PluginProbe
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets / 4.1.18
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets v4.1.18
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.18, at admin/admin.php

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