@@ -7,14 +7,14 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | // Define the basic options for HTTP calls to REDLINK. |
| 9 | 9 | define( 'WL_REDLINK_API_HTTP_OPTIONS', serialize( array( |
| 10 | - 'timeout' => 300, |
|
| 11 | - 'redirection' => 5, |
|
| 12 | - 'httpversion' => '1.1', |
|
| 13 | - 'blocking' => true, |
|
| 14 | - 'cookies' => array(), |
|
| 15 | - 'sslverify' => ( 'false' === getenv( 'WL_SSL_VERIFY_ENABLED' ) ) ? false : true, |
|
| 16 | - 'sslcertificates' => dirname( __FILE__ ) . '/ssl/ca-bundle.crt', |
|
| 17 | - 'decompress' => false, |
|
| 10 | + 'timeout' => 300, |
|
| 11 | + 'redirection' => 5, |
|
| 12 | + 'httpversion' => '1.1', |
|
| 13 | + 'blocking' => true, |
|
| 14 | + 'cookies' => array(), |
|
| 15 | + 'sslverify' => ( 'false' === getenv( 'WL_SSL_VERIFY_ENABLED' ) ) ? false : true, |
|
| 16 | + 'sslcertificates' => dirname( __FILE__ ) . '/ssl/ca-bundle.crt', |
|
| 17 | + 'decompress' => false, |
|
| 18 | 18 | ) ) ); |
| 19 | 19 | |
| 20 | 20 | // Create a unique ID for this request, useful to hook async HTTP requests. |
@@ -27,11 +27,11 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | function wl_is_sparql_update_queries_buffering_enabled() { |
| 29 | 29 | |
| 30 | - if ( isset( $_REQUEST['wl-async'] ) && 'false' === $_REQUEST['wl-async'] ) { |
|
| 31 | - return false; |
|
| 32 | - } |
|
| 30 | + if ( isset( $_REQUEST['wl-async'] ) && 'false' === $_REQUEST['wl-async'] ) { |
|
| 31 | + return false; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - return 'true' !== getenv( 'WL_DISABLE_SPARQL_UPDATE_QUERIES_BUFFERING' ); |
|
| 34 | + return 'true' !== getenv( 'WL_DISABLE_SPARQL_UPDATE_QUERIES_BUFFERING' ); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | // Define the meta name used to store the entity URL. |
@@ -58,14 +58,14 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | function wl_prefixes() { |
| 60 | 60 | |
| 61 | - $items = wl_prefixes_list(); |
|
| 62 | - $prefixes = array(); |
|
| 61 | + $items = wl_prefixes_list(); |
|
| 62 | + $prefixes = array(); |
|
| 63 | 63 | |
| 64 | - foreach ( $items as $item ) { |
|
| 65 | - $prefixes[ $item['prefix'] ] = $item['namespace']; |
|
| 66 | - } |
|
| 64 | + foreach ( $items as $item ) { |
|
| 65 | + $prefixes[ $item['prefix'] ] = $item['namespace']; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - return $prefixes; |
|
| 68 | + return $prefixes; |
|
| 69 | 69 | |
| 70 | 70 | } |
| 71 | 71 | |
@@ -81,14 +81,14 @@ discard block |
||
| 81 | 81 | * @return string The path to the temp directory for the specific site. |
| 82 | 82 | */ |
| 83 | 83 | function wl_temp_dir() { |
| 84 | - $tempdir = get_temp_dir(); |
|
| 85 | - $unique = md5( site_url() . get_current_blog_id() ); |
|
| 86 | - $unique_temp_dir = $tempdir . 'wl_' . $unique; // $tempdir should have a trailing slash. |
|
| 84 | + $tempdir = get_temp_dir(); |
|
| 85 | + $unique = md5( site_url() . get_current_blog_id() ); |
|
| 86 | + $unique_temp_dir = $tempdir . 'wl_' . $unique; // $tempdir should have a trailing slash. |
|
| 87 | 87 | |
| 88 | - // If directory do not exist, create it. |
|
| 89 | - if ( ! file_exists( $unique_temp_dir ) ) { |
|
| 90 | - mkdir( $unique_temp_dir ); |
|
| 91 | - } |
|
| 88 | + // If directory do not exist, create it. |
|
| 89 | + if ( ! file_exists( $unique_temp_dir ) ) { |
|
| 90 | + mkdir( $unique_temp_dir ); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - return $unique_temp_dir . '/'; |
|
| 93 | + return $unique_temp_dir . '/'; |
|
| 94 | 94 | } |
@@ -6,49 +6,49 @@ discard block |
||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | // Define the basic options for HTTP calls to REDLINK. |
| 9 | -define( 'WL_REDLINK_API_HTTP_OPTIONS', serialize( array( |
|
| 9 | +define('WL_REDLINK_API_HTTP_OPTIONS', serialize(array( |
|
| 10 | 10 | 'timeout' => 300, |
| 11 | 11 | 'redirection' => 5, |
| 12 | 12 | 'httpversion' => '1.1', |
| 13 | 13 | 'blocking' => true, |
| 14 | 14 | 'cookies' => array(), |
| 15 | - 'sslverify' => ( 'false' === getenv( 'WL_SSL_VERIFY_ENABLED' ) ) ? false : true, |
|
| 16 | - 'sslcertificates' => dirname( __FILE__ ) . '/ssl/ca-bundle.crt', |
|
| 15 | + 'sslverify' => ('false' === getenv('WL_SSL_VERIFY_ENABLED')) ? false : true, |
|
| 16 | + 'sslcertificates' => dirname(__FILE__).'/ssl/ca-bundle.crt', |
|
| 17 | 17 | 'decompress' => false, |
| 18 | -) ) ); |
|
| 18 | +))); |
|
| 19 | 19 | |
| 20 | 20 | // Create a unique ID for this request, useful to hook async HTTP requests. |
| 21 | -define( 'WL_REQUEST_ID', uniqid( true ) ); |
|
| 21 | +define('WL_REQUEST_ID', uniqid(true)); |
|
| 22 | 22 | |
| 23 | 23 | // Set the temporary files folder. |
| 24 | -defined( 'WL_TEMP_DIR' ) || define( 'WL_TEMP_DIR', wl_temp_dir() ); |
|
| 24 | +defined('WL_TEMP_DIR') || define('WL_TEMP_DIR', wl_temp_dir()); |
|
| 25 | 25 | |
| 26 | -define( 'WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING', wl_is_sparql_update_queries_buffering_enabled() ); |
|
| 26 | +define('WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING', wl_is_sparql_update_queries_buffering_enabled()); |
|
| 27 | 27 | |
| 28 | 28 | function wl_is_sparql_update_queries_buffering_enabled() { |
| 29 | 29 | |
| 30 | - if ( isset( $_REQUEST['wl-async'] ) && 'false' === $_REQUEST['wl-async'] ) { |
|
| 30 | + if (isset($_REQUEST['wl-async']) && 'false' === $_REQUEST['wl-async']) { |
|
| 31 | 31 | return false; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - return 'true' !== getenv( 'WL_DISABLE_SPARQL_UPDATE_QUERIES_BUFFERING' ); |
|
| 34 | + return 'true' !== getenv('WL_DISABLE_SPARQL_UPDATE_QUERIES_BUFFERING'); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | // Define the meta name used to store the entity URL. |
| 38 | -define( 'WL_ENTITY_URL_META_NAME', 'entity_url' ); |
|
| 38 | +define('WL_ENTITY_URL_META_NAME', 'entity_url'); |
|
| 39 | 39 | |
| 40 | 40 | // Max number of recursions when printing microdata. |
| 41 | -define( 'WL_RECURSION_DEPTH_ON_ENTITY_METADATA_PRINTING', 3 ); |
|
| 41 | +define('WL_RECURSION_DEPTH_ON_ENTITY_METADATA_PRINTING', 3); |
|
| 42 | 42 | |
| 43 | 43 | // 3.13.0, we use by default WLS 1.11 which provides us with the new, faster |
| 44 | 44 | // chunked analysis. |
| 45 | -define( 'WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE', defined( 'WORDLIFT_API_URL' ) ? WORDLIFT_API_URL . '/' : 'https://api.wordlift.it/' ); |
|
| 45 | +define('WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE', defined('WORDLIFT_API_URL') ? WORDLIFT_API_URL . '/' : 'https://api.wordlift.it/'); |
|
| 46 | 46 | |
| 47 | -define( 'WL_CONFIG_TEST_GOOGLE_RICH_SNIPPETS_URL', 'https://developers.google.com/structured-data/testing-tool/?url=' ); |
|
| 47 | +define('WL_CONFIG_TEST_GOOGLE_RICH_SNIPPETS_URL', 'https://developers.google.com/structured-data/testing-tool/?url='); |
|
| 48 | 48 | |
| 49 | 49 | // If is set to true, there will be additional button in 'Download Your Data' page |
| 50 | 50 | // that will allow users to download their data in JSON-LD format. |
| 51 | -defined( 'WL_CONFIG_DOWNLOAD_GA_CONTENT_DATA' ) || define( 'WL_CONFIG_DOWNLOAD_GA_CONTENT_DATA', false ); |
|
| 51 | +defined('WL_CONFIG_DOWNLOAD_GA_CONTENT_DATA') || define('WL_CONFIG_DOWNLOAD_GA_CONTENT_DATA', false); |
|
| 52 | 52 | |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | $items = wl_prefixes_list(); |
| 62 | 62 | $prefixes = array(); |
| 63 | 63 | |
| 64 | - foreach ( $items as $item ) { |
|
| 65 | - $prefixes[ $item['prefix'] ] = $item['namespace']; |
|
| 64 | + foreach ($items as $item) { |
|
| 65 | + $prefixes[$item['prefix']] = $item['namespace']; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | return $prefixes; |
@@ -82,13 +82,13 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | function wl_temp_dir() { |
| 84 | 84 | $tempdir = get_temp_dir(); |
| 85 | - $unique = md5( site_url() . get_current_blog_id() ); |
|
| 86 | - $unique_temp_dir = $tempdir . 'wl_' . $unique; // $tempdir should have a trailing slash. |
|
| 85 | + $unique = md5(site_url().get_current_blog_id()); |
|
| 86 | + $unique_temp_dir = $tempdir.'wl_'.$unique; // $tempdir should have a trailing slash. |
|
| 87 | 87 | |
| 88 | 88 | // If directory do not exist, create it. |
| 89 | - if ( ! file_exists( $unique_temp_dir ) ) { |
|
| 90 | - mkdir( $unique_temp_dir ); |
|
| 89 | + if ( ! file_exists($unique_temp_dir)) { |
|
| 90 | + mkdir($unique_temp_dir); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - return $unique_temp_dir . '/'; |
|
| 93 | + return $unique_temp_dir.'/'; |
|
| 94 | 94 | } |
@@ -16,12 +16,12 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | function wl_core_check_relation_predicate_is_supported( $predicate ) { |
| 18 | 18 | |
| 19 | - return in_array( $predicate, array( |
|
| 20 | - WL_WHAT_RELATION, |
|
| 21 | - WL_WHEN_RELATION, |
|
| 22 | - WL_WHERE_RELATION, |
|
| 23 | - WL_WHO_RELATION, |
|
| 24 | - ) ); |
|
| 19 | + return in_array( $predicate, array( |
|
| 20 | + WL_WHAT_RELATION, |
|
| 21 | + WL_WHEN_RELATION, |
|
| 22 | + WL_WHERE_RELATION, |
|
| 23 | + WL_WHO_RELATION, |
|
| 24 | + ) ); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | function wl_core_get_validation_rules() { |
| 33 | 33 | |
| 34 | - return unserialize( WL_CORE_GET_POSTS_VALIDATION_RULES ); |
|
| 34 | + return unserialize( WL_CORE_GET_POSTS_VALIDATION_RULES ); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -41,10 +41,10 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | function wl_core_get_relation_instances_table_name() { |
| 43 | 43 | |
| 44 | - global $wpdb; |
|
| 45 | - $table_name = $wpdb->prefix . WL_DB_RELATION_INSTANCES_TABLE_NAME; |
|
| 44 | + global $wpdb; |
|
| 45 | + $table_name = $wpdb->prefix . WL_DB_RELATION_INSTANCES_TABLE_NAME; |
|
| 46 | 46 | |
| 47 | - return $table_name; |
|
| 47 | + return $table_name; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -59,48 +59,48 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | function wl_core_add_relation_instance( $subject_id, $predicate, $object_id ) { |
| 61 | 61 | |
| 62 | - // Checks on subject and object |
|
| 63 | - if ( ! is_numeric( $subject_id ) || ! is_numeric( $object_id ) ) { |
|
| 64 | - return false; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - // Checks on the given relation |
|
| 68 | - if ( ! wl_core_check_relation_predicate_is_supported( $predicate ) ) { |
|
| 69 | - return false; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - // Prepare interaction with db |
|
| 73 | - global $wpdb; |
|
| 74 | - |
|
| 75 | - // Checks passed. Add relation if not exists: |
|
| 76 | - // |
|
| 77 | - // See https://codex.wordpress.org/Class_Reference/wpdb#REPLACE_row |
|
| 78 | - $wpdb->replace( |
|
| 79 | - wl_core_get_relation_instances_table_name(), |
|
| 80 | - array( |
|
| 81 | - 'subject_id' => $subject_id, |
|
| 82 | - 'predicate' => $predicate, |
|
| 83 | - 'object_id' => $object_id, |
|
| 84 | - ), |
|
| 85 | - array( '%d', '%s', '%d' ) |
|
| 86 | - ); |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * Hooks: Relation Added. |
|
| 90 | - * |
|
| 91 | - * Fire a hook when a new relation between a post/entity and an entity is |
|
| 92 | - * added (the relation may already exists). |
|
| 93 | - * |
|
| 94 | - * @since 3.16.0 |
|
| 95 | - * |
|
| 96 | - * @param int $subject_id The subject {@link WP_Post} id. |
|
| 97 | - * @param string $predicate The predicate. |
|
| 98 | - * @param int $object_id The object {@link WP_Post} id. |
|
| 99 | - */ |
|
| 100 | - do_action( 'wl_relation_added', $subject_id, $predicate, $object_id ); |
|
| 101 | - |
|
| 102 | - // Return record id |
|
| 103 | - return $wpdb->insert_id; |
|
| 62 | + // Checks on subject and object |
|
| 63 | + if ( ! is_numeric( $subject_id ) || ! is_numeric( $object_id ) ) { |
|
| 64 | + return false; |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + // Checks on the given relation |
|
| 68 | + if ( ! wl_core_check_relation_predicate_is_supported( $predicate ) ) { |
|
| 69 | + return false; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + // Prepare interaction with db |
|
| 73 | + global $wpdb; |
|
| 74 | + |
|
| 75 | + // Checks passed. Add relation if not exists: |
|
| 76 | + // |
|
| 77 | + // See https://codex.wordpress.org/Class_Reference/wpdb#REPLACE_row |
|
| 78 | + $wpdb->replace( |
|
| 79 | + wl_core_get_relation_instances_table_name(), |
|
| 80 | + array( |
|
| 81 | + 'subject_id' => $subject_id, |
|
| 82 | + 'predicate' => $predicate, |
|
| 83 | + 'object_id' => $object_id, |
|
| 84 | + ), |
|
| 85 | + array( '%d', '%s', '%d' ) |
|
| 86 | + ); |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * Hooks: Relation Added. |
|
| 90 | + * |
|
| 91 | + * Fire a hook when a new relation between a post/entity and an entity is |
|
| 92 | + * added (the relation may already exists). |
|
| 93 | + * |
|
| 94 | + * @since 3.16.0 |
|
| 95 | + * |
|
| 96 | + * @param int $subject_id The subject {@link WP_Post} id. |
|
| 97 | + * @param string $predicate The predicate. |
|
| 98 | + * @param int $object_id The object {@link WP_Post} id. |
|
| 99 | + */ |
|
| 100 | + do_action( 'wl_relation_added', $subject_id, $predicate, $object_id ); |
|
| 101 | + |
|
| 102 | + // Return record id |
|
| 103 | + return $wpdb->insert_id; |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -113,37 +113,37 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | function wl_core_delete_relation_instances( $subject_id ) { |
| 115 | 115 | |
| 116 | - // Checks on subject and object |
|
| 117 | - if ( ! is_numeric( $subject_id ) ) { |
|
| 118 | - return false; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - // Prepare interaction with db |
|
| 122 | - global $wpdb; |
|
| 123 | - |
|
| 124 | - // wl_write_log( "Going to delete relation instances [ subject_id :: $subject_id ]"); |
|
| 125 | - |
|
| 126 | - // @see https://codex.wordpress.org/it:Riferimento_classi/wpdb#DELETE_di_righe |
|
| 127 | - $wpdb->delete( |
|
| 128 | - wl_core_get_relation_instances_table_name(), |
|
| 129 | - array( |
|
| 130 | - 'subject_id' => $subject_id, |
|
| 131 | - ), |
|
| 132 | - array( '%d' ) |
|
| 133 | - ); |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * Hooks: Relation Deleted. |
|
| 137 | - * |
|
| 138 | - * The hook is fired after the relations with this post/entity are deleted. |
|
| 139 | - * |
|
| 140 | - * @since 3.16.0 |
|
| 141 | - * |
|
| 142 | - * @param int $subject_id The subject {@link WP_Post} id. |
|
| 143 | - */ |
|
| 144 | - do_action( 'wl_relation_deleted', $subject_id ); |
|
| 145 | - |
|
| 146 | - return true; |
|
| 116 | + // Checks on subject and object |
|
| 117 | + if ( ! is_numeric( $subject_id ) ) { |
|
| 118 | + return false; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + // Prepare interaction with db |
|
| 122 | + global $wpdb; |
|
| 123 | + |
|
| 124 | + // wl_write_log( "Going to delete relation instances [ subject_id :: $subject_id ]"); |
|
| 125 | + |
|
| 126 | + // @see https://codex.wordpress.org/it:Riferimento_classi/wpdb#DELETE_di_righe |
|
| 127 | + $wpdb->delete( |
|
| 128 | + wl_core_get_relation_instances_table_name(), |
|
| 129 | + array( |
|
| 130 | + 'subject_id' => $subject_id, |
|
| 131 | + ), |
|
| 132 | + array( '%d' ) |
|
| 133 | + ); |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * Hooks: Relation Deleted. |
|
| 137 | + * |
|
| 138 | + * The hook is fired after the relations with this post/entity are deleted. |
|
| 139 | + * |
|
| 140 | + * @since 3.16.0 |
|
| 141 | + * |
|
| 142 | + * @param int $subject_id The subject {@link WP_Post} id. |
|
| 143 | + */ |
|
| 144 | + do_action( 'wl_relation_deleted', $subject_id ); |
|
| 145 | + |
|
| 146 | + return true; |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /** |
@@ -159,18 +159,18 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | function wl_core_validate_filters_for_related( $filters ) { |
| 161 | 161 | |
| 162 | - if ( ! is_array( $filters ) ) { |
|
| 163 | - $filters = array(); |
|
| 164 | - } |
|
| 162 | + if ( ! is_array( $filters ) ) { |
|
| 163 | + $filters = array(); |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | - if ( ! isset( $filters['predicate'] ) ) { |
|
| 167 | - $filters['predicate'] = null; |
|
| 168 | - } |
|
| 169 | - if ( ! isset( $filters['status'] ) ) { |
|
| 170 | - $filters['status'] = null; |
|
| 171 | - } |
|
| 166 | + if ( ! isset( $filters['predicate'] ) ) { |
|
| 167 | + $filters['predicate'] = null; |
|
| 168 | + } |
|
| 169 | + if ( ! isset( $filters['status'] ) ) { |
|
| 170 | + $filters['status'] = null; |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - return $filters; |
|
| 173 | + return $filters; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | ///** |
@@ -217,10 +217,10 @@ discard block |
||
| 217 | 217 | */ |
| 218 | 218 | function wl_core_get_related_entity_ids( $subject_id, $filters = array() ) { |
| 219 | 219 | |
| 220 | - $status = isset( $filters['status'] ) ? $filters['status'] : null; |
|
| 221 | - $predicate = isset( $filters['predicate'] ) ? $filters['predicate'] : null; |
|
| 220 | + $status = isset( $filters['status'] ) ? $filters['status'] : null; |
|
| 221 | + $predicate = isset( $filters['predicate'] ) ? $filters['predicate'] : null; |
|
| 222 | 222 | |
| 223 | - return Wordlift_Relation_Service::get_instance()->get_objects( $subject_id, 'ids', $predicate, $status ); |
|
| 223 | + return Wordlift_Relation_Service::get_instance()->get_objects( $subject_id, 'ids', $predicate, $status ); |
|
| 224 | 224 | |
| 225 | 225 | // $filters = wl_core_validate_filters_for_related( $filters ); |
| 226 | 226 | // |
@@ -241,11 +241,11 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | function wl_core_get_related_entities( $subject_id, $filters = array() ) { |
| 243 | 243 | |
| 244 | - $ids = wl_core_get_related_entity_ids( $subject_id, $filters ); |
|
| 244 | + $ids = wl_core_get_related_entity_ids( $subject_id, $filters ); |
|
| 245 | 245 | |
| 246 | - return array_map( function ( $item ) { |
|
| 247 | - return get_post( $item ); |
|
| 248 | - }, $ids ); |
|
| 246 | + return array_map( function ( $item ) { |
|
| 247 | + return get_post( $item ); |
|
| 248 | + }, $ids ); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | // |
@@ -323,12 +323,12 @@ discard block |
||
| 323 | 323 | */ |
| 324 | 324 | function wl_core_get_related_post_ids( $object_id, $filters = array() ) { |
| 325 | 325 | |
| 326 | - $relation_service = Wordlift_Relation_Service::get_instance(); |
|
| 326 | + $relation_service = Wordlift_Relation_Service::get_instance(); |
|
| 327 | 327 | |
| 328 | - $status = isset( $filters['status'] ) ? $filters['status'] : null; |
|
| 329 | - $predicate = isset( $filters['predicate'] ) ? $filters['predicate'] : null; |
|
| 328 | + $status = isset( $filters['status'] ) ? $filters['status'] : null; |
|
| 329 | + $predicate = isset( $filters['predicate'] ) ? $filters['predicate'] : null; |
|
| 330 | 330 | |
| 331 | - return $relation_service->get_article_subjects( $object_id, 'ids', $predicate, $status ); |
|
| 331 | + return $relation_service->get_article_subjects( $object_id, 'ids', $predicate, $status ); |
|
| 332 | 332 | // |
| 333 | 333 | // $filters = wl_core_validate_filters_for_related( $filters ); |
| 334 | 334 | // |
@@ -352,11 +352,11 @@ discard block |
||
| 352 | 352 | */ |
| 353 | 353 | function wl_core_get_related_posts( $subject_id, $filters = array() ) { |
| 354 | 354 | |
| 355 | - $ids = wl_core_get_related_post_ids( $subject_id, $filters ); |
|
| 355 | + $ids = wl_core_get_related_post_ids( $subject_id, $filters ); |
|
| 356 | 356 | |
| 357 | - return array_map( function ( $item ) { |
|
| 358 | - return get_post( $item ); |
|
| 359 | - }, $ids ); |
|
| 357 | + return array_map( function ( $item ) { |
|
| 358 | + return get_post( $item ); |
|
| 359 | + }, $ids ); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | ///** |
@@ -441,129 +441,129 @@ discard block |
||
| 441 | 441 | */ |
| 442 | 442 | function wl_core_sql_query_builder( $args ) { |
| 443 | 443 | |
| 444 | - // Prepare interaction with db |
|
| 445 | - global $wpdb; |
|
| 446 | - |
|
| 447 | - // Retrieve Wordlift relation instances table name |
|
| 448 | - $table_name = wl_core_get_relation_instances_table_name(); |
|
| 449 | - |
|
| 450 | - // When type is set to `post` we're looking for `post`s that are not |
|
| 451 | - // configured as entities. |
|
| 452 | - // When the type is set to `entity` we're looking also for `post`s that are |
|
| 453 | - // configured as entities. |
|
| 454 | - |
|
| 455 | - // Since we want Find only articles, based on the entity type, we need |
|
| 456 | - // to figure out the relevant sql statements to add to the join and where |
|
| 457 | - // parts. |
|
| 458 | - if ( 'entity' === $args['post_type'] ) { |
|
| 459 | - $tax_query = array( |
|
| 460 | - 'relation' => 'AND', |
|
| 461 | - array( |
|
| 462 | - 'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, |
|
| 463 | - 'operator' => 'EXISTS', |
|
| 464 | - ), |
|
| 465 | - array( |
|
| 466 | - 'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, |
|
| 467 | - 'field' => 'slug', |
|
| 468 | - 'terms' => 'article', |
|
| 469 | - 'operator' => 'NOT IN', |
|
| 470 | - ), |
|
| 471 | - ); |
|
| 472 | - } else { |
|
| 473 | - $tax_query = array( |
|
| 474 | - 'relation' => 'OR', |
|
| 475 | - array( |
|
| 476 | - 'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, |
|
| 477 | - 'operator' => 'NOT EXISTS', |
|
| 478 | - ), |
|
| 479 | - array( |
|
| 480 | - 'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, |
|
| 481 | - 'field' => 'slug', |
|
| 482 | - 'terms' => 'article', |
|
| 483 | - ), |
|
| 484 | - ); |
|
| 485 | - } |
|
| 486 | - |
|
| 487 | - |
|
| 488 | - // Use "p" as the table to match the initial join. |
|
| 489 | - $tax_sql = get_tax_sql( $tax_query, 'p', 'ID' ); |
|
| 490 | - |
|
| 491 | - // Sql Action |
|
| 492 | - $sql = 'SELECT '; |
|
| 493 | - // Determine what has to be returned depending on 'get' argument value |
|
| 494 | - switch ( $args['get'] ) { |
|
| 495 | - case 'posts': |
|
| 496 | - $sql .= 'p.*'; |
|
| 497 | - break; |
|
| 498 | - case 'post_ids': |
|
| 499 | - $sql .= 'p.id'; |
|
| 500 | - break; |
|
| 501 | - } |
|
| 502 | - |
|
| 503 | - // If we look for posts related as objects the JOIN has to be done with the object_id column and viceversa |
|
| 504 | - $join_column = $args['as'] . '_id'; |
|
| 505 | - |
|
| 506 | - $sql .= " FROM $wpdb->posts as p JOIN $table_name as r ON p.id = r.$join_column"; |
|
| 507 | - |
|
| 508 | - // Changing left join generate by the tax query into an inner since the term relationship has to exist. |
|
| 509 | - $sql .= str_replace( 'LEFT JOIN', 'INNER JOIN', $tax_sql['join'] ); |
|
| 510 | - |
|
| 511 | - // Sql add post type filter |
|
| 512 | - $post_types = Wordlift_Entity_Service::valid_entity_post_types(); |
|
| 513 | - $sql .= " AND p.post_type IN ('" . join( "', '", esc_sql( $post_types ) ) . "') AND"; |
|
| 514 | - |
|
| 515 | - // Sql add post status filter |
|
| 516 | - if ( isset( $args['post_status'] ) && ! is_null( $args['post_status'] ) ) { |
|
| 517 | - $sql .= $wpdb->prepare( ' p.post_status = %s AND', $args['post_status'] ); |
|
| 518 | - } |
|
| 519 | - |
|
| 520 | - // Add filtering conditions |
|
| 521 | - // If we look for posts related as objects this means that |
|
| 522 | - // related_to is a reference for a subject: subject_id is the filtering column |
|
| 523 | - // If we look for posts related as subject this means that |
|
| 524 | - // related_to is reference for an object: object_id is the filtering column |
|
| 525 | - |
|
| 526 | - $filtering_column = ( 'object' == $args['as'] ) ? 'subject_id' : 'object_id'; |
|
| 527 | - |
|
| 528 | - if ( isset( $args['related_to'] ) ) { |
|
| 529 | - $sql .= $wpdb->prepare( " r.$filtering_column = %d", $args['related_to'] ); |
|
| 530 | - } |
|
| 531 | - if ( isset( $args['related_to'] ) && isset( $args['related_to__in'] ) ) { |
|
| 532 | - $sql .= ' AND'; |
|
| 533 | - } |
|
| 534 | - if ( isset( $args['related_to__in'] ) ) { |
|
| 535 | - $sql .= " r.$filtering_column IN (" . implode( ',', $args['related_to__in'] ) . ')'; |
|
| 536 | - // The IDs used for filtering shouldn't be in the results. |
|
| 537 | - $sql .= " AND p.ID NOT IN (" . implode( ',', $args['related_to__in'] ) . ')'; |
|
| 538 | - } |
|
| 539 | - if ( isset( $args['post__not_in'] ) ) { |
|
| 540 | - $sql .= ' AND r.' . $args['as'] . '_id NOT IN (' . implode( ',', $args['post__not_in'] ) . ')'; |
|
| 541 | - } |
|
| 542 | - if ( isset( $args['post__in'] ) ) { |
|
| 543 | - $sql .= ' AND r.' . $args['as'] . '_id IN (' . implode( ',', $args['post__in'] ) . ')'; |
|
| 544 | - } |
|
| 545 | - // Add predicate filter if required. |
|
| 546 | - if ( isset( $args['with_predicate'] ) ) { |
|
| 547 | - // Sql Inner Join clause. |
|
| 548 | - $sql .= $wpdb->prepare( ' AND r.predicate = %s', $args['with_predicate'] ); |
|
| 549 | - } |
|
| 550 | - |
|
| 551 | - // Add the taxonomy related sql. |
|
| 552 | - $sql .= $tax_sql['where']; |
|
| 553 | - |
|
| 554 | - // Add a group by clause to avoid duplicated rows |
|
| 555 | - // @todo: isn't a distinct a better choice? |
|
| 556 | - $sql .= ' GROUP BY p.id'; |
|
| 557 | - |
|
| 558 | - // @todo: how does `first` represent the limit? |
|
| 559 | - if ( isset( $args['first'] ) && is_numeric( $args['first'] ) ) { |
|
| 560 | - // Sql Inner Join clause. |
|
| 561 | - $sql .= $wpdb->prepare( ' LIMIT %d', $args['first'] ); |
|
| 562 | - } |
|
| 563 | - // Close sql statement |
|
| 564 | - $sql .= ';'; |
|
| 565 | - |
|
| 566 | - return $sql; |
|
| 444 | + // Prepare interaction with db |
|
| 445 | + global $wpdb; |
|
| 446 | + |
|
| 447 | + // Retrieve Wordlift relation instances table name |
|
| 448 | + $table_name = wl_core_get_relation_instances_table_name(); |
|
| 449 | + |
|
| 450 | + // When type is set to `post` we're looking for `post`s that are not |
|
| 451 | + // configured as entities. |
|
| 452 | + // When the type is set to `entity` we're looking also for `post`s that are |
|
| 453 | + // configured as entities. |
|
| 454 | + |
|
| 455 | + // Since we want Find only articles, based on the entity type, we need |
|
| 456 | + // to figure out the relevant sql statements to add to the join and where |
|
| 457 | + // parts. |
|
| 458 | + if ( 'entity' === $args['post_type'] ) { |
|
| 459 | + $tax_query = array( |
|
| 460 | + 'relation' => 'AND', |
|
| 461 | + array( |
|
| 462 | + 'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, |
|
| 463 | + 'operator' => 'EXISTS', |
|
| 464 | + ), |
|
| 465 | + array( |
|
| 466 | + 'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, |
|
| 467 | + 'field' => 'slug', |
|
| 468 | + 'terms' => 'article', |
|
| 469 | + 'operator' => 'NOT IN', |
|
| 470 | + ), |
|
| 471 | + ); |
|
| 472 | + } else { |
|
| 473 | + $tax_query = array( |
|
| 474 | + 'relation' => 'OR', |
|
| 475 | + array( |
|
| 476 | + 'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, |
|
| 477 | + 'operator' => 'NOT EXISTS', |
|
| 478 | + ), |
|
| 479 | + array( |
|
| 480 | + 'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, |
|
| 481 | + 'field' => 'slug', |
|
| 482 | + 'terms' => 'article', |
|
| 483 | + ), |
|
| 484 | + ); |
|
| 485 | + } |
|
| 486 | + |
|
| 487 | + |
|
| 488 | + // Use "p" as the table to match the initial join. |
|
| 489 | + $tax_sql = get_tax_sql( $tax_query, 'p', 'ID' ); |
|
| 490 | + |
|
| 491 | + // Sql Action |
|
| 492 | + $sql = 'SELECT '; |
|
| 493 | + // Determine what has to be returned depending on 'get' argument value |
|
| 494 | + switch ( $args['get'] ) { |
|
| 495 | + case 'posts': |
|
| 496 | + $sql .= 'p.*'; |
|
| 497 | + break; |
|
| 498 | + case 'post_ids': |
|
| 499 | + $sql .= 'p.id'; |
|
| 500 | + break; |
|
| 501 | + } |
|
| 502 | + |
|
| 503 | + // If we look for posts related as objects the JOIN has to be done with the object_id column and viceversa |
|
| 504 | + $join_column = $args['as'] . '_id'; |
|
| 505 | + |
|
| 506 | + $sql .= " FROM $wpdb->posts as p JOIN $table_name as r ON p.id = r.$join_column"; |
|
| 507 | + |
|
| 508 | + // Changing left join generate by the tax query into an inner since the term relationship has to exist. |
|
| 509 | + $sql .= str_replace( 'LEFT JOIN', 'INNER JOIN', $tax_sql['join'] ); |
|
| 510 | + |
|
| 511 | + // Sql add post type filter |
|
| 512 | + $post_types = Wordlift_Entity_Service::valid_entity_post_types(); |
|
| 513 | + $sql .= " AND p.post_type IN ('" . join( "', '", esc_sql( $post_types ) ) . "') AND"; |
|
| 514 | + |
|
| 515 | + // Sql add post status filter |
|
| 516 | + if ( isset( $args['post_status'] ) && ! is_null( $args['post_status'] ) ) { |
|
| 517 | + $sql .= $wpdb->prepare( ' p.post_status = %s AND', $args['post_status'] ); |
|
| 518 | + } |
|
| 519 | + |
|
| 520 | + // Add filtering conditions |
|
| 521 | + // If we look for posts related as objects this means that |
|
| 522 | + // related_to is a reference for a subject: subject_id is the filtering column |
|
| 523 | + // If we look for posts related as subject this means that |
|
| 524 | + // related_to is reference for an object: object_id is the filtering column |
|
| 525 | + |
|
| 526 | + $filtering_column = ( 'object' == $args['as'] ) ? 'subject_id' : 'object_id'; |
|
| 527 | + |
|
| 528 | + if ( isset( $args['related_to'] ) ) { |
|
| 529 | + $sql .= $wpdb->prepare( " r.$filtering_column = %d", $args['related_to'] ); |
|
| 530 | + } |
|
| 531 | + if ( isset( $args['related_to'] ) && isset( $args['related_to__in'] ) ) { |
|
| 532 | + $sql .= ' AND'; |
|
| 533 | + } |
|
| 534 | + if ( isset( $args['related_to__in'] ) ) { |
|
| 535 | + $sql .= " r.$filtering_column IN (" . implode( ',', $args['related_to__in'] ) . ')'; |
|
| 536 | + // The IDs used for filtering shouldn't be in the results. |
|
| 537 | + $sql .= " AND p.ID NOT IN (" . implode( ',', $args['related_to__in'] ) . ')'; |
|
| 538 | + } |
|
| 539 | + if ( isset( $args['post__not_in'] ) ) { |
|
| 540 | + $sql .= ' AND r.' . $args['as'] . '_id NOT IN (' . implode( ',', $args['post__not_in'] ) . ')'; |
|
| 541 | + } |
|
| 542 | + if ( isset( $args['post__in'] ) ) { |
|
| 543 | + $sql .= ' AND r.' . $args['as'] . '_id IN (' . implode( ',', $args['post__in'] ) . ')'; |
|
| 544 | + } |
|
| 545 | + // Add predicate filter if required. |
|
| 546 | + if ( isset( $args['with_predicate'] ) ) { |
|
| 547 | + // Sql Inner Join clause. |
|
| 548 | + $sql .= $wpdb->prepare( ' AND r.predicate = %s', $args['with_predicate'] ); |
|
| 549 | + } |
|
| 550 | + |
|
| 551 | + // Add the taxonomy related sql. |
|
| 552 | + $sql .= $tax_sql['where']; |
|
| 553 | + |
|
| 554 | + // Add a group by clause to avoid duplicated rows |
|
| 555 | + // @todo: isn't a distinct a better choice? |
|
| 556 | + $sql .= ' GROUP BY p.id'; |
|
| 557 | + |
|
| 558 | + // @todo: how does `first` represent the limit? |
|
| 559 | + if ( isset( $args['first'] ) && is_numeric( $args['first'] ) ) { |
|
| 560 | + // Sql Inner Join clause. |
|
| 561 | + $sql .= $wpdb->prepare( ' LIMIT %d', $args['first'] ); |
|
| 562 | + } |
|
| 563 | + // Close sql statement |
|
| 564 | + $sql .= ';'; |
|
| 565 | + |
|
| 566 | + return $sql; |
|
| 567 | 567 | |
| 568 | 568 | } |
| 569 | 569 | |
@@ -581,70 +581,70 @@ discard block |
||
| 581 | 581 | */ |
| 582 | 582 | function wl_core_get_posts( $args, $returned_type = OBJECT ) { |
| 583 | 583 | |
| 584 | - // Merge given args with defaults args value |
|
| 585 | - $args = array_merge( array( |
|
| 586 | - 'with_predicate' => null, |
|
| 587 | - 'as' => 'subject', |
|
| 588 | - 'post_type' => 'post', |
|
| 589 | - 'get' => 'posts', |
|
| 590 | - 'post_status' => null, |
|
| 591 | - ), $args ); |
|
| 592 | - |
|
| 593 | - // Arguments validation rules |
|
| 594 | - // At least one between related_to and related_to__in has to be set |
|
| 595 | - if ( ! isset( $args['related_to'] ) && ! isset( $args['related_to__in'] ) ) { |
|
| 596 | - return false; |
|
| 597 | - } |
|
| 598 | - if ( isset( $args['related_to'] ) && ! is_numeric( $args['related_to'] ) ) { |
|
| 599 | - return false; |
|
| 600 | - } |
|
| 601 | - |
|
| 602 | - // The same check is applied to post_in, post__not_in and related_to__in options |
|
| 603 | - // Only arrays with at least one numeric value are considerad valid |
|
| 604 | - // The argument value is further sanitized in order to clean up not numeric values |
|
| 605 | - foreach ( |
|
| 606 | - array( |
|
| 607 | - 'post__in', |
|
| 608 | - 'post__not_in', |
|
| 609 | - 'related_to__in', |
|
| 610 | - ) as $option_name |
|
| 611 | - ) { |
|
| 612 | - if ( isset( $args[ $option_name ] ) ) { |
|
| 613 | - if ( ! is_array( $args[ $option_name ] ) || 0 == count( array_filter( $args[ $option_name ], "is_numeric" ) ) ) { |
|
| 614 | - return false; |
|
| 615 | - } |
|
| 616 | - // Sanitize value removing non numeric values from the array |
|
| 617 | - $args[ $option_name ] = array_filter( $args[ $option_name ], "is_numeric" ); |
|
| 618 | - } |
|
| 619 | - } |
|
| 620 | - // Performing validation rules |
|
| 621 | - foreach ( wl_core_get_validation_rules() as $option_name => $accepeted_values ) { |
|
| 622 | - if ( isset( $args[ $option_name ] ) && ! is_null( $args[ $option_name ] ) ) { |
|
| 623 | - if ( ! in_array( $args[ $option_name ], $accepeted_values ) ) { |
|
| 624 | - return false; |
|
| 625 | - } |
|
| 626 | - } |
|
| 627 | - } |
|
| 628 | - |
|
| 629 | - // Prepare interaction with db |
|
| 630 | - global $wpdb; |
|
| 631 | - |
|
| 632 | - // Build sql statement with given arguments |
|
| 633 | - $sql_statement = wl_core_sql_query_builder( $args ); |
|
| 634 | - |
|
| 635 | - // If ids are required, returns a one-dimensional array containing ids. |
|
| 636 | - // Otherwise an array of associative arrays representing the post | relation object |
|
| 637 | - if ( 'post_ids' == $args['get'] ) { |
|
| 638 | - # See https://codex.wordpress.org/Class_Reference/wpdb#SELECT_a_Column |
|
| 639 | - $results = $wpdb->get_col( $sql_statement ); |
|
| 640 | - } else { |
|
| 641 | - $results = $wpdb->get_results( $sql_statement, $returned_type ); |
|
| 642 | - } |
|
| 643 | - // If there were an error performing the query then false is returned |
|
| 644 | - if ( ! empty( $wpdb->last_error ) ) { |
|
| 645 | - return false; |
|
| 646 | - } |
|
| 647 | - |
|
| 648 | - // Finally |
|
| 649 | - return $results; |
|
| 584 | + // Merge given args with defaults args value |
|
| 585 | + $args = array_merge( array( |
|
| 586 | + 'with_predicate' => null, |
|
| 587 | + 'as' => 'subject', |
|
| 588 | + 'post_type' => 'post', |
|
| 589 | + 'get' => 'posts', |
|
| 590 | + 'post_status' => null, |
|
| 591 | + ), $args ); |
|
| 592 | + |
|
| 593 | + // Arguments validation rules |
|
| 594 | + // At least one between related_to and related_to__in has to be set |
|
| 595 | + if ( ! isset( $args['related_to'] ) && ! isset( $args['related_to__in'] ) ) { |
|
| 596 | + return false; |
|
| 597 | + } |
|
| 598 | + if ( isset( $args['related_to'] ) && ! is_numeric( $args['related_to'] ) ) { |
|
| 599 | + return false; |
|
| 600 | + } |
|
| 601 | + |
|
| 602 | + // The same check is applied to post_in, post__not_in and related_to__in options |
|
| 603 | + // Only arrays with at least one numeric value are considerad valid |
|
| 604 | + // The argument value is further sanitized in order to clean up not numeric values |
|
| 605 | + foreach ( |
|
| 606 | + array( |
|
| 607 | + 'post__in', |
|
| 608 | + 'post__not_in', |
|
| 609 | + 'related_to__in', |
|
| 610 | + ) as $option_name |
|
| 611 | + ) { |
|
| 612 | + if ( isset( $args[ $option_name ] ) ) { |
|
| 613 | + if ( ! is_array( $args[ $option_name ] ) || 0 == count( array_filter( $args[ $option_name ], "is_numeric" ) ) ) { |
|
| 614 | + return false; |
|
| 615 | + } |
|
| 616 | + // Sanitize value removing non numeric values from the array |
|
| 617 | + $args[ $option_name ] = array_filter( $args[ $option_name ], "is_numeric" ); |
|
| 618 | + } |
|
| 619 | + } |
|
| 620 | + // Performing validation rules |
|
| 621 | + foreach ( wl_core_get_validation_rules() as $option_name => $accepeted_values ) { |
|
| 622 | + if ( isset( $args[ $option_name ] ) && ! is_null( $args[ $option_name ] ) ) { |
|
| 623 | + if ( ! in_array( $args[ $option_name ], $accepeted_values ) ) { |
|
| 624 | + return false; |
|
| 625 | + } |
|
| 626 | + } |
|
| 627 | + } |
|
| 628 | + |
|
| 629 | + // Prepare interaction with db |
|
| 630 | + global $wpdb; |
|
| 631 | + |
|
| 632 | + // Build sql statement with given arguments |
|
| 633 | + $sql_statement = wl_core_sql_query_builder( $args ); |
|
| 634 | + |
|
| 635 | + // If ids are required, returns a one-dimensional array containing ids. |
|
| 636 | + // Otherwise an array of associative arrays representing the post | relation object |
|
| 637 | + if ( 'post_ids' == $args['get'] ) { |
|
| 638 | + # See https://codex.wordpress.org/Class_Reference/wpdb#SELECT_a_Column |
|
| 639 | + $results = $wpdb->get_col( $sql_statement ); |
|
| 640 | + } else { |
|
| 641 | + $results = $wpdb->get_results( $sql_statement, $returned_type ); |
|
| 642 | + } |
|
| 643 | + // If there were an error performing the query then false is returned |
|
| 644 | + if ( ! empty( $wpdb->last_error ) ) { |
|
| 645 | + return false; |
|
| 646 | + } |
|
| 647 | + |
|
| 648 | + // Finally |
|
| 649 | + return $results; |
|
| 650 | 650 | } |
@@ -14,14 +14,14 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @return boolean Return true if supported, false otherwise |
| 16 | 16 | */ |
| 17 | -function wl_core_check_relation_predicate_is_supported( $predicate ) { |
|
| 17 | +function wl_core_check_relation_predicate_is_supported($predicate) { |
|
| 18 | 18 | |
| 19 | - return in_array( $predicate, array( |
|
| 19 | + return in_array($predicate, array( |
|
| 20 | 20 | WL_WHAT_RELATION, |
| 21 | 21 | WL_WHEN_RELATION, |
| 22 | 22 | WL_WHERE_RELATION, |
| 23 | 23 | WL_WHO_RELATION, |
| 24 | - ) ); |
|
| 24 | + )); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | function wl_core_get_validation_rules() { |
| 33 | 33 | |
| 34 | - return unserialize( WL_CORE_GET_POSTS_VALIDATION_RULES ); |
|
| 34 | + return unserialize(WL_CORE_GET_POSTS_VALIDATION_RULES); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | function wl_core_get_relation_instances_table_name() { |
| 43 | 43 | |
| 44 | 44 | global $wpdb; |
| 45 | - $table_name = $wpdb->prefix . WL_DB_RELATION_INSTANCES_TABLE_NAME; |
|
| 45 | + $table_name = $wpdb->prefix.WL_DB_RELATION_INSTANCES_TABLE_NAME; |
|
| 46 | 46 | |
| 47 | 47 | return $table_name; |
| 48 | 48 | } |
@@ -57,15 +57,15 @@ discard block |
||
| 57 | 57 | * @uses $wpdb->replace() to perform the query |
| 58 | 58 | * @return integer|boolean Return then relation instance ID or false. |
| 59 | 59 | */ |
| 60 | -function wl_core_add_relation_instance( $subject_id, $predicate, $object_id ) { |
|
| 60 | +function wl_core_add_relation_instance($subject_id, $predicate, $object_id) { |
|
| 61 | 61 | |
| 62 | 62 | // Checks on subject and object |
| 63 | - if ( ! is_numeric( $subject_id ) || ! is_numeric( $object_id ) ) { |
|
| 63 | + if ( ! is_numeric($subject_id) || ! is_numeric($object_id)) { |
|
| 64 | 64 | return false; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | // Checks on the given relation |
| 68 | - if ( ! wl_core_check_relation_predicate_is_supported( $predicate ) ) { |
|
| 68 | + if ( ! wl_core_check_relation_predicate_is_supported($predicate)) { |
|
| 69 | 69 | return false; |
| 70 | 70 | } |
| 71 | 71 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | 'predicate' => $predicate, |
| 83 | 83 | 'object_id' => $object_id, |
| 84 | 84 | ), |
| 85 | - array( '%d', '%s', '%d' ) |
|
| 85 | + array('%d', '%s', '%d') |
|
| 86 | 86 | ); |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * @param string $predicate The predicate. |
| 98 | 98 | * @param int $object_id The object {@link WP_Post} id. |
| 99 | 99 | */ |
| 100 | - do_action( 'wl_relation_added', $subject_id, $predicate, $object_id ); |
|
| 100 | + do_action('wl_relation_added', $subject_id, $predicate, $object_id); |
|
| 101 | 101 | |
| 102 | 102 | // Return record id |
| 103 | 103 | return $wpdb->insert_id; |
@@ -111,10 +111,10 @@ discard block |
||
| 111 | 111 | * |
| 112 | 112 | * @return boolean False for failure. True for success. |
| 113 | 113 | */ |
| 114 | -function wl_core_delete_relation_instances( $subject_id ) { |
|
| 114 | +function wl_core_delete_relation_instances($subject_id) { |
|
| 115 | 115 | |
| 116 | 116 | // Checks on subject and object |
| 117 | - if ( ! is_numeric( $subject_id ) ) { |
|
| 117 | + if ( ! is_numeric($subject_id)) { |
|
| 118 | 118 | return false; |
| 119 | 119 | } |
| 120 | 120 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | array( |
| 130 | 130 | 'subject_id' => $subject_id, |
| 131 | 131 | ), |
| 132 | - array( '%d' ) |
|
| 132 | + array('%d') |
|
| 133 | 133 | ); |
| 134 | 134 | |
| 135 | 135 | /** |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | * |
| 142 | 142 | * @param int $subject_id The subject {@link WP_Post} id. |
| 143 | 143 | */ |
| 144 | - do_action( 'wl_relation_deleted', $subject_id ); |
|
| 144 | + do_action('wl_relation_deleted', $subject_id); |
|
| 145 | 145 | |
| 146 | 146 | return true; |
| 147 | 147 | } |
@@ -157,16 +157,16 @@ discard block |
||
| 157 | 157 | * 'status' => null |
| 158 | 158 | * ); |
| 159 | 159 | */ |
| 160 | -function wl_core_validate_filters_for_related( $filters ) { |
|
| 160 | +function wl_core_validate_filters_for_related($filters) { |
|
| 161 | 161 | |
| 162 | - if ( ! is_array( $filters ) ) { |
|
| 162 | + if ( ! is_array($filters)) { |
|
| 163 | 163 | $filters = array(); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - if ( ! isset( $filters['predicate'] ) ) { |
|
| 166 | + if ( ! isset($filters['predicate'])) { |
|
| 167 | 167 | $filters['predicate'] = null; |
| 168 | 168 | } |
| 169 | - if ( ! isset( $filters['status'] ) ) { |
|
| 169 | + if ( ! isset($filters['status'])) { |
|
| 170 | 170 | $filters['status'] = null; |
| 171 | 171 | } |
| 172 | 172 | |
@@ -215,12 +215,12 @@ discard block |
||
| 215 | 215 | * |
| 216 | 216 | * @return array Array of post entity objects. |
| 217 | 217 | */ |
| 218 | -function wl_core_get_related_entity_ids( $subject_id, $filters = array() ) { |
|
| 218 | +function wl_core_get_related_entity_ids($subject_id, $filters = array()) { |
|
| 219 | 219 | |
| 220 | - $status = isset( $filters['status'] ) ? $filters['status'] : null; |
|
| 221 | - $predicate = isset( $filters['predicate'] ) ? $filters['predicate'] : null; |
|
| 220 | + $status = isset($filters['status']) ? $filters['status'] : null; |
|
| 221 | + $predicate = isset($filters['predicate']) ? $filters['predicate'] : null; |
|
| 222 | 222 | |
| 223 | - return Wordlift_Relation_Service::get_instance()->get_objects( $subject_id, 'ids', $predicate, $status ); |
|
| 223 | + return Wordlift_Relation_Service::get_instance()->get_objects($subject_id, 'ids', $predicate, $status); |
|
| 224 | 224 | |
| 225 | 225 | // $filters = wl_core_validate_filters_for_related( $filters ); |
| 226 | 226 | // |
@@ -239,13 +239,13 @@ discard block |
||
| 239 | 239 | * |
| 240 | 240 | * @return array An array of {@link WP_Post}s. |
| 241 | 241 | */ |
| 242 | -function wl_core_get_related_entities( $subject_id, $filters = array() ) { |
|
| 242 | +function wl_core_get_related_entities($subject_id, $filters = array()) { |
|
| 243 | 243 | |
| 244 | - $ids = wl_core_get_related_entity_ids( $subject_id, $filters ); |
|
| 244 | + $ids = wl_core_get_related_entity_ids($subject_id, $filters); |
|
| 245 | 245 | |
| 246 | - return array_map( function ( $item ) { |
|
| 247 | - return get_post( $item ); |
|
| 248 | - }, $ids ); |
|
| 246 | + return array_map(function($item) { |
|
| 247 | + return get_post($item); |
|
| 248 | + }, $ids); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | // |
@@ -321,14 +321,14 @@ discard block |
||
| 321 | 321 | * |
| 322 | 322 | * @return array Array of objects. |
| 323 | 323 | */ |
| 324 | -function wl_core_get_related_post_ids( $object_id, $filters = array() ) { |
|
| 324 | +function wl_core_get_related_post_ids($object_id, $filters = array()) { |
|
| 325 | 325 | |
| 326 | 326 | $relation_service = Wordlift_Relation_Service::get_instance(); |
| 327 | 327 | |
| 328 | - $status = isset( $filters['status'] ) ? $filters['status'] : null; |
|
| 329 | - $predicate = isset( $filters['predicate'] ) ? $filters['predicate'] : null; |
|
| 328 | + $status = isset($filters['status']) ? $filters['status'] : null; |
|
| 329 | + $predicate = isset($filters['predicate']) ? $filters['predicate'] : null; |
|
| 330 | 330 | |
| 331 | - return $relation_service->get_article_subjects( $object_id, 'ids', $predicate, $status ); |
|
| 331 | + return $relation_service->get_article_subjects($object_id, 'ids', $predicate, $status); |
|
| 332 | 332 | // |
| 333 | 333 | // $filters = wl_core_validate_filters_for_related( $filters ); |
| 334 | 334 | // |
@@ -350,13 +350,13 @@ discard block |
||
| 350 | 350 | * |
| 351 | 351 | * @return array An array of {@link WP_Post}s. |
| 352 | 352 | */ |
| 353 | -function wl_core_get_related_posts( $subject_id, $filters = array() ) { |
|
| 353 | +function wl_core_get_related_posts($subject_id, $filters = array()) { |
|
| 354 | 354 | |
| 355 | - $ids = wl_core_get_related_post_ids( $subject_id, $filters ); |
|
| 355 | + $ids = wl_core_get_related_post_ids($subject_id, $filters); |
|
| 356 | 356 | |
| 357 | - return array_map( function ( $item ) { |
|
| 358 | - return get_post( $item ); |
|
| 359 | - }, $ids ); |
|
| 357 | + return array_map(function($item) { |
|
| 358 | + return get_post($item); |
|
| 359 | + }, $ids); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | ///** |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | * |
| 440 | 440 | * @return string|false String representing a sql statement, or false in case of error |
| 441 | 441 | */ |
| 442 | -function wl_core_sql_query_builder( $args ) { |
|
| 442 | +function wl_core_sql_query_builder($args) { |
|
| 443 | 443 | |
| 444 | 444 | // Prepare interaction with db |
| 445 | 445 | global $wpdb; |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | // Since we want Find only articles, based on the entity type, we need |
| 456 | 456 | // to figure out the relevant sql statements to add to the join and where |
| 457 | 457 | // parts. |
| 458 | - if ( 'entity' === $args['post_type'] ) { |
|
| 458 | + if ('entity' === $args['post_type']) { |
|
| 459 | 459 | $tax_query = array( |
| 460 | 460 | 'relation' => 'AND', |
| 461 | 461 | array( |
@@ -486,12 +486,12 @@ discard block |
||
| 486 | 486 | |
| 487 | 487 | |
| 488 | 488 | // Use "p" as the table to match the initial join. |
| 489 | - $tax_sql = get_tax_sql( $tax_query, 'p', 'ID' ); |
|
| 489 | + $tax_sql = get_tax_sql($tax_query, 'p', 'ID'); |
|
| 490 | 490 | |
| 491 | 491 | // Sql Action |
| 492 | 492 | $sql = 'SELECT '; |
| 493 | 493 | // Determine what has to be returned depending on 'get' argument value |
| 494 | - switch ( $args['get'] ) { |
|
| 494 | + switch ($args['get']) { |
|
| 495 | 495 | case 'posts': |
| 496 | 496 | $sql .= 'p.*'; |
| 497 | 497 | break; |
@@ -501,20 +501,20 @@ discard block |
||
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | // If we look for posts related as objects the JOIN has to be done with the object_id column and viceversa |
| 504 | - $join_column = $args['as'] . '_id'; |
|
| 504 | + $join_column = $args['as'].'_id'; |
|
| 505 | 505 | |
| 506 | 506 | $sql .= " FROM $wpdb->posts as p JOIN $table_name as r ON p.id = r.$join_column"; |
| 507 | 507 | |
| 508 | 508 | // Changing left join generate by the tax query into an inner since the term relationship has to exist. |
| 509 | - $sql .= str_replace( 'LEFT JOIN', 'INNER JOIN', $tax_sql['join'] ); |
|
| 509 | + $sql .= str_replace('LEFT JOIN', 'INNER JOIN', $tax_sql['join']); |
|
| 510 | 510 | |
| 511 | 511 | // Sql add post type filter |
| 512 | 512 | $post_types = Wordlift_Entity_Service::valid_entity_post_types(); |
| 513 | - $sql .= " AND p.post_type IN ('" . join( "', '", esc_sql( $post_types ) ) . "') AND"; |
|
| 513 | + $sql .= " AND p.post_type IN ('".join("', '", esc_sql($post_types))."') AND"; |
|
| 514 | 514 | |
| 515 | 515 | // Sql add post status filter |
| 516 | - if ( isset( $args['post_status'] ) && ! is_null( $args['post_status'] ) ) { |
|
| 517 | - $sql .= $wpdb->prepare( ' p.post_status = %s AND', $args['post_status'] ); |
|
| 516 | + if (isset($args['post_status']) && ! is_null($args['post_status'])) { |
|
| 517 | + $sql .= $wpdb->prepare(' p.post_status = %s AND', $args['post_status']); |
|
| 518 | 518 | } |
| 519 | 519 | |
| 520 | 520 | // Add filtering conditions |
@@ -523,29 +523,29 @@ discard block |
||
| 523 | 523 | // If we look for posts related as subject this means that |
| 524 | 524 | // related_to is reference for an object: object_id is the filtering column |
| 525 | 525 | |
| 526 | - $filtering_column = ( 'object' == $args['as'] ) ? 'subject_id' : 'object_id'; |
|
| 526 | + $filtering_column = ('object' == $args['as']) ? 'subject_id' : 'object_id'; |
|
| 527 | 527 | |
| 528 | - if ( isset( $args['related_to'] ) ) { |
|
| 529 | - $sql .= $wpdb->prepare( " r.$filtering_column = %d", $args['related_to'] ); |
|
| 528 | + if (isset($args['related_to'])) { |
|
| 529 | + $sql .= $wpdb->prepare(" r.$filtering_column = %d", $args['related_to']); |
|
| 530 | 530 | } |
| 531 | - if ( isset( $args['related_to'] ) && isset( $args['related_to__in'] ) ) { |
|
| 531 | + if (isset($args['related_to']) && isset($args['related_to__in'])) { |
|
| 532 | 532 | $sql .= ' AND'; |
| 533 | 533 | } |
| 534 | - if ( isset( $args['related_to__in'] ) ) { |
|
| 535 | - $sql .= " r.$filtering_column IN (" . implode( ',', $args['related_to__in'] ) . ')'; |
|
| 534 | + if (isset($args['related_to__in'])) { |
|
| 535 | + $sql .= " r.$filtering_column IN (".implode(',', $args['related_to__in']).')'; |
|
| 536 | 536 | // The IDs used for filtering shouldn't be in the results. |
| 537 | - $sql .= " AND p.ID NOT IN (" . implode( ',', $args['related_to__in'] ) . ')'; |
|
| 537 | + $sql .= " AND p.ID NOT IN (".implode(',', $args['related_to__in']).')'; |
|
| 538 | 538 | } |
| 539 | - if ( isset( $args['post__not_in'] ) ) { |
|
| 540 | - $sql .= ' AND r.' . $args['as'] . '_id NOT IN (' . implode( ',', $args['post__not_in'] ) . ')'; |
|
| 539 | + if (isset($args['post__not_in'])) { |
|
| 540 | + $sql .= ' AND r.'.$args['as'].'_id NOT IN ('.implode(',', $args['post__not_in']).')'; |
|
| 541 | 541 | } |
| 542 | - if ( isset( $args['post__in'] ) ) { |
|
| 543 | - $sql .= ' AND r.' . $args['as'] . '_id IN (' . implode( ',', $args['post__in'] ) . ')'; |
|
| 542 | + if (isset($args['post__in'])) { |
|
| 543 | + $sql .= ' AND r.'.$args['as'].'_id IN ('.implode(',', $args['post__in']).')'; |
|
| 544 | 544 | } |
| 545 | 545 | // Add predicate filter if required. |
| 546 | - if ( isset( $args['with_predicate'] ) ) { |
|
| 546 | + if (isset($args['with_predicate'])) { |
|
| 547 | 547 | // Sql Inner Join clause. |
| 548 | - $sql .= $wpdb->prepare( ' AND r.predicate = %s', $args['with_predicate'] ); |
|
| 548 | + $sql .= $wpdb->prepare(' AND r.predicate = %s', $args['with_predicate']); |
|
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | // Add the taxonomy related sql. |
@@ -556,9 +556,9 @@ discard block |
||
| 556 | 556 | $sql .= ' GROUP BY p.id'; |
| 557 | 557 | |
| 558 | 558 | // @todo: how does `first` represent the limit? |
| 559 | - if ( isset( $args['first'] ) && is_numeric( $args['first'] ) ) { |
|
| 559 | + if (isset($args['first']) && is_numeric($args['first'])) { |
|
| 560 | 560 | // Sql Inner Join clause. |
| 561 | - $sql .= $wpdb->prepare( ' LIMIT %d', $args['first'] ); |
|
| 561 | + $sql .= $wpdb->prepare(' LIMIT %d', $args['first']); |
|
| 562 | 562 | } |
| 563 | 563 | // Close sql statement |
| 564 | 564 | $sql .= ';'; |
@@ -579,23 +579,23 @@ discard block |
||
| 579 | 579 | * |
| 580 | 580 | * @return array|false List of WP_Post objects or list of WP_Post ids. False in case of error or invalid params |
| 581 | 581 | */ |
| 582 | -function wl_core_get_posts( $args, $returned_type = OBJECT ) { |
|
| 582 | +function wl_core_get_posts($args, $returned_type = OBJECT) { |
|
| 583 | 583 | |
| 584 | 584 | // Merge given args with defaults args value |
| 585 | - $args = array_merge( array( |
|
| 585 | + $args = array_merge(array( |
|
| 586 | 586 | 'with_predicate' => null, |
| 587 | 587 | 'as' => 'subject', |
| 588 | 588 | 'post_type' => 'post', |
| 589 | 589 | 'get' => 'posts', |
| 590 | 590 | 'post_status' => null, |
| 591 | - ), $args ); |
|
| 591 | + ), $args); |
|
| 592 | 592 | |
| 593 | 593 | // Arguments validation rules |
| 594 | 594 | // At least one between related_to and related_to__in has to be set |
| 595 | - if ( ! isset( $args['related_to'] ) && ! isset( $args['related_to__in'] ) ) { |
|
| 595 | + if ( ! isset($args['related_to']) && ! isset($args['related_to__in'])) { |
|
| 596 | 596 | return false; |
| 597 | 597 | } |
| 598 | - if ( isset( $args['related_to'] ) && ! is_numeric( $args['related_to'] ) ) { |
|
| 598 | + if (isset($args['related_to']) && ! is_numeric($args['related_to'])) { |
|
| 599 | 599 | return false; |
| 600 | 600 | } |
| 601 | 601 | |
@@ -609,18 +609,18 @@ discard block |
||
| 609 | 609 | 'related_to__in', |
| 610 | 610 | ) as $option_name |
| 611 | 611 | ) { |
| 612 | - if ( isset( $args[ $option_name ] ) ) { |
|
| 613 | - if ( ! is_array( $args[ $option_name ] ) || 0 == count( array_filter( $args[ $option_name ], "is_numeric" ) ) ) { |
|
| 612 | + if (isset($args[$option_name])) { |
|
| 613 | + if ( ! is_array($args[$option_name]) || 0 == count(array_filter($args[$option_name], "is_numeric"))) { |
|
| 614 | 614 | return false; |
| 615 | 615 | } |
| 616 | 616 | // Sanitize value removing non numeric values from the array |
| 617 | - $args[ $option_name ] = array_filter( $args[ $option_name ], "is_numeric" ); |
|
| 617 | + $args[$option_name] = array_filter($args[$option_name], "is_numeric"); |
|
| 618 | 618 | } |
| 619 | 619 | } |
| 620 | 620 | // Performing validation rules |
| 621 | - foreach ( wl_core_get_validation_rules() as $option_name => $accepeted_values ) { |
|
| 622 | - if ( isset( $args[ $option_name ] ) && ! is_null( $args[ $option_name ] ) ) { |
|
| 623 | - if ( ! in_array( $args[ $option_name ], $accepeted_values ) ) { |
|
| 621 | + foreach (wl_core_get_validation_rules() as $option_name => $accepeted_values) { |
|
| 622 | + if (isset($args[$option_name]) && ! is_null($args[$option_name])) { |
|
| 623 | + if ( ! in_array($args[$option_name], $accepeted_values)) { |
|
| 624 | 624 | return false; |
| 625 | 625 | } |
| 626 | 626 | } |
@@ -630,18 +630,18 @@ discard block |
||
| 630 | 630 | global $wpdb; |
| 631 | 631 | |
| 632 | 632 | // Build sql statement with given arguments |
| 633 | - $sql_statement = wl_core_sql_query_builder( $args ); |
|
| 633 | + $sql_statement = wl_core_sql_query_builder($args); |
|
| 634 | 634 | |
| 635 | 635 | // If ids are required, returns a one-dimensional array containing ids. |
| 636 | 636 | // Otherwise an array of associative arrays representing the post | relation object |
| 637 | - if ( 'post_ids' == $args['get'] ) { |
|
| 637 | + if ('post_ids' == $args['get']) { |
|
| 638 | 638 | # See https://codex.wordpress.org/Class_Reference/wpdb#SELECT_a_Column |
| 639 | - $results = $wpdb->get_col( $sql_statement ); |
|
| 639 | + $results = $wpdb->get_col($sql_statement); |
|
| 640 | 640 | } else { |
| 641 | - $results = $wpdb->get_results( $sql_statement, $returned_type ); |
|
| 641 | + $results = $wpdb->get_results($sql_statement, $returned_type); |
|
| 642 | 642 | } |
| 643 | 643 | // If there were an error performing the query then false is returned |
| 644 | - if ( ! empty( $wpdb->last_error ) ) { |
|
| 644 | + if ( ! empty($wpdb->last_error)) { |
|
| 645 | 645 | return false; |
| 646 | 646 | } |
| 647 | 647 | |
@@ -18,38 +18,38 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | function wl_linked_data_save_post( $post_id ) { |
| 20 | 20 | |
| 21 | - $log = Wordlift_Log_Service::get_logger( 'wl_linked_data_save_post' ); |
|
| 21 | + $log = Wordlift_Log_Service::get_logger( 'wl_linked_data_save_post' ); |
|
| 22 | 22 | |
| 23 | - $log->trace( "Saving post $post_id to Linked Data..." ); |
|
| 23 | + $log->trace( "Saving post $post_id to Linked Data..." ); |
|
| 24 | 24 | |
| 25 | - // If it's not numeric exit from here. |
|
| 26 | - if ( ! is_numeric( $post_id ) || is_numeric( wp_is_post_revision( $post_id ) ) ) { |
|
| 27 | - $log->debug( "Skipping $post_id, because id is not numeric or is a post revision." ); |
|
| 25 | + // If it's not numeric exit from here. |
|
| 26 | + if ( ! is_numeric( $post_id ) || is_numeric( wp_is_post_revision( $post_id ) ) ) { |
|
| 27 | + $log->debug( "Skipping $post_id, because id is not numeric or is a post revision." ); |
|
| 28 | 28 | |
| 29 | - return; |
|
| 30 | - } |
|
| 29 | + return; |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - // Get the post type and check whether it supports the editor. |
|
| 33 | - // |
|
| 34 | - // See https://github.com/insideout10/wordlift-plugin/issues/659. |
|
| 35 | - $post_type = get_post_type( $post_id ); |
|
| 36 | - $is_editor_supported = post_type_supports( $post_type, 'editor' ); |
|
| 32 | + // Get the post type and check whether it supports the editor. |
|
| 33 | + // |
|
| 34 | + // See https://github.com/insideout10/wordlift-plugin/issues/659. |
|
| 35 | + $post_type = get_post_type( $post_id ); |
|
| 36 | + $is_editor_supported = post_type_supports( $post_type, 'editor' ); |
|
| 37 | 37 | |
| 38 | - // Bail out if it's not an entity. |
|
| 39 | - if ( ! $is_editor_supported ) { |
|
| 40 | - $log->debug( "Skipping $post_id, because $post_type doesn't support the editor (content)." ); |
|
| 38 | + // Bail out if it's not an entity. |
|
| 39 | + if ( ! $is_editor_supported ) { |
|
| 40 | + $log->debug( "Skipping $post_id, because $post_type doesn't support the editor (content)." ); |
|
| 41 | 41 | |
| 42 | - return; |
|
| 43 | - } |
|
| 42 | + return; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - // Unhook this function so it doesn't loop infinitely. |
|
| 46 | - remove_action( 'save_post', 'wl_linked_data_save_post' ); |
|
| 45 | + // Unhook this function so it doesn't loop infinitely. |
|
| 46 | + remove_action( 'save_post', 'wl_linked_data_save_post' ); |
|
| 47 | 47 | |
| 48 | - // raise the *wl_linked_data_save_post* event. |
|
| 49 | - do_action( 'wl_linked_data_save_post', $post_id ); |
|
| 48 | + // raise the *wl_linked_data_save_post* event. |
|
| 49 | + do_action( 'wl_linked_data_save_post', $post_id ); |
|
| 50 | 50 | |
| 51 | - // Re-hook this function. |
|
| 52 | - add_action( 'save_post', 'wl_linked_data_save_post' ); |
|
| 51 | + // Re-hook this function. |
|
| 52 | + add_action( 'save_post', 'wl_linked_data_save_post' ); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | add_action( 'save_post', 'wl_linked_data_save_post' ); |
@@ -63,156 +63,156 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | function wl_linked_data_save_post_and_related_entities( $post_id ) { |
| 65 | 65 | |
| 66 | - $log = Wordlift_Log_Service::get_logger( 'wl_linked_data_save_post_and_related_entities' ); |
|
| 66 | + $log = Wordlift_Log_Service::get_logger( 'wl_linked_data_save_post_and_related_entities' ); |
|
| 67 | 67 | |
| 68 | - $log->trace( "Saving $post_id to Linked Data along with related entities..." ); |
|
| 68 | + $log->trace( "Saving $post_id to Linked Data along with related entities..." ); |
|
| 69 | 69 | |
| 70 | - // Ignore auto-saves |
|
| 71 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
| 72 | - $log->trace( 'Doing autosave, skipping...' ); |
|
| 70 | + // Ignore auto-saves |
|
| 71 | + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
| 72 | + $log->trace( 'Doing autosave, skipping...' ); |
|
| 73 | 73 | |
| 74 | - return; |
|
| 75 | - } |
|
| 74 | + return; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - // get the current post. |
|
| 78 | - $post = get_post( $post_id ); |
|
| 77 | + // get the current post. |
|
| 78 | + $post = get_post( $post_id ); |
|
| 79 | 79 | |
| 80 | - remove_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' ); |
|
| 80 | + remove_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' ); |
|
| 81 | 81 | |
| 82 | - // wl_write_log( "[ post id :: $post_id ][ autosave :: false ][ post type :: $post->post_type ]" ); |
|
| 82 | + // wl_write_log( "[ post id :: $post_id ][ autosave :: false ][ post type :: $post->post_type ]" ); |
|
| 83 | 83 | |
| 84 | - // Get the entity service instance. |
|
| 85 | - $entity_service = Wordlift_Entity_Service::get_instance(); |
|
| 84 | + // Get the entity service instance. |
|
| 85 | + $entity_service = Wordlift_Entity_Service::get_instance(); |
|
| 86 | 86 | |
| 87 | - // Store mapping between tmp new entities uris and real new entities uri |
|
| 88 | - $entities_uri_mapping = array(); |
|
| 87 | + // Store mapping between tmp new entities uris and real new entities uri |
|
| 88 | + $entities_uri_mapping = array(); |
|
| 89 | 89 | |
| 90 | - // Save the entities coming with POST data. |
|
| 91 | - if ( isset( $_POST['wl_entities'] ) && isset( $_POST['wl_boxes'] ) ) { |
|
| 90 | + // Save the entities coming with POST data. |
|
| 91 | + if ( isset( $_POST['wl_entities'] ) && isset( $_POST['wl_boxes'] ) ) { |
|
| 92 | 92 | |
| 93 | - wl_write_log( "[ post id :: $post_id ][ POST(wl_entities) :: " ); |
|
| 94 | - wl_write_log( json_encode( $_POST['wl_entities'] ) ); |
|
| 95 | - wl_write_log( "]" ); |
|
| 96 | - wl_write_log( "[ post id :: $post_id ][ POST(wl_boxes) :: " ); |
|
| 97 | - wl_write_log( json_encode( $_POST['wl_boxes'], true ) ); |
|
| 98 | - wl_write_log( "]" ); |
|
| 93 | + wl_write_log( "[ post id :: $post_id ][ POST(wl_entities) :: " ); |
|
| 94 | + wl_write_log( json_encode( $_POST['wl_entities'] ) ); |
|
| 95 | + wl_write_log( "]" ); |
|
| 96 | + wl_write_log( "[ post id :: $post_id ][ POST(wl_boxes) :: " ); |
|
| 97 | + wl_write_log( json_encode( $_POST['wl_boxes'], true ) ); |
|
| 98 | + wl_write_log( "]" ); |
|
| 99 | 99 | |
| 100 | - $entities_via_post = $_POST['wl_entities']; |
|
| 101 | - $boxes_via_post = $_POST['wl_boxes']; |
|
| 100 | + $entities_via_post = $_POST['wl_entities']; |
|
| 101 | + $boxes_via_post = $_POST['wl_boxes']; |
|
| 102 | 102 | |
| 103 | - foreach ( $entities_via_post as $entity_uri => $entity ) { |
|
| 103 | + foreach ( $entities_via_post as $entity_uri => $entity ) { |
|
| 104 | 104 | |
| 105 | - // Only if the current entity is created from scratch let's avoid to |
|
| 106 | - // create more than one entity with same label & entity type. |
|
| 107 | - $entity_type = ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) ? |
|
| 108 | - $entity['main_type'] : null; |
|
| 105 | + // Only if the current entity is created from scratch let's avoid to |
|
| 106 | + // create more than one entity with same label & entity type. |
|
| 107 | + $entity_type = ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) ? |
|
| 108 | + $entity['main_type'] : null; |
|
| 109 | 109 | |
| 110 | - // Look if current entity uri matches an internal existing entity, meaning: |
|
| 111 | - // 1. when $entity_uri is an internal uri |
|
| 112 | - // 2. when $entity_uri is an external uri used as sameAs of an internal entity |
|
| 113 | - $ie = $entity_service->get_entity_post_by_uri( $entity_uri ); |
|
| 110 | + // Look if current entity uri matches an internal existing entity, meaning: |
|
| 111 | + // 1. when $entity_uri is an internal uri |
|
| 112 | + // 2. when $entity_uri is an external uri used as sameAs of an internal entity |
|
| 113 | + $ie = $entity_service->get_entity_post_by_uri( $entity_uri ); |
|
| 114 | 114 | |
| 115 | - // Detect the uri depending if is an existing or a new entity |
|
| 116 | - $uri = ( null === $ie ) ? |
|
| 117 | - Wordlift_Uri_Service::get_instance()->build_uri( |
|
| 118 | - $entity['label'], |
|
| 119 | - Wordlift_Entity_Service::TYPE_NAME, |
|
| 120 | - $entity_type |
|
| 121 | - ) : wl_get_entity_uri( $ie->ID ); |
|
| 115 | + // Detect the uri depending if is an existing or a new entity |
|
| 116 | + $uri = ( null === $ie ) ? |
|
| 117 | + Wordlift_Uri_Service::get_instance()->build_uri( |
|
| 118 | + $entity['label'], |
|
| 119 | + Wordlift_Entity_Service::TYPE_NAME, |
|
| 120 | + $entity_type |
|
| 121 | + ) : wl_get_entity_uri( $ie->ID ); |
|
| 122 | 122 | |
| 123 | - wl_write_log( "Map $entity_uri on $uri" ); |
|
| 124 | - $entities_uri_mapping[ $entity_uri ] = $uri; |
|
| 123 | + wl_write_log( "Map $entity_uri on $uri" ); |
|
| 124 | + $entities_uri_mapping[ $entity_uri ] = $uri; |
|
| 125 | 125 | |
| 126 | - // Local entities have a tmp uri with 'local-entity-' prefix |
|
| 127 | - // These uris need to be rewritten here and replaced in the content |
|
| 128 | - if ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) { |
|
| 129 | - // Override the entity obj |
|
| 130 | - $entity['uri'] = $uri; |
|
| 131 | - } |
|
| 126 | + // Local entities have a tmp uri with 'local-entity-' prefix |
|
| 127 | + // These uris need to be rewritten here and replaced in the content |
|
| 128 | + if ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) { |
|
| 129 | + // Override the entity obj |
|
| 130 | + $entity['uri'] = $uri; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - // Update entity data with related post |
|
| 134 | - $entity['related_post_id'] = $post_id; |
|
| 133 | + // Update entity data with related post |
|
| 134 | + $entity['related_post_id'] = $post_id; |
|
| 135 | 135 | |
| 136 | - // Save the entity if is a new entity |
|
| 137 | - if ( null === $ie ) { |
|
| 138 | - wl_save_entity( $entity ); |
|
| 139 | - } |
|
| 136 | + // Save the entity if is a new entity |
|
| 137 | + if ( null === $ie ) { |
|
| 138 | + wl_save_entity( $entity ); |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | - } |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - } |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - // Replace tmp uris in content post if needed |
|
| 146 | - $updated_post_content = $post->post_content; |
|
| 145 | + // Replace tmp uris in content post if needed |
|
| 146 | + $updated_post_content = $post->post_content; |
|
| 147 | 147 | |
| 148 | - // Update the post content if we found mappings of new entities. |
|
| 149 | - if ( ! empty( $entities_uri_mapping ) ) { |
|
| 150 | - // Save each entity and store the post id. |
|
| 151 | - foreach ( $entities_uri_mapping as $tmp_uri => $uri ) { |
|
| 152 | - $updated_post_content = str_replace( $tmp_uri, $uri, $updated_post_content ); |
|
| 153 | - } |
|
| 148 | + // Update the post content if we found mappings of new entities. |
|
| 149 | + if ( ! empty( $entities_uri_mapping ) ) { |
|
| 150 | + // Save each entity and store the post id. |
|
| 151 | + foreach ( $entities_uri_mapping as $tmp_uri => $uri ) { |
|
| 152 | + $updated_post_content = str_replace( $tmp_uri, $uri, $updated_post_content ); |
|
| 153 | + } |
|
| 154 | 154 | |
| 155 | - // Update the post content. |
|
| 156 | - wp_update_post( array( |
|
| 157 | - 'ID' => $post->ID, |
|
| 158 | - 'post_content' => $updated_post_content, |
|
| 159 | - ) ); |
|
| 160 | - } |
|
| 155 | + // Update the post content. |
|
| 156 | + wp_update_post( array( |
|
| 157 | + 'ID' => $post->ID, |
|
| 158 | + 'post_content' => $updated_post_content, |
|
| 159 | + ) ); |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - // Extract related/referenced entities from text. |
|
| 163 | - $disambiguated_entities = wl_linked_data_content_get_embedded_entities( $updated_post_content ); |
|
| 162 | + // Extract related/referenced entities from text. |
|
| 163 | + $disambiguated_entities = wl_linked_data_content_get_embedded_entities( $updated_post_content ); |
|
| 164 | 164 | |
| 165 | - // Reset previously saved instances. |
|
| 166 | - wl_core_delete_relation_instances( $post_id ); |
|
| 165 | + // Reset previously saved instances. |
|
| 166 | + wl_core_delete_relation_instances( $post_id ); |
|
| 167 | 167 | |
| 168 | - // Save relation instances |
|
| 169 | - foreach ( array_unique( $disambiguated_entities ) as $referenced_entity_id ) { |
|
| 168 | + // Save relation instances |
|
| 169 | + foreach ( array_unique( $disambiguated_entities ) as $referenced_entity_id ) { |
|
| 170 | 170 | |
| 171 | - wl_core_add_relation_instance( |
|
| 172 | - $post_id, |
|
| 173 | - $entity_service->get_classification_scope_for( $referenced_entity_id ), |
|
| 174 | - $referenced_entity_id |
|
| 175 | - ); |
|
| 171 | + wl_core_add_relation_instance( |
|
| 172 | + $post_id, |
|
| 173 | + $entity_service->get_classification_scope_for( $referenced_entity_id ), |
|
| 174 | + $referenced_entity_id |
|
| 175 | + ); |
|
| 176 | 176 | |
| 177 | - } |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - if ( isset( $_POST['wl_entities'] ) ) { |
|
| 180 | - // Save post metadata if available |
|
| 181 | - $metadata_via_post = ( isset( $_POST['wl_metadata'] ) ) ? |
|
| 182 | - $_POST['wl_metadata'] : array(); |
|
| 183 | - |
|
| 184 | - $fields = array( |
|
| 185 | - Wordlift_Schema_Service::FIELD_LOCATION_CREATED, |
|
| 186 | - Wordlift_Schema_Service::FIELD_TOPIC, |
|
| 187 | - ); |
|
| 188 | - |
|
| 189 | - // Unlink topic taxonomy terms |
|
| 190 | - Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for( $post->ID ); |
|
| 191 | - |
|
| 192 | - foreach ( $fields as $field ) { |
|
| 193 | - |
|
| 194 | - // Delete current values |
|
| 195 | - delete_post_meta( $post->ID, $field ); |
|
| 196 | - // Retrieve the entity uri |
|
| 197 | - $uri = ( isset( $metadata_via_post[ $field ] ) ) ? |
|
| 198 | - stripslashes( $metadata_via_post[ $field ] ) : ''; |
|
| 199 | - |
|
| 200 | - $entity = $entity_service->get_entity_post_by_uri( $uri ); |
|
| 201 | - |
|
| 202 | - if ( $entity ) { |
|
| 203 | - add_post_meta( $post->ID, $field, $entity->ID, true ); |
|
| 204 | - // Set also the topic taxonomy |
|
| 205 | - if ( $field === Wordlift_Schema_Service::FIELD_TOPIC ) { |
|
| 206 | - Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for( $post->ID, $entity ); |
|
| 207 | - } |
|
| 208 | - } |
|
| 209 | - } |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - // Push the post to Redlink. |
|
| 213 | - Wordlift_Linked_Data_Service::get_instance()->push( $post->ID ); |
|
| 214 | - |
|
| 215 | - add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' ); |
|
| 179 | + if ( isset( $_POST['wl_entities'] ) ) { |
|
| 180 | + // Save post metadata if available |
|
| 181 | + $metadata_via_post = ( isset( $_POST['wl_metadata'] ) ) ? |
|
| 182 | + $_POST['wl_metadata'] : array(); |
|
| 183 | + |
|
| 184 | + $fields = array( |
|
| 185 | + Wordlift_Schema_Service::FIELD_LOCATION_CREATED, |
|
| 186 | + Wordlift_Schema_Service::FIELD_TOPIC, |
|
| 187 | + ); |
|
| 188 | + |
|
| 189 | + // Unlink topic taxonomy terms |
|
| 190 | + Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for( $post->ID ); |
|
| 191 | + |
|
| 192 | + foreach ( $fields as $field ) { |
|
| 193 | + |
|
| 194 | + // Delete current values |
|
| 195 | + delete_post_meta( $post->ID, $field ); |
|
| 196 | + // Retrieve the entity uri |
|
| 197 | + $uri = ( isset( $metadata_via_post[ $field ] ) ) ? |
|
| 198 | + stripslashes( $metadata_via_post[ $field ] ) : ''; |
|
| 199 | + |
|
| 200 | + $entity = $entity_service->get_entity_post_by_uri( $uri ); |
|
| 201 | + |
|
| 202 | + if ( $entity ) { |
|
| 203 | + add_post_meta( $post->ID, $field, $entity->ID, true ); |
|
| 204 | + // Set also the topic taxonomy |
|
| 205 | + if ( $field === Wordlift_Schema_Service::FIELD_TOPIC ) { |
|
| 206 | + Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for( $post->ID, $entity ); |
|
| 207 | + } |
|
| 208 | + } |
|
| 209 | + } |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + // Push the post to Redlink. |
|
| 213 | + Wordlift_Linked_Data_Service::get_instance()->push( $post->ID ); |
|
| 214 | + |
|
| 215 | + add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' ); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' ); |
@@ -235,192 +235,192 @@ discard block |
||
| 235 | 235 | */ |
| 236 | 236 | function wl_save_entity( $entity_data ) { |
| 237 | 237 | |
| 238 | - $log = Wordlift_Log_Service::get_logger( 'wl_save_entity' ); |
|
| 239 | - |
|
| 240 | - $uri = $entity_data['uri']; |
|
| 241 | - $label = $entity_data['label']; |
|
| 242 | - $type_uri = $entity_data['main_type']; |
|
| 243 | - $entity_types = isset( $entity_data['type'] ) ? $entity_data['type'] : array(); |
|
| 244 | - $description = $entity_data['description']; |
|
| 245 | - $images = isset( $entity_data['image'] ) ? (array) $entity_data['image'] : array(); |
|
| 246 | - $same_as = isset( $entity_data['sameas'] ) ? (array) $entity_data['sameas'] : array(); |
|
| 247 | - $related_post_id = isset( $entity_data['related_post_id'] ) ? $entity_data['related_post_id'] : null; |
|
| 248 | - $other_properties = isset( $entity_data['properties'] ) ? $entity_data['properties'] : array(); |
|
| 249 | - |
|
| 250 | - // Get the synonyms. |
|
| 251 | - $synonyms = isset( $entity_data['synonym'] ) ? $entity_data['synonym'] : array(); |
|
| 252 | - |
|
| 253 | - // Check whether an entity already exists with the provided URI. |
|
| 254 | - if ( null !== $post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri ) ) { |
|
| 255 | - $log->debug( "Post already exists for URI $uri." ); |
|
| 256 | - |
|
| 257 | - return $post; |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - // Prepare properties of the new entity. |
|
| 261 | - $params = array( |
|
| 262 | - 'post_status' => ( is_numeric( $related_post_id ) ? get_post_status( $related_post_id ) : 'draft' ), |
|
| 263 | - 'post_type' => Wordlift_Entity_Service::TYPE_NAME, |
|
| 264 | - 'post_title' => $label, |
|
| 265 | - 'post_content' => $description, |
|
| 266 | - 'post_excerpt' => '', |
|
| 267 | - // Ensure we're using a valid slug. We're not overwriting an existing |
|
| 268 | - // entity with a post_name already set, since this call is made only for |
|
| 269 | - // new entities. |
|
| 270 | - // |
|
| 271 | - // See https://github.com/insideout10/wordlift-plugin/issues/282 |
|
| 272 | - 'post_name' => sanitize_title( $label ), |
|
| 273 | - ); |
|
| 274 | - |
|
| 275 | - // If Yoast is installed and active, we temporary remove the save_postdata hook which causes Yoast to "pass over" |
|
| 276 | - // the local SEO form values to the created entity (https://github.com/insideout10/wordlift-plugin/issues/156) |
|
| 277 | - // Same thing applies to SEO Ultimate (https://github.com/insideout10/wordlift-plugin/issues/148) |
|
| 278 | - // This does NOT affect saving an entity from the entity admin page since this function is called when an entity |
|
| 279 | - // is created when saving a post. |
|
| 280 | - global $wpseo_metabox, $seo_ultimate; |
|
| 281 | - if ( isset( $wpseo_metabox ) ) { |
|
| 282 | - remove_action( 'wp_insert_post', array( |
|
| 283 | - $wpseo_metabox, |
|
| 284 | - 'save_postdata', |
|
| 285 | - ) ); |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - if ( isset( $seo_ultimate ) ) { |
|
| 289 | - remove_action( 'save_post', array( |
|
| 290 | - $seo_ultimate, |
|
| 291 | - 'save_postmeta_box', |
|
| 292 | - ) ); |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - // The fact that we're calling here wp_insert_post is causing issues with plugins (and ourselves too) that hook to |
|
| 296 | - // save_post in order to save additional inputs from the edit page. In order to avoid issues, we pop all the hooks |
|
| 297 | - // to the save_post and restore them after we saved the entity. |
|
| 298 | - // see https://github.com/insideout10/wordlift-plugin/issues/203 |
|
| 299 | - // see https://github.com/insideout10/wordlift-plugin/issues/156 |
|
| 300 | - // see https://github.com/insideout10/wordlift-plugin/issues/148 |
|
| 301 | - global $wp_filter; |
|
| 302 | - $save_post_filters = is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] : $wp_filter['save_post']->callbacks; |
|
| 303 | - is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = array() : $wp_filter['save_post']->remove_all_filters(); |
|
| 304 | - |
|
| 305 | - |
|
| 306 | - $log->trace( 'Going to insert new post...' ); |
|
| 307 | - |
|
| 308 | - // create or update the post. |
|
| 309 | - $post_id = wp_insert_post( $params, true ); |
|
| 310 | - |
|
| 311 | - // Setting the alternative labels for this entity. |
|
| 312 | - Wordlift_Entity_Service::get_instance() |
|
| 313 | - ->set_alternative_labels( $post_id, $synonyms ); |
|
| 314 | - |
|
| 315 | - // Restore all the existing filters. |
|
| 316 | - is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = $save_post_filters : $wp_filter['save_post']->callbacks = $save_post_filters; |
|
| 317 | - |
|
| 318 | - // If Yoast is installed and active, we restore the Yoast save_postdata hook (https://github.com/insideout10/wordlift-plugin/issues/156) |
|
| 319 | - if ( isset( $wpseo_metabox ) ) { |
|
| 320 | - add_action( 'wp_insert_post', array( |
|
| 321 | - $wpseo_metabox, |
|
| 322 | - 'save_postdata', |
|
| 323 | - ) ); |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - // If SEO Ultimate is installed, add back the hook we removed a few lines above. |
|
| 327 | - if ( isset( $seo_ultimate ) ) { |
|
| 328 | - add_action( 'save_post', array( |
|
| 329 | - $seo_ultimate, |
|
| 330 | - 'save_postmeta_box', |
|
| 331 | - ), 10, 2 ); |
|
| 332 | - } |
|
| 333 | - |
|
| 334 | - // TODO: handle errors. |
|
| 335 | - if ( is_wp_error( $post_id ) ) { |
|
| 336 | - $log->error( 'An error occurred: ' . $post_id->get_error_message() ); |
|
| 337 | - |
|
| 338 | - // inform an error occurred. |
|
| 339 | - return null; |
|
| 340 | - } |
|
| 341 | - |
|
| 342 | - wl_set_entity_main_type( $post_id, $type_uri ); |
|
| 343 | - |
|
| 344 | - // Save the entity types. |
|
| 345 | - wl_set_entity_rdf_types( $post_id, $entity_types ); |
|
| 346 | - |
|
| 347 | - // Get a dataset URI for the entity. |
|
| 348 | - $wl_uri = wl_build_entity_uri( $post_id ); |
|
| 349 | - |
|
| 350 | - // Save the entity URI. |
|
| 351 | - wl_set_entity_uri( $post_id, $wl_uri ); |
|
| 352 | - |
|
| 353 | - // Add the uri to the sameAs data if it's not a local URI. |
|
| 354 | - if ( $wl_uri !== $uri ) { |
|
| 355 | - array_push( $same_as, $uri ); |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - $new_uri = wl_get_entity_uri( $post_id ); |
|
| 359 | - |
|
| 360 | - // Save the sameAs data for the entity. |
|
| 361 | - wl_schema_set_value( $post_id, 'sameAs', $same_as ); |
|
| 362 | - |
|
| 363 | - // Save the other properties (latitude, langitude, startDate, endDate, etc.) |
|
| 364 | - foreach ( $other_properties as $property_name => $property_value ) { |
|
| 365 | - wl_schema_set_value( $post_id, $property_name, $property_value ); |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - // Call hooks. |
|
| 369 | - do_action( 'wl_save_entity', $post_id ); |
|
| 370 | - |
|
| 371 | - foreach ( $images as $image_remote_url ) { |
|
| 372 | - |
|
| 373 | - // Check if image is already present in local DB |
|
| 374 | - if ( strpos( $image_remote_url, site_url() ) !== false ) { |
|
| 375 | - // Do nothing. |
|
| 376 | - continue; |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - // Check if there is an existing attachment for this post ID and source URL. |
|
| 380 | - $existing_image = wl_get_attachment_for_source_url( $post_id, $image_remote_url ); |
|
| 381 | - |
|
| 382 | - // Skip if an existing image is found. |
|
| 383 | - if ( null !== $existing_image ) { |
|
| 384 | - continue; |
|
| 385 | - } |
|
| 386 | - |
|
| 387 | - // Save the image and get the local path. |
|
| 388 | - $image = wl_save_image( $image_remote_url ); |
|
| 389 | - |
|
| 390 | - // Get the local URL. |
|
| 391 | - $filename = $image['path']; |
|
| 392 | - $url = $image['url']; |
|
| 393 | - $content_type = $image['content_type']; |
|
| 238 | + $log = Wordlift_Log_Service::get_logger( 'wl_save_entity' ); |
|
| 239 | + |
|
| 240 | + $uri = $entity_data['uri']; |
|
| 241 | + $label = $entity_data['label']; |
|
| 242 | + $type_uri = $entity_data['main_type']; |
|
| 243 | + $entity_types = isset( $entity_data['type'] ) ? $entity_data['type'] : array(); |
|
| 244 | + $description = $entity_data['description']; |
|
| 245 | + $images = isset( $entity_data['image'] ) ? (array) $entity_data['image'] : array(); |
|
| 246 | + $same_as = isset( $entity_data['sameas'] ) ? (array) $entity_data['sameas'] : array(); |
|
| 247 | + $related_post_id = isset( $entity_data['related_post_id'] ) ? $entity_data['related_post_id'] : null; |
|
| 248 | + $other_properties = isset( $entity_data['properties'] ) ? $entity_data['properties'] : array(); |
|
| 249 | + |
|
| 250 | + // Get the synonyms. |
|
| 251 | + $synonyms = isset( $entity_data['synonym'] ) ? $entity_data['synonym'] : array(); |
|
| 252 | + |
|
| 253 | + // Check whether an entity already exists with the provided URI. |
|
| 254 | + if ( null !== $post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri ) ) { |
|
| 255 | + $log->debug( "Post already exists for URI $uri." ); |
|
| 256 | + |
|
| 257 | + return $post; |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + // Prepare properties of the new entity. |
|
| 261 | + $params = array( |
|
| 262 | + 'post_status' => ( is_numeric( $related_post_id ) ? get_post_status( $related_post_id ) : 'draft' ), |
|
| 263 | + 'post_type' => Wordlift_Entity_Service::TYPE_NAME, |
|
| 264 | + 'post_title' => $label, |
|
| 265 | + 'post_content' => $description, |
|
| 266 | + 'post_excerpt' => '', |
|
| 267 | + // Ensure we're using a valid slug. We're not overwriting an existing |
|
| 268 | + // entity with a post_name already set, since this call is made only for |
|
| 269 | + // new entities. |
|
| 270 | + // |
|
| 271 | + // See https://github.com/insideout10/wordlift-plugin/issues/282 |
|
| 272 | + 'post_name' => sanitize_title( $label ), |
|
| 273 | + ); |
|
| 274 | + |
|
| 275 | + // If Yoast is installed and active, we temporary remove the save_postdata hook which causes Yoast to "pass over" |
|
| 276 | + // the local SEO form values to the created entity (https://github.com/insideout10/wordlift-plugin/issues/156) |
|
| 277 | + // Same thing applies to SEO Ultimate (https://github.com/insideout10/wordlift-plugin/issues/148) |
|
| 278 | + // This does NOT affect saving an entity from the entity admin page since this function is called when an entity |
|
| 279 | + // is created when saving a post. |
|
| 280 | + global $wpseo_metabox, $seo_ultimate; |
|
| 281 | + if ( isset( $wpseo_metabox ) ) { |
|
| 282 | + remove_action( 'wp_insert_post', array( |
|
| 283 | + $wpseo_metabox, |
|
| 284 | + 'save_postdata', |
|
| 285 | + ) ); |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + if ( isset( $seo_ultimate ) ) { |
|
| 289 | + remove_action( 'save_post', array( |
|
| 290 | + $seo_ultimate, |
|
| 291 | + 'save_postmeta_box', |
|
| 292 | + ) ); |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + // The fact that we're calling here wp_insert_post is causing issues with plugins (and ourselves too) that hook to |
|
| 296 | + // save_post in order to save additional inputs from the edit page. In order to avoid issues, we pop all the hooks |
|
| 297 | + // to the save_post and restore them after we saved the entity. |
|
| 298 | + // see https://github.com/insideout10/wordlift-plugin/issues/203 |
|
| 299 | + // see https://github.com/insideout10/wordlift-plugin/issues/156 |
|
| 300 | + // see https://github.com/insideout10/wordlift-plugin/issues/148 |
|
| 301 | + global $wp_filter; |
|
| 302 | + $save_post_filters = is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] : $wp_filter['save_post']->callbacks; |
|
| 303 | + is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = array() : $wp_filter['save_post']->remove_all_filters(); |
|
| 304 | + |
|
| 305 | + |
|
| 306 | + $log->trace( 'Going to insert new post...' ); |
|
| 307 | + |
|
| 308 | + // create or update the post. |
|
| 309 | + $post_id = wp_insert_post( $params, true ); |
|
| 310 | + |
|
| 311 | + // Setting the alternative labels for this entity. |
|
| 312 | + Wordlift_Entity_Service::get_instance() |
|
| 313 | + ->set_alternative_labels( $post_id, $synonyms ); |
|
| 314 | + |
|
| 315 | + // Restore all the existing filters. |
|
| 316 | + is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = $save_post_filters : $wp_filter['save_post']->callbacks = $save_post_filters; |
|
| 317 | + |
|
| 318 | + // If Yoast is installed and active, we restore the Yoast save_postdata hook (https://github.com/insideout10/wordlift-plugin/issues/156) |
|
| 319 | + if ( isset( $wpseo_metabox ) ) { |
|
| 320 | + add_action( 'wp_insert_post', array( |
|
| 321 | + $wpseo_metabox, |
|
| 322 | + 'save_postdata', |
|
| 323 | + ) ); |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + // If SEO Ultimate is installed, add back the hook we removed a few lines above. |
|
| 327 | + if ( isset( $seo_ultimate ) ) { |
|
| 328 | + add_action( 'save_post', array( |
|
| 329 | + $seo_ultimate, |
|
| 330 | + 'save_postmeta_box', |
|
| 331 | + ), 10, 2 ); |
|
| 332 | + } |
|
| 333 | + |
|
| 334 | + // TODO: handle errors. |
|
| 335 | + if ( is_wp_error( $post_id ) ) { |
|
| 336 | + $log->error( 'An error occurred: ' . $post_id->get_error_message() ); |
|
| 337 | + |
|
| 338 | + // inform an error occurred. |
|
| 339 | + return null; |
|
| 340 | + } |
|
| 341 | + |
|
| 342 | + wl_set_entity_main_type( $post_id, $type_uri ); |
|
| 343 | + |
|
| 344 | + // Save the entity types. |
|
| 345 | + wl_set_entity_rdf_types( $post_id, $entity_types ); |
|
| 346 | + |
|
| 347 | + // Get a dataset URI for the entity. |
|
| 348 | + $wl_uri = wl_build_entity_uri( $post_id ); |
|
| 349 | + |
|
| 350 | + // Save the entity URI. |
|
| 351 | + wl_set_entity_uri( $post_id, $wl_uri ); |
|
| 352 | + |
|
| 353 | + // Add the uri to the sameAs data if it's not a local URI. |
|
| 354 | + if ( $wl_uri !== $uri ) { |
|
| 355 | + array_push( $same_as, $uri ); |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + $new_uri = wl_get_entity_uri( $post_id ); |
|
| 359 | + |
|
| 360 | + // Save the sameAs data for the entity. |
|
| 361 | + wl_schema_set_value( $post_id, 'sameAs', $same_as ); |
|
| 362 | + |
|
| 363 | + // Save the other properties (latitude, langitude, startDate, endDate, etc.) |
|
| 364 | + foreach ( $other_properties as $property_name => $property_value ) { |
|
| 365 | + wl_schema_set_value( $post_id, $property_name, $property_value ); |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + // Call hooks. |
|
| 369 | + do_action( 'wl_save_entity', $post_id ); |
|
| 370 | + |
|
| 371 | + foreach ( $images as $image_remote_url ) { |
|
| 372 | + |
|
| 373 | + // Check if image is already present in local DB |
|
| 374 | + if ( strpos( $image_remote_url, site_url() ) !== false ) { |
|
| 375 | + // Do nothing. |
|
| 376 | + continue; |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + // Check if there is an existing attachment for this post ID and source URL. |
|
| 380 | + $existing_image = wl_get_attachment_for_source_url( $post_id, $image_remote_url ); |
|
| 381 | + |
|
| 382 | + // Skip if an existing image is found. |
|
| 383 | + if ( null !== $existing_image ) { |
|
| 384 | + continue; |
|
| 385 | + } |
|
| 386 | + |
|
| 387 | + // Save the image and get the local path. |
|
| 388 | + $image = wl_save_image( $image_remote_url ); |
|
| 389 | + |
|
| 390 | + // Get the local URL. |
|
| 391 | + $filename = $image['path']; |
|
| 392 | + $url = $image['url']; |
|
| 393 | + $content_type = $image['content_type']; |
|
| 394 | 394 | |
| 395 | - $attachment = array( |
|
| 396 | - 'guid' => $url, |
|
| 397 | - // post_title, post_content (the value for this key should be the empty string), post_status and post_mime_type |
|
| 398 | - 'post_title' => $label, |
|
| 399 | - // Set the title to the post title. |
|
| 400 | - 'post_content' => '', |
|
| 401 | - 'post_status' => 'inherit', |
|
| 402 | - 'post_mime_type' => $content_type, |
|
| 403 | - ); |
|
| 395 | + $attachment = array( |
|
| 396 | + 'guid' => $url, |
|
| 397 | + // post_title, post_content (the value for this key should be the empty string), post_status and post_mime_type |
|
| 398 | + 'post_title' => $label, |
|
| 399 | + // Set the title to the post title. |
|
| 400 | + 'post_content' => '', |
|
| 401 | + 'post_status' => 'inherit', |
|
| 402 | + 'post_mime_type' => $content_type, |
|
| 403 | + ); |
|
| 404 | 404 | |
| 405 | - // Create the attachment in WordPress and generate the related metadata. |
|
| 406 | - $attachment_id = wp_insert_attachment( $attachment, $filename, $post_id ); |
|
| 405 | + // Create the attachment in WordPress and generate the related metadata. |
|
| 406 | + $attachment_id = wp_insert_attachment( $attachment, $filename, $post_id ); |
|
| 407 | 407 | |
| 408 | - // Set the source URL for the image. |
|
| 409 | - wl_set_source_url( $attachment_id, $image_remote_url ); |
|
| 408 | + // Set the source URL for the image. |
|
| 409 | + wl_set_source_url( $attachment_id, $image_remote_url ); |
|
| 410 | 410 | |
| 411 | - $attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename ); |
|
| 412 | - wp_update_attachment_metadata( $attachment_id, $attachment_data ); |
|
| 411 | + $attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename ); |
|
| 412 | + wp_update_attachment_metadata( $attachment_id, $attachment_data ); |
|
| 413 | 413 | |
| 414 | - // Set it as the featured image. |
|
| 415 | - set_post_thumbnail( $post_id, $attachment_id ); |
|
| 416 | - } |
|
| 414 | + // Set it as the featured image. |
|
| 415 | + set_post_thumbnail( $post_id, $attachment_id ); |
|
| 416 | + } |
|
| 417 | 417 | |
| 418 | - // The entity is pushed to Redlink on save by the function hooked to save_post. |
|
| 419 | - // save the entity in the triple store. |
|
| 420 | - Wordlift_Linked_Data_Service::get_instance()->push( $post_id ); |
|
| 418 | + // The entity is pushed to Redlink on save by the function hooked to save_post. |
|
| 419 | + // save the entity in the triple store. |
|
| 420 | + Wordlift_Linked_Data_Service::get_instance()->push( $post_id ); |
|
| 421 | 421 | |
| 422 | - // finally return the entity post. |
|
| 423 | - return get_post( $post_id ); |
|
| 422 | + // finally return the entity post. |
|
| 423 | + return get_post( $post_id ); |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | /** |
@@ -434,40 +434,40 @@ discard block |
||
| 434 | 434 | */ |
| 435 | 435 | function wl_linked_data_content_get_embedded_entities( $content ) { |
| 436 | 436 | |
| 437 | - // Remove quote escapes. |
|
| 438 | - $content = str_replace( '\\"', '"', $content ); |
|
| 437 | + // Remove quote escapes. |
|
| 438 | + $content = str_replace( '\\"', '"', $content ); |
|
| 439 | 439 | |
| 440 | - // Match all itemid attributes. |
|
| 441 | - $pattern = '/<\w+[^>]*\sitemid="([^"]+)"[^>]*>/im'; |
|
| 440 | + // Match all itemid attributes. |
|
| 441 | + $pattern = '/<\w+[^>]*\sitemid="([^"]+)"[^>]*>/im'; |
|
| 442 | 442 | |
| 443 | - // wl_write_log( "Getting entities embedded into content [ pattern :: $pattern ]" ); |
|
| 443 | + // wl_write_log( "Getting entities embedded into content [ pattern :: $pattern ]" ); |
|
| 444 | 444 | |
| 445 | - // Remove the pattern while it is found (match nested annotations). |
|
| 446 | - $matches = array(); |
|
| 445 | + // Remove the pattern while it is found (match nested annotations). |
|
| 446 | + $matches = array(); |
|
| 447 | 447 | |
| 448 | - // In case of errors, return an empty array. |
|
| 449 | - if ( false === preg_match_all( $pattern, $content, $matches ) ) { |
|
| 450 | - wl_write_log( "Found no entities embedded in content" ); |
|
| 448 | + // In case of errors, return an empty array. |
|
| 449 | + if ( false === preg_match_all( $pattern, $content, $matches ) ) { |
|
| 450 | + wl_write_log( "Found no entities embedded in content" ); |
|
| 451 | 451 | |
| 452 | - return array(); |
|
| 453 | - } |
|
| 452 | + return array(); |
|
| 453 | + } |
|
| 454 | 454 | |
| 455 | 455 | // wl_write_log("wl_update_related_entities [ content :: $content ][ data :: " . var_export($data, true). " ][ matches :: " . var_export($matches, true) . " ]"); |
| 456 | 456 | |
| 457 | - // Collect the entities. |
|
| 458 | - $entities = array(); |
|
| 459 | - foreach ( $matches[1] as $uri ) { |
|
| 460 | - $uri_d = html_entity_decode( $uri ); |
|
| 457 | + // Collect the entities. |
|
| 458 | + $entities = array(); |
|
| 459 | + foreach ( $matches[1] as $uri ) { |
|
| 460 | + $uri_d = html_entity_decode( $uri ); |
|
| 461 | 461 | |
| 462 | - $entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri_d ); |
|
| 462 | + $entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri_d ); |
|
| 463 | 463 | |
| 464 | - if ( null !== $entity ) { |
|
| 465 | - array_push( $entities, $entity->ID ); |
|
| 466 | - } |
|
| 467 | - } |
|
| 464 | + if ( null !== $entity ) { |
|
| 465 | + array_push( $entities, $entity->ID ); |
|
| 466 | + } |
|
| 467 | + } |
|
| 468 | 468 | |
| 469 | - // $count = sizeof( $entities ); |
|
| 470 | - // wl_write_log( "Found $count entities embedded in content" ); |
|
| 469 | + // $count = sizeof( $entities ); |
|
| 470 | + // wl_write_log( "Found $count entities embedded in content" ); |
|
| 471 | 471 | |
| 472 | - return $entities; |
|
| 472 | + return $entities; |
|
| 473 | 473 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * @subpackage Wordlift/modules/linked_data |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -require_once( 'wordlift_linked_data_images.php' ); |
|
| 10 | +require_once('wordlift_linked_data_images.php'); |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * Receive events from post saves, and split them according to the post type. |
@@ -16,15 +16,15 @@ discard block |
||
| 16 | 16 | * |
| 17 | 17 | * @param int $post_id The post id. |
| 18 | 18 | */ |
| 19 | -function wl_linked_data_save_post( $post_id ) { |
|
| 19 | +function wl_linked_data_save_post($post_id) { |
|
| 20 | 20 | |
| 21 | - $log = Wordlift_Log_Service::get_logger( 'wl_linked_data_save_post' ); |
|
| 21 | + $log = Wordlift_Log_Service::get_logger('wl_linked_data_save_post'); |
|
| 22 | 22 | |
| 23 | - $log->trace( "Saving post $post_id to Linked Data..." ); |
|
| 23 | + $log->trace("Saving post $post_id to Linked Data..."); |
|
| 24 | 24 | |
| 25 | 25 | // If it's not numeric exit from here. |
| 26 | - if ( ! is_numeric( $post_id ) || is_numeric( wp_is_post_revision( $post_id ) ) ) { |
|
| 27 | - $log->debug( "Skipping $post_id, because id is not numeric or is a post revision." ); |
|
| 26 | + if ( ! is_numeric($post_id) || is_numeric(wp_is_post_revision($post_id))) { |
|
| 27 | + $log->debug("Skipping $post_id, because id is not numeric or is a post revision."); |
|
| 28 | 28 | |
| 29 | 29 | return; |
| 30 | 30 | } |
@@ -32,27 +32,27 @@ discard block |
||
| 32 | 32 | // Get the post type and check whether it supports the editor. |
| 33 | 33 | // |
| 34 | 34 | // See https://github.com/insideout10/wordlift-plugin/issues/659. |
| 35 | - $post_type = get_post_type( $post_id ); |
|
| 36 | - $is_editor_supported = post_type_supports( $post_type, 'editor' ); |
|
| 35 | + $post_type = get_post_type($post_id); |
|
| 36 | + $is_editor_supported = post_type_supports($post_type, 'editor'); |
|
| 37 | 37 | |
| 38 | 38 | // Bail out if it's not an entity. |
| 39 | - if ( ! $is_editor_supported ) { |
|
| 40 | - $log->debug( "Skipping $post_id, because $post_type doesn't support the editor (content)." ); |
|
| 39 | + if ( ! $is_editor_supported) { |
|
| 40 | + $log->debug("Skipping $post_id, because $post_type doesn't support the editor (content)."); |
|
| 41 | 41 | |
| 42 | 42 | return; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | // Unhook this function so it doesn't loop infinitely. |
| 46 | - remove_action( 'save_post', 'wl_linked_data_save_post' ); |
|
| 46 | + remove_action('save_post', 'wl_linked_data_save_post'); |
|
| 47 | 47 | |
| 48 | 48 | // raise the *wl_linked_data_save_post* event. |
| 49 | - do_action( 'wl_linked_data_save_post', $post_id ); |
|
| 49 | + do_action('wl_linked_data_save_post', $post_id); |
|
| 50 | 50 | |
| 51 | 51 | // Re-hook this function. |
| 52 | - add_action( 'save_post', 'wl_linked_data_save_post' ); |
|
| 52 | + add_action('save_post', 'wl_linked_data_save_post'); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | -add_action( 'save_post', 'wl_linked_data_save_post' ); |
|
| 55 | +add_action('save_post', 'wl_linked_data_save_post'); |
|
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * Save the post to the triple store. Also saves the entities locally and on the triple store. |
@@ -61,23 +61,23 @@ discard block |
||
| 61 | 61 | * |
| 62 | 62 | * @param int $post_id The post id being saved. |
| 63 | 63 | */ |
| 64 | -function wl_linked_data_save_post_and_related_entities( $post_id ) { |
|
| 64 | +function wl_linked_data_save_post_and_related_entities($post_id) { |
|
| 65 | 65 | |
| 66 | - $log = Wordlift_Log_Service::get_logger( 'wl_linked_data_save_post_and_related_entities' ); |
|
| 66 | + $log = Wordlift_Log_Service::get_logger('wl_linked_data_save_post_and_related_entities'); |
|
| 67 | 67 | |
| 68 | - $log->trace( "Saving $post_id to Linked Data along with related entities..." ); |
|
| 68 | + $log->trace("Saving $post_id to Linked Data along with related entities..."); |
|
| 69 | 69 | |
| 70 | 70 | // Ignore auto-saves |
| 71 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
| 72 | - $log->trace( 'Doing autosave, skipping...' ); |
|
| 71 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
| 72 | + $log->trace('Doing autosave, skipping...'); |
|
| 73 | 73 | |
| 74 | 74 | return; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | // get the current post. |
| 78 | - $post = get_post( $post_id ); |
|
| 78 | + $post = get_post($post_id); |
|
| 79 | 79 | |
| 80 | - remove_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' ); |
|
| 80 | + remove_action('wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities'); |
|
| 81 | 81 | |
| 82 | 82 | // wl_write_log( "[ post id :: $post_id ][ autosave :: false ][ post type :: $post->post_type ]" ); |
| 83 | 83 | |
@@ -88,44 +88,44 @@ discard block |
||
| 88 | 88 | $entities_uri_mapping = array(); |
| 89 | 89 | |
| 90 | 90 | // Save the entities coming with POST data. |
| 91 | - if ( isset( $_POST['wl_entities'] ) && isset( $_POST['wl_boxes'] ) ) { |
|
| 91 | + if (isset($_POST['wl_entities']) && isset($_POST['wl_boxes'])) { |
|
| 92 | 92 | |
| 93 | - wl_write_log( "[ post id :: $post_id ][ POST(wl_entities) :: " ); |
|
| 94 | - wl_write_log( json_encode( $_POST['wl_entities'] ) ); |
|
| 95 | - wl_write_log( "]" ); |
|
| 96 | - wl_write_log( "[ post id :: $post_id ][ POST(wl_boxes) :: " ); |
|
| 97 | - wl_write_log( json_encode( $_POST['wl_boxes'], true ) ); |
|
| 98 | - wl_write_log( "]" ); |
|
| 93 | + wl_write_log("[ post id :: $post_id ][ POST(wl_entities) :: "); |
|
| 94 | + wl_write_log(json_encode($_POST['wl_entities'])); |
|
| 95 | + wl_write_log("]"); |
|
| 96 | + wl_write_log("[ post id :: $post_id ][ POST(wl_boxes) :: "); |
|
| 97 | + wl_write_log(json_encode($_POST['wl_boxes'], true)); |
|
| 98 | + wl_write_log("]"); |
|
| 99 | 99 | |
| 100 | 100 | $entities_via_post = $_POST['wl_entities']; |
| 101 | 101 | $boxes_via_post = $_POST['wl_boxes']; |
| 102 | 102 | |
| 103 | - foreach ( $entities_via_post as $entity_uri => $entity ) { |
|
| 103 | + foreach ($entities_via_post as $entity_uri => $entity) { |
|
| 104 | 104 | |
| 105 | 105 | // Only if the current entity is created from scratch let's avoid to |
| 106 | 106 | // create more than one entity with same label & entity type. |
| 107 | - $entity_type = ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) ? |
|
| 107 | + $entity_type = (preg_match('/^local-entity-.+/', $entity_uri) > 0) ? |
|
| 108 | 108 | $entity['main_type'] : null; |
| 109 | 109 | |
| 110 | 110 | // Look if current entity uri matches an internal existing entity, meaning: |
| 111 | 111 | // 1. when $entity_uri is an internal uri |
| 112 | 112 | // 2. when $entity_uri is an external uri used as sameAs of an internal entity |
| 113 | - $ie = $entity_service->get_entity_post_by_uri( $entity_uri ); |
|
| 113 | + $ie = $entity_service->get_entity_post_by_uri($entity_uri); |
|
| 114 | 114 | |
| 115 | 115 | // Detect the uri depending if is an existing or a new entity |
| 116 | - $uri = ( null === $ie ) ? |
|
| 116 | + $uri = (null === $ie) ? |
|
| 117 | 117 | Wordlift_Uri_Service::get_instance()->build_uri( |
| 118 | 118 | $entity['label'], |
| 119 | 119 | Wordlift_Entity_Service::TYPE_NAME, |
| 120 | 120 | $entity_type |
| 121 | - ) : wl_get_entity_uri( $ie->ID ); |
|
| 121 | + ) : wl_get_entity_uri($ie->ID); |
|
| 122 | 122 | |
| 123 | - wl_write_log( "Map $entity_uri on $uri" ); |
|
| 124 | - $entities_uri_mapping[ $entity_uri ] = $uri; |
|
| 123 | + wl_write_log("Map $entity_uri on $uri"); |
|
| 124 | + $entities_uri_mapping[$entity_uri] = $uri; |
|
| 125 | 125 | |
| 126 | 126 | // Local entities have a tmp uri with 'local-entity-' prefix |
| 127 | 127 | // These uris need to be rewritten here and replaced in the content |
| 128 | - if ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) { |
|
| 128 | + if (preg_match('/^local-entity-.+/', $entity_uri) > 0) { |
|
| 129 | 129 | // Override the entity obj |
| 130 | 130 | $entity['uri'] = $uri; |
| 131 | 131 | } |
@@ -134,8 +134,8 @@ discard block |
||
| 134 | 134 | $entity['related_post_id'] = $post_id; |
| 135 | 135 | |
| 136 | 136 | // Save the entity if is a new entity |
| 137 | - if ( null === $ie ) { |
|
| 138 | - wl_save_entity( $entity ); |
|
| 137 | + if (null === $ie) { |
|
| 138 | + wl_save_entity($entity); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | } |
@@ -146,39 +146,39 @@ discard block |
||
| 146 | 146 | $updated_post_content = $post->post_content; |
| 147 | 147 | |
| 148 | 148 | // Update the post content if we found mappings of new entities. |
| 149 | - if ( ! empty( $entities_uri_mapping ) ) { |
|
| 149 | + if ( ! empty($entities_uri_mapping)) { |
|
| 150 | 150 | // Save each entity and store the post id. |
| 151 | - foreach ( $entities_uri_mapping as $tmp_uri => $uri ) { |
|
| 152 | - $updated_post_content = str_replace( $tmp_uri, $uri, $updated_post_content ); |
|
| 151 | + foreach ($entities_uri_mapping as $tmp_uri => $uri) { |
|
| 152 | + $updated_post_content = str_replace($tmp_uri, $uri, $updated_post_content); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | // Update the post content. |
| 156 | - wp_update_post( array( |
|
| 156 | + wp_update_post(array( |
|
| 157 | 157 | 'ID' => $post->ID, |
| 158 | 158 | 'post_content' => $updated_post_content, |
| 159 | - ) ); |
|
| 159 | + )); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | // Extract related/referenced entities from text. |
| 163 | - $disambiguated_entities = wl_linked_data_content_get_embedded_entities( $updated_post_content ); |
|
| 163 | + $disambiguated_entities = wl_linked_data_content_get_embedded_entities($updated_post_content); |
|
| 164 | 164 | |
| 165 | 165 | // Reset previously saved instances. |
| 166 | - wl_core_delete_relation_instances( $post_id ); |
|
| 166 | + wl_core_delete_relation_instances($post_id); |
|
| 167 | 167 | |
| 168 | 168 | // Save relation instances |
| 169 | - foreach ( array_unique( $disambiguated_entities ) as $referenced_entity_id ) { |
|
| 169 | + foreach (array_unique($disambiguated_entities) as $referenced_entity_id) { |
|
| 170 | 170 | |
| 171 | 171 | wl_core_add_relation_instance( |
| 172 | 172 | $post_id, |
| 173 | - $entity_service->get_classification_scope_for( $referenced_entity_id ), |
|
| 173 | + $entity_service->get_classification_scope_for($referenced_entity_id), |
|
| 174 | 174 | $referenced_entity_id |
| 175 | 175 | ); |
| 176 | 176 | |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - if ( isset( $_POST['wl_entities'] ) ) { |
|
| 179 | + if (isset($_POST['wl_entities'])) { |
|
| 180 | 180 | // Save post metadata if available |
| 181 | - $metadata_via_post = ( isset( $_POST['wl_metadata'] ) ) ? |
|
| 181 | + $metadata_via_post = (isset($_POST['wl_metadata'])) ? |
|
| 182 | 182 | $_POST['wl_metadata'] : array(); |
| 183 | 183 | |
| 184 | 184 | $fields = array( |
@@ -187,35 +187,35 @@ discard block |
||
| 187 | 187 | ); |
| 188 | 188 | |
| 189 | 189 | // Unlink topic taxonomy terms |
| 190 | - Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for( $post->ID ); |
|
| 190 | + Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for($post->ID); |
|
| 191 | 191 | |
| 192 | - foreach ( $fields as $field ) { |
|
| 192 | + foreach ($fields as $field) { |
|
| 193 | 193 | |
| 194 | 194 | // Delete current values |
| 195 | - delete_post_meta( $post->ID, $field ); |
|
| 195 | + delete_post_meta($post->ID, $field); |
|
| 196 | 196 | // Retrieve the entity uri |
| 197 | - $uri = ( isset( $metadata_via_post[ $field ] ) ) ? |
|
| 198 | - stripslashes( $metadata_via_post[ $field ] ) : ''; |
|
| 197 | + $uri = (isset($metadata_via_post[$field])) ? |
|
| 198 | + stripslashes($metadata_via_post[$field]) : ''; |
|
| 199 | 199 | |
| 200 | - $entity = $entity_service->get_entity_post_by_uri( $uri ); |
|
| 200 | + $entity = $entity_service->get_entity_post_by_uri($uri); |
|
| 201 | 201 | |
| 202 | - if ( $entity ) { |
|
| 203 | - add_post_meta( $post->ID, $field, $entity->ID, true ); |
|
| 202 | + if ($entity) { |
|
| 203 | + add_post_meta($post->ID, $field, $entity->ID, true); |
|
| 204 | 204 | // Set also the topic taxonomy |
| 205 | - if ( $field === Wordlift_Schema_Service::FIELD_TOPIC ) { |
|
| 206 | - Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for( $post->ID, $entity ); |
|
| 205 | + if ($field === Wordlift_Schema_Service::FIELD_TOPIC) { |
|
| 206 | + Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for($post->ID, $entity); |
|
| 207 | 207 | } |
| 208 | 208 | } |
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | // Push the post to Redlink. |
| 213 | - Wordlift_Linked_Data_Service::get_instance()->push( $post->ID ); |
|
| 213 | + Wordlift_Linked_Data_Service::get_instance()->push($post->ID); |
|
| 214 | 214 | |
| 215 | - add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' ); |
|
| 215 | + add_action('wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities'); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | -add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' ); |
|
| 218 | +add_action('wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities'); |
|
| 219 | 219 | |
| 220 | 220 | /** |
| 221 | 221 | * Save the specified data as an entity in WordPress. This method only create new entities. When an existing entity is |
@@ -233,33 +233,33 @@ discard block |
||
| 233 | 233 | * |
| 234 | 234 | * @return null|WP_Post A post instance or null in case of failure. |
| 235 | 235 | */ |
| 236 | -function wl_save_entity( $entity_data ) { |
|
| 236 | +function wl_save_entity($entity_data) { |
|
| 237 | 237 | |
| 238 | - $log = Wordlift_Log_Service::get_logger( 'wl_save_entity' ); |
|
| 238 | + $log = Wordlift_Log_Service::get_logger('wl_save_entity'); |
|
| 239 | 239 | |
| 240 | 240 | $uri = $entity_data['uri']; |
| 241 | 241 | $label = $entity_data['label']; |
| 242 | 242 | $type_uri = $entity_data['main_type']; |
| 243 | - $entity_types = isset( $entity_data['type'] ) ? $entity_data['type'] : array(); |
|
| 243 | + $entity_types = isset($entity_data['type']) ? $entity_data['type'] : array(); |
|
| 244 | 244 | $description = $entity_data['description']; |
| 245 | - $images = isset( $entity_data['image'] ) ? (array) $entity_data['image'] : array(); |
|
| 246 | - $same_as = isset( $entity_data['sameas'] ) ? (array) $entity_data['sameas'] : array(); |
|
| 247 | - $related_post_id = isset( $entity_data['related_post_id'] ) ? $entity_data['related_post_id'] : null; |
|
| 248 | - $other_properties = isset( $entity_data['properties'] ) ? $entity_data['properties'] : array(); |
|
| 245 | + $images = isset($entity_data['image']) ? (array) $entity_data['image'] : array(); |
|
| 246 | + $same_as = isset($entity_data['sameas']) ? (array) $entity_data['sameas'] : array(); |
|
| 247 | + $related_post_id = isset($entity_data['related_post_id']) ? $entity_data['related_post_id'] : null; |
|
| 248 | + $other_properties = isset($entity_data['properties']) ? $entity_data['properties'] : array(); |
|
| 249 | 249 | |
| 250 | 250 | // Get the synonyms. |
| 251 | - $synonyms = isset( $entity_data['synonym'] ) ? $entity_data['synonym'] : array(); |
|
| 251 | + $synonyms = isset($entity_data['synonym']) ? $entity_data['synonym'] : array(); |
|
| 252 | 252 | |
| 253 | 253 | // Check whether an entity already exists with the provided URI. |
| 254 | - if ( null !== $post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri ) ) { |
|
| 255 | - $log->debug( "Post already exists for URI $uri." ); |
|
| 254 | + if (null !== $post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri($uri)) { |
|
| 255 | + $log->debug("Post already exists for URI $uri."); |
|
| 256 | 256 | |
| 257 | 257 | return $post; |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | // Prepare properties of the new entity. |
| 261 | 261 | $params = array( |
| 262 | - 'post_status' => ( is_numeric( $related_post_id ) ? get_post_status( $related_post_id ) : 'draft' ), |
|
| 262 | + 'post_status' => (is_numeric($related_post_id) ? get_post_status($related_post_id) : 'draft'), |
|
| 263 | 263 | 'post_type' => Wordlift_Entity_Service::TYPE_NAME, |
| 264 | 264 | 'post_title' => $label, |
| 265 | 265 | 'post_content' => $description, |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | // new entities. |
| 270 | 270 | // |
| 271 | 271 | // See https://github.com/insideout10/wordlift-plugin/issues/282 |
| 272 | - 'post_name' => sanitize_title( $label ), |
|
| 272 | + 'post_name' => sanitize_title($label), |
|
| 273 | 273 | ); |
| 274 | 274 | |
| 275 | 275 | // If Yoast is installed and active, we temporary remove the save_postdata hook which causes Yoast to "pass over" |
@@ -278,18 +278,18 @@ discard block |
||
| 278 | 278 | // This does NOT affect saving an entity from the entity admin page since this function is called when an entity |
| 279 | 279 | // is created when saving a post. |
| 280 | 280 | global $wpseo_metabox, $seo_ultimate; |
| 281 | - if ( isset( $wpseo_metabox ) ) { |
|
| 282 | - remove_action( 'wp_insert_post', array( |
|
| 281 | + if (isset($wpseo_metabox)) { |
|
| 282 | + remove_action('wp_insert_post', array( |
|
| 283 | 283 | $wpseo_metabox, |
| 284 | 284 | 'save_postdata', |
| 285 | - ) ); |
|
| 285 | + )); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - if ( isset( $seo_ultimate ) ) { |
|
| 289 | - remove_action( 'save_post', array( |
|
| 288 | + if (isset($seo_ultimate)) { |
|
| 289 | + remove_action('save_post', array( |
|
| 290 | 290 | $seo_ultimate, |
| 291 | 291 | 'save_postmeta_box', |
| 292 | - ) ); |
|
| 292 | + )); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | // The fact that we're calling here wp_insert_post is causing issues with plugins (and ourselves too) that hook to |
@@ -299,93 +299,93 @@ discard block |
||
| 299 | 299 | // see https://github.com/insideout10/wordlift-plugin/issues/156 |
| 300 | 300 | // see https://github.com/insideout10/wordlift-plugin/issues/148 |
| 301 | 301 | global $wp_filter; |
| 302 | - $save_post_filters = is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] : $wp_filter['save_post']->callbacks; |
|
| 303 | - is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = array() : $wp_filter['save_post']->remove_all_filters(); |
|
| 302 | + $save_post_filters = is_array($wp_filter['save_post']) ? $wp_filter['save_post'] : $wp_filter['save_post']->callbacks; |
|
| 303 | + is_array($wp_filter['save_post']) ? $wp_filter['save_post'] = array() : $wp_filter['save_post']->remove_all_filters(); |
|
| 304 | 304 | |
| 305 | 305 | |
| 306 | - $log->trace( 'Going to insert new post...' ); |
|
| 306 | + $log->trace('Going to insert new post...'); |
|
| 307 | 307 | |
| 308 | 308 | // create or update the post. |
| 309 | - $post_id = wp_insert_post( $params, true ); |
|
| 309 | + $post_id = wp_insert_post($params, true); |
|
| 310 | 310 | |
| 311 | 311 | // Setting the alternative labels for this entity. |
| 312 | 312 | Wordlift_Entity_Service::get_instance() |
| 313 | - ->set_alternative_labels( $post_id, $synonyms ); |
|
| 313 | + ->set_alternative_labels($post_id, $synonyms); |
|
| 314 | 314 | |
| 315 | 315 | // Restore all the existing filters. |
| 316 | - is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = $save_post_filters : $wp_filter['save_post']->callbacks = $save_post_filters; |
|
| 316 | + is_array($wp_filter['save_post']) ? $wp_filter['save_post'] = $save_post_filters : $wp_filter['save_post']->callbacks = $save_post_filters; |
|
| 317 | 317 | |
| 318 | 318 | // If Yoast is installed and active, we restore the Yoast save_postdata hook (https://github.com/insideout10/wordlift-plugin/issues/156) |
| 319 | - if ( isset( $wpseo_metabox ) ) { |
|
| 320 | - add_action( 'wp_insert_post', array( |
|
| 319 | + if (isset($wpseo_metabox)) { |
|
| 320 | + add_action('wp_insert_post', array( |
|
| 321 | 321 | $wpseo_metabox, |
| 322 | 322 | 'save_postdata', |
| 323 | - ) ); |
|
| 323 | + )); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | // If SEO Ultimate is installed, add back the hook we removed a few lines above. |
| 327 | - if ( isset( $seo_ultimate ) ) { |
|
| 328 | - add_action( 'save_post', array( |
|
| 327 | + if (isset($seo_ultimate)) { |
|
| 328 | + add_action('save_post', array( |
|
| 329 | 329 | $seo_ultimate, |
| 330 | 330 | 'save_postmeta_box', |
| 331 | - ), 10, 2 ); |
|
| 331 | + ), 10, 2); |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | // TODO: handle errors. |
| 335 | - if ( is_wp_error( $post_id ) ) { |
|
| 336 | - $log->error( 'An error occurred: ' . $post_id->get_error_message() ); |
|
| 335 | + if (is_wp_error($post_id)) { |
|
| 336 | + $log->error('An error occurred: '.$post_id->get_error_message()); |
|
| 337 | 337 | |
| 338 | 338 | // inform an error occurred. |
| 339 | 339 | return null; |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - wl_set_entity_main_type( $post_id, $type_uri ); |
|
| 342 | + wl_set_entity_main_type($post_id, $type_uri); |
|
| 343 | 343 | |
| 344 | 344 | // Save the entity types. |
| 345 | - wl_set_entity_rdf_types( $post_id, $entity_types ); |
|
| 345 | + wl_set_entity_rdf_types($post_id, $entity_types); |
|
| 346 | 346 | |
| 347 | 347 | // Get a dataset URI for the entity. |
| 348 | - $wl_uri = wl_build_entity_uri( $post_id ); |
|
| 348 | + $wl_uri = wl_build_entity_uri($post_id); |
|
| 349 | 349 | |
| 350 | 350 | // Save the entity URI. |
| 351 | - wl_set_entity_uri( $post_id, $wl_uri ); |
|
| 351 | + wl_set_entity_uri($post_id, $wl_uri); |
|
| 352 | 352 | |
| 353 | 353 | // Add the uri to the sameAs data if it's not a local URI. |
| 354 | - if ( $wl_uri !== $uri ) { |
|
| 355 | - array_push( $same_as, $uri ); |
|
| 354 | + if ($wl_uri !== $uri) { |
|
| 355 | + array_push($same_as, $uri); |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | - $new_uri = wl_get_entity_uri( $post_id ); |
|
| 358 | + $new_uri = wl_get_entity_uri($post_id); |
|
| 359 | 359 | |
| 360 | 360 | // Save the sameAs data for the entity. |
| 361 | - wl_schema_set_value( $post_id, 'sameAs', $same_as ); |
|
| 361 | + wl_schema_set_value($post_id, 'sameAs', $same_as); |
|
| 362 | 362 | |
| 363 | 363 | // Save the other properties (latitude, langitude, startDate, endDate, etc.) |
| 364 | - foreach ( $other_properties as $property_name => $property_value ) { |
|
| 365 | - wl_schema_set_value( $post_id, $property_name, $property_value ); |
|
| 364 | + foreach ($other_properties as $property_name => $property_value) { |
|
| 365 | + wl_schema_set_value($post_id, $property_name, $property_value); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | // Call hooks. |
| 369 | - do_action( 'wl_save_entity', $post_id ); |
|
| 369 | + do_action('wl_save_entity', $post_id); |
|
| 370 | 370 | |
| 371 | - foreach ( $images as $image_remote_url ) { |
|
| 371 | + foreach ($images as $image_remote_url) { |
|
| 372 | 372 | |
| 373 | 373 | // Check if image is already present in local DB |
| 374 | - if ( strpos( $image_remote_url, site_url() ) !== false ) { |
|
| 374 | + if (strpos($image_remote_url, site_url()) !== false) { |
|
| 375 | 375 | // Do nothing. |
| 376 | 376 | continue; |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | // Check if there is an existing attachment for this post ID and source URL. |
| 380 | - $existing_image = wl_get_attachment_for_source_url( $post_id, $image_remote_url ); |
|
| 380 | + $existing_image = wl_get_attachment_for_source_url($post_id, $image_remote_url); |
|
| 381 | 381 | |
| 382 | 382 | // Skip if an existing image is found. |
| 383 | - if ( null !== $existing_image ) { |
|
| 383 | + if (null !== $existing_image) { |
|
| 384 | 384 | continue; |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | // Save the image and get the local path. |
| 388 | - $image = wl_save_image( $image_remote_url ); |
|
| 388 | + $image = wl_save_image($image_remote_url); |
|
| 389 | 389 | |
| 390 | 390 | // Get the local URL. |
| 391 | 391 | $filename = $image['path']; |
@@ -403,24 +403,24 @@ discard block |
||
| 403 | 403 | ); |
| 404 | 404 | |
| 405 | 405 | // Create the attachment in WordPress and generate the related metadata. |
| 406 | - $attachment_id = wp_insert_attachment( $attachment, $filename, $post_id ); |
|
| 406 | + $attachment_id = wp_insert_attachment($attachment, $filename, $post_id); |
|
| 407 | 407 | |
| 408 | 408 | // Set the source URL for the image. |
| 409 | - wl_set_source_url( $attachment_id, $image_remote_url ); |
|
| 409 | + wl_set_source_url($attachment_id, $image_remote_url); |
|
| 410 | 410 | |
| 411 | - $attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename ); |
|
| 412 | - wp_update_attachment_metadata( $attachment_id, $attachment_data ); |
|
| 411 | + $attachment_data = wp_generate_attachment_metadata($attachment_id, $filename); |
|
| 412 | + wp_update_attachment_metadata($attachment_id, $attachment_data); |
|
| 413 | 413 | |
| 414 | 414 | // Set it as the featured image. |
| 415 | - set_post_thumbnail( $post_id, $attachment_id ); |
|
| 415 | + set_post_thumbnail($post_id, $attachment_id); |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | // The entity is pushed to Redlink on save by the function hooked to save_post. |
| 419 | 419 | // save the entity in the triple store. |
| 420 | - Wordlift_Linked_Data_Service::get_instance()->push( $post_id ); |
|
| 420 | + Wordlift_Linked_Data_Service::get_instance()->push($post_id); |
|
| 421 | 421 | |
| 422 | 422 | // finally return the entity post. |
| 423 | - return get_post( $post_id ); |
|
| 423 | + return get_post($post_id); |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | /** |
@@ -432,10 +432,10 @@ discard block |
||
| 432 | 432 | * |
| 433 | 433 | * @return array An array of entity posts. |
| 434 | 434 | */ |
| 435 | -function wl_linked_data_content_get_embedded_entities( $content ) { |
|
| 435 | +function wl_linked_data_content_get_embedded_entities($content) { |
|
| 436 | 436 | |
| 437 | 437 | // Remove quote escapes. |
| 438 | - $content = str_replace( '\\"', '"', $content ); |
|
| 438 | + $content = str_replace('\\"', '"', $content); |
|
| 439 | 439 | |
| 440 | 440 | // Match all itemid attributes. |
| 441 | 441 | $pattern = '/<\w+[^>]*\sitemid="([^"]+)"[^>]*>/im'; |
@@ -446,8 +446,8 @@ discard block |
||
| 446 | 446 | $matches = array(); |
| 447 | 447 | |
| 448 | 448 | // In case of errors, return an empty array. |
| 449 | - if ( false === preg_match_all( $pattern, $content, $matches ) ) { |
|
| 450 | - wl_write_log( "Found no entities embedded in content" ); |
|
| 449 | + if (false === preg_match_all($pattern, $content, $matches)) { |
|
| 450 | + wl_write_log("Found no entities embedded in content"); |
|
| 451 | 451 | |
| 452 | 452 | return array(); |
| 453 | 453 | } |
@@ -456,13 +456,13 @@ discard block |
||
| 456 | 456 | |
| 457 | 457 | // Collect the entities. |
| 458 | 458 | $entities = array(); |
| 459 | - foreach ( $matches[1] as $uri ) { |
|
| 460 | - $uri_d = html_entity_decode( $uri ); |
|
| 459 | + foreach ($matches[1] as $uri) { |
|
| 460 | + $uri_d = html_entity_decode($uri); |
|
| 461 | 461 | |
| 462 | - $entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri_d ); |
|
| 462 | + $entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri($uri_d); |
|
| 463 | 463 | |
| 464 | - if ( null !== $entity ) { |
|
| 465 | - array_push( $entities, $entity->ID ); |
|
| 464 | + if (null !== $entity) { |
|
| 465 | + array_push($entities, $entity->ID); |
|
| 466 | 466 | } |
| 467 | 467 | } |
| 468 | 468 | |
@@ -16,58 +16,58 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class Wordlift_Postid_To_Jsonld_Converter implements Wordlift_Post_Converter { |
| 18 | 18 | |
| 19 | - private $entity_service; |
|
| 20 | - private $entity_post_to_jsonld_converter; |
|
| 21 | - private $post_to_jsonld_converter; |
|
| 19 | + private $entity_service; |
|
| 20 | + private $entity_post_to_jsonld_converter; |
|
| 21 | + private $post_to_jsonld_converter; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * A {@link Wordlift_Log_Service} instance. |
|
| 25 | - * |
|
| 26 | - * @since 3.16.0 |
|
| 27 | - * @access private |
|
| 28 | - * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 29 | - */ |
|
| 30 | - private $log; |
|
| 23 | + /** |
|
| 24 | + * A {@link Wordlift_Log_Service} instance. |
|
| 25 | + * |
|
| 26 | + * @since 3.16.0 |
|
| 27 | + * @access private |
|
| 28 | + * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 29 | + */ |
|
| 30 | + private $log; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Wordlift_Entity_To_Jsonld_Converter constructor. |
|
| 34 | - * |
|
| 35 | - * @since 3.8.0 |
|
| 36 | - * |
|
| 37 | - * @param \Wordlift_Entity_Service $entity_service |
|
| 38 | - * @param \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter |
|
| 39 | - * @param \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter |
|
| 40 | - */ |
|
| 41 | - public function __construct( $entity_service, $entity_post_to_jsonld_converter, $post_to_jsonld_converter ) { |
|
| 32 | + /** |
|
| 33 | + * Wordlift_Entity_To_Jsonld_Converter constructor. |
|
| 34 | + * |
|
| 35 | + * @since 3.8.0 |
|
| 36 | + * |
|
| 37 | + * @param \Wordlift_Entity_Service $entity_service |
|
| 38 | + * @param \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter |
|
| 39 | + * @param \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter |
|
| 40 | + */ |
|
| 41 | + public function __construct( $entity_service, $entity_post_to_jsonld_converter, $post_to_jsonld_converter ) { |
|
| 42 | 42 | |
| 43 | - $this->log = Wordlift_Log_Service::get_logger( get_class() ); |
|
| 43 | + $this->log = Wordlift_Log_Service::get_logger( get_class() ); |
|
| 44 | 44 | |
| 45 | - $this->entity_service = $entity_service; |
|
| 46 | - $this->entity_post_to_jsonld_converter = $entity_post_to_jsonld_converter; |
|
| 47 | - $this->post_to_jsonld_converter = $post_to_jsonld_converter; |
|
| 45 | + $this->entity_service = $entity_service; |
|
| 46 | + $this->entity_post_to_jsonld_converter = $entity_post_to_jsonld_converter; |
|
| 47 | + $this->post_to_jsonld_converter = $post_to_jsonld_converter; |
|
| 48 | 48 | |
| 49 | - } |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Convert a post to JSON-LD. |
|
| 53 | - * |
|
| 54 | - * @since 3.8.0 |
|
| 55 | - * |
|
| 56 | - * @param string $id A post id (post or entity). |
|
| 57 | - * |
|
| 58 | - * @param array $references |
|
| 59 | - * |
|
| 60 | - * @return array|NULL A JSON-LD array representation of the post with the provided id, or NULL if not found. |
|
| 61 | - */ |
|
| 62 | - public function convert( $id, &$references = array() ) { |
|
| 51 | + /** |
|
| 52 | + * Convert a post to JSON-LD. |
|
| 53 | + * |
|
| 54 | + * @since 3.8.0 |
|
| 55 | + * |
|
| 56 | + * @param string $id A post id (post or entity). |
|
| 57 | + * |
|
| 58 | + * @param array $references |
|
| 59 | + * |
|
| 60 | + * @return array|NULL A JSON-LD array representation of the post with the provided id, or NULL if not found. |
|
| 61 | + */ |
|
| 62 | + public function convert( $id, &$references = array() ) { |
|
| 63 | 63 | |
| 64 | - $this->log->trace( "Converting post $id..." ); |
|
| 64 | + $this->log->trace( "Converting post $id..." ); |
|
| 65 | 65 | |
| 66 | - return $this->entity_service->is_entity( $id ) |
|
| 67 | - // Entity. |
|
| 68 | - ? $this->entity_post_to_jsonld_converter->convert( $id, $references ) |
|
| 69 | - // Post/Page. |
|
| 70 | - : $this->post_to_jsonld_converter->convert( $id, $references ); |
|
| 71 | - } |
|
| 66 | + return $this->entity_service->is_entity( $id ) |
|
| 67 | + // Entity. |
|
| 68 | + ? $this->entity_post_to_jsonld_converter->convert( $id, $references ) |
|
| 69 | + // Post/Page. |
|
| 70 | + : $this->post_to_jsonld_converter->convert( $id, $references ); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | 73 | } |
@@ -38,9 +38,9 @@ discard block |
||
| 38 | 38 | * @param \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter |
| 39 | 39 | * @param \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter |
| 40 | 40 | */ |
| 41 | - public function __construct( $entity_service, $entity_post_to_jsonld_converter, $post_to_jsonld_converter ) { |
|
| 41 | + public function __construct($entity_service, $entity_post_to_jsonld_converter, $post_to_jsonld_converter) { |
|
| 42 | 42 | |
| 43 | - $this->log = Wordlift_Log_Service::get_logger( get_class() ); |
|
| 43 | + $this->log = Wordlift_Log_Service::get_logger(get_class()); |
|
| 44 | 44 | |
| 45 | 45 | $this->entity_service = $entity_service; |
| 46 | 46 | $this->entity_post_to_jsonld_converter = $entity_post_to_jsonld_converter; |
@@ -59,15 +59,15 @@ discard block |
||
| 59 | 59 | * |
| 60 | 60 | * @return array|NULL A JSON-LD array representation of the post with the provided id, or NULL if not found. |
| 61 | 61 | */ |
| 62 | - public function convert( $id, &$references = array() ) { |
|
| 62 | + public function convert($id, &$references = array()) { |
|
| 63 | 63 | |
| 64 | - $this->log->trace( "Converting post $id..." ); |
|
| 64 | + $this->log->trace("Converting post $id..."); |
|
| 65 | 65 | |
| 66 | - return $this->entity_service->is_entity( $id ) |
|
| 66 | + return $this->entity_service->is_entity($id) |
|
| 67 | 67 | // Entity. |
| 68 | - ? $this->entity_post_to_jsonld_converter->convert( $id, $references ) |
|
| 68 | + ? $this->entity_post_to_jsonld_converter->convert($id, $references) |
|
| 69 | 69 | // Post/Page. |
| 70 | - : $this->post_to_jsonld_converter->convert( $id, $references ); |
|
| 70 | + : $this->post_to_jsonld_converter->convert($id, $references); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | } |
@@ -18,223 +18,223 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | abstract class Wordlift_Abstract_Post_To_Jsonld_Converter implements Wordlift_Post_Converter { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * The JSON-LD context. |
|
| 23 | - * |
|
| 24 | - * @since 3.10.0 |
|
| 25 | - */ |
|
| 26 | - const CONTEXT = 'http://schema.org'; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * A {@link Wordlift_Entity_Type_Service} instance. |
|
| 30 | - * |
|
| 31 | - * @since 3.10.0 |
|
| 32 | - * @access protected |
|
| 33 | - * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 34 | - */ |
|
| 35 | - protected $entity_type_service; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * A {@link Wordlift_Entity_Service} instance. |
|
| 39 | - * |
|
| 40 | - * @since 3.10.0 |
|
| 41 | - * @access protected |
|
| 42 | - * @var \Wordlift_Entity_Service $entity_type_service A {@link Wordlift_Entity_Service} instance. |
|
| 43 | - */ |
|
| 44 | - protected $entity_service; |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * A {@link Wordlift_User_Service} instance. |
|
| 48 | - * |
|
| 49 | - * @since 3.10.0 |
|
| 50 | - * @access private |
|
| 51 | - * @var \Wordlift_User_Service $user_service A {@link Wordlift_User_Service} instance. |
|
| 52 | - */ |
|
| 53 | - protected $user_service; |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * A {@link Wordlift_Attachment_Service} instance. |
|
| 57 | - * |
|
| 58 | - * @since 3.10.0 |
|
| 59 | - * @access private |
|
| 60 | - * @var \Wordlift_Attachment_Service $attachment_service A {@link Wordlift_Attachment_Service} instance. |
|
| 61 | - */ |
|
| 62 | - protected $attachment_service; |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * Wordlift_Post_To_Jsonld_Converter constructor. |
|
| 66 | - * |
|
| 67 | - * @since 3.10.0 |
|
| 68 | - * |
|
| 69 | - * @param \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 70 | - * @param \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 71 | - * @param \Wordlift_User_Service $user_service A {@link Wordlift_User_Service} instance. |
|
| 72 | - * @param \Wordlift_Attachment_Service $attachment_service A {@link Wordlift_Attachment_Service} instance. |
|
| 73 | - */ |
|
| 74 | - public function __construct( $entity_type_service, $entity_service, $user_service, $attachment_service ) { |
|
| 75 | - |
|
| 76 | - $this->entity_type_service = $entity_type_service; |
|
| 77 | - $this->entity_service = $entity_service; |
|
| 78 | - $this->user_service = $user_service; |
|
| 79 | - $this->attachment_service = $attachment_service; |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * Convert the provided {@link WP_Post} to a JSON-LD array. Any entity reference |
|
| 84 | - * found while processing the post is set in the $references array. |
|
| 85 | - * |
|
| 86 | - * @since 3.10.0 |
|
| 87 | - * |
|
| 88 | - * @param int $post_id The post id. |
|
| 89 | - * @param array $references An array of entity references. |
|
| 90 | - * |
|
| 91 | - * @return array A JSON-LD array. |
|
| 92 | - */ |
|
| 93 | - public function convert( $post_id, &$references = array() ) { |
|
| 94 | - |
|
| 95 | - // Get the post instance. |
|
| 96 | - $post = get_post( $post_id ); |
|
| 97 | - if ( null === $post ) { |
|
| 98 | - // Post not found. |
|
| 99 | - return null; |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - // Get the post URI @id. |
|
| 103 | - $id = $this->entity_service->get_uri( $post->ID ); |
|
| 104 | - |
|
| 105 | - // Get the entity @type. We consider `post` BlogPostings. |
|
| 106 | - $type = $this->entity_type_service->get( $post_id ); |
|
| 107 | - |
|
| 108 | - // Prepare the response. |
|
| 109 | - $jsonld = array( |
|
| 110 | - '@context' => self::CONTEXT, |
|
| 111 | - '@id' => $id, |
|
| 112 | - '@type' => $this->relative_to_context( $type['uri'] ), |
|
| 113 | - 'description' => Wordlift_Post_Excerpt_Helper::get_text_excerpt( $post ), |
|
| 114 | - ); |
|
| 115 | - |
|
| 116 | - // Set the `mainEntityOfPage` property if the post has some contents. |
|
| 117 | - if ( ! empty( $post->post_content ) ) { |
|
| 118 | - // We're setting the `mainEntityOfPage` to signal which one is the |
|
| 119 | - // main entity for the specified URL. It might be however that the |
|
| 120 | - // post/page is actually about another specific entity. How WL deals |
|
| 121 | - // with that hasn't been defined yet (see https://github.com/insideout10/wordlift-plugin/issues/451). |
|
| 122 | - // |
|
| 123 | - // See http://schema.org/mainEntityOfPage |
|
| 124 | - // |
|
| 125 | - // No need to specify `'@type' => 'WebPage'. |
|
| 126 | - // |
|
| 127 | - // See https://github.com/insideout10/wordlift-plugin/issues/451. |
|
| 128 | - $jsonld['mainEntityOfPage'] = get_the_permalink( $post->ID ); |
|
| 129 | - }; |
|
| 130 | - |
|
| 131 | - $this->set_images( $post, $jsonld ); |
|
| 132 | - |
|
| 133 | - // Get the entities referenced by this post and set it to the `references` |
|
| 134 | - // array so that the caller can do further processing, such as printing out |
|
| 135 | - // more of those references. |
|
| 136 | - $references = $this->entity_service->get_related_entities( $post->ID ); |
|
| 137 | - |
|
| 138 | - return $jsonld; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * If the provided value starts with the schema.org context, we remove the schema.org |
|
| 143 | - * part since it is set with the '@context'. |
|
| 144 | - * |
|
| 145 | - * @since 3.10.0 |
|
| 146 | - * |
|
| 147 | - * @param string $value The property value. |
|
| 148 | - * |
|
| 149 | - * @return string The property value without the context. |
|
| 150 | - */ |
|
| 151 | - public function relative_to_context( $value ) { |
|
| 152 | - |
|
| 153 | - return 0 === strpos( $value, self::CONTEXT . '/' ) ? substr( $value, strlen( self::CONTEXT ) + 1 ) : $value; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * Set the images, by looking for embedded images, for images loaded via the |
|
| 158 | - * gallery and for the featured image. |
|
| 159 | - * |
|
| 160 | - * Uses the cache service to store the results of this function for a day. |
|
| 161 | - * |
|
| 162 | - * @since 3.10.0 |
|
| 163 | - * |
|
| 164 | - * @param WP_Post $post The target {@link WP_Post}. |
|
| 165 | - * @param array $jsonld The JSON-LD array. |
|
| 166 | - */ |
|
| 167 | - protected function set_images( $post, &$jsonld ) { |
|
| 168 | - |
|
| 169 | - // Prepare the attachment ids array. |
|
| 170 | - $ids = array(); |
|
| 171 | - |
|
| 172 | - // Set the thumbnail id as first attachment id, if any. |
|
| 173 | - $thumbnail_id = get_post_thumbnail_id( $post->ID ); |
|
| 174 | - if ( '' !== $thumbnail_id ) { |
|
| 175 | - $ids[] = $thumbnail_id; |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - // For the time being the following is being removed since the query |
|
| 179 | - // initiated by `get_image_embeds` is consuming lots of CPU. |
|
| 180 | - // |
|
| 181 | - // See https://github.com/insideout10/wordlift-plugin/issues/689. |
|
| 182 | - // |
|
| 183 | - // Get the embeds, removing existing ids. |
|
| 184 | - // $embeds = array_diff( $this->attachment_service->get_image_embeds( $post->post_content ), $ids ); |
|
| 185 | - $embeds = array(); |
|
| 186 | - |
|
| 187 | - // Get the gallery, removing existing ids. |
|
| 188 | - $gallery = array_diff( $this->attachment_service->get_gallery( $post ), $ids, $embeds ); |
|
| 189 | - |
|
| 190 | - // Map the attachment ids to images' data structured for schema.org use. |
|
| 191 | - $images = array_map( function ( $item ) { |
|
| 192 | - /* |
|
| 21 | + /** |
|
| 22 | + * The JSON-LD context. |
|
| 23 | + * |
|
| 24 | + * @since 3.10.0 |
|
| 25 | + */ |
|
| 26 | + const CONTEXT = 'http://schema.org'; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * A {@link Wordlift_Entity_Type_Service} instance. |
|
| 30 | + * |
|
| 31 | + * @since 3.10.0 |
|
| 32 | + * @access protected |
|
| 33 | + * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 34 | + */ |
|
| 35 | + protected $entity_type_service; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * A {@link Wordlift_Entity_Service} instance. |
|
| 39 | + * |
|
| 40 | + * @since 3.10.0 |
|
| 41 | + * @access protected |
|
| 42 | + * @var \Wordlift_Entity_Service $entity_type_service A {@link Wordlift_Entity_Service} instance. |
|
| 43 | + */ |
|
| 44 | + protected $entity_service; |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * A {@link Wordlift_User_Service} instance. |
|
| 48 | + * |
|
| 49 | + * @since 3.10.0 |
|
| 50 | + * @access private |
|
| 51 | + * @var \Wordlift_User_Service $user_service A {@link Wordlift_User_Service} instance. |
|
| 52 | + */ |
|
| 53 | + protected $user_service; |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * A {@link Wordlift_Attachment_Service} instance. |
|
| 57 | + * |
|
| 58 | + * @since 3.10.0 |
|
| 59 | + * @access private |
|
| 60 | + * @var \Wordlift_Attachment_Service $attachment_service A {@link Wordlift_Attachment_Service} instance. |
|
| 61 | + */ |
|
| 62 | + protected $attachment_service; |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * Wordlift_Post_To_Jsonld_Converter constructor. |
|
| 66 | + * |
|
| 67 | + * @since 3.10.0 |
|
| 68 | + * |
|
| 69 | + * @param \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 70 | + * @param \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 71 | + * @param \Wordlift_User_Service $user_service A {@link Wordlift_User_Service} instance. |
|
| 72 | + * @param \Wordlift_Attachment_Service $attachment_service A {@link Wordlift_Attachment_Service} instance. |
|
| 73 | + */ |
|
| 74 | + public function __construct( $entity_type_service, $entity_service, $user_service, $attachment_service ) { |
|
| 75 | + |
|
| 76 | + $this->entity_type_service = $entity_type_service; |
|
| 77 | + $this->entity_service = $entity_service; |
|
| 78 | + $this->user_service = $user_service; |
|
| 79 | + $this->attachment_service = $attachment_service; |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * Convert the provided {@link WP_Post} to a JSON-LD array. Any entity reference |
|
| 84 | + * found while processing the post is set in the $references array. |
|
| 85 | + * |
|
| 86 | + * @since 3.10.0 |
|
| 87 | + * |
|
| 88 | + * @param int $post_id The post id. |
|
| 89 | + * @param array $references An array of entity references. |
|
| 90 | + * |
|
| 91 | + * @return array A JSON-LD array. |
|
| 92 | + */ |
|
| 93 | + public function convert( $post_id, &$references = array() ) { |
|
| 94 | + |
|
| 95 | + // Get the post instance. |
|
| 96 | + $post = get_post( $post_id ); |
|
| 97 | + if ( null === $post ) { |
|
| 98 | + // Post not found. |
|
| 99 | + return null; |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + // Get the post URI @id. |
|
| 103 | + $id = $this->entity_service->get_uri( $post->ID ); |
|
| 104 | + |
|
| 105 | + // Get the entity @type. We consider `post` BlogPostings. |
|
| 106 | + $type = $this->entity_type_service->get( $post_id ); |
|
| 107 | + |
|
| 108 | + // Prepare the response. |
|
| 109 | + $jsonld = array( |
|
| 110 | + '@context' => self::CONTEXT, |
|
| 111 | + '@id' => $id, |
|
| 112 | + '@type' => $this->relative_to_context( $type['uri'] ), |
|
| 113 | + 'description' => Wordlift_Post_Excerpt_Helper::get_text_excerpt( $post ), |
|
| 114 | + ); |
|
| 115 | + |
|
| 116 | + // Set the `mainEntityOfPage` property if the post has some contents. |
|
| 117 | + if ( ! empty( $post->post_content ) ) { |
|
| 118 | + // We're setting the `mainEntityOfPage` to signal which one is the |
|
| 119 | + // main entity for the specified URL. It might be however that the |
|
| 120 | + // post/page is actually about another specific entity. How WL deals |
|
| 121 | + // with that hasn't been defined yet (see https://github.com/insideout10/wordlift-plugin/issues/451). |
|
| 122 | + // |
|
| 123 | + // See http://schema.org/mainEntityOfPage |
|
| 124 | + // |
|
| 125 | + // No need to specify `'@type' => 'WebPage'. |
|
| 126 | + // |
|
| 127 | + // See https://github.com/insideout10/wordlift-plugin/issues/451. |
|
| 128 | + $jsonld['mainEntityOfPage'] = get_the_permalink( $post->ID ); |
|
| 129 | + }; |
|
| 130 | + |
|
| 131 | + $this->set_images( $post, $jsonld ); |
|
| 132 | + |
|
| 133 | + // Get the entities referenced by this post and set it to the `references` |
|
| 134 | + // array so that the caller can do further processing, such as printing out |
|
| 135 | + // more of those references. |
|
| 136 | + $references = $this->entity_service->get_related_entities( $post->ID ); |
|
| 137 | + |
|
| 138 | + return $jsonld; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * If the provided value starts with the schema.org context, we remove the schema.org |
|
| 143 | + * part since it is set with the '@context'. |
|
| 144 | + * |
|
| 145 | + * @since 3.10.0 |
|
| 146 | + * |
|
| 147 | + * @param string $value The property value. |
|
| 148 | + * |
|
| 149 | + * @return string The property value without the context. |
|
| 150 | + */ |
|
| 151 | + public function relative_to_context( $value ) { |
|
| 152 | + |
|
| 153 | + return 0 === strpos( $value, self::CONTEXT . '/' ) ? substr( $value, strlen( self::CONTEXT ) + 1 ) : $value; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * Set the images, by looking for embedded images, for images loaded via the |
|
| 158 | + * gallery and for the featured image. |
|
| 159 | + * |
|
| 160 | + * Uses the cache service to store the results of this function for a day. |
|
| 161 | + * |
|
| 162 | + * @since 3.10.0 |
|
| 163 | + * |
|
| 164 | + * @param WP_Post $post The target {@link WP_Post}. |
|
| 165 | + * @param array $jsonld The JSON-LD array. |
|
| 166 | + */ |
|
| 167 | + protected function set_images( $post, &$jsonld ) { |
|
| 168 | + |
|
| 169 | + // Prepare the attachment ids array. |
|
| 170 | + $ids = array(); |
|
| 171 | + |
|
| 172 | + // Set the thumbnail id as first attachment id, if any. |
|
| 173 | + $thumbnail_id = get_post_thumbnail_id( $post->ID ); |
|
| 174 | + if ( '' !== $thumbnail_id ) { |
|
| 175 | + $ids[] = $thumbnail_id; |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + // For the time being the following is being removed since the query |
|
| 179 | + // initiated by `get_image_embeds` is consuming lots of CPU. |
|
| 180 | + // |
|
| 181 | + // See https://github.com/insideout10/wordlift-plugin/issues/689. |
|
| 182 | + // |
|
| 183 | + // Get the embeds, removing existing ids. |
|
| 184 | + // $embeds = array_diff( $this->attachment_service->get_image_embeds( $post->post_content ), $ids ); |
|
| 185 | + $embeds = array(); |
|
| 186 | + |
|
| 187 | + // Get the gallery, removing existing ids. |
|
| 188 | + $gallery = array_diff( $this->attachment_service->get_gallery( $post ), $ids, $embeds ); |
|
| 189 | + |
|
| 190 | + // Map the attachment ids to images' data structured for schema.org use. |
|
| 191 | + $images = array_map( function ( $item ) { |
|
| 192 | + /* |
|
| 193 | 193 | * @todo: we're not sure that we're getting attachment data here, we |
| 194 | 194 | * should filter `false`s. |
| 195 | 195 | */ |
| 196 | 196 | |
| 197 | - // Get the attachment data. |
|
| 198 | - $attachment = wp_get_attachment_image_src( $item, 'full' ); |
|
| 199 | - |
|
| 200 | - // Refactor data as per schema.org specifications. |
|
| 201 | - return Wordlift_Abstract_Post_To_Jsonld_Converter::set_image_size( array( |
|
| 202 | - '@type' => 'ImageObject', |
|
| 203 | - 'url' => $attachment[0], |
|
| 204 | - ), $attachment ); |
|
| 205 | - }, array_merge( $ids, $embeds, $gallery ) ); |
|
| 206 | - |
|
| 207 | - if ( 0 < count( $images ) ) { |
|
| 208 | - $jsonld['image'] = $images; |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - /** |
|
| 214 | - * Process the provided array by adding the width / height if the values |
|
| 215 | - * are available and are greater than 0. |
|
| 216 | - * |
|
| 217 | - * @since 3.14.0 |
|
| 218 | - * |
|
| 219 | - * @param array $image The `ImageObject` array. |
|
| 220 | - * @param array $attachment The attachment array. |
|
| 221 | - * |
|
| 222 | - * @return array The enriched `ImageObject` array. |
|
| 223 | - */ |
|
| 224 | - public static function set_image_size( $image, $attachment ) { |
|
| 225 | - |
|
| 226 | - // If you specify a "width" or "height" value you should leave out |
|
| 227 | - // 'px'. For example: "width":"4608px" should be "width":"4608". |
|
| 228 | - // |
|
| 229 | - // See https://github.com/insideout10/wordlift-plugin/issues/451. |
|
| 230 | - if ( isset( $attachment[1] ) && is_numeric( $attachment[1] ) && 0 < $attachment[1] ) { |
|
| 231 | - $image['width'] = $attachment[1]; |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - if ( isset( $attachment[2] ) && is_numeric( $attachment[2] ) && 0 < $attachment[2] ) { |
|
| 235 | - $image['height'] = $attachment[2]; |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - return $image; |
|
| 239 | - } |
|
| 197 | + // Get the attachment data. |
|
| 198 | + $attachment = wp_get_attachment_image_src( $item, 'full' ); |
|
| 199 | + |
|
| 200 | + // Refactor data as per schema.org specifications. |
|
| 201 | + return Wordlift_Abstract_Post_To_Jsonld_Converter::set_image_size( array( |
|
| 202 | + '@type' => 'ImageObject', |
|
| 203 | + 'url' => $attachment[0], |
|
| 204 | + ), $attachment ); |
|
| 205 | + }, array_merge( $ids, $embeds, $gallery ) ); |
|
| 206 | + |
|
| 207 | + if ( 0 < count( $images ) ) { |
|
| 208 | + $jsonld['image'] = $images; |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + /** |
|
| 214 | + * Process the provided array by adding the width / height if the values |
|
| 215 | + * are available and are greater than 0. |
|
| 216 | + * |
|
| 217 | + * @since 3.14.0 |
|
| 218 | + * |
|
| 219 | + * @param array $image The `ImageObject` array. |
|
| 220 | + * @param array $attachment The attachment array. |
|
| 221 | + * |
|
| 222 | + * @return array The enriched `ImageObject` array. |
|
| 223 | + */ |
|
| 224 | + public static function set_image_size( $image, $attachment ) { |
|
| 225 | + |
|
| 226 | + // If you specify a "width" or "height" value you should leave out |
|
| 227 | + // 'px'. For example: "width":"4608px" should be "width":"4608". |
|
| 228 | + // |
|
| 229 | + // See https://github.com/insideout10/wordlift-plugin/issues/451. |
|
| 230 | + if ( isset( $attachment[1] ) && is_numeric( $attachment[1] ) && 0 < $attachment[1] ) { |
|
| 231 | + $image['width'] = $attachment[1]; |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + if ( isset( $attachment[2] ) && is_numeric( $attachment[2] ) && 0 < $attachment[2] ) { |
|
| 235 | + $image['height'] = $attachment[2]; |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + return $image; |
|
| 239 | + } |
|
| 240 | 240 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | * @param \Wordlift_User_Service $user_service A {@link Wordlift_User_Service} instance. |
| 72 | 72 | * @param \Wordlift_Attachment_Service $attachment_service A {@link Wordlift_Attachment_Service} instance. |
| 73 | 73 | */ |
| 74 | - public function __construct( $entity_type_service, $entity_service, $user_service, $attachment_service ) { |
|
| 74 | + public function __construct($entity_type_service, $entity_service, $user_service, $attachment_service) { |
|
| 75 | 75 | |
| 76 | 76 | $this->entity_type_service = $entity_type_service; |
| 77 | 77 | $this->entity_service = $entity_service; |
@@ -90,31 +90,31 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @return array A JSON-LD array. |
| 92 | 92 | */ |
| 93 | - public function convert( $post_id, &$references = array() ) { |
|
| 93 | + public function convert($post_id, &$references = array()) { |
|
| 94 | 94 | |
| 95 | 95 | // Get the post instance. |
| 96 | - $post = get_post( $post_id ); |
|
| 97 | - if ( null === $post ) { |
|
| 96 | + $post = get_post($post_id); |
|
| 97 | + if (null === $post) { |
|
| 98 | 98 | // Post not found. |
| 99 | 99 | return null; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | // Get the post URI @id. |
| 103 | - $id = $this->entity_service->get_uri( $post->ID ); |
|
| 103 | + $id = $this->entity_service->get_uri($post->ID); |
|
| 104 | 104 | |
| 105 | 105 | // Get the entity @type. We consider `post` BlogPostings. |
| 106 | - $type = $this->entity_type_service->get( $post_id ); |
|
| 106 | + $type = $this->entity_type_service->get($post_id); |
|
| 107 | 107 | |
| 108 | 108 | // Prepare the response. |
| 109 | 109 | $jsonld = array( |
| 110 | 110 | '@context' => self::CONTEXT, |
| 111 | 111 | '@id' => $id, |
| 112 | - '@type' => $this->relative_to_context( $type['uri'] ), |
|
| 113 | - 'description' => Wordlift_Post_Excerpt_Helper::get_text_excerpt( $post ), |
|
| 112 | + '@type' => $this->relative_to_context($type['uri']), |
|
| 113 | + 'description' => Wordlift_Post_Excerpt_Helper::get_text_excerpt($post), |
|
| 114 | 114 | ); |
| 115 | 115 | |
| 116 | 116 | // Set the `mainEntityOfPage` property if the post has some contents. |
| 117 | - if ( ! empty( $post->post_content ) ) { |
|
| 117 | + if ( ! empty($post->post_content)) { |
|
| 118 | 118 | // We're setting the `mainEntityOfPage` to signal which one is the |
| 119 | 119 | // main entity for the specified URL. It might be however that the |
| 120 | 120 | // post/page is actually about another specific entity. How WL deals |
@@ -125,15 +125,15 @@ discard block |
||
| 125 | 125 | // No need to specify `'@type' => 'WebPage'. |
| 126 | 126 | // |
| 127 | 127 | // See https://github.com/insideout10/wordlift-plugin/issues/451. |
| 128 | - $jsonld['mainEntityOfPage'] = get_the_permalink( $post->ID ); |
|
| 128 | + $jsonld['mainEntityOfPage'] = get_the_permalink($post->ID); |
|
| 129 | 129 | }; |
| 130 | 130 | |
| 131 | - $this->set_images( $post, $jsonld ); |
|
| 131 | + $this->set_images($post, $jsonld); |
|
| 132 | 132 | |
| 133 | 133 | // Get the entities referenced by this post and set it to the `references` |
| 134 | 134 | // array so that the caller can do further processing, such as printing out |
| 135 | 135 | // more of those references. |
| 136 | - $references = $this->entity_service->get_related_entities( $post->ID ); |
|
| 136 | + $references = $this->entity_service->get_related_entities($post->ID); |
|
| 137 | 137 | |
| 138 | 138 | return $jsonld; |
| 139 | 139 | } |
@@ -148,9 +148,9 @@ discard block |
||
| 148 | 148 | * |
| 149 | 149 | * @return string The property value without the context. |
| 150 | 150 | */ |
| 151 | - public function relative_to_context( $value ) { |
|
| 151 | + public function relative_to_context($value) { |
|
| 152 | 152 | |
| 153 | - return 0 === strpos( $value, self::CONTEXT . '/' ) ? substr( $value, strlen( self::CONTEXT ) + 1 ) : $value; |
|
| 153 | + return 0 === strpos($value, self::CONTEXT.'/') ? substr($value, strlen(self::CONTEXT) + 1) : $value; |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
@@ -164,14 +164,14 @@ discard block |
||
| 164 | 164 | * @param WP_Post $post The target {@link WP_Post}. |
| 165 | 165 | * @param array $jsonld The JSON-LD array. |
| 166 | 166 | */ |
| 167 | - protected function set_images( $post, &$jsonld ) { |
|
| 167 | + protected function set_images($post, &$jsonld) { |
|
| 168 | 168 | |
| 169 | 169 | // Prepare the attachment ids array. |
| 170 | 170 | $ids = array(); |
| 171 | 171 | |
| 172 | 172 | // Set the thumbnail id as first attachment id, if any. |
| 173 | - $thumbnail_id = get_post_thumbnail_id( $post->ID ); |
|
| 174 | - if ( '' !== $thumbnail_id ) { |
|
| 173 | + $thumbnail_id = get_post_thumbnail_id($post->ID); |
|
| 174 | + if ('' !== $thumbnail_id) { |
|
| 175 | 175 | $ids[] = $thumbnail_id; |
| 176 | 176 | } |
| 177 | 177 | |
@@ -185,26 +185,26 @@ discard block |
||
| 185 | 185 | $embeds = array(); |
| 186 | 186 | |
| 187 | 187 | // Get the gallery, removing existing ids. |
| 188 | - $gallery = array_diff( $this->attachment_service->get_gallery( $post ), $ids, $embeds ); |
|
| 188 | + $gallery = array_diff($this->attachment_service->get_gallery($post), $ids, $embeds); |
|
| 189 | 189 | |
| 190 | 190 | // Map the attachment ids to images' data structured for schema.org use. |
| 191 | - $images = array_map( function ( $item ) { |
|
| 191 | + $images = array_map(function($item) { |
|
| 192 | 192 | /* |
| 193 | 193 | * @todo: we're not sure that we're getting attachment data here, we |
| 194 | 194 | * should filter `false`s. |
| 195 | 195 | */ |
| 196 | 196 | |
| 197 | 197 | // Get the attachment data. |
| 198 | - $attachment = wp_get_attachment_image_src( $item, 'full' ); |
|
| 198 | + $attachment = wp_get_attachment_image_src($item, 'full'); |
|
| 199 | 199 | |
| 200 | 200 | // Refactor data as per schema.org specifications. |
| 201 | - return Wordlift_Abstract_Post_To_Jsonld_Converter::set_image_size( array( |
|
| 201 | + return Wordlift_Abstract_Post_To_Jsonld_Converter::set_image_size(array( |
|
| 202 | 202 | '@type' => 'ImageObject', |
| 203 | 203 | 'url' => $attachment[0], |
| 204 | - ), $attachment ); |
|
| 205 | - }, array_merge( $ids, $embeds, $gallery ) ); |
|
| 204 | + ), $attachment); |
|
| 205 | + }, array_merge($ids, $embeds, $gallery)); |
|
| 206 | 206 | |
| 207 | - if ( 0 < count( $images ) ) { |
|
| 207 | + if (0 < count($images)) { |
|
| 208 | 208 | $jsonld['image'] = $images; |
| 209 | 209 | } |
| 210 | 210 | |
@@ -221,17 +221,17 @@ discard block |
||
| 221 | 221 | * |
| 222 | 222 | * @return array The enriched `ImageObject` array. |
| 223 | 223 | */ |
| 224 | - public static function set_image_size( $image, $attachment ) { |
|
| 224 | + public static function set_image_size($image, $attachment) { |
|
| 225 | 225 | |
| 226 | 226 | // If you specify a "width" or "height" value you should leave out |
| 227 | 227 | // 'px'. For example: "width":"4608px" should be "width":"4608". |
| 228 | 228 | // |
| 229 | 229 | // See https://github.com/insideout10/wordlift-plugin/issues/451. |
| 230 | - if ( isset( $attachment[1] ) && is_numeric( $attachment[1] ) && 0 < $attachment[1] ) { |
|
| 230 | + if (isset($attachment[1]) && is_numeric($attachment[1]) && 0 < $attachment[1]) { |
|
| 231 | 231 | $image['width'] = $attachment[1]; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - if ( isset( $attachment[2] ) && is_numeric( $attachment[2] ) && 0 < $attachment[2] ) { |
|
| 234 | + if (isset($attachment[2]) && is_numeric($attachment[2]) && 0 < $attachment[2]) { |
|
| 235 | 235 | $image['height'] = $attachment[2]; |
| 236 | 236 | } |
| 237 | 237 | |
@@ -13,163 +13,163 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class Wordlift_Entity_Post_To_Jsonld_Converter extends Wordlift_Abstract_Post_To_Jsonld_Converter { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * A {@link Wordlift_Property_Getter} instance. |
|
| 18 | - * |
|
| 19 | - * @since 3.8.0 |
|
| 20 | - * @access private |
|
| 21 | - * @var \Wordlift_Property_Getter $property_getter A {@link Wordlift_Property_Getter} instance. |
|
| 22 | - */ |
|
| 23 | - private $property_getter; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * Wordlift_Entity_To_Jsonld_Converter constructor. |
|
| 27 | - * |
|
| 28 | - * @since 3.8.0 |
|
| 29 | - * |
|
| 30 | - * @param \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 31 | - * @param \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 32 | - * @param \Wordlift_User_Service $user_service A {@link Wordlift_User_Service} instance. |
|
| 33 | - * @param \Wordlift_Attachment_Service $attachment_service A {@link Wordlift_Attachment_Service} instance. |
|
| 34 | - * @param \Wordlift_Property_Getter $property_getter A {@link Wordlift_Property_Getter} instance. |
|
| 35 | - */ |
|
| 36 | - public function __construct( $entity_type_service, $entity_service, $user_service, $attachment_service, $property_getter ) { |
|
| 37 | - parent::__construct( $entity_type_service, $entity_service, $user_service, $attachment_service ); |
|
| 38 | - |
|
| 39 | - $this->property_getter = $property_getter; |
|
| 40 | - |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Convert the provided {@link WP_Post} to a JSON-LD array. Any entity reference |
|
| 45 | - * found while processing the post is set in the $references array. |
|
| 46 | - * |
|
| 47 | - * @since 3.8.0 |
|
| 48 | - * |
|
| 49 | - * @param int $post_id The {@link WP_Post} id. |
|
| 50 | - * |
|
| 51 | - * @param array $references An array of entity references. |
|
| 52 | - * |
|
| 53 | - * @return array A JSON-LD array. |
|
| 54 | - */ |
|
| 55 | - public function convert( $post_id, &$references = array() ) { |
|
| 56 | - |
|
| 57 | - // Get the post instance. |
|
| 58 | - $post = get_post( $post_id ); |
|
| 59 | - if ( null === $post ) { |
|
| 60 | - // Post not found. |
|
| 61 | - return null; |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - // Get the base JSON-LD and the list of entities referenced by this entity. |
|
| 65 | - $jsonld = parent::convert( $post_id, $references ); |
|
| 66 | - |
|
| 67 | - // Get the entity name. |
|
| 68 | - $jsonld['name'] = $post->post_title; |
|
| 69 | - |
|
| 70 | - // 3.13.0, add alternate names. |
|
| 71 | - $alternative_labels = $this->entity_service->get_alternative_labels( $post_id ); |
|
| 72 | - if ( 0 < count( $alternative_labels ) ) { |
|
| 73 | - $jsonld['alternateName'] = $alternative_labels; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - // Get the entity @type. |
|
| 77 | - $type = $this->entity_type_service->get( $post_id ); |
|
| 78 | - |
|
| 79 | - // Get the configured type custom fields. |
|
| 80 | - $fields = $type['custom_fields']; |
|
| 81 | - |
|
| 82 | - // Set a reference to use in closures. |
|
| 83 | - $converter = $this; |
|
| 84 | - |
|
| 85 | - // Try each field on the entity. |
|
| 86 | - foreach ( $fields as $key => $value ) { |
|
| 87 | - |
|
| 88 | - // Get the predicate. |
|
| 89 | - $name = $this->relative_to_context( $value['predicate'] ); |
|
| 90 | - |
|
| 91 | - // Get the value, the property service will get the right extractor |
|
| 92 | - // for that property. |
|
| 93 | - $value = $this->property_getter->get( $post->ID, $key ); |
|
| 94 | - |
|
| 95 | - if ( 0 === count( $value ) ) { |
|
| 96 | - continue; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - // Map the value to the property name. |
|
| 100 | - // If we got an array with just one value, we return that one value. |
|
| 101 | - // If we got a Wordlift_Property_Entity_Reference we get the URL. |
|
| 102 | - $jsonld[ $name ] = $this->make_one( array_map( function ( $item ) use ( $converter, &$references ) { |
|
| 103 | - |
|
| 104 | - if ( $item instanceof Wordlift_Property_Entity_Reference ) { |
|
| 105 | - |
|
| 106 | - $url = $item->getURL(); |
|
| 107 | - |
|
| 108 | - // The refactored converters require the entity id. |
|
| 109 | - $references[] = $item->getID(); |
|
| 110 | - |
|
| 111 | - return array( |
|
| 112 | - '@id' => $url, |
|
| 113 | - ); |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - return $converter->relative_to_context( $item ); |
|
| 117 | - }, $value ) ); |
|
| 118 | - |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - return $this->post_process( $jsonld ); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * If the provided array of values contains only one value, then one single |
|
| 126 | - * value is returned, otherwise the original array is returned. |
|
| 127 | - * |
|
| 128 | - * @since 3.8.0 |
|
| 129 | - * @access private |
|
| 130 | - * |
|
| 131 | - * @param array $value An array of values. |
|
| 132 | - * |
|
| 133 | - * @return mixed|array A single value or the original array. |
|
| 134 | - */ |
|
| 135 | - private function make_one( $value ) { |
|
| 136 | - |
|
| 137 | - return 1 === count( $value ) ? $value[0] : $value; |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * Post process the generated JSON to reorganize values which are stored as 1st |
|
| 142 | - * level in WP but are really 2nd level. |
|
| 143 | - * |
|
| 144 | - * @since 3.8.0 |
|
| 145 | - * |
|
| 146 | - * @param array $jsonld An array of JSON-LD properties and values. |
|
| 147 | - * |
|
| 148 | - * @return array The array remapped. |
|
| 149 | - */ |
|
| 150 | - private function post_process( $jsonld ) { |
|
| 151 | - |
|
| 152 | - foreach ( $jsonld as $key => $value ) { |
|
| 153 | - if ( 'streetAddress' === $key || 'postalCode' === $key || 'addressLocality' === $key || 'addressRegion' === $key || 'addressCountry' === $key || 'postOfficeBoxNumber' === $key ) { |
|
| 154 | - $jsonld['address']['@type'] = 'PostalAddress'; |
|
| 155 | - $jsonld['address'][ $key ] = $value; |
|
| 156 | - unset( $jsonld[ $key ] ); |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - if ( 'latitude' === $key || 'longitude' === $key ) { |
|
| 160 | - $jsonld['geo']['@type'] = 'GeoCoordinates'; |
|
| 161 | - $jsonld['geo'][ $key ] = $value; |
|
| 162 | - unset( $jsonld[ $key ] ); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - if ( 'calories' === $key ) { |
|
| 166 | - $jsonld['nutrition']['@type'] = 'NutritionInformation'; |
|
| 167 | - $jsonld['nutrition'][ $key ] = $value; |
|
| 168 | - unset( $jsonld[ $key ] ); |
|
| 169 | - } |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - return $jsonld; |
|
| 173 | - } |
|
| 16 | + /** |
|
| 17 | + * A {@link Wordlift_Property_Getter} instance. |
|
| 18 | + * |
|
| 19 | + * @since 3.8.0 |
|
| 20 | + * @access private |
|
| 21 | + * @var \Wordlift_Property_Getter $property_getter A {@link Wordlift_Property_Getter} instance. |
|
| 22 | + */ |
|
| 23 | + private $property_getter; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * Wordlift_Entity_To_Jsonld_Converter constructor. |
|
| 27 | + * |
|
| 28 | + * @since 3.8.0 |
|
| 29 | + * |
|
| 30 | + * @param \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 31 | + * @param \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 32 | + * @param \Wordlift_User_Service $user_service A {@link Wordlift_User_Service} instance. |
|
| 33 | + * @param \Wordlift_Attachment_Service $attachment_service A {@link Wordlift_Attachment_Service} instance. |
|
| 34 | + * @param \Wordlift_Property_Getter $property_getter A {@link Wordlift_Property_Getter} instance. |
|
| 35 | + */ |
|
| 36 | + public function __construct( $entity_type_service, $entity_service, $user_service, $attachment_service, $property_getter ) { |
|
| 37 | + parent::__construct( $entity_type_service, $entity_service, $user_service, $attachment_service ); |
|
| 38 | + |
|
| 39 | + $this->property_getter = $property_getter; |
|
| 40 | + |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Convert the provided {@link WP_Post} to a JSON-LD array. Any entity reference |
|
| 45 | + * found while processing the post is set in the $references array. |
|
| 46 | + * |
|
| 47 | + * @since 3.8.0 |
|
| 48 | + * |
|
| 49 | + * @param int $post_id The {@link WP_Post} id. |
|
| 50 | + * |
|
| 51 | + * @param array $references An array of entity references. |
|
| 52 | + * |
|
| 53 | + * @return array A JSON-LD array. |
|
| 54 | + */ |
|
| 55 | + public function convert( $post_id, &$references = array() ) { |
|
| 56 | + |
|
| 57 | + // Get the post instance. |
|
| 58 | + $post = get_post( $post_id ); |
|
| 59 | + if ( null === $post ) { |
|
| 60 | + // Post not found. |
|
| 61 | + return null; |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + // Get the base JSON-LD and the list of entities referenced by this entity. |
|
| 65 | + $jsonld = parent::convert( $post_id, $references ); |
|
| 66 | + |
|
| 67 | + // Get the entity name. |
|
| 68 | + $jsonld['name'] = $post->post_title; |
|
| 69 | + |
|
| 70 | + // 3.13.0, add alternate names. |
|
| 71 | + $alternative_labels = $this->entity_service->get_alternative_labels( $post_id ); |
|
| 72 | + if ( 0 < count( $alternative_labels ) ) { |
|
| 73 | + $jsonld['alternateName'] = $alternative_labels; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + // Get the entity @type. |
|
| 77 | + $type = $this->entity_type_service->get( $post_id ); |
|
| 78 | + |
|
| 79 | + // Get the configured type custom fields. |
|
| 80 | + $fields = $type['custom_fields']; |
|
| 81 | + |
|
| 82 | + // Set a reference to use in closures. |
|
| 83 | + $converter = $this; |
|
| 84 | + |
|
| 85 | + // Try each field on the entity. |
|
| 86 | + foreach ( $fields as $key => $value ) { |
|
| 87 | + |
|
| 88 | + // Get the predicate. |
|
| 89 | + $name = $this->relative_to_context( $value['predicate'] ); |
|
| 90 | + |
|
| 91 | + // Get the value, the property service will get the right extractor |
|
| 92 | + // for that property. |
|
| 93 | + $value = $this->property_getter->get( $post->ID, $key ); |
|
| 94 | + |
|
| 95 | + if ( 0 === count( $value ) ) { |
|
| 96 | + continue; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + // Map the value to the property name. |
|
| 100 | + // If we got an array with just one value, we return that one value. |
|
| 101 | + // If we got a Wordlift_Property_Entity_Reference we get the URL. |
|
| 102 | + $jsonld[ $name ] = $this->make_one( array_map( function ( $item ) use ( $converter, &$references ) { |
|
| 103 | + |
|
| 104 | + if ( $item instanceof Wordlift_Property_Entity_Reference ) { |
|
| 105 | + |
|
| 106 | + $url = $item->getURL(); |
|
| 107 | + |
|
| 108 | + // The refactored converters require the entity id. |
|
| 109 | + $references[] = $item->getID(); |
|
| 110 | + |
|
| 111 | + return array( |
|
| 112 | + '@id' => $url, |
|
| 113 | + ); |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + return $converter->relative_to_context( $item ); |
|
| 117 | + }, $value ) ); |
|
| 118 | + |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + return $this->post_process( $jsonld ); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * If the provided array of values contains only one value, then one single |
|
| 126 | + * value is returned, otherwise the original array is returned. |
|
| 127 | + * |
|
| 128 | + * @since 3.8.0 |
|
| 129 | + * @access private |
|
| 130 | + * |
|
| 131 | + * @param array $value An array of values. |
|
| 132 | + * |
|
| 133 | + * @return mixed|array A single value or the original array. |
|
| 134 | + */ |
|
| 135 | + private function make_one( $value ) { |
|
| 136 | + |
|
| 137 | + return 1 === count( $value ) ? $value[0] : $value; |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * Post process the generated JSON to reorganize values which are stored as 1st |
|
| 142 | + * level in WP but are really 2nd level. |
|
| 143 | + * |
|
| 144 | + * @since 3.8.0 |
|
| 145 | + * |
|
| 146 | + * @param array $jsonld An array of JSON-LD properties and values. |
|
| 147 | + * |
|
| 148 | + * @return array The array remapped. |
|
| 149 | + */ |
|
| 150 | + private function post_process( $jsonld ) { |
|
| 151 | + |
|
| 152 | + foreach ( $jsonld as $key => $value ) { |
|
| 153 | + if ( 'streetAddress' === $key || 'postalCode' === $key || 'addressLocality' === $key || 'addressRegion' === $key || 'addressCountry' === $key || 'postOfficeBoxNumber' === $key ) { |
|
| 154 | + $jsonld['address']['@type'] = 'PostalAddress'; |
|
| 155 | + $jsonld['address'][ $key ] = $value; |
|
| 156 | + unset( $jsonld[ $key ] ); |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + if ( 'latitude' === $key || 'longitude' === $key ) { |
|
| 160 | + $jsonld['geo']['@type'] = 'GeoCoordinates'; |
|
| 161 | + $jsonld['geo'][ $key ] = $value; |
|
| 162 | + unset( $jsonld[ $key ] ); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + if ( 'calories' === $key ) { |
|
| 166 | + $jsonld['nutrition']['@type'] = 'NutritionInformation'; |
|
| 167 | + $jsonld['nutrition'][ $key ] = $value; |
|
| 168 | + unset( $jsonld[ $key ] ); |
|
| 169 | + } |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + return $jsonld; |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | 175 | } |
@@ -33,8 +33,8 @@ discard block |
||
| 33 | 33 | * @param \Wordlift_Attachment_Service $attachment_service A {@link Wordlift_Attachment_Service} instance. |
| 34 | 34 | * @param \Wordlift_Property_Getter $property_getter A {@link Wordlift_Property_Getter} instance. |
| 35 | 35 | */ |
| 36 | - public function __construct( $entity_type_service, $entity_service, $user_service, $attachment_service, $property_getter ) { |
|
| 37 | - parent::__construct( $entity_type_service, $entity_service, $user_service, $attachment_service ); |
|
| 36 | + public function __construct($entity_type_service, $entity_service, $user_service, $attachment_service, $property_getter) { |
|
| 37 | + parent::__construct($entity_type_service, $entity_service, $user_service, $attachment_service); |
|
| 38 | 38 | |
| 39 | 39 | $this->property_getter = $property_getter; |
| 40 | 40 | |
@@ -52,29 +52,29 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @return array A JSON-LD array. |
| 54 | 54 | */ |
| 55 | - public function convert( $post_id, &$references = array() ) { |
|
| 55 | + public function convert($post_id, &$references = array()) { |
|
| 56 | 56 | |
| 57 | 57 | // Get the post instance. |
| 58 | - $post = get_post( $post_id ); |
|
| 59 | - if ( null === $post ) { |
|
| 58 | + $post = get_post($post_id); |
|
| 59 | + if (null === $post) { |
|
| 60 | 60 | // Post not found. |
| 61 | 61 | return null; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | // Get the base JSON-LD and the list of entities referenced by this entity. |
| 65 | - $jsonld = parent::convert( $post_id, $references ); |
|
| 65 | + $jsonld = parent::convert($post_id, $references); |
|
| 66 | 66 | |
| 67 | 67 | // Get the entity name. |
| 68 | 68 | $jsonld['name'] = $post->post_title; |
| 69 | 69 | |
| 70 | 70 | // 3.13.0, add alternate names. |
| 71 | - $alternative_labels = $this->entity_service->get_alternative_labels( $post_id ); |
|
| 72 | - if ( 0 < count( $alternative_labels ) ) { |
|
| 71 | + $alternative_labels = $this->entity_service->get_alternative_labels($post_id); |
|
| 72 | + if (0 < count($alternative_labels)) { |
|
| 73 | 73 | $jsonld['alternateName'] = $alternative_labels; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | // Get the entity @type. |
| 77 | - $type = $this->entity_type_service->get( $post_id ); |
|
| 77 | + $type = $this->entity_type_service->get($post_id); |
|
| 78 | 78 | |
| 79 | 79 | // Get the configured type custom fields. |
| 80 | 80 | $fields = $type['custom_fields']; |
@@ -83,25 +83,25 @@ discard block |
||
| 83 | 83 | $converter = $this; |
| 84 | 84 | |
| 85 | 85 | // Try each field on the entity. |
| 86 | - foreach ( $fields as $key => $value ) { |
|
| 86 | + foreach ($fields as $key => $value) { |
|
| 87 | 87 | |
| 88 | 88 | // Get the predicate. |
| 89 | - $name = $this->relative_to_context( $value['predicate'] ); |
|
| 89 | + $name = $this->relative_to_context($value['predicate']); |
|
| 90 | 90 | |
| 91 | 91 | // Get the value, the property service will get the right extractor |
| 92 | 92 | // for that property. |
| 93 | - $value = $this->property_getter->get( $post->ID, $key ); |
|
| 93 | + $value = $this->property_getter->get($post->ID, $key); |
|
| 94 | 94 | |
| 95 | - if ( 0 === count( $value ) ) { |
|
| 95 | + if (0 === count($value)) { |
|
| 96 | 96 | continue; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // Map the value to the property name. |
| 100 | 100 | // If we got an array with just one value, we return that one value. |
| 101 | 101 | // If we got a Wordlift_Property_Entity_Reference we get the URL. |
| 102 | - $jsonld[ $name ] = $this->make_one( array_map( function ( $item ) use ( $converter, &$references ) { |
|
| 102 | + $jsonld[$name] = $this->make_one(array_map(function($item) use ($converter, &$references) { |
|
| 103 | 103 | |
| 104 | - if ( $item instanceof Wordlift_Property_Entity_Reference ) { |
|
| 104 | + if ($item instanceof Wordlift_Property_Entity_Reference) { |
|
| 105 | 105 | |
| 106 | 106 | $url = $item->getURL(); |
| 107 | 107 | |
@@ -113,12 +113,12 @@ discard block |
||
| 113 | 113 | ); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - return $converter->relative_to_context( $item ); |
|
| 117 | - }, $value ) ); |
|
| 116 | + return $converter->relative_to_context($item); |
|
| 117 | + }, $value)); |
|
| 118 | 118 | |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - return $this->post_process( $jsonld ); |
|
| 121 | + return $this->post_process($jsonld); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -132,9 +132,9 @@ discard block |
||
| 132 | 132 | * |
| 133 | 133 | * @return mixed|array A single value or the original array. |
| 134 | 134 | */ |
| 135 | - private function make_one( $value ) { |
|
| 135 | + private function make_one($value) { |
|
| 136 | 136 | |
| 137 | - return 1 === count( $value ) ? $value[0] : $value; |
|
| 137 | + return 1 === count($value) ? $value[0] : $value; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -147,25 +147,25 @@ discard block |
||
| 147 | 147 | * |
| 148 | 148 | * @return array The array remapped. |
| 149 | 149 | */ |
| 150 | - private function post_process( $jsonld ) { |
|
| 150 | + private function post_process($jsonld) { |
|
| 151 | 151 | |
| 152 | - foreach ( $jsonld as $key => $value ) { |
|
| 153 | - if ( 'streetAddress' === $key || 'postalCode' === $key || 'addressLocality' === $key || 'addressRegion' === $key || 'addressCountry' === $key || 'postOfficeBoxNumber' === $key ) { |
|
| 152 | + foreach ($jsonld as $key => $value) { |
|
| 153 | + if ('streetAddress' === $key || 'postalCode' === $key || 'addressLocality' === $key || 'addressRegion' === $key || 'addressCountry' === $key || 'postOfficeBoxNumber' === $key) { |
|
| 154 | 154 | $jsonld['address']['@type'] = 'PostalAddress'; |
| 155 | - $jsonld['address'][ $key ] = $value; |
|
| 156 | - unset( $jsonld[ $key ] ); |
|
| 155 | + $jsonld['address'][$key] = $value; |
|
| 156 | + unset($jsonld[$key]); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - if ( 'latitude' === $key || 'longitude' === $key ) { |
|
| 159 | + if ('latitude' === $key || 'longitude' === $key) { |
|
| 160 | 160 | $jsonld['geo']['@type'] = 'GeoCoordinates'; |
| 161 | - $jsonld['geo'][ $key ] = $value; |
|
| 162 | - unset( $jsonld[ $key ] ); |
|
| 161 | + $jsonld['geo'][$key] = $value; |
|
| 162 | + unset($jsonld[$key]); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - if ( 'calories' === $key ) { |
|
| 165 | + if ('calories' === $key) { |
|
| 166 | 166 | $jsonld['nutrition']['@type'] = 'NutritionInformation'; |
| 167 | - $jsonld['nutrition'][ $key ] = $value; |
|
| 168 | - unset( $jsonld[ $key ] ); |
|
| 167 | + $jsonld['nutrition'][$key] = $value; |
|
| 168 | + unset($jsonld[$key]); |
|
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | |
@@ -18,377 +18,377 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | class Wordlift_Relation_Service { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * The singleton instance. |
|
| 23 | - * |
|
| 24 | - * @since 3.15.0 |
|
| 25 | - * @access private |
|
| 26 | - * @var \Wordlift_Relation_Service $instance The singleton instance. |
|
| 27 | - */ |
|
| 28 | - private static $instance; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * The relation table name in MySQL, set during instantiation. |
|
| 32 | - * |
|
| 33 | - * @since 3.15.0 |
|
| 34 | - * @access private |
|
| 35 | - * @var string $relation_table The relation table name. |
|
| 36 | - */ |
|
| 37 | - private $relation_table; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * A {@link Wordlift_Log_Service} instance. |
|
| 41 | - * |
|
| 42 | - * @since 3.15.3 |
|
| 43 | - * |
|
| 44 | - * @var Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 45 | - */ |
|
| 46 | - private static $log; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * Create a {@link Wordlift_Relation_Service} instance. |
|
| 50 | - * |
|
| 51 | - * @since 3.15.0 |
|
| 52 | - */ |
|
| 53 | - public function __construct() { |
|
| 54 | - |
|
| 55 | - self::$log = Wordlift_Log_Service::get_logger( get_class() ); |
|
| 56 | - |
|
| 57 | - global $wpdb; |
|
| 58 | - |
|
| 59 | - // The relations table. |
|
| 60 | - $this->relation_table = "{$wpdb->prefix}wl_relation_instances"; |
|
| 61 | - |
|
| 62 | - self::$instance = $this; |
|
| 63 | - |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * Get the singleton instance. |
|
| 68 | - * |
|
| 69 | - * @since 3.15.0 |
|
| 70 | - * @access public |
|
| 71 | - * @return \Wordlift_Relation_Service The {@link Wordlift_Relation_Service} |
|
| 72 | - * singleton instance. |
|
| 73 | - */ |
|
| 74 | - public static function get_instance() { |
|
| 75 | - |
|
| 76 | - return self::$instance; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Get the articles referencing the specified entity {@link WP_Post}. |
|
| 81 | - * |
|
| 82 | - * @since 3.15.0 |
|
| 83 | - * |
|
| 84 | - * @param int|array $object_id The entity {@link WP_Post}'s id. |
|
| 85 | - * @param string $fields The fields to return, 'ids' to only return ids or |
|
| 86 | - * '*' to return all fields, by default '*'. |
|
| 87 | - * @param null|string $predicate The predicate (who|what|...), by default all. |
|
| 88 | - * @param null|string $status The status, by default all. |
|
| 89 | - * @param array $excludes An array of ids to exclude from the results. |
|
| 90 | - * @param null|int $limit The maximum number of results, by default |
|
| 91 | - * no limit. |
|
| 92 | - * @param null|array $include The {@link WP_Post}s' ids to include. |
|
| 93 | - * |
|
| 94 | - * @return array|object|null Database query results |
|
| 95 | - */ |
|
| 96 | - public function get_article_subjects( $object_id, $fields = '*', $predicate = null, $status = null, $excludes = array(), $limit = null, $include = null ) { |
|
| 97 | - global $wpdb; |
|
| 98 | - |
|
| 99 | - // The output fields. |
|
| 100 | - $actual_fields = self::fields( $fields ); |
|
| 101 | - |
|
| 102 | - self::$log->trace( 'Getting article subjects for object ' . implode( ', ', (array) $object_id ) . '...' ); |
|
| 103 | - |
|
| 104 | - $objects = $this->article_id_to_entity_id( $object_id ); |
|
| 105 | - |
|
| 106 | - // If there are no related objects, return an empty array. |
|
| 107 | - if ( empty( $objects ) ) { |
|
| 108 | - self::$log->debug( 'No entities found for object ' . implode( ', ', (array) $object_id ) . '.' ); |
|
| 109 | - |
|
| 110 | - return array(); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - self::$log->debug( count( $objects ) . ' entity id(s) found for object ' . implode( ', ', (array) $object_id ) . '.' ); |
|
| 114 | - |
|
| 115 | - $sql = |
|
| 116 | - " |
|
| 21 | + /** |
|
| 22 | + * The singleton instance. |
|
| 23 | + * |
|
| 24 | + * @since 3.15.0 |
|
| 25 | + * @access private |
|
| 26 | + * @var \Wordlift_Relation_Service $instance The singleton instance. |
|
| 27 | + */ |
|
| 28 | + private static $instance; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * The relation table name in MySQL, set during instantiation. |
|
| 32 | + * |
|
| 33 | + * @since 3.15.0 |
|
| 34 | + * @access private |
|
| 35 | + * @var string $relation_table The relation table name. |
|
| 36 | + */ |
|
| 37 | + private $relation_table; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * A {@link Wordlift_Log_Service} instance. |
|
| 41 | + * |
|
| 42 | + * @since 3.15.3 |
|
| 43 | + * |
|
| 44 | + * @var Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 45 | + */ |
|
| 46 | + private static $log; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * Create a {@link Wordlift_Relation_Service} instance. |
|
| 50 | + * |
|
| 51 | + * @since 3.15.0 |
|
| 52 | + */ |
|
| 53 | + public function __construct() { |
|
| 54 | + |
|
| 55 | + self::$log = Wordlift_Log_Service::get_logger( get_class() ); |
|
| 56 | + |
|
| 57 | + global $wpdb; |
|
| 58 | + |
|
| 59 | + // The relations table. |
|
| 60 | + $this->relation_table = "{$wpdb->prefix}wl_relation_instances"; |
|
| 61 | + |
|
| 62 | + self::$instance = $this; |
|
| 63 | + |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * Get the singleton instance. |
|
| 68 | + * |
|
| 69 | + * @since 3.15.0 |
|
| 70 | + * @access public |
|
| 71 | + * @return \Wordlift_Relation_Service The {@link Wordlift_Relation_Service} |
|
| 72 | + * singleton instance. |
|
| 73 | + */ |
|
| 74 | + public static function get_instance() { |
|
| 75 | + |
|
| 76 | + return self::$instance; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Get the articles referencing the specified entity {@link WP_Post}. |
|
| 81 | + * |
|
| 82 | + * @since 3.15.0 |
|
| 83 | + * |
|
| 84 | + * @param int|array $object_id The entity {@link WP_Post}'s id. |
|
| 85 | + * @param string $fields The fields to return, 'ids' to only return ids or |
|
| 86 | + * '*' to return all fields, by default '*'. |
|
| 87 | + * @param null|string $predicate The predicate (who|what|...), by default all. |
|
| 88 | + * @param null|string $status The status, by default all. |
|
| 89 | + * @param array $excludes An array of ids to exclude from the results. |
|
| 90 | + * @param null|int $limit The maximum number of results, by default |
|
| 91 | + * no limit. |
|
| 92 | + * @param null|array $include The {@link WP_Post}s' ids to include. |
|
| 93 | + * |
|
| 94 | + * @return array|object|null Database query results |
|
| 95 | + */ |
|
| 96 | + public function get_article_subjects( $object_id, $fields = '*', $predicate = null, $status = null, $excludes = array(), $limit = null, $include = null ) { |
|
| 97 | + global $wpdb; |
|
| 98 | + |
|
| 99 | + // The output fields. |
|
| 100 | + $actual_fields = self::fields( $fields ); |
|
| 101 | + |
|
| 102 | + self::$log->trace( 'Getting article subjects for object ' . implode( ', ', (array) $object_id ) . '...' ); |
|
| 103 | + |
|
| 104 | + $objects = $this->article_id_to_entity_id( $object_id ); |
|
| 105 | + |
|
| 106 | + // If there are no related objects, return an empty array. |
|
| 107 | + if ( empty( $objects ) ) { |
|
| 108 | + self::$log->debug( 'No entities found for object ' . implode( ', ', (array) $object_id ) . '.' ); |
|
| 109 | + |
|
| 110 | + return array(); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + self::$log->debug( count( $objects ) . ' entity id(s) found for object ' . implode( ', ', (array) $object_id ) . '.' ); |
|
| 114 | + |
|
| 115 | + $sql = |
|
| 116 | + " |
|
| 117 | 117 | SELECT DISTINCT p.$actual_fields |
| 118 | 118 | FROM {$this->relation_table} r |
| 119 | 119 | INNER JOIN $wpdb->posts p |
| 120 | 120 | ON p.id = r.subject_id |
| 121 | 121 | " |
| 122 | - // Add the status clause. |
|
| 123 | - . self::and_status( $status ) |
|
| 124 | - . self::inner_join_is_article() |
|
| 125 | - . self::where_object_id( $objects ) |
|
| 126 | - // Since `object_id` can be an article ID we need to exclude it from |
|
| 127 | - // the results. |
|
| 128 | - . self::and_article_not_in( array_merge( $excludes, (array) $object_id ) ) |
|
| 129 | - . self::and_article_in( $include ) |
|
| 130 | - . self::and_post_type_in() |
|
| 131 | - . self::and_predicate( $predicate ) |
|
| 132 | - . self::limit( $limit ); |
|
| 133 | - |
|
| 134 | - |
|
| 135 | - return '*' === $actual_fields ? $wpdb->get_results( $sql ) : $wpdb->get_col( $sql ); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * The `post_type IN` clause. |
|
| 140 | - * |
|
| 141 | - * @since 3.15.3 |
|
| 142 | - * |
|
| 143 | - * @return string The `post_type IN` clause. |
|
| 144 | - */ |
|
| 145 | - private static function and_post_type_in() { |
|
| 146 | - |
|
| 147 | - return " AND p.post_type IN ( '" |
|
| 148 | - . implode( |
|
| 149 | - "','", |
|
| 150 | - array_map( 'esc_sql', Wordlift_Entity_Service::valid_entity_post_types() ) |
|
| 151 | - ) |
|
| 152 | - . "' )"; |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * Add the limit clause if specified. |
|
| 157 | - * |
|
| 158 | - * @since 3.15.0 |
|
| 159 | - * |
|
| 160 | - * @param null|int $limit The maximum number of results. |
|
| 161 | - * |
|
| 162 | - * @return string The limit clause (empty if no limit has been specified). |
|
| 163 | - */ |
|
| 164 | - private static function limit( $limit = null ) { |
|
| 165 | - |
|
| 166 | - if ( null === $limit ) { |
|
| 167 | - return ''; |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - return "LIMIT $limit"; |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - /** |
|
| 174 | - * Map the provided ids into entities (i.e. return the id if it's an entity |
|
| 175 | - * or get the entities if it's a post). |
|
| 176 | - * |
|
| 177 | - * @since 3.15.0 |
|
| 178 | - * |
|
| 179 | - * @param int|array $object_id An array of posts/entities' ids. |
|
| 180 | - * |
|
| 181 | - * @return array An array of entities' ids. |
|
| 182 | - */ |
|
| 183 | - private function article_id_to_entity_id( $object_id ) { |
|
| 184 | - |
|
| 185 | - $entity_service = Wordlift_Entity_Service::get_instance(); |
|
| 186 | - |
|
| 187 | - $relation_service = $this; |
|
| 188 | - |
|
| 189 | - return array_reduce( (array) $object_id, function ( $carry, $item ) use ( $entity_service, $relation_service ) { |
|
| 190 | - if ( $entity_service->is_entity( $item ) ) { |
|
| 191 | - return array_merge( $carry, (array) $item ); |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - return array_merge( $carry, $relation_service->get_objects( $item, 'ids' ) ); |
|
| 195 | - }, array() ); |
|
| 196 | - |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - /** |
|
| 200 | - * Add the WHERE clause. |
|
| 201 | - * |
|
| 202 | - * @since 3.15.0 |
|
| 203 | - * |
|
| 204 | - * @param int|array $object_id An array of {@link WP_Post}s' ids. |
|
| 205 | - * |
|
| 206 | - * @return string The WHERE clause. |
|
| 207 | - */ |
|
| 208 | - private static function where_object_id( $object_id ) { |
|
| 209 | - |
|
| 210 | - if ( empty( $object_id ) ) { |
|
| 211 | - self::$log->warn( sprintf( "%s `where_object_id` called with empty `object_id`.", var_export( debug_backtrace( false, 3 ), true ) ) ); |
|
| 212 | - |
|
| 213 | - return ' WHERE 1 = 1'; |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - return ' WHERE r.object_id IN ( ' . implode( ',', wp_parse_id_list( (array) $object_id ) ) . ' )'; |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - /** |
|
| 220 | - * Add the exclude clause. |
|
| 221 | - * |
|
| 222 | - * @since 3.15.0 |
|
| 223 | - * |
|
| 224 | - * @param int|array $exclude An array of {@link WP_Post}s' ids to exclude. |
|
| 225 | - * |
|
| 226 | - * @return string The exclude clause. |
|
| 227 | - */ |
|
| 228 | - private static function and_article_not_in( $exclude ) { |
|
| 229 | - |
|
| 230 | - return ' AND NOT p.ID IN ( ' . implode( ',', wp_parse_id_list( (array) $exclude ) ) . ' )'; |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - /** |
|
| 234 | - * Add the include clause. |
|
| 235 | - * |
|
| 236 | - * @since 3.15.0 |
|
| 237 | - * |
|
| 238 | - * @param null|int|array $include An array of {@link WP_Post}s' ids. |
|
| 239 | - * |
|
| 240 | - * @return string An empty string if $include is null otherwise the include |
|
| 241 | - * clause. |
|
| 242 | - */ |
|
| 243 | - private static function and_article_in( $include = null ) { |
|
| 244 | - |
|
| 245 | - if ( null === $include ) { |
|
| 246 | - return ''; |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - return ' AND p.ID IN ( ' . implode( ',', wp_parse_id_list( (array) $include ) ) . ' )'; |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * Get the entities' {@link WP_Post}s' ids referencing the specified {@link WP_Post}. |
|
| 254 | - * |
|
| 255 | - * @since 3.15.0 |
|
| 256 | - * |
|
| 257 | - * @param int $object_id The object {@link WP_Post}'s id. |
|
| 258 | - * @param string $fields The fields to return, 'ids' to only return ids or |
|
| 259 | - * '*' to return all fields, by default '*'. |
|
| 260 | - * @param null|string $status The status, by default all. |
|
| 261 | - * |
|
| 262 | - * @return array|object|null Database query results |
|
| 263 | - */ |
|
| 264 | - public function get_non_article_subjects( $object_id, $fields = '*', $status = null ) { |
|
| 265 | - global $wpdb; |
|
| 266 | - |
|
| 267 | - // The output fields. |
|
| 268 | - $actual_fields = self::fields( $fields ); |
|
| 269 | - |
|
| 270 | - $sql = $wpdb->prepare( |
|
| 271 | - " |
|
| 122 | + // Add the status clause. |
|
| 123 | + . self::and_status( $status ) |
|
| 124 | + . self::inner_join_is_article() |
|
| 125 | + . self::where_object_id( $objects ) |
|
| 126 | + // Since `object_id` can be an article ID we need to exclude it from |
|
| 127 | + // the results. |
|
| 128 | + . self::and_article_not_in( array_merge( $excludes, (array) $object_id ) ) |
|
| 129 | + . self::and_article_in( $include ) |
|
| 130 | + . self::and_post_type_in() |
|
| 131 | + . self::and_predicate( $predicate ) |
|
| 132 | + . self::limit( $limit ); |
|
| 133 | + |
|
| 134 | + |
|
| 135 | + return '*' === $actual_fields ? $wpdb->get_results( $sql ) : $wpdb->get_col( $sql ); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * The `post_type IN` clause. |
|
| 140 | + * |
|
| 141 | + * @since 3.15.3 |
|
| 142 | + * |
|
| 143 | + * @return string The `post_type IN` clause. |
|
| 144 | + */ |
|
| 145 | + private static function and_post_type_in() { |
|
| 146 | + |
|
| 147 | + return " AND p.post_type IN ( '" |
|
| 148 | + . implode( |
|
| 149 | + "','", |
|
| 150 | + array_map( 'esc_sql', Wordlift_Entity_Service::valid_entity_post_types() ) |
|
| 151 | + ) |
|
| 152 | + . "' )"; |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * Add the limit clause if specified. |
|
| 157 | + * |
|
| 158 | + * @since 3.15.0 |
|
| 159 | + * |
|
| 160 | + * @param null|int $limit The maximum number of results. |
|
| 161 | + * |
|
| 162 | + * @return string The limit clause (empty if no limit has been specified). |
|
| 163 | + */ |
|
| 164 | + private static function limit( $limit = null ) { |
|
| 165 | + |
|
| 166 | + if ( null === $limit ) { |
|
| 167 | + return ''; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + return "LIMIT $limit"; |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + /** |
|
| 174 | + * Map the provided ids into entities (i.e. return the id if it's an entity |
|
| 175 | + * or get the entities if it's a post). |
|
| 176 | + * |
|
| 177 | + * @since 3.15.0 |
|
| 178 | + * |
|
| 179 | + * @param int|array $object_id An array of posts/entities' ids. |
|
| 180 | + * |
|
| 181 | + * @return array An array of entities' ids. |
|
| 182 | + */ |
|
| 183 | + private function article_id_to_entity_id( $object_id ) { |
|
| 184 | + |
|
| 185 | + $entity_service = Wordlift_Entity_Service::get_instance(); |
|
| 186 | + |
|
| 187 | + $relation_service = $this; |
|
| 188 | + |
|
| 189 | + return array_reduce( (array) $object_id, function ( $carry, $item ) use ( $entity_service, $relation_service ) { |
|
| 190 | + if ( $entity_service->is_entity( $item ) ) { |
|
| 191 | + return array_merge( $carry, (array) $item ); |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + return array_merge( $carry, $relation_service->get_objects( $item, 'ids' ) ); |
|
| 195 | + }, array() ); |
|
| 196 | + |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + /** |
|
| 200 | + * Add the WHERE clause. |
|
| 201 | + * |
|
| 202 | + * @since 3.15.0 |
|
| 203 | + * |
|
| 204 | + * @param int|array $object_id An array of {@link WP_Post}s' ids. |
|
| 205 | + * |
|
| 206 | + * @return string The WHERE clause. |
|
| 207 | + */ |
|
| 208 | + private static function where_object_id( $object_id ) { |
|
| 209 | + |
|
| 210 | + if ( empty( $object_id ) ) { |
|
| 211 | + self::$log->warn( sprintf( "%s `where_object_id` called with empty `object_id`.", var_export( debug_backtrace( false, 3 ), true ) ) ); |
|
| 212 | + |
|
| 213 | + return ' WHERE 1 = 1'; |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + return ' WHERE r.object_id IN ( ' . implode( ',', wp_parse_id_list( (array) $object_id ) ) . ' )'; |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + /** |
|
| 220 | + * Add the exclude clause. |
|
| 221 | + * |
|
| 222 | + * @since 3.15.0 |
|
| 223 | + * |
|
| 224 | + * @param int|array $exclude An array of {@link WP_Post}s' ids to exclude. |
|
| 225 | + * |
|
| 226 | + * @return string The exclude clause. |
|
| 227 | + */ |
|
| 228 | + private static function and_article_not_in( $exclude ) { |
|
| 229 | + |
|
| 230 | + return ' AND NOT p.ID IN ( ' . implode( ',', wp_parse_id_list( (array) $exclude ) ) . ' )'; |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + /** |
|
| 234 | + * Add the include clause. |
|
| 235 | + * |
|
| 236 | + * @since 3.15.0 |
|
| 237 | + * |
|
| 238 | + * @param null|int|array $include An array of {@link WP_Post}s' ids. |
|
| 239 | + * |
|
| 240 | + * @return string An empty string if $include is null otherwise the include |
|
| 241 | + * clause. |
|
| 242 | + */ |
|
| 243 | + private static function and_article_in( $include = null ) { |
|
| 244 | + |
|
| 245 | + if ( null === $include ) { |
|
| 246 | + return ''; |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + return ' AND p.ID IN ( ' . implode( ',', wp_parse_id_list( (array) $include ) ) . ' )'; |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * Get the entities' {@link WP_Post}s' ids referencing the specified {@link WP_Post}. |
|
| 254 | + * |
|
| 255 | + * @since 3.15.0 |
|
| 256 | + * |
|
| 257 | + * @param int $object_id The object {@link WP_Post}'s id. |
|
| 258 | + * @param string $fields The fields to return, 'ids' to only return ids or |
|
| 259 | + * '*' to return all fields, by default '*'. |
|
| 260 | + * @param null|string $status The status, by default all. |
|
| 261 | + * |
|
| 262 | + * @return array|object|null Database query results |
|
| 263 | + */ |
|
| 264 | + public function get_non_article_subjects( $object_id, $fields = '*', $status = null ) { |
|
| 265 | + global $wpdb; |
|
| 266 | + |
|
| 267 | + // The output fields. |
|
| 268 | + $actual_fields = self::fields( $fields ); |
|
| 269 | + |
|
| 270 | + $sql = $wpdb->prepare( |
|
| 271 | + " |
|
| 272 | 272 | SELECT p.$actual_fields |
| 273 | 273 | FROM {$this->relation_table} r |
| 274 | 274 | INNER JOIN $wpdb->posts p |
| 275 | 275 | ON p.id = r.subject_id |
| 276 | 276 | " |
| 277 | - // Add the status clause. |
|
| 278 | - . self::and_status( $status ) |
|
| 279 | - . self::inner_join_is_not_article() |
|
| 280 | - . " WHERE r.object_id = %d " |
|
| 281 | - . self::and_post_type_in() |
|
| 282 | - , |
|
| 283 | - $object_id |
|
| 284 | - ); |
|
| 285 | - |
|
| 286 | - return '*' === $actual_fields ? $wpdb->get_results( $sql ) : $wpdb->get_col( $sql ); |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - /** |
|
| 290 | - * Get the entities referenced by the specified {@link WP_Post}. |
|
| 291 | - * |
|
| 292 | - * @since 3.15.0 |
|
| 293 | - * |
|
| 294 | - * @param int $subject_id The {@link WP_Post}'s id. |
|
| 295 | - * @param string $fields The fields to return, 'ids' to only return ids or |
|
| 296 | - * '*' to return all fields, by default '*'. |
|
| 297 | - * @param null|string $predicate The predicate (who|what|...), by default all. |
|
| 298 | - * @param null|string $status The status, by default all. |
|
| 299 | - * |
|
| 300 | - * @return array|object|null Database query results |
|
| 301 | - */ |
|
| 302 | - public function get_objects( $subject_id, $fields = '*', $predicate = null, $status = null ) { |
|
| 303 | - global $wpdb; |
|
| 304 | - |
|
| 305 | - // The output fields. |
|
| 306 | - $actual_fields = self::fields( $fields ); |
|
| 307 | - |
|
| 308 | - $sql = $wpdb->prepare( |
|
| 309 | - " |
|
| 277 | + // Add the status clause. |
|
| 278 | + . self::and_status( $status ) |
|
| 279 | + . self::inner_join_is_not_article() |
|
| 280 | + . " WHERE r.object_id = %d " |
|
| 281 | + . self::and_post_type_in() |
|
| 282 | + , |
|
| 283 | + $object_id |
|
| 284 | + ); |
|
| 285 | + |
|
| 286 | + return '*' === $actual_fields ? $wpdb->get_results( $sql ) : $wpdb->get_col( $sql ); |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + /** |
|
| 290 | + * Get the entities referenced by the specified {@link WP_Post}. |
|
| 291 | + * |
|
| 292 | + * @since 3.15.0 |
|
| 293 | + * |
|
| 294 | + * @param int $subject_id The {@link WP_Post}'s id. |
|
| 295 | + * @param string $fields The fields to return, 'ids' to only return ids or |
|
| 296 | + * '*' to return all fields, by default '*'. |
|
| 297 | + * @param null|string $predicate The predicate (who|what|...), by default all. |
|
| 298 | + * @param null|string $status The status, by default all. |
|
| 299 | + * |
|
| 300 | + * @return array|object|null Database query results |
|
| 301 | + */ |
|
| 302 | + public function get_objects( $subject_id, $fields = '*', $predicate = null, $status = null ) { |
|
| 303 | + global $wpdb; |
|
| 304 | + |
|
| 305 | + // The output fields. |
|
| 306 | + $actual_fields = self::fields( $fields ); |
|
| 307 | + |
|
| 308 | + $sql = $wpdb->prepare( |
|
| 309 | + " |
|
| 310 | 310 | SELECT p.$actual_fields |
| 311 | 311 | FROM {$this->relation_table} r |
| 312 | 312 | INNER JOIN $wpdb->posts p |
| 313 | 313 | ON p.id = r.object_id |
| 314 | 314 | " |
| 315 | - // Add the status clause. |
|
| 316 | - . self::and_status( $status ) |
|
| 317 | - . self::inner_join_is_not_article() |
|
| 318 | - . " WHERE r.subject_id = %d " |
|
| 319 | - . self::and_post_type_in() |
|
| 320 | - . self::and_predicate( $predicate ) |
|
| 321 | - , |
|
| 322 | - $subject_id |
|
| 323 | - ); |
|
| 324 | - |
|
| 325 | - return '*' === $actual_fields ? $wpdb->get_results( $sql ) : $wpdb->get_col( $sql ); |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - /** |
|
| 329 | - * Add the `post_status` clause. |
|
| 330 | - * |
|
| 331 | - * @since 3.15.0 |
|
| 332 | - * |
|
| 333 | - * @param null|string|array $status The status values. |
|
| 334 | - * |
|
| 335 | - * @return string An empty string if $status is null, otherwise the status clause. |
|
| 336 | - */ |
|
| 337 | - private static function and_status( $status = null ) { |
|
| 338 | - |
|
| 339 | - if ( null === $status ) { |
|
| 340 | - return ''; |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - return " AND p.post_status IN ('" . implode( "', '", array_map( 'esc_sql', (array) $status ) ) . "')"; |
|
| 344 | - } |
|
| 345 | - |
|
| 346 | - /** |
|
| 347 | - * Add the `predicate` clause. |
|
| 348 | - * |
|
| 349 | - * @since 3.15.0 |
|
| 350 | - * |
|
| 351 | - * @param null|string|array $predicate An array of predicates. |
|
| 352 | - * |
|
| 353 | - * @return string An empty string if $predicate is null otherwise the predicate |
|
| 354 | - * clause. |
|
| 355 | - */ |
|
| 356 | - private static function and_predicate( $predicate = null ) { |
|
| 357 | - |
|
| 358 | - if ( null === $predicate ) { |
|
| 359 | - return ''; |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - return " AND r.predicate IN ('" . implode( "', '", array_map( 'esc_sql', (array) $predicate ) ) . "')"; |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - /** |
|
| 366 | - * The select fields. |
|
| 367 | - * |
|
| 368 | - * @since 3.15.0 |
|
| 369 | - * |
|
| 370 | - * @param string $fields Either 'ids' or '*', by default '*'. |
|
| 371 | - * |
|
| 372 | - * @return string The `id` field if `ids` otherwise `*`. |
|
| 373 | - */ |
|
| 374 | - private static function fields( $fields = '*' ) { |
|
| 375 | - |
|
| 376 | - // The output fields. |
|
| 377 | - return 'ids' === $fields ? 'id' : '*'; |
|
| 378 | - } |
|
| 379 | - |
|
| 380 | - /** |
|
| 381 | - * The inner join clause for articles. |
|
| 382 | - * |
|
| 383 | - * @since 3.15.0 |
|
| 384 | - * |
|
| 385 | - * @return string The articles inner join clause. |
|
| 386 | - */ |
|
| 387 | - private static function inner_join_is_article() { |
|
| 388 | - global $wpdb; |
|
| 389 | - |
|
| 390 | - return $wpdb->prepare( |
|
| 391 | - " |
|
| 315 | + // Add the status clause. |
|
| 316 | + . self::and_status( $status ) |
|
| 317 | + . self::inner_join_is_not_article() |
|
| 318 | + . " WHERE r.subject_id = %d " |
|
| 319 | + . self::and_post_type_in() |
|
| 320 | + . self::and_predicate( $predicate ) |
|
| 321 | + , |
|
| 322 | + $subject_id |
|
| 323 | + ); |
|
| 324 | + |
|
| 325 | + return '*' === $actual_fields ? $wpdb->get_results( $sql ) : $wpdb->get_col( $sql ); |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + /** |
|
| 329 | + * Add the `post_status` clause. |
|
| 330 | + * |
|
| 331 | + * @since 3.15.0 |
|
| 332 | + * |
|
| 333 | + * @param null|string|array $status The status values. |
|
| 334 | + * |
|
| 335 | + * @return string An empty string if $status is null, otherwise the status clause. |
|
| 336 | + */ |
|
| 337 | + private static function and_status( $status = null ) { |
|
| 338 | + |
|
| 339 | + if ( null === $status ) { |
|
| 340 | + return ''; |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + return " AND p.post_status IN ('" . implode( "', '", array_map( 'esc_sql', (array) $status ) ) . "')"; |
|
| 344 | + } |
|
| 345 | + |
|
| 346 | + /** |
|
| 347 | + * Add the `predicate` clause. |
|
| 348 | + * |
|
| 349 | + * @since 3.15.0 |
|
| 350 | + * |
|
| 351 | + * @param null|string|array $predicate An array of predicates. |
|
| 352 | + * |
|
| 353 | + * @return string An empty string if $predicate is null otherwise the predicate |
|
| 354 | + * clause. |
|
| 355 | + */ |
|
| 356 | + private static function and_predicate( $predicate = null ) { |
|
| 357 | + |
|
| 358 | + if ( null === $predicate ) { |
|
| 359 | + return ''; |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + return " AND r.predicate IN ('" . implode( "', '", array_map( 'esc_sql', (array) $predicate ) ) . "')"; |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + /** |
|
| 366 | + * The select fields. |
|
| 367 | + * |
|
| 368 | + * @since 3.15.0 |
|
| 369 | + * |
|
| 370 | + * @param string $fields Either 'ids' or '*', by default '*'. |
|
| 371 | + * |
|
| 372 | + * @return string The `id` field if `ids` otherwise `*`. |
|
| 373 | + */ |
|
| 374 | + private static function fields( $fields = '*' ) { |
|
| 375 | + |
|
| 376 | + // The output fields. |
|
| 377 | + return 'ids' === $fields ? 'id' : '*'; |
|
| 378 | + } |
|
| 379 | + |
|
| 380 | + /** |
|
| 381 | + * The inner join clause for articles. |
|
| 382 | + * |
|
| 383 | + * @since 3.15.0 |
|
| 384 | + * |
|
| 385 | + * @return string The articles inner join clause. |
|
| 386 | + */ |
|
| 387 | + private static function inner_join_is_article() { |
|
| 388 | + global $wpdb; |
|
| 389 | + |
|
| 390 | + return $wpdb->prepare( |
|
| 391 | + " |
|
| 392 | 392 | INNER JOIN $wpdb->term_relationships tr |
| 393 | 393 | ON p.id = tr.object_id |
| 394 | 394 | INNER JOIN $wpdb->term_taxonomy tt |
@@ -398,23 +398,23 @@ discard block |
||
| 398 | 398 | ON t.term_id = tt.term_id |
| 399 | 399 | AND t.slug = %s |
| 400 | 400 | ", |
| 401 | - 'wl_entity_type', |
|
| 402 | - 'article' |
|
| 403 | - ); |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - /** |
|
| 407 | - * The inner join clause for non-articles. |
|
| 408 | - * |
|
| 409 | - * @since 3.15.0 |
|
| 410 | - * |
|
| 411 | - * @return string The non-articles inner join clause. |
|
| 412 | - */ |
|
| 413 | - private static function inner_join_is_not_article() { |
|
| 414 | - global $wpdb; |
|
| 415 | - |
|
| 416 | - return $wpdb->prepare( |
|
| 417 | - " |
|
| 401 | + 'wl_entity_type', |
|
| 402 | + 'article' |
|
| 403 | + ); |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + /** |
|
| 407 | + * The inner join clause for non-articles. |
|
| 408 | + * |
|
| 409 | + * @since 3.15.0 |
|
| 410 | + * |
|
| 411 | + * @return string The non-articles inner join clause. |
|
| 412 | + */ |
|
| 413 | + private static function inner_join_is_not_article() { |
|
| 414 | + global $wpdb; |
|
| 415 | + |
|
| 416 | + return $wpdb->prepare( |
|
| 417 | + " |
|
| 418 | 418 | INNER JOIN $wpdb->term_relationships tr |
| 419 | 419 | ON p.id = tr.object_id |
| 420 | 420 | INNER JOIN $wpdb->term_taxonomy tt |
@@ -424,9 +424,9 @@ discard block |
||
| 424 | 424 | ON t.term_id = tt.term_id |
| 425 | 425 | AND NOT t.slug = %s |
| 426 | 426 | ", |
| 427 | - 'wl_entity_type', |
|
| 428 | - 'article' |
|
| 429 | - ); |
|
| 430 | - } |
|
| 427 | + 'wl_entity_type', |
|
| 428 | + 'article' |
|
| 429 | + ); |
|
| 430 | + } |
|
| 431 | 431 | |
| 432 | 432 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public function __construct() { |
| 54 | 54 | |
| 55 | - self::$log = Wordlift_Log_Service::get_logger( get_class() ); |
|
| 55 | + self::$log = Wordlift_Log_Service::get_logger(get_class()); |
|
| 56 | 56 | |
| 57 | 57 | global $wpdb; |
| 58 | 58 | |
@@ -93,24 +93,24 @@ discard block |
||
| 93 | 93 | * |
| 94 | 94 | * @return array|object|null Database query results |
| 95 | 95 | */ |
| 96 | - public function get_article_subjects( $object_id, $fields = '*', $predicate = null, $status = null, $excludes = array(), $limit = null, $include = null ) { |
|
| 96 | + public function get_article_subjects($object_id, $fields = '*', $predicate = null, $status = null, $excludes = array(), $limit = null, $include = null) { |
|
| 97 | 97 | global $wpdb; |
| 98 | 98 | |
| 99 | 99 | // The output fields. |
| 100 | - $actual_fields = self::fields( $fields ); |
|
| 100 | + $actual_fields = self::fields($fields); |
|
| 101 | 101 | |
| 102 | - self::$log->trace( 'Getting article subjects for object ' . implode( ', ', (array) $object_id ) . '...' ); |
|
| 102 | + self::$log->trace('Getting article subjects for object '.implode(', ', (array) $object_id).'...'); |
|
| 103 | 103 | |
| 104 | - $objects = $this->article_id_to_entity_id( $object_id ); |
|
| 104 | + $objects = $this->article_id_to_entity_id($object_id); |
|
| 105 | 105 | |
| 106 | 106 | // If there are no related objects, return an empty array. |
| 107 | - if ( empty( $objects ) ) { |
|
| 108 | - self::$log->debug( 'No entities found for object ' . implode( ', ', (array) $object_id ) . '.' ); |
|
| 107 | + if (empty($objects)) { |
|
| 108 | + self::$log->debug('No entities found for object '.implode(', ', (array) $object_id).'.'); |
|
| 109 | 109 | |
| 110 | 110 | return array(); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - self::$log->debug( count( $objects ) . ' entity id(s) found for object ' . implode( ', ', (array) $object_id ) . '.' ); |
|
| 113 | + self::$log->debug(count($objects).' entity id(s) found for object '.implode(', ', (array) $object_id).'.'); |
|
| 114 | 114 | |
| 115 | 115 | $sql = |
| 116 | 116 | " |
@@ -120,19 +120,19 @@ discard block |
||
| 120 | 120 | ON p.id = r.subject_id |
| 121 | 121 | " |
| 122 | 122 | // Add the status clause. |
| 123 | - . self::and_status( $status ) |
|
| 123 | + . self::and_status($status) |
|
| 124 | 124 | . self::inner_join_is_article() |
| 125 | - . self::where_object_id( $objects ) |
|
| 125 | + . self::where_object_id($objects) |
|
| 126 | 126 | // Since `object_id` can be an article ID we need to exclude it from |
| 127 | 127 | // the results. |
| 128 | - . self::and_article_not_in( array_merge( $excludes, (array) $object_id ) ) |
|
| 129 | - . self::and_article_in( $include ) |
|
| 128 | + . self::and_article_not_in(array_merge($excludes, (array) $object_id)) |
|
| 129 | + . self::and_article_in($include) |
|
| 130 | 130 | . self::and_post_type_in() |
| 131 | - . self::and_predicate( $predicate ) |
|
| 132 | - . self::limit( $limit ); |
|
| 131 | + . self::and_predicate($predicate) |
|
| 132 | + . self::limit($limit); |
|
| 133 | 133 | |
| 134 | 134 | |
| 135 | - return '*' === $actual_fields ? $wpdb->get_results( $sql ) : $wpdb->get_col( $sql ); |
|
| 135 | + return '*' === $actual_fields ? $wpdb->get_results($sql) : $wpdb->get_col($sql); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | return " AND p.post_type IN ( '" |
| 148 | 148 | . implode( |
| 149 | 149 | "','", |
| 150 | - array_map( 'esc_sql', Wordlift_Entity_Service::valid_entity_post_types() ) |
|
| 150 | + array_map('esc_sql', Wordlift_Entity_Service::valid_entity_post_types()) |
|
| 151 | 151 | ) |
| 152 | 152 | . "' )"; |
| 153 | 153 | } |
@@ -161,9 +161,9 @@ discard block |
||
| 161 | 161 | * |
| 162 | 162 | * @return string The limit clause (empty if no limit has been specified). |
| 163 | 163 | */ |
| 164 | - private static function limit( $limit = null ) { |
|
| 164 | + private static function limit($limit = null) { |
|
| 165 | 165 | |
| 166 | - if ( null === $limit ) { |
|
| 166 | + if (null === $limit) { |
|
| 167 | 167 | return ''; |
| 168 | 168 | } |
| 169 | 169 | |
@@ -180,19 +180,19 @@ discard block |
||
| 180 | 180 | * |
| 181 | 181 | * @return array An array of entities' ids. |
| 182 | 182 | */ |
| 183 | - private function article_id_to_entity_id( $object_id ) { |
|
| 183 | + private function article_id_to_entity_id($object_id) { |
|
| 184 | 184 | |
| 185 | 185 | $entity_service = Wordlift_Entity_Service::get_instance(); |
| 186 | 186 | |
| 187 | 187 | $relation_service = $this; |
| 188 | 188 | |
| 189 | - return array_reduce( (array) $object_id, function ( $carry, $item ) use ( $entity_service, $relation_service ) { |
|
| 190 | - if ( $entity_service->is_entity( $item ) ) { |
|
| 191 | - return array_merge( $carry, (array) $item ); |
|
| 189 | + return array_reduce((array) $object_id, function($carry, $item) use ($entity_service, $relation_service) { |
|
| 190 | + if ($entity_service->is_entity($item)) { |
|
| 191 | + return array_merge($carry, (array) $item); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - return array_merge( $carry, $relation_service->get_objects( $item, 'ids' ) ); |
|
| 195 | - }, array() ); |
|
| 194 | + return array_merge($carry, $relation_service->get_objects($item, 'ids')); |
|
| 195 | + }, array()); |
|
| 196 | 196 | |
| 197 | 197 | } |
| 198 | 198 | |
@@ -205,15 +205,15 @@ discard block |
||
| 205 | 205 | * |
| 206 | 206 | * @return string The WHERE clause. |
| 207 | 207 | */ |
| 208 | - private static function where_object_id( $object_id ) { |
|
| 208 | + private static function where_object_id($object_id) { |
|
| 209 | 209 | |
| 210 | - if ( empty( $object_id ) ) { |
|
| 211 | - self::$log->warn( sprintf( "%s `where_object_id` called with empty `object_id`.", var_export( debug_backtrace( false, 3 ), true ) ) ); |
|
| 210 | + if (empty($object_id)) { |
|
| 211 | + self::$log->warn(sprintf("%s `where_object_id` called with empty `object_id`.", var_export(debug_backtrace(false, 3), true))); |
|
| 212 | 212 | |
| 213 | 213 | return ' WHERE 1 = 1'; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - return ' WHERE r.object_id IN ( ' . implode( ',', wp_parse_id_list( (array) $object_id ) ) . ' )'; |
|
| 216 | + return ' WHERE r.object_id IN ( '.implode(',', wp_parse_id_list((array) $object_id)).' )'; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /** |
@@ -225,9 +225,9 @@ discard block |
||
| 225 | 225 | * |
| 226 | 226 | * @return string The exclude clause. |
| 227 | 227 | */ |
| 228 | - private static function and_article_not_in( $exclude ) { |
|
| 228 | + private static function and_article_not_in($exclude) { |
|
| 229 | 229 | |
| 230 | - return ' AND NOT p.ID IN ( ' . implode( ',', wp_parse_id_list( (array) $exclude ) ) . ' )'; |
|
| 230 | + return ' AND NOT p.ID IN ( '.implode(',', wp_parse_id_list((array) $exclude)).' )'; |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | /** |
@@ -240,13 +240,13 @@ discard block |
||
| 240 | 240 | * @return string An empty string if $include is null otherwise the include |
| 241 | 241 | * clause. |
| 242 | 242 | */ |
| 243 | - private static function and_article_in( $include = null ) { |
|
| 243 | + private static function and_article_in($include = null) { |
|
| 244 | 244 | |
| 245 | - if ( null === $include ) { |
|
| 245 | + if (null === $include) { |
|
| 246 | 246 | return ''; |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - return ' AND p.ID IN ( ' . implode( ',', wp_parse_id_list( (array) $include ) ) . ' )'; |
|
| 249 | + return ' AND p.ID IN ( '.implode(',', wp_parse_id_list((array) $include)).' )'; |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
@@ -261,11 +261,11 @@ discard block |
||
| 261 | 261 | * |
| 262 | 262 | * @return array|object|null Database query results |
| 263 | 263 | */ |
| 264 | - public function get_non_article_subjects( $object_id, $fields = '*', $status = null ) { |
|
| 264 | + public function get_non_article_subjects($object_id, $fields = '*', $status = null) { |
|
| 265 | 265 | global $wpdb; |
| 266 | 266 | |
| 267 | 267 | // The output fields. |
| 268 | - $actual_fields = self::fields( $fields ); |
|
| 268 | + $actual_fields = self::fields($fields); |
|
| 269 | 269 | |
| 270 | 270 | $sql = $wpdb->prepare( |
| 271 | 271 | " |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | ON p.id = r.subject_id |
| 276 | 276 | " |
| 277 | 277 | // Add the status clause. |
| 278 | - . self::and_status( $status ) |
|
| 278 | + . self::and_status($status) |
|
| 279 | 279 | . self::inner_join_is_not_article() |
| 280 | 280 | . " WHERE r.object_id = %d " |
| 281 | 281 | . self::and_post_type_in() |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | $object_id |
| 284 | 284 | ); |
| 285 | 285 | |
| 286 | - return '*' === $actual_fields ? $wpdb->get_results( $sql ) : $wpdb->get_col( $sql ); |
|
| 286 | + return '*' === $actual_fields ? $wpdb->get_results($sql) : $wpdb->get_col($sql); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | /** |
@@ -299,11 +299,11 @@ discard block |
||
| 299 | 299 | * |
| 300 | 300 | * @return array|object|null Database query results |
| 301 | 301 | */ |
| 302 | - public function get_objects( $subject_id, $fields = '*', $predicate = null, $status = null ) { |
|
| 302 | + public function get_objects($subject_id, $fields = '*', $predicate = null, $status = null) { |
|
| 303 | 303 | global $wpdb; |
| 304 | 304 | |
| 305 | 305 | // The output fields. |
| 306 | - $actual_fields = self::fields( $fields ); |
|
| 306 | + $actual_fields = self::fields($fields); |
|
| 307 | 307 | |
| 308 | 308 | $sql = $wpdb->prepare( |
| 309 | 309 | " |
@@ -313,16 +313,16 @@ discard block |
||
| 313 | 313 | ON p.id = r.object_id |
| 314 | 314 | " |
| 315 | 315 | // Add the status clause. |
| 316 | - . self::and_status( $status ) |
|
| 316 | + . self::and_status($status) |
|
| 317 | 317 | . self::inner_join_is_not_article() |
| 318 | 318 | . " WHERE r.subject_id = %d " |
| 319 | 319 | . self::and_post_type_in() |
| 320 | - . self::and_predicate( $predicate ) |
|
| 320 | + . self::and_predicate($predicate) |
|
| 321 | 321 | , |
| 322 | 322 | $subject_id |
| 323 | 323 | ); |
| 324 | 324 | |
| 325 | - return '*' === $actual_fields ? $wpdb->get_results( $sql ) : $wpdb->get_col( $sql ); |
|
| 325 | + return '*' === $actual_fields ? $wpdb->get_results($sql) : $wpdb->get_col($sql); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | /** |
@@ -334,13 +334,13 @@ discard block |
||
| 334 | 334 | * |
| 335 | 335 | * @return string An empty string if $status is null, otherwise the status clause. |
| 336 | 336 | */ |
| 337 | - private static function and_status( $status = null ) { |
|
| 337 | + private static function and_status($status = null) { |
|
| 338 | 338 | |
| 339 | - if ( null === $status ) { |
|
| 339 | + if (null === $status) { |
|
| 340 | 340 | return ''; |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - return " AND p.post_status IN ('" . implode( "', '", array_map( 'esc_sql', (array) $status ) ) . "')"; |
|
| 343 | + return " AND p.post_status IN ('".implode("', '", array_map('esc_sql', (array) $status))."')"; |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | /** |
@@ -353,13 +353,13 @@ discard block |
||
| 353 | 353 | * @return string An empty string if $predicate is null otherwise the predicate |
| 354 | 354 | * clause. |
| 355 | 355 | */ |
| 356 | - private static function and_predicate( $predicate = null ) { |
|
| 356 | + private static function and_predicate($predicate = null) { |
|
| 357 | 357 | |
| 358 | - if ( null === $predicate ) { |
|
| 358 | + if (null === $predicate) { |
|
| 359 | 359 | return ''; |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - return " AND r.predicate IN ('" . implode( "', '", array_map( 'esc_sql', (array) $predicate ) ) . "')"; |
|
| 362 | + return " AND r.predicate IN ('".implode("', '", array_map('esc_sql', (array) $predicate))."')"; |
|
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | /** |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | * |
| 372 | 372 | * @return string The `id` field if `ids` otherwise `*`. |
| 373 | 373 | */ |
| 374 | - private static function fields( $fields = '*' ) { |
|
| 374 | + private static function fields($fields = '*') { |
|
| 375 | 375 | |
| 376 | 376 | // The output fields. |
| 377 | 377 | return 'ids' === $fields ? 'id' : '*'; |
@@ -15,250 +15,250 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class Wordlift_Post_To_Jsonld_Converter extends Wordlift_Abstract_Post_To_Jsonld_Converter { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * A {@link Wordlift_Configuration_Service} instance. |
|
| 20 | - * |
|
| 21 | - * @since 3.10.0 |
|
| 22 | - * @access private |
|
| 23 | - * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 24 | - */ |
|
| 25 | - private $configuration_service; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * @var Wordlift_Entity_Post_To_Jsonld_Converter |
|
| 29 | - */ |
|
| 30 | - private $entity_post_to_jsonld_converter; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * A {@link Wordlift_Log_Service} instance. |
|
| 34 | - * |
|
| 35 | - * @since 3.10.0 |
|
| 36 | - * @access private |
|
| 37 | - * @var Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 38 | - */ |
|
| 39 | - private $log; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * Wordlift_Post_To_Jsonld_Converter constructor. |
|
| 43 | - * |
|
| 44 | - * @since 3.10.0 |
|
| 45 | - * |
|
| 46 | - * @param \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 47 | - * @param \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 48 | - * @param \Wordlift_User_Service $user_service A {@link Wordlift_User_Service} instance. |
|
| 49 | - * @param \Wordlift_Attachment_Service $attachment_service A {@link Wordlift_Attachment_Service} instance. |
|
| 50 | - * @param \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 51 | - * @param \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter |
|
| 52 | - */ |
|
| 53 | - public function __construct( $entity_type_service, $entity_service, $user_service, $attachment_service, $configuration_service, $entity_post_to_jsonld_converter ) { |
|
| 54 | - parent::__construct( $entity_type_service, $entity_service, $user_service, $attachment_service ); |
|
| 55 | - |
|
| 56 | - $this->configuration_service = $configuration_service; |
|
| 57 | - $this->entity_post_to_jsonld_converter = $entity_post_to_jsonld_converter; |
|
| 58 | - |
|
| 59 | - // Set a reference to the logger. |
|
| 60 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Post_To_Jsonld_Converter' ); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Convert the provided {@link WP_Post} to a JSON-LD array. Any entity reference |
|
| 65 | - * found while processing the post is set in the $references array. |
|
| 66 | - * |
|
| 67 | - * @since 3.10.0 |
|
| 68 | - * |
|
| 69 | - * @param int $post_id The post id. |
|
| 70 | - * @param array $references An array of entity references. |
|
| 71 | - * |
|
| 72 | - * @return array A JSON-LD array. |
|
| 73 | - */ |
|
| 74 | - public function convert( $post_id, &$references = array() ) { |
|
| 75 | - |
|
| 76 | - // Get the post instance. |
|
| 77 | - if ( null === $post = get_post( $post_id ) ) { |
|
| 78 | - // Post not found. |
|
| 79 | - return null; |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - // Get the base JSON-LD and the list of entities referenced by this entity. |
|
| 83 | - $jsonld = parent::convert( $post_id, $references ); |
|
| 84 | - |
|
| 85 | - // Get the entity name. |
|
| 86 | - $jsonld['headline'] = $post->post_title; |
|
| 87 | - |
|
| 88 | - // Get the author. |
|
| 89 | - $jsonld['author'] = $this->get_author( $post->post_author ); |
|
| 90 | - |
|
| 91 | - // Set the published and modified dates. |
|
| 92 | - $jsonld['datePublished'] = get_post_time( 'Y-m-d\TH:i', true, $post, false ); |
|
| 93 | - $jsonld['dateModified'] = get_post_modified_time( 'Y-m-d\TH:i', true, $post, false ); |
|
| 94 | - |
|
| 95 | - // Get the word count for the post. |
|
| 96 | - $post_adapter = new Wordlift_Post_Adapter( $post_id ); |
|
| 97 | - $jsonld['wordCount'] = $post_adapter->word_count(); |
|
| 98 | - |
|
| 99 | - // Set the publisher. |
|
| 100 | - $this->set_publisher( $jsonld ); |
|
| 101 | - |
|
| 102 | - // Process the references if any. |
|
| 103 | - if ( 0 < count( $references ) ) { |
|
| 104 | - |
|
| 105 | - // Prepare the `about` and `mentions` array. |
|
| 106 | - $about = $mentions = array(); |
|
| 107 | - |
|
| 108 | - // If the entity is in the title, then it should be an `about`. |
|
| 109 | - foreach ( $references as $reference ) { |
|
| 110 | - |
|
| 111 | - // Get the entity labels. |
|
| 112 | - $labels = $this->entity_service->get_labels( $reference ); |
|
| 113 | - |
|
| 114 | - // Get the entity URI. |
|
| 115 | - $item = array( |
|
| 116 | - '@id' => $this->entity_service->get_uri( $reference ), |
|
| 117 | - ); |
|
| 118 | - |
|
| 119 | - // Check if the labels match any part of the title. |
|
| 120 | - $matches = 1 === preg_match( '/' . implode( '|', $labels ) . '/', $post->post_title ); |
|
| 121 | - |
|
| 122 | - // If the title matches, assign the entity to the about, otherwise to the mentions. |
|
| 123 | - if ( $matches ) { |
|
| 124 | - $about[] = $item; |
|
| 125 | - } else { |
|
| 126 | - $mentions[] = $item; |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - // If we have abouts, assign them to the JSON-LD. |
|
| 131 | - if ( 0 < count( $about ) ) { |
|
| 132 | - $jsonld['about'] = $about; |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - // If we have mentions, assign them to the JSON-LD. |
|
| 136 | - if ( 0 < count( $mentions ) ) { |
|
| 137 | - $jsonld['mentions'] = $mentions; |
|
| 138 | - } |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * Call the `wl_post_jsonld` filter. |
|
| 143 | - * |
|
| 144 | - * @api |
|
| 145 | - * |
|
| 146 | - * @since 3.14.0 |
|
| 147 | - * |
|
| 148 | - * @param array $jsonld The JSON-LD structure. |
|
| 149 | - * @param int $post_id The {@link WP_Post} `id`. |
|
| 150 | - * @param array $references The array of referenced entities. |
|
| 151 | - */ |
|
| 152 | - return apply_filters( 'wl_post_jsonld', $jsonld, $post_id, $references ); |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * Get the author's JSON-LD fragment. |
|
| 157 | - * |
|
| 158 | - * The JSON-LD fragment is generated using the {@link WP_User}'s data or |
|
| 159 | - * the referenced entity if configured for the {@link WP_User}. |
|
| 160 | - * |
|
| 161 | - * @since 3.14.0 |
|
| 162 | - * |
|
| 163 | - * @param int $author_id The author {@link WP_User}'s `id`. |
|
| 164 | - * |
|
| 165 | - * @return array A JSON-LD structure. |
|
| 166 | - */ |
|
| 167 | - private function get_author( $author_id ) { |
|
| 168 | - |
|
| 169 | - // Get the entity bound to this user. |
|
| 170 | - $entity_id = $this->user_service->get_entity( $author_id ); |
|
| 171 | - |
|
| 172 | - // If there's no entity bound return a simple author structure. |
|
| 173 | - if ( empty( $entity_id ) ) { |
|
| 174 | - |
|
| 175 | - $author = get_the_author_meta( 'display_name', $author_id ); |
|
| 176 | - $author_uri = $this->user_service->get_uri( $author_id ); |
|
| 177 | - |
|
| 178 | - return array( |
|
| 179 | - '@type' => 'Person', |
|
| 180 | - '@id' => $author_uri, |
|
| 181 | - 'name' => $author, |
|
| 182 | - ); |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - // Return the JSON-LD for the referenced entity. |
|
| 186 | - return $this->entity_post_to_jsonld_converter->convert( $entity_id ); |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - /** |
|
| 190 | - * Enrich the provided params array with publisher data, if available. |
|
| 191 | - * |
|
| 192 | - * @since 3.10.0 |
|
| 193 | - * |
|
| 194 | - * @param array $params The parameters array. |
|
| 195 | - */ |
|
| 196 | - protected function set_publisher( &$params ) { |
|
| 197 | - |
|
| 198 | - // If the publisher id isn't set don't do anything. |
|
| 199 | - if ( null === $publisher_id = $this->configuration_service->get_publisher_id() ) { |
|
| 200 | - return; |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - // Get the post instance. |
|
| 204 | - if ( null === $post = get_post( $publisher_id ) ) { |
|
| 205 | - // Publisher not found. |
|
| 206 | - return; |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - // Get the item id. |
|
| 210 | - $id = $this->entity_service->get_uri( $publisher_id ); |
|
| 211 | - |
|
| 212 | - // Get the type. |
|
| 213 | - $type = $this->entity_type_service->get( $publisher_id ); |
|
| 214 | - |
|
| 215 | - // Get the name. |
|
| 216 | - $name = $post->post_title; |
|
| 217 | - |
|
| 218 | - // Set the publisher data. |
|
| 219 | - $params['publisher'] = array( |
|
| 220 | - '@type' => $this->relative_to_context( $type['uri'] ), |
|
| 221 | - '@id' => $id, |
|
| 222 | - 'name' => $name, |
|
| 223 | - ); |
|
| 224 | - |
|
| 225 | - // Add the sameAs values associated with the publisher. |
|
| 226 | - $storage_factory = Wordlift_Storage_Factory::get_instance(); |
|
| 227 | - $sameas = $storage_factory->post_meta( Wordlift_Schema_Service::FIELD_SAME_AS )->get( $publisher_id ); |
|
| 228 | - if ( ! empty( $sameas ) ) { |
|
| 229 | - $params['publisher']['sameAs'] = $sameas; |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - // Set the logo, only for http://schema.org/Organization as Person doesn't |
|
| 233 | - // support the logo property. |
|
| 234 | - // |
|
| 235 | - // See http://schema.org/logo. |
|
| 236 | - if ( 'http://schema.org/Organization' !== $type['uri'] ) { |
|
| 237 | - return; |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - // Get the logo, WP < 4.4 way: only post ID accepted here. |
|
| 241 | - if ( '' === $thumbnail_id = get_post_thumbnail_id( $post->ID ) ) { |
|
| 242 | - return; |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - // Get the image URL. |
|
| 246 | - if ( false === $attachment = wp_get_attachment_image_src( $thumbnail_id, 'full' ) ) { |
|
| 247 | - return; |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - // Copy over some useful properties. |
|
| 251 | - // |
|
| 252 | - // See https://developers.google.com/search/docs/data-types/articles. |
|
| 253 | - $params['publisher']['logo']['@type'] = 'ImageObject'; |
|
| 254 | - $params['publisher']['logo']['url'] = $attachment[0]; |
|
| 255 | - // If you specify a "width" or "height" value you should leave out |
|
| 256 | - // 'px'. For example: "width":"4608px" should be "width":"4608". |
|
| 257 | - // |
|
| 258 | - // See https://github.com/insideout10/wordlift-plugin/issues/451. |
|
| 259 | - $params['publisher']['logo']['width'] = $attachment[1]; |
|
| 260 | - $params['publisher']['logo']['height'] = $attachment[2]; |
|
| 261 | - |
|
| 262 | - } |
|
| 18 | + /** |
|
| 19 | + * A {@link Wordlift_Configuration_Service} instance. |
|
| 20 | + * |
|
| 21 | + * @since 3.10.0 |
|
| 22 | + * @access private |
|
| 23 | + * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 24 | + */ |
|
| 25 | + private $configuration_service; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * @var Wordlift_Entity_Post_To_Jsonld_Converter |
|
| 29 | + */ |
|
| 30 | + private $entity_post_to_jsonld_converter; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * A {@link Wordlift_Log_Service} instance. |
|
| 34 | + * |
|
| 35 | + * @since 3.10.0 |
|
| 36 | + * @access private |
|
| 37 | + * @var Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 38 | + */ |
|
| 39 | + private $log; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * Wordlift_Post_To_Jsonld_Converter constructor. |
|
| 43 | + * |
|
| 44 | + * @since 3.10.0 |
|
| 45 | + * |
|
| 46 | + * @param \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 47 | + * @param \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 48 | + * @param \Wordlift_User_Service $user_service A {@link Wordlift_User_Service} instance. |
|
| 49 | + * @param \Wordlift_Attachment_Service $attachment_service A {@link Wordlift_Attachment_Service} instance. |
|
| 50 | + * @param \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 51 | + * @param \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter |
|
| 52 | + */ |
|
| 53 | + public function __construct( $entity_type_service, $entity_service, $user_service, $attachment_service, $configuration_service, $entity_post_to_jsonld_converter ) { |
|
| 54 | + parent::__construct( $entity_type_service, $entity_service, $user_service, $attachment_service ); |
|
| 55 | + |
|
| 56 | + $this->configuration_service = $configuration_service; |
|
| 57 | + $this->entity_post_to_jsonld_converter = $entity_post_to_jsonld_converter; |
|
| 58 | + |
|
| 59 | + // Set a reference to the logger. |
|
| 60 | + $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Post_To_Jsonld_Converter' ); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Convert the provided {@link WP_Post} to a JSON-LD array. Any entity reference |
|
| 65 | + * found while processing the post is set in the $references array. |
|
| 66 | + * |
|
| 67 | + * @since 3.10.0 |
|
| 68 | + * |
|
| 69 | + * @param int $post_id The post id. |
|
| 70 | + * @param array $references An array of entity references. |
|
| 71 | + * |
|
| 72 | + * @return array A JSON-LD array. |
|
| 73 | + */ |
|
| 74 | + public function convert( $post_id, &$references = array() ) { |
|
| 75 | + |
|
| 76 | + // Get the post instance. |
|
| 77 | + if ( null === $post = get_post( $post_id ) ) { |
|
| 78 | + // Post not found. |
|
| 79 | + return null; |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + // Get the base JSON-LD and the list of entities referenced by this entity. |
|
| 83 | + $jsonld = parent::convert( $post_id, $references ); |
|
| 84 | + |
|
| 85 | + // Get the entity name. |
|
| 86 | + $jsonld['headline'] = $post->post_title; |
|
| 87 | + |
|
| 88 | + // Get the author. |
|
| 89 | + $jsonld['author'] = $this->get_author( $post->post_author ); |
|
| 90 | + |
|
| 91 | + // Set the published and modified dates. |
|
| 92 | + $jsonld['datePublished'] = get_post_time( 'Y-m-d\TH:i', true, $post, false ); |
|
| 93 | + $jsonld['dateModified'] = get_post_modified_time( 'Y-m-d\TH:i', true, $post, false ); |
|
| 94 | + |
|
| 95 | + // Get the word count for the post. |
|
| 96 | + $post_adapter = new Wordlift_Post_Adapter( $post_id ); |
|
| 97 | + $jsonld['wordCount'] = $post_adapter->word_count(); |
|
| 98 | + |
|
| 99 | + // Set the publisher. |
|
| 100 | + $this->set_publisher( $jsonld ); |
|
| 101 | + |
|
| 102 | + // Process the references if any. |
|
| 103 | + if ( 0 < count( $references ) ) { |
|
| 104 | + |
|
| 105 | + // Prepare the `about` and `mentions` array. |
|
| 106 | + $about = $mentions = array(); |
|
| 107 | + |
|
| 108 | + // If the entity is in the title, then it should be an `about`. |
|
| 109 | + foreach ( $references as $reference ) { |
|
| 110 | + |
|
| 111 | + // Get the entity labels. |
|
| 112 | + $labels = $this->entity_service->get_labels( $reference ); |
|
| 113 | + |
|
| 114 | + // Get the entity URI. |
|
| 115 | + $item = array( |
|
| 116 | + '@id' => $this->entity_service->get_uri( $reference ), |
|
| 117 | + ); |
|
| 118 | + |
|
| 119 | + // Check if the labels match any part of the title. |
|
| 120 | + $matches = 1 === preg_match( '/' . implode( '|', $labels ) . '/', $post->post_title ); |
|
| 121 | + |
|
| 122 | + // If the title matches, assign the entity to the about, otherwise to the mentions. |
|
| 123 | + if ( $matches ) { |
|
| 124 | + $about[] = $item; |
|
| 125 | + } else { |
|
| 126 | + $mentions[] = $item; |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + // If we have abouts, assign them to the JSON-LD. |
|
| 131 | + if ( 0 < count( $about ) ) { |
|
| 132 | + $jsonld['about'] = $about; |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + // If we have mentions, assign them to the JSON-LD. |
|
| 136 | + if ( 0 < count( $mentions ) ) { |
|
| 137 | + $jsonld['mentions'] = $mentions; |
|
| 138 | + } |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * Call the `wl_post_jsonld` filter. |
|
| 143 | + * |
|
| 144 | + * @api |
|
| 145 | + * |
|
| 146 | + * @since 3.14.0 |
|
| 147 | + * |
|
| 148 | + * @param array $jsonld The JSON-LD structure. |
|
| 149 | + * @param int $post_id The {@link WP_Post} `id`. |
|
| 150 | + * @param array $references The array of referenced entities. |
|
| 151 | + */ |
|
| 152 | + return apply_filters( 'wl_post_jsonld', $jsonld, $post_id, $references ); |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * Get the author's JSON-LD fragment. |
|
| 157 | + * |
|
| 158 | + * The JSON-LD fragment is generated using the {@link WP_User}'s data or |
|
| 159 | + * the referenced entity if configured for the {@link WP_User}. |
|
| 160 | + * |
|
| 161 | + * @since 3.14.0 |
|
| 162 | + * |
|
| 163 | + * @param int $author_id The author {@link WP_User}'s `id`. |
|
| 164 | + * |
|
| 165 | + * @return array A JSON-LD structure. |
|
| 166 | + */ |
|
| 167 | + private function get_author( $author_id ) { |
|
| 168 | + |
|
| 169 | + // Get the entity bound to this user. |
|
| 170 | + $entity_id = $this->user_service->get_entity( $author_id ); |
|
| 171 | + |
|
| 172 | + // If there's no entity bound return a simple author structure. |
|
| 173 | + if ( empty( $entity_id ) ) { |
|
| 174 | + |
|
| 175 | + $author = get_the_author_meta( 'display_name', $author_id ); |
|
| 176 | + $author_uri = $this->user_service->get_uri( $author_id ); |
|
| 177 | + |
|
| 178 | + return array( |
|
| 179 | + '@type' => 'Person', |
|
| 180 | + '@id' => $author_uri, |
|
| 181 | + 'name' => $author, |
|
| 182 | + ); |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + // Return the JSON-LD for the referenced entity. |
|
| 186 | + return $this->entity_post_to_jsonld_converter->convert( $entity_id ); |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + /** |
|
| 190 | + * Enrich the provided params array with publisher data, if available. |
|
| 191 | + * |
|
| 192 | + * @since 3.10.0 |
|
| 193 | + * |
|
| 194 | + * @param array $params The parameters array. |
|
| 195 | + */ |
|
| 196 | + protected function set_publisher( &$params ) { |
|
| 197 | + |
|
| 198 | + // If the publisher id isn't set don't do anything. |
|
| 199 | + if ( null === $publisher_id = $this->configuration_service->get_publisher_id() ) { |
|
| 200 | + return; |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + // Get the post instance. |
|
| 204 | + if ( null === $post = get_post( $publisher_id ) ) { |
|
| 205 | + // Publisher not found. |
|
| 206 | + return; |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + // Get the item id. |
|
| 210 | + $id = $this->entity_service->get_uri( $publisher_id ); |
|
| 211 | + |
|
| 212 | + // Get the type. |
|
| 213 | + $type = $this->entity_type_service->get( $publisher_id ); |
|
| 214 | + |
|
| 215 | + // Get the name. |
|
| 216 | + $name = $post->post_title; |
|
| 217 | + |
|
| 218 | + // Set the publisher data. |
|
| 219 | + $params['publisher'] = array( |
|
| 220 | + '@type' => $this->relative_to_context( $type['uri'] ), |
|
| 221 | + '@id' => $id, |
|
| 222 | + 'name' => $name, |
|
| 223 | + ); |
|
| 224 | + |
|
| 225 | + // Add the sameAs values associated with the publisher. |
|
| 226 | + $storage_factory = Wordlift_Storage_Factory::get_instance(); |
|
| 227 | + $sameas = $storage_factory->post_meta( Wordlift_Schema_Service::FIELD_SAME_AS )->get( $publisher_id ); |
|
| 228 | + if ( ! empty( $sameas ) ) { |
|
| 229 | + $params['publisher']['sameAs'] = $sameas; |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + // Set the logo, only for http://schema.org/Organization as Person doesn't |
|
| 233 | + // support the logo property. |
|
| 234 | + // |
|
| 235 | + // See http://schema.org/logo. |
|
| 236 | + if ( 'http://schema.org/Organization' !== $type['uri'] ) { |
|
| 237 | + return; |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + // Get the logo, WP < 4.4 way: only post ID accepted here. |
|
| 241 | + if ( '' === $thumbnail_id = get_post_thumbnail_id( $post->ID ) ) { |
|
| 242 | + return; |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + // Get the image URL. |
|
| 246 | + if ( false === $attachment = wp_get_attachment_image_src( $thumbnail_id, 'full' ) ) { |
|
| 247 | + return; |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + // Copy over some useful properties. |
|
| 251 | + // |
|
| 252 | + // See https://developers.google.com/search/docs/data-types/articles. |
|
| 253 | + $params['publisher']['logo']['@type'] = 'ImageObject'; |
|
| 254 | + $params['publisher']['logo']['url'] = $attachment[0]; |
|
| 255 | + // If you specify a "width" or "height" value you should leave out |
|
| 256 | + // 'px'. For example: "width":"4608px" should be "width":"4608". |
|
| 257 | + // |
|
| 258 | + // See https://github.com/insideout10/wordlift-plugin/issues/451. |
|
| 259 | + $params['publisher']['logo']['width'] = $attachment[1]; |
|
| 260 | + $params['publisher']['logo']['height'] = $attachment[2]; |
|
| 261 | + |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | 264 | } |
@@ -50,14 +50,14 @@ discard block |
||
| 50 | 50 | * @param \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
| 51 | 51 | * @param \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter |
| 52 | 52 | */ |
| 53 | - public function __construct( $entity_type_service, $entity_service, $user_service, $attachment_service, $configuration_service, $entity_post_to_jsonld_converter ) { |
|
| 54 | - parent::__construct( $entity_type_service, $entity_service, $user_service, $attachment_service ); |
|
| 53 | + public function __construct($entity_type_service, $entity_service, $user_service, $attachment_service, $configuration_service, $entity_post_to_jsonld_converter) { |
|
| 54 | + parent::__construct($entity_type_service, $entity_service, $user_service, $attachment_service); |
|
| 55 | 55 | |
| 56 | 56 | $this->configuration_service = $configuration_service; |
| 57 | 57 | $this->entity_post_to_jsonld_converter = $entity_post_to_jsonld_converter; |
| 58 | 58 | |
| 59 | 59 | // Set a reference to the logger. |
| 60 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Post_To_Jsonld_Converter' ); |
|
| 60 | + $this->log = Wordlift_Log_Service::get_logger('Wordlift_Post_To_Jsonld_Converter'); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -71,56 +71,56 @@ discard block |
||
| 71 | 71 | * |
| 72 | 72 | * @return array A JSON-LD array. |
| 73 | 73 | */ |
| 74 | - public function convert( $post_id, &$references = array() ) { |
|
| 74 | + public function convert($post_id, &$references = array()) { |
|
| 75 | 75 | |
| 76 | 76 | // Get the post instance. |
| 77 | - if ( null === $post = get_post( $post_id ) ) { |
|
| 77 | + if (null === $post = get_post($post_id)) { |
|
| 78 | 78 | // Post not found. |
| 79 | 79 | return null; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | // Get the base JSON-LD and the list of entities referenced by this entity. |
| 83 | - $jsonld = parent::convert( $post_id, $references ); |
|
| 83 | + $jsonld = parent::convert($post_id, $references); |
|
| 84 | 84 | |
| 85 | 85 | // Get the entity name. |
| 86 | 86 | $jsonld['headline'] = $post->post_title; |
| 87 | 87 | |
| 88 | 88 | // Get the author. |
| 89 | - $jsonld['author'] = $this->get_author( $post->post_author ); |
|
| 89 | + $jsonld['author'] = $this->get_author($post->post_author); |
|
| 90 | 90 | |
| 91 | 91 | // Set the published and modified dates. |
| 92 | - $jsonld['datePublished'] = get_post_time( 'Y-m-d\TH:i', true, $post, false ); |
|
| 93 | - $jsonld['dateModified'] = get_post_modified_time( 'Y-m-d\TH:i', true, $post, false ); |
|
| 92 | + $jsonld['datePublished'] = get_post_time('Y-m-d\TH:i', true, $post, false); |
|
| 93 | + $jsonld['dateModified'] = get_post_modified_time('Y-m-d\TH:i', true, $post, false); |
|
| 94 | 94 | |
| 95 | 95 | // Get the word count for the post. |
| 96 | - $post_adapter = new Wordlift_Post_Adapter( $post_id ); |
|
| 96 | + $post_adapter = new Wordlift_Post_Adapter($post_id); |
|
| 97 | 97 | $jsonld['wordCount'] = $post_adapter->word_count(); |
| 98 | 98 | |
| 99 | 99 | // Set the publisher. |
| 100 | - $this->set_publisher( $jsonld ); |
|
| 100 | + $this->set_publisher($jsonld); |
|
| 101 | 101 | |
| 102 | 102 | // Process the references if any. |
| 103 | - if ( 0 < count( $references ) ) { |
|
| 103 | + if (0 < count($references)) { |
|
| 104 | 104 | |
| 105 | 105 | // Prepare the `about` and `mentions` array. |
| 106 | 106 | $about = $mentions = array(); |
| 107 | 107 | |
| 108 | 108 | // If the entity is in the title, then it should be an `about`. |
| 109 | - foreach ( $references as $reference ) { |
|
| 109 | + foreach ($references as $reference) { |
|
| 110 | 110 | |
| 111 | 111 | // Get the entity labels. |
| 112 | - $labels = $this->entity_service->get_labels( $reference ); |
|
| 112 | + $labels = $this->entity_service->get_labels($reference); |
|
| 113 | 113 | |
| 114 | 114 | // Get the entity URI. |
| 115 | 115 | $item = array( |
| 116 | - '@id' => $this->entity_service->get_uri( $reference ), |
|
| 116 | + '@id' => $this->entity_service->get_uri($reference), |
|
| 117 | 117 | ); |
| 118 | 118 | |
| 119 | 119 | // Check if the labels match any part of the title. |
| 120 | - $matches = 1 === preg_match( '/' . implode( '|', $labels ) . '/', $post->post_title ); |
|
| 120 | + $matches = 1 === preg_match('/'.implode('|', $labels).'/', $post->post_title); |
|
| 121 | 121 | |
| 122 | 122 | // If the title matches, assign the entity to the about, otherwise to the mentions. |
| 123 | - if ( $matches ) { |
|
| 123 | + if ($matches) { |
|
| 124 | 124 | $about[] = $item; |
| 125 | 125 | } else { |
| 126 | 126 | $mentions[] = $item; |
@@ -128,12 +128,12 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | // If we have abouts, assign them to the JSON-LD. |
| 131 | - if ( 0 < count( $about ) ) { |
|
| 131 | + if (0 < count($about)) { |
|
| 132 | 132 | $jsonld['about'] = $about; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | // If we have mentions, assign them to the JSON-LD. |
| 136 | - if ( 0 < count( $mentions ) ) { |
|
| 136 | + if (0 < count($mentions)) { |
|
| 137 | 137 | $jsonld['mentions'] = $mentions; |
| 138 | 138 | } |
| 139 | 139 | } |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * @param int $post_id The {@link WP_Post} `id`. |
| 150 | 150 | * @param array $references The array of referenced entities. |
| 151 | 151 | */ |
| 152 | - return apply_filters( 'wl_post_jsonld', $jsonld, $post_id, $references ); |
|
| 152 | + return apply_filters('wl_post_jsonld', $jsonld, $post_id, $references); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -164,16 +164,16 @@ discard block |
||
| 164 | 164 | * |
| 165 | 165 | * @return array A JSON-LD structure. |
| 166 | 166 | */ |
| 167 | - private function get_author( $author_id ) { |
|
| 167 | + private function get_author($author_id) { |
|
| 168 | 168 | |
| 169 | 169 | // Get the entity bound to this user. |
| 170 | - $entity_id = $this->user_service->get_entity( $author_id ); |
|
| 170 | + $entity_id = $this->user_service->get_entity($author_id); |
|
| 171 | 171 | |
| 172 | 172 | // If there's no entity bound return a simple author structure. |
| 173 | - if ( empty( $entity_id ) ) { |
|
| 173 | + if (empty($entity_id)) { |
|
| 174 | 174 | |
| 175 | - $author = get_the_author_meta( 'display_name', $author_id ); |
|
| 176 | - $author_uri = $this->user_service->get_uri( $author_id ); |
|
| 175 | + $author = get_the_author_meta('display_name', $author_id); |
|
| 176 | + $author_uri = $this->user_service->get_uri($author_id); |
|
| 177 | 177 | |
| 178 | 178 | return array( |
| 179 | 179 | '@type' => 'Person', |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | // Return the JSON-LD for the referenced entity. |
| 186 | - return $this->entity_post_to_jsonld_converter->convert( $entity_id ); |
|
| 186 | + return $this->entity_post_to_jsonld_converter->convert($entity_id); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | /** |
@@ -193,39 +193,39 @@ discard block |
||
| 193 | 193 | * |
| 194 | 194 | * @param array $params The parameters array. |
| 195 | 195 | */ |
| 196 | - protected function set_publisher( &$params ) { |
|
| 196 | + protected function set_publisher(&$params) { |
|
| 197 | 197 | |
| 198 | 198 | // If the publisher id isn't set don't do anything. |
| 199 | - if ( null === $publisher_id = $this->configuration_service->get_publisher_id() ) { |
|
| 199 | + if (null === $publisher_id = $this->configuration_service->get_publisher_id()) { |
|
| 200 | 200 | return; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | // Get the post instance. |
| 204 | - if ( null === $post = get_post( $publisher_id ) ) { |
|
| 204 | + if (null === $post = get_post($publisher_id)) { |
|
| 205 | 205 | // Publisher not found. |
| 206 | 206 | return; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | // Get the item id. |
| 210 | - $id = $this->entity_service->get_uri( $publisher_id ); |
|
| 210 | + $id = $this->entity_service->get_uri($publisher_id); |
|
| 211 | 211 | |
| 212 | 212 | // Get the type. |
| 213 | - $type = $this->entity_type_service->get( $publisher_id ); |
|
| 213 | + $type = $this->entity_type_service->get($publisher_id); |
|
| 214 | 214 | |
| 215 | 215 | // Get the name. |
| 216 | 216 | $name = $post->post_title; |
| 217 | 217 | |
| 218 | 218 | // Set the publisher data. |
| 219 | 219 | $params['publisher'] = array( |
| 220 | - '@type' => $this->relative_to_context( $type['uri'] ), |
|
| 220 | + '@type' => $this->relative_to_context($type['uri']), |
|
| 221 | 221 | '@id' => $id, |
| 222 | 222 | 'name' => $name, |
| 223 | 223 | ); |
| 224 | 224 | |
| 225 | 225 | // Add the sameAs values associated with the publisher. |
| 226 | 226 | $storage_factory = Wordlift_Storage_Factory::get_instance(); |
| 227 | - $sameas = $storage_factory->post_meta( Wordlift_Schema_Service::FIELD_SAME_AS )->get( $publisher_id ); |
|
| 228 | - if ( ! empty( $sameas ) ) { |
|
| 227 | + $sameas = $storage_factory->post_meta(Wordlift_Schema_Service::FIELD_SAME_AS)->get($publisher_id); |
|
| 228 | + if ( ! empty($sameas)) { |
|
| 229 | 229 | $params['publisher']['sameAs'] = $sameas; |
| 230 | 230 | } |
| 231 | 231 | |
@@ -233,17 +233,17 @@ discard block |
||
| 233 | 233 | // support the logo property. |
| 234 | 234 | // |
| 235 | 235 | // See http://schema.org/logo. |
| 236 | - if ( 'http://schema.org/Organization' !== $type['uri'] ) { |
|
| 236 | + if ('http://schema.org/Organization' !== $type['uri']) { |
|
| 237 | 237 | return; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | // Get the logo, WP < 4.4 way: only post ID accepted here. |
| 241 | - if ( '' === $thumbnail_id = get_post_thumbnail_id( $post->ID ) ) { |
|
| 241 | + if ('' === $thumbnail_id = get_post_thumbnail_id($post->ID)) { |
|
| 242 | 242 | return; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | // Get the image URL. |
| 246 | - if ( false === $attachment = wp_get_attachment_image_src( $thumbnail_id, 'full' ) ) { |
|
| 246 | + if (false === $attachment = wp_get_attachment_image_src($thumbnail_id, 'full')) { |
|
| 247 | 247 | return; |
| 248 | 248 | } |
| 249 | 249 | |
@@ -28,1468 +28,1468 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | class Wordlift { |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * The loader that's responsible for maintaining and registering all hooks that power |
|
| 33 | - * the plugin. |
|
| 34 | - * |
|
| 35 | - * @since 1.0.0 |
|
| 36 | - * @access protected |
|
| 37 | - * @var Wordlift_Loader $loader Maintains and registers all hooks for the plugin. |
|
| 38 | - */ |
|
| 39 | - protected $loader; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * The unique identifier of this plugin. |
|
| 43 | - * |
|
| 44 | - * @since 1.0.0 |
|
| 45 | - * @access protected |
|
| 46 | - * @var string $plugin_name The string used to uniquely identify this plugin. |
|
| 47 | - */ |
|
| 48 | - protected $plugin_name; |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * The current version of the plugin. |
|
| 52 | - * |
|
| 53 | - * @since 1.0.0 |
|
| 54 | - * @access protected |
|
| 55 | - * @var string $version The current version of the plugin. |
|
| 56 | - */ |
|
| 57 | - protected $version; |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 61 | - * |
|
| 62 | - * @since 3.12.0 |
|
| 63 | - * @access protected |
|
| 64 | - * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 65 | - */ |
|
| 66 | - protected $tinymce_adapter; |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * The Thumbnail service. |
|
| 70 | - * |
|
| 71 | - * @since 3.1.5 |
|
| 72 | - * @access private |
|
| 73 | - * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service. |
|
| 74 | - */ |
|
| 75 | - private $thumbnail_service; |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * The UI service. |
|
| 79 | - * |
|
| 80 | - * @since 3.2.0 |
|
| 81 | - * @access private |
|
| 82 | - * @var \Wordlift_UI_Service $ui_service The UI service. |
|
| 83 | - */ |
|
| 84 | - private $ui_service; |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * The Schema service. |
|
| 88 | - * |
|
| 89 | - * @since 3.3.0 |
|
| 90 | - * @access protected |
|
| 91 | - * @var \Wordlift_Schema_Service $schema_service The Schema service. |
|
| 92 | - */ |
|
| 93 | - protected $schema_service; |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * The Entity service. |
|
| 97 | - * |
|
| 98 | - * @since 3.1.0 |
|
| 99 | - * @access protected |
|
| 100 | - * @var \Wordlift_Entity_Service $entity_service The Entity service. |
|
| 101 | - */ |
|
| 102 | - protected $entity_service; |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * The Topic Taxonomy service. |
|
| 106 | - * |
|
| 107 | - * @since 3.5.0 |
|
| 108 | - * @access private |
|
| 109 | - * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service. |
|
| 110 | - */ |
|
| 111 | - private $topic_taxonomy_service; |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * The User service. |
|
| 115 | - * |
|
| 116 | - * @since 3.1.7 |
|
| 117 | - * @access protected |
|
| 118 | - * @var \Wordlift_User_Service $user_service The User service. |
|
| 119 | - */ |
|
| 120 | - protected $user_service; |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * The Timeline service. |
|
| 124 | - * |
|
| 125 | - * @since 3.1.0 |
|
| 126 | - * @access private |
|
| 127 | - * @var \Wordlift_Timeline_Service $timeline_service The Timeline service. |
|
| 128 | - */ |
|
| 129 | - private $timeline_service; |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * The Redirect service. |
|
| 133 | - * |
|
| 134 | - * @since 3.2.0 |
|
| 135 | - * @access private |
|
| 136 | - * @var \Wordlift_Redirect_Service $redirect_service The Redirect service. |
|
| 137 | - */ |
|
| 138 | - private $redirect_service; |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * The Notice service. |
|
| 142 | - * |
|
| 143 | - * @since 3.3.0 |
|
| 144 | - * @access private |
|
| 145 | - * @var \Wordlift_Notice_Service $notice_service The Notice service. |
|
| 146 | - */ |
|
| 147 | - private $notice_service; |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * The Entity list customization. |
|
| 151 | - * |
|
| 152 | - * @since 3.3.0 |
|
| 153 | - * @access protected |
|
| 154 | - * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service. |
|
| 155 | - */ |
|
| 156 | - protected $entity_list_service; |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * The Entity Types Taxonomy Walker. |
|
| 160 | - * |
|
| 161 | - * @since 3.1.0 |
|
| 162 | - * @access private |
|
| 163 | - * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker |
|
| 164 | - */ |
|
| 165 | - private $entity_types_taxonomy_walker; |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * The ShareThis service. |
|
| 169 | - * |
|
| 170 | - * @since 3.2.0 |
|
| 171 | - * @access private |
|
| 172 | - * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service. |
|
| 173 | - */ |
|
| 174 | - private $sharethis_service; |
|
| 175 | - |
|
| 176 | - /** |
|
| 177 | - * The PrimaShop adapter. |
|
| 178 | - * |
|
| 179 | - * @since 3.2.3 |
|
| 180 | - * @access private |
|
| 181 | - * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter. |
|
| 182 | - */ |
|
| 183 | - private $primashop_adapter; |
|
| 184 | - |
|
| 185 | - /** |
|
| 186 | - * The WordLift Dashboard adapter. |
|
| 187 | - * |
|
| 188 | - * @since 3.4.0 |
|
| 189 | - * @access private |
|
| 190 | - * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service; |
|
| 191 | - */ |
|
| 192 | - private $dashboard_service; |
|
| 193 | - |
|
| 194 | - /** |
|
| 195 | - * The entity type service. |
|
| 196 | - * |
|
| 197 | - * @since 3.6.0 |
|
| 198 | - * @access private |
|
| 199 | - * @var \Wordlift_Entity_Post_Type_Service |
|
| 200 | - */ |
|
| 201 | - private $entity_post_type_service; |
|
| 202 | - |
|
| 203 | - /** |
|
| 204 | - * The entity link service used to mangle links to entities with a custom slug or even w/o a slug. |
|
| 205 | - * |
|
| 206 | - * @since 3.6.0 |
|
| 207 | - * @access private |
|
| 208 | - * @var \Wordlift_Entity_Link_Service |
|
| 209 | - */ |
|
| 210 | - private $entity_link_service; |
|
| 211 | - |
|
| 212 | - /** |
|
| 213 | - * A {@link Wordlift_Sparql_Service} instance. |
|
| 214 | - * |
|
| 215 | - * @since 3.6.0 |
|
| 216 | - * @access protected |
|
| 217 | - * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance. |
|
| 218 | - */ |
|
| 219 | - protected $sparql_service; |
|
| 220 | - |
|
| 221 | - /** |
|
| 222 | - * A {@link Wordlift_Import_Service} instance. |
|
| 223 | - * |
|
| 224 | - * @since 3.6.0 |
|
| 225 | - * @access private |
|
| 226 | - * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance. |
|
| 227 | - */ |
|
| 228 | - private $import_service; |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * A {@link Wordlift_Rebuild_Service} instance. |
|
| 232 | - * |
|
| 233 | - * @since 3.6.0 |
|
| 234 | - * @access private |
|
| 235 | - * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance. |
|
| 236 | - */ |
|
| 237 | - private $rebuild_service; |
|
| 238 | - |
|
| 239 | - /** |
|
| 240 | - * A {@link Wordlift_Jsonld_Service} instance. |
|
| 241 | - * |
|
| 242 | - * @since 3.7.0 |
|
| 243 | - * @access protected |
|
| 244 | - * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance. |
|
| 245 | - */ |
|
| 246 | - protected $jsonld_service; |
|
| 247 | - |
|
| 248 | - /** |
|
| 249 | - * A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 250 | - * |
|
| 251 | - * @since 3.14.0 |
|
| 252 | - * @access protected |
|
| 253 | - * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 254 | - */ |
|
| 255 | - protected $jsonld_website_converter; |
|
| 256 | - |
|
| 257 | - /** |
|
| 258 | - * A {@link Wordlift_Property_Factory} instance. |
|
| 259 | - * |
|
| 260 | - * @since 3.7.0 |
|
| 261 | - * @access private |
|
| 262 | - * @var \Wordlift_Property_Factory $property_factory |
|
| 263 | - */ |
|
| 264 | - private $property_factory; |
|
| 265 | - |
|
| 266 | - /** |
|
| 267 | - * The 'Download Your Data' page. |
|
| 268 | - * |
|
| 269 | - * @since 3.6.0 |
|
| 270 | - * @access private |
|
| 271 | - * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page. |
|
| 272 | - */ |
|
| 273 | - private $download_your_data_page; |
|
| 274 | - |
|
| 275 | - /** |
|
| 276 | - * The 'WordLift Settings' page. |
|
| 277 | - * |
|
| 278 | - * @since 3.11.0 |
|
| 279 | - * @access protected |
|
| 280 | - * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page. |
|
| 281 | - */ |
|
| 282 | - protected $settings_page; |
|
| 283 | - |
|
| 284 | - /** |
|
| 285 | - * The 'WordLift Batch analysis' page. |
|
| 286 | - * |
|
| 287 | - * @since 3.14.0 |
|
| 288 | - * @access protected |
|
| 289 | - * @var \Wordlift_Batch_Analysis_Page $sbatch_analysis_page The 'WordLift batcch analysis' page. |
|
| 290 | - */ |
|
| 291 | - protected $batch_analysis_page; |
|
| 292 | - |
|
| 293 | - /** |
|
| 294 | - * The install wizard page. |
|
| 295 | - * |
|
| 296 | - * @since 3.9.0 |
|
| 297 | - * @access private |
|
| 298 | - * @var \Wordlift_Admin_Setup $admin_setup The Install wizard. |
|
| 299 | - */ |
|
| 300 | - private $admin_setup; |
|
| 301 | - |
|
| 302 | - /** |
|
| 303 | - * The Content Filter Service hooks up to the 'the_content' filter and provides |
|
| 304 | - * linking of entities to their pages. |
|
| 305 | - * |
|
| 306 | - * @since 3.8.0 |
|
| 307 | - * @access private |
|
| 308 | - * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance. |
|
| 309 | - */ |
|
| 310 | - private $content_filter_service; |
|
| 311 | - |
|
| 312 | - /** |
|
| 313 | - * A {@link Wordlift_Key_Validation_Service} instance. |
|
| 314 | - * |
|
| 315 | - * @since 3.9.0 |
|
| 316 | - * @access private |
|
| 317 | - * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 318 | - */ |
|
| 319 | - private $key_validation_service; |
|
| 320 | - |
|
| 321 | - /** |
|
| 322 | - * A {@link Wordlift_Rating_Service} instance. |
|
| 323 | - * |
|
| 324 | - * @since 3.10.0 |
|
| 325 | - * @access private |
|
| 326 | - * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance. |
|
| 327 | - */ |
|
| 328 | - private $rating_service; |
|
| 329 | - |
|
| 330 | - /** |
|
| 331 | - * A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 332 | - * |
|
| 333 | - * @since 3.10.0 |
|
| 334 | - * @access protected |
|
| 335 | - * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 336 | - */ |
|
| 337 | - protected $post_to_jsonld_converter; |
|
| 338 | - |
|
| 339 | - /** |
|
| 340 | - * A {@link Wordlift_Configuration_Service} instance. |
|
| 341 | - * |
|
| 342 | - * @since 3.10.0 |
|
| 343 | - * @access protected |
|
| 344 | - * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 345 | - */ |
|
| 346 | - protected $configuration_service; |
|
| 347 | - |
|
| 348 | - /** |
|
| 349 | - * A {@link Wordlift_Entity_Type_Service} instance. |
|
| 350 | - * |
|
| 351 | - * @since 3.10.0 |
|
| 352 | - * @access protected |
|
| 353 | - * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 354 | - */ |
|
| 355 | - protected $entity_type_service; |
|
| 356 | - |
|
| 357 | - /** |
|
| 358 | - * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 359 | - * |
|
| 360 | - * @since 3.10.0 |
|
| 361 | - * @access protected |
|
| 362 | - * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 363 | - */ |
|
| 364 | - protected $entity_post_to_jsonld_converter; |
|
| 365 | - |
|
| 366 | - /** |
|
| 367 | - * A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 368 | - * |
|
| 369 | - * @since 3.10.0 |
|
| 370 | - * @access protected |
|
| 371 | - * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 372 | - */ |
|
| 373 | - protected $postid_to_jsonld_converter; |
|
| 374 | - |
|
| 375 | - /** |
|
| 376 | - * The {@link Wordlift_Admin_Status_Page} class. |
|
| 377 | - * |
|
| 378 | - * @since 3.9.8 |
|
| 379 | - * @access private |
|
| 380 | - * @var \Wordlift_Admin_Status_Page $status_page The {@link Wordlift_Admin_Status_Page} class. |
|
| 381 | - */ |
|
| 382 | - private $status_page; |
|
| 383 | - |
|
| 384 | - /** |
|
| 385 | - * The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 386 | - * |
|
| 387 | - * @since 3.11.0 |
|
| 388 | - * @access protected |
|
| 389 | - * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 390 | - */ |
|
| 391 | - protected $category_taxonomy_service; |
|
| 392 | - |
|
| 393 | - /** |
|
| 394 | - * The {@link Wordlift_Entity_Page_Service} instance. |
|
| 395 | - * |
|
| 396 | - * @since 3.11.0 |
|
| 397 | - * @access protected |
|
| 398 | - * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance. |
|
| 399 | - */ |
|
| 400 | - protected $entity_page_service; |
|
| 401 | - |
|
| 402 | - /** |
|
| 403 | - * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 404 | - * |
|
| 405 | - * @since 3.11.0 |
|
| 406 | - * @access protected |
|
| 407 | - * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 408 | - */ |
|
| 409 | - protected $settings_page_action_link; |
|
| 410 | - |
|
| 411 | - /** |
|
| 412 | - * The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 413 | - * |
|
| 414 | - * @since 3.11.0 |
|
| 415 | - * @access protected |
|
| 416 | - * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 417 | - */ |
|
| 418 | - protected $publisher_ajax_adapter; |
|
| 419 | - |
|
| 420 | - /** |
|
| 421 | - * The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 422 | - * |
|
| 423 | - * @since 3.11.0 |
|
| 424 | - * @access protected |
|
| 425 | - * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 426 | - */ |
|
| 427 | - protected $input_element; |
|
| 428 | - |
|
| 429 | - /** |
|
| 430 | - * The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 431 | - * |
|
| 432 | - * @since 3.13.0 |
|
| 433 | - * @access protected |
|
| 434 | - * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 435 | - */ |
|
| 436 | - protected $radio_input_element; |
|
| 437 | - |
|
| 438 | - /** |
|
| 439 | - * The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 440 | - * |
|
| 441 | - * @since 3.11.0 |
|
| 442 | - * @access protected |
|
| 443 | - * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 444 | - */ |
|
| 445 | - protected $language_select_element; |
|
| 446 | - |
|
| 447 | - /** |
|
| 448 | - * The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 449 | - * |
|
| 450 | - * @since 3.11.0 |
|
| 451 | - * @access protected |
|
| 452 | - * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 453 | - */ |
|
| 454 | - protected $publisher_element; |
|
| 455 | - |
|
| 456 | - /** |
|
| 457 | - * The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 458 | - * |
|
| 459 | - * @since 3.11.0 |
|
| 460 | - * @access protected |
|
| 461 | - * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 462 | - */ |
|
| 463 | - protected $select2_element; |
|
| 464 | - |
|
| 465 | - /** |
|
| 466 | - * The controller for the entity type list admin page |
|
| 467 | - * |
|
| 468 | - * @since 3.11.0 |
|
| 469 | - * @access private |
|
| 470 | - * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class. |
|
| 471 | - */ |
|
| 472 | - private $entity_type_admin_page; |
|
| 473 | - |
|
| 474 | - /** |
|
| 475 | - * The controller for the entity type settings admin page |
|
| 476 | - * |
|
| 477 | - * @since 3.11.0 |
|
| 478 | - * @access private |
|
| 479 | - * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class. |
|
| 480 | - */ |
|
| 481 | - private $entity_type_settings_admin_page; |
|
| 482 | - |
|
| 483 | - /** |
|
| 484 | - * The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 485 | - * |
|
| 486 | - * @since 3.11.0 |
|
| 487 | - * @access protected |
|
| 488 | - * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 489 | - */ |
|
| 490 | - protected $related_entities_cloud_widget; |
|
| 491 | - |
|
| 492 | - /** |
|
| 493 | - * The {@link Wordlift_Admin_Author_Element} instance. |
|
| 494 | - * |
|
| 495 | - * @since 3.14.0 |
|
| 496 | - * @access protected |
|
| 497 | - * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance. |
|
| 498 | - */ |
|
| 499 | - protected $author_element; |
|
| 500 | - |
|
| 501 | - /** |
|
| 502 | - * The {@link Wordlift_Batch_Analysis_Service} instance. |
|
| 503 | - * |
|
| 504 | - * @since 3.14.0 |
|
| 505 | - * @access protected |
|
| 506 | - * @var \Wordlift_Batch_Analysis_Service $batch_analysis_service The {@link Wordlift_Batch_Analysis_Service} instance. |
|
| 507 | - */ |
|
| 508 | - protected $batch_analysis_service; |
|
| 509 | - |
|
| 510 | - /** |
|
| 511 | - * The {@link Wordlift_Sample_Data_Service} instance. |
|
| 512 | - * |
|
| 513 | - * @since 3.12.0 |
|
| 514 | - * @access protected |
|
| 515 | - * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance. |
|
| 516 | - */ |
|
| 517 | - protected $sample_data_service; |
|
| 518 | - |
|
| 519 | - /** |
|
| 520 | - * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 521 | - * |
|
| 522 | - * @since 3.12.0 |
|
| 523 | - * @access protected |
|
| 524 | - * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 525 | - */ |
|
| 526 | - protected $sample_data_ajax_adapter; |
|
| 527 | - |
|
| 528 | - /** |
|
| 529 | - * The {@link Wordlift_Batch_Analysis_Adapter} instance. |
|
| 530 | - * |
|
| 531 | - * @since 3.14.2 |
|
| 532 | - * @access protected |
|
| 533 | - * @var \Wordlift_Batch_Analysis_Adapter $batch_analysis_adapter The {@link Wordlift_Batch_Analysis_Adapter} instance. |
|
| 534 | - */ |
|
| 535 | - private $batch_analysis_adapter; |
|
| 536 | - |
|
| 537 | - /** |
|
| 538 | - * The {@link Wordlift_Relation_Rebuild_Service} instance. |
|
| 539 | - * |
|
| 540 | - * @since 3.14.3 |
|
| 541 | - * @access private |
|
| 542 | - * @var \Wordlift_Relation_Rebuild_Service $relation_rebuild_service The {@link Wordlift_Relation_Rebuild_Service} instance. |
|
| 543 | - */ |
|
| 544 | - private $relation_rebuild_service; |
|
| 545 | - |
|
| 546 | - /** |
|
| 547 | - * The {@link Wordlift_Relation_Rebuild_Adapter} instance. |
|
| 548 | - * |
|
| 549 | - * @since 3.14.3 |
|
| 550 | - * @access private |
|
| 551 | - * @var \Wordlift_Relation_Rebuild_Adapter $relation_rebuild_adapter The {@link Wordlift_Relation_Rebuild_Adapter} instance. |
|
| 552 | - */ |
|
| 553 | - private $relation_rebuild_adapter; |
|
| 554 | - |
|
| 555 | - /** |
|
| 556 | - * The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 557 | - * |
|
| 558 | - * @since 3.16.0 |
|
| 559 | - * @access protected |
|
| 560 | - * @var \Wordlift_Google_Analytics_Export_Service $google_analytics_export_service The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 561 | - */ |
|
| 562 | - protected $google_analytics_export_service; |
|
| 563 | - |
|
| 564 | - /** |
|
| 565 | - * {@link Wordlift}'s singleton instance. |
|
| 566 | - * |
|
| 567 | - * @since 3.15.0 |
|
| 568 | - * @access protected |
|
| 569 | - * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance. |
|
| 570 | - */ |
|
| 571 | - protected $entity_type_adapter; |
|
| 572 | - |
|
| 573 | - /** |
|
| 574 | - * The {@link Wordlift_Linked_Data_Service} instance. |
|
| 575 | - * |
|
| 576 | - * @since 3.15.0 |
|
| 577 | - * @access protected |
|
| 578 | - * @var \Wordlift_Linked_Data_Service $linked_data_service The {@link Wordlift_Linked_Data_Service} instance. |
|
| 579 | - */ |
|
| 580 | - protected $linked_data_service; |
|
| 581 | - |
|
| 582 | - /** |
|
| 583 | - * The {@link Wordlift_Storage_Factory} instance. |
|
| 584 | - * |
|
| 585 | - * @since 3.15.0 |
|
| 586 | - * @access protected |
|
| 587 | - * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance. |
|
| 588 | - */ |
|
| 589 | - protected $storage_factory; |
|
| 590 | - |
|
| 591 | - /** |
|
| 592 | - * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 593 | - * |
|
| 594 | - * @since 3.15.0 |
|
| 595 | - * @access protected |
|
| 596 | - * @var \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 597 | - */ |
|
| 598 | - protected $rendition_factory; |
|
| 599 | - |
|
| 600 | - /** |
|
| 601 | - * The {@link Wordlift_Autocomplete_Service} instance. |
|
| 602 | - * |
|
| 603 | - * @since 3.15.0 |
|
| 604 | - * @access private |
|
| 605 | - * @var \Wordlift_Autocomplete_Service $autocomplete_service The {@link Wordlift_Autocomplete_Service} instance. |
|
| 606 | - */ |
|
| 607 | - private $autocomplete_service; |
|
| 608 | - |
|
| 609 | - /** |
|
| 610 | - * The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 611 | - * |
|
| 612 | - * @since 3.15.0 |
|
| 613 | - * @access private |
|
| 614 | - * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 615 | - */ |
|
| 616 | - private $autocomplete_adapter; |
|
| 617 | - |
|
| 618 | - /** |
|
| 619 | - * The {@link Wordlift_Relation_Service} instance. |
|
| 620 | - * |
|
| 621 | - * @since 3.15.0 |
|
| 622 | - * @access protected |
|
| 623 | - * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance. |
|
| 624 | - */ |
|
| 625 | - protected $relation_service; |
|
| 626 | - |
|
| 627 | - /** |
|
| 628 | - * The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 629 | - * |
|
| 630 | - * @since 3.16.0 |
|
| 631 | - * @access protected |
|
| 632 | - * @var \Wordlift_Cached_Post_Converter $cached_postid_to_jsonld_converter The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 633 | - * |
|
| 634 | - */ |
|
| 635 | - protected $cached_postid_to_jsonld_converter; |
|
| 636 | - |
|
| 637 | - /** |
|
| 638 | - * The {@link Wordlift_File_Cache_Service} instance. |
|
| 639 | - * |
|
| 640 | - * @since 3.16.0 |
|
| 641 | - * @access protected |
|
| 642 | - * @var \Wordlift_File_Cache_Service $file_cache_service The {@link Wordlift_File_Cache_Service} instance. |
|
| 643 | - */ |
|
| 644 | - protected $file_cache_service; |
|
| 645 | - |
|
| 646 | - /** |
|
| 647 | - * {@link Wordlift}'s singleton instance. |
|
| 648 | - * |
|
| 649 | - * @since 3.11.2 |
|
| 650 | - * @access private |
|
| 651 | - * @var Wordlift $instance {@link Wordlift}'s singleton instance. |
|
| 652 | - */ |
|
| 653 | - private static $instance; |
|
| 654 | - |
|
| 655 | - |
|
| 656 | - /** |
|
| 657 | - * Define the core functionality of the plugin. |
|
| 658 | - * |
|
| 659 | - * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 660 | - * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 661 | - * the public-facing side of the site. |
|
| 662 | - * |
|
| 663 | - * @since 1.0.0 |
|
| 664 | - */ |
|
| 665 | - public function __construct() { |
|
| 666 | - |
|
| 667 | - $this->plugin_name = 'wordlift'; |
|
| 668 | - $this->version = '3.16.0-dev'; |
|
| 669 | - $this->load_dependencies(); |
|
| 670 | - $this->set_locale(); |
|
| 671 | - $this->define_admin_hooks(); |
|
| 672 | - $this->define_public_hooks(); |
|
| 673 | - |
|
| 674 | - self::$instance = $this; |
|
| 675 | - |
|
| 676 | - } |
|
| 677 | - |
|
| 678 | - /** |
|
| 679 | - * Get the singleton instance. |
|
| 680 | - * |
|
| 681 | - * @since 3.11.2 |
|
| 682 | - * |
|
| 683 | - * @return Wordlift The {@link Wordlift} singleton instance. |
|
| 684 | - */ |
|
| 685 | - public static function get_instance() { |
|
| 686 | - |
|
| 687 | - return self::$instance; |
|
| 688 | - } |
|
| 689 | - |
|
| 690 | - /** |
|
| 691 | - * Load the required dependencies for this plugin. |
|
| 692 | - * |
|
| 693 | - * Include the following files that make up the plugin: |
|
| 694 | - * |
|
| 695 | - * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 696 | - * - Wordlift_i18n. Defines internationalization functionality. |
|
| 697 | - * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 698 | - * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 699 | - * |
|
| 700 | - * Create an instance of the loader which will be used to register the hooks |
|
| 701 | - * with WordPress. |
|
| 702 | - * |
|
| 703 | - * @since 1.0.0 |
|
| 704 | - * @access private |
|
| 705 | - */ |
|
| 706 | - private function load_dependencies() { |
|
| 707 | - |
|
| 708 | - /** |
|
| 709 | - * The class responsible for orchestrating the actions and filters of the |
|
| 710 | - * core plugin. |
|
| 711 | - */ |
|
| 712 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 713 | - |
|
| 714 | - /** |
|
| 715 | - * The class responsible for defining internationalization functionality |
|
| 716 | - * of the plugin. |
|
| 717 | - */ |
|
| 718 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 719 | - |
|
| 720 | - /** |
|
| 721 | - * WordLift's supported languages. |
|
| 722 | - */ |
|
| 723 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php'; |
|
| 724 | - |
|
| 725 | - /** |
|
| 726 | - * Provide support functions to sanitize data. |
|
| 727 | - */ |
|
| 728 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 729 | - |
|
| 730 | - /** Services. */ |
|
| 731 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 732 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php'; |
|
| 733 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 734 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 735 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 736 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 737 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 738 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php'; |
|
| 739 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php'; |
|
| 740 | - |
|
| 741 | - /** |
|
| 742 | - * The Query builder. |
|
| 743 | - */ |
|
| 744 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 745 | - |
|
| 746 | - /** |
|
| 747 | - * The Schema service. |
|
| 748 | - */ |
|
| 749 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 750 | - |
|
| 751 | - /** |
|
| 752 | - * The schema:url property service. |
|
| 753 | - */ |
|
| 754 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 755 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 756 | - |
|
| 757 | - /** |
|
| 758 | - * The UI service. |
|
| 759 | - */ |
|
| 760 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 761 | - |
|
| 762 | - /** |
|
| 763 | - * The Thumbnail service. |
|
| 764 | - */ |
|
| 765 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 766 | - |
|
| 767 | - /** |
|
| 768 | - * The Entity Types Taxonomy service. |
|
| 769 | - */ |
|
| 770 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 771 | - |
|
| 772 | - /** |
|
| 773 | - * The Entity service. |
|
| 774 | - */ |
|
| 775 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 776 | - |
|
| 777 | - // Add the entity rating service. |
|
| 778 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php'; |
|
| 779 | - |
|
| 780 | - /** |
|
| 781 | - * The User service. |
|
| 782 | - */ |
|
| 783 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 784 | - |
|
| 785 | - /** |
|
| 786 | - * The Timeline service. |
|
| 787 | - */ |
|
| 788 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 789 | - |
|
| 790 | - /** |
|
| 791 | - * The Topic Taxonomy service. |
|
| 792 | - */ |
|
| 793 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 794 | - |
|
| 795 | - /** |
|
| 796 | - * The SPARQL service. |
|
| 797 | - */ |
|
| 798 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 799 | - |
|
| 800 | - /** |
|
| 801 | - * The WordLift import service. |
|
| 802 | - */ |
|
| 803 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 804 | - |
|
| 805 | - /** |
|
| 806 | - * The WordLift URI service. |
|
| 807 | - */ |
|
| 808 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 809 | - |
|
| 810 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php'; |
|
| 811 | - |
|
| 812 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 813 | - |
|
| 814 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php'; |
|
| 815 | - |
|
| 816 | - /** |
|
| 817 | - * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
|
| 818 | - */ |
|
| 819 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php'; |
|
| 820 | - |
|
| 821 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 822 | - |
|
| 823 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php'; |
|
| 824 | - |
|
| 825 | - /** |
|
| 826 | - * Load the converters. |
|
| 827 | - */ |
|
| 828 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php'; |
|
| 829 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 830 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 831 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 832 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 833 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php'; |
|
| 834 | - |
|
| 835 | - /** |
|
| 836 | - * Load cache-related files. |
|
| 837 | - */ |
|
| 838 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php'; |
|
| 839 | - |
|
| 840 | - /** |
|
| 841 | - * Load the content filter. |
|
| 842 | - */ |
|
| 843 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 844 | - |
|
| 845 | - /* |
|
| 31 | + /** |
|
| 32 | + * The loader that's responsible for maintaining and registering all hooks that power |
|
| 33 | + * the plugin. |
|
| 34 | + * |
|
| 35 | + * @since 1.0.0 |
|
| 36 | + * @access protected |
|
| 37 | + * @var Wordlift_Loader $loader Maintains and registers all hooks for the plugin. |
|
| 38 | + */ |
|
| 39 | + protected $loader; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * The unique identifier of this plugin. |
|
| 43 | + * |
|
| 44 | + * @since 1.0.0 |
|
| 45 | + * @access protected |
|
| 46 | + * @var string $plugin_name The string used to uniquely identify this plugin. |
|
| 47 | + */ |
|
| 48 | + protected $plugin_name; |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * The current version of the plugin. |
|
| 52 | + * |
|
| 53 | + * @since 1.0.0 |
|
| 54 | + * @access protected |
|
| 55 | + * @var string $version The current version of the plugin. |
|
| 56 | + */ |
|
| 57 | + protected $version; |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 61 | + * |
|
| 62 | + * @since 3.12.0 |
|
| 63 | + * @access protected |
|
| 64 | + * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 65 | + */ |
|
| 66 | + protected $tinymce_adapter; |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * The Thumbnail service. |
|
| 70 | + * |
|
| 71 | + * @since 3.1.5 |
|
| 72 | + * @access private |
|
| 73 | + * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service. |
|
| 74 | + */ |
|
| 75 | + private $thumbnail_service; |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * The UI service. |
|
| 79 | + * |
|
| 80 | + * @since 3.2.0 |
|
| 81 | + * @access private |
|
| 82 | + * @var \Wordlift_UI_Service $ui_service The UI service. |
|
| 83 | + */ |
|
| 84 | + private $ui_service; |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * The Schema service. |
|
| 88 | + * |
|
| 89 | + * @since 3.3.0 |
|
| 90 | + * @access protected |
|
| 91 | + * @var \Wordlift_Schema_Service $schema_service The Schema service. |
|
| 92 | + */ |
|
| 93 | + protected $schema_service; |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * The Entity service. |
|
| 97 | + * |
|
| 98 | + * @since 3.1.0 |
|
| 99 | + * @access protected |
|
| 100 | + * @var \Wordlift_Entity_Service $entity_service The Entity service. |
|
| 101 | + */ |
|
| 102 | + protected $entity_service; |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * The Topic Taxonomy service. |
|
| 106 | + * |
|
| 107 | + * @since 3.5.0 |
|
| 108 | + * @access private |
|
| 109 | + * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service. |
|
| 110 | + */ |
|
| 111 | + private $topic_taxonomy_service; |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * The User service. |
|
| 115 | + * |
|
| 116 | + * @since 3.1.7 |
|
| 117 | + * @access protected |
|
| 118 | + * @var \Wordlift_User_Service $user_service The User service. |
|
| 119 | + */ |
|
| 120 | + protected $user_service; |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * The Timeline service. |
|
| 124 | + * |
|
| 125 | + * @since 3.1.0 |
|
| 126 | + * @access private |
|
| 127 | + * @var \Wordlift_Timeline_Service $timeline_service The Timeline service. |
|
| 128 | + */ |
|
| 129 | + private $timeline_service; |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * The Redirect service. |
|
| 133 | + * |
|
| 134 | + * @since 3.2.0 |
|
| 135 | + * @access private |
|
| 136 | + * @var \Wordlift_Redirect_Service $redirect_service The Redirect service. |
|
| 137 | + */ |
|
| 138 | + private $redirect_service; |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * The Notice service. |
|
| 142 | + * |
|
| 143 | + * @since 3.3.0 |
|
| 144 | + * @access private |
|
| 145 | + * @var \Wordlift_Notice_Service $notice_service The Notice service. |
|
| 146 | + */ |
|
| 147 | + private $notice_service; |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * The Entity list customization. |
|
| 151 | + * |
|
| 152 | + * @since 3.3.0 |
|
| 153 | + * @access protected |
|
| 154 | + * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service. |
|
| 155 | + */ |
|
| 156 | + protected $entity_list_service; |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * The Entity Types Taxonomy Walker. |
|
| 160 | + * |
|
| 161 | + * @since 3.1.0 |
|
| 162 | + * @access private |
|
| 163 | + * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker |
|
| 164 | + */ |
|
| 165 | + private $entity_types_taxonomy_walker; |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * The ShareThis service. |
|
| 169 | + * |
|
| 170 | + * @since 3.2.0 |
|
| 171 | + * @access private |
|
| 172 | + * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service. |
|
| 173 | + */ |
|
| 174 | + private $sharethis_service; |
|
| 175 | + |
|
| 176 | + /** |
|
| 177 | + * The PrimaShop adapter. |
|
| 178 | + * |
|
| 179 | + * @since 3.2.3 |
|
| 180 | + * @access private |
|
| 181 | + * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter. |
|
| 182 | + */ |
|
| 183 | + private $primashop_adapter; |
|
| 184 | + |
|
| 185 | + /** |
|
| 186 | + * The WordLift Dashboard adapter. |
|
| 187 | + * |
|
| 188 | + * @since 3.4.0 |
|
| 189 | + * @access private |
|
| 190 | + * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service; |
|
| 191 | + */ |
|
| 192 | + private $dashboard_service; |
|
| 193 | + |
|
| 194 | + /** |
|
| 195 | + * The entity type service. |
|
| 196 | + * |
|
| 197 | + * @since 3.6.0 |
|
| 198 | + * @access private |
|
| 199 | + * @var \Wordlift_Entity_Post_Type_Service |
|
| 200 | + */ |
|
| 201 | + private $entity_post_type_service; |
|
| 202 | + |
|
| 203 | + /** |
|
| 204 | + * The entity link service used to mangle links to entities with a custom slug or even w/o a slug. |
|
| 205 | + * |
|
| 206 | + * @since 3.6.0 |
|
| 207 | + * @access private |
|
| 208 | + * @var \Wordlift_Entity_Link_Service |
|
| 209 | + */ |
|
| 210 | + private $entity_link_service; |
|
| 211 | + |
|
| 212 | + /** |
|
| 213 | + * A {@link Wordlift_Sparql_Service} instance. |
|
| 214 | + * |
|
| 215 | + * @since 3.6.0 |
|
| 216 | + * @access protected |
|
| 217 | + * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance. |
|
| 218 | + */ |
|
| 219 | + protected $sparql_service; |
|
| 220 | + |
|
| 221 | + /** |
|
| 222 | + * A {@link Wordlift_Import_Service} instance. |
|
| 223 | + * |
|
| 224 | + * @since 3.6.0 |
|
| 225 | + * @access private |
|
| 226 | + * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance. |
|
| 227 | + */ |
|
| 228 | + private $import_service; |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * A {@link Wordlift_Rebuild_Service} instance. |
|
| 232 | + * |
|
| 233 | + * @since 3.6.0 |
|
| 234 | + * @access private |
|
| 235 | + * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance. |
|
| 236 | + */ |
|
| 237 | + private $rebuild_service; |
|
| 238 | + |
|
| 239 | + /** |
|
| 240 | + * A {@link Wordlift_Jsonld_Service} instance. |
|
| 241 | + * |
|
| 242 | + * @since 3.7.0 |
|
| 243 | + * @access protected |
|
| 244 | + * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance. |
|
| 245 | + */ |
|
| 246 | + protected $jsonld_service; |
|
| 247 | + |
|
| 248 | + /** |
|
| 249 | + * A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 250 | + * |
|
| 251 | + * @since 3.14.0 |
|
| 252 | + * @access protected |
|
| 253 | + * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 254 | + */ |
|
| 255 | + protected $jsonld_website_converter; |
|
| 256 | + |
|
| 257 | + /** |
|
| 258 | + * A {@link Wordlift_Property_Factory} instance. |
|
| 259 | + * |
|
| 260 | + * @since 3.7.0 |
|
| 261 | + * @access private |
|
| 262 | + * @var \Wordlift_Property_Factory $property_factory |
|
| 263 | + */ |
|
| 264 | + private $property_factory; |
|
| 265 | + |
|
| 266 | + /** |
|
| 267 | + * The 'Download Your Data' page. |
|
| 268 | + * |
|
| 269 | + * @since 3.6.0 |
|
| 270 | + * @access private |
|
| 271 | + * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page. |
|
| 272 | + */ |
|
| 273 | + private $download_your_data_page; |
|
| 274 | + |
|
| 275 | + /** |
|
| 276 | + * The 'WordLift Settings' page. |
|
| 277 | + * |
|
| 278 | + * @since 3.11.0 |
|
| 279 | + * @access protected |
|
| 280 | + * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page. |
|
| 281 | + */ |
|
| 282 | + protected $settings_page; |
|
| 283 | + |
|
| 284 | + /** |
|
| 285 | + * The 'WordLift Batch analysis' page. |
|
| 286 | + * |
|
| 287 | + * @since 3.14.0 |
|
| 288 | + * @access protected |
|
| 289 | + * @var \Wordlift_Batch_Analysis_Page $sbatch_analysis_page The 'WordLift batcch analysis' page. |
|
| 290 | + */ |
|
| 291 | + protected $batch_analysis_page; |
|
| 292 | + |
|
| 293 | + /** |
|
| 294 | + * The install wizard page. |
|
| 295 | + * |
|
| 296 | + * @since 3.9.0 |
|
| 297 | + * @access private |
|
| 298 | + * @var \Wordlift_Admin_Setup $admin_setup The Install wizard. |
|
| 299 | + */ |
|
| 300 | + private $admin_setup; |
|
| 301 | + |
|
| 302 | + /** |
|
| 303 | + * The Content Filter Service hooks up to the 'the_content' filter and provides |
|
| 304 | + * linking of entities to their pages. |
|
| 305 | + * |
|
| 306 | + * @since 3.8.0 |
|
| 307 | + * @access private |
|
| 308 | + * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance. |
|
| 309 | + */ |
|
| 310 | + private $content_filter_service; |
|
| 311 | + |
|
| 312 | + /** |
|
| 313 | + * A {@link Wordlift_Key_Validation_Service} instance. |
|
| 314 | + * |
|
| 315 | + * @since 3.9.0 |
|
| 316 | + * @access private |
|
| 317 | + * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 318 | + */ |
|
| 319 | + private $key_validation_service; |
|
| 320 | + |
|
| 321 | + /** |
|
| 322 | + * A {@link Wordlift_Rating_Service} instance. |
|
| 323 | + * |
|
| 324 | + * @since 3.10.0 |
|
| 325 | + * @access private |
|
| 326 | + * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance. |
|
| 327 | + */ |
|
| 328 | + private $rating_service; |
|
| 329 | + |
|
| 330 | + /** |
|
| 331 | + * A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 332 | + * |
|
| 333 | + * @since 3.10.0 |
|
| 334 | + * @access protected |
|
| 335 | + * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 336 | + */ |
|
| 337 | + protected $post_to_jsonld_converter; |
|
| 338 | + |
|
| 339 | + /** |
|
| 340 | + * A {@link Wordlift_Configuration_Service} instance. |
|
| 341 | + * |
|
| 342 | + * @since 3.10.0 |
|
| 343 | + * @access protected |
|
| 344 | + * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 345 | + */ |
|
| 346 | + protected $configuration_service; |
|
| 347 | + |
|
| 348 | + /** |
|
| 349 | + * A {@link Wordlift_Entity_Type_Service} instance. |
|
| 350 | + * |
|
| 351 | + * @since 3.10.0 |
|
| 352 | + * @access protected |
|
| 353 | + * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 354 | + */ |
|
| 355 | + protected $entity_type_service; |
|
| 356 | + |
|
| 357 | + /** |
|
| 358 | + * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 359 | + * |
|
| 360 | + * @since 3.10.0 |
|
| 361 | + * @access protected |
|
| 362 | + * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 363 | + */ |
|
| 364 | + protected $entity_post_to_jsonld_converter; |
|
| 365 | + |
|
| 366 | + /** |
|
| 367 | + * A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 368 | + * |
|
| 369 | + * @since 3.10.0 |
|
| 370 | + * @access protected |
|
| 371 | + * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 372 | + */ |
|
| 373 | + protected $postid_to_jsonld_converter; |
|
| 374 | + |
|
| 375 | + /** |
|
| 376 | + * The {@link Wordlift_Admin_Status_Page} class. |
|
| 377 | + * |
|
| 378 | + * @since 3.9.8 |
|
| 379 | + * @access private |
|
| 380 | + * @var \Wordlift_Admin_Status_Page $status_page The {@link Wordlift_Admin_Status_Page} class. |
|
| 381 | + */ |
|
| 382 | + private $status_page; |
|
| 383 | + |
|
| 384 | + /** |
|
| 385 | + * The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 386 | + * |
|
| 387 | + * @since 3.11.0 |
|
| 388 | + * @access protected |
|
| 389 | + * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 390 | + */ |
|
| 391 | + protected $category_taxonomy_service; |
|
| 392 | + |
|
| 393 | + /** |
|
| 394 | + * The {@link Wordlift_Entity_Page_Service} instance. |
|
| 395 | + * |
|
| 396 | + * @since 3.11.0 |
|
| 397 | + * @access protected |
|
| 398 | + * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance. |
|
| 399 | + */ |
|
| 400 | + protected $entity_page_service; |
|
| 401 | + |
|
| 402 | + /** |
|
| 403 | + * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 404 | + * |
|
| 405 | + * @since 3.11.0 |
|
| 406 | + * @access protected |
|
| 407 | + * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 408 | + */ |
|
| 409 | + protected $settings_page_action_link; |
|
| 410 | + |
|
| 411 | + /** |
|
| 412 | + * The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 413 | + * |
|
| 414 | + * @since 3.11.0 |
|
| 415 | + * @access protected |
|
| 416 | + * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 417 | + */ |
|
| 418 | + protected $publisher_ajax_adapter; |
|
| 419 | + |
|
| 420 | + /** |
|
| 421 | + * The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 422 | + * |
|
| 423 | + * @since 3.11.0 |
|
| 424 | + * @access protected |
|
| 425 | + * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 426 | + */ |
|
| 427 | + protected $input_element; |
|
| 428 | + |
|
| 429 | + /** |
|
| 430 | + * The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 431 | + * |
|
| 432 | + * @since 3.13.0 |
|
| 433 | + * @access protected |
|
| 434 | + * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 435 | + */ |
|
| 436 | + protected $radio_input_element; |
|
| 437 | + |
|
| 438 | + /** |
|
| 439 | + * The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 440 | + * |
|
| 441 | + * @since 3.11.0 |
|
| 442 | + * @access protected |
|
| 443 | + * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 444 | + */ |
|
| 445 | + protected $language_select_element; |
|
| 446 | + |
|
| 447 | + /** |
|
| 448 | + * The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 449 | + * |
|
| 450 | + * @since 3.11.0 |
|
| 451 | + * @access protected |
|
| 452 | + * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 453 | + */ |
|
| 454 | + protected $publisher_element; |
|
| 455 | + |
|
| 456 | + /** |
|
| 457 | + * The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 458 | + * |
|
| 459 | + * @since 3.11.0 |
|
| 460 | + * @access protected |
|
| 461 | + * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 462 | + */ |
|
| 463 | + protected $select2_element; |
|
| 464 | + |
|
| 465 | + /** |
|
| 466 | + * The controller for the entity type list admin page |
|
| 467 | + * |
|
| 468 | + * @since 3.11.0 |
|
| 469 | + * @access private |
|
| 470 | + * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class. |
|
| 471 | + */ |
|
| 472 | + private $entity_type_admin_page; |
|
| 473 | + |
|
| 474 | + /** |
|
| 475 | + * The controller for the entity type settings admin page |
|
| 476 | + * |
|
| 477 | + * @since 3.11.0 |
|
| 478 | + * @access private |
|
| 479 | + * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class. |
|
| 480 | + */ |
|
| 481 | + private $entity_type_settings_admin_page; |
|
| 482 | + |
|
| 483 | + /** |
|
| 484 | + * The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 485 | + * |
|
| 486 | + * @since 3.11.0 |
|
| 487 | + * @access protected |
|
| 488 | + * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 489 | + */ |
|
| 490 | + protected $related_entities_cloud_widget; |
|
| 491 | + |
|
| 492 | + /** |
|
| 493 | + * The {@link Wordlift_Admin_Author_Element} instance. |
|
| 494 | + * |
|
| 495 | + * @since 3.14.0 |
|
| 496 | + * @access protected |
|
| 497 | + * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance. |
|
| 498 | + */ |
|
| 499 | + protected $author_element; |
|
| 500 | + |
|
| 501 | + /** |
|
| 502 | + * The {@link Wordlift_Batch_Analysis_Service} instance. |
|
| 503 | + * |
|
| 504 | + * @since 3.14.0 |
|
| 505 | + * @access protected |
|
| 506 | + * @var \Wordlift_Batch_Analysis_Service $batch_analysis_service The {@link Wordlift_Batch_Analysis_Service} instance. |
|
| 507 | + */ |
|
| 508 | + protected $batch_analysis_service; |
|
| 509 | + |
|
| 510 | + /** |
|
| 511 | + * The {@link Wordlift_Sample_Data_Service} instance. |
|
| 512 | + * |
|
| 513 | + * @since 3.12.0 |
|
| 514 | + * @access protected |
|
| 515 | + * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance. |
|
| 516 | + */ |
|
| 517 | + protected $sample_data_service; |
|
| 518 | + |
|
| 519 | + /** |
|
| 520 | + * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 521 | + * |
|
| 522 | + * @since 3.12.0 |
|
| 523 | + * @access protected |
|
| 524 | + * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 525 | + */ |
|
| 526 | + protected $sample_data_ajax_adapter; |
|
| 527 | + |
|
| 528 | + /** |
|
| 529 | + * The {@link Wordlift_Batch_Analysis_Adapter} instance. |
|
| 530 | + * |
|
| 531 | + * @since 3.14.2 |
|
| 532 | + * @access protected |
|
| 533 | + * @var \Wordlift_Batch_Analysis_Adapter $batch_analysis_adapter The {@link Wordlift_Batch_Analysis_Adapter} instance. |
|
| 534 | + */ |
|
| 535 | + private $batch_analysis_adapter; |
|
| 536 | + |
|
| 537 | + /** |
|
| 538 | + * The {@link Wordlift_Relation_Rebuild_Service} instance. |
|
| 539 | + * |
|
| 540 | + * @since 3.14.3 |
|
| 541 | + * @access private |
|
| 542 | + * @var \Wordlift_Relation_Rebuild_Service $relation_rebuild_service The {@link Wordlift_Relation_Rebuild_Service} instance. |
|
| 543 | + */ |
|
| 544 | + private $relation_rebuild_service; |
|
| 545 | + |
|
| 546 | + /** |
|
| 547 | + * The {@link Wordlift_Relation_Rebuild_Adapter} instance. |
|
| 548 | + * |
|
| 549 | + * @since 3.14.3 |
|
| 550 | + * @access private |
|
| 551 | + * @var \Wordlift_Relation_Rebuild_Adapter $relation_rebuild_adapter The {@link Wordlift_Relation_Rebuild_Adapter} instance. |
|
| 552 | + */ |
|
| 553 | + private $relation_rebuild_adapter; |
|
| 554 | + |
|
| 555 | + /** |
|
| 556 | + * The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 557 | + * |
|
| 558 | + * @since 3.16.0 |
|
| 559 | + * @access protected |
|
| 560 | + * @var \Wordlift_Google_Analytics_Export_Service $google_analytics_export_service The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 561 | + */ |
|
| 562 | + protected $google_analytics_export_service; |
|
| 563 | + |
|
| 564 | + /** |
|
| 565 | + * {@link Wordlift}'s singleton instance. |
|
| 566 | + * |
|
| 567 | + * @since 3.15.0 |
|
| 568 | + * @access protected |
|
| 569 | + * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance. |
|
| 570 | + */ |
|
| 571 | + protected $entity_type_adapter; |
|
| 572 | + |
|
| 573 | + /** |
|
| 574 | + * The {@link Wordlift_Linked_Data_Service} instance. |
|
| 575 | + * |
|
| 576 | + * @since 3.15.0 |
|
| 577 | + * @access protected |
|
| 578 | + * @var \Wordlift_Linked_Data_Service $linked_data_service The {@link Wordlift_Linked_Data_Service} instance. |
|
| 579 | + */ |
|
| 580 | + protected $linked_data_service; |
|
| 581 | + |
|
| 582 | + /** |
|
| 583 | + * The {@link Wordlift_Storage_Factory} instance. |
|
| 584 | + * |
|
| 585 | + * @since 3.15.0 |
|
| 586 | + * @access protected |
|
| 587 | + * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance. |
|
| 588 | + */ |
|
| 589 | + protected $storage_factory; |
|
| 590 | + |
|
| 591 | + /** |
|
| 592 | + * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 593 | + * |
|
| 594 | + * @since 3.15.0 |
|
| 595 | + * @access protected |
|
| 596 | + * @var \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 597 | + */ |
|
| 598 | + protected $rendition_factory; |
|
| 599 | + |
|
| 600 | + /** |
|
| 601 | + * The {@link Wordlift_Autocomplete_Service} instance. |
|
| 602 | + * |
|
| 603 | + * @since 3.15.0 |
|
| 604 | + * @access private |
|
| 605 | + * @var \Wordlift_Autocomplete_Service $autocomplete_service The {@link Wordlift_Autocomplete_Service} instance. |
|
| 606 | + */ |
|
| 607 | + private $autocomplete_service; |
|
| 608 | + |
|
| 609 | + /** |
|
| 610 | + * The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 611 | + * |
|
| 612 | + * @since 3.15.0 |
|
| 613 | + * @access private |
|
| 614 | + * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 615 | + */ |
|
| 616 | + private $autocomplete_adapter; |
|
| 617 | + |
|
| 618 | + /** |
|
| 619 | + * The {@link Wordlift_Relation_Service} instance. |
|
| 620 | + * |
|
| 621 | + * @since 3.15.0 |
|
| 622 | + * @access protected |
|
| 623 | + * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance. |
|
| 624 | + */ |
|
| 625 | + protected $relation_service; |
|
| 626 | + |
|
| 627 | + /** |
|
| 628 | + * The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 629 | + * |
|
| 630 | + * @since 3.16.0 |
|
| 631 | + * @access protected |
|
| 632 | + * @var \Wordlift_Cached_Post_Converter $cached_postid_to_jsonld_converter The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 633 | + * |
|
| 634 | + */ |
|
| 635 | + protected $cached_postid_to_jsonld_converter; |
|
| 636 | + |
|
| 637 | + /** |
|
| 638 | + * The {@link Wordlift_File_Cache_Service} instance. |
|
| 639 | + * |
|
| 640 | + * @since 3.16.0 |
|
| 641 | + * @access protected |
|
| 642 | + * @var \Wordlift_File_Cache_Service $file_cache_service The {@link Wordlift_File_Cache_Service} instance. |
|
| 643 | + */ |
|
| 644 | + protected $file_cache_service; |
|
| 645 | + |
|
| 646 | + /** |
|
| 647 | + * {@link Wordlift}'s singleton instance. |
|
| 648 | + * |
|
| 649 | + * @since 3.11.2 |
|
| 650 | + * @access private |
|
| 651 | + * @var Wordlift $instance {@link Wordlift}'s singleton instance. |
|
| 652 | + */ |
|
| 653 | + private static $instance; |
|
| 654 | + |
|
| 655 | + |
|
| 656 | + /** |
|
| 657 | + * Define the core functionality of the plugin. |
|
| 658 | + * |
|
| 659 | + * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 660 | + * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 661 | + * the public-facing side of the site. |
|
| 662 | + * |
|
| 663 | + * @since 1.0.0 |
|
| 664 | + */ |
|
| 665 | + public function __construct() { |
|
| 666 | + |
|
| 667 | + $this->plugin_name = 'wordlift'; |
|
| 668 | + $this->version = '3.16.0-dev'; |
|
| 669 | + $this->load_dependencies(); |
|
| 670 | + $this->set_locale(); |
|
| 671 | + $this->define_admin_hooks(); |
|
| 672 | + $this->define_public_hooks(); |
|
| 673 | + |
|
| 674 | + self::$instance = $this; |
|
| 675 | + |
|
| 676 | + } |
|
| 677 | + |
|
| 678 | + /** |
|
| 679 | + * Get the singleton instance. |
|
| 680 | + * |
|
| 681 | + * @since 3.11.2 |
|
| 682 | + * |
|
| 683 | + * @return Wordlift The {@link Wordlift} singleton instance. |
|
| 684 | + */ |
|
| 685 | + public static function get_instance() { |
|
| 686 | + |
|
| 687 | + return self::$instance; |
|
| 688 | + } |
|
| 689 | + |
|
| 690 | + /** |
|
| 691 | + * Load the required dependencies for this plugin. |
|
| 692 | + * |
|
| 693 | + * Include the following files that make up the plugin: |
|
| 694 | + * |
|
| 695 | + * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 696 | + * - Wordlift_i18n. Defines internationalization functionality. |
|
| 697 | + * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 698 | + * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 699 | + * |
|
| 700 | + * Create an instance of the loader which will be used to register the hooks |
|
| 701 | + * with WordPress. |
|
| 702 | + * |
|
| 703 | + * @since 1.0.0 |
|
| 704 | + * @access private |
|
| 705 | + */ |
|
| 706 | + private function load_dependencies() { |
|
| 707 | + |
|
| 708 | + /** |
|
| 709 | + * The class responsible for orchestrating the actions and filters of the |
|
| 710 | + * core plugin. |
|
| 711 | + */ |
|
| 712 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 713 | + |
|
| 714 | + /** |
|
| 715 | + * The class responsible for defining internationalization functionality |
|
| 716 | + * of the plugin. |
|
| 717 | + */ |
|
| 718 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 719 | + |
|
| 720 | + /** |
|
| 721 | + * WordLift's supported languages. |
|
| 722 | + */ |
|
| 723 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php'; |
|
| 724 | + |
|
| 725 | + /** |
|
| 726 | + * Provide support functions to sanitize data. |
|
| 727 | + */ |
|
| 728 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 729 | + |
|
| 730 | + /** Services. */ |
|
| 731 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 732 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php'; |
|
| 733 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 734 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 735 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 736 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 737 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 738 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php'; |
|
| 739 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php'; |
|
| 740 | + |
|
| 741 | + /** |
|
| 742 | + * The Query builder. |
|
| 743 | + */ |
|
| 744 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 745 | + |
|
| 746 | + /** |
|
| 747 | + * The Schema service. |
|
| 748 | + */ |
|
| 749 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 750 | + |
|
| 751 | + /** |
|
| 752 | + * The schema:url property service. |
|
| 753 | + */ |
|
| 754 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 755 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 756 | + |
|
| 757 | + /** |
|
| 758 | + * The UI service. |
|
| 759 | + */ |
|
| 760 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 761 | + |
|
| 762 | + /** |
|
| 763 | + * The Thumbnail service. |
|
| 764 | + */ |
|
| 765 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 766 | + |
|
| 767 | + /** |
|
| 768 | + * The Entity Types Taxonomy service. |
|
| 769 | + */ |
|
| 770 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 771 | + |
|
| 772 | + /** |
|
| 773 | + * The Entity service. |
|
| 774 | + */ |
|
| 775 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 776 | + |
|
| 777 | + // Add the entity rating service. |
|
| 778 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php'; |
|
| 779 | + |
|
| 780 | + /** |
|
| 781 | + * The User service. |
|
| 782 | + */ |
|
| 783 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 784 | + |
|
| 785 | + /** |
|
| 786 | + * The Timeline service. |
|
| 787 | + */ |
|
| 788 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 789 | + |
|
| 790 | + /** |
|
| 791 | + * The Topic Taxonomy service. |
|
| 792 | + */ |
|
| 793 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 794 | + |
|
| 795 | + /** |
|
| 796 | + * The SPARQL service. |
|
| 797 | + */ |
|
| 798 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 799 | + |
|
| 800 | + /** |
|
| 801 | + * The WordLift import service. |
|
| 802 | + */ |
|
| 803 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 804 | + |
|
| 805 | + /** |
|
| 806 | + * The WordLift URI service. |
|
| 807 | + */ |
|
| 808 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 809 | + |
|
| 810 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php'; |
|
| 811 | + |
|
| 812 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 813 | + |
|
| 814 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php'; |
|
| 815 | + |
|
| 816 | + /** |
|
| 817 | + * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
|
| 818 | + */ |
|
| 819 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php'; |
|
| 820 | + |
|
| 821 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 822 | + |
|
| 823 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php'; |
|
| 824 | + |
|
| 825 | + /** |
|
| 826 | + * Load the converters. |
|
| 827 | + */ |
|
| 828 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php'; |
|
| 829 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 830 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 831 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 832 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 833 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php'; |
|
| 834 | + |
|
| 835 | + /** |
|
| 836 | + * Load cache-related files. |
|
| 837 | + */ |
|
| 838 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php'; |
|
| 839 | + |
|
| 840 | + /** |
|
| 841 | + * Load the content filter. |
|
| 842 | + */ |
|
| 843 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 844 | + |
|
| 845 | + /* |
|
| 846 | 846 | * Load the excerpt helper. |
| 847 | 847 | */ |
| 848 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 849 | - |
|
| 850 | - /** |
|
| 851 | - * Load the JSON-LD service to publish entities using JSON-LD.s |
|
| 852 | - * |
|
| 853 | - * @since 3.8.0 |
|
| 854 | - */ |
|
| 855 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 856 | - |
|
| 857 | - // The Publisher Service and the AJAX adapter. |
|
| 858 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php'; |
|
| 859 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 860 | - |
|
| 861 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php'; |
|
| 862 | - |
|
| 863 | - /** |
|
| 864 | - * Load the WordLift key validation service. |
|
| 865 | - */ |
|
| 866 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php'; |
|
| 867 | - |
|
| 868 | - // Load the `Wordlift_Category_Taxonomy_Service` class definition. |
|
| 869 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 870 | - |
|
| 871 | - // Load the `Wordlift_Entity_Page_Service` class definition. |
|
| 872 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php'; |
|
| 873 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-analysis-service.php'; |
|
| 874 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-rebuild-service.php'; |
|
| 875 | - |
|
| 876 | - /** Linked Data. */ |
|
| 877 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php'; |
|
| 878 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php'; |
|
| 879 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php'; |
|
| 880 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php'; |
|
| 881 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php'; |
|
| 882 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php'; |
|
| 883 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php'; |
|
| 884 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php'; |
|
| 885 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php'; |
|
| 886 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php'; |
|
| 887 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php'; |
|
| 888 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition.php'; |
|
| 889 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php'; |
|
| 890 | - |
|
| 891 | - /** Services. */ |
|
| 892 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php'; |
|
| 893 | - |
|
| 894 | - /** Adapters. */ |
|
| 895 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php'; |
|
| 896 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php'; |
|
| 897 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php'; |
|
| 898 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php'; |
|
| 899 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-analysis-adapter.php'; |
|
| 900 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-rebuild-adapter.php'; |
|
| 901 | - |
|
| 902 | - /** Async Tasks. */ |
|
| 903 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-async-task.php'; |
|
| 904 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php'; |
|
| 905 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-batch-analysis-request-async-task.php'; |
|
| 906 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-batch-analysis-complete-async-task.php'; |
|
| 907 | - |
|
| 908 | - /** Async Tasks. */ |
|
| 909 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-service.php'; |
|
| 910 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php'; |
|
| 911 | - |
|
| 912 | - /** |
|
| 913 | - * The class responsible for defining all actions that occur in the admin area. |
|
| 914 | - */ |
|
| 915 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 916 | - |
|
| 917 | - /** |
|
| 918 | - * The class to customize the entity list admin page. |
|
| 919 | - */ |
|
| 920 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 921 | - |
|
| 922 | - /** |
|
| 923 | - * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 924 | - */ |
|
| 925 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 926 | - |
|
| 927 | - /** |
|
| 928 | - * The Notice service. |
|
| 929 | - */ |
|
| 930 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 931 | - |
|
| 932 | - /** |
|
| 933 | - * The PrimaShop adapter. |
|
| 934 | - */ |
|
| 935 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 936 | - |
|
| 937 | - /** |
|
| 938 | - * The WordLift Dashboard service. |
|
| 939 | - */ |
|
| 940 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 941 | - |
|
| 942 | - /** |
|
| 943 | - * The admin 'Install wizard' page. |
|
| 944 | - */ |
|
| 945 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php'; |
|
| 946 | - |
|
| 947 | - /** |
|
| 948 | - * The WordLift entity type list admin page controller. |
|
| 949 | - */ |
|
| 950 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 951 | - |
|
| 952 | - /** |
|
| 953 | - * The WordLift entity type settings admin page controller. |
|
| 954 | - */ |
|
| 955 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php'; |
|
| 956 | - |
|
| 957 | - /** |
|
| 958 | - * The admin 'Download Your Data' page. |
|
| 959 | - */ |
|
| 960 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 961 | - |
|
| 962 | - /** |
|
| 963 | - * The admin 'WordLift Settings' page. |
|
| 964 | - */ |
|
| 965 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/intf-wordlift-admin-element.php'; |
|
| 966 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-element.php'; |
|
| 967 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-radio-element.php'; |
|
| 968 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-select2-element.php'; |
|
| 969 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-language-select-element.php'; |
|
| 970 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-tabs-element.php'; |
|
| 971 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-author-element.php'; |
|
| 972 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-publisher-element.php'; |
|
| 973 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php'; |
|
| 974 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php'; |
|
| 975 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-batch-analysis-page.php'; |
|
| 976 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 977 | - |
|
| 978 | - /** Admin Pages */ |
|
| 979 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 980 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php'; |
|
| 981 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php'; |
|
| 982 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php'; |
|
| 983 | - |
|
| 984 | - /** |
|
| 985 | - * The class responsible for defining all actions that occur in the public-facing |
|
| 986 | - * side of the site. |
|
| 987 | - */ |
|
| 988 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 989 | - |
|
| 990 | - /** |
|
| 991 | - * The shortcode abstract class. |
|
| 992 | - */ |
|
| 993 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 994 | - |
|
| 995 | - /** |
|
| 996 | - * The Timeline shortcode. |
|
| 997 | - */ |
|
| 998 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 999 | - |
|
| 1000 | - /** |
|
| 1001 | - * The Navigator shortcode. |
|
| 1002 | - */ |
|
| 1003 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 1004 | - |
|
| 1005 | - /** |
|
| 1006 | - * The chord shortcode. |
|
| 1007 | - */ |
|
| 1008 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 1009 | - |
|
| 1010 | - /** |
|
| 1011 | - * The geomap shortcode. |
|
| 1012 | - */ |
|
| 1013 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 1014 | - |
|
| 1015 | - /** |
|
| 1016 | - * The entity cloud shortcode. |
|
| 1017 | - */ |
|
| 1018 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 1019 | - |
|
| 1020 | - /** |
|
| 1021 | - * The ShareThis service. |
|
| 1022 | - */ |
|
| 1023 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 1024 | - |
|
| 1025 | - /** |
|
| 1026 | - * The SEO service. |
|
| 1027 | - */ |
|
| 1028 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php'; |
|
| 1029 | - |
|
| 1030 | - /** |
|
| 1031 | - * The AMP service. |
|
| 1032 | - */ |
|
| 1033 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php'; |
|
| 1034 | - |
|
| 1035 | - /** Widgets */ |
|
| 1036 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php'; |
|
| 1037 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 1038 | - |
|
| 1039 | - $this->loader = new Wordlift_Loader(); |
|
| 1040 | - |
|
| 1041 | - // Instantiate a global logger. |
|
| 1042 | - global $wl_logger; |
|
| 1043 | - $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 1044 | - |
|
| 1045 | - // Load the `wl-api` end-point. |
|
| 1046 | - new Wordlift_Http_Api(); |
|
| 1047 | - |
|
| 1048 | - /** Services. */ |
|
| 1049 | - // Create the configuration service. |
|
| 1050 | - $this->configuration_service = new Wordlift_Configuration_Service(); |
|
| 1051 | - |
|
| 1052 | - // Create an entity type service instance. It'll be later bound to the init action. |
|
| 1053 | - $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() ); |
|
| 1054 | - |
|
| 1055 | - // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 1056 | - $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() ); |
|
| 1057 | - |
|
| 1058 | - // Create an instance of the UI service. |
|
| 1059 | - $this->ui_service = new Wordlift_UI_Service(); |
|
| 1060 | - |
|
| 1061 | - // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 1062 | - $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 1063 | - |
|
| 1064 | - $this->sparql_service = new Wordlift_Sparql_Service(); |
|
| 1065 | - $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 1066 | - $this->notice_service = new Wordlift_Notice_Service(); |
|
| 1067 | - $this->relation_service = new Wordlift_Relation_Service(); |
|
| 1068 | - $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service ); |
|
| 1069 | - $this->user_service = new Wordlift_User_Service(); |
|
| 1070 | - |
|
| 1071 | - // Instantiate the JSON-LD service. |
|
| 1072 | - $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 848 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 849 | + |
|
| 850 | + /** |
|
| 851 | + * Load the JSON-LD service to publish entities using JSON-LD.s |
|
| 852 | + * |
|
| 853 | + * @since 3.8.0 |
|
| 854 | + */ |
|
| 855 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 856 | + |
|
| 857 | + // The Publisher Service and the AJAX adapter. |
|
| 858 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php'; |
|
| 859 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 860 | + |
|
| 861 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php'; |
|
| 862 | + |
|
| 863 | + /** |
|
| 864 | + * Load the WordLift key validation service. |
|
| 865 | + */ |
|
| 866 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php'; |
|
| 867 | + |
|
| 868 | + // Load the `Wordlift_Category_Taxonomy_Service` class definition. |
|
| 869 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 870 | + |
|
| 871 | + // Load the `Wordlift_Entity_Page_Service` class definition. |
|
| 872 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php'; |
|
| 873 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-analysis-service.php'; |
|
| 874 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-rebuild-service.php'; |
|
| 875 | + |
|
| 876 | + /** Linked Data. */ |
|
| 877 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php'; |
|
| 878 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php'; |
|
| 879 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php'; |
|
| 880 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php'; |
|
| 881 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php'; |
|
| 882 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php'; |
|
| 883 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php'; |
|
| 884 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php'; |
|
| 885 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php'; |
|
| 886 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php'; |
|
| 887 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php'; |
|
| 888 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition.php'; |
|
| 889 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php'; |
|
| 890 | + |
|
| 891 | + /** Services. */ |
|
| 892 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php'; |
|
| 893 | + |
|
| 894 | + /** Adapters. */ |
|
| 895 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php'; |
|
| 896 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php'; |
|
| 897 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php'; |
|
| 898 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php'; |
|
| 899 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-analysis-adapter.php'; |
|
| 900 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-rebuild-adapter.php'; |
|
| 901 | + |
|
| 902 | + /** Async Tasks. */ |
|
| 903 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-async-task.php'; |
|
| 904 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php'; |
|
| 905 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-batch-analysis-request-async-task.php'; |
|
| 906 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-batch-analysis-complete-async-task.php'; |
|
| 907 | + |
|
| 908 | + /** Async Tasks. */ |
|
| 909 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-service.php'; |
|
| 910 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php'; |
|
| 911 | + |
|
| 912 | + /** |
|
| 913 | + * The class responsible for defining all actions that occur in the admin area. |
|
| 914 | + */ |
|
| 915 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 916 | + |
|
| 917 | + /** |
|
| 918 | + * The class to customize the entity list admin page. |
|
| 919 | + */ |
|
| 920 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 921 | + |
|
| 922 | + /** |
|
| 923 | + * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 924 | + */ |
|
| 925 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 926 | + |
|
| 927 | + /** |
|
| 928 | + * The Notice service. |
|
| 929 | + */ |
|
| 930 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 931 | + |
|
| 932 | + /** |
|
| 933 | + * The PrimaShop adapter. |
|
| 934 | + */ |
|
| 935 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 936 | + |
|
| 937 | + /** |
|
| 938 | + * The WordLift Dashboard service. |
|
| 939 | + */ |
|
| 940 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 941 | + |
|
| 942 | + /** |
|
| 943 | + * The admin 'Install wizard' page. |
|
| 944 | + */ |
|
| 945 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php'; |
|
| 946 | + |
|
| 947 | + /** |
|
| 948 | + * The WordLift entity type list admin page controller. |
|
| 949 | + */ |
|
| 950 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 951 | + |
|
| 952 | + /** |
|
| 953 | + * The WordLift entity type settings admin page controller. |
|
| 954 | + */ |
|
| 955 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php'; |
|
| 956 | + |
|
| 957 | + /** |
|
| 958 | + * The admin 'Download Your Data' page. |
|
| 959 | + */ |
|
| 960 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 961 | + |
|
| 962 | + /** |
|
| 963 | + * The admin 'WordLift Settings' page. |
|
| 964 | + */ |
|
| 965 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/intf-wordlift-admin-element.php'; |
|
| 966 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-element.php'; |
|
| 967 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-radio-element.php'; |
|
| 968 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-select2-element.php'; |
|
| 969 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-language-select-element.php'; |
|
| 970 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-tabs-element.php'; |
|
| 971 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-author-element.php'; |
|
| 972 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-publisher-element.php'; |
|
| 973 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php'; |
|
| 974 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php'; |
|
| 975 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-batch-analysis-page.php'; |
|
| 976 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 977 | + |
|
| 978 | + /** Admin Pages */ |
|
| 979 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 980 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php'; |
|
| 981 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php'; |
|
| 982 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php'; |
|
| 983 | + |
|
| 984 | + /** |
|
| 985 | + * The class responsible for defining all actions that occur in the public-facing |
|
| 986 | + * side of the site. |
|
| 987 | + */ |
|
| 988 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 989 | + |
|
| 990 | + /** |
|
| 991 | + * The shortcode abstract class. |
|
| 992 | + */ |
|
| 993 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 994 | + |
|
| 995 | + /** |
|
| 996 | + * The Timeline shortcode. |
|
| 997 | + */ |
|
| 998 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 999 | + |
|
| 1000 | + /** |
|
| 1001 | + * The Navigator shortcode. |
|
| 1002 | + */ |
|
| 1003 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 1004 | + |
|
| 1005 | + /** |
|
| 1006 | + * The chord shortcode. |
|
| 1007 | + */ |
|
| 1008 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 1009 | + |
|
| 1010 | + /** |
|
| 1011 | + * The geomap shortcode. |
|
| 1012 | + */ |
|
| 1013 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 1014 | + |
|
| 1015 | + /** |
|
| 1016 | + * The entity cloud shortcode. |
|
| 1017 | + */ |
|
| 1018 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 1019 | + |
|
| 1020 | + /** |
|
| 1021 | + * The ShareThis service. |
|
| 1022 | + */ |
|
| 1023 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 1024 | + |
|
| 1025 | + /** |
|
| 1026 | + * The SEO service. |
|
| 1027 | + */ |
|
| 1028 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php'; |
|
| 1029 | + |
|
| 1030 | + /** |
|
| 1031 | + * The AMP service. |
|
| 1032 | + */ |
|
| 1033 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php'; |
|
| 1034 | + |
|
| 1035 | + /** Widgets */ |
|
| 1036 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php'; |
|
| 1037 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 1038 | + |
|
| 1039 | + $this->loader = new Wordlift_Loader(); |
|
| 1040 | + |
|
| 1041 | + // Instantiate a global logger. |
|
| 1042 | + global $wl_logger; |
|
| 1043 | + $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 1044 | + |
|
| 1045 | + // Load the `wl-api` end-point. |
|
| 1046 | + new Wordlift_Http_Api(); |
|
| 1047 | + |
|
| 1048 | + /** Services. */ |
|
| 1049 | + // Create the configuration service. |
|
| 1050 | + $this->configuration_service = new Wordlift_Configuration_Service(); |
|
| 1051 | + |
|
| 1052 | + // Create an entity type service instance. It'll be later bound to the init action. |
|
| 1053 | + $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() ); |
|
| 1054 | + |
|
| 1055 | + // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 1056 | + $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() ); |
|
| 1057 | + |
|
| 1058 | + // Create an instance of the UI service. |
|
| 1059 | + $this->ui_service = new Wordlift_UI_Service(); |
|
| 1060 | + |
|
| 1061 | + // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 1062 | + $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 1063 | + |
|
| 1064 | + $this->sparql_service = new Wordlift_Sparql_Service(); |
|
| 1065 | + $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 1066 | + $this->notice_service = new Wordlift_Notice_Service(); |
|
| 1067 | + $this->relation_service = new Wordlift_Relation_Service(); |
|
| 1068 | + $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service ); |
|
| 1069 | + $this->user_service = new Wordlift_User_Service(); |
|
| 1070 | + |
|
| 1071 | + // Instantiate the JSON-LD service. |
|
| 1072 | + $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 1073 | 1073 | |
| 1074 | - /** Linked Data. */ |
|
| 1075 | - $this->storage_factory = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter ); |
|
| 1076 | - $this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service ); |
|
| 1074 | + /** Linked Data. */ |
|
| 1075 | + $this->storage_factory = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter ); |
|
| 1076 | + $this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service ); |
|
| 1077 | 1077 | |
| 1078 | - $this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service ); |
|
| 1078 | + $this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service ); |
|
| 1079 | 1079 | |
| 1080 | - // Create a new instance of the Redirect service. |
|
| 1081 | - $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service ); |
|
| 1082 | - $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service ); |
|
| 1083 | - $this->linked_data_service = new Wordlift_Linked_Data_Service( $this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service ); |
|
| 1080 | + // Create a new instance of the Redirect service. |
|
| 1081 | + $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service ); |
|
| 1082 | + $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service ); |
|
| 1083 | + $this->linked_data_service = new Wordlift_Linked_Data_Service( $this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service ); |
|
| 1084 | 1084 | |
| 1085 | - // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 1086 | - $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service ); |
|
| 1085 | + // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 1086 | + $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service ); |
|
| 1087 | 1087 | |
| 1088 | - $this->batch_analysis_service = new Wordlift_Batch_Analysis_Service( $this, $this->configuration_service ); |
|
| 1088 | + $this->batch_analysis_service = new Wordlift_Batch_Analysis_Service( $this, $this->configuration_service ); |
|
| 1089 | 1089 | |
| 1090 | - $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 1090 | + $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 1091 | 1091 | |
| 1092 | - $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 1092 | + $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 1093 | 1093 | |
| 1094 | - // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 1095 | - $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 1094 | + // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 1095 | + $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 1096 | 1096 | |
| 1097 | - // Create an instance of the PrimaShop adapter. |
|
| 1098 | - $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 1097 | + // Create an instance of the PrimaShop adapter. |
|
| 1098 | + $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 1099 | 1099 | |
| 1100 | - // Create an import service instance to hook later to WP's import function. |
|
| 1101 | - $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() ); |
|
| 1100 | + // Create an import service instance to hook later to WP's import function. |
|
| 1101 | + $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() ); |
|
| 1102 | 1102 | |
| 1103 | - $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 1103 | + $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 1104 | 1104 | |
| 1105 | - // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
|
| 1106 | - $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service ); |
|
| 1105 | + // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
|
| 1106 | + $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service ); |
|
| 1107 | 1107 | |
| 1108 | - // Create the entity rating service. |
|
| 1109 | - $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service ); |
|
| 1108 | + // Create the entity rating service. |
|
| 1109 | + $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service ); |
|
| 1110 | 1110 | |
| 1111 | - // Create entity list customization (wp-admin/edit.php). |
|
| 1112 | - $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service ); |
|
| 1111 | + // Create entity list customization (wp-admin/edit.php). |
|
| 1112 | + $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service ); |
|
| 1113 | 1113 | |
| 1114 | - // Create a new instance of the Redirect service. |
|
| 1115 | - $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service ); |
|
| 1114 | + // Create a new instance of the Redirect service. |
|
| 1115 | + $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service ); |
|
| 1116 | 1116 | |
| 1117 | - // Create an instance of the Publisher Service and the AJAX Adapter. |
|
| 1118 | - $publisher_service = new Wordlift_Publisher_Service(); |
|
| 1119 | - $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 1120 | - $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 1117 | + // Create an instance of the Publisher Service and the AJAX Adapter. |
|
| 1118 | + $publisher_service = new Wordlift_Publisher_Service(); |
|
| 1119 | + $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 1120 | + $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 1121 | 1121 | |
| 1122 | - $attachment_service = new Wordlift_Attachment_Service(); |
|
| 1122 | + $attachment_service = new Wordlift_Attachment_Service(); |
|
| 1123 | 1123 | |
| 1124 | - // Instantiate the JSON-LD service. |
|
| 1125 | - $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 1126 | - $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 ); |
|
| 1127 | - $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, $this->entity_post_to_jsonld_converter ); |
|
| 1128 | - $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 ); |
|
| 1129 | - $this->jsonld_website_converter = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service, $this->entity_post_to_jsonld_converter ); |
|
| 1130 | - $this->file_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'converter/' ); |
|
| 1131 | - $this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $this->postid_to_jsonld_converter, $this->file_cache_service ); |
|
| 1132 | - $this->jsonld_service = new Wordlift_Jsonld_Service( $this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter ); |
|
| 1124 | + // Instantiate the JSON-LD service. |
|
| 1125 | + $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 1126 | + $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 ); |
|
| 1127 | + $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, $this->entity_post_to_jsonld_converter ); |
|
| 1128 | + $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 ); |
|
| 1129 | + $this->jsonld_website_converter = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service, $this->entity_post_to_jsonld_converter ); |
|
| 1130 | + $this->file_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'converter/' ); |
|
| 1131 | + $this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $this->postid_to_jsonld_converter, $this->file_cache_service ); |
|
| 1132 | + $this->jsonld_service = new Wordlift_Jsonld_Service( $this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter ); |
|
| 1133 | 1133 | |
| 1134 | 1134 | |
| 1135 | - $this->key_validation_service = new Wordlift_Key_Validation_Service( $this->configuration_service ); |
|
| 1136 | - $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service ); |
|
| 1137 | - $this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service ); |
|
| 1138 | - $this->sample_data_service = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service ); |
|
| 1139 | - $this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service ); |
|
| 1135 | + $this->key_validation_service = new Wordlift_Key_Validation_Service( $this->configuration_service ); |
|
| 1136 | + $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service ); |
|
| 1137 | + $this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service ); |
|
| 1138 | + $this->sample_data_service = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service ); |
|
| 1139 | + $this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service ); |
|
| 1140 | 1140 | |
| 1141 | - // Initialize the shortcodes. |
|
| 1142 | - new Wordlift_Navigator_Shortcode(); |
|
| 1143 | - new Wordlift_Chord_Shortcode(); |
|
| 1144 | - new Wordlift_Geomap_Shortcode(); |
|
| 1145 | - new Wordlift_Timeline_Shortcode(); |
|
| 1146 | - new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service ); |
|
| 1141 | + // Initialize the shortcodes. |
|
| 1142 | + new Wordlift_Navigator_Shortcode(); |
|
| 1143 | + new Wordlift_Chord_Shortcode(); |
|
| 1144 | + new Wordlift_Geomap_Shortcode(); |
|
| 1145 | + new Wordlift_Timeline_Shortcode(); |
|
| 1146 | + new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service ); |
|
| 1147 | 1147 | |
| 1148 | - // Initialize the SEO service. |
|
| 1149 | - new Wordlift_Seo_Service(); |
|
| 1148 | + // Initialize the SEO service. |
|
| 1149 | + new Wordlift_Seo_Service(); |
|
| 1150 | 1150 | |
| 1151 | - // Initialize the AMP service. |
|
| 1152 | - new Wordlift_AMP_Service(); |
|
| 1151 | + // Initialize the AMP service. |
|
| 1152 | + new Wordlift_AMP_Service(); |
|
| 1153 | 1153 | |
| 1154 | - /** Services. */ |
|
| 1155 | - $this->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service(); |
|
| 1154 | + /** Services. */ |
|
| 1155 | + $this->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service(); |
|
| 1156 | 1156 | |
| 1157 | - /** Adapters. */ |
|
| 1158 | - $this->entity_type_adapter = new Wordlift_Entity_Type_Adapter( $this->entity_type_service ); |
|
| 1159 | - $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $publisher_service ); |
|
| 1160 | - $this->tinymce_adapter = new Wordlift_Tinymce_Adapter( $this ); |
|
| 1161 | - $this->batch_analysis_adapter = new Wordlift_Batch_Analysis_Adapter( $this->batch_analysis_service ); |
|
| 1162 | - $this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service ); |
|
| 1157 | + /** Adapters. */ |
|
| 1158 | + $this->entity_type_adapter = new Wordlift_Entity_Type_Adapter( $this->entity_type_service ); |
|
| 1159 | + $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $publisher_service ); |
|
| 1160 | + $this->tinymce_adapter = new Wordlift_Tinymce_Adapter( $this ); |
|
| 1161 | + $this->batch_analysis_adapter = new Wordlift_Batch_Analysis_Adapter( $this->batch_analysis_service ); |
|
| 1162 | + $this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service ); |
|
| 1163 | 1163 | |
| 1164 | - /** Async Tasks. */ |
|
| 1165 | - new Wordlift_Sparql_Query_Async_Task(); |
|
| 1166 | - new Wordlift_Batch_Analysis_Request_Async_Task(); |
|
| 1167 | - new Wordlift_Batch_Analysis_Complete_Async_Task(); |
|
| 1164 | + /** Async Tasks. */ |
|
| 1165 | + new Wordlift_Sparql_Query_Async_Task(); |
|
| 1166 | + new Wordlift_Batch_Analysis_Request_Async_Task(); |
|
| 1167 | + new Wordlift_Batch_Analysis_Complete_Async_Task(); |
|
| 1168 | 1168 | |
| 1169 | - /** WL Autocomplete. */ |
|
| 1170 | - $this->autocomplete_service = new Wordlift_Autocomplete_Service( $this->configuration_service ); |
|
| 1171 | - $this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $this->autocomplete_service ); |
|
| 1169 | + /** WL Autocomplete. */ |
|
| 1170 | + $this->autocomplete_service = new Wordlift_Autocomplete_Service( $this->configuration_service ); |
|
| 1171 | + $this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $this->autocomplete_service ); |
|
| 1172 | 1172 | |
| 1173 | - /** WordPress Admin UI. */ |
|
| 1173 | + /** WordPress Admin UI. */ |
|
| 1174 | 1174 | |
| 1175 | - // UI elements. |
|
| 1176 | - $this->input_element = new Wordlift_Admin_Input_Element(); |
|
| 1177 | - $this->radio_input_element = new Wordlift_Admin_Radio_Input_Element(); |
|
| 1178 | - $this->select2_element = new Wordlift_Admin_Select2_Element(); |
|
| 1179 | - $this->language_select_element = new Wordlift_Admin_Language_Select_Element(); |
|
| 1180 | - $tabs_element = new Wordlift_Admin_Tabs_Element(); |
|
| 1181 | - $this->publisher_element = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $publisher_service, $tabs_element, $this->select2_element ); |
|
| 1182 | - $this->author_element = new Wordlift_Admin_Author_Element( $publisher_service, $this->select2_element ); |
|
| 1175 | + // UI elements. |
|
| 1176 | + $this->input_element = new Wordlift_Admin_Input_Element(); |
|
| 1177 | + $this->radio_input_element = new Wordlift_Admin_Radio_Input_Element(); |
|
| 1178 | + $this->select2_element = new Wordlift_Admin_Select2_Element(); |
|
| 1179 | + $this->language_select_element = new Wordlift_Admin_Language_Select_Element(); |
|
| 1180 | + $tabs_element = new Wordlift_Admin_Tabs_Element(); |
|
| 1181 | + $this->publisher_element = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $publisher_service, $tabs_element, $this->select2_element ); |
|
| 1182 | + $this->author_element = new Wordlift_Admin_Author_Element( $publisher_service, $this->select2_element ); |
|
| 1183 | 1183 | |
| 1184 | - $this->settings_page = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->publisher_element, $this->radio_input_element ); |
|
| 1185 | - $this->batch_analysis_page = new Wordlift_Batch_Analysis_Page( $this->batch_analysis_service ); |
|
| 1186 | - $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page ); |
|
| 1184 | + $this->settings_page = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->publisher_element, $this->radio_input_element ); |
|
| 1185 | + $this->batch_analysis_page = new Wordlift_Batch_Analysis_Page( $this->batch_analysis_service ); |
|
| 1186 | + $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page ); |
|
| 1187 | 1187 | |
| 1188 | - // Pages. |
|
| 1189 | - new Wordlift_Admin_Post_Edit_Page( $this ); |
|
| 1190 | - new Wordlift_Entity_Type_Admin_Service(); |
|
| 1188 | + // Pages. |
|
| 1189 | + new Wordlift_Admin_Post_Edit_Page( $this ); |
|
| 1190 | + new Wordlift_Entity_Type_Admin_Service(); |
|
| 1191 | 1191 | |
| 1192 | - // create an instance of the entity type list admin page controller. |
|
| 1193 | - $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page(); |
|
| 1194 | - |
|
| 1195 | - // create an instance of the entity type etting admin page controller. |
|
| 1196 | - $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings(); |
|
| 1197 | - |
|
| 1198 | - /** Widgets */ |
|
| 1199 | - $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget(); |
|
| 1200 | - |
|
| 1201 | - /* WordPress Admin. */ |
|
| 1202 | - $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 1203 | - $this->status_page = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service ); |
|
| 1204 | - |
|
| 1205 | - // Create an instance of the install wizard. |
|
| 1206 | - $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service ); |
|
| 1207 | - |
|
| 1208 | - $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service ); |
|
| 1209 | - |
|
| 1210 | - // User Profile. |
|
| 1211 | - new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service ); |
|
| 1212 | - |
|
| 1213 | - $this->entity_page_service = new Wordlift_Entity_Page_Service(); |
|
| 1214 | - |
|
| 1215 | - // Load the debug service if WP is in debug mode. |
|
| 1216 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 1217 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 1218 | - new Wordlift_Debug_Service( $this->entity_service, $uri_service ); |
|
| 1219 | - } |
|
| 1220 | - |
|
| 1221 | - } |
|
| 1222 | - |
|
| 1223 | - /** |
|
| 1224 | - * Define the locale for this plugin for internationalization. |
|
| 1225 | - * |
|
| 1226 | - * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 1227 | - * with WordPress. |
|
| 1228 | - * |
|
| 1229 | - * @since 1.0.0 |
|
| 1230 | - * @access private |
|
| 1231 | - */ |
|
| 1232 | - private function set_locale() { |
|
| 1233 | - |
|
| 1234 | - $plugin_i18n = new Wordlift_i18n(); |
|
| 1235 | - $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 1236 | - |
|
| 1237 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 1238 | - |
|
| 1239 | - } |
|
| 1240 | - |
|
| 1241 | - /** |
|
| 1242 | - * Register all of the hooks related to the admin area functionality |
|
| 1243 | - * of the plugin. |
|
| 1244 | - * |
|
| 1245 | - * @since 1.0.0 |
|
| 1246 | - * @access private |
|
| 1247 | - */ |
|
| 1248 | - private function define_admin_hooks() { |
|
| 1249 | - |
|
| 1250 | - $plugin_admin = new Wordlift_Admin( |
|
| 1251 | - $this->get_plugin_name(), |
|
| 1252 | - $this->get_version(), |
|
| 1253 | - $this->configuration_service, |
|
| 1254 | - $this->notice_service, |
|
| 1255 | - $this->user_service |
|
| 1256 | - ); |
|
| 1257 | - |
|
| 1258 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 1259 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
| 1260 | - |
|
| 1261 | - // Hook the init action to the Topic Taxonomy service. |
|
| 1262 | - $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 1263 | - |
|
| 1264 | - // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 1265 | - $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 1266 | - |
|
| 1267 | - // Hook the added_post_meta action to the Thumbnail service. |
|
| 1268 | - $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1269 | - |
|
| 1270 | - // Hook the updated_post_meta action to the Thumbnail service. |
|
| 1271 | - $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1272 | - |
|
| 1273 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1274 | - $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1275 | - |
|
| 1276 | - // Register custom allowed redirect hosts. |
|
| 1277 | - $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 1278 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1279 | - $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 1280 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1281 | - $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 1282 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1283 | - $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 1284 | - |
|
| 1285 | - // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 1286 | - // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 1287 | - $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 1288 | - $this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 ); |
|
| 1289 | - |
|
| 1290 | - $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 1291 | - $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' ); |
|
| 1292 | - |
|
| 1293 | - // Entity listing customization (wp-admin/edit.php) |
|
| 1294 | - // Add custom columns. |
|
| 1295 | - $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 1296 | - // no explicit entity as it prevents handling of other post types. |
|
| 1297 | - $this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 1298 | - // Add 4W selection. |
|
| 1299 | - $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 1300 | - $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 1301 | - $this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' ); |
|
| 1302 | - $this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' ); |
|
| 1303 | - $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 1304 | - |
|
| 1305 | - // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 1306 | - // entities. |
|
| 1307 | - $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 1308 | - |
|
| 1309 | - // Filter imported post meta. |
|
| 1310 | - $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 1311 | - |
|
| 1312 | - // Notify the import service when an import starts and ends. |
|
| 1313 | - $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 1314 | - $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 1315 | - |
|
| 1316 | - // Hook the AJAX wl_rebuild action to the Rebuild Service. |
|
| 1317 | - $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 1318 | - |
|
| 1319 | - // Hook the menu to the Download Your Data page. |
|
| 1320 | - $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 ); |
|
| 1321 | - $this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 ); |
|
| 1322 | - $this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 ); |
|
| 1323 | - |
|
| 1324 | - // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
|
| 1325 | - $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 1326 | - |
|
| 1327 | - // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1328 | - $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1329 | - |
|
| 1330 | - // Hook the AJAX wl_validate_key action to the Key Validation service. |
|
| 1331 | - $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' ); |
|
| 1332 | - |
|
| 1333 | - // Hook the `admin_init` function to the Admin Setup. |
|
| 1334 | - $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' ); |
|
| 1335 | - |
|
| 1336 | - // Hook the admin_init to the settings page. |
|
| 1337 | - $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' ); |
|
| 1338 | - |
|
| 1339 | - // Hook the menu creation on the general wordlift menu creation. |
|
| 1340 | - $this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 ); |
|
| 1341 | - if ( defined( 'WORDLIFT_BATCH' ) && WORDLIFT_BATCH ) { |
|
| 1342 | - // Add the functionality only if a flag is set in wp-config.php . |
|
| 1343 | - $this->loader->add_action( 'wl_admin_menu', $this->batch_analysis_page, 'admin_menu', 10, 2 ); |
|
| 1344 | - } |
|
| 1345 | - |
|
| 1346 | - // Hook key update. |
|
| 1347 | - $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 ); |
|
| 1348 | - $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 ); |
|
| 1349 | - |
|
| 1350 | - // Add additional action links to the WordLift plugin in the plugins page. |
|
| 1351 | - $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1352 | - |
|
| 1353 | - // Hook the AJAX `wl_publisher` action name. |
|
| 1354 | - $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' ); |
|
| 1355 | - |
|
| 1356 | - // Hook row actions for the entity type list admin. |
|
| 1357 | - $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 ); |
|
| 1358 | - |
|
| 1359 | - /** Ajax actions. */ |
|
| 1360 | - $this->loader->add_action( 'wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export' ); |
|
| 1361 | - |
|
| 1362 | - // Hook capabilities manipulation to allow access to entity type admin |
|
| 1363 | - // page on WordPress versions before 4.7. |
|
| 1364 | - global $wp_version; |
|
| 1365 | - if ( version_compare( $wp_version, '4.7', '<' ) ) { |
|
| 1366 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 ); |
|
| 1367 | - } |
|
| 1368 | - |
|
| 1369 | - $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1370 | - |
|
| 1371 | - /** Adapters. */ |
|
| 1372 | - $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 ); |
|
| 1373 | - $this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit_auto_selected_posts', $this->batch_analysis_adapter, 'submit_auto_selected_posts', 10 ); |
|
| 1374 | - $this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit_all_posts', $this->batch_analysis_adapter, 'submit_all_posts', 10 ); |
|
| 1375 | - $this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit', $this->batch_analysis_adapter, 'submit', 10 ); |
|
| 1376 | - $this->loader->add_action( 'wp_ajax_wl_batch_analysis_cancel', $this->batch_analysis_adapter, 'cancel', 10 ); |
|
| 1377 | - $this->loader->add_action( 'wp_ajax_wl_batch_analysis_clear_warning', $this->batch_analysis_adapter, 'clear_warning', 10 ); |
|
| 1378 | - $this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all', 10 ); |
|
| 1379 | - |
|
| 1380 | - $this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' ); |
|
| 1381 | - $this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' ); |
|
| 1382 | - |
|
| 1383 | - // Handle the autocomplete request. |
|
| 1384 | - add_action( 'wp_ajax_wl_autocomplete', array( |
|
| 1385 | - $this->autocomplete_adapter, |
|
| 1386 | - 'wl_autocomplete', |
|
| 1387 | - ) ); |
|
| 1388 | - add_action( 'wp_ajax_nopriv_wl_autocomplete', array( |
|
| 1389 | - $this->autocomplete_adapter, |
|
| 1390 | - 'wl_autocomplete', |
|
| 1391 | - ) ); |
|
| 1392 | - |
|
| 1393 | - // Hooks to restrict multisite super admin from manipulating entity types. |
|
| 1394 | - if ( is_multisite() ) { |
|
| 1395 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 ); |
|
| 1396 | - } |
|
| 1397 | - |
|
| 1398 | - } |
|
| 1399 | - |
|
| 1400 | - /** |
|
| 1401 | - * Register all of the hooks related to the public-facing functionality |
|
| 1402 | - * of the plugin. |
|
| 1403 | - * |
|
| 1404 | - * @since 1.0.0 |
|
| 1405 | - * @access private |
|
| 1406 | - */ |
|
| 1407 | - private function define_public_hooks() { |
|
| 1192 | + // create an instance of the entity type list admin page controller. |
|
| 1193 | + $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page(); |
|
| 1194 | + |
|
| 1195 | + // create an instance of the entity type etting admin page controller. |
|
| 1196 | + $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings(); |
|
| 1197 | + |
|
| 1198 | + /** Widgets */ |
|
| 1199 | + $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget(); |
|
| 1200 | + |
|
| 1201 | + /* WordPress Admin. */ |
|
| 1202 | + $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 1203 | + $this->status_page = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service ); |
|
| 1204 | + |
|
| 1205 | + // Create an instance of the install wizard. |
|
| 1206 | + $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service ); |
|
| 1207 | + |
|
| 1208 | + $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service ); |
|
| 1209 | + |
|
| 1210 | + // User Profile. |
|
| 1211 | + new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service ); |
|
| 1212 | + |
|
| 1213 | + $this->entity_page_service = new Wordlift_Entity_Page_Service(); |
|
| 1214 | + |
|
| 1215 | + // Load the debug service if WP is in debug mode. |
|
| 1216 | + if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 1217 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 1218 | + new Wordlift_Debug_Service( $this->entity_service, $uri_service ); |
|
| 1219 | + } |
|
| 1220 | + |
|
| 1221 | + } |
|
| 1222 | + |
|
| 1223 | + /** |
|
| 1224 | + * Define the locale for this plugin for internationalization. |
|
| 1225 | + * |
|
| 1226 | + * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 1227 | + * with WordPress. |
|
| 1228 | + * |
|
| 1229 | + * @since 1.0.0 |
|
| 1230 | + * @access private |
|
| 1231 | + */ |
|
| 1232 | + private function set_locale() { |
|
| 1233 | + |
|
| 1234 | + $plugin_i18n = new Wordlift_i18n(); |
|
| 1235 | + $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 1236 | + |
|
| 1237 | + $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 1238 | + |
|
| 1239 | + } |
|
| 1240 | + |
|
| 1241 | + /** |
|
| 1242 | + * Register all of the hooks related to the admin area functionality |
|
| 1243 | + * of the plugin. |
|
| 1244 | + * |
|
| 1245 | + * @since 1.0.0 |
|
| 1246 | + * @access private |
|
| 1247 | + */ |
|
| 1248 | + private function define_admin_hooks() { |
|
| 1249 | + |
|
| 1250 | + $plugin_admin = new Wordlift_Admin( |
|
| 1251 | + $this->get_plugin_name(), |
|
| 1252 | + $this->get_version(), |
|
| 1253 | + $this->configuration_service, |
|
| 1254 | + $this->notice_service, |
|
| 1255 | + $this->user_service |
|
| 1256 | + ); |
|
| 1257 | + |
|
| 1258 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 1259 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
| 1260 | + |
|
| 1261 | + // Hook the init action to the Topic Taxonomy service. |
|
| 1262 | + $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 1263 | + |
|
| 1264 | + // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 1265 | + $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 1266 | + |
|
| 1267 | + // Hook the added_post_meta action to the Thumbnail service. |
|
| 1268 | + $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1269 | + |
|
| 1270 | + // Hook the updated_post_meta action to the Thumbnail service. |
|
| 1271 | + $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1272 | + |
|
| 1273 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1274 | + $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1275 | + |
|
| 1276 | + // Register custom allowed redirect hosts. |
|
| 1277 | + $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 1278 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1279 | + $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 1280 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1281 | + $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 1282 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1283 | + $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 1284 | + |
|
| 1285 | + // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 1286 | + // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 1287 | + $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 1288 | + $this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 ); |
|
| 1289 | + |
|
| 1290 | + $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 1291 | + $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' ); |
|
| 1292 | + |
|
| 1293 | + // Entity listing customization (wp-admin/edit.php) |
|
| 1294 | + // Add custom columns. |
|
| 1295 | + $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 1296 | + // no explicit entity as it prevents handling of other post types. |
|
| 1297 | + $this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 1298 | + // Add 4W selection. |
|
| 1299 | + $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 1300 | + $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 1301 | + $this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' ); |
|
| 1302 | + $this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' ); |
|
| 1303 | + $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 1304 | + |
|
| 1305 | + // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 1306 | + // entities. |
|
| 1307 | + $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 1308 | + |
|
| 1309 | + // Filter imported post meta. |
|
| 1310 | + $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 1311 | + |
|
| 1312 | + // Notify the import service when an import starts and ends. |
|
| 1313 | + $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 1314 | + $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 1315 | + |
|
| 1316 | + // Hook the AJAX wl_rebuild action to the Rebuild Service. |
|
| 1317 | + $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 1318 | + |
|
| 1319 | + // Hook the menu to the Download Your Data page. |
|
| 1320 | + $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 ); |
|
| 1321 | + $this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 ); |
|
| 1322 | + $this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 ); |
|
| 1323 | + |
|
| 1324 | + // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
|
| 1325 | + $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 1326 | + |
|
| 1327 | + // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1328 | + $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1329 | + |
|
| 1330 | + // Hook the AJAX wl_validate_key action to the Key Validation service. |
|
| 1331 | + $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' ); |
|
| 1332 | + |
|
| 1333 | + // Hook the `admin_init` function to the Admin Setup. |
|
| 1334 | + $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' ); |
|
| 1335 | + |
|
| 1336 | + // Hook the admin_init to the settings page. |
|
| 1337 | + $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' ); |
|
| 1338 | + |
|
| 1339 | + // Hook the menu creation on the general wordlift menu creation. |
|
| 1340 | + $this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 ); |
|
| 1341 | + if ( defined( 'WORDLIFT_BATCH' ) && WORDLIFT_BATCH ) { |
|
| 1342 | + // Add the functionality only if a flag is set in wp-config.php . |
|
| 1343 | + $this->loader->add_action( 'wl_admin_menu', $this->batch_analysis_page, 'admin_menu', 10, 2 ); |
|
| 1344 | + } |
|
| 1345 | + |
|
| 1346 | + // Hook key update. |
|
| 1347 | + $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 ); |
|
| 1348 | + $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 ); |
|
| 1349 | + |
|
| 1350 | + // Add additional action links to the WordLift plugin in the plugins page. |
|
| 1351 | + $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1352 | + |
|
| 1353 | + // Hook the AJAX `wl_publisher` action name. |
|
| 1354 | + $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' ); |
|
| 1355 | + |
|
| 1356 | + // Hook row actions for the entity type list admin. |
|
| 1357 | + $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 ); |
|
| 1358 | + |
|
| 1359 | + /** Ajax actions. */ |
|
| 1360 | + $this->loader->add_action( 'wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export' ); |
|
| 1361 | + |
|
| 1362 | + // Hook capabilities manipulation to allow access to entity type admin |
|
| 1363 | + // page on WordPress versions before 4.7. |
|
| 1364 | + global $wp_version; |
|
| 1365 | + if ( version_compare( $wp_version, '4.7', '<' ) ) { |
|
| 1366 | + $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 ); |
|
| 1367 | + } |
|
| 1368 | + |
|
| 1369 | + $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1370 | + |
|
| 1371 | + /** Adapters. */ |
|
| 1372 | + $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 ); |
|
| 1373 | + $this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit_auto_selected_posts', $this->batch_analysis_adapter, 'submit_auto_selected_posts', 10 ); |
|
| 1374 | + $this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit_all_posts', $this->batch_analysis_adapter, 'submit_all_posts', 10 ); |
|
| 1375 | + $this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit', $this->batch_analysis_adapter, 'submit', 10 ); |
|
| 1376 | + $this->loader->add_action( 'wp_ajax_wl_batch_analysis_cancel', $this->batch_analysis_adapter, 'cancel', 10 ); |
|
| 1377 | + $this->loader->add_action( 'wp_ajax_wl_batch_analysis_clear_warning', $this->batch_analysis_adapter, 'clear_warning', 10 ); |
|
| 1378 | + $this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all', 10 ); |
|
| 1379 | + |
|
| 1380 | + $this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' ); |
|
| 1381 | + $this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' ); |
|
| 1382 | + |
|
| 1383 | + // Handle the autocomplete request. |
|
| 1384 | + add_action( 'wp_ajax_wl_autocomplete', array( |
|
| 1385 | + $this->autocomplete_adapter, |
|
| 1386 | + 'wl_autocomplete', |
|
| 1387 | + ) ); |
|
| 1388 | + add_action( 'wp_ajax_nopriv_wl_autocomplete', array( |
|
| 1389 | + $this->autocomplete_adapter, |
|
| 1390 | + 'wl_autocomplete', |
|
| 1391 | + ) ); |
|
| 1392 | + |
|
| 1393 | + // Hooks to restrict multisite super admin from manipulating entity types. |
|
| 1394 | + if ( is_multisite() ) { |
|
| 1395 | + $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 ); |
|
| 1396 | + } |
|
| 1397 | + |
|
| 1398 | + } |
|
| 1399 | + |
|
| 1400 | + /** |
|
| 1401 | + * Register all of the hooks related to the public-facing functionality |
|
| 1402 | + * of the plugin. |
|
| 1403 | + * |
|
| 1404 | + * @since 1.0.0 |
|
| 1405 | + * @access private |
|
| 1406 | + */ |
|
| 1407 | + private function define_public_hooks() { |
|
| 1408 | 1408 | |
| 1409 | - $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 1410 | - |
|
| 1411 | - // Register the entity post type. |
|
| 1412 | - $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' ); |
|
| 1413 | - |
|
| 1414 | - // Bind the link generation and handling hooks to the entity link service. |
|
| 1415 | - $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 1416 | - $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 ); |
|
| 1417 | - $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 ); |
|
| 1418 | - $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 ); |
|
| 1419 | - |
|
| 1420 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 1421 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 1422 | - |
|
| 1423 | - // Hook the content filter service to add entity links. |
|
| 1424 | - $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' ); |
|
| 1425 | - |
|
| 1426 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1427 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1428 | - |
|
| 1429 | - // Hook the ShareThis service. |
|
| 1430 | - $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 1431 | - $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 1432 | - |
|
| 1433 | - // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1434 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1435 | - |
|
| 1436 | - // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service` |
|
| 1437 | - // in order to tweak WP's `WP_Query` to include entities in queries related |
|
| 1438 | - // to categories. |
|
| 1439 | - $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 ); |
|
| 1440 | - |
|
| 1441 | - /* |
|
| 1409 | + $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 1410 | + |
|
| 1411 | + // Register the entity post type. |
|
| 1412 | + $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' ); |
|
| 1413 | + |
|
| 1414 | + // Bind the link generation and handling hooks to the entity link service. |
|
| 1415 | + $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 1416 | + $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 ); |
|
| 1417 | + $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 ); |
|
| 1418 | + $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 ); |
|
| 1419 | + |
|
| 1420 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 1421 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 1422 | + |
|
| 1423 | + // Hook the content filter service to add entity links. |
|
| 1424 | + $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' ); |
|
| 1425 | + |
|
| 1426 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1427 | + $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1428 | + |
|
| 1429 | + // Hook the ShareThis service. |
|
| 1430 | + $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 1431 | + $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 1432 | + |
|
| 1433 | + // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1434 | + $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1435 | + |
|
| 1436 | + // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service` |
|
| 1437 | + // in order to tweak WP's `WP_Query` to include entities in queries related |
|
| 1438 | + // to categories. |
|
| 1439 | + $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 ); |
|
| 1440 | + |
|
| 1441 | + /* |
|
| 1442 | 1442 | * Hook the `pre_get_posts` action to the `Wordlift_Entity_Page_Service` |
| 1443 | 1443 | * in order to tweak WP's `WP_Query` to show event related entities in reverse |
| 1444 | 1444 | * order of start time. |
| 1445 | 1445 | */ |
| 1446 | - $this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 ); |
|
| 1447 | - |
|
| 1448 | - $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1449 | - |
|
| 1450 | - // This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done. |
|
| 1451 | - $this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 ); |
|
| 1452 | - |
|
| 1453 | - } |
|
| 1454 | - |
|
| 1455 | - /** |
|
| 1456 | - * Run the loader to execute all of the hooks with WordPress. |
|
| 1457 | - * |
|
| 1458 | - * @since 1.0.0 |
|
| 1459 | - */ |
|
| 1460 | - public function run() { |
|
| 1461 | - $this->loader->run(); |
|
| 1462 | - } |
|
| 1463 | - |
|
| 1464 | - /** |
|
| 1465 | - * The name of the plugin used to uniquely identify it within the context of |
|
| 1466 | - * WordPress and to define internationalization functionality. |
|
| 1467 | - * |
|
| 1468 | - * @since 1.0.0 |
|
| 1469 | - * @return string The name of the plugin. |
|
| 1470 | - */ |
|
| 1471 | - public function get_plugin_name() { |
|
| 1472 | - return $this->plugin_name; |
|
| 1473 | - } |
|
| 1474 | - |
|
| 1475 | - /** |
|
| 1476 | - * The reference to the class that orchestrates the hooks with the plugin. |
|
| 1477 | - * |
|
| 1478 | - * @since 1.0.0 |
|
| 1479 | - * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 1480 | - */ |
|
| 1481 | - public function get_loader() { |
|
| 1482 | - return $this->loader; |
|
| 1483 | - } |
|
| 1484 | - |
|
| 1485 | - /** |
|
| 1486 | - * Retrieve the version number of the plugin. |
|
| 1487 | - * |
|
| 1488 | - * @since 1.0.0 |
|
| 1489 | - * @return string The version number of the plugin. |
|
| 1490 | - */ |
|
| 1491 | - public function get_version() { |
|
| 1492 | - return $this->version; |
|
| 1493 | - } |
|
| 1446 | + $this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 ); |
|
| 1447 | + |
|
| 1448 | + $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1449 | + |
|
| 1450 | + // This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done. |
|
| 1451 | + $this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 ); |
|
| 1452 | + |
|
| 1453 | + } |
|
| 1454 | + |
|
| 1455 | + /** |
|
| 1456 | + * Run the loader to execute all of the hooks with WordPress. |
|
| 1457 | + * |
|
| 1458 | + * @since 1.0.0 |
|
| 1459 | + */ |
|
| 1460 | + public function run() { |
|
| 1461 | + $this->loader->run(); |
|
| 1462 | + } |
|
| 1463 | + |
|
| 1464 | + /** |
|
| 1465 | + * The name of the plugin used to uniquely identify it within the context of |
|
| 1466 | + * WordPress and to define internationalization functionality. |
|
| 1467 | + * |
|
| 1468 | + * @since 1.0.0 |
|
| 1469 | + * @return string The name of the plugin. |
|
| 1470 | + */ |
|
| 1471 | + public function get_plugin_name() { |
|
| 1472 | + return $this->plugin_name; |
|
| 1473 | + } |
|
| 1474 | + |
|
| 1475 | + /** |
|
| 1476 | + * The reference to the class that orchestrates the hooks with the plugin. |
|
| 1477 | + * |
|
| 1478 | + * @since 1.0.0 |
|
| 1479 | + * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 1480 | + */ |
|
| 1481 | + public function get_loader() { |
|
| 1482 | + return $this->loader; |
|
| 1483 | + } |
|
| 1484 | + |
|
| 1485 | + /** |
|
| 1486 | + * Retrieve the version number of the plugin. |
|
| 1487 | + * |
|
| 1488 | + * @since 1.0.0 |
|
| 1489 | + * @return string The version number of the plugin. |
|
| 1490 | + */ |
|
| 1491 | + public function get_version() { |
|
| 1492 | + return $this->version; |
|
| 1493 | + } |
|
| 1494 | 1494 | |
| 1495 | 1495 | } |
@@ -709,338 +709,338 @@ discard block |
||
| 709 | 709 | * The class responsible for orchestrating the actions and filters of the |
| 710 | 710 | * core plugin. |
| 711 | 711 | */ |
| 712 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 712 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-loader.php'; |
|
| 713 | 713 | |
| 714 | 714 | /** |
| 715 | 715 | * The class responsible for defining internationalization functionality |
| 716 | 716 | * of the plugin. |
| 717 | 717 | */ |
| 718 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 718 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-i18n.php'; |
|
| 719 | 719 | |
| 720 | 720 | /** |
| 721 | 721 | * WordLift's supported languages. |
| 722 | 722 | */ |
| 723 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php'; |
|
| 723 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-languages.php'; |
|
| 724 | 724 | |
| 725 | 725 | /** |
| 726 | 726 | * Provide support functions to sanitize data. |
| 727 | 727 | */ |
| 728 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 728 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sanitizer.php'; |
|
| 729 | 729 | |
| 730 | 730 | /** Services. */ |
| 731 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 732 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php'; |
|
| 733 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 734 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 735 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 736 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 737 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 738 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php'; |
|
| 739 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php'; |
|
| 731 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-log-service.php'; |
|
| 732 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-http-api.php'; |
|
| 733 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-redirect-service.php'; |
|
| 734 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-configuration-service.php'; |
|
| 735 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-post-type-service.php'; |
|
| 736 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-type-service.php'; |
|
| 737 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-link-service.php'; |
|
| 738 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-linked-data-service.php'; |
|
| 739 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-relation-service.php'; |
|
| 740 | 740 | |
| 741 | 741 | /** |
| 742 | 742 | * The Query builder. |
| 743 | 743 | */ |
| 744 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 744 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-query-builder.php'; |
|
| 745 | 745 | |
| 746 | 746 | /** |
| 747 | 747 | * The Schema service. |
| 748 | 748 | */ |
| 749 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 749 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-schema-service.php'; |
|
| 750 | 750 | |
| 751 | 751 | /** |
| 752 | 752 | * The schema:url property service. |
| 753 | 753 | */ |
| 754 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 755 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 754 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-property-service.php'; |
|
| 755 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-schema-url-property-service.php'; |
|
| 756 | 756 | |
| 757 | 757 | /** |
| 758 | 758 | * The UI service. |
| 759 | 759 | */ |
| 760 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 760 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-ui-service.php'; |
|
| 761 | 761 | |
| 762 | 762 | /** |
| 763 | 763 | * The Thumbnail service. |
| 764 | 764 | */ |
| 765 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 765 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-thumbnail-service.php'; |
|
| 766 | 766 | |
| 767 | 767 | /** |
| 768 | 768 | * The Entity Types Taxonomy service. |
| 769 | 769 | */ |
| 770 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 770 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 771 | 771 | |
| 772 | 772 | /** |
| 773 | 773 | * The Entity service. |
| 774 | 774 | */ |
| 775 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 775 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-service.php'; |
|
| 776 | 776 | |
| 777 | 777 | // Add the entity rating service. |
| 778 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php'; |
|
| 778 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-rating-service.php'; |
|
| 779 | 779 | |
| 780 | 780 | /** |
| 781 | 781 | * The User service. |
| 782 | 782 | */ |
| 783 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 783 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-user-service.php'; |
|
| 784 | 784 | |
| 785 | 785 | /** |
| 786 | 786 | * The Timeline service. |
| 787 | 787 | */ |
| 788 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 788 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-timeline-service.php'; |
|
| 789 | 789 | |
| 790 | 790 | /** |
| 791 | 791 | * The Topic Taxonomy service. |
| 792 | 792 | */ |
| 793 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 793 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 794 | 794 | |
| 795 | 795 | /** |
| 796 | 796 | * The SPARQL service. |
| 797 | 797 | */ |
| 798 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 798 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sparql-service.php'; |
|
| 799 | 799 | |
| 800 | 800 | /** |
| 801 | 801 | * The WordLift import service. |
| 802 | 802 | */ |
| 803 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 803 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-import-service.php'; |
|
| 804 | 804 | |
| 805 | 805 | /** |
| 806 | 806 | * The WordLift URI service. |
| 807 | 807 | */ |
| 808 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 808 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-uri-service.php'; |
|
| 809 | 809 | |
| 810 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php'; |
|
| 810 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-listable.php'; |
|
| 811 | 811 | |
| 812 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 812 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-property-factory.php'; |
|
| 813 | 813 | |
| 814 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php'; |
|
| 814 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sample-data-service.php'; |
|
| 815 | 815 | |
| 816 | 816 | /** |
| 817 | 817 | * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
| 818 | 818 | */ |
| 819 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php'; |
|
| 819 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-rebuild-service.php'; |
|
| 820 | 820 | |
| 821 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 821 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 822 | 822 | |
| 823 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php'; |
|
| 823 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-attachment-service.php'; |
|
| 824 | 824 | |
| 825 | 825 | /** |
| 826 | 826 | * Load the converters. |
| 827 | 827 | */ |
| 828 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php'; |
|
| 829 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 830 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 831 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 832 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 833 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php'; |
|
| 828 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/intf-wordlift-post-converter.php'; |
|
| 829 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 830 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 831 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 832 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 833 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-jsonld-website-converter.php'; |
|
| 834 | 834 | |
| 835 | 835 | /** |
| 836 | 836 | * Load cache-related files. |
| 837 | 837 | */ |
| 838 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php'; |
|
| 838 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/cache/require.php'; |
|
| 839 | 839 | |
| 840 | 840 | /** |
| 841 | 841 | * Load the content filter. |
| 842 | 842 | */ |
| 843 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 843 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-content-filter-service.php'; |
|
| 844 | 844 | |
| 845 | 845 | /* |
| 846 | 846 | * Load the excerpt helper. |
| 847 | 847 | */ |
| 848 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 848 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 849 | 849 | |
| 850 | 850 | /** |
| 851 | 851 | * Load the JSON-LD service to publish entities using JSON-LD.s |
| 852 | 852 | * |
| 853 | 853 | * @since 3.8.0 |
| 854 | 854 | */ |
| 855 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 855 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-jsonld-service.php'; |
|
| 856 | 856 | |
| 857 | 857 | // The Publisher Service and the AJAX adapter. |
| 858 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php'; |
|
| 859 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 858 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-publisher-service.php'; |
|
| 859 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 860 | 860 | |
| 861 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php'; |
|
| 861 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-post-adapter.php'; |
|
| 862 | 862 | |
| 863 | 863 | /** |
| 864 | 864 | * Load the WordLift key validation service. |
| 865 | 865 | */ |
| 866 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php'; |
|
| 866 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-key-validation-service.php'; |
|
| 867 | 867 | |
| 868 | 868 | // Load the `Wordlift_Category_Taxonomy_Service` class definition. |
| 869 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 869 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 870 | 870 | |
| 871 | 871 | // Load the `Wordlift_Entity_Page_Service` class definition. |
| 872 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php'; |
|
| 873 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-analysis-service.php'; |
|
| 874 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-rebuild-service.php'; |
|
| 872 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-page-service.php'; |
|
| 873 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-batch-analysis-service.php'; |
|
| 874 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-relation-rebuild-service.php'; |
|
| 875 | 875 | |
| 876 | 876 | /** Linked Data. */ |
| 877 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php'; |
|
| 878 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php'; |
|
| 879 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php'; |
|
| 880 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php'; |
|
| 881 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php'; |
|
| 882 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php'; |
|
| 883 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php'; |
|
| 884 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php'; |
|
| 885 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php'; |
|
| 886 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php'; |
|
| 887 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php'; |
|
| 888 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition.php'; |
|
| 889 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php'; |
|
| 877 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-storage.php'; |
|
| 878 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-meta-storage.php'; |
|
| 879 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-property-storage.php'; |
|
| 880 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php'; |
|
| 881 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php'; |
|
| 882 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-author-storage.php'; |
|
| 883 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php'; |
|
| 884 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-image-storage.php'; |
|
| 885 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-related-storage.php'; |
|
| 886 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-url-property-storage.php'; |
|
| 887 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-storage-factory.php'; |
|
| 888 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition.php'; |
|
| 889 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php'; |
|
| 890 | 890 | |
| 891 | 891 | /** Services. */ |
| 892 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php'; |
|
| 892 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-google-analytics-export-service.php'; |
|
| 893 | 893 | |
| 894 | 894 | /** Adapters. */ |
| 895 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php'; |
|
| 896 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php'; |
|
| 897 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php'; |
|
| 898 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php'; |
|
| 899 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-analysis-adapter.php'; |
|
| 900 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-rebuild-adapter.php'; |
|
| 895 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-tinymce-adapter.php'; |
|
| 896 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-newrelic-adapter.php'; |
|
| 897 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sample-data-ajax-adapter.php'; |
|
| 898 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-type-adapter.php'; |
|
| 899 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-batch-analysis-adapter.php'; |
|
| 900 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-relation-rebuild-adapter.php'; |
|
| 901 | 901 | |
| 902 | 902 | /** Async Tasks. */ |
| 903 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-async-task.php'; |
|
| 904 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php'; |
|
| 905 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-batch-analysis-request-async-task.php'; |
|
| 906 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-batch-analysis-complete-async-task.php'; |
|
| 903 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/wp-async-task/class-wordlift-async-task.php'; |
|
| 904 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/wp-async-task/class-wordlift-sparql-query-async-task.php'; |
|
| 905 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/wp-async-task/class-wordlift-batch-analysis-request-async-task.php'; |
|
| 906 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/wp-async-task/class-wordlift-batch-analysis-complete-async-task.php'; |
|
| 907 | 907 | |
| 908 | 908 | /** Async Tasks. */ |
| 909 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-service.php'; |
|
| 910 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php'; |
|
| 909 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-autocomplete-service.php'; |
|
| 910 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-autocomplete-adapter.php'; |
|
| 911 | 911 | |
| 912 | 912 | /** |
| 913 | 913 | * The class responsible for defining all actions that occur in the admin area. |
| 914 | 914 | */ |
| 915 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 915 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin.php'; |
|
| 916 | 916 | |
| 917 | 917 | /** |
| 918 | 918 | * The class to customize the entity list admin page. |
| 919 | 919 | */ |
| 920 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 920 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-entity-list.php'; |
|
| 921 | 921 | |
| 922 | 922 | /** |
| 923 | 923 | * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
| 924 | 924 | */ |
| 925 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 925 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 926 | 926 | |
| 927 | 927 | /** |
| 928 | 928 | * The Notice service. |
| 929 | 929 | */ |
| 930 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 930 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-notice-service.php'; |
|
| 931 | 931 | |
| 932 | 932 | /** |
| 933 | 933 | * The PrimaShop adapter. |
| 934 | 934 | */ |
| 935 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 935 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-primashop-adapter.php'; |
|
| 936 | 936 | |
| 937 | 937 | /** |
| 938 | 938 | * The WordLift Dashboard service. |
| 939 | 939 | */ |
| 940 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 940 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-dashboard.php'; |
|
| 941 | 941 | |
| 942 | 942 | /** |
| 943 | 943 | * The admin 'Install wizard' page. |
| 944 | 944 | */ |
| 945 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php'; |
|
| 945 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-setup.php'; |
|
| 946 | 946 | |
| 947 | 947 | /** |
| 948 | 948 | * The WordLift entity type list admin page controller. |
| 949 | 949 | */ |
| 950 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 950 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 951 | 951 | |
| 952 | 952 | /** |
| 953 | 953 | * The WordLift entity type settings admin page controller. |
| 954 | 954 | */ |
| 955 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php'; |
|
| 955 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-type-settings.php'; |
|
| 956 | 956 | |
| 957 | 957 | /** |
| 958 | 958 | * The admin 'Download Your Data' page. |
| 959 | 959 | */ |
| 960 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 960 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-download-your-data-page.php'; |
|
| 961 | 961 | |
| 962 | 962 | /** |
| 963 | 963 | * The admin 'WordLift Settings' page. |
| 964 | 964 | */ |
| 965 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/intf-wordlift-admin-element.php'; |
|
| 966 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-element.php'; |
|
| 967 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-radio-element.php'; |
|
| 968 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-select2-element.php'; |
|
| 969 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-language-select-element.php'; |
|
| 970 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-tabs-element.php'; |
|
| 971 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-author-element.php'; |
|
| 972 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-publisher-element.php'; |
|
| 973 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php'; |
|
| 974 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php'; |
|
| 975 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-batch-analysis-page.php'; |
|
| 976 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 965 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/intf-wordlift-admin-element.php'; |
|
| 966 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-input-element.php'; |
|
| 967 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-input-radio-element.php'; |
|
| 968 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-select2-element.php'; |
|
| 969 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-language-select-element.php'; |
|
| 970 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-tabs-element.php'; |
|
| 971 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-author-element.php'; |
|
| 972 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-publisher-element.php'; |
|
| 973 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-page.php'; |
|
| 974 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-settings-page.php'; |
|
| 975 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-batch-analysis-page.php'; |
|
| 976 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 977 | 977 | |
| 978 | 978 | /** Admin Pages */ |
| 979 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 980 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php'; |
|
| 981 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php'; |
|
| 982 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php'; |
|
| 979 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 980 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-user-profile-page.php'; |
|
| 981 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-status-page.php'; |
|
| 982 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-type-admin-service.php'; |
|
| 983 | 983 | |
| 984 | 984 | /** |
| 985 | 985 | * The class responsible for defining all actions that occur in the public-facing |
| 986 | 986 | * side of the site. |
| 987 | 987 | */ |
| 988 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 988 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-public.php'; |
|
| 989 | 989 | |
| 990 | 990 | /** |
| 991 | 991 | * The shortcode abstract class. |
| 992 | 992 | */ |
| 993 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 993 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-shortcode.php'; |
|
| 994 | 994 | |
| 995 | 995 | /** |
| 996 | 996 | * The Timeline shortcode. |
| 997 | 997 | */ |
| 998 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 998 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-timeline-shortcode.php'; |
|
| 999 | 999 | |
| 1000 | 1000 | /** |
| 1001 | 1001 | * The Navigator shortcode. |
| 1002 | 1002 | */ |
| 1003 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 1003 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-navigator-shortcode.php'; |
|
| 1004 | 1004 | |
| 1005 | 1005 | /** |
| 1006 | 1006 | * The chord shortcode. |
| 1007 | 1007 | */ |
| 1008 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 1008 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-chord-shortcode.php'; |
|
| 1009 | 1009 | |
| 1010 | 1010 | /** |
| 1011 | 1011 | * The geomap shortcode. |
| 1012 | 1012 | */ |
| 1013 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 1013 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-geomap-shortcode.php'; |
|
| 1014 | 1014 | |
| 1015 | 1015 | /** |
| 1016 | 1016 | * The entity cloud shortcode. |
| 1017 | 1017 | */ |
| 1018 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 1018 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 1019 | 1019 | |
| 1020 | 1020 | /** |
| 1021 | 1021 | * The ShareThis service. |
| 1022 | 1022 | */ |
| 1023 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 1023 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-sharethis-service.php'; |
|
| 1024 | 1024 | |
| 1025 | 1025 | /** |
| 1026 | 1026 | * The SEO service. |
| 1027 | 1027 | */ |
| 1028 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php'; |
|
| 1028 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-seo-service.php'; |
|
| 1029 | 1029 | |
| 1030 | 1030 | /** |
| 1031 | 1031 | * The AMP service. |
| 1032 | 1032 | */ |
| 1033 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php'; |
|
| 1033 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-amp-service.php'; |
|
| 1034 | 1034 | |
| 1035 | 1035 | /** Widgets */ |
| 1036 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php'; |
|
| 1037 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 1036 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-widget.php'; |
|
| 1037 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 1038 | 1038 | |
| 1039 | 1039 | $this->loader = new Wordlift_Loader(); |
| 1040 | 1040 | |
| 1041 | 1041 | // Instantiate a global logger. |
| 1042 | 1042 | global $wl_logger; |
| 1043 | - $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 1043 | + $wl_logger = Wordlift_Log_Service::get_logger('WordLift'); |
|
| 1044 | 1044 | |
| 1045 | 1045 | // Load the `wl-api` end-point. |
| 1046 | 1046 | new Wordlift_Http_Api(); |
@@ -1050,10 +1050,10 @@ discard block |
||
| 1050 | 1050 | $this->configuration_service = new Wordlift_Configuration_Service(); |
| 1051 | 1051 | |
| 1052 | 1052 | // Create an entity type service instance. It'll be later bound to the init action. |
| 1053 | - $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() ); |
|
| 1053 | + $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service(Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path()); |
|
| 1054 | 1054 | |
| 1055 | 1055 | // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
| 1056 | - $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() ); |
|
| 1056 | + $this->entity_link_service = new Wordlift_Entity_Link_Service($this->entity_post_type_service, $this->configuration_service->get_entity_base_path()); |
|
| 1057 | 1057 | |
| 1058 | 1058 | // Create an instance of the UI service. |
| 1059 | 1059 | $this->ui_service = new Wordlift_UI_Service(); |
@@ -1062,30 +1062,30 @@ discard block |
||
| 1062 | 1062 | $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
| 1063 | 1063 | |
| 1064 | 1064 | $this->sparql_service = new Wordlift_Sparql_Service(); |
| 1065 | - $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 1065 | + $schema_url_property_service = new Wordlift_Schema_Url_Property_Service($this->sparql_service); |
|
| 1066 | 1066 | $this->notice_service = new Wordlift_Notice_Service(); |
| 1067 | 1067 | $this->relation_service = new Wordlift_Relation_Service(); |
| 1068 | - $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service ); |
|
| 1068 | + $this->entity_service = new Wordlift_Entity_Service($this->ui_service, $this->relation_service); |
|
| 1069 | 1069 | $this->user_service = new Wordlift_User_Service(); |
| 1070 | 1070 | |
| 1071 | 1071 | // Instantiate the JSON-LD service. |
| 1072 | - $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 1072 | + $property_getter = Wordlift_Property_Getter_Factory::create($this->entity_service); |
|
| 1073 | 1073 | |
| 1074 | 1074 | /** Linked Data. */ |
| 1075 | - $this->storage_factory = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter ); |
|
| 1076 | - $this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service ); |
|
| 1075 | + $this->storage_factory = new Wordlift_Storage_Factory($this->entity_service, $this->user_service, $property_getter); |
|
| 1076 | + $this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory($this->entity_service); |
|
| 1077 | 1077 | |
| 1078 | - $this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service ); |
|
| 1078 | + $this->schema_service = new Wordlift_Schema_Service($this->storage_factory, $this->rendition_factory, $this->configuration_service); |
|
| 1079 | 1079 | |
| 1080 | 1080 | // Create a new instance of the Redirect service. |
| 1081 | - $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service ); |
|
| 1082 | - $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service ); |
|
| 1083 | - $this->linked_data_service = new Wordlift_Linked_Data_Service( $this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service ); |
|
| 1081 | + $this->redirect_service = new Wordlift_Redirect_Service($this->entity_service); |
|
| 1082 | + $this->entity_type_service = new Wordlift_Entity_Type_Service($this->schema_service); |
|
| 1083 | + $this->linked_data_service = new Wordlift_Linked_Data_Service($this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service); |
|
| 1084 | 1084 | |
| 1085 | 1085 | // Create a new instance of the Timeline service and Timeline shortcode. |
| 1086 | - $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service ); |
|
| 1086 | + $this->timeline_service = new Wordlift_Timeline_Service($this->entity_service, $this->entity_type_service); |
|
| 1087 | 1087 | |
| 1088 | - $this->batch_analysis_service = new Wordlift_Batch_Analysis_Service( $this, $this->configuration_service ); |
|
| 1088 | + $this->batch_analysis_service = new Wordlift_Batch_Analysis_Service($this, $this->configuration_service); |
|
| 1089 | 1089 | |
| 1090 | 1090 | $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
| 1091 | 1091 | |
@@ -1098,52 +1098,52 @@ discard block |
||
| 1098 | 1098 | $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
| 1099 | 1099 | |
| 1100 | 1100 | // Create an import service instance to hook later to WP's import function. |
| 1101 | - $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() ); |
|
| 1101 | + $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()); |
|
| 1102 | 1102 | |
| 1103 | - $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 1103 | + $uri_service = new Wordlift_Uri_Service($GLOBALS['wpdb']); |
|
| 1104 | 1104 | |
| 1105 | 1105 | // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
| 1106 | - $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service ); |
|
| 1106 | + $this->rebuild_service = new Wordlift_Rebuild_Service($this->sparql_service, $uri_service); |
|
| 1107 | 1107 | |
| 1108 | 1108 | // Create the entity rating service. |
| 1109 | - $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service ); |
|
| 1109 | + $this->rating_service = new Wordlift_Rating_Service($this->entity_service, $this->entity_type_service, $this->notice_service); |
|
| 1110 | 1110 | |
| 1111 | 1111 | // Create entity list customization (wp-admin/edit.php). |
| 1112 | - $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service ); |
|
| 1112 | + $this->entity_list_service = new Wordlift_Entity_List_Service($this->rating_service); |
|
| 1113 | 1113 | |
| 1114 | 1114 | // Create a new instance of the Redirect service. |
| 1115 | - $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service ); |
|
| 1115 | + $this->dashboard_service = new Wordlift_Dashboard_Service($this->rating_service, $this->entity_service); |
|
| 1116 | 1116 | |
| 1117 | 1117 | // Create an instance of the Publisher Service and the AJAX Adapter. |
| 1118 | 1118 | $publisher_service = new Wordlift_Publisher_Service(); |
| 1119 | - $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 1120 | - $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 1119 | + $this->property_factory = new Wordlift_Property_Factory($schema_url_property_service); |
|
| 1120 | + $this->property_factory->register(Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service); |
|
| 1121 | 1121 | |
| 1122 | 1122 | $attachment_service = new Wordlift_Attachment_Service(); |
| 1123 | 1123 | |
| 1124 | 1124 | // Instantiate the JSON-LD service. |
| 1125 | - $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 1126 | - $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 ); |
|
| 1127 | - $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, $this->entity_post_to_jsonld_converter ); |
|
| 1128 | - $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 ); |
|
| 1129 | - $this->jsonld_website_converter = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service, $this->entity_post_to_jsonld_converter ); |
|
| 1130 | - $this->file_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'converter/' ); |
|
| 1131 | - $this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $this->postid_to_jsonld_converter, $this->file_cache_service ); |
|
| 1132 | - $this->jsonld_service = new Wordlift_Jsonld_Service( $this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter ); |
|
| 1133 | - |
|
| 1134 | - |
|
| 1135 | - $this->key_validation_service = new Wordlift_Key_Validation_Service( $this->configuration_service ); |
|
| 1136 | - $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service ); |
|
| 1137 | - $this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service ); |
|
| 1138 | - $this->sample_data_service = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service ); |
|
| 1139 | - $this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service ); |
|
| 1125 | + $property_getter = Wordlift_Property_Getter_Factory::create($this->entity_service); |
|
| 1126 | + $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); |
|
| 1127 | + $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, $this->entity_post_to_jsonld_converter); |
|
| 1128 | + $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); |
|
| 1129 | + $this->jsonld_website_converter = new Wordlift_Website_Jsonld_Converter($this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service, $this->entity_post_to_jsonld_converter); |
|
| 1130 | + $this->file_cache_service = new Wordlift_File_Cache_Service(WL_TEMP_DIR.'converter/'); |
|
| 1131 | + $this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter($this->postid_to_jsonld_converter, $this->file_cache_service); |
|
| 1132 | + $this->jsonld_service = new Wordlift_Jsonld_Service($this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter); |
|
| 1133 | + |
|
| 1134 | + |
|
| 1135 | + $this->key_validation_service = new Wordlift_Key_Validation_Service($this->configuration_service); |
|
| 1136 | + $this->content_filter_service = new Wordlift_Content_Filter_Service($this->entity_service, $this->configuration_service); |
|
| 1137 | + $this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service($this->content_filter_service, $this->entity_service); |
|
| 1138 | + $this->sample_data_service = new Wordlift_Sample_Data_Service($this->entity_type_service, $this->configuration_service); |
|
| 1139 | + $this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter($this->sample_data_service); |
|
| 1140 | 1140 | |
| 1141 | 1141 | // Initialize the shortcodes. |
| 1142 | 1142 | new Wordlift_Navigator_Shortcode(); |
| 1143 | 1143 | new Wordlift_Chord_Shortcode(); |
| 1144 | 1144 | new Wordlift_Geomap_Shortcode(); |
| 1145 | 1145 | new Wordlift_Timeline_Shortcode(); |
| 1146 | - new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service ); |
|
| 1146 | + new Wordlift_Related_Entities_Cloud_Shortcode($this->relation_service); |
|
| 1147 | 1147 | |
| 1148 | 1148 | // Initialize the SEO service. |
| 1149 | 1149 | new Wordlift_Seo_Service(); |
@@ -1155,11 +1155,11 @@ discard block |
||
| 1155 | 1155 | $this->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service(); |
| 1156 | 1156 | |
| 1157 | 1157 | /** Adapters. */ |
| 1158 | - $this->entity_type_adapter = new Wordlift_Entity_Type_Adapter( $this->entity_type_service ); |
|
| 1159 | - $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $publisher_service ); |
|
| 1160 | - $this->tinymce_adapter = new Wordlift_Tinymce_Adapter( $this ); |
|
| 1161 | - $this->batch_analysis_adapter = new Wordlift_Batch_Analysis_Adapter( $this->batch_analysis_service ); |
|
| 1162 | - $this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service ); |
|
| 1158 | + $this->entity_type_adapter = new Wordlift_Entity_Type_Adapter($this->entity_type_service); |
|
| 1159 | + $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter($publisher_service); |
|
| 1160 | + $this->tinymce_adapter = new Wordlift_Tinymce_Adapter($this); |
|
| 1161 | + $this->batch_analysis_adapter = new Wordlift_Batch_Analysis_Adapter($this->batch_analysis_service); |
|
| 1162 | + $this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter($this->relation_rebuild_service); |
|
| 1163 | 1163 | |
| 1164 | 1164 | /** Async Tasks. */ |
| 1165 | 1165 | new Wordlift_Sparql_Query_Async_Task(); |
@@ -1167,8 +1167,8 @@ discard block |
||
| 1167 | 1167 | new Wordlift_Batch_Analysis_Complete_Async_Task(); |
| 1168 | 1168 | |
| 1169 | 1169 | /** WL Autocomplete. */ |
| 1170 | - $this->autocomplete_service = new Wordlift_Autocomplete_Service( $this->configuration_service ); |
|
| 1171 | - $this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $this->autocomplete_service ); |
|
| 1170 | + $this->autocomplete_service = new Wordlift_Autocomplete_Service($this->configuration_service); |
|
| 1171 | + $this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter($this->autocomplete_service); |
|
| 1172 | 1172 | |
| 1173 | 1173 | /** WordPress Admin UI. */ |
| 1174 | 1174 | |
@@ -1178,15 +1178,15 @@ discard block |
||
| 1178 | 1178 | $this->select2_element = new Wordlift_Admin_Select2_Element(); |
| 1179 | 1179 | $this->language_select_element = new Wordlift_Admin_Language_Select_Element(); |
| 1180 | 1180 | $tabs_element = new Wordlift_Admin_Tabs_Element(); |
| 1181 | - $this->publisher_element = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $publisher_service, $tabs_element, $this->select2_element ); |
|
| 1182 | - $this->author_element = new Wordlift_Admin_Author_Element( $publisher_service, $this->select2_element ); |
|
| 1181 | + $this->publisher_element = new Wordlift_Admin_Publisher_Element($this->configuration_service, $publisher_service, $tabs_element, $this->select2_element); |
|
| 1182 | + $this->author_element = new Wordlift_Admin_Author_Element($publisher_service, $this->select2_element); |
|
| 1183 | 1183 | |
| 1184 | - $this->settings_page = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->publisher_element, $this->radio_input_element ); |
|
| 1185 | - $this->batch_analysis_page = new Wordlift_Batch_Analysis_Page( $this->batch_analysis_service ); |
|
| 1186 | - $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page ); |
|
| 1184 | + $this->settings_page = new Wordlift_Admin_Settings_Page($this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->publisher_element, $this->radio_input_element); |
|
| 1185 | + $this->batch_analysis_page = new Wordlift_Batch_Analysis_Page($this->batch_analysis_service); |
|
| 1186 | + $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link($this->settings_page); |
|
| 1187 | 1187 | |
| 1188 | 1188 | // Pages. |
| 1189 | - new Wordlift_Admin_Post_Edit_Page( $this ); |
|
| 1189 | + new Wordlift_Admin_Post_Edit_Page($this); |
|
| 1190 | 1190 | new Wordlift_Entity_Type_Admin_Service(); |
| 1191 | 1191 | |
| 1192 | 1192 | // create an instance of the entity type list admin page controller. |
@@ -1199,23 +1199,23 @@ discard block |
||
| 1199 | 1199 | $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget(); |
| 1200 | 1200 | |
| 1201 | 1201 | /* WordPress Admin. */ |
| 1202 | - $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 1203 | - $this->status_page = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service ); |
|
| 1202 | + $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page($this->configuration_service); |
|
| 1203 | + $this->status_page = new Wordlift_Admin_Status_Page($this->entity_service, $this->sparql_service); |
|
| 1204 | 1204 | |
| 1205 | 1205 | // Create an instance of the install wizard. |
| 1206 | - $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service ); |
|
| 1206 | + $this->admin_setup = new Wordlift_Admin_Setup($this->configuration_service, $this->key_validation_service, $this->entity_service); |
|
| 1207 | 1207 | |
| 1208 | - $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service ); |
|
| 1208 | + $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service($this->entity_post_type_service); |
|
| 1209 | 1209 | |
| 1210 | 1210 | // User Profile. |
| 1211 | - new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service ); |
|
| 1211 | + new Wordlift_Admin_User_Profile_Page($this->author_element, $this->user_service); |
|
| 1212 | 1212 | |
| 1213 | 1213 | $this->entity_page_service = new Wordlift_Entity_Page_Service(); |
| 1214 | 1214 | |
| 1215 | 1215 | // Load the debug service if WP is in debug mode. |
| 1216 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 1217 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 1218 | - new Wordlift_Debug_Service( $this->entity_service, $uri_service ); |
|
| 1216 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
| 1217 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-debug-service.php'; |
|
| 1218 | + new Wordlift_Debug_Service($this->entity_service, $uri_service); |
|
| 1219 | 1219 | } |
| 1220 | 1220 | |
| 1221 | 1221 | } |
@@ -1232,9 +1232,9 @@ discard block |
||
| 1232 | 1232 | private function set_locale() { |
| 1233 | 1233 | |
| 1234 | 1234 | $plugin_i18n = new Wordlift_i18n(); |
| 1235 | - $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 1235 | + $plugin_i18n->set_domain($this->get_plugin_name()); |
|
| 1236 | 1236 | |
| 1237 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 1237 | + $this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain'); |
|
| 1238 | 1238 | |
| 1239 | 1239 | } |
| 1240 | 1240 | |
@@ -1255,144 +1255,144 @@ discard block |
||
| 1255 | 1255 | $this->user_service |
| 1256 | 1256 | ); |
| 1257 | 1257 | |
| 1258 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 1259 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
| 1258 | + $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles'); |
|
| 1259 | + $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts'); |
|
| 1260 | 1260 | |
| 1261 | 1261 | // Hook the init action to the Topic Taxonomy service. |
| 1262 | - $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 1262 | + $this->loader->add_action('init', $this->topic_taxonomy_service, 'init', 0); |
|
| 1263 | 1263 | |
| 1264 | 1264 | // Hook the deleted_post_meta action to the Thumbnail service. |
| 1265 | - $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 1265 | + $this->loader->add_action('deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4); |
|
| 1266 | 1266 | |
| 1267 | 1267 | // Hook the added_post_meta action to the Thumbnail service. |
| 1268 | - $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1268 | + $this->loader->add_action('added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4); |
|
| 1269 | 1269 | |
| 1270 | 1270 | // Hook the updated_post_meta action to the Thumbnail service. |
| 1271 | - $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1271 | + $this->loader->add_action('updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4); |
|
| 1272 | 1272 | |
| 1273 | 1273 | // Hook the AJAX wl_timeline action to the Timeline service. |
| 1274 | - $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1274 | + $this->loader->add_action('wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline'); |
|
| 1275 | 1275 | |
| 1276 | 1276 | // Register custom allowed redirect hosts. |
| 1277 | - $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 1277 | + $this->loader->add_filter('allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts'); |
|
| 1278 | 1278 | // Hook the AJAX wordlift_redirect action to the Redirect service. |
| 1279 | - $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 1279 | + $this->loader->add_action('wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect'); |
|
| 1280 | 1280 | // Hook the AJAX wordlift_redirect action to the Redirect service. |
| 1281 | - $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 1281 | + $this->loader->add_action('wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats'); |
|
| 1282 | 1282 | // Hook the AJAX wordlift_redirect action to the Redirect service. |
| 1283 | - $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 1283 | + $this->loader->add_action('wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets'); |
|
| 1284 | 1284 | |
| 1285 | 1285 | // Hook save_post to the entity service to update custom fields (such as alternate labels). |
| 1286 | 1286 | // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
| 1287 | - $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 1288 | - $this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 ); |
|
| 1287 | + $this->loader->add_action('save_post', $this->entity_service, 'save_post', 9, 3); |
|
| 1288 | + $this->loader->add_action('save_post', $this->rating_service, 'set_rating_for', 20, 1); |
|
| 1289 | 1289 | |
| 1290 | - $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 1291 | - $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' ); |
|
| 1290 | + $this->loader->add_action('edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1); |
|
| 1291 | + $this->loader->add_action('in_admin_header', $this->rating_service, 'in_admin_header'); |
|
| 1292 | 1292 | |
| 1293 | 1293 | // Entity listing customization (wp-admin/edit.php) |
| 1294 | 1294 | // Add custom columns. |
| 1295 | - $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 1295 | + $this->loader->add_filter('manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns'); |
|
| 1296 | 1296 | // no explicit entity as it prevents handling of other post types. |
| 1297 | - $this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 1297 | + $this->loader->add_filter('manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2); |
|
| 1298 | 1298 | // Add 4W selection. |
| 1299 | - $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 1300 | - $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 1301 | - $this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' ); |
|
| 1302 | - $this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' ); |
|
| 1303 | - $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 1299 | + $this->loader->add_action('restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope'); |
|
| 1300 | + $this->loader->add_filter('posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope'); |
|
| 1301 | + $this->loader->add_action('pre_get_posts', $this->entity_list_service, 'pre_get_posts'); |
|
| 1302 | + $this->loader->add_action('load-edit.php', $this->entity_list_service, 'load_edit'); |
|
| 1303 | + $this->loader->add_filter('wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args'); |
|
| 1304 | 1304 | |
| 1305 | 1305 | // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
| 1306 | 1306 | // entities. |
| 1307 | - $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 1307 | + $this->loader->add_filter('prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2); |
|
| 1308 | 1308 | |
| 1309 | 1309 | // Filter imported post meta. |
| 1310 | - $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 1310 | + $this->loader->add_filter('wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3); |
|
| 1311 | 1311 | |
| 1312 | 1312 | // Notify the import service when an import starts and ends. |
| 1313 | - $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 1314 | - $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 1313 | + $this->loader->add_action('import_start', $this->import_service, 'import_start', 10, 0); |
|
| 1314 | + $this->loader->add_action('import_end', $this->import_service, 'import_end', 10, 0); |
|
| 1315 | 1315 | |
| 1316 | 1316 | // Hook the AJAX wl_rebuild action to the Rebuild Service. |
| 1317 | - $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 1317 | + $this->loader->add_action('wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild'); |
|
| 1318 | 1318 | |
| 1319 | 1319 | // Hook the menu to the Download Your Data page. |
| 1320 | - $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 ); |
|
| 1321 | - $this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 ); |
|
| 1322 | - $this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 ); |
|
| 1320 | + $this->loader->add_action('admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0); |
|
| 1321 | + $this->loader->add_action('admin_menu', $this->status_page, 'admin_menu', 100, 0); |
|
| 1322 | + $this->loader->add_action('admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0); |
|
| 1323 | 1323 | |
| 1324 | 1324 | // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
| 1325 | - $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 1325 | + $this->loader->add_action('wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10); |
|
| 1326 | 1326 | |
| 1327 | 1327 | // Hook the AJAX wl_jsonld action to the JSON-LD service. |
| 1328 | - $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1328 | + $this->loader->add_action('wp_ajax_wl_jsonld', $this->jsonld_service, 'get'); |
|
| 1329 | 1329 | |
| 1330 | 1330 | // Hook the AJAX wl_validate_key action to the Key Validation service. |
| 1331 | - $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' ); |
|
| 1331 | + $this->loader->add_action('wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key'); |
|
| 1332 | 1332 | |
| 1333 | 1333 | // Hook the `admin_init` function to the Admin Setup. |
| 1334 | - $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' ); |
|
| 1334 | + $this->loader->add_action('admin_init', $this->admin_setup, 'admin_init'); |
|
| 1335 | 1335 | |
| 1336 | 1336 | // Hook the admin_init to the settings page. |
| 1337 | - $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' ); |
|
| 1337 | + $this->loader->add_action('admin_init', $this->settings_page, 'admin_init'); |
|
| 1338 | 1338 | |
| 1339 | 1339 | // Hook the menu creation on the general wordlift menu creation. |
| 1340 | - $this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 ); |
|
| 1341 | - if ( defined( 'WORDLIFT_BATCH' ) && WORDLIFT_BATCH ) { |
|
| 1340 | + $this->loader->add_action('wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2); |
|
| 1341 | + if (defined('WORDLIFT_BATCH') && WORDLIFT_BATCH) { |
|
| 1342 | 1342 | // Add the functionality only if a flag is set in wp-config.php . |
| 1343 | - $this->loader->add_action( 'wl_admin_menu', $this->batch_analysis_page, 'admin_menu', 10, 2 ); |
|
| 1343 | + $this->loader->add_action('wl_admin_menu', $this->batch_analysis_page, 'admin_menu', 10, 2); |
|
| 1344 | 1344 | } |
| 1345 | 1345 | |
| 1346 | 1346 | // Hook key update. |
| 1347 | - $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 ); |
|
| 1348 | - $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 ); |
|
| 1347 | + $this->loader->add_action('pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2); |
|
| 1348 | + $this->loader->add_action('update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2); |
|
| 1349 | 1349 | |
| 1350 | 1350 | // Add additional action links to the WordLift plugin in the plugins page. |
| 1351 | - $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1351 | + $this->loader->add_filter('plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1); |
|
| 1352 | 1352 | |
| 1353 | 1353 | // Hook the AJAX `wl_publisher` action name. |
| 1354 | - $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' ); |
|
| 1354 | + $this->loader->add_action('wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher'); |
|
| 1355 | 1355 | |
| 1356 | 1356 | // Hook row actions for the entity type list admin. |
| 1357 | - $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 ); |
|
| 1357 | + $this->loader->add_filter('wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2); |
|
| 1358 | 1358 | |
| 1359 | 1359 | /** Ajax actions. */ |
| 1360 | - $this->loader->add_action( 'wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export' ); |
|
| 1360 | + $this->loader->add_action('wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export'); |
|
| 1361 | 1361 | |
| 1362 | 1362 | // Hook capabilities manipulation to allow access to entity type admin |
| 1363 | 1363 | // page on WordPress versions before 4.7. |
| 1364 | 1364 | global $wp_version; |
| 1365 | - if ( version_compare( $wp_version, '4.7', '<' ) ) { |
|
| 1366 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 ); |
|
| 1365 | + if (version_compare($wp_version, '4.7', '<')) { |
|
| 1366 | + $this->loader->add_filter('map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4); |
|
| 1367 | 1367 | } |
| 1368 | 1368 | |
| 1369 | - $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1369 | + $this->loader->add_action('wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1); |
|
| 1370 | 1370 | |
| 1371 | 1371 | /** Adapters. */ |
| 1372 | - $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 ); |
|
| 1373 | - $this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit_auto_selected_posts', $this->batch_analysis_adapter, 'submit_auto_selected_posts', 10 ); |
|
| 1374 | - $this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit_all_posts', $this->batch_analysis_adapter, 'submit_all_posts', 10 ); |
|
| 1375 | - $this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit', $this->batch_analysis_adapter, 'submit', 10 ); |
|
| 1376 | - $this->loader->add_action( 'wp_ajax_wl_batch_analysis_cancel', $this->batch_analysis_adapter, 'cancel', 10 ); |
|
| 1377 | - $this->loader->add_action( 'wp_ajax_wl_batch_analysis_clear_warning', $this->batch_analysis_adapter, 'clear_warning', 10 ); |
|
| 1378 | - $this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all', 10 ); |
|
| 1372 | + $this->loader->add_filter('mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1); |
|
| 1373 | + $this->loader->add_action('wp_ajax_wl_batch_analysis_submit_auto_selected_posts', $this->batch_analysis_adapter, 'submit_auto_selected_posts', 10); |
|
| 1374 | + $this->loader->add_action('wp_ajax_wl_batch_analysis_submit_all_posts', $this->batch_analysis_adapter, 'submit_all_posts', 10); |
|
| 1375 | + $this->loader->add_action('wp_ajax_wl_batch_analysis_submit', $this->batch_analysis_adapter, 'submit', 10); |
|
| 1376 | + $this->loader->add_action('wp_ajax_wl_batch_analysis_cancel', $this->batch_analysis_adapter, 'cancel', 10); |
|
| 1377 | + $this->loader->add_action('wp_ajax_wl_batch_analysis_clear_warning', $this->batch_analysis_adapter, 'clear_warning', 10); |
|
| 1378 | + $this->loader->add_action('wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all', 10); |
|
| 1379 | 1379 | |
| 1380 | - $this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' ); |
|
| 1381 | - $this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' ); |
|
| 1380 | + $this->loader->add_action('wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create'); |
|
| 1381 | + $this->loader->add_action('wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete'); |
|
| 1382 | 1382 | |
| 1383 | 1383 | // Handle the autocomplete request. |
| 1384 | - add_action( 'wp_ajax_wl_autocomplete', array( |
|
| 1384 | + add_action('wp_ajax_wl_autocomplete', array( |
|
| 1385 | 1385 | $this->autocomplete_adapter, |
| 1386 | 1386 | 'wl_autocomplete', |
| 1387 | - ) ); |
|
| 1388 | - add_action( 'wp_ajax_nopriv_wl_autocomplete', array( |
|
| 1387 | + )); |
|
| 1388 | + add_action('wp_ajax_nopriv_wl_autocomplete', array( |
|
| 1389 | 1389 | $this->autocomplete_adapter, |
| 1390 | 1390 | 'wl_autocomplete', |
| 1391 | - ) ); |
|
| 1391 | + )); |
|
| 1392 | 1392 | |
| 1393 | 1393 | // Hooks to restrict multisite super admin from manipulating entity types. |
| 1394 | - if ( is_multisite() ) { |
|
| 1395 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 ); |
|
| 1394 | + if (is_multisite()) { |
|
| 1395 | + $this->loader->add_filter('map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4); |
|
| 1396 | 1396 | } |
| 1397 | 1397 | |
| 1398 | 1398 | } |
@@ -1406,49 +1406,49 @@ discard block |
||
| 1406 | 1406 | */ |
| 1407 | 1407 | private function define_public_hooks() { |
| 1408 | 1408 | |
| 1409 | - $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 1409 | + $plugin_public = new Wordlift_Public($this->get_plugin_name(), $this->get_version()); |
|
| 1410 | 1410 | |
| 1411 | 1411 | // Register the entity post type. |
| 1412 | - $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' ); |
|
| 1412 | + $this->loader->add_action('init', $this->entity_post_type_service, 'register'); |
|
| 1413 | 1413 | |
| 1414 | 1414 | // Bind the link generation and handling hooks to the entity link service. |
| 1415 | - $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 1416 | - $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 ); |
|
| 1417 | - $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 ); |
|
| 1418 | - $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 ); |
|
| 1415 | + $this->loader->add_filter('post_type_link', $this->entity_link_service, 'post_type_link', 10, 4); |
|
| 1416 | + $this->loader->add_action('pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1); |
|
| 1417 | + $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); |
|
| 1418 | + $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); |
|
| 1419 | 1419 | |
| 1420 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 1421 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 1420 | + $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles'); |
|
| 1421 | + $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts'); |
|
| 1422 | 1422 | |
| 1423 | 1423 | // Hook the content filter service to add entity links. |
| 1424 | - $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' ); |
|
| 1424 | + $this->loader->add_filter('the_content', $this->content_filter_service, 'the_content'); |
|
| 1425 | 1425 | |
| 1426 | 1426 | // Hook the AJAX wl_timeline action to the Timeline service. |
| 1427 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1427 | + $this->loader->add_action('wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline'); |
|
| 1428 | 1428 | |
| 1429 | 1429 | // Hook the ShareThis service. |
| 1430 | - $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 1431 | - $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 1430 | + $this->loader->add_filter('the_content', $this->sharethis_service, 'the_content', 99); |
|
| 1431 | + $this->loader->add_filter('the_excerpt', $this->sharethis_service, 'the_excerpt', 99); |
|
| 1432 | 1432 | |
| 1433 | 1433 | // Hook the AJAX wl_jsonld action to the JSON-LD service. |
| 1434 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1434 | + $this->loader->add_action('wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get'); |
|
| 1435 | 1435 | |
| 1436 | 1436 | // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service` |
| 1437 | 1437 | // in order to tweak WP's `WP_Query` to include entities in queries related |
| 1438 | 1438 | // to categories. |
| 1439 | - $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 ); |
|
| 1439 | + $this->loader->add_action('pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1); |
|
| 1440 | 1440 | |
| 1441 | 1441 | /* |
| 1442 | 1442 | * Hook the `pre_get_posts` action to the `Wordlift_Entity_Page_Service` |
| 1443 | 1443 | * in order to tweak WP's `WP_Query` to show event related entities in reverse |
| 1444 | 1444 | * order of start time. |
| 1445 | 1445 | */ |
| 1446 | - $this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 ); |
|
| 1446 | + $this->loader->add_action('pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1); |
|
| 1447 | 1447 | |
| 1448 | - $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1448 | + $this->loader->add_action('wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1); |
|
| 1449 | 1449 | |
| 1450 | 1450 | // This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done. |
| 1451 | - $this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 ); |
|
| 1451 | + $this->loader->add_action('save_post', $this->entity_type_adapter, 'save_post', 9, 3); |
|
| 1452 | 1452 | |
| 1453 | 1453 | } |
| 1454 | 1454 | |