@@ -15,67 +15,67 @@ |
||
15 | 15 | |
16 | 16 | class Local_Autocomplete_Service extends Abstract_Autocomplete_Service { |
17 | 17 | |
18 | - /** |
|
19 | - * @inheritDoc |
|
20 | - */ |
|
21 | - public function query( $query, $scope, $excludes ) { |
|
22 | - global $wpdb; |
|
18 | + /** |
|
19 | + * @inheritDoc |
|
20 | + */ |
|
21 | + public function query( $query, $scope, $excludes ) { |
|
22 | + global $wpdb; |
|
23 | 23 | |
24 | - $posts = $wpdb->get_results( |
|
25 | - $wpdb->prepare( |
|
26 | - "SELECT * FROM {$wpdb->posts} p" |
|
27 | - . " INNER JOIN {$wpdb->term_relationships} tr" |
|
28 | - . ' ON tr.object_id = p.ID' |
|
29 | - . " INNER JOIN {$wpdb->term_taxonomy} tt" |
|
30 | - . ' ON tt.taxonomy = %s AND tt.term_taxonomy_id = tr.term_taxonomy_id' |
|
31 | - . " INNER JOIN {$wpdb->terms} t" |
|
32 | - . ' ON t.term_id = tt.term_id AND t.name != %s' |
|
33 | - . " LEFT OUTER JOIN {$wpdb->postmeta} pm" |
|
34 | - . ' ON pm.meta_key = %s AND pm.post_id = p.ID' |
|
35 | - . " WHERE p.post_type IN ( '" . implode( "', '", array_map( 'esc_sql', Wordlift_Entity_Service::valid_entity_post_types() ) ) . "' )" // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.PreparedSQLPlaceholders.QuotedDynamicPlaceholderGeneration |
|
36 | - . " AND p.post_status IN ( 'publish', 'draft', 'private', 'future' ) " |
|
37 | - . ' AND ( p.post_title LIKE %s OR pm.meta_value LIKE %s )' |
|
38 | - . ' LIMIT %d', |
|
39 | - Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
|
40 | - 'article', |
|
41 | - Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY, |
|
42 | - // `prepare` doesn't support argument number, hence we must repeat the query. |
|
43 | - '%' . $wpdb->esc_like( $query ) . '%', |
|
44 | - '%' . $wpdb->esc_like( $query ) . '%', |
|
45 | - 50 |
|
46 | - ) |
|
47 | - ); |
|
24 | + $posts = $wpdb->get_results( |
|
25 | + $wpdb->prepare( |
|
26 | + "SELECT * FROM {$wpdb->posts} p" |
|
27 | + . " INNER JOIN {$wpdb->term_relationships} tr" |
|
28 | + . ' ON tr.object_id = p.ID' |
|
29 | + . " INNER JOIN {$wpdb->term_taxonomy} tt" |
|
30 | + . ' ON tt.taxonomy = %s AND tt.term_taxonomy_id = tr.term_taxonomy_id' |
|
31 | + . " INNER JOIN {$wpdb->terms} t" |
|
32 | + . ' ON t.term_id = tt.term_id AND t.name != %s' |
|
33 | + . " LEFT OUTER JOIN {$wpdb->postmeta} pm" |
|
34 | + . ' ON pm.meta_key = %s AND pm.post_id = p.ID' |
|
35 | + . " WHERE p.post_type IN ( '" . implode( "', '", array_map( 'esc_sql', Wordlift_Entity_Service::valid_entity_post_types() ) ) . "' )" // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.PreparedSQLPlaceholders.QuotedDynamicPlaceholderGeneration |
|
36 | + . " AND p.post_status IN ( 'publish', 'draft', 'private', 'future' ) " |
|
37 | + . ' AND ( p.post_title LIKE %s OR pm.meta_value LIKE %s )' |
|
38 | + . ' LIMIT %d', |
|
39 | + Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
|
40 | + 'article', |
|
41 | + Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY, |
|
42 | + // `prepare` doesn't support argument number, hence we must repeat the query. |
|
43 | + '%' . $wpdb->esc_like( $query ) . '%', |
|
44 | + '%' . $wpdb->esc_like( $query ) . '%', |
|
45 | + 50 |
|
46 | + ) |
|
47 | + ); |
|
48 | 48 | |
49 | - $results = array_map( |
|
50 | - function ( $item ) { |
|
49 | + $results = array_map( |
|
50 | + function ( $item ) { |
|
51 | 51 | |
52 | - $entity_service = Wordlift_Entity_Service::get_instance(); |
|
53 | - $uri = $entity_service->get_uri( $item->ID ); |
|
52 | + $entity_service = Wordlift_Entity_Service::get_instance(); |
|
53 | + $uri = $entity_service->get_uri( $item->ID ); |
|
54 | 54 | |
55 | - return array( |
|
56 | - // see #1074: The value property is needed for autocomplete in category page |
|
57 | - // to function correctly, if value is not provided, then the entity |
|
58 | - // wont be correctly saved. |
|
59 | - 'value' => $uri, |
|
60 | - 'id' => $uri, |
|
61 | - 'label' => array( $item->post_title ), |
|
62 | - 'labels' => $entity_service->get_alternative_labels( $item->ID ), |
|
63 | - 'descriptions' => array( Wordlift_Post_Excerpt_Helper::get_text_excerpt( $item ) ), |
|
64 | - 'scope' => 'local', |
|
65 | - 'sameAss' => get_post_meta( $item->ID, \Wordlift_Schema_Service::FIELD_SAME_AS ), |
|
66 | - // The following properties are less relevant because we're linking entities that exist already in the |
|
67 | - // vocabulary. That's why we don't make an effort to load the real data. |
|
68 | - 'types' => array( 'http://schema.org/Thing' ), |
|
69 | - 'urls' => array(), |
|
70 | - 'images' => array(), |
|
71 | - ); |
|
72 | - }, |
|
73 | - $posts |
|
74 | - ); |
|
55 | + return array( |
|
56 | + // see #1074: The value property is needed for autocomplete in category page |
|
57 | + // to function correctly, if value is not provided, then the entity |
|
58 | + // wont be correctly saved. |
|
59 | + 'value' => $uri, |
|
60 | + 'id' => $uri, |
|
61 | + 'label' => array( $item->post_title ), |
|
62 | + 'labels' => $entity_service->get_alternative_labels( $item->ID ), |
|
63 | + 'descriptions' => array( Wordlift_Post_Excerpt_Helper::get_text_excerpt( $item ) ), |
|
64 | + 'scope' => 'local', |
|
65 | + 'sameAss' => get_post_meta( $item->ID, \Wordlift_Schema_Service::FIELD_SAME_AS ), |
|
66 | + // The following properties are less relevant because we're linking entities that exist already in the |
|
67 | + // vocabulary. That's why we don't make an effort to load the real data. |
|
68 | + 'types' => array( 'http://schema.org/Thing' ), |
|
69 | + 'urls' => array(), |
|
70 | + 'images' => array(), |
|
71 | + ); |
|
72 | + }, |
|
73 | + $posts |
|
74 | + ); |
|
75 | 75 | |
76 | - $results = array_unique( $results, SORT_REGULAR ); |
|
76 | + $results = array_unique( $results, SORT_REGULAR ); |
|
77 | 77 | |
78 | - return $this->filter( $results, $excludes ); |
|
79 | - } |
|
78 | + return $this->filter( $results, $excludes ); |
|
79 | + } |
|
80 | 80 | |
81 | 81 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * @inheritDoc |
20 | 20 | */ |
21 | - public function query( $query, $scope, $excludes ) { |
|
21 | + public function query($query, $scope, $excludes) { |
|
22 | 22 | global $wpdb; |
23 | 23 | |
24 | 24 | $posts = $wpdb->get_results( |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | . ' ON t.term_id = tt.term_id AND t.name != %s' |
33 | 33 | . " LEFT OUTER JOIN {$wpdb->postmeta} pm" |
34 | 34 | . ' ON pm.meta_key = %s AND pm.post_id = p.ID' |
35 | - . " WHERE p.post_type IN ( '" . implode( "', '", array_map( 'esc_sql', Wordlift_Entity_Service::valid_entity_post_types() ) ) . "' )" // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.PreparedSQLPlaceholders.QuotedDynamicPlaceholderGeneration |
|
35 | + . " WHERE p.post_type IN ( '".implode("', '", array_map('esc_sql', Wordlift_Entity_Service::valid_entity_post_types()))."' )" // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.PreparedSQLPlaceholders.QuotedDynamicPlaceholderGeneration |
|
36 | 36 | . " AND p.post_status IN ( 'publish', 'draft', 'private', 'future' ) " |
37 | 37 | . ' AND ( p.post_title LIKE %s OR pm.meta_value LIKE %s )' |
38 | 38 | . ' LIMIT %d', |
@@ -40,17 +40,17 @@ discard block |
||
40 | 40 | 'article', |
41 | 41 | Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY, |
42 | 42 | // `prepare` doesn't support argument number, hence we must repeat the query. |
43 | - '%' . $wpdb->esc_like( $query ) . '%', |
|
44 | - '%' . $wpdb->esc_like( $query ) . '%', |
|
43 | + '%'.$wpdb->esc_like($query).'%', |
|
44 | + '%'.$wpdb->esc_like($query).'%', |
|
45 | 45 | 50 |
46 | 46 | ) |
47 | 47 | ); |
48 | 48 | |
49 | 49 | $results = array_map( |
50 | - function ( $item ) { |
|
50 | + function($item) { |
|
51 | 51 | |
52 | 52 | $entity_service = Wordlift_Entity_Service::get_instance(); |
53 | - $uri = $entity_service->get_uri( $item->ID ); |
|
53 | + $uri = $entity_service->get_uri($item->ID); |
|
54 | 54 | |
55 | 55 | return array( |
56 | 56 | // see #1074: The value property is needed for autocomplete in category page |
@@ -58,14 +58,14 @@ discard block |
||
58 | 58 | // wont be correctly saved. |
59 | 59 | 'value' => $uri, |
60 | 60 | 'id' => $uri, |
61 | - 'label' => array( $item->post_title ), |
|
62 | - 'labels' => $entity_service->get_alternative_labels( $item->ID ), |
|
63 | - 'descriptions' => array( Wordlift_Post_Excerpt_Helper::get_text_excerpt( $item ) ), |
|
61 | + 'label' => array($item->post_title), |
|
62 | + 'labels' => $entity_service->get_alternative_labels($item->ID), |
|
63 | + 'descriptions' => array(Wordlift_Post_Excerpt_Helper::get_text_excerpt($item)), |
|
64 | 64 | 'scope' => 'local', |
65 | - 'sameAss' => get_post_meta( $item->ID, \Wordlift_Schema_Service::FIELD_SAME_AS ), |
|
65 | + 'sameAss' => get_post_meta($item->ID, \Wordlift_Schema_Service::FIELD_SAME_AS), |
|
66 | 66 | // The following properties are less relevant because we're linking entities that exist already in the |
67 | 67 | // vocabulary. That's why we don't make an effort to load the real data. |
68 | - 'types' => array( 'http://schema.org/Thing' ), |
|
68 | + 'types' => array('http://schema.org/Thing'), |
|
69 | 69 | 'urls' => array(), |
70 | 70 | 'images' => array(), |
71 | 71 | ); |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | $posts |
74 | 74 | ); |
75 | 75 | |
76 | - $results = array_unique( $results, SORT_REGULAR ); |
|
76 | + $results = array_unique($results, SORT_REGULAR); |
|
77 | 77 | |
78 | - return $this->filter( $results, $excludes ); |
|
78 | + return $this->filter($results, $excludes); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | } |
@@ -12,47 +12,47 @@ |
||
12 | 12 | |
13 | 13 | class Term_Metabox extends Wl_Abstract_Metabox { |
14 | 14 | |
15 | - public function __construct() { |
|
16 | - parent::__construct(); |
|
17 | - add_action( 'init', array( $this, 'init_all_custom_fields' ) ); |
|
18 | - } |
|
19 | - |
|
20 | - /** |
|
21 | - * @param $term \WP_Term |
|
22 | - */ |
|
23 | - public function render_ui( $term ) { |
|
24 | - $this->instantiate_fields( $term->term_id, Object_Type_Enum::TERM ); |
|
25 | - $this->html(); |
|
26 | - $this->enqueue_scripts_and_styles(); |
|
27 | - $plugin = \Wordlift::get_instance(); |
|
28 | - |
|
29 | - // Enqueue this scripts for sameas fields. |
|
30 | - wp_enqueue_script( |
|
31 | - 'wl-autocomplete-select', |
|
32 | - plugin_dir_url( dirname( __DIR__ ) ) . 'js/dist/autocomplete-select.js', |
|
33 | - array(), |
|
34 | - $plugin->get_version(), |
|
35 | - true |
|
36 | - ); |
|
37 | - |
|
38 | - wp_enqueue_style( |
|
39 | - 'wl-autocomplete-select', |
|
40 | - plugin_dir_url( dirname( __DIR__ ) ) . 'js/dist/autocomplete-select.css', |
|
41 | - array(), |
|
42 | - $plugin->get_version() |
|
43 | - ); |
|
44 | - } |
|
45 | - |
|
46 | - public function save_field( $term_id ) { |
|
47 | - $this->save_form_data( $term_id, Object_Type_Enum::TERM ); |
|
48 | - } |
|
49 | - |
|
50 | - public function init_all_custom_fields() { |
|
51 | - $taxonomies = Terms_Compat::get_public_taxonomies(); |
|
52 | - foreach ( $taxonomies as $taxonomy ) { |
|
53 | - add_action( "${taxonomy}_edit_form", array( $this, 'render_ui' ), 1 ); |
|
54 | - add_action( "edited_${taxonomy}", array( $this, 'save_field' ) ); |
|
55 | - } |
|
56 | - } |
|
15 | + public function __construct() { |
|
16 | + parent::__construct(); |
|
17 | + add_action( 'init', array( $this, 'init_all_custom_fields' ) ); |
|
18 | + } |
|
19 | + |
|
20 | + /** |
|
21 | + * @param $term \WP_Term |
|
22 | + */ |
|
23 | + public function render_ui( $term ) { |
|
24 | + $this->instantiate_fields( $term->term_id, Object_Type_Enum::TERM ); |
|
25 | + $this->html(); |
|
26 | + $this->enqueue_scripts_and_styles(); |
|
27 | + $plugin = \Wordlift::get_instance(); |
|
28 | + |
|
29 | + // Enqueue this scripts for sameas fields. |
|
30 | + wp_enqueue_script( |
|
31 | + 'wl-autocomplete-select', |
|
32 | + plugin_dir_url( dirname( __DIR__ ) ) . 'js/dist/autocomplete-select.js', |
|
33 | + array(), |
|
34 | + $plugin->get_version(), |
|
35 | + true |
|
36 | + ); |
|
37 | + |
|
38 | + wp_enqueue_style( |
|
39 | + 'wl-autocomplete-select', |
|
40 | + plugin_dir_url( dirname( __DIR__ ) ) . 'js/dist/autocomplete-select.css', |
|
41 | + array(), |
|
42 | + $plugin->get_version() |
|
43 | + ); |
|
44 | + } |
|
45 | + |
|
46 | + public function save_field( $term_id ) { |
|
47 | + $this->save_form_data( $term_id, Object_Type_Enum::TERM ); |
|
48 | + } |
|
49 | + |
|
50 | + public function init_all_custom_fields() { |
|
51 | + $taxonomies = Terms_Compat::get_public_taxonomies(); |
|
52 | + foreach ( $taxonomies as $taxonomy ) { |
|
53 | + add_action( "${taxonomy}_edit_form", array( $this, 'render_ui' ), 1 ); |
|
54 | + add_action( "edited_${taxonomy}", array( $this, 'save_field' ) ); |
|
55 | + } |
|
56 | + } |
|
57 | 57 | |
58 | 58 | } |
@@ -14,14 +14,14 @@ discard block |
||
14 | 14 | |
15 | 15 | public function __construct() { |
16 | 16 | parent::__construct(); |
17 | - add_action( 'init', array( $this, 'init_all_custom_fields' ) ); |
|
17 | + add_action('init', array($this, 'init_all_custom_fields')); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @param $term \WP_Term |
22 | 22 | */ |
23 | - public function render_ui( $term ) { |
|
24 | - $this->instantiate_fields( $term->term_id, Object_Type_Enum::TERM ); |
|
23 | + public function render_ui($term) { |
|
24 | + $this->instantiate_fields($term->term_id, Object_Type_Enum::TERM); |
|
25 | 25 | $this->html(); |
26 | 26 | $this->enqueue_scripts_and_styles(); |
27 | 27 | $plugin = \Wordlift::get_instance(); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | // Enqueue this scripts for sameas fields. |
30 | 30 | wp_enqueue_script( |
31 | 31 | 'wl-autocomplete-select', |
32 | - plugin_dir_url( dirname( __DIR__ ) ) . 'js/dist/autocomplete-select.js', |
|
32 | + plugin_dir_url(dirname(__DIR__)).'js/dist/autocomplete-select.js', |
|
33 | 33 | array(), |
34 | 34 | $plugin->get_version(), |
35 | 35 | true |
@@ -37,21 +37,21 @@ discard block |
||
37 | 37 | |
38 | 38 | wp_enqueue_style( |
39 | 39 | 'wl-autocomplete-select', |
40 | - plugin_dir_url( dirname( __DIR__ ) ) . 'js/dist/autocomplete-select.css', |
|
40 | + plugin_dir_url(dirname(__DIR__)).'js/dist/autocomplete-select.css', |
|
41 | 41 | array(), |
42 | 42 | $plugin->get_version() |
43 | 43 | ); |
44 | 44 | } |
45 | 45 | |
46 | - public function save_field( $term_id ) { |
|
47 | - $this->save_form_data( $term_id, Object_Type_Enum::TERM ); |
|
46 | + public function save_field($term_id) { |
|
47 | + $this->save_form_data($term_id, Object_Type_Enum::TERM); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | public function init_all_custom_fields() { |
51 | 51 | $taxonomies = Terms_Compat::get_public_taxonomies(); |
52 | - foreach ( $taxonomies as $taxonomy ) { |
|
53 | - add_action( "${taxonomy}_edit_form", array( $this, 'render_ui' ), 1 ); |
|
54 | - add_action( "edited_${taxonomy}", array( $this, 'save_field' ) ); |
|
52 | + foreach ($taxonomies as $taxonomy) { |
|
53 | + add_action("${taxonomy}_edit_form", array($this, 'render_ui'), 1); |
|
54 | + add_action("edited_${taxonomy}", array($this, 'save_field')); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 |
@@ -21,18 +21,18 @@ |
||
21 | 21 | */ |
22 | 22 | class Term_Save { |
23 | 23 | |
24 | - public function init() { |
|
25 | - add_action( 'create_term', array( $this, 'saved_term' ) ); |
|
26 | - add_action( 'edited_term', array( $this, 'saved_term' ) ); |
|
27 | - } |
|
24 | + public function init() { |
|
25 | + add_action( 'create_term', array( $this, 'saved_term' ) ); |
|
26 | + add_action( 'edited_term', array( $this, 'saved_term' ) ); |
|
27 | + } |
|
28 | 28 | |
29 | - public function saved_term( $term_id ) { |
|
29 | + public function saved_term( $term_id ) { |
|
30 | 30 | |
31 | - // check if entity url already exists. |
|
31 | + // check if entity url already exists. |
|
32 | 32 | |
33 | - Wordpress_Term_Content_Legacy_Service::get_instance() |
|
34 | - ->get_entity_id( Wordpress_Content_Id::create_term( $term_id ) ); |
|
33 | + Wordpress_Term_Content_Legacy_Service::get_instance() |
|
34 | + ->get_entity_id( Wordpress_Content_Id::create_term( $term_id ) ); |
|
35 | 35 | |
36 | - } |
|
36 | + } |
|
37 | 37 | |
38 | 38 | } |
@@ -22,16 +22,16 @@ |
||
22 | 22 | class Term_Save { |
23 | 23 | |
24 | 24 | public function init() { |
25 | - add_action( 'create_term', array( $this, 'saved_term' ) ); |
|
26 | - add_action( 'edited_term', array( $this, 'saved_term' ) ); |
|
25 | + add_action('create_term', array($this, 'saved_term')); |
|
26 | + add_action('edited_term', array($this, 'saved_term')); |
|
27 | 27 | } |
28 | 28 | |
29 | - public function saved_term( $term_id ) { |
|
29 | + public function saved_term($term_id) { |
|
30 | 30 | |
31 | 31 | // check if entity url already exists. |
32 | 32 | |
33 | 33 | Wordpress_Term_Content_Legacy_Service::get_instance() |
34 | - ->get_entity_id( Wordpress_Content_Id::create_term( $term_id ) ); |
|
34 | + ->get_entity_id(Wordpress_Content_Id::create_term($term_id)); |
|
35 | 35 | |
36 | 36 | } |
37 | 37 |
@@ -12,44 +12,44 @@ |
||
12 | 12 | use Wordlift\Vocabulary_Terms\Jsonld\Post_Jsonld; |
13 | 13 | |
14 | 14 | class Vocabulary_Terms_Loader extends Default_Loader { |
15 | - /** |
|
16 | - * @var \Wordlift_Entity_Type_Service |
|
17 | - */ |
|
18 | - private $entity_type_service; |
|
19 | - /** |
|
20 | - * @var \Wordlift_Property_Getter |
|
21 | - */ |
|
22 | - private $property_getter; |
|
23 | - |
|
24 | - /** |
|
25 | - * Vocabulary_Terms_Loader constructor. |
|
26 | - * |
|
27 | - * @param $entity_type_service \Wordlift_Entity_Type_Service |
|
28 | - * @param \Wordlift_Property_Getter $property_getter |
|
29 | - */ |
|
30 | - public function __construct( $entity_type_service, $property_getter ) { |
|
31 | - parent::__construct(); |
|
32 | - $this->entity_type_service = $entity_type_service; |
|
33 | - $this->property_getter = $property_getter; |
|
34 | - } |
|
35 | - |
|
36 | - public function init_all_dependencies() { |
|
37 | - new Entity_Type(); |
|
38 | - new Term_Metabox(); |
|
39 | - $jsonld = new Jsonld_Generator( $this->entity_type_service, $this->property_getter ); |
|
40 | - $jsonld->init(); |
|
41 | - $term_save_hook = new Term_Save(); |
|
42 | - $term_save_hook->init(); |
|
43 | - $post_jsonld = new Post_Jsonld(); |
|
44 | - $post_jsonld->init(); |
|
45 | - } |
|
46 | - |
|
47 | - protected function get_feature_slug() { |
|
48 | - return 'no-vocabulary-terms'; |
|
49 | - } |
|
50 | - |
|
51 | - protected function get_feature_default_value() { |
|
52 | - return false; |
|
53 | - } |
|
15 | + /** |
|
16 | + * @var \Wordlift_Entity_Type_Service |
|
17 | + */ |
|
18 | + private $entity_type_service; |
|
19 | + /** |
|
20 | + * @var \Wordlift_Property_Getter |
|
21 | + */ |
|
22 | + private $property_getter; |
|
23 | + |
|
24 | + /** |
|
25 | + * Vocabulary_Terms_Loader constructor. |
|
26 | + * |
|
27 | + * @param $entity_type_service \Wordlift_Entity_Type_Service |
|
28 | + * @param \Wordlift_Property_Getter $property_getter |
|
29 | + */ |
|
30 | + public function __construct( $entity_type_service, $property_getter ) { |
|
31 | + parent::__construct(); |
|
32 | + $this->entity_type_service = $entity_type_service; |
|
33 | + $this->property_getter = $property_getter; |
|
34 | + } |
|
35 | + |
|
36 | + public function init_all_dependencies() { |
|
37 | + new Entity_Type(); |
|
38 | + new Term_Metabox(); |
|
39 | + $jsonld = new Jsonld_Generator( $this->entity_type_service, $this->property_getter ); |
|
40 | + $jsonld->init(); |
|
41 | + $term_save_hook = new Term_Save(); |
|
42 | + $term_save_hook->init(); |
|
43 | + $post_jsonld = new Post_Jsonld(); |
|
44 | + $post_jsonld->init(); |
|
45 | + } |
|
46 | + |
|
47 | + protected function get_feature_slug() { |
|
48 | + return 'no-vocabulary-terms'; |
|
49 | + } |
|
50 | + |
|
51 | + protected function get_feature_default_value() { |
|
52 | + return false; |
|
53 | + } |
|
54 | 54 | |
55 | 55 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * @param $entity_type_service \Wordlift_Entity_Type_Service |
28 | 28 | * @param \Wordlift_Property_Getter $property_getter |
29 | 29 | */ |
30 | - public function __construct( $entity_type_service, $property_getter ) { |
|
30 | + public function __construct($entity_type_service, $property_getter) { |
|
31 | 31 | parent::__construct(); |
32 | 32 | $this->entity_type_service = $entity_type_service; |
33 | 33 | $this->property_getter = $property_getter; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | public function init_all_dependencies() { |
37 | 37 | new Entity_Type(); |
38 | 38 | new Term_Metabox(); |
39 | - $jsonld = new Jsonld_Generator( $this->entity_type_service, $this->property_getter ); |
|
39 | + $jsonld = new Jsonld_Generator($this->entity_type_service, $this->property_getter); |
|
40 | 40 | $jsonld->init(); |
41 | 41 | $term_save_hook = new Term_Save(); |
42 | 42 | $term_save_hook->init(); |
@@ -12,153 +12,153 @@ |
||
12 | 12 | |
13 | 13 | class Jsonld_Generator { |
14 | 14 | |
15 | - /** |
|
16 | - * @var \Wordlift_Entity_Type_Service |
|
17 | - */ |
|
18 | - private $entity_type_service; |
|
19 | - /** |
|
20 | - * @var \Wordlift_Property_Getter |
|
21 | - */ |
|
22 | - private $property_getter; |
|
23 | - /** |
|
24 | - * @var Type_Service |
|
25 | - */ |
|
26 | - private $term_entity_type_service; |
|
27 | - /** |
|
28 | - * @var \Wordlift_Entity_Service |
|
29 | - */ |
|
30 | - private $entity_service; |
|
31 | - |
|
32 | - public function __construct( $entity_type_service, $property_getter ) { |
|
33 | - $this->entity_type_service = $entity_type_service; |
|
34 | - $this->property_getter = $property_getter; |
|
35 | - $this->term_entity_type_service = Type_Service::get_instance(); |
|
36 | - $this->entity_service = \Wordlift_Entity_Service::get_instance(); |
|
37 | - } |
|
38 | - |
|
39 | - public function init() { |
|
40 | - add_filter( 'wl_term_jsonld_array', array( $this, 'wl_term_jsonld_array' ), 10, 2 ); |
|
41 | - } |
|
42 | - |
|
43 | - public function wl_term_jsonld_array( $data, $term_id ) { |
|
44 | - $jsonld = $data['jsonld']; |
|
45 | - $references = $data['references']; |
|
46 | - |
|
47 | - $term_jsonld_data = $this->get_jsonld_data_for_term( $term_id ); |
|
48 | - |
|
49 | - // Return early if we dont have the entity data |
|
50 | - // for the term. |
|
51 | - if ( ! $term_jsonld_data ) { |
|
52 | - return $data; |
|
53 | - } |
|
54 | - |
|
55 | - $term_jsonld = $term_jsonld_data['jsonld']; |
|
56 | - |
|
57 | - $references = array_merge( $references, $term_jsonld_data['references'] ); |
|
58 | - |
|
59 | - array_unshift( $jsonld, $term_jsonld ); |
|
60 | - |
|
61 | - return array( |
|
62 | - 'jsonld' => $jsonld, |
|
63 | - 'references' => $references, |
|
64 | - ); |
|
65 | - } |
|
66 | - |
|
67 | - private function get_jsonld_data_for_term( $term_id ) { |
|
68 | - |
|
69 | - $id = $this->entity_service->get_uri( $term_id, Object_Type_Enum::TERM ); |
|
70 | - |
|
71 | - // If we don't have a dataset URI, then don't publish the term data |
|
72 | - // on this page. |
|
73 | - if ( ! $id ) { |
|
74 | - return false; |
|
75 | - } |
|
76 | - |
|
77 | - $references = array(); |
|
78 | - $term = get_term( $term_id ); |
|
79 | - $permalink = get_term_link( $term ); |
|
80 | - |
|
81 | - $custom_fields = $this->entity_type_service->get_custom_fields_for_term( $term_id ); |
|
82 | - $term = get_term( $term_id ); |
|
83 | - $jsonld = array( |
|
84 | - '@context' => 'http://schema.org', |
|
85 | - 'name' => $term->name, |
|
86 | - '@type' => $this->term_entity_type_service->get_entity_types_labels( $term_id ), |
|
87 | - '@id' => $id, |
|
88 | - 'description' => $term->description, |
|
89 | - ); |
|
90 | - |
|
91 | - if ( ! $custom_fields || ! is_array( $custom_fields ) ) { |
|
92 | - return $jsonld; |
|
93 | - } |
|
94 | - |
|
95 | - foreach ( $custom_fields as $key => $value ) { |
|
96 | - $name = $this->relative_to_schema_context( $value['predicate'] ); |
|
97 | - $value = $this->property_getter->get( $term_id, $key, Object_Type_Enum::TERM ); |
|
98 | - $value = $this->process_value( $value, $references ); |
|
99 | - if ( ! isset( $value ) || |
|
100 | - is_array( $value ) && empty( $value ) || |
|
101 | - is_string( $value ) && empty( $value ) ) { |
|
102 | - continue; |
|
103 | - } |
|
104 | - $jsonld[ $name ] = $value; |
|
105 | - |
|
106 | - } |
|
107 | - |
|
108 | - if ( $permalink ) { |
|
109 | - $jsonld['mainEntityOfPage'] = $permalink; |
|
110 | - } |
|
111 | - |
|
112 | - return apply_filters( |
|
113 | - 'wl_no_vocabulary_term_jsonld_array', |
|
114 | - array( |
|
115 | - 'jsonld' => $jsonld, |
|
116 | - 'references' => $references, |
|
117 | - ), |
|
118 | - $term_id |
|
119 | - ); |
|
120 | - |
|
121 | - } |
|
122 | - |
|
123 | - private function relative_to_schema_context( $predicate ) { |
|
124 | - return str_replace( 'http://schema.org/', '', $predicate ); |
|
125 | - } |
|
126 | - |
|
127 | - private function process_value( $value, &$references ) { |
|
128 | - |
|
129 | - if ( is_array( $value ) |
|
130 | - && count( $value ) > 0 |
|
131 | - && $value[0] instanceof \Wordlift_Property_Entity_Reference ) { |
|
132 | - |
|
133 | - // All of the references from the custom fields are post references. |
|
134 | - $references = array_merge( |
|
135 | - $references, |
|
136 | - array_map( |
|
137 | - function ( $property_entity_reference ) { |
|
138 | - /** |
|
139 | - * @var $property_entity_reference \Wordlift_Property_Entity_Reference |
|
140 | - */ |
|
141 | - return new Post_Reference( $property_entity_reference->get_id() ); |
|
142 | - }, |
|
143 | - $value |
|
144 | - ) |
|
145 | - ); |
|
146 | - |
|
147 | - $that = $this; |
|
148 | - |
|
149 | - return array_map( |
|
150 | - function ( $reference ) use ( $that ) { |
|
151 | - /** |
|
152 | - * @var $reference \Wordlift_Property_Entity_Reference |
|
153 | - */ |
|
154 | - return array( '@id' => $that->entity_service->get_uri( $reference->get_id() ) ); |
|
155 | - }, |
|
156 | - $value |
|
157 | - ); |
|
158 | - |
|
159 | - } |
|
160 | - |
|
161 | - return $value; |
|
162 | - } |
|
15 | + /** |
|
16 | + * @var \Wordlift_Entity_Type_Service |
|
17 | + */ |
|
18 | + private $entity_type_service; |
|
19 | + /** |
|
20 | + * @var \Wordlift_Property_Getter |
|
21 | + */ |
|
22 | + private $property_getter; |
|
23 | + /** |
|
24 | + * @var Type_Service |
|
25 | + */ |
|
26 | + private $term_entity_type_service; |
|
27 | + /** |
|
28 | + * @var \Wordlift_Entity_Service |
|
29 | + */ |
|
30 | + private $entity_service; |
|
31 | + |
|
32 | + public function __construct( $entity_type_service, $property_getter ) { |
|
33 | + $this->entity_type_service = $entity_type_service; |
|
34 | + $this->property_getter = $property_getter; |
|
35 | + $this->term_entity_type_service = Type_Service::get_instance(); |
|
36 | + $this->entity_service = \Wordlift_Entity_Service::get_instance(); |
|
37 | + } |
|
38 | + |
|
39 | + public function init() { |
|
40 | + add_filter( 'wl_term_jsonld_array', array( $this, 'wl_term_jsonld_array' ), 10, 2 ); |
|
41 | + } |
|
42 | + |
|
43 | + public function wl_term_jsonld_array( $data, $term_id ) { |
|
44 | + $jsonld = $data['jsonld']; |
|
45 | + $references = $data['references']; |
|
46 | + |
|
47 | + $term_jsonld_data = $this->get_jsonld_data_for_term( $term_id ); |
|
48 | + |
|
49 | + // Return early if we dont have the entity data |
|
50 | + // for the term. |
|
51 | + if ( ! $term_jsonld_data ) { |
|
52 | + return $data; |
|
53 | + } |
|
54 | + |
|
55 | + $term_jsonld = $term_jsonld_data['jsonld']; |
|
56 | + |
|
57 | + $references = array_merge( $references, $term_jsonld_data['references'] ); |
|
58 | + |
|
59 | + array_unshift( $jsonld, $term_jsonld ); |
|
60 | + |
|
61 | + return array( |
|
62 | + 'jsonld' => $jsonld, |
|
63 | + 'references' => $references, |
|
64 | + ); |
|
65 | + } |
|
66 | + |
|
67 | + private function get_jsonld_data_for_term( $term_id ) { |
|
68 | + |
|
69 | + $id = $this->entity_service->get_uri( $term_id, Object_Type_Enum::TERM ); |
|
70 | + |
|
71 | + // If we don't have a dataset URI, then don't publish the term data |
|
72 | + // on this page. |
|
73 | + if ( ! $id ) { |
|
74 | + return false; |
|
75 | + } |
|
76 | + |
|
77 | + $references = array(); |
|
78 | + $term = get_term( $term_id ); |
|
79 | + $permalink = get_term_link( $term ); |
|
80 | + |
|
81 | + $custom_fields = $this->entity_type_service->get_custom_fields_for_term( $term_id ); |
|
82 | + $term = get_term( $term_id ); |
|
83 | + $jsonld = array( |
|
84 | + '@context' => 'http://schema.org', |
|
85 | + 'name' => $term->name, |
|
86 | + '@type' => $this->term_entity_type_service->get_entity_types_labels( $term_id ), |
|
87 | + '@id' => $id, |
|
88 | + 'description' => $term->description, |
|
89 | + ); |
|
90 | + |
|
91 | + if ( ! $custom_fields || ! is_array( $custom_fields ) ) { |
|
92 | + return $jsonld; |
|
93 | + } |
|
94 | + |
|
95 | + foreach ( $custom_fields as $key => $value ) { |
|
96 | + $name = $this->relative_to_schema_context( $value['predicate'] ); |
|
97 | + $value = $this->property_getter->get( $term_id, $key, Object_Type_Enum::TERM ); |
|
98 | + $value = $this->process_value( $value, $references ); |
|
99 | + if ( ! isset( $value ) || |
|
100 | + is_array( $value ) && empty( $value ) || |
|
101 | + is_string( $value ) && empty( $value ) ) { |
|
102 | + continue; |
|
103 | + } |
|
104 | + $jsonld[ $name ] = $value; |
|
105 | + |
|
106 | + } |
|
107 | + |
|
108 | + if ( $permalink ) { |
|
109 | + $jsonld['mainEntityOfPage'] = $permalink; |
|
110 | + } |
|
111 | + |
|
112 | + return apply_filters( |
|
113 | + 'wl_no_vocabulary_term_jsonld_array', |
|
114 | + array( |
|
115 | + 'jsonld' => $jsonld, |
|
116 | + 'references' => $references, |
|
117 | + ), |
|
118 | + $term_id |
|
119 | + ); |
|
120 | + |
|
121 | + } |
|
122 | + |
|
123 | + private function relative_to_schema_context( $predicate ) { |
|
124 | + return str_replace( 'http://schema.org/', '', $predicate ); |
|
125 | + } |
|
126 | + |
|
127 | + private function process_value( $value, &$references ) { |
|
128 | + |
|
129 | + if ( is_array( $value ) |
|
130 | + && count( $value ) > 0 |
|
131 | + && $value[0] instanceof \Wordlift_Property_Entity_Reference ) { |
|
132 | + |
|
133 | + // All of the references from the custom fields are post references. |
|
134 | + $references = array_merge( |
|
135 | + $references, |
|
136 | + array_map( |
|
137 | + function ( $property_entity_reference ) { |
|
138 | + /** |
|
139 | + * @var $property_entity_reference \Wordlift_Property_Entity_Reference |
|
140 | + */ |
|
141 | + return new Post_Reference( $property_entity_reference->get_id() ); |
|
142 | + }, |
|
143 | + $value |
|
144 | + ) |
|
145 | + ); |
|
146 | + |
|
147 | + $that = $this; |
|
148 | + |
|
149 | + return array_map( |
|
150 | + function ( $reference ) use ( $that ) { |
|
151 | + /** |
|
152 | + * @var $reference \Wordlift_Property_Entity_Reference |
|
153 | + */ |
|
154 | + return array( '@id' => $that->entity_service->get_uri( $reference->get_id() ) ); |
|
155 | + }, |
|
156 | + $value |
|
157 | + ); |
|
158 | + |
|
159 | + } |
|
160 | + |
|
161 | + return $value; |
|
162 | + } |
|
163 | 163 | |
164 | 164 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | private $entity_service; |
31 | 31 | |
32 | - public function __construct( $entity_type_service, $property_getter ) { |
|
32 | + public function __construct($entity_type_service, $property_getter) { |
|
33 | 33 | $this->entity_type_service = $entity_type_service; |
34 | 34 | $this->property_getter = $property_getter; |
35 | 35 | $this->term_entity_type_service = Type_Service::get_instance(); |
@@ -37,26 +37,26 @@ discard block |
||
37 | 37 | } |
38 | 38 | |
39 | 39 | public function init() { |
40 | - add_filter( 'wl_term_jsonld_array', array( $this, 'wl_term_jsonld_array' ), 10, 2 ); |
|
40 | + add_filter('wl_term_jsonld_array', array($this, 'wl_term_jsonld_array'), 10, 2); |
|
41 | 41 | } |
42 | 42 | |
43 | - public function wl_term_jsonld_array( $data, $term_id ) { |
|
43 | + public function wl_term_jsonld_array($data, $term_id) { |
|
44 | 44 | $jsonld = $data['jsonld']; |
45 | 45 | $references = $data['references']; |
46 | 46 | |
47 | - $term_jsonld_data = $this->get_jsonld_data_for_term( $term_id ); |
|
47 | + $term_jsonld_data = $this->get_jsonld_data_for_term($term_id); |
|
48 | 48 | |
49 | 49 | // Return early if we dont have the entity data |
50 | 50 | // for the term. |
51 | - if ( ! $term_jsonld_data ) { |
|
51 | + if ( ! $term_jsonld_data) { |
|
52 | 52 | return $data; |
53 | 53 | } |
54 | 54 | |
55 | 55 | $term_jsonld = $term_jsonld_data['jsonld']; |
56 | 56 | |
57 | - $references = array_merge( $references, $term_jsonld_data['references'] ); |
|
57 | + $references = array_merge($references, $term_jsonld_data['references']); |
|
58 | 58 | |
59 | - array_unshift( $jsonld, $term_jsonld ); |
|
59 | + array_unshift($jsonld, $term_jsonld); |
|
60 | 60 | |
61 | 61 | return array( |
62 | 62 | 'jsonld' => $jsonld, |
@@ -64,48 +64,48 @@ discard block |
||
64 | 64 | ); |
65 | 65 | } |
66 | 66 | |
67 | - private function get_jsonld_data_for_term( $term_id ) { |
|
67 | + private function get_jsonld_data_for_term($term_id) { |
|
68 | 68 | |
69 | - $id = $this->entity_service->get_uri( $term_id, Object_Type_Enum::TERM ); |
|
69 | + $id = $this->entity_service->get_uri($term_id, Object_Type_Enum::TERM); |
|
70 | 70 | |
71 | 71 | // If we don't have a dataset URI, then don't publish the term data |
72 | 72 | // on this page. |
73 | - if ( ! $id ) { |
|
73 | + if ( ! $id) { |
|
74 | 74 | return false; |
75 | 75 | } |
76 | 76 | |
77 | 77 | $references = array(); |
78 | - $term = get_term( $term_id ); |
|
79 | - $permalink = get_term_link( $term ); |
|
78 | + $term = get_term($term_id); |
|
79 | + $permalink = get_term_link($term); |
|
80 | 80 | |
81 | - $custom_fields = $this->entity_type_service->get_custom_fields_for_term( $term_id ); |
|
82 | - $term = get_term( $term_id ); |
|
81 | + $custom_fields = $this->entity_type_service->get_custom_fields_for_term($term_id); |
|
82 | + $term = get_term($term_id); |
|
83 | 83 | $jsonld = array( |
84 | 84 | '@context' => 'http://schema.org', |
85 | 85 | 'name' => $term->name, |
86 | - '@type' => $this->term_entity_type_service->get_entity_types_labels( $term_id ), |
|
86 | + '@type' => $this->term_entity_type_service->get_entity_types_labels($term_id), |
|
87 | 87 | '@id' => $id, |
88 | 88 | 'description' => $term->description, |
89 | 89 | ); |
90 | 90 | |
91 | - if ( ! $custom_fields || ! is_array( $custom_fields ) ) { |
|
91 | + if ( ! $custom_fields || ! is_array($custom_fields)) { |
|
92 | 92 | return $jsonld; |
93 | 93 | } |
94 | 94 | |
95 | - foreach ( $custom_fields as $key => $value ) { |
|
96 | - $name = $this->relative_to_schema_context( $value['predicate'] ); |
|
97 | - $value = $this->property_getter->get( $term_id, $key, Object_Type_Enum::TERM ); |
|
98 | - $value = $this->process_value( $value, $references ); |
|
99 | - if ( ! isset( $value ) || |
|
100 | - is_array( $value ) && empty( $value ) || |
|
101 | - is_string( $value ) && empty( $value ) ) { |
|
95 | + foreach ($custom_fields as $key => $value) { |
|
96 | + $name = $this->relative_to_schema_context($value['predicate']); |
|
97 | + $value = $this->property_getter->get($term_id, $key, Object_Type_Enum::TERM); |
|
98 | + $value = $this->process_value($value, $references); |
|
99 | + if ( ! isset($value) || |
|
100 | + is_array($value) && empty($value) || |
|
101 | + is_string($value) && empty($value)) { |
|
102 | 102 | continue; |
103 | 103 | } |
104 | - $jsonld[ $name ] = $value; |
|
104 | + $jsonld[$name] = $value; |
|
105 | 105 | |
106 | 106 | } |
107 | 107 | |
108 | - if ( $permalink ) { |
|
108 | + if ($permalink) { |
|
109 | 109 | $jsonld['mainEntityOfPage'] = $permalink; |
110 | 110 | } |
111 | 111 | |
@@ -120,25 +120,25 @@ discard block |
||
120 | 120 | |
121 | 121 | } |
122 | 122 | |
123 | - private function relative_to_schema_context( $predicate ) { |
|
124 | - return str_replace( 'http://schema.org/', '', $predicate ); |
|
123 | + private function relative_to_schema_context($predicate) { |
|
124 | + return str_replace('http://schema.org/', '', $predicate); |
|
125 | 125 | } |
126 | 126 | |
127 | - private function process_value( $value, &$references ) { |
|
127 | + private function process_value($value, &$references) { |
|
128 | 128 | |
129 | - if ( is_array( $value ) |
|
130 | - && count( $value ) > 0 |
|
131 | - && $value[0] instanceof \Wordlift_Property_Entity_Reference ) { |
|
129 | + if (is_array($value) |
|
130 | + && count($value) > 0 |
|
131 | + && $value[0] instanceof \Wordlift_Property_Entity_Reference) { |
|
132 | 132 | |
133 | 133 | // All of the references from the custom fields are post references. |
134 | 134 | $references = array_merge( |
135 | 135 | $references, |
136 | 136 | array_map( |
137 | - function ( $property_entity_reference ) { |
|
137 | + function($property_entity_reference) { |
|
138 | 138 | /** |
139 | 139 | * @var $property_entity_reference \Wordlift_Property_Entity_Reference |
140 | 140 | */ |
141 | - return new Post_Reference( $property_entity_reference->get_id() ); |
|
141 | + return new Post_Reference($property_entity_reference->get_id()); |
|
142 | 142 | }, |
143 | 143 | $value |
144 | 144 | ) |
@@ -147,11 +147,11 @@ discard block |
||
147 | 147 | $that = $this; |
148 | 148 | |
149 | 149 | return array_map( |
150 | - function ( $reference ) use ( $that ) { |
|
150 | + function($reference) use ($that) { |
|
151 | 151 | /** |
152 | 152 | * @var $reference \Wordlift_Property_Entity_Reference |
153 | 153 | */ |
154 | - return array( '@id' => $that->entity_service->get_uri( $reference->get_id() ) ); |
|
154 | + return array('@id' => $that->entity_service->get_uri($reference->get_id())); |
|
155 | 155 | }, |
156 | 156 | $value |
157 | 157 | ); |
@@ -16,94 +16,94 @@ |
||
16 | 16 | |
17 | 17 | class Post_Jsonld { |
18 | 18 | |
19 | - public function init() { |
|
20 | - add_filter( 'wl_post_jsonld_array', array( $this, 'wl_post_jsonld_array' ), 10, 2 ); |
|
21 | - } |
|
22 | - |
|
23 | - public function wl_post_jsonld_array( $data, $post_id ) { |
|
24 | - |
|
25 | - $term_references = $this->get_term_references( $post_id ); |
|
26 | - |
|
27 | - if ( ! $term_references ) { |
|
28 | - return $data; |
|
29 | - } |
|
30 | - |
|
31 | - $references = $data['references']; |
|
32 | - $jsonld = $data['jsonld']; |
|
33 | - |
|
34 | - $jsonld['mentions'] = $this->append_term_mentions( $jsonld, $term_references ); |
|
35 | - |
|
36 | - return array( |
|
37 | - 'jsonld' => $jsonld, |
|
38 | - 'references' => array_merge( $references, $term_references ), |
|
39 | - ); |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * @param $post_id |
|
44 | - * |
|
45 | - * @return array Returns a list of term references, Returns empty array if none found. |
|
46 | - */ |
|
47 | - private function get_term_references( $post_id ) { |
|
48 | - |
|
49 | - /** @var WP_Taxonomy[] $taxonomies_for_post */ |
|
50 | - $taxonomies_for_post = get_object_taxonomies( get_post_type( $post_id ), 'objects' ); |
|
51 | - |
|
52 | - // now we need to collect all terms attached to this post. |
|
53 | - $terms = array(); |
|
54 | - |
|
55 | - foreach ( $taxonomies_for_post as $taxonomy ) { |
|
56 | - // Please note that `$taxonomy->publicly_queryable is only WP 4.7+ |
|
57 | - if ( 'wl_entity_type' === $taxonomy->name || ! $taxonomy->public ) { |
|
58 | - continue; |
|
59 | - } |
|
60 | - |
|
61 | - $taxonomy_terms = get_the_terms( $post_id, $taxonomy->name ); |
|
62 | - if ( is_array( $taxonomy_terms ) ) { |
|
63 | - $terms = array_merge( $terms, $taxonomy_terms ); |
|
64 | - } |
|
65 | - } |
|
66 | - |
|
67 | - // Convert everything to the Term Reference. |
|
68 | - return array_filter( |
|
69 | - array_map( |
|
70 | - function ( $term ) { |
|
71 | - /** |
|
72 | - * @var WP_Term $term |
|
73 | - */ |
|
74 | - if ( Wordpress_Term_Content_Legacy_Service::get_instance() |
|
75 | - ->get_entity_id( Wordpress_Content_Id::create_term( $term->term_id ) ) |
|
76 | - ) { |
|
77 | - return new Term_Reference( $term->term_id ); |
|
78 | - } |
|
79 | - |
|
80 | - return false; |
|
81 | - }, |
|
82 | - $terms |
|
83 | - ) |
|
84 | - ); |
|
85 | - |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * @param $jsonld array |
|
90 | - * @param $term_references array<Term_Reference> |
|
91 | - */ |
|
92 | - private function append_term_mentions( $jsonld, $term_references ) { |
|
93 | - |
|
94 | - $existing_mentions = array_key_exists( 'mentions', $jsonld ) ? $jsonld['mentions'] : array(); |
|
95 | - |
|
96 | - $term_mentions = array_map( |
|
97 | - function ( $term_reference ) { |
|
98 | - return array( |
|
99 | - '@id' => Wordpress_Term_Content_Legacy_Service::get_instance() |
|
100 | - ->get_entity_id( Wordpress_Content_Id::create_term( $term_reference->get_id() ) ), |
|
101 | - ); |
|
102 | - }, |
|
103 | - $term_references |
|
104 | - ); |
|
105 | - |
|
106 | - return array_merge( $existing_mentions, $term_mentions ); |
|
107 | - } |
|
19 | + public function init() { |
|
20 | + add_filter( 'wl_post_jsonld_array', array( $this, 'wl_post_jsonld_array' ), 10, 2 ); |
|
21 | + } |
|
22 | + |
|
23 | + public function wl_post_jsonld_array( $data, $post_id ) { |
|
24 | + |
|
25 | + $term_references = $this->get_term_references( $post_id ); |
|
26 | + |
|
27 | + if ( ! $term_references ) { |
|
28 | + return $data; |
|
29 | + } |
|
30 | + |
|
31 | + $references = $data['references']; |
|
32 | + $jsonld = $data['jsonld']; |
|
33 | + |
|
34 | + $jsonld['mentions'] = $this->append_term_mentions( $jsonld, $term_references ); |
|
35 | + |
|
36 | + return array( |
|
37 | + 'jsonld' => $jsonld, |
|
38 | + 'references' => array_merge( $references, $term_references ), |
|
39 | + ); |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * @param $post_id |
|
44 | + * |
|
45 | + * @return array Returns a list of term references, Returns empty array if none found. |
|
46 | + */ |
|
47 | + private function get_term_references( $post_id ) { |
|
48 | + |
|
49 | + /** @var WP_Taxonomy[] $taxonomies_for_post */ |
|
50 | + $taxonomies_for_post = get_object_taxonomies( get_post_type( $post_id ), 'objects' ); |
|
51 | + |
|
52 | + // now we need to collect all terms attached to this post. |
|
53 | + $terms = array(); |
|
54 | + |
|
55 | + foreach ( $taxonomies_for_post as $taxonomy ) { |
|
56 | + // Please note that `$taxonomy->publicly_queryable is only WP 4.7+ |
|
57 | + if ( 'wl_entity_type' === $taxonomy->name || ! $taxonomy->public ) { |
|
58 | + continue; |
|
59 | + } |
|
60 | + |
|
61 | + $taxonomy_terms = get_the_terms( $post_id, $taxonomy->name ); |
|
62 | + if ( is_array( $taxonomy_terms ) ) { |
|
63 | + $terms = array_merge( $terms, $taxonomy_terms ); |
|
64 | + } |
|
65 | + } |
|
66 | + |
|
67 | + // Convert everything to the Term Reference. |
|
68 | + return array_filter( |
|
69 | + array_map( |
|
70 | + function ( $term ) { |
|
71 | + /** |
|
72 | + * @var WP_Term $term |
|
73 | + */ |
|
74 | + if ( Wordpress_Term_Content_Legacy_Service::get_instance() |
|
75 | + ->get_entity_id( Wordpress_Content_Id::create_term( $term->term_id ) ) |
|
76 | + ) { |
|
77 | + return new Term_Reference( $term->term_id ); |
|
78 | + } |
|
79 | + |
|
80 | + return false; |
|
81 | + }, |
|
82 | + $terms |
|
83 | + ) |
|
84 | + ); |
|
85 | + |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * @param $jsonld array |
|
90 | + * @param $term_references array<Term_Reference> |
|
91 | + */ |
|
92 | + private function append_term_mentions( $jsonld, $term_references ) { |
|
93 | + |
|
94 | + $existing_mentions = array_key_exists( 'mentions', $jsonld ) ? $jsonld['mentions'] : array(); |
|
95 | + |
|
96 | + $term_mentions = array_map( |
|
97 | + function ( $term_reference ) { |
|
98 | + return array( |
|
99 | + '@id' => Wordpress_Term_Content_Legacy_Service::get_instance() |
|
100 | + ->get_entity_id( Wordpress_Content_Id::create_term( $term_reference->get_id() ) ), |
|
101 | + ); |
|
102 | + }, |
|
103 | + $term_references |
|
104 | + ); |
|
105 | + |
|
106 | + return array_merge( $existing_mentions, $term_mentions ); |
|
107 | + } |
|
108 | 108 | |
109 | 109 | } |
@@ -17,25 +17,25 @@ discard block |
||
17 | 17 | class Post_Jsonld { |
18 | 18 | |
19 | 19 | public function init() { |
20 | - add_filter( 'wl_post_jsonld_array', array( $this, 'wl_post_jsonld_array' ), 10, 2 ); |
|
20 | + add_filter('wl_post_jsonld_array', array($this, 'wl_post_jsonld_array'), 10, 2); |
|
21 | 21 | } |
22 | 22 | |
23 | - public function wl_post_jsonld_array( $data, $post_id ) { |
|
23 | + public function wl_post_jsonld_array($data, $post_id) { |
|
24 | 24 | |
25 | - $term_references = $this->get_term_references( $post_id ); |
|
25 | + $term_references = $this->get_term_references($post_id); |
|
26 | 26 | |
27 | - if ( ! $term_references ) { |
|
27 | + if ( ! $term_references) { |
|
28 | 28 | return $data; |
29 | 29 | } |
30 | 30 | |
31 | 31 | $references = $data['references']; |
32 | 32 | $jsonld = $data['jsonld']; |
33 | 33 | |
34 | - $jsonld['mentions'] = $this->append_term_mentions( $jsonld, $term_references ); |
|
34 | + $jsonld['mentions'] = $this->append_term_mentions($jsonld, $term_references); |
|
35 | 35 | |
36 | 36 | return array( |
37 | 37 | 'jsonld' => $jsonld, |
38 | - 'references' => array_merge( $references, $term_references ), |
|
38 | + 'references' => array_merge($references, $term_references), |
|
39 | 39 | ); |
40 | 40 | } |
41 | 41 | |
@@ -44,37 +44,37 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return array Returns a list of term references, Returns empty array if none found. |
46 | 46 | */ |
47 | - private function get_term_references( $post_id ) { |
|
47 | + private function get_term_references($post_id) { |
|
48 | 48 | |
49 | 49 | /** @var WP_Taxonomy[] $taxonomies_for_post */ |
50 | - $taxonomies_for_post = get_object_taxonomies( get_post_type( $post_id ), 'objects' ); |
|
50 | + $taxonomies_for_post = get_object_taxonomies(get_post_type($post_id), 'objects'); |
|
51 | 51 | |
52 | 52 | // now we need to collect all terms attached to this post. |
53 | 53 | $terms = array(); |
54 | 54 | |
55 | - foreach ( $taxonomies_for_post as $taxonomy ) { |
|
55 | + foreach ($taxonomies_for_post as $taxonomy) { |
|
56 | 56 | // Please note that `$taxonomy->publicly_queryable is only WP 4.7+ |
57 | - if ( 'wl_entity_type' === $taxonomy->name || ! $taxonomy->public ) { |
|
57 | + if ('wl_entity_type' === $taxonomy->name || ! $taxonomy->public) { |
|
58 | 58 | continue; |
59 | 59 | } |
60 | 60 | |
61 | - $taxonomy_terms = get_the_terms( $post_id, $taxonomy->name ); |
|
62 | - if ( is_array( $taxonomy_terms ) ) { |
|
63 | - $terms = array_merge( $terms, $taxonomy_terms ); |
|
61 | + $taxonomy_terms = get_the_terms($post_id, $taxonomy->name); |
|
62 | + if (is_array($taxonomy_terms)) { |
|
63 | + $terms = array_merge($terms, $taxonomy_terms); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | 67 | // Convert everything to the Term Reference. |
68 | 68 | return array_filter( |
69 | 69 | array_map( |
70 | - function ( $term ) { |
|
70 | + function($term) { |
|
71 | 71 | /** |
72 | 72 | * @var WP_Term $term |
73 | 73 | */ |
74 | - if ( Wordpress_Term_Content_Legacy_Service::get_instance() |
|
75 | - ->get_entity_id( Wordpress_Content_Id::create_term( $term->term_id ) ) |
|
74 | + if (Wordpress_Term_Content_Legacy_Service::get_instance() |
|
75 | + ->get_entity_id(Wordpress_Content_Id::create_term($term->term_id)) |
|
76 | 76 | ) { |
77 | - return new Term_Reference( $term->term_id ); |
|
77 | + return new Term_Reference($term->term_id); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | return false; |
@@ -89,21 +89,21 @@ discard block |
||
89 | 89 | * @param $jsonld array |
90 | 90 | * @param $term_references array<Term_Reference> |
91 | 91 | */ |
92 | - private function append_term_mentions( $jsonld, $term_references ) { |
|
92 | + private function append_term_mentions($jsonld, $term_references) { |
|
93 | 93 | |
94 | - $existing_mentions = array_key_exists( 'mentions', $jsonld ) ? $jsonld['mentions'] : array(); |
|
94 | + $existing_mentions = array_key_exists('mentions', $jsonld) ? $jsonld['mentions'] : array(); |
|
95 | 95 | |
96 | 96 | $term_mentions = array_map( |
97 | - function ( $term_reference ) { |
|
97 | + function($term_reference) { |
|
98 | 98 | return array( |
99 | 99 | '@id' => Wordpress_Term_Content_Legacy_Service::get_instance() |
100 | - ->get_entity_id( Wordpress_Content_Id::create_term( $term_reference->get_id() ) ), |
|
100 | + ->get_entity_id(Wordpress_Content_Id::create_term($term_reference->get_id())), |
|
101 | 101 | ); |
102 | 102 | }, |
103 | 103 | $term_references |
104 | 104 | ); |
105 | 105 | |
106 | - return array_merge( $existing_mentions, $term_mentions ); |
|
106 | + return array_merge($existing_mentions, $term_mentions); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | } |
@@ -4,20 +4,20 @@ |
||
4 | 4 | |
5 | 5 | interface Task { |
6 | 6 | |
7 | - /** |
|
8 | - * @return int The total number of items to process. |
|
9 | - */ |
|
10 | - public function starting(); |
|
7 | + /** |
|
8 | + * @return int The total number of items to process. |
|
9 | + */ |
|
10 | + public function starting(); |
|
11 | 11 | |
12 | - /** |
|
13 | - * @param $value mixed The incoming value. |
|
14 | - * @param $args { |
|
15 | - * |
|
16 | - * @type int $offset The index of the current item. |
|
17 | - * @type int $count The total number of items as provided by the `starting` function. |
|
18 | - * @type int $batch_size The number of items to process within this call. |
|
19 | - * } |
|
20 | - */ |
|
21 | - public function tick( $value, $args ); |
|
12 | + /** |
|
13 | + * @param $value mixed The incoming value. |
|
14 | + * @param $args { |
|
15 | + * |
|
16 | + * @type int $offset The index of the current item. |
|
17 | + * @type int $count The total number of items as provided by the `starting` function. |
|
18 | + * @type int $batch_size The number of items to process within this call. |
|
19 | + * } |
|
20 | + */ |
|
21 | + public function tick( $value, $args ); |
|
22 | 22 | |
23 | 23 | } |
@@ -18,6 +18,6 @@ |
||
18 | 18 | * @type int $batch_size The number of items to process within this call. |
19 | 19 | * } |
20 | 20 | */ |
21 | - public function tick( $value, $args ); |
|
21 | + public function tick($value, $args); |
|
22 | 22 | |
23 | 23 | } |
@@ -4,31 +4,31 @@ |
||
4 | 4 | |
5 | 5 | class Background_Task_Stopped_State extends Abstract_Background_Task_State { |
6 | 6 | |
7 | - /** |
|
8 | - * @var Background_Task |
|
9 | - */ |
|
10 | - private $context; |
|
7 | + /** |
|
8 | + * @var Background_Task |
|
9 | + */ |
|
10 | + private $context; |
|
11 | 11 | |
12 | - public function __construct( $context ) { |
|
13 | - parent::__construct( $context, Background_Task::STATE_STOPPED ); |
|
12 | + public function __construct( $context ) { |
|
13 | + parent::__construct( $context, Background_Task::STATE_STOPPED ); |
|
14 | 14 | |
15 | - $this->context = $context; |
|
16 | - } |
|
15 | + $this->context = $context; |
|
16 | + } |
|
17 | 17 | |
18 | - public function enter() { |
|
19 | - $this->context->set_state( Background_Task::STATE_STOPPED ); |
|
20 | - } |
|
18 | + public function enter() { |
|
19 | + $this->context->set_state( Background_Task::STATE_STOPPED ); |
|
20 | + } |
|
21 | 21 | |
22 | - public function leave() { |
|
23 | - $this->context->set_state( null ); |
|
24 | - } |
|
22 | + public function leave() { |
|
23 | + $this->context->set_state( null ); |
|
24 | + } |
|
25 | 25 | |
26 | - // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
|
27 | - public function task( $value ) { |
|
26 | + // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
|
27 | + public function task( $value ) { |
|
28 | 28 | |
29 | - $this->context->cancel_process(); |
|
29 | + $this->context->cancel_process(); |
|
30 | 30 | |
31 | - return false; |
|
32 | - } |
|
31 | + return false; |
|
32 | + } |
|
33 | 33 | |
34 | 34 | } |
@@ -9,22 +9,22 @@ |
||
9 | 9 | */ |
10 | 10 | private $context; |
11 | 11 | |
12 | - public function __construct( $context ) { |
|
13 | - parent::__construct( $context, Background_Task::STATE_STOPPED ); |
|
12 | + public function __construct($context) { |
|
13 | + parent::__construct($context, Background_Task::STATE_STOPPED); |
|
14 | 14 | |
15 | 15 | $this->context = $context; |
16 | 16 | } |
17 | 17 | |
18 | 18 | public function enter() { |
19 | - $this->context->set_state( Background_Task::STATE_STOPPED ); |
|
19 | + $this->context->set_state(Background_Task::STATE_STOPPED); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | public function leave() { |
23 | - $this->context->set_state( null ); |
|
23 | + $this->context->set_state(null); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
27 | - public function task( $value ) { |
|
27 | + public function task($value) { |
|
28 | 28 | |
29 | 29 | $this->context->cancel_process(); |
30 | 30 |
@@ -8,73 +8,73 @@ discard block |
||
8 | 8 | |
9 | 9 | class Background_Task_Page { |
10 | 10 | |
11 | - private $title; |
|
12 | - |
|
13 | - private $menu_slug; |
|
14 | - |
|
15 | - /** |
|
16 | - * @var Background_Task_Route $background_task_route |
|
17 | - */ |
|
18 | - private $background_task_route; |
|
19 | - |
|
20 | - /** |
|
21 | - * @throws Exception if one or more parameters are invalid. |
|
22 | - */ |
|
23 | - public function __construct( $title, $menu_slug, $background_task_route ) { |
|
24 | - Assertions::not_empty( $title, '`$title` cannot be empty.' ); |
|
25 | - Assertions::not_empty( $menu_slug, '`$menu_slug` cannot be empty.' ); |
|
26 | - Assertions::is_a( $background_task_route, 'Wordlift\Task\Background\Background_Task_Route', '`Background_Task_Route` must be of type `Wordlift\Task\Background\Background_Route`.' ); |
|
27 | - |
|
28 | - add_action( 'admin_menu', array( $this, 'admin_menu' ) ); |
|
29 | - |
|
30 | - $this->title = $title; |
|
31 | - $this->menu_slug = $menu_slug; |
|
32 | - $this->background_task_route = $background_task_route; |
|
33 | - } |
|
34 | - |
|
35 | - /** |
|
36 | - * @throws Exception if one or more parameters are invalid. |
|
37 | - */ |
|
38 | - public static function create( $title, $menu_slug, $background_route ) { |
|
39 | - return new self( $title, $menu_slug, $background_route ); |
|
40 | - } |
|
41 | - |
|
42 | - public function admin_menu() { |
|
43 | - |
|
44 | - add_submenu_page( |
|
45 | - 'wl_admin_menu', |
|
46 | - $this->title, |
|
47 | - $this->title, |
|
48 | - 'manage_options', |
|
49 | - $this->menu_slug, |
|
50 | - array( |
|
51 | - $this, |
|
52 | - 'render', |
|
53 | - ) |
|
54 | - ); |
|
55 | - |
|
56 | - } |
|
57 | - |
|
58 | - public function render() { |
|
59 | - |
|
60 | - wp_enqueue_style( |
|
61 | - 'wl-task-page', |
|
62 | - plugin_dir_url( __FILE__ ) . 'assets/task-page.css', |
|
63 | - array(), |
|
64 | - Wordlift::get_instance()->get_version(), |
|
65 | - 'all' |
|
66 | - ); |
|
67 | - |
|
68 | - wp_enqueue_script( |
|
69 | - 'wl-task-page', |
|
70 | - plugin_dir_url( __FILE__ ) . 'assets/task-page.js', |
|
71 | - array( 'wp-api' ), |
|
72 | - WORDLIFT_VERSION, |
|
73 | - false |
|
74 | - ); |
|
75 | - |
|
76 | - wp_localize_script( 'wl-task-page', '_wlTaskPageSettings', array( 'rest_path' => $this->background_task_route->get_rest_path() ) ); |
|
77 | - ?> |
|
11 | + private $title; |
|
12 | + |
|
13 | + private $menu_slug; |
|
14 | + |
|
15 | + /** |
|
16 | + * @var Background_Task_Route $background_task_route |
|
17 | + */ |
|
18 | + private $background_task_route; |
|
19 | + |
|
20 | + /** |
|
21 | + * @throws Exception if one or more parameters are invalid. |
|
22 | + */ |
|
23 | + public function __construct( $title, $menu_slug, $background_task_route ) { |
|
24 | + Assertions::not_empty( $title, '`$title` cannot be empty.' ); |
|
25 | + Assertions::not_empty( $menu_slug, '`$menu_slug` cannot be empty.' ); |
|
26 | + Assertions::is_a( $background_task_route, 'Wordlift\Task\Background\Background_Task_Route', '`Background_Task_Route` must be of type `Wordlift\Task\Background\Background_Route`.' ); |
|
27 | + |
|
28 | + add_action( 'admin_menu', array( $this, 'admin_menu' ) ); |
|
29 | + |
|
30 | + $this->title = $title; |
|
31 | + $this->menu_slug = $menu_slug; |
|
32 | + $this->background_task_route = $background_task_route; |
|
33 | + } |
|
34 | + |
|
35 | + /** |
|
36 | + * @throws Exception if one or more parameters are invalid. |
|
37 | + */ |
|
38 | + public static function create( $title, $menu_slug, $background_route ) { |
|
39 | + return new self( $title, $menu_slug, $background_route ); |
|
40 | + } |
|
41 | + |
|
42 | + public function admin_menu() { |
|
43 | + |
|
44 | + add_submenu_page( |
|
45 | + 'wl_admin_menu', |
|
46 | + $this->title, |
|
47 | + $this->title, |
|
48 | + 'manage_options', |
|
49 | + $this->menu_slug, |
|
50 | + array( |
|
51 | + $this, |
|
52 | + 'render', |
|
53 | + ) |
|
54 | + ); |
|
55 | + |
|
56 | + } |
|
57 | + |
|
58 | + public function render() { |
|
59 | + |
|
60 | + wp_enqueue_style( |
|
61 | + 'wl-task-page', |
|
62 | + plugin_dir_url( __FILE__ ) . 'assets/task-page.css', |
|
63 | + array(), |
|
64 | + Wordlift::get_instance()->get_version(), |
|
65 | + 'all' |
|
66 | + ); |
|
67 | + |
|
68 | + wp_enqueue_script( |
|
69 | + 'wl-task-page', |
|
70 | + plugin_dir_url( __FILE__ ) . 'assets/task-page.js', |
|
71 | + array( 'wp-api' ), |
|
72 | + WORDLIFT_VERSION, |
|
73 | + false |
|
74 | + ); |
|
75 | + |
|
76 | + wp_localize_script( 'wl-task-page', '_wlTaskPageSettings', array( 'rest_path' => $this->background_task_route->get_rest_path() ) ); |
|
77 | + ?> |
|
78 | 78 | <div class="wrap"> |
79 | 79 | <h2><?php echo esc_html( $this->title ); ?></h2> |
80 | 80 | |
@@ -85,17 +85,17 @@ discard block |
||
85 | 85 | |
86 | 86 | <button id="wl-start-btn" type="button" class="button button-large button-primary"> |
87 | 87 | <?php |
88 | - esc_html_e( 'Start', 'wordlift' ); |
|
89 | - ?> |
|
88 | + esc_html_e( 'Start', 'wordlift' ); |
|
89 | + ?> |
|
90 | 90 | </button> |
91 | 91 | <button id="wl-stop-btn" type="button" class="button button-large button-primary hidden"> |
92 | 92 | <?php |
93 | - esc_html_e( 'Stop', 'wordlift' ); |
|
94 | - ?> |
|
93 | + esc_html_e( 'Stop', 'wordlift' ); |
|
94 | + ?> |
|
95 | 95 | </button> |
96 | 96 | |
97 | 97 | </div> |
98 | 98 | <?php |
99 | - } |
|
99 | + } |
|
100 | 100 | |
101 | 101 | } |
@@ -20,12 +20,12 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * @throws Exception if one or more parameters are invalid. |
22 | 22 | */ |
23 | - public function __construct( $title, $menu_slug, $background_task_route ) { |
|
24 | - Assertions::not_empty( $title, '`$title` cannot be empty.' ); |
|
25 | - Assertions::not_empty( $menu_slug, '`$menu_slug` cannot be empty.' ); |
|
26 | - Assertions::is_a( $background_task_route, 'Wordlift\Task\Background\Background_Task_Route', '`Background_Task_Route` must be of type `Wordlift\Task\Background\Background_Route`.' ); |
|
23 | + public function __construct($title, $menu_slug, $background_task_route) { |
|
24 | + Assertions::not_empty($title, '`$title` cannot be empty.'); |
|
25 | + Assertions::not_empty($menu_slug, '`$menu_slug` cannot be empty.'); |
|
26 | + Assertions::is_a($background_task_route, 'Wordlift\Task\Background\Background_Task_Route', '`Background_Task_Route` must be of type `Wordlift\Task\Background\Background_Route`.'); |
|
27 | 27 | |
28 | - add_action( 'admin_menu', array( $this, 'admin_menu' ) ); |
|
28 | + add_action('admin_menu', array($this, 'admin_menu')); |
|
29 | 29 | |
30 | 30 | $this->title = $title; |
31 | 31 | $this->menu_slug = $menu_slug; |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | /** |
36 | 36 | * @throws Exception if one or more parameters are invalid. |
37 | 37 | */ |
38 | - public static function create( $title, $menu_slug, $background_route ) { |
|
39 | - return new self( $title, $menu_slug, $background_route ); |
|
38 | + public static function create($title, $menu_slug, $background_route) { |
|
39 | + return new self($title, $menu_slug, $background_route); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | public function admin_menu() { |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | wp_enqueue_style( |
61 | 61 | 'wl-task-page', |
62 | - plugin_dir_url( __FILE__ ) . 'assets/task-page.css', |
|
62 | + plugin_dir_url(__FILE__).'assets/task-page.css', |
|
63 | 63 | array(), |
64 | 64 | Wordlift::get_instance()->get_version(), |
65 | 65 | 'all' |
@@ -67,16 +67,16 @@ discard block |
||
67 | 67 | |
68 | 68 | wp_enqueue_script( |
69 | 69 | 'wl-task-page', |
70 | - plugin_dir_url( __FILE__ ) . 'assets/task-page.js', |
|
71 | - array( 'wp-api' ), |
|
70 | + plugin_dir_url(__FILE__).'assets/task-page.js', |
|
71 | + array('wp-api'), |
|
72 | 72 | WORDLIFT_VERSION, |
73 | 73 | false |
74 | 74 | ); |
75 | 75 | |
76 | - wp_localize_script( 'wl-task-page', '_wlTaskPageSettings', array( 'rest_path' => $this->background_task_route->get_rest_path() ) ); |
|
76 | + wp_localize_script('wl-task-page', '_wlTaskPageSettings', array('rest_path' => $this->background_task_route->get_rest_path())); |
|
77 | 77 | ?> |
78 | 78 | <div class="wrap"> |
79 | - <h2><?php echo esc_html( $this->title ); ?></h2> |
|
79 | + <h2><?php echo esc_html($this->title); ?></h2> |
|
80 | 80 | |
81 | 81 | <div class="wl-task__progress" style="border: 1px solid #23282D; height: 20px; margin: 8px 0;"> |
82 | 82 | <div class="wl-task__progress__bar" |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | |
86 | 86 | <button id="wl-start-btn" type="button" class="button button-large button-primary"> |
87 | 87 | <?php |
88 | - esc_html_e( 'Start', 'wordlift' ); |
|
88 | + esc_html_e('Start', 'wordlift'); |
|
89 | 89 | ?> |
90 | 90 | </button> |
91 | 91 | <button id="wl-stop-btn" type="button" class="button button-large button-primary hidden"> |
92 | 92 | <?php |
93 | - esc_html_e( 'Stop', 'wordlift' ); |
|
93 | + esc_html_e('Stop', 'wordlift'); |
|
94 | 94 | ?> |
95 | 95 | </button> |
96 | 96 |