@@ -19,12 +19,12 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | class Wordlift_Metabox_Field_Multiline extends Wl_Metabox_Field { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @inheritdoc |
|
| 24 | - */ |
|
| 25 | - public function html_input( $text ) { |
|
| 26 | - @ob_start(); |
|
| 27 | - ?> |
|
| 22 | + /** |
|
| 23 | + * @inheritdoc |
|
| 24 | + */ |
|
| 25 | + public function html_input( $text ) { |
|
| 26 | + @ob_start(); |
|
| 27 | + ?> |
|
| 28 | 28 | <div class="wl-input-wrapper"> |
| 29 | 29 | <textarea |
| 30 | 30 | id="<?php echo esc_attr( $this->meta_name ) ?>" |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | </button> |
| 39 | 39 | </div> |
| 40 | 40 | <?php |
| 41 | - $html = ob_get_clean(); |
|
| 41 | + $html = ob_get_clean(); |
|
| 42 | 42 | |
| 43 | - return $html; |
|
| 44 | - } |
|
| 43 | + return $html; |
|
| 44 | + } |
|
| 45 | 45 | } |
@@ -22,19 +22,19 @@ |
||
| 22 | 22 | /** |
| 23 | 23 | * @inheritdoc |
| 24 | 24 | */ |
| 25 | - public function html_input( $text ) { |
|
| 25 | + public function html_input($text) { |
|
| 26 | 26 | @ob_start(); |
| 27 | 27 | ?> |
| 28 | 28 | <div class="wl-input-wrapper"> |
| 29 | 29 | <textarea |
| 30 | - id="<?php echo esc_attr( $this->meta_name ) ?>" |
|
| 31 | - class="<?php echo esc_attr( $this->meta_name ) ?>" |
|
| 32 | - name="wl_metaboxes[<?php echo esc_attr( $this->meta_name ); ?>][]" |
|
| 30 | + id="<?php echo esc_attr($this->meta_name) ?>" |
|
| 31 | + class="<?php echo esc_attr($this->meta_name) ?>" |
|
| 32 | + name="wl_metaboxes[<?php echo esc_attr($this->meta_name); ?>][]" |
|
| 33 | 33 | style="width:88%" |
| 34 | - ><?php echo esc_textarea( $text ) ?></textarea> |
|
| 34 | + ><?php echo esc_textarea($text) ?></textarea> |
|
| 35 | 35 | |
| 36 | 36 | <button class="button wl-remove-input wl-button" type="button"> |
| 37 | - <?php esc_html_e( 'Remove', 'wordlift' ); ?> |
|
| 37 | + <?php esc_html_e('Remove', 'wordlift'); ?> |
|
| 38 | 38 | </button> |
| 39 | 39 | </div> |
| 40 | 40 | <?php |
@@ -7,57 +7,57 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | class Wl_Metabox_Field_Coordinates extends Wl_Metabox_Field { |
| 9 | 9 | |
| 10 | - public function __construct( $args, $id, $type ) { |
|
| 11 | - |
|
| 12 | - // Just set up the necessary info without calling the parent constructor. |
|
| 13 | - // TODO: write a parent class for grouped properties |
|
| 14 | - parent::__construct( $args, $id, $type ); |
|
| 15 | - |
|
| 16 | - // we use 'coordinates' to namespace the Field in $_POST data. |
|
| 17 | - // In the DB the correct meta names will be used. |
|
| 18 | - $this->meta_name = 'coordinates'; |
|
| 19 | - } |
|
| 20 | - |
|
| 21 | - public function get_data() { |
|
| 22 | - $instance = Store_Factory::get_instance( $this->type ); |
|
| 23 | - $latitude = $instance::get_data( $this->id, Wordlift_Schema_Service::FIELD_GEO_LATITUDE ); |
|
| 24 | - $longitude = $instance::get_data( $this->id, Wordlift_Schema_Service::FIELD_GEO_LONGITUDE ); |
|
| 25 | - $this->data = array( |
|
| 26 | - 'latitude' => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '', |
|
| 27 | - 'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '', |
|
| 28 | - ); |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - public function html() { |
|
| 32 | - |
|
| 33 | - // Open main <div> for the Field |
|
| 34 | - $html = $this->html_wrapper_open(); |
|
| 35 | - |
|
| 36 | - // Label |
|
| 37 | - $html .= '<h3>coordinates</h3>'; |
|
| 38 | - |
|
| 39 | - // print nonce |
|
| 40 | - $html .= $this->html_nonce(); |
|
| 41 | - |
|
| 42 | - // Get coordinates |
|
| 43 | - $data = $this->data; |
|
| 44 | - // TODO: We temporary use here 0,0 as default coordinates for the marker, but if no coordinates are given we |
|
| 45 | - // want to use the current user location for the marker. |
|
| 46 | - $coordinates = ( ! empty( $data['latitude'] ) && ! empty( $data['longitude'] ) ? sprintf( '[%f,%f]', $data['latitude'], $data['longitude'] ) : '[0,0]' ); |
|
| 47 | - $map_init = '[0,0]' === $coordinates |
|
| 48 | - ? 'locate( {setView: true, maxZoom: 16} )' |
|
| 49 | - : sprintf( "setView( [%f,%f], 9 )", $data['latitude'], $data['longitude'] ); |
|
| 50 | - |
|
| 51 | - // Print input fields |
|
| 52 | - $html .= '<label for="wl_place_lat">' . __( 'Latitude', 'wordlift' ) . '</label>'; |
|
| 53 | - $html .= '<input type="text" id="wl_place_lat" name="wl_metaboxes[coordinates][]" value="' . $data['latitude'] . '" style="width:100%" />'; |
|
| 54 | - |
|
| 55 | - $html .= '<label for="wl_place_lon">' . __( 'Longitude', 'wordlift' ) . '</label>'; |
|
| 56 | - $html .= '<input type="text" id="wl_place_lon" name="wl_metaboxes[coordinates][]" value="' . $data['longitude'] . '" style="width:100%" />'; |
|
| 57 | - |
|
| 58 | - // Show Leaflet map to pick coordinates |
|
| 59 | - $element_id = uniqid( 'wl-geo-map-' ); |
|
| 60 | - $html .= <<<EOF |
|
| 10 | + public function __construct( $args, $id, $type ) { |
|
| 11 | + |
|
| 12 | + // Just set up the necessary info without calling the parent constructor. |
|
| 13 | + // TODO: write a parent class for grouped properties |
|
| 14 | + parent::__construct( $args, $id, $type ); |
|
| 15 | + |
|
| 16 | + // we use 'coordinates' to namespace the Field in $_POST data. |
|
| 17 | + // In the DB the correct meta names will be used. |
|
| 18 | + $this->meta_name = 'coordinates'; |
|
| 19 | + } |
|
| 20 | + |
|
| 21 | + public function get_data() { |
|
| 22 | + $instance = Store_Factory::get_instance( $this->type ); |
|
| 23 | + $latitude = $instance::get_data( $this->id, Wordlift_Schema_Service::FIELD_GEO_LATITUDE ); |
|
| 24 | + $longitude = $instance::get_data( $this->id, Wordlift_Schema_Service::FIELD_GEO_LONGITUDE ); |
|
| 25 | + $this->data = array( |
|
| 26 | + 'latitude' => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '', |
|
| 27 | + 'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '', |
|
| 28 | + ); |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + public function html() { |
|
| 32 | + |
|
| 33 | + // Open main <div> for the Field |
|
| 34 | + $html = $this->html_wrapper_open(); |
|
| 35 | + |
|
| 36 | + // Label |
|
| 37 | + $html .= '<h3>coordinates</h3>'; |
|
| 38 | + |
|
| 39 | + // print nonce |
|
| 40 | + $html .= $this->html_nonce(); |
|
| 41 | + |
|
| 42 | + // Get coordinates |
|
| 43 | + $data = $this->data; |
|
| 44 | + // TODO: We temporary use here 0,0 as default coordinates for the marker, but if no coordinates are given we |
|
| 45 | + // want to use the current user location for the marker. |
|
| 46 | + $coordinates = ( ! empty( $data['latitude'] ) && ! empty( $data['longitude'] ) ? sprintf( '[%f,%f]', $data['latitude'], $data['longitude'] ) : '[0,0]' ); |
|
| 47 | + $map_init = '[0,0]' === $coordinates |
|
| 48 | + ? 'locate( {setView: true, maxZoom: 16} )' |
|
| 49 | + : sprintf( "setView( [%f,%f], 9 )", $data['latitude'], $data['longitude'] ); |
|
| 50 | + |
|
| 51 | + // Print input fields |
|
| 52 | + $html .= '<label for="wl_place_lat">' . __( 'Latitude', 'wordlift' ) . '</label>'; |
|
| 53 | + $html .= '<input type="text" id="wl_place_lat" name="wl_metaboxes[coordinates][]" value="' . $data['latitude'] . '" style="width:100%" />'; |
|
| 54 | + |
|
| 55 | + $html .= '<label for="wl_place_lon">' . __( 'Longitude', 'wordlift' ) . '</label>'; |
|
| 56 | + $html .= '<input type="text" id="wl_place_lon" name="wl_metaboxes[coordinates][]" value="' . $data['longitude'] . '" style="width:100%" />'; |
|
| 57 | + |
|
| 58 | + // Show Leaflet map to pick coordinates |
|
| 59 | + $element_id = uniqid( 'wl-geo-map-' ); |
|
| 60 | + $html .= <<<EOF |
|
| 61 | 61 | |
| 62 | 62 | <div id="$element_id"></div> |
| 63 | 63 | |
@@ -91,42 +91,42 @@ discard block |
||
| 91 | 91 | EOF; |
| 92 | 92 | |
| 93 | 93 | |
| 94 | - $html .= $this->html_wrapper_close(); |
|
| 94 | + $html .= $this->html_wrapper_close(); |
|
| 95 | 95 | |
| 96 | - return $html; |
|
| 97 | - } |
|
| 96 | + return $html; |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - public function save_data( $coords ) { |
|
| 99 | + public function save_data( $coords ) { |
|
| 100 | 100 | |
| 101 | - $data = $this->sanitize_data( $coords ); |
|
| 101 | + $data = $this->sanitize_data( $coords ); |
|
| 102 | 102 | |
| 103 | - $instance = Store_Factory::get_instance( $this->type ); |
|
| 104 | - // Take away old values |
|
| 105 | - $instance::delete_meta( $this->id, Wordlift_Schema_Service::FIELD_GEO_LATITUDE ); |
|
| 106 | - $instance::delete_meta( $this->id, Wordlift_Schema_Service::FIELD_GEO_LONGITUDE ); |
|
| 103 | + $instance = Store_Factory::get_instance( $this->type ); |
|
| 104 | + // Take away old values |
|
| 105 | + $instance::delete_meta( $this->id, Wordlift_Schema_Service::FIELD_GEO_LATITUDE ); |
|
| 106 | + $instance::delete_meta( $this->id, Wordlift_Schema_Service::FIELD_GEO_LONGITUDE ); |
|
| 107 | 107 | |
| 108 | - $latitude = $data[0]; |
|
| 109 | - $longitude = $data[1]; |
|
| 110 | - // insert new coordinate values |
|
| 111 | - if ( ! empty( $latitude ) && ! empty( $longitude ) ) { |
|
| 112 | - $instance::add_meta( $this->id, Wordlift_Schema_Service::FIELD_GEO_LATITUDE, $latitude, true ); |
|
| 113 | - $instance::add_meta( $this->id, Wordlift_Schema_Service::FIELD_GEO_LONGITUDE, $longitude, true ); |
|
| 114 | - } |
|
| 108 | + $latitude = $data[0]; |
|
| 109 | + $longitude = $data[1]; |
|
| 110 | + // insert new coordinate values |
|
| 111 | + if ( ! empty( $latitude ) && ! empty( $longitude ) ) { |
|
| 112 | + $instance::add_meta( $this->id, Wordlift_Schema_Service::FIELD_GEO_LATITUDE, $latitude, true ); |
|
| 113 | + $instance::add_meta( $this->id, Wordlift_Schema_Service::FIELD_GEO_LONGITUDE, $longitude, true ); |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - } |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * Only accept float numbers |
|
| 120 | - */ |
|
| 121 | - public function sanitize_data_filter( $value ) { |
|
| 118 | + /** |
|
| 119 | + * Only accept float numbers |
|
| 120 | + */ |
|
| 121 | + public function sanitize_data_filter( $value ) { |
|
| 122 | 122 | |
| 123 | - // DO NOT set latitude/longitude to 0/0 as default values. It's a specific place on the globe: |
|
| 124 | - // "The zero/zero point of this system is located in the Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana." |
|
| 125 | - if ( ! is_numeric( $value ) ) { |
|
| 126 | - return ''; |
|
| 127 | - } |
|
| 123 | + // DO NOT set latitude/longitude to 0/0 as default values. It's a specific place on the globe: |
|
| 124 | + // "The zero/zero point of this system is located in the Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana." |
|
| 125 | + if ( ! is_numeric( $value ) ) { |
|
| 126 | + return ''; |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - return $value; |
|
| 130 | - } |
|
| 129 | + return $value; |
|
| 130 | + } |
|
| 131 | 131 | } |
| 132 | 132 | |
@@ -7,11 +7,11 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | class Wl_Metabox_Field_Coordinates extends Wl_Metabox_Field { |
| 9 | 9 | |
| 10 | - public function __construct( $args, $id, $type ) { |
|
| 10 | + public function __construct($args, $id, $type) { |
|
| 11 | 11 | |
| 12 | 12 | // Just set up the necessary info without calling the parent constructor. |
| 13 | 13 | // TODO: write a parent class for grouped properties |
| 14 | - parent::__construct( $args, $id, $type ); |
|
| 14 | + parent::__construct($args, $id, $type); |
|
| 15 | 15 | |
| 16 | 16 | // we use 'coordinates' to namespace the Field in $_POST data. |
| 17 | 17 | // In the DB the correct meta names will be used. |
@@ -19,12 +19,12 @@ discard block |
||
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | public function get_data() { |
| 22 | - $instance = Store_Factory::get_instance( $this->type ); |
|
| 23 | - $latitude = $instance::get_data( $this->id, Wordlift_Schema_Service::FIELD_GEO_LATITUDE ); |
|
| 24 | - $longitude = $instance::get_data( $this->id, Wordlift_Schema_Service::FIELD_GEO_LONGITUDE ); |
|
| 22 | + $instance = Store_Factory::get_instance($this->type); |
|
| 23 | + $latitude = $instance::get_data($this->id, Wordlift_Schema_Service::FIELD_GEO_LATITUDE); |
|
| 24 | + $longitude = $instance::get_data($this->id, Wordlift_Schema_Service::FIELD_GEO_LONGITUDE); |
|
| 25 | 25 | $this->data = array( |
| 26 | - 'latitude' => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '', |
|
| 27 | - 'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '', |
|
| 26 | + 'latitude' => isset($latitude[0]) && is_numeric($latitude[0]) ? $latitude[0] : '', |
|
| 27 | + 'longitude' => isset($longitude[0]) && is_numeric($longitude[0]) ? $longitude[0] : '', |
|
| 28 | 28 | ); |
| 29 | 29 | } |
| 30 | 30 | |
@@ -43,21 +43,21 @@ discard block |
||
| 43 | 43 | $data = $this->data; |
| 44 | 44 | // TODO: We temporary use here 0,0 as default coordinates for the marker, but if no coordinates are given we |
| 45 | 45 | // want to use the current user location for the marker. |
| 46 | - $coordinates = ( ! empty( $data['latitude'] ) && ! empty( $data['longitude'] ) ? sprintf( '[%f,%f]', $data['latitude'], $data['longitude'] ) : '[0,0]' ); |
|
| 46 | + $coordinates = ( ! empty($data['latitude']) && ! empty($data['longitude']) ? sprintf('[%f,%f]', $data['latitude'], $data['longitude']) : '[0,0]'); |
|
| 47 | 47 | $map_init = '[0,0]' === $coordinates |
| 48 | 48 | ? 'locate( {setView: true, maxZoom: 16} )' |
| 49 | - : sprintf( "setView( [%f,%f], 9 )", $data['latitude'], $data['longitude'] ); |
|
| 49 | + : sprintf("setView( [%f,%f], 9 )", $data['latitude'], $data['longitude']); |
|
| 50 | 50 | |
| 51 | 51 | // Print input fields |
| 52 | - $html .= '<label for="wl_place_lat">' . __( 'Latitude', 'wordlift' ) . '</label>'; |
|
| 53 | - $html .= '<input type="text" id="wl_place_lat" name="wl_metaboxes[coordinates][]" value="' . $data['latitude'] . '" style="width:100%" />'; |
|
| 52 | + $html .= '<label for="wl_place_lat">'.__('Latitude', 'wordlift').'</label>'; |
|
| 53 | + $html .= '<input type="text" id="wl_place_lat" name="wl_metaboxes[coordinates][]" value="'.$data['latitude'].'" style="width:100%" />'; |
|
| 54 | 54 | |
| 55 | - $html .= '<label for="wl_place_lon">' . __( 'Longitude', 'wordlift' ) . '</label>'; |
|
| 56 | - $html .= '<input type="text" id="wl_place_lon" name="wl_metaboxes[coordinates][]" value="' . $data['longitude'] . '" style="width:100%" />'; |
|
| 55 | + $html .= '<label for="wl_place_lon">'.__('Longitude', 'wordlift').'</label>'; |
|
| 56 | + $html .= '<input type="text" id="wl_place_lon" name="wl_metaboxes[coordinates][]" value="'.$data['longitude'].'" style="width:100%" />'; |
|
| 57 | 57 | |
| 58 | 58 | // Show Leaflet map to pick coordinates |
| 59 | - $element_id = uniqid( 'wl-geo-map-' ); |
|
| 60 | - $html .= <<<EOF |
|
| 59 | + $element_id = uniqid('wl-geo-map-'); |
|
| 60 | + $html .= <<<EOF |
|
| 61 | 61 | |
| 62 | 62 | <div id="$element_id"></div> |
| 63 | 63 | |
@@ -96,21 +96,21 @@ discard block |
||
| 96 | 96 | return $html; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - public function save_data( $coords ) { |
|
| 99 | + public function save_data($coords) { |
|
| 100 | 100 | |
| 101 | - $data = $this->sanitize_data( $coords ); |
|
| 101 | + $data = $this->sanitize_data($coords); |
|
| 102 | 102 | |
| 103 | - $instance = Store_Factory::get_instance( $this->type ); |
|
| 103 | + $instance = Store_Factory::get_instance($this->type); |
|
| 104 | 104 | // Take away old values |
| 105 | - $instance::delete_meta( $this->id, Wordlift_Schema_Service::FIELD_GEO_LATITUDE ); |
|
| 106 | - $instance::delete_meta( $this->id, Wordlift_Schema_Service::FIELD_GEO_LONGITUDE ); |
|
| 105 | + $instance::delete_meta($this->id, Wordlift_Schema_Service::FIELD_GEO_LATITUDE); |
|
| 106 | + $instance::delete_meta($this->id, Wordlift_Schema_Service::FIELD_GEO_LONGITUDE); |
|
| 107 | 107 | |
| 108 | 108 | $latitude = $data[0]; |
| 109 | 109 | $longitude = $data[1]; |
| 110 | 110 | // insert new coordinate values |
| 111 | - if ( ! empty( $latitude ) && ! empty( $longitude ) ) { |
|
| 112 | - $instance::add_meta( $this->id, Wordlift_Schema_Service::FIELD_GEO_LATITUDE, $latitude, true ); |
|
| 113 | - $instance::add_meta( $this->id, Wordlift_Schema_Service::FIELD_GEO_LONGITUDE, $longitude, true ); |
|
| 111 | + if ( ! empty($latitude) && ! empty($longitude)) { |
|
| 112 | + $instance::add_meta($this->id, Wordlift_Schema_Service::FIELD_GEO_LATITUDE, $latitude, true); |
|
| 113 | + $instance::add_meta($this->id, Wordlift_Schema_Service::FIELD_GEO_LONGITUDE, $longitude, true); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | } |
@@ -118,11 +118,11 @@ discard block |
||
| 118 | 118 | /** |
| 119 | 119 | * Only accept float numbers |
| 120 | 120 | */ |
| 121 | - public function sanitize_data_filter( $value ) { |
|
| 121 | + public function sanitize_data_filter($value) { |
|
| 122 | 122 | |
| 123 | 123 | // DO NOT set latitude/longitude to 0/0 as default values. It's a specific place on the globe: |
| 124 | 124 | // "The zero/zero point of this system is located in the Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana." |
| 125 | - if ( ! is_numeric( $value ) ) { |
|
| 125 | + if ( ! is_numeric($value)) { |
|
| 126 | 126 | return ''; |
| 127 | 127 | } |
| 128 | 128 | |
@@ -8,12 +8,12 @@ |
||
| 8 | 8 | |
| 9 | 9 | interface Store { |
| 10 | 10 | |
| 11 | - public static function get_data( $post_id, $meta_key ); |
|
| 11 | + public static function get_data( $post_id, $meta_key ); |
|
| 12 | 12 | |
| 13 | - public static function save_data( $post_id, $meta_key, $cardinality, $values ); |
|
| 13 | + public static function save_data( $post_id, $meta_key, $cardinality, $values ); |
|
| 14 | 14 | |
| 15 | - public static function delete_meta( $id, $meta_key ); |
|
| 15 | + public static function delete_meta( $id, $meta_key ); |
|
| 16 | 16 | |
| 17 | - public static function add_meta( $id, $meta_key, $meta_value, $is_unique ); |
|
| 17 | + public static function add_meta( $id, $meta_key, $meta_value, $is_unique ); |
|
| 18 | 18 | |
| 19 | 19 | } |
| 20 | 20 | \ No newline at end of file |
@@ -8,12 +8,12 @@ |
||
| 8 | 8 | |
| 9 | 9 | interface Store { |
| 10 | 10 | |
| 11 | - public static function get_data( $post_id, $meta_key ); |
|
| 11 | + public static function get_data($post_id, $meta_key); |
|
| 12 | 12 | |
| 13 | - public static function save_data( $post_id, $meta_key, $cardinality, $values ); |
|
| 13 | + public static function save_data($post_id, $meta_key, $cardinality, $values); |
|
| 14 | 14 | |
| 15 | - public static function delete_meta( $id, $meta_key ); |
|
| 15 | + public static function delete_meta($id, $meta_key); |
|
| 16 | 16 | |
| 17 | - public static function add_meta( $id, $meta_key, $meta_value, $is_unique ); |
|
| 17 | + public static function add_meta($id, $meta_key, $meta_value, $is_unique); |
|
| 18 | 18 | |
| 19 | 19 | } |
| 20 | 20 | \ No newline at end of file |
@@ -9,31 +9,31 @@ |
||
| 9 | 9 | |
| 10 | 10 | class Term_Store implements Store { |
| 11 | 11 | |
| 12 | - public static function get_data( $term_id, $meta_key ) { |
|
| 13 | - return get_term_meta( $term_id, $meta_key ); |
|
| 14 | - } |
|
| 12 | + public static function get_data( $term_id, $meta_key ) { |
|
| 13 | + return get_term_meta( $term_id, $meta_key ); |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | - public static function save_data( $term_id, $meta_key, $cardinality, $values ) { |
|
| 16 | + public static function save_data( $term_id, $meta_key, $cardinality, $values ) { |
|
| 17 | 17 | |
| 18 | - // Take away old values. |
|
| 19 | - delete_term_meta( $term_id, $meta_key ); |
|
| 18 | + // Take away old values. |
|
| 19 | + delete_term_meta( $term_id, $meta_key ); |
|
| 20 | 20 | |
| 21 | - // insert new values, respecting cardinality. |
|
| 22 | - $single = ( 1 === $cardinality ); |
|
| 23 | - foreach ( $values as $value ) { |
|
| 24 | - // To avoid duplicate values |
|
| 25 | - delete_term_meta( $term_id, $meta_key, $value ); |
|
| 26 | - add_term_meta( $term_id, $meta_key, $value, $single ); |
|
| 27 | - } |
|
| 21 | + // insert new values, respecting cardinality. |
|
| 22 | + $single = ( 1 === $cardinality ); |
|
| 23 | + foreach ( $values as $value ) { |
|
| 24 | + // To avoid duplicate values |
|
| 25 | + delete_term_meta( $term_id, $meta_key, $value ); |
|
| 26 | + add_term_meta( $term_id, $meta_key, $value, $single ); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - } |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - public static function delete_meta( $id, $meta_key ) { |
|
| 32 | - delete_term_meta( $id, $meta_key ); |
|
| 33 | - } |
|
| 31 | + public static function delete_meta( $id, $meta_key ) { |
|
| 32 | + delete_term_meta( $id, $meta_key ); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | 35 | |
| 36 | - public static function add_meta( $id, $meta_key, $meta_value, $is_unique ) { |
|
| 37 | - add_term_meta( $id, $meta_key, $meta_value, $is_unique ); |
|
| 38 | - } |
|
| 36 | + public static function add_meta( $id, $meta_key, $meta_value, $is_unique ) { |
|
| 37 | + add_term_meta( $id, $meta_key, $meta_value, $is_unique ); |
|
| 38 | + } |
|
| 39 | 39 | } |
| 40 | 40 | \ No newline at end of file |
@@ -9,31 +9,31 @@ |
||
| 9 | 9 | |
| 10 | 10 | class Term_Store implements Store { |
| 11 | 11 | |
| 12 | - public static function get_data( $term_id, $meta_key ) { |
|
| 13 | - return get_term_meta( $term_id, $meta_key ); |
|
| 12 | + public static function get_data($term_id, $meta_key) { |
|
| 13 | + return get_term_meta($term_id, $meta_key); |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - public static function save_data( $term_id, $meta_key, $cardinality, $values ) { |
|
| 16 | + public static function save_data($term_id, $meta_key, $cardinality, $values) { |
|
| 17 | 17 | |
| 18 | 18 | // Take away old values. |
| 19 | - delete_term_meta( $term_id, $meta_key ); |
|
| 19 | + delete_term_meta($term_id, $meta_key); |
|
| 20 | 20 | |
| 21 | 21 | // insert new values, respecting cardinality. |
| 22 | - $single = ( 1 === $cardinality ); |
|
| 23 | - foreach ( $values as $value ) { |
|
| 22 | + $single = (1 === $cardinality); |
|
| 23 | + foreach ($values as $value) { |
|
| 24 | 24 | // To avoid duplicate values |
| 25 | - delete_term_meta( $term_id, $meta_key, $value ); |
|
| 26 | - add_term_meta( $term_id, $meta_key, $value, $single ); |
|
| 25 | + delete_term_meta($term_id, $meta_key, $value); |
|
| 26 | + add_term_meta($term_id, $meta_key, $value, $single); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public static function delete_meta( $id, $meta_key ) { |
|
| 32 | - delete_term_meta( $id, $meta_key ); |
|
| 31 | + public static function delete_meta($id, $meta_key) { |
|
| 32 | + delete_term_meta($id, $meta_key); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | |
| 36 | - public static function add_meta( $id, $meta_key, $meta_value, $is_unique ) { |
|
| 37 | - add_term_meta( $id, $meta_key, $meta_value, $is_unique ); |
|
| 36 | + public static function add_meta($id, $meta_key, $meta_value, $is_unique) { |
|
| 37 | + add_term_meta($id, $meta_key, $meta_value, $is_unique); |
|
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | \ No newline at end of file |
@@ -9,30 +9,30 @@ |
||
| 9 | 9 | |
| 10 | 10 | class Post_Store implements Store { |
| 11 | 11 | |
| 12 | - public static function get_data( $post_id, $meta_key ) { |
|
| 13 | - return get_post_meta( $post_id, $meta_key ); |
|
| 14 | - } |
|
| 15 | - |
|
| 16 | - public static function save_data( $post_id, $meta_key, $cardinality, $values ) { |
|
| 17 | - $entity_id = $post_id; |
|
| 18 | - // Take away old values. |
|
| 19 | - delete_post_meta( $entity_id, $meta_key ); |
|
| 20 | - // insert new values, respecting cardinality. |
|
| 21 | - $single = ( 1 === $cardinality ); |
|
| 22 | - foreach ( $values as $value ) { |
|
| 23 | - // To avoid duplicate values |
|
| 24 | - delete_post_meta( $entity_id, $meta_key, $value ); |
|
| 25 | - $meta_id = add_post_meta( $entity_id, $meta_key, $value, $single ); |
|
| 26 | - } |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - |
|
| 30 | - public static function delete_meta( $id, $meta_key ) { |
|
| 31 | - delete_post_meta( $id, $meta_key ); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - |
|
| 35 | - public static function add_meta( $id, $meta_key, $meta_value, $is_unique ) { |
|
| 36 | - add_post_meta( $id, $meta_key, $meta_value, $is_unique ); |
|
| 37 | - } |
|
| 12 | + public static function get_data( $post_id, $meta_key ) { |
|
| 13 | + return get_post_meta( $post_id, $meta_key ); |
|
| 14 | + } |
|
| 15 | + |
|
| 16 | + public static function save_data( $post_id, $meta_key, $cardinality, $values ) { |
|
| 17 | + $entity_id = $post_id; |
|
| 18 | + // Take away old values. |
|
| 19 | + delete_post_meta( $entity_id, $meta_key ); |
|
| 20 | + // insert new values, respecting cardinality. |
|
| 21 | + $single = ( 1 === $cardinality ); |
|
| 22 | + foreach ( $values as $value ) { |
|
| 23 | + // To avoid duplicate values |
|
| 24 | + delete_post_meta( $entity_id, $meta_key, $value ); |
|
| 25 | + $meta_id = add_post_meta( $entity_id, $meta_key, $value, $single ); |
|
| 26 | + } |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + |
|
| 30 | + public static function delete_meta( $id, $meta_key ) { |
|
| 31 | + delete_post_meta( $id, $meta_key ); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + |
|
| 35 | + public static function add_meta( $id, $meta_key, $meta_value, $is_unique ) { |
|
| 36 | + add_post_meta( $id, $meta_key, $meta_value, $is_unique ); |
|
| 37 | + } |
|
| 38 | 38 | } |
| 39 | 39 | \ No newline at end of file |
@@ -9,30 +9,30 @@ |
||
| 9 | 9 | |
| 10 | 10 | class Post_Store implements Store { |
| 11 | 11 | |
| 12 | - public static function get_data( $post_id, $meta_key ) { |
|
| 13 | - return get_post_meta( $post_id, $meta_key ); |
|
| 12 | + public static function get_data($post_id, $meta_key) { |
|
| 13 | + return get_post_meta($post_id, $meta_key); |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - public static function save_data( $post_id, $meta_key, $cardinality, $values ) { |
|
| 16 | + public static function save_data($post_id, $meta_key, $cardinality, $values) { |
|
| 17 | 17 | $entity_id = $post_id; |
| 18 | 18 | // Take away old values. |
| 19 | - delete_post_meta( $entity_id, $meta_key ); |
|
| 19 | + delete_post_meta($entity_id, $meta_key); |
|
| 20 | 20 | // insert new values, respecting cardinality. |
| 21 | - $single = ( 1 === $cardinality ); |
|
| 22 | - foreach ( $values as $value ) { |
|
| 21 | + $single = (1 === $cardinality); |
|
| 22 | + foreach ($values as $value) { |
|
| 23 | 23 | // To avoid duplicate values |
| 24 | - delete_post_meta( $entity_id, $meta_key, $value ); |
|
| 25 | - $meta_id = add_post_meta( $entity_id, $meta_key, $value, $single ); |
|
| 24 | + delete_post_meta($entity_id, $meta_key, $value); |
|
| 25 | + $meta_id = add_post_meta($entity_id, $meta_key, $value, $single); |
|
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | |
| 30 | - public static function delete_meta( $id, $meta_key ) { |
|
| 31 | - delete_post_meta( $id, $meta_key ); |
|
| 30 | + public static function delete_meta($id, $meta_key) { |
|
| 31 | + delete_post_meta($id, $meta_key); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | |
| 35 | - public static function add_meta( $id, $meta_key, $meta_value, $is_unique ) { |
|
| 36 | - add_post_meta( $id, $meta_key, $meta_value, $is_unique ); |
|
| 35 | + public static function add_meta($id, $meta_key, $meta_value, $is_unique) { |
|
| 36 | + add_post_meta($id, $meta_key, $meta_value, $is_unique); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | \ No newline at end of file |
@@ -13,20 +13,20 @@ |
||
| 13 | 13 | class Store_Factory { |
| 14 | 14 | |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * @param $type |
|
| 18 | - * |
|
| 19 | - * @return Store |
|
| 20 | - */ |
|
| 21 | - public static function get_instance( $type ) { |
|
| 16 | + /** |
|
| 17 | + * @param $type |
|
| 18 | + * |
|
| 19 | + * @return Store |
|
| 20 | + */ |
|
| 21 | + public static function get_instance( $type ) { |
|
| 22 | 22 | |
| 23 | - if ( Object_Type_Enum::POST === $type ) { |
|
| 24 | - return new Post_Store(); |
|
| 25 | - } |
|
| 26 | - else if ( Object_Type_Enum::TERM === $type) { |
|
| 27 | - return new Term_Store(); |
|
| 28 | - } |
|
| 29 | - return null; |
|
| 30 | - } |
|
| 23 | + if ( Object_Type_Enum::POST === $type ) { |
|
| 24 | + return new Post_Store(); |
|
| 25 | + } |
|
| 26 | + else if ( Object_Type_Enum::TERM === $type) { |
|
| 27 | + return new Term_Store(); |
|
| 28 | + } |
|
| 29 | + return null; |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | 32 | } |
| 33 | 33 | \ No newline at end of file |
@@ -18,12 +18,12 @@ |
||
| 18 | 18 | * |
| 19 | 19 | * @return Store |
| 20 | 20 | */ |
| 21 | - public static function get_instance( $type ) { |
|
| 21 | + public static function get_instance($type) { |
|
| 22 | 22 | |
| 23 | - if ( Object_Type_Enum::POST === $type ) { |
|
| 23 | + if (Object_Type_Enum::POST === $type) { |
|
| 24 | 24 | return new Post_Store(); |
| 25 | 25 | } |
| 26 | - else if ( Object_Type_Enum::TERM === $type) { |
|
| 26 | + else if (Object_Type_Enum::TERM === $type) { |
|
| 27 | 27 | return new Term_Store(); |
| 28 | 28 | } |
| 29 | 29 | return null; |
@@ -22,8 +22,7 @@ |
||
| 22 | 22 | |
| 23 | 23 | if ( Object_Type_Enum::POST === $type ) { |
| 24 | 24 | return new Post_Store(); |
| 25 | - } |
|
| 26 | - else if ( Object_Type_Enum::TERM === $type) { |
|
| 25 | + } else if ( Object_Type_Enum::TERM === $type) { |
|
| 27 | 26 | return new Term_Store(); |
| 28 | 27 | } |
| 29 | 28 | return null; |
@@ -18,12 +18,12 @@ discard block |
||
| 18 | 18 | * @package Wordlift |
| 19 | 19 | */ |
| 20 | 20 | class Wordlift_Metabox_Field_Integer extends Wl_Metabox_Field { |
| 21 | - /** |
|
| 22 | - * @inheritdoc |
|
| 23 | - */ |
|
| 24 | - public function html_input( $text ) { |
|
| 25 | - @ob_start(); |
|
| 26 | - ?> |
|
| 21 | + /** |
|
| 22 | + * @inheritdoc |
|
| 23 | + */ |
|
| 24 | + public function html_input( $text ) { |
|
| 25 | + @ob_start(); |
|
| 26 | + ?> |
|
| 27 | 27 | <div class="wl-input-wrapper"> |
| 28 | 28 | <input |
| 29 | 29 | type="number" |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | </div> |
| 44 | 44 | |
| 45 | 45 | <?php |
| 46 | - $html = ob_get_clean(); |
|
| 46 | + $html = ob_get_clean(); |
|
| 47 | 47 | |
| 48 | - return $html; |
|
| 49 | - } |
|
| 48 | + return $html; |
|
| 49 | + } |
|
| 50 | 50 | } |
@@ -20,22 +20,22 @@ |
||
| 20 | 20 | /** |
| 21 | 21 | * @inheritdoc |
| 22 | 22 | */ |
| 23 | - public function html_input( $text ) { |
|
| 23 | + public function html_input($text) { |
|
| 24 | 24 | @ob_start(); |
| 25 | 25 | ?> |
| 26 | 26 | <div class="wl-input-wrapper"> |
| 27 | 27 | <input |
| 28 | 28 | type="number" |
| 29 | - id="<?php echo esc_attr( $this->meta_name ); ?>" |
|
| 30 | - class="<?php echo esc_attr( $this->meta_name ); ?>" |
|
| 31 | - value="<?php echo esc_attr( $text ) ?>" |
|
| 29 | + id="<?php echo esc_attr($this->meta_name); ?>" |
|
| 30 | + class="<?php echo esc_attr($this->meta_name); ?>" |
|
| 31 | + value="<?php echo esc_attr($text) ?>" |
|
| 32 | 32 | name="wl_metaboxes[<?php echo $this->meta_name; ?>][]" |
| 33 | 33 | style="width:88%" |
| 34 | 34 | min="0" |
| 35 | 35 | /> |
| 36 | 36 | |
| 37 | 37 | <button class="button wl-remove-input wl-button" type="button"> |
| 38 | - <?php esc_html_e( 'Remove', 'wordlift' ); ?> |
|
| 38 | + <?php esc_html_e('Remove', 'wordlift'); ?> |
|
| 39 | 39 | </button> |
| 40 | 40 | |
| 41 | 41 | <div class="wl-input-notice"></div> |
@@ -20,38 +20,38 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class Wl_Metabox extends Wl_Abstract_Metabox { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * WL_Metabox constructor. |
|
| 25 | - * |
|
| 26 | - * @since 3.1.0 |
|
| 27 | - */ |
|
| 28 | - public function __construct() { |
|
| 29 | - parent::__construct(); |
|
| 30 | - /** |
|
| 31 | - * Filter: wl_feature__enable__metabox. |
|
| 32 | - * |
|
| 33 | - * @param bool whether the metabox should be shown, defaults to true. |
|
| 34 | - * |
|
| 35 | - * @return bool |
|
| 36 | - * @since 3.28.1 |
|
| 37 | - */ |
|
| 38 | - if ( apply_filters( 'wl_feature__enable__metabox', true ) ) { |
|
| 39 | - |
|
| 40 | - // Add hooks to print metaboxes and save submitted data. |
|
| 41 | - add_action( 'add_meta_boxes', array( $this, 'add_main_metabox' ) ); |
|
| 42 | - $that = $this; |
|
| 43 | - add_action( 'wl_linked_data_save_post', array( $this, 'save_form' ) ); |
|
| 44 | - |
|
| 45 | - // Enqueue js and css. |
|
| 46 | - $this->enqueue_scripts_and_styles(); |
|
| 47 | - |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - public function save_form( $post_id ) { |
|
| 53 | - $this->save_form_data( $post_id, Object_Type_Enum::POST ); |
|
| 54 | - } |
|
| 23 | + /** |
|
| 24 | + * WL_Metabox constructor. |
|
| 25 | + * |
|
| 26 | + * @since 3.1.0 |
|
| 27 | + */ |
|
| 28 | + public function __construct() { |
|
| 29 | + parent::__construct(); |
|
| 30 | + /** |
|
| 31 | + * Filter: wl_feature__enable__metabox. |
|
| 32 | + * |
|
| 33 | + * @param bool whether the metabox should be shown, defaults to true. |
|
| 34 | + * |
|
| 35 | + * @return bool |
|
| 36 | + * @since 3.28.1 |
|
| 37 | + */ |
|
| 38 | + if ( apply_filters( 'wl_feature__enable__metabox', true ) ) { |
|
| 39 | + |
|
| 40 | + // Add hooks to print metaboxes and save submitted data. |
|
| 41 | + add_action( 'add_meta_boxes', array( $this, 'add_main_metabox' ) ); |
|
| 42 | + $that = $this; |
|
| 43 | + add_action( 'wl_linked_data_save_post', array( $this, 'save_form' ) ); |
|
| 44 | + |
|
| 45 | + // Enqueue js and css. |
|
| 46 | + $this->enqueue_scripts_and_styles(); |
|
| 47 | + |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + public function save_form( $post_id ) { |
|
| 53 | + $this->save_form_data( $post_id, Object_Type_Enum::POST ); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | 56 | |
| 57 | 57 | } |
@@ -35,12 +35,12 @@ discard block |
||
| 35 | 35 | * @return bool |
| 36 | 36 | * @since 3.28.1 |
| 37 | 37 | */ |
| 38 | - if ( apply_filters( 'wl_feature__enable__metabox', true ) ) { |
|
| 38 | + if (apply_filters('wl_feature__enable__metabox', true)) { |
|
| 39 | 39 | |
| 40 | 40 | // Add hooks to print metaboxes and save submitted data. |
| 41 | - add_action( 'add_meta_boxes', array( $this, 'add_main_metabox' ) ); |
|
| 41 | + add_action('add_meta_boxes', array($this, 'add_main_metabox')); |
|
| 42 | 42 | $that = $this; |
| 43 | - add_action( 'wl_linked_data_save_post', array( $this, 'save_form' ) ); |
|
| 43 | + add_action('wl_linked_data_save_post', array($this, 'save_form')); |
|
| 44 | 44 | |
| 45 | 45 | // Enqueue js and css. |
| 46 | 46 | $this->enqueue_scripts_and_styles(); |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public function save_form( $post_id ) { |
|
| 53 | - $this->save_form_data( $post_id, Object_Type_Enum::POST ); |
|
| 52 | + public function save_form($post_id) { |
|
| 53 | + $this->save_form_data($post_id, Object_Type_Enum::POST); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | |
| 13 | 13 | class Post_Reference extends Abstract_Reference { |
| 14 | 14 | |
| 15 | - function get_type() { |
|
| 16 | - return Object_Type_Enum::POST; |
|
| 17 | - } |
|
| 15 | + function get_type() { |
|
| 16 | + return Object_Type_Enum::POST; |
|
| 17 | + } |
|
| 18 | 18 | } |
| 19 | 19 | \ No newline at end of file |