PluginProbe
Parse.ly / 2.5.1
Parse.ly v2.5.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 +37 -280 3.19.22.5.1 View file →
@@ -1,18 +1,18 @@
1 1 <?php
2 2 /**
3 3 * Parse.ly
4 4 *
5 - * @package Parsely
6 - * @author Parse.ly
7 - * @copyright 2012 Parse.ly
8 - * @license GPL-2.0-or-later
5 + * @package Parsely\wp-parsely
6 + * @author Parse.ly
7 + * @copyright 2012 Parse.ly
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
13 - * Description: This plugin makes it a snap to add Parse.ly tracking code and metadata to your WordPress blog.
14 - * Version: 3.19.2
12 + * Plugin URI: https://www.parse.ly/help/integration/wordpress
13 + * Description: This plugin makes it a snap to add Parse.ly tracking code to your WordPress blog.
14 + * Version: 2.5.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,301 +17,58 @@
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.2
22 - * Requires WP: 6.0.0
21 + * Requires PHP: 5.6
22 + * Requires WP: 4.0.0
23 23 */
24 24
25 -declare(strict_types=1);
25 +// If this file is called directly, abort.
26 +if ( ! defined( 'WPINC' ) ) {
27 + die;
28 +}
26 29
27 -namespace Parsely;
28 -
29 -use Parsely\Content_Helper\Dashboard_Widget;
30 -use Parsely\Content_Helper\Editor_Sidebar;
31 -use Parsely\Content_Helper\Post_List_Stats;
32 -use Parsely\Endpoints\GraphQL_Metadata;
33 -use Parsely\Endpoints\Rest_Metadata;
34 -use Parsely\Integrations\Amp;
35 -use Parsely\Integrations\Google_Web_Stories;
36 -use Parsely\Integrations\Integrations;
37 -use Parsely\UI\Admin_Bar;
38 -use Parsely\UI\Admin_Warning;
39 -use Parsely\UI\Dashboard_Page;
40 -use Parsely\UI\Metadata_Renderer;
41 -use Parsely\UI\Network_Admin_Sites_List;
42 -use Parsely\UI\Plugins_Actions;
43 -use Parsely\UI\Recommended_Widget;
44 -use Parsely\UI\Row_Actions;
45 -use Parsely\UI\Settings_Page;
46 -use Parsely\UI\Site_Health;
47 -
48 -if ( class_exists( Parsely::class ) ) {
30 +if ( class_exists( 'Parsely' ) ) {
49 31 return;
50 32 }
51 33
52 -const PARSELY_VERSION = '3.19.2';
53 -const PARSELY_FILE = __FILE__;
54 -const PARSELY_DATA_SCHEMA_VERSION = '1';
55 -const PARSELY_CACHE_GROUP = 'wp-parsely';
34 +define( 'PARSELY_VERSION', '2.5.1' );
56 35
57 -if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
58 - require_once __DIR__ . '/vendor/autoload.php';
36 +if ( ! defined( 'PARSELY_PLUGIN_BASENAME' ) ) {
37 + define( 'PARSELY_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
59 38 }
60 -
61 -// Load Telemetry classes.
62 -require_once __DIR__ . '/src/Telemetry/telemetry-init.php';
63 -
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'];
39 +if ( ! defined( 'PARSELY_PLUGIN_DIR' ) ) {
40 + define( 'PARSELY_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
77 41 }
78 -
79 -add_action( 'plugins_loaded', __NAMESPACE__ . '\\parsely_initialize_plugin' );
80 -/**
81 - * Registers the basic classes to initialize the plugin.
82 - */
83 -function parsely_initialize_plugin(): void {
84 - $parsely = get_parsely();
85 - $parsely->run();
86 -
87 - if ( class_exists( 'WPGraphQL' ) ) {
88 - $graphql = new GraphQL_Metadata( $parsely );
89 - $graphql->run();
90 - }
91 -
92 - $scripts = new Scripts( $parsely );
93 - $scripts->run();
94 -
95 - $admin_bar = new Admin_Bar( $parsely );
96 - $admin_bar->run();
97 -
98 - $metadata_renderer = new Metadata_Renderer( $parsely );
99 - $metadata_renderer->run();
42 +if ( ! defined( 'PARSELY_PLUGIN_URL' ) ) {
43 + define( 'PARSELY_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
100 44 }
101 45
102 -add_action( 'admin_init', __NAMESPACE__ . '\\parsely_admin_init_register' );
103 -/**
104 - * Registers the Parse.ly wp-admin warnings, plugin actions and row actions.
105 - */
106 -function parsely_admin_init_register(): void {
107 - $parsely = get_parsely();
46 +require PARSELY_PLUGIN_DIR . 'src/class-parsely.php';
108 47
109 - ( new Admin_Warning( $parsely ) )->run();
110 - ( new Plugins_Actions() )->run();
111 - ( new Row_Actions( $parsely ) )->run();
112 - ( new Post_List_Stats( $parsely ) )->run();
113 - ( new Site_Health( $parsely ) )->run();
114 - ( new Dashboard_Widget( $parsely ) )->run();
115 -}
48 +$GLOBALS['parsely'] = new Parsely();
116 49
117 -add_action( 'init', __NAMESPACE__ . '\\parsely_wp_admin_early_register' );
118 -/**
119 - * Registers the additions the Parse.ly wp-admin settings page and Multisite
120 - * Network Admin Sites List table.
121 - */
122 -function parsely_wp_admin_early_register(): void {
123 - $parsely = get_parsely();
50 +require PARSELY_PLUGIN_DIR . 'src/class-parsely-recommended-widget.php';
124 51
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 );
131 - $GLOBALS['parsely_settings_page']->run();
132 -
133 - $network_admin_sites_list = new Network_Admin_Sites_List( $parsely );
134 - $network_admin_sites_list->run();
135 -
136 - // Initialize the REST API Controller.
137 - $rest_api_controller = $parsely->get_rest_api_controller();
138 - $rest_api_controller->init();
139 -}
140 -
141 -add_action( 'rest_api_init', __NAMESPACE__ . '\\parsely_rest_api_init' );
52 +add_action( 'widgets_init', 'parsely_recommended_widget_register' );
142 53 /**
143 - * Registers REST Endpoints that act as a proxy to the Parse.ly API.
144 - * This is needed to get around CORS issues with Firefox.
145 - *
146 - * @since 3.2.0
54 + * Register the Parse.ly Recommended widget.
147 55 */
148 -function parsely_rest_api_init(): void {
149 - $parsely = get_parsely();
150 -
151 - $rest = new Rest_Metadata( $parsely );
152 - $rest->run();
56 +function parsely_recommended_widget_register() {
57 + register_widget( 'Parsely_Recommended_Widget' );
153 58 }
154 59
155 -add_action( 'init', __NAMESPACE__ . '\\init_recommendations_block' );
60 +add_action( 'init', 'parsely_load_textdomain' );
156 61 /**
157 - * Registers the Recommendations Block.
158 - */
159 -function init_recommendations_block(): void {
160 - $recommendations_block = new Recommendations_Block();
161 - $recommendations_block->run();
162 -}
163 -
164 -add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\\init_content_helper_editor_sidebar' );
165 -/**
166 - * Inserts the PCH Editor Sidebar.
62 + * Load plugin textdomain.
167 63 *
168 - * @since 3.5.0 Moved from Parsely\Scripts\enqueue_block_editor_assets().
169 - * @since 3.9.0 Renamed from init_content_helper().
170 - */
171 -function init_content_helper_editor_sidebar(): void {
172 - $GLOBALS['parsely_editor_sidebar']->run();
173 -}
174 -
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.
64 + * Only look for WP_LANG_DIR . '/plugins/wp-parsely-' . $locale . '.mo'.
65 + * WP_LANG_DIR is usually WP_CONTENT_DIR . '/languages/'.
66 + * No other fallback location is supported.
179 67 *
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();
191 -
192 - $GLOBALS['parsely_editor_sidebar'] = new Editor_Sidebar( $parsely );
193 - $GLOBALS['parsely_editor_sidebar']->init_features();
194 - }
195 -}
196 -
197 -add_action( 'widgets_init', __NAMESPACE__ . '\\parsely_recommended_widget_register' );
198 -/**
199 - * Registers the Parse.ly Recommended widget.
200 - */
201 -function parsely_recommended_widget_register(): void {
202 - $parsely = get_parsely();
203 -
204 - register_widget( new Recommended_Widget( $parsely ) );
205 -}
206 -
207 -add_action( 'init', __NAMESPACE__ . '\\parsely_integrations' ); // @phpstan-ignore-line
208 -/**
209 - * Instantiates Integrations collection and registers built-in integrations.
68 + * This can be removed once minimum supported WordPress is 4.6 or later.
210 69 *
211 - * @since 2.6.0
212 - *
213 - * @param Parsely|string|null $parsely The Parsely object to pass to the integrations.
214 - * @return Integrations
70 + * @since 2.5.0
215 71 */
216 -function parsely_integrations( $parsely = null ): Integrations {
217 - // If $parsely value is "", then this function is being called by the init
218 - // hook and we can get the value from $GLOBALS. If $parsely is an instance
219 - // of the Parsely object, then this function is being called by a test.
220 - if ( ! is_object( $parsely ) || get_class( $parsely ) !== Parsely::class ) {
221 - $parsely = get_parsely();
222 - }
223 -
224 - $parsely_integrations = new Integrations( $parsely );
225 - $parsely_integrations->register( 'amp', Amp::class );
226 - $parsely_integrations->register( 'webstories', Google_Web_Stories::class );
227 - $parsely_integrations = apply_filters( 'wp_parsely_add_integration', $parsely_integrations );
228 - $parsely_integrations->integrate();
229 -
230 - return $parsely_integrations;
231 -}
232 -
233 -add_action( 'admin_init', __NAMESPACE__ . '\\parsely_check_data_schema_updates', 999 );
234 -/**
235 - * Checks and performs any data schema updates.
236 - *
237 - * @since 3.19.0 Handles the update from schema version 0 to 1.
238 - */
239 -function parsely_check_data_schema_updates(): void {
240 - $current_data_schema_version = get_option( 'parsely_data_schema_version' );
241 -
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 - /**
251 - * Updates the smart links to have the Smart Link Status terms,
252 - * and checks the _smart_link_applied meta, if it exists.
253 - *
254 - * Schema version 1.
255 - *
256 - * @since 3.19.0
257 - */
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 - }
72 +function parsely_load_textdomain() {
73 + load_plugin_textdomain( 'wp-parsely' );
317 74 }