| @@ -10,9 +10,8 @@ | ||
| 10 | 10 | use WPDataAccess\Data_Dictionary\WPDA_Dictionary_Lists; |
| 11 | 11 | use WPDataAccess\Data_Tables\WPDA_Data_Tables; |
| 12 | 12 | use WPDataAccess\Plugin_Table_Models\WPDA_Table_Settings_Model; |
| 13 | 13 | use WPDataAccess\Utilities\WPDA_Export; |
| 14 | -use WPDataAccess\Utilities\WPDA_Favourites; | |
| 15 | 14 | use WPDataAccess\WPDA; |
| 16 | 15 | use WPDataProjects\Utilities\WPDP_Export_Project; |
| 17 | 16 | use WPDataAccess\Backup\WPDA_Data_Export; |
| 18 | 17 | use WPDataAccess\Plugin_Table_Models\WPDA_CSV_Uploads_Model; |
| @@ -217,13 +216,8 @@ | ||
| 217 | 216 | $this->loader->add_action( 'wp_ajax_wpda_remove_new_dashboard_message', WPDA_Dashboard::class, 'remove_new_dashboard_message' ); |
| 218 | 217 | $this->loader->add_action( 'wp_ajax_wpda_widget_pub_add', WPDA_Widget_Publication::class, 'ajax_widget' ); |
| 219 | 218 | $this->loader->add_action( 'wp_ajax_wpda_widget_chart_add', WPDA_Widget_Google_Chart::class, 'ajax_widget' ); |
| 220 | 219 | $this->loader->add_action( 'wp_ajax_wpda_widget_chart_refresh', WPDA_Widget_Google_Chart::class, 'ajax_refresh' ); |
| 221 | - // Add/remove favourites. | |
| 222 | - // ??? | |
| 223 | - $plugin_favourites = new WPDA_Favourites(); | |
| 224 | - $this->loader->add_action( 'admin_action_wpda_add_favourite', $plugin_favourites, 'add' ); | |
| 225 | - $this->loader->add_action( 'admin_action_wpda_rem_favourite', $plugin_favourites, 'rem' ); | |
| 226 | 220 | $plugin_dictionary_list = new WPDA_Dictionary_Lists(); |
| 227 | 221 | // Get tables for a specific database. |
| 228 | 222 | $this->loader->add_action( 'admin_action_wpda_get_tables', $plugin_dictionary_list, 'get_tables_ajax' ); |
| 229 | 223 | // Get columns for a specific table. |
| @@ -368,8 +362,78 @@ | ||
| 368 | 362 | }, |
| 369 | 363 | 10, |
| 370 | 364 | 2 |
| 371 | 365 | ); |
| 366 | + // Add WP Data Access dashboard to freemius pages | |
| 367 | + add_action( 'admin_enqueue_scripts', function () { | |
| 368 | + if ( 'wpda_navi-account' === $this->page || 'wpda_navi-pricing' === $this->page || 'wpda_navi-affiliation' === $this->page ) { | |
| 369 | + wp_enqueue_script( 'jquery-ui-sortable' ); | |
| 370 | + wp_enqueue_script( 'jquery-ui-tooltip' ); | |
| 371 | + wp_enqueue_style( | |
| 372 | + 'wpdataaccess_dashboard', | |
| 373 | + plugins_url( '../assets/css/wpda_dashboard.css', __FILE__ ), | |
| 374 | + array(), | |
| 375 | + WPDA::get_option( WPDA::OPTION_WPDA_VERSION ) | |
| 376 | + ); | |
| 377 | + wp_enqueue_script( | |
| 378 | + 'wpdataaccess_dashboard', | |
| 379 | + plugins_url( '../assets/js/wpda_dashboard.js', __FILE__ ), | |
| 380 | + array(), | |
| 381 | + WPDA::get_option( WPDA::OPTION_WPDA_VERSION ), | |
| 382 | + false | |
| 383 | + ); | |
| 384 | + wp_localize_script( 'wpdataaccess_dashboard', 'wpda_dashboard_vars', array( | |
| 385 | + 'wpda_ajaxurl' => admin_url( 'admin-ajax.php' ), | |
| 386 | + ) ); | |
| 387 | + // SAVING SPACE - According to the plugin guidelines it is allowed to include external fonts: | |
| 388 | + // https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/#8-plugins-may-not-send-executable-code-via-third-party-systems . | |
| 389 | + // Load fontawesome icons. | |
| 390 | + // phpcs:disable WordPress.WP.EnqueuedResourceParameters.MissingVersion | |
| 391 | + wp_enqueue_style( | |
| 392 | + 'wpda_fontawesome_icons', | |
| 393 | + WPDA::CDN_FONTAWESOME . 'all.min.css', | |
| 394 | + array(), | |
| 395 | + null, | |
| 396 | + false | |
| 397 | + ); | |
| 398 | + // phpcs:enable WordPress.WP.EnqueuedResourceParameters.MissingVersion | |
| 399 | + // Add dashboards to freemius pages | |
| 400 | + wp_enqueue_style( | |
| 401 | + 'wpda_add_dashboard_freemius', | |
| 402 | + plugins_url( '../assets/css/wpda_freemius.css', __FILE__ ), | |
| 403 | + array(), | |
| 404 | + WPDA::get_option( WPDA::OPTION_WPDA_VERSION ) | |
| 405 | + ); | |
| 406 | + wp_enqueue_script( | |
| 407 | + 'wpda_add_dashboard_freemius', | |
| 408 | + plugins_url( '../assets/js/wpda_freemius.js', __FILE__ ), | |
| 409 | + array(), | |
| 410 | + WPDA::get_option( WPDA::OPTION_WPDA_VERSION ), | |
| 411 | + false | |
| 412 | + ); | |
| 413 | + ob_start(); | |
| 414 | + WPDA_Dashboard::add_dashboard(); | |
| 415 | + $freemius_dashboard = ob_get_clean(); | |
| 416 | + $freemius_title = ''; | |
| 417 | + if ( 'wpda_navi-affiliation' === $this->page ) { | |
| 418 | + $freemius_title = '<h1 class="wp-heading-inline" style="padding-top: 10px">WP Data Access Affiliate Program</h1>'; | |
| 419 | + } else { | |
| 420 | + if ( 'wpda_navi-pricing' === $this->page ) { | |
| 421 | + $freemius_title = '<h1 class="wp-heading-inline" style="padding-top: 10px">WP Data Access Plans and Pricing</h1><h2>Choose your plan and upgrade in minutes!</h2>'; | |
| 422 | + } else { | |
| 423 | + if ( 'wpda_navi-account' === $this->page ) { | |
| 424 | + $freemius_title = '<h1 class="wp-heading-inline" style="padding-top: 10px">WP Data Access Account</h1>'; | |
| 425 | + } | |
| 426 | + } | |
| 427 | + } | |
| 428 | + wp_localize_script( 'wpda_add_dashboard_freemius', 'dashboard', array( | |
| 429 | + 'content' => $freemius_dashboard . $freemius_title, | |
| 430 | + ) ); | |
| 431 | + // Remove notices | |
| 432 | + remove_all_actions( 'admin_notices' ); | |
| 433 | + remove_all_actions( 'all_admin_notices' ); | |
| 434 | + } | |
| 435 | + }, 9 ); | |
| 372 | 436 | } |
| 373 | 437 | |
| 374 | 438 | /** |
| 375 | 439 | * Needed for JDT to support IE |