| @@ -26,8 +26,9 @@ | ||
| 26 | 26 | public function __construct() |
| 27 | 27 | { |
| 28 | 28 | |
| 29 | 29 | // Embed the Script on our Plugin's Option Page Only |
| 30 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only check of the current admin page slug for asset routing, no form data processed. | |
| 30 | 31 | if (isset($_GET['page']) && ($_GET['page'] == 'ultimate_post_kit_options')) { |
| 31 | 32 | add_action('admin_enqueue_scripts', [$this, 'enqueue_styles']); |
| 32 | 33 | } |
| 33 | 34 | add_action('admin_init', [$this, 'enqueue_admin_script']); |
| @@ -43,9 +44,10 @@ | ||
| 43 | 44 | |
| 44 | 45 | } |
| 45 | 46 | |
| 46 | 47 | public function admin_notice_styles(){ |
| 47 | - wp_enqueue_style('upk-admin-biggopti', BDTUPK_ADMIN_ASSETS_URL . 'css/upk-admin-biggopti.css', [], BDTUPK_VER); | |
| 48 | + $direction_suffix = is_rtl() ? '.rtl' : ''; | |
| 49 | + wp_enqueue_style('upk-admin-biggopti', BDTUPK_ADMIN_ASSETS_URL . 'css/upk-admin-biggopti' . $direction_suffix . '.css', [], BDTUPK_VER); | |
| 48 | 50 | } |
| 49 | 51 | |
| 50 | 52 | |
| 51 | 53 | function install_and_activate() |
| @@ -50,11 +52,10 @@ | ||
| 50 | 52 | |
| 51 | 53 | function install_and_activate() |
| 52 | 54 | { |
| 53 | 55 | |
| 54 | - // I don't know of any other redirect function, so this'll have to do. | |
| 55 | - wp_redirect(admin_url('admin.php?page=ultimate_post_kit_options')); | |
| 56 | - // You could use a header(sprintf('Location: %s', admin_url(...)); here instead too. | |
| 56 | + wp_safe_redirect(admin_url('admin.php?page=ultimate_post_kit_options')); | |
| 57 | + exit; | |
| 57 | 58 | } |
| 58 | 59 | |
| 59 | 60 | /** |
| 60 | 61 | * Enqueue styles |
| @@ -73,9 +74,9 @@ | ||
| 73 | 74 | |
| 74 | 75 | wp_enqueue_style('bdt-uikit', BDTUPK_ADMIN_ASSETS_URL . 'css/bdt-uikit' . $direction_suffix . '.css', [], '3.17.0'); |
| 75 | 76 | wp_enqueue_style('upk-font', BDTUPK_ASSETS_URL . 'css/upk-font' . $direction_suffix . '.css', [], BDTUPK_VER); |
| 76 | 77 | |
| 77 | - wp_enqueue_script('bdt-uikit', BDTUPK_ADMIN_ASSETS_URL . 'js/bdt-uikit.min.js', ['jquery'], '3.17.0'); | |
| 78 | + wp_enqueue_script('bdt-uikit', BDTUPK_ADMIN_ASSETS_URL . 'js/bdt-uikit.min.js', ['jquery'], '3.17.0', true); | |
| 78 | 79 | } |
| 79 | 80 | |
| 80 | 81 | /** |
| 81 | 82 | * Row meta |
| @@ -127,18 +128,11 @@ | ||
| 127 | 128 | */ |
| 128 | 129 | |
| 129 | 130 | public function plugin_action_links( $plugin_meta ) { |
| 130 | 131 | |
| 131 | - if ( true !== _is_upk_pro_activated() ) { | |
| 132 | - $row_meta = [ | |
| 133 | - 'settings' => '<a href="'.admin_url( 'admin.php?page=ultimate_post_kit_options' ) .'" aria-label="' . esc_attr(__('Go to settings', 'ultimate-post-kit')) . '" >' . __('Settings', 'ultimate-post-kit') . '</b></a>', | |
| 134 | - 'gopro' => '<a href="https://bdthemes.com/deals/?utm_source=WordPress_org&utm_medium=bfcm_cta&utm_campaign=ultimate_post_kit" aria-label="' . esc_attr(__('Go get the pro version', 'ultimate-post-kit')) . '" target="_blank" title="When you purchase through this link you will get 87% discount!" class="upk-go-pro">' . __('Black Friday Limited Offer Up To 87% Off!', 'ultimate-post-kit') . '</a>', | |
| 135 | - ]; | |
| 136 | - } else { | |
| 137 | - $row_meta = [ | |
| 138 | - 'settings' => '<a href="'.admin_url( 'admin.php?page=ultimate_post_kit_options' ) .'" aria-label="' . esc_attr(__('Go to settings', 'ultimate-post-kit')) . '" >' . __('Settings', 'ultimate-post-kit') . '</b></a>', | |
| 139 | - ]; | |
| 140 | - } | |
| 132 | + $row_meta = [ | |
| 133 | + 'settings' => '<a href="'.admin_url( 'admin.php?page=ultimate_post_kit_options' ) .'" aria-label="' . esc_attr(__('Go to settings', 'ultimate-post-kit')) . '" >' . __('Settings', 'ultimate-post-kit') . '</b></a>', | |
| 134 | + ]; | |
| 141 | 135 | |
| 142 | 136 | $plugin_meta = array_merge($plugin_meta, $row_meta); |
| 143 | 137 | |
| 144 | 138 | return $plugin_meta; |
| @@ -191,16 +185,37 @@ | ||
| 191 | 185 | wp_enqueue_script('jquery'); |
| 192 | 186 | wp_enqueue_script('jquery-form'); |
| 193 | 187 | wp_enqueue_script('upk-biggopti', BDTUPK_ADMIN_ASSETS_URL . 'js/upk-biggopti.min.js', ['jquery'], BDTUPK_VER, true); |
| 194 | 188 | |
| 189 | + $dismissals = get_option('bdtupk_biggopti_dismissals', []); | |
| 190 | + $dismissed_display_ids = []; | |
| 191 | + $prefix = 'bdt-admin-biggopti-api-biggopti-'; | |
| 192 | + foreach (array_keys($dismissals) as $key) { | |
| 193 | + if (strpos($key, $prefix) === 0) { | |
| 194 | + $dismissed_display_ids[] = substr($key, strlen($prefix)); | |
| 195 | + } else { | |
| 196 | + $dismissed_display_ids[] = $key; | |
| 197 | + } | |
| 198 | + } | |
| 199 | + | |
| 200 | + $current_sector = ''; | |
| 201 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only check of the current admin page slug for display routing, no form data processed. | |
| 202 | + if ( isset( $_GET['page'] ) && $_GET['page'] === 'ultimate_post_kit_options' ) { | |
| 203 | + $current_sector = 'plugin_dashboard'; | |
| 204 | + } | |
| 195 | 205 | $script_config = [ |
| 196 | - 'ajaxurl' => admin_url('admin-ajax.php'), | |
| 197 | - 'nonce' => wp_create_nonce('ultimate-post-kit'), | |
| 206 | + 'ajaxurl' => admin_url('admin-ajax.php'), | |
| 207 | + 'nonce' => wp_create_nonce('ultimate-post-kit'), | |
| 208 | + 'isPro' => function_exists('_is_upk_pro_activated') && _is_upk_pro_activated(), | |
| 209 | + 'assetsUrl' => defined('BDTUPK_ASSETS_URL') ? BDTUPK_ASSETS_URL : '', | |
| 210 | + 'dismissedDisplayIds' => $dismissed_display_ids, | |
| 211 | + 'currentSector' => $current_sector, | |
| 198 | 212 | ]; |
| 199 | 213 | wp_localize_script('upk-biggopti', 'UltimatePostKitBiggoptiConfig', $script_config); |
| 200 | 214 | |
| 215 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only check of the current admin page slug for asset routing, no form data processed. | |
| 201 | 216 | if (isset($_GET['page']) && ($_GET['page'] == 'ultimate_post_kit_options')) { |
| 202 | - wp_enqueue_script('chart', BDTUPK_ADMIN_ASSETS_URL . 'js/chart.min.js', ['jquery'], '3.9.1', true); | |
| 217 | + wp_enqueue_script('chart', BDTUPK_ADMIN_ASSETS_URL . 'js/chart.min.js', ['jquery'], '4.5.1', true); | |
| 203 | 218 | wp_enqueue_script('upk-admin', BDTUPK_ADMIN_ASSETS_URL . 'js/upk-admin.min.js', ['jquery', 'chart'], BDTUPK_VER, true); |
| 204 | 219 | }else{ |
| 205 | 220 | wp_enqueue_script('upk-admin', BDTUPK_ADMIN_ASSETS_URL . 'js/upk-admin.min.js', ['jquery'], BDTUPK_VER, true); |
| 206 | 221 | } |