@@ -7,103 +7,103 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class Wordlift_ShareThis_Service { |
| 9 | 9 | |
| 10 | - /** |
|
| 11 | - * The ShareThis function which prints the buttons. |
|
| 12 | - * |
|
| 13 | - * @since 3.2.0 |
|
| 14 | - */ |
|
| 15 | - const ADD_WIDGET_FUNCTION_NAME = 'st_add_widget'; |
|
| 16 | - |
|
| 17 | - /** |
|
| 18 | - * The Log service. |
|
| 19 | - * |
|
| 20 | - * @since 3.2.0 |
|
| 21 | - * @access private |
|
| 22 | - * @var \Wordlift_Log_Service $log_service The Log service. |
|
| 23 | - */ |
|
| 24 | - private $log_service; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * Create an instance of the ShareThis service. |
|
| 28 | - * |
|
| 29 | - * @since 3.2.0 |
|
| 30 | - */ |
|
| 31 | - public function __construct() { |
|
| 32 | - |
|
| 33 | - $this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_ShareThis_Service' ); |
|
| 34 | - |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * Receive <em>the_content</em> filter calls from WordPress. |
|
| 39 | - * |
|
| 40 | - * @since 3.2.0 |
|
| 41 | - * |
|
| 42 | - * @param string $content The post content. |
|
| 43 | - * |
|
| 44 | - * @return string The updated post content. |
|
| 45 | - */ |
|
| 46 | - public function the_content( $content ) { |
|
| 47 | - |
|
| 48 | - return $this->call_sharethis( 'the_content', $content ); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * Receive <em>the_excerpt</em> filter calls from WordPress. |
|
| 53 | - * |
|
| 54 | - * @since 3.2.0 |
|
| 55 | - * |
|
| 56 | - * @param string $content The post excerpt. |
|
| 57 | - * |
|
| 58 | - * @return string The updated post excerpt. |
|
| 59 | - */ |
|
| 60 | - public function the_excerpt( $content ) { |
|
| 61 | - |
|
| 62 | - return $this->call_sharethis( 'the_excerpt', $content ); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * Call the ShareThis function. |
|
| 67 | - * |
|
| 68 | - * @since 3.2.0 |
|
| 69 | - * |
|
| 70 | - * @param string $tag The filter tag. |
|
| 71 | - * @param string $content The post content. |
|
| 72 | - * |
|
| 73 | - * @return string The updated post content. |
|
| 74 | - */ |
|
| 75 | - private function call_sharethis( $tag, $content ) { |
|
| 76 | - |
|
| 77 | - // Get the current post. |
|
| 78 | - global $post; |
|
| 79 | - |
|
| 80 | - // If it's not the entity type, return. |
|
| 81 | - if ( null === $post || ! isset( $post->post_type ) || Wordlift_Entity_Service::TYPE_NAME !== $post->post_type ) { |
|
| 82 | - return $content; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - // If the ShareThis function doesn't exist, return. |
|
| 86 | - if ( ! function_exists( self::ADD_WIDGET_FUNCTION_NAME ) ) { |
|
| 87 | - return $content; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - // If ShareThis hasn't been added as a filter, return. |
|
| 91 | - if ( ! has_filter( $tag, self::ADD_WIDGET_FUNCTION_NAME ) ) { |
|
| 92 | - return $content; |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - // Temporary pop the post type and replace it with post. |
|
| 96 | - $post_type = $post->post_type; |
|
| 97 | - $post->post_type = 'post'; |
|
| 98 | - |
|
| 99 | - // Call ShareThis (disguised as a post). |
|
| 100 | - $content = call_user_func_array( self::ADD_WIDGET_FUNCTION_NAME, array( $content ) ); |
|
| 101 | - |
|
| 102 | - // Restore our post type. |
|
| 103 | - $post->post_type = $post_type; |
|
| 104 | - |
|
| 105 | - // Finally return the content. |
|
| 106 | - return $content; |
|
| 107 | - } |
|
| 10 | + /** |
|
| 11 | + * The ShareThis function which prints the buttons. |
|
| 12 | + * |
|
| 13 | + * @since 3.2.0 |
|
| 14 | + */ |
|
| 15 | + const ADD_WIDGET_FUNCTION_NAME = 'st_add_widget'; |
|
| 16 | + |
|
| 17 | + /** |
|
| 18 | + * The Log service. |
|
| 19 | + * |
|
| 20 | + * @since 3.2.0 |
|
| 21 | + * @access private |
|
| 22 | + * @var \Wordlift_Log_Service $log_service The Log service. |
|
| 23 | + */ |
|
| 24 | + private $log_service; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * Create an instance of the ShareThis service. |
|
| 28 | + * |
|
| 29 | + * @since 3.2.0 |
|
| 30 | + */ |
|
| 31 | + public function __construct() { |
|
| 32 | + |
|
| 33 | + $this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_ShareThis_Service' ); |
|
| 34 | + |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * Receive <em>the_content</em> filter calls from WordPress. |
|
| 39 | + * |
|
| 40 | + * @since 3.2.0 |
|
| 41 | + * |
|
| 42 | + * @param string $content The post content. |
|
| 43 | + * |
|
| 44 | + * @return string The updated post content. |
|
| 45 | + */ |
|
| 46 | + public function the_content( $content ) { |
|
| 47 | + |
|
| 48 | + return $this->call_sharethis( 'the_content', $content ); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * Receive <em>the_excerpt</em> filter calls from WordPress. |
|
| 53 | + * |
|
| 54 | + * @since 3.2.0 |
|
| 55 | + * |
|
| 56 | + * @param string $content The post excerpt. |
|
| 57 | + * |
|
| 58 | + * @return string The updated post excerpt. |
|
| 59 | + */ |
|
| 60 | + public function the_excerpt( $content ) { |
|
| 61 | + |
|
| 62 | + return $this->call_sharethis( 'the_excerpt', $content ); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * Call the ShareThis function. |
|
| 67 | + * |
|
| 68 | + * @since 3.2.0 |
|
| 69 | + * |
|
| 70 | + * @param string $tag The filter tag. |
|
| 71 | + * @param string $content The post content. |
|
| 72 | + * |
|
| 73 | + * @return string The updated post content. |
|
| 74 | + */ |
|
| 75 | + private function call_sharethis( $tag, $content ) { |
|
| 76 | + |
|
| 77 | + // Get the current post. |
|
| 78 | + global $post; |
|
| 79 | + |
|
| 80 | + // If it's not the entity type, return. |
|
| 81 | + if ( null === $post || ! isset( $post->post_type ) || Wordlift_Entity_Service::TYPE_NAME !== $post->post_type ) { |
|
| 82 | + return $content; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + // If the ShareThis function doesn't exist, return. |
|
| 86 | + if ( ! function_exists( self::ADD_WIDGET_FUNCTION_NAME ) ) { |
|
| 87 | + return $content; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + // If ShareThis hasn't been added as a filter, return. |
|
| 91 | + if ( ! has_filter( $tag, self::ADD_WIDGET_FUNCTION_NAME ) ) { |
|
| 92 | + return $content; |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + // Temporary pop the post type and replace it with post. |
|
| 96 | + $post_type = $post->post_type; |
|
| 97 | + $post->post_type = 'post'; |
|
| 98 | + |
|
| 99 | + // Call ShareThis (disguised as a post). |
|
| 100 | + $content = call_user_func_array( self::ADD_WIDGET_FUNCTION_NAME, array( $content ) ); |
|
| 101 | + |
|
| 102 | + // Restore our post type. |
|
| 103 | + $post->post_type = $post_type; |
|
| 104 | + |
|
| 105 | + // Finally return the content. |
|
| 106 | + return $content; |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | 109 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | public function __construct() { |
| 32 | 32 | |
| 33 | - $this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_ShareThis_Service' ); |
|
| 33 | + $this->log_service = Wordlift_Log_Service::get_logger('Wordlift_ShareThis_Service'); |
|
| 34 | 34 | |
| 35 | 35 | } |
| 36 | 36 | |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | * |
| 44 | 44 | * @return string The updated post content. |
| 45 | 45 | */ |
| 46 | - public function the_content( $content ) { |
|
| 46 | + public function the_content($content) { |
|
| 47 | 47 | |
| 48 | - return $this->call_sharethis( 'the_content', $content ); |
|
| 48 | + return $this->call_sharethis('the_content', $content); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @return string The updated post excerpt. |
| 59 | 59 | */ |
| 60 | - public function the_excerpt( $content ) { |
|
| 60 | + public function the_excerpt($content) { |
|
| 61 | 61 | |
| 62 | - return $this->call_sharethis( 'the_excerpt', $content ); |
|
| 62 | + return $this->call_sharethis('the_excerpt', $content); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -72,23 +72,23 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @return string The updated post content. |
| 74 | 74 | */ |
| 75 | - private function call_sharethis( $tag, $content ) { |
|
| 75 | + private function call_sharethis($tag, $content) { |
|
| 76 | 76 | |
| 77 | 77 | // Get the current post. |
| 78 | 78 | global $post; |
| 79 | 79 | |
| 80 | 80 | // If it's not the entity type, return. |
| 81 | - if ( null === $post || ! isset( $post->post_type ) || Wordlift_Entity_Service::TYPE_NAME !== $post->post_type ) { |
|
| 81 | + if (null === $post || ! isset($post->post_type) || Wordlift_Entity_Service::TYPE_NAME !== $post->post_type) { |
|
| 82 | 82 | return $content; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | // If the ShareThis function doesn't exist, return. |
| 86 | - if ( ! function_exists( self::ADD_WIDGET_FUNCTION_NAME ) ) { |
|
| 86 | + if ( ! function_exists(self::ADD_WIDGET_FUNCTION_NAME)) { |
|
| 87 | 87 | return $content; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | // If ShareThis hasn't been added as a filter, return. |
| 91 | - if ( ! has_filter( $tag, self::ADD_WIDGET_FUNCTION_NAME ) ) { |
|
| 91 | + if ( ! has_filter($tag, self::ADD_WIDGET_FUNCTION_NAME)) { |
|
| 92 | 92 | return $content; |
| 93 | 93 | } |
| 94 | 94 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $post->post_type = 'post'; |
| 98 | 98 | |
| 99 | 99 | // Call ShareThis (disguised as a post). |
| 100 | - $content = call_user_func_array( self::ADD_WIDGET_FUNCTION_NAME, array( $content ) ); |
|
| 100 | + $content = call_user_func_array(self::ADD_WIDGET_FUNCTION_NAME, array($content)); |
|
| 101 | 101 | |
| 102 | 102 | // Restore our post type. |
| 103 | 103 | $post->post_type = $post_type; |
@@ -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 | ///** |
@@ -137,21 +137,21 @@ discard block |
||
| 137 | 137 | * see http://vip.wordpress.com/documentation/register-additional-html-attributes-for-tinymce-and-wp-kses/ |
| 138 | 138 | */ |
| 139 | 139 | function wordlift_allowed_post_tags() { |
| 140 | - global $allowedposttags; |
|
| 141 | - |
|
| 142 | - $tags = array( 'span' ); |
|
| 143 | - $new_attributes = array( |
|
| 144 | - 'itemscope' => array(), |
|
| 145 | - 'itemtype' => array(), |
|
| 146 | - 'itemprop' => array(), |
|
| 147 | - 'itemid' => array(), |
|
| 148 | - ); |
|
| 149 | - |
|
| 150 | - foreach ( $tags as $tag ) { |
|
| 151 | - if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) { |
|
| 152 | - $allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes ); |
|
| 153 | - } |
|
| 154 | - } |
|
| 140 | + global $allowedposttags; |
|
| 141 | + |
|
| 142 | + $tags = array( 'span' ); |
|
| 143 | + $new_attributes = array( |
|
| 144 | + 'itemscope' => array(), |
|
| 145 | + 'itemtype' => array(), |
|
| 146 | + 'itemprop' => array(), |
|
| 147 | + 'itemid' => array(), |
|
| 148 | + ); |
|
| 149 | + |
|
| 150 | + foreach ( $tags as $tag ) { |
|
| 151 | + if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) { |
|
| 152 | + $allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes ); |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | // init process for button control |
@@ -166,28 +166,28 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | function wordlift_admin_enqueue_scripts() { |
| 168 | 168 | |
| 169 | - // Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/) |
|
| 170 | - wp_enqueue_script( 'wpdialogs' ); |
|
| 171 | - wp_enqueue_style( 'wp-jquery-ui-dialog' ); |
|
| 169 | + // Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/) |
|
| 170 | + wp_enqueue_script( 'wpdialogs' ); |
|
| 171 | + wp_enqueue_style( 'wp-jquery-ui-dialog' ); |
|
| 172 | 172 | |
| 173 | - wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css' ); |
|
| 173 | + wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css' ); |
|
| 174 | 174 | |
| 175 | - wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
| 176 | - wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' ); |
|
| 177 | - wp_enqueue_script( 'angularjs-geolocation', plugin_dir_url( __FILE__ ) . '/bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js' ); |
|
| 178 | - wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js' ); |
|
| 179 | - wp_enqueue_script( 'angularjs-animate', 'https://code.angularjs.org/1.3.11/angular-animate.min.js' ); |
|
| 175 | + wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
| 176 | + wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' ); |
|
| 177 | + wp_enqueue_script( 'angularjs-geolocation', plugin_dir_url( __FILE__ ) . '/bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js' ); |
|
| 178 | + wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js' ); |
|
| 179 | + wp_enqueue_script( 'angularjs-animate', 'https://code.angularjs.org/1.3.11/angular-animate.min.js' ); |
|
| 180 | 180 | |
| 181 | - // Disable auto-save for custom entity posts only |
|
| 182 | - if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) { |
|
| 183 | - wp_dequeue_script( 'autosave' ); |
|
| 184 | - } |
|
| 181 | + // Disable auto-save for custom entity posts only |
|
| 182 | + if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) { |
|
| 183 | + wp_dequeue_script( 'autosave' ); |
|
| 184 | + } |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | add_action( 'admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts' ); |
| 188 | 188 | |
| 189 | 189 | function wl_enqueue_scripts() { |
| 190 | - wp_enqueue_style( 'wordlift-ui', plugin_dir_url( __FILE__ ) . 'css/wordlift-ui.min.css' ); |
|
| 190 | + wp_enqueue_style( 'wordlift-ui', plugin_dir_url( __FILE__ ) . 'css/wordlift-ui.min.css' ); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | add_action( 'wp_enqueue_scripts', 'wl_enqueue_scripts' ); |
@@ -202,18 +202,18 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | function wordlift_allowed_html( $allowedtags, $context ) { |
| 204 | 204 | |
| 205 | - if ( 'post' !== $context ) { |
|
| 206 | - return $allowedtags; |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - return array_merge_recursive( $allowedtags, array( |
|
| 210 | - 'span' => array( |
|
| 211 | - 'itemscope' => true, |
|
| 212 | - 'itemtype' => true, |
|
| 213 | - 'itemid' => true, |
|
| 214 | - 'itemprop' => true, |
|
| 215 | - ), |
|
| 216 | - ) ); |
|
| 205 | + if ( 'post' !== $context ) { |
|
| 206 | + return $allowedtags; |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + return array_merge_recursive( $allowedtags, array( |
|
| 210 | + 'span' => array( |
|
| 211 | + 'itemscope' => true, |
|
| 212 | + 'itemtype' => true, |
|
| 213 | + 'itemid' => true, |
|
| 214 | + 'itemprop' => true, |
|
| 215 | + ), |
|
| 216 | + ) ); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | add_filter( 'wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2 ); |
@@ -227,16 +227,16 @@ discard block |
||
| 227 | 227 | */ |
| 228 | 228 | function wl_get_coordinates( $post_id ) { |
| 229 | 229 | |
| 230 | - $latitude = wl_schema_get_value( $post_id, 'latitude' ); |
|
| 231 | - $longitude = wl_schema_get_value( $post_id, 'longitude' ); |
|
| 230 | + $latitude = wl_schema_get_value( $post_id, 'latitude' ); |
|
| 231 | + $longitude = wl_schema_get_value( $post_id, 'longitude' ); |
|
| 232 | 232 | |
| 233 | - // DO NOT set latitude/longitude to 0/0 as default values. It's a specific |
|
| 234 | - // place on the globe:"The zero/zero point of this system is located in the |
|
| 235 | - // Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana." |
|
| 236 | - return array( |
|
| 237 | - 'latitude' => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '', |
|
| 238 | - 'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '', |
|
| 239 | - ); |
|
| 233 | + // DO NOT set latitude/longitude to 0/0 as default values. It's a specific |
|
| 234 | + // place on the globe:"The zero/zero point of this system is located in the |
|
| 235 | + // Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana." |
|
| 236 | + return array( |
|
| 237 | + 'latitude' => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '', |
|
| 238 | + 'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '', |
|
| 239 | + ); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -248,13 +248,13 @@ discard block |
||
| 248 | 248 | */ |
| 249 | 249 | function wl_get_post_modified_time( $post ) { |
| 250 | 250 | |
| 251 | - $date_modified = get_post_modified_time( 'c', true, $post ); |
|
| 251 | + $date_modified = get_post_modified_time( 'c', true, $post ); |
|
| 252 | 252 | |
| 253 | - if ( '-' === substr( $date_modified, 0, 1 ) ) { |
|
| 254 | - return get_the_time( 'c', $post ); |
|
| 255 | - } |
|
| 253 | + if ( '-' === substr( $date_modified, 0, 1 ) ) { |
|
| 254 | + return get_the_time( 'c', $post ); |
|
| 255 | + } |
|
| 256 | 256 | |
| 257 | - return $date_modified; |
|
| 257 | + return $date_modified; |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | /** |
@@ -266,40 +266,40 @@ discard block |
||
| 266 | 266 | */ |
| 267 | 267 | function wl_get_image_urls( $post_id ) { |
| 268 | 268 | |
| 269 | - // If there is a featured image it has the priority. |
|
| 270 | - $featured_image_id = get_post_thumbnail_id( $post_id ); |
|
| 271 | - if ( is_numeric( $featured_image_id ) ) { |
|
| 272 | - $image_url = wp_get_attachment_url( $featured_image_id ); |
|
| 269 | + // If there is a featured image it has the priority. |
|
| 270 | + $featured_image_id = get_post_thumbnail_id( $post_id ); |
|
| 271 | + if ( is_numeric( $featured_image_id ) ) { |
|
| 272 | + $image_url = wp_get_attachment_url( $featured_image_id ); |
|
| 273 | 273 | |
| 274 | - return array( $image_url ); |
|
| 275 | - } |
|
| 274 | + return array( $image_url ); |
|
| 275 | + } |
|
| 276 | 276 | |
| 277 | - $images = get_children( array( |
|
| 278 | - 'post_parent' => $post_id, |
|
| 279 | - 'post_type' => 'attachment', |
|
| 280 | - 'post_mime_type' => 'image', |
|
| 281 | - ) ); |
|
| 277 | + $images = get_children( array( |
|
| 278 | + 'post_parent' => $post_id, |
|
| 279 | + 'post_type' => 'attachment', |
|
| 280 | + 'post_mime_type' => 'image', |
|
| 281 | + ) ); |
|
| 282 | 282 | |
| 283 | - // Return an empty array if no image is found. |
|
| 284 | - if ( empty( $images ) ) { |
|
| 285 | - return array(); |
|
| 286 | - } |
|
| 283 | + // Return an empty array if no image is found. |
|
| 284 | + if ( empty( $images ) ) { |
|
| 285 | + return array(); |
|
| 286 | + } |
|
| 287 | 287 | |
| 288 | - // Prepare the return array. |
|
| 289 | - $image_urls = array(); |
|
| 288 | + // Prepare the return array. |
|
| 289 | + $image_urls = array(); |
|
| 290 | 290 | |
| 291 | - // Collect the URLs. |
|
| 292 | - foreach ( $images as $attachment_id => $attachment ) { |
|
| 293 | - $image_url = wp_get_attachment_url( $attachment_id ); |
|
| 294 | - // Ensure the URL isn't collected already. |
|
| 295 | - if ( ! in_array( $image_url, $image_urls ) ) { |
|
| 296 | - array_push( $image_urls, $image_url ); |
|
| 297 | - } |
|
| 298 | - } |
|
| 291 | + // Collect the URLs. |
|
| 292 | + foreach ( $images as $attachment_id => $attachment ) { |
|
| 293 | + $image_url = wp_get_attachment_url( $attachment_id ); |
|
| 294 | + // Ensure the URL isn't collected already. |
|
| 295 | + if ( ! in_array( $image_url, $image_urls ) ) { |
|
| 296 | + array_push( $image_urls, $image_url ); |
|
| 297 | + } |
|
| 298 | + } |
|
| 299 | 299 | |
| 300 | - // wl_write_log( "wl_get_image_urls [ post id :: $post_id ][ image urls count :: " . count( $image_urls ) . " ]" ); |
|
| 300 | + // wl_write_log( "wl_get_image_urls [ post id :: $post_id ][ image urls count :: " . count( $image_urls ) . " ]" ); |
|
| 301 | 301 | |
| 302 | - return $image_urls; |
|
| 302 | + return $image_urls; |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /** |
@@ -312,19 +312,19 @@ discard block |
||
| 312 | 312 | */ |
| 313 | 313 | function wl_get_sparql_images( $uri, $post_id ) { |
| 314 | 314 | |
| 315 | - $sparql = ''; |
|
| 315 | + $sparql = ''; |
|
| 316 | 316 | |
| 317 | - // Get the escaped URI. |
|
| 318 | - $uri_e = esc_html( $uri ); |
|
| 317 | + // Get the escaped URI. |
|
| 318 | + $uri_e = esc_html( $uri ); |
|
| 319 | 319 | |
| 320 | - // Add SPARQL stmts to write the schema:image. |
|
| 321 | - $image_urls = wl_get_image_urls( $post_id ); |
|
| 322 | - foreach ( $image_urls as $image_url ) { |
|
| 323 | - $image_url_esc = wl_sparql_escape_uri( $image_url ); |
|
| 324 | - $sparql .= " <$uri_e> schema:image <$image_url_esc> . \n"; |
|
| 325 | - } |
|
| 320 | + // Add SPARQL stmts to write the schema:image. |
|
| 321 | + $image_urls = wl_get_image_urls( $post_id ); |
|
| 322 | + foreach ( $image_urls as $image_url ) { |
|
| 323 | + $image_url_esc = wl_sparql_escape_uri( $image_url ); |
|
| 324 | + $sparql .= " <$uri_e> schema:image <$image_url_esc> . \n"; |
|
| 325 | + } |
|
| 326 | 326 | |
| 327 | - return $sparql; |
|
| 327 | + return $sparql; |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | /** |
@@ -337,24 +337,24 @@ discard block |
||
| 337 | 337 | */ |
| 338 | 338 | function wl_get_attachment_for_source_url( $parent_post_id, $source_url ) { |
| 339 | 339 | |
| 340 | - // wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" ); |
|
| 340 | + // wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" ); |
|
| 341 | 341 | |
| 342 | - $posts = get_posts( array( |
|
| 343 | - 'post_type' => 'attachment', |
|
| 344 | - 'posts_per_page' => 1, |
|
| 345 | - 'post_status' => 'any', |
|
| 346 | - 'post_parent' => $parent_post_id, |
|
| 347 | - 'meta_key' => 'wl_source_url', |
|
| 348 | - 'meta_value' => $source_url, |
|
| 349 | - ) ); |
|
| 342 | + $posts = get_posts( array( |
|
| 343 | + 'post_type' => 'attachment', |
|
| 344 | + 'posts_per_page' => 1, |
|
| 345 | + 'post_status' => 'any', |
|
| 346 | + 'post_parent' => $parent_post_id, |
|
| 347 | + 'meta_key' => 'wl_source_url', |
|
| 348 | + 'meta_value' => $source_url, |
|
| 349 | + ) ); |
|
| 350 | 350 | |
| 351 | - // Return the found post. |
|
| 352 | - if ( 1 === count( $posts ) ) { |
|
| 353 | - return $posts[0]; |
|
| 354 | - } |
|
| 351 | + // Return the found post. |
|
| 352 | + if ( 1 === count( $posts ) ) { |
|
| 353 | + return $posts[0]; |
|
| 354 | + } |
|
| 355 | 355 | |
| 356 | - // Return null. |
|
| 357 | - return null; |
|
| 356 | + // Return null. |
|
| 357 | + return null; |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | /** |
@@ -365,8 +365,8 @@ discard block |
||
| 365 | 365 | */ |
| 366 | 366 | function wl_set_source_url( $post_id, $source_url ) { |
| 367 | 367 | |
| 368 | - delete_post_meta( $post_id, 'wl_source_url' ); |
|
| 369 | - add_post_meta( $post_id, 'wl_source_url', $source_url ); |
|
| 368 | + delete_post_meta( $post_id, 'wl_source_url' ); |
|
| 369 | + add_post_meta( $post_id, 'wl_source_url', $source_url ); |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | |
@@ -384,61 +384,61 @@ discard block |
||
| 384 | 384 | */ |
| 385 | 385 | function wl_flush_rewrite_rules_hard( $hard ) { |
| 386 | 386 | |
| 387 | - // If WL is not yet configured, we cannot perform any update, so we exit. |
|
| 388 | - if ( '' === wl_configuration_get_key() ) { |
|
| 389 | - return; |
|
| 390 | - } |
|
| 387 | + // If WL is not yet configured, we cannot perform any update, so we exit. |
|
| 388 | + if ( '' === wl_configuration_get_key() ) { |
|
| 389 | + return; |
|
| 390 | + } |
|
| 391 | 391 | |
| 392 | - // Set the initial offset and limit each call to 100 posts to avoid memory errors. |
|
| 393 | - $offset = 0; |
|
| 394 | - $limit = 100; |
|
| 392 | + // Set the initial offset and limit each call to 100 posts to avoid memory errors. |
|
| 393 | + $offset = 0; |
|
| 394 | + $limit = 100; |
|
| 395 | 395 | |
| 396 | - // Get more posts if the number of returned posts matches the limit. |
|
| 397 | - while ( $limit === ( $posts = get_posts( array( |
|
| 398 | - 'offset' => $offset, |
|
| 399 | - 'numberposts' => $limit, |
|
| 400 | - 'orderby' => 'ID', |
|
| 401 | - 'post_type' => 'any', |
|
| 402 | - 'post_status' => 'publish', |
|
| 403 | - ) ) ) ) { |
|
| 396 | + // Get more posts if the number of returned posts matches the limit. |
|
| 397 | + while ( $limit === ( $posts = get_posts( array( |
|
| 398 | + 'offset' => $offset, |
|
| 399 | + 'numberposts' => $limit, |
|
| 400 | + 'orderby' => 'ID', |
|
| 401 | + 'post_type' => 'any', |
|
| 402 | + 'post_status' => 'publish', |
|
| 403 | + ) ) ) ) { |
|
| 404 | 404 | |
| 405 | - // Holds the delete part of the query. |
|
| 406 | - $delete_query = rl_sparql_prefixes(); |
|
| 405 | + // Holds the delete part of the query. |
|
| 406 | + $delete_query = rl_sparql_prefixes(); |
|
| 407 | 407 | |
| 408 | - // Holds the insert part of the query. |
|
| 409 | - $insert_query = ''; |
|
| 408 | + // Holds the insert part of the query. |
|
| 409 | + $insert_query = ''; |
|
| 410 | 410 | |
| 411 | - // Cycle in each post to build the query. |
|
| 412 | - foreach ( $posts as $post ) { |
|
| 411 | + // Cycle in each post to build the query. |
|
| 412 | + foreach ( $posts as $post ) { |
|
| 413 | 413 | |
| 414 | - // Ignore revisions. |
|
| 415 | - if ( wp_is_post_revision( $post->ID ) ) { |
|
| 416 | - continue; |
|
| 417 | - } |
|
| 414 | + // Ignore revisions. |
|
| 415 | + if ( wp_is_post_revision( $post->ID ) ) { |
|
| 416 | + continue; |
|
| 417 | + } |
|
| 418 | 418 | |
| 419 | - // Get the entity URI. |
|
| 420 | - $s = Wordlift_Sparql_Service::escape_uri( Wordlift_Entity_Service::get_instance() |
|
| 421 | - ->get_uri( $post->ID ) ); |
|
| 419 | + // Get the entity URI. |
|
| 420 | + $s = Wordlift_Sparql_Service::escape_uri( Wordlift_Entity_Service::get_instance() |
|
| 421 | + ->get_uri( $post->ID ) ); |
|
| 422 | 422 | |
| 423 | - // Get the post URL. |
|
| 424 | - // $url = wl_sparql_escape_uri( get_permalink( $post->ID ) ); |
|
| 423 | + // Get the post URL. |
|
| 424 | + // $url = wl_sparql_escape_uri( get_permalink( $post->ID ) ); |
|
| 425 | 425 | |
| 426 | - // Prepare the DELETE and INSERT commands. |
|
| 427 | - $delete_query .= "DELETE { <$s> schema:url ?u . } WHERE { <$s> schema:url ?u . };\n"; |
|
| 426 | + // Prepare the DELETE and INSERT commands. |
|
| 427 | + $delete_query .= "DELETE { <$s> schema:url ?u . } WHERE { <$s> schema:url ?u . };\n"; |
|
| 428 | 428 | |
| 429 | - $insert_query .= Wordlift_Schema_Url_Property_Service::get_instance() |
|
| 430 | - ->get_insert_query( $s, $post->ID ); |
|
| 429 | + $insert_query .= Wordlift_Schema_Url_Property_Service::get_instance() |
|
| 430 | + ->get_insert_query( $s, $post->ID ); |
|
| 431 | 431 | |
| 432 | - } |
|
| 432 | + } |
|
| 433 | 433 | |
| 434 | 434 | |
| 435 | - // Execute the query. |
|
| 436 | - rl_execute_sparql_update_query( $delete_query . $insert_query ); |
|
| 435 | + // Execute the query. |
|
| 436 | + rl_execute_sparql_update_query( $delete_query . $insert_query ); |
|
| 437 | 437 | |
| 438 | - // Advance to the next posts. |
|
| 439 | - $offset += $limit; |
|
| 438 | + // Advance to the next posts. |
|
| 439 | + $offset += $limit; |
|
| 440 | 440 | |
| 441 | - } |
|
| 441 | + } |
|
| 442 | 442 | |
| 443 | 443 | // // Get all published posts. |
| 444 | 444 | // $posts = get_posts( array( |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | */ |
| 465 | 465 | function wl_sanitize_uri_path( $path, $char = '_' ) { |
| 466 | 466 | |
| 467 | - return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char ); |
|
| 467 | + return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char ); |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | /** |
@@ -476,11 +476,11 @@ discard block |
||
| 476 | 476 | */ |
| 477 | 477 | function wl_force_to_array( $value ) { |
| 478 | 478 | |
| 479 | - if ( ! is_array( $value ) ) { |
|
| 480 | - return array( $value ); |
|
| 481 | - } |
|
| 479 | + if ( ! is_array( $value ) ) { |
|
| 480 | + return array( $value ); |
|
| 481 | + } |
|
| 482 | 482 | |
| 483 | - return $value; |
|
| 483 | + return $value; |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | ///** |
@@ -521,46 +521,46 @@ discard block |
||
| 521 | 521 | */ |
| 522 | 522 | function wl_replace_item_id_with_uri( $content ) { |
| 523 | 523 | |
| 524 | - // wl_write_log( "wl_replace_item_id_with_uri" ); |
|
| 524 | + // wl_write_log( "wl_replace_item_id_with_uri" ); |
|
| 525 | 525 | |
| 526 | - // Strip slashes, see https://core.trac.wordpress.org/ticket/21767 |
|
| 527 | - $content = stripslashes( $content ); |
|
| 526 | + // Strip slashes, see https://core.trac.wordpress.org/ticket/21767 |
|
| 527 | + $content = stripslashes( $content ); |
|
| 528 | 528 | |
| 529 | - // If any match are found. |
|
| 530 | - $matches = array(); |
|
| 531 | - if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) { |
|
| 529 | + // If any match are found. |
|
| 530 | + $matches = array(); |
|
| 531 | + if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) { |
|
| 532 | 532 | |
| 533 | - foreach ( $matches as $match ) { |
|
| 533 | + foreach ( $matches as $match ) { |
|
| 534 | 534 | |
| 535 | - // Get the item ID. |
|
| 536 | - $item_id = $match[1]; |
|
| 535 | + // Get the item ID. |
|
| 536 | + $item_id = $match[1]; |
|
| 537 | 537 | |
| 538 | - // Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' . |
|
| 539 | - $post = Wordlift_Entity_Service::get_instance() |
|
| 540 | - ->get_entity_post_by_uri( $item_id ); |
|
| 538 | + // Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' . |
|
| 539 | + $post = Wordlift_Entity_Service::get_instance() |
|
| 540 | + ->get_entity_post_by_uri( $item_id ); |
|
| 541 | 541 | |
| 542 | - // If no entity is found, continue to the next one. |
|
| 543 | - if ( null === $post ) { |
|
| 544 | - continue; |
|
| 545 | - } |
|
| 542 | + // If no entity is found, continue to the next one. |
|
| 543 | + if ( null === $post ) { |
|
| 544 | + continue; |
|
| 545 | + } |
|
| 546 | 546 | |
| 547 | - // Get the URI for that post. |
|
| 548 | - $uri = wl_get_entity_uri( $post->ID ); |
|
| 547 | + // Get the URI for that post. |
|
| 548 | + $uri = wl_get_entity_uri( $post->ID ); |
|
| 549 | 549 | |
| 550 | - // wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" ); |
|
| 550 | + // wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" ); |
|
| 551 | 551 | |
| 552 | - // If the item ID and the URI differ, replace the item ID with the URI saved in WordPress. |
|
| 553 | - if ( $item_id !== $uri ) { |
|
| 554 | - $uri_e = esc_html( $uri ); |
|
| 555 | - $content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content ); |
|
| 556 | - } |
|
| 557 | - } |
|
| 558 | - } |
|
| 552 | + // If the item ID and the URI differ, replace the item ID with the URI saved in WordPress. |
|
| 553 | + if ( $item_id !== $uri ) { |
|
| 554 | + $uri_e = esc_html( $uri ); |
|
| 555 | + $content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content ); |
|
| 556 | + } |
|
| 557 | + } |
|
| 558 | + } |
|
| 559 | 559 | |
| 560 | - // Reapply slashes. |
|
| 561 | - $content = addslashes( $content ); |
|
| 560 | + // Reapply slashes. |
|
| 561 | + $content = addslashes( $content ); |
|
| 562 | 562 | |
| 563 | - return $content; |
|
| 563 | + return $content; |
|
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | add_filter( 'content_save_pre', 'wl_replace_item_id_with_uri', 1, 1 ); |
@@ -629,8 +629,8 @@ discard block |
||
| 629 | 629 | * This action is documented in includes/class-wordlift-activator.php |
| 630 | 630 | */ |
| 631 | 631 | function activate_wordlift() { |
| 632 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php'; |
|
| 633 | - Wordlift_Activator::activate(); |
|
| 632 | + require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php'; |
|
| 633 | + Wordlift_Activator::activate(); |
|
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | /** |
@@ -638,8 +638,8 @@ discard block |
||
| 638 | 638 | * This action is documented in includes/class-wordlift-deactivator.php |
| 639 | 639 | */ |
| 640 | 640 | function deactivate_wordlift() { |
| 641 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php'; |
|
| 642 | - Wordlift_Deactivator::deactivate(); |
|
| 641 | + require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php'; |
|
| 642 | + Wordlift_Deactivator::deactivate(); |
|
| 643 | 643 | } |
| 644 | 644 | |
| 645 | 645 | register_activation_hook( __FILE__, 'activate_wordlift' ); |
@@ -662,8 +662,8 @@ discard block |
||
| 662 | 662 | */ |
| 663 | 663 | function run_wordlift() { |
| 664 | 664 | |
| 665 | - $plugin = new Wordlift(); |
|
| 666 | - $plugin->run(); |
|
| 665 | + $plugin = new Wordlift(); |
|
| 666 | + $plugin->run(); |
|
| 667 | 667 | |
| 668 | 668 | } |
| 669 | 669 | |
@@ -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 | ///** |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | function wordlift_allowed_post_tags() { |
| 140 | 140 | global $allowedposttags; |
| 141 | 141 | |
| 142 | - $tags = array( 'span' ); |
|
| 142 | + $tags = array('span'); |
|
| 143 | 143 | $new_attributes = array( |
| 144 | 144 | 'itemscope' => array(), |
| 145 | 145 | 'itemtype' => array(), |
@@ -147,9 +147,9 @@ discard block |
||
| 147 | 147 | 'itemid' => array(), |
| 148 | 148 | ); |
| 149 | 149 | |
| 150 | - foreach ( $tags as $tag ) { |
|
| 151 | - if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) { |
|
| 152 | - $allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes ); |
|
| 150 | + foreach ($tags as $tag) { |
|
| 151 | + if (isset($allowedposttags[$tag]) && is_array($allowedposttags[$tag])) { |
|
| 152 | + $allowedposttags[$tag] = array_merge($allowedposttags[$tag], $new_attributes); |
|
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | } |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | //add_action( 'init', 'wordlift_buttonhooks' ); |
| 159 | 159 | |
| 160 | 160 | // add allowed post tags. |
| 161 | -add_action( 'init', 'wordlift_allowed_post_tags' ); |
|
| 161 | +add_action('init', 'wordlift_allowed_post_tags'); |
|
| 162 | 162 | |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -167,30 +167,30 @@ discard block |
||
| 167 | 167 | function wordlift_admin_enqueue_scripts() { |
| 168 | 168 | |
| 169 | 169 | // Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/) |
| 170 | - wp_enqueue_script( 'wpdialogs' ); |
|
| 171 | - wp_enqueue_style( 'wp-jquery-ui-dialog' ); |
|
| 170 | + wp_enqueue_script('wpdialogs'); |
|
| 171 | + wp_enqueue_style('wp-jquery-ui-dialog'); |
|
| 172 | 172 | |
| 173 | - wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css' ); |
|
| 173 | + wp_enqueue_style('wordlift-reloaded', plugin_dir_url(__FILE__).'css/wordlift-reloaded.min.css'); |
|
| 174 | 174 | |
| 175 | - wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
| 176 | - wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' ); |
|
| 177 | - wp_enqueue_script( 'angularjs-geolocation', plugin_dir_url( __FILE__ ) . '/bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js' ); |
|
| 178 | - wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js' ); |
|
| 179 | - wp_enqueue_script( 'angularjs-animate', 'https://code.angularjs.org/1.3.11/angular-animate.min.js' ); |
|
| 175 | + wp_enqueue_script('jquery-ui-autocomplete'); |
|
| 176 | + wp_enqueue_script('angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js'); |
|
| 177 | + wp_enqueue_script('angularjs-geolocation', plugin_dir_url(__FILE__).'/bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js'); |
|
| 178 | + wp_enqueue_script('angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js'); |
|
| 179 | + wp_enqueue_script('angularjs-animate', 'https://code.angularjs.org/1.3.11/angular-animate.min.js'); |
|
| 180 | 180 | |
| 181 | 181 | // Disable auto-save for custom entity posts only |
| 182 | - if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) { |
|
| 183 | - wp_dequeue_script( 'autosave' ); |
|
| 182 | + if (Wordlift_Entity_Service::TYPE_NAME === get_post_type()) { |
|
| 183 | + wp_dequeue_script('autosave'); |
|
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | -add_action( 'admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts' ); |
|
| 187 | +add_action('admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts'); |
|
| 188 | 188 | |
| 189 | 189 | function wl_enqueue_scripts() { |
| 190 | - wp_enqueue_style( 'wordlift-ui', plugin_dir_url( __FILE__ ) . 'css/wordlift-ui.min.css' ); |
|
| 190 | + wp_enqueue_style('wordlift-ui', plugin_dir_url(__FILE__).'css/wordlift-ui.min.css'); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | -add_action( 'wp_enqueue_scripts', 'wl_enqueue_scripts' ); |
|
| 193 | +add_action('wp_enqueue_scripts', 'wl_enqueue_scripts'); |
|
| 194 | 194 | |
| 195 | 195 | /** |
| 196 | 196 | * Hooked to *wp_kses_allowed_html* filter, adds microdata attributes. |
@@ -200,23 +200,23 @@ discard block |
||
| 200 | 200 | * |
| 201 | 201 | * @return array An array which contains allowed microdata attributes. |
| 202 | 202 | */ |
| 203 | -function wordlift_allowed_html( $allowedtags, $context ) { |
|
| 203 | +function wordlift_allowed_html($allowedtags, $context) { |
|
| 204 | 204 | |
| 205 | - if ( 'post' !== $context ) { |
|
| 205 | + if ('post' !== $context) { |
|
| 206 | 206 | return $allowedtags; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - return array_merge_recursive( $allowedtags, array( |
|
| 209 | + return array_merge_recursive($allowedtags, array( |
|
| 210 | 210 | 'span' => array( |
| 211 | 211 | 'itemscope' => true, |
| 212 | 212 | 'itemtype' => true, |
| 213 | 213 | 'itemid' => true, |
| 214 | 214 | 'itemprop' => true, |
| 215 | 215 | ), |
| 216 | - ) ); |
|
| 216 | + )); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | -add_filter( 'wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2 ); |
|
| 219 | +add_filter('wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2); |
|
| 220 | 220 | |
| 221 | 221 | /** |
| 222 | 222 | * Get the coordinates for the specified post ID. |
@@ -225,17 +225,17 @@ discard block |
||
| 225 | 225 | * |
| 226 | 226 | * @return array|null An array of coordinates or null. |
| 227 | 227 | */ |
| 228 | -function wl_get_coordinates( $post_id ) { |
|
| 228 | +function wl_get_coordinates($post_id) { |
|
| 229 | 229 | |
| 230 | - $latitude = wl_schema_get_value( $post_id, 'latitude' ); |
|
| 231 | - $longitude = wl_schema_get_value( $post_id, 'longitude' ); |
|
| 230 | + $latitude = wl_schema_get_value($post_id, 'latitude'); |
|
| 231 | + $longitude = wl_schema_get_value($post_id, 'longitude'); |
|
| 232 | 232 | |
| 233 | 233 | // DO NOT set latitude/longitude to 0/0 as default values. It's a specific |
| 234 | 234 | // place on the globe:"The zero/zero point of this system is located in the |
| 235 | 235 | // Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana." |
| 236 | 236 | return array( |
| 237 | - 'latitude' => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '', |
|
| 238 | - 'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '', |
|
| 237 | + 'latitude' => isset($latitude[0]) && is_numeric($latitude[0]) ? $latitude[0] : '', |
|
| 238 | + 'longitude' => isset($longitude[0]) && is_numeric($longitude[0]) ? $longitude[0] : '', |
|
| 239 | 239 | ); |
| 240 | 240 | } |
| 241 | 241 | |
@@ -246,12 +246,12 @@ discard block |
||
| 246 | 246 | * |
| 247 | 247 | * @return string A datetime. |
| 248 | 248 | */ |
| 249 | -function wl_get_post_modified_time( $post ) { |
|
| 249 | +function wl_get_post_modified_time($post) { |
|
| 250 | 250 | |
| 251 | - $date_modified = get_post_modified_time( 'c', true, $post ); |
|
| 251 | + $date_modified = get_post_modified_time('c', true, $post); |
|
| 252 | 252 | |
| 253 | - if ( '-' === substr( $date_modified, 0, 1 ) ) { |
|
| 254 | - return get_the_time( 'c', $post ); |
|
| 253 | + if ('-' === substr($date_modified, 0, 1)) { |
|
| 254 | + return get_the_time('c', $post); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | return $date_modified; |
@@ -264,24 +264,24 @@ discard block |
||
| 264 | 264 | * |
| 265 | 265 | * @return array An array of image URLs. |
| 266 | 266 | */ |
| 267 | -function wl_get_image_urls( $post_id ) { |
|
| 267 | +function wl_get_image_urls($post_id) { |
|
| 268 | 268 | |
| 269 | 269 | // If there is a featured image it has the priority. |
| 270 | - $featured_image_id = get_post_thumbnail_id( $post_id ); |
|
| 271 | - if ( is_numeric( $featured_image_id ) ) { |
|
| 272 | - $image_url = wp_get_attachment_url( $featured_image_id ); |
|
| 270 | + $featured_image_id = get_post_thumbnail_id($post_id); |
|
| 271 | + if (is_numeric($featured_image_id)) { |
|
| 272 | + $image_url = wp_get_attachment_url($featured_image_id); |
|
| 273 | 273 | |
| 274 | - return array( $image_url ); |
|
| 274 | + return array($image_url); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - $images = get_children( array( |
|
| 277 | + $images = get_children(array( |
|
| 278 | 278 | 'post_parent' => $post_id, |
| 279 | 279 | 'post_type' => 'attachment', |
| 280 | 280 | 'post_mime_type' => 'image', |
| 281 | - ) ); |
|
| 281 | + )); |
|
| 282 | 282 | |
| 283 | 283 | // Return an empty array if no image is found. |
| 284 | - if ( empty( $images ) ) { |
|
| 284 | + if (empty($images)) { |
|
| 285 | 285 | return array(); |
| 286 | 286 | } |
| 287 | 287 | |
@@ -289,11 +289,11 @@ discard block |
||
| 289 | 289 | $image_urls = array(); |
| 290 | 290 | |
| 291 | 291 | // Collect the URLs. |
| 292 | - foreach ( $images as $attachment_id => $attachment ) { |
|
| 293 | - $image_url = wp_get_attachment_url( $attachment_id ); |
|
| 292 | + foreach ($images as $attachment_id => $attachment) { |
|
| 293 | + $image_url = wp_get_attachment_url($attachment_id); |
|
| 294 | 294 | // Ensure the URL isn't collected already. |
| 295 | - if ( ! in_array( $image_url, $image_urls ) ) { |
|
| 296 | - array_push( $image_urls, $image_url ); |
|
| 295 | + if ( ! in_array($image_url, $image_urls)) { |
|
| 296 | + array_push($image_urls, $image_url); |
|
| 297 | 297 | } |
| 298 | 298 | } |
| 299 | 299 | |
@@ -310,18 +310,18 @@ discard block |
||
| 310 | 310 | * |
| 311 | 311 | * @return string The SPARQL fragment. |
| 312 | 312 | */ |
| 313 | -function wl_get_sparql_images( $uri, $post_id ) { |
|
| 313 | +function wl_get_sparql_images($uri, $post_id) { |
|
| 314 | 314 | |
| 315 | 315 | $sparql = ''; |
| 316 | 316 | |
| 317 | 317 | // Get the escaped URI. |
| 318 | - $uri_e = esc_html( $uri ); |
|
| 318 | + $uri_e = esc_html($uri); |
|
| 319 | 319 | |
| 320 | 320 | // Add SPARQL stmts to write the schema:image. |
| 321 | - $image_urls = wl_get_image_urls( $post_id ); |
|
| 322 | - foreach ( $image_urls as $image_url ) { |
|
| 323 | - $image_url_esc = wl_sparql_escape_uri( $image_url ); |
|
| 324 | - $sparql .= " <$uri_e> schema:image <$image_url_esc> . \n"; |
|
| 321 | + $image_urls = wl_get_image_urls($post_id); |
|
| 322 | + foreach ($image_urls as $image_url) { |
|
| 323 | + $image_url_esc = wl_sparql_escape_uri($image_url); |
|
| 324 | + $sparql .= " <$uri_e> schema:image <$image_url_esc> . \n"; |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | return $sparql; |
@@ -335,21 +335,21 @@ discard block |
||
| 335 | 335 | * |
| 336 | 336 | * @return WP_Post|null A post instance or null if not found. |
| 337 | 337 | */ |
| 338 | -function wl_get_attachment_for_source_url( $parent_post_id, $source_url ) { |
|
| 338 | +function wl_get_attachment_for_source_url($parent_post_id, $source_url) { |
|
| 339 | 339 | |
| 340 | 340 | // wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" ); |
| 341 | 341 | |
| 342 | - $posts = get_posts( array( |
|
| 342 | + $posts = get_posts(array( |
|
| 343 | 343 | 'post_type' => 'attachment', |
| 344 | 344 | 'posts_per_page' => 1, |
| 345 | 345 | 'post_status' => 'any', |
| 346 | 346 | 'post_parent' => $parent_post_id, |
| 347 | 347 | 'meta_key' => 'wl_source_url', |
| 348 | 348 | 'meta_value' => $source_url, |
| 349 | - ) ); |
|
| 349 | + )); |
|
| 350 | 350 | |
| 351 | 351 | // Return the found post. |
| 352 | - if ( 1 === count( $posts ) ) { |
|
| 352 | + if (1 === count($posts)) { |
|
| 353 | 353 | return $posts[0]; |
| 354 | 354 | } |
| 355 | 355 | |
@@ -363,10 +363,10 @@ discard block |
||
| 363 | 363 | * @param int $post_id The post ID. |
| 364 | 364 | * @param string $source_url The source URL. |
| 365 | 365 | */ |
| 366 | -function wl_set_source_url( $post_id, $source_url ) { |
|
| 366 | +function wl_set_source_url($post_id, $source_url) { |
|
| 367 | 367 | |
| 368 | - delete_post_meta( $post_id, 'wl_source_url' ); |
|
| 369 | - add_post_meta( $post_id, 'wl_source_url', $source_url ); |
|
| 368 | + delete_post_meta($post_id, 'wl_source_url'); |
|
| 369 | + add_post_meta($post_id, 'wl_source_url', $source_url); |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | |
@@ -382,10 +382,10 @@ discard block |
||
| 382 | 382 | * |
| 383 | 383 | * @param bool $hard True if the rewrite involves configuration updates in Apache/IIS. |
| 384 | 384 | */ |
| 385 | -function wl_flush_rewrite_rules_hard( $hard ) { |
|
| 385 | +function wl_flush_rewrite_rules_hard($hard) { |
|
| 386 | 386 | |
| 387 | 387 | // If WL is not yet configured, we cannot perform any update, so we exit. |
| 388 | - if ( '' === wl_configuration_get_key() ) { |
|
| 388 | + if ('' === wl_configuration_get_key()) { |
|
| 389 | 389 | return; |
| 390 | 390 | } |
| 391 | 391 | |
@@ -394,13 +394,13 @@ discard block |
||
| 394 | 394 | $limit = 100; |
| 395 | 395 | |
| 396 | 396 | // Get more posts if the number of returned posts matches the limit. |
| 397 | - while ( $limit === ( $posts = get_posts( array( |
|
| 397 | + while ($limit === ($posts = get_posts(array( |
|
| 398 | 398 | 'offset' => $offset, |
| 399 | 399 | 'numberposts' => $limit, |
| 400 | 400 | 'orderby' => 'ID', |
| 401 | 401 | 'post_type' => 'any', |
| 402 | 402 | 'post_status' => 'publish', |
| 403 | - ) ) ) ) { |
|
| 403 | + )))) { |
|
| 404 | 404 | |
| 405 | 405 | // Holds the delete part of the query. |
| 406 | 406 | $delete_query = rl_sparql_prefixes(); |
@@ -409,16 +409,16 @@ discard block |
||
| 409 | 409 | $insert_query = ''; |
| 410 | 410 | |
| 411 | 411 | // Cycle in each post to build the query. |
| 412 | - foreach ( $posts as $post ) { |
|
| 412 | + foreach ($posts as $post) { |
|
| 413 | 413 | |
| 414 | 414 | // Ignore revisions. |
| 415 | - if ( wp_is_post_revision( $post->ID ) ) { |
|
| 415 | + if (wp_is_post_revision($post->ID)) { |
|
| 416 | 416 | continue; |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | // Get the entity URI. |
| 420 | - $s = Wordlift_Sparql_Service::escape_uri( Wordlift_Entity_Service::get_instance() |
|
| 421 | - ->get_uri( $post->ID ) ); |
|
| 420 | + $s = Wordlift_Sparql_Service::escape_uri(Wordlift_Entity_Service::get_instance() |
|
| 421 | + ->get_uri($post->ID)); |
|
| 422 | 422 | |
| 423 | 423 | // Get the post URL. |
| 424 | 424 | // $url = wl_sparql_escape_uri( get_permalink( $post->ID ) ); |
@@ -427,13 +427,13 @@ discard block |
||
| 427 | 427 | $delete_query .= "DELETE { <$s> schema:url ?u . } WHERE { <$s> schema:url ?u . };\n"; |
| 428 | 428 | |
| 429 | 429 | $insert_query .= Wordlift_Schema_Url_Property_Service::get_instance() |
| 430 | - ->get_insert_query( $s, $post->ID ); |
|
| 430 | + ->get_insert_query($s, $post->ID); |
|
| 431 | 431 | |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | |
| 435 | 435 | // Execute the query. |
| 436 | - rl_execute_sparql_update_query( $delete_query . $insert_query ); |
|
| 436 | + rl_execute_sparql_update_query($delete_query.$insert_query); |
|
| 437 | 437 | |
| 438 | 438 | // Advance to the next posts. |
| 439 | 439 | $offset += $limit; |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | -add_filter( 'flush_rewrite_rules_hard', 'wl_flush_rewrite_rules_hard', 10, 1 ); |
|
| 452 | +add_filter('flush_rewrite_rules_hard', 'wl_flush_rewrite_rules_hard', 10, 1); |
|
| 453 | 453 | |
| 454 | 454 | /** |
| 455 | 455 | * Sanitizes an URI path by replacing the non allowed characters with an underscore. |
@@ -462,9 +462,9 @@ discard block |
||
| 462 | 462 | * |
| 463 | 463 | * @return string The sanitized path. |
| 464 | 464 | */ |
| 465 | -function wl_sanitize_uri_path( $path, $char = '_' ) { |
|
| 465 | +function wl_sanitize_uri_path($path, $char = '_') { |
|
| 466 | 466 | |
| 467 | - return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char ); |
|
| 467 | + return Wordlift_Uri_Service::get_instance()->sanitize_path($path, $char); |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | /** |
@@ -474,10 +474,10 @@ discard block |
||
| 474 | 474 | * |
| 475 | 475 | * @return array Array containing $value (if $value was not an array) |
| 476 | 476 | */ |
| 477 | -function wl_force_to_array( $value ) { |
|
| 477 | +function wl_force_to_array($value) { |
|
| 478 | 478 | |
| 479 | - if ( ! is_array( $value ) ) { |
|
| 480 | - return array( $value ); |
|
| 479 | + if ( ! is_array($value)) { |
|
| 480 | + return array($value); |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | return $value; |
@@ -519,109 +519,109 @@ discard block |
||
| 519 | 519 | * |
| 520 | 520 | * @return string The updated post content. |
| 521 | 521 | */ |
| 522 | -function wl_replace_item_id_with_uri( $content ) { |
|
| 522 | +function wl_replace_item_id_with_uri($content) { |
|
| 523 | 523 | |
| 524 | 524 | // wl_write_log( "wl_replace_item_id_with_uri" ); |
| 525 | 525 | |
| 526 | 526 | // Strip slashes, see https://core.trac.wordpress.org/ticket/21767 |
| 527 | - $content = stripslashes( $content ); |
|
| 527 | + $content = stripslashes($content); |
|
| 528 | 528 | |
| 529 | 529 | // If any match are found. |
| 530 | 530 | $matches = array(); |
| 531 | - if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) { |
|
| 531 | + if (0 < preg_match_all('/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER)) { |
|
| 532 | 532 | |
| 533 | - foreach ( $matches as $match ) { |
|
| 533 | + foreach ($matches as $match) { |
|
| 534 | 534 | |
| 535 | 535 | // Get the item ID. |
| 536 | 536 | $item_id = $match[1]; |
| 537 | 537 | |
| 538 | 538 | // Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' . |
| 539 | 539 | $post = Wordlift_Entity_Service::get_instance() |
| 540 | - ->get_entity_post_by_uri( $item_id ); |
|
| 540 | + ->get_entity_post_by_uri($item_id); |
|
| 541 | 541 | |
| 542 | 542 | // If no entity is found, continue to the next one. |
| 543 | - if ( null === $post ) { |
|
| 543 | + if (null === $post) { |
|
| 544 | 544 | continue; |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | // Get the URI for that post. |
| 548 | - $uri = wl_get_entity_uri( $post->ID ); |
|
| 548 | + $uri = wl_get_entity_uri($post->ID); |
|
| 549 | 549 | |
| 550 | 550 | // wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" ); |
| 551 | 551 | |
| 552 | 552 | // If the item ID and the URI differ, replace the item ID with the URI saved in WordPress. |
| 553 | - if ( $item_id !== $uri ) { |
|
| 554 | - $uri_e = esc_html( $uri ); |
|
| 555 | - $content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content ); |
|
| 553 | + if ($item_id !== $uri) { |
|
| 554 | + $uri_e = esc_html($uri); |
|
| 555 | + $content = str_replace(" itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content); |
|
| 556 | 556 | } |
| 557 | 557 | } |
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | // Reapply slashes. |
| 561 | - $content = addslashes( $content ); |
|
| 561 | + $content = addslashes($content); |
|
| 562 | 562 | |
| 563 | 563 | return $content; |
| 564 | 564 | } |
| 565 | 565 | |
| 566 | -add_filter( 'content_save_pre', 'wl_replace_item_id_with_uri', 1, 1 ); |
|
| 566 | +add_filter('content_save_pre', 'wl_replace_item_id_with_uri', 1, 1); |
|
| 567 | 567 | |
| 568 | -require_once( 'wordlift_entity_functions.php' ); |
|
| 568 | +require_once('wordlift_entity_functions.php'); |
|
| 569 | 569 | |
| 570 | 570 | // add editor related methods. |
| 571 | -require_once( 'wordlift_editor.php' ); |
|
| 571 | +require_once('wordlift_editor.php'); |
|
| 572 | 572 | |
| 573 | 573 | // add the WordLift entity custom type. |
| 574 | -require_once( 'wordlift_entity_type.php' ); |
|
| 575 | -require_once( 'wordlift_entity_type_taxonomy.php' ); |
|
| 574 | +require_once('wordlift_entity_type.php'); |
|
| 575 | +require_once('wordlift_entity_type_taxonomy.php'); |
|
| 576 | 576 | |
| 577 | 577 | // add callbacks on post save to notify data changes from wp to redlink triple store |
| 578 | -require_once( 'wordlift_to_redlink_data_push_callbacks.php' ); |
|
| 578 | +require_once('wordlift_to_redlink_data_push_callbacks.php'); |
|
| 579 | 579 | |
| 580 | -require_once( 'modules/configuration/wordlift_configuration_settings.php' ); |
|
| 580 | +require_once('modules/configuration/wordlift_configuration_settings.php'); |
|
| 581 | 581 | |
| 582 | 582 | // Load modules |
| 583 | -require_once( 'modules/analyzer/wordlift_analyzer.php' ); |
|
| 584 | -require_once( 'modules/linked_data/wordlift_linked_data.php' ); |
|
| 585 | -require_once( 'modules/prefixes/wordlift_prefixes.php' ); |
|
| 586 | -require_once( 'modules/redirector/wordlift_redirector.php' ); |
|
| 583 | +require_once('modules/analyzer/wordlift_analyzer.php'); |
|
| 584 | +require_once('modules/linked_data/wordlift_linked_data.php'); |
|
| 585 | +require_once('modules/prefixes/wordlift_prefixes.php'); |
|
| 586 | +require_once('modules/redirector/wordlift_redirector.php'); |
|
| 587 | 587 | |
| 588 | 588 | // Shortcodes |
| 589 | 589 | |
| 590 | -require_once( 'modules/geo_widget/wordlift_geo_widget.php' ); |
|
| 591 | -require_once( 'shortcodes/wordlift_shortcode_chord.php' ); |
|
| 592 | -require_once( 'shortcodes/wordlift_shortcode_geomap.php' ); |
|
| 593 | -require_once( 'shortcodes/wordlift_shortcode_field.php' ); |
|
| 594 | -require_once( 'shortcodes/wordlift_shortcode_faceted_search.php' ); |
|
| 595 | -require_once( 'shortcodes/wordlift_shortcode_navigator.php' ); |
|
| 590 | +require_once('modules/geo_widget/wordlift_geo_widget.php'); |
|
| 591 | +require_once('shortcodes/wordlift_shortcode_chord.php'); |
|
| 592 | +require_once('shortcodes/wordlift_shortcode_geomap.php'); |
|
| 593 | +require_once('shortcodes/wordlift_shortcode_field.php'); |
|
| 594 | +require_once('shortcodes/wordlift_shortcode_faceted_search.php'); |
|
| 595 | +require_once('shortcodes/wordlift_shortcode_navigator.php'); |
|
| 596 | 596 | |
| 597 | -require_once( 'widgets/wordlift_widget_geo.php' ); |
|
| 598 | -require_once( 'widgets/wordlift_widget_chord.php' ); |
|
| 599 | -require_once( 'widgets/wordlift_widget_timeline.php' ); |
|
| 597 | +require_once('widgets/wordlift_widget_geo.php'); |
|
| 598 | +require_once('widgets/wordlift_widget_chord.php'); |
|
| 599 | +require_once('widgets/wordlift_widget_timeline.php'); |
|
| 600 | 600 | |
| 601 | -require_once( 'wordlift_sparql.php' ); |
|
| 602 | -require_once( 'wordlift_redlink.php' ); |
|
| 601 | +require_once('wordlift_sparql.php'); |
|
| 602 | +require_once('wordlift_redlink.php'); |
|
| 603 | 603 | |
| 604 | 604 | // Add admin functions. |
| 605 | 605 | // TODO: find a way to make 'admin' UI tests work. |
| 606 | 606 | //if ( is_admin() ) { |
| 607 | 607 | |
| 608 | -require_once( 'admin/wordlift_admin.php' ); |
|
| 609 | -require_once( 'admin/wordlift_admin_edit_post.php' ); |
|
| 610 | -require_once( 'admin/wordlift_admin_save_post.php' ); |
|
| 608 | +require_once('admin/wordlift_admin.php'); |
|
| 609 | +require_once('admin/wordlift_admin_edit_post.php'); |
|
| 610 | +require_once('admin/wordlift_admin_save_post.php'); |
|
| 611 | 611 | |
| 612 | 612 | // add the entities meta box. |
| 613 | -require_once( 'admin/wordlift_admin_meta_box_entities.php' ); |
|
| 613 | +require_once('admin/wordlift_admin_meta_box_entities.php'); |
|
| 614 | 614 | |
| 615 | 615 | // add the entity creation AJAX. |
| 616 | -require_once( 'admin/wordlift_admin_ajax_related_posts.php' ); |
|
| 616 | +require_once('admin/wordlift_admin_ajax_related_posts.php'); |
|
| 617 | 617 | |
| 618 | 618 | // Load the wl_chord TinyMCE button and configuration dialog. |
| 619 | -require_once( 'admin/wordlift_admin_shortcodes.php' ); |
|
| 619 | +require_once('admin/wordlift_admin_shortcodes.php'); |
|
| 620 | 620 | |
| 621 | 621 | // load languages. |
| 622 | 622 | // TODO: the following call gives for granted that the plugin is in the wordlift directory, |
| 623 | 623 | // we're currently doing this because wordlift is symbolic linked. |
| 624 | -load_plugin_textdomain( 'wordlift', false, '/wordlift/languages' ); |
|
| 624 | +load_plugin_textdomain('wordlift', false, '/wordlift/languages'); |
|
| 625 | 625 | |
| 626 | 626 | |
| 627 | 627 | /** |
@@ -629,7 +629,7 @@ discard block |
||
| 629 | 629 | * This action is documented in includes/class-wordlift-activator.php |
| 630 | 630 | */ |
| 631 | 631 | function activate_wordlift() { |
| 632 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php'; |
|
| 632 | + require_once plugin_dir_path(__FILE__).'includes/class-wordlift-activator.php'; |
|
| 633 | 633 | Wordlift_Activator::activate(); |
| 634 | 634 | } |
| 635 | 635 | |
@@ -638,18 +638,18 @@ discard block |
||
| 638 | 638 | * This action is documented in includes/class-wordlift-deactivator.php |
| 639 | 639 | */ |
| 640 | 640 | function deactivate_wordlift() { |
| 641 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php'; |
|
| 641 | + require_once plugin_dir_path(__FILE__).'includes/class-wordlift-deactivator.php'; |
|
| 642 | 642 | Wordlift_Deactivator::deactivate(); |
| 643 | 643 | } |
| 644 | 644 | |
| 645 | -register_activation_hook( __FILE__, 'activate_wordlift' ); |
|
| 646 | -register_deactivation_hook( __FILE__, 'deactivate_wordlift' ); |
|
| 645 | +register_activation_hook(__FILE__, 'activate_wordlift'); |
|
| 646 | +register_deactivation_hook(__FILE__, 'deactivate_wordlift'); |
|
| 647 | 647 | |
| 648 | 648 | /** |
| 649 | 649 | * The core plugin class that is used to define internationalization, |
| 650 | 650 | * admin-specific hooks, and public-facing site hooks. |
| 651 | 651 | */ |
| 652 | -require plugin_dir_path( __FILE__ ) . 'includes/class-wordlift.php'; |
|
| 652 | +require plugin_dir_path(__FILE__).'includes/class-wordlift.php'; |
|
| 653 | 653 | |
| 654 | 654 | /** |
| 655 | 655 | * Begins execution of the plugin. |