@@ -6,64 +6,64 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Rest_Field { |
| 8 | 8 | |
| 9 | - public function __construct() { |
|
| 10 | - add_action( 'rest_api_init', array( $this, 'register_rest_field' ) ); |
|
| 11 | - } |
|
| 9 | + public function __construct() { |
|
| 10 | + add_action( 'rest_api_init', array( $this, 'register_rest_field' ) ); |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - public function register_rest_field() { |
|
| 13 | + public function register_rest_field() { |
|
| 14 | 14 | |
| 15 | - if ( ! function_exists( 'register_rest_field' ) ) { |
|
| 16 | - return; |
|
| 17 | - } |
|
| 15 | + if ( ! function_exists( 'register_rest_field' ) ) { |
|
| 16 | + return; |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | 19 | |
| 20 | - $post_types = Wordlift_Entity_Service::valid_entity_post_types(); |
|
| 20 | + $post_types = Wordlift_Entity_Service::valid_entity_post_types(); |
|
| 21 | 21 | |
| 22 | - foreach ( $post_types as $post_type ) { |
|
| 22 | + foreach ( $post_types as $post_type ) { |
|
| 23 | 23 | |
| 24 | - register_rest_field( |
|
| 25 | - $post_type, |
|
| 26 | - \Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY, |
|
| 27 | - array( |
|
| 28 | - 'get_callback' => array( $this, 'get_value' ), |
|
| 29 | - 'update_callback' => array( $this, 'update_value' ) |
|
| 30 | - ) |
|
| 31 | - ); |
|
| 24 | + register_rest_field( |
|
| 25 | + $post_type, |
|
| 26 | + \Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY, |
|
| 27 | + array( |
|
| 28 | + 'get_callback' => array( $this, 'get_value' ), |
|
| 29 | + 'update_callback' => array( $this, 'update_value' ) |
|
| 30 | + ) |
|
| 31 | + ); |
|
| 32 | 32 | |
| 33 | - } |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | 35 | |
| 36 | - } |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @param $meta_values array |
|
| 40 | - * @param $post \WP_Post |
|
| 41 | - * @param $meta_key string |
|
| 42 | - */ |
|
| 43 | - public function update_value( $meta_values, $post, $meta_key ) { |
|
| 38 | + /** |
|
| 39 | + * @param $meta_values array |
|
| 40 | + * @param $post \WP_Post |
|
| 41 | + * @param $meta_key string |
|
| 42 | + */ |
|
| 43 | + public function update_value( $meta_values, $post, $meta_key ) { |
|
| 44 | 44 | |
| 45 | - if ( ! is_array( $meta_values ) ) { |
|
| 46 | - return; |
|
| 47 | - } |
|
| 45 | + if ( ! is_array( $meta_values ) ) { |
|
| 46 | + return; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - $entity_service = Wordlift_Entity_Service::get_instance(); |
|
| 49 | + $entity_service = Wordlift_Entity_Service::get_instance(); |
|
| 50 | 50 | |
| 51 | - $entity_service->set_alternative_labels( $post->ID, $meta_values ); |
|
| 52 | - } |
|
| 51 | + $entity_service->set_alternative_labels( $post->ID, $meta_values ); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @param $post array Post array. |
|
| 56 | - * |
|
| 57 | - * @return array|mixed |
|
| 58 | - */ |
|
| 59 | - public function get_value( $post ) { |
|
| 60 | - $data = get_post_meta( (int) $post["id"], \Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY ); |
|
| 61 | - if ( ! is_array( $data ) ) { |
|
| 62 | - return array(); |
|
| 63 | - } |
|
| 54 | + /** |
|
| 55 | + * @param $post array Post array. |
|
| 56 | + * |
|
| 57 | + * @return array|mixed |
|
| 58 | + */ |
|
| 59 | + public function get_value( $post ) { |
|
| 60 | + $data = get_post_meta( (int) $post["id"], \Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY ); |
|
| 61 | + if ( ! is_array( $data ) ) { |
|
| 62 | + return array(); |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - return $data; |
|
| 66 | - } |
|
| 65 | + return $data; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | 68 | |
| 69 | 69 | } |
| 70 | 70 | \ No newline at end of file |
@@ -7,26 +7,26 @@ discard block |
||
| 7 | 7 | class Rest_Field { |
| 8 | 8 | |
| 9 | 9 | public function __construct() { |
| 10 | - add_action( 'rest_api_init', array( $this, 'register_rest_field' ) ); |
|
| 10 | + add_action('rest_api_init', array($this, 'register_rest_field')); |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | public function register_rest_field() { |
| 14 | 14 | |
| 15 | - if ( ! function_exists( 'register_rest_field' ) ) { |
|
| 15 | + if ( ! function_exists('register_rest_field')) { |
|
| 16 | 16 | return; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | |
| 20 | 20 | $post_types = Wordlift_Entity_Service::valid_entity_post_types(); |
| 21 | 21 | |
| 22 | - foreach ( $post_types as $post_type ) { |
|
| 22 | + foreach ($post_types as $post_type) { |
|
| 23 | 23 | |
| 24 | 24 | register_rest_field( |
| 25 | 25 | $post_type, |
| 26 | 26 | \Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY, |
| 27 | 27 | array( |
| 28 | - 'get_callback' => array( $this, 'get_value' ), |
|
| 29 | - 'update_callback' => array( $this, 'update_value' ) |
|
| 28 | + 'get_callback' => array($this, 'get_value'), |
|
| 29 | + 'update_callback' => array($this, 'update_value') |
|
| 30 | 30 | ) |
| 31 | 31 | ); |
| 32 | 32 | |
@@ -40,15 +40,15 @@ discard block |
||
| 40 | 40 | * @param $post \WP_Post |
| 41 | 41 | * @param $meta_key string |
| 42 | 42 | */ |
| 43 | - public function update_value( $meta_values, $post, $meta_key ) { |
|
| 43 | + public function update_value($meta_values, $post, $meta_key) { |
|
| 44 | 44 | |
| 45 | - if ( ! is_array( $meta_values ) ) { |
|
| 45 | + if ( ! is_array($meta_values)) { |
|
| 46 | 46 | return; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | $entity_service = Wordlift_Entity_Service::get_instance(); |
| 50 | 50 | |
| 51 | - $entity_service->set_alternative_labels( $post->ID, $meta_values ); |
|
| 51 | + $entity_service->set_alternative_labels($post->ID, $meta_values); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -56,9 +56,9 @@ discard block |
||
| 56 | 56 | * |
| 57 | 57 | * @return array|mixed |
| 58 | 58 | */ |
| 59 | - public function get_value( $post ) { |
|
| 60 | - $data = get_post_meta( (int) $post["id"], \Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY ); |
|
| 61 | - if ( ! is_array( $data ) ) { |
|
| 59 | + public function get_value($post) { |
|
| 60 | + $data = get_post_meta((int) $post["id"], \Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY); |
|
| 61 | + if ( ! is_array($data)) { |
|
| 62 | 62 | return array(); |
| 63 | 63 | } |
| 64 | 64 | |