PluginProbe
Gmedia Photo Gallery / trunk
Gmedia Photo Gallery vtrunk
trunk 0.6.3 0.8.6 0.9.23 1.1.1 1.12.4 1.13.4 1.14.7 1.16.4 1.16.6 1.16.7 1.17.6 1.18.0 1.2.6 1.20.0 1.21.6 1.21.8 1.21.9 1.22.0 1.23.0 1.24.0 1.24.1 1.25.0 1.25.1 1.3.7 All 37 releases
grand-media / admin / admin.php

admin.php in Gmedia Photo Gallery trunk, at admin/admin.php

1,259 lines 63.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit;
4 }
5
6 /**
7 * GmediaAdmin - Admin Section for GRAND Media
8 */
9 class GmediaAdmin {
10 public $pages = [];
11 public $body_classes = [];
12
13 /**
14 * constructor
15 */
16 public function __construct() {
17 global $pagenow, $gmCore;
18
19 add_action( 'admin_head', [ &$this, 'admin_head' ] );
20
21 // Add the admin menu.
22 add_action( 'admin_menu', [ &$this, 'add_menu' ] );
23
24 // Add the script and style files.
25 add_action( 'admin_enqueue_scripts', [ &$this, 'load_scripts' ], 20 );
26 add_action( 'admin_print_scripts-widgets.php', [ &$this, 'gmedia_widget_scripts' ] );
27
28 add_action( 'enqueue_block_editor_assets', [ &$this, 'gutenberg_assets' ] );
29
30 add_filter( 'screen_settings', [ &$this, 'screen_settings' ], 10, 2 );
31 add_filter( 'set-screen-option', [ &$this, 'screen_settings_save' ], 11, 3 );
32 add_filter( 'set_screen_option_gm_screen_options', [ &$this, 'screen_settings_save' ], 11, 3 );
33
34 $page = $gmCore->_get( 'page' );
35 if ( $page && ( false !== strpos( $page, 'GrandMedia' ) ) ) {
36 $this->body_classes[] = 'grand-media-admin-page';
37
38 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only layout flag selects body classes, not an action.
39 if ( ! isset( $_GET['gmediablank'] ) || 'library' === $gmCore->_get( 'gmediablank' ) ) {
40 $this->body_classes[] = $page;
41 $mode = $gmCore->_get( 'mode' );
42 if ( $mode ) {
43 $this->body_classes[] = $page . '_' . $mode;
44 }
45 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Editor navigation only adds a body class.
46 if ( isset( $_GET['edit_term'] ) || isset( $_GET['gallery_module'] ) || isset( $_GET['preset'] ) ) {
47 $this->body_classes[] = $page . '_edit';
48 }
49 }
50
51 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Register an iframe route; the updater action verifies its nonce at gmedia_do_update.
52 if ( ( 'admin.php' === $pagenow ) && isset( $_GET['gmediablank'] ) ) {
53 add_action( 'admin_init', [ &$this, 'gmedia_blank_page' ] );
54 }
55
56 add_action( 'admin_footer', [ &$this, 'admin_footer' ] );
57 }
58
59 }
60
61 /**
62 * admin_head
63 */
64 public function admin_head() {
65 global $gmCore;
66
67 add_filter( 'admin_body_class', [ &$this, 'admin_body_class' ] );
68 ?>
69 <style id="gmedia_admin_menu_icon_css">
70 #adminmenu #toplevel_page_GrandMedia .wp-menu-image img {
71 width: 20px;
72 height: 20px;
73 box-sizing: content-box;
74 }
75 </style>
76 <?php
77
78 $page = $gmCore->_get( 'page' );
79 if ( $page && ( false !== strpos( $page, 'GrandMedia' ) ) ) {
80 ?>
81 <style id="gmedia_admin_css">html, body {
82 background: <?php echo isset( $_GET['gmediablank'] ) ? 'transparent' : '#708090'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only layout flag selects one of two literal colors. ?>;
83 }</style>
84 <?php
85 }
86 }
87
88 /**
89 * admin_body_class
90 *
91 * @param string $classes_string
92 *
93 * @return string
94 */
95 public function admin_body_class( $classes_string ) {
96 global $gmCore;
97
98 $classes = $this->body_classes;
99
100 $classes[] = $classes_string;
101 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only iframe layout flag; no form data is processed.
102 if ( isset( $_GET['gmediablank'] ) ) {
103 $classes[] = 'gmedia-blank gmedia_' . $gmCore->_get( 'gmediablank', '' );
104 }
105 $classes = array_filter( $classes );
106
107 return implode( ' ', $classes );
108 }
109
110 /**
111 * Load gmedia pages in wpless interface
112 */
113 public function gmedia_blank_page() {
114 global $gmCore, $gmDB, $gmProcessor, $gm_allowed_tags, $hook_suffix;
115 $gmediablank = $gmCore->_get( 'gmediablank', '' );
116 $allowed = true;
117 switch ( $gmediablank ) {
118 case 'update_plugin':
119 $allowed = current_user_can( 'manage_options' );
120 if ( $allowed ) {
121 check_admin_referer( 'gmedia_update' );
122 }
123 break;
124 case 'module_preview':
125 $allowed = current_user_can( 'gmedia_module_manage' );
126 break;
127 case 'library':
128 $allowed = current_user_can( 'gmedia_library' );
129 break;
130 case 'image_editor':
131 case 'map_editor':
132 $allowed = current_user_can( 'gmedia_library' ) && current_user_can( 'gmedia_edit_media' );
133 if ( $allowed ) {
134 $item = $gmDB->get_gmedia( (int) $gmCore->_get( 'id', 0 ) );
135 $allowed = $item && ( get_current_user_id() === (int) $item->author || current_user_can( 'gmedia_edit_others_media' ) );
136 }
137 break;
138 case 'comments':
139 $allowed = current_user_can( 'gmedia_library' );
140 if ( $allowed ) {
141 $gmedia_id = (int) $gmCore->_get( 'gmedia_id', 0 );
142 if ( $gmedia_id ) {
143 $item = $gmDB->get_gmedia( $gmedia_id );
144 $author = $item ? (int) $item->author : -1;
145 } else {
146 $term_id = (int) $gmCore->_get( 'gmedia_term_id', 0 );
147 $item = $term_id ? $gmDB->get_term( $term_id ) : null;
148 $author = $item ? (int) $item->global : -1;
149 }
150 // Match the library's read scope; comment editing retains WordPress's own checks.
151 $allowed = $item && ( 0 === $author || get_current_user_id() === $author || current_user_can( 'gmedia_show_others_media' ) );
152 }
153 break;
154 }
155 if ( ! $allowed ) {
156 wp_die( esc_html__( 'You are not allowed to run this process.', 'grand-media' ), '', array( 'response' => 403 ) );
157 }
158
159 set_current_screen( 'GrandMedia_Settings' );
160 $hook_suffix = 'gmedia_' . $gmediablank;
161 define( 'IFRAME_REQUEST', true );
162
163 iframe_header( 'GmediaGallery' );
164
165 echo '<div id="gmedia-container">';
166 switch ( $gmediablank ) {
167 case 'update_plugin':
168 require_once dirname( dirname( __FILE__ ) ) . '/config/update.php';
169 gmedia_do_update();
170 break;
171 case 'image_editor':
172 require_once dirname( dirname( __FILE__ ) ) . '/inc/image-editor.php';
173 gmedia_image_editor();
174 break;
175 case 'map_editor':
176 require_once dirname( dirname( __FILE__ ) ) . '/inc/map-editor.php';
177 gmedia_map_editor();
178 break;
179 case 'library':
180 echo '<div id="gmedia_iframe_content">';
181 echo '<div id="gm-message">' . wp_kses( $gmCore->alert( 'success', $gmProcessor->msg ) . $gmCore->alert( 'danger', $gmProcessor->error ), $gm_allowed_tags ) . '</div>';
182 include GMEDIA_ABSPATH . 'admin/pages/library/library.php';
183 echo '</div>';
184 break;
185 case 'comments':
186 require_once dirname( __FILE__ ) . '/tpl/comments.php';
187 break;
188 case 'module_preview':
189 require_once dirname( __FILE__ ) . '/tpl/module-preview.php';
190 break;
191 }
192 echo '</div>';
193
194 iframe_footer();
195 exit;
196 }
197
198 /** Integrate the menu. */
199 public function add_menu() {
200
201 $count = '';
202 if ( current_user_can( 'gmedia_module_manage' ) ) {
203 global $gmGallery;
204 if ( $gmGallery->options['modules_update'] ) {
205 $count .= ' <span class="update-plugins count-' . intval( $gmGallery->options['modules_update'] ) . '" style="background-color: #bb391b;"><span class="plugin-count gm-module-count gm-modules-update-count" title="' . esc_html__( 'Modules Updates', 'grand-media' ) . '">' . intval( $gmGallery->options['modules_update'] ) . '</span></span>';
206 }
207 if ( $gmGallery->options['modules_new'] && ! empty( $gmGallery->options['notify_new_modules'] ) ) {
208 $count .= ' <span class="update-plugins count-' . intval( $gmGallery->options['modules_new'] ) . '" style="background-color: #367236;"><span class="plugin-count gm-module-count gm-modules-new-count" title="' . esc_html__( 'New Modules', 'grand-media' ) . '">' . intval( $gmGallery->options['modules_new'] ) . '</span></span>';
209 }
210 }
211
212 $this->pages = [];
213 $this->pages[] = add_menu_page(
214 __( 'Gmedia Library', 'grand-media' ),
215 "Gmedia{$count}",
216 'gmedia_library',
217 'GrandMedia',
218 [
219 &$this,
220 'shell',
221 ],
222 plugins_url( 'assets/icons/icon_gmedia_rounded.png', dirname( __FILE__ ) ),
223 11
224 );
225 $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Gmedia Library', 'grand-media' ), __( 'Gmedia Library', 'grand-media' ), 'gmedia_library', 'GrandMedia', [ &$this, 'shell' ] );
226 if ( current_user_can( 'gmedia_library' ) ) {
227 $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Add Media Files', 'grand-media' ), __( 'Add/Import Files', 'grand-media' ), 'gmedia_upload', 'GrandMedia_AddMedia', [ &$this, 'shell' ] );
228 $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Tags', 'grand-media' ), __( 'Tags', 'grand-media' ), 'gmedia_tag_manage', 'GrandMedia_Tags', [ &$this, 'shell' ] );
229 $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Categories', 'grand-media' ), __( 'Categories', 'grand-media' ), 'gmedia_category_manage', 'GrandMedia_Categories', [ &$this, 'shell' ] );
230 $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Albums', 'grand-media' ), __( 'Albums', 'grand-media' ), 'gmedia_album_manage', 'GrandMedia_Albums', [ &$this, 'shell' ] );
231 $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Gmedia Galleries', 'grand-media' ), __( 'Galleries', 'grand-media' ), 'gmedia_gallery_manage', 'GrandMedia_Galleries', [ &$this, 'shell' ] );
232 $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Modules', 'grand-media' ), __( 'Modules', 'grand-media' ), 'gmedia_gallery_manage', 'GrandMedia_Modules', [ &$this, 'shell' ] );
233 $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Gmedia Settings', 'grand-media' ), __( 'Settings', 'grand-media' ), 'manage_options', 'GrandMedia_Settings', [ &$this, 'shell' ] );
234 //$this->pages[] = add_submenu_page( 'GrandMedia', __( 'iOS Application', 'grand-media' ), __( 'iOS Application', 'grand-media' ), 'gmedia_settings', 'GrandMedia_App', array( &$this, 'shell' ) );
235 $this->pages[] = add_submenu_page( 'GrandMedia', __( 'WordPress Media Library', 'grand-media' ), __( 'WP Media Library', 'grand-media' ), 'gmedia_import', 'GrandMedia_WordpressLibrary', [ &$this, 'shell' ] );
236 $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Gmedia Logs', 'grand-media' ), __( 'Gmedia Logs', 'grand-media' ), 'manage_options', 'GrandMedia_Logs', [ &$this, 'shell' ] );
237 //$this->pages[] = add_submenu_page( 'GrandMedia', __( 'Gmedia Support', 'grand-media' ), __( 'Support', 'grand-media' ), 'manage_options', 'GrandMedia_Support', array( &$this, 'shell' ) );
238 }
239
240 foreach ( $this->pages as $page ) {
241 add_action( "load-$page", [ &$this, 'screen_help' ] );
242 }
243 }
244
245 /**
246 * Load the script for the defined page and load only this code
247 * Display shell of plugin
248 */
249 public function shell() {
250 global $gmCore, $gmProcessor, $gmGallery, $gm_allowed_tags;
251
252 $sideLinks = $this->sideLinks();
253
254 // check for upgrade.
255 if ( get_option( 'gmediaDbVersion' ) !== GMEDIA_DBVERSION ) {
256 if ( current_user_can( 'manage_options' ) && ( get_transient( 'gmediaUpgrade' ) || ( 'gmedia' === $gmCore->_get( 'do_update' ) ) ) ) {
257 $sideLinks['grandTitle'] = __( 'Updating GmediaGallery Plugin', 'grand-media' );
258 $sideLinks['sideLinks'] = '';
259 $gmProcessor->page = 'GrandMedia_Update';
260 } else {
261 return;
262 }
263 }
264
265 // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion -- PayPal serves an unversioned SDK URL; preserve the provider URL without inventing a version.
266 wp_enqueue_script( 'gmedia-paypal-donate', 'https://www.paypalobjects.com/donate/sdk/donate-sdk.js', [], null, true );
267 wp_add_inline_script(
268 'gmedia-paypal-donate',
269 "PayPal.Donation.Button({
270 env: 'production',
271 hosted_button_id: 'QC8SXC3HSSJ36',
272 image: {
273 src: 'https://pics.paypal.com/00/s/NWYwYzFhMjktZjY2NS00MTE5LThkNmMtYjBjZjA3OTNlZDNk/file.PNG',
274 alt: 'Donate with PayPal button',
275 title: 'PayPal - The safer, easier way to pay online!',
276 },
277 }).render('#donate-button');",
278 'after'
279 );
280
281 //global $wpdb;
282 //$query = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}gmedia_term");
283 //foreach($query as $item){
284 // $name = $gmCore->mb_convert_encoding_utf8($item->name);
285 // $wpdb->update($wpdb->prefix . 'gmedia_term', array('name' => $name), array('term_id' => $item->term_id));
286 //}
287 //echo '<pre>' . print_r($query, true) . '</pre>';
288
289 ?>
290 <div id="gmedia-container" class="gmedia-admin">
291 <?php
292 if ( 'GrandMedia_App' !== $gmProcessor->page && ! isset( $gmGallery->options['gmedia_service'] ) && current_user_can( 'manage_options' ) ) {
293 $this->collect_data_permission();
294 }
295 ?>
296 <div id="gmedia-header" class="clearfix">
297 <div id="gmedia-logo">Gmedia
298 <small> by CodEasily.com</small>
299 </div>
300 <h2><?php echo esc_html( $sideLinks['grandTitle'] ); ?></h2>
301 <?php
302 if ( ! is_plugin_active( 'woowgallery/woowgallery.php' ) && empty( $gmGallery->options['disable_ads'] ) ) {
303 ?>
304 <div class="promote-woowbox"><a href="https://bit.ly/gm-woowgallery" target="_blank"><img src="<?php echo esc_url( plugins_url( 'assets/img/woowbox-promote.png', __FILE__ ) ); ?>" alt="Try WoowGallery plugin"/></a></div>
305 <?php
306 }
307 ?>
308 </div>
309 <div class="container-fluid">
310 <div class="row row-fx180-fl">
311 <div class="col-2 p-0 hidden-xs" id="sidebar" role="navigation">
312 <?php echo wp_kses( $sideLinks['sideLinks'], $gm_allowed_tags ); ?>
313
314 <div id="gm-donate" class='card p-0'>
315 <div class='card-header'>
316 <b><?php esc_html_e( 'SOS from Ukraine', 'grand-media' ); ?></b>
317 </div>
318 <div class="card-body">
319 <div id='donate-button-container'>
320 <div id='donate-button'></div>
321 </div>
322
323 <style>
324 #donate-button img {
325 max-width: 100%;
326 box-shadow: 2px 2px 2px;
327 border-radius: 12px;
328 overflow: hidden;
329 }
330 </style>
331 <br/>
332 <p><?php esc_html_e( 'If you are able to donate, no matter how much, and if you enjoy using the Gmedia Gallery plugin and would like to help me in my time of need, please consider making a donation.', 'grand-media' ); ?></p>
333 <p id="special_thanks">&#x2764;&#xfe0f; <a href="<?php echo esc_url( admin_url( 'admin.php?page=GrandMedia_Settings#gmedia_thanks_tab' ) ); ?>" style="font-weight: bold;"><?php esc_html_e( 'Special Thanks', 'grand-media' ); ?></a> &#x2764;&#xfe0f;</p>
334 </div>
335
336 <script>
337 (function() {
338 let timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
339 let donate_div = document.querySelector('#gm-donate');
340 if ('Europe/Kiev' === timezone) {
341 donate_div.style.display = 'none';
342 }
343 })();
344 </script>
345 </div>
346
347 <?php
348 if ( (int) $gmGallery->options['feedback'] ) {
349 $installDate = get_option( 'gmediaInstallDate' );
350 if ( $installDate && ( strtotime( $installDate ) < strtotime( '2 weeks ago' ) ) ) {
351 ?>
352 <div class="card p-0 d-none d-xl-block d-sm-none">
353 <div class="card-header" data-bs-toggle="collapse" data-bs-target="#support_div_collapse" aria-expanded="true" aria-controls="support_div_collapse" style="cursor:pointer;">
354 <b><?php esc_html_e( 'Any feedback?', 'grand-media' ); ?></b>
355 </div>
356 <div class="collapse<?php echo ! gmedia_has_premium_license() ? ' in' : ''; ?>" id="support_div_collapse">
357 <div class="card-body">
358 <p><?php esc_html_e( 'You can help me spread the word about GmediaGallery among the users striving to get awesome galleries on their WordPress sites.', 'grand-media' ); ?></p>
359
360 <p>
361 <a class="btn btn-primary" href="https://wordpress.org/support/view/plugin-reviews/grand-media?filter=5" target="_blank"><?php esc_html_e( 'Rate Gmedia Gallery', 'grand-media' ); ?></a>
362 </p>
363
364 <p><?php esc_html_e( 'Your reviews and ideas helps me to create new awesome modules and to improve plugin.', 'grand-media' ); ?></p>
365 </div>
366 </div>
367 </div>
368 <?php
369 }
370 }
371 ?>
372 </div>
373 <div class="col-10">
374 <div id="gm-message">
375 <?php
376 echo wp_kses( $gmCore->alert( 'success', $gmProcessor->msg ), $gm_allowed_tags );
377 echo wp_kses( $gmCore->alert( 'danger', $gmProcessor->error ), $gm_allowed_tags );
378 ?>
379 </div>
380
381 <?php $this->controller(); ?>
382
383 </div>
384 </div>
385 </div>
386 </div>
387 <?php
388 }
389
390 public function sideLinks() {
391 global $submenu, $gmProcessor, $gmGallery;
392 $content['sideLinks'] = '
393 <div id="gmedia-navbar">
394 <div class="row">
395 <ul>';
396 if ( ! gmedia_has_premium_license() ) {
397 $content['sideLinks'] .= "\n" . '<li class="list-group mb-3"><a class="list-group-item list-group-item-premium" href="' . esc_url( admin_url( 'admin.php?page=GrandMedia-pricing' ) ) . '">' . esc_html__( 'Get Gmedia Premium', 'grand-media' ) . '</a></li>';
398 }
399 $content['sideLinks'] .= "\n" . '<li class="list-group">';
400 foreach ( $submenu['GrandMedia'] as $menuItem ) {
401 if ( $menuItem[2] === $gmProcessor->page ) {
402 $iscur = ' active';
403 $content['grandTitle'] = $menuItem[3];
404 } else {
405 $iscur = '';
406 }
407 $menuData = '';
408 if ( 'GrandMedia_Modules' === $menuItem[2] && gm_user_can( 'module_manage' ) ) {
409 if ( ! empty( $gmGallery->options['notify_new_modules'] ) ) {
410 $menuData .= '<span class="badge badge-success float-end gm-module-count-' . intval( $gmGallery->options['modules_new'] ) . '" title="' . esc_attr__( 'New Modules', 'grand-media' ) . '">' . intval( $gmGallery->options['modules_new'] ) . '</span>';
411 }
412 $menuData .= '<span class="badge badge-error float-end gm-module-count-' . intval( $gmGallery->options['modules_update'] ) . '" title="' . esc_attr__( 'Modules Updates', 'grand-media' ) . '">' . intval( $gmGallery->options['modules_update'] ) . '</span>';
413 }
414
415 $content['sideLinks'] .= "\n" . '<a class="list-group-item list-group-item-action' . esc_attr( $iscur ) . '" href="' . esc_url( admin_url( 'admin.php?page=' . $menuItem[2] ) ) . '">' . wp_kses_post( $menuItem[0] . $menuData ) . '</a>';
416 }
417 $content['sideLinks'] .= "\n" . '<a class="list-group-item list-group-item-action" target="_blank" href="https://wordpress.org/support/plugin/grand-media/">' . esc_html__( 'Support', 'grand-media' ) . '</a>';
418 $content['sideLinks'] .= '
419 </li></ul>
420 </div>
421 </div>';
422
423 return $content;
424 }
425
426 public function collect_data_permission() {
427 $current_user = wp_get_current_user();
428 $nonce = wp_create_nonce( 'GmediaService' );
429 ?>
430 <div class="notice updated gm-message gmedia-service__message">
431 <div class="gm-message-content">
432 <div class="gm-plugin-icon">
433 <img src="<?php echo esc_url( plugins_url( 'assets/img/icon-128x128.png', __FILE__ ) ); ?>" width="90" height="90" alt="">
434 </div>
435 <?php
436 // translators: user name.
437 echo wp_kses_post( sprintf( __( '<p>Hey %s,<br>Please help us improve <b>Gmedia Gallery</b>! If you opt-in, some data about your usage of <b>Gmedia Gallery</b> will be sent to <a href="https://codeasily.com/" target="_blank" tabindex="1">codeasily.com</a>. If you skip this, that\'s okay! <b>Gmedia Gallery</b> will still work just fine.</p>', 'grand-media' ), esc_html( $current_user->display_name ) ) );
438 ?>
439 </div>
440 <div class="gm-message-actions">
441 <button class="button button-secondary gm_service_action" data-action="skip" data-nonce="<?php echo esc_attr( $nonce ); ?>"><?php esc_html_e( 'Skip', 'grand-media' ); ?></button>
442 <button class="button button-primary gm_service_action" data-action="allow" data-nonce="<?php echo esc_attr( $nonce ); ?>"><?php esc_html_e( 'Allow &amp; Continue', 'grand-media' ); ?></button>
443 </div>
444 <div class="gm-message-plus gm-closed">
445 <a class="gm-mp-trigger" href="#" onclick="jQuery('.gm-message-plus').toggleClass('gm-closed gm-opened'); return false;"><?php esc_html_e( 'What permissions are being granted?', 'grand-media' ); ?></a>
446 <ul>
447 <li>
448 <i class="dashicons dashicons-admin-users"></i>
449
450 <div>
451 <span><?php esc_html_e( 'Your Profile Overview', 'grand-media' ); ?></span>
452
453 <p><?php esc_html_e( 'Name and email address', 'grand-media' ); ?></p>
454 </div>
455 </li>
456 <li>
457 <i class="dashicons dashicons-admin-settings"></i>
458
459 <div>
460 <span><?php esc_html_e( 'Your Site Overview', 'grand-media' ); ?></span>
461
462 <p><?php esc_html_e( 'Site URL, WP version, PHP version, active theme &amp; plugins', 'grand-media' ); ?></p>
463 </div>
464 </li>
465 </ul>
466 </div>
467 </div>
468 <?php
469 }
470
471 public function controller() {
472
473 global $gmProcessor;
474 switch ( $gmProcessor->page ) {
475 case 'GrandMedia_AddMedia':
476 include_once dirname( __FILE__ ) . '/pages/addmedia/addmedia.php';
477 break;
478 case 'GrandMedia_Albums':
479 case 'GrandMedia_Categories':
480 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Select an existing view; term mutations are authorized by their processor.
481 if ( isset( $_GET['edit_term'] ) ) {
482 include_once dirname( __FILE__ ) . '/pages/terms/edit-term.php';
483 } else {
484 include_once dirname( __FILE__ ) . '/pages/terms/terms.php';
485 }
486 break;
487 case 'GrandMedia_Tags':
488 include_once dirname( __FILE__ ) . '/pages/terms/terms.php';
489 break;
490 case 'GrandMedia_Galleries':
491 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Select an existing view; gallery mutations are authorized by their processor.
492 if ( isset( $_GET['gallery_module'] ) || isset( $_GET['edit_term'] ) ) {
493 include_once dirname( __FILE__ ) . '/pages/galleries/edit-gallery.php';
494 } else {
495 include_once dirname( __FILE__ ) . '/pages/galleries/galleries.php';
496 }
497 break;
498 case 'GrandMedia_Modules':
499 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Select an existing view; preset mutations are authorized by their processor.
500 if ( isset( $_GET['preset_module'] ) || isset( $_GET['preset'] ) ) {
501 include_once dirname( __FILE__ ) . '/pages/modules/edit-preset.php';
502 } else {
503 include_once dirname( __FILE__ ) . '/pages/modules/modules.php';
504 }
505 break;
506 case 'GrandMedia_Settings':
507 include_once dirname( __FILE__ ) . '/pages/settings/settings.php';
508 break;
509 case 'GrandMedia_App':
510 include_once dirname( __FILE__ ) . '/app.php';
511 gmediaApp();
512 break;
513 case 'GrandMedia_WordpressLibrary':
514 include_once dirname( __FILE__ ) . '/wpmedia.php';
515 grandWPMedia();
516 break;
517 case 'GrandMedia_Logs':
518 include_once dirname( __FILE__ ) . '/logs.php';
519 break;
520 case 'GrandMedia_Support':
521 include_once dirname( __FILE__ ) . '/support.php';
522 gmediaSupport();
523 break;
524 case 'GrandMedia_Update':
525 include_once GMEDIA_ABSPATH . 'config/update.php';
526 gmedia_upgrade_progress_panel();
527 break;
528 case 'GrandMedia':
529 include_once dirname( __FILE__ ) . '/pages/library/library.php';
530 break;
531 default:
532 do_action( 'gmedia_admin_page__' . $gmProcessor->page );
533 break;
534 }
535 }
536
537 public function admin_footer() {
538 $ajax_operations = get_option( 'gmedia_ajax_long_operations' );
539 if ( empty( $ajax_operations ) || ! is_array( $ajax_operations ) ) {
540 return;
541 }
542 reset( $ajax_operations );
543 $ajax = key( $ajax_operations );
544 if ( empty( $ajax ) ) {
545 delete_option( 'gmedia_ajax_long_operations' );
546
547 return;
548 }
549 $nonce = wp_create_nonce( 'gmedia_ajax_long_operations' );
550 ?>
551 <script type="text/javascript">
552 jQuery(document).ready(function($) {
553 var header = $('#gmedia-header');
554 header.append('<div id="ajax-long-operation"><div class="progress"><div class="progress-bar progress-bar-info" style="width: 0%;"></div><div class="progress-bar-indicator">0%</div></div></div>');
555 var gmAjaxLongOperation = function() {
556 jQuery.post(ajaxurl, {action: '<?php echo esc_js( $ajax ); ?>', _wpnonce_ajax_long_operations: '<?php echo esc_attr( $nonce ); ?>'}, function(r) {
557 if (r.data) {
558 jQuery('.progress-bar-info', header).width(r.data.progress);
559 var indicator = r.data.info ? r.data.info + ' ' + r.data.progress : r.data.progress;
560 jQuery('.progress-bar-indicator', header).html(indicator);
561
562 if (r.data.done) {
563 return;
564 }
565 }
566 gmAjaxLongOperation();
567 });
568 };
569 gmAjaxLongOperation();
570 });
571 </script>
572 <?php
573 }
574
575 /**
576 * @param string $hook
577 */
578 public function load_scripts( $hook ) {
579 global $gmCore, $gmProcessor, $gmGallery;
580 // no need to go on if it's not a plugin page.
581 if ( 'admin.php' !== $hook && strpos( $gmCore->_get( 'page' ), 'GrandMedia' ) === false ) {
582 return;
583 }
584
585 if ( $gmGallery->options['isolation_mode'] ) {
586 global $wp_scripts, $wp_styles;
587 foreach ( $wp_scripts->registered as $handle => $wp_script ) {
588 if ( ( ( false !== strpos( $wp_script->src, '/plugins/' ) ) || ( false !== strpos( $wp_script->src, '/themes/' ) ) ) && ( false === strpos( $wp_script->src, GMEDIA_FOLDER ) ) ) {
589 if ( in_array( $handle, $wp_scripts->queue, true ) ) {
590 wp_dequeue_script( $handle );
591 }
592 wp_deregister_script( $handle );
593 }
594 }
595 foreach ( $wp_styles->registered as $handle => $wp_style ) {
596 if ( ( ( false !== strpos( $wp_style->src, '/plugins/' ) ) || ( false !== strpos( $wp_style->src, '/themes/' ) ) ) && ( false === strpos( $wp_style->src, GMEDIA_FOLDER ) ) ) {
597 if ( in_array( $handle, $wp_styles->queue, true ) ) {
598 wp_dequeue_style( $handle );
599 }
600 wp_deregister_style( $handle );
601 }
602 }
603 }
604
605 wp_enqueue_style( 'gmedia-bootstrap' );
606 wp_enqueue_script( 'gmedia-bootstrap' );
607
608 wp_register_style( 'selectize', $gmCore->gmedia_url . '/assets/selectize/selectize.bootstrap5.css', [ 'gmedia-bootstrap' ], '0.13.5', 'screen' );
609 wp_register_script( 'selectize', $gmCore->gmedia_url . '/assets/selectize/selectize.min.js', [ 'jquery' ], '0.13.5', true );
610
611 wp_register_style( 'spectrum', $gmCore->gmedia_url . '/assets/spectrum/spectrum.min.css', [], '1.8.0' );
612 wp_register_script( 'spectrum', $gmCore->gmedia_url . '/assets/spectrum/spectrum.min.js', [ 'jquery' ], '1.8.0', true );
613
614 $page = $gmCore->_get( 'page' );
615 if ( $page ) {
616 switch ( $page ) {
617 case 'GrandMedia':
618 if ( $gmCore->caps['gmedia_edit_media'] ) {
619 if ( $gmCore->_get( 'gmediablank' ) === 'image_editor' ) {
620 wp_enqueue_script( 'camanjs', $gmCore->gmedia_url . '/assets/image-editor/camanjs/caman.full.min.js', [], '4.1.2', true );
621
622 wp_enqueue_style( 'nouislider', $gmCore->gmedia_url . '/assets/image-editor/js/jquery.nouislider.css', [ 'gmedia-bootstrap' ], '6.1.0' );
623 wp_enqueue_script( 'nouislider', $gmCore->gmedia_url . '/assets/image-editor/js/jquery.nouislider.min.js', [ 'jquery' ], '6.1.0', true );
624
625 wp_enqueue_style( 'gmedia-image-editor', $gmCore->gmedia_url . '/assets/image-editor/style.css', [ 'gmedia-bootstrap' ], '0.9.16', 'screen' );
626 wp_enqueue_script( 'gmedia-image-editor', $gmCore->gmedia_url . '/assets/image-editor/image-editor.js', [ 'jquery', 'camanjs' ], '0.9.16', true );
627 break;
628 }
629 if ( 'edit' === $gmProcessor->mode ) {
630 wp_enqueue_script( 'alphanum', $gmCore->gmedia_url . '/assets/jq-plugins/jquery.alphanum.js', [ 'jquery' ], '1.0.16', true );
631
632 wp_enqueue_script( 'jquery-ui-sortable' );
633
634 wp_enqueue_script( 'popper', $gmCore->gmedia_url . '/assets/popper/popper.min.js', [], '2.11.2', true );
635 wp_enqueue_style( 'tempus-dominus', $gmCore->gmedia_url . '/assets/tempus-dominus/css/tempus-dominus.min.css', [ 'gmedia-bootstrap' ], '6.0.0' );
636 wp_enqueue_script( 'tempus-dominus', $gmCore->gmedia_url . '/assets/tempus-dominus/js/tempus-dominus.js', [ 'popper', 'gmedia-bootstrap' ], '6.0.0', true );
637 wp_enqueue_script( 'moment' );
638 }
639 }
640 wp_enqueue_script( 'wavesurfer', $gmCore->gmedia_url . '/assets/wavesurfer/wavesurfer.min.js', [ 'jquery' ], '1.1.5', true );
641 break;
642 case 'GrandMedia_WordpressLibrary':
643 break;
644 case 'GrandMedia_Albums':
645 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Editor navigation only selects assets to enqueue.
646 if ( isset( $_GET['edit_term'] ) ) {
647 if ( $gmCore->caps['gmedia_album_manage'] ) {
648 wp_enqueue_script( 'jquery-ui-sortable' );
649 }
650
651 wp_enqueue_script( 'popper', $gmCore->gmedia_url . '/assets/popper/popper.min.js', [], '2.11.2', true );
652 wp_enqueue_style( 'tempus-dominus', $gmCore->gmedia_url . '/assets/tempus-dominus/css/tempus-dominus.min.css', [ 'gmedia-bootstrap' ], '6.0.0' );
653 wp_enqueue_script( 'tempus-dominus', $gmCore->gmedia_url . '/assets/tempus-dominus/js/tempus-dominus.min.js', [ 'popper', 'gmedia-bootstrap' ], '6.0.0', true );
654 wp_enqueue_script( 'tempus-dominus-jq', $gmCore->gmedia_url . '/assets/tempus-dominus/js/jQuery-provider.min.js', [ 'tempus-dominus', 'jquery' ], '6.0.0', true );
655 wp_enqueue_script( 'moment' );
656 }
657 break;
658 case 'GrandMedia_Categories':
659 break;
660 case 'GrandMedia_AddMedia':
661 if ( $gmCore->caps['gmedia_upload'] ) {
662 $tab = $gmCore->_get( 'tab', 'upload' );
663 if ( 'upload' === $tab ) {
664 wp_enqueue_style( 'jquery.plupload.queue', $gmCore->gmedia_url . '/assets/jquery.plupload.queue/css/jquery.plupload.queue.css', [], '2.3.9', 'screen' );
665 wp_enqueue_script( 'jquery.plupload.queue', $gmCore->gmedia_url . '/assets/jquery.plupload.queue/jquery.plupload.queue.js', [ 'plupload' ], '2.3.9', true );
666 }
667 }
668 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Import navigation only enqueues the file-tree UI; it does not import files.
669 if ( ! empty( $_GET['import'] ) ) {
670 wp_enqueue_style( 'jqueryFileTree', $gmCore->gmedia_url . '/assets/jqueryFileTree/jqueryFileTree.css', [], '1.0.1', 'screen' );
671 wp_enqueue_script(
672 'jqueryFileTree',
673 $gmCore->gmedia_url . '/assets/jqueryFileTree/jqueryFileTree.js',
674 [
675 'jquery',
676 ],
677 '1.0.1',
678 true
679 );
680 }
681 break;
682 case 'GrandMedia_Settings':
683 case 'GrandMedia_App':
684 // under construction.
685 break;
686 case 'GrandMedia_Galleries':
687 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Gallery editor navigation only selects assets to enqueue.
688 if ( $gmCore->caps['gmedia_gallery_manage'] && ( isset( $_GET['gallery_module'] ) || isset( $_GET['edit_term'] ) ) ) {
689
690 wp_enqueue_script( 'jquery-ui-sortable' );
691
692 wp_enqueue_style( 'jquery.minicolors', $gmCore->gmedia_url . '/assets/minicolors/jquery.minicolors.css', [ 'gmedia-bootstrap' ], '0.9.13' );
693 wp_enqueue_script( 'jquery.minicolors', $gmCore->gmedia_url . '/assets/minicolors/jquery.minicolors.js', [ 'jquery' ], '0.9.13', true );
694
695 wp_enqueue_style( 'spectrum' );
696 wp_enqueue_script( 'spectrum' );
697 }
698 break;
699 case 'GrandMedia_Modules':
700 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Preset editor navigation only selects assets to enqueue.
701 if ( isset( $_GET['preset_module'] ) || isset( $_GET['preset'] ) ) {
702
703 wp_enqueue_script( 'jquery-ui-sortable' );
704
705 wp_enqueue_style( 'jquery.minicolors', $gmCore->gmedia_url . '/assets/minicolors/jquery.minicolors.css', [ 'gmedia-bootstrap' ], '0.9.13' );
706 wp_enqueue_script( 'jquery.minicolors', $gmCore->gmedia_url . '/assets/minicolors/jquery.minicolors.js', [ 'jquery' ], '0.9.13', true );
707
708 wp_enqueue_style( 'spectrum' );
709 wp_enqueue_script( 'spectrum' );
710 }
711 break;
712 }
713 }
714 wp_enqueue_style( 'selectize' );
715 wp_enqueue_script( 'selectize' );
716
717 wp_enqueue_style( 'grand-media' );
718 wp_enqueue_script( 'grand-media' );
719
720 }
721
722 public function gmedia_widget_scripts() {
723 }
724
725 /**
726 * Enqueue the block's assets for the gutenberg editor.
727 */
728 public function gutenberg_assets() {
729 global $gmGallery, $gmDB, $gmCore;
730
731 wp_enqueue_style( 'gmedia-block-editor', $gmCore->gmedia_url . '/admin/assets/css/gmedia-block.css', [], $gmGallery->version );
732 wp_register_script(
733 'gmedia-block-editor',
734 $gmCore->gmedia_url . '/admin/assets/js/gmedia-block.js',
735 [ 'wp-blocks', 'wp-element' ],
736 $gmGallery->version,
737 true
738 );
739
740 $default_module = $gmGallery->options['default_gmedia_module'];
741 $default_preset = $gmCore->getModulePreset( $default_module );
742 $default_module = $default_preset['module'];
743
744 $modules_data = get_gmedia_modules( false );
745 $modules = [];
746 $modules_options = [];
747 if ( ! empty( $modules_data['in'] ) ) {
748 foreach ( $modules_data['in'] as $module_name => $module_data ) {
749
750 $presets = $gmDB->get_terms( 'gmedia_module', [ 'status' => $module_name ] );
751 $option = [];
752 $option[ $module_name ] = esc_html( $module_data['title'] . ' - ' . __( 'Default Settings' , 'grand-media') );
753 foreach ( $presets as $preset ) {
754 if ( ! (int) $preset->global && '[' . $module_name . ']' === $preset->name ) {
755 continue;
756 }
757 $by_author = '';
758 if ( (int) $preset->global ) {
759 $display_name = get_the_author_meta( 'display_name', $preset->global );
760 $by_author = $display_name ? ' [' . $display_name . ']' : '';
761 }
762 if ( '[' . $module_name . ']' === $preset->name ) {
763 $option[ $preset->term_id ] = esc_html( $module_data['title'] . $by_author . ' - ' . __( 'Default Settings' , 'grand-media') );
764 } else {
765 $preset_name = str_replace( '[' . $module_name . '] ', '', $preset->name );
766 $option[ $preset->term_id ] = esc_html( $module_data['title'] . $by_author . ' - ' . $preset_name );
767 }
768 }
769 $modules_options[ $module_name ] = [ 'title' => esc_html( $module_data['title'] ), 'options' => $option ];
770
771 $modules[ $module_name ] = [
772 'name' => esc_html( $module_data['title'] ),
773 'screenshot' => esc_url( $module_data['module_url'] . '/screenshot.png' ),
774 ];
775 }
776 }
777
778 $gm_galleries = [];
779 $gm_albums = [];
780 $gm_categories = [];
781 $gm_tags = [];
782
783 $gm_terms = $gmDB->get_terms( 'gmedia_gallery' );
784 if ( count( $gm_terms ) ) {
785 foreach ( $gm_terms as $_term ) {
786 unset( $_term->description );
787 unset( $_term->taxonomy );
788 $_term->module_name = esc_html( $gmDB->get_metadata( 'gmedia_term', $_term->term_id, '_module', true ) );
789 if ( $_term->global ) {
790 $display_name = get_the_author_meta( 'display_name', $_term->global );
791 // translators: author name.
792 $_term->name .= empty( $display_name ) ? '' : ' ' . sprintf( esc_html__( 'by %s', 'grand-media' ), esc_html( $display_name ) );
793 }
794 if ( $_term->status && 'publish' !== $_term->status ) {
795 $_term->name .= esc_html( " [{$_term->status}]" );
796 }
797 $gm_galleries[ $_term->term_id ] = $_term;
798 }
799 }
800 $gm_galleries = [ 0 => [ 'term_id' => 0, 'name' => esc_html__( ' - select gallery - ', 'grand-media' ) ] ] + $gm_galleries;
801
802 $gm_terms = $gmDB->get_terms( 'gmedia_album' );
803 if ( count( $gm_terms ) ) {
804 foreach ( $gm_terms as $_term ) {
805 unset( $_term->description );
806 unset( $_term->taxonomy );
807 $module_preset = esc_html( $gmDB->get_metadata( 'gmedia_term', $_term->term_id, '_module_preset', true ) );
808 if ( $module_preset ) {
809 $preset = $gmCore->getModulePreset( $module_preset );
810 $_term->module_name = esc_html( $preset['module'] );
811 } else {
812 $_term->module_name = '';
813 }
814 if ( $_term->global ) {
815 $display_name = get_the_author_meta( 'display_name', $_term->global );
816 // translators: author name.
817 $_term->name .= empty( $display_name ) ? '' : ' ' . sprintf( esc_html__( 'by %s', 'grand-media' ), esc_html( $display_name ) );
818 }
819 if ( $_term->status && 'publish' !== $_term->status ) {
820 $_term->name .= esc_html( " [{$_term->status}]" );
821 }
822 $_term->name .= esc_html( " ({$_term->count})" );
823
824 $gm_albums[ $_term->term_id ] = $_term;
825 }
826 }
827 $gm_albums = [ 0 => [ 'term_id' => 0, 'name' => esc_html__( ' - select album - ', 'grand-media' ) ] ] + $gm_albums;
828
829 $gm_terms = $gmDB->get_terms( 'gmedia_category' );
830 if ( count( $gm_terms ) ) {
831 foreach ( $gm_terms as $_term ) {
832 unset( $_term->description );
833 unset( $_term->taxonomy );
834 unset( $_term->global );
835 unset( $_term->status );
836 $_term->name .= esc_html( " ({$_term->count})" );
837
838 $gm_categories[ $_term->term_id ] = $_term;
839 }
840 }
841 $gm_categories = [ 0 => [ 'term_id' => 0, 'name' => esc_html__( ' - select category - ', 'grand-media' ) ] ] + $gm_categories;
842
843 $gm_terms = $gmDB->get_terms( 'gmedia_tag' );
844 if ( count( $gm_terms ) ) {
845 foreach ( $gm_terms as $_term ) {
846 unset( $_term->description );
847 unset( $_term->taxonomy );
848 unset( $_term->global );
849 unset( $_term->status );
850 $_term->name .= esc_html( " ({$_term->count})" );
851
852 $gm_tags[ $_term->term_id ] = $_term;
853 }
854 }
855 $gm_tags = [ 0 => [ 'term_id' => 0, 'name' => esc_html__( ' - select tag - ', 'grand-media' ) ] ] + $gm_tags;
856
857 $data = [
858 'modules' => $modules,
859 'default_module' => $default_module,
860 'modules_options' => $modules_options,
861 'gmedia_image' => $gmCore->gmedia_url . '/admin/assets/img/gmedia-icon-320x240.png',
862 'galleries' => $gm_galleries,
863 'albums' => $gm_albums,
864 'categories' => $gm_categories,
865 'tags' => $gm_tags,
866 ];
867
868 wp_localize_script( 'gmedia-block-editor', 'gmedia_data', $data );
869 wp_enqueue_script( 'gmedia-block-editor' );
870 }
871
872 public function screen_help() {
873 $screen = get_current_screen();
874 $screen_id = explode( 'page_', $screen->id, 2 );
875 $screen_id = $screen_id[1];
876
877 $screen->add_help_tab(
878 [
879 'id' => 'help_' . $screen_id . '_support',
880 'title' => __( 'Support' , 'grand-media'),
881 'content' =>
882 __(
883 '<h4>First steps</h4>
884 <p>If you have any problems with displaying Gmedia Gallery in admin or on website. Before posting to the Forum try next:</p>
885 <ul>
886 <li>Exclude plugin conflicts: Disable other plugins one by one and check if it resolves problem</li>
887 <li>Exclude theme conflict: Temporary switch to one of default themes and check if gallery works</li>
888 </ul>
889 <h4>Links</h4>',
890 'grand-media'
891 )
892 . '<p><a href="https://wordpress.org/support/plugin/grand-media" target="_blank">' . esc_html__( 'Support Forum', 'grand-media' ) . '</a>
893 | <a href="https://codeasily.com/contact/" target="_blank">' . esc_html__( 'Contact', 'grand-media' ) . '</a>
894 | <a href="https://codeasily.com/portfolio/gmedia-gallery-modules/" target="_blank">' . esc_html__( 'Demo', 'grand-media' ) . '</a>
895 | <a href="' . esc_url( admin_url( 'admin.php?page=GrandMedia-pricing' ) ) . '" target="_blank">' . esc_html__( 'Premium', 'grand-media' ) . '</a>
896 </p>',
897 ]
898 );
899
900 switch ( $screen_id ) {
901 case 'GrandMedia':
902 break;
903 case 'GrandMedia_Settings':
904 if ( current_user_can( 'manage_options' ) ) {
905 $license_type = gmedia_get_license_type();
906 $screen->add_help_tab(
907 [
908 'id' => 'help_' . $screen_id . '_license',
909 'title' => __( 'License Key' , 'grand-media'),
910 'content' =>
911 sprintf(
912 /* translators: 1: Gmedia support forum URL, 2: Developer contact email address. */
913 __(
914 '<h4>Should I buy it, to use plugin?</h4>
915 <p>No, plugin is absolutely free and all modules for it are free to install.</p>
916 <p>Even premium modules are fully functional and free to test, but have backlink labels. To remove baclink labels from premium modules you need license key.</p>
917 <p>Note: License Key will remove backlinks from all current and future premium modules, so you can use all available modules on one website.</p>
918 <p>Do not purchase license key before testing module you like. Only if everything works fine, and you satisfied with functionality you are good to purchase license. Otherwise use <a href="%1$s" target="_blank">Gmedia Support Forum</a>.</p>
919 <h4>I have license key, but I can\'t activate it</h4>
920 <p>Contact developer <a href="mailto:%2$s">%2$s</a> with your problem and wait for additional instructions and code for manual activation</p>',
921 'grand-media'
922 ),
923 'https://wordpress.org/support/plugin/grand-media/',
924 'gmediafolder@gmail.com'
925 )
926 . ('freemius' !== $license_type ? '<div><a class="btn btn-secondary" href="' . admin_url( 'admin.php?page=' . $screen_id . '&license_activate=manual' ) . '">' . __( 'Manual Activation', 'grand-media' ) . '</a></div>' : ''),
927 ]
928 );
929 }
930 break;
931 case 'GrandMedia_App':
932 $gm_options = get_option( 'gmediaOptions' );
933 $nonce = wp_create_nonce( 'GmediaService' );
934 if ( current_user_can( 'manage_options' ) && (int) $gm_options['mobile_app'] ) {
935 $screen->add_help_tab(
936 [
937 'id' => 'help_' . $screen_id . '_optout',
938 'title' => __( 'Opt Out', 'grand-media' ),
939 'content' =>
940 __(
941 '<h4>We appreciate your help in making the plugin better by letting us track some usage data.</h4>
942 <p>Usage tracking is done in the name of making <strong>Gmedia Gallery</strong> better. Making a better user experience, prioritizing new features, and more good things.</p>
943 <p>By clicking "Opt Out", we will no longer be sending any data from <strong>Gmedia Gallery</strong> to <a href="https://codeasily.com" target="_blank">codeasily.com</a>.</p>',
944 'grand-media'
945 )
946 . '<p><button class="button button-default gm_service_action" data-action="app_deactivate" data-nonce="' . esc_attr( $nonce ) . '">' . esc_html__( 'Opt Out', 'grand-media' ) . '</button><span class="spinner" style="float: none;"></span></p>'
947 . '<div style="display:none;">Test:
948 <button type="button" data-action="app_updateinfo" data-nonce="' . esc_attr( $nonce ) . '" class="btn btn-sm btn-primary gm_service_action">Update</button>
949 <button type="button" data-action="app_updatecron" data-nonce="' . esc_attr( $nonce ) . '" class="btn btn-sm btn-primary gm_service_action">CronJob</button> &nbsp;&nbsp;
950 <button type="button" data-action="app_deactivateplugin" data-nonce="' . esc_attr( $nonce ) . '" class="btn btn-sm btn-primary gm_service_action">Deactivate Plugin</button>
951 <button type="button" data-action="app_uninstallplugin" data-nonce="' . esc_attr( $nonce ) . '" class="btn btn-sm btn-primary gm_service_action">Uninstall Plugin</button>
952 </div>
953 ',
954 ]
955 );
956 }
957 break;
958 }
959 }
960
961 /**
962 * @param string $current
963 * @param object $screen
964 *
965 * @return string
966 */
967 public function screen_settings( $current, $screen ) {
968 global $gmProcessor, $gmCore;
969 if ( in_array( $screen->id, $this->pages, true ) ) {
970
971 $gm_screen_options = $gmProcessor->user_options;
972
973 $title = '<h5><strong>' . esc_html__( 'Settings', 'grand-media' ) . '</strong></h5>';
974 $wp_screen_options = '<input type="hidden" name="wp_screen_options[option]" value="gm_screen_options" /><input type="hidden" name="wp_screen_options[value]" value="' . esc_attr( $screen->id ) . '" />';
975 $button = get_submit_button( esc_html__( 'Apply', 'grand-media' ), 'button', 'screen-options-apply', false );
976
977 $settings = false;
978
979 $screen_id = explode( 'page_', $screen->id, 2 );
980
981 switch ( $screen_id[1] ) {
982 case 'GrandMedia':
983 $settings = '
984 <div class="form-inline float-start row row-cols-auto">
985 <div class="form-group">
986 <input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_gmedia]" class="form-control input-xs d-inline" style="width: 5em;" value="' . esc_attr( $gm_screen_options['per_page_gmedia'] ) . '" /> <span>' . esc_html__( 'items per page', 'grand-media' ) . '</span>
987 </div>
988 <div class="form-group">
989 <select name="gm_screen_options[orderby_gmedia]" class="form-control input-xs d-inline w-auto pe-4">
990 <option' . selected( $gm_screen_options['orderby_gmedia'], 'ID', false ) . ' value="ID">' . esc_html__( 'ID', 'grand-media' ) . '</option>
991 <option' . selected( $gm_screen_options['orderby_gmedia'], 'title', false ) . ' value="title">' . esc_html__( 'Title', 'grand-media' ) . '</option>
992 <option' . selected( $gm_screen_options['orderby_gmedia'], 'gmuid', false ) . ' value="gmuid">' . esc_html__( 'Filename', 'grand-media' ) . '</option>
993 <option' . selected( $gm_screen_options['orderby_gmedia'], 'mime_type', false ) . ' value="mime_type">' . esc_html__( 'MIME Type', 'grand-media' ) . '</option>
994 <option' . selected( $gm_screen_options['orderby_gmedia'], 'author', false ) . ' value="author">' . esc_html__( 'Author', 'grand-media' ) . '</option>
995 <option' . selected( $gm_screen_options['orderby_gmedia'], 'date', false ) . ' value="date">' . esc_html__( 'Date', 'grand-media' ) . '</option>
996 <option' . selected( $gm_screen_options['orderby_gmedia'], 'modified', false ) . ' value="modified">' . esc_html__( 'Last Modified', 'grand-media' ) . '</option>
997 <option' . selected( $gm_screen_options['orderby_gmedia'], '_created_timestamp', false ) . ' value="_created_timestamp">' . esc_html__( 'Created Timestamp', 'grand-media' ) . '</option>
998 <option' . selected( $gm_screen_options['orderby_gmedia'], 'comment_count', false ) . ' value="comment_count">' . esc_html__( 'Comment Count', 'grand-media' ) . '</option>
999 <option' . selected( $gm_screen_options['orderby_gmedia'], 'views', false ) . ' value="views">' . esc_html__( 'Views Count', 'grand-media' ) . '</option>
1000 <option' . selected( $gm_screen_options['orderby_gmedia'], 'likes', false ) . ' value="likes">' . esc_html__( 'Likes Count', 'grand-media' ) . '</option>
1001 <option' . selected( $gm_screen_options['orderby_gmedia'], '_size', false ) . ' value="_size">' . esc_html__( 'File Size', 'grand-media' ) . '</option>
1002 </select> <span>' . esc_html__( 'order items', 'grand-media' ) . '</span>
1003 </div>
1004 <div class="form-group">
1005 <select name="gm_screen_options[sortorder_gmedia]" class="form-control input-xs d-inline w-auto pe-4">
1006 <option' . selected( $gm_screen_options['sortorder_gmedia'], 'DESC', false ) . ' value="DESC">' . esc_html__( 'DESC', 'grand-media' ) . '</option>
1007 <option' . selected( $gm_screen_options['sortorder_gmedia'], 'ASC', false ) . ' value="ASC">' . esc_html__( 'ASC', 'grand-media' ) . '</option>
1008 </select> <span>' . esc_html__( 'sort order', 'grand-media' ) . '</span>
1009 </div>
1010 ';
1011 if ( 'edit' === $gmCore->_get( 'mode' ) ) {
1012 $settings .= '
1013 <div class="form-group">
1014 <select name="gm_screen_options[library_edit_quicktags]" class="form-control input-xs d-inline w-auto pe-4">
1015 <option' . selected( $gm_screen_options['library_edit_quicktags'], 'false', false ) . ' value="false">' . esc_html__( 'FALSE', 'grand-media' ) . '</option>
1016 <option' . selected( $gm_screen_options['library_edit_quicktags'], 'true', false ) . ' value="true">' . esc_html__( 'TRUE', 'grand-media' ) . '</option>
1017 </select> <span>' . esc_html__( 'Quick Tags panel for Description field', 'grand-media' ) . '</span>
1018 </div>
1019 ';
1020 }
1021 $settings .= '
1022 </div>
1023 ';
1024 break;
1025 case 'GrandMedia_AddMedia':
1026 $tab = $gmCore->_get( 'tab', 'upload' );
1027 if ( 'upload' === $tab ) {
1028 $html4_hide = ( 'html4' === $gm_screen_options['uploader_runtime'] ) ? ' hide' : '';
1029 $settings = '
1030 <div class="form-inline float-start row row-cols-auto">
1031 <div id="uploader_runtime" class="form-group"><span>' . esc_html__( 'Uploader runtime:', 'grand-media' ) . ' </span>
1032 <select name="gm_screen_options[uploader_runtime]" class="form-control input-xs d-inline w-auto pe-4">
1033 <option' . selected( $gm_screen_options['uploader_runtime'], 'auto', false ) . ' value="auto">' . esc_html__( 'Auto', 'grand-media' ) . '</option>
1034 <option' . selected( $gm_screen_options['uploader_runtime'], 'html5', false ) . ' value="html5">' . esc_html__( 'HTML5 Uploader', 'grand-media' ) . '</option>
1035 <option' . selected( $gm_screen_options['uploader_runtime'], 'html4', false ) . ' value="html4">' . esc_html__( 'HTML4 Uploader', 'grand-media' ) . '</option>
1036 </select>
1037 </div>
1038 <div id="uploader_chunking" class="form-group' . esc_attr( $html4_hide ) . '"><span>' . esc_html__( 'Chunking:', 'grand-media' ) . ' </span>
1039 <select name="gm_screen_options[uploader_chunking]" class="form-control input-xs d-inline w-auto pe-4">
1040 <option' . selected( $gm_screen_options['uploader_chunking'], 'true', false ) . ' value="true">' . esc_html__( 'TRUE', 'grand-media' ) . '</option>
1041 <option' . selected( $gm_screen_options['uploader_chunking'], 'false', false ) . ' value="false">' . esc_html__( 'FALSE', 'grand-media' ) . '</option>
1042 </select>
1043 </div>
1044 <div id="uploader_urlstream_upload" class="form-group' . esc_attr( $html4_hide ) . '"><span>' . esc_html__( 'URL streem upload:', 'grand-media' ) . ' </span>
1045 <select name="gm_screen_options[uploader_urlstream_upload]" class="form-control input-xs d-inline w-auto pe-4">
1046 <option' . selected( $gm_screen_options['uploader_urlstream_upload'], 'true', false ) . ' value="true">' . esc_html__( 'TRUE', 'grand-media' ) . '</option>
1047 <option' . selected( $gm_screen_options['uploader_urlstream_upload'], 'false', false ) . ' value="false">' . esc_html__( 'FALSE', 'grand-media' ) . '</option>
1048 </select>
1049 </div>
1050 </div>
1051 ';
1052 }
1053 break;
1054 case 'GrandMedia_Albums':
1055 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Choose screen-option fields to display; WordPress separately verifies option submissions.
1056 if ( isset( $_GET['edit_term'] ) ) {
1057 $settings = '
1058 <div class="form-inline float-start row row-cols-auto">
1059 <div class="form-group">
1060 <input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_gmedia_album_edit]" class="form-control input-xs d-inline" style="width: 5em;" value="' . esc_attr( $gm_screen_options['per_page_gmedia_album_edit'] ) . '" /> <span>' . esc_html__( 'items per page', 'grand-media' ) . '</span>
1061 </div>
1062 </div>
1063 ';
1064 } else {
1065 $settings = '
1066 <div class="form-inline float-start row row-cols-auto">
1067 <div class="form-group">
1068 <input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_gmedia_album]" class="form-control input-xs d-inline" style="width: 5em;" value="' . esc_attr( $gm_screen_options['per_page_gmedia_album'] ) . '" /> <span>' . esc_html__( 'items per page', 'grand-media' ) . '</span>
1069 </div>
1070 <div class="form-group">
1071 <select name="gm_screen_options[orderby_gmedia_album]" class="form-control input-xs d-inline w-auto pe-4">
1072 <option' . selected( $gm_screen_options['orderby_gmedia_album'], 'id', false ) . ' value="id">' . esc_html__( 'ID', 'grand-media' ) . '</option>
1073 <option' . selected( $gm_screen_options['orderby_gmedia_album'], 'name', false ) . ' value="name">' . esc_html__( 'Name', 'grand-media' ) . '</option>
1074 <option' . selected( $gm_screen_options['orderby_gmedia_album'], 'count', false ) . ' value="count">' . esc_html__( 'Gmedia Count', 'grand-media' ) . '</option>
1075 <option' . selected( $gm_screen_options['orderby_gmedia_album'], 'global', false ) . ' value="global">' . esc_html__( 'Author ID', 'grand-media' ) . '</option>
1076 </select> <span>' . esc_html__( 'order items', 'grand-media' ) . '</span>
1077 </div>
1078 <div class="form-group">
1079 <select name="gm_screen_options[sortorder_gmedia_album]" class="form-control input-xs d-inline w-auto pe-4">
1080 <option' . selected( $gm_screen_options['sortorder_gmedia_album'], 'DESC', false ) . ' value="DESC">' . esc_html__( 'DESC', 'grand-media' ) . '</option>
1081 <option' . selected( $gm_screen_options['sortorder_gmedia_album'], 'ASC', false ) . ' value="ASC">' . esc_html__( 'ASC', 'grand-media' ) . '</option>
1082 </select> <span>' . esc_html__( 'sort order', 'grand-media' ) . '</span>
1083 </div>
1084 </div>
1085 ';
1086 }
1087 break;
1088 case 'GrandMedia_Categories':
1089 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Choose screen-option fields to display; WordPress separately verifies option submissions.
1090 if ( isset( $_GET['edit_term'] ) ) {
1091 $settings = '
1092 <div class="form-inline float-start row row-cols-auto">
1093 <div class="form-group">
1094 <input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_gmedia_category_edit]" class="form-control input-xs d-inline" style="width: 5em;" value="' . esc_attr( $gm_screen_options['per_page_gmedia_category_edit'] ) . '" /> <span>' . esc_html__( 'items per page', 'grand-media' ) . '</span>
1095 </div>
1096 </div>
1097 ';
1098 } else {
1099 $settings = '
1100 <div class="form-inline float-start row row-cols-auto">
1101 <div class="form-group">
1102 <input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_gmedia_category]" class="form-control input-xs d-inline" style="width: 5em;" value="' . esc_attr( $gm_screen_options['per_page_gmedia_category'] ) . '" /> <span>' . esc_html__( 'items per page', 'grand-media' ) . '</span>
1103 </div>
1104 <div class="form-group">
1105 <select name="gm_screen_options[orderby_gmedia_category]" class="form-control input-xs d-inline w-auto pe-4">
1106 <option' . selected( $gm_screen_options['orderby_gmedia_category'], 'id', false ) . ' value="id">' . esc_html__( 'ID', 'grand-media' ) . '</option>
1107 <option' . selected( $gm_screen_options['orderby_gmedia_category'], 'name', false ) . ' value="name">' . esc_html__( 'Name', 'grand-media' ) . '</option>
1108 <option' . selected( $gm_screen_options['orderby_gmedia_category'], 'count', false ) . ' value="count">' . esc_html__( 'Gmedia Count', 'grand-media' ) . '</option>
1109 </select> <span>' . esc_html__( 'order items', 'grand-media' ) . '</span>
1110 </div>
1111 <div class="form-group">
1112 <select name="gm_screen_options[sortorder_gmedia_category]" class="form-control input-xs d-inline w-auto pe-4">
1113 <option' . selected( $gm_screen_options['sortorder_gmedia_category'], 'DESC', false ) . ' value="DESC">' . esc_html__( 'DESC', 'grand-media' ) . '</option>
1114 <option' . selected( $gm_screen_options['sortorder_gmedia_category'], 'ASC', false ) . ' value="ASC">' . esc_html__( 'ASC', 'grand-media' ) . '</option>
1115 </select> <span>' . esc_html__( 'sort order', 'grand-media' ) . '</span>
1116 </div>
1117 </div>
1118 ';
1119 }
1120 break;
1121 case 'GrandMedia_Tags':
1122 $settings = '
1123 <div class="form-inline float-start row row-cols-auto">
1124 <div class="form-group">
1125 <input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_gmedia_tag]" class="form-control input-xs d-inline" style="width: 5em;" value="' . esc_attr( $gm_screen_options['per_page_gmedia_tag'] ) . '" /> <span>' . esc_html__( 'items per page', 'grand-media' ) . '</span>
1126 </div>
1127 <div class="form-group">
1128 <select name="gm_screen_options[orderby_gmedia_tag]" class="form-control input-xs d-inline w-auto pe-4">
1129 <option' . selected( $gm_screen_options['orderby_gmedia_tag'], 'id', false ) . ' value="id">' . esc_html__( 'ID', 'grand-media' ) . '</option>
1130 <option' . selected( $gm_screen_options['orderby_gmedia_tag'], 'name', false ) . ' value="name">' . esc_html__( 'Name', 'grand-media' ) . '</option>
1131 <option' . selected( $gm_screen_options['orderby_gmedia_tag'], 'count', false ) . ' value="count">' . esc_html__( 'Gmedia Count', 'grand-media' ) . '</option>
1132 </select> <span>' . esc_html__( 'order items', 'grand-media' ) . '</span>
1133 </div>
1134 <div class="form-group">
1135 <select name="gm_screen_options[sortorder_gmedia_tag]" class="form-control input-xs d-inline w-auto pe-4">
1136 <option' . selected( $gm_screen_options['sortorder_gmedia_tag'], 'DESC', false ) . ' value="DESC">' . esc_html__( 'DESC', 'grand-media' ) . '</option>
1137 <option' . selected( $gm_screen_options['sortorder_gmedia_tag'], 'ASC', false ) . ' value="ASC">' . esc_html__( 'ASC', 'grand-media' ) . '</option>
1138 </select> <span>' . esc_html__( 'sort order', 'grand-media' ) . '</span>
1139 </div>
1140 </div>
1141 ';
1142 break;
1143 case 'GrandMedia_Galleries':
1144 if ( ! $gmCore->_get( 'edit_term' ) && ! $gmCore->_get( 'gallery_module' ) ) {
1145 $settings = '
1146 <div class="form-inline float-start row row-cols-auto">
1147 <div class="form-group">
1148 <input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_gmedia_gallery]" class="form-control input-xs d-inline" style="width: 5em;" value="' . esc_attr( $gm_screen_options['per_page_gmedia_gallery'] ) . '" /> <span>' . esc_html__( 'items per page', 'grand-media' ) . '</span>
1149 </div>
1150 <div class="form-group">
1151 <select name="gm_screen_options[orderby_gmedia_gallery]" class="form-control input-xs d-inline w-auto pe-4">
1152 <option' . selected( $gm_screen_options['orderby_gmedia_gallery'], 'id', false ) . ' value="id">' . esc_html__( 'ID', 'grand-media' ) . '</option>
1153 <option' . selected( $gm_screen_options['orderby_gmedia_gallery'], 'name', false ) . ' value="name">' . esc_html__( 'Name', 'grand-media' ) . '</option>
1154 <option' . selected( $gm_screen_options['orderby_gmedia_gallery'], 'global', false ) . ' value="global">' . esc_html__( 'Author ID', 'grand-media' ) . '</option>
1155 </select> <span>' . esc_html__( 'order items', 'grand-media' ) . '</span>
1156 </div>
1157 <div class="form-group">
1158 <select name="gm_screen_options[sortorder_gmedia_gallery]" class="form-control input-xs d-inline w-auto pe-4">
1159 <option' . selected( $gm_screen_options['sortorder_gmedia_gallery'], 'DESC', false ) . ' value="DESC">' . esc_html__( 'DESC', 'grand-media' ) . '</option>
1160 <option' . selected( $gm_screen_options['sortorder_gmedia_gallery'], 'ASC', false ) . ' value="ASC">' . esc_html__( 'ASC', 'grand-media' ) . '</option>
1161 </select> <span>' . esc_html__( 'sort order', 'grand-media' ) . '</span>
1162 </div>
1163 </div>
1164 ';
1165 }
1166 break;
1167 case 'GrandMedia_WordpressLibrary':
1168 $settings = '<p>' . esc_html__( 'Set query options for this page to be loaded by default.', 'grand-media' ) . '</p>
1169 <div class="form-inline float-start row row-cols-auto">
1170 <div class="form-group">
1171 <input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_wpmedia]" class="form-control input-xs d-inline" style="width: 5em;" value="' . esc_attr( $gm_screen_options['per_page_wpmedia'] ) . '" /> <span>' . esc_html__( 'items per page', 'grand-media' ) . '</span>
1172 </div>
1173 <div class="form-group">
1174 <select name="gm_screen_options[orderby_wpmedia]" class="form-control input-xs d-inline w-auto pe-4">
1175 <option' . selected( $gm_screen_options['orderby_wpmedia'], 'ID', false ) . ' value="ID">' . esc_html__( 'ID', 'grand-media' ) . '</option>
1176 <option' . selected( $gm_screen_options['orderby_wpmedia'], 'title', false ) . ' value="title">' . esc_html__( 'Title', 'grand-media' ) . '</option>
1177 <option' . selected( $gm_screen_options['orderby_wpmedia'], 'filename', false ) . ' value="filename">' . esc_html__( 'Filename', 'grand-media' ) . '</option>
1178 <option' . selected( $gm_screen_options['orderby_wpmedia'], 'date', false ) . ' value="date">' . esc_html__( 'Date', 'grand-media' ) . '</option>
1179 <option' . selected( $gm_screen_options['orderby_wpmedia'], 'modified', false ) . ' value="modified">' . esc_html__( 'Last Modified', 'grand-media' ) . '</option>
1180 <option' . selected( $gm_screen_options['orderby_wpmedia'], 'mime_type', false ) . ' value="mime_type">' . esc_html__( 'MIME Type', 'grand-media' ) . '</option>
1181 <option' . selected( $gm_screen_options['orderby_wpmedia'], 'author', false ) . ' value="author">' . esc_html__( 'Author', 'grand-media' ) . '</option>
1182 </select> <span>' . esc_html__( 'order items', 'grand-media' ) . '</span>
1183 </div>
1184 <div class="form-group">
1185 <select name="gm_screen_options[sortorder_wpmedia]" class="form-control input-xs d-inline w-auto pe-4">
1186 <option' . selected( $gm_screen_options['sortorder_wpmedia'], 'DESC', false ) . ' value="DESC">' . esc_html__( 'DESC', 'grand-media' ) . '</option>
1187 <option' . selected( $gm_screen_options['sortorder_wpmedia'], 'ASC', false ) . ' value="ASC">' . esc_html__( 'ASC', 'grand-media' ) . '</option>
1188 </select> <span>' . esc_html__( 'sort order', 'grand-media' ) . '</span>
1189 </div>
1190 </div>
1191 ';
1192 break;
1193 case 'GrandMedia_Logs':
1194 $settings = '
1195 <div class="form-inline float-start row row-cols-auto">
1196 <div class="form-group">
1197 <input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_gmedia_log]" class="form-control input-xs d-inline" style="width: 5em;" value="' . esc_attr( $gm_screen_options['per_page_gmedia_log'] ) . '" /> <span>' . esc_html__( 'items per page', 'grand-media' ) . '</span>
1198 </div>
1199 <div class="form-group">
1200 <select name="gm_screen_options[orderby_gmedia_log]" class="form-control input-xs d-inline w-auto pe-4">
1201 <option' . selected( $gm_screen_options['orderby_gmedia_log'], 'log_date', false ) . ' value="log_date">' . esc_html__( 'Date', 'grand-media' ) . '</option>
1202 <option' . selected( $gm_screen_options['orderby_gmedia_log'], 'ID', false ) . ' value="ID">' . esc_html__( 'Gmedia ID', 'grand-media' ) . '</option>
1203 <option' . selected( $gm_screen_options['orderby_gmedia_log'], 'author', false ) . ' value="author">' . esc_html__( 'Author ID', 'grand-media' ) . '</option>
1204 </select> <span>' . esc_html__( 'order items', 'grand-media' ) . '</span>
1205 </div>
1206 <div class="form-group">
1207 <select name="gm_screen_options[sortorder_gmedia_log]" class="form-control input-xs d-inline w-auto pe-4">
1208 <option' . selected( $gm_screen_options['sortorder_gmedia_log'], 'DESC', false ) . ' value="DESC">' . esc_html__( 'DESC', 'grand-media' ) . '</option>
1209 <option' . selected( $gm_screen_options['sortorder_gmedia_log'], 'ASC', false ) . ' value="ASC">' . esc_html__( 'ASC', 'grand-media' ) . '</option>
1210 </select> <span>' . esc_html__( 'sort order', 'grand-media' ) . '</span>
1211 </div>
1212 </div>
1213 ';
1214 break;
1215 }
1216
1217 if ( $settings ) {
1218 $current = $title . $settings . $wp_screen_options . $button;
1219 }
1220 }
1221
1222 return $current;
1223 }
1224
1225 /**
1226 * @param string|array $status
1227 * @param string $option
1228 * @param array $value
1229 *
1230 * @return array
1231 */
1232 public function screen_settings_save( $status, $option, $value ) {
1233 global $user_ID, $gmCore;
1234 if ( 'gm_screen_options' === $option ) {
1235 /*
1236 global $gmGallery;
1237 foreach ( $_POST['gm_screen_options'] as $key => $val ) {
1238 $gmGallery->options['gm_screen_options'][$key] = $val;
1239 }
1240 update_option( 'gmediaOptions', $gmGallery->options );
1241 */
1242 $gm_screen_options = get_user_meta( $user_ID, 'gm_screen_options', true );
1243 if ( ! is_array( $gm_screen_options ) ) {
1244 $gm_screen_options = [];
1245 }
1246 $value = array_merge( $gm_screen_options, $gmCore->_post( 'gm_screen_options', [] ) );
1247
1248 return $value;
1249 }
1250
1251 return $status;
1252 }
1253
1254 }
1255
1256 global $gmAdmin;
1257 // Start GmediaAdmin.
1258 $gmAdmin = new GmediaAdmin();
1259