PluginProbe
Code Snippets / 4.0.0-beta.2
Code Snippets v4.0.0-beta.2
4.0.0-beta.2 3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 All 65 releases
← All changes | php/Plugin.php +45 -25 3.10.14.0.0-beta.2 View file →
@@ -2,8 +2,12 @@
2 2
3 3 namespace Code_Snippets;
4 4
5 5 use Code_Snippets\Admin\Bootstrap_Admin;
6 +use Code_Snippets\Admin\Feedback_Error_Capture;
7 +use Code_Snippets\Admin\Feedback_Panel;
8 +use Code_Snippets\Admin\Menus\Manage\Manage_Menu;
9 +use Code_Snippets\Client\Feedback_Client;
6 10 use Code_Snippets\Controller\Cloud_Search_Controller;
7 11 use Code_Snippets\Core\DB;
8 12 use Code_Snippets\Core\Licensing;
9 13 use Code_Snippets\Core\Upgrader;
@@ -13,12 +17,16 @@
13 17 use Code_Snippets\Integration\Evaluate_Functions;
14 18 use Code_Snippets\Integration\Promotions\Promotion_Manager;
15 19 use Code_Snippets\Integration\Shortcodes;
16 20 use Code_Snippets\Model\Basic_Cloud_Connection;
21 +use Code_Snippets\Model\Feedback_Connection;
17 22 use Code_Snippets\REST_API\Cloud\Cloud_Snippets_REST_Controller;
23 +use Code_Snippets\REST_API\Feedback\Feedback_REST_Controller;
18 24 use Code_Snippets\REST_API\Import\File_Import_REST_Controller;
19 25 use Code_Snippets\REST_API\Import\Plugins_Import_REST_Controller;
20 -use Code_Snippets\REST_API\Snippets\Preferences_REST_Controller;
26 +use Code_Snippets\REST_API\Preferences\Demos_Seen_REST_Controller;
27 +use Code_Snippets\REST_API\Preferences\Insights_View_Rest_Controller;
28 +use Code_Snippets\REST_API\Preferences\Snippet_View_REST_Controller;
21 29 use Code_Snippets\REST_API\Snippets\Recently_Active_REST_Controller;
22 30 use Code_Snippets\REST_API\Snippets\Snippets_REST_Controller;
23 31 use function Code_Snippets\Settings\are_settings_unified;
24 32
@@ -107,9 +115,9 @@
107 115 require_once __DIR__ . '/snippet-ops.php';
108 116 }
109 117
110 118 /**
111 - * Initialise the plugin and load all necessary classes.
119 + * Initialize the plugin and load all necessary classes.
112 120 */
113 121 public function load_plugin() {
114 122 $this->load_utilities();
115 123
@@ -125,8 +133,9 @@
125 133
126 134 if ( is_admin() ) {
127 135 $this->admin = new Bootstrap_Admin();
128 136 new Promotion_Manager();
137 + new Feedback_Error_Capture( new Feedback_Panel() );
129 138 }
130 139
131 140 new Shortcodes();
132 141 new MCE_Plugin();
@@ -132,12 +141,8 @@
132 141 new MCE_Plugin();
133 142 new Upgrader( PLUGIN_VERSION, $this->db );
134 143 new Admin_Bar();
135 144
136 - if ( is_admin() ) {
137 - new Promotion_Manager();
138 - }
139 -
140 145 $this->init_snippet_files();
141 146
142 147 add_action( 'rest_api_init', [ $this, 'init_rest_api' ], 1 );
143 148 }
@@ -151,17 +156,23 @@
151 156 $cloud_search = new Cloud_Search_Controller( $this->cloud_connection );
152 157
153 158 new Snippets_REST_Controller();
154 159 new Recently_Active_REST_Controller();
155 - new Preferences_REST_Controller();
160 +
161 + new Snippet_View_REST_Controller();
162 + new Insights_View_Rest_Controller();
163 + new Demos_Seen_REST_Controller();
164 +
156 165 new Plugins_Import_REST_Controller();
157 166 new File_Import_REST_Controller();
158 167
159 168 new Cloud_Snippets_REST_Controller( $cloud_search );
169 +
170 + new Feedback_REST_Controller( new Feedback_Client( new Feedback_Connection() ) );
160 171 }
161 172
162 173 /**
163 - * Initialises the snippet files component.
174 + * Initializes the snippet files component.
164 175 *
165 176 * @return void
166 177 */
167 178 private function init_snippet_files() {
@@ -200,8 +211,9 @@
200 211 $edit = [ 'edit', 'edit-snippet' ];
201 212 $import = [ 'import', 'import-snippets', 'import-code-snippets' ];
202 213 $settings = [ 'settings', 'snippets-settings' ];
203 214 $cloud = [ 'cloud', 'cloud-snippets' ];
215 + $insights = [ 'insights', 'code-snippets-insights' ];
204 216 $welcome = [ 'welcome', 'getting-started', 'code-snippets' ];
205 217
206 218 if ( in_array( $menu, $edit, true ) ) {
207 219 return 'edit-snippet';
@@ -212,8 +224,10 @@
212 224 } elseif ( in_array( $menu, $settings, true ) ) {
213 225 return 'snippets-settings';
214 226 } elseif ( in_array( $menu, $cloud, true ) ) {
215 227 return 'snippets&subpage=cloud-community';
228 + } elseif ( in_array( $menu, $insights, true ) ) {
229 + return 'code-snippets-insights';
216 230 } elseif ( in_array( $menu, $welcome, true ) ) {
217 231 return 'code-snippets-welcome';
218 232 } else {
219 233 return 'snippets';
@@ -340,9 +354,9 @@
340 354 : $this->get_cap_name();
341 355 }
342 356
343 357 /**
344 - * Localise a plugin script to provide the CODE_SNIPPETS object.
358 + * Localize a plugin script to provide the CODE_SNIPPETS object.
345 359 *
346 360 * @param string $handle Script handle.
347 361 *
348 362 * @return void
@@ -351,18 +365,22 @@
351 365 wp_localize_script(
352 366 $handle,
353 367 'CODE_SNIPPETS',
354 368 [
355 - 'debug' => defined( 'WP_DEBUG' ) && WP_DEBUG,
356 - 'isLicensed' => $this->licensing->is_licensed(),
357 - 'isCloudConnected' => $this->cloud_connection->is_authenticated(),
358 - 'hideUpsell' => Settings\get_setting( 'general', 'hide_upgrade_menu' ),
359 - 'snippetView' => Preferences_REST_Controller::get_snippet_view(),
360 - 'restAPI' => [
369 + 'debug' => defined( 'WP_DEBUG' ) && WP_DEBUG,
370 + 'isLicensed' => $this->licensing->is_licensed(),
371 + 'isCloudConnected' => $this->cloud_connection->is_authenticated(),
372 + 'hideUpsell' => Settings\get_setting( 'general', 'hide_upgrade_menu' ),
373 + 'snippetView' => Snippet_View_REST_Controller::get_snippet_view(),
374 + 'insightsChartViews' => Insights_View_Rest_Controller::get_insights_chart_views(),
375 + 'demosSeen' => Demos_Seen_REST_Controller::get_demos_seen(),
376 + 'restAPI' => [
361 377 'base' => esc_url_raw( rest_url() ),
362 378 'snippets' => esc_url_raw( rest_url( Snippets_REST_Controller::get_base_route() ) ),
363 379 'recentlyActive' => esc_url_raw( rest_url( Recently_Active_REST_Controller::get_base_route() ) ),
364 - 'preferences' => esc_url_raw( rest_url( Preferences_REST_Controller::get_base_route() ) ),
380 + 'snippetView' => esc_url_raw( rest_url( Snippet_View_REST_Controller::get_base_route() ) ),
381 + 'insightsView' => esc_url_raw( rest_url( Insights_View_Rest_Controller::get_base_route() ) ),
382 + 'demosSeen' => esc_url_raw( rest_url( Demos_Seen_REST_Controller::get_base_route() ) ),
365 383 'importPlugins' => esc_url_raw( rest_url( Plugins_Import_REST_Controller::get_base_route() ) ),
366 384 'importFiles' => esc_url_raw( rest_url( File_Import_REST_Controller::get_base_route() ) ),
367 385 'nonce' => wp_create_nonce( 'wp_rest' ),
368 386 'cloud' => [
@@ -369,17 +387,19 @@
369 387 'token' => $this->cloud_connection->get_local_token(),
370 388 'snippets' => esc_url_raw( rest_url( Cloud_Snippets_REST_Controller::get_base_route() ) ),
371 389 ],
372 390 ],
373 - 'urls' => [
374 - 'plugin' => esc_url_raw( plugins_url( '', PLUGIN_FILE ) ),
375 - 'manage' => esc_url_raw( $this->get_menu_url() ),
376 - 'edit' => esc_url_raw( $this->get_menu_url( 'edit' ) ),
377 - 'addNew' => esc_url_raw( $this->get_menu_url( 'add' ) ),
378 - 'welcome' => esc_url_raw( $this->get_menu_url( 'welcome' ) ),
379 - 'import' => esc_url_raw( $this->get_menu_url( 'import' ) ),
380 - 'cloud' => esc_url_raw( $this->cloud_connection->get_base_url() ),
381 - 'settings' => ! are_settings_unified() || is_super_admin()
391 + 'urls' => [
392 + 'plugin' => esc_url_raw( plugins_url( '', PLUGIN_FILE ) ),
393 + 'manage' => esc_url_raw( $this->get_menu_url() ),
394 + 'edit' => esc_url_raw( $this->get_menu_url( 'edit' ) ),
395 + 'addNew' => esc_url_raw( $this->get_menu_url( 'add' ) ),
396 + 'insights' => esc_url_raw( $this->get_menu_url( 'insights' ) ),
397 + 'welcome' => esc_url_raw( $this->get_menu_url( 'welcome' ) ),
398 + 'import' => esc_url_raw( $this->get_menu_url( 'import' ) ),
399 + 'cloud' => esc_url_raw( $this->cloud_connection->get_base_url() ),
400 + 'demoReset' => esc_url_raw( Manage_Menu::get_demo_reset_url() ),
401 + 'settings' => ! are_settings_unified() || is_super_admin()
382 402 ? esc_url_raw( $this->get_menu_url( 'settings' ) )
383 403 : null,
384 404 ],
385 405 ]