PluginProbe
Parse.ly / 3.14.1
Parse.ly v3.14.1
3.24.1 3.24.0 3.23.7 3.23.6 3.23.5 3.23.4 3.23.3 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.17.0 3.18.0 3.18.1 3.19.0 3.19.1 3.19.2 3.19.3 3.2.0 3.2.1 3.20.0 3.20.1 3.20.2 3.20.3 All 105 releases
← All changes | wp-parsely.php +190 -214 3.24.03.14.1 View file →
@@ -10,9 +10,9 @@
10 10 * @wordpress-plugin
11 11 * Plugin Name: Parse.ly
12 12 * Plugin URI: https://docs.parse.ly/wordpress
13 13 * Description: This plugin makes it a snap to add Parse.ly tracking code and metadata to your WordPress blog.
14 - * Version: 3.24.0
14 + * Version: 3.14.1
15 15 * Author: Parse.ly
16 16 * Author URI: https://www.parse.ly
17 17 * Text Domain: wp-parsely
18 18 * License: GPL-2.0-or-later
@@ -17,10 +17,10 @@
17 17 * Text Domain: wp-parsely
18 18 * License: GPL-2.0-or-later
19 19 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
20 20 * GitHub Plugin URI: https://github.com/Parsely/wp-parsely
21 - * Requires PHP: 7.4
22 - * Requires WP: 6.1.0
21 + * Requires PHP: 7.2
22 + * Requires WP: 5.0.0
23 23 */
24 24
25 25 declare(strict_types=1);
26 26
@@ -27,18 +27,35 @@
27 27 namespace Parsely;
28 28
29 29 use Parsely\Content_Helper\Dashboard_Widget;
30 30 use Parsely\Content_Helper\Editor_Sidebar;
31 +use Parsely\Content_Helper\Excerpt_Generator;
31 32 use Parsely\Content_Helper\Post_List_Stats;
33 +use Parsely\Endpoints\Analytics_Post_Detail_API_Proxy;
34 +use Parsely\Endpoints\Analytics_Posts_API_Proxy;
35 +use Parsely\Endpoints\ContentSuggestions\Suggest_Brief_API_Proxy;
36 +use Parsely\Endpoints\ContentSuggestions\Suggest_Headline_API_Proxy;
37 +use Parsely\Endpoints\ContentSuggestions\Suggest_Linked_Reference_API_Proxy;
32 38 use Parsely\Endpoints\GraphQL_Metadata;
39 +use Parsely\Endpoints\Referrers_Post_Detail_API_Proxy;
40 +use Parsely\Endpoints\Related_API_Proxy;
33 41 use Parsely\Endpoints\Rest_Metadata;
34 -use Parsely\Headline_Testing;
42 +use Parsely\Endpoints\User_Meta\Dashboard_Widget_Settings_Endpoint;
43 +use Parsely\Endpoints\User_Meta\Editor_Sidebar_Settings_Endpoint;
35 44 use Parsely\Integrations\Amp;
36 45 use Parsely\Integrations\Google_Web_Stories;
37 46 use Parsely\Integrations\Integrations;
47 +use Parsely\RemoteAPI\Analytics_Post_Detail_API;
48 +use Parsely\RemoteAPI\Analytics_Posts_API;
49 +use Parsely\RemoteAPI\ContentSuggestions\Suggest_Brief_API;
50 +use Parsely\RemoteAPI\ContentSuggestions\Suggest_Headline_API;
51 +use Parsely\RemoteAPI\ContentSuggestions\Suggest_Linked_Reference_API;
52 +use Parsely\RemoteAPI\Referrers_Post_Detail_API;
53 +use Parsely\RemoteAPI\Related_API;
54 +use Parsely\RemoteAPI\Remote_API_Cache;
55 +use Parsely\RemoteAPI\WordPress_Cache;
38 56 use Parsely\UI\Admin_Bar;
39 57 use Parsely\UI\Admin_Warning;
40 -use Parsely\UI\Dashboard_Page;
41 58 use Parsely\UI\Metadata_Renderer;
42 59 use Parsely\UI\Network_Admin_Sites_List;
43 60 use Parsely\UI\Plugins_Actions;
44 61 use Parsely\UI\Recommended_Widget;
@@ -45,65 +62,69 @@
45 62 use Parsely\UI\Row_Actions;
46 63 use Parsely\UI\Settings_Page;
47 64 use Parsely\UI\Site_Health;
48 65
66 +require_once __DIR__ . '/src/Utils/utils.php';
67 +
49 68 if ( class_exists( Parsely::class ) ) {
50 69 return;
51 70 }
52 71
53 -const PARSELY_VERSION = '3.24.0';
54 -const PARSELY_FILE = __FILE__;
55 -const PARSELY_DATA_SCHEMA_VERSION = '1';
56 -const PARSELY_CACHE_GROUP = 'wp-parsely';
72 +const PARSELY_VERSION = '3.14.1';
73 +const PARSELY_FILE = __FILE__;
57 74
58 -if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
59 - require_once __DIR__ . '/vendor/autoload.php';
60 -}
61 -
62 -// Load Telemetry classes.
75 +require_once __DIR__ . '/src/class-parsely.php';
76 +require_once __DIR__ . '/src/class-scripts.php';
77 +require_once __DIR__ . '/src/class-dashboard-link.php';
78 +require_once __DIR__ . '/src/class-validator.php';
79 +require_once __DIR__ . '/src/UI/class-admin-bar.php';
80 +require_once __DIR__ . '/src/UI/class-metadata-renderer.php';
81 +require_once __DIR__ . '/src/Endpoints/class-metadata-endpoint.php';
82 +require_once __DIR__ . '/src/Endpoints/class-graphql-metadata.php';
63 83 require_once __DIR__ . '/src/Telemetry/telemetry-init.php';
64 84
65 -/**
66 - * Gets the Parsely object.
67 - *
68 - * @since 3.19.0
69 - *
70 - * @return Parsely The Parsely object.
71 - */
72 -function get_parsely(): Parsely {
73 - if ( ! isset( $GLOBALS['parsely'] ) ) {
74 - $GLOBALS['parsely'] = new Parsely();
75 - }
85 +require_once __DIR__ . '/src/class-metadata.php';
86 +require_once __DIR__ . '/src/Metadata/class-metadata-builder.php';
87 +require_once __DIR__ . '/src/Metadata/class-author-archive-builder.php';
88 +require_once __DIR__ . '/src/Metadata/class-category-builder.php';
89 +require_once __DIR__ . '/src/Metadata/class-date-builder.php';
90 +require_once __DIR__ . '/src/Metadata/class-front-page-builder.php';
91 +require_once __DIR__ . '/src/Metadata/class-page-builder.php';
92 +require_once __DIR__ . '/src/Metadata/class-page-for-posts-builder.php';
93 +require_once __DIR__ . '/src/Metadata/class-paginated-front-page-builder.php';
94 +require_once __DIR__ . '/src/Metadata/class-post-builder.php';
95 +require_once __DIR__ . '/src/Metadata/class-tag-builder.php';
76 96
77 - return $GLOBALS['parsely'];
78 -}
79 -
80 97 add_action( 'plugins_loaded', __NAMESPACE__ . '\\parsely_initialize_plugin' );
81 98 /**
82 99 * Registers the basic classes to initialize the plugin.
83 100 */
84 101 function parsely_initialize_plugin(): void {
85 - $parsely = get_parsely();
86 - $parsely->run();
102 + $GLOBALS['parsely'] = new Parsely();
103 + $GLOBALS['parsely']->run();
87 104
88 105 if ( class_exists( 'WPGraphQL' ) ) {
89 - $graphql = new GraphQL_Metadata( $parsely );
106 + $graphql = new GraphQL_Metadata( $GLOBALS['parsely'] );
90 107 $graphql->run();
91 108 }
92 109
93 - $scripts = new Scripts( $parsely );
110 + $scripts = new Scripts( $GLOBALS['parsely'] );
94 111 $scripts->run();
95 112
96 - $admin_bar = new Admin_Bar( $parsely );
113 + $admin_bar = new Admin_Bar( $GLOBALS['parsely'] );
97 114 $admin_bar->run();
98 115
99 - $metadata_renderer = new Metadata_Renderer( $parsely );
116 + $metadata_renderer = new Metadata_Renderer( $GLOBALS['parsely'] );
100 117 $metadata_renderer->run();
118 +}
101 119
102 - // Initialize Headline Testing feature.
103 - $headline_testing = new Headline_Testing( $parsely );
104 - $headline_testing->run();
105 -}
120 +require_once __DIR__ . '/src/content-helper/common/class-content-helper-feature.php';
121 +require_once __DIR__ . '/src/content-helper/post-list-stats/class-post-list-stats.php';
122 +require_once __DIR__ . '/src/UI/class-admin-warning.php';
123 +require_once __DIR__ . '/src/UI/class-plugins-actions.php';
124 +require_once __DIR__ . '/src/UI/class-row-actions.php';
125 +require_once __DIR__ . '/src/UI/class-site-health.php';
126 +require_once __DIR__ . '/src/content-helper/dashboard-widget/class-dashboard-widget.php';
106 127
107 128 add_action( 'admin_init', __NAMESPACE__ . '\\parsely_admin_init_register' );
108 129 /**
109 130 * Registers the Parse.ly wp-admin warnings, plugin actions and row actions.
@@ -108,9 +129,9 @@
108 129 /**
109 130 * Registers the Parse.ly wp-admin warnings, plugin actions and row actions.
110 131 */
111 132 function parsely_admin_init_register(): void {
112 - $parsely = get_parsely();
133 + $parsely = $GLOBALS['parsely'];
113 134
114 135 ( new Admin_Warning( $parsely ) )->run();
115 136 ( new Plugins_Actions() )->run();
116 137 ( new Row_Actions( $parsely ) )->run();
@@ -118,56 +139,11 @@
118 139 ( new Site_Health( $parsely ) )->run();
119 140 ( new Dashboard_Widget( $parsely ) )->run();
120 141 }
121 142
122 -add_action( 'admin_init', __NAMESPACE__ . '\\create_engagement_boost_changeset_post' );
123 -/**
124 - * Creates a predefined changeset post in order to make the Engagement Boost
125 - * preview work for non-administrator user roles.
126 - *
127 - * When the Engagement Boost preview iframe is loaded, it calls the WordPress
128 - * Customizer in the `iFrameSrc()` function. The Customizer requires the current
129 - * user to have the `customize` capability (available to Administrators), or the
130 - * passed UUID to have a corresponding changeset post in the database. Otherwise
131 - * it fails with -1 ("Non-existent changeset UUID") around line 561 in
132 - * `class-wp-customize-manager.php` and prevents preview, displaying "-1".
133 - *
134 - * By creating a predefined changeset post with a known UUID that we use in
135 - * `iFrameSrc()`, we guarantee that the preview will work for all authorized
136 - * user roles.
137 - *
138 - * @since 3.20.7
139 - */
140 -function create_engagement_boost_changeset_post(): void {
141 - if ( ! function_exists( 'post_exists' ) ) {
142 - return;
143 - }
143 +require_once __DIR__ . '/src/UI/class-settings-page.php';
144 +require_once __DIR__ . '/src/UI/class-network-admin-sites-list.php';
144 145
145 - $parsely = get_parsely();
146 -
147 - if ( ! $parsely->api_secret_is_set() || ! Permissions::current_user_can_use_pch_feature(
148 - 'traffic_boost',
149 - $parsely->get_options()['content_helper']
150 - ) ) {
151 - return;
152 - }
153 -
154 - // Needs to match the UUID in `iFrameSrc()` in `preview-iframe.tsx`.
155 - $uuid = '905b130b-4129-4416-919c-9e31433a6f65';
156 - $post_id = post_exists( "wp-parsely-$uuid", '', '', 'customize_changeset', 'private' );
157 -
158 - if ( 0 === $post_id ) {
159 - wp_insert_post(
160 - array(
161 - 'post_type' => 'customize_changeset',
162 - 'post_name' => $uuid,
163 - 'post_title' => "wp-parsely-$uuid",
164 - 'post_status' => 'private',
165 - )
166 - );
167 - }
168 -}
169 -
170 146 add_action( 'init', __NAMESPACE__ . '\\parsely_wp_admin_early_register' );
171 147 /**
172 148 * Registers the additions the Parse.ly wp-admin settings page and Multisite
173 149 * Network Admin Sites List table.
@@ -172,26 +148,50 @@
172 148 * Registers the additions the Parse.ly wp-admin settings page and Multisite
173 149 * Network Admin Sites List table.
174 150 */
175 151 function parsely_wp_admin_early_register(): void {
176 - $parsely = get_parsely();
152 + $GLOBALS['parsely_settings_page'] = new Settings_Page( $GLOBALS['parsely'] );
153 + $GLOBALS['parsely_settings_page']->run();
177 154
178 - // Plugin dashboard page.
179 - $GLOBALS['parsely_dashboard_page'] = new Dashboard_Page( $parsely );
180 - $GLOBALS['parsely_dashboard_page']->run();
155 + $network_admin_sites_list = new Network_Admin_Sites_List( $GLOBALS['parsely'] );
156 + $network_admin_sites_list->run();
157 +}
181 158
182 - // Plugin settings page.
183 - $GLOBALS['parsely_settings_page'] = new Settings_Page( $parsely );
184 - $GLOBALS['parsely_settings_page']->run();
159 +// Endpoint base classes.
160 +require_once __DIR__ . '/src/Endpoints/class-base-endpoint.php';
161 +require_once __DIR__ . '/src/Endpoints/class-base-api-proxy.php';
162 +require_once __DIR__ . '/src/Endpoints/user-meta/class-base-endpoint-user-meta.php';
185 163
186 - $network_admin_sites_list = new Network_Admin_Sites_List( $parsely );
187 - $network_admin_sites_list->run();
164 +// Endpoint classes.
165 +require_once __DIR__ . '/src/Endpoints/class-analytics-post-detail-api-proxy.php';
166 +require_once __DIR__ . '/src/Endpoints/class-analytics-posts-api-proxy.php';
167 +require_once __DIR__ . '/src/Endpoints/class-referrers-post-detail-api-proxy.php';
168 +require_once __DIR__ . '/src/Endpoints/class-related-api-proxy.php';
169 +require_once __DIR__ . '/src/Endpoints/class-rest-metadata.php';
170 +require_once __DIR__ . '/src/Endpoints/content-suggestions/class-suggest-brief-api-proxy.php';
171 +require_once __DIR__ . '/src/Endpoints/content-suggestions/class-suggest-headline-api-proxy.php';
172 +require_once __DIR__ . '/src/Endpoints/content-suggestions/class-suggest-linked-reference-api-proxy.php';
173 +require_once __DIR__ . '/src/Endpoints/user-meta/class-dashboard-widget-settings-endpoint.php';
174 +require_once __DIR__ . '/src/Endpoints/user-meta/class-editor-sidebar-settings-endpoint.php';
188 175
189 - // Initialize the REST API Controller.
190 - $rest_api_controller = $parsely->get_rest_api_controller();
191 - $rest_api_controller->init();
192 -}
176 +// RemoteAPI base classes.
177 +require_once __DIR__ . '/src/RemoteAPI/interface-cache.php';
178 +require_once __DIR__ . '/src/RemoteAPI/interface-remote-api.php';
179 +require_once __DIR__ . '/src/RemoteAPI/class-remote-api-cache.php';
180 +require_once __DIR__ . '/src/RemoteAPI/class-wordpress-cache.php';
181 +require_once __DIR__ . '/src/RemoteAPI/class-base-endpoint-remote.php';
182 +require_once __DIR__ . '/src/RemoteAPI/content-suggestions/class-content-suggestions-base-api.php';
193 183
184 +// RemoteAPI classes.
185 +require_once __DIR__ . '/src/RemoteAPI/class-analytics-post-detail-api.php';
186 +require_once __DIR__ . '/src/RemoteAPI/class-analytics-posts-api.php';
187 +require_once __DIR__ . '/src/RemoteAPI/class-referrers-post-detail-api.php';
188 +require_once __DIR__ . '/src/RemoteAPI/class-related-api.php';
189 +require_once __DIR__ . '/src/RemoteAPI/class-validate-api.php';
190 +require_once __DIR__ . '/src/RemoteAPI/content-suggestions/class-suggest-brief-api.php';
191 +require_once __DIR__ . '/src/RemoteAPI/content-suggestions/class-suggest-headline-api.php';
192 +require_once __DIR__ . '/src/RemoteAPI/content-suggestions/class-suggest-linked-reference-api.php';
193 +
194 194 add_action( 'rest_api_init', __NAMESPACE__ . '\\parsely_rest_api_init' );
195 195 /**
196 196 * Registers REST Endpoints that act as a proxy to the Parse.ly API.
197 197 * This is needed to get around CORS issues with Firefox.
@@ -198,14 +198,61 @@
198 198 *
199 199 * @since 3.2.0
200 200 */
201 201 function parsely_rest_api_init(): void {
202 - $parsely = get_parsely();
202 + $wp_cache = new WordPress_Cache();
203 + $rest = new Rest_Metadata( $GLOBALS['parsely'] );
204 + $rest->run();
203 205
204 - $rest = new Rest_Metadata( $parsely );
205 - $rest->run();
206 + // Content Helper settings endpoints.
207 + ( new Dashboard_Widget_Settings_Endpoint( $GLOBALS['parsely'] ) )->run();
208 + ( new Editor_Sidebar_Settings_Endpoint( $GLOBALS['parsely'] ) )->run();
209 +
210 + parsely_run_rest_api_endpoint(
211 + Related_API::class,
212 + Related_API_Proxy::class,
213 + $wp_cache
214 + );
215 +
216 + parsely_run_rest_api_endpoint(
217 + Analytics_Posts_API::class,
218 + Analytics_Posts_API_Proxy::class,
219 + $wp_cache
220 + );
221 +
222 + parsely_run_rest_api_endpoint(
223 + Analytics_Post_Detail_API::class,
224 + Analytics_Post_Detail_API_Proxy::class,
225 + $wp_cache
226 + );
227 +
228 + parsely_run_rest_api_endpoint(
229 + Referrers_Post_Detail_API::class,
230 + Referrers_Post_Detail_API_Proxy::class,
231 + $wp_cache
232 + );
233 +
234 + parsely_run_rest_api_endpoint(
235 + Suggest_Headline_API::class,
236 + Suggest_Headline_API_Proxy::class,
237 + $wp_cache
238 + );
239 +
240 + parsely_run_rest_api_endpoint(
241 + Suggest_Brief_API::class,
242 + Suggest_Brief_API_Proxy::class,
243 + $wp_cache
244 + );
245 +
246 + parsely_run_rest_api_endpoint(
247 + Suggest_Linked_Reference_API::class,
248 + Suggest_Linked_Reference_API_Proxy::class,
249 + $wp_cache
250 + );
206 251 }
207 252
253 +require_once __DIR__ . '/src/blocks/recommendations/class-recommendations-block.php';
254 +
208 255 add_action( 'init', __NAMESPACE__ . '\\init_recommendations_block' );
209 256 /**
210 257 * Registers the Recommendations Block.
211 258 */
@@ -213,8 +260,10 @@
213 260 $recommendations_block = new Recommendations_Block();
214 261 $recommendations_block->run();
215 262 }
216 263
264 +require_once __DIR__ . '/src/content-helper/editor-sidebar/class-editor-sidebar.php';
265 +
217 266 add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\\init_content_helper_editor_sidebar' );
218 267 /**
219 268 * Inserts the PCH Editor Sidebar.
220 269 *
@@ -221,56 +270,38 @@
221 270 * @since 3.5.0 Moved from Parsely\Scripts\enqueue_block_editor_assets().
222 271 * @since 3.9.0 Renamed from init_content_helper().
223 272 */
224 273 function init_content_helper_editor_sidebar(): void {
225 - $GLOBALS['parsely_editor_sidebar']->run();
274 + ( new Editor_Sidebar( $GLOBALS['parsely'] ) )->run();
226 275 }
227 276
228 -add_action( 'enqueue_block_assets', __NAMESPACE__ . '\\init_content_helper_canvas_styles' );
277 +require_once __DIR__ . '/src/content-helper/excerpt-generator/class-excerpt-generator.php';
278 +
279 +// The priority of 9 is used to ensure that the Excerpt Generator is loaded before the PCH Editor Sidebar (10).
280 +add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\\init_content_helper_excerpt_generator', 9 );
229 281 /**
230 - * Inserts the PCH Editor Sidebar styles that need to reach the Editor canvas.
282 + * Initializes and inserts the PCH Excerpt Generator.
231 283 *
232 - * @since 3.24.0
284 + * @since 3.13.0
233 285 */
234 -function init_content_helper_canvas_styles(): void {
235 - if ( ! isset( $GLOBALS['parsely_editor_sidebar'] ) ) {
236 - return;
237 - }
238 -
239 - $GLOBALS['parsely_editor_sidebar']->run_canvas_styles();
286 +function init_content_helper_excerpt_generator(): void {
287 + ( new Excerpt_Generator( $GLOBALS['parsely'] ) )->run();
240 288 }
241 289
242 -add_action( 'admin_init', __NAMESPACE__ . '\\parsely_content_helper_editor_sidebar_features' );
243 -add_action( 'rest_api_init', __NAMESPACE__ . '\\parsely_content_helper_editor_sidebar_features' );
244 -/**
245 - * Initializes the PCH Editor Sidebar features.
246 - *
247 - * @since 3.16.0
248 - */
249 -function parsely_content_helper_editor_sidebar_features(): void {
250 - if ( ! isset( $GLOBALS['parsely_editor_sidebar'] ) ) {
251 - /**
252 - * The Editor Sidebar instance.
253 - *
254 - * @since 3.16.0
255 - * @var Editor_Sidebar $GLOBALS['parsely_editor_sidebar']
256 - */
257 - $parsely = get_parsely();
290 +require_once __DIR__ . '/src/UI/class-recommended-widget.php';
258 291
259 - $GLOBALS['parsely_editor_sidebar'] = new Editor_Sidebar( $parsely );
260 - $GLOBALS['parsely_editor_sidebar']->init_features();
261 - }
262 -}
263 -
264 292 add_action( 'widgets_init', __NAMESPACE__ . '\\parsely_recommended_widget_register' );
265 293 /**
266 294 * Registers the Parse.ly Recommended widget.
267 295 */
268 296 function parsely_recommended_widget_register(): void {
269 - $parsely = get_parsely();
297 + register_widget( new Recommended_Widget( $GLOBALS['parsely'] ) );
298 +}
270 299
271 - register_widget( new Recommended_Widget( $parsely ) );
272 -}
300 +require_once __DIR__ . '/src/Integrations/class-integration.php';
301 +require_once __DIR__ . '/src/Integrations/class-integrations.php';
302 +require_once __DIR__ . '/src/Integrations/class-amp.php';
303 +require_once __DIR__ . '/src/Integrations/class-google-web-stories.php';
273 304
274 305 add_action( 'init', __NAMESPACE__ . '\\parsely_integrations' ); // @phpstan-ignore-line
275 306 /**
276 307 * Instantiates Integrations collection and registers built-in integrations.
@@ -284,9 +315,9 @@
284 315 // If $parsely value is "", then this function is being called by the init
285 316 // hook and we can get the value from $GLOBALS. If $parsely is an instance
286 317 // of the Parsely object, then this function is being called by a test.
287 318 if ( ! is_object( $parsely ) || get_class( $parsely ) !== Parsely::class ) {
288 - $parsely = get_parsely();
319 + $parsely = $GLOBALS['parsely'];
289 320 }
290 321
291 322 $parsely_integrations = new Integrations( $parsely );
292 323 $parsely_integrations->register( 'amp', Amp::class );
@@ -296,89 +327,34 @@
296 327
297 328 return $parsely_integrations;
298 329 }
299 330
300 -add_action( 'admin_init', __NAMESPACE__ . '\\parsely_check_data_schema_updates', 999 );
301 331 /**
302 - * Checks and performs any data schema updates.
332 + * Instantiates and runs the specified API endpoint.
303 333 *
304 - * @since 3.19.0 Handles the update from schema version 0 to 1.
334 + * @since 3.6.0
335 + *
336 + * @param string $api_class_name The proxy class to instantiate.
337 + * @param string $proxy_api_class_name The API proxy class to instantiate and run.
338 + * @param WordPress_Cache $wp_cache The WordPress cache instance to be used.
305 339 */
306 -function parsely_check_data_schema_updates(): void {
307 - $current_data_schema_version = get_option( 'parsely_data_schema_version' );
340 +function parsely_run_rest_api_endpoint(
341 + string $api_class_name,
342 + string $proxy_api_class_name,
343 + WordPress_Cache &$wp_cache
344 +): void {
345 + /**
346 + * Internal Variable.
347 + *
348 + * @var RemoteAPI\Base_Endpoint_Remote
349 + */
350 + $remote_api = new $api_class_name( $GLOBALS['parsely'] );
351 + $remote_api_cache = new Remote_API_Cache( $remote_api, $wp_cache );
308 352
309 - if ( false === $current_data_schema_version ) {
310 - $current_data_schema_version = 0;
311 - }
312 -
313 - if ( PARSELY_DATA_SCHEMA_VERSION <= $current_data_schema_version ) {
314 - return;
315 - }
316 -
317 353 /**
318 - * Updates the smart links to have the Smart Link Status terms,
319 - * and checks the _smart_link_applied meta, if it exists.
354 + * Internal Variable.
320 355 *
321 - * Schema version 1.
322 - *
323 - * @since 3.19.0
356 + * @var Endpoints\Base_API_Proxy
324 357 */
325 - if ( 0 === $current_data_schema_version ) {
326 - // Get all the smart links that do not have any Smart Link Status terms.
327 - // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.get_posts_get_posts
328 - $smart_links_without_status = get_posts(
329 - array(
330 - 'post_type' => 'parsely_smart_link',
331 - 'posts_per_page' => -1, // phpcs:ignore WordPressVIPMinimum.Performance.NoPaging.posts_per_page_posts_per_page
332 - 'fields' => 'ids',
333 - // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
334 - 'tax_query' => array(
335 - array(
336 - 'taxonomy' => 'smart_link_status',
337 - 'field' => 'name',
338 - 'terms' => \Parsely\Models\Smart_Link_Status::get_all_statuses(),
339 - 'operator' => 'NOT IN',
340 - ),
341 - ),
342 - )
343 - );
344 -
345 - if ( count( $smart_links_without_status ) === 0 ) {
346 - update_option( 'parsely_data_schema_version', PARSELY_DATA_SCHEMA_VERSION );
347 - return;
348 - }
349 -
350 - // Loop through the smart links and update them to have the Smart Link Status terms.
351 - foreach ( $smart_links_without_status as $post_id ) {
352 - $smart_link = \Parsely\Models\Smart_Link::get_smart_link_by_id( intval( $post_id ) );
353 -
354 - if ( false === $smart_link ) {
355 - continue;
356 - }
357 -
358 - $meta_exists = metadata_exists( 'post', $post_id, '_smart_link_applied' );
359 -
360 - // If there is no meta, it means that the smart link is considered applied,
361 - // for backwards compatibility with Parse.ly < 3.18.0.
362 - if ( ! $meta_exists ) {
363 - $smart_link->set_status( \Parsely\Models\Smart_Link_Status::APPLIED, true );
364 - continue;
365 - }
366 -
367 - // Get the value of the _smart_link_applied meta.
368 - $meta_value = get_post_meta( $post_id, '_smart_link_applied', true );
369 -
370 - // If the meta value is true, then the smart link is considered applied.
371 - if ( 'true' === $meta_value || true === $meta_value ) {
372 - $smart_link->set_status( \Parsely\Models\Smart_Link_Status::APPLIED, true );
373 - } else {
374 - // If the meta value is not true, then the smart link is considered pending.
375 - $smart_link->set_status( \Parsely\Models\Smart_Link_Status::PENDING, true );
376 - }
377 -
378 - // Flush the cache for the smart link.
379 - $smart_link->flush_all_cache();
380 - }
381 -
382 - update_option( 'parsely_data_schema_version', PARSELY_DATA_SCHEMA_VERSION );
383 - }
358 + $remote_api_proxy = new $proxy_api_class_name( $GLOBALS['parsely'], $remote_api_cache );
359 + $remote_api_proxy->run();
384 360 }