@@ -93,7 +93,7 @@ |
||
| 93 | 93 | * |
| 94 | 94 | * @since 3.0.0 |
| 95 | 95 | * |
| 96 | - * @param $text string A text that may potentially contain a WL key. |
|
| 96 | + * @param string $text string A text that may potentially contain a WL key. |
|
| 97 | 97 | * |
| 98 | 98 | * @return string A text with the key hidden. |
| 99 | 99 | */ |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | // If this file is called directly, abort. |
| 28 | 28 | if ( ! defined( 'WPINC' ) ) { |
| 29 | - die; |
|
| 29 | + die; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | // Include WordLift constants. |
@@ -47,18 +47,18 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | function wl_write_log( $log ) { |
| 49 | 49 | |
| 50 | - $handler = apply_filters( 'wl_write_log_handler', NULL ); |
|
| 50 | + $handler = apply_filters( 'wl_write_log_handler', NULL ); |
|
| 51 | 51 | |
| 52 | - $callers = debug_backtrace(); |
|
| 53 | - $caller_function = $callers[1]['function']; |
|
| 52 | + $callers = debug_backtrace(); |
|
| 53 | + $caller_function = $callers[1]['function']; |
|
| 54 | 54 | |
| 55 | - if ( is_null( $handler ) ) { |
|
| 56 | - wl_write_log_handler( $log, $caller_function ); |
|
| 55 | + if ( is_null( $handler ) ) { |
|
| 56 | + wl_write_log_handler( $log, $caller_function ); |
|
| 57 | 57 | |
| 58 | - return; |
|
| 59 | - } |
|
| 58 | + return; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - call_user_func( $handler, $log, $caller_function ); |
|
| 61 | + call_user_func( $handler, $log, $caller_function ); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -71,20 +71,20 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | function wl_write_log_handler( $log, $caller = NULL ) { |
| 73 | 73 | |
| 74 | - global $wl_logger; |
|
| 74 | + global $wl_logger; |
|
| 75 | 75 | |
| 76 | - if ( TRUE === WP_DEBUG ) { |
|
| 76 | + if ( TRUE === WP_DEBUG ) { |
|
| 77 | 77 | |
| 78 | - $message = ( isset( $caller ) ? sprintf( '[%-40.40s] ', $caller ) : '' ) . |
|
| 79 | - ( is_array( $log ) || is_object( $log ) ? print_r( $log, TRUE ) : wl_write_log_hide_key( $log ) ); |
|
| 78 | + $message = ( isset( $caller ) ? sprintf( '[%-40.40s] ', $caller ) : '' ) . |
|
| 79 | + ( is_array( $log ) || is_object( $log ) ? print_r( $log, TRUE ) : wl_write_log_hide_key( $log ) ); |
|
| 80 | 80 | |
| 81 | - if ( isset( $wl_logger ) ) { |
|
| 82 | - $wl_logger->info( $message ); |
|
| 83 | - } else { |
|
| 84 | - error_log( $message ); |
|
| 85 | - } |
|
| 81 | + if ( isset( $wl_logger ) ) { |
|
| 82 | + $wl_logger->info( $message ); |
|
| 83 | + } else { |
|
| 84 | + error_log( $message ); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - } |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | 89 | } |
| 90 | 90 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | function wl_write_log_hide_key( $text ) { |
| 101 | 101 | |
| 102 | - return str_ireplace( wl_configuration_get_key(), '<hidden>', $text ); |
|
| 102 | + return str_ireplace( wl_configuration_get_key(), '<hidden>', $text ); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -111,10 +111,10 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | function wl_queue_sparql_update_query( $query ) { |
| 113 | 113 | |
| 114 | - $filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql'; |
|
| 115 | - file_put_contents( $filename, $query . "\n", FILE_APPEND ); |
|
| 114 | + $filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql'; |
|
| 115 | + file_put_contents( $filename, $query . "\n", FILE_APPEND ); |
|
| 116 | 116 | |
| 117 | - wl_write_log( "wl_queue_sparql_update_query [ filename :: $filename ]" ); |
|
| 117 | + wl_write_log( "wl_queue_sparql_update_query [ filename :: $filename ]" ); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
@@ -124,28 +124,28 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | function wl_execute_saved_sparql_update_query( $request_id ) { |
| 126 | 126 | |
| 127 | - $filename = WL_TEMP_DIR . $request_id . '.sparql'; |
|
| 127 | + $filename = WL_TEMP_DIR . $request_id . '.sparql'; |
|
| 128 | 128 | |
| 129 | - // If the file doesn't exist, exit. |
|
| 130 | - if ( ! file_exists( $filename ) ) { |
|
| 131 | - wl_write_log( "wl_execute_saved_sparql_update_query : file doesn't exist [ filename :: $filename ]" ); |
|
| 129 | + // If the file doesn't exist, exit. |
|
| 130 | + if ( ! file_exists( $filename ) ) { |
|
| 131 | + wl_write_log( "wl_execute_saved_sparql_update_query : file doesn't exist [ filename :: $filename ]" ); |
|
| 132 | 132 | |
| 133 | - return; |
|
| 134 | - } |
|
| 133 | + return; |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | - wl_write_log( "wl_execute_saved_sparql_update_query [ filename :: $filename ]" ); |
|
| 136 | + wl_write_log( "wl_execute_saved_sparql_update_query [ filename :: $filename ]" ); |
|
| 137 | 137 | |
| 138 | - // Get the query saved in the file. |
|
| 139 | - $query = file_get_contents( $filename ); |
|
| 138 | + // Get the query saved in the file. |
|
| 139 | + $query = file_get_contents( $filename ); |
|
| 140 | 140 | |
| 141 | - // Execute the SPARQL query. |
|
| 142 | - rl_execute_sparql_update_query( $query, FALSE ); |
|
| 141 | + // Execute the SPARQL query. |
|
| 142 | + rl_execute_sparql_update_query( $query, FALSE ); |
|
| 143 | 143 | |
| 144 | - // Reindex the triple store. |
|
| 145 | - wordlift_reindex_triple_store(); |
|
| 144 | + // Reindex the triple store. |
|
| 145 | + wordlift_reindex_triple_store(); |
|
| 146 | 146 | |
| 147 | - // Delete the temporary file. |
|
| 148 | - unlink( $filename ); |
|
| 147 | + // Delete the temporary file. |
|
| 148 | + unlink( $filename ); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | add_action( 'wl_execute_saved_sparql_update_query', 'wl_execute_saved_sparql_update_query', 10, 1 ); |
@@ -155,10 +155,10 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | function wordlift_buttonhooks() { |
| 157 | 157 | |
| 158 | - // Only add hooks when the current user has permissions AND is in Rich Text editor mode |
|
| 159 | - if ( ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) && get_user_option( 'rich_editing' ) ) { |
|
| 160 | - add_filter( 'mce_external_plugins', 'wordlift_register_tinymce_javascript' ); |
|
| 161 | - } |
|
| 158 | + // Only add hooks when the current user has permissions AND is in Rich Text editor mode |
|
| 159 | + if ( ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) && get_user_option( 'rich_editing' ) ) { |
|
| 160 | + add_filter( 'mce_external_plugins', 'wordlift_register_tinymce_javascript' ); |
|
| 161 | + } |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -170,11 +170,11 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | function wordlift_register_tinymce_javascript( $plugin_array ) { |
| 172 | 172 | |
| 173 | - // add the wordlift plugin. |
|
| 174 | - // We can't use the minified version here. |
|
| 175 | - $plugin_array['wordlift'] = plugin_dir_url( __FILE__ ) . 'js/wordlift-reloaded.js'; |
|
| 173 | + // add the wordlift plugin. |
|
| 174 | + // We can't use the minified version here. |
|
| 175 | + $plugin_array['wordlift'] = plugin_dir_url( __FILE__ ) . 'js/wordlift-reloaded.js'; |
|
| 176 | 176 | |
| 177 | - return $plugin_array; |
|
| 177 | + return $plugin_array; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -182,21 +182,21 @@ discard block |
||
| 182 | 182 | * see http://vip.wordpress.com/documentation/register-additional-html-attributes-for-tinymce-and-wp-kses/ |
| 183 | 183 | */ |
| 184 | 184 | function wordlift_allowed_post_tags() { |
| 185 | - global $allowedposttags; |
|
| 186 | - |
|
| 187 | - $tags = array( 'span' ); |
|
| 188 | - $new_attributes = array( |
|
| 189 | - 'itemscope' => array(), |
|
| 190 | - 'itemtype' => array(), |
|
| 191 | - 'itemprop' => array(), |
|
| 192 | - 'itemid' => array(), |
|
| 193 | - ); |
|
| 194 | - |
|
| 195 | - foreach ( $tags as $tag ) { |
|
| 196 | - if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) { |
|
| 197 | - $allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes ); |
|
| 198 | - } |
|
| 199 | - } |
|
| 185 | + global $allowedposttags; |
|
| 186 | + |
|
| 187 | + $tags = array( 'span' ); |
|
| 188 | + $new_attributes = array( |
|
| 189 | + 'itemscope' => array(), |
|
| 190 | + 'itemtype' => array(), |
|
| 191 | + 'itemprop' => array(), |
|
| 192 | + 'itemid' => array(), |
|
| 193 | + ); |
|
| 194 | + |
|
| 195 | + foreach ( $tags as $tag ) { |
|
| 196 | + if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) { |
|
| 197 | + $allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes ); |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | // init process for button control |
@@ -210,28 +210,28 @@ discard block |
||
| 210 | 210 | */ |
| 211 | 211 | function wordlift_admin_enqueue_scripts() { |
| 212 | 212 | |
| 213 | - // Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/) |
|
| 214 | - wp_enqueue_script( 'wpdialogs' ); |
|
| 215 | - wp_enqueue_style( 'wp-jquery-ui-dialog' ); |
|
| 213 | + // Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/) |
|
| 214 | + wp_enqueue_script( 'wpdialogs' ); |
|
| 215 | + wp_enqueue_style( 'wp-jquery-ui-dialog' ); |
|
| 216 | 216 | |
| 217 | - wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css' ); |
|
| 217 | + wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css' ); |
|
| 218 | 218 | |
| 219 | - wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
| 220 | - wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' ); |
|
| 221 | - wp_enqueue_script( 'angularjs-geolocation', plugin_dir_url( __FILE__ ) . '/bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js' ); |
|
| 222 | - wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js' ); |
|
| 223 | - wp_enqueue_script( 'angularjs-animate', 'https://code.angularjs.org/1.3.11/angular-animate.min.js' ); |
|
| 219 | + wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
| 220 | + wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' ); |
|
| 221 | + wp_enqueue_script( 'angularjs-geolocation', plugin_dir_url( __FILE__ ) . '/bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js' ); |
|
| 222 | + wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js' ); |
|
| 223 | + wp_enqueue_script( 'angularjs-animate', 'https://code.angularjs.org/1.3.11/angular-animate.min.js' ); |
|
| 224 | 224 | |
| 225 | - // Disable auto-save for custom entity posts only |
|
| 226 | - if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) { |
|
| 227 | - wp_dequeue_script( 'autosave' ); |
|
| 228 | - } |
|
| 225 | + // Disable auto-save for custom entity posts only |
|
| 226 | + if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) { |
|
| 227 | + wp_dequeue_script( 'autosave' ); |
|
| 228 | + } |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | add_action( 'admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts' ); |
| 232 | 232 | |
| 233 | 233 | function wl_enqueue_scripts() { |
| 234 | - wp_enqueue_style( 'wordlift-ui', plugin_dir_url( __FILE__ ) . 'css/wordlift-ui.min.css' ); |
|
| 234 | + wp_enqueue_style( 'wordlift-ui', plugin_dir_url( __FILE__ ) . 'css/wordlift-ui.min.css' ); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | add_action( 'wp_enqueue_scripts', 'wl_enqueue_scripts' ); |
@@ -246,18 +246,18 @@ discard block |
||
| 246 | 246 | */ |
| 247 | 247 | function wordlift_allowed_html( $allowedtags, $context ) { |
| 248 | 248 | |
| 249 | - if ( 'post' !== $context ) { |
|
| 250 | - return $allowedtags; |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - return array_merge_recursive( $allowedtags, array( |
|
| 254 | - 'span' => array( |
|
| 255 | - 'itemscope' => TRUE, |
|
| 256 | - 'itemtype' => TRUE, |
|
| 257 | - 'itemid' => TRUE, |
|
| 258 | - 'itemprop' => TRUE, |
|
| 259 | - ), |
|
| 260 | - ) ); |
|
| 249 | + if ( 'post' !== $context ) { |
|
| 250 | + return $allowedtags; |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + return array_merge_recursive( $allowedtags, array( |
|
| 254 | + 'span' => array( |
|
| 255 | + 'itemscope' => TRUE, |
|
| 256 | + 'itemtype' => TRUE, |
|
| 257 | + 'itemid' => TRUE, |
|
| 258 | + 'itemprop' => TRUE, |
|
| 259 | + ), |
|
| 260 | + ) ); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | add_filter( 'wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2 ); |
@@ -271,15 +271,15 @@ discard block |
||
| 271 | 271 | */ |
| 272 | 272 | function wl_get_coordinates( $post_id ) { |
| 273 | 273 | |
| 274 | - $latitude = wl_schema_get_value( $post_id, 'latitude' ); |
|
| 275 | - $longitude = wl_schema_get_value( $post_id, 'longitude' ); |
|
| 274 | + $latitude = wl_schema_get_value( $post_id, 'latitude' ); |
|
| 275 | + $longitude = wl_schema_get_value( $post_id, 'longitude' ); |
|
| 276 | 276 | |
| 277 | - // DO NOT set latitude/longitude to 0/0 as default values. It's a specific place on the globe: |
|
| 278 | - // "The zero/zero point of this system is located in the Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana." |
|
| 279 | - return array( |
|
| 280 | - 'latitude' => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '', |
|
| 281 | - 'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '', |
|
| 282 | - ); |
|
| 277 | + // DO NOT set latitude/longitude to 0/0 as default values. It's a specific place on the globe: |
|
| 278 | + // "The zero/zero point of this system is located in the Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana." |
|
| 279 | + return array( |
|
| 280 | + 'latitude' => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '', |
|
| 281 | + 'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '', |
|
| 282 | + ); |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | /** |
@@ -291,13 +291,13 @@ discard block |
||
| 291 | 291 | */ |
| 292 | 292 | function wl_get_post_modified_time( $post ) { |
| 293 | 293 | |
| 294 | - $date_modified = get_post_modified_time( 'c', TRUE, $post ); |
|
| 294 | + $date_modified = get_post_modified_time( 'c', TRUE, $post ); |
|
| 295 | 295 | |
| 296 | - if ( '-' === substr( $date_modified, 0, 1 ) ) { |
|
| 297 | - return get_the_time( 'c', $post ); |
|
| 298 | - } |
|
| 296 | + if ( '-' === substr( $date_modified, 0, 1 ) ) { |
|
| 297 | + return get_the_time( 'c', $post ); |
|
| 298 | + } |
|
| 299 | 299 | |
| 300 | - return $date_modified; |
|
| 300 | + return $date_modified; |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | /** |
@@ -310,42 +310,42 @@ discard block |
||
| 310 | 310 | function wl_get_image_urls( $post_id ) { |
| 311 | 311 | |
| 312 | 312 | |
| 313 | - // If there is a featured image it has the priority |
|
| 314 | - $featured_image_id = get_post_thumbnail_id( $post_id ); |
|
| 315 | - if ( is_numeric( $featured_image_id ) ) { |
|
| 316 | - $image_url = wp_get_attachment_url( $featured_image_id ); |
|
| 313 | + // If there is a featured image it has the priority |
|
| 314 | + $featured_image_id = get_post_thumbnail_id( $post_id ); |
|
| 315 | + if ( is_numeric( $featured_image_id ) ) { |
|
| 316 | + $image_url = wp_get_attachment_url( $featured_image_id ); |
|
| 317 | 317 | |
| 318 | - return array( $image_url ); |
|
| 319 | - } |
|
| 318 | + return array( $image_url ); |
|
| 319 | + } |
|
| 320 | 320 | |
| 321 | - // wl_write_log( "wl_get_image_urls [ post id :: $post_id ]" ); |
|
| 321 | + // wl_write_log( "wl_get_image_urls [ post id :: $post_id ]" ); |
|
| 322 | 322 | |
| 323 | - $images = get_children( array( |
|
| 324 | - 'post_parent' => $post_id, |
|
| 325 | - 'post_type' => 'attachment', |
|
| 326 | - 'post_mime_type' => 'image', |
|
| 327 | - ) ); |
|
| 323 | + $images = get_children( array( |
|
| 324 | + 'post_parent' => $post_id, |
|
| 325 | + 'post_type' => 'attachment', |
|
| 326 | + 'post_mime_type' => 'image', |
|
| 327 | + ) ); |
|
| 328 | 328 | |
| 329 | - // Return an empty array if no image is found. |
|
| 330 | - if ( empty( $images ) ) { |
|
| 331 | - return array(); |
|
| 332 | - } |
|
| 329 | + // Return an empty array if no image is found. |
|
| 330 | + if ( empty( $images ) ) { |
|
| 331 | + return array(); |
|
| 332 | + } |
|
| 333 | 333 | |
| 334 | - // Prepare the return array. |
|
| 335 | - $image_urls = array(); |
|
| 334 | + // Prepare the return array. |
|
| 335 | + $image_urls = array(); |
|
| 336 | 336 | |
| 337 | - // Collect the URLs. |
|
| 338 | - foreach ( $images as $attachment_id => $attachment ) { |
|
| 339 | - $image_url = wp_get_attachment_url( $attachment_id ); |
|
| 340 | - // Ensure the URL isn't collected already. |
|
| 341 | - if ( ! in_array( $image_url, $image_urls ) ) { |
|
| 342 | - array_push( $image_urls, $image_url ); |
|
| 343 | - } |
|
| 344 | - } |
|
| 337 | + // Collect the URLs. |
|
| 338 | + foreach ( $images as $attachment_id => $attachment ) { |
|
| 339 | + $image_url = wp_get_attachment_url( $attachment_id ); |
|
| 340 | + // Ensure the URL isn't collected already. |
|
| 341 | + if ( ! in_array( $image_url, $image_urls ) ) { |
|
| 342 | + array_push( $image_urls, $image_url ); |
|
| 343 | + } |
|
| 344 | + } |
|
| 345 | 345 | |
| 346 | - // wl_write_log( "wl_get_image_urls [ post id :: $post_id ][ image urls count :: " . count( $image_urls ) . " ]" ); |
|
| 346 | + // wl_write_log( "wl_get_image_urls [ post id :: $post_id ][ image urls count :: " . count( $image_urls ) . " ]" ); |
|
| 347 | 347 | |
| 348 | - return $image_urls; |
|
| 348 | + return $image_urls; |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | /** |
@@ -358,19 +358,19 @@ discard block |
||
| 358 | 358 | */ |
| 359 | 359 | function wl_get_sparql_images( $uri, $post_id ) { |
| 360 | 360 | |
| 361 | - $sparql = ''; |
|
| 361 | + $sparql = ''; |
|
| 362 | 362 | |
| 363 | - // Get the escaped URI. |
|
| 364 | - $uri_e = esc_html( $uri ); |
|
| 363 | + // Get the escaped URI. |
|
| 364 | + $uri_e = esc_html( $uri ); |
|
| 365 | 365 | |
| 366 | - // Add SPARQL stmts to write the schema:image. |
|
| 367 | - $image_urls = wl_get_image_urls( $post_id ); |
|
| 368 | - foreach ( $image_urls as $image_url ) { |
|
| 369 | - $image_url_esc = wl_sparql_escape_uri( $image_url ); |
|
| 370 | - $sparql .= " <$uri_e> schema:image <$image_url_esc> . \n"; |
|
| 371 | - } |
|
| 366 | + // Add SPARQL stmts to write the schema:image. |
|
| 367 | + $image_urls = wl_get_image_urls( $post_id ); |
|
| 368 | + foreach ( $image_urls as $image_url ) { |
|
| 369 | + $image_url_esc = wl_sparql_escape_uri( $image_url ); |
|
| 370 | + $sparql .= " <$uri_e> schema:image <$image_url_esc> . \n"; |
|
| 371 | + } |
|
| 372 | 372 | |
| 373 | - return $sparql; |
|
| 373 | + return $sparql; |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | /** |
@@ -383,24 +383,24 @@ discard block |
||
| 383 | 383 | */ |
| 384 | 384 | function wl_get_attachment_for_source_url( $parent_post_id, $source_url ) { |
| 385 | 385 | |
| 386 | - // wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" ); |
|
| 386 | + // wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" ); |
|
| 387 | 387 | |
| 388 | - $posts = get_posts( array( |
|
| 389 | - 'post_type' => 'attachment', |
|
| 390 | - 'posts_per_page' => 1, |
|
| 391 | - 'post_status' => 'any', |
|
| 392 | - 'post_parent' => $parent_post_id, |
|
| 393 | - 'meta_key' => 'wl_source_url', |
|
| 394 | - 'meta_value' => $source_url, |
|
| 395 | - ) ); |
|
| 388 | + $posts = get_posts( array( |
|
| 389 | + 'post_type' => 'attachment', |
|
| 390 | + 'posts_per_page' => 1, |
|
| 391 | + 'post_status' => 'any', |
|
| 392 | + 'post_parent' => $parent_post_id, |
|
| 393 | + 'meta_key' => 'wl_source_url', |
|
| 394 | + 'meta_value' => $source_url, |
|
| 395 | + ) ); |
|
| 396 | 396 | |
| 397 | - // Return the found post. |
|
| 398 | - if ( 1 === count( $posts ) ) { |
|
| 399 | - return $posts[0]; |
|
| 400 | - } |
|
| 397 | + // Return the found post. |
|
| 398 | + if ( 1 === count( $posts ) ) { |
|
| 399 | + return $posts[0]; |
|
| 400 | + } |
|
| 401 | 401 | |
| 402 | - // Return null. |
|
| 403 | - return NULL; |
|
| 402 | + // Return null. |
|
| 403 | + return NULL; |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | /** |
@@ -411,8 +411,8 @@ discard block |
||
| 411 | 411 | */ |
| 412 | 412 | function wl_set_source_url( $post_id, $source_url ) { |
| 413 | 413 | |
| 414 | - delete_post_meta( $post_id, 'wl_source_url' ); |
|
| 415 | - add_post_meta( $post_id, 'wl_source_url', $source_url ); |
|
| 414 | + delete_post_meta( $post_id, 'wl_source_url' ); |
|
| 415 | + add_post_meta( $post_id, 'wl_source_url', $source_url ); |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | |
@@ -430,61 +430,61 @@ discard block |
||
| 430 | 430 | */ |
| 431 | 431 | function wl_flush_rewrite_rules_hard( $hard ) { |
| 432 | 432 | |
| 433 | - // If WL is not yet configured, we cannot perform any update, so we exit. |
|
| 434 | - if ( '' === wl_configuration_get_key() ) { |
|
| 435 | - return; |
|
| 436 | - } |
|
| 433 | + // If WL is not yet configured, we cannot perform any update, so we exit. |
|
| 434 | + if ( '' === wl_configuration_get_key() ) { |
|
| 435 | + return; |
|
| 436 | + } |
|
| 437 | 437 | |
| 438 | - // Set the initial offset and limit each call to 100 posts to avoid memory errors. |
|
| 439 | - $offset = 0; |
|
| 440 | - $limit = 100; |
|
| 438 | + // Set the initial offset and limit each call to 100 posts to avoid memory errors. |
|
| 439 | + $offset = 0; |
|
| 440 | + $limit = 100; |
|
| 441 | 441 | |
| 442 | - // Get more posts if the number of returned posts matches the limit. |
|
| 443 | - while ( $limit === ( $posts = get_posts( array( |
|
| 444 | - 'offset' => $offset, |
|
| 445 | - 'numberposts' => $limit, |
|
| 446 | - 'orderby' => 'ID', |
|
| 447 | - 'post_type' => 'any', |
|
| 448 | - 'post_status' => 'publish', |
|
| 449 | - ) ) ) ) { |
|
| 442 | + // Get more posts if the number of returned posts matches the limit. |
|
| 443 | + while ( $limit === ( $posts = get_posts( array( |
|
| 444 | + 'offset' => $offset, |
|
| 445 | + 'numberposts' => $limit, |
|
| 446 | + 'orderby' => 'ID', |
|
| 447 | + 'post_type' => 'any', |
|
| 448 | + 'post_status' => 'publish', |
|
| 449 | + ) ) ) ) { |
|
| 450 | 450 | |
| 451 | - // Holds the delete part of the query. |
|
| 452 | - $delete_query = rl_sparql_prefixes(); |
|
| 451 | + // Holds the delete part of the query. |
|
| 452 | + $delete_query = rl_sparql_prefixes(); |
|
| 453 | 453 | |
| 454 | - // Holds the insert part of the query. |
|
| 455 | - $insert_query = ''; |
|
| 454 | + // Holds the insert part of the query. |
|
| 455 | + $insert_query = ''; |
|
| 456 | 456 | |
| 457 | - // Cycle in each post to build the query. |
|
| 458 | - foreach ( $posts as $post ) { |
|
| 457 | + // Cycle in each post to build the query. |
|
| 458 | + foreach ( $posts as $post ) { |
|
| 459 | 459 | |
| 460 | - // Ignore revisions. |
|
| 461 | - if ( wp_is_post_revision( $post->ID ) ) { |
|
| 462 | - continue; |
|
| 463 | - } |
|
| 460 | + // Ignore revisions. |
|
| 461 | + if ( wp_is_post_revision( $post->ID ) ) { |
|
| 462 | + continue; |
|
| 463 | + } |
|
| 464 | 464 | |
| 465 | - // Get the entity URI. |
|
| 466 | - $s = Wordlift_Sparql_Service::escape_uri( Wordlift_Entity_Service::get_instance() |
|
| 467 | - ->get_uri( $post->ID ) ); |
|
| 465 | + // Get the entity URI. |
|
| 466 | + $s = Wordlift_Sparql_Service::escape_uri( Wordlift_Entity_Service::get_instance() |
|
| 467 | + ->get_uri( $post->ID ) ); |
|
| 468 | 468 | |
| 469 | - // Get the post URL. |
|
| 470 | - // $url = wl_sparql_escape_uri( get_permalink( $post->ID ) ); |
|
| 469 | + // Get the post URL. |
|
| 470 | + // $url = wl_sparql_escape_uri( get_permalink( $post->ID ) ); |
|
| 471 | 471 | |
| 472 | - // Prepare the DELETE and INSERT commands. |
|
| 473 | - $delete_query .= "DELETE { <$s> schema:url ?u . } WHERE { <$s> schema:url ?u . };\n"; |
|
| 472 | + // Prepare the DELETE and INSERT commands. |
|
| 473 | + $delete_query .= "DELETE { <$s> schema:url ?u . } WHERE { <$s> schema:url ?u . };\n"; |
|
| 474 | 474 | |
| 475 | - $insert_query .= Wordlift_Schema_Url_Property_Service::get_instance() |
|
| 476 | - ->get_insert_query( $s, $post->ID ); |
|
| 475 | + $insert_query .= Wordlift_Schema_Url_Property_Service::get_instance() |
|
| 476 | + ->get_insert_query( $s, $post->ID ); |
|
| 477 | 477 | |
| 478 | - } |
|
| 478 | + } |
|
| 479 | 479 | |
| 480 | 480 | |
| 481 | - // Execute the query. |
|
| 482 | - rl_execute_sparql_update_query( $delete_query . $insert_query ); |
|
| 481 | + // Execute the query. |
|
| 482 | + rl_execute_sparql_update_query( $delete_query . $insert_query ); |
|
| 483 | 483 | |
| 484 | - // Advance to the next posts. |
|
| 485 | - $offset += $limit; |
|
| 484 | + // Advance to the next posts. |
|
| 485 | + $offset += $limit; |
|
| 486 | 486 | |
| 487 | - } |
|
| 487 | + } |
|
| 488 | 488 | |
| 489 | 489 | // // Get all published posts. |
| 490 | 490 | // $posts = get_posts( array( |
@@ -510,7 +510,7 @@ discard block |
||
| 510 | 510 | */ |
| 511 | 511 | function wl_sanitize_uri_path( $path, $char = '_' ) { |
| 512 | 512 | |
| 513 | - return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char ); |
|
| 513 | + return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char ); |
|
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | /** |
@@ -522,11 +522,11 @@ discard block |
||
| 522 | 522 | */ |
| 523 | 523 | function wl_force_to_array( $value ) { |
| 524 | 524 | |
| 525 | - if ( ! is_array( $value ) ) { |
|
| 526 | - return array( $value ); |
|
| 527 | - } |
|
| 525 | + if ( ! is_array( $value ) ) { |
|
| 526 | + return array( $value ); |
|
| 527 | + } |
|
| 528 | 528 | |
| 529 | - return $value; |
|
| 529 | + return $value; |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | /** |
@@ -534,26 +534,26 @@ discard block |
||
| 534 | 534 | */ |
| 535 | 535 | function wl_shutdown() { |
| 536 | 536 | |
| 537 | - // Get the filename to the temporary SPARQL file. |
|
| 538 | - $filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql'; |
|
| 537 | + // Get the filename to the temporary SPARQL file. |
|
| 538 | + $filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql'; |
|
| 539 | 539 | |
| 540 | - // If WordLift is buffering SPARQL queries, we're admins and a buffer exists, then schedule it. |
|
| 541 | - if ( WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING && is_admin() && file_exists( $filename ) ) { |
|
| 540 | + // If WordLift is buffering SPARQL queries, we're admins and a buffer exists, then schedule it. |
|
| 541 | + if ( WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING && is_admin() && file_exists( $filename ) ) { |
|
| 542 | 542 | |
| 543 | - // The request ID. |
|
| 544 | - $args = array( WL_REQUEST_ID ); |
|
| 543 | + // The request ID. |
|
| 544 | + $args = array( WL_REQUEST_ID ); |
|
| 545 | 545 | |
| 546 | - // Schedule the execution of the SPARQL query with the request ID. |
|
| 547 | - wp_schedule_single_event( time(), 'wl_execute_saved_sparql_update_query', $args ); |
|
| 546 | + // Schedule the execution of the SPARQL query with the request ID. |
|
| 547 | + wp_schedule_single_event( time(), 'wl_execute_saved_sparql_update_query', $args ); |
|
| 548 | 548 | |
| 549 | - // Check that the request is scheduled. |
|
| 550 | - $timestamp = wp_next_scheduled( 'wl_execute_saved_sparql_update_query', $args ); |
|
| 549 | + // Check that the request is scheduled. |
|
| 550 | + $timestamp = wp_next_scheduled( 'wl_execute_saved_sparql_update_query', $args ); |
|
| 551 | 551 | |
| 552 | - // Spawn the cron. |
|
| 553 | - spawn_cron(); |
|
| 552 | + // Spawn the cron. |
|
| 553 | + spawn_cron(); |
|
| 554 | 554 | |
| 555 | - wl_write_log( "wl_shutdown [ request id :: " . WL_REQUEST_ID . " ][ timestamp :: $timestamp ]" ); |
|
| 556 | - } |
|
| 555 | + wl_write_log( "wl_shutdown [ request id :: " . WL_REQUEST_ID . " ][ timestamp :: $timestamp ]" ); |
|
| 556 | + } |
|
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | add_action( 'shutdown', 'wl_shutdown' ); |
@@ -567,46 +567,46 @@ discard block |
||
| 567 | 567 | */ |
| 568 | 568 | function wl_replace_item_id_with_uri( $content ) { |
| 569 | 569 | |
| 570 | - // wl_write_log( "wl_replace_item_id_with_uri" ); |
|
| 570 | + // wl_write_log( "wl_replace_item_id_with_uri" ); |
|
| 571 | 571 | |
| 572 | - // Strip slashes, see https://core.trac.wordpress.org/ticket/21767 |
|
| 573 | - $content = stripslashes( $content ); |
|
| 572 | + // Strip slashes, see https://core.trac.wordpress.org/ticket/21767 |
|
| 573 | + $content = stripslashes( $content ); |
|
| 574 | 574 | |
| 575 | - // If any match are found. |
|
| 576 | - $matches = array(); |
|
| 577 | - if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) { |
|
| 575 | + // If any match are found. |
|
| 576 | + $matches = array(); |
|
| 577 | + if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) { |
|
| 578 | 578 | |
| 579 | - foreach ( $matches as $match ) { |
|
| 579 | + foreach ( $matches as $match ) { |
|
| 580 | 580 | |
| 581 | - // Get the item ID. |
|
| 582 | - $item_id = $match[1]; |
|
| 581 | + // Get the item ID. |
|
| 582 | + $item_id = $match[1]; |
|
| 583 | 583 | |
| 584 | - // Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' . |
|
| 585 | - $post = Wordlift_Entity_Service::get_instance() |
|
| 586 | - ->get_entity_post_by_uri( $item_id ); |
|
| 584 | + // Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' . |
|
| 585 | + $post = Wordlift_Entity_Service::get_instance() |
|
| 586 | + ->get_entity_post_by_uri( $item_id ); |
|
| 587 | 587 | |
| 588 | - // If no entity is found, continue to the next one. |
|
| 589 | - if ( NULL === $post ) { |
|
| 590 | - continue; |
|
| 591 | - } |
|
| 588 | + // If no entity is found, continue to the next one. |
|
| 589 | + if ( NULL === $post ) { |
|
| 590 | + continue; |
|
| 591 | + } |
|
| 592 | 592 | |
| 593 | - // Get the URI for that post. |
|
| 594 | - $uri = wl_get_entity_uri( $post->ID ); |
|
| 593 | + // Get the URI for that post. |
|
| 594 | + $uri = wl_get_entity_uri( $post->ID ); |
|
| 595 | 595 | |
| 596 | - // wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" ); |
|
| 596 | + // wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" ); |
|
| 597 | 597 | |
| 598 | - // If the item ID and the URI differ, replace the item ID with the URI saved in WordPress. |
|
| 599 | - if ( $item_id !== $uri ) { |
|
| 600 | - $uri_e = esc_html( $uri ); |
|
| 601 | - $content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content ); |
|
| 602 | - } |
|
| 603 | - } |
|
| 604 | - } |
|
| 598 | + // If the item ID and the URI differ, replace the item ID with the URI saved in WordPress. |
|
| 599 | + if ( $item_id !== $uri ) { |
|
| 600 | + $uri_e = esc_html( $uri ); |
|
| 601 | + $content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content ); |
|
| 602 | + } |
|
| 603 | + } |
|
| 604 | + } |
|
| 605 | 605 | |
| 606 | - // Reapply slashes. |
|
| 607 | - $content = addslashes( $content ); |
|
| 606 | + // Reapply slashes. |
|
| 607 | + $content = addslashes( $content ); |
|
| 608 | 608 | |
| 609 | - return $content; |
|
| 609 | + return $content; |
|
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | add_filter( 'content_save_pre', 'wl_replace_item_id_with_uri', 1, 1 ); |
@@ -679,8 +679,8 @@ discard block |
||
| 679 | 679 | * This action is documented in includes/class-wordlift-activator.php |
| 680 | 680 | */ |
| 681 | 681 | function activate_wordlift() { |
| 682 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php'; |
|
| 683 | - Wordlift_Activator::activate(); |
|
| 682 | + require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php'; |
|
| 683 | + Wordlift_Activator::activate(); |
|
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | /** |
@@ -688,8 +688,8 @@ discard block |
||
| 688 | 688 | * This action is documented in includes/class-wordlift-deactivator.php |
| 689 | 689 | */ |
| 690 | 690 | function deactivate_wordlift() { |
| 691 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php'; |
|
| 692 | - Wordlift_Deactivator::deactivate(); |
|
| 691 | + require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php'; |
|
| 692 | + Wordlift_Deactivator::deactivate(); |
|
| 693 | 693 | } |
| 694 | 694 | |
| 695 | 695 | register_activation_hook( __FILE__, 'activate_wordlift' ); |
@@ -712,8 +712,8 @@ discard block |
||
| 712 | 712 | */ |
| 713 | 713 | function run_wordlift() { |
| 714 | 714 | |
| 715 | - $plugin = new Wordlift(); |
|
| 716 | - $plugin->run(); |
|
| 715 | + $plugin = new Wordlift(); |
|
| 716 | + $plugin->run(); |
|
| 717 | 717 | |
| 718 | 718 | } |
| 719 | 719 | |
@@ -25,16 +25,16 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | // If this file is called directly, abort. |
| 28 | -if ( ! defined( 'WPINC' ) ) { |
|
| 28 | +if ( ! defined('WPINC')) { |
|
| 29 | 29 | die; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | // Include WordLift constants. |
| 33 | -require_once( 'wordlift_constants.php' ); |
|
| 33 | +require_once('wordlift_constants.php'); |
|
| 34 | 34 | |
| 35 | 35 | // Load modules |
| 36 | -require_once( 'modules/core/wordlift_core.php' ); |
|
| 37 | -require_once( 'modules/configuration/wordlift_configuration.php' ); |
|
| 36 | +require_once('modules/core/wordlift_core.php'); |
|
| 37 | +require_once('modules/configuration/wordlift_configuration.php'); |
|
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * Log to the debug.log file. |
@@ -45,20 +45,20 @@ discard block |
||
| 45 | 45 | * |
| 46 | 46 | * @param string|mixed $log The log data. |
| 47 | 47 | */ |
| 48 | -function wl_write_log( $log ) { |
|
| 48 | +function wl_write_log($log) { |
|
| 49 | 49 | |
| 50 | - $handler = apply_filters( 'wl_write_log_handler', NULL ); |
|
| 50 | + $handler = apply_filters('wl_write_log_handler', NULL); |
|
| 51 | 51 | |
| 52 | 52 | $callers = debug_backtrace(); |
| 53 | 53 | $caller_function = $callers[1]['function']; |
| 54 | 54 | |
| 55 | - if ( is_null( $handler ) ) { |
|
| 56 | - wl_write_log_handler( $log, $caller_function ); |
|
| 55 | + if (is_null($handler)) { |
|
| 56 | + wl_write_log_handler($log, $caller_function); |
|
| 57 | 57 | |
| 58 | 58 | return; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - call_user_func( $handler, $log, $caller_function ); |
|
| 61 | + call_user_func($handler, $log, $caller_function); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -69,19 +69,19 @@ discard block |
||
| 69 | 69 | * @param string|array $log The log data. |
| 70 | 70 | * @param string $caller The calling function. |
| 71 | 71 | */ |
| 72 | -function wl_write_log_handler( $log, $caller = NULL ) { |
|
| 72 | +function wl_write_log_handler($log, $caller = NULL) { |
|
| 73 | 73 | |
| 74 | 74 | global $wl_logger; |
| 75 | 75 | |
| 76 | - if ( TRUE === WP_DEBUG ) { |
|
| 76 | + if (TRUE === WP_DEBUG) { |
|
| 77 | 77 | |
| 78 | - $message = ( isset( $caller ) ? sprintf( '[%-40.40s] ', $caller ) : '' ) . |
|
| 79 | - ( is_array( $log ) || is_object( $log ) ? print_r( $log, TRUE ) : wl_write_log_hide_key( $log ) ); |
|
| 78 | + $message = (isset($caller) ? sprintf('[%-40.40s] ', $caller) : ''). |
|
| 79 | + (is_array($log) || is_object($log) ? print_r($log, TRUE) : wl_write_log_hide_key($log)); |
|
| 80 | 80 | |
| 81 | - if ( isset( $wl_logger ) ) { |
|
| 82 | - $wl_logger->info( $message ); |
|
| 81 | + if (isset($wl_logger)) { |
|
| 82 | + $wl_logger->info($message); |
|
| 83 | 83 | } else { |
| 84 | - error_log( $message ); |
|
| 84 | + error_log($message); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | } |
@@ -97,9 +97,9 @@ discard block |
||
| 97 | 97 | * |
| 98 | 98 | * @return string A text with the key hidden. |
| 99 | 99 | */ |
| 100 | -function wl_write_log_hide_key( $text ) { |
|
| 100 | +function wl_write_log_hide_key($text) { |
|
| 101 | 101 | |
| 102 | - return str_ireplace( wl_configuration_get_key(), '<hidden>', $text ); |
|
| 102 | + return str_ireplace(wl_configuration_get_key(), '<hidden>', $text); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -109,12 +109,12 @@ discard block |
||
| 109 | 109 | * |
| 110 | 110 | * @param string $query A SPARQL query. |
| 111 | 111 | */ |
| 112 | -function wl_queue_sparql_update_query( $query ) { |
|
| 112 | +function wl_queue_sparql_update_query($query) { |
|
| 113 | 113 | |
| 114 | - $filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql'; |
|
| 115 | - file_put_contents( $filename, $query . "\n", FILE_APPEND ); |
|
| 114 | + $filename = WL_TEMP_DIR.WL_REQUEST_ID.'.sparql'; |
|
| 115 | + file_put_contents($filename, $query."\n", FILE_APPEND); |
|
| 116 | 116 | |
| 117 | - wl_write_log( "wl_queue_sparql_update_query [ filename :: $filename ]" ); |
|
| 117 | + wl_write_log("wl_queue_sparql_update_query [ filename :: $filename ]"); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
@@ -122,33 +122,33 @@ discard block |
||
| 122 | 122 | * |
| 123 | 123 | * @param int $request_id The request ID. |
| 124 | 124 | */ |
| 125 | -function wl_execute_saved_sparql_update_query( $request_id ) { |
|
| 125 | +function wl_execute_saved_sparql_update_query($request_id) { |
|
| 126 | 126 | |
| 127 | - $filename = WL_TEMP_DIR . $request_id . '.sparql'; |
|
| 127 | + $filename = WL_TEMP_DIR.$request_id.'.sparql'; |
|
| 128 | 128 | |
| 129 | 129 | // If the file doesn't exist, exit. |
| 130 | - if ( ! file_exists( $filename ) ) { |
|
| 131 | - wl_write_log( "wl_execute_saved_sparql_update_query : file doesn't exist [ filename :: $filename ]" ); |
|
| 130 | + if ( ! file_exists($filename)) { |
|
| 131 | + wl_write_log("wl_execute_saved_sparql_update_query : file doesn't exist [ filename :: $filename ]"); |
|
| 132 | 132 | |
| 133 | 133 | return; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - wl_write_log( "wl_execute_saved_sparql_update_query [ filename :: $filename ]" ); |
|
| 136 | + wl_write_log("wl_execute_saved_sparql_update_query [ filename :: $filename ]"); |
|
| 137 | 137 | |
| 138 | 138 | // Get the query saved in the file. |
| 139 | - $query = file_get_contents( $filename ); |
|
| 139 | + $query = file_get_contents($filename); |
|
| 140 | 140 | |
| 141 | 141 | // Execute the SPARQL query. |
| 142 | - rl_execute_sparql_update_query( $query, FALSE ); |
|
| 142 | + rl_execute_sparql_update_query($query, FALSE); |
|
| 143 | 143 | |
| 144 | 144 | // Reindex the triple store. |
| 145 | 145 | wordlift_reindex_triple_store(); |
| 146 | 146 | |
| 147 | 147 | // Delete the temporary file. |
| 148 | - unlink( $filename ); |
|
| 148 | + unlink($filename); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | -add_action( 'wl_execute_saved_sparql_update_query', 'wl_execute_saved_sparql_update_query', 10, 1 ); |
|
| 151 | +add_action('wl_execute_saved_sparql_update_query', 'wl_execute_saved_sparql_update_query', 10, 1); |
|
| 152 | 152 | |
| 153 | 153 | /** |
| 154 | 154 | * Add buttons hook for the TinyMCE editor. This method is called by the WP init hook. |
@@ -156,8 +156,8 @@ discard block |
||
| 156 | 156 | function wordlift_buttonhooks() { |
| 157 | 157 | |
| 158 | 158 | // Only add hooks when the current user has permissions AND is in Rich Text editor mode |
| 159 | - if ( ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) && get_user_option( 'rich_editing' ) ) { |
|
| 160 | - add_filter( 'mce_external_plugins', 'wordlift_register_tinymce_javascript' ); |
|
| 159 | + if ((current_user_can('edit_posts') || current_user_can('edit_pages')) && get_user_option('rich_editing')) { |
|
| 160 | + add_filter('mce_external_plugins', 'wordlift_register_tinymce_javascript'); |
|
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | |
@@ -168,11 +168,11 @@ discard block |
||
| 168 | 168 | * |
| 169 | 169 | * @return array The modified plugins array. |
| 170 | 170 | */ |
| 171 | -function wordlift_register_tinymce_javascript( $plugin_array ) { |
|
| 171 | +function wordlift_register_tinymce_javascript($plugin_array) { |
|
| 172 | 172 | |
| 173 | 173 | // add the wordlift plugin. |
| 174 | 174 | // We can't use the minified version here. |
| 175 | - $plugin_array['wordlift'] = plugin_dir_url( __FILE__ ) . 'js/wordlift-reloaded.js'; |
|
| 175 | + $plugin_array['wordlift'] = plugin_dir_url(__FILE__).'js/wordlift-reloaded.js'; |
|
| 176 | 176 | |
| 177 | 177 | return $plugin_array; |
| 178 | 178 | } |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | function wordlift_allowed_post_tags() { |
| 185 | 185 | global $allowedposttags; |
| 186 | 186 | |
| 187 | - $tags = array( 'span' ); |
|
| 187 | + $tags = array('span'); |
|
| 188 | 188 | $new_attributes = array( |
| 189 | 189 | 'itemscope' => array(), |
| 190 | 190 | 'itemtype' => array(), |
@@ -192,17 +192,17 @@ discard block |
||
| 192 | 192 | 'itemid' => array(), |
| 193 | 193 | ); |
| 194 | 194 | |
| 195 | - foreach ( $tags as $tag ) { |
|
| 196 | - if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) { |
|
| 197 | - $allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes ); |
|
| 195 | + foreach ($tags as $tag) { |
|
| 196 | + if (isset($allowedposttags[$tag]) && is_array($allowedposttags[$tag])) { |
|
| 197 | + $allowedposttags[$tag] = array_merge($allowedposttags[$tag], $new_attributes); |
|
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | // init process for button control |
| 203 | -add_action( 'init', 'wordlift_buttonhooks' ); |
|
| 203 | +add_action('init', 'wordlift_buttonhooks'); |
|
| 204 | 204 | // add allowed post tags. |
| 205 | -add_action( 'init', 'wordlift_allowed_post_tags' ); |
|
| 205 | +add_action('init', 'wordlift_allowed_post_tags'); |
|
| 206 | 206 | |
| 207 | 207 | |
| 208 | 208 | /** |
@@ -211,30 +211,30 @@ discard block |
||
| 211 | 211 | function wordlift_admin_enqueue_scripts() { |
| 212 | 212 | |
| 213 | 213 | // Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/) |
| 214 | - wp_enqueue_script( 'wpdialogs' ); |
|
| 215 | - wp_enqueue_style( 'wp-jquery-ui-dialog' ); |
|
| 214 | + wp_enqueue_script('wpdialogs'); |
|
| 215 | + wp_enqueue_style('wp-jquery-ui-dialog'); |
|
| 216 | 216 | |
| 217 | - wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css' ); |
|
| 217 | + wp_enqueue_style('wordlift-reloaded', plugin_dir_url(__FILE__).'css/wordlift-reloaded.min.css'); |
|
| 218 | 218 | |
| 219 | - wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
| 220 | - wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' ); |
|
| 221 | - wp_enqueue_script( 'angularjs-geolocation', plugin_dir_url( __FILE__ ) . '/bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js' ); |
|
| 222 | - wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js' ); |
|
| 223 | - wp_enqueue_script( 'angularjs-animate', 'https://code.angularjs.org/1.3.11/angular-animate.min.js' ); |
|
| 219 | + wp_enqueue_script('jquery-ui-autocomplete'); |
|
| 220 | + wp_enqueue_script('angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js'); |
|
| 221 | + wp_enqueue_script('angularjs-geolocation', plugin_dir_url(__FILE__).'/bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js'); |
|
| 222 | + wp_enqueue_script('angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js'); |
|
| 223 | + wp_enqueue_script('angularjs-animate', 'https://code.angularjs.org/1.3.11/angular-animate.min.js'); |
|
| 224 | 224 | |
| 225 | 225 | // Disable auto-save for custom entity posts only |
| 226 | - if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) { |
|
| 227 | - wp_dequeue_script( 'autosave' ); |
|
| 226 | + if (Wordlift_Entity_Service::TYPE_NAME === get_post_type()) { |
|
| 227 | + wp_dequeue_script('autosave'); |
|
| 228 | 228 | } |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | -add_action( 'admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts' ); |
|
| 231 | +add_action('admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts'); |
|
| 232 | 232 | |
| 233 | 233 | function wl_enqueue_scripts() { |
| 234 | - wp_enqueue_style( 'wordlift-ui', plugin_dir_url( __FILE__ ) . 'css/wordlift-ui.min.css' ); |
|
| 234 | + wp_enqueue_style('wordlift-ui', plugin_dir_url(__FILE__).'css/wordlift-ui.min.css'); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | -add_action( 'wp_enqueue_scripts', 'wl_enqueue_scripts' ); |
|
| 237 | +add_action('wp_enqueue_scripts', 'wl_enqueue_scripts'); |
|
| 238 | 238 | |
| 239 | 239 | /** |
| 240 | 240 | * Hooked to *wp_kses_allowed_html* filter, adds microdata attributes. |
@@ -244,23 +244,23 @@ discard block |
||
| 244 | 244 | * |
| 245 | 245 | * @return array An array which contains allowed microdata attributes. |
| 246 | 246 | */ |
| 247 | -function wordlift_allowed_html( $allowedtags, $context ) { |
|
| 247 | +function wordlift_allowed_html($allowedtags, $context) { |
|
| 248 | 248 | |
| 249 | - if ( 'post' !== $context ) { |
|
| 249 | + if ('post' !== $context) { |
|
| 250 | 250 | return $allowedtags; |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - return array_merge_recursive( $allowedtags, array( |
|
| 253 | + return array_merge_recursive($allowedtags, array( |
|
| 254 | 254 | 'span' => array( |
| 255 | 255 | 'itemscope' => TRUE, |
| 256 | 256 | 'itemtype' => TRUE, |
| 257 | 257 | 'itemid' => TRUE, |
| 258 | 258 | 'itemprop' => TRUE, |
| 259 | 259 | ), |
| 260 | - ) ); |
|
| 260 | + )); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | -add_filter( 'wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2 ); |
|
| 263 | +add_filter('wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2); |
|
| 264 | 264 | |
| 265 | 265 | /** |
| 266 | 266 | * Get the coordinates for the specified post ID. |
@@ -269,16 +269,16 @@ discard block |
||
| 269 | 269 | * |
| 270 | 270 | * @return array|null An array of coordinates or null. |
| 271 | 271 | */ |
| 272 | -function wl_get_coordinates( $post_id ) { |
|
| 272 | +function wl_get_coordinates($post_id) { |
|
| 273 | 273 | |
| 274 | - $latitude = wl_schema_get_value( $post_id, 'latitude' ); |
|
| 275 | - $longitude = wl_schema_get_value( $post_id, 'longitude' ); |
|
| 274 | + $latitude = wl_schema_get_value($post_id, 'latitude'); |
|
| 275 | + $longitude = wl_schema_get_value($post_id, 'longitude'); |
|
| 276 | 276 | |
| 277 | 277 | // DO NOT set latitude/longitude to 0/0 as default values. It's a specific place on the globe: |
| 278 | 278 | // "The zero/zero point of this system is located in the Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana." |
| 279 | 279 | return array( |
| 280 | - 'latitude' => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '', |
|
| 281 | - 'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '', |
|
| 280 | + 'latitude' => isset($latitude[0]) && is_numeric($latitude[0]) ? $latitude[0] : '', |
|
| 281 | + 'longitude' => isset($longitude[0]) && is_numeric($longitude[0]) ? $longitude[0] : '', |
|
| 282 | 282 | ); |
| 283 | 283 | } |
| 284 | 284 | |
@@ -289,12 +289,12 @@ discard block |
||
| 289 | 289 | * |
| 290 | 290 | * @return string A datetime. |
| 291 | 291 | */ |
| 292 | -function wl_get_post_modified_time( $post ) { |
|
| 292 | +function wl_get_post_modified_time($post) { |
|
| 293 | 293 | |
| 294 | - $date_modified = get_post_modified_time( 'c', TRUE, $post ); |
|
| 294 | + $date_modified = get_post_modified_time('c', TRUE, $post); |
|
| 295 | 295 | |
| 296 | - if ( '-' === substr( $date_modified, 0, 1 ) ) { |
|
| 297 | - return get_the_time( 'c', $post ); |
|
| 296 | + if ('-' === substr($date_modified, 0, 1)) { |
|
| 297 | + return get_the_time('c', $post); |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | return $date_modified; |
@@ -307,27 +307,27 @@ discard block |
||
| 307 | 307 | * |
| 308 | 308 | * @return array An array of image URLs. |
| 309 | 309 | */ |
| 310 | -function wl_get_image_urls( $post_id ) { |
|
| 310 | +function wl_get_image_urls($post_id) { |
|
| 311 | 311 | |
| 312 | 312 | |
| 313 | 313 | // If there is a featured image it has the priority |
| 314 | - $featured_image_id = get_post_thumbnail_id( $post_id ); |
|
| 315 | - if ( is_numeric( $featured_image_id ) ) { |
|
| 316 | - $image_url = wp_get_attachment_url( $featured_image_id ); |
|
| 314 | + $featured_image_id = get_post_thumbnail_id($post_id); |
|
| 315 | + if (is_numeric($featured_image_id)) { |
|
| 316 | + $image_url = wp_get_attachment_url($featured_image_id); |
|
| 317 | 317 | |
| 318 | - return array( $image_url ); |
|
| 318 | + return array($image_url); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | // wl_write_log( "wl_get_image_urls [ post id :: $post_id ]" ); |
| 322 | 322 | |
| 323 | - $images = get_children( array( |
|
| 323 | + $images = get_children(array( |
|
| 324 | 324 | 'post_parent' => $post_id, |
| 325 | 325 | 'post_type' => 'attachment', |
| 326 | 326 | 'post_mime_type' => 'image', |
| 327 | - ) ); |
|
| 327 | + )); |
|
| 328 | 328 | |
| 329 | 329 | // Return an empty array if no image is found. |
| 330 | - if ( empty( $images ) ) { |
|
| 330 | + if (empty($images)) { |
|
| 331 | 331 | return array(); |
| 332 | 332 | } |
| 333 | 333 | |
@@ -335,11 +335,11 @@ discard block |
||
| 335 | 335 | $image_urls = array(); |
| 336 | 336 | |
| 337 | 337 | // Collect the URLs. |
| 338 | - foreach ( $images as $attachment_id => $attachment ) { |
|
| 339 | - $image_url = wp_get_attachment_url( $attachment_id ); |
|
| 338 | + foreach ($images as $attachment_id => $attachment) { |
|
| 339 | + $image_url = wp_get_attachment_url($attachment_id); |
|
| 340 | 340 | // Ensure the URL isn't collected already. |
| 341 | - if ( ! in_array( $image_url, $image_urls ) ) { |
|
| 342 | - array_push( $image_urls, $image_url ); |
|
| 341 | + if ( ! in_array($image_url, $image_urls)) { |
|
| 342 | + array_push($image_urls, $image_url); |
|
| 343 | 343 | } |
| 344 | 344 | } |
| 345 | 345 | |
@@ -356,17 +356,17 @@ discard block |
||
| 356 | 356 | * |
| 357 | 357 | * @return string The SPARQL fragment. |
| 358 | 358 | */ |
| 359 | -function wl_get_sparql_images( $uri, $post_id ) { |
|
| 359 | +function wl_get_sparql_images($uri, $post_id) { |
|
| 360 | 360 | |
| 361 | 361 | $sparql = ''; |
| 362 | 362 | |
| 363 | 363 | // Get the escaped URI. |
| 364 | - $uri_e = esc_html( $uri ); |
|
| 364 | + $uri_e = esc_html($uri); |
|
| 365 | 365 | |
| 366 | 366 | // Add SPARQL stmts to write the schema:image. |
| 367 | - $image_urls = wl_get_image_urls( $post_id ); |
|
| 368 | - foreach ( $image_urls as $image_url ) { |
|
| 369 | - $image_url_esc = wl_sparql_escape_uri( $image_url ); |
|
| 367 | + $image_urls = wl_get_image_urls($post_id); |
|
| 368 | + foreach ($image_urls as $image_url) { |
|
| 369 | + $image_url_esc = wl_sparql_escape_uri($image_url); |
|
| 370 | 370 | $sparql .= " <$uri_e> schema:image <$image_url_esc> . \n"; |
| 371 | 371 | } |
| 372 | 372 | |
@@ -381,21 +381,21 @@ discard block |
||
| 381 | 381 | * |
| 382 | 382 | * @return WP_Post|null A post instance or null if not found. |
| 383 | 383 | */ |
| 384 | -function wl_get_attachment_for_source_url( $parent_post_id, $source_url ) { |
|
| 384 | +function wl_get_attachment_for_source_url($parent_post_id, $source_url) { |
|
| 385 | 385 | |
| 386 | 386 | // wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" ); |
| 387 | 387 | |
| 388 | - $posts = get_posts( array( |
|
| 388 | + $posts = get_posts(array( |
|
| 389 | 389 | 'post_type' => 'attachment', |
| 390 | 390 | 'posts_per_page' => 1, |
| 391 | 391 | 'post_status' => 'any', |
| 392 | 392 | 'post_parent' => $parent_post_id, |
| 393 | 393 | 'meta_key' => 'wl_source_url', |
| 394 | 394 | 'meta_value' => $source_url, |
| 395 | - ) ); |
|
| 395 | + )); |
|
| 396 | 396 | |
| 397 | 397 | // Return the found post. |
| 398 | - if ( 1 === count( $posts ) ) { |
|
| 398 | + if (1 === count($posts)) { |
|
| 399 | 399 | return $posts[0]; |
| 400 | 400 | } |
| 401 | 401 | |
@@ -409,10 +409,10 @@ discard block |
||
| 409 | 409 | * @param int $post_id The post ID. |
| 410 | 410 | * @param string $source_url The source URL. |
| 411 | 411 | */ |
| 412 | -function wl_set_source_url( $post_id, $source_url ) { |
|
| 412 | +function wl_set_source_url($post_id, $source_url) { |
|
| 413 | 413 | |
| 414 | - delete_post_meta( $post_id, 'wl_source_url' ); |
|
| 415 | - add_post_meta( $post_id, 'wl_source_url', $source_url ); |
|
| 414 | + delete_post_meta($post_id, 'wl_source_url'); |
|
| 415 | + add_post_meta($post_id, 'wl_source_url', $source_url); |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | |
@@ -428,10 +428,10 @@ discard block |
||
| 428 | 428 | * |
| 429 | 429 | * @param bool $hard True if the rewrite involves configuration updates in Apache/IIS. |
| 430 | 430 | */ |
| 431 | -function wl_flush_rewrite_rules_hard( $hard ) { |
|
| 431 | +function wl_flush_rewrite_rules_hard($hard) { |
|
| 432 | 432 | |
| 433 | 433 | // If WL is not yet configured, we cannot perform any update, so we exit. |
| 434 | - if ( '' === wl_configuration_get_key() ) { |
|
| 434 | + if ('' === wl_configuration_get_key()) { |
|
| 435 | 435 | return; |
| 436 | 436 | } |
| 437 | 437 | |
@@ -440,13 +440,13 @@ discard block |
||
| 440 | 440 | $limit = 100; |
| 441 | 441 | |
| 442 | 442 | // Get more posts if the number of returned posts matches the limit. |
| 443 | - while ( $limit === ( $posts = get_posts( array( |
|
| 443 | + while ($limit === ($posts = get_posts(array( |
|
| 444 | 444 | 'offset' => $offset, |
| 445 | 445 | 'numberposts' => $limit, |
| 446 | 446 | 'orderby' => 'ID', |
| 447 | 447 | 'post_type' => 'any', |
| 448 | 448 | 'post_status' => 'publish', |
| 449 | - ) ) ) ) { |
|
| 449 | + )))) { |
|
| 450 | 450 | |
| 451 | 451 | // Holds the delete part of the query. |
| 452 | 452 | $delete_query = rl_sparql_prefixes(); |
@@ -455,16 +455,16 @@ discard block |
||
| 455 | 455 | $insert_query = ''; |
| 456 | 456 | |
| 457 | 457 | // Cycle in each post to build the query. |
| 458 | - foreach ( $posts as $post ) { |
|
| 458 | + foreach ($posts as $post) { |
|
| 459 | 459 | |
| 460 | 460 | // Ignore revisions. |
| 461 | - if ( wp_is_post_revision( $post->ID ) ) { |
|
| 461 | + if (wp_is_post_revision($post->ID)) { |
|
| 462 | 462 | continue; |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | // Get the entity URI. |
| 466 | - $s = Wordlift_Sparql_Service::escape_uri( Wordlift_Entity_Service::get_instance() |
|
| 467 | - ->get_uri( $post->ID ) ); |
|
| 466 | + $s = Wordlift_Sparql_Service::escape_uri(Wordlift_Entity_Service::get_instance() |
|
| 467 | + ->get_uri($post->ID)); |
|
| 468 | 468 | |
| 469 | 469 | // Get the post URL. |
| 470 | 470 | // $url = wl_sparql_escape_uri( get_permalink( $post->ID ) ); |
@@ -473,13 +473,13 @@ discard block |
||
| 473 | 473 | $delete_query .= "DELETE { <$s> schema:url ?u . } WHERE { <$s> schema:url ?u . };\n"; |
| 474 | 474 | |
| 475 | 475 | $insert_query .= Wordlift_Schema_Url_Property_Service::get_instance() |
| 476 | - ->get_insert_query( $s, $post->ID ); |
|
| 476 | + ->get_insert_query($s, $post->ID); |
|
| 477 | 477 | |
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | |
| 481 | 481 | // Execute the query. |
| 482 | - rl_execute_sparql_update_query( $delete_query . $insert_query ); |
|
| 482 | + rl_execute_sparql_update_query($delete_query.$insert_query); |
|
| 483 | 483 | |
| 484 | 484 | // Advance to the next posts. |
| 485 | 485 | $offset += $limit; |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | |
| 496 | 496 | } |
| 497 | 497 | |
| 498 | -add_filter( 'flush_rewrite_rules_hard', 'wl_flush_rewrite_rules_hard', 10, 1 ); |
|
| 498 | +add_filter('flush_rewrite_rules_hard', 'wl_flush_rewrite_rules_hard', 10, 1); |
|
| 499 | 499 | |
| 500 | 500 | /** |
| 501 | 501 | * Sanitizes an URI path by replacing the non allowed characters with an underscore. |
@@ -508,9 +508,9 @@ discard block |
||
| 508 | 508 | * |
| 509 | 509 | * @return string The sanitized path. |
| 510 | 510 | */ |
| 511 | -function wl_sanitize_uri_path( $path, $char = '_' ) { |
|
| 511 | +function wl_sanitize_uri_path($path, $char = '_') { |
|
| 512 | 512 | |
| 513 | - return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char ); |
|
| 513 | + return Wordlift_Uri_Service::get_instance()->sanitize_path($path, $char); |
|
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | /** |
@@ -520,10 +520,10 @@ discard block |
||
| 520 | 520 | * |
| 521 | 521 | * @return array Array containing $value (if $value was not an array) |
| 522 | 522 | */ |
| 523 | -function wl_force_to_array( $value ) { |
|
| 523 | +function wl_force_to_array($value) { |
|
| 524 | 524 | |
| 525 | - if ( ! is_array( $value ) ) { |
|
| 526 | - return array( $value ); |
|
| 525 | + if ( ! is_array($value)) { |
|
| 526 | + return array($value); |
|
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | return $value; |
@@ -535,28 +535,28 @@ discard block |
||
| 535 | 535 | function wl_shutdown() { |
| 536 | 536 | |
| 537 | 537 | // Get the filename to the temporary SPARQL file. |
| 538 | - $filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql'; |
|
| 538 | + $filename = WL_TEMP_DIR.WL_REQUEST_ID.'.sparql'; |
|
| 539 | 539 | |
| 540 | 540 | // If WordLift is buffering SPARQL queries, we're admins and a buffer exists, then schedule it. |
| 541 | - if ( WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING && is_admin() && file_exists( $filename ) ) { |
|
| 541 | + if (WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING && is_admin() && file_exists($filename)) { |
|
| 542 | 542 | |
| 543 | 543 | // The request ID. |
| 544 | - $args = array( WL_REQUEST_ID ); |
|
| 544 | + $args = array(WL_REQUEST_ID); |
|
| 545 | 545 | |
| 546 | 546 | // Schedule the execution of the SPARQL query with the request ID. |
| 547 | - wp_schedule_single_event( time(), 'wl_execute_saved_sparql_update_query', $args ); |
|
| 547 | + wp_schedule_single_event(time(), 'wl_execute_saved_sparql_update_query', $args); |
|
| 548 | 548 | |
| 549 | 549 | // Check that the request is scheduled. |
| 550 | - $timestamp = wp_next_scheduled( 'wl_execute_saved_sparql_update_query', $args ); |
|
| 550 | + $timestamp = wp_next_scheduled('wl_execute_saved_sparql_update_query', $args); |
|
| 551 | 551 | |
| 552 | 552 | // Spawn the cron. |
| 553 | 553 | spawn_cron(); |
| 554 | 554 | |
| 555 | - wl_write_log( "wl_shutdown [ request id :: " . WL_REQUEST_ID . " ][ timestamp :: $timestamp ]" ); |
|
| 555 | + wl_write_log("wl_shutdown [ request id :: ".WL_REQUEST_ID." ][ timestamp :: $timestamp ]"); |
|
| 556 | 556 | } |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | -add_action( 'shutdown', 'wl_shutdown' ); |
|
| 559 | +add_action('shutdown', 'wl_shutdown'); |
|
| 560 | 560 | |
| 561 | 561 | /** |
| 562 | 562 | * Replaces the *itemid* attributes URIs with the WordLift URIs. |
@@ -565,113 +565,113 @@ discard block |
||
| 565 | 565 | * |
| 566 | 566 | * @return string The updated post content. |
| 567 | 567 | */ |
| 568 | -function wl_replace_item_id_with_uri( $content ) { |
|
| 568 | +function wl_replace_item_id_with_uri($content) { |
|
| 569 | 569 | |
| 570 | 570 | // wl_write_log( "wl_replace_item_id_with_uri" ); |
| 571 | 571 | |
| 572 | 572 | // Strip slashes, see https://core.trac.wordpress.org/ticket/21767 |
| 573 | - $content = stripslashes( $content ); |
|
| 573 | + $content = stripslashes($content); |
|
| 574 | 574 | |
| 575 | 575 | // If any match are found. |
| 576 | 576 | $matches = array(); |
| 577 | - if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) { |
|
| 577 | + if (0 < preg_match_all('/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER)) { |
|
| 578 | 578 | |
| 579 | - foreach ( $matches as $match ) { |
|
| 579 | + foreach ($matches as $match) { |
|
| 580 | 580 | |
| 581 | 581 | // Get the item ID. |
| 582 | 582 | $item_id = $match[1]; |
| 583 | 583 | |
| 584 | 584 | // Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' . |
| 585 | 585 | $post = Wordlift_Entity_Service::get_instance() |
| 586 | - ->get_entity_post_by_uri( $item_id ); |
|
| 586 | + ->get_entity_post_by_uri($item_id); |
|
| 587 | 587 | |
| 588 | 588 | // If no entity is found, continue to the next one. |
| 589 | - if ( NULL === $post ) { |
|
| 589 | + if (NULL === $post) { |
|
| 590 | 590 | continue; |
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | // Get the URI for that post. |
| 594 | - $uri = wl_get_entity_uri( $post->ID ); |
|
| 594 | + $uri = wl_get_entity_uri($post->ID); |
|
| 595 | 595 | |
| 596 | 596 | // wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" ); |
| 597 | 597 | |
| 598 | 598 | // If the item ID and the URI differ, replace the item ID with the URI saved in WordPress. |
| 599 | - if ( $item_id !== $uri ) { |
|
| 600 | - $uri_e = esc_html( $uri ); |
|
| 601 | - $content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content ); |
|
| 599 | + if ($item_id !== $uri) { |
|
| 600 | + $uri_e = esc_html($uri); |
|
| 601 | + $content = str_replace(" itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content); |
|
| 602 | 602 | } |
| 603 | 603 | } |
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | // Reapply slashes. |
| 607 | - $content = addslashes( $content ); |
|
| 607 | + $content = addslashes($content); |
|
| 608 | 608 | |
| 609 | 609 | return $content; |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | -add_filter( 'content_save_pre', 'wl_replace_item_id_with_uri', 1, 1 ); |
|
| 612 | +add_filter('content_save_pre', 'wl_replace_item_id_with_uri', 1, 1); |
|
| 613 | 613 | |
| 614 | -require_once( 'wordlift_entity_functions.php' ); |
|
| 614 | +require_once('wordlift_entity_functions.php'); |
|
| 615 | 615 | |
| 616 | 616 | // add editor related methods. |
| 617 | -require_once( 'wordlift_editor.php' ); |
|
| 617 | +require_once('wordlift_editor.php'); |
|
| 618 | 618 | |
| 619 | 619 | // add the WordLift entity custom type. |
| 620 | -require_once( 'wordlift_entity_type.php' ); |
|
| 621 | -require_once( 'wordlift_entity_type_taxonomy.php' ); |
|
| 620 | +require_once('wordlift_entity_type.php'); |
|
| 621 | +require_once('wordlift_entity_type_taxonomy.php'); |
|
| 622 | 622 | |
| 623 | 623 | // add callbacks on post save to notify data changes from wp to redlink triple store |
| 624 | -require_once( 'wordlift_to_redlink_data_push_callbacks.php' ); |
|
| 624 | +require_once('wordlift_to_redlink_data_push_callbacks.php'); |
|
| 625 | 625 | |
| 626 | 626 | // Load modules |
| 627 | -require_once( 'modules/analyzer/wordlift_analyzer.php' ); |
|
| 628 | -require_once( 'modules/linked_data/wordlift_linked_data.php' ); |
|
| 629 | -require_once( 'modules/prefixes/wordlift_prefixes.php' ); |
|
| 630 | -require_once( 'modules/caching/wordlift_caching.php' ); |
|
| 631 | -require_once( 'modules/redirector/wordlift_redirector.php' ); |
|
| 632 | -require_once( 'modules/freebase_image_proxy/wordlift_freebase_image_proxy.php' ); |
|
| 627 | +require_once('modules/analyzer/wordlift_analyzer.php'); |
|
| 628 | +require_once('modules/linked_data/wordlift_linked_data.php'); |
|
| 629 | +require_once('modules/prefixes/wordlift_prefixes.php'); |
|
| 630 | +require_once('modules/caching/wordlift_caching.php'); |
|
| 631 | +require_once('modules/redirector/wordlift_redirector.php'); |
|
| 632 | +require_once('modules/freebase_image_proxy/wordlift_freebase_image_proxy.php'); |
|
| 633 | 633 | |
| 634 | 634 | // Shortcodes |
| 635 | 635 | |
| 636 | -require_once( 'modules/geo_widget/wordlift_geo_widget.php' ); |
|
| 637 | -require_once( 'shortcodes/wordlift_shortcode_chord.php' ); |
|
| 638 | -require_once( 'shortcodes/wordlift_shortcode_geomap.php' ); |
|
| 639 | -require_once( 'shortcodes/wordlift_shortcode_field.php' ); |
|
| 640 | -require_once( 'shortcodes/wordlift_shortcode_faceted_search.php' ); |
|
| 641 | -require_once( 'shortcodes/wordlift_shortcode_navigator.php' ); |
|
| 636 | +require_once('modules/geo_widget/wordlift_geo_widget.php'); |
|
| 637 | +require_once('shortcodes/wordlift_shortcode_chord.php'); |
|
| 638 | +require_once('shortcodes/wordlift_shortcode_geomap.php'); |
|
| 639 | +require_once('shortcodes/wordlift_shortcode_field.php'); |
|
| 640 | +require_once('shortcodes/wordlift_shortcode_faceted_search.php'); |
|
| 641 | +require_once('shortcodes/wordlift_shortcode_navigator.php'); |
|
| 642 | 642 | |
| 643 | -require_once( 'widgets/wordlift_widget_geo.php' ); |
|
| 644 | -require_once( 'widgets/wordlift_widget_chord.php' ); |
|
| 645 | -require_once( 'widgets/wordlift_widget_timeline.php' ); |
|
| 643 | +require_once('widgets/wordlift_widget_geo.php'); |
|
| 644 | +require_once('widgets/wordlift_widget_chord.php'); |
|
| 645 | +require_once('widgets/wordlift_widget_timeline.php'); |
|
| 646 | 646 | |
| 647 | -require_once( 'wordlift_sparql.php' ); |
|
| 648 | -require_once( 'wordlift_redlink.php' ); |
|
| 647 | +require_once('wordlift_sparql.php'); |
|
| 648 | +require_once('wordlift_redlink.php'); |
|
| 649 | 649 | |
| 650 | 650 | // Add admin functions. |
| 651 | 651 | // TODO: find a way to make 'admin' UI tests work. |
| 652 | 652 | //if ( is_admin() ) { |
| 653 | 653 | |
| 654 | -require_once( 'admin/wordlift_admin.php' ); |
|
| 655 | -require_once( 'admin/wordlift_admin_edit_post.php' ); |
|
| 656 | -require_once( 'admin/wordlift_admin_save_post.php' ); |
|
| 654 | +require_once('admin/wordlift_admin.php'); |
|
| 655 | +require_once('admin/wordlift_admin_edit_post.php'); |
|
| 656 | +require_once('admin/wordlift_admin_save_post.php'); |
|
| 657 | 657 | |
| 658 | 658 | // add the entities meta box. |
| 659 | -require_once( 'admin/wordlift_admin_meta_box_entities.php' ); |
|
| 659 | +require_once('admin/wordlift_admin_meta_box_entities.php'); |
|
| 660 | 660 | |
| 661 | 661 | // add the entity creation AJAX. |
| 662 | -require_once( 'admin/wordlift_admin_ajax_related_posts.php' ); |
|
| 662 | +require_once('admin/wordlift_admin_ajax_related_posts.php'); |
|
| 663 | 663 | |
| 664 | 664 | // Load the wl_chord TinyMCE button and configuration dialog. |
| 665 | -require_once( 'admin/wordlift_admin_shortcodes.php' ); |
|
| 665 | +require_once('admin/wordlift_admin_shortcodes.php'); |
|
| 666 | 666 | |
| 667 | 667 | // Provide syncing features. |
| 668 | -require_once( 'admin/wordlift_admin_sync.php' ); |
|
| 668 | +require_once('admin/wordlift_admin_sync.php'); |
|
| 669 | 669 | //} |
| 670 | 670 | |
| 671 | 671 | // load languages. |
| 672 | 672 | // TODO: the following call gives for granted that the plugin is in the wordlift directory, |
| 673 | 673 | // we're currently doing this because wordlift is symbolic linked. |
| 674 | -load_plugin_textdomain( 'wordlift', FALSE, '/wordlift/languages' ); |
|
| 674 | +load_plugin_textdomain('wordlift', FALSE, '/wordlift/languages'); |
|
| 675 | 675 | |
| 676 | 676 | |
| 677 | 677 | /** |
@@ -679,7 +679,7 @@ discard block |
||
| 679 | 679 | * This action is documented in includes/class-wordlift-activator.php |
| 680 | 680 | */ |
| 681 | 681 | function activate_wordlift() { |
| 682 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php'; |
|
| 682 | + require_once plugin_dir_path(__FILE__).'includes/class-wordlift-activator.php'; |
|
| 683 | 683 | Wordlift_Activator::activate(); |
| 684 | 684 | } |
| 685 | 685 | |
@@ -688,18 +688,18 @@ discard block |
||
| 688 | 688 | * This action is documented in includes/class-wordlift-deactivator.php |
| 689 | 689 | */ |
| 690 | 690 | function deactivate_wordlift() { |
| 691 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php'; |
|
| 691 | + require_once plugin_dir_path(__FILE__).'includes/class-wordlift-deactivator.php'; |
|
| 692 | 692 | Wordlift_Deactivator::deactivate(); |
| 693 | 693 | } |
| 694 | 694 | |
| 695 | -register_activation_hook( __FILE__, 'activate_wordlift' ); |
|
| 696 | -register_deactivation_hook( __FILE__, 'deactivate_wordlift' ); |
|
| 695 | +register_activation_hook(__FILE__, 'activate_wordlift'); |
|
| 696 | +register_deactivation_hook(__FILE__, 'deactivate_wordlift'); |
|
| 697 | 697 | |
| 698 | 698 | /** |
| 699 | 699 | * The core plugin class that is used to define internationalization, |
| 700 | 700 | * admin-specific hooks, and public-facing site hooks. |
| 701 | 701 | */ |
| 702 | -require plugin_dir_path( __FILE__ ) . 'includes/class-wordlift.php'; |
|
| 702 | +require plugin_dir_path(__FILE__).'includes/class-wordlift.php'; |
|
| 703 | 703 | |
| 704 | 704 | /** |
| 705 | 705 | * Begins execution of the plugin. |
@@ -29,783 +29,783 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | class Wordlift { |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * The loader that's responsible for maintaining and registering all hooks that power |
|
| 34 | - * the plugin. |
|
| 35 | - * |
|
| 36 | - * @since 1.0.0 |
|
| 37 | - * @access protected |
|
| 38 | - * @var Wordlift_Loader $loader Maintains and registers all hooks for the plugin. |
|
| 39 | - */ |
|
| 40 | - protected $loader; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * The unique identifier of this plugin. |
|
| 44 | - * |
|
| 45 | - * @since 1.0.0 |
|
| 46 | - * @access protected |
|
| 47 | - * @var string $plugin_name The string used to uniquely identify this plugin. |
|
| 48 | - */ |
|
| 49 | - protected $plugin_name; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * The current version of the plugin. |
|
| 53 | - * |
|
| 54 | - * @since 1.0.0 |
|
| 55 | - * @access protected |
|
| 56 | - * @var string $version The current version of the plugin. |
|
| 57 | - */ |
|
| 58 | - protected $version; |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * The Thumbnail service. |
|
| 62 | - * |
|
| 63 | - * @since 3.1.5 |
|
| 64 | - * @access private |
|
| 65 | - * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service. |
|
| 66 | - */ |
|
| 67 | - private $thumbnail_service; |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * The UI service. |
|
| 71 | - * |
|
| 72 | - * @since 3.2.0 |
|
| 73 | - * @access private |
|
| 74 | - * @var \Wordlift_UI_Service $ui_service The UI service. |
|
| 75 | - */ |
|
| 76 | - private $ui_service; |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * The Schema service. |
|
| 80 | - * |
|
| 81 | - * @since 3.3.0 |
|
| 82 | - * @access private |
|
| 83 | - * @var \Wordlift_Schema_Service $schema_service The Schema service. |
|
| 84 | - */ |
|
| 85 | - private $schema_service; |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * The Entity service. |
|
| 89 | - * |
|
| 90 | - * @since 3.1.0 |
|
| 91 | - * @access private |
|
| 92 | - * @var \Wordlift_Entity_Service $entity_service The Entity service. |
|
| 93 | - */ |
|
| 94 | - private $entity_service; |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * The Topic Taxonomy service. |
|
| 98 | - * |
|
| 99 | - * @since 3.5.0 |
|
| 100 | - * @access private |
|
| 101 | - * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service. |
|
| 102 | - */ |
|
| 103 | - private $topic_taxonomy_service; |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * The User service. |
|
| 107 | - * |
|
| 108 | - * @since 3.1.7 |
|
| 109 | - * @access private |
|
| 110 | - * @var \Wordlift_User_Service $user_service The User service. |
|
| 111 | - */ |
|
| 112 | - private $user_service; |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * The Timeline service. |
|
| 116 | - * |
|
| 117 | - * @since 3.1.0 |
|
| 118 | - * @access private |
|
| 119 | - * @var \Wordlift_Timeline_Service $timeline_service The Timeline service. |
|
| 120 | - */ |
|
| 121 | - private $timeline_service; |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * The Redirect service. |
|
| 125 | - * |
|
| 126 | - * @since 3.2.0 |
|
| 127 | - * @access private |
|
| 128 | - * @var \Wordlift_Redirect_Service $redirect_service The Redirect service. |
|
| 129 | - */ |
|
| 130 | - private $redirect_service; |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * The Notice service. |
|
| 134 | - * |
|
| 135 | - * @since 3.3.0 |
|
| 136 | - * @access private |
|
| 137 | - * @var \Wordlift_Notice_Service $notice_service The Notice service. |
|
| 138 | - */ |
|
| 139 | - private $notice_service; |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * The Entity list customization. |
|
| 143 | - * |
|
| 144 | - * @since 3.3.0 |
|
| 145 | - * @access private |
|
| 146 | - * @var \Wordlift_List_Service $entity_list_service The Entity list service. |
|
| 147 | - */ |
|
| 148 | - private $entity_list_service; |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * The Entity Types Taxonomy Walker. |
|
| 152 | - * |
|
| 153 | - * @since 3.1.0 |
|
| 154 | - * @access private |
|
| 155 | - * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker |
|
| 156 | - */ |
|
| 157 | - private $entity_types_taxonomy_walker; |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * The ShareThis service. |
|
| 161 | - * |
|
| 162 | - * @since 3.2.0 |
|
| 163 | - * @access private |
|
| 164 | - * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service. |
|
| 165 | - */ |
|
| 166 | - private $sharethis_service; |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * The PrimaShop adapter. |
|
| 170 | - * |
|
| 171 | - * @since 3.2.3 |
|
| 172 | - * @access private |
|
| 173 | - * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter. |
|
| 174 | - */ |
|
| 175 | - private $primashop_adapter; |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * The WordLift Dashboard adapter. |
|
| 179 | - * |
|
| 180 | - * @since 3.4.0 |
|
| 181 | - * @access private |
|
| 182 | - * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service; |
|
| 183 | - */ |
|
| 184 | - private $dashboard_service; |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * The entity type service. |
|
| 188 | - * |
|
| 189 | - * @since 3.6.0 |
|
| 190 | - * @access private |
|
| 191 | - * @var \Wordlift_Entity_Post_Type_Service |
|
| 192 | - */ |
|
| 193 | - private $entity_post_type_service; |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * The entity link service used to mangle links to entities with a custom slug or even w/o a slug. |
|
| 197 | - * |
|
| 198 | - * @since 3.6.0 |
|
| 199 | - * @access private |
|
| 200 | - * @var \Wordlift_Entity_Link_Service |
|
| 201 | - */ |
|
| 202 | - private $entity_link_service; |
|
| 203 | - |
|
| 204 | - /** |
|
| 205 | - * The page service instance which processes the page output in order to insert schema.org microdata to export the |
|
| 206 | - * correct page title to Google+. |
|
| 207 | - * |
|
| 208 | - * @since 3.5.3 |
|
| 209 | - * @access private |
|
| 210 | - * @var \Wordlift_Page_Service |
|
| 211 | - */ |
|
| 212 | - private $page_service; |
|
| 213 | - |
|
| 214 | - /** |
|
| 215 | - * A {@link Wordlift_Sparql_Service} instance. |
|
| 216 | - * |
|
| 217 | - * @var 3.6.0 |
|
| 218 | - * @access private |
|
| 219 | - * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance. |
|
| 220 | - */ |
|
| 221 | - private $sparql_service; |
|
| 222 | - |
|
| 223 | - /** |
|
| 224 | - * A {@link Wordlift_Import_Service} instance. |
|
| 225 | - * |
|
| 226 | - * @since 3.6.0 |
|
| 227 | - * @access private |
|
| 228 | - * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance. |
|
| 229 | - */ |
|
| 230 | - private $import_service; |
|
| 231 | - |
|
| 232 | - /** |
|
| 233 | - * A {@link Wordlift_Rebuild_Service} instance. |
|
| 234 | - * |
|
| 235 | - * @since 3.6.0 |
|
| 236 | - * @access private |
|
| 237 | - * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance. |
|
| 238 | - */ |
|
| 239 | - private $rebuild_service; |
|
| 240 | - |
|
| 241 | - /** |
|
| 242 | - * A {@link Wordlift_Jsonld_Service} instance. |
|
| 243 | - * |
|
| 244 | - * @since 3.7.0 |
|
| 245 | - * @access private |
|
| 246 | - * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance. |
|
| 247 | - */ |
|
| 248 | - private $jsonld_service; |
|
| 249 | - |
|
| 250 | - /** |
|
| 251 | - * |
|
| 252 | - * @since 3.7.0 |
|
| 253 | - * @access private |
|
| 254 | - * @var \Wordlift_Property_Factory $property_factory |
|
| 255 | - */ |
|
| 256 | - private $property_factory; |
|
| 257 | - |
|
| 258 | - /** |
|
| 259 | - * The 'Download Your Data' page. |
|
| 260 | - * |
|
| 261 | - * @since 3.6.0 |
|
| 262 | - * @access private |
|
| 263 | - * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page. |
|
| 264 | - */ |
|
| 265 | - private $download_your_data_page; |
|
| 266 | - |
|
| 267 | - /** |
|
| 268 | - * The Content Filter Service hooks up to the 'the_content' filter and provides |
|
| 269 | - * linking of entities to their pages. |
|
| 270 | - * |
|
| 271 | - * @since 3.8.0 |
|
| 272 | - * @access private |
|
| 273 | - * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance. |
|
| 274 | - */ |
|
| 275 | - private $content_filter_service; |
|
| 276 | - |
|
| 277 | - /** |
|
| 278 | - * Define the core functionality of the plugin. |
|
| 279 | - * |
|
| 280 | - * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 281 | - * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 282 | - * the public-facing side of the site. |
|
| 283 | - * |
|
| 284 | - * @since 1.0.0 |
|
| 285 | - */ |
|
| 286 | - public function __construct() { |
|
| 287 | - |
|
| 288 | - $this->plugin_name = 'wordlift'; |
|
| 289 | - $this->version = '3.9.0-dev'; |
|
| 290 | - $this->load_dependencies(); |
|
| 291 | - $this->set_locale(); |
|
| 292 | - $this->define_admin_hooks(); |
|
| 293 | - $this->define_public_hooks(); |
|
| 294 | - |
|
| 295 | - } |
|
| 296 | - |
|
| 297 | - /** |
|
| 298 | - * Load the required dependencies for this plugin. |
|
| 299 | - * |
|
| 300 | - * Include the following files that make up the plugin: |
|
| 301 | - * |
|
| 302 | - * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 303 | - * - Wordlift_i18n. Defines internationalization functionality. |
|
| 304 | - * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 305 | - * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 306 | - * |
|
| 307 | - * Create an instance of the loader which will be used to register the hooks |
|
| 308 | - * with WordPress. |
|
| 309 | - * |
|
| 310 | - * @since 1.0.0 |
|
| 311 | - * @access private |
|
| 312 | - */ |
|
| 313 | - private function load_dependencies() { |
|
| 314 | - |
|
| 315 | - /** |
|
| 316 | - * The class responsible for orchestrating the actions and filters of the |
|
| 317 | - * core plugin. |
|
| 318 | - */ |
|
| 319 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 320 | - |
|
| 321 | - /** |
|
| 322 | - * The class responsible for defining internationalization functionality |
|
| 323 | - * of the plugin. |
|
| 324 | - */ |
|
| 325 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 326 | - |
|
| 327 | - /** |
|
| 328 | - * Provide support functions to sanitize data. |
|
| 329 | - */ |
|
| 330 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 331 | - |
|
| 332 | - /** |
|
| 333 | - * The Redirect service. |
|
| 334 | - */ |
|
| 335 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 336 | - |
|
| 337 | - /** |
|
| 338 | - * The Log service. |
|
| 339 | - */ |
|
| 340 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 341 | - |
|
| 342 | - /** |
|
| 343 | - * The configuration service. |
|
| 344 | - */ |
|
| 345 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 346 | - |
|
| 347 | - /** |
|
| 348 | - * The entity post type service (this is the WordPress post type, not the entity schema type). |
|
| 349 | - */ |
|
| 350 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 351 | - |
|
| 352 | - /** |
|
| 353 | - * The entity type service (i.e. the schema type). |
|
| 354 | - */ |
|
| 355 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 356 | - |
|
| 357 | - /** |
|
| 358 | - * The entity link service. |
|
| 359 | - */ |
|
| 360 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 361 | - |
|
| 362 | - /** |
|
| 363 | - * The Query builder. |
|
| 364 | - */ |
|
| 365 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 366 | - |
|
| 367 | - /** |
|
| 368 | - * The Schema service. |
|
| 369 | - */ |
|
| 370 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 371 | - |
|
| 372 | - /** |
|
| 373 | - * The schema:url property service. |
|
| 374 | - */ |
|
| 375 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 376 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 377 | - |
|
| 378 | - /** |
|
| 379 | - * The UI service. |
|
| 380 | - */ |
|
| 381 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 382 | - |
|
| 383 | - /** |
|
| 384 | - * The Thumbnail service. |
|
| 385 | - */ |
|
| 386 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 387 | - |
|
| 388 | - /** |
|
| 389 | - * The Entity Types Taxonomy service. |
|
| 390 | - */ |
|
| 391 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 392 | - |
|
| 393 | - /** |
|
| 394 | - * The Entity service. |
|
| 395 | - */ |
|
| 396 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 397 | - |
|
| 398 | - /** |
|
| 399 | - * The User service. |
|
| 400 | - */ |
|
| 401 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 402 | - |
|
| 403 | - /** |
|
| 404 | - * The Timeline service. |
|
| 405 | - */ |
|
| 406 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 407 | - |
|
| 408 | - /** |
|
| 409 | - * The Topic Taxonomy service. |
|
| 410 | - */ |
|
| 411 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 412 | - |
|
| 413 | - |
|
| 414 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-page-service.php'; |
|
| 415 | - |
|
| 416 | - /** |
|
| 417 | - * The SPARQL service. |
|
| 418 | - */ |
|
| 419 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 420 | - |
|
| 421 | - /** |
|
| 422 | - * The WordLift import service. |
|
| 423 | - */ |
|
| 424 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 425 | - |
|
| 426 | - /** |
|
| 427 | - * The WordLift URI service. |
|
| 428 | - */ |
|
| 429 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 430 | - |
|
| 431 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php'; |
|
| 432 | - |
|
| 433 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 434 | - |
|
| 435 | - /** |
|
| 436 | - * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
|
| 437 | - */ |
|
| 438 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php'; |
|
| 439 | - |
|
| 440 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 441 | - |
|
| 442 | - /** |
|
| 443 | - * Load the converters. |
|
| 444 | - */ |
|
| 445 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 446 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-to-jsonld-converter.php'; |
|
| 447 | - |
|
| 448 | - /** |
|
| 449 | - * Load the content filter. |
|
| 450 | - */ |
|
| 451 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 452 | - |
|
| 453 | - /** |
|
| 454 | - * Load the JSON-LD service to publish entities using JSON-LD.s |
|
| 455 | - * |
|
| 456 | - * @since 3.8.0 |
|
| 457 | - */ |
|
| 458 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 459 | - |
|
| 460 | - /** |
|
| 461 | - * The class responsible for defining all actions that occur in the admin area. |
|
| 462 | - */ |
|
| 463 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 464 | - |
|
| 465 | - /** |
|
| 466 | - * The class to customize the entity list admin page. |
|
| 467 | - */ |
|
| 468 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 469 | - |
|
| 470 | - /** |
|
| 471 | - * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 472 | - */ |
|
| 473 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 474 | - |
|
| 475 | - /** |
|
| 476 | - * The Notice service. |
|
| 477 | - */ |
|
| 478 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 479 | - |
|
| 480 | - /** |
|
| 481 | - * The PrimaShop adapter. |
|
| 482 | - */ |
|
| 483 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 484 | - |
|
| 485 | - /** |
|
| 486 | - * The WordLift Dashboard service. |
|
| 487 | - */ |
|
| 488 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 32 | + /** |
|
| 33 | + * The loader that's responsible for maintaining and registering all hooks that power |
|
| 34 | + * the plugin. |
|
| 35 | + * |
|
| 36 | + * @since 1.0.0 |
|
| 37 | + * @access protected |
|
| 38 | + * @var Wordlift_Loader $loader Maintains and registers all hooks for the plugin. |
|
| 39 | + */ |
|
| 40 | + protected $loader; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * The unique identifier of this plugin. |
|
| 44 | + * |
|
| 45 | + * @since 1.0.0 |
|
| 46 | + * @access protected |
|
| 47 | + * @var string $plugin_name The string used to uniquely identify this plugin. |
|
| 48 | + */ |
|
| 49 | + protected $plugin_name; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * The current version of the plugin. |
|
| 53 | + * |
|
| 54 | + * @since 1.0.0 |
|
| 55 | + * @access protected |
|
| 56 | + * @var string $version The current version of the plugin. |
|
| 57 | + */ |
|
| 58 | + protected $version; |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * The Thumbnail service. |
|
| 62 | + * |
|
| 63 | + * @since 3.1.5 |
|
| 64 | + * @access private |
|
| 65 | + * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service. |
|
| 66 | + */ |
|
| 67 | + private $thumbnail_service; |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * The UI service. |
|
| 71 | + * |
|
| 72 | + * @since 3.2.0 |
|
| 73 | + * @access private |
|
| 74 | + * @var \Wordlift_UI_Service $ui_service The UI service. |
|
| 75 | + */ |
|
| 76 | + private $ui_service; |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * The Schema service. |
|
| 80 | + * |
|
| 81 | + * @since 3.3.0 |
|
| 82 | + * @access private |
|
| 83 | + * @var \Wordlift_Schema_Service $schema_service The Schema service. |
|
| 84 | + */ |
|
| 85 | + private $schema_service; |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * The Entity service. |
|
| 89 | + * |
|
| 90 | + * @since 3.1.0 |
|
| 91 | + * @access private |
|
| 92 | + * @var \Wordlift_Entity_Service $entity_service The Entity service. |
|
| 93 | + */ |
|
| 94 | + private $entity_service; |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * The Topic Taxonomy service. |
|
| 98 | + * |
|
| 99 | + * @since 3.5.0 |
|
| 100 | + * @access private |
|
| 101 | + * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service. |
|
| 102 | + */ |
|
| 103 | + private $topic_taxonomy_service; |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * The User service. |
|
| 107 | + * |
|
| 108 | + * @since 3.1.7 |
|
| 109 | + * @access private |
|
| 110 | + * @var \Wordlift_User_Service $user_service The User service. |
|
| 111 | + */ |
|
| 112 | + private $user_service; |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * The Timeline service. |
|
| 116 | + * |
|
| 117 | + * @since 3.1.0 |
|
| 118 | + * @access private |
|
| 119 | + * @var \Wordlift_Timeline_Service $timeline_service The Timeline service. |
|
| 120 | + */ |
|
| 121 | + private $timeline_service; |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * The Redirect service. |
|
| 125 | + * |
|
| 126 | + * @since 3.2.0 |
|
| 127 | + * @access private |
|
| 128 | + * @var \Wordlift_Redirect_Service $redirect_service The Redirect service. |
|
| 129 | + */ |
|
| 130 | + private $redirect_service; |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * The Notice service. |
|
| 134 | + * |
|
| 135 | + * @since 3.3.0 |
|
| 136 | + * @access private |
|
| 137 | + * @var \Wordlift_Notice_Service $notice_service The Notice service. |
|
| 138 | + */ |
|
| 139 | + private $notice_service; |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * The Entity list customization. |
|
| 143 | + * |
|
| 144 | + * @since 3.3.0 |
|
| 145 | + * @access private |
|
| 146 | + * @var \Wordlift_List_Service $entity_list_service The Entity list service. |
|
| 147 | + */ |
|
| 148 | + private $entity_list_service; |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * The Entity Types Taxonomy Walker. |
|
| 152 | + * |
|
| 153 | + * @since 3.1.0 |
|
| 154 | + * @access private |
|
| 155 | + * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker |
|
| 156 | + */ |
|
| 157 | + private $entity_types_taxonomy_walker; |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * The ShareThis service. |
|
| 161 | + * |
|
| 162 | + * @since 3.2.0 |
|
| 163 | + * @access private |
|
| 164 | + * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service. |
|
| 165 | + */ |
|
| 166 | + private $sharethis_service; |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * The PrimaShop adapter. |
|
| 170 | + * |
|
| 171 | + * @since 3.2.3 |
|
| 172 | + * @access private |
|
| 173 | + * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter. |
|
| 174 | + */ |
|
| 175 | + private $primashop_adapter; |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * The WordLift Dashboard adapter. |
|
| 179 | + * |
|
| 180 | + * @since 3.4.0 |
|
| 181 | + * @access private |
|
| 182 | + * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service; |
|
| 183 | + */ |
|
| 184 | + private $dashboard_service; |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * The entity type service. |
|
| 188 | + * |
|
| 189 | + * @since 3.6.0 |
|
| 190 | + * @access private |
|
| 191 | + * @var \Wordlift_Entity_Post_Type_Service |
|
| 192 | + */ |
|
| 193 | + private $entity_post_type_service; |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * The entity link service used to mangle links to entities with a custom slug or even w/o a slug. |
|
| 197 | + * |
|
| 198 | + * @since 3.6.0 |
|
| 199 | + * @access private |
|
| 200 | + * @var \Wordlift_Entity_Link_Service |
|
| 201 | + */ |
|
| 202 | + private $entity_link_service; |
|
| 203 | + |
|
| 204 | + /** |
|
| 205 | + * The page service instance which processes the page output in order to insert schema.org microdata to export the |
|
| 206 | + * correct page title to Google+. |
|
| 207 | + * |
|
| 208 | + * @since 3.5.3 |
|
| 209 | + * @access private |
|
| 210 | + * @var \Wordlift_Page_Service |
|
| 211 | + */ |
|
| 212 | + private $page_service; |
|
| 213 | + |
|
| 214 | + /** |
|
| 215 | + * A {@link Wordlift_Sparql_Service} instance. |
|
| 216 | + * |
|
| 217 | + * @var 3.6.0 |
|
| 218 | + * @access private |
|
| 219 | + * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance. |
|
| 220 | + */ |
|
| 221 | + private $sparql_service; |
|
| 222 | + |
|
| 223 | + /** |
|
| 224 | + * A {@link Wordlift_Import_Service} instance. |
|
| 225 | + * |
|
| 226 | + * @since 3.6.0 |
|
| 227 | + * @access private |
|
| 228 | + * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance. |
|
| 229 | + */ |
|
| 230 | + private $import_service; |
|
| 231 | + |
|
| 232 | + /** |
|
| 233 | + * A {@link Wordlift_Rebuild_Service} instance. |
|
| 234 | + * |
|
| 235 | + * @since 3.6.0 |
|
| 236 | + * @access private |
|
| 237 | + * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance. |
|
| 238 | + */ |
|
| 239 | + private $rebuild_service; |
|
| 240 | + |
|
| 241 | + /** |
|
| 242 | + * A {@link Wordlift_Jsonld_Service} instance. |
|
| 243 | + * |
|
| 244 | + * @since 3.7.0 |
|
| 245 | + * @access private |
|
| 246 | + * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance. |
|
| 247 | + */ |
|
| 248 | + private $jsonld_service; |
|
| 249 | + |
|
| 250 | + /** |
|
| 251 | + * |
|
| 252 | + * @since 3.7.0 |
|
| 253 | + * @access private |
|
| 254 | + * @var \Wordlift_Property_Factory $property_factory |
|
| 255 | + */ |
|
| 256 | + private $property_factory; |
|
| 257 | + |
|
| 258 | + /** |
|
| 259 | + * The 'Download Your Data' page. |
|
| 260 | + * |
|
| 261 | + * @since 3.6.0 |
|
| 262 | + * @access private |
|
| 263 | + * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page. |
|
| 264 | + */ |
|
| 265 | + private $download_your_data_page; |
|
| 266 | + |
|
| 267 | + /** |
|
| 268 | + * The Content Filter Service hooks up to the 'the_content' filter and provides |
|
| 269 | + * linking of entities to their pages. |
|
| 270 | + * |
|
| 271 | + * @since 3.8.0 |
|
| 272 | + * @access private |
|
| 273 | + * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance. |
|
| 274 | + */ |
|
| 275 | + private $content_filter_service; |
|
| 276 | + |
|
| 277 | + /** |
|
| 278 | + * Define the core functionality of the plugin. |
|
| 279 | + * |
|
| 280 | + * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 281 | + * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 282 | + * the public-facing side of the site. |
|
| 283 | + * |
|
| 284 | + * @since 1.0.0 |
|
| 285 | + */ |
|
| 286 | + public function __construct() { |
|
| 287 | + |
|
| 288 | + $this->plugin_name = 'wordlift'; |
|
| 289 | + $this->version = '3.9.0-dev'; |
|
| 290 | + $this->load_dependencies(); |
|
| 291 | + $this->set_locale(); |
|
| 292 | + $this->define_admin_hooks(); |
|
| 293 | + $this->define_public_hooks(); |
|
| 294 | + |
|
| 295 | + } |
|
| 296 | + |
|
| 297 | + /** |
|
| 298 | + * Load the required dependencies for this plugin. |
|
| 299 | + * |
|
| 300 | + * Include the following files that make up the plugin: |
|
| 301 | + * |
|
| 302 | + * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 303 | + * - Wordlift_i18n. Defines internationalization functionality. |
|
| 304 | + * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 305 | + * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 306 | + * |
|
| 307 | + * Create an instance of the loader which will be used to register the hooks |
|
| 308 | + * with WordPress. |
|
| 309 | + * |
|
| 310 | + * @since 1.0.0 |
|
| 311 | + * @access private |
|
| 312 | + */ |
|
| 313 | + private function load_dependencies() { |
|
| 314 | + |
|
| 315 | + /** |
|
| 316 | + * The class responsible for orchestrating the actions and filters of the |
|
| 317 | + * core plugin. |
|
| 318 | + */ |
|
| 319 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 320 | + |
|
| 321 | + /** |
|
| 322 | + * The class responsible for defining internationalization functionality |
|
| 323 | + * of the plugin. |
|
| 324 | + */ |
|
| 325 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 326 | + |
|
| 327 | + /** |
|
| 328 | + * Provide support functions to sanitize data. |
|
| 329 | + */ |
|
| 330 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 331 | + |
|
| 332 | + /** |
|
| 333 | + * The Redirect service. |
|
| 334 | + */ |
|
| 335 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 336 | + |
|
| 337 | + /** |
|
| 338 | + * The Log service. |
|
| 339 | + */ |
|
| 340 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 341 | + |
|
| 342 | + /** |
|
| 343 | + * The configuration service. |
|
| 344 | + */ |
|
| 345 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 346 | + |
|
| 347 | + /** |
|
| 348 | + * The entity post type service (this is the WordPress post type, not the entity schema type). |
|
| 349 | + */ |
|
| 350 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 351 | + |
|
| 352 | + /** |
|
| 353 | + * The entity type service (i.e. the schema type). |
|
| 354 | + */ |
|
| 355 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 356 | + |
|
| 357 | + /** |
|
| 358 | + * The entity link service. |
|
| 359 | + */ |
|
| 360 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 361 | + |
|
| 362 | + /** |
|
| 363 | + * The Query builder. |
|
| 364 | + */ |
|
| 365 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 366 | + |
|
| 367 | + /** |
|
| 368 | + * The Schema service. |
|
| 369 | + */ |
|
| 370 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 371 | + |
|
| 372 | + /** |
|
| 373 | + * The schema:url property service. |
|
| 374 | + */ |
|
| 375 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 376 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 377 | + |
|
| 378 | + /** |
|
| 379 | + * The UI service. |
|
| 380 | + */ |
|
| 381 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 382 | + |
|
| 383 | + /** |
|
| 384 | + * The Thumbnail service. |
|
| 385 | + */ |
|
| 386 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 387 | + |
|
| 388 | + /** |
|
| 389 | + * The Entity Types Taxonomy service. |
|
| 390 | + */ |
|
| 391 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 392 | + |
|
| 393 | + /** |
|
| 394 | + * The Entity service. |
|
| 395 | + */ |
|
| 396 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 397 | + |
|
| 398 | + /** |
|
| 399 | + * The User service. |
|
| 400 | + */ |
|
| 401 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 402 | + |
|
| 403 | + /** |
|
| 404 | + * The Timeline service. |
|
| 405 | + */ |
|
| 406 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 407 | + |
|
| 408 | + /** |
|
| 409 | + * The Topic Taxonomy service. |
|
| 410 | + */ |
|
| 411 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 412 | + |
|
| 413 | + |
|
| 414 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-page-service.php'; |
|
| 415 | + |
|
| 416 | + /** |
|
| 417 | + * The SPARQL service. |
|
| 418 | + */ |
|
| 419 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 420 | + |
|
| 421 | + /** |
|
| 422 | + * The WordLift import service. |
|
| 423 | + */ |
|
| 424 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 425 | + |
|
| 426 | + /** |
|
| 427 | + * The WordLift URI service. |
|
| 428 | + */ |
|
| 429 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 430 | + |
|
| 431 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php'; |
|
| 432 | + |
|
| 433 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 434 | + |
|
| 435 | + /** |
|
| 436 | + * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
|
| 437 | + */ |
|
| 438 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php'; |
|
| 439 | + |
|
| 440 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 441 | + |
|
| 442 | + /** |
|
| 443 | + * Load the converters. |
|
| 444 | + */ |
|
| 445 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 446 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-to-jsonld-converter.php'; |
|
| 447 | + |
|
| 448 | + /** |
|
| 449 | + * Load the content filter. |
|
| 450 | + */ |
|
| 451 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 452 | + |
|
| 453 | + /** |
|
| 454 | + * Load the JSON-LD service to publish entities using JSON-LD.s |
|
| 455 | + * |
|
| 456 | + * @since 3.8.0 |
|
| 457 | + */ |
|
| 458 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 459 | + |
|
| 460 | + /** |
|
| 461 | + * The class responsible for defining all actions that occur in the admin area. |
|
| 462 | + */ |
|
| 463 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 464 | + |
|
| 465 | + /** |
|
| 466 | + * The class to customize the entity list admin page. |
|
| 467 | + */ |
|
| 468 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 469 | + |
|
| 470 | + /** |
|
| 471 | + * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 472 | + */ |
|
| 473 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 474 | + |
|
| 475 | + /** |
|
| 476 | + * The Notice service. |
|
| 477 | + */ |
|
| 478 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 479 | + |
|
| 480 | + /** |
|
| 481 | + * The PrimaShop adapter. |
|
| 482 | + */ |
|
| 483 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 484 | + |
|
| 485 | + /** |
|
| 486 | + * The WordLift Dashboard service. |
|
| 487 | + */ |
|
| 488 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 489 | 489 | |
| 490 | - /** |
|
| 491 | - * The admin 'Download Your Data' page. |
|
| 492 | - */ |
|
| 493 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 490 | + /** |
|
| 491 | + * The admin 'Download Your Data' page. |
|
| 492 | + */ |
|
| 493 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 494 | 494 | |
| 495 | - /** |
|
| 496 | - * The class responsible for defining all actions that occur in the public-facing |
|
| 497 | - * side of the site. |
|
| 498 | - */ |
|
| 499 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 495 | + /** |
|
| 496 | + * The class responsible for defining all actions that occur in the public-facing |
|
| 497 | + * side of the site. |
|
| 498 | + */ |
|
| 499 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 500 | 500 | |
| 501 | - /** |
|
| 502 | - * The shortcode abstract class. |
|
| 503 | - */ |
|
| 504 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 501 | + /** |
|
| 502 | + * The shortcode abstract class. |
|
| 503 | + */ |
|
| 504 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 505 | 505 | |
| 506 | - /** |
|
| 507 | - * The Timeline shortcode. |
|
| 508 | - */ |
|
| 509 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 506 | + /** |
|
| 507 | + * The Timeline shortcode. |
|
| 508 | + */ |
|
| 509 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 510 | 510 | |
| 511 | - /** |
|
| 512 | - * The Navigator shortcode. |
|
| 513 | - */ |
|
| 514 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 511 | + /** |
|
| 512 | + * The Navigator shortcode. |
|
| 513 | + */ |
|
| 514 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 515 | 515 | |
| 516 | - /** |
|
| 517 | - * The chord shortcode. |
|
| 518 | - */ |
|
| 519 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 516 | + /** |
|
| 517 | + * The chord shortcode. |
|
| 518 | + */ |
|
| 519 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 520 | 520 | |
| 521 | - /** |
|
| 522 | - * The geomap shortcode. |
|
| 523 | - */ |
|
| 524 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 521 | + /** |
|
| 522 | + * The geomap shortcode. |
|
| 523 | + */ |
|
| 524 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 525 | 525 | |
| 526 | - /** |
|
| 527 | - * The ShareThis service. |
|
| 528 | - */ |
|
| 529 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 526 | + /** |
|
| 527 | + * The ShareThis service. |
|
| 528 | + */ |
|
| 529 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 530 | 530 | |
| 531 | - $this->loader = new Wordlift_Loader(); |
|
| 531 | + $this->loader = new Wordlift_Loader(); |
|
| 532 | 532 | |
| 533 | - // Instantiate a global logger. |
|
| 534 | - global $wl_logger; |
|
| 535 | - $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 533 | + // Instantiate a global logger. |
|
| 534 | + global $wl_logger; |
|
| 535 | + $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 536 | 536 | |
| 537 | - // Create the configuration service. |
|
| 538 | - $configuration_service = new Wordlift_Configuration_Service(); |
|
| 537 | + // Create the configuration service. |
|
| 538 | + $configuration_service = new Wordlift_Configuration_Service(); |
|
| 539 | 539 | |
| 540 | - // Create an entity type service instance. It'll be later bound to the init action. |
|
| 541 | - $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $configuration_service->get_entity_base_path() ); |
|
| 540 | + // Create an entity type service instance. It'll be later bound to the init action. |
|
| 541 | + $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $configuration_service->get_entity_base_path() ); |
|
| 542 | 542 | |
| 543 | - // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 544 | - $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $configuration_service->get_entity_base_path() ); |
|
| 543 | + // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 544 | + $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $configuration_service->get_entity_base_path() ); |
|
| 545 | 545 | |
| 546 | - // Create an instance of the UI service. |
|
| 547 | - $this->ui_service = new Wordlift_UI_Service(); |
|
| 546 | + // Create an instance of the UI service. |
|
| 547 | + $this->ui_service = new Wordlift_UI_Service(); |
|
| 548 | 548 | |
| 549 | - // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 550 | - $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 549 | + // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 550 | + $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 551 | 551 | |
| 552 | - $this->sparql_service = new Wordlift_Sparql_Service(); |
|
| 552 | + $this->sparql_service = new Wordlift_Sparql_Service(); |
|
| 553 | 553 | |
| 554 | - // Create an instance of the Schema service. |
|
| 555 | - $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 556 | - $this->schema_service = new Wordlift_Schema_Service(); |
|
| 554 | + // Create an instance of the Schema service. |
|
| 555 | + $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 556 | + $this->schema_service = new Wordlift_Schema_Service(); |
|
| 557 | 557 | |
| 558 | - // Create an instance of the Notice service. |
|
| 559 | - $this->notice_service = new Wordlift_Notice_Service(); |
|
| 558 | + // Create an instance of the Notice service. |
|
| 559 | + $this->notice_service = new Wordlift_Notice_Service(); |
|
| 560 | 560 | |
| 561 | - // Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page. |
|
| 562 | - $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->schema_service, $this->notice_service ); |
|
| 561 | + // Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page. |
|
| 562 | + $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->schema_service, $this->notice_service ); |
|
| 563 | 563 | |
| 564 | - // Create an instance of the User service. |
|
| 565 | - $this->user_service = new Wordlift_User_Service(); |
|
| 564 | + // Create an instance of the User service. |
|
| 565 | + $this->user_service = new Wordlift_User_Service(); |
|
| 566 | 566 | |
| 567 | - // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 568 | - $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service ); |
|
| 567 | + // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 568 | + $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service ); |
|
| 569 | 569 | |
| 570 | - // Create a new instance of the Redirect service. |
|
| 571 | - $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service ); |
|
| 570 | + // Create a new instance of the Redirect service. |
|
| 571 | + $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service ); |
|
| 572 | 572 | |
| 573 | - // Create a new instance of the Redirect service. |
|
| 574 | - $this->dashboard_service = new Wordlift_Dashboard_Service( $this->entity_service ); |
|
| 573 | + // Create a new instance of the Redirect service. |
|
| 574 | + $this->dashboard_service = new Wordlift_Dashboard_Service( $this->entity_service ); |
|
| 575 | 575 | |
| 576 | - // Initialize the shortcodes. |
|
| 577 | - new Wordlift_Navigator_Shortcode(); |
|
| 578 | - new Wordlift_Chord_Shortcode(); |
|
| 579 | - new Wordlift_Geomap_Shortcode(); |
|
| 580 | - new Wordlift_Timeline_Shortcode(); |
|
| 576 | + // Initialize the shortcodes. |
|
| 577 | + new Wordlift_Navigator_Shortcode(); |
|
| 578 | + new Wordlift_Chord_Shortcode(); |
|
| 579 | + new Wordlift_Geomap_Shortcode(); |
|
| 580 | + new Wordlift_Timeline_Shortcode(); |
|
| 581 | 581 | |
| 582 | - // Create entity list customization (wp-admin/edit.php) |
|
| 583 | - $this->entity_list_service = new Wordlift_Entity_List_Service( $this->entity_service ); |
|
| 582 | + // Create entity list customization (wp-admin/edit.php) |
|
| 583 | + $this->entity_list_service = new Wordlift_Entity_List_Service( $this->entity_service ); |
|
| 584 | 584 | |
| 585 | - $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 585 | + $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 586 | 586 | |
| 587 | - $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 587 | + $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 588 | 588 | |
| 589 | - // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 590 | - $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 589 | + // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 590 | + $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 591 | 591 | |
| 592 | - // Create an instance of the PrimaShop adapter. |
|
| 593 | - $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 592 | + // Create an instance of the PrimaShop adapter. |
|
| 593 | + $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 594 | 594 | |
| 595 | - $this->page_service = new Wordlift_Page_Service(); |
|
| 595 | + $this->page_service = new Wordlift_Page_Service(); |
|
| 596 | 596 | |
| 597 | - // Create an import service instance to hook later to WP's import function. |
|
| 598 | - $this->import_service = new Wordlift_Import_Service( $this->entity_post_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, wl_configuration_get_redlink_dataset_uri() ); |
|
| 597 | + // Create an import service instance to hook later to WP's import function. |
|
| 598 | + $this->import_service = new Wordlift_Import_Service( $this->entity_post_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, wl_configuration_get_redlink_dataset_uri() ); |
|
| 599 | 599 | |
| 600 | - $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 600 | + $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 601 | 601 | |
| 602 | - // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
|
| 603 | - $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service ); |
|
| 602 | + // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
|
| 603 | + $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service ); |
|
| 604 | 604 | |
| 605 | - $entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service ); |
|
| 605 | + $entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service ); |
|
| 606 | 606 | |
| 607 | - $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 608 | - $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 607 | + $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 608 | + $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 609 | 609 | |
| 610 | - // Instantiate the JSON-LD service. |
|
| 611 | - $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 612 | - $entity_uri_to_jsonld_converter = new Wordlift_Entity_Uri_To_Jsonld_Converter( $entity_type_service, $this->entity_service, $property_getter ); |
|
| 613 | - $this->jsonld_service = new Wordlift_Jsonld_Service( $this->entity_service, $entity_uri_to_jsonld_converter ); |
|
| 610 | + // Instantiate the JSON-LD service. |
|
| 611 | + $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 612 | + $entity_uri_to_jsonld_converter = new Wordlift_Entity_Uri_To_Jsonld_Converter( $entity_type_service, $this->entity_service, $property_getter ); |
|
| 613 | + $this->jsonld_service = new Wordlift_Jsonld_Service( $this->entity_service, $entity_uri_to_jsonld_converter ); |
|
| 614 | 614 | |
| 615 | - //** WordPress Admin */ |
|
| 616 | - $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page(); |
|
| 615 | + //** WordPress Admin */ |
|
| 616 | + $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page(); |
|
| 617 | 617 | |
| 618 | - // Create an instance of the content filter service. |
|
| 619 | - $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service ); |
|
| 620 | - // Load the debug service if WP is in debug mode. |
|
| 621 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 622 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 623 | - new Wordlift_Debug_Service( $this->entity_service ); |
|
| 624 | - } |
|
| 618 | + // Create an instance of the content filter service. |
|
| 619 | + $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service ); |
|
| 620 | + // Load the debug service if WP is in debug mode. |
|
| 621 | + if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 622 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 623 | + new Wordlift_Debug_Service( $this->entity_service ); |
|
| 624 | + } |
|
| 625 | 625 | |
| 626 | - } |
|
| 626 | + } |
|
| 627 | 627 | |
| 628 | - /** |
|
| 629 | - * Define the locale for this plugin for internationalization. |
|
| 630 | - * |
|
| 631 | - * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 632 | - * with WordPress. |
|
| 633 | - * |
|
| 634 | - * @since 1.0.0 |
|
| 635 | - * @access private |
|
| 636 | - */ |
|
| 637 | - private function set_locale() { |
|
| 628 | + /** |
|
| 629 | + * Define the locale for this plugin for internationalization. |
|
| 630 | + * |
|
| 631 | + * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 632 | + * with WordPress. |
|
| 633 | + * |
|
| 634 | + * @since 1.0.0 |
|
| 635 | + * @access private |
|
| 636 | + */ |
|
| 637 | + private function set_locale() { |
|
| 638 | 638 | |
| 639 | - $plugin_i18n = new Wordlift_i18n(); |
|
| 640 | - $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 639 | + $plugin_i18n = new Wordlift_i18n(); |
|
| 640 | + $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 641 | 641 | |
| 642 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 642 | + $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 643 | 643 | |
| 644 | - } |
|
| 644 | + } |
|
| 645 | 645 | |
| 646 | - /** |
|
| 647 | - * Register all of the hooks related to the admin area functionality |
|
| 648 | - * of the plugin. |
|
| 649 | - * |
|
| 650 | - * @since 1.0.0 |
|
| 651 | - * @access private |
|
| 652 | - */ |
|
| 653 | - private function define_admin_hooks() { |
|
| 646 | + /** |
|
| 647 | + * Register all of the hooks related to the admin area functionality |
|
| 648 | + * of the plugin. |
|
| 649 | + * |
|
| 650 | + * @since 1.0.0 |
|
| 651 | + * @access private |
|
| 652 | + */ |
|
| 653 | + private function define_admin_hooks() { |
|
| 654 | 654 | |
| 655 | - $plugin_admin = new Wordlift_Admin( $this->get_plugin_name(), $this->get_version() ); |
|
| 655 | + $plugin_admin = new Wordlift_Admin( $this->get_plugin_name(), $this->get_version() ); |
|
| 656 | 656 | |
| 657 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 658 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
| 657 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 658 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
| 659 | 659 | |
| 660 | - // Hook the init action to the Topic Taxonomy service. |
|
| 661 | - $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 660 | + // Hook the init action to the Topic Taxonomy service. |
|
| 661 | + $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 662 | 662 | |
| 663 | - // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 664 | - $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 663 | + // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 664 | + $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 665 | 665 | |
| 666 | - // Hook the added_post_meta action to the Thumbnail service. |
|
| 667 | - $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 666 | + // Hook the added_post_meta action to the Thumbnail service. |
|
| 667 | + $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 668 | 668 | |
| 669 | - // Hook the updated_post_meta action to the Thumbnail service. |
|
| 670 | - $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 669 | + // Hook the updated_post_meta action to the Thumbnail service. |
|
| 670 | + $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 671 | 671 | |
| 672 | - // Hook posts inserts (or updates) to the user service. |
|
| 673 | - $this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 ); |
|
| 672 | + // Hook posts inserts (or updates) to the user service. |
|
| 673 | + $this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 ); |
|
| 674 | 674 | |
| 675 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 676 | - $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 675 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 676 | + $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 677 | 677 | |
| 678 | - // Register custom allowed redirect hosts. |
|
| 679 | - $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 680 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 681 | - $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 682 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 683 | - $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 684 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 685 | - $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 678 | + // Register custom allowed redirect hosts. |
|
| 679 | + $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 680 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 681 | + $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 682 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 683 | + $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 684 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 685 | + $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 686 | 686 | |
| 687 | - // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 688 | - // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 689 | - $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 690 | - $this->loader->add_action( 'save_post_entity', $this->entity_service, 'set_rating_for', 10, 1 ); |
|
| 687 | + // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 688 | + // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 689 | + $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 690 | + $this->loader->add_action( 'save_post_entity', $this->entity_service, 'set_rating_for', 10, 1 ); |
|
| 691 | 691 | |
| 692 | - $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 693 | - $this->loader->add_action( 'in_admin_header', $this->entity_service, 'in_admin_header' ); |
|
| 692 | + $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 693 | + $this->loader->add_action( 'in_admin_header', $this->entity_service, 'in_admin_header' ); |
|
| 694 | 694 | |
| 695 | - // Entity listing customization (wp-admin/edit.php) |
|
| 696 | - // Add custom columns |
|
| 697 | - $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 698 | - $this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 699 | - // Add 4W selection |
|
| 700 | - $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 701 | - $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 702 | - |
|
| 703 | - $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 704 | - |
|
| 705 | - // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 706 | - // entities. |
|
| 707 | - $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 708 | - |
|
| 709 | - // Filter imported post meta. |
|
| 710 | - $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 711 | - |
|
| 712 | - // Notify the import service when an import starts and ends. |
|
| 713 | - $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 714 | - $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 715 | - |
|
| 716 | - // Hook the AJAX wl_rebuild action to the Rebuild Service. |
|
| 717 | - $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 718 | - |
|
| 719 | - // Hook the menu to the Download Your Data page. |
|
| 720 | - $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 ); |
|
| 721 | - |
|
| 722 | - // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
|
| 723 | - $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 724 | - |
|
| 725 | - // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 726 | - $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 727 | - |
|
| 728 | - } |
|
| 729 | - |
|
| 730 | - /** |
|
| 731 | - * Register all of the hooks related to the public-facing functionality |
|
| 732 | - * of the plugin. |
|
| 733 | - * |
|
| 734 | - * @since 1.0.0 |
|
| 735 | - * @access private |
|
| 736 | - */ |
|
| 737 | - private function define_public_hooks() { |
|
| 738 | - |
|
| 739 | - $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 740 | - |
|
| 741 | - // Register the entity post type. |
|
| 742 | - $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' ); |
|
| 743 | - |
|
| 744 | - // Bind the link generation and handling hooks to the entity link service. |
|
| 745 | - $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 746 | - $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1 ); |
|
| 747 | - $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 ); |
|
| 748 | - $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 ); |
|
| 749 | - |
|
| 750 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 751 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 752 | - |
|
| 753 | - // Hook the content filter service to add entity links. |
|
| 754 | - $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content'); |
|
| 755 | - |
|
| 756 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 757 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 758 | - |
|
| 759 | - // Hook the ShareThis service. |
|
| 760 | - $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 761 | - $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 762 | - |
|
| 763 | - $this->loader->add_action( 'wp_head', $this->page_service, 'wp_head', PHP_INT_MAX ); |
|
| 764 | - $this->loader->add_action( 'wp_footer', $this->page_service, 'wp_head', - PHP_INT_MAX ); |
|
| 765 | - |
|
| 766 | - // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 767 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 768 | - |
|
| 769 | - } |
|
| 770 | - |
|
| 771 | - /** |
|
| 772 | - * Run the loader to execute all of the hooks with WordPress. |
|
| 773 | - * |
|
| 774 | - * @since 1.0.0 |
|
| 775 | - */ |
|
| 776 | - public function run() { |
|
| 777 | - $this->loader->run(); |
|
| 778 | - } |
|
| 779 | - |
|
| 780 | - /** |
|
| 781 | - * The name of the plugin used to uniquely identify it within the context of |
|
| 782 | - * WordPress and to define internationalization functionality. |
|
| 783 | - * |
|
| 784 | - * @since 1.0.0 |
|
| 785 | - * @return string The name of the plugin. |
|
| 786 | - */ |
|
| 787 | - public function get_plugin_name() { |
|
| 788 | - return $this->plugin_name; |
|
| 789 | - } |
|
| 790 | - |
|
| 791 | - /** |
|
| 792 | - * The reference to the class that orchestrates the hooks with the plugin. |
|
| 793 | - * |
|
| 794 | - * @since 1.0.0 |
|
| 795 | - * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 796 | - */ |
|
| 797 | - public function get_loader() { |
|
| 798 | - return $this->loader; |
|
| 799 | - } |
|
| 800 | - |
|
| 801 | - /** |
|
| 802 | - * Retrieve the version number of the plugin. |
|
| 803 | - * |
|
| 804 | - * @since 1.0.0 |
|
| 805 | - * @return string The version number of the plugin. |
|
| 806 | - */ |
|
| 807 | - public function get_version() { |
|
| 808 | - return $this->version; |
|
| 809 | - } |
|
| 695 | + // Entity listing customization (wp-admin/edit.php) |
|
| 696 | + // Add custom columns |
|
| 697 | + $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 698 | + $this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 699 | + // Add 4W selection |
|
| 700 | + $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 701 | + $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 702 | + |
|
| 703 | + $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 704 | + |
|
| 705 | + // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 706 | + // entities. |
|
| 707 | + $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 708 | + |
|
| 709 | + // Filter imported post meta. |
|
| 710 | + $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 711 | + |
|
| 712 | + // Notify the import service when an import starts and ends. |
|
| 713 | + $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 714 | + $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 715 | + |
|
| 716 | + // Hook the AJAX wl_rebuild action to the Rebuild Service. |
|
| 717 | + $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 718 | + |
|
| 719 | + // Hook the menu to the Download Your Data page. |
|
| 720 | + $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 ); |
|
| 721 | + |
|
| 722 | + // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
|
| 723 | + $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 724 | + |
|
| 725 | + // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 726 | + $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 727 | + |
|
| 728 | + } |
|
| 729 | + |
|
| 730 | + /** |
|
| 731 | + * Register all of the hooks related to the public-facing functionality |
|
| 732 | + * of the plugin. |
|
| 733 | + * |
|
| 734 | + * @since 1.0.0 |
|
| 735 | + * @access private |
|
| 736 | + */ |
|
| 737 | + private function define_public_hooks() { |
|
| 738 | + |
|
| 739 | + $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 740 | + |
|
| 741 | + // Register the entity post type. |
|
| 742 | + $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' ); |
|
| 743 | + |
|
| 744 | + // Bind the link generation and handling hooks to the entity link service. |
|
| 745 | + $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 746 | + $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1 ); |
|
| 747 | + $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 ); |
|
| 748 | + $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 ); |
|
| 749 | + |
|
| 750 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 751 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 752 | + |
|
| 753 | + // Hook the content filter service to add entity links. |
|
| 754 | + $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content'); |
|
| 755 | + |
|
| 756 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 757 | + $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 758 | + |
|
| 759 | + // Hook the ShareThis service. |
|
| 760 | + $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 761 | + $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 762 | + |
|
| 763 | + $this->loader->add_action( 'wp_head', $this->page_service, 'wp_head', PHP_INT_MAX ); |
|
| 764 | + $this->loader->add_action( 'wp_footer', $this->page_service, 'wp_head', - PHP_INT_MAX ); |
|
| 765 | + |
|
| 766 | + // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 767 | + $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 768 | + |
|
| 769 | + } |
|
| 770 | + |
|
| 771 | + /** |
|
| 772 | + * Run the loader to execute all of the hooks with WordPress. |
|
| 773 | + * |
|
| 774 | + * @since 1.0.0 |
|
| 775 | + */ |
|
| 776 | + public function run() { |
|
| 777 | + $this->loader->run(); |
|
| 778 | + } |
|
| 779 | + |
|
| 780 | + /** |
|
| 781 | + * The name of the plugin used to uniquely identify it within the context of |
|
| 782 | + * WordPress and to define internationalization functionality. |
|
| 783 | + * |
|
| 784 | + * @since 1.0.0 |
|
| 785 | + * @return string The name of the plugin. |
|
| 786 | + */ |
|
| 787 | + public function get_plugin_name() { |
|
| 788 | + return $this->plugin_name; |
|
| 789 | + } |
|
| 790 | + |
|
| 791 | + /** |
|
| 792 | + * The reference to the class that orchestrates the hooks with the plugin. |
|
| 793 | + * |
|
| 794 | + * @since 1.0.0 |
|
| 795 | + * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 796 | + */ |
|
| 797 | + public function get_loader() { |
|
| 798 | + return $this->loader; |
|
| 799 | + } |
|
| 800 | + |
|
| 801 | + /** |
|
| 802 | + * Retrieve the version number of the plugin. |
|
| 803 | + * |
|
| 804 | + * @since 1.0.0 |
|
| 805 | + * @return string The version number of the plugin. |
|
| 806 | + */ |
|
| 807 | + public function get_version() { |
|
| 808 | + return $this->version; |
|
| 809 | + } |
|
| 810 | 810 | |
| 811 | 811 | } |
@@ -316,232 +316,232 @@ discard block |
||
| 316 | 316 | * The class responsible for orchestrating the actions and filters of the |
| 317 | 317 | * core plugin. |
| 318 | 318 | */ |
| 319 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 319 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-loader.php'; |
|
| 320 | 320 | |
| 321 | 321 | /** |
| 322 | 322 | * The class responsible for defining internationalization functionality |
| 323 | 323 | * of the plugin. |
| 324 | 324 | */ |
| 325 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 325 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-i18n.php'; |
|
| 326 | 326 | |
| 327 | 327 | /** |
| 328 | 328 | * Provide support functions to sanitize data. |
| 329 | 329 | */ |
| 330 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 330 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sanitizer.php'; |
|
| 331 | 331 | |
| 332 | 332 | /** |
| 333 | 333 | * The Redirect service. |
| 334 | 334 | */ |
| 335 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 335 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-redirect-service.php'; |
|
| 336 | 336 | |
| 337 | 337 | /** |
| 338 | 338 | * The Log service. |
| 339 | 339 | */ |
| 340 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 340 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-log-service.php'; |
|
| 341 | 341 | |
| 342 | 342 | /** |
| 343 | 343 | * The configuration service. |
| 344 | 344 | */ |
| 345 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 345 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-configuration-service.php'; |
|
| 346 | 346 | |
| 347 | 347 | /** |
| 348 | 348 | * The entity post type service (this is the WordPress post type, not the entity schema type). |
| 349 | 349 | */ |
| 350 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 350 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-post-type-service.php'; |
|
| 351 | 351 | |
| 352 | 352 | /** |
| 353 | 353 | * The entity type service (i.e. the schema type). |
| 354 | 354 | */ |
| 355 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 355 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-type-service.php'; |
|
| 356 | 356 | |
| 357 | 357 | /** |
| 358 | 358 | * The entity link service. |
| 359 | 359 | */ |
| 360 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 360 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-link-service.php'; |
|
| 361 | 361 | |
| 362 | 362 | /** |
| 363 | 363 | * The Query builder. |
| 364 | 364 | */ |
| 365 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 365 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-query-builder.php'; |
|
| 366 | 366 | |
| 367 | 367 | /** |
| 368 | 368 | * The Schema service. |
| 369 | 369 | */ |
| 370 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 370 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-schema-service.php'; |
|
| 371 | 371 | |
| 372 | 372 | /** |
| 373 | 373 | * The schema:url property service. |
| 374 | 374 | */ |
| 375 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 376 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 375 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-property-service.php'; |
|
| 376 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-schema-url-property-service.php'; |
|
| 377 | 377 | |
| 378 | 378 | /** |
| 379 | 379 | * The UI service. |
| 380 | 380 | */ |
| 381 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 381 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-ui-service.php'; |
|
| 382 | 382 | |
| 383 | 383 | /** |
| 384 | 384 | * The Thumbnail service. |
| 385 | 385 | */ |
| 386 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 386 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-thumbnail-service.php'; |
|
| 387 | 387 | |
| 388 | 388 | /** |
| 389 | 389 | * The Entity Types Taxonomy service. |
| 390 | 390 | */ |
| 391 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 391 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 392 | 392 | |
| 393 | 393 | /** |
| 394 | 394 | * The Entity service. |
| 395 | 395 | */ |
| 396 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 396 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-service.php'; |
|
| 397 | 397 | |
| 398 | 398 | /** |
| 399 | 399 | * The User service. |
| 400 | 400 | */ |
| 401 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 401 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-user-service.php'; |
|
| 402 | 402 | |
| 403 | 403 | /** |
| 404 | 404 | * The Timeline service. |
| 405 | 405 | */ |
| 406 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 406 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-timeline-service.php'; |
|
| 407 | 407 | |
| 408 | 408 | /** |
| 409 | 409 | * The Topic Taxonomy service. |
| 410 | 410 | */ |
| 411 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 411 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 412 | 412 | |
| 413 | 413 | |
| 414 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-page-service.php'; |
|
| 414 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-page-service.php'; |
|
| 415 | 415 | |
| 416 | 416 | /** |
| 417 | 417 | * The SPARQL service. |
| 418 | 418 | */ |
| 419 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 419 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sparql-service.php'; |
|
| 420 | 420 | |
| 421 | 421 | /** |
| 422 | 422 | * The WordLift import service. |
| 423 | 423 | */ |
| 424 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 424 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-import-service.php'; |
|
| 425 | 425 | |
| 426 | 426 | /** |
| 427 | 427 | * The WordLift URI service. |
| 428 | 428 | */ |
| 429 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 429 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-uri-service.php'; |
|
| 430 | 430 | |
| 431 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php'; |
|
| 431 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-listable.php'; |
|
| 432 | 432 | |
| 433 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 433 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-property-factory.php'; |
|
| 434 | 434 | |
| 435 | 435 | /** |
| 436 | 436 | * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
| 437 | 437 | */ |
| 438 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php'; |
|
| 438 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-rebuild-service.php'; |
|
| 439 | 439 | |
| 440 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 440 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 441 | 441 | |
| 442 | 442 | /** |
| 443 | 443 | * Load the converters. |
| 444 | 444 | */ |
| 445 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 446 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-to-jsonld-converter.php'; |
|
| 445 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 446 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-uri-to-jsonld-converter.php'; |
|
| 447 | 447 | |
| 448 | 448 | /** |
| 449 | 449 | * Load the content filter. |
| 450 | 450 | */ |
| 451 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 451 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-content-filter-service.php'; |
|
| 452 | 452 | |
| 453 | 453 | /** |
| 454 | 454 | * Load the JSON-LD service to publish entities using JSON-LD.s |
| 455 | 455 | * |
| 456 | 456 | * @since 3.8.0 |
| 457 | 457 | */ |
| 458 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 458 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-jsonld-service.php'; |
|
| 459 | 459 | |
| 460 | 460 | /** |
| 461 | 461 | * The class responsible for defining all actions that occur in the admin area. |
| 462 | 462 | */ |
| 463 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 463 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin.php'; |
|
| 464 | 464 | |
| 465 | 465 | /** |
| 466 | 466 | * The class to customize the entity list admin page. |
| 467 | 467 | */ |
| 468 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 468 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-entity-list.php'; |
|
| 469 | 469 | |
| 470 | 470 | /** |
| 471 | 471 | * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
| 472 | 472 | */ |
| 473 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 473 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 474 | 474 | |
| 475 | 475 | /** |
| 476 | 476 | * The Notice service. |
| 477 | 477 | */ |
| 478 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 478 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-notice-service.php'; |
|
| 479 | 479 | |
| 480 | 480 | /** |
| 481 | 481 | * The PrimaShop adapter. |
| 482 | 482 | */ |
| 483 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 483 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-primashop-adapter.php'; |
|
| 484 | 484 | |
| 485 | 485 | /** |
| 486 | 486 | * The WordLift Dashboard service. |
| 487 | 487 | */ |
| 488 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 488 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-dashboard.php'; |
|
| 489 | 489 | |
| 490 | 490 | /** |
| 491 | 491 | * The admin 'Download Your Data' page. |
| 492 | 492 | */ |
| 493 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 493 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-download-your-data-page.php'; |
|
| 494 | 494 | |
| 495 | 495 | /** |
| 496 | 496 | * The class responsible for defining all actions that occur in the public-facing |
| 497 | 497 | * side of the site. |
| 498 | 498 | */ |
| 499 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 499 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-public.php'; |
|
| 500 | 500 | |
| 501 | 501 | /** |
| 502 | 502 | * The shortcode abstract class. |
| 503 | 503 | */ |
| 504 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 504 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-shortcode.php'; |
|
| 505 | 505 | |
| 506 | 506 | /** |
| 507 | 507 | * The Timeline shortcode. |
| 508 | 508 | */ |
| 509 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 509 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-timeline-shortcode.php'; |
|
| 510 | 510 | |
| 511 | 511 | /** |
| 512 | 512 | * The Navigator shortcode. |
| 513 | 513 | */ |
| 514 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 514 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-navigator-shortcode.php'; |
|
| 515 | 515 | |
| 516 | 516 | /** |
| 517 | 517 | * The chord shortcode. |
| 518 | 518 | */ |
| 519 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 519 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-chord-shortcode.php'; |
|
| 520 | 520 | |
| 521 | 521 | /** |
| 522 | 522 | * The geomap shortcode. |
| 523 | 523 | */ |
| 524 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 524 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-geomap-shortcode.php'; |
|
| 525 | 525 | |
| 526 | 526 | /** |
| 527 | 527 | * The ShareThis service. |
| 528 | 528 | */ |
| 529 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 529 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-sharethis-service.php'; |
|
| 530 | 530 | |
| 531 | 531 | $this->loader = new Wordlift_Loader(); |
| 532 | 532 | |
| 533 | 533 | // Instantiate a global logger. |
| 534 | 534 | global $wl_logger; |
| 535 | - $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 535 | + $wl_logger = Wordlift_Log_Service::get_logger('WordLift'); |
|
| 536 | 536 | |
| 537 | 537 | // Create the configuration service. |
| 538 | 538 | $configuration_service = new Wordlift_Configuration_Service(); |
| 539 | 539 | |
| 540 | 540 | // Create an entity type service instance. It'll be later bound to the init action. |
| 541 | - $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $configuration_service->get_entity_base_path() ); |
|
| 541 | + $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service(Wordlift_Entity_Service::TYPE_NAME, $configuration_service->get_entity_base_path()); |
|
| 542 | 542 | |
| 543 | 543 | // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
| 544 | - $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $configuration_service->get_entity_base_path() ); |
|
| 544 | + $this->entity_link_service = new Wordlift_Entity_Link_Service($this->entity_post_type_service, $configuration_service->get_entity_base_path()); |
|
| 545 | 545 | |
| 546 | 546 | // Create an instance of the UI service. |
| 547 | 547 | $this->ui_service = new Wordlift_UI_Service(); |
@@ -552,26 +552,26 @@ discard block |
||
| 552 | 552 | $this->sparql_service = new Wordlift_Sparql_Service(); |
| 553 | 553 | |
| 554 | 554 | // Create an instance of the Schema service. |
| 555 | - $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 555 | + $schema_url_property_service = new Wordlift_Schema_Url_Property_Service($this->sparql_service); |
|
| 556 | 556 | $this->schema_service = new Wordlift_Schema_Service(); |
| 557 | 557 | |
| 558 | 558 | // Create an instance of the Notice service. |
| 559 | 559 | $this->notice_service = new Wordlift_Notice_Service(); |
| 560 | 560 | |
| 561 | 561 | // Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page. |
| 562 | - $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->schema_service, $this->notice_service ); |
|
| 562 | + $this->entity_service = new Wordlift_Entity_Service($this->ui_service, $this->schema_service, $this->notice_service); |
|
| 563 | 563 | |
| 564 | 564 | // Create an instance of the User service. |
| 565 | 565 | $this->user_service = new Wordlift_User_Service(); |
| 566 | 566 | |
| 567 | 567 | // Create a new instance of the Timeline service and Timeline shortcode. |
| 568 | - $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service ); |
|
| 568 | + $this->timeline_service = new Wordlift_Timeline_Service($this->entity_service); |
|
| 569 | 569 | |
| 570 | 570 | // Create a new instance of the Redirect service. |
| 571 | - $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service ); |
|
| 571 | + $this->redirect_service = new Wordlift_Redirect_Service($this->entity_service); |
|
| 572 | 572 | |
| 573 | 573 | // Create a new instance of the Redirect service. |
| 574 | - $this->dashboard_service = new Wordlift_Dashboard_Service( $this->entity_service ); |
|
| 574 | + $this->dashboard_service = new Wordlift_Dashboard_Service($this->entity_service); |
|
| 575 | 575 | |
| 576 | 576 | // Initialize the shortcodes. |
| 577 | 577 | new Wordlift_Navigator_Shortcode(); |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | new Wordlift_Timeline_Shortcode(); |
| 581 | 581 | |
| 582 | 582 | // Create entity list customization (wp-admin/edit.php) |
| 583 | - $this->entity_list_service = new Wordlift_Entity_List_Service( $this->entity_service ); |
|
| 583 | + $this->entity_list_service = new Wordlift_Entity_List_Service($this->entity_service); |
|
| 584 | 584 | |
| 585 | 585 | $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
| 586 | 586 | |
@@ -595,32 +595,32 @@ discard block |
||
| 595 | 595 | $this->page_service = new Wordlift_Page_Service(); |
| 596 | 596 | |
| 597 | 597 | // Create an import service instance to hook later to WP's import function. |
| 598 | - $this->import_service = new Wordlift_Import_Service( $this->entity_post_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, wl_configuration_get_redlink_dataset_uri() ); |
|
| 598 | + $this->import_service = new Wordlift_Import_Service($this->entity_post_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, wl_configuration_get_redlink_dataset_uri()); |
|
| 599 | 599 | |
| 600 | - $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 600 | + $uri_service = new Wordlift_Uri_Service($GLOBALS['wpdb']); |
|
| 601 | 601 | |
| 602 | 602 | // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
| 603 | - $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service ); |
|
| 603 | + $this->rebuild_service = new Wordlift_Rebuild_Service($this->sparql_service, $uri_service); |
|
| 604 | 604 | |
| 605 | - $entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service ); |
|
| 605 | + $entity_type_service = new Wordlift_Entity_Type_Service($this->schema_service); |
|
| 606 | 606 | |
| 607 | - $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 608 | - $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 607 | + $this->property_factory = new Wordlift_Property_Factory($schema_url_property_service); |
|
| 608 | + $this->property_factory->register(Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service); |
|
| 609 | 609 | |
| 610 | 610 | // Instantiate the JSON-LD service. |
| 611 | - $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 612 | - $entity_uri_to_jsonld_converter = new Wordlift_Entity_Uri_To_Jsonld_Converter( $entity_type_service, $this->entity_service, $property_getter ); |
|
| 613 | - $this->jsonld_service = new Wordlift_Jsonld_Service( $this->entity_service, $entity_uri_to_jsonld_converter ); |
|
| 611 | + $property_getter = Wordlift_Property_Getter_Factory::create($this->entity_service); |
|
| 612 | + $entity_uri_to_jsonld_converter = new Wordlift_Entity_Uri_To_Jsonld_Converter($entity_type_service, $this->entity_service, $property_getter); |
|
| 613 | + $this->jsonld_service = new Wordlift_Jsonld_Service($this->entity_service, $entity_uri_to_jsonld_converter); |
|
| 614 | 614 | |
| 615 | 615 | //** WordPress Admin */ |
| 616 | 616 | $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page(); |
| 617 | 617 | |
| 618 | 618 | // Create an instance of the content filter service. |
| 619 | - $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service ); |
|
| 619 | + $this->content_filter_service = new Wordlift_Content_Filter_Service($this->entity_service); |
|
| 620 | 620 | // Load the debug service if WP is in debug mode. |
| 621 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 622 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 623 | - new Wordlift_Debug_Service( $this->entity_service ); |
|
| 621 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
| 622 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-debug-service.php'; |
|
| 623 | + new Wordlift_Debug_Service($this->entity_service); |
|
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | } |
@@ -637,9 +637,9 @@ discard block |
||
| 637 | 637 | private function set_locale() { |
| 638 | 638 | |
| 639 | 639 | $plugin_i18n = new Wordlift_i18n(); |
| 640 | - $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 640 | + $plugin_i18n->set_domain($this->get_plugin_name()); |
|
| 641 | 641 | |
| 642 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 642 | + $this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain'); |
|
| 643 | 643 | |
| 644 | 644 | } |
| 645 | 645 | |
@@ -652,78 +652,78 @@ discard block |
||
| 652 | 652 | */ |
| 653 | 653 | private function define_admin_hooks() { |
| 654 | 654 | |
| 655 | - $plugin_admin = new Wordlift_Admin( $this->get_plugin_name(), $this->get_version() ); |
|
| 655 | + $plugin_admin = new Wordlift_Admin($this->get_plugin_name(), $this->get_version()); |
|
| 656 | 656 | |
| 657 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 658 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
| 657 | + $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles'); |
|
| 658 | + $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts'); |
|
| 659 | 659 | |
| 660 | 660 | // Hook the init action to the Topic Taxonomy service. |
| 661 | - $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 661 | + $this->loader->add_action('init', $this->topic_taxonomy_service, 'init', 0); |
|
| 662 | 662 | |
| 663 | 663 | // Hook the deleted_post_meta action to the Thumbnail service. |
| 664 | - $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 664 | + $this->loader->add_action('deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4); |
|
| 665 | 665 | |
| 666 | 666 | // Hook the added_post_meta action to the Thumbnail service. |
| 667 | - $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 667 | + $this->loader->add_action('added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4); |
|
| 668 | 668 | |
| 669 | 669 | // Hook the updated_post_meta action to the Thumbnail service. |
| 670 | - $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 670 | + $this->loader->add_action('updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4); |
|
| 671 | 671 | |
| 672 | 672 | // Hook posts inserts (or updates) to the user service. |
| 673 | - $this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 ); |
|
| 673 | + $this->loader->add_action('wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3); |
|
| 674 | 674 | |
| 675 | 675 | // Hook the AJAX wl_timeline action to the Timeline service. |
| 676 | - $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 676 | + $this->loader->add_action('wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline'); |
|
| 677 | 677 | |
| 678 | 678 | // Register custom allowed redirect hosts. |
| 679 | - $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 679 | + $this->loader->add_filter('allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts'); |
|
| 680 | 680 | // Hook the AJAX wordlift_redirect action to the Redirect service. |
| 681 | - $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 681 | + $this->loader->add_action('wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect'); |
|
| 682 | 682 | // Hook the AJAX wordlift_redirect action to the Redirect service. |
| 683 | - $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 683 | + $this->loader->add_action('wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats'); |
|
| 684 | 684 | // Hook the AJAX wordlift_redirect action to the Redirect service. |
| 685 | - $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 685 | + $this->loader->add_action('wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets'); |
|
| 686 | 686 | |
| 687 | 687 | // Hook save_post to the entity service to update custom fields (such as alternate labels). |
| 688 | 688 | // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
| 689 | - $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 690 | - $this->loader->add_action( 'save_post_entity', $this->entity_service, 'set_rating_for', 10, 1 ); |
|
| 689 | + $this->loader->add_action('save_post', $this->entity_service, 'save_post', 9, 3); |
|
| 690 | + $this->loader->add_action('save_post_entity', $this->entity_service, 'set_rating_for', 10, 1); |
|
| 691 | 691 | |
| 692 | - $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 693 | - $this->loader->add_action( 'in_admin_header', $this->entity_service, 'in_admin_header' ); |
|
| 692 | + $this->loader->add_action('edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1); |
|
| 693 | + $this->loader->add_action('in_admin_header', $this->entity_service, 'in_admin_header'); |
|
| 694 | 694 | |
| 695 | 695 | // Entity listing customization (wp-admin/edit.php) |
| 696 | 696 | // Add custom columns |
| 697 | - $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 698 | - $this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 697 | + $this->loader->add_filter('manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns'); |
|
| 698 | + $this->loader->add_filter('manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2); |
|
| 699 | 699 | // Add 4W selection |
| 700 | - $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 701 | - $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 700 | + $this->loader->add_action('restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope'); |
|
| 701 | + $this->loader->add_filter('posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope'); |
|
| 702 | 702 | |
| 703 | - $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 703 | + $this->loader->add_filter('wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args'); |
|
| 704 | 704 | |
| 705 | 705 | // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
| 706 | 706 | // entities. |
| 707 | - $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 707 | + $this->loader->add_filter('prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2); |
|
| 708 | 708 | |
| 709 | 709 | // Filter imported post meta. |
| 710 | - $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 710 | + $this->loader->add_filter('wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3); |
|
| 711 | 711 | |
| 712 | 712 | // Notify the import service when an import starts and ends. |
| 713 | - $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 714 | - $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 713 | + $this->loader->add_action('import_start', $this->import_service, 'import_start', 10, 0); |
|
| 714 | + $this->loader->add_action('import_end', $this->import_service, 'import_end', 10, 0); |
|
| 715 | 715 | |
| 716 | 716 | // Hook the AJAX wl_rebuild action to the Rebuild Service. |
| 717 | - $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 717 | + $this->loader->add_action('wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild'); |
|
| 718 | 718 | |
| 719 | 719 | // Hook the menu to the Download Your Data page. |
| 720 | - $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 ); |
|
| 720 | + $this->loader->add_action('admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0); |
|
| 721 | 721 | |
| 722 | 722 | // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
| 723 | - $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 723 | + $this->loader->add_action('wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10); |
|
| 724 | 724 | |
| 725 | 725 | // Hook the AJAX wl_jsonld action to the JSON-LD service. |
| 726 | - $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 726 | + $this->loader->add_action('wp_ajax_wl_jsonld', $this->jsonld_service, 'get'); |
|
| 727 | 727 | |
| 728 | 728 | } |
| 729 | 729 | |
@@ -736,35 +736,35 @@ discard block |
||
| 736 | 736 | */ |
| 737 | 737 | private function define_public_hooks() { |
| 738 | 738 | |
| 739 | - $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 739 | + $plugin_public = new Wordlift_Public($this->get_plugin_name(), $this->get_version()); |
|
| 740 | 740 | |
| 741 | 741 | // Register the entity post type. |
| 742 | - $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' ); |
|
| 742 | + $this->loader->add_action('init', $this->entity_post_type_service, 'register'); |
|
| 743 | 743 | |
| 744 | 744 | // Bind the link generation and handling hooks to the entity link service. |
| 745 | - $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 746 | - $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1 ); |
|
| 747 | - $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 ); |
|
| 748 | - $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 ); |
|
| 745 | + $this->loader->add_filter('post_type_link', $this->entity_link_service, 'post_type_link', 10, 4); |
|
| 746 | + $this->loader->add_action('pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1); |
|
| 747 | + $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); |
|
| 748 | + $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); |
|
| 749 | 749 | |
| 750 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 751 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 750 | + $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles'); |
|
| 751 | + $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts'); |
|
| 752 | 752 | |
| 753 | 753 | // Hook the content filter service to add entity links. |
| 754 | - $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content'); |
|
| 754 | + $this->loader->add_filter('the_content', $this->content_filter_service, 'the_content'); |
|
| 755 | 755 | |
| 756 | 756 | // Hook the AJAX wl_timeline action to the Timeline service. |
| 757 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 757 | + $this->loader->add_action('wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline'); |
|
| 758 | 758 | |
| 759 | 759 | // Hook the ShareThis service. |
| 760 | - $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 761 | - $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 760 | + $this->loader->add_filter('the_content', $this->sharethis_service, 'the_content', 99); |
|
| 761 | + $this->loader->add_filter('the_excerpt', $this->sharethis_service, 'the_excerpt', 99); |
|
| 762 | 762 | |
| 763 | - $this->loader->add_action( 'wp_head', $this->page_service, 'wp_head', PHP_INT_MAX ); |
|
| 764 | - $this->loader->add_action( 'wp_footer', $this->page_service, 'wp_head', - PHP_INT_MAX ); |
|
| 763 | + $this->loader->add_action('wp_head', $this->page_service, 'wp_head', PHP_INT_MAX); |
|
| 764 | + $this->loader->add_action('wp_footer', $this->page_service, 'wp_head', - PHP_INT_MAX); |
|
| 765 | 765 | |
| 766 | 766 | // Hook the AJAX wl_jsonld action to the JSON-LD service. |
| 767 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 767 | + $this->loader->add_action('wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get'); |
|
| 768 | 768 | |
| 769 | 769 | } |
| 770 | 770 | |
@@ -13,55 +13,55 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class Wordlift_Debug_Service { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * The {@link Wordlift_Entity_Service} instance. |
|
| 18 | - * |
|
| 19 | - * @since 3.7.2 |
|
| 20 | - * @access private |
|
| 21 | - * @var Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
| 22 | - */ |
|
| 23 | - private $entity_service; |
|
| 16 | + /** |
|
| 17 | + * The {@link Wordlift_Entity_Service} instance. |
|
| 18 | + * |
|
| 19 | + * @since 3.7.2 |
|
| 20 | + * @access private |
|
| 21 | + * @var Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
| 22 | + */ |
|
| 23 | + private $entity_service; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Wordlift_Debug_Service constructor. |
|
| 27 | - * |
|
| 28 | - * @since 3.7.2 |
|
| 29 | - * |
|
| 30 | - * @param Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
| 31 | - */ |
|
| 32 | - public function __construct( $entity_service ) { |
|
| 25 | + /** |
|
| 26 | + * Wordlift_Debug_Service constructor. |
|
| 27 | + * |
|
| 28 | + * @since 3.7.2 |
|
| 29 | + * |
|
| 30 | + * @param Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
| 31 | + */ |
|
| 32 | + public function __construct( $entity_service ) { |
|
| 33 | 33 | |
| 34 | - $this->entity_service = $entity_service; |
|
| 34 | + $this->entity_service = $entity_service; |
|
| 35 | 35 | |
| 36 | - add_action( 'wp_ajax_wl_dump_uri', array( $this, 'dump_uri' ) ); |
|
| 36 | + add_action( 'wp_ajax_wl_dump_uri', array( $this, 'dump_uri' ) ); |
|
| 37 | 37 | |
| 38 | - } |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - public function dump_uri() { |
|
| 40 | + public function dump_uri() { |
|
| 41 | 41 | |
| 42 | - if ( ! isset( $_GET['id'] ) ) { |
|
| 43 | - wp_send_json_error( 'id not set' ); |
|
| 44 | - } |
|
| 42 | + if ( ! isset( $_GET['id'] ) ) { |
|
| 43 | + wp_send_json_error( 'id not set' ); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - $post_id = $_GET['id']; |
|
| 46 | + $post_id = $_GET['id']; |
|
| 47 | 47 | |
| 48 | - $post = get_post( $post_id ); |
|
| 48 | + $post = get_post( $post_id ); |
|
| 49 | 49 | |
| 50 | - $uri = $this->entity_service->get_uri( $post_id ); |
|
| 51 | - $encoding = mb_detect_encoding( $uri ); |
|
| 52 | - $build_uri = $this->entity_service->build_uri( $post->post_title, $post->post_type ); |
|
| 50 | + $uri = $this->entity_service->get_uri( $post_id ); |
|
| 51 | + $encoding = mb_detect_encoding( $uri ); |
|
| 52 | + $build_uri = $this->entity_service->build_uri( $post->post_title, $post->post_type ); |
|
| 53 | 53 | |
| 54 | 54 | |
| 55 | - var_dump( $uri ); |
|
| 55 | + var_dump( $uri ); |
|
| 56 | 56 | |
| 57 | - wp_send_json_success( array( |
|
| 58 | - 'uri' => $uri, |
|
| 59 | - 'post_title' => sprintf( '%s (%s)', $post->post_title, mb_detect_encoding( $post->post_title ) ), |
|
| 60 | - 'post_title_ascii' => mb_convert_encoding( $post->post_title, 'ASCII' ), |
|
| 61 | - 'build_uri' => $build_uri, |
|
| 62 | - 'build_uri_convert' => mb_convert_encoding( $build_uri, 'ASCII' ), |
|
| 63 | - ) ); |
|
| 57 | + wp_send_json_success( array( |
|
| 58 | + 'uri' => $uri, |
|
| 59 | + 'post_title' => sprintf( '%s (%s)', $post->post_title, mb_detect_encoding( $post->post_title ) ), |
|
| 60 | + 'post_title_ascii' => mb_convert_encoding( $post->post_title, 'ASCII' ), |
|
| 61 | + 'build_uri' => $build_uri, |
|
| 62 | + 'build_uri_convert' => mb_convert_encoding( $build_uri, 'ASCII' ), |
|
| 63 | + ) ); |
|
| 64 | 64 | |
| 65 | - } |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | 67 | } |
| 68 | 68 | \ No newline at end of file |
@@ -29,38 +29,38 @@ |
||
| 29 | 29 | * |
| 30 | 30 | * @param Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
| 31 | 31 | */ |
| 32 | - public function __construct( $entity_service ) { |
|
| 32 | + public function __construct($entity_service) { |
|
| 33 | 33 | |
| 34 | 34 | $this->entity_service = $entity_service; |
| 35 | 35 | |
| 36 | - add_action( 'wp_ajax_wl_dump_uri', array( $this, 'dump_uri' ) ); |
|
| 36 | + add_action('wp_ajax_wl_dump_uri', array($this, 'dump_uri')); |
|
| 37 | 37 | |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | public function dump_uri() { |
| 41 | 41 | |
| 42 | - if ( ! isset( $_GET['id'] ) ) { |
|
| 43 | - wp_send_json_error( 'id not set' ); |
|
| 42 | + if ( ! isset($_GET['id'])) { |
|
| 43 | + wp_send_json_error('id not set'); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | $post_id = $_GET['id']; |
| 47 | 47 | |
| 48 | - $post = get_post( $post_id ); |
|
| 48 | + $post = get_post($post_id); |
|
| 49 | 49 | |
| 50 | - $uri = $this->entity_service->get_uri( $post_id ); |
|
| 51 | - $encoding = mb_detect_encoding( $uri ); |
|
| 52 | - $build_uri = $this->entity_service->build_uri( $post->post_title, $post->post_type ); |
|
| 50 | + $uri = $this->entity_service->get_uri($post_id); |
|
| 51 | + $encoding = mb_detect_encoding($uri); |
|
| 52 | + $build_uri = $this->entity_service->build_uri($post->post_title, $post->post_type); |
|
| 53 | 53 | |
| 54 | 54 | |
| 55 | - var_dump( $uri ); |
|
| 55 | + var_dump($uri); |
|
| 56 | 56 | |
| 57 | - wp_send_json_success( array( |
|
| 57 | + wp_send_json_success(array( |
|
| 58 | 58 | 'uri' => $uri, |
| 59 | - 'post_title' => sprintf( '%s (%s)', $post->post_title, mb_detect_encoding( $post->post_title ) ), |
|
| 60 | - 'post_title_ascii' => mb_convert_encoding( $post->post_title, 'ASCII' ), |
|
| 59 | + 'post_title' => sprintf('%s (%s)', $post->post_title, mb_detect_encoding($post->post_title)), |
|
| 60 | + 'post_title_ascii' => mb_convert_encoding($post->post_title, 'ASCII'), |
|
| 61 | 61 | 'build_uri' => $build_uri, |
| 62 | - 'build_uri_convert' => mb_convert_encoding( $build_uri, 'ASCII' ), |
|
| 63 | - ) ); |
|
| 62 | + 'build_uri_convert' => mb_convert_encoding($build_uri, 'ASCII'), |
|
| 63 | + )); |
|
| 64 | 64 | |
| 65 | 65 | } |
| 66 | 66 | |
@@ -11,109 +11,109 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class Wordlift_Uri_Service { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * The title regex to sanitize titles in paths. |
|
| 16 | - * |
|
| 17 | - * According to RFC2396 (http://www.ietf.org/rfc/rfc2396.txt) these characters are reserved: |
|
| 18 | - * ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | |
|
| 19 | - * "$" | "," |
|
| 20 | - * |
|
| 21 | - * We also remove the space and the UTF-8 BOM sequence. |
|
| 22 | - * |
|
| 23 | - * @since 3.7.1 |
|
| 24 | - */ |
|
| 25 | - const INVALID_CHARACTERS = "/[ ;\\/?:@&=\\+\\\$,]|(?:\\xEF\\xBB\\xBF)/"; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * A {@link Wordlift_Log_Service} instance. |
|
| 29 | - * |
|
| 30 | - * @since 3.6.0 |
|
| 31 | - * @access private |
|
| 32 | - * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 33 | - */ |
|
| 34 | - private $log; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * The global WordPress database connection. |
|
| 38 | - * |
|
| 39 | - * @since 3.6.0 |
|
| 40 | - * @access private |
|
| 41 | - * @var \wpdb $wpdb The global WordPress database connection. |
|
| 42 | - */ |
|
| 43 | - private $wpdb; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * The {@link Wordlift_Uri_Service} singleton instance. |
|
| 47 | - * |
|
| 48 | - * @since 3.7.2 |
|
| 49 | - * @access private |
|
| 50 | - * @var \Wordlift_Uri_Service The {@link Wordlift_Uri_Service} singleton instance. |
|
| 51 | - */ |
|
| 52 | - private static $instance; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * Create an instance of Wordlift_Uri_Service. |
|
| 56 | - * |
|
| 57 | - * @since 3.6.0 |
|
| 58 | - * |
|
| 59 | - * @param \wpdb $wpdb The global WordPress database connection. |
|
| 60 | - */ |
|
| 61 | - public function __construct( $wpdb ) { |
|
| 62 | - |
|
| 63 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Uri_Service' ); |
|
| 64 | - |
|
| 65 | - $this->wpdb = $wpdb; |
|
| 66 | - |
|
| 67 | - self::$instance = $this; |
|
| 68 | - |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * Get the {@link Wordlift_Uri_Service} singleton instance. |
|
| 73 | - * |
|
| 74 | - * @since 3.7.2 |
|
| 75 | - * @return \Wordlift_Uri_Service The {@link Wordlift_Uri_Service} singleton instance. |
|
| 76 | - */ |
|
| 77 | - public static function get_instance() { |
|
| 78 | - |
|
| 79 | - return self::$instance; |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * Delete all generated URIs from the database. |
|
| 84 | - * |
|
| 85 | - * @since 3.6.0 |
|
| 86 | - */ |
|
| 87 | - public function delete_all() { |
|
| 88 | - |
|
| 89 | - // Delete URIs associated with posts/entities. |
|
| 90 | - $this->wpdb->delete( $this->wpdb->postmeta, array( 'meta_key' => 'entity_url' ) ); |
|
| 91 | - |
|
| 92 | - // Delete URIs associated with authors. |
|
| 93 | - $this->wpdb->delete( $this->wpdb->usermeta, array( 'meta_key' => '_wl_uri' ) ); |
|
| 94 | - |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * Sanitizes an URI path by replacing the non allowed characters with an underscore. |
|
| 99 | - * |
|
| 100 | - * @since 3.7.2 |
|
| 101 | - * @uses sanitize_title() to manage not ASCII chars |
|
| 102 | - * |
|
| 103 | - * @see https://codex.wordpress.org/Function_Reference/sanitize_title |
|
| 104 | - * |
|
| 105 | - * @param string $path The path to sanitize. |
|
| 106 | - * @param string $char The replacement character (by default an underscore). |
|
| 107 | - * |
|
| 108 | - * @return string The sanitized path. |
|
| 109 | - */ |
|
| 110 | - public function sanitize_path( $path, $char = '_' ) { |
|
| 111 | - |
|
| 112 | - // Ensure the path is ASCII. |
|
| 113 | - // see https://github.com/insideout10/wordlift-plugin/issues/386 |
|
| 14 | + /** |
|
| 15 | + * The title regex to sanitize titles in paths. |
|
| 16 | + * |
|
| 17 | + * According to RFC2396 (http://www.ietf.org/rfc/rfc2396.txt) these characters are reserved: |
|
| 18 | + * ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | |
|
| 19 | + * "$" | "," |
|
| 20 | + * |
|
| 21 | + * We also remove the space and the UTF-8 BOM sequence. |
|
| 22 | + * |
|
| 23 | + * @since 3.7.1 |
|
| 24 | + */ |
|
| 25 | + const INVALID_CHARACTERS = "/[ ;\\/?:@&=\\+\\\$,]|(?:\\xEF\\xBB\\xBF)/"; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * A {@link Wordlift_Log_Service} instance. |
|
| 29 | + * |
|
| 30 | + * @since 3.6.0 |
|
| 31 | + * @access private |
|
| 32 | + * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 33 | + */ |
|
| 34 | + private $log; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * The global WordPress database connection. |
|
| 38 | + * |
|
| 39 | + * @since 3.6.0 |
|
| 40 | + * @access private |
|
| 41 | + * @var \wpdb $wpdb The global WordPress database connection. |
|
| 42 | + */ |
|
| 43 | + private $wpdb; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * The {@link Wordlift_Uri_Service} singleton instance. |
|
| 47 | + * |
|
| 48 | + * @since 3.7.2 |
|
| 49 | + * @access private |
|
| 50 | + * @var \Wordlift_Uri_Service The {@link Wordlift_Uri_Service} singleton instance. |
|
| 51 | + */ |
|
| 52 | + private static $instance; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * Create an instance of Wordlift_Uri_Service. |
|
| 56 | + * |
|
| 57 | + * @since 3.6.0 |
|
| 58 | + * |
|
| 59 | + * @param \wpdb $wpdb The global WordPress database connection. |
|
| 60 | + */ |
|
| 61 | + public function __construct( $wpdb ) { |
|
| 62 | + |
|
| 63 | + $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Uri_Service' ); |
|
| 64 | + |
|
| 65 | + $this->wpdb = $wpdb; |
|
| 66 | + |
|
| 67 | + self::$instance = $this; |
|
| 68 | + |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * Get the {@link Wordlift_Uri_Service} singleton instance. |
|
| 73 | + * |
|
| 74 | + * @since 3.7.2 |
|
| 75 | + * @return \Wordlift_Uri_Service The {@link Wordlift_Uri_Service} singleton instance. |
|
| 76 | + */ |
|
| 77 | + public static function get_instance() { |
|
| 78 | + |
|
| 79 | + return self::$instance; |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * Delete all generated URIs from the database. |
|
| 84 | + * |
|
| 85 | + * @since 3.6.0 |
|
| 86 | + */ |
|
| 87 | + public function delete_all() { |
|
| 88 | + |
|
| 89 | + // Delete URIs associated with posts/entities. |
|
| 90 | + $this->wpdb->delete( $this->wpdb->postmeta, array( 'meta_key' => 'entity_url' ) ); |
|
| 91 | + |
|
| 92 | + // Delete URIs associated with authors. |
|
| 93 | + $this->wpdb->delete( $this->wpdb->usermeta, array( 'meta_key' => '_wl_uri' ) ); |
|
| 94 | + |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * Sanitizes an URI path by replacing the non allowed characters with an underscore. |
|
| 99 | + * |
|
| 100 | + * @since 3.7.2 |
|
| 101 | + * @uses sanitize_title() to manage not ASCII chars |
|
| 102 | + * |
|
| 103 | + * @see https://codex.wordpress.org/Function_Reference/sanitize_title |
|
| 104 | + * |
|
| 105 | + * @param string $path The path to sanitize. |
|
| 106 | + * @param string $char The replacement character (by default an underscore). |
|
| 107 | + * |
|
| 108 | + * @return string The sanitized path. |
|
| 109 | + */ |
|
| 110 | + public function sanitize_path( $path, $char = '_' ) { |
|
| 111 | + |
|
| 112 | + // Ensure the path is ASCII. |
|
| 113 | + // see https://github.com/insideout10/wordlift-plugin/issues/386 |
|
| 114 | 114 | // $path_ascii = mb_convert_encoding( $path, 'ASCII' ); |
| 115 | 115 | |
| 116 | - return sanitize_title( preg_replace( self::INVALID_CHARACTERS, $char, stripslashes( $path ) ) ); |
|
| 117 | - } |
|
| 116 | + return sanitize_title( preg_replace( self::INVALID_CHARACTERS, $char, stripslashes( $path ) ) ); |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | 119 | } |
@@ -58,9 +58,9 @@ discard block |
||
| 58 | 58 | * |
| 59 | 59 | * @param \wpdb $wpdb The global WordPress database connection. |
| 60 | 60 | */ |
| 61 | - public function __construct( $wpdb ) { |
|
| 61 | + public function __construct($wpdb) { |
|
| 62 | 62 | |
| 63 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Uri_Service' ); |
|
| 63 | + $this->log = Wordlift_Log_Service::get_logger('Wordlift_Uri_Service'); |
|
| 64 | 64 | |
| 65 | 65 | $this->wpdb = $wpdb; |
| 66 | 66 | |
@@ -87,10 +87,10 @@ discard block |
||
| 87 | 87 | public function delete_all() { |
| 88 | 88 | |
| 89 | 89 | // Delete URIs associated with posts/entities. |
| 90 | - $this->wpdb->delete( $this->wpdb->postmeta, array( 'meta_key' => 'entity_url' ) ); |
|
| 90 | + $this->wpdb->delete($this->wpdb->postmeta, array('meta_key' => 'entity_url')); |
|
| 91 | 91 | |
| 92 | 92 | // Delete URIs associated with authors. |
| 93 | - $this->wpdb->delete( $this->wpdb->usermeta, array( 'meta_key' => '_wl_uri' ) ); |
|
| 93 | + $this->wpdb->delete($this->wpdb->usermeta, array('meta_key' => '_wl_uri')); |
|
| 94 | 94 | |
| 95 | 95 | } |
| 96 | 96 | |
@@ -107,13 +107,13 @@ discard block |
||
| 107 | 107 | * |
| 108 | 108 | * @return string The sanitized path. |
| 109 | 109 | */ |
| 110 | - public function sanitize_path( $path, $char = '_' ) { |
|
| 110 | + public function sanitize_path($path, $char = '_') { |
|
| 111 | 111 | |
| 112 | 112 | // Ensure the path is ASCII. |
| 113 | 113 | // see https://github.com/insideout10/wordlift-plugin/issues/386 |
| 114 | 114 | // $path_ascii = mb_convert_encoding( $path, 'ASCII' ); |
| 115 | 115 | |
| 116 | - return sanitize_title( preg_replace( self::INVALID_CHARACTERS, $char, stripslashes( $path ) ) ); |
|
| 116 | + return sanitize_title(preg_replace(self::INVALID_CHARACTERS, $char, stripslashes($path))); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | } |