From e98b74ff2e0ebac9740dc42624e86ff385cbb6b3 Mon Sep 17 00:00:00 2001 From: Ben Huson Date: Tue, 31 Aug 2021 22:25:38 +0100 Subject: [PATCH] Ensure REST methods and current subtitle check use `wps_subtitle_key` filter. --- plugin/includes/rest.php | 4 +++- plugin/includes/subtitle.php | 4 ++-- plugin/plugin.php | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/plugin/includes/rest.php b/plugin/includes/rest.php index 4d37e42..95793c0 100644 --- a/plugin/includes/rest.php +++ b/plugin/includes/rest.php @@ -77,7 +77,9 @@ public function get_rest_field( $object, $field_name, $request ) { */ public function update_rest_field( $value, $object ) { - update_post_meta( $object->ID, 'wps_subtitle', wp_kses_post( $value ) ); + $subtitle = new WP_Subtitle( $object->ID ); + + $subtitle->update_subtitle( wp_kses_post( $value ) ); } diff --git a/plugin/includes/subtitle.php b/plugin/includes/subtitle.php index af73b1f..b7496c7 100644 --- a/plugin/includes/subtitle.php +++ b/plugin/includes/subtitle.php @@ -133,7 +133,7 @@ public function update_subtitle( $subtitle ) { */ public function is_current_subtitle( $subtitle ) { - return $subtitle === get_metadata( 'post', $this->post_id, 'wps_subtitle', true ); + return $subtitle === get_metadata( 'post', $this->post_id, $this->get_post_meta_key(), true ); } @@ -144,7 +144,7 @@ public function is_current_subtitle( $subtitle ) { * * @return string The subtitle meta key. */ - private function get_post_meta_key() { + public function get_post_meta_key() { return apply_filters( 'wps_subtitle_key', 'wps_subtitle', $this->post_id ); diff --git a/plugin/plugin.php b/plugin/plugin.php index 09f193d..a0bee9d 100644 --- a/plugin/plugin.php +++ b/plugin/plugin.php @@ -199,7 +199,9 @@ public static function _get_post_meta( $post = 0 ) { */ public static function _get_post_meta_key( $post_id = 0 ) { - return apply_filters( 'wps_subtitle_key', 'wps_subtitle', $post_id ); + $subtitle = new WP_Subtitle( $post_id ); + + return $subtitle->get_post_meta_key(); }