@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | // If this file is called directly, abort. |
| 51 | 51 | if ( ! defined( 'WPINC' ) ) { |
| 52 | - die; |
|
| 52 | + die; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php'; |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | function wl_write_log( $log ) { |
| 74 | 74 | |
| 75 | - Wordlift_Log_Service::get_instance()->debug( $log ); |
|
| 75 | + Wordlift_Log_Service::get_instance()->debug( $log ); |
|
| 76 | 76 | |
| 77 | 77 | } |
| 78 | 78 | |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | function wl_write_log_hide_key( $text ) { |
| 91 | 91 | |
| 92 | - return str_ireplace( wl_configuration_get_key(), '<hidden>', $text ); |
|
| 92 | + return str_ireplace( wl_configuration_get_key(), '<hidden>', $text ); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -97,21 +97,21 @@ discard block |
||
| 97 | 97 | * see http://vip.wordpress.com/documentation/register-additional-html-attributes-for-tinymce-and-wp-kses/ |
| 98 | 98 | */ |
| 99 | 99 | function wordlift_allowed_post_tags() { |
| 100 | - global $allowedposttags; |
|
| 101 | - |
|
| 102 | - $tags = array( 'span' ); |
|
| 103 | - $new_attributes = array( |
|
| 104 | - 'itemscope' => array(), |
|
| 105 | - 'itemtype' => array(), |
|
| 106 | - 'itemprop' => array(), |
|
| 107 | - 'itemid' => array(), |
|
| 108 | - ); |
|
| 109 | - |
|
| 110 | - foreach ( $tags as $tag ) { |
|
| 111 | - if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) { |
|
| 112 | - $allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes ); |
|
| 113 | - } |
|
| 114 | - } |
|
| 100 | + global $allowedposttags; |
|
| 101 | + |
|
| 102 | + $tags = array( 'span' ); |
|
| 103 | + $new_attributes = array( |
|
| 104 | + 'itemscope' => array(), |
|
| 105 | + 'itemtype' => array(), |
|
| 106 | + 'itemprop' => array(), |
|
| 107 | + 'itemid' => array(), |
|
| 108 | + ); |
|
| 109 | + |
|
| 110 | + foreach ( $tags as $tag ) { |
|
| 111 | + if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) { |
|
| 112 | + $allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes ); |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | // add allowed post tags. |
@@ -122,18 +122,18 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | function wordlift_admin_enqueue_scripts() { |
| 124 | 124 | |
| 125 | - // Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/) |
|
| 126 | - wp_enqueue_script( 'wpdialogs' ); |
|
| 127 | - wp_enqueue_style( 'wp-jquery-ui-dialog' ); |
|
| 125 | + // Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/) |
|
| 126 | + wp_enqueue_script( 'wpdialogs' ); |
|
| 127 | + wp_enqueue_style( 'wp-jquery-ui-dialog' ); |
|
| 128 | 128 | |
| 129 | - wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css' ); |
|
| 129 | + wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css' ); |
|
| 130 | 130 | |
| 131 | - wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
| 131 | + wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
| 132 | 132 | |
| 133 | - // Disable auto-save for custom entity posts only |
|
| 134 | - if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) { |
|
| 135 | - wp_dequeue_script( 'autosave' ); |
|
| 136 | - } |
|
| 133 | + // Disable auto-save for custom entity posts only |
|
| 134 | + if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) { |
|
| 135 | + wp_dequeue_script( 'autosave' ); |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | 138 | } |
| 139 | 139 | |
@@ -149,18 +149,18 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | function wordlift_allowed_html( $allowedtags, $context ) { |
| 151 | 151 | |
| 152 | - if ( 'post' !== $context ) { |
|
| 153 | - return $allowedtags; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - return array_merge_recursive( $allowedtags, array( |
|
| 157 | - 'span' => array( |
|
| 158 | - 'itemscope' => true, |
|
| 159 | - 'itemtype' => true, |
|
| 160 | - 'itemid' => true, |
|
| 161 | - 'itemprop' => true, |
|
| 162 | - ), |
|
| 163 | - ) ); |
|
| 152 | + if ( 'post' !== $context ) { |
|
| 153 | + return $allowedtags; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + return array_merge_recursive( $allowedtags, array( |
|
| 157 | + 'span' => array( |
|
| 158 | + 'itemscope' => true, |
|
| 159 | + 'itemtype' => true, |
|
| 160 | + 'itemid' => true, |
|
| 161 | + 'itemprop' => true, |
|
| 162 | + ), |
|
| 163 | + ) ); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | add_filter( 'wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2 ); |
@@ -174,16 +174,16 @@ discard block |
||
| 174 | 174 | */ |
| 175 | 175 | function wl_get_coordinates( $post_id ) { |
| 176 | 176 | |
| 177 | - $latitude = wl_schema_get_value( $post_id, 'latitude' ); |
|
| 178 | - $longitude = wl_schema_get_value( $post_id, 'longitude' ); |
|
| 177 | + $latitude = wl_schema_get_value( $post_id, 'latitude' ); |
|
| 178 | + $longitude = wl_schema_get_value( $post_id, 'longitude' ); |
|
| 179 | 179 | |
| 180 | - // DO NOT set latitude/longitude to 0/0 as default values. It's a specific |
|
| 181 | - // place on the globe:"The zero/zero point of this system is located in the |
|
| 182 | - // Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana." |
|
| 183 | - return array( |
|
| 184 | - 'latitude' => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '', |
|
| 185 | - 'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '', |
|
| 186 | - ); |
|
| 180 | + // DO NOT set latitude/longitude to 0/0 as default values. It's a specific |
|
| 181 | + // place on the globe:"The zero/zero point of this system is located in the |
|
| 182 | + // Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana." |
|
| 183 | + return array( |
|
| 184 | + 'latitude' => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '', |
|
| 185 | + 'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '', |
|
| 186 | + ); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | /** |
@@ -197,9 +197,9 @@ discard block |
||
| 197 | 197 | */ |
| 198 | 198 | function wl_get_image_urls( $post_id ) { |
| 199 | 199 | |
| 200 | - return Wordlift_Storage_Factory::get_instance() |
|
| 201 | - ->post_images() |
|
| 202 | - ->get( $post_id ); |
|
| 200 | + return Wordlift_Storage_Factory::get_instance() |
|
| 201 | + ->post_images() |
|
| 202 | + ->get( $post_id ); |
|
| 203 | 203 | |
| 204 | 204 | } |
| 205 | 205 | |
@@ -213,24 +213,24 @@ discard block |
||
| 213 | 213 | */ |
| 214 | 214 | function wl_get_attachment_for_source_url( $parent_post_id, $source_url ) { |
| 215 | 215 | |
| 216 | - // wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" ); |
|
| 216 | + // wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" ); |
|
| 217 | 217 | |
| 218 | - $posts = get_posts( array( |
|
| 219 | - 'post_type' => 'attachment', |
|
| 220 | - 'posts_per_page' => 1, |
|
| 221 | - 'post_status' => 'any', |
|
| 222 | - 'post_parent' => $parent_post_id, |
|
| 223 | - 'meta_key' => 'wl_source_url', |
|
| 224 | - 'meta_value' => $source_url, |
|
| 225 | - ) ); |
|
| 218 | + $posts = get_posts( array( |
|
| 219 | + 'post_type' => 'attachment', |
|
| 220 | + 'posts_per_page' => 1, |
|
| 221 | + 'post_status' => 'any', |
|
| 222 | + 'post_parent' => $parent_post_id, |
|
| 223 | + 'meta_key' => 'wl_source_url', |
|
| 224 | + 'meta_value' => $source_url, |
|
| 225 | + ) ); |
|
| 226 | 226 | |
| 227 | - // Return the found post. |
|
| 228 | - if ( 1 === count( $posts ) ) { |
|
| 229 | - return $posts[0]; |
|
| 230 | - } |
|
| 227 | + // Return the found post. |
|
| 228 | + if ( 1 === count( $posts ) ) { |
|
| 229 | + return $posts[0]; |
|
| 230 | + } |
|
| 231 | 231 | |
| 232 | - // Return null. |
|
| 233 | - return null; |
|
| 232 | + // Return null. |
|
| 233 | + return null; |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /** |
@@ -241,8 +241,8 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | function wl_set_source_url( $post_id, $source_url ) { |
| 243 | 243 | |
| 244 | - delete_post_meta( $post_id, 'wl_source_url' ); |
|
| 245 | - add_post_meta( $post_id, 'wl_source_url', $source_url ); |
|
| 244 | + delete_post_meta( $post_id, 'wl_source_url' ); |
|
| 245 | + add_post_meta( $post_id, 'wl_source_url', $source_url ); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | /** |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | */ |
| 260 | 260 | function wl_sanitize_uri_path( $path, $char = '_' ) { |
| 261 | 261 | |
| 262 | - return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char ); |
|
| 262 | + return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char ); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | /** |
@@ -271,47 +271,47 @@ discard block |
||
| 271 | 271 | */ |
| 272 | 272 | function wl_replace_item_id_with_uri( $content ) { |
| 273 | 273 | |
| 274 | - $log = Wordlift_Log_Service::get_logger( 'wl_replace_item_id_with_uri' ); |
|
| 275 | - $log->trace( 'Replacing item IDs with URIs...' ); |
|
| 274 | + $log = Wordlift_Log_Service::get_logger( 'wl_replace_item_id_with_uri' ); |
|
| 275 | + $log->trace( 'Replacing item IDs with URIs...' ); |
|
| 276 | 276 | |
| 277 | - // Strip slashes, see https://core.trac.wordpress.org/ticket/21767 |
|
| 278 | - $content = stripslashes( $content ); |
|
| 277 | + // Strip slashes, see https://core.trac.wordpress.org/ticket/21767 |
|
| 278 | + $content = stripslashes( $content ); |
|
| 279 | 279 | |
| 280 | - // If any match are found. |
|
| 281 | - $matches = array(); |
|
| 282 | - if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) { |
|
| 280 | + // If any match are found. |
|
| 281 | + $matches = array(); |
|
| 282 | + if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) { |
|
| 283 | 283 | |
| 284 | - foreach ( $matches as $match ) { |
|
| 284 | + foreach ( $matches as $match ) { |
|
| 285 | 285 | |
| 286 | - // Get the item ID. |
|
| 287 | - $item_id = $match[1]; |
|
| 286 | + // Get the item ID. |
|
| 287 | + $item_id = $match[1]; |
|
| 288 | 288 | |
| 289 | - // Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' . |
|
| 290 | - $post = Wordlift_Entity_Service::get_instance() |
|
| 291 | - ->get_entity_post_by_uri( $item_id ); |
|
| 289 | + // Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' . |
|
| 290 | + $post = Wordlift_Entity_Service::get_instance() |
|
| 291 | + ->get_entity_post_by_uri( $item_id ); |
|
| 292 | 292 | |
| 293 | - // If no entity is found, continue to the next one. |
|
| 294 | - if ( null === $post ) { |
|
| 295 | - continue; |
|
| 296 | - } |
|
| 293 | + // If no entity is found, continue to the next one. |
|
| 294 | + if ( null === $post ) { |
|
| 295 | + continue; |
|
| 296 | + } |
|
| 297 | 297 | |
| 298 | - // Get the URI for that post. |
|
| 299 | - $uri = wl_get_entity_uri( $post->ID ); |
|
| 298 | + // Get the URI for that post. |
|
| 299 | + $uri = wl_get_entity_uri( $post->ID ); |
|
| 300 | 300 | |
| 301 | - // wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" ); |
|
| 301 | + // wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" ); |
|
| 302 | 302 | |
| 303 | - // If the item ID and the URI differ, replace the item ID with the URI saved in WordPress. |
|
| 304 | - if ( ! empty( $uri ) && $item_id !== $uri ) { |
|
| 305 | - $uri_e = esc_html( $uri ); |
|
| 306 | - $content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content ); |
|
| 307 | - } |
|
| 308 | - } |
|
| 309 | - } |
|
| 303 | + // If the item ID and the URI differ, replace the item ID with the URI saved in WordPress. |
|
| 304 | + if ( ! empty( $uri ) && $item_id !== $uri ) { |
|
| 305 | + $uri_e = esc_html( $uri ); |
|
| 306 | + $content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content ); |
|
| 307 | + } |
|
| 308 | + } |
|
| 309 | + } |
|
| 310 | 310 | |
| 311 | - // Reapply slashes. |
|
| 312 | - $content = addslashes( $content ); |
|
| 311 | + // Reapply slashes. |
|
| 312 | + $content = addslashes( $content ); |
|
| 313 | 313 | |
| 314 | - return $content; |
|
| 314 | + return $content; |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | add_filter( 'content_save_pre', 'wl_replace_item_id_with_uri', 1, 1 ); |
@@ -374,29 +374,29 @@ discard block |
||
| 374 | 374 | */ |
| 375 | 375 | function activate_wordlift() { |
| 376 | 376 | |
| 377 | - $log = Wordlift_Log_Service::get_logger( 'activate_wordlift' ); |
|
| 378 | - |
|
| 379 | - $log->info( 'Activating WordLift...' ); |
|
| 380 | - |
|
| 381 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php'; |
|
| 382 | - Wordlift_Activator::activate(); |
|
| 383 | - |
|
| 384 | - /** |
|
| 385 | - * Tell the {@link Wordlift_Http_Api} class that we're activating, to let it run activation tasks. |
|
| 386 | - * |
|
| 387 | - * @see https://github.com/insideout10/wordlift-plugin/issues/820 related issue. |
|
| 388 | - * @since 3.19.2 |
|
| 389 | - */ |
|
| 390 | - Wordlift_Http_Api::activate(); |
|
| 391 | - |
|
| 392 | - // Ensure the post type is registered before flushing the rewrite rules. |
|
| 393 | - Wordlift_Entity_Post_Type_Service::get_instance()->register(); |
|
| 394 | - flush_rewrite_rules(); |
|
| 395 | - /** |
|
| 396 | - * @since 3.27.7 |
|
| 397 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
| 398 | - */ |
|
| 399 | - Top_Entities::activate(); |
|
| 377 | + $log = Wordlift_Log_Service::get_logger( 'activate_wordlift' ); |
|
| 378 | + |
|
| 379 | + $log->info( 'Activating WordLift...' ); |
|
| 380 | + |
|
| 381 | + require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php'; |
|
| 382 | + Wordlift_Activator::activate(); |
|
| 383 | + |
|
| 384 | + /** |
|
| 385 | + * Tell the {@link Wordlift_Http_Api} class that we're activating, to let it run activation tasks. |
|
| 386 | + * |
|
| 387 | + * @see https://github.com/insideout10/wordlift-plugin/issues/820 related issue. |
|
| 388 | + * @since 3.19.2 |
|
| 389 | + */ |
|
| 390 | + Wordlift_Http_Api::activate(); |
|
| 391 | + |
|
| 392 | + // Ensure the post type is registered before flushing the rewrite rules. |
|
| 393 | + Wordlift_Entity_Post_Type_Service::get_instance()->register(); |
|
| 394 | + flush_rewrite_rules(); |
|
| 395 | + /** |
|
| 396 | + * @since 3.27.7 |
|
| 397 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
| 398 | + */ |
|
| 399 | + Top_Entities::activate(); |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | /** |
@@ -405,16 +405,16 @@ discard block |
||
| 405 | 405 | */ |
| 406 | 406 | function deactivate_wordlift() { |
| 407 | 407 | |
| 408 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php'; |
|
| 409 | - Wordlift_Deactivator::deactivate(); |
|
| 410 | - Wordlift_Http_Api::deactivate(); |
|
| 411 | - Ttl_Cache_Cleaner::deactivate(); |
|
| 412 | - /** |
|
| 413 | - * @since 3.27.7 |
|
| 414 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
| 415 | - */ |
|
| 416 | - Top_Entities::deactivate(); |
|
| 417 | - flush_rewrite_rules(); |
|
| 408 | + require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php'; |
|
| 409 | + Wordlift_Deactivator::deactivate(); |
|
| 410 | + Wordlift_Http_Api::deactivate(); |
|
| 411 | + Ttl_Cache_Cleaner::deactivate(); |
|
| 412 | + /** |
|
| 413 | + * @since 3.27.7 |
|
| 414 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
| 415 | + */ |
|
| 416 | + Top_Entities::deactivate(); |
|
| 417 | + flush_rewrite_rules(); |
|
| 418 | 418 | |
| 419 | 419 | } |
| 420 | 420 | |
@@ -437,98 +437,98 @@ discard block |
||
| 437 | 437 | * @since 1.0.0 |
| 438 | 438 | */ |
| 439 | 439 | function run_wordlift() { |
| 440 | - /** |
|
| 441 | - * Filter: wl_feature__enable__widgets. |
|
| 442 | - * |
|
| 443 | - * @param bool whether the widgets needed to be registered, defaults to true. |
|
| 444 | - * |
|
| 445 | - * @return bool |
|
| 446 | - * @since 3.27.6 |
|
| 447 | - */ |
|
| 448 | - if ( apply_filters( 'wl_feature__enable__widgets', true ) ) { |
|
| 449 | - add_action( 'widgets_init', 'wl_register_chord_widget' ); |
|
| 450 | - add_action( 'widgets_init', 'wl_register_geo_widget' ); |
|
| 451 | - add_action( 'widgets_init', 'wl_register_timeline_widget' ); |
|
| 452 | - } |
|
| 453 | - add_filter( 'widget_text', 'do_shortcode' ); |
|
| 454 | - |
|
| 455 | - |
|
| 456 | - /** |
|
| 457 | - * Filter: wl_feature__enable__analysis |
|
| 458 | - * |
|
| 459 | - * @param bool Whether to send api request to analysis or not |
|
| 460 | - * |
|
| 461 | - * @return bool |
|
| 462 | - * @since 3.27.6 |
|
| 463 | - */ |
|
| 464 | - if ( apply_filters( 'wl_feature__enable__analysis', true ) ) { |
|
| 465 | - add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_action' ); |
|
| 466 | - } else { |
|
| 467 | - add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action' ); |
|
| 468 | - } |
|
| 469 | - |
|
| 470 | - /* |
|
| 440 | + /** |
|
| 441 | + * Filter: wl_feature__enable__widgets. |
|
| 442 | + * |
|
| 443 | + * @param bool whether the widgets needed to be registered, defaults to true. |
|
| 444 | + * |
|
| 445 | + * @return bool |
|
| 446 | + * @since 3.27.6 |
|
| 447 | + */ |
|
| 448 | + if ( apply_filters( 'wl_feature__enable__widgets', true ) ) { |
|
| 449 | + add_action( 'widgets_init', 'wl_register_chord_widget' ); |
|
| 450 | + add_action( 'widgets_init', 'wl_register_geo_widget' ); |
|
| 451 | + add_action( 'widgets_init', 'wl_register_timeline_widget' ); |
|
| 452 | + } |
|
| 453 | + add_filter( 'widget_text', 'do_shortcode' ); |
|
| 454 | + |
|
| 455 | + |
|
| 456 | + /** |
|
| 457 | + * Filter: wl_feature__enable__analysis |
|
| 458 | + * |
|
| 459 | + * @param bool Whether to send api request to analysis or not |
|
| 460 | + * |
|
| 461 | + * @return bool |
|
| 462 | + * @since 3.27.6 |
|
| 463 | + */ |
|
| 464 | + if ( apply_filters( 'wl_feature__enable__analysis', true ) ) { |
|
| 465 | + add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_action' ); |
|
| 466 | + } else { |
|
| 467 | + add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action' ); |
|
| 468 | + } |
|
| 469 | + |
|
| 470 | + /* |
|
| 471 | 471 | * We introduce the WordLift autoloader, since we start using classes in namespaces, i.e. Wordlift\Http. |
| 472 | 472 | * |
| 473 | 473 | * @since 3.21.2 |
| 474 | 474 | */ |
| 475 | - wordlift_plugin_autoload_register(); |
|
| 475 | + wordlift_plugin_autoload_register(); |
|
| 476 | 476 | |
| 477 | - $plugin = new Wordlift(); |
|
| 478 | - $plugin->run(); |
|
| 477 | + $plugin = new Wordlift(); |
|
| 478 | + $plugin->run(); |
|
| 479 | 479 | |
| 480 | - // Initialize the TTL Cache Cleaner. |
|
| 481 | - new Ttl_Cache_Cleaner(); |
|
| 480 | + // Initialize the TTL Cache Cleaner. |
|
| 481 | + new Ttl_Cache_Cleaner(); |
|
| 482 | 482 | |
| 483 | - // Load the new Post Adapter. |
|
| 484 | - new Post_Adapter(); |
|
| 483 | + // Load the new Post Adapter. |
|
| 484 | + new Post_Adapter(); |
|
| 485 | 485 | |
| 486 | - // Load the API Data Hooks. |
|
| 487 | - new Api_Data_Hooks(); |
|
| 486 | + // Load the API Data Hooks. |
|
| 487 | + new Api_Data_Hooks(); |
|
| 488 | 488 | |
| 489 | - add_action( 'plugins_loaded', function () use ( $plugin ) { |
|
| 490 | - // Load early. **PLEASE NOTE** that features are applied only to calls that happen **AFTER** the `plugins_loaded` |
|
| 491 | - // action. |
|
| 492 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/features/index.php'; |
|
| 489 | + add_action( 'plugins_loaded', function () use ( $plugin ) { |
|
| 490 | + // Load early. **PLEASE NOTE** that features are applied only to calls that happen **AFTER** the `plugins_loaded` |
|
| 491 | + // action. |
|
| 492 | + require_once plugin_dir_path( __FILE__ ) . 'wordlift/features/index.php'; |
|
| 493 | 493 | |
| 494 | - // Licenses Images. |
|
| 495 | - $user_agent = User_Agent::get_user_agent(); |
|
| 496 | - $wordlift_key = Wordlift_Configuration_Service::get_instance()->get_key(); |
|
| 497 | - $api_service = new Default_Api_Service( apply_filters( 'wl_api_base_url', WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE ), 60, $user_agent, $wordlift_key ); |
|
| 498 | - $image_license_factory = new Image_License_Factory(); |
|
| 499 | - $image_license_service = new Image_License_Service( $api_service, $image_license_factory ); |
|
| 500 | - $image_license_cache = new Ttl_Cache( 'image-license', 86400 * 30 ); // 30 days. |
|
| 501 | - $cached_image_license_service = new Cached_Image_License_Service( $image_license_service, $image_license_cache ); |
|
| 494 | + // Licenses Images. |
|
| 495 | + $user_agent = User_Agent::get_user_agent(); |
|
| 496 | + $wordlift_key = Wordlift_Configuration_Service::get_instance()->get_key(); |
|
| 497 | + $api_service = new Default_Api_Service( apply_filters( 'wl_api_base_url', WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE ), 60, $user_agent, $wordlift_key ); |
|
| 498 | + $image_license_factory = new Image_License_Factory(); |
|
| 499 | + $image_license_service = new Image_License_Service( $api_service, $image_license_factory ); |
|
| 500 | + $image_license_cache = new Ttl_Cache( 'image-license', 86400 * 30 ); // 30 days. |
|
| 501 | + $cached_image_license_service = new Cached_Image_License_Service( $image_license_service, $image_license_cache ); |
|
| 502 | 502 | |
| 503 | - $image_license_scheduler = new Image_License_Scheduler( $image_license_service, $image_license_cache ); |
|
| 504 | - $image_license_cleanup_service = new Image_License_Cleanup_Service(); |
|
| 503 | + $image_license_scheduler = new Image_License_Scheduler( $image_license_service, $image_license_cache ); |
|
| 504 | + $image_license_cleanup_service = new Image_License_Cleanup_Service(); |
|
| 505 | 505 | |
| 506 | - // Get the cached data. If we have cached data, we load the notifier. |
|
| 507 | - $image_license_data = $image_license_cache->get( Cached_Image_License_Service::GET_NON_PUBLIC_DOMAIN_IMAGES ); |
|
| 508 | - if ( null !== $image_license_data ) { |
|
| 509 | - $image_license_page = new Image_License_Page( $image_license_data, Wordlift::get_instance()->get_version() ); |
|
| 510 | - new Image_License_Notifier( $image_license_data, $image_license_page ); |
|
| 511 | - } |
|
| 506 | + // Get the cached data. If we have cached data, we load the notifier. |
|
| 507 | + $image_license_data = $image_license_cache->get( Cached_Image_License_Service::GET_NON_PUBLIC_DOMAIN_IMAGES ); |
|
| 508 | + if ( null !== $image_license_data ) { |
|
| 509 | + $image_license_page = new Image_License_Page( $image_license_data, Wordlift::get_instance()->get_version() ); |
|
| 510 | + new Image_License_Notifier( $image_license_data, $image_license_page ); |
|
| 511 | + } |
|
| 512 | 512 | |
| 513 | - $remove_all_images_task = new Remove_All_Images_Task( $cached_image_license_service ); |
|
| 514 | - $remove_all_images_task_adapter = new Task_Ajax_Adapter( $remove_all_images_task ); |
|
| 513 | + $remove_all_images_task = new Remove_All_Images_Task( $cached_image_license_service ); |
|
| 514 | + $remove_all_images_task_adapter = new Task_Ajax_Adapter( $remove_all_images_task ); |
|
| 515 | 515 | |
| 516 | - $reload_data_task = new Reload_Data_Task(); |
|
| 517 | - $reload_data_task_adapter = new Task_Ajax_Adapter( $reload_data_task ); |
|
| 516 | + $reload_data_task = new Reload_Data_Task(); |
|
| 517 | + $reload_data_task_adapter = new Task_Ajax_Adapter( $reload_data_task ); |
|
| 518 | 518 | |
| 519 | - $add_license_caption_or_remove_task = new Add_License_Caption_Or_Remove_Task( $cached_image_license_service ); |
|
| 520 | - $add_license_caption_or_remove_task_adapter = new Task_Ajax_Adapter( $add_license_caption_or_remove_task ); |
|
| 519 | + $add_license_caption_or_remove_task = new Add_License_Caption_Or_Remove_Task( $cached_image_license_service ); |
|
| 520 | + $add_license_caption_or_remove_task_adapter = new Task_Ajax_Adapter( $add_license_caption_or_remove_task ); |
|
| 521 | 521 | |
| 522 | - $remove_all_images_task_page = new Remove_All_Images_Page( new Task_Ajax_Adapters_Registry( $remove_all_images_task_adapter ), $plugin->get_version() ); |
|
| 523 | - $reload_data_task_page = new Reload_Data_Page( new Task_Ajax_Adapters_Registry( $reload_data_task_adapter ), $plugin->get_version() ); |
|
| 524 | - $add_license_caption_or_remove_task_page = new Add_License_Caption_Or_Remove_Page( new Task_Ajax_Adapters_Registry( $add_license_caption_or_remove_task_adapter ), $plugin->get_version() ); |
|
| 522 | + $remove_all_images_task_page = new Remove_All_Images_Page( new Task_Ajax_Adapters_Registry( $remove_all_images_task_adapter ), $plugin->get_version() ); |
|
| 523 | + $reload_data_task_page = new Reload_Data_Page( new Task_Ajax_Adapters_Registry( $reload_data_task_adapter ), $plugin->get_version() ); |
|
| 524 | + $add_license_caption_or_remove_task_page = new Add_License_Caption_Or_Remove_Page( new Task_Ajax_Adapters_Registry( $add_license_caption_or_remove_task_adapter ), $plugin->get_version() ); |
|
| 525 | 525 | |
| 526 | - new Wordlift_Products_Navigator_Shortcode_REST(); |
|
| 526 | + new Wordlift_Products_Navigator_Shortcode_REST(); |
|
| 527 | 527 | |
| 528 | - // Register the Dataset module, requires `$api_service`. |
|
| 529 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/dataset/index.php'; |
|
| 528 | + // Register the Dataset module, requires `$api_service`. |
|
| 529 | + require_once plugin_dir_path( __FILE__ ) . 'wordlift/dataset/index.php'; |
|
| 530 | 530 | |
| 531 | - } ); |
|
| 531 | + } ); |
|
| 532 | 532 | |
| 533 | 533 | } |
| 534 | 534 | |
@@ -542,45 +542,45 @@ discard block |
||
| 542 | 542 | */ |
| 543 | 543 | function wordlift_plugin_autoload_register() { |
| 544 | 544 | |
| 545 | - spl_autoload_register( function ( $class_name ) { |
|
| 545 | + spl_autoload_register( function ( $class_name ) { |
|
| 546 | 546 | |
| 547 | - // Bail out if these are not our classes. |
|
| 548 | - if ( 0 !== strpos( $class_name, 'Wordlift\\' ) ) { |
|
| 549 | - return false; |
|
| 550 | - } |
|
| 547 | + // Bail out if these are not our classes. |
|
| 548 | + if ( 0 !== strpos( $class_name, 'Wordlift\\' ) ) { |
|
| 549 | + return false; |
|
| 550 | + } |
|
| 551 | 551 | |
| 552 | - $class_name_lc = strtolower( str_replace( '_', '-', $class_name ) ); |
|
| 552 | + $class_name_lc = strtolower( str_replace( '_', '-', $class_name ) ); |
|
| 553 | 553 | |
| 554 | - preg_match( '|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches ); |
|
| 554 | + preg_match( '|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches ); |
|
| 555 | 555 | |
| 556 | - $path = str_replace( '\\', DIRECTORY_SEPARATOR, $matches[1] ); |
|
| 557 | - $file = 'class-' . $matches[2] . '.php'; |
|
| 556 | + $path = str_replace( '\\', DIRECTORY_SEPARATOR, $matches[1] ); |
|
| 557 | + $file = 'class-' . $matches[2] . '.php'; |
|
| 558 | 558 | |
| 559 | - $full_path = plugin_dir_path( __FILE__ ) . $path . DIRECTORY_SEPARATOR . $file; |
|
| 559 | + $full_path = plugin_dir_path( __FILE__ ) . $path . DIRECTORY_SEPARATOR . $file; |
|
| 560 | 560 | |
| 561 | - if ( ! file_exists( $full_path ) ) { |
|
| 562 | - echo( "Class $class_name not found at $full_path." ); |
|
| 561 | + if ( ! file_exists( $full_path ) ) { |
|
| 562 | + echo( "Class $class_name not found at $full_path." ); |
|
| 563 | 563 | |
| 564 | - return false; |
|
| 565 | - } |
|
| 564 | + return false; |
|
| 565 | + } |
|
| 566 | 566 | |
| 567 | - require_once $full_path; |
|
| 567 | + require_once $full_path; |
|
| 568 | 568 | |
| 569 | - return true; |
|
| 570 | - } ); |
|
| 569 | + return true; |
|
| 570 | + } ); |
|
| 571 | 571 | |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | function wl_block_categories( $categories, $post ) { |
| 575 | - return array_merge( |
|
| 576 | - $categories, |
|
| 577 | - array( |
|
| 578 | - array( |
|
| 579 | - 'slug' => 'wordlift', |
|
| 580 | - 'title' => __( 'WordLift', 'wordlift' ), |
|
| 581 | - ), |
|
| 582 | - ) |
|
| 583 | - ); |
|
| 575 | + return array_merge( |
|
| 576 | + $categories, |
|
| 577 | + array( |
|
| 578 | + array( |
|
| 579 | + 'slug' => 'wordlift', |
|
| 580 | + 'title' => __( 'WordLift', 'wordlift' ), |
|
| 581 | + ), |
|
| 582 | + ) |
|
| 583 | + ); |
|
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | add_filter( 'block_categories', 'wl_block_categories', 10, 2 ); |
@@ -48,17 +48,17 @@ discard block |
||
| 48 | 48 | use Wordlift\Tasks\Task_Ajax_Adapters_Registry; |
| 49 | 49 | |
| 50 | 50 | // If this file is called directly, abort. |
| 51 | -if ( ! defined( 'WPINC' ) ) { |
|
| 51 | +if ( ! defined('WPINC')) { |
|
| 52 | 52 | die; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | -require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php'; |
|
| 55 | +require_once plugin_dir_path(__FILE__).'vendor/autoload.php'; |
|
| 56 | 56 | |
| 57 | 57 | // Include WordLift constants. |
| 58 | -require_once( 'wordlift_constants.php' ); |
|
| 58 | +require_once('wordlift_constants.php'); |
|
| 59 | 59 | |
| 60 | 60 | // Load modules. |
| 61 | -require_once( 'modules/core/wordlift_core.php' ); |
|
| 61 | +require_once('modules/core/wordlift_core.php'); |
|
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | 64 | * Log to the debug.log file. |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | * @deprecated use Wordlift_Log_Service::get_instance()->info( $log ); |
| 71 | 71 | * |
| 72 | 72 | */ |
| 73 | -function wl_write_log( $log ) { |
|
| 73 | +function wl_write_log($log) { |
|
| 74 | 74 | |
| 75 | - Wordlift_Log_Service::get_instance()->debug( $log ); |
|
| 75 | + Wordlift_Log_Service::get_instance()->debug($log); |
|
| 76 | 76 | |
| 77 | 77 | } |
| 78 | 78 | |
@@ -87,9 +87,9 @@ discard block |
||
| 87 | 87 | * @since 3.0.0 |
| 88 | 88 | * |
| 89 | 89 | */ |
| 90 | -function wl_write_log_hide_key( $text ) { |
|
| 90 | +function wl_write_log_hide_key($text) { |
|
| 91 | 91 | |
| 92 | - return str_ireplace( wl_configuration_get_key(), '<hidden>', $text ); |
|
| 92 | + return str_ireplace(wl_configuration_get_key(), '<hidden>', $text); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | function wordlift_allowed_post_tags() { |
| 100 | 100 | global $allowedposttags; |
| 101 | 101 | |
| 102 | - $tags = array( 'span' ); |
|
| 102 | + $tags = array('span'); |
|
| 103 | 103 | $new_attributes = array( |
| 104 | 104 | 'itemscope' => array(), |
| 105 | 105 | 'itemtype' => array(), |
@@ -107,15 +107,15 @@ discard block |
||
| 107 | 107 | 'itemid' => array(), |
| 108 | 108 | ); |
| 109 | 109 | |
| 110 | - foreach ( $tags as $tag ) { |
|
| 111 | - if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) { |
|
| 112 | - $allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes ); |
|
| 110 | + foreach ($tags as $tag) { |
|
| 111 | + if (isset($allowedposttags[$tag]) && is_array($allowedposttags[$tag])) { |
|
| 112 | + $allowedposttags[$tag] = array_merge($allowedposttags[$tag], $new_attributes); |
|
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | // add allowed post tags. |
| 118 | -add_action( 'init', 'wordlift_allowed_post_tags' ); |
|
| 118 | +add_action('init', 'wordlift_allowed_post_tags'); |
|
| 119 | 119 | |
| 120 | 120 | /** |
| 121 | 121 | * Register additional scripts for the admin UI. |
@@ -123,21 +123,21 @@ discard block |
||
| 123 | 123 | function wordlift_admin_enqueue_scripts() { |
| 124 | 124 | |
| 125 | 125 | // Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/) |
| 126 | - wp_enqueue_script( 'wpdialogs' ); |
|
| 127 | - wp_enqueue_style( 'wp-jquery-ui-dialog' ); |
|
| 126 | + wp_enqueue_script('wpdialogs'); |
|
| 127 | + wp_enqueue_style('wp-jquery-ui-dialog'); |
|
| 128 | 128 | |
| 129 | - wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css' ); |
|
| 129 | + wp_enqueue_style('wordlift-reloaded', plugin_dir_url(__FILE__).'css/wordlift-reloaded.min.css'); |
|
| 130 | 130 | |
| 131 | - wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
| 131 | + wp_enqueue_script('jquery-ui-autocomplete'); |
|
| 132 | 132 | |
| 133 | 133 | // Disable auto-save for custom entity posts only |
| 134 | - if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) { |
|
| 135 | - wp_dequeue_script( 'autosave' ); |
|
| 134 | + if (Wordlift_Entity_Service::TYPE_NAME === get_post_type()) { |
|
| 135 | + wp_dequeue_script('autosave'); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | -add_action( 'admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts' ); |
|
| 140 | +add_action('admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts'); |
|
| 141 | 141 | |
| 142 | 142 | /** |
| 143 | 143 | * Hooked to *wp_kses_allowed_html* filter, adds microdata attributes. |
@@ -147,23 +147,23 @@ discard block |
||
| 147 | 147 | * |
| 148 | 148 | * @return array An array which contains allowed microdata attributes. |
| 149 | 149 | */ |
| 150 | -function wordlift_allowed_html( $allowedtags, $context ) { |
|
| 150 | +function wordlift_allowed_html($allowedtags, $context) { |
|
| 151 | 151 | |
| 152 | - if ( 'post' !== $context ) { |
|
| 152 | + if ('post' !== $context) { |
|
| 153 | 153 | return $allowedtags; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - return array_merge_recursive( $allowedtags, array( |
|
| 156 | + return array_merge_recursive($allowedtags, array( |
|
| 157 | 157 | 'span' => array( |
| 158 | 158 | 'itemscope' => true, |
| 159 | 159 | 'itemtype' => true, |
| 160 | 160 | 'itemid' => true, |
| 161 | 161 | 'itemprop' => true, |
| 162 | 162 | ), |
| 163 | - ) ); |
|
| 163 | + )); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | -add_filter( 'wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2 ); |
|
| 166 | +add_filter('wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2); |
|
| 167 | 167 | |
| 168 | 168 | /** |
| 169 | 169 | * Get the coordinates for the specified post ID. |
@@ -172,17 +172,17 @@ discard block |
||
| 172 | 172 | * |
| 173 | 173 | * @return array|null An array of coordinates or null. |
| 174 | 174 | */ |
| 175 | -function wl_get_coordinates( $post_id ) { |
|
| 175 | +function wl_get_coordinates($post_id) { |
|
| 176 | 176 | |
| 177 | - $latitude = wl_schema_get_value( $post_id, 'latitude' ); |
|
| 178 | - $longitude = wl_schema_get_value( $post_id, 'longitude' ); |
|
| 177 | + $latitude = wl_schema_get_value($post_id, 'latitude'); |
|
| 178 | + $longitude = wl_schema_get_value($post_id, 'longitude'); |
|
| 179 | 179 | |
| 180 | 180 | // DO NOT set latitude/longitude to 0/0 as default values. It's a specific |
| 181 | 181 | // place on the globe:"The zero/zero point of this system is located in the |
| 182 | 182 | // Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana." |
| 183 | 183 | return array( |
| 184 | - 'latitude' => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '', |
|
| 185 | - 'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '', |
|
| 184 | + 'latitude' => isset($latitude[0]) && is_numeric($latitude[0]) ? $latitude[0] : '', |
|
| 185 | + 'longitude' => isset($longitude[0]) && is_numeric($longitude[0]) ? $longitude[0] : '', |
|
| 186 | 186 | ); |
| 187 | 187 | } |
| 188 | 188 | |
@@ -195,11 +195,11 @@ discard block |
||
| 195 | 195 | * @deprecated use Wordlift_Storage_Factory::get_instance()->post_images()->get( $post_id ) |
| 196 | 196 | * |
| 197 | 197 | */ |
| 198 | -function wl_get_image_urls( $post_id ) { |
|
| 198 | +function wl_get_image_urls($post_id) { |
|
| 199 | 199 | |
| 200 | 200 | return Wordlift_Storage_Factory::get_instance() |
| 201 | 201 | ->post_images() |
| 202 | - ->get( $post_id ); |
|
| 202 | + ->get($post_id); |
|
| 203 | 203 | |
| 204 | 204 | } |
| 205 | 205 | |
@@ -211,21 +211,21 @@ discard block |
||
| 211 | 211 | * |
| 212 | 212 | * @return WP_Post|null A post instance or null if not found. |
| 213 | 213 | */ |
| 214 | -function wl_get_attachment_for_source_url( $parent_post_id, $source_url ) { |
|
| 214 | +function wl_get_attachment_for_source_url($parent_post_id, $source_url) { |
|
| 215 | 215 | |
| 216 | 216 | // wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" ); |
| 217 | 217 | |
| 218 | - $posts = get_posts( array( |
|
| 218 | + $posts = get_posts(array( |
|
| 219 | 219 | 'post_type' => 'attachment', |
| 220 | 220 | 'posts_per_page' => 1, |
| 221 | 221 | 'post_status' => 'any', |
| 222 | 222 | 'post_parent' => $parent_post_id, |
| 223 | 223 | 'meta_key' => 'wl_source_url', |
| 224 | 224 | 'meta_value' => $source_url, |
| 225 | - ) ); |
|
| 225 | + )); |
|
| 226 | 226 | |
| 227 | 227 | // Return the found post. |
| 228 | - if ( 1 === count( $posts ) ) { |
|
| 228 | + if (1 === count($posts)) { |
|
| 229 | 229 | return $posts[0]; |
| 230 | 230 | } |
| 231 | 231 | |
@@ -239,10 +239,10 @@ discard block |
||
| 239 | 239 | * @param int $post_id The post ID. |
| 240 | 240 | * @param string $source_url The source URL. |
| 241 | 241 | */ |
| 242 | -function wl_set_source_url( $post_id, $source_url ) { |
|
| 242 | +function wl_set_source_url($post_id, $source_url) { |
|
| 243 | 243 | |
| 244 | - delete_post_meta( $post_id, 'wl_source_url' ); |
|
| 245 | - add_post_meta( $post_id, 'wl_source_url', $source_url ); |
|
| 244 | + delete_post_meta($post_id, 'wl_source_url'); |
|
| 245 | + add_post_meta($post_id, 'wl_source_url', $source_url); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | /** |
@@ -257,9 +257,9 @@ discard block |
||
| 257 | 257 | * @see https://codex.wordpress.org/Function_Reference/sanitize_title |
| 258 | 258 | * |
| 259 | 259 | */ |
| 260 | -function wl_sanitize_uri_path( $path, $char = '_' ) { |
|
| 260 | +function wl_sanitize_uri_path($path, $char = '_') { |
|
| 261 | 261 | |
| 262 | - return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char ); |
|
| 262 | + return Wordlift_Uri_Service::get_instance()->sanitize_path($path, $char); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | /** |
@@ -269,104 +269,104 @@ discard block |
||
| 269 | 269 | * |
| 270 | 270 | * @return string The updated post content. |
| 271 | 271 | */ |
| 272 | -function wl_replace_item_id_with_uri( $content ) { |
|
| 272 | +function wl_replace_item_id_with_uri($content) { |
|
| 273 | 273 | |
| 274 | - $log = Wordlift_Log_Service::get_logger( 'wl_replace_item_id_with_uri' ); |
|
| 275 | - $log->trace( 'Replacing item IDs with URIs...' ); |
|
| 274 | + $log = Wordlift_Log_Service::get_logger('wl_replace_item_id_with_uri'); |
|
| 275 | + $log->trace('Replacing item IDs with URIs...'); |
|
| 276 | 276 | |
| 277 | 277 | // Strip slashes, see https://core.trac.wordpress.org/ticket/21767 |
| 278 | - $content = stripslashes( $content ); |
|
| 278 | + $content = stripslashes($content); |
|
| 279 | 279 | |
| 280 | 280 | // If any match are found. |
| 281 | 281 | $matches = array(); |
| 282 | - if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) { |
|
| 282 | + if (0 < preg_match_all('/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER)) { |
|
| 283 | 283 | |
| 284 | - foreach ( $matches as $match ) { |
|
| 284 | + foreach ($matches as $match) { |
|
| 285 | 285 | |
| 286 | 286 | // Get the item ID. |
| 287 | 287 | $item_id = $match[1]; |
| 288 | 288 | |
| 289 | 289 | // Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' . |
| 290 | 290 | $post = Wordlift_Entity_Service::get_instance() |
| 291 | - ->get_entity_post_by_uri( $item_id ); |
|
| 291 | + ->get_entity_post_by_uri($item_id); |
|
| 292 | 292 | |
| 293 | 293 | // If no entity is found, continue to the next one. |
| 294 | - if ( null === $post ) { |
|
| 294 | + if (null === $post) { |
|
| 295 | 295 | continue; |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | // Get the URI for that post. |
| 299 | - $uri = wl_get_entity_uri( $post->ID ); |
|
| 299 | + $uri = wl_get_entity_uri($post->ID); |
|
| 300 | 300 | |
| 301 | 301 | // wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" ); |
| 302 | 302 | |
| 303 | 303 | // If the item ID and the URI differ, replace the item ID with the URI saved in WordPress. |
| 304 | - if ( ! empty( $uri ) && $item_id !== $uri ) { |
|
| 305 | - $uri_e = esc_html( $uri ); |
|
| 306 | - $content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content ); |
|
| 304 | + if ( ! empty($uri) && $item_id !== $uri) { |
|
| 305 | + $uri_e = esc_html($uri); |
|
| 306 | + $content = str_replace(" itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content); |
|
| 307 | 307 | } |
| 308 | 308 | } |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | // Reapply slashes. |
| 312 | - $content = addslashes( $content ); |
|
| 312 | + $content = addslashes($content); |
|
| 313 | 313 | |
| 314 | 314 | return $content; |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | -add_filter( 'content_save_pre', 'wl_replace_item_id_with_uri', 1, 1 ); |
|
| 317 | +add_filter('content_save_pre', 'wl_replace_item_id_with_uri', 1, 1); |
|
| 318 | 318 | |
| 319 | -require_once( 'wordlift_entity_functions.php' ); |
|
| 319 | +require_once('wordlift_entity_functions.php'); |
|
| 320 | 320 | |
| 321 | 321 | // add editor related methods. |
| 322 | -require_once( 'wordlift_editor.php' ); |
|
| 322 | +require_once('wordlift_editor.php'); |
|
| 323 | 323 | |
| 324 | 324 | // add the WordLift entity custom type. |
| 325 | -require_once( 'wordlift_entity_type.php' ); |
|
| 325 | +require_once('wordlift_entity_type.php'); |
|
| 326 | 326 | |
| 327 | 327 | // add callbacks on post save to notify data changes from wp to redlink triple store |
| 328 | -require_once( 'wordlift_to_redlink_data_push_callbacks.php' ); |
|
| 328 | +require_once('wordlift_to_redlink_data_push_callbacks.php'); |
|
| 329 | 329 | |
| 330 | -require_once( 'modules/configuration/wordlift_configuration_settings.php' ); |
|
| 330 | +require_once('modules/configuration/wordlift_configuration_settings.php'); |
|
| 331 | 331 | |
| 332 | 332 | // Load modules |
| 333 | -require_once( 'modules/analyzer/wordlift_analyzer.php' ); |
|
| 334 | -require_once( 'modules/linked_data/wordlift_linked_data.php' ); |
|
| 335 | -require_once( 'modules/prefixes/wordlift_prefixes.php' ); |
|
| 333 | +require_once('modules/analyzer/wordlift_analyzer.php'); |
|
| 334 | +require_once('modules/linked_data/wordlift_linked_data.php'); |
|
| 335 | +require_once('modules/prefixes/wordlift_prefixes.php'); |
|
| 336 | 336 | |
| 337 | 337 | // Shortcodes |
| 338 | 338 | |
| 339 | -require_once( 'modules/geo_widget/wordlift_geo_widget.php' ); |
|
| 340 | -require_once( 'shortcodes/class-wordlift-shortcode-rest.php' ); |
|
| 341 | -require_once( 'shortcodes/wordlift_shortcode_chord.php' ); |
|
| 342 | -require_once( 'shortcodes/wordlift_shortcode_geomap.php' ); |
|
| 343 | -require_once( 'shortcodes/wordlift_shortcode_field.php' ); |
|
| 344 | -require_once( 'shortcodes/wordlift_shortcode_faceted_search.php' ); |
|
| 345 | -require_once( 'shortcodes/wordlift_shortcode_navigator.php' ); |
|
| 346 | -require_once( 'shortcodes/class-wordlift-products-navigator-shortcode-rest.php' ); |
|
| 339 | +require_once('modules/geo_widget/wordlift_geo_widget.php'); |
|
| 340 | +require_once('shortcodes/class-wordlift-shortcode-rest.php'); |
|
| 341 | +require_once('shortcodes/wordlift_shortcode_chord.php'); |
|
| 342 | +require_once('shortcodes/wordlift_shortcode_geomap.php'); |
|
| 343 | +require_once('shortcodes/wordlift_shortcode_field.php'); |
|
| 344 | +require_once('shortcodes/wordlift_shortcode_faceted_search.php'); |
|
| 345 | +require_once('shortcodes/wordlift_shortcode_navigator.php'); |
|
| 346 | +require_once('shortcodes/class-wordlift-products-navigator-shortcode-rest.php'); |
|
| 347 | 347 | |
| 348 | -require_once( 'widgets/wordlift_widget_geo.php' ); |
|
| 349 | -require_once( 'widgets/class-wordlift-chord-widget.php' ); |
|
| 350 | -require_once( 'widgets/wordlift_widget_timeline.php' ); |
|
| 348 | +require_once('widgets/wordlift_widget_geo.php'); |
|
| 349 | +require_once('widgets/class-wordlift-chord-widget.php'); |
|
| 350 | +require_once('widgets/wordlift_widget_timeline.php'); |
|
| 351 | 351 | |
| 352 | -require_once( 'wordlift_redlink.php' ); |
|
| 352 | +require_once('wordlift_redlink.php'); |
|
| 353 | 353 | |
| 354 | 354 | // Add admin functions. |
| 355 | 355 | // TODO: find a way to make 'admin' UI tests work. |
| 356 | 356 | //if ( is_admin() ) { |
| 357 | 357 | |
| 358 | -require_once( 'admin/wordlift_admin.php' ); |
|
| 359 | -require_once( 'admin/wordlift_admin_edit_post.php' ); |
|
| 360 | -require_once( 'admin/wordlift_admin_save_post.php' ); |
|
| 358 | +require_once('admin/wordlift_admin.php'); |
|
| 359 | +require_once('admin/wordlift_admin_edit_post.php'); |
|
| 360 | +require_once('admin/wordlift_admin_save_post.php'); |
|
| 361 | 361 | |
| 362 | 362 | // add the entities meta box. |
| 363 | -require_once( 'admin/wordlift_admin_meta_box_entities.php' ); |
|
| 363 | +require_once('admin/wordlift_admin_meta_box_entities.php'); |
|
| 364 | 364 | |
| 365 | 365 | // add the entity creation AJAX. |
| 366 | -require_once( 'admin/wordlift_admin_ajax_related_posts.php' ); |
|
| 366 | +require_once('admin/wordlift_admin_ajax_related_posts.php'); |
|
| 367 | 367 | |
| 368 | 368 | // Load the wl_chord TinyMCE button and configuration dialog. |
| 369 | -require_once( 'admin/wordlift_admin_shortcodes.php' ); |
|
| 369 | +require_once('admin/wordlift_admin_shortcodes.php'); |
|
| 370 | 370 | |
| 371 | 371 | /** |
| 372 | 372 | * The code that runs during plugin activation. |
@@ -374,11 +374,11 @@ discard block |
||
| 374 | 374 | */ |
| 375 | 375 | function activate_wordlift() { |
| 376 | 376 | |
| 377 | - $log = Wordlift_Log_Service::get_logger( 'activate_wordlift' ); |
|
| 377 | + $log = Wordlift_Log_Service::get_logger('activate_wordlift'); |
|
| 378 | 378 | |
| 379 | - $log->info( 'Activating WordLift...' ); |
|
| 379 | + $log->info('Activating WordLift...'); |
|
| 380 | 380 | |
| 381 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php'; |
|
| 381 | + require_once plugin_dir_path(__FILE__).'includes/class-wordlift-activator.php'; |
|
| 382 | 382 | Wordlift_Activator::activate(); |
| 383 | 383 | |
| 384 | 384 | /** |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | */ |
| 406 | 406 | function deactivate_wordlift() { |
| 407 | 407 | |
| 408 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php'; |
|
| 408 | + require_once plugin_dir_path(__FILE__).'includes/class-wordlift-deactivator.php'; |
|
| 409 | 409 | Wordlift_Deactivator::deactivate(); |
| 410 | 410 | Wordlift_Http_Api::deactivate(); |
| 411 | 411 | Ttl_Cache_Cleaner::deactivate(); |
@@ -418,14 +418,14 @@ discard block |
||
| 418 | 418 | |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | -register_activation_hook( __FILE__, 'activate_wordlift' ); |
|
| 422 | -register_deactivation_hook( __FILE__, 'deactivate_wordlift' ); |
|
| 421 | +register_activation_hook(__FILE__, 'activate_wordlift'); |
|
| 422 | +register_deactivation_hook(__FILE__, 'deactivate_wordlift'); |
|
| 423 | 423 | |
| 424 | 424 | /** |
| 425 | 425 | * The core plugin class that is used to define internationalization, |
| 426 | 426 | * admin-specific hooks, and public-facing site hooks. |
| 427 | 427 | */ |
| 428 | -require plugin_dir_path( __FILE__ ) . 'includes/class-wordlift.php'; |
|
| 428 | +require plugin_dir_path(__FILE__).'includes/class-wordlift.php'; |
|
| 429 | 429 | |
| 430 | 430 | /** |
| 431 | 431 | * Begins execution of the plugin. |
@@ -445,12 +445,12 @@ discard block |
||
| 445 | 445 | * @return bool |
| 446 | 446 | * @since 3.27.6 |
| 447 | 447 | */ |
| 448 | - if ( apply_filters( 'wl_feature__enable__widgets', true ) ) { |
|
| 449 | - add_action( 'widgets_init', 'wl_register_chord_widget' ); |
|
| 450 | - add_action( 'widgets_init', 'wl_register_geo_widget' ); |
|
| 451 | - add_action( 'widgets_init', 'wl_register_timeline_widget' ); |
|
| 448 | + if (apply_filters('wl_feature__enable__widgets', true)) { |
|
| 449 | + add_action('widgets_init', 'wl_register_chord_widget'); |
|
| 450 | + add_action('widgets_init', 'wl_register_geo_widget'); |
|
| 451 | + add_action('widgets_init', 'wl_register_timeline_widget'); |
|
| 452 | 452 | } |
| 453 | - add_filter( 'widget_text', 'do_shortcode' ); |
|
| 453 | + add_filter('widget_text', 'do_shortcode'); |
|
| 454 | 454 | |
| 455 | 455 | |
| 456 | 456 | /** |
@@ -461,10 +461,10 @@ discard block |
||
| 461 | 461 | * @return bool |
| 462 | 462 | * @since 3.27.6 |
| 463 | 463 | */ |
| 464 | - if ( apply_filters( 'wl_feature__enable__analysis', true ) ) { |
|
| 465 | - add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_action' ); |
|
| 464 | + if (apply_filters('wl_feature__enable__analysis', true)) { |
|
| 465 | + add_action('wp_ajax_wl_analyze', 'wl_ajax_analyze_action'); |
|
| 466 | 466 | } else { |
| 467 | - add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action' ); |
|
| 467 | + add_action('wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action'); |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | /* |
@@ -486,47 +486,47 @@ discard block |
||
| 486 | 486 | // Load the API Data Hooks. |
| 487 | 487 | new Api_Data_Hooks(); |
| 488 | 488 | |
| 489 | - add_action( 'plugins_loaded', function () use ( $plugin ) { |
|
| 489 | + add_action('plugins_loaded', function() use ($plugin) { |
|
| 490 | 490 | // Load early. **PLEASE NOTE** that features are applied only to calls that happen **AFTER** the `plugins_loaded` |
| 491 | 491 | // action. |
| 492 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/features/index.php'; |
|
| 492 | + require_once plugin_dir_path(__FILE__).'wordlift/features/index.php'; |
|
| 493 | 493 | |
| 494 | 494 | // Licenses Images. |
| 495 | 495 | $user_agent = User_Agent::get_user_agent(); |
| 496 | 496 | $wordlift_key = Wordlift_Configuration_Service::get_instance()->get_key(); |
| 497 | - $api_service = new Default_Api_Service( apply_filters( 'wl_api_base_url', WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE ), 60, $user_agent, $wordlift_key ); |
|
| 497 | + $api_service = new Default_Api_Service(apply_filters('wl_api_base_url', WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE), 60, $user_agent, $wordlift_key); |
|
| 498 | 498 | $image_license_factory = new Image_License_Factory(); |
| 499 | - $image_license_service = new Image_License_Service( $api_service, $image_license_factory ); |
|
| 500 | - $image_license_cache = new Ttl_Cache( 'image-license', 86400 * 30 ); // 30 days. |
|
| 501 | - $cached_image_license_service = new Cached_Image_License_Service( $image_license_service, $image_license_cache ); |
|
| 499 | + $image_license_service = new Image_License_Service($api_service, $image_license_factory); |
|
| 500 | + $image_license_cache = new Ttl_Cache('image-license', 86400 * 30); // 30 days. |
|
| 501 | + $cached_image_license_service = new Cached_Image_License_Service($image_license_service, $image_license_cache); |
|
| 502 | 502 | |
| 503 | - $image_license_scheduler = new Image_License_Scheduler( $image_license_service, $image_license_cache ); |
|
| 503 | + $image_license_scheduler = new Image_License_Scheduler($image_license_service, $image_license_cache); |
|
| 504 | 504 | $image_license_cleanup_service = new Image_License_Cleanup_Service(); |
| 505 | 505 | |
| 506 | 506 | // Get the cached data. If we have cached data, we load the notifier. |
| 507 | - $image_license_data = $image_license_cache->get( Cached_Image_License_Service::GET_NON_PUBLIC_DOMAIN_IMAGES ); |
|
| 508 | - if ( null !== $image_license_data ) { |
|
| 509 | - $image_license_page = new Image_License_Page( $image_license_data, Wordlift::get_instance()->get_version() ); |
|
| 510 | - new Image_License_Notifier( $image_license_data, $image_license_page ); |
|
| 507 | + $image_license_data = $image_license_cache->get(Cached_Image_License_Service::GET_NON_PUBLIC_DOMAIN_IMAGES); |
|
| 508 | + if (null !== $image_license_data) { |
|
| 509 | + $image_license_page = new Image_License_Page($image_license_data, Wordlift::get_instance()->get_version()); |
|
| 510 | + new Image_License_Notifier($image_license_data, $image_license_page); |
|
| 511 | 511 | } |
| 512 | 512 | |
| 513 | - $remove_all_images_task = new Remove_All_Images_Task( $cached_image_license_service ); |
|
| 514 | - $remove_all_images_task_adapter = new Task_Ajax_Adapter( $remove_all_images_task ); |
|
| 513 | + $remove_all_images_task = new Remove_All_Images_Task($cached_image_license_service); |
|
| 514 | + $remove_all_images_task_adapter = new Task_Ajax_Adapter($remove_all_images_task); |
|
| 515 | 515 | |
| 516 | 516 | $reload_data_task = new Reload_Data_Task(); |
| 517 | - $reload_data_task_adapter = new Task_Ajax_Adapter( $reload_data_task ); |
|
| 517 | + $reload_data_task_adapter = new Task_Ajax_Adapter($reload_data_task); |
|
| 518 | 518 | |
| 519 | - $add_license_caption_or_remove_task = new Add_License_Caption_Or_Remove_Task( $cached_image_license_service ); |
|
| 520 | - $add_license_caption_or_remove_task_adapter = new Task_Ajax_Adapter( $add_license_caption_or_remove_task ); |
|
| 519 | + $add_license_caption_or_remove_task = new Add_License_Caption_Or_Remove_Task($cached_image_license_service); |
|
| 520 | + $add_license_caption_or_remove_task_adapter = new Task_Ajax_Adapter($add_license_caption_or_remove_task); |
|
| 521 | 521 | |
| 522 | - $remove_all_images_task_page = new Remove_All_Images_Page( new Task_Ajax_Adapters_Registry( $remove_all_images_task_adapter ), $plugin->get_version() ); |
|
| 523 | - $reload_data_task_page = new Reload_Data_Page( new Task_Ajax_Adapters_Registry( $reload_data_task_adapter ), $plugin->get_version() ); |
|
| 524 | - $add_license_caption_or_remove_task_page = new Add_License_Caption_Or_Remove_Page( new Task_Ajax_Adapters_Registry( $add_license_caption_or_remove_task_adapter ), $plugin->get_version() ); |
|
| 522 | + $remove_all_images_task_page = new Remove_All_Images_Page(new Task_Ajax_Adapters_Registry($remove_all_images_task_adapter), $plugin->get_version()); |
|
| 523 | + $reload_data_task_page = new Reload_Data_Page(new Task_Ajax_Adapters_Registry($reload_data_task_adapter), $plugin->get_version()); |
|
| 524 | + $add_license_caption_or_remove_task_page = new Add_License_Caption_Or_Remove_Page(new Task_Ajax_Adapters_Registry($add_license_caption_or_remove_task_adapter), $plugin->get_version()); |
|
| 525 | 525 | |
| 526 | 526 | new Wordlift_Products_Navigator_Shortcode_REST(); |
| 527 | 527 | |
| 528 | 528 | // Register the Dataset module, requires `$api_service`. |
| 529 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/dataset/index.php'; |
|
| 529 | + require_once plugin_dir_path(__FILE__).'wordlift/dataset/index.php'; |
|
| 530 | 530 | |
| 531 | 531 | } ); |
| 532 | 532 | |
@@ -542,24 +542,24 @@ discard block |
||
| 542 | 542 | */ |
| 543 | 543 | function wordlift_plugin_autoload_register() { |
| 544 | 544 | |
| 545 | - spl_autoload_register( function ( $class_name ) { |
|
| 545 | + spl_autoload_register(function($class_name) { |
|
| 546 | 546 | |
| 547 | 547 | // Bail out if these are not our classes. |
| 548 | - if ( 0 !== strpos( $class_name, 'Wordlift\\' ) ) { |
|
| 548 | + if (0 !== strpos($class_name, 'Wordlift\\')) { |
|
| 549 | 549 | return false; |
| 550 | 550 | } |
| 551 | 551 | |
| 552 | - $class_name_lc = strtolower( str_replace( '_', '-', $class_name ) ); |
|
| 552 | + $class_name_lc = strtolower(str_replace('_', '-', $class_name)); |
|
| 553 | 553 | |
| 554 | - preg_match( '|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches ); |
|
| 554 | + preg_match('|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches); |
|
| 555 | 555 | |
| 556 | - $path = str_replace( '\\', DIRECTORY_SEPARATOR, $matches[1] ); |
|
| 557 | - $file = 'class-' . $matches[2] . '.php'; |
|
| 556 | + $path = str_replace('\\', DIRECTORY_SEPARATOR, $matches[1]); |
|
| 557 | + $file = 'class-'.$matches[2].'.php'; |
|
| 558 | 558 | |
| 559 | - $full_path = plugin_dir_path( __FILE__ ) . $path . DIRECTORY_SEPARATOR . $file; |
|
| 559 | + $full_path = plugin_dir_path(__FILE__).$path.DIRECTORY_SEPARATOR.$file; |
|
| 560 | 560 | |
| 561 | - if ( ! file_exists( $full_path ) ) { |
|
| 562 | - echo( "Class $class_name not found at $full_path." ); |
|
| 561 | + if ( ! file_exists($full_path)) { |
|
| 562 | + echo("Class $class_name not found at $full_path."); |
|
| 563 | 563 | |
| 564 | 564 | return false; |
| 565 | 565 | } |
@@ -571,16 +571,16 @@ discard block |
||
| 571 | 571 | |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | -function wl_block_categories( $categories, $post ) { |
|
| 574 | +function wl_block_categories($categories, $post) { |
|
| 575 | 575 | return array_merge( |
| 576 | 576 | $categories, |
| 577 | 577 | array( |
| 578 | 578 | array( |
| 579 | 579 | 'slug' => 'wordlift', |
| 580 | - 'title' => __( 'WordLift', 'wordlift' ), |
|
| 580 | + 'title' => __('WordLift', 'wordlift'), |
|
| 581 | 581 | ), |
| 582 | 582 | ) |
| 583 | 583 | ); |
| 584 | 584 | } |
| 585 | 585 | |
| 586 | -add_filter( 'block_categories', 'wl_block_categories', 10, 2 ); |
|
| 586 | +add_filter('block_categories', 'wl_block_categories', 10, 2); |
|
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | if ( ! defined( 'ABSPATH' ) ) { |
| 14 | - exit; |
|
| 14 | + exit; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -21,295 +21,295 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | class Wordlift_Languages { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * An array that will contain language codes => language names pairs. It gets lazily loaded the first time by the |
|
| 26 | - * `get_languages` function. |
|
| 27 | - * |
|
| 28 | - * @since 3.9.0 |
|
| 29 | - * @var array|null An array of language codes => language names pairs or NULL if not initialized yet. |
|
| 30 | - */ |
|
| 31 | - private static $languages = null; |
|
| 24 | + /** |
|
| 25 | + * An array that will contain language codes => language names pairs. It gets lazily loaded the first time by the |
|
| 26 | + * `get_languages` function. |
|
| 27 | + * |
|
| 28 | + * @since 3.9.0 |
|
| 29 | + * @var array|null An array of language codes => language names pairs or NULL if not initialized yet. |
|
| 30 | + */ |
|
| 31 | + private static $languages = null; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * The list of supported language codes. |
|
| 35 | - * |
|
| 36 | - * @since 3.9.0 |
|
| 37 | - * |
|
| 38 | - * @var array An array of language codes. |
|
| 39 | - */ |
|
| 40 | - private static $codes = array( |
|
| 41 | - 'ar', |
|
| 42 | - 'be', |
|
| 43 | - 'bg', |
|
| 44 | - 'ca', |
|
| 45 | - 'cs', |
|
| 46 | - 'da', |
|
| 47 | - 'de', |
|
| 48 | - 'el', |
|
| 49 | - 'en', |
|
| 50 | - 'es', |
|
| 51 | - 'et', |
|
| 52 | - 'fi', |
|
| 53 | - 'fr', |
|
| 54 | - 'he', |
|
| 55 | - 'hr', |
|
| 56 | - 'hu', |
|
| 57 | - 'id', |
|
| 58 | - 'is', |
|
| 59 | - 'it', |
|
| 60 | - 'lt', |
|
| 61 | - 'lv', |
|
| 62 | - 'nl', |
|
| 63 | - 'no', |
|
| 64 | - 'pl', |
|
| 65 | - 'pt', |
|
| 66 | - 'ro', |
|
| 67 | - 'ru', |
|
| 68 | - 'sk', |
|
| 69 | - 'sl', |
|
| 70 | - 'sq', |
|
| 71 | - 'sr', |
|
| 72 | - 'sv', |
|
| 73 | - 'tr', |
|
| 74 | - 'uk', |
|
| 75 | - 'zh-cn', |
|
| 76 | - ); |
|
| 33 | + /** |
|
| 34 | + * The list of supported language codes. |
|
| 35 | + * |
|
| 36 | + * @since 3.9.0 |
|
| 37 | + * |
|
| 38 | + * @var array An array of language codes. |
|
| 39 | + */ |
|
| 40 | + private static $codes = array( |
|
| 41 | + 'ar', |
|
| 42 | + 'be', |
|
| 43 | + 'bg', |
|
| 44 | + 'ca', |
|
| 45 | + 'cs', |
|
| 46 | + 'da', |
|
| 47 | + 'de', |
|
| 48 | + 'el', |
|
| 49 | + 'en', |
|
| 50 | + 'es', |
|
| 51 | + 'et', |
|
| 52 | + 'fi', |
|
| 53 | + 'fr', |
|
| 54 | + 'he', |
|
| 55 | + 'hr', |
|
| 56 | + 'hu', |
|
| 57 | + 'id', |
|
| 58 | + 'is', |
|
| 59 | + 'it', |
|
| 60 | + 'lt', |
|
| 61 | + 'lv', |
|
| 62 | + 'nl', |
|
| 63 | + 'no', |
|
| 64 | + 'pl', |
|
| 65 | + 'pt', |
|
| 66 | + 'ro', |
|
| 67 | + 'ru', |
|
| 68 | + 'sk', |
|
| 69 | + 'sl', |
|
| 70 | + 'sq', |
|
| 71 | + 'sr', |
|
| 72 | + 'sv', |
|
| 73 | + 'tr', |
|
| 74 | + 'uk', |
|
| 75 | + 'zh-cn', |
|
| 76 | + ); |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Get the list of WordLift's supported languages in an array with language code => language name pairs. |
|
| 80 | - * |
|
| 81 | - * @since 3.9.0 |
|
| 82 | - * |
|
| 83 | - * @return array An array with language code => language name pairs. |
|
| 84 | - */ |
|
| 85 | - public static function get_languages() { |
|
| 78 | + /** |
|
| 79 | + * Get the list of WordLift's supported languages in an array with language code => language name pairs. |
|
| 80 | + * |
|
| 81 | + * @since 3.9.0 |
|
| 82 | + * |
|
| 83 | + * @return array An array with language code => language name pairs. |
|
| 84 | + */ |
|
| 85 | + public static function get_languages() { |
|
| 86 | 86 | |
| 87 | - // Lazily load the languages. |
|
| 88 | - if ( null === self::$languages ) { |
|
| 87 | + // Lazily load the languages. |
|
| 88 | + if ( null === self::$languages ) { |
|
| 89 | 89 | |
| 90 | - // Get the language names from WP's own (multisite) function. |
|
| 91 | - foreach ( self::$codes as $key ) { |
|
| 92 | - self::$languages[ $key ] = self::format_code_lang( $key ); |
|
| 93 | - } |
|
| 90 | + // Get the language names from WP's own (multisite) function. |
|
| 91 | + foreach ( self::$codes as $key ) { |
|
| 92 | + self::$languages[ $key ] = self::format_code_lang( $key ); |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - // Sort by language name. |
|
| 96 | - asort( self::$languages ); |
|
| 97 | - } |
|
| 95 | + // Sort by language name. |
|
| 96 | + asort( self::$languages ); |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - return self::$languages; |
|
| 100 | - } |
|
| 99 | + return self::$languages; |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * Returns the language for a language code. This function is a clone of WP's function provided in `ms.php`. |
|
| 104 | - * |
|
| 105 | - * @since 3.9.3 |
|
| 106 | - * |
|
| 107 | - * @param string $code Optional. The two-letter language code. Default empty. |
|
| 108 | - * |
|
| 109 | - * @return string The language corresponding to $code if it exists. If it does not exist, |
|
| 110 | - * then the first two letters of $code is returned. |
|
| 111 | - */ |
|
| 112 | - private static function format_code_lang( $code = '' ) { |
|
| 113 | - $code = strtolower( substr( $code, 0, 2 ) ); |
|
| 114 | - $lang_codes = array( |
|
| 115 | - 'aa' => 'Afar', |
|
| 116 | - 'ab' => 'Abkhazian', |
|
| 117 | - 'af' => 'Afrikaans', |
|
| 118 | - 'ak' => 'Akan', |
|
| 119 | - 'sq' => 'Albanian', |
|
| 120 | - 'am' => 'Amharic', |
|
| 121 | - 'ar' => 'Arabic', |
|
| 122 | - 'an' => 'Aragonese', |
|
| 123 | - 'hy' => 'Armenian', |
|
| 124 | - 'as' => 'Assamese', |
|
| 125 | - 'av' => 'Avaric', |
|
| 126 | - 'ae' => 'Avestan', |
|
| 127 | - 'ay' => 'Aymara', |
|
| 128 | - 'az' => 'Azerbaijani', |
|
| 129 | - 'ba' => 'Bashkir', |
|
| 130 | - 'bm' => 'Bambara', |
|
| 131 | - 'eu' => 'Basque', |
|
| 132 | - 'be' => 'Belarusian', |
|
| 133 | - 'bn' => 'Bengali', |
|
| 134 | - 'bh' => 'Bihari', |
|
| 135 | - 'bi' => 'Bislama', |
|
| 136 | - 'bs' => 'Bosnian', |
|
| 137 | - 'br' => 'Breton', |
|
| 138 | - 'bg' => 'Bulgarian', |
|
| 139 | - 'my' => 'Burmese', |
|
| 140 | - 'ca' => 'Catalan; Valencian', |
|
| 141 | - 'ch' => 'Chamorro', |
|
| 142 | - 'ce' => 'Chechen', |
|
| 143 | - 'zh' => 'Chinese', |
|
| 144 | - 'cu' => 'Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic', |
|
| 145 | - 'cv' => 'Chuvash', |
|
| 146 | - 'kw' => 'Cornish', |
|
| 147 | - 'co' => 'Corsican', |
|
| 148 | - 'cr' => 'Cree', |
|
| 149 | - 'cs' => 'Czech', |
|
| 150 | - 'da' => 'Danish', |
|
| 151 | - 'dv' => 'Divehi; Dhivehi; Maldivian', |
|
| 152 | - 'nl' => 'Dutch; Flemish', |
|
| 153 | - 'dz' => 'Dzongkha', |
|
| 154 | - 'en' => 'English', |
|
| 155 | - 'eo' => 'Esperanto', |
|
| 156 | - 'et' => 'Estonian', |
|
| 157 | - 'ee' => 'Ewe', |
|
| 158 | - 'fo' => 'Faroese', |
|
| 159 | - 'fj' => 'Fijjian', |
|
| 160 | - 'fi' => 'Finnish', |
|
| 161 | - 'fr' => 'French', |
|
| 162 | - 'fy' => 'Western Frisian', |
|
| 163 | - 'ff' => 'Fulah', |
|
| 164 | - 'ka' => 'Georgian', |
|
| 165 | - 'de' => 'German', |
|
| 166 | - 'gd' => 'Gaelic; Scottish Gaelic', |
|
| 167 | - 'ga' => 'Irish', |
|
| 168 | - 'gl' => 'Galician', |
|
| 169 | - 'gv' => 'Manx', |
|
| 170 | - 'el' => 'Greek, Modern', |
|
| 171 | - 'gn' => 'Guarani', |
|
| 172 | - 'gu' => 'Gujarati', |
|
| 173 | - 'ht' => 'Haitian; Haitian Creole', |
|
| 174 | - 'ha' => 'Hausa', |
|
| 175 | - 'he' => 'Hebrew', |
|
| 176 | - 'hz' => 'Herero', |
|
| 177 | - 'hi' => 'Hindi', |
|
| 178 | - 'ho' => 'Hiri Motu', |
|
| 179 | - 'hu' => 'Hungarian', |
|
| 180 | - 'ig' => 'Igbo', |
|
| 181 | - 'is' => 'Icelandic', |
|
| 182 | - 'io' => 'Ido', |
|
| 183 | - 'ii' => 'Sichuan Yi', |
|
| 184 | - 'iu' => 'Inuktitut', |
|
| 185 | - 'ie' => 'Interlingue', |
|
| 186 | - 'ia' => 'Interlingua (International Auxiliary Language Association)', |
|
| 187 | - 'id' => 'Indonesian', |
|
| 188 | - 'ik' => 'Inupiaq', |
|
| 189 | - 'it' => 'Italian', |
|
| 190 | - 'jv' => 'Javanese', |
|
| 191 | - 'ja' => 'Japanese', |
|
| 192 | - 'kl' => 'Kalaallisut; Greenlandic', |
|
| 193 | - 'kn' => 'Kannada', |
|
| 194 | - 'ks' => 'Kashmiri', |
|
| 195 | - 'kr' => 'Kanuri', |
|
| 196 | - 'kk' => 'Kazakh', |
|
| 197 | - 'km' => 'Central Khmer', |
|
| 198 | - 'ki' => 'Kikuyu; Gikuyu', |
|
| 199 | - 'rw' => 'Kinyarwanda', |
|
| 200 | - 'ky' => 'Kirghiz; Kyrgyz', |
|
| 201 | - 'kv' => 'Komi', |
|
| 202 | - 'kg' => 'Kongo', |
|
| 203 | - 'ko' => 'Korean', |
|
| 204 | - 'kj' => 'Kuanyama; Kwanyama', |
|
| 205 | - 'ku' => 'Kurdish', |
|
| 206 | - 'lo' => 'Lao', |
|
| 207 | - 'la' => 'Latin', |
|
| 208 | - 'lv' => 'Latvian', |
|
| 209 | - 'li' => 'Limburgan; Limburger; Limburgish', |
|
| 210 | - 'ln' => 'Lingala', |
|
| 211 | - 'lt' => 'Lithuanian', |
|
| 212 | - 'lb' => 'Luxembourgish; Letzeburgesch', |
|
| 213 | - 'lu' => 'Luba-Katanga', |
|
| 214 | - 'lg' => 'Ganda', |
|
| 215 | - 'mk' => 'Macedonian', |
|
| 216 | - 'mh' => 'Marshallese', |
|
| 217 | - 'ml' => 'Malayalam', |
|
| 218 | - 'mi' => 'Maori', |
|
| 219 | - 'mr' => 'Marathi', |
|
| 220 | - 'ms' => 'Malay', |
|
| 221 | - 'mg' => 'Malagasy', |
|
| 222 | - 'mt' => 'Maltese', |
|
| 223 | - 'mo' => 'Moldavian', |
|
| 224 | - 'mn' => 'Mongolian', |
|
| 225 | - 'na' => 'Nauru', |
|
| 226 | - 'nv' => 'Navajo; Navaho', |
|
| 227 | - 'nr' => 'Ndebele, South; South Ndebele', |
|
| 228 | - 'nd' => 'Ndebele, North; North Ndebele', |
|
| 229 | - 'ng' => 'Ndonga', |
|
| 230 | - 'ne' => 'Nepali', |
|
| 231 | - 'nn' => 'Norwegian Nynorsk; Nynorsk, Norwegian', |
|
| 232 | - 'nb' => 'Bokmål, Norwegian, Norwegian Bokmål', |
|
| 233 | - 'no' => 'Norwegian', |
|
| 234 | - 'ny' => 'Chichewa; Chewa; Nyanja', |
|
| 235 | - 'oc' => 'Occitan, Provençal', |
|
| 236 | - 'oj' => 'Ojibwa', |
|
| 237 | - 'or' => 'Oriya', |
|
| 238 | - 'om' => 'Oromo', |
|
| 239 | - 'os' => 'Ossetian; Ossetic', |
|
| 240 | - 'pa' => 'Panjabi; Punjabi', |
|
| 241 | - 'fa' => 'Persian', |
|
| 242 | - 'pi' => 'Pali', |
|
| 243 | - 'pl' => 'Polish', |
|
| 244 | - 'pt' => 'Portuguese', |
|
| 245 | - 'ps' => 'Pushto', |
|
| 246 | - 'qu' => 'Quechua', |
|
| 247 | - 'rm' => 'Romansh', |
|
| 248 | - 'ro' => 'Romanian', |
|
| 249 | - 'rn' => 'Rundi', |
|
| 250 | - 'ru' => 'Russian', |
|
| 251 | - 'sg' => 'Sango', |
|
| 252 | - 'sa' => 'Sanskrit', |
|
| 253 | - 'sr' => 'Serbian', |
|
| 254 | - 'hr' => 'Croatian', |
|
| 255 | - 'si' => 'Sinhala; Sinhalese', |
|
| 256 | - 'sk' => 'Slovak', |
|
| 257 | - 'sl' => 'Slovenian', |
|
| 258 | - 'se' => 'Northern Sami', |
|
| 259 | - 'sm' => 'Samoan', |
|
| 260 | - 'sn' => 'Shona', |
|
| 261 | - 'sd' => 'Sindhi', |
|
| 262 | - 'so' => 'Somali', |
|
| 263 | - 'st' => 'Sotho, Southern', |
|
| 264 | - 'es' => 'Spanish; Castilian', |
|
| 265 | - 'sc' => 'Sardinian', |
|
| 266 | - 'ss' => 'Swati', |
|
| 267 | - 'su' => 'Sundanese', |
|
| 268 | - 'sw' => 'Swahili', |
|
| 269 | - 'sv' => 'Swedish', |
|
| 270 | - 'ty' => 'Tahitian', |
|
| 271 | - 'ta' => 'Tamil', |
|
| 272 | - 'tt' => 'Tatar', |
|
| 273 | - 'te' => 'Telugu', |
|
| 274 | - 'tg' => 'Tajik', |
|
| 275 | - 'tl' => 'Tagalog', |
|
| 276 | - 'th' => 'Thai', |
|
| 277 | - 'bo' => 'Tibetan', |
|
| 278 | - 'ti' => 'Tigrinya', |
|
| 279 | - 'to' => 'Tonga (Tonga Islands)', |
|
| 280 | - 'tn' => 'Tswana', |
|
| 281 | - 'ts' => 'Tsonga', |
|
| 282 | - 'tk' => 'Turkmen', |
|
| 283 | - 'tr' => 'Turkish', |
|
| 284 | - 'tw' => 'Twi', |
|
| 285 | - 'ug' => 'Uighur; Uyghur', |
|
| 286 | - 'uk' => 'Ukrainian', |
|
| 287 | - 'ur' => 'Urdu', |
|
| 288 | - 'uz' => 'Uzbek', |
|
| 289 | - 've' => 'Venda', |
|
| 290 | - 'vi' => 'Vietnamese', |
|
| 291 | - 'vo' => 'Volapük', |
|
| 292 | - 'cy' => 'Welsh', |
|
| 293 | - 'wa' => 'Walloon', |
|
| 294 | - 'wo' => 'Wolof', |
|
| 295 | - 'xh' => 'Xhosa', |
|
| 296 | - 'yi' => 'Yiddish', |
|
| 297 | - 'yo' => 'Yoruba', |
|
| 298 | - 'za' => 'Zhuang; Chuang', |
|
| 299 | - 'zu' => 'Zulu' |
|
| 300 | - ); |
|
| 102 | + /** |
|
| 103 | + * Returns the language for a language code. This function is a clone of WP's function provided in `ms.php`. |
|
| 104 | + * |
|
| 105 | + * @since 3.9.3 |
|
| 106 | + * |
|
| 107 | + * @param string $code Optional. The two-letter language code. Default empty. |
|
| 108 | + * |
|
| 109 | + * @return string The language corresponding to $code if it exists. If it does not exist, |
|
| 110 | + * then the first two letters of $code is returned. |
|
| 111 | + */ |
|
| 112 | + private static function format_code_lang( $code = '' ) { |
|
| 113 | + $code = strtolower( substr( $code, 0, 2 ) ); |
|
| 114 | + $lang_codes = array( |
|
| 115 | + 'aa' => 'Afar', |
|
| 116 | + 'ab' => 'Abkhazian', |
|
| 117 | + 'af' => 'Afrikaans', |
|
| 118 | + 'ak' => 'Akan', |
|
| 119 | + 'sq' => 'Albanian', |
|
| 120 | + 'am' => 'Amharic', |
|
| 121 | + 'ar' => 'Arabic', |
|
| 122 | + 'an' => 'Aragonese', |
|
| 123 | + 'hy' => 'Armenian', |
|
| 124 | + 'as' => 'Assamese', |
|
| 125 | + 'av' => 'Avaric', |
|
| 126 | + 'ae' => 'Avestan', |
|
| 127 | + 'ay' => 'Aymara', |
|
| 128 | + 'az' => 'Azerbaijani', |
|
| 129 | + 'ba' => 'Bashkir', |
|
| 130 | + 'bm' => 'Bambara', |
|
| 131 | + 'eu' => 'Basque', |
|
| 132 | + 'be' => 'Belarusian', |
|
| 133 | + 'bn' => 'Bengali', |
|
| 134 | + 'bh' => 'Bihari', |
|
| 135 | + 'bi' => 'Bislama', |
|
| 136 | + 'bs' => 'Bosnian', |
|
| 137 | + 'br' => 'Breton', |
|
| 138 | + 'bg' => 'Bulgarian', |
|
| 139 | + 'my' => 'Burmese', |
|
| 140 | + 'ca' => 'Catalan; Valencian', |
|
| 141 | + 'ch' => 'Chamorro', |
|
| 142 | + 'ce' => 'Chechen', |
|
| 143 | + 'zh' => 'Chinese', |
|
| 144 | + 'cu' => 'Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic', |
|
| 145 | + 'cv' => 'Chuvash', |
|
| 146 | + 'kw' => 'Cornish', |
|
| 147 | + 'co' => 'Corsican', |
|
| 148 | + 'cr' => 'Cree', |
|
| 149 | + 'cs' => 'Czech', |
|
| 150 | + 'da' => 'Danish', |
|
| 151 | + 'dv' => 'Divehi; Dhivehi; Maldivian', |
|
| 152 | + 'nl' => 'Dutch; Flemish', |
|
| 153 | + 'dz' => 'Dzongkha', |
|
| 154 | + 'en' => 'English', |
|
| 155 | + 'eo' => 'Esperanto', |
|
| 156 | + 'et' => 'Estonian', |
|
| 157 | + 'ee' => 'Ewe', |
|
| 158 | + 'fo' => 'Faroese', |
|
| 159 | + 'fj' => 'Fijjian', |
|
| 160 | + 'fi' => 'Finnish', |
|
| 161 | + 'fr' => 'French', |
|
| 162 | + 'fy' => 'Western Frisian', |
|
| 163 | + 'ff' => 'Fulah', |
|
| 164 | + 'ka' => 'Georgian', |
|
| 165 | + 'de' => 'German', |
|
| 166 | + 'gd' => 'Gaelic; Scottish Gaelic', |
|
| 167 | + 'ga' => 'Irish', |
|
| 168 | + 'gl' => 'Galician', |
|
| 169 | + 'gv' => 'Manx', |
|
| 170 | + 'el' => 'Greek, Modern', |
|
| 171 | + 'gn' => 'Guarani', |
|
| 172 | + 'gu' => 'Gujarati', |
|
| 173 | + 'ht' => 'Haitian; Haitian Creole', |
|
| 174 | + 'ha' => 'Hausa', |
|
| 175 | + 'he' => 'Hebrew', |
|
| 176 | + 'hz' => 'Herero', |
|
| 177 | + 'hi' => 'Hindi', |
|
| 178 | + 'ho' => 'Hiri Motu', |
|
| 179 | + 'hu' => 'Hungarian', |
|
| 180 | + 'ig' => 'Igbo', |
|
| 181 | + 'is' => 'Icelandic', |
|
| 182 | + 'io' => 'Ido', |
|
| 183 | + 'ii' => 'Sichuan Yi', |
|
| 184 | + 'iu' => 'Inuktitut', |
|
| 185 | + 'ie' => 'Interlingue', |
|
| 186 | + 'ia' => 'Interlingua (International Auxiliary Language Association)', |
|
| 187 | + 'id' => 'Indonesian', |
|
| 188 | + 'ik' => 'Inupiaq', |
|
| 189 | + 'it' => 'Italian', |
|
| 190 | + 'jv' => 'Javanese', |
|
| 191 | + 'ja' => 'Japanese', |
|
| 192 | + 'kl' => 'Kalaallisut; Greenlandic', |
|
| 193 | + 'kn' => 'Kannada', |
|
| 194 | + 'ks' => 'Kashmiri', |
|
| 195 | + 'kr' => 'Kanuri', |
|
| 196 | + 'kk' => 'Kazakh', |
|
| 197 | + 'km' => 'Central Khmer', |
|
| 198 | + 'ki' => 'Kikuyu; Gikuyu', |
|
| 199 | + 'rw' => 'Kinyarwanda', |
|
| 200 | + 'ky' => 'Kirghiz; Kyrgyz', |
|
| 201 | + 'kv' => 'Komi', |
|
| 202 | + 'kg' => 'Kongo', |
|
| 203 | + 'ko' => 'Korean', |
|
| 204 | + 'kj' => 'Kuanyama; Kwanyama', |
|
| 205 | + 'ku' => 'Kurdish', |
|
| 206 | + 'lo' => 'Lao', |
|
| 207 | + 'la' => 'Latin', |
|
| 208 | + 'lv' => 'Latvian', |
|
| 209 | + 'li' => 'Limburgan; Limburger; Limburgish', |
|
| 210 | + 'ln' => 'Lingala', |
|
| 211 | + 'lt' => 'Lithuanian', |
|
| 212 | + 'lb' => 'Luxembourgish; Letzeburgesch', |
|
| 213 | + 'lu' => 'Luba-Katanga', |
|
| 214 | + 'lg' => 'Ganda', |
|
| 215 | + 'mk' => 'Macedonian', |
|
| 216 | + 'mh' => 'Marshallese', |
|
| 217 | + 'ml' => 'Malayalam', |
|
| 218 | + 'mi' => 'Maori', |
|
| 219 | + 'mr' => 'Marathi', |
|
| 220 | + 'ms' => 'Malay', |
|
| 221 | + 'mg' => 'Malagasy', |
|
| 222 | + 'mt' => 'Maltese', |
|
| 223 | + 'mo' => 'Moldavian', |
|
| 224 | + 'mn' => 'Mongolian', |
|
| 225 | + 'na' => 'Nauru', |
|
| 226 | + 'nv' => 'Navajo; Navaho', |
|
| 227 | + 'nr' => 'Ndebele, South; South Ndebele', |
|
| 228 | + 'nd' => 'Ndebele, North; North Ndebele', |
|
| 229 | + 'ng' => 'Ndonga', |
|
| 230 | + 'ne' => 'Nepali', |
|
| 231 | + 'nn' => 'Norwegian Nynorsk; Nynorsk, Norwegian', |
|
| 232 | + 'nb' => 'Bokmål, Norwegian, Norwegian Bokmål', |
|
| 233 | + 'no' => 'Norwegian', |
|
| 234 | + 'ny' => 'Chichewa; Chewa; Nyanja', |
|
| 235 | + 'oc' => 'Occitan, Provençal', |
|
| 236 | + 'oj' => 'Ojibwa', |
|
| 237 | + 'or' => 'Oriya', |
|
| 238 | + 'om' => 'Oromo', |
|
| 239 | + 'os' => 'Ossetian; Ossetic', |
|
| 240 | + 'pa' => 'Panjabi; Punjabi', |
|
| 241 | + 'fa' => 'Persian', |
|
| 242 | + 'pi' => 'Pali', |
|
| 243 | + 'pl' => 'Polish', |
|
| 244 | + 'pt' => 'Portuguese', |
|
| 245 | + 'ps' => 'Pushto', |
|
| 246 | + 'qu' => 'Quechua', |
|
| 247 | + 'rm' => 'Romansh', |
|
| 248 | + 'ro' => 'Romanian', |
|
| 249 | + 'rn' => 'Rundi', |
|
| 250 | + 'ru' => 'Russian', |
|
| 251 | + 'sg' => 'Sango', |
|
| 252 | + 'sa' => 'Sanskrit', |
|
| 253 | + 'sr' => 'Serbian', |
|
| 254 | + 'hr' => 'Croatian', |
|
| 255 | + 'si' => 'Sinhala; Sinhalese', |
|
| 256 | + 'sk' => 'Slovak', |
|
| 257 | + 'sl' => 'Slovenian', |
|
| 258 | + 'se' => 'Northern Sami', |
|
| 259 | + 'sm' => 'Samoan', |
|
| 260 | + 'sn' => 'Shona', |
|
| 261 | + 'sd' => 'Sindhi', |
|
| 262 | + 'so' => 'Somali', |
|
| 263 | + 'st' => 'Sotho, Southern', |
|
| 264 | + 'es' => 'Spanish; Castilian', |
|
| 265 | + 'sc' => 'Sardinian', |
|
| 266 | + 'ss' => 'Swati', |
|
| 267 | + 'su' => 'Sundanese', |
|
| 268 | + 'sw' => 'Swahili', |
|
| 269 | + 'sv' => 'Swedish', |
|
| 270 | + 'ty' => 'Tahitian', |
|
| 271 | + 'ta' => 'Tamil', |
|
| 272 | + 'tt' => 'Tatar', |
|
| 273 | + 'te' => 'Telugu', |
|
| 274 | + 'tg' => 'Tajik', |
|
| 275 | + 'tl' => 'Tagalog', |
|
| 276 | + 'th' => 'Thai', |
|
| 277 | + 'bo' => 'Tibetan', |
|
| 278 | + 'ti' => 'Tigrinya', |
|
| 279 | + 'to' => 'Tonga (Tonga Islands)', |
|
| 280 | + 'tn' => 'Tswana', |
|
| 281 | + 'ts' => 'Tsonga', |
|
| 282 | + 'tk' => 'Turkmen', |
|
| 283 | + 'tr' => 'Turkish', |
|
| 284 | + 'tw' => 'Twi', |
|
| 285 | + 'ug' => 'Uighur; Uyghur', |
|
| 286 | + 'uk' => 'Ukrainian', |
|
| 287 | + 'ur' => 'Urdu', |
|
| 288 | + 'uz' => 'Uzbek', |
|
| 289 | + 've' => 'Venda', |
|
| 290 | + 'vi' => 'Vietnamese', |
|
| 291 | + 'vo' => 'Volapük', |
|
| 292 | + 'cy' => 'Welsh', |
|
| 293 | + 'wa' => 'Walloon', |
|
| 294 | + 'wo' => 'Wolof', |
|
| 295 | + 'xh' => 'Xhosa', |
|
| 296 | + 'yi' => 'Yiddish', |
|
| 297 | + 'yo' => 'Yoruba', |
|
| 298 | + 'za' => 'Zhuang; Chuang', |
|
| 299 | + 'zu' => 'Zulu' |
|
| 300 | + ); |
|
| 301 | 301 | |
| 302 | - /** |
|
| 303 | - * Filters the language codes. |
|
| 304 | - * |
|
| 305 | - * @since MU |
|
| 306 | - * |
|
| 307 | - * @param array $lang_codes Key/value pair of language codes where key is the short version. |
|
| 308 | - * @param string $code A two-letter designation of the language. |
|
| 309 | - */ |
|
| 310 | - $lang_codes = apply_filters( 'lang_codes', $lang_codes, $code ); |
|
| 302 | + /** |
|
| 303 | + * Filters the language codes. |
|
| 304 | + * |
|
| 305 | + * @since MU |
|
| 306 | + * |
|
| 307 | + * @param array $lang_codes Key/value pair of language codes where key is the short version. |
|
| 308 | + * @param string $code A two-letter designation of the language. |
|
| 309 | + */ |
|
| 310 | + $lang_codes = apply_filters( 'lang_codes', $lang_codes, $code ); |
|
| 311 | 311 | |
| 312 | - return strtr( $code, $lang_codes ); |
|
| 313 | - } |
|
| 312 | + return strtr( $code, $lang_codes ); |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | 315 | } |
@@ -17,280 +17,280 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class Wordlift_Entity_Uri_Service { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Holds the {@link Wordlift_Entity_Uri_Service} instance. |
|
| 22 | - * |
|
| 23 | - * @since 3.21.5 |
|
| 24 | - * @access private |
|
| 25 | - * @var Wordlift_Entity_Uri_Service $instance The {@link Wordlift_Entity_Uri_Service} singleton. |
|
| 26 | - */ |
|
| 27 | - private static $instance; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * A {@link Wordlift_Log_Service} instance. |
|
| 31 | - * |
|
| 32 | - * @since 3.16.3 |
|
| 33 | - * @access private |
|
| 34 | - * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 35 | - */ |
|
| 36 | - private $log; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * The {@link Wordlift_Configuration_Service} instance. |
|
| 40 | - * |
|
| 41 | - * @since 3.16.3 |
|
| 42 | - * @access private |
|
| 43 | - * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance. |
|
| 44 | - */ |
|
| 45 | - private $configuration_service; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * An array of URIs to post ID valid for the current request. |
|
| 49 | - * |
|
| 50 | - * @since 3.16.3 |
|
| 51 | - * @access private |
|
| 52 | - * @var array $uri_to_post An array of URIs to post ID valid for the current request. |
|
| 53 | - */ |
|
| 54 | - protected $uri_to_post; |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * Create a {@link Wordlift_Entity_Uri_Service} instance. |
|
| 58 | - * |
|
| 59 | - * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance. |
|
| 60 | - * |
|
| 61 | - * @since 3.16.3 |
|
| 62 | - * |
|
| 63 | - */ |
|
| 64 | - public function __construct( $configuration_service ) { |
|
| 65 | - |
|
| 66 | - $this->log = Wordlift_Log_Service::get_logger( get_class() ); |
|
| 67 | - |
|
| 68 | - $this->configuration_service = $configuration_service; |
|
| 69 | - |
|
| 70 | - // Add a filter to the `rest_post_dispatch` filter to add the wl_entity_url meta as `wl:entity_url`. |
|
| 71 | - add_filter( 'rest_post_dispatch', array( $this, 'rest_post_dispatch' ) ); |
|
| 72 | - |
|
| 73 | - self::$instance = $this; |
|
| 74 | - |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * Get the singleton. |
|
| 79 | - * |
|
| 80 | - * @return Wordlift_Entity_Uri_Service The singleton instance. |
|
| 81 | - * @since 3.21.5 |
|
| 82 | - */ |
|
| 83 | - public static function get_instance() { |
|
| 84 | - |
|
| 85 | - return self::$instance; |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * Preload the provided URIs in the local cache. |
|
| 90 | - * |
|
| 91 | - * This function will populate the local `$uri_to_post` array by running a |
|
| 92 | - * single query with all the URIs and returning the mappings in the array. |
|
| 93 | - * |
|
| 94 | - * @param array $uris An array of URIs. |
|
| 95 | - * |
|
| 96 | - * @since 3.16.3 |
|
| 97 | - * |
|
| 98 | - */ |
|
| 99 | - public function preload_uris( $uris ) { |
|
| 100 | - |
|
| 101 | - // Bail out if there are no URIs. |
|
| 102 | - if ( 0 === count( $uris ) ) { |
|
| 103 | - return; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - $this->log->trace( 'Preloading ' . count( $uris ) . ' URI(s)...' ); |
|
| 107 | - |
|
| 108 | - $that = $this; |
|
| 109 | - $external_uris = array_filter( $uris, function ( $item ) use ( $that ) { |
|
| 110 | - return ! $that->is_internal( $item ); |
|
| 111 | - } ); |
|
| 112 | - |
|
| 113 | - $query_args = array( |
|
| 114 | - // See https://github.com/insideout10/wordlift-plugin/issues/654. |
|
| 115 | - 'ignore_sticky_posts' => 1, |
|
| 116 | - 'cache_results' => false, |
|
| 117 | - 'numberposts' => - 1, |
|
| 118 | - 'post_status' => array( 'publish', 'draft', 'private', 'future' ), |
|
| 119 | - 'post_type' => Wordlift_Entity_Service::valid_entity_post_types(), |
|
| 120 | - 'meta_query' => array( |
|
| 121 | - array( |
|
| 122 | - 'key' => WL_ENTITY_URL_META_NAME, |
|
| 123 | - 'value' => $uris, |
|
| 124 | - 'compare' => 'IN', |
|
| 125 | - ), |
|
| 126 | - ), |
|
| 127 | - ); |
|
| 128 | - |
|
| 129 | - // Only if the current uri is not an internal uri, entity search is |
|
| 130 | - // performed also looking at sameAs values. |
|
| 131 | - // |
|
| 132 | - // This solve issues like https://github.com/insideout10/wordlift-plugin/issues/237 |
|
| 133 | - if ( 0 < count( $external_uris ) ) { |
|
| 134 | - |
|
| 135 | - $query_args['meta_query']['relation'] = 'OR'; |
|
| 136 | - $query_args['meta_query'][] = array( |
|
| 137 | - 'key' => Wordlift_Schema_Service::FIELD_SAME_AS, |
|
| 138 | - 'value' => $external_uris, |
|
| 139 | - 'compare' => 'IN', |
|
| 140 | - ); |
|
| 141 | - |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - // Get the posts. |
|
| 145 | - $posts = get_posts( $query_args ); |
|
| 146 | - |
|
| 147 | - // Populate the array. We reinitialize the array on purpose because |
|
| 148 | - // we don't want these data to long live. |
|
| 149 | - $this->uri_to_post = array_reduce( $posts, function ( $carry, $item ) use ( $that ) { |
|
| 150 | - $uris = array_merge( |
|
| 151 | - get_post_meta( $item->ID, WL_ENTITY_URL_META_NAME ), |
|
| 152 | - get_post_meta( $item->ID, Wordlift_Schema_Service::FIELD_SAME_AS ) |
|
| 153 | - ); |
|
| 154 | - |
|
| 155 | - return $carry |
|
| 156 | - // Get the URI related to the post and fill them with the item id. |
|
| 157 | - + array_fill_keys( $uris, $item ); |
|
| 158 | - }, array() ); |
|
| 159 | - |
|
| 160 | - // Add the not found URIs. |
|
| 161 | - $this->uri_to_post += array_fill_keys( $uris, null ); |
|
| 162 | - |
|
| 163 | - $this->log->debug( count( $this->uri_to_post ) . " URI(s) preloaded." ); |
|
| 164 | - |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * Reset the URI to post local cache. |
|
| 169 | - * |
|
| 170 | - * @since 3.16.3 |
|
| 171 | - */ |
|
| 172 | - public function reset_uris() { |
|
| 173 | - |
|
| 174 | - $this->uri_to_post = array(); |
|
| 175 | - |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * Find entity posts by the entity URI. Entity as searched by their entity URI or same as. |
|
| 180 | - * |
|
| 181 | - * @param string $uri The entity URI. |
|
| 182 | - * |
|
| 183 | - * @return WP_Post|null A WP_Post instance or null if not found. |
|
| 184 | - * @since 3.2.0 |
|
| 185 | - * |
|
| 186 | - */ |
|
| 187 | - public function get_entity( $uri ) { |
|
| 188 | - |
|
| 189 | - $this->log->trace( "Getting an entity post for URI $uri..." ); |
|
| 190 | - |
|
| 191 | - // Check if we've been provided with a value otherwise return null. |
|
| 192 | - if ( empty( $uri ) ) { |
|
| 193 | - return null; |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - $this->log->debug( "Querying post for $uri..." ); |
|
| 197 | - |
|
| 198 | - $query_args = array( |
|
| 199 | - // See https://github.com/insideout10/wordlift-plugin/issues/654. |
|
| 200 | - 'ignore_sticky_posts' => 1, |
|
| 201 | - 'posts_per_page' => 1, |
|
| 202 | - 'post_status' => 'any', |
|
| 203 | - 'post_type' => Wordlift_Entity_Service::valid_entity_post_types(), |
|
| 204 | - 'meta_query' => array( |
|
| 205 | - array( |
|
| 206 | - 'key' => WL_ENTITY_URL_META_NAME, |
|
| 207 | - 'value' => $uri, |
|
| 208 | - 'compare' => '=', |
|
| 209 | - ), |
|
| 210 | - ), |
|
| 211 | - ); |
|
| 212 | - |
|
| 213 | - // Only if the current uri is not an internal uri, entity search is |
|
| 214 | - // performed also looking at sameAs values. |
|
| 215 | - // |
|
| 216 | - // This solve issues like https://github.com/insideout10/wordlift-plugin/issues/237 |
|
| 217 | - if ( ! $this->is_internal( $uri ) ) { |
|
| 218 | - |
|
| 219 | - $query_args['meta_query']['relation'] = 'OR'; |
|
| 220 | - $query_args['meta_query'][] = array( |
|
| 221 | - 'key' => Wordlift_Schema_Service::FIELD_SAME_AS, |
|
| 222 | - 'value' => $uri, |
|
| 223 | - 'compare' => '=', |
|
| 224 | - ); |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - $posts = get_posts( $query_args ); |
|
| 228 | - |
|
| 229 | - // Attempt to find post by URI (only for local entity URLs) |
|
| 230 | - if ( empty( $posts ) ) { |
|
| 231 | - |
|
| 232 | - $this->log->debug( "Finding post by $uri..." ); |
|
| 233 | - $postid = url_to_postid( $uri ); |
|
| 234 | - if ( $postid !== 0 ) { |
|
| 235 | - $this->log->trace( "Found post $postid by URL" ); |
|
| 236 | - |
|
| 237 | - return get_post( $postid ); |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - // Return null if no post is found. |
|
| 243 | - if ( empty( $posts ) ) { |
|
| 244 | - $this->log->warn( "No post for URI $uri." ); |
|
| 245 | - |
|
| 246 | - return null; |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - // Return the found post. |
|
| 250 | - return current( $posts ); |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - /** |
|
| 254 | - * Determines whether a given uri is an internal uri or not. |
|
| 255 | - * |
|
| 256 | - * @param string $uri An uri. |
|
| 257 | - * |
|
| 258 | - * @return true if the uri internal to the current dataset otherwise false. |
|
| 259 | - * @since 3.16.3 |
|
| 260 | - * |
|
| 261 | - */ |
|
| 262 | - public function is_internal( $uri ) { |
|
| 263 | - |
|
| 264 | - return ( 0 === strrpos( $uri, (string) $this->configuration_service->get_dataset_uri() ) ); |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - /** |
|
| 268 | - * Hook to `rest_post_dispatch` to alter the response and add the `wl_entity_url` post meta as `wl:entity_url`. |
|
| 269 | - * |
|
| 270 | - * We're using this filter instead of the well known `register_meta` / `register_rest_field` because we still need |
|
| 271 | - * to provide full compatibility with WordPress 4.4+. |
|
| 272 | - * |
|
| 273 | - * @param WP_HTTP_Response $result Result to send to the client. Usually a WP_REST_Response. |
|
| 274 | - * |
|
| 275 | - * @return WP_HTTP_Response The result to send to the client. |
|
| 276 | - * |
|
| 277 | - * @since 3.23.0 |
|
| 278 | - */ |
|
| 279 | - public function rest_post_dispatch( $result ) { |
|
| 280 | - |
|
| 281 | - // Get a reference to the actual data. |
|
| 282 | - $data = &$result->data; |
|
| 283 | - |
|
| 284 | - // Bail out if we don't have the required parameters, or if the type is not a valid entity. |
|
| 285 | - if ( ! is_array( $data ) || ! isset( $data['id'] ) || ! isset( $data['type'] ) |
|
| 286 | - || ! Wordlift_Entity_Type_Service::is_valid_entity_post_type( $data['type'] ) ) { |
|
| 287 | - return $result; |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - // Add the `wl:entity_url`. |
|
| 291 | - $data['wl:entity_url'] = Wordlift_Entity_Service::get_instance()->get_uri( $data['id'] ); |
|
| 292 | - |
|
| 293 | - return $result; |
|
| 294 | - } |
|
| 20 | + /** |
|
| 21 | + * Holds the {@link Wordlift_Entity_Uri_Service} instance. |
|
| 22 | + * |
|
| 23 | + * @since 3.21.5 |
|
| 24 | + * @access private |
|
| 25 | + * @var Wordlift_Entity_Uri_Service $instance The {@link Wordlift_Entity_Uri_Service} singleton. |
|
| 26 | + */ |
|
| 27 | + private static $instance; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * A {@link Wordlift_Log_Service} instance. |
|
| 31 | + * |
|
| 32 | + * @since 3.16.3 |
|
| 33 | + * @access private |
|
| 34 | + * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 35 | + */ |
|
| 36 | + private $log; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * The {@link Wordlift_Configuration_Service} instance. |
|
| 40 | + * |
|
| 41 | + * @since 3.16.3 |
|
| 42 | + * @access private |
|
| 43 | + * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance. |
|
| 44 | + */ |
|
| 45 | + private $configuration_service; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * An array of URIs to post ID valid for the current request. |
|
| 49 | + * |
|
| 50 | + * @since 3.16.3 |
|
| 51 | + * @access private |
|
| 52 | + * @var array $uri_to_post An array of URIs to post ID valid for the current request. |
|
| 53 | + */ |
|
| 54 | + protected $uri_to_post; |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * Create a {@link Wordlift_Entity_Uri_Service} instance. |
|
| 58 | + * |
|
| 59 | + * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance. |
|
| 60 | + * |
|
| 61 | + * @since 3.16.3 |
|
| 62 | + * |
|
| 63 | + */ |
|
| 64 | + public function __construct( $configuration_service ) { |
|
| 65 | + |
|
| 66 | + $this->log = Wordlift_Log_Service::get_logger( get_class() ); |
|
| 67 | + |
|
| 68 | + $this->configuration_service = $configuration_service; |
|
| 69 | + |
|
| 70 | + // Add a filter to the `rest_post_dispatch` filter to add the wl_entity_url meta as `wl:entity_url`. |
|
| 71 | + add_filter( 'rest_post_dispatch', array( $this, 'rest_post_dispatch' ) ); |
|
| 72 | + |
|
| 73 | + self::$instance = $this; |
|
| 74 | + |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * Get the singleton. |
|
| 79 | + * |
|
| 80 | + * @return Wordlift_Entity_Uri_Service The singleton instance. |
|
| 81 | + * @since 3.21.5 |
|
| 82 | + */ |
|
| 83 | + public static function get_instance() { |
|
| 84 | + |
|
| 85 | + return self::$instance; |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * Preload the provided URIs in the local cache. |
|
| 90 | + * |
|
| 91 | + * This function will populate the local `$uri_to_post` array by running a |
|
| 92 | + * single query with all the URIs and returning the mappings in the array. |
|
| 93 | + * |
|
| 94 | + * @param array $uris An array of URIs. |
|
| 95 | + * |
|
| 96 | + * @since 3.16.3 |
|
| 97 | + * |
|
| 98 | + */ |
|
| 99 | + public function preload_uris( $uris ) { |
|
| 100 | + |
|
| 101 | + // Bail out if there are no URIs. |
|
| 102 | + if ( 0 === count( $uris ) ) { |
|
| 103 | + return; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + $this->log->trace( 'Preloading ' . count( $uris ) . ' URI(s)...' ); |
|
| 107 | + |
|
| 108 | + $that = $this; |
|
| 109 | + $external_uris = array_filter( $uris, function ( $item ) use ( $that ) { |
|
| 110 | + return ! $that->is_internal( $item ); |
|
| 111 | + } ); |
|
| 112 | + |
|
| 113 | + $query_args = array( |
|
| 114 | + // See https://github.com/insideout10/wordlift-plugin/issues/654. |
|
| 115 | + 'ignore_sticky_posts' => 1, |
|
| 116 | + 'cache_results' => false, |
|
| 117 | + 'numberposts' => - 1, |
|
| 118 | + 'post_status' => array( 'publish', 'draft', 'private', 'future' ), |
|
| 119 | + 'post_type' => Wordlift_Entity_Service::valid_entity_post_types(), |
|
| 120 | + 'meta_query' => array( |
|
| 121 | + array( |
|
| 122 | + 'key' => WL_ENTITY_URL_META_NAME, |
|
| 123 | + 'value' => $uris, |
|
| 124 | + 'compare' => 'IN', |
|
| 125 | + ), |
|
| 126 | + ), |
|
| 127 | + ); |
|
| 128 | + |
|
| 129 | + // Only if the current uri is not an internal uri, entity search is |
|
| 130 | + // performed also looking at sameAs values. |
|
| 131 | + // |
|
| 132 | + // This solve issues like https://github.com/insideout10/wordlift-plugin/issues/237 |
|
| 133 | + if ( 0 < count( $external_uris ) ) { |
|
| 134 | + |
|
| 135 | + $query_args['meta_query']['relation'] = 'OR'; |
|
| 136 | + $query_args['meta_query'][] = array( |
|
| 137 | + 'key' => Wordlift_Schema_Service::FIELD_SAME_AS, |
|
| 138 | + 'value' => $external_uris, |
|
| 139 | + 'compare' => 'IN', |
|
| 140 | + ); |
|
| 141 | + |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + // Get the posts. |
|
| 145 | + $posts = get_posts( $query_args ); |
|
| 146 | + |
|
| 147 | + // Populate the array. We reinitialize the array on purpose because |
|
| 148 | + // we don't want these data to long live. |
|
| 149 | + $this->uri_to_post = array_reduce( $posts, function ( $carry, $item ) use ( $that ) { |
|
| 150 | + $uris = array_merge( |
|
| 151 | + get_post_meta( $item->ID, WL_ENTITY_URL_META_NAME ), |
|
| 152 | + get_post_meta( $item->ID, Wordlift_Schema_Service::FIELD_SAME_AS ) |
|
| 153 | + ); |
|
| 154 | + |
|
| 155 | + return $carry |
|
| 156 | + // Get the URI related to the post and fill them with the item id. |
|
| 157 | + + array_fill_keys( $uris, $item ); |
|
| 158 | + }, array() ); |
|
| 159 | + |
|
| 160 | + // Add the not found URIs. |
|
| 161 | + $this->uri_to_post += array_fill_keys( $uris, null ); |
|
| 162 | + |
|
| 163 | + $this->log->debug( count( $this->uri_to_post ) . " URI(s) preloaded." ); |
|
| 164 | + |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * Reset the URI to post local cache. |
|
| 169 | + * |
|
| 170 | + * @since 3.16.3 |
|
| 171 | + */ |
|
| 172 | + public function reset_uris() { |
|
| 173 | + |
|
| 174 | + $this->uri_to_post = array(); |
|
| 175 | + |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * Find entity posts by the entity URI. Entity as searched by their entity URI or same as. |
|
| 180 | + * |
|
| 181 | + * @param string $uri The entity URI. |
|
| 182 | + * |
|
| 183 | + * @return WP_Post|null A WP_Post instance or null if not found. |
|
| 184 | + * @since 3.2.0 |
|
| 185 | + * |
|
| 186 | + */ |
|
| 187 | + public function get_entity( $uri ) { |
|
| 188 | + |
|
| 189 | + $this->log->trace( "Getting an entity post for URI $uri..." ); |
|
| 190 | + |
|
| 191 | + // Check if we've been provided with a value otherwise return null. |
|
| 192 | + if ( empty( $uri ) ) { |
|
| 193 | + return null; |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + $this->log->debug( "Querying post for $uri..." ); |
|
| 197 | + |
|
| 198 | + $query_args = array( |
|
| 199 | + // See https://github.com/insideout10/wordlift-plugin/issues/654. |
|
| 200 | + 'ignore_sticky_posts' => 1, |
|
| 201 | + 'posts_per_page' => 1, |
|
| 202 | + 'post_status' => 'any', |
|
| 203 | + 'post_type' => Wordlift_Entity_Service::valid_entity_post_types(), |
|
| 204 | + 'meta_query' => array( |
|
| 205 | + array( |
|
| 206 | + 'key' => WL_ENTITY_URL_META_NAME, |
|
| 207 | + 'value' => $uri, |
|
| 208 | + 'compare' => '=', |
|
| 209 | + ), |
|
| 210 | + ), |
|
| 211 | + ); |
|
| 212 | + |
|
| 213 | + // Only if the current uri is not an internal uri, entity search is |
|
| 214 | + // performed also looking at sameAs values. |
|
| 215 | + // |
|
| 216 | + // This solve issues like https://github.com/insideout10/wordlift-plugin/issues/237 |
|
| 217 | + if ( ! $this->is_internal( $uri ) ) { |
|
| 218 | + |
|
| 219 | + $query_args['meta_query']['relation'] = 'OR'; |
|
| 220 | + $query_args['meta_query'][] = array( |
|
| 221 | + 'key' => Wordlift_Schema_Service::FIELD_SAME_AS, |
|
| 222 | + 'value' => $uri, |
|
| 223 | + 'compare' => '=', |
|
| 224 | + ); |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + $posts = get_posts( $query_args ); |
|
| 228 | + |
|
| 229 | + // Attempt to find post by URI (only for local entity URLs) |
|
| 230 | + if ( empty( $posts ) ) { |
|
| 231 | + |
|
| 232 | + $this->log->debug( "Finding post by $uri..." ); |
|
| 233 | + $postid = url_to_postid( $uri ); |
|
| 234 | + if ( $postid !== 0 ) { |
|
| 235 | + $this->log->trace( "Found post $postid by URL" ); |
|
| 236 | + |
|
| 237 | + return get_post( $postid ); |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + // Return null if no post is found. |
|
| 243 | + if ( empty( $posts ) ) { |
|
| 244 | + $this->log->warn( "No post for URI $uri." ); |
|
| 245 | + |
|
| 246 | + return null; |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + // Return the found post. |
|
| 250 | + return current( $posts ); |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + /** |
|
| 254 | + * Determines whether a given uri is an internal uri or not. |
|
| 255 | + * |
|
| 256 | + * @param string $uri An uri. |
|
| 257 | + * |
|
| 258 | + * @return true if the uri internal to the current dataset otherwise false. |
|
| 259 | + * @since 3.16.3 |
|
| 260 | + * |
|
| 261 | + */ |
|
| 262 | + public function is_internal( $uri ) { |
|
| 263 | + |
|
| 264 | + return ( 0 === strrpos( $uri, (string) $this->configuration_service->get_dataset_uri() ) ); |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + /** |
|
| 268 | + * Hook to `rest_post_dispatch` to alter the response and add the `wl_entity_url` post meta as `wl:entity_url`. |
|
| 269 | + * |
|
| 270 | + * We're using this filter instead of the well known `register_meta` / `register_rest_field` because we still need |
|
| 271 | + * to provide full compatibility with WordPress 4.4+. |
|
| 272 | + * |
|
| 273 | + * @param WP_HTTP_Response $result Result to send to the client. Usually a WP_REST_Response. |
|
| 274 | + * |
|
| 275 | + * @return WP_HTTP_Response The result to send to the client. |
|
| 276 | + * |
|
| 277 | + * @since 3.23.0 |
|
| 278 | + */ |
|
| 279 | + public function rest_post_dispatch( $result ) { |
|
| 280 | + |
|
| 281 | + // Get a reference to the actual data. |
|
| 282 | + $data = &$result->data; |
|
| 283 | + |
|
| 284 | + // Bail out if we don't have the required parameters, or if the type is not a valid entity. |
|
| 285 | + if ( ! is_array( $data ) || ! isset( $data['id'] ) || ! isset( $data['type'] ) |
|
| 286 | + || ! Wordlift_Entity_Type_Service::is_valid_entity_post_type( $data['type'] ) ) { |
|
| 287 | + return $result; |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + // Add the `wl:entity_url`. |
|
| 291 | + $data['wl:entity_url'] = Wordlift_Entity_Service::get_instance()->get_uri( $data['id'] ); |
|
| 292 | + |
|
| 293 | + return $result; |
|
| 294 | + } |
|
| 295 | 295 | |
| 296 | 296 | } |
@@ -61,14 +61,14 @@ discard block |
||
| 61 | 61 | * @since 3.16.3 |
| 62 | 62 | * |
| 63 | 63 | */ |
| 64 | - public function __construct( $configuration_service ) { |
|
| 64 | + public function __construct($configuration_service) { |
|
| 65 | 65 | |
| 66 | - $this->log = Wordlift_Log_Service::get_logger( get_class() ); |
|
| 66 | + $this->log = Wordlift_Log_Service::get_logger(get_class()); |
|
| 67 | 67 | |
| 68 | 68 | $this->configuration_service = $configuration_service; |
| 69 | 69 | |
| 70 | 70 | // Add a filter to the `rest_post_dispatch` filter to add the wl_entity_url meta as `wl:entity_url`. |
| 71 | - add_filter( 'rest_post_dispatch', array( $this, 'rest_post_dispatch' ) ); |
|
| 71 | + add_filter('rest_post_dispatch', array($this, 'rest_post_dispatch')); |
|
| 72 | 72 | |
| 73 | 73 | self::$instance = $this; |
| 74 | 74 | |
@@ -96,26 +96,26 @@ discard block |
||
| 96 | 96 | * @since 3.16.3 |
| 97 | 97 | * |
| 98 | 98 | */ |
| 99 | - public function preload_uris( $uris ) { |
|
| 99 | + public function preload_uris($uris) { |
|
| 100 | 100 | |
| 101 | 101 | // Bail out if there are no URIs. |
| 102 | - if ( 0 === count( $uris ) ) { |
|
| 102 | + if (0 === count($uris)) { |
|
| 103 | 103 | return; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - $this->log->trace( 'Preloading ' . count( $uris ) . ' URI(s)...' ); |
|
| 106 | + $this->log->trace('Preloading '.count($uris).' URI(s)...'); |
|
| 107 | 107 | |
| 108 | 108 | $that = $this; |
| 109 | - $external_uris = array_filter( $uris, function ( $item ) use ( $that ) { |
|
| 110 | - return ! $that->is_internal( $item ); |
|
| 109 | + $external_uris = array_filter($uris, function($item) use ($that) { |
|
| 110 | + return ! $that->is_internal($item); |
|
| 111 | 111 | } ); |
| 112 | 112 | |
| 113 | 113 | $query_args = array( |
| 114 | 114 | // See https://github.com/insideout10/wordlift-plugin/issues/654. |
| 115 | 115 | 'ignore_sticky_posts' => 1, |
| 116 | 116 | 'cache_results' => false, |
| 117 | - 'numberposts' => - 1, |
|
| 118 | - 'post_status' => array( 'publish', 'draft', 'private', 'future' ), |
|
| 117 | + 'numberposts' => -1, |
|
| 118 | + 'post_status' => array('publish', 'draft', 'private', 'future'), |
|
| 119 | 119 | 'post_type' => Wordlift_Entity_Service::valid_entity_post_types(), |
| 120 | 120 | 'meta_query' => array( |
| 121 | 121 | array( |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | // performed also looking at sameAs values. |
| 131 | 131 | // |
| 132 | 132 | // This solve issues like https://github.com/insideout10/wordlift-plugin/issues/237 |
| 133 | - if ( 0 < count( $external_uris ) ) { |
|
| 133 | + if (0 < count($external_uris)) { |
|
| 134 | 134 | |
| 135 | 135 | $query_args['meta_query']['relation'] = 'OR'; |
| 136 | 136 | $query_args['meta_query'][] = array( |
@@ -142,25 +142,25 @@ discard block |
||
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | // Get the posts. |
| 145 | - $posts = get_posts( $query_args ); |
|
| 145 | + $posts = get_posts($query_args); |
|
| 146 | 146 | |
| 147 | 147 | // Populate the array. We reinitialize the array on purpose because |
| 148 | 148 | // we don't want these data to long live. |
| 149 | - $this->uri_to_post = array_reduce( $posts, function ( $carry, $item ) use ( $that ) { |
|
| 149 | + $this->uri_to_post = array_reduce($posts, function($carry, $item) use ($that) { |
|
| 150 | 150 | $uris = array_merge( |
| 151 | - get_post_meta( $item->ID, WL_ENTITY_URL_META_NAME ), |
|
| 152 | - get_post_meta( $item->ID, Wordlift_Schema_Service::FIELD_SAME_AS ) |
|
| 151 | + get_post_meta($item->ID, WL_ENTITY_URL_META_NAME), |
|
| 152 | + get_post_meta($item->ID, Wordlift_Schema_Service::FIELD_SAME_AS) |
|
| 153 | 153 | ); |
| 154 | 154 | |
| 155 | 155 | return $carry |
| 156 | 156 | // Get the URI related to the post and fill them with the item id. |
| 157 | - + array_fill_keys( $uris, $item ); |
|
| 158 | - }, array() ); |
|
| 157 | + + array_fill_keys($uris, $item); |
|
| 158 | + }, array()); |
|
| 159 | 159 | |
| 160 | 160 | // Add the not found URIs. |
| 161 | - $this->uri_to_post += array_fill_keys( $uris, null ); |
|
| 161 | + $this->uri_to_post += array_fill_keys($uris, null); |
|
| 162 | 162 | |
| 163 | - $this->log->debug( count( $this->uri_to_post ) . " URI(s) preloaded." ); |
|
| 163 | + $this->log->debug(count($this->uri_to_post)." URI(s) preloaded."); |
|
| 164 | 164 | |
| 165 | 165 | } |
| 166 | 166 | |
@@ -184,16 +184,16 @@ discard block |
||
| 184 | 184 | * @since 3.2.0 |
| 185 | 185 | * |
| 186 | 186 | */ |
| 187 | - public function get_entity( $uri ) { |
|
| 187 | + public function get_entity($uri) { |
|
| 188 | 188 | |
| 189 | - $this->log->trace( "Getting an entity post for URI $uri..." ); |
|
| 189 | + $this->log->trace("Getting an entity post for URI $uri..."); |
|
| 190 | 190 | |
| 191 | 191 | // Check if we've been provided with a value otherwise return null. |
| 192 | - if ( empty( $uri ) ) { |
|
| 192 | + if (empty($uri)) { |
|
| 193 | 193 | return null; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - $this->log->debug( "Querying post for $uri..." ); |
|
| 196 | + $this->log->debug("Querying post for $uri..."); |
|
| 197 | 197 | |
| 198 | 198 | $query_args = array( |
| 199 | 199 | // See https://github.com/insideout10/wordlift-plugin/issues/654. |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | // performed also looking at sameAs values. |
| 215 | 215 | // |
| 216 | 216 | // This solve issues like https://github.com/insideout10/wordlift-plugin/issues/237 |
| 217 | - if ( ! $this->is_internal( $uri ) ) { |
|
| 217 | + if ( ! $this->is_internal($uri)) { |
|
| 218 | 218 | |
| 219 | 219 | $query_args['meta_query']['relation'] = 'OR'; |
| 220 | 220 | $query_args['meta_query'][] = array( |
@@ -224,30 +224,30 @@ discard block |
||
| 224 | 224 | ); |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - $posts = get_posts( $query_args ); |
|
| 227 | + $posts = get_posts($query_args); |
|
| 228 | 228 | |
| 229 | 229 | // Attempt to find post by URI (only for local entity URLs) |
| 230 | - if ( empty( $posts ) ) { |
|
| 230 | + if (empty($posts)) { |
|
| 231 | 231 | |
| 232 | - $this->log->debug( "Finding post by $uri..." ); |
|
| 233 | - $postid = url_to_postid( $uri ); |
|
| 234 | - if ( $postid !== 0 ) { |
|
| 235 | - $this->log->trace( "Found post $postid by URL" ); |
|
| 232 | + $this->log->debug("Finding post by $uri..."); |
|
| 233 | + $postid = url_to_postid($uri); |
|
| 234 | + if ($postid !== 0) { |
|
| 235 | + $this->log->trace("Found post $postid by URL"); |
|
| 236 | 236 | |
| 237 | - return get_post( $postid ); |
|
| 237 | + return get_post($postid); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | // Return null if no post is found. |
| 243 | - if ( empty( $posts ) ) { |
|
| 244 | - $this->log->warn( "No post for URI $uri." ); |
|
| 243 | + if (empty($posts)) { |
|
| 244 | + $this->log->warn("No post for URI $uri."); |
|
| 245 | 245 | |
| 246 | 246 | return null; |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | // Return the found post. |
| 250 | - return current( $posts ); |
|
| 250 | + return current($posts); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** |
@@ -259,9 +259,9 @@ discard block |
||
| 259 | 259 | * @since 3.16.3 |
| 260 | 260 | * |
| 261 | 261 | */ |
| 262 | - public function is_internal( $uri ) { |
|
| 262 | + public function is_internal($uri) { |
|
| 263 | 263 | |
| 264 | - return ( 0 === strrpos( $uri, (string) $this->configuration_service->get_dataset_uri() ) ); |
|
| 264 | + return (0 === strrpos($uri, (string) $this->configuration_service->get_dataset_uri())); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | /** |
@@ -276,19 +276,19 @@ discard block |
||
| 276 | 276 | * |
| 277 | 277 | * @since 3.23.0 |
| 278 | 278 | */ |
| 279 | - public function rest_post_dispatch( $result ) { |
|
| 279 | + public function rest_post_dispatch($result) { |
|
| 280 | 280 | |
| 281 | 281 | // Get a reference to the actual data. |
| 282 | 282 | $data = &$result->data; |
| 283 | 283 | |
| 284 | 284 | // Bail out if we don't have the required parameters, or if the type is not a valid entity. |
| 285 | - if ( ! is_array( $data ) || ! isset( $data['id'] ) || ! isset( $data['type'] ) |
|
| 286 | - || ! Wordlift_Entity_Type_Service::is_valid_entity_post_type( $data['type'] ) ) { |
|
| 285 | + if ( ! is_array($data) || ! isset($data['id']) || ! isset($data['type']) |
|
| 286 | + || ! Wordlift_Entity_Type_Service::is_valid_entity_post_type($data['type'])) { |
|
| 287 | 287 | return $result; |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | // Add the `wl:entity_url`. |
| 291 | - $data['wl:entity_url'] = Wordlift_Entity_Service::get_instance()->get_uri( $data['id'] ); |
|
| 291 | + $data['wl:entity_url'] = Wordlift_Entity_Service::get_instance()->get_uri($data['id']); |
|
| 292 | 292 | |
| 293 | 293 | return $result; |
| 294 | 294 | } |
@@ -6,76 +6,76 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Jsonld_User_Service { |
| 8 | 8 | |
| 9 | - /** |
|
| 10 | - * @var \Wordlift_User_Service $user_service |
|
| 11 | - */ |
|
| 12 | - private $user_service; |
|
| 13 | - |
|
| 14 | - /** |
|
| 15 | - * @var Jsonld_Service |
|
| 16 | - */ |
|
| 17 | - private $jsonld_service; |
|
| 18 | - |
|
| 19 | - /** |
|
| 20 | - * Jsonld_User_Service constructor. |
|
| 21 | - * |
|
| 22 | - * @param \Wordlift_User_Service $user_service |
|
| 23 | - */ |
|
| 24 | - function __construct( $user_service ) { |
|
| 25 | - $this->user_service = $user_service; |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * @param Jsonld_Service $jsonld_service |
|
| 30 | - */ |
|
| 31 | - function set_jsonld_service( $jsonld_service ) { |
|
| 32 | - $this->jsonld_service = $jsonld_service; |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - function get( $user_id ) { |
|
| 36 | - $userdata = get_userdata( $user_id ); |
|
| 37 | - |
|
| 38 | - // Bail out if user not found. |
|
| 39 | - if ( ! ( $userdata instanceof \WP_User ) ) { |
|
| 40 | - return array(); |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - // Return the post JSON-LD if a post has been bound to this user. |
|
| 44 | - $post_id = $this->user_service->get_entity( $user_id ); |
|
| 45 | - if ( ! empty( $post_id ) && isset( $this->jsonld_service ) ) { |
|
| 46 | - return $this->jsonld_service->get( Object_Type_Enum::POST, $post_id ); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - // Bail out if the user doesn't have a valid URI. |
|
| 50 | - $uri = $this->user_service->get_uri( $user_id ); |
|
| 51 | - if ( empty( $uri ) ) { |
|
| 52 | - return array(); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - // Finally return the user's JSON-LD. |
|
| 56 | - $data = array( |
|
| 57 | - '@context' => 'http://schema.org', |
|
| 58 | - '@id' => $uri, |
|
| 59 | - '@type' => 'Person', |
|
| 60 | - ); |
|
| 61 | - |
|
| 62 | - if ( ! empty( $userdata->display_name ) ) { |
|
| 63 | - $data['name'] = $userdata->display_name; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - if ( ! empty( $userdata->first_name ) ) { |
|
| 67 | - $data['givenName'] = $userdata->first_name; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - if ( ! empty( $userdata->last_name ) ) { |
|
| 71 | - $data['familyName'] = $userdata->last_name; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - if ( ! empty( $userdata->user_url ) ) { |
|
| 75 | - $data['url'] = $userdata->user_url; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - return array( $data ); |
|
| 79 | - } |
|
| 9 | + /** |
|
| 10 | + * @var \Wordlift_User_Service $user_service |
|
| 11 | + */ |
|
| 12 | + private $user_service; |
|
| 13 | + |
|
| 14 | + /** |
|
| 15 | + * @var Jsonld_Service |
|
| 16 | + */ |
|
| 17 | + private $jsonld_service; |
|
| 18 | + |
|
| 19 | + /** |
|
| 20 | + * Jsonld_User_Service constructor. |
|
| 21 | + * |
|
| 22 | + * @param \Wordlift_User_Service $user_service |
|
| 23 | + */ |
|
| 24 | + function __construct( $user_service ) { |
|
| 25 | + $this->user_service = $user_service; |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * @param Jsonld_Service $jsonld_service |
|
| 30 | + */ |
|
| 31 | + function set_jsonld_service( $jsonld_service ) { |
|
| 32 | + $this->jsonld_service = $jsonld_service; |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + function get( $user_id ) { |
|
| 36 | + $userdata = get_userdata( $user_id ); |
|
| 37 | + |
|
| 38 | + // Bail out if user not found. |
|
| 39 | + if ( ! ( $userdata instanceof \WP_User ) ) { |
|
| 40 | + return array(); |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + // Return the post JSON-LD if a post has been bound to this user. |
|
| 44 | + $post_id = $this->user_service->get_entity( $user_id ); |
|
| 45 | + if ( ! empty( $post_id ) && isset( $this->jsonld_service ) ) { |
|
| 46 | + return $this->jsonld_service->get( Object_Type_Enum::POST, $post_id ); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + // Bail out if the user doesn't have a valid URI. |
|
| 50 | + $uri = $this->user_service->get_uri( $user_id ); |
|
| 51 | + if ( empty( $uri ) ) { |
|
| 52 | + return array(); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + // Finally return the user's JSON-LD. |
|
| 56 | + $data = array( |
|
| 57 | + '@context' => 'http://schema.org', |
|
| 58 | + '@id' => $uri, |
|
| 59 | + '@type' => 'Person', |
|
| 60 | + ); |
|
| 61 | + |
|
| 62 | + if ( ! empty( $userdata->display_name ) ) { |
|
| 63 | + $data['name'] = $userdata->display_name; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + if ( ! empty( $userdata->first_name ) ) { |
|
| 67 | + $data['givenName'] = $userdata->first_name; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + if ( ! empty( $userdata->last_name ) ) { |
|
| 71 | + $data['familyName'] = $userdata->last_name; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + if ( ! empty( $userdata->user_url ) ) { |
|
| 75 | + $data['url'] = $userdata->user_url; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + return array( $data ); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | 81 | } |
@@ -21,34 +21,34 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @param \Wordlift_User_Service $user_service |
| 23 | 23 | */ |
| 24 | - function __construct( $user_service ) { |
|
| 24 | + function __construct($user_service) { |
|
| 25 | 25 | $this->user_service = $user_service; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * @param Jsonld_Service $jsonld_service |
| 30 | 30 | */ |
| 31 | - function set_jsonld_service( $jsonld_service ) { |
|
| 31 | + function set_jsonld_service($jsonld_service) { |
|
| 32 | 32 | $this->jsonld_service = $jsonld_service; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - function get( $user_id ) { |
|
| 36 | - $userdata = get_userdata( $user_id ); |
|
| 35 | + function get($user_id) { |
|
| 36 | + $userdata = get_userdata($user_id); |
|
| 37 | 37 | |
| 38 | 38 | // Bail out if user not found. |
| 39 | - if ( ! ( $userdata instanceof \WP_User ) ) { |
|
| 39 | + if ( ! ($userdata instanceof \WP_User)) { |
|
| 40 | 40 | return array(); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // Return the post JSON-LD if a post has been bound to this user. |
| 44 | - $post_id = $this->user_service->get_entity( $user_id ); |
|
| 45 | - if ( ! empty( $post_id ) && isset( $this->jsonld_service ) ) { |
|
| 46 | - return $this->jsonld_service->get( Object_Type_Enum::POST, $post_id ); |
|
| 44 | + $post_id = $this->user_service->get_entity($user_id); |
|
| 45 | + if ( ! empty($post_id) && isset($this->jsonld_service)) { |
|
| 46 | + return $this->jsonld_service->get(Object_Type_Enum::POST, $post_id); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | // Bail out if the user doesn't have a valid URI. |
| 50 | - $uri = $this->user_service->get_uri( $user_id ); |
|
| 51 | - if ( empty( $uri ) ) { |
|
| 50 | + $uri = $this->user_service->get_uri($user_id); |
|
| 51 | + if (empty($uri)) { |
|
| 52 | 52 | return array(); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -59,23 +59,23 @@ discard block |
||
| 59 | 59 | '@type' => 'Person', |
| 60 | 60 | ); |
| 61 | 61 | |
| 62 | - if ( ! empty( $userdata->display_name ) ) { |
|
| 62 | + if ( ! empty($userdata->display_name)) { |
|
| 63 | 63 | $data['name'] = $userdata->display_name; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - if ( ! empty( $userdata->first_name ) ) { |
|
| 66 | + if ( ! empty($userdata->first_name)) { |
|
| 67 | 67 | $data['givenName'] = $userdata->first_name; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - if ( ! empty( $userdata->last_name ) ) { |
|
| 70 | + if ( ! empty($userdata->last_name)) { |
|
| 71 | 71 | $data['familyName'] = $userdata->last_name; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if ( ! empty( $userdata->user_url ) ) { |
|
| 74 | + if ( ! empty($userdata->user_url)) { |
|
| 75 | 75 | $data['url'] = $userdata->user_url; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - return array( $data ); |
|
| 78 | + return array($data); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | } |
@@ -15,62 +15,62 @@ |
||
| 15 | 15 | |
| 16 | 16 | class Local_Autocomplete_Service extends Abstract_Autocomplete_Service { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * @inheritDoc |
|
| 20 | - */ |
|
| 21 | - public function query( $query, $scope, $excludes ) { |
|
| 22 | - global $wpdb; |
|
| 18 | + /** |
|
| 19 | + * @inheritDoc |
|
| 20 | + */ |
|
| 21 | + public function query( $query, $scope, $excludes ) { |
|
| 22 | + global $wpdb; |
|
| 23 | 23 | |
| 24 | - $posts = $wpdb->get_results( $wpdb->prepare( |
|
| 25 | - "SELECT * FROM {$wpdb->posts} p" |
|
| 26 | - . " INNER JOIN {$wpdb->term_relationships} tr" |
|
| 27 | - . " ON tr.object_id = p.ID" |
|
| 28 | - . " INNER JOIN {$wpdb->term_taxonomy} tt" |
|
| 29 | - . " ON tt.taxonomy = %s AND tt.term_taxonomy_id = tr.term_taxonomy_id" |
|
| 30 | - . " INNER JOIN {$wpdb->terms} t" |
|
| 31 | - . " ON t.term_id = tt.term_id AND t.name != %s" |
|
| 32 | - . " LEFT OUTER JOIN {$wpdb->postmeta} pm" |
|
| 33 | - . " ON pm.meta_key = %s AND pm.post_id = p.ID" |
|
| 34 | - . " WHERE p.post_type IN ( '" . implode( "', '", array_map( 'esc_sql', Wordlift_Entity_Service::valid_entity_post_types() ) ) . "' )" |
|
| 35 | - . " AND p.post_status IN ( 'publish', 'draft', 'private', 'future' ) " |
|
| 36 | - . " AND ( p.post_title LIKE %s OR pm.meta_value LIKE %s )" |
|
| 37 | - . " LIMIT %d", |
|
| 38 | - Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
|
| 39 | - 'article', |
|
| 40 | - Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY, |
|
| 41 | - // `prepare` doesn't support argument number, hence we must repeat the query. |
|
| 42 | - '%' . $wpdb->esc_like( $query ) . '%', |
|
| 43 | - '%' . $wpdb->esc_like( $query ) . '%', |
|
| 44 | - 50 |
|
| 45 | - ) ); |
|
| 24 | + $posts = $wpdb->get_results( $wpdb->prepare( |
|
| 25 | + "SELECT * FROM {$wpdb->posts} p" |
|
| 26 | + . " INNER JOIN {$wpdb->term_relationships} tr" |
|
| 27 | + . " ON tr.object_id = p.ID" |
|
| 28 | + . " INNER JOIN {$wpdb->term_taxonomy} tt" |
|
| 29 | + . " ON tt.taxonomy = %s AND tt.term_taxonomy_id = tr.term_taxonomy_id" |
|
| 30 | + . " INNER JOIN {$wpdb->terms} t" |
|
| 31 | + . " ON t.term_id = tt.term_id AND t.name != %s" |
|
| 32 | + . " LEFT OUTER JOIN {$wpdb->postmeta} pm" |
|
| 33 | + . " ON pm.meta_key = %s AND pm.post_id = p.ID" |
|
| 34 | + . " WHERE p.post_type IN ( '" . implode( "', '", array_map( 'esc_sql', Wordlift_Entity_Service::valid_entity_post_types() ) ) . "' )" |
|
| 35 | + . " AND p.post_status IN ( 'publish', 'draft', 'private', 'future' ) " |
|
| 36 | + . " AND ( p.post_title LIKE %s OR pm.meta_value LIKE %s )" |
|
| 37 | + . " LIMIT %d", |
|
| 38 | + Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
|
| 39 | + 'article', |
|
| 40 | + Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY, |
|
| 41 | + // `prepare` doesn't support argument number, hence we must repeat the query. |
|
| 42 | + '%' . $wpdb->esc_like( $query ) . '%', |
|
| 43 | + '%' . $wpdb->esc_like( $query ) . '%', |
|
| 44 | + 50 |
|
| 45 | + ) ); |
|
| 46 | 46 | |
| 47 | - $results = array_map( function ( $item ) { |
|
| 47 | + $results = array_map( function ( $item ) { |
|
| 48 | 48 | |
| 49 | - $entity_service = Wordlift_Entity_Service::get_instance(); |
|
| 50 | - $uri = $entity_service->get_uri( $item->ID ); |
|
| 49 | + $entity_service = Wordlift_Entity_Service::get_instance(); |
|
| 50 | + $uri = $entity_service->get_uri( $item->ID ); |
|
| 51 | 51 | |
| 52 | - return array( |
|
| 53 | - // see #1074: The value property is needed for autocomplete in category page |
|
| 54 | - // to function correctly, if value is not provided, then the entity |
|
| 55 | - // wont be correctly saved. |
|
| 56 | - 'value' => $uri, |
|
| 57 | - 'id' => $uri, |
|
| 58 | - 'label' => array( $item->post_title ), |
|
| 59 | - 'labels' => $entity_service->get_alternative_labels( $item->ID ), |
|
| 60 | - 'descriptions' => array( Wordlift_Post_Excerpt_Helper::get_text_excerpt( $item ) ), |
|
| 61 | - 'scope' => 'local', |
|
| 62 | - 'sameAss' => get_post_meta( $item->ID, \Wordlift_Schema_Service::FIELD_SAME_AS ), |
|
| 63 | - // The following properties are less relevant because we're linking entities that exist already in the |
|
| 64 | - // vocabulary. That's why we don't make an effort to load the real data. |
|
| 65 | - 'types' => array( 'http://schema.org/Thing' ), |
|
| 66 | - 'urls' => array(), |
|
| 67 | - 'images' => array(), |
|
| 68 | - ); |
|
| 69 | - }, $posts ); |
|
| 52 | + return array( |
|
| 53 | + // see #1074: The value property is needed for autocomplete in category page |
|
| 54 | + // to function correctly, if value is not provided, then the entity |
|
| 55 | + // wont be correctly saved. |
|
| 56 | + 'value' => $uri, |
|
| 57 | + 'id' => $uri, |
|
| 58 | + 'label' => array( $item->post_title ), |
|
| 59 | + 'labels' => $entity_service->get_alternative_labels( $item->ID ), |
|
| 60 | + 'descriptions' => array( Wordlift_Post_Excerpt_Helper::get_text_excerpt( $item ) ), |
|
| 61 | + 'scope' => 'local', |
|
| 62 | + 'sameAss' => get_post_meta( $item->ID, \Wordlift_Schema_Service::FIELD_SAME_AS ), |
|
| 63 | + // The following properties are less relevant because we're linking entities that exist already in the |
|
| 64 | + // vocabulary. That's why we don't make an effort to load the real data. |
|
| 65 | + 'types' => array( 'http://schema.org/Thing' ), |
|
| 66 | + 'urls' => array(), |
|
| 67 | + 'images' => array(), |
|
| 68 | + ); |
|
| 69 | + }, $posts ); |
|
| 70 | 70 | |
| 71 | - $results = array_unique( $results, SORT_REGULAR ); |
|
| 71 | + $results = array_unique( $results, SORT_REGULAR ); |
|
| 72 | 72 | |
| 73 | - return $this->filter( $results, $excludes ); |
|
| 74 | - } |
|
| 73 | + return $this->filter( $results, $excludes ); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | 76 | } |
@@ -18,10 +18,10 @@ discard block |
||
| 18 | 18 | /** |
| 19 | 19 | * @inheritDoc |
| 20 | 20 | */ |
| 21 | - public function query( $query, $scope, $excludes ) { |
|
| 21 | + public function query($query, $scope, $excludes) { |
|
| 22 | 22 | global $wpdb; |
| 23 | 23 | |
| 24 | - $posts = $wpdb->get_results( $wpdb->prepare( |
|
| 24 | + $posts = $wpdb->get_results($wpdb->prepare( |
|
| 25 | 25 | "SELECT * FROM {$wpdb->posts} p" |
| 26 | 26 | . " INNER JOIN {$wpdb->term_relationships} tr" |
| 27 | 27 | . " ON tr.object_id = p.ID" |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | . " ON t.term_id = tt.term_id AND t.name != %s" |
| 32 | 32 | . " LEFT OUTER JOIN {$wpdb->postmeta} pm" |
| 33 | 33 | . " ON pm.meta_key = %s AND pm.post_id = p.ID" |
| 34 | - . " WHERE p.post_type IN ( '" . implode( "', '", array_map( 'esc_sql', Wordlift_Entity_Service::valid_entity_post_types() ) ) . "' )" |
|
| 34 | + . " WHERE p.post_type IN ( '".implode("', '", array_map('esc_sql', Wordlift_Entity_Service::valid_entity_post_types()))."' )" |
|
| 35 | 35 | . " AND p.post_status IN ( 'publish', 'draft', 'private', 'future' ) " |
| 36 | 36 | . " AND ( p.post_title LIKE %s OR pm.meta_value LIKE %s )" |
| 37 | 37 | . " LIMIT %d", |
@@ -39,15 +39,15 @@ discard block |
||
| 39 | 39 | 'article', |
| 40 | 40 | Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY, |
| 41 | 41 | // `prepare` doesn't support argument number, hence we must repeat the query. |
| 42 | - '%' . $wpdb->esc_like( $query ) . '%', |
|
| 43 | - '%' . $wpdb->esc_like( $query ) . '%', |
|
| 42 | + '%'.$wpdb->esc_like($query).'%', |
|
| 43 | + '%'.$wpdb->esc_like($query).'%', |
|
| 44 | 44 | 50 |
| 45 | - ) ); |
|
| 45 | + )); |
|
| 46 | 46 | |
| 47 | - $results = array_map( function ( $item ) { |
|
| 47 | + $results = array_map(function($item) { |
|
| 48 | 48 | |
| 49 | 49 | $entity_service = Wordlift_Entity_Service::get_instance(); |
| 50 | - $uri = $entity_service->get_uri( $item->ID ); |
|
| 50 | + $uri = $entity_service->get_uri($item->ID); |
|
| 51 | 51 | |
| 52 | 52 | return array( |
| 53 | 53 | // see #1074: The value property is needed for autocomplete in category page |
@@ -55,22 +55,22 @@ discard block |
||
| 55 | 55 | // wont be correctly saved. |
| 56 | 56 | 'value' => $uri, |
| 57 | 57 | 'id' => $uri, |
| 58 | - 'label' => array( $item->post_title ), |
|
| 59 | - 'labels' => $entity_service->get_alternative_labels( $item->ID ), |
|
| 60 | - 'descriptions' => array( Wordlift_Post_Excerpt_Helper::get_text_excerpt( $item ) ), |
|
| 58 | + 'label' => array($item->post_title), |
|
| 59 | + 'labels' => $entity_service->get_alternative_labels($item->ID), |
|
| 60 | + 'descriptions' => array(Wordlift_Post_Excerpt_Helper::get_text_excerpt($item)), |
|
| 61 | 61 | 'scope' => 'local', |
| 62 | - 'sameAss' => get_post_meta( $item->ID, \Wordlift_Schema_Service::FIELD_SAME_AS ), |
|
| 62 | + 'sameAss' => get_post_meta($item->ID, \Wordlift_Schema_Service::FIELD_SAME_AS), |
|
| 63 | 63 | // The following properties are less relevant because we're linking entities that exist already in the |
| 64 | 64 | // vocabulary. That's why we don't make an effort to load the real data. |
| 65 | - 'types' => array( 'http://schema.org/Thing' ), |
|
| 65 | + 'types' => array('http://schema.org/Thing'), |
|
| 66 | 66 | 'urls' => array(), |
| 67 | 67 | 'images' => array(), |
| 68 | 68 | ); |
| 69 | - }, $posts ); |
|
| 69 | + }, $posts); |
|
| 70 | 70 | |
| 71 | - $results = array_unique( $results, SORT_REGULAR ); |
|
| 71 | + $results = array_unique($results, SORT_REGULAR); |
|
| 72 | 72 | |
| 73 | - return $this->filter( $results, $excludes ); |
|
| 73 | + return $this->filter($results, $excludes); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | } |
@@ -18,326 +18,326 @@ |
||
| 18 | 18 | |
| 19 | 19 | class Post_Adapter { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * A {@link Wordlift_Log_Service} logging instance. |
|
| 23 | - * |
|
| 24 | - * @access private |
|
| 25 | - * @var \Wordlift_Log_Service A {@link Wordlift_Log_Service} logging instance. |
|
| 26 | - */ |
|
| 27 | - private $log; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * A {@link Wordlift_Entity_Service} instance. |
|
| 31 | - * |
|
| 32 | - * @access private |
|
| 33 | - * @var \Wordlift_Entity_Service A {@link Wordlift_Entity_Service} instance. |
|
| 34 | - */ |
|
| 35 | - private $entity_service; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * A {@link Entity_Store} instance. |
|
| 39 | - * |
|
| 40 | - * @access private |
|
| 41 | - * @var Entity_Store $entity_store A {@link Entity_Store} instance. |
|
| 42 | - */ |
|
| 43 | - private $entity_store; |
|
| 44 | - |
|
| 45 | - public function __construct() { |
|
| 46 | - |
|
| 47 | - // Bail out if block editor's functions aren't available. |
|
| 48 | - if ( ! function_exists( 'register_block_type' ) || ! function_exists( 'parse_blocks' ) ) { |
|
| 49 | - return; |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - $this->log = \Wordlift_Log_Service::get_logger( get_class() ); |
|
| 53 | - |
|
| 54 | - $this->entity_service = \Wordlift_Entity_Service::get_instance(); |
|
| 55 | - $this->entity_store = Entity_Store::get_instance(); |
|
| 56 | - |
|
| 57 | - add_action( 'init', array( $this, 'init' ) ); |
|
| 58 | - add_filter( 'wp_insert_post_data', array( $this, 'wp_insert_post_data' ), 10, 2 ); |
|
| 59 | - |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * Initialize by registering our block type `wordlift/classification`, required for {@link parse_blocks) to work |
|
| 64 | - * correctly. |
|
| 65 | - */ |
|
| 66 | - public function init() { |
|
| 67 | - |
|
| 68 | - register_block_type( 'wordlift/classification', array( |
|
| 69 | - 'editor_script' => 'wl-block-editor', |
|
| 70 | - 'attributes' => array( |
|
| 71 | - 'entities' => array( 'type' => 'array' ), |
|
| 72 | - ), |
|
| 73 | - ) ); |
|
| 74 | - |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * A sample structure: |
|
| 79 | - * |
|
| 80 | - * { |
|
| 81 | - * "entities": [ |
|
| 82 | - * { |
|
| 83 | - * "annotations": { |
|
| 84 | - * "urn:enhancement-7e8e66fc": { |
|
| 85 | - * "start": 3480, |
|
| 86 | - * "end": 3486, |
|
| 87 | - * "text": "libero" |
|
| 88 | - * } |
|
| 89 | - * }, |
|
| 90 | - * "description": "Le libero ou libéro est un poste défensif du volley-ball. Des règles particulières le concernant ont été introduites à la fin des années 1990. De par sa spécificité, le libéro a un statut à part au sein d’une équipe de volley-ball. Pour être identifié, il doit porter un uniforme qui contraste avec ceux des autres membres de son équipe, titulaires ou remplaçants.", |
|
| 91 | - * "id": "http://fr.dbpedia.org/resource/Libero_(volley-ball)", |
|
| 92 | - * "label": "Libero (volley-ball)", |
|
| 93 | - * "mainType": "other", |
|
| 94 | - * "occurrences": ["urn:enhancement-7e8e66fc"], |
|
| 95 | - * "sameAs": null, |
|
| 96 | - * "synonyms": [], |
|
| 97 | - * "types": ["other"] |
|
| 98 | - * } |
|
| 99 | - * ] |
|
| 100 | - * } |
|
| 101 | - * |
|
| 102 | - * @param array $data An array of slashed post data. |
|
| 103 | - * @param array $postarr An array of sanitized, but otherwise unmodified post data. |
|
| 104 | - * |
|
| 105 | - * @return array The data array. |
|
| 106 | - * @throws \Exception |
|
| 107 | - */ |
|
| 108 | - public function wp_insert_post_data( $data, $postarr ) { |
|
| 109 | - |
|
| 110 | - // |
|
| 111 | - $post_status = $data['post_status']; |
|
| 112 | - if ( 'auto-draft' === $post_status || 'inherit' === $post_status ) { |
|
| 113 | - return $data; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - $this->log->trace( "The following data has been received by `wp_insert_post_data`:\n" |
|
| 117 | - . var_export( $data, true ) ); |
|
| 118 | - |
|
| 119 | - try { |
|
| 120 | - $entities = $this->parse_content( wp_unslash( $data['post_content'] ) ); |
|
| 121 | - |
|
| 122 | - foreach ( $entities as $entity ) { |
|
| 123 | - $this->create_or_update_entity( $entity, $data['post_status'] ); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - } catch ( \Exception $e ) { |
|
| 127 | - $this->log->error( $e->getMessage() ); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - return $data; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * Parse the post content to find the `wordlift/classification` block and return the entities' data. |
|
| 135 | - * |
|
| 136 | - * @param string $post_content The post content. |
|
| 137 | - * |
|
| 138 | - * @return array An array of entities' structures. |
|
| 139 | - * @throws \Exception |
|
| 140 | - */ |
|
| 141 | - private function parse_content( $post_content ) { |
|
| 142 | - |
|
| 143 | - $all_blocks = parse_blocks( $post_content ); |
|
| 144 | - $this->log->trace( "The following blocks have been parsed while in `wp_insert_post`:\n" |
|
| 145 | - . var_export( $all_blocks, true ) ); |
|
| 146 | - |
|
| 147 | - $blocks = array_filter( $all_blocks, function ( $item ) { |
|
| 148 | - return ! empty( $item['blockName'] ) && 'wordlift/classification' === $item['blockName']; |
|
| 149 | - } ); |
|
| 150 | - |
|
| 151 | - // Bail out if the blocks' array is empty. |
|
| 152 | - if ( empty( $blocks ) ) { |
|
| 153 | - return array(); |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - $block = current( $blocks ); |
|
| 157 | - $this->log->trace( "The following block has been found while in `wp_insert_post`:\n" |
|
| 158 | - . var_export( $block, true ) ); |
|
| 159 | - |
|
| 160 | - // Bail out if the entities array is empty. |
|
| 161 | - if ( empty( $block['attrs'] ) && empty( $block['attrs']['entities'] ) ) { |
|
| 162 | - return array(); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - return $block['attrs']['entities']; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * Collect entity labels from the entity array. |
|
| 170 | - * |
|
| 171 | - * This function expects an array with the following keys: |
|
| 172 | - * |
|
| 173 | - * array( |
|
| 174 | - * 'label' => ..., |
|
| 175 | - * 'synonyms' => array( ... ), |
|
| 176 | - * 'annotations' => array( |
|
| 177 | - * ...id... => array( text => ... ), |
|
| 178 | - * ), |
|
| 179 | - * 'occurrences' => array( ... ), |
|
| 180 | - * ) |
|
| 181 | - * |
|
| 182 | - * and it is going to output an array with all the labels, keeping the `label` at first position: |
|
| 183 | - * |
|
| 184 | - * array( |
|
| 185 | - * ...label..., |
|
| 186 | - * ...synonyms..., |
|
| 187 | - * ...texts..., |
|
| 188 | - * ) |
|
| 189 | - * |
|
| 190 | - * This function is going to collect the label from the `label` property, from the `synonyms` property and from |
|
| 191 | - * `annotations` property. Since the `annotations` property contains all the annotations including those that |
|
| 192 | - * haven't been selected, this function is going to only get the `text` for the annotations property listed in |
|
| 193 | - * `occurrences`. |
|
| 194 | - * |
|
| 195 | - * @param array $entity { |
|
| 196 | - * The entity data. |
|
| 197 | - * |
|
| 198 | - * @type string $label The entity label. |
|
| 199 | - * @type array $synonyms The entity synonyms. |
|
| 200 | - * @type array $occurrences The selected occurrences. |
|
| 201 | - * @type array $annotations The annotations. |
|
| 202 | - * } |
|
| 203 | - * |
|
| 204 | - * @return array An array of labels. |
|
| 205 | - */ |
|
| 206 | - public function get_labels( $entity ) { |
|
| 207 | - |
|
| 208 | - $args = wp_parse_args( $entity, array( |
|
| 209 | - 'label' => array(), |
|
| 210 | - 'synonyms' => array(), |
|
| 211 | - 'annotations' => array(), |
|
| 212 | - 'occurrences' => array(), |
|
| 213 | - ) ); |
|
| 214 | - |
|
| 215 | - // We gather all the labels, occurrences texts and synonyms into one array. |
|
| 216 | - $initial = array_merge( |
|
| 217 | - (array) $args['label'], |
|
| 218 | - (array) $args['synonyms'] |
|
| 219 | - ); |
|
| 220 | - |
|
| 221 | - $annotations = $args['annotations']; |
|
| 222 | - |
|
| 223 | - return array_reduce( $args['occurrences'], function ( $carry, $item ) use ( $annotations ) { |
|
| 224 | - |
|
| 225 | - // Bail out if occurrences->$item->text isn't set or its contents are already |
|
| 226 | - // in `$carry`. |
|
| 227 | - if ( ! isset( $annotations[ $item ]['text'] ) |
|
| 228 | - || in_array( $annotations[ $item ]['text'], $carry ) ) { |
|
| 229 | - return $carry; |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - // Push the label. |
|
| 233 | - $carry[] = $annotations[ $item ]['text']; |
|
| 234 | - |
|
| 235 | - return $carry; |
|
| 236 | - }, $initial ); |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - /** |
|
| 240 | - * Create or update the entity. |
|
| 241 | - * |
|
| 242 | - * An entity lookup is performed on the local vocabulary using the `id` and `sameAs` URIs. If an entity is found |
|
| 243 | - * the {@link Entity_Store} update function is called to update the `labels` and the `sameAs` values. |
|
| 244 | - * |
|
| 245 | - * If an entity is not found the {@link Entity_Store} create function is called to create a new entity. |
|
| 246 | - * |
|
| 247 | - * @param array $entity { |
|
| 248 | - * The entity parameters. |
|
| 249 | - * |
|
| 250 | - * @type string The entity item id URI. |
|
| 251 | - * @type string|array The entity sameAs URI(s). |
|
| 252 | - * @type string $description The entity description. |
|
| 253 | - * } |
|
| 254 | - * |
|
| 255 | - * @param $string $post_status The post status, default 'draft'. |
|
| 256 | - * |
|
| 257 | - * @return int|\WP_Error |
|
| 258 | - * @throws \Exception |
|
| 259 | - */ |
|
| 260 | - private function create_or_update_entity( $entity, $post_status = 'draft' ) { |
|
| 261 | - |
|
| 262 | - // Get only valid IDs. |
|
| 263 | - $ids = array_filter( (array) $entity['id'], function ( $id ) { |
|
| 264 | - return preg_match( '|^https?://|', $id ); |
|
| 265 | - } ); |
|
| 266 | - |
|
| 267 | - $uris = array_merge( |
|
| 268 | - (array) $ids, |
|
| 269 | - (array) $entity['sameAs'] |
|
| 270 | - ); |
|
| 271 | - |
|
| 272 | - $post = $this->get_first_matching_entity_by_uri( $uris ); |
|
| 273 | - |
|
| 274 | - $this->log->trace( 'Entity' . ( empty( $post ) ? ' not' : '' ) . " found with the following URIs:\n" |
|
| 275 | - . var_export( $uris, true ) ); |
|
| 276 | - |
|
| 277 | - // Get the labels. |
|
| 278 | - $labels = $this->get_labels( $entity ); |
|
| 279 | - |
|
| 280 | - if ( empty( $post ) ) { |
|
| 281 | - // Create the entity if it doesn't exist. |
|
| 282 | - $post_id = $this->entity_store->create( array( |
|
| 283 | - 'labels' => $labels, |
|
| 284 | - 'description' => $entity['description'], |
|
| 285 | - 'same_as' => $uris, |
|
| 286 | - ), $post_status ); |
|
| 287 | - |
|
| 288 | - // Return the WP_Error if we got one. |
|
| 289 | - if ( is_wp_error( $post_id ) ) { |
|
| 290 | - return $post_id; |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - // Add the entity type. |
|
| 294 | - if ( isset( $entity['mainType'] ) ) { |
|
| 295 | - wp_set_object_terms( $post_id, $entity['mainType'], \Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - if ( isset( $entity['properties'] ) && isset( $entity['properties']['latitude'] ) && isset( $entity['properties']['longitude'] ) ) { |
|
| 299 | - add_post_meta( $post_id, \Wordlift_Schema_Service::FIELD_GEO_LATITUDE, $entity['properties']['latitude'] ); |
|
| 300 | - add_post_meta( $post_id, \Wordlift_Schema_Service::FIELD_GEO_LONGITUDE, $entity['properties']['longitude'] ); |
|
| 301 | - } |
|
| 302 | - } else { |
|
| 303 | - // Update the entity otherwise. |
|
| 304 | - $post_id = $this->entity_store->update( array( |
|
| 305 | - 'ID' => $post->ID, |
|
| 306 | - 'labels' => $labels, |
|
| 307 | - 'same_as' => $uris, |
|
| 308 | - ) ); |
|
| 309 | - |
|
| 310 | - // Add the entity type. |
|
| 311 | - if ( isset( $entity['mainType'] ) ) { |
|
| 312 | - wp_add_object_terms( $post_id, $entity['mainType'], \Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 313 | - } |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - return $post_id; |
|
| 317 | - } |
|
| 318 | - |
|
| 319 | - /** |
|
| 320 | - * Get the first matching entity for the provided URI array. |
|
| 321 | - * |
|
| 322 | - * Entities IDs and sameAs are searched. |
|
| 323 | - * |
|
| 324 | - * @param array $uris An array of URIs. |
|
| 325 | - * |
|
| 326 | - * @return \WP_Post|null The entity WP_Post if found or null if not found. |
|
| 327 | - */ |
|
| 328 | - private function get_first_matching_entity_by_uri( $uris ) { |
|
| 329 | - |
|
| 330 | - foreach ( $uris as $uri ) { |
|
| 331 | - $existing_entity = $this->entity_service->get_entity_post_by_uri( $uri ); |
|
| 332 | - if ( isset( $existing_entity ) ) { |
|
| 333 | - return $existing_entity; |
|
| 334 | - } |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - return null; |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - // /** |
|
| 21 | + /** |
|
| 22 | + * A {@link Wordlift_Log_Service} logging instance. |
|
| 23 | + * |
|
| 24 | + * @access private |
|
| 25 | + * @var \Wordlift_Log_Service A {@link Wordlift_Log_Service} logging instance. |
|
| 26 | + */ |
|
| 27 | + private $log; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * A {@link Wordlift_Entity_Service} instance. |
|
| 31 | + * |
|
| 32 | + * @access private |
|
| 33 | + * @var \Wordlift_Entity_Service A {@link Wordlift_Entity_Service} instance. |
|
| 34 | + */ |
|
| 35 | + private $entity_service; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * A {@link Entity_Store} instance. |
|
| 39 | + * |
|
| 40 | + * @access private |
|
| 41 | + * @var Entity_Store $entity_store A {@link Entity_Store} instance. |
|
| 42 | + */ |
|
| 43 | + private $entity_store; |
|
| 44 | + |
|
| 45 | + public function __construct() { |
|
| 46 | + |
|
| 47 | + // Bail out if block editor's functions aren't available. |
|
| 48 | + if ( ! function_exists( 'register_block_type' ) || ! function_exists( 'parse_blocks' ) ) { |
|
| 49 | + return; |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + $this->log = \Wordlift_Log_Service::get_logger( get_class() ); |
|
| 53 | + |
|
| 54 | + $this->entity_service = \Wordlift_Entity_Service::get_instance(); |
|
| 55 | + $this->entity_store = Entity_Store::get_instance(); |
|
| 56 | + |
|
| 57 | + add_action( 'init', array( $this, 'init' ) ); |
|
| 58 | + add_filter( 'wp_insert_post_data', array( $this, 'wp_insert_post_data' ), 10, 2 ); |
|
| 59 | + |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * Initialize by registering our block type `wordlift/classification`, required for {@link parse_blocks) to work |
|
| 64 | + * correctly. |
|
| 65 | + */ |
|
| 66 | + public function init() { |
|
| 67 | + |
|
| 68 | + register_block_type( 'wordlift/classification', array( |
|
| 69 | + 'editor_script' => 'wl-block-editor', |
|
| 70 | + 'attributes' => array( |
|
| 71 | + 'entities' => array( 'type' => 'array' ), |
|
| 72 | + ), |
|
| 73 | + ) ); |
|
| 74 | + |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * A sample structure: |
|
| 79 | + * |
|
| 80 | + * { |
|
| 81 | + * "entities": [ |
|
| 82 | + * { |
|
| 83 | + * "annotations": { |
|
| 84 | + * "urn:enhancement-7e8e66fc": { |
|
| 85 | + * "start": 3480, |
|
| 86 | + * "end": 3486, |
|
| 87 | + * "text": "libero" |
|
| 88 | + * } |
|
| 89 | + * }, |
|
| 90 | + * "description": "Le libero ou libéro est un poste défensif du volley-ball. Des règles particulières le concernant ont été introduites à la fin des années 1990. De par sa spécificité, le libéro a un statut à part au sein d’une équipe de volley-ball. Pour être identifié, il doit porter un uniforme qui contraste avec ceux des autres membres de son équipe, titulaires ou remplaçants.", |
|
| 91 | + * "id": "http://fr.dbpedia.org/resource/Libero_(volley-ball)", |
|
| 92 | + * "label": "Libero (volley-ball)", |
|
| 93 | + * "mainType": "other", |
|
| 94 | + * "occurrences": ["urn:enhancement-7e8e66fc"], |
|
| 95 | + * "sameAs": null, |
|
| 96 | + * "synonyms": [], |
|
| 97 | + * "types": ["other"] |
|
| 98 | + * } |
|
| 99 | + * ] |
|
| 100 | + * } |
|
| 101 | + * |
|
| 102 | + * @param array $data An array of slashed post data. |
|
| 103 | + * @param array $postarr An array of sanitized, but otherwise unmodified post data. |
|
| 104 | + * |
|
| 105 | + * @return array The data array. |
|
| 106 | + * @throws \Exception |
|
| 107 | + */ |
|
| 108 | + public function wp_insert_post_data( $data, $postarr ) { |
|
| 109 | + |
|
| 110 | + // |
|
| 111 | + $post_status = $data['post_status']; |
|
| 112 | + if ( 'auto-draft' === $post_status || 'inherit' === $post_status ) { |
|
| 113 | + return $data; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + $this->log->trace( "The following data has been received by `wp_insert_post_data`:\n" |
|
| 117 | + . var_export( $data, true ) ); |
|
| 118 | + |
|
| 119 | + try { |
|
| 120 | + $entities = $this->parse_content( wp_unslash( $data['post_content'] ) ); |
|
| 121 | + |
|
| 122 | + foreach ( $entities as $entity ) { |
|
| 123 | + $this->create_or_update_entity( $entity, $data['post_status'] ); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + } catch ( \Exception $e ) { |
|
| 127 | + $this->log->error( $e->getMessage() ); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + return $data; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * Parse the post content to find the `wordlift/classification` block and return the entities' data. |
|
| 135 | + * |
|
| 136 | + * @param string $post_content The post content. |
|
| 137 | + * |
|
| 138 | + * @return array An array of entities' structures. |
|
| 139 | + * @throws \Exception |
|
| 140 | + */ |
|
| 141 | + private function parse_content( $post_content ) { |
|
| 142 | + |
|
| 143 | + $all_blocks = parse_blocks( $post_content ); |
|
| 144 | + $this->log->trace( "The following blocks have been parsed while in `wp_insert_post`:\n" |
|
| 145 | + . var_export( $all_blocks, true ) ); |
|
| 146 | + |
|
| 147 | + $blocks = array_filter( $all_blocks, function ( $item ) { |
|
| 148 | + return ! empty( $item['blockName'] ) && 'wordlift/classification' === $item['blockName']; |
|
| 149 | + } ); |
|
| 150 | + |
|
| 151 | + // Bail out if the blocks' array is empty. |
|
| 152 | + if ( empty( $blocks ) ) { |
|
| 153 | + return array(); |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + $block = current( $blocks ); |
|
| 157 | + $this->log->trace( "The following block has been found while in `wp_insert_post`:\n" |
|
| 158 | + . var_export( $block, true ) ); |
|
| 159 | + |
|
| 160 | + // Bail out if the entities array is empty. |
|
| 161 | + if ( empty( $block['attrs'] ) && empty( $block['attrs']['entities'] ) ) { |
|
| 162 | + return array(); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + return $block['attrs']['entities']; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * Collect entity labels from the entity array. |
|
| 170 | + * |
|
| 171 | + * This function expects an array with the following keys: |
|
| 172 | + * |
|
| 173 | + * array( |
|
| 174 | + * 'label' => ..., |
|
| 175 | + * 'synonyms' => array( ... ), |
|
| 176 | + * 'annotations' => array( |
|
| 177 | + * ...id... => array( text => ... ), |
|
| 178 | + * ), |
|
| 179 | + * 'occurrences' => array( ... ), |
|
| 180 | + * ) |
|
| 181 | + * |
|
| 182 | + * and it is going to output an array with all the labels, keeping the `label` at first position: |
|
| 183 | + * |
|
| 184 | + * array( |
|
| 185 | + * ...label..., |
|
| 186 | + * ...synonyms..., |
|
| 187 | + * ...texts..., |
|
| 188 | + * ) |
|
| 189 | + * |
|
| 190 | + * This function is going to collect the label from the `label` property, from the `synonyms` property and from |
|
| 191 | + * `annotations` property. Since the `annotations` property contains all the annotations including those that |
|
| 192 | + * haven't been selected, this function is going to only get the `text` for the annotations property listed in |
|
| 193 | + * `occurrences`. |
|
| 194 | + * |
|
| 195 | + * @param array $entity { |
|
| 196 | + * The entity data. |
|
| 197 | + * |
|
| 198 | + * @type string $label The entity label. |
|
| 199 | + * @type array $synonyms The entity synonyms. |
|
| 200 | + * @type array $occurrences The selected occurrences. |
|
| 201 | + * @type array $annotations The annotations. |
|
| 202 | + * } |
|
| 203 | + * |
|
| 204 | + * @return array An array of labels. |
|
| 205 | + */ |
|
| 206 | + public function get_labels( $entity ) { |
|
| 207 | + |
|
| 208 | + $args = wp_parse_args( $entity, array( |
|
| 209 | + 'label' => array(), |
|
| 210 | + 'synonyms' => array(), |
|
| 211 | + 'annotations' => array(), |
|
| 212 | + 'occurrences' => array(), |
|
| 213 | + ) ); |
|
| 214 | + |
|
| 215 | + // We gather all the labels, occurrences texts and synonyms into one array. |
|
| 216 | + $initial = array_merge( |
|
| 217 | + (array) $args['label'], |
|
| 218 | + (array) $args['synonyms'] |
|
| 219 | + ); |
|
| 220 | + |
|
| 221 | + $annotations = $args['annotations']; |
|
| 222 | + |
|
| 223 | + return array_reduce( $args['occurrences'], function ( $carry, $item ) use ( $annotations ) { |
|
| 224 | + |
|
| 225 | + // Bail out if occurrences->$item->text isn't set or its contents are already |
|
| 226 | + // in `$carry`. |
|
| 227 | + if ( ! isset( $annotations[ $item ]['text'] ) |
|
| 228 | + || in_array( $annotations[ $item ]['text'], $carry ) ) { |
|
| 229 | + return $carry; |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + // Push the label. |
|
| 233 | + $carry[] = $annotations[ $item ]['text']; |
|
| 234 | + |
|
| 235 | + return $carry; |
|
| 236 | + }, $initial ); |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + /** |
|
| 240 | + * Create or update the entity. |
|
| 241 | + * |
|
| 242 | + * An entity lookup is performed on the local vocabulary using the `id` and `sameAs` URIs. If an entity is found |
|
| 243 | + * the {@link Entity_Store} update function is called to update the `labels` and the `sameAs` values. |
|
| 244 | + * |
|
| 245 | + * If an entity is not found the {@link Entity_Store} create function is called to create a new entity. |
|
| 246 | + * |
|
| 247 | + * @param array $entity { |
|
| 248 | + * The entity parameters. |
|
| 249 | + * |
|
| 250 | + * @type string The entity item id URI. |
|
| 251 | + * @type string|array The entity sameAs URI(s). |
|
| 252 | + * @type string $description The entity description. |
|
| 253 | + * } |
|
| 254 | + * |
|
| 255 | + * @param $string $post_status The post status, default 'draft'. |
|
| 256 | + * |
|
| 257 | + * @return int|\WP_Error |
|
| 258 | + * @throws \Exception |
|
| 259 | + */ |
|
| 260 | + private function create_or_update_entity( $entity, $post_status = 'draft' ) { |
|
| 261 | + |
|
| 262 | + // Get only valid IDs. |
|
| 263 | + $ids = array_filter( (array) $entity['id'], function ( $id ) { |
|
| 264 | + return preg_match( '|^https?://|', $id ); |
|
| 265 | + } ); |
|
| 266 | + |
|
| 267 | + $uris = array_merge( |
|
| 268 | + (array) $ids, |
|
| 269 | + (array) $entity['sameAs'] |
|
| 270 | + ); |
|
| 271 | + |
|
| 272 | + $post = $this->get_first_matching_entity_by_uri( $uris ); |
|
| 273 | + |
|
| 274 | + $this->log->trace( 'Entity' . ( empty( $post ) ? ' not' : '' ) . " found with the following URIs:\n" |
|
| 275 | + . var_export( $uris, true ) ); |
|
| 276 | + |
|
| 277 | + // Get the labels. |
|
| 278 | + $labels = $this->get_labels( $entity ); |
|
| 279 | + |
|
| 280 | + if ( empty( $post ) ) { |
|
| 281 | + // Create the entity if it doesn't exist. |
|
| 282 | + $post_id = $this->entity_store->create( array( |
|
| 283 | + 'labels' => $labels, |
|
| 284 | + 'description' => $entity['description'], |
|
| 285 | + 'same_as' => $uris, |
|
| 286 | + ), $post_status ); |
|
| 287 | + |
|
| 288 | + // Return the WP_Error if we got one. |
|
| 289 | + if ( is_wp_error( $post_id ) ) { |
|
| 290 | + return $post_id; |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + // Add the entity type. |
|
| 294 | + if ( isset( $entity['mainType'] ) ) { |
|
| 295 | + wp_set_object_terms( $post_id, $entity['mainType'], \Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + if ( isset( $entity['properties'] ) && isset( $entity['properties']['latitude'] ) && isset( $entity['properties']['longitude'] ) ) { |
|
| 299 | + add_post_meta( $post_id, \Wordlift_Schema_Service::FIELD_GEO_LATITUDE, $entity['properties']['latitude'] ); |
|
| 300 | + add_post_meta( $post_id, \Wordlift_Schema_Service::FIELD_GEO_LONGITUDE, $entity['properties']['longitude'] ); |
|
| 301 | + } |
|
| 302 | + } else { |
|
| 303 | + // Update the entity otherwise. |
|
| 304 | + $post_id = $this->entity_store->update( array( |
|
| 305 | + 'ID' => $post->ID, |
|
| 306 | + 'labels' => $labels, |
|
| 307 | + 'same_as' => $uris, |
|
| 308 | + ) ); |
|
| 309 | + |
|
| 310 | + // Add the entity type. |
|
| 311 | + if ( isset( $entity['mainType'] ) ) { |
|
| 312 | + wp_add_object_terms( $post_id, $entity['mainType'], \Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 313 | + } |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + return $post_id; |
|
| 317 | + } |
|
| 318 | + |
|
| 319 | + /** |
|
| 320 | + * Get the first matching entity for the provided URI array. |
|
| 321 | + * |
|
| 322 | + * Entities IDs and sameAs are searched. |
|
| 323 | + * |
|
| 324 | + * @param array $uris An array of URIs. |
|
| 325 | + * |
|
| 326 | + * @return \WP_Post|null The entity WP_Post if found or null if not found. |
|
| 327 | + */ |
|
| 328 | + private function get_first_matching_entity_by_uri( $uris ) { |
|
| 329 | + |
|
| 330 | + foreach ( $uris as $uri ) { |
|
| 331 | + $existing_entity = $this->entity_service->get_entity_post_by_uri( $uri ); |
|
| 332 | + if ( isset( $existing_entity ) ) { |
|
| 333 | + return $existing_entity; |
|
| 334 | + } |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + return null; |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + // /** |
|
| 341 | 341 | // * @param int $post_ID Post ID. |
| 342 | 342 | // * @param \WP_Post $post Post object. |
| 343 | 343 | // * @param bool $update Whether this is an existing post being updated or not. |
@@ -45,17 +45,17 @@ discard block |
||
| 45 | 45 | public function __construct() { |
| 46 | 46 | |
| 47 | 47 | // Bail out if block editor's functions aren't available. |
| 48 | - if ( ! function_exists( 'register_block_type' ) || ! function_exists( 'parse_blocks' ) ) { |
|
| 48 | + if ( ! function_exists('register_block_type') || ! function_exists('parse_blocks')) { |
|
| 49 | 49 | return; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - $this->log = \Wordlift_Log_Service::get_logger( get_class() ); |
|
| 52 | + $this->log = \Wordlift_Log_Service::get_logger(get_class()); |
|
| 53 | 53 | |
| 54 | 54 | $this->entity_service = \Wordlift_Entity_Service::get_instance(); |
| 55 | 55 | $this->entity_store = Entity_Store::get_instance(); |
| 56 | 56 | |
| 57 | - add_action( 'init', array( $this, 'init' ) ); |
|
| 58 | - add_filter( 'wp_insert_post_data', array( $this, 'wp_insert_post_data' ), 10, 2 ); |
|
| 57 | + add_action('init', array($this, 'init')); |
|
| 58 | + add_filter('wp_insert_post_data', array($this, 'wp_insert_post_data'), 10, 2); |
|
| 59 | 59 | |
| 60 | 60 | } |
| 61 | 61 | |
@@ -65,12 +65,12 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | public function init() { |
| 67 | 67 | |
| 68 | - register_block_type( 'wordlift/classification', array( |
|
| 68 | + register_block_type('wordlift/classification', array( |
|
| 69 | 69 | 'editor_script' => 'wl-block-editor', |
| 70 | 70 | 'attributes' => array( |
| 71 | - 'entities' => array( 'type' => 'array' ), |
|
| 71 | + 'entities' => array('type' => 'array'), |
|
| 72 | 72 | ), |
| 73 | - ) ); |
|
| 73 | + )); |
|
| 74 | 74 | |
| 75 | 75 | } |
| 76 | 76 | |
@@ -105,26 +105,26 @@ discard block |
||
| 105 | 105 | * @return array The data array. |
| 106 | 106 | * @throws \Exception |
| 107 | 107 | */ |
| 108 | - public function wp_insert_post_data( $data, $postarr ) { |
|
| 108 | + public function wp_insert_post_data($data, $postarr) { |
|
| 109 | 109 | |
| 110 | 110 | // |
| 111 | 111 | $post_status = $data['post_status']; |
| 112 | - if ( 'auto-draft' === $post_status || 'inherit' === $post_status ) { |
|
| 112 | + if ('auto-draft' === $post_status || 'inherit' === $post_status) { |
|
| 113 | 113 | return $data; |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - $this->log->trace( "The following data has been received by `wp_insert_post_data`:\n" |
|
| 117 | - . var_export( $data, true ) ); |
|
| 116 | + $this->log->trace("The following data has been received by `wp_insert_post_data`:\n" |
|
| 117 | + . var_export($data, true)); |
|
| 118 | 118 | |
| 119 | 119 | try { |
| 120 | - $entities = $this->parse_content( wp_unslash( $data['post_content'] ) ); |
|
| 120 | + $entities = $this->parse_content(wp_unslash($data['post_content'])); |
|
| 121 | 121 | |
| 122 | - foreach ( $entities as $entity ) { |
|
| 123 | - $this->create_or_update_entity( $entity, $data['post_status'] ); |
|
| 122 | + foreach ($entities as $entity) { |
|
| 123 | + $this->create_or_update_entity($entity, $data['post_status']); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - } catch ( \Exception $e ) { |
|
| 127 | - $this->log->error( $e->getMessage() ); |
|
| 126 | + } catch (\Exception $e) { |
|
| 127 | + $this->log->error($e->getMessage()); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | return $data; |
@@ -138,27 +138,27 @@ discard block |
||
| 138 | 138 | * @return array An array of entities' structures. |
| 139 | 139 | * @throws \Exception |
| 140 | 140 | */ |
| 141 | - private function parse_content( $post_content ) { |
|
| 141 | + private function parse_content($post_content) { |
|
| 142 | 142 | |
| 143 | - $all_blocks = parse_blocks( $post_content ); |
|
| 144 | - $this->log->trace( "The following blocks have been parsed while in `wp_insert_post`:\n" |
|
| 145 | - . var_export( $all_blocks, true ) ); |
|
| 143 | + $all_blocks = parse_blocks($post_content); |
|
| 144 | + $this->log->trace("The following blocks have been parsed while in `wp_insert_post`:\n" |
|
| 145 | + . var_export($all_blocks, true)); |
|
| 146 | 146 | |
| 147 | - $blocks = array_filter( $all_blocks, function ( $item ) { |
|
| 148 | - return ! empty( $item['blockName'] ) && 'wordlift/classification' === $item['blockName']; |
|
| 147 | + $blocks = array_filter($all_blocks, function($item) { |
|
| 148 | + return ! empty($item['blockName']) && 'wordlift/classification' === $item['blockName']; |
|
| 149 | 149 | } ); |
| 150 | 150 | |
| 151 | 151 | // Bail out if the blocks' array is empty. |
| 152 | - if ( empty( $blocks ) ) { |
|
| 152 | + if (empty($blocks)) { |
|
| 153 | 153 | return array(); |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - $block = current( $blocks ); |
|
| 157 | - $this->log->trace( "The following block has been found while in `wp_insert_post`:\n" |
|
| 158 | - . var_export( $block, true ) ); |
|
| 156 | + $block = current($blocks); |
|
| 157 | + $this->log->trace("The following block has been found while in `wp_insert_post`:\n" |
|
| 158 | + . var_export($block, true)); |
|
| 159 | 159 | |
| 160 | 160 | // Bail out if the entities array is empty. |
| 161 | - if ( empty( $block['attrs'] ) && empty( $block['attrs']['entities'] ) ) { |
|
| 161 | + if (empty($block['attrs']) && empty($block['attrs']['entities'])) { |
|
| 162 | 162 | return array(); |
| 163 | 163 | } |
| 164 | 164 | |
@@ -203,14 +203,14 @@ discard block |
||
| 203 | 203 | * |
| 204 | 204 | * @return array An array of labels. |
| 205 | 205 | */ |
| 206 | - public function get_labels( $entity ) { |
|
| 206 | + public function get_labels($entity) { |
|
| 207 | 207 | |
| 208 | - $args = wp_parse_args( $entity, array( |
|
| 208 | + $args = wp_parse_args($entity, array( |
|
| 209 | 209 | 'label' => array(), |
| 210 | 210 | 'synonyms' => array(), |
| 211 | 211 | 'annotations' => array(), |
| 212 | 212 | 'occurrences' => array(), |
| 213 | - ) ); |
|
| 213 | + )); |
|
| 214 | 214 | |
| 215 | 215 | // We gather all the labels, occurrences texts and synonyms into one array. |
| 216 | 216 | $initial = array_merge( |
@@ -220,20 +220,20 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | $annotations = $args['annotations']; |
| 222 | 222 | |
| 223 | - return array_reduce( $args['occurrences'], function ( $carry, $item ) use ( $annotations ) { |
|
| 223 | + return array_reduce($args['occurrences'], function($carry, $item) use ($annotations) { |
|
| 224 | 224 | |
| 225 | 225 | // Bail out if occurrences->$item->text isn't set or its contents are already |
| 226 | 226 | // in `$carry`. |
| 227 | - if ( ! isset( $annotations[ $item ]['text'] ) |
|
| 228 | - || in_array( $annotations[ $item ]['text'], $carry ) ) { |
|
| 227 | + if ( ! isset($annotations[$item]['text']) |
|
| 228 | + || in_array($annotations[$item]['text'], $carry)) { |
|
| 229 | 229 | return $carry; |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | // Push the label. |
| 233 | - $carry[] = $annotations[ $item ]['text']; |
|
| 233 | + $carry[] = $annotations[$item]['text']; |
|
| 234 | 234 | |
| 235 | 235 | return $carry; |
| 236 | - }, $initial ); |
|
| 236 | + }, $initial); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
@@ -257,11 +257,11 @@ discard block |
||
| 257 | 257 | * @return int|\WP_Error |
| 258 | 258 | * @throws \Exception |
| 259 | 259 | */ |
| 260 | - private function create_or_update_entity( $entity, $post_status = 'draft' ) { |
|
| 260 | + private function create_or_update_entity($entity, $post_status = 'draft') { |
|
| 261 | 261 | |
| 262 | 262 | // Get only valid IDs. |
| 263 | - $ids = array_filter( (array) $entity['id'], function ( $id ) { |
|
| 264 | - return preg_match( '|^https?://|', $id ); |
|
| 263 | + $ids = array_filter((array) $entity['id'], function($id) { |
|
| 264 | + return preg_match('|^https?://|', $id); |
|
| 265 | 265 | } ); |
| 266 | 266 | |
| 267 | 267 | $uris = array_merge( |
@@ -269,47 +269,47 @@ discard block |
||
| 269 | 269 | (array) $entity['sameAs'] |
| 270 | 270 | ); |
| 271 | 271 | |
| 272 | - $post = $this->get_first_matching_entity_by_uri( $uris ); |
|
| 272 | + $post = $this->get_first_matching_entity_by_uri($uris); |
|
| 273 | 273 | |
| 274 | - $this->log->trace( 'Entity' . ( empty( $post ) ? ' not' : '' ) . " found with the following URIs:\n" |
|
| 275 | - . var_export( $uris, true ) ); |
|
| 274 | + $this->log->trace('Entity'.(empty($post) ? ' not' : '')." found with the following URIs:\n" |
|
| 275 | + . var_export($uris, true)); |
|
| 276 | 276 | |
| 277 | 277 | // Get the labels. |
| 278 | - $labels = $this->get_labels( $entity ); |
|
| 278 | + $labels = $this->get_labels($entity); |
|
| 279 | 279 | |
| 280 | - if ( empty( $post ) ) { |
|
| 280 | + if (empty($post)) { |
|
| 281 | 281 | // Create the entity if it doesn't exist. |
| 282 | - $post_id = $this->entity_store->create( array( |
|
| 282 | + $post_id = $this->entity_store->create(array( |
|
| 283 | 283 | 'labels' => $labels, |
| 284 | 284 | 'description' => $entity['description'], |
| 285 | 285 | 'same_as' => $uris, |
| 286 | - ), $post_status ); |
|
| 286 | + ), $post_status); |
|
| 287 | 287 | |
| 288 | 288 | // Return the WP_Error if we got one. |
| 289 | - if ( is_wp_error( $post_id ) ) { |
|
| 289 | + if (is_wp_error($post_id)) { |
|
| 290 | 290 | return $post_id; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | // Add the entity type. |
| 294 | - if ( isset( $entity['mainType'] ) ) { |
|
| 295 | - wp_set_object_terms( $post_id, $entity['mainType'], \Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 294 | + if (isset($entity['mainType'])) { |
|
| 295 | + wp_set_object_terms($post_id, $entity['mainType'], \Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - if ( isset( $entity['properties'] ) && isset( $entity['properties']['latitude'] ) && isset( $entity['properties']['longitude'] ) ) { |
|
| 299 | - add_post_meta( $post_id, \Wordlift_Schema_Service::FIELD_GEO_LATITUDE, $entity['properties']['latitude'] ); |
|
| 300 | - add_post_meta( $post_id, \Wordlift_Schema_Service::FIELD_GEO_LONGITUDE, $entity['properties']['longitude'] ); |
|
| 298 | + if (isset($entity['properties']) && isset($entity['properties']['latitude']) && isset($entity['properties']['longitude'])) { |
|
| 299 | + add_post_meta($post_id, \Wordlift_Schema_Service::FIELD_GEO_LATITUDE, $entity['properties']['latitude']); |
|
| 300 | + add_post_meta($post_id, \Wordlift_Schema_Service::FIELD_GEO_LONGITUDE, $entity['properties']['longitude']); |
|
| 301 | 301 | } |
| 302 | 302 | } else { |
| 303 | 303 | // Update the entity otherwise. |
| 304 | - $post_id = $this->entity_store->update( array( |
|
| 304 | + $post_id = $this->entity_store->update(array( |
|
| 305 | 305 | 'ID' => $post->ID, |
| 306 | 306 | 'labels' => $labels, |
| 307 | 307 | 'same_as' => $uris, |
| 308 | - ) ); |
|
| 308 | + )); |
|
| 309 | 309 | |
| 310 | 310 | // Add the entity type. |
| 311 | - if ( isset( $entity['mainType'] ) ) { |
|
| 312 | - wp_add_object_terms( $post_id, $entity['mainType'], \Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 311 | + if (isset($entity['mainType'])) { |
|
| 312 | + wp_add_object_terms($post_id, $entity['mainType'], \Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME); |
|
| 313 | 313 | } |
| 314 | 314 | } |
| 315 | 315 | |
@@ -325,11 +325,11 @@ discard block |
||
| 325 | 325 | * |
| 326 | 326 | * @return \WP_Post|null The entity WP_Post if found or null if not found. |
| 327 | 327 | */ |
| 328 | - private function get_first_matching_entity_by_uri( $uris ) { |
|
| 328 | + private function get_first_matching_entity_by_uri($uris) { |
|
| 329 | 329 | |
| 330 | - foreach ( $uris as $uri ) { |
|
| 331 | - $existing_entity = $this->entity_service->get_entity_post_by_uri( $uri ); |
|
| 332 | - if ( isset( $existing_entity ) ) { |
|
| 330 | + foreach ($uris as $uri) { |
|
| 331 | + $existing_entity = $this->entity_service->get_entity_post_by_uri($uri); |
|
| 332 | + if (isset($existing_entity)) { |
|
| 333 | 333 | return $existing_entity; |
| 334 | 334 | } |
| 335 | 335 | } |
@@ -67,1561 +67,1561 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | class Wordlift { |
| 69 | 69 | |
| 70 | - //<editor-fold desc="## FIELDS"> |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * The loader that's responsible for maintaining and registering all hooks that power |
|
| 74 | - * the plugin. |
|
| 75 | - * |
|
| 76 | - * @since 1.0.0 |
|
| 77 | - * @access protected |
|
| 78 | - * @var Wordlift_Loader $loader Maintains and registers all hooks for the plugin. |
|
| 79 | - */ |
|
| 80 | - protected $loader; |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * The unique identifier of this plugin. |
|
| 84 | - * |
|
| 85 | - * @since 1.0.0 |
|
| 86 | - * @access protected |
|
| 87 | - * @var string $plugin_name The string used to uniquely identify this plugin. |
|
| 88 | - */ |
|
| 89 | - protected $plugin_name; |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * The current version of the plugin. |
|
| 93 | - * |
|
| 94 | - * @since 1.0.0 |
|
| 95 | - * @access protected |
|
| 96 | - * @var string $version The current version of the plugin. |
|
| 97 | - */ |
|
| 98 | - protected $version; |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 102 | - * |
|
| 103 | - * @since 3.12.0 |
|
| 104 | - * @access protected |
|
| 105 | - * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 106 | - */ |
|
| 107 | - protected $tinymce_adapter; |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * The {@link Faq_Tinymce_Adapter} instance |
|
| 111 | - * @since 3.26.0 |
|
| 112 | - * @access protected |
|
| 113 | - * @var Faq_Tinymce_Adapter $faq_tinymce_adapter . |
|
| 114 | - */ |
|
| 115 | - //protected $faq_tinymce_adapter; |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * The Thumbnail service. |
|
| 119 | - * |
|
| 120 | - * @since 3.1.5 |
|
| 121 | - * @access private |
|
| 122 | - * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service. |
|
| 123 | - */ |
|
| 124 | - private $thumbnail_service; |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * The UI service. |
|
| 128 | - * |
|
| 129 | - * @since 3.2.0 |
|
| 130 | - * @access private |
|
| 131 | - * @var \Wordlift_UI_Service $ui_service The UI service. |
|
| 132 | - */ |
|
| 133 | - private $ui_service; |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * The Schema service. |
|
| 137 | - * |
|
| 138 | - * @since 3.3.0 |
|
| 139 | - * @access protected |
|
| 140 | - * @var \Wordlift_Schema_Service $schema_service The Schema service. |
|
| 141 | - */ |
|
| 142 | - protected $schema_service; |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * The Entity service. |
|
| 146 | - * |
|
| 147 | - * @since 3.1.0 |
|
| 148 | - * @access protected |
|
| 149 | - * @var \Wordlift_Entity_Service $entity_service The Entity service. |
|
| 150 | - */ |
|
| 151 | - protected $entity_service; |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * The Topic Taxonomy service. |
|
| 155 | - * |
|
| 156 | - * @since 3.5.0 |
|
| 157 | - * @access private |
|
| 158 | - * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service. |
|
| 159 | - */ |
|
| 160 | - private $topic_taxonomy_service; |
|
| 161 | - |
|
| 162 | - /** |
|
| 163 | - * The Entity Types Taxonomy service. |
|
| 164 | - * |
|
| 165 | - * @since 3.18.0 |
|
| 166 | - * @access private |
|
| 167 | - * @var \Wordlift_Entity_Type_Taxonomy_Service The Entity Types Taxonomy service. |
|
| 168 | - */ |
|
| 169 | - private $entity_types_taxonomy_service; |
|
| 170 | - |
|
| 171 | - /** |
|
| 172 | - * The User service. |
|
| 173 | - * |
|
| 174 | - * @since 3.1.7 |
|
| 175 | - * @access protected |
|
| 176 | - * @var \Wordlift_User_Service $user_service The User service. |
|
| 177 | - */ |
|
| 178 | - protected $user_service; |
|
| 179 | - |
|
| 180 | - /** |
|
| 181 | - * The Timeline service. |
|
| 182 | - * |
|
| 183 | - * @since 3.1.0 |
|
| 184 | - * @access private |
|
| 185 | - * @var \Wordlift_Timeline_Service $timeline_service The Timeline service. |
|
| 186 | - */ |
|
| 187 | - private $timeline_service; |
|
| 188 | - |
|
| 189 | - /** |
|
| 190 | - * The Redirect service. |
|
| 191 | - * |
|
| 192 | - * @since 3.2.0 |
|
| 193 | - * @access private |
|
| 194 | - * @var \Wordlift_Redirect_Service $redirect_service The Redirect service. |
|
| 195 | - */ |
|
| 196 | - private $redirect_service; |
|
| 197 | - |
|
| 198 | - /** |
|
| 199 | - * The Notice service. |
|
| 200 | - * |
|
| 201 | - * @since 3.3.0 |
|
| 202 | - * @access private |
|
| 203 | - * @var \Wordlift_Notice_Service $notice_service The Notice service. |
|
| 204 | - */ |
|
| 205 | - private $notice_service; |
|
| 206 | - |
|
| 207 | - /** |
|
| 208 | - * The Entity list customization. |
|
| 209 | - * |
|
| 210 | - * @since 3.3.0 |
|
| 211 | - * @access protected |
|
| 212 | - * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service. |
|
| 213 | - */ |
|
| 214 | - protected $entity_list_service; |
|
| 215 | - |
|
| 216 | - /** |
|
| 217 | - * The Entity Types Taxonomy Walker. |
|
| 218 | - * |
|
| 219 | - * @since 3.1.0 |
|
| 220 | - * @access private |
|
| 221 | - * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker |
|
| 222 | - */ |
|
| 223 | - private $entity_types_taxonomy_walker; |
|
| 224 | - |
|
| 225 | - /** |
|
| 226 | - * The ShareThis service. |
|
| 227 | - * |
|
| 228 | - * @since 3.2.0 |
|
| 229 | - * @access private |
|
| 230 | - * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service. |
|
| 231 | - */ |
|
| 232 | - private $sharethis_service; |
|
| 233 | - |
|
| 234 | - /** |
|
| 235 | - * The PrimaShop adapter. |
|
| 236 | - * |
|
| 237 | - * @since 3.2.3 |
|
| 238 | - * @access private |
|
| 239 | - * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter. |
|
| 240 | - */ |
|
| 241 | - private $primashop_adapter; |
|
| 242 | - |
|
| 243 | - /** |
|
| 244 | - * The WordLift Dashboard adapter. |
|
| 245 | - * |
|
| 246 | - * @since 3.4.0 |
|
| 247 | - * @access private |
|
| 248 | - * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service; |
|
| 249 | - */ |
|
| 250 | - private $dashboard_service; |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * The entity type service. |
|
| 254 | - * |
|
| 255 | - * @since 3.6.0 |
|
| 256 | - * @access private |
|
| 257 | - * @var \Wordlift_Entity_Post_Type_Service |
|
| 258 | - */ |
|
| 259 | - private $entity_post_type_service; |
|
| 260 | - |
|
| 261 | - /** |
|
| 262 | - * The entity link service used to mangle links to entities with a custom slug or even w/o a slug. |
|
| 263 | - * |
|
| 264 | - * @since 3.6.0 |
|
| 265 | - * @access private |
|
| 266 | - * @var \Wordlift_Entity_Link_Service $entity_link_service The {@link Wordlift_Entity_Link_Service} instance. |
|
| 267 | - */ |
|
| 268 | - private $entity_link_service; |
|
| 269 | - |
|
| 270 | - /** |
|
| 271 | - * A {@link Wordlift_Sparql_Service} instance. |
|
| 272 | - * |
|
| 273 | - * @since 3.6.0 |
|
| 274 | - * @access protected |
|
| 275 | - * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance. |
|
| 276 | - */ |
|
| 277 | - protected $sparql_service; |
|
| 278 | - |
|
| 279 | - /** |
|
| 280 | - * A {@link Wordlift_Import_Service} instance. |
|
| 281 | - * |
|
| 282 | - * @since 3.6.0 |
|
| 283 | - * @access private |
|
| 284 | - * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance. |
|
| 285 | - */ |
|
| 286 | - private $import_service; |
|
| 287 | - |
|
| 288 | - /** |
|
| 289 | - * A {@link Wordlift_Rebuild_Service} instance. |
|
| 290 | - * |
|
| 291 | - * @since 3.6.0 |
|
| 292 | - * @access private |
|
| 293 | - * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance. |
|
| 294 | - */ |
|
| 295 | - private $rebuild_service; |
|
| 296 | - |
|
| 297 | - /** |
|
| 298 | - * A {@link Wordlift_Jsonld_Service} instance. |
|
| 299 | - * |
|
| 300 | - * @since 3.7.0 |
|
| 301 | - * @access protected |
|
| 302 | - * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance. |
|
| 303 | - */ |
|
| 304 | - protected $jsonld_service; |
|
| 305 | - |
|
| 306 | - /** |
|
| 307 | - * A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 308 | - * |
|
| 309 | - * @since 3.14.0 |
|
| 310 | - * @access protected |
|
| 311 | - * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 312 | - */ |
|
| 313 | - protected $jsonld_website_converter; |
|
| 314 | - |
|
| 315 | - /** |
|
| 316 | - * A {@link Wordlift_Property_Factory} instance. |
|
| 317 | - * |
|
| 318 | - * @since 3.7.0 |
|
| 319 | - * @access private |
|
| 320 | - * @var \Wordlift_Property_Factory $property_factory |
|
| 321 | - */ |
|
| 322 | - private $property_factory; |
|
| 323 | - |
|
| 324 | - /** |
|
| 325 | - * The 'Download Your Data' page. |
|
| 326 | - * |
|
| 327 | - * @since 3.6.0 |
|
| 328 | - * @access private |
|
| 329 | - * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page. |
|
| 330 | - */ |
|
| 331 | - private $download_your_data_page; |
|
| 332 | - |
|
| 333 | - /** |
|
| 334 | - * The 'WordLift Settings' page. |
|
| 335 | - * |
|
| 336 | - * @since 3.11.0 |
|
| 337 | - * @access protected |
|
| 338 | - * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page. |
|
| 339 | - */ |
|
| 340 | - protected $settings_page; |
|
| 341 | - |
|
| 342 | - /** |
|
| 343 | - * The install wizard page. |
|
| 344 | - * |
|
| 345 | - * @since 3.9.0 |
|
| 346 | - * @access private |
|
| 347 | - * @var \Wordlift_Admin_Setup $admin_setup The Install wizard. |
|
| 348 | - */ |
|
| 349 | - public $admin_setup; |
|
| 350 | - |
|
| 351 | - /** |
|
| 352 | - * The Content Filter Service hooks up to the 'the_content' filter and provides |
|
| 353 | - * linking of entities to their pages. |
|
| 354 | - * |
|
| 355 | - * @since 3.8.0 |
|
| 356 | - * @access private |
|
| 357 | - * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance. |
|
| 358 | - */ |
|
| 359 | - private $content_filter_service; |
|
| 360 | - |
|
| 361 | - /** |
|
| 362 | - * The Faq Content filter service |
|
| 363 | - * @since 3.26.0 |
|
| 364 | - * @access private |
|
| 365 | - * @var Faq_Content_Filter $faq_content_filter_service A {@link Faq_Content_Filter} instance. |
|
| 366 | - */ |
|
| 367 | - private $faq_content_filter_service; |
|
| 368 | - |
|
| 369 | - /** |
|
| 370 | - * A {@link Wordlift_Key_Validation_Service} instance. |
|
| 371 | - * |
|
| 372 | - * @since 3.9.0 |
|
| 373 | - * @access private |
|
| 374 | - * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 375 | - */ |
|
| 376 | - private $key_validation_service; |
|
| 377 | - |
|
| 378 | - /** |
|
| 379 | - * A {@link Wordlift_Rating_Service} instance. |
|
| 380 | - * |
|
| 381 | - * @since 3.10.0 |
|
| 382 | - * @access private |
|
| 383 | - * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance. |
|
| 384 | - */ |
|
| 385 | - private $rating_service; |
|
| 386 | - |
|
| 387 | - /** |
|
| 388 | - * A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 389 | - * |
|
| 390 | - * @since 3.10.0 |
|
| 391 | - * @access protected |
|
| 392 | - * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 393 | - */ |
|
| 394 | - protected $post_to_jsonld_converter; |
|
| 395 | - |
|
| 396 | - /** |
|
| 397 | - * A {@link Wordlift_Configuration_Service} instance. |
|
| 398 | - * |
|
| 399 | - * @since 3.10.0 |
|
| 400 | - * @access protected |
|
| 401 | - * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 402 | - */ |
|
| 403 | - protected $configuration_service; |
|
| 404 | - |
|
| 405 | - /** |
|
| 406 | - * A {@link Wordlift_Install_Service} instance. |
|
| 407 | - * |
|
| 408 | - * @since 3.18.0 |
|
| 409 | - * @access protected |
|
| 410 | - * @var \Wordlift_Install_Service $install_service A {@link Wordlift_Install_Service} instance. |
|
| 411 | - */ |
|
| 412 | - protected $install_service; |
|
| 413 | - |
|
| 414 | - /** |
|
| 415 | - * A {@link Wordlift_Entity_Type_Service} instance. |
|
| 416 | - * |
|
| 417 | - * @since 3.10.0 |
|
| 418 | - * @access protected |
|
| 419 | - * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 420 | - */ |
|
| 421 | - protected $entity_type_service; |
|
| 422 | - |
|
| 423 | - /** |
|
| 424 | - * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 425 | - * |
|
| 426 | - * @since 3.10.0 |
|
| 427 | - * @access protected |
|
| 428 | - * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 429 | - */ |
|
| 430 | - protected $entity_post_to_jsonld_converter; |
|
| 431 | - |
|
| 432 | - /** |
|
| 433 | - * A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 434 | - * |
|
| 435 | - * @since 3.10.0 |
|
| 436 | - * @access protected |
|
| 437 | - * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 438 | - */ |
|
| 439 | - protected $postid_to_jsonld_converter; |
|
| 440 | - |
|
| 441 | - /** |
|
| 442 | - * The {@link Wordlift_Admin_Status_Page} class. |
|
| 443 | - * |
|
| 444 | - * @since 3.9.8 |
|
| 445 | - * @access private |
|
| 446 | - * @var \Wordlift_Admin_Status_Page $status_page The {@link Wordlift_Admin_Status_Page} class. |
|
| 447 | - */ |
|
| 448 | - private $status_page; |
|
| 449 | - |
|
| 450 | - /** |
|
| 451 | - * The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 452 | - * |
|
| 453 | - * @since 3.11.0 |
|
| 454 | - * @access protected |
|
| 455 | - * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 456 | - */ |
|
| 457 | - protected $category_taxonomy_service; |
|
| 458 | - |
|
| 459 | - /** |
|
| 460 | - * The {@link Wordlift_Entity_Page_Service} instance. |
|
| 461 | - * |
|
| 462 | - * @since 3.11.0 |
|
| 463 | - * @access protected |
|
| 464 | - * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance. |
|
| 465 | - */ |
|
| 466 | - protected $entity_page_service; |
|
| 467 | - |
|
| 468 | - /** |
|
| 469 | - * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 470 | - * |
|
| 471 | - * @since 3.11.0 |
|
| 472 | - * @access protected |
|
| 473 | - * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 474 | - */ |
|
| 475 | - protected $settings_page_action_link; |
|
| 476 | - |
|
| 477 | - /** |
|
| 478 | - * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 479 | - * |
|
| 480 | - * @since 3.11.0 |
|
| 481 | - * @access protected |
|
| 482 | - * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 483 | - */ |
|
| 484 | - protected $analytics_settings_page_action_link; |
|
| 485 | - |
|
| 486 | - /** |
|
| 487 | - * The {@link Wordlift_Analytics_Connect} class. |
|
| 488 | - * |
|
| 489 | - * @since 3.11.0 |
|
| 490 | - * @access protected |
|
| 491 | - * @var \Wordlift_Analytics_Connect $analytics_connect The {@link Wordlift_Analytics_Connect} class. |
|
| 492 | - */ |
|
| 493 | - protected $analytics_connect; |
|
| 494 | - |
|
| 495 | - /** |
|
| 496 | - * The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 497 | - * |
|
| 498 | - * @since 3.11.0 |
|
| 499 | - * @access protected |
|
| 500 | - * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 501 | - */ |
|
| 502 | - protected $publisher_ajax_adapter; |
|
| 503 | - |
|
| 504 | - /** |
|
| 505 | - * The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 506 | - * |
|
| 507 | - * @since 3.11.0 |
|
| 508 | - * @access protected |
|
| 509 | - * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 510 | - */ |
|
| 511 | - protected $input_element; |
|
| 512 | - |
|
| 513 | - /** |
|
| 514 | - * The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 515 | - * |
|
| 516 | - * @since 3.13.0 |
|
| 517 | - * @access protected |
|
| 518 | - * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 519 | - */ |
|
| 520 | - protected $radio_input_element; |
|
| 521 | - |
|
| 522 | - /** |
|
| 523 | - * The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 524 | - * |
|
| 525 | - * @since 3.11.0 |
|
| 526 | - * @access protected |
|
| 527 | - * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 528 | - */ |
|
| 529 | - protected $language_select_element; |
|
| 530 | - |
|
| 531 | - /** |
|
| 532 | - * The {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 533 | - * |
|
| 534 | - * @since 3.18.0 |
|
| 535 | - * @access protected |
|
| 536 | - * @var \Wordlift_Admin_Country_Select_Element $country_select_element The {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 537 | - */ |
|
| 538 | - protected $country_select_element; |
|
| 539 | - |
|
| 540 | - /** |
|
| 541 | - * The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 542 | - * |
|
| 543 | - * @since 3.11.0 |
|
| 544 | - * @access protected |
|
| 545 | - * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 546 | - */ |
|
| 547 | - protected $publisher_element; |
|
| 548 | - |
|
| 549 | - /** |
|
| 550 | - * The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 551 | - * |
|
| 552 | - * @since 3.11.0 |
|
| 553 | - * @access protected |
|
| 554 | - * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 555 | - */ |
|
| 556 | - protected $select2_element; |
|
| 557 | - |
|
| 558 | - /** |
|
| 559 | - * The controller for the entity type list admin page |
|
| 560 | - * |
|
| 561 | - * @since 3.11.0 |
|
| 562 | - * @access private |
|
| 563 | - * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class. |
|
| 564 | - */ |
|
| 565 | - private $entity_type_admin_page; |
|
| 566 | - |
|
| 567 | - /** |
|
| 568 | - * The controller for the entity type settings admin page |
|
| 569 | - * |
|
| 570 | - * @since 3.11.0 |
|
| 571 | - * @access private |
|
| 572 | - * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class. |
|
| 573 | - */ |
|
| 574 | - private $entity_type_settings_admin_page; |
|
| 575 | - |
|
| 576 | - /** |
|
| 577 | - * The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 578 | - * |
|
| 579 | - * @since 3.11.0 |
|
| 580 | - * @access protected |
|
| 581 | - * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 582 | - */ |
|
| 583 | - protected $related_entities_cloud_widget; |
|
| 584 | - |
|
| 585 | - /** |
|
| 586 | - * The {@link Wordlift_Admin_Author_Element} instance. |
|
| 587 | - * |
|
| 588 | - * @since 3.14.0 |
|
| 589 | - * @access protected |
|
| 590 | - * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance. |
|
| 591 | - */ |
|
| 592 | - protected $author_element; |
|
| 593 | - |
|
| 594 | - /** |
|
| 595 | - * The {@link Wordlift_Sample_Data_Service} instance. |
|
| 596 | - * |
|
| 597 | - * @since 3.12.0 |
|
| 598 | - * @access protected |
|
| 599 | - * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance. |
|
| 600 | - */ |
|
| 601 | - protected $sample_data_service; |
|
| 602 | - |
|
| 603 | - /** |
|
| 604 | - * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 605 | - * |
|
| 606 | - * @since 3.12.0 |
|
| 607 | - * @access protected |
|
| 608 | - * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 609 | - */ |
|
| 610 | - protected $sample_data_ajax_adapter; |
|
| 611 | - |
|
| 612 | - /** |
|
| 613 | - * The {@link Wordlift_Relation_Rebuild_Service} instance. |
|
| 614 | - * |
|
| 615 | - * @since 3.14.3 |
|
| 616 | - * @access private |
|
| 617 | - * @var \Wordlift_Relation_Rebuild_Service $relation_rebuild_service The {@link Wordlift_Relation_Rebuild_Service} instance. |
|
| 618 | - */ |
|
| 619 | - private $relation_rebuild_service; |
|
| 620 | - |
|
| 621 | - /** |
|
| 622 | - * The {@link Wordlift_Relation_Rebuild_Adapter} instance. |
|
| 623 | - * |
|
| 624 | - * @since 3.14.3 |
|
| 625 | - * @access private |
|
| 626 | - * @var \Wordlift_Relation_Rebuild_Adapter $relation_rebuild_adapter The {@link Wordlift_Relation_Rebuild_Adapter} instance. |
|
| 627 | - */ |
|
| 628 | - private $relation_rebuild_adapter; |
|
| 629 | - |
|
| 630 | - /** |
|
| 631 | - * The {@link Wordlift_Reference_Rebuild_Service} instance. |
|
| 632 | - * |
|
| 633 | - * @since 3.18.0 |
|
| 634 | - * @access private |
|
| 635 | - * @var \Wordlift_Reference_Rebuild_Service $reference_rebuild_service The {@link Wordlift_Reference_Rebuild_Service} instance. |
|
| 636 | - */ |
|
| 637 | - private $reference_rebuild_service; |
|
| 638 | - |
|
| 639 | - /** |
|
| 640 | - * The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 641 | - * |
|
| 642 | - * @since 3.16.0 |
|
| 643 | - * @access protected |
|
| 644 | - * @var \Wordlift_Google_Analytics_Export_Service $google_analytics_export_service The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 645 | - */ |
|
| 646 | - protected $google_analytics_export_service; |
|
| 647 | - |
|
| 648 | - /** |
|
| 649 | - * {@link Wordlift}'s singleton instance. |
|
| 650 | - * |
|
| 651 | - * @since 3.15.0 |
|
| 652 | - * @access protected |
|
| 653 | - * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance. |
|
| 654 | - */ |
|
| 655 | - protected $entity_type_adapter; |
|
| 656 | - |
|
| 657 | - /** |
|
| 658 | - * The {@link Wordlift_Storage_Factory} instance. |
|
| 659 | - * |
|
| 660 | - * @since 3.15.0 |
|
| 661 | - * @access protected |
|
| 662 | - * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance. |
|
| 663 | - */ |
|
| 664 | - protected $storage_factory; |
|
| 665 | - |
|
| 666 | - /** |
|
| 667 | - * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 668 | - * |
|
| 669 | - * @since 3.15.0 |
|
| 670 | - * @access protected |
|
| 671 | - * @var \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 672 | - */ |
|
| 673 | - protected $rendition_factory; |
|
| 674 | - |
|
| 675 | - /** |
|
| 676 | - * The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 677 | - * |
|
| 678 | - * @since 3.15.0 |
|
| 679 | - * @access private |
|
| 680 | - * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 681 | - */ |
|
| 682 | - private $autocomplete_adapter; |
|
| 683 | - |
|
| 684 | - /** |
|
| 685 | - * The {@link Wordlift_Relation_Service} instance. |
|
| 686 | - * |
|
| 687 | - * @since 3.15.0 |
|
| 688 | - * @access protected |
|
| 689 | - * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance. |
|
| 690 | - */ |
|
| 691 | - protected $relation_service; |
|
| 692 | - |
|
| 693 | - /** |
|
| 694 | - * The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 695 | - * |
|
| 696 | - * @since 3.16.0 |
|
| 697 | - * @access protected |
|
| 698 | - * @var \Wordlift_Cached_Post_Converter $cached_postid_to_jsonld_converter The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 699 | - * |
|
| 700 | - */ |
|
| 701 | - protected $cached_postid_to_jsonld_converter; |
|
| 702 | - |
|
| 703 | - /** |
|
| 704 | - * The {@link Wordlift_Entity_Uri_Service} instance. |
|
| 705 | - * |
|
| 706 | - * @since 3.16.3 |
|
| 707 | - * @access protected |
|
| 708 | - * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance. |
|
| 709 | - */ |
|
| 710 | - protected $entity_uri_service; |
|
| 711 | - |
|
| 712 | - /** |
|
| 713 | - * The {@link Wordlift_Publisher_Service} instance. |
|
| 714 | - * |
|
| 715 | - * @since 3.19.0 |
|
| 716 | - * @access protected |
|
| 717 | - * @var \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance. |
|
| 718 | - */ |
|
| 719 | - protected $publisher_service; |
|
| 720 | - |
|
| 721 | - /** |
|
| 722 | - * The {@link Wordlift_Context_Cards_Service} instance. |
|
| 723 | - * |
|
| 724 | - * @var \Wordlift_Context_Cards_Service The {@link Wordlift_Context_Cards_Service} instance. |
|
| 725 | - */ |
|
| 726 | - protected $context_cards_service; |
|
| 727 | - |
|
| 728 | - /** |
|
| 729 | - * {@link Wordlift}'s singleton instance. |
|
| 730 | - * |
|
| 731 | - * @since 3.11.2 |
|
| 732 | - * @access private |
|
| 733 | - * @var Wordlift $instance {@link Wordlift}'s singleton instance. |
|
| 734 | - */ |
|
| 735 | - private static $instance; |
|
| 736 | - |
|
| 737 | - //</editor-fold> |
|
| 738 | - |
|
| 739 | - /** |
|
| 740 | - * Define the core functionality of the plugin. |
|
| 741 | - * |
|
| 742 | - * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 743 | - * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 744 | - * the public-facing side of the site. |
|
| 745 | - * |
|
| 746 | - * @since 1.0.0 |
|
| 747 | - */ |
|
| 748 | - public function __construct() { |
|
| 749 | - |
|
| 750 | - self::$instance = $this; |
|
| 751 | - |
|
| 752 | - $this->plugin_name = 'wordlift'; |
|
| 753 | - $this->version = '3.27.7.1'; |
|
| 754 | - $this->load_dependencies(); |
|
| 755 | - $this->set_locale(); |
|
| 756 | - $this->define_admin_hooks(); |
|
| 757 | - $this->define_public_hooks(); |
|
| 758 | - |
|
| 759 | - // If we're in `WP_CLI` load the related files. |
|
| 760 | - if ( class_exists( 'WP_CLI' ) ) { |
|
| 761 | - $this->load_cli_dependencies(); |
|
| 762 | - } |
|
| 763 | - |
|
| 764 | - } |
|
| 765 | - |
|
| 766 | - /** |
|
| 767 | - * Get the singleton instance. |
|
| 768 | - * |
|
| 769 | - * @return Wordlift The {@link Wordlift} singleton instance. |
|
| 770 | - * @since 3.11.2 |
|
| 771 | - * |
|
| 772 | - */ |
|
| 773 | - public static function get_instance() { |
|
| 774 | - |
|
| 775 | - return self::$instance; |
|
| 776 | - } |
|
| 777 | - |
|
| 778 | - /** |
|
| 779 | - * Load the required dependencies for this plugin. |
|
| 780 | - * |
|
| 781 | - * Include the following files that make up the plugin: |
|
| 782 | - * |
|
| 783 | - * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 784 | - * - Wordlift_i18n. Defines internationalization functionality. |
|
| 785 | - * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 786 | - * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 787 | - * |
|
| 788 | - * Create an instance of the loader which will be used to register the hooks |
|
| 789 | - * with WordPress. |
|
| 790 | - * |
|
| 791 | - * @throws Exception |
|
| 792 | - * @since 1.0.0 |
|
| 793 | - * @access private |
|
| 794 | - */ |
|
| 795 | - private function load_dependencies() { |
|
| 796 | - |
|
| 797 | - /** |
|
| 798 | - * The class responsible for orchestrating the actions and filters of the |
|
| 799 | - * core plugin. |
|
| 800 | - */ |
|
| 801 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 802 | - |
|
| 803 | - // The class responsible for plugin uninstall. |
|
| 804 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-deactivator-feedback.php'; |
|
| 805 | - |
|
| 806 | - /** |
|
| 807 | - * The class responsible for defining internationalization functionality |
|
| 808 | - * of the plugin. |
|
| 809 | - */ |
|
| 810 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 811 | - |
|
| 812 | - /** |
|
| 813 | - * WordLift's supported languages. |
|
| 814 | - */ |
|
| 815 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php'; |
|
| 816 | - |
|
| 817 | - /** |
|
| 818 | - * WordLift's supported countries. |
|
| 819 | - */ |
|
| 820 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-countries.php'; |
|
| 821 | - |
|
| 822 | - /** |
|
| 823 | - * Provide support functions to sanitize data. |
|
| 824 | - */ |
|
| 825 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 826 | - |
|
| 827 | - /** Services. */ |
|
| 828 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 829 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php'; |
|
| 830 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 831 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 832 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 833 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 834 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 835 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php'; |
|
| 836 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php'; |
|
| 837 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-image-service.php'; |
|
| 838 | - |
|
| 839 | - /** |
|
| 840 | - * The Query builder. |
|
| 841 | - */ |
|
| 842 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 843 | - |
|
| 844 | - /** |
|
| 845 | - * The Schema service. |
|
| 846 | - */ |
|
| 847 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 848 | - |
|
| 849 | - /** |
|
| 850 | - * The schema:url property service. |
|
| 851 | - */ |
|
| 852 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 853 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 854 | - |
|
| 855 | - /** |
|
| 856 | - * The UI service. |
|
| 857 | - */ |
|
| 858 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 859 | - |
|
| 860 | - /** |
|
| 861 | - * The Thumbnail service. |
|
| 862 | - */ |
|
| 863 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 864 | - |
|
| 865 | - /** |
|
| 866 | - * The Entity Types Taxonomy service. |
|
| 867 | - */ |
|
| 868 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-taxonomy-service.php'; |
|
| 869 | - |
|
| 870 | - /** |
|
| 871 | - * The Entity service. |
|
| 872 | - */ |
|
| 873 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php'; |
|
| 874 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 875 | - |
|
| 876 | - // Add the entity rating service. |
|
| 877 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php'; |
|
| 878 | - |
|
| 879 | - /** |
|
| 880 | - * The User service. |
|
| 881 | - */ |
|
| 882 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 883 | - |
|
| 884 | - /** |
|
| 885 | - * The Timeline service. |
|
| 886 | - */ |
|
| 887 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 888 | - |
|
| 889 | - /** |
|
| 890 | - * The Topic Taxonomy service. |
|
| 891 | - */ |
|
| 892 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 893 | - |
|
| 894 | - /** |
|
| 895 | - * The SPARQL service. |
|
| 896 | - */ |
|
| 897 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 898 | - |
|
| 899 | - /** |
|
| 900 | - * The WordLift import service. |
|
| 901 | - */ |
|
| 902 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 903 | - |
|
| 904 | - /** |
|
| 905 | - * The WordLift URI service. |
|
| 906 | - */ |
|
| 907 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 908 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 909 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php'; |
|
| 910 | - |
|
| 911 | - /** |
|
| 912 | - * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
|
| 913 | - */ |
|
| 914 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-listable.php'; |
|
| 915 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-rebuild-service.php'; |
|
| 916 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-reference-rebuild-service.php'; |
|
| 917 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-service.php'; |
|
| 918 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-adapter.php'; |
|
| 919 | - |
|
| 920 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 921 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php'; |
|
| 922 | - |
|
| 923 | - /** |
|
| 924 | - * Load the converters. |
|
| 925 | - */ |
|
| 926 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php'; |
|
| 927 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 928 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 929 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 930 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 931 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php'; |
|
| 932 | - |
|
| 933 | - /** |
|
| 934 | - * Load cache-related files. |
|
| 935 | - */ |
|
| 936 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php'; |
|
| 937 | - |
|
| 938 | - /** |
|
| 939 | - * Load the content filter. |
|
| 940 | - */ |
|
| 941 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 942 | - |
|
| 943 | - /* |
|
| 70 | + //<editor-fold desc="## FIELDS"> |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * The loader that's responsible for maintaining and registering all hooks that power |
|
| 74 | + * the plugin. |
|
| 75 | + * |
|
| 76 | + * @since 1.0.0 |
|
| 77 | + * @access protected |
|
| 78 | + * @var Wordlift_Loader $loader Maintains and registers all hooks for the plugin. |
|
| 79 | + */ |
|
| 80 | + protected $loader; |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * The unique identifier of this plugin. |
|
| 84 | + * |
|
| 85 | + * @since 1.0.0 |
|
| 86 | + * @access protected |
|
| 87 | + * @var string $plugin_name The string used to uniquely identify this plugin. |
|
| 88 | + */ |
|
| 89 | + protected $plugin_name; |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * The current version of the plugin. |
|
| 93 | + * |
|
| 94 | + * @since 1.0.0 |
|
| 95 | + * @access protected |
|
| 96 | + * @var string $version The current version of the plugin. |
|
| 97 | + */ |
|
| 98 | + protected $version; |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 102 | + * |
|
| 103 | + * @since 3.12.0 |
|
| 104 | + * @access protected |
|
| 105 | + * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 106 | + */ |
|
| 107 | + protected $tinymce_adapter; |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * The {@link Faq_Tinymce_Adapter} instance |
|
| 111 | + * @since 3.26.0 |
|
| 112 | + * @access protected |
|
| 113 | + * @var Faq_Tinymce_Adapter $faq_tinymce_adapter . |
|
| 114 | + */ |
|
| 115 | + //protected $faq_tinymce_adapter; |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * The Thumbnail service. |
|
| 119 | + * |
|
| 120 | + * @since 3.1.5 |
|
| 121 | + * @access private |
|
| 122 | + * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service. |
|
| 123 | + */ |
|
| 124 | + private $thumbnail_service; |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * The UI service. |
|
| 128 | + * |
|
| 129 | + * @since 3.2.0 |
|
| 130 | + * @access private |
|
| 131 | + * @var \Wordlift_UI_Service $ui_service The UI service. |
|
| 132 | + */ |
|
| 133 | + private $ui_service; |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * The Schema service. |
|
| 137 | + * |
|
| 138 | + * @since 3.3.0 |
|
| 139 | + * @access protected |
|
| 140 | + * @var \Wordlift_Schema_Service $schema_service The Schema service. |
|
| 141 | + */ |
|
| 142 | + protected $schema_service; |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * The Entity service. |
|
| 146 | + * |
|
| 147 | + * @since 3.1.0 |
|
| 148 | + * @access protected |
|
| 149 | + * @var \Wordlift_Entity_Service $entity_service The Entity service. |
|
| 150 | + */ |
|
| 151 | + protected $entity_service; |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * The Topic Taxonomy service. |
|
| 155 | + * |
|
| 156 | + * @since 3.5.0 |
|
| 157 | + * @access private |
|
| 158 | + * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service. |
|
| 159 | + */ |
|
| 160 | + private $topic_taxonomy_service; |
|
| 161 | + |
|
| 162 | + /** |
|
| 163 | + * The Entity Types Taxonomy service. |
|
| 164 | + * |
|
| 165 | + * @since 3.18.0 |
|
| 166 | + * @access private |
|
| 167 | + * @var \Wordlift_Entity_Type_Taxonomy_Service The Entity Types Taxonomy service. |
|
| 168 | + */ |
|
| 169 | + private $entity_types_taxonomy_service; |
|
| 170 | + |
|
| 171 | + /** |
|
| 172 | + * The User service. |
|
| 173 | + * |
|
| 174 | + * @since 3.1.7 |
|
| 175 | + * @access protected |
|
| 176 | + * @var \Wordlift_User_Service $user_service The User service. |
|
| 177 | + */ |
|
| 178 | + protected $user_service; |
|
| 179 | + |
|
| 180 | + /** |
|
| 181 | + * The Timeline service. |
|
| 182 | + * |
|
| 183 | + * @since 3.1.0 |
|
| 184 | + * @access private |
|
| 185 | + * @var \Wordlift_Timeline_Service $timeline_service The Timeline service. |
|
| 186 | + */ |
|
| 187 | + private $timeline_service; |
|
| 188 | + |
|
| 189 | + /** |
|
| 190 | + * The Redirect service. |
|
| 191 | + * |
|
| 192 | + * @since 3.2.0 |
|
| 193 | + * @access private |
|
| 194 | + * @var \Wordlift_Redirect_Service $redirect_service The Redirect service. |
|
| 195 | + */ |
|
| 196 | + private $redirect_service; |
|
| 197 | + |
|
| 198 | + /** |
|
| 199 | + * The Notice service. |
|
| 200 | + * |
|
| 201 | + * @since 3.3.0 |
|
| 202 | + * @access private |
|
| 203 | + * @var \Wordlift_Notice_Service $notice_service The Notice service. |
|
| 204 | + */ |
|
| 205 | + private $notice_service; |
|
| 206 | + |
|
| 207 | + /** |
|
| 208 | + * The Entity list customization. |
|
| 209 | + * |
|
| 210 | + * @since 3.3.0 |
|
| 211 | + * @access protected |
|
| 212 | + * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service. |
|
| 213 | + */ |
|
| 214 | + protected $entity_list_service; |
|
| 215 | + |
|
| 216 | + /** |
|
| 217 | + * The Entity Types Taxonomy Walker. |
|
| 218 | + * |
|
| 219 | + * @since 3.1.0 |
|
| 220 | + * @access private |
|
| 221 | + * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker |
|
| 222 | + */ |
|
| 223 | + private $entity_types_taxonomy_walker; |
|
| 224 | + |
|
| 225 | + /** |
|
| 226 | + * The ShareThis service. |
|
| 227 | + * |
|
| 228 | + * @since 3.2.0 |
|
| 229 | + * @access private |
|
| 230 | + * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service. |
|
| 231 | + */ |
|
| 232 | + private $sharethis_service; |
|
| 233 | + |
|
| 234 | + /** |
|
| 235 | + * The PrimaShop adapter. |
|
| 236 | + * |
|
| 237 | + * @since 3.2.3 |
|
| 238 | + * @access private |
|
| 239 | + * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter. |
|
| 240 | + */ |
|
| 241 | + private $primashop_adapter; |
|
| 242 | + |
|
| 243 | + /** |
|
| 244 | + * The WordLift Dashboard adapter. |
|
| 245 | + * |
|
| 246 | + * @since 3.4.0 |
|
| 247 | + * @access private |
|
| 248 | + * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service; |
|
| 249 | + */ |
|
| 250 | + private $dashboard_service; |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * The entity type service. |
|
| 254 | + * |
|
| 255 | + * @since 3.6.0 |
|
| 256 | + * @access private |
|
| 257 | + * @var \Wordlift_Entity_Post_Type_Service |
|
| 258 | + */ |
|
| 259 | + private $entity_post_type_service; |
|
| 260 | + |
|
| 261 | + /** |
|
| 262 | + * The entity link service used to mangle links to entities with a custom slug or even w/o a slug. |
|
| 263 | + * |
|
| 264 | + * @since 3.6.0 |
|
| 265 | + * @access private |
|
| 266 | + * @var \Wordlift_Entity_Link_Service $entity_link_service The {@link Wordlift_Entity_Link_Service} instance. |
|
| 267 | + */ |
|
| 268 | + private $entity_link_service; |
|
| 269 | + |
|
| 270 | + /** |
|
| 271 | + * A {@link Wordlift_Sparql_Service} instance. |
|
| 272 | + * |
|
| 273 | + * @since 3.6.0 |
|
| 274 | + * @access protected |
|
| 275 | + * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance. |
|
| 276 | + */ |
|
| 277 | + protected $sparql_service; |
|
| 278 | + |
|
| 279 | + /** |
|
| 280 | + * A {@link Wordlift_Import_Service} instance. |
|
| 281 | + * |
|
| 282 | + * @since 3.6.0 |
|
| 283 | + * @access private |
|
| 284 | + * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance. |
|
| 285 | + */ |
|
| 286 | + private $import_service; |
|
| 287 | + |
|
| 288 | + /** |
|
| 289 | + * A {@link Wordlift_Rebuild_Service} instance. |
|
| 290 | + * |
|
| 291 | + * @since 3.6.0 |
|
| 292 | + * @access private |
|
| 293 | + * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance. |
|
| 294 | + */ |
|
| 295 | + private $rebuild_service; |
|
| 296 | + |
|
| 297 | + /** |
|
| 298 | + * A {@link Wordlift_Jsonld_Service} instance. |
|
| 299 | + * |
|
| 300 | + * @since 3.7.0 |
|
| 301 | + * @access protected |
|
| 302 | + * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance. |
|
| 303 | + */ |
|
| 304 | + protected $jsonld_service; |
|
| 305 | + |
|
| 306 | + /** |
|
| 307 | + * A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 308 | + * |
|
| 309 | + * @since 3.14.0 |
|
| 310 | + * @access protected |
|
| 311 | + * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 312 | + */ |
|
| 313 | + protected $jsonld_website_converter; |
|
| 314 | + |
|
| 315 | + /** |
|
| 316 | + * A {@link Wordlift_Property_Factory} instance. |
|
| 317 | + * |
|
| 318 | + * @since 3.7.0 |
|
| 319 | + * @access private |
|
| 320 | + * @var \Wordlift_Property_Factory $property_factory |
|
| 321 | + */ |
|
| 322 | + private $property_factory; |
|
| 323 | + |
|
| 324 | + /** |
|
| 325 | + * The 'Download Your Data' page. |
|
| 326 | + * |
|
| 327 | + * @since 3.6.0 |
|
| 328 | + * @access private |
|
| 329 | + * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page. |
|
| 330 | + */ |
|
| 331 | + private $download_your_data_page; |
|
| 332 | + |
|
| 333 | + /** |
|
| 334 | + * The 'WordLift Settings' page. |
|
| 335 | + * |
|
| 336 | + * @since 3.11.0 |
|
| 337 | + * @access protected |
|
| 338 | + * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page. |
|
| 339 | + */ |
|
| 340 | + protected $settings_page; |
|
| 341 | + |
|
| 342 | + /** |
|
| 343 | + * The install wizard page. |
|
| 344 | + * |
|
| 345 | + * @since 3.9.0 |
|
| 346 | + * @access private |
|
| 347 | + * @var \Wordlift_Admin_Setup $admin_setup The Install wizard. |
|
| 348 | + */ |
|
| 349 | + public $admin_setup; |
|
| 350 | + |
|
| 351 | + /** |
|
| 352 | + * The Content Filter Service hooks up to the 'the_content' filter and provides |
|
| 353 | + * linking of entities to their pages. |
|
| 354 | + * |
|
| 355 | + * @since 3.8.0 |
|
| 356 | + * @access private |
|
| 357 | + * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance. |
|
| 358 | + */ |
|
| 359 | + private $content_filter_service; |
|
| 360 | + |
|
| 361 | + /** |
|
| 362 | + * The Faq Content filter service |
|
| 363 | + * @since 3.26.0 |
|
| 364 | + * @access private |
|
| 365 | + * @var Faq_Content_Filter $faq_content_filter_service A {@link Faq_Content_Filter} instance. |
|
| 366 | + */ |
|
| 367 | + private $faq_content_filter_service; |
|
| 368 | + |
|
| 369 | + /** |
|
| 370 | + * A {@link Wordlift_Key_Validation_Service} instance. |
|
| 371 | + * |
|
| 372 | + * @since 3.9.0 |
|
| 373 | + * @access private |
|
| 374 | + * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 375 | + */ |
|
| 376 | + private $key_validation_service; |
|
| 377 | + |
|
| 378 | + /** |
|
| 379 | + * A {@link Wordlift_Rating_Service} instance. |
|
| 380 | + * |
|
| 381 | + * @since 3.10.0 |
|
| 382 | + * @access private |
|
| 383 | + * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance. |
|
| 384 | + */ |
|
| 385 | + private $rating_service; |
|
| 386 | + |
|
| 387 | + /** |
|
| 388 | + * A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 389 | + * |
|
| 390 | + * @since 3.10.0 |
|
| 391 | + * @access protected |
|
| 392 | + * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 393 | + */ |
|
| 394 | + protected $post_to_jsonld_converter; |
|
| 395 | + |
|
| 396 | + /** |
|
| 397 | + * A {@link Wordlift_Configuration_Service} instance. |
|
| 398 | + * |
|
| 399 | + * @since 3.10.0 |
|
| 400 | + * @access protected |
|
| 401 | + * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 402 | + */ |
|
| 403 | + protected $configuration_service; |
|
| 404 | + |
|
| 405 | + /** |
|
| 406 | + * A {@link Wordlift_Install_Service} instance. |
|
| 407 | + * |
|
| 408 | + * @since 3.18.0 |
|
| 409 | + * @access protected |
|
| 410 | + * @var \Wordlift_Install_Service $install_service A {@link Wordlift_Install_Service} instance. |
|
| 411 | + */ |
|
| 412 | + protected $install_service; |
|
| 413 | + |
|
| 414 | + /** |
|
| 415 | + * A {@link Wordlift_Entity_Type_Service} instance. |
|
| 416 | + * |
|
| 417 | + * @since 3.10.0 |
|
| 418 | + * @access protected |
|
| 419 | + * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 420 | + */ |
|
| 421 | + protected $entity_type_service; |
|
| 422 | + |
|
| 423 | + /** |
|
| 424 | + * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 425 | + * |
|
| 426 | + * @since 3.10.0 |
|
| 427 | + * @access protected |
|
| 428 | + * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 429 | + */ |
|
| 430 | + protected $entity_post_to_jsonld_converter; |
|
| 431 | + |
|
| 432 | + /** |
|
| 433 | + * A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 434 | + * |
|
| 435 | + * @since 3.10.0 |
|
| 436 | + * @access protected |
|
| 437 | + * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 438 | + */ |
|
| 439 | + protected $postid_to_jsonld_converter; |
|
| 440 | + |
|
| 441 | + /** |
|
| 442 | + * The {@link Wordlift_Admin_Status_Page} class. |
|
| 443 | + * |
|
| 444 | + * @since 3.9.8 |
|
| 445 | + * @access private |
|
| 446 | + * @var \Wordlift_Admin_Status_Page $status_page The {@link Wordlift_Admin_Status_Page} class. |
|
| 447 | + */ |
|
| 448 | + private $status_page; |
|
| 449 | + |
|
| 450 | + /** |
|
| 451 | + * The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 452 | + * |
|
| 453 | + * @since 3.11.0 |
|
| 454 | + * @access protected |
|
| 455 | + * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 456 | + */ |
|
| 457 | + protected $category_taxonomy_service; |
|
| 458 | + |
|
| 459 | + /** |
|
| 460 | + * The {@link Wordlift_Entity_Page_Service} instance. |
|
| 461 | + * |
|
| 462 | + * @since 3.11.0 |
|
| 463 | + * @access protected |
|
| 464 | + * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance. |
|
| 465 | + */ |
|
| 466 | + protected $entity_page_service; |
|
| 467 | + |
|
| 468 | + /** |
|
| 469 | + * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 470 | + * |
|
| 471 | + * @since 3.11.0 |
|
| 472 | + * @access protected |
|
| 473 | + * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 474 | + */ |
|
| 475 | + protected $settings_page_action_link; |
|
| 476 | + |
|
| 477 | + /** |
|
| 478 | + * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 479 | + * |
|
| 480 | + * @since 3.11.0 |
|
| 481 | + * @access protected |
|
| 482 | + * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 483 | + */ |
|
| 484 | + protected $analytics_settings_page_action_link; |
|
| 485 | + |
|
| 486 | + /** |
|
| 487 | + * The {@link Wordlift_Analytics_Connect} class. |
|
| 488 | + * |
|
| 489 | + * @since 3.11.0 |
|
| 490 | + * @access protected |
|
| 491 | + * @var \Wordlift_Analytics_Connect $analytics_connect The {@link Wordlift_Analytics_Connect} class. |
|
| 492 | + */ |
|
| 493 | + protected $analytics_connect; |
|
| 494 | + |
|
| 495 | + /** |
|
| 496 | + * The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 497 | + * |
|
| 498 | + * @since 3.11.0 |
|
| 499 | + * @access protected |
|
| 500 | + * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 501 | + */ |
|
| 502 | + protected $publisher_ajax_adapter; |
|
| 503 | + |
|
| 504 | + /** |
|
| 505 | + * The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 506 | + * |
|
| 507 | + * @since 3.11.0 |
|
| 508 | + * @access protected |
|
| 509 | + * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 510 | + */ |
|
| 511 | + protected $input_element; |
|
| 512 | + |
|
| 513 | + /** |
|
| 514 | + * The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 515 | + * |
|
| 516 | + * @since 3.13.0 |
|
| 517 | + * @access protected |
|
| 518 | + * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 519 | + */ |
|
| 520 | + protected $radio_input_element; |
|
| 521 | + |
|
| 522 | + /** |
|
| 523 | + * The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 524 | + * |
|
| 525 | + * @since 3.11.0 |
|
| 526 | + * @access protected |
|
| 527 | + * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 528 | + */ |
|
| 529 | + protected $language_select_element; |
|
| 530 | + |
|
| 531 | + /** |
|
| 532 | + * The {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 533 | + * |
|
| 534 | + * @since 3.18.0 |
|
| 535 | + * @access protected |
|
| 536 | + * @var \Wordlift_Admin_Country_Select_Element $country_select_element The {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 537 | + */ |
|
| 538 | + protected $country_select_element; |
|
| 539 | + |
|
| 540 | + /** |
|
| 541 | + * The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 542 | + * |
|
| 543 | + * @since 3.11.0 |
|
| 544 | + * @access protected |
|
| 545 | + * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 546 | + */ |
|
| 547 | + protected $publisher_element; |
|
| 548 | + |
|
| 549 | + /** |
|
| 550 | + * The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 551 | + * |
|
| 552 | + * @since 3.11.0 |
|
| 553 | + * @access protected |
|
| 554 | + * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 555 | + */ |
|
| 556 | + protected $select2_element; |
|
| 557 | + |
|
| 558 | + /** |
|
| 559 | + * The controller for the entity type list admin page |
|
| 560 | + * |
|
| 561 | + * @since 3.11.0 |
|
| 562 | + * @access private |
|
| 563 | + * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class. |
|
| 564 | + */ |
|
| 565 | + private $entity_type_admin_page; |
|
| 566 | + |
|
| 567 | + /** |
|
| 568 | + * The controller for the entity type settings admin page |
|
| 569 | + * |
|
| 570 | + * @since 3.11.0 |
|
| 571 | + * @access private |
|
| 572 | + * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class. |
|
| 573 | + */ |
|
| 574 | + private $entity_type_settings_admin_page; |
|
| 575 | + |
|
| 576 | + /** |
|
| 577 | + * The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 578 | + * |
|
| 579 | + * @since 3.11.0 |
|
| 580 | + * @access protected |
|
| 581 | + * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 582 | + */ |
|
| 583 | + protected $related_entities_cloud_widget; |
|
| 584 | + |
|
| 585 | + /** |
|
| 586 | + * The {@link Wordlift_Admin_Author_Element} instance. |
|
| 587 | + * |
|
| 588 | + * @since 3.14.0 |
|
| 589 | + * @access protected |
|
| 590 | + * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance. |
|
| 591 | + */ |
|
| 592 | + protected $author_element; |
|
| 593 | + |
|
| 594 | + /** |
|
| 595 | + * The {@link Wordlift_Sample_Data_Service} instance. |
|
| 596 | + * |
|
| 597 | + * @since 3.12.0 |
|
| 598 | + * @access protected |
|
| 599 | + * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance. |
|
| 600 | + */ |
|
| 601 | + protected $sample_data_service; |
|
| 602 | + |
|
| 603 | + /** |
|
| 604 | + * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 605 | + * |
|
| 606 | + * @since 3.12.0 |
|
| 607 | + * @access protected |
|
| 608 | + * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 609 | + */ |
|
| 610 | + protected $sample_data_ajax_adapter; |
|
| 611 | + |
|
| 612 | + /** |
|
| 613 | + * The {@link Wordlift_Relation_Rebuild_Service} instance. |
|
| 614 | + * |
|
| 615 | + * @since 3.14.3 |
|
| 616 | + * @access private |
|
| 617 | + * @var \Wordlift_Relation_Rebuild_Service $relation_rebuild_service The {@link Wordlift_Relation_Rebuild_Service} instance. |
|
| 618 | + */ |
|
| 619 | + private $relation_rebuild_service; |
|
| 620 | + |
|
| 621 | + /** |
|
| 622 | + * The {@link Wordlift_Relation_Rebuild_Adapter} instance. |
|
| 623 | + * |
|
| 624 | + * @since 3.14.3 |
|
| 625 | + * @access private |
|
| 626 | + * @var \Wordlift_Relation_Rebuild_Adapter $relation_rebuild_adapter The {@link Wordlift_Relation_Rebuild_Adapter} instance. |
|
| 627 | + */ |
|
| 628 | + private $relation_rebuild_adapter; |
|
| 629 | + |
|
| 630 | + /** |
|
| 631 | + * The {@link Wordlift_Reference_Rebuild_Service} instance. |
|
| 632 | + * |
|
| 633 | + * @since 3.18.0 |
|
| 634 | + * @access private |
|
| 635 | + * @var \Wordlift_Reference_Rebuild_Service $reference_rebuild_service The {@link Wordlift_Reference_Rebuild_Service} instance. |
|
| 636 | + */ |
|
| 637 | + private $reference_rebuild_service; |
|
| 638 | + |
|
| 639 | + /** |
|
| 640 | + * The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 641 | + * |
|
| 642 | + * @since 3.16.0 |
|
| 643 | + * @access protected |
|
| 644 | + * @var \Wordlift_Google_Analytics_Export_Service $google_analytics_export_service The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 645 | + */ |
|
| 646 | + protected $google_analytics_export_service; |
|
| 647 | + |
|
| 648 | + /** |
|
| 649 | + * {@link Wordlift}'s singleton instance. |
|
| 650 | + * |
|
| 651 | + * @since 3.15.0 |
|
| 652 | + * @access protected |
|
| 653 | + * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance. |
|
| 654 | + */ |
|
| 655 | + protected $entity_type_adapter; |
|
| 656 | + |
|
| 657 | + /** |
|
| 658 | + * The {@link Wordlift_Storage_Factory} instance. |
|
| 659 | + * |
|
| 660 | + * @since 3.15.0 |
|
| 661 | + * @access protected |
|
| 662 | + * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance. |
|
| 663 | + */ |
|
| 664 | + protected $storage_factory; |
|
| 665 | + |
|
| 666 | + /** |
|
| 667 | + * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 668 | + * |
|
| 669 | + * @since 3.15.0 |
|
| 670 | + * @access protected |
|
| 671 | + * @var \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 672 | + */ |
|
| 673 | + protected $rendition_factory; |
|
| 674 | + |
|
| 675 | + /** |
|
| 676 | + * The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 677 | + * |
|
| 678 | + * @since 3.15.0 |
|
| 679 | + * @access private |
|
| 680 | + * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 681 | + */ |
|
| 682 | + private $autocomplete_adapter; |
|
| 683 | + |
|
| 684 | + /** |
|
| 685 | + * The {@link Wordlift_Relation_Service} instance. |
|
| 686 | + * |
|
| 687 | + * @since 3.15.0 |
|
| 688 | + * @access protected |
|
| 689 | + * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance. |
|
| 690 | + */ |
|
| 691 | + protected $relation_service; |
|
| 692 | + |
|
| 693 | + /** |
|
| 694 | + * The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 695 | + * |
|
| 696 | + * @since 3.16.0 |
|
| 697 | + * @access protected |
|
| 698 | + * @var \Wordlift_Cached_Post_Converter $cached_postid_to_jsonld_converter The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 699 | + * |
|
| 700 | + */ |
|
| 701 | + protected $cached_postid_to_jsonld_converter; |
|
| 702 | + |
|
| 703 | + /** |
|
| 704 | + * The {@link Wordlift_Entity_Uri_Service} instance. |
|
| 705 | + * |
|
| 706 | + * @since 3.16.3 |
|
| 707 | + * @access protected |
|
| 708 | + * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance. |
|
| 709 | + */ |
|
| 710 | + protected $entity_uri_service; |
|
| 711 | + |
|
| 712 | + /** |
|
| 713 | + * The {@link Wordlift_Publisher_Service} instance. |
|
| 714 | + * |
|
| 715 | + * @since 3.19.0 |
|
| 716 | + * @access protected |
|
| 717 | + * @var \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance. |
|
| 718 | + */ |
|
| 719 | + protected $publisher_service; |
|
| 720 | + |
|
| 721 | + /** |
|
| 722 | + * The {@link Wordlift_Context_Cards_Service} instance. |
|
| 723 | + * |
|
| 724 | + * @var \Wordlift_Context_Cards_Service The {@link Wordlift_Context_Cards_Service} instance. |
|
| 725 | + */ |
|
| 726 | + protected $context_cards_service; |
|
| 727 | + |
|
| 728 | + /** |
|
| 729 | + * {@link Wordlift}'s singleton instance. |
|
| 730 | + * |
|
| 731 | + * @since 3.11.2 |
|
| 732 | + * @access private |
|
| 733 | + * @var Wordlift $instance {@link Wordlift}'s singleton instance. |
|
| 734 | + */ |
|
| 735 | + private static $instance; |
|
| 736 | + |
|
| 737 | + //</editor-fold> |
|
| 738 | + |
|
| 739 | + /** |
|
| 740 | + * Define the core functionality of the plugin. |
|
| 741 | + * |
|
| 742 | + * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 743 | + * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 744 | + * the public-facing side of the site. |
|
| 745 | + * |
|
| 746 | + * @since 1.0.0 |
|
| 747 | + */ |
|
| 748 | + public function __construct() { |
|
| 749 | + |
|
| 750 | + self::$instance = $this; |
|
| 751 | + |
|
| 752 | + $this->plugin_name = 'wordlift'; |
|
| 753 | + $this->version = '3.27.7.1'; |
|
| 754 | + $this->load_dependencies(); |
|
| 755 | + $this->set_locale(); |
|
| 756 | + $this->define_admin_hooks(); |
|
| 757 | + $this->define_public_hooks(); |
|
| 758 | + |
|
| 759 | + // If we're in `WP_CLI` load the related files. |
|
| 760 | + if ( class_exists( 'WP_CLI' ) ) { |
|
| 761 | + $this->load_cli_dependencies(); |
|
| 762 | + } |
|
| 763 | + |
|
| 764 | + } |
|
| 765 | + |
|
| 766 | + /** |
|
| 767 | + * Get the singleton instance. |
|
| 768 | + * |
|
| 769 | + * @return Wordlift The {@link Wordlift} singleton instance. |
|
| 770 | + * @since 3.11.2 |
|
| 771 | + * |
|
| 772 | + */ |
|
| 773 | + public static function get_instance() { |
|
| 774 | + |
|
| 775 | + return self::$instance; |
|
| 776 | + } |
|
| 777 | + |
|
| 778 | + /** |
|
| 779 | + * Load the required dependencies for this plugin. |
|
| 780 | + * |
|
| 781 | + * Include the following files that make up the plugin: |
|
| 782 | + * |
|
| 783 | + * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 784 | + * - Wordlift_i18n. Defines internationalization functionality. |
|
| 785 | + * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 786 | + * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 787 | + * |
|
| 788 | + * Create an instance of the loader which will be used to register the hooks |
|
| 789 | + * with WordPress. |
|
| 790 | + * |
|
| 791 | + * @throws Exception |
|
| 792 | + * @since 1.0.0 |
|
| 793 | + * @access private |
|
| 794 | + */ |
|
| 795 | + private function load_dependencies() { |
|
| 796 | + |
|
| 797 | + /** |
|
| 798 | + * The class responsible for orchestrating the actions and filters of the |
|
| 799 | + * core plugin. |
|
| 800 | + */ |
|
| 801 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 802 | + |
|
| 803 | + // The class responsible for plugin uninstall. |
|
| 804 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-deactivator-feedback.php'; |
|
| 805 | + |
|
| 806 | + /** |
|
| 807 | + * The class responsible for defining internationalization functionality |
|
| 808 | + * of the plugin. |
|
| 809 | + */ |
|
| 810 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 811 | + |
|
| 812 | + /** |
|
| 813 | + * WordLift's supported languages. |
|
| 814 | + */ |
|
| 815 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php'; |
|
| 816 | + |
|
| 817 | + /** |
|
| 818 | + * WordLift's supported countries. |
|
| 819 | + */ |
|
| 820 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-countries.php'; |
|
| 821 | + |
|
| 822 | + /** |
|
| 823 | + * Provide support functions to sanitize data. |
|
| 824 | + */ |
|
| 825 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 826 | + |
|
| 827 | + /** Services. */ |
|
| 828 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 829 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php'; |
|
| 830 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 831 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 832 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 833 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 834 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 835 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php'; |
|
| 836 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php'; |
|
| 837 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-image-service.php'; |
|
| 838 | + |
|
| 839 | + /** |
|
| 840 | + * The Query builder. |
|
| 841 | + */ |
|
| 842 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 843 | + |
|
| 844 | + /** |
|
| 845 | + * The Schema service. |
|
| 846 | + */ |
|
| 847 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 848 | + |
|
| 849 | + /** |
|
| 850 | + * The schema:url property service. |
|
| 851 | + */ |
|
| 852 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 853 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 854 | + |
|
| 855 | + /** |
|
| 856 | + * The UI service. |
|
| 857 | + */ |
|
| 858 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 859 | + |
|
| 860 | + /** |
|
| 861 | + * The Thumbnail service. |
|
| 862 | + */ |
|
| 863 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 864 | + |
|
| 865 | + /** |
|
| 866 | + * The Entity Types Taxonomy service. |
|
| 867 | + */ |
|
| 868 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-taxonomy-service.php'; |
|
| 869 | + |
|
| 870 | + /** |
|
| 871 | + * The Entity service. |
|
| 872 | + */ |
|
| 873 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php'; |
|
| 874 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 875 | + |
|
| 876 | + // Add the entity rating service. |
|
| 877 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php'; |
|
| 878 | + |
|
| 879 | + /** |
|
| 880 | + * The User service. |
|
| 881 | + */ |
|
| 882 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 883 | + |
|
| 884 | + /** |
|
| 885 | + * The Timeline service. |
|
| 886 | + */ |
|
| 887 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 888 | + |
|
| 889 | + /** |
|
| 890 | + * The Topic Taxonomy service. |
|
| 891 | + */ |
|
| 892 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 893 | + |
|
| 894 | + /** |
|
| 895 | + * The SPARQL service. |
|
| 896 | + */ |
|
| 897 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 898 | + |
|
| 899 | + /** |
|
| 900 | + * The WordLift import service. |
|
| 901 | + */ |
|
| 902 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 903 | + |
|
| 904 | + /** |
|
| 905 | + * The WordLift URI service. |
|
| 906 | + */ |
|
| 907 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 908 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 909 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php'; |
|
| 910 | + |
|
| 911 | + /** |
|
| 912 | + * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
|
| 913 | + */ |
|
| 914 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-listable.php'; |
|
| 915 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-rebuild-service.php'; |
|
| 916 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-reference-rebuild-service.php'; |
|
| 917 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-service.php'; |
|
| 918 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-adapter.php'; |
|
| 919 | + |
|
| 920 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 921 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php'; |
|
| 922 | + |
|
| 923 | + /** |
|
| 924 | + * Load the converters. |
|
| 925 | + */ |
|
| 926 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php'; |
|
| 927 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 928 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 929 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 930 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 931 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php'; |
|
| 932 | + |
|
| 933 | + /** |
|
| 934 | + * Load cache-related files. |
|
| 935 | + */ |
|
| 936 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php'; |
|
| 937 | + |
|
| 938 | + /** |
|
| 939 | + * Load the content filter. |
|
| 940 | + */ |
|
| 941 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 942 | + |
|
| 943 | + /* |
|
| 944 | 944 | * Load the excerpt helper. |
| 945 | 945 | */ |
| 946 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 947 | - |
|
| 948 | - /** |
|
| 949 | - * Load the JSON-LD service to publish entities using JSON-LD.s |
|
| 950 | - * |
|
| 951 | - * @since 3.8.0 |
|
| 952 | - */ |
|
| 953 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 954 | - |
|
| 955 | - // The Publisher Service and the AJAX adapter. |
|
| 956 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php'; |
|
| 957 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 958 | - |
|
| 959 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php'; |
|
| 960 | - |
|
| 961 | - /** |
|
| 962 | - * Load the WordLift key validation service. |
|
| 963 | - */ |
|
| 964 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php'; |
|
| 965 | - |
|
| 966 | - // Load the `Wordlift_Category_Taxonomy_Service` class definition. |
|
| 967 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 968 | - |
|
| 969 | - // Load the `Wordlift_Entity_Page_Service` class definition. |
|
| 970 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php'; |
|
| 971 | - |
|
| 972 | - /** Linked Data. */ |
|
| 973 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php'; |
|
| 974 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php'; |
|
| 975 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php'; |
|
| 976 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php'; |
|
| 977 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php'; |
|
| 978 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php'; |
|
| 979 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php'; |
|
| 980 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php'; |
|
| 981 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php'; |
|
| 982 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php'; |
|
| 983 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php'; |
|
| 984 | - |
|
| 985 | - /** Linked Data Rendition. */ |
|
| 986 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/intf-wordlift-sparql-tuple-rendition.php'; |
|
| 987 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-default-sparql-tuple-rendition.php'; |
|
| 988 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-address-sparql-tuple-rendition.php'; |
|
| 989 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php'; |
|
| 990 | - |
|
| 991 | - /** Services. */ |
|
| 992 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php'; |
|
| 993 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-api-service.php'; |
|
| 994 | - |
|
| 995 | - /** Adapters. */ |
|
| 996 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php'; |
|
| 997 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php'; |
|
| 998 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php'; |
|
| 999 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php'; |
|
| 1000 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-wprocket-adapter.php'; |
|
| 1001 | - |
|
| 1002 | - /** Async Tasks. */ |
|
| 1003 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-async-task.php'; |
|
| 1004 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php'; |
|
| 1005 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-push-references-async-task.php'; |
|
| 1006 | - |
|
| 1007 | - /** Autocomplete. */ |
|
| 1008 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php'; |
|
| 1009 | - |
|
| 1010 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-remote-image-service.php'; |
|
| 1011 | - |
|
| 1012 | - /** Analytics */ |
|
| 1013 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/analytics/class-wordlift-analytics-connect.php'; |
|
| 1014 | - |
|
| 1015 | - /** |
|
| 1016 | - * The class responsible for defining all actions that occur in the admin area. |
|
| 1017 | - */ |
|
| 1018 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 1019 | - |
|
| 1020 | - /** |
|
| 1021 | - * The class to customize the entity list admin page. |
|
| 1022 | - */ |
|
| 1023 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 1024 | - |
|
| 1025 | - /** |
|
| 1026 | - * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 1027 | - */ |
|
| 1028 | - global $wp_version; |
|
| 1029 | - if ( version_compare( $wp_version, '5.3', '<' ) ) { |
|
| 1030 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 1031 | - } else { |
|
| 1032 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker-5-3.php'; |
|
| 1033 | - } |
|
| 1034 | - |
|
| 1035 | - /** |
|
| 1036 | - * The Notice service. |
|
| 1037 | - */ |
|
| 1038 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 1039 | - |
|
| 1040 | - /** |
|
| 1041 | - * The PrimaShop adapter. |
|
| 1042 | - */ |
|
| 1043 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 1044 | - |
|
| 1045 | - /** |
|
| 1046 | - * The WordLift Dashboard service. |
|
| 1047 | - */ |
|
| 1048 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 1049 | - |
|
| 1050 | - /** |
|
| 1051 | - * The admin 'Install wizard' page. |
|
| 1052 | - */ |
|
| 1053 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php'; |
|
| 1054 | - |
|
| 1055 | - /** |
|
| 1056 | - * The WordLift entity type list admin page controller. |
|
| 1057 | - */ |
|
| 1058 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 1059 | - |
|
| 1060 | - /** |
|
| 1061 | - * The WordLift entity type settings admin page controller. |
|
| 1062 | - */ |
|
| 1063 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php'; |
|
| 1064 | - |
|
| 1065 | - /** |
|
| 1066 | - * The admin 'Download Your Data' page. |
|
| 1067 | - */ |
|
| 1068 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 1069 | - |
|
| 1070 | - /** |
|
| 1071 | - * The admin 'WordLift Settings' page. |
|
| 1072 | - */ |
|
| 1073 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/intf-wordlift-admin-element.php'; |
|
| 1074 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-element.php'; |
|
| 1075 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-radio-element.php'; |
|
| 1076 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select-element.php'; |
|
| 1077 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select2-element.php'; |
|
| 1078 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-language-select-element.php'; |
|
| 1079 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-country-select-element.php'; |
|
| 1080 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-tabs-element.php'; |
|
| 1081 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-author-element.php'; |
|
| 1082 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-publisher-element.php'; |
|
| 1083 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php'; |
|
| 1084 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php'; |
|
| 1085 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page.php'; |
|
| 1086 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 1087 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page-action-link.php'; |
|
| 1088 | - |
|
| 1089 | - /** Admin Pages */ |
|
| 1090 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php'; |
|
| 1091 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php'; |
|
| 1092 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-search-rankings-page.php'; |
|
| 1093 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php'; |
|
| 1094 | - |
|
| 1095 | - /** |
|
| 1096 | - * The class responsible for defining all actions that occur in the public-facing |
|
| 1097 | - * side of the site. |
|
| 1098 | - */ |
|
| 1099 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 1100 | - |
|
| 1101 | - /** |
|
| 1102 | - * The shortcode abstract class. |
|
| 1103 | - */ |
|
| 1104 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 1105 | - |
|
| 1106 | - /** |
|
| 1107 | - * The Timeline shortcode. |
|
| 1108 | - */ |
|
| 1109 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 1110 | - |
|
| 1111 | - /** |
|
| 1112 | - * The Navigator shortcode. |
|
| 1113 | - */ |
|
| 1114 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 1115 | - |
|
| 1116 | - /** |
|
| 1117 | - * The Products Navigator shortcode. |
|
| 1118 | - */ |
|
| 1119 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-products-navigator-shortcode.php'; |
|
| 1120 | - |
|
| 1121 | - /** |
|
| 1122 | - * The chord shortcode. |
|
| 1123 | - */ |
|
| 1124 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 1125 | - |
|
| 1126 | - /** |
|
| 1127 | - * The geomap shortcode. |
|
| 1128 | - */ |
|
| 1129 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 1130 | - |
|
| 1131 | - /** |
|
| 1132 | - * The entity cloud shortcode. |
|
| 1133 | - */ |
|
| 1134 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 1135 | - |
|
| 1136 | - /** |
|
| 1137 | - * The entity glossary shortcode. |
|
| 1138 | - */ |
|
| 1139 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php'; |
|
| 1140 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php'; |
|
| 1141 | - |
|
| 1142 | - /** |
|
| 1143 | - * Faceted Search shortcode. |
|
| 1144 | - */ |
|
| 1145 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-faceted-search-shortcode.php'; |
|
| 1146 | - |
|
| 1147 | - /** |
|
| 1148 | - * The ShareThis service. |
|
| 1149 | - */ |
|
| 1150 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 1151 | - |
|
| 1152 | - /** |
|
| 1153 | - * The SEO service. |
|
| 1154 | - */ |
|
| 1155 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php'; |
|
| 1156 | - |
|
| 1157 | - /** |
|
| 1158 | - * The AMP service. |
|
| 1159 | - */ |
|
| 1160 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php'; |
|
| 1161 | - |
|
| 1162 | - /** Widgets */ |
|
| 1163 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php'; |
|
| 1164 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 1165 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-context-cards.php'; |
|
| 1166 | - |
|
| 1167 | - /* |
|
| 946 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 947 | + |
|
| 948 | + /** |
|
| 949 | + * Load the JSON-LD service to publish entities using JSON-LD.s |
|
| 950 | + * |
|
| 951 | + * @since 3.8.0 |
|
| 952 | + */ |
|
| 953 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 954 | + |
|
| 955 | + // The Publisher Service and the AJAX adapter. |
|
| 956 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php'; |
|
| 957 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 958 | + |
|
| 959 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php'; |
|
| 960 | + |
|
| 961 | + /** |
|
| 962 | + * Load the WordLift key validation service. |
|
| 963 | + */ |
|
| 964 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php'; |
|
| 965 | + |
|
| 966 | + // Load the `Wordlift_Category_Taxonomy_Service` class definition. |
|
| 967 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 968 | + |
|
| 969 | + // Load the `Wordlift_Entity_Page_Service` class definition. |
|
| 970 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php'; |
|
| 971 | + |
|
| 972 | + /** Linked Data. */ |
|
| 973 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php'; |
|
| 974 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php'; |
|
| 975 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php'; |
|
| 976 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php'; |
|
| 977 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php'; |
|
| 978 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php'; |
|
| 979 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php'; |
|
| 980 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php'; |
|
| 981 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php'; |
|
| 982 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php'; |
|
| 983 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php'; |
|
| 984 | + |
|
| 985 | + /** Linked Data Rendition. */ |
|
| 986 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/intf-wordlift-sparql-tuple-rendition.php'; |
|
| 987 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-default-sparql-tuple-rendition.php'; |
|
| 988 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-address-sparql-tuple-rendition.php'; |
|
| 989 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php'; |
|
| 990 | + |
|
| 991 | + /** Services. */ |
|
| 992 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php'; |
|
| 993 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-api-service.php'; |
|
| 994 | + |
|
| 995 | + /** Adapters. */ |
|
| 996 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php'; |
|
| 997 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php'; |
|
| 998 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php'; |
|
| 999 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php'; |
|
| 1000 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-wprocket-adapter.php'; |
|
| 1001 | + |
|
| 1002 | + /** Async Tasks. */ |
|
| 1003 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-async-task.php'; |
|
| 1004 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php'; |
|
| 1005 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-push-references-async-task.php'; |
|
| 1006 | + |
|
| 1007 | + /** Autocomplete. */ |
|
| 1008 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php'; |
|
| 1009 | + |
|
| 1010 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-remote-image-service.php'; |
|
| 1011 | + |
|
| 1012 | + /** Analytics */ |
|
| 1013 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/analytics/class-wordlift-analytics-connect.php'; |
|
| 1014 | + |
|
| 1015 | + /** |
|
| 1016 | + * The class responsible for defining all actions that occur in the admin area. |
|
| 1017 | + */ |
|
| 1018 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 1019 | + |
|
| 1020 | + /** |
|
| 1021 | + * The class to customize the entity list admin page. |
|
| 1022 | + */ |
|
| 1023 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 1024 | + |
|
| 1025 | + /** |
|
| 1026 | + * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 1027 | + */ |
|
| 1028 | + global $wp_version; |
|
| 1029 | + if ( version_compare( $wp_version, '5.3', '<' ) ) { |
|
| 1030 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 1031 | + } else { |
|
| 1032 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker-5-3.php'; |
|
| 1033 | + } |
|
| 1034 | + |
|
| 1035 | + /** |
|
| 1036 | + * The Notice service. |
|
| 1037 | + */ |
|
| 1038 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 1039 | + |
|
| 1040 | + /** |
|
| 1041 | + * The PrimaShop adapter. |
|
| 1042 | + */ |
|
| 1043 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 1044 | + |
|
| 1045 | + /** |
|
| 1046 | + * The WordLift Dashboard service. |
|
| 1047 | + */ |
|
| 1048 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 1049 | + |
|
| 1050 | + /** |
|
| 1051 | + * The admin 'Install wizard' page. |
|
| 1052 | + */ |
|
| 1053 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php'; |
|
| 1054 | + |
|
| 1055 | + /** |
|
| 1056 | + * The WordLift entity type list admin page controller. |
|
| 1057 | + */ |
|
| 1058 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 1059 | + |
|
| 1060 | + /** |
|
| 1061 | + * The WordLift entity type settings admin page controller. |
|
| 1062 | + */ |
|
| 1063 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php'; |
|
| 1064 | + |
|
| 1065 | + /** |
|
| 1066 | + * The admin 'Download Your Data' page. |
|
| 1067 | + */ |
|
| 1068 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 1069 | + |
|
| 1070 | + /** |
|
| 1071 | + * The admin 'WordLift Settings' page. |
|
| 1072 | + */ |
|
| 1073 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/intf-wordlift-admin-element.php'; |
|
| 1074 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-element.php'; |
|
| 1075 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-radio-element.php'; |
|
| 1076 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select-element.php'; |
|
| 1077 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select2-element.php'; |
|
| 1078 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-language-select-element.php'; |
|
| 1079 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-country-select-element.php'; |
|
| 1080 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-tabs-element.php'; |
|
| 1081 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-author-element.php'; |
|
| 1082 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-publisher-element.php'; |
|
| 1083 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php'; |
|
| 1084 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php'; |
|
| 1085 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page.php'; |
|
| 1086 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 1087 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page-action-link.php'; |
|
| 1088 | + |
|
| 1089 | + /** Admin Pages */ |
|
| 1090 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php'; |
|
| 1091 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php'; |
|
| 1092 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-search-rankings-page.php'; |
|
| 1093 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php'; |
|
| 1094 | + |
|
| 1095 | + /** |
|
| 1096 | + * The class responsible for defining all actions that occur in the public-facing |
|
| 1097 | + * side of the site. |
|
| 1098 | + */ |
|
| 1099 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 1100 | + |
|
| 1101 | + /** |
|
| 1102 | + * The shortcode abstract class. |
|
| 1103 | + */ |
|
| 1104 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 1105 | + |
|
| 1106 | + /** |
|
| 1107 | + * The Timeline shortcode. |
|
| 1108 | + */ |
|
| 1109 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 1110 | + |
|
| 1111 | + /** |
|
| 1112 | + * The Navigator shortcode. |
|
| 1113 | + */ |
|
| 1114 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 1115 | + |
|
| 1116 | + /** |
|
| 1117 | + * The Products Navigator shortcode. |
|
| 1118 | + */ |
|
| 1119 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-products-navigator-shortcode.php'; |
|
| 1120 | + |
|
| 1121 | + /** |
|
| 1122 | + * The chord shortcode. |
|
| 1123 | + */ |
|
| 1124 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 1125 | + |
|
| 1126 | + /** |
|
| 1127 | + * The geomap shortcode. |
|
| 1128 | + */ |
|
| 1129 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 1130 | + |
|
| 1131 | + /** |
|
| 1132 | + * The entity cloud shortcode. |
|
| 1133 | + */ |
|
| 1134 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 1135 | + |
|
| 1136 | + /** |
|
| 1137 | + * The entity glossary shortcode. |
|
| 1138 | + */ |
|
| 1139 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php'; |
|
| 1140 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php'; |
|
| 1141 | + |
|
| 1142 | + /** |
|
| 1143 | + * Faceted Search shortcode. |
|
| 1144 | + */ |
|
| 1145 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-faceted-search-shortcode.php'; |
|
| 1146 | + |
|
| 1147 | + /** |
|
| 1148 | + * The ShareThis service. |
|
| 1149 | + */ |
|
| 1150 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 1151 | + |
|
| 1152 | + /** |
|
| 1153 | + * The SEO service. |
|
| 1154 | + */ |
|
| 1155 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php'; |
|
| 1156 | + |
|
| 1157 | + /** |
|
| 1158 | + * The AMP service. |
|
| 1159 | + */ |
|
| 1160 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php'; |
|
| 1161 | + |
|
| 1162 | + /** Widgets */ |
|
| 1163 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php'; |
|
| 1164 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 1165 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-context-cards.php'; |
|
| 1166 | + |
|
| 1167 | + /* |
|
| 1168 | 1168 | * Schema.org Services. |
| 1169 | 1169 | * |
| 1170 | 1170 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
| 1171 | 1171 | */ |
| 1172 | - if ( WL_ALL_ENTITY_TYPES ) { |
|
| 1173 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-sync-service.php'; |
|
| 1174 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-property-service.php'; |
|
| 1175 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-class-service.php'; |
|
| 1176 | - new Wordlift_Schemaorg_Sync_Service(); |
|
| 1177 | - $schemaorg_property_service = new Wordlift_Schemaorg_Property_Service(); |
|
| 1178 | - new Wordlift_Schemaorg_Class_Service(); |
|
| 1179 | - } else { |
|
| 1180 | - $schemaorg_property_service = null; |
|
| 1181 | - } |
|
| 1172 | + if ( WL_ALL_ENTITY_TYPES ) { |
|
| 1173 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-sync-service.php'; |
|
| 1174 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-property-service.php'; |
|
| 1175 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-class-service.php'; |
|
| 1176 | + new Wordlift_Schemaorg_Sync_Service(); |
|
| 1177 | + $schemaorg_property_service = new Wordlift_Schemaorg_Property_Service(); |
|
| 1178 | + new Wordlift_Schemaorg_Class_Service(); |
|
| 1179 | + } else { |
|
| 1180 | + $schemaorg_property_service = null; |
|
| 1181 | + } |
|
| 1182 | 1182 | |
| 1183 | - $this->loader = new Wordlift_Loader(); |
|
| 1183 | + $this->loader = new Wordlift_Loader(); |
|
| 1184 | 1184 | |
| 1185 | - // Instantiate a global logger. |
|
| 1186 | - global $wl_logger; |
|
| 1187 | - $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 1185 | + // Instantiate a global logger. |
|
| 1186 | + global $wl_logger; |
|
| 1187 | + $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 1188 | 1188 | |
| 1189 | - // Load the `wl-api` end-point. |
|
| 1190 | - new Wordlift_Http_Api(); |
|
| 1189 | + // Load the `wl-api` end-point. |
|
| 1190 | + new Wordlift_Http_Api(); |
|
| 1191 | 1191 | |
| 1192 | - // Load the Install Service. |
|
| 1193 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-service.php'; |
|
| 1194 | - $this->install_service = new Wordlift_Install_Service(); |
|
| 1192 | + // Load the Install Service. |
|
| 1193 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-service.php'; |
|
| 1194 | + $this->install_service = new Wordlift_Install_Service(); |
|
| 1195 | 1195 | |
| 1196 | - /** Services. */ |
|
| 1197 | - // Create the configuration service. |
|
| 1198 | - $this->configuration_service = new Wordlift_Configuration_Service(); |
|
| 1199 | - $api_service = new Wordlift_Api_Service( $this->configuration_service ); |
|
| 1196 | + /** Services. */ |
|
| 1197 | + // Create the configuration service. |
|
| 1198 | + $this->configuration_service = new Wordlift_Configuration_Service(); |
|
| 1199 | + $api_service = new Wordlift_Api_Service( $this->configuration_service ); |
|
| 1200 | 1200 | |
| 1201 | - // Create an entity type service instance. It'll be later bound to the init action. |
|
| 1202 | - $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() ); |
|
| 1201 | + // Create an entity type service instance. It'll be later bound to the init action. |
|
| 1202 | + $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() ); |
|
| 1203 | 1203 | |
| 1204 | - // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 1205 | - $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() ); |
|
| 1204 | + // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 1205 | + $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() ); |
|
| 1206 | 1206 | |
| 1207 | - // Create an instance of the UI service. |
|
| 1208 | - $this->ui_service = new Wordlift_UI_Service(); |
|
| 1207 | + // Create an instance of the UI service. |
|
| 1208 | + $this->ui_service = new Wordlift_UI_Service(); |
|
| 1209 | 1209 | |
| 1210 | - // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 1211 | - $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 1210 | + // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 1211 | + $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 1212 | 1212 | |
| 1213 | - $this->sparql_service = new Wordlift_Sparql_Service(); |
|
| 1214 | - $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 1215 | - $this->notice_service = new Wordlift_Notice_Service(); |
|
| 1216 | - $this->relation_service = new Wordlift_Relation_Service(); |
|
| 1213 | + $this->sparql_service = new Wordlift_Sparql_Service(); |
|
| 1214 | + $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 1215 | + $this->notice_service = new Wordlift_Notice_Service(); |
|
| 1216 | + $this->relation_service = new Wordlift_Relation_Service(); |
|
| 1217 | 1217 | |
| 1218 | - $entity_uri_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'entity_uri/' ); |
|
| 1219 | - $this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service( $this->configuration_service, $entity_uri_cache_service ); |
|
| 1220 | - $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service, $this->entity_uri_service ); |
|
| 1221 | - $this->user_service = new Wordlift_User_Service( $this->sparql_service, $this->entity_service ); |
|
| 1218 | + $entity_uri_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'entity_uri/' ); |
|
| 1219 | + $this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service( $this->configuration_service, $entity_uri_cache_service ); |
|
| 1220 | + $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service, $this->entity_uri_service ); |
|
| 1221 | + $this->user_service = new Wordlift_User_Service( $this->sparql_service, $this->entity_service ); |
|
| 1222 | 1222 | |
| 1223 | - // Instantiate the JSON-LD service. |
|
| 1224 | - $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 1223 | + // Instantiate the JSON-LD service. |
|
| 1224 | + $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 1225 | 1225 | |
| 1226 | - /** Linked Data. */ |
|
| 1227 | - $this->storage_factory = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter ); |
|
| 1228 | - $this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service ); |
|
| 1226 | + /** Linked Data. */ |
|
| 1227 | + $this->storage_factory = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter ); |
|
| 1228 | + $this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service ); |
|
| 1229 | 1229 | |
| 1230 | - $this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service ); |
|
| 1230 | + $this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service ); |
|
| 1231 | 1231 | |
| 1232 | - // Create a new instance of the Redirect service. |
|
| 1233 | - $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_uri_service ); |
|
| 1234 | - $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service ); |
|
| 1232 | + // Create a new instance of the Redirect service. |
|
| 1233 | + $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_uri_service ); |
|
| 1234 | + $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service ); |
|
| 1235 | 1235 | |
| 1236 | - if ( apply_filters( 'wl_feature__enable__dataset-ng', false ) ) { |
|
| 1237 | - new Wordlift_Linked_Data_Service( $this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service ); |
|
| 1238 | - } |
|
| 1236 | + if ( apply_filters( 'wl_feature__enable__dataset-ng', false ) ) { |
|
| 1237 | + new Wordlift_Linked_Data_Service( $this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service ); |
|
| 1238 | + } |
|
| 1239 | 1239 | |
| 1240 | - // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 1241 | - $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service ); |
|
| 1240 | + // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 1241 | + $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service ); |
|
| 1242 | 1242 | |
| 1243 | - $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 1243 | + $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 1244 | 1244 | |
| 1245 | - $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 1246 | - $this->entity_types_taxonomy_service = new Wordlift_Entity_Type_Taxonomy_Service(); |
|
| 1245 | + $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 1246 | + $this->entity_types_taxonomy_service = new Wordlift_Entity_Type_Taxonomy_Service(); |
|
| 1247 | 1247 | |
| 1248 | - // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 1249 | - $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 1248 | + // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 1249 | + $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 1250 | 1250 | |
| 1251 | - // Create an instance of the PrimaShop adapter. |
|
| 1252 | - $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 1251 | + // Create an instance of the PrimaShop adapter. |
|
| 1252 | + $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 1253 | 1253 | |
| 1254 | - // Create an import service instance to hook later to WP's import function. |
|
| 1255 | - $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() ); |
|
| 1254 | + // Create an import service instance to hook later to WP's import function. |
|
| 1255 | + $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() ); |
|
| 1256 | 1256 | |
| 1257 | - $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 1257 | + $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 1258 | 1258 | |
| 1259 | - // Create the entity rating service. |
|
| 1260 | - $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service ); |
|
| 1259 | + // Create the entity rating service. |
|
| 1260 | + $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service ); |
|
| 1261 | 1261 | |
| 1262 | - // Create entity list customization (wp-admin/edit.php). |
|
| 1263 | - $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service ); |
|
| 1262 | + // Create entity list customization (wp-admin/edit.php). |
|
| 1263 | + $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service ); |
|
| 1264 | 1264 | |
| 1265 | - // Create a new instance of the Redirect service. |
|
| 1266 | - $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service ); |
|
| 1265 | + // Create a new instance of the Redirect service. |
|
| 1266 | + $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service ); |
|
| 1267 | 1267 | |
| 1268 | - // Create an instance of the Publisher Service and the AJAX Adapter. |
|
| 1269 | - $this->publisher_service = new Wordlift_Publisher_Service( $this->configuration_service ); |
|
| 1270 | - $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 1271 | - $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 1268 | + // Create an instance of the Publisher Service and the AJAX Adapter. |
|
| 1269 | + $this->publisher_service = new Wordlift_Publisher_Service( $this->configuration_service ); |
|
| 1270 | + $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 1271 | + $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 1272 | 1272 | |
| 1273 | - $attachment_service = new Wordlift_Attachment_Service(); |
|
| 1273 | + $attachment_service = new Wordlift_Attachment_Service(); |
|
| 1274 | 1274 | |
| 1275 | - // Instantiate the JSON-LD service. |
|
| 1276 | - $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 1277 | - $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 ); |
|
| 1278 | - $this->entity_post_to_jsonld_converter = new Wordlift_Entity_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $property_getter, $schemaorg_property_service, $this->post_to_jsonld_converter ); |
|
| 1279 | - $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 ); |
|
| 1280 | - $this->jsonld_website_converter = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service ); |
|
| 1275 | + // Instantiate the JSON-LD service. |
|
| 1276 | + $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 1277 | + $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 ); |
|
| 1278 | + $this->entity_post_to_jsonld_converter = new Wordlift_Entity_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $property_getter, $schemaorg_property_service, $this->post_to_jsonld_converter ); |
|
| 1279 | + $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 ); |
|
| 1280 | + $this->jsonld_website_converter = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service ); |
|
| 1281 | 1281 | |
| 1282 | - $jsonld_cache = new Ttl_Cache( 'jsonld', 86400 ); |
|
| 1283 | - $this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $this->postid_to_jsonld_converter, $this->configuration_service, $jsonld_cache ); |
|
| 1284 | - $this->jsonld_service = new Wordlift_Jsonld_Service( $this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter ); |
|
| 1282 | + $jsonld_cache = new Ttl_Cache( 'jsonld', 86400 ); |
|
| 1283 | + $this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $this->postid_to_jsonld_converter, $this->configuration_service, $jsonld_cache ); |
|
| 1284 | + $this->jsonld_service = new Wordlift_Jsonld_Service( $this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter ); |
|
| 1285 | 1285 | |
| 1286 | - /* |
|
| 1286 | + /* |
|
| 1287 | 1287 | * Load the `Wordlift_Term_JsonLd_Adapter`. |
| 1288 | 1288 | * |
| 1289 | 1289 | * @see https://github.com/insideout10/wordlift-plugin/issues/892 |
| 1290 | 1290 | * |
| 1291 | 1291 | * @since 3.20.0 |
| 1292 | 1292 | */ |
| 1293 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-term-jsonld-adapter.php'; |
|
| 1294 | - $term_jsonld_adapter = new Wordlift_Term_JsonLd_Adapter( $this->entity_uri_service, $this->jsonld_service ); |
|
| 1295 | - $jsonld_service = new Jsonld_Service( |
|
| 1296 | - $this->jsonld_service, |
|
| 1297 | - $term_jsonld_adapter, |
|
| 1298 | - new Jsonld_User_Service( $this->user_service ) ); |
|
| 1299 | - new Jsonld_Endpoint( $jsonld_service, $this->entity_uri_service ); |
|
| 1300 | - |
|
| 1301 | - // Prints the JSON-LD in the head. |
|
| 1302 | - new Jsonld_Adapter( $this->jsonld_service ); |
|
| 1303 | - |
|
| 1304 | - new Jsonld_By_Id_Endpoint( $this->jsonld_service, $this->entity_uri_service ); |
|
| 1305 | - |
|
| 1306 | - $this->key_validation_service = new Wordlift_Key_Validation_Service( $this->configuration_service ); |
|
| 1307 | - $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service, $this->entity_uri_service ); |
|
| 1308 | - // Creating Faq Content filter service. |
|
| 1309 | - $this->faq_content_filter_service = new Faq_Content_Filter(); |
|
| 1310 | - $this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service ); |
|
| 1311 | - $this->sample_data_service = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service, $this->user_service ); |
|
| 1312 | - $this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service ); |
|
| 1313 | - $this->reference_rebuild_service = new Wordlift_Reference_Rebuild_Service( $this->entity_service ); |
|
| 1314 | - |
|
| 1315 | - $this->loader->add_action( 'enqueue_block_editor_assets', $this, 'add_wl_enabled_blocks' ); |
|
| 1316 | - |
|
| 1317 | - /** |
|
| 1318 | - * Filter: wl_feature__enable__blocks. |
|
| 1319 | - * |
|
| 1320 | - * @param bool whether the blocks needed to be registered, defaults to true. |
|
| 1321 | - * |
|
| 1322 | - * @return bool |
|
| 1323 | - * @since 3.27.6 |
|
| 1324 | - */ |
|
| 1325 | - if ( apply_filters( 'wl_feature__enable__blocks', true ) ) { |
|
| 1326 | - // Initialize the short-codes. |
|
| 1327 | - new Wordlift_Navigator_Shortcode(); |
|
| 1328 | - new Wordlift_Chord_Shortcode(); |
|
| 1329 | - new Wordlift_Geomap_Shortcode(); |
|
| 1330 | - new Wordlift_Timeline_Shortcode(); |
|
| 1331 | - new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service ); |
|
| 1332 | - new Wordlift_Vocabulary_Shortcode( $this->configuration_service ); |
|
| 1333 | - new Wordlift_Faceted_Search_Shortcode(); |
|
| 1334 | - /** |
|
| 1335 | - * @since ?.??.? |
|
| 1336 | - * Register a route to load faceted search template async. |
|
| 1337 | - */ |
|
| 1338 | - new Faceted_Search_Template_Endpoint(); |
|
| 1339 | - } |
|
| 1340 | - |
|
| 1341 | - new Wordlift_Products_Navigator_Shortcode(); |
|
| 1342 | - |
|
| 1343 | - |
|
| 1344 | - // Initialize the Context Cards Service |
|
| 1345 | - $this->context_cards_service = new Wordlift_Context_Cards_Service(); |
|
| 1346 | - |
|
| 1347 | - // Initialize the SEO service. |
|
| 1348 | - new Wordlift_Seo_Service(); |
|
| 1349 | - |
|
| 1350 | - // Initialize the AMP service. |
|
| 1351 | - new Wordlift_AMP_Service( $this->jsonld_service ); |
|
| 1352 | - |
|
| 1353 | - /** Services. */ |
|
| 1354 | - $this->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service(); |
|
| 1355 | - new Wordlift_Image_Service(); |
|
| 1356 | - |
|
| 1357 | - /** Adapters. */ |
|
| 1358 | - $this->entity_type_adapter = new Wordlift_Entity_Type_Adapter( $this->entity_type_service ); |
|
| 1359 | - $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $this->publisher_service ); |
|
| 1360 | - $this->tinymce_adapter = new Wordlift_Tinymce_Adapter( $this ); |
|
| 1361 | - //$this->faq_tinymce_adapter = new Faq_Tinymce_Adapter(); |
|
| 1362 | - $this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service ); |
|
| 1363 | - |
|
| 1364 | - /* |
|
| 1293 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-term-jsonld-adapter.php'; |
|
| 1294 | + $term_jsonld_adapter = new Wordlift_Term_JsonLd_Adapter( $this->entity_uri_service, $this->jsonld_service ); |
|
| 1295 | + $jsonld_service = new Jsonld_Service( |
|
| 1296 | + $this->jsonld_service, |
|
| 1297 | + $term_jsonld_adapter, |
|
| 1298 | + new Jsonld_User_Service( $this->user_service ) ); |
|
| 1299 | + new Jsonld_Endpoint( $jsonld_service, $this->entity_uri_service ); |
|
| 1300 | + |
|
| 1301 | + // Prints the JSON-LD in the head. |
|
| 1302 | + new Jsonld_Adapter( $this->jsonld_service ); |
|
| 1303 | + |
|
| 1304 | + new Jsonld_By_Id_Endpoint( $this->jsonld_service, $this->entity_uri_service ); |
|
| 1305 | + |
|
| 1306 | + $this->key_validation_service = new Wordlift_Key_Validation_Service( $this->configuration_service ); |
|
| 1307 | + $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service, $this->entity_uri_service ); |
|
| 1308 | + // Creating Faq Content filter service. |
|
| 1309 | + $this->faq_content_filter_service = new Faq_Content_Filter(); |
|
| 1310 | + $this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service ); |
|
| 1311 | + $this->sample_data_service = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service, $this->user_service ); |
|
| 1312 | + $this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service ); |
|
| 1313 | + $this->reference_rebuild_service = new Wordlift_Reference_Rebuild_Service( $this->entity_service ); |
|
| 1314 | + |
|
| 1315 | + $this->loader->add_action( 'enqueue_block_editor_assets', $this, 'add_wl_enabled_blocks' ); |
|
| 1316 | + |
|
| 1317 | + /** |
|
| 1318 | + * Filter: wl_feature__enable__blocks. |
|
| 1319 | + * |
|
| 1320 | + * @param bool whether the blocks needed to be registered, defaults to true. |
|
| 1321 | + * |
|
| 1322 | + * @return bool |
|
| 1323 | + * @since 3.27.6 |
|
| 1324 | + */ |
|
| 1325 | + if ( apply_filters( 'wl_feature__enable__blocks', true ) ) { |
|
| 1326 | + // Initialize the short-codes. |
|
| 1327 | + new Wordlift_Navigator_Shortcode(); |
|
| 1328 | + new Wordlift_Chord_Shortcode(); |
|
| 1329 | + new Wordlift_Geomap_Shortcode(); |
|
| 1330 | + new Wordlift_Timeline_Shortcode(); |
|
| 1331 | + new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service ); |
|
| 1332 | + new Wordlift_Vocabulary_Shortcode( $this->configuration_service ); |
|
| 1333 | + new Wordlift_Faceted_Search_Shortcode(); |
|
| 1334 | + /** |
|
| 1335 | + * @since ?.??.? |
|
| 1336 | + * Register a route to load faceted search template async. |
|
| 1337 | + */ |
|
| 1338 | + new Faceted_Search_Template_Endpoint(); |
|
| 1339 | + } |
|
| 1340 | + |
|
| 1341 | + new Wordlift_Products_Navigator_Shortcode(); |
|
| 1342 | + |
|
| 1343 | + |
|
| 1344 | + // Initialize the Context Cards Service |
|
| 1345 | + $this->context_cards_service = new Wordlift_Context_Cards_Service(); |
|
| 1346 | + |
|
| 1347 | + // Initialize the SEO service. |
|
| 1348 | + new Wordlift_Seo_Service(); |
|
| 1349 | + |
|
| 1350 | + // Initialize the AMP service. |
|
| 1351 | + new Wordlift_AMP_Service( $this->jsonld_service ); |
|
| 1352 | + |
|
| 1353 | + /** Services. */ |
|
| 1354 | + $this->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service(); |
|
| 1355 | + new Wordlift_Image_Service(); |
|
| 1356 | + |
|
| 1357 | + /** Adapters. */ |
|
| 1358 | + $this->entity_type_adapter = new Wordlift_Entity_Type_Adapter( $this->entity_type_service ); |
|
| 1359 | + $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $this->publisher_service ); |
|
| 1360 | + $this->tinymce_adapter = new Wordlift_Tinymce_Adapter( $this ); |
|
| 1361 | + //$this->faq_tinymce_adapter = new Faq_Tinymce_Adapter(); |
|
| 1362 | + $this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service ); |
|
| 1363 | + |
|
| 1364 | + /* |
|
| 1365 | 1365 | * Exclude our public js from WP-Rocket. |
| 1366 | 1366 | * |
| 1367 | 1367 | * @since 3.19.4 |
| 1368 | 1368 | * |
| 1369 | 1369 | * @see https://github.com/insideout10/wordlift-plugin/issues/842. |
| 1370 | 1370 | */ |
| 1371 | - new Wordlift_WpRocket_Adapter(); |
|
| 1372 | - |
|
| 1373 | - // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
|
| 1374 | - $this->rebuild_service = new Wordlift_Rebuild_Service( |
|
| 1375 | - $this->sparql_service, |
|
| 1376 | - $uri_service |
|
| 1377 | - ); |
|
| 1378 | - |
|
| 1379 | - /** Async Tasks. */ |
|
| 1380 | - if ( ! apply_filters( 'wl_feature__enable__dataset-ng', false ) ) { |
|
| 1381 | - new Wordlift_Sparql_Query_Async_Task(); |
|
| 1382 | - new Wordlift_Push_References_Async_Task(); |
|
| 1383 | - } |
|
| 1384 | - |
|
| 1385 | - /** WordPress Admin UI. */ |
|
| 1386 | - |
|
| 1387 | - // UI elements. |
|
| 1388 | - $this->input_element = new Wordlift_Admin_Input_Element(); |
|
| 1389 | - $this->radio_input_element = new Wordlift_Admin_Radio_Input_Element(); |
|
| 1390 | - $this->select2_element = new Wordlift_Admin_Select2_Element(); |
|
| 1391 | - $this->language_select_element = new Wordlift_Admin_Language_Select_Element(); |
|
| 1392 | - $this->country_select_element = new Wordlift_Admin_Country_Select_Element(); |
|
| 1393 | - $tabs_element = new Wordlift_Admin_Tabs_Element(); |
|
| 1394 | - $this->publisher_element = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $this->publisher_service, $tabs_element, $this->select2_element ); |
|
| 1395 | - $this->author_element = new Wordlift_Admin_Author_Element( $this->publisher_service, $this->select2_element ); |
|
| 1396 | - |
|
| 1397 | - $this->settings_page = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->country_select_element, $this->publisher_element, $this->radio_input_element ); |
|
| 1398 | - $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page ); |
|
| 1399 | - |
|
| 1400 | - $this->analytics_settings_page = new Wordlift_Admin_Settings_Analytics_Page( $this->configuration_service, $this->input_element, $this->radio_input_element ); |
|
| 1401 | - $this->analytics_settings_page_action_link = new Wordlift_Admin_Settings_Analytics_Page_Action_Link( $this->analytics_settings_page ); |
|
| 1402 | - $this->analytics_connect = new Wordlift_Analytics_Connect(); |
|
| 1403 | - |
|
| 1404 | - // Pages. |
|
| 1405 | - /* |
|
| 1371 | + new Wordlift_WpRocket_Adapter(); |
|
| 1372 | + |
|
| 1373 | + // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
|
| 1374 | + $this->rebuild_service = new Wordlift_Rebuild_Service( |
|
| 1375 | + $this->sparql_service, |
|
| 1376 | + $uri_service |
|
| 1377 | + ); |
|
| 1378 | + |
|
| 1379 | + /** Async Tasks. */ |
|
| 1380 | + if ( ! apply_filters( 'wl_feature__enable__dataset-ng', false ) ) { |
|
| 1381 | + new Wordlift_Sparql_Query_Async_Task(); |
|
| 1382 | + new Wordlift_Push_References_Async_Task(); |
|
| 1383 | + } |
|
| 1384 | + |
|
| 1385 | + /** WordPress Admin UI. */ |
|
| 1386 | + |
|
| 1387 | + // UI elements. |
|
| 1388 | + $this->input_element = new Wordlift_Admin_Input_Element(); |
|
| 1389 | + $this->radio_input_element = new Wordlift_Admin_Radio_Input_Element(); |
|
| 1390 | + $this->select2_element = new Wordlift_Admin_Select2_Element(); |
|
| 1391 | + $this->language_select_element = new Wordlift_Admin_Language_Select_Element(); |
|
| 1392 | + $this->country_select_element = new Wordlift_Admin_Country_Select_Element(); |
|
| 1393 | + $tabs_element = new Wordlift_Admin_Tabs_Element(); |
|
| 1394 | + $this->publisher_element = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $this->publisher_service, $tabs_element, $this->select2_element ); |
|
| 1395 | + $this->author_element = new Wordlift_Admin_Author_Element( $this->publisher_service, $this->select2_element ); |
|
| 1396 | + |
|
| 1397 | + $this->settings_page = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->country_select_element, $this->publisher_element, $this->radio_input_element ); |
|
| 1398 | + $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page ); |
|
| 1399 | + |
|
| 1400 | + $this->analytics_settings_page = new Wordlift_Admin_Settings_Analytics_Page( $this->configuration_service, $this->input_element, $this->radio_input_element ); |
|
| 1401 | + $this->analytics_settings_page_action_link = new Wordlift_Admin_Settings_Analytics_Page_Action_Link( $this->analytics_settings_page ); |
|
| 1402 | + $this->analytics_connect = new Wordlift_Analytics_Connect(); |
|
| 1403 | + |
|
| 1404 | + // Pages. |
|
| 1405 | + /* |
|
| 1406 | 1406 | * Call the `wl_can_see_classification_box` filter to determine whether we can display the classification box. |
| 1407 | 1407 | * |
| 1408 | 1408 | * @since 3.20.3 |
| 1409 | 1409 | * |
| 1410 | 1410 | * @see https://github.com/insideout10/wordlift-plugin/issues/914 |
| 1411 | 1411 | */ |
| 1412 | - if ( apply_filters( 'wl_can_see_classification_box', true ) ) { |
|
| 1413 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 1414 | - new Wordlift_Admin_Post_Edit_Page( $this ); |
|
| 1415 | - } |
|
| 1416 | - new Wordlift_Entity_Type_Admin_Service(); |
|
| 1412 | + if ( apply_filters( 'wl_can_see_classification_box', true ) ) { |
|
| 1413 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 1414 | + new Wordlift_Admin_Post_Edit_Page( $this ); |
|
| 1415 | + } |
|
| 1416 | + new Wordlift_Entity_Type_Admin_Service(); |
|
| 1417 | 1417 | |
| 1418 | - // create an instance of the entity type list admin page controller. |
|
| 1419 | - $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page(); |
|
| 1418 | + // create an instance of the entity type list admin page controller. |
|
| 1419 | + $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page(); |
|
| 1420 | 1420 | |
| 1421 | - // create an instance of the entity type setting admin page controller. |
|
| 1422 | - $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings(); |
|
| 1421 | + // create an instance of the entity type setting admin page controller. |
|
| 1422 | + $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings(); |
|
| 1423 | 1423 | |
| 1424 | - /** Widgets */ |
|
| 1425 | - $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget(); |
|
| 1424 | + /** Widgets */ |
|
| 1425 | + $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget(); |
|
| 1426 | 1426 | |
| 1427 | - /* WordPress Admin. */ |
|
| 1428 | - $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 1429 | - $this->status_page = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service ); |
|
| 1427 | + /* WordPress Admin. */ |
|
| 1428 | + $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 1429 | + $this->status_page = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service ); |
|
| 1430 | 1430 | |
| 1431 | - // Create an instance of the install wizard. |
|
| 1432 | - $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service, $this->language_select_element, $this->country_select_element ); |
|
| 1431 | + // Create an instance of the install wizard. |
|
| 1432 | + $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service, $this->language_select_element, $this->country_select_element ); |
|
| 1433 | 1433 | |
| 1434 | - $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service ); |
|
| 1434 | + $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service ); |
|
| 1435 | 1435 | |
| 1436 | - // User Profile. |
|
| 1437 | - new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service ); |
|
| 1436 | + // User Profile. |
|
| 1437 | + new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service ); |
|
| 1438 | 1438 | |
| 1439 | - $this->entity_page_service = new Wordlift_Entity_Page_Service(); |
|
| 1439 | + $this->entity_page_service = new Wordlift_Entity_Page_Service(); |
|
| 1440 | 1440 | |
| 1441 | - // Load the debug service if WP is in debug mode. |
|
| 1442 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 1443 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 1444 | - new Wordlift_Debug_Service( $this->entity_service, $uri_service ); |
|
| 1445 | - } |
|
| 1441 | + // Load the debug service if WP is in debug mode. |
|
| 1442 | + if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 1443 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 1444 | + new Wordlift_Debug_Service( $this->entity_service, $uri_service ); |
|
| 1445 | + } |
|
| 1446 | 1446 | |
| 1447 | - // Remote Image Service. |
|
| 1448 | - new Wordlift_Remote_Image_Service(); |
|
| 1447 | + // Remote Image Service. |
|
| 1448 | + new Wordlift_Remote_Image_Service(); |
|
| 1449 | 1449 | |
| 1450 | - /* |
|
| 1450 | + /* |
|
| 1451 | 1451 | * Provides mappings between post types and entity types. |
| 1452 | 1452 | * |
| 1453 | 1453 | * @since 3.20.0 |
| 1454 | 1454 | * |
| 1455 | 1455 | * @see https://github.com/insideout10/wordlift-plugin/issues/852. |
| 1456 | 1456 | */ |
| 1457 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-action.php'; |
|
| 1458 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-service.php'; |
|
| 1459 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-ajax-adapter.php'; |
|
| 1457 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-action.php'; |
|
| 1458 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-service.php'; |
|
| 1459 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-ajax-adapter.php'; |
|
| 1460 | 1460 | |
| 1461 | - // Create an instance of the Mapping Service and assign it to the Ajax Adapter. |
|
| 1462 | - new Wordlift_Mapping_Ajax_Adapter( new Wordlift_Mapping_Service( Wordlift_Entity_Type_Service::get_instance() ) ); |
|
| 1461 | + // Create an instance of the Mapping Service and assign it to the Ajax Adapter. |
|
| 1462 | + new Wordlift_Mapping_Ajax_Adapter( new Wordlift_Mapping_Service( Wordlift_Entity_Type_Service::get_instance() ) ); |
|
| 1463 | 1463 | |
| 1464 | - /* |
|
| 1464 | + /* |
|
| 1465 | 1465 | * Batch Operations. They're similar to Batch Actions but do not require working on post types. |
| 1466 | 1466 | * |
| 1467 | 1467 | * Eventually Batch Actions will become Batch Operations. |
| 1468 | 1468 | * |
| 1469 | 1469 | * @since 3.20.0 |
| 1470 | 1470 | */ |
| 1471 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/intf-wordlift-batch-operation.php'; |
|
| 1472 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/class-wordlift-batch-operation-ajax-adapter.php'; |
|
| 1471 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/intf-wordlift-batch-operation.php'; |
|
| 1472 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/class-wordlift-batch-operation-ajax-adapter.php'; |
|
| 1473 | 1473 | |
| 1474 | - /* |
|
| 1474 | + /* |
|
| 1475 | 1475 | * Add the Search Keywords taxonomy to manage the Search Keywords on WLS. |
| 1476 | 1476 | * |
| 1477 | 1477 | * @link https://github.com/insideout10/wordlift-plugin/issues/761 |
| 1478 | 1478 | * |
| 1479 | 1479 | * @since 3.20.0 |
| 1480 | 1480 | */ |
| 1481 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/search-keywords/class-wordlift-search-keyword-taxonomy.php'; |
|
| 1482 | - new Wordlift_Search_Keyword_Taxonomy( $api_service ); |
|
| 1481 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/search-keywords/class-wordlift-search-keyword-taxonomy.php'; |
|
| 1482 | + new Wordlift_Search_Keyword_Taxonomy( $api_service ); |
|
| 1483 | 1483 | |
| 1484 | - /* |
|
| 1484 | + /* |
|
| 1485 | 1485 | * Load the Mappings JSON-LD post processing. |
| 1486 | 1486 | * |
| 1487 | 1487 | * @since 3.25.0 |
| 1488 | 1488 | */ |
| 1489 | 1489 | |
| 1490 | - $mappings_dbo = new Mappings_DBO(); |
|
| 1491 | - $default_rule_validator = new Taxonomy_Rule_Validator(); |
|
| 1492 | - new Post_Type_Rule_Validator(); |
|
| 1493 | - // Taxonomy term rule validator for validating rules for term pages. |
|
| 1494 | - new Taxonomy_Term_Rule_Validator(); |
|
| 1495 | - $rule_validators_registry = new Rule_Validators_Registry( $default_rule_validator ); |
|
| 1496 | - $rule_groups_validator = new Rule_Groups_Validator( $rule_validators_registry ); |
|
| 1497 | - $mappings_validator = new Mappings_Validator( $mappings_dbo, $rule_groups_validator ); |
|
| 1498 | - |
|
| 1499 | - new Url_To_Entity_Transform_Function( $this->entity_uri_service ); |
|
| 1500 | - new Taxonomy_To_Terms_Transform_Function(); |
|
| 1501 | - new Post_Id_To_Entity_Transform_Function(); |
|
| 1502 | - $mappings_transform_functions_registry = new Mappings_Transform_Functions_Registry(); |
|
| 1503 | - |
|
| 1504 | - /** |
|
| 1505 | - * @since 3.27.1 |
|
| 1506 | - * Intiailize the acf group data formatter. |
|
| 1507 | - */ |
|
| 1508 | - new Acf_Group_Formatter(); |
|
| 1509 | - new Jsonld_Converter( $mappings_validator, $mappings_transform_functions_registry ); |
|
| 1510 | - |
|
| 1511 | - /** |
|
| 1512 | - * @since 3.26.0 |
|
| 1513 | - * Initialize the Faq JSON LD converter here - disabled. |
|
| 1514 | - */ |
|
| 1515 | - // new Faq_To_Jsonld_Converter(); |
|
| 1516 | - /* |
|
| 1490 | + $mappings_dbo = new Mappings_DBO(); |
|
| 1491 | + $default_rule_validator = new Taxonomy_Rule_Validator(); |
|
| 1492 | + new Post_Type_Rule_Validator(); |
|
| 1493 | + // Taxonomy term rule validator for validating rules for term pages. |
|
| 1494 | + new Taxonomy_Term_Rule_Validator(); |
|
| 1495 | + $rule_validators_registry = new Rule_Validators_Registry( $default_rule_validator ); |
|
| 1496 | + $rule_groups_validator = new Rule_Groups_Validator( $rule_validators_registry ); |
|
| 1497 | + $mappings_validator = new Mappings_Validator( $mappings_dbo, $rule_groups_validator ); |
|
| 1498 | + |
|
| 1499 | + new Url_To_Entity_Transform_Function( $this->entity_uri_service ); |
|
| 1500 | + new Taxonomy_To_Terms_Transform_Function(); |
|
| 1501 | + new Post_Id_To_Entity_Transform_Function(); |
|
| 1502 | + $mappings_transform_functions_registry = new Mappings_Transform_Functions_Registry(); |
|
| 1503 | + |
|
| 1504 | + /** |
|
| 1505 | + * @since 3.27.1 |
|
| 1506 | + * Intiailize the acf group data formatter. |
|
| 1507 | + */ |
|
| 1508 | + new Acf_Group_Formatter(); |
|
| 1509 | + new Jsonld_Converter( $mappings_validator, $mappings_transform_functions_registry ); |
|
| 1510 | + |
|
| 1511 | + /** |
|
| 1512 | + * @since 3.26.0 |
|
| 1513 | + * Initialize the Faq JSON LD converter here - disabled. |
|
| 1514 | + */ |
|
| 1515 | + // new Faq_To_Jsonld_Converter(); |
|
| 1516 | + /* |
|
| 1517 | 1517 | * Use the Templates Ajax Endpoint to load HTML templates for the legacy Angular app via admin-ajax.php |
| 1518 | 1518 | * end-point. |
| 1519 | 1519 | * |
| 1520 | 1520 | * @see https://github.com/insideout10/wordlift-plugin/issues/834 |
| 1521 | 1521 | * @since 3.24.4 |
| 1522 | 1522 | */ |
| 1523 | - new Templates_Ajax_Endpoint(); |
|
| 1524 | - // Call this static method to register FAQ routes to rest api - disabled |
|
| 1525 | - //Faq_Rest_Controller::register_routes(); |
|
| 1523 | + new Templates_Ajax_Endpoint(); |
|
| 1524 | + // Call this static method to register FAQ routes to rest api - disabled |
|
| 1525 | + //Faq_Rest_Controller::register_routes(); |
|
| 1526 | 1526 | |
| 1527 | - /* |
|
| 1527 | + /* |
|
| 1528 | 1528 | * Create a singleton for the Analysis_Response_Ops_Factory. |
| 1529 | 1529 | */ |
| 1530 | - $entity_helper = new Entity_Helper( $this->entity_uri_service, $this->entity_service ); |
|
| 1531 | - new Analysis_Response_Ops_Factory( |
|
| 1532 | - $this->entity_uri_service, |
|
| 1533 | - $this->entity_service, |
|
| 1534 | - $this->entity_type_service, |
|
| 1535 | - $this->storage_factory->post_images(), |
|
| 1536 | - $entity_helper |
|
| 1537 | - ); |
|
| 1538 | - |
|
| 1539 | - /** WL Autocomplete. */ |
|
| 1540 | - $autocomplete_service = new All_Autocomplete_Service( array( |
|
| 1541 | - new Local_Autocomplete_Service(), |
|
| 1542 | - new Linked_Data_Autocomplete_Service( $this->configuration_service, $entity_helper, $this->entity_uri_service, $this->entity_service ), |
|
| 1543 | - ) ); |
|
| 1544 | - $this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $autocomplete_service ); |
|
| 1545 | - |
|
| 1546 | - /** |
|
| 1547 | - * @since 3.27.2 |
|
| 1548 | - * Integrate the recipe maker jsonld & set recipe |
|
| 1549 | - * as default entity type to the wprm_recipe CPT. |
|
| 1550 | - */ |
|
| 1551 | - new Recipe_Maker_Post_Type_Hook(); |
|
| 1552 | - $recipe_maker_validation_service = new Recipe_Maker_Validation_Service(); |
|
| 1553 | - new Recipe_Maker_Jsonld_Hook( $attachment_service, $recipe_maker_validation_service ); |
|
| 1554 | - new Recipe_Maker_After_Get_Jsonld_Hook( $recipe_maker_validation_service ); |
|
| 1555 | - new Recipe_Maker_Warning( $recipe_maker_validation_service ); |
|
| 1556 | - new Yoast_Jsonld( $recipe_maker_validation_service ); |
|
| 1557 | - |
|
| 1558 | - /** |
|
| 1559 | - * @since 3.27.4 |
|
| 1560 | - * Add the faq duplicate markup hook. |
|
| 1561 | - */ |
|
| 1562 | - new Faq_Duplicate_Markup_Remover(); |
|
| 1563 | - } |
|
| 1564 | - |
|
| 1565 | - /** |
|
| 1566 | - * Define the locale for this plugin for internationalization. |
|
| 1567 | - * |
|
| 1568 | - * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 1569 | - * with WordPress. |
|
| 1570 | - * |
|
| 1571 | - * @since 1.0.0 |
|
| 1572 | - * @access private |
|
| 1573 | - */ |
|
| 1574 | - private function set_locale() { |
|
| 1575 | - |
|
| 1576 | - $plugin_i18n = new Wordlift_i18n(); |
|
| 1577 | - $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 1578 | - |
|
| 1579 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 1580 | - |
|
| 1581 | - } |
|
| 1582 | - |
|
| 1583 | - /** |
|
| 1584 | - * Register all of the hooks related to the admin area functionality |
|
| 1585 | - * of the plugin. |
|
| 1586 | - * |
|
| 1587 | - * @since 1.0.0 |
|
| 1588 | - * @access private |
|
| 1589 | - */ |
|
| 1590 | - private function define_admin_hooks() { |
|
| 1591 | - |
|
| 1592 | - $plugin_admin = new Wordlift_Admin( |
|
| 1593 | - $this->get_plugin_name(), |
|
| 1594 | - $this->get_version(), |
|
| 1595 | - $this->configuration_service, |
|
| 1596 | - $this->notice_service, |
|
| 1597 | - $this->user_service |
|
| 1598 | - ); |
|
| 1599 | - |
|
| 1600 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 1601 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts', 11 ); |
|
| 1602 | - |
|
| 1603 | - // Hook the init action to taxonomy services. |
|
| 1604 | - $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 1605 | - $this->loader->add_action( 'init', $this->entity_types_taxonomy_service, 'init', 0 ); |
|
| 1606 | - |
|
| 1607 | - // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 1608 | - $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 1609 | - |
|
| 1610 | - // Hook the added_post_meta action to the Thumbnail service. |
|
| 1611 | - $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1612 | - |
|
| 1613 | - // Hook the updated_post_meta action to the Thumbnail service. |
|
| 1614 | - $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1615 | - |
|
| 1616 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1617 | - $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1618 | - |
|
| 1619 | - // Register custom allowed redirect hosts. |
|
| 1620 | - $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 1621 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1622 | - $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 1623 | - |
|
| 1624 | - /* |
|
| 1530 | + $entity_helper = new Entity_Helper( $this->entity_uri_service, $this->entity_service ); |
|
| 1531 | + new Analysis_Response_Ops_Factory( |
|
| 1532 | + $this->entity_uri_service, |
|
| 1533 | + $this->entity_service, |
|
| 1534 | + $this->entity_type_service, |
|
| 1535 | + $this->storage_factory->post_images(), |
|
| 1536 | + $entity_helper |
|
| 1537 | + ); |
|
| 1538 | + |
|
| 1539 | + /** WL Autocomplete. */ |
|
| 1540 | + $autocomplete_service = new All_Autocomplete_Service( array( |
|
| 1541 | + new Local_Autocomplete_Service(), |
|
| 1542 | + new Linked_Data_Autocomplete_Service( $this->configuration_service, $entity_helper, $this->entity_uri_service, $this->entity_service ), |
|
| 1543 | + ) ); |
|
| 1544 | + $this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $autocomplete_service ); |
|
| 1545 | + |
|
| 1546 | + /** |
|
| 1547 | + * @since 3.27.2 |
|
| 1548 | + * Integrate the recipe maker jsonld & set recipe |
|
| 1549 | + * as default entity type to the wprm_recipe CPT. |
|
| 1550 | + */ |
|
| 1551 | + new Recipe_Maker_Post_Type_Hook(); |
|
| 1552 | + $recipe_maker_validation_service = new Recipe_Maker_Validation_Service(); |
|
| 1553 | + new Recipe_Maker_Jsonld_Hook( $attachment_service, $recipe_maker_validation_service ); |
|
| 1554 | + new Recipe_Maker_After_Get_Jsonld_Hook( $recipe_maker_validation_service ); |
|
| 1555 | + new Recipe_Maker_Warning( $recipe_maker_validation_service ); |
|
| 1556 | + new Yoast_Jsonld( $recipe_maker_validation_service ); |
|
| 1557 | + |
|
| 1558 | + /** |
|
| 1559 | + * @since 3.27.4 |
|
| 1560 | + * Add the faq duplicate markup hook. |
|
| 1561 | + */ |
|
| 1562 | + new Faq_Duplicate_Markup_Remover(); |
|
| 1563 | + } |
|
| 1564 | + |
|
| 1565 | + /** |
|
| 1566 | + * Define the locale for this plugin for internationalization. |
|
| 1567 | + * |
|
| 1568 | + * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 1569 | + * with WordPress. |
|
| 1570 | + * |
|
| 1571 | + * @since 1.0.0 |
|
| 1572 | + * @access private |
|
| 1573 | + */ |
|
| 1574 | + private function set_locale() { |
|
| 1575 | + |
|
| 1576 | + $plugin_i18n = new Wordlift_i18n(); |
|
| 1577 | + $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 1578 | + |
|
| 1579 | + $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 1580 | + |
|
| 1581 | + } |
|
| 1582 | + |
|
| 1583 | + /** |
|
| 1584 | + * Register all of the hooks related to the admin area functionality |
|
| 1585 | + * of the plugin. |
|
| 1586 | + * |
|
| 1587 | + * @since 1.0.0 |
|
| 1588 | + * @access private |
|
| 1589 | + */ |
|
| 1590 | + private function define_admin_hooks() { |
|
| 1591 | + |
|
| 1592 | + $plugin_admin = new Wordlift_Admin( |
|
| 1593 | + $this->get_plugin_name(), |
|
| 1594 | + $this->get_version(), |
|
| 1595 | + $this->configuration_service, |
|
| 1596 | + $this->notice_service, |
|
| 1597 | + $this->user_service |
|
| 1598 | + ); |
|
| 1599 | + |
|
| 1600 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 1601 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts', 11 ); |
|
| 1602 | + |
|
| 1603 | + // Hook the init action to taxonomy services. |
|
| 1604 | + $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 1605 | + $this->loader->add_action( 'init', $this->entity_types_taxonomy_service, 'init', 0 ); |
|
| 1606 | + |
|
| 1607 | + // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 1608 | + $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 1609 | + |
|
| 1610 | + // Hook the added_post_meta action to the Thumbnail service. |
|
| 1611 | + $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1612 | + |
|
| 1613 | + // Hook the updated_post_meta action to the Thumbnail service. |
|
| 1614 | + $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1615 | + |
|
| 1616 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1617 | + $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1618 | + |
|
| 1619 | + // Register custom allowed redirect hosts. |
|
| 1620 | + $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 1621 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1622 | + $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 1623 | + |
|
| 1624 | + /* |
|
| 1625 | 1625 | * The old dashboard is replaced with dashboard v2. |
| 1626 | 1626 | * |
| 1627 | 1627 | * The old dashboard service is still loaded because its functions are used. |
@@ -1630,389 +1630,389 @@ discard block |
||
| 1630 | 1630 | * |
| 1631 | 1631 | * @since 3.20.0 |
| 1632 | 1632 | */ |
| 1633 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1634 | - // $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 1635 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1636 | - // $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 1637 | - |
|
| 1638 | - // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 1639 | - // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 1640 | - $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 1641 | - $this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 ); |
|
| 1642 | - |
|
| 1643 | - $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 1644 | - $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' ); |
|
| 1645 | - |
|
| 1646 | - // Entity listing customization (wp-admin/edit.php) |
|
| 1647 | - // Add custom columns. |
|
| 1648 | - $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 1649 | - // no explicit entity as it prevents handling of other post types. |
|
| 1650 | - $this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 1651 | - // Add 4W selection. |
|
| 1652 | - $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 1653 | - $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 1654 | - $this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' ); |
|
| 1655 | - $this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' ); |
|
| 1656 | - |
|
| 1657 | - /* |
|
| 1633 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1634 | + // $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 1635 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1636 | + // $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 1637 | + |
|
| 1638 | + // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 1639 | + // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 1640 | + $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 1641 | + $this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 ); |
|
| 1642 | + |
|
| 1643 | + $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 1644 | + $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' ); |
|
| 1645 | + |
|
| 1646 | + // Entity listing customization (wp-admin/edit.php) |
|
| 1647 | + // Add custom columns. |
|
| 1648 | + $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 1649 | + // no explicit entity as it prevents handling of other post types. |
|
| 1650 | + $this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 1651 | + // Add 4W selection. |
|
| 1652 | + $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 1653 | + $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 1654 | + $this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' ); |
|
| 1655 | + $this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' ); |
|
| 1656 | + |
|
| 1657 | + /* |
|
| 1658 | 1658 | * If `All Entity Types` is disable, use the radio button Walker. |
| 1659 | 1659 | * |
| 1660 | 1660 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
| 1661 | 1661 | */ |
| 1662 | - if ( ! WL_ALL_ENTITY_TYPES ) { |
|
| 1663 | - $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 1664 | - } |
|
| 1665 | - |
|
| 1666 | - // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 1667 | - // entities. |
|
| 1668 | - $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 1669 | - |
|
| 1670 | - // Filter imported post meta. |
|
| 1671 | - $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 1672 | - |
|
| 1673 | - // Notify the import service when an import starts and ends. |
|
| 1674 | - $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 1675 | - $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 1676 | - |
|
| 1677 | - // Hook the AJAX wl_rebuild action to the Rebuild Service. |
|
| 1678 | - $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 1679 | - $this->loader->add_action( 'wp_ajax_wl_rebuild_references', $this->reference_rebuild_service, 'rebuild' ); |
|
| 1680 | - |
|
| 1681 | - /** |
|
| 1682 | - * Filter: wl_feature__enable__screens. |
|
| 1683 | - * |
|
| 1684 | - * @param bool whether the screens needed to be registered, defaults to true. |
|
| 1685 | - * |
|
| 1686 | - * @return bool |
|
| 1687 | - * @since 3.27.6 |
|
| 1688 | - */ |
|
| 1689 | - if ( apply_filters( 'wl_feature__enable__screens', true ) ) { |
|
| 1690 | - // Hook the menu to the Download Your Data page. |
|
| 1691 | - $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 ); |
|
| 1692 | - $this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 ); |
|
| 1693 | - $this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 ); |
|
| 1694 | - } |
|
| 1695 | - // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
|
| 1696 | - $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 1697 | - |
|
| 1698 | - // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1699 | - $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1700 | - $this->loader->add_action( 'admin_post_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1701 | - $this->loader->add_action( 'admin_post_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1702 | - |
|
| 1703 | - // Hook the AJAX wl_validate_key action to the Key Validation service. |
|
| 1704 | - $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' ); |
|
| 1705 | - |
|
| 1706 | - // Hook the AJAX wl_update_country_options action to the countries. |
|
| 1707 | - $this->loader->add_action( 'wp_ajax_wl_update_country_options', $this->country_select_element, 'get_options_html' ); |
|
| 1708 | - |
|
| 1709 | - // Hook the `admin_init` function to the Admin Setup. |
|
| 1710 | - $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' ); |
|
| 1711 | - |
|
| 1712 | - // Hook the admin_init to the settings page. |
|
| 1713 | - $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' ); |
|
| 1714 | - $this->loader->add_action( 'admin_init', $this->analytics_settings_page, 'admin_init' ); |
|
| 1715 | - |
|
| 1716 | - $this->loader->add_filter( 'admin_post_thumbnail_html', $this->publisher_service, 'add_featured_image_instruction' ); |
|
| 1717 | - |
|
| 1718 | - // Hook the menu creation on the general wordlift menu creation. |
|
| 1719 | - /** |
|
| 1720 | - * Filter: wl_feature__enable__screens. |
|
| 1721 | - * |
|
| 1722 | - * @param bool whether the screens needed to be registered, defaults to true. |
|
| 1723 | - * |
|
| 1724 | - * @return bool |
|
| 1725 | - * @since 3.27.6 |
|
| 1726 | - */ |
|
| 1727 | - if ( apply_filters( 'wl_feature__enable__screens', true ) ) { |
|
| 1728 | - $this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 ); |
|
| 1729 | - } |
|
| 1730 | - /* |
|
| 1662 | + if ( ! WL_ALL_ENTITY_TYPES ) { |
|
| 1663 | + $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 1664 | + } |
|
| 1665 | + |
|
| 1666 | + // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 1667 | + // entities. |
|
| 1668 | + $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 1669 | + |
|
| 1670 | + // Filter imported post meta. |
|
| 1671 | + $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 1672 | + |
|
| 1673 | + // Notify the import service when an import starts and ends. |
|
| 1674 | + $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 1675 | + $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 1676 | + |
|
| 1677 | + // Hook the AJAX wl_rebuild action to the Rebuild Service. |
|
| 1678 | + $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 1679 | + $this->loader->add_action( 'wp_ajax_wl_rebuild_references', $this->reference_rebuild_service, 'rebuild' ); |
|
| 1680 | + |
|
| 1681 | + /** |
|
| 1682 | + * Filter: wl_feature__enable__screens. |
|
| 1683 | + * |
|
| 1684 | + * @param bool whether the screens needed to be registered, defaults to true. |
|
| 1685 | + * |
|
| 1686 | + * @return bool |
|
| 1687 | + * @since 3.27.6 |
|
| 1688 | + */ |
|
| 1689 | + if ( apply_filters( 'wl_feature__enable__screens', true ) ) { |
|
| 1690 | + // Hook the menu to the Download Your Data page. |
|
| 1691 | + $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 ); |
|
| 1692 | + $this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 ); |
|
| 1693 | + $this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 ); |
|
| 1694 | + } |
|
| 1695 | + // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
|
| 1696 | + $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 1697 | + |
|
| 1698 | + // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1699 | + $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1700 | + $this->loader->add_action( 'admin_post_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1701 | + $this->loader->add_action( 'admin_post_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1702 | + |
|
| 1703 | + // Hook the AJAX wl_validate_key action to the Key Validation service. |
|
| 1704 | + $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' ); |
|
| 1705 | + |
|
| 1706 | + // Hook the AJAX wl_update_country_options action to the countries. |
|
| 1707 | + $this->loader->add_action( 'wp_ajax_wl_update_country_options', $this->country_select_element, 'get_options_html' ); |
|
| 1708 | + |
|
| 1709 | + // Hook the `admin_init` function to the Admin Setup. |
|
| 1710 | + $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' ); |
|
| 1711 | + |
|
| 1712 | + // Hook the admin_init to the settings page. |
|
| 1713 | + $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' ); |
|
| 1714 | + $this->loader->add_action( 'admin_init', $this->analytics_settings_page, 'admin_init' ); |
|
| 1715 | + |
|
| 1716 | + $this->loader->add_filter( 'admin_post_thumbnail_html', $this->publisher_service, 'add_featured_image_instruction' ); |
|
| 1717 | + |
|
| 1718 | + // Hook the menu creation on the general wordlift menu creation. |
|
| 1719 | + /** |
|
| 1720 | + * Filter: wl_feature__enable__screens. |
|
| 1721 | + * |
|
| 1722 | + * @param bool whether the screens needed to be registered, defaults to true. |
|
| 1723 | + * |
|
| 1724 | + * @return bool |
|
| 1725 | + * @since 3.27.6 |
|
| 1726 | + */ |
|
| 1727 | + if ( apply_filters( 'wl_feature__enable__screens', true ) ) { |
|
| 1728 | + $this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 ); |
|
| 1729 | + } |
|
| 1730 | + /* |
|
| 1731 | 1731 | * Display the `Wordlift_Admin_Search_Rankings_Page` page. |
| 1732 | 1732 | * |
| 1733 | 1733 | * @link https://github.com/insideout10/wordlift-plugin/issues/761 |
| 1734 | 1734 | * |
| 1735 | 1735 | * @since 3.20.0 |
| 1736 | 1736 | */ |
| 1737 | - if ( in_array( $this->configuration_service->get_package_type(), array( 'editorial', 'business' ) ) ) { |
|
| 1738 | - /** |
|
| 1739 | - * Filter: wl_feature__enable__screens. |
|
| 1740 | - * |
|
| 1741 | - * @param bool whether the screens needed to be registered, defaults to true. |
|
| 1742 | - * |
|
| 1743 | - * @return bool |
|
| 1744 | - * @since 3.27.6 |
|
| 1745 | - */ |
|
| 1746 | - if ( apply_filters( 'wl_feature__enable__screens', true ) ) { |
|
| 1747 | - $admin_search_rankings_page = new Wordlift_Admin_Search_Rankings_Page(); |
|
| 1748 | - $this->loader->add_action( 'wl_admin_menu', $admin_search_rankings_page, 'admin_menu' ); |
|
| 1749 | - } |
|
| 1750 | - } |
|
| 1751 | - |
|
| 1752 | - // Hook key update. |
|
| 1753 | - $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 ); |
|
| 1754 | - $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 ); |
|
| 1755 | - |
|
| 1756 | - // Add additional action links to the WordLift plugin in the plugins page. |
|
| 1757 | - $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1758 | - |
|
| 1759 | - /* |
|
| 1737 | + if ( in_array( $this->configuration_service->get_package_type(), array( 'editorial', 'business' ) ) ) { |
|
| 1738 | + /** |
|
| 1739 | + * Filter: wl_feature__enable__screens. |
|
| 1740 | + * |
|
| 1741 | + * @param bool whether the screens needed to be registered, defaults to true. |
|
| 1742 | + * |
|
| 1743 | + * @return bool |
|
| 1744 | + * @since 3.27.6 |
|
| 1745 | + */ |
|
| 1746 | + if ( apply_filters( 'wl_feature__enable__screens', true ) ) { |
|
| 1747 | + $admin_search_rankings_page = new Wordlift_Admin_Search_Rankings_Page(); |
|
| 1748 | + $this->loader->add_action( 'wl_admin_menu', $admin_search_rankings_page, 'admin_menu' ); |
|
| 1749 | + } |
|
| 1750 | + } |
|
| 1751 | + |
|
| 1752 | + // Hook key update. |
|
| 1753 | + $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 ); |
|
| 1754 | + $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 ); |
|
| 1755 | + |
|
| 1756 | + // Add additional action links to the WordLift plugin in the plugins page. |
|
| 1757 | + $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1758 | + |
|
| 1759 | + /* |
|
| 1760 | 1760 | * Remove the Analytics Settings link from the plugin page. |
| 1761 | 1761 | * |
| 1762 | 1762 | * @see https://github.com/insideout10/wordlift-plugin/issues/932 |
| 1763 | 1763 | * @since 3.21.1 |
| 1764 | 1764 | */ |
| 1765 | - // $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->analytics_settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1766 | - |
|
| 1767 | - // Hook the AJAX `wl_publisher` action name. |
|
| 1768 | - $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' ); |
|
| 1769 | - |
|
| 1770 | - // Hook row actions for the entity type list admin. |
|
| 1771 | - $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 ); |
|
| 1772 | - |
|
| 1773 | - /** Ajax actions. */ |
|
| 1774 | - $this->loader->add_action( 'wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export' ); |
|
| 1775 | - |
|
| 1776 | - // Hook capabilities manipulation to allow access to entity type admin |
|
| 1777 | - // page on WordPress versions before 4.7. |
|
| 1778 | - global $wp_version; |
|
| 1779 | - if ( version_compare( $wp_version, '4.7', '<' ) ) { |
|
| 1780 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 ); |
|
| 1781 | - } |
|
| 1782 | - |
|
| 1783 | - $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1784 | - |
|
| 1785 | - /** Adapters. */ |
|
| 1786 | - $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 ); |
|
| 1787 | - /** |
|
| 1788 | - * Disabling Faq temporarily. |
|
| 1789 | - * Load the tinymce editor button on the tool bar. |
|
| 1790 | - * @since 3.26.0 |
|
| 1791 | - */ |
|
| 1792 | - //$this->loader->add_filter( 'tiny_mce_before_init', $this->faq_tinymce_adapter, 'register_custom_tags' ); |
|
| 1793 | - //$this->loader->add_filter( 'mce_buttons', $this->faq_tinymce_adapter, 'register_faq_toolbar_button', 10, 1 ); |
|
| 1794 | - //$this->loader->add_filter( 'mce_external_plugins', $this->faq_tinymce_adapter, 'register_faq_tinymce_plugin', 10, 1 ); |
|
| 1795 | - |
|
| 1796 | - |
|
| 1797 | - $this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all' ); |
|
| 1798 | - $this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' ); |
|
| 1799 | - $this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' ); |
|
| 1800 | - /** |
|
| 1801 | - * @since 3.26.0 |
|
| 1802 | - */ |
|
| 1803 | - if ( apply_filters( 'wl_feature__enable__post_excerpt', true ) ) { |
|
| 1804 | - $excerpt_adapter = new Post_Excerpt_Meta_Box_Adapter(); |
|
| 1805 | - $this->loader->add_action( 'do_meta_boxes', $excerpt_adapter, 'replace_post_excerpt_meta_box' ); |
|
| 1806 | - // Adding Rest route for the post excerpt |
|
| 1807 | - Post_Excerpt_Rest_Controller::register_routes(); |
|
| 1808 | - } |
|
| 1809 | - |
|
| 1810 | - $this->loader->add_action( 'update_user_metadata', $this->user_service, 'update_user_metadata', 10, 5 ); |
|
| 1811 | - $this->loader->add_action( 'delete_user_metadata', $this->user_service, 'delete_user_metadata', 10, 5 ); |
|
| 1812 | - |
|
| 1813 | - // Handle the autocomplete request. |
|
| 1814 | - add_action( 'wp_ajax_wl_autocomplete', array( |
|
| 1815 | - $this->autocomplete_adapter, |
|
| 1816 | - 'wl_autocomplete', |
|
| 1817 | - ) ); |
|
| 1818 | - add_action( 'wp_ajax_nopriv_wl_autocomplete', array( |
|
| 1819 | - $this->autocomplete_adapter, |
|
| 1820 | - 'wl_autocomplete', |
|
| 1821 | - ) ); |
|
| 1822 | - |
|
| 1823 | - // Hooks to restrict multisite super admin from manipulating entity types. |
|
| 1824 | - if ( is_multisite() ) { |
|
| 1825 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 ); |
|
| 1826 | - } |
|
| 1827 | - |
|
| 1828 | - $deactivator_feedback = new Wordlift_Deactivator_Feedback( $this->configuration_service ); |
|
| 1829 | - |
|
| 1830 | - add_action( 'admin_footer', array( $deactivator_feedback, 'render_feedback_popup' ) ); |
|
| 1831 | - add_action( 'admin_enqueue_scripts', array( $deactivator_feedback, 'enqueue_popup_scripts' ) ); |
|
| 1832 | - add_action( 'wp_ajax_wl_deactivation_feedback', array( $deactivator_feedback, 'wl_deactivation_feedback' ) ); |
|
| 1833 | - |
|
| 1834 | - /** |
|
| 1835 | - * Always allow the `wordlift/classification` block. |
|
| 1836 | - * |
|
| 1837 | - * @since 3.23.0 |
|
| 1838 | - */ |
|
| 1839 | - add_filter( 'allowed_block_types', function ( $value ) { |
|
| 1840 | - |
|
| 1841 | - if ( true === $value ) { |
|
| 1842 | - return $value; |
|
| 1843 | - } |
|
| 1844 | - |
|
| 1845 | - return array_merge( (array) $value, array( 'wordlift/classification' ) ); |
|
| 1846 | - }, PHP_INT_MAX ); |
|
| 1847 | - |
|
| 1848 | - /** |
|
| 1849 | - * @since 3.27.7 |
|
| 1850 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
| 1851 | - */ |
|
| 1852 | - new Top_Entities(); |
|
| 1853 | - } |
|
| 1854 | - |
|
| 1855 | - /** |
|
| 1856 | - * Register all of the hooks related to the public-facing functionality |
|
| 1857 | - * of the plugin. |
|
| 1858 | - * |
|
| 1859 | - * @since 1.0.0 |
|
| 1860 | - * @access private |
|
| 1861 | - */ |
|
| 1862 | - private function define_public_hooks() { |
|
| 1863 | - |
|
| 1864 | - $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 1865 | - |
|
| 1866 | - // Register the entity post type. |
|
| 1867 | - $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' ); |
|
| 1868 | - |
|
| 1869 | - // Bind the link generation and handling hooks to the entity link service. |
|
| 1870 | - $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 1871 | - $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 ); |
|
| 1872 | - // $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 ); |
|
| 1873 | - // $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 ); |
|
| 1874 | - |
|
| 1875 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 1876 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 1877 | - $this->loader->add_action( 'wp_enqueue_scripts', $this->context_cards_service, 'enqueue_scripts' ); |
|
| 1878 | - |
|
| 1879 | - // Registering Faq_Content_Filter service used for removing faq question and answer tags from the html. |
|
| 1880 | - $this->loader->add_filter( 'the_content', $this->faq_content_filter_service, 'remove_all_faq_question_and_answer_tags' ); |
|
| 1881 | - // Hook the content filter service to add entity links. |
|
| 1882 | - if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) { |
|
| 1883 | - $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' ); |
|
| 1884 | - } |
|
| 1885 | - |
|
| 1886 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1887 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1888 | - |
|
| 1889 | - // Hook the ShareThis service. |
|
| 1890 | - $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 1891 | - $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 1892 | - |
|
| 1893 | - // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1894 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1895 | - |
|
| 1896 | - // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service` |
|
| 1897 | - // in order to tweak WP's `WP_Query` to include entities in queries related |
|
| 1898 | - // to categories. |
|
| 1899 | - $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 ); |
|
| 1900 | - |
|
| 1901 | - /* |
|
| 1765 | + // $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->analytics_settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1766 | + |
|
| 1767 | + // Hook the AJAX `wl_publisher` action name. |
|
| 1768 | + $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' ); |
|
| 1769 | + |
|
| 1770 | + // Hook row actions for the entity type list admin. |
|
| 1771 | + $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 ); |
|
| 1772 | + |
|
| 1773 | + /** Ajax actions. */ |
|
| 1774 | + $this->loader->add_action( 'wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export' ); |
|
| 1775 | + |
|
| 1776 | + // Hook capabilities manipulation to allow access to entity type admin |
|
| 1777 | + // page on WordPress versions before 4.7. |
|
| 1778 | + global $wp_version; |
|
| 1779 | + if ( version_compare( $wp_version, '4.7', '<' ) ) { |
|
| 1780 | + $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 ); |
|
| 1781 | + } |
|
| 1782 | + |
|
| 1783 | + $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1784 | + |
|
| 1785 | + /** Adapters. */ |
|
| 1786 | + $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 ); |
|
| 1787 | + /** |
|
| 1788 | + * Disabling Faq temporarily. |
|
| 1789 | + * Load the tinymce editor button on the tool bar. |
|
| 1790 | + * @since 3.26.0 |
|
| 1791 | + */ |
|
| 1792 | + //$this->loader->add_filter( 'tiny_mce_before_init', $this->faq_tinymce_adapter, 'register_custom_tags' ); |
|
| 1793 | + //$this->loader->add_filter( 'mce_buttons', $this->faq_tinymce_adapter, 'register_faq_toolbar_button', 10, 1 ); |
|
| 1794 | + //$this->loader->add_filter( 'mce_external_plugins', $this->faq_tinymce_adapter, 'register_faq_tinymce_plugin', 10, 1 ); |
|
| 1795 | + |
|
| 1796 | + |
|
| 1797 | + $this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all' ); |
|
| 1798 | + $this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' ); |
|
| 1799 | + $this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' ); |
|
| 1800 | + /** |
|
| 1801 | + * @since 3.26.0 |
|
| 1802 | + */ |
|
| 1803 | + if ( apply_filters( 'wl_feature__enable__post_excerpt', true ) ) { |
|
| 1804 | + $excerpt_adapter = new Post_Excerpt_Meta_Box_Adapter(); |
|
| 1805 | + $this->loader->add_action( 'do_meta_boxes', $excerpt_adapter, 'replace_post_excerpt_meta_box' ); |
|
| 1806 | + // Adding Rest route for the post excerpt |
|
| 1807 | + Post_Excerpt_Rest_Controller::register_routes(); |
|
| 1808 | + } |
|
| 1809 | + |
|
| 1810 | + $this->loader->add_action( 'update_user_metadata', $this->user_service, 'update_user_metadata', 10, 5 ); |
|
| 1811 | + $this->loader->add_action( 'delete_user_metadata', $this->user_service, 'delete_user_metadata', 10, 5 ); |
|
| 1812 | + |
|
| 1813 | + // Handle the autocomplete request. |
|
| 1814 | + add_action( 'wp_ajax_wl_autocomplete', array( |
|
| 1815 | + $this->autocomplete_adapter, |
|
| 1816 | + 'wl_autocomplete', |
|
| 1817 | + ) ); |
|
| 1818 | + add_action( 'wp_ajax_nopriv_wl_autocomplete', array( |
|
| 1819 | + $this->autocomplete_adapter, |
|
| 1820 | + 'wl_autocomplete', |
|
| 1821 | + ) ); |
|
| 1822 | + |
|
| 1823 | + // Hooks to restrict multisite super admin from manipulating entity types. |
|
| 1824 | + if ( is_multisite() ) { |
|
| 1825 | + $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 ); |
|
| 1826 | + } |
|
| 1827 | + |
|
| 1828 | + $deactivator_feedback = new Wordlift_Deactivator_Feedback( $this->configuration_service ); |
|
| 1829 | + |
|
| 1830 | + add_action( 'admin_footer', array( $deactivator_feedback, 'render_feedback_popup' ) ); |
|
| 1831 | + add_action( 'admin_enqueue_scripts', array( $deactivator_feedback, 'enqueue_popup_scripts' ) ); |
|
| 1832 | + add_action( 'wp_ajax_wl_deactivation_feedback', array( $deactivator_feedback, 'wl_deactivation_feedback' ) ); |
|
| 1833 | + |
|
| 1834 | + /** |
|
| 1835 | + * Always allow the `wordlift/classification` block. |
|
| 1836 | + * |
|
| 1837 | + * @since 3.23.0 |
|
| 1838 | + */ |
|
| 1839 | + add_filter( 'allowed_block_types', function ( $value ) { |
|
| 1840 | + |
|
| 1841 | + if ( true === $value ) { |
|
| 1842 | + return $value; |
|
| 1843 | + } |
|
| 1844 | + |
|
| 1845 | + return array_merge( (array) $value, array( 'wordlift/classification' ) ); |
|
| 1846 | + }, PHP_INT_MAX ); |
|
| 1847 | + |
|
| 1848 | + /** |
|
| 1849 | + * @since 3.27.7 |
|
| 1850 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
| 1851 | + */ |
|
| 1852 | + new Top_Entities(); |
|
| 1853 | + } |
|
| 1854 | + |
|
| 1855 | + /** |
|
| 1856 | + * Register all of the hooks related to the public-facing functionality |
|
| 1857 | + * of the plugin. |
|
| 1858 | + * |
|
| 1859 | + * @since 1.0.0 |
|
| 1860 | + * @access private |
|
| 1861 | + */ |
|
| 1862 | + private function define_public_hooks() { |
|
| 1863 | + |
|
| 1864 | + $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 1865 | + |
|
| 1866 | + // Register the entity post type. |
|
| 1867 | + $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' ); |
|
| 1868 | + |
|
| 1869 | + // Bind the link generation and handling hooks to the entity link service. |
|
| 1870 | + $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 1871 | + $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 ); |
|
| 1872 | + // $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 ); |
|
| 1873 | + // $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 ); |
|
| 1874 | + |
|
| 1875 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 1876 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 1877 | + $this->loader->add_action( 'wp_enqueue_scripts', $this->context_cards_service, 'enqueue_scripts' ); |
|
| 1878 | + |
|
| 1879 | + // Registering Faq_Content_Filter service used for removing faq question and answer tags from the html. |
|
| 1880 | + $this->loader->add_filter( 'the_content', $this->faq_content_filter_service, 'remove_all_faq_question_and_answer_tags' ); |
|
| 1881 | + // Hook the content filter service to add entity links. |
|
| 1882 | + if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) { |
|
| 1883 | + $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' ); |
|
| 1884 | + } |
|
| 1885 | + |
|
| 1886 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1887 | + $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1888 | + |
|
| 1889 | + // Hook the ShareThis service. |
|
| 1890 | + $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 1891 | + $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 1892 | + |
|
| 1893 | + // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1894 | + $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1895 | + |
|
| 1896 | + // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service` |
|
| 1897 | + // in order to tweak WP's `WP_Query` to include entities in queries related |
|
| 1898 | + // to categories. |
|
| 1899 | + $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 ); |
|
| 1900 | + |
|
| 1901 | + /* |
|
| 1902 | 1902 | * Hook the `pre_get_posts` action to the `Wordlift_Entity_Page_Service` |
| 1903 | 1903 | * in order to tweak WP's `WP_Query` to show event related entities in reverse |
| 1904 | 1904 | * order of start time. |
| 1905 | 1905 | */ |
| 1906 | - $this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 ); |
|
| 1907 | - |
|
| 1908 | - $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1909 | - |
|
| 1910 | - // This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done. |
|
| 1911 | - $this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 ); |
|
| 1912 | - |
|
| 1913 | - // Analytics Script Frontend. |
|
| 1914 | - if ( $this->configuration_service->is_analytics_enable() ) { |
|
| 1915 | - $this->loader->add_action( 'wp_enqueue_scripts', $this->analytics_connect, 'enqueue_scripts', 10 ); |
|
| 1916 | - } |
|
| 1917 | - |
|
| 1918 | - } |
|
| 1919 | - |
|
| 1920 | - /** |
|
| 1921 | - * Run the loader to execute all of the hooks with WordPress. |
|
| 1922 | - * |
|
| 1923 | - * @since 1.0.0 |
|
| 1924 | - */ |
|
| 1925 | - public function run() { |
|
| 1926 | - $this->loader->run(); |
|
| 1927 | - } |
|
| 1928 | - |
|
| 1929 | - /** |
|
| 1930 | - * The name of the plugin used to uniquely identify it within the context of |
|
| 1931 | - * WordPress and to define internationalization functionality. |
|
| 1932 | - * |
|
| 1933 | - * @return string The name of the plugin. |
|
| 1934 | - * @since 1.0.0 |
|
| 1935 | - */ |
|
| 1936 | - public function get_plugin_name() { |
|
| 1937 | - return $this->plugin_name; |
|
| 1938 | - } |
|
| 1939 | - |
|
| 1940 | - /** |
|
| 1941 | - * The reference to the class that orchestrates the hooks with the plugin. |
|
| 1942 | - * |
|
| 1943 | - * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 1944 | - * @since 1.0.0 |
|
| 1945 | - */ |
|
| 1946 | - public function get_loader() { |
|
| 1947 | - return $this->loader; |
|
| 1948 | - } |
|
| 1949 | - |
|
| 1950 | - /** |
|
| 1951 | - * Retrieve the version number of the plugin. |
|
| 1952 | - * |
|
| 1953 | - * @return string The version number of the plugin. |
|
| 1954 | - * @since 1.0.0 |
|
| 1955 | - */ |
|
| 1956 | - public function get_version() { |
|
| 1957 | - return $this->version; |
|
| 1958 | - } |
|
| 1959 | - |
|
| 1960 | - /** |
|
| 1961 | - * Load dependencies for WP-CLI. |
|
| 1962 | - * |
|
| 1963 | - * @throws Exception |
|
| 1964 | - * @since 3.18.0 |
|
| 1965 | - */ |
|
| 1966 | - private function load_cli_dependencies() { |
|
| 1967 | - |
|
| 1968 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'cli/class-wordlift-push-reference-data-command.php'; |
|
| 1969 | - |
|
| 1970 | - $push_reference_data_command = new Wordlift_Push_Reference_Data_Command( $this->relation_service, $this->entity_service, $this->sparql_service, $this->configuration_service, $this->entity_type_service ); |
|
| 1971 | - |
|
| 1972 | - WP_CLI::add_command( 'wl references push', $push_reference_data_command ); |
|
| 1973 | - |
|
| 1974 | - } |
|
| 1975 | - |
|
| 1976 | - /** |
|
| 1977 | - * Get the {@link \Wordlift_Dashboard_Service} to allow others to use its functions. |
|
| 1978 | - * |
|
| 1979 | - * @return \Wordlift_Dashboard_Service The {@link \Wordlift_Dashboard_Service} instance. |
|
| 1980 | - * @since 3.20.0 |
|
| 1981 | - */ |
|
| 1982 | - public function get_dashboard_service() { |
|
| 1983 | - |
|
| 1984 | - return $this->dashboard_service; |
|
| 1985 | - } |
|
| 1986 | - |
|
| 1987 | - public function add_wl_enabled_blocks() { |
|
| 1988 | - /** |
|
| 1989 | - * Filter: wl_feature__enable__blocks. |
|
| 1990 | - * |
|
| 1991 | - * @param bool whether the blocks needed to be registered, defaults to true. |
|
| 1992 | - * |
|
| 1993 | - * @return bool |
|
| 1994 | - * @since 3.27.6 |
|
| 1995 | - */ |
|
| 1996 | - |
|
| 1997 | - wp_register_script( 'wl_enabled_blocks', false ); |
|
| 1998 | - |
|
| 1999 | - $enabled_blocks = array( 'wordlift/products-navigator' ); |
|
| 2000 | - |
|
| 2001 | - if ( apply_filters( 'wl_feature__enable__blocks', true ) ) { |
|
| 2002 | - // To intimate JS |
|
| 2003 | - $enabled_blocks = array_merge( $enabled_blocks, array( |
|
| 2004 | - 'wordlift/navigator', |
|
| 2005 | - 'wordlift/chord', |
|
| 2006 | - 'wordlift/geomap', |
|
| 2007 | - 'wordlift/timeline', |
|
| 2008 | - 'wordlift/cloud', |
|
| 2009 | - 'wordlift/vocabulary', |
|
| 2010 | - 'wordlift/faceted-search' |
|
| 2011 | - ) ); |
|
| 2012 | - } |
|
| 2013 | - |
|
| 2014 | - wp_localize_script( 'wl_enabled_blocks', 'wlEnabledBlocks', $enabled_blocks ); |
|
| 2015 | - wp_enqueue_script( 'wl_enabled_blocks' ); |
|
| 2016 | - } |
|
| 1906 | + $this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 ); |
|
| 1907 | + |
|
| 1908 | + $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1909 | + |
|
| 1910 | + // This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done. |
|
| 1911 | + $this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 ); |
|
| 1912 | + |
|
| 1913 | + // Analytics Script Frontend. |
|
| 1914 | + if ( $this->configuration_service->is_analytics_enable() ) { |
|
| 1915 | + $this->loader->add_action( 'wp_enqueue_scripts', $this->analytics_connect, 'enqueue_scripts', 10 ); |
|
| 1916 | + } |
|
| 1917 | + |
|
| 1918 | + } |
|
| 1919 | + |
|
| 1920 | + /** |
|
| 1921 | + * Run the loader to execute all of the hooks with WordPress. |
|
| 1922 | + * |
|
| 1923 | + * @since 1.0.0 |
|
| 1924 | + */ |
|
| 1925 | + public function run() { |
|
| 1926 | + $this->loader->run(); |
|
| 1927 | + } |
|
| 1928 | + |
|
| 1929 | + /** |
|
| 1930 | + * The name of the plugin used to uniquely identify it within the context of |
|
| 1931 | + * WordPress and to define internationalization functionality. |
|
| 1932 | + * |
|
| 1933 | + * @return string The name of the plugin. |
|
| 1934 | + * @since 1.0.0 |
|
| 1935 | + */ |
|
| 1936 | + public function get_plugin_name() { |
|
| 1937 | + return $this->plugin_name; |
|
| 1938 | + } |
|
| 1939 | + |
|
| 1940 | + /** |
|
| 1941 | + * The reference to the class that orchestrates the hooks with the plugin. |
|
| 1942 | + * |
|
| 1943 | + * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 1944 | + * @since 1.0.0 |
|
| 1945 | + */ |
|
| 1946 | + public function get_loader() { |
|
| 1947 | + return $this->loader; |
|
| 1948 | + } |
|
| 1949 | + |
|
| 1950 | + /** |
|
| 1951 | + * Retrieve the version number of the plugin. |
|
| 1952 | + * |
|
| 1953 | + * @return string The version number of the plugin. |
|
| 1954 | + * @since 1.0.0 |
|
| 1955 | + */ |
|
| 1956 | + public function get_version() { |
|
| 1957 | + return $this->version; |
|
| 1958 | + } |
|
| 1959 | + |
|
| 1960 | + /** |
|
| 1961 | + * Load dependencies for WP-CLI. |
|
| 1962 | + * |
|
| 1963 | + * @throws Exception |
|
| 1964 | + * @since 3.18.0 |
|
| 1965 | + */ |
|
| 1966 | + private function load_cli_dependencies() { |
|
| 1967 | + |
|
| 1968 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'cli/class-wordlift-push-reference-data-command.php'; |
|
| 1969 | + |
|
| 1970 | + $push_reference_data_command = new Wordlift_Push_Reference_Data_Command( $this->relation_service, $this->entity_service, $this->sparql_service, $this->configuration_service, $this->entity_type_service ); |
|
| 1971 | + |
|
| 1972 | + WP_CLI::add_command( 'wl references push', $push_reference_data_command ); |
|
| 1973 | + |
|
| 1974 | + } |
|
| 1975 | + |
|
| 1976 | + /** |
|
| 1977 | + * Get the {@link \Wordlift_Dashboard_Service} to allow others to use its functions. |
|
| 1978 | + * |
|
| 1979 | + * @return \Wordlift_Dashboard_Service The {@link \Wordlift_Dashboard_Service} instance. |
|
| 1980 | + * @since 3.20.0 |
|
| 1981 | + */ |
|
| 1982 | + public function get_dashboard_service() { |
|
| 1983 | + |
|
| 1984 | + return $this->dashboard_service; |
|
| 1985 | + } |
|
| 1986 | + |
|
| 1987 | + public function add_wl_enabled_blocks() { |
|
| 1988 | + /** |
|
| 1989 | + * Filter: wl_feature__enable__blocks. |
|
| 1990 | + * |
|
| 1991 | + * @param bool whether the blocks needed to be registered, defaults to true. |
|
| 1992 | + * |
|
| 1993 | + * @return bool |
|
| 1994 | + * @since 3.27.6 |
|
| 1995 | + */ |
|
| 1996 | + |
|
| 1997 | + wp_register_script( 'wl_enabled_blocks', false ); |
|
| 1998 | + |
|
| 1999 | + $enabled_blocks = array( 'wordlift/products-navigator' ); |
|
| 2000 | + |
|
| 2001 | + if ( apply_filters( 'wl_feature__enable__blocks', true ) ) { |
|
| 2002 | + // To intimate JS |
|
| 2003 | + $enabled_blocks = array_merge( $enabled_blocks, array( |
|
| 2004 | + 'wordlift/navigator', |
|
| 2005 | + 'wordlift/chord', |
|
| 2006 | + 'wordlift/geomap', |
|
| 2007 | + 'wordlift/timeline', |
|
| 2008 | + 'wordlift/cloud', |
|
| 2009 | + 'wordlift/vocabulary', |
|
| 2010 | + 'wordlift/faceted-search' |
|
| 2011 | + ) ); |
|
| 2012 | + } |
|
| 2013 | + |
|
| 2014 | + wp_localize_script( 'wl_enabled_blocks', 'wlEnabledBlocks', $enabled_blocks ); |
|
| 2015 | + wp_enqueue_script( 'wl_enabled_blocks' ); |
|
| 2016 | + } |
|
| 2017 | 2017 | |
| 2018 | 2018 | } |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | $this->define_public_hooks(); |
| 758 | 758 | |
| 759 | 759 | // If we're in `WP_CLI` load the related files. |
| 760 | - if ( class_exists( 'WP_CLI' ) ) { |
|
| 760 | + if (class_exists('WP_CLI')) { |
|
| 761 | 761 | $this->load_cli_dependencies(); |
| 762 | 762 | } |
| 763 | 763 | |
@@ -798,381 +798,381 @@ discard block |
||
| 798 | 798 | * The class responsible for orchestrating the actions and filters of the |
| 799 | 799 | * core plugin. |
| 800 | 800 | */ |
| 801 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 801 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-loader.php'; |
|
| 802 | 802 | |
| 803 | 803 | // The class responsible for plugin uninstall. |
| 804 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-deactivator-feedback.php'; |
|
| 804 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-deactivator-feedback.php'; |
|
| 805 | 805 | |
| 806 | 806 | /** |
| 807 | 807 | * The class responsible for defining internationalization functionality |
| 808 | 808 | * of the plugin. |
| 809 | 809 | */ |
| 810 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 810 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-i18n.php'; |
|
| 811 | 811 | |
| 812 | 812 | /** |
| 813 | 813 | * WordLift's supported languages. |
| 814 | 814 | */ |
| 815 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php'; |
|
| 815 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-languages.php'; |
|
| 816 | 816 | |
| 817 | 817 | /** |
| 818 | 818 | * WordLift's supported countries. |
| 819 | 819 | */ |
| 820 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-countries.php'; |
|
| 820 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-countries.php'; |
|
| 821 | 821 | |
| 822 | 822 | /** |
| 823 | 823 | * Provide support functions to sanitize data. |
| 824 | 824 | */ |
| 825 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 825 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sanitizer.php'; |
|
| 826 | 826 | |
| 827 | 827 | /** Services. */ |
| 828 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 829 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php'; |
|
| 830 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 831 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 832 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 833 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 834 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 835 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php'; |
|
| 836 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php'; |
|
| 837 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-image-service.php'; |
|
| 828 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-log-service.php'; |
|
| 829 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-http-api.php'; |
|
| 830 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-redirect-service.php'; |
|
| 831 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-configuration-service.php'; |
|
| 832 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-post-type-service.php'; |
|
| 833 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-type-service.php'; |
|
| 834 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-link-service.php'; |
|
| 835 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-linked-data-service.php'; |
|
| 836 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-relation-service.php'; |
|
| 837 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-image-service.php'; |
|
| 838 | 838 | |
| 839 | 839 | /** |
| 840 | 840 | * The Query builder. |
| 841 | 841 | */ |
| 842 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 842 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-query-builder.php'; |
|
| 843 | 843 | |
| 844 | 844 | /** |
| 845 | 845 | * The Schema service. |
| 846 | 846 | */ |
| 847 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 847 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-schema-service.php'; |
|
| 848 | 848 | |
| 849 | 849 | /** |
| 850 | 850 | * The schema:url property service. |
| 851 | 851 | */ |
| 852 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 853 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 852 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-property-service.php'; |
|
| 853 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-schema-url-property-service.php'; |
|
| 854 | 854 | |
| 855 | 855 | /** |
| 856 | 856 | * The UI service. |
| 857 | 857 | */ |
| 858 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 858 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-ui-service.php'; |
|
| 859 | 859 | |
| 860 | 860 | /** |
| 861 | 861 | * The Thumbnail service. |
| 862 | 862 | */ |
| 863 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 863 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-thumbnail-service.php'; |
|
| 864 | 864 | |
| 865 | 865 | /** |
| 866 | 866 | * The Entity Types Taxonomy service. |
| 867 | 867 | */ |
| 868 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-taxonomy-service.php'; |
|
| 868 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-type-taxonomy-service.php'; |
|
| 869 | 869 | |
| 870 | 870 | /** |
| 871 | 871 | * The Entity service. |
| 872 | 872 | */ |
| 873 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php'; |
|
| 874 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 873 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-uri-service.php'; |
|
| 874 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-service.php'; |
|
| 875 | 875 | |
| 876 | 876 | // Add the entity rating service. |
| 877 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php'; |
|
| 877 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-rating-service.php'; |
|
| 878 | 878 | |
| 879 | 879 | /** |
| 880 | 880 | * The User service. |
| 881 | 881 | */ |
| 882 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 882 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-user-service.php'; |
|
| 883 | 883 | |
| 884 | 884 | /** |
| 885 | 885 | * The Timeline service. |
| 886 | 886 | */ |
| 887 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 887 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-timeline-service.php'; |
|
| 888 | 888 | |
| 889 | 889 | /** |
| 890 | 890 | * The Topic Taxonomy service. |
| 891 | 891 | */ |
| 892 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 892 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 893 | 893 | |
| 894 | 894 | /** |
| 895 | 895 | * The SPARQL service. |
| 896 | 896 | */ |
| 897 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 897 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sparql-service.php'; |
|
| 898 | 898 | |
| 899 | 899 | /** |
| 900 | 900 | * The WordLift import service. |
| 901 | 901 | */ |
| 902 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 902 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-import-service.php'; |
|
| 903 | 903 | |
| 904 | 904 | /** |
| 905 | 905 | * The WordLift URI service. |
| 906 | 906 | */ |
| 907 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 908 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 909 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php'; |
|
| 907 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-uri-service.php'; |
|
| 908 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-property-factory.php'; |
|
| 909 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sample-data-service.php'; |
|
| 910 | 910 | |
| 911 | 911 | /** |
| 912 | 912 | * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
| 913 | 913 | */ |
| 914 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-listable.php'; |
|
| 915 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-rebuild-service.php'; |
|
| 916 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-reference-rebuild-service.php'; |
|
| 917 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-service.php'; |
|
| 918 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-adapter.php'; |
|
| 914 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/rebuild/class-wordlift-listable.php'; |
|
| 915 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/rebuild/class-wordlift-rebuild-service.php'; |
|
| 916 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/rebuild/class-wordlift-reference-rebuild-service.php'; |
|
| 917 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/rebuild/class-wordlift-relation-rebuild-service.php'; |
|
| 918 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/rebuild/class-wordlift-relation-rebuild-adapter.php'; |
|
| 919 | 919 | |
| 920 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 921 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php'; |
|
| 920 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 921 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-attachment-service.php'; |
|
| 922 | 922 | |
| 923 | 923 | /** |
| 924 | 924 | * Load the converters. |
| 925 | 925 | */ |
| 926 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php'; |
|
| 927 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 928 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 929 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 930 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 931 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php'; |
|
| 926 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/intf-wordlift-post-converter.php'; |
|
| 927 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 928 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 929 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 930 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 931 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-jsonld-website-converter.php'; |
|
| 932 | 932 | |
| 933 | 933 | /** |
| 934 | 934 | * Load cache-related files. |
| 935 | 935 | */ |
| 936 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php'; |
|
| 936 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/cache/require.php'; |
|
| 937 | 937 | |
| 938 | 938 | /** |
| 939 | 939 | * Load the content filter. |
| 940 | 940 | */ |
| 941 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 941 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-content-filter-service.php'; |
|
| 942 | 942 | |
| 943 | 943 | /* |
| 944 | 944 | * Load the excerpt helper. |
| 945 | 945 | */ |
| 946 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 946 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 947 | 947 | |
| 948 | 948 | /** |
| 949 | 949 | * Load the JSON-LD service to publish entities using JSON-LD.s |
| 950 | 950 | * |
| 951 | 951 | * @since 3.8.0 |
| 952 | 952 | */ |
| 953 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 953 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-jsonld-service.php'; |
|
| 954 | 954 | |
| 955 | 955 | // The Publisher Service and the AJAX adapter. |
| 956 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php'; |
|
| 957 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 956 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-publisher-service.php'; |
|
| 957 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 958 | 958 | |
| 959 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php'; |
|
| 959 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-post-adapter.php'; |
|
| 960 | 960 | |
| 961 | 961 | /** |
| 962 | 962 | * Load the WordLift key validation service. |
| 963 | 963 | */ |
| 964 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php'; |
|
| 964 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-key-validation-service.php'; |
|
| 965 | 965 | |
| 966 | 966 | // Load the `Wordlift_Category_Taxonomy_Service` class definition. |
| 967 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 967 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 968 | 968 | |
| 969 | 969 | // Load the `Wordlift_Entity_Page_Service` class definition. |
| 970 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php'; |
|
| 970 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-page-service.php'; |
|
| 971 | 971 | |
| 972 | 972 | /** Linked Data. */ |
| 973 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php'; |
|
| 974 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php'; |
|
| 975 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php'; |
|
| 976 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php'; |
|
| 977 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php'; |
|
| 978 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php'; |
|
| 979 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php'; |
|
| 980 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php'; |
|
| 981 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php'; |
|
| 982 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php'; |
|
| 983 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php'; |
|
| 973 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-storage.php'; |
|
| 974 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-meta-storage.php'; |
|
| 975 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-property-storage.php'; |
|
| 976 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php'; |
|
| 977 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php'; |
|
| 978 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-author-storage.php'; |
|
| 979 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php'; |
|
| 980 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-image-storage.php'; |
|
| 981 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-related-storage.php'; |
|
| 982 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-url-property-storage.php'; |
|
| 983 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-storage-factory.php'; |
|
| 984 | 984 | |
| 985 | 985 | /** Linked Data Rendition. */ |
| 986 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/intf-wordlift-sparql-tuple-rendition.php'; |
|
| 987 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-default-sparql-tuple-rendition.php'; |
|
| 988 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-address-sparql-tuple-rendition.php'; |
|
| 989 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php'; |
|
| 986 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/rendition/intf-wordlift-sparql-tuple-rendition.php'; |
|
| 987 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/rendition/class-wordlift-default-sparql-tuple-rendition.php'; |
|
| 988 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/rendition/class-wordlift-address-sparql-tuple-rendition.php'; |
|
| 989 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php'; |
|
| 990 | 990 | |
| 991 | 991 | /** Services. */ |
| 992 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php'; |
|
| 993 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-api-service.php'; |
|
| 992 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-google-analytics-export-service.php'; |
|
| 993 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-api-service.php'; |
|
| 994 | 994 | |
| 995 | 995 | /** Adapters. */ |
| 996 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php'; |
|
| 997 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php'; |
|
| 998 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php'; |
|
| 999 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php'; |
|
| 1000 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-wprocket-adapter.php'; |
|
| 996 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-tinymce-adapter.php'; |
|
| 997 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-newrelic-adapter.php'; |
|
| 998 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sample-data-ajax-adapter.php'; |
|
| 999 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-type-adapter.php'; |
|
| 1000 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-wprocket-adapter.php'; |
|
| 1001 | 1001 | |
| 1002 | 1002 | /** Async Tasks. */ |
| 1003 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-async-task.php'; |
|
| 1004 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php'; |
|
| 1005 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-push-references-async-task.php'; |
|
| 1003 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/wp-async-task/class-wordlift-async-task.php'; |
|
| 1004 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/wp-async-task/class-wordlift-sparql-query-async-task.php'; |
|
| 1005 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/wp-async-task/class-wordlift-push-references-async-task.php'; |
|
| 1006 | 1006 | |
| 1007 | 1007 | /** Autocomplete. */ |
| 1008 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php'; |
|
| 1008 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-autocomplete-adapter.php'; |
|
| 1009 | 1009 | |
| 1010 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-remote-image-service.php'; |
|
| 1010 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-remote-image-service.php'; |
|
| 1011 | 1011 | |
| 1012 | 1012 | /** Analytics */ |
| 1013 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/analytics/class-wordlift-analytics-connect.php'; |
|
| 1013 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/analytics/class-wordlift-analytics-connect.php'; |
|
| 1014 | 1014 | |
| 1015 | 1015 | /** |
| 1016 | 1016 | * The class responsible for defining all actions that occur in the admin area. |
| 1017 | 1017 | */ |
| 1018 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 1018 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin.php'; |
|
| 1019 | 1019 | |
| 1020 | 1020 | /** |
| 1021 | 1021 | * The class to customize the entity list admin page. |
| 1022 | 1022 | */ |
| 1023 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 1023 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-entity-list.php'; |
|
| 1024 | 1024 | |
| 1025 | 1025 | /** |
| 1026 | 1026 | * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
| 1027 | 1027 | */ |
| 1028 | 1028 | global $wp_version; |
| 1029 | - if ( version_compare( $wp_version, '5.3', '<' ) ) { |
|
| 1030 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 1029 | + if (version_compare($wp_version, '5.3', '<')) { |
|
| 1030 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 1031 | 1031 | } else { |
| 1032 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker-5-3.php'; |
|
| 1032 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-types-taxonomy-walker-5-3.php'; |
|
| 1033 | 1033 | } |
| 1034 | 1034 | |
| 1035 | 1035 | /** |
| 1036 | 1036 | * The Notice service. |
| 1037 | 1037 | */ |
| 1038 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 1038 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-notice-service.php'; |
|
| 1039 | 1039 | |
| 1040 | 1040 | /** |
| 1041 | 1041 | * The PrimaShop adapter. |
| 1042 | 1042 | */ |
| 1043 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 1043 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-primashop-adapter.php'; |
|
| 1044 | 1044 | |
| 1045 | 1045 | /** |
| 1046 | 1046 | * The WordLift Dashboard service. |
| 1047 | 1047 | */ |
| 1048 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 1048 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-dashboard.php'; |
|
| 1049 | 1049 | |
| 1050 | 1050 | /** |
| 1051 | 1051 | * The admin 'Install wizard' page. |
| 1052 | 1052 | */ |
| 1053 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php'; |
|
| 1053 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-setup.php'; |
|
| 1054 | 1054 | |
| 1055 | 1055 | /** |
| 1056 | 1056 | * The WordLift entity type list admin page controller. |
| 1057 | 1057 | */ |
| 1058 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 1058 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 1059 | 1059 | |
| 1060 | 1060 | /** |
| 1061 | 1061 | * The WordLift entity type settings admin page controller. |
| 1062 | 1062 | */ |
| 1063 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php'; |
|
| 1063 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-type-settings.php'; |
|
| 1064 | 1064 | |
| 1065 | 1065 | /** |
| 1066 | 1066 | * The admin 'Download Your Data' page. |
| 1067 | 1067 | */ |
| 1068 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 1068 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-download-your-data-page.php'; |
|
| 1069 | 1069 | |
| 1070 | 1070 | /** |
| 1071 | 1071 | * The admin 'WordLift Settings' page. |
| 1072 | 1072 | */ |
| 1073 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/intf-wordlift-admin-element.php'; |
|
| 1074 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-element.php'; |
|
| 1075 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-radio-element.php'; |
|
| 1076 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select-element.php'; |
|
| 1077 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select2-element.php'; |
|
| 1078 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-language-select-element.php'; |
|
| 1079 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-country-select-element.php'; |
|
| 1080 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-tabs-element.php'; |
|
| 1081 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-author-element.php'; |
|
| 1082 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-publisher-element.php'; |
|
| 1083 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php'; |
|
| 1084 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php'; |
|
| 1085 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page.php'; |
|
| 1086 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 1087 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page-action-link.php'; |
|
| 1073 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/intf-wordlift-admin-element.php'; |
|
| 1074 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/class-wordlift-admin-input-element.php'; |
|
| 1075 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/class-wordlift-admin-input-radio-element.php'; |
|
| 1076 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/class-wordlift-admin-select-element.php'; |
|
| 1077 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/class-wordlift-admin-select2-element.php'; |
|
| 1078 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/class-wordlift-admin-language-select-element.php'; |
|
| 1079 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/class-wordlift-admin-country-select-element.php'; |
|
| 1080 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/class-wordlift-admin-tabs-element.php'; |
|
| 1081 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/class-wordlift-admin-author-element.php'; |
|
| 1082 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/class-wordlift-admin-publisher-element.php'; |
|
| 1083 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-page.php'; |
|
| 1084 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-settings-page.php'; |
|
| 1085 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-settings-analytics-page.php'; |
|
| 1086 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 1087 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-settings-analytics-page-action-link.php'; |
|
| 1088 | 1088 | |
| 1089 | 1089 | /** Admin Pages */ |
| 1090 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php'; |
|
| 1091 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php'; |
|
| 1092 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-search-rankings-page.php'; |
|
| 1093 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php'; |
|
| 1090 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-user-profile-page.php'; |
|
| 1091 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-status-page.php'; |
|
| 1092 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-search-rankings-page.php'; |
|
| 1093 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-type-admin-service.php'; |
|
| 1094 | 1094 | |
| 1095 | 1095 | /** |
| 1096 | 1096 | * The class responsible for defining all actions that occur in the public-facing |
| 1097 | 1097 | * side of the site. |
| 1098 | 1098 | */ |
| 1099 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 1099 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-public.php'; |
|
| 1100 | 1100 | |
| 1101 | 1101 | /** |
| 1102 | 1102 | * The shortcode abstract class. |
| 1103 | 1103 | */ |
| 1104 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 1104 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-shortcode.php'; |
|
| 1105 | 1105 | |
| 1106 | 1106 | /** |
| 1107 | 1107 | * The Timeline shortcode. |
| 1108 | 1108 | */ |
| 1109 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 1109 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-timeline-shortcode.php'; |
|
| 1110 | 1110 | |
| 1111 | 1111 | /** |
| 1112 | 1112 | * The Navigator shortcode. |
| 1113 | 1113 | */ |
| 1114 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 1114 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-navigator-shortcode.php'; |
|
| 1115 | 1115 | |
| 1116 | 1116 | /** |
| 1117 | 1117 | * The Products Navigator shortcode. |
| 1118 | 1118 | */ |
| 1119 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-products-navigator-shortcode.php'; |
|
| 1119 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-products-navigator-shortcode.php'; |
|
| 1120 | 1120 | |
| 1121 | 1121 | /** |
| 1122 | 1122 | * The chord shortcode. |
| 1123 | 1123 | */ |
| 1124 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 1124 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-chord-shortcode.php'; |
|
| 1125 | 1125 | |
| 1126 | 1126 | /** |
| 1127 | 1127 | * The geomap shortcode. |
| 1128 | 1128 | */ |
| 1129 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 1129 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-geomap-shortcode.php'; |
|
| 1130 | 1130 | |
| 1131 | 1131 | /** |
| 1132 | 1132 | * The entity cloud shortcode. |
| 1133 | 1133 | */ |
| 1134 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 1134 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 1135 | 1135 | |
| 1136 | 1136 | /** |
| 1137 | 1137 | * The entity glossary shortcode. |
| 1138 | 1138 | */ |
| 1139 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php'; |
|
| 1140 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php'; |
|
| 1139 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-alphabet-service.php'; |
|
| 1140 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-vocabulary-shortcode.php'; |
|
| 1141 | 1141 | |
| 1142 | 1142 | /** |
| 1143 | 1143 | * Faceted Search shortcode. |
| 1144 | 1144 | */ |
| 1145 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-faceted-search-shortcode.php'; |
|
| 1145 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-faceted-search-shortcode.php'; |
|
| 1146 | 1146 | |
| 1147 | 1147 | /** |
| 1148 | 1148 | * The ShareThis service. |
| 1149 | 1149 | */ |
| 1150 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 1150 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-sharethis-service.php'; |
|
| 1151 | 1151 | |
| 1152 | 1152 | /** |
| 1153 | 1153 | * The SEO service. |
| 1154 | 1154 | */ |
| 1155 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php'; |
|
| 1155 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-seo-service.php'; |
|
| 1156 | 1156 | |
| 1157 | 1157 | /** |
| 1158 | 1158 | * The AMP service. |
| 1159 | 1159 | */ |
| 1160 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php'; |
|
| 1160 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-amp-service.php'; |
|
| 1161 | 1161 | |
| 1162 | 1162 | /** Widgets */ |
| 1163 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php'; |
|
| 1164 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 1165 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-context-cards.php'; |
|
| 1163 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-widget.php'; |
|
| 1164 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 1165 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-context-cards.php'; |
|
| 1166 | 1166 | |
| 1167 | 1167 | /* |
| 1168 | 1168 | * Schema.org Services. |
| 1169 | 1169 | * |
| 1170 | 1170 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
| 1171 | 1171 | */ |
| 1172 | - if ( WL_ALL_ENTITY_TYPES ) { |
|
| 1173 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-sync-service.php'; |
|
| 1174 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-property-service.php'; |
|
| 1175 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-class-service.php'; |
|
| 1172 | + if (WL_ALL_ENTITY_TYPES) { |
|
| 1173 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/schemaorg/class-wordlift-schemaorg-sync-service.php'; |
|
| 1174 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/schemaorg/class-wordlift-schemaorg-property-service.php'; |
|
| 1175 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/schemaorg/class-wordlift-schemaorg-class-service.php'; |
|
| 1176 | 1176 | new Wordlift_Schemaorg_Sync_Service(); |
| 1177 | 1177 | $schemaorg_property_service = new Wordlift_Schemaorg_Property_Service(); |
| 1178 | 1178 | new Wordlift_Schemaorg_Class_Service(); |
@@ -1184,25 +1184,25 @@ discard block |
||
| 1184 | 1184 | |
| 1185 | 1185 | // Instantiate a global logger. |
| 1186 | 1186 | global $wl_logger; |
| 1187 | - $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 1187 | + $wl_logger = Wordlift_Log_Service::get_logger('WordLift'); |
|
| 1188 | 1188 | |
| 1189 | 1189 | // Load the `wl-api` end-point. |
| 1190 | 1190 | new Wordlift_Http_Api(); |
| 1191 | 1191 | |
| 1192 | 1192 | // Load the Install Service. |
| 1193 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-service.php'; |
|
| 1193 | + require_once plugin_dir_path(dirname(__FILE__)).'install/class-wordlift-install-service.php'; |
|
| 1194 | 1194 | $this->install_service = new Wordlift_Install_Service(); |
| 1195 | 1195 | |
| 1196 | 1196 | /** Services. */ |
| 1197 | 1197 | // Create the configuration service. |
| 1198 | 1198 | $this->configuration_service = new Wordlift_Configuration_Service(); |
| 1199 | - $api_service = new Wordlift_Api_Service( $this->configuration_service ); |
|
| 1199 | + $api_service = new Wordlift_Api_Service($this->configuration_service); |
|
| 1200 | 1200 | |
| 1201 | 1201 | // Create an entity type service instance. It'll be later bound to the init action. |
| 1202 | - $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() ); |
|
| 1202 | + $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service(Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path()); |
|
| 1203 | 1203 | |
| 1204 | 1204 | // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
| 1205 | - $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() ); |
|
| 1205 | + $this->entity_link_service = new Wordlift_Entity_Link_Service($this->entity_post_type_service, $this->configuration_service->get_entity_base_path()); |
|
| 1206 | 1206 | |
| 1207 | 1207 | // Create an instance of the UI service. |
| 1208 | 1208 | $this->ui_service = new Wordlift_UI_Service(); |
@@ -1211,34 +1211,34 @@ discard block |
||
| 1211 | 1211 | $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
| 1212 | 1212 | |
| 1213 | 1213 | $this->sparql_service = new Wordlift_Sparql_Service(); |
| 1214 | - $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 1214 | + $schema_url_property_service = new Wordlift_Schema_Url_Property_Service($this->sparql_service); |
|
| 1215 | 1215 | $this->notice_service = new Wordlift_Notice_Service(); |
| 1216 | 1216 | $this->relation_service = new Wordlift_Relation_Service(); |
| 1217 | 1217 | |
| 1218 | - $entity_uri_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'entity_uri/' ); |
|
| 1219 | - $this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service( $this->configuration_service, $entity_uri_cache_service ); |
|
| 1220 | - $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service, $this->entity_uri_service ); |
|
| 1221 | - $this->user_service = new Wordlift_User_Service( $this->sparql_service, $this->entity_service ); |
|
| 1218 | + $entity_uri_cache_service = new Wordlift_File_Cache_Service(WL_TEMP_DIR.'entity_uri/'); |
|
| 1219 | + $this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service($this->configuration_service, $entity_uri_cache_service); |
|
| 1220 | + $this->entity_service = new Wordlift_Entity_Service($this->ui_service, $this->relation_service, $this->entity_uri_service); |
|
| 1221 | + $this->user_service = new Wordlift_User_Service($this->sparql_service, $this->entity_service); |
|
| 1222 | 1222 | |
| 1223 | 1223 | // Instantiate the JSON-LD service. |
| 1224 | - $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 1224 | + $property_getter = Wordlift_Property_Getter_Factory::create($this->entity_service); |
|
| 1225 | 1225 | |
| 1226 | 1226 | /** Linked Data. */ |
| 1227 | - $this->storage_factory = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter ); |
|
| 1228 | - $this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service ); |
|
| 1227 | + $this->storage_factory = new Wordlift_Storage_Factory($this->entity_service, $this->user_service, $property_getter); |
|
| 1228 | + $this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory($this->entity_service); |
|
| 1229 | 1229 | |
| 1230 | - $this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service ); |
|
| 1230 | + $this->schema_service = new Wordlift_Schema_Service($this->storage_factory, $this->rendition_factory, $this->configuration_service); |
|
| 1231 | 1231 | |
| 1232 | 1232 | // Create a new instance of the Redirect service. |
| 1233 | - $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_uri_service ); |
|
| 1234 | - $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service ); |
|
| 1233 | + $this->redirect_service = new Wordlift_Redirect_Service($this->entity_uri_service); |
|
| 1234 | + $this->entity_type_service = new Wordlift_Entity_Type_Service($this->schema_service); |
|
| 1235 | 1235 | |
| 1236 | - if ( apply_filters( 'wl_feature__enable__dataset-ng', false ) ) { |
|
| 1237 | - new Wordlift_Linked_Data_Service( $this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service ); |
|
| 1236 | + if (apply_filters('wl_feature__enable__dataset-ng', false)) { |
|
| 1237 | + new Wordlift_Linked_Data_Service($this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service); |
|
| 1238 | 1238 | } |
| 1239 | 1239 | |
| 1240 | 1240 | // Create a new instance of the Timeline service and Timeline shortcode. |
| 1241 | - $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service ); |
|
| 1241 | + $this->timeline_service = new Wordlift_Timeline_Service($this->entity_service, $this->entity_type_service); |
|
| 1242 | 1242 | |
| 1243 | 1243 | $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
| 1244 | 1244 | |
@@ -1252,36 +1252,36 @@ discard block |
||
| 1252 | 1252 | $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
| 1253 | 1253 | |
| 1254 | 1254 | // Create an import service instance to hook later to WP's import function. |
| 1255 | - $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() ); |
|
| 1255 | + $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()); |
|
| 1256 | 1256 | |
| 1257 | - $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 1257 | + $uri_service = new Wordlift_Uri_Service($GLOBALS['wpdb']); |
|
| 1258 | 1258 | |
| 1259 | 1259 | // Create the entity rating service. |
| 1260 | - $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service ); |
|
| 1260 | + $this->rating_service = new Wordlift_Rating_Service($this->entity_service, $this->entity_type_service, $this->notice_service); |
|
| 1261 | 1261 | |
| 1262 | 1262 | // Create entity list customization (wp-admin/edit.php). |
| 1263 | - $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service ); |
|
| 1263 | + $this->entity_list_service = new Wordlift_Entity_List_Service($this->rating_service); |
|
| 1264 | 1264 | |
| 1265 | 1265 | // Create a new instance of the Redirect service. |
| 1266 | - $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service ); |
|
| 1266 | + $this->dashboard_service = new Wordlift_Dashboard_Service($this->rating_service, $this->entity_service); |
|
| 1267 | 1267 | |
| 1268 | 1268 | // Create an instance of the Publisher Service and the AJAX Adapter. |
| 1269 | - $this->publisher_service = new Wordlift_Publisher_Service( $this->configuration_service ); |
|
| 1270 | - $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 1271 | - $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 1269 | + $this->publisher_service = new Wordlift_Publisher_Service($this->configuration_service); |
|
| 1270 | + $this->property_factory = new Wordlift_Property_Factory($schema_url_property_service); |
|
| 1271 | + $this->property_factory->register(Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service); |
|
| 1272 | 1272 | |
| 1273 | 1273 | $attachment_service = new Wordlift_Attachment_Service(); |
| 1274 | 1274 | |
| 1275 | 1275 | // Instantiate the JSON-LD service. |
| 1276 | - $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 1277 | - $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 ); |
|
| 1278 | - $this->entity_post_to_jsonld_converter = new Wordlift_Entity_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $property_getter, $schemaorg_property_service, $this->post_to_jsonld_converter ); |
|
| 1279 | - $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 ); |
|
| 1280 | - $this->jsonld_website_converter = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service ); |
|
| 1276 | + $property_getter = Wordlift_Property_Getter_Factory::create($this->entity_service); |
|
| 1277 | + $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); |
|
| 1278 | + $this->entity_post_to_jsonld_converter = new Wordlift_Entity_Post_To_Jsonld_Converter($this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $property_getter, $schemaorg_property_service, $this->post_to_jsonld_converter); |
|
| 1279 | + $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); |
|
| 1280 | + $this->jsonld_website_converter = new Wordlift_Website_Jsonld_Converter($this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service); |
|
| 1281 | 1281 | |
| 1282 | - $jsonld_cache = new Ttl_Cache( 'jsonld', 86400 ); |
|
| 1283 | - $this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $this->postid_to_jsonld_converter, $this->configuration_service, $jsonld_cache ); |
|
| 1284 | - $this->jsonld_service = new Wordlift_Jsonld_Service( $this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter ); |
|
| 1282 | + $jsonld_cache = new Ttl_Cache('jsonld', 86400); |
|
| 1283 | + $this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter($this->postid_to_jsonld_converter, $this->configuration_service, $jsonld_cache); |
|
| 1284 | + $this->jsonld_service = new Wordlift_Jsonld_Service($this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter); |
|
| 1285 | 1285 | |
| 1286 | 1286 | /* |
| 1287 | 1287 | * Load the `Wordlift_Term_JsonLd_Adapter`. |
@@ -1290,29 +1290,29 @@ discard block |
||
| 1290 | 1290 | * |
| 1291 | 1291 | * @since 3.20.0 |
| 1292 | 1292 | */ |
| 1293 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-term-jsonld-adapter.php'; |
|
| 1294 | - $term_jsonld_adapter = new Wordlift_Term_JsonLd_Adapter( $this->entity_uri_service, $this->jsonld_service ); |
|
| 1293 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-term-jsonld-adapter.php'; |
|
| 1294 | + $term_jsonld_adapter = new Wordlift_Term_JsonLd_Adapter($this->entity_uri_service, $this->jsonld_service); |
|
| 1295 | 1295 | $jsonld_service = new Jsonld_Service( |
| 1296 | 1296 | $this->jsonld_service, |
| 1297 | 1297 | $term_jsonld_adapter, |
| 1298 | - new Jsonld_User_Service( $this->user_service ) ); |
|
| 1299 | - new Jsonld_Endpoint( $jsonld_service, $this->entity_uri_service ); |
|
| 1298 | + new Jsonld_User_Service($this->user_service) ); |
|
| 1299 | + new Jsonld_Endpoint($jsonld_service, $this->entity_uri_service); |
|
| 1300 | 1300 | |
| 1301 | 1301 | // Prints the JSON-LD in the head. |
| 1302 | - new Jsonld_Adapter( $this->jsonld_service ); |
|
| 1302 | + new Jsonld_Adapter($this->jsonld_service); |
|
| 1303 | 1303 | |
| 1304 | - new Jsonld_By_Id_Endpoint( $this->jsonld_service, $this->entity_uri_service ); |
|
| 1304 | + new Jsonld_By_Id_Endpoint($this->jsonld_service, $this->entity_uri_service); |
|
| 1305 | 1305 | |
| 1306 | - $this->key_validation_service = new Wordlift_Key_Validation_Service( $this->configuration_service ); |
|
| 1307 | - $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service, $this->entity_uri_service ); |
|
| 1306 | + $this->key_validation_service = new Wordlift_Key_Validation_Service($this->configuration_service); |
|
| 1307 | + $this->content_filter_service = new Wordlift_Content_Filter_Service($this->entity_service, $this->configuration_service, $this->entity_uri_service); |
|
| 1308 | 1308 | // Creating Faq Content filter service. |
| 1309 | 1309 | $this->faq_content_filter_service = new Faq_Content_Filter(); |
| 1310 | - $this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service ); |
|
| 1311 | - $this->sample_data_service = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service, $this->user_service ); |
|
| 1312 | - $this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service ); |
|
| 1313 | - $this->reference_rebuild_service = new Wordlift_Reference_Rebuild_Service( $this->entity_service ); |
|
| 1310 | + $this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service($this->content_filter_service, $this->entity_service); |
|
| 1311 | + $this->sample_data_service = new Wordlift_Sample_Data_Service($this->entity_type_service, $this->configuration_service, $this->user_service); |
|
| 1312 | + $this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter($this->sample_data_service); |
|
| 1313 | + $this->reference_rebuild_service = new Wordlift_Reference_Rebuild_Service($this->entity_service); |
|
| 1314 | 1314 | |
| 1315 | - $this->loader->add_action( 'enqueue_block_editor_assets', $this, 'add_wl_enabled_blocks' ); |
|
| 1315 | + $this->loader->add_action('enqueue_block_editor_assets', $this, 'add_wl_enabled_blocks'); |
|
| 1316 | 1316 | |
| 1317 | 1317 | /** |
| 1318 | 1318 | * Filter: wl_feature__enable__blocks. |
@@ -1322,14 +1322,14 @@ discard block |
||
| 1322 | 1322 | * @return bool |
| 1323 | 1323 | * @since 3.27.6 |
| 1324 | 1324 | */ |
| 1325 | - if ( apply_filters( 'wl_feature__enable__blocks', true ) ) { |
|
| 1325 | + if (apply_filters('wl_feature__enable__blocks', true)) { |
|
| 1326 | 1326 | // Initialize the short-codes. |
| 1327 | 1327 | new Wordlift_Navigator_Shortcode(); |
| 1328 | 1328 | new Wordlift_Chord_Shortcode(); |
| 1329 | 1329 | new Wordlift_Geomap_Shortcode(); |
| 1330 | 1330 | new Wordlift_Timeline_Shortcode(); |
| 1331 | - new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service ); |
|
| 1332 | - new Wordlift_Vocabulary_Shortcode( $this->configuration_service ); |
|
| 1331 | + new Wordlift_Related_Entities_Cloud_Shortcode($this->relation_service); |
|
| 1332 | + new Wordlift_Vocabulary_Shortcode($this->configuration_service); |
|
| 1333 | 1333 | new Wordlift_Faceted_Search_Shortcode(); |
| 1334 | 1334 | /** |
| 1335 | 1335 | * @since ?.??.? |
@@ -1348,18 +1348,18 @@ discard block |
||
| 1348 | 1348 | new Wordlift_Seo_Service(); |
| 1349 | 1349 | |
| 1350 | 1350 | // Initialize the AMP service. |
| 1351 | - new Wordlift_AMP_Service( $this->jsonld_service ); |
|
| 1351 | + new Wordlift_AMP_Service($this->jsonld_service); |
|
| 1352 | 1352 | |
| 1353 | 1353 | /** Services. */ |
| 1354 | 1354 | $this->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service(); |
| 1355 | 1355 | new Wordlift_Image_Service(); |
| 1356 | 1356 | |
| 1357 | 1357 | /** Adapters. */ |
| 1358 | - $this->entity_type_adapter = new Wordlift_Entity_Type_Adapter( $this->entity_type_service ); |
|
| 1359 | - $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $this->publisher_service ); |
|
| 1360 | - $this->tinymce_adapter = new Wordlift_Tinymce_Adapter( $this ); |
|
| 1358 | + $this->entity_type_adapter = new Wordlift_Entity_Type_Adapter($this->entity_type_service); |
|
| 1359 | + $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter($this->publisher_service); |
|
| 1360 | + $this->tinymce_adapter = new Wordlift_Tinymce_Adapter($this); |
|
| 1361 | 1361 | //$this->faq_tinymce_adapter = new Faq_Tinymce_Adapter(); |
| 1362 | - $this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service ); |
|
| 1362 | + $this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter($this->relation_rebuild_service); |
|
| 1363 | 1363 | |
| 1364 | 1364 | /* |
| 1365 | 1365 | * Exclude our public js from WP-Rocket. |
@@ -1377,7 +1377,7 @@ discard block |
||
| 1377 | 1377 | ); |
| 1378 | 1378 | |
| 1379 | 1379 | /** Async Tasks. */ |
| 1380 | - if ( ! apply_filters( 'wl_feature__enable__dataset-ng', false ) ) { |
|
| 1380 | + if ( ! apply_filters('wl_feature__enable__dataset-ng', false)) { |
|
| 1381 | 1381 | new Wordlift_Sparql_Query_Async_Task(); |
| 1382 | 1382 | new Wordlift_Push_References_Async_Task(); |
| 1383 | 1383 | } |
@@ -1391,14 +1391,14 @@ discard block |
||
| 1391 | 1391 | $this->language_select_element = new Wordlift_Admin_Language_Select_Element(); |
| 1392 | 1392 | $this->country_select_element = new Wordlift_Admin_Country_Select_Element(); |
| 1393 | 1393 | $tabs_element = new Wordlift_Admin_Tabs_Element(); |
| 1394 | - $this->publisher_element = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $this->publisher_service, $tabs_element, $this->select2_element ); |
|
| 1395 | - $this->author_element = new Wordlift_Admin_Author_Element( $this->publisher_service, $this->select2_element ); |
|
| 1394 | + $this->publisher_element = new Wordlift_Admin_Publisher_Element($this->configuration_service, $this->publisher_service, $tabs_element, $this->select2_element); |
|
| 1395 | + $this->author_element = new Wordlift_Admin_Author_Element($this->publisher_service, $this->select2_element); |
|
| 1396 | 1396 | |
| 1397 | - $this->settings_page = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->country_select_element, $this->publisher_element, $this->radio_input_element ); |
|
| 1398 | - $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page ); |
|
| 1397 | + $this->settings_page = new Wordlift_Admin_Settings_Page($this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->country_select_element, $this->publisher_element, $this->radio_input_element); |
|
| 1398 | + $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link($this->settings_page); |
|
| 1399 | 1399 | |
| 1400 | - $this->analytics_settings_page = new Wordlift_Admin_Settings_Analytics_Page( $this->configuration_service, $this->input_element, $this->radio_input_element ); |
|
| 1401 | - $this->analytics_settings_page_action_link = new Wordlift_Admin_Settings_Analytics_Page_Action_Link( $this->analytics_settings_page ); |
|
| 1400 | + $this->analytics_settings_page = new Wordlift_Admin_Settings_Analytics_Page($this->configuration_service, $this->input_element, $this->radio_input_element); |
|
| 1401 | + $this->analytics_settings_page_action_link = new Wordlift_Admin_Settings_Analytics_Page_Action_Link($this->analytics_settings_page); |
|
| 1402 | 1402 | $this->analytics_connect = new Wordlift_Analytics_Connect(); |
| 1403 | 1403 | |
| 1404 | 1404 | // Pages. |
@@ -1409,9 +1409,9 @@ discard block |
||
| 1409 | 1409 | * |
| 1410 | 1410 | * @see https://github.com/insideout10/wordlift-plugin/issues/914 |
| 1411 | 1411 | */ |
| 1412 | - if ( apply_filters( 'wl_can_see_classification_box', true ) ) { |
|
| 1413 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 1414 | - new Wordlift_Admin_Post_Edit_Page( $this ); |
|
| 1412 | + if (apply_filters('wl_can_see_classification_box', true)) { |
|
| 1413 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 1414 | + new Wordlift_Admin_Post_Edit_Page($this); |
|
| 1415 | 1415 | } |
| 1416 | 1416 | new Wordlift_Entity_Type_Admin_Service(); |
| 1417 | 1417 | |
@@ -1425,23 +1425,23 @@ discard block |
||
| 1425 | 1425 | $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget(); |
| 1426 | 1426 | |
| 1427 | 1427 | /* WordPress Admin. */ |
| 1428 | - $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 1429 | - $this->status_page = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service ); |
|
| 1428 | + $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page($this->configuration_service); |
|
| 1429 | + $this->status_page = new Wordlift_Admin_Status_Page($this->entity_service, $this->sparql_service); |
|
| 1430 | 1430 | |
| 1431 | 1431 | // Create an instance of the install wizard. |
| 1432 | - $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service, $this->language_select_element, $this->country_select_element ); |
|
| 1432 | + $this->admin_setup = new Wordlift_Admin_Setup($this->configuration_service, $this->key_validation_service, $this->entity_service, $this->language_select_element, $this->country_select_element); |
|
| 1433 | 1433 | |
| 1434 | - $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service ); |
|
| 1434 | + $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service($this->entity_post_type_service); |
|
| 1435 | 1435 | |
| 1436 | 1436 | // User Profile. |
| 1437 | - new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service ); |
|
| 1437 | + new Wordlift_Admin_User_Profile_Page($this->author_element, $this->user_service); |
|
| 1438 | 1438 | |
| 1439 | 1439 | $this->entity_page_service = new Wordlift_Entity_Page_Service(); |
| 1440 | 1440 | |
| 1441 | 1441 | // Load the debug service if WP is in debug mode. |
| 1442 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 1443 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 1444 | - new Wordlift_Debug_Service( $this->entity_service, $uri_service ); |
|
| 1442 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
| 1443 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-debug-service.php'; |
|
| 1444 | + new Wordlift_Debug_Service($this->entity_service, $uri_service); |
|
| 1445 | 1445 | } |
| 1446 | 1446 | |
| 1447 | 1447 | // Remote Image Service. |
@@ -1454,12 +1454,12 @@ discard block |
||
| 1454 | 1454 | * |
| 1455 | 1455 | * @see https://github.com/insideout10/wordlift-plugin/issues/852. |
| 1456 | 1456 | */ |
| 1457 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-action.php'; |
|
| 1458 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-service.php'; |
|
| 1459 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-ajax-adapter.php'; |
|
| 1457 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-batch-action.php'; |
|
| 1458 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/mapping/class-wordlift-mapping-service.php'; |
|
| 1459 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/mapping/class-wordlift-mapping-ajax-adapter.php'; |
|
| 1460 | 1460 | |
| 1461 | 1461 | // Create an instance of the Mapping Service and assign it to the Ajax Adapter. |
| 1462 | - new Wordlift_Mapping_Ajax_Adapter( new Wordlift_Mapping_Service( Wordlift_Entity_Type_Service::get_instance() ) ); |
|
| 1462 | + new Wordlift_Mapping_Ajax_Adapter(new Wordlift_Mapping_Service(Wordlift_Entity_Type_Service::get_instance())); |
|
| 1463 | 1463 | |
| 1464 | 1464 | /* |
| 1465 | 1465 | * Batch Operations. They're similar to Batch Actions but do not require working on post types. |
@@ -1468,8 +1468,8 @@ discard block |
||
| 1468 | 1468 | * |
| 1469 | 1469 | * @since 3.20.0 |
| 1470 | 1470 | */ |
| 1471 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/intf-wordlift-batch-operation.php'; |
|
| 1472 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/class-wordlift-batch-operation-ajax-adapter.php'; |
|
| 1471 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/batch/intf-wordlift-batch-operation.php'; |
|
| 1472 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/batch/class-wordlift-batch-operation-ajax-adapter.php'; |
|
| 1473 | 1473 | |
| 1474 | 1474 | /* |
| 1475 | 1475 | * Add the Search Keywords taxonomy to manage the Search Keywords on WLS. |
@@ -1478,8 +1478,8 @@ discard block |
||
| 1478 | 1478 | * |
| 1479 | 1479 | * @since 3.20.0 |
| 1480 | 1480 | */ |
| 1481 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/search-keywords/class-wordlift-search-keyword-taxonomy.php'; |
|
| 1482 | - new Wordlift_Search_Keyword_Taxonomy( $api_service ); |
|
| 1481 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/search-keywords/class-wordlift-search-keyword-taxonomy.php'; |
|
| 1482 | + new Wordlift_Search_Keyword_Taxonomy($api_service); |
|
| 1483 | 1483 | |
| 1484 | 1484 | /* |
| 1485 | 1485 | * Load the Mappings JSON-LD post processing. |
@@ -1492,11 +1492,11 @@ discard block |
||
| 1492 | 1492 | new Post_Type_Rule_Validator(); |
| 1493 | 1493 | // Taxonomy term rule validator for validating rules for term pages. |
| 1494 | 1494 | new Taxonomy_Term_Rule_Validator(); |
| 1495 | - $rule_validators_registry = new Rule_Validators_Registry( $default_rule_validator ); |
|
| 1496 | - $rule_groups_validator = new Rule_Groups_Validator( $rule_validators_registry ); |
|
| 1497 | - $mappings_validator = new Mappings_Validator( $mappings_dbo, $rule_groups_validator ); |
|
| 1495 | + $rule_validators_registry = new Rule_Validators_Registry($default_rule_validator); |
|
| 1496 | + $rule_groups_validator = new Rule_Groups_Validator($rule_validators_registry); |
|
| 1497 | + $mappings_validator = new Mappings_Validator($mappings_dbo, $rule_groups_validator); |
|
| 1498 | 1498 | |
| 1499 | - new Url_To_Entity_Transform_Function( $this->entity_uri_service ); |
|
| 1499 | + new Url_To_Entity_Transform_Function($this->entity_uri_service); |
|
| 1500 | 1500 | new Taxonomy_To_Terms_Transform_Function(); |
| 1501 | 1501 | new Post_Id_To_Entity_Transform_Function(); |
| 1502 | 1502 | $mappings_transform_functions_registry = new Mappings_Transform_Functions_Registry(); |
@@ -1506,7 +1506,7 @@ discard block |
||
| 1506 | 1506 | * Intiailize the acf group data formatter. |
| 1507 | 1507 | */ |
| 1508 | 1508 | new Acf_Group_Formatter(); |
| 1509 | - new Jsonld_Converter( $mappings_validator, $mappings_transform_functions_registry ); |
|
| 1509 | + new Jsonld_Converter($mappings_validator, $mappings_transform_functions_registry); |
|
| 1510 | 1510 | |
| 1511 | 1511 | /** |
| 1512 | 1512 | * @since 3.26.0 |
@@ -1527,7 +1527,7 @@ discard block |
||
| 1527 | 1527 | /* |
| 1528 | 1528 | * Create a singleton for the Analysis_Response_Ops_Factory. |
| 1529 | 1529 | */ |
| 1530 | - $entity_helper = new Entity_Helper( $this->entity_uri_service, $this->entity_service ); |
|
| 1530 | + $entity_helper = new Entity_Helper($this->entity_uri_service, $this->entity_service); |
|
| 1531 | 1531 | new Analysis_Response_Ops_Factory( |
| 1532 | 1532 | $this->entity_uri_service, |
| 1533 | 1533 | $this->entity_service, |
@@ -1537,11 +1537,11 @@ discard block |
||
| 1537 | 1537 | ); |
| 1538 | 1538 | |
| 1539 | 1539 | /** WL Autocomplete. */ |
| 1540 | - $autocomplete_service = new All_Autocomplete_Service( array( |
|
| 1540 | + $autocomplete_service = new All_Autocomplete_Service(array( |
|
| 1541 | 1541 | new Local_Autocomplete_Service(), |
| 1542 | - new Linked_Data_Autocomplete_Service( $this->configuration_service, $entity_helper, $this->entity_uri_service, $this->entity_service ), |
|
| 1543 | - ) ); |
|
| 1544 | - $this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $autocomplete_service ); |
|
| 1542 | + new Linked_Data_Autocomplete_Service($this->configuration_service, $entity_helper, $this->entity_uri_service, $this->entity_service), |
|
| 1543 | + )); |
|
| 1544 | + $this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter($autocomplete_service); |
|
| 1545 | 1545 | |
| 1546 | 1546 | /** |
| 1547 | 1547 | * @since 3.27.2 |
@@ -1550,10 +1550,10 @@ discard block |
||
| 1550 | 1550 | */ |
| 1551 | 1551 | new Recipe_Maker_Post_Type_Hook(); |
| 1552 | 1552 | $recipe_maker_validation_service = new Recipe_Maker_Validation_Service(); |
| 1553 | - new Recipe_Maker_Jsonld_Hook( $attachment_service, $recipe_maker_validation_service ); |
|
| 1554 | - new Recipe_Maker_After_Get_Jsonld_Hook( $recipe_maker_validation_service ); |
|
| 1555 | - new Recipe_Maker_Warning( $recipe_maker_validation_service ); |
|
| 1556 | - new Yoast_Jsonld( $recipe_maker_validation_service ); |
|
| 1553 | + new Recipe_Maker_Jsonld_Hook($attachment_service, $recipe_maker_validation_service); |
|
| 1554 | + new Recipe_Maker_After_Get_Jsonld_Hook($recipe_maker_validation_service); |
|
| 1555 | + new Recipe_Maker_Warning($recipe_maker_validation_service); |
|
| 1556 | + new Yoast_Jsonld($recipe_maker_validation_service); |
|
| 1557 | 1557 | |
| 1558 | 1558 | /** |
| 1559 | 1559 | * @since 3.27.4 |
@@ -1574,9 +1574,9 @@ discard block |
||
| 1574 | 1574 | private function set_locale() { |
| 1575 | 1575 | |
| 1576 | 1576 | $plugin_i18n = new Wordlift_i18n(); |
| 1577 | - $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 1577 | + $plugin_i18n->set_domain($this->get_plugin_name()); |
|
| 1578 | 1578 | |
| 1579 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 1579 | + $this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain'); |
|
| 1580 | 1580 | |
| 1581 | 1581 | } |
| 1582 | 1582 | |
@@ -1597,29 +1597,29 @@ discard block |
||
| 1597 | 1597 | $this->user_service |
| 1598 | 1598 | ); |
| 1599 | 1599 | |
| 1600 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 1601 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts', 11 ); |
|
| 1600 | + $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles'); |
|
| 1601 | + $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts', 11); |
|
| 1602 | 1602 | |
| 1603 | 1603 | // Hook the init action to taxonomy services. |
| 1604 | - $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 1605 | - $this->loader->add_action( 'init', $this->entity_types_taxonomy_service, 'init', 0 ); |
|
| 1604 | + $this->loader->add_action('init', $this->topic_taxonomy_service, 'init', 0); |
|
| 1605 | + $this->loader->add_action('init', $this->entity_types_taxonomy_service, 'init', 0); |
|
| 1606 | 1606 | |
| 1607 | 1607 | // Hook the deleted_post_meta action to the Thumbnail service. |
| 1608 | - $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 1608 | + $this->loader->add_action('deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4); |
|
| 1609 | 1609 | |
| 1610 | 1610 | // Hook the added_post_meta action to the Thumbnail service. |
| 1611 | - $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1611 | + $this->loader->add_action('added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4); |
|
| 1612 | 1612 | |
| 1613 | 1613 | // Hook the updated_post_meta action to the Thumbnail service. |
| 1614 | - $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1614 | + $this->loader->add_action('updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4); |
|
| 1615 | 1615 | |
| 1616 | 1616 | // Hook the AJAX wl_timeline action to the Timeline service. |
| 1617 | - $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1617 | + $this->loader->add_action('wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline'); |
|
| 1618 | 1618 | |
| 1619 | 1619 | // Register custom allowed redirect hosts. |
| 1620 | - $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 1620 | + $this->loader->add_filter('allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts'); |
|
| 1621 | 1621 | // Hook the AJAX wordlift_redirect action to the Redirect service. |
| 1622 | - $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 1622 | + $this->loader->add_action('wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect'); |
|
| 1623 | 1623 | |
| 1624 | 1624 | /* |
| 1625 | 1625 | * The old dashboard is replaced with dashboard v2. |
@@ -1637,46 +1637,46 @@ discard block |
||
| 1637 | 1637 | |
| 1638 | 1638 | // Hook save_post to the entity service to update custom fields (such as alternate labels). |
| 1639 | 1639 | // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
| 1640 | - $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 1641 | - $this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 ); |
|
| 1640 | + $this->loader->add_action('save_post', $this->entity_service, 'save_post', 9, 3); |
|
| 1641 | + $this->loader->add_action('save_post', $this->rating_service, 'set_rating_for', 20, 1); |
|
| 1642 | 1642 | |
| 1643 | - $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 1644 | - $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' ); |
|
| 1643 | + $this->loader->add_action('edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1); |
|
| 1644 | + $this->loader->add_action('in_admin_header', $this->rating_service, 'in_admin_header'); |
|
| 1645 | 1645 | |
| 1646 | 1646 | // Entity listing customization (wp-admin/edit.php) |
| 1647 | 1647 | // Add custom columns. |
| 1648 | - $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 1648 | + $this->loader->add_filter('manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns'); |
|
| 1649 | 1649 | // no explicit entity as it prevents handling of other post types. |
| 1650 | - $this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 1650 | + $this->loader->add_filter('manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2); |
|
| 1651 | 1651 | // Add 4W selection. |
| 1652 | - $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 1653 | - $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 1654 | - $this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' ); |
|
| 1655 | - $this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' ); |
|
| 1652 | + $this->loader->add_action('restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope'); |
|
| 1653 | + $this->loader->add_filter('posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope'); |
|
| 1654 | + $this->loader->add_action('pre_get_posts', $this->entity_list_service, 'pre_get_posts'); |
|
| 1655 | + $this->loader->add_action('load-edit.php', $this->entity_list_service, 'load_edit'); |
|
| 1656 | 1656 | |
| 1657 | 1657 | /* |
| 1658 | 1658 | * If `All Entity Types` is disable, use the radio button Walker. |
| 1659 | 1659 | * |
| 1660 | 1660 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
| 1661 | 1661 | */ |
| 1662 | - if ( ! WL_ALL_ENTITY_TYPES ) { |
|
| 1663 | - $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 1662 | + if ( ! WL_ALL_ENTITY_TYPES) { |
|
| 1663 | + $this->loader->add_filter('wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args'); |
|
| 1664 | 1664 | } |
| 1665 | 1665 | |
| 1666 | 1666 | // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
| 1667 | 1667 | // entities. |
| 1668 | - $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 1668 | + $this->loader->add_filter('prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2); |
|
| 1669 | 1669 | |
| 1670 | 1670 | // Filter imported post meta. |
| 1671 | - $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 1671 | + $this->loader->add_filter('wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3); |
|
| 1672 | 1672 | |
| 1673 | 1673 | // Notify the import service when an import starts and ends. |
| 1674 | - $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 1675 | - $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 1674 | + $this->loader->add_action('import_start', $this->import_service, 'import_start', 10, 0); |
|
| 1675 | + $this->loader->add_action('import_end', $this->import_service, 'import_end', 10, 0); |
|
| 1676 | 1676 | |
| 1677 | 1677 | // Hook the AJAX wl_rebuild action to the Rebuild Service. |
| 1678 | - $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 1679 | - $this->loader->add_action( 'wp_ajax_wl_rebuild_references', $this->reference_rebuild_service, 'rebuild' ); |
|
| 1678 | + $this->loader->add_action('wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild'); |
|
| 1679 | + $this->loader->add_action('wp_ajax_wl_rebuild_references', $this->reference_rebuild_service, 'rebuild'); |
|
| 1680 | 1680 | |
| 1681 | 1681 | /** |
| 1682 | 1682 | * Filter: wl_feature__enable__screens. |
@@ -1686,34 +1686,34 @@ discard block |
||
| 1686 | 1686 | * @return bool |
| 1687 | 1687 | * @since 3.27.6 |
| 1688 | 1688 | */ |
| 1689 | - if ( apply_filters( 'wl_feature__enable__screens', true ) ) { |
|
| 1689 | + if (apply_filters('wl_feature__enable__screens', true)) { |
|
| 1690 | 1690 | // Hook the menu to the Download Your Data page. |
| 1691 | - $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 ); |
|
| 1692 | - $this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 ); |
|
| 1693 | - $this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 ); |
|
| 1691 | + $this->loader->add_action('admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0); |
|
| 1692 | + $this->loader->add_action('admin_menu', $this->status_page, 'admin_menu', 100, 0); |
|
| 1693 | + $this->loader->add_action('admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0); |
|
| 1694 | 1694 | } |
| 1695 | 1695 | // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
| 1696 | - $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 1696 | + $this->loader->add_action('wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10); |
|
| 1697 | 1697 | |
| 1698 | 1698 | // Hook the AJAX wl_jsonld action to the JSON-LD service. |
| 1699 | - $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1700 | - $this->loader->add_action( 'admin_post_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1701 | - $this->loader->add_action( 'admin_post_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1699 | + $this->loader->add_action('wp_ajax_wl_jsonld', $this->jsonld_service, 'get'); |
|
| 1700 | + $this->loader->add_action('admin_post_wl_jsonld', $this->jsonld_service, 'get'); |
|
| 1701 | + $this->loader->add_action('admin_post_nopriv_wl_jsonld', $this->jsonld_service, 'get'); |
|
| 1702 | 1702 | |
| 1703 | 1703 | // Hook the AJAX wl_validate_key action to the Key Validation service. |
| 1704 | - $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' ); |
|
| 1704 | + $this->loader->add_action('wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key'); |
|
| 1705 | 1705 | |
| 1706 | 1706 | // Hook the AJAX wl_update_country_options action to the countries. |
| 1707 | - $this->loader->add_action( 'wp_ajax_wl_update_country_options', $this->country_select_element, 'get_options_html' ); |
|
| 1707 | + $this->loader->add_action('wp_ajax_wl_update_country_options', $this->country_select_element, 'get_options_html'); |
|
| 1708 | 1708 | |
| 1709 | 1709 | // Hook the `admin_init` function to the Admin Setup. |
| 1710 | - $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' ); |
|
| 1710 | + $this->loader->add_action('admin_init', $this->admin_setup, 'admin_init'); |
|
| 1711 | 1711 | |
| 1712 | 1712 | // Hook the admin_init to the settings page. |
| 1713 | - $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' ); |
|
| 1714 | - $this->loader->add_action( 'admin_init', $this->analytics_settings_page, 'admin_init' ); |
|
| 1713 | + $this->loader->add_action('admin_init', $this->settings_page, 'admin_init'); |
|
| 1714 | + $this->loader->add_action('admin_init', $this->analytics_settings_page, 'admin_init'); |
|
| 1715 | 1715 | |
| 1716 | - $this->loader->add_filter( 'admin_post_thumbnail_html', $this->publisher_service, 'add_featured_image_instruction' ); |
|
| 1716 | + $this->loader->add_filter('admin_post_thumbnail_html', $this->publisher_service, 'add_featured_image_instruction'); |
|
| 1717 | 1717 | |
| 1718 | 1718 | // Hook the menu creation on the general wordlift menu creation. |
| 1719 | 1719 | /** |
@@ -1724,8 +1724,8 @@ discard block |
||
| 1724 | 1724 | * @return bool |
| 1725 | 1725 | * @since 3.27.6 |
| 1726 | 1726 | */ |
| 1727 | - if ( apply_filters( 'wl_feature__enable__screens', true ) ) { |
|
| 1728 | - $this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 ); |
|
| 1727 | + if (apply_filters('wl_feature__enable__screens', true)) { |
|
| 1728 | + $this->loader->add_action('wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2); |
|
| 1729 | 1729 | } |
| 1730 | 1730 | /* |
| 1731 | 1731 | * Display the `Wordlift_Admin_Search_Rankings_Page` page. |
@@ -1734,7 +1734,7 @@ discard block |
||
| 1734 | 1734 | * |
| 1735 | 1735 | * @since 3.20.0 |
| 1736 | 1736 | */ |
| 1737 | - if ( in_array( $this->configuration_service->get_package_type(), array( 'editorial', 'business' ) ) ) { |
|
| 1737 | + if (in_array($this->configuration_service->get_package_type(), array('editorial', 'business'))) { |
|
| 1738 | 1738 | /** |
| 1739 | 1739 | * Filter: wl_feature__enable__screens. |
| 1740 | 1740 | * |
@@ -1743,18 +1743,18 @@ discard block |
||
| 1743 | 1743 | * @return bool |
| 1744 | 1744 | * @since 3.27.6 |
| 1745 | 1745 | */ |
| 1746 | - if ( apply_filters( 'wl_feature__enable__screens', true ) ) { |
|
| 1746 | + if (apply_filters('wl_feature__enable__screens', true)) { |
|
| 1747 | 1747 | $admin_search_rankings_page = new Wordlift_Admin_Search_Rankings_Page(); |
| 1748 | - $this->loader->add_action( 'wl_admin_menu', $admin_search_rankings_page, 'admin_menu' ); |
|
| 1748 | + $this->loader->add_action('wl_admin_menu', $admin_search_rankings_page, 'admin_menu'); |
|
| 1749 | 1749 | } |
| 1750 | 1750 | } |
| 1751 | 1751 | |
| 1752 | 1752 | // Hook key update. |
| 1753 | - $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 ); |
|
| 1754 | - $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 ); |
|
| 1753 | + $this->loader->add_action('pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2); |
|
| 1754 | + $this->loader->add_action('update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2); |
|
| 1755 | 1755 | |
| 1756 | 1756 | // Add additional action links to the WordLift plugin in the plugins page. |
| 1757 | - $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1757 | + $this->loader->add_filter('plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1); |
|
| 1758 | 1758 | |
| 1759 | 1759 | /* |
| 1760 | 1760 | * Remove the Analytics Settings link from the plugin page. |
@@ -1765,25 +1765,25 @@ discard block |
||
| 1765 | 1765 | // $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->analytics_settings_page_action_link, 'action_links', 10, 1 ); |
| 1766 | 1766 | |
| 1767 | 1767 | // Hook the AJAX `wl_publisher` action name. |
| 1768 | - $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' ); |
|
| 1768 | + $this->loader->add_action('wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher'); |
|
| 1769 | 1769 | |
| 1770 | 1770 | // Hook row actions for the entity type list admin. |
| 1771 | - $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 ); |
|
| 1771 | + $this->loader->add_filter('wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2); |
|
| 1772 | 1772 | |
| 1773 | 1773 | /** Ajax actions. */ |
| 1774 | - $this->loader->add_action( 'wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export' ); |
|
| 1774 | + $this->loader->add_action('wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export'); |
|
| 1775 | 1775 | |
| 1776 | 1776 | // Hook capabilities manipulation to allow access to entity type admin |
| 1777 | 1777 | // page on WordPress versions before 4.7. |
| 1778 | 1778 | global $wp_version; |
| 1779 | - if ( version_compare( $wp_version, '4.7', '<' ) ) { |
|
| 1780 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 ); |
|
| 1779 | + if (version_compare($wp_version, '4.7', '<')) { |
|
| 1780 | + $this->loader->add_filter('map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4); |
|
| 1781 | 1781 | } |
| 1782 | 1782 | |
| 1783 | - $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1783 | + $this->loader->add_action('wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1); |
|
| 1784 | 1784 | |
| 1785 | 1785 | /** Adapters. */ |
| 1786 | - $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 ); |
|
| 1786 | + $this->loader->add_filter('mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1); |
|
| 1787 | 1787 | /** |
| 1788 | 1788 | * Disabling Faq temporarily. |
| 1789 | 1789 | * Load the tinymce editor button on the tool bar. |
@@ -1794,56 +1794,56 @@ discard block |
||
| 1794 | 1794 | //$this->loader->add_filter( 'mce_external_plugins', $this->faq_tinymce_adapter, 'register_faq_tinymce_plugin', 10, 1 ); |
| 1795 | 1795 | |
| 1796 | 1796 | |
| 1797 | - $this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all' ); |
|
| 1798 | - $this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' ); |
|
| 1799 | - $this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' ); |
|
| 1797 | + $this->loader->add_action('wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all'); |
|
| 1798 | + $this->loader->add_action('wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create'); |
|
| 1799 | + $this->loader->add_action('wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete'); |
|
| 1800 | 1800 | /** |
| 1801 | 1801 | * @since 3.26.0 |
| 1802 | 1802 | */ |
| 1803 | - if ( apply_filters( 'wl_feature__enable__post_excerpt', true ) ) { |
|
| 1803 | + if (apply_filters('wl_feature__enable__post_excerpt', true)) { |
|
| 1804 | 1804 | $excerpt_adapter = new Post_Excerpt_Meta_Box_Adapter(); |
| 1805 | - $this->loader->add_action( 'do_meta_boxes', $excerpt_adapter, 'replace_post_excerpt_meta_box' ); |
|
| 1805 | + $this->loader->add_action('do_meta_boxes', $excerpt_adapter, 'replace_post_excerpt_meta_box'); |
|
| 1806 | 1806 | // Adding Rest route for the post excerpt |
| 1807 | 1807 | Post_Excerpt_Rest_Controller::register_routes(); |
| 1808 | 1808 | } |
| 1809 | 1809 | |
| 1810 | - $this->loader->add_action( 'update_user_metadata', $this->user_service, 'update_user_metadata', 10, 5 ); |
|
| 1811 | - $this->loader->add_action( 'delete_user_metadata', $this->user_service, 'delete_user_metadata', 10, 5 ); |
|
| 1810 | + $this->loader->add_action('update_user_metadata', $this->user_service, 'update_user_metadata', 10, 5); |
|
| 1811 | + $this->loader->add_action('delete_user_metadata', $this->user_service, 'delete_user_metadata', 10, 5); |
|
| 1812 | 1812 | |
| 1813 | 1813 | // Handle the autocomplete request. |
| 1814 | - add_action( 'wp_ajax_wl_autocomplete', array( |
|
| 1814 | + add_action('wp_ajax_wl_autocomplete', array( |
|
| 1815 | 1815 | $this->autocomplete_adapter, |
| 1816 | 1816 | 'wl_autocomplete', |
| 1817 | - ) ); |
|
| 1818 | - add_action( 'wp_ajax_nopriv_wl_autocomplete', array( |
|
| 1817 | + )); |
|
| 1818 | + add_action('wp_ajax_nopriv_wl_autocomplete', array( |
|
| 1819 | 1819 | $this->autocomplete_adapter, |
| 1820 | 1820 | 'wl_autocomplete', |
| 1821 | - ) ); |
|
| 1821 | + )); |
|
| 1822 | 1822 | |
| 1823 | 1823 | // Hooks to restrict multisite super admin from manipulating entity types. |
| 1824 | - if ( is_multisite() ) { |
|
| 1825 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 ); |
|
| 1824 | + if (is_multisite()) { |
|
| 1825 | + $this->loader->add_filter('map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4); |
|
| 1826 | 1826 | } |
| 1827 | 1827 | |
| 1828 | - $deactivator_feedback = new Wordlift_Deactivator_Feedback( $this->configuration_service ); |
|
| 1828 | + $deactivator_feedback = new Wordlift_Deactivator_Feedback($this->configuration_service); |
|
| 1829 | 1829 | |
| 1830 | - add_action( 'admin_footer', array( $deactivator_feedback, 'render_feedback_popup' ) ); |
|
| 1831 | - add_action( 'admin_enqueue_scripts', array( $deactivator_feedback, 'enqueue_popup_scripts' ) ); |
|
| 1832 | - add_action( 'wp_ajax_wl_deactivation_feedback', array( $deactivator_feedback, 'wl_deactivation_feedback' ) ); |
|
| 1830 | + add_action('admin_footer', array($deactivator_feedback, 'render_feedback_popup')); |
|
| 1831 | + add_action('admin_enqueue_scripts', array($deactivator_feedback, 'enqueue_popup_scripts')); |
|
| 1832 | + add_action('wp_ajax_wl_deactivation_feedback', array($deactivator_feedback, 'wl_deactivation_feedback')); |
|
| 1833 | 1833 | |
| 1834 | 1834 | /** |
| 1835 | 1835 | * Always allow the `wordlift/classification` block. |
| 1836 | 1836 | * |
| 1837 | 1837 | * @since 3.23.0 |
| 1838 | 1838 | */ |
| 1839 | - add_filter( 'allowed_block_types', function ( $value ) { |
|
| 1839 | + add_filter('allowed_block_types', function($value) { |
|
| 1840 | 1840 | |
| 1841 | - if ( true === $value ) { |
|
| 1841 | + if (true === $value) { |
|
| 1842 | 1842 | return $value; |
| 1843 | 1843 | } |
| 1844 | 1844 | |
| 1845 | - return array_merge( (array) $value, array( 'wordlift/classification' ) ); |
|
| 1846 | - }, PHP_INT_MAX ); |
|
| 1845 | + return array_merge((array) $value, array('wordlift/classification')); |
|
| 1846 | + }, PHP_INT_MAX); |
|
| 1847 | 1847 | |
| 1848 | 1848 | /** |
| 1849 | 1849 | * @since 3.27.7 |
@@ -1861,58 +1861,58 @@ discard block |
||
| 1861 | 1861 | */ |
| 1862 | 1862 | private function define_public_hooks() { |
| 1863 | 1863 | |
| 1864 | - $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 1864 | + $plugin_public = new Wordlift_Public($this->get_plugin_name(), $this->get_version()); |
|
| 1865 | 1865 | |
| 1866 | 1866 | // Register the entity post type. |
| 1867 | - $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' ); |
|
| 1867 | + $this->loader->add_action('init', $this->entity_post_type_service, 'register'); |
|
| 1868 | 1868 | |
| 1869 | 1869 | // Bind the link generation and handling hooks to the entity link service. |
| 1870 | - $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 1871 | - $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 ); |
|
| 1870 | + $this->loader->add_filter('post_type_link', $this->entity_link_service, 'post_type_link', 10, 4); |
|
| 1871 | + $this->loader->add_action('pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1); |
|
| 1872 | 1872 | // $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 ); |
| 1873 | 1873 | // $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 ); |
| 1874 | 1874 | |
| 1875 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 1876 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 1877 | - $this->loader->add_action( 'wp_enqueue_scripts', $this->context_cards_service, 'enqueue_scripts' ); |
|
| 1875 | + $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles'); |
|
| 1876 | + $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts'); |
|
| 1877 | + $this->loader->add_action('wp_enqueue_scripts', $this->context_cards_service, 'enqueue_scripts'); |
|
| 1878 | 1878 | |
| 1879 | 1879 | // Registering Faq_Content_Filter service used for removing faq question and answer tags from the html. |
| 1880 | - $this->loader->add_filter( 'the_content', $this->faq_content_filter_service, 'remove_all_faq_question_and_answer_tags' ); |
|
| 1880 | + $this->loader->add_filter('the_content', $this->faq_content_filter_service, 'remove_all_faq_question_and_answer_tags'); |
|
| 1881 | 1881 | // Hook the content filter service to add entity links. |
| 1882 | - if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) { |
|
| 1883 | - $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' ); |
|
| 1882 | + if ( ! defined('WL_DISABLE_CONTENT_FILTER') || ! WL_DISABLE_CONTENT_FILTER) { |
|
| 1883 | + $this->loader->add_filter('the_content', $this->content_filter_service, 'the_content'); |
|
| 1884 | 1884 | } |
| 1885 | 1885 | |
| 1886 | 1886 | // Hook the AJAX wl_timeline action to the Timeline service. |
| 1887 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1887 | + $this->loader->add_action('wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline'); |
|
| 1888 | 1888 | |
| 1889 | 1889 | // Hook the ShareThis service. |
| 1890 | - $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 1891 | - $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 1890 | + $this->loader->add_filter('the_content', $this->sharethis_service, 'the_content', 99); |
|
| 1891 | + $this->loader->add_filter('the_excerpt', $this->sharethis_service, 'the_excerpt', 99); |
|
| 1892 | 1892 | |
| 1893 | 1893 | // Hook the AJAX wl_jsonld action to the JSON-LD service. |
| 1894 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1894 | + $this->loader->add_action('wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get'); |
|
| 1895 | 1895 | |
| 1896 | 1896 | // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service` |
| 1897 | 1897 | // in order to tweak WP's `WP_Query` to include entities in queries related |
| 1898 | 1898 | // to categories. |
| 1899 | - $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 ); |
|
| 1899 | + $this->loader->add_action('pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1); |
|
| 1900 | 1900 | |
| 1901 | 1901 | /* |
| 1902 | 1902 | * Hook the `pre_get_posts` action to the `Wordlift_Entity_Page_Service` |
| 1903 | 1903 | * in order to tweak WP's `WP_Query` to show event related entities in reverse |
| 1904 | 1904 | * order of start time. |
| 1905 | 1905 | */ |
| 1906 | - $this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 ); |
|
| 1906 | + $this->loader->add_action('pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1); |
|
| 1907 | 1907 | |
| 1908 | - $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1908 | + $this->loader->add_action('wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1); |
|
| 1909 | 1909 | |
| 1910 | 1910 | // This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done. |
| 1911 | - $this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 ); |
|
| 1911 | + $this->loader->add_action('save_post', $this->entity_type_adapter, 'save_post', 9, 3); |
|
| 1912 | 1912 | |
| 1913 | 1913 | // Analytics Script Frontend. |
| 1914 | - if ( $this->configuration_service->is_analytics_enable() ) { |
|
| 1915 | - $this->loader->add_action( 'wp_enqueue_scripts', $this->analytics_connect, 'enqueue_scripts', 10 ); |
|
| 1914 | + if ($this->configuration_service->is_analytics_enable()) { |
|
| 1915 | + $this->loader->add_action('wp_enqueue_scripts', $this->analytics_connect, 'enqueue_scripts', 10); |
|
| 1916 | 1916 | } |
| 1917 | 1917 | |
| 1918 | 1918 | } |
@@ -1965,11 +1965,11 @@ discard block |
||
| 1965 | 1965 | */ |
| 1966 | 1966 | private function load_cli_dependencies() { |
| 1967 | 1967 | |
| 1968 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'cli/class-wordlift-push-reference-data-command.php'; |
|
| 1968 | + require_once plugin_dir_path(dirname(__FILE__)).'cli/class-wordlift-push-reference-data-command.php'; |
|
| 1969 | 1969 | |
| 1970 | - $push_reference_data_command = new Wordlift_Push_Reference_Data_Command( $this->relation_service, $this->entity_service, $this->sparql_service, $this->configuration_service, $this->entity_type_service ); |
|
| 1970 | + $push_reference_data_command = new Wordlift_Push_Reference_Data_Command($this->relation_service, $this->entity_service, $this->sparql_service, $this->configuration_service, $this->entity_type_service); |
|
| 1971 | 1971 | |
| 1972 | - WP_CLI::add_command( 'wl references push', $push_reference_data_command ); |
|
| 1972 | + WP_CLI::add_command('wl references push', $push_reference_data_command); |
|
| 1973 | 1973 | |
| 1974 | 1974 | } |
| 1975 | 1975 | |
@@ -1994,13 +1994,13 @@ discard block |
||
| 1994 | 1994 | * @since 3.27.6 |
| 1995 | 1995 | */ |
| 1996 | 1996 | |
| 1997 | - wp_register_script( 'wl_enabled_blocks', false ); |
|
| 1997 | + wp_register_script('wl_enabled_blocks', false); |
|
| 1998 | 1998 | |
| 1999 | - $enabled_blocks = array( 'wordlift/products-navigator' ); |
|
| 1999 | + $enabled_blocks = array('wordlift/products-navigator'); |
|
| 2000 | 2000 | |
| 2001 | - if ( apply_filters( 'wl_feature__enable__blocks', true ) ) { |
|
| 2001 | + if (apply_filters('wl_feature__enable__blocks', true)) { |
|
| 2002 | 2002 | // To intimate JS |
| 2003 | - $enabled_blocks = array_merge( $enabled_blocks, array( |
|
| 2003 | + $enabled_blocks = array_merge($enabled_blocks, array( |
|
| 2004 | 2004 | 'wordlift/navigator', |
| 2005 | 2005 | 'wordlift/chord', |
| 2006 | 2006 | 'wordlift/geomap', |
@@ -2008,11 +2008,11 @@ discard block |
||
| 2008 | 2008 | 'wordlift/cloud', |
| 2009 | 2009 | 'wordlift/vocabulary', |
| 2010 | 2010 | 'wordlift/faceted-search' |
| 2011 | - ) ); |
|
| 2011 | + )); |
|
| 2012 | 2012 | } |
| 2013 | 2013 | |
| 2014 | - wp_localize_script( 'wl_enabled_blocks', 'wlEnabledBlocks', $enabled_blocks ); |
|
| 2015 | - wp_enqueue_script( 'wl_enabled_blocks' ); |
|
| 2014 | + wp_localize_script('wl_enabled_blocks', 'wlEnabledBlocks', $enabled_blocks); |
|
| 2015 | + wp_enqueue_script('wl_enabled_blocks'); |
|
| 2016 | 2016 | } |
| 2017 | 2017 | |
| 2018 | 2018 | } |
@@ -10,42 +10,42 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | class Faceted_Search_Template_Endpoint { |
| 12 | 12 | |
| 13 | - public function __construct() { |
|
| 14 | - add_action( 'rest_api_init', array( $this, 'register_template_route' ) ); |
|
| 15 | - } |
|
| 13 | + public function __construct() { |
|
| 14 | + add_action( 'rest_api_init', array( $this, 'register_template_route' ) ); |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - public function register_template_route() { |
|
| 17 | + public function register_template_route() { |
|
| 18 | 18 | |
| 19 | - register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/faceted-search/template/', array( |
|
| 20 | - 'methods' => WP_REST_Server::CREATABLE, |
|
| 21 | - 'callback' => array( $this, 'get_template' ), |
|
| 22 | - /** |
|
| 23 | - * We want this endpoint to be publicly accessible |
|
| 24 | - */ |
|
| 25 | - 'permission_callback' => '__return_true', |
|
| 26 | - 'args' => array( |
|
| 27 | - 'template_id' => array( |
|
| 28 | - 'validate_callback' => function ( $param, $request, $key ) { |
|
| 29 | - return is_string( $param ) && $param; |
|
| 30 | - }, |
|
| 31 | - ), |
|
| 32 | - ) |
|
| 33 | - ) ); |
|
| 34 | - } |
|
| 19 | + register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/faceted-search/template/', array( |
|
| 20 | + 'methods' => WP_REST_Server::CREATABLE, |
|
| 21 | + 'callback' => array( $this, 'get_template' ), |
|
| 22 | + /** |
|
| 23 | + * We want this endpoint to be publicly accessible |
|
| 24 | + */ |
|
| 25 | + 'permission_callback' => '__return_true', |
|
| 26 | + 'args' => array( |
|
| 27 | + 'template_id' => array( |
|
| 28 | + 'validate_callback' => function ( $param, $request, $key ) { |
|
| 29 | + return is_string( $param ) && $param; |
|
| 30 | + }, |
|
| 31 | + ), |
|
| 32 | + ) |
|
| 33 | + ) ); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Faceted search widget makes call to this endpoint to get the template. |
|
| 38 | - * Takes the request, checks if template id is registered via filter, |
|
| 39 | - * if not it returns empty. |
|
| 40 | - * |
|
| 41 | - * @param $request \WP_REST_Request |
|
| 42 | - * |
|
| 43 | - * @return string Returns the template string. |
|
| 44 | - */ |
|
| 45 | - public function get_template( $request ) { |
|
| 46 | - $data = $request->get_params(); |
|
| 47 | - $template_id = (string) $data['template_id']; |
|
| 48 | - $templates = apply_filters( 'wordlift_faceted_search_template', array() ); |
|
| 49 | - return array_key_exists( $template_id, $templates ) ? $templates[$template_id] : ''; |
|
| 50 | - } |
|
| 36 | + /** |
|
| 37 | + * Faceted search widget makes call to this endpoint to get the template. |
|
| 38 | + * Takes the request, checks if template id is registered via filter, |
|
| 39 | + * if not it returns empty. |
|
| 40 | + * |
|
| 41 | + * @param $request \WP_REST_Request |
|
| 42 | + * |
|
| 43 | + * @return string Returns the template string. |
|
| 44 | + */ |
|
| 45 | + public function get_template( $request ) { |
|
| 46 | + $data = $request->get_params(); |
|
| 47 | + $template_id = (string) $data['template_id']; |
|
| 48 | + $templates = apply_filters( 'wordlift_faceted_search_template', array() ); |
|
| 49 | + return array_key_exists( $template_id, $templates ) ? $templates[$template_id] : ''; |
|
| 50 | + } |
|
| 51 | 51 | } |
| 52 | 52 | \ No newline at end of file |
@@ -11,26 +11,26 @@ discard block |
||
| 11 | 11 | class Faceted_Search_Template_Endpoint { |
| 12 | 12 | |
| 13 | 13 | public function __construct() { |
| 14 | - add_action( 'rest_api_init', array( $this, 'register_template_route' ) ); |
|
| 14 | + add_action('rest_api_init', array($this, 'register_template_route')); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | public function register_template_route() { |
| 18 | 18 | |
| 19 | - register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/faceted-search/template/', array( |
|
| 19 | + register_rest_route(WL_REST_ROUTE_DEFAULT_NAMESPACE, '/faceted-search/template/', array( |
|
| 20 | 20 | 'methods' => WP_REST_Server::CREATABLE, |
| 21 | - 'callback' => array( $this, 'get_template' ), |
|
| 21 | + 'callback' => array($this, 'get_template'), |
|
| 22 | 22 | /** |
| 23 | 23 | * We want this endpoint to be publicly accessible |
| 24 | 24 | */ |
| 25 | 25 | 'permission_callback' => '__return_true', |
| 26 | 26 | 'args' => array( |
| 27 | 27 | 'template_id' => array( |
| 28 | - 'validate_callback' => function ( $param, $request, $key ) { |
|
| 29 | - return is_string( $param ) && $param; |
|
| 28 | + 'validate_callback' => function($param, $request, $key) { |
|
| 29 | + return is_string($param) && $param; |
|
| 30 | 30 | }, |
| 31 | 31 | ), |
| 32 | 32 | ) |
| 33 | - ) ); |
|
| 33 | + )); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -42,10 +42,10 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return string Returns the template string. |
| 44 | 44 | */ |
| 45 | - public function get_template( $request ) { |
|
| 45 | + public function get_template($request) { |
|
| 46 | 46 | $data = $request->get_params(); |
| 47 | 47 | $template_id = (string) $data['template_id']; |
| 48 | - $templates = apply_filters( 'wordlift_faceted_search_template', array() ); |
|
| 49 | - return array_key_exists( $template_id, $templates ) ? $templates[$template_id] : ''; |
|
| 48 | + $templates = apply_filters('wordlift_faceted_search_template', array()); |
|
| 49 | + return array_key_exists($template_id, $templates) ? $templates[$template_id] : ''; |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | \ No newline at end of file |
@@ -17,145 +17,145 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | class Wordlift_Faceted_Search_Shortcode extends Wordlift_Shortcode { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * {@inheritdoc} |
|
| 22 | - */ |
|
| 23 | - const SHORTCODE = 'wl_faceted_search'; |
|
| 24 | - |
|
| 25 | - public function __construct() { |
|
| 26 | - parent::__construct(); |
|
| 27 | - $this->register_block_type(); |
|
| 28 | - } |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * {@inheritdoc} |
|
| 32 | - */ |
|
| 33 | - public function render( $atts ) { |
|
| 34 | - |
|
| 35 | - return Wordlift_AMP_Service::is_amp_endpoint() ? $this->amp_shortcode( $atts ) |
|
| 36 | - : $this->web_shortcode( $atts ); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - private function register_block_type() { |
|
| 40 | - |
|
| 41 | - $scope = $this; |
|
| 42 | - |
|
| 43 | - add_action( 'init', function () use ( $scope ) { |
|
| 44 | - if ( ! function_exists( 'register_block_type' ) ) { |
|
| 45 | - // Gutenberg is not active. |
|
| 46 | - return; |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - register_block_type( 'wordlift/faceted-search', array( |
|
| 50 | - 'editor_script' => 'wl-block-editor', |
|
| 51 | - 'render_callback' => function ( $attributes ) use ( $scope ) { |
|
| 52 | - $attr_code = ''; |
|
| 53 | - foreach ( $attributes as $key => $value ) { |
|
| 54 | - $attr_code .= $key . '="' . htmlentities( $value ) . '" '; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - return '[' . $scope::SHORTCODE . ' ' . $attr_code . ']'; |
|
| 58 | - }, |
|
| 59 | - 'attributes' => array( |
|
| 60 | - 'title' => array( |
|
| 61 | - 'type' => 'string', |
|
| 62 | - 'default' => __( 'Related articles', 'wordlift' ), |
|
| 63 | - ), |
|
| 64 | - 'template_id' => array( |
|
| 65 | - 'type' => 'string', |
|
| 66 | - 'default' => '', |
|
| 67 | - ), |
|
| 68 | - 'post_id' => array( |
|
| 69 | - 'type' => 'number', |
|
| 70 | - 'default' => '', |
|
| 71 | - ), |
|
| 72 | - 'uniqid' => array( |
|
| 73 | - 'type' => 'string', |
|
| 74 | - 'default' => '', |
|
| 75 | - ), |
|
| 76 | - 'limit' => array( |
|
| 77 | - 'type' => 'number', |
|
| 78 | - 'default' => apply_filters( 'wl_faceted_search_default_limit', 10 ), |
|
| 79 | - ), |
|
| 80 | - 'preview' => array( |
|
| 81 | - 'type' => 'boolean', |
|
| 82 | - 'default' => false, |
|
| 83 | - ), |
|
| 84 | - 'preview_src' => array( |
|
| 85 | - 'type' => 'string', |
|
| 86 | - 'default' => WP_CONTENT_URL . '/plugins/wordlift/images/block-previews/faceted-search.png', |
|
| 87 | - ), |
|
| 88 | - ), |
|
| 89 | - ) ); |
|
| 90 | - } ); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * Shared function used by web_shortcode and amp_shortcode |
|
| 95 | - * Bootstrap logic for attributes extraction and boolean filtering |
|
| 96 | - * |
|
| 97 | - * @since 3.20.0 |
|
| 98 | - * |
|
| 99 | - * @param array $atts Shortcode attributes. |
|
| 100 | - * |
|
| 101 | - * @return array $shortcode_atts |
|
| 102 | - */ |
|
| 103 | - private function make_shortcode_atts( $atts ) { |
|
| 104 | - |
|
| 105 | - // Extract attributes and set default values. |
|
| 106 | - $shortcode_atts = shortcode_atts( array( |
|
| 107 | - 'title' => __( 'Related articles', 'wordlift' ), |
|
| 108 | - 'limit' => apply_filters( 'wl_faceted_search_default_limit', 10 ), |
|
| 109 | - 'post_id' => '', |
|
| 110 | - 'template_id' => '', |
|
| 111 | - 'uniqid' => uniqid( 'wl-faceted-widget-' ), |
|
| 112 | - ), $atts ); |
|
| 113 | - |
|
| 114 | - return $shortcode_atts; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * Function in charge of diplaying the [wl-faceted-search] in web mode. |
|
| 119 | - * |
|
| 120 | - * @since 3.20.0 |
|
| 121 | - * |
|
| 122 | - * @param array $atts Shortcode attributes. |
|
| 123 | - * |
|
| 124 | - * @return string Shortcode HTML for web |
|
| 125 | - */ |
|
| 126 | - private function web_shortcode( $atts ) { |
|
| 127 | - |
|
| 128 | - // attributes extraction and boolean filtering |
|
| 129 | - $shortcode_atts = $this->make_shortcode_atts( $atts ); |
|
| 130 | - |
|
| 131 | - // avoid building the widget when no post_id is specified and there is a list of posts. |
|
| 132 | - if ( empty( $shortcode_atts['post_id'] ) && ! is_singular() ) { |
|
| 133 | - return; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - $post = ! empty( $shortcode_atts['post_id'] ) ? get_post( intval( sanitize_text_field( $shortcode_atts['post_id'] ) ) ) : get_post(); |
|
| 137 | - $title = esc_attr( sanitize_text_field( $shortcode_atts['title'] ) ); |
|
| 138 | - $template_id = esc_attr( sanitize_text_field( $shortcode_atts['template_id'] ) ); |
|
| 139 | - $limit = esc_attr( sanitize_text_field( $shortcode_atts['limit'] ) ); |
|
| 140 | - $faceted_id = ! empty( $shortcode_atts['uniqid'] ) ? esc_attr( sanitize_text_field( $shortcode_atts['uniqid'] ) ) : uniqid( 'wl-faceted-widget-' ); |
|
| 141 | - |
|
| 142 | - $permalink_structure = get_option( 'permalink_structure' ); |
|
| 143 | - $delimiter = empty( $permalink_structure ) ? '&' : '?'; |
|
| 144 | - $rest_url = $post ? rest_url( WL_REST_ROUTE_DEFAULT_NAMESPACE . '/faceted-search' . $delimiter . build_query( array( |
|
| 145 | - 'post_id' => $post->ID, |
|
| 146 | - 'limit' => $limit |
|
| 147 | - ) ) ) : false; |
|
| 148 | - |
|
| 149 | - // avoid building the widget when no valid $rest_url |
|
| 150 | - if ( ! $rest_url ) { |
|
| 151 | - return; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - wp_enqueue_script( 'wordlift-cloud' ); |
|
| 155 | - $json_faceted_id = wp_json_encode( $faceted_id ); |
|
| 156 | - $template_url = get_rest_url( null, '/wordlift/v1/faceted-search/template' ); |
|
| 157 | - |
|
| 158 | - return <<<HTML |
|
| 20 | + /** |
|
| 21 | + * {@inheritdoc} |
|
| 22 | + */ |
|
| 23 | + const SHORTCODE = 'wl_faceted_search'; |
|
| 24 | + |
|
| 25 | + public function __construct() { |
|
| 26 | + parent::__construct(); |
|
| 27 | + $this->register_block_type(); |
|
| 28 | + } |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * {@inheritdoc} |
|
| 32 | + */ |
|
| 33 | + public function render( $atts ) { |
|
| 34 | + |
|
| 35 | + return Wordlift_AMP_Service::is_amp_endpoint() ? $this->amp_shortcode( $atts ) |
|
| 36 | + : $this->web_shortcode( $atts ); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + private function register_block_type() { |
|
| 40 | + |
|
| 41 | + $scope = $this; |
|
| 42 | + |
|
| 43 | + add_action( 'init', function () use ( $scope ) { |
|
| 44 | + if ( ! function_exists( 'register_block_type' ) ) { |
|
| 45 | + // Gutenberg is not active. |
|
| 46 | + return; |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + register_block_type( 'wordlift/faceted-search', array( |
|
| 50 | + 'editor_script' => 'wl-block-editor', |
|
| 51 | + 'render_callback' => function ( $attributes ) use ( $scope ) { |
|
| 52 | + $attr_code = ''; |
|
| 53 | + foreach ( $attributes as $key => $value ) { |
|
| 54 | + $attr_code .= $key . '="' . htmlentities( $value ) . '" '; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + return '[' . $scope::SHORTCODE . ' ' . $attr_code . ']'; |
|
| 58 | + }, |
|
| 59 | + 'attributes' => array( |
|
| 60 | + 'title' => array( |
|
| 61 | + 'type' => 'string', |
|
| 62 | + 'default' => __( 'Related articles', 'wordlift' ), |
|
| 63 | + ), |
|
| 64 | + 'template_id' => array( |
|
| 65 | + 'type' => 'string', |
|
| 66 | + 'default' => '', |
|
| 67 | + ), |
|
| 68 | + 'post_id' => array( |
|
| 69 | + 'type' => 'number', |
|
| 70 | + 'default' => '', |
|
| 71 | + ), |
|
| 72 | + 'uniqid' => array( |
|
| 73 | + 'type' => 'string', |
|
| 74 | + 'default' => '', |
|
| 75 | + ), |
|
| 76 | + 'limit' => array( |
|
| 77 | + 'type' => 'number', |
|
| 78 | + 'default' => apply_filters( 'wl_faceted_search_default_limit', 10 ), |
|
| 79 | + ), |
|
| 80 | + 'preview' => array( |
|
| 81 | + 'type' => 'boolean', |
|
| 82 | + 'default' => false, |
|
| 83 | + ), |
|
| 84 | + 'preview_src' => array( |
|
| 85 | + 'type' => 'string', |
|
| 86 | + 'default' => WP_CONTENT_URL . '/plugins/wordlift/images/block-previews/faceted-search.png', |
|
| 87 | + ), |
|
| 88 | + ), |
|
| 89 | + ) ); |
|
| 90 | + } ); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * Shared function used by web_shortcode and amp_shortcode |
|
| 95 | + * Bootstrap logic for attributes extraction and boolean filtering |
|
| 96 | + * |
|
| 97 | + * @since 3.20.0 |
|
| 98 | + * |
|
| 99 | + * @param array $atts Shortcode attributes. |
|
| 100 | + * |
|
| 101 | + * @return array $shortcode_atts |
|
| 102 | + */ |
|
| 103 | + private function make_shortcode_atts( $atts ) { |
|
| 104 | + |
|
| 105 | + // Extract attributes and set default values. |
|
| 106 | + $shortcode_atts = shortcode_atts( array( |
|
| 107 | + 'title' => __( 'Related articles', 'wordlift' ), |
|
| 108 | + 'limit' => apply_filters( 'wl_faceted_search_default_limit', 10 ), |
|
| 109 | + 'post_id' => '', |
|
| 110 | + 'template_id' => '', |
|
| 111 | + 'uniqid' => uniqid( 'wl-faceted-widget-' ), |
|
| 112 | + ), $atts ); |
|
| 113 | + |
|
| 114 | + return $shortcode_atts; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * Function in charge of diplaying the [wl-faceted-search] in web mode. |
|
| 119 | + * |
|
| 120 | + * @since 3.20.0 |
|
| 121 | + * |
|
| 122 | + * @param array $atts Shortcode attributes. |
|
| 123 | + * |
|
| 124 | + * @return string Shortcode HTML for web |
|
| 125 | + */ |
|
| 126 | + private function web_shortcode( $atts ) { |
|
| 127 | + |
|
| 128 | + // attributes extraction and boolean filtering |
|
| 129 | + $shortcode_atts = $this->make_shortcode_atts( $atts ); |
|
| 130 | + |
|
| 131 | + // avoid building the widget when no post_id is specified and there is a list of posts. |
|
| 132 | + if ( empty( $shortcode_atts['post_id'] ) && ! is_singular() ) { |
|
| 133 | + return; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + $post = ! empty( $shortcode_atts['post_id'] ) ? get_post( intval( sanitize_text_field( $shortcode_atts['post_id'] ) ) ) : get_post(); |
|
| 137 | + $title = esc_attr( sanitize_text_field( $shortcode_atts['title'] ) ); |
|
| 138 | + $template_id = esc_attr( sanitize_text_field( $shortcode_atts['template_id'] ) ); |
|
| 139 | + $limit = esc_attr( sanitize_text_field( $shortcode_atts['limit'] ) ); |
|
| 140 | + $faceted_id = ! empty( $shortcode_atts['uniqid'] ) ? esc_attr( sanitize_text_field( $shortcode_atts['uniqid'] ) ) : uniqid( 'wl-faceted-widget-' ); |
|
| 141 | + |
|
| 142 | + $permalink_structure = get_option( 'permalink_structure' ); |
|
| 143 | + $delimiter = empty( $permalink_structure ) ? '&' : '?'; |
|
| 144 | + $rest_url = $post ? rest_url( WL_REST_ROUTE_DEFAULT_NAMESPACE . '/faceted-search' . $delimiter . build_query( array( |
|
| 145 | + 'post_id' => $post->ID, |
|
| 146 | + 'limit' => $limit |
|
| 147 | + ) ) ) : false; |
|
| 148 | + |
|
| 149 | + // avoid building the widget when no valid $rest_url |
|
| 150 | + if ( ! $rest_url ) { |
|
| 151 | + return; |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + wp_enqueue_script( 'wordlift-cloud' ); |
|
| 155 | + $json_faceted_id = wp_json_encode( $faceted_id ); |
|
| 156 | + $template_url = get_rest_url( null, '/wordlift/v1/faceted-search/template' ); |
|
| 157 | + |
|
| 158 | + return <<<HTML |
|
| 159 | 159 | <!-- Faceted {$faceted_id} --> |
| 160 | 160 | <script type="application/javascript"> |
| 161 | 161 | window.wlFaceteds = window.wlFaceteds || []; wlFaceteds.push({$json_faceted_id}); |
@@ -168,58 +168,58 @@ discard block |
||
| 168 | 168 | data-template-url="{$template_url}"></div> |
| 169 | 169 | <!-- /Faceted {$faceted_id} --> |
| 170 | 170 | HTML; |
| 171 | - } |
|
| 172 | - |
|
| 173 | - /** |
|
| 174 | - * Function in charge of diplaying the [wl-faceted-search] in amp mode. |
|
| 175 | - * |
|
| 176 | - * @since 3.20.0 |
|
| 177 | - * |
|
| 178 | - * @param array $atts Shortcode attributes. |
|
| 179 | - * |
|
| 180 | - * @return string Shortcode HTML for amp |
|
| 181 | - */ |
|
| 182 | - private function amp_shortcode( $atts ) { |
|
| 183 | - |
|
| 184 | - // attributes extraction and boolean filtering |
|
| 185 | - $shortcode_atts = $this->make_shortcode_atts( $atts ); |
|
| 186 | - |
|
| 187 | - // avoid building the widget when no post_id is specified and there is a list of posts. |
|
| 188 | - if ( empty( $shortcode_atts['post_id'] ) && ! is_singular() ) { |
|
| 189 | - return; |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - $post = ! empty( $shortcode_atts['post_id'] ) ? get_post( intval( sanitize_text_field( $shortcode_atts['post_id'] ) ) ) : get_post(); |
|
| 193 | - $title = esc_attr( sanitize_text_field( $shortcode_atts['title'] ) ); |
|
| 194 | - $template_id = esc_attr( sanitize_text_field( $shortcode_atts['template_id'] ) ); |
|
| 195 | - $limit = esc_attr( sanitize_text_field( $shortcode_atts['limit'] ) ); |
|
| 196 | - $faceted_id = ! empty( $shortcode_atts['uniqid'] ) ? esc_attr( sanitize_text_field( $shortcode_atts['uniqid'] ) ) : uniqid( 'wl-faceted-widget-' ); |
|
| 197 | - |
|
| 198 | - $permalink_structure = get_option( 'permalink_structure' ); |
|
| 199 | - $delimiter = empty( $permalink_structure ) ? '&' : '?'; |
|
| 200 | - $rest_url = $post ? rest_url( WL_REST_ROUTE_DEFAULT_NAMESPACE . '/faceted-search' . $delimiter . build_query( array( |
|
| 201 | - 'amp', |
|
| 202 | - 'post_id' => $post->ID, |
|
| 203 | - 'limit' => $limit |
|
| 204 | - ) ) ) : false; |
|
| 205 | - |
|
| 206 | - $rest_url = $post ? rest_url( sprintf( "wordlift/v1/faceted-search?amp&post_id=%s&limit=%s", $post->ID, $limit ) ) : false; |
|
| 207 | - |
|
| 208 | - // avoid building the widget when no valid $rest_url |
|
| 209 | - if ( ! $rest_url ) { |
|
| 210 | - return; |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - // Use a protocol-relative URL as amp-list spec says that URL's protocol must be HTTPS. |
|
| 214 | - // This is a hackish way, but this works for http and https URLs |
|
| 215 | - $rest_url = str_replace( array( 'http:', 'https:' ), '', $rest_url ); |
|
| 216 | - |
|
| 217 | - if ( empty( $template_id ) ) { |
|
| 218 | - $template_id = "template-" . $faceted_id; |
|
| 219 | - wp_enqueue_style( 'wordlift-amp-custom', plugin_dir_url( dirname( __FILE__ ) ) . '/css/wordlift-amp-custom.min.css' ); |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - return <<<HTML |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + /** |
|
| 174 | + * Function in charge of diplaying the [wl-faceted-search] in amp mode. |
|
| 175 | + * |
|
| 176 | + * @since 3.20.0 |
|
| 177 | + * |
|
| 178 | + * @param array $atts Shortcode attributes. |
|
| 179 | + * |
|
| 180 | + * @return string Shortcode HTML for amp |
|
| 181 | + */ |
|
| 182 | + private function amp_shortcode( $atts ) { |
|
| 183 | + |
|
| 184 | + // attributes extraction and boolean filtering |
|
| 185 | + $shortcode_atts = $this->make_shortcode_atts( $atts ); |
|
| 186 | + |
|
| 187 | + // avoid building the widget when no post_id is specified and there is a list of posts. |
|
| 188 | + if ( empty( $shortcode_atts['post_id'] ) && ! is_singular() ) { |
|
| 189 | + return; |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + $post = ! empty( $shortcode_atts['post_id'] ) ? get_post( intval( sanitize_text_field( $shortcode_atts['post_id'] ) ) ) : get_post(); |
|
| 193 | + $title = esc_attr( sanitize_text_field( $shortcode_atts['title'] ) ); |
|
| 194 | + $template_id = esc_attr( sanitize_text_field( $shortcode_atts['template_id'] ) ); |
|
| 195 | + $limit = esc_attr( sanitize_text_field( $shortcode_atts['limit'] ) ); |
|
| 196 | + $faceted_id = ! empty( $shortcode_atts['uniqid'] ) ? esc_attr( sanitize_text_field( $shortcode_atts['uniqid'] ) ) : uniqid( 'wl-faceted-widget-' ); |
|
| 197 | + |
|
| 198 | + $permalink_structure = get_option( 'permalink_structure' ); |
|
| 199 | + $delimiter = empty( $permalink_structure ) ? '&' : '?'; |
|
| 200 | + $rest_url = $post ? rest_url( WL_REST_ROUTE_DEFAULT_NAMESPACE . '/faceted-search' . $delimiter . build_query( array( |
|
| 201 | + 'amp', |
|
| 202 | + 'post_id' => $post->ID, |
|
| 203 | + 'limit' => $limit |
|
| 204 | + ) ) ) : false; |
|
| 205 | + |
|
| 206 | + $rest_url = $post ? rest_url( sprintf( "wordlift/v1/faceted-search?amp&post_id=%s&limit=%s", $post->ID, $limit ) ) : false; |
|
| 207 | + |
|
| 208 | + // avoid building the widget when no valid $rest_url |
|
| 209 | + if ( ! $rest_url ) { |
|
| 210 | + return; |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + // Use a protocol-relative URL as amp-list spec says that URL's protocol must be HTTPS. |
|
| 214 | + // This is a hackish way, but this works for http and https URLs |
|
| 215 | + $rest_url = str_replace( array( 'http:', 'https:' ), '', $rest_url ); |
|
| 216 | + |
|
| 217 | + if ( empty( $template_id ) ) { |
|
| 218 | + $template_id = "template-" . $faceted_id; |
|
| 219 | + wp_enqueue_style( 'wordlift-amp-custom', plugin_dir_url( dirname( __FILE__ ) ) . '/css/wordlift-amp-custom.min.css' ); |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + return <<<HTML |
|
| 223 | 223 | <div id="{$faceted_id}" class="wl-amp-faceted"> |
| 224 | 224 | <h2 class="wl-headline">{$title}</h2> |
| 225 | 225 | <amp-state id="referencedPosts"> |
@@ -302,6 +302,6 @@ discard block |
||
| 302 | 302 | </section> |
| 303 | 303 | </div> |
| 304 | 304 | HTML; |
| 305 | - } |
|
| 305 | + } |
|
| 306 | 306 | |
| 307 | 307 | } |
@@ -30,36 +30,36 @@ discard block |
||
| 30 | 30 | /** |
| 31 | 31 | * {@inheritdoc} |
| 32 | 32 | */ |
| 33 | - public function render( $atts ) { |
|
| 33 | + public function render($atts) { |
|
| 34 | 34 | |
| 35 | - return Wordlift_AMP_Service::is_amp_endpoint() ? $this->amp_shortcode( $atts ) |
|
| 36 | - : $this->web_shortcode( $atts ); |
|
| 35 | + return Wordlift_AMP_Service::is_amp_endpoint() ? $this->amp_shortcode($atts) |
|
| 36 | + : $this->web_shortcode($atts); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | private function register_block_type() { |
| 40 | 40 | |
| 41 | 41 | $scope = $this; |
| 42 | 42 | |
| 43 | - add_action( 'init', function () use ( $scope ) { |
|
| 44 | - if ( ! function_exists( 'register_block_type' ) ) { |
|
| 43 | + add_action('init', function() use ($scope) { |
|
| 44 | + if ( ! function_exists('register_block_type')) { |
|
| 45 | 45 | // Gutenberg is not active. |
| 46 | 46 | return; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - register_block_type( 'wordlift/faceted-search', array( |
|
| 49 | + register_block_type('wordlift/faceted-search', array( |
|
| 50 | 50 | 'editor_script' => 'wl-block-editor', |
| 51 | - 'render_callback' => function ( $attributes ) use ( $scope ) { |
|
| 51 | + 'render_callback' => function($attributes) use ($scope) { |
|
| 52 | 52 | $attr_code = ''; |
| 53 | - foreach ( $attributes as $key => $value ) { |
|
| 54 | - $attr_code .= $key . '="' . htmlentities( $value ) . '" '; |
|
| 53 | + foreach ($attributes as $key => $value) { |
|
| 54 | + $attr_code .= $key.'="'.htmlentities($value).'" '; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - return '[' . $scope::SHORTCODE . ' ' . $attr_code . ']'; |
|
| 57 | + return '['.$scope::SHORTCODE.' '.$attr_code.']'; |
|
| 58 | 58 | }, |
| 59 | 59 | 'attributes' => array( |
| 60 | 60 | 'title' => array( |
| 61 | 61 | 'type' => 'string', |
| 62 | - 'default' => __( 'Related articles', 'wordlift' ), |
|
| 62 | + 'default' => __('Related articles', 'wordlift'), |
|
| 63 | 63 | ), |
| 64 | 64 | 'template_id' => array( |
| 65 | 65 | 'type' => 'string', |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | ), |
| 76 | 76 | 'limit' => array( |
| 77 | 77 | 'type' => 'number', |
| 78 | - 'default' => apply_filters( 'wl_faceted_search_default_limit', 10 ), |
|
| 78 | + 'default' => apply_filters('wl_faceted_search_default_limit', 10), |
|
| 79 | 79 | ), |
| 80 | 80 | 'preview' => array( |
| 81 | 81 | 'type' => 'boolean', |
@@ -83,10 +83,10 @@ discard block |
||
| 83 | 83 | ), |
| 84 | 84 | 'preview_src' => array( |
| 85 | 85 | 'type' => 'string', |
| 86 | - 'default' => WP_CONTENT_URL . '/plugins/wordlift/images/block-previews/faceted-search.png', |
|
| 86 | + 'default' => WP_CONTENT_URL.'/plugins/wordlift/images/block-previews/faceted-search.png', |
|
| 87 | 87 | ), |
| 88 | 88 | ), |
| 89 | - ) ); |
|
| 89 | + )); |
|
| 90 | 90 | } ); |
| 91 | 91 | } |
| 92 | 92 | |
@@ -100,16 +100,16 @@ discard block |
||
| 100 | 100 | * |
| 101 | 101 | * @return array $shortcode_atts |
| 102 | 102 | */ |
| 103 | - private function make_shortcode_atts( $atts ) { |
|
| 103 | + private function make_shortcode_atts($atts) { |
|
| 104 | 104 | |
| 105 | 105 | // Extract attributes and set default values. |
| 106 | - $shortcode_atts = shortcode_atts( array( |
|
| 107 | - 'title' => __( 'Related articles', 'wordlift' ), |
|
| 108 | - 'limit' => apply_filters( 'wl_faceted_search_default_limit', 10 ), |
|
| 106 | + $shortcode_atts = shortcode_atts(array( |
|
| 107 | + 'title' => __('Related articles', 'wordlift'), |
|
| 108 | + 'limit' => apply_filters('wl_faceted_search_default_limit', 10), |
|
| 109 | 109 | 'post_id' => '', |
| 110 | 110 | 'template_id' => '', |
| 111 | - 'uniqid' => uniqid( 'wl-faceted-widget-' ), |
|
| 112 | - ), $atts ); |
|
| 111 | + 'uniqid' => uniqid('wl-faceted-widget-'), |
|
| 112 | + ), $atts); |
|
| 113 | 113 | |
| 114 | 114 | return $shortcode_atts; |
| 115 | 115 | } |
@@ -123,37 +123,37 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @return string Shortcode HTML for web |
| 125 | 125 | */ |
| 126 | - private function web_shortcode( $atts ) { |
|
| 126 | + private function web_shortcode($atts) { |
|
| 127 | 127 | |
| 128 | 128 | // attributes extraction and boolean filtering |
| 129 | - $shortcode_atts = $this->make_shortcode_atts( $atts ); |
|
| 129 | + $shortcode_atts = $this->make_shortcode_atts($atts); |
|
| 130 | 130 | |
| 131 | 131 | // avoid building the widget when no post_id is specified and there is a list of posts. |
| 132 | - if ( empty( $shortcode_atts['post_id'] ) && ! is_singular() ) { |
|
| 132 | + if (empty($shortcode_atts['post_id']) && ! is_singular()) { |
|
| 133 | 133 | return; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - $post = ! empty( $shortcode_atts['post_id'] ) ? get_post( intval( sanitize_text_field( $shortcode_atts['post_id'] ) ) ) : get_post(); |
|
| 137 | - $title = esc_attr( sanitize_text_field( $shortcode_atts['title'] ) ); |
|
| 138 | - $template_id = esc_attr( sanitize_text_field( $shortcode_atts['template_id'] ) ); |
|
| 139 | - $limit = esc_attr( sanitize_text_field( $shortcode_atts['limit'] ) ); |
|
| 140 | - $faceted_id = ! empty( $shortcode_atts['uniqid'] ) ? esc_attr( sanitize_text_field( $shortcode_atts['uniqid'] ) ) : uniqid( 'wl-faceted-widget-' ); |
|
| 136 | + $post = ! empty($shortcode_atts['post_id']) ? get_post(intval(sanitize_text_field($shortcode_atts['post_id']))) : get_post(); |
|
| 137 | + $title = esc_attr(sanitize_text_field($shortcode_atts['title'])); |
|
| 138 | + $template_id = esc_attr(sanitize_text_field($shortcode_atts['template_id'])); |
|
| 139 | + $limit = esc_attr(sanitize_text_field($shortcode_atts['limit'])); |
|
| 140 | + $faceted_id = ! empty($shortcode_atts['uniqid']) ? esc_attr(sanitize_text_field($shortcode_atts['uniqid'])) : uniqid('wl-faceted-widget-'); |
|
| 141 | 141 | |
| 142 | - $permalink_structure = get_option( 'permalink_structure' ); |
|
| 143 | - $delimiter = empty( $permalink_structure ) ? '&' : '?'; |
|
| 144 | - $rest_url = $post ? rest_url( WL_REST_ROUTE_DEFAULT_NAMESPACE . '/faceted-search' . $delimiter . build_query( array( |
|
| 142 | + $permalink_structure = get_option('permalink_structure'); |
|
| 143 | + $delimiter = empty($permalink_structure) ? '&' : '?'; |
|
| 144 | + $rest_url = $post ? rest_url(WL_REST_ROUTE_DEFAULT_NAMESPACE.'/faceted-search'.$delimiter.build_query(array( |
|
| 145 | 145 | 'post_id' => $post->ID, |
| 146 | 146 | 'limit' => $limit |
| 147 | - ) ) ) : false; |
|
| 147 | + ))) : false; |
|
| 148 | 148 | |
| 149 | 149 | // avoid building the widget when no valid $rest_url |
| 150 | - if ( ! $rest_url ) { |
|
| 150 | + if ( ! $rest_url) { |
|
| 151 | 151 | return; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - wp_enqueue_script( 'wordlift-cloud' ); |
|
| 155 | - $json_faceted_id = wp_json_encode( $faceted_id ); |
|
| 156 | - $template_url = get_rest_url( null, '/wordlift/v1/faceted-search/template' ); |
|
| 154 | + wp_enqueue_script('wordlift-cloud'); |
|
| 155 | + $json_faceted_id = wp_json_encode($faceted_id); |
|
| 156 | + $template_url = get_rest_url(null, '/wordlift/v1/faceted-search/template'); |
|
| 157 | 157 | |
| 158 | 158 | return <<<HTML |
| 159 | 159 | <!-- Faceted {$faceted_id} --> |
@@ -179,44 +179,44 @@ discard block |
||
| 179 | 179 | * |
| 180 | 180 | * @return string Shortcode HTML for amp |
| 181 | 181 | */ |
| 182 | - private function amp_shortcode( $atts ) { |
|
| 182 | + private function amp_shortcode($atts) { |
|
| 183 | 183 | |
| 184 | 184 | // attributes extraction and boolean filtering |
| 185 | - $shortcode_atts = $this->make_shortcode_atts( $atts ); |
|
| 185 | + $shortcode_atts = $this->make_shortcode_atts($atts); |
|
| 186 | 186 | |
| 187 | 187 | // avoid building the widget when no post_id is specified and there is a list of posts. |
| 188 | - if ( empty( $shortcode_atts['post_id'] ) && ! is_singular() ) { |
|
| 188 | + if (empty($shortcode_atts['post_id']) && ! is_singular()) { |
|
| 189 | 189 | return; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - $post = ! empty( $shortcode_atts['post_id'] ) ? get_post( intval( sanitize_text_field( $shortcode_atts['post_id'] ) ) ) : get_post(); |
|
| 193 | - $title = esc_attr( sanitize_text_field( $shortcode_atts['title'] ) ); |
|
| 194 | - $template_id = esc_attr( sanitize_text_field( $shortcode_atts['template_id'] ) ); |
|
| 195 | - $limit = esc_attr( sanitize_text_field( $shortcode_atts['limit'] ) ); |
|
| 196 | - $faceted_id = ! empty( $shortcode_atts['uniqid'] ) ? esc_attr( sanitize_text_field( $shortcode_atts['uniqid'] ) ) : uniqid( 'wl-faceted-widget-' ); |
|
| 192 | + $post = ! empty($shortcode_atts['post_id']) ? get_post(intval(sanitize_text_field($shortcode_atts['post_id']))) : get_post(); |
|
| 193 | + $title = esc_attr(sanitize_text_field($shortcode_atts['title'])); |
|
| 194 | + $template_id = esc_attr(sanitize_text_field($shortcode_atts['template_id'])); |
|
| 195 | + $limit = esc_attr(sanitize_text_field($shortcode_atts['limit'])); |
|
| 196 | + $faceted_id = ! empty($shortcode_atts['uniqid']) ? esc_attr(sanitize_text_field($shortcode_atts['uniqid'])) : uniqid('wl-faceted-widget-'); |
|
| 197 | 197 | |
| 198 | - $permalink_structure = get_option( 'permalink_structure' ); |
|
| 199 | - $delimiter = empty( $permalink_structure ) ? '&' : '?'; |
|
| 200 | - $rest_url = $post ? rest_url( WL_REST_ROUTE_DEFAULT_NAMESPACE . '/faceted-search' . $delimiter . build_query( array( |
|
| 198 | + $permalink_structure = get_option('permalink_structure'); |
|
| 199 | + $delimiter = empty($permalink_structure) ? '&' : '?'; |
|
| 200 | + $rest_url = $post ? rest_url(WL_REST_ROUTE_DEFAULT_NAMESPACE.'/faceted-search'.$delimiter.build_query(array( |
|
| 201 | 201 | 'amp', |
| 202 | 202 | 'post_id' => $post->ID, |
| 203 | 203 | 'limit' => $limit |
| 204 | - ) ) ) : false; |
|
| 204 | + ))) : false; |
|
| 205 | 205 | |
| 206 | - $rest_url = $post ? rest_url( sprintf( "wordlift/v1/faceted-search?amp&post_id=%s&limit=%s", $post->ID, $limit ) ) : false; |
|
| 206 | + $rest_url = $post ? rest_url(sprintf("wordlift/v1/faceted-search?amp&post_id=%s&limit=%s", $post->ID, $limit)) : false; |
|
| 207 | 207 | |
| 208 | 208 | // avoid building the widget when no valid $rest_url |
| 209 | - if ( ! $rest_url ) { |
|
| 209 | + if ( ! $rest_url) { |
|
| 210 | 210 | return; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | // Use a protocol-relative URL as amp-list spec says that URL's protocol must be HTTPS. |
| 214 | 214 | // This is a hackish way, but this works for http and https URLs |
| 215 | - $rest_url = str_replace( array( 'http:', 'https:' ), '', $rest_url ); |
|
| 215 | + $rest_url = str_replace(array('http:', 'https:'), '', $rest_url); |
|
| 216 | 216 | |
| 217 | - if ( empty( $template_id ) ) { |
|
| 218 | - $template_id = "template-" . $faceted_id; |
|
| 219 | - wp_enqueue_style( 'wordlift-amp-custom', plugin_dir_url( dirname( __FILE__ ) ) . '/css/wordlift-amp-custom.min.css' ); |
|
| 217 | + if (empty($template_id)) { |
|
| 218 | + $template_id = "template-".$faceted_id; |
|
| 219 | + wp_enqueue_style('wordlift-amp-custom', plugin_dir_url(dirname(__FILE__)).'/css/wordlift-amp-custom.min.css'); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | return <<<HTML |