PluginProbe
Parse.ly / 3.8.4
Parse.ly v3.8.4
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 +142 -163 3.19.33.8.4 View file →
@@ -8,11 +8,11 @@
8 8 * @license GPL-2.0-or-later
9 9 *
10 10 * @wordpress-plugin
11 11 * Plugin Name: Parse.ly
12 - * Plugin URI: https://docs.parse.ly/wordpress
12 + * Plugin URI: https://www.parse.ly/help/integration/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.19.3
14 + * Version: 3.8.4
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
@@ -18,9 +18,9 @@
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 21 * Requires PHP: 7.2
22 - * Requires WP: 6.0.0
22 + * Requires WP: 5.0.0
23 23 */
24 24
25 25 declare(strict_types=1);
26 26
@@ -25,19 +25,28 @@
25 25 declare(strict_types=1);
26 26
27 27 namespace Parsely;
28 28
29 -use Parsely\Content_Helper\Dashboard_Widget;
30 -use Parsely\Content_Helper\Editor_Sidebar;
31 -use Parsely\Content_Helper\Post_List_Stats;
29 +use Parsely\ContentHelper\Dashboard_Widget;
30 +use Parsely\Endpoints\Analytics_Post_Detail_API_Proxy;
31 +use Parsely\Endpoints\Analytics_Posts_API_Proxy;
32 32 use Parsely\Endpoints\GraphQL_Metadata;
33 +use Parsely\Endpoints\Referrers_Post_Detail_API_Proxy;
34 +use Parsely\Endpoints\Related_API_Proxy;
33 35 use Parsely\Endpoints\Rest_Metadata;
34 36 use Parsely\Integrations\Amp;
37 +use Parsely\Integrations\Facebook_Instant_Articles;
35 38 use Parsely\Integrations\Google_Web_Stories;
36 39 use Parsely\Integrations\Integrations;
40 +use Parsely\RemoteAPI\Analytics_Post_Detail_API;
41 +use Parsely\RemoteAPI\Analytics_Posts_API;
42 +use Parsely\RemoteAPI\Remote_API_Cache;
43 +use Parsely\RemoteAPI\Referrers_Post_Detail_API;
44 +use Parsely\RemoteAPI\Related_API;
45 +use Parsely\RemoteAPI\WordPress_Cache;
37 46 use Parsely\UI\Admin_Bar;
47 +use Parsely\UI\Admin_Columns_Parsely_Stats;
38 48 use Parsely\UI\Admin_Warning;
39 -use Parsely\UI\Dashboard_Page;
40 49 use Parsely\UI\Metadata_Renderer;
41 50 use Parsely\UI\Network_Admin_Sites_List;
42 51 use Parsely\UI\Plugins_Actions;
43 52 use Parsely\UI\Recommended_Widget;
@@ -44,77 +53,85 @@
44 53 use Parsely\UI\Row_Actions;
45 54 use Parsely\UI\Settings_Page;
46 55 use Parsely\UI\Site_Health;
47 56
57 +require_once __DIR__ . '/src/Utils/utils.php';
58 +
48 59 if ( class_exists( Parsely::class ) ) {
49 60 return;
50 61 }
51 62
52 -const PARSELY_VERSION = '3.19.3';
53 -const PARSELY_FILE = __FILE__;
54 -const PARSELY_DATA_SCHEMA_VERSION = '1';
55 -const PARSELY_CACHE_GROUP = 'wp-parsely';
63 +const PARSELY_VERSION = '3.8.4';
64 +const PARSELY_FILE = __FILE__;
56 65
57 -if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
58 - require_once __DIR__ . '/vendor/autoload.php';
59 -}
66 +require_once __DIR__ . '/src/class-parsely.php';
67 +require_once __DIR__ . '/src/class-scripts.php';
68 +require_once __DIR__ . '/src/class-dashboard-link.php';
69 +require_once __DIR__ . '/src/UI/class-admin-bar.php';
70 +require_once __DIR__ . '/src/UI/class-metadata-renderer.php';
71 +require_once __DIR__ . '/src/Endpoints/class-metadata-endpoint.php';
72 +require_once __DIR__ . '/src/Endpoints/class-graphql-metadata.php';
60 73
61 -// Load Telemetry classes.
62 -require_once __DIR__ . '/src/Telemetry/telemetry-init.php';
74 +require_once __DIR__ . '/src/class-metadata.php';
75 +require_once __DIR__ . '/src/Metadata/class-metadata-builder.php';
76 +require_once __DIR__ . '/src/Metadata/class-author-archive-builder.php';
77 +require_once __DIR__ . '/src/Metadata/class-category-builder.php';
78 +require_once __DIR__ . '/src/Metadata/class-date-builder.php';
79 +require_once __DIR__ . '/src/Metadata/class-front-page-builder.php';
80 +require_once __DIR__ . '/src/Metadata/class-page-builder.php';
81 +require_once __DIR__ . '/src/Metadata/class-page-for-posts-builder.php';
82 +require_once __DIR__ . '/src/Metadata/class-paginated-front-page-builder.php';
83 +require_once __DIR__ . '/src/Metadata/class-post-builder.php';
84 +require_once __DIR__ . '/src/Metadata/class-tag-builder.php';
63 85
64 -/**
65 - * Gets the Parsely object.
66 - *
67 - * @since 3.19.0
68 - *
69 - * @return Parsely The Parsely object.
70 - */
71 -function get_parsely(): Parsely {
72 - if ( ! isset( $GLOBALS['parsely'] ) ) {
73 - $GLOBALS['parsely'] = new Parsely();
74 - }
75 -
76 - return $GLOBALS['parsely'];
77 -}
78 -
79 86 add_action( 'plugins_loaded', __NAMESPACE__ . '\\parsely_initialize_plugin' );
80 87 /**
81 88 * Registers the basic classes to initialize the plugin.
82 89 */
83 90 function parsely_initialize_plugin(): void {
84 - $parsely = get_parsely();
85 - $parsely->run();
91 + $GLOBALS['parsely'] = new Parsely();
92 + $GLOBALS['parsely']->run();
86 93
87 94 if ( class_exists( 'WPGraphQL' ) ) {
88 - $graphql = new GraphQL_Metadata( $parsely );
95 + $graphql = new GraphQL_Metadata( $GLOBALS['parsely'] );
89 96 $graphql->run();
90 97 }
91 98
92 - $scripts = new Scripts( $parsely );
99 + $scripts = new Scripts( $GLOBALS['parsely'] );
93 100 $scripts->run();
94 101
95 - $admin_bar = new Admin_Bar( $parsely );
102 + $admin_bar = new Admin_Bar( $GLOBALS['parsely'] );
96 103 $admin_bar->run();
97 104
98 - $metadata_renderer = new Metadata_Renderer( $parsely );
105 + $metadata_renderer = new Metadata_Renderer( $GLOBALS['parsely'] );
99 106 $metadata_renderer->run();
100 107 }
101 108
109 +require_once __DIR__ . '/src/UI/class-admin-columns-parsely-stats.php';
110 +require_once __DIR__ . '/src/UI/class-admin-warning.php';
111 +require_once __DIR__ . '/src/UI/class-plugins-actions.php';
112 +require_once __DIR__ . '/src/UI/class-row-actions.php';
113 +require_once __DIR__ . '/src/UI/class-site-health.php';
114 +require_once __DIR__ . '/src/content-helper/dashboard-widget/class-dashboard-widget.php';
115 +
102 116 add_action( 'admin_init', __NAMESPACE__ . '\\parsely_admin_init_register' );
103 117 /**
104 118 * Registers the Parse.ly wp-admin warnings, plugin actions and row actions.
105 119 */
106 120 function parsely_admin_init_register(): void {
107 - $parsely = get_parsely();
121 + $parsely = $GLOBALS['parsely'];
108 122
109 123 ( new Admin_Warning( $parsely ) )->run();
110 124 ( new Plugins_Actions() )->run();
111 125 ( new Row_Actions( $parsely ) )->run();
112 - ( new Post_List_Stats( $parsely ) )->run();
126 + ( new Admin_Columns_Parsely_Stats( $parsely ) )->run();
113 127 ( new Site_Health( $parsely ) )->run();
114 - ( new Dashboard_Widget( $parsely ) )->run();
128 + ( new Dashboard_Widget() )->run();
115 129 }
116 130
131 +require_once __DIR__ . '/src/UI/class-settings-page.php';
132 +require_once __DIR__ . '/src/UI/class-network-admin-sites-list.php';
133 +
117 134 add_action( 'init', __NAMESPACE__ . '\\parsely_wp_admin_early_register' );
118 135 /**
119 136 * Registers the additions the Parse.ly wp-admin settings page and Multisite
120 137 * Network Admin Sites List table.
@@ -119,26 +136,32 @@
119 136 * Registers the additions the Parse.ly wp-admin settings page and Multisite
120 137 * Network Admin Sites List table.
121 138 */
122 139 function parsely_wp_admin_early_register(): void {
123 - $parsely = get_parsely();
124 -
125 - // Plugin dashboard page.
126 - $GLOBALS['parsely_dashboard_page'] = new Dashboard_Page( $parsely );
127 - $GLOBALS['parsely_dashboard_page']->run();
128 -
129 - // Plugin settings page.
130 - $GLOBALS['parsely_settings_page'] = new Settings_Page( $parsely );
140 + $GLOBALS['parsely_settings_page'] = new Settings_Page( $GLOBALS['parsely'] );
131 141 $GLOBALS['parsely_settings_page']->run();
132 142
133 - $network_admin_sites_list = new Network_Admin_Sites_List( $parsely );
143 + $network_admin_sites_list = new Network_Admin_Sites_List( $GLOBALS['parsely'] );
134 144 $network_admin_sites_list->run();
145 +}
135 146
136 - // Initialize the REST API Controller.
137 - $rest_api_controller = $parsely->get_rest_api_controller();
138 - $rest_api_controller->init();
139 -}
147 +require_once __DIR__ . '/src/RemoteAPI/interface-cache.php';
148 +require_once __DIR__ . '/src/RemoteAPI/interface-remote-api.php';
149 +require_once __DIR__ . '/src/RemoteAPI/class-remote-api-base.php';
150 +require_once __DIR__ . '/src/RemoteAPI/class-remote-api-cache.php';
151 +require_once __DIR__ . '/src/RemoteAPI/class-related-api.php';
152 +require_once __DIR__ . '/src/RemoteAPI/class-analytics-posts-api.php';
153 +require_once __DIR__ . '/src/RemoteAPI/class-analytics-post-detail-api.php';
154 +require_once __DIR__ . '/src/RemoteAPI/class-referrers-post-detail-api.php';
155 +require_once __DIR__ . '/src/RemoteAPI/class-wordpress-cache.php';
140 156
157 +require_once __DIR__ . '/src/Endpoints/class-base-api-proxy.php';
158 +require_once __DIR__ . '/src/Endpoints/class-related-api-proxy.php';
159 +require_once __DIR__ . '/src/Endpoints/class-analytics-posts-api-proxy.php';
160 +require_once __DIR__ . '/src/Endpoints/class-analytics-post-detail-api-proxy.php';
161 +require_once __DIR__ . '/src/Endpoints/class-referrers-post-detail-api-proxy.php';
162 +require_once __DIR__ . '/src/Endpoints/class-rest-metadata.php';
163 +
141 164 add_action( 'rest_api_init', __NAMESPACE__ . '\\parsely_rest_api_init' );
142 165 /**
143 166 * Registers REST Endpoints that act as a proxy to the Parse.ly API.
144 167 * This is needed to get around CORS issues with Firefox.
@@ -145,14 +168,39 @@
145 168 *
146 169 * @since 3.2.0
147 170 */
148 171 function parsely_rest_api_init(): void {
149 - $parsely = get_parsely();
172 + $wp_cache = new WordPress_Cache();
173 + $rest = new Rest_Metadata( $GLOBALS['parsely'] );
174 + $rest->run();
150 175
151 - $rest = new Rest_Metadata( $parsely );
152 - $rest->run();
176 + parsely_run_rest_api_endpoint(
177 + Related_API::class,
178 + Related_API_Proxy::class,
179 + $wp_cache
180 + );
181 +
182 + parsely_run_rest_api_endpoint(
183 + Analytics_Posts_API::class,
184 + Analytics_Posts_API_Proxy::class,
185 + $wp_cache
186 + );
187 +
188 + parsely_run_rest_api_endpoint(
189 + Analytics_Post_Detail_API::class,
190 + Analytics_Post_Detail_API_Proxy::class,
191 + $wp_cache
192 + );
193 +
194 + parsely_run_rest_api_endpoint(
195 + Referrers_Post_Detail_API::class,
196 + Referrers_Post_Detail_API_Proxy::class,
197 + $wp_cache
198 + );
153 199 }
154 200
201 +require_once __DIR__ . '/src/blocks/recommendations/class-recommendations-block.php';
202 +
155 203 add_action( 'init', __NAMESPACE__ . '\\init_recommendations_block' );
156 204 /**
157 205 * Registers the Recommendations Block.
158 206 */
@@ -160,50 +208,35 @@
160 208 $recommendations_block = new Recommendations_Block();
161 209 $recommendations_block->run();
162 210 }
163 211
164 -add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\\init_content_helper_editor_sidebar' );
212 +require_once __DIR__ . '/src/blocks/content-helper/class-content-helper.php';
213 +
214 +add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\init_content_helper' );
165 215 /**
166 216 * Inserts the PCH Editor Sidebar.
167 217 *
168 - * @since 3.5.0 Moved from Parsely\Scripts\enqueue_block_editor_assets().
169 - * @since 3.9.0 Renamed from init_content_helper().
218 + * @since 3.5.0 Moved from Parsely\Scripts\enqueue_block_editor_assets()
170 219 */
171 -function init_content_helper_editor_sidebar(): void {
172 - $GLOBALS['parsely_editor_sidebar']->run();
220 +function init_content_helper(): void {
221 + ( new Content_Helper() )->run();
173 222 }
174 223
175 -add_action( 'admin_init', __NAMESPACE__ . '\\parsely_content_helper_editor_sidebar_features' );
176 -add_action( 'rest_api_init', __NAMESPACE__ . '\\parsely_content_helper_editor_sidebar_features' );
177 -/**
178 - * Initializes the PCH Editor Sidebar features.
179 - *
180 - * @since 3.16.0
181 - */
182 -function parsely_content_helper_editor_sidebar_features(): void {
183 - if ( ! isset( $GLOBALS['parsely_editor_sidebar'] ) ) {
184 - /**
185 - * The Editor Sidebar instance.
186 - *
187 - * @since 3.16.0
188 - * @var Editor_Sidebar $GLOBALS['parsely_editor_sidebar']
189 - */
190 - $parsely = get_parsely();
224 +require_once __DIR__ . '/src/UI/class-recommended-widget.php';
191 225
192 - $GLOBALS['parsely_editor_sidebar'] = new Editor_Sidebar( $parsely );
193 - $GLOBALS['parsely_editor_sidebar']->init_features();
194 - }
195 -}
196 -
197 226 add_action( 'widgets_init', __NAMESPACE__ . '\\parsely_recommended_widget_register' );
198 227 /**
199 228 * Registers the Parse.ly Recommended widget.
200 229 */
201 230 function parsely_recommended_widget_register(): void {
202 - $parsely = get_parsely();
231 + register_widget( new Recommended_Widget( $GLOBALS['parsely'] ) );
232 +}
203 233
204 - register_widget( new Recommended_Widget( $parsely ) );
205 -}
234 +require_once __DIR__ . '/src/Integrations/class-integration.php';
235 +require_once __DIR__ . '/src/Integrations/class-integrations.php';
236 +require_once __DIR__ . '/src/Integrations/class-amp.php';
237 +require_once __DIR__ . '/src/Integrations/class-facebook-instant-articles.php';
238 +require_once __DIR__ . '/src/Integrations/class-google-web-stories.php';
206 239
207 240 add_action( 'init', __NAMESPACE__ . '\\parsely_integrations' ); // @phpstan-ignore-line
208 241 /**
209 242 * Instantiates Integrations collection and registers built-in integrations.
@@ -217,13 +250,14 @@
217 250 // If $parsely value is "", then this function is being called by the init
218 251 // hook and we can get the value from $GLOBALS. If $parsely is an instance
219 252 // of the Parsely object, then this function is being called by a test.
220 253 if ( ! is_object( $parsely ) || get_class( $parsely ) !== Parsely::class ) {
221 - $parsely = get_parsely();
254 + $parsely = $GLOBALS['parsely'];
222 255 }
223 256
224 257 $parsely_integrations = new Integrations( $parsely );
225 258 $parsely_integrations->register( 'amp', Amp::class );
259 + $parsely_integrations->register( 'fbia', Facebook_Instant_Articles::class );
226 260 $parsely_integrations->register( 'webstories', Google_Web_Stories::class );
227 261 $parsely_integrations = apply_filters( 'wp_parsely_add_integration', $parsely_integrations );
228 262 $parsely_integrations->integrate();
229 263
@@ -229,89 +263,34 @@
229 263
230 264 return $parsely_integrations;
231 265 }
232 266
233 -add_action( 'admin_init', __NAMESPACE__ . '\\parsely_check_data_schema_updates', 999 );
234 267 /**
235 - * Checks and performs any data schema updates.
268 + * Instantiates and runs the specified API endpoint.
236 269 *
237 - * @since 3.19.0 Handles the update from schema version 0 to 1.
270 + * @since 3.6.0
271 + *
272 + * @param string $api_class_name The proxy class to instantiate.
273 + * @param string $proxy_api_class_name The API proxy class to instantiate and run.
274 + * @param WordPress_Cache $wp_cache The WordPress cache instance to be used.
238 275 */
239 -function parsely_check_data_schema_updates(): void {
240 - $current_data_schema_version = get_option( 'parsely_data_schema_version' );
276 +function parsely_run_rest_api_endpoint(
277 + string $api_class_name,
278 + string $proxy_api_class_name,
279 + WordPress_Cache &$wp_cache
280 +): void {
281 + /**
282 + * Internal Variable.
283 + *
284 + * @var RemoteAPI\Remote_API_Base
285 + */
286 + $remote_api = new $api_class_name( $GLOBALS['parsely'] );
287 + $remote_api_cache = new Remote_API_Cache( $remote_api, $wp_cache );
241 288
242 - if ( false === $current_data_schema_version ) {
243 - $current_data_schema_version = 0;
244 - }
245 -
246 - if ( PARSELY_DATA_SCHEMA_VERSION <= $current_data_schema_version ) {
247 - return;
248 - }
249 -
250 289 /**
251 - * Updates the smart links to have the Smart Link Status terms,
252 - * and checks the _smart_link_applied meta, if it exists.
290 + * Internal Variable.
253 291 *
254 - * Schema version 1.
255 - *
256 - * @since 3.19.0
292 + * @var Endpoints\Base_API_Proxy
257 293 */
258 - if ( 0 === $current_data_schema_version ) {
259 - // Get all the smart links that do not have any Smart Link Status terms.
260 - // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.get_posts_get_posts
261 - $smart_links_without_status = get_posts(
262 - array(
263 - 'post_type' => 'parsely_smart_link',
264 - 'posts_per_page' => -1,
265 - 'fields' => 'ids',
266 - // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
267 - 'tax_query' => array(
268 - array(
269 - 'taxonomy' => 'smart_link_status',
270 - 'field' => 'name',
271 - 'terms' => \Parsely\Models\Smart_Link_Status::get_all_statuses(),
272 - 'operator' => 'NOT IN',
273 - ),
274 - ),
275 - )
276 - );
277 -
278 - if ( count( $smart_links_without_status ) === 0 ) {
279 - update_option( 'parsely_data_schema_version', PARSELY_DATA_SCHEMA_VERSION );
280 - return;
281 - }
282 -
283 - // Loop through the smart links and update them to have the Smart Link Status terms.
284 - foreach ( $smart_links_without_status as $post_id ) {
285 - $smart_link = \Parsely\Models\Smart_Link::get_smart_link_by_id( intval( $post_id ) );
286 -
287 - if ( false === $smart_link ) {
288 - continue;
289 - }
290 -
291 - $meta_exists = metadata_exists( 'post', $post_id, '_smart_link_applied' );
292 -
293 - // If there is no meta, it means that the smart link is considered applied,
294 - // for backwards compatibility with Parse.ly < 3.18.0.
295 - if ( ! $meta_exists ) {
296 - $smart_link->set_status( \Parsely\Models\Smart_Link_Status::APPLIED, true );
297 - continue;
298 - }
299 -
300 - // Get the value of the _smart_link_applied meta.
301 - $meta_value = get_post_meta( $post_id, '_smart_link_applied', true );
302 -
303 - // If the meta value is true, then the smart link is considered applied.
304 - if ( 'true' === $meta_value || true === $meta_value ) {
305 - $smart_link->set_status( \Parsely\Models\Smart_Link_Status::APPLIED, true );
306 - } else {
307 - // If the meta value is not true, then the smart link is considered pending.
308 - $smart_link->set_status( \Parsely\Models\Smart_Link_Status::PENDING, true );
309 - }
310 -
311 - // Flush the cache for the smart link.
312 - $smart_link->flush_all_cache();
313 - }
314 -
315 - update_option( 'parsely_data_schema_version', PARSELY_DATA_SCHEMA_VERSION );
316 - }
294 + $remote_api_proxy = new $proxy_api_class_name( $GLOBALS['parsely'], $remote_api_cache );
295 + $remote_api_proxy->run();
317 296 }