@@ -11,17 +11,17 @@ discard block |
||
| 11 | 11 | * @since 3.27.6 |
| 12 | 12 | */ |
| 13 | 13 | function wl_ajax_analyze_disabled_action() { |
| 14 | - // adding the below header for debugging purpose. |
|
| 15 | - if ( ! headers_sent() ) { |
|
| 16 | - header( 'X-WordLift-Analysis: OFF' ); |
|
| 17 | - } |
|
| 18 | - wp_send_json_success( |
|
| 19 | - array( |
|
| 20 | - 'entities' => array(), |
|
| 21 | - 'annotations' => array(), |
|
| 22 | - 'topics' => array(), |
|
| 23 | - ) |
|
| 24 | - ); |
|
| 14 | + // adding the below header for debugging purpose. |
|
| 15 | + if ( ! headers_sent() ) { |
|
| 16 | + header( 'X-WordLift-Analysis: OFF' ); |
|
| 17 | + } |
|
| 18 | + wp_send_json_success( |
|
| 19 | + array( |
|
| 20 | + 'entities' => array(), |
|
| 21 | + 'annotations' => array(), |
|
| 22 | + 'topics' => array(), |
|
| 23 | + ) |
|
| 24 | + ); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -35,13 +35,13 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | function wl_ajax_analyze_action() { |
| 37 | 37 | |
| 38 | - check_admin_referer( 'wl_analyze' ); |
|
| 38 | + check_admin_referer( 'wl_analyze' ); |
|
| 39 | 39 | |
| 40 | - // If you use `filter_input` here, `Ajax_Content_Analysis_Test` would fail because `filter_input` doesn't use |
|
| 41 | - // `$_POST`. |
|
| 42 | - $data = $_POST['data']; |
|
| 40 | + // If you use `filter_input` here, `Ajax_Content_Analysis_Test` would fail because `filter_input` doesn't use |
|
| 41 | + // `$_POST`. |
|
| 42 | + $data = $_POST['data']; |
|
| 43 | 43 | |
| 44 | - wp_send_json_success( wl_analyze_content( $data, 'application/json; charset=' . strtolower( get_bloginfo( 'charset' ) ) ) ); |
|
| 44 | + wp_send_json_success( wl_analyze_content( $data, 'application/json; charset=' . strtolower( get_bloginfo( 'charset' ) ) ) ); |
|
| 45 | 45 | |
| 46 | 46 | } |
| 47 | 47 | |
@@ -63,74 +63,74 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | function wl_analyze_content( $data, $content_type ) { |
| 65 | 65 | |
| 66 | - $default_response = json_decode( '{ "entities": {}, "annotations": {}, "topics": {} }' ); |
|
| 67 | - $request_body = json_decode( $data, true ); |
|
| 68 | - $post_id = isset( $_REQUEST['postId'] ) ? intval( $_REQUEST['postId'] ) : 0; |
|
| 69 | - if ( $request_body === null ) { |
|
| 70 | - /** |
|
| 71 | - * @since 3.27.7 |
|
| 72 | - * |
|
| 73 | - * Conditionally try using stripslashes as $_POST['data'] could be escaped |
|
| 74 | - */ |
|
| 75 | - $request_body = json_decode( stripslashes( $data ), true ); |
|
| 76 | - } |
|
| 77 | - $request_body['contentLanguage'] = Wordlift_Configuration_Service::get_instance()->get_language_code(); |
|
| 78 | - $excluded_uris = array_key_exists( 'exclude', $request_body ) ? (array) $request_body['exclude'] : array(); |
|
| 79 | - $data = wp_json_encode( $request_body ); |
|
| 80 | - |
|
| 81 | - // If dataset is not enabled, return a locally prepared response without analysis API. |
|
| 82 | - if ( ! apply_filters( 'wl_features__enable__dataset', true ) ) { |
|
| 83 | - |
|
| 84 | - return Analysis_Response_Ops_Factory::get_instance() |
|
| 85 | - ->create( $default_response, $post_id ) |
|
| 86 | - ->make_entities_local() |
|
| 87 | - ->add_occurrences( $request_body['content'] ) |
|
| 88 | - ->add_local_entities() |
|
| 89 | - ->get_json(); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - add_filter( 'wl_api_service_api_url_path', 'wl_use_analysis_on_api_wordlift_io' ); |
|
| 93 | - |
|
| 94 | - |
|
| 95 | - $json = Analysis_Service_Factory::get_instance( $post_id ) |
|
| 96 | - ->get_analysis_response( $data, $content_type, $post_id ); |
|
| 97 | - |
|
| 98 | - remove_filter( 'wl_api_service_api_url_path', 'wl_use_analysis_on_api_wordlift_io' ); |
|
| 99 | - |
|
| 100 | - // If it's an error log it. |
|
| 101 | - if ( is_wp_error( $json ) ) { |
|
| 102 | - return Analysis_Response_Ops_Factory::get_instance() |
|
| 103 | - ->create( $default_response, $post_id ) |
|
| 104 | - ->make_entities_local() |
|
| 105 | - ->add_occurrences( $request_body['content'] ) |
|
| 106 | - ->get_json(); |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - /* |
|
| 66 | + $default_response = json_decode( '{ "entities": {}, "annotations": {}, "topics": {} }' ); |
|
| 67 | + $request_body = json_decode( $data, true ); |
|
| 68 | + $post_id = isset( $_REQUEST['postId'] ) ? intval( $_REQUEST['postId'] ) : 0; |
|
| 69 | + if ( $request_body === null ) { |
|
| 70 | + /** |
|
| 71 | + * @since 3.27.7 |
|
| 72 | + * |
|
| 73 | + * Conditionally try using stripslashes as $_POST['data'] could be escaped |
|
| 74 | + */ |
|
| 75 | + $request_body = json_decode( stripslashes( $data ), true ); |
|
| 76 | + } |
|
| 77 | + $request_body['contentLanguage'] = Wordlift_Configuration_Service::get_instance()->get_language_code(); |
|
| 78 | + $excluded_uris = array_key_exists( 'exclude', $request_body ) ? (array) $request_body['exclude'] : array(); |
|
| 79 | + $data = wp_json_encode( $request_body ); |
|
| 80 | + |
|
| 81 | + // If dataset is not enabled, return a locally prepared response without analysis API. |
|
| 82 | + if ( ! apply_filters( 'wl_features__enable__dataset', true ) ) { |
|
| 83 | + |
|
| 84 | + return Analysis_Response_Ops_Factory::get_instance() |
|
| 85 | + ->create( $default_response, $post_id ) |
|
| 86 | + ->make_entities_local() |
|
| 87 | + ->add_occurrences( $request_body['content'] ) |
|
| 88 | + ->add_local_entities() |
|
| 89 | + ->get_json(); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + add_filter( 'wl_api_service_api_url_path', 'wl_use_analysis_on_api_wordlift_io' ); |
|
| 93 | + |
|
| 94 | + |
|
| 95 | + $json = Analysis_Service_Factory::get_instance( $post_id ) |
|
| 96 | + ->get_analysis_response( $data, $content_type, $post_id ); |
|
| 97 | + |
|
| 98 | + remove_filter( 'wl_api_service_api_url_path', 'wl_use_analysis_on_api_wordlift_io' ); |
|
| 99 | + |
|
| 100 | + // If it's an error log it. |
|
| 101 | + if ( is_wp_error( $json ) ) { |
|
| 102 | + return Analysis_Response_Ops_Factory::get_instance() |
|
| 103 | + ->create( $default_response, $post_id ) |
|
| 104 | + ->make_entities_local() |
|
| 105 | + ->add_occurrences( $request_body['content'] ) |
|
| 106 | + ->get_json(); |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + /* |
|
| 110 | 110 | * We pass the response to the Analysis_Response_Ops to ensure that we make remote entities local. |
| 111 | 111 | * |
| 112 | 112 | * @see https://github.com/insideout10/wordlift-plugin/issues/944 |
| 113 | 113 | * @since 3.21.5 |
| 114 | 114 | */ |
| 115 | 115 | |
| 116 | - // Get the actual content sent to the analysis, so that we can pass it to the Analysis_Response_Ops to populate |
|
| 117 | - // the occurrences for the local entities. |
|
| 118 | - if ( 0 === strpos( $content_type, 'application/json' ) ) { |
|
| 119 | - $request_content = $request_body['content']; |
|
| 120 | - } else { |
|
| 121 | - $request_content = $data; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return Analysis_Response_Ops_Factory::get_instance() |
|
| 125 | - ->create( $json, $post_id ) |
|
| 126 | - ->make_entities_local() |
|
| 127 | - ->remove_excluded_entities( $excluded_uris ) |
|
| 128 | - ->add_occurrences( $request_content ) |
|
| 129 | - ->get_json(); |
|
| 116 | + // Get the actual content sent to the analysis, so that we can pass it to the Analysis_Response_Ops to populate |
|
| 117 | + // the occurrences for the local entities. |
|
| 118 | + if ( 0 === strpos( $content_type, 'application/json' ) ) { |
|
| 119 | + $request_content = $request_body['content']; |
|
| 120 | + } else { |
|
| 121 | + $request_content = $data; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + return Analysis_Response_Ops_Factory::get_instance() |
|
| 125 | + ->create( $json, $post_id ) |
|
| 126 | + ->make_entities_local() |
|
| 127 | + ->remove_excluded_entities( $excluded_uris ) |
|
| 128 | + ->add_occurrences( $request_content ) |
|
| 129 | + ->get_json(); |
|
| 130 | 130 | |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | function wl_use_analysis_on_api_wordlift_io( $value ) { |
| 134 | 134 | |
| 135 | - return preg_replace( '|https://api\.wordlift\.it/|', apply_filters( 'wl_api_base_url', 'https://api.wordlift.io' ) . '/', $value ); |
|
| 135 | + return preg_replace( '|https://api\.wordlift\.it/|', apply_filters( 'wl_api_base_url', 'https://api.wordlift.io' ) . '/', $value ); |
|
| 136 | 136 | } |
@@ -12,8 +12,8 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | function wl_ajax_analyze_disabled_action() { |
| 14 | 14 | // adding the below header for debugging purpose. |
| 15 | - if ( ! headers_sent() ) { |
|
| 16 | - header( 'X-WordLift-Analysis: OFF' ); |
|
| 15 | + if ( ! headers_sent()) { |
|
| 16 | + header('X-WordLift-Analysis: OFF'); |
|
| 17 | 17 | } |
| 18 | 18 | wp_send_json_success( |
| 19 | 19 | array( |
@@ -35,13 +35,13 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | function wl_ajax_analyze_action() { |
| 37 | 37 | |
| 38 | - check_admin_referer( 'wl_analyze' ); |
|
| 38 | + check_admin_referer('wl_analyze'); |
|
| 39 | 39 | |
| 40 | 40 | // If you use `filter_input` here, `Ajax_Content_Analysis_Test` would fail because `filter_input` doesn't use |
| 41 | 41 | // `$_POST`. |
| 42 | 42 | $data = $_POST['data']; |
| 43 | 43 | |
| 44 | - wp_send_json_success( wl_analyze_content( $data, 'application/json; charset=' . strtolower( get_bloginfo( 'charset' ) ) ) ); |
|
| 44 | + wp_send_json_success(wl_analyze_content($data, 'application/json; charset='.strtolower(get_bloginfo('charset')))); |
|
| 45 | 45 | |
| 46 | 46 | } |
| 47 | 47 | |
@@ -61,48 +61,48 @@ discard block |
||
| 61 | 61 | * @since 3.24.2 We don't return an error anymore, but an empty analysis response. This is required to allow the editor |
| 62 | 62 | * to manage entities or to manually add them even when analysis isn't available. |
| 63 | 63 | */ |
| 64 | -function wl_analyze_content( $data, $content_type ) { |
|
| 64 | +function wl_analyze_content($data, $content_type) { |
|
| 65 | 65 | |
| 66 | - $default_response = json_decode( '{ "entities": {}, "annotations": {}, "topics": {} }' ); |
|
| 67 | - $request_body = json_decode( $data, true ); |
|
| 68 | - $post_id = isset( $_REQUEST['postId'] ) ? intval( $_REQUEST['postId'] ) : 0; |
|
| 69 | - if ( $request_body === null ) { |
|
| 66 | + $default_response = json_decode('{ "entities": {}, "annotations": {}, "topics": {} }'); |
|
| 67 | + $request_body = json_decode($data, true); |
|
| 68 | + $post_id = isset($_REQUEST['postId']) ? intval($_REQUEST['postId']) : 0; |
|
| 69 | + if ($request_body === null) { |
|
| 70 | 70 | /** |
| 71 | 71 | * @since 3.27.7 |
| 72 | 72 | * |
| 73 | 73 | * Conditionally try using stripslashes as $_POST['data'] could be escaped |
| 74 | 74 | */ |
| 75 | - $request_body = json_decode( stripslashes( $data ), true ); |
|
| 75 | + $request_body = json_decode(stripslashes($data), true); |
|
| 76 | 76 | } |
| 77 | 77 | $request_body['contentLanguage'] = Wordlift_Configuration_Service::get_instance()->get_language_code(); |
| 78 | - $excluded_uris = array_key_exists( 'exclude', $request_body ) ? (array) $request_body['exclude'] : array(); |
|
| 79 | - $data = wp_json_encode( $request_body ); |
|
| 78 | + $excluded_uris = array_key_exists('exclude', $request_body) ? (array) $request_body['exclude'] : array(); |
|
| 79 | + $data = wp_json_encode($request_body); |
|
| 80 | 80 | |
| 81 | 81 | // If dataset is not enabled, return a locally prepared response without analysis API. |
| 82 | - if ( ! apply_filters( 'wl_features__enable__dataset', true ) ) { |
|
| 82 | + if ( ! apply_filters('wl_features__enable__dataset', true)) { |
|
| 83 | 83 | |
| 84 | 84 | return Analysis_Response_Ops_Factory::get_instance() |
| 85 | - ->create( $default_response, $post_id ) |
|
| 85 | + ->create($default_response, $post_id) |
|
| 86 | 86 | ->make_entities_local() |
| 87 | - ->add_occurrences( $request_body['content'] ) |
|
| 87 | + ->add_occurrences($request_body['content']) |
|
| 88 | 88 | ->add_local_entities() |
| 89 | 89 | ->get_json(); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - add_filter( 'wl_api_service_api_url_path', 'wl_use_analysis_on_api_wordlift_io' ); |
|
| 92 | + add_filter('wl_api_service_api_url_path', 'wl_use_analysis_on_api_wordlift_io'); |
|
| 93 | 93 | |
| 94 | 94 | |
| 95 | - $json = Analysis_Service_Factory::get_instance( $post_id ) |
|
| 96 | - ->get_analysis_response( $data, $content_type, $post_id ); |
|
| 95 | + $json = Analysis_Service_Factory::get_instance($post_id) |
|
| 96 | + ->get_analysis_response($data, $content_type, $post_id); |
|
| 97 | 97 | |
| 98 | - remove_filter( 'wl_api_service_api_url_path', 'wl_use_analysis_on_api_wordlift_io' ); |
|
| 98 | + remove_filter('wl_api_service_api_url_path', 'wl_use_analysis_on_api_wordlift_io'); |
|
| 99 | 99 | |
| 100 | 100 | // If it's an error log it. |
| 101 | - if ( is_wp_error( $json ) ) { |
|
| 101 | + if (is_wp_error($json)) { |
|
| 102 | 102 | return Analysis_Response_Ops_Factory::get_instance() |
| 103 | - ->create( $default_response, $post_id ) |
|
| 103 | + ->create($default_response, $post_id) |
|
| 104 | 104 | ->make_entities_local() |
| 105 | - ->add_occurrences( $request_body['content'] ) |
|
| 105 | + ->add_occurrences($request_body['content']) |
|
| 106 | 106 | ->get_json(); |
| 107 | 107 | } |
| 108 | 108 | |
@@ -115,22 +115,22 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | // Get the actual content sent to the analysis, so that we can pass it to the Analysis_Response_Ops to populate |
| 117 | 117 | // the occurrences for the local entities. |
| 118 | - if ( 0 === strpos( $content_type, 'application/json' ) ) { |
|
| 118 | + if (0 === strpos($content_type, 'application/json')) { |
|
| 119 | 119 | $request_content = $request_body['content']; |
| 120 | 120 | } else { |
| 121 | 121 | $request_content = $data; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | return Analysis_Response_Ops_Factory::get_instance() |
| 125 | - ->create( $json, $post_id ) |
|
| 125 | + ->create($json, $post_id) |
|
| 126 | 126 | ->make_entities_local() |
| 127 | - ->remove_excluded_entities( $excluded_uris ) |
|
| 128 | - ->add_occurrences( $request_content ) |
|
| 127 | + ->remove_excluded_entities($excluded_uris) |
|
| 128 | + ->add_occurrences($request_content) |
|
| 129 | 129 | ->get_json(); |
| 130 | 130 | |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | -function wl_use_analysis_on_api_wordlift_io( $value ) { |
|
| 133 | +function wl_use_analysis_on_api_wordlift_io($value) { |
|
| 134 | 134 | |
| 135 | - return preg_replace( '|https://api\.wordlift\.it/|', apply_filters( 'wl_api_base_url', 'https://api.wordlift.io' ) . '/', $value ); |
|
| 135 | + return preg_replace('|https://api\.wordlift\.it/|', apply_filters('wl_api_base_url', 'https://api.wordlift.io').'/', $value); |
|
| 136 | 136 | } |
@@ -21,60 +21,60 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | function wl_linked_data_save_post( $post_id ) { |
| 23 | 23 | |
| 24 | - $log = Wordlift_Log_Service::get_logger( 'wl_linked_data_save_post' ); |
|
| 25 | - |
|
| 26 | - $log->trace( "Saving post $post_id to Linked Data..." ); |
|
| 27 | - |
|
| 28 | - // If it's not numeric exit from here. |
|
| 29 | - if ( ! is_numeric( $post_id ) || is_numeric( wp_is_post_revision( $post_id ) ) ) { |
|
| 30 | - $log->debug( "Skipping $post_id, because id is not numeric or is a post revision." ); |
|
| 31 | - |
|
| 32 | - return; |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - // Get the post type and check whether it supports the editor. |
|
| 36 | - // |
|
| 37 | - // @see https://github.com/insideout10/wordlift-plugin/issues/659. |
|
| 38 | - $post_type = get_post_type( $post_id ); |
|
| 39 | - /** |
|
| 40 | - * Use `wl_post_type_supports_editor` which calls a filter to allow 3rd parties to change the setting. |
|
| 41 | - * |
|
| 42 | - * @since 3.19.4 |
|
| 43 | - * |
|
| 44 | - * @see https://github.com/insideout10/wordlift-plugin/issues/847. |
|
| 45 | - */ |
|
| 46 | - $is_editor_supported = wl_post_type_supports_editor( $post_type ); |
|
| 47 | - |
|
| 48 | - // Bail out if it's not an entity. |
|
| 49 | - if ( ! $is_editor_supported ) { |
|
| 50 | - $log->debug( "Skipping $post_id, because $post_type doesn't support the editor (content)." ); |
|
| 51 | - |
|
| 52 | - return; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Only process valid post types |
|
| 57 | - * |
|
| 58 | - * @since 3.25.6 |
|
| 59 | - * |
|
| 60 | - */ |
|
| 61 | - $supported_types = Wordlift_Entity_Service::valid_entity_post_types(); |
|
| 62 | - |
|
| 63 | - // Bail out if it's not a valid entity. |
|
| 64 | - if ( ! in_array( $post_type, $supported_types ) ) { |
|
| 65 | - $log->debug( "Skipping $post_id, because $post_type is not a valid entity." ); |
|
| 66 | - |
|
| 67 | - return; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - // Unhook this function so it doesn't loop infinitely. |
|
| 71 | - remove_action( 'save_post', 'wl_linked_data_save_post' ); |
|
| 72 | - |
|
| 73 | - // raise the *wl_linked_data_save_post* event. |
|
| 74 | - do_action( 'wl_linked_data_save_post', $post_id ); |
|
| 75 | - |
|
| 76 | - // Re-hook this function. |
|
| 77 | - add_action( 'save_post', 'wl_linked_data_save_post' ); |
|
| 24 | + $log = Wordlift_Log_Service::get_logger( 'wl_linked_data_save_post' ); |
|
| 25 | + |
|
| 26 | + $log->trace( "Saving post $post_id to Linked Data..." ); |
|
| 27 | + |
|
| 28 | + // If it's not numeric exit from here. |
|
| 29 | + if ( ! is_numeric( $post_id ) || is_numeric( wp_is_post_revision( $post_id ) ) ) { |
|
| 30 | + $log->debug( "Skipping $post_id, because id is not numeric or is a post revision." ); |
|
| 31 | + |
|
| 32 | + return; |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + // Get the post type and check whether it supports the editor. |
|
| 36 | + // |
|
| 37 | + // @see https://github.com/insideout10/wordlift-plugin/issues/659. |
|
| 38 | + $post_type = get_post_type( $post_id ); |
|
| 39 | + /** |
|
| 40 | + * Use `wl_post_type_supports_editor` which calls a filter to allow 3rd parties to change the setting. |
|
| 41 | + * |
|
| 42 | + * @since 3.19.4 |
|
| 43 | + * |
|
| 44 | + * @see https://github.com/insideout10/wordlift-plugin/issues/847. |
|
| 45 | + */ |
|
| 46 | + $is_editor_supported = wl_post_type_supports_editor( $post_type ); |
|
| 47 | + |
|
| 48 | + // Bail out if it's not an entity. |
|
| 49 | + if ( ! $is_editor_supported ) { |
|
| 50 | + $log->debug( "Skipping $post_id, because $post_type doesn't support the editor (content)." ); |
|
| 51 | + |
|
| 52 | + return; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * Only process valid post types |
|
| 57 | + * |
|
| 58 | + * @since 3.25.6 |
|
| 59 | + * |
|
| 60 | + */ |
|
| 61 | + $supported_types = Wordlift_Entity_Service::valid_entity_post_types(); |
|
| 62 | + |
|
| 63 | + // Bail out if it's not a valid entity. |
|
| 64 | + if ( ! in_array( $post_type, $supported_types ) ) { |
|
| 65 | + $log->debug( "Skipping $post_id, because $post_type is not a valid entity." ); |
|
| 66 | + |
|
| 67 | + return; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + // Unhook this function so it doesn't loop infinitely. |
|
| 71 | + remove_action( 'save_post', 'wl_linked_data_save_post' ); |
|
| 72 | + |
|
| 73 | + // raise the *wl_linked_data_save_post* event. |
|
| 74 | + do_action( 'wl_linked_data_save_post', $post_id ); |
|
| 75 | + |
|
| 76 | + // Re-hook this function. |
|
| 77 | + add_action( 'save_post', 'wl_linked_data_save_post' ); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | add_action( 'save_post', 'wl_linked_data_save_post' ); |
@@ -89,176 +89,176 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | function wl_linked_data_save_post_and_related_entities( $post_id ) { |
| 91 | 91 | |
| 92 | - $log = Wordlift_Log_Service::get_logger( 'wl_linked_data_save_post_and_related_entities' ); |
|
| 92 | + $log = Wordlift_Log_Service::get_logger( 'wl_linked_data_save_post_and_related_entities' ); |
|
| 93 | 93 | |
| 94 | - $log->trace( "Saving $post_id to Linked Data along with related entities..." ); |
|
| 94 | + $log->trace( "Saving $post_id to Linked Data along with related entities..." ); |
|
| 95 | 95 | |
| 96 | - // Ignore auto-saves |
|
| 97 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
| 98 | - $log->trace( 'Doing autosave, skipping...' ); |
|
| 96 | + // Ignore auto-saves |
|
| 97 | + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
| 98 | + $log->trace( 'Doing autosave, skipping...' ); |
|
| 99 | 99 | |
| 100 | - return; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - // get the current post. |
|
| 104 | - $post = get_post( $post_id ); |
|
| 100 | + return; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + // get the current post. |
|
| 104 | + $post = get_post( $post_id ); |
|
| 105 | 105 | |
| 106 | - remove_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' ); |
|
| 106 | + remove_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' ); |
|
| 107 | 107 | |
| 108 | - // wl_write_log( "[ post id :: $post_id ][ autosave :: false ][ post type :: $post->post_type ]" ); |
|
| 108 | + // wl_write_log( "[ post id :: $post_id ][ autosave :: false ][ post type :: $post->post_type ]" ); |
|
| 109 | 109 | |
| 110 | - // Get the entity service instance. |
|
| 111 | - $entity_service = Wordlift_Entity_Service::get_instance(); |
|
| 110 | + // Get the entity service instance. |
|
| 111 | + $entity_service = Wordlift_Entity_Service::get_instance(); |
|
| 112 | 112 | |
| 113 | - // Store mapping between tmp new entities uris and real new entities uri |
|
| 114 | - $entities_uri_mapping = array(); |
|
| 115 | - |
|
| 116 | - // Save the entities coming with POST data. |
|
| 117 | - if ( isset( $_POST['wl_entities'] ) && isset( $_POST['wl_boxes'] ) ) { |
|
| 118 | - |
|
| 119 | - wl_write_log( "[ post id :: $post_id ][ POST(wl_entities) :: " ); |
|
| 120 | - wl_write_log( json_encode( $_POST['wl_entities'] ) ); |
|
| 121 | - wl_write_log( "]" ); |
|
| 122 | - wl_write_log( "[ post id :: $post_id ][ POST(wl_boxes) :: " ); |
|
| 123 | - wl_write_log( json_encode( $_POST['wl_boxes'], true ) ); |
|
| 124 | - wl_write_log( "]" ); |
|
| 125 | - |
|
| 126 | - $entities_via_post = $_POST['wl_entities']; |
|
| 127 | - $boxes_via_post = $_POST['wl_boxes']; |
|
| 128 | - |
|
| 129 | - foreach ( $entities_via_post as $entity_uri => $entity ) { |
|
| 130 | - |
|
| 131 | - // Only if the current entity is created from scratch let's avoid to |
|
| 132 | - // create more than one entity with same label & entity type. |
|
| 133 | - $entity_type = ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) ? |
|
| 134 | - $entity['main_type'] : null; |
|
| 135 | - |
|
| 136 | - // Look if current entity uri matches an internal existing entity, meaning: |
|
| 137 | - // 1. when $entity_uri is an internal uri |
|
| 138 | - // 2. when $entity_uri is an external uri used as sameAs of an internal entity |
|
| 139 | - $ie = $entity_service->get_entity_post_by_uri( $entity_uri ); |
|
| 140 | - |
|
| 141 | - // Dont save the entities which are not found, but also local. |
|
| 142 | - if ( $ie === null && Wordlift_Entity_Uri_Service::get_instance()->is_internal( $entity_uri ) ) { |
|
| 143 | - continue; |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - // Detect the uri depending if is an existing or a new entity |
|
| 147 | - $uri = ( null === $ie ) ? |
|
| 148 | - Wordlift_Uri_Service::get_instance()->build_uri( |
|
| 149 | - $entity['label'], |
|
| 150 | - Wordlift_Entity_Service::TYPE_NAME, |
|
| 151 | - $entity_type |
|
| 152 | - ) : wl_get_entity_uri( $ie->ID ); |
|
| 153 | - |
|
| 154 | - wl_write_log( "Map $entity_uri on $uri" ); |
|
| 155 | - $entities_uri_mapping[ $entity_uri ] = $uri; |
|
| 156 | - |
|
| 157 | - // Local entities have a tmp uri with 'local-entity-' prefix |
|
| 158 | - // These uris need to be rewritten here and replaced in the content |
|
| 159 | - if ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) { |
|
| 160 | - // Override the entity obj |
|
| 161 | - $entity['uri'] = $uri; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - // Update entity data with related post |
|
| 165 | - $entity['related_post_id'] = $post_id; |
|
| 166 | - |
|
| 167 | - // Save the entity if is a new entity |
|
| 168 | - if ( null === $ie ) { |
|
| 169 | - wl_save_entity( $entity ); |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - // Replace tmp uris in content post if needed |
|
| 177 | - $updated_post_content = $post->post_content; |
|
| 178 | - |
|
| 179 | - // Update the post content if we found mappings of new entities. |
|
| 180 | - if ( ! empty( $entities_uri_mapping ) ) { |
|
| 181 | - // Save each entity and store the post id. |
|
| 182 | - foreach ( $entities_uri_mapping as $tmp_uri => $uri ) { |
|
| 183 | - if ( 1 !== preg_match( '@^(https?://|local-entity-)@', $tmp_uri ) ) { |
|
| 184 | - continue; |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - $updated_post_content = str_replace( $tmp_uri, $uri, $updated_post_content ); |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - // Update the post content. |
|
| 191 | - /** |
|
| 192 | - * Note: wp_update_post do stripslashes before saving the |
|
| 193 | - * content, so add the slashes to prevent back slash getting |
|
| 194 | - * removed. |
|
| 195 | - */ |
|
| 196 | - wp_update_post( array( |
|
| 197 | - 'ID' => $post->ID, |
|
| 198 | - 'post_content' => addslashes( $updated_post_content ), |
|
| 199 | - ) ); |
|
| 200 | - } |
|
| 201 | - // Reset previously saved instances. |
|
| 202 | - wl_core_delete_relation_instances( $post_id ); |
|
| 203 | - |
|
| 204 | - $relations = Object_Relation_Factory::get_instance( $post_id ) |
|
| 205 | - ->get_relations_from_content( $updated_post_content, Object_Type_Enum::POST ); |
|
| 206 | - |
|
| 207 | - // Save relation instances |
|
| 208 | - foreach ( $relations as $relation ) { |
|
| 209 | - |
|
| 210 | - wl_core_add_relation_instance( |
|
| 211 | - // subject id. |
|
| 212 | - $post_id, |
|
| 213 | - // what, where, when, who |
|
| 214 | - $relation->get_relation_type(), |
|
| 215 | - // object id. |
|
| 216 | - $relation->get_object_id(), |
|
| 217 | - // Subject type. |
|
| 218 | - $relation->get_subject_type(), |
|
| 219 | - // Object type. |
|
| 220 | - $relation->get_object_type() |
|
| 221 | - ); |
|
| 222 | - |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - if ( isset( $_POST['wl_entities'] ) ) { |
|
| 226 | - // Save post metadata if available |
|
| 227 | - $metadata_via_post = ( isset( $_POST['wl_metadata'] ) ) ? |
|
| 228 | - $_POST['wl_metadata'] : array(); |
|
| 229 | - |
|
| 230 | - $fields = array( |
|
| 231 | - Wordlift_Schema_Service::FIELD_LOCATION_CREATED, |
|
| 232 | - Wordlift_Schema_Service::FIELD_TOPIC, |
|
| 233 | - ); |
|
| 234 | - |
|
| 235 | - // Unlink topic taxonomy terms |
|
| 236 | - Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for( $post->ID ); |
|
| 237 | - |
|
| 238 | - foreach ( $fields as $field ) { |
|
| 239 | - |
|
| 240 | - // Delete current values |
|
| 241 | - delete_post_meta( $post->ID, $field ); |
|
| 242 | - // Retrieve the entity uri |
|
| 243 | - $uri = ( isset( $metadata_via_post[ $field ] ) ) ? |
|
| 244 | - stripslashes( $metadata_via_post[ $field ] ) : ''; |
|
| 245 | - |
|
| 246 | - $entity = $entity_service->get_entity_post_by_uri( $uri ); |
|
| 247 | - |
|
| 248 | - if ( $entity ) { |
|
| 249 | - add_post_meta( $post->ID, $field, $entity->ID, true ); |
|
| 250 | - // Set also the topic taxonomy |
|
| 251 | - if ( $field === Wordlift_Schema_Service::FIELD_TOPIC ) { |
|
| 252 | - Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for( $post->ID, $entity ); |
|
| 253 | - } |
|
| 254 | - } |
|
| 255 | - } |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - // Push the post to Redlink. |
|
| 259 | - do_action( 'wl_legacy_linked_data__push', $post->ID ); |
|
| 260 | - |
|
| 261 | - add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' ); |
|
| 113 | + // Store mapping between tmp new entities uris and real new entities uri |
|
| 114 | + $entities_uri_mapping = array(); |
|
| 115 | + |
|
| 116 | + // Save the entities coming with POST data. |
|
| 117 | + if ( isset( $_POST['wl_entities'] ) && isset( $_POST['wl_boxes'] ) ) { |
|
| 118 | + |
|
| 119 | + wl_write_log( "[ post id :: $post_id ][ POST(wl_entities) :: " ); |
|
| 120 | + wl_write_log( json_encode( $_POST['wl_entities'] ) ); |
|
| 121 | + wl_write_log( "]" ); |
|
| 122 | + wl_write_log( "[ post id :: $post_id ][ POST(wl_boxes) :: " ); |
|
| 123 | + wl_write_log( json_encode( $_POST['wl_boxes'], true ) ); |
|
| 124 | + wl_write_log( "]" ); |
|
| 125 | + |
|
| 126 | + $entities_via_post = $_POST['wl_entities']; |
|
| 127 | + $boxes_via_post = $_POST['wl_boxes']; |
|
| 128 | + |
|
| 129 | + foreach ( $entities_via_post as $entity_uri => $entity ) { |
|
| 130 | + |
|
| 131 | + // Only if the current entity is created from scratch let's avoid to |
|
| 132 | + // create more than one entity with same label & entity type. |
|
| 133 | + $entity_type = ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) ? |
|
| 134 | + $entity['main_type'] : null; |
|
| 135 | + |
|
| 136 | + // Look if current entity uri matches an internal existing entity, meaning: |
|
| 137 | + // 1. when $entity_uri is an internal uri |
|
| 138 | + // 2. when $entity_uri is an external uri used as sameAs of an internal entity |
|
| 139 | + $ie = $entity_service->get_entity_post_by_uri( $entity_uri ); |
|
| 140 | + |
|
| 141 | + // Dont save the entities which are not found, but also local. |
|
| 142 | + if ( $ie === null && Wordlift_Entity_Uri_Service::get_instance()->is_internal( $entity_uri ) ) { |
|
| 143 | + continue; |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + // Detect the uri depending if is an existing or a new entity |
|
| 147 | + $uri = ( null === $ie ) ? |
|
| 148 | + Wordlift_Uri_Service::get_instance()->build_uri( |
|
| 149 | + $entity['label'], |
|
| 150 | + Wordlift_Entity_Service::TYPE_NAME, |
|
| 151 | + $entity_type |
|
| 152 | + ) : wl_get_entity_uri( $ie->ID ); |
|
| 153 | + |
|
| 154 | + wl_write_log( "Map $entity_uri on $uri" ); |
|
| 155 | + $entities_uri_mapping[ $entity_uri ] = $uri; |
|
| 156 | + |
|
| 157 | + // Local entities have a tmp uri with 'local-entity-' prefix |
|
| 158 | + // These uris need to be rewritten here and replaced in the content |
|
| 159 | + if ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) { |
|
| 160 | + // Override the entity obj |
|
| 161 | + $entity['uri'] = $uri; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + // Update entity data with related post |
|
| 165 | + $entity['related_post_id'] = $post_id; |
|
| 166 | + |
|
| 167 | + // Save the entity if is a new entity |
|
| 168 | + if ( null === $ie ) { |
|
| 169 | + wl_save_entity( $entity ); |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + // Replace tmp uris in content post if needed |
|
| 177 | + $updated_post_content = $post->post_content; |
|
| 178 | + |
|
| 179 | + // Update the post content if we found mappings of new entities. |
|
| 180 | + if ( ! empty( $entities_uri_mapping ) ) { |
|
| 181 | + // Save each entity and store the post id. |
|
| 182 | + foreach ( $entities_uri_mapping as $tmp_uri => $uri ) { |
|
| 183 | + if ( 1 !== preg_match( '@^(https?://|local-entity-)@', $tmp_uri ) ) { |
|
| 184 | + continue; |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + $updated_post_content = str_replace( $tmp_uri, $uri, $updated_post_content ); |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + // Update the post content. |
|
| 191 | + /** |
|
| 192 | + * Note: wp_update_post do stripslashes before saving the |
|
| 193 | + * content, so add the slashes to prevent back slash getting |
|
| 194 | + * removed. |
|
| 195 | + */ |
|
| 196 | + wp_update_post( array( |
|
| 197 | + 'ID' => $post->ID, |
|
| 198 | + 'post_content' => addslashes( $updated_post_content ), |
|
| 199 | + ) ); |
|
| 200 | + } |
|
| 201 | + // Reset previously saved instances. |
|
| 202 | + wl_core_delete_relation_instances( $post_id ); |
|
| 203 | + |
|
| 204 | + $relations = Object_Relation_Factory::get_instance( $post_id ) |
|
| 205 | + ->get_relations_from_content( $updated_post_content, Object_Type_Enum::POST ); |
|
| 206 | + |
|
| 207 | + // Save relation instances |
|
| 208 | + foreach ( $relations as $relation ) { |
|
| 209 | + |
|
| 210 | + wl_core_add_relation_instance( |
|
| 211 | + // subject id. |
|
| 212 | + $post_id, |
|
| 213 | + // what, where, when, who |
|
| 214 | + $relation->get_relation_type(), |
|
| 215 | + // object id. |
|
| 216 | + $relation->get_object_id(), |
|
| 217 | + // Subject type. |
|
| 218 | + $relation->get_subject_type(), |
|
| 219 | + // Object type. |
|
| 220 | + $relation->get_object_type() |
|
| 221 | + ); |
|
| 222 | + |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + if ( isset( $_POST['wl_entities'] ) ) { |
|
| 226 | + // Save post metadata if available |
|
| 227 | + $metadata_via_post = ( isset( $_POST['wl_metadata'] ) ) ? |
|
| 228 | + $_POST['wl_metadata'] : array(); |
|
| 229 | + |
|
| 230 | + $fields = array( |
|
| 231 | + Wordlift_Schema_Service::FIELD_LOCATION_CREATED, |
|
| 232 | + Wordlift_Schema_Service::FIELD_TOPIC, |
|
| 233 | + ); |
|
| 234 | + |
|
| 235 | + // Unlink topic taxonomy terms |
|
| 236 | + Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for( $post->ID ); |
|
| 237 | + |
|
| 238 | + foreach ( $fields as $field ) { |
|
| 239 | + |
|
| 240 | + // Delete current values |
|
| 241 | + delete_post_meta( $post->ID, $field ); |
|
| 242 | + // Retrieve the entity uri |
|
| 243 | + $uri = ( isset( $metadata_via_post[ $field ] ) ) ? |
|
| 244 | + stripslashes( $metadata_via_post[ $field ] ) : ''; |
|
| 245 | + |
|
| 246 | + $entity = $entity_service->get_entity_post_by_uri( $uri ); |
|
| 247 | + |
|
| 248 | + if ( $entity ) { |
|
| 249 | + add_post_meta( $post->ID, $field, $entity->ID, true ); |
|
| 250 | + // Set also the topic taxonomy |
|
| 251 | + if ( $field === Wordlift_Schema_Service::FIELD_TOPIC ) { |
|
| 252 | + Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for( $post->ID, $entity ); |
|
| 253 | + } |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + // Push the post to Redlink. |
|
| 259 | + do_action( 'wl_legacy_linked_data__push', $post->ID ); |
|
| 260 | + |
|
| 261 | + add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' ); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' ); |
@@ -281,203 +281,203 @@ discard block |
||
| 281 | 281 | */ |
| 282 | 282 | function wl_save_entity( $entity_data ) { |
| 283 | 283 | |
| 284 | - // Required for REST API calls |
|
| 285 | - if ( ! function_exists( 'wp_crop_image' ) ) { |
|
| 286 | - require_once( ABSPATH . 'wp-admin/includes/image.php' ); |
|
| 287 | - } |
|
| 284 | + // Required for REST API calls |
|
| 285 | + if ( ! function_exists( 'wp_crop_image' ) ) { |
|
| 286 | + require_once( ABSPATH . 'wp-admin/includes/image.php' ); |
|
| 287 | + } |
|
| 288 | 288 | |
| 289 | - $log = Wordlift_Log_Service::get_logger( 'wl_save_entity' ); |
|
| 289 | + $log = Wordlift_Log_Service::get_logger( 'wl_save_entity' ); |
|
| 290 | 290 | |
| 291 | - $uri = $entity_data['uri']; |
|
| 292 | - /* |
|
| 291 | + $uri = $entity_data['uri']; |
|
| 292 | + /* |
|
| 293 | 293 | * Data is coming from a $_POST, sanitize it. |
| 294 | 294 | * |
| 295 | 295 | * @since 3.19.4 |
| 296 | 296 | * |
| 297 | 297 | * @see https://github.com/insideout10/wordlift-plugin/issues/841 |
| 298 | 298 | */ |
| 299 | - $label = preg_replace( '/\xEF\xBB\xBF/', '', sanitize_text_field( $entity_data['label'] ) ); |
|
| 300 | - $type_uri = $entity_data['main_type']; |
|
| 301 | - $entity_types = isset( $entity_data['type'] ) ? $entity_data['type'] : array(); |
|
| 302 | - $description = $entity_data['description']; |
|
| 303 | - $images = isset( $entity_data['image'] ) ? (array) $entity_data['image'] : array(); |
|
| 304 | - $same_as = isset( $entity_data['sameas'] ) ? (array) $entity_data['sameas'] : array(); |
|
| 305 | - $related_post_id = isset( $entity_data['related_post_id'] ) ? $entity_data['related_post_id'] : null; |
|
| 306 | - $other_properties = isset( $entity_data['properties'] ) ? $entity_data['properties'] : array(); |
|
| 307 | - |
|
| 308 | - // Get the synonyms. |
|
| 309 | - $synonyms = isset( $entity_data['synonym'] ) ? $entity_data['synonym'] : array(); |
|
| 310 | - |
|
| 311 | - // Check whether an entity already exists with the provided URI. |
|
| 312 | - if ( null !== $post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri ) ) { |
|
| 313 | - $log->debug( "Post already exists for URI $uri." ); |
|
| 314 | - |
|
| 315 | - return $post; |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - // Prepare properties of the new entity. |
|
| 319 | - $params = array( |
|
| 320 | - 'post_status' => ( is_numeric( $related_post_id ) ? get_post_status( $related_post_id ) : 'draft' ), |
|
| 321 | - 'post_type' => Wordlift_Entity_Service::TYPE_NAME, |
|
| 322 | - 'post_title' => $label, |
|
| 323 | - 'post_content' => $description, |
|
| 324 | - 'post_excerpt' => '', |
|
| 325 | - // Ensure we're using a valid slug. We're not overwriting an existing |
|
| 326 | - // entity with a post_name already set, since this call is made only for |
|
| 327 | - // new entities. |
|
| 328 | - // |
|
| 329 | - // See https://github.com/insideout10/wordlift-plugin/issues/282 |
|
| 330 | - 'post_name' => sanitize_title( $label ), |
|
| 331 | - ); |
|
| 332 | - |
|
| 333 | - // If Yoast is installed and active, we temporary remove the save_postdata hook which causes Yoast to "pass over" |
|
| 334 | - // the local SEO form values to the created entity (https://github.com/insideout10/wordlift-plugin/issues/156) |
|
| 335 | - // Same thing applies to SEO Ultimate (https://github.com/insideout10/wordlift-plugin/issues/148) |
|
| 336 | - // This does NOT affect saving an entity from the entity admin page since this function is called when an entity |
|
| 337 | - // is created when saving a post. |
|
| 338 | - global $wpseo_metabox, $seo_ultimate; |
|
| 339 | - if ( isset( $wpseo_metabox ) ) { |
|
| 340 | - remove_action( 'wp_insert_post', array( |
|
| 341 | - $wpseo_metabox, |
|
| 342 | - 'save_postdata', |
|
| 343 | - ) ); |
|
| 344 | - } |
|
| 345 | - |
|
| 346 | - if ( isset( $seo_ultimate ) ) { |
|
| 347 | - remove_action( 'save_post', array( |
|
| 348 | - $seo_ultimate, |
|
| 349 | - 'save_postmeta_box', |
|
| 350 | - ) ); |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - // The fact that we're calling here wp_insert_post is causing issues with plugins (and ourselves too) that hook to |
|
| 354 | - // save_post in order to save additional inputs from the edit page. In order to avoid issues, we pop all the hooks |
|
| 355 | - // to the save_post and restore them after we saved the entity. |
|
| 356 | - // see https://github.com/insideout10/wordlift-plugin/issues/203 |
|
| 357 | - // see https://github.com/insideout10/wordlift-plugin/issues/156 |
|
| 358 | - // see https://github.com/insideout10/wordlift-plugin/issues/148 |
|
| 359 | - global $wp_filter; |
|
| 360 | - $save_post_filters = is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] : $wp_filter['save_post']->callbacks; |
|
| 361 | - is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = array() : $wp_filter['save_post']->remove_all_filters(); |
|
| 362 | - |
|
| 363 | - |
|
| 364 | - $log->trace( 'Going to insert new post...' ); |
|
| 365 | - |
|
| 366 | - // create or update the post. |
|
| 367 | - $post_id = wp_insert_post( $params, true ); |
|
| 368 | - |
|
| 369 | - // Setting the alternative labels for this entity. |
|
| 370 | - Wordlift_Entity_Service::get_instance() |
|
| 371 | - ->set_alternative_labels( $post_id, $synonyms ); |
|
| 372 | - |
|
| 373 | - // Restore all the existing filters. |
|
| 374 | - is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = $save_post_filters : $wp_filter['save_post']->callbacks = $save_post_filters; |
|
| 375 | - |
|
| 376 | - // If Yoast is installed and active, we restore the Yoast save_postdata hook (https://github.com/insideout10/wordlift-plugin/issues/156) |
|
| 377 | - if ( isset( $wpseo_metabox ) ) { |
|
| 378 | - add_action( 'wp_insert_post', array( |
|
| 379 | - $wpseo_metabox, |
|
| 380 | - 'save_postdata', |
|
| 381 | - ) ); |
|
| 382 | - } |
|
| 383 | - |
|
| 384 | - // If SEO Ultimate is installed, add back the hook we removed a few lines above. |
|
| 385 | - if ( isset( $seo_ultimate ) ) { |
|
| 386 | - add_action( 'save_post', array( |
|
| 387 | - $seo_ultimate, |
|
| 388 | - 'save_postmeta_box', |
|
| 389 | - ), 10, 2 ); |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - // TODO: handle errors. |
|
| 393 | - if ( is_wp_error( $post_id ) ) { |
|
| 394 | - $log->error( 'An error occurred: ' . $post_id->get_error_message() ); |
|
| 395 | - |
|
| 396 | - // inform an error occurred. |
|
| 397 | - return null; |
|
| 398 | - } |
|
| 399 | - |
|
| 400 | - wl_set_entity_main_type( $post_id, $type_uri ); |
|
| 401 | - |
|
| 402 | - // Save the entity types. |
|
| 403 | - wl_set_entity_rdf_types( $post_id, $entity_types ); |
|
| 404 | - |
|
| 405 | - // Get a dataset URI for the entity. |
|
| 406 | - $wl_uri = Wordlift_Entity_Service::get_instance()->get_uri( $post_id ); |
|
| 407 | - |
|
| 408 | - // Add the uri to the sameAs data if it's not a local URI. |
|
| 409 | - if ( $wl_uri !== $uri ) { |
|
| 410 | - array_push( $same_as, $uri ); |
|
| 411 | - } |
|
| 412 | - |
|
| 413 | - // Save the sameAs data for the entity. |
|
| 414 | - wl_schema_set_value( $post_id, 'sameAs', $same_as ); |
|
| 415 | - |
|
| 416 | - // Save the other properties (latitude, langitude, startDate, endDate, etc.) |
|
| 417 | - foreach ( $other_properties as $property_name => $property_value ) { |
|
| 418 | - wl_schema_set_value( $post_id, $property_name, $property_value ); |
|
| 419 | - } |
|
| 420 | - |
|
| 421 | - // Call hooks. |
|
| 422 | - do_action( 'wl_save_entity', $post_id ); |
|
| 423 | - |
|
| 424 | - foreach ( $images as $image_remote_url ) { |
|
| 425 | - |
|
| 426 | - // Check if image is already present in local DB |
|
| 427 | - if ( strpos( $image_remote_url, site_url() ) !== false ) { |
|
| 428 | - // Do nothing. |
|
| 429 | - continue; |
|
| 430 | - } |
|
| 431 | - |
|
| 432 | - // Check if there is an existing attachment for this post ID and source URL. |
|
| 433 | - $existing_image = wl_get_attachment_for_source_url( $post_id, $image_remote_url ); |
|
| 434 | - |
|
| 435 | - // Skip if an existing image is found. |
|
| 436 | - if ( null !== $existing_image ) { |
|
| 437 | - continue; |
|
| 438 | - } |
|
| 439 | - |
|
| 440 | - // Save the image and get the local path. |
|
| 441 | - $image = Wordlift_Remote_Image_Service::save_from_url( $image_remote_url ); |
|
| 442 | - |
|
| 443 | - if ( false === $image || is_wp_error( $image ) ) { |
|
| 444 | - continue; |
|
| 445 | - } |
|
| 446 | - |
|
| 447 | - // Get the local URL. |
|
| 448 | - $filename = $image['path']; |
|
| 449 | - $url = $image['url']; |
|
| 450 | - $content_type = $image['content_type']; |
|
| 451 | - |
|
| 452 | - $attachment = array( |
|
| 453 | - 'guid' => $url, |
|
| 454 | - // post_title, post_content (the value for this key should be the empty string), post_status and post_mime_type |
|
| 455 | - 'post_title' => $label, |
|
| 456 | - // Set the title to the post title. |
|
| 457 | - 'post_content' => '', |
|
| 458 | - 'post_status' => 'inherit', |
|
| 459 | - 'post_mime_type' => $content_type, |
|
| 460 | - ); |
|
| 299 | + $label = preg_replace( '/\xEF\xBB\xBF/', '', sanitize_text_field( $entity_data['label'] ) ); |
|
| 300 | + $type_uri = $entity_data['main_type']; |
|
| 301 | + $entity_types = isset( $entity_data['type'] ) ? $entity_data['type'] : array(); |
|
| 302 | + $description = $entity_data['description']; |
|
| 303 | + $images = isset( $entity_data['image'] ) ? (array) $entity_data['image'] : array(); |
|
| 304 | + $same_as = isset( $entity_data['sameas'] ) ? (array) $entity_data['sameas'] : array(); |
|
| 305 | + $related_post_id = isset( $entity_data['related_post_id'] ) ? $entity_data['related_post_id'] : null; |
|
| 306 | + $other_properties = isset( $entity_data['properties'] ) ? $entity_data['properties'] : array(); |
|
| 307 | + |
|
| 308 | + // Get the synonyms. |
|
| 309 | + $synonyms = isset( $entity_data['synonym'] ) ? $entity_data['synonym'] : array(); |
|
| 310 | + |
|
| 311 | + // Check whether an entity already exists with the provided URI. |
|
| 312 | + if ( null !== $post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri ) ) { |
|
| 313 | + $log->debug( "Post already exists for URI $uri." ); |
|
| 314 | + |
|
| 315 | + return $post; |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + // Prepare properties of the new entity. |
|
| 319 | + $params = array( |
|
| 320 | + 'post_status' => ( is_numeric( $related_post_id ) ? get_post_status( $related_post_id ) : 'draft' ), |
|
| 321 | + 'post_type' => Wordlift_Entity_Service::TYPE_NAME, |
|
| 322 | + 'post_title' => $label, |
|
| 323 | + 'post_content' => $description, |
|
| 324 | + 'post_excerpt' => '', |
|
| 325 | + // Ensure we're using a valid slug. We're not overwriting an existing |
|
| 326 | + // entity with a post_name already set, since this call is made only for |
|
| 327 | + // new entities. |
|
| 328 | + // |
|
| 329 | + // See https://github.com/insideout10/wordlift-plugin/issues/282 |
|
| 330 | + 'post_name' => sanitize_title( $label ), |
|
| 331 | + ); |
|
| 332 | + |
|
| 333 | + // If Yoast is installed and active, we temporary remove the save_postdata hook which causes Yoast to "pass over" |
|
| 334 | + // the local SEO form values to the created entity (https://github.com/insideout10/wordlift-plugin/issues/156) |
|
| 335 | + // Same thing applies to SEO Ultimate (https://github.com/insideout10/wordlift-plugin/issues/148) |
|
| 336 | + // This does NOT affect saving an entity from the entity admin page since this function is called when an entity |
|
| 337 | + // is created when saving a post. |
|
| 338 | + global $wpseo_metabox, $seo_ultimate; |
|
| 339 | + if ( isset( $wpseo_metabox ) ) { |
|
| 340 | + remove_action( 'wp_insert_post', array( |
|
| 341 | + $wpseo_metabox, |
|
| 342 | + 'save_postdata', |
|
| 343 | + ) ); |
|
| 344 | + } |
|
| 345 | + |
|
| 346 | + if ( isset( $seo_ultimate ) ) { |
|
| 347 | + remove_action( 'save_post', array( |
|
| 348 | + $seo_ultimate, |
|
| 349 | + 'save_postmeta_box', |
|
| 350 | + ) ); |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + // The fact that we're calling here wp_insert_post is causing issues with plugins (and ourselves too) that hook to |
|
| 354 | + // save_post in order to save additional inputs from the edit page. In order to avoid issues, we pop all the hooks |
|
| 355 | + // to the save_post and restore them after we saved the entity. |
|
| 356 | + // see https://github.com/insideout10/wordlift-plugin/issues/203 |
|
| 357 | + // see https://github.com/insideout10/wordlift-plugin/issues/156 |
|
| 358 | + // see https://github.com/insideout10/wordlift-plugin/issues/148 |
|
| 359 | + global $wp_filter; |
|
| 360 | + $save_post_filters = is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] : $wp_filter['save_post']->callbacks; |
|
| 361 | + is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = array() : $wp_filter['save_post']->remove_all_filters(); |
|
| 362 | + |
|
| 363 | + |
|
| 364 | + $log->trace( 'Going to insert new post...' ); |
|
| 365 | + |
|
| 366 | + // create or update the post. |
|
| 367 | + $post_id = wp_insert_post( $params, true ); |
|
| 368 | + |
|
| 369 | + // Setting the alternative labels for this entity. |
|
| 370 | + Wordlift_Entity_Service::get_instance() |
|
| 371 | + ->set_alternative_labels( $post_id, $synonyms ); |
|
| 372 | + |
|
| 373 | + // Restore all the existing filters. |
|
| 374 | + is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = $save_post_filters : $wp_filter['save_post']->callbacks = $save_post_filters; |
|
| 375 | + |
|
| 376 | + // If Yoast is installed and active, we restore the Yoast save_postdata hook (https://github.com/insideout10/wordlift-plugin/issues/156) |
|
| 377 | + if ( isset( $wpseo_metabox ) ) { |
|
| 378 | + add_action( 'wp_insert_post', array( |
|
| 379 | + $wpseo_metabox, |
|
| 380 | + 'save_postdata', |
|
| 381 | + ) ); |
|
| 382 | + } |
|
| 383 | + |
|
| 384 | + // If SEO Ultimate is installed, add back the hook we removed a few lines above. |
|
| 385 | + if ( isset( $seo_ultimate ) ) { |
|
| 386 | + add_action( 'save_post', array( |
|
| 387 | + $seo_ultimate, |
|
| 388 | + 'save_postmeta_box', |
|
| 389 | + ), 10, 2 ); |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + // TODO: handle errors. |
|
| 393 | + if ( is_wp_error( $post_id ) ) { |
|
| 394 | + $log->error( 'An error occurred: ' . $post_id->get_error_message() ); |
|
| 395 | + |
|
| 396 | + // inform an error occurred. |
|
| 397 | + return null; |
|
| 398 | + } |
|
| 399 | + |
|
| 400 | + wl_set_entity_main_type( $post_id, $type_uri ); |
|
| 401 | + |
|
| 402 | + // Save the entity types. |
|
| 403 | + wl_set_entity_rdf_types( $post_id, $entity_types ); |
|
| 404 | + |
|
| 405 | + // Get a dataset URI for the entity. |
|
| 406 | + $wl_uri = Wordlift_Entity_Service::get_instance()->get_uri( $post_id ); |
|
| 407 | + |
|
| 408 | + // Add the uri to the sameAs data if it's not a local URI. |
|
| 409 | + if ( $wl_uri !== $uri ) { |
|
| 410 | + array_push( $same_as, $uri ); |
|
| 411 | + } |
|
| 412 | + |
|
| 413 | + // Save the sameAs data for the entity. |
|
| 414 | + wl_schema_set_value( $post_id, 'sameAs', $same_as ); |
|
| 415 | + |
|
| 416 | + // Save the other properties (latitude, langitude, startDate, endDate, etc.) |
|
| 417 | + foreach ( $other_properties as $property_name => $property_value ) { |
|
| 418 | + wl_schema_set_value( $post_id, $property_name, $property_value ); |
|
| 419 | + } |
|
| 420 | + |
|
| 421 | + // Call hooks. |
|
| 422 | + do_action( 'wl_save_entity', $post_id ); |
|
| 423 | + |
|
| 424 | + foreach ( $images as $image_remote_url ) { |
|
| 425 | + |
|
| 426 | + // Check if image is already present in local DB |
|
| 427 | + if ( strpos( $image_remote_url, site_url() ) !== false ) { |
|
| 428 | + // Do nothing. |
|
| 429 | + continue; |
|
| 430 | + } |
|
| 431 | + |
|
| 432 | + // Check if there is an existing attachment for this post ID and source URL. |
|
| 433 | + $existing_image = wl_get_attachment_for_source_url( $post_id, $image_remote_url ); |
|
| 434 | + |
|
| 435 | + // Skip if an existing image is found. |
|
| 436 | + if ( null !== $existing_image ) { |
|
| 437 | + continue; |
|
| 438 | + } |
|
| 439 | + |
|
| 440 | + // Save the image and get the local path. |
|
| 441 | + $image = Wordlift_Remote_Image_Service::save_from_url( $image_remote_url ); |
|
| 442 | + |
|
| 443 | + if ( false === $image || is_wp_error( $image ) ) { |
|
| 444 | + continue; |
|
| 445 | + } |
|
| 446 | + |
|
| 447 | + // Get the local URL. |
|
| 448 | + $filename = $image['path']; |
|
| 449 | + $url = $image['url']; |
|
| 450 | + $content_type = $image['content_type']; |
|
| 451 | + |
|
| 452 | + $attachment = array( |
|
| 453 | + 'guid' => $url, |
|
| 454 | + // post_title, post_content (the value for this key should be the empty string), post_status and post_mime_type |
|
| 455 | + 'post_title' => $label, |
|
| 456 | + // Set the title to the post title. |
|
| 457 | + 'post_content' => '', |
|
| 458 | + 'post_status' => 'inherit', |
|
| 459 | + 'post_mime_type' => $content_type, |
|
| 460 | + ); |
|
| 461 | 461 | |
| 462 | - // Create the attachment in WordPress and generate the related metadata. |
|
| 463 | - $attachment_id = wp_insert_attachment( $attachment, $filename, $post_id ); |
|
| 464 | - |
|
| 465 | - // Set the source URL for the image. |
|
| 466 | - wl_set_source_url( $attachment_id, $image_remote_url ); |
|
| 467 | - |
|
| 468 | - $attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename ); |
|
| 469 | - wp_update_attachment_metadata( $attachment_id, $attachment_data ); |
|
| 470 | - |
|
| 471 | - // Set it as the featured image. |
|
| 472 | - set_post_thumbnail( $post_id, $attachment_id ); |
|
| 473 | - } |
|
| 474 | - |
|
| 475 | - // The entity is pushed to Redlink on save by the function hooked to save_post. |
|
| 476 | - // save the entity in the triple store. |
|
| 477 | - do_action( 'wl_legacy_linked_data__push', $post_id ); |
|
| 478 | - |
|
| 479 | - // finally return the entity post. |
|
| 480 | - return get_post( $post_id ); |
|
| 462 | + // Create the attachment in WordPress and generate the related metadata. |
|
| 463 | + $attachment_id = wp_insert_attachment( $attachment, $filename, $post_id ); |
|
| 464 | + |
|
| 465 | + // Set the source URL for the image. |
|
| 466 | + wl_set_source_url( $attachment_id, $image_remote_url ); |
|
| 467 | + |
|
| 468 | + $attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename ); |
|
| 469 | + wp_update_attachment_metadata( $attachment_id, $attachment_data ); |
|
| 470 | + |
|
| 471 | + // Set it as the featured image. |
|
| 472 | + set_post_thumbnail( $post_id, $attachment_id ); |
|
| 473 | + } |
|
| 474 | + |
|
| 475 | + // The entity is pushed to Redlink on save by the function hooked to save_post. |
|
| 476 | + // save the entity in the triple store. |
|
| 477 | + do_action( 'wl_legacy_linked_data__push', $post_id ); |
|
| 478 | + |
|
| 479 | + // finally return the entity post. |
|
| 480 | + return get_post( $post_id ); |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | /** |
@@ -491,41 +491,41 @@ discard block |
||
| 491 | 491 | */ |
| 492 | 492 | function wl_linked_data_content_get_embedded_entities( $content ) { |
| 493 | 493 | |
| 494 | - // Remove quote escapes. |
|
| 495 | - $content = str_replace( '\\"', '"', $content ); |
|
| 494 | + // Remove quote escapes. |
|
| 495 | + $content = str_replace( '\\"', '"', $content ); |
|
| 496 | 496 | |
| 497 | - // Match all itemid attributes. |
|
| 498 | - $pattern = '/<\w+[^>]*\sitemid="([^"]+)"[^>]*>/im'; |
|
| 497 | + // Match all itemid attributes. |
|
| 498 | + $pattern = '/<\w+[^>]*\sitemid="([^"]+)"[^>]*>/im'; |
|
| 499 | 499 | |
| 500 | - // wl_write_log( "Getting entities embedded into content [ pattern :: $pattern ]" ); |
|
| 500 | + // wl_write_log( "Getting entities embedded into content [ pattern :: $pattern ]" ); |
|
| 501 | 501 | |
| 502 | - // Remove the pattern while it is found (match nested annotations). |
|
| 503 | - $matches = array(); |
|
| 502 | + // Remove the pattern while it is found (match nested annotations). |
|
| 503 | + $matches = array(); |
|
| 504 | 504 | |
| 505 | - // In case of errors, return an empty array. |
|
| 506 | - if ( false === preg_match_all( $pattern, $content, $matches ) ) { |
|
| 507 | - wl_write_log( "Found no entities embedded in content" ); |
|
| 505 | + // In case of errors, return an empty array. |
|
| 506 | + if ( false === preg_match_all( $pattern, $content, $matches ) ) { |
|
| 507 | + wl_write_log( "Found no entities embedded in content" ); |
|
| 508 | 508 | |
| 509 | - return array(); |
|
| 510 | - } |
|
| 509 | + return array(); |
|
| 510 | + } |
|
| 511 | 511 | |
| 512 | 512 | // wl_write_log("wl_update_related_entities [ content :: $content ][ data :: " . var_export($data, true). " ][ matches :: " . var_export($matches, true) . " ]"); |
| 513 | 513 | |
| 514 | - $uris = $matches[1]; |
|
| 515 | - // Collect the entities. |
|
| 516 | - $entities = array(); |
|
| 517 | - foreach ( $uris as $uri ) { |
|
| 518 | - $uri_d = html_entity_decode( $uri ); |
|
| 514 | + $uris = $matches[1]; |
|
| 515 | + // Collect the entities. |
|
| 516 | + $entities = array(); |
|
| 517 | + foreach ( $uris as $uri ) { |
|
| 518 | + $uri_d = html_entity_decode( $uri ); |
|
| 519 | 519 | |
| 520 | - $entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri_d ); |
|
| 520 | + $entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri_d ); |
|
| 521 | 521 | |
| 522 | - if ( null !== $entity ) { |
|
| 523 | - array_push( $entities, $entity->ID ); |
|
| 524 | - } |
|
| 525 | - } |
|
| 522 | + if ( null !== $entity ) { |
|
| 523 | + array_push( $entities, $entity->ID ); |
|
| 524 | + } |
|
| 525 | + } |
|
| 526 | 526 | |
| 527 | - // $count = sizeof( $entities ); |
|
| 528 | - // wl_write_log( "Found $count entities embedded in content" ); |
|
| 527 | + // $count = sizeof( $entities ); |
|
| 528 | + // wl_write_log( "Found $count entities embedded in content" ); |
|
| 529 | 529 | |
| 530 | - return $entities; |
|
| 530 | + return $entities; |
|
| 531 | 531 | } |
| 532 | 532 | \ No newline at end of file |
@@ -19,15 +19,15 @@ discard block |
||
| 19 | 19 | * @since 3.0.0 |
| 20 | 20 | * |
| 21 | 21 | */ |
| 22 | -function wl_linked_data_save_post( $post_id ) { |
|
| 22 | +function wl_linked_data_save_post($post_id) { |
|
| 23 | 23 | |
| 24 | - $log = Wordlift_Log_Service::get_logger( 'wl_linked_data_save_post' ); |
|
| 24 | + $log = Wordlift_Log_Service::get_logger('wl_linked_data_save_post'); |
|
| 25 | 25 | |
| 26 | - $log->trace( "Saving post $post_id to Linked Data..." ); |
|
| 26 | + $log->trace("Saving post $post_id to Linked Data..."); |
|
| 27 | 27 | |
| 28 | 28 | // If it's not numeric exit from here. |
| 29 | - if ( ! is_numeric( $post_id ) || is_numeric( wp_is_post_revision( $post_id ) ) ) { |
|
| 30 | - $log->debug( "Skipping $post_id, because id is not numeric or is a post revision." ); |
|
| 29 | + if ( ! is_numeric($post_id) || is_numeric(wp_is_post_revision($post_id))) { |
|
| 30 | + $log->debug("Skipping $post_id, because id is not numeric or is a post revision."); |
|
| 31 | 31 | |
| 32 | 32 | return; |
| 33 | 33 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | // Get the post type and check whether it supports the editor. |
| 36 | 36 | // |
| 37 | 37 | // @see https://github.com/insideout10/wordlift-plugin/issues/659. |
| 38 | - $post_type = get_post_type( $post_id ); |
|
| 38 | + $post_type = get_post_type($post_id); |
|
| 39 | 39 | /** |
| 40 | 40 | * Use `wl_post_type_supports_editor` which calls a filter to allow 3rd parties to change the setting. |
| 41 | 41 | * |
@@ -43,11 +43,11 @@ discard block |
||
| 43 | 43 | * |
| 44 | 44 | * @see https://github.com/insideout10/wordlift-plugin/issues/847. |
| 45 | 45 | */ |
| 46 | - $is_editor_supported = wl_post_type_supports_editor( $post_type ); |
|
| 46 | + $is_editor_supported = wl_post_type_supports_editor($post_type); |
|
| 47 | 47 | |
| 48 | 48 | // Bail out if it's not an entity. |
| 49 | - if ( ! $is_editor_supported ) { |
|
| 50 | - $log->debug( "Skipping $post_id, because $post_type doesn't support the editor (content)." ); |
|
| 49 | + if ( ! $is_editor_supported) { |
|
| 50 | + $log->debug("Skipping $post_id, because $post_type doesn't support the editor (content)."); |
|
| 51 | 51 | |
| 52 | 52 | return; |
| 53 | 53 | } |
@@ -61,23 +61,23 @@ discard block |
||
| 61 | 61 | $supported_types = Wordlift_Entity_Service::valid_entity_post_types(); |
| 62 | 62 | |
| 63 | 63 | // Bail out if it's not a valid entity. |
| 64 | - if ( ! in_array( $post_type, $supported_types ) ) { |
|
| 65 | - $log->debug( "Skipping $post_id, because $post_type is not a valid entity." ); |
|
| 64 | + if ( ! in_array($post_type, $supported_types)) { |
|
| 65 | + $log->debug("Skipping $post_id, because $post_type is not a valid entity."); |
|
| 66 | 66 | |
| 67 | 67 | return; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | // Unhook this function so it doesn't loop infinitely. |
| 71 | - remove_action( 'save_post', 'wl_linked_data_save_post' ); |
|
| 71 | + remove_action('save_post', 'wl_linked_data_save_post'); |
|
| 72 | 72 | |
| 73 | 73 | // raise the *wl_linked_data_save_post* event. |
| 74 | - do_action( 'wl_linked_data_save_post', $post_id ); |
|
| 74 | + do_action('wl_linked_data_save_post', $post_id); |
|
| 75 | 75 | |
| 76 | 76 | // Re-hook this function. |
| 77 | - add_action( 'save_post', 'wl_linked_data_save_post' ); |
|
| 77 | + add_action('save_post', 'wl_linked_data_save_post'); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | -add_action( 'save_post', 'wl_linked_data_save_post' ); |
|
| 80 | +add_action('save_post', 'wl_linked_data_save_post'); |
|
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | 83 | * Save the post to the triple store. Also saves the entities locally and on the triple store. |
@@ -87,23 +87,23 @@ discard block |
||
| 87 | 87 | * @since 3.0.0 |
| 88 | 88 | * |
| 89 | 89 | */ |
| 90 | -function wl_linked_data_save_post_and_related_entities( $post_id ) { |
|
| 90 | +function wl_linked_data_save_post_and_related_entities($post_id) { |
|
| 91 | 91 | |
| 92 | - $log = Wordlift_Log_Service::get_logger( 'wl_linked_data_save_post_and_related_entities' ); |
|
| 92 | + $log = Wordlift_Log_Service::get_logger('wl_linked_data_save_post_and_related_entities'); |
|
| 93 | 93 | |
| 94 | - $log->trace( "Saving $post_id to Linked Data along with related entities..." ); |
|
| 94 | + $log->trace("Saving $post_id to Linked Data along with related entities..."); |
|
| 95 | 95 | |
| 96 | 96 | // Ignore auto-saves |
| 97 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
| 98 | - $log->trace( 'Doing autosave, skipping...' ); |
|
| 97 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
| 98 | + $log->trace('Doing autosave, skipping...'); |
|
| 99 | 99 | |
| 100 | 100 | return; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | // get the current post. |
| 104 | - $post = get_post( $post_id ); |
|
| 104 | + $post = get_post($post_id); |
|
| 105 | 105 | |
| 106 | - remove_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' ); |
|
| 106 | + remove_action('wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities'); |
|
| 107 | 107 | |
| 108 | 108 | // wl_write_log( "[ post id :: $post_id ][ autosave :: false ][ post type :: $post->post_type ]" ); |
| 109 | 109 | |
@@ -114,49 +114,49 @@ discard block |
||
| 114 | 114 | $entities_uri_mapping = array(); |
| 115 | 115 | |
| 116 | 116 | // Save the entities coming with POST data. |
| 117 | - if ( isset( $_POST['wl_entities'] ) && isset( $_POST['wl_boxes'] ) ) { |
|
| 117 | + if (isset($_POST['wl_entities']) && isset($_POST['wl_boxes'])) { |
|
| 118 | 118 | |
| 119 | - wl_write_log( "[ post id :: $post_id ][ POST(wl_entities) :: " ); |
|
| 120 | - wl_write_log( json_encode( $_POST['wl_entities'] ) ); |
|
| 121 | - wl_write_log( "]" ); |
|
| 122 | - wl_write_log( "[ post id :: $post_id ][ POST(wl_boxes) :: " ); |
|
| 123 | - wl_write_log( json_encode( $_POST['wl_boxes'], true ) ); |
|
| 124 | - wl_write_log( "]" ); |
|
| 119 | + wl_write_log("[ post id :: $post_id ][ POST(wl_entities) :: "); |
|
| 120 | + wl_write_log(json_encode($_POST['wl_entities'])); |
|
| 121 | + wl_write_log("]"); |
|
| 122 | + wl_write_log("[ post id :: $post_id ][ POST(wl_boxes) :: "); |
|
| 123 | + wl_write_log(json_encode($_POST['wl_boxes'], true)); |
|
| 124 | + wl_write_log("]"); |
|
| 125 | 125 | |
| 126 | 126 | $entities_via_post = $_POST['wl_entities']; |
| 127 | 127 | $boxes_via_post = $_POST['wl_boxes']; |
| 128 | 128 | |
| 129 | - foreach ( $entities_via_post as $entity_uri => $entity ) { |
|
| 129 | + foreach ($entities_via_post as $entity_uri => $entity) { |
|
| 130 | 130 | |
| 131 | 131 | // Only if the current entity is created from scratch let's avoid to |
| 132 | 132 | // create more than one entity with same label & entity type. |
| 133 | - $entity_type = ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) ? |
|
| 133 | + $entity_type = (preg_match('/^local-entity-.+/', $entity_uri) > 0) ? |
|
| 134 | 134 | $entity['main_type'] : null; |
| 135 | 135 | |
| 136 | 136 | // Look if current entity uri matches an internal existing entity, meaning: |
| 137 | 137 | // 1. when $entity_uri is an internal uri |
| 138 | 138 | // 2. when $entity_uri is an external uri used as sameAs of an internal entity |
| 139 | - $ie = $entity_service->get_entity_post_by_uri( $entity_uri ); |
|
| 139 | + $ie = $entity_service->get_entity_post_by_uri($entity_uri); |
|
| 140 | 140 | |
| 141 | 141 | // Dont save the entities which are not found, but also local. |
| 142 | - if ( $ie === null && Wordlift_Entity_Uri_Service::get_instance()->is_internal( $entity_uri ) ) { |
|
| 142 | + if ($ie === null && Wordlift_Entity_Uri_Service::get_instance()->is_internal($entity_uri)) { |
|
| 143 | 143 | continue; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | // Detect the uri depending if is an existing or a new entity |
| 147 | - $uri = ( null === $ie ) ? |
|
| 147 | + $uri = (null === $ie) ? |
|
| 148 | 148 | Wordlift_Uri_Service::get_instance()->build_uri( |
| 149 | 149 | $entity['label'], |
| 150 | 150 | Wordlift_Entity_Service::TYPE_NAME, |
| 151 | 151 | $entity_type |
| 152 | - ) : wl_get_entity_uri( $ie->ID ); |
|
| 152 | + ) : wl_get_entity_uri($ie->ID); |
|
| 153 | 153 | |
| 154 | - wl_write_log( "Map $entity_uri on $uri" ); |
|
| 155 | - $entities_uri_mapping[ $entity_uri ] = $uri; |
|
| 154 | + wl_write_log("Map $entity_uri on $uri"); |
|
| 155 | + $entities_uri_mapping[$entity_uri] = $uri; |
|
| 156 | 156 | |
| 157 | 157 | // Local entities have a tmp uri with 'local-entity-' prefix |
| 158 | 158 | // These uris need to be rewritten here and replaced in the content |
| 159 | - if ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) { |
|
| 159 | + if (preg_match('/^local-entity-.+/', $entity_uri) > 0) { |
|
| 160 | 160 | // Override the entity obj |
| 161 | 161 | $entity['uri'] = $uri; |
| 162 | 162 | } |
@@ -165,8 +165,8 @@ discard block |
||
| 165 | 165 | $entity['related_post_id'] = $post_id; |
| 166 | 166 | |
| 167 | 167 | // Save the entity if is a new entity |
| 168 | - if ( null === $ie ) { |
|
| 169 | - wl_save_entity( $entity ); |
|
| 168 | + if (null === $ie) { |
|
| 169 | + wl_save_entity($entity); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | } |
@@ -177,14 +177,14 @@ discard block |
||
| 177 | 177 | $updated_post_content = $post->post_content; |
| 178 | 178 | |
| 179 | 179 | // Update the post content if we found mappings of new entities. |
| 180 | - if ( ! empty( $entities_uri_mapping ) ) { |
|
| 180 | + if ( ! empty($entities_uri_mapping)) { |
|
| 181 | 181 | // Save each entity and store the post id. |
| 182 | - foreach ( $entities_uri_mapping as $tmp_uri => $uri ) { |
|
| 183 | - if ( 1 !== preg_match( '@^(https?://|local-entity-)@', $tmp_uri ) ) { |
|
| 182 | + foreach ($entities_uri_mapping as $tmp_uri => $uri) { |
|
| 183 | + if (1 !== preg_match('@^(https?://|local-entity-)@', $tmp_uri)) { |
|
| 184 | 184 | continue; |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - $updated_post_content = str_replace( $tmp_uri, $uri, $updated_post_content ); |
|
| 187 | + $updated_post_content = str_replace($tmp_uri, $uri, $updated_post_content); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | // Update the post content. |
@@ -193,19 +193,19 @@ discard block |
||
| 193 | 193 | * content, so add the slashes to prevent back slash getting |
| 194 | 194 | * removed. |
| 195 | 195 | */ |
| 196 | - wp_update_post( array( |
|
| 196 | + wp_update_post(array( |
|
| 197 | 197 | 'ID' => $post->ID, |
| 198 | - 'post_content' => addslashes( $updated_post_content ), |
|
| 199 | - ) ); |
|
| 198 | + 'post_content' => addslashes($updated_post_content), |
|
| 199 | + )); |
|
| 200 | 200 | } |
| 201 | 201 | // Reset previously saved instances. |
| 202 | - wl_core_delete_relation_instances( $post_id ); |
|
| 202 | + wl_core_delete_relation_instances($post_id); |
|
| 203 | 203 | |
| 204 | - $relations = Object_Relation_Factory::get_instance( $post_id ) |
|
| 205 | - ->get_relations_from_content( $updated_post_content, Object_Type_Enum::POST ); |
|
| 204 | + $relations = Object_Relation_Factory::get_instance($post_id) |
|
| 205 | + ->get_relations_from_content($updated_post_content, Object_Type_Enum::POST); |
|
| 206 | 206 | |
| 207 | 207 | // Save relation instances |
| 208 | - foreach ( $relations as $relation ) { |
|
| 208 | + foreach ($relations as $relation) { |
|
| 209 | 209 | |
| 210 | 210 | wl_core_add_relation_instance( |
| 211 | 211 | // subject id. |
@@ -222,9 +222,9 @@ discard block |
||
| 222 | 222 | |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - if ( isset( $_POST['wl_entities'] ) ) { |
|
| 225 | + if (isset($_POST['wl_entities'])) { |
|
| 226 | 226 | // Save post metadata if available |
| 227 | - $metadata_via_post = ( isset( $_POST['wl_metadata'] ) ) ? |
|
| 227 | + $metadata_via_post = (isset($_POST['wl_metadata'])) ? |
|
| 228 | 228 | $_POST['wl_metadata'] : array(); |
| 229 | 229 | |
| 230 | 230 | $fields = array( |
@@ -233,35 +233,35 @@ discard block |
||
| 233 | 233 | ); |
| 234 | 234 | |
| 235 | 235 | // Unlink topic taxonomy terms |
| 236 | - Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for( $post->ID ); |
|
| 236 | + Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for($post->ID); |
|
| 237 | 237 | |
| 238 | - foreach ( $fields as $field ) { |
|
| 238 | + foreach ($fields as $field) { |
|
| 239 | 239 | |
| 240 | 240 | // Delete current values |
| 241 | - delete_post_meta( $post->ID, $field ); |
|
| 241 | + delete_post_meta($post->ID, $field); |
|
| 242 | 242 | // Retrieve the entity uri |
| 243 | - $uri = ( isset( $metadata_via_post[ $field ] ) ) ? |
|
| 244 | - stripslashes( $metadata_via_post[ $field ] ) : ''; |
|
| 243 | + $uri = (isset($metadata_via_post[$field])) ? |
|
| 244 | + stripslashes($metadata_via_post[$field]) : ''; |
|
| 245 | 245 | |
| 246 | - $entity = $entity_service->get_entity_post_by_uri( $uri ); |
|
| 246 | + $entity = $entity_service->get_entity_post_by_uri($uri); |
|
| 247 | 247 | |
| 248 | - if ( $entity ) { |
|
| 249 | - add_post_meta( $post->ID, $field, $entity->ID, true ); |
|
| 248 | + if ($entity) { |
|
| 249 | + add_post_meta($post->ID, $field, $entity->ID, true); |
|
| 250 | 250 | // Set also the topic taxonomy |
| 251 | - if ( $field === Wordlift_Schema_Service::FIELD_TOPIC ) { |
|
| 252 | - Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for( $post->ID, $entity ); |
|
| 251 | + if ($field === Wordlift_Schema_Service::FIELD_TOPIC) { |
|
| 252 | + Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for($post->ID, $entity); |
|
| 253 | 253 | } |
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | // Push the post to Redlink. |
| 259 | - do_action( 'wl_legacy_linked_data__push', $post->ID ); |
|
| 259 | + do_action('wl_legacy_linked_data__push', $post->ID); |
|
| 260 | 260 | |
| 261 | - add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' ); |
|
| 261 | + add_action('wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities'); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | -add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' ); |
|
| 264 | +add_action('wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities'); |
|
| 265 | 265 | |
| 266 | 266 | /** |
| 267 | 267 | * Save the specified data as an entity in WordPress. This method only create new entities. When an existing entity is |
@@ -279,14 +279,14 @@ discard block |
||
| 279 | 279 | * |
| 280 | 280 | * @return null|WP_Post A post instance or null in case of failure. |
| 281 | 281 | */ |
| 282 | -function wl_save_entity( $entity_data ) { |
|
| 282 | +function wl_save_entity($entity_data) { |
|
| 283 | 283 | |
| 284 | 284 | // Required for REST API calls |
| 285 | - if ( ! function_exists( 'wp_crop_image' ) ) { |
|
| 286 | - require_once( ABSPATH . 'wp-admin/includes/image.php' ); |
|
| 285 | + if ( ! function_exists('wp_crop_image')) { |
|
| 286 | + require_once(ABSPATH.'wp-admin/includes/image.php'); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - $log = Wordlift_Log_Service::get_logger( 'wl_save_entity' ); |
|
| 289 | + $log = Wordlift_Log_Service::get_logger('wl_save_entity'); |
|
| 290 | 290 | |
| 291 | 291 | $uri = $entity_data['uri']; |
| 292 | 292 | /* |
@@ -296,28 +296,28 @@ discard block |
||
| 296 | 296 | * |
| 297 | 297 | * @see https://github.com/insideout10/wordlift-plugin/issues/841 |
| 298 | 298 | */ |
| 299 | - $label = preg_replace( '/\xEF\xBB\xBF/', '', sanitize_text_field( $entity_data['label'] ) ); |
|
| 299 | + $label = preg_replace('/\xEF\xBB\xBF/', '', sanitize_text_field($entity_data['label'])); |
|
| 300 | 300 | $type_uri = $entity_data['main_type']; |
| 301 | - $entity_types = isset( $entity_data['type'] ) ? $entity_data['type'] : array(); |
|
| 301 | + $entity_types = isset($entity_data['type']) ? $entity_data['type'] : array(); |
|
| 302 | 302 | $description = $entity_data['description']; |
| 303 | - $images = isset( $entity_data['image'] ) ? (array) $entity_data['image'] : array(); |
|
| 304 | - $same_as = isset( $entity_data['sameas'] ) ? (array) $entity_data['sameas'] : array(); |
|
| 305 | - $related_post_id = isset( $entity_data['related_post_id'] ) ? $entity_data['related_post_id'] : null; |
|
| 306 | - $other_properties = isset( $entity_data['properties'] ) ? $entity_data['properties'] : array(); |
|
| 303 | + $images = isset($entity_data['image']) ? (array) $entity_data['image'] : array(); |
|
| 304 | + $same_as = isset($entity_data['sameas']) ? (array) $entity_data['sameas'] : array(); |
|
| 305 | + $related_post_id = isset($entity_data['related_post_id']) ? $entity_data['related_post_id'] : null; |
|
| 306 | + $other_properties = isset($entity_data['properties']) ? $entity_data['properties'] : array(); |
|
| 307 | 307 | |
| 308 | 308 | // Get the synonyms. |
| 309 | - $synonyms = isset( $entity_data['synonym'] ) ? $entity_data['synonym'] : array(); |
|
| 309 | + $synonyms = isset($entity_data['synonym']) ? $entity_data['synonym'] : array(); |
|
| 310 | 310 | |
| 311 | 311 | // Check whether an entity already exists with the provided URI. |
| 312 | - if ( null !== $post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri ) ) { |
|
| 313 | - $log->debug( "Post already exists for URI $uri." ); |
|
| 312 | + if (null !== $post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri($uri)) { |
|
| 313 | + $log->debug("Post already exists for URI $uri."); |
|
| 314 | 314 | |
| 315 | 315 | return $post; |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | // Prepare properties of the new entity. |
| 319 | 319 | $params = array( |
| 320 | - 'post_status' => ( is_numeric( $related_post_id ) ? get_post_status( $related_post_id ) : 'draft' ), |
|
| 320 | + 'post_status' => (is_numeric($related_post_id) ? get_post_status($related_post_id) : 'draft'), |
|
| 321 | 321 | 'post_type' => Wordlift_Entity_Service::TYPE_NAME, |
| 322 | 322 | 'post_title' => $label, |
| 323 | 323 | 'post_content' => $description, |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | // new entities. |
| 328 | 328 | // |
| 329 | 329 | // See https://github.com/insideout10/wordlift-plugin/issues/282 |
| 330 | - 'post_name' => sanitize_title( $label ), |
|
| 330 | + 'post_name' => sanitize_title($label), |
|
| 331 | 331 | ); |
| 332 | 332 | |
| 333 | 333 | // If Yoast is installed and active, we temporary remove the save_postdata hook which causes Yoast to "pass over" |
@@ -336,18 +336,18 @@ discard block |
||
| 336 | 336 | // This does NOT affect saving an entity from the entity admin page since this function is called when an entity |
| 337 | 337 | // is created when saving a post. |
| 338 | 338 | global $wpseo_metabox, $seo_ultimate; |
| 339 | - if ( isset( $wpseo_metabox ) ) { |
|
| 340 | - remove_action( 'wp_insert_post', array( |
|
| 339 | + if (isset($wpseo_metabox)) { |
|
| 340 | + remove_action('wp_insert_post', array( |
|
| 341 | 341 | $wpseo_metabox, |
| 342 | 342 | 'save_postdata', |
| 343 | - ) ); |
|
| 343 | + )); |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | - if ( isset( $seo_ultimate ) ) { |
|
| 347 | - remove_action( 'save_post', array( |
|
| 346 | + if (isset($seo_ultimate)) { |
|
| 347 | + remove_action('save_post', array( |
|
| 348 | 348 | $seo_ultimate, |
| 349 | 349 | 'save_postmeta_box', |
| 350 | - ) ); |
|
| 350 | + )); |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | // The fact that we're calling here wp_insert_post is causing issues with plugins (and ourselves too) that hook to |
@@ -357,90 +357,90 @@ discard block |
||
| 357 | 357 | // see https://github.com/insideout10/wordlift-plugin/issues/156 |
| 358 | 358 | // see https://github.com/insideout10/wordlift-plugin/issues/148 |
| 359 | 359 | global $wp_filter; |
| 360 | - $save_post_filters = is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] : $wp_filter['save_post']->callbacks; |
|
| 361 | - is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = array() : $wp_filter['save_post']->remove_all_filters(); |
|
| 360 | + $save_post_filters = is_array($wp_filter['save_post']) ? $wp_filter['save_post'] : $wp_filter['save_post']->callbacks; |
|
| 361 | + is_array($wp_filter['save_post']) ? $wp_filter['save_post'] = array() : $wp_filter['save_post']->remove_all_filters(); |
|
| 362 | 362 | |
| 363 | 363 | |
| 364 | - $log->trace( 'Going to insert new post...' ); |
|
| 364 | + $log->trace('Going to insert new post...'); |
|
| 365 | 365 | |
| 366 | 366 | // create or update the post. |
| 367 | - $post_id = wp_insert_post( $params, true ); |
|
| 367 | + $post_id = wp_insert_post($params, true); |
|
| 368 | 368 | |
| 369 | 369 | // Setting the alternative labels for this entity. |
| 370 | 370 | Wordlift_Entity_Service::get_instance() |
| 371 | - ->set_alternative_labels( $post_id, $synonyms ); |
|
| 371 | + ->set_alternative_labels($post_id, $synonyms); |
|
| 372 | 372 | |
| 373 | 373 | // Restore all the existing filters. |
| 374 | - is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = $save_post_filters : $wp_filter['save_post']->callbacks = $save_post_filters; |
|
| 374 | + is_array($wp_filter['save_post']) ? $wp_filter['save_post'] = $save_post_filters : $wp_filter['save_post']->callbacks = $save_post_filters; |
|
| 375 | 375 | |
| 376 | 376 | // If Yoast is installed and active, we restore the Yoast save_postdata hook (https://github.com/insideout10/wordlift-plugin/issues/156) |
| 377 | - if ( isset( $wpseo_metabox ) ) { |
|
| 378 | - add_action( 'wp_insert_post', array( |
|
| 377 | + if (isset($wpseo_metabox)) { |
|
| 378 | + add_action('wp_insert_post', array( |
|
| 379 | 379 | $wpseo_metabox, |
| 380 | 380 | 'save_postdata', |
| 381 | - ) ); |
|
| 381 | + )); |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | // If SEO Ultimate is installed, add back the hook we removed a few lines above. |
| 385 | - if ( isset( $seo_ultimate ) ) { |
|
| 386 | - add_action( 'save_post', array( |
|
| 385 | + if (isset($seo_ultimate)) { |
|
| 386 | + add_action('save_post', array( |
|
| 387 | 387 | $seo_ultimate, |
| 388 | 388 | 'save_postmeta_box', |
| 389 | - ), 10, 2 ); |
|
| 389 | + ), 10, 2); |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | // TODO: handle errors. |
| 393 | - if ( is_wp_error( $post_id ) ) { |
|
| 394 | - $log->error( 'An error occurred: ' . $post_id->get_error_message() ); |
|
| 393 | + if (is_wp_error($post_id)) { |
|
| 394 | + $log->error('An error occurred: '.$post_id->get_error_message()); |
|
| 395 | 395 | |
| 396 | 396 | // inform an error occurred. |
| 397 | 397 | return null; |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | - wl_set_entity_main_type( $post_id, $type_uri ); |
|
| 400 | + wl_set_entity_main_type($post_id, $type_uri); |
|
| 401 | 401 | |
| 402 | 402 | // Save the entity types. |
| 403 | - wl_set_entity_rdf_types( $post_id, $entity_types ); |
|
| 403 | + wl_set_entity_rdf_types($post_id, $entity_types); |
|
| 404 | 404 | |
| 405 | 405 | // Get a dataset URI for the entity. |
| 406 | - $wl_uri = Wordlift_Entity_Service::get_instance()->get_uri( $post_id ); |
|
| 406 | + $wl_uri = Wordlift_Entity_Service::get_instance()->get_uri($post_id); |
|
| 407 | 407 | |
| 408 | 408 | // Add the uri to the sameAs data if it's not a local URI. |
| 409 | - if ( $wl_uri !== $uri ) { |
|
| 410 | - array_push( $same_as, $uri ); |
|
| 409 | + if ($wl_uri !== $uri) { |
|
| 410 | + array_push($same_as, $uri); |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | // Save the sameAs data for the entity. |
| 414 | - wl_schema_set_value( $post_id, 'sameAs', $same_as ); |
|
| 414 | + wl_schema_set_value($post_id, 'sameAs', $same_as); |
|
| 415 | 415 | |
| 416 | 416 | // Save the other properties (latitude, langitude, startDate, endDate, etc.) |
| 417 | - foreach ( $other_properties as $property_name => $property_value ) { |
|
| 418 | - wl_schema_set_value( $post_id, $property_name, $property_value ); |
|
| 417 | + foreach ($other_properties as $property_name => $property_value) { |
|
| 418 | + wl_schema_set_value($post_id, $property_name, $property_value); |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | // Call hooks. |
| 422 | - do_action( 'wl_save_entity', $post_id ); |
|
| 422 | + do_action('wl_save_entity', $post_id); |
|
| 423 | 423 | |
| 424 | - foreach ( $images as $image_remote_url ) { |
|
| 424 | + foreach ($images as $image_remote_url) { |
|
| 425 | 425 | |
| 426 | 426 | // Check if image is already present in local DB |
| 427 | - if ( strpos( $image_remote_url, site_url() ) !== false ) { |
|
| 427 | + if (strpos($image_remote_url, site_url()) !== false) { |
|
| 428 | 428 | // Do nothing. |
| 429 | 429 | continue; |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | // Check if there is an existing attachment for this post ID and source URL. |
| 433 | - $existing_image = wl_get_attachment_for_source_url( $post_id, $image_remote_url ); |
|
| 433 | + $existing_image = wl_get_attachment_for_source_url($post_id, $image_remote_url); |
|
| 434 | 434 | |
| 435 | 435 | // Skip if an existing image is found. |
| 436 | - if ( null !== $existing_image ) { |
|
| 436 | + if (null !== $existing_image) { |
|
| 437 | 437 | continue; |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | // Save the image and get the local path. |
| 441 | - $image = Wordlift_Remote_Image_Service::save_from_url( $image_remote_url ); |
|
| 441 | + $image = Wordlift_Remote_Image_Service::save_from_url($image_remote_url); |
|
| 442 | 442 | |
| 443 | - if ( false === $image || is_wp_error( $image ) ) { |
|
| 443 | + if (false === $image || is_wp_error($image)) { |
|
| 444 | 444 | continue; |
| 445 | 445 | } |
| 446 | 446 | |
@@ -460,24 +460,24 @@ discard block |
||
| 460 | 460 | ); |
| 461 | 461 | |
| 462 | 462 | // Create the attachment in WordPress and generate the related metadata. |
| 463 | - $attachment_id = wp_insert_attachment( $attachment, $filename, $post_id ); |
|
| 463 | + $attachment_id = wp_insert_attachment($attachment, $filename, $post_id); |
|
| 464 | 464 | |
| 465 | 465 | // Set the source URL for the image. |
| 466 | - wl_set_source_url( $attachment_id, $image_remote_url ); |
|
| 466 | + wl_set_source_url($attachment_id, $image_remote_url); |
|
| 467 | 467 | |
| 468 | - $attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename ); |
|
| 469 | - wp_update_attachment_metadata( $attachment_id, $attachment_data ); |
|
| 468 | + $attachment_data = wp_generate_attachment_metadata($attachment_id, $filename); |
|
| 469 | + wp_update_attachment_metadata($attachment_id, $attachment_data); |
|
| 470 | 470 | |
| 471 | 471 | // Set it as the featured image. |
| 472 | - set_post_thumbnail( $post_id, $attachment_id ); |
|
| 472 | + set_post_thumbnail($post_id, $attachment_id); |
|
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | // The entity is pushed to Redlink on save by the function hooked to save_post. |
| 476 | 476 | // save the entity in the triple store. |
| 477 | - do_action( 'wl_legacy_linked_data__push', $post_id ); |
|
| 477 | + do_action('wl_legacy_linked_data__push', $post_id); |
|
| 478 | 478 | |
| 479 | 479 | // finally return the entity post. |
| 480 | - return get_post( $post_id ); |
|
| 480 | + return get_post($post_id); |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | /** |
@@ -489,10 +489,10 @@ discard block |
||
| 489 | 489 | * @since 3.0.0 |
| 490 | 490 | * |
| 491 | 491 | */ |
| 492 | -function wl_linked_data_content_get_embedded_entities( $content ) { |
|
| 492 | +function wl_linked_data_content_get_embedded_entities($content) { |
|
| 493 | 493 | |
| 494 | 494 | // Remove quote escapes. |
| 495 | - $content = str_replace( '\\"', '"', $content ); |
|
| 495 | + $content = str_replace('\\"', '"', $content); |
|
| 496 | 496 | |
| 497 | 497 | // Match all itemid attributes. |
| 498 | 498 | $pattern = '/<\w+[^>]*\sitemid="([^"]+)"[^>]*>/im'; |
@@ -503,24 +503,24 @@ discard block |
||
| 503 | 503 | $matches = array(); |
| 504 | 504 | |
| 505 | 505 | // In case of errors, return an empty array. |
| 506 | - if ( false === preg_match_all( $pattern, $content, $matches ) ) { |
|
| 507 | - wl_write_log( "Found no entities embedded in content" ); |
|
| 506 | + if (false === preg_match_all($pattern, $content, $matches)) { |
|
| 507 | + wl_write_log("Found no entities embedded in content"); |
|
| 508 | 508 | |
| 509 | 509 | return array(); |
| 510 | 510 | } |
| 511 | 511 | |
| 512 | 512 | // wl_write_log("wl_update_related_entities [ content :: $content ][ data :: " . var_export($data, true). " ][ matches :: " . var_export($matches, true) . " ]"); |
| 513 | 513 | |
| 514 | - $uris = $matches[1]; |
|
| 514 | + $uris = $matches[1]; |
|
| 515 | 515 | // Collect the entities. |
| 516 | 516 | $entities = array(); |
| 517 | - foreach ( $uris as $uri ) { |
|
| 518 | - $uri_d = html_entity_decode( $uri ); |
|
| 517 | + foreach ($uris as $uri) { |
|
| 518 | + $uri_d = html_entity_decode($uri); |
|
| 519 | 519 | |
| 520 | - $entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri_d ); |
|
| 520 | + $entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri($uri_d); |
|
| 521 | 521 | |
| 522 | - if ( null !== $entity ) { |
|
| 523 | - array_push( $entities, $entity->ID ); |
|
| 522 | + if (null !== $entity) { |
|
| 523 | + array_push($entities, $entity->ID); |
|
| 524 | 524 | } |
| 525 | 525 | } |
| 526 | 526 | |
@@ -84,1651 +84,1651 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | class Wordlift { |
| 86 | 86 | |
| 87 | - //<editor-fold desc="## FIELDS"> |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * The loader that's responsible for maintaining and registering all hooks that power |
|
| 91 | - * the plugin. |
|
| 92 | - * |
|
| 93 | - * @since 1.0.0 |
|
| 94 | - * @access protected |
|
| 95 | - * @var Wordlift_Loader $loader Maintains and registers all hooks for the plugin. |
|
| 96 | - */ |
|
| 97 | - protected $loader; |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * The unique identifier of this plugin. |
|
| 101 | - * |
|
| 102 | - * @since 1.0.0 |
|
| 103 | - * @access protected |
|
| 104 | - * @var string $plugin_name The string used to uniquely identify this plugin. |
|
| 105 | - */ |
|
| 106 | - protected $plugin_name; |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * The current version of the plugin. |
|
| 110 | - * |
|
| 111 | - * @since 1.0.0 |
|
| 112 | - * @access protected |
|
| 113 | - * @var string $version The current version of the plugin. |
|
| 114 | - */ |
|
| 115 | - protected $version; |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 119 | - * |
|
| 120 | - * @since 3.12.0 |
|
| 121 | - * @access protected |
|
| 122 | - * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 123 | - */ |
|
| 124 | - protected $tinymce_adapter; |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * The {@link Faq_Tinymce_Adapter} instance |
|
| 128 | - * @since 3.26.0 |
|
| 129 | - * @access protected |
|
| 130 | - * @var Faq_Tinymce_Adapter $faq_tinymce_adapter . |
|
| 131 | - */ |
|
| 132 | - //protected $faq_tinymce_adapter; |
|
| 133 | - |
|
| 134 | - /** |
|
| 135 | - * The Thumbnail service. |
|
| 136 | - * |
|
| 137 | - * @since 3.1.5 |
|
| 138 | - * @access private |
|
| 139 | - * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service. |
|
| 140 | - */ |
|
| 141 | - private $thumbnail_service; |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * The UI service. |
|
| 145 | - * |
|
| 146 | - * @since 3.2.0 |
|
| 147 | - * @access private |
|
| 148 | - * @var \Wordlift_UI_Service $ui_service The UI service. |
|
| 149 | - */ |
|
| 150 | - private $ui_service; |
|
| 151 | - |
|
| 152 | - /** |
|
| 153 | - * The Schema service. |
|
| 154 | - * |
|
| 155 | - * @since 3.3.0 |
|
| 156 | - * @access protected |
|
| 157 | - * @var \Wordlift_Schema_Service $schema_service The Schema service. |
|
| 158 | - */ |
|
| 159 | - protected $schema_service; |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * The Entity service. |
|
| 163 | - * |
|
| 164 | - * @since 3.1.0 |
|
| 165 | - * @access protected |
|
| 166 | - * @var \Wordlift_Entity_Service $entity_service The Entity service. |
|
| 167 | - */ |
|
| 168 | - protected $entity_service; |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * The Topic Taxonomy service. |
|
| 172 | - * |
|
| 173 | - * @since 3.5.0 |
|
| 174 | - * @access private |
|
| 175 | - * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service. |
|
| 176 | - */ |
|
| 177 | - private $topic_taxonomy_service; |
|
| 178 | - |
|
| 179 | - /** |
|
| 180 | - * The Entity Types Taxonomy service. |
|
| 181 | - * |
|
| 182 | - * @since 3.18.0 |
|
| 183 | - * @access private |
|
| 184 | - * @var \Wordlift_Entity_Type_Taxonomy_Service The Entity Types Taxonomy service. |
|
| 185 | - */ |
|
| 186 | - private $entity_types_taxonomy_service; |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * The User service. |
|
| 190 | - * |
|
| 191 | - * @since 3.1.7 |
|
| 192 | - * @access protected |
|
| 193 | - * @var \Wordlift_User_Service $user_service The User service. |
|
| 194 | - */ |
|
| 195 | - protected $user_service; |
|
| 196 | - |
|
| 197 | - /** |
|
| 198 | - * The Timeline service. |
|
| 199 | - * |
|
| 200 | - * @since 3.1.0 |
|
| 201 | - * @access private |
|
| 202 | - * @var \Wordlift_Timeline_Service $timeline_service The Timeline service. |
|
| 203 | - */ |
|
| 204 | - private $timeline_service; |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * The Redirect service. |
|
| 208 | - * |
|
| 209 | - * @since 3.2.0 |
|
| 210 | - * @access private |
|
| 211 | - * @var \Wordlift_Redirect_Service $redirect_service The Redirect service. |
|
| 212 | - */ |
|
| 213 | - private $redirect_service; |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * The Notice service. |
|
| 217 | - * |
|
| 218 | - * @since 3.3.0 |
|
| 219 | - * @access private |
|
| 220 | - * @var \Wordlift_Notice_Service $notice_service The Notice service. |
|
| 221 | - */ |
|
| 222 | - private $notice_service; |
|
| 223 | - |
|
| 224 | - /** |
|
| 225 | - * The Entity list customization. |
|
| 226 | - * |
|
| 227 | - * @since 3.3.0 |
|
| 228 | - * @access protected |
|
| 229 | - * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service. |
|
| 230 | - */ |
|
| 231 | - protected $entity_list_service; |
|
| 232 | - |
|
| 233 | - /** |
|
| 234 | - * The Entity Types Taxonomy Walker. |
|
| 235 | - * |
|
| 236 | - * @since 3.1.0 |
|
| 237 | - * @access private |
|
| 238 | - * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker |
|
| 239 | - */ |
|
| 240 | - private $entity_types_taxonomy_walker; |
|
| 241 | - |
|
| 242 | - /** |
|
| 243 | - * The ShareThis service. |
|
| 244 | - * |
|
| 245 | - * @since 3.2.0 |
|
| 246 | - * @access private |
|
| 247 | - * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service. |
|
| 248 | - */ |
|
| 249 | - private $sharethis_service; |
|
| 250 | - |
|
| 251 | - /** |
|
| 252 | - * The PrimaShop adapter. |
|
| 253 | - * |
|
| 254 | - * @since 3.2.3 |
|
| 255 | - * @access private |
|
| 256 | - * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter. |
|
| 257 | - */ |
|
| 258 | - private $primashop_adapter; |
|
| 259 | - |
|
| 260 | - /** |
|
| 261 | - * The WordLift Dashboard adapter. |
|
| 262 | - * |
|
| 263 | - * @since 3.4.0 |
|
| 264 | - * @access private |
|
| 265 | - * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service; |
|
| 266 | - */ |
|
| 267 | - private $dashboard_service; |
|
| 268 | - |
|
| 269 | - /** |
|
| 270 | - * The entity type service. |
|
| 271 | - * |
|
| 272 | - * @since 3.6.0 |
|
| 273 | - * @access private |
|
| 274 | - * @var \Wordlift_Entity_Post_Type_Service |
|
| 275 | - */ |
|
| 276 | - private $entity_post_type_service; |
|
| 277 | - |
|
| 278 | - /** |
|
| 279 | - * The entity link service used to mangle links to entities with a custom slug or even w/o a slug. |
|
| 280 | - * |
|
| 281 | - * @since 3.6.0 |
|
| 282 | - * @access private |
|
| 283 | - * @var \Wordlift_Entity_Link_Service $entity_link_service The {@link Wordlift_Entity_Link_Service} instance. |
|
| 284 | - */ |
|
| 285 | - private $entity_link_service; |
|
| 286 | - |
|
| 287 | - /** |
|
| 288 | - * A {@link Wordlift_Sparql_Service} instance. |
|
| 289 | - * |
|
| 290 | - * @since 3.6.0 |
|
| 291 | - * @access protected |
|
| 292 | - * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance. |
|
| 293 | - */ |
|
| 294 | - protected $sparql_service; |
|
| 295 | - |
|
| 296 | - /** |
|
| 297 | - * A {@link Wordlift_Import_Service} instance. |
|
| 298 | - * |
|
| 299 | - * @since 3.6.0 |
|
| 300 | - * @access private |
|
| 301 | - * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance. |
|
| 302 | - */ |
|
| 303 | - private $import_service; |
|
| 304 | - |
|
| 305 | - /** |
|
| 306 | - * A {@link Wordlift_Rebuild_Service} instance. |
|
| 307 | - * |
|
| 308 | - * @since 3.6.0 |
|
| 309 | - * @access private |
|
| 310 | - * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance. |
|
| 311 | - */ |
|
| 312 | - private $rebuild_service; |
|
| 313 | - |
|
| 314 | - /** |
|
| 315 | - * A {@link Wordlift_Jsonld_Service} instance. |
|
| 316 | - * |
|
| 317 | - * @since 3.7.0 |
|
| 318 | - * @access protected |
|
| 319 | - * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance. |
|
| 320 | - */ |
|
| 321 | - protected $jsonld_service; |
|
| 322 | - |
|
| 323 | - /** |
|
| 324 | - * A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 325 | - * |
|
| 326 | - * @since 3.14.0 |
|
| 327 | - * @access protected |
|
| 328 | - * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 329 | - */ |
|
| 330 | - protected $jsonld_website_converter; |
|
| 331 | - |
|
| 332 | - /** |
|
| 333 | - * A {@link Wordlift_Property_Factory} instance. |
|
| 334 | - * |
|
| 335 | - * @since 3.7.0 |
|
| 336 | - * @access private |
|
| 337 | - * @var \Wordlift_Property_Factory $property_factory |
|
| 338 | - */ |
|
| 339 | - private $property_factory; |
|
| 340 | - |
|
| 341 | - /** |
|
| 342 | - * The 'Download Your Data' page. |
|
| 343 | - * |
|
| 344 | - * @since 3.6.0 |
|
| 345 | - * @access private |
|
| 346 | - * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page. |
|
| 347 | - */ |
|
| 348 | - private $download_your_data_page; |
|
| 349 | - |
|
| 350 | - /** |
|
| 351 | - * The 'WordLift Settings' page. |
|
| 352 | - * |
|
| 353 | - * @since 3.11.0 |
|
| 354 | - * @access protected |
|
| 355 | - * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page. |
|
| 356 | - */ |
|
| 357 | - protected $settings_page; |
|
| 358 | - |
|
| 359 | - /** |
|
| 360 | - * The install wizard page. |
|
| 361 | - * |
|
| 362 | - * @since 3.9.0 |
|
| 363 | - * @access private |
|
| 364 | - * @var \Wordlift_Admin_Setup $admin_setup The Install wizard. |
|
| 365 | - */ |
|
| 366 | - public $admin_setup; |
|
| 367 | - |
|
| 368 | - /** |
|
| 369 | - * The Content Filter Service hooks up to the 'the_content' filter and provides |
|
| 370 | - * linking of entities to their pages. |
|
| 371 | - * |
|
| 372 | - * @since 3.8.0 |
|
| 373 | - * @access private |
|
| 374 | - * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance. |
|
| 375 | - */ |
|
| 376 | - private $content_filter_service; |
|
| 377 | - |
|
| 378 | - /** |
|
| 379 | - * The Faq Content filter service |
|
| 380 | - * @since 3.26.0 |
|
| 381 | - * @access private |
|
| 382 | - * @var Faq_Content_Filter $faq_content_filter_service A {@link Faq_Content_Filter} instance. |
|
| 383 | - */ |
|
| 384 | - private $faq_content_filter_service; |
|
| 385 | - |
|
| 386 | - /** |
|
| 387 | - * A {@link Wordlift_Key_Validation_Service} instance. |
|
| 388 | - * |
|
| 389 | - * @since 3.9.0 |
|
| 390 | - * @access private |
|
| 391 | - * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 392 | - */ |
|
| 393 | - private $key_validation_service; |
|
| 394 | - |
|
| 395 | - /** |
|
| 396 | - * A {@link Wordlift_Rating_Service} instance. |
|
| 397 | - * |
|
| 398 | - * @since 3.10.0 |
|
| 399 | - * @access private |
|
| 400 | - * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance. |
|
| 401 | - */ |
|
| 402 | - private $rating_service; |
|
| 403 | - |
|
| 404 | - /** |
|
| 405 | - * A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 406 | - * |
|
| 407 | - * @since 3.10.0 |
|
| 408 | - * @access protected |
|
| 409 | - * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 410 | - */ |
|
| 411 | - protected $post_to_jsonld_converter; |
|
| 412 | - |
|
| 413 | - /** |
|
| 414 | - * A {@link Wordlift_Configuration_Service} instance. |
|
| 415 | - * |
|
| 416 | - * @since 3.10.0 |
|
| 417 | - * @access protected |
|
| 418 | - * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 419 | - */ |
|
| 420 | - protected $configuration_service; |
|
| 421 | - |
|
| 422 | - /** |
|
| 423 | - * A {@link Wordlift_Install_Service} instance. |
|
| 424 | - * |
|
| 425 | - * @since 3.18.0 |
|
| 426 | - * @access protected |
|
| 427 | - * @var \Wordlift_Install_Service $install_service A {@link Wordlift_Install_Service} instance. |
|
| 428 | - */ |
|
| 429 | - protected $install_service; |
|
| 430 | - |
|
| 431 | - /** |
|
| 432 | - * A {@link Wordlift_Entity_Type_Service} instance. |
|
| 433 | - * |
|
| 434 | - * @since 3.10.0 |
|
| 435 | - * @access protected |
|
| 436 | - * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 437 | - */ |
|
| 438 | - protected $entity_type_service; |
|
| 439 | - |
|
| 440 | - /** |
|
| 441 | - * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 442 | - * |
|
| 443 | - * @since 3.10.0 |
|
| 444 | - * @access protected |
|
| 445 | - * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 446 | - */ |
|
| 447 | - protected $entity_post_to_jsonld_converter; |
|
| 448 | - |
|
| 449 | - /** |
|
| 450 | - * A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 451 | - * |
|
| 452 | - * @since 3.10.0 |
|
| 453 | - * @access protected |
|
| 454 | - * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 455 | - */ |
|
| 456 | - protected $postid_to_jsonld_converter; |
|
| 457 | - |
|
| 458 | - /** |
|
| 459 | - * The {@link Wordlift_Admin_Status_Page} class. |
|
| 460 | - * |
|
| 461 | - * @since 3.9.8 |
|
| 462 | - * @access private |
|
| 463 | - * @var \Wordlift_Admin_Status_Page $status_page The {@link Wordlift_Admin_Status_Page} class. |
|
| 464 | - */ |
|
| 465 | - private $status_page; |
|
| 466 | - |
|
| 467 | - /** |
|
| 468 | - * The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 469 | - * |
|
| 470 | - * @since 3.11.0 |
|
| 471 | - * @access protected |
|
| 472 | - * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 473 | - */ |
|
| 474 | - protected $category_taxonomy_service; |
|
| 475 | - |
|
| 476 | - /** |
|
| 477 | - * The {@link Wordlift_Entity_Page_Service} instance. |
|
| 478 | - * |
|
| 479 | - * @since 3.11.0 |
|
| 480 | - * @access protected |
|
| 481 | - * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance. |
|
| 482 | - */ |
|
| 483 | - protected $entity_page_service; |
|
| 484 | - |
|
| 485 | - /** |
|
| 486 | - * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 487 | - * |
|
| 488 | - * @since 3.11.0 |
|
| 489 | - * @access protected |
|
| 490 | - * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 491 | - */ |
|
| 492 | - protected $settings_page_action_link; |
|
| 493 | - |
|
| 494 | - /** |
|
| 495 | - * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 496 | - * |
|
| 497 | - * @since 3.11.0 |
|
| 498 | - * @access protected |
|
| 499 | - * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 500 | - */ |
|
| 501 | - protected $analytics_settings_page_action_link; |
|
| 502 | - |
|
| 503 | - /** |
|
| 504 | - * The {@link Wordlift_Analytics_Connect} class. |
|
| 505 | - * |
|
| 506 | - * @since 3.11.0 |
|
| 507 | - * @access protected |
|
| 508 | - * @var \Wordlift_Analytics_Connect $analytics_connect The {@link Wordlift_Analytics_Connect} class. |
|
| 509 | - */ |
|
| 510 | - protected $analytics_connect; |
|
| 511 | - |
|
| 512 | - /** |
|
| 513 | - * The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 514 | - * |
|
| 515 | - * @since 3.11.0 |
|
| 516 | - * @access protected |
|
| 517 | - * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 518 | - */ |
|
| 519 | - protected $publisher_ajax_adapter; |
|
| 520 | - |
|
| 521 | - /** |
|
| 522 | - * The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 523 | - * |
|
| 524 | - * @since 3.11.0 |
|
| 525 | - * @access protected |
|
| 526 | - * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 527 | - */ |
|
| 528 | - protected $input_element; |
|
| 529 | - |
|
| 530 | - /** |
|
| 531 | - * The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 532 | - * |
|
| 533 | - * @since 3.13.0 |
|
| 534 | - * @access protected |
|
| 535 | - * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 536 | - */ |
|
| 537 | - protected $radio_input_element; |
|
| 538 | - |
|
| 539 | - /** |
|
| 540 | - * The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 541 | - * |
|
| 542 | - * @since 3.11.0 |
|
| 543 | - * @access protected |
|
| 544 | - * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 545 | - */ |
|
| 546 | - protected $language_select_element; |
|
| 547 | - |
|
| 548 | - /** |
|
| 549 | - * The {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 550 | - * |
|
| 551 | - * @since 3.18.0 |
|
| 552 | - * @access protected |
|
| 553 | - * @var \Wordlift_Admin_Country_Select_Element $country_select_element The {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 554 | - */ |
|
| 555 | - protected $country_select_element; |
|
| 556 | - |
|
| 557 | - /** |
|
| 558 | - * The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 559 | - * |
|
| 560 | - * @since 3.11.0 |
|
| 561 | - * @access protected |
|
| 562 | - * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 563 | - */ |
|
| 564 | - protected $publisher_element; |
|
| 565 | - |
|
| 566 | - /** |
|
| 567 | - * The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 568 | - * |
|
| 569 | - * @since 3.11.0 |
|
| 570 | - * @access protected |
|
| 571 | - * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 572 | - */ |
|
| 573 | - protected $select2_element; |
|
| 574 | - |
|
| 575 | - /** |
|
| 576 | - * The controller for the entity type list admin page |
|
| 577 | - * |
|
| 578 | - * @since 3.11.0 |
|
| 579 | - * @access private |
|
| 580 | - * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class. |
|
| 581 | - */ |
|
| 582 | - private $entity_type_admin_page; |
|
| 583 | - |
|
| 584 | - /** |
|
| 585 | - * The controller for the entity type settings admin page |
|
| 586 | - * |
|
| 587 | - * @since 3.11.0 |
|
| 588 | - * @access private |
|
| 589 | - * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class. |
|
| 590 | - */ |
|
| 591 | - private $entity_type_settings_admin_page; |
|
| 592 | - |
|
| 593 | - /** |
|
| 594 | - * The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 595 | - * |
|
| 596 | - * @since 3.11.0 |
|
| 597 | - * @access protected |
|
| 598 | - * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 599 | - */ |
|
| 600 | - protected $related_entities_cloud_widget; |
|
| 601 | - |
|
| 602 | - /** |
|
| 603 | - * The {@link Wordlift_Admin_Author_Element} instance. |
|
| 604 | - * |
|
| 605 | - * @since 3.14.0 |
|
| 606 | - * @access protected |
|
| 607 | - * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance. |
|
| 608 | - */ |
|
| 609 | - protected $author_element; |
|
| 610 | - |
|
| 611 | - /** |
|
| 612 | - * The {@link Wordlift_Sample_Data_Service} instance. |
|
| 613 | - * |
|
| 614 | - * @since 3.12.0 |
|
| 615 | - * @access protected |
|
| 616 | - * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance. |
|
| 617 | - */ |
|
| 618 | - protected $sample_data_service; |
|
| 619 | - |
|
| 620 | - /** |
|
| 621 | - * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 622 | - * |
|
| 623 | - * @since 3.12.0 |
|
| 624 | - * @access protected |
|
| 625 | - * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 626 | - */ |
|
| 627 | - protected $sample_data_ajax_adapter; |
|
| 628 | - |
|
| 629 | - /** |
|
| 630 | - * The {@link Wordlift_Relation_Rebuild_Service} instance. |
|
| 631 | - * |
|
| 632 | - * @since 3.14.3 |
|
| 633 | - * @access private |
|
| 634 | - * @var \Wordlift_Relation_Rebuild_Service $relation_rebuild_service The {@link Wordlift_Relation_Rebuild_Service} instance. |
|
| 635 | - */ |
|
| 636 | - private $relation_rebuild_service; |
|
| 637 | - |
|
| 638 | - /** |
|
| 639 | - * The {@link Wordlift_Relation_Rebuild_Adapter} instance. |
|
| 640 | - * |
|
| 641 | - * @since 3.14.3 |
|
| 642 | - * @access private |
|
| 643 | - * @var \Wordlift_Relation_Rebuild_Adapter $relation_rebuild_adapter The {@link Wordlift_Relation_Rebuild_Adapter} instance. |
|
| 644 | - */ |
|
| 645 | - private $relation_rebuild_adapter; |
|
| 646 | - |
|
| 647 | - /** |
|
| 648 | - * The {@link Wordlift_Reference_Rebuild_Service} instance. |
|
| 649 | - * |
|
| 650 | - * @since 3.18.0 |
|
| 651 | - * @access private |
|
| 652 | - * @var \Wordlift_Reference_Rebuild_Service $reference_rebuild_service The {@link Wordlift_Reference_Rebuild_Service} instance. |
|
| 653 | - */ |
|
| 654 | - private $reference_rebuild_service; |
|
| 655 | - |
|
| 656 | - /** |
|
| 657 | - * The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 658 | - * |
|
| 659 | - * @since 3.16.0 |
|
| 660 | - * @access protected |
|
| 661 | - * @var \Wordlift_Google_Analytics_Export_Service $google_analytics_export_service The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 662 | - */ |
|
| 663 | - protected $google_analytics_export_service; |
|
| 664 | - |
|
| 665 | - /** |
|
| 666 | - * {@link Wordlift}'s singleton instance. |
|
| 667 | - * |
|
| 668 | - * @since 3.15.0 |
|
| 669 | - * @access protected |
|
| 670 | - * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance. |
|
| 671 | - */ |
|
| 672 | - protected $entity_type_adapter; |
|
| 673 | - |
|
| 674 | - /** |
|
| 675 | - * The {@link Wordlift_Storage_Factory} instance. |
|
| 676 | - * |
|
| 677 | - * @since 3.15.0 |
|
| 678 | - * @access protected |
|
| 679 | - * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance. |
|
| 680 | - */ |
|
| 681 | - protected $storage_factory; |
|
| 682 | - |
|
| 683 | - /** |
|
| 684 | - * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 685 | - * |
|
| 686 | - * @since 3.15.0 |
|
| 687 | - * @access protected |
|
| 688 | - * @var \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 689 | - */ |
|
| 690 | - protected $rendition_factory; |
|
| 691 | - |
|
| 692 | - /** |
|
| 693 | - * The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 694 | - * |
|
| 695 | - * @since 3.15.0 |
|
| 696 | - * @access private |
|
| 697 | - * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 698 | - */ |
|
| 699 | - private $autocomplete_adapter; |
|
| 700 | - |
|
| 701 | - /** |
|
| 702 | - * The {@link Wordlift_Relation_Service} instance. |
|
| 703 | - * |
|
| 704 | - * @since 3.15.0 |
|
| 705 | - * @access protected |
|
| 706 | - * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance. |
|
| 707 | - */ |
|
| 708 | - protected $relation_service; |
|
| 709 | - |
|
| 710 | - /** |
|
| 711 | - * The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 712 | - * |
|
| 713 | - * @since 3.16.0 |
|
| 714 | - * @access protected |
|
| 715 | - * @var \Wordlift_Cached_Post_Converter $cached_postid_to_jsonld_converter The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 716 | - * |
|
| 717 | - */ |
|
| 718 | - protected $cached_postid_to_jsonld_converter; |
|
| 719 | - |
|
| 720 | - /** |
|
| 721 | - * The {@link Wordlift_Entity_Uri_Service} instance. |
|
| 722 | - * |
|
| 723 | - * @since 3.16.3 |
|
| 724 | - * @access protected |
|
| 725 | - * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance. |
|
| 726 | - */ |
|
| 727 | - protected $entity_uri_service; |
|
| 728 | - |
|
| 729 | - /** |
|
| 730 | - * The {@link Wordlift_Publisher_Service} instance. |
|
| 731 | - * |
|
| 732 | - * @since 3.19.0 |
|
| 733 | - * @access protected |
|
| 734 | - * @var \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance. |
|
| 735 | - */ |
|
| 736 | - protected $publisher_service; |
|
| 737 | - |
|
| 738 | - /** |
|
| 739 | - * The {@link Wordlift_Context_Cards_Service} instance. |
|
| 740 | - * |
|
| 741 | - * @var \Wordlift_Context_Cards_Service The {@link Wordlift_Context_Cards_Service} instance. |
|
| 742 | - */ |
|
| 743 | - protected $context_cards_service; |
|
| 744 | - |
|
| 745 | - /** |
|
| 746 | - * {@link Wordlift}'s singleton instance. |
|
| 747 | - * |
|
| 748 | - * @since 3.11.2 |
|
| 749 | - * @access private |
|
| 750 | - * @var Wordlift $instance {@link Wordlift}'s singleton instance. |
|
| 751 | - */ |
|
| 752 | - private static $instance; |
|
| 753 | - |
|
| 754 | - /** |
|
| 755 | - * A singleton instance of features registry. |
|
| 756 | - * @since 3.30.0 |
|
| 757 | - * @var Features_Registry |
|
| 758 | - */ |
|
| 759 | - private $features_registry; |
|
| 760 | - |
|
| 761 | - //</editor-fold> |
|
| 762 | - |
|
| 763 | - /** |
|
| 764 | - * Define the core functionality of the plugin. |
|
| 765 | - * |
|
| 766 | - * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 767 | - * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 768 | - * the public-facing side of the site. |
|
| 769 | - * |
|
| 770 | - * @since 1.0.0 |
|
| 771 | - */ |
|
| 772 | - public function __construct() { |
|
| 773 | - |
|
| 774 | - self::$instance = $this; |
|
| 775 | - |
|
| 776 | - $this->plugin_name = 'wordlift'; |
|
| 777 | - $this->version = '3.32.5'; |
|
| 778 | - $this->load_dependencies(); |
|
| 779 | - $this->set_locale(); |
|
| 780 | - $this->define_admin_hooks(); |
|
| 781 | - $this->define_public_hooks(); |
|
| 782 | - |
|
| 783 | - // If we're in `WP_CLI` load the related files. |
|
| 784 | - if ( class_exists( 'WP_CLI' ) ) { |
|
| 785 | - $this->load_cli_dependencies(); |
|
| 786 | - } |
|
| 787 | - |
|
| 788 | - } |
|
| 789 | - |
|
| 790 | - /** |
|
| 791 | - * Get the singleton instance. |
|
| 792 | - * |
|
| 793 | - * @return Wordlift The {@link Wordlift} singleton instance. |
|
| 794 | - * @since 3.11.2 |
|
| 795 | - * |
|
| 796 | - */ |
|
| 797 | - public static function get_instance() { |
|
| 798 | - |
|
| 799 | - return self::$instance; |
|
| 800 | - } |
|
| 801 | - |
|
| 802 | - /** |
|
| 803 | - * Load the required dependencies for this plugin. |
|
| 804 | - * |
|
| 805 | - * Include the following files that make up the plugin: |
|
| 806 | - * |
|
| 807 | - * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 808 | - * - Wordlift_i18n. Defines internationalization functionality. |
|
| 809 | - * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 810 | - * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 811 | - * |
|
| 812 | - * Create an instance of the loader which will be used to register the hooks |
|
| 813 | - * with WordPress. |
|
| 814 | - * |
|
| 815 | - * @throws Exception |
|
| 816 | - * @since 1.0.0 |
|
| 817 | - * @access private |
|
| 818 | - */ |
|
| 819 | - private function load_dependencies() { |
|
| 820 | - |
|
| 821 | - /** |
|
| 822 | - * The class responsible for orchestrating the actions and filters of the |
|
| 823 | - * core plugin. |
|
| 824 | - */ |
|
| 825 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 826 | - |
|
| 827 | - // The class responsible for plugin uninstall. |
|
| 828 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-deactivator-feedback.php'; |
|
| 829 | - |
|
| 830 | - /** |
|
| 831 | - * The class responsible for defining internationalization functionality |
|
| 832 | - * of the plugin. |
|
| 833 | - */ |
|
| 834 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 835 | - |
|
| 836 | - /** |
|
| 837 | - * WordLift's supported languages. |
|
| 838 | - */ |
|
| 839 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php'; |
|
| 840 | - |
|
| 841 | - /** |
|
| 842 | - * WordLift's supported countries. |
|
| 843 | - */ |
|
| 844 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-countries.php'; |
|
| 845 | - |
|
| 846 | - /** |
|
| 847 | - * Provide support functions to sanitize data. |
|
| 848 | - */ |
|
| 849 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 850 | - |
|
| 851 | - /** Services. */ |
|
| 852 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 853 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php'; |
|
| 854 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 855 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 856 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 857 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 858 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 859 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php'; |
|
| 860 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php'; |
|
| 861 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-image-service.php'; |
|
| 862 | - |
|
| 863 | - /** |
|
| 864 | - * The Query builder. |
|
| 865 | - */ |
|
| 866 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 867 | - |
|
| 868 | - /** |
|
| 869 | - * The Schema service. |
|
| 870 | - */ |
|
| 871 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 872 | - |
|
| 873 | - /** |
|
| 874 | - * The schema:url property service. |
|
| 875 | - */ |
|
| 876 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 877 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 878 | - |
|
| 879 | - /** |
|
| 880 | - * The UI service. |
|
| 881 | - */ |
|
| 882 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 883 | - |
|
| 884 | - /** |
|
| 885 | - * The Thumbnail service. |
|
| 886 | - */ |
|
| 887 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 888 | - |
|
| 889 | - /** |
|
| 890 | - * The Entity Types Taxonomy service. |
|
| 891 | - */ |
|
| 892 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-taxonomy-service.php'; |
|
| 893 | - |
|
| 894 | - /** |
|
| 895 | - * The Entity service. |
|
| 896 | - */ |
|
| 897 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php'; |
|
| 898 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 899 | - |
|
| 900 | - // Add the entity rating service. |
|
| 901 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php'; |
|
| 902 | - |
|
| 903 | - /** |
|
| 904 | - * The User service. |
|
| 905 | - */ |
|
| 906 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 907 | - |
|
| 908 | - /** |
|
| 909 | - * The Timeline service. |
|
| 910 | - */ |
|
| 911 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 912 | - |
|
| 913 | - /** |
|
| 914 | - * The Topic Taxonomy service. |
|
| 915 | - */ |
|
| 916 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 917 | - |
|
| 918 | - /** |
|
| 919 | - * The SPARQL service. |
|
| 920 | - */ |
|
| 921 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 922 | - |
|
| 923 | - /** |
|
| 924 | - * The WordLift import service. |
|
| 925 | - */ |
|
| 926 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 927 | - |
|
| 928 | - /** |
|
| 929 | - * The WordLift URI service. |
|
| 930 | - */ |
|
| 931 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 932 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 933 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php'; |
|
| 934 | - |
|
| 935 | - /** |
|
| 936 | - * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
|
| 937 | - */ |
|
| 938 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-listable.php'; |
|
| 939 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-rebuild-service.php'; |
|
| 940 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-reference-rebuild-service.php'; |
|
| 941 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-service.php'; |
|
| 942 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-adapter.php'; |
|
| 943 | - |
|
| 944 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 945 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php'; |
|
| 946 | - |
|
| 947 | - /** |
|
| 948 | - * Load the converters. |
|
| 949 | - */ |
|
| 950 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php'; |
|
| 951 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 952 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 953 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 954 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 955 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php'; |
|
| 956 | - |
|
| 957 | - /** |
|
| 958 | - * Load cache-related files. |
|
| 959 | - */ |
|
| 960 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php'; |
|
| 961 | - |
|
| 962 | - /** |
|
| 963 | - * Load the content filter. |
|
| 964 | - */ |
|
| 965 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 966 | - |
|
| 967 | - /* |
|
| 87 | + //<editor-fold desc="## FIELDS"> |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * The loader that's responsible for maintaining and registering all hooks that power |
|
| 91 | + * the plugin. |
|
| 92 | + * |
|
| 93 | + * @since 1.0.0 |
|
| 94 | + * @access protected |
|
| 95 | + * @var Wordlift_Loader $loader Maintains and registers all hooks for the plugin. |
|
| 96 | + */ |
|
| 97 | + protected $loader; |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * The unique identifier of this plugin. |
|
| 101 | + * |
|
| 102 | + * @since 1.0.0 |
|
| 103 | + * @access protected |
|
| 104 | + * @var string $plugin_name The string used to uniquely identify this plugin. |
|
| 105 | + */ |
|
| 106 | + protected $plugin_name; |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * The current version of the plugin. |
|
| 110 | + * |
|
| 111 | + * @since 1.0.0 |
|
| 112 | + * @access protected |
|
| 113 | + * @var string $version The current version of the plugin. |
|
| 114 | + */ |
|
| 115 | + protected $version; |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 119 | + * |
|
| 120 | + * @since 3.12.0 |
|
| 121 | + * @access protected |
|
| 122 | + * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 123 | + */ |
|
| 124 | + protected $tinymce_adapter; |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * The {@link Faq_Tinymce_Adapter} instance |
|
| 128 | + * @since 3.26.0 |
|
| 129 | + * @access protected |
|
| 130 | + * @var Faq_Tinymce_Adapter $faq_tinymce_adapter . |
|
| 131 | + */ |
|
| 132 | + //protected $faq_tinymce_adapter; |
|
| 133 | + |
|
| 134 | + /** |
|
| 135 | + * The Thumbnail service. |
|
| 136 | + * |
|
| 137 | + * @since 3.1.5 |
|
| 138 | + * @access private |
|
| 139 | + * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service. |
|
| 140 | + */ |
|
| 141 | + private $thumbnail_service; |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * The UI service. |
|
| 145 | + * |
|
| 146 | + * @since 3.2.0 |
|
| 147 | + * @access private |
|
| 148 | + * @var \Wordlift_UI_Service $ui_service The UI service. |
|
| 149 | + */ |
|
| 150 | + private $ui_service; |
|
| 151 | + |
|
| 152 | + /** |
|
| 153 | + * The Schema service. |
|
| 154 | + * |
|
| 155 | + * @since 3.3.0 |
|
| 156 | + * @access protected |
|
| 157 | + * @var \Wordlift_Schema_Service $schema_service The Schema service. |
|
| 158 | + */ |
|
| 159 | + protected $schema_service; |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * The Entity service. |
|
| 163 | + * |
|
| 164 | + * @since 3.1.0 |
|
| 165 | + * @access protected |
|
| 166 | + * @var \Wordlift_Entity_Service $entity_service The Entity service. |
|
| 167 | + */ |
|
| 168 | + protected $entity_service; |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * The Topic Taxonomy service. |
|
| 172 | + * |
|
| 173 | + * @since 3.5.0 |
|
| 174 | + * @access private |
|
| 175 | + * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service. |
|
| 176 | + */ |
|
| 177 | + private $topic_taxonomy_service; |
|
| 178 | + |
|
| 179 | + /** |
|
| 180 | + * The Entity Types Taxonomy service. |
|
| 181 | + * |
|
| 182 | + * @since 3.18.0 |
|
| 183 | + * @access private |
|
| 184 | + * @var \Wordlift_Entity_Type_Taxonomy_Service The Entity Types Taxonomy service. |
|
| 185 | + */ |
|
| 186 | + private $entity_types_taxonomy_service; |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * The User service. |
|
| 190 | + * |
|
| 191 | + * @since 3.1.7 |
|
| 192 | + * @access protected |
|
| 193 | + * @var \Wordlift_User_Service $user_service The User service. |
|
| 194 | + */ |
|
| 195 | + protected $user_service; |
|
| 196 | + |
|
| 197 | + /** |
|
| 198 | + * The Timeline service. |
|
| 199 | + * |
|
| 200 | + * @since 3.1.0 |
|
| 201 | + * @access private |
|
| 202 | + * @var \Wordlift_Timeline_Service $timeline_service The Timeline service. |
|
| 203 | + */ |
|
| 204 | + private $timeline_service; |
|
| 205 | + |
|
| 206 | + /** |
|
| 207 | + * The Redirect service. |
|
| 208 | + * |
|
| 209 | + * @since 3.2.0 |
|
| 210 | + * @access private |
|
| 211 | + * @var \Wordlift_Redirect_Service $redirect_service The Redirect service. |
|
| 212 | + */ |
|
| 213 | + private $redirect_service; |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * The Notice service. |
|
| 217 | + * |
|
| 218 | + * @since 3.3.0 |
|
| 219 | + * @access private |
|
| 220 | + * @var \Wordlift_Notice_Service $notice_service The Notice service. |
|
| 221 | + */ |
|
| 222 | + private $notice_service; |
|
| 223 | + |
|
| 224 | + /** |
|
| 225 | + * The Entity list customization. |
|
| 226 | + * |
|
| 227 | + * @since 3.3.0 |
|
| 228 | + * @access protected |
|
| 229 | + * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service. |
|
| 230 | + */ |
|
| 231 | + protected $entity_list_service; |
|
| 232 | + |
|
| 233 | + /** |
|
| 234 | + * The Entity Types Taxonomy Walker. |
|
| 235 | + * |
|
| 236 | + * @since 3.1.0 |
|
| 237 | + * @access private |
|
| 238 | + * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker |
|
| 239 | + */ |
|
| 240 | + private $entity_types_taxonomy_walker; |
|
| 241 | + |
|
| 242 | + /** |
|
| 243 | + * The ShareThis service. |
|
| 244 | + * |
|
| 245 | + * @since 3.2.0 |
|
| 246 | + * @access private |
|
| 247 | + * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service. |
|
| 248 | + */ |
|
| 249 | + private $sharethis_service; |
|
| 250 | + |
|
| 251 | + /** |
|
| 252 | + * The PrimaShop adapter. |
|
| 253 | + * |
|
| 254 | + * @since 3.2.3 |
|
| 255 | + * @access private |
|
| 256 | + * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter. |
|
| 257 | + */ |
|
| 258 | + private $primashop_adapter; |
|
| 259 | + |
|
| 260 | + /** |
|
| 261 | + * The WordLift Dashboard adapter. |
|
| 262 | + * |
|
| 263 | + * @since 3.4.0 |
|
| 264 | + * @access private |
|
| 265 | + * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service; |
|
| 266 | + */ |
|
| 267 | + private $dashboard_service; |
|
| 268 | + |
|
| 269 | + /** |
|
| 270 | + * The entity type service. |
|
| 271 | + * |
|
| 272 | + * @since 3.6.0 |
|
| 273 | + * @access private |
|
| 274 | + * @var \Wordlift_Entity_Post_Type_Service |
|
| 275 | + */ |
|
| 276 | + private $entity_post_type_service; |
|
| 277 | + |
|
| 278 | + /** |
|
| 279 | + * The entity link service used to mangle links to entities with a custom slug or even w/o a slug. |
|
| 280 | + * |
|
| 281 | + * @since 3.6.0 |
|
| 282 | + * @access private |
|
| 283 | + * @var \Wordlift_Entity_Link_Service $entity_link_service The {@link Wordlift_Entity_Link_Service} instance. |
|
| 284 | + */ |
|
| 285 | + private $entity_link_service; |
|
| 286 | + |
|
| 287 | + /** |
|
| 288 | + * A {@link Wordlift_Sparql_Service} instance. |
|
| 289 | + * |
|
| 290 | + * @since 3.6.0 |
|
| 291 | + * @access protected |
|
| 292 | + * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance. |
|
| 293 | + */ |
|
| 294 | + protected $sparql_service; |
|
| 295 | + |
|
| 296 | + /** |
|
| 297 | + * A {@link Wordlift_Import_Service} instance. |
|
| 298 | + * |
|
| 299 | + * @since 3.6.0 |
|
| 300 | + * @access private |
|
| 301 | + * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance. |
|
| 302 | + */ |
|
| 303 | + private $import_service; |
|
| 304 | + |
|
| 305 | + /** |
|
| 306 | + * A {@link Wordlift_Rebuild_Service} instance. |
|
| 307 | + * |
|
| 308 | + * @since 3.6.0 |
|
| 309 | + * @access private |
|
| 310 | + * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance. |
|
| 311 | + */ |
|
| 312 | + private $rebuild_service; |
|
| 313 | + |
|
| 314 | + /** |
|
| 315 | + * A {@link Wordlift_Jsonld_Service} instance. |
|
| 316 | + * |
|
| 317 | + * @since 3.7.0 |
|
| 318 | + * @access protected |
|
| 319 | + * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance. |
|
| 320 | + */ |
|
| 321 | + protected $jsonld_service; |
|
| 322 | + |
|
| 323 | + /** |
|
| 324 | + * A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 325 | + * |
|
| 326 | + * @since 3.14.0 |
|
| 327 | + * @access protected |
|
| 328 | + * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 329 | + */ |
|
| 330 | + protected $jsonld_website_converter; |
|
| 331 | + |
|
| 332 | + /** |
|
| 333 | + * A {@link Wordlift_Property_Factory} instance. |
|
| 334 | + * |
|
| 335 | + * @since 3.7.0 |
|
| 336 | + * @access private |
|
| 337 | + * @var \Wordlift_Property_Factory $property_factory |
|
| 338 | + */ |
|
| 339 | + private $property_factory; |
|
| 340 | + |
|
| 341 | + /** |
|
| 342 | + * The 'Download Your Data' page. |
|
| 343 | + * |
|
| 344 | + * @since 3.6.0 |
|
| 345 | + * @access private |
|
| 346 | + * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page. |
|
| 347 | + */ |
|
| 348 | + private $download_your_data_page; |
|
| 349 | + |
|
| 350 | + /** |
|
| 351 | + * The 'WordLift Settings' page. |
|
| 352 | + * |
|
| 353 | + * @since 3.11.0 |
|
| 354 | + * @access protected |
|
| 355 | + * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page. |
|
| 356 | + */ |
|
| 357 | + protected $settings_page; |
|
| 358 | + |
|
| 359 | + /** |
|
| 360 | + * The install wizard page. |
|
| 361 | + * |
|
| 362 | + * @since 3.9.0 |
|
| 363 | + * @access private |
|
| 364 | + * @var \Wordlift_Admin_Setup $admin_setup The Install wizard. |
|
| 365 | + */ |
|
| 366 | + public $admin_setup; |
|
| 367 | + |
|
| 368 | + /** |
|
| 369 | + * The Content Filter Service hooks up to the 'the_content' filter and provides |
|
| 370 | + * linking of entities to their pages. |
|
| 371 | + * |
|
| 372 | + * @since 3.8.0 |
|
| 373 | + * @access private |
|
| 374 | + * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance. |
|
| 375 | + */ |
|
| 376 | + private $content_filter_service; |
|
| 377 | + |
|
| 378 | + /** |
|
| 379 | + * The Faq Content filter service |
|
| 380 | + * @since 3.26.0 |
|
| 381 | + * @access private |
|
| 382 | + * @var Faq_Content_Filter $faq_content_filter_service A {@link Faq_Content_Filter} instance. |
|
| 383 | + */ |
|
| 384 | + private $faq_content_filter_service; |
|
| 385 | + |
|
| 386 | + /** |
|
| 387 | + * A {@link Wordlift_Key_Validation_Service} instance. |
|
| 388 | + * |
|
| 389 | + * @since 3.9.0 |
|
| 390 | + * @access private |
|
| 391 | + * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 392 | + */ |
|
| 393 | + private $key_validation_service; |
|
| 394 | + |
|
| 395 | + /** |
|
| 396 | + * A {@link Wordlift_Rating_Service} instance. |
|
| 397 | + * |
|
| 398 | + * @since 3.10.0 |
|
| 399 | + * @access private |
|
| 400 | + * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance. |
|
| 401 | + */ |
|
| 402 | + private $rating_service; |
|
| 403 | + |
|
| 404 | + /** |
|
| 405 | + * A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 406 | + * |
|
| 407 | + * @since 3.10.0 |
|
| 408 | + * @access protected |
|
| 409 | + * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 410 | + */ |
|
| 411 | + protected $post_to_jsonld_converter; |
|
| 412 | + |
|
| 413 | + /** |
|
| 414 | + * A {@link Wordlift_Configuration_Service} instance. |
|
| 415 | + * |
|
| 416 | + * @since 3.10.0 |
|
| 417 | + * @access protected |
|
| 418 | + * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 419 | + */ |
|
| 420 | + protected $configuration_service; |
|
| 421 | + |
|
| 422 | + /** |
|
| 423 | + * A {@link Wordlift_Install_Service} instance. |
|
| 424 | + * |
|
| 425 | + * @since 3.18.0 |
|
| 426 | + * @access protected |
|
| 427 | + * @var \Wordlift_Install_Service $install_service A {@link Wordlift_Install_Service} instance. |
|
| 428 | + */ |
|
| 429 | + protected $install_service; |
|
| 430 | + |
|
| 431 | + /** |
|
| 432 | + * A {@link Wordlift_Entity_Type_Service} instance. |
|
| 433 | + * |
|
| 434 | + * @since 3.10.0 |
|
| 435 | + * @access protected |
|
| 436 | + * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 437 | + */ |
|
| 438 | + protected $entity_type_service; |
|
| 439 | + |
|
| 440 | + /** |
|
| 441 | + * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 442 | + * |
|
| 443 | + * @since 3.10.0 |
|
| 444 | + * @access protected |
|
| 445 | + * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 446 | + */ |
|
| 447 | + protected $entity_post_to_jsonld_converter; |
|
| 448 | + |
|
| 449 | + /** |
|
| 450 | + * A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 451 | + * |
|
| 452 | + * @since 3.10.0 |
|
| 453 | + * @access protected |
|
| 454 | + * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 455 | + */ |
|
| 456 | + protected $postid_to_jsonld_converter; |
|
| 457 | + |
|
| 458 | + /** |
|
| 459 | + * The {@link Wordlift_Admin_Status_Page} class. |
|
| 460 | + * |
|
| 461 | + * @since 3.9.8 |
|
| 462 | + * @access private |
|
| 463 | + * @var \Wordlift_Admin_Status_Page $status_page The {@link Wordlift_Admin_Status_Page} class. |
|
| 464 | + */ |
|
| 465 | + private $status_page; |
|
| 466 | + |
|
| 467 | + /** |
|
| 468 | + * The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 469 | + * |
|
| 470 | + * @since 3.11.0 |
|
| 471 | + * @access protected |
|
| 472 | + * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 473 | + */ |
|
| 474 | + protected $category_taxonomy_service; |
|
| 475 | + |
|
| 476 | + /** |
|
| 477 | + * The {@link Wordlift_Entity_Page_Service} instance. |
|
| 478 | + * |
|
| 479 | + * @since 3.11.0 |
|
| 480 | + * @access protected |
|
| 481 | + * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance. |
|
| 482 | + */ |
|
| 483 | + protected $entity_page_service; |
|
| 484 | + |
|
| 485 | + /** |
|
| 486 | + * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 487 | + * |
|
| 488 | + * @since 3.11.0 |
|
| 489 | + * @access protected |
|
| 490 | + * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 491 | + */ |
|
| 492 | + protected $settings_page_action_link; |
|
| 493 | + |
|
| 494 | + /** |
|
| 495 | + * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 496 | + * |
|
| 497 | + * @since 3.11.0 |
|
| 498 | + * @access protected |
|
| 499 | + * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 500 | + */ |
|
| 501 | + protected $analytics_settings_page_action_link; |
|
| 502 | + |
|
| 503 | + /** |
|
| 504 | + * The {@link Wordlift_Analytics_Connect} class. |
|
| 505 | + * |
|
| 506 | + * @since 3.11.0 |
|
| 507 | + * @access protected |
|
| 508 | + * @var \Wordlift_Analytics_Connect $analytics_connect The {@link Wordlift_Analytics_Connect} class. |
|
| 509 | + */ |
|
| 510 | + protected $analytics_connect; |
|
| 511 | + |
|
| 512 | + /** |
|
| 513 | + * The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 514 | + * |
|
| 515 | + * @since 3.11.0 |
|
| 516 | + * @access protected |
|
| 517 | + * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 518 | + */ |
|
| 519 | + protected $publisher_ajax_adapter; |
|
| 520 | + |
|
| 521 | + /** |
|
| 522 | + * The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 523 | + * |
|
| 524 | + * @since 3.11.0 |
|
| 525 | + * @access protected |
|
| 526 | + * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 527 | + */ |
|
| 528 | + protected $input_element; |
|
| 529 | + |
|
| 530 | + /** |
|
| 531 | + * The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 532 | + * |
|
| 533 | + * @since 3.13.0 |
|
| 534 | + * @access protected |
|
| 535 | + * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 536 | + */ |
|
| 537 | + protected $radio_input_element; |
|
| 538 | + |
|
| 539 | + /** |
|
| 540 | + * The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 541 | + * |
|
| 542 | + * @since 3.11.0 |
|
| 543 | + * @access protected |
|
| 544 | + * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 545 | + */ |
|
| 546 | + protected $language_select_element; |
|
| 547 | + |
|
| 548 | + /** |
|
| 549 | + * The {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 550 | + * |
|
| 551 | + * @since 3.18.0 |
|
| 552 | + * @access protected |
|
| 553 | + * @var \Wordlift_Admin_Country_Select_Element $country_select_element The {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 554 | + */ |
|
| 555 | + protected $country_select_element; |
|
| 556 | + |
|
| 557 | + /** |
|
| 558 | + * The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 559 | + * |
|
| 560 | + * @since 3.11.0 |
|
| 561 | + * @access protected |
|
| 562 | + * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 563 | + */ |
|
| 564 | + protected $publisher_element; |
|
| 565 | + |
|
| 566 | + /** |
|
| 567 | + * The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 568 | + * |
|
| 569 | + * @since 3.11.0 |
|
| 570 | + * @access protected |
|
| 571 | + * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 572 | + */ |
|
| 573 | + protected $select2_element; |
|
| 574 | + |
|
| 575 | + /** |
|
| 576 | + * The controller for the entity type list admin page |
|
| 577 | + * |
|
| 578 | + * @since 3.11.0 |
|
| 579 | + * @access private |
|
| 580 | + * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class. |
|
| 581 | + */ |
|
| 582 | + private $entity_type_admin_page; |
|
| 583 | + |
|
| 584 | + /** |
|
| 585 | + * The controller for the entity type settings admin page |
|
| 586 | + * |
|
| 587 | + * @since 3.11.0 |
|
| 588 | + * @access private |
|
| 589 | + * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class. |
|
| 590 | + */ |
|
| 591 | + private $entity_type_settings_admin_page; |
|
| 592 | + |
|
| 593 | + /** |
|
| 594 | + * The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 595 | + * |
|
| 596 | + * @since 3.11.0 |
|
| 597 | + * @access protected |
|
| 598 | + * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 599 | + */ |
|
| 600 | + protected $related_entities_cloud_widget; |
|
| 601 | + |
|
| 602 | + /** |
|
| 603 | + * The {@link Wordlift_Admin_Author_Element} instance. |
|
| 604 | + * |
|
| 605 | + * @since 3.14.0 |
|
| 606 | + * @access protected |
|
| 607 | + * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance. |
|
| 608 | + */ |
|
| 609 | + protected $author_element; |
|
| 610 | + |
|
| 611 | + /** |
|
| 612 | + * The {@link Wordlift_Sample_Data_Service} instance. |
|
| 613 | + * |
|
| 614 | + * @since 3.12.0 |
|
| 615 | + * @access protected |
|
| 616 | + * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance. |
|
| 617 | + */ |
|
| 618 | + protected $sample_data_service; |
|
| 619 | + |
|
| 620 | + /** |
|
| 621 | + * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 622 | + * |
|
| 623 | + * @since 3.12.0 |
|
| 624 | + * @access protected |
|
| 625 | + * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 626 | + */ |
|
| 627 | + protected $sample_data_ajax_adapter; |
|
| 628 | + |
|
| 629 | + /** |
|
| 630 | + * The {@link Wordlift_Relation_Rebuild_Service} instance. |
|
| 631 | + * |
|
| 632 | + * @since 3.14.3 |
|
| 633 | + * @access private |
|
| 634 | + * @var \Wordlift_Relation_Rebuild_Service $relation_rebuild_service The {@link Wordlift_Relation_Rebuild_Service} instance. |
|
| 635 | + */ |
|
| 636 | + private $relation_rebuild_service; |
|
| 637 | + |
|
| 638 | + /** |
|
| 639 | + * The {@link Wordlift_Relation_Rebuild_Adapter} instance. |
|
| 640 | + * |
|
| 641 | + * @since 3.14.3 |
|
| 642 | + * @access private |
|
| 643 | + * @var \Wordlift_Relation_Rebuild_Adapter $relation_rebuild_adapter The {@link Wordlift_Relation_Rebuild_Adapter} instance. |
|
| 644 | + */ |
|
| 645 | + private $relation_rebuild_adapter; |
|
| 646 | + |
|
| 647 | + /** |
|
| 648 | + * The {@link Wordlift_Reference_Rebuild_Service} instance. |
|
| 649 | + * |
|
| 650 | + * @since 3.18.0 |
|
| 651 | + * @access private |
|
| 652 | + * @var \Wordlift_Reference_Rebuild_Service $reference_rebuild_service The {@link Wordlift_Reference_Rebuild_Service} instance. |
|
| 653 | + */ |
|
| 654 | + private $reference_rebuild_service; |
|
| 655 | + |
|
| 656 | + /** |
|
| 657 | + * The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 658 | + * |
|
| 659 | + * @since 3.16.0 |
|
| 660 | + * @access protected |
|
| 661 | + * @var \Wordlift_Google_Analytics_Export_Service $google_analytics_export_service The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 662 | + */ |
|
| 663 | + protected $google_analytics_export_service; |
|
| 664 | + |
|
| 665 | + /** |
|
| 666 | + * {@link Wordlift}'s singleton instance. |
|
| 667 | + * |
|
| 668 | + * @since 3.15.0 |
|
| 669 | + * @access protected |
|
| 670 | + * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance. |
|
| 671 | + */ |
|
| 672 | + protected $entity_type_adapter; |
|
| 673 | + |
|
| 674 | + /** |
|
| 675 | + * The {@link Wordlift_Storage_Factory} instance. |
|
| 676 | + * |
|
| 677 | + * @since 3.15.0 |
|
| 678 | + * @access protected |
|
| 679 | + * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance. |
|
| 680 | + */ |
|
| 681 | + protected $storage_factory; |
|
| 682 | + |
|
| 683 | + /** |
|
| 684 | + * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 685 | + * |
|
| 686 | + * @since 3.15.0 |
|
| 687 | + * @access protected |
|
| 688 | + * @var \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 689 | + */ |
|
| 690 | + protected $rendition_factory; |
|
| 691 | + |
|
| 692 | + /** |
|
| 693 | + * The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 694 | + * |
|
| 695 | + * @since 3.15.0 |
|
| 696 | + * @access private |
|
| 697 | + * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 698 | + */ |
|
| 699 | + private $autocomplete_adapter; |
|
| 700 | + |
|
| 701 | + /** |
|
| 702 | + * The {@link Wordlift_Relation_Service} instance. |
|
| 703 | + * |
|
| 704 | + * @since 3.15.0 |
|
| 705 | + * @access protected |
|
| 706 | + * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance. |
|
| 707 | + */ |
|
| 708 | + protected $relation_service; |
|
| 709 | + |
|
| 710 | + /** |
|
| 711 | + * The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 712 | + * |
|
| 713 | + * @since 3.16.0 |
|
| 714 | + * @access protected |
|
| 715 | + * @var \Wordlift_Cached_Post_Converter $cached_postid_to_jsonld_converter The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 716 | + * |
|
| 717 | + */ |
|
| 718 | + protected $cached_postid_to_jsonld_converter; |
|
| 719 | + |
|
| 720 | + /** |
|
| 721 | + * The {@link Wordlift_Entity_Uri_Service} instance. |
|
| 722 | + * |
|
| 723 | + * @since 3.16.3 |
|
| 724 | + * @access protected |
|
| 725 | + * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance. |
|
| 726 | + */ |
|
| 727 | + protected $entity_uri_service; |
|
| 728 | + |
|
| 729 | + /** |
|
| 730 | + * The {@link Wordlift_Publisher_Service} instance. |
|
| 731 | + * |
|
| 732 | + * @since 3.19.0 |
|
| 733 | + * @access protected |
|
| 734 | + * @var \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance. |
|
| 735 | + */ |
|
| 736 | + protected $publisher_service; |
|
| 737 | + |
|
| 738 | + /** |
|
| 739 | + * The {@link Wordlift_Context_Cards_Service} instance. |
|
| 740 | + * |
|
| 741 | + * @var \Wordlift_Context_Cards_Service The {@link Wordlift_Context_Cards_Service} instance. |
|
| 742 | + */ |
|
| 743 | + protected $context_cards_service; |
|
| 744 | + |
|
| 745 | + /** |
|
| 746 | + * {@link Wordlift}'s singleton instance. |
|
| 747 | + * |
|
| 748 | + * @since 3.11.2 |
|
| 749 | + * @access private |
|
| 750 | + * @var Wordlift $instance {@link Wordlift}'s singleton instance. |
|
| 751 | + */ |
|
| 752 | + private static $instance; |
|
| 753 | + |
|
| 754 | + /** |
|
| 755 | + * A singleton instance of features registry. |
|
| 756 | + * @since 3.30.0 |
|
| 757 | + * @var Features_Registry |
|
| 758 | + */ |
|
| 759 | + private $features_registry; |
|
| 760 | + |
|
| 761 | + //</editor-fold> |
|
| 762 | + |
|
| 763 | + /** |
|
| 764 | + * Define the core functionality of the plugin. |
|
| 765 | + * |
|
| 766 | + * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 767 | + * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 768 | + * the public-facing side of the site. |
|
| 769 | + * |
|
| 770 | + * @since 1.0.0 |
|
| 771 | + */ |
|
| 772 | + public function __construct() { |
|
| 773 | + |
|
| 774 | + self::$instance = $this; |
|
| 775 | + |
|
| 776 | + $this->plugin_name = 'wordlift'; |
|
| 777 | + $this->version = '3.32.5'; |
|
| 778 | + $this->load_dependencies(); |
|
| 779 | + $this->set_locale(); |
|
| 780 | + $this->define_admin_hooks(); |
|
| 781 | + $this->define_public_hooks(); |
|
| 782 | + |
|
| 783 | + // If we're in `WP_CLI` load the related files. |
|
| 784 | + if ( class_exists( 'WP_CLI' ) ) { |
|
| 785 | + $this->load_cli_dependencies(); |
|
| 786 | + } |
|
| 787 | + |
|
| 788 | + } |
|
| 789 | + |
|
| 790 | + /** |
|
| 791 | + * Get the singleton instance. |
|
| 792 | + * |
|
| 793 | + * @return Wordlift The {@link Wordlift} singleton instance. |
|
| 794 | + * @since 3.11.2 |
|
| 795 | + * |
|
| 796 | + */ |
|
| 797 | + public static function get_instance() { |
|
| 798 | + |
|
| 799 | + return self::$instance; |
|
| 800 | + } |
|
| 801 | + |
|
| 802 | + /** |
|
| 803 | + * Load the required dependencies for this plugin. |
|
| 804 | + * |
|
| 805 | + * Include the following files that make up the plugin: |
|
| 806 | + * |
|
| 807 | + * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 808 | + * - Wordlift_i18n. Defines internationalization functionality. |
|
| 809 | + * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 810 | + * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 811 | + * |
|
| 812 | + * Create an instance of the loader which will be used to register the hooks |
|
| 813 | + * with WordPress. |
|
| 814 | + * |
|
| 815 | + * @throws Exception |
|
| 816 | + * @since 1.0.0 |
|
| 817 | + * @access private |
|
| 818 | + */ |
|
| 819 | + private function load_dependencies() { |
|
| 820 | + |
|
| 821 | + /** |
|
| 822 | + * The class responsible for orchestrating the actions and filters of the |
|
| 823 | + * core plugin. |
|
| 824 | + */ |
|
| 825 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 826 | + |
|
| 827 | + // The class responsible for plugin uninstall. |
|
| 828 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-deactivator-feedback.php'; |
|
| 829 | + |
|
| 830 | + /** |
|
| 831 | + * The class responsible for defining internationalization functionality |
|
| 832 | + * of the plugin. |
|
| 833 | + */ |
|
| 834 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 835 | + |
|
| 836 | + /** |
|
| 837 | + * WordLift's supported languages. |
|
| 838 | + */ |
|
| 839 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php'; |
|
| 840 | + |
|
| 841 | + /** |
|
| 842 | + * WordLift's supported countries. |
|
| 843 | + */ |
|
| 844 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-countries.php'; |
|
| 845 | + |
|
| 846 | + /** |
|
| 847 | + * Provide support functions to sanitize data. |
|
| 848 | + */ |
|
| 849 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 850 | + |
|
| 851 | + /** Services. */ |
|
| 852 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 853 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php'; |
|
| 854 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 855 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 856 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 857 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 858 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 859 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php'; |
|
| 860 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php'; |
|
| 861 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-image-service.php'; |
|
| 862 | + |
|
| 863 | + /** |
|
| 864 | + * The Query builder. |
|
| 865 | + */ |
|
| 866 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 867 | + |
|
| 868 | + /** |
|
| 869 | + * The Schema service. |
|
| 870 | + */ |
|
| 871 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 872 | + |
|
| 873 | + /** |
|
| 874 | + * The schema:url property service. |
|
| 875 | + */ |
|
| 876 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 877 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 878 | + |
|
| 879 | + /** |
|
| 880 | + * The UI service. |
|
| 881 | + */ |
|
| 882 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 883 | + |
|
| 884 | + /** |
|
| 885 | + * The Thumbnail service. |
|
| 886 | + */ |
|
| 887 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 888 | + |
|
| 889 | + /** |
|
| 890 | + * The Entity Types Taxonomy service. |
|
| 891 | + */ |
|
| 892 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-taxonomy-service.php'; |
|
| 893 | + |
|
| 894 | + /** |
|
| 895 | + * The Entity service. |
|
| 896 | + */ |
|
| 897 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php'; |
|
| 898 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 899 | + |
|
| 900 | + // Add the entity rating service. |
|
| 901 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php'; |
|
| 902 | + |
|
| 903 | + /** |
|
| 904 | + * The User service. |
|
| 905 | + */ |
|
| 906 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 907 | + |
|
| 908 | + /** |
|
| 909 | + * The Timeline service. |
|
| 910 | + */ |
|
| 911 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 912 | + |
|
| 913 | + /** |
|
| 914 | + * The Topic Taxonomy service. |
|
| 915 | + */ |
|
| 916 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 917 | + |
|
| 918 | + /** |
|
| 919 | + * The SPARQL service. |
|
| 920 | + */ |
|
| 921 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 922 | + |
|
| 923 | + /** |
|
| 924 | + * The WordLift import service. |
|
| 925 | + */ |
|
| 926 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 927 | + |
|
| 928 | + /** |
|
| 929 | + * The WordLift URI service. |
|
| 930 | + */ |
|
| 931 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 932 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 933 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php'; |
|
| 934 | + |
|
| 935 | + /** |
|
| 936 | + * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
|
| 937 | + */ |
|
| 938 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-listable.php'; |
|
| 939 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-rebuild-service.php'; |
|
| 940 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-reference-rebuild-service.php'; |
|
| 941 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-service.php'; |
|
| 942 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-adapter.php'; |
|
| 943 | + |
|
| 944 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 945 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php'; |
|
| 946 | + |
|
| 947 | + /** |
|
| 948 | + * Load the converters. |
|
| 949 | + */ |
|
| 950 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php'; |
|
| 951 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 952 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 953 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 954 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 955 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php'; |
|
| 956 | + |
|
| 957 | + /** |
|
| 958 | + * Load cache-related files. |
|
| 959 | + */ |
|
| 960 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php'; |
|
| 961 | + |
|
| 962 | + /** |
|
| 963 | + * Load the content filter. |
|
| 964 | + */ |
|
| 965 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 966 | + |
|
| 967 | + /* |
|
| 968 | 968 | * Load the excerpt helper. |
| 969 | 969 | */ |
| 970 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 971 | - |
|
| 972 | - /** |
|
| 973 | - * Load the JSON-LD service to publish entities using JSON-LD.s |
|
| 974 | - * |
|
| 975 | - * @since 3.8.0 |
|
| 976 | - */ |
|
| 977 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 978 | - |
|
| 979 | - // The Publisher Service and the AJAX adapter. |
|
| 980 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php'; |
|
| 981 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 982 | - |
|
| 983 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php'; |
|
| 984 | - |
|
| 985 | - /** |
|
| 986 | - * Load the WordLift key validation service. |
|
| 987 | - */ |
|
| 988 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php'; |
|
| 989 | - |
|
| 990 | - // Load the `Wordlift_Category_Taxonomy_Service` class definition. |
|
| 991 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 992 | - |
|
| 993 | - // Load the `Wordlift_Entity_Page_Service` class definition. |
|
| 994 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php'; |
|
| 995 | - |
|
| 996 | - /** Linked Data. */ |
|
| 997 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php'; |
|
| 998 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php'; |
|
| 999 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php'; |
|
| 1000 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php'; |
|
| 1001 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php'; |
|
| 1002 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php'; |
|
| 1003 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php'; |
|
| 1004 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php'; |
|
| 1005 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php'; |
|
| 1006 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php'; |
|
| 1007 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php'; |
|
| 1008 | - |
|
| 1009 | - /** Linked Data Rendition. */ |
|
| 1010 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/intf-wordlift-sparql-tuple-rendition.php'; |
|
| 1011 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-default-sparql-tuple-rendition.php'; |
|
| 1012 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-address-sparql-tuple-rendition.php'; |
|
| 1013 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php'; |
|
| 1014 | - |
|
| 1015 | - /** Services. */ |
|
| 1016 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php'; |
|
| 1017 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-api-service.php'; |
|
| 1018 | - |
|
| 1019 | - /** Adapters. */ |
|
| 1020 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php'; |
|
| 1021 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php'; |
|
| 1022 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php'; |
|
| 1023 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php'; |
|
| 1024 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-wprocket-adapter.php'; |
|
| 1025 | - |
|
| 1026 | - /** Async Tasks. */ |
|
| 1027 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-async-task.php'; |
|
| 1028 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php'; |
|
| 1029 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-push-references-async-task.php'; |
|
| 1030 | - |
|
| 1031 | - /** Autocomplete. */ |
|
| 1032 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php'; |
|
| 1033 | - |
|
| 1034 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-remote-image-service.php'; |
|
| 1035 | - |
|
| 1036 | - /** Analytics */ |
|
| 1037 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/analytics/class-wordlift-analytics-connect.php'; |
|
| 1038 | - |
|
| 1039 | - /** |
|
| 1040 | - * The class responsible for defining all actions that occur in the admin area. |
|
| 1041 | - */ |
|
| 1042 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 1043 | - |
|
| 1044 | - /** |
|
| 1045 | - * The class to customize the entity list admin page. |
|
| 1046 | - */ |
|
| 1047 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 1048 | - |
|
| 1049 | - /** |
|
| 1050 | - * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 1051 | - */ |
|
| 1052 | - global $wp_version; |
|
| 1053 | - if ( version_compare( $wp_version, '5.3', '<' ) ) { |
|
| 1054 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 1055 | - } else { |
|
| 1056 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker-5-3.php'; |
|
| 1057 | - } |
|
| 1058 | - |
|
| 1059 | - /** |
|
| 1060 | - * The Notice service. |
|
| 1061 | - */ |
|
| 1062 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 1063 | - |
|
| 1064 | - /** |
|
| 1065 | - * The PrimaShop adapter. |
|
| 1066 | - */ |
|
| 1067 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 1068 | - |
|
| 1069 | - /** |
|
| 1070 | - * The WordLift Dashboard service. |
|
| 1071 | - */ |
|
| 1072 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 1073 | - |
|
| 1074 | - /** |
|
| 1075 | - * The admin 'Install wizard' page. |
|
| 1076 | - */ |
|
| 1077 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php'; |
|
| 1078 | - |
|
| 1079 | - /** |
|
| 1080 | - * The WordLift entity type list admin page controller. |
|
| 1081 | - */ |
|
| 1082 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 1083 | - |
|
| 1084 | - /** |
|
| 1085 | - * The WordLift entity type settings admin page controller. |
|
| 1086 | - */ |
|
| 1087 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php'; |
|
| 1088 | - |
|
| 1089 | - /** |
|
| 1090 | - * The admin 'Download Your Data' page. |
|
| 1091 | - */ |
|
| 1092 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 1093 | - |
|
| 1094 | - /** |
|
| 1095 | - * The admin 'WordLift Settings' page. |
|
| 1096 | - */ |
|
| 1097 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/intf-wordlift-admin-element.php'; |
|
| 1098 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-element.php'; |
|
| 1099 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-radio-element.php'; |
|
| 1100 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select-element.php'; |
|
| 1101 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select2-element.php'; |
|
| 1102 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-language-select-element.php'; |
|
| 1103 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-country-select-element.php'; |
|
| 1104 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-tabs-element.php'; |
|
| 1105 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-author-element.php'; |
|
| 1106 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-publisher-element.php'; |
|
| 1107 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php'; |
|
| 1108 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php'; |
|
| 1109 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page.php'; |
|
| 1110 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 1111 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page-action-link.php'; |
|
| 1112 | - |
|
| 1113 | - /** Admin Pages */ |
|
| 1114 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php'; |
|
| 1115 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php'; |
|
| 1116 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php'; |
|
| 1117 | - |
|
| 1118 | - /** |
|
| 1119 | - * The class responsible for defining all actions that occur in the public-facing |
|
| 1120 | - * side of the site. |
|
| 1121 | - */ |
|
| 1122 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 1123 | - |
|
| 1124 | - /** |
|
| 1125 | - * The shortcode abstract class. |
|
| 1126 | - */ |
|
| 1127 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 1128 | - |
|
| 1129 | - /** |
|
| 1130 | - * The Timeline shortcode. |
|
| 1131 | - */ |
|
| 1132 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 1133 | - |
|
| 1134 | - /** |
|
| 1135 | - * The Navigator shortcode. |
|
| 1136 | - */ |
|
| 1137 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 1138 | - |
|
| 1139 | - /** |
|
| 1140 | - * The Products Navigator shortcode. |
|
| 1141 | - */ |
|
| 1142 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-products-navigator-shortcode.php'; |
|
| 1143 | - |
|
| 1144 | - /** |
|
| 1145 | - * The chord shortcode. |
|
| 1146 | - */ |
|
| 1147 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 1148 | - |
|
| 1149 | - /** |
|
| 1150 | - * The geomap shortcode. |
|
| 1151 | - */ |
|
| 1152 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 1153 | - |
|
| 1154 | - /** |
|
| 1155 | - * The entity cloud shortcode. |
|
| 1156 | - */ |
|
| 1157 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 1158 | - |
|
| 1159 | - /** |
|
| 1160 | - * The entity glossary shortcode. |
|
| 1161 | - */ |
|
| 1162 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php'; |
|
| 1163 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php'; |
|
| 1164 | - |
|
| 1165 | - /** |
|
| 1166 | - * Faceted Search shortcode. |
|
| 1167 | - */ |
|
| 1168 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-faceted-search-shortcode.php'; |
|
| 1169 | - |
|
| 1170 | - /** |
|
| 1171 | - * The ShareThis service. |
|
| 1172 | - */ |
|
| 1173 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 1174 | - |
|
| 1175 | - /** |
|
| 1176 | - * The SEO service. |
|
| 1177 | - */ |
|
| 1178 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php'; |
|
| 1179 | - |
|
| 1180 | - /** |
|
| 1181 | - * The AMP service. |
|
| 1182 | - */ |
|
| 1183 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php'; |
|
| 1184 | - |
|
| 1185 | - /** Widgets */ |
|
| 1186 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php'; |
|
| 1187 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 1188 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-context-cards.php'; |
|
| 1189 | - |
|
| 1190 | - /* |
|
| 970 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 971 | + |
|
| 972 | + /** |
|
| 973 | + * Load the JSON-LD service to publish entities using JSON-LD.s |
|
| 974 | + * |
|
| 975 | + * @since 3.8.0 |
|
| 976 | + */ |
|
| 977 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 978 | + |
|
| 979 | + // The Publisher Service and the AJAX adapter. |
|
| 980 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php'; |
|
| 981 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 982 | + |
|
| 983 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php'; |
|
| 984 | + |
|
| 985 | + /** |
|
| 986 | + * Load the WordLift key validation service. |
|
| 987 | + */ |
|
| 988 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php'; |
|
| 989 | + |
|
| 990 | + // Load the `Wordlift_Category_Taxonomy_Service` class definition. |
|
| 991 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 992 | + |
|
| 993 | + // Load the `Wordlift_Entity_Page_Service` class definition. |
|
| 994 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php'; |
|
| 995 | + |
|
| 996 | + /** Linked Data. */ |
|
| 997 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php'; |
|
| 998 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php'; |
|
| 999 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php'; |
|
| 1000 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php'; |
|
| 1001 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php'; |
|
| 1002 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php'; |
|
| 1003 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php'; |
|
| 1004 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php'; |
|
| 1005 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php'; |
|
| 1006 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php'; |
|
| 1007 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php'; |
|
| 1008 | + |
|
| 1009 | + /** Linked Data Rendition. */ |
|
| 1010 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/intf-wordlift-sparql-tuple-rendition.php'; |
|
| 1011 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-default-sparql-tuple-rendition.php'; |
|
| 1012 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-address-sparql-tuple-rendition.php'; |
|
| 1013 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php'; |
|
| 1014 | + |
|
| 1015 | + /** Services. */ |
|
| 1016 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php'; |
|
| 1017 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-api-service.php'; |
|
| 1018 | + |
|
| 1019 | + /** Adapters. */ |
|
| 1020 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php'; |
|
| 1021 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php'; |
|
| 1022 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php'; |
|
| 1023 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php'; |
|
| 1024 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-wprocket-adapter.php'; |
|
| 1025 | + |
|
| 1026 | + /** Async Tasks. */ |
|
| 1027 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-async-task.php'; |
|
| 1028 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php'; |
|
| 1029 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-push-references-async-task.php'; |
|
| 1030 | + |
|
| 1031 | + /** Autocomplete. */ |
|
| 1032 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php'; |
|
| 1033 | + |
|
| 1034 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-remote-image-service.php'; |
|
| 1035 | + |
|
| 1036 | + /** Analytics */ |
|
| 1037 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/analytics/class-wordlift-analytics-connect.php'; |
|
| 1038 | + |
|
| 1039 | + /** |
|
| 1040 | + * The class responsible for defining all actions that occur in the admin area. |
|
| 1041 | + */ |
|
| 1042 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 1043 | + |
|
| 1044 | + /** |
|
| 1045 | + * The class to customize the entity list admin page. |
|
| 1046 | + */ |
|
| 1047 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 1048 | + |
|
| 1049 | + /** |
|
| 1050 | + * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 1051 | + */ |
|
| 1052 | + global $wp_version; |
|
| 1053 | + if ( version_compare( $wp_version, '5.3', '<' ) ) { |
|
| 1054 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 1055 | + } else { |
|
| 1056 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker-5-3.php'; |
|
| 1057 | + } |
|
| 1058 | + |
|
| 1059 | + /** |
|
| 1060 | + * The Notice service. |
|
| 1061 | + */ |
|
| 1062 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 1063 | + |
|
| 1064 | + /** |
|
| 1065 | + * The PrimaShop adapter. |
|
| 1066 | + */ |
|
| 1067 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 1068 | + |
|
| 1069 | + /** |
|
| 1070 | + * The WordLift Dashboard service. |
|
| 1071 | + */ |
|
| 1072 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 1073 | + |
|
| 1074 | + /** |
|
| 1075 | + * The admin 'Install wizard' page. |
|
| 1076 | + */ |
|
| 1077 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php'; |
|
| 1078 | + |
|
| 1079 | + /** |
|
| 1080 | + * The WordLift entity type list admin page controller. |
|
| 1081 | + */ |
|
| 1082 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 1083 | + |
|
| 1084 | + /** |
|
| 1085 | + * The WordLift entity type settings admin page controller. |
|
| 1086 | + */ |
|
| 1087 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php'; |
|
| 1088 | + |
|
| 1089 | + /** |
|
| 1090 | + * The admin 'Download Your Data' page. |
|
| 1091 | + */ |
|
| 1092 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 1093 | + |
|
| 1094 | + /** |
|
| 1095 | + * The admin 'WordLift Settings' page. |
|
| 1096 | + */ |
|
| 1097 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/intf-wordlift-admin-element.php'; |
|
| 1098 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-element.php'; |
|
| 1099 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-radio-element.php'; |
|
| 1100 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select-element.php'; |
|
| 1101 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select2-element.php'; |
|
| 1102 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-language-select-element.php'; |
|
| 1103 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-country-select-element.php'; |
|
| 1104 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-tabs-element.php'; |
|
| 1105 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-author-element.php'; |
|
| 1106 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-publisher-element.php'; |
|
| 1107 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php'; |
|
| 1108 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php'; |
|
| 1109 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page.php'; |
|
| 1110 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 1111 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page-action-link.php'; |
|
| 1112 | + |
|
| 1113 | + /** Admin Pages */ |
|
| 1114 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php'; |
|
| 1115 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php'; |
|
| 1116 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php'; |
|
| 1117 | + |
|
| 1118 | + /** |
|
| 1119 | + * The class responsible for defining all actions that occur in the public-facing |
|
| 1120 | + * side of the site. |
|
| 1121 | + */ |
|
| 1122 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 1123 | + |
|
| 1124 | + /** |
|
| 1125 | + * The shortcode abstract class. |
|
| 1126 | + */ |
|
| 1127 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 1128 | + |
|
| 1129 | + /** |
|
| 1130 | + * The Timeline shortcode. |
|
| 1131 | + */ |
|
| 1132 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 1133 | + |
|
| 1134 | + /** |
|
| 1135 | + * The Navigator shortcode. |
|
| 1136 | + */ |
|
| 1137 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 1138 | + |
|
| 1139 | + /** |
|
| 1140 | + * The Products Navigator shortcode. |
|
| 1141 | + */ |
|
| 1142 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-products-navigator-shortcode.php'; |
|
| 1143 | + |
|
| 1144 | + /** |
|
| 1145 | + * The chord shortcode. |
|
| 1146 | + */ |
|
| 1147 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 1148 | + |
|
| 1149 | + /** |
|
| 1150 | + * The geomap shortcode. |
|
| 1151 | + */ |
|
| 1152 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 1153 | + |
|
| 1154 | + /** |
|
| 1155 | + * The entity cloud shortcode. |
|
| 1156 | + */ |
|
| 1157 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 1158 | + |
|
| 1159 | + /** |
|
| 1160 | + * The entity glossary shortcode. |
|
| 1161 | + */ |
|
| 1162 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php'; |
|
| 1163 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php'; |
|
| 1164 | + |
|
| 1165 | + /** |
|
| 1166 | + * Faceted Search shortcode. |
|
| 1167 | + */ |
|
| 1168 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-faceted-search-shortcode.php'; |
|
| 1169 | + |
|
| 1170 | + /** |
|
| 1171 | + * The ShareThis service. |
|
| 1172 | + */ |
|
| 1173 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 1174 | + |
|
| 1175 | + /** |
|
| 1176 | + * The SEO service. |
|
| 1177 | + */ |
|
| 1178 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php'; |
|
| 1179 | + |
|
| 1180 | + /** |
|
| 1181 | + * The AMP service. |
|
| 1182 | + */ |
|
| 1183 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php'; |
|
| 1184 | + |
|
| 1185 | + /** Widgets */ |
|
| 1186 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php'; |
|
| 1187 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 1188 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-context-cards.php'; |
|
| 1189 | + |
|
| 1190 | + /* |
|
| 1191 | 1191 | * Schema.org Services. |
| 1192 | 1192 | * |
| 1193 | 1193 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
| 1194 | 1194 | */ |
| 1195 | - if ( WL_ALL_ENTITY_TYPES ) { |
|
| 1196 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-sync-service.php'; |
|
| 1197 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-property-service.php'; |
|
| 1198 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-class-service.php'; |
|
| 1199 | - new Wordlift_Schemaorg_Sync_Service(); |
|
| 1200 | - $schemaorg_property_service = new Wordlift_Schemaorg_Property_Service(); |
|
| 1201 | - new Wordlift_Schemaorg_Class_Service(); |
|
| 1202 | - } else { |
|
| 1203 | - $schemaorg_property_service = null; |
|
| 1204 | - } |
|
| 1205 | - |
|
| 1206 | - $this->loader = new Wordlift_Loader(); |
|
| 1207 | - /** |
|
| 1208 | - * @since 3.30.0 |
|
| 1209 | - */ |
|
| 1210 | - $this->features_registry = Features_Registry::get_instance(); |
|
| 1195 | + if ( WL_ALL_ENTITY_TYPES ) { |
|
| 1196 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-sync-service.php'; |
|
| 1197 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-property-service.php'; |
|
| 1198 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-class-service.php'; |
|
| 1199 | + new Wordlift_Schemaorg_Sync_Service(); |
|
| 1200 | + $schemaorg_property_service = new Wordlift_Schemaorg_Property_Service(); |
|
| 1201 | + new Wordlift_Schemaorg_Class_Service(); |
|
| 1202 | + } else { |
|
| 1203 | + $schemaorg_property_service = null; |
|
| 1204 | + } |
|
| 1205 | + |
|
| 1206 | + $this->loader = new Wordlift_Loader(); |
|
| 1207 | + /** |
|
| 1208 | + * @since 3.30.0 |
|
| 1209 | + */ |
|
| 1210 | + $this->features_registry = Features_Registry::get_instance(); |
|
| 1211 | 1211 | |
| 1212 | - // Instantiate a global logger. |
|
| 1213 | - global $wl_logger; |
|
| 1214 | - $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 1212 | + // Instantiate a global logger. |
|
| 1213 | + global $wl_logger; |
|
| 1214 | + $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 1215 | 1215 | |
| 1216 | - // Load the `wl-api` end-point. |
|
| 1217 | - new Wordlift_Http_Api(); |
|
| 1216 | + // Load the `wl-api` end-point. |
|
| 1217 | + new Wordlift_Http_Api(); |
|
| 1218 | 1218 | |
| 1219 | - // Load the Install Service. |
|
| 1220 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-service.php'; |
|
| 1221 | - $this->install_service = new Wordlift_Install_Service(); |
|
| 1219 | + // Load the Install Service. |
|
| 1220 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-service.php'; |
|
| 1221 | + $this->install_service = new Wordlift_Install_Service(); |
|
| 1222 | 1222 | |
| 1223 | - /** Services. */ |
|
| 1224 | - // Create the configuration service. |
|
| 1225 | - $this->configuration_service = new Wordlift_Configuration_Service(); |
|
| 1226 | - $api_service = new Wordlift_Api_Service( $this->configuration_service ); |
|
| 1223 | + /** Services. */ |
|
| 1224 | + // Create the configuration service. |
|
| 1225 | + $this->configuration_service = new Wordlift_Configuration_Service(); |
|
| 1226 | + $api_service = new Wordlift_Api_Service( $this->configuration_service ); |
|
| 1227 | 1227 | |
| 1228 | - // Create an entity type service instance. It'll be later bound to the init action. |
|
| 1229 | - $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() ); |
|
| 1228 | + // Create an entity type service instance. It'll be later bound to the init action. |
|
| 1229 | + $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() ); |
|
| 1230 | 1230 | |
| 1231 | - // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 1232 | - $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() ); |
|
| 1231 | + // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 1232 | + $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() ); |
|
| 1233 | 1233 | |
| 1234 | - // Create an instance of the UI service. |
|
| 1235 | - $this->ui_service = new Wordlift_UI_Service(); |
|
| 1234 | + // Create an instance of the UI service. |
|
| 1235 | + $this->ui_service = new Wordlift_UI_Service(); |
|
| 1236 | 1236 | |
| 1237 | - // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 1238 | - $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 1237 | + // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 1238 | + $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 1239 | 1239 | |
| 1240 | - $this->sparql_service = new Wordlift_Sparql_Service(); |
|
| 1241 | - $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 1242 | - $this->notice_service = new Wordlift_Notice_Service(); |
|
| 1243 | - $this->relation_service = new Wordlift_Relation_Service(); |
|
| 1240 | + $this->sparql_service = new Wordlift_Sparql_Service(); |
|
| 1241 | + $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 1242 | + $this->notice_service = new Wordlift_Notice_Service(); |
|
| 1243 | + $this->relation_service = new Wordlift_Relation_Service(); |
|
| 1244 | 1244 | |
| 1245 | - $entity_uri_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'entity_uri/' ); |
|
| 1246 | - $this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service( $this->configuration_service, $entity_uri_cache_service ); |
|
| 1247 | - $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service, $this->entity_uri_service ); |
|
| 1248 | - $this->user_service = new Wordlift_User_Service( $this->sparql_service, $this->entity_service ); |
|
| 1245 | + $entity_uri_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'entity_uri/' ); |
|
| 1246 | + $this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service( $this->configuration_service, $entity_uri_cache_service ); |
|
| 1247 | + $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service, $this->entity_uri_service ); |
|
| 1248 | + $this->user_service = new Wordlift_User_Service( $this->sparql_service, $this->entity_service ); |
|
| 1249 | 1249 | |
| 1250 | - // Instantiate the JSON-LD service. |
|
| 1251 | - $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 1250 | + // Instantiate the JSON-LD service. |
|
| 1251 | + $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 1252 | 1252 | |
| 1253 | - /** Linked Data. */ |
|
| 1254 | - $this->storage_factory = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter ); |
|
| 1255 | - $this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service ); |
|
| 1253 | + /** Linked Data. */ |
|
| 1254 | + $this->storage_factory = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter ); |
|
| 1255 | + $this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service ); |
|
| 1256 | 1256 | |
| 1257 | - $this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service ); |
|
| 1257 | + $this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service ); |
|
| 1258 | 1258 | |
| 1259 | - // Create a new instance of the Redirect service. |
|
| 1260 | - $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_uri_service ); |
|
| 1261 | - $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service ); |
|
| 1259 | + // Create a new instance of the Redirect service. |
|
| 1260 | + $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_uri_service ); |
|
| 1261 | + $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service ); |
|
| 1262 | 1262 | |
| 1263 | - // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 1264 | - $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service ); |
|
| 1263 | + // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 1264 | + $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service ); |
|
| 1265 | 1265 | |
| 1266 | - $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 1266 | + $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 1267 | 1267 | |
| 1268 | - $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 1269 | - $this->entity_types_taxonomy_service = new Wordlift_Entity_Type_Taxonomy_Service(); |
|
| 1268 | + $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 1269 | + $this->entity_types_taxonomy_service = new Wordlift_Entity_Type_Taxonomy_Service(); |
|
| 1270 | 1270 | |
| 1271 | - // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 1272 | - $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 1271 | + // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 1272 | + $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 1273 | 1273 | |
| 1274 | - // Create an instance of the PrimaShop adapter. |
|
| 1275 | - $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 1274 | + // Create an instance of the PrimaShop adapter. |
|
| 1275 | + $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 1276 | 1276 | |
| 1277 | - // Create an import service instance to hook later to WP's import function. |
|
| 1278 | - $this->import_service = new Wordlift_Import_Service( $this->entity_post_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, $this->configuration_service->get_dataset_uri() ); |
|
| 1277 | + // Create an import service instance to hook later to WP's import function. |
|
| 1278 | + $this->import_service = new Wordlift_Import_Service( $this->entity_post_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, $this->configuration_service->get_dataset_uri() ); |
|
| 1279 | 1279 | |
| 1280 | - $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 1280 | + $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 1281 | 1281 | |
| 1282 | - // Create the entity rating service. |
|
| 1283 | - $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service ); |
|
| 1282 | + // Create the entity rating service. |
|
| 1283 | + $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service ); |
|
| 1284 | 1284 | |
| 1285 | - // Create entity list customization (wp-admin/edit.php). |
|
| 1286 | - $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service ); |
|
| 1285 | + // Create entity list customization (wp-admin/edit.php). |
|
| 1286 | + $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service ); |
|
| 1287 | 1287 | |
| 1288 | - // Create a new instance of the Redirect service. |
|
| 1289 | - $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service ); |
|
| 1288 | + // Create a new instance of the Redirect service. |
|
| 1289 | + $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service ); |
|
| 1290 | 1290 | |
| 1291 | - // Create an instance of the Publisher Service and the AJAX Adapter. |
|
| 1292 | - $this->publisher_service = new Wordlift_Publisher_Service( $this->configuration_service ); |
|
| 1293 | - $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 1294 | - $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 1291 | + // Create an instance of the Publisher Service and the AJAX Adapter. |
|
| 1292 | + $this->publisher_service = new Wordlift_Publisher_Service( $this->configuration_service ); |
|
| 1293 | + $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 1294 | + $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 1295 | 1295 | |
| 1296 | - $attachment_service = new Wordlift_Attachment_Service(); |
|
| 1296 | + $attachment_service = new Wordlift_Attachment_Service(); |
|
| 1297 | 1297 | |
| 1298 | - // Instantiate the JSON-LD service. |
|
| 1299 | - $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 1300 | - $this->post_to_jsonld_converter = new Wordlift_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service ); |
|
| 1301 | - $this->entity_post_to_jsonld_converter = new Wordlift_Entity_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $property_getter, $schemaorg_property_service, $this->post_to_jsonld_converter ); |
|
| 1302 | - $this->postid_to_jsonld_converter = new Wordlift_Postid_To_Jsonld_Converter( $this->entity_service, $this->entity_post_to_jsonld_converter, $this->post_to_jsonld_converter ); |
|
| 1303 | - $this->jsonld_website_converter = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service ); |
|
| 1298 | + // Instantiate the JSON-LD service. |
|
| 1299 | + $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 1300 | + $this->post_to_jsonld_converter = new Wordlift_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service ); |
|
| 1301 | + $this->entity_post_to_jsonld_converter = new Wordlift_Entity_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $property_getter, $schemaorg_property_service, $this->post_to_jsonld_converter ); |
|
| 1302 | + $this->postid_to_jsonld_converter = new Wordlift_Postid_To_Jsonld_Converter( $this->entity_service, $this->entity_post_to_jsonld_converter, $this->post_to_jsonld_converter ); |
|
| 1303 | + $this->jsonld_website_converter = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service ); |
|
| 1304 | 1304 | |
| 1305 | - $jsonld_cache = new Ttl_Cache( 'jsonld', 86400 ); |
|
| 1306 | - $this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $this->postid_to_jsonld_converter, $this->configuration_service, $jsonld_cache ); |
|
| 1307 | - /* |
|
| 1305 | + $jsonld_cache = new Ttl_Cache( 'jsonld', 86400 ); |
|
| 1306 | + $this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $this->postid_to_jsonld_converter, $this->configuration_service, $jsonld_cache ); |
|
| 1307 | + /* |
|
| 1308 | 1308 | * Load the `Wordlift_Term_JsonLd_Adapter`. |
| 1309 | 1309 | * |
| 1310 | 1310 | * @see https://github.com/insideout10/wordlift-plugin/issues/892 |
| 1311 | 1311 | * |
| 1312 | 1312 | * @since 3.20.0 |
| 1313 | 1313 | */ |
| 1314 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-term-jsonld-adapter.php'; |
|
| 1315 | - |
|
| 1316 | - $term_jsonld_adapter = new Wordlift_Term_JsonLd_Adapter( $this->entity_uri_service, $this->cached_postid_to_jsonld_converter ); |
|
| 1317 | - $this->jsonld_service = new Wordlift_Jsonld_Service( $this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter, $term_jsonld_adapter ); |
|
| 1318 | - |
|
| 1319 | - $jsonld_service = new Jsonld_Service( |
|
| 1320 | - $this->jsonld_service, |
|
| 1321 | - $term_jsonld_adapter, |
|
| 1322 | - new Jsonld_User_Service( $this->user_service ) ); |
|
| 1323 | - new Jsonld_Endpoint( $jsonld_service, $this->entity_uri_service ); |
|
| 1324 | - |
|
| 1325 | - // Prints the JSON-LD in the head. |
|
| 1326 | - new Jsonld_Adapter( $this->jsonld_service ); |
|
| 1327 | - |
|
| 1328 | - new Jsonld_By_Id_Endpoint( $this->jsonld_service, $this->entity_uri_service ); |
|
| 1329 | - |
|
| 1330 | - $this->key_validation_service = new Wordlift_Key_Validation_Service( $this->configuration_service ); |
|
| 1331 | - $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service, $this->entity_uri_service ); |
|
| 1332 | - // Creating Faq Content filter service. |
|
| 1333 | - $this->faq_content_filter_service = new Faq_Content_Filter(); |
|
| 1334 | - $this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service ); |
|
| 1335 | - $this->sample_data_service = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service, $this->user_service ); |
|
| 1336 | - $this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service ); |
|
| 1337 | - $this->reference_rebuild_service = new Wordlift_Reference_Rebuild_Service( $this->entity_service ); |
|
| 1338 | - |
|
| 1339 | - $this->loader->add_action( 'enqueue_block_editor_assets', $this, 'add_wl_enabled_blocks' ); |
|
| 1340 | - $this->loader->add_action( 'admin_enqueue_scripts', $this, 'add_wl_enabled_blocks' ); |
|
| 1341 | - |
|
| 1342 | - /** |
|
| 1343 | - * Filter: wl_feature__enable__blocks. |
|
| 1344 | - * |
|
| 1345 | - * @param bool whether the blocks needed to be registered, defaults to true. |
|
| 1346 | - * |
|
| 1347 | - * @return bool |
|
| 1348 | - * @since 3.27.6 |
|
| 1349 | - */ |
|
| 1350 | - if ( apply_filters( 'wl_feature__enable__blocks', true ) ) { |
|
| 1351 | - // Initialize the short-codes. |
|
| 1352 | - new Async_Template_Decorator( new Wordlift_Navigator_Shortcode() ); |
|
| 1353 | - new Wordlift_Chord_Shortcode(); |
|
| 1354 | - new Wordlift_Geomap_Shortcode(); |
|
| 1355 | - new Wordlift_Timeline_Shortcode(); |
|
| 1356 | - new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service, $this->entity_service ); |
|
| 1357 | - new Wordlift_Vocabulary_Shortcode( $this->configuration_service ); |
|
| 1358 | - new Async_Template_Decorator( new Wordlift_Faceted_Search_Shortcode() ); |
|
| 1359 | - } |
|
| 1360 | - |
|
| 1361 | - new Wordlift_Products_Navigator_Shortcode(); |
|
| 1362 | - |
|
| 1363 | - |
|
| 1364 | - // Initialize the Context Cards Service |
|
| 1365 | - $this->context_cards_service = new Wordlift_Context_Cards_Service(); |
|
| 1366 | - |
|
| 1367 | - // Initialize the SEO service. |
|
| 1368 | - new Wordlift_Seo_Service(); |
|
| 1369 | - |
|
| 1370 | - // Initialize the AMP service. |
|
| 1371 | - new Wordlift_AMP_Service( $this->jsonld_service ); |
|
| 1372 | - |
|
| 1373 | - /** Services. */ |
|
| 1374 | - $this->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service(); |
|
| 1375 | - new Wordlift_Image_Service(); |
|
| 1376 | - |
|
| 1377 | - /** Adapters. */ |
|
| 1378 | - $this->entity_type_adapter = new Wordlift_Entity_Type_Adapter( $this->entity_type_service ); |
|
| 1379 | - $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $this->publisher_service ); |
|
| 1380 | - $this->tinymce_adapter = new Wordlift_Tinymce_Adapter( $this ); |
|
| 1381 | - //$this->faq_tinymce_adapter = new Faq_Tinymce_Adapter(); |
|
| 1382 | - $this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service ); |
|
| 1383 | - |
|
| 1384 | - /* |
|
| 1314 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-term-jsonld-adapter.php'; |
|
| 1315 | + |
|
| 1316 | + $term_jsonld_adapter = new Wordlift_Term_JsonLd_Adapter( $this->entity_uri_service, $this->cached_postid_to_jsonld_converter ); |
|
| 1317 | + $this->jsonld_service = new Wordlift_Jsonld_Service( $this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter, $term_jsonld_adapter ); |
|
| 1318 | + |
|
| 1319 | + $jsonld_service = new Jsonld_Service( |
|
| 1320 | + $this->jsonld_service, |
|
| 1321 | + $term_jsonld_adapter, |
|
| 1322 | + new Jsonld_User_Service( $this->user_service ) ); |
|
| 1323 | + new Jsonld_Endpoint( $jsonld_service, $this->entity_uri_service ); |
|
| 1324 | + |
|
| 1325 | + // Prints the JSON-LD in the head. |
|
| 1326 | + new Jsonld_Adapter( $this->jsonld_service ); |
|
| 1327 | + |
|
| 1328 | + new Jsonld_By_Id_Endpoint( $this->jsonld_service, $this->entity_uri_service ); |
|
| 1329 | + |
|
| 1330 | + $this->key_validation_service = new Wordlift_Key_Validation_Service( $this->configuration_service ); |
|
| 1331 | + $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service, $this->entity_uri_service ); |
|
| 1332 | + // Creating Faq Content filter service. |
|
| 1333 | + $this->faq_content_filter_service = new Faq_Content_Filter(); |
|
| 1334 | + $this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service ); |
|
| 1335 | + $this->sample_data_service = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service, $this->user_service ); |
|
| 1336 | + $this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service ); |
|
| 1337 | + $this->reference_rebuild_service = new Wordlift_Reference_Rebuild_Service( $this->entity_service ); |
|
| 1338 | + |
|
| 1339 | + $this->loader->add_action( 'enqueue_block_editor_assets', $this, 'add_wl_enabled_blocks' ); |
|
| 1340 | + $this->loader->add_action( 'admin_enqueue_scripts', $this, 'add_wl_enabled_blocks' ); |
|
| 1341 | + |
|
| 1342 | + /** |
|
| 1343 | + * Filter: wl_feature__enable__blocks. |
|
| 1344 | + * |
|
| 1345 | + * @param bool whether the blocks needed to be registered, defaults to true. |
|
| 1346 | + * |
|
| 1347 | + * @return bool |
|
| 1348 | + * @since 3.27.6 |
|
| 1349 | + */ |
|
| 1350 | + if ( apply_filters( 'wl_feature__enable__blocks', true ) ) { |
|
| 1351 | + // Initialize the short-codes. |
|
| 1352 | + new Async_Template_Decorator( new Wordlift_Navigator_Shortcode() ); |
|
| 1353 | + new Wordlift_Chord_Shortcode(); |
|
| 1354 | + new Wordlift_Geomap_Shortcode(); |
|
| 1355 | + new Wordlift_Timeline_Shortcode(); |
|
| 1356 | + new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service, $this->entity_service ); |
|
| 1357 | + new Wordlift_Vocabulary_Shortcode( $this->configuration_service ); |
|
| 1358 | + new Async_Template_Decorator( new Wordlift_Faceted_Search_Shortcode() ); |
|
| 1359 | + } |
|
| 1360 | + |
|
| 1361 | + new Wordlift_Products_Navigator_Shortcode(); |
|
| 1362 | + |
|
| 1363 | + |
|
| 1364 | + // Initialize the Context Cards Service |
|
| 1365 | + $this->context_cards_service = new Wordlift_Context_Cards_Service(); |
|
| 1366 | + |
|
| 1367 | + // Initialize the SEO service. |
|
| 1368 | + new Wordlift_Seo_Service(); |
|
| 1369 | + |
|
| 1370 | + // Initialize the AMP service. |
|
| 1371 | + new Wordlift_AMP_Service( $this->jsonld_service ); |
|
| 1372 | + |
|
| 1373 | + /** Services. */ |
|
| 1374 | + $this->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service(); |
|
| 1375 | + new Wordlift_Image_Service(); |
|
| 1376 | + |
|
| 1377 | + /** Adapters. */ |
|
| 1378 | + $this->entity_type_adapter = new Wordlift_Entity_Type_Adapter( $this->entity_type_service ); |
|
| 1379 | + $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $this->publisher_service ); |
|
| 1380 | + $this->tinymce_adapter = new Wordlift_Tinymce_Adapter( $this ); |
|
| 1381 | + //$this->faq_tinymce_adapter = new Faq_Tinymce_Adapter(); |
|
| 1382 | + $this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service ); |
|
| 1383 | + |
|
| 1384 | + /* |
|
| 1385 | 1385 | * Exclude our public js from WP-Rocket. |
| 1386 | 1386 | * |
| 1387 | 1387 | * @since 3.19.4 |
| 1388 | 1388 | * |
| 1389 | 1389 | * @see https://github.com/insideout10/wordlift-plugin/issues/842. |
| 1390 | 1390 | */ |
| 1391 | - new Wordlift_WpRocket_Adapter(); |
|
| 1392 | - |
|
| 1393 | - // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
|
| 1394 | - $this->rebuild_service = new Wordlift_Rebuild_Service( |
|
| 1395 | - $this->sparql_service, |
|
| 1396 | - $uri_service |
|
| 1397 | - ); |
|
| 1398 | - |
|
| 1399 | - $that = $this; |
|
| 1400 | - add_action( 'plugins_loaded', function () use ( $that ) { |
|
| 1401 | - if ( ! apply_filters( 'wl_feature__enable__dataset-ng', false ) ) { |
|
| 1402 | - new Wordlift_Linked_Data_Service( $that->entity_service, $that->entity_type_service, $that->schema_service, $that->sparql_service ); |
|
| 1403 | - new Wordlift_Sparql_Query_Async_Task(); |
|
| 1404 | - new Wordlift_Push_References_Async_Task(); |
|
| 1405 | - } |
|
| 1406 | - } ); |
|
| 1407 | - |
|
| 1408 | - /** WordPress Admin UI. */ |
|
| 1409 | - |
|
| 1410 | - // UI elements. |
|
| 1411 | - $this->input_element = new Wordlift_Admin_Input_Element(); |
|
| 1412 | - $this->radio_input_element = new Wordlift_Admin_Radio_Input_Element(); |
|
| 1413 | - $this->select2_element = new Wordlift_Admin_Select2_Element(); |
|
| 1414 | - $this->language_select_element = new Wordlift_Admin_Language_Select_Element(); |
|
| 1415 | - $this->country_select_element = new Wordlift_Admin_Country_Select_Element(); |
|
| 1416 | - $tabs_element = new Wordlift_Admin_Tabs_Element(); |
|
| 1417 | - $this->publisher_element = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $this->publisher_service, $tabs_element, $this->select2_element ); |
|
| 1418 | - $this->author_element = new Wordlift_Admin_Author_Element( $this->publisher_service, $this->select2_element ); |
|
| 1419 | - |
|
| 1420 | - $this->settings_page = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->country_select_element, $this->publisher_element, $this->radio_input_element ); |
|
| 1421 | - $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page ); |
|
| 1422 | - |
|
| 1423 | - $this->analytics_settings_page = new Wordlift_Admin_Settings_Analytics_Page( $this->configuration_service, $this->input_element, $this->radio_input_element ); |
|
| 1424 | - $this->analytics_settings_page_action_link = new Wordlift_Admin_Settings_Analytics_Page_Action_Link( $this->analytics_settings_page ); |
|
| 1425 | - $this->analytics_connect = new Wordlift_Analytics_Connect(); |
|
| 1426 | - |
|
| 1427 | - // Pages. |
|
| 1428 | - /* |
|
| 1391 | + new Wordlift_WpRocket_Adapter(); |
|
| 1392 | + |
|
| 1393 | + // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
|
| 1394 | + $this->rebuild_service = new Wordlift_Rebuild_Service( |
|
| 1395 | + $this->sparql_service, |
|
| 1396 | + $uri_service |
|
| 1397 | + ); |
|
| 1398 | + |
|
| 1399 | + $that = $this; |
|
| 1400 | + add_action( 'plugins_loaded', function () use ( $that ) { |
|
| 1401 | + if ( ! apply_filters( 'wl_feature__enable__dataset-ng', false ) ) { |
|
| 1402 | + new Wordlift_Linked_Data_Service( $that->entity_service, $that->entity_type_service, $that->schema_service, $that->sparql_service ); |
|
| 1403 | + new Wordlift_Sparql_Query_Async_Task(); |
|
| 1404 | + new Wordlift_Push_References_Async_Task(); |
|
| 1405 | + } |
|
| 1406 | + } ); |
|
| 1407 | + |
|
| 1408 | + /** WordPress Admin UI. */ |
|
| 1409 | + |
|
| 1410 | + // UI elements. |
|
| 1411 | + $this->input_element = new Wordlift_Admin_Input_Element(); |
|
| 1412 | + $this->radio_input_element = new Wordlift_Admin_Radio_Input_Element(); |
|
| 1413 | + $this->select2_element = new Wordlift_Admin_Select2_Element(); |
|
| 1414 | + $this->language_select_element = new Wordlift_Admin_Language_Select_Element(); |
|
| 1415 | + $this->country_select_element = new Wordlift_Admin_Country_Select_Element(); |
|
| 1416 | + $tabs_element = new Wordlift_Admin_Tabs_Element(); |
|
| 1417 | + $this->publisher_element = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $this->publisher_service, $tabs_element, $this->select2_element ); |
|
| 1418 | + $this->author_element = new Wordlift_Admin_Author_Element( $this->publisher_service, $this->select2_element ); |
|
| 1419 | + |
|
| 1420 | + $this->settings_page = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->country_select_element, $this->publisher_element, $this->radio_input_element ); |
|
| 1421 | + $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page ); |
|
| 1422 | + |
|
| 1423 | + $this->analytics_settings_page = new Wordlift_Admin_Settings_Analytics_Page( $this->configuration_service, $this->input_element, $this->radio_input_element ); |
|
| 1424 | + $this->analytics_settings_page_action_link = new Wordlift_Admin_Settings_Analytics_Page_Action_Link( $this->analytics_settings_page ); |
|
| 1425 | + $this->analytics_connect = new Wordlift_Analytics_Connect(); |
|
| 1426 | + |
|
| 1427 | + // Pages. |
|
| 1428 | + /* |
|
| 1429 | 1429 | * Call the `wl_can_see_classification_box` filter to determine whether we can display the classification box. |
| 1430 | 1430 | * |
| 1431 | 1431 | * @since 3.20.3 |
| 1432 | 1432 | * |
| 1433 | 1433 | * @see https://github.com/insideout10/wordlift-plugin/issues/914 |
| 1434 | 1434 | */ |
| 1435 | - if ( apply_filters( 'wl_can_see_classification_box', true ) ) { |
|
| 1436 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 1437 | - new Wordlift_Admin_Post_Edit_Page( $this ); |
|
| 1438 | - } |
|
| 1439 | - new Wordlift_Entity_Type_Admin_Service(); |
|
| 1435 | + if ( apply_filters( 'wl_can_see_classification_box', true ) ) { |
|
| 1436 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 1437 | + new Wordlift_Admin_Post_Edit_Page( $this ); |
|
| 1438 | + } |
|
| 1439 | + new Wordlift_Entity_Type_Admin_Service(); |
|
| 1440 | 1440 | |
| 1441 | - // create an instance of the entity type list admin page controller. |
|
| 1442 | - $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page(); |
|
| 1441 | + // create an instance of the entity type list admin page controller. |
|
| 1442 | + $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page(); |
|
| 1443 | 1443 | |
| 1444 | - // create an instance of the entity type setting admin page controller. |
|
| 1445 | - $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings(); |
|
| 1444 | + // create an instance of the entity type setting admin page controller. |
|
| 1445 | + $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings(); |
|
| 1446 | 1446 | |
| 1447 | - /** Widgets */ |
|
| 1448 | - $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget(); |
|
| 1447 | + /** Widgets */ |
|
| 1448 | + $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget(); |
|
| 1449 | 1449 | |
| 1450 | - /* WordPress Admin. */ |
|
| 1451 | - $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 1452 | - $this->status_page = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service ); |
|
| 1450 | + /* WordPress Admin. */ |
|
| 1451 | + $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 1452 | + $this->status_page = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service ); |
|
| 1453 | 1453 | |
| 1454 | - // Create an instance of the install wizard. |
|
| 1455 | - $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service, $this->language_select_element, $this->country_select_element ); |
|
| 1454 | + // Create an instance of the install wizard. |
|
| 1455 | + $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service, $this->language_select_element, $this->country_select_element ); |
|
| 1456 | 1456 | |
| 1457 | - $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service ); |
|
| 1457 | + $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service ); |
|
| 1458 | 1458 | |
| 1459 | - // User Profile. |
|
| 1460 | - new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service ); |
|
| 1459 | + // User Profile. |
|
| 1460 | + new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service ); |
|
| 1461 | 1461 | |
| 1462 | - $this->entity_page_service = new Wordlift_Entity_Page_Service(); |
|
| 1462 | + $this->entity_page_service = new Wordlift_Entity_Page_Service(); |
|
| 1463 | 1463 | |
| 1464 | - // Load the debug service if WP is in debug mode. |
|
| 1465 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 1466 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 1467 | - new Wordlift_Debug_Service( $this->entity_service, $uri_service ); |
|
| 1468 | - } |
|
| 1464 | + // Load the debug service if WP is in debug mode. |
|
| 1465 | + if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 1466 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 1467 | + new Wordlift_Debug_Service( $this->entity_service, $uri_service ); |
|
| 1468 | + } |
|
| 1469 | 1469 | |
| 1470 | - // Remote Image Service. |
|
| 1471 | - new Wordlift_Remote_Image_Service(); |
|
| 1470 | + // Remote Image Service. |
|
| 1471 | + new Wordlift_Remote_Image_Service(); |
|
| 1472 | 1472 | |
| 1473 | - /* |
|
| 1473 | + /* |
|
| 1474 | 1474 | * Provides mappings between post types and entity types. |
| 1475 | 1475 | * |
| 1476 | 1476 | * @since 3.20.0 |
| 1477 | 1477 | * |
| 1478 | 1478 | * @see https://github.com/insideout10/wordlift-plugin/issues/852. |
| 1479 | 1479 | */ |
| 1480 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-action.php'; |
|
| 1481 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-service.php'; |
|
| 1482 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-ajax-adapter.php'; |
|
| 1480 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-action.php'; |
|
| 1481 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-service.php'; |
|
| 1482 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-ajax-adapter.php'; |
|
| 1483 | 1483 | |
| 1484 | - // Create an instance of the Mapping Service and assign it to the Ajax Adapter. |
|
| 1485 | - new Wordlift_Mapping_Ajax_Adapter( new Wordlift_Mapping_Service( Wordlift_Entity_Type_Service::get_instance() ) ); |
|
| 1484 | + // Create an instance of the Mapping Service and assign it to the Ajax Adapter. |
|
| 1485 | + new Wordlift_Mapping_Ajax_Adapter( new Wordlift_Mapping_Service( Wordlift_Entity_Type_Service::get_instance() ) ); |
|
| 1486 | 1486 | |
| 1487 | - /* |
|
| 1487 | + /* |
|
| 1488 | 1488 | * Batch Operations. They're similar to Batch Actions but do not require working on post types. |
| 1489 | 1489 | * |
| 1490 | 1490 | * Eventually Batch Actions will become Batch Operations. |
| 1491 | 1491 | * |
| 1492 | 1492 | * @since 3.20.0 |
| 1493 | 1493 | */ |
| 1494 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/intf-wordlift-batch-operation.php'; |
|
| 1495 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/class-wordlift-batch-operation-ajax-adapter.php'; |
|
| 1496 | - /* |
|
| 1494 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/intf-wordlift-batch-operation.php'; |
|
| 1495 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/class-wordlift-batch-operation-ajax-adapter.php'; |
|
| 1496 | + /* |
|
| 1497 | 1497 | * Load the Mappings JSON-LD post processing. |
| 1498 | 1498 | * |
| 1499 | 1499 | * @since 3.25.0 |
| 1500 | 1500 | */ |
| 1501 | 1501 | |
| 1502 | - $mappings_dbo = new Mappings_DBO(); |
|
| 1503 | - $default_rule_validator = new Taxonomy_Rule_Validator(); |
|
| 1504 | - new Post_Type_Rule_Validator(); |
|
| 1505 | - // Taxonomy term rule validator for validating rules for term pages. |
|
| 1506 | - new Taxonomy_Term_Rule_Validator(); |
|
| 1507 | - new Post_Taxonomy_Term_Rule_Validator(); |
|
| 1508 | - $rule_validators_registry = new Rule_Validators_Registry( $default_rule_validator ); |
|
| 1509 | - $rule_groups_validator = new Rule_Groups_Validator( $rule_validators_registry ); |
|
| 1510 | - $mappings_validator = new Mappings_Validator( $mappings_dbo, $rule_groups_validator ); |
|
| 1511 | - |
|
| 1512 | - new Url_To_Entity_Transform_Function( $this->entity_uri_service ); |
|
| 1513 | - new Taxonomy_To_Terms_Transform_Function(); |
|
| 1514 | - new Post_Id_To_Entity_Transform_Function(); |
|
| 1515 | - $mappings_transform_functions_registry = new Mappings_Transform_Functions_Registry(); |
|
| 1516 | - |
|
| 1517 | - /** |
|
| 1518 | - * @since 3.27.1 |
|
| 1519 | - * Intiailize the acf group data formatter. |
|
| 1520 | - */ |
|
| 1521 | - new Acf_Group_Formatter(); |
|
| 1522 | - new Jsonld_Converter( $mappings_validator, $mappings_transform_functions_registry ); |
|
| 1523 | - |
|
| 1524 | - /** |
|
| 1525 | - * @since 3.26.0 |
|
| 1526 | - * Initialize the Faq JSON LD converter here - disabled. |
|
| 1527 | - */ |
|
| 1528 | - // new Faq_To_Jsonld_Converter(); |
|
| 1529 | - /* |
|
| 1502 | + $mappings_dbo = new Mappings_DBO(); |
|
| 1503 | + $default_rule_validator = new Taxonomy_Rule_Validator(); |
|
| 1504 | + new Post_Type_Rule_Validator(); |
|
| 1505 | + // Taxonomy term rule validator for validating rules for term pages. |
|
| 1506 | + new Taxonomy_Term_Rule_Validator(); |
|
| 1507 | + new Post_Taxonomy_Term_Rule_Validator(); |
|
| 1508 | + $rule_validators_registry = new Rule_Validators_Registry( $default_rule_validator ); |
|
| 1509 | + $rule_groups_validator = new Rule_Groups_Validator( $rule_validators_registry ); |
|
| 1510 | + $mappings_validator = new Mappings_Validator( $mappings_dbo, $rule_groups_validator ); |
|
| 1511 | + |
|
| 1512 | + new Url_To_Entity_Transform_Function( $this->entity_uri_service ); |
|
| 1513 | + new Taxonomy_To_Terms_Transform_Function(); |
|
| 1514 | + new Post_Id_To_Entity_Transform_Function(); |
|
| 1515 | + $mappings_transform_functions_registry = new Mappings_Transform_Functions_Registry(); |
|
| 1516 | + |
|
| 1517 | + /** |
|
| 1518 | + * @since 3.27.1 |
|
| 1519 | + * Intiailize the acf group data formatter. |
|
| 1520 | + */ |
|
| 1521 | + new Acf_Group_Formatter(); |
|
| 1522 | + new Jsonld_Converter( $mappings_validator, $mappings_transform_functions_registry ); |
|
| 1523 | + |
|
| 1524 | + /** |
|
| 1525 | + * @since 3.26.0 |
|
| 1526 | + * Initialize the Faq JSON LD converter here - disabled. |
|
| 1527 | + */ |
|
| 1528 | + // new Faq_To_Jsonld_Converter(); |
|
| 1529 | + /* |
|
| 1530 | 1530 | * Use the Templates Ajax Endpoint to load HTML templates for the legacy Angular app via admin-ajax.php |
| 1531 | 1531 | * end-point. |
| 1532 | 1532 | * |
| 1533 | 1533 | * @see https://github.com/insideout10/wordlift-plugin/issues/834 |
| 1534 | 1534 | * @since 3.24.4 |
| 1535 | 1535 | */ |
| 1536 | - new Templates_Ajax_Endpoint(); |
|
| 1537 | - // Call this static method to register FAQ routes to rest api - disabled |
|
| 1538 | - //Faq_Rest_Controller::register_routes(); |
|
| 1536 | + new Templates_Ajax_Endpoint(); |
|
| 1537 | + // Call this static method to register FAQ routes to rest api - disabled |
|
| 1538 | + //Faq_Rest_Controller::register_routes(); |
|
| 1539 | 1539 | |
| 1540 | - /* |
|
| 1540 | + /* |
|
| 1541 | 1541 | * Create a singleton for the Analysis_Response_Ops_Factory. |
| 1542 | 1542 | */ |
| 1543 | - $entity_helper = new Entity_Helper( $this->entity_uri_service, $this->entity_service ); |
|
| 1544 | - /** |
|
| 1545 | - * @since 3.32.0 |
|
| 1546 | - * Initialize a local entity provider which acts as an abstraction layer |
|
| 1547 | - * between the different types of objects in wordpress. |
|
| 1548 | - */ |
|
| 1549 | - $entity_provider_registry = new Entity_Provider_Registry(); |
|
| 1550 | - |
|
| 1551 | - /** |
|
| 1552 | - * @since 3.32.0 |
|
| 1553 | - * The post entity provider has the legacy code which provides the entity |
|
| 1554 | - * if the object is post {@link \Wordlift\Object_Type_Enum::POST} |
|
| 1555 | - */ |
|
| 1556 | - new Post_Entity_Provider( $this->entity_uri_service, |
|
| 1557 | - $this->entity_type_service, $this->storage_factory->post_images() ); |
|
| 1558 | - /** |
|
| 1559 | - * @since 3.32.0 |
|
| 1560 | - * The term entity provider provides the entity |
|
| 1561 | - * if the object is term {@link \Wordlift\Object_Type_Enum::POST} |
|
| 1562 | - */ |
|
| 1563 | - new Term_Entity_Provider(); |
|
| 1564 | - |
|
| 1565 | - new Analysis_Response_Ops_Factory( |
|
| 1566 | - $this->entity_uri_service, |
|
| 1567 | - $entity_helper, |
|
| 1568 | - $entity_provider_registry |
|
| 1569 | - ); |
|
| 1570 | - |
|
| 1571 | - /** WL Autocomplete. */ |
|
| 1572 | - $autocomplete_service = new All_Autocomplete_Service( array( |
|
| 1573 | - new Local_Autocomplete_Service(), |
|
| 1574 | - new Linked_Data_Autocomplete_Service( $this->configuration_service, $entity_helper, $this->entity_uri_service, $this->entity_service ), |
|
| 1575 | - ) ); |
|
| 1576 | - $this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $autocomplete_service ); |
|
| 1577 | - |
|
| 1578 | - /** |
|
| 1579 | - * @since 3.27.2 |
|
| 1580 | - * Integrate the recipe maker jsonld & set recipe |
|
| 1581 | - * as default entity type to the wprm_recipe CPT. |
|
| 1582 | - */ |
|
| 1583 | - new Recipe_Maker_Post_Type_Hook(); |
|
| 1584 | - $recipe_maker_validation_service = new Recipe_Maker_Validation_Service(); |
|
| 1585 | - new Recipe_Maker_Jsonld_Hook( $attachment_service, $recipe_maker_validation_service ); |
|
| 1586 | - new Recipe_Maker_After_Get_Jsonld_Hook( $recipe_maker_validation_service ); |
|
| 1587 | - new Recipe_Maker_Warning( $recipe_maker_validation_service ); |
|
| 1588 | - new Yoast_Jsonld( $recipe_maker_validation_service ); |
|
| 1589 | - |
|
| 1590 | - /** |
|
| 1591 | - * @since 3.27.4 |
|
| 1592 | - * Add the faq duplicate markup hook. |
|
| 1593 | - */ |
|
| 1594 | - new Faq_Duplicate_Markup_Remover(); |
|
| 1595 | - /** |
|
| 1596 | - * @since 3.27.8 |
|
| 1597 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1248 |
|
| 1598 | - */ |
|
| 1599 | - new Key_Validation_Notice( $this->key_validation_service, $this->configuration_service ); |
|
| 1600 | - /** |
|
| 1601 | - * @since 3.28.0 |
|
| 1602 | - * @see https://github.com/insideout10/wordlift-plugin/issues?q=assignee%3Anaveen17797+is%3Aopen |
|
| 1603 | - */ |
|
| 1604 | - new Entity_No_Index_Flag(); |
|
| 1605 | - |
|
| 1606 | - /** |
|
| 1607 | - * @since 3.29.0 |
|
| 1608 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1304 |
|
| 1609 | - */ |
|
| 1610 | - new Entity_Rest_Service( $this->entity_type_service ); |
|
| 1611 | - |
|
| 1612 | - /** |
|
| 1613 | - * Expand author in to references. |
|
| 1614 | - * @since 3.30.0 |
|
| 1615 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1318 |
|
| 1616 | - */ |
|
| 1617 | - |
|
| 1618 | - add_action( 'plugins_loaded', function () use ( $that ) { |
|
| 1619 | - |
|
| 1620 | - if ( apply_filters( 'wl_feature__enable__article-wrapper', false ) ) { |
|
| 1621 | - new Jsonld_Article_Wrapper( Wordlift_Post_To_Jsonld_Converter::get_instance(), $that->cached_postid_to_jsonld_converter ); |
|
| 1622 | - } |
|
| 1623 | - |
|
| 1624 | - if ( apply_filters( 'wl_feature__enable__match-terms', false ) ) { |
|
| 1625 | - $vocabulary_loader = new Vocabulary_Loader(); |
|
| 1626 | - $vocabulary_loader->init_vocabulary(); |
|
| 1627 | - } |
|
| 1628 | - |
|
| 1629 | - } ); |
|
| 1630 | - |
|
| 1631 | - /** |
|
| 1632 | - * @since 3.30.0 |
|
| 1633 | - * Add a checkbox to user option screen for wordlift admin. |
|
| 1634 | - */ |
|
| 1635 | - $wordlift_admin_checkbox = new Admin_User_Option(); |
|
| 1636 | - $wordlift_admin_checkbox->connect_hook(); |
|
| 1637 | - /** |
|
| 1638 | - * @since 3.31.0 |
|
| 1639 | - * Init loader class for videoobject. |
|
| 1640 | - */ |
|
| 1641 | - $videoobject_loader = new Loader(); |
|
| 1642 | - $videoobject_loader->init_feature(); |
|
| 1643 | - /** |
|
| 1644 | - * @since 3.31.5 |
|
| 1645 | - * Create configuration endpoint for webapp to configure. |
|
| 1646 | - */ |
|
| 1647 | - new Config( $this->admin_setup, $this->key_validation_service, $this->configuration_service ); |
|
| 1648 | - /** |
|
| 1649 | - * @since 3.31.7 |
|
| 1650 | - * Remove duplicate videoobject. |
|
| 1651 | - */ |
|
| 1652 | - new Videoobject_Duplicate_Remover(); |
|
| 1653 | - $synonym_loader = new \Wordlift\Synonym\Loader(); |
|
| 1654 | - $synonym_loader->init_feature(); |
|
| 1655 | - /** |
|
| 1656 | - * @since 3.32.0 |
|
| 1657 | - * Create loader for vocabulary terms. |
|
| 1658 | - */ |
|
| 1659 | - $vocabulary_terms_loader = new Vocabulary_Terms_Loader( $this->entity_type_service, $property_getter ); |
|
| 1660 | - $vocabulary_terms_loader->init_feature(); |
|
| 1661 | - |
|
| 1662 | - new Entity_Type_Change_Handler( |
|
| 1663 | - $this->entity_service, |
|
| 1664 | - $this->entity_type_service |
|
| 1665 | - ); |
|
| 1666 | - |
|
| 1667 | - new Entity_Type_Setter(); |
|
| 1668 | - $no_editor_analysis_loader = new \Wordlift\No_Editor_Analysis\Loader(); |
|
| 1669 | - $no_editor_analysis_loader->init_feature(); |
|
| 1670 | - } |
|
| 1671 | - |
|
| 1672 | - /** |
|
| 1673 | - * Define the locale for this plugin for internationalization. |
|
| 1674 | - * |
|
| 1675 | - * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 1676 | - * with WordPress. |
|
| 1677 | - * |
|
| 1678 | - * @since 1.0.0 |
|
| 1679 | - * @access private |
|
| 1680 | - */ |
|
| 1681 | - private function set_locale() { |
|
| 1682 | - |
|
| 1683 | - $plugin_i18n = new Wordlift_i18n(); |
|
| 1684 | - $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 1685 | - |
|
| 1686 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 1687 | - |
|
| 1688 | - } |
|
| 1689 | - |
|
| 1690 | - /** |
|
| 1691 | - * Register all of the hooks related to the admin area functionality |
|
| 1692 | - * of the plugin. |
|
| 1693 | - * |
|
| 1694 | - * @since 1.0.0 |
|
| 1695 | - * @access private |
|
| 1696 | - */ |
|
| 1697 | - private function define_admin_hooks() { |
|
| 1698 | - $that = $this; |
|
| 1699 | - $plugin_admin = new Wordlift_Admin( |
|
| 1700 | - $this->get_plugin_name(), |
|
| 1701 | - $this->get_version(), |
|
| 1702 | - $this->configuration_service, |
|
| 1703 | - $this->notice_service, |
|
| 1704 | - $this->user_service |
|
| 1705 | - ); |
|
| 1706 | - |
|
| 1707 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 1708 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts', 11 ); |
|
| 1709 | - |
|
| 1710 | - // Hook the init action to taxonomy services. |
|
| 1711 | - $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 1712 | - $this->loader->add_action( 'init', $this->entity_types_taxonomy_service, 'init', 0 ); |
|
| 1713 | - |
|
| 1714 | - // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 1715 | - $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 1716 | - |
|
| 1717 | - // Hook the added_post_meta action to the Thumbnail service. |
|
| 1718 | - $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1719 | - |
|
| 1720 | - // Hook the updated_post_meta action to the Thumbnail service. |
|
| 1721 | - $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1722 | - |
|
| 1723 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1724 | - $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1725 | - |
|
| 1726 | - // Register custom allowed redirect hosts. |
|
| 1727 | - $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 1728 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1729 | - $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 1730 | - |
|
| 1731 | - /* |
|
| 1543 | + $entity_helper = new Entity_Helper( $this->entity_uri_service, $this->entity_service ); |
|
| 1544 | + /** |
|
| 1545 | + * @since 3.32.0 |
|
| 1546 | + * Initialize a local entity provider which acts as an abstraction layer |
|
| 1547 | + * between the different types of objects in wordpress. |
|
| 1548 | + */ |
|
| 1549 | + $entity_provider_registry = new Entity_Provider_Registry(); |
|
| 1550 | + |
|
| 1551 | + /** |
|
| 1552 | + * @since 3.32.0 |
|
| 1553 | + * The post entity provider has the legacy code which provides the entity |
|
| 1554 | + * if the object is post {@link \Wordlift\Object_Type_Enum::POST} |
|
| 1555 | + */ |
|
| 1556 | + new Post_Entity_Provider( $this->entity_uri_service, |
|
| 1557 | + $this->entity_type_service, $this->storage_factory->post_images() ); |
|
| 1558 | + /** |
|
| 1559 | + * @since 3.32.0 |
|
| 1560 | + * The term entity provider provides the entity |
|
| 1561 | + * if the object is term {@link \Wordlift\Object_Type_Enum::POST} |
|
| 1562 | + */ |
|
| 1563 | + new Term_Entity_Provider(); |
|
| 1564 | + |
|
| 1565 | + new Analysis_Response_Ops_Factory( |
|
| 1566 | + $this->entity_uri_service, |
|
| 1567 | + $entity_helper, |
|
| 1568 | + $entity_provider_registry |
|
| 1569 | + ); |
|
| 1570 | + |
|
| 1571 | + /** WL Autocomplete. */ |
|
| 1572 | + $autocomplete_service = new All_Autocomplete_Service( array( |
|
| 1573 | + new Local_Autocomplete_Service(), |
|
| 1574 | + new Linked_Data_Autocomplete_Service( $this->configuration_service, $entity_helper, $this->entity_uri_service, $this->entity_service ), |
|
| 1575 | + ) ); |
|
| 1576 | + $this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $autocomplete_service ); |
|
| 1577 | + |
|
| 1578 | + /** |
|
| 1579 | + * @since 3.27.2 |
|
| 1580 | + * Integrate the recipe maker jsonld & set recipe |
|
| 1581 | + * as default entity type to the wprm_recipe CPT. |
|
| 1582 | + */ |
|
| 1583 | + new Recipe_Maker_Post_Type_Hook(); |
|
| 1584 | + $recipe_maker_validation_service = new Recipe_Maker_Validation_Service(); |
|
| 1585 | + new Recipe_Maker_Jsonld_Hook( $attachment_service, $recipe_maker_validation_service ); |
|
| 1586 | + new Recipe_Maker_After_Get_Jsonld_Hook( $recipe_maker_validation_service ); |
|
| 1587 | + new Recipe_Maker_Warning( $recipe_maker_validation_service ); |
|
| 1588 | + new Yoast_Jsonld( $recipe_maker_validation_service ); |
|
| 1589 | + |
|
| 1590 | + /** |
|
| 1591 | + * @since 3.27.4 |
|
| 1592 | + * Add the faq duplicate markup hook. |
|
| 1593 | + */ |
|
| 1594 | + new Faq_Duplicate_Markup_Remover(); |
|
| 1595 | + /** |
|
| 1596 | + * @since 3.27.8 |
|
| 1597 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1248 |
|
| 1598 | + */ |
|
| 1599 | + new Key_Validation_Notice( $this->key_validation_service, $this->configuration_service ); |
|
| 1600 | + /** |
|
| 1601 | + * @since 3.28.0 |
|
| 1602 | + * @see https://github.com/insideout10/wordlift-plugin/issues?q=assignee%3Anaveen17797+is%3Aopen |
|
| 1603 | + */ |
|
| 1604 | + new Entity_No_Index_Flag(); |
|
| 1605 | + |
|
| 1606 | + /** |
|
| 1607 | + * @since 3.29.0 |
|
| 1608 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1304 |
|
| 1609 | + */ |
|
| 1610 | + new Entity_Rest_Service( $this->entity_type_service ); |
|
| 1611 | + |
|
| 1612 | + /** |
|
| 1613 | + * Expand author in to references. |
|
| 1614 | + * @since 3.30.0 |
|
| 1615 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1318 |
|
| 1616 | + */ |
|
| 1617 | + |
|
| 1618 | + add_action( 'plugins_loaded', function () use ( $that ) { |
|
| 1619 | + |
|
| 1620 | + if ( apply_filters( 'wl_feature__enable__article-wrapper', false ) ) { |
|
| 1621 | + new Jsonld_Article_Wrapper( Wordlift_Post_To_Jsonld_Converter::get_instance(), $that->cached_postid_to_jsonld_converter ); |
|
| 1622 | + } |
|
| 1623 | + |
|
| 1624 | + if ( apply_filters( 'wl_feature__enable__match-terms', false ) ) { |
|
| 1625 | + $vocabulary_loader = new Vocabulary_Loader(); |
|
| 1626 | + $vocabulary_loader->init_vocabulary(); |
|
| 1627 | + } |
|
| 1628 | + |
|
| 1629 | + } ); |
|
| 1630 | + |
|
| 1631 | + /** |
|
| 1632 | + * @since 3.30.0 |
|
| 1633 | + * Add a checkbox to user option screen for wordlift admin. |
|
| 1634 | + */ |
|
| 1635 | + $wordlift_admin_checkbox = new Admin_User_Option(); |
|
| 1636 | + $wordlift_admin_checkbox->connect_hook(); |
|
| 1637 | + /** |
|
| 1638 | + * @since 3.31.0 |
|
| 1639 | + * Init loader class for videoobject. |
|
| 1640 | + */ |
|
| 1641 | + $videoobject_loader = new Loader(); |
|
| 1642 | + $videoobject_loader->init_feature(); |
|
| 1643 | + /** |
|
| 1644 | + * @since 3.31.5 |
|
| 1645 | + * Create configuration endpoint for webapp to configure. |
|
| 1646 | + */ |
|
| 1647 | + new Config( $this->admin_setup, $this->key_validation_service, $this->configuration_service ); |
|
| 1648 | + /** |
|
| 1649 | + * @since 3.31.7 |
|
| 1650 | + * Remove duplicate videoobject. |
|
| 1651 | + */ |
|
| 1652 | + new Videoobject_Duplicate_Remover(); |
|
| 1653 | + $synonym_loader = new \Wordlift\Synonym\Loader(); |
|
| 1654 | + $synonym_loader->init_feature(); |
|
| 1655 | + /** |
|
| 1656 | + * @since 3.32.0 |
|
| 1657 | + * Create loader for vocabulary terms. |
|
| 1658 | + */ |
|
| 1659 | + $vocabulary_terms_loader = new Vocabulary_Terms_Loader( $this->entity_type_service, $property_getter ); |
|
| 1660 | + $vocabulary_terms_loader->init_feature(); |
|
| 1661 | + |
|
| 1662 | + new Entity_Type_Change_Handler( |
|
| 1663 | + $this->entity_service, |
|
| 1664 | + $this->entity_type_service |
|
| 1665 | + ); |
|
| 1666 | + |
|
| 1667 | + new Entity_Type_Setter(); |
|
| 1668 | + $no_editor_analysis_loader = new \Wordlift\No_Editor_Analysis\Loader(); |
|
| 1669 | + $no_editor_analysis_loader->init_feature(); |
|
| 1670 | + } |
|
| 1671 | + |
|
| 1672 | + /** |
|
| 1673 | + * Define the locale for this plugin for internationalization. |
|
| 1674 | + * |
|
| 1675 | + * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 1676 | + * with WordPress. |
|
| 1677 | + * |
|
| 1678 | + * @since 1.0.0 |
|
| 1679 | + * @access private |
|
| 1680 | + */ |
|
| 1681 | + private function set_locale() { |
|
| 1682 | + |
|
| 1683 | + $plugin_i18n = new Wordlift_i18n(); |
|
| 1684 | + $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 1685 | + |
|
| 1686 | + $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 1687 | + |
|
| 1688 | + } |
|
| 1689 | + |
|
| 1690 | + /** |
|
| 1691 | + * Register all of the hooks related to the admin area functionality |
|
| 1692 | + * of the plugin. |
|
| 1693 | + * |
|
| 1694 | + * @since 1.0.0 |
|
| 1695 | + * @access private |
|
| 1696 | + */ |
|
| 1697 | + private function define_admin_hooks() { |
|
| 1698 | + $that = $this; |
|
| 1699 | + $plugin_admin = new Wordlift_Admin( |
|
| 1700 | + $this->get_plugin_name(), |
|
| 1701 | + $this->get_version(), |
|
| 1702 | + $this->configuration_service, |
|
| 1703 | + $this->notice_service, |
|
| 1704 | + $this->user_service |
|
| 1705 | + ); |
|
| 1706 | + |
|
| 1707 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 1708 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts', 11 ); |
|
| 1709 | + |
|
| 1710 | + // Hook the init action to taxonomy services. |
|
| 1711 | + $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 1712 | + $this->loader->add_action( 'init', $this->entity_types_taxonomy_service, 'init', 0 ); |
|
| 1713 | + |
|
| 1714 | + // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 1715 | + $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 1716 | + |
|
| 1717 | + // Hook the added_post_meta action to the Thumbnail service. |
|
| 1718 | + $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1719 | + |
|
| 1720 | + // Hook the updated_post_meta action to the Thumbnail service. |
|
| 1721 | + $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1722 | + |
|
| 1723 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1724 | + $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1725 | + |
|
| 1726 | + // Register custom allowed redirect hosts. |
|
| 1727 | + $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 1728 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1729 | + $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 1730 | + |
|
| 1731 | + /* |
|
| 1732 | 1732 | * The old dashboard is replaced with dashboard v2. |
| 1733 | 1733 | * |
| 1734 | 1734 | * The old dashboard service is still loaded because its functions are used. |
@@ -1737,391 +1737,391 @@ discard block |
||
| 1737 | 1737 | * |
| 1738 | 1738 | * @since 3.20.0 |
| 1739 | 1739 | */ |
| 1740 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1741 | - // $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 1742 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1743 | - // $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 1744 | - |
|
| 1745 | - // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 1746 | - // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 1747 | - $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 1748 | - $this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 ); |
|
| 1749 | - |
|
| 1750 | - $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 1751 | - $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' ); |
|
| 1752 | - |
|
| 1753 | - // Entity listing customization (wp-admin/edit.php) |
|
| 1754 | - // Add custom columns. |
|
| 1755 | - $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 1756 | - // no explicit entity as it prevents handling of other post types. |
|
| 1757 | - $this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 1758 | - // Add 4W selection. |
|
| 1759 | - $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 1760 | - $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 1761 | - $this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' ); |
|
| 1762 | - $this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' ); |
|
| 1763 | - |
|
| 1764 | - /* |
|
| 1740 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1741 | + // $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 1742 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1743 | + // $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 1744 | + |
|
| 1745 | + // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 1746 | + // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 1747 | + $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 1748 | + $this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 ); |
|
| 1749 | + |
|
| 1750 | + $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 1751 | + $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' ); |
|
| 1752 | + |
|
| 1753 | + // Entity listing customization (wp-admin/edit.php) |
|
| 1754 | + // Add custom columns. |
|
| 1755 | + $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 1756 | + // no explicit entity as it prevents handling of other post types. |
|
| 1757 | + $this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 1758 | + // Add 4W selection. |
|
| 1759 | + $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 1760 | + $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 1761 | + $this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' ); |
|
| 1762 | + $this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' ); |
|
| 1763 | + |
|
| 1764 | + /* |
|
| 1765 | 1765 | * If `All Entity Types` is disable, use the radio button Walker. |
| 1766 | 1766 | * |
| 1767 | 1767 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
| 1768 | 1768 | */ |
| 1769 | - if ( ! WL_ALL_ENTITY_TYPES ) { |
|
| 1770 | - $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 1771 | - } |
|
| 1772 | - |
|
| 1773 | - // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 1774 | - // entities. |
|
| 1775 | - $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 1776 | - |
|
| 1777 | - // Filter imported post meta. |
|
| 1778 | - $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 1779 | - |
|
| 1780 | - // Notify the import service when an import starts and ends. |
|
| 1781 | - $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 1782 | - $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 1783 | - |
|
| 1784 | - // Hook the AJAX wl_rebuild action to the Rebuild Service. |
|
| 1785 | - $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 1786 | - $this->loader->add_action( 'wp_ajax_wl_rebuild_references', $this->reference_rebuild_service, 'rebuild' ); |
|
| 1787 | - |
|
| 1788 | - /** |
|
| 1789 | - * Filter: wl_feature__enable__settings-download. |
|
| 1790 | - * |
|
| 1791 | - * @param bool whether the screens needed to be registered, defaults to true. |
|
| 1792 | - * |
|
| 1793 | - * @return bool |
|
| 1794 | - * @since 3.27.6 |
|
| 1795 | - */ |
|
| 1796 | - $this->features_registry->register_feature_from_slug( 'settings-download', true, array( |
|
| 1797 | - $this, |
|
| 1798 | - 'register_screens' |
|
| 1799 | - ) ); |
|
| 1800 | - |
|
| 1801 | - |
|
| 1802 | - // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
|
| 1803 | - $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 1804 | - |
|
| 1805 | - // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1806 | - $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1807 | - $this->loader->add_action( 'admin_post_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1808 | - $this->loader->add_action( 'admin_post_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1809 | - |
|
| 1810 | - // Hook the AJAX wl_validate_key action to the Key Validation service. |
|
| 1811 | - $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' ); |
|
| 1812 | - |
|
| 1813 | - // Hook the AJAX wl_update_country_options action to the countries. |
|
| 1814 | - $this->loader->add_action( 'wp_ajax_wl_update_country_options', $this->country_select_element, 'get_options_html' ); |
|
| 1815 | - |
|
| 1816 | - // Hook the `admin_init` function to the Admin Setup. |
|
| 1817 | - $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' ); |
|
| 1818 | - |
|
| 1819 | - // Hook the admin_init to the settings page. |
|
| 1820 | - $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' ); |
|
| 1821 | - $this->loader->add_action( 'admin_init', $this->analytics_settings_page, 'admin_init' ); |
|
| 1822 | - |
|
| 1823 | - $this->loader->add_filter( 'admin_post_thumbnail_html', $this->publisher_service, 'add_featured_image_instruction' ); |
|
| 1824 | - |
|
| 1825 | - // Hook the menu creation on the general wordlift menu creation. |
|
| 1826 | - /** |
|
| 1827 | - * Filter: wl_feature__enable__screens. |
|
| 1828 | - * |
|
| 1829 | - * @param bool whether the screens needed to be registered, defaults to true. |
|
| 1830 | - * |
|
| 1831 | - * @return bool |
|
| 1832 | - * @since 3.27.6 |
|
| 1833 | - * |
|
| 1834 | - * Since 3.30.0 this feature is registered using registry. |
|
| 1835 | - */ |
|
| 1836 | - add_action( 'plugins_loaded', function () use ( $that ) { |
|
| 1837 | - if ( apply_filters( 'wl_feature__enable__settings-screen', true ) || Admin_User_Option::is_wordlift_admin() ) { |
|
| 1838 | - add_action( 'wl_admin_menu', array( $that->settings_page, 'admin_menu' ), 10, 2 ); |
|
| 1839 | - } |
|
| 1840 | - } ); |
|
| 1841 | - |
|
| 1842 | - // Hook key update. |
|
| 1843 | - $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 ); |
|
| 1844 | - $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 ); |
|
| 1845 | - |
|
| 1846 | - // Add additional action links to the WordLift plugin in the plugins page. |
|
| 1847 | - $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1848 | - |
|
| 1849 | - /* |
|
| 1769 | + if ( ! WL_ALL_ENTITY_TYPES ) { |
|
| 1770 | + $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 1771 | + } |
|
| 1772 | + |
|
| 1773 | + // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 1774 | + // entities. |
|
| 1775 | + $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 1776 | + |
|
| 1777 | + // Filter imported post meta. |
|
| 1778 | + $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 1779 | + |
|
| 1780 | + // Notify the import service when an import starts and ends. |
|
| 1781 | + $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 1782 | + $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 1783 | + |
|
| 1784 | + // Hook the AJAX wl_rebuild action to the Rebuild Service. |
|
| 1785 | + $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 1786 | + $this->loader->add_action( 'wp_ajax_wl_rebuild_references', $this->reference_rebuild_service, 'rebuild' ); |
|
| 1787 | + |
|
| 1788 | + /** |
|
| 1789 | + * Filter: wl_feature__enable__settings-download. |
|
| 1790 | + * |
|
| 1791 | + * @param bool whether the screens needed to be registered, defaults to true. |
|
| 1792 | + * |
|
| 1793 | + * @return bool |
|
| 1794 | + * @since 3.27.6 |
|
| 1795 | + */ |
|
| 1796 | + $this->features_registry->register_feature_from_slug( 'settings-download', true, array( |
|
| 1797 | + $this, |
|
| 1798 | + 'register_screens' |
|
| 1799 | + ) ); |
|
| 1800 | + |
|
| 1801 | + |
|
| 1802 | + // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
|
| 1803 | + $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 1804 | + |
|
| 1805 | + // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1806 | + $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1807 | + $this->loader->add_action( 'admin_post_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1808 | + $this->loader->add_action( 'admin_post_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1809 | + |
|
| 1810 | + // Hook the AJAX wl_validate_key action to the Key Validation service. |
|
| 1811 | + $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' ); |
|
| 1812 | + |
|
| 1813 | + // Hook the AJAX wl_update_country_options action to the countries. |
|
| 1814 | + $this->loader->add_action( 'wp_ajax_wl_update_country_options', $this->country_select_element, 'get_options_html' ); |
|
| 1815 | + |
|
| 1816 | + // Hook the `admin_init` function to the Admin Setup. |
|
| 1817 | + $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' ); |
|
| 1818 | + |
|
| 1819 | + // Hook the admin_init to the settings page. |
|
| 1820 | + $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' ); |
|
| 1821 | + $this->loader->add_action( 'admin_init', $this->analytics_settings_page, 'admin_init' ); |
|
| 1822 | + |
|
| 1823 | + $this->loader->add_filter( 'admin_post_thumbnail_html', $this->publisher_service, 'add_featured_image_instruction' ); |
|
| 1824 | + |
|
| 1825 | + // Hook the menu creation on the general wordlift menu creation. |
|
| 1826 | + /** |
|
| 1827 | + * Filter: wl_feature__enable__screens. |
|
| 1828 | + * |
|
| 1829 | + * @param bool whether the screens needed to be registered, defaults to true. |
|
| 1830 | + * |
|
| 1831 | + * @return bool |
|
| 1832 | + * @since 3.27.6 |
|
| 1833 | + * |
|
| 1834 | + * Since 3.30.0 this feature is registered using registry. |
|
| 1835 | + */ |
|
| 1836 | + add_action( 'plugins_loaded', function () use ( $that ) { |
|
| 1837 | + if ( apply_filters( 'wl_feature__enable__settings-screen', true ) || Admin_User_Option::is_wordlift_admin() ) { |
|
| 1838 | + add_action( 'wl_admin_menu', array( $that->settings_page, 'admin_menu' ), 10, 2 ); |
|
| 1839 | + } |
|
| 1840 | + } ); |
|
| 1841 | + |
|
| 1842 | + // Hook key update. |
|
| 1843 | + $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 ); |
|
| 1844 | + $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 ); |
|
| 1845 | + |
|
| 1846 | + // Add additional action links to the WordLift plugin in the plugins page. |
|
| 1847 | + $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1848 | + |
|
| 1849 | + /* |
|
| 1850 | 1850 | * Remove the Analytics Settings link from the plugin page. |
| 1851 | 1851 | * |
| 1852 | 1852 | * @see https://github.com/insideout10/wordlift-plugin/issues/932 |
| 1853 | 1853 | * @since 3.21.1 |
| 1854 | 1854 | */ |
| 1855 | - // $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->analytics_settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1856 | - |
|
| 1857 | - // Hook the AJAX `wl_publisher` action name. |
|
| 1858 | - $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' ); |
|
| 1859 | - |
|
| 1860 | - // Hook row actions for the entity type list admin. |
|
| 1861 | - $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 ); |
|
| 1862 | - |
|
| 1863 | - /** Ajax actions. */ |
|
| 1864 | - $this->loader->add_action( 'wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export' ); |
|
| 1865 | - |
|
| 1866 | - // Hook capabilities manipulation to allow access to entity type admin |
|
| 1867 | - // page on WordPress versions before 4.7. |
|
| 1868 | - global $wp_version; |
|
| 1869 | - if ( version_compare( $wp_version, '4.7', '<' ) ) { |
|
| 1870 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 ); |
|
| 1871 | - } |
|
| 1872 | - |
|
| 1873 | - $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1874 | - |
|
| 1875 | - /** Adapters. */ |
|
| 1876 | - $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 ); |
|
| 1877 | - /** |
|
| 1878 | - * Disabling Faq temporarily. |
|
| 1879 | - * Load the tinymce editor button on the tool bar. |
|
| 1880 | - * @since 3.26.0 |
|
| 1881 | - */ |
|
| 1882 | - //$this->loader->add_filter( 'tiny_mce_before_init', $this->faq_tinymce_adapter, 'register_custom_tags' ); |
|
| 1883 | - //$this->loader->add_filter( 'mce_buttons', $this->faq_tinymce_adapter, 'register_faq_toolbar_button', 10, 1 ); |
|
| 1884 | - //$this->loader->add_filter( 'mce_external_plugins', $this->faq_tinymce_adapter, 'register_faq_tinymce_plugin', 10, 1 ); |
|
| 1885 | - |
|
| 1886 | - |
|
| 1887 | - $this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all' ); |
|
| 1888 | - $this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' ); |
|
| 1889 | - $this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' ); |
|
| 1890 | - /** |
|
| 1891 | - * @since 3.26.0 |
|
| 1892 | - */ |
|
| 1893 | - $excerpt_adapter = new Post_Excerpt_Meta_Box_Adapter(); |
|
| 1894 | - $this->loader->add_action( 'do_meta_boxes', $excerpt_adapter, 'replace_post_excerpt_meta_box' ); |
|
| 1895 | - // Adding Rest route for the post excerpt |
|
| 1896 | - Post_Excerpt_Rest_Controller::register_routes(); |
|
| 1897 | - |
|
| 1898 | - $this->loader->add_action( 'update_user_metadata', $this->user_service, 'update_user_metadata', 10, 5 ); |
|
| 1899 | - $this->loader->add_action( 'delete_user_metadata', $this->user_service, 'delete_user_metadata', 10, 5 ); |
|
| 1900 | - |
|
| 1901 | - // Handle the autocomplete request. |
|
| 1902 | - add_action( 'wp_ajax_wl_autocomplete', array( |
|
| 1903 | - $this->autocomplete_adapter, |
|
| 1904 | - 'wl_autocomplete', |
|
| 1905 | - ) ); |
|
| 1906 | - add_action( 'wp_ajax_nopriv_wl_autocomplete', array( |
|
| 1907 | - $this->autocomplete_adapter, |
|
| 1908 | - 'wl_autocomplete', |
|
| 1909 | - ) ); |
|
| 1910 | - |
|
| 1911 | - // Hooks to restrict multisite super admin from manipulating entity types. |
|
| 1912 | - if ( is_multisite() ) { |
|
| 1913 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 ); |
|
| 1914 | - } |
|
| 1915 | - |
|
| 1916 | - $deactivator_feedback = new Wordlift_Deactivator_Feedback( $this->configuration_service ); |
|
| 1917 | - |
|
| 1918 | - add_action( 'admin_footer', array( $deactivator_feedback, 'render_feedback_popup' ) ); |
|
| 1919 | - add_action( 'admin_enqueue_scripts', array( $deactivator_feedback, 'enqueue_popup_scripts' ) ); |
|
| 1920 | - add_action( 'wp_ajax_wl_deactivation_feedback', array( $deactivator_feedback, 'wl_deactivation_feedback' ) ); |
|
| 1921 | - |
|
| 1922 | - /** |
|
| 1923 | - * Always allow the `wordlift/classification` block. |
|
| 1924 | - * |
|
| 1925 | - * @since 3.23.0 |
|
| 1926 | - */ |
|
| 1927 | - add_filter( 'allowed_block_types', function ( $value ) { |
|
| 1928 | - |
|
| 1929 | - if ( true === $value ) { |
|
| 1930 | - return $value; |
|
| 1931 | - } |
|
| 1932 | - |
|
| 1933 | - return array_merge( (array) $value, array( 'wordlift/classification' ) ); |
|
| 1934 | - }, PHP_INT_MAX ); |
|
| 1935 | - |
|
| 1936 | - /** |
|
| 1937 | - * @since 3.27.7 |
|
| 1938 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
| 1939 | - */ |
|
| 1940 | - new Top_Entities(); |
|
| 1941 | - } |
|
| 1942 | - |
|
| 1943 | - /** |
|
| 1944 | - * Register all of the hooks related to the public-facing functionality |
|
| 1945 | - * of the plugin. |
|
| 1946 | - * |
|
| 1947 | - * @since 1.0.0 |
|
| 1948 | - * @access private |
|
| 1949 | - */ |
|
| 1950 | - private function define_public_hooks() { |
|
| 1951 | - |
|
| 1952 | - $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 1953 | - |
|
| 1954 | - // Register the entity post type. |
|
| 1955 | - $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' ); |
|
| 1956 | - |
|
| 1957 | - // Bind the link generation and handling hooks to the entity link service. |
|
| 1958 | - $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 1959 | - $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 ); |
|
| 1960 | - // $this->loader->add_filter( 'wp_unique_post_slug_is_bad_flat_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_flat_slug', 10, 3 ); |
|
| 1961 | - // $this->loader->add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_hierarchical_slug', 10, 4 ); |
|
| 1962 | - |
|
| 1963 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 1964 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 1965 | - $this->loader->add_action( 'wp_enqueue_scripts', $this->context_cards_service, 'enqueue_scripts' ); |
|
| 1966 | - |
|
| 1967 | - // Registering Faq_Content_Filter service used for removing faq question and answer tags from the html. |
|
| 1968 | - $this->loader->add_filter( 'the_content', $this->faq_content_filter_service, 'remove_all_faq_question_and_answer_tags' ); |
|
| 1969 | - // Hook the content filter service to add entity links. |
|
| 1970 | - if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) { |
|
| 1971 | - $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' ); |
|
| 1972 | - } |
|
| 1973 | - |
|
| 1974 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1975 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1976 | - |
|
| 1977 | - // Hook the ShareThis service. |
|
| 1978 | - $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 1979 | - $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 1980 | - |
|
| 1981 | - // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1982 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1983 | - |
|
| 1984 | - // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service` |
|
| 1985 | - // in order to tweak WP's `WP_Query` to include entities in queries related |
|
| 1986 | - // to categories. |
|
| 1987 | - $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 ); |
|
| 1988 | - |
|
| 1989 | - /* |
|
| 1855 | + // $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->analytics_settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1856 | + |
|
| 1857 | + // Hook the AJAX `wl_publisher` action name. |
|
| 1858 | + $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' ); |
|
| 1859 | + |
|
| 1860 | + // Hook row actions for the entity type list admin. |
|
| 1861 | + $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 ); |
|
| 1862 | + |
|
| 1863 | + /** Ajax actions. */ |
|
| 1864 | + $this->loader->add_action( 'wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export' ); |
|
| 1865 | + |
|
| 1866 | + // Hook capabilities manipulation to allow access to entity type admin |
|
| 1867 | + // page on WordPress versions before 4.7. |
|
| 1868 | + global $wp_version; |
|
| 1869 | + if ( version_compare( $wp_version, '4.7', '<' ) ) { |
|
| 1870 | + $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 ); |
|
| 1871 | + } |
|
| 1872 | + |
|
| 1873 | + $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1874 | + |
|
| 1875 | + /** Adapters. */ |
|
| 1876 | + $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 ); |
|
| 1877 | + /** |
|
| 1878 | + * Disabling Faq temporarily. |
|
| 1879 | + * Load the tinymce editor button on the tool bar. |
|
| 1880 | + * @since 3.26.0 |
|
| 1881 | + */ |
|
| 1882 | + //$this->loader->add_filter( 'tiny_mce_before_init', $this->faq_tinymce_adapter, 'register_custom_tags' ); |
|
| 1883 | + //$this->loader->add_filter( 'mce_buttons', $this->faq_tinymce_adapter, 'register_faq_toolbar_button', 10, 1 ); |
|
| 1884 | + //$this->loader->add_filter( 'mce_external_plugins', $this->faq_tinymce_adapter, 'register_faq_tinymce_plugin', 10, 1 ); |
|
| 1885 | + |
|
| 1886 | + |
|
| 1887 | + $this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all' ); |
|
| 1888 | + $this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' ); |
|
| 1889 | + $this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' ); |
|
| 1890 | + /** |
|
| 1891 | + * @since 3.26.0 |
|
| 1892 | + */ |
|
| 1893 | + $excerpt_adapter = new Post_Excerpt_Meta_Box_Adapter(); |
|
| 1894 | + $this->loader->add_action( 'do_meta_boxes', $excerpt_adapter, 'replace_post_excerpt_meta_box' ); |
|
| 1895 | + // Adding Rest route for the post excerpt |
|
| 1896 | + Post_Excerpt_Rest_Controller::register_routes(); |
|
| 1897 | + |
|
| 1898 | + $this->loader->add_action( 'update_user_metadata', $this->user_service, 'update_user_metadata', 10, 5 ); |
|
| 1899 | + $this->loader->add_action( 'delete_user_metadata', $this->user_service, 'delete_user_metadata', 10, 5 ); |
|
| 1900 | + |
|
| 1901 | + // Handle the autocomplete request. |
|
| 1902 | + add_action( 'wp_ajax_wl_autocomplete', array( |
|
| 1903 | + $this->autocomplete_adapter, |
|
| 1904 | + 'wl_autocomplete', |
|
| 1905 | + ) ); |
|
| 1906 | + add_action( 'wp_ajax_nopriv_wl_autocomplete', array( |
|
| 1907 | + $this->autocomplete_adapter, |
|
| 1908 | + 'wl_autocomplete', |
|
| 1909 | + ) ); |
|
| 1910 | + |
|
| 1911 | + // Hooks to restrict multisite super admin from manipulating entity types. |
|
| 1912 | + if ( is_multisite() ) { |
|
| 1913 | + $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 ); |
|
| 1914 | + } |
|
| 1915 | + |
|
| 1916 | + $deactivator_feedback = new Wordlift_Deactivator_Feedback( $this->configuration_service ); |
|
| 1917 | + |
|
| 1918 | + add_action( 'admin_footer', array( $deactivator_feedback, 'render_feedback_popup' ) ); |
|
| 1919 | + add_action( 'admin_enqueue_scripts', array( $deactivator_feedback, 'enqueue_popup_scripts' ) ); |
|
| 1920 | + add_action( 'wp_ajax_wl_deactivation_feedback', array( $deactivator_feedback, 'wl_deactivation_feedback' ) ); |
|
| 1921 | + |
|
| 1922 | + /** |
|
| 1923 | + * Always allow the `wordlift/classification` block. |
|
| 1924 | + * |
|
| 1925 | + * @since 3.23.0 |
|
| 1926 | + */ |
|
| 1927 | + add_filter( 'allowed_block_types', function ( $value ) { |
|
| 1928 | + |
|
| 1929 | + if ( true === $value ) { |
|
| 1930 | + return $value; |
|
| 1931 | + } |
|
| 1932 | + |
|
| 1933 | + return array_merge( (array) $value, array( 'wordlift/classification' ) ); |
|
| 1934 | + }, PHP_INT_MAX ); |
|
| 1935 | + |
|
| 1936 | + /** |
|
| 1937 | + * @since 3.27.7 |
|
| 1938 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
| 1939 | + */ |
|
| 1940 | + new Top_Entities(); |
|
| 1941 | + } |
|
| 1942 | + |
|
| 1943 | + /** |
|
| 1944 | + * Register all of the hooks related to the public-facing functionality |
|
| 1945 | + * of the plugin. |
|
| 1946 | + * |
|
| 1947 | + * @since 1.0.0 |
|
| 1948 | + * @access private |
|
| 1949 | + */ |
|
| 1950 | + private function define_public_hooks() { |
|
| 1951 | + |
|
| 1952 | + $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 1953 | + |
|
| 1954 | + // Register the entity post type. |
|
| 1955 | + $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' ); |
|
| 1956 | + |
|
| 1957 | + // Bind the link generation and handling hooks to the entity link service. |
|
| 1958 | + $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 1959 | + $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 ); |
|
| 1960 | + // $this->loader->add_filter( 'wp_unique_post_slug_is_bad_flat_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_flat_slug', 10, 3 ); |
|
| 1961 | + // $this->loader->add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_hierarchical_slug', 10, 4 ); |
|
| 1962 | + |
|
| 1963 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 1964 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 1965 | + $this->loader->add_action( 'wp_enqueue_scripts', $this->context_cards_service, 'enqueue_scripts' ); |
|
| 1966 | + |
|
| 1967 | + // Registering Faq_Content_Filter service used for removing faq question and answer tags from the html. |
|
| 1968 | + $this->loader->add_filter( 'the_content', $this->faq_content_filter_service, 'remove_all_faq_question_and_answer_tags' ); |
|
| 1969 | + // Hook the content filter service to add entity links. |
|
| 1970 | + if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) { |
|
| 1971 | + $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' ); |
|
| 1972 | + } |
|
| 1973 | + |
|
| 1974 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1975 | + $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1976 | + |
|
| 1977 | + // Hook the ShareThis service. |
|
| 1978 | + $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 1979 | + $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 1980 | + |
|
| 1981 | + // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1982 | + $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1983 | + |
|
| 1984 | + // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service` |
|
| 1985 | + // in order to tweak WP's `WP_Query` to include entities in queries related |
|
| 1986 | + // to categories. |
|
| 1987 | + $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 ); |
|
| 1988 | + |
|
| 1989 | + /* |
|
| 1990 | 1990 | * Hook the `pre_get_posts` action to the `Wordlift_Entity_Page_Service` |
| 1991 | 1991 | * in order to tweak WP's `WP_Query` to show event related entities in reverse |
| 1992 | 1992 | * order of start time. |
| 1993 | 1993 | */ |
| 1994 | - $this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 ); |
|
| 1995 | - |
|
| 1996 | - $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1997 | - |
|
| 1998 | - // This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done. |
|
| 1999 | - $this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 ); |
|
| 2000 | - |
|
| 2001 | - // Analytics Script Frontend. |
|
| 2002 | - if ( apply_filters( 'wl_feature__enable__analytics', true ) && $this->configuration_service->is_analytics_enable() ) { |
|
| 2003 | - $this->loader->add_action( 'wp_enqueue_scripts', $this->analytics_connect, 'enqueue_scripts', 10 ); |
|
| 2004 | - } |
|
| 2005 | - |
|
| 2006 | - } |
|
| 2007 | - |
|
| 2008 | - /** |
|
| 2009 | - * Run the loader to execute all of the hooks with WordPress. |
|
| 2010 | - * |
|
| 2011 | - * @since 1.0.0 |
|
| 2012 | - */ |
|
| 2013 | - public function run() { |
|
| 2014 | - $this->loader->run(); |
|
| 2015 | - } |
|
| 2016 | - |
|
| 2017 | - /** |
|
| 2018 | - * The name of the plugin used to uniquely identify it within the context of |
|
| 2019 | - * WordPress and to define internationalization functionality. |
|
| 2020 | - * |
|
| 2021 | - * @return string The name of the plugin. |
|
| 2022 | - * @since 1.0.0 |
|
| 2023 | - */ |
|
| 2024 | - public function get_plugin_name() { |
|
| 2025 | - return $this->plugin_name; |
|
| 2026 | - } |
|
| 2027 | - |
|
| 2028 | - /** |
|
| 2029 | - * The reference to the class that orchestrates the hooks with the plugin. |
|
| 2030 | - * |
|
| 2031 | - * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 2032 | - * @since 1.0.0 |
|
| 2033 | - */ |
|
| 2034 | - public function get_loader() { |
|
| 2035 | - return $this->loader; |
|
| 2036 | - } |
|
| 2037 | - |
|
| 2038 | - /** |
|
| 2039 | - * Retrieve the version number of the plugin. |
|
| 2040 | - * |
|
| 2041 | - * @return string The version number of the plugin. |
|
| 2042 | - * @since 1.0.0 |
|
| 2043 | - */ |
|
| 2044 | - public function get_version() { |
|
| 2045 | - return $this->version; |
|
| 2046 | - } |
|
| 2047 | - |
|
| 2048 | - /** |
|
| 2049 | - * Load dependencies for WP-CLI. |
|
| 2050 | - * |
|
| 2051 | - * @throws Exception |
|
| 2052 | - * @since 3.18.0 |
|
| 2053 | - */ |
|
| 2054 | - private function load_cli_dependencies() { |
|
| 2055 | - |
|
| 2056 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'cli/class-wordlift-push-reference-data-command.php'; |
|
| 2057 | - |
|
| 2058 | - $push_reference_data_command = new Wordlift_Push_Reference_Data_Command( $this->relation_service, $this->entity_service, $this->sparql_service, $this->configuration_service, $this->entity_type_service ); |
|
| 2059 | - |
|
| 2060 | - WP_CLI::add_command( 'wl references push', $push_reference_data_command ); |
|
| 2061 | - |
|
| 2062 | - } |
|
| 2063 | - |
|
| 2064 | - /** |
|
| 2065 | - * Get the {@link \Wordlift_Dashboard_Service} to allow others to use its functions. |
|
| 2066 | - * |
|
| 2067 | - * @return \Wordlift_Dashboard_Service The {@link \Wordlift_Dashboard_Service} instance. |
|
| 2068 | - * @since 3.20.0 |
|
| 2069 | - */ |
|
| 2070 | - public function get_dashboard_service() { |
|
| 2071 | - |
|
| 2072 | - return $this->dashboard_service; |
|
| 2073 | - } |
|
| 2074 | - |
|
| 2075 | - public function add_wl_enabled_blocks() { |
|
| 2076 | - /** |
|
| 2077 | - * Filter: wl_feature__enable__blocks. |
|
| 2078 | - * |
|
| 2079 | - * @param bool whether the blocks needed to be registered, defaults to true. |
|
| 2080 | - * |
|
| 2081 | - * @return bool |
|
| 2082 | - * @since 3.27.6 |
|
| 2083 | - */ |
|
| 2084 | - |
|
| 2085 | - wp_register_script( 'wl_enabled_blocks', false ); |
|
| 2086 | - |
|
| 2087 | - $enabled_blocks = array(); |
|
| 2088 | - |
|
| 2089 | - /** |
|
| 2090 | - * Filter name: wl_feature__enable__product-navigator |
|
| 2091 | - * @since 3.32.3 |
|
| 2092 | - */ |
|
| 2093 | - if ( apply_filters( 'wl_feature__enable__product-navigator', true ) ) { |
|
| 2094 | - $enabled_blocks[] = 'wordlift/products-navigator'; |
|
| 2095 | - } |
|
| 2096 | - |
|
| 2097 | - if ( apply_filters( 'wl_feature__enable__blocks', true ) ) { |
|
| 2098 | - // To intimate JS |
|
| 2099 | - $enabled_blocks = array_merge( $enabled_blocks, array( |
|
| 2100 | - 'wordlift/navigator', |
|
| 2101 | - 'wordlift/chord', |
|
| 2102 | - 'wordlift/geomap', |
|
| 2103 | - 'wordlift/timeline', |
|
| 2104 | - 'wordlift/cloud', |
|
| 2105 | - 'wordlift/vocabulary', |
|
| 2106 | - 'wordlift/faceted-search' |
|
| 2107 | - ) ); |
|
| 2108 | - } |
|
| 2109 | - |
|
| 2110 | - wp_localize_script( 'wl_enabled_blocks', 'wlEnabledBlocks', $enabled_blocks ); |
|
| 2111 | - wp_enqueue_script( 'wl_enabled_blocks' ); |
|
| 2112 | - } |
|
| 2113 | - |
|
| 2114 | - /** |
|
| 2115 | - * Register screens based on the filter. |
|
| 2116 | - */ |
|
| 2117 | - public function register_screens() { |
|
| 2118 | - // Hook the menu to the Download Your Data page. |
|
| 2119 | - if ( apply_filters( 'wl_feature__enable__settings-download', true ) ) { |
|
| 2120 | - add_action( 'admin_menu', array( $this->download_your_data_page, 'admin_menu' ), 100, 0 ); |
|
| 2121 | - } |
|
| 2122 | - add_action( 'admin_menu', array( $this->status_page, 'admin_menu' ), 100, 0 ); |
|
| 2123 | - add_action( 'admin_menu', array( $this->entity_type_settings_admin_page, 'admin_menu' ), 100, 0 ); |
|
| 2124 | - |
|
| 2125 | - } |
|
| 1994 | + $this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 ); |
|
| 1995 | + |
|
| 1996 | + $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1997 | + |
|
| 1998 | + // This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done. |
|
| 1999 | + $this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 ); |
|
| 2000 | + |
|
| 2001 | + // Analytics Script Frontend. |
|
| 2002 | + if ( apply_filters( 'wl_feature__enable__analytics', true ) && $this->configuration_service->is_analytics_enable() ) { |
|
| 2003 | + $this->loader->add_action( 'wp_enqueue_scripts', $this->analytics_connect, 'enqueue_scripts', 10 ); |
|
| 2004 | + } |
|
| 2005 | + |
|
| 2006 | + } |
|
| 2007 | + |
|
| 2008 | + /** |
|
| 2009 | + * Run the loader to execute all of the hooks with WordPress. |
|
| 2010 | + * |
|
| 2011 | + * @since 1.0.0 |
|
| 2012 | + */ |
|
| 2013 | + public function run() { |
|
| 2014 | + $this->loader->run(); |
|
| 2015 | + } |
|
| 2016 | + |
|
| 2017 | + /** |
|
| 2018 | + * The name of the plugin used to uniquely identify it within the context of |
|
| 2019 | + * WordPress and to define internationalization functionality. |
|
| 2020 | + * |
|
| 2021 | + * @return string The name of the plugin. |
|
| 2022 | + * @since 1.0.0 |
|
| 2023 | + */ |
|
| 2024 | + public function get_plugin_name() { |
|
| 2025 | + return $this->plugin_name; |
|
| 2026 | + } |
|
| 2027 | + |
|
| 2028 | + /** |
|
| 2029 | + * The reference to the class that orchestrates the hooks with the plugin. |
|
| 2030 | + * |
|
| 2031 | + * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 2032 | + * @since 1.0.0 |
|
| 2033 | + */ |
|
| 2034 | + public function get_loader() { |
|
| 2035 | + return $this->loader; |
|
| 2036 | + } |
|
| 2037 | + |
|
| 2038 | + /** |
|
| 2039 | + * Retrieve the version number of the plugin. |
|
| 2040 | + * |
|
| 2041 | + * @return string The version number of the plugin. |
|
| 2042 | + * @since 1.0.0 |
|
| 2043 | + */ |
|
| 2044 | + public function get_version() { |
|
| 2045 | + return $this->version; |
|
| 2046 | + } |
|
| 2047 | + |
|
| 2048 | + /** |
|
| 2049 | + * Load dependencies for WP-CLI. |
|
| 2050 | + * |
|
| 2051 | + * @throws Exception |
|
| 2052 | + * @since 3.18.0 |
|
| 2053 | + */ |
|
| 2054 | + private function load_cli_dependencies() { |
|
| 2055 | + |
|
| 2056 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'cli/class-wordlift-push-reference-data-command.php'; |
|
| 2057 | + |
|
| 2058 | + $push_reference_data_command = new Wordlift_Push_Reference_Data_Command( $this->relation_service, $this->entity_service, $this->sparql_service, $this->configuration_service, $this->entity_type_service ); |
|
| 2059 | + |
|
| 2060 | + WP_CLI::add_command( 'wl references push', $push_reference_data_command ); |
|
| 2061 | + |
|
| 2062 | + } |
|
| 2063 | + |
|
| 2064 | + /** |
|
| 2065 | + * Get the {@link \Wordlift_Dashboard_Service} to allow others to use its functions. |
|
| 2066 | + * |
|
| 2067 | + * @return \Wordlift_Dashboard_Service The {@link \Wordlift_Dashboard_Service} instance. |
|
| 2068 | + * @since 3.20.0 |
|
| 2069 | + */ |
|
| 2070 | + public function get_dashboard_service() { |
|
| 2071 | + |
|
| 2072 | + return $this->dashboard_service; |
|
| 2073 | + } |
|
| 2074 | + |
|
| 2075 | + public function add_wl_enabled_blocks() { |
|
| 2076 | + /** |
|
| 2077 | + * Filter: wl_feature__enable__blocks. |
|
| 2078 | + * |
|
| 2079 | + * @param bool whether the blocks needed to be registered, defaults to true. |
|
| 2080 | + * |
|
| 2081 | + * @return bool |
|
| 2082 | + * @since 3.27.6 |
|
| 2083 | + */ |
|
| 2084 | + |
|
| 2085 | + wp_register_script( 'wl_enabled_blocks', false ); |
|
| 2086 | + |
|
| 2087 | + $enabled_blocks = array(); |
|
| 2088 | + |
|
| 2089 | + /** |
|
| 2090 | + * Filter name: wl_feature__enable__product-navigator |
|
| 2091 | + * @since 3.32.3 |
|
| 2092 | + */ |
|
| 2093 | + if ( apply_filters( 'wl_feature__enable__product-navigator', true ) ) { |
|
| 2094 | + $enabled_blocks[] = 'wordlift/products-navigator'; |
|
| 2095 | + } |
|
| 2096 | + |
|
| 2097 | + if ( apply_filters( 'wl_feature__enable__blocks', true ) ) { |
|
| 2098 | + // To intimate JS |
|
| 2099 | + $enabled_blocks = array_merge( $enabled_blocks, array( |
|
| 2100 | + 'wordlift/navigator', |
|
| 2101 | + 'wordlift/chord', |
|
| 2102 | + 'wordlift/geomap', |
|
| 2103 | + 'wordlift/timeline', |
|
| 2104 | + 'wordlift/cloud', |
|
| 2105 | + 'wordlift/vocabulary', |
|
| 2106 | + 'wordlift/faceted-search' |
|
| 2107 | + ) ); |
|
| 2108 | + } |
|
| 2109 | + |
|
| 2110 | + wp_localize_script( 'wl_enabled_blocks', 'wlEnabledBlocks', $enabled_blocks ); |
|
| 2111 | + wp_enqueue_script( 'wl_enabled_blocks' ); |
|
| 2112 | + } |
|
| 2113 | + |
|
| 2114 | + /** |
|
| 2115 | + * Register screens based on the filter. |
|
| 2116 | + */ |
|
| 2117 | + public function register_screens() { |
|
| 2118 | + // Hook the menu to the Download Your Data page. |
|
| 2119 | + if ( apply_filters( 'wl_feature__enable__settings-download', true ) ) { |
|
| 2120 | + add_action( 'admin_menu', array( $this->download_your_data_page, 'admin_menu' ), 100, 0 ); |
|
| 2121 | + } |
|
| 2122 | + add_action( 'admin_menu', array( $this->status_page, 'admin_menu' ), 100, 0 ); |
|
| 2123 | + add_action( 'admin_menu', array( $this->entity_type_settings_admin_page, 'admin_menu' ), 100, 0 ); |
|
| 2124 | + |
|
| 2125 | + } |
|
| 2126 | 2126 | |
| 2127 | 2127 | } |
@@ -16,20 +16,20 @@ |
||
| 16 | 16 | |
| 17 | 17 | class Object_Relation_Factory { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * @param int $post_id |
|
| 21 | - * |
|
| 22 | - * @return Relation_Service_Interface |
|
| 23 | - */ |
|
| 24 | - public static function get_instance( $post_id ) { |
|
| 25 | - // The post type doesnt have an editor and no-editor-analysis feature is turned on. |
|
| 26 | - if ( No_Editor_Analysis_Feature::can_no_editor_analysis_be_used( $post_id ) ) { |
|
| 27 | - return Object_No_Annotation_Relation_Service::get_instance(); |
|
| 28 | - } |
|
| 29 | - |
|
| 30 | - return Object_Relation_Service::get_instance(); |
|
| 31 | - |
|
| 32 | - } |
|
| 19 | + /** |
|
| 20 | + * @param int $post_id |
|
| 21 | + * |
|
| 22 | + * @return Relation_Service_Interface |
|
| 23 | + */ |
|
| 24 | + public static function get_instance( $post_id ) { |
|
| 25 | + // The post type doesnt have an editor and no-editor-analysis feature is turned on. |
|
| 26 | + if ( No_Editor_Analysis_Feature::can_no_editor_analysis_be_used( $post_id ) ) { |
|
| 27 | + return Object_No_Annotation_Relation_Service::get_instance(); |
|
| 28 | + } |
|
| 29 | + |
|
| 30 | + return Object_Relation_Service::get_instance(); |
|
| 31 | + |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | 34 | |
| 35 | 35 | } |
| 36 | 36 | \ No newline at end of file |
@@ -21,9 +21,9 @@ |
||
| 21 | 21 | * |
| 22 | 22 | * @return Relation_Service_Interface |
| 23 | 23 | */ |
| 24 | - public static function get_instance( $post_id ) { |
|
| 24 | + public static function get_instance($post_id) { |
|
| 25 | 25 | // The post type doesnt have an editor and no-editor-analysis feature is turned on. |
| 26 | - if ( No_Editor_Analysis_Feature::can_no_editor_analysis_be_used( $post_id ) ) { |
|
| 26 | + if (No_Editor_Analysis_Feature::can_no_editor_analysis_be_used($post_id)) { |
|
| 27 | 27 | return Object_No_Annotation_Relation_Service::get_instance(); |
| 28 | 28 | } |
| 29 | 29 | |
@@ -18,80 +18,80 @@ |
||
| 18 | 18 | |
| 19 | 19 | class Object_Relation_Service extends Singleton implements Relation_Service_Interface { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @var \Wordlift_Relation_Service |
|
| 23 | - */ |
|
| 24 | - protected $post_relation_service; |
|
| 25 | - /** |
|
| 26 | - * @var Term_Relation_Service |
|
| 27 | - */ |
|
| 28 | - protected $term_relation_service; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * @var \Wordlift_Log_Service |
|
| 32 | - */ |
|
| 33 | - private $log; |
|
| 34 | - |
|
| 35 | - public function __construct() { |
|
| 36 | - parent::__construct(); |
|
| 37 | - $this->post_relation_service = Post_Relation_Service::get_instance(); |
|
| 38 | - $this->term_relation_service = Term_Relation_Service::get_instance(); |
|
| 39 | - $this->log = \Wordlift_Log_Service::get_logger( get_class() ); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @return Object_Relation_Service |
|
| 44 | - */ |
|
| 45 | - public static function get_instance() { |
|
| 46 | - return parent::get_instance(); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @param $subject_id int |
|
| 51 | - * |
|
| 52 | - * @return array<Reference> |
|
| 53 | - */ |
|
| 54 | - public function get_references( $subject_id, $subject_type ) { |
|
| 55 | - $post_references = $this->post_relation_service->get_references( $subject_id, $subject_type ); |
|
| 56 | - $term_references = $this->term_relation_service->get_references( $subject_id, $subject_type ); |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * @since 3.31.3 |
|
| 60 | - * Should return only unique references. |
|
| 61 | - */ |
|
| 62 | - return array_unique( array_merge( $post_references, $term_references ) ); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - |
|
| 66 | - public function get_relations_from_content( $content, $subject_type ) { |
|
| 67 | - $post_relations = $this->post_relation_service->get_relations_from_content( $content, $subject_type ); |
|
| 68 | - $term_relations = $this->term_relation_service->get_relations_from_content( $content, $subject_type ); |
|
| 69 | - return array_filter( array_merge( $post_relations, $term_relations) ); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - |
|
| 73 | - public static function get_entity_uris( $content ) { |
|
| 74 | - // Remove quote escapes. |
|
| 75 | - $content = str_replace( '\\"', '"', $content ); |
|
| 76 | - |
|
| 77 | - // Match all itemid attributes. |
|
| 78 | - $pattern = '/<\w+[^>]*\sitemid="([^"]+)"[^>]*>/im'; |
|
| 79 | - |
|
| 80 | - // Remove the pattern while it is found (match nested annotations). |
|
| 81 | - $matches = array(); |
|
| 82 | - |
|
| 83 | - // In case of errors, return an empty array. |
|
| 84 | - if ( false === preg_match_all( $pattern, $content, $matches ) ) { |
|
| 85 | - |
|
| 86 | - return array(); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - return $matches[1]; |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - public function get_relations_from_entity_uris( $subject_type, $entity_uris ) { |
|
| 93 | - $post_relations = $this->post_relation_service->get_relations_from_entity_uris( $subject_type, $entity_uris ); |
|
| 94 | - $term_relations = $this->term_relation_service->get_relations_from_entity_uris( $subject_type, $entity_uris ); |
|
| 95 | - return array_filter( array_merge( $post_relations, $term_relations) ); |
|
| 96 | - } |
|
| 21 | + /** |
|
| 22 | + * @var \Wordlift_Relation_Service |
|
| 23 | + */ |
|
| 24 | + protected $post_relation_service; |
|
| 25 | + /** |
|
| 26 | + * @var Term_Relation_Service |
|
| 27 | + */ |
|
| 28 | + protected $term_relation_service; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * @var \Wordlift_Log_Service |
|
| 32 | + */ |
|
| 33 | + private $log; |
|
| 34 | + |
|
| 35 | + public function __construct() { |
|
| 36 | + parent::__construct(); |
|
| 37 | + $this->post_relation_service = Post_Relation_Service::get_instance(); |
|
| 38 | + $this->term_relation_service = Term_Relation_Service::get_instance(); |
|
| 39 | + $this->log = \Wordlift_Log_Service::get_logger( get_class() ); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @return Object_Relation_Service |
|
| 44 | + */ |
|
| 45 | + public static function get_instance() { |
|
| 46 | + return parent::get_instance(); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @param $subject_id int |
|
| 51 | + * |
|
| 52 | + * @return array<Reference> |
|
| 53 | + */ |
|
| 54 | + public function get_references( $subject_id, $subject_type ) { |
|
| 55 | + $post_references = $this->post_relation_service->get_references( $subject_id, $subject_type ); |
|
| 56 | + $term_references = $this->term_relation_service->get_references( $subject_id, $subject_type ); |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * @since 3.31.3 |
|
| 60 | + * Should return only unique references. |
|
| 61 | + */ |
|
| 62 | + return array_unique( array_merge( $post_references, $term_references ) ); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + |
|
| 66 | + public function get_relations_from_content( $content, $subject_type ) { |
|
| 67 | + $post_relations = $this->post_relation_service->get_relations_from_content( $content, $subject_type ); |
|
| 68 | + $term_relations = $this->term_relation_service->get_relations_from_content( $content, $subject_type ); |
|
| 69 | + return array_filter( array_merge( $post_relations, $term_relations) ); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + |
|
| 73 | + public static function get_entity_uris( $content ) { |
|
| 74 | + // Remove quote escapes. |
|
| 75 | + $content = str_replace( '\\"', '"', $content ); |
|
| 76 | + |
|
| 77 | + // Match all itemid attributes. |
|
| 78 | + $pattern = '/<\w+[^>]*\sitemid="([^"]+)"[^>]*>/im'; |
|
| 79 | + |
|
| 80 | + // Remove the pattern while it is found (match nested annotations). |
|
| 81 | + $matches = array(); |
|
| 82 | + |
|
| 83 | + // In case of errors, return an empty array. |
|
| 84 | + if ( false === preg_match_all( $pattern, $content, $matches ) ) { |
|
| 85 | + |
|
| 86 | + return array(); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + return $matches[1]; |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + public function get_relations_from_entity_uris( $subject_type, $entity_uris ) { |
|
| 93 | + $post_relations = $this->post_relation_service->get_relations_from_entity_uris( $subject_type, $entity_uris ); |
|
| 94 | + $term_relations = $this->term_relation_service->get_relations_from_entity_uris( $subject_type, $entity_uris ); |
|
| 95 | + return array_filter( array_merge( $post_relations, $term_relations) ); |
|
| 96 | + } |
|
| 97 | 97 | } |
| 98 | 98 | \ No newline at end of file |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | parent::__construct(); |
| 37 | 37 | $this->post_relation_service = Post_Relation_Service::get_instance(); |
| 38 | 38 | $this->term_relation_service = Term_Relation_Service::get_instance(); |
| 39 | - $this->log = \Wordlift_Log_Service::get_logger( get_class() ); |
|
| 39 | + $this->log = \Wordlift_Log_Service::get_logger(get_class()); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -51,28 +51,28 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @return array<Reference> |
| 53 | 53 | */ |
| 54 | - public function get_references( $subject_id, $subject_type ) { |
|
| 55 | - $post_references = $this->post_relation_service->get_references( $subject_id, $subject_type ); |
|
| 56 | - $term_references = $this->term_relation_service->get_references( $subject_id, $subject_type ); |
|
| 54 | + public function get_references($subject_id, $subject_type) { |
|
| 55 | + $post_references = $this->post_relation_service->get_references($subject_id, $subject_type); |
|
| 56 | + $term_references = $this->term_relation_service->get_references($subject_id, $subject_type); |
|
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * @since 3.31.3 |
| 60 | 60 | * Should return only unique references. |
| 61 | 61 | */ |
| 62 | - return array_unique( array_merge( $post_references, $term_references ) ); |
|
| 62 | + return array_unique(array_merge($post_references, $term_references)); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | |
| 66 | - public function get_relations_from_content( $content, $subject_type ) { |
|
| 67 | - $post_relations = $this->post_relation_service->get_relations_from_content( $content, $subject_type ); |
|
| 68 | - $term_relations = $this->term_relation_service->get_relations_from_content( $content, $subject_type ); |
|
| 69 | - return array_filter( array_merge( $post_relations, $term_relations) ); |
|
| 66 | + public function get_relations_from_content($content, $subject_type) { |
|
| 67 | + $post_relations = $this->post_relation_service->get_relations_from_content($content, $subject_type); |
|
| 68 | + $term_relations = $this->term_relation_service->get_relations_from_content($content, $subject_type); |
|
| 69 | + return array_filter(array_merge($post_relations, $term_relations)); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | |
| 73 | - public static function get_entity_uris( $content ) { |
|
| 73 | + public static function get_entity_uris($content) { |
|
| 74 | 74 | // Remove quote escapes. |
| 75 | - $content = str_replace( '\\"', '"', $content ); |
|
| 75 | + $content = str_replace('\\"', '"', $content); |
|
| 76 | 76 | |
| 77 | 77 | // Match all itemid attributes. |
| 78 | 78 | $pattern = '/<\w+[^>]*\sitemid="([^"]+)"[^>]*>/im'; |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | $matches = array(); |
| 82 | 82 | |
| 83 | 83 | // In case of errors, return an empty array. |
| 84 | - if ( false === preg_match_all( $pattern, $content, $matches ) ) { |
|
| 84 | + if (false === preg_match_all($pattern, $content, $matches)) { |
|
| 85 | 85 | |
| 86 | 86 | return array(); |
| 87 | 87 | } |
@@ -89,9 +89,9 @@ discard block |
||
| 89 | 89 | return $matches[1]; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - public function get_relations_from_entity_uris( $subject_type, $entity_uris ) { |
|
| 93 | - $post_relations = $this->post_relation_service->get_relations_from_entity_uris( $subject_type, $entity_uris ); |
|
| 94 | - $term_relations = $this->term_relation_service->get_relations_from_entity_uris( $subject_type, $entity_uris ); |
|
| 95 | - return array_filter( array_merge( $post_relations, $term_relations) ); |
|
| 92 | + public function get_relations_from_entity_uris($subject_type, $entity_uris) { |
|
| 93 | + $post_relations = $this->post_relation_service->get_relations_from_entity_uris($subject_type, $entity_uris); |
|
| 94 | + $term_relations = $this->term_relation_service->get_relations_from_entity_uris($subject_type, $entity_uris); |
|
| 95 | + return array_filter(array_merge($post_relations, $term_relations)); |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | \ No newline at end of file |
@@ -21,89 +21,89 @@ |
||
| 21 | 21 | |
| 22 | 22 | class Term_Relation_Service extends Singleton implements Relation_Service_Interface { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @var Uri_Service |
|
| 26 | - */ |
|
| 27 | - private $term_uri_service; |
|
| 28 | - /** |
|
| 29 | - * @var Type_Service |
|
| 30 | - */ |
|
| 31 | - private $term_entity_type_service; |
|
| 32 | - |
|
| 33 | - |
|
| 34 | - public function __construct() { |
|
| 35 | - parent::__construct(); |
|
| 36 | - $this->term_uri_service = Uri_Service::get_instance(); |
|
| 37 | - $this->term_entity_type_service = Type_Service::get_instance(); |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @return Term_Relation_Service |
|
| 42 | - */ |
|
| 43 | - public static function get_instance() { |
|
| 44 | - return parent::get_instance(); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - |
|
| 48 | - public function get_references( $subject_id, $subject_type ) { |
|
| 49 | - global $wpdb; |
|
| 50 | - $table_name = $wpdb->prefix . WL_DB_RELATION_INSTANCES_TABLE_NAME; |
|
| 51 | - $query = $wpdb->prepare( "SELECT object_id FROM $table_name WHERE subject_id = %d AND object_type = %d AND subject_type = %d", |
|
| 52 | - $subject_id, |
|
| 53 | - Object_Type_Enum::TERM, |
|
| 54 | - $subject_type |
|
| 55 | - ); |
|
| 56 | - |
|
| 57 | - $term_ids = $wpdb->get_col( $query ); |
|
| 58 | - |
|
| 59 | - return array_map( function ( $term_id ) { |
|
| 60 | - return new Term_Reference( $term_id ); |
|
| 61 | - }, $term_ids ); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - |
|
| 65 | - public function get_relations_from_content( $content, $subject_type ) { |
|
| 66 | - $entity_uris = Object_Relation_Service::get_entity_uris( $content ); |
|
| 67 | - return $this->get_relations_from_entity_uris( $subject_type, $entity_uris ); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * @param $term_id int Term id. |
|
| 72 | - */ |
|
| 73 | - public function get_relation_type( $term_id ) { |
|
| 74 | - $schema = $this->term_entity_type_service->get_schema( |
|
| 75 | - $term_id |
|
| 76 | - ); |
|
| 77 | - $classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES ); |
|
| 78 | - |
|
| 79 | - $entity_type = str_replace( 'wl-', '', $schema['css_class'] ); |
|
| 80 | - foreach ( $classification_boxes as $cb ) { |
|
| 81 | - if ( in_array( $entity_type, $cb['registeredTypes'] ) ) { |
|
| 82 | - return $cb['id']; |
|
| 83 | - } |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - return WL_WHAT_RELATION; |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * @param $subject_type |
|
| 91 | - * @param $entity_uris |
|
| 92 | - * |
|
| 93 | - * @return false[]|Types\Relation[] |
|
| 94 | - */ |
|
| 95 | - public function get_relations_from_entity_uris( $subject_type, $entity_uris ) { |
|
| 96 | - $that = $this; |
|
| 97 | - |
|
| 98 | - return array_map( function ( $entity_uri ) use ( $subject_type, $that ) { |
|
| 99 | - $term = $that->term_uri_service->get_term( $entity_uri ); |
|
| 100 | - if ( ! $term ) { |
|
| 101 | - return false; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - return new Term_Relation( $term->term_id, $that->get_relation_type( $term->term_id ), $subject_type ); |
|
| 105 | - }, $entity_uris ); |
|
| 106 | - } |
|
| 24 | + /** |
|
| 25 | + * @var Uri_Service |
|
| 26 | + */ |
|
| 27 | + private $term_uri_service; |
|
| 28 | + /** |
|
| 29 | + * @var Type_Service |
|
| 30 | + */ |
|
| 31 | + private $term_entity_type_service; |
|
| 32 | + |
|
| 33 | + |
|
| 34 | + public function __construct() { |
|
| 35 | + parent::__construct(); |
|
| 36 | + $this->term_uri_service = Uri_Service::get_instance(); |
|
| 37 | + $this->term_entity_type_service = Type_Service::get_instance(); |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @return Term_Relation_Service |
|
| 42 | + */ |
|
| 43 | + public static function get_instance() { |
|
| 44 | + return parent::get_instance(); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + |
|
| 48 | + public function get_references( $subject_id, $subject_type ) { |
|
| 49 | + global $wpdb; |
|
| 50 | + $table_name = $wpdb->prefix . WL_DB_RELATION_INSTANCES_TABLE_NAME; |
|
| 51 | + $query = $wpdb->prepare( "SELECT object_id FROM $table_name WHERE subject_id = %d AND object_type = %d AND subject_type = %d", |
|
| 52 | + $subject_id, |
|
| 53 | + Object_Type_Enum::TERM, |
|
| 54 | + $subject_type |
|
| 55 | + ); |
|
| 56 | + |
|
| 57 | + $term_ids = $wpdb->get_col( $query ); |
|
| 58 | + |
|
| 59 | + return array_map( function ( $term_id ) { |
|
| 60 | + return new Term_Reference( $term_id ); |
|
| 61 | + }, $term_ids ); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + |
|
| 65 | + public function get_relations_from_content( $content, $subject_type ) { |
|
| 66 | + $entity_uris = Object_Relation_Service::get_entity_uris( $content ); |
|
| 67 | + return $this->get_relations_from_entity_uris( $subject_type, $entity_uris ); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * @param $term_id int Term id. |
|
| 72 | + */ |
|
| 73 | + public function get_relation_type( $term_id ) { |
|
| 74 | + $schema = $this->term_entity_type_service->get_schema( |
|
| 75 | + $term_id |
|
| 76 | + ); |
|
| 77 | + $classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES ); |
|
| 78 | + |
|
| 79 | + $entity_type = str_replace( 'wl-', '', $schema['css_class'] ); |
|
| 80 | + foreach ( $classification_boxes as $cb ) { |
|
| 81 | + if ( in_array( $entity_type, $cb['registeredTypes'] ) ) { |
|
| 82 | + return $cb['id']; |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + return WL_WHAT_RELATION; |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * @param $subject_type |
|
| 91 | + * @param $entity_uris |
|
| 92 | + * |
|
| 93 | + * @return false[]|Types\Relation[] |
|
| 94 | + */ |
|
| 95 | + public function get_relations_from_entity_uris( $subject_type, $entity_uris ) { |
|
| 96 | + $that = $this; |
|
| 97 | + |
|
| 98 | + return array_map( function ( $entity_uri ) use ( $subject_type, $that ) { |
|
| 99 | + $term = $that->term_uri_service->get_term( $entity_uri ); |
|
| 100 | + if ( ! $term ) { |
|
| 101 | + return false; |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + return new Term_Relation( $term->term_id, $that->get_relation_type( $term->term_id ), $subject_type ); |
|
| 105 | + }, $entity_uris ); |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | 108 | |
| 109 | 109 | } |
| 110 | 110 | \ No newline at end of file |
@@ -45,40 +45,40 @@ discard block |
||
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | |
| 48 | - public function get_references( $subject_id, $subject_type ) { |
|
| 48 | + public function get_references($subject_id, $subject_type) { |
|
| 49 | 49 | global $wpdb; |
| 50 | - $table_name = $wpdb->prefix . WL_DB_RELATION_INSTANCES_TABLE_NAME; |
|
| 51 | - $query = $wpdb->prepare( "SELECT object_id FROM $table_name WHERE subject_id = %d AND object_type = %d AND subject_type = %d", |
|
| 50 | + $table_name = $wpdb->prefix.WL_DB_RELATION_INSTANCES_TABLE_NAME; |
|
| 51 | + $query = $wpdb->prepare("SELECT object_id FROM $table_name WHERE subject_id = %d AND object_type = %d AND subject_type = %d", |
|
| 52 | 52 | $subject_id, |
| 53 | 53 | Object_Type_Enum::TERM, |
| 54 | 54 | $subject_type |
| 55 | 55 | ); |
| 56 | 56 | |
| 57 | - $term_ids = $wpdb->get_col( $query ); |
|
| 57 | + $term_ids = $wpdb->get_col($query); |
|
| 58 | 58 | |
| 59 | - return array_map( function ( $term_id ) { |
|
| 60 | - return new Term_Reference( $term_id ); |
|
| 61 | - }, $term_ids ); |
|
| 59 | + return array_map(function($term_id) { |
|
| 60 | + return new Term_Reference($term_id); |
|
| 61 | + }, $term_ids); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | |
| 65 | - public function get_relations_from_content( $content, $subject_type ) { |
|
| 66 | - $entity_uris = Object_Relation_Service::get_entity_uris( $content ); |
|
| 67 | - return $this->get_relations_from_entity_uris( $subject_type, $entity_uris ); |
|
| 65 | + public function get_relations_from_content($content, $subject_type) { |
|
| 66 | + $entity_uris = Object_Relation_Service::get_entity_uris($content); |
|
| 67 | + return $this->get_relations_from_entity_uris($subject_type, $entity_uris); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | 71 | * @param $term_id int Term id. |
| 72 | 72 | */ |
| 73 | - public function get_relation_type( $term_id ) { |
|
| 73 | + public function get_relation_type($term_id) { |
|
| 74 | 74 | $schema = $this->term_entity_type_service->get_schema( |
| 75 | 75 | $term_id |
| 76 | 76 | ); |
| 77 | - $classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES ); |
|
| 77 | + $classification_boxes = unserialize(WL_CORE_POST_CLASSIFICATION_BOXES); |
|
| 78 | 78 | |
| 79 | - $entity_type = str_replace( 'wl-', '', $schema['css_class'] ); |
|
| 80 | - foreach ( $classification_boxes as $cb ) { |
|
| 81 | - if ( in_array( $entity_type, $cb['registeredTypes'] ) ) { |
|
| 79 | + $entity_type = str_replace('wl-', '', $schema['css_class']); |
|
| 80 | + foreach ($classification_boxes as $cb) { |
|
| 81 | + if (in_array($entity_type, $cb['registeredTypes'])) { |
|
| 82 | 82 | return $cb['id']; |
| 83 | 83 | } |
| 84 | 84 | } |
@@ -92,17 +92,17 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @return false[]|Types\Relation[] |
| 94 | 94 | */ |
| 95 | - public function get_relations_from_entity_uris( $subject_type, $entity_uris ) { |
|
| 95 | + public function get_relations_from_entity_uris($subject_type, $entity_uris) { |
|
| 96 | 96 | $that = $this; |
| 97 | 97 | |
| 98 | - return array_map( function ( $entity_uri ) use ( $subject_type, $that ) { |
|
| 99 | - $term = $that->term_uri_service->get_term( $entity_uri ); |
|
| 100 | - if ( ! $term ) { |
|
| 98 | + return array_map(function($entity_uri) use ($subject_type, $that) { |
|
| 99 | + $term = $that->term_uri_service->get_term($entity_uri); |
|
| 100 | + if ( ! $term) { |
|
| 101 | 101 | return false; |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - return new Term_Relation( $term->term_id, $that->get_relation_type( $term->term_id ), $subject_type ); |
|
| 105 | - }, $entity_uris ); |
|
| 104 | + return new Term_Relation($term->term_id, $that->get_relation_type($term->term_id), $subject_type); |
|
| 105 | + }, $entity_uris); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | |
@@ -13,14 +13,14 @@ |
||
| 13 | 13 | class Object_No_Annotation_Relation_Service extends Object_Relation_Service { |
| 14 | 14 | |
| 15 | 15 | |
| 16 | - public function get_relations_from_content( $content, $subject_type ) { |
|
| 17 | - if ( ! isset($_POST['wl_entities'])) { |
|
| 18 | - return array(); |
|
| 19 | - } |
|
| 16 | + public function get_relations_from_content( $content, $subject_type ) { |
|
| 17 | + if ( ! isset($_POST['wl_entities'])) { |
|
| 18 | + return array(); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - $selected_entities = (array) $_POST['wl_entities']; |
|
| 22 | - // Returns the list of entity ids. |
|
| 23 | - $entity_uris = array_keys( $selected_entities ); |
|
| 24 | - return $this->get_relations_from_entity_uris( $subject_type, $entity_uris ); |
|
| 25 | - } |
|
| 21 | + $selected_entities = (array) $_POST['wl_entities']; |
|
| 22 | + // Returns the list of entity ids. |
|
| 23 | + $entity_uris = array_keys( $selected_entities ); |
|
| 24 | + return $this->get_relations_from_entity_uris( $subject_type, $entity_uris ); |
|
| 25 | + } |
|
| 26 | 26 | } |
| 27 | 27 | \ No newline at end of file |
@@ -13,14 +13,14 @@ |
||
| 13 | 13 | class Object_No_Annotation_Relation_Service extends Object_Relation_Service { |
| 14 | 14 | |
| 15 | 15 | |
| 16 | - public function get_relations_from_content( $content, $subject_type ) { |
|
| 16 | + public function get_relations_from_content($content, $subject_type) { |
|
| 17 | 17 | if ( ! isset($_POST['wl_entities'])) { |
| 18 | 18 | return array(); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | $selected_entities = (array) $_POST['wl_entities']; |
| 22 | 22 | // Returns the list of entity ids. |
| 23 | - $entity_uris = array_keys( $selected_entities ); |
|
| 24 | - return $this->get_relations_from_entity_uris( $subject_type, $entity_uris ); |
|
| 23 | + $entity_uris = array_keys($selected_entities); |
|
| 24 | + return $this->get_relations_from_entity_uris($subject_type, $entity_uris); |
|
| 25 | 25 | } |
| 26 | 26 | } |
| 27 | 27 | \ No newline at end of file |
@@ -17,30 +17,30 @@ |
||
| 17 | 17 | |
| 18 | 18 | interface Relation_Service_Interface { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @param $subject_id int |
|
| 22 | - * @param int $subject_type {@link Object_Type_Enum} |
|
| 23 | - * @return array<Reference> |
|
| 24 | - */ |
|
| 25 | - public function get_references( $subject_id, $subject_type ); |
|
| 26 | - |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * @param $content string |
|
| 30 | - * @param int $subject_type {@link Object_Type_Enum} |
|
| 31 | - * @return array<Relation> |
|
| 32 | - * Extracts the relations from the post content. |
|
| 33 | - */ |
|
| 34 | - public function get_relations_from_content( $content, $subject_type ); |
|
| 35 | - |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * @param $subject_type |
|
| 39 | - * @param $entity_uris |
|
| 40 | - * |
|
| 41 | - * @return Relation[] | false[] |
|
| 42 | - */ |
|
| 43 | - public function get_relations_from_entity_uris( $subject_type, $entity_uris ); |
|
| 20 | + /** |
|
| 21 | + * @param $subject_id int |
|
| 22 | + * @param int $subject_type {@link Object_Type_Enum} |
|
| 23 | + * @return array<Reference> |
|
| 24 | + */ |
|
| 25 | + public function get_references( $subject_id, $subject_type ); |
|
| 26 | + |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * @param $content string |
|
| 30 | + * @param int $subject_type {@link Object_Type_Enum} |
|
| 31 | + * @return array<Relation> |
|
| 32 | + * Extracts the relations from the post content. |
|
| 33 | + */ |
|
| 34 | + public function get_relations_from_content( $content, $subject_type ); |
|
| 35 | + |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * @param $subject_type |
|
| 39 | + * @param $entity_uris |
|
| 40 | + * |
|
| 41 | + * @return Relation[] | false[] |
|
| 42 | + */ |
|
| 43 | + public function get_relations_from_entity_uris( $subject_type, $entity_uris ); |
|
| 44 | 44 | |
| 45 | 45 | |
| 46 | 46 | } |
| 47 | 47 | \ No newline at end of file |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | * @param int $subject_type {@link Object_Type_Enum} |
| 23 | 23 | * @return array<Reference> |
| 24 | 24 | */ |
| 25 | - public function get_references( $subject_id, $subject_type ); |
|
| 25 | + public function get_references($subject_id, $subject_type); |
|
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @return array<Relation> |
| 32 | 32 | * Extracts the relations from the post content. |
| 33 | 33 | */ |
| 34 | - public function get_relations_from_content( $content, $subject_type ); |
|
| 34 | + public function get_relations_from_content($content, $subject_type); |
|
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @return Relation[] | false[] |
| 42 | 42 | */ |
| 43 | - public function get_relations_from_entity_uris( $subject_type, $entity_uris ); |
|
| 43 | + public function get_relations_from_entity_uris($subject_type, $entity_uris); |
|
| 44 | 44 | |
| 45 | 45 | |
| 46 | 46 | } |
| 47 | 47 | \ No newline at end of file |
@@ -17,65 +17,65 @@ |
||
| 17 | 17 | use Wordlift\Relation\Types\Relation; |
| 18 | 18 | |
| 19 | 19 | class Post_Relation_Service extends Singleton implements Relation_Service_Interface { |
| 20 | - /** |
|
| 21 | - * @var \Wordlift_Relation_Service |
|
| 22 | - */ |
|
| 23 | - private $legacy_post_relation_service; |
|
| 24 | - /** |
|
| 25 | - * @var \Wordlift_Entity_Uri_Service |
|
| 26 | - */ |
|
| 27 | - private $entity_uri_service; |
|
| 28 | - /** |
|
| 29 | - * @var \Wordlift_Entity_Service |
|
| 30 | - */ |
|
| 31 | - private $entity_service; |
|
| 20 | + /** |
|
| 21 | + * @var \Wordlift_Relation_Service |
|
| 22 | + */ |
|
| 23 | + private $legacy_post_relation_service; |
|
| 24 | + /** |
|
| 25 | + * @var \Wordlift_Entity_Uri_Service |
|
| 26 | + */ |
|
| 27 | + private $entity_uri_service; |
|
| 28 | + /** |
|
| 29 | + * @var \Wordlift_Entity_Service |
|
| 30 | + */ |
|
| 31 | + private $entity_service; |
|
| 32 | 32 | |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @return Post_Relation_Service |
|
| 36 | - */ |
|
| 37 | - public static function get_instance() { |
|
| 38 | - return parent::get_instance(); |
|
| 39 | - } |
|
| 34 | + /** |
|
| 35 | + * @return Post_Relation_Service |
|
| 36 | + */ |
|
| 37 | + public static function get_instance() { |
|
| 38 | + return parent::get_instance(); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - public function __construct() { |
|
| 42 | - parent::__construct(); |
|
| 43 | - $this->legacy_post_relation_service = \Wordlift_Relation_Service::get_instance(); |
|
| 44 | - $this->entity_uri_service = \Wordlift_Entity_Uri_Service::get_instance(); |
|
| 45 | - $this->entity_service = \Wordlift_Entity_Service::get_instance(); |
|
| 46 | - } |
|
| 41 | + public function __construct() { |
|
| 42 | + parent::__construct(); |
|
| 43 | + $this->legacy_post_relation_service = \Wordlift_Relation_Service::get_instance(); |
|
| 44 | + $this->entity_uri_service = \Wordlift_Entity_Uri_Service::get_instance(); |
|
| 45 | + $this->entity_service = \Wordlift_Entity_Service::get_instance(); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | 48 | |
| 49 | - public function get_references( $subject_id, $subject_type ) { |
|
| 50 | - $post_ids = $this->legacy_post_relation_service->get_objects( $subject_id, 'ids' ); |
|
| 49 | + public function get_references( $subject_id, $subject_type ) { |
|
| 50 | + $post_ids = $this->legacy_post_relation_service->get_objects( $subject_id, 'ids' ); |
|
| 51 | 51 | |
| 52 | - return array_map( function ( $post_id ) { |
|
| 53 | - return new Post_Reference( $post_id ); |
|
| 54 | - }, $post_ids ); |
|
| 55 | - } |
|
| 52 | + return array_map( function ( $post_id ) { |
|
| 53 | + return new Post_Reference( $post_id ); |
|
| 54 | + }, $post_ids ); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - public function get_relations_from_content( $content, $subject_type ) { |
|
| 58 | - $entity_uris = Object_Relation_Service::get_entity_uris( $content ); |
|
| 57 | + public function get_relations_from_content( $content, $subject_type ) { |
|
| 58 | + $entity_uris = Object_Relation_Service::get_entity_uris( $content ); |
|
| 59 | 59 | |
| 60 | - return $this->get_relations_from_entity_uris( $subject_type, $entity_uris ); |
|
| 61 | - } |
|
| 60 | + return $this->get_relations_from_entity_uris( $subject_type, $entity_uris ); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * @param $subject_type |
|
| 65 | - * @param $entity_uris |
|
| 66 | - * |
|
| 67 | - * @return false[]|Relation[] |
|
| 68 | - */ |
|
| 69 | - public function get_relations_from_entity_uris( $subject_type, $entity_uris ) { |
|
| 70 | - $that = $this; |
|
| 63 | + /** |
|
| 64 | + * @param $subject_type |
|
| 65 | + * @param $entity_uris |
|
| 66 | + * |
|
| 67 | + * @return false[]|Relation[] |
|
| 68 | + */ |
|
| 69 | + public function get_relations_from_entity_uris( $subject_type, $entity_uris ) { |
|
| 70 | + $that = $this; |
|
| 71 | 71 | |
| 72 | - return array_map( function ( $entity_uri ) use ( $subject_type, $that ) { |
|
| 73 | - $entity = $that->entity_uri_service->get_entity( $entity_uri ); |
|
| 74 | - if ( ! $entity ) { |
|
| 75 | - return false; |
|
| 76 | - } |
|
| 72 | + return array_map( function ( $entity_uri ) use ( $subject_type, $that ) { |
|
| 73 | + $entity = $that->entity_uri_service->get_entity( $entity_uri ); |
|
| 74 | + if ( ! $entity ) { |
|
| 75 | + return false; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - return new Post_Relation( $entity->ID, $that->entity_service->get_classification_scope_for( $entity->ID ), $subject_type ); |
|
| 79 | - }, $entity_uris ); |
|
| 80 | - } |
|
| 78 | + return new Post_Relation( $entity->ID, $that->entity_service->get_classification_scope_for( $entity->ID ), $subject_type ); |
|
| 79 | + }, $entity_uris ); |
|
| 80 | + } |
|
| 81 | 81 | } |
| 82 | 82 | \ No newline at end of file |
@@ -46,18 +46,18 @@ discard block |
||
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | |
| 49 | - public function get_references( $subject_id, $subject_type ) { |
|
| 50 | - $post_ids = $this->legacy_post_relation_service->get_objects( $subject_id, 'ids' ); |
|
| 49 | + public function get_references($subject_id, $subject_type) { |
|
| 50 | + $post_ids = $this->legacy_post_relation_service->get_objects($subject_id, 'ids'); |
|
| 51 | 51 | |
| 52 | - return array_map( function ( $post_id ) { |
|
| 53 | - return new Post_Reference( $post_id ); |
|
| 54 | - }, $post_ids ); |
|
| 52 | + return array_map(function($post_id) { |
|
| 53 | + return new Post_Reference($post_id); |
|
| 54 | + }, $post_ids); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - public function get_relations_from_content( $content, $subject_type ) { |
|
| 58 | - $entity_uris = Object_Relation_Service::get_entity_uris( $content ); |
|
| 57 | + public function get_relations_from_content($content, $subject_type) { |
|
| 58 | + $entity_uris = Object_Relation_Service::get_entity_uris($content); |
|
| 59 | 59 | |
| 60 | - return $this->get_relations_from_entity_uris( $subject_type, $entity_uris ); |
|
| 60 | + return $this->get_relations_from_entity_uris($subject_type, $entity_uris); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -66,16 +66,16 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @return false[]|Relation[] |
| 68 | 68 | */ |
| 69 | - public function get_relations_from_entity_uris( $subject_type, $entity_uris ) { |
|
| 69 | + public function get_relations_from_entity_uris($subject_type, $entity_uris) { |
|
| 70 | 70 | $that = $this; |
| 71 | 71 | |
| 72 | - return array_map( function ( $entity_uri ) use ( $subject_type, $that ) { |
|
| 73 | - $entity = $that->entity_uri_service->get_entity( $entity_uri ); |
|
| 74 | - if ( ! $entity ) { |
|
| 72 | + return array_map(function($entity_uri) use ($subject_type, $that) { |
|
| 73 | + $entity = $that->entity_uri_service->get_entity($entity_uri); |
|
| 74 | + if ( ! $entity) { |
|
| 75 | 75 | return false; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - return new Post_Relation( $entity->ID, $that->entity_service->get_classification_scope_for( $entity->ID ), $subject_type ); |
|
| 79 | - }, $entity_uris ); |
|
| 78 | + return new Post_Relation($entity->ID, $that->entity_service->get_classification_scope_for($entity->ID), $subject_type); |
|
| 79 | + }, $entity_uris); |
|
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | \ No newline at end of file |