@@ -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. |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | function wl_write_log( $log ) { |
| 50 | 50 | |
| 51 | - Wordlift_Log_Service::get_instance()->info( $log ); |
|
| 51 | + Wordlift_Log_Service::get_instance()->info( $log ); |
|
| 52 | 52 | |
| 53 | 53 | } |
| 54 | 54 | |
@@ -64,20 +64,20 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | function wl_write_log_handler( $log, $caller = null ) { |
| 66 | 66 | |
| 67 | - global $wl_logger; |
|
| 67 | + global $wl_logger; |
|
| 68 | 68 | |
| 69 | - if ( true === WP_DEBUG ) { |
|
| 69 | + if ( true === WP_DEBUG ) { |
|
| 70 | 70 | |
| 71 | - $message = ( isset( $caller ) ? sprintf( '[%-40.40s] ', $caller ) : '' ) . |
|
| 72 | - ( is_array( $log ) || is_object( $log ) ? print_r( $log, true ) : wl_write_log_hide_key( $log ) ); |
|
| 71 | + $message = ( isset( $caller ) ? sprintf( '[%-40.40s] ', $caller ) : '' ) . |
|
| 72 | + ( is_array( $log ) || is_object( $log ) ? print_r( $log, true ) : wl_write_log_hide_key( $log ) ); |
|
| 73 | 73 | |
| 74 | - if ( isset( $wl_logger ) ) { |
|
| 75 | - $wl_logger->info( $message ); |
|
| 76 | - } else { |
|
| 77 | - error_log( $message ); |
|
| 78 | - } |
|
| 74 | + if ( isset( $wl_logger ) ) { |
|
| 75 | + $wl_logger->info( $message ); |
|
| 76 | + } else { |
|
| 77 | + error_log( $message ); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - } |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | 82 | } |
| 83 | 83 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | function wl_write_log_hide_key( $text ) { |
| 96 | 96 | |
| 97 | - return str_ireplace( wl_configuration_get_key(), '<hidden>', $text ); |
|
| 97 | + return str_ireplace( wl_configuration_get_key(), '<hidden>', $text ); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -106,10 +106,10 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | function wl_queue_sparql_update_query( $query ) { |
| 108 | 108 | |
| 109 | - $filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql'; |
|
| 110 | - file_put_contents( $filename, $query . "\n", FILE_APPEND ); |
|
| 109 | + $filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql'; |
|
| 110 | + file_put_contents( $filename, $query . "\n", FILE_APPEND ); |
|
| 111 | 111 | |
| 112 | - wl_write_log( "wl_queue_sparql_update_query [ filename :: $filename ]" ); |
|
| 112 | + wl_write_log( "wl_queue_sparql_update_query [ filename :: $filename ]" ); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -119,28 +119,28 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | function wl_execute_saved_sparql_update_query( $request_id ) { |
| 121 | 121 | |
| 122 | - $filename = WL_TEMP_DIR . $request_id . '.sparql'; |
|
| 122 | + $filename = WL_TEMP_DIR . $request_id . '.sparql'; |
|
| 123 | 123 | |
| 124 | - // If the file doesn't exist, exit. |
|
| 125 | - if ( ! file_exists( $filename ) ) { |
|
| 126 | - wl_write_log( "wl_execute_saved_sparql_update_query : file doesn't exist [ filename :: $filename ]" ); |
|
| 124 | + // If the file doesn't exist, exit. |
|
| 125 | + if ( ! file_exists( $filename ) ) { |
|
| 126 | + wl_write_log( "wl_execute_saved_sparql_update_query : file doesn't exist [ filename :: $filename ]" ); |
|
| 127 | 127 | |
| 128 | - return; |
|
| 129 | - } |
|
| 128 | + return; |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | - wl_write_log( "wl_execute_saved_sparql_update_query [ filename :: $filename ]" ); |
|
| 131 | + wl_write_log( "wl_execute_saved_sparql_update_query [ filename :: $filename ]" ); |
|
| 132 | 132 | |
| 133 | - // Get the query saved in the file. |
|
| 134 | - $query = file_get_contents( $filename ); |
|
| 133 | + // Get the query saved in the file. |
|
| 134 | + $query = file_get_contents( $filename ); |
|
| 135 | 135 | |
| 136 | - // Execute the SPARQL query. |
|
| 137 | - rl_execute_sparql_update_query( $query, false ); |
|
| 136 | + // Execute the SPARQL query. |
|
| 137 | + rl_execute_sparql_update_query( $query, false ); |
|
| 138 | 138 | |
| 139 | - // Reindex the triple store. |
|
| 140 | - wordlift_reindex_triple_store(); |
|
| 139 | + // Reindex the triple store. |
|
| 140 | + wordlift_reindex_triple_store(); |
|
| 141 | 141 | |
| 142 | - // Delete the temporary file. |
|
| 143 | - unlink( $filename ); |
|
| 142 | + // Delete the temporary file. |
|
| 143 | + unlink( $filename ); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | add_action( 'wl_execute_saved_sparql_update_query', 'wl_execute_saved_sparql_update_query', 10, 1 ); |
@@ -150,21 +150,21 @@ discard block |
||
| 150 | 150 | * see http://vip.wordpress.com/documentation/register-additional-html-attributes-for-tinymce-and-wp-kses/ |
| 151 | 151 | */ |
| 152 | 152 | function wordlift_allowed_post_tags() { |
| 153 | - global $allowedposttags; |
|
| 154 | - |
|
| 155 | - $tags = array( 'span' ); |
|
| 156 | - $new_attributes = array( |
|
| 157 | - 'itemscope' => array(), |
|
| 158 | - 'itemtype' => array(), |
|
| 159 | - 'itemprop' => array(), |
|
| 160 | - 'itemid' => array(), |
|
| 161 | - ); |
|
| 162 | - |
|
| 163 | - foreach ( $tags as $tag ) { |
|
| 164 | - if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) { |
|
| 165 | - $allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes ); |
|
| 166 | - } |
|
| 167 | - } |
|
| 153 | + global $allowedposttags; |
|
| 154 | + |
|
| 155 | + $tags = array( 'span' ); |
|
| 156 | + $new_attributes = array( |
|
| 157 | + 'itemscope' => array(), |
|
| 158 | + 'itemtype' => array(), |
|
| 159 | + 'itemprop' => array(), |
|
| 160 | + 'itemid' => array(), |
|
| 161 | + ); |
|
| 162 | + |
|
| 163 | + foreach ( $tags as $tag ) { |
|
| 164 | + if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) { |
|
| 165 | + $allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes ); |
|
| 166 | + } |
|
| 167 | + } |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | // init process for button control |
@@ -179,28 +179,28 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | function wordlift_admin_enqueue_scripts() { |
| 181 | 181 | |
| 182 | - // Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/) |
|
| 183 | - wp_enqueue_script( 'wpdialogs' ); |
|
| 184 | - wp_enqueue_style( 'wp-jquery-ui-dialog' ); |
|
| 182 | + // Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/) |
|
| 183 | + wp_enqueue_script( 'wpdialogs' ); |
|
| 184 | + wp_enqueue_style( 'wp-jquery-ui-dialog' ); |
|
| 185 | 185 | |
| 186 | - wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css' ); |
|
| 186 | + wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css' ); |
|
| 187 | 187 | |
| 188 | - wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
| 189 | - wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' ); |
|
| 190 | - wp_enqueue_script( 'angularjs-geolocation', plugin_dir_url( __FILE__ ) . '/bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js' ); |
|
| 191 | - wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js' ); |
|
| 192 | - wp_enqueue_script( 'angularjs-animate', 'https://code.angularjs.org/1.3.11/angular-animate.min.js' ); |
|
| 188 | + wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
| 189 | + wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' ); |
|
| 190 | + wp_enqueue_script( 'angularjs-geolocation', plugin_dir_url( __FILE__ ) . '/bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js' ); |
|
| 191 | + wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js' ); |
|
| 192 | + wp_enqueue_script( 'angularjs-animate', 'https://code.angularjs.org/1.3.11/angular-animate.min.js' ); |
|
| 193 | 193 | |
| 194 | - // Disable auto-save for custom entity posts only |
|
| 195 | - if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) { |
|
| 196 | - wp_dequeue_script( 'autosave' ); |
|
| 197 | - } |
|
| 194 | + // Disable auto-save for custom entity posts only |
|
| 195 | + if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) { |
|
| 196 | + wp_dequeue_script( 'autosave' ); |
|
| 197 | + } |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | add_action( 'admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts' ); |
| 201 | 201 | |
| 202 | 202 | function wl_enqueue_scripts() { |
| 203 | - wp_enqueue_style( 'wordlift-ui', plugin_dir_url( __FILE__ ) . 'css/wordlift-ui.min.css' ); |
|
| 203 | + wp_enqueue_style( 'wordlift-ui', plugin_dir_url( __FILE__ ) . 'css/wordlift-ui.min.css' ); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | add_action( 'wp_enqueue_scripts', 'wl_enqueue_scripts' ); |
@@ -215,18 +215,18 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | function wordlift_allowed_html( $allowedtags, $context ) { |
| 217 | 217 | |
| 218 | - if ( 'post' !== $context ) { |
|
| 219 | - return $allowedtags; |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - return array_merge_recursive( $allowedtags, array( |
|
| 223 | - 'span' => array( |
|
| 224 | - 'itemscope' => true, |
|
| 225 | - 'itemtype' => true, |
|
| 226 | - 'itemid' => true, |
|
| 227 | - 'itemprop' => true, |
|
| 228 | - ), |
|
| 229 | - ) ); |
|
| 218 | + if ( 'post' !== $context ) { |
|
| 219 | + return $allowedtags; |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + return array_merge_recursive( $allowedtags, array( |
|
| 223 | + 'span' => array( |
|
| 224 | + 'itemscope' => true, |
|
| 225 | + 'itemtype' => true, |
|
| 226 | + 'itemid' => true, |
|
| 227 | + 'itemprop' => true, |
|
| 228 | + ), |
|
| 229 | + ) ); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | add_filter( 'wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2 ); |
@@ -240,16 +240,16 @@ discard block |
||
| 240 | 240 | */ |
| 241 | 241 | function wl_get_coordinates( $post_id ) { |
| 242 | 242 | |
| 243 | - $latitude = wl_schema_get_value( $post_id, 'latitude' ); |
|
| 244 | - $longitude = wl_schema_get_value( $post_id, 'longitude' ); |
|
| 243 | + $latitude = wl_schema_get_value( $post_id, 'latitude' ); |
|
| 244 | + $longitude = wl_schema_get_value( $post_id, 'longitude' ); |
|
| 245 | 245 | |
| 246 | - // DO NOT set latitude/longitude to 0/0 as default values. It's a specific |
|
| 247 | - // place on the globe:"The zero/zero point of this system is located in the |
|
| 248 | - // Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana." |
|
| 249 | - return array( |
|
| 250 | - 'latitude' => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '', |
|
| 251 | - 'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '', |
|
| 252 | - ); |
|
| 246 | + // DO NOT set latitude/longitude to 0/0 as default values. It's a specific |
|
| 247 | + // place on the globe:"The zero/zero point of this system is located in the |
|
| 248 | + // Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana." |
|
| 249 | + return array( |
|
| 250 | + 'latitude' => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '', |
|
| 251 | + 'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '', |
|
| 252 | + ); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | /** |
@@ -261,13 +261,13 @@ discard block |
||
| 261 | 261 | */ |
| 262 | 262 | function wl_get_post_modified_time( $post ) { |
| 263 | 263 | |
| 264 | - $date_modified = get_post_modified_time( 'c', true, $post ); |
|
| 264 | + $date_modified = get_post_modified_time( 'c', true, $post ); |
|
| 265 | 265 | |
| 266 | - if ( '-' === substr( $date_modified, 0, 1 ) ) { |
|
| 267 | - return get_the_time( 'c', $post ); |
|
| 268 | - } |
|
| 266 | + if ( '-' === substr( $date_modified, 0, 1 ) ) { |
|
| 267 | + return get_the_time( 'c', $post ); |
|
| 268 | + } |
|
| 269 | 269 | |
| 270 | - return $date_modified; |
|
| 270 | + return $date_modified; |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | /** |
@@ -279,40 +279,40 @@ discard block |
||
| 279 | 279 | */ |
| 280 | 280 | function wl_get_image_urls( $post_id ) { |
| 281 | 281 | |
| 282 | - // If there is a featured image it has the priority. |
|
| 283 | - $featured_image_id = get_post_thumbnail_id( $post_id ); |
|
| 284 | - if ( is_numeric( $featured_image_id ) ) { |
|
| 285 | - $image_url = wp_get_attachment_url( $featured_image_id ); |
|
| 282 | + // If there is a featured image it has the priority. |
|
| 283 | + $featured_image_id = get_post_thumbnail_id( $post_id ); |
|
| 284 | + if ( is_numeric( $featured_image_id ) ) { |
|
| 285 | + $image_url = wp_get_attachment_url( $featured_image_id ); |
|
| 286 | 286 | |
| 287 | - return array( $image_url ); |
|
| 288 | - } |
|
| 287 | + return array( $image_url ); |
|
| 288 | + } |
|
| 289 | 289 | |
| 290 | - $images = get_children( array( |
|
| 291 | - 'post_parent' => $post_id, |
|
| 292 | - 'post_type' => 'attachment', |
|
| 293 | - 'post_mime_type' => 'image', |
|
| 294 | - ) ); |
|
| 290 | + $images = get_children( array( |
|
| 291 | + 'post_parent' => $post_id, |
|
| 292 | + 'post_type' => 'attachment', |
|
| 293 | + 'post_mime_type' => 'image', |
|
| 294 | + ) ); |
|
| 295 | 295 | |
| 296 | - // Return an empty array if no image is found. |
|
| 297 | - if ( empty( $images ) ) { |
|
| 298 | - return array(); |
|
| 299 | - } |
|
| 296 | + // Return an empty array if no image is found. |
|
| 297 | + if ( empty( $images ) ) { |
|
| 298 | + return array(); |
|
| 299 | + } |
|
| 300 | 300 | |
| 301 | - // Prepare the return array. |
|
| 302 | - $image_urls = array(); |
|
| 301 | + // Prepare the return array. |
|
| 302 | + $image_urls = array(); |
|
| 303 | 303 | |
| 304 | - // Collect the URLs. |
|
| 305 | - foreach ( $images as $attachment_id => $attachment ) { |
|
| 306 | - $image_url = wp_get_attachment_url( $attachment_id ); |
|
| 307 | - // Ensure the URL isn't collected already. |
|
| 308 | - if ( ! in_array( $image_url, $image_urls ) ) { |
|
| 309 | - array_push( $image_urls, $image_url ); |
|
| 310 | - } |
|
| 311 | - } |
|
| 304 | + // Collect the URLs. |
|
| 305 | + foreach ( $images as $attachment_id => $attachment ) { |
|
| 306 | + $image_url = wp_get_attachment_url( $attachment_id ); |
|
| 307 | + // Ensure the URL isn't collected already. |
|
| 308 | + if ( ! in_array( $image_url, $image_urls ) ) { |
|
| 309 | + array_push( $image_urls, $image_url ); |
|
| 310 | + } |
|
| 311 | + } |
|
| 312 | 312 | |
| 313 | - // wl_write_log( "wl_get_image_urls [ post id :: $post_id ][ image urls count :: " . count( $image_urls ) . " ]" ); |
|
| 313 | + // wl_write_log( "wl_get_image_urls [ post id :: $post_id ][ image urls count :: " . count( $image_urls ) . " ]" ); |
|
| 314 | 314 | |
| 315 | - return $image_urls; |
|
| 315 | + return $image_urls; |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | /** |
@@ -325,19 +325,19 @@ discard block |
||
| 325 | 325 | */ |
| 326 | 326 | function wl_get_sparql_images( $uri, $post_id ) { |
| 327 | 327 | |
| 328 | - $sparql = ''; |
|
| 328 | + $sparql = ''; |
|
| 329 | 329 | |
| 330 | - // Get the escaped URI. |
|
| 331 | - $uri_e = esc_html( $uri ); |
|
| 330 | + // Get the escaped URI. |
|
| 331 | + $uri_e = esc_html( $uri ); |
|
| 332 | 332 | |
| 333 | - // Add SPARQL stmts to write the schema:image. |
|
| 334 | - $image_urls = wl_get_image_urls( $post_id ); |
|
| 335 | - foreach ( $image_urls as $image_url ) { |
|
| 336 | - $image_url_esc = wl_sparql_escape_uri( $image_url ); |
|
| 337 | - $sparql .= " <$uri_e> schema:image <$image_url_esc> . \n"; |
|
| 338 | - } |
|
| 333 | + // Add SPARQL stmts to write the schema:image. |
|
| 334 | + $image_urls = wl_get_image_urls( $post_id ); |
|
| 335 | + foreach ( $image_urls as $image_url ) { |
|
| 336 | + $image_url_esc = wl_sparql_escape_uri( $image_url ); |
|
| 337 | + $sparql .= " <$uri_e> schema:image <$image_url_esc> . \n"; |
|
| 338 | + } |
|
| 339 | 339 | |
| 340 | - return $sparql; |
|
| 340 | + return $sparql; |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | /** |
@@ -350,24 +350,24 @@ discard block |
||
| 350 | 350 | */ |
| 351 | 351 | function wl_get_attachment_for_source_url( $parent_post_id, $source_url ) { |
| 352 | 352 | |
| 353 | - // wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" ); |
|
| 353 | + // wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" ); |
|
| 354 | 354 | |
| 355 | - $posts = get_posts( array( |
|
| 356 | - 'post_type' => 'attachment', |
|
| 357 | - 'posts_per_page' => 1, |
|
| 358 | - 'post_status' => 'any', |
|
| 359 | - 'post_parent' => $parent_post_id, |
|
| 360 | - 'meta_key' => 'wl_source_url', |
|
| 361 | - 'meta_value' => $source_url, |
|
| 362 | - ) ); |
|
| 355 | + $posts = get_posts( array( |
|
| 356 | + 'post_type' => 'attachment', |
|
| 357 | + 'posts_per_page' => 1, |
|
| 358 | + 'post_status' => 'any', |
|
| 359 | + 'post_parent' => $parent_post_id, |
|
| 360 | + 'meta_key' => 'wl_source_url', |
|
| 361 | + 'meta_value' => $source_url, |
|
| 362 | + ) ); |
|
| 363 | 363 | |
| 364 | - // Return the found post. |
|
| 365 | - if ( 1 === count( $posts ) ) { |
|
| 366 | - return $posts[0]; |
|
| 367 | - } |
|
| 364 | + // Return the found post. |
|
| 365 | + if ( 1 === count( $posts ) ) { |
|
| 366 | + return $posts[0]; |
|
| 367 | + } |
|
| 368 | 368 | |
| 369 | - // Return null. |
|
| 370 | - return null; |
|
| 369 | + // Return null. |
|
| 370 | + return null; |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | /** |
@@ -378,8 +378,8 @@ discard block |
||
| 378 | 378 | */ |
| 379 | 379 | function wl_set_source_url( $post_id, $source_url ) { |
| 380 | 380 | |
| 381 | - delete_post_meta( $post_id, 'wl_source_url' ); |
|
| 382 | - add_post_meta( $post_id, 'wl_source_url', $source_url ); |
|
| 381 | + delete_post_meta( $post_id, 'wl_source_url' ); |
|
| 382 | + add_post_meta( $post_id, 'wl_source_url', $source_url ); |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | |
@@ -397,61 +397,61 @@ discard block |
||
| 397 | 397 | */ |
| 398 | 398 | function wl_flush_rewrite_rules_hard( $hard ) { |
| 399 | 399 | |
| 400 | - // If WL is not yet configured, we cannot perform any update, so we exit. |
|
| 401 | - if ( '' === wl_configuration_get_key() ) { |
|
| 402 | - return; |
|
| 403 | - } |
|
| 400 | + // If WL is not yet configured, we cannot perform any update, so we exit. |
|
| 401 | + if ( '' === wl_configuration_get_key() ) { |
|
| 402 | + return; |
|
| 403 | + } |
|
| 404 | 404 | |
| 405 | - // Set the initial offset and limit each call to 100 posts to avoid memory errors. |
|
| 406 | - $offset = 0; |
|
| 407 | - $limit = 100; |
|
| 405 | + // Set the initial offset and limit each call to 100 posts to avoid memory errors. |
|
| 406 | + $offset = 0; |
|
| 407 | + $limit = 100; |
|
| 408 | 408 | |
| 409 | - // Get more posts if the number of returned posts matches the limit. |
|
| 410 | - while ( $limit === ( $posts = get_posts( array( |
|
| 411 | - 'offset' => $offset, |
|
| 412 | - 'numberposts' => $limit, |
|
| 413 | - 'orderby' => 'ID', |
|
| 414 | - 'post_type' => 'any', |
|
| 415 | - 'post_status' => 'publish', |
|
| 416 | - ) ) ) ) { |
|
| 409 | + // Get more posts if the number of returned posts matches the limit. |
|
| 410 | + while ( $limit === ( $posts = get_posts( array( |
|
| 411 | + 'offset' => $offset, |
|
| 412 | + 'numberposts' => $limit, |
|
| 413 | + 'orderby' => 'ID', |
|
| 414 | + 'post_type' => 'any', |
|
| 415 | + 'post_status' => 'publish', |
|
| 416 | + ) ) ) ) { |
|
| 417 | 417 | |
| 418 | - // Holds the delete part of the query. |
|
| 419 | - $delete_query = rl_sparql_prefixes(); |
|
| 418 | + // Holds the delete part of the query. |
|
| 419 | + $delete_query = rl_sparql_prefixes(); |
|
| 420 | 420 | |
| 421 | - // Holds the insert part of the query. |
|
| 422 | - $insert_query = ''; |
|
| 421 | + // Holds the insert part of the query. |
|
| 422 | + $insert_query = ''; |
|
| 423 | 423 | |
| 424 | - // Cycle in each post to build the query. |
|
| 425 | - foreach ( $posts as $post ) { |
|
| 424 | + // Cycle in each post to build the query. |
|
| 425 | + foreach ( $posts as $post ) { |
|
| 426 | 426 | |
| 427 | - // Ignore revisions. |
|
| 428 | - if ( wp_is_post_revision( $post->ID ) ) { |
|
| 429 | - continue; |
|
| 430 | - } |
|
| 427 | + // Ignore revisions. |
|
| 428 | + if ( wp_is_post_revision( $post->ID ) ) { |
|
| 429 | + continue; |
|
| 430 | + } |
|
| 431 | 431 | |
| 432 | - // Get the entity URI. |
|
| 433 | - $s = Wordlift_Sparql_Service::escape_uri( Wordlift_Entity_Service::get_instance() |
|
| 434 | - ->get_uri( $post->ID ) ); |
|
| 432 | + // Get the entity URI. |
|
| 433 | + $s = Wordlift_Sparql_Service::escape_uri( Wordlift_Entity_Service::get_instance() |
|
| 434 | + ->get_uri( $post->ID ) ); |
|
| 435 | 435 | |
| 436 | - // Get the post URL. |
|
| 437 | - // $url = wl_sparql_escape_uri( get_permalink( $post->ID ) ); |
|
| 436 | + // Get the post URL. |
|
| 437 | + // $url = wl_sparql_escape_uri( get_permalink( $post->ID ) ); |
|
| 438 | 438 | |
| 439 | - // Prepare the DELETE and INSERT commands. |
|
| 440 | - $delete_query .= "DELETE { <$s> schema:url ?u . } WHERE { <$s> schema:url ?u . };\n"; |
|
| 439 | + // Prepare the DELETE and INSERT commands. |
|
| 440 | + $delete_query .= "DELETE { <$s> schema:url ?u . } WHERE { <$s> schema:url ?u . };\n"; |
|
| 441 | 441 | |
| 442 | - $insert_query .= Wordlift_Schema_Url_Property_Service::get_instance() |
|
| 443 | - ->get_insert_query( $s, $post->ID ); |
|
| 442 | + $insert_query .= Wordlift_Schema_Url_Property_Service::get_instance() |
|
| 443 | + ->get_insert_query( $s, $post->ID ); |
|
| 444 | 444 | |
| 445 | - } |
|
| 445 | + } |
|
| 446 | 446 | |
| 447 | 447 | |
| 448 | - // Execute the query. |
|
| 449 | - rl_execute_sparql_update_query( $delete_query . $insert_query ); |
|
| 448 | + // Execute the query. |
|
| 449 | + rl_execute_sparql_update_query( $delete_query . $insert_query ); |
|
| 450 | 450 | |
| 451 | - // Advance to the next posts. |
|
| 452 | - $offset += $limit; |
|
| 451 | + // Advance to the next posts. |
|
| 452 | + $offset += $limit; |
|
| 453 | 453 | |
| 454 | - } |
|
| 454 | + } |
|
| 455 | 455 | |
| 456 | 456 | // // Get all published posts. |
| 457 | 457 | // $posts = get_posts( array( |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | */ |
| 478 | 478 | function wl_sanitize_uri_path( $path, $char = '_' ) { |
| 479 | 479 | |
| 480 | - return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char ); |
|
| 480 | + return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char ); |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | /** |
@@ -489,11 +489,11 @@ discard block |
||
| 489 | 489 | */ |
| 490 | 490 | function wl_force_to_array( $value ) { |
| 491 | 491 | |
| 492 | - if ( ! is_array( $value ) ) { |
|
| 493 | - return array( $value ); |
|
| 494 | - } |
|
| 492 | + if ( ! is_array( $value ) ) { |
|
| 493 | + return array( $value ); |
|
| 494 | + } |
|
| 495 | 495 | |
| 496 | - return $value; |
|
| 496 | + return $value; |
|
| 497 | 497 | } |
| 498 | 498 | |
| 499 | 499 | /** |
@@ -501,26 +501,26 @@ discard block |
||
| 501 | 501 | */ |
| 502 | 502 | function wl_shutdown() { |
| 503 | 503 | |
| 504 | - // Get the filename to the temporary SPARQL file. |
|
| 505 | - $filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql'; |
|
| 504 | + // Get the filename to the temporary SPARQL file. |
|
| 505 | + $filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql'; |
|
| 506 | 506 | |
| 507 | - // If WordLift is buffering SPARQL queries, we're admins and a buffer exists, then schedule it. |
|
| 508 | - if ( WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING && is_admin() && file_exists( $filename ) ) { |
|
| 507 | + // If WordLift is buffering SPARQL queries, we're admins and a buffer exists, then schedule it. |
|
| 508 | + if ( WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING && is_admin() && file_exists( $filename ) ) { |
|
| 509 | 509 | |
| 510 | - // The request ID. |
|
| 511 | - $args = array( WL_REQUEST_ID ); |
|
| 510 | + // The request ID. |
|
| 511 | + $args = array( WL_REQUEST_ID ); |
|
| 512 | 512 | |
| 513 | - // Schedule the execution of the SPARQL query with the request ID. |
|
| 514 | - wp_schedule_single_event( time(), 'wl_execute_saved_sparql_update_query', $args ); |
|
| 513 | + // Schedule the execution of the SPARQL query with the request ID. |
|
| 514 | + wp_schedule_single_event( time(), 'wl_execute_saved_sparql_update_query', $args ); |
|
| 515 | 515 | |
| 516 | - // Check that the request is scheduled. |
|
| 517 | - $timestamp = wp_next_scheduled( 'wl_execute_saved_sparql_update_query', $args ); |
|
| 516 | + // Check that the request is scheduled. |
|
| 517 | + $timestamp = wp_next_scheduled( 'wl_execute_saved_sparql_update_query', $args ); |
|
| 518 | 518 | |
| 519 | - // Spawn the cron. |
|
| 520 | - spawn_cron(); |
|
| 519 | + // Spawn the cron. |
|
| 520 | + spawn_cron(); |
|
| 521 | 521 | |
| 522 | - wl_write_log( "wl_shutdown [ request id :: " . WL_REQUEST_ID . " ][ timestamp :: $timestamp ]" ); |
|
| 523 | - } |
|
| 522 | + wl_write_log( "wl_shutdown [ request id :: " . WL_REQUEST_ID . " ][ timestamp :: $timestamp ]" ); |
|
| 523 | + } |
|
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | add_action( 'shutdown', 'wl_shutdown' ); |
@@ -534,46 +534,46 @@ discard block |
||
| 534 | 534 | */ |
| 535 | 535 | function wl_replace_item_id_with_uri( $content ) { |
| 536 | 536 | |
| 537 | - // wl_write_log( "wl_replace_item_id_with_uri" ); |
|
| 537 | + // wl_write_log( "wl_replace_item_id_with_uri" ); |
|
| 538 | 538 | |
| 539 | - // Strip slashes, see https://core.trac.wordpress.org/ticket/21767 |
|
| 540 | - $content = stripslashes( $content ); |
|
| 539 | + // Strip slashes, see https://core.trac.wordpress.org/ticket/21767 |
|
| 540 | + $content = stripslashes( $content ); |
|
| 541 | 541 | |
| 542 | - // If any match are found. |
|
| 543 | - $matches = array(); |
|
| 544 | - if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) { |
|
| 542 | + // If any match are found. |
|
| 543 | + $matches = array(); |
|
| 544 | + if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) { |
|
| 545 | 545 | |
| 546 | - foreach ( $matches as $match ) { |
|
| 546 | + foreach ( $matches as $match ) { |
|
| 547 | 547 | |
| 548 | - // Get the item ID. |
|
| 549 | - $item_id = $match[1]; |
|
| 548 | + // Get the item ID. |
|
| 549 | + $item_id = $match[1]; |
|
| 550 | 550 | |
| 551 | - // Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' . |
|
| 552 | - $post = Wordlift_Entity_Service::get_instance() |
|
| 553 | - ->get_entity_post_by_uri( $item_id ); |
|
| 551 | + // Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' . |
|
| 552 | + $post = Wordlift_Entity_Service::get_instance() |
|
| 553 | + ->get_entity_post_by_uri( $item_id ); |
|
| 554 | 554 | |
| 555 | - // If no entity is found, continue to the next one. |
|
| 556 | - if ( null === $post ) { |
|
| 557 | - continue; |
|
| 558 | - } |
|
| 555 | + // If no entity is found, continue to the next one. |
|
| 556 | + if ( null === $post ) { |
|
| 557 | + continue; |
|
| 558 | + } |
|
| 559 | 559 | |
| 560 | - // Get the URI for that post. |
|
| 561 | - $uri = wl_get_entity_uri( $post->ID ); |
|
| 560 | + // Get the URI for that post. |
|
| 561 | + $uri = wl_get_entity_uri( $post->ID ); |
|
| 562 | 562 | |
| 563 | - // wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" ); |
|
| 563 | + // wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" ); |
|
| 564 | 564 | |
| 565 | - // If the item ID and the URI differ, replace the item ID with the URI saved in WordPress. |
|
| 566 | - if ( $item_id !== $uri ) { |
|
| 567 | - $uri_e = esc_html( $uri ); |
|
| 568 | - $content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content ); |
|
| 569 | - } |
|
| 570 | - } |
|
| 571 | - } |
|
| 565 | + // If the item ID and the URI differ, replace the item ID with the URI saved in WordPress. |
|
| 566 | + if ( $item_id !== $uri ) { |
|
| 567 | + $uri_e = esc_html( $uri ); |
|
| 568 | + $content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content ); |
|
| 569 | + } |
|
| 570 | + } |
|
| 571 | + } |
|
| 572 | 572 | |
| 573 | - // Reapply slashes. |
|
| 574 | - $content = addslashes( $content ); |
|
| 573 | + // Reapply slashes. |
|
| 574 | + $content = addslashes( $content ); |
|
| 575 | 575 | |
| 576 | - return $content; |
|
| 576 | + return $content; |
|
| 577 | 577 | } |
| 578 | 578 | |
| 579 | 579 | add_filter( 'content_save_pre', 'wl_replace_item_id_with_uri', 1, 1 ); |
@@ -646,8 +646,8 @@ discard block |
||
| 646 | 646 | * This action is documented in includes/class-wordlift-activator.php |
| 647 | 647 | */ |
| 648 | 648 | function activate_wordlift() { |
| 649 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php'; |
|
| 650 | - Wordlift_Activator::activate(); |
|
| 649 | + require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php'; |
|
| 650 | + Wordlift_Activator::activate(); |
|
| 651 | 651 | } |
| 652 | 652 | |
| 653 | 653 | /** |
@@ -655,8 +655,8 @@ discard block |
||
| 655 | 655 | * This action is documented in includes/class-wordlift-deactivator.php |
| 656 | 656 | */ |
| 657 | 657 | function deactivate_wordlift() { |
| 658 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php'; |
|
| 659 | - Wordlift_Deactivator::deactivate(); |
|
| 658 | + require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php'; |
|
| 659 | + Wordlift_Deactivator::deactivate(); |
|
| 660 | 660 | } |
| 661 | 661 | |
| 662 | 662 | register_activation_hook( __FILE__, 'activate_wordlift' ); |
@@ -679,8 +679,8 @@ discard block |
||
| 679 | 679 | */ |
| 680 | 680 | function run_wordlift() { |
| 681 | 681 | |
| 682 | - $plugin = new Wordlift(); |
|
| 683 | - $plugin->run(); |
|
| 682 | + $plugin = new Wordlift(); |
|
| 683 | + $plugin->run(); |
|
| 684 | 684 | |
| 685 | 685 | } |
| 686 | 686 | |
@@ -25,15 +25,15 @@ 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' ); |
|
| 36 | +require_once('modules/core/wordlift_core.php'); |
|
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * Log to the debug.log file. |
@@ -46,9 +46,9 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | * @param string|mixed $log The log data. |
| 48 | 48 | */ |
| 49 | -function wl_write_log( $log ) { |
|
| 49 | +function wl_write_log($log) { |
|
| 50 | 50 | |
| 51 | - Wordlift_Log_Service::get_instance()->info( $log ); |
|
| 51 | + Wordlift_Log_Service::get_instance()->info($log); |
|
| 52 | 52 | |
| 53 | 53 | } |
| 54 | 54 | |
@@ -62,19 +62,19 @@ discard block |
||
| 62 | 62 | * @param string|array $log The log data. |
| 63 | 63 | * @param string $caller The calling function. |
| 64 | 64 | */ |
| 65 | -function wl_write_log_handler( $log, $caller = null ) { |
|
| 65 | +function wl_write_log_handler($log, $caller = null) { |
|
| 66 | 66 | |
| 67 | 67 | global $wl_logger; |
| 68 | 68 | |
| 69 | - if ( true === WP_DEBUG ) { |
|
| 69 | + if (true === WP_DEBUG) { |
|
| 70 | 70 | |
| 71 | - $message = ( isset( $caller ) ? sprintf( '[%-40.40s] ', $caller ) : '' ) . |
|
| 72 | - ( is_array( $log ) || is_object( $log ) ? print_r( $log, true ) : wl_write_log_hide_key( $log ) ); |
|
| 71 | + $message = (isset($caller) ? sprintf('[%-40.40s] ', $caller) : ''). |
|
| 72 | + (is_array($log) || is_object($log) ? print_r($log, true) : wl_write_log_hide_key($log)); |
|
| 73 | 73 | |
| 74 | - if ( isset( $wl_logger ) ) { |
|
| 75 | - $wl_logger->info( $message ); |
|
| 74 | + if (isset($wl_logger)) { |
|
| 75 | + $wl_logger->info($message); |
|
| 76 | 76 | } else { |
| 77 | - error_log( $message ); |
|
| 77 | + error_log($message); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | } |
@@ -92,9 +92,9 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @return string A text with the key hidden. |
| 94 | 94 | */ |
| 95 | -function wl_write_log_hide_key( $text ) { |
|
| 95 | +function wl_write_log_hide_key($text) { |
|
| 96 | 96 | |
| 97 | - return str_ireplace( wl_configuration_get_key(), '<hidden>', $text ); |
|
| 97 | + return str_ireplace(wl_configuration_get_key(), '<hidden>', $text); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -104,12 +104,12 @@ discard block |
||
| 104 | 104 | * |
| 105 | 105 | * @param string $query A SPARQL query. |
| 106 | 106 | */ |
| 107 | -function wl_queue_sparql_update_query( $query ) { |
|
| 107 | +function wl_queue_sparql_update_query($query) { |
|
| 108 | 108 | |
| 109 | - $filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql'; |
|
| 110 | - file_put_contents( $filename, $query . "\n", FILE_APPEND ); |
|
| 109 | + $filename = WL_TEMP_DIR.WL_REQUEST_ID.'.sparql'; |
|
| 110 | + file_put_contents($filename, $query."\n", FILE_APPEND); |
|
| 111 | 111 | |
| 112 | - wl_write_log( "wl_queue_sparql_update_query [ filename :: $filename ]" ); |
|
| 112 | + wl_write_log("wl_queue_sparql_update_query [ filename :: $filename ]"); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -117,33 +117,33 @@ discard block |
||
| 117 | 117 | * |
| 118 | 118 | * @param int $request_id The request ID. |
| 119 | 119 | */ |
| 120 | -function wl_execute_saved_sparql_update_query( $request_id ) { |
|
| 120 | +function wl_execute_saved_sparql_update_query($request_id) { |
|
| 121 | 121 | |
| 122 | - $filename = WL_TEMP_DIR . $request_id . '.sparql'; |
|
| 122 | + $filename = WL_TEMP_DIR.$request_id.'.sparql'; |
|
| 123 | 123 | |
| 124 | 124 | // If the file doesn't exist, exit. |
| 125 | - if ( ! file_exists( $filename ) ) { |
|
| 126 | - wl_write_log( "wl_execute_saved_sparql_update_query : file doesn't exist [ filename :: $filename ]" ); |
|
| 125 | + if ( ! file_exists($filename)) { |
|
| 126 | + wl_write_log("wl_execute_saved_sparql_update_query : file doesn't exist [ filename :: $filename ]"); |
|
| 127 | 127 | |
| 128 | 128 | return; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - wl_write_log( "wl_execute_saved_sparql_update_query [ filename :: $filename ]" ); |
|
| 131 | + wl_write_log("wl_execute_saved_sparql_update_query [ filename :: $filename ]"); |
|
| 132 | 132 | |
| 133 | 133 | // Get the query saved in the file. |
| 134 | - $query = file_get_contents( $filename ); |
|
| 134 | + $query = file_get_contents($filename); |
|
| 135 | 135 | |
| 136 | 136 | // Execute the SPARQL query. |
| 137 | - rl_execute_sparql_update_query( $query, false ); |
|
| 137 | + rl_execute_sparql_update_query($query, false); |
|
| 138 | 138 | |
| 139 | 139 | // Reindex the triple store. |
| 140 | 140 | wordlift_reindex_triple_store(); |
| 141 | 141 | |
| 142 | 142 | // Delete the temporary file. |
| 143 | - unlink( $filename ); |
|
| 143 | + unlink($filename); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | -add_action( 'wl_execute_saved_sparql_update_query', 'wl_execute_saved_sparql_update_query', 10, 1 ); |
|
| 146 | +add_action('wl_execute_saved_sparql_update_query', 'wl_execute_saved_sparql_update_query', 10, 1); |
|
| 147 | 147 | |
| 148 | 148 | /** |
| 149 | 149 | * Enable microdata schema.org tagging. |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | function wordlift_allowed_post_tags() { |
| 153 | 153 | global $allowedposttags; |
| 154 | 154 | |
| 155 | - $tags = array( 'span' ); |
|
| 155 | + $tags = array('span'); |
|
| 156 | 156 | $new_attributes = array( |
| 157 | 157 | 'itemscope' => array(), |
| 158 | 158 | 'itemtype' => array(), |
@@ -160,9 +160,9 @@ discard block |
||
| 160 | 160 | 'itemid' => array(), |
| 161 | 161 | ); |
| 162 | 162 | |
| 163 | - foreach ( $tags as $tag ) { |
|
| 164 | - if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) { |
|
| 165 | - $allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes ); |
|
| 163 | + foreach ($tags as $tag) { |
|
| 164 | + if (isset($allowedposttags[$tag]) && is_array($allowedposttags[$tag])) { |
|
| 165 | + $allowedposttags[$tag] = array_merge($allowedposttags[$tag], $new_attributes); |
|
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | } |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | //add_action( 'init', 'wordlift_buttonhooks' ); |
| 172 | 172 | |
| 173 | 173 | // add allowed post tags. |
| 174 | -add_action( 'init', 'wordlift_allowed_post_tags' ); |
|
| 174 | +add_action('init', 'wordlift_allowed_post_tags'); |
|
| 175 | 175 | |
| 176 | 176 | |
| 177 | 177 | /** |
@@ -180,30 +180,30 @@ discard block |
||
| 180 | 180 | function wordlift_admin_enqueue_scripts() { |
| 181 | 181 | |
| 182 | 182 | // Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/) |
| 183 | - wp_enqueue_script( 'wpdialogs' ); |
|
| 184 | - wp_enqueue_style( 'wp-jquery-ui-dialog' ); |
|
| 183 | + wp_enqueue_script('wpdialogs'); |
|
| 184 | + wp_enqueue_style('wp-jquery-ui-dialog'); |
|
| 185 | 185 | |
| 186 | - wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css' ); |
|
| 186 | + wp_enqueue_style('wordlift-reloaded', plugin_dir_url(__FILE__).'css/wordlift-reloaded.min.css'); |
|
| 187 | 187 | |
| 188 | - wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
| 189 | - wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' ); |
|
| 190 | - wp_enqueue_script( 'angularjs-geolocation', plugin_dir_url( __FILE__ ) . '/bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js' ); |
|
| 191 | - wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js' ); |
|
| 192 | - wp_enqueue_script( 'angularjs-animate', 'https://code.angularjs.org/1.3.11/angular-animate.min.js' ); |
|
| 188 | + wp_enqueue_script('jquery-ui-autocomplete'); |
|
| 189 | + wp_enqueue_script('angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js'); |
|
| 190 | + wp_enqueue_script('angularjs-geolocation', plugin_dir_url(__FILE__).'/bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js'); |
|
| 191 | + wp_enqueue_script('angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js'); |
|
| 192 | + wp_enqueue_script('angularjs-animate', 'https://code.angularjs.org/1.3.11/angular-animate.min.js'); |
|
| 193 | 193 | |
| 194 | 194 | // Disable auto-save for custom entity posts only |
| 195 | - if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) { |
|
| 196 | - wp_dequeue_script( 'autosave' ); |
|
| 195 | + if (Wordlift_Entity_Service::TYPE_NAME === get_post_type()) { |
|
| 196 | + wp_dequeue_script('autosave'); |
|
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | -add_action( 'admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts' ); |
|
| 200 | +add_action('admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts'); |
|
| 201 | 201 | |
| 202 | 202 | function wl_enqueue_scripts() { |
| 203 | - wp_enqueue_style( 'wordlift-ui', plugin_dir_url( __FILE__ ) . 'css/wordlift-ui.min.css' ); |
|
| 203 | + wp_enqueue_style('wordlift-ui', plugin_dir_url(__FILE__).'css/wordlift-ui.min.css'); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | -add_action( 'wp_enqueue_scripts', 'wl_enqueue_scripts' ); |
|
| 206 | +add_action('wp_enqueue_scripts', 'wl_enqueue_scripts'); |
|
| 207 | 207 | |
| 208 | 208 | /** |
| 209 | 209 | * Hooked to *wp_kses_allowed_html* filter, adds microdata attributes. |
@@ -213,23 +213,23 @@ discard block |
||
| 213 | 213 | * |
| 214 | 214 | * @return array An array which contains allowed microdata attributes. |
| 215 | 215 | */ |
| 216 | -function wordlift_allowed_html( $allowedtags, $context ) { |
|
| 216 | +function wordlift_allowed_html($allowedtags, $context) { |
|
| 217 | 217 | |
| 218 | - if ( 'post' !== $context ) { |
|
| 218 | + if ('post' !== $context) { |
|
| 219 | 219 | return $allowedtags; |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - return array_merge_recursive( $allowedtags, array( |
|
| 222 | + return array_merge_recursive($allowedtags, array( |
|
| 223 | 223 | 'span' => array( |
| 224 | 224 | 'itemscope' => true, |
| 225 | 225 | 'itemtype' => true, |
| 226 | 226 | 'itemid' => true, |
| 227 | 227 | 'itemprop' => true, |
| 228 | 228 | ), |
| 229 | - ) ); |
|
| 229 | + )); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | -add_filter( 'wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2 ); |
|
| 232 | +add_filter('wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2); |
|
| 233 | 233 | |
| 234 | 234 | /** |
| 235 | 235 | * Get the coordinates for the specified post ID. |
@@ -238,17 +238,17 @@ discard block |
||
| 238 | 238 | * |
| 239 | 239 | * @return array|null An array of coordinates or null. |
| 240 | 240 | */ |
| 241 | -function wl_get_coordinates( $post_id ) { |
|
| 241 | +function wl_get_coordinates($post_id) { |
|
| 242 | 242 | |
| 243 | - $latitude = wl_schema_get_value( $post_id, 'latitude' ); |
|
| 244 | - $longitude = wl_schema_get_value( $post_id, 'longitude' ); |
|
| 243 | + $latitude = wl_schema_get_value($post_id, 'latitude'); |
|
| 244 | + $longitude = wl_schema_get_value($post_id, 'longitude'); |
|
| 245 | 245 | |
| 246 | 246 | // DO NOT set latitude/longitude to 0/0 as default values. It's a specific |
| 247 | 247 | // place on the globe:"The zero/zero point of this system is located in the |
| 248 | 248 | // Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana." |
| 249 | 249 | return array( |
| 250 | - 'latitude' => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '', |
|
| 251 | - 'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '', |
|
| 250 | + 'latitude' => isset($latitude[0]) && is_numeric($latitude[0]) ? $latitude[0] : '', |
|
| 251 | + 'longitude' => isset($longitude[0]) && is_numeric($longitude[0]) ? $longitude[0] : '', |
|
| 252 | 252 | ); |
| 253 | 253 | } |
| 254 | 254 | |
@@ -259,12 +259,12 @@ discard block |
||
| 259 | 259 | * |
| 260 | 260 | * @return string A datetime. |
| 261 | 261 | */ |
| 262 | -function wl_get_post_modified_time( $post ) { |
|
| 262 | +function wl_get_post_modified_time($post) { |
|
| 263 | 263 | |
| 264 | - $date_modified = get_post_modified_time( 'c', true, $post ); |
|
| 264 | + $date_modified = get_post_modified_time('c', true, $post); |
|
| 265 | 265 | |
| 266 | - if ( '-' === substr( $date_modified, 0, 1 ) ) { |
|
| 267 | - return get_the_time( 'c', $post ); |
|
| 266 | + if ('-' === substr($date_modified, 0, 1)) { |
|
| 267 | + return get_the_time('c', $post); |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | return $date_modified; |
@@ -277,24 +277,24 @@ discard block |
||
| 277 | 277 | * |
| 278 | 278 | * @return array An array of image URLs. |
| 279 | 279 | */ |
| 280 | -function wl_get_image_urls( $post_id ) { |
|
| 280 | +function wl_get_image_urls($post_id) { |
|
| 281 | 281 | |
| 282 | 282 | // If there is a featured image it has the priority. |
| 283 | - $featured_image_id = get_post_thumbnail_id( $post_id ); |
|
| 284 | - if ( is_numeric( $featured_image_id ) ) { |
|
| 285 | - $image_url = wp_get_attachment_url( $featured_image_id ); |
|
| 283 | + $featured_image_id = get_post_thumbnail_id($post_id); |
|
| 284 | + if (is_numeric($featured_image_id)) { |
|
| 285 | + $image_url = wp_get_attachment_url($featured_image_id); |
|
| 286 | 286 | |
| 287 | - return array( $image_url ); |
|
| 287 | + return array($image_url); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - $images = get_children( array( |
|
| 290 | + $images = get_children(array( |
|
| 291 | 291 | 'post_parent' => $post_id, |
| 292 | 292 | 'post_type' => 'attachment', |
| 293 | 293 | 'post_mime_type' => 'image', |
| 294 | - ) ); |
|
| 294 | + )); |
|
| 295 | 295 | |
| 296 | 296 | // Return an empty array if no image is found. |
| 297 | - if ( empty( $images ) ) { |
|
| 297 | + if (empty($images)) { |
|
| 298 | 298 | return array(); |
| 299 | 299 | } |
| 300 | 300 | |
@@ -302,11 +302,11 @@ discard block |
||
| 302 | 302 | $image_urls = array(); |
| 303 | 303 | |
| 304 | 304 | // Collect the URLs. |
| 305 | - foreach ( $images as $attachment_id => $attachment ) { |
|
| 306 | - $image_url = wp_get_attachment_url( $attachment_id ); |
|
| 305 | + foreach ($images as $attachment_id => $attachment) { |
|
| 306 | + $image_url = wp_get_attachment_url($attachment_id); |
|
| 307 | 307 | // Ensure the URL isn't collected already. |
| 308 | - if ( ! in_array( $image_url, $image_urls ) ) { |
|
| 309 | - array_push( $image_urls, $image_url ); |
|
| 308 | + if ( ! in_array($image_url, $image_urls)) { |
|
| 309 | + array_push($image_urls, $image_url); |
|
| 310 | 310 | } |
| 311 | 311 | } |
| 312 | 312 | |
@@ -323,18 +323,18 @@ discard block |
||
| 323 | 323 | * |
| 324 | 324 | * @return string The SPARQL fragment. |
| 325 | 325 | */ |
| 326 | -function wl_get_sparql_images( $uri, $post_id ) { |
|
| 326 | +function wl_get_sparql_images($uri, $post_id) { |
|
| 327 | 327 | |
| 328 | 328 | $sparql = ''; |
| 329 | 329 | |
| 330 | 330 | // Get the escaped URI. |
| 331 | - $uri_e = esc_html( $uri ); |
|
| 331 | + $uri_e = esc_html($uri); |
|
| 332 | 332 | |
| 333 | 333 | // Add SPARQL stmts to write the schema:image. |
| 334 | - $image_urls = wl_get_image_urls( $post_id ); |
|
| 335 | - foreach ( $image_urls as $image_url ) { |
|
| 336 | - $image_url_esc = wl_sparql_escape_uri( $image_url ); |
|
| 337 | - $sparql .= " <$uri_e> schema:image <$image_url_esc> . \n"; |
|
| 334 | + $image_urls = wl_get_image_urls($post_id); |
|
| 335 | + foreach ($image_urls as $image_url) { |
|
| 336 | + $image_url_esc = wl_sparql_escape_uri($image_url); |
|
| 337 | + $sparql .= " <$uri_e> schema:image <$image_url_esc> . \n"; |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | return $sparql; |
@@ -348,21 +348,21 @@ discard block |
||
| 348 | 348 | * |
| 349 | 349 | * @return WP_Post|null A post instance or null if not found. |
| 350 | 350 | */ |
| 351 | -function wl_get_attachment_for_source_url( $parent_post_id, $source_url ) { |
|
| 351 | +function wl_get_attachment_for_source_url($parent_post_id, $source_url) { |
|
| 352 | 352 | |
| 353 | 353 | // wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" ); |
| 354 | 354 | |
| 355 | - $posts = get_posts( array( |
|
| 355 | + $posts = get_posts(array( |
|
| 356 | 356 | 'post_type' => 'attachment', |
| 357 | 357 | 'posts_per_page' => 1, |
| 358 | 358 | 'post_status' => 'any', |
| 359 | 359 | 'post_parent' => $parent_post_id, |
| 360 | 360 | 'meta_key' => 'wl_source_url', |
| 361 | 361 | 'meta_value' => $source_url, |
| 362 | - ) ); |
|
| 362 | + )); |
|
| 363 | 363 | |
| 364 | 364 | // Return the found post. |
| 365 | - if ( 1 === count( $posts ) ) { |
|
| 365 | + if (1 === count($posts)) { |
|
| 366 | 366 | return $posts[0]; |
| 367 | 367 | } |
| 368 | 368 | |
@@ -376,10 +376,10 @@ discard block |
||
| 376 | 376 | * @param int $post_id The post ID. |
| 377 | 377 | * @param string $source_url The source URL. |
| 378 | 378 | */ |
| 379 | -function wl_set_source_url( $post_id, $source_url ) { |
|
| 379 | +function wl_set_source_url($post_id, $source_url) { |
|
| 380 | 380 | |
| 381 | - delete_post_meta( $post_id, 'wl_source_url' ); |
|
| 382 | - add_post_meta( $post_id, 'wl_source_url', $source_url ); |
|
| 381 | + delete_post_meta($post_id, 'wl_source_url'); |
|
| 382 | + add_post_meta($post_id, 'wl_source_url', $source_url); |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | |
@@ -395,10 +395,10 @@ discard block |
||
| 395 | 395 | * |
| 396 | 396 | * @param bool $hard True if the rewrite involves configuration updates in Apache/IIS. |
| 397 | 397 | */ |
| 398 | -function wl_flush_rewrite_rules_hard( $hard ) { |
|
| 398 | +function wl_flush_rewrite_rules_hard($hard) { |
|
| 399 | 399 | |
| 400 | 400 | // If WL is not yet configured, we cannot perform any update, so we exit. |
| 401 | - if ( '' === wl_configuration_get_key() ) { |
|
| 401 | + if ('' === wl_configuration_get_key()) { |
|
| 402 | 402 | return; |
| 403 | 403 | } |
| 404 | 404 | |
@@ -407,13 +407,13 @@ discard block |
||
| 407 | 407 | $limit = 100; |
| 408 | 408 | |
| 409 | 409 | // Get more posts if the number of returned posts matches the limit. |
| 410 | - while ( $limit === ( $posts = get_posts( array( |
|
| 410 | + while ($limit === ($posts = get_posts(array( |
|
| 411 | 411 | 'offset' => $offset, |
| 412 | 412 | 'numberposts' => $limit, |
| 413 | 413 | 'orderby' => 'ID', |
| 414 | 414 | 'post_type' => 'any', |
| 415 | 415 | 'post_status' => 'publish', |
| 416 | - ) ) ) ) { |
|
| 416 | + )))) { |
|
| 417 | 417 | |
| 418 | 418 | // Holds the delete part of the query. |
| 419 | 419 | $delete_query = rl_sparql_prefixes(); |
@@ -422,16 +422,16 @@ discard block |
||
| 422 | 422 | $insert_query = ''; |
| 423 | 423 | |
| 424 | 424 | // Cycle in each post to build the query. |
| 425 | - foreach ( $posts as $post ) { |
|
| 425 | + foreach ($posts as $post) { |
|
| 426 | 426 | |
| 427 | 427 | // Ignore revisions. |
| 428 | - if ( wp_is_post_revision( $post->ID ) ) { |
|
| 428 | + if (wp_is_post_revision($post->ID)) { |
|
| 429 | 429 | continue; |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | // Get the entity URI. |
| 433 | - $s = Wordlift_Sparql_Service::escape_uri( Wordlift_Entity_Service::get_instance() |
|
| 434 | - ->get_uri( $post->ID ) ); |
|
| 433 | + $s = Wordlift_Sparql_Service::escape_uri(Wordlift_Entity_Service::get_instance() |
|
| 434 | + ->get_uri($post->ID)); |
|
| 435 | 435 | |
| 436 | 436 | // Get the post URL. |
| 437 | 437 | // $url = wl_sparql_escape_uri( get_permalink( $post->ID ) ); |
@@ -440,13 +440,13 @@ discard block |
||
| 440 | 440 | $delete_query .= "DELETE { <$s> schema:url ?u . } WHERE { <$s> schema:url ?u . };\n"; |
| 441 | 441 | |
| 442 | 442 | $insert_query .= Wordlift_Schema_Url_Property_Service::get_instance() |
| 443 | - ->get_insert_query( $s, $post->ID ); |
|
| 443 | + ->get_insert_query($s, $post->ID); |
|
| 444 | 444 | |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | |
| 448 | 448 | // Execute the query. |
| 449 | - rl_execute_sparql_update_query( $delete_query . $insert_query ); |
|
| 449 | + rl_execute_sparql_update_query($delete_query.$insert_query); |
|
| 450 | 450 | |
| 451 | 451 | // Advance to the next posts. |
| 452 | 452 | $offset += $limit; |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | -add_filter( 'flush_rewrite_rules_hard', 'wl_flush_rewrite_rules_hard', 10, 1 ); |
|
| 465 | +add_filter('flush_rewrite_rules_hard', 'wl_flush_rewrite_rules_hard', 10, 1); |
|
| 466 | 466 | |
| 467 | 467 | /** |
| 468 | 468 | * Sanitizes an URI path by replacing the non allowed characters with an underscore. |
@@ -475,9 +475,9 @@ discard block |
||
| 475 | 475 | * |
| 476 | 476 | * @return string The sanitized path. |
| 477 | 477 | */ |
| 478 | -function wl_sanitize_uri_path( $path, $char = '_' ) { |
|
| 478 | +function wl_sanitize_uri_path($path, $char = '_') { |
|
| 479 | 479 | |
| 480 | - return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char ); |
|
| 480 | + return Wordlift_Uri_Service::get_instance()->sanitize_path($path, $char); |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | /** |
@@ -487,10 +487,10 @@ discard block |
||
| 487 | 487 | * |
| 488 | 488 | * @return array Array containing $value (if $value was not an array) |
| 489 | 489 | */ |
| 490 | -function wl_force_to_array( $value ) { |
|
| 490 | +function wl_force_to_array($value) { |
|
| 491 | 491 | |
| 492 | - if ( ! is_array( $value ) ) { |
|
| 493 | - return array( $value ); |
|
| 492 | + if ( ! is_array($value)) { |
|
| 493 | + return array($value); |
|
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | return $value; |
@@ -502,28 +502,28 @@ discard block |
||
| 502 | 502 | function wl_shutdown() { |
| 503 | 503 | |
| 504 | 504 | // Get the filename to the temporary SPARQL file. |
| 505 | - $filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql'; |
|
| 505 | + $filename = WL_TEMP_DIR.WL_REQUEST_ID.'.sparql'; |
|
| 506 | 506 | |
| 507 | 507 | // If WordLift is buffering SPARQL queries, we're admins and a buffer exists, then schedule it. |
| 508 | - if ( WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING && is_admin() && file_exists( $filename ) ) { |
|
| 508 | + if (WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING && is_admin() && file_exists($filename)) { |
|
| 509 | 509 | |
| 510 | 510 | // The request ID. |
| 511 | - $args = array( WL_REQUEST_ID ); |
|
| 511 | + $args = array(WL_REQUEST_ID); |
|
| 512 | 512 | |
| 513 | 513 | // Schedule the execution of the SPARQL query with the request ID. |
| 514 | - wp_schedule_single_event( time(), 'wl_execute_saved_sparql_update_query', $args ); |
|
| 514 | + wp_schedule_single_event(time(), 'wl_execute_saved_sparql_update_query', $args); |
|
| 515 | 515 | |
| 516 | 516 | // Check that the request is scheduled. |
| 517 | - $timestamp = wp_next_scheduled( 'wl_execute_saved_sparql_update_query', $args ); |
|
| 517 | + $timestamp = wp_next_scheduled('wl_execute_saved_sparql_update_query', $args); |
|
| 518 | 518 | |
| 519 | 519 | // Spawn the cron. |
| 520 | 520 | spawn_cron(); |
| 521 | 521 | |
| 522 | - wl_write_log( "wl_shutdown [ request id :: " . WL_REQUEST_ID . " ][ timestamp :: $timestamp ]" ); |
|
| 522 | + wl_write_log("wl_shutdown [ request id :: ".WL_REQUEST_ID." ][ timestamp :: $timestamp ]"); |
|
| 523 | 523 | } |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | -add_action( 'shutdown', 'wl_shutdown' ); |
|
| 526 | +add_action('shutdown', 'wl_shutdown'); |
|
| 527 | 527 | |
| 528 | 528 | /** |
| 529 | 529 | * Replaces the *itemid* attributes URIs with the WordLift URIs. |
@@ -532,113 +532,113 @@ discard block |
||
| 532 | 532 | * |
| 533 | 533 | * @return string The updated post content. |
| 534 | 534 | */ |
| 535 | -function wl_replace_item_id_with_uri( $content ) { |
|
| 535 | +function wl_replace_item_id_with_uri($content) { |
|
| 536 | 536 | |
| 537 | 537 | // wl_write_log( "wl_replace_item_id_with_uri" ); |
| 538 | 538 | |
| 539 | 539 | // Strip slashes, see https://core.trac.wordpress.org/ticket/21767 |
| 540 | - $content = stripslashes( $content ); |
|
| 540 | + $content = stripslashes($content); |
|
| 541 | 541 | |
| 542 | 542 | // If any match are found. |
| 543 | 543 | $matches = array(); |
| 544 | - if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) { |
|
| 544 | + if (0 < preg_match_all('/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER)) { |
|
| 545 | 545 | |
| 546 | - foreach ( $matches as $match ) { |
|
| 546 | + foreach ($matches as $match) { |
|
| 547 | 547 | |
| 548 | 548 | // Get the item ID. |
| 549 | 549 | $item_id = $match[1]; |
| 550 | 550 | |
| 551 | 551 | // Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' . |
| 552 | 552 | $post = Wordlift_Entity_Service::get_instance() |
| 553 | - ->get_entity_post_by_uri( $item_id ); |
|
| 553 | + ->get_entity_post_by_uri($item_id); |
|
| 554 | 554 | |
| 555 | 555 | // If no entity is found, continue to the next one. |
| 556 | - if ( null === $post ) { |
|
| 556 | + if (null === $post) { |
|
| 557 | 557 | continue; |
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | // Get the URI for that post. |
| 561 | - $uri = wl_get_entity_uri( $post->ID ); |
|
| 561 | + $uri = wl_get_entity_uri($post->ID); |
|
| 562 | 562 | |
| 563 | 563 | // wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" ); |
| 564 | 564 | |
| 565 | 565 | // If the item ID and the URI differ, replace the item ID with the URI saved in WordPress. |
| 566 | - if ( $item_id !== $uri ) { |
|
| 567 | - $uri_e = esc_html( $uri ); |
|
| 568 | - $content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content ); |
|
| 566 | + if ($item_id !== $uri) { |
|
| 567 | + $uri_e = esc_html($uri); |
|
| 568 | + $content = str_replace(" itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content); |
|
| 569 | 569 | } |
| 570 | 570 | } |
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | // Reapply slashes. |
| 574 | - $content = addslashes( $content ); |
|
| 574 | + $content = addslashes($content); |
|
| 575 | 575 | |
| 576 | 576 | return $content; |
| 577 | 577 | } |
| 578 | 578 | |
| 579 | -add_filter( 'content_save_pre', 'wl_replace_item_id_with_uri', 1, 1 ); |
|
| 579 | +add_filter('content_save_pre', 'wl_replace_item_id_with_uri', 1, 1); |
|
| 580 | 580 | |
| 581 | -require_once( 'wordlift_entity_functions.php' ); |
|
| 581 | +require_once('wordlift_entity_functions.php'); |
|
| 582 | 582 | |
| 583 | 583 | // add editor related methods. |
| 584 | -require_once( 'wordlift_editor.php' ); |
|
| 584 | +require_once('wordlift_editor.php'); |
|
| 585 | 585 | |
| 586 | 586 | // add the WordLift entity custom type. |
| 587 | -require_once( 'wordlift_entity_type.php' ); |
|
| 588 | -require_once( 'wordlift_entity_type_taxonomy.php' ); |
|
| 587 | +require_once('wordlift_entity_type.php'); |
|
| 588 | +require_once('wordlift_entity_type_taxonomy.php'); |
|
| 589 | 589 | |
| 590 | 590 | // add callbacks on post save to notify data changes from wp to redlink triple store |
| 591 | -require_once( 'wordlift_to_redlink_data_push_callbacks.php' ); |
|
| 591 | +require_once('wordlift_to_redlink_data_push_callbacks.php'); |
|
| 592 | 592 | |
| 593 | -require_once( 'modules/configuration/wordlift_configuration_settings.php' ); |
|
| 593 | +require_once('modules/configuration/wordlift_configuration_settings.php'); |
|
| 594 | 594 | |
| 595 | 595 | // Load modules |
| 596 | -require_once( 'modules/analyzer/wordlift_analyzer.php' ); |
|
| 597 | -require_once( 'modules/linked_data/wordlift_linked_data.php' ); |
|
| 598 | -require_once( 'modules/prefixes/wordlift_prefixes.php' ); |
|
| 599 | -require_once( 'modules/redirector/wordlift_redirector.php' ); |
|
| 596 | +require_once('modules/analyzer/wordlift_analyzer.php'); |
|
| 597 | +require_once('modules/linked_data/wordlift_linked_data.php'); |
|
| 598 | +require_once('modules/prefixes/wordlift_prefixes.php'); |
|
| 599 | +require_once('modules/redirector/wordlift_redirector.php'); |
|
| 600 | 600 | |
| 601 | 601 | // Shortcodes |
| 602 | 602 | |
| 603 | -require_once( 'modules/geo_widget/wordlift_geo_widget.php' ); |
|
| 604 | -require_once( 'shortcodes/wordlift_shortcode_chord.php' ); |
|
| 605 | -require_once( 'shortcodes/wordlift_shortcode_geomap.php' ); |
|
| 606 | -require_once( 'shortcodes/wordlift_shortcode_field.php' ); |
|
| 607 | -require_once( 'shortcodes/wordlift_shortcode_faceted_search.php' ); |
|
| 608 | -require_once( 'shortcodes/wordlift_shortcode_navigator.php' ); |
|
| 603 | +require_once('modules/geo_widget/wordlift_geo_widget.php'); |
|
| 604 | +require_once('shortcodes/wordlift_shortcode_chord.php'); |
|
| 605 | +require_once('shortcodes/wordlift_shortcode_geomap.php'); |
|
| 606 | +require_once('shortcodes/wordlift_shortcode_field.php'); |
|
| 607 | +require_once('shortcodes/wordlift_shortcode_faceted_search.php'); |
|
| 608 | +require_once('shortcodes/wordlift_shortcode_navigator.php'); |
|
| 609 | 609 | |
| 610 | -require_once( 'widgets/wordlift_widget_geo.php' ); |
|
| 611 | -require_once( 'widgets/wordlift_widget_chord.php' ); |
|
| 612 | -require_once( 'widgets/wordlift_widget_timeline.php' ); |
|
| 610 | +require_once('widgets/wordlift_widget_geo.php'); |
|
| 611 | +require_once('widgets/wordlift_widget_chord.php'); |
|
| 612 | +require_once('widgets/wordlift_widget_timeline.php'); |
|
| 613 | 613 | |
| 614 | -require_once( 'wordlift_sparql.php' ); |
|
| 615 | -require_once( 'wordlift_redlink.php' ); |
|
| 614 | +require_once('wordlift_sparql.php'); |
|
| 615 | +require_once('wordlift_redlink.php'); |
|
| 616 | 616 | |
| 617 | 617 | // Add admin functions. |
| 618 | 618 | // TODO: find a way to make 'admin' UI tests work. |
| 619 | 619 | //if ( is_admin() ) { |
| 620 | 620 | |
| 621 | -require_once( 'admin/wordlift_admin.php' ); |
|
| 622 | -require_once( 'admin/wordlift_admin_edit_post.php' ); |
|
| 623 | -require_once( 'admin/wordlift_admin_save_post.php' ); |
|
| 621 | +require_once('admin/wordlift_admin.php'); |
|
| 622 | +require_once('admin/wordlift_admin_edit_post.php'); |
|
| 623 | +require_once('admin/wordlift_admin_save_post.php'); |
|
| 624 | 624 | |
| 625 | 625 | // add the entities meta box. |
| 626 | -require_once( 'admin/wordlift_admin_meta_box_entities.php' ); |
|
| 626 | +require_once('admin/wordlift_admin_meta_box_entities.php'); |
|
| 627 | 627 | |
| 628 | 628 | // add the entity creation AJAX. |
| 629 | -require_once( 'admin/wordlift_admin_ajax_related_posts.php' ); |
|
| 629 | +require_once('admin/wordlift_admin_ajax_related_posts.php'); |
|
| 630 | 630 | |
| 631 | 631 | // Load the wl_chord TinyMCE button and configuration dialog. |
| 632 | -require_once( 'admin/wordlift_admin_shortcodes.php' ); |
|
| 632 | +require_once('admin/wordlift_admin_shortcodes.php'); |
|
| 633 | 633 | |
| 634 | 634 | // Provide syncing features. |
| 635 | -require_once( 'admin/wordlift_admin_sync.php' ); |
|
| 635 | +require_once('admin/wordlift_admin_sync.php'); |
|
| 636 | 636 | //} |
| 637 | 637 | |
| 638 | 638 | // load languages. |
| 639 | 639 | // TODO: the following call gives for granted that the plugin is in the wordlift directory, |
| 640 | 640 | // we're currently doing this because wordlift is symbolic linked. |
| 641 | -load_plugin_textdomain( 'wordlift', false, '/wordlift/languages' ); |
|
| 641 | +load_plugin_textdomain('wordlift', false, '/wordlift/languages'); |
|
| 642 | 642 | |
| 643 | 643 | |
| 644 | 644 | /** |
@@ -646,7 +646,7 @@ discard block |
||
| 646 | 646 | * This action is documented in includes/class-wordlift-activator.php |
| 647 | 647 | */ |
| 648 | 648 | function activate_wordlift() { |
| 649 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php'; |
|
| 649 | + require_once plugin_dir_path(__FILE__).'includes/class-wordlift-activator.php'; |
|
| 650 | 650 | Wordlift_Activator::activate(); |
| 651 | 651 | } |
| 652 | 652 | |
@@ -655,18 +655,18 @@ discard block |
||
| 655 | 655 | * This action is documented in includes/class-wordlift-deactivator.php |
| 656 | 656 | */ |
| 657 | 657 | function deactivate_wordlift() { |
| 658 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php'; |
|
| 658 | + require_once plugin_dir_path(__FILE__).'includes/class-wordlift-deactivator.php'; |
|
| 659 | 659 | Wordlift_Deactivator::deactivate(); |
| 660 | 660 | } |
| 661 | 661 | |
| 662 | -register_activation_hook( __FILE__, 'activate_wordlift' ); |
|
| 663 | -register_deactivation_hook( __FILE__, 'deactivate_wordlift' ); |
|
| 662 | +register_activation_hook(__FILE__, 'activate_wordlift'); |
|
| 663 | +register_deactivation_hook(__FILE__, 'deactivate_wordlift'); |
|
| 664 | 664 | |
| 665 | 665 | /** |
| 666 | 666 | * The core plugin class that is used to define internationalization, |
| 667 | 667 | * admin-specific hooks, and public-facing site hooks. |
| 668 | 668 | */ |
| 669 | -require plugin_dir_path( __FILE__ ) . 'includes/class-wordlift.php'; |
|
| 669 | +require plugin_dir_path(__FILE__).'includes/class-wordlift.php'; |
|
| 670 | 670 | |
| 671 | 671 | /** |
| 672 | 672 | * Begins execution of the plugin. |