@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | // Use the WordLift API URL set on the command line. |
15 | 15 | if ( ! defined( 'WORDLIFT_API_URL' ) && false !== getenv( 'WORDLIFT_API_URL' ) ) { |
16 | - define( 'WORDLIFT_API_URL', getenv( 'WORDLIFT_API_URL' ) ); |
|
16 | + define( 'WORDLIFT_API_URL', getenv( 'WORDLIFT_API_URL' ) ); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | // 3.13.0, we use by default WLS 1.11 which provides us with the new, faster |
@@ -52,15 +52,15 @@ discard block |
||
52 | 52 | * @since 3.16.0 |
53 | 53 | */ |
54 | 54 | function wl_temp_dir() { |
55 | - $tempdir = get_temp_dir(); |
|
56 | - $unique = md5( site_url() . get_current_blog_id() ); |
|
57 | - $unique_temp_dir = $tempdir . 'wl_' . $unique; // $tempdir should have a trailing slash. |
|
55 | + $tempdir = get_temp_dir(); |
|
56 | + $unique = md5( site_url() . get_current_blog_id() ); |
|
57 | + $unique_temp_dir = $tempdir . 'wl_' . $unique; // $tempdir should have a trailing slash. |
|
58 | 58 | |
59 | - // If directory do not exist, create it. |
|
60 | - if ( ! file_exists( $unique_temp_dir ) ) { |
|
61 | - // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged |
|
62 | - @mkdir( $unique_temp_dir ); |
|
63 | - } |
|
59 | + // If directory do not exist, create it. |
|
60 | + if ( ! file_exists( $unique_temp_dir ) ) { |
|
61 | + // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged |
|
62 | + @mkdir( $unique_temp_dir ); |
|
63 | + } |
|
64 | 64 | |
65 | - return $unique_temp_dir . '/'; |
|
65 | + return $unique_temp_dir . '/'; |
|
66 | 66 | } |
@@ -6,40 +6,40 @@ discard block |
||
6 | 6 | */ |
7 | 7 | |
8 | 8 | // Set the temporary files folder. |
9 | -defined( 'WL_TEMP_DIR' ) || define( 'WL_TEMP_DIR', wl_temp_dir() ); |
|
9 | +defined('WL_TEMP_DIR') || define('WL_TEMP_DIR', wl_temp_dir()); |
|
10 | 10 | |
11 | 11 | // Define the meta name used to store the entity URL. |
12 | -define( 'WL_ENTITY_URL_META_NAME', 'entity_url' ); |
|
12 | +define('WL_ENTITY_URL_META_NAME', 'entity_url'); |
|
13 | 13 | |
14 | 14 | // Use the WordLift API URL set on the command line. |
15 | -if ( ! defined( 'WORDLIFT_API_URL' ) && false !== getenv( 'WORDLIFT_API_URL' ) ) { |
|
16 | - define( 'WORDLIFT_API_URL', getenv( 'WORDLIFT_API_URL' ) ); |
|
15 | +if ( ! defined('WORDLIFT_API_URL') && false !== getenv('WORDLIFT_API_URL')) { |
|
16 | + define('WORDLIFT_API_URL', getenv('WORDLIFT_API_URL')); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | // 3.13.0, we use by default WLS 1.11 which provides us with the new, faster |
20 | 20 | // chunked analysis. |
21 | -define( 'WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE', defined( 'WORDLIFT_API_URL' ) ? WORDLIFT_API_URL . '/' : 'https://api.wordlift.io/' ); |
|
21 | +define('WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE', defined('WORDLIFT_API_URL') ? WORDLIFT_API_URL . '/' : 'https://api.wordlift.io/'); |
|
22 | 22 | |
23 | 23 | // @since 3.29.0 we do not use https://developers.google.com/structured-data/testing-tool/?url= |
24 | -define( 'WL_CONFIG_TEST_GOOGLE_RICH_SNIPPETS_URL', 'https://search.google.com/test/rich-results?url=' ); |
|
24 | +define('WL_CONFIG_TEST_GOOGLE_RICH_SNIPPETS_URL', 'https://search.google.com/test/rich-results?url='); |
|
25 | 25 | |
26 | 26 | // If is set to true, there will be additional button in 'Download Your Data' page |
27 | 27 | // that will allow users to download their data in JSON-LD format. |
28 | -defined( 'WL_CONFIG_DOWNLOAD_GA_CONTENT_DATA' ) || define( 'WL_CONFIG_DOWNLOAD_GA_CONTENT_DATA', false ); |
|
28 | +defined('WL_CONFIG_DOWNLOAD_GA_CONTENT_DATA') || define('WL_CONFIG_DOWNLOAD_GA_CONTENT_DATA', false); |
|
29 | 29 | |
30 | 30 | /* |
31 | 31 | * Define the default scope for autocomplete requests. |
32 | 32 | * |
33 | 33 | * @see https://github.com/insideout10/wordlift-plugin/issues/839 |
34 | 34 | */ |
35 | -defined( 'WL_AUTOCOMPLETE_SCOPE' ) || define( 'WL_AUTOCOMPLETE_SCOPE', 'cloud' ); |
|
35 | +defined('WL_AUTOCOMPLETE_SCOPE') || define('WL_AUTOCOMPLETE_SCOPE', 'cloud'); |
|
36 | 36 | |
37 | 37 | /* |
38 | 38 | * Enable/disable the `all entity types` feature. Initially we keep the feature disabled to enture proper Q/A. |
39 | 39 | * |
40 | 40 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
41 | 41 | */ |
42 | -defined( 'WL_ALL_ENTITY_TYPES' ) || define( 'WL_ALL_ENTITY_TYPES', false ); |
|
42 | +defined('WL_ALL_ENTITY_TYPES') || define('WL_ALL_ENTITY_TYPES', false); |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * Get a site unique directory under the system or WordPress temporary directory. |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | */ |
54 | 54 | function wl_temp_dir() { |
55 | 55 | $tempdir = get_temp_dir(); |
56 | - $unique = md5( site_url() . get_current_blog_id() ); |
|
57 | - $unique_temp_dir = $tempdir . 'wl_' . $unique; // $tempdir should have a trailing slash. |
|
56 | + $unique = md5(site_url().get_current_blog_id()); |
|
57 | + $unique_temp_dir = $tempdir.'wl_'.$unique; // $tempdir should have a trailing slash. |
|
58 | 58 | |
59 | 59 | // If directory do not exist, create it. |
60 | - if ( ! file_exists( $unique_temp_dir ) ) { |
|
60 | + if ( ! file_exists($unique_temp_dir)) { |
|
61 | 61 | // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged |
62 | - @mkdir( $unique_temp_dir ); |
|
62 | + @mkdir($unique_temp_dir); |
|
63 | 63 | } |
64 | 64 | |
65 | - return $unique_temp_dir . '/'; |
|
65 | + return $unique_temp_dir.'/'; |
|
66 | 66 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | */ |
18 | 18 | function wl_write_log( $log ) { |
19 | 19 | |
20 | - Wordlift_Log_Service::get_instance()->debug( $log ); |
|
20 | + Wordlift_Log_Service::get_instance()->debug( $log ); |
|
21 | 21 | |
22 | 22 | } |
23 | 23 | |
@@ -26,21 +26,21 @@ discard block |
||
26 | 26 | * see http://vip.wordpress.com/documentation/register-additional-html-attributes-for-tinymce-and-wp-kses/ |
27 | 27 | */ |
28 | 28 | function wordlift_allowed_post_tags() { |
29 | - global $allowedposttags; |
|
30 | - |
|
31 | - $tags = array( 'span' ); |
|
32 | - $new_attributes = array( |
|
33 | - 'itemscope' => array(), |
|
34 | - 'itemtype' => array(), |
|
35 | - 'itemprop' => array(), |
|
36 | - 'itemid' => array(), |
|
37 | - ); |
|
38 | - |
|
39 | - foreach ( $tags as $tag ) { |
|
40 | - if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) { |
|
41 | - $allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited |
|
42 | - } |
|
43 | - } |
|
29 | + global $allowedposttags; |
|
30 | + |
|
31 | + $tags = array( 'span' ); |
|
32 | + $new_attributes = array( |
|
33 | + 'itemscope' => array(), |
|
34 | + 'itemtype' => array(), |
|
35 | + 'itemprop' => array(), |
|
36 | + 'itemid' => array(), |
|
37 | + ); |
|
38 | + |
|
39 | + foreach ( $tags as $tag ) { |
|
40 | + if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) { |
|
41 | + $allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited |
|
42 | + } |
|
43 | + } |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | // add allowed post tags. |
@@ -51,18 +51,18 @@ discard block |
||
51 | 51 | */ |
52 | 52 | function wordlift_admin_enqueue_scripts() { |
53 | 53 | |
54 | - // Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/) |
|
55 | - wp_enqueue_script( 'wpdialogs' ); |
|
56 | - wp_enqueue_style( 'wp-jquery-ui-dialog' ); |
|
54 | + // Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/) |
|
55 | + wp_enqueue_script( 'wpdialogs' ); |
|
56 | + wp_enqueue_style( 'wp-jquery-ui-dialog' ); |
|
57 | 57 | |
58 | - wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css', array(), WORDLIFT_VERSION ); |
|
58 | + wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css', array(), WORDLIFT_VERSION ); |
|
59 | 59 | |
60 | - wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
60 | + wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
61 | 61 | |
62 | - // Disable auto-save for custom entity posts only |
|
63 | - if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) { |
|
64 | - wp_dequeue_script( 'autosave' ); |
|
65 | - } |
|
62 | + // Disable auto-save for custom entity posts only |
|
63 | + if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) { |
|
64 | + wp_dequeue_script( 'autosave' ); |
|
65 | + } |
|
66 | 66 | |
67 | 67 | } |
68 | 68 | |
@@ -78,21 +78,21 @@ discard block |
||
78 | 78 | */ |
79 | 79 | function wordlift_allowed_html( $allowedtags, $context ) { |
80 | 80 | |
81 | - if ( 'post' !== $context ) { |
|
82 | - return $allowedtags; |
|
83 | - } |
|
84 | - |
|
85 | - return array_merge_recursive( |
|
86 | - $allowedtags, |
|
87 | - array( |
|
88 | - 'span' => array( |
|
89 | - 'itemscope' => true, |
|
90 | - 'itemtype' => true, |
|
91 | - 'itemid' => true, |
|
92 | - 'itemprop' => true, |
|
93 | - ), |
|
94 | - ) |
|
95 | - ); |
|
81 | + if ( 'post' !== $context ) { |
|
82 | + return $allowedtags; |
|
83 | + } |
|
84 | + |
|
85 | + return array_merge_recursive( |
|
86 | + $allowedtags, |
|
87 | + array( |
|
88 | + 'span' => array( |
|
89 | + 'itemscope' => true, |
|
90 | + 'itemtype' => true, |
|
91 | + 'itemid' => true, |
|
92 | + 'itemprop' => true, |
|
93 | + ), |
|
94 | + ) |
|
95 | + ); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | add_filter( 'wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2 ); |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | */ |
108 | 108 | function wl_get_image_urls( $post_id ) { |
109 | 109 | |
110 | - return Wordlift_Storage_Factory::get_instance() |
|
111 | - ->post_images() |
|
112 | - ->get( $post_id ); |
|
110 | + return Wordlift_Storage_Factory::get_instance() |
|
111 | + ->post_images() |
|
112 | + ->get( $post_id ); |
|
113 | 113 | |
114 | 114 | } |
115 | 115 | |
@@ -123,26 +123,26 @@ discard block |
||
123 | 123 | */ |
124 | 124 | function wl_get_attachment_for_source_url( $parent_post_id, $source_url ) { |
125 | 125 | |
126 | - // wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" ); |
|
127 | - |
|
128 | - $posts = get_posts( |
|
129 | - array( |
|
130 | - 'post_type' => 'attachment', |
|
131 | - 'posts_per_page' => 1, |
|
132 | - 'post_status' => 'any', |
|
133 | - 'post_parent' => $parent_post_id, |
|
134 | - 'meta_key' => 'wl_source_url', |
|
135 | - 'meta_value' => $source_url, |
|
136 | - ) |
|
137 | - ); |
|
138 | - |
|
139 | - // Return the found post. |
|
140 | - if ( 1 === count( $posts ) ) { |
|
141 | - return $posts[0]; |
|
142 | - } |
|
143 | - |
|
144 | - // Return null. |
|
145 | - return null; |
|
126 | + // wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" ); |
|
127 | + |
|
128 | + $posts = get_posts( |
|
129 | + array( |
|
130 | + 'post_type' => 'attachment', |
|
131 | + 'posts_per_page' => 1, |
|
132 | + 'post_status' => 'any', |
|
133 | + 'post_parent' => $parent_post_id, |
|
134 | + 'meta_key' => 'wl_source_url', |
|
135 | + 'meta_value' => $source_url, |
|
136 | + ) |
|
137 | + ); |
|
138 | + |
|
139 | + // Return the found post. |
|
140 | + if ( 1 === count( $posts ) ) { |
|
141 | + return $posts[0]; |
|
142 | + } |
|
143 | + |
|
144 | + // Return null. |
|
145 | + return null; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | */ |
154 | 154 | function wl_set_source_url( $post_id, $source_url ) { |
155 | 155 | |
156 | - delete_post_meta( $post_id, 'wl_source_url' ); |
|
157 | - add_post_meta( $post_id, 'wl_source_url', $source_url ); |
|
156 | + delete_post_meta( $post_id, 'wl_source_url' ); |
|
157 | + add_post_meta( $post_id, 'wl_source_url', $source_url ); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | */ |
171 | 171 | function wl_sanitize_uri_path( $path, $char = '_' ) { |
172 | 172 | |
173 | - return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char ); |
|
173 | + return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char ); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -182,47 +182,47 @@ discard block |
||
182 | 182 | */ |
183 | 183 | function wl_replace_item_id_with_uri( $content ) { |
184 | 184 | |
185 | - $log = Wordlift_Log_Service::get_logger( 'wl_replace_item_id_with_uri' ); |
|
186 | - $log->trace( 'Replacing item IDs with URIs...' ); |
|
185 | + $log = Wordlift_Log_Service::get_logger( 'wl_replace_item_id_with_uri' ); |
|
186 | + $log->trace( 'Replacing item IDs with URIs...' ); |
|
187 | 187 | |
188 | - // Strip slashes, see https://core.trac.wordpress.org/ticket/21767 |
|
189 | - $content = stripslashes( $content ); |
|
188 | + // Strip slashes, see https://core.trac.wordpress.org/ticket/21767 |
|
189 | + $content = stripslashes( $content ); |
|
190 | 190 | |
191 | - // If any match are found. |
|
192 | - $matches = array(); |
|
193 | - if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) { |
|
191 | + // If any match are found. |
|
192 | + $matches = array(); |
|
193 | + if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) { |
|
194 | 194 | |
195 | - foreach ( $matches as $match ) { |
|
195 | + foreach ( $matches as $match ) { |
|
196 | 196 | |
197 | - // Get the item ID. |
|
198 | - $item_id = $match[1]; |
|
197 | + // Get the item ID. |
|
198 | + $item_id = $match[1]; |
|
199 | 199 | |
200 | - // Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' . |
|
201 | - $post = Wordlift_Entity_Service::get_instance() |
|
202 | - ->get_entity_post_by_uri( $item_id ); |
|
200 | + // Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' . |
|
201 | + $post = Wordlift_Entity_Service::get_instance() |
|
202 | + ->get_entity_post_by_uri( $item_id ); |
|
203 | 203 | |
204 | - // If no entity is found, continue to the next one. |
|
205 | - if ( null === $post ) { |
|
206 | - continue; |
|
207 | - } |
|
204 | + // If no entity is found, continue to the next one. |
|
205 | + if ( null === $post ) { |
|
206 | + continue; |
|
207 | + } |
|
208 | 208 | |
209 | - // Get the URI for that post. |
|
210 | - $uri = wl_get_entity_uri( $post->ID ); |
|
209 | + // Get the URI for that post. |
|
210 | + $uri = wl_get_entity_uri( $post->ID ); |
|
211 | 211 | |
212 | - // wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" ); |
|
212 | + // wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" ); |
|
213 | 213 | |
214 | - // If the item ID and the URI differ, replace the item ID with the URI saved in WordPress. |
|
215 | - if ( ! empty( $uri ) && $item_id !== $uri ) { |
|
216 | - $uri_e = esc_html( $uri ); |
|
217 | - $content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content ); |
|
218 | - } |
|
219 | - } |
|
220 | - } |
|
214 | + // If the item ID and the URI differ, replace the item ID with the URI saved in WordPress. |
|
215 | + if ( ! empty( $uri ) && $item_id !== $uri ) { |
|
216 | + $uri_e = esc_html( $uri ); |
|
217 | + $content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content ); |
|
218 | + } |
|
219 | + } |
|
220 | + } |
|
221 | 221 | |
222 | - // Reapply slashes. |
|
223 | - $content = addslashes( $content ); |
|
222 | + // Reapply slashes. |
|
223 | + $content = addslashes( $content ); |
|
224 | 224 | |
225 | - return $content; |
|
225 | + return $content; |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | add_filter( 'content_save_pre', 'wl_replace_item_id_with_uri', 1, 1 ); |
@@ -15,9 +15,9 @@ discard block |
||
15 | 15 | * |
16 | 16 | * @deprecated use Wordlift_Log_Service::get_instance()->info( $log ); |
17 | 17 | */ |
18 | -function wl_write_log( $log ) { |
|
18 | +function wl_write_log($log) { |
|
19 | 19 | |
20 | - Wordlift_Log_Service::get_instance()->debug( $log ); |
|
20 | + Wordlift_Log_Service::get_instance()->debug($log); |
|
21 | 21 | |
22 | 22 | } |
23 | 23 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | function wordlift_allowed_post_tags() { |
29 | 29 | global $allowedposttags; |
30 | 30 | |
31 | - $tags = array( 'span' ); |
|
31 | + $tags = array('span'); |
|
32 | 32 | $new_attributes = array( |
33 | 33 | 'itemscope' => array(), |
34 | 34 | 'itemtype' => array(), |
@@ -36,15 +36,15 @@ discard block |
||
36 | 36 | 'itemid' => array(), |
37 | 37 | ); |
38 | 38 | |
39 | - foreach ( $tags as $tag ) { |
|
40 | - if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) { |
|
41 | - $allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited |
|
39 | + foreach ($tags as $tag) { |
|
40 | + if (isset($allowedposttags[$tag]) && is_array($allowedposttags[$tag])) { |
|
41 | + $allowedposttags[$tag] = array_merge($allowedposttags[$tag], $new_attributes); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | 46 | // add allowed post tags. |
47 | -add_action( 'init', 'wordlift_allowed_post_tags' ); |
|
47 | +add_action('init', 'wordlift_allowed_post_tags'); |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * Register additional scripts for the admin UI. |
@@ -52,21 +52,21 @@ discard block |
||
52 | 52 | function wordlift_admin_enqueue_scripts() { |
53 | 53 | |
54 | 54 | // Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/) |
55 | - wp_enqueue_script( 'wpdialogs' ); |
|
56 | - wp_enqueue_style( 'wp-jquery-ui-dialog' ); |
|
55 | + wp_enqueue_script('wpdialogs'); |
|
56 | + wp_enqueue_style('wp-jquery-ui-dialog'); |
|
57 | 57 | |
58 | - wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css', array(), WORDLIFT_VERSION ); |
|
58 | + wp_enqueue_style('wordlift-reloaded', plugin_dir_url(__FILE__).'css/wordlift-reloaded.min.css', array(), WORDLIFT_VERSION); |
|
59 | 59 | |
60 | - wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
60 | + wp_enqueue_script('jquery-ui-autocomplete'); |
|
61 | 61 | |
62 | 62 | // Disable auto-save for custom entity posts only |
63 | - if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) { |
|
64 | - wp_dequeue_script( 'autosave' ); |
|
63 | + if (Wordlift_Entity_Service::TYPE_NAME === get_post_type()) { |
|
64 | + wp_dequeue_script('autosave'); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | } |
68 | 68 | |
69 | -add_action( 'admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts' ); |
|
69 | +add_action('admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts'); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Hooked to *wp_kses_allowed_html* filter, adds microdata attributes. |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @return array An array which contains allowed microdata attributes. |
78 | 78 | */ |
79 | -function wordlift_allowed_html( $allowedtags, $context ) { |
|
79 | +function wordlift_allowed_html($allowedtags, $context) { |
|
80 | 80 | |
81 | - if ( 'post' !== $context ) { |
|
81 | + if ('post' !== $context) { |
|
82 | 82 | return $allowedtags; |
83 | 83 | } |
84 | 84 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | ); |
96 | 96 | } |
97 | 97 | |
98 | -add_filter( 'wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2 ); |
|
98 | +add_filter('wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2); |
|
99 | 99 | |
100 | 100 | /** |
101 | 101 | * Get all the images bound to a post. |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | * @return array An array of image URLs. |
106 | 106 | * @deprecated use Wordlift_Storage_Factory::get_instance()->post_images()->get( $post_id ) |
107 | 107 | */ |
108 | -function wl_get_image_urls( $post_id ) { |
|
108 | +function wl_get_image_urls($post_id) { |
|
109 | 109 | |
110 | 110 | return Wordlift_Storage_Factory::get_instance() |
111 | 111 | ->post_images() |
112 | - ->get( $post_id ); |
|
112 | + ->get($post_id); |
|
113 | 113 | |
114 | 114 | } |
115 | 115 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * |
122 | 122 | * @return WP_Post|null A post instance or null if not found. |
123 | 123 | */ |
124 | -function wl_get_attachment_for_source_url( $parent_post_id, $source_url ) { |
|
124 | +function wl_get_attachment_for_source_url($parent_post_id, $source_url) { |
|
125 | 125 | |
126 | 126 | // wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" ); |
127 | 127 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | ); |
138 | 138 | |
139 | 139 | // Return the found post. |
140 | - if ( 1 === count( $posts ) ) { |
|
140 | + if (1 === count($posts)) { |
|
141 | 141 | return $posts[0]; |
142 | 142 | } |
143 | 143 | |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | * @param int $post_id The post ID. |
152 | 152 | * @param string $source_url The source URL. |
153 | 153 | */ |
154 | -function wl_set_source_url( $post_id, $source_url ) { |
|
154 | +function wl_set_source_url($post_id, $source_url) { |
|
155 | 155 | |
156 | - delete_post_meta( $post_id, 'wl_source_url' ); |
|
157 | - add_post_meta( $post_id, 'wl_source_url', $source_url ); |
|
156 | + delete_post_meta($post_id, 'wl_source_url'); |
|
157 | + add_post_meta($post_id, 'wl_source_url', $source_url); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -168,9 +168,9 @@ discard block |
||
168 | 168 | * @deprecated use Wordlift_Uri_Service::get_instance()->sanitize_path(); |
169 | 169 | * @see https://codex.wordpress.org/Function_Reference/sanitize_title |
170 | 170 | */ |
171 | -function wl_sanitize_uri_path( $path, $char = '_' ) { |
|
171 | +function wl_sanitize_uri_path($path, $char = '_') { |
|
172 | 172 | |
173 | - return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char ); |
|
173 | + return Wordlift_Uri_Service::get_instance()->sanitize_path($path, $char); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -180,52 +180,52 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @return string The updated post content. |
182 | 182 | */ |
183 | -function wl_replace_item_id_with_uri( $content ) { |
|
183 | +function wl_replace_item_id_with_uri($content) { |
|
184 | 184 | |
185 | - $log = Wordlift_Log_Service::get_logger( 'wl_replace_item_id_with_uri' ); |
|
186 | - $log->trace( 'Replacing item IDs with URIs...' ); |
|
185 | + $log = Wordlift_Log_Service::get_logger('wl_replace_item_id_with_uri'); |
|
186 | + $log->trace('Replacing item IDs with URIs...'); |
|
187 | 187 | |
188 | 188 | // Strip slashes, see https://core.trac.wordpress.org/ticket/21767 |
189 | - $content = stripslashes( $content ); |
|
189 | + $content = stripslashes($content); |
|
190 | 190 | |
191 | 191 | // If any match are found. |
192 | 192 | $matches = array(); |
193 | - if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) { |
|
193 | + if (0 < preg_match_all('/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER)) { |
|
194 | 194 | |
195 | - foreach ( $matches as $match ) { |
|
195 | + foreach ($matches as $match) { |
|
196 | 196 | |
197 | 197 | // Get the item ID. |
198 | 198 | $item_id = $match[1]; |
199 | 199 | |
200 | 200 | // Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' . |
201 | 201 | $post = Wordlift_Entity_Service::get_instance() |
202 | - ->get_entity_post_by_uri( $item_id ); |
|
202 | + ->get_entity_post_by_uri($item_id); |
|
203 | 203 | |
204 | 204 | // If no entity is found, continue to the next one. |
205 | - if ( null === $post ) { |
|
205 | + if (null === $post) { |
|
206 | 206 | continue; |
207 | 207 | } |
208 | 208 | |
209 | 209 | // Get the URI for that post. |
210 | - $uri = wl_get_entity_uri( $post->ID ); |
|
210 | + $uri = wl_get_entity_uri($post->ID); |
|
211 | 211 | |
212 | 212 | // wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" ); |
213 | 213 | |
214 | 214 | // If the item ID and the URI differ, replace the item ID with the URI saved in WordPress. |
215 | - if ( ! empty( $uri ) && $item_id !== $uri ) { |
|
216 | - $uri_e = esc_html( $uri ); |
|
217 | - $content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content ); |
|
215 | + if ( ! empty($uri) && $item_id !== $uri) { |
|
216 | + $uri_e = esc_html($uri); |
|
217 | + $content = str_replace(" itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content); |
|
218 | 218 | } |
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
222 | 222 | // Reapply slashes. |
223 | - $content = addslashes( $content ); |
|
223 | + $content = addslashes($content); |
|
224 | 224 | |
225 | 225 | return $content; |
226 | 226 | } |
227 | 227 | |
228 | -add_filter( 'content_save_pre', 'wl_replace_item_id_with_uri', 1, 1 ); |
|
228 | +add_filter('content_save_pre', 'wl_replace_item_id_with_uri', 1, 1); |
|
229 | 229 | |
230 | 230 | require_once 'wordlift-entity-functions.php'; |
231 | 231 |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'react', 'react-dom', 'wp-polyfill' ), |
|
3 | - 'version' => 'f3639839f6d33cdc7c6ca16c2178908a', |
|
2 | + 'dependencies' => array( 'react', 'react-dom', 'wp-polyfill' ), |
|
3 | + 'version' => 'f3639839f6d33cdc7c6ca16c2178908a', |
|
4 | 4 | ); |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'react', 'react-dom', 'wp-polyfill' ), |
|
2 | + 'dependencies' => array('react', 'react-dom', 'wp-polyfill'), |
|
3 | 3 | 'version' => 'f3639839f6d33cdc7c6ca16c2178908a', |
4 | 4 | ); |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'react', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-polyfill', 'wp-rich-text' ), |
|
3 | - 'version' => '58771ef40b11db9353dc73af4117a5da', |
|
2 | + 'dependencies' => array( 'react', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-polyfill', 'wp-rich-text' ), |
|
3 | + 'version' => '58771ef40b11db9353dc73af4117a5da', |
|
4 | 4 | ); |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'react', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-polyfill', 'wp-rich-text' ), |
|
2 | + 'dependencies' => array('react', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-polyfill', 'wp-rich-text'), |
|
3 | 3 | 'version' => '58771ef40b11db9353dc73af4117a5da', |
4 | 4 | ); |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'react', 'react-dom', 'wp-polyfill' ), |
|
3 | - 'version' => '0da1bd4b6e30da1da70f8a7521ca7dd3', |
|
2 | + 'dependencies' => array( 'react', 'react-dom', 'wp-polyfill' ), |
|
3 | + 'version' => '0da1bd4b6e30da1da70f8a7521ca7dd3', |
|
4 | 4 | ); |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'react', 'react-dom', 'wp-polyfill' ), |
|
2 | + 'dependencies' => array('react', 'react-dom', 'wp-polyfill'), |
|
3 | 3 | 'version' => '0da1bd4b6e30da1da70f8a7521ca7dd3', |
4 | 4 | ); |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'react', 'wp-polyfill', 'wp-rich-text' ), |
|
3 | - 'version' => '2acea653abe0b60106c905b5a66c405e', |
|
2 | + 'dependencies' => array( 'react', 'wp-polyfill', 'wp-rich-text' ), |
|
3 | + 'version' => '2acea653abe0b60106c905b5a66c405e', |
|
4 | 4 | ); |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'react', 'wp-polyfill', 'wp-rich-text' ), |
|
2 | + 'dependencies' => array('react', 'wp-polyfill', 'wp-rich-text'), |
|
3 | 3 | 'version' => '2acea653abe0b60106c905b5a66c405e', |
4 | 4 | ); |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'react', 'wp-polyfill' ), |
|
3 | - 'version' => 'e5d470323035777d27587e84c51a198f', |
|
2 | + 'dependencies' => array( 'react', 'wp-polyfill' ), |
|
3 | + 'version' => 'e5d470323035777d27587e84c51a198f', |
|
4 | 4 | ); |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'react', 'wp-polyfill' ), |
|
2 | + 'dependencies' => array('react', 'wp-polyfill'), |
|
3 | 3 | 'version' => 'e5d470323035777d27587e84c51a198f', |
4 | 4 | ); |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'react', 'react-dom', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-hooks', 'wp-polyfill', 'wp-rich-text' ), |
|
3 | - 'version' => 'bc0e5e59245d63d670c2741796c7fb01', |
|
2 | + 'dependencies' => array( 'react', 'react-dom', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-hooks', 'wp-polyfill', 'wp-rich-text' ), |
|
3 | + 'version' => 'bc0e5e59245d63d670c2741796c7fb01', |
|
4 | 4 | ); |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'react', 'react-dom', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-hooks', 'wp-polyfill', 'wp-rich-text' ), |
|
2 | + 'dependencies' => array('react', 'react-dom', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-hooks', 'wp-polyfill', 'wp-rich-text'), |
|
3 | 3 | 'version' => 'bc0e5e59245d63d670c2741796c7fb01', |
4 | 4 | ); |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'react', 'react-dom', 'wp-polyfill' ), |
|
3 | - 'version' => '4f8316b1a6da18bdcd2a8c2373e032ab', |
|
2 | + 'dependencies' => array( 'react', 'react-dom', 'wp-polyfill' ), |
|
3 | + 'version' => '4f8316b1a6da18bdcd2a8c2373e032ab', |
|
4 | 4 | ); |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'react', 'react-dom', 'wp-polyfill' ), |
|
2 | + 'dependencies' => array('react', 'react-dom', 'wp-polyfill'), |
|
3 | 3 | 'version' => '4f8316b1a6da18bdcd2a8c2373e032ab', |
4 | 4 | ); |