@@ -8,18 +8,18 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | class Wordlift_Install_3_36_0 extends Wordlift_Install { |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * {@inheritdoc} |
|
| 13 | - */ |
|
| 14 | - protected static $version = '3.36.1'; |
|
| 11 | + /** |
|
| 12 | + * {@inheritdoc} |
|
| 13 | + */ |
|
| 14 | + protected static $version = '3.36.1'; |
|
| 15 | 15 | |
| 16 | - public function install() { |
|
| 16 | + public function install() { |
|
| 17 | 17 | |
| 18 | - $is_woocommerce_extension_installed = defined( 'WL_WOO_VERSION' ); |
|
| 18 | + $is_woocommerce_extension_installed = defined( 'WL_WOO_VERSION' ); |
|
| 19 | 19 | |
| 20 | - if ( $is_woocommerce_extension_installed ) { |
|
| 21 | - do_action( 'wl_install_and_activate_advanced-custom-fields-for-schema-org' ); |
|
| 22 | - } |
|
| 23 | - } |
|
| 20 | + if ( $is_woocommerce_extension_installed ) { |
|
| 21 | + do_action( 'wl_install_and_activate_advanced-custom-fields-for-schema-org' ); |
|
| 22 | + } |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | 25 | } |
@@ -15,70 +15,70 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class Wordlift_Website_Jsonld_Converter extends Wordlift_Post_To_Jsonld_Converter { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Convert the home/blog page to a JSON-LD array. |
|
| 20 | - * |
|
| 21 | - * @return array A JSON-LD array. |
|
| 22 | - * @since 3.14.0 |
|
| 23 | - * |
|
| 24 | - */ |
|
| 25 | - public function create_schema() { |
|
| 18 | + /** |
|
| 19 | + * Convert the home/blog page to a JSON-LD array. |
|
| 20 | + * |
|
| 21 | + * @return array A JSON-LD array. |
|
| 22 | + * @since 3.14.0 |
|
| 23 | + * |
|
| 24 | + */ |
|
| 25 | + public function create_schema() { |
|
| 26 | 26 | |
| 27 | - // Create new jsonld. |
|
| 28 | - $home_url = home_url( '/' ); |
|
| 27 | + // Create new jsonld. |
|
| 28 | + $home_url = home_url( '/' ); |
|
| 29 | 29 | |
| 30 | - $jsonld = array( |
|
| 31 | - '@context' => 'http://schema.org', |
|
| 32 | - '@type' => 'WebSite', |
|
| 33 | - '@id' => "$home_url#website", |
|
| 34 | - 'name' => html_entity_decode( get_bloginfo( 'name' ), ENT_QUOTES ), |
|
| 35 | - 'alternateName' => html_entity_decode( get_bloginfo( 'description' ), ENT_QUOTES ), |
|
| 36 | - 'url' => $home_url, |
|
| 37 | - ); |
|
| 30 | + $jsonld = array( |
|
| 31 | + '@context' => 'http://schema.org', |
|
| 32 | + '@type' => 'WebSite', |
|
| 33 | + '@id' => "$home_url#website", |
|
| 34 | + 'name' => html_entity_decode( get_bloginfo( 'name' ), ENT_QUOTES ), |
|
| 35 | + 'alternateName' => html_entity_decode( get_bloginfo( 'description' ), ENT_QUOTES ), |
|
| 36 | + 'url' => $home_url, |
|
| 37 | + ); |
|
| 38 | 38 | |
| 39 | - // Add publisher information. |
|
| 40 | - $this->set_publisher( $jsonld ); |
|
| 39 | + // Add publisher information. |
|
| 40 | + $this->set_publisher( $jsonld ); |
|
| 41 | 41 | |
| 42 | - // Add search action. |
|
| 43 | - $this->set_search_action( $jsonld ); |
|
| 42 | + // Add search action. |
|
| 43 | + $this->set_search_action( $jsonld ); |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Call the `wl_website_jsonld` filter. |
|
| 47 | - * |
|
| 48 | - * @param array $jsonld The JSON-LD structure. |
|
| 49 | - * |
|
| 50 | - * @since 3.14.0 |
|
| 51 | - * |
|
| 52 | - * @api |
|
| 53 | - * |
|
| 54 | - */ |
|
| 55 | - return apply_filters( 'wl_website_jsonld', $jsonld ); |
|
| 56 | - } |
|
| 45 | + /** |
|
| 46 | + * Call the `wl_website_jsonld` filter. |
|
| 47 | + * |
|
| 48 | + * @param array $jsonld The JSON-LD structure. |
|
| 49 | + * |
|
| 50 | + * @since 3.14.0 |
|
| 51 | + * |
|
| 52 | + * @api |
|
| 53 | + * |
|
| 54 | + */ |
|
| 55 | + return apply_filters( 'wl_website_jsonld', $jsonld ); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Add SearchAction part to the schema |
|
| 60 | - * |
|
| 61 | - * @param array $params The parameters array. |
|
| 62 | - * |
|
| 63 | - * @since 3.14.0 |
|
| 64 | - * |
|
| 65 | - */ |
|
| 66 | - private function set_search_action( &$params ) { |
|
| 67 | - /** |
|
| 68 | - * Filter: 'wl_jsonld_search_url' - Allows filtering of the search URL. |
|
| 69 | - * |
|
| 70 | - * @since 3.14.0 |
|
| 71 | - * @api string $search_url The search URL for this site with a `{search_term_string}` variable. |
|
| 72 | - */ |
|
| 73 | - $search_url = apply_filters( 'wl_jsonld_search_url', home_url( '/' ) . '?s={search_term_string}' ); |
|
| 58 | + /** |
|
| 59 | + * Add SearchAction part to the schema |
|
| 60 | + * |
|
| 61 | + * @param array $params The parameters array. |
|
| 62 | + * |
|
| 63 | + * @since 3.14.0 |
|
| 64 | + * |
|
| 65 | + */ |
|
| 66 | + private function set_search_action( &$params ) { |
|
| 67 | + /** |
|
| 68 | + * Filter: 'wl_jsonld_search_url' - Allows filtering of the search URL. |
|
| 69 | + * |
|
| 70 | + * @since 3.14.0 |
|
| 71 | + * @api string $search_url The search URL for this site with a `{search_term_string}` variable. |
|
| 72 | + */ |
|
| 73 | + $search_url = apply_filters( 'wl_jsonld_search_url', home_url( '/' ) . '?s={search_term_string}' ); |
|
| 74 | 74 | |
| 75 | - // Add search action |
|
| 76 | - $params['potentialAction'] = array( |
|
| 77 | - '@type' => 'SearchAction', |
|
| 78 | - 'target' => $search_url, |
|
| 79 | - 'query-input' => 'required name=search_term_string', |
|
| 80 | - ); |
|
| 75 | + // Add search action |
|
| 76 | + $params['potentialAction'] = array( |
|
| 77 | + '@type' => 'SearchAction', |
|
| 78 | + 'target' => $search_url, |
|
| 79 | + 'query-input' => 'required name=search_term_string', |
|
| 80 | + ); |
|
| 81 | 81 | |
| 82 | - } |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | 84 | } |
@@ -25,22 +25,22 @@ discard block |
||
| 25 | 25 | public function create_schema() { |
| 26 | 26 | |
| 27 | 27 | // Create new jsonld. |
| 28 | - $home_url = home_url( '/' ); |
|
| 28 | + $home_url = home_url('/'); |
|
| 29 | 29 | |
| 30 | 30 | $jsonld = array( |
| 31 | 31 | '@context' => 'http://schema.org', |
| 32 | 32 | '@type' => 'WebSite', |
| 33 | 33 | '@id' => "$home_url#website", |
| 34 | - 'name' => html_entity_decode( get_bloginfo( 'name' ), ENT_QUOTES ), |
|
| 35 | - 'alternateName' => html_entity_decode( get_bloginfo( 'description' ), ENT_QUOTES ), |
|
| 34 | + 'name' => html_entity_decode(get_bloginfo('name'), ENT_QUOTES), |
|
| 35 | + 'alternateName' => html_entity_decode(get_bloginfo('description'), ENT_QUOTES), |
|
| 36 | 36 | 'url' => $home_url, |
| 37 | 37 | ); |
| 38 | 38 | |
| 39 | 39 | // Add publisher information. |
| 40 | - $this->set_publisher( $jsonld ); |
|
| 40 | + $this->set_publisher($jsonld); |
|
| 41 | 41 | |
| 42 | 42 | // Add search action. |
| 43 | - $this->set_search_action( $jsonld ); |
|
| 43 | + $this->set_search_action($jsonld); |
|
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | 46 | * Call the `wl_website_jsonld` filter. |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * @api |
| 53 | 53 | * |
| 54 | 54 | */ |
| 55 | - return apply_filters( 'wl_website_jsonld', $jsonld ); |
|
| 55 | + return apply_filters('wl_website_jsonld', $jsonld); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -63,14 +63,14 @@ discard block |
||
| 63 | 63 | * @since 3.14.0 |
| 64 | 64 | * |
| 65 | 65 | */ |
| 66 | - private function set_search_action( &$params ) { |
|
| 66 | + private function set_search_action(&$params) { |
|
| 67 | 67 | /** |
| 68 | 68 | * Filter: 'wl_jsonld_search_url' - Allows filtering of the search URL. |
| 69 | 69 | * |
| 70 | 70 | * @since 3.14.0 |
| 71 | 71 | * @api string $search_url The search URL for this site with a `{search_term_string}` variable. |
| 72 | 72 | */ |
| 73 | - $search_url = apply_filters( 'wl_jsonld_search_url', home_url( '/' ) . '?s={search_term_string}' ); |
|
| 73 | + $search_url = apply_filters('wl_jsonld_search_url', home_url('/').'?s={search_term_string}'); |
|
| 74 | 74 | |
| 75 | 75 | // Add search action |
| 76 | 76 | $params['potentialAction'] = array( |
@@ -23,400 +23,400 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | abstract class Wordlift_Abstract_Post_To_Jsonld_Converter implements Wordlift_Post_Converter { |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * The JSON-LD context. |
|
| 28 | - * |
|
| 29 | - * @since 3.10.0 |
|
| 30 | - */ |
|
| 31 | - const CONTEXT = 'http://schema.org'; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * A {@link Wordlift_Entity_Type_Service} instance. |
|
| 35 | - * |
|
| 36 | - * @since 3.10.0 |
|
| 37 | - * @access protected |
|
| 38 | - * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 39 | - */ |
|
| 40 | - protected $entity_type_service; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * A {@link Wordlift_User_Service} instance. |
|
| 44 | - * |
|
| 45 | - * @since 3.10.0 |
|
| 46 | - * @access private |
|
| 47 | - * @var \Wordlift_User_Service $user_service A {@link Wordlift_User_Service} instance. |
|
| 48 | - */ |
|
| 49 | - protected $user_service; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * A {@link Wordlift_Attachment_Service} instance. |
|
| 53 | - * |
|
| 54 | - * @since 3.10.0 |
|
| 55 | - * @access private |
|
| 56 | - * @var \Wordlift_Attachment_Service $attachment_service A {@link Wordlift_Attachment_Service} instance. |
|
| 57 | - */ |
|
| 58 | - protected $attachment_service; |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * @var Wordlift_Property_Getter |
|
| 62 | - */ |
|
| 63 | - private $property_getter; |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * Wordlift_Post_To_Jsonld_Converter constructor. |
|
| 67 | - * |
|
| 68 | - * @param \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 69 | - * @param \Wordlift_User_Service $user_service A {@link Wordlift_User_Service} instance. |
|
| 70 | - * @param \Wordlift_Attachment_Service $attachment_service A {@link Wordlift_Attachment_Service} instance. |
|
| 71 | - * @param \Wordlift_Property_Getter $property_getter |
|
| 72 | - * |
|
| 73 | - * @since 3.10.0 |
|
| 74 | - * |
|
| 75 | - */ |
|
| 76 | - public function __construct( $entity_type_service, $user_service, $attachment_service, $property_getter ) { |
|
| 77 | - $this->entity_type_service = $entity_type_service; |
|
| 78 | - $this->user_service = $user_service; |
|
| 79 | - $this->attachment_service = $attachment_service; |
|
| 80 | - $this->property_getter = $property_getter; |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * Convert the provided {@link WP_Post} to a JSON-LD array. Any entity reference |
|
| 85 | - * found while processing the post is set in the $references array. |
|
| 86 | - * |
|
| 87 | - * @param int $post_id The post id. |
|
| 88 | - * @param array $references An array of entity references. |
|
| 89 | - * @param array $references_infos |
|
| 90 | - * |
|
| 91 | - * @return array A JSON-LD array. |
|
| 92 | - * @since 3.10.0 |
|
| 93 | - */ |
|
| 94 | - public function convert( $post_id, &$references = array(), &$references_infos = array() ) { |
|
| 95 | - |
|
| 96 | - // Get the post instance. |
|
| 97 | - $post = get_post( $post_id ); |
|
| 98 | - if ( null === $post ) { |
|
| 99 | - // Post not found. |
|
| 100 | - return null; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - // Get the post URI @id. |
|
| 104 | - $id = Wordlift_Entity_Service::get_instance()->get_uri( $post->ID ); |
|
| 105 | - if ( is_null( $id ) ) { |
|
| 106 | - $id = 'get_uri returned null, dataset is ' . wl_configuration_get_redlink_dataset_uri(); |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - /* |
|
| 26 | + /** |
|
| 27 | + * The JSON-LD context. |
|
| 28 | + * |
|
| 29 | + * @since 3.10.0 |
|
| 30 | + */ |
|
| 31 | + const CONTEXT = 'http://schema.org'; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * A {@link Wordlift_Entity_Type_Service} instance. |
|
| 35 | + * |
|
| 36 | + * @since 3.10.0 |
|
| 37 | + * @access protected |
|
| 38 | + * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 39 | + */ |
|
| 40 | + protected $entity_type_service; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * A {@link Wordlift_User_Service} instance. |
|
| 44 | + * |
|
| 45 | + * @since 3.10.0 |
|
| 46 | + * @access private |
|
| 47 | + * @var \Wordlift_User_Service $user_service A {@link Wordlift_User_Service} instance. |
|
| 48 | + */ |
|
| 49 | + protected $user_service; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * A {@link Wordlift_Attachment_Service} instance. |
|
| 53 | + * |
|
| 54 | + * @since 3.10.0 |
|
| 55 | + * @access private |
|
| 56 | + * @var \Wordlift_Attachment_Service $attachment_service A {@link Wordlift_Attachment_Service} instance. |
|
| 57 | + */ |
|
| 58 | + protected $attachment_service; |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * @var Wordlift_Property_Getter |
|
| 62 | + */ |
|
| 63 | + private $property_getter; |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * Wordlift_Post_To_Jsonld_Converter constructor. |
|
| 67 | + * |
|
| 68 | + * @param \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 69 | + * @param \Wordlift_User_Service $user_service A {@link Wordlift_User_Service} instance. |
|
| 70 | + * @param \Wordlift_Attachment_Service $attachment_service A {@link Wordlift_Attachment_Service} instance. |
|
| 71 | + * @param \Wordlift_Property_Getter $property_getter |
|
| 72 | + * |
|
| 73 | + * @since 3.10.0 |
|
| 74 | + * |
|
| 75 | + */ |
|
| 76 | + public function __construct( $entity_type_service, $user_service, $attachment_service, $property_getter ) { |
|
| 77 | + $this->entity_type_service = $entity_type_service; |
|
| 78 | + $this->user_service = $user_service; |
|
| 79 | + $this->attachment_service = $attachment_service; |
|
| 80 | + $this->property_getter = $property_getter; |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * Convert the provided {@link WP_Post} to a JSON-LD array. Any entity reference |
|
| 85 | + * found while processing the post is set in the $references array. |
|
| 86 | + * |
|
| 87 | + * @param int $post_id The post id. |
|
| 88 | + * @param array $references An array of entity references. |
|
| 89 | + * @param array $references_infos |
|
| 90 | + * |
|
| 91 | + * @return array A JSON-LD array. |
|
| 92 | + * @since 3.10.0 |
|
| 93 | + */ |
|
| 94 | + public function convert( $post_id, &$references = array(), &$references_infos = array() ) { |
|
| 95 | + |
|
| 96 | + // Get the post instance. |
|
| 97 | + $post = get_post( $post_id ); |
|
| 98 | + if ( null === $post ) { |
|
| 99 | + // Post not found. |
|
| 100 | + return null; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + // Get the post URI @id. |
|
| 104 | + $id = Wordlift_Entity_Service::get_instance()->get_uri( $post->ID ); |
|
| 105 | + if ( is_null( $id ) ) { |
|
| 106 | + $id = 'get_uri returned null, dataset is ' . wl_configuration_get_redlink_dataset_uri(); |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + /* |
|
| 110 | 110 | * The `types` variable holds one or more entity types. The `type` variable isn't used anymore. |
| 111 | 111 | * |
| 112 | 112 | * @since 3.20.0 We support more than one entity type. |
| 113 | 113 | * |
| 114 | 114 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
| 115 | 115 | */ |
| 116 | - // // Get the entity @type. We consider `post` BlogPostings. |
|
| 117 | - // $type = $this->entity_type_service->get( $post_id ); |
|
| 118 | - $types = $this->entity_type_service->get_names( $post_id ); |
|
| 119 | - $type = self::make_one( $types ); |
|
| 120 | - |
|
| 121 | - // Prepare the response. |
|
| 122 | - $jsonld = array( |
|
| 123 | - '@context' => self::CONTEXT, |
|
| 124 | - '@id' => $id, |
|
| 125 | - '@type' => $type, |
|
| 126 | - 'description' => Wordlift_Post_Excerpt_Helper::get_text_excerpt( $post ), |
|
| 127 | - ); |
|
| 128 | - |
|
| 129 | - // Set the `mainEntityOfPage` property if the post has some contents. |
|
| 130 | - /* |
|
| 116 | + // // Get the entity @type. We consider `post` BlogPostings. |
|
| 117 | + // $type = $this->entity_type_service->get( $post_id ); |
|
| 118 | + $types = $this->entity_type_service->get_names( $post_id ); |
|
| 119 | + $type = self::make_one( $types ); |
|
| 120 | + |
|
| 121 | + // Prepare the response. |
|
| 122 | + $jsonld = array( |
|
| 123 | + '@context' => self::CONTEXT, |
|
| 124 | + '@id' => $id, |
|
| 125 | + '@type' => $type, |
|
| 126 | + 'description' => Wordlift_Post_Excerpt_Helper::get_text_excerpt( $post ), |
|
| 127 | + ); |
|
| 128 | + |
|
| 129 | + // Set the `mainEntityOfPage` property if the post has some contents. |
|
| 130 | + /* |
|
| 131 | 131 | * Apply the `wl_post_content` filter, in case 3rd parties want to change the post content, e.g. |
| 132 | 132 | * because the content is written elsewhere. |
| 133 | 133 | * |
| 134 | 134 | * @since 3.20.0 |
| 135 | 135 | */ |
| 136 | - $post_content = apply_filters( 'wl_post_content', $post->post_content, $post ); |
|
| 137 | - if ( ! empty( $post_content ) ) { |
|
| 138 | - // We're setting the `mainEntityOfPage` to signal which one is the |
|
| 139 | - // main entity for the specified URL. It might be however that the |
|
| 140 | - // post/page is actually about another specific entity. How WL deals |
|
| 141 | - // with that hasn't been defined yet (see https://github.com/insideout10/wordlift-plugin/issues/451). |
|
| 142 | - // |
|
| 143 | - // See http://schema.org/mainEntityOfPage |
|
| 144 | - // |
|
| 145 | - // No need to specify `'@type' => 'WebPage'. |
|
| 146 | - // |
|
| 147 | - // See https://github.com/insideout10/wordlift-plugin/issues/451. |
|
| 148 | - $jsonld['mainEntityOfPage'] = get_the_permalink( $post->ID ); |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1207 |
|
| 152 | - * |
|
| 153 | - * @since 3.27.7 |
|
| 154 | - */ |
|
| 155 | - if ( in_array( $type, array( 'Occupation', 'OccupationAggregationByEmployer' ) ) ) { |
|
| 156 | - $jsonld['mainEntityOfPage'] = array( |
|
| 157 | - '@type' => 'WebPage', |
|
| 158 | - 'lastReviewed' => get_post_time( 'Y-m-d\TH:i:sP', true, $post, false ) |
|
| 159 | - ); |
|
| 160 | - } |
|
| 161 | - }; |
|
| 162 | - |
|
| 163 | - $this->set_images( $this->attachment_service, $post, $jsonld ); |
|
| 164 | - |
|
| 165 | - // Get the entities referenced by this post and set it to the `references` |
|
| 166 | - // array so that the caller can do further processing, such as printing out |
|
| 167 | - // more of those references. |
|
| 168 | - $references_without_locations = Object_Relation_Service::get_instance() |
|
| 169 | - ->get_references( $post_id, Object_Type_Enum::POST ); |
|
| 170 | - |
|
| 171 | - /* |
|
| 136 | + $post_content = apply_filters( 'wl_post_content', $post->post_content, $post ); |
|
| 137 | + if ( ! empty( $post_content ) ) { |
|
| 138 | + // We're setting the `mainEntityOfPage` to signal which one is the |
|
| 139 | + // main entity for the specified URL. It might be however that the |
|
| 140 | + // post/page is actually about another specific entity. How WL deals |
|
| 141 | + // with that hasn't been defined yet (see https://github.com/insideout10/wordlift-plugin/issues/451). |
|
| 142 | + // |
|
| 143 | + // See http://schema.org/mainEntityOfPage |
|
| 144 | + // |
|
| 145 | + // No need to specify `'@type' => 'WebPage'. |
|
| 146 | + // |
|
| 147 | + // See https://github.com/insideout10/wordlift-plugin/issues/451. |
|
| 148 | + $jsonld['mainEntityOfPage'] = get_the_permalink( $post->ID ); |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1207 |
|
| 152 | + * |
|
| 153 | + * @since 3.27.7 |
|
| 154 | + */ |
|
| 155 | + if ( in_array( $type, array( 'Occupation', 'OccupationAggregationByEmployer' ) ) ) { |
|
| 156 | + $jsonld['mainEntityOfPage'] = array( |
|
| 157 | + '@type' => 'WebPage', |
|
| 158 | + 'lastReviewed' => get_post_time( 'Y-m-d\TH:i:sP', true, $post, false ) |
|
| 159 | + ); |
|
| 160 | + } |
|
| 161 | + }; |
|
| 162 | + |
|
| 163 | + $this->set_images( $this->attachment_service, $post, $jsonld ); |
|
| 164 | + |
|
| 165 | + // Get the entities referenced by this post and set it to the `references` |
|
| 166 | + // array so that the caller can do further processing, such as printing out |
|
| 167 | + // more of those references. |
|
| 168 | + $references_without_locations = Object_Relation_Service::get_instance() |
|
| 169 | + ->get_references( $post_id, Object_Type_Enum::POST ); |
|
| 170 | + |
|
| 171 | + /* |
|
| 172 | 172 | * Add the locations to the references. |
| 173 | 173 | * |
| 174 | 174 | * @since 3.19.5 |
| 175 | 175 | * |
| 176 | 176 | * @see https://github.com/insideout10/wordlift-plugin/issues/858. |
| 177 | 177 | */ |
| 178 | - // A reference to use in closure. |
|
| 179 | - $entity_type_service = $this->entity_type_service; |
|
| 180 | - $locations = array_reduce( $references_without_locations, function ( $carry, $reference ) use ( $entity_type_service ) { |
|
| 181 | - /** |
|
| 182 | - * @var $reference Reference |
|
| 183 | - */ |
|
| 184 | - // @see https://schema.org/location for the schema.org types using the `location` property. |
|
| 185 | - if ( ! $entity_type_service->has_entity_type( $reference->get_id(), 'http://schema.org/Action' ) |
|
| 186 | - && ! $entity_type_service->has_entity_type( $reference->get_id(), 'http://schema.org/Event' ) |
|
| 187 | - && ! $entity_type_service->has_entity_type( $reference->get_id(), 'http://schema.org/Organization' ) ) { |
|
| 188 | - |
|
| 189 | - return $carry; |
|
| 190 | - } |
|
| 191 | - $post_location_ids = get_post_meta( $reference->get_id(), Wordlift_Schema_Service::FIELD_LOCATION ); |
|
| 192 | - $post_location_references = array_map( function ( $post_id ) { |
|
| 193 | - return new Post_Reference( $post_id ); |
|
| 194 | - }, $post_location_ids ); |
|
| 195 | - |
|
| 196 | - return array_merge( $carry, $post_location_references ); |
|
| 197 | - }, array() ); |
|
| 198 | - |
|
| 199 | - // Merge the references with the referenced locations if any. |
|
| 200 | - $references = array_merge( $references_without_locations, $locations ); |
|
| 201 | - |
|
| 202 | - return $jsonld; |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - /** |
|
| 206 | - * If the provided value starts with the schema.org context, we remove the schema.org |
|
| 207 | - * part since it is set with the '@context'. |
|
| 208 | - * |
|
| 209 | - * @param string $value The property value. |
|
| 210 | - * |
|
| 211 | - * @return string The property value without the context. |
|
| 212 | - * @since 3.10.0 |
|
| 213 | - * |
|
| 214 | - */ |
|
| 215 | - public function relative_to_context( $value ) { |
|
| 216 | - |
|
| 217 | - return 0 === strpos( $value, self::CONTEXT . '/' ) ? substr( $value, strlen( self::CONTEXT ) + 1 ) : $value; |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - /** |
|
| 221 | - * Set the images, by looking for embedded images, for images loaded via the |
|
| 222 | - * gallery and for the featured image. |
|
| 223 | - * |
|
| 224 | - * Uses the cache service to store the results of this function for a day. |
|
| 225 | - * |
|
| 226 | - * @param $attachment_service Wordlift_Attachment_Service |
|
| 227 | - * @param WP_Post $post The target {@link WP_Post}. |
|
| 228 | - * @param array $jsonld The JSON-LD array. |
|
| 229 | - * |
|
| 230 | - * @since 3.10.0 |
|
| 231 | - */ |
|
| 232 | - public static function set_images( $attachment_service, $post, &$jsonld ) { |
|
| 233 | - |
|
| 234 | - // Prepare the attachment ids array. |
|
| 235 | - $ids = array(); |
|
| 236 | - |
|
| 237 | - // Set the thumbnail id as first attachment id, if any. |
|
| 238 | - $thumbnail_id = get_post_thumbnail_id( $post->ID ); |
|
| 239 | - if ( '' !== $thumbnail_id && 0 !== $thumbnail_id ) { |
|
| 240 | - $ids[] = $thumbnail_id; |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - // For the time being the following is being removed since the query |
|
| 244 | - // initiated by `get_image_embeds` is consuming lots of CPU. |
|
| 245 | - // |
|
| 246 | - // See https://github.com/insideout10/wordlift-plugin/issues/689. |
|
| 247 | - // |
|
| 248 | - // Get the embeds, removing existing ids. |
|
| 249 | - if ( apply_filters( 'wl_feature__enable__image-embeds', false ) ) { |
|
| 250 | - $embeds = array_diff( $attachment_service->get_image_embeds( $post->post_content ), $ids ); |
|
| 251 | - } else { |
|
| 252 | - $embeds = array(); |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - // Get the gallery, removing existing ids. |
|
| 256 | - $gallery = array_diff( $attachment_service->get_gallery( $post ), $ids, $embeds ); |
|
| 257 | - |
|
| 258 | - // Map the attachment ids to images' data structured for schema.org use. |
|
| 259 | - $images_with_sizes = array_filter( |
|
| 260 | - array_reduce( array_merge( $ids, $embeds, $gallery ), |
|
| 261 | - function ( $carry, $item ) { |
|
| 262 | - /* |
|
| 178 | + // A reference to use in closure. |
|
| 179 | + $entity_type_service = $this->entity_type_service; |
|
| 180 | + $locations = array_reduce( $references_without_locations, function ( $carry, $reference ) use ( $entity_type_service ) { |
|
| 181 | + /** |
|
| 182 | + * @var $reference Reference |
|
| 183 | + */ |
|
| 184 | + // @see https://schema.org/location for the schema.org types using the `location` property. |
|
| 185 | + if ( ! $entity_type_service->has_entity_type( $reference->get_id(), 'http://schema.org/Action' ) |
|
| 186 | + && ! $entity_type_service->has_entity_type( $reference->get_id(), 'http://schema.org/Event' ) |
|
| 187 | + && ! $entity_type_service->has_entity_type( $reference->get_id(), 'http://schema.org/Organization' ) ) { |
|
| 188 | + |
|
| 189 | + return $carry; |
|
| 190 | + } |
|
| 191 | + $post_location_ids = get_post_meta( $reference->get_id(), Wordlift_Schema_Service::FIELD_LOCATION ); |
|
| 192 | + $post_location_references = array_map( function ( $post_id ) { |
|
| 193 | + return new Post_Reference( $post_id ); |
|
| 194 | + }, $post_location_ids ); |
|
| 195 | + |
|
| 196 | + return array_merge( $carry, $post_location_references ); |
|
| 197 | + }, array() ); |
|
| 198 | + |
|
| 199 | + // Merge the references with the referenced locations if any. |
|
| 200 | + $references = array_merge( $references_without_locations, $locations ); |
|
| 201 | + |
|
| 202 | + return $jsonld; |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + /** |
|
| 206 | + * If the provided value starts with the schema.org context, we remove the schema.org |
|
| 207 | + * part since it is set with the '@context'. |
|
| 208 | + * |
|
| 209 | + * @param string $value The property value. |
|
| 210 | + * |
|
| 211 | + * @return string The property value without the context. |
|
| 212 | + * @since 3.10.0 |
|
| 213 | + * |
|
| 214 | + */ |
|
| 215 | + public function relative_to_context( $value ) { |
|
| 216 | + |
|
| 217 | + return 0 === strpos( $value, self::CONTEXT . '/' ) ? substr( $value, strlen( self::CONTEXT ) + 1 ) : $value; |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * Set the images, by looking for embedded images, for images loaded via the |
|
| 222 | + * gallery and for the featured image. |
|
| 223 | + * |
|
| 224 | + * Uses the cache service to store the results of this function for a day. |
|
| 225 | + * |
|
| 226 | + * @param $attachment_service Wordlift_Attachment_Service |
|
| 227 | + * @param WP_Post $post The target {@link WP_Post}. |
|
| 228 | + * @param array $jsonld The JSON-LD array. |
|
| 229 | + * |
|
| 230 | + * @since 3.10.0 |
|
| 231 | + */ |
|
| 232 | + public static function set_images( $attachment_service, $post, &$jsonld ) { |
|
| 233 | + |
|
| 234 | + // Prepare the attachment ids array. |
|
| 235 | + $ids = array(); |
|
| 236 | + |
|
| 237 | + // Set the thumbnail id as first attachment id, if any. |
|
| 238 | + $thumbnail_id = get_post_thumbnail_id( $post->ID ); |
|
| 239 | + if ( '' !== $thumbnail_id && 0 !== $thumbnail_id ) { |
|
| 240 | + $ids[] = $thumbnail_id; |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + // For the time being the following is being removed since the query |
|
| 244 | + // initiated by `get_image_embeds` is consuming lots of CPU. |
|
| 245 | + // |
|
| 246 | + // See https://github.com/insideout10/wordlift-plugin/issues/689. |
|
| 247 | + // |
|
| 248 | + // Get the embeds, removing existing ids. |
|
| 249 | + if ( apply_filters( 'wl_feature__enable__image-embeds', false ) ) { |
|
| 250 | + $embeds = array_diff( $attachment_service->get_image_embeds( $post->post_content ), $ids ); |
|
| 251 | + } else { |
|
| 252 | + $embeds = array(); |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + // Get the gallery, removing existing ids. |
|
| 256 | + $gallery = array_diff( $attachment_service->get_gallery( $post ), $ids, $embeds ); |
|
| 257 | + |
|
| 258 | + // Map the attachment ids to images' data structured for schema.org use. |
|
| 259 | + $images_with_sizes = array_filter( |
|
| 260 | + array_reduce( array_merge( $ids, $embeds, $gallery ), |
|
| 261 | + function ( $carry, $item ) { |
|
| 262 | + /* |
|
| 263 | 263 | * @todo: we're not sure that we're getting attachment data here, we |
| 264 | 264 | * should filter `false`s. |
| 265 | 265 | */ |
| 266 | 266 | |
| 267 | - $sources = array_merge( |
|
| 268 | - Wordlift_Image_Service::get_sources( $item ), |
|
| 269 | - array( wp_get_attachment_image_src( $item, 'full' ) ) |
|
| 270 | - ); |
|
| 271 | - |
|
| 272 | - $sources_with_image = array_filter( $sources, function ( $source ) { |
|
| 273 | - return ! empty( $source[0] ); |
|
| 274 | - } ); |
|
| 275 | - |
|
| 276 | - // Get the attachment data. |
|
| 277 | - // $attachment = wp_get_attachment_image_src( $item, 'full' ); |
|
| 278 | - |
|
| 279 | - // var_dump( array( "sources-$item" => Wordlift_Image_Service::get_sources( $item ) ) ); |
|
| 280 | - |
|
| 281 | - // Bail if image is not found. |
|
| 282 | - // In some cases, you can delete the image from the database |
|
| 283 | - // or from uploads dir, but the image id still exists as featured image |
|
| 284 | - // or in [gallery] shortcode. |
|
| 285 | - // if ( empty( $attachment[0] ) ) { |
|
| 286 | - if ( empty( $sources_with_image ) ) { |
|
| 287 | - return $carry; |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - // Merge the arrays. |
|
| 291 | - return array_merge( |
|
| 292 | - $carry, |
|
| 293 | - $sources_with_image |
|
| 294 | - ); |
|
| 295 | - } |
|
| 296 | - // Initial array. |
|
| 297 | - , array() ) |
|
| 298 | - ); |
|
| 299 | - |
|
| 300 | - // Refactor data as per schema.org specifications. |
|
| 301 | - $images = array_map( function ( $attachment ) { |
|
| 302 | - return Wordlift_Abstract_Post_To_Jsonld_Converter::set_image_size( |
|
| 303 | - array( |
|
| 304 | - '@type' => 'ImageObject', |
|
| 305 | - 'url' => $attachment[0], |
|
| 306 | - ), $attachment |
|
| 307 | - ); |
|
| 308 | - }, $images_with_sizes ); |
|
| 309 | - |
|
| 310 | - // Add images if present. |
|
| 311 | - if ( 0 < count( $images ) ) { |
|
| 312 | - $jsonld['image'] = $images; |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - /** |
|
| 318 | - * If the provided array of values contains only one value, then one single |
|
| 319 | - * value is returned, otherwise the original array is returned. |
|
| 320 | - * |
|
| 321 | - * @param array $value An array of values. |
|
| 322 | - * |
|
| 323 | - * @return mixed|array A single value or the original array. |
|
| 324 | - * @since 3.20.0 The function has been moved from {@link Wordlift_Entity_Post_To_Jsonld_Converter} to |
|
| 325 | - * {@link Wordlift_Abstract_Post_To_Jsonld_Converter}. |
|
| 326 | - * @since 3.8.0 |
|
| 327 | - * @access private |
|
| 328 | - * |
|
| 329 | - */ |
|
| 330 | - protected static function make_one( $value ) { |
|
| 331 | - |
|
| 332 | - return 1 === count( $value ) ? $value[0] : $value; |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - /** |
|
| 336 | - * Process the provided array by adding the width / height if the values |
|
| 337 | - * are available and are greater than 0. |
|
| 338 | - * |
|
| 339 | - * @param array $image The `ImageObject` array. |
|
| 340 | - * @param array $attachment The attachment array. |
|
| 341 | - * |
|
| 342 | - * @return array The enriched `ImageObject` array. |
|
| 343 | - * @since 3.14.0 |
|
| 344 | - * |
|
| 345 | - */ |
|
| 346 | - public static function set_image_size( $image, $attachment ) { |
|
| 347 | - |
|
| 348 | - // If you specify a "width" or "height" value you should leave out |
|
| 349 | - // 'px'. For example: "width":"4608px" should be "width":"4608". |
|
| 350 | - // |
|
| 351 | - // See https://github.com/insideout10/wordlift-plugin/issues/451. |
|
| 352 | - if ( isset( $attachment[1] ) && is_numeric( $attachment[1] ) && 0 < $attachment[1] ) { |
|
| 353 | - $image['width'] = $attachment[1]; |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - if ( isset( $attachment[2] ) && is_numeric( $attachment[2] ) && 0 < $attachment[2] ) { |
|
| 357 | - $image['height'] = $attachment[2]; |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - return $image; |
|
| 361 | - } |
|
| 362 | - |
|
| 363 | - |
|
| 364 | - /** |
|
| 365 | - * Add data to the JSON-LD using the `custom_fields` array which contains the definitions of property |
|
| 366 | - * for the post entity type. |
|
| 367 | - * |
|
| 368 | - * @param array $jsonld The JSON-LD array. |
|
| 369 | - * @param array $fields The entity types field array. |
|
| 370 | - * @param WP_Post $post The target {@link WP_Post} instance. |
|
| 371 | - * @param array $references The references array. |
|
| 372 | - * |
|
| 373 | - * @since 3.20.0 This code moved from the above function `convert`, used for entity types defined in |
|
| 374 | - * the {@link Wordlift_Schema_Service} class. |
|
| 375 | - * |
|
| 376 | - */ |
|
| 377 | - protected function process_type_custom_fields( &$jsonld, $fields, $post, &$references, &$references_infos ) { |
|
| 378 | - |
|
| 379 | - // Set a reference to use in closures. |
|
| 380 | - $converter = $this; |
|
| 381 | - |
|
| 382 | - // Try each field on the entity. |
|
| 383 | - foreach ( $fields as $key => $value ) { |
|
| 384 | - |
|
| 385 | - // Get the predicate. |
|
| 386 | - $name = $this->relative_to_context( $value['predicate'] ); |
|
| 387 | - |
|
| 388 | - // Get the value, the property service will get the right extractor |
|
| 389 | - // for that property. |
|
| 390 | - $value = $this->property_getter->get( $post->ID, $key, Object_Type_Enum::POST ); |
|
| 391 | - |
|
| 392 | - if ( empty( $value ) ) { |
|
| 393 | - continue; |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - // Map the value to the property name. |
|
| 397 | - // If we got an array with just one value, we return that one value. |
|
| 398 | - // If we got a Wordlift_Property_Entity_Reference we get the URL. |
|
| 399 | - $jsonld[ $name ] = self::make_one( array_map( function ( $item ) use ( $converter, &$references, &$references_infos ) { |
|
| 400 | - |
|
| 401 | - if ( $item instanceof Wordlift_Property_Entity_Reference ) { |
|
| 402 | - |
|
| 403 | - $url = $item->get_url(); |
|
| 404 | - |
|
| 405 | - // The refactored converters require the entity id. |
|
| 406 | - $references[] = $item->get_id(); |
|
| 407 | - |
|
| 408 | - $references_infos[] = array( 'reference' => $item ); |
|
| 409 | - |
|
| 410 | - return array( |
|
| 411 | - '@id' => $url, |
|
| 412 | - ); |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - return $converter->relative_to_context( $item ); |
|
| 416 | - }, $value ) ); |
|
| 417 | - |
|
| 418 | - } |
|
| 419 | - |
|
| 420 | - } |
|
| 267 | + $sources = array_merge( |
|
| 268 | + Wordlift_Image_Service::get_sources( $item ), |
|
| 269 | + array( wp_get_attachment_image_src( $item, 'full' ) ) |
|
| 270 | + ); |
|
| 271 | + |
|
| 272 | + $sources_with_image = array_filter( $sources, function ( $source ) { |
|
| 273 | + return ! empty( $source[0] ); |
|
| 274 | + } ); |
|
| 275 | + |
|
| 276 | + // Get the attachment data. |
|
| 277 | + // $attachment = wp_get_attachment_image_src( $item, 'full' ); |
|
| 278 | + |
|
| 279 | + // var_dump( array( "sources-$item" => Wordlift_Image_Service::get_sources( $item ) ) ); |
|
| 280 | + |
|
| 281 | + // Bail if image is not found. |
|
| 282 | + // In some cases, you can delete the image from the database |
|
| 283 | + // or from uploads dir, but the image id still exists as featured image |
|
| 284 | + // or in [gallery] shortcode. |
|
| 285 | + // if ( empty( $attachment[0] ) ) { |
|
| 286 | + if ( empty( $sources_with_image ) ) { |
|
| 287 | + return $carry; |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + // Merge the arrays. |
|
| 291 | + return array_merge( |
|
| 292 | + $carry, |
|
| 293 | + $sources_with_image |
|
| 294 | + ); |
|
| 295 | + } |
|
| 296 | + // Initial array. |
|
| 297 | + , array() ) |
|
| 298 | + ); |
|
| 299 | + |
|
| 300 | + // Refactor data as per schema.org specifications. |
|
| 301 | + $images = array_map( function ( $attachment ) { |
|
| 302 | + return Wordlift_Abstract_Post_To_Jsonld_Converter::set_image_size( |
|
| 303 | + array( |
|
| 304 | + '@type' => 'ImageObject', |
|
| 305 | + 'url' => $attachment[0], |
|
| 306 | + ), $attachment |
|
| 307 | + ); |
|
| 308 | + }, $images_with_sizes ); |
|
| 309 | + |
|
| 310 | + // Add images if present. |
|
| 311 | + if ( 0 < count( $images ) ) { |
|
| 312 | + $jsonld['image'] = $images; |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + /** |
|
| 318 | + * If the provided array of values contains only one value, then one single |
|
| 319 | + * value is returned, otherwise the original array is returned. |
|
| 320 | + * |
|
| 321 | + * @param array $value An array of values. |
|
| 322 | + * |
|
| 323 | + * @return mixed|array A single value or the original array. |
|
| 324 | + * @since 3.20.0 The function has been moved from {@link Wordlift_Entity_Post_To_Jsonld_Converter} to |
|
| 325 | + * {@link Wordlift_Abstract_Post_To_Jsonld_Converter}. |
|
| 326 | + * @since 3.8.0 |
|
| 327 | + * @access private |
|
| 328 | + * |
|
| 329 | + */ |
|
| 330 | + protected static function make_one( $value ) { |
|
| 331 | + |
|
| 332 | + return 1 === count( $value ) ? $value[0] : $value; |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + /** |
|
| 336 | + * Process the provided array by adding the width / height if the values |
|
| 337 | + * are available and are greater than 0. |
|
| 338 | + * |
|
| 339 | + * @param array $image The `ImageObject` array. |
|
| 340 | + * @param array $attachment The attachment array. |
|
| 341 | + * |
|
| 342 | + * @return array The enriched `ImageObject` array. |
|
| 343 | + * @since 3.14.0 |
|
| 344 | + * |
|
| 345 | + */ |
|
| 346 | + public static function set_image_size( $image, $attachment ) { |
|
| 347 | + |
|
| 348 | + // If you specify a "width" or "height" value you should leave out |
|
| 349 | + // 'px'. For example: "width":"4608px" should be "width":"4608". |
|
| 350 | + // |
|
| 351 | + // See https://github.com/insideout10/wordlift-plugin/issues/451. |
|
| 352 | + if ( isset( $attachment[1] ) && is_numeric( $attachment[1] ) && 0 < $attachment[1] ) { |
|
| 353 | + $image['width'] = $attachment[1]; |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + if ( isset( $attachment[2] ) && is_numeric( $attachment[2] ) && 0 < $attachment[2] ) { |
|
| 357 | + $image['height'] = $attachment[2]; |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + return $image; |
|
| 361 | + } |
|
| 362 | + |
|
| 363 | + |
|
| 364 | + /** |
|
| 365 | + * Add data to the JSON-LD using the `custom_fields` array which contains the definitions of property |
|
| 366 | + * for the post entity type. |
|
| 367 | + * |
|
| 368 | + * @param array $jsonld The JSON-LD array. |
|
| 369 | + * @param array $fields The entity types field array. |
|
| 370 | + * @param WP_Post $post The target {@link WP_Post} instance. |
|
| 371 | + * @param array $references The references array. |
|
| 372 | + * |
|
| 373 | + * @since 3.20.0 This code moved from the above function `convert`, used for entity types defined in |
|
| 374 | + * the {@link Wordlift_Schema_Service} class. |
|
| 375 | + * |
|
| 376 | + */ |
|
| 377 | + protected function process_type_custom_fields( &$jsonld, $fields, $post, &$references, &$references_infos ) { |
|
| 378 | + |
|
| 379 | + // Set a reference to use in closures. |
|
| 380 | + $converter = $this; |
|
| 381 | + |
|
| 382 | + // Try each field on the entity. |
|
| 383 | + foreach ( $fields as $key => $value ) { |
|
| 384 | + |
|
| 385 | + // Get the predicate. |
|
| 386 | + $name = $this->relative_to_context( $value['predicate'] ); |
|
| 387 | + |
|
| 388 | + // Get the value, the property service will get the right extractor |
|
| 389 | + // for that property. |
|
| 390 | + $value = $this->property_getter->get( $post->ID, $key, Object_Type_Enum::POST ); |
|
| 391 | + |
|
| 392 | + if ( empty( $value ) ) { |
|
| 393 | + continue; |
|
| 394 | + } |
|
| 395 | + |
|
| 396 | + // Map the value to the property name. |
|
| 397 | + // If we got an array with just one value, we return that one value. |
|
| 398 | + // If we got a Wordlift_Property_Entity_Reference we get the URL. |
|
| 399 | + $jsonld[ $name ] = self::make_one( array_map( function ( $item ) use ( $converter, &$references, &$references_infos ) { |
|
| 400 | + |
|
| 401 | + if ( $item instanceof Wordlift_Property_Entity_Reference ) { |
|
| 402 | + |
|
| 403 | + $url = $item->get_url(); |
|
| 404 | + |
|
| 405 | + // The refactored converters require the entity id. |
|
| 406 | + $references[] = $item->get_id(); |
|
| 407 | + |
|
| 408 | + $references_infos[] = array( 'reference' => $item ); |
|
| 409 | + |
|
| 410 | + return array( |
|
| 411 | + '@id' => $url, |
|
| 412 | + ); |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + return $converter->relative_to_context( $item ); |
|
| 416 | + }, $value ) ); |
|
| 417 | + |
|
| 418 | + } |
|
| 419 | + |
|
| 420 | + } |
|
| 421 | 421 | |
| 422 | 422 | } |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * @since 3.10.0 |
| 74 | 74 | * |
| 75 | 75 | */ |
| 76 | - public function __construct( $entity_type_service, $user_service, $attachment_service, $property_getter ) { |
|
| 76 | + public function __construct($entity_type_service, $user_service, $attachment_service, $property_getter) { |
|
| 77 | 77 | $this->entity_type_service = $entity_type_service; |
| 78 | 78 | $this->user_service = $user_service; |
| 79 | 79 | $this->attachment_service = $attachment_service; |
@@ -91,19 +91,19 @@ discard block |
||
| 91 | 91 | * @return array A JSON-LD array. |
| 92 | 92 | * @since 3.10.0 |
| 93 | 93 | */ |
| 94 | - public function convert( $post_id, &$references = array(), &$references_infos = array() ) { |
|
| 94 | + public function convert($post_id, &$references = array(), &$references_infos = array()) { |
|
| 95 | 95 | |
| 96 | 96 | // Get the post instance. |
| 97 | - $post = get_post( $post_id ); |
|
| 98 | - if ( null === $post ) { |
|
| 97 | + $post = get_post($post_id); |
|
| 98 | + if (null === $post) { |
|
| 99 | 99 | // Post not found. |
| 100 | 100 | return null; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | // Get the post URI @id. |
| 104 | - $id = Wordlift_Entity_Service::get_instance()->get_uri( $post->ID ); |
|
| 105 | - if ( is_null( $id ) ) { |
|
| 106 | - $id = 'get_uri returned null, dataset is ' . wl_configuration_get_redlink_dataset_uri(); |
|
| 104 | + $id = Wordlift_Entity_Service::get_instance()->get_uri($post->ID); |
|
| 105 | + if (is_null($id)) { |
|
| 106 | + $id = 'get_uri returned null, dataset is '.wl_configuration_get_redlink_dataset_uri(); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /* |
@@ -115,15 +115,15 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | // // Get the entity @type. We consider `post` BlogPostings. |
| 117 | 117 | // $type = $this->entity_type_service->get( $post_id ); |
| 118 | - $types = $this->entity_type_service->get_names( $post_id ); |
|
| 119 | - $type = self::make_one( $types ); |
|
| 118 | + $types = $this->entity_type_service->get_names($post_id); |
|
| 119 | + $type = self::make_one($types); |
|
| 120 | 120 | |
| 121 | 121 | // Prepare the response. |
| 122 | 122 | $jsonld = array( |
| 123 | 123 | '@context' => self::CONTEXT, |
| 124 | 124 | '@id' => $id, |
| 125 | 125 | '@type' => $type, |
| 126 | - 'description' => Wordlift_Post_Excerpt_Helper::get_text_excerpt( $post ), |
|
| 126 | + 'description' => Wordlift_Post_Excerpt_Helper::get_text_excerpt($post), |
|
| 127 | 127 | ); |
| 128 | 128 | |
| 129 | 129 | // Set the `mainEntityOfPage` property if the post has some contents. |
@@ -133,8 +133,8 @@ discard block |
||
| 133 | 133 | * |
| 134 | 134 | * @since 3.20.0 |
| 135 | 135 | */ |
| 136 | - $post_content = apply_filters( 'wl_post_content', $post->post_content, $post ); |
|
| 137 | - if ( ! empty( $post_content ) ) { |
|
| 136 | + $post_content = apply_filters('wl_post_content', $post->post_content, $post); |
|
| 137 | + if ( ! empty($post_content)) { |
|
| 138 | 138 | // We're setting the `mainEntityOfPage` to signal which one is the |
| 139 | 139 | // main entity for the specified URL. It might be however that the |
| 140 | 140 | // post/page is actually about another specific entity. How WL deals |
@@ -145,28 +145,28 @@ discard block |
||
| 145 | 145 | // No need to specify `'@type' => 'WebPage'. |
| 146 | 146 | // |
| 147 | 147 | // See https://github.com/insideout10/wordlift-plugin/issues/451. |
| 148 | - $jsonld['mainEntityOfPage'] = get_the_permalink( $post->ID ); |
|
| 148 | + $jsonld['mainEntityOfPage'] = get_the_permalink($post->ID); |
|
| 149 | 149 | |
| 150 | 150 | /** |
| 151 | 151 | * @see https://github.com/insideout10/wordlift-plugin/issues/1207 |
| 152 | 152 | * |
| 153 | 153 | * @since 3.27.7 |
| 154 | 154 | */ |
| 155 | - if ( in_array( $type, array( 'Occupation', 'OccupationAggregationByEmployer' ) ) ) { |
|
| 155 | + if (in_array($type, array('Occupation', 'OccupationAggregationByEmployer'))) { |
|
| 156 | 156 | $jsonld['mainEntityOfPage'] = array( |
| 157 | 157 | '@type' => 'WebPage', |
| 158 | - 'lastReviewed' => get_post_time( 'Y-m-d\TH:i:sP', true, $post, false ) |
|
| 158 | + 'lastReviewed' => get_post_time('Y-m-d\TH:i:sP', true, $post, false) |
|
| 159 | 159 | ); |
| 160 | 160 | } |
| 161 | 161 | }; |
| 162 | 162 | |
| 163 | - $this->set_images( $this->attachment_service, $post, $jsonld ); |
|
| 163 | + $this->set_images($this->attachment_service, $post, $jsonld); |
|
| 164 | 164 | |
| 165 | 165 | // Get the entities referenced by this post and set it to the `references` |
| 166 | 166 | // array so that the caller can do further processing, such as printing out |
| 167 | 167 | // more of those references. |
| 168 | 168 | $references_without_locations = Object_Relation_Service::get_instance() |
| 169 | - ->get_references( $post_id, Object_Type_Enum::POST ); |
|
| 169 | + ->get_references($post_id, Object_Type_Enum::POST); |
|
| 170 | 170 | |
| 171 | 171 | /* |
| 172 | 172 | * Add the locations to the references. |
@@ -177,27 +177,27 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | // A reference to use in closure. |
| 179 | 179 | $entity_type_service = $this->entity_type_service; |
| 180 | - $locations = array_reduce( $references_without_locations, function ( $carry, $reference ) use ( $entity_type_service ) { |
|
| 180 | + $locations = array_reduce($references_without_locations, function($carry, $reference) use ($entity_type_service) { |
|
| 181 | 181 | /** |
| 182 | 182 | * @var $reference Reference |
| 183 | 183 | */ |
| 184 | 184 | // @see https://schema.org/location for the schema.org types using the `location` property. |
| 185 | - if ( ! $entity_type_service->has_entity_type( $reference->get_id(), 'http://schema.org/Action' ) |
|
| 186 | - && ! $entity_type_service->has_entity_type( $reference->get_id(), 'http://schema.org/Event' ) |
|
| 187 | - && ! $entity_type_service->has_entity_type( $reference->get_id(), 'http://schema.org/Organization' ) ) { |
|
| 185 | + if ( ! $entity_type_service->has_entity_type($reference->get_id(), 'http://schema.org/Action') |
|
| 186 | + && ! $entity_type_service->has_entity_type($reference->get_id(), 'http://schema.org/Event') |
|
| 187 | + && ! $entity_type_service->has_entity_type($reference->get_id(), 'http://schema.org/Organization')) { |
|
| 188 | 188 | |
| 189 | 189 | return $carry; |
| 190 | 190 | } |
| 191 | - $post_location_ids = get_post_meta( $reference->get_id(), Wordlift_Schema_Service::FIELD_LOCATION ); |
|
| 192 | - $post_location_references = array_map( function ( $post_id ) { |
|
| 193 | - return new Post_Reference( $post_id ); |
|
| 194 | - }, $post_location_ids ); |
|
| 191 | + $post_location_ids = get_post_meta($reference->get_id(), Wordlift_Schema_Service::FIELD_LOCATION); |
|
| 192 | + $post_location_references = array_map(function($post_id) { |
|
| 193 | + return new Post_Reference($post_id); |
|
| 194 | + }, $post_location_ids); |
|
| 195 | 195 | |
| 196 | - return array_merge( $carry, $post_location_references ); |
|
| 197 | - }, array() ); |
|
| 196 | + return array_merge($carry, $post_location_references); |
|
| 197 | + }, array()); |
|
| 198 | 198 | |
| 199 | 199 | // Merge the references with the referenced locations if any. |
| 200 | - $references = array_merge( $references_without_locations, $locations ); |
|
| 200 | + $references = array_merge($references_without_locations, $locations); |
|
| 201 | 201 | |
| 202 | 202 | return $jsonld; |
| 203 | 203 | } |
@@ -212,9 +212,9 @@ discard block |
||
| 212 | 212 | * @since 3.10.0 |
| 213 | 213 | * |
| 214 | 214 | */ |
| 215 | - public function relative_to_context( $value ) { |
|
| 215 | + public function relative_to_context($value) { |
|
| 216 | 216 | |
| 217 | - return 0 === strpos( $value, self::CONTEXT . '/' ) ? substr( $value, strlen( self::CONTEXT ) + 1 ) : $value; |
|
| 217 | + return 0 === strpos($value, self::CONTEXT.'/') ? substr($value, strlen(self::CONTEXT) + 1) : $value; |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -229,14 +229,14 @@ discard block |
||
| 229 | 229 | * |
| 230 | 230 | * @since 3.10.0 |
| 231 | 231 | */ |
| 232 | - public static function set_images( $attachment_service, $post, &$jsonld ) { |
|
| 232 | + public static function set_images($attachment_service, $post, &$jsonld) { |
|
| 233 | 233 | |
| 234 | 234 | // Prepare the attachment ids array. |
| 235 | 235 | $ids = array(); |
| 236 | 236 | |
| 237 | 237 | // Set the thumbnail id as first attachment id, if any. |
| 238 | - $thumbnail_id = get_post_thumbnail_id( $post->ID ); |
|
| 239 | - if ( '' !== $thumbnail_id && 0 !== $thumbnail_id ) { |
|
| 238 | + $thumbnail_id = get_post_thumbnail_id($post->ID); |
|
| 239 | + if ('' !== $thumbnail_id && 0 !== $thumbnail_id) { |
|
| 240 | 240 | $ids[] = $thumbnail_id; |
| 241 | 241 | } |
| 242 | 242 | |
@@ -246,31 +246,31 @@ discard block |
||
| 246 | 246 | // See https://github.com/insideout10/wordlift-plugin/issues/689. |
| 247 | 247 | // |
| 248 | 248 | // Get the embeds, removing existing ids. |
| 249 | - if ( apply_filters( 'wl_feature__enable__image-embeds', false ) ) { |
|
| 250 | - $embeds = array_diff( $attachment_service->get_image_embeds( $post->post_content ), $ids ); |
|
| 249 | + if (apply_filters('wl_feature__enable__image-embeds', false)) { |
|
| 250 | + $embeds = array_diff($attachment_service->get_image_embeds($post->post_content), $ids); |
|
| 251 | 251 | } else { |
| 252 | 252 | $embeds = array(); |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | // Get the gallery, removing existing ids. |
| 256 | - $gallery = array_diff( $attachment_service->get_gallery( $post ), $ids, $embeds ); |
|
| 256 | + $gallery = array_diff($attachment_service->get_gallery($post), $ids, $embeds); |
|
| 257 | 257 | |
| 258 | 258 | // Map the attachment ids to images' data structured for schema.org use. |
| 259 | 259 | $images_with_sizes = array_filter( |
| 260 | - array_reduce( array_merge( $ids, $embeds, $gallery ), |
|
| 261 | - function ( $carry, $item ) { |
|
| 260 | + array_reduce(array_merge($ids, $embeds, $gallery), |
|
| 261 | + function($carry, $item) { |
|
| 262 | 262 | /* |
| 263 | 263 | * @todo: we're not sure that we're getting attachment data here, we |
| 264 | 264 | * should filter `false`s. |
| 265 | 265 | */ |
| 266 | 266 | |
| 267 | 267 | $sources = array_merge( |
| 268 | - Wordlift_Image_Service::get_sources( $item ), |
|
| 269 | - array( wp_get_attachment_image_src( $item, 'full' ) ) |
|
| 268 | + Wordlift_Image_Service::get_sources($item), |
|
| 269 | + array(wp_get_attachment_image_src($item, 'full')) |
|
| 270 | 270 | ); |
| 271 | 271 | |
| 272 | - $sources_with_image = array_filter( $sources, function ( $source ) { |
|
| 273 | - return ! empty( $source[0] ); |
|
| 272 | + $sources_with_image = array_filter($sources, function($source) { |
|
| 273 | + return ! empty($source[0]); |
|
| 274 | 274 | } ); |
| 275 | 275 | |
| 276 | 276 | // Get the attachment data. |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | // or from uploads dir, but the image id still exists as featured image |
| 284 | 284 | // or in [gallery] shortcode. |
| 285 | 285 | // if ( empty( $attachment[0] ) ) { |
| 286 | - if ( empty( $sources_with_image ) ) { |
|
| 286 | + if (empty($sources_with_image)) { |
|
| 287 | 287 | return $carry; |
| 288 | 288 | } |
| 289 | 289 | |
@@ -294,21 +294,21 @@ discard block |
||
| 294 | 294 | ); |
| 295 | 295 | } |
| 296 | 296 | // Initial array. |
| 297 | - , array() ) |
|
| 297 | + , array()) |
|
| 298 | 298 | ); |
| 299 | 299 | |
| 300 | 300 | // Refactor data as per schema.org specifications. |
| 301 | - $images = array_map( function ( $attachment ) { |
|
| 301 | + $images = array_map(function($attachment) { |
|
| 302 | 302 | return Wordlift_Abstract_Post_To_Jsonld_Converter::set_image_size( |
| 303 | 303 | array( |
| 304 | 304 | '@type' => 'ImageObject', |
| 305 | 305 | 'url' => $attachment[0], |
| 306 | 306 | ), $attachment |
| 307 | 307 | ); |
| 308 | - }, $images_with_sizes ); |
|
| 308 | + }, $images_with_sizes); |
|
| 309 | 309 | |
| 310 | 310 | // Add images if present. |
| 311 | - if ( 0 < count( $images ) ) { |
|
| 311 | + if (0 < count($images)) { |
|
| 312 | 312 | $jsonld['image'] = $images; |
| 313 | 313 | } |
| 314 | 314 | |
@@ -327,9 +327,9 @@ discard block |
||
| 327 | 327 | * @access private |
| 328 | 328 | * |
| 329 | 329 | */ |
| 330 | - protected static function make_one( $value ) { |
|
| 330 | + protected static function make_one($value) { |
|
| 331 | 331 | |
| 332 | - return 1 === count( $value ) ? $value[0] : $value; |
|
| 332 | + return 1 === count($value) ? $value[0] : $value; |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | /** |
@@ -343,17 +343,17 @@ discard block |
||
| 343 | 343 | * @since 3.14.0 |
| 344 | 344 | * |
| 345 | 345 | */ |
| 346 | - public static function set_image_size( $image, $attachment ) { |
|
| 346 | + public static function set_image_size($image, $attachment) { |
|
| 347 | 347 | |
| 348 | 348 | // If you specify a "width" or "height" value you should leave out |
| 349 | 349 | // 'px'. For example: "width":"4608px" should be "width":"4608". |
| 350 | 350 | // |
| 351 | 351 | // See https://github.com/insideout10/wordlift-plugin/issues/451. |
| 352 | - if ( isset( $attachment[1] ) && is_numeric( $attachment[1] ) && 0 < $attachment[1] ) { |
|
| 352 | + if (isset($attachment[1]) && is_numeric($attachment[1]) && 0 < $attachment[1]) { |
|
| 353 | 353 | $image['width'] = $attachment[1]; |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - if ( isset( $attachment[2] ) && is_numeric( $attachment[2] ) && 0 < $attachment[2] ) { |
|
| 356 | + if (isset($attachment[2]) && is_numeric($attachment[2]) && 0 < $attachment[2]) { |
|
| 357 | 357 | $image['height'] = $attachment[2]; |
| 358 | 358 | } |
| 359 | 359 | |
@@ -374,46 +374,46 @@ discard block |
||
| 374 | 374 | * the {@link Wordlift_Schema_Service} class. |
| 375 | 375 | * |
| 376 | 376 | */ |
| 377 | - protected function process_type_custom_fields( &$jsonld, $fields, $post, &$references, &$references_infos ) { |
|
| 377 | + protected function process_type_custom_fields(&$jsonld, $fields, $post, &$references, &$references_infos) { |
|
| 378 | 378 | |
| 379 | 379 | // Set a reference to use in closures. |
| 380 | 380 | $converter = $this; |
| 381 | 381 | |
| 382 | 382 | // Try each field on the entity. |
| 383 | - foreach ( $fields as $key => $value ) { |
|
| 383 | + foreach ($fields as $key => $value) { |
|
| 384 | 384 | |
| 385 | 385 | // Get the predicate. |
| 386 | - $name = $this->relative_to_context( $value['predicate'] ); |
|
| 386 | + $name = $this->relative_to_context($value['predicate']); |
|
| 387 | 387 | |
| 388 | 388 | // Get the value, the property service will get the right extractor |
| 389 | 389 | // for that property. |
| 390 | - $value = $this->property_getter->get( $post->ID, $key, Object_Type_Enum::POST ); |
|
| 390 | + $value = $this->property_getter->get($post->ID, $key, Object_Type_Enum::POST); |
|
| 391 | 391 | |
| 392 | - if ( empty( $value ) ) { |
|
| 392 | + if (empty($value)) { |
|
| 393 | 393 | continue; |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | // Map the value to the property name. |
| 397 | 397 | // If we got an array with just one value, we return that one value. |
| 398 | 398 | // If we got a Wordlift_Property_Entity_Reference we get the URL. |
| 399 | - $jsonld[ $name ] = self::make_one( array_map( function ( $item ) use ( $converter, &$references, &$references_infos ) { |
|
| 399 | + $jsonld[$name] = self::make_one(array_map(function($item) use ($converter, &$references, &$references_infos) { |
|
| 400 | 400 | |
| 401 | - if ( $item instanceof Wordlift_Property_Entity_Reference ) { |
|
| 401 | + if ($item instanceof Wordlift_Property_Entity_Reference) { |
|
| 402 | 402 | |
| 403 | 403 | $url = $item->get_url(); |
| 404 | 404 | |
| 405 | 405 | // The refactored converters require the entity id. |
| 406 | 406 | $references[] = $item->get_id(); |
| 407 | 407 | |
| 408 | - $references_infos[] = array( 'reference' => $item ); |
|
| 408 | + $references_infos[] = array('reference' => $item); |
|
| 409 | 409 | |
| 410 | 410 | return array( |
| 411 | 411 | '@id' => $url, |
| 412 | 412 | ); |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | - return $converter->relative_to_context( $item ); |
|
| 416 | - }, $value ) ); |
|
| 415 | + return $converter->relative_to_context($item); |
|
| 416 | + }, $value)); |
|
| 417 | 417 | |
| 418 | 418 | } |
| 419 | 419 | |
@@ -81,1759 +81,1759 @@ |
||
| 81 | 81 | */ |
| 82 | 82 | class Wordlift { |
| 83 | 83 | |
| 84 | - //<editor-fold desc="## FIELDS"> |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * The loader that's responsible for maintaining and registering all hooks that power |
|
| 88 | - * the plugin. |
|
| 89 | - * |
|
| 90 | - * @since 1.0.0 |
|
| 91 | - * @access protected |
|
| 92 | - * @var Wordlift_Loader $loader Maintains and registers all hooks for the plugin. |
|
| 93 | - */ |
|
| 94 | - protected $loader; |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * The unique identifier of this plugin. |
|
| 98 | - * |
|
| 99 | - * @since 1.0.0 |
|
| 100 | - * @access protected |
|
| 101 | - * @var string $plugin_name The string used to uniquely identify this plugin. |
|
| 102 | - */ |
|
| 103 | - protected $plugin_name; |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * The current version of the plugin. |
|
| 107 | - * |
|
| 108 | - * @since 1.0.0 |
|
| 109 | - * @access protected |
|
| 110 | - * @var string $version The current version of the plugin. |
|
| 111 | - */ |
|
| 112 | - protected $version; |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 116 | - * |
|
| 117 | - * @since 3.12.0 |
|
| 118 | - * @access protected |
|
| 119 | - * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 120 | - */ |
|
| 121 | - protected $tinymce_adapter; |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * The Schema service. |
|
| 125 | - * |
|
| 126 | - * @since 3.3.0 |
|
| 127 | - * @access protected |
|
| 128 | - * @var \Wordlift_Schema_Service $schema_service The Schema service. |
|
| 129 | - */ |
|
| 130 | - protected $schema_service; |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * The Topic Taxonomy service. |
|
| 134 | - * |
|
| 135 | - * @since 3.5.0 |
|
| 136 | - * @access private |
|
| 137 | - * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service. |
|
| 138 | - */ |
|
| 139 | - private $topic_taxonomy_service; |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * The Entity Types Taxonomy service. |
|
| 143 | - * |
|
| 144 | - * @since 3.18.0 |
|
| 145 | - * @access private |
|
| 146 | - * @var \Wordlift_Entity_Type_Taxonomy_Service The Entity Types Taxonomy service. |
|
| 147 | - */ |
|
| 148 | - private $entity_types_taxonomy_service; |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * The User service. |
|
| 152 | - * |
|
| 153 | - * @since 3.1.7 |
|
| 154 | - * @access protected |
|
| 155 | - * @var \Wordlift_User_Service $user_service The User service. |
|
| 156 | - */ |
|
| 157 | - protected $user_service; |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * The Timeline service. |
|
| 161 | - * |
|
| 162 | - * @since 3.1.0 |
|
| 163 | - * @access private |
|
| 164 | - * @var \Wordlift_Timeline_Service $timeline_service The Timeline service. |
|
| 165 | - */ |
|
| 166 | - private $timeline_service; |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * The Redirect service. |
|
| 170 | - * |
|
| 171 | - * @since 3.2.0 |
|
| 172 | - * @access private |
|
| 173 | - * @var \Wordlift_Redirect_Service $redirect_service The Redirect service. |
|
| 174 | - */ |
|
| 175 | - private $redirect_service; |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * The Notice service. |
|
| 179 | - * |
|
| 180 | - * @since 3.3.0 |
|
| 181 | - * @access private |
|
| 182 | - * @var \Wordlift_Notice_Service $notice_service The Notice service. |
|
| 183 | - */ |
|
| 184 | - private $notice_service; |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * The Entity list customization. |
|
| 188 | - * |
|
| 189 | - * @since 3.3.0 |
|
| 190 | - * @access protected |
|
| 191 | - * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service. |
|
| 192 | - */ |
|
| 193 | - protected $entity_list_service; |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * The Entity Types Taxonomy Walker. |
|
| 197 | - * |
|
| 198 | - * @since 3.1.0 |
|
| 199 | - * @access private |
|
| 200 | - * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker |
|
| 201 | - */ |
|
| 202 | - private $entity_types_taxonomy_walker; |
|
| 203 | - |
|
| 204 | - /** |
|
| 205 | - * The ShareThis service. |
|
| 206 | - * |
|
| 207 | - * @since 3.2.0 |
|
| 208 | - * @access private |
|
| 209 | - * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service. |
|
| 210 | - */ |
|
| 211 | - private $sharethis_service; |
|
| 212 | - |
|
| 213 | - /** |
|
| 214 | - * The PrimaShop adapter. |
|
| 215 | - * |
|
| 216 | - * @since 3.2.3 |
|
| 217 | - * @access private |
|
| 218 | - * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter. |
|
| 219 | - */ |
|
| 220 | - private $primashop_adapter; |
|
| 221 | - |
|
| 222 | - /** |
|
| 223 | - * The entity type service. |
|
| 224 | - * |
|
| 225 | - * @since 3.6.0 |
|
| 226 | - * @access private |
|
| 227 | - * @var \Wordlift_Entity_Post_Type_Service |
|
| 228 | - */ |
|
| 229 | - private $entity_post_type_service; |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * The entity link service used to mangle links to entities with a custom slug or even w/o a slug. |
|
| 233 | - * |
|
| 234 | - * @since 3.6.0 |
|
| 235 | - * @access private |
|
| 236 | - * @var \Wordlift_Entity_Link_Service $entity_link_service The {@link Wordlift_Entity_Link_Service} instance. |
|
| 237 | - */ |
|
| 238 | - private $entity_link_service; |
|
| 239 | - |
|
| 240 | - /** |
|
| 241 | - * A {@link Wordlift_Jsonld_Service} instance. |
|
| 242 | - * |
|
| 243 | - * @since 3.7.0 |
|
| 244 | - * @access protected |
|
| 245 | - * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance. |
|
| 246 | - */ |
|
| 247 | - protected $jsonld_service; |
|
| 248 | - |
|
| 249 | - /** |
|
| 250 | - * A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 251 | - * |
|
| 252 | - * @since 3.14.0 |
|
| 253 | - * @access protected |
|
| 254 | - * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 255 | - */ |
|
| 256 | - protected $jsonld_website_converter; |
|
| 257 | - |
|
| 258 | - /** |
|
| 259 | - * A {@link Wordlift_Property_Factory} instance. |
|
| 260 | - * |
|
| 261 | - * @since 3.7.0 |
|
| 262 | - * @access private |
|
| 263 | - * @var \Wordlift_Property_Factory $property_factory |
|
| 264 | - */ |
|
| 265 | - private $property_factory; |
|
| 266 | - |
|
| 267 | - /** |
|
| 268 | - * The 'Download Your Data' page. |
|
| 269 | - * |
|
| 270 | - * @since 3.6.0 |
|
| 271 | - * @access private |
|
| 272 | - * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page. |
|
| 273 | - */ |
|
| 274 | - private $download_your_data_page; |
|
| 275 | - |
|
| 276 | - /** |
|
| 277 | - * The 'WordLift Settings' page. |
|
| 278 | - * |
|
| 279 | - * @since 3.11.0 |
|
| 280 | - * @access protected |
|
| 281 | - * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page. |
|
| 282 | - */ |
|
| 283 | - protected $settings_page; |
|
| 284 | - |
|
| 285 | - /** |
|
| 286 | - * The install wizard page. |
|
| 287 | - * |
|
| 288 | - * @since 3.9.0 |
|
| 289 | - * @access private |
|
| 290 | - * @var \Wordlift_Admin_Setup $admin_setup The Install wizard. |
|
| 291 | - */ |
|
| 292 | - public $admin_setup; |
|
| 293 | - |
|
| 294 | - /** |
|
| 295 | - * The Content Filter Service hooks up to the 'the_content' filter and provides |
|
| 296 | - * linking of entities to their pages. |
|
| 297 | - * |
|
| 298 | - * @since 3.8.0 |
|
| 299 | - * @access private |
|
| 300 | - * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance. |
|
| 301 | - */ |
|
| 302 | - private $content_filter_service; |
|
| 303 | - |
|
| 304 | - /** |
|
| 305 | - * The Faq Content filter service |
|
| 306 | - * @since 3.26.0 |
|
| 307 | - * @access private |
|
| 308 | - * @var Faq_Content_Filter $faq_content_filter_service A {@link Faq_Content_Filter} instance. |
|
| 309 | - */ |
|
| 310 | - private $faq_content_filter_service; |
|
| 311 | - |
|
| 312 | - /** |
|
| 313 | - * A {@link Wordlift_Key_Validation_Service} instance. |
|
| 314 | - * |
|
| 315 | - * @since 3.9.0 |
|
| 316 | - * @access private |
|
| 317 | - * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 318 | - */ |
|
| 319 | - private $key_validation_service; |
|
| 320 | - |
|
| 321 | - /** |
|
| 322 | - * A {@link Wordlift_Rating_Service} instance. |
|
| 323 | - * |
|
| 324 | - * @since 3.10.0 |
|
| 325 | - * @access private |
|
| 326 | - * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance. |
|
| 327 | - */ |
|
| 328 | - private $rating_service; |
|
| 329 | - |
|
| 330 | - /** |
|
| 331 | - * A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 332 | - * |
|
| 333 | - * @since 3.10.0 |
|
| 334 | - * @access protected |
|
| 335 | - * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 336 | - */ |
|
| 337 | - protected $post_to_jsonld_converter; |
|
| 338 | - |
|
| 339 | - /** |
|
| 340 | - * A {@link Wordlift_Install_Service} instance. |
|
| 341 | - * |
|
| 342 | - * @since 3.18.0 |
|
| 343 | - * @access protected |
|
| 344 | - * @var \Wordlift_Install_Service $install_service A {@link Wordlift_Install_Service} instance. |
|
| 345 | - */ |
|
| 346 | - protected $install_service; |
|
| 347 | - |
|
| 348 | - /** |
|
| 349 | - * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 350 | - * |
|
| 351 | - * @since 3.10.0 |
|
| 352 | - * @access protected |
|
| 353 | - * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 354 | - */ |
|
| 355 | - protected $entity_post_to_jsonld_converter; |
|
| 356 | - |
|
| 357 | - /** |
|
| 358 | - * A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 359 | - * |
|
| 360 | - * @since 3.10.0 |
|
| 361 | - * @access protected |
|
| 362 | - * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 363 | - */ |
|
| 364 | - protected $postid_to_jsonld_converter; |
|
| 365 | - |
|
| 366 | - /** |
|
| 367 | - * The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 368 | - * |
|
| 369 | - * @since 3.11.0 |
|
| 370 | - * @access protected |
|
| 371 | - * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 372 | - */ |
|
| 373 | - protected $category_taxonomy_service; |
|
| 374 | - |
|
| 375 | - /** |
|
| 376 | - * The {@link Wordlift_Entity_Page_Service} instance. |
|
| 377 | - * |
|
| 378 | - * @since 3.11.0 |
|
| 379 | - * @access protected |
|
| 380 | - * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance. |
|
| 381 | - */ |
|
| 382 | - protected $entity_page_service; |
|
| 383 | - |
|
| 384 | - /** |
|
| 385 | - * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 386 | - * |
|
| 387 | - * @since 3.11.0 |
|
| 388 | - * @access protected |
|
| 389 | - * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 390 | - */ |
|
| 391 | - protected $settings_page_action_link; |
|
| 392 | - |
|
| 393 | - /** |
|
| 394 | - * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 395 | - * |
|
| 396 | - * @since 3.11.0 |
|
| 397 | - * @access protected |
|
| 398 | - * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 399 | - */ |
|
| 400 | - protected $analytics_settings_page_action_link; |
|
| 401 | - |
|
| 402 | - /** |
|
| 403 | - * The {@link Wordlift_Analytics_Connect} class. |
|
| 404 | - * |
|
| 405 | - * @since 3.11.0 |
|
| 406 | - * @access protected |
|
| 407 | - * @var \Wordlift_Analytics_Connect $analytics_connect The {@link Wordlift_Analytics_Connect} class. |
|
| 408 | - */ |
|
| 409 | - protected $analytics_connect; |
|
| 410 | - |
|
| 411 | - /** |
|
| 412 | - * The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 413 | - * |
|
| 414 | - * @since 3.11.0 |
|
| 415 | - * @access protected |
|
| 416 | - * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 417 | - */ |
|
| 418 | - protected $publisher_ajax_adapter; |
|
| 419 | - |
|
| 420 | - /** |
|
| 421 | - * The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 422 | - * |
|
| 423 | - * @since 3.11.0 |
|
| 424 | - * @access protected |
|
| 425 | - * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 426 | - */ |
|
| 427 | - protected $input_element; |
|
| 428 | - |
|
| 429 | - /** |
|
| 430 | - * The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 431 | - * |
|
| 432 | - * @since 3.13.0 |
|
| 433 | - * @access protected |
|
| 434 | - * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 435 | - */ |
|
| 436 | - protected $radio_input_element; |
|
| 437 | - |
|
| 438 | - /** |
|
| 439 | - * The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 440 | - * |
|
| 441 | - * @since 3.11.0 |
|
| 442 | - * @access protected |
|
| 443 | - * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 444 | - */ |
|
| 445 | - protected $language_select_element; |
|
| 446 | - |
|
| 447 | - /** |
|
| 448 | - * The {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 449 | - * |
|
| 450 | - * @since 3.18.0 |
|
| 451 | - * @access protected |
|
| 452 | - * @var \Wordlift_Admin_Country_Select_Element $country_select_element The {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 453 | - */ |
|
| 454 | - protected $country_select_element; |
|
| 455 | - |
|
| 456 | - /** |
|
| 457 | - * The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 458 | - * |
|
| 459 | - * @since 3.11.0 |
|
| 460 | - * @access protected |
|
| 461 | - * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 462 | - */ |
|
| 463 | - protected $publisher_element; |
|
| 464 | - |
|
| 465 | - /** |
|
| 466 | - * The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 467 | - * |
|
| 468 | - * @since 3.11.0 |
|
| 469 | - * @access protected |
|
| 470 | - * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 471 | - */ |
|
| 472 | - protected $select2_element; |
|
| 473 | - |
|
| 474 | - /** |
|
| 475 | - * The controller for the entity type list admin page |
|
| 476 | - * |
|
| 477 | - * @since 3.11.0 |
|
| 478 | - * @access private |
|
| 479 | - * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class. |
|
| 480 | - */ |
|
| 481 | - private $entity_type_admin_page; |
|
| 482 | - |
|
| 483 | - /** |
|
| 484 | - * The controller for the entity type settings admin page |
|
| 485 | - * |
|
| 486 | - * @since 3.11.0 |
|
| 487 | - * @access private |
|
| 488 | - * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class. |
|
| 489 | - */ |
|
| 490 | - private $entity_type_settings_admin_page; |
|
| 491 | - |
|
| 492 | - /** |
|
| 493 | - * The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 494 | - * |
|
| 495 | - * @since 3.11.0 |
|
| 496 | - * @access protected |
|
| 497 | - * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 498 | - */ |
|
| 499 | - protected $related_entities_cloud_widget; |
|
| 500 | - |
|
| 501 | - /** |
|
| 502 | - * The {@link Wordlift_Admin_Author_Element} instance. |
|
| 503 | - * |
|
| 504 | - * @since 3.14.0 |
|
| 505 | - * @access protected |
|
| 506 | - * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance. |
|
| 507 | - */ |
|
| 508 | - protected $author_element; |
|
| 509 | - |
|
| 510 | - /** |
|
| 511 | - * The {@link Wordlift_Sample_Data_Service} instance. |
|
| 512 | - * |
|
| 513 | - * @since 3.12.0 |
|
| 514 | - * @access protected |
|
| 515 | - * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance. |
|
| 516 | - */ |
|
| 517 | - protected $sample_data_service; |
|
| 518 | - |
|
| 519 | - /** |
|
| 520 | - * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 521 | - * |
|
| 522 | - * @since 3.12.0 |
|
| 523 | - * @access protected |
|
| 524 | - * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 525 | - */ |
|
| 526 | - protected $sample_data_ajax_adapter; |
|
| 527 | - |
|
| 528 | - /** |
|
| 529 | - * The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 530 | - * |
|
| 531 | - * @since 3.16.0 |
|
| 532 | - * @access protected |
|
| 533 | - * @var \Wordlift_Google_Analytics_Export_Service $google_analytics_export_service The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 534 | - */ |
|
| 535 | - protected $google_analytics_export_service; |
|
| 536 | - |
|
| 537 | - /** |
|
| 538 | - * {@link Wordlift}'s singleton instance. |
|
| 539 | - * |
|
| 540 | - * @since 3.15.0 |
|
| 541 | - * @access protected |
|
| 542 | - * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance. |
|
| 543 | - */ |
|
| 544 | - protected $entity_type_adapter; |
|
| 545 | - |
|
| 546 | - /** |
|
| 547 | - * The {@link Wordlift_Storage_Factory} instance. |
|
| 548 | - * |
|
| 549 | - * @since 3.15.0 |
|
| 550 | - * @access protected |
|
| 551 | - * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance. |
|
| 552 | - */ |
|
| 553 | - protected $storage_factory; |
|
| 554 | - |
|
| 555 | - /** |
|
| 556 | - * The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 557 | - * |
|
| 558 | - * @since 3.15.0 |
|
| 559 | - * @access private |
|
| 560 | - * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 561 | - */ |
|
| 562 | - private $autocomplete_adapter; |
|
| 563 | - |
|
| 564 | - /** |
|
| 565 | - * The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 566 | - * |
|
| 567 | - * @since 3.16.0 |
|
| 568 | - * @access protected |
|
| 569 | - * @var \Wordlift_Cached_Post_Converter $cached_postid_to_jsonld_converter The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 570 | - * |
|
| 571 | - */ |
|
| 572 | - protected $cached_postid_to_jsonld_converter; |
|
| 573 | - |
|
| 574 | - /** |
|
| 575 | - * The {@link Wordlift_Entity_Uri_Service} instance. |
|
| 576 | - * |
|
| 577 | - * @since 3.16.3 |
|
| 578 | - * @access protected |
|
| 579 | - * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance. |
|
| 580 | - */ |
|
| 581 | - protected $entity_uri_service; |
|
| 582 | - |
|
| 583 | - /** |
|
| 584 | - * The {@link Wordlift_Publisher_Service} instance. |
|
| 585 | - * |
|
| 586 | - * @since 3.19.0 |
|
| 587 | - * @access protected |
|
| 588 | - * @var \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance. |
|
| 589 | - */ |
|
| 590 | - protected $publisher_service; |
|
| 591 | - |
|
| 592 | - /** |
|
| 593 | - * The {@link Wordlift_Context_Cards_Service} instance. |
|
| 594 | - * |
|
| 595 | - * @var \Wordlift_Context_Cards_Service The {@link Wordlift_Context_Cards_Service} instance. |
|
| 596 | - */ |
|
| 597 | - protected $context_cards_service; |
|
| 598 | - |
|
| 599 | - /** |
|
| 600 | - * {@link Wordlift}'s singleton instance. |
|
| 601 | - * |
|
| 602 | - * @since 3.11.2 |
|
| 603 | - * @access private |
|
| 604 | - * @var Wordlift $instance {@link Wordlift}'s singleton instance. |
|
| 605 | - */ |
|
| 606 | - private static $instance; |
|
| 607 | - |
|
| 608 | - /** |
|
| 609 | - * A singleton instance of features registry. |
|
| 610 | - * @since 3.30.0 |
|
| 611 | - * @var Features_Registry |
|
| 612 | - */ |
|
| 613 | - private $features_registry; |
|
| 614 | - |
|
| 615 | - private $analytics_settings_page; |
|
| 616 | - //</editor-fold> |
|
| 617 | - |
|
| 618 | - // Experimental code added by Nishit for feature request 1496 |
|
| 619 | - private $webhook_loader; |
|
| 620 | - // Experimental code ents here |
|
| 621 | - |
|
| 622 | - /** |
|
| 623 | - * Define the core functionality of the plugin. |
|
| 624 | - * |
|
| 625 | - * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 626 | - * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 627 | - * the public-facing side of the site. |
|
| 628 | - * |
|
| 629 | - * @since 1.0.0 |
|
| 630 | - */ |
|
| 631 | - public function __construct() { |
|
| 632 | - |
|
| 633 | - self::$instance = $this; |
|
| 634 | - |
|
| 635 | - $this->plugin_name = 'wordlift'; |
|
| 636 | - $this->version = '3.36.1'; |
|
| 637 | - $this->load_dependencies(); |
|
| 638 | - $this->set_locale(); |
|
| 639 | - |
|
| 640 | - $that = $this; |
|
| 641 | - add_action( 'plugins_loaded', function () use ( $that ) { |
|
| 642 | - $that->define_admin_hooks( $that ); |
|
| 643 | - $that->define_public_hooks( $that ); |
|
| 644 | - }, 4 ); |
|
| 645 | - |
|
| 646 | - // If we're in `WP_CLI` load the related files. |
|
| 647 | - if ( class_exists( 'WP_CLI' ) ) { |
|
| 648 | - $this->load_cli_dependencies(); |
|
| 649 | - } |
|
| 650 | - |
|
| 651 | - } |
|
| 652 | - |
|
| 653 | - /** |
|
| 654 | - * Get the singleton instance. |
|
| 655 | - * |
|
| 656 | - * @return Wordlift The {@link Wordlift} singleton instance. |
|
| 657 | - * @since 3.11.2 |
|
| 658 | - * |
|
| 659 | - */ |
|
| 660 | - public static function get_instance() { |
|
| 661 | - |
|
| 662 | - return self::$instance; |
|
| 663 | - } |
|
| 664 | - |
|
| 665 | - /** |
|
| 666 | - * Load the required dependencies for this plugin. |
|
| 667 | - * |
|
| 668 | - * Include the following files that make up the plugin: |
|
| 669 | - * |
|
| 670 | - * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 671 | - * - Wordlift_i18n. Defines internationalization functionality. |
|
| 672 | - * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 673 | - * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 674 | - * |
|
| 675 | - * Create an instance of the loader which will be used to register the hooks |
|
| 676 | - * with WordPress. |
|
| 677 | - * |
|
| 678 | - * @throws Exception |
|
| 679 | - * @since 1.0.0 |
|
| 680 | - * @access private |
|
| 681 | - */ |
|
| 682 | - private function load_dependencies() { |
|
| 683 | - |
|
| 684 | - /** |
|
| 685 | - * The class responsible for orchestrating the actions and filters of the |
|
| 686 | - * core plugin. |
|
| 687 | - */ |
|
| 688 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 689 | - |
|
| 690 | - // The class responsible for plugin uninstall. |
|
| 691 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-deactivator-feedback.php'; |
|
| 692 | - |
|
| 693 | - /** |
|
| 694 | - * The class responsible for defining internationalization functionality |
|
| 695 | - * of the plugin. |
|
| 696 | - */ |
|
| 697 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 698 | - |
|
| 699 | - /** |
|
| 700 | - * WordLift's supported languages. |
|
| 701 | - */ |
|
| 702 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php'; |
|
| 703 | - |
|
| 704 | - /** |
|
| 705 | - * WordLift's supported countries. |
|
| 706 | - */ |
|
| 707 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-countries.php'; |
|
| 708 | - |
|
| 709 | - /** |
|
| 710 | - * Provide support functions to sanitize data. |
|
| 711 | - */ |
|
| 712 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 713 | - |
|
| 714 | - /** Services. */ |
|
| 715 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 716 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php'; |
|
| 717 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 718 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 719 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 720 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 721 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 722 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php'; |
|
| 723 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-image-service.php'; |
|
| 724 | - |
|
| 725 | - /** |
|
| 726 | - * The Schema service. |
|
| 727 | - */ |
|
| 728 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 729 | - |
|
| 730 | - /** |
|
| 731 | - * The schema:url property service. |
|
| 732 | - */ |
|
| 733 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 734 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 735 | - |
|
| 736 | - /** |
|
| 737 | - * The UI service. |
|
| 738 | - */ |
|
| 739 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 740 | - |
|
| 741 | - /** |
|
| 742 | - * The Entity Types Taxonomy service. |
|
| 743 | - */ |
|
| 744 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-taxonomy-service.php'; |
|
| 745 | - |
|
| 746 | - /** |
|
| 747 | - * The Entity service. |
|
| 748 | - */ |
|
| 749 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php'; |
|
| 750 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 751 | - |
|
| 752 | - // Add the entity rating service. |
|
| 753 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php'; |
|
| 754 | - |
|
| 755 | - /** |
|
| 756 | - * The User service. |
|
| 757 | - */ |
|
| 758 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 759 | - |
|
| 760 | - /** |
|
| 761 | - * The Timeline service. |
|
| 762 | - */ |
|
| 763 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 764 | - |
|
| 765 | - /** |
|
| 766 | - * The Topic Taxonomy service. |
|
| 767 | - */ |
|
| 768 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 769 | - |
|
| 770 | - /** |
|
| 771 | - * The WordLift URI service. |
|
| 772 | - */ |
|
| 773 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 774 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 775 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php'; |
|
| 776 | - |
|
| 777 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 778 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php'; |
|
| 779 | - |
|
| 780 | - /** |
|
| 781 | - * Load the converters. |
|
| 782 | - */ |
|
| 783 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php'; |
|
| 784 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 785 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 786 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 787 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 788 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php'; |
|
| 789 | - |
|
| 790 | - /** |
|
| 791 | - * Load cache-related files. |
|
| 792 | - */ |
|
| 793 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php'; |
|
| 794 | - |
|
| 795 | - /** |
|
| 796 | - * Load the content filter. |
|
| 797 | - */ |
|
| 798 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 799 | - |
|
| 800 | - /* |
|
| 84 | + //<editor-fold desc="## FIELDS"> |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * The loader that's responsible for maintaining and registering all hooks that power |
|
| 88 | + * the plugin. |
|
| 89 | + * |
|
| 90 | + * @since 1.0.0 |
|
| 91 | + * @access protected |
|
| 92 | + * @var Wordlift_Loader $loader Maintains and registers all hooks for the plugin. |
|
| 93 | + */ |
|
| 94 | + protected $loader; |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * The unique identifier of this plugin. |
|
| 98 | + * |
|
| 99 | + * @since 1.0.0 |
|
| 100 | + * @access protected |
|
| 101 | + * @var string $plugin_name The string used to uniquely identify this plugin. |
|
| 102 | + */ |
|
| 103 | + protected $plugin_name; |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * The current version of the plugin. |
|
| 107 | + * |
|
| 108 | + * @since 1.0.0 |
|
| 109 | + * @access protected |
|
| 110 | + * @var string $version The current version of the plugin. |
|
| 111 | + */ |
|
| 112 | + protected $version; |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 116 | + * |
|
| 117 | + * @since 3.12.0 |
|
| 118 | + * @access protected |
|
| 119 | + * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 120 | + */ |
|
| 121 | + protected $tinymce_adapter; |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * The Schema service. |
|
| 125 | + * |
|
| 126 | + * @since 3.3.0 |
|
| 127 | + * @access protected |
|
| 128 | + * @var \Wordlift_Schema_Service $schema_service The Schema service. |
|
| 129 | + */ |
|
| 130 | + protected $schema_service; |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * The Topic Taxonomy service. |
|
| 134 | + * |
|
| 135 | + * @since 3.5.0 |
|
| 136 | + * @access private |
|
| 137 | + * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service. |
|
| 138 | + */ |
|
| 139 | + private $topic_taxonomy_service; |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * The Entity Types Taxonomy service. |
|
| 143 | + * |
|
| 144 | + * @since 3.18.0 |
|
| 145 | + * @access private |
|
| 146 | + * @var \Wordlift_Entity_Type_Taxonomy_Service The Entity Types Taxonomy service. |
|
| 147 | + */ |
|
| 148 | + private $entity_types_taxonomy_service; |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * The User service. |
|
| 152 | + * |
|
| 153 | + * @since 3.1.7 |
|
| 154 | + * @access protected |
|
| 155 | + * @var \Wordlift_User_Service $user_service The User service. |
|
| 156 | + */ |
|
| 157 | + protected $user_service; |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * The Timeline service. |
|
| 161 | + * |
|
| 162 | + * @since 3.1.0 |
|
| 163 | + * @access private |
|
| 164 | + * @var \Wordlift_Timeline_Service $timeline_service The Timeline service. |
|
| 165 | + */ |
|
| 166 | + private $timeline_service; |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * The Redirect service. |
|
| 170 | + * |
|
| 171 | + * @since 3.2.0 |
|
| 172 | + * @access private |
|
| 173 | + * @var \Wordlift_Redirect_Service $redirect_service The Redirect service. |
|
| 174 | + */ |
|
| 175 | + private $redirect_service; |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * The Notice service. |
|
| 179 | + * |
|
| 180 | + * @since 3.3.0 |
|
| 181 | + * @access private |
|
| 182 | + * @var \Wordlift_Notice_Service $notice_service The Notice service. |
|
| 183 | + */ |
|
| 184 | + private $notice_service; |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * The Entity list customization. |
|
| 188 | + * |
|
| 189 | + * @since 3.3.0 |
|
| 190 | + * @access protected |
|
| 191 | + * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service. |
|
| 192 | + */ |
|
| 193 | + protected $entity_list_service; |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * The Entity Types Taxonomy Walker. |
|
| 197 | + * |
|
| 198 | + * @since 3.1.0 |
|
| 199 | + * @access private |
|
| 200 | + * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker |
|
| 201 | + */ |
|
| 202 | + private $entity_types_taxonomy_walker; |
|
| 203 | + |
|
| 204 | + /** |
|
| 205 | + * The ShareThis service. |
|
| 206 | + * |
|
| 207 | + * @since 3.2.0 |
|
| 208 | + * @access private |
|
| 209 | + * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service. |
|
| 210 | + */ |
|
| 211 | + private $sharethis_service; |
|
| 212 | + |
|
| 213 | + /** |
|
| 214 | + * The PrimaShop adapter. |
|
| 215 | + * |
|
| 216 | + * @since 3.2.3 |
|
| 217 | + * @access private |
|
| 218 | + * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter. |
|
| 219 | + */ |
|
| 220 | + private $primashop_adapter; |
|
| 221 | + |
|
| 222 | + /** |
|
| 223 | + * The entity type service. |
|
| 224 | + * |
|
| 225 | + * @since 3.6.0 |
|
| 226 | + * @access private |
|
| 227 | + * @var \Wordlift_Entity_Post_Type_Service |
|
| 228 | + */ |
|
| 229 | + private $entity_post_type_service; |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * The entity link service used to mangle links to entities with a custom slug or even w/o a slug. |
|
| 233 | + * |
|
| 234 | + * @since 3.6.0 |
|
| 235 | + * @access private |
|
| 236 | + * @var \Wordlift_Entity_Link_Service $entity_link_service The {@link Wordlift_Entity_Link_Service} instance. |
|
| 237 | + */ |
|
| 238 | + private $entity_link_service; |
|
| 239 | + |
|
| 240 | + /** |
|
| 241 | + * A {@link Wordlift_Jsonld_Service} instance. |
|
| 242 | + * |
|
| 243 | + * @since 3.7.0 |
|
| 244 | + * @access protected |
|
| 245 | + * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance. |
|
| 246 | + */ |
|
| 247 | + protected $jsonld_service; |
|
| 248 | + |
|
| 249 | + /** |
|
| 250 | + * A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 251 | + * |
|
| 252 | + * @since 3.14.0 |
|
| 253 | + * @access protected |
|
| 254 | + * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 255 | + */ |
|
| 256 | + protected $jsonld_website_converter; |
|
| 257 | + |
|
| 258 | + /** |
|
| 259 | + * A {@link Wordlift_Property_Factory} instance. |
|
| 260 | + * |
|
| 261 | + * @since 3.7.0 |
|
| 262 | + * @access private |
|
| 263 | + * @var \Wordlift_Property_Factory $property_factory |
|
| 264 | + */ |
|
| 265 | + private $property_factory; |
|
| 266 | + |
|
| 267 | + /** |
|
| 268 | + * The 'Download Your Data' page. |
|
| 269 | + * |
|
| 270 | + * @since 3.6.0 |
|
| 271 | + * @access private |
|
| 272 | + * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page. |
|
| 273 | + */ |
|
| 274 | + private $download_your_data_page; |
|
| 275 | + |
|
| 276 | + /** |
|
| 277 | + * The 'WordLift Settings' page. |
|
| 278 | + * |
|
| 279 | + * @since 3.11.0 |
|
| 280 | + * @access protected |
|
| 281 | + * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page. |
|
| 282 | + */ |
|
| 283 | + protected $settings_page; |
|
| 284 | + |
|
| 285 | + /** |
|
| 286 | + * The install wizard page. |
|
| 287 | + * |
|
| 288 | + * @since 3.9.0 |
|
| 289 | + * @access private |
|
| 290 | + * @var \Wordlift_Admin_Setup $admin_setup The Install wizard. |
|
| 291 | + */ |
|
| 292 | + public $admin_setup; |
|
| 293 | + |
|
| 294 | + /** |
|
| 295 | + * The Content Filter Service hooks up to the 'the_content' filter and provides |
|
| 296 | + * linking of entities to their pages. |
|
| 297 | + * |
|
| 298 | + * @since 3.8.0 |
|
| 299 | + * @access private |
|
| 300 | + * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance. |
|
| 301 | + */ |
|
| 302 | + private $content_filter_service; |
|
| 303 | + |
|
| 304 | + /** |
|
| 305 | + * The Faq Content filter service |
|
| 306 | + * @since 3.26.0 |
|
| 307 | + * @access private |
|
| 308 | + * @var Faq_Content_Filter $faq_content_filter_service A {@link Faq_Content_Filter} instance. |
|
| 309 | + */ |
|
| 310 | + private $faq_content_filter_service; |
|
| 311 | + |
|
| 312 | + /** |
|
| 313 | + * A {@link Wordlift_Key_Validation_Service} instance. |
|
| 314 | + * |
|
| 315 | + * @since 3.9.0 |
|
| 316 | + * @access private |
|
| 317 | + * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 318 | + */ |
|
| 319 | + private $key_validation_service; |
|
| 320 | + |
|
| 321 | + /** |
|
| 322 | + * A {@link Wordlift_Rating_Service} instance. |
|
| 323 | + * |
|
| 324 | + * @since 3.10.0 |
|
| 325 | + * @access private |
|
| 326 | + * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance. |
|
| 327 | + */ |
|
| 328 | + private $rating_service; |
|
| 329 | + |
|
| 330 | + /** |
|
| 331 | + * A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 332 | + * |
|
| 333 | + * @since 3.10.0 |
|
| 334 | + * @access protected |
|
| 335 | + * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 336 | + */ |
|
| 337 | + protected $post_to_jsonld_converter; |
|
| 338 | + |
|
| 339 | + /** |
|
| 340 | + * A {@link Wordlift_Install_Service} instance. |
|
| 341 | + * |
|
| 342 | + * @since 3.18.0 |
|
| 343 | + * @access protected |
|
| 344 | + * @var \Wordlift_Install_Service $install_service A {@link Wordlift_Install_Service} instance. |
|
| 345 | + */ |
|
| 346 | + protected $install_service; |
|
| 347 | + |
|
| 348 | + /** |
|
| 349 | + * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 350 | + * |
|
| 351 | + * @since 3.10.0 |
|
| 352 | + * @access protected |
|
| 353 | + * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 354 | + */ |
|
| 355 | + protected $entity_post_to_jsonld_converter; |
|
| 356 | + |
|
| 357 | + /** |
|
| 358 | + * A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 359 | + * |
|
| 360 | + * @since 3.10.0 |
|
| 361 | + * @access protected |
|
| 362 | + * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 363 | + */ |
|
| 364 | + protected $postid_to_jsonld_converter; |
|
| 365 | + |
|
| 366 | + /** |
|
| 367 | + * The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 368 | + * |
|
| 369 | + * @since 3.11.0 |
|
| 370 | + * @access protected |
|
| 371 | + * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 372 | + */ |
|
| 373 | + protected $category_taxonomy_service; |
|
| 374 | + |
|
| 375 | + /** |
|
| 376 | + * The {@link Wordlift_Entity_Page_Service} instance. |
|
| 377 | + * |
|
| 378 | + * @since 3.11.0 |
|
| 379 | + * @access protected |
|
| 380 | + * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance. |
|
| 381 | + */ |
|
| 382 | + protected $entity_page_service; |
|
| 383 | + |
|
| 384 | + /** |
|
| 385 | + * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 386 | + * |
|
| 387 | + * @since 3.11.0 |
|
| 388 | + * @access protected |
|
| 389 | + * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 390 | + */ |
|
| 391 | + protected $settings_page_action_link; |
|
| 392 | + |
|
| 393 | + /** |
|
| 394 | + * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 395 | + * |
|
| 396 | + * @since 3.11.0 |
|
| 397 | + * @access protected |
|
| 398 | + * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 399 | + */ |
|
| 400 | + protected $analytics_settings_page_action_link; |
|
| 401 | + |
|
| 402 | + /** |
|
| 403 | + * The {@link Wordlift_Analytics_Connect} class. |
|
| 404 | + * |
|
| 405 | + * @since 3.11.0 |
|
| 406 | + * @access protected |
|
| 407 | + * @var \Wordlift_Analytics_Connect $analytics_connect The {@link Wordlift_Analytics_Connect} class. |
|
| 408 | + */ |
|
| 409 | + protected $analytics_connect; |
|
| 410 | + |
|
| 411 | + /** |
|
| 412 | + * The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 413 | + * |
|
| 414 | + * @since 3.11.0 |
|
| 415 | + * @access protected |
|
| 416 | + * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 417 | + */ |
|
| 418 | + protected $publisher_ajax_adapter; |
|
| 419 | + |
|
| 420 | + /** |
|
| 421 | + * The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 422 | + * |
|
| 423 | + * @since 3.11.0 |
|
| 424 | + * @access protected |
|
| 425 | + * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 426 | + */ |
|
| 427 | + protected $input_element; |
|
| 428 | + |
|
| 429 | + /** |
|
| 430 | + * The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 431 | + * |
|
| 432 | + * @since 3.13.0 |
|
| 433 | + * @access protected |
|
| 434 | + * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 435 | + */ |
|
| 436 | + protected $radio_input_element; |
|
| 437 | + |
|
| 438 | + /** |
|
| 439 | + * The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 440 | + * |
|
| 441 | + * @since 3.11.0 |
|
| 442 | + * @access protected |
|
| 443 | + * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 444 | + */ |
|
| 445 | + protected $language_select_element; |
|
| 446 | + |
|
| 447 | + /** |
|
| 448 | + * The {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 449 | + * |
|
| 450 | + * @since 3.18.0 |
|
| 451 | + * @access protected |
|
| 452 | + * @var \Wordlift_Admin_Country_Select_Element $country_select_element The {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 453 | + */ |
|
| 454 | + protected $country_select_element; |
|
| 455 | + |
|
| 456 | + /** |
|
| 457 | + * The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 458 | + * |
|
| 459 | + * @since 3.11.0 |
|
| 460 | + * @access protected |
|
| 461 | + * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 462 | + */ |
|
| 463 | + protected $publisher_element; |
|
| 464 | + |
|
| 465 | + /** |
|
| 466 | + * The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 467 | + * |
|
| 468 | + * @since 3.11.0 |
|
| 469 | + * @access protected |
|
| 470 | + * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 471 | + */ |
|
| 472 | + protected $select2_element; |
|
| 473 | + |
|
| 474 | + /** |
|
| 475 | + * The controller for the entity type list admin page |
|
| 476 | + * |
|
| 477 | + * @since 3.11.0 |
|
| 478 | + * @access private |
|
| 479 | + * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class. |
|
| 480 | + */ |
|
| 481 | + private $entity_type_admin_page; |
|
| 482 | + |
|
| 483 | + /** |
|
| 484 | + * The controller for the entity type settings admin page |
|
| 485 | + * |
|
| 486 | + * @since 3.11.0 |
|
| 487 | + * @access private |
|
| 488 | + * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class. |
|
| 489 | + */ |
|
| 490 | + private $entity_type_settings_admin_page; |
|
| 491 | + |
|
| 492 | + /** |
|
| 493 | + * The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 494 | + * |
|
| 495 | + * @since 3.11.0 |
|
| 496 | + * @access protected |
|
| 497 | + * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 498 | + */ |
|
| 499 | + protected $related_entities_cloud_widget; |
|
| 500 | + |
|
| 501 | + /** |
|
| 502 | + * The {@link Wordlift_Admin_Author_Element} instance. |
|
| 503 | + * |
|
| 504 | + * @since 3.14.0 |
|
| 505 | + * @access protected |
|
| 506 | + * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance. |
|
| 507 | + */ |
|
| 508 | + protected $author_element; |
|
| 509 | + |
|
| 510 | + /** |
|
| 511 | + * The {@link Wordlift_Sample_Data_Service} instance. |
|
| 512 | + * |
|
| 513 | + * @since 3.12.0 |
|
| 514 | + * @access protected |
|
| 515 | + * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance. |
|
| 516 | + */ |
|
| 517 | + protected $sample_data_service; |
|
| 518 | + |
|
| 519 | + /** |
|
| 520 | + * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 521 | + * |
|
| 522 | + * @since 3.12.0 |
|
| 523 | + * @access protected |
|
| 524 | + * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 525 | + */ |
|
| 526 | + protected $sample_data_ajax_adapter; |
|
| 527 | + |
|
| 528 | + /** |
|
| 529 | + * The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 530 | + * |
|
| 531 | + * @since 3.16.0 |
|
| 532 | + * @access protected |
|
| 533 | + * @var \Wordlift_Google_Analytics_Export_Service $google_analytics_export_service The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 534 | + */ |
|
| 535 | + protected $google_analytics_export_service; |
|
| 536 | + |
|
| 537 | + /** |
|
| 538 | + * {@link Wordlift}'s singleton instance. |
|
| 539 | + * |
|
| 540 | + * @since 3.15.0 |
|
| 541 | + * @access protected |
|
| 542 | + * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance. |
|
| 543 | + */ |
|
| 544 | + protected $entity_type_adapter; |
|
| 545 | + |
|
| 546 | + /** |
|
| 547 | + * The {@link Wordlift_Storage_Factory} instance. |
|
| 548 | + * |
|
| 549 | + * @since 3.15.0 |
|
| 550 | + * @access protected |
|
| 551 | + * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance. |
|
| 552 | + */ |
|
| 553 | + protected $storage_factory; |
|
| 554 | + |
|
| 555 | + /** |
|
| 556 | + * The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 557 | + * |
|
| 558 | + * @since 3.15.0 |
|
| 559 | + * @access private |
|
| 560 | + * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 561 | + */ |
|
| 562 | + private $autocomplete_adapter; |
|
| 563 | + |
|
| 564 | + /** |
|
| 565 | + * The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 566 | + * |
|
| 567 | + * @since 3.16.0 |
|
| 568 | + * @access protected |
|
| 569 | + * @var \Wordlift_Cached_Post_Converter $cached_postid_to_jsonld_converter The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 570 | + * |
|
| 571 | + */ |
|
| 572 | + protected $cached_postid_to_jsonld_converter; |
|
| 573 | + |
|
| 574 | + /** |
|
| 575 | + * The {@link Wordlift_Entity_Uri_Service} instance. |
|
| 576 | + * |
|
| 577 | + * @since 3.16.3 |
|
| 578 | + * @access protected |
|
| 579 | + * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance. |
|
| 580 | + */ |
|
| 581 | + protected $entity_uri_service; |
|
| 582 | + |
|
| 583 | + /** |
|
| 584 | + * The {@link Wordlift_Publisher_Service} instance. |
|
| 585 | + * |
|
| 586 | + * @since 3.19.0 |
|
| 587 | + * @access protected |
|
| 588 | + * @var \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance. |
|
| 589 | + */ |
|
| 590 | + protected $publisher_service; |
|
| 591 | + |
|
| 592 | + /** |
|
| 593 | + * The {@link Wordlift_Context_Cards_Service} instance. |
|
| 594 | + * |
|
| 595 | + * @var \Wordlift_Context_Cards_Service The {@link Wordlift_Context_Cards_Service} instance. |
|
| 596 | + */ |
|
| 597 | + protected $context_cards_service; |
|
| 598 | + |
|
| 599 | + /** |
|
| 600 | + * {@link Wordlift}'s singleton instance. |
|
| 601 | + * |
|
| 602 | + * @since 3.11.2 |
|
| 603 | + * @access private |
|
| 604 | + * @var Wordlift $instance {@link Wordlift}'s singleton instance. |
|
| 605 | + */ |
|
| 606 | + private static $instance; |
|
| 607 | + |
|
| 608 | + /** |
|
| 609 | + * A singleton instance of features registry. |
|
| 610 | + * @since 3.30.0 |
|
| 611 | + * @var Features_Registry |
|
| 612 | + */ |
|
| 613 | + private $features_registry; |
|
| 614 | + |
|
| 615 | + private $analytics_settings_page; |
|
| 616 | + //</editor-fold> |
|
| 617 | + |
|
| 618 | + // Experimental code added by Nishit for feature request 1496 |
|
| 619 | + private $webhook_loader; |
|
| 620 | + // Experimental code ents here |
|
| 621 | + |
|
| 622 | + /** |
|
| 623 | + * Define the core functionality of the plugin. |
|
| 624 | + * |
|
| 625 | + * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 626 | + * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 627 | + * the public-facing side of the site. |
|
| 628 | + * |
|
| 629 | + * @since 1.0.0 |
|
| 630 | + */ |
|
| 631 | + public function __construct() { |
|
| 632 | + |
|
| 633 | + self::$instance = $this; |
|
| 634 | + |
|
| 635 | + $this->plugin_name = 'wordlift'; |
|
| 636 | + $this->version = '3.36.1'; |
|
| 637 | + $this->load_dependencies(); |
|
| 638 | + $this->set_locale(); |
|
| 639 | + |
|
| 640 | + $that = $this; |
|
| 641 | + add_action( 'plugins_loaded', function () use ( $that ) { |
|
| 642 | + $that->define_admin_hooks( $that ); |
|
| 643 | + $that->define_public_hooks( $that ); |
|
| 644 | + }, 4 ); |
|
| 645 | + |
|
| 646 | + // If we're in `WP_CLI` load the related files. |
|
| 647 | + if ( class_exists( 'WP_CLI' ) ) { |
|
| 648 | + $this->load_cli_dependencies(); |
|
| 649 | + } |
|
| 650 | + |
|
| 651 | + } |
|
| 652 | + |
|
| 653 | + /** |
|
| 654 | + * Get the singleton instance. |
|
| 655 | + * |
|
| 656 | + * @return Wordlift The {@link Wordlift} singleton instance. |
|
| 657 | + * @since 3.11.2 |
|
| 658 | + * |
|
| 659 | + */ |
|
| 660 | + public static function get_instance() { |
|
| 661 | + |
|
| 662 | + return self::$instance; |
|
| 663 | + } |
|
| 664 | + |
|
| 665 | + /** |
|
| 666 | + * Load the required dependencies for this plugin. |
|
| 667 | + * |
|
| 668 | + * Include the following files that make up the plugin: |
|
| 669 | + * |
|
| 670 | + * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 671 | + * - Wordlift_i18n. Defines internationalization functionality. |
|
| 672 | + * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 673 | + * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 674 | + * |
|
| 675 | + * Create an instance of the loader which will be used to register the hooks |
|
| 676 | + * with WordPress. |
|
| 677 | + * |
|
| 678 | + * @throws Exception |
|
| 679 | + * @since 1.0.0 |
|
| 680 | + * @access private |
|
| 681 | + */ |
|
| 682 | + private function load_dependencies() { |
|
| 683 | + |
|
| 684 | + /** |
|
| 685 | + * The class responsible for orchestrating the actions and filters of the |
|
| 686 | + * core plugin. |
|
| 687 | + */ |
|
| 688 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 689 | + |
|
| 690 | + // The class responsible for plugin uninstall. |
|
| 691 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-deactivator-feedback.php'; |
|
| 692 | + |
|
| 693 | + /** |
|
| 694 | + * The class responsible for defining internationalization functionality |
|
| 695 | + * of the plugin. |
|
| 696 | + */ |
|
| 697 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 698 | + |
|
| 699 | + /** |
|
| 700 | + * WordLift's supported languages. |
|
| 701 | + */ |
|
| 702 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php'; |
|
| 703 | + |
|
| 704 | + /** |
|
| 705 | + * WordLift's supported countries. |
|
| 706 | + */ |
|
| 707 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-countries.php'; |
|
| 708 | + |
|
| 709 | + /** |
|
| 710 | + * Provide support functions to sanitize data. |
|
| 711 | + */ |
|
| 712 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 713 | + |
|
| 714 | + /** Services. */ |
|
| 715 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 716 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php'; |
|
| 717 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 718 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 719 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 720 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 721 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 722 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php'; |
|
| 723 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-image-service.php'; |
|
| 724 | + |
|
| 725 | + /** |
|
| 726 | + * The Schema service. |
|
| 727 | + */ |
|
| 728 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 729 | + |
|
| 730 | + /** |
|
| 731 | + * The schema:url property service. |
|
| 732 | + */ |
|
| 733 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 734 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 735 | + |
|
| 736 | + /** |
|
| 737 | + * The UI service. |
|
| 738 | + */ |
|
| 739 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 740 | + |
|
| 741 | + /** |
|
| 742 | + * The Entity Types Taxonomy service. |
|
| 743 | + */ |
|
| 744 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-taxonomy-service.php'; |
|
| 745 | + |
|
| 746 | + /** |
|
| 747 | + * The Entity service. |
|
| 748 | + */ |
|
| 749 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php'; |
|
| 750 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 751 | + |
|
| 752 | + // Add the entity rating service. |
|
| 753 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php'; |
|
| 754 | + |
|
| 755 | + /** |
|
| 756 | + * The User service. |
|
| 757 | + */ |
|
| 758 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 759 | + |
|
| 760 | + /** |
|
| 761 | + * The Timeline service. |
|
| 762 | + */ |
|
| 763 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 764 | + |
|
| 765 | + /** |
|
| 766 | + * The Topic Taxonomy service. |
|
| 767 | + */ |
|
| 768 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 769 | + |
|
| 770 | + /** |
|
| 771 | + * The WordLift URI service. |
|
| 772 | + */ |
|
| 773 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 774 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 775 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php'; |
|
| 776 | + |
|
| 777 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 778 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php'; |
|
| 779 | + |
|
| 780 | + /** |
|
| 781 | + * Load the converters. |
|
| 782 | + */ |
|
| 783 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php'; |
|
| 784 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 785 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 786 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 787 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 788 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php'; |
|
| 789 | + |
|
| 790 | + /** |
|
| 791 | + * Load cache-related files. |
|
| 792 | + */ |
|
| 793 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php'; |
|
| 794 | + |
|
| 795 | + /** |
|
| 796 | + * Load the content filter. |
|
| 797 | + */ |
|
| 798 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 799 | + |
|
| 800 | + /* |
|
| 801 | 801 | * Load the excerpt helper. |
| 802 | 802 | */ |
| 803 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 804 | - |
|
| 805 | - /** |
|
| 806 | - * Load the JSON-LD service to publish entities using JSON-LD.s |
|
| 807 | - * |
|
| 808 | - * @since 3.8.0 |
|
| 809 | - */ |
|
| 810 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 811 | - |
|
| 812 | - // The Publisher Service and the AJAX adapter. |
|
| 813 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php'; |
|
| 814 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 815 | - |
|
| 816 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php'; |
|
| 817 | - |
|
| 818 | - /** |
|
| 819 | - * Load the WordLift key validation service. |
|
| 820 | - */ |
|
| 821 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php'; |
|
| 822 | - |
|
| 823 | - // Load the `Wordlift_Category_Taxonomy_Service` class definition. |
|
| 824 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 825 | - |
|
| 826 | - // Load the `Wordlift_Entity_Page_Service` class definition. |
|
| 827 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php'; |
|
| 828 | - |
|
| 829 | - /** Linked Data. */ |
|
| 830 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php'; |
|
| 831 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php'; |
|
| 832 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php'; |
|
| 833 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php'; |
|
| 834 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php'; |
|
| 835 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php'; |
|
| 836 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php'; |
|
| 837 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php'; |
|
| 838 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php'; |
|
| 839 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php'; |
|
| 840 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php'; |
|
| 841 | - |
|
| 842 | - /** Services. */ |
|
| 843 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php'; |
|
| 844 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-api-service.php'; |
|
| 845 | - |
|
| 846 | - /** Adapters. */ |
|
| 847 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php'; |
|
| 848 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php'; |
|
| 849 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php'; |
|
| 850 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php'; |
|
| 851 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-wprocket-adapter.php'; |
|
| 852 | - |
|
| 853 | - /** Autocomplete. */ |
|
| 854 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php'; |
|
| 855 | - |
|
| 856 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-remote-image-service.php'; |
|
| 857 | - |
|
| 858 | - /** Analytics */ |
|
| 859 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/analytics/class-wordlift-analytics-connect.php'; |
|
| 860 | - |
|
| 861 | - /** |
|
| 862 | - * The class responsible for defining all actions that occur in the admin area. |
|
| 863 | - */ |
|
| 864 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 865 | - |
|
| 866 | - /** |
|
| 867 | - * The class to customize the entity list admin page. |
|
| 868 | - */ |
|
| 869 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 870 | - |
|
| 871 | - /** |
|
| 872 | - * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 873 | - */ |
|
| 874 | - global $wp_version; |
|
| 875 | - if ( version_compare( $wp_version, '5.3', '<' ) ) { |
|
| 876 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 877 | - } else { |
|
| 878 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker-5-3.php'; |
|
| 879 | - } |
|
| 880 | - |
|
| 881 | - /** |
|
| 882 | - * The Notice service. |
|
| 883 | - */ |
|
| 884 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 885 | - |
|
| 886 | - /** |
|
| 887 | - * The PrimaShop adapter. |
|
| 888 | - */ |
|
| 889 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 890 | - |
|
| 891 | - /** |
|
| 892 | - * The WordLift Dashboard service. |
|
| 893 | - */ |
|
| 894 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 895 | - |
|
| 896 | - /** |
|
| 897 | - * The admin 'Install wizard' page. |
|
| 898 | - */ |
|
| 899 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php'; |
|
| 900 | - |
|
| 901 | - /** |
|
| 902 | - * The WordLift entity type list admin page controller. |
|
| 903 | - */ |
|
| 904 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 905 | - |
|
| 906 | - /** |
|
| 907 | - * The WordLift entity type settings admin page controller. |
|
| 908 | - */ |
|
| 909 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php'; |
|
| 910 | - |
|
| 911 | - /** |
|
| 912 | - * The admin 'Download Your Data' page. |
|
| 913 | - */ |
|
| 914 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 915 | - |
|
| 916 | - /** |
|
| 917 | - * The admin 'WordLift Settings' page. |
|
| 918 | - */ |
|
| 919 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/intf-wordlift-admin-element.php'; |
|
| 920 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-element.php'; |
|
| 921 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-radio-element.php'; |
|
| 922 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select-element.php'; |
|
| 923 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select2-element.php'; |
|
| 924 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-language-select-element.php'; |
|
| 925 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-country-select-element.php'; |
|
| 926 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-tabs-element.php'; |
|
| 927 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-author-element.php'; |
|
| 928 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-publisher-element.php'; |
|
| 929 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php'; |
|
| 930 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php'; |
|
| 931 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page.php'; |
|
| 932 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 933 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page-action-link.php'; |
|
| 934 | - |
|
| 935 | - /** Admin Pages */ |
|
| 936 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php'; |
|
| 937 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php'; |
|
| 938 | - |
|
| 939 | - /** |
|
| 940 | - * The class responsible for defining all actions that occur in the public-facing |
|
| 941 | - * side of the site. |
|
| 942 | - */ |
|
| 943 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 944 | - |
|
| 945 | - /** |
|
| 946 | - * The shortcode abstract class. |
|
| 947 | - */ |
|
| 948 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 949 | - |
|
| 950 | - /** |
|
| 951 | - * The Timeline shortcode. |
|
| 952 | - */ |
|
| 953 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 954 | - |
|
| 955 | - /** |
|
| 956 | - * The Navigator shortcode. |
|
| 957 | - */ |
|
| 958 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 959 | - |
|
| 960 | - /** |
|
| 961 | - * The Products Navigator shortcode. |
|
| 962 | - */ |
|
| 963 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-products-navigator-shortcode.php'; |
|
| 964 | - |
|
| 965 | - /** |
|
| 966 | - * The chord shortcode. |
|
| 967 | - */ |
|
| 968 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 969 | - |
|
| 970 | - /** |
|
| 971 | - * The geomap shortcode. |
|
| 972 | - */ |
|
| 973 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 974 | - |
|
| 975 | - /** |
|
| 976 | - * The entity cloud shortcode. |
|
| 977 | - */ |
|
| 978 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 979 | - |
|
| 980 | - /** |
|
| 981 | - * The entity glossary shortcode. |
|
| 982 | - */ |
|
| 983 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php'; |
|
| 984 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php'; |
|
| 985 | - |
|
| 986 | - /** |
|
| 987 | - * Faceted Search shortcode. |
|
| 988 | - */ |
|
| 989 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-faceted-search-shortcode.php'; |
|
| 990 | - |
|
| 991 | - /** |
|
| 992 | - * The ShareThis service. |
|
| 993 | - */ |
|
| 994 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 995 | - |
|
| 996 | - /** |
|
| 997 | - * The SEO service. |
|
| 998 | - */ |
|
| 999 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php'; |
|
| 1000 | - |
|
| 1001 | - /** |
|
| 1002 | - * The AMP service. |
|
| 1003 | - */ |
|
| 1004 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php'; |
|
| 1005 | - |
|
| 1006 | - /** Widgets */ |
|
| 1007 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php'; |
|
| 1008 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 1009 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-context-cards.php'; |
|
| 1010 | - |
|
| 1011 | - /* |
|
| 803 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 804 | + |
|
| 805 | + /** |
|
| 806 | + * Load the JSON-LD service to publish entities using JSON-LD.s |
|
| 807 | + * |
|
| 808 | + * @since 3.8.0 |
|
| 809 | + */ |
|
| 810 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 811 | + |
|
| 812 | + // The Publisher Service and the AJAX adapter. |
|
| 813 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php'; |
|
| 814 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 815 | + |
|
| 816 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php'; |
|
| 817 | + |
|
| 818 | + /** |
|
| 819 | + * Load the WordLift key validation service. |
|
| 820 | + */ |
|
| 821 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php'; |
|
| 822 | + |
|
| 823 | + // Load the `Wordlift_Category_Taxonomy_Service` class definition. |
|
| 824 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 825 | + |
|
| 826 | + // Load the `Wordlift_Entity_Page_Service` class definition. |
|
| 827 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php'; |
|
| 828 | + |
|
| 829 | + /** Linked Data. */ |
|
| 830 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php'; |
|
| 831 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php'; |
|
| 832 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php'; |
|
| 833 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php'; |
|
| 834 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php'; |
|
| 835 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php'; |
|
| 836 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php'; |
|
| 837 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php'; |
|
| 838 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php'; |
|
| 839 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php'; |
|
| 840 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php'; |
|
| 841 | + |
|
| 842 | + /** Services. */ |
|
| 843 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php'; |
|
| 844 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-api-service.php'; |
|
| 845 | + |
|
| 846 | + /** Adapters. */ |
|
| 847 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php'; |
|
| 848 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php'; |
|
| 849 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php'; |
|
| 850 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php'; |
|
| 851 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-wprocket-adapter.php'; |
|
| 852 | + |
|
| 853 | + /** Autocomplete. */ |
|
| 854 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php'; |
|
| 855 | + |
|
| 856 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-remote-image-service.php'; |
|
| 857 | + |
|
| 858 | + /** Analytics */ |
|
| 859 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/analytics/class-wordlift-analytics-connect.php'; |
|
| 860 | + |
|
| 861 | + /** |
|
| 862 | + * The class responsible for defining all actions that occur in the admin area. |
|
| 863 | + */ |
|
| 864 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 865 | + |
|
| 866 | + /** |
|
| 867 | + * The class to customize the entity list admin page. |
|
| 868 | + */ |
|
| 869 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 870 | + |
|
| 871 | + /** |
|
| 872 | + * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 873 | + */ |
|
| 874 | + global $wp_version; |
|
| 875 | + if ( version_compare( $wp_version, '5.3', '<' ) ) { |
|
| 876 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 877 | + } else { |
|
| 878 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker-5-3.php'; |
|
| 879 | + } |
|
| 880 | + |
|
| 881 | + /** |
|
| 882 | + * The Notice service. |
|
| 883 | + */ |
|
| 884 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 885 | + |
|
| 886 | + /** |
|
| 887 | + * The PrimaShop adapter. |
|
| 888 | + */ |
|
| 889 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 890 | + |
|
| 891 | + /** |
|
| 892 | + * The WordLift Dashboard service. |
|
| 893 | + */ |
|
| 894 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 895 | + |
|
| 896 | + /** |
|
| 897 | + * The admin 'Install wizard' page. |
|
| 898 | + */ |
|
| 899 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php'; |
|
| 900 | + |
|
| 901 | + /** |
|
| 902 | + * The WordLift entity type list admin page controller. |
|
| 903 | + */ |
|
| 904 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 905 | + |
|
| 906 | + /** |
|
| 907 | + * The WordLift entity type settings admin page controller. |
|
| 908 | + */ |
|
| 909 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php'; |
|
| 910 | + |
|
| 911 | + /** |
|
| 912 | + * The admin 'Download Your Data' page. |
|
| 913 | + */ |
|
| 914 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 915 | + |
|
| 916 | + /** |
|
| 917 | + * The admin 'WordLift Settings' page. |
|
| 918 | + */ |
|
| 919 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/intf-wordlift-admin-element.php'; |
|
| 920 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-element.php'; |
|
| 921 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-radio-element.php'; |
|
| 922 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select-element.php'; |
|
| 923 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select2-element.php'; |
|
| 924 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-language-select-element.php'; |
|
| 925 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-country-select-element.php'; |
|
| 926 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-tabs-element.php'; |
|
| 927 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-author-element.php'; |
|
| 928 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-publisher-element.php'; |
|
| 929 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php'; |
|
| 930 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php'; |
|
| 931 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page.php'; |
|
| 932 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 933 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page-action-link.php'; |
|
| 934 | + |
|
| 935 | + /** Admin Pages */ |
|
| 936 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php'; |
|
| 937 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php'; |
|
| 938 | + |
|
| 939 | + /** |
|
| 940 | + * The class responsible for defining all actions that occur in the public-facing |
|
| 941 | + * side of the site. |
|
| 942 | + */ |
|
| 943 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 944 | + |
|
| 945 | + /** |
|
| 946 | + * The shortcode abstract class. |
|
| 947 | + */ |
|
| 948 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 949 | + |
|
| 950 | + /** |
|
| 951 | + * The Timeline shortcode. |
|
| 952 | + */ |
|
| 953 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 954 | + |
|
| 955 | + /** |
|
| 956 | + * The Navigator shortcode. |
|
| 957 | + */ |
|
| 958 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 959 | + |
|
| 960 | + /** |
|
| 961 | + * The Products Navigator shortcode. |
|
| 962 | + */ |
|
| 963 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-products-navigator-shortcode.php'; |
|
| 964 | + |
|
| 965 | + /** |
|
| 966 | + * The chord shortcode. |
|
| 967 | + */ |
|
| 968 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 969 | + |
|
| 970 | + /** |
|
| 971 | + * The geomap shortcode. |
|
| 972 | + */ |
|
| 973 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 974 | + |
|
| 975 | + /** |
|
| 976 | + * The entity cloud shortcode. |
|
| 977 | + */ |
|
| 978 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 979 | + |
|
| 980 | + /** |
|
| 981 | + * The entity glossary shortcode. |
|
| 982 | + */ |
|
| 983 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php'; |
|
| 984 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php'; |
|
| 985 | + |
|
| 986 | + /** |
|
| 987 | + * Faceted Search shortcode. |
|
| 988 | + */ |
|
| 989 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-faceted-search-shortcode.php'; |
|
| 990 | + |
|
| 991 | + /** |
|
| 992 | + * The ShareThis service. |
|
| 993 | + */ |
|
| 994 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 995 | + |
|
| 996 | + /** |
|
| 997 | + * The SEO service. |
|
| 998 | + */ |
|
| 999 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php'; |
|
| 1000 | + |
|
| 1001 | + /** |
|
| 1002 | + * The AMP service. |
|
| 1003 | + */ |
|
| 1004 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php'; |
|
| 1005 | + |
|
| 1006 | + /** Widgets */ |
|
| 1007 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php'; |
|
| 1008 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 1009 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-context-cards.php'; |
|
| 1010 | + |
|
| 1011 | + /* |
|
| 1012 | 1012 | * Batch Operations. They're similar to Batch Actions but do not require working on post types. |
| 1013 | 1013 | * |
| 1014 | 1014 | * Eventually Batch Actions will become Batch Operations. |
| 1015 | 1015 | * |
| 1016 | 1016 | * @since 3.20.0 |
| 1017 | 1017 | */ |
| 1018 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/intf-wordlift-batch-operation.php'; |
|
| 1019 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/class-wordlift-batch-operation-ajax-adapter.php'; |
|
| 1018 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/intf-wordlift-batch-operation.php'; |
|
| 1019 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/class-wordlift-batch-operation-ajax-adapter.php'; |
|
| 1020 | 1020 | |
| 1021 | - /* |
|
| 1021 | + /* |
|
| 1022 | 1022 | * Schema.org Services. |
| 1023 | 1023 | * |
| 1024 | 1024 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
| 1025 | 1025 | */ |
| 1026 | - if ( apply_filters( 'wl_feature__enable__all-entity-types', WL_ALL_ENTITY_TYPES ) ) { |
|
| 1027 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-sync-service.php'; |
|
| 1028 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-property-service.php'; |
|
| 1029 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-class-service.php'; |
|
| 1030 | - new Wordlift_Schemaorg_Sync_Service(); |
|
| 1031 | - $schemaorg_property_service = Wordlift_Schemaorg_Property_Service::get_instance(); |
|
| 1032 | - new Wordlift_Schemaorg_Class_Service(); |
|
| 1033 | - } else { |
|
| 1034 | - $schemaorg_property_service = null; |
|
| 1035 | - } |
|
| 1036 | - |
|
| 1037 | - $this->loader = new Wordlift_Loader(); |
|
| 1038 | - /** |
|
| 1039 | - * @since 3.30.0 |
|
| 1040 | - */ |
|
| 1041 | - $this->features_registry = Features_Registry::get_instance(); |
|
| 1042 | - |
|
| 1043 | - // Instantiate a global logger. |
|
| 1044 | - global $wl_logger; |
|
| 1045 | - $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 1046 | - |
|
| 1047 | - // Load the `wl-api` end-point. |
|
| 1048 | - new Wordlift_Http_Api(); |
|
| 1049 | - |
|
| 1050 | - // Load the Install Service. |
|
| 1051 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-service.php'; |
|
| 1052 | - $this->install_service = new Wordlift_Install_Service(); |
|
| 1053 | - $this->notice_service = new Wordlift_Notice_Service(); |
|
| 1054 | - $this->user_service = Wordlift_User_Service::get_instance(); |
|
| 1055 | - // create an instance of the entity type list admin page controller. |
|
| 1056 | - $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page(); |
|
| 1057 | - $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 1058 | - $this->entity_types_taxonomy_service = new Wordlift_Entity_Type_Taxonomy_Service(); |
|
| 1059 | - // Create an entity type service instance. It'll be later bound to the init action. |
|
| 1060 | - $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( |
|
| 1061 | - Wordlift_Entity_Service::TYPE_NAME, Wordlift_Configuration_Service::get_instance()->get_entity_base_path() ); |
|
| 1062 | - /* WordPress Admin. */ |
|
| 1063 | - $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page(); |
|
| 1064 | - // create an instance of the entity type setting admin page controller. |
|
| 1065 | - $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings(); |
|
| 1066 | - |
|
| 1067 | - |
|
| 1068 | - $that = $this; |
|
| 1069 | - add_action( 'plugins_loaded', function () use ( &$that, $schemaorg_property_service ) { |
|
| 1070 | - |
|
| 1071 | - /** Services. */ |
|
| 1072 | - // Create the configuration service. |
|
| 1073 | - $api_service = new Wordlift_Api_Service(); |
|
| 1074 | - |
|
| 1075 | - // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 1076 | - $that->entity_link_service = new Wordlift_Entity_Link_Service( $that->entity_post_type_service, Wordlift_Configuration_Service::get_instance()->get_entity_base_path() ); |
|
| 1077 | - |
|
| 1078 | - $schema_url_property_service = new Wordlift_Schema_Url_Property_Service(); |
|
| 1079 | - |
|
| 1080 | - $that->entity_uri_service = Wordlift_Entity_Uri_Service::get_instance(); |
|
| 1081 | - |
|
| 1082 | - // Create a new instance of the Redirect service. |
|
| 1083 | - $that->redirect_service = new Wordlift_Redirect_Service( $that->entity_uri_service ); |
|
| 1084 | - |
|
| 1085 | - // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 1086 | - $that->timeline_service = new Wordlift_Timeline_Service(); |
|
| 1087 | - |
|
| 1088 | - $that->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 1089 | - |
|
| 1090 | - // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 1091 | - $that->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 1092 | - |
|
| 1093 | - // Create an instance of the PrimaShop adapter. |
|
| 1094 | - $that->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 1095 | - |
|
| 1096 | - $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 1097 | - |
|
| 1098 | - // Create the entity rating service. |
|
| 1099 | - $that->rating_service = Wordlift_Rating_Service::get_instance(); |
|
| 1100 | - |
|
| 1101 | - // Create entity list customization (wp-admin/edit.php). |
|
| 1102 | - $that->entity_list_service = new Wordlift_Entity_List_Service( $that->rating_service ); |
|
| 1103 | - |
|
| 1104 | - // Create an instance of the Publisher Service and the AJAX Adapter. |
|
| 1105 | - $that->publisher_service = Wordlift_Publisher_Service::get_instance(); |
|
| 1106 | - $that->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 1107 | - $that->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 1108 | - |
|
| 1109 | - $attachment_service = Wordlift_Attachment_Service::get_instance(); |
|
| 1110 | - |
|
| 1111 | - // Instantiate the JSON-LD service. |
|
| 1112 | - $property_getter = Wordlift_Property_Getter_Factory::create(); |
|
| 1113 | - $that->post_to_jsonld_converter = new Wordlift_Post_To_Jsonld_Converter( Wordlift_Entity_Type_Service::get_instance(), $that->user_service, $attachment_service ); |
|
| 1114 | - $that->entity_post_to_jsonld_converter = new Wordlift_Entity_Post_To_Jsonld_Converter( Wordlift_Entity_Type_Service::get_instance(), $that->user_service, $attachment_service, $property_getter, $schemaorg_property_service, $that->post_to_jsonld_converter ); |
|
| 1115 | - $that->postid_to_jsonld_converter = new Wordlift_Postid_To_Jsonld_Converter( $that->entity_post_to_jsonld_converter, $that->post_to_jsonld_converter ); |
|
| 1116 | - $that->jsonld_website_converter = new Wordlift_Website_Jsonld_Converter( Wordlift_Entity_Type_Service::get_instance(), $that->user_service, $attachment_service ); |
|
| 1117 | - |
|
| 1118 | - $jsonld_cache = new Ttl_Cache( 'jsonld', 86400 ); |
|
| 1119 | - $that->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $that->postid_to_jsonld_converter, $jsonld_cache ); |
|
| 1120 | - /* |
|
| 1026 | + if ( apply_filters( 'wl_feature__enable__all-entity-types', WL_ALL_ENTITY_TYPES ) ) { |
|
| 1027 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-sync-service.php'; |
|
| 1028 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-property-service.php'; |
|
| 1029 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-class-service.php'; |
|
| 1030 | + new Wordlift_Schemaorg_Sync_Service(); |
|
| 1031 | + $schemaorg_property_service = Wordlift_Schemaorg_Property_Service::get_instance(); |
|
| 1032 | + new Wordlift_Schemaorg_Class_Service(); |
|
| 1033 | + } else { |
|
| 1034 | + $schemaorg_property_service = null; |
|
| 1035 | + } |
|
| 1036 | + |
|
| 1037 | + $this->loader = new Wordlift_Loader(); |
|
| 1038 | + /** |
|
| 1039 | + * @since 3.30.0 |
|
| 1040 | + */ |
|
| 1041 | + $this->features_registry = Features_Registry::get_instance(); |
|
| 1042 | + |
|
| 1043 | + // Instantiate a global logger. |
|
| 1044 | + global $wl_logger; |
|
| 1045 | + $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 1046 | + |
|
| 1047 | + // Load the `wl-api` end-point. |
|
| 1048 | + new Wordlift_Http_Api(); |
|
| 1049 | + |
|
| 1050 | + // Load the Install Service. |
|
| 1051 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-service.php'; |
|
| 1052 | + $this->install_service = new Wordlift_Install_Service(); |
|
| 1053 | + $this->notice_service = new Wordlift_Notice_Service(); |
|
| 1054 | + $this->user_service = Wordlift_User_Service::get_instance(); |
|
| 1055 | + // create an instance of the entity type list admin page controller. |
|
| 1056 | + $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page(); |
|
| 1057 | + $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 1058 | + $this->entity_types_taxonomy_service = new Wordlift_Entity_Type_Taxonomy_Service(); |
|
| 1059 | + // Create an entity type service instance. It'll be later bound to the init action. |
|
| 1060 | + $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( |
|
| 1061 | + Wordlift_Entity_Service::TYPE_NAME, Wordlift_Configuration_Service::get_instance()->get_entity_base_path() ); |
|
| 1062 | + /* WordPress Admin. */ |
|
| 1063 | + $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page(); |
|
| 1064 | + // create an instance of the entity type setting admin page controller. |
|
| 1065 | + $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings(); |
|
| 1066 | + |
|
| 1067 | + |
|
| 1068 | + $that = $this; |
|
| 1069 | + add_action( 'plugins_loaded', function () use ( &$that, $schemaorg_property_service ) { |
|
| 1070 | + |
|
| 1071 | + /** Services. */ |
|
| 1072 | + // Create the configuration service. |
|
| 1073 | + $api_service = new Wordlift_Api_Service(); |
|
| 1074 | + |
|
| 1075 | + // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 1076 | + $that->entity_link_service = new Wordlift_Entity_Link_Service( $that->entity_post_type_service, Wordlift_Configuration_Service::get_instance()->get_entity_base_path() ); |
|
| 1077 | + |
|
| 1078 | + $schema_url_property_service = new Wordlift_Schema_Url_Property_Service(); |
|
| 1079 | + |
|
| 1080 | + $that->entity_uri_service = Wordlift_Entity_Uri_Service::get_instance(); |
|
| 1081 | + |
|
| 1082 | + // Create a new instance of the Redirect service. |
|
| 1083 | + $that->redirect_service = new Wordlift_Redirect_Service( $that->entity_uri_service ); |
|
| 1084 | + |
|
| 1085 | + // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 1086 | + $that->timeline_service = new Wordlift_Timeline_Service(); |
|
| 1087 | + |
|
| 1088 | + $that->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 1089 | + |
|
| 1090 | + // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 1091 | + $that->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 1092 | + |
|
| 1093 | + // Create an instance of the PrimaShop adapter. |
|
| 1094 | + $that->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 1095 | + |
|
| 1096 | + $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 1097 | + |
|
| 1098 | + // Create the entity rating service. |
|
| 1099 | + $that->rating_service = Wordlift_Rating_Service::get_instance(); |
|
| 1100 | + |
|
| 1101 | + // Create entity list customization (wp-admin/edit.php). |
|
| 1102 | + $that->entity_list_service = new Wordlift_Entity_List_Service( $that->rating_service ); |
|
| 1103 | + |
|
| 1104 | + // Create an instance of the Publisher Service and the AJAX Adapter. |
|
| 1105 | + $that->publisher_service = Wordlift_Publisher_Service::get_instance(); |
|
| 1106 | + $that->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 1107 | + $that->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 1108 | + |
|
| 1109 | + $attachment_service = Wordlift_Attachment_Service::get_instance(); |
|
| 1110 | + |
|
| 1111 | + // Instantiate the JSON-LD service. |
|
| 1112 | + $property_getter = Wordlift_Property_Getter_Factory::create(); |
|
| 1113 | + $that->post_to_jsonld_converter = new Wordlift_Post_To_Jsonld_Converter( Wordlift_Entity_Type_Service::get_instance(), $that->user_service, $attachment_service ); |
|
| 1114 | + $that->entity_post_to_jsonld_converter = new Wordlift_Entity_Post_To_Jsonld_Converter( Wordlift_Entity_Type_Service::get_instance(), $that->user_service, $attachment_service, $property_getter, $schemaorg_property_service, $that->post_to_jsonld_converter ); |
|
| 1115 | + $that->postid_to_jsonld_converter = new Wordlift_Postid_To_Jsonld_Converter( $that->entity_post_to_jsonld_converter, $that->post_to_jsonld_converter ); |
|
| 1116 | + $that->jsonld_website_converter = new Wordlift_Website_Jsonld_Converter( Wordlift_Entity_Type_Service::get_instance(), $that->user_service, $attachment_service ); |
|
| 1117 | + |
|
| 1118 | + $jsonld_cache = new Ttl_Cache( 'jsonld', 86400 ); |
|
| 1119 | + $that->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $that->postid_to_jsonld_converter, $jsonld_cache ); |
|
| 1120 | + /* |
|
| 1121 | 1121 | * Load the `Wordlift_Term_JsonLd_Adapter`. |
| 1122 | 1122 | * |
| 1123 | 1123 | * @see https://github.com/insideout10/wordlift-plugin/issues/892 |
| 1124 | 1124 | * |
| 1125 | 1125 | * @since 3.20.0 |
| 1126 | 1126 | */ |
| 1127 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-term-jsonld-adapter.php'; |
|
| 1128 | - |
|
| 1129 | - $term_jsonld_adapter = new Wordlift_Term_JsonLd_Adapter( $that->entity_uri_service, $that->cached_postid_to_jsonld_converter ); |
|
| 1130 | - $that->jsonld_service = new Wordlift_Jsonld_Service( Wordlift_Entity_Service::get_instance(), $that->cached_postid_to_jsonld_converter, $that->jsonld_website_converter, $term_jsonld_adapter ); |
|
| 1131 | - |
|
| 1132 | - $jsonld_service = new Jsonld_Service( |
|
| 1133 | - $that->jsonld_service, |
|
| 1134 | - $term_jsonld_adapter, |
|
| 1135 | - new Jsonld_User_Service( $that->user_service ) ); |
|
| 1136 | - new Jsonld_Endpoint( $jsonld_service, $that->entity_uri_service ); |
|
| 1137 | - |
|
| 1138 | - // Prints the JSON-LD in the head. |
|
| 1139 | - new Jsonld_Adapter( $that->jsonld_service ); |
|
| 1140 | - |
|
| 1141 | - new Jsonld_By_Id_Endpoint( $that->jsonld_service, $that->entity_uri_service ); |
|
| 1142 | - |
|
| 1143 | - $that->key_validation_service = new Wordlift_Key_Validation_Service(); |
|
| 1144 | - $that->content_filter_service = Wordlift_Content_Filter_Service::get_instance(); |
|
| 1145 | - // Creating Faq Content filter service. |
|
| 1146 | - $that->faq_content_filter_service = new Faq_Content_Filter(); |
|
| 1147 | - $that->sample_data_service = Wordlift_Sample_Data_Service::get_instance(); |
|
| 1148 | - $that->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $that->sample_data_service ); |
|
| 1149 | - |
|
| 1150 | - $that->loader->add_action( 'enqueue_block_editor_assets', $that, 'add_wl_enabled_blocks' ); |
|
| 1151 | - $that->loader->add_action( 'admin_enqueue_scripts', $that, 'add_wl_enabled_blocks' ); |
|
| 1152 | - |
|
| 1153 | - /** |
|
| 1154 | - * Filter: wl_feature__enable__blocks. |
|
| 1155 | - * |
|
| 1156 | - * @param bool whether the blocks needed to be registered, defaults to true. |
|
| 1157 | - * |
|
| 1158 | - * @return bool |
|
| 1159 | - * @since 3.27.6 |
|
| 1160 | - */ |
|
| 1161 | - if ( apply_filters( 'wl_feature__enable__blocks', true ) ) { |
|
| 1162 | - // Initialize the short-codes. |
|
| 1163 | - new Async_Template_Decorator( new Wordlift_Navigator_Shortcode() ); |
|
| 1164 | - new Wordlift_Chord_Shortcode(); |
|
| 1165 | - new Wordlift_Geomap_Shortcode(); |
|
| 1166 | - new Wordlift_Timeline_Shortcode(); |
|
| 1167 | - new Wordlift_Related_Entities_Cloud_Shortcode( Wordlift_Relation_Service::get_instance(), Wordlift_Entity_Service::get_instance() ); |
|
| 1168 | - new Wordlift_Vocabulary_Shortcode(); |
|
| 1169 | - new Async_Template_Decorator( new Wordlift_Faceted_Search_Shortcode() ); |
|
| 1170 | - } |
|
| 1171 | - |
|
| 1172 | - new Wordlift_Products_Navigator_Shortcode(); |
|
| 1173 | - |
|
| 1174 | - |
|
| 1175 | - // Initialize the Context Cards Service |
|
| 1176 | - $that->context_cards_service = new Wordlift_Context_Cards_Service(); |
|
| 1177 | - |
|
| 1178 | - // Initialize the SEO service. |
|
| 1179 | - new Wordlift_Seo_Service(); |
|
| 1180 | - |
|
| 1181 | - // Initialize the AMP service. |
|
| 1182 | - new Wordlift_AMP_Service( $that->jsonld_service ); |
|
| 1183 | - |
|
| 1184 | - /** Services. */ |
|
| 1185 | - $that->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service(); |
|
| 1186 | - new Wordlift_Image_Service(); |
|
| 1187 | - |
|
| 1188 | - /** Adapters. */ |
|
| 1189 | - $that->entity_type_adapter = new Wordlift_Entity_Type_Adapter( Wordlift_Entity_Type_Service::get_instance() ); |
|
| 1190 | - $that->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $that->publisher_service ); |
|
| 1191 | - $that->tinymce_adapter = new Wordlift_Tinymce_Adapter( $that ); |
|
| 1192 | - |
|
| 1193 | - /* |
|
| 1127 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-term-jsonld-adapter.php'; |
|
| 1128 | + |
|
| 1129 | + $term_jsonld_adapter = new Wordlift_Term_JsonLd_Adapter( $that->entity_uri_service, $that->cached_postid_to_jsonld_converter ); |
|
| 1130 | + $that->jsonld_service = new Wordlift_Jsonld_Service( Wordlift_Entity_Service::get_instance(), $that->cached_postid_to_jsonld_converter, $that->jsonld_website_converter, $term_jsonld_adapter ); |
|
| 1131 | + |
|
| 1132 | + $jsonld_service = new Jsonld_Service( |
|
| 1133 | + $that->jsonld_service, |
|
| 1134 | + $term_jsonld_adapter, |
|
| 1135 | + new Jsonld_User_Service( $that->user_service ) ); |
|
| 1136 | + new Jsonld_Endpoint( $jsonld_service, $that->entity_uri_service ); |
|
| 1137 | + |
|
| 1138 | + // Prints the JSON-LD in the head. |
|
| 1139 | + new Jsonld_Adapter( $that->jsonld_service ); |
|
| 1140 | + |
|
| 1141 | + new Jsonld_By_Id_Endpoint( $that->jsonld_service, $that->entity_uri_service ); |
|
| 1142 | + |
|
| 1143 | + $that->key_validation_service = new Wordlift_Key_Validation_Service(); |
|
| 1144 | + $that->content_filter_service = Wordlift_Content_Filter_Service::get_instance(); |
|
| 1145 | + // Creating Faq Content filter service. |
|
| 1146 | + $that->faq_content_filter_service = new Faq_Content_Filter(); |
|
| 1147 | + $that->sample_data_service = Wordlift_Sample_Data_Service::get_instance(); |
|
| 1148 | + $that->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $that->sample_data_service ); |
|
| 1149 | + |
|
| 1150 | + $that->loader->add_action( 'enqueue_block_editor_assets', $that, 'add_wl_enabled_blocks' ); |
|
| 1151 | + $that->loader->add_action( 'admin_enqueue_scripts', $that, 'add_wl_enabled_blocks' ); |
|
| 1152 | + |
|
| 1153 | + /** |
|
| 1154 | + * Filter: wl_feature__enable__blocks. |
|
| 1155 | + * |
|
| 1156 | + * @param bool whether the blocks needed to be registered, defaults to true. |
|
| 1157 | + * |
|
| 1158 | + * @return bool |
|
| 1159 | + * @since 3.27.6 |
|
| 1160 | + */ |
|
| 1161 | + if ( apply_filters( 'wl_feature__enable__blocks', true ) ) { |
|
| 1162 | + // Initialize the short-codes. |
|
| 1163 | + new Async_Template_Decorator( new Wordlift_Navigator_Shortcode() ); |
|
| 1164 | + new Wordlift_Chord_Shortcode(); |
|
| 1165 | + new Wordlift_Geomap_Shortcode(); |
|
| 1166 | + new Wordlift_Timeline_Shortcode(); |
|
| 1167 | + new Wordlift_Related_Entities_Cloud_Shortcode( Wordlift_Relation_Service::get_instance(), Wordlift_Entity_Service::get_instance() ); |
|
| 1168 | + new Wordlift_Vocabulary_Shortcode(); |
|
| 1169 | + new Async_Template_Decorator( new Wordlift_Faceted_Search_Shortcode() ); |
|
| 1170 | + } |
|
| 1171 | + |
|
| 1172 | + new Wordlift_Products_Navigator_Shortcode(); |
|
| 1173 | + |
|
| 1174 | + |
|
| 1175 | + // Initialize the Context Cards Service |
|
| 1176 | + $that->context_cards_service = new Wordlift_Context_Cards_Service(); |
|
| 1177 | + |
|
| 1178 | + // Initialize the SEO service. |
|
| 1179 | + new Wordlift_Seo_Service(); |
|
| 1180 | + |
|
| 1181 | + // Initialize the AMP service. |
|
| 1182 | + new Wordlift_AMP_Service( $that->jsonld_service ); |
|
| 1183 | + |
|
| 1184 | + /** Services. */ |
|
| 1185 | + $that->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service(); |
|
| 1186 | + new Wordlift_Image_Service(); |
|
| 1187 | + |
|
| 1188 | + /** Adapters. */ |
|
| 1189 | + $that->entity_type_adapter = new Wordlift_Entity_Type_Adapter( Wordlift_Entity_Type_Service::get_instance() ); |
|
| 1190 | + $that->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $that->publisher_service ); |
|
| 1191 | + $that->tinymce_adapter = new Wordlift_Tinymce_Adapter( $that ); |
|
| 1192 | + |
|
| 1193 | + /* |
|
| 1194 | 1194 | * Exclude our public js from WP-Rocket. |
| 1195 | 1195 | * |
| 1196 | 1196 | * @since 3.19.4 |
| 1197 | 1197 | * |
| 1198 | 1198 | * @see https://github.com/insideout10/wordlift-plugin/issues/842. |
| 1199 | 1199 | */ |
| 1200 | - new Wordlift_WpRocket_Adapter(); |
|
| 1200 | + new Wordlift_WpRocket_Adapter(); |
|
| 1201 | 1201 | |
| 1202 | - /** WordPress Admin UI. */ |
|
| 1202 | + /** WordPress Admin UI. */ |
|
| 1203 | 1203 | |
| 1204 | - // UI elements. |
|
| 1205 | - $that->input_element = new Wordlift_Admin_Input_Element(); |
|
| 1206 | - $that->radio_input_element = new Wordlift_Admin_Radio_Input_Element(); |
|
| 1207 | - $that->select2_element = new Wordlift_Admin_Select2_Element(); |
|
| 1208 | - $that->language_select_element = new Wordlift_Admin_Language_Select_Element(); |
|
| 1209 | - $that->country_select_element = new Wordlift_Admin_Country_Select_Element(); |
|
| 1210 | - $tabs_element = new Wordlift_Admin_Tabs_Element(); |
|
| 1211 | - $that->publisher_element = new Wordlift_Admin_Publisher_Element( $that->publisher_service, $tabs_element, $that->select2_element ); |
|
| 1212 | - $that->author_element = new Wordlift_Admin_Author_Element( $that->publisher_service, $that->select2_element ); |
|
| 1204 | + // UI elements. |
|
| 1205 | + $that->input_element = new Wordlift_Admin_Input_Element(); |
|
| 1206 | + $that->radio_input_element = new Wordlift_Admin_Radio_Input_Element(); |
|
| 1207 | + $that->select2_element = new Wordlift_Admin_Select2_Element(); |
|
| 1208 | + $that->language_select_element = new Wordlift_Admin_Language_Select_Element(); |
|
| 1209 | + $that->country_select_element = new Wordlift_Admin_Country_Select_Element(); |
|
| 1210 | + $tabs_element = new Wordlift_Admin_Tabs_Element(); |
|
| 1211 | + $that->publisher_element = new Wordlift_Admin_Publisher_Element( $that->publisher_service, $tabs_element, $that->select2_element ); |
|
| 1212 | + $that->author_element = new Wordlift_Admin_Author_Element( $that->publisher_service, $that->select2_element ); |
|
| 1213 | 1213 | |
| 1214 | - $that->settings_page = Wordlift_Admin_Settings_Page::get_instance(); |
|
| 1215 | - $that->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $that->settings_page ); |
|
| 1214 | + $that->settings_page = Wordlift_Admin_Settings_Page::get_instance(); |
|
| 1215 | + $that->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $that->settings_page ); |
|
| 1216 | 1216 | |
| 1217 | - $that->analytics_settings_page = new Wordlift_Admin_Settings_Analytics_Page( $that->input_element, $that->radio_input_element ); |
|
| 1218 | - $that->analytics_settings_page_action_link = new Wordlift_Admin_Settings_Analytics_Page_Action_Link( $that->analytics_settings_page ); |
|
| 1219 | - $that->analytics_connect = new Wordlift_Analytics_Connect(); |
|
| 1217 | + $that->analytics_settings_page = new Wordlift_Admin_Settings_Analytics_Page( $that->input_element, $that->radio_input_element ); |
|
| 1218 | + $that->analytics_settings_page_action_link = new Wordlift_Admin_Settings_Analytics_Page_Action_Link( $that->analytics_settings_page ); |
|
| 1219 | + $that->analytics_connect = new Wordlift_Analytics_Connect(); |
|
| 1220 | 1220 | |
| 1221 | - // Pages. |
|
| 1222 | - /* |
|
| 1221 | + // Pages. |
|
| 1222 | + /* |
|
| 1223 | 1223 | * Call the `wl_can_see_classification_box` filter to determine whether we can display the classification box. |
| 1224 | 1224 | * |
| 1225 | 1225 | * @since 3.20.3 |
| 1226 | 1226 | * |
| 1227 | 1227 | * @see https://github.com/insideout10/wordlift-plugin/issues/914 |
| 1228 | 1228 | */ |
| 1229 | - if ( apply_filters( 'wl_can_see_classification_box', true ) ) { |
|
| 1230 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 1231 | - new Wordlift_Admin_Post_Edit_Page( $that ); |
|
| 1232 | - } |
|
| 1233 | - new Wordlift_Entity_Type_Admin_Service(); |
|
| 1229 | + if ( apply_filters( 'wl_can_see_classification_box', true ) ) { |
|
| 1230 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 1231 | + new Wordlift_Admin_Post_Edit_Page( $that ); |
|
| 1232 | + } |
|
| 1233 | + new Wordlift_Entity_Type_Admin_Service(); |
|
| 1234 | 1234 | |
| 1235 | - /** Widgets */ |
|
| 1236 | - $that->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget(); |
|
| 1235 | + /** Widgets */ |
|
| 1236 | + $that->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget(); |
|
| 1237 | 1237 | |
| 1238 | - // Create an instance of the install wizard. |
|
| 1239 | - $that->admin_setup = new Wordlift_Admin_Setup( $that->key_validation_service, Wordlift_Entity_Service::get_instance(), $that->language_select_element, $that->country_select_element ); |
|
| 1238 | + // Create an instance of the install wizard. |
|
| 1239 | + $that->admin_setup = new Wordlift_Admin_Setup( $that->key_validation_service, Wordlift_Entity_Service::get_instance(), $that->language_select_element, $that->country_select_element ); |
|
| 1240 | 1240 | |
| 1241 | - $that->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $that->entity_post_type_service ); |
|
| 1241 | + $that->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $that->entity_post_type_service ); |
|
| 1242 | 1242 | |
| 1243 | - // User Profile. |
|
| 1244 | - new Wordlift_Admin_User_Profile_Page( $that->author_element, $that->user_service ); |
|
| 1243 | + // User Profile. |
|
| 1244 | + new Wordlift_Admin_User_Profile_Page( $that->author_element, $that->user_service ); |
|
| 1245 | 1245 | |
| 1246 | - $that->entity_page_service = new Wordlift_Entity_Page_Service(); |
|
| 1246 | + $that->entity_page_service = new Wordlift_Entity_Page_Service(); |
|
| 1247 | 1247 | |
| 1248 | - // Load the debug service if WP is in debug mode. |
|
| 1249 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 1250 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 1251 | - new Wordlift_Debug_Service( Wordlift_Entity_Service::get_instance(), $uri_service ); |
|
| 1252 | - } |
|
| 1248 | + // Load the debug service if WP is in debug mode. |
|
| 1249 | + if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 1250 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 1251 | + new Wordlift_Debug_Service( Wordlift_Entity_Service::get_instance(), $uri_service ); |
|
| 1252 | + } |
|
| 1253 | 1253 | |
| 1254 | - // Remote Image Service. |
|
| 1255 | - new Wordlift_Remote_Image_Service(); |
|
| 1254 | + // Remote Image Service. |
|
| 1255 | + new Wordlift_Remote_Image_Service(); |
|
| 1256 | 1256 | |
| 1257 | - /* |
|
| 1257 | + /* |
|
| 1258 | 1258 | * Provides mappings between post types and entity types. |
| 1259 | 1259 | * |
| 1260 | 1260 | * @since 3.20.0 |
| 1261 | 1261 | * |
| 1262 | 1262 | * @see https://github.com/insideout10/wordlift-plugin/issues/852. |
| 1263 | 1263 | */ |
| 1264 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-action.php'; |
|
| 1265 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-service.php'; |
|
| 1266 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-ajax-adapter.php'; |
|
| 1264 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-action.php'; |
|
| 1265 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-service.php'; |
|
| 1266 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-ajax-adapter.php'; |
|
| 1267 | 1267 | |
| 1268 | - // Create an instance of the Mapping Service and assign it to the Ajax Adapter. |
|
| 1269 | - new Wordlift_Mapping_Ajax_Adapter( new Wordlift_Mapping_Service( Wordlift_Entity_Type_Service::get_instance() ) ); |
|
| 1268 | + // Create an instance of the Mapping Service and assign it to the Ajax Adapter. |
|
| 1269 | + new Wordlift_Mapping_Ajax_Adapter( new Wordlift_Mapping_Service( Wordlift_Entity_Type_Service::get_instance() ) ); |
|
| 1270 | 1270 | |
| 1271 | - /* |
|
| 1271 | + /* |
|
| 1272 | 1272 | * Load the Mappings JSON-LD post processing. |
| 1273 | 1273 | * |
| 1274 | 1274 | * @since 3.25.0 |
| 1275 | 1275 | */ |
| 1276 | 1276 | |
| 1277 | - $mappings_dbo = new Mappings_DBO(); |
|
| 1278 | - $default_rule_validator = new Taxonomy_Rule_Validator(); |
|
| 1279 | - new Post_Type_Rule_Validator(); |
|
| 1280 | - // Taxonomy term rule validator for validating rules for term pages. |
|
| 1281 | - new Taxonomy_Term_Rule_Validator(); |
|
| 1282 | - new Post_Taxonomy_Term_Rule_Validator(); |
|
| 1283 | - $rule_validators_registry = new Rule_Validators_Registry( $default_rule_validator ); |
|
| 1284 | - $rule_groups_validator = new Rule_Groups_Validator( $rule_validators_registry ); |
|
| 1285 | - $mappings_validator = new Mappings_Validator( $mappings_dbo, $rule_groups_validator ); |
|
| 1286 | - |
|
| 1287 | - new Url_To_Entity_Transform_Function( $that->entity_uri_service ); |
|
| 1288 | - new Taxonomy_To_Terms_Transform_Function(); |
|
| 1289 | - new Post_Id_To_Entity_Transform_Function(); |
|
| 1290 | - $mappings_transform_functions_registry = new Mappings_Transform_Functions_Registry(); |
|
| 1291 | - |
|
| 1292 | - /** |
|
| 1293 | - * @since 3.27.1 |
|
| 1294 | - * Intiailize the acf group data formatter. |
|
| 1295 | - */ |
|
| 1296 | - new Acf_Group_Formatter(); |
|
| 1297 | - new Jsonld_Converter( $mappings_validator, $mappings_transform_functions_registry ); |
|
| 1298 | - |
|
| 1299 | - /** |
|
| 1300 | - * @since 3.26.0 |
|
| 1301 | - * Initialize the Faq JSON LD converter here - disabled. |
|
| 1302 | - */ |
|
| 1303 | - // new Faq_To_Jsonld_Converter(); |
|
| 1304 | - /* |
|
| 1277 | + $mappings_dbo = new Mappings_DBO(); |
|
| 1278 | + $default_rule_validator = new Taxonomy_Rule_Validator(); |
|
| 1279 | + new Post_Type_Rule_Validator(); |
|
| 1280 | + // Taxonomy term rule validator for validating rules for term pages. |
|
| 1281 | + new Taxonomy_Term_Rule_Validator(); |
|
| 1282 | + new Post_Taxonomy_Term_Rule_Validator(); |
|
| 1283 | + $rule_validators_registry = new Rule_Validators_Registry( $default_rule_validator ); |
|
| 1284 | + $rule_groups_validator = new Rule_Groups_Validator( $rule_validators_registry ); |
|
| 1285 | + $mappings_validator = new Mappings_Validator( $mappings_dbo, $rule_groups_validator ); |
|
| 1286 | + |
|
| 1287 | + new Url_To_Entity_Transform_Function( $that->entity_uri_service ); |
|
| 1288 | + new Taxonomy_To_Terms_Transform_Function(); |
|
| 1289 | + new Post_Id_To_Entity_Transform_Function(); |
|
| 1290 | + $mappings_transform_functions_registry = new Mappings_Transform_Functions_Registry(); |
|
| 1291 | + |
|
| 1292 | + /** |
|
| 1293 | + * @since 3.27.1 |
|
| 1294 | + * Intiailize the acf group data formatter. |
|
| 1295 | + */ |
|
| 1296 | + new Acf_Group_Formatter(); |
|
| 1297 | + new Jsonld_Converter( $mappings_validator, $mappings_transform_functions_registry ); |
|
| 1298 | + |
|
| 1299 | + /** |
|
| 1300 | + * @since 3.26.0 |
|
| 1301 | + * Initialize the Faq JSON LD converter here - disabled. |
|
| 1302 | + */ |
|
| 1303 | + // new Faq_To_Jsonld_Converter(); |
|
| 1304 | + /* |
|
| 1305 | 1305 | * Use the Templates Ajax Endpoint to load HTML templates for the legacy Angular app via admin-ajax.php |
| 1306 | 1306 | * end-point. |
| 1307 | 1307 | * |
| 1308 | 1308 | * @see https://github.com/insideout10/wordlift-plugin/issues/834 |
| 1309 | 1309 | * @since 3.24.4 |
| 1310 | 1310 | */ |
| 1311 | - new Templates_Ajax_Endpoint(); |
|
| 1312 | - // Call this static method to register FAQ routes to rest api - disabled |
|
| 1313 | - //Faq_Rest_Controller::register_routes(); |
|
| 1314 | - |
|
| 1315 | - $that->storage_factory = new Wordlift_Storage_Factory( Wordlift_Entity_Service::get_instance(), $that->user_service, $property_getter ); |
|
| 1316 | - |
|
| 1317 | - /** WL Autocomplete. */ |
|
| 1318 | - $autocomplete_service = new All_Autocomplete_Service( array( |
|
| 1319 | - new Local_Autocomplete_Service(), |
|
| 1320 | - new Linked_Data_Autocomplete_Service( Entity_Helper::get_instance(), $that->entity_uri_service, Wordlift_Entity_Service::get_instance() ), |
|
| 1321 | - ) ); |
|
| 1322 | - $that->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $autocomplete_service ); |
|
| 1323 | - |
|
| 1324 | - /** |
|
| 1325 | - * @since 3.27.2 |
|
| 1326 | - * Integrate the recipe maker jsonld & set recipe |
|
| 1327 | - * as default entity type to the wprm_recipe CPT. |
|
| 1328 | - */ |
|
| 1329 | - new Recipe_Maker_Post_Type_Hook(); |
|
| 1330 | - $recipe_maker_validation_service = new Recipe_Maker_Validation_Service(); |
|
| 1331 | - new Recipe_Maker_Jsonld_Hook( $attachment_service, $recipe_maker_validation_service ); |
|
| 1332 | - new Recipe_Maker_After_Get_Jsonld_Hook( $recipe_maker_validation_service ); |
|
| 1333 | - new Recipe_Maker_Jsonld_Swap( $recipe_maker_validation_service, $that->jsonld_service ); |
|
| 1334 | - new Recipe_Maker_Warning( $recipe_maker_validation_service ); |
|
| 1335 | - |
|
| 1336 | - |
|
| 1337 | - new Duplicate_Markup_Remover(); |
|
| 1338 | - |
|
| 1339 | - /** |
|
| 1340 | - * @since 3.27.8 |
|
| 1341 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1248 |
|
| 1342 | - */ |
|
| 1343 | - new Key_Validation_Notice( $that->key_validation_service, Wordlift_Configuration_Service::get_instance() ); |
|
| 1344 | - /** |
|
| 1345 | - * @since 3.28.0 |
|
| 1346 | - * @see https://github.com/insideout10/wordlift-plugin/issues?q=assignee%3Anaveen17797+is%3Aopen |
|
| 1347 | - */ |
|
| 1348 | - new Entity_No_Index_Flag(); |
|
| 1349 | - |
|
| 1350 | - /** |
|
| 1351 | - * @since 3.29.0 |
|
| 1352 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1304 |
|
| 1353 | - */ |
|
| 1354 | - new Entity_Rest_Service( Wordlift_Entity_Type_Service::get_instance() ); |
|
| 1355 | - |
|
| 1356 | - /** |
|
| 1357 | - * Expand author in to references. |
|
| 1358 | - * @since 3.30.0 |
|
| 1359 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1318 |
|
| 1360 | - */ |
|
| 1361 | - |
|
| 1362 | - |
|
| 1363 | - if ( apply_filters( 'wl_feature__enable__article-wrapper', false ) ) { |
|
| 1364 | - new Jsonld_Article_Wrapper( Wordlift_Post_To_Jsonld_Converter::get_instance(), $that->cached_postid_to_jsonld_converter ); |
|
| 1365 | - } |
|
| 1366 | - |
|
| 1367 | - |
|
| 1368 | - if ( apply_filters( 'wl_feature__enable__match-terms', false ) ) { |
|
| 1369 | - $vocabulary_loader = new Vocabulary_Loader(); |
|
| 1370 | - $vocabulary_loader->init_vocabulary(); |
|
| 1371 | - } |
|
| 1372 | - |
|
| 1373 | - /** |
|
| 1374 | - *Added for feature request 1496 (Webhooks) |
|
| 1375 | - */ |
|
| 1376 | - if ( apply_filters( 'wl_feature__enable__webhooks', false ) ) { |
|
| 1377 | - $that->webhook_loader = new Webhooks_Loader(); |
|
| 1378 | - $that->webhook_loader->init(); |
|
| 1379 | - } |
|
| 1380 | - |
|
| 1381 | - /** |
|
| 1382 | - * @since 3.30.0 |
|
| 1383 | - * Add a checkbox to user option screen for wordlift admin. |
|
| 1384 | - */ |
|
| 1385 | - $wordlift_admin_checkbox = new Admin_User_Option(); |
|
| 1386 | - $wordlift_admin_checkbox->connect_hook(); |
|
| 1387 | - |
|
| 1388 | - /** |
|
| 1389 | - * @since 3.31.0 |
|
| 1390 | - * Init loader class for videoobject. |
|
| 1391 | - */ |
|
| 1392 | - $videoobject_loader = new Loader(); |
|
| 1393 | - $videoobject_loader->init_feature(); |
|
| 1394 | - |
|
| 1395 | - /** |
|
| 1396 | - * @since 3.35.0 |
|
| 1397 | - */ |
|
| 1398 | - $google_addon_integration_loader = new \Wordlift\Google_Addon_Integration\Loader(); |
|
| 1399 | - $google_addon_integration_loader->init_feature(); |
|
| 1400 | - |
|
| 1401 | - /** |
|
| 1402 | - * @since 3.31.5 |
|
| 1403 | - * Create configuration endpoint for webapp to configure. |
|
| 1404 | - */ |
|
| 1405 | - new Config( $that->admin_setup, $that->key_validation_service ); |
|
| 1406 | - /** |
|
| 1407 | - * @since 3.31.7 |
|
| 1408 | - * Remove duplicate videoobject. |
|
| 1409 | - */ |
|
| 1410 | - new Videoobject_Duplicate_Remover(); |
|
| 1411 | - $synonym_loader = new \Wordlift\Synonym\Loader(); |
|
| 1412 | - $synonym_loader->init_feature(); |
|
| 1413 | - /** |
|
| 1414 | - * @since 3.32.0 |
|
| 1415 | - * Create loader for vocabulary terms. |
|
| 1416 | - */ |
|
| 1417 | - $vocabulary_terms_loader = new Vocabulary_Terms_Loader( Wordlift_Entity_Type_Service::get_instance(), $property_getter ); |
|
| 1418 | - $vocabulary_terms_loader->init_feature(); |
|
| 1419 | - |
|
| 1420 | - new Entity_Type_Change_Handler( |
|
| 1421 | - Wordlift_Entity_Service::get_instance(), |
|
| 1422 | - Wordlift_Entity_Type_Service::get_instance() |
|
| 1423 | - ); |
|
| 1424 | - |
|
| 1425 | - }, 3 ); |
|
| 1426 | - |
|
| 1427 | - |
|
| 1428 | - new Entity_Type_Setter(); |
|
| 1429 | - $no_editor_analysis_loader = new \Wordlift\No_Editor_Analysis\Loader(); |
|
| 1430 | - $no_editor_analysis_loader->init_feature(); |
|
| 1431 | - } |
|
| 1432 | - |
|
| 1433 | - /** |
|
| 1434 | - * Define the locale for this plugin for internationalization. |
|
| 1435 | - * |
|
| 1436 | - * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 1437 | - * with WordPress. |
|
| 1438 | - * |
|
| 1439 | - * @since 1.0.0 |
|
| 1440 | - * @access private |
|
| 1441 | - */ |
|
| 1442 | - private function set_locale() { |
|
| 1443 | - |
|
| 1444 | - $plugin_i18n = new Wordlift_i18n(); |
|
| 1445 | - $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 1446 | - |
|
| 1447 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 1448 | - |
|
| 1449 | - } |
|
| 1450 | - |
|
| 1451 | - /** |
|
| 1452 | - * Register all of the hooks related to the admin area functionality |
|
| 1453 | - * of the plugin. |
|
| 1454 | - * |
|
| 1455 | - * @since 1.0.0 |
|
| 1456 | - * @access private |
|
| 1457 | - */ |
|
| 1458 | - private function define_admin_hooks( $that ) { |
|
| 1459 | - $plugin_admin = new |
|
| 1460 | - Wordlift_Admin( |
|
| 1461 | - $that->get_plugin_name(), |
|
| 1462 | - $that->get_version(), |
|
| 1463 | - $that->notice_service, |
|
| 1464 | - $that->user_service |
|
| 1465 | - ); |
|
| 1466 | - |
|
| 1467 | - $that->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 1468 | - $that->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts', 11 ); |
|
| 1469 | - |
|
| 1470 | - // Hook the `admin_init` function to the Admin Setup. |
|
| 1471 | - Assertions::is_set( $that->admin_setup, '`admin_setup` must be set' ); |
|
| 1472 | - $that->loader->add_action( 'admin_init', $that->admin_setup, 'admin_init' ); |
|
| 1473 | - |
|
| 1474 | - // Hook the admin_init to the settings page. |
|
| 1475 | - Assertions::is_set( $that->settings_page, '`setting_page` must be set' ); |
|
| 1476 | - $that->loader->add_action( 'admin_init', $that->settings_page, 'admin_init' ); |
|
| 1477 | - |
|
| 1478 | - // Hook the admin_init to the analytics settings page. |
|
| 1479 | - Assertions::is_set( $that->analytics_settings_page, '`analytics_setting_page` must be set' ); |
|
| 1480 | - $that->loader->add_action( 'admin_init', $that->analytics_settings_page, 'admin_init' ); |
|
| 1481 | - |
|
| 1482 | - // Hook the init action to taxonomy services. |
|
| 1483 | - $that->loader->add_action( 'init', $that->topic_taxonomy_service, 'init', 0 ); |
|
| 1484 | - $that->loader->add_action( 'init', $that->entity_types_taxonomy_service, 'init', 0 ); |
|
| 1485 | - |
|
| 1486 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1487 | - $that->loader->add_action( 'wp_ajax_wl_timeline', $that->timeline_service, 'ajax_timeline' ); |
|
| 1488 | - |
|
| 1489 | - // Register custom allowed redirect hosts. |
|
| 1490 | - $that->loader->add_filter( 'allowed_redirect_hosts', $that->redirect_service, 'allowed_redirect_hosts' ); |
|
| 1491 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1492 | - $that->loader->add_action( 'wp_ajax_wordlift_redirect', $that->redirect_service, 'ajax_redirect' ); |
|
| 1493 | - |
|
| 1494 | - // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 1495 | - // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 1496 | - $that->loader->add_action( 'save_post', Wordlift_Entity_Service::get_instance(), 'save_post', 9, 3 ); |
|
| 1497 | - $that->loader->add_action( 'save_post', $that->rating_service, 'set_rating_for', 20, 1 ); |
|
| 1498 | - |
|
| 1499 | - $that->loader->add_action( 'edit_form_before_permalink', Wordlift_Entity_Service::get_instance(), 'edit_form_before_permalink', 10, 1 ); |
|
| 1500 | - $that->loader->add_action( 'in_admin_header', $that->rating_service, 'in_admin_header' ); |
|
| 1501 | - |
|
| 1502 | - // Entity listing customization (wp-admin/edit.php) |
|
| 1503 | - // Add custom columns. |
|
| 1504 | - $that->loader->add_filter( 'manage_entity_posts_columns', $that->entity_list_service, 'register_custom_columns' ); |
|
| 1505 | - // no explicit entity as it prevents handling of other post types. |
|
| 1506 | - $that->loader->add_filter( 'manage_posts_custom_column', $that->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 1507 | - // Add 4W selection. |
|
| 1508 | - $that->loader->add_action( 'restrict_manage_posts', $that->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 1509 | - $that->loader->add_filter( 'posts_clauses', $that->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 1510 | - $that->loader->add_action( 'pre_get_posts', $that->entity_list_service, 'pre_get_posts' ); |
|
| 1511 | - $that->loader->add_action( 'load-edit.php', $that->entity_list_service, 'load_edit' ); |
|
| 1512 | - |
|
| 1513 | - /* |
|
| 1311 | + new Templates_Ajax_Endpoint(); |
|
| 1312 | + // Call this static method to register FAQ routes to rest api - disabled |
|
| 1313 | + //Faq_Rest_Controller::register_routes(); |
|
| 1314 | + |
|
| 1315 | + $that->storage_factory = new Wordlift_Storage_Factory( Wordlift_Entity_Service::get_instance(), $that->user_service, $property_getter ); |
|
| 1316 | + |
|
| 1317 | + /** WL Autocomplete. */ |
|
| 1318 | + $autocomplete_service = new All_Autocomplete_Service( array( |
|
| 1319 | + new Local_Autocomplete_Service(), |
|
| 1320 | + new Linked_Data_Autocomplete_Service( Entity_Helper::get_instance(), $that->entity_uri_service, Wordlift_Entity_Service::get_instance() ), |
|
| 1321 | + ) ); |
|
| 1322 | + $that->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $autocomplete_service ); |
|
| 1323 | + |
|
| 1324 | + /** |
|
| 1325 | + * @since 3.27.2 |
|
| 1326 | + * Integrate the recipe maker jsonld & set recipe |
|
| 1327 | + * as default entity type to the wprm_recipe CPT. |
|
| 1328 | + */ |
|
| 1329 | + new Recipe_Maker_Post_Type_Hook(); |
|
| 1330 | + $recipe_maker_validation_service = new Recipe_Maker_Validation_Service(); |
|
| 1331 | + new Recipe_Maker_Jsonld_Hook( $attachment_service, $recipe_maker_validation_service ); |
|
| 1332 | + new Recipe_Maker_After_Get_Jsonld_Hook( $recipe_maker_validation_service ); |
|
| 1333 | + new Recipe_Maker_Jsonld_Swap( $recipe_maker_validation_service, $that->jsonld_service ); |
|
| 1334 | + new Recipe_Maker_Warning( $recipe_maker_validation_service ); |
|
| 1335 | + |
|
| 1336 | + |
|
| 1337 | + new Duplicate_Markup_Remover(); |
|
| 1338 | + |
|
| 1339 | + /** |
|
| 1340 | + * @since 3.27.8 |
|
| 1341 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1248 |
|
| 1342 | + */ |
|
| 1343 | + new Key_Validation_Notice( $that->key_validation_service, Wordlift_Configuration_Service::get_instance() ); |
|
| 1344 | + /** |
|
| 1345 | + * @since 3.28.0 |
|
| 1346 | + * @see https://github.com/insideout10/wordlift-plugin/issues?q=assignee%3Anaveen17797+is%3Aopen |
|
| 1347 | + */ |
|
| 1348 | + new Entity_No_Index_Flag(); |
|
| 1349 | + |
|
| 1350 | + /** |
|
| 1351 | + * @since 3.29.0 |
|
| 1352 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1304 |
|
| 1353 | + */ |
|
| 1354 | + new Entity_Rest_Service( Wordlift_Entity_Type_Service::get_instance() ); |
|
| 1355 | + |
|
| 1356 | + /** |
|
| 1357 | + * Expand author in to references. |
|
| 1358 | + * @since 3.30.0 |
|
| 1359 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1318 |
|
| 1360 | + */ |
|
| 1361 | + |
|
| 1362 | + |
|
| 1363 | + if ( apply_filters( 'wl_feature__enable__article-wrapper', false ) ) { |
|
| 1364 | + new Jsonld_Article_Wrapper( Wordlift_Post_To_Jsonld_Converter::get_instance(), $that->cached_postid_to_jsonld_converter ); |
|
| 1365 | + } |
|
| 1366 | + |
|
| 1367 | + |
|
| 1368 | + if ( apply_filters( 'wl_feature__enable__match-terms', false ) ) { |
|
| 1369 | + $vocabulary_loader = new Vocabulary_Loader(); |
|
| 1370 | + $vocabulary_loader->init_vocabulary(); |
|
| 1371 | + } |
|
| 1372 | + |
|
| 1373 | + /** |
|
| 1374 | + *Added for feature request 1496 (Webhooks) |
|
| 1375 | + */ |
|
| 1376 | + if ( apply_filters( 'wl_feature__enable__webhooks', false ) ) { |
|
| 1377 | + $that->webhook_loader = new Webhooks_Loader(); |
|
| 1378 | + $that->webhook_loader->init(); |
|
| 1379 | + } |
|
| 1380 | + |
|
| 1381 | + /** |
|
| 1382 | + * @since 3.30.0 |
|
| 1383 | + * Add a checkbox to user option screen for wordlift admin. |
|
| 1384 | + */ |
|
| 1385 | + $wordlift_admin_checkbox = new Admin_User_Option(); |
|
| 1386 | + $wordlift_admin_checkbox->connect_hook(); |
|
| 1387 | + |
|
| 1388 | + /** |
|
| 1389 | + * @since 3.31.0 |
|
| 1390 | + * Init loader class for videoobject. |
|
| 1391 | + */ |
|
| 1392 | + $videoobject_loader = new Loader(); |
|
| 1393 | + $videoobject_loader->init_feature(); |
|
| 1394 | + |
|
| 1395 | + /** |
|
| 1396 | + * @since 3.35.0 |
|
| 1397 | + */ |
|
| 1398 | + $google_addon_integration_loader = new \Wordlift\Google_Addon_Integration\Loader(); |
|
| 1399 | + $google_addon_integration_loader->init_feature(); |
|
| 1400 | + |
|
| 1401 | + /** |
|
| 1402 | + * @since 3.31.5 |
|
| 1403 | + * Create configuration endpoint for webapp to configure. |
|
| 1404 | + */ |
|
| 1405 | + new Config( $that->admin_setup, $that->key_validation_service ); |
|
| 1406 | + /** |
|
| 1407 | + * @since 3.31.7 |
|
| 1408 | + * Remove duplicate videoobject. |
|
| 1409 | + */ |
|
| 1410 | + new Videoobject_Duplicate_Remover(); |
|
| 1411 | + $synonym_loader = new \Wordlift\Synonym\Loader(); |
|
| 1412 | + $synonym_loader->init_feature(); |
|
| 1413 | + /** |
|
| 1414 | + * @since 3.32.0 |
|
| 1415 | + * Create loader for vocabulary terms. |
|
| 1416 | + */ |
|
| 1417 | + $vocabulary_terms_loader = new Vocabulary_Terms_Loader( Wordlift_Entity_Type_Service::get_instance(), $property_getter ); |
|
| 1418 | + $vocabulary_terms_loader->init_feature(); |
|
| 1419 | + |
|
| 1420 | + new Entity_Type_Change_Handler( |
|
| 1421 | + Wordlift_Entity_Service::get_instance(), |
|
| 1422 | + Wordlift_Entity_Type_Service::get_instance() |
|
| 1423 | + ); |
|
| 1424 | + |
|
| 1425 | + }, 3 ); |
|
| 1426 | + |
|
| 1427 | + |
|
| 1428 | + new Entity_Type_Setter(); |
|
| 1429 | + $no_editor_analysis_loader = new \Wordlift\No_Editor_Analysis\Loader(); |
|
| 1430 | + $no_editor_analysis_loader->init_feature(); |
|
| 1431 | + } |
|
| 1432 | + |
|
| 1433 | + /** |
|
| 1434 | + * Define the locale for this plugin for internationalization. |
|
| 1435 | + * |
|
| 1436 | + * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 1437 | + * with WordPress. |
|
| 1438 | + * |
|
| 1439 | + * @since 1.0.0 |
|
| 1440 | + * @access private |
|
| 1441 | + */ |
|
| 1442 | + private function set_locale() { |
|
| 1443 | + |
|
| 1444 | + $plugin_i18n = new Wordlift_i18n(); |
|
| 1445 | + $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 1446 | + |
|
| 1447 | + $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 1448 | + |
|
| 1449 | + } |
|
| 1450 | + |
|
| 1451 | + /** |
|
| 1452 | + * Register all of the hooks related to the admin area functionality |
|
| 1453 | + * of the plugin. |
|
| 1454 | + * |
|
| 1455 | + * @since 1.0.0 |
|
| 1456 | + * @access private |
|
| 1457 | + */ |
|
| 1458 | + private function define_admin_hooks( $that ) { |
|
| 1459 | + $plugin_admin = new |
|
| 1460 | + Wordlift_Admin( |
|
| 1461 | + $that->get_plugin_name(), |
|
| 1462 | + $that->get_version(), |
|
| 1463 | + $that->notice_service, |
|
| 1464 | + $that->user_service |
|
| 1465 | + ); |
|
| 1466 | + |
|
| 1467 | + $that->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 1468 | + $that->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts', 11 ); |
|
| 1469 | + |
|
| 1470 | + // Hook the `admin_init` function to the Admin Setup. |
|
| 1471 | + Assertions::is_set( $that->admin_setup, '`admin_setup` must be set' ); |
|
| 1472 | + $that->loader->add_action( 'admin_init', $that->admin_setup, 'admin_init' ); |
|
| 1473 | + |
|
| 1474 | + // Hook the admin_init to the settings page. |
|
| 1475 | + Assertions::is_set( $that->settings_page, '`setting_page` must be set' ); |
|
| 1476 | + $that->loader->add_action( 'admin_init', $that->settings_page, 'admin_init' ); |
|
| 1477 | + |
|
| 1478 | + // Hook the admin_init to the analytics settings page. |
|
| 1479 | + Assertions::is_set( $that->analytics_settings_page, '`analytics_setting_page` must be set' ); |
|
| 1480 | + $that->loader->add_action( 'admin_init', $that->analytics_settings_page, 'admin_init' ); |
|
| 1481 | + |
|
| 1482 | + // Hook the init action to taxonomy services. |
|
| 1483 | + $that->loader->add_action( 'init', $that->topic_taxonomy_service, 'init', 0 ); |
|
| 1484 | + $that->loader->add_action( 'init', $that->entity_types_taxonomy_service, 'init', 0 ); |
|
| 1485 | + |
|
| 1486 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1487 | + $that->loader->add_action( 'wp_ajax_wl_timeline', $that->timeline_service, 'ajax_timeline' ); |
|
| 1488 | + |
|
| 1489 | + // Register custom allowed redirect hosts. |
|
| 1490 | + $that->loader->add_filter( 'allowed_redirect_hosts', $that->redirect_service, 'allowed_redirect_hosts' ); |
|
| 1491 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1492 | + $that->loader->add_action( 'wp_ajax_wordlift_redirect', $that->redirect_service, 'ajax_redirect' ); |
|
| 1493 | + |
|
| 1494 | + // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 1495 | + // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 1496 | + $that->loader->add_action( 'save_post', Wordlift_Entity_Service::get_instance(), 'save_post', 9, 3 ); |
|
| 1497 | + $that->loader->add_action( 'save_post', $that->rating_service, 'set_rating_for', 20, 1 ); |
|
| 1498 | + |
|
| 1499 | + $that->loader->add_action( 'edit_form_before_permalink', Wordlift_Entity_Service::get_instance(), 'edit_form_before_permalink', 10, 1 ); |
|
| 1500 | + $that->loader->add_action( 'in_admin_header', $that->rating_service, 'in_admin_header' ); |
|
| 1501 | + |
|
| 1502 | + // Entity listing customization (wp-admin/edit.php) |
|
| 1503 | + // Add custom columns. |
|
| 1504 | + $that->loader->add_filter( 'manage_entity_posts_columns', $that->entity_list_service, 'register_custom_columns' ); |
|
| 1505 | + // no explicit entity as it prevents handling of other post types. |
|
| 1506 | + $that->loader->add_filter( 'manage_posts_custom_column', $that->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 1507 | + // Add 4W selection. |
|
| 1508 | + $that->loader->add_action( 'restrict_manage_posts', $that->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 1509 | + $that->loader->add_filter( 'posts_clauses', $that->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 1510 | + $that->loader->add_action( 'pre_get_posts', $that->entity_list_service, 'pre_get_posts' ); |
|
| 1511 | + $that->loader->add_action( 'load-edit.php', $that->entity_list_service, 'load_edit' ); |
|
| 1512 | + |
|
| 1513 | + /* |
|
| 1514 | 1514 | * If `All Entity Types` is disable, use the radio button Walker. |
| 1515 | 1515 | * |
| 1516 | 1516 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
| 1517 | 1517 | */ |
| 1518 | - if ( ! apply_filters( 'wl_feature__enable__all-entity-types', WL_ALL_ENTITY_TYPES ) ) { |
|
| 1519 | - $that->loader->add_filter( 'wp_terms_checklist_args', $that->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 1520 | - } |
|
| 1521 | - |
|
| 1522 | - // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 1523 | - // entities. |
|
| 1524 | - $that->loader->add_filter( 'prima_metabox_entity_header_args', $that->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 1525 | - |
|
| 1526 | - /** |
|
| 1527 | - * Filter: wl_feature__enable__settings-download. |
|
| 1528 | - * |
|
| 1529 | - * @param bool whether the screens needed to be registered, defaults to true. |
|
| 1530 | - * |
|
| 1531 | - * @return bool |
|
| 1532 | - * @since 3.27.6 |
|
| 1533 | - */ |
|
| 1534 | - $that->features_registry->register_feature_from_slug( 'settings-download', true, array( |
|
| 1535 | - $that, |
|
| 1536 | - 'register_screens' |
|
| 1537 | - ) ); |
|
| 1538 | - |
|
| 1539 | - |
|
| 1540 | - // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
|
| 1541 | - $that->loader->add_action( 'wp_ajax_wl_download_your_data', $that->download_your_data_page, 'download_your_data', 10 ); |
|
| 1542 | - |
|
| 1543 | - // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1544 | - $that->loader->add_action( 'wp_ajax_wl_jsonld', $that->jsonld_service, 'get' ); |
|
| 1545 | - $that->loader->add_action( 'admin_post_wl_jsonld', $that->jsonld_service, 'get' ); |
|
| 1546 | - $that->loader->add_action( 'admin_post_nopriv_wl_jsonld', $that->jsonld_service, 'get' ); |
|
| 1547 | - |
|
| 1548 | - // Hook the AJAX wl_validate_key action to the Key Validation service. |
|
| 1549 | - $that->loader->add_action( 'wp_ajax_wl_validate_key', $that->key_validation_service, 'validate_key' ); |
|
| 1550 | - |
|
| 1551 | - // Hook the AJAX wl_update_country_options action to the countries. |
|
| 1552 | - $that->loader->add_action( 'wp_ajax_wl_update_country_options', $that->country_select_element, 'get_options_html' ); |
|
| 1553 | - |
|
| 1554 | - $that->loader->add_filter( 'admin_post_thumbnail_html', $that->publisher_service, 'add_featured_image_instruction' ); |
|
| 1555 | - |
|
| 1556 | - // Hook the menu creation on the general wordlift menu creation. |
|
| 1557 | - /** |
|
| 1558 | - * Filter: wl_feature__enable__screens. |
|
| 1559 | - * |
|
| 1560 | - * @param bool whether the screens needed to be registered, defaults to true. |
|
| 1561 | - * |
|
| 1562 | - * @return bool |
|
| 1563 | - * @since 3.27.6 |
|
| 1564 | - * |
|
| 1565 | - * Since 3.30.0 this feature is registered using registry. |
|
| 1566 | - */ |
|
| 1567 | - if ( apply_filters( 'wl_feature__enable__settings-screen', true ) || Admin_User_Option::is_wordlift_admin() ) { |
|
| 1568 | - add_action( 'wl_admin_menu', array( $that->settings_page, 'admin_menu' ), 10, 2 ); |
|
| 1569 | - } |
|
| 1570 | - |
|
| 1571 | - // Hook key update. |
|
| 1572 | - $that->loader->add_action( 'pre_update_option_wl_general_settings', Wordlift_Configuration_Service::get_instance(), 'maybe_update_dataset_uri', 10, 2 ); |
|
| 1573 | - $that->loader->add_action( 'update_option_wl_general_settings', Wordlift_Configuration_Service::get_instance(), 'update_key', 10, 2 ); |
|
| 1574 | - |
|
| 1575 | - // Add additional action links to the WordLift plugin in the plugins page. |
|
| 1576 | - $that->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $that->settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1577 | - |
|
| 1578 | - /* |
|
| 1518 | + if ( ! apply_filters( 'wl_feature__enable__all-entity-types', WL_ALL_ENTITY_TYPES ) ) { |
|
| 1519 | + $that->loader->add_filter( 'wp_terms_checklist_args', $that->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 1520 | + } |
|
| 1521 | + |
|
| 1522 | + // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 1523 | + // entities. |
|
| 1524 | + $that->loader->add_filter( 'prima_metabox_entity_header_args', $that->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 1525 | + |
|
| 1526 | + /** |
|
| 1527 | + * Filter: wl_feature__enable__settings-download. |
|
| 1528 | + * |
|
| 1529 | + * @param bool whether the screens needed to be registered, defaults to true. |
|
| 1530 | + * |
|
| 1531 | + * @return bool |
|
| 1532 | + * @since 3.27.6 |
|
| 1533 | + */ |
|
| 1534 | + $that->features_registry->register_feature_from_slug( 'settings-download', true, array( |
|
| 1535 | + $that, |
|
| 1536 | + 'register_screens' |
|
| 1537 | + ) ); |
|
| 1538 | + |
|
| 1539 | + |
|
| 1540 | + // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
|
| 1541 | + $that->loader->add_action( 'wp_ajax_wl_download_your_data', $that->download_your_data_page, 'download_your_data', 10 ); |
|
| 1542 | + |
|
| 1543 | + // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1544 | + $that->loader->add_action( 'wp_ajax_wl_jsonld', $that->jsonld_service, 'get' ); |
|
| 1545 | + $that->loader->add_action( 'admin_post_wl_jsonld', $that->jsonld_service, 'get' ); |
|
| 1546 | + $that->loader->add_action( 'admin_post_nopriv_wl_jsonld', $that->jsonld_service, 'get' ); |
|
| 1547 | + |
|
| 1548 | + // Hook the AJAX wl_validate_key action to the Key Validation service. |
|
| 1549 | + $that->loader->add_action( 'wp_ajax_wl_validate_key', $that->key_validation_service, 'validate_key' ); |
|
| 1550 | + |
|
| 1551 | + // Hook the AJAX wl_update_country_options action to the countries. |
|
| 1552 | + $that->loader->add_action( 'wp_ajax_wl_update_country_options', $that->country_select_element, 'get_options_html' ); |
|
| 1553 | + |
|
| 1554 | + $that->loader->add_filter( 'admin_post_thumbnail_html', $that->publisher_service, 'add_featured_image_instruction' ); |
|
| 1555 | + |
|
| 1556 | + // Hook the menu creation on the general wordlift menu creation. |
|
| 1557 | + /** |
|
| 1558 | + * Filter: wl_feature__enable__screens. |
|
| 1559 | + * |
|
| 1560 | + * @param bool whether the screens needed to be registered, defaults to true. |
|
| 1561 | + * |
|
| 1562 | + * @return bool |
|
| 1563 | + * @since 3.27.6 |
|
| 1564 | + * |
|
| 1565 | + * Since 3.30.0 this feature is registered using registry. |
|
| 1566 | + */ |
|
| 1567 | + if ( apply_filters( 'wl_feature__enable__settings-screen', true ) || Admin_User_Option::is_wordlift_admin() ) { |
|
| 1568 | + add_action( 'wl_admin_menu', array( $that->settings_page, 'admin_menu' ), 10, 2 ); |
|
| 1569 | + } |
|
| 1570 | + |
|
| 1571 | + // Hook key update. |
|
| 1572 | + $that->loader->add_action( 'pre_update_option_wl_general_settings', Wordlift_Configuration_Service::get_instance(), 'maybe_update_dataset_uri', 10, 2 ); |
|
| 1573 | + $that->loader->add_action( 'update_option_wl_general_settings', Wordlift_Configuration_Service::get_instance(), 'update_key', 10, 2 ); |
|
| 1574 | + |
|
| 1575 | + // Add additional action links to the WordLift plugin in the plugins page. |
|
| 1576 | + $that->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $that->settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1577 | + |
|
| 1578 | + /* |
|
| 1579 | 1579 | * Remove the Analytics Settings link from the plugin page. |
| 1580 | 1580 | * |
| 1581 | 1581 | * @see https://github.com/insideout10/wordlift-plugin/issues/932 |
| 1582 | 1582 | * @since 3.21.1 |
| 1583 | 1583 | */ |
| 1584 | - // $that->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $that->analytics_settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1585 | - |
|
| 1586 | - // Hook the AJAX `wl_publisher` action name. |
|
| 1587 | - $that->loader->add_action( 'wp_ajax_wl_publisher', $that->publisher_ajax_adapter, 'publisher' ); |
|
| 1588 | - |
|
| 1589 | - // Hook row actions for the entity type list admin. |
|
| 1590 | - $that->loader->add_filter( 'wl_entity_type_row_actions', $that->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 ); |
|
| 1591 | - |
|
| 1592 | - /** Ajax actions. */ |
|
| 1593 | - $that->loader->add_action( 'wp_ajax_wl_google_analytics_export', $that->google_analytics_export_service, 'export' ); |
|
| 1594 | - |
|
| 1595 | - // Hook capabilities manipulation to allow access to entity type admin |
|
| 1596 | - // page on WordPress versions before 4.7. |
|
| 1597 | - global $wp_version; |
|
| 1598 | - if ( version_compare( $wp_version, '4.7', '<' ) ) { |
|
| 1599 | - $that->loader->add_filter( 'map_meta_cap', $that->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 ); |
|
| 1600 | - } |
|
| 1601 | - |
|
| 1602 | - /** Adapters. */ |
|
| 1603 | - $that->loader->add_filter( 'mce_external_plugins', $that->tinymce_adapter, 'mce_external_plugins', 10, 1 ); |
|
| 1604 | - /** |
|
| 1605 | - * Disabling Faq temporarily. |
|
| 1606 | - * Load the tinymce editor button on the tool bar. |
|
| 1607 | - * @since 3.26.0 |
|
| 1608 | - */ |
|
| 1609 | - //$that->loader->add_filter( 'tiny_mce_before_init', $that->faq_tinymce_adapter, 'register_custom_tags' ); |
|
| 1610 | - //$that->loader->add_filter( 'mce_buttons', $that->faq_tinymce_adapter, 'register_faq_toolbar_button', 10, 1 ); |
|
| 1611 | - //$that->loader->add_filter( 'mce_external_plugins', $that->faq_tinymce_adapter, 'register_faq_tinymce_plugin', 10, 1 ); |
|
| 1612 | - |
|
| 1613 | - |
|
| 1614 | - $that->loader->add_action( 'wp_ajax_wl_sample_data_create', $that->sample_data_ajax_adapter, 'create' ); |
|
| 1615 | - $that->loader->add_action( 'wp_ajax_wl_sample_data_delete', $that->sample_data_ajax_adapter, 'delete' ); |
|
| 1616 | - |
|
| 1617 | - /** |
|
| 1618 | - * @since 3.26.0 |
|
| 1619 | - */ |
|
| 1620 | - $excerpt_adapter = new Post_Excerpt_Meta_Box_Adapter(); |
|
| 1621 | - $that->loader->add_action( 'do_meta_boxes', $excerpt_adapter, 'replace_post_excerpt_meta_box' ); |
|
| 1622 | - // Adding Rest route for the post excerpt |
|
| 1623 | - Post_Excerpt_Rest_Controller::register_routes(); |
|
| 1624 | - |
|
| 1625 | - // Handle the autocomplete request. |
|
| 1626 | - add_action( 'wp_ajax_wl_autocomplete', array( |
|
| 1627 | - $that->autocomplete_adapter, |
|
| 1628 | - 'wl_autocomplete', |
|
| 1629 | - ) ); |
|
| 1630 | - add_action( 'wp_ajax_nopriv_wl_autocomplete', array( |
|
| 1631 | - $that->autocomplete_adapter, |
|
| 1632 | - 'wl_autocomplete', |
|
| 1633 | - ) ); |
|
| 1634 | - |
|
| 1635 | - // Hooks to restrict multisite super admin from manipulating entity types. |
|
| 1636 | - if ( is_multisite() ) { |
|
| 1637 | - $that->loader->add_filter( 'map_meta_cap', $that->entity_type_admin_page, 'restrict_super_admin', 10, 4 ); |
|
| 1638 | - } |
|
| 1639 | - |
|
| 1640 | - $deactivator_feedback = new Wordlift_Deactivator_Feedback(); |
|
| 1641 | - |
|
| 1642 | - add_action( 'admin_footer', array( $deactivator_feedback, 'render_feedback_popup' ) ); |
|
| 1643 | - add_action( 'admin_enqueue_scripts', array( $deactivator_feedback, 'enqueue_popup_scripts' ) ); |
|
| 1644 | - add_action( 'wp_ajax_wl_deactivation_feedback', array( |
|
| 1645 | - $deactivator_feedback, |
|
| 1646 | - 'wl_deactivation_feedback' |
|
| 1647 | - ) ); |
|
| 1648 | - |
|
| 1649 | - /** |
|
| 1650 | - * Always allow the `wordlift/classification` block. |
|
| 1651 | - * |
|
| 1652 | - * @since 3.23.0 |
|
| 1653 | - */ |
|
| 1654 | - add_filter( 'allowed_block_types', function ( $value ) { |
|
| 1655 | - |
|
| 1656 | - if ( true === $value ) { |
|
| 1657 | - return $value; |
|
| 1658 | - } |
|
| 1659 | - |
|
| 1660 | - return array_merge( (array) $value, array( 'wordlift/classification' ) ); |
|
| 1661 | - }, PHP_INT_MAX ); |
|
| 1662 | - |
|
| 1663 | - /** |
|
| 1664 | - * @since 3.27.7 |
|
| 1665 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
| 1666 | - */ |
|
| 1667 | - new Top_Entities(); |
|
| 1668 | - |
|
| 1669 | - } |
|
| 1670 | - |
|
| 1671 | - /** |
|
| 1672 | - * Register all of the hooks related to the public-facing functionality |
|
| 1673 | - * of the plugin. |
|
| 1674 | - * |
|
| 1675 | - * @since 1.0.0 |
|
| 1676 | - * @access private |
|
| 1677 | - */ |
|
| 1678 | - private function define_public_hooks( $that ) { |
|
| 1679 | - |
|
| 1680 | - $plugin_public = new Wordlift_Public( $that->get_plugin_name(), $that->get_version() ); |
|
| 1681 | - |
|
| 1682 | - // Register the entity post type. |
|
| 1683 | - $that->loader->add_action( 'init', $that->entity_post_type_service, 'register' ); |
|
| 1684 | - |
|
| 1685 | - // Bind the link generation and handling hooks to the entity link service. |
|
| 1686 | - $that->loader->add_filter( 'post_type_link', $that->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 1687 | - $that->loader->add_action( 'pre_get_posts', $that->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 ); |
|
| 1688 | - // $that->loader->add_filter( 'wp_unique_post_slug_is_bad_flat_slug', $that->entity_link_service, 'wp_unique_post_slug_is_bad_flat_slug', 10, 3 ); |
|
| 1689 | - // $that->loader->add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', $that->entity_link_service, 'wp_unique_post_slug_is_bad_hierarchical_slug', 10, 4 ); |
|
| 1690 | - |
|
| 1691 | - $that->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 1692 | - $that->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 1693 | - $that->loader->add_action( 'wp_enqueue_scripts', $that->context_cards_service, 'enqueue_scripts' ); |
|
| 1694 | - |
|
| 1695 | - // Registering Faq_Content_Filter service used for removing faq question and answer tags from the html. |
|
| 1696 | - $that->loader->add_filter( 'the_content', $that->faq_content_filter_service, 'remove_all_faq_question_and_answer_tags' ); |
|
| 1697 | - // Hook the content filter service to add entity links. |
|
| 1698 | - if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) { |
|
| 1699 | - // We run before other filters. |
|
| 1700 | - $that->loader->add_filter( 'the_content', $that->content_filter_service, 'the_content', 9 ); |
|
| 1701 | - } |
|
| 1702 | - |
|
| 1703 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1704 | - $that->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $that->timeline_service, 'ajax_timeline' ); |
|
| 1705 | - |
|
| 1706 | - // Hook the ShareThis service. |
|
| 1707 | - $that->loader->add_filter( 'the_content', $that->sharethis_service, 'the_content', 99 ); |
|
| 1708 | - $that->loader->add_filter( 'the_excerpt', $that->sharethis_service, 'the_excerpt', 99 ); |
|
| 1709 | - |
|
| 1710 | - // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1711 | - $that->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $that->jsonld_service, 'get' ); |
|
| 1712 | - |
|
| 1713 | - // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service` |
|
| 1714 | - // in order to tweak WP's `WP_Query` to include entities in queries related |
|
| 1715 | - // to categories. |
|
| 1716 | - $that->loader->add_action( 'pre_get_posts', $that->category_taxonomy_service, 'pre_get_posts', 10, 1 ); |
|
| 1717 | - |
|
| 1718 | - /* |
|
| 1584 | + // $that->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $that->analytics_settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1585 | + |
|
| 1586 | + // Hook the AJAX `wl_publisher` action name. |
|
| 1587 | + $that->loader->add_action( 'wp_ajax_wl_publisher', $that->publisher_ajax_adapter, 'publisher' ); |
|
| 1588 | + |
|
| 1589 | + // Hook row actions for the entity type list admin. |
|
| 1590 | + $that->loader->add_filter( 'wl_entity_type_row_actions', $that->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 ); |
|
| 1591 | + |
|
| 1592 | + /** Ajax actions. */ |
|
| 1593 | + $that->loader->add_action( 'wp_ajax_wl_google_analytics_export', $that->google_analytics_export_service, 'export' ); |
|
| 1594 | + |
|
| 1595 | + // Hook capabilities manipulation to allow access to entity type admin |
|
| 1596 | + // page on WordPress versions before 4.7. |
|
| 1597 | + global $wp_version; |
|
| 1598 | + if ( version_compare( $wp_version, '4.7', '<' ) ) { |
|
| 1599 | + $that->loader->add_filter( 'map_meta_cap', $that->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 ); |
|
| 1600 | + } |
|
| 1601 | + |
|
| 1602 | + /** Adapters. */ |
|
| 1603 | + $that->loader->add_filter( 'mce_external_plugins', $that->tinymce_adapter, 'mce_external_plugins', 10, 1 ); |
|
| 1604 | + /** |
|
| 1605 | + * Disabling Faq temporarily. |
|
| 1606 | + * Load the tinymce editor button on the tool bar. |
|
| 1607 | + * @since 3.26.0 |
|
| 1608 | + */ |
|
| 1609 | + //$that->loader->add_filter( 'tiny_mce_before_init', $that->faq_tinymce_adapter, 'register_custom_tags' ); |
|
| 1610 | + //$that->loader->add_filter( 'mce_buttons', $that->faq_tinymce_adapter, 'register_faq_toolbar_button', 10, 1 ); |
|
| 1611 | + //$that->loader->add_filter( 'mce_external_plugins', $that->faq_tinymce_adapter, 'register_faq_tinymce_plugin', 10, 1 ); |
|
| 1612 | + |
|
| 1613 | + |
|
| 1614 | + $that->loader->add_action( 'wp_ajax_wl_sample_data_create', $that->sample_data_ajax_adapter, 'create' ); |
|
| 1615 | + $that->loader->add_action( 'wp_ajax_wl_sample_data_delete', $that->sample_data_ajax_adapter, 'delete' ); |
|
| 1616 | + |
|
| 1617 | + /** |
|
| 1618 | + * @since 3.26.0 |
|
| 1619 | + */ |
|
| 1620 | + $excerpt_adapter = new Post_Excerpt_Meta_Box_Adapter(); |
|
| 1621 | + $that->loader->add_action( 'do_meta_boxes', $excerpt_adapter, 'replace_post_excerpt_meta_box' ); |
|
| 1622 | + // Adding Rest route for the post excerpt |
|
| 1623 | + Post_Excerpt_Rest_Controller::register_routes(); |
|
| 1624 | + |
|
| 1625 | + // Handle the autocomplete request. |
|
| 1626 | + add_action( 'wp_ajax_wl_autocomplete', array( |
|
| 1627 | + $that->autocomplete_adapter, |
|
| 1628 | + 'wl_autocomplete', |
|
| 1629 | + ) ); |
|
| 1630 | + add_action( 'wp_ajax_nopriv_wl_autocomplete', array( |
|
| 1631 | + $that->autocomplete_adapter, |
|
| 1632 | + 'wl_autocomplete', |
|
| 1633 | + ) ); |
|
| 1634 | + |
|
| 1635 | + // Hooks to restrict multisite super admin from manipulating entity types. |
|
| 1636 | + if ( is_multisite() ) { |
|
| 1637 | + $that->loader->add_filter( 'map_meta_cap', $that->entity_type_admin_page, 'restrict_super_admin', 10, 4 ); |
|
| 1638 | + } |
|
| 1639 | + |
|
| 1640 | + $deactivator_feedback = new Wordlift_Deactivator_Feedback(); |
|
| 1641 | + |
|
| 1642 | + add_action( 'admin_footer', array( $deactivator_feedback, 'render_feedback_popup' ) ); |
|
| 1643 | + add_action( 'admin_enqueue_scripts', array( $deactivator_feedback, 'enqueue_popup_scripts' ) ); |
|
| 1644 | + add_action( 'wp_ajax_wl_deactivation_feedback', array( |
|
| 1645 | + $deactivator_feedback, |
|
| 1646 | + 'wl_deactivation_feedback' |
|
| 1647 | + ) ); |
|
| 1648 | + |
|
| 1649 | + /** |
|
| 1650 | + * Always allow the `wordlift/classification` block. |
|
| 1651 | + * |
|
| 1652 | + * @since 3.23.0 |
|
| 1653 | + */ |
|
| 1654 | + add_filter( 'allowed_block_types', function ( $value ) { |
|
| 1655 | + |
|
| 1656 | + if ( true === $value ) { |
|
| 1657 | + return $value; |
|
| 1658 | + } |
|
| 1659 | + |
|
| 1660 | + return array_merge( (array) $value, array( 'wordlift/classification' ) ); |
|
| 1661 | + }, PHP_INT_MAX ); |
|
| 1662 | + |
|
| 1663 | + /** |
|
| 1664 | + * @since 3.27.7 |
|
| 1665 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
| 1666 | + */ |
|
| 1667 | + new Top_Entities(); |
|
| 1668 | + |
|
| 1669 | + } |
|
| 1670 | + |
|
| 1671 | + /** |
|
| 1672 | + * Register all of the hooks related to the public-facing functionality |
|
| 1673 | + * of the plugin. |
|
| 1674 | + * |
|
| 1675 | + * @since 1.0.0 |
|
| 1676 | + * @access private |
|
| 1677 | + */ |
|
| 1678 | + private function define_public_hooks( $that ) { |
|
| 1679 | + |
|
| 1680 | + $plugin_public = new Wordlift_Public( $that->get_plugin_name(), $that->get_version() ); |
|
| 1681 | + |
|
| 1682 | + // Register the entity post type. |
|
| 1683 | + $that->loader->add_action( 'init', $that->entity_post_type_service, 'register' ); |
|
| 1684 | + |
|
| 1685 | + // Bind the link generation and handling hooks to the entity link service. |
|
| 1686 | + $that->loader->add_filter( 'post_type_link', $that->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 1687 | + $that->loader->add_action( 'pre_get_posts', $that->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 ); |
|
| 1688 | + // $that->loader->add_filter( 'wp_unique_post_slug_is_bad_flat_slug', $that->entity_link_service, 'wp_unique_post_slug_is_bad_flat_slug', 10, 3 ); |
|
| 1689 | + // $that->loader->add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', $that->entity_link_service, 'wp_unique_post_slug_is_bad_hierarchical_slug', 10, 4 ); |
|
| 1690 | + |
|
| 1691 | + $that->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 1692 | + $that->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 1693 | + $that->loader->add_action( 'wp_enqueue_scripts', $that->context_cards_service, 'enqueue_scripts' ); |
|
| 1694 | + |
|
| 1695 | + // Registering Faq_Content_Filter service used for removing faq question and answer tags from the html. |
|
| 1696 | + $that->loader->add_filter( 'the_content', $that->faq_content_filter_service, 'remove_all_faq_question_and_answer_tags' ); |
|
| 1697 | + // Hook the content filter service to add entity links. |
|
| 1698 | + if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) { |
|
| 1699 | + // We run before other filters. |
|
| 1700 | + $that->loader->add_filter( 'the_content', $that->content_filter_service, 'the_content', 9 ); |
|
| 1701 | + } |
|
| 1702 | + |
|
| 1703 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1704 | + $that->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $that->timeline_service, 'ajax_timeline' ); |
|
| 1705 | + |
|
| 1706 | + // Hook the ShareThis service. |
|
| 1707 | + $that->loader->add_filter( 'the_content', $that->sharethis_service, 'the_content', 99 ); |
|
| 1708 | + $that->loader->add_filter( 'the_excerpt', $that->sharethis_service, 'the_excerpt', 99 ); |
|
| 1709 | + |
|
| 1710 | + // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1711 | + $that->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $that->jsonld_service, 'get' ); |
|
| 1712 | + |
|
| 1713 | + // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service` |
|
| 1714 | + // in order to tweak WP's `WP_Query` to include entities in queries related |
|
| 1715 | + // to categories. |
|
| 1716 | + $that->loader->add_action( 'pre_get_posts', $that->category_taxonomy_service, 'pre_get_posts', 10, 1 ); |
|
| 1717 | + |
|
| 1718 | + /* |
|
| 1719 | 1719 | * Hook the `pre_get_posts` action to the `Wordlift_Entity_Page_Service` |
| 1720 | 1720 | * in order to tweak WP's `WP_Query` to show event related entities in reverse |
| 1721 | 1721 | * order of start time. |
| 1722 | 1722 | */ |
| 1723 | - $that->loader->add_action( 'pre_get_posts', $that->entity_page_service, 'pre_get_posts', 10, 1 ); |
|
| 1724 | - |
|
| 1725 | - // This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done. |
|
| 1726 | - $that->loader->add_action( 'save_post', $that->entity_type_adapter, 'save_post', 9, 3 ); |
|
| 1727 | - |
|
| 1728 | - // Analytics Script Frontend. |
|
| 1729 | - if ( apply_filters( 'wl_feature__enable__analytics', true ) && Wordlift_Configuration_Service::get_instance()->is_analytics_enable() ) { |
|
| 1730 | - $that->loader->add_action( 'wp_enqueue_scripts', $that->analytics_connect, 'enqueue_scripts', 10 ); |
|
| 1731 | - } |
|
| 1732 | - |
|
| 1733 | - } |
|
| 1734 | - |
|
| 1735 | - /** |
|
| 1736 | - * Run the loader to execute all of the hooks with WordPress. |
|
| 1737 | - * |
|
| 1738 | - * @since 1.0.0 |
|
| 1739 | - */ |
|
| 1740 | - public function run() { |
|
| 1741 | - $this->loader->run(); |
|
| 1742 | - } |
|
| 1743 | - |
|
| 1744 | - /** |
|
| 1745 | - * The name of the plugin used to uniquely identify it within the context of |
|
| 1746 | - * WordPress and to define internationalization functionality. |
|
| 1747 | - * |
|
| 1748 | - * @return string The name of the plugin. |
|
| 1749 | - * @since 1.0.0 |
|
| 1750 | - */ |
|
| 1751 | - public function get_plugin_name() { |
|
| 1752 | - return $this->plugin_name; |
|
| 1753 | - } |
|
| 1754 | - |
|
| 1755 | - /** |
|
| 1756 | - * The reference to the class that orchestrates the hooks with the plugin. |
|
| 1757 | - * |
|
| 1758 | - * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 1759 | - * @since 1.0.0 |
|
| 1760 | - */ |
|
| 1761 | - public function get_loader() { |
|
| 1762 | - return $this->loader; |
|
| 1763 | - } |
|
| 1764 | - |
|
| 1765 | - /** |
|
| 1766 | - * Retrieve the version number of the plugin. |
|
| 1767 | - * |
|
| 1768 | - * @return string The version number of the plugin. |
|
| 1769 | - * @since 1.0.0 |
|
| 1770 | - */ |
|
| 1771 | - public function get_version() { |
|
| 1772 | - return $this->version; |
|
| 1773 | - } |
|
| 1774 | - |
|
| 1775 | - /** |
|
| 1776 | - * Load dependencies for WP-CLI. |
|
| 1777 | - * |
|
| 1778 | - * @throws Exception |
|
| 1779 | - * @since 3.18.0 |
|
| 1780 | - */ |
|
| 1781 | - private function load_cli_dependencies() { |
|
| 1782 | - |
|
| 1783 | - } |
|
| 1784 | - |
|
| 1785 | - public function add_wl_enabled_blocks() { |
|
| 1786 | - /** |
|
| 1787 | - * Filter: wl_feature__enable__blocks. |
|
| 1788 | - * |
|
| 1789 | - * @param bool whether the blocks needed to be registered, defaults to true. |
|
| 1790 | - * |
|
| 1791 | - * @return bool |
|
| 1792 | - * @since 3.27.6 |
|
| 1793 | - */ |
|
| 1794 | - |
|
| 1795 | - wp_register_script( 'wl_enabled_blocks', false ); |
|
| 1796 | - |
|
| 1797 | - $enabled_blocks = array(); |
|
| 1798 | - |
|
| 1799 | - /** |
|
| 1800 | - * Filter name: wl_feature__enable__product-navigator |
|
| 1801 | - * @since 3.32.3 |
|
| 1802 | - */ |
|
| 1803 | - if ( apply_filters( 'wl_feature__enable__product-navigator', true ) ) { |
|
| 1804 | - $enabled_blocks[] = 'wordlift/products-navigator'; |
|
| 1805 | - } |
|
| 1806 | - |
|
| 1807 | - if ( apply_filters( 'wl_feature__enable__blocks', true ) ) { |
|
| 1808 | - // To intimate JS |
|
| 1809 | - $enabled_blocks = array_merge( $enabled_blocks, array( |
|
| 1810 | - 'wordlift/navigator', |
|
| 1811 | - 'wordlift/chord', |
|
| 1812 | - 'wordlift/geomap', |
|
| 1813 | - 'wordlift/timeline', |
|
| 1814 | - 'wordlift/cloud', |
|
| 1815 | - 'wordlift/vocabulary', |
|
| 1816 | - 'wordlift/faceted-search' |
|
| 1817 | - ) ); |
|
| 1818 | - } |
|
| 1819 | - |
|
| 1820 | - wp_localize_script( 'wl_enabled_blocks', 'wlEnabledBlocks', $enabled_blocks ); |
|
| 1821 | - wp_enqueue_script( 'wl_enabled_blocks' ); |
|
| 1822 | - } |
|
| 1823 | - |
|
| 1824 | - /** |
|
| 1825 | - * Register screens based on the filter. |
|
| 1826 | - */ |
|
| 1827 | - public function register_screens() { |
|
| 1828 | - // Hook the menu to the Download Your Data page. |
|
| 1829 | - if ( apply_filters( 'wl_feature__enable__settings-download', true ) ) { |
|
| 1830 | - Assertions::is_set( $this->download_your_data_page, "`download_your_data_page` can't be null" ); |
|
| 1831 | - add_action( 'admin_menu', array( $this->download_your_data_page, 'admin_menu' ), 100, 0 ); |
|
| 1832 | - } |
|
| 1833 | - |
|
| 1834 | - Assertions::is_set( $this->entity_type_settings_admin_page, "`entity_type_settings_admin_page` can't be null" ); |
|
| 1835 | - add_action( 'admin_menu', array( $this->entity_type_settings_admin_page, 'admin_menu' ), 100, 0 ); |
|
| 1836 | - |
|
| 1837 | - } |
|
| 1723 | + $that->loader->add_action( 'pre_get_posts', $that->entity_page_service, 'pre_get_posts', 10, 1 ); |
|
| 1724 | + |
|
| 1725 | + // This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done. |
|
| 1726 | + $that->loader->add_action( 'save_post', $that->entity_type_adapter, 'save_post', 9, 3 ); |
|
| 1727 | + |
|
| 1728 | + // Analytics Script Frontend. |
|
| 1729 | + if ( apply_filters( 'wl_feature__enable__analytics', true ) && Wordlift_Configuration_Service::get_instance()->is_analytics_enable() ) { |
|
| 1730 | + $that->loader->add_action( 'wp_enqueue_scripts', $that->analytics_connect, 'enqueue_scripts', 10 ); |
|
| 1731 | + } |
|
| 1732 | + |
|
| 1733 | + } |
|
| 1734 | + |
|
| 1735 | + /** |
|
| 1736 | + * Run the loader to execute all of the hooks with WordPress. |
|
| 1737 | + * |
|
| 1738 | + * @since 1.0.0 |
|
| 1739 | + */ |
|
| 1740 | + public function run() { |
|
| 1741 | + $this->loader->run(); |
|
| 1742 | + } |
|
| 1743 | + |
|
| 1744 | + /** |
|
| 1745 | + * The name of the plugin used to uniquely identify it within the context of |
|
| 1746 | + * WordPress and to define internationalization functionality. |
|
| 1747 | + * |
|
| 1748 | + * @return string The name of the plugin. |
|
| 1749 | + * @since 1.0.0 |
|
| 1750 | + */ |
|
| 1751 | + public function get_plugin_name() { |
|
| 1752 | + return $this->plugin_name; |
|
| 1753 | + } |
|
| 1754 | + |
|
| 1755 | + /** |
|
| 1756 | + * The reference to the class that orchestrates the hooks with the plugin. |
|
| 1757 | + * |
|
| 1758 | + * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 1759 | + * @since 1.0.0 |
|
| 1760 | + */ |
|
| 1761 | + public function get_loader() { |
|
| 1762 | + return $this->loader; |
|
| 1763 | + } |
|
| 1764 | + |
|
| 1765 | + /** |
|
| 1766 | + * Retrieve the version number of the plugin. |
|
| 1767 | + * |
|
| 1768 | + * @return string The version number of the plugin. |
|
| 1769 | + * @since 1.0.0 |
|
| 1770 | + */ |
|
| 1771 | + public function get_version() { |
|
| 1772 | + return $this->version; |
|
| 1773 | + } |
|
| 1774 | + |
|
| 1775 | + /** |
|
| 1776 | + * Load dependencies for WP-CLI. |
|
| 1777 | + * |
|
| 1778 | + * @throws Exception |
|
| 1779 | + * @since 3.18.0 |
|
| 1780 | + */ |
|
| 1781 | + private function load_cli_dependencies() { |
|
| 1782 | + |
|
| 1783 | + } |
|
| 1784 | + |
|
| 1785 | + public function add_wl_enabled_blocks() { |
|
| 1786 | + /** |
|
| 1787 | + * Filter: wl_feature__enable__blocks. |
|
| 1788 | + * |
|
| 1789 | + * @param bool whether the blocks needed to be registered, defaults to true. |
|
| 1790 | + * |
|
| 1791 | + * @return bool |
|
| 1792 | + * @since 3.27.6 |
|
| 1793 | + */ |
|
| 1794 | + |
|
| 1795 | + wp_register_script( 'wl_enabled_blocks', false ); |
|
| 1796 | + |
|
| 1797 | + $enabled_blocks = array(); |
|
| 1798 | + |
|
| 1799 | + /** |
|
| 1800 | + * Filter name: wl_feature__enable__product-navigator |
|
| 1801 | + * @since 3.32.3 |
|
| 1802 | + */ |
|
| 1803 | + if ( apply_filters( 'wl_feature__enable__product-navigator', true ) ) { |
|
| 1804 | + $enabled_blocks[] = 'wordlift/products-navigator'; |
|
| 1805 | + } |
|
| 1806 | + |
|
| 1807 | + if ( apply_filters( 'wl_feature__enable__blocks', true ) ) { |
|
| 1808 | + // To intimate JS |
|
| 1809 | + $enabled_blocks = array_merge( $enabled_blocks, array( |
|
| 1810 | + 'wordlift/navigator', |
|
| 1811 | + 'wordlift/chord', |
|
| 1812 | + 'wordlift/geomap', |
|
| 1813 | + 'wordlift/timeline', |
|
| 1814 | + 'wordlift/cloud', |
|
| 1815 | + 'wordlift/vocabulary', |
|
| 1816 | + 'wordlift/faceted-search' |
|
| 1817 | + ) ); |
|
| 1818 | + } |
|
| 1819 | + |
|
| 1820 | + wp_localize_script( 'wl_enabled_blocks', 'wlEnabledBlocks', $enabled_blocks ); |
|
| 1821 | + wp_enqueue_script( 'wl_enabled_blocks' ); |
|
| 1822 | + } |
|
| 1823 | + |
|
| 1824 | + /** |
|
| 1825 | + * Register screens based on the filter. |
|
| 1826 | + */ |
|
| 1827 | + public function register_screens() { |
|
| 1828 | + // Hook the menu to the Download Your Data page. |
|
| 1829 | + if ( apply_filters( 'wl_feature__enable__settings-download', true ) ) { |
|
| 1830 | + Assertions::is_set( $this->download_your_data_page, "`download_your_data_page` can't be null" ); |
|
| 1831 | + add_action( 'admin_menu', array( $this->download_your_data_page, 'admin_menu' ), 100, 0 ); |
|
| 1832 | + } |
|
| 1833 | + |
|
| 1834 | + Assertions::is_set( $this->entity_type_settings_admin_page, "`entity_type_settings_admin_page` can't be null" ); |
|
| 1835 | + add_action( 'admin_menu', array( $this->entity_type_settings_admin_page, 'admin_menu' ), 100, 0 ); |
|
| 1836 | + |
|
| 1837 | + } |
|
| 1838 | 1838 | |
| 1839 | 1839 | } |
@@ -13,205 +13,205 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class Wordlift_Entity_Post_To_Jsonld_Converter extends Wordlift_Abstract_Post_To_Jsonld_Converter { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * The {@link Wordlift_Schemaorg_Property_Service} or null if not provided. |
|
| 18 | - * |
|
| 19 | - * @since 3.20.0 |
|
| 20 | - * @access private |
|
| 21 | - * @var null|Wordlift_Schemaorg_Property_Service The {@link Wordlift_Schemaorg_Property_Service} or null if not provided. |
|
| 22 | - */ |
|
| 23 | - private $schemaorg_property_service; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * The {@link Wordlift_Post_To_Jsonld_Converter} is used to convert entities that also have the `article` term. |
|
| 27 | - * |
|
| 28 | - * @since 3.25.2 |
|
| 29 | - * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter The {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 30 | - */ |
|
| 31 | - private $post_to_jsonld_converter; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Wordlift_Entity_To_Jsonld_Converter constructor. |
|
| 35 | - * |
|
| 36 | - * @param \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 37 | - * @param \Wordlift_User_Service $user_service A {@link Wordlift_User_Service} instance. |
|
| 38 | - * @param \Wordlift_Attachment_Service $attachment_service A {@link Wordlift_Attachment_Service} instance. |
|
| 39 | - * @param \Wordlift_Property_Getter $property_getter A {@link Wordlift_Property_Getter} instance. |
|
| 40 | - * @param \Wordlift_Schemaorg_Property_Service $schemaorg_property_service A {@link Wordlift_Schemaorg_Property_Service} instance. |
|
| 41 | - * @param \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter The {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 42 | - * |
|
| 43 | - * @since 3.8.0 |
|
| 44 | - */ |
|
| 45 | - public function __construct( $entity_type_service, $user_service, $attachment_service, $property_getter, $schemaorg_property_service, $post_to_jsonld_converter ) { |
|
| 46 | - parent::__construct( $entity_type_service, $user_service, $attachment_service, $property_getter ); |
|
| 47 | - $this->schemaorg_property_service = $schemaorg_property_service; |
|
| 48 | - $this->post_to_jsonld_converter = $post_to_jsonld_converter; |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * Convert the provided {@link WP_Post} to a JSON-LD array. Any entity reference |
|
| 53 | - * found while processing the post is set in the $references array. |
|
| 54 | - * |
|
| 55 | - * @param int $post_id The {@link WP_Post} id. |
|
| 56 | - * @param array $references An array of entity references. |
|
| 57 | - * @param array $references_infos |
|
| 58 | - * |
|
| 59 | - * @return array A JSON-LD array. |
|
| 60 | - * @since 3.8.0 |
|
| 61 | - */ |
|
| 62 | - public function convert( $post_id, &$references = array(), &$references_infos = array() ) { |
|
| 63 | - |
|
| 64 | - // Get the post instance. |
|
| 65 | - $post = get_post( $post_id ); |
|
| 66 | - if ( null === $post ) { |
|
| 67 | - // Post not found. |
|
| 68 | - return null; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - // Get the base JSON-LD and the list of entities referenced by this entity. |
|
| 72 | - if ( has_term( 'article', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, $post_id ) ) { |
|
| 73 | - $jsonld = $this->post_to_jsonld_converter->convert( $post_id, $references, $references_infos ); |
|
| 74 | - } else { |
|
| 75 | - $jsonld = parent::convert( $post_id, $references, $references_infos ); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - // Get the entity name. |
|
| 79 | - $jsonld['name'] = html_entity_decode( $post->post_title ); |
|
| 80 | - |
|
| 81 | - // 3.13.0, add alternate names. |
|
| 82 | - $alternative_labels = Wordlift_Entity_Service::get_instance()->get_alternative_labels( $post_id ); |
|
| 83 | - if ( 0 < count( $alternative_labels ) ) { |
|
| 84 | - $jsonld['alternateName'] = $alternative_labels; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - // Get the entity `@type` with custom fields set by the Wordlift_Schema_Service. |
|
| 88 | - // |
|
| 89 | - // This allows us to gather the basic properties as defined by the `Thing` entity type. |
|
| 90 | - // Get the configured type custom fields. |
|
| 91 | - $custom_fields = $this->entity_type_service->get_custom_fields_for_post( $post_id ); |
|
| 92 | - |
|
| 93 | - if ( isset( $custom_fields ) ) { |
|
| 94 | - $this->process_type_custom_fields( $jsonld, $custom_fields, $post, $references, $references_infos ); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - /* |
|
| 16 | + /** |
|
| 17 | + * The {@link Wordlift_Schemaorg_Property_Service} or null if not provided. |
|
| 18 | + * |
|
| 19 | + * @since 3.20.0 |
|
| 20 | + * @access private |
|
| 21 | + * @var null|Wordlift_Schemaorg_Property_Service The {@link Wordlift_Schemaorg_Property_Service} or null if not provided. |
|
| 22 | + */ |
|
| 23 | + private $schemaorg_property_service; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * The {@link Wordlift_Post_To_Jsonld_Converter} is used to convert entities that also have the `article` term. |
|
| 27 | + * |
|
| 28 | + * @since 3.25.2 |
|
| 29 | + * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter The {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 30 | + */ |
|
| 31 | + private $post_to_jsonld_converter; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Wordlift_Entity_To_Jsonld_Converter constructor. |
|
| 35 | + * |
|
| 36 | + * @param \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 37 | + * @param \Wordlift_User_Service $user_service A {@link Wordlift_User_Service} instance. |
|
| 38 | + * @param \Wordlift_Attachment_Service $attachment_service A {@link Wordlift_Attachment_Service} instance. |
|
| 39 | + * @param \Wordlift_Property_Getter $property_getter A {@link Wordlift_Property_Getter} instance. |
|
| 40 | + * @param \Wordlift_Schemaorg_Property_Service $schemaorg_property_service A {@link Wordlift_Schemaorg_Property_Service} instance. |
|
| 41 | + * @param \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter The {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 42 | + * |
|
| 43 | + * @since 3.8.0 |
|
| 44 | + */ |
|
| 45 | + public function __construct( $entity_type_service, $user_service, $attachment_service, $property_getter, $schemaorg_property_service, $post_to_jsonld_converter ) { |
|
| 46 | + parent::__construct( $entity_type_service, $user_service, $attachment_service, $property_getter ); |
|
| 47 | + $this->schemaorg_property_service = $schemaorg_property_service; |
|
| 48 | + $this->post_to_jsonld_converter = $post_to_jsonld_converter; |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * Convert the provided {@link WP_Post} to a JSON-LD array. Any entity reference |
|
| 53 | + * found while processing the post is set in the $references array. |
|
| 54 | + * |
|
| 55 | + * @param int $post_id The {@link WP_Post} id. |
|
| 56 | + * @param array $references An array of entity references. |
|
| 57 | + * @param array $references_infos |
|
| 58 | + * |
|
| 59 | + * @return array A JSON-LD array. |
|
| 60 | + * @since 3.8.0 |
|
| 61 | + */ |
|
| 62 | + public function convert( $post_id, &$references = array(), &$references_infos = array() ) { |
|
| 63 | + |
|
| 64 | + // Get the post instance. |
|
| 65 | + $post = get_post( $post_id ); |
|
| 66 | + if ( null === $post ) { |
|
| 67 | + // Post not found. |
|
| 68 | + return null; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + // Get the base JSON-LD and the list of entities referenced by this entity. |
|
| 72 | + if ( has_term( 'article', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, $post_id ) ) { |
|
| 73 | + $jsonld = $this->post_to_jsonld_converter->convert( $post_id, $references, $references_infos ); |
|
| 74 | + } else { |
|
| 75 | + $jsonld = parent::convert( $post_id, $references, $references_infos ); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + // Get the entity name. |
|
| 79 | + $jsonld['name'] = html_entity_decode( $post->post_title ); |
|
| 80 | + |
|
| 81 | + // 3.13.0, add alternate names. |
|
| 82 | + $alternative_labels = Wordlift_Entity_Service::get_instance()->get_alternative_labels( $post_id ); |
|
| 83 | + if ( 0 < count( $alternative_labels ) ) { |
|
| 84 | + $jsonld['alternateName'] = $alternative_labels; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + // Get the entity `@type` with custom fields set by the Wordlift_Schema_Service. |
|
| 88 | + // |
|
| 89 | + // This allows us to gather the basic properties as defined by the `Thing` entity type. |
|
| 90 | + // Get the configured type custom fields. |
|
| 91 | + $custom_fields = $this->entity_type_service->get_custom_fields_for_post( $post_id ); |
|
| 92 | + |
|
| 93 | + if ( isset( $custom_fields ) ) { |
|
| 94 | + $this->process_type_custom_fields( $jsonld, $custom_fields, $post, $references, $references_infos ); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + /* |
|
| 98 | 98 | * Get the properties attached to the post. |
| 99 | 99 | * |
| 100 | 100 | * @since 3.20.0 We attach properties directly to the posts. |
| 101 | 101 | * |
| 102 | 102 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
| 103 | 103 | */ |
| 104 | - if ( apply_filters( 'wl_feature__enable__all-entity-types', WL_ALL_ENTITY_TYPES ) ) { |
|
| 105 | - $this->process_post_properties( $jsonld, $post_id ); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * Call the `wl_post_jsonld_array` filter. This filter allows 3rd parties to also modify the references. |
|
| 110 | - * |
|
| 111 | - * @param array $value { |
|
| 112 | - * |
|
| 113 | - * @type array $jsonld The JSON-LD structure. |
|
| 114 | - * @type int[] $references An array of post IDs. |
|
| 115 | - * } |
|
| 116 | - * @since 3.25.0 |
|
| 117 | - * |
|
| 118 | - * @see https://www.geeklab.info/2010/04/wordpress-pass-variables-by-reference-with-apply_filter/ |
|
| 119 | - * |
|
| 120 | - * @api |
|
| 121 | - */ |
|
| 122 | - $ret_val = apply_filters( 'wl_entity_jsonld_array', array( |
|
| 123 | - 'jsonld' => $jsonld, |
|
| 124 | - 'references' => $references, |
|
| 125 | - ), $post_id ); |
|
| 126 | - $jsonld = $ret_val['jsonld']; |
|
| 127 | - $references = $ret_val['references']; |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * Call the `wl_entity_jsonld` filter. |
|
| 131 | - * |
|
| 132 | - * @param array $jsonld The JSON-LD structure. |
|
| 133 | - * @param int $post_id The {@link WP_Post} `id`. |
|
| 134 | - * @param array $references The array of referenced entities. |
|
| 135 | - * |
|
| 136 | - * @since 3.20.0 |
|
| 137 | - * |
|
| 138 | - * @api |
|
| 139 | - */ |
|
| 140 | - return apply_filters( 'wl_entity_jsonld', $this->post_process( $jsonld ), $post_id, $references ); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * Process the properties attached to the {@link WP_Post}. |
|
| 145 | - * |
|
| 146 | - * @param array $jsonld The JSON-LD array. |
|
| 147 | - * @param int $post_id The target {@link WP_Post} id. |
|
| 148 | - * |
|
| 149 | - * @since 3.20.0 |
|
| 150 | - * |
|
| 151 | - */ |
|
| 152 | - private function process_post_properties( &$jsonld, $post_id ) { |
|
| 153 | - |
|
| 154 | - // Get all the props. |
|
| 155 | - $props = $this->schemaorg_property_service->get_all( $post_id ); |
|
| 156 | - |
|
| 157 | - // Process all the props. |
|
| 158 | - foreach ( $props as $name => $instances ) { |
|
| 159 | - |
|
| 160 | - // Get the values. |
|
| 161 | - $values = array_map( function ( $instance ) { |
|
| 162 | - return $instance['value']; |
|
| 163 | - }, $instances ); |
|
| 164 | - |
|
| 165 | - // We might receive empty values, remove them. |
|
| 166 | - $non_empty_values = array_filter( $values, function ( $value ) { |
|
| 167 | - return ! empty( $value ); |
|
| 168 | - } ); |
|
| 169 | - |
|
| 170 | - // Skip empty properties. |
|
| 171 | - if ( empty( $non_empty_values ) ) { |
|
| 172 | - continue; |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - // @@todo: need to handle maybe Numbers and URLs differently. |
|
| 176 | - // Make an array a single value when possible. |
|
| 177 | - $jsonld[ $name ] = self::make_one( $non_empty_values ); |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - /** |
|
| 183 | - * Post process the generated JSON to reorganize values which are stored as 1st |
|
| 184 | - * level in WP but are really 2nd level. |
|
| 185 | - * |
|
| 186 | - * @param array $jsonld An array of JSON-LD properties and values. |
|
| 187 | - * |
|
| 188 | - * @return array The array remapped. |
|
| 189 | - * @since 3.8.0 |
|
| 190 | - * |
|
| 191 | - */ |
|
| 192 | - private function post_process( $jsonld ) { |
|
| 193 | - |
|
| 194 | - foreach ( $jsonld as $key => $value ) { |
|
| 195 | - if ( 'streetAddress' === $key || 'postalCode' === $key || 'addressLocality' === $key || 'addressRegion' === $key || 'addressCountry' === $key || 'postOfficeBoxNumber' === $key ) { |
|
| 196 | - $jsonld['address']['@type'] = 'PostalAddress'; |
|
| 197 | - $jsonld['address'][ $key ] = $value; |
|
| 198 | - unset( $jsonld[ $key ] ); |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - if ( 'latitude' === $key || 'longitude' === $key ) { |
|
| 202 | - $jsonld['geo']['@type'] = 'GeoCoordinates'; |
|
| 203 | - $jsonld['geo'][ $key ] = $value; |
|
| 204 | - unset( $jsonld[ $key ] ); |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - if ( 'calories' === $key ) { |
|
| 208 | - $jsonld['nutrition']['@type'] = 'NutritionInformation'; |
|
| 209 | - $jsonld['nutrition'][ $key ] = $value; |
|
| 210 | - unset( $jsonld[ $key ] ); |
|
| 211 | - } |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - return $jsonld; |
|
| 215 | - } |
|
| 104 | + if ( apply_filters( 'wl_feature__enable__all-entity-types', WL_ALL_ENTITY_TYPES ) ) { |
|
| 105 | + $this->process_post_properties( $jsonld, $post_id ); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * Call the `wl_post_jsonld_array` filter. This filter allows 3rd parties to also modify the references. |
|
| 110 | + * |
|
| 111 | + * @param array $value { |
|
| 112 | + * |
|
| 113 | + * @type array $jsonld The JSON-LD structure. |
|
| 114 | + * @type int[] $references An array of post IDs. |
|
| 115 | + * } |
|
| 116 | + * @since 3.25.0 |
|
| 117 | + * |
|
| 118 | + * @see https://www.geeklab.info/2010/04/wordpress-pass-variables-by-reference-with-apply_filter/ |
|
| 119 | + * |
|
| 120 | + * @api |
|
| 121 | + */ |
|
| 122 | + $ret_val = apply_filters( 'wl_entity_jsonld_array', array( |
|
| 123 | + 'jsonld' => $jsonld, |
|
| 124 | + 'references' => $references, |
|
| 125 | + ), $post_id ); |
|
| 126 | + $jsonld = $ret_val['jsonld']; |
|
| 127 | + $references = $ret_val['references']; |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * Call the `wl_entity_jsonld` filter. |
|
| 131 | + * |
|
| 132 | + * @param array $jsonld The JSON-LD structure. |
|
| 133 | + * @param int $post_id The {@link WP_Post} `id`. |
|
| 134 | + * @param array $references The array of referenced entities. |
|
| 135 | + * |
|
| 136 | + * @since 3.20.0 |
|
| 137 | + * |
|
| 138 | + * @api |
|
| 139 | + */ |
|
| 140 | + return apply_filters( 'wl_entity_jsonld', $this->post_process( $jsonld ), $post_id, $references ); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * Process the properties attached to the {@link WP_Post}. |
|
| 145 | + * |
|
| 146 | + * @param array $jsonld The JSON-LD array. |
|
| 147 | + * @param int $post_id The target {@link WP_Post} id. |
|
| 148 | + * |
|
| 149 | + * @since 3.20.0 |
|
| 150 | + * |
|
| 151 | + */ |
|
| 152 | + private function process_post_properties( &$jsonld, $post_id ) { |
|
| 153 | + |
|
| 154 | + // Get all the props. |
|
| 155 | + $props = $this->schemaorg_property_service->get_all( $post_id ); |
|
| 156 | + |
|
| 157 | + // Process all the props. |
|
| 158 | + foreach ( $props as $name => $instances ) { |
|
| 159 | + |
|
| 160 | + // Get the values. |
|
| 161 | + $values = array_map( function ( $instance ) { |
|
| 162 | + return $instance['value']; |
|
| 163 | + }, $instances ); |
|
| 164 | + |
|
| 165 | + // We might receive empty values, remove them. |
|
| 166 | + $non_empty_values = array_filter( $values, function ( $value ) { |
|
| 167 | + return ! empty( $value ); |
|
| 168 | + } ); |
|
| 169 | + |
|
| 170 | + // Skip empty properties. |
|
| 171 | + if ( empty( $non_empty_values ) ) { |
|
| 172 | + continue; |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + // @@todo: need to handle maybe Numbers and URLs differently. |
|
| 176 | + // Make an array a single value when possible. |
|
| 177 | + $jsonld[ $name ] = self::make_one( $non_empty_values ); |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + /** |
|
| 183 | + * Post process the generated JSON to reorganize values which are stored as 1st |
|
| 184 | + * level in WP but are really 2nd level. |
|
| 185 | + * |
|
| 186 | + * @param array $jsonld An array of JSON-LD properties and values. |
|
| 187 | + * |
|
| 188 | + * @return array The array remapped. |
|
| 189 | + * @since 3.8.0 |
|
| 190 | + * |
|
| 191 | + */ |
|
| 192 | + private function post_process( $jsonld ) { |
|
| 193 | + |
|
| 194 | + foreach ( $jsonld as $key => $value ) { |
|
| 195 | + if ( 'streetAddress' === $key || 'postalCode' === $key || 'addressLocality' === $key || 'addressRegion' === $key || 'addressCountry' === $key || 'postOfficeBoxNumber' === $key ) { |
|
| 196 | + $jsonld['address']['@type'] = 'PostalAddress'; |
|
| 197 | + $jsonld['address'][ $key ] = $value; |
|
| 198 | + unset( $jsonld[ $key ] ); |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + if ( 'latitude' === $key || 'longitude' === $key ) { |
|
| 202 | + $jsonld['geo']['@type'] = 'GeoCoordinates'; |
|
| 203 | + $jsonld['geo'][ $key ] = $value; |
|
| 204 | + unset( $jsonld[ $key ] ); |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + if ( 'calories' === $key ) { |
|
| 208 | + $jsonld['nutrition']['@type'] = 'NutritionInformation'; |
|
| 209 | + $jsonld['nutrition'][ $key ] = $value; |
|
| 210 | + unset( $jsonld[ $key ] ); |
|
| 211 | + } |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + return $jsonld; |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | 217 | } |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @since 3.8.0 |
| 44 | 44 | */ |
| 45 | - public function __construct( $entity_type_service, $user_service, $attachment_service, $property_getter, $schemaorg_property_service, $post_to_jsonld_converter ) { |
|
| 46 | - parent::__construct( $entity_type_service, $user_service, $attachment_service, $property_getter ); |
|
| 45 | + public function __construct($entity_type_service, $user_service, $attachment_service, $property_getter, $schemaorg_property_service, $post_to_jsonld_converter) { |
|
| 46 | + parent::__construct($entity_type_service, $user_service, $attachment_service, $property_getter); |
|
| 47 | 47 | $this->schemaorg_property_service = $schemaorg_property_service; |
| 48 | 48 | $this->post_to_jsonld_converter = $post_to_jsonld_converter; |
| 49 | 49 | } |
@@ -59,28 +59,28 @@ discard block |
||
| 59 | 59 | * @return array A JSON-LD array. |
| 60 | 60 | * @since 3.8.0 |
| 61 | 61 | */ |
| 62 | - public function convert( $post_id, &$references = array(), &$references_infos = array() ) { |
|
| 62 | + public function convert($post_id, &$references = array(), &$references_infos = array()) { |
|
| 63 | 63 | |
| 64 | 64 | // Get the post instance. |
| 65 | - $post = get_post( $post_id ); |
|
| 66 | - if ( null === $post ) { |
|
| 65 | + $post = get_post($post_id); |
|
| 66 | + if (null === $post) { |
|
| 67 | 67 | // Post not found. |
| 68 | 68 | return null; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | // Get the base JSON-LD and the list of entities referenced by this entity. |
| 72 | - if ( has_term( 'article', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, $post_id ) ) { |
|
| 73 | - $jsonld = $this->post_to_jsonld_converter->convert( $post_id, $references, $references_infos ); |
|
| 72 | + if (has_term('article', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, $post_id)) { |
|
| 73 | + $jsonld = $this->post_to_jsonld_converter->convert($post_id, $references, $references_infos); |
|
| 74 | 74 | } else { |
| 75 | - $jsonld = parent::convert( $post_id, $references, $references_infos ); |
|
| 75 | + $jsonld = parent::convert($post_id, $references, $references_infos); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | // Get the entity name. |
| 79 | - $jsonld['name'] = html_entity_decode( $post->post_title ); |
|
| 79 | + $jsonld['name'] = html_entity_decode($post->post_title); |
|
| 80 | 80 | |
| 81 | 81 | // 3.13.0, add alternate names. |
| 82 | - $alternative_labels = Wordlift_Entity_Service::get_instance()->get_alternative_labels( $post_id ); |
|
| 83 | - if ( 0 < count( $alternative_labels ) ) { |
|
| 82 | + $alternative_labels = Wordlift_Entity_Service::get_instance()->get_alternative_labels($post_id); |
|
| 83 | + if (0 < count($alternative_labels)) { |
|
| 84 | 84 | $jsonld['alternateName'] = $alternative_labels; |
| 85 | 85 | } |
| 86 | 86 | |
@@ -88,10 +88,10 @@ discard block |
||
| 88 | 88 | // |
| 89 | 89 | // This allows us to gather the basic properties as defined by the `Thing` entity type. |
| 90 | 90 | // Get the configured type custom fields. |
| 91 | - $custom_fields = $this->entity_type_service->get_custom_fields_for_post( $post_id ); |
|
| 91 | + $custom_fields = $this->entity_type_service->get_custom_fields_for_post($post_id); |
|
| 92 | 92 | |
| 93 | - if ( isset( $custom_fields ) ) { |
|
| 94 | - $this->process_type_custom_fields( $jsonld, $custom_fields, $post, $references, $references_infos ); |
|
| 93 | + if (isset($custom_fields)) { |
|
| 94 | + $this->process_type_custom_fields($jsonld, $custom_fields, $post, $references, $references_infos); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /* |
@@ -101,8 +101,8 @@ discard block |
||
| 101 | 101 | * |
| 102 | 102 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
| 103 | 103 | */ |
| 104 | - if ( apply_filters( 'wl_feature__enable__all-entity-types', WL_ALL_ENTITY_TYPES ) ) { |
|
| 105 | - $this->process_post_properties( $jsonld, $post_id ); |
|
| 104 | + if (apply_filters('wl_feature__enable__all-entity-types', WL_ALL_ENTITY_TYPES)) { |
|
| 105 | + $this->process_post_properties($jsonld, $post_id); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
@@ -119,10 +119,10 @@ discard block |
||
| 119 | 119 | * |
| 120 | 120 | * @api |
| 121 | 121 | */ |
| 122 | - $ret_val = apply_filters( 'wl_entity_jsonld_array', array( |
|
| 122 | + $ret_val = apply_filters('wl_entity_jsonld_array', array( |
|
| 123 | 123 | 'jsonld' => $jsonld, |
| 124 | 124 | 'references' => $references, |
| 125 | - ), $post_id ); |
|
| 125 | + ), $post_id); |
|
| 126 | 126 | $jsonld = $ret_val['jsonld']; |
| 127 | 127 | $references = $ret_val['references']; |
| 128 | 128 | |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * |
| 138 | 138 | * @api |
| 139 | 139 | */ |
| 140 | - return apply_filters( 'wl_entity_jsonld', $this->post_process( $jsonld ), $post_id, $references ); |
|
| 140 | + return apply_filters('wl_entity_jsonld', $this->post_process($jsonld), $post_id, $references); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -149,32 +149,32 @@ discard block |
||
| 149 | 149 | * @since 3.20.0 |
| 150 | 150 | * |
| 151 | 151 | */ |
| 152 | - private function process_post_properties( &$jsonld, $post_id ) { |
|
| 152 | + private function process_post_properties(&$jsonld, $post_id) { |
|
| 153 | 153 | |
| 154 | 154 | // Get all the props. |
| 155 | - $props = $this->schemaorg_property_service->get_all( $post_id ); |
|
| 155 | + $props = $this->schemaorg_property_service->get_all($post_id); |
|
| 156 | 156 | |
| 157 | 157 | // Process all the props. |
| 158 | - foreach ( $props as $name => $instances ) { |
|
| 158 | + foreach ($props as $name => $instances) { |
|
| 159 | 159 | |
| 160 | 160 | // Get the values. |
| 161 | - $values = array_map( function ( $instance ) { |
|
| 161 | + $values = array_map(function($instance) { |
|
| 162 | 162 | return $instance['value']; |
| 163 | - }, $instances ); |
|
| 163 | + }, $instances); |
|
| 164 | 164 | |
| 165 | 165 | // We might receive empty values, remove them. |
| 166 | - $non_empty_values = array_filter( $values, function ( $value ) { |
|
| 167 | - return ! empty( $value ); |
|
| 166 | + $non_empty_values = array_filter($values, function($value) { |
|
| 167 | + return ! empty($value); |
|
| 168 | 168 | } ); |
| 169 | 169 | |
| 170 | 170 | // Skip empty properties. |
| 171 | - if ( empty( $non_empty_values ) ) { |
|
| 171 | + if (empty($non_empty_values)) { |
|
| 172 | 172 | continue; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | // @@todo: need to handle maybe Numbers and URLs differently. |
| 176 | 176 | // Make an array a single value when possible. |
| 177 | - $jsonld[ $name ] = self::make_one( $non_empty_values ); |
|
| 177 | + $jsonld[$name] = self::make_one($non_empty_values); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | } |
@@ -189,25 +189,25 @@ discard block |
||
| 189 | 189 | * @since 3.8.0 |
| 190 | 190 | * |
| 191 | 191 | */ |
| 192 | - private function post_process( $jsonld ) { |
|
| 192 | + private function post_process($jsonld) { |
|
| 193 | 193 | |
| 194 | - foreach ( $jsonld as $key => $value ) { |
|
| 195 | - if ( 'streetAddress' === $key || 'postalCode' === $key || 'addressLocality' === $key || 'addressRegion' === $key || 'addressCountry' === $key || 'postOfficeBoxNumber' === $key ) { |
|
| 194 | + foreach ($jsonld as $key => $value) { |
|
| 195 | + if ('streetAddress' === $key || 'postalCode' === $key || 'addressLocality' === $key || 'addressRegion' === $key || 'addressCountry' === $key || 'postOfficeBoxNumber' === $key) { |
|
| 196 | 196 | $jsonld['address']['@type'] = 'PostalAddress'; |
| 197 | - $jsonld['address'][ $key ] = $value; |
|
| 198 | - unset( $jsonld[ $key ] ); |
|
| 197 | + $jsonld['address'][$key] = $value; |
|
| 198 | + unset($jsonld[$key]); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - if ( 'latitude' === $key || 'longitude' === $key ) { |
|
| 201 | + if ('latitude' === $key || 'longitude' === $key) { |
|
| 202 | 202 | $jsonld['geo']['@type'] = 'GeoCoordinates'; |
| 203 | - $jsonld['geo'][ $key ] = $value; |
|
| 204 | - unset( $jsonld[ $key ] ); |
|
| 203 | + $jsonld['geo'][$key] = $value; |
|
| 204 | + unset($jsonld[$key]); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - if ( 'calories' === $key ) { |
|
| 207 | + if ('calories' === $key) { |
|
| 208 | 208 | $jsonld['nutrition']['@type'] = 'NutritionInformation'; |
| 209 | - $jsonld['nutrition'][ $key ] = $value; |
|
| 210 | - unset( $jsonld[ $key ] ); |
|
| 209 | + $jsonld['nutrition'][$key] = $value; |
|
| 210 | + unset($jsonld[$key]); |
|
| 211 | 211 | } |
| 212 | 212 | } |
| 213 | 213 | |
@@ -19,514 +19,514 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class Wordlift_Post_To_Jsonld_Converter extends Wordlift_Abstract_Post_To_Jsonld_Converter { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @var Wordlift_Post_To_Jsonld_Converter |
|
| 24 | - */ |
|
| 25 | - private static $instance; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * A {@link Wordlift_Log_Service} instance. |
|
| 29 | - * |
|
| 30 | - * @since 3.10.0 |
|
| 31 | - * @access private |
|
| 32 | - * @var Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 33 | - */ |
|
| 34 | - private $log; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @var false |
|
| 38 | - */ |
|
| 39 | - private $disable_convert_filters; |
|
| 40 | - /** |
|
| 41 | - * @var Object_Relation_Service |
|
| 42 | - */ |
|
| 43 | - private $object_relation_service; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * Wordlift_Post_To_Jsonld_Converter constructor. |
|
| 47 | - * |
|
| 48 | - * @param \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 49 | - * @param \Wordlift_User_Service $user_service A {@link Wordlift_User_Service} instance. |
|
| 50 | - * @param \Wordlift_Attachment_Service $attachment_service A {@link Wordlift_Attachment_Service} instance. |
|
| 51 | - * |
|
| 52 | - * @since 3.10.0 |
|
| 53 | - * |
|
| 54 | - */ |
|
| 55 | - public function __construct( $entity_type_service, $user_service, $attachment_service, $disable_convert_filters = false ) { |
|
| 56 | - parent::__construct( $entity_type_service, $user_service, $attachment_service, Wordlift_Property_Getter_Factory::create() ); |
|
| 57 | - $this->disable_convert_filters = $disable_convert_filters; |
|
| 58 | - $this->object_relation_service = Object_Relation_Service::get_instance(); |
|
| 59 | - // Set a reference to the logger. |
|
| 60 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Post_To_Jsonld_Converter' ); |
|
| 61 | - |
|
| 62 | - self::$instance = $this; |
|
| 63 | - |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - public static function get_instance() { |
|
| 67 | - |
|
| 68 | - return self::$instance; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - public function new_instance_with_filters_disabled() { |
|
| 72 | - return new static( $this->entity_type_service, $this->user_service, $this->attachment_service, true ); |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * Convert the provided {@link WP_Post} to a JSON-LD array. Any entity reference |
|
| 77 | - * found while processing the post is set in the $references array. |
|
| 78 | - * |
|
| 79 | - * @param int $post_id The post id. |
|
| 80 | - * @param array<Reference> $references An array of entity references. |
|
| 81 | - * @param array $references_infos |
|
| 82 | - * |
|
| 83 | - * @return array A JSON-LD array. |
|
| 84 | - * @since 3.10.0 |
|
| 85 | - */ |
|
| 86 | - public function convert( $post_id, &$references = array(), &$references_infos = array() ) { |
|
| 87 | - |
|
| 88 | - // Get the post instance. |
|
| 89 | - if ( null === $post = get_post( $post_id ) ) { |
|
| 90 | - // Post not found. |
|
| 91 | - return null; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - // Get the base JSON-LD and the list of entities referenced by this entity. |
|
| 95 | - $jsonld = parent::convert( $post_id, $references, $references_infos ); |
|
| 96 | - |
|
| 97 | - // Set WebPage by default. |
|
| 98 | - if ( empty( $jsonld['@type'] ) ) { |
|
| 99 | - $jsonld['@type'] = 'WebPage'; |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - // Get the entity name. |
|
| 103 | - $jsonld['headline'] = $post->post_title; |
|
| 104 | - |
|
| 105 | - $custom_fields = $this->entity_type_service->get_custom_fields_for_post( $post_id ); |
|
| 106 | - |
|
| 107 | - if ( isset( $custom_fields ) ) { |
|
| 108 | - $this->process_type_custom_fields( $jsonld, $custom_fields, $post, $references, $references_infos ); |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - // Set the published and modified dates. |
|
| 112 | - /* |
|
| 22 | + /** |
|
| 23 | + * @var Wordlift_Post_To_Jsonld_Converter |
|
| 24 | + */ |
|
| 25 | + private static $instance; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * A {@link Wordlift_Log_Service} instance. |
|
| 29 | + * |
|
| 30 | + * @since 3.10.0 |
|
| 31 | + * @access private |
|
| 32 | + * @var Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 33 | + */ |
|
| 34 | + private $log; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @var false |
|
| 38 | + */ |
|
| 39 | + private $disable_convert_filters; |
|
| 40 | + /** |
|
| 41 | + * @var Object_Relation_Service |
|
| 42 | + */ |
|
| 43 | + private $object_relation_service; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * Wordlift_Post_To_Jsonld_Converter constructor. |
|
| 47 | + * |
|
| 48 | + * @param \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 49 | + * @param \Wordlift_User_Service $user_service A {@link Wordlift_User_Service} instance. |
|
| 50 | + * @param \Wordlift_Attachment_Service $attachment_service A {@link Wordlift_Attachment_Service} instance. |
|
| 51 | + * |
|
| 52 | + * @since 3.10.0 |
|
| 53 | + * |
|
| 54 | + */ |
|
| 55 | + public function __construct( $entity_type_service, $user_service, $attachment_service, $disable_convert_filters = false ) { |
|
| 56 | + parent::__construct( $entity_type_service, $user_service, $attachment_service, Wordlift_Property_Getter_Factory::create() ); |
|
| 57 | + $this->disable_convert_filters = $disable_convert_filters; |
|
| 58 | + $this->object_relation_service = Object_Relation_Service::get_instance(); |
|
| 59 | + // Set a reference to the logger. |
|
| 60 | + $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Post_To_Jsonld_Converter' ); |
|
| 61 | + |
|
| 62 | + self::$instance = $this; |
|
| 63 | + |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + public static function get_instance() { |
|
| 67 | + |
|
| 68 | + return self::$instance; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + public function new_instance_with_filters_disabled() { |
|
| 72 | + return new static( $this->entity_type_service, $this->user_service, $this->attachment_service, true ); |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * Convert the provided {@link WP_Post} to a JSON-LD array. Any entity reference |
|
| 77 | + * found while processing the post is set in the $references array. |
|
| 78 | + * |
|
| 79 | + * @param int $post_id The post id. |
|
| 80 | + * @param array<Reference> $references An array of entity references. |
|
| 81 | + * @param array $references_infos |
|
| 82 | + * |
|
| 83 | + * @return array A JSON-LD array. |
|
| 84 | + * @since 3.10.0 |
|
| 85 | + */ |
|
| 86 | + public function convert( $post_id, &$references = array(), &$references_infos = array() ) { |
|
| 87 | + |
|
| 88 | + // Get the post instance. |
|
| 89 | + if ( null === $post = get_post( $post_id ) ) { |
|
| 90 | + // Post not found. |
|
| 91 | + return null; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + // Get the base JSON-LD and the list of entities referenced by this entity. |
|
| 95 | + $jsonld = parent::convert( $post_id, $references, $references_infos ); |
|
| 96 | + |
|
| 97 | + // Set WebPage by default. |
|
| 98 | + if ( empty( $jsonld['@type'] ) ) { |
|
| 99 | + $jsonld['@type'] = 'WebPage'; |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + // Get the entity name. |
|
| 103 | + $jsonld['headline'] = $post->post_title; |
|
| 104 | + |
|
| 105 | + $custom_fields = $this->entity_type_service->get_custom_fields_for_post( $post_id ); |
|
| 106 | + |
|
| 107 | + if ( isset( $custom_fields ) ) { |
|
| 108 | + $this->process_type_custom_fields( $jsonld, $custom_fields, $post, $references, $references_infos ); |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + // Set the published and modified dates. |
|
| 112 | + /* |
|
| 113 | 113 | * Set the `datePublished` and `dateModified` using the local timezone. |
| 114 | 114 | * |
| 115 | 115 | * @see https://github.com/insideout10/wordlift-plugin/issues/887 |
| 116 | 116 | * |
| 117 | 117 | * @since 3.20.0 |
| 118 | 118 | */ |
| 119 | - try { |
|
| 120 | - $default_timezone = date_default_timezone_get(); |
|
| 121 | - $timezone = get_option( 'timezone_string' ); |
|
| 122 | - if ( ! empty( $timezone ) ) { |
|
| 123 | - date_default_timezone_set( $timezone ); |
|
| 124 | - $jsonld['datePublished'] = get_post_time( 'Y-m-d\TH:i:sP', false, $post ); |
|
| 125 | - $jsonld['dateModified'] = get_post_modified_time( 'Y-m-d\TH:i:sP', false, $post ); |
|
| 126 | - date_default_timezone_set( $default_timezone ); |
|
| 127 | - } else { |
|
| 128 | - $jsonld['datePublished'] = get_post_time( 'Y-m-d\TH:i', true, $post, false ); |
|
| 129 | - $jsonld['dateModified'] = get_post_modified_time( 'Y-m-d\TH:i', true, $post, false ); |
|
| 130 | - } |
|
| 131 | - } catch ( Exception $e ) { |
|
| 132 | - $jsonld['datePublished'] = get_post_time( 'Y-m-d\TH:i', true, $post, false ); |
|
| 133 | - $jsonld['dateModified'] = get_post_modified_time( 'Y-m-d\TH:i', true, $post, false ); |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - // Get the word count for the post. |
|
| 137 | - /* |
|
| 119 | + try { |
|
| 120 | + $default_timezone = date_default_timezone_get(); |
|
| 121 | + $timezone = get_option( 'timezone_string' ); |
|
| 122 | + if ( ! empty( $timezone ) ) { |
|
| 123 | + date_default_timezone_set( $timezone ); |
|
| 124 | + $jsonld['datePublished'] = get_post_time( 'Y-m-d\TH:i:sP', false, $post ); |
|
| 125 | + $jsonld['dateModified'] = get_post_modified_time( 'Y-m-d\TH:i:sP', false, $post ); |
|
| 126 | + date_default_timezone_set( $default_timezone ); |
|
| 127 | + } else { |
|
| 128 | + $jsonld['datePublished'] = get_post_time( 'Y-m-d\TH:i', true, $post, false ); |
|
| 129 | + $jsonld['dateModified'] = get_post_modified_time( 'Y-m-d\TH:i', true, $post, false ); |
|
| 130 | + } |
|
| 131 | + } catch ( Exception $e ) { |
|
| 132 | + $jsonld['datePublished'] = get_post_time( 'Y-m-d\TH:i', true, $post, false ); |
|
| 133 | + $jsonld['dateModified'] = get_post_modified_time( 'Y-m-d\TH:i', true, $post, false ); |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + // Get the word count for the post. |
|
| 137 | + /* |
|
| 138 | 138 | * Do not display the `wordCount` on a `WebPage`. |
| 139 | 139 | * |
| 140 | 140 | * @see https://github.com/insideout10/wordlift-plugin/issues/888 |
| 141 | 141 | * |
| 142 | 142 | * @since 3.20.0 |
| 143 | 143 | */ |
| 144 | - if ( ! empty( $jsonld['@type'] ) && 'WebPage' !== $jsonld['@type'] ) { |
|
| 145 | - $post_adapter = new Wordlift_Post_Adapter( $post_id ); |
|
| 146 | - $jsonld['wordCount'] = $post_adapter->word_count(); |
|
| 147 | - } |
|
| 144 | + if ( ! empty( $jsonld['@type'] ) && 'WebPage' !== $jsonld['@type'] ) { |
|
| 145 | + $post_adapter = new Wordlift_Post_Adapter( $post_id ); |
|
| 146 | + $jsonld['wordCount'] = $post_adapter->word_count(); |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - /* |
|
| 149 | + /* |
|
| 150 | 150 | * Add keywords, articleSection, commentCount and inLanguage properties to `Article` JSON-LD |
| 151 | 151 | * |
| 152 | 152 | * @see https://github.com/insideout10/wordlift-plugin/issues/1140 |
| 153 | 153 | * |
| 154 | 154 | * @since 3.27.2 |
| 155 | 155 | */ |
| 156 | - if ( ! empty( $jsonld['@type'] ) && 'WebPage' !== $jsonld['@type'] ) { |
|
| 157 | - $post_adapter = new Wordlift_Post_Adapter( $post_id ); |
|
| 158 | - $keywords = $post_adapter->keywords(); |
|
| 159 | - $article_section = $post_adapter->article_section(); |
|
| 160 | - $comment_count = $post_adapter->comment_count(); |
|
| 161 | - $locale = $post_adapter->locale(); |
|
| 162 | - |
|
| 163 | - if ( isset( $keywords ) ) { |
|
| 164 | - $jsonld['keywords'] = $keywords; |
|
| 165 | - } |
|
| 166 | - if ( ! empty( $article_section ) ) { |
|
| 167 | - $jsonld['articleSection'] = $article_section; |
|
| 168 | - } |
|
| 169 | - $jsonld['commentCount'] = $comment_count; |
|
| 170 | - $jsonld['inLanguage'] = $locale; |
|
| 171 | - $post_adapter->add_references( $post_id, $references ); |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - // Set the publisher. |
|
| 175 | - $this->set_publisher( $jsonld ); |
|
| 176 | - |
|
| 177 | - $references = $this->convert_references( $references ); |
|
| 178 | - |
|
| 179 | - // Process the references if any. |
|
| 180 | - $this->set_mentions_and_about( $references, $post, $jsonld ); |
|
| 181 | - |
|
| 182 | - // Finally set the author. |
|
| 183 | - $jsonld['author'] = $this->get_author( $post->post_author, $references ); |
|
| 184 | - |
|
| 185 | - // Return the JSON-LD if filters are disabled by the client. |
|
| 186 | - if ( $this->disable_convert_filters ) { |
|
| 187 | - return $jsonld; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * Call the `wl_post_jsonld_array` filter. This filter allows 3rd parties to also modify the references. |
|
| 192 | - * |
|
| 193 | - * @param array $value { |
|
| 194 | - * |
|
| 195 | - * @type array $jsonld The JSON-LD structure. |
|
| 196 | - * @type int[] $references An array of post IDs. |
|
| 197 | - * } |
|
| 198 | - * @since 3.25.0 |
|
| 199 | - * |
|
| 200 | - * @see https://www.geeklab.info/2010/04/wordpress-pass-variables-by-reference-with-apply_filter/ |
|
| 201 | - * |
|
| 202 | - * @api |
|
| 203 | - */ |
|
| 204 | - $ret_val = apply_filters( 'wl_post_jsonld_array', array( |
|
| 205 | - 'jsonld' => $jsonld, |
|
| 206 | - 'references' => $references, |
|
| 207 | - ), $post_id ); |
|
| 208 | - |
|
| 209 | - $jsonld = $ret_val['jsonld']; |
|
| 210 | - $references = $ret_val['references']; |
|
| 211 | - |
|
| 212 | - /** |
|
| 213 | - * Call the `wl_post_jsonld` filter. |
|
| 214 | - * |
|
| 215 | - * @param array $jsonld The JSON-LD structure. |
|
| 216 | - * @param int $post_id The {@link WP_Post} `id`. |
|
| 217 | - * @param array $references The array of referenced entities. |
|
| 218 | - * |
|
| 219 | - * @since 3.14.0 |
|
| 220 | - * |
|
| 221 | - * @api |
|
| 222 | - */ |
|
| 223 | - return apply_filters( 'wl_post_jsonld', $jsonld, $post_id, $references ); |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - /** |
|
| 227 | - * Get the author's JSON-LD fragment. |
|
| 228 | - * |
|
| 229 | - * The JSON-LD fragment is generated using the {@link WP_User}'s data or |
|
| 230 | - * the referenced entity if configured for the {@link WP_User}. |
|
| 231 | - * |
|
| 232 | - * @param int $author_id The author {@link WP_User}'s `id`. |
|
| 233 | - * @param array $references An array of referenced entities. |
|
| 234 | - * |
|
| 235 | - * @return string|array A JSON-LD structure. |
|
| 236 | - * @since 3.14.0 |
|
| 237 | - * |
|
| 238 | - */ |
|
| 239 | - public function get_author( $author_id, &$references ) { |
|
| 240 | - |
|
| 241 | - // Get the entity bound to this user. |
|
| 242 | - $entity_id = $this->user_service->get_entity( $author_id ); |
|
| 243 | - |
|
| 244 | - // If there's no entity bound return a simple author structure. |
|
| 245 | - if ( empty( $entity_id ) || 'publish' !== get_post_status( $entity_id ) ) { |
|
| 246 | - |
|
| 247 | - $author = get_the_author_meta( 'display_name', $author_id ); |
|
| 248 | - $author_first_name = get_the_author_meta( 'first_name', $author_id ); |
|
| 249 | - $author_last_name = get_the_author_meta( 'last_name', $author_id ); |
|
| 250 | - $author_uri = $this->user_service->get_uri( $author_id ); |
|
| 251 | - |
|
| 252 | - return array( |
|
| 253 | - '@type' => 'Person', |
|
| 254 | - '@id' => $author_uri, |
|
| 255 | - 'name' => $author, |
|
| 256 | - 'givenName' => $author_first_name, |
|
| 257 | - 'familyName' => $author_last_name, |
|
| 258 | - 'url' => get_author_posts_url( $author_id ), |
|
| 259 | - ); |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - // Add the author to the references. |
|
| 263 | - $author_uri = Wordlift_Entity_Service::get_instance()->get_uri( $entity_id ); |
|
| 264 | - $references[] = $entity_id; |
|
| 265 | - |
|
| 266 | - // Return the JSON-LD for the referenced entity. |
|
| 267 | - return array( |
|
| 268 | - '@id' => $author_uri, |
|
| 269 | - ); |
|
| 270 | - } |
|
| 271 | - |
|
| 272 | - /** |
|
| 273 | - * Enrich the provided params array with publisher data, if available. |
|
| 274 | - * |
|
| 275 | - * @param array $params The parameters array. |
|
| 276 | - * |
|
| 277 | - * @since 3.10.0 |
|
| 278 | - * |
|
| 279 | - */ |
|
| 280 | - protected function set_publisher( &$params ) { |
|
| 281 | - |
|
| 282 | - // If the publisher id isn't set don't do anything. |
|
| 283 | - if ( null === $publisher_id = Wordlift_Configuration_Service::get_instance()->get_publisher_id() ) { |
|
| 284 | - return; |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - // Get the post instance. |
|
| 288 | - if ( null === $post = get_post( $publisher_id ) ) { |
|
| 289 | - // Publisher not found. |
|
| 290 | - return; |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - // Get the item id. |
|
| 294 | - $id = Wordlift_Entity_Service::get_instance()->get_uri( $publisher_id ); |
|
| 295 | - |
|
| 296 | - // Get the type. |
|
| 297 | - $type = $this->entity_type_service->get( $publisher_id ); |
|
| 298 | - |
|
| 299 | - // Get the name. |
|
| 300 | - $name = $post->post_title; |
|
| 301 | - |
|
| 302 | - // Set the publisher data. |
|
| 303 | - $params['publisher'] = array( |
|
| 304 | - '@type' => $this->relative_to_context( $type['uri'] ), |
|
| 305 | - '@id' => $id, |
|
| 306 | - 'name' => $name, |
|
| 307 | - ); |
|
| 308 | - |
|
| 309 | - // Add the sameAs values associated with the publisher. |
|
| 310 | - $storage_factory = Wordlift_Storage_Factory::get_instance(); |
|
| 311 | - $sameas = $storage_factory->post_meta( Wordlift_Schema_Service::FIELD_SAME_AS )->get( $publisher_id ); |
|
| 312 | - if ( ! empty( $sameas ) ) { |
|
| 313 | - $params['publisher']['sameAs'] = $sameas; |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - // Set the logo, only for http://schema.org/Organization as Person doesn't |
|
| 317 | - // support the logo property. |
|
| 318 | - // |
|
| 319 | - // See http://schema.org/logo. |
|
| 320 | - if ( 1 !== preg_match( '~Organization$~', $type['uri'] ) ) { |
|
| 321 | - return; |
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - // Get the publisher logo. |
|
| 325 | - $publisher_logo = $this->get_publisher_logo( $post->ID ); |
|
| 326 | - |
|
| 327 | - // Bail out if the publisher logo isn't set. |
|
| 328 | - if ( false === $publisher_logo ) { |
|
| 329 | - return; |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - // Copy over some useful properties. |
|
| 333 | - // |
|
| 334 | - // See https://developers.google.com/search/docs/data-types/articles. |
|
| 335 | - $params['publisher']['logo']['@type'] = 'ImageObject'; |
|
| 336 | - $params['publisher']['logo']['url'] = $publisher_logo['url']; |
|
| 337 | - |
|
| 338 | - // If you specify a "width" or "height" value you should leave out |
|
| 339 | - // 'px'. For example: "width":"4608px" should be "width":"4608". |
|
| 340 | - // |
|
| 341 | - // See https://github.com/insideout10/wordlift-plugin/issues/451. |
|
| 342 | - $params['publisher']['logo']['width'] = $publisher_logo['width']; |
|
| 343 | - $params['publisher']['logo']['height'] = $publisher_logo['height']; |
|
| 344 | - |
|
| 345 | - } |
|
| 346 | - |
|
| 347 | - /** |
|
| 348 | - * Get the publisher logo structure. |
|
| 349 | - * |
|
| 350 | - * The function returns false when the publisher logo cannot be determined, i.e.: |
|
| 351 | - * - the post has no featured image. |
|
| 352 | - * - the featured image has no file. |
|
| 353 | - * - a wp_image_editor instance cannot be instantiated on the original file or on the publisher logo file. |
|
| 354 | - * |
|
| 355 | - * @param int $post_id The post id. |
|
| 356 | - * |
|
| 357 | - * @return array|false Returns an array with the `url`, `width` and `height` for the publisher logo or false in case |
|
| 358 | - * of errors. |
|
| 359 | - * @since 3.19.2 |
|
| 360 | - * @see https://github.com/insideout10/wordlift-plugin/issues/823 related issue. |
|
| 361 | - * |
|
| 362 | - */ |
|
| 363 | - private function get_publisher_logo( $post_id ) { |
|
| 364 | - |
|
| 365 | - // Get the featured image for the post. |
|
| 366 | - $thumbnail_id = get_post_thumbnail_id( $post_id ); |
|
| 367 | - |
|
| 368 | - // Bail out if thumbnail not available. |
|
| 369 | - if ( empty( $thumbnail_id ) || 0 === $thumbnail_id ) { |
|
| 370 | - $this->log->info( "Featured image not set for post $post_id." ); |
|
| 371 | - |
|
| 372 | - return false; |
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - // Get the uploads base URL. |
|
| 376 | - $uploads_dir = wp_upload_dir(); |
|
| 377 | - |
|
| 378 | - // Get the attachment metadata. |
|
| 379 | - $metadata = wp_get_attachment_metadata( $thumbnail_id ); |
|
| 380 | - |
|
| 381 | - // Bail out if the file isn't set. |
|
| 382 | - if ( ! isset( $metadata['file'] ) ) { |
|
| 383 | - $this->log->warn( "Featured image file not found for post $post_id." ); |
|
| 384 | - |
|
| 385 | - return false; |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - // Retrieve the relative filename, e.g. "2018/05/logo_publisher.png" |
|
| 389 | - $path = $uploads_dir['basedir'] . DIRECTORY_SEPARATOR . $metadata['file']; |
|
| 390 | - |
|
| 391 | - // Use image src, if local file does not exist. @see https://github.com/insideout10/wordlift-plugin/issues/1149 |
|
| 392 | - if ( ! file_exists( $path ) ) { |
|
| 393 | - $this->log->warn( "Featured image file $path doesn't exist for post $post_id." ); |
|
| 394 | - |
|
| 395 | - $attachment_image_src = wp_get_attachment_image_src( $thumbnail_id, '' ); |
|
| 396 | - if ( $attachment_image_src ) { |
|
| 397 | - return array( |
|
| 398 | - 'url' => $attachment_image_src[0], |
|
| 399 | - 'width' => $attachment_image_src[1], |
|
| 400 | - 'height' => $attachment_image_src[2], |
|
| 401 | - ); |
|
| 402 | - } |
|
| 403 | - |
|
| 404 | - // Bail out if we cant fetch wp_get_attachment_image_src |
|
| 405 | - return false; |
|
| 406 | - |
|
| 407 | - } |
|
| 408 | - |
|
| 409 | - // Try to get the image editor and bail out if the editor cannot be instantiated. |
|
| 410 | - $original_file_editor = wp_get_image_editor( $path ); |
|
| 411 | - if ( is_wp_error( $original_file_editor ) ) { |
|
| 412 | - $this->log->warn( "Cannot instantiate WP Image Editor on file $path for post $post_id." ); |
|
| 413 | - |
|
| 414 | - return false; |
|
| 415 | - } |
|
| 416 | - |
|
| 417 | - // Generate the publisher logo filename, we cannot use the `width` and `height` because we're scaling |
|
| 418 | - // and we don't actually know the end values. |
|
| 419 | - $publisher_logo_path = $original_file_editor->generate_filename( '-publisher-logo' ); |
|
| 420 | - |
|
| 421 | - // If the file doesn't exist yet, create it. |
|
| 422 | - if ( ! file_exists( $publisher_logo_path ) ) { |
|
| 423 | - $original_file_editor->resize( 600, 60 ); |
|
| 424 | - $original_file_editor->save( $publisher_logo_path ); |
|
| 425 | - } |
|
| 426 | - |
|
| 427 | - // Try to get the image editor and bail out if the editor cannot be instantiated. |
|
| 428 | - $publisher_logo_editor = wp_get_image_editor( $publisher_logo_path ); |
|
| 429 | - if ( is_wp_error( $publisher_logo_editor ) ) { |
|
| 430 | - $this->log->warn( "Cannot instantiate WP Image Editor on file $publisher_logo_path for post $post_id." ); |
|
| 431 | - |
|
| 432 | - return false; |
|
| 433 | - } |
|
| 434 | - |
|
| 435 | - // Get the actual size. |
|
| 436 | - $size = $publisher_logo_editor->get_size(); |
|
| 437 | - |
|
| 438 | - // Finally return the array with data. |
|
| 439 | - return array( |
|
| 440 | - 'url' => $uploads_dir['baseurl'] . substr( $publisher_logo_path, strlen( $uploads_dir['basedir'] ) ), |
|
| 441 | - 'width' => $size['width'], |
|
| 442 | - 'height' => $size['height'], |
|
| 443 | - ); |
|
| 444 | - } |
|
| 445 | - |
|
| 446 | - /** |
|
| 447 | - * @param $references |
|
| 448 | - * @param $post |
|
| 449 | - * @param $jsonld |
|
| 450 | - * |
|
| 451 | - * @return void |
|
| 452 | - * |
|
| 453 | - */ |
|
| 454 | - private function set_mentions_and_about( $references, $post, &$jsonld ) { |
|
| 455 | - |
|
| 456 | - if ( count( $references ) === 0 ) { |
|
| 457 | - return; |
|
| 458 | - } |
|
| 459 | - |
|
| 460 | - // Prepare the `about` and `mentions` array. |
|
| 461 | - $about = $mentions = array(); |
|
| 462 | - |
|
| 463 | - // If the entity is in the title, then it should be an `about`. |
|
| 464 | - foreach ( $references as $reference ) { |
|
| 465 | - |
|
| 466 | - if ( ! $reference instanceof Reference ) { |
|
| 467 | - // This condition should never be reached. |
|
| 468 | - continue; |
|
| 469 | - } |
|
| 470 | - |
|
| 471 | - // Get the entity labels. |
|
| 472 | - $labels = Wordlift_Entity_Service::get_instance()->get_labels( $reference->get_id(), $reference->get_type() ); |
|
| 473 | - // Get the entity URI. |
|
| 474 | - $item = array( |
|
| 475 | - '@id' => Wordlift_Entity_Service::get_instance()->get_uri( $reference->get_id(), $reference->get_type() ), |
|
| 476 | - ); |
|
| 477 | - |
|
| 478 | - $escaped_labels = array_map( function ( $value ) { |
|
| 479 | - return preg_quote( $value, '/' ); |
|
| 480 | - }, $labels ); |
|
| 481 | - |
|
| 482 | - |
|
| 483 | - $matches = false; |
|
| 484 | - |
|
| 485 | - // When the title is empty, then we shouldn't yield a match to about section. |
|
| 486 | - if ( array_filter( $escaped_labels ) ) { |
|
| 487 | - // Check if the labels match any part of the title. |
|
| 488 | - $matches = 1 === preg_match( '/' . implode( '|', $escaped_labels ) . '/', $post->post_title ); |
|
| 489 | - } |
|
| 490 | - |
|
| 491 | - // If the title matches, assign the entity to the about, otherwise to the mentions. |
|
| 492 | - if ( $matches ) { |
|
| 493 | - $about[] = $item; |
|
| 494 | - } else { |
|
| 495 | - $mentions[] = $item; |
|
| 496 | - } |
|
| 497 | - } |
|
| 498 | - |
|
| 499 | - // If we have abouts, assign them to the JSON-LD. |
|
| 500 | - if ( 0 < count( $about ) ) { |
|
| 501 | - $jsonld['about'] = $about; |
|
| 502 | - } |
|
| 503 | - |
|
| 504 | - // If we have mentions, assign them to the JSON-LD. |
|
| 505 | - if ( 0 < count( $mentions ) ) { |
|
| 506 | - $jsonld['mentions'] = $mentions; |
|
| 507 | - } |
|
| 508 | - |
|
| 509 | - return $jsonld; |
|
| 510 | - } |
|
| 511 | - |
|
| 512 | - /** |
|
| 513 | - * Convert references to abstract data type if we find any. |
|
| 514 | - * |
|
| 515 | - * @param $references array<int|Reference> |
|
| 516 | - * |
|
| 517 | - * @return Reference[] |
|
| 518 | - */ |
|
| 519 | - private function convert_references( $references ) { |
|
| 520 | - return array_map( function ( $reference ) { |
|
| 521 | - // Legacy code may still push numerical references to this |
|
| 522 | - // $references variable, so convert it to post references. |
|
| 523 | - if ( is_numeric( $reference ) ) { |
|
| 524 | - return new Post_Reference( $reference ); |
|
| 525 | - } |
|
| 526 | - |
|
| 527 | - return $reference; |
|
| 528 | - |
|
| 529 | - }, $references ); |
|
| 530 | - } |
|
| 156 | + if ( ! empty( $jsonld['@type'] ) && 'WebPage' !== $jsonld['@type'] ) { |
|
| 157 | + $post_adapter = new Wordlift_Post_Adapter( $post_id ); |
|
| 158 | + $keywords = $post_adapter->keywords(); |
|
| 159 | + $article_section = $post_adapter->article_section(); |
|
| 160 | + $comment_count = $post_adapter->comment_count(); |
|
| 161 | + $locale = $post_adapter->locale(); |
|
| 162 | + |
|
| 163 | + if ( isset( $keywords ) ) { |
|
| 164 | + $jsonld['keywords'] = $keywords; |
|
| 165 | + } |
|
| 166 | + if ( ! empty( $article_section ) ) { |
|
| 167 | + $jsonld['articleSection'] = $article_section; |
|
| 168 | + } |
|
| 169 | + $jsonld['commentCount'] = $comment_count; |
|
| 170 | + $jsonld['inLanguage'] = $locale; |
|
| 171 | + $post_adapter->add_references( $post_id, $references ); |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + // Set the publisher. |
|
| 175 | + $this->set_publisher( $jsonld ); |
|
| 176 | + |
|
| 177 | + $references = $this->convert_references( $references ); |
|
| 178 | + |
|
| 179 | + // Process the references if any. |
|
| 180 | + $this->set_mentions_and_about( $references, $post, $jsonld ); |
|
| 181 | + |
|
| 182 | + // Finally set the author. |
|
| 183 | + $jsonld['author'] = $this->get_author( $post->post_author, $references ); |
|
| 184 | + |
|
| 185 | + // Return the JSON-LD if filters are disabled by the client. |
|
| 186 | + if ( $this->disable_convert_filters ) { |
|
| 187 | + return $jsonld; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * Call the `wl_post_jsonld_array` filter. This filter allows 3rd parties to also modify the references. |
|
| 192 | + * |
|
| 193 | + * @param array $value { |
|
| 194 | + * |
|
| 195 | + * @type array $jsonld The JSON-LD structure. |
|
| 196 | + * @type int[] $references An array of post IDs. |
|
| 197 | + * } |
|
| 198 | + * @since 3.25.0 |
|
| 199 | + * |
|
| 200 | + * @see https://www.geeklab.info/2010/04/wordpress-pass-variables-by-reference-with-apply_filter/ |
|
| 201 | + * |
|
| 202 | + * @api |
|
| 203 | + */ |
|
| 204 | + $ret_val = apply_filters( 'wl_post_jsonld_array', array( |
|
| 205 | + 'jsonld' => $jsonld, |
|
| 206 | + 'references' => $references, |
|
| 207 | + ), $post_id ); |
|
| 208 | + |
|
| 209 | + $jsonld = $ret_val['jsonld']; |
|
| 210 | + $references = $ret_val['references']; |
|
| 211 | + |
|
| 212 | + /** |
|
| 213 | + * Call the `wl_post_jsonld` filter. |
|
| 214 | + * |
|
| 215 | + * @param array $jsonld The JSON-LD structure. |
|
| 216 | + * @param int $post_id The {@link WP_Post} `id`. |
|
| 217 | + * @param array $references The array of referenced entities. |
|
| 218 | + * |
|
| 219 | + * @since 3.14.0 |
|
| 220 | + * |
|
| 221 | + * @api |
|
| 222 | + */ |
|
| 223 | + return apply_filters( 'wl_post_jsonld', $jsonld, $post_id, $references ); |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + /** |
|
| 227 | + * Get the author's JSON-LD fragment. |
|
| 228 | + * |
|
| 229 | + * The JSON-LD fragment is generated using the {@link WP_User}'s data or |
|
| 230 | + * the referenced entity if configured for the {@link WP_User}. |
|
| 231 | + * |
|
| 232 | + * @param int $author_id The author {@link WP_User}'s `id`. |
|
| 233 | + * @param array $references An array of referenced entities. |
|
| 234 | + * |
|
| 235 | + * @return string|array A JSON-LD structure. |
|
| 236 | + * @since 3.14.0 |
|
| 237 | + * |
|
| 238 | + */ |
|
| 239 | + public function get_author( $author_id, &$references ) { |
|
| 240 | + |
|
| 241 | + // Get the entity bound to this user. |
|
| 242 | + $entity_id = $this->user_service->get_entity( $author_id ); |
|
| 243 | + |
|
| 244 | + // If there's no entity bound return a simple author structure. |
|
| 245 | + if ( empty( $entity_id ) || 'publish' !== get_post_status( $entity_id ) ) { |
|
| 246 | + |
|
| 247 | + $author = get_the_author_meta( 'display_name', $author_id ); |
|
| 248 | + $author_first_name = get_the_author_meta( 'first_name', $author_id ); |
|
| 249 | + $author_last_name = get_the_author_meta( 'last_name', $author_id ); |
|
| 250 | + $author_uri = $this->user_service->get_uri( $author_id ); |
|
| 251 | + |
|
| 252 | + return array( |
|
| 253 | + '@type' => 'Person', |
|
| 254 | + '@id' => $author_uri, |
|
| 255 | + 'name' => $author, |
|
| 256 | + 'givenName' => $author_first_name, |
|
| 257 | + 'familyName' => $author_last_name, |
|
| 258 | + 'url' => get_author_posts_url( $author_id ), |
|
| 259 | + ); |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + // Add the author to the references. |
|
| 263 | + $author_uri = Wordlift_Entity_Service::get_instance()->get_uri( $entity_id ); |
|
| 264 | + $references[] = $entity_id; |
|
| 265 | + |
|
| 266 | + // Return the JSON-LD for the referenced entity. |
|
| 267 | + return array( |
|
| 268 | + '@id' => $author_uri, |
|
| 269 | + ); |
|
| 270 | + } |
|
| 271 | + |
|
| 272 | + /** |
|
| 273 | + * Enrich the provided params array with publisher data, if available. |
|
| 274 | + * |
|
| 275 | + * @param array $params The parameters array. |
|
| 276 | + * |
|
| 277 | + * @since 3.10.0 |
|
| 278 | + * |
|
| 279 | + */ |
|
| 280 | + protected function set_publisher( &$params ) { |
|
| 281 | + |
|
| 282 | + // If the publisher id isn't set don't do anything. |
|
| 283 | + if ( null === $publisher_id = Wordlift_Configuration_Service::get_instance()->get_publisher_id() ) { |
|
| 284 | + return; |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + // Get the post instance. |
|
| 288 | + if ( null === $post = get_post( $publisher_id ) ) { |
|
| 289 | + // Publisher not found. |
|
| 290 | + return; |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + // Get the item id. |
|
| 294 | + $id = Wordlift_Entity_Service::get_instance()->get_uri( $publisher_id ); |
|
| 295 | + |
|
| 296 | + // Get the type. |
|
| 297 | + $type = $this->entity_type_service->get( $publisher_id ); |
|
| 298 | + |
|
| 299 | + // Get the name. |
|
| 300 | + $name = $post->post_title; |
|
| 301 | + |
|
| 302 | + // Set the publisher data. |
|
| 303 | + $params['publisher'] = array( |
|
| 304 | + '@type' => $this->relative_to_context( $type['uri'] ), |
|
| 305 | + '@id' => $id, |
|
| 306 | + 'name' => $name, |
|
| 307 | + ); |
|
| 308 | + |
|
| 309 | + // Add the sameAs values associated with the publisher. |
|
| 310 | + $storage_factory = Wordlift_Storage_Factory::get_instance(); |
|
| 311 | + $sameas = $storage_factory->post_meta( Wordlift_Schema_Service::FIELD_SAME_AS )->get( $publisher_id ); |
|
| 312 | + if ( ! empty( $sameas ) ) { |
|
| 313 | + $params['publisher']['sameAs'] = $sameas; |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + // Set the logo, only for http://schema.org/Organization as Person doesn't |
|
| 317 | + // support the logo property. |
|
| 318 | + // |
|
| 319 | + // See http://schema.org/logo. |
|
| 320 | + if ( 1 !== preg_match( '~Organization$~', $type['uri'] ) ) { |
|
| 321 | + return; |
|
| 322 | + } |
|
| 323 | + |
|
| 324 | + // Get the publisher logo. |
|
| 325 | + $publisher_logo = $this->get_publisher_logo( $post->ID ); |
|
| 326 | + |
|
| 327 | + // Bail out if the publisher logo isn't set. |
|
| 328 | + if ( false === $publisher_logo ) { |
|
| 329 | + return; |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + // Copy over some useful properties. |
|
| 333 | + // |
|
| 334 | + // See https://developers.google.com/search/docs/data-types/articles. |
|
| 335 | + $params['publisher']['logo']['@type'] = 'ImageObject'; |
|
| 336 | + $params['publisher']['logo']['url'] = $publisher_logo['url']; |
|
| 337 | + |
|
| 338 | + // If you specify a "width" or "height" value you should leave out |
|
| 339 | + // 'px'. For example: "width":"4608px" should be "width":"4608". |
|
| 340 | + // |
|
| 341 | + // See https://github.com/insideout10/wordlift-plugin/issues/451. |
|
| 342 | + $params['publisher']['logo']['width'] = $publisher_logo['width']; |
|
| 343 | + $params['publisher']['logo']['height'] = $publisher_logo['height']; |
|
| 344 | + |
|
| 345 | + } |
|
| 346 | + |
|
| 347 | + /** |
|
| 348 | + * Get the publisher logo structure. |
|
| 349 | + * |
|
| 350 | + * The function returns false when the publisher logo cannot be determined, i.e.: |
|
| 351 | + * - the post has no featured image. |
|
| 352 | + * - the featured image has no file. |
|
| 353 | + * - a wp_image_editor instance cannot be instantiated on the original file or on the publisher logo file. |
|
| 354 | + * |
|
| 355 | + * @param int $post_id The post id. |
|
| 356 | + * |
|
| 357 | + * @return array|false Returns an array with the `url`, `width` and `height` for the publisher logo or false in case |
|
| 358 | + * of errors. |
|
| 359 | + * @since 3.19.2 |
|
| 360 | + * @see https://github.com/insideout10/wordlift-plugin/issues/823 related issue. |
|
| 361 | + * |
|
| 362 | + */ |
|
| 363 | + private function get_publisher_logo( $post_id ) { |
|
| 364 | + |
|
| 365 | + // Get the featured image for the post. |
|
| 366 | + $thumbnail_id = get_post_thumbnail_id( $post_id ); |
|
| 367 | + |
|
| 368 | + // Bail out if thumbnail not available. |
|
| 369 | + if ( empty( $thumbnail_id ) || 0 === $thumbnail_id ) { |
|
| 370 | + $this->log->info( "Featured image not set for post $post_id." ); |
|
| 371 | + |
|
| 372 | + return false; |
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + // Get the uploads base URL. |
|
| 376 | + $uploads_dir = wp_upload_dir(); |
|
| 377 | + |
|
| 378 | + // Get the attachment metadata. |
|
| 379 | + $metadata = wp_get_attachment_metadata( $thumbnail_id ); |
|
| 380 | + |
|
| 381 | + // Bail out if the file isn't set. |
|
| 382 | + if ( ! isset( $metadata['file'] ) ) { |
|
| 383 | + $this->log->warn( "Featured image file not found for post $post_id." ); |
|
| 384 | + |
|
| 385 | + return false; |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + // Retrieve the relative filename, e.g. "2018/05/logo_publisher.png" |
|
| 389 | + $path = $uploads_dir['basedir'] . DIRECTORY_SEPARATOR . $metadata['file']; |
|
| 390 | + |
|
| 391 | + // Use image src, if local file does not exist. @see https://github.com/insideout10/wordlift-plugin/issues/1149 |
|
| 392 | + if ( ! file_exists( $path ) ) { |
|
| 393 | + $this->log->warn( "Featured image file $path doesn't exist for post $post_id." ); |
|
| 394 | + |
|
| 395 | + $attachment_image_src = wp_get_attachment_image_src( $thumbnail_id, '' ); |
|
| 396 | + if ( $attachment_image_src ) { |
|
| 397 | + return array( |
|
| 398 | + 'url' => $attachment_image_src[0], |
|
| 399 | + 'width' => $attachment_image_src[1], |
|
| 400 | + 'height' => $attachment_image_src[2], |
|
| 401 | + ); |
|
| 402 | + } |
|
| 403 | + |
|
| 404 | + // Bail out if we cant fetch wp_get_attachment_image_src |
|
| 405 | + return false; |
|
| 406 | + |
|
| 407 | + } |
|
| 408 | + |
|
| 409 | + // Try to get the image editor and bail out if the editor cannot be instantiated. |
|
| 410 | + $original_file_editor = wp_get_image_editor( $path ); |
|
| 411 | + if ( is_wp_error( $original_file_editor ) ) { |
|
| 412 | + $this->log->warn( "Cannot instantiate WP Image Editor on file $path for post $post_id." ); |
|
| 413 | + |
|
| 414 | + return false; |
|
| 415 | + } |
|
| 416 | + |
|
| 417 | + // Generate the publisher logo filename, we cannot use the `width` and `height` because we're scaling |
|
| 418 | + // and we don't actually know the end values. |
|
| 419 | + $publisher_logo_path = $original_file_editor->generate_filename( '-publisher-logo' ); |
|
| 420 | + |
|
| 421 | + // If the file doesn't exist yet, create it. |
|
| 422 | + if ( ! file_exists( $publisher_logo_path ) ) { |
|
| 423 | + $original_file_editor->resize( 600, 60 ); |
|
| 424 | + $original_file_editor->save( $publisher_logo_path ); |
|
| 425 | + } |
|
| 426 | + |
|
| 427 | + // Try to get the image editor and bail out if the editor cannot be instantiated. |
|
| 428 | + $publisher_logo_editor = wp_get_image_editor( $publisher_logo_path ); |
|
| 429 | + if ( is_wp_error( $publisher_logo_editor ) ) { |
|
| 430 | + $this->log->warn( "Cannot instantiate WP Image Editor on file $publisher_logo_path for post $post_id." ); |
|
| 431 | + |
|
| 432 | + return false; |
|
| 433 | + } |
|
| 434 | + |
|
| 435 | + // Get the actual size. |
|
| 436 | + $size = $publisher_logo_editor->get_size(); |
|
| 437 | + |
|
| 438 | + // Finally return the array with data. |
|
| 439 | + return array( |
|
| 440 | + 'url' => $uploads_dir['baseurl'] . substr( $publisher_logo_path, strlen( $uploads_dir['basedir'] ) ), |
|
| 441 | + 'width' => $size['width'], |
|
| 442 | + 'height' => $size['height'], |
|
| 443 | + ); |
|
| 444 | + } |
|
| 445 | + |
|
| 446 | + /** |
|
| 447 | + * @param $references |
|
| 448 | + * @param $post |
|
| 449 | + * @param $jsonld |
|
| 450 | + * |
|
| 451 | + * @return void |
|
| 452 | + * |
|
| 453 | + */ |
|
| 454 | + private function set_mentions_and_about( $references, $post, &$jsonld ) { |
|
| 455 | + |
|
| 456 | + if ( count( $references ) === 0 ) { |
|
| 457 | + return; |
|
| 458 | + } |
|
| 459 | + |
|
| 460 | + // Prepare the `about` and `mentions` array. |
|
| 461 | + $about = $mentions = array(); |
|
| 462 | + |
|
| 463 | + // If the entity is in the title, then it should be an `about`. |
|
| 464 | + foreach ( $references as $reference ) { |
|
| 465 | + |
|
| 466 | + if ( ! $reference instanceof Reference ) { |
|
| 467 | + // This condition should never be reached. |
|
| 468 | + continue; |
|
| 469 | + } |
|
| 470 | + |
|
| 471 | + // Get the entity labels. |
|
| 472 | + $labels = Wordlift_Entity_Service::get_instance()->get_labels( $reference->get_id(), $reference->get_type() ); |
|
| 473 | + // Get the entity URI. |
|
| 474 | + $item = array( |
|
| 475 | + '@id' => Wordlift_Entity_Service::get_instance()->get_uri( $reference->get_id(), $reference->get_type() ), |
|
| 476 | + ); |
|
| 477 | + |
|
| 478 | + $escaped_labels = array_map( function ( $value ) { |
|
| 479 | + return preg_quote( $value, '/' ); |
|
| 480 | + }, $labels ); |
|
| 481 | + |
|
| 482 | + |
|
| 483 | + $matches = false; |
|
| 484 | + |
|
| 485 | + // When the title is empty, then we shouldn't yield a match to about section. |
|
| 486 | + if ( array_filter( $escaped_labels ) ) { |
|
| 487 | + // Check if the labels match any part of the title. |
|
| 488 | + $matches = 1 === preg_match( '/' . implode( '|', $escaped_labels ) . '/', $post->post_title ); |
|
| 489 | + } |
|
| 490 | + |
|
| 491 | + // If the title matches, assign the entity to the about, otherwise to the mentions. |
|
| 492 | + if ( $matches ) { |
|
| 493 | + $about[] = $item; |
|
| 494 | + } else { |
|
| 495 | + $mentions[] = $item; |
|
| 496 | + } |
|
| 497 | + } |
|
| 498 | + |
|
| 499 | + // If we have abouts, assign them to the JSON-LD. |
|
| 500 | + if ( 0 < count( $about ) ) { |
|
| 501 | + $jsonld['about'] = $about; |
|
| 502 | + } |
|
| 503 | + |
|
| 504 | + // If we have mentions, assign them to the JSON-LD. |
|
| 505 | + if ( 0 < count( $mentions ) ) { |
|
| 506 | + $jsonld['mentions'] = $mentions; |
|
| 507 | + } |
|
| 508 | + |
|
| 509 | + return $jsonld; |
|
| 510 | + } |
|
| 511 | + |
|
| 512 | + /** |
|
| 513 | + * Convert references to abstract data type if we find any. |
|
| 514 | + * |
|
| 515 | + * @param $references array<int|Reference> |
|
| 516 | + * |
|
| 517 | + * @return Reference[] |
|
| 518 | + */ |
|
| 519 | + private function convert_references( $references ) { |
|
| 520 | + return array_map( function ( $reference ) { |
|
| 521 | + // Legacy code may still push numerical references to this |
|
| 522 | + // $references variable, so convert it to post references. |
|
| 523 | + if ( is_numeric( $reference ) ) { |
|
| 524 | + return new Post_Reference( $reference ); |
|
| 525 | + } |
|
| 526 | + |
|
| 527 | + return $reference; |
|
| 528 | + |
|
| 529 | + }, $references ); |
|
| 530 | + } |
|
| 531 | 531 | |
| 532 | 532 | } |
@@ -52,12 +52,12 @@ discard block |
||
| 52 | 52 | * @since 3.10.0 |
| 53 | 53 | * |
| 54 | 54 | */ |
| 55 | - public function __construct( $entity_type_service, $user_service, $attachment_service, $disable_convert_filters = false ) { |
|
| 56 | - parent::__construct( $entity_type_service, $user_service, $attachment_service, Wordlift_Property_Getter_Factory::create() ); |
|
| 55 | + public function __construct($entity_type_service, $user_service, $attachment_service, $disable_convert_filters = false) { |
|
| 56 | + parent::__construct($entity_type_service, $user_service, $attachment_service, Wordlift_Property_Getter_Factory::create()); |
|
| 57 | 57 | $this->disable_convert_filters = $disable_convert_filters; |
| 58 | 58 | $this->object_relation_service = Object_Relation_Service::get_instance(); |
| 59 | 59 | // Set a reference to the logger. |
| 60 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Post_To_Jsonld_Converter' ); |
|
| 60 | + $this->log = Wordlift_Log_Service::get_logger('Wordlift_Post_To_Jsonld_Converter'); |
|
| 61 | 61 | |
| 62 | 62 | self::$instance = $this; |
| 63 | 63 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | public function new_instance_with_filters_disabled() { |
| 72 | - return new static( $this->entity_type_service, $this->user_service, $this->attachment_service, true ); |
|
| 72 | + return new static($this->entity_type_service, $this->user_service, $this->attachment_service, true); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -83,29 +83,29 @@ discard block |
||
| 83 | 83 | * @return array A JSON-LD array. |
| 84 | 84 | * @since 3.10.0 |
| 85 | 85 | */ |
| 86 | - public function convert( $post_id, &$references = array(), &$references_infos = array() ) { |
|
| 86 | + public function convert($post_id, &$references = array(), &$references_infos = array()) { |
|
| 87 | 87 | |
| 88 | 88 | // Get the post instance. |
| 89 | - if ( null === $post = get_post( $post_id ) ) { |
|
| 89 | + if (null === $post = get_post($post_id)) { |
|
| 90 | 90 | // Post not found. |
| 91 | 91 | return null; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | // Get the base JSON-LD and the list of entities referenced by this entity. |
| 95 | - $jsonld = parent::convert( $post_id, $references, $references_infos ); |
|
| 95 | + $jsonld = parent::convert($post_id, $references, $references_infos); |
|
| 96 | 96 | |
| 97 | 97 | // Set WebPage by default. |
| 98 | - if ( empty( $jsonld['@type'] ) ) { |
|
| 98 | + if (empty($jsonld['@type'])) { |
|
| 99 | 99 | $jsonld['@type'] = 'WebPage'; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | // Get the entity name. |
| 103 | 103 | $jsonld['headline'] = $post->post_title; |
| 104 | 104 | |
| 105 | - $custom_fields = $this->entity_type_service->get_custom_fields_for_post( $post_id ); |
|
| 105 | + $custom_fields = $this->entity_type_service->get_custom_fields_for_post($post_id); |
|
| 106 | 106 | |
| 107 | - if ( isset( $custom_fields ) ) { |
|
| 108 | - $this->process_type_custom_fields( $jsonld, $custom_fields, $post, $references, $references_infos ); |
|
| 107 | + if (isset($custom_fields)) { |
|
| 108 | + $this->process_type_custom_fields($jsonld, $custom_fields, $post, $references, $references_infos); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | // Set the published and modified dates. |
@@ -118,19 +118,19 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | try { |
| 120 | 120 | $default_timezone = date_default_timezone_get(); |
| 121 | - $timezone = get_option( 'timezone_string' ); |
|
| 122 | - if ( ! empty( $timezone ) ) { |
|
| 123 | - date_default_timezone_set( $timezone ); |
|
| 124 | - $jsonld['datePublished'] = get_post_time( 'Y-m-d\TH:i:sP', false, $post ); |
|
| 125 | - $jsonld['dateModified'] = get_post_modified_time( 'Y-m-d\TH:i:sP', false, $post ); |
|
| 126 | - date_default_timezone_set( $default_timezone ); |
|
| 121 | + $timezone = get_option('timezone_string'); |
|
| 122 | + if ( ! empty($timezone)) { |
|
| 123 | + date_default_timezone_set($timezone); |
|
| 124 | + $jsonld['datePublished'] = get_post_time('Y-m-d\TH:i:sP', false, $post); |
|
| 125 | + $jsonld['dateModified'] = get_post_modified_time('Y-m-d\TH:i:sP', false, $post); |
|
| 126 | + date_default_timezone_set($default_timezone); |
|
| 127 | 127 | } else { |
| 128 | - $jsonld['datePublished'] = get_post_time( 'Y-m-d\TH:i', true, $post, false ); |
|
| 129 | - $jsonld['dateModified'] = get_post_modified_time( 'Y-m-d\TH:i', true, $post, false ); |
|
| 128 | + $jsonld['datePublished'] = get_post_time('Y-m-d\TH:i', true, $post, false); |
|
| 129 | + $jsonld['dateModified'] = get_post_modified_time('Y-m-d\TH:i', true, $post, false); |
|
| 130 | 130 | } |
| 131 | - } catch ( Exception $e ) { |
|
| 132 | - $jsonld['datePublished'] = get_post_time( 'Y-m-d\TH:i', true, $post, false ); |
|
| 133 | - $jsonld['dateModified'] = get_post_modified_time( 'Y-m-d\TH:i', true, $post, false ); |
|
| 131 | + } catch (Exception $e) { |
|
| 132 | + $jsonld['datePublished'] = get_post_time('Y-m-d\TH:i', true, $post, false); |
|
| 133 | + $jsonld['dateModified'] = get_post_modified_time('Y-m-d\TH:i', true, $post, false); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // Get the word count for the post. |
@@ -141,8 +141,8 @@ discard block |
||
| 141 | 141 | * |
| 142 | 142 | * @since 3.20.0 |
| 143 | 143 | */ |
| 144 | - if ( ! empty( $jsonld['@type'] ) && 'WebPage' !== $jsonld['@type'] ) { |
|
| 145 | - $post_adapter = new Wordlift_Post_Adapter( $post_id ); |
|
| 144 | + if ( ! empty($jsonld['@type']) && 'WebPage' !== $jsonld['@type']) { |
|
| 145 | + $post_adapter = new Wordlift_Post_Adapter($post_id); |
|
| 146 | 146 | $jsonld['wordCount'] = $post_adapter->word_count(); |
| 147 | 147 | } |
| 148 | 148 | |
@@ -153,37 +153,37 @@ discard block |
||
| 153 | 153 | * |
| 154 | 154 | * @since 3.27.2 |
| 155 | 155 | */ |
| 156 | - if ( ! empty( $jsonld['@type'] ) && 'WebPage' !== $jsonld['@type'] ) { |
|
| 157 | - $post_adapter = new Wordlift_Post_Adapter( $post_id ); |
|
| 156 | + if ( ! empty($jsonld['@type']) && 'WebPage' !== $jsonld['@type']) { |
|
| 157 | + $post_adapter = new Wordlift_Post_Adapter($post_id); |
|
| 158 | 158 | $keywords = $post_adapter->keywords(); |
| 159 | 159 | $article_section = $post_adapter->article_section(); |
| 160 | 160 | $comment_count = $post_adapter->comment_count(); |
| 161 | 161 | $locale = $post_adapter->locale(); |
| 162 | 162 | |
| 163 | - if ( isset( $keywords ) ) { |
|
| 163 | + if (isset($keywords)) { |
|
| 164 | 164 | $jsonld['keywords'] = $keywords; |
| 165 | 165 | } |
| 166 | - if ( ! empty( $article_section ) ) { |
|
| 166 | + if ( ! empty($article_section)) { |
|
| 167 | 167 | $jsonld['articleSection'] = $article_section; |
| 168 | 168 | } |
| 169 | 169 | $jsonld['commentCount'] = $comment_count; |
| 170 | 170 | $jsonld['inLanguage'] = $locale; |
| 171 | - $post_adapter->add_references( $post_id, $references ); |
|
| 171 | + $post_adapter->add_references($post_id, $references); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | // Set the publisher. |
| 175 | - $this->set_publisher( $jsonld ); |
|
| 175 | + $this->set_publisher($jsonld); |
|
| 176 | 176 | |
| 177 | - $references = $this->convert_references( $references ); |
|
| 177 | + $references = $this->convert_references($references); |
|
| 178 | 178 | |
| 179 | 179 | // Process the references if any. |
| 180 | - $this->set_mentions_and_about( $references, $post, $jsonld ); |
|
| 180 | + $this->set_mentions_and_about($references, $post, $jsonld); |
|
| 181 | 181 | |
| 182 | 182 | // Finally set the author. |
| 183 | - $jsonld['author'] = $this->get_author( $post->post_author, $references ); |
|
| 183 | + $jsonld['author'] = $this->get_author($post->post_author, $references); |
|
| 184 | 184 | |
| 185 | 185 | // Return the JSON-LD if filters are disabled by the client. |
| 186 | - if ( $this->disable_convert_filters ) { |
|
| 186 | + if ($this->disable_convert_filters) { |
|
| 187 | 187 | return $jsonld; |
| 188 | 188 | } |
| 189 | 189 | |
@@ -201,10 +201,10 @@ discard block |
||
| 201 | 201 | * |
| 202 | 202 | * @api |
| 203 | 203 | */ |
| 204 | - $ret_val = apply_filters( 'wl_post_jsonld_array', array( |
|
| 204 | + $ret_val = apply_filters('wl_post_jsonld_array', array( |
|
| 205 | 205 | 'jsonld' => $jsonld, |
| 206 | 206 | 'references' => $references, |
| 207 | - ), $post_id ); |
|
| 207 | + ), $post_id); |
|
| 208 | 208 | |
| 209 | 209 | $jsonld = $ret_val['jsonld']; |
| 210 | 210 | $references = $ret_val['references']; |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | * |
| 221 | 221 | * @api |
| 222 | 222 | */ |
| 223 | - return apply_filters( 'wl_post_jsonld', $jsonld, $post_id, $references ); |
|
| 223 | + return apply_filters('wl_post_jsonld', $jsonld, $post_id, $references); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
@@ -236,18 +236,18 @@ discard block |
||
| 236 | 236 | * @since 3.14.0 |
| 237 | 237 | * |
| 238 | 238 | */ |
| 239 | - public function get_author( $author_id, &$references ) { |
|
| 239 | + public function get_author($author_id, &$references) { |
|
| 240 | 240 | |
| 241 | 241 | // Get the entity bound to this user. |
| 242 | - $entity_id = $this->user_service->get_entity( $author_id ); |
|
| 242 | + $entity_id = $this->user_service->get_entity($author_id); |
|
| 243 | 243 | |
| 244 | 244 | // If there's no entity bound return a simple author structure. |
| 245 | - if ( empty( $entity_id ) || 'publish' !== get_post_status( $entity_id ) ) { |
|
| 245 | + if (empty($entity_id) || 'publish' !== get_post_status($entity_id)) { |
|
| 246 | 246 | |
| 247 | - $author = get_the_author_meta( 'display_name', $author_id ); |
|
| 248 | - $author_first_name = get_the_author_meta( 'first_name', $author_id ); |
|
| 249 | - $author_last_name = get_the_author_meta( 'last_name', $author_id ); |
|
| 250 | - $author_uri = $this->user_service->get_uri( $author_id ); |
|
| 247 | + $author = get_the_author_meta('display_name', $author_id); |
|
| 248 | + $author_first_name = get_the_author_meta('first_name', $author_id); |
|
| 249 | + $author_last_name = get_the_author_meta('last_name', $author_id); |
|
| 250 | + $author_uri = $this->user_service->get_uri($author_id); |
|
| 251 | 251 | |
| 252 | 252 | return array( |
| 253 | 253 | '@type' => 'Person', |
@@ -255,12 +255,12 @@ discard block |
||
| 255 | 255 | 'name' => $author, |
| 256 | 256 | 'givenName' => $author_first_name, |
| 257 | 257 | 'familyName' => $author_last_name, |
| 258 | - 'url' => get_author_posts_url( $author_id ), |
|
| 258 | + 'url' => get_author_posts_url($author_id), |
|
| 259 | 259 | ); |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | // Add the author to the references. |
| 263 | - $author_uri = Wordlift_Entity_Service::get_instance()->get_uri( $entity_id ); |
|
| 263 | + $author_uri = Wordlift_Entity_Service::get_instance()->get_uri($entity_id); |
|
| 264 | 264 | $references[] = $entity_id; |
| 265 | 265 | |
| 266 | 266 | // Return the JSON-LD for the referenced entity. |
@@ -277,39 +277,39 @@ discard block |
||
| 277 | 277 | * @since 3.10.0 |
| 278 | 278 | * |
| 279 | 279 | */ |
| 280 | - protected function set_publisher( &$params ) { |
|
| 280 | + protected function set_publisher(&$params) { |
|
| 281 | 281 | |
| 282 | 282 | // If the publisher id isn't set don't do anything. |
| 283 | - if ( null === $publisher_id = Wordlift_Configuration_Service::get_instance()->get_publisher_id() ) { |
|
| 283 | + if (null === $publisher_id = Wordlift_Configuration_Service::get_instance()->get_publisher_id()) { |
|
| 284 | 284 | return; |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | // Get the post instance. |
| 288 | - if ( null === $post = get_post( $publisher_id ) ) { |
|
| 288 | + if (null === $post = get_post($publisher_id)) { |
|
| 289 | 289 | // Publisher not found. |
| 290 | 290 | return; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | // Get the item id. |
| 294 | - $id = Wordlift_Entity_Service::get_instance()->get_uri( $publisher_id ); |
|
| 294 | + $id = Wordlift_Entity_Service::get_instance()->get_uri($publisher_id); |
|
| 295 | 295 | |
| 296 | 296 | // Get the type. |
| 297 | - $type = $this->entity_type_service->get( $publisher_id ); |
|
| 297 | + $type = $this->entity_type_service->get($publisher_id); |
|
| 298 | 298 | |
| 299 | 299 | // Get the name. |
| 300 | 300 | $name = $post->post_title; |
| 301 | 301 | |
| 302 | 302 | // Set the publisher data. |
| 303 | 303 | $params['publisher'] = array( |
| 304 | - '@type' => $this->relative_to_context( $type['uri'] ), |
|
| 304 | + '@type' => $this->relative_to_context($type['uri']), |
|
| 305 | 305 | '@id' => $id, |
| 306 | 306 | 'name' => $name, |
| 307 | 307 | ); |
| 308 | 308 | |
| 309 | 309 | // Add the sameAs values associated with the publisher. |
| 310 | 310 | $storage_factory = Wordlift_Storage_Factory::get_instance(); |
| 311 | - $sameas = $storage_factory->post_meta( Wordlift_Schema_Service::FIELD_SAME_AS )->get( $publisher_id ); |
|
| 312 | - if ( ! empty( $sameas ) ) { |
|
| 311 | + $sameas = $storage_factory->post_meta(Wordlift_Schema_Service::FIELD_SAME_AS)->get($publisher_id); |
|
| 312 | + if ( ! empty($sameas)) { |
|
| 313 | 313 | $params['publisher']['sameAs'] = $sameas; |
| 314 | 314 | } |
| 315 | 315 | |
@@ -317,15 +317,15 @@ discard block |
||
| 317 | 317 | // support the logo property. |
| 318 | 318 | // |
| 319 | 319 | // See http://schema.org/logo. |
| 320 | - if ( 1 !== preg_match( '~Organization$~', $type['uri'] ) ) { |
|
| 320 | + if (1 !== preg_match('~Organization$~', $type['uri'])) { |
|
| 321 | 321 | return; |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | // Get the publisher logo. |
| 325 | - $publisher_logo = $this->get_publisher_logo( $post->ID ); |
|
| 325 | + $publisher_logo = $this->get_publisher_logo($post->ID); |
|
| 326 | 326 | |
| 327 | 327 | // Bail out if the publisher logo isn't set. |
| 328 | - if ( false === $publisher_logo ) { |
|
| 328 | + if (false === $publisher_logo) { |
|
| 329 | 329 | return; |
| 330 | 330 | } |
| 331 | 331 | |
@@ -360,14 +360,14 @@ discard block |
||
| 360 | 360 | * @see https://github.com/insideout10/wordlift-plugin/issues/823 related issue. |
| 361 | 361 | * |
| 362 | 362 | */ |
| 363 | - private function get_publisher_logo( $post_id ) { |
|
| 363 | + private function get_publisher_logo($post_id) { |
|
| 364 | 364 | |
| 365 | 365 | // Get the featured image for the post. |
| 366 | - $thumbnail_id = get_post_thumbnail_id( $post_id ); |
|
| 366 | + $thumbnail_id = get_post_thumbnail_id($post_id); |
|
| 367 | 367 | |
| 368 | 368 | // Bail out if thumbnail not available. |
| 369 | - if ( empty( $thumbnail_id ) || 0 === $thumbnail_id ) { |
|
| 370 | - $this->log->info( "Featured image not set for post $post_id." ); |
|
| 369 | + if (empty($thumbnail_id) || 0 === $thumbnail_id) { |
|
| 370 | + $this->log->info("Featured image not set for post $post_id."); |
|
| 371 | 371 | |
| 372 | 372 | return false; |
| 373 | 373 | } |
@@ -376,24 +376,24 @@ discard block |
||
| 376 | 376 | $uploads_dir = wp_upload_dir(); |
| 377 | 377 | |
| 378 | 378 | // Get the attachment metadata. |
| 379 | - $metadata = wp_get_attachment_metadata( $thumbnail_id ); |
|
| 379 | + $metadata = wp_get_attachment_metadata($thumbnail_id); |
|
| 380 | 380 | |
| 381 | 381 | // Bail out if the file isn't set. |
| 382 | - if ( ! isset( $metadata['file'] ) ) { |
|
| 383 | - $this->log->warn( "Featured image file not found for post $post_id." ); |
|
| 382 | + if ( ! isset($metadata['file'])) { |
|
| 383 | + $this->log->warn("Featured image file not found for post $post_id."); |
|
| 384 | 384 | |
| 385 | 385 | return false; |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | // Retrieve the relative filename, e.g. "2018/05/logo_publisher.png" |
| 389 | - $path = $uploads_dir['basedir'] . DIRECTORY_SEPARATOR . $metadata['file']; |
|
| 389 | + $path = $uploads_dir['basedir'].DIRECTORY_SEPARATOR.$metadata['file']; |
|
| 390 | 390 | |
| 391 | 391 | // Use image src, if local file does not exist. @see https://github.com/insideout10/wordlift-plugin/issues/1149 |
| 392 | - if ( ! file_exists( $path ) ) { |
|
| 393 | - $this->log->warn( "Featured image file $path doesn't exist for post $post_id." ); |
|
| 392 | + if ( ! file_exists($path)) { |
|
| 393 | + $this->log->warn("Featured image file $path doesn't exist for post $post_id."); |
|
| 394 | 394 | |
| 395 | - $attachment_image_src = wp_get_attachment_image_src( $thumbnail_id, '' ); |
|
| 396 | - if ( $attachment_image_src ) { |
|
| 395 | + $attachment_image_src = wp_get_attachment_image_src($thumbnail_id, ''); |
|
| 396 | + if ($attachment_image_src) { |
|
| 397 | 397 | return array( |
| 398 | 398 | 'url' => $attachment_image_src[0], |
| 399 | 399 | 'width' => $attachment_image_src[1], |
@@ -407,27 +407,27 @@ discard block |
||
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | // Try to get the image editor and bail out if the editor cannot be instantiated. |
| 410 | - $original_file_editor = wp_get_image_editor( $path ); |
|
| 411 | - if ( is_wp_error( $original_file_editor ) ) { |
|
| 412 | - $this->log->warn( "Cannot instantiate WP Image Editor on file $path for post $post_id." ); |
|
| 410 | + $original_file_editor = wp_get_image_editor($path); |
|
| 411 | + if (is_wp_error($original_file_editor)) { |
|
| 412 | + $this->log->warn("Cannot instantiate WP Image Editor on file $path for post $post_id."); |
|
| 413 | 413 | |
| 414 | 414 | return false; |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | // Generate the publisher logo filename, we cannot use the `width` and `height` because we're scaling |
| 418 | 418 | // and we don't actually know the end values. |
| 419 | - $publisher_logo_path = $original_file_editor->generate_filename( '-publisher-logo' ); |
|
| 419 | + $publisher_logo_path = $original_file_editor->generate_filename('-publisher-logo'); |
|
| 420 | 420 | |
| 421 | 421 | // If the file doesn't exist yet, create it. |
| 422 | - if ( ! file_exists( $publisher_logo_path ) ) { |
|
| 423 | - $original_file_editor->resize( 600, 60 ); |
|
| 424 | - $original_file_editor->save( $publisher_logo_path ); |
|
| 422 | + if ( ! file_exists($publisher_logo_path)) { |
|
| 423 | + $original_file_editor->resize(600, 60); |
|
| 424 | + $original_file_editor->save($publisher_logo_path); |
|
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | // Try to get the image editor and bail out if the editor cannot be instantiated. |
| 428 | - $publisher_logo_editor = wp_get_image_editor( $publisher_logo_path ); |
|
| 429 | - if ( is_wp_error( $publisher_logo_editor ) ) { |
|
| 430 | - $this->log->warn( "Cannot instantiate WP Image Editor on file $publisher_logo_path for post $post_id." ); |
|
| 428 | + $publisher_logo_editor = wp_get_image_editor($publisher_logo_path); |
|
| 429 | + if (is_wp_error($publisher_logo_editor)) { |
|
| 430 | + $this->log->warn("Cannot instantiate WP Image Editor on file $publisher_logo_path for post $post_id."); |
|
| 431 | 431 | |
| 432 | 432 | return false; |
| 433 | 433 | } |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | |
| 438 | 438 | // Finally return the array with data. |
| 439 | 439 | return array( |
| 440 | - 'url' => $uploads_dir['baseurl'] . substr( $publisher_logo_path, strlen( $uploads_dir['basedir'] ) ), |
|
| 440 | + 'url' => $uploads_dir['baseurl'].substr($publisher_logo_path, strlen($uploads_dir['basedir'])), |
|
| 441 | 441 | 'width' => $size['width'], |
| 442 | 442 | 'height' => $size['height'], |
| 443 | 443 | ); |
@@ -451,9 +451,9 @@ discard block |
||
| 451 | 451 | * @return void |
| 452 | 452 | * |
| 453 | 453 | */ |
| 454 | - private function set_mentions_and_about( $references, $post, &$jsonld ) { |
|
| 454 | + private function set_mentions_and_about($references, $post, &$jsonld) { |
|
| 455 | 455 | |
| 456 | - if ( count( $references ) === 0 ) { |
|
| 456 | + if (count($references) === 0) { |
|
| 457 | 457 | return; |
| 458 | 458 | } |
| 459 | 459 | |
@@ -461,35 +461,35 @@ discard block |
||
| 461 | 461 | $about = $mentions = array(); |
| 462 | 462 | |
| 463 | 463 | // If the entity is in the title, then it should be an `about`. |
| 464 | - foreach ( $references as $reference ) { |
|
| 464 | + foreach ($references as $reference) { |
|
| 465 | 465 | |
| 466 | - if ( ! $reference instanceof Reference ) { |
|
| 466 | + if ( ! $reference instanceof Reference) { |
|
| 467 | 467 | // This condition should never be reached. |
| 468 | 468 | continue; |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | // Get the entity labels. |
| 472 | - $labels = Wordlift_Entity_Service::get_instance()->get_labels( $reference->get_id(), $reference->get_type() ); |
|
| 472 | + $labels = Wordlift_Entity_Service::get_instance()->get_labels($reference->get_id(), $reference->get_type()); |
|
| 473 | 473 | // Get the entity URI. |
| 474 | 474 | $item = array( |
| 475 | - '@id' => Wordlift_Entity_Service::get_instance()->get_uri( $reference->get_id(), $reference->get_type() ), |
|
| 475 | + '@id' => Wordlift_Entity_Service::get_instance()->get_uri($reference->get_id(), $reference->get_type()), |
|
| 476 | 476 | ); |
| 477 | 477 | |
| 478 | - $escaped_labels = array_map( function ( $value ) { |
|
| 479 | - return preg_quote( $value, '/' ); |
|
| 480 | - }, $labels ); |
|
| 478 | + $escaped_labels = array_map(function($value) { |
|
| 479 | + return preg_quote($value, '/'); |
|
| 480 | + }, $labels); |
|
| 481 | 481 | |
| 482 | 482 | |
| 483 | 483 | $matches = false; |
| 484 | 484 | |
| 485 | 485 | // When the title is empty, then we shouldn't yield a match to about section. |
| 486 | - if ( array_filter( $escaped_labels ) ) { |
|
| 486 | + if (array_filter($escaped_labels)) { |
|
| 487 | 487 | // Check if the labels match any part of the title. |
| 488 | - $matches = 1 === preg_match( '/' . implode( '|', $escaped_labels ) . '/', $post->post_title ); |
|
| 488 | + $matches = 1 === preg_match('/'.implode('|', $escaped_labels).'/', $post->post_title); |
|
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | // If the title matches, assign the entity to the about, otherwise to the mentions. |
| 492 | - if ( $matches ) { |
|
| 492 | + if ($matches) { |
|
| 493 | 493 | $about[] = $item; |
| 494 | 494 | } else { |
| 495 | 495 | $mentions[] = $item; |
@@ -497,12 +497,12 @@ discard block |
||
| 497 | 497 | } |
| 498 | 498 | |
| 499 | 499 | // If we have abouts, assign them to the JSON-LD. |
| 500 | - if ( 0 < count( $about ) ) { |
|
| 500 | + if (0 < count($about)) { |
|
| 501 | 501 | $jsonld['about'] = $about; |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | // If we have mentions, assign them to the JSON-LD. |
| 505 | - if ( 0 < count( $mentions ) ) { |
|
| 505 | + if (0 < count($mentions)) { |
|
| 506 | 506 | $jsonld['mentions'] = $mentions; |
| 507 | 507 | } |
| 508 | 508 | |
@@ -516,17 +516,17 @@ discard block |
||
| 516 | 516 | * |
| 517 | 517 | * @return Reference[] |
| 518 | 518 | */ |
| 519 | - private function convert_references( $references ) { |
|
| 520 | - return array_map( function ( $reference ) { |
|
| 519 | + private function convert_references($references) { |
|
| 520 | + return array_map(function($reference) { |
|
| 521 | 521 | // Legacy code may still push numerical references to this |
| 522 | 522 | // $references variable, so convert it to post references. |
| 523 | - if ( is_numeric( $reference ) ) { |
|
| 524 | - return new Post_Reference( $reference ); |
|
| 523 | + if (is_numeric($reference)) { |
|
| 524 | + return new Post_Reference($reference); |
|
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | return $reference; |
| 528 | 528 | |
| 529 | - }, $references ); |
|
| 529 | + }, $references); |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | } |