PluginProbe
Ultimate Post Kit / trunk
Ultimate Post Kit vtrunk
4.2.1 4.2.2 4.2.3 4.5.0 4.5.2 4.5.3 4.2.0 4.1.18 4.1.17 4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.1.9 4.1.8 4.0.9 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.1.5 All 145 releases
ultimate-post-kit / admin / admin.php

admin.php in Ultimate Post Kit trunk, at admin/admin.php

225 lines 6.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace UltimatePostKit;
4
5 if (!defined('ABSPATH')) {
6 exit;
7 } // Exit if accessed directly
8
9
10 require_once BDTUPK_ADMIN_PATH . 'class-settings-api.php';
11
12 if (current_user_can('manage_options')) {
13 require_once BDTUPK_ADMIN_PATH . 'admin-feeds.php';
14 }
15
16 // element pack admin settings here
17 require_once BDTUPK_ADMIN_PATH . 'admin-settings.php';
18
19 /**
20 * Admin class
21 */
22
23 class Admin
24 {
25
26 public function __construct()
27 {
28
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.
31 if (isset($_GET['page']) && ($_GET['page'] == 'ultimate_post_kit_options')) {
32 add_action('admin_enqueue_scripts', [$this, 'enqueue_styles']);
33 }
34 add_action('admin_init', [$this, 'enqueue_admin_script']);
35
36 // Admin settings controller
37 require_once BDTUPK_ADMIN_PATH . 'module-settings.php';
38
39 // register_activation_hook(BDTUPK__FILE__, 'install_and_activate');
40
41 add_action('admin_init', [$this, 'admin_notice_styles']);
42
43 add_filter('plugin_action_links_' . BDTUPK_PBNAME, [$this, 'plugin_action_links']);
44
45 }
46
47 public function admin_notice_styles(){
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);
50 }
51
52
53 function install_and_activate()
54 {
55
56 wp_safe_redirect(admin_url('admin.php?page=ultimate_post_kit_options'));
57 exit;
58 }
59
60 /**
61 * Enqueue styles
62 * @access public
63 */
64
65 public function enqueue_styles()
66 {
67
68 $direction_suffix = is_rtl() ? '.rtl' : '';
69 // $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
70
71 wp_enqueue_style('upk-admin', BDTUPK_ADMIN_ASSETS_URL . 'css/upk-admin' . $direction_suffix . '.css', [], BDTUPK_VER);
72 wp_enqueue_script('upk-admin', BDTUPK_ASSETS_URL . 'js/upk-admin.min.js', ['jquery'], BDTUPK_VER, true);
73 wp_enqueue_style('upk-editor', BDTUPK_ASSETS_URL . 'css/upk-editor' . $direction_suffix . '.css', [], BDTUPK_VER);
74
75 wp_enqueue_style('bdt-uikit', BDTUPK_ADMIN_ASSETS_URL . 'css/bdt-uikit' . $direction_suffix . '.css', [], '3.17.0');
76 wp_enqueue_style('upk-font', BDTUPK_ASSETS_URL . 'css/upk-font' . $direction_suffix . '.css', [], BDTUPK_VER);
77
78 wp_enqueue_script('bdt-uikit', BDTUPK_ADMIN_ASSETS_URL . 'js/bdt-uikit.min.js', ['jquery'], '3.17.0', true);
79 }
80
81 /**
82 * Row meta
83 * @access public
84 * @return array
85 */
86
87 public function plugin_row_meta($plugin_meta, $plugin_file)
88 {
89 if (BDTUPK_PBNAME === $plugin_file) {
90 $row_meta = [
91 'docs' => '<a href="https://postkit.pro/contact/" aria-label="' . esc_attr(__('Go for Get Support', 'ultimate-post-kit')) . '" target="_blank">' . __('Get Support', 'ultimate-post-kit') . '</a>',
92 'video' => '<a href="https://www.youtube.com/playlist?list=PLP0S85GEw7DOJf_cbgUIL20qqwqb5x8KA" aria-label="' . esc_attr(__('View Ultimate Post Kit Video Tutorials', 'ultimate-post-kit')) . '" target="_blank">' . __('Video Tutorials', 'ultimate-post-kit') . '</a>',
93 ];
94
95 $plugin_meta = array_merge($plugin_meta, $row_meta);
96 }
97
98 return $plugin_meta;
99 }
100
101 /**
102 * Action meta
103 * @access public
104 * @return array
105 */
106
107
108 public function plugin_action_meta($links)
109 {
110
111 $links = array_merge([sprintf('<a href="%s">%s</a>', ultimate_post_kit_dashboard_link('#ultimate_post_kit_welcome'), esc_html__('Settings', 'ultimate-post-kit'))], $links);
112
113 $links = array_merge($links, [
114 sprintf(
115 '<a href="%s">%s</a>',
116 ultimate_post_kit_dashboard_link('#license'),
117 esc_html__('License', 'ultimate-post-kit')
118 )
119 ]);
120
121 return $links;
122 }
123
124 /**
125 * Plugin action links
126 * @access public
127 * @return array
128 */
129
130 public function plugin_action_links( $plugin_meta ) {
131
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 ];
135
136 $plugin_meta = array_merge($plugin_meta, $row_meta);
137
138 return $plugin_meta;
139 }
140
141 /**
142 * Change Ultimate Post Kit Name
143 * @access public
144 * @return string
145 */
146
147 public function ultimate_post_kit_name_change($translated_text, $text, $domain)
148 {
149 switch ($translated_text) {
150 case 'Ultimate Post Kit Pro':
151 $translated_text = BDTUPK_TITLE;
152 break;
153 }
154
155 return $translated_text;
156 }
157
158 /**
159 * Hiding plugins //still in testing purpose
160 * @access public
161 */
162
163 public function hide_ultimate_post_kit()
164 {
165 global $wp_list_table;
166 $hide_plg_array = array('ultimate-post-kit/ultimate-post-kit.php');
167 $all_plugins = $wp_list_table->items;
168
169 foreach ($all_plugins as $key => $val) {
170 if (in_array($key, $hide_plg_array)) {
171 unset($wp_list_table->items[$key]);
172 }
173 }
174 }
175
176 /**
177 * Register admin script
178 * @access public
179 */
180
181 public function enqueue_admin_script()
182 {
183
184 // $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
185 wp_enqueue_script('jquery');
186 wp_enqueue_script('jquery-form');
187 wp_enqueue_script('upk-biggopti', BDTUPK_ADMIN_ASSETS_URL . 'js/upk-biggopti.min.js', ['jquery'], BDTUPK_VER, true);
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 }
205 $script_config = [
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,
212 ];
213 wp_localize_script('upk-biggopti', 'UltimatePostKitBiggoptiConfig', $script_config);
214
215 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only check of the current admin page slug for asset routing, no form data processed.
216 if (isset($_GET['page']) && ($_GET['page'] == 'ultimate_post_kit_options')) {
217 wp_enqueue_script('chart', BDTUPK_ADMIN_ASSETS_URL . 'js/chart.min.js', ['jquery'], '4.5.1', true);
218 wp_enqueue_script('upk-admin', BDTUPK_ADMIN_ASSETS_URL . 'js/upk-admin.min.js', ['jquery', 'chart'], BDTUPK_VER, true);
219 }else{
220 wp_enqueue_script('upk-admin', BDTUPK_ADMIN_ASSETS_URL . 'js/upk-admin.min.js', ['jquery'], BDTUPK_VER, true);
221 }
222
223 }
224 }
225