PluginProbe
Pixel Gallery Addons for Elementor – Easy Grid, Creative Gallery, Drag and Drop Grid, Custom Grid Layout, Portfolio Gallery / 2.1.13
Pixel Gallery Addons for Elementor – Easy Grid, Creative Gallery, Drag and Drop Grid, Custom Grid Layout, Portfolio Gallery v2.1.13
2.1.14 2.1.13 2.1.12 2.1.11 2.1.10 2.1.9 2.1.8 2.1.7 trunk 1.2.2 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.4.0 1.4.1 1.4.10 1.4.11 1.4.2 1.4.3 1.4.5 1.4.6 All 74 releases
pixel-gallery / admin / admin.php

admin.php in Pixel Gallery Addons for Elementor – Easy Grid, Creative Gallery, Drag and Drop Grid, Custom Grid Layout, Portfolio Gallery 2.1.13, at admin/admin.php

267 lines 9.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace PixelGallery;
4
5 if (!defined('ABSPATH')) {
6 exit;
7 } // Exit if accessed directly
8
9
10 require_once BDTPG_ADMIN_PATH . 'class-settings-api.php';
11 // require_once BDTPG_ADMIN_PATH . 'admin-feeds.php';
12 // pixel gallery admin settings here
13 require_once BDTPG_ADMIN_PATH . 'admin-settings.php';
14
15 /**
16 * Admin class
17 */
18
19 class Admin {
20
21 public function __construct() {
22
23 // Embed the Script on our Plugin's Option Page Only
24 if (isset($_GET['page']) && ($_GET['page'] == 'pixel_gallery_options')) {
25 add_action('admin_enqueue_scripts', [$this, 'enqueue_styles']);
26 }
27
28 add_action('admin_init', [$this, 'admin_script']);
29
30 add_action('upgrader_process_complete', [$this, 'pixel_gallery_plugin_on_upgrade_process_complete'], 10, 2);
31
32 register_deactivation_hook(BDTPG__FILE__, [$this, 'pixel_gallery_plugin_on_deactivate']);
33
34 add_action('after_setup_theme', [$this, 'whitelabel']);
35
36 add_filter('plugin_action_links_' . BDTPG_PBNAME, [$this, 'plugin_action_links']);
37
38 }
39
40
41 function install_and_activate() {
42
43 // I don't know of any other redirect function, so this'll have to do.
44 wp_redirect(admin_url('admin.php?page=pixel_gallery_options'));
45 // You could use a header(sprintf('Location: %s', admin_url(...)); here instead too.
46 }
47
48 /**
49 * You can easily add white label branding for extended license or multi site license. Don't try for regular license otherwise your license will be invalid.
50 * @return [type] [description]
51 * Define BDTPG_WL for execute white label branding
52 */
53 public function whitelabel() {
54 if (defined('BDTPG_WL')) {
55 add_filter('gettext', [$this, 'pixel_gallery_name_change'], 20, 3);
56
57 if (defined('BDTPG_HIDE')) {
58 add_action('pre_current_active_plugins', [$this, 'hide_pixel_gallery']);
59 }
60 } else {
61 add_filter('plugin_row_meta', [$this, 'plugin_row_meta'], 10, 2);
62 add_filter('plugin_action_links_' . BDTPG_PBNAME, [$this, 'plugin_action_meta']);
63 }
64 }
65
66 /**
67 * Enqueue styles
68 * @access public
69 */
70
71 public function enqueue_styles() {
72
73 $direction_suffix = is_rtl() ? '.rtl' : '';
74
75 wp_enqueue_style('bdt-uikit', BDTPG_ADMIN_URL . 'assets/css/bdt-uikit'. $direction_suffix .'.css', [], '3.21.7');
76 wp_enqueue_style('pg-editor', BDTPG_ASSETS_URL . 'css/pg-editor.css', [], BDTPG_VER);
77 wp_enqueue_style('pg-admin', BDTPG_ADMIN_URL . 'assets/css/pg-admin.css', [], BDTPG_VER);
78
79
80 wp_enqueue_script('bdt-uikit', BDTPG_ADMIN_URL . 'assets/js/bdt-uikit.min.js', ['jquery'], '3.21.7');
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 if (BDTPG_PBNAME === $plugin_file) {
91 $row_meta = [
92 'docs' => '<a href="https://bdthemes.com/contact/" aria-label="' . esc_attr(__('Go for Get Support', 'pixel-gallery')) . '" target="_blank">' . __('Get Support', 'pixel-gallery') . '</a>',
93 'video' => '<a href="https://www.youtube.com/playlist?list=PLP0S85GEw7DPv5T-Ara11Zvplmk4ty0jy" aria-label="' . esc_attr(__('View Pixel Gallery Video Tutorials', 'pixel-gallery')) . '" target="_blank">' . __('Video Tutorials', 'pixel-gallery') . '</a>',
94 ];
95
96 $plugin_meta = array_merge($plugin_meta, $row_meta);
97 }
98
99 return $plugin_meta;
100 }
101
102 /**
103 * Plugin action links
104 * @access public
105 * @return array
106 */
107
108 public function plugin_action_links( $plugin_meta ) {
109
110 $row_meta = [
111 'settings' => '<a href="'.admin_url( 'admin.php?page=pixel_gallery_options' ) .'" aria-label="' . esc_attr(__('Go to settings', 'pixel-gallery')) . '" >' . __('Settings', 'pixel-gallery') . '</b></a>',
112 ];
113
114 $plugin_meta = array_merge($plugin_meta, $row_meta);
115
116 return $plugin_meta;
117 }
118
119 /**
120 * Action meta
121 * @access public
122 * @return array
123 */
124
125
126 public function plugin_action_meta($links) {
127
128 $links = array_merge([sprintf('<a href="%s">%s</a>', pixel_gallery_dashboard_link('#pixel_gallery_welcome'), esc_html__('Settings', 'pixel-gallery'))], $links);
129
130 $links = array_merge($links, [
131 sprintf(
132 '<a href="%s">%s</a>',
133 pixel_gallery_dashboard_link('#pixel_gallery_license_settings'),
134 esc_html__('License', 'pixel-gallery')
135 )
136 ]);
137
138 return $links;
139 }
140
141 /**
142 * Change Pixel Gallery Name
143 * @access public
144 * @return string
145 */
146
147 public function pixel_gallery_name_change($translated_text, $text, $domain) {
148 switch ($translated_text) {
149 case 'Pixel Gallery':
150 $translated_text = BDTPG_TITLE;
151 break;
152 }
153
154 return $translated_text;
155 }
156
157 /**
158 * Hiding plugins //still in testing purpose
159 * @access public
160 */
161
162 public function hide_pixel_gallery() {
163 global $wp_list_table;
164 $hide_plg_array = array('pixel-gallery/pixel-gallery.php');
165 $all_plugins = $wp_list_table->items;
166
167 foreach ($all_plugins as $key => $val) {
168 if (in_array($key, $hide_plg_array)) {
169 unset($wp_list_table->items[$key]);
170 }
171 }
172 }
173
174 /**
175 * Register admin script
176 * @access public
177 */
178
179 public function admin_script() {
180
181 if (is_admin()) { // for Admin Dashboard Only
182
183 if (isset($_GET['page']) && ($_GET['page'] == 'pixel_gallery_options')) {
184 wp_enqueue_script('chart', BDTPG_ADMIN_URL . 'assets/js/chart.min.js', ['jquery'], '2.7.3', true);
185 wp_enqueue_script('pg-admin', BDTPG_ADMIN_URL . 'assets/js/pg-admin.min.js', ['jquery', 'chart'], BDTPG_VER, true);
186 }else{
187 wp_enqueue_script('pg-admin', BDTPG_ADMIN_URL . 'assets/js/pg-admin.min.js', ['jquery'], BDTPG_VER, true);
188 }
189
190 wp_enqueue_script('jquery');
191 wp_enqueue_script('jquery-form');
192
193 wp_enqueue_style('bdt-admin-api-biggopti', BDTPG_ADMIN_URL . 'assets/css/pg-admin-api-biggopti.css', [], BDTPG_VER);
194 wp_enqueue_style('bdt-product-feed', BDTPG_ADMIN_URL . 'assets/css/pg-admin-feeds.css', [], BDTPG_VER);
195
196 wp_enqueue_script('pg-biggopti', BDTPG_ADMIN_URL . 'assets/js/pg-biggopti.min.js', ['jquery'], BDTPG_VER, true);
197 wp_enqueue_script('pg-admin-api-biggopti', BDTPG_ADMIN_URL . 'assets/js/pg-admin-api-biggopti.min.js', ['jquery'], BDTPG_VER, true);
198
199 $dismissals = get_option('bdt_biggopti_dismissals', []);
200 $dismissed_display_ids = [];
201 $prefix = 'bdt-admin-biggopti-api-biggopti-';
202 foreach (array_keys($dismissals) as $key) {
203 if (strpos($key, $prefix) === 0) {
204 $dismissed_display_ids[] = substr($key, strlen($prefix));
205 } else {
206 $dismissed_display_ids[] = $key;
207 }
208 }
209
210 $current_sector = '';
211 if ( isset( $_GET['page'] ) && $_GET['page'] === 'pixel_gallery_options' ) {
212 $current_sector = 'plugin_dashboard';
213 }
214
215 $script_config = [
216 'ajaxurl' => admin_url('admin-ajax.php'),
217 'nonce' => wp_create_nonce('pixel-gallery'),
218 'isPro' => function_exists('_is_pg_pro_activated') && _is_pg_pro_activated(),
219 'assetsUrl' => defined('BDTPG_ASSETS_URL') ? BDTPG_ASSETS_URL : '',
220 'dismissedDisplayIds' => $dismissed_display_ids,
221 'currentSector' => $current_sector,
222 ];
223
224 wp_localize_script('pg-biggopti', 'PixelGalleryBiggoptiConfig', $script_config);
225 wp_localize_script('pg-admin-api-biggopti', 'PixelGalleryAdminApiBiggoptiConfig', $script_config);
226
227 }
228 }
229
230 /**
231 * Drop Tables on deactivated plugin
232 * @access public
233 */
234
235 public function pixel_gallery_plugin_on_deactivate() {
236
237 global $wpdb;
238
239 $table_cat = $wpdb->prefix . 'pg_template_library_cat';
240 $table_post = $wpdb->prefix . 'pg_template_library_post';
241 $table_cat_post = $wpdb->prefix . 'pg_template_library_cat_post';
242 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange
243 $wpdb->query('DROP TABLE IF EXISTS ' . $table_cat_post);
244 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange
245 $wpdb->query('DROP TABLE IF EXISTS ' . $table_cat);
246 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange
247 $wpdb->query('DROP TABLE IF EXISTS ' . $table_post);
248 }
249
250 /**
251 * Upgrade Process Complete
252 * @access public
253 */
254
255 public function pixel_gallery_plugin_on_upgrade_process_complete($upgrader_object, $options) {
256 if (isset($options['action']) && $options['action'] == 'update' && $options['type'] == 'plugin') {
257 if (isset($options['plugins']) && is_array($options['plugins'])) {
258 foreach ($options['plugins'] as $each_plugin) {
259 if ($each_plugin == BDTPG_PBNAME) {
260 @$this->pixel_gallery_plugin_on_deactivate();
261 }
262 }
263 }
264 }
265 }
266 }
267