PluginProbe
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets / 4.1.8
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets v4.1.8
4.5.4 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 All 146 releases
ultimate-post-kit / admin / admin.php

admin.php in Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets 4.1.8, at admin/admin.php

228 lines 7.0 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 if (isset($_GET['page']) && ($_GET['page'] == 'ultimate_post_kit_options')) {
31 add_action('admin_enqueue_scripts', [$this, 'enqueue_styles']);
32 }
33 add_action('admin_init', [$this, 'enqueue_admin_script']);
34
35 // Admin settings controller
36 require_once BDTUPK_ADMIN_PATH . 'module-settings.php';
37
38 // register_activation_hook(BDTUPK__FILE__, 'install_and_activate');
39
40 add_action('admin_init', [$this, 'admin_notice_styles']);
41
42 add_filter('plugin_action_links_' . BDTUPK_PBNAME, [$this, 'plugin_action_links']);
43
44 }
45
46 public function admin_notice_styles(){
47 $direction_suffix = is_rtl() ? '.rtl' : '';
48 wp_enqueue_style('upk-admin-biggopti', BDTUPK_ADMIN_ASSETS_URL . 'css/upk-admin-biggopti' . $direction_suffix . '.css', [], BDTUPK_VER);
49 wp_enqueue_style('bdt-admin-api-biggopti', BDTUPK_ADMIN_ASSETS_URL . 'css/upk-admin-api-biggopti' . $direction_suffix . '.css', [], BDTUPK_VER);
50 wp_enqueue_style('bdt-product-feed', BDTUPK_ADMIN_ASSETS_URL . 'css/upk-product-feed' . $direction_suffix . '.css', [], BDTUPK_VER);
51 }
52
53
54 function install_and_activate()
55 {
56
57 // I don't know of any other redirect function, so this'll have to do.
58 wp_redirect(admin_url('admin.php?page=ultimate_post_kit_options'));
59 // You could use a header(sprintf('Location: %s', admin_url(...)); here instead too.
60 }
61
62 /**
63 * Enqueue styles
64 * @access public
65 */
66
67 public function enqueue_styles()
68 {
69
70 $direction_suffix = is_rtl() ? '.rtl' : '';
71 // $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
72
73 wp_enqueue_style('upk-admin', BDTUPK_ADMIN_ASSETS_URL . 'css/upk-admin' . $direction_suffix . '.css', [], BDTUPK_VER);
74 wp_enqueue_script('upk-admin', BDTUPK_ASSETS_URL . 'js/upk-admin.min.js', ['jquery'], BDTUPK_VER, true);
75 wp_enqueue_style('upk-editor', BDTUPK_ASSETS_URL . 'css/upk-editor' . $direction_suffix . '.css', [], BDTUPK_VER);
76
77 wp_enqueue_style('bdt-uikit', BDTUPK_ADMIN_ASSETS_URL . 'css/bdt-uikit' . $direction_suffix . '.css', [], '3.17.0');
78 wp_enqueue_style('upk-font', BDTUPK_ASSETS_URL . 'css/upk-font' . $direction_suffix . '.css', [], BDTUPK_VER);
79
80 wp_enqueue_script('bdt-uikit', BDTUPK_ADMIN_ASSETS_URL . 'js/bdt-uikit.min.js', ['jquery'], '3.17.0');
81 }
82
83 /**
84 * Row meta
85 * @access public
86 * @return array
87 */
88
89 public function plugin_row_meta($plugin_meta, $plugin_file)
90 {
91 if (BDTUPK_PBNAME === $plugin_file) {
92 $row_meta = [
93 '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>',
94 '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>',
95 ];
96
97 $plugin_meta = array_merge($plugin_meta, $row_meta);
98 }
99
100 return $plugin_meta;
101 }
102
103 /**
104 * Action meta
105 * @access public
106 * @return array
107 */
108
109
110 public function plugin_action_meta($links)
111 {
112
113 $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);
114
115 $links = array_merge($links, [
116 sprintf(
117 '<a href="%s">%s</a>',
118 ultimate_post_kit_dashboard_link('#license'),
119 esc_html__('License', 'ultimate-post-kit')
120 )
121 ]);
122
123 return $links;
124 }
125
126 /**
127 * Plugin action links
128 * @access public
129 * @return array
130 */
131
132 public function plugin_action_links( $plugin_meta ) {
133
134 $row_meta = [
135 '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>',
136 ];
137
138 $plugin_meta = array_merge($plugin_meta, $row_meta);
139
140 return $plugin_meta;
141 }
142
143 /**
144 * Change Ultimate Post Kit Name
145 * @access public
146 * @return string
147 */
148
149 public function ultimate_post_kit_name_change($translated_text, $text, $domain)
150 {
151 switch ($translated_text) {
152 case 'Ultimate Post Kit Pro':
153 $translated_text = BDTUPK_TITLE;
154 break;
155 }
156
157 return $translated_text;
158 }
159
160 /**
161 * Hiding plugins //still in testing purpose
162 * @access public
163 */
164
165 public function hide_ultimate_post_kit()
166 {
167 global $wp_list_table;
168 $hide_plg_array = array('ultimate-post-kit/ultimate-post-kit.php');
169 $all_plugins = $wp_list_table->items;
170
171 foreach ($all_plugins as $key => $val) {
172 if (in_array($key, $hide_plg_array)) {
173 unset($wp_list_table->items[$key]);
174 }
175 }
176 }
177
178 /**
179 * Register admin script
180 * @access public
181 */
182
183 public function enqueue_admin_script()
184 {
185
186 // $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
187 wp_enqueue_script('jquery');
188 wp_enqueue_script('jquery-form');
189 wp_enqueue_script('upk-biggopti', BDTUPK_ADMIN_ASSETS_URL . 'js/upk-biggopti.min.js', ['jquery'], BDTUPK_VER, true);
190
191 wp_enqueue_script('upk-admin-api-biggopti', BDTUPK_ADMIN_ASSETS_URL . 'js/upk-admin-api-biggopti.min.js', ['jquery'], BDTUPK_VER, true);
192
193 $dismissals = get_option('bdt_biggopti_dismissals', []);
194 $dismissed_display_ids = [];
195 $prefix = 'bdt-admin-biggopti-api-biggopti-';
196 foreach (array_keys($dismissals) as $key) {
197 if (strpos($key, $prefix) === 0) {
198 $dismissed_display_ids[] = substr($key, strlen($prefix));
199 } else {
200 $dismissed_display_ids[] = $key;
201 }
202 }
203
204 $current_sector = '';
205 if ( isset( $_GET['page'] ) && $_GET['page'] === 'ultimate_post_kit_options' ) {
206 $current_sector = 'plugin_dashboard';
207 }
208 $script_config = [
209 'ajaxurl' => admin_url('admin-ajax.php'),
210 'nonce' => wp_create_nonce('ultimate-post-kit'),
211 'isPro' => function_exists('_is_upk_pro_activated') && _is_upk_pro_activated(),
212 'assetsUrl' => defined('BDTUPK_ASSETS_URL') ? BDTUPK_ASSETS_URL : '',
213 'dismissedDisplayIds' => $dismissed_display_ids,
214 'currentSector' => $current_sector,
215 ];
216 wp_localize_script('upk-biggopti', 'UltimatePostKitBiggoptiConfig', $script_config);
217 wp_localize_script('upk-admin-api-biggopti', 'UltimatePostKitAdminApiBiggoptiConfig', $script_config);
218
219 if (isset($_GET['page']) && ($_GET['page'] == 'ultimate_post_kit_options')) {
220 wp_enqueue_script('chart', BDTUPK_ADMIN_ASSETS_URL . 'js/chart.min.js', ['jquery'], '3.9.1', true);
221 wp_enqueue_script('upk-admin', BDTUPK_ADMIN_ASSETS_URL . 'js/upk-admin.min.js', ['jquery', 'chart'], BDTUPK_VER, true);
222 }else{
223 wp_enqueue_script('upk-admin', BDTUPK_ADMIN_ASSETS_URL . 'js/upk-admin.min.js', ['jquery'], BDTUPK_VER, true);
224 }
225
226 }
227 }
228