modal.php
56 lines
| 1 | <?php |
| 2 | if ( ! defined('ABSPATH')) { |
| 3 | exit; |
| 4 | } |
| 5 | |
| 6 | if ( ! function_exists('rsssl_plugin_plugin_page_scripts')) { |
| 7 | function rsssl_plugin_plugin_page_scripts($hook) |
| 8 | { |
| 9 | if ( $hook !== 'plugins.php' && $hook !== 'plugins-network.php' ) { |
| 10 | return; |
| 11 | } |
| 12 | |
| 13 | $js_data = rsssl_get_chunk_translations( 'modal/build' ); |
| 14 | if (empty($js_data)) { |
| 15 | return; |
| 16 | } |
| 17 | |
| 18 | wp_enqueue_style('wp-components'); |
| 19 | $handle = 'rsssl-modal'; |
| 20 | wp_enqueue_script( |
| 21 | $handle, |
| 22 | plugins_url('build/' . $js_data['js_file'], __FILE__), |
| 23 | $js_data['dependencies'], |
| 24 | $js_data['version'], |
| 25 | true |
| 26 | ); |
| 27 | wp_set_script_translations($handle, 'really-simple-ssl'); |
| 28 | $token = wp_create_nonce('rsssl_deactivate_plugin'); |
| 29 | $deactivate_keep_ssl_link = rsssl_admin_url([ 'action' => 'uninstall_keep_ssl', 'token' => $token ]); |
| 30 | $deactivate_revert_ssl_link = rsssl_admin_url([ 'action' => 'uninstall_revert_ssl', 'token' => $token ]); |
| 31 | |
| 32 | wp_localize_script( |
| 33 | $handle, |
| 34 | 'rsssl_modal', |
| 35 | apply_filters('rsssl_localize_script', [ |
| 36 | 'json_translations' => $js_data['json_translations'], |
| 37 | 'plugin_url' => rsssl_url, |
| 38 | 'deactivate_keep_https' => $deactivate_keep_ssl_link, |
| 39 | 'deactivate_revert_https' => $deactivate_revert_ssl_link, |
| 40 | 'pro_plugin_active' => defined('rsssl_pro'), |
| 41 | ]) |
| 42 | ); |
| 43 | |
| 44 | function rsssl_add_modal_root_div() |
| 45 | { |
| 46 | // Check if we're on the plugins page (single site or network admin) |
| 47 | $screen = get_current_screen(); |
| 48 | if ($screen && ($screen->id === 'plugins' || $screen->id === 'plugins-network')) { |
| 49 | echo '<div id="rsssl-modal-root"></div>'; |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | add_action('admin_footer', 'rsssl_add_modal_root_div'); |
| 54 | } |
| 55 | } |
| 56 | add_action('admin_enqueue_scripts', 'rsssl_plugin_plugin_page_scripts'); |