PluginProbe
Parse.ly / 3.17.0
Parse.ly v3.17.0
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
wp-parsely / wp-parsely.php

wp-parsely.php in Parse.ly 3.17.0, at wp-parsely.php

204 lines 6.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Parse.ly
4 *
5 * @package Parsely
6 * @author Parse.ly
7 * @copyright 2012 Parse.ly
8 * @license GPL-2.0-or-later
9 *
10 * @wordpress-plugin
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.17.0
15 * Author: Parse.ly
16 * Author URI: https://www.parse.ly
17 * Text Domain: wp-parsely
18 * License: GPL-2.0-or-later
19 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
20 * GitHub Plugin URI: https://github.com/Parsely/wp-parsely
21 * Requires PHP: 7.2
22 * Requires WP: 5.0.0
23 */
24
25 declare(strict_types=1);
26
27 namespace Parsely;
28
29 use Parsely\Content_Helper\Dashboard_Widget;
30 use Parsely\Content_Helper\Editor_Sidebar;
31 use Parsely\Content_Helper\Excerpt_Suggestions;
32 use Parsely\Content_Helper\Post_List_Stats;
33 use Parsely\Endpoints\GraphQL_Metadata;
34 use Parsely\Endpoints\Rest_Metadata;
35 use Parsely\Integrations\Amp;
36 use Parsely\Integrations\Google_Web_Stories;
37 use Parsely\Integrations\Integrations;
38 use Parsely\REST_API\REST_API_Controller;
39 use Parsely\UI\Admin_Bar;
40 use Parsely\UI\Admin_Warning;
41 use Parsely\UI\Metadata_Renderer;
42 use Parsely\UI\Network_Admin_Sites_List;
43 use Parsely\UI\Plugins_Actions;
44 use Parsely\UI\Recommended_Widget;
45 use Parsely\UI\Row_Actions;
46 use Parsely\UI\Settings_Page;
47 use Parsely\UI\Site_Health;
48
49 if ( class_exists( Parsely::class ) ) {
50 return;
51 }
52
53 const PARSELY_VERSION = '3.17.0';
54 const PARSELY_FILE = __FILE__;
55
56 if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
57 require_once __DIR__ . '/vendor/autoload.php';
58 }
59
60 // Load Telemetry classes.
61 require_once __DIR__ . '/src/Telemetry/telemetry-init.php';
62
63
64 add_action( 'plugins_loaded', __NAMESPACE__ . '\\parsely_initialize_plugin' );
65 /**
66 * Registers the basic classes to initialize the plugin.
67 */
68 function parsely_initialize_plugin(): void {
69 $GLOBALS['parsely'] = new Parsely();
70 $GLOBALS['parsely']->run();
71
72 if ( class_exists( 'WPGraphQL' ) ) {
73 $graphql = new GraphQL_Metadata( $GLOBALS['parsely'] );
74 $graphql->run();
75 }
76
77 $scripts = new Scripts( $GLOBALS['parsely'] );
78 $scripts->run();
79
80 $admin_bar = new Admin_Bar( $GLOBALS['parsely'] );
81 $admin_bar->run();
82
83 $metadata_renderer = new Metadata_Renderer( $GLOBALS['parsely'] );
84 $metadata_renderer->run();
85 }
86
87 add_action( 'admin_init', __NAMESPACE__ . '\\parsely_admin_init_register' );
88 /**
89 * Registers the Parse.ly wp-admin warnings, plugin actions and row actions.
90 */
91 function parsely_admin_init_register(): void {
92 $parsely = $GLOBALS['parsely'];
93
94 ( new Admin_Warning( $parsely ) )->run();
95 ( new Plugins_Actions() )->run();
96 ( new Row_Actions( $parsely ) )->run();
97 ( new Post_List_Stats( $parsely ) )->run();
98 ( new Site_Health( $parsely ) )->run();
99 ( new Dashboard_Widget( $parsely ) )->run();
100 }
101
102 add_action( 'init', __NAMESPACE__ . '\\parsely_wp_admin_early_register' );
103 /**
104 * Registers the additions the Parse.ly wp-admin settings page and Multisite
105 * Network Admin Sites List table.
106 */
107 function parsely_wp_admin_early_register(): void {
108 $GLOBALS['parsely_settings_page'] = new Settings_Page( $GLOBALS['parsely'] );
109 $GLOBALS['parsely_settings_page']->run();
110
111 $network_admin_sites_list = new Network_Admin_Sites_List( $GLOBALS['parsely'] );
112 $network_admin_sites_list->run();
113
114 // Initialize the REST API Controller.
115 $rest_api_controller = $GLOBALS['parsely']->get_rest_api_controller();
116 $rest_api_controller->init();
117 }
118
119 add_action( 'rest_api_init', __NAMESPACE__ . '\\parsely_rest_api_init' );
120 /**
121 * Registers REST Endpoints that act as a proxy to the Parse.ly API.
122 * This is needed to get around CORS issues with Firefox.
123 *
124 * @since 3.2.0
125 */
126 function parsely_rest_api_init(): void {
127 $rest = new Rest_Metadata( $GLOBALS['parsely'] );
128 $rest->run();
129 }
130
131 add_action( 'init', __NAMESPACE__ . '\\init_recommendations_block' );
132 /**
133 * Registers the Recommendations Block.
134 */
135 function init_recommendations_block(): void {
136 $recommendations_block = new Recommendations_Block();
137 $recommendations_block->run();
138 }
139
140 add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\\init_content_helper_editor_sidebar' );
141 /**
142 * Inserts the PCH Editor Sidebar.
143 *
144 * @since 3.5.0 Moved from Parsely\Scripts\enqueue_block_editor_assets().
145 * @since 3.9.0 Renamed from init_content_helper().
146 */
147 function init_content_helper_editor_sidebar(): void {
148 $GLOBALS['parsely_editor_sidebar']->run();
149 }
150
151 add_action( 'admin_init', __NAMESPACE__ . '\\parsely_content_helper_editor_sidebar_features' );
152 add_action( 'rest_api_init', __NAMESPACE__ . '\\parsely_content_helper_editor_sidebar_features' );
153 /**
154 * Initializes the PCH Editor Sidebar features.
155 *
156 * @since 3.16.0
157 */
158 function parsely_content_helper_editor_sidebar_features(): void {
159 if ( ! isset( $GLOBALS['parsely_editor_sidebar'] ) ) {
160 /**
161 * The Editor Sidebar instance.
162 *
163 * @since 3.16.0
164 * @var Editor_Sidebar $GLOBALS['parsely_editor_sidebar']
165 */
166 $GLOBALS['parsely_editor_sidebar'] = new Editor_Sidebar( $GLOBALS['parsely'] );
167 $GLOBALS['parsely_editor_sidebar']->init_features();
168 }
169 }
170
171 add_action( 'widgets_init', __NAMESPACE__ . '\\parsely_recommended_widget_register' );
172 /**
173 * Registers the Parse.ly Recommended widget.
174 */
175 function parsely_recommended_widget_register(): void {
176 register_widget( new Recommended_Widget( $GLOBALS['parsely'] ) );
177 }
178
179 add_action( 'init', __NAMESPACE__ . '\\parsely_integrations' ); // @phpstan-ignore-line
180 /**
181 * Instantiates Integrations collection and registers built-in integrations.
182 *
183 * @since 2.6.0
184 *
185 * @param Parsely|string|null $parsely The Parsely object to pass to the integrations.
186 * @return Integrations
187 */
188 function parsely_integrations( $parsely = null ): Integrations {
189 // If $parsely value is "", then this function is being called by the init
190 // hook and we can get the value from $GLOBALS. If $parsely is an instance
191 // of the Parsely object, then this function is being called by a test.
192 if ( ! is_object( $parsely ) || get_class( $parsely ) !== Parsely::class ) {
193 $parsely = $GLOBALS['parsely'];
194 }
195
196 $parsely_integrations = new Integrations( $parsely );
197 $parsely_integrations->register( 'amp', Amp::class );
198 $parsely_integrations->register( 'webstories', Google_Web_Stories::class );
199 $parsely_integrations = apply_filters( 'wp_parsely_add_integration', $parsely_integrations );
200 $parsely_integrations->integrate();
201
202 return $parsely_integrations;
203 }
204