admin-scripts.php
2 years ago
class-wpcode-admin-page-loader-lite.php
9 months ago
class-wpcode-connect.php
2 years ago
class-wpcode-metabox-snippets-lite.php
1 year ago
class-wpcode-usage-tracking-lite.php
3 years ago
notices.php
1 year ago
admin-scripts.php
72 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Load lite-specific scripts here. |
| 4 | * |
| 5 | * @package WPCode |
| 6 | */ |
| 7 | |
| 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | exit; |
| 10 | } |
| 11 | |
| 12 | add_action( 'admin_enqueue_scripts', 'wpcode_admin_scripts_global_lite' ); |
| 13 | add_action( 'admin_head', 'wpcode_listen_for_deploy_message' ); |
| 14 | |
| 15 | /** |
| 16 | * Load version-specific global scripts. |
| 17 | * |
| 18 | * @return void |
| 19 | */ |
| 20 | function wpcode_admin_scripts_global_lite() { |
| 21 | // Don't load global admin scripts if headers & footers mode is enabled. |
| 22 | if ( wpcode()->settings->get_option( 'headers_footers_mode' ) ) { |
| 23 | return; |
| 24 | } |
| 25 | wpcode_admin_scripts_global(); |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * This is loaded after the plugin is activated and if the installation process was initiated |
| 30 | * from the WPCode Library site it will redirect the user to the appropriate page to continue |
| 31 | * that process. |
| 32 | * |
| 33 | * @return void |
| 34 | */ |
| 35 | function wpcode_listen_for_deploy_message() { |
| 36 | // Load this only in the plugins list. |
| 37 | $screen = get_current_screen(); |
| 38 | $screens = array( |
| 39 | 'plugins', |
| 40 | 'plugin-install', |
| 41 | ); |
| 42 | if ( ! isset( $screen->id ) || ! in_array( $screen->id, $screens, true ) ) { |
| 43 | return; |
| 44 | } |
| 45 | $click_page = add_query_arg( |
| 46 | array( |
| 47 | 'page' => 'wpcode-click', |
| 48 | ), |
| 49 | admin_url( 'admin.php' ) |
| 50 | ) |
| 51 | ?> |
| 52 | <script> |
| 53 | if ( window.opener ) { |
| 54 | window.opener.postMessage( |
| 55 | 'wpcode-plugin-installed', |
| 56 | '<?php echo esc_url( wpcode()->library_auth->library_url ); ?>' |
| 57 | ); |
| 58 | } |
| 59 | window.addEventListener( |
| 60 | 'message', |
| 61 | ( event ) => { |
| 62 | if ( !event.isTrusted || '<?php echo esc_url( wpcode()->library_auth->library_url ); ?>' !== event.origin || 'wpcode-show-connect' !== event.data ) { |
| 63 | return; |
| 64 | } |
| 65 | window.location.href = '<?php echo esc_url( $click_page ); ?>&message=wpcode-deploy'; |
| 66 | }, |
| 67 | false |
| 68 | ); |
| 69 | </script> |
| 70 | <?php |
| 71 | } |
| 72 |