Gmedia Photo Gallery - Version 1.20.0

Version Description

Download this release

Release Info

Developer pasyuk
Plugin Icon 128x128 Gmedia Photo Gallery
Version 1.20.0
Comparing to
See all releases

Code changes from version 1.18.0 to 1.20.0

Files changed (48) hide show
  1. admin/admin.php +189 -189
  2. admin/ajax.php +2504 -2493
  3. admin/app.php +173 -172
  4. admin/assets/css/gmedia-block.css +28 -28
  5. admin/assets/css/gmedia.admin.css +2013 -1674
  6. admin/assets/css/gmedia.metabox.css +60 -55
  7. admin/assets/img/woowbox-promote.png +0 -0
  8. admin/assets/js/gmedia-block.js +115 -109
  9. admin/assets/js/gmedia.admin.js +1643 -1610
  10. admin/assets/js/gmedia.global.js +8 -8
  11. admin/assets/js/gmedia.metabox.js +261 -250
  12. admin/class.processor.php +271 -280
  13. admin/functions.php +31 -30
  14. admin/logs.php +297 -295
  15. admin/pages/addmedia/addmedia.php +15 -17
  16. admin/pages/addmedia/tpl/assign-terms.php +61 -61
  17. admin/pages/addmedia/tpl/import.php +152 -152
  18. admin/pages/addmedia/tpl/panel-heading.php +39 -39
  19. admin/pages/addmedia/tpl/upload.php +137 -138
  20. admin/pages/galleries/edit-gallery.php +111 -103
  21. admin/pages/galleries/functions.php +25 -25
  22. admin/pages/galleries/galleries.php +44 -44
  23. admin/pages/galleries/tpl/choose-module.php +113 -113
  24. admin/pages/galleries/tpl/galleries-panel-heading.php +79 -79
  25. admin/pages/galleries/tpl/gallery-edit-item.php +207 -204
  26. admin/pages/galleries/tpl/gallery-list-item.php +76 -76
  27. admin/pages/galleries/tpl/gallery-panel-heading.php +48 -46
  28. admin/pages/galleries/tpl/modal-build-query.php +217 -214
  29. admin/pages/galleries/tpl/module-settings.php +229 -219
  30. admin/pages/library/functions.php +134 -132
  31. admin/pages/library/library.php +180 -180
  32. admin/pages/library/tpl/edit-item.php +186 -186
  33. admin/pages/library/tpl/grid-item.php +85 -85
  34. admin/pages/library/tpl/list-item.php +153 -154
  35. admin/pages/library/tpl/no-items.php +23 -23
  36. admin/pages/library/tpl/panel-footer.php +5 -5
  37. admin/pages/library/tpl/panel-heading.php +232 -226
  38. admin/pages/modules/edit-preset.php +46 -46
  39. admin/pages/modules/functions.php +8 -8
  40. admin/pages/modules/modules.php +117 -118
  41. admin/pages/modules/tpl/modal-modulezip.php +21 -22
  42. admin/pages/modules/tpl/module-item.php +84 -84
  43. admin/pages/modules/tpl/module-preset-edit-item.php +87 -87
  44. admin/pages/modules/tpl/module-preset-panel-heading.php +21 -20
  45. admin/pages/settings/settings.php +71 -71
  46. admin/pages/settings/tpl/common.php +241 -240
  47. admin/pages/settings/tpl/license.php +87 -87
  48. admin/pages/settings/tpl/permalinks.php +92 -95
admin/admin.php CHANGED
@@ -4,8 +4,8 @@
4
  * GmediaAdmin - Admin Section for GRAND Media
5
  */
6
  class GmediaAdmin {
7
- var $pages = array();
8
- var $body_classes = array();
9
 
10
  /**
11
  * constructor
@@ -13,19 +13,20 @@ class GmediaAdmin {
13
  function __construct() {
14
  global $pagenow;
15
 
16
- add_action( 'admin_head', array( &$this, 'admin_head' ) );
17
 
18
  // Add the admin menu
19
- add_action( 'admin_menu', array( &$this, 'add_menu' ) );
20
 
21
  // Add the script and style files
22
- add_action( 'admin_enqueue_scripts', array( &$this, 'load_scripts' ), 20 );
23
- add_action( 'admin_print_scripts-widgets.php', array( &$this, 'gmedia_widget_scripts' ) );
24
 
25
- add_action( 'enqueue_block_editor_assets', array( &$this, 'gutenberg_assets' ) );
26
 
27
- add_filter( 'screen_settings', array( &$this, 'screen_settings' ), 10, 2 );
28
- add_filter( 'set-screen-option', array( &$this, 'screen_settings_save' ), 11, 3 );
 
29
 
30
  if ( isset( $_GET['page'] ) && ( false !== strpos( $_GET['page'], 'GrandMedia' ) ) ) {
31
  $this->body_classes[] = 'grand-media-admin-page';
@@ -40,11 +41,11 @@ class GmediaAdmin {
40
  }
41
  }
42
 
43
- if ( ( 'admin.php' == $pagenow ) && isset( $_GET['gmediablank'] ) ) {
44
- add_action( 'admin_init', array( &$this, 'gmedia_blank_page' ) );
45
  }
46
 
47
- add_action( 'admin_footer', array( &$this, 'admin_footer' ) );
48
  }
49
 
50
  }
@@ -53,7 +54,7 @@ class GmediaAdmin {
53
  * admin_head
54
  */
55
  function admin_head() {
56
- add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ) );
57
 
58
  if ( isset( $_GET['page'] ) && ( false !== strpos( $_GET['page'], 'GrandMedia' ) ) ) {
59
  ?>
@@ -96,28 +97,28 @@ class GmediaAdmin {
96
  echo '<div id="gmedia-container">';
97
  switch ( $gmediablank ) {
98
  case 'update_plugin':
99
- require_once( dirname( dirname( __FILE__ ) ) . '/config/update.php' );
100
  gmedia_do_update();
101
  break;
102
  case 'image_editor':
103
- require_once( dirname( dirname( __FILE__ ) ) . '/inc/image-editor.php' );
104
  gmedia_image_editor();
105
  break;
106
  case 'map_editor':
107
- require_once( dirname( dirname( __FILE__ ) ) . '/inc/map-editor.php' );
108
  gmedia_map_editor();
109
  break;
110
  case 'library':
111
  echo '<div id="gmedia_iframe_content">';
112
  echo '<div id="gm-message">' . $gmCore->alert( 'success', $gmProcessor->msg ) . $gmCore->alert( 'danger', $gmProcessor->error ) . '</div>';
113
- include( GMEDIA_ABSPATH . 'admin/pages/library/library.php' );
114
  echo '</div>';
115
  break;
116
  case 'comments':
117
- require_once( dirname( __FILE__ ) . '/tpl/comments.php' );
118
  break;
119
  case 'module_preview':
120
- require_once( dirname( __FILE__ ) . '/tpl/module-preview.php' );
121
  break;
122
  }
123
  echo '</div>';
@@ -126,7 +127,7 @@ class GmediaAdmin {
126
  exit;
127
  }
128
 
129
- // integrate the menu
130
  function add_menu() {
131
 
132
  $count = '';
@@ -135,33 +136,33 @@ class GmediaAdmin {
135
  if ( $gmGallery->options['modules_update'] ) {
136
  $count .= " <span class='update-plugins count-{$gmGallery->options['modules_update']}' style='background-color: #bb391b;'><span class='plugin-count gm-module-count gm-modules-update-count' title='" . __( 'Modules Updates', 'grand-media' ) . "'>{$gmGallery->options['modules_update']}</span></span>";
137
  }
138
- if ( $gmGallery->options['modules_new'] && !empty( $gmGallery->options['notify_new_modules'] ) ) {
139
  $count .= " <span class='update-plugins count-{$gmGallery->options['modules_new']}' style='background-color: #367236;'><span class='plugin-count gm-module-count gm-modules-new-count' title='" . __( 'New Modules', 'grand-media' ) . "'>{$gmGallery->options['modules_new']}</span></span>";
140
  }
141
  }
142
 
143
- $this->pages = array();
144
- $this->pages[] = add_menu_page( __( 'Gmedia Library', 'grand-media' ), "Gmedia{$count}", 'gmedia_library', 'GrandMedia', array(
145
  &$this,
146
  'shell',
147
- ), 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+CjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSIyMHB4IiBoZWlnaHQ9IjIwcHgiIHZpZXdCb3g9IjAgMCAyMCAyMCIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgMjAgMjAiIHhtbDpzcGFjZT0icHJlc2VydmUiPiAgPGltYWdlIGlkPSJpbWFnZTAiIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgeD0iMCIgeT0iMCIKICAgIHhsaW5rOmhyZWY9ImRhdGE6aW1hZ2UvcG5nO2Jhc2U2NCxpVkJPUncwS0dnb0FBQUFOU1VoRVVnQUFBQlFBQUFBVUNBTUFBQUM2ViswL0FBQUFCR2RCVFVFQUFMR1BDL3hoQlFBQUFDQmpTRkpOCkFBQjZKZ0FBZ0lRQUFQb0FBQUNBNkFBQWRUQUFBT3BnQUFBNm1BQUFGM0NjdWxFOEFBQUJrbEJNVkVVeFpua3haM2d4WjNoQ2RJTnUKbEtBK2NZQnBrSjJRcmJhb3Y4YTV5OUdadEx5UnJyZG1qcHMzYTN4WmhKS0txYktPckxXcndjaW52c1dWc2JxM3l0Q1hzcnRWZ1k5UwpmNDZndWNGN25hZzdibjVFZFlWeGxxS01xclN3eGN1aHVzS2Z1TUMrejlSMm1xWTZibjZ1dzhyNy9QekYxTm0weU03dDh2UHo5dmVGCnBhL2Y1K3BiaHBSSWVJZCtvS3FOcTdTZHQ3OWhpcGN5YUhuSDF0clMzdUZIZDRiSzJOMzUrL3YzK2ZxOXp0UmFoWk5QZll5Qm9xeUMKbzYwOGIzOUdkb1poaTVoT2ZJdnE3L0dwdjhiLy8vLzIrUG45L2YzQjBkWkFjb0tZczd3emFIbSt6OVZxa1oxWGc1SFQzK0xZNHVaNgpuYWh3bGFGRGRJVFAzT0JLZVloTWU0bnc5UFhoNmV2eDlmYkwyZDFUZ0k1em1LTXphWHJUM3VLWXM3dlAyOS9WNE9PY3RyN2c2T3VVCnNMbE5mSXU0eTlEbzd2QkZkb1YzbTZibTdlODViWDNJMXR1RHBLN1EzT0JZaEpHUHJMWEMwdGVsdmNSSmVZamI1ZWpOMnQ1eWw2S1cKc3JyYjVPZUFvYXhqakpuZTUrbDJtcVhFMDlpSHByQnRrNTl5bDZOOG5xazRiSDNXNGVUVTMrUFIzZUdxd01jY1RNSnpBQUFBQW5SUwpUbE51MlhMaTRXRUFBQUFCWWt0SFJFVDV0SmpCQUFBQUNYQklXWE1BQUFzVEFBQUxFd0VBbXB3WUFBQUFCM1JKVFVVSDRBc0NDRGNJCmw0WXhCZ0FBQVIxSlJFRlVHTk5qWUdCa1FnT01ESmhpSUZFNGs1bUZGY2FFQzdLeGMzQnljZlB3SWd2eWNmRUxDQW9KYzRxSThvdEIKQmNVRkpDU2xtS1JsWklYbDVCVVVsVUNDeWlxcWF1b2FtbHJhT3N4TXVucjZCb1pBUVNOakUxTW1Kak56QzBzQkt5WW1hMTBiUHFDZwpyWWFkdllLRG81T3ppNnVidTRlOHA1QVhVTkJiMGNmWHo5OHVJRkNDS1VneE9NUk9DR2hScUdaWU9MTmRSR1JVZ0FFVGsxU0VYMVEwCkUwTk1ySGRjZklKVVlwSzdiRExRMHBUVXRIUW1ob3pNTEgzVGhPd2MzY3pjUExEelRMU1lHUElMbUR3S2k0cExtRXFUSWQ3Z0tHUmkKWUF1elk3SXJpeXV2cUlTSVNWVlZBeTJxQ2ErdERtU3BxMk1KckZkcXlNbjN5MjRFQ25weEp6UWxOUHZGeHBxMDVBWUh4N2Z5SW9VUwpNc0FleU5paUF3Q3FwalN3RnBqcGxnQUFBQ1YwUlZoMFpHRjBaVHBqY21WaGRHVUFNakF4TmkweE1TMHdNbFF3T0RvMU5Ub3dPQzB3Ck56b3dNSWl4dXBvQUFBQWxkRVZZZEdSaGRHVTZiVzlrYVdaNUFESXdNVFl0TVRFdE1ESlVNRGc2TlRVNk1EZ3RNRGM2TURENTdBSW0KQUFBQUFFbEZUa1N1UW1DQyIgLz4KPC9zdmc+Cg==', 11 );
148
- $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Gmedia Library', 'grand-media' ), __( 'Gmedia Library', 'grand-media' ), 'gmedia_library', 'GrandMedia', array( &$this, 'shell' ) );
149
  if ( current_user_can( 'gmedia_library' ) ) {
150
- $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Add Media Files', 'grand-media' ), __( 'Add/Import Files', 'grand-media' ), 'gmedia_upload', 'GrandMedia_AddMedia', array( &$this, 'shell' ) );
151
- $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Tags', 'grand-media' ), __( 'Tags', 'grand-media' ), 'gmedia_tag_manage', 'GrandMedia_Tags', array( &$this, 'shell' ) );
152
- $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Categories', 'grand-media' ), __( 'Categories', 'grand-media' ), 'gmedia_category_manage', 'GrandMedia_Categories', array( &$this, 'shell' ) );
153
- $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Albums', 'grand-media' ), __( 'Albums', 'grand-media' ), 'gmedia_album_manage', 'GrandMedia_Albums', array( &$this, 'shell' ) );
154
- $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Gmedia Galleries', 'grand-media' ), __( 'Galleries', 'grand-media' ), 'gmedia_gallery_manage', 'GrandMedia_Galleries', array( &$this, 'shell' ) );
155
- $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Modules', 'grand-media' ), __( 'Modules', 'grand-media' ), 'gmedia_gallery_manage', 'GrandMedia_Modules', array( &$this, 'shell' ) );
156
- $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Gmedia Settings', 'grand-media' ), __( 'Settings', 'grand-media' ), 'manage_options', 'GrandMedia_Settings', array( &$this, 'shell' ) );
157
  //$this->pages[] = add_submenu_page( 'GrandMedia', __( 'iOS Application', 'grand-media' ), __( 'iOS Application', 'grand-media' ), 'gmedia_settings', 'GrandMedia_App', array( &$this, 'shell' ) );
158
- $this->pages[] = add_submenu_page( 'GrandMedia', __( 'WordPress Media Library', 'grand-media' ), __( 'WP Media Library', 'grand-media' ), 'gmedia_import', 'GrandMedia_WordpressLibrary', array( &$this, 'shell' ) );
159
- $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Gmedia Logs', 'grand-media' ), __( 'Gmedia Logs', 'grand-media' ), 'manage_options', 'GrandMedia_Logs', array( &$this, 'shell' ) );
160
  //$this->pages[] = add_submenu_page( 'GrandMedia', __( 'Gmedia Support', 'grand-media' ), __( 'Support', 'grand-media' ), 'manage_options', 'GrandMedia_Support', array( &$this, 'shell' ) );
161
  }
162
 
163
  foreach ( $this->pages as $page ) {
164
- add_action( "load-$page", array( &$this, 'screen_help' ) );
165
  }
166
  }
167
 
@@ -175,8 +176,8 @@ class GmediaAdmin {
175
  $sideLinks = $this->sideLinks();
176
 
177
  // check for upgrade
178
- if ( get_option( 'gmediaDbVersion' ) != GMEDIA_DBVERSION ) {
179
- if ( get_transient( 'gmediaUpgrade' ) || ( isset( $_GET['do_update'] ) && ( 'gmedia' == $_GET['do_update'] ) ) ) {
180
  $sideLinks['grandTitle'] = __( 'Updating GmediaGallery Plugin', 'grand-media' );
181
  $sideLinks['sideLinks'] = '';
182
  $gmProcessor->page = 'GrandMedia_Update';
@@ -204,11 +205,11 @@ class GmediaAdmin {
204
  <div id="gmedia-logo">Gmedia
205
  <small> by CodEasily.com</small>
206
  </div>
207
- <h2><?php echo $sideLinks['grandTitle']; ?></h2>
208
  <?php
209
- if ( ! is_plugin_active( 'woowbox/woowbox.php' ) && empty( $gmGallery->options['disable_ads'] ) ) {
210
  ?>
211
- <div class="promote-woowbox"><a href="https://bit.ly/woowbox" target="_blank"><img src="<?php echo plugins_url( '/grand-media/admin/assets/img/woowbox-promote.png' ) ?>" alt="Try WoowBox Gallery plugin"/></a></div>
212
  <?php
213
  }
214
  ?>
@@ -276,15 +277,15 @@ class GmediaAdmin {
276
  $content['sideLinks'] .= "\n" . '<a class="list-group-item list-group-item-premium" target="_blank" href="https://codeasily.com/product/one-site-license/">' . __( 'Get Gmedia Premium', 'grand-media' ) . '</a></li><li>';
277
  }
278
  foreach ( $submenu['GrandMedia'] as $menuKey => $menuItem ) {
279
- if ( $menuItem[2] == $gmProcessor->page ) {
280
  $iscur = ' active';
281
  $content['grandTitle'] = $menuItem[3];
282
  } else {
283
  $iscur = '';
284
  }
285
  $menuData = '';
286
- if ( $menuItem[2] == 'GrandMedia_Modules' && gm_user_can( 'module_manage' ) ) {
287
- if ( !empty( $gmGallery->options['notify_new_modules'] ) ) {
288
  $menuData .= '<span class="badge badge-success pull-right gm-module-count-' . $gmGallery->options['modules_new'] . '" title="' . __( 'New Modules', 'grand-media' ) . '">' . $gmGallery->options['modules_new'] . '</span>';
289
  }
290
  $menuData .= '<span class="badge badge-error pull-right gm-module-count-' . $gmGallery->options['modules_update'] . '" title="' . __( 'Modules Updates', 'grand-media' ) . '">' . $gmGallery->options['modules_update'] . '</span>';
@@ -308,14 +309,14 @@ class GmediaAdmin {
308
  <div class="notice updated gm-message gmedia-service__message">
309
  <div class="gm-message-content">
310
  <div class="gm-plugin-icon">
311
- <img src="<?php echo plugins_url( '/grand-media/admin/assets/img/icon-128x128.png' ) ?>" width="90" height="90">
312
  </div>
313
  <?php printf( __( '<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>.
314
  If you skip this, that\'s okay! <b>Gmedia Gallery</b> will still work just fine.</p>', 'grand-media' ), $current_user->display_name ); ?>
315
  </div>
316
  <div class="gm-message-actions">
317
- <button class="button button-secondary gm_service_action" data-action="skip" data-nonce="<?php echo $nonce; ?>"><?php _e( 'Skip', 'grand-media' ); ?></button>
318
- <button class="button button-primary gm_service_action" data-action="allow" data-nonce="<?php echo $nonce; ?>"><?php _e( 'Allow &amp; Continue', 'grand-media' ); ?></button>
319
  </div>
320
  <div class="gm-message-plus gm-closed">
321
  <a class="gm-mp-trigger" href="#" onclick="jQuery('.gm-message-plus').toggleClass('gm-closed gm-opened'); return false;"><?php _e( 'What permissions are being granted?', 'grand-media' ); ?></a>
@@ -344,106 +345,68 @@ class GmediaAdmin {
344
  <?php
345
  }
346
 
347
- function admin_footer() {
348
- $ajax_operations = get_option( 'gmedia_ajax_long_operations' );
349
- if ( empty( $ajax_operations ) || ! is_array( $ajax_operations ) ) {
350
- return;
351
- }
352
- reset( $ajax_operations );
353
- $ajax = key( $ajax_operations );
354
- if ( empty( $ajax ) ) {
355
- delete_option( 'gmedia_ajax_long_operations' );
356
-
357
- return;
358
- }
359
- $nonce = wp_create_nonce( 'gmedia_ajax_long_operations' );
360
- ?>
361
- <script type="text/javascript">
362
- jQuery(document).ready(function($) {
363
- var header = $('#gmedia-header');
364
- 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>');
365
- gmAjaxLongOperation = function() {
366
- jQuery.post(ajaxurl, {action: '<?php echo $ajax; ?>', _wpnonce_ajax_long_operations: '<?php echo $nonce; ?>'}, function(r) {
367
- if(r.data) {
368
- jQuery('.progress-bar-info', header).width(r.data.progress);
369
- var indicator = r.data.info ? r.data.info + ' ' + r.data.progress : r.data.progress;
370
- jQuery('.progress-bar-indicator', header).html(indicator);
371
-
372
- if(r.data.done) {
373
- return;
374
- }
375
- }
376
- gmAjaxLongOperation();
377
- });
378
- };
379
- gmAjaxLongOperation();
380
- });
381
- </script>
382
- <?php
383
- }
384
-
385
  function controller() {
386
 
387
  global $gmProcessor;
388
  switch ( $gmProcessor->page ) {
389
  case 'GrandMedia_AddMedia':
390
- include_once( dirname( __FILE__ ) . '/pages/addmedia/addmedia.php' );
391
  break;
392
  case 'GrandMedia_Albums':
393
  if ( isset( $_GET['edit_term'] ) ) {
394
- include_once( dirname( __FILE__ ) . '/pages/terms/edit-term.php' );
395
  } else {
396
- include_once( dirname( __FILE__ ) . '/pages/terms/terms.php' );
397
  }
398
  break;
399
  case 'GrandMedia_Categories':
400
  if ( isset( $_GET['edit_term'] ) ) {
401
- include_once( dirname( __FILE__ ) . '/pages/terms/edit-term.php' );
402
  } else {
403
- include_once( dirname( __FILE__ ) . '/pages/terms/terms.php' );
404
  }
405
  break;
406
  case 'GrandMedia_Tags':
407
- include_once( dirname( __FILE__ ) . '/pages/terms/terms.php' );
408
  break;
409
  case 'GrandMedia_Galleries':
410
  if ( isset( $_GET['gallery_module'] ) || isset( $_GET['edit_term'] ) ) {
411
- include_once( dirname( __FILE__ ) . '/pages/galleries/edit-gallery.php' );
412
  } else {
413
- include_once( dirname( __FILE__ ) . '/pages/galleries/galleries.php' );
414
  }
415
  break;
416
  case 'GrandMedia_Modules':
417
  if ( isset( $_GET['preset_module'] ) || isset( $_GET['preset'] ) ) {
418
- include_once( dirname( __FILE__ ) . '/pages/modules/edit-preset.php' );
419
  } else {
420
- include_once( dirname( __FILE__ ) . '/pages/modules/modules.php' );
421
  }
422
  break;
423
  case 'GrandMedia_Settings':
424
- include_once( dirname( __FILE__ ) . '/pages/settings/settings.php' );
425
  break;
426
  case 'GrandMedia_App':
427
- include_once( dirname( __FILE__ ) . '/app.php' );
428
  gmediaApp();
429
  break;
430
  case 'GrandMedia_WordpressLibrary':
431
- include_once( dirname( __FILE__ ) . '/wpmedia.php' );
432
  grandWPMedia();
433
  break;
434
  case 'GrandMedia_Logs':
435
- include_once( dirname( __FILE__ ) . '/logs.php' );
436
  break;
437
  case 'GrandMedia_Support':
438
- include_once( dirname( __FILE__ ) . '/support.php' );
439
  gmediaSupport();
440
  break;
441
  case 'GrandMedia_Update':
442
- include_once( GMEDIA_ABSPATH . 'config/update.php' );
443
  gmedia_upgrade_progress_panel();
444
  break;
445
  case 'GrandMedia':
446
- include_once( dirname( __FILE__ ) . '/pages/library/library.php' );
447
  break;
448
  default:
449
  do_action( 'gmedia_admin_page-' . $gmProcessor->page );
@@ -451,13 +414,51 @@ class GmediaAdmin {
451
  }
452
  }
453
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
454
  /**
455
  * @param $hook
456
  */
457
  function load_scripts( $hook ) {
458
  global $gmCore, $gmProcessor, $gmGallery;
459
  // no need to go on if it's not a plugin page
460
- if ( 'admin.php' != $hook && strpos( $gmCore->_get( 'page' ), 'GrandMedia' ) === false ) {
461
  return;
462
  }
463
 
@@ -465,7 +466,7 @@ class GmediaAdmin {
465
  global $wp_scripts, $wp_styles;
466
  foreach ( $wp_scripts->registered as $handle => $wp_script ) {
467
  if ( ( ( false !== strpos( $wp_script->src, '/plugins/' ) ) || ( false !== strpos( $wp_script->src, '/themes/' ) ) ) && ( false === strpos( $wp_script->src, GMEDIA_FOLDER ) ) ) {
468
- if ( in_array( $handle, $wp_scripts->queue ) ) {
469
  wp_dequeue_script( $handle );
470
  }
471
  wp_deregister_script( $handle );
@@ -473,7 +474,7 @@ class GmediaAdmin {
473
  }
474
  foreach ( $wp_styles->registered as $handle => $wp_style ) {
475
  if ( ( ( false !== strpos( $wp_style->src, '/plugins/' ) ) || ( false !== strpos( $wp_style->src, '/themes/' ) ) ) && ( false === strpos( $wp_style->src, GMEDIA_FOLDER ) ) ) {
476
- if ( in_array( $handle, $wp_styles->queue ) ) {
477
  wp_dequeue_style( $handle );
478
  }
479
  wp_deregister_style( $handle );
@@ -484,58 +485,58 @@ class GmediaAdmin {
484
  wp_enqueue_style( 'gmedia-bootstrap' );
485
  wp_enqueue_script( 'gmedia-bootstrap' );
486
 
487
- wp_register_script( 'selectize', $gmCore->gmedia_url . '/assets/selectize/selectize.min.js', array( 'jquery' ), '0.12.1' );
488
- wp_register_style( 'selectize', $gmCore->gmedia_url . '/assets/selectize/selectize.bootstrap3.css', array( 'gmedia-bootstrap' ), '0.12.1', 'screen' );
489
 
490
- wp_register_style( 'spectrum', $gmCore->gmedia_url . '/assets/spectrum/spectrum.min.css', array(), '1.8.0' );
491
- wp_register_script( 'spectrum', $gmCore->gmedia_url . '/assets/spectrum/spectrum.min.js', array( 'jquery' ), '1.8.0', true );
492
 
493
  if ( isset( $_GET['page'] ) ) {
494
  switch ( $_GET['page'] ) {
495
  case "GrandMedia" :
496
  if ( $gmCore->caps['gmedia_edit_media'] ) {
497
- if ( $gmCore->_get( 'gmediablank' ) == 'image_editor' ) {
498
- wp_enqueue_script( 'camanjs', $gmCore->gmedia_url . '/assets/image-editor/camanjs/caman.full.min.js', array(), '4.1.2' );
499
 
500
- wp_enqueue_style( 'nouislider', $gmCore->gmedia_url . '/assets/image-editor/js/jquery.nouislider.css', array( 'gmedia-bootstrap' ), '6.1.0' );
501
- wp_enqueue_script( 'nouislider', $gmCore->gmedia_url . '/assets/image-editor/js/jquery.nouislider.min.js', array( 'jquery' ), '6.1.0' );
502
 
503
- wp_enqueue_style( 'gmedia-image-editor', $gmCore->gmedia_url . '/assets/image-editor/style.css', array( 'gmedia-bootstrap' ), '0.9.16', 'screen' );
504
- wp_enqueue_script( 'gmedia-image-editor', $gmCore->gmedia_url . '/assets/image-editor/image-editor.js', array( 'jquery', 'camanjs' ), '0.9.16' );
505
  break;
506
  }
507
- if ( $gmProcessor->mode == 'edit' ) {
508
- wp_enqueue_script( 'alphanum', $gmCore->gmedia_url . '/assets/jq-plugins/jquery.alphanum.js', array( 'jquery' ), '1.0.16' );
509
 
510
  wp_enqueue_script( 'jquery-ui-sortable' );
511
 
512
- wp_enqueue_script( 'moment', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/moment.min.js', array( 'jquery' ), '2.22.2' );
513
- wp_enqueue_style( 'datetimepicker', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css', array( 'gmedia-bootstrap' ), '4.17.47' );
514
- wp_enqueue_script( 'datetimepicker', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js', array(
515
  'jquery',
516
  'moment',
517
  'gmedia-bootstrap',
518
- ), '4.17.47' );
519
  }
520
  }
521
- wp_enqueue_script( 'wavesurfer', $gmCore->gmedia_url . '/assets/wavesurfer/wavesurfer.min.js', array( 'jquery' ), '1.1.5' );
522
  break;
523
  case "GrandMedia_WordpressLibrary" :
524
  break;
525
  case "GrandMedia_Albums" :
526
  if ( isset( $_GET['edit_term'] ) ) {
527
  if ( $gmCore->caps['gmedia_album_manage'] ) {
528
- wp_enqueue_style( 'jquery-ui-smoothness', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/smoothness/jquery-ui.min.css', array(), '1.10.2', 'screen' );
529
- wp_enqueue_script( 'jquery-ui-full', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js', array(), '1.10.2' );
530
  }
531
 
532
- wp_enqueue_script( 'moment', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/moment.min.js', array( 'jquery' ), '2.5.1' );
533
- wp_enqueue_style( 'datetimepicker', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css', array( 'gmedia-bootstrap' ), '2.1.32' );
534
- wp_enqueue_script( 'datetimepicker', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js', array(
535
  'jquery',
536
  'moment',
537
  'gmedia-bootstrap',
538
- ), '2.1.32' );
539
  }
540
  break;
541
  case "GrandMedia_Categories" :
@@ -543,17 +544,17 @@ class GmediaAdmin {
543
  case "GrandMedia_AddMedia" :
544
  if ( $gmCore->caps['gmedia_upload'] ) {
545
  $tab = $gmCore->_get( 'tab', 'upload' );
546
- if ( $tab == 'upload' ) {
547
- wp_enqueue_style( 'jquery-ui-smoothness', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/smoothness/jquery-ui.min.css', array(), '1.10.2', 'screen' );
548
- wp_enqueue_script( 'jquery-ui-full', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js', array(), '1.10.2' );
549
 
550
- wp_enqueue_script( 'gmedia-plupload', $gmCore->gmedia_url . '/assets/plupload/plupload.full.min.js', array( 'jquery', 'jquery-ui-full' ), '2.1.2' );
551
 
552
- wp_enqueue_style( 'jquery.ui.plupload', $gmCore->gmedia_url . '/assets/plupload/jquery.ui.plupload/css/jquery.ui.plupload.css', array( 'jquery-ui-smoothness' ), '2.1.2', 'screen' );
553
- wp_enqueue_script( 'jquery.ui.plupload', $gmCore->gmedia_url . '/assets/plupload/jquery.ui.plupload/jquery.ui.plupload.min.js', array(
554
  'gmedia-plupload',
555
  'jquery-ui-full',
556
- ), '2.1.2' );
557
 
558
  }
559
  }
@@ -565,13 +566,13 @@ class GmediaAdmin {
565
  case "GrandMedia_Galleries" :
566
  if ( $gmCore->caps['gmedia_gallery_manage'] && ( isset( $_GET['gallery_module'] ) || isset( $_GET['edit_term'] ) ) ) {
567
 
568
- wp_enqueue_style( 'jquery-ui-smoothness', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/smoothness/jquery-ui.min.css', array(), '1.10.2', 'screen' );
569
  wp_enqueue_script( 'jquery-ui-resizable' );
570
 
571
  wp_enqueue_script( 'jquery-ui-sortable' );
572
 
573
- wp_enqueue_style( 'jquery.minicolors', $gmCore->gmedia_url . '/assets/minicolors/jquery.minicolors.css', array( 'gmedia-bootstrap' ), '0.9.13' );
574
- wp_enqueue_script( 'jquery.minicolors', $gmCore->gmedia_url . '/assets/minicolors/jquery.minicolors.js', array( 'jquery' ), '0.9.13' );
575
 
576
  wp_enqueue_style( 'spectrum' );
577
  wp_enqueue_script( 'spectrum' );
@@ -580,13 +581,13 @@ class GmediaAdmin {
580
  case "GrandMedia_Modules" :
581
  if ( isset( $_GET['preset_module'] ) || isset( $_GET['preset'] ) ) {
582
 
583
- wp_enqueue_style( 'jquery-ui-smoothness', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/smoothness/jquery-ui.min.css', array(), '1.10.2', 'screen' );
584
  wp_enqueue_script( 'jquery-ui-resizable' );
585
 
586
  wp_enqueue_script( 'jquery-ui-sortable' );
587
 
588
- wp_enqueue_style( 'jquery.minicolors', $gmCore->gmedia_url . '/assets/minicolors/jquery.minicolors.css', array( 'gmedia-bootstrap' ), '0.9.13' );
589
- wp_enqueue_script( 'jquery.minicolors', $gmCore->gmedia_url . '/assets/minicolors/jquery.minicolors.js', array( 'jquery' ), '0.9.13' );
590
 
591
  wp_enqueue_style( 'spectrum' );
592
  wp_enqueue_script( 'spectrum' );
@@ -612,11 +613,11 @@ class GmediaAdmin {
612
  function gutenberg_assets() {
613
  global $gmGallery, $gmDB, $gmCore;
614
 
615
- wp_enqueue_style( 'gmedia-block-editor', $gmCore->gmedia_url . '/admin/assets/css/gmedia-block.css', array(), $gmGallery->version );
616
  wp_register_script(
617
  'gmedia-block-editor',
618
  $gmCore->gmedia_url . '/admin/assets/js/gmedia-block.js',
619
- array( 'wp-blocks', 'wp-element' ),
620
  $gmGallery->version
621
  );
622
 
@@ -625,13 +626,13 @@ class GmediaAdmin {
625
  $default_module = $default_preset['module'];
626
 
627
  $modules_data = get_gmedia_modules( false );
628
- $modules = array();
629
- $modules_options = array();
630
  if ( ! empty( $modules_data['in'] ) ) {
631
  foreach ( $modules_data['in'] as $module_name => $module_data ) {
632
 
633
- $presets = $gmDB->get_terms( 'gmedia_module', array( 'status' => $module_name ) );
634
- $option = array();
635
  $option[ $module_name ] = $module_data['title'] . ' - ' . __( 'Default Settings' );
636
  foreach ( $presets as $preset ) {
637
  if ( ! (int) $preset->global && '[' . $module_name . ']' === $preset->name ) {
@@ -649,19 +650,19 @@ class GmediaAdmin {
649
  $option[ $preset->term_id ] = $module_data['title'] . $by_author . ' - ' . $preset_name;
650
  }
651
  }
652
- $modules_options[ $module_name ] = array( 'title' => $module_data['title'], 'options' => $option );
653
 
654
- $modules[ $module_name ] = array(
655
  'name' => $module_data['title'],
656
  'screenshot' => $module_data['module_url'] . '/screenshot.png',
657
- );
658
  }
659
  }
660
 
661
- $gm_galleries = array();
662
- $gm_albums = array();
663
- $gm_categories = array();
664
- $gm_tags = array();
665
 
666
  $gm_terms = $gmDB->get_terms( 'gmedia_gallery' );
667
  if ( count( $gm_terms ) ) {
@@ -670,7 +671,7 @@ class GmediaAdmin {
670
  unset( $_term->taxonomy );
671
  $_term->module_name = $gmDB->get_metadata( 'gmedia_term', $_term->term_id, '_module', true );
672
  if ( $_term->global ) {
673
- $display_name = sprintf( __( 'by %s', 'grand-media' ), get_the_author_meta( 'display_name', $_term->global ) );
674
  $_term->name .= 'by ' === $display_name ? '' : ' ' . $display_name;
675
  }
676
  if ( $_term->status && 'publish' !== $_term->status ) {
@@ -679,12 +680,12 @@ class GmediaAdmin {
679
  $gm_galleries[ $_term->term_id ] = $_term;
680
  }
681
  }
682
- $gm_galleries = array(
683
- 0 => array(
684
  'term_id' => 0,
685
  'name' => __( ' - select gallery - ', 'grand-media' ),
686
- ),
687
- ) + $gm_galleries;
688
 
689
  $gm_terms = $gmDB->get_terms( 'gmedia_album' );
690
  if ( count( $gm_terms ) ) {
@@ -699,7 +700,7 @@ class GmediaAdmin {
699
  $_term->module_name = '';
700
  }
701
  if ( $_term->global ) {
702
- $display_name = sprintf( __( 'by %s', 'grand-media' ), get_the_author_meta( 'display_name', $_term->global ) );
703
  $_term->name .= 'by ' === $display_name ? '' : ' ' . $display_name;
704
  }
705
  if ( $_term->status && 'publish' !== $_term->status ) {
@@ -709,12 +710,12 @@ class GmediaAdmin {
709
  $gm_albums[ $_term->term_id ] = $_term;
710
  }
711
  }
712
- $gm_albums = array(
713
- 0 => array(
714
  'term_id' => 0,
715
  'name' => __( ' - select album - ', 'grand-media' ),
716
- ),
717
- ) + $gm_albums;
718
 
719
  $gm_terms = $gmDB->get_terms( 'gmedia_category' );
720
  if ( count( $gm_terms ) ) {
@@ -727,12 +728,12 @@ class GmediaAdmin {
727
  $gm_categories[ $_term->term_id ] = $_term;
728
  }
729
  }
730
- $gm_categories = array(
731
- 0 => array(
732
  'term_id' => 0,
733
  'name' => __( ' - select category - ', 'grand-media' ),
734
- ),
735
- ) + $gm_categories;
736
 
737
  $gm_terms = $gmDB->get_terms( 'gmedia_tag' );
738
  if ( count( $gm_terms ) ) {
@@ -745,14 +746,14 @@ class GmediaAdmin {
745
  $gm_tags[ $_term->term_id ] = $_term;
746
  }
747
  }
748
- $gm_tags = array(
749
- 0 => array(
750
  'term_id' => 0,
751
  'name' => __( ' - select tag - ', 'grand-media' ),
752
- ),
753
- ) + $gm_tags;
754
 
755
- $data = array(
756
  'modules' => $modules,
757
  'default_module' => $default_module,
758
  'modules_options' => $modules_options,
@@ -761,7 +762,7 @@ class GmediaAdmin {
761
  'albums' => $gm_albums,
762
  'categories' => $gm_categories,
763
  'tags' => $gm_tags,
764
- );
765
 
766
  wp_localize_script( 'gmedia-block-editor', 'gmedia_data', $data );
767
  wp_enqueue_script( 'gmedia-block-editor' );
@@ -772,7 +773,7 @@ class GmediaAdmin {
772
  $screen_id = explode( 'page_', $screen->id, 2 );
773
  $screen_id = $screen_id[1];
774
 
775
- $screen->add_help_tab( array(
776
  'id' => 'help_' . $screen_id . '_support',
777
  'title' => __( 'Support' ),
778
  'content' => __( '<h4>First steps</h4>
@@ -787,14 +788,14 @@ class GmediaAdmin {
787
  | <a href="https://codeasily.com/portfolio/gmedia-gallery-modules/" target="_blank">' . __( 'Demo', 'grand-media' ) . '</a>
788
  | <a href="https://codeasily.com/product/one-site-license/" target="_blank">' . __( 'Premium', 'grand-media' ) . '</a>
789
  </p>',
790
- ) );
791
 
792
  switch ( $screen_id ) {
793
  case 'GrandMedia' :
794
  break;
795
  case 'GrandMedia_Settings' :
796
  if ( current_user_can( 'manage_options' ) ) {
797
- $screen->add_help_tab( array(
798
  'id' => 'help_' . $screen_id . '_license',
799
  'title' => __( 'License Key' ),
800
  'content' => sprintf( __( '<h4>Should I buy it, to use plugin?</h4>
@@ -803,22 +804,21 @@ class GmediaAdmin {
803
  <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>
804
  <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>
805
  <h4>I have license key but I can\'t activate it</h4>
806
- <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>', 'grand-media' ), 'https://codeasily.com/community/forum/gmedia-gallery-wordpress-plugin/', 'gmediafolder@gmail.com' )
807
  . '<div><a class="btn btn-default" href="' . admin_url( 'admin.php?page=' . $screen_id . '&license_activate=manual' ) . '">' . __( 'Manual Activation', 'grand-media' ) . '</a></div>',
808
- ) );
809
  }
810
  break;
811
  case 'GrandMedia_App' :
812
  $gm_options = get_option( 'gmediaOptions' );
813
  $nonce = wp_create_nonce( 'GmediaService' );
814
  if ( current_user_can( 'manage_options' ) && (int) $gm_options['mobile_app'] ) {
815
- $screen->add_help_tab( array(
816
  'id' => 'help_' . $screen_id . '_optout',
817
  'title' => __( 'Opt Out' ),
818
  'content' => __( '<h4>We appreciate your help in making the plugin better by letting us track some usage data.</h4>
819
  <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>
820
- <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>
821
- <p>You\'ll also not be able to use Gmedia iOS application.</p>', 'grand-media' )
822
  . '<p><button class="button button-default gm_service_action" data-action="app_deactivate" data-nonce="' . $nonce . '">' . __( 'Opt Out', 'grand-media' ) . '</button><span class="spinner" style="float: none;"></span></p>'
823
  . '<div style="display:none;">Test:
824
  <button type="button" data-action="app_updateinfo" data-nonce="' . $nonce . '" class="btn btn-sm btn-primary gm_service_action">Update</button>
@@ -827,7 +827,7 @@ class GmediaAdmin {
827
  <button type="button" data-action="app_uninstallplugin" data-nonce="' . $nonce . '" class="btn btn-sm btn-primary gm_service_action">Uninstall Plugin</button>
828
  </div>
829
  ',
830
- ) );
831
  }
832
  break;
833
  }
@@ -841,7 +841,7 @@ class GmediaAdmin {
841
  */
842
  function screen_settings( $current, $screen ) {
843
  global $gmProcessor, $gmCore;
844
- if ( in_array( $screen->id, $this->pages ) ) {
845
 
846
  $gm_screen_options = $gmProcessor->user_options;
847
 
@@ -883,7 +883,7 @@ class GmediaAdmin {
883
  </select> <span>' . __( 'sort order', 'grand-media' ) . '</span>
884
  </div>
885
  ';
886
- if ( 'edit' == $gmCore->_get( 'mode' ) ) {
887
  $settings .= '
888
  <div class="form-group">
889
  <select name="gm_screen_options[library_edit_quicktags]" class="form-control input-sm">
@@ -899,8 +899,8 @@ class GmediaAdmin {
899
  break;
900
  case 'GrandMedia_AddMedia' :
901
  $tab = $gmCore->_get( 'tab', 'upload' );
902
- if ( 'upload' == $tab ) {
903
- $html4_hide = ( 'html4' == $gm_screen_options['uploader_runtime'] ) ? ' hide' : '';
904
  $settings = '
905
  <div class="form-inline pull-left">
906
  <div id="uploader_runtime" class="form-group"><span>' . __( 'Uploader runtime:', 'grand-media' ) . ' </span>
@@ -1106,7 +1106,7 @@ class GmediaAdmin {
1106
  */
1107
  function screen_settings_save( $status, $option, $value ) {
1108
  global $user_ID;
1109
- if ( 'gm_screen_options' == $option ) {
1110
  /*
1111
  global $gmGallery;
1112
  foreach ( $_POST['gm_screen_options'] as $key => $val ) {
@@ -1116,7 +1116,7 @@ class GmediaAdmin {
1116
  */
1117
  $gm_screen_options = get_user_meta( $user_ID, 'gm_screen_options', true );
1118
  if ( ! is_array( $gm_screen_options ) ) {
1119
- $gm_screen_options = array();
1120
  }
1121
  $value = array_merge( $gm_screen_options, $_POST['gm_screen_options'] );
1122
 
@@ -1129,5 +1129,5 @@ class GmediaAdmin {
1129
  }
1130
 
1131
  global $gmAdmin;
1132
- // Start GmediaAdmin
1133
  $gmAdmin = new GmediaAdmin();
4
  * GmediaAdmin - Admin Section for GRAND Media
5
  */
6
  class GmediaAdmin {
7
+ var $pages = [];
8
+ var $body_classes = [];
9
 
10
  /**
11
  * constructor
13
  function __construct() {
14
  global $pagenow;
15
 
16
+ add_action( 'admin_head', [ &$this, 'admin_head' ] );
17
 
18
  // Add the admin menu
19
+ add_action( 'admin_menu', [ &$this, 'add_menu' ] );
20
 
21
  // Add the script and style files
22
+ add_action( 'admin_enqueue_scripts', [ &$this, 'load_scripts' ], 20 );
23
+ add_action( 'admin_print_scripts-widgets.php', [ &$this, 'gmedia_widget_scripts' ] );
24
 
25
+ add_action( 'enqueue_block_editor_assets', [ &$this, 'gutenberg_assets' ] );
26
 
27
+ add_filter( 'screen_settings', [ &$this, 'screen_settings' ], 10, 2 );
28
+ add_filter( 'set-screen-option', [ &$this, 'screen_settings_save' ], 11, 3 );
29
+ add_filter( 'set_screen_option_gm_screen_options', [ &$this, 'screen_settings_save' ], 11, 3 );
30
 
31
  if ( isset( $_GET['page'] ) && ( false !== strpos( $_GET['page'], 'GrandMedia' ) ) ) {
32
  $this->body_classes[] = 'grand-media-admin-page';
41
  }
42
  }
43
 
44
+ if ( ( 'admin.php' === $pagenow ) && isset( $_GET['gmediablank'] ) ) {
45
+ add_action( 'admin_init', [ &$this, 'gmedia_blank_page' ] );
46
  }
47
 
48
+ add_action( 'admin_footer', [ &$this, 'admin_footer' ] );
49
  }
50
 
51
  }
54
  * admin_head
55
  */
56
  function admin_head() {
57
+ add_filter( 'admin_body_class', [ &$this, 'admin_body_class' ] );
58
 
59
  if ( isset( $_GET['page'] ) && ( false !== strpos( $_GET['page'], 'GrandMedia' ) ) ) {
60
  ?>
97
  echo '<div id="gmedia-container">';
98
  switch ( $gmediablank ) {
99
  case 'update_plugin':
100
+ require_once dirname( dirname( __FILE__ ) ) . '/config/update.php';
101
  gmedia_do_update();
102
  break;
103
  case 'image_editor':
104
+ require_once dirname( dirname( __FILE__ ) ) . '/inc/image-editor.php';
105
  gmedia_image_editor();
106
  break;
107
  case 'map_editor':
108
+ require_once dirname( dirname( __FILE__ ) ) . '/inc/map-editor.php';
109
  gmedia_map_editor();
110
  break;
111
  case 'library':
112
  echo '<div id="gmedia_iframe_content">';
113
  echo '<div id="gm-message">' . $gmCore->alert( 'success', $gmProcessor->msg ) . $gmCore->alert( 'danger', $gmProcessor->error ) . '</div>';
114
+ include GMEDIA_ABSPATH . 'admin/pages/library/library.php';
115
  echo '</div>';
116
  break;
117
  case 'comments':
118
+ require_once dirname( __FILE__ ) . '/tpl/comments.php';
119
  break;
120
  case 'module_preview':
121
+ require_once dirname( __FILE__ ) . '/tpl/module-preview.php';
122
  break;
123
  }
124
  echo '</div>';
127
  exit;
128
  }
129
 
130
+ // integrate the menu.
131
  function add_menu() {
132
 
133
  $count = '';
136
  if ( $gmGallery->options['modules_update'] ) {
137
  $count .= " <span class='update-plugins count-{$gmGallery->options['modules_update']}' style='background-color: #bb391b;'><span class='plugin-count gm-module-count gm-modules-update-count' title='" . __( 'Modules Updates', 'grand-media' ) . "'>{$gmGallery->options['modules_update']}</span></span>";
138
  }
139
+ if ( $gmGallery->options['modules_new'] && ! empty( $gmGallery->options['notify_new_modules'] ) ) {
140
  $count .= " <span class='update-plugins count-{$gmGallery->options['modules_new']}' style='background-color: #367236;'><span class='plugin-count gm-module-count gm-modules-new-count' title='" . __( 'New Modules', 'grand-media' ) . "'>{$gmGallery->options['modules_new']}</span></span>";
141
  }
142
  }
143
 
144
+ $this->pages = [];
145
+ $this->pages[] = add_menu_page( __( 'Gmedia Library', 'grand-media' ), "Gmedia{$count}", 'gmedia_library', 'GrandMedia', [
146
  &$this,
147
  'shell',
148
+ ], 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+CjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSIyMHB4IiBoZWlnaHQ9IjIwcHgiIHZpZXdCb3g9IjAgMCAyMCAyMCIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgMjAgMjAiIHhtbDpzcGFjZT0icHJlc2VydmUiPiAgPGltYWdlIGlkPSJpbWFnZTAiIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgeD0iMCIgeT0iMCIKICAgIHhsaW5rOmhyZWY9ImRhdGE6aW1hZ2UvcG5nO2Jhc2U2NCxpVkJPUncwS0dnb0FBQUFOU1VoRVVnQUFBQlFBQUFBVUNBTUFBQUM2ViswL0FBQUFCR2RCVFVFQUFMR1BDL3hoQlFBQUFDQmpTRkpOCkFBQjZKZ0FBZ0lRQUFQb0FBQUNBNkFBQWRUQUFBT3BnQUFBNm1BQUFGM0NjdWxFOEFBQUJrbEJNVkVVeFpua3haM2d4WjNoQ2RJTnUKbEtBK2NZQnBrSjJRcmJhb3Y4YTV5OUdadEx5UnJyZG1qcHMzYTN4WmhKS0txYktPckxXcndjaW52c1dWc2JxM3l0Q1hzcnRWZ1k5UwpmNDZndWNGN25hZzdibjVFZFlWeGxxS01xclN3eGN1aHVzS2Z1TUMrejlSMm1xWTZibjZ1dzhyNy9QekYxTm0weU03dDh2UHo5dmVGCnBhL2Y1K3BiaHBSSWVJZCtvS3FOcTdTZHQ3OWhpcGN5YUhuSDF0clMzdUZIZDRiSzJOMzUrL3YzK2ZxOXp0UmFoWk5QZll5Qm9xeUMKbzYwOGIzOUdkb1poaTVoT2ZJdnE3L0dwdjhiLy8vLzIrUG45L2YzQjBkWkFjb0tZczd3emFIbSt6OVZxa1oxWGc1SFQzK0xZNHVaNgpuYWh3bGFGRGRJVFAzT0JLZVloTWU0bnc5UFhoNmV2eDlmYkwyZDFUZ0k1em1LTXphWHJUM3VLWXM3dlAyOS9WNE9PY3RyN2c2T3VVCnNMbE5mSXU0eTlEbzd2QkZkb1YzbTZibTdlODViWDNJMXR1RHBLN1EzT0JZaEpHUHJMWEMwdGVsdmNSSmVZamI1ZWpOMnQ1eWw2S1cKc3JyYjVPZUFvYXhqakpuZTUrbDJtcVhFMDlpSHByQnRrNTl5bDZOOG5xazRiSDNXNGVUVTMrUFIzZUdxd01jY1RNSnpBQUFBQW5SUwpUbE51MlhMaTRXRUFBQUFCWWt0SFJFVDV0SmpCQUFBQUNYQklXWE1BQUFzVEFBQUxFd0VBbXB3WUFBQUFCM1JKVFVVSDRBc0NDRGNJCmw0WXhCZ0FBQVIxSlJFRlVHTk5qWUdCa1FnT01ESmhpSUZFNGs1bUZGY2FFQzdLeGMzQnljZlB3SWd2eWNmRUxDQW9KYzRxSThvdEIKQmNVRkpDU2xtS1JsWklYbDVCVVVsVUNDeWlxcWF1b2FtbHJhT3N4TXVucjZCb1pBUVNOakUxTW1Kak56QzBzQkt5WW1hMTBiUHFDZwpyWWFkdllLRG81T3ppNnVidTRlOHA1QVhVTkJiMGNmWHo5OHVJRkNDS1VneE9NUk9DR2hScUdaWU9MTmRSR1JVZ0FFVGsxU0VYMVEwCkUwTk1ySGRjZklKVVlwSzdiRExRMHBUVXRIUW1ob3pNTEgzVGhPd2MzY3pjUExEelRMU1lHUElMbUR3S2k0cExtRXFUSWQ3Z0tHUmkKWUF1elk3SXJpeXV2cUlTSVNWVlZBeTJxQ2ErdERtU3BxMk1KckZkcXlNbjN5MjRFQ25weEp6UWxOUHZGeHBxMDVBWUh4N2Z5SW9VUwpNc0FleU5paUF3Q3FwalN3RnBqcGxnQUFBQ1YwUlZoMFpHRjBaVHBqY21WaGRHVUFNakF4TmkweE1TMHdNbFF3T0RvMU5Ub3dPQzB3Ck56b3dNSWl4dXBvQUFBQWxkRVZZZEdSaGRHVTZiVzlrYVdaNUFESXdNVFl0TVRFdE1ESlVNRGc2TlRVNk1EZ3RNRGM2TURENTdBSW0KQUFBQUFFbEZUa1N1UW1DQyIgLz4KPC9zdmc+Cg==', 11 );
149
+ $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Gmedia Library', 'grand-media' ), __( 'Gmedia Library', 'grand-media' ), 'gmedia_library', 'GrandMedia', [ &$this, 'shell' ] );
150
  if ( current_user_can( 'gmedia_library' ) ) {
151
+ $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Add Media Files', 'grand-media' ), __( 'Add/Import Files', 'grand-media' ), 'gmedia_upload', 'GrandMedia_AddMedia', [ &$this, 'shell' ] );
152
+ $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Tags', 'grand-media' ), __( 'Tags', 'grand-media' ), 'gmedia_tag_manage', 'GrandMedia_Tags', [ &$this, 'shell' ] );
153
+ $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Categories', 'grand-media' ), __( 'Categories', 'grand-media' ), 'gmedia_category_manage', 'GrandMedia_Categories', [ &$this, 'shell' ] );
154
+ $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Albums', 'grand-media' ), __( 'Albums', 'grand-media' ), 'gmedia_album_manage', 'GrandMedia_Albums', [ &$this, 'shell' ] );
155
+ $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Gmedia Galleries', 'grand-media' ), __( 'Galleries', 'grand-media' ), 'gmedia_gallery_manage', 'GrandMedia_Galleries', [ &$this, 'shell' ] );
156
+ $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Modules', 'grand-media' ), __( 'Modules', 'grand-media' ), 'gmedia_gallery_manage', 'GrandMedia_Modules', [ &$this, 'shell' ] );
157
+ $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Gmedia Settings', 'grand-media' ), __( 'Settings', 'grand-media' ), 'manage_options', 'GrandMedia_Settings', [ &$this, 'shell' ] );
158
  //$this->pages[] = add_submenu_page( 'GrandMedia', __( 'iOS Application', 'grand-media' ), __( 'iOS Application', 'grand-media' ), 'gmedia_settings', 'GrandMedia_App', array( &$this, 'shell' ) );
159
+ $this->pages[] = add_submenu_page( 'GrandMedia', __( 'WordPress Media Library', 'grand-media' ), __( 'WP Media Library', 'grand-media' ), 'gmedia_import', 'GrandMedia_WordpressLibrary', [ &$this, 'shell' ] );
160
+ $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Gmedia Logs', 'grand-media' ), __( 'Gmedia Logs', 'grand-media' ), 'manage_options', 'GrandMedia_Logs', [ &$this, 'shell' ] );
161
  //$this->pages[] = add_submenu_page( 'GrandMedia', __( 'Gmedia Support', 'grand-media' ), __( 'Support', 'grand-media' ), 'manage_options', 'GrandMedia_Support', array( &$this, 'shell' ) );
162
  }
163
 
164
  foreach ( $this->pages as $page ) {
165
+ add_action( "load-$page", [ &$this, 'screen_help' ] );
166
  }
167
  }
168
 
176
  $sideLinks = $this->sideLinks();
177
 
178
  // check for upgrade
179
+ if ( get_option( 'gmediaDbVersion' ) !== GMEDIA_DBVERSION ) {
180
+ if ( get_transient( 'gmediaUpgrade' ) || ( isset( $_GET['do_update'] ) && ( 'gmedia' === $_GET['do_update'] ) ) ) {
181
  $sideLinks['grandTitle'] = __( 'Updating GmediaGallery Plugin', 'grand-media' );
182
  $sideLinks['sideLinks'] = '';
183
  $gmProcessor->page = 'GrandMedia_Update';
205
  <div id="gmedia-logo">Gmedia
206
  <small> by CodEasily.com</small>
207
  </div>
208
+ <h2><?php echo esc_html( $sideLinks['grandTitle'] ); ?></h2>
209
  <?php
210
+ if ( ! is_plugin_active( 'woowgallery/woowgallery.php' ) && empty( $gmGallery->options['disable_ads'] ) ) {
211
  ?>
212
+ <div class="promote-woowbox"><a href="https://bit.ly/gm-woowgallery" target="_blank"><img src="<?php echo esc_url( plugins_url( '/grand-media/admin/assets/img/woowbox-promote.png' ) ); ?>" alt="Try WoowGallery plugin"/></a></div>
213
  <?php
214
  }
215
  ?>
277
  $content['sideLinks'] .= "\n" . '<a class="list-group-item list-group-item-premium" target="_blank" href="https://codeasily.com/product/one-site-license/">' . __( 'Get Gmedia Premium', 'grand-media' ) . '</a></li><li>';
278
  }
279
  foreach ( $submenu['GrandMedia'] as $menuKey => $menuItem ) {
280
+ if ( $menuItem[2] === $gmProcessor->page ) {
281
  $iscur = ' active';
282
  $content['grandTitle'] = $menuItem[3];
283
  } else {
284
  $iscur = '';
285
  }
286
  $menuData = '';
287
+ if ( $menuItem[2] === 'GrandMedia_Modules' && gm_user_can( 'module_manage' ) ) {
288
+ if ( ! empty( $gmGallery->options['notify_new_modules'] ) ) {
289
  $menuData .= '<span class="badge badge-success pull-right gm-module-count-' . $gmGallery->options['modules_new'] . '" title="' . __( 'New Modules', 'grand-media' ) . '">' . $gmGallery->options['modules_new'] . '</span>';
290
  }
291
  $menuData .= '<span class="badge badge-error pull-right gm-module-count-' . $gmGallery->options['modules_update'] . '" title="' . __( 'Modules Updates', 'grand-media' ) . '">' . $gmGallery->options['modules_update'] . '</span>';
309
  <div class="notice updated gm-message gmedia-service__message">
310
  <div class="gm-message-content">
311
  <div class="gm-plugin-icon">
312
+ <img src="<?php echo esc_url( plugins_url( '/grand-media/admin/assets/img/icon-128x128.png' ) ); ?>" width="90" height="90">
313
  </div>
314
  <?php printf( __( '<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>.
315
  If you skip this, that\'s okay! <b>Gmedia Gallery</b> will still work just fine.</p>', 'grand-media' ), $current_user->display_name ); ?>
316
  </div>
317
  <div class="gm-message-actions">
318
+ <button class="button button-secondary gm_service_action" data-action="skip" data-nonce="<?php echo esc_attr( $nonce ); ?>"><?php _e( 'Skip', 'grand-media' ); ?></button>
319
+ <button class="button button-primary gm_service_action" data-action="allow" data-nonce="<?php echo esc_attr( $nonce ); ?>"><?php _e( 'Allow &amp; Continue', 'grand-media' ); ?></button>
320
  </div>
321
  <div class="gm-message-plus gm-closed">
322
  <a class="gm-mp-trigger" href="#" onclick="jQuery('.gm-message-plus').toggleClass('gm-closed gm-opened'); return false;"><?php _e( 'What permissions are being granted?', 'grand-media' ); ?></a>
345
  <?php
346
  }
347
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
348
  function controller() {
349
 
350
  global $gmProcessor;
351
  switch ( $gmProcessor->page ) {
352
  case 'GrandMedia_AddMedia':
353
+ include_once dirname( __FILE__ ) . '/pages/addmedia/addmedia.php';
354
  break;
355
  case 'GrandMedia_Albums':
356
  if ( isset( $_GET['edit_term'] ) ) {
357
+ include_once dirname( __FILE__ ) . '/pages/terms/edit-term.php';
358
  } else {
359
+ include_once dirname( __FILE__ ) . '/pages/terms/terms.php';
360
  }
361
  break;
362
  case 'GrandMedia_Categories':
363
  if ( isset( $_GET['edit_term'] ) ) {
364
+ include_once dirname( __FILE__ ) . '/pages/terms/edit-term.php';
365
  } else {
366
+ include_once dirname( __FILE__ ) . '/pages/terms/terms.php';
367
  }
368
  break;
369
  case 'GrandMedia_Tags':
370
+ include_once dirname( __FILE__ ) . '/pages/terms/terms.php';
371
  break;
372
  case 'GrandMedia_Galleries':
373
  if ( isset( $_GET['gallery_module'] ) || isset( $_GET['edit_term'] ) ) {
374
+ include_once dirname( __FILE__ ) . '/pages/galleries/edit-gallery.php';
375
  } else {
376
+ include_once dirname( __FILE__ ) . '/pages/galleries/galleries.php';
377
  }
378
  break;
379
  case 'GrandMedia_Modules':
380
  if ( isset( $_GET['preset_module'] ) || isset( $_GET['preset'] ) ) {
381
+ include_once dirname( __FILE__ ) . '/pages/modules/edit-preset.php';
382
  } else {
383
+ include_once dirname( __FILE__ ) . '/pages/modules/modules.php';
384
  }
385
  break;
386
  case 'GrandMedia_Settings':
387
+ include_once dirname( __FILE__ ) . '/pages/settings/settings.php';
388
  break;
389
  case 'GrandMedia_App':
390
+ include_once dirname( __FILE__ ) . '/app.php';
391
  gmediaApp();
392
  break;
393
  case 'GrandMedia_WordpressLibrary':
394
+ include_once dirname( __FILE__ ) . '/wpmedia.php';
395
  grandWPMedia();
396
  break;
397
  case 'GrandMedia_Logs':
398
+ include_once dirname( __FILE__ ) . '/logs.php';
399
  break;
400
  case 'GrandMedia_Support':
401
+ include_once dirname( __FILE__ ) . '/support.php';
402
  gmediaSupport();
403
  break;
404
  case 'GrandMedia_Update':
405
+ include_once GMEDIA_ABSPATH . 'config/update.php';
406
  gmedia_upgrade_progress_panel();
407
  break;
408
  case 'GrandMedia':
409
+ include_once dirname( __FILE__ ) . '/pages/library/library.php';
410
  break;
411
  default:
412
  do_action( 'gmedia_admin_page-' . $gmProcessor->page );
414
  }
415
  }
416
 
417
+ function admin_footer() {
418
+ $ajax_operations = get_option( 'gmedia_ajax_long_operations' );
419
+ if ( empty( $ajax_operations ) || ! is_array( $ajax_operations ) ) {
420
+ return;
421
+ }
422
+ reset( $ajax_operations );
423
+ $ajax = key( $ajax_operations );
424
+ if ( empty( $ajax ) ) {
425
+ delete_option( 'gmedia_ajax_long_operations' );
426
+
427
+ return;
428
+ }
429
+ $nonce = wp_create_nonce( 'gmedia_ajax_long_operations' );
430
+ ?>
431
+ <script type="text/javascript">
432
+ jQuery(document).ready(function($) {
433
+ var header = $('#gmedia-header');
434
+ 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>');
435
+ gmAjaxLongOperation = function() {
436
+ jQuery.post(ajaxurl, {action: '<?php echo $ajax; ?>', _wpnonce_ajax_long_operations: '<?php echo $nonce; ?>'}, function(r) {
437
+ if (r.data) {
438
+ jQuery('.progress-bar-info', header).width(r.data.progress);
439
+ var indicator = r.data.info ? r.data.info + ' ' + r.data.progress : r.data.progress;
440
+ jQuery('.progress-bar-indicator', header).html(indicator);
441
+
442
+ if (r.data.done) {
443
+ return;
444
+ }
445
+ }
446
+ gmAjaxLongOperation();
447
+ });
448
+ };
449
+ gmAjaxLongOperation();
450
+ });
451
+ </script>
452
+ <?php
453
+ }
454
+
455
  /**
456
  * @param $hook
457
  */
458
  function load_scripts( $hook ) {
459
  global $gmCore, $gmProcessor, $gmGallery;
460
  // no need to go on if it's not a plugin page
461
+ if ( 'admin.php' !== $hook && strpos( $gmCore->_get( 'page' ), 'GrandMedia' ) === false ) {
462
  return;
463
  }
464
 
466
  global $wp_scripts, $wp_styles;
467
  foreach ( $wp_scripts->registered as $handle => $wp_script ) {
468
  if ( ( ( false !== strpos( $wp_script->src, '/plugins/' ) ) || ( false !== strpos( $wp_script->src, '/themes/' ) ) ) && ( false === strpos( $wp_script->src, GMEDIA_FOLDER ) ) ) {
469
+ if ( in_array( $handle, $wp_scripts->queue, true ) ) {
470
  wp_dequeue_script( $handle );
471
  }
472
  wp_deregister_script( $handle );
474
  }
475
  foreach ( $wp_styles->registered as $handle => $wp_style ) {
476
  if ( ( ( false !== strpos( $wp_style->src, '/plugins/' ) ) || ( false !== strpos( $wp_style->src, '/themes/' ) ) ) && ( false === strpos( $wp_style->src, GMEDIA_FOLDER ) ) ) {
477
+ if ( in_array( $handle, $wp_styles->queue, true ) ) {
478
  wp_dequeue_style( $handle );
479
  }
480
  wp_deregister_style( $handle );
485
  wp_enqueue_style( 'gmedia-bootstrap' );
486
  wp_enqueue_script( 'gmedia-bootstrap' );
487
 
488
+ wp_register_script( 'selectize', $gmCore->gmedia_url . '/assets/selectize/selectize.min.js', [ 'jquery' ], '0.12.1' );
489
+ wp_register_style( 'selectize', $gmCore->gmedia_url . '/assets/selectize/selectize.bootstrap3.css', [ 'gmedia-bootstrap' ], '0.12.1', 'screen' );
490
 
491
+ wp_register_style( 'spectrum', $gmCore->gmedia_url . '/assets/spectrum/spectrum.min.css', [], '1.8.0' );
492
+ wp_register_script( 'spectrum', $gmCore->gmedia_url . '/assets/spectrum/spectrum.min.js', [ 'jquery' ], '1.8.0', true );
493
 
494
  if ( isset( $_GET['page'] ) ) {
495
  switch ( $_GET['page'] ) {
496
  case "GrandMedia" :
497
  if ( $gmCore->caps['gmedia_edit_media'] ) {
498
+ if ( $gmCore->_get( 'gmediablank' ) === 'image_editor' ) {
499
+ wp_enqueue_script( 'camanjs', $gmCore->gmedia_url . '/assets/image-editor/camanjs/caman.full.min.js', [], '4.1.2' );
500
 
501
+ wp_enqueue_style( 'nouislider', $gmCore->gmedia_url . '/assets/image-editor/js/jquery.nouislider.css', [ 'gmedia-bootstrap' ], '6.1.0' );
502
+ wp_enqueue_script( 'nouislider', $gmCore->gmedia_url . '/assets/image-editor/js/jquery.nouislider.min.js', [ 'jquery' ], '6.1.0' );
503
 
504
+ wp_enqueue_style( 'gmedia-image-editor', $gmCore->gmedia_url . '/assets/image-editor/style.css', [ 'gmedia-bootstrap' ], '0.9.16', 'screen' );
505
+ wp_enqueue_script( 'gmedia-image-editor', $gmCore->gmedia_url . '/assets/image-editor/image-editor.js', [ 'jquery', 'camanjs' ], '0.9.16' );
506
  break;
507
  }
508
+ if ( $gmProcessor->mode === 'edit' ) {
509
+ wp_enqueue_script( 'alphanum', $gmCore->gmedia_url . '/assets/jq-plugins/jquery.alphanum.js', [ 'jquery' ], '1.0.16' );
510
 
511
  wp_enqueue_script( 'jquery-ui-sortable' );
512
 
513
+ wp_enqueue_script( 'moment', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/moment.min.js', [ 'jquery' ], '2.22.2' );
514
+ wp_enqueue_style( 'datetimepicker', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css', [ 'gmedia-bootstrap' ], '4.17.47' );
515
+ wp_enqueue_script( 'datetimepicker', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js', [
516
  'jquery',
517
  'moment',
518
  'gmedia-bootstrap',
519
+ ], '4.17.47' );
520
  }
521
  }
522
+ wp_enqueue_script( 'wavesurfer', $gmCore->gmedia_url . '/assets/wavesurfer/wavesurfer.min.js', [ 'jquery' ], '1.1.5' );
523
  break;
524
  case "GrandMedia_WordpressLibrary" :
525
  break;
526
  case "GrandMedia_Albums" :
527
  if ( isset( $_GET['edit_term'] ) ) {
528
  if ( $gmCore->caps['gmedia_album_manage'] ) {
529
+ wp_enqueue_style( 'jquery-ui-smoothness', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/smoothness/jquery-ui.min.css', [], '1.10.2', 'screen' );
530
+ wp_enqueue_script( 'jquery-ui-full', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js', [], '1.10.2' );
531
  }
532
 
533
+ wp_enqueue_script( 'moment', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/moment.min.js', [ 'jquery' ], '2.5.1' );
534
+ wp_enqueue_style( 'datetimepicker', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css', [ 'gmedia-bootstrap' ], '2.1.32' );
535
+ wp_enqueue_script( 'datetimepicker', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js', [
536
  'jquery',
537
  'moment',
538
  'gmedia-bootstrap',
539
+ ], '2.1.32' );
540
  }
541
  break;
542
  case "GrandMedia_Categories" :
544
  case "GrandMedia_AddMedia" :
545
  if ( $gmCore->caps['gmedia_upload'] ) {
546
  $tab = $gmCore->_get( 'tab', 'upload' );
547
+ if ( $tab === 'upload' ) {
548
+ wp_enqueue_style( 'jquery-ui-smoothness', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/smoothness/jquery-ui.min.css', [], '1.10.2', 'screen' );
549
+ wp_enqueue_script( 'jquery-ui-full', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js', [], '1.10.2' );
550
 
551
+ wp_enqueue_script( 'gmedia-plupload', $gmCore->gmedia_url . '/assets/plupload/plupload.full.min.js', [ 'jquery', 'jquery-ui-full' ], '2.3.7' );
552
 
553
+ wp_enqueue_style( 'jquery.ui.plupload', $gmCore->gmedia_url . '/assets/plupload/jquery.ui.plupload/css/jquery.ui.plupload.css', [ 'jquery-ui-smoothness' ], '2.3.7', 'screen' );
554
+ wp_enqueue_script( 'jquery.ui.plupload', $gmCore->gmedia_url . '/assets/plupload/jquery.ui.plupload/jquery.ui.plupload.min.js', [
555
  'gmedia-plupload',
556
  'jquery-ui-full',
557
+ ], '2.1.2' );
558
 
559
  }
560
  }
566
  case "GrandMedia_Galleries" :
567
  if ( $gmCore->caps['gmedia_gallery_manage'] && ( isset( $_GET['gallery_module'] ) || isset( $_GET['edit_term'] ) ) ) {
568
 
569
+ wp_enqueue_style( 'jquery-ui-smoothness', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/smoothness/jquery-ui.min.css', [], '1.10.2', 'screen' );
570
  wp_enqueue_script( 'jquery-ui-resizable' );
571
 
572
  wp_enqueue_script( 'jquery-ui-sortable' );
573
 
574
+ wp_enqueue_style( 'jquery.minicolors', $gmCore->gmedia_url . '/assets/minicolors/jquery.minicolors.css', [ 'gmedia-bootstrap' ], '0.9.13' );
575
+ wp_enqueue_script( 'jquery.minicolors', $gmCore->gmedia_url . '/assets/minicolors/jquery.minicolors.js', [ 'jquery' ], '0.9.13' );
576
 
577
  wp_enqueue_style( 'spectrum' );
578
  wp_enqueue_script( 'spectrum' );
581
  case "GrandMedia_Modules" :
582
  if ( isset( $_GET['preset_module'] ) || isset( $_GET['preset'] ) ) {
583
 
584
+ wp_enqueue_style( 'jquery-ui-smoothness', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/smoothness/jquery-ui.min.css', [], '1.10.2', 'screen' );
585
  wp_enqueue_script( 'jquery-ui-resizable' );
586
 
587
  wp_enqueue_script( 'jquery-ui-sortable' );
588
 
589
+ wp_enqueue_style( 'jquery.minicolors', $gmCore->gmedia_url . '/assets/minicolors/jquery.minicolors.css', [ 'gmedia-bootstrap' ], '0.9.13' );
590
+ wp_enqueue_script( 'jquery.minicolors', $gmCore->gmedia_url . '/assets/minicolors/jquery.minicolors.js', [ 'jquery' ], '0.9.13' );
591
 
592
  wp_enqueue_style( 'spectrum' );
593
  wp_enqueue_script( 'spectrum' );
613
  function gutenberg_assets() {
614
  global $gmGallery, $gmDB, $gmCore;
615
 
616
+ wp_enqueue_style( 'gmedia-block-editor', $gmCore->gmedia_url . '/admin/assets/css/gmedia-block.css', [], $gmGallery->version );
617
  wp_register_script(
618
  'gmedia-block-editor',
619
  $gmCore->gmedia_url . '/admin/assets/js/gmedia-block.js',
620
+ [ 'wp-blocks', 'wp-element' ],
621
  $gmGallery->version
622
  );
623
 
626
  $default_module = $default_preset['module'];
627
 
628
  $modules_data = get_gmedia_modules( false );
629
+ $modules = [];
630
+ $modules_options = [];
631
  if ( ! empty( $modules_data['in'] ) ) {
632
  foreach ( $modules_data['in'] as $module_name => $module_data ) {
633
 
634
+ $presets = $gmDB->get_terms( 'gmedia_module', [ 'status' => $module_name ] );
635
+ $option = [];
636
  $option[ $module_name ] = $module_data['title'] . ' - ' . __( 'Default Settings' );
637
  foreach ( $presets as $preset ) {
638
  if ( ! (int) $preset->global && '[' . $module_name . ']' === $preset->name ) {
650
  $option[ $preset->term_id ] = $module_data['title'] . $by_author . ' - ' . $preset_name;
651
  }
652
  }
653
+ $modules_options[ $module_name ] = [ 'title' => $module_data['title'], 'options' => $option ];
654
 
655
+ $modules[ $module_name ] = [
656
  'name' => $module_data['title'],
657
  'screenshot' => $module_data['module_url'] . '/screenshot.png',
658
+ ];
659
  }
660
  }
661
 
662
+ $gm_galleries = [];
663
+ $gm_albums = [];
664
+ $gm_categories = [];
665
+ $gm_tags = [];
666
 
667
  $gm_terms = $gmDB->get_terms( 'gmedia_gallery' );
668
  if ( count( $gm_terms ) ) {
671
  unset( $_term->taxonomy );
672
  $_term->module_name = $gmDB->get_metadata( 'gmedia_term', $_term->term_id, '_module', true );
673
  if ( $_term->global ) {
674
+ $display_name = sprintf( __( 'by %s', 'grand-media' ), esc_html( get_the_author_meta( 'display_name', $_term->global ) ) );
675
  $_term->name .= 'by ' === $display_name ? '' : ' ' . $display_name;
676
  }
677
  if ( $_term->status && 'publish' !== $_term->status ) {
680
  $gm_galleries[ $_term->term_id ] = $_term;
681
  }
682
  }
683
+ $gm_galleries = [
684
+ 0 => [
685
  'term_id' => 0,
686
  'name' => __( ' - select gallery - ', 'grand-media' ),
687
+ ],
688
+ ] + $gm_galleries;
689
 
690
  $gm_terms = $gmDB->get_terms( 'gmedia_album' );
691
  if ( count( $gm_terms ) ) {
700
  $_term->module_name = '';
701
  }
702
  if ( $_term->global ) {
703
+ $display_name = sprintf( __( 'by %s', 'grand-media' ), esc_html( get_the_author_meta( 'display_name', $_term->global ) ) );
704
  $_term->name .= 'by ' === $display_name ? '' : ' ' . $display_name;
705
  }
706
  if ( $_term->status && 'publish' !== $_term->status ) {
710
  $gm_albums[ $_term->term_id ] = $_term;
711
  }
712
  }
713
+ $gm_albums = [
714
+ 0 => [
715
  'term_id' => 0,
716
  'name' => __( ' - select album - ', 'grand-media' ),
717
+ ],
718
+ ] + $gm_albums;
719
 
720
  $gm_terms = $gmDB->get_terms( 'gmedia_category' );
721
  if ( count( $gm_terms ) ) {
728
  $gm_categories[ $_term->term_id ] = $_term;
729
  }
730
  }
731
+ $gm_categories = [
732
+ 0 => [
733
  'term_id' => 0,
734
  'name' => __( ' - select category - ', 'grand-media' ),
735
+ ],
736
+ ] + $gm_categories;
737
 
738
  $gm_terms = $gmDB->get_terms( 'gmedia_tag' );
739
  if ( count( $gm_terms ) ) {
746
  $gm_tags[ $_term->term_id ] = $_term;
747
  }
748
  }
749
+ $gm_tags = [
750
+ 0 => [
751
  'term_id' => 0,
752
  'name' => __( ' - select tag - ', 'grand-media' ),
753
+ ],
754
+ ] + $gm_tags;
755
 
756
+ $data = [
757
  'modules' => $modules,
758
  'default_module' => $default_module,
759
  'modules_options' => $modules_options,
762
  'albums' => $gm_albums,
763
  'categories' => $gm_categories,
764
  'tags' => $gm_tags,
765
+ ];
766
 
767
  wp_localize_script( 'gmedia-block-editor', 'gmedia_data', $data );
768
  wp_enqueue_script( 'gmedia-block-editor' );
773
  $screen_id = explode( 'page_', $screen->id, 2 );
774
  $screen_id = $screen_id[1];
775
 
776
+ $screen->add_help_tab( [
777
  'id' => 'help_' . $screen_id . '_support',
778
  'title' => __( 'Support' ),
779
  'content' => __( '<h4>First steps</h4>
788
  | <a href="https://codeasily.com/portfolio/gmedia-gallery-modules/" target="_blank">' . __( 'Demo', 'grand-media' ) . '</a>
789
  | <a href="https://codeasily.com/product/one-site-license/" target="_blank">' . __( 'Premium', 'grand-media' ) . '</a>
790
  </p>',
791
+ ] );
792
 
793
  switch ( $screen_id ) {
794
  case 'GrandMedia' :
795
  break;
796
  case 'GrandMedia_Settings' :
797
  if ( current_user_can( 'manage_options' ) ) {
798
+ $screen->add_help_tab( [
799
  'id' => 'help_' . $screen_id . '_license',
800
  'title' => __( 'License Key' ),
801
  'content' => sprintf( __( '<h4>Should I buy it, to use plugin?</h4>
804
  <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>
805
  <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>
806
  <h4>I have license key but I can\'t activate it</h4>
807
+ <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>', 'grand-media' ), 'https://wordpress.org/support/plugin/grand-media/', 'gmediafolder@gmail.com' )
808
  . '<div><a class="btn btn-default" href="' . admin_url( 'admin.php?page=' . $screen_id . '&license_activate=manual' ) . '">' . __( 'Manual Activation', 'grand-media' ) . '</a></div>',
809
+ ] );
810
  }
811
  break;
812
  case 'GrandMedia_App' :
813
  $gm_options = get_option( 'gmediaOptions' );
814
  $nonce = wp_create_nonce( 'GmediaService' );
815
  if ( current_user_can( 'manage_options' ) && (int) $gm_options['mobile_app'] ) {
816
+ $screen->add_help_tab( [
817
  'id' => 'help_' . $screen_id . '_optout',
818
  'title' => __( 'Opt Out' ),
819
  'content' => __( '<h4>We appreciate your help in making the plugin better by letting us track some usage data.</h4>
820
  <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>
821
+ <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>', 'grand-media' )
 
822
  . '<p><button class="button button-default gm_service_action" data-action="app_deactivate" data-nonce="' . $nonce . '">' . __( 'Opt Out', 'grand-media' ) . '</button><span class="spinner" style="float: none;"></span></p>'
823
  . '<div style="display:none;">Test:
824
  <button type="button" data-action="app_updateinfo" data-nonce="' . $nonce . '" class="btn btn-sm btn-primary gm_service_action">Update</button>
827
  <button type="button" data-action="app_uninstallplugin" data-nonce="' . $nonce . '" class="btn btn-sm btn-primary gm_service_action">Uninstall Plugin</button>
828
  </div>
829
  ',
830
+ ] );
831
  }
832
  break;
833
  }
841
  */
842
  function screen_settings( $current, $screen ) {
843
  global $gmProcessor, $gmCore;
844
+ if ( in_array( $screen->id, $this->pages, true ) ) {
845
 
846
  $gm_screen_options = $gmProcessor->user_options;
847
 
883
  </select> <span>' . __( 'sort order', 'grand-media' ) . '</span>
884
  </div>
885
  ';
886
+ if ( 'edit' === $gmCore->_get( 'mode' ) ) {
887
  $settings .= '
888
  <div class="form-group">
889
  <select name="gm_screen_options[library_edit_quicktags]" class="form-control input-sm">
899
  break;
900
  case 'GrandMedia_AddMedia' :
901
  $tab = $gmCore->_get( 'tab', 'upload' );
902
+ if ( 'upload' === $tab ) {
903
+ $html4_hide = ( 'html4' === $gm_screen_options['uploader_runtime'] ) ? ' hide' : '';
904
  $settings = '
905
  <div class="form-inline pull-left">
906
  <div id="uploader_runtime" class="form-group"><span>' . __( 'Uploader runtime:', 'grand-media' ) . ' </span>
1106
  */
1107
  function screen_settings_save( $status, $option, $value ) {
1108
  global $user_ID;
1109
+ if ( 'gm_screen_options' === $option ) {
1110
  /*
1111
  global $gmGallery;
1112
  foreach ( $_POST['gm_screen_options'] as $key => $val ) {
1116
  */
1117
  $gm_screen_options = get_user_meta( $user_ID, 'gm_screen_options', true );
1118
  if ( ! is_array( $gm_screen_options ) ) {
1119
+ $gm_screen_options = [];
1120
  }
1121
  $value = array_merge( $gm_screen_options, $_POST['gm_screen_options'] );
1122
 
1129
  }
1130
 
1131
  global $gmAdmin;
1132
+ // Start GmediaAdmin.
1133
  $gmAdmin = new GmediaAdmin();
admin/ajax.php CHANGED
@@ -1,2493 +1,2504 @@
1
- <?php
2
- add_action('wp_ajax_gmedia_update_data', 'gmedia_update_data');
3
- function gmedia_update_data(){
4
- global $gmDB, $gmCore;
5
- check_ajax_referer("GmediaGallery");
6
- if( !current_user_can('gmedia_edit_media')){
7
- die('-1');
8
- }
9
-
10
- $data = $gmCore->_post('data');
11
-
12
- wp_parse_str($data, $gmedia);
13
-
14
- if( !empty($gmedia['ID'])){
15
- $item = $gmDB->get_gmedia($gmedia['ID']);
16
- if((int) $item->author != get_current_user_id()){
17
- if( !current_user_can('gmedia_edit_others_media')){
18
- die('-2');
19
- }
20
- }
21
-
22
- $gmedia['modified'] = current_time('mysql');
23
- $gmedia['mime_type'] = $item->mime_type;
24
- $gmedia['gmuid'] = $item->gmuid;
25
- if( !current_user_can('gmedia_delete_others_media')){
26
- $gmedia['author'] = $item->author;
27
- }
28
-
29
- $gmuid = pathinfo($item->gmuid);
30
-
31
- $gmedia['filename'] = preg_replace('/[^a-z0-9_\.-]+/i', '_', $gmedia['filename']);
32
- if(($gmedia['filename'] != $gmuid['filename']) && (current_user_can('gmedia_delete_others_media') || ((int) $item->author == get_current_user_id()))){
33
- $fileinfo = $gmCore->fileinfo($gmedia['filename'] . '.' . $gmuid['extension']);
34
- if(false !== $fileinfo){
35
- if('image' == $fileinfo['dirname'] && file_is_displayable_image($fileinfo['dirpath'] . '/' . $item->gmuid)){
36
- if(is_file($fileinfo['dirpath_original'] . '/' . $item->gmuid)){
37
- @rename($fileinfo['dirpath_original'] . '/' . $item->gmuid, $fileinfo['filepath_original']);
38
- }
39
- @rename($fileinfo['dirpath_thumb'] . '/' . $item->gmuid, $fileinfo['filepath_thumb']);
40
- }
41
- if(@rename($fileinfo['dirpath'] . '/' . $item->gmuid, $fileinfo['filepath'])){
42
- $gmedia['gmuid'] = $fileinfo['basename'];
43
- }
44
- }
45
- }
46
- if( !current_user_can('gmedia_terms')){
47
- unset($gmedia['terms']);
48
- }
49
-
50
- $id = $gmDB->insert_gmedia($gmedia);
51
- if( !is_wp_error($id)){
52
- // Meta Stuff
53
- if(isset($gmedia['meta']) && is_array($gmedia['meta'])){
54
- $meta_error = array();
55
- foreach($gmedia['meta'] as $key => $value){
56
- if($gmCore->is_digit($key)){
57
- $mid = (int) $key;
58
- //$value = wp_unslash( $value );
59
- if( !($meta = $gmDB->get_metadata_by_mid('gmedia', $mid))){
60
- $meta_error[] = array(
61
- 'error' => 'no_meta',
62
- 'message' => __('No record in DataBase.', 'grand-media'),
63
- 'meta_id' => $mid,
64
- 'meta_key' => $meta->meta_key
65
- );
66
- continue;
67
- }
68
- if('' == trim($value)){
69
- $meta_error[] = array(
70
- 'error' => 'empty_value',
71
- 'message' => __('Please provide a custom field value.', 'grand-media'),
72
- 'meta_id' => $mid,
73
- 'meta_key' => $meta->meta_key,
74
- 'meta_value' => $meta->meta_value
75
- );
76
- continue;
77
- }
78
-
79
- if($meta->meta_value != $value){
80
- if( !($u = $gmDB->update_metadata_by_mid('gmedia', $mid, $value))){
81
- $meta_error[] = array(
82
- 'error' => 'meta_update',
83
- 'message' => __('Something goes wrong.', 'grand-media'),
84
- 'meta_id' => $mid,
85
- 'meta_key' => $meta->meta_key,
86
- 'meta_value' => $meta->meta_value
87
- );
88
- }
89
- }
90
- } elseif('_' == $key[0]){
91
- if('_cover' == $key){
92
- $value = ltrim($value, '#');
93
- } elseif('_gps' == $key){
94
- if($value){
95
- $latlng = explode(',', $value);
96
- $value = array('lat' => trim($latlng[0]), 'lng' => trim($latlng[1]));
97
- }
98
- }
99
- $value = apply_filters('gmedia_protected_meta_value', $value, $key, $id);
100
- $gmDB->update_metadata('gmedia', $id, $key, $value);
101
- }
102
- }
103
- }
104
- $result = $gmDB->get_gmedia($id);
105
- } else{
106
- $result = $gmDB->get_gmedia($id);
107
- }
108
-
109
- gmedia_item_more_data($result);
110
- if('image' != $result->type){
111
- include_once(GMEDIA_ABSPATH . 'admin/pages/library/functions.php');
112
- $result->thumbnail = gmedia_item_thumbnail($result);
113
- }
114
-
115
- if(current_user_can('gmedia_terms')){
116
- if( !empty($gmedia['terms']['gmedia_album'])){
117
- if(isset($gmedia['gmedia_album_order'])){
118
- $album = $gmDB->get_the_gmedia_terms($id, 'gmedia_album');
119
- if($album){
120
- $album = reset($album);
121
- if((int) $gmedia['gmedia_album_order'] != (int) $album->gmedia_order){
122
- $gmDB->update_term_sortorder($album->term_id, array($id => (int) $gmedia['gmedia_album_order']));
123
- $result->gmedia_album_order = (int) $gmedia['gmedia_album_order'];
124
- }
125
- }
126
- }
127
- $alb_id = $gmedia['terms']['gmedia_album'];
128
- $alb = $gmDB->get_term($alb_id, 'gmedia_album');
129
- $result->album_status = $alb? $alb->status : 'none';
130
- } else{
131
- $result->album_status = 'none';
132
- }
133
- }
134
- if( !empty($meta_error)){
135
- $result->meta_error = $meta_error;
136
- }
137
- gmedia_delete_transients( 'gm_cache' );
138
-
139
- header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
140
- echo json_encode($result);
141
- }
142
-
143
- die();
144
- }
145
-
146
- add_action('wp_ajax_gmedit_save', 'gmedit_save');
147
- function gmedit_save(){
148
- global $gmDB, $gmCore, $gmGallery;
149
- check_ajax_referer('gmedia_edit', '_wpnonce_edit');
150
- if( !current_user_can('gmedia_edit_media')){
151
- die('-1');
152
- }
153
-
154
- $gmedia = array();
155
- $fail = '';
156
- $success = '';
157
- $gmid = $gmCore->_post('id');
158
- $image = $gmCore->_post('image');
159
- $applyto = $gmCore->_post('applyto', 'web_thumb');
160
-
161
- $item = $gmDB->get_gmedia($gmid);
162
- if( !empty($item)){
163
- if((int) $item->author != get_current_user_id()){
164
- if( !current_user_can('gmedia_edit_others_media')){
165
- die('-2');
166
- }
167
- }
168
- $meta = $gmDB->get_metadata('gmedia', $item->ID);
169
- $metadata = $meta['_metadata'][0];
170
- $gmedia['ID'] = $gmid;
171
- $gmedia['date'] = $item->date;
172
- $gmedia['modified'] = current_time('mysql');
173
- $gmedia['author'] = $item->author;
174
-
175
- $thumbimg = $gmGallery->options['thumb'];
176
-
177
- $image = $gmCore->process_gmedit_image($image);
178
-
179
- $fileinfo = $gmCore->fileinfo($item->gmuid, false);
180
-
181
- $size = @getimagesize($fileinfo['filepath']);
182
-
183
- do {
184
- $extensions = array('1' => 'GIF', '2' => 'JPG', '3' => 'PNG', '6' => 'BMP');
185
- if(function_exists('memory_get_usage')){
186
- switch($extensions[ $size[2] ]){
187
- case 'GIF':
188
- $CHANNEL = 1;
189
- break;
190
- case 'JPG':
191
- $CHANNEL = $size['channels'];
192
- break;
193
- case 'PNG':
194
- $CHANNEL = 3;
195
- break;
196
- case 'BMP':
197
- default:
198
- $CHANNEL = 6;
199
- break;
200
- }
201
- $MB = 1048576; // number of bytes in 1M
202
- $K64 = 65536; // number of bytes in 64K
203
- $TWEAKFACTOR = 1.8; // Or whatever works for you
204
- $memoryNeeded = round(($size[0] * $size[1] * $size['bits'] * $CHANNEL / 8 + $K64) * $TWEAKFACTOR);
205
- $memoryNeeded = memory_get_usage() + $memoryNeeded;
206
- $current_limit = @ini_get('memory_limit');
207
- $current_limit_int = intval($current_limit);
208
- if(false !== strpos($current_limit, 'M')){
209
- $current_limit_int *= $MB;
210
- }
211
- if(false !== strpos($current_limit, 'G')){
212
- $current_limit_int *= 1024;
213
- }
214
-
215
- if(- 1 != $current_limit && $memoryNeeded > $current_limit_int){
216
- $newLimit = $current_limit_int / $MB + ceil(($memoryNeeded - $current_limit_int) / $MB);
217
- if($newLimit < 256){
218
- $newLimit = 256;
219
- }
220
- @ini_set('memory_limit', $newLimit . 'M');
221
- }
222
- }
223
-
224
- $no_original = false;
225
- if('thumb' == $applyto){
226
- $editfile = $fileinfo['filepath_thumb'];
227
- } else{
228
- $editfile = $fileinfo['filepath'];
229
- if(('JPG' == $extensions[ $size[2] ]) && !is_file($fileinfo['filepath_original'])){
230
- $no_original = true;
231
- @copy($editfile, $fileinfo['filepath_original']);
232
- }
233
- }
234
- if( !@file_put_contents($editfile, $image['data'])){
235
- $fail = $fileinfo['basename'] . ": " . __('Can\'t write to file. Permission denied', 'grand-media');
236
- break;
237
- }
238
-
239
- $modified = isset($meta['_modified'][0])? (intval($meta['_modified'][0]) + 1) : 1;
240
- $gmDB->update_metadata($meta_type = 'gmedia', $item->ID, $meta_key = '_modified', $modified);
241
-
242
- // Web-image
243
- if('thumb' !== $applyto){
244
- if('JPG' == $extensions[ $size[2] ]){
245
- $gmCore->copy_exif($fileinfo['filepath_original'], $fileinfo['filepath']);
246
- if($no_original){
247
- @unlink($fileinfo['filepath_original']);
248
- }
249
- }
250
- }
251
- // Thumbnail
252
- if('web_thumb' == $applyto){
253
- $size_ratio = $size[0] / $size[1];
254
- $thumbimg['resize'] = (((1 >= $size_ratio) && ($thumbimg['width'] > $size[0])) || ((1 <= $size_ratio) && ($thumbimg['height'] > $size[1])))? false : true;
255
- if($thumbimg['resize']){
256
- $editor = wp_get_image_editor($editfile);
257
- if(is_wp_error($editor)){
258
- $fail = $fileinfo['basename'] . " (wp_get_image_editor): " . $editor->get_error_message();
259
- break;
260
- }
261
-
262
- $editor->set_quality($thumbimg['quality']);
263
- $ed_size = $editor->get_size();
264
- $ed_ratio = $ed_size['width'] / $ed_size['height'];
265
- if(1 > $ed_ratio){
266
- $resized = $editor->resize($thumbimg['width'], 0, $thumbimg['crop']);
267
- } else{
268
- $resized = $editor->resize(0, $thumbimg['height'], $thumbimg['crop']);
269
- }
270
- if(is_wp_error($resized)){
271
- $fail = $fileinfo['basename'] . " (" . $resized->get_error_code() . " | editor->resize->thumb({$thumbimg['width']}, {$thumbimg['height']}, {$thumbimg['crop']})) applyto-{$applyto}: " . $resized->get_error_message();
272
- break;
273
- }
274
-
275
- $thumbis = false;
276
- if(is_file($fileinfo['filepath_thumb'])){
277
- $thumbis = true;
278
- rename($fileinfo['filepath_thumb'], $fileinfo['filepath_thumb'] . '.tmp');
279
- }
280
- $saved = $editor->save($fileinfo['filepath_thumb']);
281
- if(is_wp_error($saved)){
282
- if($thumbis){
283
- rename($fileinfo['filepath_thumb'] . '.tmp', $fileinfo['filepath_thumb']);
284
- }
285
- $fail = $fileinfo['basename'] . " (" . $saved->get_error_code() . " | editor->save->thumb): " . $saved->get_error_message();
286
- break;
287
- }
288
-
289
- } else{
290
- @copy($fileinfo['filepath'], $fileinfo['filepath_thumb']);
291
- }
292
- }
293
-
294
-
295
- $id = $gmDB->insert_gmedia($gmedia);
296
-
297
- $new_metadata = $gmDB->generate_gmedia_metadata($id, $fileinfo);
298
- $metadata['web'] = $new_metadata['web'];
299
- $metadata['original'] = $new_metadata['original'];
300
- $metadata['thumb'] = $new_metadata['thumb'];
301
-
302
- $gmDB->update_metadata($meta_type = 'gmedia', $id, $meta_key = '_metadata', $metadata);
303
-
304
- $success = sprintf(__('Image "%d" updated', 'grand-media'), $id);
305
- } while(0);
306
-
307
- if(empty($fail)){
308
- $out = array('msg' => $gmCore->alert('info', $success), 'modified' => $gmedia['modified']);
309
- } else{
310
- $out = array('error' => $gmCore->alert('danger', $fail));
311
- }
312
-
313
- header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
314
- echo json_encode($out);
315
- }
316
-
317
- die();
318
- }
319
-
320
- add_action('wp_ajax_gmedit_restore', 'gmedit_restore');
321
- function gmedit_restore(){
322
- global $gmCore;
323
- check_ajax_referer('gmedia_edit', '_wpnonce_edit');
324
- if( !current_user_can('gmedia_edit_media')){
325
- die('-1');
326
- }
327
-
328
- $gmid = $gmCore->_post('id');
329
- $out = $gmCore->recreate_images_from_original($gmid);
330
-
331
- header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
332
- echo json_encode($out);
333
-
334
- die();
335
- }
336
-
337
- add_action('wp_ajax_gmedia_get_modal', 'gmedia_get_modal');
338
- function gmedia_get_modal(){
339
- global $gmDB, $gmCore, $gmGallery;
340
- check_ajax_referer("GmediaGallery");
341
- $user_ID = get_current_user_id();
342
- $button_class = 'btn-primary';
343
- $gm_terms = array();
344
- $modal = $gmCore->_post('modal');
345
- $ckey = $gmCore->_post('ckey');
346
- switch($modal){
347
- case 'quick_gallery':
348
- if( !current_user_can('gmedia_gallery_manage')){
349
- die('-1');
350
- }
351
- //$ckey = "gmedia_library";
352
- $modal_title = __('Quick Gallery from selected items', 'grand-media');
353
- $modal_button = __('Create Quick Gallery', 'grand-media');
354
- break;
355
- case 'quick_gallery_stack':
356
- if( !current_user_can('gmedia_gallery_manage')){
357
- die('-1');
358
- }
359
- //$ckey = "gmedia_{$user_ID}_libstack";
360
- $modal_title = __('Quick Gallery from Stack', 'grand-media');
361
- $modal_button = __('Create Quick Gallery', 'grand-media');
362
- break;
363
- case 'exclude_categories':
364
- case 'filter_categories':
365
- $modal_title = __('Show Images from Categories', 'grand-media');
366
- $modal_button = __('Show Selected', 'grand-media');
367
- break;
368
- case 'assign_category':
369
- if( !current_user_can('gmedia_terms')){
370
- die('-1');
371
- }
372
- $modal_title = __('Assign Category for Selected Images', 'grand-media');
373
- $modal_button = __('Assign Category', 'grand-media');
374
- break;
375
- case 'unassign_category':
376
- if( !current_user_can('gmedia_terms')){
377
- die('-1');
378
- }
379
- $button_class = 'btn-danger';
380
- $modal_title = __('Unassign Categories from Selected Items', 'grand-media');
381
- $modal_button = __('Unassign Categories', 'grand-media');
382
- break;
383
- case 'exclude_albums':
384
- case 'filter_albums':
385
- $modal_title = __('Filter Albums', 'grand-media');
386
- $modal_button = __('Show Selected', 'grand-media');
387
- break;
388
- case 'assign_album':
389
- if( !current_user_can('gmedia_terms')){
390
- die('-1');
391
- }
392
- $modal_title = __('Assign Album for Selected Items', 'grand-media');
393
- $modal_button = __('Assign Album', 'grand-media');
394
- break;
395
- case 'exclude_tags':
396
- case 'filter_tags':
397
- $modal_title = __('Filter by Tags', 'grand-media');
398
- $modal_button = __('Show Selected', 'grand-media');
399
- break;
400
- case 'add_tags':
401
- if( !current_user_can('gmedia_terms')){
402
- die('-1');
403
- }
404
- $modal_title = __('Add Tags to Selected Items', 'grand-media');
405
- $modal_button = __('Add Tags', 'grand-media');
406
- break;
407
- case 'delete_tags':
408
- if( !current_user_can('gmedia_terms')){
409
- die('-1');
410
- }
411
- $button_class = 'btn-danger';
412
- $modal_title = __('Delete Tags from Selected Items', 'grand-media');
413
- $modal_button = __('Delete Tags', 'grand-media');
414
- break;
415
- case 'custom_filter':
416
- $modal_title = __('Custom Filters', 'grand-media');
417
- $modal_button = __('Show Selected', 'grand-media');
418
- break;
419
- case 'filter_author':
420
- $modal_title = __('Filter by Author', 'grand-media');
421
- if($gmCore->caps['gmedia_show_others_media']){
422
- $modal_button = __('Show Selected', 'grand-media');
423
- } else{
424
- $modal_button = false;
425
- }
426
- break;
427
- case 'select_author':
428
- $modal_title = __('Select Author', 'grand-media');
429
- if($gmCore->caps['gmedia_show_others_media']){
430
- $modal_button = __('Select', 'grand-media');
431
- } else{
432
- $modal_button = false;
433
- }
434
- break;
435
- case 'batch_edit':
436
- if( !current_user_can('gmedia_edit_media')){
437
- die('-1');
438
- }
439
- $modal_title = __('Batch Edit', 'grand-media');
440
- $modal_button = __('Batch Save', 'grand-media');
441
- break;
442
- default:
443
- $modal_title = ' ';
444
- $modal_button = false;
445
- break;
446
- }
447
-
448
- $form_action = !empty($_SERVER['HTTP_REFERER'])? $gmCore->get_admin_url(array(), array(), $_SERVER['HTTP_REFERER']) : '';
449
- ?>
450
- <form class="modal-content" id="ajax-modal-form" autocomplete="off" method="post" action="<?php echo $form_action; ?>">
451
- <div class="modal-header">
452
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
453
- <h4 class="modal-title"><?php echo $modal_title; ?></h4>
454
- </div>
455
- <div class="modal-body">
456
- <?php
457
- switch($modal){
458
- case 'quick_gallery':
459
- case 'quick_gallery_stack':
460
- if( !empty($ckey)){
461
- $selected_in_library = isset($_COOKIE[ $ckey ])? str_replace('.', ',', $_COOKIE[ $ckey ]) : '';
462
- }
463
- if(empty($selected_in_library)){
464
- _e('No selected Gmedia. Select at least one item in library.', 'grand-media');
465
- break;
466
- }
467
- $gmedia_modules = get_gmedia_modules(false);
468
- ?>
469
- <div class="form-group">
470
- <label><?php _e('Gallery Name', 'grand-media'); ?></label>
471
- <input type="text" class="form-control input-sm" name="gallery[name]" placeholder="<?php esc_attr_e(__('Gallery Name', 'grand-media')); ?>" value="" required="required"/>
472
- </div>
473
- <div class="form-group">
474
- <label><?php _e('Modue', 'grand-media'); ?></label>
475
- <select class="form-control input-sm" name="gallery[module]">
476
- <?php foreach($gmedia_modules['in'] as $mfold => $module){
477
- echo '<optgroup label="' . esc_attr($module['title']) . '">';
478
- $presets = $gmDB->get_terms('gmedia_module', array('status' => $mfold));
479
- $selected = selected($gmGallery->options['default_gmedia_module'], esc_attr($mfold), false);
480
- $option = array();
481
- $option[] = '<option ' . $selected . ' value="' . esc_attr($mfold) . '">' . $module['title'] . ' - ' . __('Default Settings') . '</option>';
482
- foreach($presets as $preset){
483
- if( !(int) $preset->global && '[' . $mfold . ']' === $preset->name){
484
- continue;
485
- }
486
- $selected = selected($gmGallery->options['default_gmedia_module'], $preset->term_id, false);
487
- $by_author = '';
488
- if((int) $preset->global){
489
- $by_author = ' [' . get_the_author_meta('display_name', $preset->global) . ']';
490
- }
491
- if('[' . $mfold . ']' === $preset->name){
492
- $option[] = '<option ' . $selected . ' value="' . $preset->term_id . '">' . $module['title'] . $by_author . ' - ' . __('Default Settings') . '</option>';
493
- } else{
494
- $preset_name = str_replace('[' . $mfold . '] ', '', $preset->name);
495
- $option[] = '<option ' . $selected . ' value="' . $preset->term_id . '">' . $module['title'] . $by_author . ' - ' . $preset_name . '</option>';
496
- }
497
- }
498
- echo implode('', $option);
499
- echo '</optgroup>';
500
- } ?>
501
- </select>
502
- </div>
503
- <div class="form-group">
504
- <label><?php _e('Selected IDs', 'grand-media'); ?></label>
505
- <input type="text" name="gallery[query][gmedia__in]" class="form-control input-sm" value="<?php echo $selected_in_library; ?>" required="required"/>
506
- </div>
507
- <?php
508
- break;
509
- case 'exclude_albums':
510
- case 'filter_albums':
511
- if($gmCore->caps['gmedia_show_others_media']){
512
- $args = array();
513
- } else{
514
- $args = array(
515
- 'global' => array(0, $user_ID),
516
- 'orderby' => 'global_desc_name'
517
- );
518
- }
519
- $gm_terms = $gmDB->get_terms('gmedia_album', $args);
520
- ?>
521
- <div class="checkbox"><label><input type="checkbox" name="alb[]" value="0"> <?php _e('No Album', 'grand-media'); ?></label></div>
522
- <hr/>
523
- <?php if(count($gm_terms)){
524
- foreach($gm_terms as $term){
525
- $author_name = '';
526
- if($term->global){
527
- if($gmCore->caps['gmedia_show_others_media']){
528
- $author_name .= sprintf(__('by %s', 'grand-media'), get_the_author_meta('display_name', $term->global));
529
- }
530
- } else{
531
- $author_name .= '(' . __('shared', 'grand-media') . ')';
532
- }
533
- if('publish' != $term->status){
534
- $author_name .= ' [' . $term->status . ']';
535
- }
536
- if($author_name){
537
- $author_name = " <small>{$author_name}</small>";
538
- }
539
- ?>
540
- <div class="checkbox">
541
- <label><input type="checkbox" name="alb[]" value="<?php echo $term->term_id; ?>"> <?php echo esc_html($term->name) . $author_name; ?></label>
542
- <span class="badge pull-right"><?php echo $term->count; ?></span>
543
- </div>
544
- <?php
545
- }
546
- } else{
547
- $modal_button = false;
548
- }
549
- break;
550
- case 'assign_album':
551
- if($gmCore->caps['gmedia_edit_others_media']){
552
- $args = array();
553
- } else{
554
- $args = array(
555
- 'global' => array(0, $user_ID),
556
- 'orderby' => 'global_desc_name'
557
- );
558
- }
559
- $gm_terms = $gmDB->get_terms('gmedia_album', $args);
560
-
561
- $terms_album = '';
562
- if(count($gm_terms)){
563
- foreach($gm_terms as $term){
564
- $author_name = '';
565
- if($term->global){
566
- if($gmCore->caps['gmedia_edit_others_media']){
567
- $author_name .= ' &nbsp; ' . sprintf(__('by %s', 'grand-media'), get_the_author_meta('display_name', $term->global));
568
- }
569
- } else{
570
- $author_name .= ' &nbsp; (' . __('shared', 'grand-media') . ')';
571
- }
572
- if('publish' != $term->status){
573
- $author_name .= ' [' . $term->status . ']';
574
- }
575
- $terms_album .= '<option value="' . $term->term_id . '" data-count="' . $term->count . '" data-name="' . esc_html($term->name) . '" data-meta="' . $author_name . '">' . esc_html($term->name) . $author_name . '</option>' . "\n";
576
- }
577
- }
578
- ?>
579
- <div class="form-group">
580
- <label><?php _e('Move to Album', 'grand-media'); ?> </label>
581
- <select id="combobox_gmedia_album" name="alb" class="form-control" placeholder="<?php _e('Album Name...', 'grand-media'); ?>">
582
- <option></option>
583
- <option value="0"><?php _e('No Album', 'grand-media'); ?></option>
584
- <?php echo $terms_album; ?>
585
- </select>
586
- <small class="help-block" style="margin-top:0;"><?php _e('Choose "No Album" to delete albums from selected items', 'grand-media'); ?></small>
587
- </div>
588
- <div class="form-group">
589
- <div class="checkbox">
590
- <label><input type="checkbox" name="status_global" value="1" checked> <?php _e('Make status of selected items be the same as Album status', 'grand-media'); ?>
591
- </label></div>
592
- </div>
593
- <script type="text/javascript">
594
- jQuery(function($){
595
- var albums = $('#combobox_gmedia_album');
596
- var albums_data = $('option', albums);
597
- //noinspection JSDuplicatedDeclaration
598
- albums.selectize({
599
- <?php if($gmCore->caps['gmedia_album_manage']){ ?>
600
- create: function(input){
601
- return {
602
- value: input,
603
- text: input
604
- }
605
- },
606
- createOnBlur: true,
607
- <?php } else{ ?>
608
- create: false,
609
- <?php } ?>
610
- persist: false,
611
- render: {
612
- item: function(item, escape){
613
- if(0 === (parseInt(item.value, 10) || 0)){
614
- return '<div>' + escape(item.text) + '</div>';
615
- }
616
- if(item.$order){
617
- var data = $(albums_data[item.$order]).data();
618
- return '<div>' + escape(data.name) + ' <small>' + escape(data.meta) + '</small></div>';
619
- }
620
- },
621
- option: function(item, escape){
622
- if(0 === (parseInt(item.value) || 0)){
623
- return '<div>' + escape(item.text) + '</div>';
624
- }
625
- if(item.$order){
626
- var data = $(albums_data[item.$order]).data();
627
- return '<div>' + escape(data.name) + ' <small>' + escape(data.meta) + '</small>' + ' <span class="badge pull-right">' + escape(data.count) + '</span></div>';
628
- }
629
- }
630
- }
631
-
632
- });
633
- });
634
- </script>
635
- <?php
636
- break;
637
- case 'exclude_categories':
638
- case 'filter_categories':
639
- $gm_terms = $gmDB->get_terms('gmedia_category');
640
- ?>
641
- <div class="checkbox"><label><input type="checkbox" name="cat[]" value="0"> <?php _e('Uncategorized', 'grand-media'); ?></label></div>
642
- <?php
643
- if(count($gm_terms)){
644
- foreach($gm_terms as $term){
645
- if($term->count){
646
- ?>
647
- <div class="checkbox">
648
- <label><input type="checkbox" name="cat[]" value="<?php echo $term->term_id; ?>"> <?php echo esc_html($term->name); ?></label>
649
- <span class="badge pull-right"><?php echo $term->count; ?></span>
650
- </div>
651
- <?php
652
- }
653
- }
654
- }
655
- break;
656
- case 'assign_category':
657
- $gm_terms = $gmDB->get_terms('gmedia_category', array('fields' => 'names_count'));
658
- $gm_terms = array_values($gm_terms);
659
- ?>
660
- <div class="form-group">
661
- <input id="combobox_gmedia_category" name="cat_names" class="form-control input-sm" value="" placeholder="<?php _e('Add to Categories...', 'grand-media'); ?>"/>
662
- </div>
663
- <script type="text/javascript">
664
- jQuery(function($){
665
- var gm_terms = <?php echo json_encode($gm_terms); ?>;
666
- //noinspection JSUnusedAssignment
667
- var items = gm_terms.map(function(x){
668
- //noinspection JSUnresolvedVariable
669
- return {id: x.term_id, name: x.name, count: x.count};
670
- });
671
- //noinspection JSDuplicatedDeclaration
672
- $('#combobox_gmedia_category').selectize({
673
- delimiter: ',',
674
- maxItems: null,
675
- openOnFocus: true,
676
- labelField: 'name',
677
- hideSelected: true,
678
- options: items,
679
- searchField: ['name'],
680
- valueField: 'name',
681
- persist: false,
682
- <?php if($gmCore->caps['gmedia_category_manage']){ ?>
683
- createOnBlur: true,
684
- create: function(input){
685
- return {
686
- name: input
687
- }
688
- },
689
- <?php } else{ ?>
690
- create: false,
691
- <?php } ?>
692
- render: {
693
- item: function(item, escape){
694
- return '<div>' + escape(item.name) + '</div>';
695
- },
696
- option: function(item, escape){
697
- return '<div>' + escape(item.name) + ' <span class="badge">' + escape(item.count) + '</span></div>';
698
- }
699
- }
700
- });
701
- });
702
- </script>
703
- <?php
704
- break;
705
- case 'unassign_category':
706
- // get selected items in Gmedia Library
707
- $selected_items = !empty($ckey)? array_filter(explode('.', $_COOKIE[ $ckey ]), 'is_numeric') : false;
708
- if( !empty($selected_items)){
709
- $gm_terms = $gmDB->get_gmedia_terms($selected_items, 'gmedia_category');
710
- }
711
- if(count($gm_terms)){
712
- foreach($gm_terms
713
-
714
- as $term){
715
- ?>
716
- <div class="checkbox">
717
- <label><input type="checkbox" name="category_id[]" value="<?php echo $term->term_id; ?>"> <?php echo esc_html($term->name); ?></label>
718
- <span class="badge pull-right"><?php echo $term->count; ?></span>
719
- </div>
720
- <?php
721
- }
722
- } else{
723
- $modal_button = false; ?>
724
- <p class="noterms"><?php _e('No categories', 'grand-media'); ?></p>
725
- <?php
726
- }
727
- break;
728
- case 'exclude_tags':
729
- case 'filter_tags':
730
- $gm_terms = $gmDB->get_terms('gmedia_tag', array('fields' => 'names_count'));
731
- $gm_terms = array_values($gm_terms);
732
- if(count($gm_terms)){
733
- ?>
734
- <div class="form-group">
735
- <input id="combobox_gmedia_tag" name="tag_ids" class="form-control input-sm" value="" placeholder="<?php _e('Filter Tags...', 'grand-media'); ?>"/></div>
736
- <script type="text/javascript">
737
- jQuery(function($){
738
- var gm_terms = <?php echo json_encode($gm_terms); ?>;
739
- //noinspection JSUnusedAssignment
740
- var items = gm_terms.map(function(x){
741
- //noinspection JSUnresolvedVariable
742
- return {id: x.term_id, name: x.name, count: x.count};
743
- });
744
- $('#combobox_gmedia_tag').selectize({
745
- delimiter: ',',
746
- maxItems: null,
747
- openOnFocus: true,
748
- labelField: 'name',
749
- hideSelected: true,
750
- options: items,
751
- searchField: ['name'],
752
- valueField: 'id',
753
- create: false,
754
- render: {
755
- item: function(item, escape){
756
- return '<div>' + escape(item.name) + '</div>';
757
- },
758
- option: function(item, escape){
759
- return '<div>' + escape(item.name) + ' <span class="badge">' + escape(item.count) + '</span></div>';
760
- }
761
- }
762
- });
763
- });
764
- </script>
765
- <?php
766
- } else {
767
- $modal_button = false; ?>
768
- <p class="noterms"><?php _e('No tags', 'grand-media'); ?></p>
769
- <?php
770
- }
771
- break;
772
- case 'add_tags':
773
- $gm_terms = $gmDB->get_terms('gmedia_tag', array('fields' => 'names_count'));
774
- $gm_terms = array_values($gm_terms);
775
- ?>
776
- <div class="form-group">
777
- <input id="combobox_gmedia_tag" name="tag_names" class="form-control input-sm" value="" placeholder="<?php _e('Add Tags...', 'grand-media'); ?>"/>
778
- </div>
779
- <div class="checkbox">
780
- <label><input type="checkbox" name="iptc_tags" value="1"> <?php _e('Import IPTC Keywords from selected images to Tags'); ?></label>
781
- </div>
782
- <script type="text/javascript">
783
- jQuery(function($){
784
- var gm_terms = <?php echo json_encode($gm_terms); ?>;
785
- //noinspection JSUnusedAssignment
786
- var items = gm_terms.map(function(x){
787
- //noinspection JSUnresolvedVariable
788
- return {id: x.term_id, name: x.name, count: x.count};
789
- });
790
- //noinspection JSDuplicatedDeclaration
791
- $('#combobox_gmedia_tag').selectize({
792
- delimiter: ',',
793
- maxItems: null,
794
- openOnFocus: true,
795
- labelField: 'name',
796
- hideSelected: true,
797
- options: items,
798
- searchField: ['name'],
799
- valueField: 'name',
800
- persist: false,
801
- <?php if($gmCore->caps['gmedia_tag_manage']){ ?>
802
- createOnBlur: true,
803
- create: function(input){
804
- return {
805
- name: input
806
- }
807
- },
808
- <?php } else{ ?>
809
- create: false,
810
- <?php } ?>
811
- render: {
812
- item: function(item, escape){
813
- return '<div>' + escape(item.name) + '</div>';
814
- },
815
- option: function(item, escape){
816
- return '<div>' + escape(item.name) + ' <span class="badge">' + escape(item.count) + '</span></div>';
817
- }
818
- }
819
- });
820
- });
821
- </script>
822
- <?php
823
- break;
824
- case 'delete_tags':
825
- // get selected items in Gmedia Library
826
- $selected_items = !empty($ckey)? array_filter(explode('.', $_COOKIE[ $ckey ]), 'is_numeric') : false;
827
- if( !empty($selected_items)){
828
- $gm_terms = $gmDB->get_gmedia_terms($selected_items, 'gmedia_tag');
829
- }
830
- if(count($gm_terms)){
831
- foreach($gm_terms
832
-
833
- as $term){
834
- ?>
835
- <div class="checkbox">
836
- <label><input type="checkbox" name="tag_id[]" value="<?php echo $term->term_id; ?>"> <?php echo esc_html($term->name); ?></label>
837
- <span class="badge pull-right"><?php echo $term->count; ?></span>
838
- </div>
839
- <?php
840
- }
841
- } else{
842
- $modal_button = false; ?>
843
- <p class="noterms"><?php _e('No tags', 'grand-media'); ?></p>
844
- <?php
845
- }
846
- break;
847
- case 'filter_author':
848
- case 'select_author':
849
- if($gmCore->caps['gmedia_show_others_media']){
850
- ?>
851
- <div class="form-group">
852
- <label><?php _e('Choose Author', 'grand-media'); ?></label>
853
- <?php
854
- $user_ids = $gmCore->get_editable_user_ids();
855
- if($user_ids){
856
- if( !in_array($user_ID, $user_ids)){
857
- array_push($user_ids, $user_ID);
858
- }
859
- wp_dropdown_users(array(
860
- 'show_option_all' => ' &#8212; ',
861
- 'include' => $user_ids,
862
- 'include_selected' => true,
863
- 'name' => 'author_ids',
864
- 'selected' => $user_ID,
865
- 'class' => 'form-control combobox_authors'
866
- ));
867
- } else{
868
- echo '<div>' . get_the_author_meta('display_name', $user_ID) . '</div>';
869
- }
870
- ?>
871
- </div>
872
- <script type="text/javascript">
873
- jQuery(function(){
874
- jQuery('.combobox_authors').selectize({
875
- create: false,
876
- maxItems: 1,
877
- openOnFocus: true,
878
- hideSelected: true
879
- });
880
- });
881
- </script>
882
- <?php
883
- } else{
884
- echo '<p>' . __('You are not allowed to see others media') . '</p>';
885
- echo '<p><strong>' . get_the_author_meta('display_name', $user_ID) . '</strong></p>';
886
- }
887
- break;
888
- case 'batch_edit':
889
- ?>
890
- <p><?php _e('Note, data will be saved to all selected items in Gmedia Library.') ?></p>
891
- <div class="form-group">
892
- <label><?php _e('Filename', 'grand-media'); ?></label>
893
- <select class="form-control input-sm batch_set" name="batch_filename">
894
- <option value=""><?php _e('Skip. Do not change', 'grand-media'); ?></option>
895
- <option value="custom"><?php _e('Custom', 'grand-media'); ?></option>
896
- </select>
897
-
898
- <div class="batch_set_custom" style="margin-top:5px;display:none;">
899
- <input class="form-control input-sm" name="batch_filename_custom" value="" placeholder="<?php echo 'newname_{id}'; ?>"/>
900
-
901
- <div><?php _e('Variables: <b>{filename}</b> - original file name; <b>{id}</b> - Gmedia #ID in database; <b>{index:001}</b> - index of selected file in order you select (set start number after colon).') ?></div>
902
- </div>
903
- </div>
904
- <div class="form-group">
905
- <label><?php _e('Title', 'grand-media'); ?></label>
906
- <select class="form-control input-sm batch_set" name="batch_title">
907
- <option value=""><?php _e('Skip. Do not change', 'grand-media'); ?></option>
908
- <option value="empty"><?php _e('Empty Title', 'grand-media'); ?></option>
909
- <option value="filename"><?php _e('From Filename', 'grand-media'); ?></option>
910
- <option value="custom"><?php _e('Custom', 'grand-media'); ?></option>
911
- </select>
912
- <input class="form-control input-sm batch_set_custom" style="margin-top:5px;display:none;" name="batch_title_custom" value="" placeholder="<?php _e('Enter custom title here', 'grand-media'); ?>"/>
913
- </div>
914
- <div class="form-group">
915
- <label><?php _e('Description', 'grand-media'); ?></label>
916
- <select class="form-control input-sm batch_set" name="batch_description">
917
- <option value=""><?php _e('Skip. Do not change', 'grand-media'); ?></option>
918
- <option value="metadata"><?php _e('Add MetaInfo to Description', 'grand-media'); ?></option>
919
- <option value="empty"><?php _e('Empty Description', 'grand-media'); ?></option>
920
- <option value="custom"><?php _e('Custom', 'grand-media'); ?></option>
921
- </select>
922
-
923
- <div class="batch_set_custom" style="margin-top:5px;display:none;">
924
- <select class="form-control input-sm" name="what_description_custom" style="margin-bottom:5px;">
925
- <option value="replace"><?php _e('Replace', 'grand-media'); ?></option>
926
- <option value="append"><?php _e('Append', 'grand-media'); ?></option>
927
- <option value="prepend"><?php _e('Prepend', 'grand-media'); ?></option>
928
- </select>
929
- <textarea class="form-control input-sm" cols="30" rows="3" name="batch_description_custom" placeholder="<?php _e('Enter description here', 'grand-media'); ?>"></textarea>
930
- </div>
931
- </div>
932
- <div class="form-group">
933
- <label><?php _e('Link', 'grand-media'); ?></label>
934
- <select class="form-control input-sm batch_set" name="batch_link">
935
- <option value=""><?php _e('Skip. Do not change', 'grand-media'); ?></option>
936
- <option value="empty"><?php _e('Empty Link', 'grand-media'); ?></option>
937
- <option value="self"><?php _e('Link to original file', 'grand-media'); ?></option>
938
- <option value="custom"><?php _e('Custom', 'grand-media'); ?></option>
939
- </select>
940
- <input class="form-control input-sm batch_set_custom" style="margin-top:5px;display:none;" name="batch_link_custom" value="" placeholder="<?php _e('Enter url here'); ?>"/>
941
- </div>
942
- <div class="form-group">
943
- <label><?php _e('Status', 'grand-media'); ?></label>
944
- <select class="form-control input-sm batch_set" name="batch_status">
945
- <option value=""><?php _e('Skip. Do not change', 'grand-media'); ?></option>
946
- <option value="publish"><?php _e('Public', 'grand-media'); ?></option>
947
- <option value="private"><?php _e('Private', 'grand-media'); ?></option>
948
- <option value="draft"><?php _e('Draft', 'grand-media'); ?></option>
949
- </select>
950
- </div>
951
- <div class="form-group">
952
- <label><?php _e('Comment Status', 'grand-media'); ?></label>
953
- <select class="form-control input-sm batch_set" name="batch_comment_status">
954
- <option value=""><?php _e('Skip. Do not change', 'grand-media'); ?></option>
955
- <option value="open"><?php _e('Open', 'grand-media'); ?></option>
956
- <option value="closed"><?php _e('Closed', 'grand-media'); ?></option>
957
- </select>
958
- </div>
959
- <?php $user_ids = current_user_can('gmedia_delete_others_media')? $gmCore->get_editable_user_ids() : false;
960
- if($user_ids){
961
- if( !in_array($user_ID, $user_ids)){
962
- array_push($user_ids, $user_ID);
963
- }
964
- ?>
965
- <div class="form-group">
966
- <label><?php _e('Author', 'grand-media'); ?></label>
967
- <?php wp_dropdown_users(array(
968
- 'show_option_none' => __('Skip. Do not change', 'grand-media'),
969
- 'include' => $user_ids,
970
- 'include_selected' => true,
971
- 'name' => 'batch_author',
972
- 'selected' => - 1,
973
- 'class' => 'input-sm form-control'
974
- ));
975
- ?>
976
- </div>
977
- <?php } ?>
978
- <script type="text/javascript">
979
- jQuery(function($){
980
- $('select.batch_set').change(function(){
981
- if('custom' == $(this).val()){
982
- $(this).next().css({display: 'block'});
983
- } else{
984
- $(this).next().css({display: 'none'});
985
- }
986
- });
987
- });
988
- </script>
989
- <?php
990
- break;
991
- default:
992
- _e('Ops! Something wrong.', 'grand-media');
993
- break;
994
- }
995
- ?>
996
- </div>
997
- <div class="modal-footer">
998
- <button type="button" class="btn btn-default" data-dismiss="modal"><?php _e('Cancel', 'grand-media'); ?></button>
999
- <?php if($modal_button){ ?>
1000
- <input type="hidden" name="<?php echo $modal; ?>"/>
1001
- <button type="button" onclick="jQuery('#ajax-modal-form').submit()" class="btn <?php echo $button_class; ?>"><?php echo $modal_button; ?></button>
1002
- <?php
1003
- }
1004
- wp_nonce_field('gmedia_action', '_wpnonce_action');
1005
- ?>
1006
- </div>
1007
- </form><!-- /.modal-content -->
1008
- <?php
1009
- die();
1010
- }
1011
-
1012
- add_action('wp_ajax_gmedia_tag_edit', 'gmedia_tag_edit');
1013
- function gmedia_tag_edit(){
1014
- global $gmCore, $gmDB;
1015
-
1016
- check_ajax_referer('gmedia_terms', '_wpnonce_terms');
1017
- if( !current_user_can('gmedia_tag_manage') && !current_user_can('gmedia_edit_others_media')){
1018
- $out['error'] = $gmCore->alert('danger', __("You are not allowed to edit others media", 'grand-media'));
1019
- header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
1020
- echo json_encode($out);
1021
- die();
1022
- }
1023
-
1024
- $term = array('taxonomy' => 'gmedia_tag');
1025
- $term['name'] = trim($gmCore->_post('tag_name', ''));
1026
- $term['term_id'] = intval($gmCore->_post('tag_id', 0));
1027
- if($term['name'] && !$gmCore->is_digit($term['name'])){
1028
- if(($term_id = $gmDB->term_exists($term['term_id']))){
1029
- if( !$gmDB->term_exists($term['name'], $term['taxonomy'])){
1030
- $term_id = $gmDB->update_term($term['term_id'], $term);
1031
- if(is_wp_error($term_id)){
1032
- $out['error'] = $gmCore->alert('danger', $term_id->get_error_message());
1033
- } else{
1034
- $out['msg'] = $gmCore->alert('info', sprintf(__("Tag #%d successfully updated", 'grand-media'), $term_id));
1035
- }
1036
- } else{
1037
- $out['error'] = $gmCore->alert('danger', __("A term with the name provided already exists", 'grand-media'));
1038
- }
1039
- } else{
1040
- $out['error'] = $gmCore->alert('danger', __("A term with the id provided does not exists", 'grand-media'));
1041
- }
1042
- } else{
1043
- $out['error'] = $gmCore->alert('danger', __("Term name can't be only digits or empty", 'grand-media'));
1044
- }
1045
-
1046
- header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
1047
- echo json_encode($out);
1048
-
1049
- die();
1050
-
1051
- }
1052
-
1053
- add_action('wp_ajax_gmedia_module_preset_delete', 'gmedia_module_preset_delete');
1054
- function gmedia_module_preset_delete(){
1055
- global $gmCore, $gmDB, $user_ID;
1056
- $out = array('error' => '');
1057
-
1058
- check_ajax_referer('GmediaGallery');
1059
- if( !current_user_can('gmedia_gallery_manage')){
1060
- $out['error'] = $gmCore->alert('danger', __("You are not allowed to manage galleries", 'grand-media'));
1061
- } else{
1062
- $term_id = intval($gmCore->_post('preset_id', 0));
1063
- $term = $gmDB->get_term($term_id);
1064
- if($term && !is_wp_error($term)){
1065
- if(($term->global != $user_ID && !gm_user_can('delete_others_media')) || ((int) $term->global === 0 && !current_user_can('manage_options'))){
1066
- $out['error'] = $gmCore->alert('danger', __("You are not allowed to manage galleries", 'grand-media'));
1067
-
1068
- header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
1069
- echo json_encode($out);
1070
-
1071
- die();
1072
- }
1073
-
1074
- $delete = $gmDB->delete_term($term_id);
1075
- if(is_wp_error($delete)){
1076
- $out['error'] = $delete->get_error_message();
1077
- }
1078
- }
1079
- }
1080
-
1081
- header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
1082
- echo json_encode($out);
1083
-
1084
- die();
1085
-
1086
- }
1087
-
1088
- add_action('wp_ajax_gmedia_module_install', 'gmedia_module_install');
1089
- function gmedia_module_install(){
1090
- global $gmCore, $gmGallery;
1091
-
1092
- check_ajax_referer('GmediaGallery');
1093
- if( !current_user_can('gmedia_module_manage')){
1094
- echo $gmCore->alert('danger', __('You are not allowed to install modules'));
1095
- die();
1096
- }
1097
-
1098
- if(($download = $gmCore->_post('download'))){
1099
- $module = $gmCore->_post('module');
1100
- $mzip = download_url($download);
1101
- if(is_wp_error($mzip)){
1102
- echo $gmCore->alert('danger', $mzip->get_error_message());
1103
- die();
1104
- }
1105
-
1106
- $mzip = str_replace("\\", "/", $mzip);
1107
- $to_folder = $gmCore->upload['path'] . '/' . $gmGallery->options['folder']['module'] . '/';
1108
- if( !wp_mkdir_p($to_folder)){
1109
- echo $gmCore->alert('danger', sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?', 'grand-media'), $to_folder));
1110
- die();
1111
- }
1112
- if( !is_writable($to_folder)){
1113
- @chmod($to_folder, 0755);
1114
- if( !is_writable($to_folder)){
1115
- echo $gmCore->alert('danger', sprintf(__('Directory %s is not writable by the server.', 'grand-media'), $to_folder));
1116
- die();
1117
- }
1118
- }
1119
-
1120
- global $wp_filesystem;
1121
- // Is a filesystem accessor setup?
1122
- if( !$wp_filesystem || !is_object($wp_filesystem)){
1123
- require_once(ABSPATH . 'wp-admin/includes/file.php');
1124
- WP_Filesystem();
1125
- }
1126
- if( !is_object($wp_filesystem)){
1127
- $result = new WP_Error('fs_unavailable', __('Could not access filesystem.', 'grand-media'));
1128
- } elseif($wp_filesystem->errors->get_error_code()){
1129
- $result = new WP_Error('fs_error', __('Filesystem error', 'grand-media'), $wp_filesystem->errors);
1130
- } else{
1131
- if($module && is_dir($to_folder . $module)){
1132
- $gmCore->delete_folder($to_folder . $module);
1133
- }
1134
- $result = unzip_file($mzip, $to_folder);
1135
- }
1136
-
1137
- // Once extracted, delete the package
1138
- unlink($mzip);
1139
-
1140
- if(is_wp_error($result)){
1141
- echo $gmCore->alert('danger', $result->get_error_message());
1142
- die();
1143
- } else{
1144
- echo $gmCore->alert('success', sprintf(__("The `%s` module successfully installed", 'grand-media'), $module));
1145
- // Try to clear cache after module update
1146
- @$gmCore->clear_cache();
1147
- }
1148
- } else{
1149
- echo $gmCore->alert('danger', __('No file specified', 'grand-media'));
1150
- }
1151
-
1152
- die();
1153
-
1154
- }
1155
-
1156
-
1157
- add_action('wp_ajax_gmedia_import_wpmedia_modal', 'gmedia_import_wpmedia_modal');
1158
- function gmedia_import_wpmedia_modal(){
1159
- global $user_ID, $gmDB, $gmCore;
1160
-
1161
- check_ajax_referer('GmediaGallery');
1162
- if( !current_user_can('gmedia_import')){
1163
- die('-1');
1164
- }
1165
- ?>
1166
- <div class="modal-content">
1167
- <div class="modal-header">
1168
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
1169
- <h4 class="modal-title"><?php _e('Import from WP Media Library'); ?></h4>
1170
- </div>
1171
- <div class="modal-body" style="position:relative; min-height:270px;">
1172
- <form id="import_form" name="import_form" target="import_window" action="<?php echo admin_url('admin-ajax.php'); ?>" method="POST" accept-charset="utf-8">
1173
- <?php wp_nonce_field('gmedia_import', '_wpnonce_import'); ?>
1174
- <input type="hidden" name="action" value="gmedia_import_handler"/>
1175
- <input type="hidden" id="import-action" name="import" value="import-wpmedia"/>
1176
- <input type="hidden" name="selected" value="<?php $ckey = "gmedia_library:wpmedia";
1177
- if(isset($_COOKIE[ $ckey ])){
1178
- echo str_replace('.', ',', $_COOKIE[ $ckey ]);
1179
- } ?>"/>
1180
- <?php if($gmCore->caps['gmedia_terms']){ ?>
1181
- <div class="form-group">
1182
- <?php
1183
- $term_type = 'gmedia_album';
1184
- $gm_terms = $gmDB->get_terms($term_type, array('global' => array(0, $user_ID), 'orderby' => 'global_desc_name'));
1185
-
1186
- $terms_album = '';
1187
- if(count($gm_terms)){
1188
- foreach($gm_terms as $term){
1189
- $terms_album .= '<option value="' . esc_attr($term->term_id) . '">' . esc_html($term->name) . ($term->global? '' : __(' (shared)', 'grand-media')) . ('publish' == $term->status? '' : " [{$term->status}]") . '</option>' . "\n";
1190
- }
1191
- }
1192
- ?>
1193
- <label><?php _e('Add to Album', 'grand-media'); ?> </label>
1194
- <select id="combobox_gmedia_album" name="terms[gmedia_album]" class="form-control input-sm" placeholder="<?php _e('Album Name...', 'grand-media'); ?>">
1195
- <option value=""></option>
1196
- <?php echo $terms_album; ?>
1197
- </select>
1198
- </div>
1199
-
1200
- <div class="form-group">
1201
- <?php
1202
- $term_type = 'gmedia_category';
1203
- $gm_cat_terms = $gmDB->get_terms($term_type, array('fields' => 'names'));
1204
- ?>
1205
- <label><?php _e('Assign Categories', 'grand-media'); ?></label>
1206
- <input id="combobox_gmedia_category" name="terms[gmedia_category]" class="form-control input-sm" value="" placeholder="<?php _e('Uncategorized', 'grand-media'); ?>"/>
1207
- </div>
1208
-
1209
- <div class="form-group">
1210
- <?php
1211
- $term_type = 'gmedia_tag';
1212
- $gm_tag_terms = $gmDB->get_terms($term_type, array('fields' => 'names'));
1213
- ?>
1214
- <label><?php _e('Add Tags', 'grand-media'); ?> </label>
1215
- <input id="combobox_gmedia_tag" name="terms[gmedia_tag]" class="form-control input-sm" value="" placeholder="<?php _e('Add Tags...', 'grand-media'); ?>"/>
1216
- </div>
1217
- <script type="text/javascript">
1218
- jQuery(function($){
1219
- //noinspection JSDuplicatedDeclaration
1220
- $('#combobox_gmedia_album').selectize({
1221
- <?php if($gmCore->caps['gmedia_album_manage']){ ?>
1222
- create: true,
1223
- createOnBlur: true,
1224
- <?php } else{ ?>
1225
- create: false,
1226
- <?php } ?>
1227
- persist: false
1228
- });
1229
-
1230
- var gm_cat_terms = <?php echo json_encode($gm_cat_terms); ?>;
1231
- //noinspection JSUnusedAssignment
1232
- var cat_items = gm_cat_terms.map(function(x){
1233
- return {item: x};
1234
- });
1235
- //noinspection JSDuplicatedDeclaration
1236
- $('#combobox_gmedia_category').selectize({
1237
- <?php if($gmCore->caps['gmedia_category_manage']){ ?>
1238
- create: function(input){
1239
- return {
1240
- item: input
1241
- }
1242
- },
1243
- createOnBlur: true,
1244
- <?php } else{ ?>
1245
- create: false,
1246
- <?php } ?>
1247
- delimiter: ',',
1248
- maxItems: null,
1249
- openOnFocus: true,
1250
- persist: false,
1251
- options: cat_items,
1252
- labelField: 'item',
1253
- valueField: 'item',
1254
- searchField: ['item'],
1255
- hideSelected: true
1256
- });
1257
-
1258
- var gm_tag_terms = <?php echo json_encode($gm_tag_terms); ?>;
1259
- //noinspection JSUnusedAssignment
1260
- var tag_items = gm_tag_terms.map(function(x){
1261
- return {item: x};
1262
- });
1263
- //noinspection JSDuplicatedDeclaration
1264
- $('#combobox_gmedia_tag').selectize({
1265
- <?php if($gmCore->caps['gmedia_tag_manage']){ ?>
1266
- create: function(input){
1267
- return {
1268
- item: input
1269
- }
1270
- },
1271
- createOnBlur: true,
1272
- <?php } else{ ?>
1273
- create: false,
1274
- <?php } ?>
1275
- delimiter: ',',
1276
- maxItems: null,
1277
- openOnFocus: true,
1278
- persist: false,
1279
- options: tag_items,
1280
- labelField: 'item',
1281
- valueField: 'item',
1282
- searchField: ['item'],
1283
- hideSelected: true
1284
- });
1285
- });
1286
- </script>
1287
- <?php } else { ?>
1288
- <p><?php _e('You are not allowed to assign terms', 'grand-media') ?></p>
1289
- <?php } ?>
1290
- <div class="checkbox">
1291
- <label><input type="checkbox" name="skip_exists" value="skip"> <?php _e('Skip if file with the same name already exists in Gmedia Library', 'grand-media'); ?></label>
1292
- <div class="help-block"><?php _e('Note: duplicates will be skipped in any way (checked by file hash)') ?></div>
1293
- </div>
1294
- <script type="text/javascript">
1295
- jQuery(function($){
1296
- $('#import-done').one('click', function(){
1297
- $('#import_form').submit();
1298
- $(this).text($(this).data('loading-text')).prop('disabled', true);
1299
- $('#import_window').show();
1300
- $(this).one('click', function(){
1301
- $('#importModal').modal('hide');
1302
- });
1303
- });
1304
- });
1305
- </script>
1306
- </form>
1307
- <iframe name="import_window" id="import_window" src="about:blank" style="display:none; position:absolute; left:0; top:0; width:100%; height:100%; z-index:1000; background-color:#ffffff; padding:20px 20px 0 20px;" onload="gmedia_import_done()"></iframe>
1308
- </div>
1309
- <div class="modal-footer">
1310
- <button type="button" class="btn btn-default" data-dismiss="modal"><?php _e('Cancel', 'grand-media'); ?></button>
1311
- <button type="button" id="import-done" class="btn btn-primary" data-complete-text="<?php _e('Close', 'grand-media'); ?>" data-loading-text="<?php _e('Working...', 'grand-media'); ?>" data-reset-text="<?php _e('Import', 'grand-media'); ?>"><?php _e('Import', 'grand-media'); ?></button>
1312
- </div>
1313
- </div><!-- /.modal-content -->
1314
- <?php
1315
- die();
1316
- }
1317
-
1318
- add_action('wp_ajax_gmedia_relimage', 'gmedia_relimage');
1319
- /**
1320
- * Do Actions via Ajax
1321
- * TODO add related images to post
1322
- * TODO check author for related images
1323
- * @return void
1324
- */
1325
- function gmedia_relimage(){
1326
- /** @var $wpdb wpdb */
1327
- global $wpdb, $gmCore, $gmDB;
1328
-
1329
- check_ajax_referer("GmediaGallery");
1330
-
1331
- // check for correct capability
1332
- if( !current_user_can('gmedia_library')){
1333
- die('-1');
1334
- }
1335
-
1336
- $post_tags = array_filter(array_map('trim', explode(',', stripslashes(urldecode($gmCore->_get('tags', ''))))));
1337
- $paged = (int) $gmCore->_get('paged', 1);
1338
- $per_page = 20;
1339
- $s = trim(stripslashes(urldecode($gmCore->_get('search'))));
1340
- if($s && strlen($s) > 2){
1341
- $post_tags = array();
1342
- } else{
1343
- $s = '';
1344
- }
1345
-
1346
- $gmediaLib = array();
1347
- $relative = (int) $gmCore->_get('rel', 1);
1348
- $continue = true;
1349
- $content = '';
1350
-
1351
- if($relative == 1){
1352
- $arg = array(
1353
- 'mime_type' => 'image/*',
1354
- 'orderby' => 'ID',
1355
- 'order' => 'DESC',
1356
- 'per_page' => $per_page,
1357
- 'page' => $paged,
1358
- 's' => $s,
1359
- 'tag_name__in' => $post_tags,
1360
- 'null_tags' => true
1361
- );
1362
- $gmediaLib = $gmDB->get_gmedias($arg);
1363
- }
1364
-
1365
- if(empty($gmediaLib) && count($post_tags)){
1366
-
1367
- if($relative == 1){
1368
- $relative = 0;
1369
- $paged = 1;
1370
- $content .= '<li class="emptydb">' . __('No items related by tags.', 'grand-media') . '</li>' . "\n";
1371
- }
1372
-
1373
- $tag__not_in = "'" . implode("','", array_map('esc_sql', array_unique((array) $post_tags))) . "'";
1374
- $tag__not_in = $wpdb->get_col("
1375
- SELECT term_id
1376
- FROM {$wpdb->prefix}gmedia_term
1377
- WHERE taxonomy = 'gmedia_tag'
1378
- AND name IN ({$tag__not_in})
1379
- ");
1380
-
1381
- $arg = array(
1382
- 'mime_type' => 'image/*',
1383
- 'orderby' => 'ID',
1384
- 'order' => 'DESC',
1385
- 'per_page' => $per_page,
1386
- 'page' => $paged,
1387
- 'tag__not_in' => $tag__not_in
1388
- );
1389
- $gmediaLib = $gmDB->get_gmedias($arg);
1390
- }
1391
-
1392
- if(($count = count($gmediaLib))){
1393
- foreach($gmediaLib as $item){
1394
- $content .= "<li class='gmedia-image-li' id='gm-img-{$item->ID}'>\n";
1395
- $content .= " <a target='_blank' class='gm-img' data-gmid='{$item->ID}' href='" . $gmCore->gm_get_media_image($item) . "'><img src='" . $gmCore->gm_get_media_image($item, 'thumb') . "' height='50' style='width:auto;' alt='' title='" . esc_attr($item->title) . "' /></a>\n";
1396
- $content .= " <div style='display: none;' class='gm-img-description'>" . esc_html($item->description) . "</div>\n";
1397
- $content .= "</li>\n";
1398
- }
1399
- if(($count < $per_page) && ($relative == 0 || !empty($s))){
1400
- $continue = false;
1401
- }
1402
- } else{
1403
- if($s){
1404
- $content .= '<li class="emptydb">' . __('No items matching the search query.', 'grand-media') . '</li>' . "\n";
1405
- } else{
1406
- $content .= '<li class="emptydb">' . __('No items to show', 'grand-media') . '</li>' . "\n";
1407
- }
1408
- $continue = false;
1409
- }
1410
- $result = array('paged' => $paged, 'rel' => $relative, 'continue' => $continue, 'content' => $content, 'data' => $post_tags);
1411
- header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
1412
- echo json_encode($result);
1413
-
1414
- die();
1415
-
1416
- }
1417
-
1418
- add_action('wp_ajax_gmedia_ftp_browser', 'gmedia_ftp_browser');
1419
- /**
1420
- * jQuery File Tree PHP Connector
1421
- * @author Cory S.N. LaViska - A Beautiful Site (http://abeautifulsite.net/)
1422
- * @version 1.0.1
1423
- * @return string folder content
1424
- */
1425
- function gmedia_ftp_browser(){
1426
- if( !current_user_can('gmedia_import')){
1427
- die('No access');
1428
- }
1429
-
1430
- // if nonce is not correct it returns -1
1431
- check_ajax_referer('GmediaGallery');
1432
-
1433
- // start from the default path
1434
- $root = trailingslashit(ABSPATH);
1435
- // get the current directory
1436
- $dir = trailingslashit(urldecode($_POST['dir']));
1437
-
1438
- if((false === strpos($dir, '..')) && file_exists($root . $dir)){
1439
- $files = scandir($root . $dir);
1440
- natcasesort($files);
1441
-
1442
- // The 2 counts for . and ..
1443
- if(count($files) > 2){
1444
- echo "<ul class=\"jqueryFileTree\" style=\"display: none;\">";
1445
- // return only directories
1446
- foreach($files as $file){
1447
- if(in_array($file, array('wp-admin', 'wp-includes', 'plugins', 'themes', 'thumb', 'thumbs'))){
1448
- continue;
1449
- }
1450
-
1451
- if(file_exists($root . $dir . $file) && $file != '.' && $file != '..' && is_dir($root . $dir . $file)){
1452
- echo "<li class=\"directory collapsed\"><a href=\"#\" rel=\"" . esc_attr($dir . $file) . "/\">" . esc_html($file) . "</a></li>";
1453
- }
1454
- }
1455
- // All files
1456
- foreach($files as $file){
1457
- if(file_exists($root . $dir . $file) && $file != '.' && $file != '..' && !is_dir($root . $dir . $file)){
1458
- $ext = preg_replace('/^.*\./', '', $file);
1459
- if($file === '.' . $ext){
1460
- continue;
1461
- }
1462
- echo "<li class=\"file ext_$ext\"><a href=\"#\" rel=\"" . esc_attr($dir) . "\">" . esc_html($file) . "</a></li>";
1463
- }
1464
- }
1465
- echo "</ul>";
1466
- }
1467
- }
1468
-
1469
- die();
1470
- }
1471
-
1472
- add_action('wp_ajax_gmedia_set_post_thumbnail', 'gmedia_set_post_thumbnail');
1473
- function gmedia_set_post_thumbnail(){
1474
- global $gmCore, $gmDB, $gmGallery;
1475
-
1476
- $post_ID = intval($gmCore->_post('post_id', 0));
1477
-
1478
- if( !$post_ID || !current_user_can('edit_post', $post_ID)){
1479
- die('-1');
1480
- }
1481
-
1482
- // if nonce is not correct it returns -1
1483
- check_ajax_referer('set_post_thumbnail-' . $post_ID);
1484
-
1485
- $img_id = intval($gmCore->_post('img_id', 0));
1486
-
1487
- /*
1488
- // delete the image
1489
- if ( $thumbnail_id == '-1' ) {
1490
- delete_post_meta( $post_ID, '_thumbnail_id' );
1491
- die('0');
1492
- }
1493
- */
1494
-
1495
- if($img_id){
1496
-
1497
- $image = $gmDB->get_gmedia($img_id);
1498
- if($image){
1499
-
1500
- $args = array(
1501
- 'post_type' => 'attachment',
1502
- 'meta_key' => '_gmedia_image_id',
1503
- 'meta_compare' => '==',
1504
- 'meta_value' => $img_id
1505
- );
1506
- $posts = get_posts($args);
1507
- $attachment_id = null;
1508
-
1509
- if($posts != null){
1510
- $attachment_id = $posts[0]->ID;
1511
- //$target_path = get_attached_file( $attachment_id );
1512
- } else{
1513
- $upload_dir = wp_upload_dir();
1514
- $basedir = $upload_dir['basedir'];
1515
- $thumbs_dir = implode(DIRECTORY_SEPARATOR, array($basedir, 'gmedia_featured'));
1516
-
1517
- $type = explode('/', $image->mime_type);
1518
-
1519
- $url = $gmCore->upload['url'] . '/' . $gmGallery->options['folder'][ $type[0] ] . '/' . $image->gmuid;
1520
- $image_abspath = $gmCore->upload['path'] . '/' . $gmGallery->options['folder'][ $type[0] ] . '/' . $image->gmuid;
1521
-
1522
- $img_name = current_time('ymd_Hi') . '_' . basename($image->gmuid);
1523
- $target_path = path_join($thumbs_dir, $img_name);
1524
- wp_mkdir_p($thumbs_dir);
1525
-
1526
- if(@copy($image_abspath, $target_path)){
1527
- $title = sanitize_title($image->title);
1528
- $caption = $gmCore->sanitize($image->description);
1529
-
1530
- $attachment = array(
1531
- 'post_title' => $title,
1532
- 'post_content' => $caption,
1533
- 'post_status' => 'attachment',
1534
- 'post_parent' => 0,
1535
- 'post_mime_type' => $image->mime_type,
1536
- 'guid' => $url
1537
- );
1538
-
1539
- //require for wp_generate_attachment_metadata which generates image related meta-data also creates thumbs
1540
- require_once(ABSPATH . 'wp-admin/includes/image.php');
1541
- // Save the data
1542
- $attachment_id = wp_insert_attachment($attachment, $target_path);
1543
- wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $target_path));
1544
- add_post_meta($attachment_id, '_gmedia_image_id', $img_id, true);
1545
- }
1546
- }
1547
-
1548
- if($attachment_id){
1549
- delete_post_meta($post_ID, '_thumbnail_id');
1550
- add_post_meta($post_ID, '_thumbnail_id', $attachment_id, true);
1551
-
1552
- echo _wp_post_thumbnail_html($attachment_id, $post_ID);
1553
- die();
1554
- }
1555
- }
1556
- }
1557
-
1558
- die('0');
1559
- }
1560
-
1561
- add_action('wp_ajax_gmedia_upload_handler', 'gmedia_upload_handler');
1562
- function gmedia_upload_handler(){
1563
- global $gmCore;
1564
-
1565
- ini_set('max_execution_time', 300);
1566
-
1567
- // HTTP headers for no cache etc
1568
- send_nosniff_header();
1569
- //send_origin_headers();
1570
- nocache_headers();
1571
-
1572
- // if nonce is not correct it returns -1
1573
- check_ajax_referer('gmedia_upload', '_wpnonce_upload');
1574
- if( !current_user_can('gmedia_upload')){
1575
- wp_die(__('You do not have permission to upload files in Gmedia Library.'));
1576
- }
1577
-
1578
- // 5 minutes execution time
1579
- @set_time_limit(5 * 60);
1580
-
1581
- // fake upload time
1582
- usleep(10);
1583
-
1584
- $filename = $gmCore->_req('name');
1585
-
1586
- // Get parameters
1587
- if( !$filename){
1588
- $return = json_encode(array("error" => array("code" => 100, "message" => __("No file name.", 'grand-media'))));
1589
- die($return);
1590
- }
1591
-
1592
- $fileinfo = $gmCore->fileinfo($filename);
1593
- if(false === $fileinfo){
1594
- $return = json_encode(array("error" => array("code" => 100, "message" => __("File type not allowed.", 'grand-media')), "id" => $filename));
1595
- die($return);
1596
- }
1597
-
1598
- // Look for the content type header
1599
- $contentType = '';
1600
- if(isset($_SERVER["HTTP_CONTENT_TYPE"])){
1601
- $contentType = $_SERVER["HTTP_CONTENT_TYPE"];
1602
- }
1603
-
1604
- if(isset($_SERVER["CONTENT_TYPE"])){
1605
- $contentType = $_SERVER["CONTENT_TYPE"];
1606
- }
1607
-
1608
- // Handle non multipart uploads older WebKit versions didn't support multipart in HTML5
1609
- $file_tmp = '';
1610
- if(strpos($contentType, "multipart") !== false){
1611
- if(isset($_FILES['file']['tmp_name']) && is_uploaded_file($_FILES['file']['tmp_name'])){
1612
- $file_tmp = $_FILES['file']['tmp_name'];
1613
- }
1614
- } else{
1615
- $file_tmp = "php://input";
1616
- }
1617
-
1618
- if(empty($file_tmp)){
1619
- $return = json_encode(array("error" => array("code" => 103, "message" => __("Failed to move uploaded file.", 'grand-media')), "id" => $filename));
1620
- die($return);
1621
- }
1622
-
1623
- $post_data = array();
1624
- if(($params = $gmCore->_req('params', ''))){
1625
- parse_str($params, $post_data);
1626
- }
1627
-
1628
- $return = $gmCore->gmedia_upload_handler($file_tmp, $fileinfo, $contentType, $post_data);
1629
- $return = json_encode($return);
1630
-
1631
- die($return);
1632
- }
1633
-
1634
- add_action('wp_ajax_gmedia_import_handler', 'gmedia_import_handler');
1635
- function gmedia_import_handler(){
1636
- global $wpdb, $gmCore, $gmDB;
1637
-
1638
- ini_set('max_execution_time', 600);
1639
-
1640
- // HTTP headers for no cache etc
1641
- send_nosniff_header();
1642
- //send_origin_headers();
1643
- nocache_headers();
1644
-
1645
- check_admin_referer('gmedia_import', '_wpnonce_import');
1646
- if( !current_user_can('gmedia_import')){
1647
- wp_die(__('You do not have permission to upload files.'));
1648
- }
1649
-
1650
- // 10 minutes execution time
1651
- @set_time_limit(10 * 60);
1652
-
1653
- // fake upload time
1654
- usleep(10);
1655
-
1656
- $import = $gmCore->_post('import');
1657
- $terms = $gmCore->_post('terms', array());
1658
-
1659
- if(ob_get_level() == 0){
1660
- ob_start();
1661
- }
1662
- echo str_pad(' ', 4096) . PHP_EOL;
1663
- wp_ob_end_flush_all();
1664
- flush();
1665
- ?>
1666
- <html>
1667
- <style type="text/css">
1668
- * { margin: 0; padding: 0; }
1669
- pre { display: block; }
1670
- p { padding: 10px 0; font-size: 14px; }
1671
- .ok { color: darkgreen; }
1672
- .ko { color: darkred; }
1673
- </style>
1674
- <body>
1675
- <?php
1676
- if(('import-folder' == $import) || isset($_POST['import-folder'])){
1677
-
1678
- $path = $gmCore->_post('path');
1679
- echo '<h4 style="margin: 0 0 10px">' . __('Import Server Folder') . " `$path`:</h4>" . PHP_EOL;
1680
-
1681
- if($path){
1682
- $path = trim(urldecode($path), '/');
1683
- if( !empty($path)){
1684
- $fullpath = ABSPATH . trailingslashit($path);
1685
- $files = glob($fullpath . '?*.?*', GLOB_NOSORT);
1686
- if( !empty($files)){
1687
- $allowed_ext = get_allowed_mime_types();
1688
- $allowed_ext = array_keys($allowed_ext);
1689
- $allowed_ext = implode('|', $allowed_ext);
1690
- $allowed_ext = explode('|', $allowed_ext);
1691
- if((GMEDIA_UPLOAD_FOLDER == basename(dirname(dirname($path)))) || (GMEDIA_UPLOAD_FOLDER == basename(dirname($path)))){
1692
- global $wpdb;
1693
- $gmedias = $wpdb->get_col("SELECT gmuid FROM {$wpdb->prefix}gmedia");
1694
- foreach($files as $i => $filepath){
1695
- $gmuid = basename($filepath);
1696
- if(in_array($gmuid, $gmedias)){
1697
- $fileinfo = $gmCore->fileinfo($gmuid, false);
1698
- if( !(('image' == $fileinfo['dirname']) && !is_file($fileinfo['filepath']))){
1699
- unset($files[ $i ]);
1700
- }
1701
- }
1702
- }
1703
- $move = false;
1704
- $exists = false;
1705
- } else{
1706
- $move = $gmCore->_post('delete_source');
1707
- $exists = $gmCore->_post('skip_exists', 0);
1708
- }
1709
- foreach($files as $i => $filepath){
1710
- $ext = pathinfo($filepath, PATHINFO_EXTENSION);
1711
- if( !in_array(strtolower($ext), $allowed_ext)){
1712
- unset($files[ $i ]);
1713
- }
1714
- }
1715
- $gmCore->gmedia_import_files($files, $terms, $move, $exists);
1716
- } else{
1717
- echo sprintf(__('Folder `%s` is empty', 'grand-media'), $path) . PHP_EOL;
1718
- }
1719
- } else{
1720
- echo __('No folder chosen', 'grand-media') . PHP_EOL;
1721
- }
1722
- }
1723
- } elseif(('import-flagallery' == $import) || isset($_POST['import-flagallery'])){
1724
-
1725
- echo '<h4 style="margin: 0 0 10px">' . __('Import from Flagallery plugin') . ":</h4>" . PHP_EOL;
1726
-
1727
- $gallery = $gmCore->_post('gallery');
1728
- if( !empty($gallery)){
1729
- $album = ( !isset($terms['gmedia_album']) || empty($terms['gmedia_album']))? false : true;
1730
- foreach($gallery as $gid){
1731
- $flag_gallery = $wpdb->get_row($wpdb->prepare("SELECT gid, path, title, galdesc FROM {$wpdb->prefix}flag_gallery WHERE gid = %d", $gid), ARRAY_A);
1732
- if(empty($flag_gallery)){
1733
- continue;
1734
- }
1735
-
1736
- if( !$album){
1737
- $terms['gmedia_album'] = $flag_gallery['title'];
1738
- if($gmCore->is_digit($terms['gmedia_album'])){
1739
- $terms['gmedia_album'] = 'a' . $terms['gmedia_album'];
1740
- }
1741
- if( !$gmDB->term_exists($terms['gmedia_album'], 'gmedia_album')){
1742
- $term_id = $gmDB->insert_term($terms['gmedia_album'], 'gmedia_album', array('description' => htmlspecialchars_decode(stripslashes($flag_gallery['galdesc']))));
1743
- }
1744
- }
1745
-
1746
- $path = ABSPATH . trailingslashit($flag_gallery['path']);
1747
-
1748
- echo '<h5 style="margin: 10px 0 5px">' . sprintf(__('Import `%s` gallery', 'grand-media'), $flag_gallery['title']) . ":</h5>" . PHP_EOL;
1749
-
1750
- $flag_pictures = $wpdb->get_results($wpdb->prepare("SELECT CONCAT('%s', filename) AS file, description, alttext AS title, link FROM {$wpdb->prefix}flag_pictures WHERE galleryid = %d", $path, $flag_gallery['gid']), ARRAY_A);
1751
- if(empty($flag_pictures)){
1752
- echo '<pre>' . __('gallery contains 0 images', 'grand-media') . '</pre>';
1753
- continue;
1754
- }
1755
- $exists = $gmCore->_post('skip_exists', 0);
1756
-
1757
- //echo '<pre>'.print_r($flag_pictures, true).'</pre>';
1758
- $gmCore->gmedia_import_files($flag_pictures, $terms, false, $exists);
1759
- }
1760
- } else{
1761
- echo __('No gallery chosen', 'grand-media') . PHP_EOL;
1762
- }
1763
- } elseif(('import-nextgen' == $import) || isset($_POST['import-nextgen'])){
1764
-
1765
- echo '<h4 style="margin: 0 0 10px">' . __('Import from NextGen plugin') . ":</h4>" . PHP_EOL;
1766
-
1767
- $gallery = $gmCore->_post('gallery');
1768
- if( !empty($gallery)){
1769
- $album = ( !isset($terms['gmedia_album']) || empty($terms['gmedia_album']))? false : true;
1770
- foreach($gallery as $gid){
1771
- $ngg_gallery = $wpdb->get_row($wpdb->prepare("SELECT gid, path, title, galdesc FROM {$wpdb->prefix}ngg_gallery WHERE gid = %d", $gid), ARRAY_A);
1772
- if(empty($ngg_gallery)){
1773
- continue;
1774
- }
1775
-
1776
- if( !$album){
1777
- $terms['gmedia_album'] = $ngg_gallery['title'];
1778
- if($gmCore->is_digit($terms['gmedia_album'])){
1779
- $terms['gmedia_album'] = 'a' . $ngg_gallery['title'];
1780
- }
1781
- if( !$gmDB->term_exists($terms['gmedia_album'], 'gmedia_album')){
1782
- $term_id = $gmDB->insert_term($terms['gmedia_album'], 'gmedia_album', array('description' => htmlspecialchars_decode(stripslashes($ngg_gallery['galdesc']))));
1783
- }
1784
- }
1785
-
1786
- $path = ABSPATH . trailingslashit($ngg_gallery['path']);
1787
-
1788
- echo '<h5 style="margin: 10px 0 5px">' . sprintf(__('Import `%s` gallery', 'grand-media'), $ngg_gallery['title']) . ":</h5>" . PHP_EOL;
1789
-
1790
- $ngg_pictures = $wpdb->get_results($wpdb->prepare("SELECT CONCAT('%s', filename) AS file, description, alttext AS title FROM {$wpdb->prefix}ngg_pictures WHERE galleryid = %d", $path, $ngg_gallery['gid']), ARRAY_A);
1791
- if(empty($ngg_pictures)){
1792
- echo '<pre>' . __('gallery contains 0 images', 'grand-media') . '</pre>';
1793
- continue;
1794
- }
1795
- $exists = $gmCore->_post('skip_exists', 0);
1796
-
1797
- $gmCore->gmedia_import_files($ngg_pictures, $terms, false, $exists);
1798
- }
1799
- } else{
1800
- echo __('No gallery chosen', 'grand-media') . PHP_EOL;
1801
- }
1802
- } elseif(('import-wpmedia' == $import) || isset($_POST['import-wpmedia'])){
1803
-
1804
- echo '<h4 style="margin: 0 0 10px">' . __('Import from WP Media Library') . ":</h4>" . PHP_EOL;
1805
-
1806
- $wpMediaLib = $gmDB->get_wp_media_lib(array('filter' => 'selected', 'selected' => $gmCore->_post('selected')));
1807
-
1808
- if( !empty($wpMediaLib)){
1809
-
1810
- $wp_media = array();
1811
- foreach($wpMediaLib as $item){
1812
- $wp_media[] = array(
1813
- 'file' => get_attached_file($item->ID),
1814
- 'author' => $item->author,
1815
- 'title' => $item->post_title,
1816
- 'description' => $item->post_content
1817
- );
1818
- }
1819
- $exists = $gmCore->_post('skip_exists', 0);
1820
- //echo '<pre>' . print_r($wp_media, true) . '</pre>';
1821
- $gmCore->gmedia_import_files($wp_media, $terms, false, $exists);
1822
-
1823
- } else{
1824
- echo __('No items chosen', 'grand-media') . PHP_EOL;
1825
- }
1826
- }
1827
- ?>
1828
- </body>
1829
- </html>
1830
- <?php
1831
- wp_ob_end_flush_all();
1832
-
1833
- die();
1834
- }
1835
-
1836
- add_action('wp_ajax_gmedia_application', 'gmedia_application');
1837
- function gmedia_application(){
1838
- global $gmCore, $gmGallery;
1839
-
1840
- // if nonce is not correct it returns -1
1841
- check_ajax_referer('GmediaService');
1842
- if( !current_user_can('manage_options')){
1843
- die('-1');
1844
- }
1845
-
1846
- $service = $gmCore->_post('service');
1847
- if( !$service){
1848
- die('0');
1849
- }
1850
- $options = $gmGallery->options;
1851
-
1852
- if('skip' === $service){
1853
- $options['gmedia_service'] = $service;
1854
- if((int)$options['mobile_app']){
1855
- $options['mobile_app'] = 0;
1856
- $service = 'app_deactivate';
1857
- } else{
1858
- $gmGallery->options = $options;
1859
- update_option('gmediaOptions', $options);
1860
- wp_send_json_success();
1861
- }
1862
- } elseif('allow' === $service){
1863
- $options['gmedia_service'] = $service;
1864
- $service = 'app_activate';
1865
- }
1866
-
1867
- if($options != $gmGallery->options){
1868
- $gmGallery->options = $options;
1869
- update_option('gmediaOptions', $options);
1870
- }
1871
-
1872
- $result = $gmCore->app_service($service);
1873
-
1874
- header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
1875
- echo json_encode($result);
1876
-
1877
- die();
1878
- }
1879
-
1880
- add_action('wp_ajax_gmedia_share_page', 'gmedia_share_page');
1881
- function gmedia_share_page(){
1882
- global $gmCore, $user_ID;
1883
- // if nonce is not correct it returns -1
1884
- check_ajax_referer('gmedia_share', '_wpnonce_share');
1885
-
1886
- $sharelink = $gmCore->_post('sharelink', '');
1887
- $email = $gmCore->_post('email', '');
1888
- $sharemessage = $gmCore->_post('message', '');
1889
- if( !filter_var($email, FILTER_VALIDATE_EMAIL)){
1890
- echo $gmCore->alert('danger', __('Invalid email', 'grand-media') . ': ' . esc_html($email));
1891
- die();
1892
- }
1893
-
1894
- $display_name = get_the_author_meta('display_name', $user_ID);
1895
- $subject = sprintf(__('%s shared GmediaCloud Page with you', 'grand-media'), $display_name);
1896
- $sharetitle = sprintf(__('%s used Gmedia to share something interesting with you!', 'grand-media'), $display_name);
1897
- $sharelinktext = __('Click here to view page', 'grand-media');
1898
- if($sharemessage){
1899
- $sharemessage = '<blockquote>"' . nl2br(esc_html($sharemessage)) . '"</blockquote>';
1900
- }
1901
- $footer = ' . date('Y') . ' GmediaGallery';
1902
- $message = <<<EOT
1903
- <center>
1904
- <table cellpadding="0" cellspacing="0" style="border-radius:4px;border:1px #dceaf5 solid;" border="0" align="center">
1905
- <tr><td colspan="3" height="20"></td></tr>
1906
- <tr style="line-height:0;">
1907
- <td width="100%" style="font-size:0;" align="center" height="1">
1908
- <img width="72" style="max-height:72px;width:72px;" alt="GmediaGallery" src="http://mypgc.co/images/email/logo-128.png" />
1909
- </td>
1910
- </tr>
1911
- <tr><td>
1912
- <table cellpadding="0" cellspacing="0" style="line-height:25px;" border="0" align="center">
1913
- <tr><td colspan="3" height="20"></td></tr>
1914
- <tr>
1915
- <td width="36"></td>
1916
- <td width="454" align="left" style="color:#444444;border-collapse:collapse;font-size:11pt;font-family:proxima_nova,'Open Sans','Lucida Grande','Segoe UI',Arial,Verdana,'Lucida Sans Unicode',Tahoma,'Sans Serif';max-width:454px;" valign="top">{$sharetitle}<br />
1917
- {$sharemessage}
1918
- <br /><a style="color:#0D8FB3" href="{$sharelink}">{$sharelinktext}</a>.</td>
1919
- <td width="36"></td>
1920
- </tr>
1921
- <tr><td colspan="3" height="36"></td></tr>
1922
- </table>
1923
- </td>
1924
- </tr>
1925
- </table>
1926
- <table cellpadding="0" cellspacing="0" align="center" border="0">
1927
- <tr><td height="10"></td></tr>
1928
- <tr><td style="padding:0;border-collapse:collapse;">
1929
- <table cellpadding="0" cellspacing="0" align="center" border="0">
1930
- <tr style="color:#a8b9c6;font-size:11px;font-family:proxima_nova,'Open Sans','Lucida Grande','Segoe UI',Arial,Verdana,'Lucida Sans Unicode',Tahoma,'Sans Serif';">
1931
- <td width="128" align="left"></td>
1932
- <td width="400" align="right">{$footer}</td>
1933
- </tr>
1934
- </table>
1935
- </td>
1936
- </tr>
1937
- </table>
1938
- </center>
1939
- EOT;
1940
-
1941
- $headers = array('Content-Type: text/html; charset=UTF-8');
1942
- if(wp_mail($email, $subject, $message, $headers)){
1943
- echo $gmCore->alert('success', sprintf(__('Message sent to %s', 'grand-media'), $email));
1944
- }
1945
-
1946
- die();
1947
- }
1948
-
1949
- add_action('wp_ajax_gmedia_add_custom_field', 'gmedia_add_custom_field');
1950
- function gmedia_add_custom_field(){
1951
- global $gmDB, $user_ID, $gmCore;
1952
- check_ajax_referer('gmedia_custom_field', '_wpnonce_custom_field');
1953
-
1954
- $meta_type = 'gmedia';
1955
-
1956
- $pid = (int) $_POST['ID'];
1957
- $post = $gmDB->get_gmedia($pid);
1958
-
1959
- header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
1960
-
1961
- if( !current_user_can('gmedia_edit_media') || ($user_ID != $post->author && !current_user_can('gmedia_edit_others_media'))){
1962
- echo json_encode(array('error' => array('code' => 100, 'message' => __('You are not allowed to edit others media', 'grand-media')), 'id' => $pid));
1963
- die();
1964
- }
1965
- if(isset($_POST['metakeyselect']) && empty($_POST['metakeyselect']) && empty($_POST['metakeyinput'])){
1966
- echo json_encode(array('error' => array('code' => 101, 'message' => __('Choose or provide a custom field name', 'grand-media')), 'id' => $pid));
1967
- die();
1968
- }
1969
-
1970
- if( !$mid = $gmCore->add_meta($pid, $meta_type)){
1971
- echo json_encode(array('error' => array('code' => 102, 'message' => __('Please provide a custom field value', 'grand-media')), 'id' => $pid));
1972
- die();
1973
- }
1974
-
1975
- $column = sanitize_key($meta_type . '_id');
1976
- $meta = $gmDB->get_metadata_by_mid($meta_type, $mid);
1977
- $pid = (int) $meta->{$column};
1978
- $meta = get_object_vars($meta);
1979
- $result = array(
1980
- 'success' => array(
1981
- 'meta_id' => $mid,
1982
- 'data' => $gmCore->_list_meta_item($meta, $meta_type)
1983
- ),
1984
- 'id' => $pid
1985
- );
1986
-
1987
- if( !empty($_POST['metakeyinput'])){
1988
- $result['newmeta_form'] = $gmCore->meta_form($meta_type);
1989
- }
1990
-
1991
- echo json_encode($result);
1992
- die();
1993
-
1994
- }
1995
-
1996
- add_action('wp_ajax_gmedia_delete_custom_field', 'gmedia_delete_custom_field');
1997
- function gmedia_delete_custom_field(){
1998
- global $gmDB, $user_ID, $gmCore;
1999
- check_ajax_referer('gmedia_custom_field', '_wpnonce_custom_field');
2000
-
2001
- $meta_type = 'gmedia';
2002
-
2003
- $pid = (int) $_POST['ID'];
2004
- $post = $gmDB->get_gmedia($pid);
2005
-
2006
- if( !current_user_can('gmedia_edit_media') || ($user_ID != $post->author && !current_user_can('gmedia_edit_others_media'))){
2007
- echo json_encode(array('error' => array('code' => 100, 'message' => __('You are not allowed to edit others media', 'grand-media')), 'id' => $pid));
2008
- die();
2009
- }
2010
-
2011
- $result = array('id' => $pid);
2012
-
2013
- $deletemeta = $_POST['meta'];
2014
- $column = sanitize_key($meta_type . '_id');
2015
- if(isset($deletemeta) && is_array($deletemeta)){
2016
- foreach($deletemeta as $key => $value){
2017
- if( !$meta = $gmDB->get_metadata_by_mid($meta_type, $key)){
2018
- continue;
2019
- }
2020
- if($meta->{$column} != $pid){
2021
- continue;
2022
- }
2023
- if($gmCore->is_protected_meta($meta->meta_key, $meta_type)){
2024
- continue;
2025
- }
2026
- if(($del_meta = $gmDB->delete_metadata_by_mid($meta_type, $key))){
2027
- $result['deleted'][] = $key;
2028
- }
2029
- }
2030
- }
2031
-
2032
- header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
2033
- echo json_encode($result);
2034
- die();
2035
-
2036
- }
2037
-
2038
- add_action('wp_ajax_gmedia_term_add_custom_field', 'gmedia_term_add_custom_field');
2039
- function gmedia_term_add_custom_field(){
2040
- global $gmDB, $user_ID, $gmCore;
2041
- check_ajax_referer('gmedia_custom_field', '_wpnonce_custom_field');
2042
-
2043
- $meta_type = 'gmedia_term';
2044
-
2045
- $pid = (int) $_POST['ID'];
2046
- $post = $gmDB->get_term($pid);
2047
-
2048
- $taxonomy = $post->taxonomy;
2049
-
2050
- header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
2051
-
2052
- if( !current_user_can($taxonomy . '_manage') || ($user_ID != $post->global && !current_user_can('gmedia_edit_others_media'))){
2053
- echo json_encode(array('error' => array('code' => 100, 'message' => __('You are not allowed to edit others media', 'grand-media')), 'id' => $pid));
2054
- die();
2055
- }
2056
- if(isset($_POST['metakeyselect']) && empty($_POST['metakeyselect']) && empty($_POST['metakeyinput'])){
2057
- echo json_encode(array('error' => array('code' => 101, 'message' => __('Choose or provide a custom field name', 'grand-media')), 'id' => $pid));
2058
- die();
2059
- }
2060
-
2061
- if( !$mid = $gmCore->add_meta($pid, $meta_type)){
2062
- echo json_encode(array('error' => array('code' => 102, 'message' => __('Please provide a custom field value', 'grand-media')), 'id' => $pid));
2063
- die();
2064
- }
2065
-
2066
- $column = sanitize_key($meta_type . '_id');
2067
- $meta = $gmDB->get_metadata_by_mid($meta_type, $mid);
2068
- $pid = (int) $meta->{$column};
2069
- $meta = get_object_vars($meta);
2070
- $result = array(
2071
- 'success' => array(
2072
- 'meta_id' => $mid,
2073
- 'data' => $gmCore->_list_meta_item($meta, $meta_type)
2074
- ),
2075
- 'id' => $pid
2076
- );
2077
-
2078
- if( !empty($_POST['metakeyinput'])){
2079
- $result['newmeta_form'] = $gmCore->meta_form($meta_type);
2080
- }
2081
-
2082
- echo json_encode($result);
2083
- die();
2084
-
2085
- }
2086
-
2087
- add_action('wp_ajax_gmedia_term_delete_custom_field', 'gmedia_term_delete_custom_field');
2088
- function gmedia_term_delete_custom_field(){
2089
- global $gmDB, $user_ID, $gmCore;
2090
- check_ajax_referer('gmedia_custom_field', '_wpnonce_custom_field');
2091
-
2092
- $meta_type = 'gmedia_term';
2093
-
2094
- $pid = (int) $_POST['ID'];
2095
- $post = $gmDB->get_term($pid);
2096
-
2097
- $taxonomy = $post->taxonomy;
2098
-
2099
- header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
2100
-
2101
- if( !current_user_can($taxonomy . '_manage') || ($user_ID != $post->global && !current_user_can('gmedia_edit_others_media'))){
2102
- echo json_encode(array('error' => array('code' => 100, 'message' => __('You are not allowed to edit others media', 'grand-media')), 'id' => $pid));
2103
- die();
2104
- }
2105
-
2106
- $result = array('id' => $pid);
2107
-
2108
- $deletemeta = $_POST['meta'];
2109
- $column = sanitize_key($meta_type . '_id');
2110
- if(isset($deletemeta) && is_array($deletemeta)){
2111
- foreach($deletemeta as $key => $value){
2112
- if( !$meta = $gmDB->get_metadata_by_mid($meta_type, $key)){
2113
- continue;
2114
- }
2115
- if($meta->{$column} != $pid){
2116
- continue;
2117
- }
2118
- if($gmCore->is_protected_meta($meta->meta_key, $meta_type)){
2119
- continue;
2120
- }
2121
- if(($del_meta = $gmDB->delete_metadata_by_mid($meta_type, $key))){
2122
- $result['deleted'][] = $key;
2123
- }
2124
- }
2125
- }
2126
-
2127
- echo json_encode($result);
2128
- die();
2129
-
2130
- }
2131
-
2132
- add_action('wp_ajax_gmedia_term_sortorder', 'gmedia_term_sortorder');
2133
- function gmedia_term_sortorder(){
2134
- global $gmDB, $user_ID, $gmCore;
2135
- check_ajax_referer('gmedia_terms', '_wpnonce_terms');
2136
-
2137
- $term_id = $gmCore->_post('term_id');
2138
- $idx0 = (int) $gmCore->_post('idx0');
2139
- $ids = $gmCore->_post('ids');
2140
-
2141
- if( !$idx0 || !is_array($ids)){
2142
- die();
2143
- }
2144
-
2145
- if( !current_user_can('gmedia_album_manage')){
2146
- wp_send_json(array('error' => array('code' => 100, 'message' => __('You are not allowed to manage this taxonomy', 'grand-media')), 'id' => $term_id));
2147
- }
2148
-
2149
- if( !$term_id || !($term_id = $gmDB->term_exists($term_id))){
2150
- wp_send_json(array('error' => array('code' => 101, 'message' => __('A term with the id provided does not exists', 'grand-media')), 'id' => $term_id));
2151
- }
2152
- $term = $gmDB->get_term($term_id);
2153
- if(((int) $term->global != (int) $user_ID) && !current_user_can('gmedia_edit_others_media')){
2154
- wp_send_json(array('error' => array('code' => 102, 'message' => __('You are not allowed to edit others media', 'grand-media')), 'id' => $term_id));
2155
- }
2156
-
2157
- $gm_ids_order = array();
2158
- foreach($ids as $id){
2159
- $gm_ids_order[ $id ] = $idx0;
2160
- $idx0 ++;
2161
- }
2162
-
2163
- $term_id = $gmDB->update_term_sortorder($term_id, $gm_ids_order);
2164
- if(is_wp_error($term_id)){
2165
- wp_send_json(array('error' => array('code' => 103, 'message' => $term_id->get_error_message()), 'id' => $term_id));
2166
- }
2167
-
2168
- wp_send_json_success($term_id);
2169
- }
2170
-
2171
- add_action('wp_ajax_gmedia_upgrade_process', 'gmedia_upgrade_process');
2172
- function gmedia_upgrade_process(){
2173
-
2174
- $db_version = get_option('gmediaDbVersion');
2175
- $info = get_transient('gmediaHeavyJob');
2176
- $result = array('content' => '');
2177
-
2178
- $upgrading = get_transient('gmediaUpgrade');
2179
- if($upgrading){
2180
- $timeout = time() - $upgrading;
2181
- } else{
2182
- $timeout = 0;
2183
- }
2184
- if($timeout > 20){
2185
- require_once(GMEDIA_ABSPATH . 'config/update.php');
2186
- gmedia_db_update();
2187
- }
2188
- $result['timeout'] = $timeout;
2189
-
2190
- if( !empty($info)){
2191
- $result['content'] = '<div>' . implode("</div>\n<div>", $info) . '</div>';
2192
- } elseif($db_version == GMEDIA_DBVERSION){
2193
- $result['status'] = 'done';
2194
- }
2195
-
2196
- header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
2197
- echo json_encode($result);
2198
- die();
2199
-
2200
- }
2201
-
2202
- add_action('wp_ajax_gmedia_hash_files', 'gmedia_hash_files');
2203
- function gmedia_hash_files(){
2204
- global $wpdb, $gmCore, $gmDB;
2205
-
2206
- check_ajax_referer('gmedia_ajax_long_operations', '_wpnonce_ajax_long_operations');
2207
-
2208
- $all_count = wp_cache_get('gmedia_count_all');
2209
- if(false === $all_count){
2210
- $all_count = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->prefix}gmedia");
2211
- wp_cache_set('gmedia_count_all', $all_count);
2212
- }
2213
- $sql = "SELECT SQL_CALC_FOUND_ROWS ID, gmuid FROM {$wpdb->prefix}gmedia AS g WHERE 1 = 1
2214
- AND ( NOT EXISTS ( SELECT * FROM {$wpdb->prefix}gmedia_meta AS gm WHERE gm.meta_key = '_hash' AND gm.gmedia_id = g.ID )
2215
- OR NOT EXISTS ( SELECT * FROM {$wpdb->prefix}gmedia_meta AS gm2 WHERE gm2.meta_key = '_size' AND gm2.gmedia_id = g.ID)
2216
- )
2217
- LIMIT 20";
2218
- $unhashed = $wpdb->get_results($sql);
2219
- if( !$unhashed){
2220
- $ajax_operations = get_option('gmedia_ajax_long_operations', array());
2221
- unset($ajax_operations['gmedia_hash_files']);
2222
- if(empty($ajax_operations)){
2223
- delete_option('gmedia_ajax_long_operations');
2224
- } else{
2225
- update_option('gmedia_ajax_long_operations', $ajax_operations);
2226
- }
2227
- wp_cache_delete('gmedia_count_all');
2228
-
2229
- wp_send_json_success(array('progress' => '100%', 'info' => __('Indexing:', 'grand-media'), 'done' => true));
2230
- }
2231
-
2232
- $unhashed_count = $wpdb->get_var('SELECT FOUND_ROWS()');
2233
-
2234
- foreach($unhashed as $item){
2235
- $fileinfo = $gmCore->fileinfo($item->gmuid, false);
2236
- $filepath = is_file($fileinfo['filepath_original'])? $fileinfo['filepath_original'] : $fileinfo['filepath'];
2237
- $hash_file = hash_file('md5', $filepath);
2238
- $gmDB->update_metadata($meta_type = 'gmedia', $item->ID, $meta_key = '_hash', $hash_file);
2239
- $file_size = filesize($filepath);
2240
- $gmDB->update_metadata($meta_type = 'gmedia', $item->ID, $meta_key = '_size', $file_size);
2241
- }
2242
-
2243
- $progress = round(($all_count - $unhashed_count) * 100 / $all_count);
2244
-
2245
- wp_send_json_success(array('progress' => "{$progress}%", 'info' => __('Indexing:', 'grand-media')));
2246
- }
2247
-
2248
- add_action('wp_ajax_gmedia_recreate_images', 'gmedia_recreate_images');
2249
- function gmedia_recreate_images(){
2250
- global $gmCore;
2251
-
2252
- check_ajax_referer('gmedia_ajax_long_operations', '_wpnonce_ajax_long_operations');
2253
-
2254
- $gmid = 0;
2255
- $ajax_operations = get_option('gmedia_ajax_long_operations', array());
2256
- if( !empty($ajax_operations['gmedia_recreate_images'])){
2257
- $all_count = count($ajax_operations['gmedia_recreate_images']);
2258
- $recreate_ids = array_filter($ajax_operations['gmedia_recreate_images']);
2259
- $do_count = count($recreate_ids);
2260
-
2261
- if( !empty($recreate_ids)){
2262
- $gmid = reset($recreate_ids);
2263
- $gmCore->recreate_images_from_original($gmid);
2264
-
2265
- $ajax_operations['gmedia_recreate_images'][ $gmid ] = false;
2266
- update_option('gmedia_ajax_long_operations', $ajax_operations);
2267
- } else{
2268
- unset($ajax_operations['gmedia_recreate_images']);
2269
- }
2270
-
2271
- if(empty($ajax_operations)){
2272
- delete_option('gmedia_ajax_long_operations');
2273
-
2274
- wp_send_json_success(array('progress' => '100%', 'info' => __('Done:', 'grand-media'), 'done' => true, 'id' => $gmid));
2275
- } else{
2276
- $progress = round(($all_count - $do_count) * 100 / $all_count);
2277
-
2278
- wp_send_json_success(array('progress' => "{$progress}%", 'info' => __('Working:', 'grand-media'), 'id' => $gmid));
2279
- }
2280
- }
2281
-
2282
- wp_send_json_success(array('progress' => '100%', 'info' => __('Done:', 'grand-media'), 'done' => true, 'id' => $gmid));
2283
- }
2284
-
2285
- add_action('wp_ajax_gmedia_feedback', 'gmedia_feedback');
2286
- function gmedia_feedback(){
2287
- global $gmCore;
2288
-
2289
- check_ajax_referer('gmedia_feedback', '_wpnonce_gmedia_feedback');
2290
-
2291
- $data = $gmCore->_post('data');
2292
-
2293
- if(!empty($data)){
2294
- $current_user = wp_get_current_user();
2295
- $title = "Deactivate Reason: " . urldecode($data['reason']);
2296
- $content = 'Website: ' . home_url() . "\r\n\r\n";
2297
- foreach($data as $key=>$val){
2298
- $content .= ucwords(str_replace('_', ' ', $key)) . ': ' . urldecode($val) . "\r\n\r\n";
2299
- }
2300
- $headers = array(
2301
- "From: Gmedia Feedback <feedback@gmedia.gallery>",
2302
- "Reply-To: {$current_user->display_name} <{$current_user->user_email}>"
2303
- );
2304
- wp_mail('codeasily@gmail.com', $title, $content, $headers);
2305
- }
2306
-
2307
- wp_send_json_success();
2308
- }
2309
-
2310
- add_action('wp_ajax_gmedia_save_waveform', 'gmedia_save_waveform');
2311
- add_action('wp_ajax_nopriv_gmedia_save_waveform', 'gmedia_save_waveform');
2312
- function gmedia_save_waveform(){
2313
- global $gmCore, $gmDB;
2314
-
2315
- check_ajax_referer('GmediaGallery');
2316
-
2317
- $id = $gmCore->_post('id');
2318
- $peaks = $gmCore->_post('peaks');
2319
- if($id && $peaks){
2320
- $peaks_arr = json_decode($peaks);
2321
- $peaks_arr = array_filter($peaks_arr, 'is_numeric');
2322
- if(3600 !== count($peaks_arr)){
2323
- wp_send_json_error(array('peaks_cnt' => count($peaks_arr)));
2324
- }
2325
-
2326
- $gmDB->update_metadata('gmedia', $id, '_peaks', $peaks);
2327
- do_action( 'clean_gmedia_cache', $id );
2328
- wp_send_json_success(array('peaks' => $peaks));
2329
- } else{
2330
- wp_send_json_error();
2331
- }
2332
- }
2333
-
2334
- add_action('wp_ajax_gmedia_module_interaction', 'gmedia_module_interaction');
2335
- add_action('wp_ajax_nopriv_gmedia_module_interaction', 'gmedia_module_interaction');
2336
- function gmedia_module_interaction(){
2337
- global $gmDB, $gmCore;
2338
-
2339
- if(empty($_SERVER['HTTP_REFERER'])){
2340
- header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
2341
- die();
2342
- }
2343
-
2344
- $ref = $_SERVER['HTTP_REFERER'];
2345
- //$uip = str_replace('.', '', $_SERVER['REMOTE_ADDR'])
2346
- if((false === strpos($ref, get_home_url())) && (false === strpos($ref, get_site_url()))){
2347
- header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
2348
- die();
2349
- }
2350
- if(('POST' !== $_SERVER['REQUEST_METHOD']) || !isset($_SERVER['HTTP_HOST']) || !strpos(get_home_url(), $_SERVER['HTTP_HOST'])){
2351
- header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
2352
- die();
2353
- }
2354
-
2355
-
2356
- if(isset($_POST['hit']) && ($gmID = intval($_POST['hit']))){
2357
- if(null === $gmDB->get_gmedia($gmID)){
2358
- die('0');
2359
- }
2360
- $meta['views'] = $gmDB->get_metadata('gmedia', $gmID, 'views', true);
2361
- $meta['likes'] = $gmDB->get_metadata('gmedia', $gmID, 'likes', true);
2362
-
2363
- $meta = array_map('intval', $meta);
2364
- $meta = $gmCore->gm_hitcounter($gmID, $meta);
2365
-
2366
- header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
2367
- echo json_encode($meta);
2368
- die();
2369
- }
2370
-
2371
- if(isset($_POST['rate'])){
2372
- /**
2373
- * @var $uip
2374
- * @var $gmid
2375
- * @var $rate
2376
- */
2377
- extract($_POST['rate'], EXTR_OVERWRITE);
2378
- if( !intval($gmid) || (null === $gmDB->get_gmedia($gmid))){
2379
- die('0');
2380
- }
2381
- $rating = $gmDB->get_metadata('gmedia', $gmid, '_rating', true);
2382
- $rating = wp_parse_args((array) $rating, array('votes' => 0, 'value' => 0));
2383
- $old_rate = 0;
2384
-
2385
- $transient_key = 'gm_rate_day' . date('w');
2386
- $transient_value = get_transient($transient_key);
2387
- if(false !== $transient_value){
2388
- if(isset($transient_value[ $uip ][ $gmid ])){
2389
- $old_rate = $transient_value[ $uip ][ $gmid ];
2390
- }
2391
- $transient_value[ $uip ][ $gmid ] = $rate;
2392
- } else{
2393
- $transient_value = array($uip => array($gmid => $rate));
2394
- }
2395
- set_transient($transient_key, $transient_value, 18 * HOUR_IN_SECONDS);
2396
-
2397
- do_action('gmedia_rate', $gmid, $rating['value']);
2398
-
2399
- $rating['votes'] = $old_rate? $rating['votes'] : $rating['votes'] + 1;
2400
- $rating['value'] = ($rating['value'] * $rating['votes'] + $rate - $old_rate) / $rating['votes'];
2401
-
2402
- $gmDB->update_metadata('gmedia', $gmid, '_rating', $rating);
2403
-
2404
- header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
2405
- echo json_encode(array($rating));
2406
- die();
2407
- }
2408
-
2409
- die();
2410
- }
2411
-
2412
- add_action('wp_ajax_load_comments', 'gmedia_module_load_comments');
2413
- add_action('wp_ajax_nopriv_load_comments', 'gmedia_module_load_comments');
2414
- function gmedia_module_load_comments(){
2415
- global $gmCore;
2416
-
2417
- /* if(empty($_SERVER['HTTP_REFERER'])) {
2418
- header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
2419
- die();
2420
- }
2421
-
2422
- $ref = $_SERVER['HTTP_REFERER'];
2423
- //$uip = str_replace('.', '', $_SERVER['REMOTE_ADDR'])
2424
- if((false === strpos($ref, get_home_url())) && (false === strpos($ref, get_site_url()))) {
2425
- header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
2426
- die();
2427
- }
2428
- if(('POST' !== $_SERVER['REQUEST_METHOD']) || !isset($_SERVER['HTTP_HOST']) || !strpos(get_home_url(), $_SERVER['HTTP_HOST'])) {
2429
- header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
2430
- die();
2431
- }*/
2432
-
2433
- check_ajax_referer('GmediaGallery');
2434
-
2435
- $data = $gmCore->_post('data', false);
2436
-
2437
- $post_id = (int) $data['post_id'];
2438
- if($post_id){
2439
- $comments_link = apply_filters('gmedia_comments_link', add_query_arg('comments', 'show', get_permalink($post_id)), $post_id);
2440
- $comments_count = wp_count_comments($post_id);
2441
- $comments_count = $comments_count->approved;
2442
- } else{
2443
- $comments_link = '//about:blank';
2444
- $comments_count = 0;
2445
- }
2446
-
2447
- $result = array();
2448
- $result['comments_count'] = $comments_count;
2449
- $result['content'] = "<iframe class='gmedia-comments' src='{$comments_link}' frameborder='0' allowtransparency='true'>";
2450
-
2451
- header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
2452
- echo json_encode($result);
2453
-
2454
- die();
2455
- }
2456
-
2457
- add_action('wp_ajax_gmedia_get_data', 'gmedia_get_data');
2458
- add_action('wp_ajax_nopriv_gmedia_get_data', 'gmedia_get_data');
2459
- function gmedia_get_data(){
2460
- global $gmDB, $gmProcessor, $gmGallery;
2461
-
2462
- /** @var $gmProcessorLibrary */
2463
- include_once(GMEDIA_ABSPATH . 'admin/processor/class.processor.library.php');
2464
-
2465
- $gmProcessorLibrary->user_options = $gmProcessor::user_options();
2466
- $query_args = $gmProcessorLibrary->query_args();
2467
-
2468
- $cache_expiration = isset($gmGallery->options['cache_expiration'])? (int) $gmGallery->options['cache_expiration'] * HOUR_IN_SECONDS : 24 * HOUR_IN_SECONDS;
2469
- if($cache_expiration) {
2470
- $cache_key = 'gm_cache_' . md5( json_encode( $query_args ) );
2471
- $cache_value = get_transient( $cache_key );
2472
- }
2473
-
2474
- if(!empty( $cache_value)) {
2475
- header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
2476
- echo $cache_value;
2477
- } else {
2478
- $gmedia_query = $gmDB->get_gmedias( $query_args );
2479
- foreach ( $gmedia_query as &$item ) {
2480
- gmedia_item_more_data( $item );
2481
- }
2482
- $json_string = json_encode( $gmedia_query );
2483
- if($cache_expiration) {
2484
- set_transient( $cache_key, $json_string, $cache_expiration );
2485
- }
2486
-
2487
- header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ), true );
2488
- echo $json_string;
2489
- }
2490
-
2491
- die();
2492
- }
2493
-
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ add_action( 'wp_ajax_gmedia_update_data', 'gmedia_update_data' );
3
+ function gmedia_update_data() {
4
+ global $gmDB, $gmCore;
5
+ check_ajax_referer( "GmediaGallery" );
6
+ if ( ! current_user_can( 'gmedia_edit_media' ) ) {
7
+ die( '-1' );
8
+ }
9
+
10
+ $data = $gmCore->_post( 'data' );
11
+
12
+ wp_parse_str( $data, $gmedia );
13
+
14
+ if ( ! empty( $gmedia['ID'] ) ) {
15
+ $item = $gmDB->get_gmedia( $gmedia['ID'] );
16
+ if ( (int) $item->author !== get_current_user_id() ) {
17
+ if ( ! current_user_can( 'gmedia_edit_others_media' ) ) {
18
+ die( '-2' );
19
+ }
20
+ }
21
+
22
+ $gmedia['modified'] = current_time( 'mysql' );
23
+ $gmedia['mime_type'] = $item->mime_type;
24
+ $gmedia['gmuid'] = $item->gmuid;
25
+ if ( ! current_user_can( 'gmedia_delete_others_media' ) ) {
26
+ $gmedia['author'] = $item->author;
27
+ }
28
+
29
+ $gmuid = pathinfo( $item->gmuid );
30
+
31
+ $gmedia['filename'] = preg_replace( '/[^a-z0-9_\.-]+/i', '_', $gmedia['filename'] );
32
+ if ( ( $gmedia['filename'] !== $gmuid['filename'] ) && ( current_user_can( 'gmedia_delete_others_media' ) || ( (int) $item->author === get_current_user_id() ) ) ) {
33
+ $fileinfo = $gmCore->fileinfo( $gmedia['filename'] . '.' . $gmuid['extension'] );
34
+ if ( false !== $fileinfo ) {
35
+ if ( 'image' === $fileinfo['dirname'] && file_is_displayable_image( $fileinfo['dirpath'] . '/' . $item->gmuid ) ) {
36
+ if ( is_file( $fileinfo['dirpath_original'] . '/' . $item->gmuid ) ) {
37
+ @rename( $fileinfo['dirpath_original'] . '/' . $item->gmuid, $fileinfo['filepath_original'] );
38
+ }
39
+ @rename( $fileinfo['dirpath_thumb'] . '/' . $item->gmuid, $fileinfo['filepath_thumb'] );
40
+ }
41
+ if ( @rename( $fileinfo['dirpath'] . '/' . $item->gmuid, $fileinfo['filepath'] ) ) {
42
+ $gmedia['gmuid'] = $fileinfo['basename'];
43
+ }
44
+ }
45
+ }
46
+ if ( ! current_user_can( 'gmedia_terms' ) ) {
47
+ unset( $gmedia['terms'] );
48
+ }
49
+
50
+ $id = $gmDB->insert_gmedia( $gmedia );
51
+ if ( ! is_wp_error( $id ) ) {
52
+ // Meta Stuff.
53
+ if ( isset( $gmedia['meta'] ) && is_array( $gmedia['meta'] ) ) {
54
+ $meta_error = [];
55
+ foreach ( $gmedia['meta'] as $key => $value ) {
56
+ if ( $gmCore->is_digit( $key ) ) {
57
+ $mid = (int) $key;
58
+ //$value = wp_unslash( $value );
59
+ if ( ! ( $meta = $gmDB->get_metadata_by_mid( 'gmedia', $mid ) ) ) {
60
+ $meta_error[] = [
61
+ 'error' => 'no_meta',
62
+ 'message' => __( 'No record in DataBase.', 'grand-media' ),
63
+ 'meta_id' => $mid,
64
+ 'meta_key' => $meta->meta_key,
65
+ ];
66
+ continue;
67
+ }
68
+ if ( '' === trim( $value ) ) {
69
+ $meta_error[] = [
70
+ 'error' => 'empty_value',
71
+ 'message' => __( 'Please provide a custom field value.', 'grand-media' ),
72
+ 'meta_id' => $mid,
73
+ 'meta_key' => $meta->meta_key,
74
+ 'meta_value' => $meta->meta_value,
75
+ ];
76
+ continue;
77
+ }
78
+
79
+ if ( $meta->meta_value !== $value ) {
80
+ if ( ! ( $u = $gmDB->update_metadata_by_mid( 'gmedia', $mid, $value ) ) ) {
81
+ $meta_error[] = [
82
+ 'error' => 'meta_update',
83
+ 'message' => __( 'Something goes wrong.', 'grand-media' ),
84
+ 'meta_id' => $mid,
85
+ 'meta_key' => $meta->meta_key,
86
+ 'meta_value' => $meta->meta_value,
87
+ ];
88
+ }
89
+ }
90
+ } elseif ( '_' === $key[0] ) {
91
+ if ( '_cover' === $key ) {
92
+ $value = ltrim( $value, '#' );
93
+ } elseif ( '_gps' === $key ) {
94
+ if ( $value ) {
95
+ $latlng = explode( ',', $value );
96
+ $value = [ 'lat' => trim( $latlng[0] ), 'lng' => trim( $latlng[1] ) ];
97
+ }
98
+ }
99
+ $value = apply_filters( 'gmedia_protected_meta_value', $value, $key, $id );
100
+ $gmDB->update_metadata( 'gmedia', $id, $key, $value );
101
+ }
102
+ }
103
+ }
104
+ $result = $gmDB->get_gmedia( $id );
105
+ } else {
106
+ $result = $gmDB->get_gmedia( $id );
107
+ }
108
+
109
+ gmedia_item_more_data( $result );
110
+ if ( 'image' !== $result->type ) {
111
+ include_once GMEDIA_ABSPATH . 'admin/pages/library/functions.php';
112
+ $result->thumbnail = gmedia_item_thumbnail( $result );
113
+ }
114
+
115
+ if ( current_user_can( 'gmedia_terms' ) ) {
116
+ if ( ! empty( $gmedia['terms']['gmedia_album'] ) ) {
117
+ if ( isset( $gmedia['gmedia_album_order'] ) ) {
118
+ $album = $gmDB->get_the_gmedia_terms( $id, 'gmedia_album' );
119
+ if ( $album ) {
120
+ $album = reset( $album );
121
+ if ( (int) $gmedia['gmedia_album_order'] !== (int) $album->gmedia_order ) {
122
+ $gmDB->update_term_sortorder( $album->term_id, [ $id => (int) $gmedia['gmedia_album_order'] ] );
123
+ $result->gmedia_album_order = (int) $gmedia['gmedia_album_order'];
124
+ }
125
+ }
126
+ }
127
+ $alb_id = $gmedia['terms']['gmedia_album'];
128
+ $alb = $gmDB->get_term( $alb_id, 'gmedia_album' );
129
+ $result->album_status = $alb ? $alb->status : 'none';
130
+ } else {
131
+ $result->album_status = 'none';
132
+ }
133
+ }
134
+ if ( ! empty( $meta_error ) ) {
135
+ $result->meta_error = $meta_error;
136
+ }
137
+ gmedia_delete_transients( 'gm_cache' );
138
+
139
+ header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ), true );
140
+ echo wp_json_encode( $result );
141
+ }
142
+
143
+ die();
144
+ }
145
+
146
+ add_action( 'wp_ajax_gmedit_save', 'gmedit_save' );
147
+ function gmedit_save() {
148
+ global $gmDB, $gmCore, $gmGallery;
149
+ check_ajax_referer( 'gmedia_edit', '_wpnonce_edit' );
150
+ if ( ! current_user_can( 'gmedia_edit_media' ) ) {
151
+ die( '-1' );
152
+ }
153
+
154
+ $gmedia = [];
155
+ $fail = '';
156
+ $success = '';
157
+ $gmid = $gmCore->_post( 'id' );
158
+ $image = $gmCore->_post( 'image' );
159
+ $applyto = $gmCore->_post( 'applyto', 'web_thumb' );
160
+
161
+ $item = $gmDB->get_gmedia( $gmid );
162
+ if ( ! empty( $item ) ) {
163
+ if ( (int) $item->author !== get_current_user_id() ) {
164
+ if ( ! current_user_can( 'gmedia_edit_others_media' ) ) {
165
+ die( '-2' );
166
+ }
167
+ }
168
+ $meta = $gmDB->get_metadata( 'gmedia', $item->ID );
169
+ $metadata = $meta['_metadata'][0];
170
+ $gmedia['ID'] = $gmid;
171
+ $gmedia['date'] = $item->date;
172
+ $gmedia['modified'] = current_time( 'mysql' );
173
+ $gmedia['author'] = $item->author;
174
+
175
+ $thumbimg = $gmGallery->options['thumb'];
176
+
177
+ $image = $gmCore->process_gmedit_image( $image );
178
+
179
+ $fileinfo = $gmCore->fileinfo( $item->gmuid, false );
180
+
181
+ $size = @getimagesize( $fileinfo['filepath'] );
182
+
183
+ do {
184
+ $extensions = [ '1' => 'GIF', '2' => 'JPG', '3' => 'PNG', '6' => 'BMP' ];
185
+ if ( function_exists( 'memory_get_usage' ) ) {
186
+ switch ( $extensions[ $size[2] ] ) {
187
+ case 'GIF':
188
+ $CHANNEL = 1;
189
+ break;
190
+ case 'JPG':
191
+ $CHANNEL = $size['channels'];
192
+ break;
193
+ case 'PNG':
194
+ $CHANNEL = 3;
195
+ break;
196
+ case 'BMP':
197
+ default:
198
+ $CHANNEL = 6;
199
+ break;
200
+ }
201
+ $MB = 1048576; // number of bytes in 1M
202
+ $K64 = 65536; // number of bytes in 64K
203
+ $TWEAKFACTOR = 1.8; // Or whatever works for you
204
+ $memoryNeeded = round( ( $size[0] * $size[1] * $size['bits'] * $CHANNEL / 8 + $K64 ) * $TWEAKFACTOR );
205
+ $memoryNeeded = memory_get_usage() + $memoryNeeded;
206
+ $current_limit = @ini_get( 'memory_limit' );
207
+ $current_limit_int = intval( $current_limit );
208
+ if ( false !== strpos( $current_limit, 'M' ) ) {
209
+ $current_limit_int *= $MB;
210
+ }
211
+ if ( false !== strpos( $current_limit, 'G' ) ) {
212
+ $current_limit_int *= 1024;
213
+ }
214
+
215
+ if ( - 1 !== $current_limit && $memoryNeeded > $current_limit_int ) {
216
+ $newLimit = $current_limit_int / $MB + ceil( ( $memoryNeeded - $current_limit_int ) / $MB );
217
+ if ( $newLimit < 256 ) {
218
+ $newLimit = 256;
219
+ }
220
+ @ini_set( 'memory_limit', $newLimit . 'M' );
221
+ }
222
+ }
223
+
224
+ $no_original = false;
225
+ if ( 'thumb' === $applyto ) {
226
+ $editfile = $fileinfo['filepath_thumb'];
227
+ } else {
228
+ $editfile = $fileinfo['filepath'];
229
+ if ( ( 'JPG' === $extensions[ $size[2] ] ) && ! is_file( $fileinfo['filepath_original'] ) ) {
230
+ $no_original = true;
231
+ @copy( $editfile, $fileinfo['filepath_original'] );
232
+ }
233
+ }
234
+ if ( ! @file_put_contents( $editfile, $image['data'] ) ) {
235
+ $fail = $fileinfo['basename'] . ": " . __( 'Can\'t write to file. Permission denied', 'grand-media' );
236
+ break;
237
+ }
238
+
239
+ $modified = isset( $meta['_modified'][0] ) ? ( intval( $meta['_modified'][0] ) + 1 ) : 1;
240
+ $gmDB->update_metadata( $meta_type = 'gmedia', $item->ID, $meta_key = '_modified', $modified );
241
+
242
+ // Web-image.
243
+ if ( 'thumb' !== $applyto ) {
244
+ if ( 'JPG' === $extensions[ $size[2] ] ) {
245
+ $gmCore->copy_exif( $fileinfo['filepath_original'], $fileinfo['filepath'] );
246
+ if ( $no_original ) {
247
+ @unlink( $fileinfo['filepath_original'] );
248
+ }
249
+ }
250
+ }
251
+ // Thumbnail.
252
+ if ( 'web_thumb' === $applyto ) {
253
+ $size_ratio = $size[0] / $size[1];
254
+ $thumbimg['resize'] = ( ( ( 1 >= $size_ratio ) && ( $thumbimg['width'] > $size[0] ) ) || ( ( 1 <= $size_ratio ) && ( $thumbimg['height'] > $size[1] ) ) ) ? false : true;
255
+ if ( $thumbimg['resize'] ) {
256
+ $editor = wp_get_image_editor( $editfile );
257
+ if ( is_wp_error( $editor ) ) {
258
+ $fail = $fileinfo['basename'] . " (wp_get_image_editor): " . $editor->get_error_message();
259
+ break;
260
+ }
261
+
262
+ $editor->set_quality( $thumbimg['quality'] );
263
+ $ed_size = $editor->get_size();
264
+ $ed_ratio = $ed_size['width'] / $ed_size['height'];
265
+ if ( 1 > $ed_ratio ) {
266
+ $resized = $editor->resize( $thumbimg['width'], 0, $thumbimg['crop'] );
267
+ } else {
268
+ $resized = $editor->resize( 0, $thumbimg['height'], $thumbimg['crop'] );
269
+ }
270
+ if ( is_wp_error( $resized ) ) {
271
+ $fail = $fileinfo['basename'] . " (" . $resized->get_error_code() . " | editor->resize->thumb({$thumbimg['width']}, {$thumbimg['height']}, {$thumbimg['crop']})) applyto-{$applyto}: " . $resized->get_error_message();
272
+ break;
273
+ }
274
+
275
+ $thumbis = false;
276
+ if ( is_file( $fileinfo['filepath_thumb'] ) ) {
277
+ $thumbis = true;
278
+ rename( $fileinfo['filepath_thumb'], $fileinfo['filepath_thumb'] . '.tmp' );
279
+ }
280
+ $saved = $editor->save( $fileinfo['filepath_thumb'] );
281
+ if ( is_wp_error( $saved ) ) {
282
+ if ( $thumbis ) {
283
+ rename( $fileinfo['filepath_thumb'] . '.tmp', $fileinfo['filepath_thumb'] );
284
+ }
285
+ $fail = $fileinfo['basename'] . " (" . $saved->get_error_code() . " | editor->save->thumb): " . $saved->get_error_message();
286
+ break;
287
+ }
288
+
289
+ } else {
290
+ @copy( $fileinfo['filepath'], $fileinfo['filepath_thumb'] );
291
+ }
292
+ }
293
+
294
+
295
+ $id = $gmDB->insert_gmedia( $gmedia );
296
+
297
+ $new_metadata = $gmDB->generate_gmedia_metadata( $id, $fileinfo );
298
+ $metadata['web'] = $new_metadata['web'];
299
+ $metadata['original'] = $new_metadata['original'];
300
+ $metadata['thumb'] = $new_metadata['thumb'];
301
+
302
+ $gmDB->update_metadata( $meta_type = 'gmedia', $id, $meta_key = '_metadata', $metadata );
303
+
304
+ $success = sprintf( __( 'Image "%d" updated', 'grand-media' ), $id );
305
+ } while ( 0 );
306
+
307
+ if ( empty( $fail ) ) {
308
+ $out = [ 'msg' => $gmCore->alert( 'info', $success ), 'modified' => $gmedia['modified'] ];
309
+ } else {
310
+ $out = [ 'error' => $gmCore->alert( 'danger', $fail ) ];
311
+ }
312
+
313
+ header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ), true );
314
+ echo wp_json_encode( $out );
315
+ }
316
+
317
+ die();
318
+ }
319
+
320
+ add_action( 'wp_ajax_gmedit_restore', 'gmedit_restore' );
321
+ function gmedit_restore() {
322
+ global $gmCore;
323
+ check_ajax_referer( 'gmedia_edit', '_wpnonce_edit' );
324
+ if ( ! current_user_can( 'gmedia_edit_media' ) ) {
325
+ die( '-1' );
326
+ }
327
+
328
+ $gmid = $gmCore->_post( 'id' );
329
+ $out = $gmCore->recreate_images_from_original( $gmid );
330
+
331
+ header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ), true );
332
+ echo wp_json_encode( $out );
333
+
334
+ die();
335
+ }
336
+
337
+ add_action( 'wp_ajax_gmedia_get_modal', 'gmedia_get_modal' );
338
+ function gmedia_get_modal() {
339
+ global $gmDB, $gmCore, $gmGallery;
340
+ check_ajax_referer( "GmediaGallery" );
341
+ $user_ID = get_current_user_id();
342
+ $button_class = 'btn-primary';
343
+ $gm_terms = [];
344
+ $modal = $gmCore->_post( 'modal' );
345
+ $ckey = $gmCore->_post( 'ckey' );
346
+ switch ( $modal ) {
347
+ case 'quick_gallery':
348
+ if ( ! current_user_can( 'gmedia_gallery_manage' ) ) {
349
+ die( '-1' );
350
+ }
351
+ //$ckey = "gmedia_library";
352
+ $modal_title = __( 'Quick Gallery from selected items', 'grand-media' );
353
+ $modal_button = __( 'Create Quick Gallery', 'grand-media' );
354
+ break;
355
+ case 'quick_gallery_stack':
356
+ if ( ! current_user_can( 'gmedia_gallery_manage' ) ) {
357
+ die( '-1' );
358
+ }
359
+ //$ckey = "gmedia_{$user_ID}_libstack";
360
+ $modal_title = __( 'Quick Gallery from Stack', 'grand-media' );
361
+ $modal_button = __( 'Create Quick Gallery', 'grand-media' );
362
+ break;
363
+ case 'exclude_categories':
364
+ case 'filter_categories':
365
+ $modal_title = __( 'Show Images from Categories', 'grand-media' );
366
+ $modal_button = __( 'Show Selected', 'grand-media' );
367
+ break;
368
+ case 'assign_category':
369
+ if ( ! current_user_can( 'gmedia_terms' ) ) {
370
+ die( '-1' );
371
+ }
372
+ $modal_title = __( 'Assign Category for Selected Images', 'grand-media' );
373
+ $modal_button = __( 'Assign Category', 'grand-media' );
374
+ break;
375
+ case 'unassign_category':
376
+ if ( ! current_user_can( 'gmedia_terms' ) ) {
377
+ die( '-1' );
378
+ }
379
+ $button_class = 'btn-danger';
380
+ $modal_title = __( 'Unassign Categories from Selected Items', 'grand-media' );
381
+ $modal_button = __( 'Unassign Categories', 'grand-media' );
382
+ break;
383
+ case 'exclude_albums':
384
+ case 'filter_albums':
385
+ $modal_title = __( 'Filter Albums', 'grand-media' );
386
+ $modal_button = __( 'Show Selected', 'grand-media' );
387
+ break;
388
+ case 'assign_album':
389
+ if ( ! current_user_can( 'gmedia_terms' ) ) {
390
+ die( '-1' );
391
+ }
392
+ $modal_title = __( 'Assign Album for Selected Items', 'grand-media' );
393
+ $modal_button = __( 'Assign Album', 'grand-media' );
394
+ break;
395
+ case 'exclude_tags':
396
+ case 'filter_tags':
397
+ $modal_title = __( 'Filter by Tags', 'grand-media' );
398
+ $modal_button = __( 'Show Selected', 'grand-media' );
399
+ break;
400
+ case 'add_tags':
401
+ if ( ! current_user_can( 'gmedia_terms' ) ) {
402
+ die( '-1' );
403
+ }
404
+ $modal_title = __( 'Add Tags to Selected Items', 'grand-media' );
405
+ $modal_button = __( 'Add Tags', 'grand-media' );
406
+ break;
407
+ case 'delete_tags':
408
+ if ( ! current_user_can( 'gmedia_terms' ) ) {
409
+ die( '-1' );
410
+ }
411
+ $button_class = 'btn-danger';
412
+ $modal_title = __( 'Delete Tags from Selected Items', 'grand-media' );
413
+ $modal_button = __( 'Delete Tags', 'grand-media' );
414
+ break;
415
+ case 'custom_filter':
416
+ $modal_title = __( 'Custom Filters', 'grand-media' );
417
+ $modal_button = __( 'Show Selected', 'grand-media' );
418
+ break;
419
+ case 'filter_author':
420
+ $modal_title = __( 'Filter by Author', 'grand-media' );
421
+ if ( $gmCore->caps['gmedia_show_others_media'] ) {
422
+ $modal_button = __( 'Show Selected', 'grand-media' );
423
+ } else {
424
+ $modal_button = false;
425
+ }
426
+ break;
427
+ case 'select_author':
428
+ $modal_title = __( 'Select Author', 'grand-media' );
429
+ if ( $gmCore->caps['gmedia_show_others_media'] ) {
430
+ $modal_button = __( 'Select', 'grand-media' );
431
+ } else {
432
+ $modal_button = false;
433
+ }
434
+ break;
435
+ case 'batch_edit':
436
+ if ( ! current_user_can( 'gmedia_edit_media' ) ) {
437
+ die( '-1' );
438
+ }
439
+ $modal_title = __( 'Batch Edit', 'grand-media' );
440
+ $modal_button = __( 'Batch Save', 'grand-media' );
441
+ break;
442
+ default:
443
+ $modal_title = ' ';
444
+ $modal_button = false;
445
+ break;
446
+ }
447
+
448
+ $form_action = ! empty( $_SERVER['HTTP_REFERER'] ) ? $gmCore->get_admin_url( [], [], $_SERVER['HTTP_REFERER'] ) : '';
449
+
450
+ // @formatter:off
451
+ ?>
452
+ <form class="modal-content" id="ajax-modal-form" autocomplete="off" method="post" action="<?php echo esc_url( $form_action ); ?>">
453
+ <div class="modal-header">
454
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
455
+ <h4 class="modal-title"><?php echo esc_html( $modal_title ); ?></h4>
456
+ </div>
457
+ <div class="modal-body">
458
+ <?php
459
+ switch ( $modal ) {
460
+ case 'quick_gallery':
461
+ case 'quick_gallery_stack':
462
+ if ( ! empty( $ckey ) ) {
463
+ $selected_in_library = isset( $_COOKIE[ $ckey ] ) ? str_replace( '.', ',', $_COOKIE[ $ckey ] ) : '';
464
+ }
465
+ if ( empty( $selected_in_library ) ) {
466
+ _e( 'No selected Gmedia. Select at least one item in library.', 'grand-media' );
467
+ break;
468
+ }
469
+ $gmedia_modules = get_gmedia_modules( false );
470
+ ?>
471
+ <div class="form-group">
472
+ <label><?php _e( 'Gallery Name', 'grand-media' ); ?></label>
473
+ <input type="text" class="form-control input-sm" name="gallery[name]" placeholder="<?php esc_attr_e( __( 'Gallery Name', 'grand-media' ) ); ?>" value="" required="required"/>
474
+ </div>
475
+ <div class="form-group">
476
+ <label><?php _e( 'Modue', 'grand-media' ); ?></label>
477
+ <select class="form-control input-sm" name="gallery[module]">
478
+ <?php foreach ( $gmedia_modules['in'] as $mfold => $module ) {
479
+ echo '<optgroup label="' . esc_attr( $module['title'] ) . '">';
480
+ $presets = $gmDB->get_terms( 'gmedia_module', [ 'status' => $mfold ] );
481
+ $selected = selected( $gmGallery->options['default_gmedia_module'], esc_attr( $mfold ), false );
482
+ $option = [];
483
+ $option[] = '<option ' . $selected . ' value="' . esc_attr( $mfold ) . '">' . $module['title'] . ' - ' . __( 'Default Settings' ) . '</option>';
484
+ foreach ( $presets as $preset ) {
485
+ if ( ! (int) $preset->global && '[' . $mfold . ']' === $preset->name ) {
486
+ continue;
487
+ }
488
+ $selected = selected( $gmGallery->options['default_gmedia_module'], $preset->term_id, false );
489
+ $by_author = '';
490
+ if ( (int) $preset->global ) {
491
+ $by_author = ' [' . get_the_author_meta( 'display_name', $preset->global ) . ']';
492
+ }
493
+ if ( '[' . $mfold . ']' === $preset->name ) {
494
+ $option[] = '<option ' . $selected . ' value="' . $preset->term_id . '">' . $module['title'] . $by_author . ' - ' . __( 'Default Settings' ) . '</option>';
495
+ } else {
496
+ $preset_name = str_replace( '[' . $mfold . '] ', '', $preset->name );
497
+ $option[] = '<option ' . $selected . ' value="' . $preset->term_id . '">' . $module['title'] . $by_author . ' - ' . $preset_name . '</option>';
498
+ }
499
+ }
500
+ echo implode( '', $option );
501
+ echo '</optgroup>';
502
+ } ?>
503
+ </select>
504
+ </div>
505
+ <div class="form-group">
506
+ <label><?php _e( 'Selected IDs', 'grand-media' ); ?></label>
507
+ <input type="text" name="gallery[query][gmedia__in]" class="form-control input-sm" value="<?php echo esc_attr( $selected_in_library ); ?>" required="required"/>
508
+ </div>
509
+ <?php
510
+ break;
511
+ case 'exclude_albums':
512
+ case 'filter_albums':
513
+ if ( $gmCore->caps['gmedia_show_others_media'] ) {
514
+ $args = [];
515
+ } else {
516
+ $args = [
517
+ 'global' => [ 0, $user_ID ],
518
+ 'orderby' => 'global_desc_name',
519
+ ];
520
+ }
521
+ $gm_terms = $gmDB->get_terms( 'gmedia_album', $args );
522
+ ?>
523
+ <div class="checkbox"><label><input type="checkbox" name="alb[]" value="0"> <?php _e( 'No Album', 'grand-media' ); ?></label></div>
524
+ <hr/>
525
+ <?php
526
+ if ( count( $gm_terms ) ) {
527
+ foreach ( $gm_terms as $term ) {
528
+ $author_name = '';
529
+ if ( $term->global ) {
530
+ if ( $gmCore->caps['gmedia_show_others_media'] ) {
531
+ $author_name .= sprintf( __( 'by %s', 'grand-media' ), esc_html( get_the_author_meta( 'display_name', $term->global ) ) );
532
+ }
533
+ } else {
534
+ $author_name .= '(' . __( 'shared', 'grand-media' ) . ')';
535
+ }
536
+ if ( 'publish' !== $term->status ) {
537
+ $author_name .= ' [' . $term->status . ']';
538
+ }
539
+ if ( $author_name ) {
540
+ $author_name = " <small>{$author_name}</small>";
541
+ }
542
+ ?>
543
+ <div class="checkbox">
544
+ <label><input type="checkbox" name="alb[]" value="<?php echo absint( $term->term_id ); ?>"> <?php echo esc_html( $term->name ) . $author_name; ?></label>
545
+ <span class="badge pull-right"><?php echo absint( $term->count ); ?></span>
546
+ </div>
547
+ <?php
548
+ }
549
+ } else {
550
+ $modal_button = false;
551
+ }
552
+ break;
553
+ case 'assign_album':
554
+ if ( $gmCore->caps['gmedia_edit_others_media'] ) {
555
+ $args = [];
556
+ } else {
557
+ $args = [
558
+ 'global' => [ 0, $user_ID ],
559
+ 'orderby' => 'global_desc_name',
560
+ ];
561
+ }
562
+ $gm_terms = $gmDB->get_terms( 'gmedia_album', $args );
563
+
564
+ $terms_album = '';
565
+ if ( count( $gm_terms ) ) {
566
+ foreach ( $gm_terms as $term ) {
567
+ $author_name = '';
568
+ if ( $term->global ) {
569
+ if ( $gmCore->caps['gmedia_edit_others_media'] ) {
570
+ $author_name .= ' &nbsp; ' . sprintf( __( 'by %s', 'grand-media' ), esc_html( get_the_author_meta( 'display_name', $term->global ) ) );
571
+ }
572
+ } else {
573
+ $author_name .= ' &nbsp; (' . __( 'shared', 'grand-media' ) . ')';
574
+ }
575
+ if ( 'publish' !== $term->status ) {
576
+ $author_name .= ' [' . $term->status . ']';
577
+ }
578
+ $terms_album .= '<option value="' . $term->term_id . '" data-count="' . $term->count . '" data-name="' . esc_html( $term->name ) . '" data-meta="' . $author_name . '">' . esc_html( $term->name ) . $author_name . '</option>' . "\n";
579
+ }
580
+ }
581
+ ?>
582
+ <div class="form-group">
583
+ <label><?php _e( 'Move to Album', 'grand-media' ); ?> </label>
584
+ <select id="combobox_gmedia_album" name="alb" class="form-control" placeholder="<?php _e( 'Album Name...', 'grand-media' ); ?>">
585
+ <option></option>
586
+ <option value="0"><?php _e( 'No Album', 'grand-media' ); ?></option>
587
+ <?php echo $terms_album; ?>
588
+ </select>
589
+ <small class="help-block" style="margin-top:0;"><?php _e( 'Choose "No Album" to delete albums from selected items', 'grand-media' ); ?></small>
590
+ </div>
591
+ <div class="form-group">
592
+ <div class="checkbox">
593
+ <label><input type="checkbox" name="status_global" value="1" checked> <?php _e( 'Make status of selected items be the same as Album status', 'grand-media' ); ?>
594
+ </label></div>
595
+ </div>
596
+ <script type="text/javascript">
597
+ jQuery(function($) {
598
+ var albums = $('#combobox_gmedia_album');
599
+ var albums_data = $('option', albums);
600
+ //noinspection JSDuplicatedDeclaration
601
+ albums.selectize({
602
+ <?php if($gmCore->caps['gmedia_album_manage']){ ?>
603
+ create: function(input) {
604
+ return {
605
+ value: input,
606
+ text: input
607
+ };
608
+ },
609
+ createOnBlur: true,
610
+ <?php } else{ ?>
611
+ create: false,
612
+ <?php } ?>
613
+ persist: false,
614
+ render: {
615
+ item: function(item, escape) {
616
+ if (0 === (parseInt(item.value, 10) || 0)) {
617
+ return '<div>' + escape(item.text) + '</div>';
618
+ }
619
+ if (item.$order) {
620
+ var data = $(albums_data[item.$order]).data();
621
+ return '<div>' + escape(data.name) + ' <small>' + escape(data.meta) + '</small></div>';
622
+ }
623
+ },
624
+ option: function(item, escape) {
625
+ if (0 === (parseInt(item.value) || 0)) {
626
+ return '<div>' + escape(item.text) + '</div>';
627
+ }
628
+ if (item.$order) {
629
+ var data = $(albums_data[item.$order]).data();
630
+ return '<div>' + escape(data.name) + ' <small>' + escape(data.meta) + '</small>' + ' <span class="badge pull-right">' + escape(data.count) + '</span></div>';
631
+ }
632
+ }
633
+ }
634
+ });
635
+ });
636
+ </script>
637
+ <?php
638
+ break;
639
+ case 'exclude_categories':
640
+ case 'filter_categories':
641
+ $gm_terms = $gmDB->get_terms( 'gmedia_category' );
642
+ ?>
643
+ <div class="checkbox"><label><input type="checkbox" name="cat[]" value="0"> <?php _e( 'Uncategorized', 'grand-media' ); ?></label></div>
644
+ <?php
645
+ if ( count( $gm_terms ) ) {
646
+ foreach ( $gm_terms as $term ) {
647
+ if ( $term->count ) {
648
+ ?>
649
+ <div class="checkbox">
650
+ <label><input type="checkbox" name="cat[]" value="<?php echo absint( $term->term_id ); ?>"> <?php echo esc_html( $term->name ); ?></label>
651
+ <span class="badge pull-right"><?php echo absint( $term->count ); ?></span>
652
+ </div>
653
+ <?php
654
+ }
655
+ }
656
+ }
657
+ break;
658
+ case 'assign_category':
659
+ $gm_terms = $gmDB->get_terms( 'gmedia_category', [ 'fields' => 'names_count' ] );
660
+ $gm_terms = array_values( $gm_terms );
661
+ ?>
662
+ <div class="form-group">
663
+ <input id="combobox_gmedia_category" name="cat_names" class="form-control input-sm" value="" placeholder="<?php _e( 'Add to Categories...', 'grand-media' ); ?>"/>
664
+ </div>
665
+ <script type="text/javascript">
666
+ jQuery(function($) {
667
+ var gm_terms = <?php echo wp_json_encode( $gm_terms ); ?>;
668
+ //noinspection JSUnusedAssignment
669
+ var items = gm_terms.map(function(x) {
670
+ //noinspection JSUnresolvedVariable
671
+ return {id: x.term_id, name: x.name, count: x.count};
672
+ });
673
+ //noinspection JSDuplicatedDeclaration
674
+ $('#combobox_gmedia_category').selectize({
675
+ delimiter: ',',
676
+ maxItems: null,
677
+ openOnFocus: true,
678
+ labelField: 'name',
679
+ hideSelected: true,
680
+ options: items,
681
+ searchField: ['name'],
682
+ valueField: 'name',
683
+ persist: false,
684
+ <?php if($gmCore->caps['gmedia_category_manage']){ ?>
685
+ createOnBlur: true,
686
+ create: function(input) {
687
+ return {
688
+ name: input
689
+ };
690
+ },
691
+ <?php } else{ ?>
692
+ create: false,
693
+ <?php } ?>
694
+ render: {
695
+ item: function(item, escape) {
696
+ return '<div>' + escape(item.name) + '</div>';
697
+ },
698
+ option: function(item, escape) {
699
+ return '<div>' + escape(item.name) + ' <span class="badge">' + escape(item.count) + '</span></div>';
700
+ }
701
+ }
702
+ });
703
+ });
704
+ </script>
705
+ <?php
706
+ break;
707
+ case 'unassign_category':
708
+ // get selected items in Gmedia Library.
709
+ $selected_items = ! empty( $ckey ) ? array_filter( explode( '.', $_COOKIE[ $ckey ] ), 'is_numeric' ) : false;
710
+ if ( ! empty( $selected_items ) ) {
711
+ $gm_terms = $gmDB->get_gmedia_terms( $selected_items, 'gmedia_category' );
712
+ }
713
+ if ( count( $gm_terms ) ){
714
+ foreach ( $gm_terms as $term ){
715
+ ?>
716
+ <div class="checkbox">
717
+ <label><input type="checkbox" name="category_id[]" value="<?php echo absint( $term->term_id ); ?>"> <?php echo esc_html( $term->name ); ?></label>
718
+ <span class="badge pull-right"><?php echo absint( $term->count ); ?></span>
719
+ </div>
720
+ <?php
721
+ }
722
+ } else {
723
+ $modal_button = false; ?>
724
+ <p class="noterms"><?php _e( 'No categories', 'grand-media' ); ?></p>
725
+ <?php
726
+ }
727
+ break;
728
+ case 'exclude_tags':
729
+ case 'filter_tags':
730
+ $gm_terms = $gmDB->get_terms( 'gmedia_tag', [ 'fields' => 'names_count' ] );
731
+ $gm_terms = array_values( $gm_terms );
732
+ if ( count( $gm_terms ) ){
733
+ ?>
734
+ <div class="form-group">
735
+ <input id="combobox_gmedia_tag" name="tag_ids" class="form-control input-sm" value="" placeholder="<?php _e( 'Filter Tags...', 'grand-media' ); ?>"/>
736
+ </div>
737
+ <script type="text/javascript">
738
+ jQuery(function($) {
739
+ var gm_terms = <?php echo json_encode( $gm_terms ); ?>;
740
+ //noinspection JSUnusedAssignment
741
+ var items = gm_terms.map(function(x) {
742
+ //noinspection JSUnresolvedVariable
743
+ return {id: x.term_id, name: x.name, count: x.count};
744
+ });
745
+ $('#combobox_gmedia_tag').selectize({
746
+ delimiter: ',',
747
+ maxItems: null,
748
+ openOnFocus: true,
749
+ labelField: 'name',
750
+ hideSelected: true,
751
+ options: items,
752
+ searchField: ['name'],
753
+ valueField: 'id',
754
+ create: false,
755
+ render: {
756
+ item: function(item, escape) {
757
+ return '<div>' + escape(item.name) + '</div>';
758
+ },
759
+ option: function(item, escape) {
760
+ return '<div>' + escape(item.name) + ' <span class="badge">' + escape(item.count) + '</span></div>';
761
+ }
762
+ }
763
+ });
764
+ });
765
+ </script>
766
+ <?php
767
+ } else {
768
+ $modal_button = false;
769
+ ?>
770
+ <p class="noterms"><?php _e( 'No tags', 'grand-media' ); ?></p>
771
+ <?php
772
+ }
773
+ break;
774
+ case 'add_tags':
775
+ $gm_terms = $gmDB->get_terms( 'gmedia_tag', [ 'fields' => 'names_count' ] );
776
+ $gm_terms = array_values( $gm_terms );
777
+ ?>
778
+ <div class="form-group">
779
+ <input id="combobox_gmedia_tag" name="tag_names" class="form-control input-sm" value="" placeholder="<?php _e( 'Add Tags...', 'grand-media' ); ?>"/>
780
+ </div>
781
+ <div class="checkbox">
782
+ <label><input type="checkbox" name="iptc_tags" value="1"> <?php _e( 'Import IPTC Keywords from selected images to Tags' ); ?></label>
783
+ </div>
784
+ <script type="text/javascript">
785
+ jQuery(function($) {
786
+ var gm_terms = <?php echo json_encode( $gm_terms ); ?>;
787
+ //noinspection JSUnusedAssignment
788
+ var items = gm_terms.map(function(x) {
789
+ //noinspection JSUnresolvedVariable
790
+ return {id: x.term_id, name: x.name, count: x.count};
791
+ });
792
+ //noinspection JSDuplicatedDeclaration
793
+ $('#combobox_gmedia_tag').selectize({
794
+ delimiter: ',',
795
+ maxItems: null,
796
+ openOnFocus: true,
797
+ labelField: 'name',
798
+ hideSelected: true,
799
+ options: items,
800
+ searchField: ['name'],
801
+ valueField: 'name',
802
+ persist: false,
803
+ <?php if($gmCore->caps['gmedia_tag_manage']){ ?>
804
+ createOnBlur: true,
805
+ create: function(input) {
806
+ return {
807
+ name: input
808
+ };
809
+ },
810
+ <?php } else{ ?>
811
+ create: false,
812
+ <?php } ?>
813
+ render: {
814
+ item: function(item, escape) {
815
+ return '<div>' + escape(item.name) + '</div>';
816
+ },
817
+ option: function(item, escape) {
818
+ return '<div>' + escape(item.name) + ' <span class="badge">' + escape(item.count) + '</span></div>';
819
+ }
820
+ }
821
+ });
822
+ });
823
+ </script>
824
+ <?php
825
+ break;
826
+ case 'delete_tags':
827
+ // get selected items in Gmedia Library.
828
+ $selected_items = ! empty( $ckey ) ? array_filter( explode( '.', $_COOKIE[ $ckey ] ), 'is_numeric' ) : false;
829
+ if ( ! empty( $selected_items ) ) {
830
+ $gm_terms = $gmDB->get_gmedia_terms( $selected_items, 'gmedia_tag' );
831
+ }
832
+ if ( count( $gm_terms ) ){
833
+ foreach ( $gm_terms as $term ){
834
+ ?>
835
+ <div class="checkbox">
836
+ <label><input type="checkbox" name="tag_id[]" value="<?php echo absint( $term->term_id ); ?>"> <?php echo esc_html( $term->name ); ?></label>
837
+ <span class="badge pull-right"><?php echo absint( $term->count ); ?></span>
838
+ </div>
839
+ <?php
840
+ }
841
+ } else {
842
+ $modal_button = false;
843
+ ?>
844
+ <p class="noterms"><?php _e( 'No tags', 'grand-media' ); ?></p>
845
+ <?php
846
+ }
847
+ break;
848
+ case 'filter_author':
849
+ case 'select_author':
850
+ if ( $gmCore->caps['gmedia_show_others_media'] ){
851
+ ?>
852
+ <div class="form-group">
853
+ <label><?php _e( 'Choose Author', 'grand-media' ); ?></label>
854
+ <?php
855
+ $user_ids = $gmCore->get_editable_user_ids();
856
+ if ( $user_ids ) {
857
+ if ( ! in_array( $user_ID, $user_ids, true ) ) {
858
+ array_push( $user_ids, $user_ID );
859
+ }
860
+ wp_dropdown_users( [
861
+ 'show_option_all' => ' &#8212; ',
862
+ 'include' => $user_ids,
863
+ 'include_selected' => true,
864
+ 'name' => 'author_ids',
865
+ 'selected' => $user_ID,
866
+ 'class' => 'form-control combobox_authors',
867
+ ] );
868
+ } else {
869
+ echo '<div>' . get_the_author_meta( 'display_name', $user_ID ) . '</div>';
870
+ }
871
+ ?>
872
+ </div>
873
+ <script type="text/javascript">
874
+ jQuery(function() {
875
+ jQuery('.combobox_authors').selectize({
876
+ create: false,
877
+ maxItems: 1,
878
+ openOnFocus: true,
879
+ hideSelected: true
880
+ });
881
+ });
882
+ </script>
883
+ <?php
884
+ } else {
885
+ echo '<p>' . __( 'You are not allowed to see others media' ) . '</p>';
886
+ echo '<p><strong>' . get_the_author_meta( 'display_name', $user_ID ) . '</strong></p>';
887
+ }
888
+ break;
889
+ case 'batch_edit':
890
+ ?>
891
+ <p><?php _e( 'Note, data will be saved to all selected items in Gmedia Library.' ) ?></p>
892
+ <div class="form-group">
893
+ <label><?php _e( 'Filename', 'grand-media' ); ?></label>
894
+ <select class="form-control input-sm batch_set" name="batch_filename">
895
+ <option value=""><?php _e( 'Skip. Do not change', 'grand-media' ); ?></option>
896
+ <option value="custom"><?php _e( 'Custom', 'grand-media' ); ?></option>
897
+ </select>
898
+
899
+ <div class="batch_set_custom" style="margin-top:5px;display:none;">
900
+ <input class="form-control input-sm" name="batch_filename_custom" value="" placeholder="<?php echo esc_attr( 'newname_{id}' ); ?>"/>
901
+
902
+ <div><?php _e( 'Variables: <b>{filename}</b> - original file name; <b>{id}</b> - Gmedia #ID in database; <b>{index:001}</b> - index of selected file in order you select (set start number after colon).' ) ?></div>
903
+ </div>
904
+ </div>
905
+ <div class="form-group">
906
+ <label><?php _e( 'Title', 'grand-media' ); ?></label>
907
+ <select class="form-control input-sm batch_set" name="batch_title">
908
+ <option value=""><?php _e( 'Skip. Do not change', 'grand-media' ); ?></option>
909
+ <option value="empty"><?php _e( 'Empty Title', 'grand-media' ); ?></option>
910
+ <option value="filename"><?php _e( 'From Filename', 'grand-media' ); ?></option>
911
+ <option value="custom"><?php _e( 'Custom', 'grand-media' ); ?></option>
912
+ </select>
913
+ <input class="form-control input-sm batch_set_custom" style="margin-top:5px;display:none;" name="batch_title_custom" value="" placeholder="<?php _e( 'Enter custom title here', 'grand-media' ); ?>"/>
914
+ </div>
915
+ <div class="form-group">
916
+ <label><?php _e( 'Description', 'grand-media' ); ?></label>
917
+ <select class="form-control input-sm batch_set" name="batch_description">
918
+ <option value=""><?php _e( 'Skip. Do not change', 'grand-media' ); ?></option>
919
+ <option value="metadata"><?php _e( 'Add MetaInfo to Description', 'grand-media' ); ?></option>
920
+ <option value="empty"><?php _e( 'Empty Description', 'grand-media' ); ?></option>
921
+ <option value="custom"><?php _e( 'Custom', 'grand-media' ); ?></option>
922
+ </select>
923
+
924
+ <div class="batch_set_custom" style="margin-top:5px;display:none;">
925
+ <select class="form-control input-sm" name="what_description_custom" style="margin-bottom:5px;">
926
+ <option value="replace"><?php _e( 'Replace', 'grand-media' ); ?></option>
927
+ <option value="append"><?php _e( 'Append', 'grand-media' ); ?></option>
928
+ <option value="prepend"><?php _e( 'Prepend', 'grand-media' ); ?></option>
929
+ </select>
930
+ <textarea class="form-control input-sm" cols="30" rows="3" name="batch_description_custom" placeholder="<?php _e( 'Enter description here', 'grand-media' ); ?>"></textarea>
931
+ </div>
932
+ </div>
933
+ <div class="form-group">
934
+ <label><?php _e( 'Link', 'grand-media' ); ?></label>
935
+ <select class="form-control input-sm batch_set" name="batch_link">
936
+ <option value=""><?php _e( 'Skip. Do not change', 'grand-media' ); ?></option>
937
+ <option value="empty"><?php _e( 'Empty Link', 'grand-media' ); ?></option>
938
+ <option value="self"><?php _e( 'Link to original file', 'grand-media' ); ?></option>
939
+ <option value="custom"><?php _e( 'Custom', 'grand-media' ); ?></option>
940
+ </select>
941
+ <input class="form-control input-sm batch_set_custom" style="margin-top:5px;display:none;" name="batch_link_custom" value="" placeholder="<?php _e( 'Enter url here' ); ?>"/>
942
+ </div>
943
+ <div class="form-group">
944
+ <label><?php _e( 'Status', 'grand-media' ); ?></label>
945
+ <select class="form-control input-sm batch_set" name="batch_status">
946
+ <option value=""><?php _e( 'Skip. Do not change', 'grand-media' ); ?></option>
947
+ <option value="publish"><?php _e( 'Public', 'grand-media' ); ?></option>
948
+ <option value="private"><?php _e( 'Private', 'grand-media' ); ?></option>
949
+ <option value="draft"><?php _e( 'Draft', 'grand-media' ); ?></option>
950
+ </select>
951
+ </div>
952
+ <div class="form-group">
953
+ <label><?php _e( 'Comment Status', 'grand-media' ); ?></label>
954
+ <select class="form-control input-sm batch_set" name="batch_comment_status">
955
+ <option value=""><?php _e( 'Skip. Do not change', 'grand-media' ); ?></option>
956
+ <option value="open"><?php _e( 'Open', 'grand-media' ); ?></option>
957
+ <option value="closed"><?php _e( 'Closed', 'grand-media' ); ?></option>
958
+ </select>
959
+ </div>
960
+ <?php $user_ids = current_user_can( 'gmedia_delete_others_media' ) ? $gmCore->get_editable_user_ids() : false;
961
+ if ( $user_ids ) {
962
+ if ( ! in_array( $user_ID, $user_ids, true ) ) {
963
+ array_push( $user_ids, $user_ID );
964
+ }
965
+ ?>
966
+ <div class="form-group">
967
+ <label><?php _e( 'Author', 'grand-media' ); ?></label>
968
+ <?php wp_dropdown_users( [
969
+ 'show_option_none' => __( 'Skip. Do not change', 'grand-media' ),
970
+ 'include' => $user_ids,
971
+ 'include_selected' => true,
972
+ 'name' => 'batch_author',
973
+ 'selected' => - 1,
974
+ 'class' => 'input-sm form-control',
975
+ ] );
976
+ ?>
977
+ </div>
978
+ <?php
979
+ }
980
+ ?>
981
+ <script type="text/javascript">
982
+ jQuery(function($) {
983
+ $('select.batch_set').change(function() {
984
+ if ('custom' === $(this).val()) {
985
+ $(this).next().css({display: 'block'});
986
+ }
987
+ else {
988
+ $(this).next().css({display: 'none'});
989
+ }
990
+ });
991
+ });
992
+ </script>
993
+ <?php
994
+ break;
995
+ default:
996
+ _e( 'Ops! Something wrong.', 'grand-media' );
997
+ break;
998
+ }
999
+ ?>
1000
+ </div>
1001
+ <div class="modal-footer">
1002
+ <button type="button" class="btn btn-default" data-dismiss="modal"><?php _e( 'Cancel', 'grand-media' ); ?></button>
1003
+ <?php if ( $modal_button ) { ?>
1004
+ <input type="hidden" name="<?php echo esc_attr( $modal ); ?>"/>
1005
+ <button type="button" onclick="jQuery('#ajax-modal-form').submit()" class="btn <?php echo esc_attr( $button_class ); ?>"><?php echo esc_html( $modal_button ); ?></button>
1006
+ <?php
1007
+ }
1008
+ wp_nonce_field( 'gmedia_action', '_wpnonce_action' );
1009
+ ?>
1010
+ </div>
1011
+ </form><!-- /.modal-content -->
1012
+ <?php
1013
+ // @formatter:on
1014
+ die();
1015
+ }
1016
+
1017
+ add_action( 'wp_ajax_gmedia_tag_edit', 'gmedia_tag_edit' );
1018
+ function gmedia_tag_edit() {
1019
+ global $gmCore, $gmDB;
1020
+
1021
+ check_ajax_referer( 'gmedia_terms', '_wpnonce_terms' );
1022
+ if ( ! current_user_can( 'gmedia_tag_manage' ) && ! current_user_can( 'gmedia_edit_others_media' ) ) {
1023
+ $out['error'] = $gmCore->alert( 'danger', __( "You are not allowed to edit others media", 'grand-media' ) );
1024
+ header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ), true );
1025
+ echo wp_json_encode( $out );
1026
+ die();
1027
+ }
1028
+
1029
+ $term = [ 'taxonomy' => 'gmedia_tag' ];
1030
+ $term['name'] = trim( $gmCore->_post( 'tag_name', '' ) );
1031
+ $term['term_id'] = intval( $gmCore->_post( 'tag_id', 0 ) );
1032
+ if ( $term['name'] && ! $gmCore->is_digit( $term['name'] ) ) {
1033
+ if ( ( $term_id = $gmDB->term_exists( $term['term_id'] ) ) ) {
1034
+ if ( ! $gmDB->term_exists( $term['name'], $term['taxonomy'] ) ) {
1035
+ $term_id = $gmDB->update_term( $term['term_id'], $term );
1036
+ if ( is_wp_error( $term_id ) ) {
1037
+ $out['error'] = $gmCore->alert( 'danger', $term_id->get_error_message() );
1038
+ } else {
1039
+ $out['msg'] = $gmCore->alert( 'info', sprintf( __( "Tag #%d successfully updated", 'grand-media' ), $term_id ) );
1040
+ }
1041
+ } else {
1042
+ $out['error'] = $gmCore->alert( 'danger', __( "A term with the name provided already exists", 'grand-media' ) );
1043
+ }
1044
+ } else {
1045
+ $out['error'] = $gmCore->alert( 'danger', __( "A term with the id provided does not exists", 'grand-media' ) );
1046
+ }
1047
+ } else {
1048
+ $out['error'] = $gmCore->alert( 'danger', __( "Term name can't be only digits or empty", 'grand-media' ) );
1049
+ }
1050
+
1051
+ header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ), true );
1052
+ echo wp_json_encode( $out );
1053
+
1054
+ die();
1055
+
1056
+ }
1057
+
1058
+ add_action( 'wp_ajax_gmedia_module_preset_delete', 'gmedia_module_preset_delete' );
1059
+ function gmedia_module_preset_delete() {
1060
+ global $gmCore, $gmDB, $user_ID;
1061
+ $out = [ 'error' => '' ];
1062
+
1063
+ check_ajax_referer( 'GmediaGallery' );
1064
+ if ( ! current_user_can( 'gmedia_gallery_manage' ) ) {
1065
+ $out['error'] = $gmCore->alert( 'danger', __( "You are not allowed to manage galleries", 'grand-media' ) );
1066
+ } else {
1067
+ $term_id = intval( $gmCore->_post( 'preset_id', 0 ) );
1068
+ $term = $gmDB->get_term( $term_id );
1069
+ if ( $term && ! is_wp_error( $term ) ) {
1070
+ if ( ( $term->global !== $user_ID && ! gm_user_can( 'delete_others_media' ) ) || ( (int) $term->global === 0 && ! current_user_can( 'manage_options' ) ) ) {
1071
+ $out['error'] = $gmCore->alert( 'danger', __( "You are not allowed to manage galleries", 'grand-media' ) );
1072
+
1073
+ header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ), true );
1074
+ echo wp_json_encode( $out );
1075
+
1076
+ die();
1077
+ }
1078
+
1079
+ $delete = $gmDB->delete_term( $term_id );
1080
+ if ( is_wp_error( $delete ) ) {
1081
+ $out['error'] = $delete->get_error_message();
1082
+ }
1083
+ }
1084
+ }
1085
+
1086
+ header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ), true );
1087
+ echo wp_json_encode( $out );
1088
+
1089
+ die();
1090
+ }
1091
+
1092
+ add_action( 'wp_ajax_gmedia_module_install', 'gmedia_module_install' );
1093
+ function gmedia_module_install() {
1094
+ global $gmCore, $gmGallery;
1095
+
1096
+ check_ajax_referer( 'GmediaGallery' );
1097
+ if ( ! current_user_can( 'gmedia_module_manage' ) ) {
1098
+ echo $gmCore->alert( 'danger', __( 'You are not allowed to install modules' ) );
1099
+ die();
1100
+ }
1101
+
1102
+ if ( ( $download = $gmCore->_post( 'download' ) ) ) {
1103
+ $module = $gmCore->_post( 'module' );
1104
+ $mzip = download_url( $download );
1105
+ if ( is_wp_error( $mzip ) ) {
1106
+ echo $gmCore->alert( 'danger', $mzip->get_error_message() );
1107
+ die();
1108
+ }
1109
+
1110
+ $mzip = str_replace( "\\", "/", $mzip );
1111
+ $to_folder = $gmCore->upload['path'] . '/' . $gmGallery->options['folder']['module'] . '/';
1112
+ if ( ! wp_mkdir_p( $to_folder ) ) {
1113
+ echo $gmCore->alert( 'danger', sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?', 'grand-media' ), $to_folder ) );
1114
+ die();
1115
+ }
1116
+ if ( ! is_writable( $to_folder ) ) {
1117
+ @chmod( $to_folder, 0755 );
1118
+ if ( ! is_writable( $to_folder ) ) {
1119
+ echo $gmCore->alert( 'danger', sprintf( __( 'Directory %s is not writable by the server.', 'grand-media' ), $to_folder ) );
1120
+ die();
1121
+ }
1122
+ }
1123
+
1124
+ global $wp_filesystem;
1125
+ // Is a filesystem accessor setup?
1126
+ if ( ! $wp_filesystem || ! is_object( $wp_filesystem ) ) {
1127
+ require_once ABSPATH . 'wp-admin/includes/file.php';
1128
+ WP_Filesystem();
1129
+ }
1130
+ if ( ! is_object( $wp_filesystem ) ) {
1131
+ $result = new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.', 'grand-media' ) );
1132
+ } elseif ( $wp_filesystem->errors->get_error_code() ) {
1133
+ $result = new WP_Error( 'fs_error', __( 'Filesystem error', 'grand-media' ), $wp_filesystem->errors );
1134
+ } else {
1135
+ if ( $module && is_dir( $to_folder . $module ) ) {
1136
+ $gmCore->delete_folder( $to_folder . $module );
1137
+ }
1138
+ $result = unzip_file( $mzip, $to_folder );
1139
+ }
1140
+
1141
+ // Once extracted, delete the package.
1142
+ unlink( $mzip );
1143
+
1144
+ if ( is_wp_error( $result ) ) {
1145
+ echo $gmCore->alert( 'danger', $result->get_error_message() );
1146
+ die();
1147
+ } else {
1148
+ echo $gmCore->alert( 'success', sprintf( __( "The `%s` module successfully installed", 'grand-media' ), $module ) );
1149
+ // Try to clear cache after module update.
1150
+ @$gmCore->clear_cache();
1151
+ }
1152
+ } else {
1153
+ echo $gmCore->alert( 'danger', __( 'No file specified', 'grand-media' ) );
1154
+ }
1155
+
1156
+ die();
1157
+ }
1158
+
1159
+
1160
+ add_action( 'wp_ajax_gmedia_import_wpmedia_modal', 'gmedia_import_wpmedia_modal' );
1161
+ function gmedia_import_wpmedia_modal() {
1162
+ global $user_ID, $gmDB, $gmCore;
1163
+
1164
+ check_ajax_referer( 'GmediaGallery' );
1165
+ if ( ! current_user_can( 'gmedia_import' ) ) {
1166
+ die( '-1' );
1167
+ }
1168
+ ?>
1169
+ <div class="modal-content">
1170
+ <div class="modal-header">
1171
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
1172
+ <h4 class="modal-title"><?php _e( 'Import from WP Media Library' ); ?></h4>
1173
+ </div>
1174
+ <div class="modal-body" style="position:relative; min-height:270px;">
1175
+ <form id="import_form" name="import_form" target="import_window" action="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>" method="POST" accept-charset="utf-8">
1176
+ <?php wp_nonce_field( 'gmedia_import', '_wpnonce_import' ); ?>
1177
+ <input type="hidden" name="action" value="gmedia_import_handler"/>
1178
+ <input type="hidden" id="import-action" name="import" value="import-wpmedia"/>
1179
+ <input type="hidden" name="selected" value="<?php $ckey = "gmedia_library:wpmedia";
1180
+ if ( isset( $_COOKIE[ $ckey ] ) ) {
1181
+ echo str_replace( '.', ',', $_COOKIE[ $ckey ] );
1182
+ } ?>"/>
1183
+ <?php if ( $gmCore->caps['gmedia_terms'] ) { ?>
1184
+ <div class="form-group">
1185
+ <?php
1186
+ $term_type = 'gmedia_album';
1187
+ $gm_terms = $gmDB->get_terms( $term_type, [ 'global' => [ 0, $user_ID ], 'orderby' => 'global_desc_name' ] );
1188
+
1189
+ $terms_album = '';
1190
+ if ( count( $gm_terms ) ) {
1191
+ foreach ( $gm_terms as $term ) {
1192
+ $terms_album .= '<option value="' . esc_attr( $term->term_id ) . '">' . esc_html( $term->name ) . ( $term->global ? '' : __( ' (shared)', 'grand-media' ) ) . ( 'publish' === $term->status ? '' : " [{$term->status}]" ) . '</option>' . "\n";
1193
+ }
1194
+ }
1195
+ ?>
1196
+ <label><?php _e( 'Add to Album', 'grand-media' ); ?> </label>
1197
+ <select id="combobox_gmedia_album" name="terms[gmedia_album]" class="form-control input-sm" placeholder="<?php _e( 'Album Name...', 'grand-media' ); ?>">
1198
+ <option value=""></option>
1199
+ <?php echo $terms_album; ?>
1200
+ </select>
1201
+ </div>
1202
+
1203
+ <div class="form-group">
1204
+ <?php
1205
+ $term_type = 'gmedia_category';
1206
+ $gm_cat_terms = $gmDB->get_terms( $term_type, [ 'fields' => 'names' ] );
1207
+ ?>
1208
+ <label><?php _e( 'Assign Categories', 'grand-media' ); ?></label>
1209
+ <input id="combobox_gmedia_category" name="terms[gmedia_category]" class="form-control input-sm" value="" placeholder="<?php _e( 'Uncategorized', 'grand-media' ); ?>"/>
1210
+ </div>
1211
+
1212
+ <div class="form-group">
1213
+ <?php
1214
+ $term_type = 'gmedia_tag';
1215
+ $gm_tag_terms = $gmDB->get_terms( $term_type, [ 'fields' => 'names' ] );
1216
+ ?>
1217
+ <label><?php _e( 'Add Tags', 'grand-media' ); ?> </label>
1218
+ <input id="combobox_gmedia_tag" name="terms[gmedia_tag]" class="form-control input-sm" value="" placeholder="<?php _e( 'Add Tags...', 'grand-media' ); ?>"/>
1219
+ </div>
1220
+ <script type="text/javascript">
1221
+ jQuery(function($) {
1222
+ //noinspection JSDuplicatedDeclaration
1223
+ $('#combobox_gmedia_album').selectize({
1224
+ <?php if($gmCore->caps['gmedia_album_manage']){ ?>
1225
+ create: true,
1226
+ createOnBlur: true,
1227
+ <?php } else{ ?>
1228
+ create: false,
1229
+ <?php } ?>
1230
+ persist: false
1231
+ });
1232
+
1233
+ var gm_cat_terms = <?php echo wp_json_encode( $gm_cat_terms ); ?>;
1234
+ //noinspection JSUnusedAssignment
1235
+ var cat_items = gm_cat_terms.map(function(x) {
1236
+ return {item: x};
1237
+ });
1238
+ //noinspection JSDuplicatedDeclaration
1239
+ $('#combobox_gmedia_category').selectize({
1240
+ <?php if($gmCore->caps['gmedia_category_manage']){ ?>
1241
+ create: function(input) {
1242
+ return {
1243
+ item: input
1244
+ };
1245
+ },
1246
+ createOnBlur: true,
1247
+ <?php } else{ ?>
1248
+ create: false,
1249
+ <?php } ?>
1250
+ delimiter: ',',
1251
+ maxItems: null,
1252
+ openOnFocus: true,
1253
+ persist: false,
1254
+ options: cat_items,
1255
+ labelField: 'item',
1256
+ valueField: 'item',
1257
+ searchField: ['item'],
1258
+ hideSelected: true
1259
+ });
1260
+
1261
+ var gm_tag_terms = <?php echo wp_json_encode( $gm_tag_terms ); ?>;
1262
+ //noinspection JSUnusedAssignment
1263
+ var tag_items = gm_tag_terms.map(function(x) {
1264
+ return {item: x};
1265
+ });
1266
+ //noinspection JSDuplicatedDeclaration
1267
+ $('#combobox_gmedia_tag').selectize({
1268
+ <?php if($gmCore->caps['gmedia_tag_manage']){ ?>
1269
+ create: function(input) {
1270
+ return {
1271
+ item: input
1272
+ };
1273
+ },
1274
+ createOnBlur: true,
1275
+ <?php } else{ ?>
1276
+ create: false,
1277
+ <?php } ?>
1278
+ delimiter: ',',
1279
+ maxItems: null,
1280
+ openOnFocus: true,
1281
+ persist: false,
1282
+ options: tag_items,
1283
+ labelField: 'item',
1284
+ valueField: 'item',
1285
+ searchField: ['item'],
1286
+ hideSelected: true
1287
+ });
1288
+ });
1289
+ </script>
1290
+ <?php } else { ?>
1291
+ <p><?php _e( 'You are not allowed to assign terms', 'grand-media' ) ?></p>
1292
+ <?php } ?>
1293
+ <div class="checkbox">
1294
+ <label><input type="checkbox" name="skip_exists" value="skip"> <?php _e( 'Skip if file with the same name already exists in Gmedia Library', 'grand-media' ); ?></label>
1295
+ <div class="help-block"><?php _e( 'Note: duplicates will be skipped in any way (checked by file hash)' ) ?></div>
1296
+ </div>
1297
+ <script type="text/javascript">
1298
+ jQuery(function($) {
1299
+ $('#import-done').one('click', function() {
1300
+ $('#import_form').submit();
1301
+ $(this).text($(this).data('loading-text')).prop('disabled', true);
1302
+ $('#import_window').show();
1303
+ $(this).one('click', function() {
1304
+ $('#importModal').modal('hide');
1305
+ });
1306
+ });
1307
+ });
1308
+ </script>
1309
+ </form>
1310
+ <iframe name="import_window" id="import_window" src="about:blank" style="display:none; position:absolute; left:0; top:0; width:100%; height:100%; z-index:1000; background-color:#ffffff; padding:20px 20px 0 20px;" onload="gmedia_import_done()"></iframe>
1311
+ </div>
1312
+ <div class="modal-footer">
1313
+ <button type="button" class="btn btn-default" data-dismiss="modal"><?php _e( 'Cancel', 'grand-media' ); ?></button>
1314
+ <button type="button" id="import-done" class="btn btn-primary" data-complete-text="<?php _e( 'Close', 'grand-media' ); ?>" data-loading-text="<?php _e( 'Working...', 'grand-media' ); ?>" data-reset-text="<?php _e( 'Import', 'grand-media' ); ?>"><?php _e( 'Import', 'grand-media' ); ?></button>
1315
+ </div>
1316
+ </div><!-- /.modal-content -->
1317
+ <?php
1318
+ die();
1319
+ }
1320
+
1321
+ add_action( 'wp_ajax_gmedia_relimage', 'gmedia_relimage' );
1322
+ /**
1323
+ * Do Actions via Ajax
1324
+ * TODO add related images to post
1325
+ * TODO check author for related images
1326
+ *
1327
+ * @return void
1328
+ */
1329
+ function gmedia_relimage() {
1330
+ /** @var $wpdb wpdb */
1331
+ global $wpdb, $gmCore, $gmDB;
1332
+
1333
+ check_ajax_referer( "GmediaGallery" );
1334
+
1335
+ // check for correct capability.
1336
+ if ( ! current_user_can( 'gmedia_library' ) ) {
1337
+ die( '-1' );
1338
+ }
1339
+
1340
+ $post_tags = array_filter( array_map( 'trim', explode( ',', stripslashes( urldecode( $gmCore->_get( 'tags', '' ) ) ) ) ) );
1341
+ $paged = (int) $gmCore->_get( 'paged', 1 );
1342
+ $per_page = 20;
1343
+ $s = trim( stripslashes( urldecode( $gmCore->_get( 'search' ) ) ) );
1344
+ if ( $s && strlen( $s ) > 2 ) {
1345
+ $post_tags = [];
1346
+ } else {
1347
+ $s = '';
1348
+ }
1349
+
1350
+ $gmediaLib = [];
1351
+ $relative = (int) $gmCore->_get( 'rel', 1 );
1352
+ $continue = true;
1353
+ $content = '';
1354
+
1355
+ if ( $relative === 1 ) {
1356
+ $arg = [
1357
+ 'mime_type' => 'image/*',
1358
+ 'orderby' => 'ID',
1359
+ 'order' => 'DESC',
1360
+ 'per_page' => $per_page,
1361
+ 'page' => $paged,
1362
+ 's' => $s,
1363
+ 'tag_name__in' => $post_tags,
1364
+ 'null_tags' => true,
1365
+ ];
1366
+ $gmediaLib = $gmDB->get_gmedias( $arg );
1367
+ }
1368
+
1369
+ if ( empty( $gmediaLib ) && count( $post_tags ) ) {
1370
+
1371
+ if ( $relative === 1 ) {
1372
+ $relative = 0;
1373
+ $paged = 1;
1374
+ $content .= '<li class="emptydb">' . __( 'No items related by tags.', 'grand-media' ) . '</li>' . "\n";
1375
+ }
1376
+
1377
+ $tag__not_in = "'" . implode( "','", array_map( 'esc_sql', array_unique( (array) $post_tags ) ) ) . "'";
1378
+ $tag__not_in = $wpdb->get_col( "
1379
+ SELECT term_id
1380
+ FROM {$wpdb->prefix}gmedia_term
1381
+ WHERE taxonomy = 'gmedia_tag'
1382
+ AND name IN ({$tag__not_in})
1383
+ " );
1384
+
1385
+ $arg = [
1386
+ 'mime_type' => 'image/*',
1387
+ 'orderby' => 'ID',
1388
+ 'order' => 'DESC',
1389
+ 'per_page' => $per_page,
1390
+ 'page' => $paged,
1391
+ 'tag__not_in' => $tag__not_in,
1392
+ ];
1393
+ $gmediaLib = $gmDB->get_gmedias( $arg );
1394
+ }
1395
+
1396
+ if ( ( $count = count( $gmediaLib ) ) ) {
1397
+ foreach ( $gmediaLib as $item ) {
1398
+ $content .= "<li class='gmedia-image-li' id='gm-img-{$item->ID}'>\n";
1399
+ $content .= " <a target='_blank' class='gm-img' data-gmid='{$item->ID}' href='" . $gmCore->gm_get_media_image( $item ) . "'><img src='" . $gmCore->gm_get_media_image( $item, 'thumb' ) . "' height='50' style='width:auto;' alt='' title='" . esc_attr( $item->title ) . "' /></a>\n";
1400
+ $content .= " <div style='display: none;' class='gm-img-description'>" . esc_html( $item->description ) . "</div>\n";
1401
+ $content .= "</li>\n";
1402
+ }
1403
+ if ( ( $count < $per_page ) && ( $relative === 0 || ! empty( $s ) ) ) {
1404
+ $continue = false;
1405
+ }
1406
+ } else {
1407
+ if ( $s ) {
1408
+ $content .= '<li class="emptydb">' . __( 'No items matching the search query.', 'grand-media' ) . '</li>' . "\n";
1409
+ } else {
1410
+ $content .= '<li class="emptydb">' . __( 'No items to show', 'grand-media' ) . '</li>' . "\n";
1411
+ }
1412
+ $continue = false;
1413
+ }
1414
+ $result = [ 'paged' => $paged, 'rel' => $relative, 'continue' => $continue, 'content' => $content, 'data' => $post_tags ];
1415
+ header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ), true );
1416
+ echo wp_json_encode( $result );
1417
+
1418
+ die();
1419
+ }
1420
+
1421
+ add_action( 'wp_ajax_gmedia_ftp_browser', 'gmedia_ftp_browser' );
1422
+ /**
1423
+ * jQuery File Tree PHP Connector
1424
+ *
1425
+ * @author Cory S.N. LaViska - A Beautiful Site (http://abeautifulsite.net/)
1426
+ * @version 1.0.1
1427
+ * @return string folder content.
1428
+ */
1429
+ function gmedia_ftp_browser() {
1430
+ if ( ! current_user_can( 'gmedia_import' ) ) {
1431
+ die( 'No access' );
1432
+ }
1433
+
1434
+ // if nonce is not correct it returns -1.
1435
+ check_ajax_referer( 'GmediaGallery' );
1436
+
1437
+ // start from the default path.
1438
+ $root = trailingslashit( ABSPATH );
1439
+ // get the current directory.
1440
+ $dir = trailingslashit( urldecode( $_POST['dir'] ) );
1441
+
1442
+ if ( ( false === strpos( $dir, '..' ) ) && file_exists( $root . $dir ) ) {
1443
+ $files = scandir( $root . $dir );
1444
+ natcasesort( $files );
1445
+
1446
+ // The 2 counts for . and ..
1447
+ if ( count( $files ) > 2 ) {
1448
+ echo "<ul class=\"jqueryFileTree\" style=\"display: none;\">";
1449
+ // return only directories
1450
+ foreach ( $files as $file ) {
1451
+ if ( in_array( $file, [ 'wp-admin', 'wp-includes', 'plugins', 'themes', 'thumb', 'thumbs' ], true ) ) {
1452
+ continue;
1453
+ }
1454
+
1455
+ if ( file_exists( $root . $dir . $file ) && $file !== '.' && $file !== '..' && is_dir( $root . $dir . $file ) ) {
1456
+ echo "<li class=\"directory collapsed\"><a href=\"#\" rel=\"" . esc_attr( $dir . $file ) . "/\">" . esc_html( $file ) . "</a></li>";
1457
+ }
1458
+ }
1459
+ // All files.
1460
+ foreach ( $files as $file ) {
1461
+ if ( file_exists( $root . $dir . $file ) && $file !== '.' && $file !== '..' && ! is_dir( $root . $dir . $file ) ) {
1462
+ $ext = preg_replace( '/^.*\./', '', $file );
1463
+ if ( $file === '.' . $ext ) {
1464
+ continue;
1465
+ }
1466
+ echo "<li class=\"file ext_$ext\"><a href=\"#\" rel=\"" . esc_attr( $dir ) . "\">" . esc_html( $file ) . "</a></li>";
1467
+ }
1468
+ }
1469
+ echo '</ul>';
1470
+ }
1471
+ }
1472
+
1473
+ die();
1474
+ }
1475
+
1476
+ add_action( 'wp_ajax_gmedia_set_post_thumbnail', 'gmedia_set_post_thumbnail' );
1477
+ function gmedia_set_post_thumbnail() {
1478
+ global $gmCore, $gmDB, $gmGallery;
1479
+
1480
+ $post_ID = intval( $gmCore->_post( 'post_id', 0 ) );
1481
+
1482
+ if ( ! $post_ID || ! current_user_can( 'edit_post', $post_ID ) ) {
1483
+ die( '-1' );
1484
+ }
1485
+
1486
+ // if nonce is not correct it returns -1.
1487
+ check_ajax_referer( 'set_post_thumbnail-' . $post_ID );
1488
+
1489
+ $img_id = intval( $gmCore->_post( 'img_id', 0 ) );
1490
+
1491
+ /*
1492
+ // delete the image
1493
+ if ( $thumbnail_id === '-1' ) {
1494
+ delete_post_meta( $post_ID, '_thumbnail_id' );
1495
+ die('0');
1496
+ }
1497
+ */
1498
+
1499
+ if ( $img_id ) {
1500
+
1501
+ $image = $gmDB->get_gmedia( $img_id );
1502
+ if ( $image ) {
1503
+
1504
+ $args = [
1505
+ 'post_type' => 'attachment',
1506
+ 'meta_key' => '_gmedia_image_id',
1507
+ 'meta_compare' => '==',
1508
+ 'meta_value' => $img_id,
1509
+ ];
1510
+ $posts = get_posts( $args );
1511
+ $attachment_id = null;
1512
+
1513
+ if ( $posts !== null ) {
1514
+ $attachment_id = $posts[0]->ID;
1515
+ //$target_path = get_attached_file( $attachment_id );
1516
+ } else {
1517
+ $upload_dir = wp_upload_dir();
1518
+ $basedir = $upload_dir['basedir'];
1519
+ $thumbs_dir = implode( DIRECTORY_SEPARATOR, [ $basedir, 'gmedia_featured' ] );
1520
+
1521
+ $type = explode( '/', $image->mime_type );
1522
+
1523
+ $url = $gmCore->upload['url'] . '/' . $gmGallery->options['folder'][ $type[0] ] . '/' . $image->gmuid;
1524
+ $image_abspath = $gmCore->upload['path'] . '/' . $gmGallery->options['folder'][ $type[0] ] . '/' . $image->gmuid;
1525
+
1526
+ $img_name = current_time( 'ymd_Hi' ) . '_' . basename( $image->gmuid );
1527
+ $target_path = path_join( $thumbs_dir, $img_name );
1528
+ wp_mkdir_p( $thumbs_dir );
1529
+
1530
+ if ( @copy( $image_abspath, $target_path ) ) {
1531
+ $title = sanitize_title( $image->title );
1532
+ $caption = $gmCore->sanitize( $image->description );
1533
+
1534
+ $attachment = [
1535
+ 'post_title' => $title,
1536
+ 'post_content' => $caption,
1537
+ 'post_status' => 'attachment',
1538
+ 'post_parent' => 0,
1539
+ 'post_mime_type' => $image->mime_type,
1540
+ 'guid' => $url,
1541
+ ];
1542
+
1543
+ //require for wp_generate_attachment_metadata which generates image related meta-data also creates thumbs.
1544
+ require_once ABSPATH . 'wp-admin/includes/image.php';
1545
+ // Save the data.
1546
+ $attachment_id = wp_insert_attachment( $attachment, $target_path );
1547
+ wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $target_path ) );
1548
+ add_post_meta( $attachment_id, '_gmedia_image_id', $img_id, true );
1549
+ }
1550
+ }
1551
+
1552
+ if ( $attachment_id ) {
1553
+ delete_post_meta( $post_ID, '_thumbnail_id' );
1554
+ add_post_meta( $post_ID, '_thumbnail_id', $attachment_id, true );
1555
+
1556
+ echo _wp_post_thumbnail_html( $attachment_id, $post_ID );
1557
+ die();
1558
+ }
1559
+ }
1560
+ }
1561
+
1562
+ die( '0' );
1563
+ }
1564
+
1565
+ add_action( 'wp_ajax_gmedia_upload_handler', 'gmedia_upload_handler' );
1566
+ function gmedia_upload_handler() {
1567
+ global $gmCore;
1568
+
1569
+ ini_set( 'max_execution_time', 300 );
1570
+
1571
+ // HTTP headers for no cache etc.
1572
+ send_nosniff_header();
1573
+ //send_origin_headers();
1574
+ nocache_headers();
1575
+
1576
+ // if nonce is not correct it returns -1.
1577
+ check_ajax_referer( 'gmedia_upload', '_wpnonce_upload' );
1578
+ if ( ! current_user_can( 'gmedia_upload' ) ) {
1579
+ wp_die( __( 'You do not have permission to upload files in Gmedia Library.' ) );
1580
+ }
1581
+
1582
+ // 5 minutes execution time.
1583
+ @set_time_limit( 5 * 60 );
1584
+
1585
+ // fake upload time.
1586
+ usleep( 10 );
1587
+
1588
+ $filename = $gmCore->_req( 'name' );
1589
+
1590
+ // Get parameters.
1591
+ if ( ! $filename ) {
1592
+ $return = wp_json_encode( [ "error" => [ "code" => 100, "message" => __( "No file name.", 'grand-media' ) ] ] );
1593
+ die( $return );
1594
+ }
1595
+
1596
+ $fileinfo = $gmCore->fileinfo( $filename );
1597
+ if ( false === $fileinfo ) {
1598
+ $return = wp_json_encode( [ "error" => [ "code" => 100, "message" => __( "File type not allowed.", 'grand-media' ) ], "id" => $filename ] );
1599
+ die( $return );
1600
+ }
1601
+
1602
+ // Look for the content type header.
1603
+ $contentType = '';
1604
+ if ( isset( $_SERVER["HTTP_CONTENT_TYPE"] ) ) {
1605
+ $contentType = $_SERVER["HTTP_CONTENT_TYPE"];
1606
+ }
1607
+
1608
+ if ( isset( $_SERVER["CONTENT_TYPE"] ) ) {
1609
+ $contentType = $_SERVER["CONTENT_TYPE"];
1610
+ }
1611
+
1612
+ // Handle non multipart uploads older WebKit versions didn't support multipart in HTML5.
1613
+ $file_tmp = '';
1614
+ if ( strpos( $contentType, "multipart" ) !== false ) {
1615
+ if ( isset( $_FILES['file']['tmp_name'] ) && is_uploaded_file( $_FILES['file']['tmp_name'] ) ) {
1616
+ $file_tmp = $_FILES['file']['tmp_name'];
1617
+ }
1618
+ } else {
1619
+ $file_tmp = "php://input";
1620
+ }
1621
+
1622
+ if ( empty( $file_tmp ) ) {
1623
+ $return = wp_json_encode( [ "error" => [ "code" => 103, "message" => __( "Failed to move uploaded file.", 'grand-media' ) ], "id" => $filename ] );
1624
+ die( $return );
1625
+ }
1626
+
1627
+ $post_data = [];
1628
+ if ( ( $params = $gmCore->_req( 'params', '' ) ) ) {
1629
+ parse_str( $params, $post_data );
1630
+ }
1631
+
1632
+ $return = $gmCore->gmedia_upload_handler( $file_tmp, $fileinfo, $contentType, $post_data );
1633
+ $return = wp_json_encode( $return );
1634
+
1635
+ die( $return );
1636
+ }
1637
+
1638
+ add_action( 'wp_ajax_gmedia_import_handler', 'gmedia_import_handler' );
1639
+ function gmedia_import_handler() {
1640
+ global $wpdb, $gmCore, $gmDB;
1641
+
1642
+ ini_set( 'max_execution_time', 600 );
1643
+
1644
+ // HTTP headers for no cache etc.
1645
+ send_nosniff_header();
1646
+ //send_origin_headers();
1647
+ nocache_headers();
1648
+
1649
+ check_admin_referer( 'gmedia_import', '_wpnonce_import' );
1650
+ if ( ! current_user_can( 'gmedia_import' ) ) {
1651
+ wp_die( __( 'You do not have permission to upload files.' ) );
1652
+ }
1653
+
1654
+ // 10 minutes execution time.
1655
+ @set_time_limit( 10 * 60 );
1656
+
1657
+ // fake upload time.
1658
+ usleep( 10 );
1659
+
1660
+ $import = $gmCore->_post( 'import' );
1661
+ $terms = $gmCore->_post( 'terms', [] );
1662
+
1663
+ if ( ob_get_level() === 0 ) {
1664
+ ob_start();
1665
+ }
1666
+ echo str_pad( ' ', 4096 ) . PHP_EOL;
1667
+ wp_ob_end_flush_all();
1668
+ flush();
1669
+ ?>
1670
+ <html>
1671
+ <style type="text/css">
1672
+ * { margin: 0; padding: 0; }
1673
+
1674
+ pre { display: block; }
1675
+
1676
+ p { padding: 10px 0; font-size: 14px; }
1677
+
1678
+ .ok { color: darkgreen; }
1679
+
1680
+ .ko { color: darkred; }
1681
+ </style>
1682
+ <body>
1683
+ <?php
1684
+ if ( ( 'import-folder' === $import ) || isset( $_POST['import-folder'] ) ) {
1685
+
1686
+ $path = $gmCore->_post( 'path' );
1687
+ echo '<h4 style="margin: 0 0 10px">' . __( 'Import Server Folder' ) . " `$path`:</h4>" . PHP_EOL;
1688
+
1689
+ if ( $path ) {
1690
+ $path = trim( urldecode( $path ), '/' );
1691
+ if ( ! empty( $path ) ) {
1692
+ $fullpath = ABSPATH . trailingslashit( $path );
1693
+ $files = glob( $fullpath . '?*.?*', GLOB_NOSORT );
1694
+ if ( ! empty( $files ) ) {
1695
+ $allowed_ext = get_allowed_mime_types();
1696
+ $allowed_ext = array_keys( $allowed_ext );
1697
+ $allowed_ext = implode( '|', $allowed_ext );
1698
+ $allowed_ext = explode( '|', $allowed_ext );
1699
+ if ( ( GMEDIA_UPLOAD_FOLDER === basename( dirname( dirname( $path ) ) ) ) || ( GMEDIA_UPLOAD_FOLDER === basename( dirname( $path ) ) ) ) {
1700
+ global $wpdb;
1701
+ $gmedias = $wpdb->get_col( "SELECT gmuid FROM {$wpdb->prefix}gmedia" );
1702
+ foreach ( $files as $i => $filepath ) {
1703
+ $gmuid = basename( $filepath );
1704
+ if ( in_array( $gmuid, $gmedias, true ) ) {
1705
+ $fileinfo = $gmCore->fileinfo( $gmuid, false );
1706
+ if ( ! ( ( 'image' === $fileinfo['dirname'] ) && ! is_file( $fileinfo['filepath'] ) ) ) {
1707
+ unset( $files[ $i ] );
1708
+ }
1709
+ }
1710
+ }
1711
+ $move = false;
1712
+ $exists = false;
1713
+ } else {
1714
+ $move = $gmCore->_post( 'delete_source' );
1715
+ $exists = $gmCore->_post( 'skip_exists', 0 );
1716
+ }
1717
+ foreach ( $files as $i => $filepath ) {
1718
+ $ext = pathinfo( $filepath, PATHINFO_EXTENSION );
1719
+ if ( ! in_array( strtolower( $ext ), $allowed_ext, true ) ) {
1720
+ unset( $files[ $i ] );
1721
+ }
1722
+ }
1723
+ $gmCore->gmedia_import_files( $files, $terms, $move, $exists );
1724
+ } else {
1725
+ echo sprintf( __( 'Folder `%s` is empty', 'grand-media' ), $path ) . PHP_EOL;
1726
+ }
1727
+ } else {
1728
+ echo __( 'No folder chosen', 'grand-media' ) . PHP_EOL;
1729
+ }
1730
+ }
1731
+ } elseif ( ( 'import-flagallery' === $import ) || isset( $_POST['import-flagallery'] ) ) {
1732
+
1733
+ echo '<h4 style="margin: 0 0 10px">' . __( 'Import from Flagallery plugin' ) . ":</h4>" . PHP_EOL;
1734
+
1735
+ $gallery = $gmCore->_post( 'gallery' );
1736
+ if ( ! empty( $gallery ) ) {
1737
+ $album = ( ! isset( $terms['gmedia_album'] ) || empty( $terms['gmedia_album'] ) ) ? false : true;
1738
+ foreach ( $gallery as $gid ) {
1739
+ $flag_gallery = $wpdb->get_row( $wpdb->prepare( "SELECT gid, path, title, galdesc FROM {$wpdb->prefix}flag_gallery WHERE gid = %d", $gid ), ARRAY_A );
1740
+ if ( empty( $flag_gallery ) ) {
1741
+ continue;
1742
+ }
1743
+
1744
+ if ( ! $album ) {
1745
+ $terms['gmedia_album'] = $flag_gallery['title'];
1746
+ if ( $gmCore->is_digit( $terms['gmedia_album'] ) ) {
1747
+ $terms['gmedia_album'] = 'a' . $terms['gmedia_album'];
1748
+ }
1749
+ if ( ! $gmDB->term_exists( $terms['gmedia_album'], 'gmedia_album' ) ) {
1750
+ $term_id = $gmDB->insert_term( $terms['gmedia_album'], 'gmedia_album', [ 'description' => htmlspecialchars_decode( stripslashes( $flag_gallery['galdesc'] ) ) ] );
1751
+ }
1752
+ }
1753
+
1754
+ $path = ABSPATH . trailingslashit( $flag_gallery['path'] );
1755
+
1756
+ echo '<h5 style="margin: 10px 0 5px">' . sprintf( __( 'Import `%s` gallery', 'grand-media' ), esc_html( $flag_gallery['title'] ) ) . ":</h5>" . PHP_EOL;
1757
+
1758
+ $flag_pictures = $wpdb->get_results( $wpdb->prepare( "SELECT CONCAT('%s', filename) AS file, description, alttext AS title, link FROM {$wpdb->prefix}flag_pictures WHERE galleryid = %d", $path, $flag_gallery['gid'] ), ARRAY_A );
1759
+ if ( empty( $flag_pictures ) ) {
1760
+ echo '<pre>' . __( 'gallery contains 0 images', 'grand-media' ) . '</pre>';
1761
+ continue;
1762
+ }
1763
+ $exists = $gmCore->_post( 'skip_exists', 0 );
1764
+
1765
+ //echo '<pre>'.print_r($flag_pictures, true).'</pre>';
1766
+ $gmCore->gmedia_import_files( $flag_pictures, $terms, false, $exists );
1767
+ }
1768
+ } else {
1769
+ echo __( 'No gallery chosen', 'grand-media' ) . PHP_EOL;
1770
+ }
1771
+ } elseif ( ( 'import-nextgen' === $import ) || isset( $_POST['import-nextgen'] ) ) {
1772
+
1773
+ echo '<h4 style="margin: 0 0 10px">' . __( 'Import from NextGen plugin' ) . ":</h4>" . PHP_EOL;
1774
+
1775
+ $gallery = $gmCore->_post( 'gallery' );
1776
+ if ( ! empty( $gallery ) ) {
1777
+ $album = ( ! isset( $terms['gmedia_album'] ) || empty( $terms['gmedia_album'] ) ) ? false : true;
1778
+ foreach ( $gallery as $gid ) {
1779
+ $ngg_gallery = $wpdb->get_row( $wpdb->prepare( "SELECT gid, path, title, galdesc FROM {$wpdb->prefix}ngg_gallery WHERE gid = %d", $gid ), ARRAY_A );
1780
+ if ( empty( $ngg_gallery ) ) {
1781
+ continue;
1782
+ }
1783
+
1784
+ if ( ! $album ) {
1785
+ $terms['gmedia_album'] = $ngg_gallery['title'];
1786
+ if ( $gmCore->is_digit( $terms['gmedia_album'] ) ) {
1787
+ $terms['gmedia_album'] = 'a' . $ngg_gallery['title'];
1788
+ }
1789
+ if ( ! $gmDB->term_exists( $terms['gmedia_album'], 'gmedia_album' ) ) {
1790
+ $term_id = $gmDB->insert_term( $terms['gmedia_album'], 'gmedia_album', [ 'description' => htmlspecialchars_decode( stripslashes( $ngg_gallery['galdesc'] ) ) ] );
1791
+ }
1792
+ }
1793
+
1794
+ $path = ABSPATH . trailingslashit( $ngg_gallery['path'] );
1795
+
1796
+ echo '<h5 style="margin: 10px 0 5px">' . sprintf( __( 'Import `%s` gallery', 'grand-media' ), esc_html( $ngg_gallery['title'] ) ) . ":</h5>" . PHP_EOL;
1797
+
1798
+ $ngg_pictures = $wpdb->get_results( $wpdb->prepare( "SELECT CONCAT('%s', filename) AS file, description, alttext AS title, pid FROM {$wpdb->prefix}ngg_pictures WHERE galleryid = %d", $path, $ngg_gallery['gid'] ), ARRAY_A );
1799
+ if ( empty( $ngg_pictures ) ) {
1800
+ echo '<pre>' . __( 'gallery contains 0 images', 'grand-media' ) . '</pre>';
1801
+ continue;
1802
+ } else {
1803
+ foreach ( $ngg_pictures as &$ngg_image ) {
1804
+ $ngg_terms = wp_get_object_terms( (int) $ngg_image['pid'], 'ngg_tag', [ 'fields' => 'names' ] );
1805
+ if ( ! empty( $ngg_terms ) ) {
1806
+ $ngg_image['terms']['gmedia_tag'] = $ngg_terms;
1807
+ }
1808
+ }
1809
+ }
1810
+ $exists = $gmCore->_post( 'skip_exists', 0 );
1811
+
1812
+ $gmCore->gmedia_import_files( $ngg_pictures, $terms, false, $exists );
1813
+ }
1814
+ } else {
1815
+ echo __( 'No gallery chosen', 'grand-media' ) . PHP_EOL;
1816
+ }
1817
+ } elseif ( ( 'import-wpmedia' === $import ) || isset( $_POST['import-wpmedia'] ) ) {
1818
+
1819
+ echo '<h4 style="margin: 0 0 10px">' . __( 'Import from WP Media Library' ) . ":</h4>" . PHP_EOL;
1820
+
1821
+ $wpMediaLib = $gmDB->get_wp_media_lib( [ 'filter' => 'selected', 'selected' => $gmCore->_post( 'selected' ) ] );
1822
+
1823
+ if ( ! empty( $wpMediaLib ) ) {
1824
+
1825
+ $wp_media = [];
1826
+ foreach ( $wpMediaLib as $item ) {
1827
+ $wp_media[] = [
1828
+ 'file' => get_attached_file( $item->ID ),
1829
+ 'author' => $item->post_author,
1830
+ 'title' => $item->post_title,
1831
+ 'description' => $item->post_content,
1832
+ ];
1833
+ }
1834
+ $exists = $gmCore->_post( 'skip_exists', 0 );
1835
+ //echo '<pre>' . print_r($wp_media, true) . '</pre>';
1836
+ $gmCore->gmedia_import_files( $wp_media, $terms, false, $exists );
1837
+
1838
+ } else {
1839
+ echo __( 'No items chosen', 'grand-media' ) . PHP_EOL;
1840
+ }
1841
+ }
1842
+ ?>
1843
+ </body>
1844
+ </html>
1845
+ <?php
1846
+ wp_ob_end_flush_all();
1847
+
1848
+ die();
1849
+ }
1850
+
1851
+ add_action( 'wp_ajax_gmedia_application', 'gmedia_application' );
1852
+ function gmedia_application() {
1853
+ global $gmCore, $gmGallery;
1854
+
1855
+ // if nonce is not correct it returns -1.
1856
+ check_ajax_referer( 'GmediaService' );
1857
+ if ( ! current_user_can( 'manage_options' ) ) {
1858
+ die( '-1' );
1859
+ }
1860
+
1861
+ $service = $gmCore->_post( 'service' );
1862
+ if ( ! $service ) {
1863
+ die( '0' );
1864
+ }
1865
+ $options = $gmGallery->options;
1866
+
1867
+ if ( 'skip' === $service ) {
1868
+ $options['gmedia_service'] = $service;
1869
+ if ( (int) $options['mobile_app'] ) {
1870
+ $options['mobile_app'] = 0;
1871
+ $service = 'app_deactivate';
1872
+ } else {
1873
+ $gmGallery->options = $options;
1874
+ update_option( 'gmediaOptions', $options );
1875
+ wp_send_json_success();
1876
+ }
1877
+ } elseif ( 'allow' === $service ) {
1878
+ $options['gmedia_service'] = $service;
1879
+ $service = 'app_activate';
1880
+ }
1881
+
1882
+ if ( $options !== $gmGallery->options ) {
1883
+ $gmGallery->options = $options;
1884
+ update_option( 'gmediaOptions', $options );
1885
+ }
1886
+
1887
+ $result = $gmCore->app_service( $service );
1888
+
1889
+ header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ), true );
1890
+ echo wp_json_encode( $result );
1891
+
1892
+ die();
1893
+ }
1894
+
1895
+ add_action( 'wp_ajax_gmedia_share_page', 'gmedia_share_page' );
1896
+ function gmedia_share_page() {
1897
+ global $gmCore, $user_ID;
1898
+ // if nonce is not correct it returns -1.
1899
+ check_ajax_referer( 'gmedia_share', '_wpnonce_share' );
1900
+
1901
+ $sharelink = $gmCore->_post( 'sharelink', '' );
1902
+ $email = $gmCore->_post( 'email', '' );
1903
+ $sharemessage = $gmCore->_post( 'message', '' );
1904
+ if ( ! filter_var( $email, FILTER_VALIDATE_EMAIL ) ) {
1905
+ echo $gmCore->alert( 'danger', __( 'Invalid email', 'grand-media' ) . ': ' . esc_html( $email ) );
1906
+ die();
1907
+ }
1908
+
1909
+ $display_name = esc_html( get_the_author_meta( 'display_name', $user_ID ) );
1910
+ $subject = sprintf( __( '%s shared GmediaCloud Page with you', 'grand-media' ), $display_name );
1911
+ $sharetitle = sprintf( __( '%s used Gmedia to share something interesting with you!', 'grand-media' ), $display_name );
1912
+ $sharelinktext = __( 'Click here to view page', 'grand-media' );
1913
+ if ( $sharemessage ) {
1914
+ $sharemessage = '<blockquote>"' . nl2br( esc_html( $sharemessage ) ) . '"</blockquote>';
1915
+ }
1916
+ $footer = '© ' . date( 'Y' ) . ' GmediaGallery';
1917
+ $message = <<<EOT
1918
+ <center>
1919
+ <table cellpadding="0" cellspacing="0" style="border-radius:4px;border:1px #dceaf5 solid;" border="0" align="center">
1920
+ <tr><td colspan="3" height="20"></td></tr>
1921
+ <tr style="line-height:0;">
1922
+ <td width="100%" style="font-size:0;" align="center" height="1">
1923
+ <img width="72" style="max-height:72px;width:72px;" alt="GmediaGallery" src="http://mypgc.co/images/email/logo-128.png" />
1924
+ </td>
1925
+ </tr>
1926
+ <tr><td>
1927
+ <table cellpadding="0" cellspacing="0" style="line-height:25px;" border="0" align="center">
1928
+ <tr><td colspan="3" height="20"></td></tr>
1929
+ <tr>
1930
+ <td width="36"></td>
1931
+ <td width="454" align="left" style="color:#444444;border-collapse:collapse;font-size:11pt;font-family:proxima_nova,'Open Sans','Lucida Grande','Segoe UI',Arial,Verdana,'Lucida Sans Unicode',Tahoma,'Sans Serif';max-width:454px;" valign="top">{$sharetitle}<br />
1932
+ {$sharemessage}
1933
+ <br /><a style="color:#0D8FB3" href="{$sharelink}">{$sharelinktext}</a>.</td>
1934
+ <td width="36"></td>
1935
+ </tr>
1936
+ <tr><td colspan="3" height="36"></td></tr>
1937
+ </table>
1938
+ </td>
1939
+ </tr>
1940
+ </table>
1941
+ <table cellpadding="0" cellspacing="0" align="center" border="0">
1942
+ <tr><td height="10"></td></tr>
1943
+ <tr><td style="padding:0;border-collapse:collapse;">
1944
+ <table cellpadding="0" cellspacing="0" align="center" border="0">
1945
+ <tr style="color:#a8b9c6;font-size:11px;font-family:proxima_nova,'Open Sans','Lucida Grande','Segoe UI',Arial,Verdana,'Lucida Sans Unicode',Tahoma,'Sans Serif';">
1946
+ <td width="128" align="left"></td>
1947
+ <td width="400" align="right">{$footer}</td>
1948
+ </tr>
1949
+ </table>
1950
+ </td>
1951
+ </tr>
1952
+ </table>
1953
+ </center>
1954
+ EOT;
1955
+
1956
+ $headers = [ 'Content-Type: text/html; charset=UTF-8' ];
1957
+ if ( wp_mail( $email, $subject, $message, $headers ) ) {
1958
+ echo $gmCore->alert( 'success', sprintf( __( 'Message sent to %s', 'grand-media' ), $email ) );
1959
+ }
1960
+
1961
+ die();
1962
+ }
1963
+
1964
+ add_action( 'wp_ajax_gmedia_add_custom_field', 'gmedia_add_custom_field' );
1965
+ function gmedia_add_custom_field() {
1966
+ global $gmDB, $user_ID, $gmCore;
1967
+ check_ajax_referer( 'gmedia_custom_field', '_wpnonce_custom_field' );
1968
+
1969
+ $meta_type = 'gmedia';
1970
+
1971
+ $pid = (int) $_POST['ID'];
1972
+ $post = $gmDB->get_gmedia( $pid );
1973
+
1974
+ header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ), true );
1975
+
1976
+ if ( ! current_user_can( 'gmedia_edit_media' ) || ( $user_ID !== $post->author && ! current_user_can( 'gmedia_edit_others_media' ) ) ) {
1977
+ echo wp_json_encode( [ 'error' => [ 'code' => 100, 'message' => __( 'You are not allowed to edit others media', 'grand-media' ) ], 'id' => $pid ] );
1978
+ die();
1979
+ }
1980
+ if ( isset( $_POST['metakeyselect'] ) && empty( $_POST['metakeyselect'] ) && empty( $_POST['metakeyinput'] ) ) {
1981
+ echo wp_json_encode( [ 'error' => [ 'code' => 101, 'message' => __( 'Choose or provide a custom field name', 'grand-media' ) ], 'id' => $pid ] );
1982
+ die();
1983
+ }
1984
+
1985
+ if ( ! $mid = $gmCore->add_meta( $pid, $meta_type ) ) {
1986
+ echo wp_json_encode( [ 'error' => [ 'code' => 102, 'message' => __( 'Please provide a custom field value', 'grand-media' ) ], 'id' => $pid ] );
1987
+ die();
1988
+ }
1989
+
1990
+ $column = sanitize_key( $meta_type . '_id' );
1991
+ $meta = $gmDB->get_metadata_by_mid( $meta_type, $mid );
1992
+ $pid = (int) $meta->{$column};
1993
+ $meta = get_object_vars( $meta );
1994
+ $result = [
1995
+ 'success' => [
1996
+ 'meta_id' => $mid,
1997
+ 'data' => $gmCore->_list_meta_item( $meta, $meta_type ),
1998
+ ],
1999
+ 'id' => $pid,
2000
+ ];
2001
+
2002
+ if ( ! empty( $_POST['metakeyinput'] ) ) {
2003
+ $result['newmeta_form'] = $gmCore->meta_form( $meta_type );
2004
+ }
2005
+
2006
+ echo wp_json_encode( $result );
2007
+ die();
2008
+
2009
+ }
2010
+
2011
+ add_action( 'wp_ajax_gmedia_delete_custom_field', 'gmedia_delete_custom_field' );
2012
+ function gmedia_delete_custom_field() {
2013
+ global $gmDB, $user_ID, $gmCore;
2014
+ check_ajax_referer( 'gmedia_custom_field', '_wpnonce_custom_field' );
2015
+
2016
+ $meta_type = 'gmedia';
2017
+
2018
+ $pid = (int) $_POST['ID'];
2019
+ $post = $gmDB->get_gmedia( $pid );
2020
+
2021
+ if ( ! current_user_can( 'gmedia_edit_media' ) || ( $user_ID !== $post->author && ! current_user_can( 'gmedia_edit_others_media' ) ) ) {
2022
+ echo wp_json_encode( [ 'error' => [ 'code' => 100, 'message' => __( 'You are not allowed to edit others media', 'grand-media' ) ], 'id' => $pid ] );
2023
+ die();
2024
+ }
2025
+
2026
+ $result = [ 'id' => $pid ];
2027
+
2028
+ $deletemeta = $_POST['meta'];
2029
+ $column = sanitize_key( $meta_type . '_id' );
2030
+ if ( isset( $deletemeta ) && is_array( $deletemeta ) ) {
2031
+ foreach ( $deletemeta as $key => $value ) {
2032
+ if ( ! $meta = $gmDB->get_metadata_by_mid( $meta_type, $key ) ) {
2033
+ continue;
2034
+ }
2035
+ if ( $meta->{$column} !== $pid ) {
2036
+ continue;
2037
+ }
2038
+ if ( $gmCore->is_protected_meta( $meta->meta_key, $meta_type ) ) {
2039
+ continue;
2040
+ }
2041
+ if ( ( $del_meta = $gmDB->delete_metadata_by_mid( $meta_type, $key ) ) ) {
2042
+ $result['deleted'][] = $key;
2043
+ }
2044
+ }
2045
+ }
2046
+
2047
+ header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ), true );
2048
+ echo wp_json_encode( $result );
2049
+ die();
2050
+
2051
+ }
2052
+
2053
+ add_action( 'wp_ajax_gmedia_term_add_custom_field', 'gmedia_term_add_custom_field' );
2054
+ function gmedia_term_add_custom_field() {
2055
+ global $gmDB, $user_ID, $gmCore;
2056
+ check_ajax_referer( 'gmedia_custom_field', '_wpnonce_custom_field' );
2057
+
2058
+ $meta_type = 'gmedia_term';
2059
+
2060
+ $pid = (int) $_POST['ID'];
2061
+ $post = $gmDB->get_term( $pid );
2062
+
2063
+ $taxonomy = $post->taxonomy;
2064
+
2065
+ header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ), true );
2066
+
2067
+ if ( ! current_user_can( $taxonomy . '_manage' ) || ( $user_ID !== $post->global && ! current_user_can( 'gmedia_edit_others_media' ) ) ) {
2068
+ echo wp_json_encode( [ 'error' => [ 'code' => 100, 'message' => __( 'You are not allowed to edit others media', 'grand-media' ) ], 'id' => $pid ] );
2069
+ die();
2070
+ }
2071
+ if ( isset( $_POST['metakeyselect'] ) && empty( $_POST['metakeyselect'] ) && empty( $_POST['metakeyinput'] ) ) {
2072
+ echo wp_json_encode( [ 'error' => [ 'code' => 101, 'message' => __( 'Choose or provide a custom field name', 'grand-media' ) ], 'id' => $pid ] );
2073
+ die();
2074
+ }
2075
+
2076
+ if ( ! $mid = $gmCore->add_meta( $pid, $meta_type ) ) {
2077
+ echo wp_json_encode( [ 'error' => [ 'code' => 102, 'message' => __( 'Please provide a custom field value', 'grand-media' ) ], 'id' => $pid ] );
2078
+ die();
2079
+ }
2080
+
2081
+ $column = sanitize_key( $meta_type . '_id' );
2082
+ $meta = $gmDB->get_metadata_by_mid( $meta_type, $mid );
2083
+ $pid = (int) $meta->{$column};
2084
+ $meta = get_object_vars( $meta );
2085
+ $result = [
2086
+ 'success' => [
2087
+ 'meta_id' => $mid,
2088
+ 'data' => $gmCore->_list_meta_item( $meta, $meta_type ),
2089
+ ],
2090
+ 'id' => $pid,
2091
+ ];
2092
+
2093
+ if ( ! empty( $_POST['metakeyinput'] ) ) {
2094
+ $result['newmeta_form'] = $gmCore->meta_form( $meta_type );
2095
+ }
2096
+
2097
+ echo wp_json_encode( $result );
2098
+ die();
2099
+ }
2100
+
2101
+ add_action( 'wp_ajax_gmedia_term_delete_custom_field', 'gmedia_term_delete_custom_field' );
2102
+ function gmedia_term_delete_custom_field() {
2103
+ global $gmDB, $user_ID, $gmCore;
2104
+ check_ajax_referer( 'gmedia_custom_field', '_wpnonce_custom_field' );
2105
+
2106
+ $meta_type = 'gmedia_term';
2107
+
2108
+ $pid = (int) $_POST['ID'];
2109
+ $post = $gmDB->get_term( $pid );
2110
+
2111
+ $taxonomy = $post->taxonomy;
2112
+
2113
+ header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ), true );
2114
+
2115
+ if ( ! current_user_can( $taxonomy . '_manage' ) || ( $user_ID !== $post->global && ! current_user_can( 'gmedia_edit_others_media' ) ) ) {
2116
+ echo wp_json_encode( [ 'error' => [ 'code' => 100, 'message' => __( 'You are not allowed to edit others media', 'grand-media' ) ], 'id' => $pid ] );
2117
+ die();
2118
+ }
2119
+
2120
+ $result = [ 'id' => $pid ];
2121
+
2122
+ $deletemeta = $_POST['meta'];
2123
+ $column = sanitize_key( $meta_type . '_id' );
2124
+ if ( isset( $deletemeta ) && is_array( $deletemeta ) ) {
2125
+ foreach ( $deletemeta as $key => $value ) {
2126
+ if ( ! $meta = $gmDB->get_metadata_by_mid( $meta_type, $key ) ) {
2127
+ continue;
2128
+ }
2129
+ if ( $meta->{$column} !== $pid ) {
2130
+ continue;
2131
+ }
2132
+ if ( $gmCore->is_protected_meta( $meta->meta_key, $meta_type ) ) {
2133
+ continue;
2134
+ }
2135
+ if ( ( $del_meta = $gmDB->delete_metadata_by_mid( $meta_type, $key ) ) ) {
2136
+ $result['deleted'][] = $key;
2137
+ }
2138
+ }
2139
+ }
2140
+
2141
+ echo wp_json_encode( $result );
2142
+ die();
2143
+ }
2144
+
2145
+ add_action( 'wp_ajax_gmedia_term_sortorder', 'gmedia_term_sortorder' );
2146
+ function gmedia_term_sortorder() {
2147
+ global $gmDB, $user_ID, $gmCore;
2148
+ check_ajax_referer( 'gmedia_terms', '_wpnonce_terms' );
2149
+
2150
+ $term_id = $gmCore->_post( 'term_id' );
2151
+ $idx0 = (int) $gmCore->_post( 'idx0' );
2152
+ $ids = $gmCore->_post( 'ids' );
2153
+
2154
+ if ( ! $idx0 || ! is_array( $ids ) ) {
2155
+ die();
2156
+ }
2157
+
2158
+ if ( ! current_user_can( 'gmedia_album_manage' ) ) {
2159
+ wp_send_json( [ 'error' => [ 'code' => 100, 'message' => __( 'You are not allowed to manage this taxonomy', 'grand-media' ) ], 'id' => $term_id ] );
2160
+ }
2161
+
2162
+ if ( ! $term_id || ! ( $term_id = $gmDB->term_exists( $term_id ) ) ) {
2163
+ wp_send_json( [ 'error' => [ 'code' => 101, 'message' => __( 'A term with the id provided does not exists', 'grand-media' ) ], 'id' => $term_id ] );
2164
+ }
2165
+ $term = $gmDB->get_term( $term_id );
2166
+ if ( ( (int) $term->global !== (int) $user_ID ) && ! current_user_can( 'gmedia_edit_others_media' ) ) {
2167
+ wp_send_json( [ 'error' => [ 'code' => 102, 'message' => __( 'You are not allowed to edit others media', 'grand-media' ) ], 'id' => $term_id ] );
2168
+ }
2169
+
2170
+ $gm_ids_order = [];
2171
+ foreach ( $ids as $id ) {
2172
+ $gm_ids_order[ $id ] = $idx0;
2173
+ $idx0 ++;
2174
+ }
2175
+
2176
+ $term_id = $gmDB->update_term_sortorder( $term_id, $gm_ids_order );
2177
+ if ( is_wp_error( $term_id ) ) {
2178
+ wp_send_json( [ 'error' => [ 'code' => 103, 'message' => $term_id->get_error_message() ], 'id' => $term_id ] );
2179
+ }
2180
+
2181
+ wp_send_json_success( $term_id );
2182
+ }
2183
+
2184
+ add_action( 'wp_ajax_gmedia_upgrade_process', 'gmedia_upgrade_process' );
2185
+ function gmedia_upgrade_process() {
2186
+
2187
+ $db_version = get_option( 'gmediaDbVersion' );
2188
+ $info = get_transient( 'gmediaHeavyJob' );
2189
+ $result = [ 'content' => '' ];
2190
+
2191
+ $upgrading = get_transient( 'gmediaUpgrade' );
2192
+ if ( $upgrading ) {
2193
+ $timeout = time() - $upgrading;
2194
+ } else {
2195
+ $timeout = 0;
2196
+ }
2197
+ if ( $timeout > 20 ) {
2198
+ require_once GMEDIA_ABSPATH . 'config/update.php';
2199
+ gmedia_db_update();
2200
+ }
2201
+ $result['timeout'] = $timeout;
2202
+
2203
+ if ( ! empty( $info ) ) {
2204
+ $result['content'] = '<div>' . implode( "</div>\n<div>", $info ) . '</div>';
2205
+ } elseif ( $db_version === GMEDIA_DBVERSION ) {
2206
+ $result['status'] = 'done';
2207
+ }
2208
+
2209
+ header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ), true );
2210
+ echo wp_json_encode( $result );
2211
+ die();
2212
+ }
2213
+
2214
+ add_action( 'wp_ajax_gmedia_hash_files', 'gmedia_hash_files' );
2215
+ function gmedia_hash_files() {
2216
+ global $wpdb, $gmCore, $gmDB;
2217
+
2218
+ check_ajax_referer( 'gmedia_ajax_long_operations', '_wpnonce_ajax_long_operations' );
2219
+
2220
+ $all_count = wp_cache_get( 'gmedia_count_all' );
2221
+ if ( false === $all_count ) {
2222
+ $all_count = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}gmedia" );
2223
+ wp_cache_set( 'gmedia_count_all', $all_count );
2224
+ }
2225
+ $sql = "SELECT SQL_CALC_FOUND_ROWS ID, gmuid FROM {$wpdb->prefix}gmedia AS g WHERE 1 = 1
2226
+ AND ( NOT EXISTS ( SELECT * FROM {$wpdb->prefix}gmedia_meta AS gm WHERE gm.meta_key = '_hash' AND gm.gmedia_id = g.ID )
2227
+ OR NOT EXISTS ( SELECT * FROM {$wpdb->prefix}gmedia_meta AS gm2 WHERE gm2.meta_key = '_size' AND gm2.gmedia_id = g.ID)
2228
+ )
2229
+ LIMIT 20";
2230
+ $unhashed = $wpdb->get_results( $sql );
2231
+ if ( ! $unhashed ) {
2232
+ $ajax_operations = get_option( 'gmedia_ajax_long_operations', [] );
2233
+ unset( $ajax_operations['gmedia_hash_files'] );
2234
+ if ( empty( $ajax_operations ) ) {
2235
+ delete_option( 'gmedia_ajax_long_operations' );
2236
+ } else {
2237
+ update_option( 'gmedia_ajax_long_operations', $ajax_operations );
2238
+ }
2239
+ wp_cache_delete( 'gmedia_count_all' );
2240
+
2241
+ wp_send_json_success( [ 'progress' => '100%', 'info' => __( 'Indexing:', 'grand-media' ), 'done' => true ] );
2242
+ }
2243
+
2244
+ $unhashed_count = $wpdb->get_var( 'SELECT FOUND_ROWS()' );
2245
+
2246
+ foreach ( $unhashed as $item ) {
2247
+ $fileinfo = $gmCore->fileinfo( $item->gmuid, false );
2248
+ $filepath = is_file( $fileinfo['filepath_original'] ) ? $fileinfo['filepath_original'] : $fileinfo['filepath'];
2249
+ $hash_file = hash_file( 'md5', $filepath );
2250
+ $gmDB->update_metadata( $meta_type = 'gmedia', $item->ID, $meta_key = '_hash', $hash_file );
2251
+ $file_size = filesize( $filepath );
2252
+ $gmDB->update_metadata( $meta_type = 'gmedia', $item->ID, $meta_key = '_size', $file_size );
2253
+ }
2254
+
2255
+ $progress = round( ( $all_count - $unhashed_count ) * 100 / $all_count );
2256
+
2257
+ wp_send_json_success( [ 'progress' => "{$progress}%", 'info' => __( 'Indexing:', 'grand-media' ) ] );
2258
+ }
2259
+
2260
+ add_action( 'wp_ajax_gmedia_recreate_images', 'gmedia_recreate_images' );
2261
+ function gmedia_recreate_images() {
2262
+ global $gmCore;
2263
+
2264
+ check_ajax_referer( 'gmedia_ajax_long_operations', '_wpnonce_ajax_long_operations' );
2265
+
2266
+ $gmid = 0;
2267
+ $ajax_operations = get_option( 'gmedia_ajax_long_operations', [] );
2268
+ if ( ! empty( $ajax_operations['gmedia_recreate_images'] ) ) {
2269
+ $all_count = count( $ajax_operations['gmedia_recreate_images'] );
2270
+ $recreate_ids = array_filter( $ajax_operations['gmedia_recreate_images'] );
2271
+ $do_count = count( $recreate_ids );
2272
+
2273
+ if ( ! empty( $recreate_ids ) ) {
2274
+ $gmid = reset( $recreate_ids );
2275
+ $gmCore->recreate_images_from_original( $gmid );
2276
+
2277
+ $ajax_operations['gmedia_recreate_images'][ $gmid ] = false;
2278
+ update_option( 'gmedia_ajax_long_operations', $ajax_operations );
2279
+ } else {
2280
+ unset( $ajax_operations['gmedia_recreate_images'] );
2281
+ }
2282
+
2283
+ if ( empty( $ajax_operations ) ) {
2284
+ delete_option( 'gmedia_ajax_long_operations' );
2285
+
2286
+ wp_send_json_success( [ 'progress' => '100%', 'info' => __( 'Done:', 'grand-media' ), 'done' => true, 'id' => $gmid ] );
2287
+ } else {
2288
+ $progress = round( ( $all_count - $do_count ) * 100 / $all_count );
2289
+
2290
+ wp_send_json_success( [ 'progress' => "{$progress}%", 'info' => __( 'Working:', 'grand-media' ), 'id' => $gmid ] );
2291
+ }
2292
+ }
2293
+
2294
+ wp_send_json_success( [ 'progress' => '100%', 'info' => __( 'Done:', 'grand-media' ), 'done' => true, 'id' => $gmid ] );
2295
+ }
2296
+
2297
+ add_action( 'wp_ajax_gmedia_feedback', 'gmedia_feedback' );
2298
+ function gmedia_feedback() {
2299
+ global $gmCore;
2300
+
2301
+ check_ajax_referer( 'gmedia_feedback', '_wpnonce_gmedia_feedback' );
2302
+
2303
+ $data = $gmCore->_post( 'data' );
2304
+
2305
+ if ( ! empty( $data ) ) {
2306
+ $current_user = wp_get_current_user();
2307
+ $title = "Deactivate Reason: " . urldecode( $data['reason'] );
2308
+ $content = 'Website: ' . home_url() . "\r\n\r\n";
2309
+ foreach ( $data as $key => $val ) {
2310
+ $content .= ucwords( str_replace( '_', ' ', $key ) ) . ': ' . urldecode( $val ) . "\r\n\r\n";
2311
+ }
2312
+ $headers = [
2313
+ "From: Gmedia Feedback <feedback@gmedia.gallery>",
2314
+ "Reply-To: {$current_user->display_name} <{$current_user->user_email}>",
2315
+ ];
2316
+ wp_mail( 'codeasily@gmail.com', $title, $content, $headers );
2317
+ }
2318
+
2319
+ wp_send_json_success();
2320
+ }
2321
+
2322
+ add_action( 'wp_ajax_gmedia_save_waveform', 'gmedia_save_waveform' );
2323
+ add_action( 'wp_ajax_nopriv_gmedia_save_waveform', 'gmedia_save_waveform' );
2324
+ function gmedia_save_waveform() {
2325
+ global $gmCore, $gmDB;
2326
+
2327
+ check_ajax_referer( 'GmediaGallery' );
2328
+
2329
+ $id = $gmCore->_post( 'id' );
2330
+ $peaks = $gmCore->_post( 'peaks' );
2331
+ if ( $id && $peaks ) {
2332
+ $peaks_arr = json_decode( $peaks );
2333
+ $peaks_arr = array_filter( $peaks_arr, 'is_numeric' );
2334
+ if ( 3600 !== count( $peaks_arr ) ) {
2335
+ wp_send_json_error( [ 'peaks_cnt' => count( $peaks_arr ) ] );
2336
+ }
2337
+
2338
+ $gmDB->update_metadata( 'gmedia', $id, '_peaks', $peaks );
2339
+ do_action( 'clean_gmedia_cache', $id );
2340
+ wp_send_json_success( [ 'peaks' => $peaks ] );
2341
+ } else {
2342
+ wp_send_json_error();
2343
+ }
2344
+ }
2345
+
2346
+ add_action( 'wp_ajax_gmedia_module_interaction', 'gmedia_module_interaction' );
2347
+ add_action( 'wp_ajax_nopriv_gmedia_module_interaction', 'gmedia_module_interaction' );
2348
+ function gmedia_module_interaction() {
2349
+ global $gmDB, $gmCore;
2350
+
2351
+ if ( empty( $_SERVER['HTTP_REFERER'] ) ) {
2352
+ header( $_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request' );
2353
+ die();
2354
+ }
2355
+
2356
+ $ref = $_SERVER['HTTP_REFERER'];
2357
+ //$uip = str_replace('.', '', $_SERVER['REMOTE_ADDR'])
2358
+ if ( ( false === strpos( $ref, get_home_url() ) ) && ( false === strpos( $ref, get_site_url() ) ) ) {
2359
+ header( $_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request' );
2360
+ die();
2361
+ }
2362
+ if ( ( 'POST' !== $_SERVER['REQUEST_METHOD'] ) || ! isset( $_SERVER['HTTP_HOST'] ) || ! strpos( get_home_url(), $_SERVER['HTTP_HOST'] ) ) {
2363
+ header( $_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request' );
2364
+ die();
2365
+ }
2366
+
2367
+
2368
+ if ( isset( $_POST['hit'] ) && ( $gmID = intval( $_POST['hit'] ) ) ) {
2369
+ if ( null === $gmDB->get_gmedia( $gmID ) ) {
2370
+ die( '0' );
2371
+ }
2372
+ $meta['views'] = $gmDB->get_metadata( 'gmedia', $gmID, 'views', true );
2373
+ $meta['likes'] = $gmDB->get_metadata( 'gmedia', $gmID, 'likes', true );
2374
+
2375
+ $meta = array_map( 'intval', $meta );
2376
+ $meta = $gmCore->gm_hitcounter( $gmID, $meta );
2377
+
2378
+ header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ), true );
2379
+ echo wp_json_encode( $meta );
2380
+ die();
2381
+ }
2382
+
2383
+ if ( isset( $_POST['rate'] ) ) {
2384
+ /**
2385
+ * @var $uip
2386
+ * @var $gmid
2387
+ * @var $rate
2388
+ */
2389
+ extract( $_POST['rate'], EXTR_OVERWRITE );
2390
+ if ( ! intval( $gmid ) || ( null === $gmDB->get_gmedia( $gmid ) ) ) {
2391
+ die( '0' );
2392
+ }
2393
+ $rating = $gmDB->get_metadata( 'gmedia', $gmid, '_rating', true );
2394
+ $rating = wp_parse_args( (array) $rating, [ 'votes' => 0, 'value' => 0 ] );
2395
+ $old_rate = 0;
2396
+
2397
+ $transient_key = 'gm_rate_day' . date( 'w' );
2398
+ $transient_value = get_transient( $transient_key );
2399
+ if ( false !== $transient_value ) {
2400
+ if ( isset( $transient_value[ $uip ][ $gmid ] ) ) {
2401
+ $old_rate = $transient_value[ $uip ][ $gmid ];
2402
+ }
2403
+ $transient_value[ $uip ][ $gmid ] = $rate;
2404
+ } else {
2405
+ $transient_value = [ $uip => [ $gmid => $rate ] ];
2406
+ }
2407
+ set_transient( $transient_key, $transient_value, 18 * HOUR_IN_SECONDS );
2408
+
2409
+ do_action( 'gmedia_rate', $gmid, $rating['value'] );
2410
+
2411
+ $rating['votes'] = $old_rate ? $rating['votes'] : $rating['votes'] + 1;
2412
+ $rating['value'] = ( $rating['value'] * $rating['votes'] + $rate - $old_rate ) / $rating['votes'];
2413
+
2414
+ $gmDB->update_metadata( 'gmedia', $gmid, '_rating', $rating );
2415
+
2416
+ header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ), true );
2417
+ echo wp_json_encode( [ $rating ] );
2418
+ die();
2419
+ }
2420
+
2421
+ die();
2422
+ }
2423
+
2424
+ add_action( 'wp_ajax_load_comments', 'gmedia_module_load_comments' );
2425
+ add_action( 'wp_ajax_nopriv_load_comments', 'gmedia_module_load_comments' );
2426
+ function gmedia_module_load_comments() {
2427
+ global $gmCore;
2428
+
2429
+ /* if(empty($_SERVER['HTTP_REFERER'])) {
2430
+ header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
2431
+ die();
2432
+ }
2433
+
2434
+ $ref = $_SERVER['HTTP_REFERER'];
2435
+ //$uip = str_replace('.', '', $_SERVER['REMOTE_ADDR'])
2436
+ if((false === strpos($ref, get_home_url())) && (false === strpos($ref, get_site_url()))) {
2437
+ header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
2438
+ die();
2439
+ }
2440
+ if(('POST' !== $_SERVER['REQUEST_METHOD']) || !isset($_SERVER['HTTP_HOST']) || !strpos(get_home_url(), $_SERVER['HTTP_HOST'])) {
2441
+ header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
2442
+ die();
2443
+ }*/
2444
+
2445
+ check_ajax_referer( 'GmediaGallery' );
2446
+
2447
+ $data = $gmCore->_post( 'data', false );
2448
+
2449
+ $post_id = (int) $data['post_id'];
2450
+ if ( $post_id ) {
2451
+ $comments_link = apply_filters( 'gmedia_comments_link', add_query_arg( 'comments', 'show', get_permalink( $post_id ) ), $post_id );
2452
+ $comments_count = wp_count_comments( $post_id );
2453
+ $comments_count = $comments_count->approved;
2454
+ } else {
2455
+ $comments_link = '//about:blank';
2456
+ $comments_count = 0;
2457
+ }
2458
+
2459
+ $result = [];
2460
+ $result['comments_count'] = $comments_count;
2461
+ $result['content'] = "<iframe class='gmedia-comments' src='{$comments_link}' frameborder='0' allowtransparency='true'>";
2462
+
2463
+ header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ), true );
2464
+ echo wp_json_encode( $result );
2465
+
2466
+ die();
2467
+ }
2468
+
2469
+ add_action( 'wp_ajax_gmedia_get_data', 'gmedia_get_data' );
2470
+ add_action( 'wp_ajax_nopriv_gmedia_get_data', 'gmedia_get_data' );
2471
+ function gmedia_get_data() {
2472
+ global $gmDB, $gmProcessor, $gmGallery;
2473
+
2474
+ /** @var $gmProcessorLibrary */
2475
+ include_once GMEDIA_ABSPATH . 'admin/processor/class.processor.library.php';
2476
+
2477
+ $gmProcessorLibrary->user_options = $gmProcessor::user_options();
2478
+ $query_args = $gmProcessorLibrary->query_args();
2479
+
2480
+ $cache_expiration = isset( $gmGallery->options['cache_expiration'] ) ? (int) $gmGallery->options['cache_expiration'] * HOUR_IN_SECONDS : 24 * HOUR_IN_SECONDS;
2481
+ if ( $cache_expiration ) {
2482
+ $cache_key = 'gm_cache_' . md5( wp_json_encode( $query_args ) );
2483
+ $cache_value = get_transient( $cache_key );
2484
+ }
2485
+
2486
+ if ( ! empty( $cache_value ) ) {
2487
+ header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ), true );
2488
+ echo $cache_value;
2489
+ } else {
2490
+ $gmedia_query = $gmDB->get_gmedias( $query_args );
2491
+ foreach ( $gmedia_query as &$item ) {
2492
+ gmedia_item_more_data( $item );
2493
+ }
2494
+ $json_string = wp_json_encode( $gmedia_query );
2495
+ if ( $cache_expiration ) {
2496
+ set_transient( $cache_key, $json_string, $cache_expiration );
2497
+ }
2498
+
2499
+ header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ), true );
2500
+ echo $json_string;
2501
+ }
2502
+
2503
+ die();
2504
+ }
admin/app.php CHANGED
@@ -1,179 +1,180 @@
1
  <?php
2
- if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])){
3
- die('You are not allowed to call this page directly.');
4
  }
5
 
6
  /**
7
  * gmediaApp()
 
8
  * @return mixed content
9
  */
10
- function gmediaApp(){
11
- global $gmCore, $gmGallery;
12
-
13
- if(false !== ($force_app_status = $gmCore->_get('force_app_status'))){
14
- $gm_options = get_option('gmediaOptions');
15
- $gm_options['mobile_app'] = (int)$force_app_status;
16
- $gmGallery->options['mobile_app'] = $gm_options['mobile_app'];
17
- if(!$gm_options['site_ID']){
18
- $gm_options['site_ID'] = (int)$gmCore->_get('force_site_id');
19
- $gmGallery->options['site_ID'] = $gm_options['site_ID'];
20
- }
21
- update_option('gmediaOptions', $gm_options);
22
- }
23
-
24
- $alert = $gmCore->alert('danger', __('Your server is not accessable by iOS application', 'grand-media'));
25
-
26
- $site_ID = (int)$gmGallery->options['site_ID'];
27
- $mobile_app = (int)$gmGallery->options['mobile_app'];
28
-
29
- $current_user = wp_get_current_user();
30
-
31
- ?>
32
- <div class="panel panel-default" id="gm_application">
33
- <?php wp_nonce_field('GmediaService'); ?>
34
- <div class="panel-body" id="gmedia-service-msg-panel"><?php
35
- if(empty($_SERVER['HTTP_X_REAL_IP']) && ('127.0.0.1' == $_SERVER['REMOTE_ADDR'] || '::1' == $_SERVER['REMOTE_ADDR'])){
36
- echo $alert;
37
- } else{
38
- if(!$mobile_app || !$site_ID){
39
- echo $alert;
40
- ?>
41
- <div class="notice updated gm-message">
42
- <div class="gm-message-content">
43
- <div class="gm-plugin-icon">
44
- <img src="<?php echo plugins_url('/grand-media/admin/assets/img/icon-128x128.png') ?>" width="80" height="80">
45
- </div>
46
- <?php printf( __('<p>Hey %s,<br>You should allow some data about your <b>Gmedia Gallery</b> to be sent to <a href="https://codeasily.com/" target="_blank" tabindex="1">codeasily.com</a> in order to use iOS application.
47
- <br />These data required if you want to use Gmedia iOS application on your iPhone.</p>', 'grand-media'), $current_user->display_name ); ?>
48
- </div>
49
- <div class="gm-message-actions">
50
- <span class="spinner" style="float: none;"></span>
51
- <button class="button button-primary gm_service_action" data-action="allow" data-nonce="<?php echo wp_create_nonce('GmediaService'); ?>"><?php _e('Allow &amp; Continue', 'grand-media'); ?></button>
52
- </div>
53
- <div class="gm-message-plus gm-closed">
54
- <a class="gm-mp-trigger" href="#" onclick="jQuery('.gm-message-plus').toggleClass('gm-closed gm-opened'); return false;"><?php _e('What permissions are being granted?', 'grand-media'); ?></a>
55
- <ul>
56
- <li>
57
- <i class="dashicons dashicons-admin-users"></i>
58
-
59
- <div>
60
- <span><?php _e('Your Profile Overview', 'grand-media'); ?></span>
61
-
62
- <p><?php _e('Name and email address', 'grand-media'); ?></p>
63
- </div>
64
- </li>
65
- <li>
66
- <i class="dashicons dashicons-admin-settings"></i>
67
-
68
- <div>
69
- <span><?php _e('Your Site Overview', 'grand-media'); ?></span>
70
-
71
- <p><?php _e('Site URL, WP version, PHP version, active theme &amp; plugins', 'grand-media'); ?></p>
72
- </div>
73
- </li>
74
- </ul>
75
- </div>
76
- </div>
77
- <?php
78
- }
79
- }
80
-
81
- ?></div>
82
- <div class="panel-body" id="gm_application_data">
83
- <?php if(current_user_can('manage_options')){ ?>
84
- <div class="container-fluid">
85
- <div class="row">
86
- <div class="col-xs-6">
87
- <p><?php echo 'Server address: ' . $_SERVER['SERVER_ADDR'];
88
- echo '<br>Remote address: ' . $_SERVER['REMOTE_ADDR'];
89
- echo '<br>HTTP X Real IP: ' . ( isset($_SERVER['HTTP_X_REAL_IP'])? $_SERVER['HTTP_X_REAL_IP'] : '' );
90
- ?></p>
91
- <div class="gmapp-description">
92
- <div style="text-align:center; margin-bottom:30px;">
93
- <a target="_blank" href="https://itunes.apple.com/ua/app/gmedia/id947515626?mt=8"><img style="vertical-align:middle; max-width:100%; margin:0 30px; max-height:88px;" src="<?php echo $gmCore->gmedia_url; ?>/admin/assets/img/icon-128x128.png" alt=""/></a>
94
- <a target="_blank" href="https://itunes.apple.com/ua/app/gmedia/id947515626?mt=8"><img style="vertical-align:middle; max-width:100%; margin:0 30px;" src="<?php echo $gmCore->gmedia_url; ?>/admin/assets/img/appstore_button.png"/></a>
95
- </div>
96
-
97
- <p><?php _e('You are using one of the best plugins to create media library as well as your personal cloud storage on your WordPress website. You have chosen <strong><a href="https://wordpress.org/plugins/grand-media/" target="_blank">Gmedia Gallery Plugin</a></strong> and this choice gives you great opportunities to manage and organise your media library.', 'grand-media'); ?></p>
98
- <p><?php _e('We are happy to offer you a simple way to access your photos and audios by means of your iOS devices: at a few taps and you will be able to create great photo gallery and share it with your friends, readers and subscribers.', 'grand-media'); ?></p>
99
-
100
- <p class="text-center"><img style="max-width:90%;" src="<?php echo $gmCore->gmedia_url; ?>/admin/assets/img/slide1.jpg" alt=""/></p>
101
-
102
- <div class="text-left" style="padding-top:40%;">
103
- <div style="margin-right:20%">
104
- <h3><?php _e('DISCOVER and SHARE', 'grand-media'); ?></h3>
105
- <p><?php _e('Search, learn, open new horizons, share! It is just as easy as a piece of cake! Your photos will be seen by your friends, relatives and others.', 'grand-media'); ?></p>
106
- </div>
107
- <p><img style="max-width:90%;" src="<?php echo $gmCore->gmedia_url; ?>/admin/assets/img/slide3.jpg" alt=""/></p>
108
- </div>
109
- <div class="text-left" style="padding-top:40%;">
110
- <div style="margin-right:20%">
111
- <h3><?php _e('PRIVATE CONTENT', 'grand-media'); ?></h3>
112
- <p><?php _e('If you are one of subscribers, contributors, authors, editors or administrators, use your login and password to get an access to the private content.', 'grand-media'); ?></p>
113
- </div>
114
- <p><img style="max-width:90%;" src="<?php echo $gmCore->gmedia_url; ?>/admin/assets/img/slide5.jpg" alt=""/></p>
115
- </div>
116
-
117
- <div class="well well-lg text-center" style="margin-top:40%; padding-top:50px;">
118
- <p><?php _e('Download Gmedia iOS application from the App Store to manage your Gmedia&nbsp;Library from iPhone.', 'grand-media'); ?></p>
119
- <div>
120
- <a target="_blank" href="https://itunes.apple.com/ua/app/gmedia/id947515626?mt=8"><img style="vertical-align:middle; max-width:100%; margin:30px;" src="<?php echo $gmCore->gmedia_url; ?>/admin/assets/img/appstore_button.png"/></a>
121
- <a target="_blank" href="https://itunes.apple.com/ua/app/gmedia/id947515626?mt=8"><img style="vertical-align:middle; max-width:100%; margin:30px; max-height:88px;" src="<?php echo $gmCore->gmedia_url; ?>/admin/assets/img/icon-128x128.png" alt=""/></a>
122
- </div>
123
- </div>
124
- </div>
125
- </div>
126
- <div class="col-xs-6">
127
- <div class="well-lg well">
128
- <p><?php _e('Below you can see information about your website that will be used by GmediaService and iOS application, so you\'ll be able to manage your Gmedia Library with your smartphone and other people can find and view your public collections.', 'grand-media'); ?></p>
129
- <div class="form-group">
130
- <label><?php _e('Email', 'grand-media') ?>:</label>
131
- <input type="text" name="site_email" class="form-control input-sm" value="<?php esc_attr_e(get_option('admin_email')); ?>" readonly/>
132
- </div>
133
- <div class="form-group">
134
- <label><?php _e('Site URL', 'grand-media') ?>:</label>
135
- <input type="text" name="site_url" class="form-control input-sm" value="<?php echo home_url(); ?>" readonly/>
136
- </div>
137
- <div class="form-group">
138
- <label><?php _e('Site Title', 'grand-media') ?>:</label>
139
- <input type="text" name="site_title" class="form-control input-sm" value="<?php esc_attr_e(get_bloginfo('name')); ?>" readonly/>
140
- </div>
141
- <div class="form-group">
142
- <label><?php _e('Site Description', 'grand-media') ?>:</label>
143
- <textarea rows="2" cols="10" name="site_description" class="form-control input-sm" readonly><?php esc_attr_e(get_bloginfo('description')); ?></textarea>
144
- </div>
145
- </div>
146
-
147
- <div class="gmapp-description">
148
- <div class="text-right" style="padding-top:35%;">
149
- <div style="margin-left:20%">
150
- <h3><?php _e('FIND and ADD SITE it’s SIMPLY', 'grand-media'); ?></h3>
151
- <p><?php _e('Just a few touches and our smart search bar will let you find and add your website, your friend’s website or a famous blogger’s site to your favourites list.', 'grand-media'); ?></p>
152
- </div>
153
- <p><img style="max-width:90%;" src="<?php echo $gmCore->gmedia_url; ?>/admin/assets/img/slide2.jpg" alt=""/></p>
154
- </div>
155
-
156
- <div class="text-right" style="padding-top:35%;">
157
- <div style="margin-left:20%">
158
- <h3><?php _e('MP3', 'grand-media'); ?></h3>
159
- <p><?php _e('Take your favourite music track with you on a trip or create a playlist to travel with it! It is so simple with Gmedia. Share your energy and positive mood with your friends!', 'grand-media'); ?></p>
160
- </div>
161
- <p><img style="max-width:90%;" src="<?php echo $gmCore->gmedia_url; ?>/admin/assets/img/slide4.jpg" alt=""/></p>
162
- </div>
163
-
164
- <div class="text-right" style="padding-top:35%;">
165
- <div style="margin-left:20%">
166
- <h3><?php _e('GMEDIA LIBRARY', 'grand-media'); ?></h3>
167
- <p><?php _e('If you are one of subscribers, contributors,authors, editors or administrators, use your login and password to get an access to private content. If your type of users has an access to Gmedia Library, you will be able to create photo collections and download pictures just from iPhone, using wide functional opportunities of our app and plugin.', 'grand-media'); ?></p>
168
- </div>
169
- <p><img style="max-width:90%;" src="<?php echo $gmCore->gmedia_url; ?>/admin/assets/img/slide6.jpg" alt=""/></p>
170
- </div>
171
- </div>
172
- </div>
173
- </div>
174
- </div>
175
- <?php } ?>
176
- </div>
177
- </div>
178
- <?php
179
- }
1
  <?php
2
+ if ( preg_match( '#' . basename( __FILE__ ) . '#', $_SERVER['PHP_SELF'] ) ) {
3
+ die( 'You are not allowed to call this page directly.' );
4
  }
5
 
6
  /**
7
  * gmediaApp()
8
+ *
9
  * @return mixed content
10
  */
11
+ function gmediaApp() {
12
+ global $gmCore, $gmGallery;
13
+
14
+ if ( false !== ( $force_app_status = $gmCore->_get( 'force_app_status' ) ) ) {
15
+ $gm_options = get_option( 'gmediaOptions' );
16
+ $gm_options['mobile_app'] = (int) $force_app_status;
17
+ $gmGallery->options['mobile_app'] = $gm_options['mobile_app'];
18
+ if ( ! $gm_options['site_ID'] ) {
19
+ $gm_options['site_ID'] = (int) $gmCore->_get( 'force_site_id' );
20
+ $gmGallery->options['site_ID'] = $gm_options['site_ID'];
21
+ }
22
+ update_option( 'gmediaOptions', $gm_options );
23
+ }
24
+
25
+ $alert = $gmCore->alert( 'danger', __( 'Your server is not accessable by iOS application', 'grand-media' ) );
26
+
27
+ $site_ID = (int) $gmGallery->options['site_ID'];
28
+ $mobile_app = (int) $gmGallery->options['mobile_app'];
29
+
30
+ $current_user = wp_get_current_user();
31
+
32
+ ?>
33
+ <div class="panel panel-default" id="gm_application">
34
+ <?php wp_nonce_field( 'GmediaService' ); ?>
35
+ <div class="panel-body" id="gmedia-service-msg-panel"><?php
36
+ if ( empty( $_SERVER['HTTP_X_REAL_IP'] ) && ( '127.0.0.1' === $_SERVER['REMOTE_ADDR'] || '::1' === $_SERVER['REMOTE_ADDR'] ) ) {
37
+ echo $alert;
38
+ } else {
39
+ if ( ! $mobile_app || ! $site_ID ) {
40
+ echo $alert;
41
+ ?>
42
+ <div class="notice updated gm-message">
43
+ <div class="gm-message-content">
44
+ <div class="gm-plugin-icon">
45
+ <img src="<?php echo esc_url( plugins_url( '/grand-media/admin/assets/img/icon-128x128.png' ) ); ?>" width="80" height="80">
46
+ </div>
47
+ <?php printf( __( '<p>Hey %s,<br>You should allow some data about your <b>Gmedia Gallery</b> to be sent to <a href="https://codeasily.com/" target="_blank" tabindex="1">codeasily.com</a> in order to use iOS application.
48
+ <br />These data required if you want to use Gmedia iOS application on your iPhone.</p>', 'grand-media' ), $current_user->display_name ); ?>
49
+ </div>
50
+ <div class="gm-message-actions">
51
+ <span class="spinner" style="float: none;"></span>
52
+ <button class="button button-primary gm_service_action" data-action="allow" data-nonce="<?php echo esc_attr( wp_create_nonce( 'GmediaService' ) ); ?>"><?php _e( 'Allow &amp; Continue', 'grand-media' ); ?></button>
53
+ </div>
54
+ <div class="gm-message-plus gm-closed">
55
+ <a class="gm-mp-trigger" href="#" onclick="jQuery('.gm-message-plus').toggleClass('gm-closed gm-opened'); return false;"><?php _e( 'What permissions are being granted?', 'grand-media' ); ?></a>
56
+ <ul>
57
+ <li>
58
+ <i class="dashicons dashicons-admin-users"></i>
59
+
60
+ <div>
61
+ <span><?php _e( 'Your Profile Overview', 'grand-media' ); ?></span>
62
+
63
+ <p><?php _e( 'Name and email address', 'grand-media' ); ?></p>
64
+ </div>
65
+ </li>
66
+ <li>
67
+ <i class="dashicons dashicons-admin-settings"></i>
68
+
69
+ <div>
70
+ <span><?php _e( 'Your Site Overview', 'grand-media' ); ?></span>
71
+
72
+ <p><?php _e( 'Site URL, WP version, PHP version, active theme &amp; plugins', 'grand-media' ); ?></p>
73
+ </div>
74
+ </li>
75
+ </ul>
76
+ </div>
77
+ </div>
78
+ <?php
79
+ }
80
+ }
81
+
82
+ ?></div>
83
+ <div class="panel-body" id="gm_application_data">
84
+ <?php if ( current_user_can( 'manage_options' ) ) { ?>
85
+ <div class="container-fluid">
86
+ <div class="row">
87
+ <div class="col-xs-6">
88
+ <p><?php echo 'Server address: ' . $_SERVER['SERVER_ADDR'];
89
+ echo '<br>Remote address: ' . $_SERVER['REMOTE_ADDR'];
90
+ echo '<br>HTTP X Real IP: ' . ( isset( $_SERVER['HTTP_X_REAL_IP'] ) ? $_SERVER['HTTP_X_REAL_IP'] : '' );
91
+ ?></p>
92
+ <div class="gmapp-description">
93
+ <div style="text-align:center; margin-bottom:30px;">
94
+ <a target="_blank" href="https://itunes.apple.com/ua/app/gmedia/id947515626?mt=8"><img style="vertical-align:middle; max-width:100%; margin:0 30px; max-height:88px;" src="<?php echo esc_url( $gmCore->gmedia_url ); ?>/admin/assets/img/icon-128x128.png" alt=""/></a>
95
+ <a target="_blank" href="https://itunes.apple.com/ua/app/gmedia/id947515626?mt=8"><img style="vertical-align:middle; max-width:100%; margin:0 30px;" src="<?php echo esc_url( $gmCore->gmedia_url ); ?>/admin/assets/img/appstore_button.png"/></a>
96
+ </div>
97
+
98
+ <p><?php _e( 'You are using one of the best plugins to create media library as well as your personal cloud storage on your WordPress website. You have chosen <strong><a href="https://wordpress.org/plugins/grand-media/" target="_blank">Gmedia Gallery Plugin</a></strong> and this choice gives you great opportunities to manage and organise your media library.', 'grand-media' ); ?></p>
99
+ <p><?php _e( 'We are happy to offer you a simple way to access your photos and audios by means of your iOS devices: at a few taps and you will be able to create great photo gallery and share it with your friends, readers and subscribers.', 'grand-media' ); ?></p>
100
+
101
+ <p class="text-center"><img style="max-width:90%;" src="<?php echo esc_url( $gmCore->gmedia_url ); ?>/admin/assets/img/slide1.jpg" alt=""/></p>
102
+
103
+ <div class="text-left" style="padding-top:40%;">
104
+ <div style="margin-right:20%">
105
+ <h3><?php _e( 'DISCOVER and SHARE', 'grand-media' ); ?></h3>
106
+ <p><?php _e( 'Search, learn, open new horizons, share! It is just as easy as a piece of cake! Your photos will be seen by your friends, relatives and others.', 'grand-media' ); ?></p>
107
+ </div>
108
+ <p><img style="max-width:90%;" src="<?php echo esc_url( $gmCore->gmedia_url ); ?>/admin/assets/img/slide3.jpg" alt=""/></p>
109
+ </div>
110
+ <div class="text-left" style="padding-top:40%;">
111
+ <div style="margin-right:20%">
112
+ <h3><?php _e( 'PRIVATE CONTENT', 'grand-media' ); ?></h3>
113
+ <p><?php _e( 'If you are one of subscribers, contributors, authors, editors or administrators, use your login and password to get an access to the private content.', 'grand-media' ); ?></p>
114
+ </div>
115
+ <p><img style="max-width:90%;" src="<?php echo esc_url( $gmCore->gmedia_url ); ?>/admin/assets/img/slide5.jpg" alt=""/></p>
116
+ </div>
117
+
118
+ <div class="well well-lg text-center" style="margin-top:40%; padding-top:50px;">
119
+ <p><?php _e( 'Download Gmedia iOS application from the App Store to manage your Gmedia&nbsp;Library from iPhone.', 'grand-media' ); ?></p>
120
+ <div>
121
+ <a target="_blank" href="https://itunes.apple.com/ua/app/gmedia/id947515626?mt=8"><img style="vertical-align:middle; max-width:100%; margin:30px;" src="<?php echo esc_url( $gmCore->gmedia_url ); ?>/admin/assets/img/appstore_button.png"/></a>
122
+ <a target="_blank" href="https://itunes.apple.com/ua/app/gmedia/id947515626?mt=8"><img style="vertical-align:middle; max-width:100%; margin:30px; max-height:88px;" src="<?php echo esc_url( $gmCore->gmedia_url ); ?>/admin/assets/img/icon-128x128.png" alt=""/></a>
123
+ </div>
124
+ </div>
125
+ </div>
126
+ </div>
127
+ <div class="col-xs-6">
128
+ <div class="well-lg well">
129
+ <p><?php _e( 'Below you can see information about your website that will be used by GmediaService and iOS application, so you\'ll be able to manage your Gmedia Library with your smartphone and other people can find and view your public collections.', 'grand-media' ); ?></p>
130
+ <div class="form-group">
131
+ <label><?php _e( 'Email', 'grand-media' ) ?>:</label>
132
+ <input type="text" name="site_email" class="form-control input-sm" value="<?php echo esc_attr( get_option( 'admin_email' ) ); ?>" readonly/>
133
+ </div>
134
+ <div class="form-group">
135
+ <label><?php _e( 'Site URL', 'grand-media' ) ?>:</label>
136
+ <input type="text" name="site_url" class="form-control input-sm" value="<?php echo esc_url( home_url() ); ?>" readonly/>
137
+ </div>
138
+ <div class="form-group">
139
+ <label><?php _e( 'Site Title', 'grand-media' ) ?>:</label>
140
+ <input type="text" name="site_title" class="form-control input-sm" value="<?php echo esc_attr( get_bloginfo( 'name' ) ); ?>" readonly/>
141
+ </div>
142
+ <div class="form-group">
143
+ <label><?php _e( 'Site Description', 'grand-media' ) ?>:</label>
144
+ <textarea rows="2" cols="10" name="site_description" class="form-control input-sm" readonly><?php echo esc_attr( get_bloginfo( 'description' ) ); ?></textarea>
145
+ </div>
146
+ </div>
147
+
148
+ <div class="gmapp-description">
149
+ <div class="text-right" style="padding-top:35%;">
150
+ <div style="margin-left:20%">
151
+ <h3><?php _e( 'FIND and ADD SITE it’s SIMPLY', 'grand-media' ); ?></h3>
152
+ <p><?php _e( 'Just a few touches and our smart search bar will let you find and add your website, your friend’s website or a famous blogger’s site to your favourites list.', 'grand-media' ); ?></p>
153
+ </div>
154
+ <p><img style="max-width:90%;" src="<?php echo esc_url( $gmCore->gmedia_url ); ?>/admin/assets/img/slide2.jpg" alt=""/></p>
155
+ </div>
156
+
157
+ <div class="text-right" style="padding-top:35%;">
158
+ <div style="margin-left:20%">
159
+ <h3><?php _e( 'MP3', 'grand-media' ); ?></h3>
160
+ <p><?php _e( 'Take your favourite music track with you on a trip or create a playlist to travel with it! It is so simple with Gmedia. Share your energy and positive mood with your friends!', 'grand-media' ); ?></p>
161
+ </div>
162
+ <p><img style="max-width:90%;" src="<?php echo esc_url( $gmCore->gmedia_url ); ?>/admin/assets/img/slide4.jpg" alt=""/></p>
163
+ </div>
164
+
165
+ <div class="text-right" style="padding-top:35%;">
166
+ <div style="margin-left:20%">
167
+ <h3><?php _e( 'GMEDIA LIBRARY', 'grand-media' ); ?></h3>
168
+ <p><?php _e( 'If you are one of subscribers, contributors,authors, editors or administrators, use your login and password to get an access to private content. If your type of users has an access to Gmedia Library, you will be able to create photo collections and download pictures just from iPhone, using wide functional opportunities of our app and plugin.', 'grand-media' ); ?></p>
169
+ </div>
170
+ <p><img style="max-width:90%;" src="<?php echo esc_url( $gmCore->gmedia_url ); ?>/admin/assets/img/slide6.jpg" alt=""/></p>
171
+ </div>
172
+ </div>
173
+ </div>
174
+ </div>
175
+ </div>
176
+ <?php } ?>
177
+ </div>
178
+ </div>
179
+ <?php
180
+ }
admin/assets/css/gmedia-block.css CHANGED
@@ -1,46 +1,46 @@
1
  form.gmedia-preview {
2
- position: relative;
3
- overflow: hidden;
4
- box-sizing: border-box;
5
- width: 100%;
6
- display: flex;
7
- flex-wrap: wrap;
8
- flex-direction: row-reverse;
9
- justify-content: center;
10
  }
11
 
12
  form.gmedia-preview .form-fields {
13
- flex: 1;
14
- min-width: 30%;
15
  }
16
 
17
  form.gmedia-preview input,
18
  form.gmedia-preview select {
19
- display: block;
20
- width: 100%;
21
- margin: 5px 0 10px;
22
- box-sizing: border-box;
23
  }
24
 
25
  .gmedia-required {
26
- border-color: red !important;
27
  }
28
 
29
  img.gmedia-module-screenshot {
30
- object-fit: contain;
31
- flex: 1;
32
- width: 320px !important;
33
- height: 240px !important;
34
- margin: 0 20px 0 0;
35
  }
36
 
37
  .gmedia-shortcode {
38
- font-size: 12px;
39
- font-family: Courier, sans-serif;
40
- padding: 4px 10px;
41
- background-color: #fafafa;
42
- width: 100%;
43
- white-space: nowrap;
44
- overflow: hidden;
45
- text-overflow: ellipsis;
46
  }
1
  form.gmedia-preview {
2
+ position: relative;
3
+ overflow: hidden;
4
+ box-sizing: border-box;
5
+ width: 100%;
6
+ display: flex;
7
+ flex-wrap: wrap;
8
+ flex-direction: row-reverse;
9
+ justify-content: center;
10
  }
11
 
12
  form.gmedia-preview .form-fields {
13
+ flex: 1;
14
+ min-width: 30%;
15
  }
16
 
17
  form.gmedia-preview input,
18
  form.gmedia-preview select {
19
+ display: block;
20
+ width: 100%;
21
+ margin: 5px 0 10px;
22
+ box-sizing: border-box;
23
  }
24
 
25
  .gmedia-required {
26
+ border-color: red !important;
27
  }
28
 
29
  img.gmedia-module-screenshot {
30
+ object-fit: contain;
31
+ flex: 1;
32
+ width: 320px !important;
33
+ height: 240px !important;
34
+ margin: 0 20px 0 0;
35
  }
36
 
37
  .gmedia-shortcode {
38
+ font-size: 12px;
39
+ font-family: Courier, sans-serif;
40
+ padding: 4px 10px;
41
+ background-color: #fafafa;
42
+ width: 100%;
43
+ white-space: nowrap;
44
+ overflow: hidden;
45
+ text-overflow: ellipsis;
46
  }
admin/assets/css/gmedia.admin.css CHANGED
@@ -1,1674 +1,2013 @@
1
- .grand-media-admin-page #wpcontent { background-color: transparent !important; }
2
- .grand-media-admin-page #wpbody-content > .update-nag,
3
- .grand-media-admin-page #wpbody-content > .updated.fade {display:none;}
4
- #adminmenuback {z-index:0}
5
- #adminmenu #toplevel_page_GrandMedia ul.wp-submenu {
6
- display:none;
7
- }
8
- #wpfooter {
9
- color:#ffffff;
10
- }
11
- #wpfooter a {
12
- color:lightblue;
13
- }
14
- #TB_caption {
15
- height:auto;
16
- }
17
- a {
18
- color:#0074a2;
19
- }
20
- input[type="checkbox"] {
21
- margin-top:2px;
22
- margin-right:2px
23
- }
24
- input[type="checkbox"], input[type="radio"] {
25
- height:16px;
26
- width:16px;
27
- min-width: 0 !important;
28
- }
29
- input[type="button"] {
30
- min-width: 0 !important;
31
- }
32
- .checkbox, .radio {
33
- margin-top:5px;
34
- margin-bottom:5px;
35
- }
36
- input::-moz-focus-inner {
37
- border:0;
38
- padding:0;
39
- margin-top:-2px;
40
- margin-bottom:-2px;
41
- }
42
- form,
43
- .gmedia-admin form { margin:0; }
44
- legend.label { text-align:left; display:block; }
45
- textarea.vert { resize:vertical; }
46
- textarea.noResize { resize:none; }
47
- body.gmedia-busy {
48
- cursor:wait !important;
49
- }
50
- iframe {
51
- background-color:#ffffff;
52
- }
53
- select.disabled {pointer-events:none;}
54
- #gmedia-data-helper{
55
- background: #333;
56
- background: rgba(0,0,0,.8);
57
- border-radius: 5px;
58
- color: #fff;
59
- padding: 4px 10px;
60
- position: fixed;
61
- z-index: 999999;
62
- max-width: 220px;
63
- word-wrap:break-word;
64
- }
65
- #gmedia-data-helper:before{
66
- border: solid;
67
- border-color: #333 transparent;
68
- border-width: 0 6px 6px 6px;
69
- bottom: 100%;
70
- content: "";
71
- left: 17px;
72
- position: absolute;
73
- z-index: 99;
74
- }
75
- #gmedia-data-helper.tiptoleft:before{
76
- left: auto;
77
- right: 17px;
78
- }
79
- body.gmedia-blank {
80
- height:auto;
81
- min-height:100%;
82
- padding:0 0 1px;
83
- box-sizing:border-box;
84
- }
85
- body.gmedia-blank pre {
86
- margin:0;
87
- padding:0;
88
- border:none;
89
- }
90
- .gmedia-body div#gm-message {
91
- position:absolute;
92
- right:5px;
93
- top:5px;
94
- overflow:visible;
95
- z-index:200;
96
- }
97
- .gmedia-body div#gm-message .gm-message {
98
- text-align:right;
99
- }
100
- div#gmedia-container {
101
- font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;
102
- margin:30px 5px 10px 0;
103
- position:relative;
104
- z-index:1;
105
- direction:ltr;
106
- min-width:560px;
107
- -webkit-backface-visibility: hidden;
108
- backface-visibility: hidden;
109
- box-sizing:border-box;
110
- }
111
- div#gmedia-container * {
112
- box-sizing:inherit;
113
- }
114
- div#gmedia-container .row,
115
- div.gmedia-modal .row {
116
- padding: 0;
117
- }
118
-
119
- div#gmedia-container form.row {
120
- padding: 15px 0;
121
- }
122
-
123
- body.gmedia-blank div#gmedia-container {
124
- margin:0;
125
- position:static;
126
- z-index:auto;
127
- direction:ltr;
128
- min-width:auto;
129
- width:100%;
130
- height:100%;
131
- }
132
- div#gmedia-header {
133
- position:relative;
134
- padding:1px 1px 10px 1px;
135
- display: flex;
136
- flex-wrap: wrap;
137
- align-items: center;
138
- }
139
-
140
- /*noinspection CssInvalidElement*/
141
- div#gmedia-logo {
142
- position:relative;
143
- margin:0 30px 0 15px;
144
- font-size:48px;
145
- text-shadow:1px 1px 4px #000000;
146
- font-family:Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
147
- color:#ffffff;
148
- float:left;
149
- /*noinspection CssFloatPxLength*/
150
- -webkit-text-stroke-width:0.7px;
151
- -webkit-text-stroke-color:#ffffff;
152
- -webkit-font-smoothing:antialiased;
153
- -webkit-user-select:none;
154
- -moz-user-select:none;
155
- -ms-user-select:none;
156
- user-select:none;
157
- cursor:default;
158
- }
159
- div#gmedia-logo small {
160
- display:block;
161
- font-size:10px;
162
- margin-top:7px;
163
- text-align:right;
164
- -webkit-text-stroke-width:0;
165
- }
166
- div#gmedia-header h2 {
167
- margin:0;
168
- font:italic 24px/35px Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
169
- color:#ffffff;
170
- flex: 1 1 180px;
171
- }
172
- div#gmedia-header .promote-woowbox {
173
- flex: 1 1 50%;
174
- margin-top: -10px;
175
- }
176
- div#gmedia-header .promote-woowbox img {
177
- border: 1px solid rgba(255, 255, 255, 0.7);
178
- }
179
- #ajax-long-operation {
180
- position:absolute;
181
- right:20px;
182
- bottom:0;
183
- width: 25%;
184
- min-width:220px;
185
- }
186
- .progress-bar-indicator {
187
- position:absolute;
188
- width:100%;
189
- text-align:center;
190
- color:#204D74;
191
- }
192
- div#gmedia-navbar {
193
- font-size:14px;
194
- }
195
- a.list-group-item-premium {
196
- color: #ffffff !important;
197
- background-color: #D82700;
198
- border-color:#A52A2A;
199
- font-weight:bold;
200
- }
201
- a.list-group-item-premium:hover {
202
- color: #ffffff !important;
203
- background-color:#c52400;
204
- border-color:#A52A2A;
205
- font-weight:bold;
206
- }
207
-
208
- div.custom-message {
209
- padding:5px 10px;
210
- margin:0 0 10px;
211
- }
212
- form.gmedia-search-form {
213
- float:right;
214
- margin-left:10px;
215
- margin-bottom:4px;
216
- white-space:nowrap;
217
- }
218
- form.gmedia-search-form .form-group {
219
- margin:0;
220
- display:inline-block;
221
- vertical-align:middle;
222
- }
223
- .gmedia-pager {
224
- margin-bottom:4px;
225
- }
226
- form#gmedia-pager {
227
- float:left;
228
- width:auto;
229
- display:block;
230
- }
231
- form#gmedia-pager span,
232
- form#gmedia-pager input {
233
- width:auto;
234
- display:inline-block;
235
- vertical-align:inherit;
236
- float:none;
237
- }
238
- form#gmedia-pager input.pager_current_page {
239
- padding-left:0;
240
- padding-right:0;
241
- text-align:center;
242
- width:2.5em;
243
- }
244
- .txt-lg {
245
- font-size:120%;
246
- line-height:50%;
247
- }
248
- a.text-danger {
249
- color:#a94442;
250
- }
251
- .btn > input[type="checkbox"] {
252
- margin-top:0;
253
- width:16px;
254
- height:16px;
255
- }
256
- .va-middle { vertical-align:middle }
257
- .dropdown-menu > li > a:hover, .dropdown-menu > li > a:focus {
258
- background-color:#e8e8e8;
259
- }
260
- .gm-checkgroup {
261
- margin-right:20px;
262
- }
263
- .gm-backfade {
264
- background-color:rgba(0, 0, 0, 0.1);
265
- }
266
- .dropdown-menu > .disabled {
267
- cursor:not-allowed;
268
- }
269
- .dropdown-menu > .disabled > a {
270
- pointer-events:none;
271
- }
272
- .panel-heading-fake { display:none; }
273
- .panel-floatingHeader .panel-heading-fake,
274
- .panel-absoluteHeader .panel-heading-fake { display:block; }
275
- .panel-fixed-header { position:relative; }
276
- .panel-fixed-header .panel-heading { position:relative; top:0; max-width:100%;
277
- /*transition:top 0.2s ease-out; -webkit-transition:top 0.2s ease-out;*/
278
- }
279
- .panel-heading .spinner { margin-top:0; }
280
- body.gmedia-blank .panel-floatingHeader .panel-heading,
281
- .panel-floatingHeader .panel-heading {
282
- position:fixed;
283
- top:32px;
284
- z-index:20;
285
- border-radius:0;
286
- -webkit-box-shadow:0 5px 10px #888888;
287
- -moz-box-shadow:0 5px 10px #888888;
288
- box-shadow:0 5px 10px #888888;
289
- }
290
- body.gmedia-blank .panel-floatingHeader .panel-heading {
291
- top: 0;
292
- }
293
- body.gmedia-blank .panel-absoluteHeader .panel-heading,
294
- .panel-absoluteHeader .panel-heading {
295
- position:absolute;
296
- z-index:10;
297
- top:auto;
298
- bottom:0;
299
- border-bottom:1px solid transparent;
300
- border-bottom-right-radius:3px;
301
- border-bottom-left-radius:3px;
302
- }
303
- .dropdown-menu:not(.bootstrap-datetimepicker-widget) {
304
- max-height: calc(100vh - 50px);
305
- overflow-y: auto;
306
- }
307
- div#gm-list-table {
308
- font-size:13px;
309
- display:block;
310
- display:flex;
311
- flex-wrap:wrap;
312
- }
313
- div#gm-list-table::before {
314
- display:block;
315
- content:'';
316
- float:left;
317
- width:0;
318
- height:auto;
319
- overflow:hidden;
320
- }
321
- .list-group-item { width:100%; }
322
- .list-group-item.row {
323
- position:relative;
324
- margin-left:0;
325
- margin-right:0;
326
- padding-left:0;
327
- padding-right:0;
328
- }
329
- div.list-group-item.d-row {
330
- position:relative;
331
- color:inherit;
332
- z-index:1;
333
- }
334
- .no-touch div.list-group-item.d-row:hover {
335
- background-color:#fafafa;
336
- }
337
- .no-touch form.list-group-item.d-row:hover {
338
- background-color:#fcfcfc;
339
- }
340
- .list-group-item.d-row.gm-selected {
341
- color:#444444;
342
- border-color:#dddddd;
343
- background-color:rgb(250, 255, 245);
344
- -webkit-box-shadow:inset -1px 0 0 2px rgb(250, 255, 245), inset 7px 0 0 0 #1e8cbe;
345
- -moz-box-shadow:inset -1px 0 0 2px rgb(250, 255, 245), inset 7px 0 0 0 #1e8cbe;
346
- box-shadow:inset -1px 0 0 2px rgb(250, 255, 245), inset 7px 0 0 0 #1e8cbe;
347
- }
348
- .no-touch .list-group-item.d-row.gm-selected:hover {
349
- color:#444444;
350
- border-color:#dddddd;
351
- background-color:rgb(245, 255, 240);
352
- -webkit-box-shadow:inset -1px 0 0 2px rgb(245, 255, 240), inset 7px 0 0 0 #1e8cbe;
353
- -moz-box-shadow:inset -1px 0 0 2px rgb(245, 255, 240), inset 7px 0 0 0 #1e8cbe;
354
- box-shadow:inset -1px 0 0 2px rgb(245, 255, 240), inset 7px 0 0 0 #1e8cbe;
355
- }
356
- div#gmedia-container .list-group-item-info,
357
- div#gmedia-container .list-group-item-info:hover {
358
- background-color:#d9edf7 !important;
359
- color:inherit !important;
360
- }
361
- div#gmedia-container .list-group-item-warning,
362
- div#gmedia-container .list-group-item-warning:hover {
363
- background-color:#fcf8e3 !important;
364
- color:inherit !important;
365
- }
366
- div#gmedia-container .item-after-limit {
367
- filter:blur(1px);
368
- -webkit-filter:blur(1px);
369
- -moz-filter:blur(1px);
370
- -o-filter:blur(1px);
371
- -ms-filter:blur(1px);
372
- filter:progid:DXImageTransform.Microsoft.Blur(PixelRadius='1');
373
- }
374
- .bg-status-private {
375
- background-color:#d9edf7;
376
- -webkit-box-shadow:3px 0 0 5px #d9edf7, -2px 0 0 5px #6fbfff;
377
- -moz-box-shadow:3px 0 0 5px #d9edf7, -2px 0 0 5px #6fbfff;
378
- box-shadow:3px 0 0 5px #d9edf7, -2px 0 0 5px #6fbfff;
379
- }
380
- .bg-status-draft {
381
- background-color:#fcf8e3;
382
- -webkit-box-shadow:3px 0 0 5px #fcf8e3, -2px 0 0 5px #ffd87c;
383
- -moz-box-shadow:3px 0 0 5px #fcf8e3, -2px 0 0 5px #ffd87c;
384
- box-shadow:3px 0 0 5px #fcf8e3, -2px 0 0 5px #ffd87c;
385
- }
386
- input.gm-order-input {
387
- float: right;
388
- border: 1px solid #ccc;
389
- border-radius: 3px;
390
- padding: 1px 3px;
391
- margin: 0;
392
- font-size: 12px;
393
- line-height: 120%;
394
- width: 3em;
395
- text-align: right;
396
- }
397
- .form-group .gmpost-com-count {font-size:16px;}
398
- .gmpost-com-count:hover {text-decoration:none}
399
- label.cb_media-object-gallery {
400
- width:40px;
401
- position:absolute;
402
- left:5px;
403
- top:0; bottom:0;
404
- text-align:center;
405
- padding-top:4px;
406
- }
407
- .d-row .thumbnail {
408
- margin-bottom:0;
409
- }
410
- .gm-selected .thumbnail {
411
- border-color:#428bca;
412
- }
413
- .thumbnail {
414
- position:relative;
415
- display:inline-block;
416
- max-width:100%;
417
- }
418
- .display-as-grid .gm-item-cell {
419
- padding:12px 12px 10px;
420
- border:4px solid #ffffff;
421
- background-color:#f7f7f7;
422
- min-width:195px;
423
- max-width:340px;
424
- border-radius:14px;
425
- flex: 1 1 195px;
426
- }
427
- .display-as-grid .gm-item-cell-blank {
428
- flex: 1 1 195px;
429
- }
430
- .display-as-grid .gm-item-cell.ui-highlight-placeholder {margin-bottom:0;background-color:#2c7c91;}
431
- .edit-gmedia .gmedia-actions { margin:10px; }
432
- .gm-item-cell .gmedia-actions {
433
- overflow:hidden;
434
- position:absolute;
435
- left:0; top:0;
436
- transform:translateY(100%) translateZ(0);
437
- opacity:0;
438
- transition: transform 0.1s, opacity 0.2s;
439
- }
440
- .gmedia-actions > * {margin-left:5px; margin-right:5px;}
441
- .gm-item-cell .gmedia-actions > * {float:left;}
442
- .gm-item-cell .gmedia-actions * {
443
- -webkit-backface-visibility: hidden;
444
- backface-visibility: hidden;
445
- -webkit-transform-style: preserve-3d;
446
- }
447
- .gmedia-actions > *:first-child {margin-left: 0;}
448
- .gmedia-actions > *:last-child {margin-right: 0;}
449
-
450
- .related-media-previews {}
451
- .related-media-previews::before,
452
- .related-media-previews::after {
453
- content:"";
454
- display: table;
455
- clear: both;
456
- height: 0;
457
- overflow: hidden;
458
- }
459
- p.thumbnail.gmedia-related-image,
460
- .related-media-previews p.gmedia-related-image {
461
- width: 30%;
462
- float: left;
463
- display: inline-block;
464
- position: relative;
465
- margin-right: 3%;
466
- margin-top: 7px;
467
- }
468
- .edit-gmedia p.thumbnail.gmedia-related-image,
469
- .edit-gmedia .related-media-previews p.gmedia-related-image {
470
- width: 44%;
471
- float: none;
472
- vertical-align: top;
473
- }
474
- p.thumbnail.gmedia-related-image .gm-remove {
475
- padding: 1px;
476
- font-size: 15px;
477
- font-weight: bold;
478
- line-height: 0.7;
479
- border-radius: 50%;
480
- width: 1em;
481
- height: 1em;
482
- box-sizing: content-box;
483
- color: #fff;
484
- background-color: #cc0d00;
485
- text-align: center;
486
- position: absolute;
487
- right: -0.5em;
488
- top: -0.5em;
489
- transform: scale(0);
490
- transition: transform 0.1s ease-in;
491
- cursor: pointer;
492
- }
493
- p.thumbnail.gmedia-related-image:hover .gm-remove {
494
- transform: scale(1);
495
- }
496
- p.thumbnail.gmedia-related-image .image-wrapper {
497
- display: block;
498
- position: relative;
499
- width: 100%;
500
- height: 0;
501
- padding-bottom: 62.5%;
502
- cursor: move;
503
- }
504
- p.thumbnail.gmedia-related-image img.gmedia-thumb {
505
- position: absolute;
506
- left: 0;
507
- top: 0;
508
- width: 100%;
509
- height: 100%;
510
- display: block;
511
- object-fit: contain;
512
- }
513
-
514
- .gm-item-cell .gm-cell-bottom {
515
- position:relative;
516
- min-height:20px;
517
- margin:15px 0 0 2px;
518
- overflow:hidden;
519
- }
520
- .gm-item-cell .gm-cell-title {
521
- overflow:hidden;
522
- font-size:12px;
523
- font-weight:bold;
524
- cursor:pointer;
525
- opacity:1;
526
- position:absolute;
527
- left:0;
528
- top:0;
529
- width:100%;
530
- transition:opacity 0.15s;
531
- }
532
- .gm-item-cell .gm-cell-title span {
533
- display:block;
534
- width:100%;
535
- white-space:nowrap;
536
- text-overflow:ellipsis;
537
- overflow:hidden;
538
- }
539
-
540
- .gm-item-cell:hover .gm-cell-title { opacity:0; pointer-events:none;}
541
- .gm-item-cell:hover .gmedia-actions { transform:translateY(0) translateZ(0); opacity:1;}
542
-
543
- .display-as-grid div.thumbnail {
544
- cursor:pointer;
545
- position:relative;
546
- display:block;
547
- border-radius:0;
548
- margin:0;
549
- padding:0;
550
- -webkit-backface-visibility: hidden;
551
- backface-visibility: hidden;
552
- }
553
- .display-as-grid div.thumbnail:before {
554
- content:"";
555
- display:block;
556
- padding-top:100%;
557
- }
558
- .display-as-grid .gm-selected div.thumbnail {
559
- -webkit-box-shadow:0 0 0 7px #1e8cbe;
560
- -moz-box-shadow:0 0 0 7px #1e8cbe;
561
- box-shadow:0 0 0 7px #1e8cbe;
562
- border-radius:1px;
563
- }
564
- .display-as-grid div.thumbnail .cb_media-object,
565
- .display-as-grid div.thumbnail .gm-item-cell-media-object {
566
- bottom:0px;
567
- left:0px;
568
- overflow:hidden;
569
- position:absolute;
570
- right:0px;
571
- top:0px;
572
- text-align:center;
573
- margin:0;
574
- }
575
- .display-as-grid div.thumbnail .gm-cell-more {
576
- position:absolute;
577
- left:0; top:0; right:0;
578
- background:rgba(256, 256, 256, 0.6);
579
- color:#000000;
580
- cursor:auto;
581
- }
582
- .display-as-grid div.thumbnail .gm-cell-more-btn {
583
- position:absolute;
584
- top:0; right:0;
585
- padding:5px;
586
- cursor:pointer;
587
- color: #1e8cbe;
588
- /*text-shadow: 1px 1px 1px #83acbf;*/
589
- }
590
- .display-as-grid div.thumbnail .gm-cell-more-content {
591
- padding:5px 5px 0;
592
- display:none;
593
- overflow:hidden;
594
- /*transition:all 0.2s easy-out;*/
595
- font-size:11px;
596
- }
597
- .display-as-grid div.thumbnail .gm-cell-more-content .gmedia-actions {
598
- display:none;
599
- }
600
- .display-as-grid div.thumbnail .gm-cell-more:hover,
601
- .display-as-grid div.thumbnail .gm-cell-more.gm-cell-more-active {
602
- z-index:10;
603
- -webkit-box-shadow:0 0 0 1px #dddddd, 0 4px 3px -1px rgba(0, 0, 0, 0.3);
604
- -moz-box-shadow:0 0 0 1px #dddddd, 0 4px 3px -1px rgba(0, 0, 0, 0.3);
605
- box-shadow:0 0 0 1px #dddddd, 0 4px 3px -1px rgba(0, 0, 0, 0.3);
606
- }
607
- .display-as-grid div.thumbnail .gm-cell-more:hover {
608
- z-index:11;
609
- }
610
- .display-as-grid div.thumbnail .gm-cell-more:hover > div {
611
- background:rgba(256, 256, 256, 0.7);
612
- }
613
- .display-as-grid div.thumbnail .gm-cell-more-active .gm-cell-more-content .gmedia-actions {
614
- display:block;
615
- }
616
- .display-as-grid div.thumbnail .gm-cell-more.gm-cell-more-active > div {
617
- background:rgba(256, 256, 256, 0.9);
618
- }
619
- .display-as-grid div.thumbnail .gm-cell-more:hover .gm-cell-more-content,
620
- .display-as-grid div.thumbnail .gm-cell-more.gm-cell-more-active .gm-cell-more-content {
621
- display:block;
622
- }
623
- .display-as-grid div.thumbnail .gm-cell-more-content p {
624
- font-size:11px;
625
- }
626
- .display-as-grid div.thumbnail .cb_media-object .centered,
627
- .display-as-grid div.thumbnail .gm-item-cell-media-object .centered {
628
- height:100%;
629
- left:0;
630
- position:absolute;
631
- top:0;
632
- transform:translate(50%, 50%) translateZ(0);
633
- width:100%;
634
- }
635
- .display-as-grid div.thumbnail.landscape .cb_media-object .centered,
636
- .display-as-grid div.thumbnail.landscape .gm-item-cell-media-object .centered {
637
- transform:translate(50%, 50.5%) translateZ(0);
638
- }
639
- .display-as-grid div.thumbnail .cb_media-object img,
640
- .display-as-grid div.thumbnail .gm-item-cell-media-object img {
641
- left:0;
642
- position:absolute;
643
- top:0;
644
- transform:translate(-50%, -50%) translateZ(0);
645
- }
646
- .display-as-grid div.thumbnail.landscape img {
647
- height:101%;
648
- width:auto;
649
- }
650
- .display-as-grid div.thumbnail.portrait img {
651
- height:auto;
652
- width:100%;
653
- }
654
- .display-as-grid.invert-ratio div.thumbnail.landscape img {
655
- height:auto;
656
- width:101%;
657
- }
658
- .display-as-grid.invert-ratio div.thumbnail.portrait img {
659
- height:101%;
660
- width:auto;
661
- }
662
- .thumbnail img.gmedia-typethumb,
663
- .display-as-grid div.thumbnail .cb_media-object img.gmedia-typethumb,
664
- .display-as-grid div.thumbnail .gm-item-cell-media-object img.gmedia-typethumb {
665
- position:absolute;
666
- right:7px;
667
- bottom:7px;
668
- height:75px;
669
- max-height:60%;
670
- width:auto;
671
- }
672
- .display-as-grid div.thumbnail .cb_media-object img.gmedia-typethumb,
673
- .display-as-grid div.thumbnail .gm-item-cell-media-object img.gmedia-typethumb {
674
- left:auto;
675
- top:auto;
676
- right:50%;
677
- bottom:50%;
678
- margin:0 5px 5px 0;
679
- transform:none;
680
- opacity:0.9;
681
- }
682
- .thumbwrap { position:relative; margin-bottom:5px; }
683
- .gm-item-check,
684
- .gm-order { position:absolute; right:-8px; bottom:-8px; padding:5px; margin:0; border:1px solid #1e8cbe; background-color:#ffffff; border-width:1px 0 0 1px; }
685
- .gm-item-check input{ margin:0; padding:0; }
686
- .gm-order input{
687
- display:block;
688
- line-height:120%;
689
- width:42px;
690
- padding:0 2px;
691
- margin:0;
692
- text-align:center;
693
- border: 1px solid #ccc;
694
- border-radius:4px;
695
- }
696
-
697
- .thumbwrap .gm-item-check { right:1px; bottom:1px; border:1px solid #dddddd; border-radius:5px 0 5px 0; border-right-color:transparent; border-bottom-color:transparent; border-width:1px; }
698
- .thumbwrap .cb_media-object { width:100%; margin:0; display:flex; }
699
- .cb_media-object .thumbnail {
700
- width:100%;
701
- }
702
- .media-title {
703
- font-size:22px;
704
- word-wrap:break-word;
705
- }
706
- .media-caption:empty { display:none; }
707
- .media-caption.in-library {
708
- max-height:215px;
709
- }
710
- .media-caption {
711
- background-color:#f5f5f5;
712
- border:1px solid #cccccc;
713
- border-radius:4px;
714
- padding:5px 7px;
715
- margin:0 -6px 5px;
716
- overflow:auto;
717
- word-break:normal;
718
- word-wrap:break-word;
719
- max-height:210px;
720
- }
721
- .media-body .media-caption {
722
- margin:0;
723
- }
724
- .media-meta {
725
- width:100%;
726
- overflow:hidden;
727
- text-overflow:ellipsis; /*white-space:nowrap;*/
728
- }
729
- .media-meta .gm_gallery_source { font-weight:bold; }
730
- .media-meta .label-default {
731
- background-color:#eeeeee;
732
- color:#444444;
733
- }
734
- .gmedia_id {
735
- position:absolute;
736
- right:10px;
737
- top:10px;
738
- }
739
- .term_id {
740
- font-size:80%;
741
- }
742
- .term_date {
743
- font-size:80%;
744
- }
745
- .term_date:empty {
746
- display: none;
747
- }
748
- .term_date:before {
749
- content: '[';
750
- }
751
- .term_date:after {
752
- content: ']';
753
- }
754
- #gm-list-table .hidden {
755
- display:none !important;
756
- visibility:hidden !important;
757
- }
758
- form#adv-settings .form-inline .form-group {
759
- margin-right:20px;
760
- }
761
- form.changed {
762
- }
763
- form.changed.saved {
764
- }
765
- form.changed .gm-last-edited {
766
- text-decoration:line-through;
767
- }
768
- .selectize-input.full input {
769
- width:4px !important;
770
- }
771
- .rel-selected-hide {
772
- display:none;
773
- }
774
- .plupload_wrapper {
775
- min-width:unset;
776
- }
777
- .gmAddMedia {
778
- padding:0;
779
- }
780
- div#pluploadUploader {
781
- padding:0;
782
- box-sizing:border-box;
783
- }
784
- div#pluploadUploader > div > div * {
785
- box-sizing:content-box;
786
- }
787
- .plupload_container {
788
- padding:0;
789
- }
790
- div#pluploadUploader_container {
791
- min-height:450px;
792
- border-bottom-right-radius:4px;
793
- }
794
- div#pluploadUploader_container .plupload_filelist_footer {
795
- border-bottom-right-radius:4px;
796
- font-size:11px;
797
- white-space:nowrap;
798
- }
799
- div#pluploadUploader_buttons { margin-bottom:5px; }
800
- div.plupload_started { float:left; }
801
- div.panel-body, div#gmedia-msg-panel, #gmedia-service-msg-panel {
802
- -webkit-transition:all .2s ease-in-out;
803
- transition:all .2s ease-in-out;
804
- }
805
- div.panel-body:empty, div#gmedia-msg-panel:empty, #gmedia-service-msg-panel:empty {
806
- padding:0;
807
- }
808
- div#gmedia-msg-panel .alert,
809
- #gmedia-service-msg-panel .alert {
810
- padding:2px 35px 2px 12px;
811
- margin-bottom:5px;
812
- }
813
- .plupload_content li {
814
- margin-bottom:0;
815
- }
816
- .progress {
817
- position:relative;
818
- white-space:nowrap;
819
- font-size:12px;
820
- line-height:20px;
821
- }
822
- .progress-bar {
823
- position:absolute;
824
- overflow:hidden;
825
- }
826
- .tab-inside {
827
- padding:10px;
828
- position:relative;
829
- }
830
- .tab-footer {
831
- border-top:1px solid #dddddd;
832
- padding:20px 10px 0;
833
- }
834
- .selectize-control.input-sm .selectize-input {
835
- min-height:30px;
836
- padding:2px 10px;
837
- font-size:12px;
838
- line-height:1.9;
839
- border-radius:3px;
840
- }
841
- .selectize-control.multi .selectize-input.has-items {
842
- padding-top:2px;
843
- }
844
- .selectize-control.input-sm .selectize-input input {
845
- font-size:12px;
846
- }
847
- .selectize-control.input-sm .selectize-input:after {
848
- right:10px;
849
- }
850
- .selectize-control.input-sm .selectize-input > div {
851
- line-height:146%;
852
- }
853
- .term-list-item {
854
- padding-top:0;
855
- padding-bottom:0;
856
- z-index:1;
857
- }
858
- .object-actions { text-align:right; font-size:16px; }
859
- .object-actions.gallery-object-actions { text-align:left; margin-bottom:5px; }
860
- .object-actions > * { margin:0 0 0 10px; vertical-align:middle; display:inline-block; }
861
- .object-actions.gallery-object-actions > *:first-child { margin-left:0; }
862
- .object-actions a:hover { text-decoration:none; }
863
- /*.gm_filter_in_lib { border:1px solid; border-radius:4px; font-size:14px; line-height:14px; padding:0 2px 0 4px; }*/
864
- .gm_term_count { font-size:13px; font-weight:bold; text-decoration:none; vertical-align:bottom; }
865
- a.trash-icon:hover { color:#843534; }
866
- .action-inactive { color:#b8b8b8; }
867
- .action-inactive:hover { color:#b8b8b8; }
868
- .term-list-item .term-label .checkbox {
869
- padding-left:35px;
870
- padding-top:6px;
871
- min-height:68px;
872
- }
873
- .term-list-item .term-label .checkbox > input {
874
- margin-left:-35px;
875
- margin-top:2px;
876
- }
877
- .term-list-item .checkbox input {
878
- margin-top:0;
879
- margin-right:15px;
880
- }
881
- .term-list-item .term-description {
882
- padding:0;
883
- white-space:nowrap;
884
- overflow:hidden;
885
- color:#444444;
886
- text-overflow:ellipsis;
887
- }
888
- .term-list-item .term-description:empty {
889
- padding:0;
890
- }
891
- .term-list-item .object-actions {
892
- position: absolute;
893
- right: 0; left: auto; top: 4px;
894
- line-height:165%;
895
- }
896
-
897
- .term-list-item .term-images {
898
- padding-top:5px;
899
- padding-bottom:5px;
900
- overflow:hidden;
901
- white-space:nowrap;
902
- position:relative;
903
- z-index:1;
904
- }
905
- .term-list-item .term-images img {
906
- position:relative;
907
- height:68px;
908
- width:auto;
909
- background-color:#ffffff;
910
- }
911
- .term-list-item .term_name { margin-right:80px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; font-size:22px; display:inline-block; line-height:100%; }
912
- .term-list-item .no-checkbox .term_name { margin-right:5px; font-size:16px;}
913
- .term-list-item .term_info_author {
914
- font-size:80%;
915
- white-space:nowrap;
916
- color:#444444;
917
- }
918
- .object-actions .term-shortcode {float:left;margin:0;}
919
- .object-actions .term-shortcode input,
920
- .object-actions .term-shortcode .input-buffer{ font-family: Courier, sans-serif; font-size: 14px; line-height:100%; letter-spacing: 0.05em; border:none; box-shadow:none; background-color:#fff; margin:0; padding:0;}
921
-
922
- .panel-heading .term-shortcode {float:left;margin-left:20px;}
923
- .panel-heading .term-shortcode input,
924
- .panel-heading .term-shortcode .input-buffer{ font-family: Courier, sans-serif; font-size: 14px; letter-spacing: 0.05em; }
925
-
926
- .term-shortcode .input-buffer{position: absolute; top: -1000px; left: -1000px; visibility: hidden; white-space: nowrap;}
927
-
928
- .no-touch .term-list-item .term-images img:hover {
929
- z-index:100 !important;
930
- }
931
- .edit_tag_link { font-size:18px; }
932
- .edit_tag_form {
933
- display:inline-block;
934
- margin-left:-5px;
935
- margin-bottom:-1px;
936
- margin-top:-1px;
937
- font-size:18px;
938
- }
939
- .edit_tag_form a { font-size:18px; line-height:100%;}
940
- .edit_tag_form input.edit_tag_input {
941
- padding:0 5px;
942
- border-width:0 0 1px 0;
943
- margin:0;
944
- font-size:18px;
945
- line-height:100%;
946
- }
947
- a.edit_tag_save.btn {
948
- padding-top:0;
949
- padding-bottom:0;
950
- }
951
- .no-touch a.edit_tag_save.btn-link:hover {
952
- text-decoration:none;
953
- }
954
- .gm-img-thumbnail {
955
- display:inline-block;
956
- position:relative;
957
- margin-right:5px;
958
- margin-bottom:25px;
959
- max-width:100%;
960
- height:auto;
961
- padding:4px;
962
- line-height:1.428571429;
963
- background-color:#ffffff;
964
- border:1px solid #dddddd;
965
- border-radius:4px;
966
- }
967
- .gm-img-thumbnail img {
968
- height:auto;
969
- width:auto;
970
- max-width:100%;
971
- max-height:100%;
972
- display:inline-block;
973
- vertical-align:middle;
974
- }
975
- #gmedia-edit-term .gm-img-thumbnail {
976
- text-align:center;
977
- margin:0;
978
- }
979
- #gmedia-edit-term .gm-img-thumbnail:empty {display:none;}
980
- #gmedia-edit-term .gm-img-thumbnail img { max-height: 150px; }
981
- .choose-module {
982
- padding:10px;
983
- overflow:hidden;
984
- margin:0;
985
- }
986
- .no-touch .choose-module:hover {
987
- background-color:#d0e9c6;
988
- }
989
- .choose-module .thumbnail {
990
- margin-bottom:0;
991
- }
992
- .media {
993
- overflow:hidden;
994
- }
995
- .media > .thumbnail.pull-left {
996
- padding:4px;
997
- margin-right:10px
998
- }
999
- #gmedia_modules .media {
1000
- border-bottom: 1px solid #444444;
1001
- padding-bottom:15px;
1002
- margin-bottom:30px;
1003
- }
1004
- #gmedia_modules .media:last-child {
1005
- border-bottom: none;
1006
- padding-bottom:0;
1007
- margin-bottom:0;
1008
- }
1009
- #gmedia_modules .buttons a.btn {
1010
- margin-bottom: 7px;
1011
- }
1012
- #chooseModuleModal .choose-module {
1013
- border-bottom: 1px solid #444444;
1014
- }
1015
- #chooseModuleModal .choose-module:last-child {
1016
- border-bottom: none;
1017
- }
1018
- .modules-body .media {
1019
- display:none;
1020
- }
1021
- .modules-body .module-filtered {
1022
- display:block;
1023
- }
1024
- .presetlist a { }
1025
- .gm-preset-id {
1026
- font-size:smaller;
1027
- float:right;
1028
- padding:0 15px 0 5px;
1029
- }
1030
- .addpreset:hover,
1031
- .addpreset:active,
1032
- .addpreset {
1033
- margin:0 8px 0;
1034
- line-height:100%;
1035
- text-decoration:none;
1036
- outline:none;
1037
- }
1038
- .addpreset span {
1039
- line-height:100%;
1040
- font-size:74%;
1041
- padding:0 5px 2px;
1042
- cursor:pointer;
1043
- }
1044
- .delpreset {
1045
- position:absolute;
1046
- right:0;
1047
- top:0;
1048
- bottom:0;
1049
- padding:0.8em 7px 0;
1050
- line-height:100%;
1051
- }
1052
- .delpreset span {
1053
- line-height:100%;
1054
- font-size:94%;
1055
- padding:0 5px 2px;
1056
- cursor:pointer;
1057
- }
1058
- body#media-upload {
1059
- height:100%;
1060
- overflow:auto;
1061
- margin:0;
1062
- padding:0;
1063
- background:#ffffff;
1064
- }
1065
- body#media-upload .panel {
1066
- position:relative;
1067
- height:100%;
1068
- overflow:auto;
1069
- margin:0;
1070
- border-radius:0;
1071
- border-top:none;
1072
- }
1073
- body#media-upload .panel-heading {
1074
- position:relative;
1075
- z-index:100;
1076
- }
1077
- body#media-upload .panel-body {
1078
- position:absolute;
1079
- top:55px;
1080
- bottom:0;
1081
- width:100%;
1082
- overflow:hidden;
1083
- z-index:50;
1084
- padding-top:0;
1085
- padding-bottom:0;
1086
- }
1087
- body#media-upload .panel-body > .row {
1088
- height:100%;
1089
- }
1090
- body#media-upload .panel-body > .row > div {
1091
- height:100%;
1092
- overflow:auto;
1093
- padding-top:15px;
1094
- padding-bottom:15px;
1095
- }
1096
- body#media-upload .panel-body .list-group-item {
1097
- border-width:0;
1098
- border-top-width:1px;
1099
- margin:0;
1100
- }
1101
- body#media-upload .panel-body .list-group-item:first-child {
1102
- border-width:0;
1103
- }
1104
- body#media-upload .term-list-item .term-images img {
1105
- height:30px;
1106
- }
1107
- body#media-upload .term-list-item .term-label .no-checkbox {
1108
- display:inline-block;
1109
- width:100%;
1110
- margin:10px 0;
1111
- }
1112
- body#media-upload .term-list-item .term-info {
1113
- display:none;
1114
- }
1115
- .blank-aligner {
1116
- display:inline-block;
1117
- height:40px;
1118
- vertical-align:middle;
1119
- width:1px;
1120
- overflow:hidden;
1121
- margin-right:-2em;
1122
- }
1123
- body#media-upload .media-upload-sidebar {
1124
- border-left:1px solid #cccccc;
1125
- background-color:#eeeeee;
1126
- padding:0 !important;
1127
- position:relative;
1128
- }
1129
- body#media-upload .media-upload-sidebar form {
1130
- display:-webkit-box;
1131
- display:-moz-box;
1132
- display:-ms-flexbox;
1133
- display:-webkit-flex;
1134
- display:flex;
1135
- -webkit-flex-direction:column;
1136
- -moz-flex-direction:column;
1137
- -ms-flex-direction:column;
1138
- flex-direction:column;
1139
- height:100%;
1140
- width:100%;
1141
- }
1142
- body#media-upload .media-upload-sidebar .media-upload-form-container {
1143
- -webkit-box-flex:1 auto;
1144
- -moz-box-flex:1 auto;
1145
- -webkit-flex:1 auto;
1146
- -ms-flex:1 auto;
1147
- flex:1 auto;
1148
- overflow:auto;
1149
- padding:15px;
1150
- }
1151
- body#media-upload .media-upload-sidebar .panel-footer {
1152
- min-height:57px;
1153
- }
1154
- body#media-upload .thumbnail {
1155
- margin:0 5px 5px 0;
1156
- position:relative;
1157
- display:inline-block;
1158
- }
1159
- body#media-upload .thumbnail.active {
1160
- background-color:lightblue;
1161
- border-color:cadetblue;
1162
- }
1163
- body#media-upload .thumbnail .glyphicon {
1164
- display:none;
1165
- position:absolute;
1166
- right:-3px;
1167
- top:-7px;
1168
- font-size:30px;
1169
- }
1170
- body#media-upload .thumbnail.active .glyphicon {
1171
- display:inline-block;
1172
- }
1173
- body#media-upload .plupload_wrapper {
1174
- height:100%;
1175
- box-sizing:border-box;
1176
- overflow:hidden;
1177
- }
1178
- .addtags-gap { height:200px; }
1179
- body#media-upload div#pluploadUploader .plupload_container {
1180
- height:100%;
1181
- min-height:inherit !important;
1182
- }
1183
- body#media-upload .ui-resizable-handle {
1184
- display:none !important;
1185
- bottom:-1px;
1186
- }
1187
- #gmedia-post-thumbnail {
1188
- font-size:12px;
1189
- padding:0;
1190
- display:inline;
1191
- white-space:normal;
1192
- }
1193
- body.gmedia-blank.gmedia_image_editor {
1194
- height:100%;
1195
- overflow:auto;
1196
- margin:0;
1197
- padding:0
1198
- }
1199
- body.gmedia-blank.gmedia_image_editor .panel,
1200
- body.gmedia-blank.gmedia_map_editor .panel {
1201
- position:relative;
1202
- height:100%;
1203
- overflow:auto;
1204
- margin:0;
1205
- }
1206
- body.gmedia-blank .panel-heading {
1207
- position:relative;
1208
- z-index:100;
1209
- }
1210
- body.gmedia-blank.gmedia_image_editor .panel-body {
1211
- position:absolute;
1212
- top:55px;
1213
- bottom:0;
1214
- width:100%;
1215
- overflow:hidden;
1216
- z-index:50;
1217
- padding-top:0;
1218
- padding-bottom:0;
1219
- }
1220
- body.gmedia-blank.gmedia_image_editor .panel-body .row {
1221
- height:100%;
1222
- }
1223
- body.gmedia-blank.gmedia_image_editor .panel-body .row > div {
1224
- height:100%;
1225
- overflow:auto;
1226
- padding-top:15px;
1227
- padding-bottom:15px;
1228
- }
1229
- body.gmedia-blank .media-edit-sidebar {
1230
- border-left:1px solid #cccccc;
1231
- background-color:#eeeeee;
1232
- padding:0 0 55px 0 !important;
1233
- position:relative;
1234
- }
1235
- body.gmedia-blank #media-edit-form-container {
1236
- height:100%;
1237
- overflow:auto;
1238
- padding:15px;
1239
- }
1240
- body.gmedia-blank .media-edit-sidebar .panel-footer {
1241
- position:absolute;
1242
- left:0;
1243
- bottom:0;
1244
- right:0;
1245
- }
1246
- body.gmedia_library .panel {
1247
- margin-bottom:0;
1248
- }
1249
- #map-floating-panel {
1250
- position:absolute;
1251
- top:15px;
1252
- right:15px;
1253
- z-index:5;
1254
- background-color:#ffffff;
1255
- padding:0 0 5px 5px;
1256
- width:250px;
1257
- }
1258
- #save_buttons_duplicate { display:none;}
1259
- .panel-floatingHeader #save_buttons_duplicate { display:block;}
1260
- #gallery_preview_ {
1261
- width:200%;
1262
- height:800px;
1263
- margin-bottom:-400px;
1264
- overflow:auto;
1265
- -moz-transform:scale(0.5, 0.5) translateZ(0);
1266
- -webkit-transform:scale(0.5, 0.5) translateZ(0);
1267
- -o-transform:scale(0.5, 0.5) translateZ(0);
1268
- -ms-transform:scale(0.5, 0.5) translateZ(0);
1269
- transform:scale(0.5, 0.5) translateZ(0);
1270
- -moz-transform-origin:top left;
1271
- -webkit-transform-origin:top left;
1272
- -o-transform-origin:top left;
1273
- -ms-transform-origin:top left;
1274
- transform-origin:top left;
1275
- border:solid #cccccc 2px;
1276
- }
1277
- .gallery_preview {
1278
- padding:0 5px 5px 0;
1279
- border-right:1px dotted;
1280
- border-bottom:1px dotted;
1281
- background-color:#eee;
1282
- width:100%;
1283
- height:600px;
1284
- }
1285
- #gallery_preview {
1286
- width:100%;
1287
- height:100%;
1288
- border:solid #cccccc 1px;
1289
- overflow:auto;
1290
- }
1291
- #adv-settings {
1292
- overflow:hidden;
1293
- }
1294
- #screen-meta .form-group {
1295
- padding-bottom:10px;
1296
- }
1297
- #previewModal {
1298
- z-index:9999;
1299
- overflow-x:auto;
1300
- }
1301
- #previewModal .modal-header .btn-primary {display:none;}
1302
- #previewModal .select_gmedia .modal-header .btn-primary {display:inline-block;}
1303
- #previewModal .select_gmedia_image .modal-header .btn-primary {display:inline-block;}
1304
- #previewModal .select_gmedia_related .modal-header .btn-primary {display:inline-block;}
1305
-
1306
- .edit_gmedia_item .modal-header {display:none;}
1307
- .edit_gmedia_item .modal-body {padding:0;}
1308
- .edit_gmedia_item iframe {max-height:calc(100vh - 110px);}
1309
-
1310
- .select_gmedia .modal-body,
1311
- .select_gmedia_related .modal-body,
1312
- .select_gmedia_image .modal-body {padding:0;}
1313
- .select_gmedia iframe,
1314
- .select_gmedia_related iframe,
1315
- .select_gmedia_image iframe {max-height:calc(100vh - 160px);}
1316
- .no-transition {transition:none !important; -webkit-transition:none !important;}
1317
-
1318
- .checked_thumb {margin-top:-7px;text-align:center;}
1319
- .checked_thumb img {max-height:55px;width:auto;height:auto;}
1320
-
1321
- input.sharelink[readonly] { cursor:text; }
1322
- fieldset.gmediacustomstuff { margin:0 0 10px; padding:.35em .625em .4em; position:relative; border:1px solid silver }
1323
- .delete-custom-field { margin:4px 2px 0; cursor:pointer; }
1324
- .newcustomfield-modal { position:absolute; bottom:-0.6em; right:8px; font-size:100%; }
1325
-
1326
- .gmapp-description, .gmapp-description p {font-size:15px;}
1327
-
1328
- div#wp-link-wrap {
1329
- box-sizing: border-box;
1330
- }
1331
- div#wp-link-wrap label {
1332
- font-weight: normal;
1333
- display: block;
1334
- margin: 0;
1335
- }
1336
-
1337
- .input-group.gmedia_date input {
1338
- background: #ffffff;
1339
- }
1340
-
1341
- @media (min-width:782px) {
1342
- div.modal {
1343
- top:32px;
1344
- }
1345
- body.gmedia-blank div.modal {
1346
- top:0;
1347
- }
1348
- div#termsModal .modal-dialog {
1349
- width:350px;
1350
- }
1351
-
1352
- }
1353
- @media (max-width:600px) {
1354
- .panel-floatingHeader .panel-heading,
1355
- .panel-absoluteHeader .panel-heading {
1356
- position:static;
1357
- box-shadow:none;
1358
- }
1359
- .panel-floatingHeader .panel-heading-fake, .panel-absoluteHeader .panel-heading-fake {
1360
- display:none;
1361
- }
1362
- }
1363
- @media (max-width:782px) {
1364
- .panel-floatingHeader .panel-heading {
1365
- top:46px;
1366
- }
1367
- div#wpwrap {
1368
- background:#708090;
1369
- }
1370
- div#wpbody select.input-sm {
1371
- height:30px;
1372
- font-size:12px;
1373
- }
1374
- #adminmenu #toplevel_page_GrandMedia ul.wp-submenu {
1375
- display:block;
1376
- }
1377
- .media-body { display:block; }
1378
- .show-settings-link { display:none; }
1379
- }
1380
- @media (max-width:991px) {
1381
- body#media-upload .panel-body > #gmUpload.row {
1382
- overflow-y:auto;
1383
- }
1384
- body#media-upload .panel-body > #gmUpload.row > div {
1385
- height:auto;
1386
- }
1387
- body#media-upload .plupload_wrapper {
1388
- height:auto;
1389
- }
1390
- body#media-upload div#pluploadUploader .plupload_container {
1391
- height:auto;
1392
- min-height:300px !important;
1393
- }
1394
- }
1395
- /*@-moz-document url-prefix() {
1396
- a.btn, span.btn {
1397
- line-height:1.56;
1398
- }
1399
- }*/
1400
-
1401
- /* custom inclusion of right, left tabs */
1402
- .tabs-right > .nav-tabs,
1403
- .tabs-left > .nav-tabs {
1404
- border-bottom:0;
1405
- }
1406
- .gm-tab-content > .tab-pane,
1407
- .pill-content > .pill-pane {
1408
- display:none;
1409
- }
1410
- .gm-tab-content > .active,
1411
- .pill-content > .active {
1412
- display:block;
1413
- }
1414
- .tabs-left > .nav-tabs > li,
1415
- .tabs-right > .nav-tabs > li {
1416
- float:none;
1417
- }
1418
- .tabs-left > .nav-tabs > li > a,
1419
- .tabs-right > .nav-tabs > li > a {
1420
- min-width:74px;
1421
- margin-right:0;
1422
- margin-bottom:3px;
1423
- }
1424
- .tabs-left > .nav-tabs {
1425
- float:left;
1426
- margin-right:19px;
1427
- border-right:1px solid #dddddd;
1428
- }
1429
- .tabs-left > .nav-tabs > li > a {
1430
- margin-right:-1px;
1431
- -webkit-border-radius:4px 0 0 4px;
1432
- -moz-border-radius:4px 0 0 4px;
1433
- border-radius:4px 0 0 4px;
1434
- }
1435
- .no-touch .tabs-left > .nav-tabs > li > a:hover,
1436
- .tabs-left > .nav-tabs > li > a:focus {
1437
- border-color:#eeeeee #dddddd #eeeeee #eeeeee;
1438
- }
1439
- .tabs-left > .nav-tabs .active > a,
1440
- .no-touch .tabs-left > .nav-tabs .active > a:hover,
1441
- .tabs-left > .nav-tabs .active > a:focus {
1442
- border-color:#dddddd transparent #dddddd #dddddd;
1443
- *border-right-color:#ffffff;
1444
- }
1445
- .tabs-right > .nav-tabs {
1446
- float:right;
1447
- margin-left:19px;
1448
- border-left:1px solid #dddddd;
1449
- }
1450
- .tabs-right > .nav-tabs > li > a {
1451
- margin-left:-1px;
1452
- -webkit-border-radius:0 4px 4px 0;
1453
- -moz-border-radius:0 4px 4px 0;
1454
- border-radius:0 4px 4px 0;
1455
- }
1456
- .no-touch .tabs-right > .nav-tabs > li > a:hover,
1457
- .tabs-right > .nav-tabs > li > a:focus {
1458
- border-color:#eeeeee #eeeeee #eeeeee #dddddd;
1459
- }
1460
- .tabs-right > .nav-tabs .active > a,
1461
- .no-touch .tabs-right > .nav-tabs .active > a:hover,
1462
- .tabs-right > .nav-tabs .active > a:focus {
1463
- border-color:#dddddd #dddddd #dddddd transparent;
1464
- *border-left-color:#ffffff;
1465
- }
1466
- /* custom badge colors */
1467
- .badge-error {background-color: #b94a48 !important; color: #fff !important;}
1468
- .badge-error:hover {background-color: #953b39 !important; color: #fff !important;}
1469
- .badge-warning {background-color: #f89406;}
1470
- .badge-warning:hover {background-color: #c67605;}
1471
- .badge-success {background-color: #468847 !important; color: #fff !important;}
1472
- .badge-success:hover {background-color: #356635 !important; color: #fff !important;}
1473
- .badge-info {background-color: #3a87ad;}
1474
- .badge-info:hover {background-color: #2d6987;}
1475
- .badge-inverse {background-color: #333333;}
1476
- .badge-inverse:hover {background-color: #1a1a1a;}
1477
- /* custom *-xs size for form elements */
1478
- input[type="date"].input-xs,
1479
- input[type="time"].input-xs,
1480
- input[type="datetime-local"].input-xs,
1481
- input[type="month"].input-xs,
1482
- .input-group-xs input[type="date"],
1483
- .input-group-xs input[type="time"],
1484
- .input-group-xs input[type="datetime-local"],
1485
- .input-group-xs input[type="month"] {
1486
- line-height:22px;
1487
- }
1488
- .form-control-static.input-xs {
1489
- padding-right:0;
1490
- padding-left:0;
1491
- }
1492
- .input-xs {
1493
- height:22px;
1494
- padding:1px 5px !important;
1495
- font-size:12px;
1496
- line-height:1.5;
1497
- border-radius:3px;
1498
- }
1499
- select.input-xs {
1500
- height:22px;
1501
- line-height:22px;
1502
- }
1503
- textarea.input-xs,
1504
- select[multiple].input-xs {
1505
- height:auto;
1506
- }
1507
- .form-group-xs .form-control {
1508
- height:22px;
1509
- padding:1px 5px;
1510
- font-size:12px;
1511
- line-height:1.5;
1512
- border-radius:3px;
1513
- }
1514
- select.form-group-xs .form-control {
1515
- height:22px;
1516
- line-height:22px;
1517
- }
1518
- textarea.form-group-xs .form-control,
1519
- select[multiple].form-group-xs .form-control {
1520
- height:auto;
1521
- }
1522
- .form-group-xs .form-control-static {
1523
- height:22px;
1524
- min-height:25px;
1525
- padding:1px 5px;
1526
- font-size:12px;
1527
- line-height:1.5;
1528
- }
1529
- .input-xs + .form-control-feedback {
1530
- width:22px;
1531
- height:22px;
1532
- line-height:22px;
1533
- }
1534
- @media (min-width:768px) {
1535
- .form-horizontal .form-group-xs .control-label {
1536
- padding-top:4px;
1537
- }
1538
- }
1539
- .input-group-xs > .form-control,
1540
- .input-group-xs > .input-group-addon,
1541
- .input-group-xs > .input-group-btn > .btn {
1542
- height:22px;
1543
- padding:1px 5px;
1544
- font-size:12px;
1545
- line-height:1.5;
1546
- border-radius:3px;
1547
- }
1548
- select.input-group-xs > .form-control,
1549
- select.input-group-xs > .input-group-addon,
1550
- select.input-group-xs > .input-group-btn > .btn {
1551
- height:22px;
1552
- line-height:22px;
1553
- }
1554
- textarea.input-group-xs > .form-control,
1555
- textarea.input-group-xs > .input-group-addon,
1556
- textarea.input-group-xs > .input-group-btn > .btn,
1557
- select[multiple].input-group-xs > .form-control,
1558
- select[multiple].input-group-xs > .input-group-addon,
1559
- select[multiple].input-group-xs > .input-group-btn > .btn {
1560
- height:auto;
1561
- }
1562
- .input-group-addon.input-xs {
1563
- padding:1px 5px;
1564
- font-size:12px;
1565
- border-radius:3px;
1566
- }
1567
- .input-group .form-control:first-child,
1568
- .input-group-addon:first-child,
1569
- .input-group-btn:first-child > .btn,
1570
- .input-group-btn:first-child > .btn-group > .btn,
1571
- .input-group-btn:first-child > .dropdown-toggle,
1572
- .input-group-btn:last-child > .btn-group:not(:last-child) > .btn,
1573
- .input-group-btn:last-child > .btn:not(:last-child):not(.dropdown-toggle) {
1574
- border-bottom-right-radius:0;
1575
- border-top-right-radius:0;
1576
- }
1577
- .input-group .form-control:last-child,
1578
- .input-group-addon:last-child,
1579
- .input-group-btn:first-child > .btn-group:not(:first-child) > .btn,
1580
- .input-group-btn:first-child > .btn:not(:first-child),
1581
- .input-group-btn:last-child > .btn,
1582
- .input-group-btn:last-child > .btn-group > .btn,
1583
- .input-group-btn:last-child > .dropdown-toggle {
1584
- border-bottom-left-radius:0;
1585
- border-top-left-radius:0;
1586
- }
1587
-
1588
- .input-group-addon.btn-primary {
1589
- color: #fff;
1590
- background-color: #337ab7;
1591
- border-color: #2e6da4;
1592
- cursor: pointer;
1593
- }
1594
-
1595
- .notice.updated.gm-message {
1596
- margin-left: 0;
1597
- margin-bottom: 30px;
1598
- /* clear: both; */
1599
- max-width: 800px;
1600
- }
1601
-
1602
- .gm-plugin-icon {
1603
- float: left;
1604
- margin-right: 15px;
1605
- }
1606
-
1607
- .gm-message-content * {
1608
- font-size: 14px;
1609
- }
1610
-
1611
- .gm-message-actions {
1612
- background-color: #e6eef1;
1613
- padding: 10px 12px;
1614
- margin: 0 -12px;
1615
- text-align: right;
1616
- }
1617
-
1618
- .gm-message-actions button {
1619
- margin-left: 20px !important;
1620
- }
1621
-
1622
- .gm-message-plus.gm-closed ul {
1623
- display: none;
1624
- }
1625
-
1626
- .gm-message-plus {
1627
- text-align: center;
1628
- padding: 4px 0;
1629
- }
1630
-
1631
- .gm-message-plus.gm-opened ul {
1632
- display: block;
1633
- text-align: left;
1634
- margin: 20px 20px 10px 20px;
1635
- }
1636
-
1637
- .gm-message-plus ul li {
1638
- margin-bottom: 12px;
1639
- }
1640
-
1641
- .gm-message-plus ul li i.dashicons {
1642
- float: left;
1643
- font-size: 40px;
1644
- width: 40px;
1645
- height: 40px;
1646
- }
1647
-
1648
- .gm-message-plus ul li div {
1649
- margin-left: 55px;
1650
- }
1651
-
1652
- .gm-message-plus ul li div span {
1653
- font-weight: bold;
1654
- text-transform: uppercase;
1655
- color: #23282d;
1656
- }
1657
-
1658
- .gm-message-plus ul li div p{
1659
- margin: 2px 0 0 0
1660
- }
1661
-
1662
- .gm-module-count-0 {
1663
- display: none;
1664
- }
1665
-
1666
- /* Spectrum */
1667
- .form-group .sp-replacer {
1668
- width: 100%;
1669
- border-radius: 3px;
1670
- }
1671
- .form-group .sp-preview {
1672
- width: calc(100% - 18px);
1673
- border-radius: 3px;
1674
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .grand-media-admin-page #wpcontent { background-color: transparent !important; }
2
+
3
+ .grand-media-admin-page #wpbody-content > .update-nag,
4
+ .grand-media-admin-page #wpbody-content > .updated.fade {display: none;}
5
+
6
+ #adminmenuback {z-index: 0}
7
+
8
+ #adminmenu #toplevel_page_GrandMedia ul.wp-submenu {
9
+ display: none;
10
+ }
11
+
12
+ #wpfooter {
13
+ color: #ffffff;
14
+ }
15
+
16
+ #wpfooter a {
17
+ color: lightblue;
18
+ }
19
+
20
+ #TB_caption {
21
+ height: auto;
22
+ }
23
+
24
+ a {
25
+ color: #0074a2;
26
+ }
27
+
28
+ input[type="checkbox"] {
29
+ margin-top: 2px;
30
+ margin-right: 2px
31
+ }
32
+
33
+ input[type="checkbox"], input[type="radio"] {
34
+ height: 16px;
35
+ width: 16px;
36
+ min-width: 0 !important;
37
+ }
38
+
39
+ input[type="button"] {
40
+ min-width: 0 !important;
41
+ }
42
+
43
+ .checkbox, .radio {
44
+ margin-top: 5px;
45
+ margin-bottom: 5px;
46
+ }
47
+
48
+ input::-moz-focus-inner {
49
+ border: 0;
50
+ padding: 0;
51
+ margin-top: -2px;
52
+ margin-bottom: -2px;
53
+ }
54
+
55
+ form,
56
+ .gmedia-admin form { margin: 0; }
57
+
58
+ legend.label { text-align: left; display: block; }
59
+
60
+ textarea.vert { resize: vertical; }
61
+
62
+ textarea.noResize { resize: none; }
63
+
64
+ body.gmedia-busy {
65
+ cursor: wait !important;
66
+ }
67
+
68
+ iframe {
69
+ background-color: #ffffff;
70
+ }
71
+
72
+ select.disabled {pointer-events: none;}
73
+
74
+ #gmedia-data-helper {
75
+ background: #333;
76
+ background: rgba(0, 0, 0, .8);
77
+ border-radius: 5px;
78
+ color: #fff;
79
+ padding: 4px 10px;
80
+ position: fixed;
81
+ z-index: 999999;
82
+ max-width: 220px;
83
+ word-wrap: break-word;
84
+ }
85
+
86
+ #gmedia-data-helper:before {
87
+ border: solid;
88
+ border-color: #333 transparent;
89
+ border-width: 0 6px 6px 6px;
90
+ bottom: 100%;
91
+ content: "";
92
+ left: 17px;
93
+ position: absolute;
94
+ z-index: 99;
95
+ }
96
+
97
+ #gmedia-data-helper.tiptoleft:before {
98
+ left: auto;
99
+ right: 17px;
100
+ }
101
+
102
+ body.gmedia-blank {
103
+ height: auto;
104
+ min-height: 100%;
105
+ padding: 0 0 1px;
106
+ box-sizing: border-box;
107
+ }
108
+
109
+ body.gmedia-blank pre {
110
+ margin: 0;
111
+ padding: 0;
112
+ border: none;
113
+ }
114
+
115
+ .gmedia-body div#gm-message {
116
+ position: absolute;
117
+ right: 5px;
118
+ top: 5px;
119
+ overflow: visible;
120
+ z-index: 200;
121
+ }
122
+
123
+ .gmedia-body div#gm-message .gm-message {
124
+ text-align: right;
125
+ }
126
+
127
+ div#gmedia-container {
128
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
129
+ margin: 30px 5px 10px 0;
130
+ position: relative;
131
+ z-index: 1;
132
+ direction: ltr;
133
+ min-width: 560px;
134
+ -webkit-backface-visibility: hidden;
135
+ backface-visibility: hidden;
136
+ box-sizing: border-box;
137
+ }
138
+
139
+ div#gmedia-container * {
140
+ box-sizing: inherit;
141
+ }
142
+
143
+ div#gmedia-container .row,
144
+ div.gmedia-modal .row {
145
+ padding: 0;
146
+ }
147
+
148
+ div#gmedia-container form.row {
149
+ padding: 15px 0;
150
+ }
151
+
152
+ body.gmedia-blank div#gmedia-container {
153
+ margin: 0;
154
+ position: static;
155
+ z-index: auto;
156
+ direction: ltr;
157
+ min-width: auto;
158
+ width: 100%;
159
+ height: 100%;
160
+ }
161
+
162
+ div#gmedia-header {
163
+ position: relative;
164
+ padding: 1px 1px 10px 1px;
165
+ display: flex;
166
+ flex-wrap: wrap;
167
+ align-items: center;
168
+ }
169
+
170
+ /*noinspection CssInvalidElement*/
171
+ div#gmedia-logo {
172
+ position: relative;
173
+ margin: 0 30px 0 15px;
174
+ font-size: 48px;
175
+ text-shadow: 1px 1px 4px #000000;
176
+ font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
177
+ color: #ffffff;
178
+ float: left;
179
+ /*noinspection CssFloatPxLength*/
180
+ -webkit-text-stroke-width: 0.7px;
181
+ -webkit-text-stroke-color: #ffffff;
182
+ -webkit-font-smoothing: antialiased;
183
+ -webkit-user-select: none;
184
+ -moz-user-select: none;
185
+ -ms-user-select: none;
186
+ user-select: none;
187
+ cursor: default;
188
+ }
189
+
190
+ div#gmedia-logo small {
191
+ display: block;
192
+ font-size: 10px;
193
+ margin-top: 7px;
194
+ text-align: right;
195
+ -webkit-text-stroke-width: 0;
196
+ }
197
+
198
+ div#gmedia-header h2 {
199
+ margin: 0;
200
+ font: italic 24px/35px Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
201
+ color: #ffffff;
202
+ flex: 1 1 180px;
203
+ }
204
+
205
+ div#gmedia-header .promote-woowbox {
206
+ flex: 1 1 50%;
207
+ margin-top: -10px;
208
+ }
209
+
210
+ div#gmedia-header .promote-woowbox img {
211
+ border: 1px solid rgba(255, 255, 255, 0.7);
212
+ }
213
+
214
+ #ajax-long-operation {
215
+ position: absolute;
216
+ right: 20px;
217
+ bottom: 0;
218
+ width: 25%;
219
+ min-width: 220px;
220
+ }
221
+
222
+ .progress-bar-indicator {
223
+ position: absolute;
224
+ width: 100%;
225
+ text-align: center;
226
+ color: #204D74;
227
+ }
228
+
229
+ div#gmedia-navbar {
230
+ font-size: 14px;
231
+ }
232
+
233
+ a.list-group-item-premium {
234
+ color: #ffffff !important;
235
+ background-color: #D82700;
236
+ border-color: #A52A2A;
237
+ font-weight: bold;
238
+ }
239
+
240
+ a.list-group-item-premium:hover {
241
+ color: #ffffff !important;
242
+ background-color: #c52400;
243
+ border-color: #A52A2A;
244
+ font-weight: bold;
245
+ }
246
+
247
+ div.custom-message {
248
+ padding: 5px 10px;
249
+ margin: 0 0 10px;
250
+ }
251
+
252
+ form.gmedia-search-form {
253
+ float: right;
254
+ margin-left: 10px;
255
+ margin-bottom: 4px;
256
+ white-space: nowrap;
257
+ }
258
+
259
+ form.gmedia-search-form .form-group {
260
+ margin: 0;
261
+ display: inline-block;
262
+ vertical-align: middle;
263
+ }
264
+
265
+ .gmedia-pager {
266
+ margin-bottom: 4px;
267
+ }
268
+
269
+ form#gmedia-pager {
270
+ float: left;
271
+ width: auto;
272
+ display: block;
273
+ }
274
+
275
+ form#gmedia-pager span,
276
+ form#gmedia-pager input {
277
+ width: auto;
278
+ display: inline-block;
279
+ vertical-align: inherit;
280
+ float: none;
281
+ }
282
+
283
+ form#gmedia-pager input.pager_current_page {
284
+ padding-left: 0;
285
+ padding-right: 0;
286
+ text-align: center;
287
+ width: 2.5em;
288
+ }
289
+
290
+ .txt-lg {
291
+ font-size: 120%;
292
+ line-height: 50%;
293
+ }
294
+
295
+ a.text-danger {
296
+ color: #a94442;
297
+ }
298
+
299
+ .btn > input[type="checkbox"] {
300
+ margin-top: 0;
301
+ width: 16px;
302
+ height: 16px;
303
+ }
304
+
305
+ .va-middle { vertical-align: middle }
306
+
307
+ .dropdown-menu > li > a:hover, .dropdown-menu > li > a:focus {
308
+ background-color: #e8e8e8;
309
+ }
310
+
311
+ .gm-checkgroup {
312
+ margin-right: 20px;
313
+ }
314
+
315
+ .gm-backfade {
316
+ background-color: rgba(0, 0, 0, 0.1);
317
+ }
318
+
319
+ .dropdown-menu > .disabled {
320
+ cursor: not-allowed;
321
+ }
322
+
323
+ .dropdown-menu > .disabled > a {
324
+ pointer-events: none;
325
+ }
326
+
327
+ .panel-heading-fake { display: none; }
328
+
329
+ .panel-floatingHeader .panel-heading-fake,
330
+ .panel-absoluteHeader .panel-heading-fake { display: block; }
331
+
332
+ .panel-fixed-header { position: relative; }
333
+
334
+ .panel-fixed-header .panel-heading { position: relative; top: 0; max-width: 100%;
335
+ /*transition:top 0.2s ease-out; -webkit-transition:top 0.2s ease-out;*/
336
+ }
337
+
338
+ .panel-heading .spinner { margin-top: 0; }
339
+
340
+ body.gmedia-blank .panel-floatingHeader .panel-heading,
341
+ .panel-floatingHeader .panel-heading {
342
+ position: fixed;
343
+ top: 32px;
344
+ z-index: 20;
345
+ border-radius: 0;
346
+ -webkit-box-shadow: 0 5px 10px #888888;
347
+ -moz-box-shadow: 0 5px 10px #888888;
348
+ box-shadow: 0 5px 10px #888888;
349
+ }
350
+
351
+ body.gmedia-blank .panel-floatingHeader .panel-heading {
352
+ top: 0;
353
+ }
354
+
355
+ body.gmedia-blank .panel-absoluteHeader .panel-heading,
356
+ .panel-absoluteHeader .panel-heading {
357
+ position: absolute;
358
+ z-index: 10;
359
+ top: auto;
360
+ bottom: 0;
361
+ border-bottom: 1px solid transparent;
362
+ border-bottom-right-radius: 3px;
363
+ border-bottom-left-radius: 3px;
364
+ }
365
+
366
+ .dropdown-menu:not(.bootstrap-datetimepicker-widget) {
367
+ max-height: calc(100vh - 50px);
368
+ overflow-y: auto;
369
+ }
370
+
371
+ div#gm-list-table {
372
+ font-size: 13px;
373
+ display: flex;
374
+ flex-wrap: wrap;
375
+ }
376
+
377
+ div#gm-list-table::before {
378
+ display: block;
379
+ content: '';
380
+ float: left;
381
+ width: 0;
382
+ height: auto;
383
+ overflow: hidden;
384
+ }
385
+
386
+ .list-group-item { width: 100%; }
387
+
388
+ .list-group-item.row {
389
+ position: relative;
390
+ margin-left: 0;
391
+ margin-right: 0;
392
+ padding-left: 0;
393
+ padding-right: 0;
394
+ }
395
+
396
+ div.list-group-item.d-row {
397
+ position: relative;
398
+ color: inherit;
399
+ z-index: 1;
400
+ }
401
+
402
+ .no-touch div.list-group-item.d-row:hover {
403
+ background-color: #fafafa;
404
+ }
405
+
406
+ .no-touch form.list-group-item.d-row:hover {
407
+ background-color: #fcfcfc;
408
+ }
409
+
410
+ .list-group-item.d-row.gm-selected {
411
+ color: #444444;
412
+ border-color: #dddddd;
413
+ background-color: rgb(250, 255, 245);
414
+ -webkit-box-shadow: inset -1px 0 0 2px rgb(250, 255, 245), inset 7px 0 0 0 #1e8cbe;
415
+ -moz-box-shadow: inset -1px 0 0 2px rgb(250, 255, 245), inset 7px 0 0 0 #1e8cbe;
416
+ box-shadow: inset -1px 0 0 2px rgb(250, 255, 245), inset 7px 0 0 0 #1e8cbe;
417
+ }
418
+
419
+ .no-touch .list-group-item.d-row.gm-selected:hover {
420
+ color: #444444;
421
+ border-color: #dddddd;
422
+ background-color: rgb(245, 255, 240);
423
+ -webkit-box-shadow: inset -1px 0 0 2px rgb(245, 255, 240), inset 7px 0 0 0 #1e8cbe;
424
+ -moz-box-shadow: inset -1px 0 0 2px rgb(245, 255, 240), inset 7px 0 0 0 #1e8cbe;
425
+ box-shadow: inset -1px 0 0 2px rgb(245, 255, 240), inset 7px 0 0 0 #1e8cbe;
426
+ }
427
+
428
+ div#gmedia-container .list-group-item-info,
429
+ div#gmedia-container .list-group-item-info:hover {
430
+ background-color: #d9edf7 !important;
431
+ color: inherit !important;
432
+ }
433
+
434
+ div#gmedia-container .list-group-item-warning,
435
+ div#gmedia-container .list-group-item-warning:hover {
436
+ background-color: #fcf8e3 !important;
437
+ color: inherit !important;
438
+ }
439
+
440
+ div#gmedia-container .item-after-limit {
441
+ filter: blur(1px);
442
+ -webkit-filter: blur(1px);
443
+ -moz-filter: blur(1px);
444
+ -o-filter: blur(1px);
445
+ -ms-filter: blur(1px);
446
+ filter: progid:DXImageTransform.Microsoft.Blur(PixelRadius='1');
447
+ }
448
+
449
+ .bg-status-private {
450
+ background-color: #d9edf7;
451
+ -webkit-box-shadow: 3px 0 0 5px #d9edf7, -2px 0 0 5px #6fbfff;
452
+ -moz-box-shadow: 3px 0 0 5px #d9edf7, -2px 0 0 5px #6fbfff;
453
+ box-shadow: 3px 0 0 5px #d9edf7, -2px 0 0 5px #6fbfff;
454
+ }
455
+
456
+ .bg-status-draft {
457
+ background-color: #fcf8e3;
458
+ -webkit-box-shadow: 3px 0 0 5px #fcf8e3, -2px 0 0 5px #ffd87c;
459
+ -moz-box-shadow: 3px 0 0 5px #fcf8e3, -2px 0 0 5px #ffd87c;
460
+ box-shadow: 3px 0 0 5px #fcf8e3, -2px 0 0 5px #ffd87c;
461
+ }
462
+
463
+ input.gm-order-input {
464
+ float: right;
465
+ border: 1px solid #ccc;
466
+ border-radius: 3px;
467
+ padding: 1px 3px;
468
+ margin: 0;
469
+ font-size: 12px;
470
+ line-height: 120%;
471
+ width: 3em;
472
+ text-align: right;
473
+ }
474
+
475
+ .form-group .gmpost-com-count {font-size: 16px;}
476
+
477
+ .gmpost-com-count:hover {text-decoration: none}
478
+
479
+ label.cb_media-object-gallery {
480
+ width: 40px;
481
+ position: absolute;
482
+ left: 5px;
483
+ top: 0; bottom: 0;
484
+ text-align: center;
485
+ padding-top: 4px;
486
+ }
487
+
488
+ .d-row .thumbnail {
489
+ margin-bottom: 0;
490
+ }
491
+
492
+ .gm-selected .thumbnail {
493
+ border-color: #428bca;
494
+ }
495
+
496
+ .thumbnail {
497
+ position: relative;
498
+ display: inline-block;
499
+ max-width: 100%;
500
+ }
501
+
502
+ .display-as-grid .gm-item-cell {
503
+ padding: 12px 12px 10px;
504
+ border: 4px solid #ffffff;
505
+ background-color: #f7f7f7;
506
+ min-width: 195px;
507
+ max-width: 340px;
508
+ border-radius: 14px;
509
+ flex: 1 1 195px;
510
+ }
511
+
512
+ .display-as-grid .gm-item-cell-blank {
513
+ flex: 1 1 195px;
514
+ }
515
+
516
+ .display-as-grid .gm-item-cell.ui-highlight-placeholder {margin-bottom: 0;background-color: #2c7c91;}
517
+
518
+ .edit-gmedia .gmedia-actions { margin: 10px; }
519
+
520
+ .gm-item-cell .gmedia-actions {
521
+ overflow: hidden;
522
+ position: absolute;
523
+ left: 0; top: 0;
524
+ transform: translateY(100%) translateZ(0);
525
+ opacity: 0;
526
+ transition: transform 0.1s, opacity 0.2s;
527
+ }
528
+
529
+ .gmedia-actions > * {margin-left: 5px; margin-right: 5px;}
530
+
531
+ .gm-item-cell .gmedia-actions > * {float: left;}
532
+
533
+ .gm-item-cell .gmedia-actions * {
534
+ -webkit-backface-visibility: hidden;
535
+ backface-visibility: hidden;
536
+ -webkit-transform-style: preserve-3d;
537
+ }
538
+
539
+ .gmedia-actions > *:first-child {margin-left: 0;}
540
+
541
+ .gmedia-actions > *:last-child {margin-right: 0;}
542
+
543
+ .related-media-previews {}
544
+
545
+ .related-media-previews::before,
546
+ .related-media-previews::after {
547
+ content: "";
548
+ display: table;
549
+ clear: both;
550
+ height: 0;
551
+ overflow: hidden;
552
+ }
553
+
554
+ p.thumbnail.gmedia-related-image,
555
+ .related-media-previews p.gmedia-related-image {
556
+ width: 30%;
557
+ float: left;
558
+ display: inline-block;
559
+ position: relative;
560
+ margin-right: 3%;
561
+ margin-top: 7px;
562
+ }
563
+
564
+ .edit-gmedia p.thumbnail.gmedia-related-image,
565
+ .edit-gmedia .related-media-previews p.gmedia-related-image {
566
+ width: 44%;
567
+ float: none;
568
+ vertical-align: top;
569
+ }
570
+
571
+ p.thumbnail.gmedia-related-image .gm-remove {
572
+ padding: 1px;
573
+ font-size: 15px;
574
+ font-weight: bold;
575
+ line-height: 0.7;
576
+ border-radius: 50%;
577
+ width: 1em;
578
+ height: 1em;
579
+ box-sizing: content-box;
580
+ color: #fff;
581
+ background-color: #cc0d00;
582
+ text-align: center;
583
+ position: absolute;
584
+ right: -0.5em;
585
+ top: -0.5em;
586
+ transform: scale(0);
587
+ transition: transform 0.1s ease-in;
588
+ cursor: pointer;
589
+ }
590
+
591
+ p.thumbnail.gmedia-related-image:hover .gm-remove {
592
+ transform: scale(1);
593
+ }
594
+
595
+ p.thumbnail.gmedia-related-image .image-wrapper {
596
+ display: block;
597
+ position: relative;
598
+ width: 100%;
599
+ height: 0;
600
+ padding-bottom: 62.5%;
601
+ cursor: move;
602
+ }
603
+
604
+ p.thumbnail.gmedia-related-image img.gmedia-thumb {
605
+ position: absolute;
606
+ left: 0;
607
+ top: 0;
608
+ width: 100%;
609
+ height: 100%;
610
+ display: block;
611
+ object-fit: contain;
612
+ }
613
+
614
+ .gm-item-cell .gm-cell-bottom {
615
+ position: relative;
616
+ min-height: 20px;
617
+ margin: 15px 0 0 2px;
618
+ overflow: hidden;
619
+ }
620
+
621
+ .gm-item-cell .gm-cell-title {
622
+ overflow: hidden;
623
+ font-size: 12px;
624
+ font-weight: bold;
625
+ cursor: pointer;
626
+ opacity: 1;
627
+ position: absolute;
628
+ left: 0;
629
+ top: 0;
630
+ width: 100%;
631
+ transition: opacity 0.15s;
632
+ }
633
+
634
+ .gm-item-cell .gm-cell-title span {
635
+ display: block;
636
+ width: 100%;
637
+ white-space: nowrap;
638
+ text-overflow: ellipsis;
639
+ overflow: hidden;
640
+ }
641
+
642
+ .gm-item-cell:hover .gm-cell-title { opacity: 0; pointer-events: none;}
643
+
644
+ .gm-item-cell:hover .gmedia-actions { transform: translateY(0) translateZ(0); opacity: 1;}
645
+
646
+ .display-as-grid div.thumbnail {
647
+ cursor: pointer;
648
+ position: relative;
649
+ display: block;
650
+ border-radius: 0;
651
+ margin: 0;
652
+ padding: 0;
653
+ -webkit-backface-visibility: hidden;
654
+ backface-visibility: hidden;
655
+ }
656
+
657
+ .display-as-grid div.thumbnail:before {
658
+ content: "";
659
+ display: block;
660
+ padding-top: 100%;
661
+ }
662
+
663
+ .display-as-grid .gm-selected div.thumbnail {
664
+ -webkit-box-shadow: 0 0 0 7px #1e8cbe;
665
+ -moz-box-shadow: 0 0 0 7px #1e8cbe;
666
+ box-shadow: 0 0 0 7px #1e8cbe;
667
+ border-radius: 1px;
668
+ }
669
+
670
+ .display-as-grid div.thumbnail .cb_media-object,
671
+ .display-as-grid div.thumbnail .gm-item-cell-media-object {
672
+ bottom: 0;
673
+ left: 0;
674
+ overflow: hidden;
675
+ position: absolute;
676
+ right: 0;
677
+ top: 0;
678
+ text-align: center;
679
+ margin: 0;
680
+ }
681
+
682
+ .display-as-grid div.thumbnail .gm-cell-more {
683
+ position: absolute;
684
+ left: 0; top: 0; right: 0;
685
+ background: rgba(256, 256, 256, 0.6);
686
+ color: #000000;
687
+ cursor: auto;
688
+ }
689
+
690
+ .display-as-grid div.thumbnail .gm-cell-more-btn {
691
+ position: absolute;
692
+ top: 0; right: 0;
693
+ padding: 5px;
694
+ cursor: pointer;
695
+ color: #1e8cbe;
696
+ /*text-shadow: 1px 1px 1px #83acbf;*/
697
+ }
698
+
699
+ .display-as-grid div.thumbnail .gm-cell-more-content {
700
+ padding: 5px 5px 0;
701
+ display: none;
702
+ overflow: hidden;
703
+ /*transition:all 0.2s easy-out;*/
704
+ font-size: 11px;
705
+ }
706
+
707
+ .display-as-grid div.thumbnail .gm-cell-more-content .gmedia-actions {
708
+ display: none;
709
+ }
710
+
711
+ .display-as-grid div.thumbnail .gm-cell-more:hover,
712
+ .display-as-grid div.thumbnail .gm-cell-more.gm-cell-more-active {
713
+ z-index: 10;
714
+ -webkit-box-shadow: 0 0 0 1px #dddddd, 0 4px 3px -1px rgba(0, 0, 0, 0.3);
715
+ -moz-box-shadow: 0 0 0 1px #dddddd, 0 4px 3px -1px rgba(0, 0, 0, 0.3);
716
+ box-shadow: 0 0 0 1px #dddddd, 0 4px 3px -1px rgba(0, 0, 0, 0.3);
717
+ }
718
+
719
+ .display-as-grid div.thumbnail .gm-cell-more:hover {
720
+ z-index: 11;
721
+ }
722
+
723
+ .display-as-grid div.thumbnail .gm-cell-more:hover > div {
724
+ background: rgba(256, 256, 256, 0.7);
725
+ }
726
+
727
+ .display-as-grid div.thumbnail .gm-cell-more-active .gm-cell-more-content .gmedia-actions {
728
+ display: block;
729
+ }
730
+
731
+ .display-as-grid div.thumbnail .gm-cell-more.gm-cell-more-active > div {
732
+ background: rgba(256, 256, 256, 0.9);
733
+ }
734
+
735
+ .display-as-grid div.thumbnail .gm-cell-more:hover .gm-cell-more-content,
736
+ .display-as-grid div.thumbnail .gm-cell-more.gm-cell-more-active .gm-cell-more-content {
737
+ display: block;
738
+ }
739
+
740
+ .display-as-grid div.thumbnail .gm-cell-more-content p {
741
+ font-size: 11px;
742
+ }
743
+
744
+ .display-as-grid div.thumbnail .cb_media-object .centered,
745
+ .display-as-grid div.thumbnail .gm-item-cell-media-object .centered {
746
+ height: 100%;
747
+ left: 0;
748
+ position: absolute;
749
+ top: 0;
750
+ transform: translate(50%, 50%) translateZ(0);
751
+ width: 100%;
752
+ }
753
+
754
+ .display-as-grid div.thumbnail.landscape .cb_media-object .centered,
755
+ .display-as-grid div.thumbnail.landscape .gm-item-cell-media-object .centered {
756
+ transform: translate(50%, 50.5%) translateZ(0);
757
+ }
758
+
759
+ .display-as-grid div.thumbnail .cb_media-object img,
760
+ .display-as-grid div.thumbnail .gm-item-cell-media-object img {
761
+ left: 0;
762
+ position: absolute;
763
+ top: 0;
764
+ transform: translate(-50%, -50%) translateZ(0);
765
+ }
766
+
767
+ .display-as-grid div.thumbnail.landscape img {
768
+ height: 101%;
769
+ width: auto;
770
+ }
771
+
772
+ .display-as-grid div.thumbnail.portrait img {
773
+ height: auto;
774
+ width: 100%;
775
+ }
776
+
777
+ .display-as-grid.invert-ratio div.thumbnail.landscape img {
778
+ height: auto;
779
+ width: 101%;
780
+ }
781
+
782
+ .display-as-grid.invert-ratio div.thumbnail.portrait img {
783
+ height: 101%;
784
+ width: auto;
785
+ }
786
+
787
+ .thumbnail img.gmedia-typethumb,
788
+ .display-as-grid div.thumbnail .cb_media-object img.gmedia-typethumb,
789
+ .display-as-grid div.thumbnail .gm-item-cell-media-object img.gmedia-typethumb {
790
+ position: absolute;
791
+ right: 7px;
792
+ bottom: 7px;
793
+ height: 75px;
794
+ max-height: 60%;
795
+ width: auto;
796
+ }
797
+
798
+ .display-as-grid div.thumbnail .cb_media-object img.gmedia-typethumb,
799
+ .display-as-grid div.thumbnail .gm-item-cell-media-object img.gmedia-typethumb {
800
+ left: auto;
801
+ top: auto;
802
+ right: 50%;
803
+ bottom: 50%;
804
+ margin: 0 5px 5px 0;
805
+ transform: none;
806
+ opacity: 0.9;
807
+ }
808
+
809
+ .thumbwrap { position: relative; margin-bottom: 5px; }
810
+
811
+ .gm-item-check,
812
+ .gm-order { position: absolute; right: -8px; bottom: -8px; padding: 5px; margin: 0; border-style: solid; border-color: #1e8cbe; background-color: #ffffff; border-width: 1px 0 0 1px; }
813
+
814
+ .gm-item-check input { margin: 0; padding: 0; }
815
+
816
+ .gm-order input {
817
+ display: block;
818
+ line-height: 120%;
819
+ width: 42px;
820
+ padding: 0 2px;
821
+ margin: 0;
822
+ text-align: center;
823
+ border: 1px solid #ccc;
824
+ border-radius: 4px;
825
+ }
826
+
827
+ .thumbwrap .gm-item-check { right: 1px; bottom: 1px; border: 1px solid #dddddd; border-radius: 5px 0 5px 0; border-right-color: transparent; border-bottom-color: transparent; border-width: 1px; }
828
+
829
+ .thumbwrap .cb_media-object { width: 100%; margin: 0; display: flex; }
830
+
831
+ .cb_media-object .thumbnail {
832
+ width: 100%;
833
+ }
834
+
835
+ .media-title {
836
+ font-size: 22px;
837
+ word-wrap: break-word;
838
+ }
839
+
840
+ .media-caption:empty { display: none; }
841
+
842
+ .media-caption.in-library {
843
+ max-height: 215px;
844
+ }
845
+
846
+ .media-caption {
847
+ background-color: #f5f5f5;
848
+ border: 1px solid #cccccc;
849
+ border-radius: 4px;
850
+ padding: 5px 7px;
851
+ margin: 0 -6px 5px;
852
+ overflow: auto;
853
+ word-break: normal;
854
+ word-wrap: break-word;
855
+ max-height: 210px;
856
+ }
857
+
858
+ .media-body .media-caption {
859
+ margin: 0;
860
+ }
861
+
862
+ .media-meta {
863
+ width: 100%;
864
+ overflow: hidden;
865
+ text-overflow: ellipsis; /*white-space:nowrap;*/
866
+ }
867
+
868
+ .media-meta .gm_gallery_source { font-weight: bold; }
869
+
870
+ .media-meta .label-default {
871
+ background-color: #eeeeee;
872
+ color: #444444;
873
+ }
874
+
875
+ .gmedia_id {
876
+ position: absolute;
877
+ right: 10px;
878
+ top: 10px;
879
+ }
880
+
881
+ .term_id {
882
+ font-size: 80%;
883
+ }
884
+
885
+ .term_date {
886
+ font-size: 80%;
887
+ }
888
+
889
+ .term_date:empty {
890
+ display: none;
891
+ }
892
+
893
+ .term_date:before {
894
+ content: '[';
895
+ }
896
+
897
+ .term_date:after {
898
+ content: ']';
899
+ }
900
+
901
+ #gm-list-table .hidden {
902
+ display: none !important;
903
+ visibility: hidden !important;
904
+ }
905
+
906
+ form#adv-settings .form-inline .form-group {
907
+ margin-right: 20px;
908
+ }
909
+
910
+ form.changed {
911
+ }
912
+
913
+ form.changed.saved {
914
+ }
915
+
916
+ form.changed .gm-last-edited {
917
+ text-decoration: line-through;
918
+ }
919
+
920
+ .selectize-input.full input {
921
+ width: 4px !important;
922
+ }
923
+
924
+ .rel-selected-hide {
925
+ display: none;
926
+ }
927
+
928
+ .plupload_wrapper {
929
+ min-width: unset;
930
+ }
931
+
932
+ .gmAddMedia {
933
+ padding: 0;
934
+ }
935
+
936
+ div#pluploadUploader {
937
+ padding: 0;
938
+ box-sizing: border-box;
939
+ }
940
+
941
+ div#pluploadUploader > div > div * {
942
+ box-sizing: content-box;
943
+ }
944
+
945
+ .plupload_container {
946
+ padding: 0;
947
+ }
948
+
949
+ div#pluploadUploader_container {
950
+ min-height: 450px;
951
+ border-bottom-right-radius: 4px;
952
+ }
953
+
954
+ div#pluploadUploader_container .plupload_filelist_footer {
955
+ border-bottom-right-radius: 4px;
956
+ font-size: 11px;
957
+ white-space: nowrap;
958
+ }
959
+
960
+ div#pluploadUploader_buttons { margin-bottom: 5px; }
961
+
962
+ div.plupload_started { float: left; }
963
+
964
+ div.panel-body, div#gmedia-msg-panel, #gmedia-service-msg-panel {
965
+ -webkit-transition: all .2s ease-in-out;
966
+ transition: all .2s ease-in-out;
967
+ }
968
+
969
+ div.panel-body:empty, div#gmedia-msg-panel:empty, #gmedia-service-msg-panel:empty {
970
+ padding: 0;
971
+ }
972
+
973
+ div#gmedia-msg-panel .alert,
974
+ #gmedia-service-msg-panel .alert {
975
+ padding: 2px 35px 2px 12px;
976
+ margin-bottom: 5px;
977
+ }
978
+
979
+ .plupload_content li {
980
+ margin-bottom: 0;
981
+ }
982
+
983
+ .progress {
984
+ position: relative;
985
+ white-space: nowrap;
986
+ font-size: 12px;
987
+ line-height: 20px;
988
+ }
989
+
990
+ .progress-bar {
991
+ position: absolute;
992
+ overflow: hidden;
993
+ }
994
+
995
+ .tab-inside {
996
+ padding: 10px;
997
+ position: relative;
998
+ }
999
+
1000
+ .tab-footer {
1001
+ border-top: 1px solid #dddddd;
1002
+ padding: 20px 10px 0;
1003
+ }
1004
+
1005
+ .selectize-control.input-sm .selectize-input {
1006
+ min-height: 30px;
1007
+ padding: 2px 10px;
1008
+ font-size: 12px;
1009
+ line-height: 1.9;
1010
+ border-radius: 3px;
1011
+ }
1012
+
1013
+ .selectize-control.multi .selectize-input.has-items {
1014
+ padding-top: 2px;
1015
+ }
1016
+
1017
+ .selectize-control.input-sm .selectize-input input {
1018
+ font-size: 12px;
1019
+ }
1020
+
1021
+ .selectize-control.input-sm .selectize-input:after {
1022
+ right: 10px;
1023
+ }
1024
+
1025
+ .selectize-control.input-sm .selectize-input > div {
1026
+ line-height: 146%;
1027
+ }
1028
+
1029
+ .term-list-item {
1030
+ padding-top: 0;
1031
+ padding-bottom: 0;
1032
+ z-index: 1;
1033
+ }
1034
+
1035
+ .object-actions { text-align: right; font-size: 16px; }
1036
+
1037
+ .object-actions.gallery-object-actions { text-align: left; margin-bottom: 5px; }
1038
+
1039
+ .object-actions > * { margin: 0 0 0 10px; vertical-align: middle; display: inline-block; }
1040
+
1041
+ .object-actions.gallery-object-actions > *:first-child { margin-left: 0; }
1042
+
1043
+ .object-actions a:hover { text-decoration: none; }
1044
+
1045
+ /*.gm_filter_in_lib { border:1px solid; border-radius:4px; font-size:14px; line-height:14px; padding:0 2px 0 4px; }*/
1046
+ .gm_term_count { font-size: 13px; font-weight: bold; text-decoration: none; vertical-align: bottom; }
1047
+
1048
+ a.trash-icon:hover { color: #843534; }
1049
+
1050
+ .action-inactive { color: #b8b8b8; }
1051
+
1052
+ .action-inactive:hover { color: #b8b8b8; }
1053
+
1054
+ .term-list-item .term-label .checkbox {
1055
+ padding-left: 35px;
1056
+ padding-top: 6px;
1057
+ min-height: 68px;
1058
+ }
1059
+
1060
+ .term-list-item .term-label .checkbox > input {
1061
+ margin-left: -35px;
1062
+ margin-top: 2px;
1063
+ }
1064
+
1065
+ .term-list-item .checkbox input {
1066
+ margin-top: 0;
1067
+ margin-right: 15px;
1068
+ }
1069
+
1070
+ .term-list-item .term-description {
1071
+ padding: 0;
1072
+ white-space: nowrap;
1073
+ overflow: hidden;
1074
+ color: #444444;
1075
+ text-overflow: ellipsis;
1076
+ }
1077
+
1078
+ .term-list-item .term-description:empty {
1079
+ padding: 0;
1080
+ }
1081
+
1082
+ .term-list-item .object-actions {
1083
+ position: absolute;
1084
+ right: 0; left: auto; top: 4px;
1085
+ line-height: 165%;
1086
+ }
1087
+
1088
+ .term-list-item .term-images {
1089
+ padding-top: 5px;
1090
+ padding-bottom: 5px;
1091
+ overflow: hidden;
1092
+ white-space: nowrap;
1093
+ position: relative;
1094
+ z-index: 1;
1095
+ }
1096
+
1097
+ .term-list-item .term-images img {
1098
+ position: relative;
1099
+ height: 68px;
1100
+ width: auto;
1101
+ background-color: #ffffff;
1102
+ }
1103
+
1104
+ .term-list-item .term_name { margin-right: 80px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 22px; display: inline-block; line-height: 100%; }
1105
+
1106
+ .term-list-item .no-checkbox .term_name { margin-right: 5px; font-size: 16px;}
1107
+
1108
+ .term-list-item .term_info_author {
1109
+ font-size: 80%;
1110
+ white-space: nowrap;
1111
+ color: #444444;
1112
+ }
1113
+
1114
+ .object-actions .term-shortcode {float: left;margin: 0;}
1115
+
1116
+ .object-actions .term-shortcode input,
1117
+ .object-actions .term-shortcode .input-buffer { font-family: Courier, sans-serif; font-size: 14px; line-height: 100%; letter-spacing: 0.05em; border: none; box-shadow: none; background-color: #fff; margin: 0; padding: 0;}
1118
+
1119
+ .panel-heading .term-shortcode {float: left;margin-left: 20px;}
1120
+
1121
+ .panel-heading .term-shortcode input,
1122
+ .panel-heading .term-shortcode .input-buffer { font-family: Courier, sans-serif; font-size: 14px; letter-spacing: 0.05em; }
1123
+
1124
+ .term-shortcode .input-buffer {position: absolute; top: -1000px; left: -1000px; visibility: hidden; white-space: nowrap;}
1125
+
1126
+ .no-touch .term-list-item .term-images img:hover {
1127
+ z-index: 100 !important;
1128
+ }
1129
+
1130
+ .edit_tag_link { font-size: 18px; }
1131
+
1132
+ .edit_tag_form {
1133
+ display: inline-block;
1134
+ margin-left: -5px;
1135
+ margin-bottom: -1px;
1136
+ margin-top: -1px;
1137
+ font-size: 18px;
1138
+ }
1139
+
1140
+ .edit_tag_form a { font-size: 18px; line-height: 100%;}
1141
+
1142
+ .edit_tag_form input.edit_tag_input {
1143
+ padding: 0 5px;
1144
+ border-width: 0 0 1px 0;
1145
+ margin: 0;
1146
+ font-size: 18px;
1147
+ line-height: 100%;
1148
+ }
1149
+
1150
+ a.edit_tag_save.btn {
1151
+ padding-top: 0;
1152
+ padding-bottom: 0;
1153
+ }
1154
+
1155
+ .no-touch a.edit_tag_save.btn-link:hover {
1156
+ text-decoration: none;
1157
+ }
1158
+
1159
+ .gm-img-thumbnail {
1160
+ display: inline-block;
1161
+ position: relative;
1162
+ margin-right: 5px;
1163
+ margin-bottom: 25px;
1164
+ max-width: 100%;
1165
+ height: auto;
1166
+ padding: 4px;
1167
+ line-height: 1.428571429;
1168
+ background-color: #ffffff;
1169
+ border: 1px solid #dddddd;
1170
+ border-radius: 4px;
1171
+ }
1172
+
1173
+ .gm-img-thumbnail img {
1174
+ height: auto;
1175
+ width: auto;
1176
+ max-width: 100%;
1177
+ max-height: 100%;
1178
+ display: inline-block;
1179
+ vertical-align: middle;
1180
+ }
1181
+
1182
+ #gmedia-edit-term .gm-img-thumbnail {
1183
+ text-align: center;
1184
+ margin: 0;
1185
+ }
1186
+
1187
+ #gmedia-edit-term .gm-img-thumbnail:empty {display: none;}
1188
+
1189
+ #gmedia-edit-term .gm-img-thumbnail img { max-height: 150px; }
1190
+
1191
+ .choose-module {
1192
+ padding: 10px;
1193
+ overflow: hidden;
1194
+ margin: 0;
1195
+ }
1196
+
1197
+ .no-touch .choose-module:hover {
1198
+ background-color: #d0e9c6;
1199
+ }
1200
+
1201
+ .choose-module .thumbnail {
1202
+ margin-bottom: 0;
1203
+ }
1204
+
1205
+ .media {
1206
+ overflow: hidden;
1207
+ }
1208
+
1209
+ .media > .thumbnail.pull-left {
1210
+ padding: 4px;
1211
+ margin-right: 10px
1212
+ }
1213
+
1214
+ #gmedia_modules .media {
1215
+ border-bottom: 1px solid #444444;
1216
+ padding-bottom: 15px;
1217
+ margin-bottom: 30px;
1218
+ }
1219
+
1220
+ #gmedia_modules .media:last-child {
1221
+ border-bottom: none;
1222
+ padding-bottom: 0;
1223
+ margin-bottom: 0;
1224
+ }
1225
+
1226
+ #gmedia_modules .buttons a.btn {
1227
+ margin-bottom: 7px;
1228
+ }
1229
+
1230
+ #chooseModuleModal .choose-module {
1231
+ border-bottom: 1px solid #444444;
1232
+ }
1233
+
1234
+ #chooseModuleModal .choose-module:last-child {
1235
+ border-bottom: none;
1236
+ }
1237
+
1238
+ .modules-body .media {
1239
+ display: none;
1240
+ }
1241
+
1242
+ .modules-body .module-filtered {
1243
+ display: block;
1244
+ }
1245
+
1246
+ .presetlist a { }
1247
+
1248
+ .gm-preset-id {
1249
+ font-size: smaller;
1250
+ float: right;
1251
+ padding: 0 15px 0 5px;
1252
+ }
1253
+
1254
+ .addpreset:hover,
1255
+ .addpreset:active,
1256
+ .addpreset {
1257
+ margin: 0 8px 0;
1258
+ line-height: 100%;
1259
+ text-decoration: none;
1260
+ outline: none;
1261
+ }
1262
+
1263
+ .addpreset span {
1264
+ line-height: 100%;
1265
+ font-size: 74%;
1266
+ padding: 0 5px 2px;
1267
+ cursor: pointer;
1268
+ }
1269
+
1270
+ .delpreset {
1271
+ position: absolute;
1272
+ right: 0;
1273
+ top: 0;
1274
+ bottom: 0;
1275
+ padding: 0.8em 7px 0;
1276
+ line-height: 100%;
1277
+ }
1278
+
1279
+ .delpreset span {
1280
+ line-height: 100%;
1281
+ font-size: 94%;
1282
+ padding: 0 5px 2px;
1283
+ cursor: pointer;
1284
+ }
1285
+
1286
+ body#media-upload {
1287
+ height: 100%;
1288
+ overflow: auto;
1289
+ margin: 0;
1290
+ padding: 0;
1291
+ background: #ffffff;
1292
+ }
1293
+
1294
+ body#media-upload .panel {
1295
+ position: relative;
1296
+ height: 100%;
1297
+ overflow: auto;
1298
+ margin: 0;
1299
+ border-radius: 0;
1300
+ border-top: none;
1301
+ }
1302
+
1303
+ body#media-upload .panel-heading {
1304
+ position: relative;
1305
+ z-index: 100;
1306
+ }
1307
+
1308
+ body#media-upload .panel-body {
1309
+ position: absolute;
1310
+ top: 55px;
1311
+ bottom: 0;
1312
+ width: 100%;
1313
+ overflow: hidden;
1314
+ z-index: 50;
1315
+ padding-top: 0;
1316
+ padding-bottom: 0;
1317
+ }
1318
+
1319
+ body#media-upload .panel-body > .row {
1320
+ height: 100%;
1321
+ }
1322
+
1323
+ body#media-upload .panel-body > .row > div {
1324
+ height: 100%;
1325
+ overflow: auto;
1326
+ padding-top: 15px;
1327
+ padding-bottom: 15px;
1328
+ }
1329
+
1330
+ body#media-upload .panel-body .list-group-item {
1331
+ border-width: 0;
1332
+ border-top-width: 1px;
1333
+ margin: 0;
1334
+ }
1335
+
1336
+ body#media-upload .panel-body .list-group-item:first-child {
1337
+ border-width: 0;
1338
+ }
1339
+
1340
+ body#media-upload .term-list-item .term-images img {
1341
+ height: 30px;
1342
+ }
1343
+
1344
+ body#media-upload .term-list-item .term-label .no-checkbox {
1345
+ display: inline-block;
1346
+ width: 100%;
1347
+ margin: 10px 0;
1348
+ }
1349
+
1350
+ body#media-upload .term-list-item .term-info {
1351
+ display: none;
1352
+ }
1353
+
1354
+ .blank-aligner {
1355
+ display: inline-block;
1356
+ height: 40px;
1357
+ vertical-align: middle;
1358
+ width: 1px;
1359
+ overflow: hidden;
1360
+ margin-right: -2em;
1361
+ }
1362
+
1363
+ body#media-upload .media-upload-sidebar {
1364
+ border-left: 1px solid #cccccc;
1365
+ background-color: #eeeeee;
1366
+ padding: 0 !important;
1367
+ position: relative;
1368
+ }
1369
+
1370
+ body#media-upload .media-upload-sidebar form {
1371
+ display: -webkit-box;
1372
+ display: -moz-box;
1373
+ display: -ms-flexbox;
1374
+ display: -webkit-flex;
1375
+ display: flex;
1376
+ -webkit-flex-direction: column;
1377
+ -moz-flex-direction: column;
1378
+ -ms-flex-direction: column;
1379
+ flex-direction: column;
1380
+ height: 100%;
1381
+ width: 100%;
1382
+ }
1383
+
1384
+ body#media-upload .media-upload-sidebar .media-upload-form-container {
1385
+ -webkit-box-flex: 1 auto;
1386
+ -moz-box-flex: 1 auto;
1387
+ -webkit-flex: 1 auto;
1388
+ -ms-flex: 1 auto;
1389
+ flex: 1 auto;
1390
+ overflow: auto;
1391
+ padding: 15px;
1392
+ }
1393
+
1394
+ body#media-upload .media-upload-sidebar .panel-footer {
1395
+ min-height: 57px;
1396
+ }
1397
+
1398
+ body#media-upload .thumbnail {
1399
+ margin: 0 5px 5px 0;
1400
+ position: relative;
1401
+ display: inline-block;
1402
+ }
1403
+
1404
+ body#media-upload .thumbnail.active {
1405
+ background-color: lightblue;
1406
+ border-color: cadetblue;
1407
+ }
1408
+
1409
+ body#media-upload .thumbnail .glyphicon {
1410
+ display: none;
1411
+ position: absolute;
1412
+ right: -3px;
1413
+ top: -7px;
1414
+ font-size: 30px;
1415
+ }
1416
+
1417
+ body#media-upload .thumbnail.active .glyphicon {
1418
+ display: inline-block;
1419
+ }
1420
+
1421
+ body#media-upload .plupload_wrapper {
1422
+ height: 100%;
1423
+ box-sizing: border-box;
1424
+ overflow: hidden;
1425
+ }
1426
+
1427
+ .addtags-gap { height: 200px; }
1428
+
1429
+ body#media-upload div#pluploadUploader .plupload_container {
1430
+ height: 100%;
1431
+ min-height: inherit !important;
1432
+ }
1433
+
1434
+ body#media-upload .ui-resizable-handle {
1435
+ display: none !important;
1436
+ bottom: -1px;
1437
+ }
1438
+
1439
+ #gmedia-post-thumbnail {
1440
+ font-size: 12px;
1441
+ padding: 0;
1442
+ display: inline;
1443
+ white-space: normal;
1444
+ }
1445
+
1446
+ body.gmedia-blank.gmedia_image_editor {
1447
+ height: 100%;
1448
+ overflow: auto;
1449
+ margin: 0;
1450
+ padding: 0
1451
+ }
1452
+
1453
+ body.gmedia-blank.gmedia_image_editor .panel,
1454
+ body.gmedia-blank.gmedia_map_editor .panel {
1455
+ position: relative;
1456
+ height: 100%;
1457
+ overflow: auto;
1458
+ margin: 0;
1459
+ }
1460
+
1461
+ body.gmedia-blank .panel-heading {
1462
+ position: relative;
1463
+ z-index: 100;
1464
+ }
1465
+
1466
+ body.gmedia-blank.gmedia_image_editor .panel-body {
1467
+ position: absolute;
1468
+ top: 55px;
1469
+ bottom: 0;
1470
+ width: 100%;
1471
+ overflow: hidden;
1472
+ z-index: 50;
1473
+ padding-top: 0;
1474
+ padding-bottom: 0;
1475
+ }
1476
+
1477
+ body.gmedia-blank.gmedia_image_editor .panel-body .row {
1478
+ height: 100%;
1479
+ }
1480
+
1481
+ body.gmedia-blank.gmedia_image_editor .panel-body .row > div {
1482
+ height: 100%;
1483
+ overflow: auto;
1484
+ padding-top: 15px;
1485
+ padding-bottom: 15px;
1486
+ }
1487
+
1488
+ body.gmedia-blank .media-edit-sidebar {
1489
+ border-left: 1px solid #cccccc;
1490
+ background-color: #eeeeee;
1491
+ padding: 0 0 55px 0 !important;
1492
+ position: relative;
1493
+ }
1494
+
1495
+ body.gmedia-blank #media-edit-form-container {
1496
+ height: 100%;
1497
+ overflow: auto;
1498
+ padding: 15px;
1499
+ }
1500
+
1501
+ body.gmedia-blank .media-edit-sidebar .panel-footer {
1502
+ position: absolute;
1503
+ left: 0;
1504
+ bottom: 0;
1505
+ right: 0;
1506
+ }
1507
+
1508
+ body.gmedia_library .panel {
1509
+ margin-bottom: 0;
1510
+ }
1511
+
1512
+ #map-floating-panel {
1513
+ position: absolute;
1514
+ top: 15px;
1515
+ right: 15px;
1516
+ z-index: 5;
1517
+ background-color: #ffffff;
1518
+ padding: 0 0 5px 5px;
1519
+ width: 250px;
1520
+ }
1521
+
1522
+ #save_buttons_duplicate { display: none;}
1523
+
1524
+ .panel-floatingHeader #save_buttons_duplicate { display: block;}
1525
+
1526
+ #gallery_preview_ {
1527
+ width: 200%;
1528
+ height: 800px;
1529
+ margin-bottom: -400px;
1530
+ overflow: auto;
1531
+ -moz-transform: scale(0.5, 0.5) translateZ(0);
1532
+ -webkit-transform: scale(0.5, 0.5) translateZ(0);
1533
+ -o-transform: scale(0.5, 0.5) translateZ(0);
1534
+ -ms-transform: scale(0.5, 0.5) translateZ(0);
1535
+ transform: scale(0.5, 0.5) translateZ(0);
1536
+ -moz-transform-origin: top left;
1537
+ -webkit-transform-origin: top left;
1538
+ -o-transform-origin: top left;
1539
+ -ms-transform-origin: top left;
1540
+ transform-origin: top left;
1541
+ border: solid #cccccc 2px;
1542
+ }
1543
+
1544
+ .gallery_preview {
1545
+ padding: 0 5px 5px 0;
1546
+ border-right: 1px dotted;
1547
+ border-bottom: 1px dotted;
1548
+ background-color: #eee;
1549
+ width: 100%;
1550
+ height: 600px;
1551
+ }
1552
+
1553
+ #gallery_preview {
1554
+ width: 100%;
1555
+ height: 100%;
1556
+ border: solid #cccccc 1px;
1557
+ overflow: auto;
1558
+ }
1559
+
1560
+ #adv-settings {
1561
+ overflow: hidden;
1562
+ }
1563
+
1564
+ #screen-meta .form-group {
1565
+ padding-bottom: 10px;
1566
+ }
1567
+
1568
+ #previewModal {
1569
+ z-index: 9999;
1570
+ overflow-x: auto;
1571
+ }
1572
+
1573
+ #previewModal .modal-header .btn-primary {display: none;}
1574
+
1575
+ #previewModal .select_gmedia .modal-header .btn-primary {display: inline-block;}
1576
+
1577
+ #previewModal .select_gmedia_image .modal-header .btn-primary {display: inline-block;}
1578
+
1579
+ #previewModal .select_gmedia_related .modal-header .btn-primary {display: inline-block;}
1580
+
1581
+ .edit_gmedia_item .modal-header {display: none;}
1582
+
1583
+ .edit_gmedia_item .modal-body {padding: 0;}
1584
+
1585
+ .edit_gmedia_item iframe {max-height: calc(100vh - 110px);}
1586
+
1587
+ .select_gmedia .modal-body,
1588
+ .select_gmedia_related .modal-body,
1589
+ .select_gmedia_image .modal-body {padding: 0;}
1590
+
1591
+ .select_gmedia iframe,
1592
+ .select_gmedia_related iframe,
1593
+ .select_gmedia_image iframe {max-height: calc(100vh - 160px);}
1594
+
1595
+ .no-transition {transition: none !important; -webkit-transition: none !important;}
1596
+
1597
+ .checked_thumb {margin-top: -7px;text-align: center;}
1598
+
1599
+ .checked_thumb img {max-height: 55px;width: auto;height: auto;}
1600
+
1601
+ input.sharelink[readonly] { cursor: text; }
1602
+
1603
+ fieldset.gmediacustomstuff { margin: 0 0 10px; padding: .35em .625em .4em; position: relative; border: 1px solid silver }
1604
+
1605
+ .delete-custom-field { margin: 4px 2px 0; cursor: pointer; }
1606
+
1607
+ .newcustomfield-modal { position: absolute; bottom: -0.6em; right: 8px; font-size: 100%; }
1608
+
1609
+ .gmapp-description, .gmapp-description p {font-size: 15px;}
1610
+
1611
+ div#wp-link-wrap {
1612
+ box-sizing: border-box;
1613
+ }
1614
+
1615
+ div#wp-link-wrap label {
1616
+ font-weight: normal;
1617
+ display: block;
1618
+ margin: 0;
1619
+ }
1620
+
1621
+ .input-group.gmedia_date input {
1622
+ background: #ffffff;
1623
+ }
1624
+
1625
+ @media (min-width: 782px) {
1626
+ div.modal {
1627
+ top: 32px;
1628
+ }
1629
+
1630
+ body.gmedia-blank div.modal {
1631
+ top: 0;
1632
+ }
1633
+
1634
+ div#termsModal .modal-dialog {
1635
+ width: 350px;
1636
+ }
1637
+
1638
+ }
1639
+
1640
+ @media (max-width: 600px) {
1641
+ .panel-floatingHeader .panel-heading,
1642
+ .panel-absoluteHeader .panel-heading {
1643
+ position: static;
1644
+ box-shadow: none;
1645
+ }
1646
+
1647
+ .panel-floatingHeader .panel-heading-fake, .panel-absoluteHeader .panel-heading-fake {
1648
+ display: none;
1649
+ }
1650
+ }
1651
+
1652
+ @media (max-width: 782px) {
1653
+ .panel-floatingHeader .panel-heading {
1654
+ top: 46px;
1655
+ }
1656
+
1657
+ div#wpwrap {
1658
+ background: #708090;
1659
+ }
1660
+
1661
+ div#wpbody select.input-sm {
1662
+ height: 30px;
1663
+ font-size: 12px;
1664
+ }
1665
+
1666
+ #adminmenu #toplevel_page_GrandMedia ul.wp-submenu {
1667
+ display: block;
1668
+ }
1669
+
1670
+ .media-body { display: block; }
1671
+
1672
+ .show-settings-link { display: none; }
1673
+ }
1674
+
1675
+ @media (max-width: 991px) {
1676
+ body#media-upload .panel-body > #gmUpload.row {
1677
+ overflow-y: auto;
1678
+ }
1679
+
1680
+ body#media-upload .panel-body > #gmUpload.row > div {
1681
+ height: auto;
1682
+ }
1683
+
1684
+ body#media-upload .plupload_wrapper {
1685
+ height: auto;
1686
+ }
1687
+
1688
+ body#media-upload div#pluploadUploader .plupload_container {
1689
+ height: auto;
1690
+ min-height: 300px !important;
1691
+ }
1692
+ }
1693
+
1694
+ /*@-moz-document url-prefix() {
1695
+ a.btn, span.btn {
1696
+ line-height:1.56;
1697
+ }
1698
+ }*/
1699
+
1700
+ /* custom inclusion of right, left tabs */
1701
+ .tabs-right > .nav-tabs,
1702
+ .tabs-left > .nav-tabs {
1703
+ border-bottom: 0;
1704
+ }
1705
+
1706
+ .gm-tab-content > .tab-pane,
1707
+ .pill-content > .pill-pane {
1708
+ display: none;
1709
+ }
1710
+
1711
+ .gm-tab-content > .active,
1712
+ .pill-content > .active {
1713
+ display: block;
1714
+ }
1715
+
1716
+ .tabs-left > .nav-tabs > li,
1717
+ .tabs-right > .nav-tabs > li {
1718
+ float: none;
1719
+ }
1720
+
1721
+ .tabs-left > .nav-tabs > li > a,
1722
+ .tabs-right > .nav-tabs > li > a {
1723
+ min-width: 74px;
1724
+ margin-right: 0;
1725
+ margin-bottom: 3px;
1726
+ }
1727
+
1728
+ .tabs-left > .nav-tabs {
1729
+ float: left;
1730
+ margin-right: 19px;
1731
+ border-right: 1px solid #dddddd;
1732
+ }
1733
+
1734
+ .tabs-left > .nav-tabs > li > a {
1735
+ margin-right: -1px;
1736
+ -webkit-border-radius: 4px 0 0 4px;
1737
+ -moz-border-radius: 4px 0 0 4px;
1738
+ border-radius: 4px 0 0 4px;
1739
+ }
1740
+
1741
+ .no-touch .tabs-left > .nav-tabs > li > a:hover,
1742
+ .tabs-left > .nav-tabs > li > a:focus {
1743
+ border-color: #eeeeee #dddddd #eeeeee #eeeeee;
1744
+ }
1745
+
1746
+ .tabs-left > .nav-tabs .active > a,
1747
+ .no-touch .tabs-left > .nav-tabs .active > a:hover,
1748
+ .tabs-left > .nav-tabs .active > a:focus {
1749
+ border-color: #dddddd transparent #dddddd #dddddd;
1750
+ *border-right-color: #ffffff;
1751
+ }
1752
+
1753
+ .tabs-right > .nav-tabs {
1754
+ float: right;
1755
+ margin-left: 19px;
1756
+ border-left: 1px solid #dddddd;
1757
+ }
1758
+
1759
+ .tabs-right > .nav-tabs > li > a {
1760
+ margin-left: -1px;
1761
+ -webkit-border-radius: 0 4px 4px 0;
1762
+ -moz-border-radius: 0 4px 4px 0;
1763
+ border-radius: 0 4px 4px 0;
1764
+ }
1765
+
1766
+ .no-touch .tabs-right > .nav-tabs > li > a:hover,
1767
+ .tabs-right > .nav-tabs > li > a:focus {
1768
+ border-color: #eeeeee #eeeeee #eeeeee #dddddd;
1769
+ }
1770
+
1771
+ .tabs-right > .nav-tabs .active > a,
1772
+ .no-touch .tabs-right > .nav-tabs .active > a:hover,
1773
+ .tabs-right > .nav-tabs .active > a:focus {
1774
+ border-color: #dddddd #dddddd #dddddd transparent;
1775
+ *border-left-color: #ffffff;
1776
+ }
1777
+
1778
+ /* custom badge colors */
1779
+ .badge-error {background-color: #b94a48 !important; color: #fff !important;}
1780
+
1781
+ .badge-error:hover {background-color: #953b39 !important; color: #fff !important;}
1782
+
1783
+ .badge-warning {background-color: #f89406;}
1784
+
1785
+ .badge-warning:hover {background-color: #c67605;}
1786
+
1787
+ .badge-success {background-color: #468847 !important; color: #fff !important;}
1788
+
1789
+ .badge-success:hover {background-color: #356635 !important; color: #fff !important;}
1790
+
1791
+ .badge-info {background-color: #3a87ad;}
1792
+
1793
+ .badge-info:hover {background-color: #2d6987;}
1794
+
1795
+ .badge-inverse {background-color: #333333;}
1796
+
1797
+ .badge-inverse:hover {background-color: #1a1a1a;}
1798
+
1799
+ /* custom *-xs size for form elements */
1800
+ input[type="date"].input-xs,
1801
+ input[type="time"].input-xs,
1802
+ input[type="datetime-local"].input-xs,
1803
+ input[type="month"].input-xs,
1804
+ .input-group-xs input[type="date"],
1805
+ .input-group-xs input[type="time"],
1806
+ .input-group-xs input[type="datetime-local"],
1807
+ .input-group-xs input[type="month"] {
1808
+ line-height: 22px;
1809
+ }
1810
+
1811
+ .form-control-static.input-xs {
1812
+ padding-right: 0;
1813
+ padding-left: 0;
1814
+ }
1815
+
1816
+ .input-xs {
1817
+ height: 22px;
1818
+ padding: 1px 5px !important;
1819
+ font-size: 12px;
1820
+ line-height: 1.5;
1821
+ border-radius: 3px;
1822
+ }
1823
+
1824
+ select.input-xs {
1825
+ height: 22px;
1826
+ line-height: 22px;
1827
+ }
1828
+
1829
+ textarea.input-xs,
1830
+ select[multiple].input-xs {
1831
+ height: auto;
1832
+ }
1833
+
1834
+ .form-group-xs .form-control {
1835
+ height: 22px;
1836
+ padding: 1px 5px;
1837
+ font-size: 12px;
1838
+ line-height: 1.5;
1839
+ border-radius: 3px;
1840
+ }
1841
+
1842
+ select.form-group-xs .form-control {
1843
+ height: 22px;
1844
+ line-height: 22px;
1845
+ }
1846
+
1847
+ textarea.form-group-xs .form-control,
1848
+ select[multiple].form-group-xs .form-control {
1849
+ height: auto;
1850
+ }
1851
+
1852
+ .form-group-xs .form-control-static {
1853
+ height: 22px;
1854
+ min-height: 25px;
1855
+ padding: 1px 5px;
1856
+ font-size: 12px;
1857
+ line-height: 1.5;
1858
+ }
1859
+
1860
+ .input-xs + .form-control-feedback {
1861
+ width: 22px;
1862
+ height: 22px;
1863
+ line-height: 22px;
1864
+ }
1865
+
1866
+ @media (min-width: 768px) {
1867
+ .form-horizontal .form-group-xs .control-label {
1868
+ padding-top: 4px;
1869
+ }
1870
+ }
1871
+
1872
+ .input-group-xs > .form-control,
1873
+ .input-group-xs > .input-group-addon,
1874
+ .input-group-xs > .input-group-btn > .btn {
1875
+ height: 22px;
1876
+ padding: 1px 5px;
1877
+ font-size: 12px;
1878
+ line-height: 1.5;
1879
+ border-radius: 3px;
1880
+ }
1881
+
1882
+ select.input-group-xs > .form-control,
1883
+ select.input-group-xs > .input-group-addon,
1884
+ select.input-group-xs > .input-group-btn > .btn {
1885
+ height: 22px;
1886
+ line-height: 22px;
1887
+ }
1888
+
1889
+ textarea.input-group-xs > .form-control,
1890
+ textarea.input-group-xs > .input-group-addon,
1891
+ textarea.input-group-xs > .input-group-btn > .btn,
1892
+ select[multiple].input-group-xs > .form-control,
1893
+ select[multiple].input-group-xs > .input-group-addon,
1894
+ select[multiple].input-group-xs > .input-group-btn > .btn {
1895
+ height: auto;
1896
+ }
1897
+
1898
+ .input-group-addon.input-xs {
1899
+ padding: 1px 5px;
1900
+ font-size: 12px;
1901
+ border-radius: 3px;
1902
+ }
1903
+
1904
+ .input-group .form-control:first-child,
1905
+ .input-group-addon:first-child,
1906
+ .input-group-btn:first-child > .btn,
1907
+ .input-group-btn:first-child > .btn-group > .btn,
1908
+ .input-group-btn:first-child > .dropdown-toggle,
1909
+ .input-group-btn:last-child > .btn-group:not(:last-child) > .btn,
1910
+ .input-group-btn:last-child > .btn:not(:last-child):not(.dropdown-toggle) {
1911
+ border-bottom-right-radius: 0;
1912
+ border-top-right-radius: 0;
1913
+ }
1914
+
1915
+ .input-group .form-control:last-child,
1916
+ .input-group-addon:last-child,
1917
+ .input-group-btn:first-child > .btn-group:not(:first-child) > .btn,
1918
+ .input-group-btn:first-child > .btn:not(:first-child),
1919
+ .input-group-btn:last-child > .btn,
1920
+ .input-group-btn:last-child > .btn-group > .btn,
1921
+ .input-group-btn:last-child > .dropdown-toggle {
1922
+ border-bottom-left-radius: 0;
1923
+ border-top-left-radius: 0;
1924
+ }
1925
+
1926
+ .input-group-addon.btn-primary {
1927
+ color: #fff;
1928
+ background-color: #337ab7;
1929
+ border-color: #2e6da4;
1930
+ cursor: pointer;
1931
+ }
1932
+
1933
+ .notice.updated.gm-message {
1934
+ margin-left: 0;
1935
+ margin-bottom: 30px;
1936
+ /* clear: both; */
1937
+ max-width: 800px;
1938
+ }
1939
+
1940
+ .gm-plugin-icon {
1941
+ float: left;
1942
+ margin-right: 15px;
1943
+ }
1944
+
1945
+ .gm-message-content * {
1946
+ font-size: 14px;
1947
+ }
1948
+
1949
+ .gm-message-actions {
1950
+ background-color: #e6eef1;
1951
+ padding: 10px 12px;
1952
+ margin: 0 -12px;
1953
+ text-align: right;
1954
+ }
1955
+
1956
+ .gm-message-actions button {
1957
+ margin-left: 20px !important;
1958
+ }
1959
+
1960
+ .gm-message-plus.gm-closed ul {
1961
+ display: none;
1962
+ }
1963
+
1964
+ .gm-message-plus {
1965
+ text-align: center;
1966
+ padding: 4px 0;
1967
+ }
1968
+
1969
+ .gm-message-plus.gm-opened ul {
1970
+ display: block;
1971
+ text-align: left;
1972
+ margin: 20px 20px 10px 20px;
1973
+ }
1974
+
1975
+ .gm-message-plus ul li {
1976
+ margin-bottom: 12px;
1977
+ }
1978
+
1979
+ .gm-message-plus ul li i.dashicons {
1980
+ float: left;
1981
+ font-size: 40px;
1982
+ width: 40px;
1983
+ height: 40px;
1984
+ }
1985
+
1986
+ .gm-message-plus ul li div {
1987
+ margin-left: 55px;
1988
+ }
1989
+
1990
+ .gm-message-plus ul li div span {
1991
+ font-weight: bold;
1992
+ text-transform: uppercase;
1993
+ color: #23282d;
1994
+ }
1995
+
1996
+ .gm-message-plus ul li div p {
1997
+ margin: 2px 0 0 0
1998
+ }
1999
+
2000
+ .gm-module-count-0 {
2001
+ display: none;
2002
+ }
2003
+
2004
+ /* Spectrum */
2005
+ .form-group .sp-replacer {
2006
+ width: 100%;
2007
+ border-radius: 3px;
2008
+ }
2009
+
2010
+ .form-group .sp-preview {
2011
+ width: calc(100% - 18px);
2012
+ border-radius: 3px;
2013
+ }
admin/assets/css/gmedia.metabox.css CHANGED
@@ -1,55 +1,60 @@
1
- @charset "utf-8";
2
- .inside #gmedia-wraper { box-sizing:border-box; }
3
- .inside #gmedia-wraper .form-group { padding:7px 0; }
4
- .inside #gmedia-wraper .form-group label { display:block; font-weight:bold; margin-bottom:4px; }
5
- .inside #gmedia-wraper .form-group input { display:block; width:100%; }
6
- .inside #gmedia-wraper .form-group select { display:block; width:100%; }
7
- /*
8
- div#gmedia-MetaBox .inside { margin:0; padding:0; }
9
- div#gmedia-wraper { background:#f9f9f9; position:relative; border:1px solid #cccccc; border-bottom-color:#2e6286; border-radius:0 0 4px 4px; box-sizing:border-box; }
10
- div#gmedia-MetaBox div#gmedia-wraper { min-width:100%; max-width:100%; }
11
- body > div#gmedia-wraper { box-shadow:0 2px 3px #222222; }
12
- body > div#gmedia-wraper:before { content:''; position:absolute; z-index:-1; left:20px; top:20px; width:100%; height:100%; }
13
- div#gmedia-wraper div#gmedia-source, div#gmedia-wraper div#gmedia-source .pane { border-radius:0 0 4px 4px; }
14
- div#gmedia-wraper * { margin:0; padding:0; font-size:11px; line-height:15px; text-decoration:none; }
15
- div#gmedia-message { background:#a1a1a1 url(../img/metabox.png) 0 -25px; position:relative; z-index:20; border-bottom:1px solid #cccccc; padding:0 6px 0 8px; }
16
- div#gmedia-message span { display:block; }
17
- div#gmedia-message .info-init { color:blue; }
18
- div#gmedia-message .info-textarea { color:red; }
19
- #gmedia-source .title-bar .gm-add-button { position:absolute; display:block; right:5px; top:5px; line-height:100%; height:auto; padding:2px 4px; }
20
- div#gmedia-wraper.ui-draggable .title-bar { cursor:move; }
21
- div#gmedia-galleries { height:227px; position:relative; z-index:1; background:#f9f9f9; border-radius:0 0 4px 4px; }
22
- div#gmedia-galleries .title-bar { position:relative; padding:0 7px; background:#a1a1a1 url(../img/metabox.png) repeat-x 0 -25px; text-shadow:0 1px 0 rgba(255, 255, 255, 0.4); height:25px; line-height:27px; border-top:1px solid rgba(250, 250, 250, 0.8); border-bottom:1px solid rgba(24, 24, 24, 0.2); }
23
- div#gmedia-galleries .title-bar span.gmedia-galleries-title { position:relative; display:block; margin-top:7px; }
24
- div#gmedia-galleries div#gmedia-galleries-wrap { box-shadow:0 0 6px #999999 inset; overflow:hidden; overflow-y:scroll; position:absolute; left:0; top:27px; bottom:35px; right:0; z-index:1; }
25
- div#gmedia-galleries ul#gmedia-galleries-list { padding:5px 0 0; }
26
- div#gmedia-galleries ul#gmedia-galleries-list .emptydb { font-size:120%; line-height:40px; text-align:center; }
27
- div#gmedia-galleries ul#gmedia-galleries-list .emptydb a { font-size:100%; }
28
- div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li { margin:0 6px 5px; padding:2px; border:1px solid #bbbbbb; position:relative; background:#ffffff; border-radius:3px; box-shadow:0 0 4px #cccccc; transition-property:border-color; transition-duration:.33s; height:38px; }
29
- div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li.gmedia-selected { border:1px solid #f18f00; transition-property:border-color; transition-duration:.33s; }
30
- div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li p.gmedia-gallery-title { padding-right:6px; display:block; overflow:hidden; }
31
- div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li p.gmedia-gallery-title span { display:inline-block; vertical-align:top; margin-right:7px; white-space:nowrap; }
32
- div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li p.gmedia-gallery-title span.gmedia-gallery-preview { line-height:0; height:43px; overflow:hidden; }
33
- div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li p.gmedia-gallery-title span.gmedia-gallery-preview img { width:50px; height:auto; }
34
- div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li p.gmedia-gallery-source { position:absolute; left:59px; bottom:5px; right:1px; z-index:1; }
35
- div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li p.gmedia-gallery-source span.gmedia-gallery-module { color:#999999; position:absolute; left:0; bottom:0; font-size:9px; height:12px; }
36
- div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li .gmedia-gallery-gear { color:#666666; display:block; overflow:hidden; font-size:9px; z-index:4; text-indent:-100em; cursor:pointer; position:absolute; right:0; top:1px; width:16px; height:16px; background:url(../img/metabox.png) 0 -258px no-repeat; }
37
- div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li .gmedia-selector { z-index:2; position:absolute; left:0; top:0; width:100%; height:100%; display:none; background:url(../img/clicked.png) 100% 0 no-repeat; }
38
- div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li.gmedia-selected .gmedia-selector { display:block; }
39
- div#gmedia-galleries ul#gmedia-galleries-list li.gmedia-gallery-li:hover { border-color:#777777; }
40
- div#gmedia-galleries ul#gmedia-galleries-list li.gmedia-gallery-li.gmedia-selected:hover { border-color:#f18f00; }
41
- div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li .gmedia-insert { z-index:2; position:absolute; left:0; top:0; width:100%; height:100%; visibility:hidden; }
42
- div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li .gmedia-insert:after { content:''; z-index:2; position:absolute; left:0; top:0; width:100%; height:100%; }
43
- div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li:hover .gmedia-insert { visibility:visible; }
44
- div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li .gmedia-insert div { position:absolute; left:0; top:0; right:0; bottom:0; text-align:center; font:bold 15px Arial; color:#ffffff; text-shadow:0 0 8px #000000; line-height:100%; vertical-align:middle; background:rgba(0, 0, 0, 0.2); filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr='#4c000000', endColorstr='#4c000000'); }
45
- div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li .gmedia-insert div img { height:50%; width:1px; vertical-align:bottom; }
46
- div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li .gmedia-insert div.gmedia-insert-button { display:block; }
47
- div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li .gmedia-insert div.gmedia-remove-button { display:none; }
48
- div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li.gmedia-selected .gmedia-insert div.gmedia-insert-button { display:none; }
49
- div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li.gmedia-selected .gmedia-insert div.gmedia-remove-button { display:block; }
50
- div#gmedia-galleries .ui-resizable-s { left:0; bottom:0; height:10px; width:100%; background:#2e6286 url(../img/social-footer.png) 50% -243px no-repeat; border-radius:0 0 2px 2px; box-shadow:2px 0 0 #2e6286; margin-left:-1px; }
51
- #gmedia-wraper #gmedia-social { z-index:3; background:#2e6286; padding:5px 0; position:absolute; bottom:10px; width:100%; box-shadow:2px 0 0 #2e6286; margin-left:-1px; }
52
- #gmedia-wraper #gmedia-social p { padding:0 0 0 19px; margin:0 auto; font-size:11px; color:#ffffff; font-weight:bold; width:176px; background:transparent url(../img/social-footer.png) -7px -196px no-repeat; }
53
- #gmedia-wraper #gmedia-social p a { color:#ffffff; text-decoration:none; }
54
- .ui-dialog.gmedia-tool-dialog .ui-dialog-content { overflow:hidden !important; }
55
- */
 
 
 
 
 
1
+ @charset "utf-8";
2
+ .inside #gmedia-wraper { box-sizing: border-box; }
3
+
4
+ .inside #gmedia-wraper .form-group { padding: 7px 0; }
5
+
6
+ .inside #gmedia-wraper .form-group label { display: block; font-weight: bold; margin-bottom: 4px; }
7
+
8
+ .inside #gmedia-wraper .form-group input { display: block; width: 100%; }
9
+
10
+ .inside #gmedia-wraper .form-group select { display: block; width: 100%; }
11
+
12
+ /*
13
+ div#gmedia-MetaBox .inside { margin:0; padding:0; }
14
+ div#gmedia-wraper { background:#f9f9f9; position:relative; border:1px solid #cccccc; border-bottom-color:#2e6286; border-radius:0 0 4px 4px; box-sizing:border-box; }
15
+ div#gmedia-MetaBox div#gmedia-wraper { min-width:100%; max-width:100%; }
16
+ body > div#gmedia-wraper { box-shadow:0 2px 3px #222222; }
17
+ body > div#gmedia-wraper:before { content:''; position:absolute; z-index:-1; left:20px; top:20px; width:100%; height:100%; }
18
+ div#gmedia-wraper div#gmedia-source, div#gmedia-wraper div#gmedia-source .pane { border-radius:0 0 4px 4px; }
19
+ div#gmedia-wraper * { margin:0; padding:0; font-size:11px; line-height:15px; text-decoration:none; }
20
+ div#gmedia-message { background:#a1a1a1 url(../img/metabox.png) 0 -25px; position:relative; z-index:20; border-bottom:1px solid #cccccc; padding:0 6px 0 8px; }
21
+ div#gmedia-message span { display:block; }
22
+ div#gmedia-message .info-init { color:blue; }
23
+ div#gmedia-message .info-textarea { color:red; }
24
+ #gmedia-source .title-bar .gm-add-button { position:absolute; display:block; right:5px; top:5px; line-height:100%; height:auto; padding:2px 4px; }
25
+ div#gmedia-wraper.ui-draggable .title-bar { cursor:move; }
26
+ div#gmedia-galleries { height:227px; position:relative; z-index:1; background:#f9f9f9; border-radius:0 0 4px 4px; }
27
+ div#gmedia-galleries .title-bar { position:relative; padding:0 7px; background:#a1a1a1 url(../img/metabox.png) repeat-x 0 -25px; text-shadow:0 1px 0 rgba(255, 255, 255, 0.4); height:25px; line-height:27px; border-top:1px solid rgba(250, 250, 250, 0.8); border-bottom:1px solid rgba(24, 24, 24, 0.2); }
28
+ div#gmedia-galleries .title-bar span.gmedia-galleries-title { position:relative; display:block; margin-top:7px; }
29
+ div#gmedia-galleries div#gmedia-galleries-wrap { box-shadow:0 0 6px #999999 inset; overflow:hidden; overflow-y:scroll; position:absolute; left:0; top:27px; bottom:35px; right:0; z-index:1; }
30
+ div#gmedia-galleries ul#gmedia-galleries-list { padding:5px 0 0; }
31
+ div#gmedia-galleries ul#gmedia-galleries-list .emptydb { font-size:120%; line-height:40px; text-align:center; }
32
+ div#gmedia-galleries ul#gmedia-galleries-list .emptydb a { font-size:100%; }
33
+ div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li { margin:0 6px 5px; padding:2px; border:1px solid #bbbbbb; position:relative; background:#ffffff; border-radius:3px; box-shadow:0 0 4px #cccccc; transition-property:border-color; transition-duration:.33s; height:38px; }
34
+ div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li.gmedia-selected { border:1px solid #f18f00; transition-property:border-color; transition-duration:.33s; }
35
+ div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li p.gmedia-gallery-title { padding-right:6px; display:block; overflow:hidden; }
36
+ div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li p.gmedia-gallery-title span { display:inline-block; vertical-align:top; margin-right:7px; white-space:nowrap; }
37
+ div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li p.gmedia-gallery-title span.gmedia-gallery-preview { line-height:0; height:43px; overflow:hidden; }
38
+ div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li p.gmedia-gallery-title span.gmedia-gallery-preview img { width:50px; height:auto; }
39
+ div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li p.gmedia-gallery-source { position:absolute; left:59px; bottom:5px; right:1px; z-index:1; }
40
+ div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li p.gmedia-gallery-source span.gmedia-gallery-module { color:#999999; position:absolute; left:0; bottom:0; font-size:9px; height:12px; }
41
+ div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li .gmedia-gallery-gear { color:#666666; display:block; overflow:hidden; font-size:9px; z-index:4; text-indent:-100em; cursor:pointer; position:absolute; right:0; top:1px; width:16px; height:16px; background:url(../img/metabox.png) 0 -258px no-repeat; }
42
+ div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li .gmedia-selector { z-index:2; position:absolute; left:0; top:0; width:100%; height:100%; display:none; background:url(../img/clicked.png) 100% 0 no-repeat; }
43
+ div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li.gmedia-selected .gmedia-selector { display:block; }
44
+ div#gmedia-galleries ul#gmedia-galleries-list li.gmedia-gallery-li:hover { border-color:#777777; }
45
+ div#gmedia-galleries ul#gmedia-galleries-list li.gmedia-gallery-li.gmedia-selected:hover { border-color:#f18f00; }
46
+ div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li .gmedia-insert { z-index:2; position:absolute; left:0; top:0; width:100%; height:100%; visibility:hidden; }
47
+ div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li .gmedia-insert:after { content:''; z-index:2; position:absolute; left:0; top:0; width:100%; height:100%; }
48
+ div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li:hover .gmedia-insert { visibility:visible; }
49
+ div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li .gmedia-insert div { position:absolute; left:0; top:0; right:0; bottom:0; text-align:center; font:bold 15px Arial; color:#ffffff; text-shadow:0 0 8px #000000; line-height:100%; vertical-align:middle; background:rgba(0, 0, 0, 0.2); filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr='#4c000000', endColorstr='#4c000000'); }
50
+ div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li .gmedia-insert div img { height:50%; width:1px; vertical-align:bottom; }
51
+ div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li .gmedia-insert div.gmedia-insert-button { display:block; }
52
+ div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li .gmedia-insert div.gmedia-remove-button { display:none; }
53
+ div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li.gmedia-selected .gmedia-insert div.gmedia-insert-button { display:none; }
54
+ div#gmedia-galleries ul#gmedia-galleries-list .gmedia-gallery-li.gmedia-selected .gmedia-insert div.gmedia-remove-button { display:block; }
55
+ div#gmedia-galleries .ui-resizable-s { left:0; bottom:0; height:10px; width:100%; background:#2e6286 url(../img/social-footer.png) 50% -243px no-repeat; border-radius:0 0 2px 2px; box-shadow:2px 0 0 #2e6286; margin-left:-1px; }
56
+ #gmedia-wraper #gmedia-social { z-index:3; background:#2e6286; padding:5px 0; position:absolute; bottom:10px; width:100%; box-shadow:2px 0 0 #2e6286; margin-left:-1px; }
57
+ #gmedia-wraper #gmedia-social p { padding:0 0 0 19px; margin:0 auto; font-size:11px; color:#ffffff; font-weight:bold; width:176px; background:transparent url(../img/social-footer.png) -7px -196px no-repeat; }
58
+ #gmedia-wraper #gmedia-social p a { color:#ffffff; text-decoration:none; }
59
+ .ui-dialog.gmedia-tool-dialog .ui-dialog-content { overflow:hidden !important; }
60
+ */
admin/assets/img/woowbox-promote.png CHANGED
Binary file
admin/assets/js/gmedia-block.js CHANGED
@@ -1,42 +1,41 @@
1
  (function(blocks, element) {
2
- console
3
  var el = element.createElement,
4
  source = blocks.source,
5
  setCategories = blocks.setCategories,
6
  getCategories = blocks.getCategories,
7
  createBlock = blocks.createBlock;
8
-
9
- var icons={};
10
- var iconColor = '#316778'
11
  icons.iconAlbum = el(
12
- 'svg',
13
- { width: 24, height: 24, style:{fill:iconColor}, viewBox:'0 0 24 24'},
14
- el('path', { d:"M24,6c0-2.2-1.8-4-4-4H4C1.8,2,0,3.8,0,6v12c0,2.2,1.8,4,4,4h16c2.2,0,4-1.8,4-4V6z M6,6c1.1,0,2,0.9,2,2 c0,1.1-0.9,2-2,2S4,9.1,4,8C4,6.9,4.9,6,6,6z M22,18c0,1.1-0.9,2-2,2H4.4c-0.9,0-1.3-1.1-0.7-1.7l3.6-3.6c0.4-0.4,1-0.4,1.4,0 l0.6,0.6c0.4,0.4,1,0.4,1.4,0l6.6-6.6c0.4-0.4,1-0.4,1.4,0l3,3c0.2,0.2,0.3,0.4,0.3,0.7V18z"})
15
  );
16
  icons.iconGal = el(
17
- 'svg',
18
- { width: 24, height: 24, style:{fill:iconColor}, viewBox:'0 0 512 512'},
19
  [
20
- el('path', { d:"M464,128h-16v-16c0-26.51-21.49-48-48-48h-16V48c0-26.51-21.49-48-48-48H48C21.49,0,0,21.49,0,48v288 c0,26.51,21.49,48,48,48h16v16c0,26.51,21.49,48,48,48h16v16c0,26.51,21.49,48,48,48h288c26.51,0,48-21.49,48-48V176 C512,149.49,490.51,128,464,128z M32,265.44V48c0-8.837,7.163-16,16-16h288c8.837,0,16,7.163,16,16v153.44l-36.64-36.64 c-6.241-6.204-16.319-6.204-22.56,0L224,233.44l-68.64-68.8c-6.241-6.204-16.319-6.204-22.56,0L32,265.44z M112,416 c-8.837,0-16-7.163-16-16v-16h240c26.51,0,48-21.49,48-48V96h16c8.837,0,16,7.163,16,16v288c0,8.837-7.163,16-16,16H112z M480,464 c0,8.837-7.163,16-16,16H176c-8.837,0-16-7.163-16-16v-16h240c26.51,0,48-21.49,48-48V160h16c8.837,0,16,7.163,16,16V464z"}),
21
  ]
22
  );
23
  icons.iconCat = el(
24
- 'svg',
25
- { width: 24, height: 24, style:{fill:iconColor}, viewBox:'0 0 24 24'},
26
- el('path', { d:"M24,6c0-2.2-1.8-4-4-4H4C1.8,2,0,3.8,0,6v12c0,2.2,1.8,4,4,4h16c2.2,0,4-1.8,4-4V6z M6,6c1.1,0,2,0.9,2,2 c0,1.1-0.9,2-2,2S4,9.1,4,8C4,6.9,4.9,6,6,6z M22,18c0,1.1-0.9,2-2,2H4.4c-0.9,0-1.3-1.1-0.7-1.7l3.6-3.6c0.4-0.4,1-0.4,1.4,0 l0.6,0.6c0.4,0.4,1,0.4,1.4,0l6.6-6.6c0.4-0.4,1-0.4,1.4,0l3,3c0.2,0.2,0.3,0.4,0.3,0.7V18z"})
27
  );
28
  icons.iconTag = el(
29
- 'svg',
30
- { width: 24, height: 24, style:{fill:iconColor}, viewBox:'0 0 427 427'},
31
  [
32
- el('path', { d:"M414.08,204.373L222.187,12.48C214.4,4.8,203.733,0,192,0H42.667C19.093,0,0,19.093,0,42.667V192 c0,11.84,4.8,22.507,12.587,30.187l192,192c7.68,7.68,18.347,12.48,30.08,12.48s22.507-4.8,30.187-12.48l149.333-149.333 c7.68-7.787,12.48-18.453,12.48-30.187C426.667,222.827,421.867,212.16,414.08,204.373z M74.667,106.667 c-17.707,0-32-14.293-32-32s14.293-32,32-32s32,14.293,32,32S92.373,106.667,74.667,106.667z"}),
33
  ]
34
  );
35
- icons.attention=el(
36
- 'svg',
37
- { width: 34, height: 34, style:{fill:iconColor}, viewBox:'0 0 30 30'},
38
  [
39
- el('path', { d:"M15,3C8.373,3,3,8.373,3,15c0,6.627,5.373,12,12,12s12-5.373,12-12C27,8.373,21.627,3,15,3z M16.212,8l-0.2,9h-2.024l-0.2-9 H16.212z M15.003,22.189c-0.828,0-1.323-0.441-1.323-1.182c0-0.755,0.494-1.196,1.323-1.196c0.822,0,1.316,0.441,1.316,1.196 C16.319,21.748,15.825,22.189,15.003,22.189z"}),
40
  ]
41
  );
42
 
@@ -48,7 +47,7 @@
48
  var catt = [category];
49
  catt = catt.concat(getCategories());
50
  setCategories(catt);
51
-
52
  function GmediaGallery(atts) {
53
  var id = atts.id;
54
  var tagtext = '[gmedia id=' + id + ']';
@@ -66,10 +65,9 @@
66
  return el('div', {className: 'gmedia-shortcode'}, tagtext);
67
  }
68
 
69
-
70
  blocks.registerBlockType('gmedia/gallery', {
71
  title: 'Gmedia Gallery',
72
- icon: { src: icons.iconGal},
73
  description: 'Add Gmedia Gallery',
74
  keywords: [
75
  'gallery',
@@ -80,7 +78,7 @@
80
  'video',
81
  'audio',
82
  'mp3',
83
- 'lightbox',
84
  ],
85
  category: category.slug,
86
  attributes: {
@@ -88,27 +86,27 @@
88
  type: 'integer'
89
  }
90
  },
91
- transforms:{
92
  to: [
93
  {
94
  type: 'block',
95
- blocks: [ 'gmedia/album' ],
96
- transform: function(){
97
- return createBlock( 'gmedia/album', {})
98
  }
99
  },
100
  {
101
  type: 'block',
102
- blocks: [ 'gmedia/category' ],
103
- transform: function(){
104
- return createBlock( 'gmedia/category', {})
105
  }
106
  },
107
  {
108
  type: 'block',
109
- blocks: [ 'gmedia/tag' ],
110
- transform: function(){
111
- return createBlock( 'gmedia/tag', {})
112
  }
113
  }
114
  ]
@@ -141,14 +139,14 @@
141
  el('option', {value: gmedia_data.galleries[key].term_id}, gmedia_data.galleries[key].name)
142
  );
143
  });
144
- if(!id) {
145
  elclass += ' gmedia-required';
146
  }
147
  form_fields.push(
148
  el('select', {className: elclass, value: id, onChange: setGallery}, options)
149
  );
150
 
151
- if(id) {
152
  form_fields.push(GmediaGallery(props.attributes));
153
  }
154
 
@@ -156,16 +154,21 @@
156
  el('div', {className: 'form-fields'}, form_fields)
157
  );
158
 
159
- if(id) {
160
  var module = gmedia_data.galleries[id].module_name;
161
  image = (gmedia_data.modules[module] && gmedia_data.modules[module].screenshot)
162
- ?gmedia_data.modules[module].screenshot:undefined;
 
 
 
163
  }
164
- if(image){
165
- children.push( el('img', {className: 'gmedia-module-screenshot', src: image}));
166
- }else{
167
- children.push( el('div', {style:{width:'240px', height:'140px', color:'red', margin:'10px', padding:'15px', display:'flex',
168
- flexDirection: 'column', justifyContent: 'center', alignItems:'center', backgroundCcolor:'#fef8ee', textAlign: 'center'}}, [
 
 
169
  'This gallery is broken, select another!',
170
  icons.attention
171
  ]));
@@ -174,7 +177,7 @@
174
  },
175
 
176
  save: function(props) {
177
- if(typeof props.attributes.id == 'undefined') {
178
  return;
179
  }
180
  return GmediaGallery(props.attributes);
@@ -184,7 +187,7 @@
184
 
185
  blocks.registerBlockType('gmedia/album', {
186
  title: 'Gmedia Album',
187
- icon: { src: icons.iconAlbum},
188
  description: 'Add Gmedia Album',
189
  keywords: [
190
  'gallery',
@@ -204,33 +207,33 @@
204
  type: 'integer'
205
  },
206
  module_name: {
207
- type: 'string',
208
  },
209
  module_preset: {
210
- type: 'string',
211
  }
212
  },
213
- transforms:{
214
  to: [
215
  {
216
  type: 'block',
217
- blocks: [ 'gmedia/gallery' ],
218
- transform: function(){
219
- return createBlock( 'gmedia/gallery', {})
220
  }
221
  },
222
  {
223
  type: 'block',
224
- blocks: [ 'gmedia/category' ],
225
- transform: function(){
226
- return createBlock( 'gmedia/category', {})
227
  }
228
  },
229
  {
230
  type: 'block',
231
- blocks: [ 'gmedia/tag' ],
232
- transform: function(){
233
- return createBlock( 'gmedia/tag', {})
234
  }
235
  }
236
  ]
@@ -239,7 +242,7 @@
239
  edit: function(props) {
240
  var id = props.attributes.id;
241
  var module_name = props.attributes.module_name;
242
- var module = props.attributes.module_preset? props.attributes.module_preset : module_name;
243
  var default_module = gmedia_data.default_module;
244
  var elclass = 'gmedia-id';
245
  var image = gmedia_data.gmedia_image;
@@ -255,13 +258,14 @@
255
  var module = form.find('.gmedia-overwrite-module');
256
  var module_name = module.find('option:selected');
257
  var module_preset = '';
258
- if(module_name.attr('value')) {
259
  module_name = module_name.closest('optgroup').attr('module');
260
- if(module.val() != module_name){
261
  module_preset = module.val();
262
  }
263
- } else {
264
- module_name = ''
 
265
  }
266
  props.setAttributes({
267
  id: id,
@@ -280,7 +284,7 @@
280
  el('option', {value: gmedia_data.albums[key].term_id}, gmedia_data.albums[key].name)
281
  );
282
  });
283
- if(!id) {
284
  elclass += ' gmedia-required';
285
  }
286
  form_fields.push(
@@ -298,14 +302,14 @@
298
  );
299
  });
300
  modules.push(
301
- el('optgroup', {label: gmedia_data.modules_options[key].title, module: key}, null, options),
302
  );
303
  });
304
  form_fields.push(
305
  el('select', {className: 'gmedia-overwrite-module', value: module, onChange: setGallery}, modules)
306
  );
307
 
308
- if(id) {
309
  form_fields.push(GmediaTerm(props.attributes, 'album'));
310
  }
311
 
@@ -313,7 +317,7 @@
313
  el('div', {className: 'form-fields'}, form_fields)
314
  );
315
 
316
- if(id) {
317
  var term_module = gmedia_data.albums[id].module_name;
318
  image = module_name ? gmedia_data.modules[module_name].screenshot : (term_module ? gmedia_data.modules[term_module].screenshot : gmedia_data.modules[default_module].screenshot);
319
  }
@@ -325,7 +329,7 @@
325
  },
326
 
327
  save: function(props) {
328
- if(typeof props.attributes.id == 'undefined') {
329
  return;
330
  }
331
  return GmediaTerm(props.attributes, 'album');
@@ -335,7 +339,7 @@
335
 
336
  blocks.registerBlockType('gmedia/category', {
337
  title: 'Gmedia Category',
338
- icon: { src: icons.iconCat},
339
  description: 'Add Gmedia Category',
340
  keywords: [
341
  'gallery',
@@ -361,27 +365,27 @@
361
  type: 'string'
362
  }
363
  },
364
- transforms:{
365
  to: [
366
  {
367
  type: 'block',
368
- blocks: [ 'gmedia/album' ],
369
- transform: function(){
370
- return createBlock( 'gmedia/album', {})
371
  }
372
  },
373
  {
374
  type: 'block',
375
- blocks: [ 'gmedia/gallery' ],
376
- transform: function(){
377
- return createBlock( 'gmedia/gallery', {})
378
  }
379
  },
380
  {
381
  type: 'block',
382
- blocks: [ 'gmedia/tag' ],
383
- transform: function(){
384
- return createBlock( 'gmedia/tag', {})
385
  }
386
  }
387
  ]
@@ -390,7 +394,7 @@
390
  edit: function(props) {
391
  var id = props.attributes.id;
392
  var module_name = props.attributes.module_name;
393
- var module = props.attributes.module_preset? props.attributes.module_preset : module_name;
394
  var default_module = gmedia_data.default_module;
395
  var elclass = 'gmedia-id';
396
  var image = gmedia_data.gmedia_image;
@@ -406,13 +410,14 @@
406
  var module = form.find('.gmedia-overwrite-module');
407
  var module_name = module.find('option:selected');
408
  var module_preset = '';
409
- if(module_name.attr('value')) {
410
  module_name = module_name.closest('optgroup').attr('module');
411
- if(module.val() != module_name){
412
  module_preset = module.val();
413
  }
414
- } else {
415
- module_name = ''
 
416
  }
417
  props.setAttributes({
418
  id: id,
@@ -431,7 +436,7 @@
431
  el('option', {value: gmedia_data.categories[key].term_id}, gmedia_data.categories[key].name)
432
  );
433
  });
434
- if(!id) {
435
  elclass += ' gmedia-required';
436
  }
437
  form_fields.push(
@@ -449,14 +454,14 @@
449
  );
450
  });
451
  modules.push(
452
- el('optgroup', {label: gmedia_data.modules_options[key].title, module: key}, null, options),
453
  );
454
  });
455
  form_fields.push(
456
  el('select', {className: 'gmedia-overwrite-module', value: module, onChange: setGallery}, modules)
457
  );
458
 
459
- if(id) {
460
  form_fields.push(GmediaTerm(props.attributes, 'category'));
461
  }
462
 
@@ -464,7 +469,7 @@
464
  el('div', {className: 'form-fields'}, form_fields)
465
  );
466
 
467
- if(id) {
468
  var term_module = gmedia_data.categories[id].module_name;
469
  image = module_name ? gmedia_data.modules[module_name].screenshot : (term_module ? gmedia_data.modules[term_module].screenshot : gmedia_data.modules[default_module].screenshot);
470
  }
@@ -476,7 +481,7 @@
476
  },
477
 
478
  save: function(props) {
479
- if(typeof props.attributes.id == 'undefined') {
480
  return;
481
  }
482
  return GmediaTerm(props.attributes, 'category');
@@ -486,7 +491,7 @@
486
 
487
  blocks.registerBlockType('gmedia/tag', {
488
  title: 'Gmedia Tag',
489
- icon: { src: icons.iconTag},
490
  description: 'Publish gallery by Gmedia Tag',
491
  keywords: [
492
  'gallery',
@@ -512,27 +517,27 @@
512
  type: 'string'
513
  }
514
  },
515
- transforms:{
516
  to: [
517
  {
518
  type: 'block',
519
- blocks: [ 'gmedia/album' ],
520
- transform: function(){
521
- return createBlock( 'gmedia/album', {})
522
  }
523
  },
524
  {
525
  type: 'block',
526
- blocks: [ 'gmedia/category' ],
527
- transform: function(){
528
- return createBlock( 'gmedia/category', {})
529
  }
530
  },
531
  {
532
  type: 'block',
533
- blocks: [ 'gmedia/gallery' ],
534
- transform: function(){
535
- return createBlock( 'gmedia/gallery', {})
536
  }
537
  }
538
  ]
@@ -541,7 +546,7 @@
541
  edit: function(props) {
542
  var id = props.attributes.id;
543
  var module_name = props.attributes.module_name;
544
- var module = props.attributes.module_preset? props.attributes.module_preset : module_name;
545
  var default_module = gmedia_data.default_module;
546
  var elclass = 'gmedia-id';
547
  var image = gmedia_data.gmedia_image;
@@ -557,13 +562,14 @@
557
  var module = form.find('.gmedia-overwrite-module');
558
  var module_name = module.find('option:selected');
559
  var module_preset = '';
560
- if(module_name.attr('value')) {
561
  module_name = module_name.closest('optgroup').attr('module');
562
- if(module.val() != module_name){
563
  module_preset = module.val();
564
  }
565
- } else {
566
- module_name = ''
 
567
  }
568
  props.setAttributes({
569
  id: id,
@@ -581,7 +587,7 @@
581
  el('option', {value: gmedia_data.tags[key].term_id}, gmedia_data.tags[key].name)
582
  );
583
  });
584
- if(!id) {
585
  elclass += ' gmedia-required';
586
  }
587
  form_fields.push(
@@ -599,14 +605,14 @@
599
  );
600
  });
601
  modules.push(
602
- el('optgroup', {label: gmedia_data.modules_options[key].title, module: key}, null, options),
603
  );
604
  });
605
  form_fields.push(
606
  el('select', {className: 'gmedia-overwrite-module', value: module, onChange: setGallery}, modules)
607
  );
608
 
609
- if(id) {
610
  form_fields.push(GmediaTerm(props.attributes, 'tag'));
611
  }
612
 
@@ -614,7 +620,7 @@
614
  el('div', {className: 'form-fields'}, form_fields)
615
  );
616
 
617
- if(id) {
618
  var term_module = gmedia_data.tags[id].module_name;
619
  image = module_name ? gmedia_data.modules[module_name].screenshot : (term_module ? gmedia_data.modules[term_module].screenshot : gmedia_data.modules[default_module].screenshot);
620
  }
@@ -626,7 +632,7 @@
626
  },
627
 
628
  save: function(props) {
629
- if(typeof props.attributes.id == 'undefined') {
630
  return;
631
  }
632
  return GmediaTerm(props.attributes, 'tag');
1
  (function(blocks, element) {
 
2
  var el = element.createElement,
3
  source = blocks.source,
4
  setCategories = blocks.setCategories,
5
  getCategories = blocks.getCategories,
6
  createBlock = blocks.createBlock;
7
+
8
+ var icons = {};
9
+ var iconColor = '#316778';
10
  icons.iconAlbum = el(
11
+ 'svg',
12
+ {key: 'gm-album', width: 24, height: 24, style: {fill: iconColor}, viewBox: '0 0 24 24'},
13
+ el('path', {d: 'M24,6c0-2.2-1.8-4-4-4H4C1.8,2,0,3.8,0,6v12c0,2.2,1.8,4,4,4h16c2.2,0,4-1.8,4-4V6z M6,6c1.1,0,2,0.9,2,2 c0,1.1-0.9,2-2,2S4,9.1,4,8C4,6.9,4.9,6,6,6z M22,18c0,1.1-0.9,2-2,2H4.4c-0.9,0-1.3-1.1-0.7-1.7l3.6-3.6c0.4-0.4,1-0.4,1.4,0 l0.6,0.6c0.4,0.4,1,0.4,1.4,0l6.6-6.6c0.4-0.4,1-0.4,1.4,0l3,3c0.2,0.2,0.3,0.4,0.3,0.7V18z'})
14
  );
15
  icons.iconGal = el(
16
+ 'svg',
17
+ {key: 'gm-gallery', width: 24, height: 24, style: {fill: iconColor}, viewBox: '0 0 512 512'},
18
  [
19
+ el('path', {d: 'M464,128h-16v-16c0-26.51-21.49-48-48-48h-16V48c0-26.51-21.49-48-48-48H48C21.49,0,0,21.49,0,48v288 c0,26.51,21.49,48,48,48h16v16c0,26.51,21.49,48,48,48h16v16c0,26.51,21.49,48,48,48h288c26.51,0,48-21.49,48-48V176 C512,149.49,490.51,128,464,128z M32,265.44V48c0-8.837,7.163-16,16-16h288c8.837,0,16,7.163,16,16v153.44l-36.64-36.64 c-6.241-6.204-16.319-6.204-22.56,0L224,233.44l-68.64-68.8c-6.241-6.204-16.319-6.204-22.56,0L32,265.44z M112,416 c-8.837,0-16-7.163-16-16v-16h240c26.51,0,48-21.49,48-48V96h16c8.837,0,16,7.163,16,16v288c0,8.837-7.163,16-16,16H112z M480,464 c0,8.837-7.163,16-16,16H176c-8.837,0-16-7.163-16-16v-16h240c26.51,0,48-21.49,48-48V160h16c8.837,0,16,7.163,16,16V464z'})
20
  ]
21
  );
22
  icons.iconCat = el(
23
+ 'svg',
24
+ {key: 'gm-category', width: 24, height: 24, style: {fill: iconColor}, viewBox: '0 0 24 24'},
25
+ el('path', {d: 'M24,6c0-2.2-1.8-4-4-4H4C1.8,2,0,3.8,0,6v12c0,2.2,1.8,4,4,4h16c2.2,0,4-1.8,4-4V6z M6,6c1.1,0,2,0.9,2,2 c0,1.1-0.9,2-2,2S4,9.1,4,8C4,6.9,4.9,6,6,6z M22,18c0,1.1-0.9,2-2,2H4.4c-0.9,0-1.3-1.1-0.7-1.7l3.6-3.6c0.4-0.4,1-0.4,1.4,0 l0.6,0.6c0.4,0.4,1,0.4,1.4,0l6.6-6.6c0.4-0.4,1-0.4,1.4,0l3,3c0.2,0.2,0.3,0.4,0.3,0.7V18z'})
26
  );
27
  icons.iconTag = el(
28
+ 'svg',
29
+ {key: 'gm-tag', width: 24, height: 24, style: {fill: iconColor}, viewBox: '0 0 427 427'},
30
  [
31
+ el('path', {d: 'M414.08,204.373L222.187,12.48C214.4,4.8,203.733,0,192,0H42.667C19.093,0,0,19.093,0,42.667V192 c0,11.84,4.8,22.507,12.587,30.187l192,192c7.68,7.68,18.347,12.48,30.08,12.48s22.507-4.8,30.187-12.48l149.333-149.333 c7.68-7.787,12.48-18.453,12.48-30.187C426.667,222.827,421.867,212.16,414.08,204.373z M74.667,106.667 c-17.707,0-32-14.293-32-32s14.293-32,32-32s32,14.293,32,32S92.373,106.667,74.667,106.667z'})
32
  ]
33
  );
34
+ icons.attention = el(
35
+ 'svg',
36
+ {key: 'gm-attention', width: 34, height: 34, style: {fill: iconColor}, viewBox: '0 0 30 30'},
37
  [
38
+ el('path', {d: 'M15,3C8.373,3,3,8.373,3,15c0,6.627,5.373,12,12,12s12-5.373,12-12C27,8.373,21.627,3,15,3z M16.212,8l-0.2,9h-2.024l-0.2-9 H16.212z M15.003,22.189c-0.828,0-1.323-0.441-1.323-1.182c0-0.755,0.494-1.196,1.323-1.196c0.822,0,1.316,0.441,1.316,1.196 C16.319,21.748,15.825,22.189,15.003,22.189z'})
39
  ]
40
  );
41
 
47
  var catt = [category];
48
  catt = catt.concat(getCategories());
49
  setCategories(catt);
50
+
51
  function GmediaGallery(atts) {
52
  var id = atts.id;
53
  var tagtext = '[gmedia id=' + id + ']';
65
  return el('div', {className: 'gmedia-shortcode'}, tagtext);
66
  }
67
 
 
68
  blocks.registerBlockType('gmedia/gallery', {
69
  title: 'Gmedia Gallery',
70
+ icon: {src: icons.iconGal},
71
  description: 'Add Gmedia Gallery',
72
  keywords: [
73
  'gallery',
78
  'video',
79
  'audio',
80
  'mp3',
81
+ 'lightbox'
82
  ],
83
  category: category.slug,
84
  attributes: {
86
  type: 'integer'
87
  }
88
  },
89
+ transforms: {
90
  to: [
91
  {
92
  type: 'block',
93
+ blocks: ['gmedia/album'],
94
+ transform: function() {
95
+ return createBlock('gmedia/album', {});
96
  }
97
  },
98
  {
99
  type: 'block',
100
+ blocks: ['gmedia/category'],
101
+ transform: function() {
102
+ return createBlock('gmedia/category', {});
103
  }
104
  },
105
  {
106
  type: 'block',
107
+ blocks: ['gmedia/tag'],
108
+ transform: function() {
109
+ return createBlock('gmedia/tag', {});
110
  }
111
  }
112
  ]
139
  el('option', {value: gmedia_data.galleries[key].term_id}, gmedia_data.galleries[key].name)
140
  );
141
  });
142
+ if (!id) {
143
  elclass += ' gmedia-required';
144
  }
145
  form_fields.push(
146
  el('select', {className: elclass, value: id, onChange: setGallery}, options)
147
  );
148
 
149
+ if (id) {
150
  form_fields.push(GmediaGallery(props.attributes));
151
  }
152
 
154
  el('div', {className: 'form-fields'}, form_fields)
155
  );
156
 
157
+ if (id) {
158
  var module = gmedia_data.galleries[id].module_name;
159
  image = (gmedia_data.modules[module] && gmedia_data.modules[module].screenshot)
160
+ ? gmedia_data.modules[module].screenshot : undefined;
161
+ }
162
+ if (image) {
163
+ children.push(el('img', {className: 'gmedia-module-screenshot', src: image}));
164
  }
165
+ else {
166
+ children.push(el('div', {
167
+ style: {
168
+ width: '240px', height: '140px', color: 'red', margin: '10px', padding: '15px', display: 'flex',
169
+ flexDirection: 'column', justifyContent: 'center', alignItems: 'center', backgroundCcolor: '#fef8ee', textAlign: 'center'
170
+ }
171
+ }, [
172
  'This gallery is broken, select another!',
173
  icons.attention
174
  ]));
177
  },
178
 
179
  save: function(props) {
180
+ if (typeof props.attributes.id == 'undefined') {
181
  return;
182
  }
183
  return GmediaGallery(props.attributes);
187
 
188
  blocks.registerBlockType('gmedia/album', {
189
  title: 'Gmedia Album',
190
+ icon: {src: icons.iconAlbum},
191
  description: 'Add Gmedia Album',
192
  keywords: [
193
  'gallery',
207
  type: 'integer'
208
  },
209
  module_name: {
210
+ type: 'string'
211
  },
212
  module_preset: {
213
+ type: 'string'
214
  }
215
  },
216
+ transforms: {
217
  to: [
218
  {
219
  type: 'block',
220
+ blocks: ['gmedia/gallery'],
221
+ transform: function() {
222
+ return createBlock('gmedia/gallery', {});
223
  }
224
  },
225
  {
226
  type: 'block',
227
+ blocks: ['gmedia/category'],
228
+ transform: function() {
229
+ return createBlock('gmedia/category', {});
230
  }
231
  },
232
  {
233
  type: 'block',
234
+ blocks: ['gmedia/tag'],
235
+ transform: function() {
236
+ return createBlock('gmedia/tag', {});
237
  }
238
  }
239
  ]
242
  edit: function(props) {
243
  var id = props.attributes.id;
244
  var module_name = props.attributes.module_name;
245
+ var module = props.attributes.module_preset ? props.attributes.module_preset : module_name;
246
  var default_module = gmedia_data.default_module;
247
  var elclass = 'gmedia-id';
248
  var image = gmedia_data.gmedia_image;
258
  var module = form.find('.gmedia-overwrite-module');
259
  var module_name = module.find('option:selected');
260
  var module_preset = '';
261
+ if (module_name.attr('value')) {
262
  module_name = module_name.closest('optgroup').attr('module');
263
+ if (module.val() !== module_name) {
264
  module_preset = module.val();
265
  }
266
+ }
267
+ else {
268
+ module_name = '';
269
  }
270
  props.setAttributes({
271
  id: id,
284
  el('option', {value: gmedia_data.albums[key].term_id}, gmedia_data.albums[key].name)
285
  );
286
  });
287
+ if (!id) {
288
  elclass += ' gmedia-required';
289
  }
290
  form_fields.push(
302
  );
303
  });
304
  modules.push(
305
+ el('optgroup', {label: gmedia_data.modules_options[key].title, module: key}, null, options)
306
  );
307
  });
308
  form_fields.push(
309
  el('select', {className: 'gmedia-overwrite-module', value: module, onChange: setGallery}, modules)
310
  );
311
 
312
+ if (id) {
313
  form_fields.push(GmediaTerm(props.attributes, 'album'));
314
  }
315
 
317
  el('div', {className: 'form-fields'}, form_fields)
318
  );
319
 
320
+ if (id) {
321
  var term_module = gmedia_data.albums[id].module_name;
322
  image = module_name ? gmedia_data.modules[module_name].screenshot : (term_module ? gmedia_data.modules[term_module].screenshot : gmedia_data.modules[default_module].screenshot);
323
  }
329
  },
330
 
331
  save: function(props) {
332
+ if (typeof props.attributes.id == 'undefined') {
333
  return;
334
  }
335
  return GmediaTerm(props.attributes, 'album');
339
 
340
  blocks.registerBlockType('gmedia/category', {
341
  title: 'Gmedia Category',
342
+ icon: {src: icons.iconCat},
343
  description: 'Add Gmedia Category',
344
  keywords: [
345
  'gallery',
365
  type: 'string'
366
  }
367
  },
368
+ transforms: {
369
  to: [
370
  {
371
  type: 'block',
372
+ blocks: ['gmedia/album'],
373
+ transform: function() {
374
+ return createBlock('gmedia/album', {});
375
  }
376
  },
377
  {
378
  type: 'block',
379
+ blocks: ['gmedia/gallery'],
380
+ transform: function() {
381
+ return createBlock('gmedia/gallery', {});
382
  }
383
  },
384
  {
385
  type: 'block',
386
+ blocks: ['gmedia/tag'],
387
+ transform: function() {
388
+ return createBlock('gmedia/tag', {});
389
  }
390
  }
391
  ]
394
  edit: function(props) {
395
  var id = props.attributes.id;
396
  var module_name = props.attributes.module_name;
397
+ var module = props.attributes.module_preset ? props.attributes.module_preset : module_name;
398
  var default_module = gmedia_data.default_module;
399
  var elclass = 'gmedia-id';
400
  var image = gmedia_data.gmedia_image;
410
  var module = form.find('.gmedia-overwrite-module');
411
  var module_name = module.find('option:selected');
412
  var module_preset = '';
413
+ if (module_name.attr('value')) {
414
  module_name = module_name.closest('optgroup').attr('module');
415
+ if (module.val() !== module_name) {
416
  module_preset = module.val();
417
  }
418
+ }
419
+ else {
420
+ module_name = '';
421
  }
422
  props.setAttributes({
423
  id: id,
436
  el('option', {value: gmedia_data.categories[key].term_id}, gmedia_data.categories[key].name)
437
  );
438
  });
439
+ if (!id) {
440
  elclass += ' gmedia-required';
441
  }
442
  form_fields.push(
454
  );
455
  });
456
  modules.push(
457
+ el('optgroup', {label: gmedia_data.modules_options[key].title, module: key}, null, options)
458
  );
459
  });
460
  form_fields.push(
461
  el('select', {className: 'gmedia-overwrite-module', value: module, onChange: setGallery}, modules)
462
  );
463
 
464
+ if (id) {
465
  form_fields.push(GmediaTerm(props.attributes, 'category'));
466
  }
467
 
469
  el('div', {className: 'form-fields'}, form_fields)
470
  );
471
 
472
+ if (id) {
473
  var term_module = gmedia_data.categories[id].module_name;
474
  image = module_name ? gmedia_data.modules[module_name].screenshot : (term_module ? gmedia_data.modules[term_module].screenshot : gmedia_data.modules[default_module].screenshot);
475
  }
481
  },
482
 
483
  save: function(props) {
484
+ if (typeof props.attributes.id == 'undefined') {
485
  return;
486
  }
487
  return GmediaTerm(props.attributes, 'category');
491
 
492
  blocks.registerBlockType('gmedia/tag', {
493
  title: 'Gmedia Tag',
494
+ icon: {src: icons.iconTag},
495
  description: 'Publish gallery by Gmedia Tag',
496
  keywords: [
497
  'gallery',
517
  type: 'string'
518
  }
519
  },
520
+ transforms: {
521
  to: [
522
  {
523
  type: 'block',
524
+ blocks: ['gmedia/album'],
525
+ transform: function() {
526
+ return createBlock('gmedia/album', {});
527
  }
528
  },
529
  {
530
  type: 'block',
531
+ blocks: ['gmedia/category'],
532
+ transform: function() {
533
+ return createBlock('gmedia/category', {});
534
  }
535
  },
536
  {
537
  type: 'block',
538
+ blocks: ['gmedia/gallery'],
539
+ transform: function() {
540
+ return createBlock('gmedia/gallery', {});
541
  }
542
  }
543
  ]
546
  edit: function(props) {
547
  var id = props.attributes.id;
548
  var module_name = props.attributes.module_name;
549
+ var module = props.attributes.module_preset ? props.attributes.module_preset : module_name;
550
  var default_module = gmedia_data.default_module;
551
  var elclass = 'gmedia-id';
552
  var image = gmedia_data.gmedia_image;
562
  var module = form.find('.gmedia-overwrite-module');
563
  var module_name = module.find('option:selected');
564
  var module_preset = '';
565
+ if (module_name.attr('value')) {
566
  module_name = module_name.closest('optgroup').attr('module');
567
+ if (module.val() !== module_name) {
568
  module_preset = module.val();
569
  }
570
+ }
571
+ else {
572
+ module_name = '';
573
  }
574
  props.setAttributes({
575
  id: id,
587
  el('option', {value: gmedia_data.tags[key].term_id}, gmedia_data.tags[key].name)
588
  );
589
  });
590
+ if (!id) {
591
  elclass += ' gmedia-required';
592
  }
593
  form_fields.push(
605
  );
606
  });
607
  modules.push(
608
+ el('optgroup', {label: gmedia_data.modules_options[key].title, module: key}, null, options)
609
  );
610
  });
611
  form_fields.push(
612
  el('select', {className: 'gmedia-overwrite-module', value: module, onChange: setGallery}, modules)
613
  );
614
 
615
+ if (id) {
616
  form_fields.push(GmediaTerm(props.attributes, 'tag'));
617
  }
618
 
620
  el('div', {className: 'form-fields'}, form_fields)
621
  );
622
 
623
+ if (id) {
624
  var term_module = gmedia_data.tags[id].module_name;
625
  image = module_name ? gmedia_data.modules[module_name].screenshot : (term_module ? gmedia_data.modules[term_module].screenshot : gmedia_data.modules[default_module].screenshot);
626
  }
632
  },
633
 
634
  save: function(props) {
635
+ if (typeof props.attributes.id == 'undefined') {
636
  return;
637
  }
638
  return GmediaTerm(props.attributes, 'tag');
admin/assets/js/gmedia.admin.js CHANGED
@@ -4,1775 +4,1808 @@
4
  var wp = window.wp || {};
5
  var gmedia_DOM;
6
  var GmediaLibrary = {
7
- init: function() {
8
- window.gm_wavesurfer = {};
9
- if(jQuery('.gmedia-audio-item').length) {
10
 
11
- jQuery('.gm-waveform-player').each(function() {
12
- var data = jQuery(this).data();
13
- data.gmid = data.id;
14
- data.id = 'ws' + data.gmid;
15
 
16
- if(data.peaks){
17
- jQuery('.gm-play', this).show();
18
- jQuery('.gm-pause', this).hide();
19
 
20
- GmediaLibrary.waveplayer(data, true);
21
- }
22
- });
23
- gmedia_DOM.on('click', '.gm-waveform', function() {
24
- var parent = jQuery(this).parent(),
25
- data = parent.data();
26
-
27
- jQuery(this).remove();
28
-
29
- GmediaLibrary.waveplayer(data);
30
-
31
- if(data.peaks) {
32
- //window.gm_wavesurfer[data.id].play();
33
- } else {
34
- window.gm_wavesurfer[data.id].on('waveform-ready', function() {
35
- jQuery('.gm-play', parent).hide();
36
- jQuery('.gm-pause', parent).show();
37
- jQuery('.spinner', parent).removeClass('is-active');
38
- var peaks = window.gm_wavesurfer[data.id].exportPCM(1800, 10000, true);
39
- var post_data = {
40
- action: 'gmedia_save_waveform',
41
- id: data.gmid,
42
- peaks: peaks,
43
- _wpnonce: jQuery('#_wpnonce').val()
44
- };
45
- jQuery.post(ajaxurl, post_data, function(return_data, textStatus, jqXHR) {
46
- var data_peaks = window.gm_wavesurfer[data.id].exportPCM(450, 10000, true);
47
- parent.attr('data-peaks', data_peaks);
48
- });
49
- });
50
- }
51
- });
52
- gmedia_DOM.on('click', '.gm-play, .gm-pause', function() {
53
- var parent = jQuery(this).parent();
54
- var data = parent.data();
55
- if(!parent.hasClass('ws-loaded')) {
56
- parent.addClass('ws-loaded');
57
- window.gm_wavesurfer[data.id].load(data.file, data.peaks);
58
- window.gm_wavesurfer[data.id].toggleInteraction();
59
- window.gm_wavesurfer[data.id].play();
60
- } else {
61
- window.gm_wavesurfer[data.id].playPause();
62
- }
63
- });
64
 
65
- var resize;
66
- jQuery(window).on('resize.gmedia', function(){
67
- clearTimeout(resize);
68
- resize = setTimeout(function(){
69
- jQuery('.gm-waveform-player').each(function() {
70
- var data = jQuery(this).data();
71
- if(data.peaks && window.gm_wavesurfer[data.id]){
72
- window.gm_wavesurfer[data.id].load(data.file, data.peaks);
73
- }
74
- });
75
- }, 500);
76
- });
77
 
78
- }
79
 
80
- if(jQuery('body').hasClass('GrandMedia_edit')) {
81
- GmediaLibrary.editmode();
82
  }
83
-
84
- if(jQuery('body').hasClass('gmedia_library')) {
85
- var previewFrame = jQuery('#previewFrame', window.parent.document);
86
- jQuery(window).on('load.gmedia', function(){
87
- setTimeout(function(){
88
- previewFrame.animate({'height': getDocHeight('gmedia_iframe_content') + 3}, 200);
89
- }, 10);
90
- });
91
- var refresh = !jQuery('body').is('.GrandMedia_select_single, .GrandMedia_select_multiple');
92
- var observer = new MutationObserver(function(mutations) {
93
- previewFrame.height(getDocHeight('gmedia_iframe_content') + 3);
94
- if(refresh) {
95
- jQuery('#previewModal', window.parent.document).attr('data-refresh', 'true');
96
- }
97
- });
98
- var gmedia_iframe_content = window.document.getElementById('gmedia_iframe_content');
99
- observer.observe(gmedia_iframe_content, {
100
- childList: true,
101
- subtree: true,
102
- attributes: true,
103
- attributeFilter: ['value']
104
  });
 
105
  }
106
-
107
- },
108
- waveplayer: function(data, draw) {
109
- window.gm_wavesurfer[data.id] = Object.create(WaveSurfer);
110
- window.gm_wavesurfer[data.id].init({
111
- container: '#' + data.id,
112
- waveColor: '#428bca',
113
- progressColor: '#31708f',
114
- backend: 'MediaElement',
115
- renderer: 'Canvas',
116
- height: 60,
117
- interact: false,
118
- barWidth: 0
119
- });
120
- // Play on audio load
121
- var parent = jQuery(window.gm_wavesurfer[data.id].container).parent();
122
-
123
- if(!parent.hasClass('ws-loaded')) {
124
- if(draw) {
125
- window.gm_wavesurfer[data.id].backend.setPeaks(data.peaks);
126
- window.gm_wavesurfer[data.id].drawBuffer();
127
- } else {
128
- parent.addClass('ws-loaded');
129
- window.gm_wavesurfer[data.id].load(data.file, data.peaks);
130
- window.gm_wavesurfer[data.id].toggleInteraction();
131
- window.gm_wavesurfer[data.id].play();
132
  }
133
- } else {
134
- window.gm_wavesurfer[data.id].play();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  }
 
 
 
 
 
 
 
 
 
136
 
137
- jQuery(window.gm_wavesurfer[data.id].container).on('click', function(e) {
138
- if(!parent.hasClass('ws-loaded')) {
139
- parent.addClass('ws-loaded');
140
- window.gm_wavesurfer[data.id].load(data.file, data.peaks);
141
- window.gm_wavesurfer[data.id].toggleInteraction();
142
- window.gm_wavesurfer[data.id].play();
143
- }
144
- if(window.gm_wavesurfer[data.id].isPlaying()) {
145
- window.gm_wavesurfer[data.id].backend.media.currentTime = 0;
146
- } else{
147
- window.gm_wavesurfer[data.id].play();
148
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
 
151
- window.gm_wavesurfer[data.id].on('play', function() {
152
- parent.find('.gm-play').hide();
153
- parent.find('.gm-pause').show();
154
- parent.find('.spinner').removeClass('is-active');
 
 
155
 
156
- jQuery.each(window.gm_wavesurfer, function(id) {
157
- if(id !== data.id && window.gm_wavesurfer[id].isPlaying()) {
158
- window.gm_wavesurfer[id].pause();
159
- }
 
 
 
 
 
 
 
 
 
 
160
  });
161
- })
162
- window.gm_wavesurfer[data.id].on('pause', function() {
163
- parent.find('.gm-play').show();
164
- parent.find('.gm-pause').hide();
165
- });
166
- window.gm_wavesurfer[data.id].on('loading', function(p) {
167
- if(p == 100) {
168
- //parent.find('.spinner').removeClass('is-active');
169
- } else {
170
- parent.find('.spinner').addClass('is-active');
171
  }
 
 
 
 
 
 
 
 
 
 
 
172
  });
173
- },
174
- /**
175
- * Edit Mode
176
- */
177
- editmode: function() {
178
- var focus_input_val;
179
- // SelectBox for albums
180
- var combobox_albums = jQuery('.combobox_gmedia_album');
181
- var selectize_albums = combobox_albums.selectize({
182
- create: (combobox_albums.data('create')? true : false),
183
- onOptionAdd: function(value, data){
184
- jQuery.each(selectize_albums, function(i, e){
185
- e.selectize.options[value] = data;
186
- });
187
- },
188
- onFocus: function(){
189
- this.$input.addClass('edit-gmedia-ignore');
190
- focus_input_val = this.$input.val();
191
- },
192
- onBlur: function(){
193
- this.$input.removeClass('edit-gmedia-ignore');
194
- if(focus_input_val != this.$input.val()) {
195
- var inporder = this.$input.prev('.gm-order-input');
196
- inporder.val('0');
197
- if('' == this.$input.val()){
198
- inporder.prop('disabled', true);
199
- } else {
200
- inporder.prop('disabled', false);
201
- }
202
- this.$input.trigger('change');
203
- }
204
- },
205
- persist: true
206
  });
207
 
208
- if(window.gmedia_categories) {
209
- var categories = jQuery('.combobox_gmedia_category');
210
- if(categories.length) {
211
- var categories_data = window.gmedia_categories.map(function(x) {
212
- return {item: x};
213
- });
214
-
215
- var selectize_categories = categories.selectize({
216
- create: function(input) {
217
- if(categories.data('create')) {
218
- return {
219
- item: input
220
- }
221
- } else {
222
- return false;
223
- }
224
- },
225
- onOptionAdd: function(value, data){
226
- jQuery.each(selectize_categories, function(i, e){
227
- e.selectize.options[value] = data;
228
- });
229
- },
230
- onFocus: function(){
231
- this.$input.addClass('edit-gmedia-ignore');
232
- focus_input_val = this.$input.val();
233
- },
234
- onBlur: function(){
235
- this.$input.removeClass('edit-gmedia-ignore');
236
- if(focus_input_val != this.$input.val()) {
237
- this.$input.trigger('change');
238
- }
239
- },
240
- createOnBlur: true,
241
- delimiter: ',',
242
- maxItems: null,
243
- openOnFocus: true,
244
- persist: true,
245
- options: categories_data,
246
- labelField: 'item',
247
- valueField: 'item',
248
- searchField: ['item'],
249
- hideSelected: true
250
- });
251
  }
252
- }
253
- if(window.gmedia_tags) {
254
- var tags = jQuery('.combobox_gmedia_tag');
255
- if(tags.length) {
256
- var tags_data = window.gmedia_tags.map(function(x) {
257
- return {item: x};
258
- });
259
-
260
- var selectize_tags = tags.selectize({
261
- create: function(input) {
262
- if(this.$input.data('create')) {
263
- var option = { item: input }
264
- tags_data.push(option);
265
- return option;
266
- } else {
267
- return false;
268
- }
269
- },
270
- onOptionAdd: function(value, data){
271
- jQuery.each(selectize_tags, function(i, e){
272
- e.selectize.options[value] = data;
273
- });
274
- },
275
- onFocus: function(){
276
- this.$input.addClass('edit-gmedia-ignore');
277
- focus_input_val = this.$input.val();
278
- },
279
- onBlur: function(){
280
- this.$input.removeClass('edit-gmedia-ignore');
281
- if(focus_input_val != this.$input.val()) {
282
- this.$input.trigger('change');
283
- }
284
- },
285
- createOnBlur: true,
286
- delimiter: ',',
287
- maxItems: null,
288
- openOnFocus: true,
289
- persist: true,
290
- options: tags_data,
291
- labelField: 'item',
292
- valueField: 'item',
293
- searchField: ['item'],
294
- hideSelected: true
295
- });
296
-
297
  }
298
- }
299
-
300
- // Date/Time picker
301
- var gmedia_date_temp;
302
- jQuery('.input-group.gmedia_date').datetimepicker({format: 'YYYY-MM-DD HH:mm:ss', focusOnShow: true, ignoreReadonly: true, allowInputToggle: true}).on('dp.show', function() {
303
- gmedia_date_temp = jQuery('input', this).val();
304
- }).on('dp.hide', function() {
305
- if(jQuery('input', this).val() !== gmedia_date_temp) {
306
- jQuery('input', this).trigger('modified');
 
 
 
 
 
307
  }
 
 
 
 
 
 
 
 
 
 
 
308
  });
309
 
310
- // Mask for filename input
311
- var inp_filename = jQuery('input.gmedia-filename').not('[readonly]');
312
- if(inp_filename.length) {
313
- inp_filename.alphanum({
314
- allow: '-_',
315
- disallow: '',
316
- allowSpace: false,
317
- allowNumeric: true,
318
- allowUpper: true,
319
- allowLower: true,
320
- allowCaseless: true,
321
- allowLatin: true,
322
- allowOtherCharSets: false,
323
- forceUpper: false,
324
- forceLower: false,
325
- maxLength: NaN
326
- });
327
- }
328
 
329
- if(jQuery('#wp-link-wrap').parent().hasClass('hidden')){
330
- jQuery('#wp-link-backdrop, #wp-link-wrap').appendTo('body');
331
- }
332
- jQuery(document).on('click.gmedia', '.gmedia-custom-link', function(e) {
333
- var editorId = jQuery(this).attr('data-target');
334
- wpActiveEditor = true;
335
- wpLink.open(editorId);
336
- wpLink.gmediaCustomLinkTarget = editorId;
337
- jQuery('#wp-link-wrap').removeClass('has-text-field').addClass('gmLinkModal').find('.link-target').css('visibility','hidden');
338
 
339
- return false;
340
- });
341
- function closeLinkModal(){
342
- jQuery('#wp-link-wrap').removeClass('gmLinkModal').find('.link-target').removeAttr('style');
343
- wpLink.close();
344
- }
345
- jQuery(document).on('click.gmedia', '.gmLinkModal #wp-link-submit', function(e) {
346
- e.preventDefault ? e.preventDefault() : e.returnValue = false;
347
- e.stopPropagation();
 
 
 
 
 
 
 
 
 
348
 
349
- var link = wpLink.getAttrs();
350
- wpLink.textarea = jQuery('#' + wpLink.gmediaCustomLinkTarget);
 
 
 
 
 
 
 
 
 
 
351
 
352
- if (!link.href) {
353
- closeLinkModal();
354
- return;
355
- }
356
- wpLink.textarea.val(link.href).trigger('change');
357
- closeLinkModal();
358
- });
359
- jQuery(document).on('click.gmedia', '#wp-link-cancel, #wp-link-close, #wp-link-backdrop', function(e) {
360
- closeLinkModal()
361
- });
362
 
363
- var related_sortable = jQuery('.related-media-previews');
364
- if(related_sortable.length){
365
- related_sortable.sortable({
366
- items: '.gmedia-related-image',
367
- handle: '.image-wrapper',
368
- placeholder: 'gmedia-related-image',
369
- tolerance: 'pointer',
370
- //helper: 'clone',
371
- revert: true,
372
- forcePlaceholderSize: true,
373
- stop: function(event, ui){
374
- console.log(ui);
375
- ui.item.find('input').trigger('change');
376
- }
377
- });
378
- }
379
 
 
 
 
 
 
 
 
 
 
 
380
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
381
  }
 
 
382
  };
383
 
384
  /**
385
  * Gmedia AddMedia
386
  */
387
  var GmediaAddMedia = {
388
- init: function() {
389
-
390
- if(jQuery('body').hasClass('GrandMedia_AddMedia')) {
391
- gmedia_DOM.on('change', '#uploader_runtime select', function() {
392
- if('html4' == jQuery(this).val()) {
393
- jQuery('#uploader_chunking').addClass('hide');
394
- jQuery('#uploader_urlstream_upload').addClass('hide');
395
- } else {
396
- jQuery('#uploader_chunking').removeClass('hide');
397
- jQuery('#uploader_urlstream_upload').removeClass('hide');
398
- }
399
- });
400
- }
401
 
402
- var albums = jQuery('select#combobox_gmedia_album');
403
- if(albums.length) {
404
- var albums_data = jQuery('option', albums);
405
- albums.selectize({
406
- create: function(input) {
407
- if(albums.data('create')) {
408
- return {
409
- value: input,
410
- text: input
411
- }
412
- } else {
413
- return false;
414
- }
415
- },
416
- createOnBlur: true,
417
- persist: false,
418
- render: {
419
- item: function(item, escape) {
420
- if(0 === (parseInt(item.value, 10) || 0)) {
421
- return '<div>' + escape(item.text) + '</div>';
422
- }
423
- if(item.$order) {
424
- var data = jQuery(albums_data[item.$order]).data();
425
- return '<div>' + escape(data.name) + ' <small>' + escape(data.meta) + '</small></div>';
426
- }
427
- },
428
- option: function(item, escape) {
429
- if(0 === (parseInt(item.value) || 0)) {
430
- return '<div>' + escape(item.text) + '</div>';
431
- }
432
- if(item.$order) {
433
- var data = jQuery(albums_data[item.$order]).data();
434
- return '<div>' + escape(data.name) + ' <small>' + escape(data.meta) + '</small></div>';
435
- }
436
- }
437
- }
438
- });
439
  }
 
 
 
 
 
 
440
 
441
- if(window.gmedia_tags) {
442
- var tags = jQuery('#combobox_gmedia_tag');
443
- if(tags.length) {
444
- var tags_data = window.gmedia_tags.map(function(x) {
445
- return {item: x};
446
- });
447
-
448
- tags.selectize({
449
- create: function(input) {
450
- if(tags.data('create')) {
451
- return {
452
- item: input
453
- }
454
- } else {
455
- return false;
456
- }
457
- },
458
- createOnBlur: true,
459
- delimiter: ',',
460
- maxItems: null,
461
- openOnFocus: true,
462
- persist: false,
463
- options: tags_data,
464
- labelField: 'item',
465
- valueField: 'item',
466
- searchField: ['item'],
467
- hideSelected: true
468
- });
469
  }
470
- }
471
- if(window.gmedia_categories) {
472
- var categories = jQuery('#combobox_gmedia_category');
473
- if(categories.length) {
474
- var categories_data = window.gmedia_categories.map(function(x) {
475
- return {item: x};
476
- });
477
-
478
- categories.selectize({
479
- create: function(input) {
480
- if(categories.data('create')) {
481
- return {
482
- item: input
483
- }
484
- } else {
485
- return false;
486
- }
487
- },
488
- createOnBlur: true,
489
- delimiter: ',',
490
- maxItems: null,
491
- openOnFocus: true,
492
- persist: false,
493
- options: categories_data,
494
- labelField: 'item',
495
- valueField: 'item',
496
- searchField: ['item'],
497
- hideSelected: true
498
- });
499
  }
 
500
  }
 
 
501
 
 
 
 
 
 
 
502
 
503
- },
504
- /**
505
- * Gmedia Import
506
- */
507
- importmode: function() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
508
  }
 
 
 
 
 
 
 
509
  };
510
 
511
  /**
512
  * Gmedia Terms
513
  */
514
  var GmediaTerms = {
515
- init: function(){
516
-
517
- if(jQuery('body').hasClass('GrandMedia_Tags')){
518
- jQuery('#gm-list-table').data('edit', false);
519
- gmedia_DOM.on('keypress', 'input.edit_tag_input', function(e){
520
- var tagdiv = jQuery('#tag_' + jQuery(this).data('tag_id'));
521
- var charCode = e.charCode || e.keyCode || e.which;
522
- if(charCode == 13){
523
- e.preventDefault();
524
- edit_tag(tagdiv);
525
- }
526
- }).on('blur', 'input.edit_tag_input', function(){
527
- var tagdiv = jQuery('#tag_' + jQuery(this).data('tag_id'));
528
- edit_tag(tagdiv);
529
- });
530
-
531
- gmedia_DOM.on('click', '.edit_tag_link', function(e){
532
- e.preventDefault();
533
- var id = jQuery(this).attr('href');
534
- jQuery(this).hide();
535
- jQuery(id).find('.edit_tag_form').show().find('input').focus();
536
- jQuery('#gm-list-table').data('edit', true);
537
- });
538
- gmedia_DOM.on('click', '.edit_tag_save', function(e){
539
- e.preventDefault();
540
- });
541
-
542
- function edit_tag(tagdiv){
543
- var inp = tagdiv.find('.edit_tag_form input');
544
- var new_tag_name = jQuery.trim(inp.val());
545
- var old_tag_name = inp.attr('placeholder');
546
- if((old_tag_name == new_tag_name) || ('' === new_tag_name) || jQuery.isNumeric()){
547
- inp.val(old_tag_name);
548
- tagdiv.find('.edit_tag_form').hide();
549
- tagdiv.find('.edit_tag_link').show();
550
- return;
551
- }
552
- var post_data = {
553
- action: 'gmedia_tag_edit',
554
- tag_id: inp.data('tag_id'),
555
- tag_name: new_tag_name,
556
- _wpnonce_terms: jQuery('#_wpnonce_terms').val()
557
- };
558
- jQuery.post(ajaxurl, post_data, function(data, textStatus, jqXHR){
559
- console.log(data);
560
- if(data.error){
561
- //inp.val(inp.attr('placeholder'));
562
- jQuery('#gmedia-panel').before(data.error);
563
- } else{
564
- //new_tag_name = new_tag_name.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
565
- inp.attr('placeholder', new_tag_name);
566
- tagdiv.find('.edit_tag_link').text(new_tag_name).show();
567
- //noinspection JSUnresolvedVariable
568
- jQuery('#gmedia-panel').before(data.msg);
569
- tagdiv.find('.edit_tag_form').hide();
570
- }
571
- });
572
- }
573
  }
574
-
575
- gmedia_DOM.on('click', '.term-shortcode input', function(){
576
- this.setSelectionRange(0, 0);
577
- this.setSelectionRange(0, this.value.length);
578
- });
579
- gmedia_DOM.on('change', '.term-shortcode input', function(){
580
- shortcode_inp_autowidth(this);
581
- });
582
- jQuery('.term-shortcode input', gmedia_DOM).each(function(i, e){
583
- shortcode_inp_autowidth(this)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
584
  });
 
 
585
 
586
- function shortcode_inp_autowidth(e){
587
- var inp = jQuery(e),
588
- buffer = inp.next('.input-buffer');
589
- buffer.text(inp.val());
590
- inp.width(buffer.width());
591
- }
 
 
 
 
592
 
593
- var sortable = jQuery('#gm-sortable');
594
- if(sortable.length && !jQuery('#gmedia-panel', sortable).hasClass('gmedia-filtered')){
595
- var sortdiv = jQuery('#gm-list-table', sortable);
596
- var post_data = sortable.data();
597
- post_data['idx0'] = parseInt(sortdiv.attr('data-idx0'));
 
598
 
599
- var _ids = [];
600
- jQuery('.gm-item-cell', sortdiv).each(function(index){
601
- _ids.push(jQuery(this).attr('data-id'));
602
- });
603
- sortdiv.sortable({
604
- items: '.gm-item-cell',
605
- handle: '.cb_media-object',
606
- placeholder: 'cb_list-item gm-item-cell col-xs-6 col-sm-4 col-md-3 col-lg-2 gmedia-image-item ui-highlight-placeholder',
607
- tolerance: 'pointer',
608
- helper: 'clone',
609
- revert: true,
610
- forcePlaceholderSize: true,
611
- stop: function(event, ui){
612
- var ids = [];
613
- jQuery('.gm-item-cell', sortdiv).each(function(index){
614
- ids.push(jQuery(this).attr('data-id'));
615
- });
616
-
617
- if(_ids.toString() != ids.toString()){
618
- _ids = ids;
619
- jQuery('.panel-heading .spinner', sortable).addClass('is-active');
620
- post_data['ids'] = ids
621
- jQuery.post(ajaxurl, post_data, function(data, textStatus, jqXHR){
622
- jQuery('.panel-heading .spinner', sortable).removeClass('is-active');
623
- console.log(data);
624
- });
625
- }
626
- }
 
 
627
  });
 
628
  }
 
 
629
 
630
- gmedia_DOM.on('change', '#gmedia_term_orderby', function(){
631
- if('custom' == jQuery(this).val()){
632
- jQuery('#gmedia_term_order').val('ASC').addClass('disabled');
633
- } else{
634
- jQuery('#gmedia_term_order').removeClass('disabled');
635
- }
636
- });
 
637
 
638
- // Date/Time picker
639
- if(jQuery.fn.datetimepicker){
640
- jQuery('.input-group.gmedia_date').datetimepicker({format: 'YYYY-MM-DD HH:mm:ss', focusOnShow: true, ignoreReadonly: true, allowInputToggle: true});
641
- }
642
  }
 
643
  };
644
 
645
  var GmediaSelect = {
646
- msg_stack: function(global) {
647
- var gm_cb = jQuery('.gm-stack input');
648
- var sel = jQuery('#gm-stack');
649
- if(!sel.length) {
650
- return;
651
- }
652
-
653
- var arr = sel.val().split(',');
654
- arr = jQuery.grep(arr, function(e) {
655
- return (e);
656
- });
657
 
658
- if(global) {
659
- var cur = false;
660
- gm_cb.each(function() {
661
- cur = jQuery(this);
662
- if(cur.is(':checked') && (jQuery.inArray(cur.val(), arr) === -1)) {
663
- cur.prop('checked', false);
664
- } else if(!(cur.is(':checked')) && (jQuery.inArray(cur.val(), arr) !== -1)) {
665
- cur.prop('checked', true);
666
- }
667
- });
668
- }
669
 
670
- if(sel.data('userid')) {
671
- var storedData = getStorage();
672
- storedData.set(sel.data('key'), arr.join('.'));
673
- }
674
- jQuery('#gm-stack-qty').text(arr.length);
675
- if(arr.length) {
676
- jQuery('#gm-stack-btn').removeClass('hidden');
677
- jQuery('.rel-stack-show').show();
678
- jQuery('.rel-stack-hide').hide();
679
  }
680
- else {
681
- jQuery('#gm-stack-btn').addClass('hidden');
682
- jQuery('.rel-stack-show').hide();
683
- jQuery('.rel-stack-hide').show();
684
- }
685
- sel.trigger('change');
686
- },
687
- msg_selected: function(obj, global) {
688
- var gm_cb = jQuery('.' + obj + ' input'),
689
- qty_v = gm_cb.length,
690
- sel_v = gm_cb.filter(':checked').length,
691
- c = jQuery('#cb_global');
692
- if((sel_v != qty_v) && (0 !== sel_v)) {
693
- c.css('opacity', '0.5').prop('checked', true);
694
- } else if((sel_v == qty_v) && (0 !== qty_v)) {
695
- c.css('opacity', '1').prop('checked', true);
696
- } else if(0 === sel_v) {
697
- c.css('opacity', '1').prop('checked', false);
698
  }
 
 
699
 
700
- var sel = jQuery('#gm-selected');
701
- if(!sel.length) {
702
- return;
703
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
704
 
705
- var arr = sel.val().split(',');
 
 
 
706
 
707
- arr = jQuery.grep(arr, function(e) {
708
- return (e);
709
- });
710
- if(global) {
711
- var cur = false;
712
- gm_cb.each(function() {
713
- cur = jQuery(this);
714
- if(cur.is(':checked') && (jQuery.inArray(cur.val(), arr) === -1)) {
715
- arr.push(cur.val());
716
- } else if(!(cur.is(':checked')) && (jQuery.inArray(cur.val(), arr) !== -1)) {
717
- arr = jQuery.grep(arr, function(e) {
718
- return e != cur.val();
719
- });
720
- }
721
- });
722
- sel.val(arr.join(','));
723
- }
724
 
725
- if(sel.data('userid')) {
726
- var storedData = getStorage();
727
- storedData.set(sel.data('key'), arr.join('.'));
 
 
 
 
 
 
 
 
 
 
 
728
  }
729
- jQuery('#gm-selected-qty').text(arr.length);
 
 
730
 
731
- var selbtn = jQuery('#gm-selected-btn');
732
- if(arr.length) {
733
- selbtn.removeClass('hidden');
734
- jQuery('.rel-selected-show').show();
735
- jQuery('.rel-selected-hide').hide();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
736
  }
737
  else {
738
- if(!selbtn.hasClass('gm-active')) {
739
- jQuery('#gm-selected-btn').addClass('hidden');
740
- }
741
- jQuery('.rel-selected-show').hide();
742
- jQuery('.rel-selected-hide').show();
743
- }
744
- sel.trigger('change');
745
- },
746
- chk_all: function(type, obj) {
747
- jQuery('.' + obj + ' input').filter(function() {
748
- return type? jQuery(this).data('type') == type : true;
749
- }).prop('checked', true).closest('.cb_list-item').addClass('gm-selected');
750
- },
751
- chk_none: function(type, obj) {
752
- jQuery('.' + obj + ' input').filter(function() {
753
- return type? jQuery(this).data('type') == type : true;
754
- }).prop('checked', false).closest('.cb_list-item').removeClass('gm-selected');
755
- },
756
- chk_toggle: function(type, obj) {
757
- if(type) {
758
- if(jQuery('.' + obj + ' input:checked').filter(function() {
759
- return jQuery(this).data('type') == type;
760
- }).length) {
761
- GmediaSelect.chk_none(type, obj);
762
- } else {
763
- GmediaSelect.chk_all(type, obj);
764
- }
765
- } else {
766
- jQuery('.' + obj + ' input').each(function() {
767
- jQuery(this).prop("checked", !jQuery(this).prop("checked")).closest('.cb_list-item').toggleClass('gm-selected');
768
- });
769
  }
770
- },
771
- init: function() {
772
- var cb_obj = jQuery('#cb_global').data('group');
773
-
774
- if(jQuery('#gm-selected').length) {
775
- GmediaSelect.msg_selected(cb_obj);
776
- gmedia_DOM.on('click', '#gm-selected-clear', function(e) {
777
- jQuery('#gm-selected').val('');
778
- GmediaSelect.chk_none(false, cb_obj);
779
- GmediaSelect.msg_selected(cb_obj);
780
- e.preventDefault();
781
- });
782
- gmedia_DOM.on('click', '#gm-selected-show', function(e) {
783
- jQuery('#gm-selected-btn').submit();
784
- e.preventDefault();
785
- });
786
- gmedia_DOM.on('click', '#gm-stack-in', function(e) {
787
- e.preventDefault();
788
- var stack_obj = jQuery('#gm-stack'),
789
- sel_obj = jQuery('#gm-selected'),
790
- stack = stack_obj.val().split(','),
791
- selected = sel_obj.val().split(','),
792
- arr = stack.concat(selected);
793
- arr = jQuery.grep(arr, function(e) {
794
- return (e);
795
- });
796
- arr = jQuery.unique(arr);
797
- stack_obj.val(arr.join(','));
798
- GmediaSelect.msg_stack(true);
799
- //sel_obj.val('');
800
- //GmediaSelect.chk_none(false, cb_obj);
801
- //GmediaSelect.msg_selected(cb_obj);
802
- });
803
- gmedia_DOM.on('click', '#gm-stack-out', function(e) {
804
- e.preventDefault();
805
- var stack_obj = jQuery('#gm-stack'),
806
- sel_obj = jQuery('#gm-selected'),
807
- stack = stack_obj.val().split(','),
808
- selected = sel_obj.val().split(','),
809
- arr = jQuery(stack).not(selected).get();
810
- arr = jQuery.grep(arr, function(e) {
811
- return (e);
812
- });
813
- arr = jQuery.unique(arr);
814
- stack_obj.val(arr.join(','));
815
- GmediaSelect.msg_stack(true);
816
- //sel_obj.val('');
817
- //GmediaSelect.chk_none(false, cb_obj);
818
- //GmediaSelect.msg_selected(cb_obj);
819
- });
820
- }
821
- gmedia_DOM.on('click', '#cb_global', function() {
822
- if(jQuery(this).is(':checked')) {
823
- GmediaSelect.chk_all(false, cb_obj);
824
- } else {
825
- GmediaSelect.chk_none(false, cb_obj);
826
- }
827
- GmediaSelect.msg_selected(cb_obj, true);
828
- });
829
- gmedia_DOM.on('click', '#cb_global-btn li a', function(e) {
830
- var sel = jQuery(this).data('select');
831
- switch(sel) {
832
- case 'total':
833
- GmediaSelect.chk_all(false, cb_obj);
834
- break;
835
- case 'none':
836
- GmediaSelect.chk_none(false, cb_obj);
837
- break;
838
- case 'reverse':
839
- GmediaSelect.chk_toggle(false, cb_obj);
840
- break;
841
- case 'image':
842
- case 'audio':
843
- case 'video':
844
- GmediaSelect.chk_toggle(sel, cb_obj);
845
- break;
846
- }
847
- GmediaSelect.msg_selected(cb_obj, true);
848
- e.preventDefault();
849
- });
850
- gmedia_DOM.on('change', '.gm-item-check input:checkbox, .cb_object input:checkbox', function() {
851
- var selected = jQuery('#gm-selected'),
852
- arr = selected.val();
853
- var cur = jQuery(this).val();
854
- if(jQuery(this).is(':checked')) {
855
- if(arr) {
856
- arr = arr + ',' + cur;
857
- } else {
858
- arr = cur;
859
- }
860
- } else {
861
- arr = jQuery.grep(arr.split(','), function(a) {
862
- return a != cur;
863
- }).join(',');
864
- }
865
- jQuery('#list-item-' + cur).toggleClass('gm-selected');
866
- selected.val(arr);
867
- GmediaSelect.msg_selected(cb_obj);
868
- });
869
-
870
- gmedia_DOM.on('click', '.gm-item-check input:radio', function() {
871
- var id = jQuery(this).val(), img, checked_thumb, data;
872
- jQuery('#list-item-' + id).addClass('gm-selected').siblings().removeClass('gm-selected');
873
- img = jQuery(this).closest('.thumbnail').find('.gmedia-thumb').clone();
874
- checked_thumb = jQuery('#gmedia-panel .panel-heading .checked_thumb');
875
- if(!checked_thumb.length){
876
- checked_thumb = jQuery('<div class="checked_thumb"></div>').appendTo(jQuery('#gmedia-panel .panel-heading'));
877
- }
878
- checked_thumb.html(img);
879
- data = {'id':id, 'src':img.attr('src')};
880
- window.parent.gmediaTempData = data;
881
- });
882
 
883
- if(jQuery('#gm-stack').length) {
884
- GmediaSelect.msg_stack();
885
- gmedia_DOM.on('click', '#gm-stack-clear', function(e) {
886
- jQuery('#gm-stack').val('');
887
- jQuery('.gm-stack input').prop('checked', false);
888
- GmediaSelect.msg_stack();
889
- e.preventDefault();
890
- });
891
- gmedia_DOM.on('click', '#gm-stack-show', function(e) {
892
- jQuery('#gm-stack-btn').submit();
893
- e.preventDefault();
894
- });
895
 
896
- }
897
- gmedia_DOM.on('change', '.gm-stack input:checkbox', function() {
898
- var selected = jQuery('#gm-stack'),
899
- arr = selected.val();
900
- var cur = jQuery(this).val();
901
- if(jQuery(this).is(':checked')) {
902
- if(arr) {
903
- arr = arr + ',' + cur;
904
- } else {
905
- arr = cur;
906
- }
907
- } else {
908
- arr = jQuery.grep(arr.split(','), function(a) {
909
- return a != cur;
910
- }).join(',');
911
- }
912
- selected.val(arr);
913
- GmediaSelect.msg_stack();
914
- });
915
 
916
- gmedia_DOM.on('click', '.term-label', function(e) {
917
- if('DIV' == e.target.nodeName) {
918
- if(!jQuery('#gm-list-table').data('edit')) {
919
- var cb = jQuery('input:checkbox', this);
920
- cb.prop("checked", !cb.prop("checked")).change();
921
- jQuery(this).closest('.term-list-item').toggleClass('gm-selected');
922
- } else {
923
- jQuery('#gm-list-table').data('edit', false);
924
- }
925
- }
926
- });
927
  }
928
- }
929
-
930
- var GmediaFunction = {
931
- confirm: function(txt) {
932
- if(!txt) {
933
- return true;
 
934
  }
935
- var r = false;
936
- //noinspection UnusedCatchParameterJS
937
- try{
938
- r = confirm(txt);
939
  }
940
- catch(err){
941
- alert('Disable Popup Blocker');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
942
  }
943
- return r;
944
- },
945
- init: function() {
946
- jQuery('#toplevel_page_GrandMedia').addClass('current').removeClass('wp-not-current-submenu');
947
- if(!("ontouchstart" in document.documentElement)) {
948
- jQuery('html').addClass('no-touch');
949
  }
 
 
 
 
950
 
951
- //jQuery(document).ajaxStart(function(a,b,c){
952
- // //jQuery('body').addClass('gmedia-busy');
953
- // jQuery('.panel-heading .spinner').addClass('is-active');
954
- //}).ajaxStop(function(){
955
- // //jQuery('body').removeClass('gmedia-busy');
956
- // jQuery('.panel-heading .spinner').removeClass('is-active');
957
- //});
 
 
 
 
 
 
 
 
 
 
 
 
958
 
959
- gmedia_DOM.on('click', '[data-confirm]', function() {
960
- return GmediaFunction.confirm(jQuery(this).data('confirm'));
961
- });
 
 
 
 
962
 
963
- jQuery(document).on('click.gmedia', '.gm_service_action', function() {
964
- var el = jQuery(this),
965
- service = jQuery(this).attr('data-action'),
966
- nonce = jQuery(this).attr('data-nonce');
967
- var post_data = {
968
- action: 'gmedia_application',
969
- service: service,
970
- _wpnonce: nonce
971
- };
972
- jQuery.post(ajaxurl, post_data, function(data, textStatus, jqXHR) {
973
- console.log(data);
974
- el.siblings('.spinner').removeClass('is-active');
975
- if(data.error) {
976
- jQuery('#gmedia-service-msg-panel').prepend(data.error);
977
- } else if(data.message) {
978
- jQuery('#gmedia-service-msg-panel').html(data.message);
979
- }
980
- });
981
 
982
- el.siblings('.spinner').addClass('is-active');
983
- jQuery('.gmedia-service__message').remove();
984
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
985
 
986
- gmedia_DOM.on('click', '.show-settings-link', function(e) {
987
- e.preventDefault();
988
- jQuery('#show-settings-link').trigger('click');
989
- });
990
 
991
- gmedia_DOM.on('click', '.fit-thumbs', function(e) {
992
- e.preventDefault();
993
- jQuery(this).toggleClass('btn-success btn-default');
994
- jQuery('.display-as-grid').toggleClass('invert-ratio');
995
- jQuery.get(jQuery(this).attr('href'), {ajaxload: 1});
996
- });
997
 
998
- gmedia_DOM.on('click', '.gm-cell-more-btn, .gm-cell-title', function() {
999
- jQuery(this).parent().toggleClass('gm-cell-more-active');
1000
- });
 
 
 
1001
 
1002
- jQuery('div.gmedia-modal', gmedia_DOM).each(function(){
1003
- var id = jQuery(this).attr('id');
1004
- jQuery('body').children('#' + id).remove();
1005
- jQuery(this).appendTo('body');
1006
- });
1007
- gmedia_DOM.on('click', 'a.gmedia-modal', function(e) {
1008
- jQuery('body').addClass('gmedia-busy');
1009
- var modal_div = jQuery(jQuery(this).attr('href'));
1010
- var post_data = jQuery(this).data();
1011
- post_data['_wpnonce'] = jQuery('#_wpnonce').val();
1012
- jQuery.post(ajaxurl, post_data, function(data, textStatus, jqXHR) {
1013
- if(!data || ('-1' == data)) {
1014
- jQuery('body').removeClass('gmedia-busy');
1015
- alert(data);
1016
- return false;
1017
- }
1018
- jQuery('.modal-dialog', modal_div).html(data);
1019
- modal_div.modal({
1020
- backdrop: 'static',
1021
- show: true,
1022
- keyboard: false
1023
- }).one('hidden.bs.modal', function() {
1024
- jQuery('.modal-dialog', this).empty();
1025
- });
1026
- jQuery('body').removeClass('gmedia-busy');
1027
- });
1028
- e.preventDefault();
1029
- });
1030
 
1031
- gmedia_DOM.on('click', 'a.gmedit-modal', function(e) {
1032
- e.preventDefault();
1033
- var modal_div = jQuery(jQuery(this).data('target'));
1034
- jQuery('.modal-content', modal_div).html(
1035
- jQuery('<iframe />', {
1036
- name: 'gmeditFrame',
1037
- id: 'gmeditFrame',
1038
- width: '100%',
1039
- height: '500',
1040
- src: jQuery(this).attr('href')
1041
- }).css({display: 'block', margin: '4px 0'})
1042
- );
1043
- modal_div.modal({
1044
- backdrop: true,
1045
- show: true,
1046
- keyboard: false
1047
- }).one('hidden.bs.modal', function() {
1048
- jQuery('.modal-content', this).empty();
1049
- });
 
 
 
 
1050
  });
 
 
 
 
1051
 
1052
- jQuery(document).on('click.gmedia', 'a.preview-modal', function(e) {
1053
- e.preventDefault();
1054
- var initiator = jQuery(this),
1055
- data = initiator.data(),
1056
- modal_div = jQuery(data['target']),
1057
- modal_dialog = jQuery('.modal-dialog', modal_div),
1058
- modal_body = jQuery('.modal-body', modal_div),
1059
- modal_title = jQuery('.modal-title', modal_div);
1060
- modal_title.text(jQuery(this).attr('data-title')? jQuery(this).attr('data-title') : jQuery(this).attr('title'));
1061
-
1062
- if(data['metainfo']) {
1063
- modal_dialog.addClass('modal-md');
1064
- modal_body.html(jQuery('#metainfo_' + data['metainfo']).html());
1065
- } else {
1066
- var r = data['width'] / data['height'],
1067
- w = Math.min(jQuery(window).width() * 0.98 - 32, data['width']),
1068
- h = w / r;
1069
- modal_dialog.css({'width': (data['width'] + 32), 'max-width': '98%'});
1070
- if(data['cls']){
1071
- modal_dialog.addClass(data['cls']);
1072
- }
1073
- modal_body.html(
1074
- jQuery('<iframe />', {
1075
- name: 'previewFrame',
1076
- id: 'previewFrame',
1077
- width: '100%',
1078
- height: h,
1079
- src: jQuery(this).attr('href')
1080
- }).on('load', function(){
1081
- jQuery(this.contentWindow.document.body).css('margin', 0);
1082
- jQuery('.modal-backdrop', modal_div).css({'width': (data['width'] + 32), 'min-width': '100%'});
1083
- }).css({display: 'block', margin: '4px 0'})
1084
- );
1085
- }
1086
 
1087
- initiator.addClass('previewModal_initiator');
1088
- modal_div.modal({
1089
- backdrop: true,
1090
- show: true
1091
- }).one('hidden.bs.modal', function() {
1092
- if (jQuery('div.gmedia-modal:visible').length) {
1093
- jQuery('body').addClass('modal-open');
1094
- }
1095
- modal_title.empty();
1096
- modal_body.empty();
1097
- modal_dialog.removeAttr('style').attr('class', 'modal-dialog');
1098
- if(modal_div.attr('data-refresh')){
1099
- modal_div.removeAttr('data-refresh');
1100
- jQuery('.panel-heading .spinner').addClass('is-active');
1101
- var url = window.location.href;
1102
- jQuery.get(url, function(data) {
1103
- jQuery('#gmedia-panel').html(jQuery('#gmedia-panel', data).html());
1104
- GmediaInit();
1105
- jQuery('.panel-heading .spinner').removeClass('is-active');
1106
- });
1107
- }
1108
- initiator.removeClass('previewModal_initiator');
1109
- });
1110
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1111
 
1112
- jQuery(document).on('click.gmedia', '#previewModal .select_gmedia_image .btn-primary', function() {
1113
- var img, form = jQuery('.previewModal_initiator').closest('form');
1114
- form.find('.gmedia-cover-id').val(window.gmediaTempData.id).trigger('change');
1115
- img = form.find('.gmedia-cover-image img:first-child');
1116
- if(img.length){
1117
- img.attr('src', window.gmediaTempData.src);
1118
- } else {
1119
- jQuery('<img src="" alt="" />').attr('src', window.gmediaTempData.src).appendTo(form.find('.gmedia-cover-image'));
1120
- }
1121
- jQuery('#previewModal').modal('hide');
1122
- });
 
1123
 
1124
- jQuery(document).on('click.gmedia', '#previewModal .select_gmedia_related .btn-primary', function() {
1125
- var relatedDiv = jQuery('.previewModal_initiator').closest('.form-group').find('.related-media-previews');
1126
- var fields = relatedDiv.find('input');
1127
- var valData = [],
1128
- getData = [];
1129
- if(fields){
1130
- fields.each(function(){
1131
- valData.push(jQuery(this).val());
1132
- });
1133
- }
1134
- var storage = getStorage();
1135
- storedData = storage.get('gmedia_library:frame').split('.');
1136
- jQuery.each(storedData, function(i, id) {
1137
- if(!id) {
1138
- return true;
1139
- }
1140
- if(jQuery.inArray(id, valData) === -1) {
1141
- getData.push(id);
1142
- }
 
 
 
 
 
 
 
 
 
 
 
 
1143
  });
1144
- if(getData.length){
1145
- jQuery.get(ajaxurl, {action: 'gmedia_get_data', gmedia__in: getData}, function(data, textStatus, jqXHR) {
1146
- if(jQuery.isArray(data) && data.length){
1147
- var thumbHTML
1148
- jQuery.each(data, function(i, item){
1149
- thumbHTML = '<p class="thumbnail gmedia-related-image">' +
1150
- '<span class="image-wrapper"><img class="gmedia-thumb" src="" alt=""></span>' +
1151
- '<span class="gm-remove">&times;</span>' +
1152
- '<input type="hidden" name="meta[_related][]" value="">' +
1153
- '</p>';
1154
- jQuery(thumbHTML).find('img').attr('src', item.url_thumb).end().find('input').val(item.ID).end().appendTo(relatedDiv);
1155
- });
1156
- relatedDiv.sortable( "refresh" );
1157
- relatedDiv.closest('form').find('input[name="title"]').trigger('change');
1158
- }
1159
- });
1160
- }
1161
- storage.set('gmedia_library:frame', '');
1162
- jQuery('#previewModal').modal('hide');
1163
  });
 
 
 
 
1164
 
1165
- jQuery(document).on('click.gmedia', '.related-media-previews .gm-remove', function() {
1166
- var inpTitle = jQuery(this).closest('form').find('input[name="title"]');
1167
- jQuery(this).closest('.gmedia-related-image').remove();
1168
- inpTitle.trigger('change');
1169
- });
1170
 
1171
- jQuery(document).on('click.gmedia', '#previewModal .select_gmedia:not(.assign_gmedia_term) .btn-primary', function() {
1172
- var field = jQuery('.previewModal_initiator').closest('.form-group').find('.form-control');
1173
- var valData = field.val().split(',');
1174
- var storedData = getStorage();
1175
- storedData = storedData.get('gmedia_library:frame').split('.');
1176
- valData = jQuery.grep(valData, function(e) {
1177
- return e.trim();
1178
- });
1179
- jQuery.each(storedData, function(i, id) {
1180
- if(!id) {
1181
- return true;
1182
- }
1183
- if(jQuery.inArray(id, valData) === -1) {
1184
- valData.push(id);
1185
- }
1186
- });
1187
- field.val(valData.join(','));
1188
- jQuery('#previewModal').modal('hide');
1189
- });
1190
 
1191
- jQuery(document).on('click.gmedia', '#previewModal .assign_gmedia_term .btn-primary', function() {
1192
- jQuery('.panel-heading .spinner').addClass('is-active');
1193
- var url = window.location.href,
1194
- post_data = jQuery('#gmedia-assign-term').serialize();
1195
- jQuery.post(url, post_data, function(data) {
1196
- jQuery('.gmedia_term__in').html(jQuery('.gmedia_term__in', data).html());
1197
- GmediaInit();
1198
- jQuery('.panel-heading .spinner').removeClass('is-active');
1199
- });
1200
- jQuery('#previewModal').modal('hide');
1201
- //console.log(window.gmediaTempData);
1202
- });
1203
 
1204
- jQuery(document).on('click.gmedia focus.gmedia', 'input.sharelink', function() {
1205
- this.setSelectionRange(0, this.value.length);
1206
- });
1207
- jQuery(document).on('keyup.gmedia', 'input.sharetoemail', function() {
1208
- jQuery('.sharebutton').prop('disabled', !validateEmail(this.value));
1209
- });
1210
- jQuery(document).on('click.gmedia', '.sharebutton', function() {
1211
- var sharetoemail = jQuery('input.sharetoemail');
1212
- if(!validateEmail(sharetoemail.val())) {
1213
- sharetoemail.focus();
1214
- sharetoemail.parent().addClass('has-error');
1215
- return false;
1216
- }
1217
- var post_data = jQuery('#shareForm').serialize();
1218
- jQuery.post(ajaxurl, post_data, function(data, textStatus, jqXHR) {
1219
- jQuery('body').removeClass('gmedia-busy');
1220
- if(data) {
1221
- jQuery('#gm-message').append(data);
1222
- }
1223
- });
1224
- jQuery('#shareModal').modal('hide');
1225
- });
1226
- gmedia_DOM.on('click', 'a.share-modal', function(e) {
1227
- e.preventDefault();
1228
- var data = jQuery(this).data(),
1229
- modal_div = jQuery(data['target']),
1230
- postlink = jQuery(this).attr('href'),
1231
- cloudlink = jQuery(this).attr('data-gmediacloud'),
1232
- sharetoemail = jQuery('input.sharetoemail'),
1233
- cloudlink_checked = false;
1234
-
1235
- if(postlink) {
1236
- jQuery('.sharelink_post', modal_div).show();
1237
- jQuery('.sharelink_post input[type="text"]', modal_div).val(postlink);
1238
- jQuery('.sharelink_post a', modal_div).attr('href', postlink);
1239
- } else {
1240
- jQuery('.sharelink_post', modal_div).hide();
1241
- jQuery('.sharelink_post input[type="radio"]', modal_div).prop('checked', false);
1242
- cloudlink_checked = true;
1243
- }
1244
- if(cloudlink) {
1245
- jQuery('.sharelink_page', modal_div).show();
1246
- jQuery('.sharelink_page input[type="text"]', modal_div).val(cloudlink);
1247
- jQuery('.sharelink_page a', modal_div).attr('href', cloudlink);
1248
- if(cloudlink_checked) {
1249
- jQuery('.sharelink_page input[type="radio"]', modal_div).prop('checked', true);
1250
- }
1251
- } else {
1252
- jQuery('.sharelink_page', modal_div).hide();
1253
- }
1254
- jQuery('.sharebutton').prop('disabled', !validateEmail(sharetoemail.val()));
1255
-
1256
- modal_div.modal({
1257
- backdrop: true,
1258
- show: true,
1259
- keyboard: false
1260
- }).one('shown.bs.modal', function() {
1261
- jQuery('input.sharelink', this).focus();
1262
- }).one('hidden.bs.modal', function() {
1263
- jQuery('input.sharelink', this).val('');
1264
- });
1265
- });
 
 
1266
 
1267
- gmedia_DOM.on('click', '.buildquery-modal', function(e) {
1268
- e.preventDefault();
1269
- var data = jQuery(this).data(),
1270
- modal_div = jQuery(jQuery(this).attr('href')),
1271
- query_field = jQuery(jQuery(this).attr('id') + '_field');
1272
- query = query_field.val();
1273
-
1274
- modal_div.modal({
1275
- backdrop: true,
1276
- show: true,
1277
- keyboard: false
1278
- }).one('shown.bs.modal', function() {
1279
- if(query) {
1280
- query = gm_parse_query(query);
1281
- console.log(query);
1282
- }
1283
- }).one('hidden.bs.modal', function() {});
1284
- });
1285
 
1286
- jQuery(document).on('click.gmedia', '.buildquerysubmit', function() {
1287
- var qform = jQuery('#buildQuery :input').filter(function() {
1288
- return !!jQuery(this).val();
1289
- });
1290
 
1291
- qform = decodeURIComponent(qform.serialize());
1292
- console.log(qform);
1293
- jQuery('#build_query_field').val(qform);
1294
- jQuery('#buildQuery').modal('hide');
1295
- });
1296
- gmedia_DOM.on('click', 'a.newcustomfield-modal', function(e) {
1297
- e.preventDefault();
1298
- var data = jQuery(this).data(),
1299
- modal_div = jQuery(jQuery(this).attr('href'));
1300
-
1301
- modal_div.modal({
1302
- backdrop: false,
1303
- show: true,
1304
- keyboard: false
1305
- }).one('shown.bs.modal', function() {
1306
- jQuery('input.newcustomfield-for-id', this).val(data['gmid']);
1307
- }).one('hidden.bs.modal', function() {
1308
- jQuery(':input.form-control, input.newcustomfield-for-id', this).val('');
1309
- if(jQuery('.newcfield', this).length) {
1310
- jQuery('a.gmediacustomstuff').click();
1311
- }
1312
- });
1313
- });
1314
- jQuery(document).on('click.gmedia', '.customfieldsubmit', function() {
1315
- var cform = jQuery('#newCustomFieldForm');
1316
- if(!jQuery('.newcustomfield-for-id', cform).val()) {
1317
- jQuery('#newCustomFieldModal').modal('hide');
1318
- alert('No ID');
1319
- return false;
 
 
 
 
 
 
 
 
 
1320
  }
1321
- var post_data = cform.serialize();
1322
- jQuery.post(ajaxurl, post_data, function(data, textStatus, jqXHR) {
1323
- jQuery('body').removeClass('gmedia-busy');
1324
- if(data.success) {
1325
- jQuery('#newCustomFieldModal').modal('hide').one('hidden.bs.modal', function() {
1326
- //noinspection JSUnresolvedVariable
1327
- if(data.newmeta_form) {
1328
- //noinspection JSUnresolvedVariable
1329
- jQuery('#newmeta').replaceWith(data.newmeta_form);
1330
- }
1331
- });
1332
- jQuery('.row:last', '#gmediacustomstuff_' + data.id).append(data.success.data);
1333
- } else {
1334
- if(data.error) {
1335
- if('100' == data.error.code) {
1336
- jQuery('#newCustomFieldModal').modal('hide');
1337
- }
1338
- alert(data.error.message);
1339
- } else {
1340
- console.log(data);
1341
- }
1342
- }
1343
- });
1344
- });
1345
- gmedia_DOM.on('click', '.delete-custom-field', function() {
1346
- var t = jQuery(this).closest('.form-group'),
1347
- post_data = convertInputsToJSON(jQuery(':input', t));
1348
- if(!post_data) {
1349
- return false;
1350
  }
1351
- var meta_type = jQuery(this).closest('fieldset').attr('data-metatype');
1352
- post_data.action = meta_type + '_delete_custom_field';
1353
- post_data.ID = jQuery(this).closest('form').attr('data-id');
1354
- post_data._wpnonce_custom_field = jQuery('#_wpnonce_custom_field').val();
1355
- jQuery.post(ajaxurl, post_data, function(data, textStatus, jqXHR) {
1356
- jQuery('body').removeClass('gmedia-busy');
1357
- //noinspection JSUnresolvedVariable
1358
- if(data.deleted) {
1359
- //noinspection JSUnresolvedVariable
1360
- jQuery.each(data.deleted, function(i, val) {
1361
- jQuery('.gm-custom-meta-' + val).remove();
1362
- });
1363
- } else {
1364
- if(data.error) {
1365
- alert(data.error.message);
1366
- } else {
1367
- console.log(data);
1368
- }
1369
- }
1370
- });
1371
- });
1372
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1373
 
1374
- gmedia_DOM.on('change modified', 'form.edit-gmedia :input:not([name="doaction[]"])', function() {
1375
- if(jQuery(this).hasClass('edit-gmedia-ignore')) {
1376
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1377
  }
1378
- jQuery('body').addClass('gmedia-busy');
1379
- jQuery('.panel-heading .spinner').addClass('is-active');
1380
- var post_data = {
1381
- action: 'gmedia_update_data', data: jQuery(this).closest('form').serialize(), _wpnonce: jQuery('#_wpnonce').val()
1382
- };
1383
- jQuery.post(ajaxurl, post_data, function(data, textStatus, jqXHR) {
1384
- console.log(data);
1385
- var item = jQuery('#list-item-' + data.ID);
1386
- item.find('.modified').text(data.modified);
1387
- //noinspection JSUnresolvedVariable
1388
- item.find('.status-album').attr('class', 'form-group status-album bg-status-' + data.album_status);
1389
- item.find('.status-item').attr('class', 'form-group status-item bg-status-' + data.status);
1390
- if(data.thumbnail) {
1391
- item.find('.gmedia-cover-image').html(data.thumbnail);
1392
- }
1393
- //if(data.tags) {
1394
- // item.find('.gmedia_tags_input').val(data.tags);
1395
- //}
1396
- //noinspection JSUnresolvedVariable
1397
- if(data.meta_error) {
1398
- jQuery.each(data.meta_error, function(i, err) {
1399
- console.log(err);
1400
- alert(err.meta_key + ': ' + err.message);
1401
- if(err.meta_value) {
1402
- jQuery('.gm-custom-field-' + err.meta_id).val(err.meta_value);
1403
- }
1404
- });
1405
- }
1406
- jQuery('body').removeClass('gmedia-busy');
1407
- jQuery('.panel-heading .spinner').removeClass('is-active');
1408
- });
1409
- });
1410
 
1411
- gmedia_DOM.on('click', '.gm-toggle-cb', function(e) {
1412
- var checkBoxes = jQuery(this).attr('href');
1413
- jQuery(checkBoxes + ' :checkbox').each(function() {
1414
- jQuery(this).prop("checked", !jQuery(this).prop("checked"));
1415
- });
1416
- e.preventDefault();
1417
- });
1418
- jQuery(document).on('click.gmedia', '.linkblock [data-href]', function() {
1419
- window.location.href = jQuery(this).data('href');
1420
- });
1421
 
1422
- gmedia_DOM.on('click', '.gmedia-import', function() {
1423
- jQuery('#import-action').val(jQuery(this).attr('name'));
1424
- jQuery('#importModal').modal({
1425
- backdrop: 'static',
1426
- show: true,
1427
- keyboard: false
1428
- }).one('shown.bs.modal', function() {
1429
- jQuery('#import_form').submit();
1430
- }).one('hidden.bs.modal', function() {
1431
- var btn = jQuery('#import-done');
1432
- btn.text(btn.data('reset-text')).prop('disabled', true);
1433
- jQuery('#import_window').attr('src', 'about:blank');
1434
- });
1435
- });
1436
 
1437
- gmedia_DOM.on('click', '.module_install', function(e) {
1438
- e.preventDefault();
1439
- jQuery('body').addClass('gmedia-busy');
1440
- var module = jQuery(this).data('module');
1441
- var btn = jQuery('.module_install').filter('[data-module="' + module + '"]');
1442
- btn.text(btn.data('loading-text'));
1443
- var post_data = {
1444
- action: 'gmedia_module_install', download: jQuery(this).attr('href'), module: module, _wpnonce: jQuery('#_wpnonce').val()
1445
- };
1446
- var pathname = window.location.href + '&time=' + jQuery.now();
1447
- jQuery.post(ajaxurl, post_data, function(data, status, xhr) {
1448
- setTimeout(function(){
1449
- jQuery('#gmedia_modules').load(pathname + ' #gmedia_modules_wrapper', function(){
1450
- setTimeout(function(){
1451
- var update_count = jQuery('#gmedia_modules').find('#gmedia_modules_wrapper').attr('data-update');
1452
- if(parseInt(update_count)){
1453
- jQuery('.gm-module-count').html(update_count);
1454
- } else {
1455
- jQuery('.gm-module-count').remove();
1456
- }
1457
- }, 1);
1458
- });
1459
- }, 1);
1460
- jQuery('#gmedia_modules').before(data);
1461
- jQuery('body').removeClass('gmedia-busy');
1462
- });
1463
- });
 
1464
 
1465
- gmedia_DOM.on('keydown', 'form :input:visible:not(:submit,:button,:reset,textarea,.allow-key-enter)', function(e) {
1466
- var charCode = e.charCode || e.keyCode || e.which;
1467
- if(13 == charCode && !jQuery(this).parent().hasClass('selectize-input')) {
1468
- var inputs = jQuery(this).parents("form").eq(0).find(":input:visible");
1469
- var inp = inputs[inputs.index(this) + 1];
1470
- if(inp !== null) {
1471
- jQuery(inp).focus();
1472
- var inp_type = jQuery(inp).attr('type');
1473
- if(!!inp_type && (inp_type == 'text' || inp_type == 'number')) {
1474
- console.log(inp);
1475
- inp.setSelectionRange(0, inp.value.length);
1476
- }
1477
- }
1478
- e.preventDefault();
1479
- return false;
1480
- }
1481
- });
1482
 
1483
- var preset_popover = function() {
1484
- jQuery('#module_presets').popover({
1485
- container: '#module_preset',
1486
- content: function() {
1487
- return jQuery('#_module_presets').html();
1488
- },
1489
- html: true,
1490
- placement: 'bottom'
1491
- }).on('show.bs.popover', function() {
1492
- jQuery(this).addClass('active');
1493
- }).on('hide.bs.popover', function() {
1494
- jQuery(this).removeClass('active');
1495
- });
1496
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1497
  preset_popover();
1498
- gmedia_DOM.on('click', '#module_preset .ajax-submit', function(e) {
1499
- e.preventDefault();
1500
- jQuery('body').addClass('gmedia-busy');
1501
- var form = jQuery('#gmedia-edit-term');
1502
- var post_data = form.serializeArray();
1503
- post_data.push({name: jQuery(this).attr('name'), value: 1});
1504
- var pathname = window.location.href;
1505
- jQuery.post(pathname, jQuery.param(post_data), function(data, status, xhr) {
1506
- jQuery('body').removeClass('gmedia-busy');
1507
- data = jQuery(data).find('#gmedia-container');
1508
- jQuery('#gm-message').append(jQuery('#gm-message', data).html());
1509
- jQuery('#save_buttons').html(jQuery('#save_buttons', data).html());
1510
- jQuery('#save_buttons_duplicate').html(jQuery('#save_buttons_duplicate', data).html());
1511
- jQuery('#module_preset').html(jQuery('#module_preset', data).html());
1512
- preset_popover();
1513
- });
1514
- });
1515
- jQuery(document).on('click.gmedia', function(e) {
1516
- if(jQuery(e.target).data('toggle') !== 'popover'
1517
- && jQuery(e.target).parents('.popover.in').length === 0) {
1518
- jQuery('[data-toggle="popover"]').popover('hide');
1519
- }
1520
- });
1521
-
1522
- gmedia_DOM.on('click', '[data-clicktarget]', function(e){
1523
- e.preventDefault();
1524
- var id = jQuery(this).attr('data-clicktarget');
1525
- jQuery('#' + id).click();
1526
- });
1527
-
1528
- gmedia_DOM.on('click', '#module_preset .delpreset span, .module_presets .delpreset span', function() {
1529
- jQuery('body').addClass('gmedia-busy');
1530
- var module_preset = this;
1531
- var preset_item_li = jQuery(this).closest('li');
1532
- var preset_id = jQuery(this).data('id');
1533
- var post_data = {
1534
- action: 'gmedia_module_preset_delete', preset_id: preset_id, _wpnonce: jQuery('#_wpnonce').val()
1535
- };
1536
- jQuery.post(ajaxurl, post_data, function(data, status, xhr) {
1537
- if(data.error) {
1538
- jQuery('#gm-message').append(data.error);
1539
- } else {
1540
- preset_item_li.remove();
1541
- if('module_presets_list' !== jQuery(this).attr('id')) {
1542
- var _module_presets = jQuery('#module_preset').find('.popover-content').html();
1543
- jQuery('#_module_presets').replaceWith('<script type="text/html" id="_module_presets">' + _module_presets + '</script>');
1544
- }
1545
- }
1546
- jQuery('body').removeClass('gmedia-busy');
1547
- });
1548
- });
1549
 
1550
- gmedia_DOM.on('click', '.filter-modules > *', function(){
1551
- jQuery('.filter-modules > .btn-primary').removeClass('btn-primary').addClass('btn-default');
1552
- jQuery('.filter-modules > .label-primary').removeClass('label-primary').addClass('label-default');
1553
- if(jQuery(this).is('button')){
1554
- jQuery(this).addClass('btn-primary').removeClass('btn-default');
1555
- } else{
1556
- jQuery(this).addClass('label-primary').removeClass('label-default');
1557
- }
1558
- var filter = jQuery(this).attr('data-filter');
1559
- jQuery('#gmedia_modules .media').removeClass('module-filtered').filter('.module-' + filter).addClass('module-filtered');
1560
- if(!jQuery('#gmedia_modules .module-filtered').length){
1561
- if('not-installed' == filter){
1562
- jQuery('#gmedia_modules .nomodules.nomodule-' + filter).addClass('module-filtered');
1563
- } else{
1564
- jQuery('#gmedia_modules .nomodules.nomodule-tag').addClass('module-filtered');
1565
- }
1566
- }
1567
- })
1568
 
1569
- if(jQuery(".panel-fixed-header").length) {
1570
- setPanelHeadersWidth();
1571
- setTimeout(function() {
1572
- setPanelHeadersWidth();
1573
- }, 800);
1574
- jQuery(window).on('resize.gmedia', function() {
1575
- setPanelHeadersWidth();
1576
- });
1577
- jQuery(document).on('click.gmedia', '#collapse-menu', function() {
1578
- setTimeout(function() {
1579
- setPanelHeadersWidth();
1580
- }, 10);
1581
- });
 
 
 
 
 
 
 
 
 
1582
 
1583
- jQuery(window).on('scroll.gmedia', function() {
1584
- UpdatePanelHeaders();
1585
- /*clearTimeout(jQuery.data(this, 'scrollTimer'));
1586
- jQuery.data(this, 'scrollTimer', setTimeout(function() {
1587
- UpdatePanelHeaders();
1588
- console.log("Haven't scrolled in 250ms!");
1589
- }, 250));*/
1590
- }).trigger("scroll.gmedia");
 
 
 
 
 
 
1591
  }
 
 
 
 
 
1592
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1593
  }
1594
- };
1595
 
 
 
1596
 
1597
  window.closeModal = function(id) {
1598
- jQuery('#' + id).modal('hide');
1599
  };
1600
 
1601
-
1602
  /*
1603
  * jQuery functions for GRAND Media
1604
  */
1605
- function GmediaInit(){
1606
- gmedia_DOM = jQuery('#gmedia-container');
1607
- gmedia_DOM.off();
1608
- jQuery(window).off('.gmedia');
1609
- jQuery(document).off('.gmedia');
1610
-
1611
- GmediaSelect.init();
1612
- GmediaFunction.init();
1613
-
1614
- if(jQuery('body').hasClass('GrandMedia')) {
1615
- GmediaLibrary.init();
 
 
 
 
 
 
 
 
 
 
 
 
 
1616
  }
1617
- if(jQuery('body').hasClass('GrandMedia_AddMedia')) {
1618
- GmediaAddMedia.init();
 
 
 
 
 
 
 
 
 
1619
  }
1620
- if(jQuery('body').is('.GrandMedia_Tags,.GrandMedia_Categories,.GrandMedia_Albums,.GrandMedia_Galleries')) {
1621
- GmediaTerms.init();
1622
  }
1623
-
1624
- var helper, helper_width, title;
1625
- jQuery('[title]', gmedia_DOM).each(function(){
1626
- title = jQuery(this).attr('title');
1627
- if(title) {
1628
- jQuery(this).attr('title','').attr('data-title', title);
1629
- }
1630
- });
1631
- gmedia_DOM.on('mouseenter', '[title]', function(e) {
1632
- title = jQuery(this).attr('data-title');
1633
- if(title) {
1634
- helper = jQuery('<div id="gmedia-data-helper">' + title + '</div>').appendTo('body');
1635
- helper_width = 0;
1636
- if(e.pageX > (window.innerWidth / 2)) {
1637
- helper_width = helper.width() - 25;
1638
- helper.addClass('tiptoleft');
1639
- }
1640
- helper.css({left: e.clientX - helper_width - 25, top: e.clientY + 25});
1641
- } else{
1642
- jQuery(this).removeAttr('title');
1643
- }
1644
- }).on('mousemove', '[title]', function(e) {
1645
- if(helper) {
1646
- helper.css({left: e.clientX - helper_width - 25, top: e.clientY + 25});
1647
- }
1648
- }).on('mouseleave', '[title]', function(e) {
1649
- jQuery('#gmedia-data-helper').remove();
1650
- helper = null;
1651
- });
1652
  }
1653
- jQuery(document).on('ready', function() {
1654
- GmediaInit();
 
1655
  });
1656
 
1657
  function convertInputsToJSON(form) {
1658
- var array = jQuery(form).serializeArray();
1659
- var json = {};
1660
 
1661
- jQuery.each(array, function() {
1662
- json[this.name] = this.value || '';
1663
- });
1664
 
1665
- return json;
1666
  }
1667
 
1668
  function gm_parse_query(s) {
1669
- var j = {},
1670
- res = s.split(/&/gm).map(function(e) {
1671
- var o = e.split(/=/),
1672
- pt = j;
1673
- if(typeof o[1] == 'undefined') {
1674
- o[1] = '';
1675
- }
1676
- o[0].replace(/^(\w+)\[([^&]*)\]/, '$1][$2').split(/\]\[/).map(function(e, i, a) {
1677
- if(e === '') {
1678
- e = Object.keys(pt).length;
1679
- }
1680
- pt = (pt[e] = pt[e] || (i == a.length - 1? decodeURIComponent(o[1].replace(/\+/, ' ')) : {}));
1681
- });
1682
- });
1683
- return j;
1684
  }
1685
 
1686
  function validateEmail(email) {
1687
- var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
1688
- return re.test(email);
1689
  }
1690
 
1691
  function getStorage() {
1692
- // use document.cookie:
1693
- return {
1694
- set: function(id, data) {
1695
- document.cookie = id + '=' + encodeURIComponent(data);
1696
- },
1697
- get: function(id) {
1698
- var cookies = document.cookie, parsed = {};
1699
- cookies.replace(/([^=]+)=([^;]*);?\s*/g, function(whole, key, value) {
1700
- parsed[key] = decodeURIComponent(value);
1701
- });
1702
- return parsed[id];
1703
- }
1704
- };
1705
  }
1706
 
1707
- function getDocHeight(id){
1708
- var H;
1709
- if(id){
1710
- H = Math.max(
1711
- jQuery('#' + id).height(),
1712
- document.getElementById(id).clientHeight
1713
- );
1714
- } else {
1715
- H = Math.max(
1716
- jQuery(document).height(),
1717
- jQuery(window).height(),
1718
- document.documentElement.clientHeight
1719
- );
1720
- }
 
 
 
 
1721
 
1722
- return H;
1723
- };
1724
- /*
1725
- function gmHashCode(str){
1726
- var l = str.length,
1727
- hash = 5381 * l * (str.charCodeAt(0) + l);
1728
- for(var i = 0; i < str.length; i++){
1729
- hash += Math.floor((str.charCodeAt(i) + i + 0.33) / (str.charCodeAt(l - i - 1) + l) + (str.charCodeAt(i) + l) * (str.charCodeAt(l - i - 1) + i + 0.33));
1730
- }
1731
- return hash;
1732
- }
1733
- function gmCreateKey(site, lic, uuid){
1734
- if(!lic){
1735
- lic = '0:lk';
1736
- }
1737
- if(!uuid){
1738
- uuid = 'xyxx-xxyx-xxxy';
1739
- }
1740
- var d = gmHashCode((site + ':' + lic).toLowerCase());
1741
- var p = d;
1742
- uuid = uuid.replace(/[xy]/g, function(c){
1743
- var r = d % 16 | 0, v = c == 'x'? r : (r & 0x7 | 0x8);
1744
- d = Math.floor(d * 15 / 16);
1745
- return v.toString(16);
1746
- });
1747
- var key = p + ': ' + lic + '-' + uuid;
1748
- return key.toLowerCase();
1749
- }
1750
- */
1751
 
1752
  function UpdatePanelHeaders() {
1753
- jQuery(".panel-fixed-header").each(function() {
1754
- var el = jQuery(this),
1755
- headerRow = jQuery(".panel-heading", this),
1756
- offset = el.offset(),
1757
- scrollTop = jQuery(window).scrollTop(),
1758
- floatingHeader = "panel-floatingHeader",
1759
- absoluteHeader = "panel-absoluteHeader",
1760
- pad_top = jQuery('#wpadminbar').height();
1761
-
1762
- if((scrollTop > offset.top - pad_top) && (scrollTop < offset.top - pad_top + (el.height() - headerRow.outerHeight(false)) + 4)) {
1763
- el.addClass(floatingHeader).removeClass(absoluteHeader);
1764
- } else if(scrollTop > (offset.top - pad_top + (el.height() - headerRow.outerHeight(false)))) {
1765
- el.addClass(absoluteHeader).removeClass(floatingHeader);
1766
- } else {
1767
- el.removeClass(absoluteHeader + ' ' + floatingHeader)
1768
- }
1769
- });
 
 
1770
  }
1771
 
1772
  function setPanelHeadersWidth() {
1773
- jQuery(".panel-fixed-header").each(function() {
1774
- var headerRow = jQuery(".panel-heading", this);
1775
- headerRow.css("width", jQuery(this).innerWidth());
1776
- jQuery(".panel-heading-fake", this).height(headerRow.outerHeight());
1777
- });
1778
  }
4
  var wp = window.wp || {};
5
  var gmedia_DOM;
6
  var GmediaLibrary = {
7
+ init: function() {
8
+ window.gm_wavesurfer = {};
9
+ if (jQuery('.gmedia-audio-item').length) {
10
 
11
+ jQuery('.gm-waveform-player').each(function() {
12
+ var data = jQuery(this).data();
13
+ data.gmid = data.id;
14
+ data.id = 'ws' + data.gmid;
15
 
16
+ if (data.peaks) {
17
+ jQuery('.gm-play', this).show();
18
+ jQuery('.gm-pause', this).hide();
19
 
20
+ GmediaLibrary.waveplayer(data, true);
21
+ }
22
+ });
23
+ gmedia_DOM.on('click', '.gm-waveform', function() {
24
+ var parent = jQuery(this).parent(),
25
+ data = parent.data();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
+ jQuery(this).remove();
 
 
 
 
 
 
 
 
 
 
 
28
 
29
+ GmediaLibrary.waveplayer(data);
30
 
31
+ if (data.peaks) {
32
+ //window.gm_wavesurfer[data.id].play();
33
  }
34
+ else {
35
+ window.gm_wavesurfer[data.id].on('waveform-ready', function() {
36
+ jQuery('.gm-play', parent).hide();
37
+ jQuery('.gm-pause', parent).show();
38
+ jQuery('.spinner', parent).removeClass('is-active');
39
+ var peaks = window.gm_wavesurfer[data.id].exportPCM(1800, 10000, true);
40
+ var post_data = {
41
+ action: 'gmedia_save_waveform',
42
+ id: data.gmid,
43
+ peaks: peaks,
44
+ _wpnonce: jQuery('#_wpnonce').val()
45
+ };
46
+ jQuery.post(ajaxurl, post_data, function(return_data, textStatus, jqXHR) {
47
+ var data_peaks = window.gm_wavesurfer[data.id].exportPCM(450, 10000, true);
48
+ parent.attr('data-peaks', data_peaks);
 
 
 
 
 
 
49
  });
50
+ });
51
  }
52
+ });
53
+ gmedia_DOM.on('click', '.gm-play, .gm-pause', function() {
54
+ var parent = jQuery(this).parent();
55
+ var data = parent.data();
56
+ if (!parent.hasClass('ws-loaded')) {
57
+ parent.addClass('ws-loaded');
58
+ window.gm_wavesurfer[data.id].load(data.file, data.peaks);
59
+ window.gm_wavesurfer[data.id].toggleInteraction();
60
+ window.gm_wavesurfer[data.id].play();
61
+ }
62
+ else {
63
+ window.gm_wavesurfer[data.id].playPause();
64
+ }
65
+ });
66
+
67
+ var resize;
68
+ jQuery(window).on('resize.gmedia', function() {
69
+ clearTimeout(resize);
70
+ resize = setTimeout(function() {
71
+ jQuery('.gm-waveform-player').each(function() {
72
+ var data = jQuery(this).data();
73
+ if (data.peaks && window.gm_wavesurfer[data.id]) {
74
+ window.gm_wavesurfer[data.id].load(data.file, data.peaks);
 
 
 
75
  }
76
+ });
77
+ }, 500);
78
+ });
79
+
80
+ }
81
+
82
+ if (jQuery('body').hasClass('GrandMedia_edit')) {
83
+ GmediaLibrary.editmode();
84
+ }
85
+
86
+ if (jQuery('body').hasClass('gmedia_library')) {
87
+ var previewFrame = jQuery('#previewFrame', window.parent.document);
88
+ jQuery(window).on('load.gmedia', function() {
89
+ setTimeout(function() {
90
+ previewFrame.animate({'height': getDocHeight('gmedia_iframe_content') + 3}, 200);
91
+ }, 10);
92
+ });
93
+ var refresh = !jQuery('body').is('.GrandMedia_select_single, .GrandMedia_select_multiple');
94
+ var observer = new MutationObserver(function(mutations) {
95
+ previewFrame.height(getDocHeight('gmedia_iframe_content') + 3);
96
+ if (refresh) {
97
+ jQuery('#previewModal', window.parent.document).attr('data-refresh', 'true');
98
  }
99
+ });
100
+ var gmedia_iframe_content = window.document.getElementById('gmedia_iframe_content');
101
+ observer.observe(gmedia_iframe_content, {
102
+ childList: true,
103
+ subtree: true,
104
+ attributes: true,
105
+ attributeFilter: ['value']
106
+ });
107
+ }
108
 
109
+ },
110
+ waveplayer: function(data, draw) {
111
+ window.gm_wavesurfer[data.id] = Object.create(WaveSurfer);
112
+ window.gm_wavesurfer[data.id].init({
113
+ container: '#' + data.id,
114
+ waveColor: '#428bca',
115
+ progressColor: '#31708f',
116
+ backend: 'MediaElement',
117
+ renderer: 'Canvas',
118
+ height: 60,
119
+ interact: false,
120
+ barWidth: 0
121
+ });
122
+ // Play on audio load
123
+ var parent = jQuery(window.gm_wavesurfer[data.id].container).parent();
124
+
125
+ if (!parent.hasClass('ws-loaded')) {
126
+ if (draw) {
127
+ window.gm_wavesurfer[data.id].backend.setPeaks(data.peaks);
128
+ window.gm_wavesurfer[data.id].drawBuffer();
129
+ }
130
+ else {
131
+ parent.addClass('ws-loaded');
132
+ window.gm_wavesurfer[data.id].load(data.file, data.peaks);
133
+ window.gm_wavesurfer[data.id].toggleInteraction();
134
+ window.gm_wavesurfer[data.id].play();
135
+ }
136
+ }
137
+ else {
138
+ window.gm_wavesurfer[data.id].play();
139
+ }
140
+
141
+ jQuery(window.gm_wavesurfer[data.id].container).on('click', function(e) {
142
+ if (!parent.hasClass('ws-loaded')) {
143
+ parent.addClass('ws-loaded');
144
+ window.gm_wavesurfer[data.id].load(data.file, data.peaks);
145
+ window.gm_wavesurfer[data.id].toggleInteraction();
146
+ window.gm_wavesurfer[data.id].play();
147
+ }
148
+ if (window.gm_wavesurfer[data.id].isPlaying()) {
149
+ window.gm_wavesurfer[data.id].backend.media.currentTime = 0;
150
+ }
151
+ else {
152
+ window.gm_wavesurfer[data.id].play();
153
+ }
154
+ });
155
+
156
+ window.gm_wavesurfer[data.id].on('play', function() {
157
+ parent.find('.gm-play').hide();
158
+ parent.find('.gm-pause').show();
159
+ parent.find('.spinner').removeClass('is-active');
160
+
161
+ jQuery.each(window.gm_wavesurfer, function(id) {
162
+ if (id !== data.id && window.gm_wavesurfer[id].isPlaying()) {
163
+ window.gm_wavesurfer[id].pause();
164
+ }
165
+ });
166
+ });
167
+ window.gm_wavesurfer[data.id].on('pause', function() {
168
+ parent.find('.gm-play').show();
169
+ parent.find('.gm-pause').hide();
170
+ });
171
+ window.gm_wavesurfer[data.id].on('loading', function(p) {
172
+ if (p === 100) {
173
+ //parent.find('.spinner').removeClass('is-active');
174
+ }
175
+ else {
176
+ parent.find('.spinner').addClass('is-active');
177
+ }
178
+ });
179
+ },
180
+ /**
181
+ * Edit Mode
182
+ */
183
+ editmode: function() {
184
+ var focus_input_val;
185
+ // SelectBox for albums
186
+ var combobox_albums = jQuery('.combobox_gmedia_album');
187
+ var selectize_albums = combobox_albums.selectize({
188
+ create: !!combobox_albums.data('create'),
189
+ onOptionAdd: function(value, data) {
190
+ jQuery.each(selectize_albums, function(i, e) {
191
+ e.selectize.options[value] = data;
192
  });
193
+ },
194
+ onFocus: function() {
195
+ this.$input.addClass('edit-gmedia-ignore');
196
+ focus_input_val = this.$input.val();
197
+ },
198
+ onBlur: function() {
199
+ this.$input.removeClass('edit-gmedia-ignore');
200
+ if (focus_input_val !== this.$input.val()) {
201
+ var inporder = this.$input.prev('.gm-order-input');
202
+ inporder.val('0');
203
+ if ('' === this.$input.val()) {
204
+ inporder.prop('disabled', true);
205
+ }
206
+ else {
207
+ inporder.prop('disabled', false);
208
+ }
209
+ this.$input.trigger('change');
210
+ }
211
+ },
212
+ persist: true
213
+ });
214
 
215
+ if (window.gmedia_categories) {
216
+ var categories = jQuery('.combobox_gmedia_category');
217
+ if (categories.length) {
218
+ var categories_data = window.gmedia_categories.map(function(x) {
219
+ return {item: x};
220
+ });
221
 
222
+ var selectize_categories = categories.selectize({
223
+ create: function(input) {
224
+ if (categories.data('create')) {
225
+ return {
226
+ item: input
227
+ };
228
+ }
229
+ else {
230
+ return false;
231
+ }
232
+ },
233
+ onOptionAdd: function(value, data) {
234
+ jQuery.each(selectize_categories, function(i, e) {
235
+ e.selectize.options[value] = data;
236
  });
237
+ },
238
+ onFocus: function() {
239
+ this.$input.addClass('edit-gmedia-ignore');
240
+ focus_input_val = this.$input.val();
241
+ },
242
+ onBlur: function() {
243
+ this.$input.removeClass('edit-gmedia-ignore');
244
+ if (focus_input_val !== this.$input.val()) {
245
+ this.$input.trigger('change');
 
246
  }
247
+ },
248
+ createOnBlur: true,
249
+ delimiter: ',',
250
+ maxItems: null,
251
+ openOnFocus: true,
252
+ persist: true,
253
+ options: categories_data,
254
+ labelField: 'item',
255
+ valueField: 'item',
256
+ searchField: ['item'],
257
+ hideSelected: true
258
  });
259
+ }
260
+ }
261
+ if (window.gmedia_tags) {
262
+ var tags = jQuery('.combobox_gmedia_tag');
263
+ if (tags.length) {
264
+ var tags_data = window.gmedia_tags.map(function(x) {
265
+ return {item: x};
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
  });
267
 
268
+ var selectize_tags = tags.selectize({
269
+ create: function(input) {
270
+ if (this.$input.data('create')) {
271
+ var option = {item: input};
272
+ tags_data.push(option);
273
+ return option;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
274
  }
275
+ else {
276
+ return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
277
  }
278
+ },
279
+ onOptionAdd: function(value, data) {
280
+ jQuery.each(selectize_tags, function(i, e) {
281
+ e.selectize.options[value] = data;
282
+ });
283
+ },
284
+ onFocus: function() {
285
+ this.$input.addClass('edit-gmedia-ignore');
286
+ focus_input_val = this.$input.val();
287
+ },
288
+ onBlur: function() {
289
+ this.$input.removeClass('edit-gmedia-ignore');
290
+ if (focus_input_val !== this.$input.val()) {
291
+ this.$input.trigger('change');
292
  }
293
+ },
294
+ createOnBlur: true,
295
+ delimiter: ',',
296
+ maxItems: null,
297
+ openOnFocus: true,
298
+ persist: true,
299
+ options: tags_data,
300
+ labelField: 'item',
301
+ valueField: 'item',
302
+ searchField: ['item'],
303
+ hideSelected: true
304
  });
305
 
306
+ }
307
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308
 
309
+ // Date/Time picker
310
+ var gmedia_date_temp;
311
+ jQuery('.input-group.gmedia_date').datetimepicker({format: 'YYYY-MM-DD HH:mm:ss', focusOnShow: true, ignoreReadonly: true, allowInputToggle: true}).on('dp.show', function() {
312
+ gmedia_date_temp = jQuery('input', this).val();
313
+ }).on('dp.hide', function() {
314
+ if (jQuery('input', this).val() !== gmedia_date_temp) {
315
+ jQuery('input', this).trigger('modified');
316
+ }
317
+ });
318
 
319
+ // Mask for filename input
320
+ var inp_filename = jQuery('input.gmedia-filename').not('[readonly]');
321
+ if (inp_filename.length) {
322
+ inp_filename.alphanum({
323
+ allow: '-_',
324
+ disallow: '',
325
+ allowSpace: false,
326
+ allowNumeric: true,
327
+ allowUpper: true,
328
+ allowLower: true,
329
+ allowCaseless: true,
330
+ allowLatin: true,
331
+ allowOtherCharSets: false,
332
+ forceUpper: false,
333
+ forceLower: false,
334
+ maxLength: NaN
335
+ });
336
+ }
337
 
338
+ if (jQuery('#wp-link-wrap').parent().hasClass('hidden')) {
339
+ jQuery('#wp-link-backdrop, #wp-link-wrap').appendTo('body');
340
+ }
341
+ jQuery(document).on('click.gmedia', '.gmedia-custom-link', function(e) {
342
+ var editorId = jQuery(this).attr('data-target');
343
+ window.wpActiveEditor = true;
344
+ wpLink.open(editorId);
345
+ wpLink.gmediaCustomLinkTarget = editorId;
346
+ jQuery('#wp-link-wrap').removeClass('has-text-field').addClass('gmLinkModal').find('.link-target').css('visibility', 'hidden');
347
+
348
+ return false;
349
+ });
350
 
351
+ function closeLinkModal() {
352
+ jQuery('#wp-link-wrap').removeClass('gmLinkModal').find('.link-target').removeAttr('style');
353
+ wpLink.close();
354
+ }
 
 
 
 
 
 
355
 
356
+ jQuery(document).on('click.gmedia', '.gmLinkModal #wp-link-submit', function(e) {
357
+ e.preventDefault ? e.preventDefault() : e.returnValue = false;
358
+ e.stopPropagation();
359
+
360
+ var link = wpLink.getAttrs();
361
+ wpLink.textarea = jQuery('#' + wpLink.gmediaCustomLinkTarget);
 
 
 
 
 
 
 
 
 
 
362
 
363
+ if (!link.href) {
364
+ closeLinkModal();
365
+ return;
366
+ }
367
+ wpLink.textarea.val(link.href).trigger('change');
368
+ closeLinkModal();
369
+ });
370
+ jQuery(document).on('click.gmedia', '#wp-link-cancel, #wp-link-close, #wp-link-backdrop', function(e) {
371
+ closeLinkModal();
372
+ });
373
 
374
+ var related_sortable = jQuery('.related-media-previews');
375
+ if (related_sortable.length) {
376
+ related_sortable.sortable({
377
+ items: '.gmedia-related-image',
378
+ handle: '.image-wrapper',
379
+ placeholder: 'gmedia-related-image',
380
+ tolerance: 'pointer',
381
+ //helper: 'clone',
382
+ revert: true,
383
+ forcePlaceholderSize: true,
384
+ stop: function(event, ui) {
385
+ ui.item.find('input').trigger('change');
386
+ }
387
+ });
388
  }
389
+
390
+ }
391
  };
392
 
393
  /**
394
  * Gmedia AddMedia
395
  */
396
  var GmediaAddMedia = {
397
+ init: function() {
 
 
 
 
 
 
 
 
 
 
 
 
398
 
399
+ if (jQuery('body').hasClass('GrandMedia_AddMedia')) {
400
+ gmedia_DOM.on('change', '#uploader_runtime select', function() {
401
+ if ('html4' === jQuery(this).val()) {
402
+ jQuery('#uploader_chunking').addClass('hide');
403
+ jQuery('#uploader_urlstream_upload').addClass('hide');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
404
  }
405
+ else {
406
+ jQuery('#uploader_chunking').removeClass('hide');
407
+ jQuery('#uploader_urlstream_upload').removeClass('hide');
408
+ }
409
+ });
410
+ }
411
 
412
+ var albums = jQuery('select#combobox_gmedia_album');
413
+ if (albums.length) {
414
+ var albums_data = jQuery('option', albums);
415
+ albums.selectize({
416
+ create: function(input) {
417
+ if (albums.data('create')) {
418
+ return {
419
+ value: input,
420
+ text: input
421
+ };
422
+ }
423
+ else {
424
+ return false;
425
+ }
426
+ },
427
+ createOnBlur: true,
428
+ persist: false,
429
+ render: {
430
+ item: function(item, escape) {
431
+ if (0 === (parseInt(item.value, 10) || 0)) {
432
+ return '<div>' + escape(item.text) + '</div>';
 
 
 
 
 
 
 
433
  }
434
+ if (item.$order) {
435
+ var data = jQuery(albums_data[item.$order]).data();
436
+ return '<div>' + escape(data.name) + ' <small>' + escape(data.meta) + '</small></div>';
437
+ }
438
+ },
439
+ option: function(item, escape) {
440
+ if (0 === (parseInt(item.value) || 0)) {
441
+ return '<div>' + escape(item.text) + '</div>';
442
+ }
443
+ if (item.$order) {
444
+ var data = jQuery(albums_data[item.$order]).data();
445
+ return '<div>' + escape(data.name) + ' <small>' + escape(data.meta) + '</small></div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
446
  }
447
+ }
448
  }
449
+ });
450
+ }
451
 
452
+ if (window.gmedia_tags) {
453
+ var tags = jQuery('#combobox_gmedia_tag');
454
+ if (tags.length) {
455
+ var tags_data = window.gmedia_tags.map(function(x) {
456
+ return {item: x};
457
+ });
458
 
459
+ tags.selectize({
460
+ create: function(input) {
461
+ if (tags.data('create')) {
462
+ return {
463
+ item: input
464
+ };
465
+ }
466
+ else {
467
+ return false;
468
+ }
469
+ },
470
+ createOnBlur: true,
471
+ delimiter: ',',
472
+ maxItems: null,
473
+ openOnFocus: true,
474
+ persist: false,
475
+ options: tags_data,
476
+ labelField: 'item',
477
+ valueField: 'item',
478
+ searchField: ['item'],
479
+ hideSelected: true
480
+ });
481
+ }
482
+ }
483
+ if (window.gmedia_categories) {
484
+ var categories = jQuery('#combobox_gmedia_category');
485
+ if (categories.length) {
486
+ var categories_data = window.gmedia_categories.map(function(x) {
487
+ return {item: x};
488
+ });
489
+
490
+ categories.selectize({
491
+ create: function(input) {
492
+ if (categories.data('create')) {
493
+ return {
494
+ item: input
495
+ };
496
+ }
497
+ else {
498
+ return false;
499
+ }
500
+ },
501
+ createOnBlur: true,
502
+ delimiter: ',',
503
+ maxItems: null,
504
+ openOnFocus: true,
505
+ persist: false,
506
+ options: categories_data,
507
+ labelField: 'item',
508
+ valueField: 'item',
509
+ searchField: ['item'],
510
+ hideSelected: true
511
+ });
512
+ }
513
  }
514
+
515
+ },
516
+ /**
517
+ * Gmedia Import
518
+ */
519
+ importmode: function() {
520
+ }
521
  };
522
 
523
  /**
524
  * Gmedia Terms
525
  */
526
  var GmediaTerms = {
527
+ init: function() {
528
+
529
+ if (jQuery('body').hasClass('GrandMedia_Tags')) {
530
+ jQuery('#gm-list-table').data('edit', false);
531
+ gmedia_DOM.on('keypress', 'input.edit_tag_input', function(e) {
532
+ var tagdiv = jQuery('#tag_' + jQuery(this).data('tag_id'));
533
+ var charCode = e.charCode || e.keyCode || e.which;
534
+ if (charCode === 13) {
535
+ e.preventDefault();
536
+ edit_tag(tagdiv);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
537
  }
538
+ }).on('blur', 'input.edit_tag_input', function() {
539
+ var tagdiv = jQuery('#tag_' + jQuery(this).data('tag_id'));
540
+ edit_tag(tagdiv);
541
+ });
542
+
543
+ gmedia_DOM.on('click', '.edit_tag_link', function(e) {
544
+ e.preventDefault();
545
+ var id = jQuery(this).attr('href');
546
+ jQuery(this).hide();
547
+ jQuery(id).find('.edit_tag_form').show().find('input').focus();
548
+ jQuery('#gm-list-table').data('edit', true);
549
+ });
550
+ gmedia_DOM.on('click', '.edit_tag_save', function(e) {
551
+ e.preventDefault();
552
+ });
553
+
554
+ function edit_tag(tagdiv) {
555
+ var inp = tagdiv.find('.edit_tag_form input');
556
+ var new_tag_name = jQuery.trim(inp.val());
557
+ var old_tag_name = inp.attr('placeholder');
558
+ if ((old_tag_name === new_tag_name) || ('' === new_tag_name) || jQuery.isNumeric()) {
559
+ inp.val(old_tag_name);
560
+ tagdiv.find('.edit_tag_form').hide();
561
+ tagdiv.find('.edit_tag_link').show();
562
+ return;
563
+ }
564
+ var post_data = {
565
+ action: 'gmedia_tag_edit',
566
+ tag_id: inp.data('tag_id'),
567
+ tag_name: new_tag_name,
568
+ _wpnonce_terms: jQuery('#_wpnonce_terms').val()
569
+ };
570
+ jQuery.post(ajaxurl, post_data, function(data, textStatus, jqXHR) {
571
+ if (data.error) {
572
+ //inp.val(inp.attr('placeholder'));
573
+ jQuery('#gmedia-panel').before(data.error);
574
+ }
575
+ else {
576
+ //new_tag_name = new_tag_name.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
577
+ inp.attr('placeholder', new_tag_name);
578
+ tagdiv.find('.edit_tag_link').text(new_tag_name).show();
579
+ //noinspection JSUnresolvedVariable
580
+ jQuery('#gmedia-panel').before(data.msg);
581
+ tagdiv.find('.edit_tag_form').hide();
582
+ }
583
  });
584
+ }
585
+ }
586
 
587
+ gmedia_DOM.on('click', '.term-shortcode input', function() {
588
+ this.setSelectionRange(0, 0);
589
+ this.setSelectionRange(0, this.value.length);
590
+ });
591
+ gmedia_DOM.on('change', '.term-shortcode input', function() {
592
+ shortcode_inp_autowidth(this);
593
+ });
594
+ jQuery('.term-shortcode input', gmedia_DOM).each(function(i, e) {
595
+ shortcode_inp_autowidth(this);
596
+ });
597
 
598
+ function shortcode_inp_autowidth(e) {
599
+ var inp = jQuery(e),
600
+ buffer = inp.next('.input-buffer');
601
+ buffer.text(inp.val());
602
+ inp.width(buffer.width());
603
+ }
604
 
605
+ var sortable = jQuery('#gm-sortable');
606
+ if (sortable.length && !jQuery('#gmedia-panel', sortable).hasClass('gmedia-filtered')) {
607
+ var sortdiv = jQuery('#gm-list-table', sortable);
608
+ var post_data = sortable.data();
609
+ post_data['idx0'] = parseInt(sortdiv.attr('data-idx0'));
610
+
611
+ var _ids = [];
612
+ jQuery('.gm-item-cell', sortdiv).each(function(index) {
613
+ _ids.push(jQuery(this).attr('data-id'));
614
+ });
615
+ sortdiv.sortable({
616
+ items: '.gm-item-cell',
617
+ handle: '.cb_media-object',
618
+ placeholder: 'cb_list-item gm-item-cell col-xs-6 col-sm-4 col-md-3 col-lg-2 gmedia-image-item ui-highlight-placeholder',
619
+ tolerance: 'pointer',
620
+ helper: 'clone',
621
+ revert: true,
622
+ forcePlaceholderSize: true,
623
+ stop: function(event, ui) {
624
+ var ids = [];
625
+ jQuery('.gm-item-cell', sortdiv).each(function(index) {
626
+ ids.push(jQuery(this).attr('data-id'));
627
+ });
628
+
629
+ if (_ids.toString() !== ids.toString()) {
630
+ _ids = ids;
631
+ jQuery('.panel-heading .spinner', sortable).addClass('is-active');
632
+ post_data['ids'] = ids;
633
+ jQuery.post(ajaxurl, post_data, function(data, textStatus, jqXHR) {
634
+ jQuery('.panel-heading .spinner', sortable).removeClass('is-active');
635
  });
636
+ }
637
  }
638
+ });
639
+ }
640
 
641
+ gmedia_DOM.on('change', '#gmedia_term_orderby', function() {
642
+ if ('custom' === jQuery(this).val()) {
643
+ jQuery('#gmedia_term_order').val('ASC').addClass('disabled');
644
+ }
645
+ else {
646
+ jQuery('#gmedia_term_order').removeClass('disabled');
647
+ }
648
+ });
649
 
650
+ // Date/Time picker
651
+ if (jQuery.fn.datetimepicker) {
652
+ jQuery('.input-group.gmedia_date').datetimepicker({format: 'YYYY-MM-DD HH:mm:ss', focusOnShow: true, ignoreReadonly: true, allowInputToggle: true});
 
653
  }
654
+ }
655
  };
656
 
657
  var GmediaSelect = {
658
+ msg_stack: function(global) {
659
+ var gm_cb = jQuery('.gm-stack input');
660
+ var sel = jQuery('#gm-stack');
661
+ if (!sel.length) {
662
+ return;
663
+ }
 
 
 
 
 
664
 
665
+ var arr = sel.val().split(',');
666
+ arr = jQuery.grep(arr, function(e) {
667
+ return (e);
668
+ });
 
 
 
 
 
 
 
669
 
670
+ if (global) {
671
+ var cur = false;
672
+ gm_cb.each(function() {
673
+ cur = jQuery(this);
674
+ if (cur.is(':checked') && (jQuery.inArray(cur.val(), arr) === -1)) {
675
+ cur.prop('checked', false);
 
 
 
676
  }
677
+ else if (!(cur.is(':checked')) && (jQuery.inArray(cur.val(), arr) !== -1)) {
678
+ cur.prop('checked', true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
679
  }
680
+ });
681
+ }
682
 
683
+ if (sel.data('userid')) {
684
+ var storedData = getStorage();
685
+ storedData.set(sel.data('key'), arr.join('.'));
686
+ }
687
+ jQuery('#gm-stack-qty').text(arr.length);
688
+ if (arr.length) {
689
+ jQuery('#gm-stack-btn').removeClass('hidden');
690
+ jQuery('.rel-stack-show').show();
691
+ jQuery('.rel-stack-hide').hide();
692
+ }
693
+ else {
694
+ jQuery('#gm-stack-btn').addClass('hidden');
695
+ jQuery('.rel-stack-show').hide();
696
+ jQuery('.rel-stack-hide').show();
697
+ }
698
+ sel.trigger('change');
699
+ },
700
+ msg_selected: function(obj, global) {
701
+ var gm_cb = jQuery('.' + obj + ' input'),
702
+ qty_v = gm_cb.length,
703
+ sel_v = gm_cb.filter(':checked').length,
704
+ c = jQuery('#cb_global');
705
+ if ((sel_v !== qty_v) && (0 !== sel_v)) {
706
+ c.css('opacity', '0.5').prop('checked', true);
707
+ }
708
+ else if ((sel_v === qty_v) && (0 !== qty_v)) {
709
+ c.css('opacity', '1').prop('checked', true);
710
+ }
711
+ else if (0 === sel_v) {
712
+ c.css('opacity', '1').prop('checked', false);
713
+ }
714
 
715
+ var sel = jQuery('#gm-selected');
716
+ if (!sel.length) {
717
+ return;
718
+ }
719
 
720
+ var arr = sel.val().split(',');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
721
 
722
+ arr = jQuery.grep(arr, function(e) {
723
+ return (e);
724
+ });
725
+ if (global) {
726
+ var cur = false;
727
+ gm_cb.each(function() {
728
+ cur = jQuery(this);
729
+ if (cur.is(':checked') && (jQuery.inArray(cur.val(), arr) === -1)) {
730
+ arr.push(cur.val());
731
+ }
732
+ else if (!(cur.is(':checked')) && (jQuery.inArray(cur.val(), arr) !== -1)) {
733
+ arr = jQuery.grep(arr, function(e) {
734
+ return e !== cur.val();
735
+ });
736
  }
737
+ });
738
+ sel.val(arr.join(','));
739
+ }
740
 
741
+ if (sel.data('userid')) {
742
+ var storedData = getStorage();
743
+ storedData.set(sel.data('key'), arr.join('.'));
744
+ }
745
+ jQuery('#gm-selected-qty').text(arr.length);
746
+
747
+ var selbtn = jQuery('#gm-selected-btn');
748
+ if (arr.length) {
749
+ selbtn.removeClass('hidden');
750
+ jQuery('.rel-selected-show').show();
751
+ jQuery('.rel-selected-hide').hide();
752
+ }
753
+ else {
754
+ if (!selbtn.hasClass('gm-active')) {
755
+ jQuery('#gm-selected-btn').addClass('hidden');
756
+ }
757
+ jQuery('.rel-selected-show').hide();
758
+ jQuery('.rel-selected-hide').show();
759
+ }
760
+ sel.trigger('change');
761
+ },
762
+ chk_all: function(type, obj) {
763
+ jQuery('.' + obj + ' input').filter(function() {
764
+ return type ? jQuery(this).data('type') === type : true;
765
+ }).prop('checked', true).closest('.cb_list-item').addClass('gm-selected');
766
+ },
767
+ chk_none: function(type, obj) {
768
+ jQuery('.' + obj + ' input').filter(function() {
769
+ return type ? jQuery(this).data('type') === type : true;
770
+ }).prop('checked', false).closest('.cb_list-item').removeClass('gm-selected');
771
+ },
772
+ chk_toggle: function(type, obj) {
773
+ if (type) {
774
+ if (jQuery('.' + obj + ' input:checked').filter(function() {
775
+ return jQuery(this).data('type') === type;
776
+ }).length) {
777
+ GmediaSelect.chk_none(type, obj);
778
+ }
779
+ else {
780
+ GmediaSelect.chk_all(type, obj);
781
+ }
782
+ }
783
+ else {
784
+ jQuery('.' + obj + ' input').each(function() {
785
+ jQuery(this).prop('checked', !jQuery(this).prop('checked')).closest('.cb_list-item').toggleClass('gm-selected');
786
+ });
787
+ }
788
+ },
789
+ init: function() {
790
+ var cb_obj = jQuery('#cb_global').data('group');
791
+
792
+ if (jQuery('#gm-selected').length) {
793
+ GmediaSelect.msg_selected(cb_obj);
794
+ gmedia_DOM.on('click', '#gm-selected-clear', function(e) {
795
+ jQuery('#gm-selected').val('');
796
+ GmediaSelect.chk_none(false, cb_obj);
797
+ GmediaSelect.msg_selected(cb_obj);
798
+ e.preventDefault();
799
+ });
800
+ gmedia_DOM.on('click', '#gm-selected-show', function(e) {
801
+ jQuery('#gm-selected-btn').submit();
802
+ e.preventDefault();
803
+ });
804
+ gmedia_DOM.on('click', '#gm-stack-in', function(e) {
805
+ e.preventDefault();
806
+ var stack_obj = jQuery('#gm-stack'),
807
+ sel_obj = jQuery('#gm-selected'),
808
+ stack = stack_obj.val().split(','),
809
+ selected = sel_obj.val().split(','),
810
+ arr = stack.concat(selected);
811
+ arr = jQuery.grep(arr, function(e) {
812
+ return (e);
813
+ });
814
+ arr = jQuery.unique(arr);
815
+ stack_obj.val(arr.join(','));
816
+ GmediaSelect.msg_stack(true);
817
+ //sel_obj.val('');
818
+ //GmediaSelect.chk_none(false, cb_obj);
819
+ //GmediaSelect.msg_selected(cb_obj);
820
+ });
821
+ gmedia_DOM.on('click', '#gm-stack-out', function(e) {
822
+ e.preventDefault();
823
+ var stack_obj = jQuery('#gm-stack'),
824
+ sel_obj = jQuery('#gm-selected'),
825
+ stack = stack_obj.val().split(','),
826
+ selected = sel_obj.val().split(','),
827
+ arr = jQuery(stack).not(selected).get();
828
+ arr = jQuery.grep(arr, function(e) {
829
+ return (e);
830
+ });
831
+ arr = jQuery.unique(arr);
832
+ stack_obj.val(arr.join(','));
833
+ GmediaSelect.msg_stack(true);
834
+ //sel_obj.val('');
835
+ //GmediaSelect.chk_none(false, cb_obj);
836
+ //GmediaSelect.msg_selected(cb_obj);
837
+ });
838
+ }
839
+ gmedia_DOM.on('click', '#cb_global', function() {
840
+ if (jQuery(this).is(':checked')) {
841
+ GmediaSelect.chk_all(false, cb_obj);
842
+ }
843
+ else {
844
+ GmediaSelect.chk_none(false, cb_obj);
845
+ }
846
+ GmediaSelect.msg_selected(cb_obj, true);
847
+ });
848
+ gmedia_DOM.on('click', '#cb_global-btn li a', function(e) {
849
+ var sel = jQuery(this).data('select');
850
+ switch (sel) {
851
+ case 'total':
852
+ GmediaSelect.chk_all(false, cb_obj);
853
+ break;
854
+ case 'none':
855
+ GmediaSelect.chk_none(false, cb_obj);
856
+ break;
857
+ case 'reverse':
858
+ GmediaSelect.chk_toggle(false, cb_obj);
859
+ break;
860
+ case 'image':
861
+ case 'audio':
862
+ case 'video':
863
+ GmediaSelect.chk_toggle(sel, cb_obj);
864
+ break;
865
+ }
866
+ GmediaSelect.msg_selected(cb_obj, true);
867
+ e.preventDefault();
868
+ });
869
+ gmedia_DOM.on('change', '.gm-item-check input:checkbox, .cb_object input:checkbox', function() {
870
+ var selected = jQuery('#gm-selected'),
871
+ arr = selected.val();
872
+ var cur = jQuery(this).val();
873
+ if (jQuery(this).is(':checked')) {
874
+ if (arr) {
875
+ arr = arr + ',' + cur;
876
  }
877
  else {
878
+ arr = cur;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
879
  }
880
+ }
881
+ else {
882
+ arr = jQuery.grep(arr.split(','), function(a) {
883
+ return a !== cur;
884
+ }).join(',');
885
+ }
886
+ jQuery('#list-item-' + cur).toggleClass('gm-selected');
887
+ selected.val(arr);
888
+ GmediaSelect.msg_selected(cb_obj);
889
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
890
 
891
+ gmedia_DOM.on('click', '.gm-item-check input:radio', function() {
892
+ var id = jQuery(this).val(), img, checked_thumb, data;
893
+ jQuery('#list-item-' + id).addClass('gm-selected').siblings().removeClass('gm-selected');
894
+ img = jQuery(this).closest('.thumbnail').find('.gmedia-thumb').clone();
895
+ checked_thumb = jQuery('#gmedia-panel .panel-heading .checked_thumb');
896
+ if (!checked_thumb.length) {
897
+ checked_thumb = jQuery('<div class="checked_thumb"></div>').appendTo(jQuery('#gmedia-panel .panel-heading'));
898
+ }
899
+ checked_thumb.html(img);
900
+ data = {'id': id, 'src': img.attr('src')};
901
+ window.parent.gmediaTempData = data;
902
+ });
903
 
904
+ if (jQuery('#gm-stack').length) {
905
+ GmediaSelect.msg_stack();
906
+ gmedia_DOM.on('click', '#gm-stack-clear', function(e) {
907
+ jQuery('#gm-stack').val('');
908
+ jQuery('.gm-stack input').prop('checked', false);
909
+ GmediaSelect.msg_stack();
910
+ e.preventDefault();
911
+ });
912
+ gmedia_DOM.on('click', '#gm-stack-show', function(e) {
913
+ jQuery('#gm-stack-btn').submit();
914
+ e.preventDefault();
915
+ });
 
 
 
 
 
 
 
916
 
 
 
 
 
 
 
 
 
 
 
 
917
  }
918
+ gmedia_DOM.on('change', '.gm-stack input:checkbox', function() {
919
+ var selected = jQuery('#gm-stack'),
920
+ arr = selected.val();
921
+ var cur = jQuery(this).val();
922
+ if (jQuery(this).is(':checked')) {
923
+ if (arr) {
924
+ arr = arr + ',' + cur;
925
  }
926
+ else {
927
+ arr = cur;
 
 
928
  }
929
+ }
930
+ else {
931
+ arr = jQuery.grep(arr.split(','), function(a) {
932
+ return a !== cur;
933
+ }).join(',');
934
+ }
935
+ selected.val(arr);
936
+ GmediaSelect.msg_stack();
937
+ });
938
+
939
+ gmedia_DOM.on('click', '.term-label', function(e) {
940
+ if ('DIV' === e.target.nodeName) {
941
+ if (!jQuery('#gm-list-table').data('edit')) {
942
+ var cb = jQuery('input:checkbox', this);
943
+ cb.prop('checked', !cb.prop('checked')).change();
944
+ jQuery(this).closest('.term-list-item').toggleClass('gm-selected');
945
  }
946
+ else {
947
+ jQuery('#gm-list-table').data('edit', false);
 
 
 
 
948
  }
949
+ }
950
+ });
951
+ }
952
+ };
953
 
954
+ var GmediaFunction = {
955
+ confirm: function(txt) {
956
+ if (!txt) {
957
+ return true;
958
+ }
959
+ var r = false;
960
+ //noinspection UnusedCatchParameterJS
961
+ try {
962
+ r = confirm(txt);
963
+ } catch (err) {
964
+ alert('Disable Popup Blocker');
965
+ }
966
+ return r;
967
+ },
968
+ init: function() {
969
+ jQuery('#toplevel_page_GrandMedia').addClass('current').removeClass('wp-not-current-submenu');
970
+ if (!('ontouchstart' in document.documentElement)) {
971
+ jQuery('html').addClass('no-touch');
972
+ }
973
 
974
+ //jQuery(document).ajaxStart(function(a,b,c){
975
+ // //jQuery('body').addClass('gmedia-busy');
976
+ // jQuery('.panel-heading .spinner').addClass('is-active');
977
+ //}).ajaxStop(function(){
978
+ // //jQuery('body').removeClass('gmedia-busy');
979
+ // jQuery('.panel-heading .spinner').removeClass('is-active');
980
+ //});
981
 
982
+ gmedia_DOM.on('click', '[data-confirm]', function() {
983
+ return GmediaFunction.confirm(jQuery(this).data('confirm'));
984
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
985
 
986
+ jQuery(document).on('click.gmedia', '.gm_service_action', function() {
987
+ var el = jQuery(this),
988
+ service = jQuery(this).attr('data-action'),
989
+ nonce = jQuery(this).attr('data-nonce');
990
+ var post_data = {
991
+ action: 'gmedia_application',
992
+ service: service,
993
+ _wpnonce: nonce
994
+ };
995
+ jQuery.post(ajaxurl, post_data, function(data, textStatus, jqXHR) {
996
+ el.siblings('.spinner').removeClass('is-active');
997
+ if (data.error) {
998
+ jQuery('#gmedia-service-msg-panel').prepend(data.error);
999
+ }
1000
+ else if (data.message) {
1001
+ jQuery('#gmedia-service-msg-panel').html(data.message);
1002
+ }
1003
+ });
1004
 
1005
+ el.siblings('.spinner').addClass('is-active');
1006
+ jQuery('.gmedia-service__message').remove();
1007
+ });
 
1008
 
1009
+ gmedia_DOM.on('click', '.show-settings-link', function(e) {
1010
+ e.preventDefault();
1011
+ jQuery('#show-settings-link').trigger('click');
1012
+ });
 
 
1013
 
1014
+ gmedia_DOM.on('click', '.fit-thumbs', function(e) {
1015
+ e.preventDefault();
1016
+ jQuery(this).toggleClass('btn-success btn-default');
1017
+ jQuery('.display-as-grid').toggleClass('invert-ratio');
1018
+ jQuery.get(jQuery(this).attr('href'), {ajaxload: 1});
1019
+ });
1020
 
1021
+ gmedia_DOM.on('click', '.gm-cell-more-btn, .gm-cell-title', function() {
1022
+ jQuery(this).parent().toggleClass('gm-cell-more-active');
1023
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1024
 
1025
+ jQuery('div.gmedia-modal', gmedia_DOM).each(function() {
1026
+ var id = jQuery(this).attr('id');
1027
+ jQuery('body').children('#' + id).remove();
1028
+ jQuery(this).appendTo('body');
1029
+ });
1030
+ gmedia_DOM.on('click', 'a.gmedia-modal', function(e) {
1031
+ jQuery('body').addClass('gmedia-busy');
1032
+ var modal_div = jQuery(jQuery(this).attr('href'));
1033
+ var post_data = jQuery(this).data();
1034
+ post_data['_wpnonce'] = jQuery('#_wpnonce').val();
1035
+ jQuery.post(ajaxurl, post_data, function(data, textStatus, jqXHR) {
1036
+ if (!data || ('-1' === data)) {
1037
+ jQuery('body').removeClass('gmedia-busy');
1038
+ alert(data);
1039
+ return false;
1040
+ }
1041
+ jQuery('.modal-dialog', modal_div).html(data);
1042
+ modal_div.modal({
1043
+ backdrop: 'static',
1044
+ show: true,
1045
+ keyboard: false
1046
+ }).one('hidden.bs.modal', function() {
1047
+ jQuery('.modal-dialog', this).empty();
1048
  });
1049
+ jQuery('body').removeClass('gmedia-busy');
1050
+ });
1051
+ e.preventDefault();
1052
+ });
1053
 
1054
+ gmedia_DOM.on('click', 'a.gmedit-modal', function(e) {
1055
+ e.preventDefault();
1056
+ var modal_div = jQuery(jQuery(this).data('target'));
1057
+ jQuery('.modal-content', modal_div).html(
1058
+ jQuery('<iframe />', {
1059
+ name: 'gmeditFrame',
1060
+ id: 'gmeditFrame',
1061
+ width: '100%',
1062
+ height: '500',
1063
+ src: jQuery(this).attr('href')
1064
+ }).css({display: 'block', margin: '4px 0'})
1065
+ );
1066
+ modal_div.modal({
1067
+ backdrop: true,
1068
+ show: true,
1069
+ keyboard: false
1070
+ }).one('hidden.bs.modal', function() {
1071
+ jQuery('.modal-content', this).empty();
1072
+ });
1073
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1074
 
1075
+ jQuery(document).on('click.gmedia', 'a.preview-modal', function(e) {
1076
+ e.preventDefault();
1077
+ var initiator = jQuery(this),
1078
+ data = initiator.data(),
1079
+ modal_div = jQuery(data['target']),
1080
+ modal_dialog = jQuery('.modal-dialog', modal_div),
1081
+ modal_body = jQuery('.modal-body', modal_div),
1082
+ modal_title = jQuery('.modal-title', modal_div),
1083
+ title = jQuery(this).attr('data-title') ? jQuery(this).attr('data-title') : jQuery(this).attr('title');
1084
+
1085
+ modal_title.text(_.escape(title));
1086
+
1087
+ if (data['metainfo']) {
1088
+ modal_dialog.addClass('modal-md');
1089
+ modal_body.html(jQuery('#metainfo_' + data['metainfo']).html());
1090
+ }
1091
+ else {
1092
+ var r = data['width'] / data['height'],
1093
+ w = Math.min(jQuery(window).width() * 0.98 - 32, data['width']),
1094
+ h = w / r;
1095
+ modal_dialog.css({'width': (data['width'] + 32), 'max-width': '98%'});
1096
+ if (data['cls']) {
1097
+ modal_dialog.addClass(data['cls']);
1098
+ }
1099
+ modal_body.html(
1100
+ jQuery('<iframe />', {
1101
+ name: 'previewFrame',
1102
+ id: 'previewFrame',
1103
+ width: '100%',
1104
+ height: h,
1105
+ src: jQuery(this).attr('href')
1106
+ }).on('load', function() {
1107
+ jQuery(this.contentWindow.document.body).css('margin', 0);
1108
+ jQuery('.modal-backdrop', modal_div).css({'width': (data['width'] + 32), 'min-width': '100%'});
1109
+ }).css({display: 'block', margin: '4px 0'})
1110
+ );
1111
+ }
1112
+
1113
+ initiator.addClass('previewModal_initiator');
1114
+ modal_div.modal({
1115
+ backdrop: true,
1116
+ show: true
1117
+ }).one('hidden.bs.modal', function() {
1118
+ if (jQuery('div.gmedia-modal:visible').length) {
1119
+ jQuery('body').addClass('modal-open');
1120
+ }
1121
+ modal_title.empty();
1122
+ modal_body.empty();
1123
+ modal_dialog.removeAttr('style').attr('class', 'modal-dialog');
1124
+ if (modal_div.attr('data-refresh')) {
1125
+ modal_div.removeAttr('data-refresh');
1126
+ jQuery('.panel-heading .spinner').addClass('is-active');
1127
+ var url = window.location.href;
1128
+ jQuery.get(url, function(data) {
1129
+ jQuery('#gmedia-panel').html(jQuery('#gmedia-panel', data).html());
1130
+ GmediaInit();
1131
+ jQuery('.panel-heading .spinner').removeClass('is-active');
1132
+ });
1133
+ }
1134
+ initiator.removeClass('previewModal_initiator');
1135
+ });
1136
+ });
1137
 
1138
+ jQuery(document).on('click.gmedia', '#previewModal .select_gmedia_image .btn-primary', function() {
1139
+ var img, form = jQuery('.previewModal_initiator').closest('form');
1140
+ form.find('.gmedia-cover-id').val(window.gmediaTempData.id).trigger('change');
1141
+ img = form.find('.gmedia-cover-image img:first-child');
1142
+ if (img.length) {
1143
+ img.attr('src', window.gmediaTempData.src);
1144
+ }
1145
+ else {
1146
+ jQuery('<img src="" alt="" />').attr('src', window.gmediaTempData.src).appendTo(form.find('.gmedia-cover-image'));
1147
+ }
1148
+ jQuery('#previewModal').modal('hide');
1149
+ });
1150
 
1151
+ jQuery(document).on('click.gmedia', '#previewModal .select_gmedia_related .btn-primary', function() {
1152
+ var relatedDiv = jQuery('.previewModal_initiator').closest('.form-group').find('.related-media-previews');
1153
+ var fields = relatedDiv.find('input');
1154
+ var valData = [],
1155
+ getData = [];
1156
+ if (fields) {
1157
+ fields.each(function() {
1158
+ valData.push(jQuery(this).val());
1159
+ });
1160
+ }
1161
+ var storage = getStorage(),
1162
+ storedData = storage.get('gmedia_library:frame').split('.');
1163
+ jQuery.each(storedData, function(i, id) {
1164
+ if (!id) {
1165
+ return true;
1166
+ }
1167
+ if (jQuery.inArray(id, valData) === -1) {
1168
+ getData.push(id);
1169
+ }
1170
+ });
1171
+ if (getData.length) {
1172
+ jQuery.get(ajaxurl, {action: 'gmedia_get_data', gmedia__in: getData}, function(data, textStatus, jqXHR) {
1173
+ if (jQuery.isArray(data) && data.length) {
1174
+ var thumbHTML;
1175
+ jQuery.each(data, function(i, item) {
1176
+ thumbHTML = '<p class="thumbnail gmedia-related-image">' +
1177
+ '<span class="image-wrapper"><img class="gmedia-thumb" src="" alt=""></span>' +
1178
+ '<span class="gm-remove">&times;</span>' +
1179
+ '<input type="hidden" name="meta[_related][]" value="">' +
1180
+ '</p>';
1181
+ jQuery(thumbHTML).find('img').attr('src', item.url_thumb).end().find('input').val(item.ID).end().appendTo(relatedDiv);
1182
  });
1183
+ relatedDiv.sortable('refresh');
1184
+ relatedDiv.closest('form').find('input[name="title"]').trigger('change');
1185
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1186
  });
1187
+ }
1188
+ storage.set('gmedia_library:frame', '');
1189
+ jQuery('#previewModal').modal('hide');
1190
+ });
1191
 
1192
+ jQuery(document).on('click.gmedia', '.related-media-previews .gm-remove', function() {
1193
+ var inpTitle = jQuery(this).closest('form').find('input[name="title"]');
1194
+ jQuery(this).closest('.gmedia-related-image').remove();
1195
+ inpTitle.trigger('change');
1196
+ });
1197
 
1198
+ jQuery(document).on('click.gmedia', '#previewModal .select_gmedia:not(.assign_gmedia_term) .btn-primary', function() {
1199
+ var field = jQuery('.previewModal_initiator').closest('.form-group').find('.form-control');
1200
+ var valData = field.val().split(',');
1201
+ var storedData = getStorage();
1202
+ storedData = storedData.get('gmedia_library:frame').split('.');
1203
+ valData = jQuery.grep(valData, function(e) {
1204
+ return e.trim();
1205
+ });
1206
+ jQuery.each(storedData, function(i, id) {
1207
+ if (!id) {
1208
+ return true;
1209
+ }
1210
+ if (jQuery.inArray(id, valData) === -1) {
1211
+ valData.push(id);
1212
+ }
1213
+ });
1214
+ field.val(valData.join(','));
1215
+ jQuery('#previewModal').modal('hide');
1216
+ });
1217
 
1218
+ jQuery(document).on('click.gmedia', '#previewModal .assign_gmedia_term .btn-primary', function() {
1219
+ jQuery('.panel-heading .spinner').addClass('is-active');
1220
+ var url = window.location.href,
1221
+ post_data = jQuery('#gmedia-assign-term').serialize();
1222
+ jQuery.post(url, post_data, function(data) {
1223
+ jQuery('.gmedia_term__in').html(jQuery('.gmedia_term__in', data).html());
1224
+ GmediaInit();
1225
+ jQuery('.panel-heading .spinner').removeClass('is-active');
1226
+ });
1227
+ jQuery('#previewModal').modal('hide');
1228
+ });
 
1229
 
1230
+ jQuery(document).on('click.gmedia focus.gmedia', 'input.sharelink', function() {
1231
+ this.setSelectionRange(0, this.value.length);
1232
+ });
1233
+ jQuery(document).on('keyup.gmedia', 'input.sharetoemail', function() {
1234
+ jQuery('.sharebutton').prop('disabled', !validateEmail(this.value));
1235
+ });
1236
+ jQuery(document).on('click.gmedia', '.sharebutton', function() {
1237
+ var sharetoemail = jQuery('input.sharetoemail');
1238
+ if (!validateEmail(sharetoemail.val())) {
1239
+ sharetoemail.focus();
1240
+ sharetoemail.parent().addClass('has-error');
1241
+ return false;
1242
+ }
1243
+ var post_data = jQuery('#shareForm').serialize();
1244
+ jQuery.post(ajaxurl, post_data, function(data, textStatus, jqXHR) {
1245
+ jQuery('body').removeClass('gmedia-busy');
1246
+ if (data) {
1247
+ jQuery('#gm-message').append(data);
1248
+ }
1249
+ });
1250
+ jQuery('#shareModal').modal('hide');
1251
+ });
1252
+ gmedia_DOM.on('click', 'a.share-modal', function(e) {
1253
+ e.preventDefault();
1254
+ var data = jQuery(this).data(),
1255
+ modal_div = jQuery(data['target']),
1256
+ postlink = jQuery(this).attr('href'),
1257
+ cloudlink = jQuery(this).attr('data-gmediacloud'),
1258
+ sharetoemail = jQuery('input.sharetoemail'),
1259
+ cloudlink_checked = false;
1260
+
1261
+ if (postlink) {
1262
+ jQuery('.sharelink_post', modal_div).show();
1263
+ jQuery('.sharelink_post input[type="text"]', modal_div).val(postlink);
1264
+ jQuery('.sharelink_post a', modal_div).attr('href', postlink);
1265
+ }
1266
+ else {
1267
+ jQuery('.sharelink_post', modal_div).hide();
1268
+ jQuery('.sharelink_post input[type="radio"]', modal_div).prop('checked', false);
1269
+ cloudlink_checked = true;
1270
+ }
1271
+ if (cloudlink) {
1272
+ jQuery('.sharelink_page', modal_div).show();
1273
+ jQuery('.sharelink_page input[type="text"]', modal_div).val(cloudlink);
1274
+ jQuery('.sharelink_page a', modal_div).attr('href', cloudlink);
1275
+ if (cloudlink_checked) {
1276
+ jQuery('.sharelink_page input[type="radio"]', modal_div).prop('checked', true);
1277
+ }
1278
+ }
1279
+ else {
1280
+ jQuery('.sharelink_page', modal_div).hide();
1281
+ }
1282
+ jQuery('.sharebutton').prop('disabled', !validateEmail(sharetoemail.val()));
1283
+
1284
+ modal_div.modal({
1285
+ backdrop: true,
1286
+ show: true,
1287
+ keyboard: false
1288
+ }).one('shown.bs.modal', function() {
1289
+ jQuery('input.sharelink', this).focus();
1290
+ }).one('hidden.bs.modal', function() {
1291
+ jQuery('input.sharelink', this).val('');
1292
+ });
1293
+ });
1294
 
1295
+ gmedia_DOM.on('click', '.buildquery-modal', function(e) {
1296
+ e.preventDefault();
1297
+ var data = jQuery(this).data(),
1298
+ modal_div = jQuery(jQuery(this).attr('href')),
1299
+ query_field = jQuery(jQuery(this).attr('id') + '_field'),
1300
+ query = query_field.val();
1301
+
1302
+ modal_div.modal({
1303
+ backdrop: true,
1304
+ show: true,
1305
+ keyboard: false
1306
+ }).one('shown.bs.modal', function() {
1307
+ if (query) {
1308
+ query = gm_parse_query(query);
1309
+ }
1310
+ }).one('hidden.bs.modal', function() {});
1311
+ });
 
1312
 
1313
+ jQuery(document).on('click.gmedia', '.buildquerysubmit', function() {
1314
+ var qform = jQuery('#buildQuery :input').filter(function() {
1315
+ return !!jQuery(this).val();
1316
+ });
1317
 
1318
+ qform = decodeURIComponent(qform.serialize());
1319
+ jQuery('#build_query_field').val(qform);
1320
+ jQuery('#buildQuery').modal('hide');
1321
+ });
1322
+ gmedia_DOM.on('click', 'a.newcustomfield-modal', function(e) {
1323
+ e.preventDefault();
1324
+ var data = jQuery(this).data(),
1325
+ modal_div = jQuery(jQuery(this).attr('href'));
1326
+
1327
+ modal_div.modal({
1328
+ backdrop: false,
1329
+ show: true,
1330
+ keyboard: false
1331
+ }).one('shown.bs.modal', function() {
1332
+ jQuery('input.newcustomfield-for-id', this).val(data['gmid']);
1333
+ }).one('hidden.bs.modal', function() {
1334
+ jQuery(':input.form-control, input.newcustomfield-for-id', this).val('');
1335
+ if (jQuery('.newcfield', this).length) {
1336
+ jQuery('a.gmediacustomstuff').click();
1337
+ }
1338
+ });
1339
+ });
1340
+ jQuery(document).on('click.gmedia', '.customfieldsubmit', function() {
1341
+ var cform = jQuery('#newCustomFieldForm');
1342
+ if (!jQuery('.newcustomfield-for-id', cform).val()) {
1343
+ jQuery('#newCustomFieldModal').modal('hide');
1344
+ alert('No ID');
1345
+ return false;
1346
+ }
1347
+ var post_data = cform.serialize();
1348
+ jQuery.post(ajaxurl, post_data, function(data, textStatus, jqXHR) {
1349
+ jQuery('body').removeClass('gmedia-busy');
1350
+ if (data.success) {
1351
+ jQuery('#newCustomFieldModal').modal('hide').one('hidden.bs.modal', function() {
1352
+ //noinspection JSUnresolvedVariable
1353
+ if (data.newmeta_form) {
1354
+ //noinspection JSUnresolvedVariable
1355
+ jQuery('#newmeta').replaceWith(data.newmeta_form);
1356
  }
1357
+ });
1358
+ jQuery('.row:last', '#gmediacustomstuff_' + data.id).append(data.success.data);
1359
+ }
1360
+ else {
1361
+ if (data.error) {
1362
+ if ('100' === data.error.code) {
1363
+ jQuery('#newCustomFieldModal').modal('hide');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1364
  }
1365
+ alert(data.error.message);
1366
+ }
1367
+ else {
1368
+ console.log(data);
1369
+ }
1370
+ }
1371
+ });
1372
+ });
1373
+ gmedia_DOM.on('click', '.delete-custom-field', function() {
1374
+ var t = jQuery(this).closest('.form-group'),
1375
+ post_data = convertInputsToJSON(jQuery(':input', t));
1376
+ if (!post_data) {
1377
+ return false;
1378
+ }
1379
+ var meta_type = jQuery(this).closest('fieldset').attr('data-metatype');
1380
+ post_data.action = meta_type + '_delete_custom_field';
1381
+ post_data.ID = jQuery(this).closest('form').attr('data-id');
1382
+ post_data._wpnonce_custom_field = jQuery('#_wpnonce_custom_field').val();
1383
+ jQuery.post(ajaxurl, post_data, function(data, textStatus, jqXHR) {
1384
+ jQuery('body').removeClass('gmedia-busy');
1385
+ //noinspection JSUnresolvedVariable
1386
+ if (data.deleted) {
1387
+ //noinspection JSUnresolvedVariable
1388
+ jQuery.each(data.deleted, function(i, val) {
1389
+ jQuery('.gm-custom-meta-' + val).remove();
1390
+ });
1391
+ }
1392
+ else {
1393
+ if (data.error) {
1394
+ alert(data.error.message);
1395
+ }
1396
+ else {
1397
+ console.log(data);
1398
+ }
1399
+ }
1400
+ });
1401
+ });
1402
 
1403
+ gmedia_DOM.on('change modified', 'form.edit-gmedia :input:not([name="doaction[]"])', function() {
1404
+ if (jQuery(this).hasClass('edit-gmedia-ignore')) {
1405
+ return;
1406
+ }
1407
+ jQuery('body').addClass('gmedia-busy');
1408
+ jQuery('.panel-heading .spinner').addClass('is-active');
1409
+ var post_data = {
1410
+ action: 'gmedia_update_data', data: jQuery(this).closest('form').serialize(), _wpnonce: jQuery('#_wpnonce').val()
1411
+ };
1412
+ jQuery.post(ajaxurl, post_data, function(data, textStatus, jqXHR) {
1413
+ var item = jQuery('#list-item-' + data.ID);
1414
+ item.find('.modified').text(data.modified);
1415
+ //noinspection JSUnresolvedVariable
1416
+ item.find('.status-album').attr('class', 'form-group status-album bg-status-' + data.album_status);
1417
+ item.find('.status-item').attr('class', 'form-group status-item bg-status-' + data.status);
1418
+ if (data.thumbnail) {
1419
+ item.find('.gmedia-cover-image').html(data.thumbnail);
1420
+ }
1421
+ //if(data.tags) {
1422
+ // item.find('.gmedia_tags_input').val(data.tags);
1423
+ //}
1424
+ //noinspection JSUnresolvedVariable
1425
+ if (data.meta_error) {
1426
+ jQuery.each(data.meta_error, function(i, err) {
1427
+ console.log(err);
1428
+ alert(err.meta_key + ': ' + err.message);
1429
+ if (err.meta_value) {
1430
+ jQuery('.gm-custom-field-' + err.meta_id).val(err.meta_value);
1431
  }
1432
+ });
1433
+ }
1434
+ jQuery('body').removeClass('gmedia-busy');
1435
+ jQuery('.panel-heading .spinner').removeClass('is-active');
1436
+ });
1437
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1438
 
1439
+ gmedia_DOM.on('click', '.gm-toggle-cb', function(e) {
1440
+ var checkBoxes = jQuery(this).attr('href');
1441
+ jQuery(checkBoxes + ' :checkbox').each(function() {
1442
+ jQuery(this).prop('checked', !jQuery(this).prop('checked'));
1443
+ });
1444
+ e.preventDefault();
1445
+ });
1446
+ jQuery(document).on('click.gmedia', '.linkblock [data-href]', function() {
1447
+ window.location.href = jQuery(this).data('href');
1448
+ });
1449
 
1450
+ gmedia_DOM.on('click', '.gmedia-import', function() {
1451
+ jQuery('#import-action').val(jQuery(this).attr('name'));
1452
+ jQuery('#importModal').modal({
1453
+ backdrop: 'static',
1454
+ show: true,
1455
+ keyboard: false
1456
+ }).one('shown.bs.modal', function() {
1457
+ jQuery('#import_form').submit();
1458
+ }).one('hidden.bs.modal', function() {
1459
+ var btn = jQuery('#import-done');
1460
+ btn.text(btn.data('reset-text')).prop('disabled', true);
1461
+ jQuery('#import_window').attr('src', 'about:blank');
1462
+ });
1463
+ });
1464
 
1465
+ gmedia_DOM.on('click', '.module_install', function(e) {
1466
+ e.preventDefault();
1467
+ jQuery('body').addClass('gmedia-busy');
1468
+ var module = jQuery(this).data('module');
1469
+ var btn = jQuery('.module_install').filter('[data-module="' + module + '"]');
1470
+ btn.text(btn.data('loading-text'));
1471
+ var post_data = {
1472
+ action: 'gmedia_module_install', download: jQuery(this).attr('href'), module: module, _wpnonce: jQuery('#_wpnonce').val()
1473
+ };
1474
+ var pathname = window.location.href + '&time=' + jQuery.now();
1475
+ jQuery.post(ajaxurl, post_data, function(data, status, xhr) {
1476
+ setTimeout(function() {
1477
+ jQuery('#gmedia_modules').load(pathname + ' #gmedia_modules_wrapper', function() {
1478
+ setTimeout(function() {
1479
+ var update_count = jQuery('#gmedia_modules').find('#gmedia_modules_wrapper').attr('data-update');
1480
+ if (parseInt(update_count)) {
1481
+ jQuery('.gm-module-count').html(update_count);
1482
+ }
1483
+ else {
1484
+ jQuery('.gm-module-count').remove();
1485
+ }
1486
+ }, 1);
1487
+ });
1488
+ }, 1);
1489
+ jQuery('#gmedia_modules').before(data);
1490
+ jQuery('body').removeClass('gmedia-busy');
1491
+ });
1492
+ });
1493
 
1494
+ gmedia_DOM.on('keydown', 'form :input:visible:not(:submit,:button,:reset,textarea,.allow-key-enter)', function(e) {
1495
+ var charCode = e.charCode || e.keyCode || e.which;
1496
+ if (13 === charCode && !jQuery(this).parent().hasClass('selectize-input')) {
1497
+ var inputs = jQuery(this).parents('form').eq(0).find(':input:visible');
1498
+ var inp = inputs[inputs.index(this) + 1];
1499
+ if (inp !== null) {
1500
+ jQuery(inp).focus();
1501
+ var inp_type = jQuery(inp).attr('type');
1502
+ if (!!inp_type && (inp_type === 'text' || inp_type === 'number')) {
1503
+ inp.setSelectionRange(0, inp.value.length);
1504
+ }
1505
+ }
1506
+ e.preventDefault();
1507
+ return false;
1508
+ }
1509
+ });
 
1510
 
1511
+ var preset_popover = function() {
1512
+ jQuery('#module_presets').popover({
1513
+ container: '#module_preset',
1514
+ content: function() {
1515
+ return jQuery('#_module_presets').html();
1516
+ },
1517
+ html: true,
1518
+ placement: 'bottom'
1519
+ }).on('show.bs.popover', function() {
1520
+ jQuery(this).addClass('active');
1521
+ }).on('hide.bs.popover', function() {
1522
+ jQuery(this).removeClass('active');
1523
+ });
1524
+ };
1525
+ preset_popover();
1526
+ gmedia_DOM.on('click', '#module_preset .ajax-submit', function(e) {
1527
+ e.preventDefault();
1528
+ jQuery('body').addClass('gmedia-busy');
1529
+ var form = jQuery('#gmedia-edit-term');
1530
+ var post_data = form.serializeArray();
1531
+ post_data.push({name: jQuery(this).attr('name'), value: 1});
1532
+ var pathname = window.location.href;
1533
+ jQuery.post(pathname, jQuery.param(post_data), function(data, status, xhr) {
1534
+ jQuery('body').removeClass('gmedia-busy');
1535
+ data = jQuery(data).find('#gmedia-container');
1536
+ jQuery('#gm-message').append(jQuery('#gm-message', data).html());
1537
+ jQuery('#save_buttons').html(jQuery('#save_buttons', data).html());
1538
+ jQuery('#save_buttons_duplicate').html(jQuery('#save_buttons_duplicate', data).html());
1539
+ jQuery('#module_preset').html(jQuery('#module_preset', data).html());
1540
  preset_popover();
1541
+ });
1542
+ });
1543
+ jQuery(document).on('click.gmedia', function(e) {
1544
+ if (jQuery(e.target).data('toggle') !== 'popover'
1545
+ && jQuery(e.target).parents('.popover.in').length === 0) {
1546
+ jQuery('[data-toggle="popover"]').popover('hide');
1547
+ }
1548
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1549
 
1550
+ gmedia_DOM.on('click', '[data-clicktarget]', function(e) {
1551
+ e.preventDefault();
1552
+ var id = jQuery(this).attr('data-clicktarget');
1553
+ jQuery('#' + id).click();
1554
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
1555
 
1556
+ gmedia_DOM.on('click', '#module_preset .delpreset span, .module_presets .delpreset span', function() {
1557
+ jQuery('body').addClass('gmedia-busy');
1558
+ var module_preset = this;
1559
+ var preset_item_li = jQuery(this).closest('li');
1560
+ var preset_id = jQuery(this).data('id');
1561
+ var post_data = {
1562
+ action: 'gmedia_module_preset_delete', preset_id: preset_id, _wpnonce: jQuery('#_wpnonce').val()
1563
+ };
1564
+ jQuery.post(ajaxurl, post_data, function(data, status, xhr) {
1565
+ if (data.error) {
1566
+ jQuery('#gm-message').append(data.error);
1567
+ }
1568
+ else {
1569
+ preset_item_li.remove();
1570
+ if ('module_presets_list' !== jQuery(this).attr('id')) {
1571
+ var _module_presets = jQuery('#module_preset').find('.popover-content').html();
1572
+ jQuery('#_module_presets').replaceWith('<script type="text/html" id="_module_presets">' + _module_presets + '</script>');
1573
+ }
1574
+ }
1575
+ jQuery('body').removeClass('gmedia-busy');
1576
+ });
1577
+ });
1578
 
1579
+ gmedia_DOM.on('click', '.filter-modules > *', function() {
1580
+ jQuery('.filter-modules > .btn-primary').removeClass('btn-primary').addClass('btn-default');
1581
+ jQuery('.filter-modules > .label-primary').removeClass('label-primary').addClass('label-default');
1582
+ if (jQuery(this).is('button')) {
1583
+ jQuery(this).addClass('btn-primary').removeClass('btn-default');
1584
+ }
1585
+ else {
1586
+ jQuery(this).addClass('label-primary').removeClass('label-default');
1587
+ }
1588
+ var filter = jQuery(this).attr('data-filter');
1589
+ jQuery('#gmedia_modules .media').removeClass('module-filtered').filter('.module-' + filter).addClass('module-filtered');
1590
+ if (!jQuery('#gmedia_modules .module-filtered').length) {
1591
+ if ('not-installed' === filter) {
1592
+ jQuery('#gmedia_modules .nomodules.nomodule-' + filter).addClass('module-filtered');
1593
  }
1594
+ else {
1595
+ jQuery('#gmedia_modules .nomodules.nomodule-tag').addClass('module-filtered');
1596
+ }
1597
+ }
1598
+ });
1599
 
1600
+ if (jQuery('.panel-fixed-header').length) {
1601
+ setPanelHeadersWidth();
1602
+ setTimeout(function() {
1603
+ setPanelHeadersWidth();
1604
+ }, 800);
1605
+ jQuery(window).on('resize.gmedia', function() {
1606
+ setPanelHeadersWidth();
1607
+ });
1608
+ jQuery(document).on('click.gmedia', '#collapse-menu', function() {
1609
+ setTimeout(function() {
1610
+ setPanelHeadersWidth();
1611
+ }, 10);
1612
+ });
1613
+
1614
+ jQuery(window).on('scroll.gmedia', function() {
1615
+ UpdatePanelHeaders();
1616
+ /*clearTimeout(jQuery.data(this, 'scrollTimer'));
1617
+ jQuery.data(this, 'scrollTimer', setTimeout(function() {
1618
+ UpdatePanelHeaders();
1619
+ }, 250));*/
1620
+ }).trigger('scroll.gmedia');
1621
  }
 
1622
 
1623
+ }
1624
+ };
1625
 
1626
  window.closeModal = function(id) {
1627
+ jQuery('#' + id).modal('hide');
1628
  };
1629
 
 
1630
  /*
1631
  * jQuery functions for GRAND Media
1632
  */
1633
+ function GmediaInit() {
1634
+ gmedia_DOM = jQuery('#gmedia-container');
1635
+ gmedia_DOM.off();
1636
+ jQuery(window).off('.gmedia');
1637
+ jQuery(document).off('.gmedia');
1638
+
1639
+ GmediaSelect.init();
1640
+ GmediaFunction.init();
1641
+
1642
+ if (jQuery('body').hasClass('GrandMedia')) {
1643
+ GmediaLibrary.init();
1644
+ }
1645
+ if (jQuery('body').hasClass('GrandMedia_AddMedia')) {
1646
+ GmediaAddMedia.init();
1647
+ }
1648
+ if (jQuery('body').is('.GrandMedia_Tags,.GrandMedia_Categories,.GrandMedia_Albums,.GrandMedia_Galleries')) {
1649
+ GmediaTerms.init();
1650
+ }
1651
+
1652
+ var helper, helper_width, title;
1653
+ jQuery('[title]', gmedia_DOM).each(function() {
1654
+ title = jQuery(this).attr('title');
1655
+ if (title) {
1656
+ jQuery(this).attr('title', '').attr('data-title', title);
1657
  }
1658
+ });
1659
+ gmedia_DOM.on('mouseenter', '[title]', function(e) {
1660
+ title = jQuery(this).attr('data-title');
1661
+ if (title) {
1662
+ helper = jQuery('<div id="gmedia-data-helper"></div>').html(_.escape(title)).appendTo('body');
1663
+ helper_width = 0;
1664
+ if (e.pageX > (window.innerWidth / 2)) {
1665
+ helper_width = helper.width() - 25;
1666
+ helper.addClass('tiptoleft');
1667
+ }
1668
+ helper.css({left: e.clientX - helper_width - 25, top: e.clientY + 25});
1669
  }
1670
+ else {
1671
+ jQuery(this).removeAttr('title');
1672
  }
1673
+ }).on('mousemove', '[title]', function(e) {
1674
+ if (helper) {
1675
+ helper.css({left: e.clientX - helper_width - 25, top: e.clientY + 25});
1676
+ }
1677
+ }).on('mouseleave', '[title]', function(e) {
1678
+ jQuery('#gmedia-data-helper').remove();
1679
+ helper = null;
1680
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1681
  }
1682
+
1683
+ jQuery(function() {
1684
+ GmediaInit();
1685
  });
1686
 
1687
  function convertInputsToJSON(form) {
1688
+ var array = jQuery(form).serializeArray();
1689
+ var json = {};
1690
 
1691
+ jQuery.each(array, function() {
1692
+ json[this.name] = this.value || '';
1693
+ });
1694
 
1695
+ return json;
1696
  }
1697
 
1698
  function gm_parse_query(s) {
1699
+ var j = {},
1700
+ res = s.split(/&/gm).map(function(e) {
1701
+ var o = e.split(/=/),
1702
+ pt = j;
1703
+ if (typeof o[1] === 'undefined') {
1704
+ o[1] = '';
1705
+ }
1706
+ o[0].replace(/^(\w+)\[([^&]*)\]/, '$1][$2').split(/\]\[/).map(function(e, i, a) {
1707
+ if (e === '') {
1708
+ e = Object.keys(pt).length;
1709
+ }
1710
+ pt = (pt[e] = pt[e] || (i === a.length - 1 ? decodeURIComponent(o[1].replace(/\+/, ' ')) : {}));
1711
+ });
1712
+ });
1713
+ return j;
1714
  }
1715
 
1716
  function validateEmail(email) {
1717
+ var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
1718
+ return re.test(email);
1719
  }
1720
 
1721
  function getStorage() {
1722
+ // use document.cookie:
1723
+ return {
1724
+ set: function(id, data) {
1725
+ document.cookie = id + '=' + encodeURIComponent(data);
1726
+ },
1727
+ get: function(id) {
1728
+ var cookies = document.cookie, parsed = {};
1729
+ cookies.replace(/([^=]+)=([^;]*);?\s*/g, function(whole, key, value) {
1730
+ parsed[key] = decodeURIComponent(value);
1731
+ });
1732
+ return parsed[id];
1733
+ }
1734
+ };
1735
  }
1736
 
1737
+ function getDocHeight(id) {
1738
+ var H;
1739
+ if (id) {
1740
+ H = Math.max(
1741
+ jQuery('#' + id).height(),
1742
+ document.getElementById(id).clientHeight
1743
+ );
1744
+ }
1745
+ else {
1746
+ H = Math.max(
1747
+ jQuery(document).height(),
1748
+ jQuery(window).height(),
1749
+ document.documentElement.clientHeight
1750
+ );
1751
+ }
1752
+
1753
+ return H;
1754
+ }
1755
 
1756
+ // function gmHashCode(str) {
1757
+ // var l = str.length,
1758
+ // hash = 5381 * l * (str.charCodeAt(0) + l);
1759
+ // for (var i = 0; i < str.length; i++) {
1760
+ // hash += Math.floor((str.charCodeAt(i) + i + 0.33) / (str.charCodeAt(l - i - 1) + l) + (str.charCodeAt(i) + l) * (str.charCodeAt(l - i - 1) + i + 0.33));
1761
+ // }
1762
+ // return hash;
1763
+ // }
1764
+ //
1765
+ // function gmCreateKey(site, lic, uuid) {
1766
+ // if (!lic) {
1767
+ // lic = '0:lk';
1768
+ // }
1769
+ // if (!uuid) {
1770
+ // uuid = 'xyxx-xxyx-xxxy';
1771
+ // }
1772
+ // var d = gmHashCode((site + ':' + lic).toLowerCase());
1773
+ // var p = d;
1774
+ // uuid = uuid.replace(/[xy]/g, function(c) {
1775
+ // var r = d % 16 | 0, v = c === 'x' ? r : (r & 0x7 | 0x8);
1776
+ // d = Math.floor(d * 15 / 16);
1777
+ // return v.toString(16);
1778
+ // });
1779
+ // var key = p + ': ' + lic + '-' + uuid;
1780
+ // return key.toLowerCase();
1781
+ // }
 
 
 
1782
 
1783
  function UpdatePanelHeaders() {
1784
+ jQuery('.panel-fixed-header').each(function() {
1785
+ var el = jQuery(this),
1786
+ headerRow = jQuery('.panel-heading', this),
1787
+ offset = el.offset(),
1788
+ scrollTop = jQuery(window).scrollTop(),
1789
+ floatingHeader = 'panel-floatingHeader',
1790
+ absoluteHeader = 'panel-absoluteHeader',
1791
+ pad_top = jQuery('#wpadminbar').height();
1792
+
1793
+ if ((scrollTop > offset.top - pad_top) && (scrollTop < offset.top - pad_top + (el.height() - headerRow.outerHeight(false)) + 4)) {
1794
+ el.addClass(floatingHeader).removeClass(absoluteHeader);
1795
+ }
1796
+ else if (scrollTop > (offset.top - pad_top + (el.height() - headerRow.outerHeight(false)))) {
1797
+ el.addClass(absoluteHeader).removeClass(floatingHeader);
1798
+ }
1799
+ else {
1800
+ el.removeClass(absoluteHeader + ' ' + floatingHeader);
1801
+ }
1802
+ });
1803
  }
1804
 
1805
  function setPanelHeadersWidth() {
1806
+ jQuery('.panel-fixed-header').each(function() {
1807
+ var headerRow = jQuery('.panel-heading', this);
1808
+ headerRow.css('width', jQuery(this).innerWidth());
1809
+ jQuery('.panel-heading-fake', this).height(headerRow.outerHeight());
1810
+ });
1811
  }
admin/assets/js/gmedia.global.js CHANGED
@@ -1,8 +1,8 @@
1
- /**
2
- * Gmedia Globals
3
- * @var GmediaGallery
4
- */
5
- if(!ajaxurl) {
6
- //noinspection JSUnresolvedVariable
7
- var ajaxurl = GmediaGallery.ajaxurl;
8
- }
1
+ /**
2
+ * Gmedia Globals
3
+ * @var GmediaGallery
4
+ */
5
+ if (!ajaxurl) {
6
+ //noinspection JSUnresolvedVariable
7
+ var ajaxurl = GmediaGallery.ajaxurl;
8
+ }
admin/assets/js/gmedia.metabox.js CHANGED
@@ -1,250 +1,261 @@
1
- var gmActiveEditor = false;
2
- (function ($, window, document, undefined) {
3
-
4
- /*
5
- $('body').on('click', 'textarea.wp-editor-area', function(){
6
- gmActiveEditor = $(this).attr('id');
7
- setTimeout(function(){
8
- gm_check_scode(gmActiveEditor);
9
- }, 10);
10
- });
11
-
12
- $("#gmedia-wraper").resizable({
13
- handles: 'e',
14
- start: function(event, ui){
15
- $('iframe').css('pointer-events', 'none');
16
- },
17
- stop: function(event, ui){
18
- $('iframe').css('pointer-events', 'auto');
19
- $('#gmedia-images-wrap').trigger('scroll');
20
- },
21
- resize: function(event, ui){
22
- ui.element.height('auto');
23
- }
24
- });
25
- $("#gmedia-galleries").resizable({
26
- handles: 's',
27
- minHeight: 94,
28
- start: function(event, ui){
29
- $('iframe').css('pointer-events', 'none');
30
- },
31
- stop: function(event, ui){
32
- $('iframe').css('pointer-events', 'auto');
33
- ui.element.width('auto');
34
- }
35
- });
36
-
37
- $('li.gmedia-gallery-li').click(function(e){
38
- if($(e.target).hasClass('gmedia-gallery-gear')){
39
- return;
40
- }
41
- var m, html, gm_id = $(this).attr('id').split('-')[1];
42
- if($(this).hasClass('gmedia-selected')){
43
- if(gm_delete_scode(gm_id)){
44
- $(this).removeClass('gmedia-selected');
45
- } else{
46
- // Show message "Focus textarea"
47
- m = $('#gmedia-message .info-textarea');
48
- m.slideDown(100, function(){
49
- setTimeout(function(){
50
- m.slideUp(100);
51
- }, 1000);
52
- });
53
- }
54
- } else{
55
- html = '[gmedia id=' + gm_id + ']';
56
- if(gm_send_to_editor(html)){
57
- $(this).addClass('gmedia-selected');
58
- } else{
59
- m = $('#gmedia-message .info-textarea');
60
- m.slideDown(100, function(){
61
- setTimeout(function(){
62
- m.slideUp(100);
63
- }, 1000);
64
- });
65
- }
66
- }
67
- e.preventDefault();
68
- });
69
-
70
- setTimeout(function(){
71
- gm_check_scode(false);
72
- }, 1000);
73
-
74
- $('textarea.wp-editor-area').on('keyup', function(e){
75
- var k = e.keyCode || e.charCode;
76
- if(k == 8 || k == 13 || k == 46){
77
- var m, content = $(this).val();
78
- m = content.match(/\[gmedia [ ]*id=(\d+)[ ]*?\]/g);
79
- jQuery('#gmedia-galleries-list li.gmedia-gallery-li').removeClass('gmedia-selected');
80
- if(m){
81
- jQuery.each(m, function(i, shcode){
82
- var id = shcode.replace(/\[gmedia [ ]*id=(\d+)[ ]*?\]/, '$1');
83
- jQuery('#gmGallery-' + id).addClass('gmedia-selected');
84
- });
85
- }
86
- }
87
- });
88
-
89
- */
90
-
91
- $(document).on('click', '#gmedia-modal', function (e) {
92
- e.stopPropagation();
93
- e.preventDefault();
94
- gmedia_post_modal(this);
95
- });
96
-
97
- $('#postimagediv').on('click', '#set-gmedia-post-thumbnail', function (e) {
98
- e.stopPropagation();
99
- e.preventDefault();
100
- gmedia_post_modal();
101
- var modal = $('#__gm-uploader');
102
- var library = modal.find('#gmedia-modal-library');
103
- if (!library.hasClass('active')) {
104
- var ifr = modal.find('iframe').clone();
105
- ifr.attr('src', library.attr('href'));
106
- library.trigger('click');
107
- modal.find('iframe').replaceWith(ifr);
108
- }
109
- });
110
-
111
- })(jQuery, window, document, undefined);
112
-
113
- function gmedia_post_modal(el) {
114
- var modal = jQuery('#__gm-uploader');
115
-
116
- if (modal.length) {
117
- modal.css('display', 'block');
118
- } else {
119
- //var title = jQuery(el).attr('title');
120
- modal = jQuery(jQuery('#tpl__gm-uploader').html());
121
- modal.find('.media-modal-close, .media-modal-backdrop').on('click', function () {
122
- modal.css('display', 'none');
123
- });
124
- modal.find('.media-menu-item').on('click', function () {
125
- jQuery('iframe', modal).attr('src', jQuery(this).attr('href'));
126
- jQuery(this).addClass('active').siblings('a').removeClass('active');
127
- jQuery('.media-frame-title h1', modal).text(jQuery(this).text());
128
- });
129
- jQuery('body').append(modal);
130
- }
131
- }
132
-
133
- /*
134
- function gm_check_scode(id){
135
- if(!id && ("undefined" != typeof(tinymce)) && tinymce.activeEditor){
136
- id = tinymce.activeEditor.id;
137
- }
138
- if(!id){
139
- id = 'content'
140
- }
141
- var temp_html = jQuery('textarea#' + id).val();
142
- if(temp_html){
143
- var temp_m = temp_html.match(/\[gmedia [ ]*id=(\d+)[ ]*?]/g);
144
- if(temp_m){
145
- jQuery.each(temp_m, function(i, shcode){
146
- var id = shcode.replace(/\[gm.*id=(\d+).*?]/, '$1');
147
- jQuery('#gmGallery-' + id).addClass('gmedia-selected');
148
- });
149
- }
150
- }
151
- }
152
-
153
- function gm_send_to_editor(c){
154
- var b, a = typeof(tinymce) != "undefined", f = typeof(QTags) != "undefined";
155
- if(!wpActiveEditor){
156
- if(a && tinymce.activeEditor){
157
- b = tinymce.activeEditor;
158
- wpActiveEditor = b.id;
159
- } else{
160
- if(gmActiveEditor){
161
- wpActiveEditor = gmActiveEditor;
162
- } else{
163
- return false;
164
- }
165
- }
166
- } else{
167
- if(a){
168
- if(tinymce.activeEditor && (tinymce.activeEditor.id == "mce_fullscreen" || tinymce.activeEditor.id == "wp_mce_fullscreen")){
169
- b = tinymce.activeEditor;
170
- } else{
171
- b = tinymce.get(wpActiveEditor);
172
- }
173
- }
174
- }
175
- if(b && !b.isHidden()){
176
- //noinspection JSUnresolvedVariable
177
- if(tinymce.isIE && b.windowManager.insertimagebookmark){
178
- //noinspection JSUnresolvedVariable
179
- b.selection.moveToBookmark(b.windowManager.insertimagebookmark);
180
- //console.log(b);
181
- }
182
- if(c.indexOf("[caption") === 0){
183
- //noinspection JSUnresolvedVariable
184
- if(b.plugins.wpeditimage){
185
- //noinspection JSUnresolvedVariable
186
- c = b.plugins.wpeditimage._do_shcode(c)
187
- }
188
- } else{
189
- c = '<p>' + c + '</p>';
190
- }
191
- b.execCommand("mceInsertContent", false, c);
192
- } else{
193
- if(f){
194
- QTags.insertContent(c);
195
- } else{
196
- document.getElementById(wpActiveEditor).value += c;
197
- }
198
- }
199
- return true;
200
- }
201
-
202
- function gm_delete_scode(c){
203
- var b, a = typeof(tinymce) != "undefined", re, html;
204
- if(!wpActiveEditor){
205
- if(a && tinymce.activeEditor){
206
- b = tinymce.activeEditor;
207
- wpActiveEditor = b.id;
208
- } else{
209
- if(gmActiveEditor){
210
- wpActiveEditor = gmActiveEditor;
211
- } else{
212
- return false;
213
- }
214
- }
215
- } else{
216
- if(a){
217
- if(tinymce.activeEditor && (tinymce.activeEditor.id == "mce_fullscreen" || tinymce.activeEditor.id == "wp_mce_fullscreen")){
218
- b = tinymce.activeEditor;
219
- } else{
220
- b = tinymce.get(wpActiveEditor);
221
- }
222
- }
223
- }
224
- if(b && !b.isHidden()){
225
- html = b.getContent();
226
- re = new RegExp("(?:<p>)?\\[gmedia \\s*id=" + c + "\\s*?\\](?:<\\/p>)?", "g");
227
- b.setContent(html.replace(re, ''));
228
- } else{
229
- html = document.getElementById(wpActiveEditor).value;
230
- re = new RegExp("\\[gmedia [ ]*id=" + c + "[ ]*?\\](?:\\n\\n|\\n)?", "g");
231
- html = html.replace(re, '');
232
- document.getElementById(wpActiveEditor).value = html;
233
- }
234
- return true;
235
- }
236
-
237
- function gm_media_button(b){
238
- var pos, el = jQuery(b).toggleClass('active');
239
- if(el.hasClass('active')){
240
- pos = el.offset();
241
- pos.top += el.height() + 1;
242
- var w = 300;
243
- jQuery('#gmedia-wraper').appendTo('body').css({'position': 'absolute', 'z-index': 99999, 'width': w}).offset(pos);
244
- jQuery("#gmedia-wraper").draggable({ handle: ".title-bar" });
245
- } else{
246
- jQuery('#gmedia-wraper').removeAttr('style').appendTo('#gmedia-MetaBox .inside');
247
- jQuery('#gmedia-wraper').draggable('destroy');
248
- }
249
- }
250
- */
 
 
 
 
 
 
 
 
 
 
 
1
+ var gmActiveEditor = false;
2
+ (function($, window, document, undefined) {
3
+
4
+ // $('body').on('click', 'textarea.wp-editor-area', function() {
5
+ // gmActiveEditor = $(this).attr('id');
6
+ // setTimeout(function() {
7
+ // gm_check_scode(gmActiveEditor);
8
+ // }, 10);
9
+ // });
10
+ //
11
+ // $('#gmedia-wraper').resizable({
12
+ // handles: 'e',
13
+ // start: function(event, ui) {
14
+ // $('iframe').css('pointer-events', 'none');
15
+ // },
16
+ // stop: function(event, ui) {
17
+ // $('iframe').css('pointer-events', 'auto');
18
+ // $('#gmedia-images-wrap').trigger('scroll');
19
+ // },
20
+ // resize: function(event, ui) {
21
+ // ui.element.height('auto');
22
+ // }
23
+ // });
24
+ // $('#gmedia-galleries').resizable({
25
+ // handles: 's',
26
+ // minHeight: 94,
27
+ // start: function(event, ui) {
28
+ // $('iframe').css('pointer-events', 'none');
29
+ // },
30
+ // stop: function(event, ui) {
31
+ // $('iframe').css('pointer-events', 'auto');
32
+ // ui.element.width('auto');
33
+ // }
34
+ // });
35
+ //
36
+ // $('li.gmedia-gallery-li').click(function(e) {
37
+ // if ($(e.target).hasClass('gmedia-gallery-gear')) {
38
+ // return;
39
+ // }
40
+ // var m, html, gm_id = $(this).attr('id').split('-')[1];
41
+ // if ($(this).hasClass('gmedia-selected')) {
42
+ // if (gm_delete_scode(gm_id)) {
43
+ // $(this).removeClass('gmedia-selected');
44
+ // }
45
+ // else {
46
+ // // Show message "Focus textarea"
47
+ // m = $('#gmedia-message .info-textarea');
48
+ // m.slideDown(100, function() {
49
+ // setTimeout(function() {
50
+ // m.slideUp(100);
51
+ // }, 1000);
52
+ // });
53
+ // }
54
+ // }
55
+ // else {
56
+ // html = '[gmedia id=' + gm_id + ']';
57
+ // if (gm_send_to_editor(html)) {
58
+ // $(this).addClass('gmedia-selected');
59
+ // }
60
+ // else {
61
+ // m = $('#gmedia-message .info-textarea');
62
+ // m.slideDown(100, function() {
63
+ // setTimeout(function() {
64
+ // m.slideUp(100);
65
+ // }, 1000);
66
+ // });
67
+ // }
68
+ // }
69
+ // e.preventDefault();
70
+ // });
71
+ //
72
+ // setTimeout(function() {
73
+ // gm_check_scode(false);
74
+ // }, 1000);
75
+ //
76
+ // $('textarea.wp-editor-area').on('keyup', function(e) {
77
+ // var k = e.keyCode || e.charCode;
78
+ // if (k == 8 || k == 13 || k == 46) {
79
+ // var m, content = $(this).val();
80
+ // m = content.match(/\[gmedia [ ]*id=(\d+)[ ]*?\]/g);
81
+ // jQuery('#gmedia-galleries-list li.gmedia-gallery-li').removeClass('gmedia-selected');
82
+ // if (m) {
83
+ // jQuery.each(m, function(i, shcode) {
84
+ // var id = shcode.replace(/\[gmedia [ ]*id=(\d+)[ ]*?\]/, '$1');
85
+ // jQuery('#gmGallery-' + id).addClass('gmedia-selected');
86
+ // });
87
+ // }
88
+ // }
89
+ // });
90
+
91
+ $(document).on('click', '#gmedia-modal', function(e) {
92
+ e.stopPropagation();
93
+ e.preventDefault();
94
+ gmedia_post_modal(this);
95
+ });
96
+
97
+ $('#postimagediv').on('click', '#set-gmedia-post-thumbnail', function(e) {
98
+ e.stopPropagation();
99
+ e.preventDefault();
100
+ gmedia_post_modal();
101
+ var modal = $('#__gm-uploader');
102
+ var library = modal.find('#gmedia-modal-library');
103
+ if (!library.hasClass('active')) {
104
+ var ifr = modal.find('iframe').clone();
105
+ ifr.attr('src', library.attr('href'));
106
+ library.trigger('click');
107
+ modal.find('iframe').replaceWith(ifr);
108
+ }
109
+ });
110
+
111
+ })(jQuery, window, document, undefined);
112
+
113
+ function gmedia_post_modal(el) {
114
+ var modal = jQuery('#__gm-uploader');
115
+
116
+ if (modal.length) {
117
+ modal.css('display', 'block');
118
+ }
119
+ else {
120
+ //var title = jQuery(el).attr('title');
121
+ modal = jQuery(jQuery('#tpl__gm-uploader').html());
122
+ modal.find('.media-modal-close, .media-modal-backdrop').on('click', function() {
123
+ modal.css('display', 'none');
124
+ });
125
+ modal.find('.media-menu-item').on('click', function() {
126
+ jQuery('iframe', modal).attr('src', jQuery(this).attr('href'));
127
+ jQuery(this).addClass('active').siblings('a').removeClass('active');
128
+ jQuery('.media-frame-title h1', modal).text(jQuery(this).text());
129
+ });
130
+ jQuery('body').append(modal);
131
+ }
132
+ }
133
+
134
+ // function gm_check_scode(id) {
135
+ // if (!id && ('undefined' != typeof (tinymce)) && tinymce.activeEditor) {
136
+ // id = tinymce.activeEditor.id;
137
+ // }
138
+ // if (!id) {
139
+ // id = 'content';
140
+ // }
141
+ // var temp_html = jQuery('textarea#' + id).val();
142
+ // if (temp_html) {
143
+ // var temp_m = temp_html.match(/\[gmedia [ ]*id=(\d+)[ ]*?]/g);
144
+ // if (temp_m) {
145
+ // jQuery.each(temp_m, function(i, shcode) {
146
+ // var id = shcode.replace(/\[gm.*id=(\d+).*?]/, '$1');
147
+ // jQuery('#gmGallery-' + id).addClass('gmedia-selected');
148
+ // });
149
+ // }
150
+ // }
151
+ // }
152
+ //
153
+ // function gm_send_to_editor(c) {
154
+ // var b, a = typeof (tinymce) != 'undefined', f = typeof (QTags) != 'undefined';
155
+ // if (!wpActiveEditor) {
156
+ // if (a && tinymce.activeEditor) {
157
+ // b = tinymce.activeEditor;
158
+ // wpActiveEditor = b.id;
159
+ // }
160
+ // else {
161
+ // if (gmActiveEditor) {
162
+ // wpActiveEditor = gmActiveEditor;
163
+ // }
164
+ // else {
165
+ // return false;
166
+ // }
167
+ // }
168
+ // }
169
+ // else {
170
+ // if (a) {
171
+ // if (tinymce.activeEditor && (tinymce.activeEditor.id == 'mce_fullscreen' || tinymce.activeEditor.id == 'wp_mce_fullscreen')) {
172
+ // b = tinymce.activeEditor;
173
+ // }
174
+ // else {
175
+ // b = tinymce.get(wpActiveEditor);
176
+ // }
177
+ // }
178
+ // }
179
+ // if (b && !b.isHidden()) {
180
+ // //noinspection JSUnresolvedVariable
181
+ // if (tinymce.isIE && b.windowManager.insertimagebookmark) {
182
+ // //noinspection JSUnresolvedVariable
183
+ // b.selection.moveToBookmark(b.windowManager.insertimagebookmark);
184
+ // }
185
+ // if (c.indexOf('[caption') === 0) {
186
+ // //noinspection JSUnresolvedVariable
187
+ // if (b.plugins.wpeditimage) {
188
+ // //noinspection JSUnresolvedVariable
189
+ // c = b.plugins.wpeditimage._do_shcode(c);
190
+ // }
191
+ // }
192
+ // else {
193
+ // c = '<p>' + c + '</p>';
194
+ // }
195
+ // b.execCommand('mceInsertContent', false, c);
196
+ // }
197
+ // else {
198
+ // if (f) {
199
+ // QTags.insertContent(c);
200
+ // }
201
+ // else {
202
+ // document.getElementById(wpActiveEditor).value += c;
203
+ // }
204
+ // }
205
+ // return true;
206
+ // }
207
+ //
208
+ // function gm_delete_scode(c) {
209
+ // var b, a = typeof (tinymce) != 'undefined', re, html;
210
+ // if (!wpActiveEditor) {
211
+ // if (a && tinymce.activeEditor) {
212
+ // b = tinymce.activeEditor;
213
+ // wpActiveEditor = b.id;
214
+ // }
215
+ // else {
216
+ // if (gmActiveEditor) {
217
+ // wpActiveEditor = gmActiveEditor;
218
+ // }
219
+ // else {
220
+ // return false;
221
+ // }
222
+ // }
223
+ // }
224
+ // else {
225
+ // if (a) {
226
+ // if (tinymce.activeEditor && (tinymce.activeEditor.id == 'mce_fullscreen' || tinymce.activeEditor.id == 'wp_mce_fullscreen')) {
227
+ // b = tinymce.activeEditor;
228
+ // }
229
+ // else {
230
+ // b = tinymce.get(wpActiveEditor);
231
+ // }
232
+ // }
233
+ // }
234
+ // if (b && !b.isHidden()) {
235
+ // html = b.getContent();
236
+ // re = new RegExp('(?:<p>)?\\[gmedia \\s*id=' + c + '\\s*?\\](?:<\\/p>)?', 'g');
237
+ // b.setContent(html.replace(re, ''));
238
+ // }
239
+ // else {
240
+ // html = document.getElementById(wpActiveEditor).value;
241
+ // re = new RegExp('\\[gmedia [ ]*id=' + c + '[ ]*?\\](?:\\n\\n|\\n)?', 'g');
242
+ // html = html.replace(re, '');
243
+ // document.getElementById(wpActiveEditor).value = html;
244
+ // }
245
+ // return true;
246
+ // }
247
+ //
248
+ // function gm_media_button(b) {
249
+ // var pos, el = jQuery(b).toggleClass('active');
250
+ // if (el.hasClass('active')) {
251
+ // pos = el.offset();
252
+ // pos.top += el.height() + 1;
253
+ // var w = 300;
254
+ // jQuery('#gmedia-wraper').appendTo('body').css({'position': 'absolute', 'z-index': 99999, 'width': w}).offset(pos);
255
+ // jQuery('#gmedia-wraper').draggable({handle: '.title-bar'});
256
+ // }
257
+ // else {
258
+ // jQuery('#gmedia-wraper').removeAttr('style').appendTo('#gmedia-MetaBox .inside');
259
+ // jQuery('#gmedia-wraper').draggable('destroy');
260
+ // }
261
+ // }
admin/class.processor.php CHANGED
@@ -1,280 +1,271 @@
1
- <?php
2
-
3
- /**
4
- * Class GmediaProcessor
5
- */
6
- class GmediaProcessor{
7
-
8
- private static $me = null;
9
- public $page;
10
- public $gmediablank;
11
- public $url;
12
- public $msg;
13
- public $error;
14
- public $user_options = array();
15
-
16
- public $display_mode;
17
- public $taxonomy;
18
- public $taxterm;
19
- public $edit_term;
20
-
21
- /**
22
- * initiate the manage page
23
- */
24
- public function __construct(){
25
- global $pagenow, $gmCore;
26
- // GET variables
27
- $this->page = $gmCore->_get('page');
28
- $this->url = add_query_arg(array('page' => $this->page), admin_url('admin.php'));
29
- if('media.php' === $pagenow){
30
- add_filter('wp_redirect', array($this, 'redirect'), 10, 2);
31
- }
32
- if('edit-comments.php' === $pagenow){
33
- add_filter('get_comment_text', array($this, 'gmedia_comment_text'), 10, 3);
34
- }
35
-
36
- add_action('init', array($this, 'controller'));
37
-
38
- if(!$this->page || strpos($this->page, 'GrandMedia') === false){
39
- return;
40
- }
41
-
42
- $this->gmediablank = $gmCore->_get('gmediablank');
43
- if($this->gmediablank){
44
- $this->url = add_query_arg(array('gmediablank' => $this->gmediablank), $this->url);
45
- }
46
-
47
- switch($this->page){
48
- case 'GrandMedia_Albums':
49
- $this->taxonomy = 'gmedia_album';
50
- break;
51
- case 'GrandMedia_Categories':
52
- $this->taxonomy = 'gmedia_category';
53
- break;
54
- case 'GrandMedia_Tags':
55
- $this->taxonomy = 'gmedia_tag';
56
- break;
57
- case 'GrandMedia_Galleries':
58
- $this->taxonomy = 'gmedia_gallery';
59
- break;
60
- }
61
- if($this->taxonomy){
62
- $this->taxterm = str_replace('gmedia_', '', $this->taxonomy);
63
- $this->edit_term = $gmCore->_get('edit_term');
64
- }
65
-
66
- }
67
-
68
- /**
69
- * load only on Gmedia admin pages
70
- */
71
- public function controller(){
72
-
73
- $this->user_options = self::user_options();
74
- $view = $this->gmediablank? '_frame' : '';
75
- $this->display_mode = $this->user_options["display_mode_gmedia{$view}"];
76
-
77
- if(!$this->page || strpos($this->page, 'GrandMedia') === false){
78
- return;
79
- }
80
-
81
- auth_redirect();
82
-
83
- $this->processor();
84
- }
85
-
86
-
87
- /**
88
- * Do diff process before lib shell
89
- */
90
- protected function processor(){ }
91
-
92
- /**
93
- * @return array|mixed
94
- */
95
- public static function user_options(){
96
- global $user_ID, $gmGallery;
97
-
98
- $screen_options = get_user_meta($user_ID, 'gm_screen_options', true);
99
- if(!is_array($screen_options)){
100
- $screen_options = array();
101
- }
102
-
103
- return array_merge($gmGallery->options['gm_screen_options'], $screen_options);
104
- }
105
-
106
- /**
107
- * @param string $key
108
- * @param string $post_key
109
- *
110
- * @return array
111
- */
112
- public static function selected_items($key, $post_key = 'selected_items'){
113
-
114
- $selected_items = array();
115
- if($key){
116
- if(isset($_POST[ $post_key ])){
117
- $selected_items = array_filter(explode(',', $_POST[ $post_key ]), 'is_numeric');
118
- } elseif(isset($_COOKIE[ $key ])){
119
- $selected_items = array_filter(explode('.', $_COOKIE[ $key ]), 'is_numeric');
120
- }
121
- }
122
-
123
- return $selected_items;
124
- }
125
-
126
- /**
127
- * @param string $cookie_key
128
- *
129
- * @return array
130
- */
131
- public function clear_selected_items($cookie_key){
132
- if($cookie_key){
133
- setcookie($cookie_key, '', time() - 3600);
134
- unset($_COOKIE[ $cookie_key ]);
135
- }
136
-
137
- return array();
138
- }
139
-
140
- /**
141
- * @param bool|string|array $author_id_list
142
- *
143
- * @return array|mixed
144
- */
145
- public static function filter_by_author($author_id_list = false){
146
- global $user_ID, $gmCore;
147
-
148
- if($author_id_list === false){
149
- $author = false;
150
- if(!$gmCore->caps['gmedia_show_others_media']){
151
- $author = array($user_ID, 0);
152
- }
153
- } else{
154
- $author = wp_parse_id_list($author_id_list);
155
- if(!$gmCore->caps['gmedia_show_others_media']){
156
- $author = array_intersect(array($user_ID, 0), $author);
157
- }
158
- }
159
-
160
- return $author;
161
- }
162
-
163
- /**
164
- * redirect to original referer after update
165
- *
166
- * @param $location
167
- * @param $status
168
- *
169
- * @return mixed
170
- */
171
- public function redirect($location, $status){
172
- global $pagenow;
173
- if('media.php' === $pagenow && isset($_POST['_wp_original_http_referer'])){
174
- if(strpos($_POST['_wp_original_http_referer'], 'GrandMedia') !== false){
175
- return $_POST['_wp_original_http_referer'];
176
- } else{
177
- return $location;
178
- }
179
- }
180
-
181
- return $location;
182
- }
183
-
184
- /**
185
- * Add thumb to gmedia comment text in admin
186
- *
187
- * @param $comment_content
188
- * @param $comment
189
- * @param $args
190
- *
191
- * @return string $comment_content
192
- */
193
- function gmedia_comment_text($comment_content, $comment, $args){
194
- global $post;
195
- if(!$post){
196
- return $comment_content;
197
- }
198
- //if('gmedia' == substr($post->post_type, 0, 6)) {
199
- if('gmedia' == $post->post_type){
200
- global $gmDB, $gmCore;
201
- $gmedia = $gmDB->get_post_gmedia($post->ID);
202
- $thumb = '<div class="alignright" style="clear:right;"><img class="gmedia-thumb" style="max-height:72px;" src="' . $gmCore->gm_get_media_image($gmedia, 'thumb', false) . '" alt=""/></div>';
203
- $comment_content = $thumb . $comment_content;
204
- }
205
-
206
- return $comment_content;
207
- }
208
-
209
- /**
210
- * Autoloader
211
- */
212
- public static function autoload(){
213
- $path_ = GMEDIA_ABSPATH . 'admin/processor/class.processor.';
214
- $page = isset($_GET['page'])? $_GET['page'] : '';
215
- switch($page){
216
- case 'GrandMedia':
217
- /** @var $gmProcessorLibrary */
218
- include_once($path_ . 'library.php');
219
-
220
- return $gmProcessorLibrary;
221
- break;
222
- case 'GrandMedia_AddMedia':
223
- /** @var $gmProcessorAddMedia */
224
- include_once($path_ . 'addmedia.php');
225
-
226
- return $gmProcessorAddMedia;
227
- break;
228
- case 'GrandMedia_Albums':
229
- case 'GrandMedia_Categories':
230
- /** @var $gmProcessorTerms */
231
- include_once($path_ . 'terms.php');
232
- /** @var $gmProcessorLibrary */
233
- include_once($path_ . 'library.php');
234
-
235
- return $gmProcessorTerms;
236
- break;
237
- case 'GrandMedia_Tags':
238
- /** @var $gmProcessorTerms */
239
- include_once($path_ . 'terms.php');
240
-
241
- return $gmProcessorTerms;
242
- break;
243
- case 'GrandMedia_Galleries':
244
- /** @var $gmProcessorGalleries */
245
- include_once($path_ . 'galleries.php');
246
-
247
- return $gmProcessorGalleries;
248
- break;
249
- case 'GrandMedia_Modules':
250
- /** @var $gmProcessorModules */
251
- include_once($path_ . 'modules.php');
252
-
253
- return $gmProcessorModules;
254
- break;
255
- case 'GrandMedia_Settings':
256
- /** @var $gmProcessorSettings */
257
- include_once($path_ . 'settings.php');
258
-
259
- return $gmProcessorSettings;
260
- break;
261
- case 'GrandMedia_WordpressLibrary':
262
- /** @var $gmProcessorWPMedia */
263
- include_once($path_ . 'wpmedia.php');
264
-
265
- return $gmProcessorWPMedia;
266
- break;
267
- default:
268
- if(self::$me == null){
269
- self::$me = new GmediaProcessor();
270
- }
271
-
272
- return self::$me;
273
- break;
274
- }
275
- }
276
-
277
- }
278
-
279
- global $gmProcessor;
280
- $gmProcessor = GmediaProcessor::autoload();
1
+ <?php
2
+
3
+ /**
4
+ * Class GmediaProcessor
5
+ */
6
+ class GmediaProcessor {
7
+
8
+ private static $me = null;
9
+ public $page;
10
+ public $gmediablank;
11
+ public $url;
12
+ public $msg;
13
+ public $error;
14
+ public $user_options = [];
15
+
16
+ public $display_mode;
17
+ public $taxonomy;
18
+ public $taxterm;
19
+ public $edit_term;
20
+
21
+ /**
22
+ * initiate the manage page
23
+ */
24
+ public function __construct() {
25
+ global $pagenow, $gmCore;
26
+ // GET variables.
27
+ $this->page = $gmCore->_get( 'page' );
28
+ $this->url = add_query_arg( [ 'page' => $this->page ], admin_url( 'admin.php' ) );
29
+ if ( 'media.php' === $pagenow ) {
30
+ add_filter( 'wp_redirect', [ $this, 'redirect' ], 10, 2 );
31
+ }
32
+ if ( 'edit-comments.php' === $pagenow ) {
33
+ add_filter( 'get_comment_text', [ $this, 'gmedia_comment_text' ], 10, 3 );
34
+ }
35
+
36
+ add_action( 'init', [ $this, 'controller' ] );
37
+
38
+ if ( ! $this->page || strpos( $this->page, 'GrandMedia' ) === false ) {
39
+ return;
40
+ }
41
+
42
+ $this->gmediablank = $gmCore->_get( 'gmediablank' );
43
+ if ( $this->gmediablank ) {
44
+ $this->url = add_query_arg( [ 'gmediablank' => $this->gmediablank ], $this->url );
45
+ }
46
+
47
+ switch ( $this->page ) {
48
+ case 'GrandMedia_Albums':
49
+ $this->taxonomy = 'gmedia_album';
50
+ break;
51
+ case 'GrandMedia_Categories':
52
+ $this->taxonomy = 'gmedia_category';
53
+ break;
54
+ case 'GrandMedia_Tags':
55
+ $this->taxonomy = 'gmedia_tag';
56
+ break;
57
+ case 'GrandMedia_Galleries':
58
+ $this->taxonomy = 'gmedia_gallery';
59
+ break;
60
+ }
61
+ if ( $this->taxonomy ) {
62
+ $this->taxterm = str_replace( 'gmedia_', '', $this->taxonomy );
63
+ $this->edit_term = $gmCore->_get( 'edit_term' );
64
+ }
65
+
66
+ }
67
+
68
+ /**
69
+ * @param string $key
70
+ * @param string $post_key
71
+ *
72
+ * @return array
73
+ */
74
+ public static function selected_items( $key, $post_key = 'selected_items' ) {
75
+
76
+ $selected_items = [];
77
+ if ( $key ) {
78
+ if ( isset( $_POST[ $post_key ] ) ) {
79
+ $selected_items = array_filter( explode( ',', $_POST[ $post_key ] ), 'is_numeric' );
80
+ } elseif ( isset( $_COOKIE[ $key ] ) ) {
81
+ $selected_items = array_filter( explode( '.', $_COOKIE[ $key ] ), 'is_numeric' );
82
+ }
83
+ }
84
+
85
+ return $selected_items;
86
+ }
87
+
88
+ /**
89
+ * @param bool|string|array $author_id_list
90
+ *
91
+ * @return array|mixed
92
+ */
93
+ public static function filter_by_author( $author_id_list = false ) {
94
+ global $user_ID, $gmCore;
95
+
96
+ if ( $author_id_list === false ) {
97
+ $author = false;
98
+ if ( ! $gmCore->caps['gmedia_show_others_media'] ) {
99
+ $author = [ $user_ID, 0 ];
100
+ }
101
+ } else {
102
+ $author = wp_parse_id_list( $author_id_list );
103
+ if ( ! $gmCore->caps['gmedia_show_others_media'] ) {
104
+ $author = array_intersect( [ $user_ID, 0 ], $author );
105
+ }
106
+ }
107
+
108
+ return $author;
109
+ }
110
+
111
+ /**
112
+ * Autoloader
113
+ */
114
+ public static function autoload() {
115
+ $path_ = GMEDIA_ABSPATH . 'admin/processor/class.processor.';
116
+ $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
117
+ switch ( $page ) {
118
+ case 'GrandMedia':
119
+ /** @var $gmProcessorLibrary */
120
+ include_once $path_ . 'library.php';
121
+
122
+ return $gmProcessorLibrary;
123
+ case 'GrandMedia_AddMedia':
124
+ /** @var $gmProcessorAddMedia */
125
+ include_once $path_ . 'addmedia.php';
126
+
127
+ return $gmProcessorAddMedia;
128
+ case 'GrandMedia_Albums':
129
+ case 'GrandMedia_Categories':
130
+ /** @var $gmProcessorTerms */
131
+ include_once $path_ . 'terms.php';
132
+ /** @var $gmProcessorLibrary */
133
+ include_once $path_ . 'library.php';
134
+
135
+ return $gmProcessorTerms;
136
+ case 'GrandMedia_Tags':
137
+ /** @var $gmProcessorTerms */
138
+ include_once $path_ . 'terms.php';
139
+
140
+ return $gmProcessorTerms;
141
+ case 'GrandMedia_Galleries':
142
+ /** @var $gmProcessorGalleries */
143
+ include_once $path_ . 'galleries.php';
144
+
145
+ return $gmProcessorGalleries;
146
+ case 'GrandMedia_Modules':
147
+ /** @var $gmProcessorModules */
148
+ include_once $path_ . 'modules.php';
149
+
150
+ return $gmProcessorModules;
151
+ case 'GrandMedia_Settings':
152
+ /** @var $gmProcessorSettings */
153
+ include_once $path_ . 'settings.php';
154
+
155
+ return $gmProcessorSettings;
156
+ case 'GrandMedia_WordpressLibrary':
157
+ /** @var $gmProcessorWPMedia */
158
+ include_once $path_ . 'wpmedia.php';
159
+
160
+ return $gmProcessorWPMedia;
161
+ default:
162
+ if ( self::$me === null ) {
163
+ self::$me = new GmediaProcessor();
164
+ }
165
+
166
+ return self::$me;
167
+ }
168
+ }
169
+
170
+ /**
171
+ * Load only on Gmedia admin pages
172
+ */
173
+ public function controller() {
174
+
175
+ $this->user_options = self::user_options();
176
+ $view = $this->gmediablank ? '_frame' : '';
177
+ $this->display_mode = $this->user_options["display_mode_gmedia{$view}"];
178
+
179
+ if ( ! $this->page || strpos( $this->page, 'GrandMedia' ) === false ) {
180
+ return;
181
+ }
182
+
183
+ auth_redirect();
184
+
185
+ $this->processor();
186
+ }
187
+
188
+ /**
189
+ * @return array|mixed
190
+ */
191
+ public static function user_options() {
192
+ global $user_ID, $gmGallery;
193
+
194
+ $screen_options = get_user_meta( $user_ID, 'gm_screen_options', true );
195
+ if ( ! is_array( $screen_options ) ) {
196
+ $screen_options = [];
197
+ }
198
+
199
+ return array_merge( $gmGallery->options['gm_screen_options'], $screen_options );
200
+ }
201
+
202
+ /**
203
+ * Do diff process before lib shell
204
+ */
205
+ protected function processor() {
206
+ }
207
+
208
+ /**
209
+ * @param string $cookie_key
210
+ *
211
+ * @return array
212
+ */
213
+ public function clear_selected_items( $cookie_key ) {
214
+ if ( $cookie_key ) {
215
+ setcookie( $cookie_key, '', time() - 3600 );
216
+ unset( $_COOKIE[ $cookie_key ] );
217
+ }
218
+
219
+ return [];
220
+ }
221
+
222
+ /**
223
+ * redirect to original referer after update
224
+ *
225
+ * @param $location
226
+ * @param $status
227
+ *
228
+ * @return mixed
229
+ */
230
+ public function redirect( $location, $status ) {
231
+ global $pagenow;
232
+ if ( 'media.php' === $pagenow && isset( $_POST['_wp_original_http_referer'] ) ) {
233
+ if ( strpos( $_POST['_wp_original_http_referer'], 'GrandMedia' ) !== false ) {
234
+ return $_POST['_wp_original_http_referer'];
235
+ } else {
236
+ return $location;
237
+ }
238
+ }
239
+
240
+ return $location;
241
+ }
242
+
243
+ /**
244
+ * Add thumb to gmedia comment text in admin
245
+ *
246
+ * @param $comment_content
247
+ * @param $comment
248
+ * @param $args
249
+ *
250
+ * @return string $comment_content
251
+ */
252
+ function gmedia_comment_text( $comment_content, $comment, $args ) {
253
+ global $post;
254
+ if ( ! $post ) {
255
+ return $comment_content;
256
+ }
257
+ //if('gmedia' === substr($post->post_type, 0, 6)) {
258
+ if ( 'gmedia' === $post->post_type ) {
259
+ global $gmDB, $gmCore;
260
+ $gmedia = $gmDB->get_post_gmedia( $post->ID );
261
+ $thumb = '<div class="alignright" style="clear:right;"><img class="gmedia-thumb" style="max-height:72px;" src="' . $gmCore->gm_get_media_image( $gmedia, 'thumb', false ) . '" alt=""/></div>';
262
+ $comment_content = $thumb . $comment_content;
263
+ }
264
+
265
+ return $comment_content;
266
+ }
267
+
268
+ }
269
+
270
+ global $gmProcessor;
271
+ $gmProcessor = GmediaProcessor::autoload();
 
 
 
 
 
 
 
 
 
admin/functions.php CHANGED
@@ -1,40 +1,41 @@
1
  <?php
2
 
3
- function gm_get_admin_url($add_args = array(), $remove_args = array(), $uri = false, $preserve_args = array()){
4
- global $gmCore;
5
 
6
- return $gmCore->get_admin_url($add_args, $remove_args, $uri, $preserve_args);
7
  }
8
 
9
- function gm_panel_classes($classes){
10
- echo implode(' ', (array)$classes);
11
  }
12
 
13
- function gmedia_term_choose_author_field($selected = false, $_args = array()){
14
- global $gmCore;
15
 
16
- $user_ID = get_current_user_id();
17
- if(false === $selected){
18
- $selected = $user_ID;
19
- }
20
 
21
- $user_ids = gm_user_can('delete_others_media')? $gmCore->get_editable_user_ids() : array($user_ID);
22
- if($user_ids && gm_user_can('edit_others_media')){
23
- if(!in_array($user_ID, $user_ids)){
24
- array_push($user_ids, $user_ID);
25
- }
26
- $args = array('include' => $user_ids,
27
- 'include_selected' => true,
28
- 'name' => 'term[global]',
29
- 'selected' => $selected,
30
- 'class' => 'form-control input-sm',
31
- 'multi' => true,
32
- 'show_option_all' => __('Shared', 'grand-media')
33
- );
34
- $args = array_merge($args, $_args);
35
- wp_dropdown_users($args);
36
- } else{
37
- echo '<input type="hidden" name="term[global]" value="' . $user_ID . '"/>';
38
- echo '<div>' . get_the_author_meta('display_name', $user_ID) . '</div>';
39
- }
 
40
  }
1
  <?php
2
 
3
+ function gm_get_admin_url( $add_args = [], $remove_args = [], $uri = false, $preserve_args = [] ) {
4
+ global $gmCore;
5
 
6
+ return $gmCore->get_admin_url( $add_args, $remove_args, $uri, $preserve_args );
7
  }
8
 
9
+ function gm_panel_classes( $classes ) {
10
+ echo implode( ' ', (array) $classes );
11
  }
12
 
13
+ function gmedia_term_choose_author_field( $selected = false, $_args = [] ) {
14
+ global $gmCore;
15
 
16
+ $user_ID = get_current_user_id();
17
+ if ( false === $selected ) {
18
+ $selected = $user_ID;
19
+ }
20
 
21
+ $user_ids = gm_user_can( 'delete_others_media' ) ? $gmCore->get_editable_user_ids() : [ $user_ID ];
22
+ if ( $user_ids && gm_user_can( 'edit_others_media' ) ) {
23
+ if ( ! in_array( $user_ID, $user_ids, true ) ) {
24
+ array_push( $user_ids, $user_ID );
25
+ }
26
+ $args = [
27
+ 'include' => $user_ids,
28
+ 'include_selected' => true,
29
+ 'name' => 'term[global]',
30
+ 'selected' => $selected,
31
+ 'class' => 'form-control input-sm',
32
+ 'multi' => true,
33
+ 'show_option_all' => __( 'Shared', 'grand-media' ),
34
+ ];
35
+ $args = array_merge( $args, $_args );
36
+ wp_dropdown_users( $args );
37
+ } else {
38
+ echo '<input type="hidden" name="term[global]" value="' . $user_ID . '"/>';
39
+ echo '<div>' . get_the_author_meta( 'display_name', $user_ID ) . '</div>';
40
+ }
41
  }
admin/logs.php CHANGED
@@ -1,295 +1,297 @@
1
- <?php
2
- /**
3
- * Gmedia Logs
4
- */
5
-
6
- // don't load directly
7
- if( !defined('ABSPATH')){
8
- die('-1');
9
- }
10
-
11
- global $user_ID, $wpdb, $gmDB, $gmCore, $gmGallery, $gmProcessor;
12
-
13
- $gmedia_url = $gmProcessor->url;
14
- $gmedia_user_options = $gmProcessor->user_options;
15
-
16
- if(isset($_GET['do_gmedia']) && 'clear_logs' == $_GET['do_gmedia']){
17
- check_admin_referer('gmedia_clear_logs', '_wpnonce_clear_logs');
18
- $wpdb->query("DELETE FROM {$wpdb->prefix}gmedia_log WHERE 1 = 1");
19
- }
20
-
21
-
22
- $gmedia_filter = array();
23
-
24
- $openPage = !empty($_GET['pager'])? (int) $_GET['pager'] : 1;
25
-
26
- $where = '';
27
- $search = '';
28
- $orderby = 'ORDER BY l.' . esc_sql($gmedia_user_options['orderby_gmedia_log']) . ' ' . esc_sql($gmedia_user_options['sortorder_gmedia_log']);
29
- $lim = '';
30
-
31
- if(isset($_POST['filter_author'])){
32
- $authors = $gmCore->_post('author_ids');
33
- $_GET['author'] = (int) $authors;
34
- }
35
- if(isset($_GET['author'])){
36
- $author = (int) $_GET['author'];
37
- $where .= "AND l.log_author = '{$author}' ";
38
- $gmedia_filter['author'] = $author;
39
- }
40
- if(isset($_GET['log_event'])){
41
- $where .= $wpdb->prepare("AND l.log = '%s' ", $_GET['log_event']);
42
- $gmedia_filter['log_event'] = $_GET['log_event'];
43
- }
44
- if(isset($_GET['s'])){
45
- $s = trim($_GET['s']);
46
- if('#' == substr($s, 0, 1)){
47
- $ids = wp_parse_id_list(substr($s, 1));
48
- $where .= ' AND l.ID IN (\'' . implode("','", $ids) . '\')';
49
- $s = false;
50
- $gmedia_filter['search'] = $s;
51
- }
52
- if( !empty($s)){
53
- // added slashes screw with quote grouping when done early, so done later
54
- $s = stripslashes($s);
55
-
56
- // split the words it a array if seperated by a space or comma
57
- preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
58
- $search_terms = array_map(function($a){ return trim($a, "\"'\n\r "); }, $matches[0]);
59
-
60
- $n = '%';
61
- $searchand = '';
62
-
63
- foreach((array) $search_terms as $term){
64
- $term = addslashes_gpc($term);
65
- $search .= "{$searchand}(g.title LIKE '{$n}{$term}{$n}') OR (g.description LIKE '{$n}{$term}{$n}')";
66
- $searchand = ' AND ';
67
- }
68
-
69
- $term = esc_sql($s);
70
- if(count($search_terms) > 1 && $search_terms[0] != $s){
71
- $search .= " OR (g.title LIKE '{$n}{$term}{$n}') OR (g.description LIKE '{$n}{$term}{$n}')";
72
- }
73
-
74
- if( !empty($search)){
75
- $search = " AND ({$search}) ";
76
- }
77
- $gmedia_filter['search'] = $s;
78
- }
79
- }
80
-
81
- $limit = intval($gmedia_user_options['per_page_gmedia_log']);
82
- if($limit > 0){
83
- $offset = ($openPage - 1) * $limit;
84
- $lim = " LIMIT {$offset}, {$limit}";
85
- }
86
-
87
- $query = "SELECT SQL_CALC_FOUND_ROWS * FROM {$wpdb->prefix}gmedia_log AS l INNER JOIN {$wpdb->prefix}gmedia AS g ON g.ID = l.ID WHERE 1=1 $where $search $orderby $lim";
88
- //echo '<pre>' . print_r($query, true) . '</pre>';
89
- $logs = $wpdb->get_results($query);
90
- $totalResult = (int) $wpdb->get_var("SELECT FOUND_ROWS()");
91
-
92
- if((1 > $limit) || (0 == $totalResult)){
93
- $limit = $totalResult;
94
- $pages = 1;
95
- } else{
96
- $pages = ceil($totalResult / $limit);
97
- }
98
-
99
- $gmDB->pages = $pages;
100
- $gmDB->openPage = $openPage;
101
- $gmedia_pager = $gmDB->query_pager();
102
-
103
- ?>
104
- <div class="panel panel-default panel-fixed-header" id="gmedia-panel">
105
- <div class="panel-heading-fake"></div>
106
- <div class="panel-heading clearfix" style="padding-bottom:2px;">
107
- <div class="pull-right" style="margin-bottom:3px;">
108
- <div class="clearfix">
109
- <?php include(GMEDIA_ABSPATH . 'admin/tpl/search-form.php'); ?>
110
-
111
- <div class="btn-toolbar pull-right" style="margin-bottom:4px; margin-left:4px;">
112
- <?php if( !$gmProcessor->gmediablank){ ?>
113
- <a title="<?php _e('More Screen Settings', 'grand-media'); ?>" class="show-settings-link pull-right btn btn-default btn-xs"><span class="glyphicon glyphicon-cog"></span></a>
114
- <?php } ?>
115
- </div>
116
- </div>
117
-
118
- <?php echo $gmedia_pager; ?>
119
-
120
- <div class="spinner"></div>
121
-
122
- </div>
123
- <div class="btn-toolbar pull-left" style="margin-bottom:7px;">
124
- <div class="btn-group">
125
- <?php if( !empty($gmedia_filter)){ ?>
126
- <a class="btn btn-warning" title="<?php _e('Reset Filter', 'grand-media'); ?>" rel="total" href="<?php echo gm_get_admin_url(array(), array(), $gmedia_url); ?>"><?php _e('Reset Filter', 'grand-media'); ?></a>
127
- <?php } else{ ?>
128
- <button type="button" class="btn btn-default" data-toggle="dropdown"><?php _e('Filter', 'grand-media'); ?></button>
129
- <?php } ?>
130
- <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
131
- <span class="caret"></span>
132
- <span class="sr-only"><?php _e('Toggle Dropdown', 'grand-media'); ?></span>
133
- </button>
134
- <ul class="dropdown-menu" role="menu">
135
- <li role="presentation" class="dropdown-header"><?php _e('FILTER BY AUTHOR', 'grand-media'); ?></li>
136
- <li class="gmedia_author<?php echo isset($gmedia_filter['author'])? ' active' : ''; ?>">
137
- <a href="#libModal" data-modal="filter_author" data-action="gmedia_get_modal" class="gmedia-modal"><?php _e('Choose authors', 'grand-media'); ?></a>
138
- </li>
139
- <li role="presentation" class="dropdown-header"><?php _e('FILTER BY EVENT', 'grand-media'); ?></li>
140
- <li class="gmedia_event<?php echo (isset($gmedia_filter['log_event']) && 'view' == $gmedia_filter['log_event'])? ' active' : ''; ?>">
141
- <a href="<?php echo add_query_arg(array('log_event' => 'view'), $gmedia_url) ?>"><?php _e('View / Play', 'grand-media'); ?></a>
142
- </li>
143
- <li class="gmedia_event<?php echo (isset($gmedia_filter['log_event']) && 'like' == $gmedia_filter['log_event'])? ' active' : ''; ?>">
144
- <a href="<?php echo add_query_arg(array('log_event' => 'like'), $gmedia_url) ?>"><?php _e('Like', 'grand-media'); ?></a>
145
- </li>
146
- <li class="gmedia_event<?php echo (isset($gmedia_filter['log_event']) && 'rate' == $gmedia_filter['log_event'])? ' active' : ''; ?>">
147
- <a href="<?php echo add_query_arg(array('log_event' => 'rate'), $gmedia_url) ?>"><?php _e('Rate', 'grand-media'); ?></a>
148
- </li>
149
- </ul>
150
- </div>
151
- <a class="btn btn-danger pull-left" href="<?php echo wp_nonce_url(gm_get_admin_url(array('do_gmedia' => 'clear_logs'), array(), $gmedia_url), 'gmedia_clear_logs', '_wpnonce_clear_logs') ?>" data-confirm="<?php _e("You are about to clear all Gmedia logs.\n\r'Cancel' to stop, 'OK' to clear.", "grand-media"); ?>"><?php _e('Clear Logs', 'grand-media'); ?></a>
152
-
153
- </div>
154
-
155
- </div>
156
- <form class="panel-body" id="gm-log-table" style="margin-bottom:4px;">
157
- <?php
158
- if(empty($gmGallery->options['license_key'])){
159
- ?>
160
- <div class="alert alert-warning" role="alert"><strong><?php _e('It\'s a premium feature. Gmedia Logger requires License Key.') ?></strong></div>
161
- <?php
162
- } elseif(!empty($gmGallery->options['disable_logs'])){
163
- ?>
164
- <div class="alert alert-warning" role="alert"><strong><?php _e('Gmedia Logger is disabled in settings.') ?></strong></div>
165
- <?php
166
- }
167
- ?>
168
- <div class="table-responsive">
169
- <table class="table table-condensed table-hover">
170
- <thead>
171
- <tr>
172
- <th><?php _e('Media', 'grand-media'); ?></th>
173
- <th><?php _e('Info', 'grand-media'); ?></th>
174
- <th><?php _e('Log Date', 'grand-media'); ?></th>
175
- <th><?php _e('User / IP', 'grand-media'); ?></th>
176
- <th><?php _e('Event', 'grand-media'); ?></th>
177
- </tr>
178
- </thead>
179
- <tbody>
180
- <?php
181
- if($logs){
182
- foreach($logs as $item){
183
- gmedia_item_more_data($item);
184
- ?>
185
- <tr>
186
- <td style="width:150px;">
187
- <div class="thumbnail" style="margin-bottom: 0;">
188
- <?php
189
- $images = $gmCore->gm_get_media_image($item, 'all');
190
- $thumb = '<img class="gmedia-thumb" src="' . $images['thumb'] . '" alt=""/>';
191
-
192
- if( !empty($images['icon'])){
193
- $thumb .= '<img class="gmedia-typethumb" src="' . $images['icon'] . '" alt=""/>';
194
- }
195
- echo $thumb;
196
- ?>
197
- </div>
198
- </td>
199
- <td>
200
- <p class="media-meta"><span class="label label-default"><?php echo "#{$item->ID}"; ?>:</span> <b><?php echo esc_html($item->title); ?>&nbsp;</b></p>
201
- <p class="media-meta">
202
- <span class="label label-default"><?php _e('Album', 'grand-media'); ?>:</span>
203
- <?php
204
- if($item->album){
205
- $terms_album = array();
206
- foreach($item->album as $c){
207
- $terms_album[] = esc_html($c->name);
208
- }
209
- $terms_album = join(', ', $terms_album);
210
- } else{
211
- $terms_album = '&#8212;';
212
- }
213
- echo $terms_album;
214
- ?>
215
- <br/><span class="label label-default"><?php _e('Category', 'grand-media'); ?>:</span>
216
- <?php
217
- if($item->categories){
218
- $terms_category = array();
219
- foreach($item->categories as $c){
220
- $terms_category[] = esc_html($c->name);
221
- }
222
- $terms_category = join(', ', $terms_category);
223
- } else{
224
- $terms_category = __('Uncategorized', 'grand-media');
225
- }
226
- echo $terms_category;
227
- ?>
228
- <br/><span class="label label-default"><?php _e('Tags', 'grand-media'); ?>:</span>
229
- <?php
230
- if($item->tags){
231
- $terms_tag = array();
232
- foreach($item->tags as $c){
233
- $terms_tag[] = esc_html($c->name);
234
- }
235
- $terms_tag = join(', ', $terms_tag);
236
- } else{
237
- $terms_tag = '&#8212;';
238
- }
239
- echo $terms_tag;
240
- ?>
241
- </p>
242
- <p class="media-meta">
243
- <span class="label label-default"><?php _e('Views / Likes', 'grand-media'); ?>:</span>
244
- <?php echo (isset($item->meta['views'][0])? $item->meta['views'][0] : '0') . ' / ' . (isset($item->meta['likes'][0])? $item->meta['likes'][0] : '0'); ?>
245
-
246
- <?php if(isset($item->meta['_rating'][0])){
247
- $ratings = maybe_unserialize($item->meta['_rating'][0]); ?>
248
- <br/><span class="label label-default"><?php _e('Rating', 'grand-media'); ?>:</span> <?php echo $ratings['value'] . ' / ' . $ratings['votes']; ?>
249
- <?php } ?>
250
- <br/><span class="label label-default"><?php _e('Type', 'grand-media'); ?>:</span> <?php echo $item->mime_type; ?>
251
- <br/><span class="label label-default"><?php _e('Filename', 'grand-media'); ?>:</span> <a href="<?php echo gm_get_admin_url(array('page' => 'GrandMedia', 'gmedia__in' => $item->ID), array(), $gmedia_url); ?>"><?php echo $item->gmuid; ?></a>
252
- </p>
253
- </td>
254
- <td><p><?php echo $item->log_date; ?></p></td>
255
- <td>
256
- <p><?php
257
- $author_name = $item->log_author? get_user_option('display_name', $item->log_author) : __('Guest', 'grand-media');
258
- printf('<a class="gmedia-author" href="%s">%s</a>', esc_url(add_query_arg(array('author' => $item->log_author), $gmedia_url)), $author_name);
259
- ?></p>
260
- <p class="media-meta"><span class="label label-default"><?php _e('IP Address', 'grand-media'); ?>:</span> <?php echo $item->ip_address; ?></p>
261
- </td>
262
- <td><p><?php
263
- switch($item->log){
264
- case 'view':
265
- _e('View / Play', 'grand-media');
266
- break;
267
- case 'like':
268
- _e('Like', 'grand-media');
269
- break;
270
- case 'rate':
271
- echo __('Rate', 'grand-media') . ": {$item->log_data}";
272
- break;
273
- }
274
- ?></p></td>
275
- </tr>
276
- <?php
277
- }
278
- } else {
279
- echo '<tr><td colspan="5" style="font-weight: bold; text-align: center; padding: 30px 0;">' . __('No Records.', 'grand-media') . '</td></tr>';
280
- }
281
- ?>
282
- </tbody>
283
-
284
- </table>
285
- </div>
286
- <?php
287
- wp_original_referer_field(true, 'previous');
288
- wp_nonce_field('GmediaGallery');
289
- ?>
290
- </form>
291
- </div>
292
-
293
- <div class="modal fade gmedia-modal" id="libModal" tabindex="-1" role="dialog" aria-hidden="true">
294
- <div class="modal-dialog"></div>
295
- </div>
 
 
1
+ <?php
2
+ /**
3
+ * Gmedia Logs
4
+ */
5
+
6
+ // don't load directly.
7
+ if ( ! defined( 'ABSPATH' ) ) {
8
+ die( '-1' );
9
+ }
10
+
11
+ global $user_ID, $wpdb, $gmDB, $gmCore, $gmGallery, $gmProcessor;
12
+
13
+ $gmedia_url = $gmProcessor->url;
14
+ $gmedia_user_options = $gmProcessor->user_options;
15
+
16
+ if ( isset( $_GET['do_gmedia'] ) && 'clear_logs' === $_GET['do_gmedia'] ) {
17
+ check_admin_referer( 'gmedia_clear_logs', '_wpnonce_clear_logs' );
18
+ $wpdb->query( "DELETE FROM {$wpdb->prefix}gmedia_log WHERE 1 = 1" );
19
+ }
20
+
21
+
22
+ $gmedia_filter = [];
23
+
24
+ $openPage = ! empty( $_GET['pager'] ) ? (int) $_GET['pager'] : 1;
25
+
26
+ $where = '';
27
+ $search = '';
28
+ $orderby = 'ORDER BY l.' . esc_sql( $gmedia_user_options['orderby_gmedia_log'] ) . ' ' . esc_sql( $gmedia_user_options['sortorder_gmedia_log'] );
29
+ $lim = '';
30
+
31
+ if ( isset( $_POST['filter_author'] ) ) {
32
+ $authors = $gmCore->_post( 'author_ids' );
33
+ $_GET['author'] = (int) $authors;
34
+ }
35
+ if ( isset( $_GET['author'] ) ) {
36
+ $author = (int) $_GET['author'];
37
+ $where .= "AND l.log_author = '{$author}' ";
38
+ $gmedia_filter['author'] = $author;
39
+ }
40
+ if ( isset( $_GET['log_event'] ) ) {
41
+ $where .= $wpdb->prepare( "AND l.log = '%s' ", $_GET['log_event'] );
42
+ $gmedia_filter['log_event'] = $_GET['log_event'];
43
+ }
44
+ if ( isset( $_GET['s'] ) ) {
45
+ $s = trim( $_GET['s'] );
46
+ if ( '#' === substr( $s, 0, 1 ) ) {
47
+ $ids = wp_parse_id_list( substr( $s, 1 ) );
48
+ $where .= ' AND l.ID IN (\'' . implode( "','", $ids ) . '\')';
49
+ $s = false;
50
+ $gmedia_filter['search'] = $s;
51
+ }
52
+ if ( ! empty( $s ) ) {
53
+ // added slashes screw with quote grouping when done early, so done later
54
+ $s = stripslashes( $s );
55
+
56
+ // split the words it a array if seperated by a space or comma
57
+ preg_match_all( '/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches );
58
+ $search_terms = array_map( function ( $a ) {
59
+ return trim( $a, "\"'\n\r " );
60
+ }, $matches[0] );
61
+
62
+ $n = '%';
63
+ $searchand = '';
64
+
65
+ foreach ( (array) $search_terms as $term ) {
66
+ $term = addslashes_gpc( $term );
67
+ $search .= "{$searchand}(g.title LIKE '{$n}{$term}{$n}') OR (g.description LIKE '{$n}{$term}{$n}')";
68
+ $searchand = ' AND ';
69
+ }
70
+
71
+ $term = esc_sql( $s );
72
+ if ( count( $search_terms ) > 1 && $search_terms[0] !== $s ) {
73
+ $search .= " OR (g.title LIKE '{$n}{$term}{$n}') OR (g.description LIKE '{$n}{$term}{$n}')";
74
+ }
75
+
76
+ if ( ! empty( $search ) ) {
77
+ $search = " AND ({$search}) ";
78
+ }
79
+ $gmedia_filter['search'] = $s;
80
+ }
81
+ }
82
+
83
+ $limit = intval( $gmedia_user_options['per_page_gmedia_log'] );
84
+ if ( $limit > 0 ) {
85
+ $offset = ( $openPage - 1 ) * $limit;
86
+ $lim = " LIMIT {$offset}, {$limit}";
87
+ }
88
+
89
+ $query = "SELECT SQL_CALC_FOUND_ROWS * FROM {$wpdb->prefix}gmedia_log AS l INNER JOIN {$wpdb->prefix}gmedia AS g ON g.ID = l.ID WHERE 1=1 $where $search $orderby $lim";
90
+ //echo '<pre>' . print_r($query, true) . '</pre>';
91
+ $logs = $wpdb->get_results( $query );
92
+ $totalResult = (int) $wpdb->get_var( "SELECT FOUND_ROWS()" );
93
+
94
+ if ( ( 1 > $limit ) || ( 0 === $totalResult ) ) {
95
+ $limit = $totalResult;
96
+ $pages = 1;
97
+ } else {
98
+ $pages = ceil( $totalResult / $limit );
99
+ }
100
+
101
+ $gmDB->pages = $pages;
102
+ $gmDB->openPage = $openPage;
103
+ $gmedia_pager = $gmDB->query_pager();
104
+
105
+ ?>
106
+ <div class="panel panel-default panel-fixed-header" id="gmedia-panel">
107
+ <div class="panel-heading-fake"></div>
108
+ <div class="panel-heading clearfix" style="padding-bottom:2px;">
109
+ <div class="pull-right" style="margin-bottom:3px;">
110
+ <div class="clearfix">
111
+ <?php include GMEDIA_ABSPATH . 'admin/tpl/search-form.php'; ?>
112
+
113
+ <div class="btn-toolbar pull-right" style="margin-bottom:4px; margin-left:4px;">
114
+ <?php if ( ! $gmProcessor->gmediablank ) { ?>
115
+ <a title="<?php _e( 'More Screen Settings', 'grand-media' ); ?>" class="show-settings-link pull-right btn btn-default btn-xs"><span class="glyphicon glyphicon-cog"></span></a>
116
+ <?php } ?>
117
+ </div>
118
+ </div>
119
+
120
+ <?php echo $gmedia_pager; ?>
121
+
122
+ <div class="spinner"></div>
123
+
124
+ </div>
125
+ <div class="btn-toolbar pull-left" style="margin-bottom:7px;">
126
+ <div class="btn-group">
127
+ <?php if ( ! empty( $gmedia_filter ) ) { ?>
128
+ <a class="btn btn-warning" title="<?php _e( 'Reset Filter', 'grand-media' ); ?>" rel="total" href="<?php echo esc_url( gm_get_admin_url( [], [], $gmedia_url ) ); ?>"><?php _e( 'Reset Filter', 'grand-media' ); ?></a>
129
+ <?php } else { ?>
130
+ <button type="button" class="btn btn-default" data-toggle="dropdown"><?php _e( 'Filter', 'grand-media' ); ?></button>
131
+ <?php } ?>
132
+ <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
133
+ <span class="caret"></span>
134
+ <span class="sr-only"><?php _e( 'Toggle Dropdown', 'grand-media' ); ?></span>
135
+ </button>
136
+ <ul class="dropdown-menu" role="menu">
137
+ <li role="presentation" class="dropdown-header"><?php _e( 'FILTER BY AUTHOR', 'grand-media' ); ?></li>
138
+ <li class="gmedia_author<?php echo esc_attr( isset( $gmedia_filter['author'] ) ? ' active' : '' ); ?>">
139
+ <a href="#libModal" data-modal="filter_author" data-action="gmedia_get_modal" class="gmedia-modal"><?php _e( 'Choose authors', 'grand-media' ); ?></a>
140
+ </li>
141
+ <li role="presentation" class="dropdown-header"><?php _e( 'FILTER BY EVENT', 'grand-media' ); ?></li>
142
+ <li class="gmedia_event<?php echo esc_attr( ( isset( $gmedia_filter['log_event'] ) && 'view' === $gmedia_filter['log_event'] ) ? ' active' : '' ); ?>">
143
+ <a href="<?php echo esc_url( add_query_arg( [ 'log_event' => 'view' ], $gmedia_url ) ); ?>"><?php _e( 'View / Play', 'grand-media' ); ?></a>
144
+ </li>
145
+ <li class="gmedia_event<?php echo esc_attr( ( isset( $gmedia_filter['log_event'] ) && 'like' === $gmedia_filter['log_event'] ) ? ' active' : '' ); ?>">
146
+ <a href="<?php echo esc_url( add_query_arg( [ 'log_event' => 'like' ], $gmedia_url ) ); ?>"><?php _e( 'Like', 'grand-media' ); ?></a>
147
+ </li>
148
+ <li class="gmedia_event<?php echo esc_attr( ( isset( $gmedia_filter['log_event'] ) && 'rate' === $gmedia_filter['log_event'] ) ? ' active' : '' ); ?>">
149
+ <a href="<?php echo esc_url( add_query_arg( [ 'log_event' => 'rate' ], $gmedia_url ) ); ?>"><?php _e( 'Rate', 'grand-media' ); ?></a>
150
+ </li>
151
+ </ul>
152
+ </div>
153
+ <a class="btn btn-danger pull-left" href="<?php echo esc_url( wp_nonce_url( gm_get_admin_url( [ 'do_gmedia' => 'clear_logs' ], [], $gmedia_url ), 'gmedia_clear_logs', '_wpnonce_clear_logs' ) ); ?>" data-confirm="<?php _e( "You are about to clear all Gmedia logs.\n\r'Cancel' to stop, 'OK' to clear.", "grand-media" ); ?>"><?php _e( 'Clear Logs', 'grand-media' ); ?></a>
154
+
155
+ </div>
156
+
157
+ </div>
158
+ <form class="panel-body" id="gm-log-table" style="margin-bottom:4px;">
159
+ <?php
160
+ if ( empty( $gmGallery->options['license_key'] ) ) {
161
+ ?>
162
+ <div class="alert alert-warning" role="alert"><strong><?php _e( 'It\'s a premium feature. Gmedia Logger requires License Key.' ) ?></strong></div>
163
+ <?php
164
+ } elseif ( ! empty( $gmGallery->options['disable_logs'] ) ) {
165
+ ?>
166
+ <div class="alert alert-warning" role="alert"><strong><?php _e( 'Gmedia Logger is disabled in settings.' ) ?></strong></div>
167
+ <?php
168
+ }
169
+ ?>
170
+ <div class="table-responsive">
171
+ <table class="table table-condensed table-hover">
172
+ <thead>
173
+ <tr>
174
+ <th><?php _e( 'Media', 'grand-media' ); ?></th>
175
+ <th><?php _e( 'Info', 'grand-media' ); ?></th>
176
+ <th><?php _e( 'Log Date', 'grand-media' ); ?></th>
177
+ <th><?php _e( 'User / IP', 'grand-media' ); ?></th>
178
+ <th><?php _e( 'Event', 'grand-media' ); ?></th>
179
+ </tr>
180
+ </thead>
181
+ <tbody>
182
+ <?php
183
+ if ( $logs ) {
184
+ foreach ( $logs as $item ) {
185
+ gmedia_item_more_data( $item );
186
+ ?>
187
+ <tr>
188
+ <td style="width:150px;">
189
+ <div class="thumbnail" style="margin-bottom: 0;">
190
+ <?php
191
+ $images = $gmCore->gm_get_media_image( $item, 'all' );
192
+ $thumb = '<img class="gmedia-thumb" src="' . $images['thumb'] . '" alt=""/>';
193
+
194
+ if ( ! empty( $images['icon'] ) ) {
195
+ $thumb .= '<img class="gmedia-typethumb" src="' . $images['icon'] . '" alt=""/>';
196
+ }
197
+ echo $thumb;
198
+ ?>
199
+ </div>
200
+ </td>
201
+ <td>
202
+ <p class="media-meta"><span class="label label-default"><?php echo "#{$item->ID}"; ?>:</span> <b><?php echo esc_html( $item->title ); ?>&nbsp;</b></p>
203
+ <p class="media-meta">
204
+ <span class="label label-default"><?php _e( 'Album', 'grand-media' ); ?>:</span>
205
+ <?php
206
+ if ( $item->album ) {
207
+ $terms_album = [];
208
+ foreach ( $item->album as $c ) {
209
+ $terms_album[] = esc_html( $c->name );
210
+ }
211
+ $terms_album = join( ', ', $terms_album );
212
+ } else {
213
+ $terms_album = '&#8212;';
214
+ }
215
+ echo $terms_album;
216
+ ?>
217
+ <br/><span class="label label-default"><?php _e( 'Category', 'grand-media' ); ?>:</span>
218
+ <?php
219
+ if ( $item->categories ) {
220
+ $terms_category = [];
221
+ foreach ( $item->categories as $c ) {
222
+ $terms_category[] = esc_html( $c->name );
223
+ }
224
+ $terms_category = join( ', ', $terms_category );
225
+ } else {
226
+ $terms_category = __( 'Uncategorized', 'grand-media' );
227
+ }
228
+ echo $terms_category;
229
+ ?>
230
+ <br/><span class="label label-default"><?php _e( 'Tags', 'grand-media' ); ?>:</span>
231
+ <?php
232
+ if ( $item->tags ) {
233
+ $terms_tag = [];
234
+ foreach ( $item->tags as $c ) {
235
+ $terms_tag[] = esc_html( $c->name );
236
+ }
237
+ $terms_tag = join( ', ', $terms_tag );
238
+ } else {
239
+ $terms_tag = '&#8212;';
240
+ }
241
+ echo $terms_tag;
242
+ ?>
243
+ </p>
244
+ <p class="media-meta">
245
+ <span class="label label-default"><?php _e( 'Views / Likes', 'grand-media' ); ?>:</span>
246
+ <?php echo ( isset( $item->meta['views'][0] ) ? $item->meta['views'][0] : '0' ) . ' / ' . ( isset( $item->meta['likes'][0] ) ? $item->meta['likes'][0] : '0' ); ?>
247
+
248
+ <?php if ( isset( $item->meta['_rating'][0] ) ) {
249
+ $ratings = maybe_unserialize( $item->meta['_rating'][0] ); ?>
250
+ <br/><span class="label label-default"><?php _e( 'Rating', 'grand-media' ); ?>:</span> <?php echo round( $ratings['value'], 2 ) . ' / ' . $ratings['votes']; ?>
251
+ <?php } ?>
252
+ <br/><span class="label label-default"><?php _e( 'Type', 'grand-media' ); ?>:</span> <?php echo $item->mime_type; ?>
253
+ <br/><span class="label label-default"><?php _e( 'Filename', 'grand-media' ); ?>:</span> <a href="<?php echo esc_url( gm_get_admin_url( [ 'page' => 'GrandMedia', 'gmedia__in' => $item->ID ], [], $gmedia_url ) ); ?>"><?php echo $item->gmuid; ?></a>
254
+ </p>
255
+ </td>
256
+ <td><p><?php echo $item->log_date; ?></p></td>
257
+ <td>
258
+ <p><?php
259
+ $author_name = $item->log_author ? get_user_option( 'display_name', $item->log_author ) : __( 'Guest', 'grand-media' );
260
+ printf( '<a class="gmedia-author" href="%s">%s</a>', esc_url( add_query_arg( [ 'author' => $item->log_author ], $gmedia_url ) ), $author_name );
261
+ ?></p>
262
+ <p class="media-meta"><span class="label label-default"><?php _e( 'IP Address', 'grand-media' ); ?>:</span> <?php echo $item->ip_address; ?></p>
263
+ </td>
264
+ <td><p><?php
265
+ switch ( $item->log ) {
266
+ case 'view':
267
+ _e( 'View / Play', 'grand-media' );
268
+ break;
269
+ case 'like':
270
+ _e( 'Like', 'grand-media' );
271
+ break;
272
+ case 'rate':
273
+ echo __( 'Rate', 'grand-media' ) . ": {$item->log_data}";
274
+ break;
275
+ }
276
+ ?></p></td>
277
+ </tr>
278
+ <?php
279
+ }
280
+ } else {
281
+ echo '<tr><td colspan="5" style="font-weight: bold; text-align: center; padding: 30px 0;">' . __( 'No Records.', 'grand-media' ) . '</td></tr>';
282
+ }
283
+ ?>
284
+ </tbody>
285
+
286
+ </table>
287
+ </div>
288
+ <?php
289
+ wp_original_referer_field( true, 'previous' );
290
+ wp_nonce_field( 'GmediaGallery' );
291
+ ?>
292
+ </form>
293
+ </div>
294
+
295
+ <div class="modal fade gmedia-modal" id="libModal" tabindex="-1" role="dialog" aria-hidden="true">
296
+ <div class="modal-dialog"></div>
297
+ </div>
admin/pages/addmedia/addmedia.php CHANGED
@@ -3,9 +3,9 @@
3
  * Gmedia AddMedia
4
  */
5
 
6
- // don't load directly
7
- if(!defined('ABSPATH')) {
8
- die('-1');
9
  }
10
 
11
  global $user_ID, $gmGallery, $gmProcessor, $gmCore, $gmDB;
@@ -16,20 +16,18 @@ $import = $gmProcessor->import;
16
 
17
  <div class="panel panel-default">
18
 
19
- <?php include(dirname(__FILE__) . '/tpl/panel-heading.php'); ?>
20
 
21
- <div class="panel-body" id="gmedia-msg-panel"></div>
22
- <div class="container-fluid gmAddMedia">
23
- <?php
24
- if(!$import) {
25
- include(dirname(__FILE__) . '/tpl/upload.php');
26
- } else {
27
- include(dirname(__FILE__) . '/tpl/import.php');
28
- }
29
 
30
- wp_original_referer_field(true, 'previous');
31
- ?>
32
- </div>
33
  </div>
34
-
35
-
3
  * Gmedia AddMedia
4
  */
5
 
6
+ // don't load directly.
7
+ if ( ! defined( 'ABSPATH' ) ) {
8
+ die( '-1' );
9
  }
10
 
11
  global $user_ID, $gmGallery, $gmProcessor, $gmCore, $gmDB;
16
 
17
  <div class="panel panel-default">
18
 
19
+ <?php include dirname( __FILE__ ) . '/tpl/panel-heading.php'; ?>
20
 
21
+ <div class="panel-body" id="gmedia-msg-panel"></div>
22
+ <div class="container-fluid gmAddMedia">
23
+ <?php
24
+ if ( ! $import ) {
25
+ include dirname( __FILE__ ) . '/tpl/upload.php';
26
+ } else {
27
+ include dirname( __FILE__ ) . '/tpl/import.php';
28
+ }
29
 
30
+ wp_original_referer_field( true, 'previous' );
31
+ ?>
32
+ </div>
33
  </div>
 
 
admin/pages/addmedia/tpl/assign-terms.php CHANGED
@@ -5,71 +5,71 @@
5
  * @var $gmDB
6
  */
7
 
8
- // don't load directly
9
- if(!defined('ABSPATH')) {
10
- die('-1');
11
  }
12
 
13
- if(gm_user_can('terms')) {
14
- global $gmCore;
15
- ?>
16
- <div class="form-group">
17
- <?php
18
- $term_type = 'gmedia_album';
19
- $global = gm_user_can('edit_others_media')? '' : array(0, $user_ID);
20
- $gm_terms = $gmDB->get_terms($term_type, array('global' => $global, 'orderby' => 'global_desc_name'));
21
 
22
- $terms_album = '';
23
- if(count($gm_terms)) {
24
- $selected = (int) $gmCore->_get('album');
25
- foreach($gm_terms as $term) {
26
- $author_name = '';
27
- if($term->global) {
28
- if(gm_user_can('edit_others_media')) {
29
- $author_name .= ' &nbsp; ' . sprintf(__('by %s', 'grand-media'), get_the_author_meta('display_name', $term->global));
30
- }
31
- } else {
32
- $author_name .= ' &nbsp; (' . __('shared', 'grand-media') . ')';
33
- }
34
- if('publish' != $term->status) {
35
- $author_name .= ' [' . $term->status . ']';
36
- }
37
- $terms_album .= '<option value="' . $term->term_id . '" data-name="' . esc_html($term->name) . '" data-meta="' . $author_name . '"' . selected($selected, $term->term_id, false) . '>' . esc_html($term->name) . $author_name . '</option>' . "\n";
38
- }
39
- }
40
- ?>
41
- <label><?php _e('Add to Album', 'grand-media'); ?> </label>
42
- <select id="combobox_gmedia_album" name="terms[gmedia_album]" data-create="<?php echo gm_user_can('album_manage')? 'true' : 'false'; ?>" class="form-control input-sm" placeholder="<?php _e('Album Name...', 'grand-media'); ?>">
43
- <option value=""></option>
44
- <?php echo $terms_album; ?>
45
- </select>
46
- </div>
47
 
48
- <div class="form-group">
49
- <?php
50
- $term_type = 'gmedia_category';
51
- $gm_category_terms = $gmDB->get_terms($term_type, array('fields' => 'id=>names'));
52
- $selected = (int) $gmCore->_get('category');
53
- $selected = isset($gm_category_terms[$selected])? $gm_category_terms[$selected] : '';
54
- ?>
55
- <label><?php _e('Assign Categories', 'grand-media'); ?></label>
56
- <input id="combobox_gmedia_category" name="terms[gmedia_category]" data-create="<?php echo gm_user_can('category_manage')? 'true' : 'false'; ?>" class="form-control input-sm" value="<?php echo $selected ?>" placeholder="<?php _e('Uncategorized', 'grand-media'); ?>"/>
57
- </div>
58
 
59
- <div class="form-group">
60
- <?php
61
- $term_type = 'gmedia_tag';
62
- $gm_tag_terms = $gmDB->get_terms($term_type, array('fields' => 'id=>names'));
63
- $selected = (int) $gmCore->_get('tag');
64
- $selected = isset($gm_tag_terms[$selected])? $gm_tag_terms[$selected] : '';
65
- ?>
66
- <label><?php _e('Add Tags', 'grand-media'); ?> </label>
67
- <input id="combobox_gmedia_tag" name="terms[gmedia_tag]" data-create="<?php echo gm_user_can('tag_manage')? 'true' : 'false'; ?>" class="form-control input-sm" value="<?php echo $selected ?>" placeholder="<?php _e('Add Tags...', 'grand-media'); ?>"/>
68
- </div>
69
- <script type="text/javascript">
70
- var gmedia_categories = <?php echo json_encode(array_values($gm_category_terms)); ?>;
71
- var gmedia_tags = <?php echo json_encode(array_values($gm_tag_terms)); ?>;
72
- </script>
73
  <?php } else { ?>
74
- <p><?php _e('You are not allowed to assign terms', 'grand-media') ?></p>
75
  <?php } ?>
5
  * @var $gmDB
6
  */
7
 
8
+ // don't load directly.
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ die( '-1' );
11
  }
12
 
13
+ if ( gm_user_can( 'terms' ) ) {
14
+ global $gmCore;
15
+ ?>
16
+ <div class="form-group">
17
+ <?php
18
+ $term_type = 'gmedia_album';
19
+ $global = gm_user_can( 'edit_others_media' ) ? '' : [ 0, $user_ID ];
20
+ $gm_terms = $gmDB->get_terms( $term_type, [ 'global' => $global, 'orderby' => 'global_desc_name' ] );
21
 
22
+ $terms_album = '';
23
+ if ( count( $gm_terms ) ) {
24
+ $selected = (int) $gmCore->_get( 'album' );
25
+ foreach ( $gm_terms as $term ) {
26
+ $author_name = '';
27
+ if ( $term->global ) {
28
+ if ( gm_user_can( 'edit_others_media' ) ) {
29
+ $author_name .= ' &nbsp; ' . sprintf( __( 'by %s', 'grand-media' ), esc_html( get_the_author_meta( 'display_name', $term->global ) ) );
30
+ }
31
+ } else {
32
+ $author_name .= ' &nbsp; (' . __( 'shared', 'grand-media' ) . ')';
33
+ }
34
+ if ( 'publish' !== $term->status ) {
35
+ $author_name .= ' [' . $term->status . ']';
36
+ }
37
+ $terms_album .= '<option value="' . $term->term_id . '" data-name="' . esc_html( $term->name ) . '" data-meta="' . $author_name . '" ' . selected( $selected, $term->term_id, false ) . '>' . esc_html( $term->name ) . $author_name . '</option>' . "\n";
38
+ }
39
+ }
40
+ ?>
41
+ <label><?php _e( 'Add to Album', 'grand-media' ); ?> </label>
42
+ <select id="combobox_gmedia_album" name="terms[gmedia_album]" data-create="<?php echo esc_attr( gm_user_can( 'album_manage' ) ? 'true' : 'false' ); ?>" class="form-control input-sm" placeholder="<?php _e( 'Album Name...', 'grand-media' ); ?>">
43
+ <option value=""></option>
44
+ <?php echo $terms_album; ?>
45
+ </select>
46
+ </div>
47
 
48
+ <div class="form-group">
49
+ <?php
50
+ $term_type = 'gmedia_category';
51
+ $gm_category_terms = $gmDB->get_terms( $term_type, [ 'fields' => 'id=>names' ] );
52
+ $selected = (int) $gmCore->_get( 'category' );
53
+ $selected = isset( $gm_category_terms[ $selected ] ) ? $gm_category_terms[ $selected ] : '';
54
+ ?>
55
+ <label><?php _e( 'Assign Categories', 'grand-media' ); ?></label>
56
+ <input id="combobox_gmedia_category" name="terms[gmedia_category]" data-create="<?php echo esc_attr( gm_user_can( 'category_manage' ) ? 'true' : 'false' ); ?>" class="form-control input-sm" value="<?php echo esc_attr( $selected ); ?>" placeholder="<?php _e( 'Uncategorized', 'grand-media' ); ?>"/>
57
+ </div>
58
 
59
+ <div class="form-group">
60
+ <?php
61
+ $term_type = 'gmedia_tag';
62
+ $gm_tag_terms = $gmDB->get_terms( $term_type, [ 'fields' => 'id=>names' ] );
63
+ $selected = (int) $gmCore->_get( 'tag' );
64
+ $selected = isset( $gm_tag_terms[ $selected ] ) ? $gm_tag_terms[ $selected ] : '';
65
+ ?>
66
+ <label><?php _e( 'Add Tags', 'grand-media' ); ?> </label>
67
+ <input id="combobox_gmedia_tag" name="terms[gmedia_tag]" data-create="<?php echo esc_attr( gm_user_can( 'tag_manage' ) ? 'true' : 'false' ); ?>" class="form-control input-sm" value="<?php echo esc_attr( $selected ); ?>" placeholder="<?php _e( 'Add Tags...', 'grand-media' ); ?>"/>
68
+ </div>
69
+ <script type="text/javascript">
70
+ var gmedia_categories = <?php echo wp_json_encode( array_values( $gm_category_terms ) ); ?>;
71
+ var gmedia_tags = <?php echo wp_json_encode( array_values( $gm_tag_terms ) ); ?>;
72
+ </script>
73
  <?php } else { ?>
74
+ <p><?php _e( 'You are not allowed to assign terms', 'grand-media' ) ?></p>
75
  <?php } ?>
admin/pages/addmedia/tpl/import.php CHANGED
@@ -3,176 +3,176 @@
3
  * Gmedia Import
4
  */
5
 
6
- // don't load directly
7
- if(!defined('ABSPATH')) {
8
- die('-1');
9
  }
10
 
11
- if(!gm_user_can('upload')) {
12
- _e('You do not have permissions to import media', 'grand-media');
13
 
14
- return;
15
  }
16
 
17
  global $wpdb;
18
 
19
- $gmediaURL = plugins_url(GMEDIA_FOLDER);
20
- $gm_terms = array();
21
- $import_tab = array();
22
  ?>
23
- <form class="row" id="import_form" name="import_form" target="import_window" action="<?php echo admin_url('admin-ajax.php'); ?>" method="POST" accept-charset="utf-8" style="padding:20px 0 10px;">
24
- <div class="col-md-4">
25
- <fieldset id="import_params" class="import-params">
26
- <?php wp_nonce_field('gmedia_import', '_wpnonce_import'); ?>
27
- <input type="hidden" name="action" value="gmedia_import_handler"/>
28
- <input type="hidden" id="import-action" name="import" value=""/>
29
 
30
- <?php include(dirname(__FILE__) . '/assign-terms.php'); ?>
31
 
32
- </fieldset>
33
- </div>
34
 
35
- <div class="col-md-8 tabable">
36
- <ul class="nav nav-tabs" style="padding:0 10px;">
37
- <li class="active"><a href="#import_folder" data-toggle="tab"><?php _e('Import Server Folder', 'grand-media'); ?></a></li>
38
- <?php
39
- if(($import_tab['flagallery'] = $wpdb->get_var("show tables like '{$wpdb->prefix}flag_gallery'"))) { ?>
40
- <li><a href="#import_flagallery" data-toggle="tab"><?php _e('FlAGallery plugin', 'grand-media'); ?></a></li>
41
- <?php
42
- }
43
- if(($import_tab['nextgen'] = $wpdb->get_var("show tables like '{$wpdb->prefix}ngg_gallery'"))) { ?>
44
- <li><a href="#import_nextgen" data-toggle="tab"><?php _e('NextGen plugin', 'grand-media'); ?></a></li>
45
- <?php
46
- } ?>
47
- </ul>
48
- <div class="tab-content">
49
- <fieldset id="import_folder" class="tab-pane active">
50
- <?php echo "<style type='text/css'>@import url('{$gmediaURL}/assets/jqueryFileTree/jqueryFileTree.css');</style>\n"; ?>
51
- <?php echo "<script type='text/javascript' src='{$gmediaURL}/assets/jqueryFileTree/jqueryFileTree.js'></script>\n"; ?>
52
- <input type="hidden" id="folderpath" name="path" value="/"/>
53
 
54
- <div class="tab-inside">
55
- <h5><?php _e('Sever folders', 'grand-media') ?>:</h5>
56
 
57
- <div id="file_browser"></div>
58
- </div>
59
- <div class="tab-footer">
60
- <div class="checkbox pull-left">
61
- <div><label><input type="checkbox" name="delete_source" value="1"/> <?php _e('delete source files after importing', 'grand-media') ?></label></div>
62
- <div><label><input type="checkbox" name="skip_exists" value="skip"> <?php _e('Skip if file with the same name already exists in Gmedia Library', 'grand-media'); ?></label></div>
63
- <div class="help-block"><?php _e('Note: duplicates will be skipped in any way (checked by file hash)') ?></div>
64
- </div>
65
- <button class="pull-right btn btn-info gmedia-import" type="button" name="import-folder" value="true"><?php _e('Import folder', 'grand-media'); ?></button>
66
- </div>
67
- <script type="text/javascript">
68
- /* <![CDATA[ */
69
- jQuery(document).ready(function() {
70
- jQuery("#file_browser").fileTree({
71
- script: ajaxurl + "?action=gmedia_ftp_browser&_wpnonce=<?php echo wp_create_nonce( 'GmediaGallery' ) ;?>",
72
- root: '/',
73
- loadMessage: "<?php _e('loading...', 'grand-media'); ?>"
74
- }, function(path) {
75
- jQuery("#folderpath").val(path);
76
- });
77
- });
78
- /* ]]> */
79
- </script>
80
- </fieldset>
81
 
82
- <?php if(!empty($import_tab['flagallery'])) { ?>
83
- <fieldset id="import_flagallery" class="tab-pane">
84
- <?php
85
- $import_tab['flagallery'] = $wpdb->get_results("SELECT gid, title, galdesc FROM {$wpdb->prefix}flag_gallery");
86
- if(!empty($import_tab['flagallery'])) {
87
- ?>
88
- <div class="tab-inside">
89
- <p><?php _e('If Album is not specified, then gallery name will be used as Album', 'grand-media') ?></p>
90
- <h5><?php _e('Flagallery Galleries', 'grand-media') ?>:
91
- <small>(<a href="#toggle-flaggalery" class="gm-toggle-cb"><?php _e('Toggle checkboxes', 'grand-media') ?></a>)</small>
92
- </h5>
93
- <div id="toggle-flaggalery">
94
- <?php foreach($import_tab['flagallery'] as $gallery) { ?>
95
- <div class="checkbox">
96
- <label><input type="checkbox" name="gallery[]" value="<?php echo $gallery->gid ?>"/>
97
- <span><?php echo esc_html($gallery->title); ?></span></label>
98
- <?php /* if(!empty($gallery->galdesc)){ echo '<div class="help-block"> ' . stripslashes($gallery->galdesc) . '</div>'; } */ ?>
99
- </div>
100
- <?php } ?>
101
- </div>
102
- </div>
103
- <div class="tab-footer">
104
- <div class="checkbox pull-left">
105
- <label><input type="checkbox" name="skip_exists" value="skip"> <?php _e('Skip if file with the same name already exists in Gmedia Library', 'grand-media'); ?></label>
106
- <div class="help-block"><?php _e('Note: duplicates will be skipped in any way (checked by file hash)') ?></div>
107
- </div>
108
- <button class="pull-right btn btn-info gmedia-import" type="button" name="import-flagallery" value="true"><?php _e('Import', 'grand-media'); ?></button>
109
- </div>
110
- <?php } else { ?>
111
- <p class="tab-inside"><?php _e('There are no created galleries in this plugin.', 'grand-media') ?></p>
112
- <?php } ?>
113
- </fieldset>
114
- <?php } ?>
115
 
116
- <?php if(!empty($import_tab['nextgen'])) { ?>
117
- <fieldset id="import_nextgen" class="tab-pane">
118
- <?php
119
- $import_tab['nextgen'] = $wpdb->get_results("SELECT gid, title, galdesc FROM {$wpdb->prefix}ngg_gallery");
120
- if(!empty($import_tab['nextgen'])) {
121
- ?>
122
- <div class="tab-inside">
123
- <p><?php _e('If Album is not specified, then gallery name will be used as Album', 'grand-media') ?></p>
124
- <h5><?php _e('NextGen Galleries', 'grand-media') ?>:
125
- <small>(<a href="#toggle-nextgen" class="gm-toggle-cb"><?php _e('Toggle checkboxes', 'grand-media') ?></a>)</small>
126
- </h5>
127
- <div id="toggle-nextgen">
128
- <?php foreach($import_tab['nextgen'] as $gallery) { ?>
129
- <div class="checkbox">
130
- <label><input type="checkbox" name="gallery[]" value="<?php echo $gallery->gid ?>"/> <span><?php echo esc_html($gallery->title); ?></span></label>
131
- <?php /* if(!empty($gallery->galdesc)){ echo '<div class="help-block"> ' . stripslashes($gallery->galdesc) . '</div>'; } */ ?>
132
- </div>
133
- <?php } ?>
134
- </div>
135
- </div>
136
- <div class="tab-footer">
137
- <div class="checkbox pull-left">
138
- <label><input type="checkbox" name="skip_exists" value="skip"> <?php _e('Skip if file with the same name already exists in Gmedia Library', 'grand-media'); ?></label>
139
- <div class="help-block"><?php _e('Note: duplicates will be skipped in any way (checked by file hash)') ?></div>
140
- </div>
141
- <button class="pull-right btn btn-info gmedia-import" type="button" name="import-nextgen" value="true"><?php _e('Import', 'grand-media'); ?></button>
142
- </div>
143
- <?php } else { ?>
144
- <p class="tab-inside"><?php _e('There are no created galleries in this plugin.', 'grand-media') ?></p>
145
- <?php } ?>
146
- </fieldset>
147
- <?php } ?>
148
 
149
- </div>
150
- <div class="clear"></div>
151
- </div>
152
  </form>
153
 
154
  <div class="modal fade gmedia-modal" id="importModal" tabindex="-1" role="dialog" aria-hidden="true">
155
- <div class="modal-dialog">
156
- <div class="modal-content">
157
- <div class="modal-header">
158
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
159
- <h4 class="modal-title"><?php _e('Import', 'grand-media'); ?></h4>
160
- </div>
161
- <div class="modal-body">
162
- <script type="text/javascript">
163
- function gmedia_import_done() {
164
- if(jQuery('#importModal').is(':visible')) {
165
- var btn = jQuery('#import-done');
166
- btn.text(btn.data('complete-text')).prop('disabled', false);
167
- }
168
- }
169
- </script>
170
- <iframe name="import_window" id="import_window" src="about:blank" width="100%" height="300" onload="gmedia_import_done()"></iframe>
171
- </div>
172
- <div class="modal-footer">
173
- <button type="button" id="import-done" class="btn btn-primary" data-dismiss="modal" data-complete-text="<?php _e('Close', 'grand-media'); ?>" disabled="disabled"><?php _e('Working...', 'grand-media'); ?></button>
174
- </div>
175
- </div>
176
- </div>
177
  </div>
178
 
3
  * Gmedia Import
4
  */
5
 
6
+ // don't load directly.
7
+ if ( ! defined( 'ABSPATH' ) ) {
8
+ die( '-1' );
9
  }
10
 
11
+ if ( ! gm_user_can( 'upload' ) ) {
12
+ _e( 'You do not have permissions to import media', 'grand-media' );
13
 
14
+ return;
15
  }
16
 
17
  global $wpdb;
18
 
19
+ $gmediaURL = plugins_url( GMEDIA_FOLDER );
20
+ $gm_terms = [];
21
+ $import_tab = [];
22
  ?>
23
+ <form class="row" id="import_form" name="import_form" target="import_window" action="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>" method="POST" accept-charset="utf-8" style="padding:20px 0 10px;">
24
+ <div class="col-md-4">
25
+ <fieldset id="import_params" class="import-params">
26
+ <?php wp_nonce_field( 'gmedia_import', '_wpnonce_import' ); ?>
27
+ <input type="hidden" name="action" value="gmedia_import_handler"/>
28
+ <input type="hidden" id="import-action" name="import" value=""/>
29
 
30
+ <?php include dirname( __FILE__ ) . '/assign-terms.php'; ?>
31
 
32
+ </fieldset>
33
+ </div>
34
 
35
+ <div class="col-md-8 tabable">
36
+ <ul class="nav nav-tabs" style="padding:0 10px;">
37
+ <li class="active"><a href="#import_folder" data-toggle="tab"><?php _e( 'Import Server Folder', 'grand-media' ); ?></a></li>
38
+ <?php
39
+ if ( ( $import_tab['flagallery'] = $wpdb->get_var( "show tables like '{$wpdb->prefix}flag_gallery'" ) ) ) { ?>
40
+ <li><a href="#import_flagallery" data-toggle="tab"><?php _e( 'FlAGallery plugin', 'grand-media' ); ?></a></li>
41
+ <?php
42
+ }
43
+ if ( ( $import_tab['nextgen'] = $wpdb->get_var( "show tables like '{$wpdb->prefix}ngg_gallery'" ) ) ) { ?>
44
+ <li><a href="#import_nextgen" data-toggle="tab"><?php _e( 'NextGen plugin', 'grand-media' ); ?></a></li>
45
+ <?php
46
+ } ?>
47
+ </ul>
48
+ <div class="tab-content">
49
+ <fieldset id="import_folder" class="tab-pane active">
50
+ <?php echo "<style type='text/css'>@import url('{$gmediaURL}/assets/jqueryFileTree/jqueryFileTree.css');</style>\n"; ?>
51
+ <?php echo "<script type='text/javascript' src='{$gmediaURL}/assets/jqueryFileTree/jqueryFileTree.js'></script>\n"; ?>
52
+ <input type="hidden" id="folderpath" name="path" value="/"/>
53
 
54
+ <div class="tab-inside">
55
+ <h5><?php _e( 'Sever folders', 'grand-media' ) ?>:</h5>
56
 
57
+ <div id="file_browser"></div>
58
+ </div>
59
+ <div class="tab-footer">
60
+ <div class="checkbox pull-left">
61
+ <div><label><input type="checkbox" name="delete_source" value="1"/> <?php _e( 'delete source files after importing', 'grand-media' ) ?></label></div>
62
+ <div><label><input type="checkbox" name="skip_exists" value="skip"> <?php _e( 'Skip if file with the same name already exists in Gmedia Library', 'grand-media' ); ?></label></div>
63
+ <div class="help-block"><?php _e( 'Note: duplicates will be skipped in any way (checked by file hash)' ) ?></div>
64
+ </div>
65
+ <button class="pull-right btn btn-info gmedia-import" type="button" name="import-folder" value="true"><?php _e( 'Import folder', 'grand-media' ); ?></button>
66
+ </div>
67
+ <script type="text/javascript">
68
+ /* <![CDATA[ */
69
+ jQuery(document).ready(function() {
70
+ jQuery('#file_browser').fileTree({
71
+ script: ajaxurl + "?action=gmedia_ftp_browser&_wpnonce=<?php echo wp_create_nonce( 'GmediaGallery' );?>",
72
+ root: '/',
73
+ loadMessage: "<?php _e( 'loading...', 'grand-media' ); ?>"
74
+ }, function(path) {
75
+ jQuery('#folderpath').val(path);
76
+ });
77
+ });
78
+ /* ]]> */
79
+ </script>
80
+ </fieldset>
81
 
82
+ <?php if ( ! empty( $import_tab['flagallery'] ) ) { ?>
83
+ <fieldset id="import_flagallery" class="tab-pane">
84
+ <?php
85
+ $import_tab['flagallery'] = $wpdb->get_results( "SELECT gid, title, galdesc FROM {$wpdb->prefix}flag_gallery" );
86
+ if ( ! empty( $import_tab['flagallery'] ) ) {
87
+ ?>
88
+ <div class="tab-inside">
89
+ <p><?php _e( 'If Album is not specified, then gallery name will be used as Album', 'grand-media' ) ?></p>
90
+ <h5><?php _e( 'Flagallery Galleries', 'grand-media' ) ?>:
91
+ <small>(<a href="#toggle-flaggalery" class="gm-toggle-cb"><?php _e( 'Toggle checkboxes', 'grand-media' ) ?></a>)</small>
92
+ </h5>
93
+ <div id="toggle-flaggalery">
94
+ <?php foreach ( $import_tab['flagallery'] as $gallery ) { ?>
95
+ <div class="checkbox">
96
+ <label><input type="checkbox" name="gallery[]" value="<?php echo absint( $gallery->gid ); ?>"/>
97
+ <span><?php echo esc_html( $gallery->title ); ?></span></label>
98
+ <?php /* if(!empty($gallery->galdesc)){ echo '<div class="help-block"> ' . stripslashes($gallery->galdesc) . '</div>'; } */ ?>
99
+ </div>
100
+ <?php } ?>
101
+ </div>
102
+ </div>
103
+ <div class="tab-footer">
104
+ <div class="checkbox pull-left">
105
+ <label><input type="checkbox" name="skip_exists" value="skip"> <?php _e( 'Skip if file with the same name already exists in Gmedia Library', 'grand-media' ); ?></label>
106
+ <div class="help-block"><?php _e( 'Note: duplicates will be skipped in any way (checked by file hash)' ) ?></div>
107
+ </div>
108
+ <button class="pull-right btn btn-info gmedia-import" type="button" name="import-flagallery" value="true"><?php _e( 'Import', 'grand-media' ); ?></button>
109
+ </div>
110
+ <?php } else { ?>
111
+ <p class="tab-inside"><?php _e( 'There are no created galleries in this plugin.', 'grand-media' ) ?></p>
112
+ <?php } ?>
113
+ </fieldset>
114
+ <?php } ?>
115
 
116
+ <?php if ( ! empty( $import_tab['nextgen'] ) ) { ?>
117
+ <fieldset id="import_nextgen" class="tab-pane">
118
+ <?php
119
+ $import_tab['nextgen'] = $wpdb->get_results( "SELECT gid, title, galdesc FROM {$wpdb->prefix}ngg_gallery" );
120
+ if ( ! empty( $import_tab['nextgen'] ) ) {
121
+ ?>
122
+ <div class="tab-inside">
123
+ <p><?php _e( 'If Album is not specified, then gallery name will be used as Album', 'grand-media' ) ?></p>
124
+ <h5><?php _e( 'NextGen Galleries', 'grand-media' ) ?>:
125
+ <small>(<a href="#toggle-nextgen" class="gm-toggle-cb"><?php _e( 'Toggle checkboxes', 'grand-media' ) ?></a>)</small>
126
+ </h5>
127
+ <div id="toggle-nextgen">
128
+ <?php foreach ( $import_tab['nextgen'] as $gallery ) { ?>
129
+ <div class="checkbox">
130
+ <label><input type="checkbox" name="gallery[]" value="<?php echo absint( $gallery->gid ); ?>"/> <span><?php echo esc_html( $gallery->title ); ?></span></label>
131
+ <?php /* if(!empty($gallery->galdesc)){ echo '<div class="help-block"> ' . stripslashes($gallery->galdesc) . '</div>'; } */ ?>
132
+ </div>
133
+ <?php } ?>
134
+ </div>
135
+ </div>
136
+ <div class="tab-footer">
137
+ <div class="checkbox pull-left">
138
+ <label><input type="checkbox" name="skip_exists" value="skip"> <?php _e( 'Skip if file with the same name already exists in Gmedia Library', 'grand-media' ); ?></label>
139
+ <div class="help-block"><?php _e( 'Note: duplicates will be skipped in any way (checked by file hash)' ) ?></div>
140
+ </div>
141
+ <button class="pull-right btn btn-info gmedia-import" type="button" name="import-nextgen" value="true"><?php _e( 'Import', 'grand-media' ); ?></button>
142
+ </div>
143
+ <?php } else { ?>
144
+ <p class="tab-inside"><?php _e( 'There are no created galleries in this plugin.', 'grand-media' ) ?></p>
145
+ <?php } ?>
146
+ </fieldset>
147
+ <?php } ?>
148
 
149
+ </div>
150
+ <div class="clear"></div>
151
+ </div>
152
  </form>
153
 
154
  <div class="modal fade gmedia-modal" id="importModal" tabindex="-1" role="dialog" aria-hidden="true">
155
+ <div class="modal-dialog">
156
+ <div class="modal-content">
157
+ <div class="modal-header">
158
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
159
+ <h4 class="modal-title"><?php _e( 'Import', 'grand-media' ); ?></h4>
160
+ </div>
161
+ <div class="modal-body">
162
+ <script type="text/javascript">
163
+ function gmedia_import_done() {
164
+ if (jQuery('#importModal').is(':visible')) {
165
+ var btn = jQuery('#import-done');
166
+ btn.text(btn.data('complete-text')).prop('disabled', false);
167
+ }
168
+ }
169
+ </script>
170
+ <iframe name="import_window" id="import_window" src="about:blank" width="100%" height="300" onload="gmedia_import_done()"></iframe>
171
+ </div>
172
+ <div class="modal-footer">
173
+ <button type="button" id="import-done" class="btn btn-primary" data-dismiss="modal" data-complete-text="<?php _e( 'Close', 'grand-media' ); ?>" disabled="disabled"><?php _e( 'Working...', 'grand-media' ); ?></button>
174
+ </div>
175
+ </div>
176
+ </div>
177
  </div>
178
 
admin/pages/addmedia/tpl/panel-heading.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- // don't load directly
3
- if(!defined('ABSPATH')) {
4
- die('-1');
5
  }
6
 
7
  /**
@@ -9,43 +9,43 @@ if(!defined('ABSPATH')) {
9
  * @var $import
10
  */
11
  global $gmCore, $gmProcessor;
12
- $extra_tools = ($gmProcessor->gmediablank || (defined('GMEDIA_IFRAME') && GMEDIA_IFRAME))? false : true;
13
  ?>
14
  <div class="panel-heading clearfix">
15
- <?php if($extra_tools) {
16
- $refurl = strpos(wp_get_referer(), "edit_term")? wp_get_referer() : false;
17
- ?>
18
- <div class="btn-toolbar pull-left" style="white-space:nowrap;">
19
- <?php if($refurl){
20
- $referer = $gmCore->get_admin_url(array(), array(), $refurl);
21
- ?>
22
- <a class="btn btn-default pull-left" style="margin-right:20px;" href="<?php echo $referer; ?>"><?php _e('Go Back', 'grand-media'); ?></a>
23
- <?php
24
- } ?>
25
 
26
- <div class="btn-group">
27
- <a class="btn btn<?php echo !$import? '-primary active' : '-default'; ?>" href="<?php echo gm_get_admin_url(array(), array('import'), $url); ?>"><?php _e('Upload Files', 'grand-media'); ?></a>
28
- <?php if(gm_user_can('import')) { ?>
29
- <a class="btn btn<?php echo $import? '-primary active' : '-default'; ?>" href="<?php echo gm_get_admin_url(array('import' => 1), array(), $url); ?>"><?php _e('Import', 'grand-media'); ?></a>
30
- <?php } ?>
31
- </div>
32
- <?php if($import && gm_user_can('import')) { ?>
33
- <a class="btn btn-default" href="<?php echo admin_url('admin.php?page=GrandMedia_WordpressLibrary'); ?>"><?php _e('Import from WP Media Library', 'grand-media'); ?></a>
34
- <?php } ?>
35
- </div>
36
- <?php } ?>
37
- <div id="total-progress-info" class="progress pull-right">
38
- <?php $msg = '';
39
- if(!$import) {
40
- $msg = __('Add files to the upload queue and click the start button', 'grand-media');
41
- } else {
42
- $msg = __('Grab files from other sources', 'grand-media');
43
- }
44
- ?>
45
- <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width:0;">
46
- <div style="padding: 2px 10px;"><?php echo $msg; ?></div>
47
- </div>
48
- <div style="padding: 2px 10px;"><?php echo $msg; ?></div>
49
- </div>
50
- <div class="spinner"></div>
51
  </div>
1
  <?php
2
+ // don't load directly.
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ die( '-1' );
5
  }
6
 
7
  /**
9
  * @var $import
10
  */
11
  global $gmCore, $gmProcessor;
12
+ $extra_tools = ( $gmProcessor->gmediablank || ( defined( 'GMEDIA_IFRAME' ) && GMEDIA_IFRAME ) ) ? false : true;
13
  ?>
14
  <div class="panel-heading clearfix">
15
+ <?php if ( $extra_tools ) {
16
+ $refurl = strpos( wp_get_referer(), "edit_term" ) ? wp_get_referer() : false;
17
+ ?>
18
+ <div class="btn-toolbar pull-left" style="white-space:nowrap;">
19
+ <?php if ( $refurl ) {
20
+ $referer = $gmCore->get_admin_url( [], [], $refurl );
21
+ ?>
22
+ <a class="btn btn-default pull-left" style="margin-right:20px;" href="<?php echo esc_url( $referer ); ?>"><?php _e( 'Go Back', 'grand-media' ); ?></a>
23
+ <?php
24
+ } ?>
25
 
26
+ <div class="btn-group">
27
+ <a class="btn btn<?php echo ! $import ? '-primary active' : '-default'; ?>" href="<?php echo esc_url( gm_get_admin_url( [], [ 'import' ], $url ) ); ?>"><?php _e( 'Upload Files', 'grand-media' ); ?></a>
28
+ <?php if ( gm_user_can( 'import' ) ) { ?>
29
+ <a class="btn btn<?php echo $import ? '-primary active' : '-default'; ?>" href="<?php echo esc_url( gm_get_admin_url( [ 'import' => 1 ], [], $url ) ); ?>"><?php _e( 'Import', 'grand-media' ); ?></a>
30
+ <?php } ?>
31
+ </div>
32
+ <?php if ( $import && gm_user_can( 'import' ) ) { ?>
33
+ <a class="btn btn-default" href="<?php echo esc_url( admin_url( 'admin.php?page=GrandMedia_WordpressLibrary' ) ); ?>"><?php _e( 'Import from WP Media Library', 'grand-media' ); ?></a>
34
+ <?php } ?>
35
+ </div>
36
+ <?php } ?>
37
+ <div id="total-progress-info" class="progress pull-right">
38
+ <?php $msg = '';
39
+ if ( ! $import ) {
40
+ $msg = __( 'Add files to the upload queue and click the start button', 'grand-media' );
41
+ } else {
42
+ $msg = __( 'Grab files from other sources', 'grand-media' );
43
+ }
44
+ ?>
45
+ <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width:0;">
46
+ <div style="padding: 2px 10px;"><?php echo $msg; ?></div>
47
+ </div>
48
+ <div style="padding: 2px 10px;"><?php echo $msg; ?></div>
49
+ </div>
50
+ <div class="spinner"></div>
51
  </div>
admin/pages/addmedia/tpl/upload.php CHANGED
@@ -7,162 +7,161 @@
7
  * @var $gmCore
8
  */
9
 
10
- // don't load directly
11
  if ( ! defined( 'ABSPATH' ) ) {
12
- die( '-1' );
13
  }
14
 
15
  if ( ! gm_user_can( 'upload' ) ) {
16
- _e( 'You do not have permissions to upload media', 'grand-media' );
17
 
18
- return;
19
  }
20
 
21
- $maxupsize = wp_max_upload_size();
22
- $maxupsize_mb = floor( $maxupsize / 1024 / 1024 );
23
- $maxchunksize = floor( $maxupsize * 0.9 );
24
  $maxchunksize_mb = floor( $maxupsize_mb * 0.9 );
25
 
26
  $screen_options = $gmProcessor->user_options;
27
 
28
- $gm_terms = array();
29
 
30
  ?>
31
  <form class="row" id="gmUpload" name="upload_form" method="POST" accept-charset="utf-8" onsubmit="return false;">
32
- <div class="col-md-4" id="uploader_multipart_params">
33
- <br/>
34
- <?php if ( 'false' == $screen_options['uploader_chunking'] || ( 'html4' == $screen_options['uploader_runtime'] ) ) { ?>
35
- <p class="clearfix text-right"><span class="label label-default"><?php echo __( 'Maximum file size', 'grand-media' ) . ": {$maxupsize_mb}Mb"; ?></span></p>
36
- <?php } else { ?>
37
- <p class="clearfix text-right hidden">
38
- <span class="label label-default"><?php echo __( 'Maximum $_POST size', 'grand-media' ) . ": {$maxupsize_mb}Mb"; ?></span>
39
- <span class="label label-default"><?php echo __( 'Chunk size', 'grand-media' ) . ': ' . min( $maxchunksize_mb, $screen_options['uploader_chunk_size'] ) . 'Mb'; ?></span>
40
- </p>
41
- <?php } ?>
42
 
43
- <div class="form-group">
44
- <label><?php _e( 'Title', 'grand-media' ); ?></label>
45
- <select name="set_title" class="form-control input-sm">
46
- <option value="exif"><?php _e( 'EXIF or File Name', 'grand-media' ); ?></option>
47
- <option value="filename"><?php _e( 'File Name', 'grand-media' ); ?></option>
48
- <option value="empty"><?php _e( 'Empty', 'grand-media' ); ?></option>
49
- </select>
50
- </div>
51
- <div class="form-group">
52
- <label><?php _e( 'Status', 'grand-media' ); ?></label>
53
- <select name="set_status" class="form-control input-sm">
54
- <option value="inherit"><?php _e( 'Same as Album or Public', 'grand-media' ); ?></option>
55
- <option value="publish"><?php _e( 'Public', 'grand-media' ); ?></option>
56
- <option value="private"><?php _e( 'Private', 'grand-media' ); ?></option>
57
- <option value="draft"><?php _e( 'Draft', 'grand-media' ); ?></option>
58
- </select>
59
- </div>
60
 
61
- <hr/>
62
 
63
- <?php include( dirname( __FILE__ ) . '/assign-terms.php' ); ?>
64
 
65
- </div>
66
- <div class="col-md-8" id="pluploadUploader">
67
- <p><?php _e( "You browser doesn't have Flash or HTML5 support. Check also if page have no JavaScript errors.", 'grand-media' ); ?></p>
68
- <?php
69
- $mime_types = get_allowed_mime_types( $user_ID );
70
- $type_ext = array();
71
- $filters = array();
72
- foreach ( $mime_types as $ext => $mime ) {
73
- $type = strtok( $mime, '/' );
74
- $type_ext[ $type ][] = $ext;
75
- }
76
- foreach ( $type_ext as $filter => $ext ) {
77
- $filters[] = array(
78
- 'title' => $filter,
79
- 'extensions' => str_replace( '|', ',', implode( ',', $ext ) )
80
- );
81
- }
82
- ?>
83
- <script type="text/javascript">
84
- // Convert divs to queue widgets when the DOM is ready
85
- jQuery(function($) {
86
- //noinspection JSDuplicatedDeclaration
87
- $("#pluploadUploader").plupload({
88
- <?php if('auto' != $screen_options['uploader_runtime']){ ?>
89
- runtimes: '<?php echo $screen_options['uploader_runtime']; ?>',
90
- <?php } ?>
91
- url: '<?php echo $gmCore->punyencode(admin_url( 'admin-ajax.php' )); ?>',
92
- <?php if(('true' == $screen_options['uploader_urlstream_upload']) && ('html4' != $screen_options['uploader_runtime'])){ ?>
93
- urlstream_upload: true,
94
- multipart: false,
95
- <?php } else{ ?>
96
- multipart: true,
97
- <?php } ?>
98
- multipart_params: {action: 'gmedia_upload_handler', _wpnonce_upload: '<?php echo wp_create_nonce('gmedia_upload'); ?>', params: ''},
99
- <?php if('true' == $screen_options['uploader_chunking'] && ('html4' != $screen_options['uploader_runtime'])){ ?>
100
- max_file_size: '2000Mb',
101
- chunk_size: <?php echo min($maxchunksize, $screen_options['uploader_chunk_size']*1024*1024); ?>,
102
- <?php } else{ ?>
103
- max_file_size: <?php echo $maxupsize; ?>,
104
- <?php } ?>
105
- max_retries: 2,
106
- unique_names: false,
107
- rename: true,
108
- sortable: true,
109
- dragdrop: true,
110
- views: {
111
- list: true,
112
- thumbs: true,
113
- active: 'thumbs'
114
- },
115
- filters: <?php echo json_encode($filters); ?>,
116
- flash_swf_url: '<?php echo $gmCore->punyencode($gmCore->gmedia_url); ?>/assets/plupload/Moxie.swf',
117
- silverlight_xap_url: '<?php echo $gmCore->punyencode($gmCore->gmedia_url); ?>/assets/plupload/Moxie.xap'
118
 
119
- });
120
- var closebtn = '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>';
121
- var uploader = $("#pluploadUploader").plupload('getUploader');
122
- uploader.bind('StateChanged', function(up) {
123
- if(up.state == plupload.STARTED) {
124
- up.settings.multipart_params.params = jQuery('#uploader_multipart_params :input').serialize();
125
- }
126
- //console.log('[StateChanged]', up.state, up.settings.multipart_params);
127
- });
128
- uploader.bind('ChunkUploaded', function(up, file, info) {
129
- //console.log('[ChunkUploaded] File:', file, "Info:", info);
130
- var response = jQuery.parseJSON(info.response);
131
- if(response && response.error) {
132
- up.stop();
133
- file.status = plupload.FAILED;
134
- //jQuery('<div/>').addClass('alert alert-danger alert-dismissable').html(closebtn + '<strong>' + response.id + ':</strong> ' + response.error.message).appendTo('#gmedia-msg-panel');
135
- console.log('[ChunkUploaded] ', response.error);
136
- up.trigger('QueueChanged StateChanged');
137
- up.trigger('UploadProgress', file);
138
- up.start();
139
- }
140
- });
141
- uploader.bind('FileUploaded', function(up, file, info) {
142
- //console.log('[FileUploaded] File:', file, "Info:", info);
143
- var response = jQuery.parseJSON(info.response);
144
- if(response && response.error) {
145
- file.status = plupload.FAILED;
146
- jQuery('<div></div>').addClass('alert alert-danger alert-dismissable').html(closebtn + '<strong>' + response.id + ':</strong> ' + response.error.message).appendTo('#gm-message');
147
- console.log('[FileUploaded] ', response.error);
148
- }
149
- });
150
- uploader.bind('UploadProgress', function(up, file) {
151
- var percent = uploader.total.percent;
152
- $('#total-progress-info .progress-bar').css('width', percent + "%").attr('aria-valuenow', percent);
153
- });
154
- uploader.bind('Error', function(up, args) {
155
- console.log('[Error] ', args);
156
- jQuery('<div></div>').addClass('alert alert-danger alert-dismissable').html(closebtn + '<strong>' + args.file.name + ':</strong> ' + args.message + ' ' + args.status).appendTo('#gm-message');
157
- });
158
- uploader.bind('UploadComplete', function(up, files) {
159
- console.log('[UploadComplete]', files);
160
- $('<div></div>').addClass('alert alert-success alert-dismissable').html(closebtn + "<?php esc_attr_e(__('Upload finished', 'grand-media')); ?>").appendTo('#gm-message');
161
- $('#total-progress-info .progress-bar').css('width', '0').attr('aria-valuenow', '0');
162
- });
163
 
164
- });
165
- </script>
166
- </div>
167
  </form>
168
-
7
  * @var $gmCore
8
  */
9
 
10
+ // don't load directly.
11
  if ( ! defined( 'ABSPATH' ) ) {
12
+ die( '-1' );
13
  }
14
 
15
  if ( ! gm_user_can( 'upload' ) ) {
16
+ _e( 'You do not have permissions to upload media', 'grand-media' );
17
 
18
+ return;
19
  }
20
 
21
+ $maxupsize = wp_max_upload_size();
22
+ $maxupsize_mb = floor( $maxupsize / 1024 / 1024 );
23
+ $maxchunksize = floor( $maxupsize * 0.9 );
24
  $maxchunksize_mb = floor( $maxupsize_mb * 0.9 );
25
 
26
  $screen_options = $gmProcessor->user_options;
27
 
28
+ $gm_terms = [];
29
 
30
  ?>
31
  <form class="row" id="gmUpload" name="upload_form" method="POST" accept-charset="utf-8" onsubmit="return false;">
32
+ <div class="col-md-4" id="uploader_multipart_params">
33
+ <br/>
34
+ <?php if ( 'false' === $screen_options['uploader_chunking'] || ( 'html4' === $screen_options['uploader_runtime'] ) ) { ?>
35
+ <p class="clearfix text-right"><span class="label label-default"><?php echo __( 'Maximum file size', 'grand-media' ) . ": {$maxupsize_mb}Mb"; ?></span></p>
36
+ <?php } else { ?>
37
+ <p class="clearfix text-right hidden">
38
+ <span class="label label-default"><?php echo __( 'Maximum $_POST size', 'grand-media' ) . ": {$maxupsize_mb}Mb"; ?></span>
39
+ <span class="label label-default"><?php echo __( 'Chunk size', 'grand-media' ) . ': ' . min( $maxchunksize_mb, $screen_options['uploader_chunk_size'] ) . 'Mb'; ?></span>
40
+ </p>
41
+ <?php } ?>
42
 
43
+ <div class="form-group">
44
+ <label><?php _e( 'Title', 'grand-media' ); ?></label>
45
+ <select name="set_title" class="form-control input-sm">
46
+ <option value="exif"><?php _e( 'EXIF or File Name', 'grand-media' ); ?></option>
47
+ <option value="filename"><?php _e( 'File Name', 'grand-media' ); ?></option>
48
+ <option value="empty"><?php _e( 'Empty', 'grand-media' ); ?></option>
49
+ </select>
50
+ </div>
51
+ <div class="form-group">
52
+ <label><?php _e( 'Status', 'grand-media' ); ?></label>
53
+ <select name="set_status" class="form-control input-sm">
54
+ <option value="inherit"><?php _e( 'Same as Album or Public', 'grand-media' ); ?></option>
55
+ <option value="publish"><?php _e( 'Public', 'grand-media' ); ?></option>
56
+ <option value="private"><?php _e( 'Private', 'grand-media' ); ?></option>
57
+ <option value="draft"><?php _e( 'Draft', 'grand-media' ); ?></option>
58
+ </select>
59
+ </div>
60
 
61
+ <hr/>
62
 
63
+ <?php include dirname( __FILE__ ) . '/assign-terms.php'; ?>
64
 
65
+ </div>
66
+ <div class="col-md-8" id="pluploadUploader">
67
+ <p><?php _e( "You browser doesn't have Flash or HTML5 support. Check also if page have no JavaScript errors.", 'grand-media' ); ?></p>
68
+ <?php
69
+ $mime_types = get_allowed_mime_types( $user_ID );
70
+ $type_ext = [];
71
+ $filters = [];
72
+ foreach ( $mime_types as $ext => $mime ) {
73
+ $type = strtok( $mime, '/' );
74
+ $type_ext[ $type ][] = $ext;
75
+ }
76
+ foreach ( $type_ext as $filter => $ext ) {
77
+ $filters[] = [
78
+ 'title' => $filter,
79
+ 'extensions' => str_replace( '|', ',', implode( ',', $ext ) ),
80
+ ];
81
+ }
82
+ ?>
83
+ <script type="text/javascript">
84
+ // Convert divs to queue widgets when the DOM is ready
85
+ jQuery(function($) {
86
+ //noinspection JSDuplicatedDeclaration
87
+ $('#pluploadUploader').plupload({
88
+ <?php if('auto' !== $screen_options['uploader_runtime']){ ?>
89
+ runtimes: '<?php echo $screen_options['uploader_runtime']; ?>',
90
+ <?php } ?>
91
+ url: '<?php echo $gmCore->punyencode( admin_url( 'admin-ajax.php' ) ); ?>',
92
+ <?php if(( 'true' === $screen_options['uploader_urlstream_upload'] ) && ( 'html4' !== $screen_options['uploader_runtime'] )){ ?>
93
+ urlstream_upload: true,
94
+ multipart: false,
95
+ <?php } else{ ?>
96
+ multipart: true,
97
+ <?php } ?>
98
+ multipart_params: {action: 'gmedia_upload_handler', _wpnonce_upload: '<?php echo wp_create_nonce( 'gmedia_upload' ); ?>', params: ''},
99
+ <?php if('true' === $screen_options['uploader_chunking'] && ( 'html4' !== $screen_options['uploader_runtime'] )){ ?>
100
+ max_file_size: '2000Mb',
101
+ chunk_size: <?php echo min( $maxchunksize, $screen_options['uploader_chunk_size'] * 1024 * 1024 ); ?>,
102
+ <?php } else{ ?>
103
+ max_file_size: <?php echo $maxupsize; ?>,
104
+ <?php } ?>
105
+ max_retries: 2,
106
+ unique_names: false,
107
+ rename: true,
108
+ sortable: true,
109
+ dragdrop: true,
110
+ views: {
111
+ list: true,
112
+ thumbs: true,
113
+ active: 'thumbs'
114
+ },
115
+ filters: <?php echo wp_json_encode( $filters ); ?>,
116
+ flash_swf_url: '<?php echo $gmCore->punyencode( $gmCore->gmedia_url ); ?>/assets/plupload/Moxie.swf',
117
+ silverlight_xap_url: '<?php echo $gmCore->punyencode( $gmCore->gmedia_url ); ?>/assets/plupload/Moxie.xap'
118
 
119
+ });
120
+ var closebtn = '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>';
121
+ var uploader = $('#pluploadUploader').plupload('getUploader');
122
+ uploader.bind('StateChanged', function(up) {
123
+ if (up.state === plupload.STARTED) {
124
+ up.settings.multipart_params.params = jQuery('#uploader_multipart_params :input').serialize();
125
+ }
126
+ //console.log('[StateChanged]', up.state, up.settings.multipart_params);
127
+ });
128
+ uploader.bind('ChunkUploaded', function(up, file, info) {
129
+ //console.log('[ChunkUploaded] File:', file, "Info:", info);
130
+ var response = jQuery.parseJSON(info.response);
131
+ if (response && response.error) {
132
+ up.stop();
133
+ file.status = plupload.FAILED;
134
+ //jQuery('<div/>').addClass('alert alert-danger alert-dismissable').html(closebtn + '<strong>' + response.id + ':</strong> ' + response.error.message).appendTo('#gmedia-msg-panel');
135
+ console.log('[ChunkUploaded] ', response.error);
136
+ up.trigger('QueueChanged StateChanged');
137
+ up.trigger('UploadProgress', file);
138
+ up.start();
139
+ }
140
+ });
141
+ uploader.bind('FileUploaded', function(up, file, info) {
142
+ //console.log('[FileUploaded] File:', file, "Info:", info);
143
+ var response = jQuery.parseJSON(info.response);
144
+ if (response && response.error) {
145
+ file.status = plupload.FAILED;
146
+ jQuery('<div></div>').addClass('alert alert-danger alert-dismissable').html(closebtn + '<strong>' + response.id + ':</strong> ' + response.error.message).appendTo('#gm-message');
147
+ console.log('[FileUploaded] ', response.error);
148
+ }
149
+ });
150
+ uploader.bind('UploadProgress', function(up, file) {
151
+ var percent = uploader.total.percent;
152
+ $('#total-progress-info .progress-bar').css('width', percent + '%').attr('aria-valuenow', percent);
153
+ });
154
+ uploader.bind('Error', function(up, args) {
155
+ console.log('[Error] ', args);
156
+ jQuery('<div></div>').addClass('alert alert-danger alert-dismissable').html(closebtn + '<strong>' + args.file.name + ':</strong> ' + args.message + ' ' + args.status).appendTo('#gm-message');
157
+ });
158
+ uploader.bind('UploadComplete', function(up, files) {
159
+ console.log('[UploadComplete]', files);
160
+ $('<div></div>').addClass('alert alert-success alert-dismissable').html(closebtn + "<?php esc_attr_e( __( 'Upload finished', 'grand-media' ) ); ?>").appendTo('#gm-message');
161
+ $('#total-progress-info .progress-bar').css('width', '0').attr('aria-valuenow', '0');
162
+ });
163
 
164
+ });
165
+ </script>
166
+ </div>
167
  </form>
 
admin/pages/galleries/edit-gallery.php CHANGED
@@ -3,149 +3,157 @@
3
  * Gmedia Gallery Edit
4
  */
5
 
6
- // don't load directly
7
- if(!defined('ABSPATH')){
8
- die('-1');
9
  }
10
 
11
  global $user_ID, $gmDB, $gmCore, $gmGallery, $gmProcessor;
12
 
13
- $term_id = $gmCore->_get('edit_term');
14
- $gmedia_url = add_query_arg(array('edit_term' => $term_id), $gmProcessor->url);
15
  $gmedia_user_options = $gmProcessor->user_options;
16
  $gmedia_term_taxonomy = $gmProcessor->taxonomy;
17
  $taxterm = $gmProcessor->taxterm;
18
 
19
- if(!gm_user_can("{$taxterm}_manage")){
20
- die('-1');
21
  }
22
 
23
- $term_id = (int)$term_id;
24
- $term = $gmDB->get_term($term_id);
25
 
26
- if(empty($term) || is_wp_error($term)){
27
- $term_id = 0;
28
- $term = new stdClass();
29
  }
30
- gmedia_gallery_more_data($term);
31
 
32
- $gmedia_modules = get_gmedia_modules(false);
33
 
34
- $default_options = array();
35
  $presets = false;
36
- $default_preset = array();
37
- $load_preset = array();
38
- $global_preset = array();
39
 
40
- $gmedia_filter = gmedia_gallery_query_data($term->meta['_query']);
41
 
42
  /**
43
  * @var $module_path
44
  */
45
- if($term->module['name']){
46
- $presets = $gmDB->get_terms('gmedia_module', array('status' => $term->module['name']));
47
- foreach($presets as $i => $preset){
48
- if('[' . $term->module['name'] . ']' == $preset->name){
49
- if(0 === (int)$preset->global){
50
- $global_preset = maybe_unserialize($preset->description);
51
- $global_preset['term_id'] = $preset->term_id;
52
- $global_preset['name'] = $preset->name;
53
- unset($presets[ $i ]);
54
- } elseif($user_ID == $preset->global){
55
- $default_preset = maybe_unserialize($preset->description);
56
- $default_preset['term_id'] = $preset->term_id;
57
- $default_preset['name'] = $preset->name;
58
- unset($presets[ $i ]);
59
- }
60
- }
61
- if((int)$preset->term_id == (int)$gmCore->_get('preset', 0)){
62
- $load_preset = maybe_unserialize($preset->description);
63
- $load_preset['term_id'] = $preset->term_id;
64
- $load_preset['name'] = $preset->name;
65
- }
66
- }
67
-
68
- if(isset($gmedia_modules['in'][ $term->module['name'] ])){
69
- extract($gmedia_modules['in'][ $term->module['name'] ]);
70
-
71
- /**
72
- * @var $module_info
73
- * @var $default_options
74
- * @var $options_tree
75
- */
76
- if(is_file($module_path . '/index.php') && is_file($module_path . '/settings.php')){
77
- /** @noinspection PhpIncludeInspection */
78
- include($module_path . '/index.php');
79
- /** @noinspection PhpIncludeInspection */
80
- include($module_path . '/settings.php');
81
-
82
- if(!empty($global_preset)){
83
- $default_options = $gmCore->array_replace_recursive($default_options, $global_preset);
84
- }
85
- if(!empty($default_preset)){
86
- $default_options = $gmCore->array_replace_recursive($default_options, $default_preset);
87
- }
88
- } else{
89
- $alert[] = sprintf(__('Module `%s` is broken. Choose another module from the list.'), $term->module['name']);
90
- }
91
- } else{
92
- $alert[] = sprintf(__('Can\'t get module with name `%s`. Choose module from the list.'), $term->module['name']);
93
- }
94
- } else{
95
- $alert[] = __('Module is not selected for this gallery. Choose module from the list.');
96
  }
97
 
98
- if(!empty($alert)){
99
- echo $gmCore->alert('danger', $alert);
100
  }
101
 
102
- if(!empty($load_preset)){
103
- $term->meta['_settings'][ $term->module['name'] ] = $gmCore->array_replace_recursive($term->meta['_settings'][ $term->module['name'] ], $load_preset);
104
- echo $gmCore->alert('info', sprintf(__('Preset `%s` loaded. To apply it for current gallery click Save button'), $load_preset['name']));
105
  }
106
- if(!empty($term->meta['_settings'][ $term->module['name'] ])){
107
- $gallery_settings = $gmCore->array_replace_recursive($default_options, $term->meta['_settings'][ $term->module['name'] ]);
108
- } else{
109
- $gallery_settings = $default_options;
110
  }
111
 
112
  /** @noinspection PhpIncludeInspection */
113
- include_once(GMEDIA_ABSPATH . 'inc/module.options.php');
114
 
115
- $reset_settings = $gmCore->array_diff_keyval_recursive($default_options, $gallery_settings, true);
116
 
117
- do_action('gmedia_gallery_before_panel');
 
 
 
 
 
 
 
 
 
118
  ?>
119
 
120
  <div class="panel panel-default panel-fixed-header">
121
 
122
- <?php
123
- include(dirname(__FILE__) . '/tpl/gallery-panel-heading.php');
124
 
125
- include(dirname(__FILE__) . "/tpl/{$taxterm}-edit-item.php");
126
- ?>
127
 
128
  </div>
129
 
130
  <?php
131
- do_action("gmedia_term_{$taxterm}_after_panel", $term);
132
- do_action('gmedia_gallery_after_panel');
133
 
134
- include(dirname(__FILE__) . "/tpl/choose-module.php");
135
- include(GMEDIA_ABSPATH . 'admin/tpl/modal-share.php');
136
  ?>
137
  <div class="modal fade gmedia-modal" id="previewModal" tabindex="-1" role="dialog" aria-hidden="true">
138
- <div class="modal-dialog">
139
- <div class="modal-content">
140
- <div class="modal-header">
141
- <div class="btn-toolbar pull-right" style="margin-top:-4px;">
142
- <button type="button" class="btn btn-primary"><?php _e('Submit', 'grand-media'); ?></button>
143
- <button type="button" class="btn btn-default" data-dismiss="modal"><?php _e('Close', 'grand-media'); ?></button>
144
- </div>
145
- <h4 class="modal-title"></h4>
146
- </div>
147
- <div class="modal-body"></div>
148
- </div>
149
- </div>
150
  </div>
151
-
3
  * Gmedia Gallery Edit
4
  */
5
 
6
+ // don't load directly.
7
+ if ( ! defined( 'ABSPATH' ) ) {
8
+ die( '-1' );
9
  }
10
 
11
  global $user_ID, $gmDB, $gmCore, $gmGallery, $gmProcessor;
12
 
13
+ $term_id = $gmCore->_get( 'edit_term' );
14
+ $gmedia_url = add_query_arg( [ 'edit_term' => $term_id ], $gmProcessor->url );
15
  $gmedia_user_options = $gmProcessor->user_options;
16
  $gmedia_term_taxonomy = $gmProcessor->taxonomy;
17
  $taxterm = $gmProcessor->taxterm;
18
 
19
+ if ( ! gm_user_can( "{$taxterm}_manage" ) ) {
20
+ die( '-1' );
21
  }
22
 
23
+ $term_id = (int) $term_id;
24
+ $term = $gmDB->get_term( $term_id );
25
 
26
+ if ( empty( $term ) || is_wp_error( $term ) ) {
27
+ $term_id = 0;
28
+ $term = new stdClass();
29
  }
30
+ gmedia_gallery_more_data( $term );
31
 
32
+ $gmedia_modules = get_gmedia_modules( false );
33
 
34
+ $default_options = [];
35
  $presets = false;
36
+ $default_preset = [];
37
+ $load_preset = [];
38
+ $global_preset = [];
39
 
40
+ $gmedia_filter = gmedia_gallery_query_data( $term->meta['_query'] );
41
 
42
  /**
43
  * @var $module_path
44
  */
45
+ if ( $term->module['name'] ) {
46
+ $presets = $gmDB->get_terms( 'gmedia_module', [ 'status' => $term->module['name'] ] );
47
+ foreach ( $presets as $i => $preset ) {
48
+ if ( '[' . $term->module['name'] . ']' === $preset->name ) {
49
+ if ( 0 === (int) $preset->global ) {
50
+ $global_preset = maybe_unserialize( $preset->description );
51
+ $global_preset['term_id'] = $preset->term_id;
52
+ $global_preset['name'] = $preset->name;
53
+ unset( $presets[ $i ] );
54
+ } elseif ( $user_ID === $preset->global ) {
55
+ $default_preset = maybe_unserialize( $preset->description );
56
+ $default_preset['term_id'] = $preset->term_id;
57
+ $default_preset['name'] = $preset->name;
58
+ unset( $presets[ $i ] );
59
+ }
60
+ }
61
+ if ( (int) $preset->term_id === (int) $gmCore->_get( 'preset', 0 ) ) {
62
+ $load_preset = maybe_unserialize( $preset->description );
63
+ $load_preset['term_id'] = $preset->term_id;
64
+ $load_preset['name'] = $preset->name;
65
+ }
66
+ }
67
+
68
+ if ( isset( $gmedia_modules['in'][ $term->module['name'] ] ) ) {
69
+ extract( $gmedia_modules['in'][ $term->module['name'] ] );
70
+
71
+ /**
72
+ * @var $module_info
73
+ * @var $default_options
74
+ * @var $options_tree
75
+ */
76
+ if ( is_file( $module_path . '/index.php' ) && is_file( $module_path . '/settings.php' ) ) {
77
+ /** @noinspection PhpIncludeInspection */
78
+ include $module_path . '/index.php';
79
+ /** @noinspection PhpIncludeInspection */
80
+ include $module_path . '/settings.php';
81
+
82
+ if ( ! empty( $global_preset ) ) {
83
+ $default_options = $gmCore->array_replace_recursive( $default_options, $global_preset );
84
+ }
85
+ if ( ! empty( $default_preset ) ) {
86
+ $default_options = $gmCore->array_replace_recursive( $default_options, $default_preset );
87
+ }
88
+ } else {
89
+ $alert[] = sprintf( __( 'Module `%s` is broken. Choose another module from the list.' ), $term->module['name'] );
90
+ }
91
+ } else {
92
+ $alert[] = sprintf( __( 'Can\'t get module with name `%s`. Choose module from the list.' ), $term->module['name'] );
93
+ }
94
+ } else {
95
+ $alert[] = __( 'Module is not selected for this gallery. Choose module from the list.' );
96
  }
97
 
98
+ if ( ! empty( $alert ) ) {
99
+ echo $gmCore->alert( 'danger', $alert );
100
  }
101
 
102
+ if ( ! empty( $load_preset ) ) {
103
+ $term->meta['_settings'][ $term->module['name'] ] = $gmCore->array_replace_recursive( $term->meta['_settings'][ $term->module['name'] ], $load_preset );
104
+ echo $gmCore->alert( 'info', sprintf( __( 'Preset `%s` loaded. To apply it for current gallery click Save button' ), esc_html( $load_preset['name'] ) ) );
105
  }
106
+ if ( ! empty( $term->meta['_settings'][ $term->module['name'] ] ) ) {
107
+ $gallery_settings = $gmCore->array_replace_recursive( $default_options, $term->meta['_settings'][ $term->module['name'] ] );
108
+ } else {
109
+ $gallery_settings = $default_options;
110
  }
111
 
112
  /** @noinspection PhpIncludeInspection */
113
+ include_once GMEDIA_ABSPATH . 'inc/module.options.php';
114
 
115
+ $reset_settings = $gmCore->array_diff_keyval_recursive( $default_options, $gallery_settings, true );
116
 
117
+ do_action( 'gmedia_gallery_before_panel' );
118
+ ?>
119
+
120
+ <?php
121
+ $limitation = empty( $gmGallery->options['license_key'] ) && in_array( $term->module['name'], [ 'amron', 'phantom', 'cubik-lite', 'photomania', 'wp-videoplayer', 'jq-mplayer', 'minima' ], true );
122
+ if ( $limitation ) {
123
+ ?>
124
+ <div style="overflow:hidden; margin-bottom: 6px; padding: 10px; background-color: #fff; border: 1px solid red; border-radius: 5px; font-size: 14px; font-weight: bold;"><?php _e( 'Note: Free version allows you to show maximum 40 images per gallery on the frontend. Purchase license key <a href="https://codeasily.com/gmedia-premium/" target="_blank">here</a>. It\'s a one time payment.', 'grand-media' ); ?></div>
125
+ <?php
126
+ }
127
  ?>
128
 
129
  <div class="panel panel-default panel-fixed-header">
130
 
131
+ <?php
132
+ include dirname( __FILE__ ) . '/tpl/gallery-panel-heading.php';
133
 
134
+ include dirname( __FILE__ ) . "/tpl/{$taxterm}-edit-item.php";
135
+ ?>
136
 
137
  </div>
138
 
139
  <?php
140
+ do_action( "gmedia_term_{$taxterm}_after_panel", $term );
141
+ do_action( 'gmedia_gallery_after_panel' );
142
 
143
+ include dirname( __FILE__ ) . "/tpl/choose-module.php";
144
+ include GMEDIA_ABSPATH . 'admin/tpl/modal-share.php';
145
  ?>
146
  <div class="modal fade gmedia-modal" id="previewModal" tabindex="-1" role="dialog" aria-hidden="true">
147
+ <div class="modal-dialog">
148
+ <div class="modal-content">
149
+ <div class="modal-header">
150
+ <div class="btn-toolbar pull-right" style="margin-top:-4px;">
151
+ <button type="button" class="btn btn-primary"><?php _e( 'Submit', 'grand-media' ); ?></button>
152
+ <button type="button" class="btn btn-default" data-dismiss="modal"><?php _e( 'Close', 'grand-media' ); ?></button>
153
+ </div>
154
+ <h4 class="modal-title"></h4>
155
+ </div>
156
+ <div class="modal-body"></div>
157
+ </div>
158
+ </div>
159
  </div>
 
admin/pages/galleries/functions.php CHANGED
@@ -1,34 +1,34 @@
1
  <?php
2
 
3
- function gmedia_gallery_actions($item) {
4
- global $gmCore, $gmProcessor;
5
 
6
- $actions = array();
7
 
8
- $filter_href = $gmCore->get_admin_url(array('page' => 'GrandMedia', "gallery" => $item->term_id), array(), true);
9
- $filter_class = 'gm_filter_in_lib';
10
- $actions['filter'] = '<a title="' . __('Filter in Gmedia Library', 'grand-media') . '" href="' . $filter_href . '" class="' . $filter_class . '"><span class="glyphicon glyphicon-filter"></span></a>';
11
 
12
- $share_icon = '<span class="glyphicon glyphicon-share"></span>';
13
- if('draft' !== $item->status) {
14
- $actions['share'] = '<a target="_blank" data-target="#shareModal" data-share="' . $item->term_id . '" class="share-modal" title="' . __('Share', 'grand-media') . '" data-gmediacloud="' . $item->cloud_link . '" href="' . $item->post_link . '">' . $share_icon . '</a>';
15
- } else {
16
- $actions['share'] = "<span class='action-inactive'>$share_icon</span>";
17
- }
18
 
19
- $edit_icon = '<span class="glyphicon glyphicon-edit"></span>';
20
- if($item->allow_edit) {
21
- $actions['edit'] = '<a title="' . __('Edit', 'grand-media') . '" href="' . add_query_arg(array("edit_term" => $item->term_id), $gmProcessor->url) . '">' . $edit_icon . '</a>';
22
- } else {
23
- $actions['edit'] = "<span class='action-inactive'>$edit_icon</span>";
24
- }
25
 
26
- $trash_icon = '<span class="glyphicon glyphicon-trash"></span>';
27
- if($item->allow_delete) {
28
- $actions['delete'] = '<a class="trash-icon" title="' . __('Delete', 'grand-media') . '" href="' . wp_nonce_url(add_query_arg(array('do_gmedia_terms' => 'delete', 'ids' => $item->term_id), $gmProcessor->url), 'gmedia_delete', '_wpnonce_delete') . '" data-confirm="' . __("You are about to permanently delete the selected items.\n\r'Cancel' to stop, 'OK' to delete.", "grand-media") . '">' . $trash_icon . '</a>';
29
- } else {
30
- $actions['delete'] = "<span class='action-inactive'>$trash_icon</span>";
31
- }
32
 
33
- return apply_filters('gmedia_gallery_actions', $actions);
34
  }
1
  <?php
2
 
3
+ function gmedia_gallery_actions( $item ) {
4
+ global $gmCore, $gmProcessor;
5
 
6
+ $actions = [];
7
 
8
+ $filter_href = $gmCore->get_admin_url( [ 'page' => 'GrandMedia', "gallery" => $item->term_id ], [], true );
9
+ $filter_class = 'gm_filter_in_lib';
10
+ $actions['filter'] = '<a title="' . __( 'Filter in Gmedia Library', 'grand-media' ) . '" href="' . $filter_href . '" class="' . $filter_class . '"><span class="glyphicon glyphicon-filter"></span></a>';
11
 
12
+ $share_icon = '<span class="glyphicon glyphicon-share"></span>';
13
+ if ( 'draft' !== $item->status ) {
14
+ $actions['share'] = '<a target="_blank" data-target="#shareModal" data-share="' . $item->term_id . '" class="share-modal" title="' . __( 'Share', 'grand-media' ) . '" data-gmediacloud="' . $item->cloud_link . '" href="' . $item->post_link . '">' . $share_icon . '</a>';
15
+ } else {
16
+ $actions['share'] = "<span class='action-inactive'>$share_icon</span>";
17
+ }
18
 
19
+ $edit_icon = '<span class="glyphicon glyphicon-edit"></span>';
20
+ if ( $item->allow_edit ) {
21
+ $actions['edit'] = '<a title="' . __( 'Edit', 'grand-media' ) . '" href="' . add_query_arg( [ "edit_term" => $item->term_id ], $gmProcessor->url ) . '">' . $edit_icon . '</a>';
22
+ } else {
23
+ $actions['edit'] = "<span class='action-inactive'>$edit_icon</span>";
24
+ }
25
 
26
+ $trash_icon = '<span class="glyphicon glyphicon-trash"></span>';
27
+ if ( $item->allow_delete ) {
28
+ $actions['delete'] = '<a class="trash-icon" title="' . __( 'Delete', 'grand-media' ) . '" href="' . wp_nonce_url( add_query_arg( [ 'do_gmedia_terms' => 'delete', 'ids' => $item->term_id ], $gmProcessor->url ), 'gmedia_delete', '_wpnonce_delete' ) . '" data-confirm="' . __( "You are about to permanently delete the selected items.\n\r'Cancel' to stop, 'OK' to delete.", "grand-media" ) . '">' . $trash_icon . '</a>';
29
+ } else {
30
+ $actions['delete'] = "<span class='action-inactive'>$trash_icon</span>";
31
+ }
32
 
33
+ return apply_filters( 'gmedia_gallery_actions', $actions );
34
  }
admin/pages/galleries/galleries.php CHANGED
@@ -3,9 +3,9 @@
3
  * Gmedia Terms
4
  */
5
 
6
- // don't load directly
7
- if(!defined('ABSPATH')) {
8
- die('-1');
9
  }
10
 
11
  global $user_ID, $gmDB, $gmCore, $gmGallery, $gmProcessor;
@@ -14,56 +14,56 @@ $gmedia_url = $gmProcessor->url;
14
  $gmedia_user_options = $gmProcessor->user_options;
15
  $gmedia_term_taxonomy = $gmProcessor->taxonomy;
16
 
17
- $gmedia_terms = $gmDB->get_terms($gmedia_term_taxonomy, $gmProcessor->query_args);
18
  $gmedia_terms_count = $gmDB->count_gmedia();
19
  $gmedia_terms_pager = $gmDB->query_pager();
20
- $gmedia_modules = get_gmedia_modules(false);
21
 
22
  ?>
23
- <div class="panel panel-default panel-fixed-header" id="gmedia-panel">
24
 
25
- <?php
26
- include(dirname(__FILE__) . '/tpl/galleries-panel-heading.php');
27
 
28
- do_action('gmedia_before_galleries_list');
29
- ?>
30
 
31
- <form class="list-group <?php echo $gmedia_term_taxonomy; ?>" id="gm-list-table" style="margin-bottom:4px;">
32
- <?php
33
- $taxterm = $gmProcessor->taxterm;
34
- if(count($gmedia_terms)) {
35
- foreach($gmedia_terms as &$item) {
36
- gmedia_gallery_more_data($item);
37
 
38
- $item->classes = array();
39
- if('publish' != $item->status) {
40
- if('private' == $item->status) {
41
- $item->classes[] = 'list-group-item-info';
42
- } elseif('draft' == $item->status) {
43
- $item->classes[] = 'list-group-item-warning';
44
- }
45
- }
46
- $item->classes[] = $item->global? (($item->global == $user_ID)? 'current_user' : 'other_user') : 'shared';
47
- $item->selected = in_array($item->term_id, (array)$gmProcessor->selected_items);
48
- if($item->selected) {
49
- $item->classes[] = 'gm-selected';
50
- }
51
 
52
- include(dirname(__FILE__) . "/tpl/{$taxterm}-list-item.php");
53
 
54
- }
55
- } else {
56
- include(GMEDIA_ABSPATH . 'admin/pages/terms/tpl/no-items.php');
57
- }
58
- wp_original_referer_field(true, 'previous');
59
- wp_nonce_field('gmedia_terms', '_wpnonce_terms');
60
- ?>
61
- </form>
62
- <?php
63
- do_action('gmedia_after_terms_list');
64
- ?>
65
- </div>
66
 
67
  <?php
68
- include(dirname(__FILE__) . "/tpl/choose-module.php");
69
- include(GMEDIA_ABSPATH . 'admin/tpl/modal-share.php');
3
  * Gmedia Terms
4
  */
5
 
6
+ // don't load directly.
7
+ if ( ! defined( 'ABSPATH' ) ) {
8
+ die( '-1' );
9
  }
10
 
11
  global $user_ID, $gmDB, $gmCore, $gmGallery, $gmProcessor;
14
  $gmedia_user_options = $gmProcessor->user_options;
15
  $gmedia_term_taxonomy = $gmProcessor->taxonomy;
16
 
17
+ $gmedia_terms = $gmDB->get_terms( $gmedia_term_taxonomy, $gmProcessor->query_args );
18
  $gmedia_terms_count = $gmDB->count_gmedia();
19
  $gmedia_terms_pager = $gmDB->query_pager();
20
+ $gmedia_modules = get_gmedia_modules( false );
21
 
22
  ?>
23
+ <div class="panel panel-default panel-fixed-header" id="gmedia-panel">
24
 
25
+ <?php
26
+ include dirname( __FILE__ ) . '/tpl/galleries-panel-heading.php';
27
 
28
+ do_action( 'gmedia_before_galleries_list' );
29
+ ?>
30
 
31
+ <form class="list-group <?php echo $gmedia_term_taxonomy; ?>" id="gm-list-table" style="margin-bottom:4px;">
32
+ <?php
33
+ $taxterm = $gmProcessor->taxterm;
34
+ if ( count( $gmedia_terms ) ) {
35
+ foreach ( $gmedia_terms as &$item ) {
36
+ gmedia_gallery_more_data( $item );
37
 
38
+ $item->classes = [];
39
+ if ( 'publish' !== $item->status ) {
40
+ if ( 'private' === $item->status ) {
41
+ $item->classes[] = 'list-group-item-info';
42
+ } elseif ( 'draft' === $item->status ) {
43
+ $item->classes[] = 'list-group-item-warning';
44
+ }
45
+ }
46
+ $item->classes[] = $item->global ? ( ( $item->global === $user_ID ) ? 'current_user' : 'other_user' ) : 'shared';
47
+ $item->selected = in_array( $item->term_id, (array) $gmProcessor->selected_items, true );
48
+ if ( $item->selected ) {
49
+ $item->classes[] = 'gm-selected';
50
+ }
51
 
52
+ include dirname( __FILE__ ) . "/tpl/{$taxterm}-list-item.php";
53
 
54
+ }
55
+ } else {
56
+ include GMEDIA_ABSPATH . 'admin/pages/terms/tpl/no-items.php';
57
+ }
58
+ wp_original_referer_field( true, 'previous' );
59
+ wp_nonce_field( 'gmedia_terms', '_wpnonce_terms' );
60
+ ?>
61
+ </form>
62
+ <?php
63
+ do_action( 'gmedia_after_terms_list' );
64
+ ?>
65
+ </div>
66
 
67
  <?php
68
+ include dirname( __FILE__ ) . "/tpl/choose-module.php";
69
+ include GMEDIA_ABSPATH . 'admin/tpl/modal-share.php';
admin/pages/galleries/tpl/choose-module.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- // don't load directly
3
- if(!defined('ABSPATH')){
4
- die('-1');
5
  }
6
 
7
  /**
@@ -12,118 +12,118 @@ if(!defined('ABSPATH')){
12
  global $gmCore, $gmDB, $gmGallery;
13
  ?>
14
  <div class="modal fade gmedia-modal" id="chooseModuleModal" tabindex="-1" role="dialog" aria-hidden="true">
15
- <div class="modal-dialog">
16
- <div class="modal-content">
17
- <div class="modal-header">
18
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
19
- <h4 class="modal-title"><?php _e('Choose Module for Gallery', 'grand-media'); ?></h4>
20
- </div>
21
- <div class="modal-body linkblock">
22
- <?php
23
- if(!empty($gmedia_modules['in'])){
24
- foreach($gmedia_modules['in'] as $m){
25
- /**
26
- * @var $module_name
27
- * @var $module_url
28
- * @var $module_path
29
- */
30
- extract($m);
31
- if(!is_file($module_path . '/index.php')){
32
- continue;
33
- }
34
- $module_info = array();
35
- /** @noinspection PhpIncludeInspection */
36
- include($module_path . '/index.php');
37
- if(empty($module_info)){
38
- continue;
39
- }
40
- $mclass = ' module-' . $module_info['type'] . ' module-' . $module_info['status'];
41
- ?>
42
- <div class="choose-module media<?php echo $mclass; ?>">
43
- <a class="thumbnail pull-left" role="button" data-toggle="collapse" href="#collapseDescr_<?php echo $module_name; ?>" aria-expanded="false" aria-controls="collapseDescr_<?php echo $module_name; ?>">
44
- <img class="media-object" src="<?php echo $module_url . '/screenshot.png'; ?>" alt="<?php esc_attr_e($module_info['title']); ?>" width="100"/>
45
- </a>
46
 
47
- <div class="media-body" style="margin-left:180px;">
48
- <h4 class="media-heading"><?php echo $module_info['title']; ?></h4>
49
- <p class="version" style="margin: 6px 0;"><?php echo __('Version', 'grand-media') . ': ' . $module_info['version']; ?></p>
50
- <div class="description collapse" id="collapseDescr_<?php echo $module_name; ?>"><?php echo nl2br($module_info['description']); ?></div>
51
- <div class="action-buttons text-right">
52
- <a href="<?php echo $gmCore->get_admin_url(array('page' => 'GrandMedia_Modules', 'preset_module' => $module_name), array(), admin_url('admin.php')); ?>" class="btn btn-default"><?php _e('Create Preset', 'grand-media'); ?></a>
53
- &nbsp;&nbsp;&nbsp;
54
- <a href="<?php echo add_query_arg(array('gallery_module' => $module_name), $gmedia_url); ?>" class="btn btn-primary"><?php _e('Create Gallery', 'grand-media'); ?></a>
55
- </div>
56
- </div>
57
- </div>
58
- <?php
59
- }
60
- } else{
61
- _e('No installed modules', 'grand-media');
62
- }
63
- ?>
64
- </div>
65
- <div class="modal-footer">
66
- <button type="button" class="btn btn-default" data-dismiss="modal"><?php _e('Cancel', 'grand-media'); ?></button>
67
- </div>
68
- </div>
69
- </div>
70
  </div>
71
 
72
  <div class="modal fade gmedia-modal" id="changeModuleModal" tabindex="-1" role="dialog" aria-hidden="true">
73
- <div class="modal-dialog">
74
- <form class="modal-content" autocomplete="off" method="post" action="<?php echo $gmCore->get_admin_url(array(), array(), $gmedia_url); ?>">
75
- <div class="modal-header">
76
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
77
- <h4 class="modal-title"><?php _e('Change Module/Preset for Galleries', 'grand-media'); ?></h4>
78
- </div>
79
- <div class="modal-body">
80
- <?php
81
- if(!empty($gmedia_modules['in'])){
82
- ?>
83
- <div class="form-group">
84
- <label><?php _e('Change Module/Preset for Galleries', 'grand-media') ?>:</label>
85
- <select class="form-control input-sm" name="gmedia_gallery_module">
86
- <?php
87
- echo '<option value="">' . __('Choose Module/Preset') . '</option>';
88
- foreach($gmedia_modules['in'] as $mfold => $module){
89
- echo '<optgroup label="' . esc_attr($module['title']) . '">';
90
- $presets = $gmDB->get_terms('gmedia_module', array('status' => $mfold));
91
- $option = array();
92
- $option[] = '<option value="' . esc_attr($mfold) . '">' . $module['title'] . ' - ' . __('Default Settings') . '</option>';
93
- foreach($presets as $preset){
94
- if(!(int)$preset->global && '[' . $mfold . ']' === $preset->name){
95
- continue;
96
- }
97
- $by_author = '';
98
- if((int)$preset->global){
99
- $by_author = ' [' . get_the_author_meta('display_name', $preset->global) . ']';
100
- }
101
- if('[' . $mfold . ']' === $preset->name){
102
- $option[] = '<option value="' . $preset->term_id . '">' . $module['title'] . $by_author . ' - ' . __('Default Settings') . '</option>';
103
- } else{
104
- $preset_name = str_replace('[' . $mfold . '] ', '', $preset->name);
105
- $option[] = '<option value="' . $preset->term_id . '">' . $module['title'] . $by_author . ' - ' . $preset_name . '</option>';
106
- }
107
- }
108
- echo implode('', $option);
109
- echo '</optgroup>';
110
- } ?>
111
- </select>
112
 
113
- <p class="help-block"><?php _e('Chosen module will be applied for selected galleries.', 'grand-media'); ?></p>
114
- </div>
115
- <?php
116
- wp_nonce_field( 'gmedia_gallery_module', '_wpnonce_gallery_module' );
117
- wp_referer_field();
118
- } else{
119
- _e('No installed modules', 'grand-media');
120
- }
121
- ?>
122
- </div>
123
- <div class="modal-footer">
124
- <button type="submit" class="btn btn-primary"><?php _e( 'Apply', 'grand-media' ); ?></button>
125
- <button type="button" class="btn btn-default" data-dismiss="modal"><?php _e('Cancel', 'grand-media'); ?></button>
126
- </div>
127
- </form>
128
- </div>
129
- </div>
1
  <?php
2
+ // don't load directly.
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ die( '-1' );
5
  }
6
 
7
  /**
12
  global $gmCore, $gmDB, $gmGallery;
13
  ?>
14
  <div class="modal fade gmedia-modal" id="chooseModuleModal" tabindex="-1" role="dialog" aria-hidden="true">
15
+ <div class="modal-dialog">
16
+ <div class="modal-content">
17
+ <div class="modal-header">
18
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
19
+ <h4 class="modal-title"><?php _e( 'Choose Module for Gallery', 'grand-media' ); ?></h4>
20
+ </div>
21
+ <div class="modal-body linkblock">
22
+ <?php
23
+ if ( ! empty( $gmedia_modules['in'] ) ) {
24
+ foreach ( $gmedia_modules['in'] as $m ) {
25
+ /**
26
+ * @var $module_name
27
+ * @var $module_url
28
+ * @var $module_path
29
+ */
30
+ extract( $m );
31
+ if ( ! is_file( $module_path . '/index.php' ) ) {
32
+ continue;
33
+ }
34
+ $module_info = [];
35
+ /** @noinspection PhpIncludeInspection */
36
+ include $module_path . '/index.php';
37
+ if ( empty( $module_info ) ) {
38
+ continue;
39
+ }
40
+ $mclass = ' module-' . $module_info['type'] . ' module-' . $module_info['status'];
41
+ ?>
42
+ <div class="choose-module media<?php echo $mclass; ?>">
43
+ <a class="thumbnail pull-left" role="button" data-toggle="collapse" href="#collapseDescr_<?php echo $module_name; ?>" aria-expanded="false" aria-controls="collapseDescr_<?php echo $module_name; ?>">
44
+ <img class="media-object" src="<?php echo esc_url( $module_url . '/screenshot.png' ); ?>" alt="<?php echo esc_attr( $module_info['title'] ); ?>" width="100"/>
45
+ </a>
46
 
47
+ <div class="media-body" style="margin-left:180px;">
48
+ <h4 class="media-heading"><?php echo $module_info['title']; ?></h4>
49
+ <p class="version" style="margin: 6px 0;"><?php echo __( 'Version', 'grand-media' ) . ': ' . $module_info['version']; ?></p>
50
+ <div class="description collapse" id="collapseDescr_<?php echo $module_name; ?>"><?php echo nl2br( $module_info['description'] ); ?></div>
51
+ <div class="action-buttons text-right">
52
+ <a href="<?php echo esc_url( $gmCore->get_admin_url( [ 'page' => 'GrandMedia_Modules', 'preset_module' => $module_name ], [], admin_url( 'admin.php' ) ) ); ?>" class="btn btn-default"><?php _e( 'Create Preset', 'grand-media' ); ?></a>
53
+ &nbsp;&nbsp;&nbsp;
54
+ <a href="<?php echo esc_url( add_query_arg( [ 'gallery_module' => $module_name ], $gmedia_url ) ); ?>" class="btn btn-primary"><?php _e( 'Create Gallery', 'grand-media' ); ?></a>
55
+ </div>
56
+ </div>
57
+ </div>
58
+ <?php
59
+ }
60
+ } else {
61
+ _e( 'No installed modules', 'grand-media' );
62
+ }
63
+ ?>
64
+ </div>
65
+ <div class="modal-footer">
66
+ <button type="button" class="btn btn-default" data-dismiss="modal"><?php _e( 'Cancel', 'grand-media' ); ?></button>
67
+ </div>
68
+ </div>
69
+ </div>
70
  </div>
71
 
72
  <div class="modal fade gmedia-modal" id="changeModuleModal" tabindex="-1" role="dialog" aria-hidden="true">
73
+ <div class="modal-dialog">
74
+ <form class="modal-content" autocomplete="off" method="post" action="<?php echo esc_url( $gmCore->get_admin_url( [], [], $gmedia_url ) ); ?>">
75
+ <div class="modal-header">
76
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
77
+ <h4 class="modal-title"><?php _e( 'Change Module/Preset for Galleries', 'grand-media' ); ?></h4>
78
+ </div>
79
+ <div class="modal-body">
80
+ <?php
81
+ if ( ! empty( $gmedia_modules['in'] ) ) {
82
+ ?>
83
+ <div class="form-group">
84
+ <label><?php _e( 'Change Module/Preset for Galleries', 'grand-media' ) ?>:</label>
85
+ <select class="form-control input-sm" name="gmedia_gallery_module">
86
+ <?php
87
+ echo '<option value="">' . __( 'Choose Module/Preset' ) . '</option>';
88
+ foreach ( $gmedia_modules['in'] as $mfold => $module ) {
89
+ echo '<optgroup label="' . esc_attr( $module['title'] ) . '">';
90
+ $presets = $gmDB->get_terms( 'gmedia_module', [ 'status' => $mfold ] );
91
+ $option = [];
92
+ $option[] = '<option value="' . esc_attr( $mfold ) . '">' . esc_html( $module['title'] ) . ' - ' . __( 'Default Settings' ) . '</option>';
93
+ foreach ( $presets as $preset ) {
94
+ if ( ! (int) $preset->global && '[' . $mfold . ']' === $preset->name ) {
95
+ continue;
96
+ }
97
+ $by_author = '';
98
+ if ( (int) $preset->global ) {
99
+ $by_author = ' [' . get_the_author_meta( 'display_name', $preset->global ) . ']';
100
+ }
101
+ if ( '[' . $mfold . ']' === $preset->name ) {
102
+ $option[] = '<option value="' . $preset->term_id . '">' . esc_html( $module['title'] . $by_author ) . ' - ' . __( 'Default Settings' ) . '</option>';
103
+ } else {
104
+ $preset_name = str_replace( '[' . $mfold . '] ', '', $preset->name );
105
+ $option[] = '<option value="' . $preset->term_id . '">' . esc_html( $module['title'] . $by_author . ' - ' . $preset_name ) . '</option>';
106
+ }
107
+ }
108
+ echo implode( '', $option );
109
+ echo '</optgroup>';
110
+ } ?>
111
+ </select>
112
 
113
+ <p class="help-block"><?php _e( 'Chosen module will be applied for selected galleries.', 'grand-media' ); ?></p>
114
+ </div>
115
+ <?php
116
+ wp_nonce_field( 'gmedia_gallery_module', '_wpnonce_gallery_module' );
117
+ wp_referer_field();
118
+ } else {
119
+ _e( 'No installed modules', 'grand-media' );
120
+ }
121
+ ?>
122
+ </div>
123
+ <div class="modal-footer">
124
+ <button type="submit" class="btn btn-primary"><?php _e( 'Apply', 'grand-media' ); ?></button>
125
+ <button type="button" class="btn btn-default" data-dismiss="modal"><?php _e( 'Cancel', 'grand-media' ); ?></button>
126
+ </div>
127
+ </form>
128
+ </div>
129
+ </div>
admin/pages/galleries/tpl/galleries-panel-heading.php CHANGED
@@ -1,11 +1,12 @@
1
  <?php
2
- // don't load directly
3
- if(!defined('ABSPATH')){
4
- die('-1');
5
  }
6
 
7
  /**
8
  * Panel heading for terms
 
9
  * @var $gmedia_term_taxonomy
10
  * @var $gmedia_terms_pager
11
  * @var $gmProcessor
@@ -13,89 +14,88 @@ if(!defined('ABSPATH')){
13
  ?>
14
  <div class="panel-heading-fake"></div>
15
  <div class="panel-heading clearfix" style="padding-bottom:2px;">
16
- <div class="pull-right" style="margin-bottom:3px;">
17
- <div class="clearfix">
18
- <?php include(GMEDIA_ABSPATH . 'admin/tpl/search-form.php'); ?>
19
 
20
- <div class="btn-toolbar pull-right" style="margin-bottom:4px; margin-left:4px;">
21
- <a title="<?php _e('More Screen Settings', 'grand-media'); ?>" class="show-settings-link pull-right btn btn-default btn-xs"><span class="glyphicon glyphicon-cog"></span></a>
22
- </div>
23
- </div>
24
 
25
- <?php echo $gmedia_terms_pager; ?>
26
 
27
- <div class="spinner"></div>
28
- </div>
29
 
30
- <div class="btn-toolbar pull-left" style="margin-bottom:7px;">
31
- <div class="btn-group gm-checkgroup" id="cb_global-btn">
32
- <span class="btn btn-default active"><input class="doaction" id="cb_global"
33
- data-group="cb_object" type="checkbox"/></span>
34
- <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
35
- <span class="caret"></span>
36
- <span class="sr-only"><?php _e('Toggle Dropdown', 'grand-media'); ?></span>
37
- </button>
38
- <ul class="dropdown-menu" role="menu">
39
- <li><a data-select="total" href="#"><?php _e('All', 'grand-media'); ?></a></li>
40
- <li><a data-select="none" href="#"><?php _e('None', 'grand-media'); ?></a></li>
41
- <li class="divider"></li>
42
- <li><a data-select="reverse" href="#" title="<?php _e('Reverse only visible items', 'grand-media'); ?>"><?php _e('Reverse', 'grand-media'); ?></a></li>
43
- </ul>
44
- </div>
45
 
46
- <div class="btn-group" style="margin-right:20px;">
47
- <a class="btn btn-primary" href="#chooseModuleModal" data-toggle="modal"><?php _e('Create Gallery', 'grand-media'); ?></a>
48
- </div>
49
 
50
- <?php if(!empty($gmedia_terms)){ ?>
51
- <div class="btn-group">
52
- <a class="btn btn-default" href="#"><?php _e('Action', 'grand-media'); ?></a>
53
- <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
54
- <span class="caret"></span>
55
- <span class="sr-only"><?php _e('Toggle Dropdown', 'grand-media'); ?></span>
56
- </button>
57
- <?php
58
- $rel_selected_show = 'rel-selected-show';
59
- $rel_selected_hide = 'rel-selected-hide';
60
- ?>
61
- <ul class="dropdown-menu" role="menu">
62
- <li class="dropdown-header <?php echo $rel_selected_hide; ?>"><span><?php _e("Select items to see more actions", "grand-media"); ?></span></li>
63
- <li class="<?php echo $rel_selected_show; ?>">
64
- <a href="#changeModuleModal" data-toggle="modal"><?php _e('Change Module/Preset for Galleries', 'grand-media'); ?></a>
65
- </li>
66
- <li class="<?php echo $rel_selected_show . (gm_user_can('terms_delete')? '' : ' disabled'); ?>">
67
- <a href="<?php echo wp_nonce_url($gmCore->get_admin_url(array('do_gmedia_terms' => 'delete',
68
- 'ids' => 'selected'
69
- ), array('filter')), 'gmedia_delete', '_wpnonce_delete') ?>" class="gmedia-delete" data-confirm="<?php _e("You are about to permanently delete the selected items.\n\r'Cancel' to stop, 'OK' to delete.", "grand-media"); ?>"><?php _e('Delete Selected Items', 'grand-media'); ?></a>
70
- </li>
71
- <?php do_action('gmedia_galleries_action_list'); ?>
72
- </ul>
73
- </div>
 
74
 
75
- <?php
76
- do_action('gmedia_galleries_btn_toolbar');
77
 
78
- $filter_selected = $gmCore->_req('filter');
79
- $filter_selected_arg = $filter_selected? false : 'selected';
80
- ?>
81
- <form class="btn-group" id="gm-selected-btn" name="gm-selected-form" action="<?php echo add_query_arg(array('filter' => $filter_selected_arg), $gmedia_url); ?>" method="post">
82
- <button type="submit" class="btn btn<?php echo ('selected' == $filter_selected)? '-success' : '-info' ?>"><?php printf(__('%s selected', 'grand-media'), '<span id="gm-selected-qty">' . count($gmProcessor->selected_items) . '</span>'); ?></button>
83
- <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown"><span class="caret"></span>
84
- <span class="sr-only"><?php _e('Toggle Dropdown', 'grand-media'); ?></span></button>
85
- <input type="hidden" id="gm-selected" data-userid="<?php echo $user_ID; ?>" data-key="<?php echo GmediaProcessor_Galleries::$cookie_key; ?>" name="selected_items" value="<?php echo implode(',', $gmProcessor->selected_items); ?>"/>
86
- <ul class="dropdown-menu" role="menu">
87
- <li><a id="gm-selected-show" href="#show"><?php
88
- if(!$filter_selected){
89
- _e('Show only selected items', 'grand-media');
90
- } else{
91
- _e('Show all gmedia items', 'grand-media');
92
- }
93
- ?></a></li>
94
- <li><a id="gm-selected-clear" href="#clear"><?php _e('Clear selected items', 'grand-media'); ?></a></li>
95
- </ul>
96
- </form>
97
- <?php } ?>
98
 
99
- </div>
100
  </div>
101
-
1
  <?php
2
+ // don't load directly.
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ die( '-1' );
5
  }
6
 
7
  /**
8
  * Panel heading for terms
9
+ *
10
  * @var $gmedia_term_taxonomy
11
  * @var $gmedia_terms_pager
12
  * @var $gmProcessor
14
  ?>
15
  <div class="panel-heading-fake"></div>
16
  <div class="panel-heading clearfix" style="padding-bottom:2px;">
17
+ <div class="pull-right" style="margin-bottom:3px;">
18
+ <div class="clearfix">
19
+ <?php include GMEDIA_ABSPATH . 'admin/tpl/search-form.php'; ?>
20
 
21
+ <div class="btn-toolbar pull-right" style="margin-bottom:4px; margin-left:4px;">
22
+ <a title="<?php _e( 'More Screen Settings', 'grand-media' ); ?>" class="show-settings-link pull-right btn btn-default btn-xs"><span class="glyphicon glyphicon-cog"></span></a>
23
+ </div>
24
+ </div>
25
 
26
+ <?php echo $gmedia_terms_pager; ?>
27
 
28
+ <div class="spinner"></div>
29
+ </div>
30
 
31
+ <div class="btn-toolbar pull-left" style="margin-bottom:7px;">
32
+ <div class="btn-group gm-checkgroup" id="cb_global-btn">
33
+ <span class="btn btn-default active"><input class="doaction" id="cb_global" data-group="cb_object" type="checkbox"/></span>
34
+ <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
35
+ <span class="caret"></span>
36
+ <span class="sr-only"><?php _e( 'Toggle Dropdown', 'grand-media' ); ?></span>
37
+ </button>
38
+ <ul class="dropdown-menu" role="menu">
39
+ <li><a data-select="total" href="#"><?php _e( 'All', 'grand-media' ); ?></a></li>
40
+ <li><a data-select="none" href="#"><?php _e( 'None', 'grand-media' ); ?></a></li>
41
+ <li class="divider"></li>
42
+ <li><a data-select="reverse" href="#" title="<?php _e( 'Reverse only visible items', 'grand-media' ); ?>"><?php _e( 'Reverse', 'grand-media' ); ?></a></li>
43
+ </ul>
44
+ </div>
 
45
 
46
+ <div class="btn-group" style="margin-right:20px;">
47
+ <a class="btn btn-primary" href="#chooseModuleModal" data-toggle="modal"><?php _e( 'Create Gallery', 'grand-media' ); ?></a>
48
+ </div>
49
 
50
+ <?php if ( ! empty( $gmedia_terms ) ) { ?>
51
+ <div class="btn-group">
52
+ <a class="btn btn-default" href="#"><?php _e( 'Action', 'grand-media' ); ?></a>
53
+ <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
54
+ <span class="caret"></span>
55
+ <span class="sr-only"><?php _e( 'Toggle Dropdown', 'grand-media' ); ?></span>
56
+ </button>
57
+ <?php
58
+ $rel_selected_show = 'rel-selected-show';
59
+ $rel_selected_hide = 'rel-selected-hide';
60
+ ?>
61
+ <ul class="dropdown-menu" role="menu">
62
+ <li class="dropdown-header <?php echo $rel_selected_hide; ?>"><span><?php _e( "Select items to see more actions", "grand-media" ); ?></span></li>
63
+ <li class="<?php echo esc_attr( $rel_selected_show ); ?>">
64
+ <a href="#changeModuleModal" data-toggle="modal"><?php _e( 'Change Module/Preset for Galleries', 'grand-media' ); ?></a>
65
+ </li>
66
+ <li class="<?php echo esc_attr( $rel_selected_show . ( gm_user_can( 'terms_delete' ) ? '' : ' disabled' ) ); ?>">
67
+ <a href="<?php echo esc_url( wp_nonce_url( $gmCore->get_admin_url( [
68
+ 'do_gmedia_terms' => 'delete',
69
+ 'ids' => 'selected',
70
+ ], [ 'filter' ] ), 'gmedia_delete', '_wpnonce_delete' ) ); ?>" class="gmedia-delete" data-confirm="<?php _e( "You are about to permanently delete the selected items.\n\r'Cancel' to stop, 'OK' to delete.", "grand-media" ); ?>"><?php _e( 'Delete Selected Items', 'grand-media' ); ?></a>
71
+ </li>
72
+ <?php do_action( 'gmedia_galleries_action_list' ); ?>
73
+ </ul>
74
+ </div>
75
 
76
+ <?php
77
+ do_action( 'gmedia_galleries_btn_toolbar' );
78
 
79
+ $filter_selected = $gmCore->_req( 'filter' );
80
+ $filter_selected_arg = $filter_selected ? false : 'selected';
81
+ ?>
82
+ <form class="btn-group" id="gm-selected-btn" name="gm-selected-form" action="<?php echo esc_url( add_query_arg( [ 'filter' => $filter_selected_arg ], $gmedia_url ) ); ?>" method="post">
83
+ <button type="submit" class="btn btn<?php echo ( 'selected' == $filter_selected ) ? '-success' : '-info' ?>"><?php printf( __( '%s selected', 'grand-media' ), '<span id="gm-selected-qty">' . count( $gmProcessor->selected_items ) . '</span>' ); ?></button>
84
+ <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown"><span class="caret"></span>
85
+ <span class="sr-only"><?php _e( 'Toggle Dropdown', 'grand-media' ); ?></span></button>
86
+ <input type="hidden" id="gm-selected" data-userid="<?php echo absint( $user_ID ); ?>" data-key="<?php echo esc_attr( GmediaProcessor_Galleries::$cookie_key ); ?>" name="selected_items" value="<?php echo esc_attr( implode( ',', $gmProcessor->selected_items ) ); ?>"/>
87
+ <ul class="dropdown-menu" role="menu">
88
+ <li><a id="gm-selected-show" href="#show"><?php
89
+ if ( ! $filter_selected ) {
90
+ _e( 'Show only selected items', 'grand-media' );
91
+ } else {
92
+ _e( 'Show all gmedia items', 'grand-media' );
93
+ }
94
+ ?></a></li>
95
+ <li><a id="gm-selected-clear" href="#clear"><?php _e( 'Clear selected items', 'grand-media' ); ?></a></li>
96
+ </ul>
97
+ </form>
98
+ <?php } ?>
99
 
100
+ </div>
101
  </div>
 
admin/pages/galleries/tpl/gallery-edit-item.php CHANGED
@@ -1,16 +1,16 @@
1
  <?php
2
- // don't load directly
3
- if(!defined('ABSPATH')){
4
- die('-1');
5
  }
6
 
7
  /**
8
  * Edit Gallery Form
9
  */
10
  ?>
11
- <form method="post" id="gmedia-edit-term" name="gmEditTerm" data-id="<?php echo $term_id; ?>" action="<?php echo $gmedia_url; ?>">
12
- <div class="panel-body">
13
- <!--<h4 style="margin-top:0;">
14
  <?php /*if($term_id) { */ ?>
15
  <span class="pull-right"><?php /*echo __('ID', 'grand-media') . ": {$term->term_id}"; */ ?></span>
16
  <?php /*_e('Edit Gallery'); */ ?>: <em><?php /*echo esc_html($term->name); */ ?></em>
@@ -19,215 +19,218 @@ if(!defined('ABSPATH')){
19
  } */ ?>
20
  </h4>-->
21
 
22
- <div class="row">
23
- <div class="col-sm-8">
24
- <div class="row">
25
- <div class="col-xs-6">
26
- <div class="form-group">
27
- <label><?php _e('Name', 'grand-media'); ?></label>
28
- <input type="text" class="form-control input-sm" name="term[name]" value="<?php esc_attr_e($term->name); ?>" placeholder="<?php _e('Gallery Name', 'grand-media'); ?>" required/>
29
- </div>
30
- <div class="form-group">
31
- <label><?php _e('Slug', 'grand-media'); ?></label>
32
- <input type="text" class="form-control input-sm" name="term[slug]" value="<?php esc_attr_e($term->slug); ?>"/>
33
- </div>
34
- <div class="form-group">
35
- <label><?php _e('Description', 'grand-media'); ?></label>
36
- <?php
37
- wp_editor(esc_textarea($term->description), "gallery{$term->term_id}_description", array('editor_class' => 'form-control input-sm',
38
- 'editor_height' => 120,
39
- 'wpautop' => false,
40
- 'media_buttons' => false,
41
- 'textarea_name' => 'term[description]',
42
- 'textarea_rows' => '4',
43
- 'tinymce' => false,
44
- 'quicktags' => array('buttons' => apply_filters('gmedia_editor_quicktags', 'strong,em,link,ul,li,close'))
45
- ));
46
- ?>
47
- </div>
48
- </div>
49
- <div class="col-xs-6">
50
- <div class="form-group">
51
- <label><?php _e('Author', 'grand-media'); ?></label>
52
- <?php gmedia_term_choose_author_field($term->global); ?>
53
- </div>
54
- <div class="form-group">
55
- <label><?php _e('Status', 'grand-media'); ?></label>
56
- <select name="term[status]" class="form-control input-sm">
57
- <option value="publish"<?php selected($term->status, 'publish'); ?>><?php _e('Public', 'grand-media'); ?></option>
58
- <option value="private"<?php selected($term->status, 'private'); ?>><?php _e('Private', 'grand-media'); ?></option>
59
- <option value="draft"<?php selected($term->status, 'draft'); ?>><?php _e('Draft', 'grand-media'); ?></option>
60
- </select>
61
- </div>
62
- <div class="form-group">
63
- <label><?php _e('Query Args.', 'grand-media'); ?></label>
64
- <textarea class="form-control input-sm" id="build_query_field" style="height:120px;" title="<?php _e("Click 'Build Query' button and choose query arguments for this gallery"); ?>"
65
- placeholder="<?php _e("Click 'Build Query' button for help with Query Args.\nIf you leave this field empty then whole Library will be loaded. That's could exceed your server's PHP Memory Limit.", 'grand-media') ?>"
66
- rows="2" name="term[query]"><?php echo(empty($gmedia_filter['query_args'])? '' : urldecode(build_query($gmedia_filter['query_args']))); ?></textarea>
67
- <p class="help-block text-right"><a id="build_query" class="btn btn-sm btn-success buildquery-modal" href="#buildQuery" style="font-size:90%;"><?php _e('Build Query', 'grand-media'); ?></a></p>
68
- </div>
69
- </div>
70
- </div>
71
- </div>
72
-
73
- <div class="col-sm-4">
74
- <div class="form-group">
75
- <label>&nbsp;
76
- <input type="hidden" name="term[term_id]" value="<?php echo $term_id; ?>"/>
77
- <input type="hidden" name="term[taxonomy]" value="<?php echo $gmedia_term_taxonomy; ?>"/>
78
- <?php
79
- wp_nonce_field('GmediaGallery');
80
- wp_referer_field();
81
- ?>
82
- </label>
83
- <div>
84
- <div class="btn-group btn-group" id="save_buttons">
85
- <?php if($term->module['name'] != $term->meta['_module']){ ?>
86
- <a href="<?php echo $gmedia_url; ?>" class="btn btn-default"><?php _e('Cancel preview module', 'grand-media'); ?></a>
87
- <button type="submit" name="gmedia_gallery_save" class="btn btn-primary"><?php _e('Save with new module', 'grand-media'); ?></button>
88
- <?php } else{ ?>
89
- <?php $reset_settings = $gmCore->array_diff_keyval_recursive($default_options, $gallery_settings, true);
90
- if(!empty($reset_settings)){
91
- ?>
92
- <button type="submit" name="gmedia_gallery_reset" class="btn btn-default" data-confirm="<?php _e('Confirm reset module settings to default preset') ?>"><?php _e('Reset to default', 'grand-media'); ?></button>
93
- <?php } ?>
94
- <button type="submit" name="gmedia_gallery_save" class="btn btn-primary"><?php _e('Save', 'grand-media'); ?></button>
95
- <?php } ?>
96
- </div>
97
- </div>
98
- </div>
99
-
100
- <p><b><?php _e('Gallery ID:'); ?></b> #<?php echo $term_id; ?></p>
101
- <p><b><?php _e('Last edited:'); ?></b> <?php echo $term->meta['_edited']; ?></p>
102
- <p><?php echo '<b>' . __('Gallery module:') . '</b> <a href="#chooseModuleModal" data-toggle="modal" title="' . __('Change module for gallery', 'grand-media') . '">' . $term->meta['_module'] . '</a>';
103
- if($term->module['name'] != $term->meta['_module']){
104
- echo '<br /><b>' . __('Preview module:') . '</b> ' . $term->module['name'];
105
- echo '<br /><span class="text-danger">' . sprintf(__('Note: Module changed to %s, but not saved yet'), $term->module['name']) . '</span>';
106
- } ?></p>
107
- <input type="hidden" name="term[module]" value="<?php esc_attr_e($term->module['name']); ?>">
108
- <?php if($term_id){
109
- $params = array();
110
- if($term->module['name'] != $term->meta['_module']){
111
- $params['gmedia_module'] = $term->module['name'];
112
- }
113
- $params['iframe'] = 1;
114
- ?>
115
- <p><b><?php _e('GmediaCloud page URL for current gallery:'); ?></b>
116
- <br/><a target="_blank" href="<?php echo $term->cloud_link; ?>"><?php echo $term->cloud_link; ?></a>
117
- </p>
118
- <?php if($term->post_link){ ?>
119
- <p><b><?php _e('Gmedia Post URL for current gallery:'); ?></b>
120
- <br/><a target="_blank" href="<?php echo $term->post_link; ?>"><?php echo $term->post_link; ?></a>
121
- </p>
122
- <?php } ?>
123
- <div class="help-block">
124
- <?php _e('update <a href="options-permalink.php">Permalink Settings</a> if above link not working', 'grand-media'); ?>
125
- <?php if(current_user_can('manage_options')){
126
- echo '<br>' . __('More info about GmediaCloud Pages and GmediaCloud Settings can be found <a href="admin.php?page=GrandMedia_Settings#gmedia_settings_cloud">here</a>', 'grand-media');
127
- } ?>
128
- </div>
129
- <?php } ?>
130
- </div>
131
- </div>
132
- <?php
133
- $gmCore->gmedia_custom_meta_box($term->term_id, $meta_type = 'gmedia_term');
134
- do_action('gmedia_term_edit_form');
135
- ?>
136
-
137
- <hr/>
138
- <div class="well well-sm clearfix">
139
- <div class="btn-toolbar pull-right" id="module_preset">
140
- <div class="btn-group">
141
- <button type="button" class="btn btn-default<?php echo ($term->module['name'] != $term->meta['_module'])? ' disabled' : ''; ?>" id="module_presets" data-toggle="popover"><?php _e('Module Presets', 'grand-media'); ?></button>
142
- </div>
143
- <script type="text/html" id="_module_presets">
144
- <div style="padding-top: 5px;">
145
- <?php if(current_user_can('manage_options')){ ?>
146
- <p><button type="button" name="module_preset_save_global" class="ajax-submit btn btn-default btn-sm" style="width:100%"><?php _e('Save as Global Preset', 'grand-media'); ?></button></p>
147
- <?php } ?>
148
- <p style="white-space: nowrap">
149
- <button type="button" name="module_preset_save_default" class="ajax-submit btn btn-default btn-sm"><?php _e('Save as Default', 'grand-media'); ?></button>
150
- &nbsp; <em><?php _e('or', 'grand-media'); ?></em> &nbsp;
151
- <?php if(!empty($default_preset)){ ?>
152
- <button type="button" name="module_preset_restore_original" class="ajax-submit btn btn-default btn-sm"><?php _e('Restore Original', 'grand-media'); ?></button>
153
- <input type="hidden" name="preset_default" value="<?php echo $default_preset['term_id']; ?>"/>
154
- <?php } ?>
155
- </p>
156
- <div class="form-group clearfix" style="border-top: 1px solid #444444; padding-top: 5px;">
157
- <label><?php _e('Save Preset as:', 'grand-media'); ?></label>
158
-
159
- <div class="input-group input-group-sm">
160
- <input type="text" class="form-control input-sm" name="module_preset_name" placeholder="<?php _e('Preset Name', 'grand-media'); ?>" value=""/>
161
- <span class="input-group-btn"><button type="button" name="module_preset_save" class="ajax-submit btn btn-primary"><?php _e('Save', 'grand-media'); ?></button></span>
162
- </div>
163
- </div>
164
-
165
- <?php if(!empty($presets)){ ?>
166
- <ul class="list-group presetlist">
167
- <?php foreach($presets as $preset){
168
- $href = $gmCore->get_admin_url(array('preset' => $preset->term_id), array());
169
-
170
- $count = 1;
171
- $name = trim(str_replace('[' . $term->module['name'] . ']', '', $preset->name, $count));
172
- $by = '';
173
- if(!$name){
174
- if(!(int)$preset->global){
175
- continue;
176
- }
177
- $name = __('Default Settings', 'grand-media');
178
- }
179
- if((int)$preset->global){
180
- $by = ' <small style="white-space:nowrap">[' . get_the_author_meta('display_name', $preset->global) . ']</small>';
181
- }
182
- $li_item = '
 
 
 
183
  <li class="list-group-item" id="gm-preset-' . $preset->term_id . '">';
184
- if($user_ID == $preset->global || ((int)$preset->global && $gmCore->caps['gmedia_edit_others_media']) || current_user_can('manage_options')){
185
- $li_item .= '<span class="delpreset"><span class="label label-danger" data-id="' . $preset->term_id . '">&times;</span></span>';
186
- }
187
- $li_item .= '
188
- <a href="' . $href . '">' . $name . $by . '</a>
189
  </li>';
190
 
191
- $li[] = $li_item;
192
- }
193
- echo implode('', $li);
194
- ?>
195
- </ul>
196
- <?php } ?>
197
- </div>
198
- </script>
199
- </div>
200
-
201
- <h5><?php _e('Module Settings', 'grand-media'); ?></h5>
202
- </div>
203
- <?php
204
- $gallery_link_default = $gmCore->gmcloudlink($term->term_id, $term->taxterm, true);
205
- include(GMEDIA_ABSPATH . 'admin/pages/galleries/tpl/module-settings.php');
206
- ?>
207
- <?php if(!empty($alert)){ ?>
208
- <script type="text/javascript">
209
- jQuery(function($) {
210
- $('#chooseModuleModal').modal('show');
211
- });
212
- </script>
213
- <?php } ?>
214
- </div>
215
 
216
  </form>
217
 
218
  <?php
219
 
220
- include(GMEDIA_ABSPATH . 'admin/pages/galleries/tpl/modal-build-query.php');
221
 
222
- if($term_id){
223
- $customfield_meta_type = 'gmedia_term';
224
- include(GMEDIA_ABSPATH . 'admin/tpl/modal-customfield.php');
225
  }
226
 
227
  ?>
228
 
229
- <?php if(gm_user_can('edit_others_media')){ ?>
230
- <div class="modal fade gmedia-modal" id="gallModal" tabindex="-1" role="dialog" aria-hidden="true">
231
- <div class="modal-dialog"></div>
232
- </div>
233
  <?php } ?>
1
  <?php
2
+ // don't load directly.
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ die( '-1' );
5
  }
6
 
7
  /**
8
  * Edit Gallery Form
9
  */
10
  ?>
11
+ <form method="post" id="gmedia-edit-term" name="gmEditTerm" data-id="<?php echo absint( $term_id ); ?>" action="<?php echo esc_url( $gmedia_url ); ?>">
12
+ <div class="panel-body">
13
+ <!--<h4 style="margin-top:0;">
14
  <?php /*if($term_id) { */ ?>
15
  <span class="pull-right"><?php /*echo __('ID', 'grand-media') . ": {$term->term_id}"; */ ?></span>
16
  <?php /*_e('Edit Gallery'); */ ?>: <em><?php /*echo esc_html($term->name); */ ?></em>
19
  } */ ?>
20
  </h4>-->
21
 
22
+ <div class="row">
23
+ <div class="col-sm-8">
24
+ <div class="row">
25
+ <div class="col-xs-6">
26
+ <div class="form-group">
27
+ <label><?php _e( 'Name', 'grand-media' ); ?></label>
28
+ <input type="text" class="form-control input-sm" name="term[name]" value="<?php echo esc_attr( $term->name ); ?>" placeholder="<?php _e( 'Gallery Name', 'grand-media' ); ?>" required/>
29
+ </div>
30
+ <div class="form-group">
31
+ <label><?php _e( 'Slug', 'grand-media' ); ?></label>
32
+ <input type="text" class="form-control input-sm" name="term[slug]" value="<?php echo esc_attr( $term->slug ); ?>"/>
33
+ </div>
34
+ <div class="form-group">
35
+ <label><?php _e( 'Description', 'grand-media' ); ?></label>
36
+ <?php
37
+ wp_editor( esc_textarea( $term->description ), "gallery{$term->term_id}_description", [
38
+ 'editor_class' => 'form-control input-sm',
39
+ 'editor_height' => 120,
40
+ 'wpautop' => false,
41
+ 'media_buttons' => false,
42
+ 'textarea_name' => 'term[description]',
43
+ 'textarea_rows' => '4',
44
+ 'tinymce' => false,
45
+ 'quicktags' => [ 'buttons' => apply_filters( 'gmedia_editor_quicktags', 'strong,em,link,ul,li,close' ) ],
46
+ ] );
47
+ ?>
48
+ </div>
49
+ </div>
50
+ <div class="col-xs-6">
51
+ <div class="form-group">
52
+ <label><?php _e( 'Author', 'grand-media' ); ?></label>
53
+ <?php gmedia_term_choose_author_field( $term->global ); ?>
54
+ </div>
55
+ <div class="form-group">
56
+ <label><?php _e( 'Status', 'grand-media' ); ?></label>
57
+ <select name="term[status]" class="form-control input-sm">
58
+ <option value="publish"<?php selected( $term->status, 'publish' ); ?>><?php _e( 'Public', 'grand-media' ); ?></option>
59
+ <option value="private"<?php selected( $term->status, 'private' ); ?>><?php _e( 'Private', 'grand-media' ); ?></option>
60
+ <option value="draft"<?php selected( $term->status, 'draft' ); ?>><?php _e( 'Draft', 'grand-media' ); ?></option>
61
+ </select>
62
+ </div>
63
+ <div class="form-group">
64
+ <label><?php _e( 'Query Args.', 'grand-media' ); ?></label>
65
+ <textarea class="form-control input-sm" id="build_query_field" style="height:120px;" title="<?php _e( "Click 'Build Query' button and choose query arguments for this gallery" ); ?>"
66
+ placeholder="<?php _e( "Click 'Build Query' button for help with Query Args.\nIf you leave this field empty then whole Library will be loaded. That's could exceed your server's PHP Memory Limit.", 'grand-media' ) ?>"
67
+ rows="2" name="term[query]"><?php echo( empty( $gmedia_filter['query_args'] ) ? '' : urldecode( build_query( $gmedia_filter['query_args'] ) ) ); ?></textarea>
68
+ <p class="help-block text-right"><a id="build_query" class="btn btn-sm btn-success buildquery-modal" href="#buildQuery" style="font-size:90%;"><?php _e( 'Build Query', 'grand-media' ); ?></a></p>
69
+ </div>
70
+ </div>
71
+ </div>
72
+ </div>
73
+
74
+ <div class="col-sm-4">
75
+ <div class="form-group">
76
+ <label>&nbsp;
77
+ <input type="hidden" name="term[term_id]" value="<?php echo absint( $term_id ); ?>"/>
78
+ <input type="hidden" name="term[taxonomy]" value="<?php echo esc_attr( $gmedia_term_taxonomy ); ?>"/>
79
+ <?php
80
+ wp_nonce_field( 'GmediaGallery' );
81
+ wp_referer_field();
82
+ ?>
83
+ </label>
84
+ <div>
85
+ <div class="btn-group btn-group" id="save_buttons">
86
+ <?php if ( $term->module['name'] !== $term->meta['_module'] ) { ?>
87
+ <a href="<?php echo esc_url( $gmedia_url ); ?>" class="btn btn-default"><?php _e( 'Cancel preview module', 'grand-media' ); ?></a>
88
+ <button type="submit" name="gmedia_gallery_save" class="btn btn-primary"><?php _e( 'Save with new module', 'grand-media' ); ?></button>
89
+ <?php } else { ?>
90
+ <?php $reset_settings = $gmCore->array_diff_keyval_recursive( $default_options, $gallery_settings, true );
91
+ if ( ! empty( $reset_settings ) ) {
92
+ ?>
93
+ <button type="submit" name="gmedia_gallery_reset" class="btn btn-default" data-confirm="<?php _e( 'Confirm reset module settings to default preset' ) ?>"><?php _e( 'Reset to default', 'grand-media' ); ?></button>
94
+ <?php } ?>
95
+ <button type="submit" name="gmedia_gallery_save" class="btn btn-primary"><?php _e( 'Save', 'grand-media' ); ?></button>
96
+ <?php } ?>
97
+ </div>
98
+ </div>
99
+ </div>
100
+
101
+ <p><b><?php _e( 'Gallery ID:' ); ?></b> #<?php echo $term_id; ?></p>
102
+ <p><b><?php _e( 'Last edited:' ); ?></b> <?php echo $term->meta['_edited']; ?></p>
103
+ <p><?php echo '<b>' . __( 'Gallery module:' ) . '</b> <a href="#chooseModuleModal" data-toggle="modal" title="' . __( 'Change module for gallery', 'grand-media' ) . '">' . $term->meta['_module'] . '</a>';
104
+ if ( $term->module['name'] !== $term->meta['_module'] ) {
105
+ echo '<br /><b>' . __( 'Preview module:' ) . '</b> ' . $term->module['name'];
106
+ echo '<br /><span class="text-danger">' . sprintf( __( 'Note: Module changed to %s, but not saved yet' ), $term->module['name'] ) . '</span>';
107
+ } ?></p>
108
+ <input type="hidden" name="term[module]" value="<?php echo esc_attr( $term->module['name'] ); ?>">
109
+ <?php if ( $term_id ) {
110
+ $params = [];
111
+ if ( $term->module['name'] !== $term->meta['_module'] ) {
112
+ $params['gmedia_module'] = $term->module['name'];
113
+ }
114
+ $params['iframe'] = 1;
115
+ ?>
116
+ <p><b><?php _e( 'GmediaCloud page URL for current gallery:' ); ?></b>
117
+ <br/><a target="_blank" href="<?php echo esc_url( $term->cloud_link ); ?>"><?php echo $term->cloud_link; ?></a>
118
+ </p>
119
+ <?php if ( $term->post_link ) { ?>
120
+ <p><b><?php _e( 'Gmedia Post URL for current gallery:' ); ?></b>
121
+ <br/><a target="_blank" href="<?php echo esc_url( $term->post_link ); ?>"><?php echo $term->post_link; ?></a>
122
+ </p>
123
+ <?php } ?>
124
+ <div class="help-block">
125
+ <?php _e( 'update <a href="options-permalink.php">Permalink Settings</a> if above link not working', 'grand-media' ); ?>
126
+ <?php if ( current_user_can( 'manage_options' ) ) {
127
+ echo '<br>' . __( 'More info about GmediaCloud Pages and GmediaCloud Settings can be found <a href="admin.php?page=GrandMedia_Settings#gmedia_settings_cloud">here</a>', 'grand-media' );
128
+ } ?>
129
+ </div>
130
+ <?php } ?>
131
+ </div>
132
+ </div>
133
+ <?php
134
+ $gmCore->gmedia_custom_meta_box( $term->term_id, $meta_type = 'gmedia_term' );
135
+ do_action( 'gmedia_term_edit_form' );
136
+ ?>
137
+
138
+ <hr/>
139
+ <div class="well well-sm clearfix">
140
+ <div class="btn-toolbar pull-right" id="module_preset">
141
+ <div class="btn-group">
142
+ <button type="button" class="btn btn-default<?php echo ( $term->module['name'] !== $term->meta['_module'] ) ? ' disabled' : ''; ?>" id="module_presets" data-toggle="popover"><?php _e( 'Module Presets', 'grand-media' ); ?></button>
143
+ </div>
144
+ <script type="text/html" id="_module_presets">
145
+ <div style="padding-top: 5px;">
146
+ <?php if ( current_user_can( 'manage_options' ) ) { ?>
147
+ <p>
148
+ <button type="button" name="module_preset_save_global" class="ajax-submit btn btn-default btn-sm" style="width:100%"><?php _e( 'Save as Global Preset', 'grand-media' ); ?></button>
149
+ </p>
150
+ <?php } ?>
151
+ <p style="white-space: nowrap">
152
+ <button type="button" name="module_preset_save_default" class="ajax-submit btn btn-default btn-sm"><?php _e( 'Save as Default', 'grand-media' ); ?></button>
153
+ &nbsp; <em><?php _e( 'or', 'grand-media' ); ?></em> &nbsp;
154
+ <?php if ( ! empty( $default_preset ) ) { ?>
155
+ <button type="button" name="module_preset_restore_original" class="ajax-submit btn btn-default btn-sm"><?php _e( 'Restore Original', 'grand-media' ); ?></button>
156
+ <input type="hidden" name="preset_default" value="<?php echo absint( $default_preset['term_id'] ); ?>"/>
157
+ <?php } ?>
158
+ </p>
159
+ <div class="form-group clearfix" style="border-top: 1px solid #444444; padding-top: 5px;">
160
+ <label><?php _e( 'Save Preset as:', 'grand-media' ); ?></label>
161
+
162
+ <div class="input-group input-group-sm">
163
+ <input type="text" class="form-control input-sm" name="module_preset_name" placeholder="<?php _e( 'Preset Name', 'grand-media' ); ?>" value=""/>
164
+ <span class="input-group-btn"><button type="button" name="module_preset_save" class="ajax-submit btn btn-primary"><?php _e( 'Save', 'grand-media' ); ?></button></span>
165
+ </div>
166
+ </div>
167
+
168
+ <?php if ( ! empty( $presets ) ) { ?>
169
+ <ul class="list-group presetlist">
170
+ <?php foreach ( $presets as $preset ) {
171
+ $href = $gmCore->get_admin_url( [ 'preset' => $preset->term_id ], [] );
172
+
173
+ $count = 1;
174
+ $name = trim( str_replace( '[' . $term->module['name'] . ']', '', $preset->name, $count ) );
175
+ $by = '';
176
+ if ( ! $name ) {
177
+ if ( ! (int) $preset->global ) {
178
+ continue;
179
+ }
180
+ $name = __( 'Default Settings', 'grand-media' );
181
+ }
182
+ if ( (int) $preset->global ) {
183
+ $by = ' <small style="white-space:nowrap">[' . esc_html( get_the_author_meta( 'display_name', $preset->global ) ) . ']</small>';
184
+ }
185
+ $li_item = '
186
  <li class="list-group-item" id="gm-preset-' . $preset->term_id . '">';
187
+ if ( $user_ID == $preset->global || ( (int) $preset->global && $gmCore->caps['gmedia_edit_others_media'] ) || current_user_can( 'manage_options' ) ) {
188
+ $li_item .= '<span class="delpreset"><span class="label label-danger" data-id="' . $preset->term_id . '">&times;</span></span>';
189
+ }
190
+ $li_item .= '
191
+ <a href="' . $href . '">' . esc_html( $name ) . $by . '</a>
192
  </li>';
193
 
194
+ $li[] = $li_item;
195
+ }
196
+ echo implode( '', $li );
197
+ ?>
198
+ </ul>
199
+ <?php } ?>
200
+ </div>
201
+ </script>
202
+ </div>
203
+
204
+ <h5><?php _e( 'Module Settings', 'grand-media' ); ?></h5>
205
+ </div>
206
+ <?php
207
+ $gallery_link_default = $gmCore->gmcloudlink( $term->term_id, $term->taxterm, true );
208
+ include GMEDIA_ABSPATH . 'admin/pages/galleries/tpl/module-settings.php';
209
+ ?>
210
+ <?php if ( ! empty( $alert ) ) { ?>
211
+ <script type="text/javascript">
212
+ jQuery(function($) {
213
+ $('#chooseModuleModal').modal('show');
214
+ });
215
+ </script>
216
+ <?php } ?>
217
+ </div>
218
 
219
  </form>
220
 
221
  <?php
222
 
223
+ include GMEDIA_ABSPATH . 'admin/pages/galleries/tpl/modal-build-query.php';
224
 
225
+ if ( $term_id ) {
226
+ $customfield_meta_type = 'gmedia_term';
227
+ include GMEDIA_ABSPATH . 'admin/tpl/modal-customfield.php';
228
  }
229
 
230
  ?>
231
 
232
+ <?php if ( gm_user_can( 'edit_others_media' ) ) { ?>
233
+ <div class="modal fade gmedia-modal" id="gallModal" tabindex="-1" role="dialog" aria-hidden="true">
234
+ <div class="modal-dialog"></div>
235
+ </div>
236
  <?php } ?>
admin/pages/galleries/tpl/gallery-list-item.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- // don't load directly
3
- if(!defined('ABSPATH')) {
4
- die('-1');
5
  }
6
 
7
  /**
@@ -11,81 +11,81 @@ if(!defined('ABSPATH')) {
11
  * @var $gmedia_url
12
  */
13
  ?>
14
- <div class="cb_list-item list-group-item gallery-list-item <?php echo implode(' ', $item->classes); ?>" id="list-item-<?php echo $item->term_id; ?>" data-id="<?php echo $item->term_id; ?>" data-type="<?php echo $item->module['name']; ?>">
15
- <div class="row cb_object">
16
- <div class="col-xs-7">
17
- <label class="cb_media-object cb_media-object-gallery">
18
- <input name="doaction[]" type="checkbox"<?php echo $item->selected ? ' checked="checked"' : ''; ?> data-type="<?php echo $item->module['name']; ?>" value="<?php echo $item->term_id; ?>"/>
19
- </label>
20
 
21
- <div class="media-info-body" style="margin-left:35px;">
22
- <p class="media-title">
23
- <?php if($item->allow_edit) { ?>
24
- <a class="term_name" href="<?php echo add_query_arg(array('edit_term' => $item->term_id), $gmedia_url); ?>"><?php echo esc_html($item->name); ?></a>
25
- <?php } else { ?>
26
- <span class="term_name"><?php echo esc_html($item->name); ?></span>
27
- <?php } ?>
28
- </p>
29
 
30
- <p class="media-meta">
31
- <span class="label label-default"><?php _e('Author', 'grand-media'); ?>:</span> <?php echo $item->global ? $item->author_name : '&#8212;'; ?>
32
- </p>
33
 
34
- <p class="media-caption"><?php echo esc_html(nl2br($item->description)); ?></p>
35
 
36
- <p class="media-meta" title="<?php _e('Shortcode', 'grand-media'); ?>" style="font-weight:bold">
37
- <span class="label label-default"><?php _e('Shortcode', 'grand-media'); ?>:</span> [gmedia id=<?php echo $item->term_id; ?>]
38
- </p>
39
- </div>
40
- </div>
41
- <div class="col-xs-5">
42
- <div class="object-actions gallery-object-actions">
43
- <?php $action_links = gmedia_gallery_actions($item);
44
- echo implode('', $action_links);
45
- ?>
46
- </div>
47
- <p class="media-meta">
48
- <span class="label label-default"><?php _e('Module', 'grand-media'); ?>:</span> <?php echo $item->module['name']; ?>
49
- <?php if (empty($item->module['info'])) { ?>
50
- <span class="bg-danger text-center"><?php _e('Module broken. Reinstall module', 'grand-media') ?></span>
51
- <?php } ?>
52
- <br><span class="label label-default"><?php _e('Last Edited', 'grand-media'); ?>:</span> <?php echo $item->meta['_edited']; ?>
53
- <br><span class="label label-default"><?php _e('Query Args.', 'grand-media'); ?>:</span> <?php echo !empty($item->meta['_query'])? str_replace(',"', ', "', json_encode($item->meta['_query'])) : ''; ?>
54
- <?php
55
- /*
56
- $gallery_tabs = reset($term_meta['_query']);
57
- $tax_tabs = key($term_meta['_query']);
58
- if ('gmedia__in' == $tax_tabs) {
59
- _e('Selected Gmedia', 'grand-media');
60
- $gmedia_ids = wp_parse_id_list($gallery_tabs[0]);
61
- $gal_source = sprintf('<a class="gm_gallery_source selected__in" href="%s">' . __('Show %d items in Gmedia Library', 'grand-media') . '</a>', esc_url(add_query_arg(array('gmedia__in' => implode(',', $gmedia_ids)), $lib_url)), count($gmedia_ids));
62
- echo " ($gal_source)";
63
- } else {
64
- $tabs = $gmDB->get_terms($tax_tabs, array('include' => $gallery_tabs));
65
- $terms_source = array();
66
- if ('gmedia_category' == $tax_tabs) {
67
- _e('Categories', 'grand-media');
68
- foreach ($tabs as $t) {
69
- $terms_source[] = sprintf('<a class="gm_gallery_source gm_category" href="%s">%s</a>', esc_url(add_query_arg(array('cat' => $t->term_id), $lib_url)), esc_html($t->name));
70
- }
71
- } elseif ('gmedia_album' == $tax_tabs) {
72
- _e('Albums', 'grand-media');
73
- foreach ($tabs as $t) {
74
- $terms_source[] = sprintf('<a class="gm_gallery_source gm_album" href="%s">%s</a>', esc_url(add_query_arg(array('alb' => $t->term_id), $lib_url)), esc_html($t->name));
75
- }
76
- } elseif ('gmedia_tag' == $tax_tabs) {
77
- _e('Tags', 'grand-media');
78
- foreach ($tabs as $t) {
79
- $terms_source[] = sprintf('<a class="gm_gallery_source gm_tag" href="%s">%s</a>', esc_url(add_query_arg(array('tag_id' => $t->term_id), $lib_url)), esc_html($t->name));
80
- }
81
- }
82
- if (! empty($terms_source)) {
83
- echo ' (' . join(', ', $terms_source) . ')';
84
- }
85
- }
86
- */
87
- ?>
88
- </p>
89
- </div>
90
- </div>
91
  </div>
1
  <?php
2
+ // don't load directly.
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ die( '-1' );
5
  }
6
 
7
  /**
11
  * @var $gmedia_url
12
  */
13
  ?>
14
+ <div class="cb_list-item list-group-item gallery-list-item <?php echo implode( ' ', $item->classes ); ?>" id="list-item-<?php echo absint( $item->term_id ); ?>" data-id="<?php echo absint( $item->term_id ); ?>" data-type="<?php echo esc_attr( $item->module['name'] ); ?>">
15
+ <div class="row cb_object">
16
+ <div class="col-xs-7">
17
+ <label class="cb_media-object cb_media-object-gallery">
18
+ <input name="doaction[]" type="checkbox"<?php echo $item->selected ? ' checked="checked"' : ''; ?> data-type="<?php echo esc_attr( $item->module['name'] ); ?>" value="<?php echo absint( $item->term_id ); ?>"/>
19
+ </label>
20
 
21
+ <div class="media-info-body" style="margin-left:35px;">
22
+ <p class="media-title">
23
+ <?php if ( $item->allow_edit ) { ?>
24
+ <a class="term_name" href="<?php echo esc_url( add_query_arg( [ 'edit_term' => $item->term_id ], $gmedia_url ) ); ?>"><?php echo esc_html( $item->name ); ?></a>
25
+ <?php } else { ?>
26
+ <span class="term_name"><?php echo esc_html( $item->name ); ?></span>
27
+ <?php } ?>
28
+ </p>
29
 
30
+ <p class="media-meta">
31
+ <span class="label label-default"><?php _e( 'Author', 'grand-media' ); ?>:</span> <?php echo $item->global ? $item->author_name : '&#8212;'; ?>
32
+ </p>
33
 
34
+ <p class="media-caption"><?php echo esc_html( nl2br( $item->description ) ); ?></p>
35
 
36
+ <p class="media-meta" title="<?php _e( 'Shortcode', 'grand-media' ); ?>" style="font-weight:bold">
37
+ <span class="label label-default"><?php _e( 'Shortcode', 'grand-media' ); ?>:</span> [gmedia id=<?php echo absint( $item->term_id ); ?>]
38
+ </p>
39
+ </div>
40
+ </div>
41
+ <div class="col-xs-5">
42
+ <div class="object-actions gallery-object-actions">
43
+ <?php $action_links = gmedia_gallery_actions( $item );
44
+ echo implode( '', $action_links );
45
+ ?>
46
+ </div>
47
+ <p class="media-meta">
48
+ <span class="label label-default"><?php _e( 'Module', 'grand-media' ); ?>:</span> <?php echo $item->module['name']; ?>
49
+ <?php if ( empty( $item->module['info'] ) ) { ?>
50
+ <span class="bg-danger text-center"><?php _e( 'Module broken. Reinstall module', 'grand-media' ) ?></span>
51
+ <?php } ?>
52
+ <br><span class="label label-default"><?php _e( 'Last Edited', 'grand-media' ); ?>:</span> <?php echo $item->meta['_edited']; ?>
53
+ <br><span class="label label-default"><?php _e( 'Query Args.', 'grand-media' ); ?>:</span> <?php echo ! empty( $item->meta['_query'] ) ? str_replace( ',"', ', "', json_encode( $item->meta['_query'] ) ) : ''; ?>
54
+ <?php
55
+ /*
56
+ $gallery_tabs = reset($term_meta['_query']);
57
+ $tax_tabs = key($term_meta['_query']);
58
+ if ('gmedia__in' == $tax_tabs) {
59
+ _e('Selected Gmedia', 'grand-media');
60
+ $gmedia_ids = wp_parse_id_list($gallery_tabs[0]);
61
+ $gal_source = sprintf('<a class="gm_gallery_source selected__in" href="%s">' . __('Show %d items in Gmedia Library', 'grand-media') . '</a>', esc_url(add_query_arg(array('gmedia__in' => implode(',', $gmedia_ids)), $lib_url)), count($gmedia_ids));
62
+ echo " ($gal_source)";
63
+ } else {
64
+ $tabs = $gmDB->get_terms($tax_tabs, array('include' => $gallery_tabs));
65
+ $terms_source = array();
66
+ if ('gmedia_category' == $tax_tabs) {
67
+ _e('Categories', 'grand-media');
68
+ foreach ($tabs as $t) {
69
+ $terms_source[] = sprintf('<a class="gm_gallery_source gm_category" href="%s">%s</a>', esc_url(add_query_arg(array('cat' => $t->term_id), $lib_url)), esc_html($t->name));
70
+ }
71
+ } elseif ('gmedia_album' == $tax_tabs) {
72
+ _e('Albums', 'grand-media');
73
+ foreach ($tabs as $t) {
74
+ $terms_source[] = sprintf('<a class="gm_gallery_source gm_album" href="%s">%s</a>', esc_url(add_query_arg(array('alb' => $t->term_id), $lib_url)), esc_html($t->name));
75
+ }
76
+ } elseif ('gmedia_tag' == $tax_tabs) {
77
+ _e('Tags', 'grand-media');
78
+ foreach ($tabs as $t) {
79
+ $terms_source[] = sprintf('<a class="gm_gallery_source gm_tag" href="%s">%s</a>', esc_url(add_query_arg(array('tag_id' => $t->term_id), $lib_url)), esc_html($t->name));
80
+ }
81
+ }
82
+ if (! empty($terms_source)) {
83
+ echo ' (' . join(', ', $terms_source) . ')';
84
+ }
85
+ }
86
+ */
87
+ ?>
88
+ </p>
89
+ </div>
90
+ </div>
91
  </div>
admin/pages/galleries/tpl/gallery-panel-heading.php CHANGED
@@ -1,64 +1,66 @@
1
  <?php
2
- // don't load directly
3
- if(!defined('ABSPATH')){
4
- die('-1');
5
  }
6
 
7
  /**
8
  * Panel heading for term
 
9
  * @var $term_id
10
  * @var $gmedia_term_taxonomy
11
  * @var $gmProcessor
12
  * @var $gmCore
13
  */
14
- $curpage = $gmCore->_get('page', 'GrandMedia');
15
- $refurl = strpos(wp_get_referer(), "page={$curpage}")? wp_get_referer() : $gmProcessor->url;
16
- $referer = remove_query_arg(array('edit_term', 'gallery_module'), $refurl);
17
  ?>
18
  <div class="panel-heading-fake"></div>
19
  <div class="panel-heading clearfix">
20
- <div class="btn-toolbar pull-left">
21
- <a class="btn btn-default pull-left" style="margin-right:20px;" href="<?php echo $referer; ?>"><?php _e('Go Back', 'grand-media'); ?></a>
22
 
23
- <?php if($term_id){ ?>
24
- <div class="btn-group">
25
- <a class="btn btn-default" href="#"><?php _e('Action', 'grand-media'); ?></a>
26
- <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
27
- <span class="caret"></span>
28
- <span class="sr-only"><?php _e('Toggle Dropdown', 'grand-media'); ?></span>
29
- </button>
30
- <ul class="dropdown-menu" role="menu">
31
- <li><a href="<?php echo add_query_arg(array('page' => 'GrandMedia', 'gallery' => $term->term_id), $gmProcessor->url); ?>"><?php _e('Show in Gmedia Library', 'grand-media'); ?></a></li>
32
- <?php
33
- echo '<li' . (('draft' !== $term->status)? '' : ' class="disabled"') . '><a target="_blank" class="share-modal" data-target="#shareModal" data-share="' . $term->term_id . '" data-gmediacloud="' . $term->cloud_link . '" href="' . $term->post_link . '">' . __('Share', 'grand-media') . '</a></li>';
34
 
35
- echo '<li' . ($term->allow_delete? '' : ' class="disabled"') . '><a href="' . wp_nonce_url(gm_get_admin_url(array('do_gmedia_terms' => 'delete',
36
- 'ids' => $term->term_id
37
- ), array('edit_term'), $gmProcessor->url), 'gmedia_delete', '_wpnonce_delete') . '" data-confirm="' . __("You are about to permanently delete the selected items.\n\r'Cancel' to stop, 'OK' to delete.", "grand-media") . '">' . __('Delete', 'grand-media') . '</a></li>';
38
- ?>
39
- </ul>
40
- </div>
41
- <?php } ?>
42
- <?php if($term_id){ ?>
43
- <div class="term-shortcode pull-left"><input type="text" title="<?php _e('Shortcode'); ?>" class="form-control pull-left" value="<?php echo "[gmedia id={$term_id}]"; ?>" readonly/>
44
- <div class="input-buffer"></div>
45
- </div>
46
- <?php }
47
- do_action('gmedia_gallery_btn_toolbar');
48
- ?>
49
- </div>
 
50
 
51
- <div class="btn-group pull-right" id="save_buttons_duplicate">
52
- <?php if($term->module['name'] != $term->meta['_module']){ ?>
53
- <a href="<?php echo $gmedia_url; ?>" class="btn btn-default"><?php _e('Cancel preview module', 'grand-media'); ?></a>
54
- <button type="button" onclick="jQuery('button[name=gmedia_gallery_save]').trigger('click');" class="btn btn-primary"><?php _e('Save with new module', 'grand-media'); ?></button>
55
- <?php } else{ ?>
56
- <?php if(!empty($reset_settings)){ ?>
57
- <button type="button" onclick="jQuery('button[name=gmedia_gallery_reset]').trigger('click');" class="btn btn-default"><?php _e('Reset to default', 'grand-media'); ?></button>
58
- <?php } ?>
59
- <button type="button" onclick="jQuery('button[name=gmedia_gallery_save]').trigger('click');" class="btn btn-primary"><?php _e('Save', 'grand-media'); ?></button>
60
- <?php } ?>
61
- </div>
62
 
63
- <div class="spinner"></div>
64
  </div>
1
  <?php
2
+ // don't load directly.
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ die( '-1' );
5
  }
6
 
7
  /**
8
  * Panel heading for term
9
+ *
10
  * @var $term_id
11
  * @var $gmedia_term_taxonomy
12
  * @var $gmProcessor
13
  * @var $gmCore
14
  */
15
+ $curpage = $gmCore->_get( 'page', 'GrandMedia' );
16
+ $refurl = strpos( wp_get_referer(), "page={$curpage}" ) ? wp_get_referer() : $gmProcessor->url;
17
+ $referer = remove_query_arg( [ 'edit_term', 'gallery_module' ], $refurl );
18
  ?>
19
  <div class="panel-heading-fake"></div>
20
  <div class="panel-heading clearfix">
21
+ <div class="btn-toolbar pull-left">
22
+ <a class="btn btn-default pull-left" style="margin-right:20px;" href="<?php echo esc_url( $referer ); ?>"><?php _e( 'Go Back', 'grand-media' ); ?></a>
23
 
24
+ <?php if ( $term_id ) { ?>
25
+ <div class="btn-group">
26
+ <a class="btn btn-default" href="#"><?php _e( 'Action', 'grand-media' ); ?></a>
27
+ <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
28
+ <span class="caret"></span>
29
+ <span class="sr-only"><?php _e( 'Toggle Dropdown', 'grand-media' ); ?></span>
30
+ </button>
31
+ <ul class="dropdown-menu" role="menu">
32
+ <li><a href="<?php echo esc_url( add_query_arg( [ 'page' => 'GrandMedia', 'gallery' => $term->term_id ], $gmProcessor->url ) ); ?>"><?php _e( 'Show in Gmedia Library', 'grand-media' ); ?></a></li>
33
+ <?php
34
+ echo '<li' . ( ( 'draft' !== $term->status ) ? '' : ' class="disabled"' ) . '><a target="_blank" class="share-modal" data-target="#shareModal" data-share="' . $term->term_id . '" data-gmediacloud="' . $term->cloud_link . '" href="' . $term->post_link . '">' . __( 'Share', 'grand-media' ) . '</a></li>';
35
 
36
+ echo '<li' . ( $term->allow_delete ? '' : ' class="disabled"' ) . '><a href="' . wp_nonce_url( gm_get_admin_url( [
37
+ 'do_gmedia_terms' => 'delete',
38
+ 'ids' => $term->term_id,
39
+ ], [ 'edit_term' ], $gmProcessor->url ), 'gmedia_delete', '_wpnonce_delete' ) . '" data-confirm="' . __( "You are about to permanently delete the selected items.\n\r'Cancel' to stop, 'OK' to delete.", "grand-media" ) . '">' . __( 'Delete', 'grand-media' ) . '</a></li>';
40
+ ?>
41
+ </ul>
42
+ </div>
43
+ <?php } ?>
44
+ <?php if ( $term_id ) { ?>
45
+ <div class="term-shortcode pull-left"><input type="text" title="<?php _e( 'Shortcode' ); ?>" class="form-control pull-left" value="<?php echo esc_attr( '[gmedia id=' . absint( $term_id ) . ']' ); ?>" readonly/>
46
+ <div class="input-buffer"></div>
47
+ </div>
48
+ <?php }
49
+ do_action( 'gmedia_gallery_btn_toolbar' );
50
+ ?>
51
+ </div>
52
 
53
+ <div class="btn-group pull-right" id="save_buttons_duplicate">
54
+ <?php if ( $term->module['name'] !== $term->meta['_module'] ) { ?>
55
+ <a href="<?php echo esc_url( $gmedia_url ); ?>" class="btn btn-default"><?php _e( 'Cancel preview module', 'grand-media' ); ?></a>
56
+ <button type="button" onclick="jQuery('button[name=gmedia_gallery_save]').trigger('click');" class="btn btn-primary"><?php _e( 'Save with new module', 'grand-media' ); ?></button>
57
+ <?php } else { ?>
58
+ <?php if ( ! empty( $reset_settings ) ) { ?>
59
+ <button type="button" onclick="jQuery('button[name=gmedia_gallery_reset]').trigger('click');" class="btn btn-default"><?php _e( 'Reset to default', 'grand-media' ); ?></button>
60
+ <?php } ?>
61
+ <button type="button" onclick="jQuery('button[name=gmedia_gallery_save]').trigger('click');" class="btn btn-primary"><?php _e( 'Save', 'grand-media' ); ?></button>
62
+ <?php } ?>
63
+ </div>
64
 
65
+ <div class="spinner"></div>
66
  </div>
admin/pages/galleries/tpl/modal-build-query.php CHANGED
@@ -1,11 +1,12 @@
1
  <?php
2
- // don't load directly
3
- if(!defined('ABSPATH')) {
4
- die('-1');
5
  }
6
 
7
  /**
8
  * Modal for Build Query
 
9
  * @var $gm_album_terms
10
  * @var $gm_category_terms
11
  * @var $gm_tag_terms
@@ -16,75 +17,75 @@ global $user_ID, $gmDB, $gmCore
16
  <div class="modal-dialog" style="width:700px;">
17
  <div class="modal-content">
18
  <div class="modal-header">
19
- <div class="pull-right" style="margin-top:-4px;">
20
- <button type="button" class="btn btn-default buildqueryreset"><?php _e('Reset', 'grand-media'); ?></button>
21
- <button type="button" class="btn btn-primary buildquerysubmit"><?php _e('Build Query', 'grand-media'); ?></button>
22
- <button type="button" class="btn btn-default" data-dismiss="modal"><?php _e('Close', 'grand-media'); ?></button>
23
- </div>
24
- <h4 class="modal-title"><?php _e('Query Parameters'); ?></h4>
25
  </div>
26
  <div class="modal-body">
27
 
28
  <?php
29
  $query_data = $gmedia_filter['query_data'];
30
- if(gm_user_can('terms')) { ?>
31
  <div class="form-group">
32
  <?php
33
  $term_type = 'gmedia_album';
34
- $args = array();
35
- if(gm_user_can('edit_others_media')) {
36
  $args['global'] = '';
37
  } else {
38
- $args['global'] = array(0, $user_ID);
39
  }
40
- $gm_album_terms = $gmDB->get_terms($term_type, $args);
41
 
42
- $no_term = array(
43
  'term_id' => 0,
44
- 'name' => __('No Album', 'grand-media'),
45
- );
46
- if(count($gm_album_terms)) {
47
- foreach($gm_album_terms as &$_term) {
48
- unset($_term->description);
49
- unset($_term->taxonomy);
50
- $_term->by_author = $_term->global? sprintf(__('by %s', 'grand-media'), get_the_author_meta('display_name', $_term->global)) : '';
51
- /* ('publish' == $_term->status? '' : " [{$_term->status}]") . ' &nbsp; (' . $_term->count . ')';*/
52
  }
53
  }
54
- $gm_album_terms = array_merge(array($no_term), $gm_album_terms);
55
- $query_gmedia_albums = array();
56
  $exclude_albums = false;
57
- if(!empty($query_data['album__in']) || (is_string($query_data['album__in']) && '0' === $query_data['album__in'])) {
58
- $query_gmedia_albums = wp_parse_id_list($query_data['album__in']);
59
- } elseif(!empty($query_data['album__not_in']) || (is_string($query_data['album__not_in']) && '0' === $query_data['album__not_in'])) {
60
- $query_gmedia_albums = wp_parse_id_list($query_data['album__not_in']);
61
  $exclude_albums = true;
62
  }
63
  ?>
64
- <label><?php _e('Albums', 'grand-media'); ?> </label>
65
 
66
  <div class="row">
67
  <div class="col-xs-8">
68
- <input id="query_album__" name="album__in" data-include="album__in" data-exclude="album__not_in" class="form-control gm-selectize input-sm" value="<?php echo implode(',', $query_gmedia_albums) ?>" placeholder="<?php esc_attr_e(__('Any Album...', 'grand-media')); ?>"/>
69
  </div>
70
  <div class="col-xs-4">
71
- <div class="checkbox"><label><input class="query_switch" data-target="query_album__" type="checkbox"<?php echo $exclude_albums? ' checked="checked"' : ''; ?> /> <?php _e('Exclude selected Albums', 'grand-media'); ?></label></div>
72
  </div>
73
  </div>
74
  <div class="row">
75
  <div class="col-xs-8">
76
- <?php _e('To show all albums just select `No Album` in dropdown above then tick `Exclude selected Albums`, so it exclude all images without Album and show other images.', 'grand-media'); ?>
77
  </div>
78
  <div class="col-xs-4">
79
- <label><?php _e('Albums Order', 'grand-media'); ?> </label>
80
  <select name="albums_order" class="form-control input-sm">
81
- <option <?php selected($query_data['albums_order'], ''); ?> value=""><?php _e('No Order'); ?></option>
82
- <option <?php selected($query_data['albums_order'], 'id'); ?> value="id"><?php _e('By ID (ASC)'); ?></option>
83
- <option <?php selected($query_data['albums_order'], 'id_desc'); ?> value="desc"><?php _e('By ID (DESC)'); ?></option>
84
- <option <?php selected($query_data['albums_order'], 'name'); ?> value="name"><?php _e('By Name (ASC)'); ?></option>
85
- <option <?php selected($query_data['albums_order'], 'name_desc'); ?> value="name_desc"><?php _e('By Name (DESC)'); ?></option>
86
- <option <?php selected($query_data['albums_order'], 'date'); ?> value="date"><?php _e('By Date (ASC)'); ?></option>
87
- <option <?php selected($query_data['albums_order'], 'date_desc'); ?> value="date_desc"><?php _e('By Date (DESC)'); ?></option>
88
  </select>
89
  </div>
90
  </div>
@@ -93,26 +94,26 @@ global $user_ID, $gmDB, $gmCore
93
  <div class="form-group">
94
  <?php
95
  $term_type = 'gmedia_category';
96
- $gm_category_terms = $gmDB->get_terms($term_type, array('fields' => 'names_count'));
97
 
98
- $no_term = array(
99
  'term_id' => 0,
100
- 'name' => __('Uncategorized', 'grand-media'),
101
- );
102
- $gm_category_terms = array_merge(array($no_term), $gm_category_terms);
103
  ?>
104
  <div class="row">
105
  <div class="col-xs-4">
106
- <label><?php _e('[IN] Categories', 'grand-media'); ?></label>
107
- <input name="category__in" class="form-control input-sm gm-selectize combobox_gmedia_category" value="<?php echo implode(',', wp_parse_id_list($query_data['category__in'])); ?>" placeholder="<?php esc_attr_e(__('Either of chosen Categories...', 'grand-media')); ?>"/>
108
  </div>
109
  <div class="col-xs-4">
110
- <label><?php _e('[AND] Categories', 'grand-media'); ?></label>
111
- <input name="category__and" class="form-control input-sm gm-selectize combobox_gmedia_category" value="<?php echo implode(',', wp_parse_id_list($query_data['category__and'])); ?>" placeholder="<?php esc_attr_e(__('Have all chosen Categories...', 'grand-media')); ?>"/>
112
  </div>
113
  <div class="col-xs-4">
114
- <label><?php _e('[NOT IN] Categories', 'grand-media'); ?></label>
115
- <input name="category__not_in" class="form-control input-sm gm-selectize combobox_gmedia_category" value="<?php echo implode(',', wp_parse_id_list($query_data['category__not_in'])); ?>" placeholder="<?php esc_attr_e(__('Exclude Categories...', 'grand-media')); ?>"/>
116
  </div>
117
  </div>
118
  </div>
@@ -120,50 +121,50 @@ global $user_ID, $gmDB, $gmCore
120
  <div class="form-group">
121
  <?php
122
  $term_type = 'gmedia_tag';
123
- $gm_tag_terms = $gmDB->get_terms($term_type, array('fields' => 'names_count'));
124
  ?>
125
  <div class="row">
126
  <div class="col-xs-4">
127
- <label><?php _e('[IN] Tags', 'grand-media'); ?> </label>
128
- <input name="tag__in" class="form-control input-sm gm-selectize combobox_gmedia_tag" value="<?php echo implode(',', wp_parse_id_list($query_data['tag__in'])); ?>" placeholder="<?php esc_attr_e(__('Either of chosen Tags...', 'grand-media')); ?>"/>
129
  </div>
130
  <div class="col-xs-4">
131
- <label><?php _e('[AND] Tags', 'grand-media'); ?> </label>
132
- <input name="tag__and" class="form-control input-sm gm-selectize combobox_gmedia_tag" value="<?php echo implode(',', wp_parse_id_list($query_data['tag__and'])); ?>" placeholder="<?php esc_attr_e(__('Have all chosen Tags...', 'grand-media')); ?>"/>
133
  </div>
134
  <div class="col-xs-4">
135
- <label><?php _e('[NOT IN] Tags', 'grand-media'); ?> </label>
136
- <input name="tag__not_in" class="form-control input-sm gm-selectize combobox_gmedia_tag" value="<?php echo implode(',', wp_parse_id_list($query_data['tag__not_in'])); ?>" placeholder="<?php esc_attr_e(__('Exclude Tags...', 'grand-media')); ?>"/>
137
  </div>
138
  </div>
139
  </div>
140
 
141
  <?php } ?>
142
  <div class="form-group">
143
- <label><?php _e('Terms Relation', 'grand-media'); ?> </label>
144
 
145
  <div class="row">
146
  <div class="col-xs-4">
147
  <select name="terms_relation" class="form-control input-sm">
148
- <option <?php selected($query_data['terms_relation'], ''); ?> value=""><?php _e('Default (OR)'); ?></option>
149
- <option <?php selected($query_data['terms_relation'], 'AND'); ?> value="AND"><?php _e('AND'); ?></option>
150
- <option <?php selected($query_data['terms_relation'], 'OR'); ?> value="OR"><?php _e('OR'); ?></option>
151
  </select>
152
  </div>
153
  <div class="col-xs-8">
154
- <p class="help-block"><?php _e('allows you to describe the relationship between the taxonomy queries', 'grand-media'); ?></p>
155
  </div>
156
  </div>
157
  </div>
158
  <div class="form-group">
159
- <label><?php _e('Search', 'grand-media'); ?></label>
160
 
161
  <div class="row">
162
  <div class="col-xs-8">
163
- <input type="text" class="form-control input-sm" placeholder="<?php _e('Search string or terms separated by comma', 'grand-media'); ?>" value="<?php echo $query_data['s']; ?>" name="s">
164
  </div>
165
  <div class="col-xs-4">
166
- <div class="checkbox"><label><input type="checkbox" name="exact" value="yes"<?php echo $query_data['exact']? ' checked="checked"' : ''; ?> /> <?php _e('Search exactly string', 'grand-media'); ?></label></div>
167
  </div>
168
  </div>
169
  </div>
@@ -171,82 +172,83 @@ global $user_ID, $gmDB, $gmCore
171
  <div class="row">
172
  <div class="col-xs-8">
173
  <div class="pull-right">
174
- <a id="_use_lib_selected" title="<?php _e('Select Media', 'grand-media'); ?>" href="<?php echo $gmCore->get_admin_url(array('page' => 'GrandMedia',
175
- 'mode' => 'select_multiple',
176
- 'gmediablank' => 'library'
177
- ), array(), true); ?>" class="label label-primary preview-modal" data-target="#previewModal" data-width="1200" data-height="500" data-cls="select_gmedia"><?php _e('Select in Library', 'grand-media'); ?></a>
178
- </div>
179
- <label><?php _e('Gmedia IDs <small class="text-muted">separated by comma</small>', 'grand-media'); ?> </label>
 
180
  </div>
181
  </div>
182
  <div class="row">
183
  <div class="col-xs-8">
184
- <?php $query_gmedia_items = array();
185
- if(!empty($query_data['gmedia__in'])) {
186
  $query_gmedia_items = $query_data['gmedia__in'];
187
- } elseif(!empty($query_data['gmedia__not_in'])) {
188
  $query_gmedia_items = $query_data['gmedia__not_in'];
189
  }
190
  ?>
191
- <textarea id="query_gmedia__" name="gmedia__in" data-include="gmedia__in" data-exclude="gmedia__not_in" rows="1" class="form-control input-sm" style="resize:vertical;" placeholder="<?php esc_attr_e(__('Gmedia IDs...', 'grand-media')); ?>"><?php echo implode(',', wp_parse_id_list($query_gmedia_items)); ?></textarea>
192
  </div>
193
  <div class="col-xs-4">
194
- <div class="checkbox"><label><input class="query_switch" data-target="query_gmedia__" type="checkbox"<?php echo (empty($query_data['gmedia__in']) && !empty($query_data['gmedia__not_in']))? ' checked="checked"' : ''; ?> /> <?php _e('Exclude selected Items', 'grand-media'); ?></label></div>
195
  </div>
196
  </div>
197
- <p class="help-block"><?php _e('You can select items you want to add here right in Gmedia Library and then return here and click button "Use selected in Library"', 'grand-media'); ?></p>
198
  </div>
199
  <div class="form-group">
200
  <div class="row">
201
  <div class="col-xs-4">
202
- <label><?php _e('Mime Type', 'grand-media'); ?> </label>
203
  <?php
204
- $mime_types = array(
205
- array('value' => 'image', 'text' => 'Image'),
206
- array('value' => 'audio', 'text' => 'Audio'),
207
- array('value' => 'video', 'text' => 'Video'),
208
- array('value' => 'text', 'text' => 'Text'),
209
- array('value' => 'application', 'text' => 'Application'),
210
- );
211
- $mime_type_val = is_array($query_data['mime_type'])? implode(',', $query_data['mime_type']) : str_replace(', ', ',', $query_data['mime_type']);
212
  ?>
213
- <input name="mime_type" class="form-control input-sm gm-selectize gmedia-combobox" data-options='<?php echo json_encode($mime_types); ?>' value="<?php esc_attr_e($mime_type_val); ?>" placeholder="<?php esc_attr_e(__('All types...', 'grand-media')); ?>"/>
214
  </div>
215
  <div class="col-xs-4">
216
- <label><?php _e('Authors', 'grand-media'); ?></label>
217
- <?php if(gm_user_can('show_others_media')) {
218
  $user_ids = $gmCore->get_editable_user_ids();
219
- if(!in_array($user_ID, $user_ids)) {
220
- array_push($user_ids, $user_ID);
221
  }
222
- $filter_users = get_users(array('include' => $user_ids));
223
  $users = '';
224
- $_users = array();
225
- if(count($filter_users)) {
226
- $author__in = wp_parse_id_list($query_data['author__in']);
227
- foreach((array)$filter_users as $user) {
228
- $user->ID = (int)$user->ID;
229
- $_selected = in_array($user->ID, $author__in)? ' selected="selected"' : '';
230
- $users .= "<option value='{$user->ID}'{$_selected}>" . esc_html($user->display_name) . "</option>";
231
- $_users[] = array('value' => $user->ID, 'text' => esc_html($user->display_name));
232
  }
233
  }
234
- $query_authors = array();
235
- if(!empty($query_data['author__in'])) {
236
  $query_authors = $query_data['author__in'];
237
- } elseif(!empty($query_data['author__not_in'])) {
238
  $query_authors = $query_data['author__not_in'];
239
  }
240
  ?>
241
- <input id="query_author__" name="author__in" data-include="author__in" data-exclude="author__not_in" class="form-control input-sm gm-selectize gmedia-combobox" data-options='<?php echo str_replace("'", "\'", json_encode($_users)); ?>' value="<?php echo implode(',', wp_parse_id_list($query_authors)); ?>" placeholder="<?php esc_attr_e(__('All authors...', 'grand-media')); ?>"/>
242
  <?php } else { ?>
243
- <input type="text" readonly="readonly" name="author__in" class="form-control input-sm" value="<?php the_author_meta('display_name', $user_ID); ?>"/>
244
  <?php } ?>
245
  </div>
246
- <?php if(gm_user_can('show_others_media')) { ?>
247
  <div class="col-xs-4">
248
  <label>&nbsp;</label>
249
- <div class="checkbox"><label><input class="query_switch" data-target="query_author__" type="checkbox"<?php echo (empty($query_data['author__in']) && !empty($query_data['author__not_in']))? ' checked="checked"' : ''; ?> /> <?php _e('Exclude Authors', 'grand-media'); ?></label></div>
250
  </div>
251
  <?php } ?>
252
  </div>
@@ -254,73 +256,73 @@ global $user_ID, $gmDB, $gmCore
254
  <div class="form-group">
255
  <div class="row">
256
  <div class="col-xs-4">
257
- <label><?php _e('Year', 'grand-media'); ?></label>
258
- <input type="text" class="form-control input-sm" placeholder="<?php _e('4 digit year e.g. 2011', 'grand-media'); ?>" value="<?php echo $query_data['year']; ?>" name="year">
259
  </div>
260
  <div class="col-xs-4">
261
- <label><?php _e('Month', 'grand-media'); ?></label>
262
- <input type="text" class="form-control input-sm" placeholder="<?php _e('from 1 to 12', 'grand-media'); ?>" value="<?php echo $query_data['monthnum']; ?>" name="monthnum">
263
  </div>
264
  <div class="col-xs-4">
265
- <label><?php _e('Day', 'grand-media'); ?></label>
266
- <input type="text" class="form-control input-sm" placeholder="<?php _e('from 1 to 31', 'grand-media'); ?>" value="<?php echo $query_data['day']; ?>" name="day">
267
  </div>
268
  </div>
269
  </div>
270
  <div class="form-group">
271
- <?php foreach($query_data['meta_query'] as $i => $q) {
272
- if($i) {
273
  continue;
274
  }
275
  ?>
276
  <div class="row">
277
  <div class="col-xs-6 col-sm-3">
278
- <label><?php _e('Custom Field Key', 'grand-media'); ?></label>
279
- <input type="text" class="form-control input-sm" value="<?php echo $q['key']; ?>" name="meta_query[<?php echo $i; ?>][key]">
280
- <span class="help-block"><?php _e('Display items with this field key', 'grand-media'); ?></span>
281
  </div>
282
  <div class="col-xs-6 col-sm-3">
283
- <label><?php _e('Custom Field Value', 'grand-media'); ?></label>
284
- <input type="text" class="form-control input-sm" value="<?php echo $q['value']; ?>" name="meta_query[<?php echo $i; ?>][value]">
285
- <span class="help-block"><?php _e('Display items with this field value', 'grand-media'); ?></span>
286
  </div>
287
  <div class="col-xs-6 col-sm-3">
288
- <label><?php _e('Compare Operator', 'grand-media'); ?></label>
289
  <select class="form-control input-sm" name="meta_query[<?php echo $i; ?>][compare]">
290
- <option <?php selected($q['compare'], ''); ?> value=""><?php _e('Default', 'grand-media'); ?> (=)</option>
291
- <option <?php selected($q['compare'], '='); ?> value="=">=</option>
292
- <option <?php selected($q['compare'], '!='); ?> value="!=">!=</option>
293
- <option <?php selected($q['compare'], '>'); ?> value="&gt;">&gt;</option>
294
- <option <?php selected($q['compare'], '>='); ?> value="&gt;=">&gt;=</option>
295
- <option <?php selected($q['compare'], '<'); ?> value="&lt;">&lt;</option>
296
- <option <?php selected($q['compare'], '<='); ?> value="&lt;=">&lt;=</option>
297
- <option <?php selected($q['compare'], 'LIKE'); ?> value="LIKE">LIKE</option>
298
- <option <?php selected($q['compare'], 'NOT LIKE'); ?> value="NOT LIKE">NOT LIKE</option>
299
  <?php /* ?>
300
- <option <?php selected($q['compare'], 'IN'); ?> value="IN">IN</option>
301
- <option <?php selected($q['compare'], 'NOT IN'); ?> value="NOT IN">NOT IN</option>
302
- <option <?php selected($q['compare'], 'BETWEEN'); ?> value="BETWEEN">BETWEEN</option>
303
- <option <?php selected($q['compare'], 'NOT BETWEEN'); ?> value="NOT BETWEEN">NOT BETWEEN</option>
304
- <?php */ ?>
305
- <option <?php selected($q['compare'], 'EXISTS'); ?> value="EXISTS">EXISTS</option>
306
  </select>
307
- <span class="help-block"><?php _e('Operator to test the field value', 'grand-media'); ?></span>
308
  </div>
309
  <div class="col-xs-6 col-sm-3">
310
- <label><?php _e('Meta Type', 'grand-media'); ?></label>
311
  <select class="form-control input-sm" name="meta_query[<?php echo $i; ?>][type]">
312
- <option <?php selected($q['type'], ''); ?> value=""><?php _e('Default', 'grand-media'); ?> (CHAR)</option>
313
- <option <?php selected($q['type'], 'CHAR'); ?> value="CHAR">CHAR</option>
314
- <option <?php selected($q['type'], 'NUMERIC'); ?> value="NUMERIC">NUMERIC</option>
315
- <option <?php selected($q['type'], 'DECIMAL'); ?> value="DECIMAL">DECIMAL</option>
316
- <option <?php selected($q['type'], 'DATE'); ?> value="DATE">DATE</option>
317
- <option <?php selected($q['type'], 'DATETIME'); ?> value="DATETIME">DATETIME</option>
318
- <option <?php selected($q['type'], 'TIME'); ?> value="TIME">TIME</option>
319
- <option <?php selected($q['type'], 'BINARY'); ?> value="BINARY">BINARY</option>
320
- <option <?php selected($q['type'], 'SIGNED'); ?> value="SIGNED">SIGNED</option>
321
- <option <?php selected($q['type'], 'UNSIGNED'); ?> value="UNSIGNED">UNSIGNED</option>
322
  </select>
323
- <span class="help-block"><?php _e('Custom field type', 'grand-media'); ?></span>
324
  </div>
325
  </div>
326
  <?php } ?>
@@ -328,52 +330,52 @@ global $user_ID, $gmDB, $gmCore
328
  <div class="form-group">
329
  <div class="row">
330
  <div class="col-xs-6 col-sm-3">
331
- <label><?php _e('Order', 'grand-media'); ?></label>
332
  <select class="form-control input-sm" name="order">
333
- <option <?php selected($query_data['order'], ''); ?> value=""><?php _e('Default (DESC)', 'grand-media'); ?></option>
334
- <option <?php selected($query_data['order'], 'DESC'); ?> value="DESC"><?php _e('DESC', 'grand-media'); ?></option>
335
- <option <?php selected($query_data['order'], 'ASC'); ?> value="ASC"><?php _e('ASC', 'grand-media'); ?></option>
336
  </select>
337
- <span class="help-block"><?php _e('Ascending or Descending order', 'grand-media'); ?></span>
338
  </div>
339
  <div class="col-xs-6 col-sm-3">
340
- <label><?php _e('Order by', 'grand-media'); ?></label>
341
  <select class="form-control input-sm" name="orderby">
342
- <option <?php selected($query_data['orderby'], ''); ?> value=""><?php _e('Default (ID)', 'grand-media'); ?></option>
343
- <option <?php selected($query_data['orderby'], 'id'); ?> value="ID"><?php _e('ID', 'grand-media'); ?></option>
344
- <option <?php selected($query_data['orderby'], 'title'); ?> value="title"><?php _e('Title', 'grand-media'); ?></option>
345
- <option <?php selected($query_data['orderby'], 'gmuid'); ?> value="gmuid"><?php _e('Filename', 'grand-media'); ?></option>
346
- <option <?php selected($query_data['orderby'], 'author'); ?> value="author"><?php _e('Author', 'grand-media'); ?></option>
347
- <option <?php selected($query_data['orderby'], 'gmedia__in'); ?> value="gmedia__in"><?php _e('Selected Order', 'grand-media'); ?></option>
348
- <option <?php selected($query_data['orderby'], 'date'); ?> value="date"><?php _e('Date', 'grand-media'); ?></option>
349
- <option <?php selected($query_data['orderby'], 'modified'); ?> value="modified"><?php _e('Modified Date', 'grand-media'); ?></option>
350
- <option <?php selected($query_data['orderby'], '_created_timestamp'); ?> value="_created_timestamp"><?php _e('Created Timestamp', 'grand-media'); ?></option>
351
- <option <?php selected($query_data['orderby'], 'comment_count'); ?> value="comment_count"><?php _e('Comment Count', 'grand-media'); ?></option>
352
- <option <?php selected($query_data['orderby'], 'views'); ?> value="views"><?php _e('Views Count', 'grand-media'); ?></option>
353
- <option <?php selected($query_data['orderby'], 'likes'); ?> value="likes"><?php _e('Likes Count', 'grand-media'); ?></option>
354
- <option <?php selected($query_data['orderby'], '_size'); ?> value="_size"><?php _e('File Size', 'grand-media'); ?></option>
355
- <option <?php selected($query_data['orderby'], 'meta_value'); ?> value="meta_value"><?php _e('Custom Field Value', 'grand-media'); ?></option>
356
- <option <?php selected($query_data['orderby'], 'meta_value_num'); ?> value="meta_value_num"><?php _e('Custom Field Value (Numeric)', 'grand-media'); ?></option>
357
- <option <?php selected($query_data['orderby'], 'rand'); ?> value="rand"><?php _e('Random', 'grand-media'); ?></option>
358
- <option <?php selected($query_data['orderby'], 'none'); ?> value="none"><?php _e('None', 'grand-media'); ?></option>
359
  </select>
360
- <span class="help-block"><?php _e('Sort retrieved posts by', 'grand-media'); ?></span>
361
  </div>
362
  <div class="col-xs-6 col-sm-3">
363
- <label><?php _e('Limit', 'grand-media'); ?></label>
364
- <input type="text" class="form-control input-sm" value="<?php echo $query_data['limit']; ?>" name="limit" placeholder="<?php _e('leave empty for no limit', 'grand-media'); ?>">
365
- <span class="help-block"><?php _e('Limit number of gmedia items', 'grand-media'); ?></span>
366
  </div>
367
  </div>
368
  </div>
369
  </div>
370
  <script type="text/javascript">
371
  jQuery(function($) {
372
- <?php if(gm_user_can('terms')){ ?>
373
 
374
- var gmedia_albums = <?php echo json_encode(array_values($gm_album_terms)); ?>;
375
- var gmedia_categories = <?php echo json_encode(array_values($gm_category_terms)); ?>;
376
- var gmedia_tags = <?php echo json_encode(array_values($gm_tag_terms)); ?>;
377
  $('#query_album__').selectize({
378
  plugins: ['drag_drop'],
379
  create: false,
@@ -389,9 +391,9 @@ global $user_ID, $gmDB, $gmCore
389
  var status = '';
390
  var author = '';
391
  var term_id = '';
392
- if(parseInt(item.term_id)) {
393
  count = '(' + escape(item.count) + ')';
394
- status = (typeof item.status != 'undefined' && ('publish' != item.status))? ' [' + item.status + '] ' : '';
395
  author = ' ' + item.by_author;
396
  term_id = '[' + item.term_id + '] ';
397
  }
@@ -402,11 +404,11 @@ global $user_ID, $gmDB, $gmCore
402
  var status = '';
403
  var author = '';
404
  var term_id = '';
405
- if(parseInt(item.term_id)) {
406
  count = '(' + escape(item.count) + ')';
407
- status = (typeof item.status != 'undefined' && ('publish' != item.status))? ' [' + item.status + '] ' : '';
408
  author = ' ' + item.by_author;
409
- term_id = '[' + item.term_id + '] ';
410
  }
411
  return '<div>[' + item.term_id + '] ' + escape(item.name) + ' <small>' + count + status + author + '</small></div>';
412
  }
@@ -414,7 +416,7 @@ global $user_ID, $gmDB, $gmCore
414
 
415
  });
416
  var cats = $('.combobox_gmedia_category').selectize({
417
- plugins: ['drag_drop'],
418
  create: false,
419
  options: gmedia_categories,
420
  preload: true,
@@ -426,22 +428,22 @@ global $user_ID, $gmDB, $gmCore
426
  render: {
427
  item: function(item, escape) {
428
  var count = '';
429
- var term_id = '';
430
- if(parseInt(item.term_id)) {
431
  count = ' <small>(' + escape(item.count) + ')</small>';
432
- term_id = '[' + item.term_id + '] ';
433
  }
434
  return '<div>' + term_id + escape(item.name) + count + '</div>';
435
  },
436
  option: function(item, escape) {
437
- if(('category__and' == this.$input[0].name) && !item.term_id) {
438
  return '';
439
  }
440
  var count = '';
441
- var term_id = '';
442
- if(parseInt(item.term_id)) {
443
  count = ' <small>(' + escape(item.count) + ')</small>';
444
- term_id = '[' + item.term_id + '] ';
445
  }
446
  return '<div>' + term_id + escape(item.name) + count + '</div>';
447
  }
@@ -464,7 +466,7 @@ global $user_ID, $gmDB, $gmCore
464
  });
465
 
466
  var tags = $('.combobox_gmedia_tag').selectize({
467
- plugins: ['drag_drop'],
468
  create: false,
469
  options: gmedia_tags,
470
  hideSelected: true,
@@ -507,10 +509,11 @@ global $user_ID, $gmDB, $gmCore
507
  });
508
 
509
  $('.query_switch').on('click', function() {
510
- var el = $('#'+$(this).attr('data-target'));
511
- if($(this).is(':checked')) {
512
  el.attr('name', el.attr('data-exclude'));
513
- } else {
 
514
  el.attr('name', el.attr('data-include'));
515
  }
516
  });
@@ -523,32 +526,32 @@ global $user_ID, $gmDB, $gmCore
523
  return e;
524
  });
525
  $.each(storedData, function(i, id) {
526
- if(!id) {
527
  return true;
528
  }
529
- if($.inArray(id, valData) === -1) {
530
  valData.push(id);
531
  }
532
  });
533
  field.val(valData.join(','));
534
  });
535
 
536
- $('.buildqueryreset').on('click', function() {
537
- $('input.gm-selectize, select.gm-selectize', '#buildQuery').each(function(){
538
- this.selectize.clear();
539
- });
540
- $('input[type="text"], select, textarea', '#buildQuery').each(function(){
541
- $(this).val('');
542
- });
543
- $('input[type="checkbox"]', '#buildQuery').prop('checked', false);
544
- });
545
  });
546
 
547
  </script>
548
  <div class="modal-footer">
549
- <button type="button" class="btn btn-default buildqueryreset"><?php _e('Reset', 'grand-media'); ?></button>
550
- <button type="button" class="btn btn-primary buildquerysubmit"><?php _e('Build Query', 'grand-media'); ?></button>
551
- <button type="button" class="btn btn-default" data-dismiss="modal"><?php _e('Close', 'grand-media'); ?></button>
552
  </div>
553
  </div>
554
  </div>
1
  <?php
2
+ // don't load directly.
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ die( '-1' );
5
  }
6
 
7
  /**
8
  * Modal for Build Query
9
+ *
10
  * @var $gm_album_terms
11
  * @var $gm_category_terms
12
  * @var $gm_tag_terms
17
  <div class="modal-dialog" style="width:700px;">
18
  <div class="modal-content">
19
  <div class="modal-header">
20
+ <div class="pull-right" style="margin-top:-4px;">
21
+ <button type="button" class="btn btn-default buildqueryreset"><?php _e( 'Reset', 'grand-media' ); ?></button>
22
+ <button type="button" class="btn btn-primary buildquerysubmit"><?php _e( 'Build Query', 'grand-media' ); ?></button>
23
+ <button type="button" class="btn btn-default" data-dismiss="modal"><?php _e( 'Close', 'grand-media' ); ?></button>
24
+ </div>
25
+ <h4 class="modal-title"><?php _e( 'Query Parameters' ); ?></h4>
26
  </div>
27
  <div class="modal-body">
28
 
29
  <?php
30
  $query_data = $gmedia_filter['query_data'];
31
+ if ( gm_user_can( 'terms' ) ) { ?>
32
  <div class="form-group">
33
  <?php
34
  $term_type = 'gmedia_album';
35
+ $args = [];
36
+ if ( gm_user_can( 'edit_others_media' ) ) {
37
  $args['global'] = '';
38
  } else {
39
+ $args['global'] = [ 0, $user_ID ];
40
  }
41
+ $gm_album_terms = $gmDB->get_terms( $term_type, $args );
42
 
43
+ $no_term = [
44
  'term_id' => 0,
45
+ 'name' => __( 'No Album', 'grand-media' ),
46
+ ];
47
+ if ( count( $gm_album_terms ) ) {
48
+ foreach ( $gm_album_terms as &$_term ) {
49
+ unset( $_term->description );
50
+ unset( $_term->taxonomy );
51
+ $_term->by_author = $_term->global ? sprintf( __( 'by %s', 'grand-media' ), esc_html( get_the_author_meta( 'display_name', $_term->global ) ) ) : '';
52
+ /* ('publish' === $_term->status? '' : " [{$_term->status}]") . ' &nbsp; (' . $_term->count . ')';*/
53
  }
54
  }
55
+ $gm_album_terms = array_merge( [ $no_term ], $gm_album_terms );
56
+ $query_gmedia_albums = [];
57
  $exclude_albums = false;
58
+ if ( ! empty( $query_data['album__in'] ) || ( is_string( $query_data['album__in'] ) && '0' === $query_data['album__in'] ) ) {
59
+ $query_gmedia_albums = wp_parse_id_list( $query_data['album__in'] );
60
+ } elseif ( ! empty( $query_data['album__not_in'] ) || ( is_string( $query_data['album__not_in'] ) && '0' === $query_data['album__not_in'] ) ) {
61
+ $query_gmedia_albums = wp_parse_id_list( $query_data['album__not_in'] );
62
  $exclude_albums = true;
63
  }
64
  ?>
65
+ <label><?php _e( 'Albums', 'grand-media' ); ?> </label>
66
 
67
  <div class="row">
68
  <div class="col-xs-8">
69
+ <input id="query_album__" name="album__in" data-include="album__in" data-exclude="album__not_in" class="form-control gm-selectize input-sm" value="<?php echo esc_attr( implode( ',', $query_gmedia_albums ) ); ?>" placeholder="<?php esc_attr_e( __( 'Any Album...', 'grand-media' ) ); ?>"/>
70
  </div>
71
  <div class="col-xs-4">
72
+ <div class="checkbox"><label><input class="query_switch" data-target="query_album__" type="checkbox"<?php echo $exclude_albums ? ' checked="checked"' : ''; ?> /> <?php _e( 'Exclude selected Albums', 'grand-media' ); ?></label></div>
73
  </div>
74
  </div>
75
  <div class="row">
76
  <div class="col-xs-8">
77
+ <?php _e( 'To show all albums just select `No Album` in dropdown above then tick `Exclude selected Albums`, so it exclude all images without Album and show other images.', 'grand-media' ); ?>
78
  </div>
79
  <div class="col-xs-4">
80
+ <label><?php _e( 'Albums Order', 'grand-media' ); ?> </label>
81
  <select name="albums_order" class="form-control input-sm">
82
+ <option <?php selected( $query_data['albums_order'], '' ); ?> value=""><?php _e( 'No Order' ); ?></option>
83
+ <option <?php selected( $query_data['albums_order'], 'id' ); ?> value="id"><?php _e( 'By ID (ASC)' ); ?></option>
84
+ <option <?php selected( $query_data['albums_order'], 'id_desc' ); ?> value="desc"><?php _e( 'By ID (DESC)' ); ?></option>
85
+ <option <?php selected( $query_data['albums_order'], 'name' ); ?> value="name"><?php _e( 'By Name (ASC)' ); ?></option>
86
+ <option <?php selected( $query_data['albums_order'], 'name_desc' ); ?> value="name_desc"><?php _e( 'By Name (DESC)' ); ?></option>
87
+ <option <?php selected( $query_data['albums_order'], 'date' ); ?> value="date"><?php _e( 'By Date (ASC)' ); ?></option>
88
+ <option <?php selected( $query_data['albums_order'], 'date_desc' ); ?> value="date_desc"><?php _e( 'By Date (DESC)' ); ?></option>
89
  </select>
90
  </div>
91
  </div>
94
  <div class="form-group">
95
  <?php
96
  $term_type = 'gmedia_category';
97
+ $gm_category_terms = $gmDB->get_terms( $term_type, [ 'fields' => 'names_count' ] );
98
 
99
+ $no_term = [
100
  'term_id' => 0,
101
+ 'name' => __( 'Uncategorized', 'grand-media' ),
102
+ ];
103
+ $gm_category_terms = array_merge( [ $no_term ], $gm_category_terms );
104
  ?>
105
  <div class="row">
106
  <div class="col-xs-4">
107
+ <label><?php _e( '[IN] Categories', 'grand-media' ); ?></label>
108
+ <input name="category__in" class="form-control input-sm gm-selectize combobox_gmedia_category" value="<?php echo esc_attr( implode( ',', wp_parse_id_list( $query_data['category__in'] ) ) ); ?>" placeholder="<?php esc_attr_e( __( 'Either of chosen Categories...', 'grand-media' ) ); ?>"/>
109
  </div>
110
  <div class="col-xs-4">
111
+ <label><?php _e( '[AND] Categories', 'grand-media' ); ?></label>
112
+ <input name="category__and" class="form-control input-sm gm-selectize combobox_gmedia_category" value="<?php echo esc_attr( implode( ',', wp_parse_id_list( $query_data['category__and'] ) ) ); ?>" placeholder="<?php esc_attr_e( __( 'Have all chosen Categories...', 'grand-media' ) ); ?>"/>
113
  </div>
114
  <div class="col-xs-4">
115
+ <label><?php _e( '[NOT IN] Categories', 'grand-media' ); ?></label>
116
+ <input name="category__not_in" class="form-control input-sm gm-selectize combobox_gmedia_category" value="<?php echo esc_attr( implode( ',', wp_parse_id_list( $query_data['category__not_in'] ) ) ); ?>" placeholder="<?php esc_attr_e( __( 'Exclude Categories...', 'grand-media' ) ); ?>"/>
117
  </div>
118
  </div>
119
  </div>
121
  <div class="form-group">
122
  <?php
123
  $term_type = 'gmedia_tag';
124
+ $gm_tag_terms = $gmDB->get_terms( $term_type, [ 'fields' => 'names_count' ] );
125
  ?>
126
  <div class="row">
127
  <div class="col-xs-4">
128
+ <label><?php _e( '[IN] Tags', 'grand-media' ); ?> </label>
129
+ <input name="tag__in" class="form-control input-sm gm-selectize combobox_gmedia_tag" value="<?php echo esc_attr( implode( ',', wp_parse_id_list( $query_data['tag__in'] ) ) ); ?>" placeholder="<?php esc_attr_e( __( 'Either of chosen Tags...', 'grand-media' ) ); ?>"/>
130
  </div>
131
  <div class="col-xs-4">
132
+ <label><?php _e( '[AND] Tags', 'grand-media' ); ?> </label>
133
+ <input name="tag__and" class="form-control input-sm gm-selectize combobox_gmedia_tag" value="<?php echo esc_attr( implode( ',', wp_parse_id_list( $query_data['tag__and'] ) ) ); ?>" placeholder="<?php esc_attr_e( __( 'Have all chosen Tags...', 'grand-media' ) ); ?>"/>
134
  </div>
135
  <div class="col-xs-4">
136
+ <label><?php _e( '[NOT IN] Tags', 'grand-media' ); ?> </label>
137
+ <input name="tag__not_in" class="form-control input-sm gm-selectize combobox_gmedia_tag" value="<?php echo esc_attr( implode( ',', wp_parse_id_list( $query_data['tag__not_in'] ) ) ); ?>" placeholder="<?php esc_attr_e( __( 'Exclude Tags...', 'grand-media' ) ); ?>"/>
138
  </div>
139
  </div>
140
  </div>
141
 
142
  <?php } ?>
143
  <div class="form-group">
144
+ <label><?php _e( 'Terms Relation', 'grand-media' ); ?> </label>
145
 
146
  <div class="row">
147
  <div class="col-xs-4">
148
  <select name="terms_relation" class="form-control input-sm">
149
+ <option <?php selected( $query_data['terms_relation'], '' ); ?> value=""><?php _e( 'Default (OR)' ); ?></option>
150
+ <option <?php selected( $query_data['terms_relation'], 'AND' ); ?> value="AND"><?php _e( 'AND' ); ?></option>
151
+ <option <?php selected( $query_data['terms_relation'], 'OR' ); ?> value="OR"><?php _e( 'OR' ); ?></option>
152
  </select>
153
  </div>
154
  <div class="col-xs-8">
155
+ <p class="help-block"><?php _e( 'allows you to describe the relationship between the taxonomy queries', 'grand-media' ); ?></p>
156
  </div>
157
  </div>
158
  </div>
159
  <div class="form-group">
160
+ <label><?php _e( 'Search', 'grand-media' ); ?></label>
161
 
162
  <div class="row">
163
  <div class="col-xs-8">
164
+ <input type="text" class="form-control input-sm" placeholder="<?php _e( 'Search string or terms separated by comma', 'grand-media' ); ?>" value="<?php echo esc_attr( $query_data['s'] ); ?>" name="s">
165
  </div>
166
  <div class="col-xs-4">
167
+ <div class="checkbox"><label><input type="checkbox" name="exact" value="yes"<?php echo $query_data['exact'] ? ' checked="checked"' : ''; ?> /> <?php _e( 'Search exactly string', 'grand-media' ); ?></label></div>
168
  </div>
169
  </div>
170
  </div>
172
  <div class="row">
173
  <div class="col-xs-8">
174
  <div class="pull-right">
175
+ <a id="_use_lib_selected" title="<?php _e( 'Select Media', 'grand-media' ); ?>" href="<?php echo esc_url( $gmCore->get_admin_url( [
176
+ 'page' => 'GrandMedia',
177
+ 'mode' => 'select_multiple',
178
+ 'gmediablank' => 'library',
179
+ ], [], true ) ); ?>" class="label label-primary preview-modal" data-target="#previewModal" data-width="1200" data-height="500" data-cls="select_gmedia"><?php _e( 'Select in Library', 'grand-media' ); ?></a>
180
+ </div>
181
+ <label><?php _e( 'Gmedia IDs <small class="text-muted">separated by comma</small>', 'grand-media' ); ?> </label>
182
  </div>
183
  </div>
184
  <div class="row">
185
  <div class="col-xs-8">
186
+ <?php $query_gmedia_items = [];
187
+ if ( ! empty( $query_data['gmedia__in'] ) ) {
188
  $query_gmedia_items = $query_data['gmedia__in'];
189
+ } elseif ( ! empty( $query_data['gmedia__not_in'] ) ) {
190
  $query_gmedia_items = $query_data['gmedia__not_in'];
191
  }
192
  ?>
193
+ <textarea id="query_gmedia__" name="gmedia__in" data-include="gmedia__in" data-exclude="gmedia__not_in" rows="1" class="form-control input-sm" style="resize:vertical;" placeholder="<?php esc_attr_e( __( 'Gmedia IDs...', 'grand-media' ) ); ?>"><?php echo implode( ',', wp_parse_id_list( $query_gmedia_items ) ); ?></textarea>
194
  </div>
195
  <div class="col-xs-4">
196
+ <div class="checkbox"><label><input class="query_switch" data-target="query_gmedia__" type="checkbox"<?php echo ( empty( $query_data['gmedia__in'] ) && ! empty( $query_data['gmedia__not_in'] ) ) ? ' checked="checked"' : ''; ?> /> <?php _e( 'Exclude selected Items', 'grand-media' ); ?></label></div>
197
  </div>
198
  </div>
199
+ <p class="help-block"><?php _e( 'You can select items you want to add here right in Gmedia Library and then return here and click button "Use selected in Library"', 'grand-media' ); ?></p>
200
  </div>
201
  <div class="form-group">
202
  <div class="row">
203
  <div class="col-xs-4">
204
+ <label><?php _e( 'Mime Type', 'grand-media' ); ?> </label>
205
  <?php
206
+ $mime_types = [
207
+ [ 'value' => 'image', 'text' => 'Image' ],
208
+ [ 'value' => 'audio', 'text' => 'Audio' ],
209
+ [ 'value' => 'video', 'text' => 'Video' ],
210
+ [ 'value' => 'text', 'text' => 'Text' ],
211
+ [ 'value' => 'application', 'text' => 'Application' ],
212
+ ];
213
+ $mime_type_val = is_array( $query_data['mime_type'] ) ? implode( ',', $query_data['mime_type'] ) : str_replace( ', ', ',', $query_data['mime_type'] );
214
  ?>
215
+ <input name="mime_type" class="form-control input-sm gm-selectize gmedia-combobox" data-options='<?php echo wp_json_encode( $mime_types ); ?>' value="<?php echo esc_attr( $mime_type_val ); ?>" placeholder="<?php esc_attr_e( __( 'All types...', 'grand-media' ) ); ?>"/>
216
  </div>
217
  <div class="col-xs-4">
218
+ <label><?php _e( 'Authors', 'grand-media' ); ?></label>
219
+ <?php if ( gm_user_can( 'show_others_media' ) ) {
220
  $user_ids = $gmCore->get_editable_user_ids();
221
+ if ( ! in_array( $user_ID, $user_ids, true ) ) {
222
+ array_push( $user_ids, $user_ID );
223
  }
224
+ $filter_users = get_users( [ 'include' => $user_ids ] );
225
  $users = '';
226
+ $_users = [];
227
+ if ( count( $filter_users ) ) {
228
+ $author__in = wp_parse_id_list( $query_data['author__in'] );
229
+ foreach ( (array) $filter_users as $user ) {
230
+ $user->ID = (int) $user->ID;
231
+ $_selected = in_array( $user->ID, $author__in, true ) ? ' selected="selected"' : '';
232
+ $users .= "<option value='{$user->ID}'{$_selected}>" . esc_html( $user->display_name ) . "</option>";
233
+ $_users[] = [ 'value' => $user->ID, 'text' => esc_html( $user->display_name ) ];
234
  }
235
  }
236
+ $query_authors = [];
237
+ if ( ! empty( $query_data['author__in'] ) ) {
238
  $query_authors = $query_data['author__in'];
239
+ } elseif ( ! empty( $query_data['author__not_in'] ) ) {
240
  $query_authors = $query_data['author__not_in'];
241
  }
242
  ?>
243
+ <input id="query_author__" name="author__in" data-include="author__in" data-exclude="author__not_in" class="form-control input-sm gm-selectize gmedia-combobox" data-options='<?php echo str_replace( "'", "\'", wp_json_encode( $_users ) ); ?>' value="<?php echo esc_attr( implode( ',', wp_parse_id_list( $query_authors ) ) ); ?>" placeholder="<?php esc_attr_e( __( 'All authors...', 'grand-media' ) ); ?>"/>
244
  <?php } else { ?>
245
+ <input type="text" readonly="readonly" name="author__in" class="form-control input-sm" value="<?php the_author_meta( 'display_name', $user_ID ); ?>"/>
246
  <?php } ?>
247
  </div>
248
+ <?php if ( gm_user_can( 'show_others_media' ) ) { ?>
249
  <div class="col-xs-4">
250
  <label>&nbsp;</label>
251
+ <div class="checkbox"><label><input class="query_switch" data-target="query_author__" type="checkbox"<?php echo ( empty( $query_data['author__in'] ) && ! empty( $query_data['author__not_in'] ) ) ? ' checked="checked"' : ''; ?> /> <?php _e( 'Exclude Authors', 'grand-media' ); ?></label></div>
252
  </div>
253
  <?php } ?>
254
  </div>
256
  <div class="form-group">
257
  <div class="row">
258
  <div class="col-xs-4">
259
+ <label><?php _e( 'Year', 'grand-media' ); ?></label>
260
+ <input type="text" class="form-control input-sm" placeholder="<?php _e( '4 digit year e.g. 2011', 'grand-media' ); ?>" value="<?php echo esc_attr( $query_data['year'] ); ?>" name="year">
261
  </div>
262
  <div class="col-xs-4">
263
+ <label><?php _e( 'Month', 'grand-media' ); ?></label>
264
+ <input type="text" class="form-control input-sm" placeholder="<?php _e( 'from 1 to 12', 'grand-media' ); ?>" value="<?php echo esc_attr( $query_data['monthnum'] ); ?>" name="monthnum">
265
  </div>
266
  <div class="col-xs-4">
267
+ <label><?php _e( 'Day', 'grand-media' ); ?></label>
268
+ <input type="text" class="form-control input-sm" placeholder="<?php _e( 'from 1 to 31', 'grand-media' ); ?>" value="<?php echo esc_attr( $query_data['day'] ); ?>" name="day">
269
  </div>
270
  </div>
271
  </div>
272
  <div class="form-group">
273
+ <?php foreach ( $query_data['meta_query'] as $i => $q ) {
274
+ if ( $i ) {
275
  continue;
276
  }
277
  ?>
278
  <div class="row">
279
  <div class="col-xs-6 col-sm-3">
280
+ <label><?php _e( 'Custom Field Key', 'grand-media' ); ?></label>
281
+ <input type="text" class="form-control input-sm" value="<?php echo esc_attr( $q['key'] ); ?>" name="meta_query[<?php echo $i; ?>][key]">
282
+ <span class="help-block"><?php _e( 'Display items with this field key', 'grand-media' ); ?></span>
283
  </div>
284
  <div class="col-xs-6 col-sm-3">
285
+ <label><?php _e( 'Custom Field Value', 'grand-media' ); ?></label>
286
+ <input type="text" class="form-control input-sm" value="<?php echo esc_attr( $q['value'] ); ?>" name="meta_query[<?php echo $i; ?>][value]">
287
+ <span class="help-block"><?php _e( 'Display items with this field value', 'grand-media' ); ?></span>
288
  </div>
289
  <div class="col-xs-6 col-sm-3">
290
+ <label><?php _e( 'Compare Operator', 'grand-media' ); ?></label>
291
  <select class="form-control input-sm" name="meta_query[<?php echo $i; ?>][compare]">
292
+ <option <?php selected( $q['compare'], '' ); ?> value=""><?php _e( 'Default', 'grand-media' ); ?> (=)</option>
293
+ <option <?php selected( $q['compare'], '=' ); ?> value="=">=</option>
294
+ <option <?php selected( $q['compare'], '!=' ); ?> value="!=">!=</option>
295
+ <option <?php selected( $q['compare'], '>' ); ?> value="&gt;">&gt;</option>
296
+ <option <?php selected( $q['compare'], '>=' ); ?> value="&gt;=">&gt;=</option>
297
+ <option <?php selected( $q['compare'], '<' ); ?> value="&lt;">&lt;</option>
298
+ <option <?php selected( $q['compare'], '<=' ); ?> value="&lt;=">&lt;=</option>
299
+ <option <?php selected( $q['compare'], 'LIKE' ); ?> value="LIKE">LIKE</option>
300
+ <option <?php selected( $q['compare'], 'NOT LIKE' ); ?> value="NOT LIKE">NOT LIKE</option>
301
  <?php /* ?>
302
+ <option <?php selected($q['compare'], 'IN'); ?> value="IN">IN</option>
303
+ <option <?php selected($q['compare'], 'NOT IN'); ?> value="NOT IN">NOT IN</option>
304
+ <option <?php selected($q['compare'], 'BETWEEN'); ?> value="BETWEEN">BETWEEN</option>
305
+ <option <?php selected($q['compare'], 'NOT BETWEEN'); ?> value="NOT BETWEEN">NOT BETWEEN</option>
306
+ <?php */ ?>
307
+ <option <?php selected( $q['compare'], 'EXISTS' ); ?> value="EXISTS">EXISTS</option>
308
  </select>
309
+ <span class="help-block"><?php _e( 'Operator to test the field value', 'grand-media' ); ?></span>
310
  </div>
311
  <div class="col-xs-6 col-sm-3">
312
+ <label><?php _e( 'Meta Type', 'grand-media' ); ?></label>
313
  <select class="form-control input-sm" name="meta_query[<?php echo $i; ?>][type]">
314
+ <option <?php selected( $q['type'], '' ); ?> value=""><?php _e( 'Default', 'grand-media' ); ?> (CHAR)</option>
315
+ <option <?php selected( $q['type'], 'CHAR' ); ?> value="CHAR">CHAR</option>
316
+ <option <?php selected( $q['type'], 'NUMERIC' ); ?> value="NUMERIC">NUMERIC</option>
317
+ <option <?php selected( $q['type'], 'DECIMAL' ); ?> value="DECIMAL">DECIMAL</option>
318
+ <option <?php selected( $q['type'], 'DATE' ); ?> value="DATE">DATE</option>
319
+ <option <?php selected( $q['type'], 'DATETIME' ); ?> value="DATETIME">DATETIME</option>
320
+ <option <?php selected( $q['type'], 'TIME' ); ?> value="TIME">TIME</option>
321
+ <option <?php selected( $q['type'], 'BINARY' ); ?> value="BINARY">BINARY</option>
322
+ <option <?php selected( $q['type'], 'SIGNED' ); ?> value="SIGNED">SIGNED</option>
323
+ <option <?php selected( $q['type'], 'UNSIGNED' ); ?> value="UNSIGNED">UNSIGNED</option>
324
  </select>
325
+ <span class="help-block"><?php _e( 'Custom field type', 'grand-media' ); ?></span>
326
  </div>
327
  </div>
328
  <?php } ?>
330
  <div class="form-group">
331
  <div class="row">
332
  <div class="col-xs-6 col-sm-3">
333
+ <label><?php _e( 'Order', 'grand-media' ); ?></label>
334
  <select class="form-control input-sm" name="order">
335
+ <option <?php selected( $query_data['order'], '' ); ?> value=""><?php _e( 'Default (DESC)', 'grand-media' ); ?></option>
336
+ <option <?php selected( $query_data['order'], 'DESC' ); ?> value="DESC"><?php _e( 'DESC', 'grand-media' ); ?></option>
337
+ <option <?php selected( $query_data['order'], 'ASC' ); ?> value="ASC"><?php _e( 'ASC', 'grand-media' ); ?></option>
338
  </select>
339
+ <span class="help-block"><?php _e( 'Ascending or Descending order', 'grand-media' ); ?></span>
340
  </div>
341
  <div class="col-xs-6 col-sm-3">
342
+ <label><?php _e( 'Order by', 'grand-media' ); ?></label>
343
  <select class="form-control input-sm" name="orderby">
344
+ <option <?php selected( $query_data['orderby'], '' ); ?> value=""><?php _e( 'Default (ID)', 'grand-media' ); ?></option>
345
+ <option <?php selected( $query_data['orderby'], 'id' ); ?> value="ID"><?php _e( 'ID', 'grand-media' ); ?></option>
346
+ <option <?php selected( $query_data['orderby'], 'title' ); ?> value="title"><?php _e( 'Title', 'grand-media' ); ?></option>
347
+ <option <?php selected( $query_data['orderby'], 'gmuid' ); ?> value="gmuid"><?php _e( 'Filename', 'grand-media' ); ?></option>
348
+ <option <?php selected( $query_data['orderby'], 'author' ); ?> value="author"><?php _e( 'Author', 'grand-media' ); ?></option>
349
+ <option <?php selected( $query_data['orderby'], 'gmedia__in' ); ?> value="gmedia__in"><?php _e( 'Selected Order', 'grand-media' ); ?></option>
350
+ <option <?php selected( $query_data['orderby'], 'date' ); ?> value="date"><?php _e( 'Date', 'grand-media' ); ?></option>
351
+ <option <?php selected( $query_data['orderby'], 'modified' ); ?> value="modified"><?php _e( 'Modified Date', 'grand-media' ); ?></option>
352
+ <option <?php selected( $query_data['orderby'], '_created_timestamp' ); ?> value="_created_timestamp"><?php _e( 'Created Timestamp', 'grand-media' ); ?></option>
353
+ <option <?php selected( $query_data['orderby'], 'comment_count' ); ?> value="comment_count"><?php _e( 'Comment Count', 'grand-media' ); ?></option>
354
+ <option <?php selected( $query_data['orderby'], 'views' ); ?> value="views"><?php _e( 'Views Count', 'grand-media' ); ?></option>
355
+ <option <?php selected( $query_data['orderby'], 'likes' ); ?> value="likes"><?php _e( 'Likes Count', 'grand-media' ); ?></option>
356
+ <option <?php selected( $query_data['orderby'], '_size' ); ?> value="_size"><?php _e( 'File Size', 'grand-media' ); ?></option>
357
+ <option <?php selected( $query_data['orderby'], 'meta_value' ); ?> value="meta_value"><?php _e( 'Custom Field Value', 'grand-media' ); ?></option>
358
+ <option <?php selected( $query_data['orderby'], 'meta_value_num' ); ?> value="meta_value_num"><?php _e( 'Custom Field Value (Numeric)', 'grand-media' ); ?></option>
359
+ <option <?php selected( $query_data['orderby'], 'rand' ); ?> value="rand"><?php _e( 'Random', 'grand-media' ); ?></option>
360
+ <option <?php selected( $query_data['orderby'], 'none' ); ?> value="none"><?php _e( 'None', 'grand-media' ); ?></option>
361
  </select>
362
+ <span class="help-block"><?php _e( 'Sort retrieved posts by', 'grand-media' ); ?></span>
363
  </div>
364
  <div class="col-xs-6 col-sm-3">
365
+ <label><?php _e( 'Limit', 'grand-media' ); ?></label>
366
+ <input type="text" class="form-control input-sm" value="<?php echo esc_attr( $query_data['limit'] ); ?>" name="limit" placeholder="<?php _e( 'leave empty for no limit', 'grand-media' ); ?>">
367
+ <span class="help-block"><?php _e( 'Limit number of gmedia items', 'grand-media' ); ?></span>
368
  </div>
369
  </div>
370
  </div>
371
  </div>
372
  <script type="text/javascript">
373
  jQuery(function($) {
374
+ <?php if(gm_user_can( 'terms' )){ ?>
375
 
376
+ var gmedia_albums = <?php echo wp_json_encode( array_values( $gm_album_terms ) ); ?>;
377
+ var gmedia_categories = <?php echo wp_json_encode( array_values( $gm_category_terms ) ); ?>;
378
+ var gmedia_tags = <?php echo wp_json_encode( array_values( $gm_tag_terms ) ); ?>;
379
  $('#query_album__').selectize({
380
  plugins: ['drag_drop'],
381
  create: false,
391
  var status = '';
392
  var author = '';
393
  var term_id = '';
394
+ if (parseInt(item.term_id)) {
395
  count = '(' + escape(item.count) + ')';
396
+ status = (typeof item.status !== 'undefined' && ('publish' !== item.status)) ? ' [' + item.status + '] ' : '';
397
  author = ' ' + item.by_author;
398
  term_id = '[' + item.term_id + '] ';
399
  }
404
  var status = '';
405
  var author = '';
406
  var term_id = '';
407
+ if (parseInt(item.term_id)) {
408
  count = '(' + escape(item.count) + ')';
409
+ status = (typeof item.status !== 'undefined' && ('publish' !== item.status)) ? ' [' + item.status + '] ' : '';
410
  author = ' ' + item.by_author;
411
+ term_id = '[' + item.term_id + '] ';
412
  }
413
  return '<div>[' + item.term_id + '] ' + escape(item.name) + ' <small>' + count + status + author + '</small></div>';
414
  }
416
 
417
  });
418
  var cats = $('.combobox_gmedia_category').selectize({
419
+ plugins: ['drag_drop'],
420
  create: false,
421
  options: gmedia_categories,
422
  preload: true,
428
  render: {
429
  item: function(item, escape) {
430
  var count = '';
431
+ var term_id = '';
432
+ if (parseInt(item.term_id)) {
433
  count = ' <small>(' + escape(item.count) + ')</small>';
434
+ term_id = '[' + item.term_id + '] ';
435
  }
436
  return '<div>' + term_id + escape(item.name) + count + '</div>';
437
  },
438
  option: function(item, escape) {
439
+ if (('category__and' === this.$input[0].name) && !item.term_id) {
440
  return '';
441
  }
442
  var count = '';
443
+ var term_id = '';
444
+ if (parseInt(item.term_id)) {
445
  count = ' <small>(' + escape(item.count) + ')</small>';
446
+ term_id = '[' + item.term_id + '] ';
447
  }
448
  return '<div>' + term_id + escape(item.name) + count + '</div>';
449
  }
466
  });
467
 
468
  var tags = $('.combobox_gmedia_tag').selectize({
469
+ plugins: ['drag_drop'],
470
  create: false,
471
  options: gmedia_tags,
472
  hideSelected: true,
509
  });
510
 
511
  $('.query_switch').on('click', function() {
512
+ var el = $('#' + $(this).attr('data-target'));
513
+ if ($(this).is(':checked')) {
514
  el.attr('name', el.attr('data-exclude'));
515
+ }
516
+ else {
517
  el.attr('name', el.attr('data-include'));
518
  }
519
  });
526
  return e;
527
  });
528
  $.each(storedData, function(i, id) {
529
+ if (!id) {
530
  return true;
531
  }
532
+ if ($.inArray(id, valData) === -1) {
533
  valData.push(id);
534
  }
535
  });
536
  field.val(valData.join(','));
537
  });
538
 
539
+ $('.buildqueryreset').on('click', function() {
540
+ $('input.gm-selectize, select.gm-selectize', '#buildQuery').each(function() {
541
+ this.selectize.clear();
542
+ });
543
+ $('input[type="text"], select, textarea', '#buildQuery').each(function() {
544
+ $(this).val('');
545
+ });
546
+ $('input[type="checkbox"]', '#buildQuery').prop('checked', false);
547
+ });
548
  });
549
 
550
  </script>
551
  <div class="modal-footer">
552
+ <button type="button" class="btn btn-default buildqueryreset"><?php _e( 'Reset', 'grand-media' ); ?></button>
553
+ <button type="button" class="btn btn-primary buildquerysubmit"><?php _e( 'Build Query', 'grand-media' ); ?></button>
554
+ <button type="button" class="btn btn-default" data-dismiss="modal"><?php _e( 'Close', 'grand-media' ); ?></button>
555
  </div>
556
  </div>
557
  </div>
admin/pages/galleries/tpl/module-settings.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- // don't load directly
3
- if(!defined('ABSPATH')){
4
- die('-1');
5
  }
6
 
7
  /**
@@ -10,231 +10,241 @@ if(!defined('ABSPATH')){
10
  global $gmGallery;
11
  ?>
12
  <div class="row">
13
- <div class="col-lg-5 tabable tabs-left">
14
- <ul class="nav nav-tabs" id="galleryTabs">
15
- <?php if(isset($module_info)){ ?>
16
- <li class="text-center">
17
- <strong><?php echo $module_info['title']; ?></strong><a href="#chooseModuleModal" data-toggle="modal" style="padding:5px 0;"><img src="<?php echo $term->module['url'] . '/screenshot.png'; ?>" alt="<?php esc_attr_e($module_info['title']); ?>" width="100" style="height:auto;"/></a>
18
- </li>
19
- <?php } else{ ?>
20
- <li class="text-center"><strong><?php echo $term->module['name']; ?></strong>
21
 
22
- <p><?php _e('This module is broken or outdated. Please, go to Modules page and update/install module or choose another one for this gallery', 'grand-media'); ?></p>
23
- <a href="#chooseModuleModal" data-toggle="modal" style="padding:5px 0;"><img src="<?php echo $term->module['url'] . '/screenshot.png'; ?>" alt="<?php esc_attr_e($term->module['name']); ?>" width="100" style="height:auto;"/></a>
24
- </li>
25
- <?php } ?>
26
- <?php
27
- if(isset($options_tree)){
28
- gmedia_gallery_options_nav($options_tree);
29
- }
30
- ?>
31
- </ul>
32
 
33
- <div id="gallery_options_block" class="tab-content">
34
- <?php
35
- if(isset($options_tree)){
36
- gmedia_gallery_options_fieldset($options_tree, $default_options, $gallery_settings);
37
- }
38
- ?>
39
- </div>
40
 
41
- </div>
42
- <div class="col-lg-7">
43
- <?php if($term_id || isset($preset_module)){
44
- $bgcolor = empty($gmGallery->options['preview_bgcolor'])? 'ffffff' : $gmGallery->options['preview_bgcolor'];
45
- $params['is_admin_preview'] = 1;
46
- ?>
47
- <div class="clearfix">
48
- <div class="form-group pull-right" style="margin:-10px 0 5px 0;"><input type="text" data-type="color" class="form-control input-sm" id="preview_color" name="preview_bgcolor" value="<?php echo $bgcolor; ?>" placeholder="ffffff" size="7"/></div>
49
- <b><?php _e('Gallery Preview:'); ?></b>
50
- </div>
51
- <div class="gallery_preview">
52
- <iframe id="gallery_preview" style="background-color:<?php echo "#$bgcolor"; ?>;padding:5px;" name="gallery_preview" src="<?php echo add_query_arg($params, set_url_scheme($gallery_link_default, 'admin')); ?>"></iframe>
53
- </div>
54
- <?php } ?>
55
- </div>
56
  </div>
57
  <script type="text/javascript">
58
- jQuery(function($) {
59
- var hash = window.location.hash;
60
- if(hash) {
61
- $('#galleryTabs a').eq(hash.replace('#tab-', '')).tab('show');
62
- }
63
- $('.gallery_preview').resizable();
64
- $('#gmedia-edit-term').on('submit', function(e) {
65
- if($('#build_query_field').val() == '') {
66
- var conf_txt = "<?php _e("Warning: Query Args. field is empty! Show in gallery all files from Gmedia Library?") ?>";
67
- if(!GmediaFunction.confirm(conf_txt)) {
68
- e.preventDefault();
69
- return false;
70
- }
71
- }
72
- $(this).attr('action', $(this).attr('action') + '#tab-' + $('#galleryTabs li.active').index());
73
- });
74
 
75
- var main = $('#gallery_options_block');
76
 
77
- $('input', main).filter('[data-type="color"]').minicolors({
78
- animationSpeed: 50,
79
- animationEasing: 'swing',
80
- change: null,
81
- changeDelay: 0,
82
- control: 'hue',
83
- //defaultValue: '',
84
- hide: null,
85
- hideSpeed: 100,
86
- inline: false,
87
- letterCase: 'lowercase',
88
- opacity: false,
89
- position: 'bottom left',
90
- show: null,
91
- showSpeed: 100,
92
- theme: 'bootstrap'
93
- });
94
- $('#preview_color').on('change', function() {
95
- var color = $(this).val();
96
- $('#gallery_preview').css({backgroundColor: '#' + color});
97
- }).minicolors({
98
- animationSpeed: 50,
99
- animationEasing: 'swing',
100
- change: null,
101
- changeDelay: 0,
102
- control: 'hue',
103
- //defaultValue: '',
104
- hide: null,
105
- hideSpeed: 100,
106
- inline: false,
107
- letterCase: 'lowercase',
108
- opacity: false,
109
- position: 'bottom right',
110
- show: null,
111
- showSpeed: 100,
112
- theme: 'bootstrap'
113
- });
114
 
115
- $('input', main).filter('[data-type="rgba"]').spectrum({
116
- showInput: true,
117
- showAlpha: true,
118
- allowEmpty: false,
119
- preferredFormat: 'rgb'
120
- });
121
 
122
- $('[data-watch]', main).each(function() {
123
- var el = $(this);
124
- gmedia_options_conditional_logic(el, 0);
125
- var event = el.attr('data-watch');
126
- if(event) {
127
- el.on(event, function() {
128
- if('change' == el.attr('data-watch')) {
129
- $(this).blur().focus();
130
- }
131
- gmedia_options_conditional_logic($(this), 400);
132
- });
133
- }
134
- });
135
 
136
- function gmedia_options_conditional_logic(el, slide) {
137
- if(el.is(':input')) {
138
- var val = el.val();
139
- var id = el.attr('id').toLowerCase();
140
- if(el.is(':checkbox') && !el[0].checked) {
141
- val = '0';
142
- }
143
- $('[data-' + id + ']', main).each(function() {
144
- var key = $(this).attr('data-' + id);
145
- key = key.split(':');
146
- //var hidden = $(this).data('hidden')? parseInt($(this).data('hidden')) : 0;
147
- var hidden = $(this).data('hidden')? $(this).data('hidden') : {};
148
- var ch = true;
149
- switch(key[0]) {
150
- case '=':
151
- case 'is':
152
- if(val == key[1]) {
153
- delete hidden[id];
154
- if(slide && $.isEmptyObject(hidden)) {
155
- $(this).prop('disabled', false).closest('.form-group').stop().slideDown(slide, function() {
156
- $(this).css({display: 'block'});
157
- });
158
- if(key[2]) {
159
- key[2] = $(this).data('value');
160
- } else {
161
- ch = false;
162
- }
163
- } else {
164
- ch = false;
165
- }
166
- $(this).data('hidden', hidden);
167
- } else {
168
- if($.isEmptyObject(hidden)) {
169
- if(key[2]) {
170
- $(this).closest('.form-group').stop().slideUp(slide, function() {
171
- $(this).css({display: 'none'});
172
- });
173
- } else {
174
- $(this).prop('disabled', true).closest('.form-group').stop().slideUp(slide, function() {
175
- $(this).css({display: 'none'});
176
- });
177
- }
178
- } else {
179
- ch = false;
180
- }
181
- hidden[id] = 1;
182
- $(this).data('hidden', hidden);
183
- }
184
- break;
185
- case '!=':
186
- case 'not':
187
- if(val == key[1]) {
188
- if($.isEmptyObject(hidden)) {
189
- if(key[2]) {
190
- $(this).closest('.form-group').stop().slideUp(slide, function() {
191
- $(this).css({display: 'none'});
192
- });
193
- } else {
194
- $(this).prop('disabled', true).closest('.form-group').stop().slideUp(slide, function() {
195
- $(this).css({display: 'none'});
196
- });
197
- }
198
- } else {
199
- ch = false;
200
- }
201
- hidden[id] = 1;
202
- $(this).data('hidden', hidden);
203
- } else {
204
- delete hidden[id];
205
- if(slide && $.isEmptyObject(hidden)) {
206
- $(this).prop('disabled', false).closest('.form-group').stop().slideDown(slide, function() {
207
- $(this).css({display: 'block'});
208
- });
209
- if(key[2] && slide) {
210
- key[2] = $(this).data('value');
211
- } else {
212
- ch = false;
213
- }
214
- } else {
215
- ch = false;
216
- }
217
- $(this).data('hidden', hidden);
218
- }
219
- break;
220
- }
221
- if(key[2] && ch) {
222
- if($(this).is(':checkbox')) {
223
- if(+($(this).prop('checked')) != parseInt(key[2])) {
224
- $(this).data('value', ($(this).prop('checked')? '1' : '0'));
225
- $(this).prop('checked', ('0' != key[2])).trigger('change');
226
- }
227
- } else {
228
- if($(this).val() != key[2]) {
229
- $(this).data('value', $(this).val());
230
- $(this).val(key[2]).trigger('change');
231
- }
232
- }
233
- }
234
- });
235
- }
236
- }
237
- });
 
 
 
 
 
 
 
 
 
 
 
238
 
239
  </script>
240
-
1
  <?php
2
+ // don't load directly.
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ die( '-1' );
5
  }
6
 
7
  /**
10
  global $gmGallery;
11
  ?>
12
  <div class="row">
13
+ <div class="col-lg-5 tabable tabs-left">
14
+ <ul class="nav nav-tabs" id="galleryTabs">
15
+ <?php if ( isset( $module_info ) ) { ?>
16
+ <li class="text-center">
17
+ <strong><?php echo $module_info['title']; ?></strong><a href="#chooseModuleModal" data-toggle="modal" style="padding:5px 0;"><img src="<?php echo esc_url( $term->module['url'] . '/screenshot.png' ); ?>" alt="<?php echo esc_attr( $module_info['title'] ); ?>" width="100" style="height:auto;"/></a>
18
+ </li>
19
+ <?php } else { ?>
20
+ <li class="text-center"><strong><?php echo $term->module['name']; ?></strong>
21
 
22
+ <p><?php _e( 'This module is broken or outdated. Please, go to Modules page and update/install module or choose another one for this gallery', 'grand-media' ); ?></p>
23
+ <a href="#chooseModuleModal" data-toggle="modal" style="padding:5px 0;"><img src="<?php echo esc_url( $term->module['url'] . '/screenshot.png' ); ?>" alt="<?php echo esc_attr( $term->module['name'] ); ?>" width="100" style="height:auto;"/></a>
24
+ </li>
25
+ <?php } ?>
26
+ <?php
27
+ if ( isset( $options_tree ) ) {
28
+ gmedia_gallery_options_nav( $options_tree );
29
+ }
30
+ ?>
31
+ </ul>
32
 
33
+ <div id="gallery_options_block" class="tab-content">
34
+ <?php
35
+ if ( isset( $options_tree ) ) {
36
+ gmedia_gallery_options_fieldset( $options_tree, $default_options, $gallery_settings );
37
+ }
38
+ ?>
39
+ </div>
40
 
41
+ </div>
42
+ <div class="col-lg-7">
43
+ <?php if ( $term_id || isset( $preset_module ) ) {
44
+ $bgcolor = empty( $gmGallery->options['preview_bgcolor'] ) ? 'ffffff' : $gmGallery->options['preview_bgcolor'];
45
+ $params['is_admin_preview'] = 1;
46
+ ?>
47
+ <div class="clearfix">
48
+ <div class="form-group pull-right" style="margin:-10px 0 5px 0;"><input type="text" data-type="color" class="form-control input-sm" id="preview_color" name="preview_bgcolor" value="<?php echo esc_attr( $bgcolor ); ?>" placeholder="ffffff" size="7"/></div>
49
+ <b><?php _e( 'Gallery Preview:' ); ?></b>
50
+ </div>
51
+ <div class="gallery_preview">
52
+ <iframe id="gallery_preview" style="background-color:<?php echo "#$bgcolor"; ?>;padding:5px;" name="gallery_preview" src="<?php echo esc_url( add_query_arg( $params, set_url_scheme( $gallery_link_default, 'admin' ) ) ); ?>"></iframe>
53
+ </div>
54
+ <?php } ?>
55
+ </div>
56
  </div>
57
  <script type="text/javascript">
58
+ jQuery(function($) {
59
+ var hash = window.location.hash;
60
+ if (hash) {
61
+ $('#galleryTabs a').eq(hash.replace('#tab-', '')).tab('show');
62
+ }
63
+ $('.gallery_preview').resizable();
64
+ $('#gmedia-edit-term').on('submit', function(e) {
65
+ if ($('#build_query_field').val() === '') {
66
+ var conf_txt = "<?php _e( "Warning: Query Args. field is empty! Show in gallery all files from Gmedia Library?" ) ?>";
67
+ if (!GmediaFunction.confirm(conf_txt)) {
68
+ e.preventDefault();
69
+ return false;
70
+ }
71
+ }
72
+ $(this).attr('action', $(this).attr('action') + '#tab-' + $('#galleryTabs li.active').index());
73
+ });
74
 
75
+ var main = $('#gallery_options_block');
76
 
77
+ $('input', main).filter('[data-type="color"]').minicolors({
78
+ animationSpeed: 50,
79
+ animationEasing: 'swing',
80
+ change: null,
81
+ changeDelay: 0,
82
+ control: 'hue',
83
+ //defaultValue: '',
84
+ hide: null,
85
+ hideSpeed: 100,
86
+ inline: false,
87
+ letterCase: 'lowercase',
88
+ opacity: false,
89
+ position: 'bottom left',
90
+ show: null,
91
+ showSpeed: 100,
92
+ theme: 'bootstrap'
93
+ });
94
+ $('#preview_color').on('change', function() {
95
+ var color = $(this).val();
96
+ $('#gallery_preview').css({backgroundColor: '#' + color});
97
+ }).minicolors({
98
+ animationSpeed: 50,
99
+ animationEasing: 'swing',
100
+ change: null,
101
+ changeDelay: 0,
102
+ control: 'hue',
103
+ //defaultValue: '',
104
+ hide: null,
105
+ hideSpeed: 100,
106
+ inline: false,
107
+ letterCase: 'lowercase',
108
+ opacity: false,
109
+ position: 'bottom right',
110
+ show: null,
111
+ showSpeed: 100,
112
+ theme: 'bootstrap'
113
+ });
114
 
115
+ $('input', main).filter('[data-type="rgba"]').spectrum({
116
+ showInput: true,
117
+ showAlpha: true,
118
+ allowEmpty: false,
119
+ preferredFormat: 'rgb'
120
+ });
121
 
122
+ $('[data-watch]', main).each(function() {
123
+ var el = $(this);
124
+ gmedia_options_conditional_logic(el, 0);
125
+ var event = el.attr('data-watch');
126
+ if (event) {
127
+ el.on(event, function() {
128
+ if ('change' === el.attr('data-watch')) {
129
+ $(this).blur().focus();
130
+ }
131
+ gmedia_options_conditional_logic($(this), 400);
132
+ });
133
+ }
134
+ });
135
 
136
+ function gmedia_options_conditional_logic(el, slide) {
137
+ if (el.is(':input')) {
138
+ var val = el.val();
139
+ var id = el.attr('id').toLowerCase();
140
+ if (el.is(':checkbox') && !el[0].checked) {
141
+ val = '0';
142
+ }
143
+ $('[data-' + id + ']', main).each(function() {
144
+ var key = $(this).attr('data-' + id);
145
+ key = key.split(':');
146
+ //var hidden = $(this).data('hidden')? parseInt($(this).data('hidden')) : 0;
147
+ var hidden = $(this).data('hidden') ? $(this).data('hidden') : {};
148
+ var ch = true;
149
+ switch (key[0]) {
150
+ case '=':
151
+ case 'is':
152
+ if (val === key[1]) {
153
+ delete hidden[id];
154
+ if (slide && $.isEmptyObject(hidden)) {
155
+ $(this).prop('disabled', false).closest('.form-group').stop().slideDown(slide, function() {
156
+ $(this).css({display: 'block'});
157
+ });
158
+ if (key[2]) {
159
+ key[2] = $(this).data('value');
160
+ }
161
+ else {
162
+ ch = false;
163
+ }
164
+ }
165
+ else {
166
+ ch = false;
167
+ }
168
+ $(this).data('hidden', hidden);
169
+ }
170
+ else {
171
+ if ($.isEmptyObject(hidden)) {
172
+ if (key[2]) {
173
+ $(this).closest('.form-group').stop().slideUp(slide, function() {
174
+ $(this).css({display: 'none'});
175
+ });
176
+ }
177
+ else {
178
+ $(this).prop('disabled', true).closest('.form-group').stop().slideUp(slide, function() {
179
+ $(this).css({display: 'none'});
180
+ });
181
+ }
182
+ }
183
+ else {
184
+ ch = false;
185
+ }
186
+ hidden[id] = 1;
187
+ $(this).data('hidden', hidden);
188
+ }
189
+ break;
190
+ case '!=':
191
+ case 'not':
192
+ if (val === key[1]) {
193
+ if ($.isEmptyObject(hidden)) {
194
+ if (key[2]) {
195
+ $(this).closest('.form-group').stop().slideUp(slide, function() {
196
+ $(this).css({display: 'none'});
197
+ });
198
+ }
199
+ else {
200
+ $(this).prop('disabled', true).closest('.form-group').stop().slideUp(slide, function() {
201
+ $(this).css({display: 'none'});
202
+ });
203
+ }
204
+ }
205
+ else {
206
+ ch = false;
207
+ }
208
+ hidden[id] = 1;
209
+ $(this).data('hidden', hidden);
210
+ }
211
+ else {
212
+ delete hidden[id];
213
+ if (slide && $.isEmptyObject(hidden)) {
214
+ $(this).prop('disabled', false).closest('.form-group').stop().slideDown(slide, function() {
215
+ $(this).css({display: 'block'});
216
+ });
217
+ if (key[2] && slide) {
218
+ key[2] = $(this).data('value');
219
+ }
220
+ else {
221
+ ch = false;
222
+ }
223
+ }
224
+ else {
225
+ ch = false;
226
+ }
227
+ $(this).data('hidden', hidden);
228
+ }
229
+ break;
230
+ }
231
+ if (key[2] && ch) {
232
+ if ($(this).is(':checkbox')) {
233
+ if (+($(this).prop('checked')) !== parseInt(key[2])) {
234
+ $(this).data('value', ($(this).prop('checked') ? '1' : '0'));
235
+ $(this).prop('checked', ('0' !== key[2])).trigger('change');
236
+ }
237
+ }
238
+ else {
239
+ if ($(this).val() !== key[2]) {
240
+ $(this).data('value', $(this).val());
241
+ $(this).val(key[2]).trigger('change');
242
+ }
243
+ }
244
+ }
245
+ });
246
+ }
247
+ }
248
+ });
249
 
250
  </script>
 
admin/pages/library/functions.php CHANGED
@@ -1,125 +1,128 @@
1
  <?php
2
 
3
- function gmedia_item_thumbnail($item){
4
- global $gmCore;
5
 
6
- $images = $gmCore->gm_get_media_image($item, 'all');
7
- $thumb = '<img class="gmedia-thumb" src="' . $images['thumb'] . '" alt=""/>';
8
 
9
- if(!empty($images['icon'])){
10
- $thumb .= '<img class="gmedia-typethumb" src="' . $images['icon'] . '" alt=""/>';
11
- }
12
 
13
- return $thumb;
14
  }
15
 
16
- function gmedia_item_actions($item){
17
- global $gmCore, $gmProcessor;
18
-
19
- if(!in_array($gmProcessor->mode, array('select_single', 'select_multiple'))){
20
- $share_icon = '<span class="glyphicon glyphicon-share"></span>';
21
- if('draft' !== $item->status){
22
- if(!empty($item->post_id)){
23
- $cloud_link = get_permalink($item->post_id);
24
- } else{
25
- $cloud_link = $gmCore->gmcloudlink($item->ID, 'single');
26
- }
27
- $share = '<a target="_blank" data-target="#shareModal" data-share="' . $item->ID . '" class="share-modal" title="' . __('Share Gmedia Post', 'grand-media') . '" href="' . $cloud_link . '">' . $share_icon . '</a>';
28
- } else{
29
- $share = "<span class='action-inactive'>$share_icon</span>";
30
- }
31
-
32
- $edit_icon = '<span class="glyphicon glyphicon-edit"></span>';
33
- if(gm_user_can('edit_media')){
34
- if(((int)$item->author == get_current_user_id()) || gm_user_can('edit_others_media')){
35
- $edit_data_data = $gmProcessor->gmediablank? '' : ' data-target="#previewModal" data-width="1200" data-height="500" data-cls="edit_gmedia_item" class="preview-modal"';
36
- $edit_data = '<a href="' . add_query_arg(array('page' => 'GrandMedia', 'mode' => 'edit', 'gmediablank' => 'library', 'gmedia__in' => $item->ID), $gmProcessor->url) . '"' . $edit_data_data . ' id="gmdataedit' . $item->ID . '" title="' . __('Edit Data', 'grand-media') . '">' . $edit_icon . '</a>';
37
- }
38
- } else{
39
- $edit_data = "<span class='action-inactive'>$edit_icon</span>";
40
- }
41
-
42
- $info_icon = '<span class="glyphicon glyphicon-info-sign"></span>';
43
- $metainfo = $gmCore->metadata_text($item->ID);
44
- if($metainfo){
45
- $info = '<a href="#metaInfo" data-target="#previewModal" data-metainfo="' . $item->ID . '" class="preview-modal" title="' . __('Exif/Meta Info', 'grand-media') . '">' . $info_icon . '</a>';
46
- $info .= '<div class="metainfo hidden" id="metainfo_' . $item->ID . '">' . nl2br($metainfo) . '</div>';
47
- } else{
48
- $info = "<span class='action-inactive'>$info_icon</span>";
49
- }
50
-
51
- $delete_icon = '<span class="glyphicon glyphicon-trash"></span>';
52
- if((gm_user_can('delete_media') && ((int)$item->author == get_current_user_id())) || gm_user_can('delete_others_media')){
53
- $delete = '<a class="text-danger" href="' . wp_nonce_url(gm_get_admin_url(array('do_gmedia' => 'delete',
54
- 'ids' => $item->ID
55
- )), 'gmedia_delete', '_wpnonce_delete') . '" data-confirm="' . sprintf(__("You are about to permanently delete %s file.\n\r'Cancel' to stop, 'OK' to delete.", "grand-media"), $item->gmuid) . '" title="' . __('Delete', 'grand-media') . '">' . $delete_icon . '</a>';
56
-
57
- if($gmCore->_get('showmore')){
58
- $erase_icon = '<span class="glyphicon glyphicon-erase"></span>';
59
- $db_delete = '<a class="text-danger" href="' . wp_nonce_url(gm_get_admin_url(array('do_gmedia' => 'delete__save_original',
60
- 'ids' => $item->ID
61
- )), 'gmedia_delete', '_wpnonce_delete') . '" data-confirm="' . sprintf(__("You are about to delete record from DB for %s file.\n\r'Cancel' to stop, 'OK' to delete.", "grand-media"), $item->gmuid) . '" title="' . __('Delete DB record (leave file on the server)', 'grand-media') . '">' . $erase_icon . '</a>';
62
- }
63
- } else{
64
- $delete = "<span class='action-inactive'>$delete_icon</span>";
65
- }
66
- }
67
-
68
- if('image' == $item->type && $item->editor){
69
- $edit_image_icon = '<span class="glyphicon glyphicon-adjust"></span>';
70
- if((gm_user_can('edit_media') && ((int)$item->author == get_current_user_id())) || gm_user_can('edit_others_media')){
71
- $edit_image = '<a href="' . add_query_arg(array('page' => 'GrandMedia', 'gmediablank' => 'image_editor', 'id' => $item->ID), $gmProcessor->url) . '" data-target="#gmeditModal" class="gmedit-modal" id="gmimageedit' . $item->ID . '" title="' . __('Edit Image', 'grand-media') . '">' . $edit_image_icon . '</a>';
72
- } else{
73
- $edit_image = "<span class='action-inactive'>$edit_image_icon</span>";
74
- }
75
-
76
- $show_icon = '<span class="glyphicon glyphicon-fullscreen"></span>';
77
- $show = '<a href="' . $gmCore->gm_get_media_image($item, 'web') . '" data-target="#previewModal" data-width="' . $item->msize['width'] . '" data-height="' . $item->msize['height'] . '" class="preview-modal" title="' . esc_attr(__('Show', 'grand-media') . ' ' . $item->title) . '">' . $show_icon . '</a>';
78
-
79
- } elseif(in_array($item->ext, array('mp3', 'ogg', 'wav', 'ogg', 'mp4', 'mpeg', 'webm'))){
80
- $show_icon = '<span class="glyphicon glyphicon-play"></span>';
81
- $show = '<a href="' . $item->url . '" data-target="#previewModal" data-width="' . $item->msize['width'] . '" data-height="' . $item->msize['height'] . '" class="preview-modal" title="' . esc_attr(__('Play', 'grand-media') . ' ' . $item->title) . '">' . $show_icon . '</a>';
82
- } else{
83
- $show_icon = '<span class="glyphicon glyphicon-cloud-download"></span>';
84
- $show = '<a href="' . $item->url . '" title="' . __('Download', 'grand-media') . '" download="' . $item->gmuid . '">' . $show_icon . '</a>';
85
- }
86
-
87
- $duplicate_icon = '<span class="glyphicon glyphicon-duplicate"></span>';
88
- $duplicate = '<a href="' . wp_nonce_url(gm_get_admin_url(array('do_gmedia' => 'duplicate', 'ids' => $item->ID)), 'gmedia_action', '_wpnonce_action') . '" title="' . __('Duplicate', 'grand-media') . '">' . $duplicate_icon . '</a>';
89
-
90
- $actions = compact('share', 'edit_data', 'edit_image', 'show', 'info', 'duplicate', 'delete', 'db_delete');
91
-
92
- return apply_filters('gmedia_item_actions', $actions);
 
 
 
93
  }
94
 
95
 
96
- function gmedia_filter_message(){
97
- global $gmProcessor;
98
- do_action('before_gmedia_filter_message');
99
- if(!empty($gmProcessor->filters)){
100
- echo '<div class="custom-message alert alert-info">';
101
- foreach($gmProcessor->filters as $key => $value){
102
- echo '<div class="custom-message-row">';
103
- echo '<strong><a href="#libModal" data-modal="' . $key . '" data-action="gmedia_get_modal" class="gmedia-modal">' . $value['title'] . '</a>: </strong>';
104
- echo implode(', ', $value['filter']);
105
- echo '</div>';
106
- }
107
- echo '</div>';
108
- }
109
  }
110
 
111
- function gmedia_alert_message(){
112
- global $gmProcessor;
113
- do_action('before_gmedia_alert_message');
114
- if(($gmProcessor->mode == 'edit') && gm_user_can('show_others_media') && !gm_user_can('edit_others_media')){
115
- ?>
116
- <div class="alert alert-warning alert-dismissible" role="alert" style="margin-bottom:0">
117
- <button type="button" class="close" data-dismiss="alert">
118
- <span aria-hidden="true">&times;</span><span class="sr-only"><?php _e('Close', 'grand-media'); ?></span></button>
119
- <strong><?php _e('Info:', 'grand-media'); ?></strong> <?php _e('You are not allowed to edit others media', 'grand-media'); ?>
120
- </div>
121
- <?php
122
- }
123
  }
124
 
125
  /**
@@ -127,30 +130,29 @@ function gmedia_alert_message(){
127
  *
128
  * @return string
129
  */
130
- function gmedia_waveform_player($item){
131
- global $gmDB;
132
- $peaks = $gmDB->get_metadata('gmedia', $item->ID, '_peaks', true);
133
- if($peaks){
134
- if('[]' === $peaks){
135
- $gmDB->delete_metadata('gmedia', $item->ID, '_peaks');
136
- $peaks = '';
137
- } else{
138
- $peaks = json_decode($peaks);
139
- while(900 < count($peaks)){
140
- $peaks = array_map('reset', array_chunk($peaks, 2));
141
- }
142
- $peaks = json_encode($peaks);
143
- }
144
- } else{
145
- $peaks = '';
146
- }
147
- $content = '
148
  <div class="gm-waveform-player" data-id="' . $item->ID . '" data-file="' . $item->url . '" data-peaks="' . $peaks . '">
149
- <div id="ws' . $item->ID . '"></div>' . ($peaks? '' : ('<button type="button" class="btn btn-sm btn-info gm-waveform">' . __('Create & Save WaveForm', 'grand-media') . '</button>')) . '<button type="button" class="btn btn-sm btn-info gm-play" style="display:none;">' . __('Play', 'grand-media') . '</button>
150
- <button type="button" class="btn btn-sm btn-info gm-pause" style="display:none;">' . __('Pause', 'grand-media') . '</button>
151
  <span style="float:none;" class="spinner"></span>
152
  </div>';
153
 
154
- return $content;
155
  }
156
-
1
  <?php
2
 
3
+ function gmedia_item_thumbnail( $item ) {
4
+ global $gmCore;
5
 
6
+ $images = $gmCore->gm_get_media_image( $item, 'all' );
7
+ $thumb = '<img class="gmedia-thumb" src="' . $images['thumb'] . '" alt=""/>';
8
 
9
+ if ( ! empty( $images['icon'] ) ) {
10
+ $thumb .= '<img class="gmedia-typethumb" src="' . $images['icon'] . '" alt=""/>';
11
+ }
12
 
13
+ return $thumb;
14
  }
15
 
16
+ function gmedia_item_actions( $item ) {
17
+ global $gmCore, $gmProcessor;
18
+
19
+ if ( ! in_array( $gmProcessor->mode, [ 'select_single', 'select_multiple' ], true ) ) {
20
+ $share_icon = '<span class="glyphicon glyphicon-share"></span>';
21
+ if ( 'draft' !== $item->status ) {
22
+ if ( ! empty( $item->post_id ) ) {
23
+ $cloud_link = get_permalink( $item->post_id );
24
+ } else {
25
+ $cloud_link = $gmCore->gmcloudlink( $item->ID, 'single' );
26
+ }
27
+ $share = '<a target="_blank" data-target="#shareModal" data-share="' . $item->ID . '" class="share-modal" title="' . __( 'Share Gmedia Post', 'grand-media' ) . '" href="' . $cloud_link . '">' . $share_icon . '</a>';
28
+ } else {
29
+ $share = "<span class='action-inactive'>$share_icon</span>";
30
+ }
31
+
32
+ $edit_icon = '<span class="glyphicon glyphicon-edit"></span>';
33
+ if ( gm_user_can( 'edit_media' ) ) {
34
+ if ( ( (int) $item->author === get_current_user_id() ) || gm_user_can( 'edit_others_media' ) ) {
35
+ $edit_data_data = $gmProcessor->gmediablank ? '' : ' data-target="#previewModal" data-width="1200" data-height="500" data-cls="edit_gmedia_item" class="preview-modal"';
36
+ $edit_data = '<a href="' . add_query_arg( [ 'page' => 'GrandMedia', 'mode' => 'edit', 'gmediablank' => 'library', 'gmedia__in' => $item->ID ], $gmProcessor->url ) . '"' . $edit_data_data . ' id="gmdataedit' . $item->ID . '" title="' . __( 'Edit Data', 'grand-media' ) . '">' . $edit_icon . '</a>';
37
+ }
38
+ } else {
39
+ $edit_data = "<span class='action-inactive'>$edit_icon</span>";
40
+ }
41
+
42
+ $info_icon = '<span class="glyphicon glyphicon-info-sign"></span>';
43
+ $metainfo = $gmCore->metadata_text( $item->ID );
44
+ if ( $metainfo ) {
45
+ $info = '<a href="#metaInfo" data-target="#previewModal" data-metainfo="' . $item->ID . '" class="preview-modal" title="' . __( 'Exif/Meta Info', 'grand-media' ) . '">' . $info_icon . '</a>';
46
+ $info .= '<div class="metainfo hidden" id="metainfo_' . $item->ID . '">' . nl2br( $metainfo ) . '</div>';
47
+ } else {
48
+ $info = "<span class='action-inactive'>$info_icon</span>";
49
+ }
50
+
51
+ $db_delete = '';
52
+ $delete_icon = '<span class="glyphicon glyphicon-trash"></span>';
53
+ if ( ( gm_user_can( 'delete_media' ) && ( (int) $item->author === get_current_user_id() ) ) || gm_user_can( 'delete_others_media' ) ) {
54
+ $delete = '<a class="text-danger" href="' . wp_nonce_url( gm_get_admin_url( [
55
+ 'do_gmedia' => 'delete',
56
+ 'ids' => $item->ID,
57
+ ] ), 'gmedia_delete', '_wpnonce_delete' ) . '" data-confirm="' . sprintf( __( "You are about to permanently delete %s file.\n\r'Cancel' to stop, 'OK' to delete.", "grand-media" ), $item->gmuid ) . '" title="' . __( 'Delete', 'grand-media' ) . '">' . $delete_icon . '</a>';
58
+
59
+ if ( $gmCore->_get( 'showmore' ) ) {
60
+ $erase_icon = '<span class="glyphicon glyphicon-erase"></span>';
61
+ $db_delete = '<a class="text-danger" href="' . wp_nonce_url( gm_get_admin_url( [
62
+ 'do_gmedia' => 'delete__save_original',
63
+ 'ids' => $item->ID,
64
+ ] ), 'gmedia_delete', '_wpnonce_delete' ) . '" data-confirm="' . sprintf( __( "You are about to delete record from DB for %s file.\n\r'Cancel' to stop, 'OK' to delete.", "grand-media" ), $item->gmuid ) . '" title="' . __( 'Delete DB record (leave file on the server)', 'grand-media' ) . '">' . $erase_icon . '</a>';
65
+ }
66
+ } else {
67
+ $delete = "<span class='action-inactive'>$delete_icon</span>";
68
+ }
69
+ }
70
+
71
+ if ( 'image' === $item->type && $item->editor ) {
72
+ $edit_image_icon = '<span class="glyphicon glyphicon-adjust"></span>';
73
+ if ( ( gm_user_can( 'edit_media' ) && ( (int) $item->author === get_current_user_id() ) ) || gm_user_can( 'edit_others_media' ) ) {
74
+ $edit_image = '<a href="' . add_query_arg( [ 'page' => 'GrandMedia', 'gmediablank' => 'image_editor', 'id' => $item->ID ], $gmProcessor->url ) . '" data-target="#gmeditModal" class="gmedit-modal" id="gmimageedit' . $item->ID . '" title="' . __( 'Edit Image', 'grand-media' ) . '">' . $edit_image_icon . '</a>';
75
+ } else {
76
+ $edit_image = "<span class='action-inactive'>$edit_image_icon</span>";
77
+ }
78
+
79
+ $show_icon = '<span class="glyphicon glyphicon-fullscreen"></span>';
80
+ $show = '<a href="' . $gmCore->gm_get_media_image( $item, 'web' ) . '" data-target="#previewModal" data-width="' . $item->msize['width'] . '" data-height="' . $item->msize['height'] . '" class="preview-modal" title="' . esc_attr__( 'Show Large Image', 'grand-media' ) . '">' . $show_icon . '</a>';
81
+
82
+ } elseif ( in_array( $item->ext, [ 'mp3', 'ogg', 'wav', 'ogg', 'mp4', 'mpeg', 'webm' ], true ) ) {
83
+ $show_icon = '<span class="glyphicon glyphicon-play"></span>';
84
+ $show = '<a href="' . $item->url . '" data-target="#previewModal" data-width="' . $item->msize['width'] . '" data-height="' . $item->msize['height'] . '" class="preview-modal" title="' . esc_attr__( 'Play', 'grand-media' ) . '">' . $show_icon . '</a>';
85
+ } else {
86
+ $show_icon = '<span class="glyphicon glyphicon-cloud-download"></span>';
87
+ $show = '<a href="' . $item->url . '" title="' . __( 'Download', 'grand-media' ) . '" download="' . $item->gmuid . '">' . $show_icon . '</a>';
88
+ }
89
+
90
+ $duplicate_icon = '<span class="glyphicon glyphicon-duplicate"></span>';
91
+ $duplicate = '<a href="' . wp_nonce_url( gm_get_admin_url( [ 'do_gmedia' => 'duplicate', 'ids' => $item->ID ] ), 'gmedia_action', '_wpnonce_action' ) . '" title="' . __( 'Duplicate', 'grand-media' ) . '">' . $duplicate_icon . '</a>';
92
+
93
+ $actions = compact( 'share', 'edit_data', 'edit_image', 'show', 'info', 'duplicate', 'delete', 'db_delete' );
94
+
95
+ return apply_filters( 'gmedia_item_actions', $actions );
96
  }
97
 
98
 
99
+ function gmedia_filter_message() {
100
+ global $gmProcessor;
101
+ do_action( 'before_gmedia_filter_message' );
102
+ if ( ! empty( $gmProcessor->filters ) ) {
103
+ echo '<div class="custom-message alert alert-info">';
104
+ foreach ( $gmProcessor->filters as $key => $value ) {
105
+ echo '<div class="custom-message-row">';
106
+ echo '<strong><a href="#libModal" data-modal="' . esc_attr( $key ) . '" data-action="gmedia_get_modal" class="gmedia-modal">' . esc_html( $value['title'] ) . '</a>: </strong>';
107
+ echo esc_html( implode( ', ', $value['filter'] ) );
108
+ echo '</div>';
109
+ }
110
+ echo '</div>';
111
+ }
112
  }
113
 
114
+ function gmedia_alert_message() {
115
+ global $gmProcessor;
116
+ do_action( 'before_gmedia_alert_message' );
117
+ if ( ( $gmProcessor->mode === 'edit' ) && gm_user_can( 'show_others_media' ) && ! gm_user_can( 'edit_others_media' ) ) {
118
+ ?>
119
+ <div class="alert alert-warning alert-dismissible" role="alert" style="margin-bottom:0">
120
+ <button type="button" class="close" data-dismiss="alert">
121
+ <span aria-hidden="true">&times;</span><span class="sr-only"><?php _e( 'Close', 'grand-media' ); ?></span></button>
122
+ <strong><?php _e( 'Info:', 'grand-media' ); ?></strong> <?php _e( 'You are not allowed to edit others media', 'grand-media' ); ?>
123
+ </div>
124
+ <?php
125
+ }
126
  }
127
 
128
  /**
130
  *
131
  * @return string
132
  */
133
+ function gmedia_waveform_player( $item ) {
134
+ global $gmDB;
135
+ $peaks = $gmDB->get_metadata( 'gmedia', $item->ID, '_peaks', true );
136
+ if ( $peaks ) {
137
+ if ( '[]' === $peaks ) {
138
+ $gmDB->delete_metadata( 'gmedia', $item->ID, '_peaks' );
139
+ $peaks = '';
140
+ } else {
141
+ $peaks = json_decode( $peaks );
142
+ while ( 900 < count( $peaks ) ) {
143
+ $peaks = array_map( 'reset', array_chunk( $peaks, 2 ) );
144
+ }
145
+ $peaks = wp_json_encode( $peaks );
146
+ }
147
+ } else {
148
+ $peaks = '';
149
+ }
150
+ $content = '
151
  <div class="gm-waveform-player" data-id="' . $item->ID . '" data-file="' . $item->url . '" data-peaks="' . $peaks . '">
152
+ <div id="ws' . $item->ID . '"></div>' . ( $peaks ? '' : ( '<button type="button" class="btn btn-sm btn-info gm-waveform">' . __( 'Create & Save WaveForm', 'grand-media' ) . '</button>' ) ) . '<button type="button" class="btn btn-sm btn-info gm-play" style="display:none;">' . __( 'Play', 'grand-media' ) . '</button>
153
+ <button type="button" class="btn btn-sm btn-info gm-pause" style="display:none;">' . __( 'Pause', 'grand-media' ) . '</button>
154
  <span style="float:none;" class="spinner"></span>
155
  </div>';
156
 
157
+ return $content;
158
  }
 
admin/pages/library/library.php CHANGED
@@ -1,180 +1,180 @@
1
- <?php
2
- /**
3
- * Gmedia Library
4
- */
5
-
6
- // don't load directly
7
- if(!defined('ABSPATH')) {
8
- die('-1');
9
- }
10
-
11
- global $user_ID, $gmDB, $gmCore, $gmGallery, $gmProcessor, $gmProcessorLibrary;
12
-
13
- $panel_class = array();
14
- $gmedia_url = $gmProcessor->url;
15
- $gmedia_user_options = $gmProcessor->user_options;
16
-
17
- $_get_filter = $gmCore->_get('filter');
18
- if($_get_filter && ($_get_filter != 'selected')){
19
- $gmProcessorLibrary->query_args['mime_type'] = $_get_filter;
20
- }
21
-
22
- $gmedia_query = $gmDB->get_gmedias($gmProcessorLibrary->query_args);
23
-
24
- $gmedia_filter = $gmDB->filter;
25
- $resultPerPage = $gmDB->resultPerPage;
26
- $openPage = $gmDB->openPage;
27
- $perPages = $gmDB->perPages;
28
- $idx0 = $perPages * ($openPage - 1);
29
-
30
- if(isset($gmedia_filter['author__in']) && !gm_user_can('show_others_media')){
31
- unset($gmDB->filter['author__in']);
32
- unset($gmedia_filter['author__in']);
33
- }
34
- if($_get_filter && ($_get_filter != 'selected')){
35
- unset($gmDB->filter['mime_type']);
36
- unset($gmedia_filter['mime_type']);
37
- }
38
- if($gmProcessor->edit_term){
39
- $taxin = "{$gmProcessor->taxterm}__in";
40
- if(isset($gmedia_filter[$taxin]) && $gmedia_filter[$taxin] == $gmProcessorLibrary->query_args[$taxin]){
41
- unset($gmDB->filter[$taxin]);
42
- unset($gmedia_filter[$taxin]);
43
- }
44
- $gmProcessorLibrary->dbfilter = $gmedia_filter;
45
- }
46
-
47
- $gmedia_count = $gmDB->count_gmedia();
48
- $gmedia_pager = $gmDB->query_pager();
49
-
50
- $display_mode_gmedia = $gmProcessor->display_mode;
51
-
52
- $panel_class[] = 'panel-fixed-header';
53
- $panel_class[] = "display-as-{$display_mode_gmedia}";
54
- if($gmProcessor->user_options['grid_cell_fit_gmedia']) {
55
- $panel_class[] = 'invert-ratio';
56
- }
57
- if(!empty($gmedia_filter)) {
58
- $panel_class[] = 'gmedia-filtered';
59
- }
60
- if($gmProcessorLibrary->mode) {
61
- $panel_class[] = "mode__{$gmProcessorLibrary->mode}";
62
- }
63
-
64
- ?>
65
-
66
- <?php gmedia_filter_message(); ?>
67
-
68
- <div class="panel panel-default <?php gm_panel_classes($panel_class); ?>" id="gmedia-panel">
69
-
70
- <?php include(dirname(__FILE__) . '/tpl/panel-heading.php'); ?>
71
-
72
- <div class="panel-body"></div>
73
- <div class="list-group clearfix" id="gm-list-table" data-idx0="<?php echo $idx0 + 1; ?>">
74
- <?php
75
- if(count($gmedia_query)) {
76
-
77
- gmedia_alert_message();
78
-
79
- if(!($gmProcessor->mode == 'edit')) {
80
- foreach($gmedia_query as &$item) {
81
- gmedia_item_more_data($item);
82
-
83
- $item->classes = array('gmedia-' . $item->type . '-item');
84
- if('publish' != $item->status) {
85
- if('private' == $item->status) {
86
- $item->classes[] = 'list-group-item-info';
87
- } elseif('draft' == $item->status) {
88
- $item->classes[] = 'list-group-item-warning';
89
- }
90
- }
91
- $item->selected = in_array($item->ID, (array)$gmProcessor->selected_items);
92
- if($item->selected && ($gmProcessor->mode != 'select_single')){
93
- $item->classes[] = 'gm-selected';
94
- }
95
- $item->in_stack = in_array($item->ID, (array)$gmProcessor->stack_items);
96
-
97
- include(dirname(__FILE__) . "/tpl/{$display_mode_gmedia}-item.php");
98
- }
99
- if('grid' == $display_mode_gmedia){
100
- echo '<div class="gm-item-cell-blank"></div><div class="gm-item-cell-blank"></div><div class="gm-item-cell-blank"></div><div class="gm-item-cell-blank"></div><div class="gm-item-cell-blank"></div><div class="gm-item-cell-blank"></div>';
101
- }
102
- } elseif(gm_user_can('edit_media')) {
103
- $gm_category_terms = $gmDB->get_terms('gmedia_category', array('fields' => 'names'));
104
- $gm_tag_terms = $gmDB->get_terms('gmedia_tag', array('fields' => 'names'));
105
- ?>
106
- <script type="text/javascript">
107
- var gmedia_categories = <?php echo json_encode($gm_category_terms); ?>;
108
- var gmedia_tags = <?php echo json_encode($gm_tag_terms); ?>;
109
- </script>
110
- <?php
111
- foreach($gmedia_query as &$item) {
112
- gmedia_item_more_data($item);
113
-
114
- $item->classes = array('gmedia-' . $item->type . '-item');
115
- if('publish' != $item->status) {
116
- if('private' == $item->status) {
117
- $item->classes[] = 'list-group-item-info';
118
- } elseif('draft' == $item->status) {
119
- $item->classes[] = 'list-group-item-warning';
120
- }
121
- }
122
- $item->selected = in_array($item->ID, (array)$gmProcessor->selected_items);
123
- if($item->selected){
124
- $item->classes[] = 'gm-selected';
125
- }
126
- $item->in_stack = in_array($item->ID, (array)$gmProcessor->stack_items);
127
-
128
- if(((int)$item->author != $user_ID) && !gm_user_can('edit_others_media')) {
129
- include(dirname(__FILE__) . '/tpl/list-item.php');
130
- } else {
131
- include(dirname(__FILE__) . '/tpl/edit-item.php');
132
- }
133
- }
134
- }
135
- } else {
136
- include(dirname(__FILE__) . '/tpl/no-items.php');
137
- } ?>
138
- </div>
139
-
140
- <?php
141
- include(dirname(__FILE__) . '/tpl/panel-footer.php');
142
-
143
- wp_original_referer_field(true, 'previous');
144
- wp_nonce_field('GmediaGallery');
145
- ?>
146
- </div>
147
-
148
- <div class="modal fade gmedia-modal" id="libModal" tabindex="-1" role="dialog" aria-hidden="true">
149
- <div class="modal-dialog"></div>
150
- </div>
151
- <?php if(gm_user_can('edit_media')) { ?>
152
- <div class="modal fade gmedia-modal" id="gmeditModal" tabindex="-1" role="dialog" aria-hidden="true">
153
- <div class="modal-dialog modal-lg">
154
- <div class="modal-content"></div>
155
- </div>
156
- </div>
157
- <?php } ?>
158
- <div class="modal fade gmedia-modal" id="previewModal" tabindex="-1" role="dialog" aria-hidden="true">
159
- <div class="modal-dialog">
160
- <div class="modal-content">
161
- <div class="modal-header">
162
- <div class="btn-toolbar pull-right" style="margin-top:-4px;">
163
- <button type="button" class="btn btn-primary"><?php _e('Submit', 'grand-media'); ?></button>
164
- <button type="button" class="btn btn-default" data-dismiss="modal"><?php _e('Close', 'grand-media'); ?></button>
165
- </div>
166
- <h4 class="modal-title"></h4>
167
- </div>
168
- <div class="modal-body"></div>
169
- </div>
170
- </div>
171
- </div>
172
-
173
- <?php
174
- include(GMEDIA_ABSPATH . 'admin/tpl/modal-share.php');
175
-
176
- if($gmProcessor->mode == 'edit') {
177
- $customfield_meta_type = 'gmedia';
178
- include(GMEDIA_ABSPATH . 'admin/tpl/modal-customfield.php');
179
- } ?>
180
-
1
+ <?php
2
+ /**
3
+ * Gmedia Library
4
+ */
5
+
6
+ // don't load directly.
7
+ if ( ! defined( 'ABSPATH' ) ) {
8
+ die( '-1' );
9
+ }
10
+
11
+ global $user_ID, $gmDB, $gmCore, $gmGallery, $gmProcessor, $gmProcessorLibrary;
12
+
13
+ $panel_class = [];
14
+ $gmedia_url = $gmProcessor->url;
15
+ $gmedia_user_options = $gmProcessor->user_options;
16
+
17
+ $_get_filter = $gmCore->_get( 'filter' );
18
+ if ( $_get_filter && ( $_get_filter !== 'selected' ) ) {
19
+ $gmProcessorLibrary->query_args['mime_type'] = $_get_filter;
20
+ }
21
+
22
+ $gmedia_query = $gmDB->get_gmedias( $gmProcessorLibrary->query_args );
23
+
24
+ $gmedia_filter = $gmDB->filter;
25
+ $resultPerPage = $gmDB->resultPerPage;
26
+ $openPage = $gmDB->openPage;
27
+ $perPages = $gmDB->perPages;
28
+ $idx0 = $perPages * ( $openPage - 1 );
29
+
30
+ if ( isset( $gmedia_filter['author__in'] ) && ! gm_user_can( 'show_others_media' ) ) {
31
+ unset( $gmDB->filter['author__in'] );
32
+ unset( $gmedia_filter['author__in'] );
33
+ }
34
+ if ( $_get_filter && ( $_get_filter !== 'selected' ) ) {
35
+ unset( $gmDB->filter['mime_type'] );
36
+ unset( $gmedia_filter['mime_type'] );
37
+ }
38
+ if ( $gmProcessor->edit_term ) {
39
+ $taxin = "{$gmProcessor->taxterm}__in";
40
+ if ( isset( $gmedia_filter[ $taxin ] ) && $gmedia_filter[ $taxin ] === $gmProcessorLibrary->query_args[ $taxin ] ) {
41
+ unset( $gmDB->filter[ $taxin ] );
42
+ unset( $gmedia_filter[ $taxin ] );
43
+ }
44
+ $gmProcessorLibrary->dbfilter = $gmedia_filter;
45
+ }
46
+
47
+ $gmedia_count = $gmDB->count_gmedia();
48
+ $gmedia_pager = $gmDB->query_pager();
49
+
50
+ $display_mode_gmedia = $gmProcessor->display_mode;
51
+
52
+ $panel_class[] = 'panel-fixed-header';
53
+ $panel_class[] = "display-as-{$display_mode_gmedia}";
54
+ if ( $gmProcessor->user_options['grid_cell_fit_gmedia'] ) {
55
+ $panel_class[] = 'invert-ratio';
56
+ }
57
+ if ( ! empty( $gmedia_filter ) ) {
58
+ $panel_class[] = 'gmedia-filtered';
59
+ }
60
+ if ( $gmProcessorLibrary->mode ) {
61
+ $panel_class[] = "mode__{$gmProcessorLibrary->mode}";
62
+ }
63
+
64
+ ?>
65
+
66
+ <?php gmedia_filter_message(); ?>
67
+
68
+ <div class="panel panel-default <?php gm_panel_classes( $panel_class ); ?>" id="gmedia-panel">
69
+
70
+ <?php include dirname( __FILE__ ) . '/tpl/panel-heading.php'; ?>
71
+
72
+ <div class="panel-body"></div>
73
+ <div class="list-group clearfix" id="gm-list-table" data-idx0="<?php echo absint( $idx0 + 1 ); ?>">
74
+ <?php
75
+ if ( count( $gmedia_query ) ) {
76
+
77
+ gmedia_alert_message();
78
+
79
+ if ( ! ( $gmProcessor->mode === 'edit' ) ) {
80
+ foreach ( $gmedia_query as &$item ) {
81
+ gmedia_item_more_data( $item );
82
+
83
+ $item->classes = [ 'gmedia-' . $item->type . '-item' ];
84
+ if ( 'publish' !== $item->status ) {
85
+ if ( 'private' === $item->status ) {
86
+ $item->classes[] = 'list-group-item-info';
87
+ } elseif ( 'draft' === $item->status ) {
88
+ $item->classes[] = 'list-group-item-warning';
89
+ }
90
+ }
91
+ $item->selected = in_array( $item->ID, (array) $gmProcessor->selected_items, true );
92
+ if ( $item->selected && ( $gmProcessor->mode !== 'select_single' ) ) {
93
+ $item->classes[] = 'gm-selected';
94
+ }
95
+ $item->in_stack = in_array( $item->ID, (array) $gmProcessor->stack_items, true );
96
+
97
+ include dirname( __FILE__ ) . "/tpl/{$display_mode_gmedia}-item.php";
98
+ }
99
+ if ( 'grid' === $display_mode_gmedia ) {
100
+ echo '<div class="gm-item-cell-blank"></div><div class="gm-item-cell-blank"></div><div class="gm-item-cell-blank"></div><div class="gm-item-cell-blank"></div><div class="gm-item-cell-blank"></div><div class="gm-item-cell-blank"></div>';
101
+ }
102
+ } elseif ( gm_user_can( 'edit_media' ) ) {
103
+ $gm_category_terms = $gmDB->get_terms( 'gmedia_category', [ 'fields' => 'names' ] );
104
+ $gm_tag_terms = $gmDB->get_terms( 'gmedia_tag', [ 'fields' => 'names' ] );
105
+ ?>
106
+ <script type="text/javascript">
107
+ var gmedia_categories = <?php echo wp_json_encode( $gm_category_terms ); ?>;
108
+ var gmedia_tags = <?php echo wp_json_encode( $gm_tag_terms ); ?>;
109
+ </script>
110
+ <?php
111
+ foreach ( $gmedia_query as &$item ) {
112
+ gmedia_item_more_data( $item );
113
+
114
+ $item->classes = [ 'gmedia-' . $item->type . '-item' ];
115
+ if ( 'publish' !== $item->status ) {
116
+ if ( 'private' === $item->status ) {
117
+ $item->classes[] = 'list-group-item-info';
118
+ } elseif ( 'draft' === $item->status ) {
119
+ $item->classes[] = 'list-group-item-warning';
120
+ }
121
+ }
122
+ $item->selected = in_array( $item->ID, (array) $gmProcessor->selected_items, true );
123
+ if ( $item->selected ) {
124
+ $item->classes[] = 'gm-selected';
125
+ }
126
+ $item->in_stack = in_array( $item->ID, (array) $gmProcessor->stack_items, true );
127
+
128
+ if ( ( (int) $item->author !== $user_ID ) && ! gm_user_can( 'edit_others_media' ) ) {
129
+ include dirname( __FILE__ ) . '/tpl/list-item.php';
130
+ } else {
131
+ include dirname( __FILE__ ) . '/tpl/edit-item.php';
132
+ }
133
+ }
134
+ }
135
+ } else {
136
+ include dirname( __FILE__ ) . '/tpl/no-items.php';
137
+ } ?>
138
+ </div>
139
+
140
+ <?php
141
+ include dirname( __FILE__ ) . '/tpl/panel-footer.php';
142
+
143
+ wp_original_referer_field( true, 'previous' );
144
+ wp_nonce_field( 'GmediaGallery' );
145
+ ?>
146
+ </div>
147
+
148
+ <div class="modal fade gmedia-modal" id="libModal" tabindex="-1" role="dialog" aria-hidden="true">
149
+ <div class="modal-dialog"></div>
150
+ </div>
151
+ <?php if ( gm_user_can( 'edit_media' ) ) { ?>
152
+ <div class="modal fade gmedia-modal" id="gmeditModal" tabindex="-1" role="dialog" aria-hidden="true">
153
+ <div class="modal-dialog modal-lg">
154
+ <div class="modal-content"></div>
155
+ </div>
156
+ </div>
157
+ <?php } ?>
158
+ <div class="modal fade gmedia-modal" id="previewModal" tabindex="-1" role="dialog" aria-hidden="true">
159
+ <div class="modal-dialog">
160
+ <div class="modal-content">
161
+ <div class="modal-header">
162
+ <div class="btn-toolbar pull-right" style="margin-top:-4px;">
163
+ <button type="button" class="btn btn-primary"><?php _e( 'Submit', 'grand-media' ); ?></button>
164
+ <button type="button" class="btn btn-default" data-dismiss="modal"><?php _e( 'Close', 'grand-media' ); ?></button>
165
+ </div>
166
+ <h4 class="modal-title"></h4>
167
+ </div>
168
+ <div class="modal-body"></div>
169
+ </div>
170
+ </div>
171
+ </div>
172
+
173
+ <?php
174
+ include GMEDIA_ABSPATH . 'admin/tpl/modal-share.php';
175
+
176
+ if ( $gmProcessor->mode === 'edit' ) {
177
+ $customfield_meta_type = 'gmedia';
178
+ include GMEDIA_ABSPATH . 'admin/tpl/modal-customfield.php';
179
+ }
180
+ ?>
admin/pages/library/tpl/edit-item.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- // don't load directly
3
  if ( ! defined( 'ABSPATH' ) ) {
4
  die( '-1' );
5
  }
@@ -8,83 +8,83 @@ if ( ! defined( 'ABSPATH' ) ) {
8
  * Edit Gmedia Item
9
  */
10
  ?>
11
- <form class="cb_list-item list-group-item row d-row edit-gmedia <?php echo implode( ' ', $item->classes ); ?>" id="list-item-<?php echo $item->ID; ?>" data-id="<?php echo $item->ID; ?>" data-type="<?php echo $item->type; ?>" role="form">
12
- <div class="col-sm-4" style="max-width:340px;">
13
- <input name="ID" type="hidden" value="<?php echo $item->ID; ?>"/>
14
- <div class="thumbwrap">
15
- <div class="cb_media-object">
16
- <span data-clicktarget="gmimageedit<?php echo $item->ID; ?>" class="thumbnail gmedia-cover-image">
17
  <?php echo gmedia_item_thumbnail( $item ); ?>
18
  </span>
19
- </div>
20
- <label class="gm-item-check"><input name="doaction[]" type="checkbox"<?php echo $item->selected ? ' checked="checked"' : ''; ?> data-type="<?php echo $item->type; ?>" value="<?php echo $item->ID; ?>"/></label>
21
- <label class="gm-stack hidden"><input name="stack[]" type="checkbox"<?php echo $item->in_stack ? ' checked="checked"' : ''; ?> data-type="<?php echo $item->type; ?>" value="<?php echo $item->ID; ?>"/></label>
22
- </div>
23
- <div class="gmedia-actions">
24
  <?php $media_action_links = gmedia_item_actions( $item );
25
  unset( $media_action_links['edit_data'] );
26
  echo implode( ' | ', $media_action_links );
27
  ?>
28
- </div>
29
  <?php
30
- if ( 'audio' == $item->type ) {
31
  echo gmedia_waveform_player( $item );
32
  }
33
  ?>
34
- <div class="form-group">
35
- <label><?php _e( 'Related Media', 'grand-media' ); ?>:
36
- <a href="<?php echo $gmCore->get_admin_url(
37
- array(
38
  'page' => 'GrandMedia',
39
  'mode' => 'select_multiple',
40
- 'gmediablank' => 'library'
41
- ), array(), true ); ?>"
42
- class="preview-modal"
43
- data-target="#previewModal"
44
- data-width="1200"
45
- data-height="500"
46
- data-cls="select_gmedia_related"
47
- title="<?php _e( 'Choose Related Media', 'grand-media' ); ?>">
48
  <?php _e( 'choose' ); ?>
49
- <span class="glyphicon glyphicon-picture"></span>
50
- </a>
51
- </label>
52
- <div class="related-media-previews">
53
  <?php
54
- $related_ids = isset( $item->meta['_related'][0] ) ? $item->meta['_related'][0] : array();
55
- if(!empty($related_ids)){
56
- $related_media = $gmDB->get_gmedias(array('gmedia__in' => $related_ids, 'orderby' => 'gmedia__in'));
57
- foreach($related_media as $r_item){
58
- ?><p class="thumbnail gmedia-related-image">
59
- <span class="image-wrapper"><?php echo gmedia_item_thumbnail( $r_item ); ?></span>
60
- <span class="gm-remove">&times;</span>
61
- <input type="hidden" name="meta[_related][]" value="<?php echo $r_item->ID; ?>" />
62
- </p><?php
63
- }
64
- }
65
  ?>
66
- </div>
67
- </div>
68
- </div>
69
- <div class="col-sm-8">
70
- <div class="row">
71
- <div class="form-group col-lg-6">
72
- <label><?php _e( 'Title', 'grand-media' ); ?></label>
73
- <input name="title" type="text" class="form-control input-sm" placeholder="<?php _e( 'Title', 'grand-media' ); ?>" value="<?php esc_attr_e( $item->title ); ?>">
74
- </div>
75
- <div class="form-group col-lg-6">
76
- <label><?php _e( 'Link URL', 'grand-media' ); ?></label>
77
- <div class="input-group">
78
- <input name="link" type="text" class="form-control input-sm gmedia-custom-link-field" id="gmlink<?php echo $item->ID; ?>" value="<?php echo $item->link; ?>"/>
79
- <span class="input-group-btn"><button type="button" class="btn btn-sm btn-primary gmedia-custom-link" data-target="gmlink<?php echo $item->ID; ?>" title="<?php _e( 'Link to existing WP content', 'grand-media' ); ?>"><span class="glyphicon glyphicon-link"></span></button></span>
80
- </div>
81
- </div>
82
- </div>
83
- <div class="row">
84
- <div class="form-group col-lg-6">
85
- <label><?php _e( 'Description', 'grand-media' ); ?></label>
86
- <?php if ( ( 'false' != $gmedia_user_options['library_edit_quicktags'] ) || ( $gmProcessor->gmediablank && ( 1 == $resultPerPage ) ) ) {
87
- wp_editor( esc_textarea( $item->description ), "gm{$item->ID}_description", array(
88
  'editor_class' => 'form-control input-sm',
89
  'editor_height' => 140,
90
  'wpautop' => false,
@@ -92,20 +92,20 @@ if ( ! defined( 'ABSPATH' ) ) {
92
  'textarea_name' => 'description',
93
  'textarea_rows' => '4',
94
  'tinymce' => false,
95
- 'quicktags' => array( 'buttons' => apply_filters( 'gmedia_editor_quicktags', 'strong,em,link,ul,li,close' ) )
96
- ) );
97
  } else {
98
  echo "<textarea id='gm{$item->ID}_description' class='form-control input-sm' name='description' cols='20' rows='4' style='height:174px'>" . esc_textarea( $item->description ) . '</textarea>';
99
  } ?>
100
- </div>
101
- <div class="col-lg-6">
102
  <?php if ( gm_user_can( 'terms' ) ) { ?>
103
  <?php
104
  $alb_id = empty( $item->album ) ? 0 : reset( $item->album )->term_id;
105
  $term_type = 'gmedia_album';
106
- $args = array();
107
  if ( ! gm_user_can( 'edit_others_media' ) ) {
108
- $args = array( 'global' => array( 0, $user_ID ), 'orderby' => 'global_desc_name' );
109
  }
110
  $gm_terms = $gmDB->get_terms( $term_type, $args );
111
 
@@ -116,17 +116,17 @@ if ( ! defined( 'ABSPATH' ) ) {
116
  $author_name = '';
117
  if ( $term->global ) {
118
  if ( gm_user_can( 'edit_others_media' ) ) {
119
- $author_name .= ' &nbsp; ' . sprintf( __( 'by %s', 'grand-media' ), get_the_author_meta( 'display_name', $term->global ) );
120
  }
121
  } else {
122
  $author_name .= ' &nbsp; (' . __( 'shared', 'grand-media' ) . ')';
123
  }
124
- if ( 'publish' != $term->status ) {
125
  $author_name .= ' [' . $term->status . ']';
126
  }
127
 
128
  $selected_option = '';
129
- if ( $alb_id == $term->term_id ) {
130
  $selected_option = ' selected="selected"';
131
  $album_status = $term->status;
132
  }
@@ -134,18 +134,18 @@ if ( ! defined( 'ABSPATH' ) ) {
134
  }
135
  }
136
  ?>
137
- <div class="form-group status-album bg-status-<?php echo $album_status; ?>">
138
- <label><?php _e( 'Album ', 'grand-media' ); ?></label>
139
- <input type="text" class="gm-order-input" name="gmedia_album_order" title="<?php _e( 'Sort order (custom) in the chosen Album', 'grand-media' ); ?>" value="<?php echo $alb_id ? reset( $item->album )->gmedia_order : '0'; ?>" <?php echo $alb_id ? '' : 'disabled' ?>/>
140
- <select name="terms[gmedia_album]" data-create="<?php echo gm_user_can( 'album_manage' ) ? 'true' : 'false'; ?>" class="combobox_gmedia_album form-control input-sm" placeholder="<?php _e( 'Album Name...', 'grand-media' ); ?>">
141
- <option<?php echo $alb_id ? '' : ' selected="selected"'; ?> value=""></option>
142
  <?php echo $terms_album; ?>
143
- </select>
144
- </div>
145
 
146
  <?php
147
  if ( ! empty( $item->categories ) ) {
148
- $terms_category = array();
149
  foreach ( $item->categories as $c ) {
150
  $terms_category[] = esc_html( $c->name );
151
  }
@@ -154,14 +154,14 @@ if ( ! defined( 'ABSPATH' ) ) {
154
  $terms_category = '';
155
  }
156
  ?>
157
- <div class="form-group">
158
- <label><?php _e( 'Categories', 'grand-media' ); ?></label>
159
- <input name="terms[gmedia_category]" data-create="<?php echo gm_user_can( 'category_manage' ) ? 'true' : 'false'; ?>" class="combobox_gmedia_category form-control input-sm" value="<?php echo $terms_category; ?>" placeholder="<?php _e( 'Uncategorized', 'grand-media' ); ?>"/>
160
- </div>
161
 
162
  <?php
163
  if ( ! empty( $item->tags ) ) {
164
- $terms_tag = array();
165
  foreach ( $item->tags as $c ) {
166
  $terms_tag[] = esc_html( $c->name );
167
  }
@@ -170,132 +170,132 @@ if ( ! defined( 'ABSPATH' ) ) {
170
  $terms_tag = '';
171
  }
172
  ?>
173
- <div class="form-group">
174
- <label><?php _e( 'Tags ', 'grand-media' ); ?></label>
175
- <input name="terms[gmedia_tag]" data-create="<?php echo gm_user_can( 'tag_manage' ) ? 'true' : 'false'; ?>" class="combobox_gmedia_tag form-control input-sm" value="<?php echo $terms_tag; ?>"/>
176
- </div>
177
  <?php } ?>
178
- </div>
179
- </div>
180
- <div class="row">
181
- <div class="col-lg-6">
182
- <?php if ( 'image' == $item->type ) { ?>
183
- <div class="form-group">
184
- <label><?php _e( 'Alternative Text', 'grand-media' ); ?></label>
185
- <input type="text" class="form-control input-sm" name="meta[_image_alt]" value="<?php echo isset( $item->meta['_image_alt'][0] ) ? esc_attr( $item->meta['_image_alt'][0] ) : ''; ?>" placeholder="<?php _e( 'if empty, same as Title', 'grand-media' ); ?>"/>
186
- </div>
187
  <?php } ?>
188
- <div class="form-group">
189
- <label><?php _e( 'Filename', 'grand-media' ); ?>
190
- <small style="white-space:nowrap;">(ext: .<?php echo $item->ext; ?>)</small>
191
- </label>
192
- <input name="filename" type="text" class="form-control input-sm gmedia-filename" <?php echo ( ! gm_user_can( 'delete_others_media' ) && ( (int) $item->author !== $user_ID ) ) ? 'readonly' : ''; ?> value="<?php echo pathinfo( $item->gmuid, PATHINFO_FILENAME ); ?>"/>
193
- </div>
194
- <div class="form-group">
195
- <label><?php _e( 'Date', 'grand-media' ); ?></label>
196
 
197
- <div class="input-group gmedia_date input-group-sm" data-date-format="YYYY-MM-DD HH:mm:ss">
198
- <input name="date" type="text" class="form-control input-sm" value="<?php echo $item->date; ?>" readonly />
199
- <span class="input-group-addon btn-primary"><span class="glyphicon glyphicon-calendar"></span></span>
200
- </div>
201
- </div>
202
- <div class="form-group status-item bg-status-<?php echo $item->status; ?>">
203
- <label><?php _e( 'Status', 'grand-media' ); ?></label>
204
- <select name="status" class="form-control input-sm">
205
- <option <?php selected( $item->status, 'publish' ); ?> value="publish"><?php _e( 'Public', 'grand-media' ); ?></option>
206
- <option <?php selected( $item->status, 'private' ); ?> value="private"><?php _e( 'Private', 'grand-media' ); ?></option>
207
- <option <?php selected( $item->status, 'draft' ); ?> value="draft"><?php _e( 'Draft', 'grand-media' ); ?></option>
208
- </select>
209
- </div>
210
  <?php if ( ! empty( $item->post_id ) ) { ?>
211
- <div class="form-group">
212
- <a href="<?php echo add_query_arg( array( 'page' => 'GrandMedia', 'gmediablank' => 'comments', 'gmedia_id' => $item->ID ), $gmProcessor->url ); ?>" data-target="#previewModal" data-width="900" data-height="500" class="preview-modal gmpost-com-count pull-right" title="<?php esc_attr_e( 'Comments', 'grand-media' ); ?>">
213
- <b class="comment-count"><?php echo $item->comment_count; ?></b>
214
- <span class="glyphicon glyphicon-comment"></span>
215
- </a>
216
- <label><?php _e( 'Comment Status', 'grand-media' ); ?></label>
217
- <select name="comment_status" class="form-control input-sm">
218
- <option <?php selected( $item->comment_status, 'open' ); ?> value="open"><?php _e( 'Open', 'grand-media' ); ?></option>
219
- <option <?php selected( $item->comment_status, 'closed' ); ?> value="closed"><?php _e( 'Closed', 'grand-media' ); ?></option>
220
- </select>
221
- </div>
222
  <?php } ?>
223
- </div>
224
- <div class="col-lg-6">
225
- <?php if ( 'image' != $item->type || ( 'image' == $item->type && ! $item->editor ) ) { ?>
226
- <div class="form-group">
227
- <label><?php _e( 'Custom Cover', 'grand-media' );
228
  echo ' <small>(' . __( 'media image ID', 'grand-media' ) . ')</small>'; ?></label>
229
- <div class="input-group">
230
- <input type="text" class="form-control input-sm gmedia-cover-id" name="meta[_cover]" value="<?php echo isset( $item->meta['_cover'][0] ) ? $item->meta['_cover'][0] : ''; ?>" placeholder="<?php _e( 'Gmedia Image ID', 'grand-media' ); ?>"/>
231
- <span class="input-group-btn"><a href="<?php echo $gmCore->get_admin_url( array(
232
  'page' => 'GrandMedia',
233
  'mode' => 'select_single',
234
  'gmediablank' => 'library',
235
- 'filter' => 'image'
236
- ), array(), true ); ?>" class="btn btn-sm btn-primary preview-modal" data-target="#previewModal" data-width="1200" data-height="500" data-cls="select_gmedia_image" title="<?php _e( 'Choose Cover Image', 'grand-media' ); ?>"><span class="glyphicon glyphicon-picture"></span></a></span>
237
- </div>
238
- </div>
239
  <?php } ?>
240
- <?php if ( ( 'image' == $item->type ) || ( 'video' == $item->type ) ) { ?>
241
- <div class="form-group">
242
- <label><?php _e( 'GPS Location', 'grand-media' ); ?></label>
243
 
244
- <div class="input-group input-group-sm">
245
- <input name="meta[_gps]" type="text" class="form-control input-sm gps_map_coordinates" value="<?php echo $item->gps; ?>" placeholder="<?php _e( 'Latitude, Longtitude', 'grand-media' ); ?>" autocomplete="off"/>
246
- <span class="input-group-btn"><a href="<?php echo add_query_arg( array( 'page' => 'GrandMedia', 'gmediablank' => 'map_editor', 'id' => $item->ID ), $gmProcessor->url ); ?>" class="btn btn-primary gmedit-modal" data-target="#gmeditModal">
247
  <span class="glyphicon glyphicon-map-marker"></span></a></span>
248
- </div>
249
- </div>
250
  <?php } ?>
251
- <p class="media-meta">
252
- <span class="label label-default"><?php _e( 'Author', 'grand-media' ); ?>:</span> <?php echo get_the_author_meta( 'display_name', $item->author ); ?>
253
- <br/><span class="label label-default"><?php _e( 'ID', 'grand-media' ) ?>:</span> <strong><?php echo $item->ID; ?></strong>
254
- <br/><span class="label label-default"><?php _e( 'Post ID', 'grand-media' ) ?>:</span> <strong><?php echo $item->post_id; ?></strong>
255
- <br/><span class="label label-default"><?php _e( 'Type', 'grand-media' ); ?>:</span> <?php echo $item->mime_type; ?>
256
- <?php if ( ( 'image' == $item->type ) && $item->editor && ! empty( $item->meta['_metadata'] ) ) { ?>
257
- <br/><span class="label label-default"><?php _e( 'Dimensions', 'grand-media' ); ?>:</span>
258
  <?php
259
  $is_file_original = (bool) $item->path_original;
260
  if ( $is_file_original ) { ?>
261
- <a href="<?php echo $item->url_original; ?>"
262
- data-target="#previewModal"
263
- data-width="<?php echo $item->meta['_metadata'][0]['original']['width']; ?>"
264
- data-height="<?php echo $item->meta['_metadata'][0]['original']['height']; ?>"
265
- class="preview-modal"
266
- title="<?php _e( 'Original', 'grand-media' ); ?>"><?php echo $item->meta['_metadata'][0]['original']['width'] . '×' . $item->meta['_metadata'][0]['original']['height']; ?></a>,
267
  <?php } else { ?>
268
- <span title="<?php _e( 'Original', 'grand-media' ); ?>"><?php echo $item->meta['_metadata'][0]['original']['width'] . '×' . $item->meta['_metadata'][0]['original']['height']; ?></span>,
269
  <?php } ?>
270
- <a href="<?php echo $item->url; ?>"
271
- data-target="#previewModal"
272
- data-width="<?php echo $item->meta['_metadata'][0]['web']['width']; ?>"
273
- data-height="<?php echo $item->meta['_metadata'][0]['web']['height']; ?>"
274
- class="preview-modal"
275
- title="<?php _e( 'Webimage', 'grand-media' ); ?>"><?php echo $item->meta['_metadata'][0]['web']['width'] . '×' . $item->meta['_metadata'][0]['web']['height']; ?></a>,
276
- <a href="<?php echo $item->url_thumb; ?>"
277
- data-target="#previewModal"
278
- data-width="<?php echo $item->meta['_metadata'][0]['thumb']['width']; ?>"
279
- data-height="<?php echo $item->meta['_metadata'][0]['thumb']['height']; ?>"
280
- class="preview-modal"
281
- title="<?php _e( 'Thumbnail', 'grand-media' ); ?>"><?php echo $item->meta['_metadata'][0]['thumb']['width'] . '×' . $item->meta['_metadata'][0]['thumb']['height']; ?></a>
282
- <br/><span class="label label-default"><?php _e( 'File Size', 'grand-media' ) ?>:</span> <?php
283
  echo ( $is_file_original ? $gmCore->filesize( $item->path_original ) : '&#8212;' ) . ', ';
284
  echo $gmCore->filesize( $item->path ) . ', ' . $gmCore->filesize( $item->path_thumb ); ?>
285
  <?php } else { ?>
286
- <br/><span class="label label-default"><?php _e( 'File Size', 'grand-media' ) ?>:</span> <?php echo $gmCore->filesize( $item->path ); ?>
287
  <?php } ?>
288
  <?php if ( ! empty( $item->meta['_created_timestamp'][0] ) ) { ?>
289
- <br/><span class="label label-default"><?php _e( 'Created', 'grand-media' ) ?>:</span> <?php echo date( 'Y-m-d H:i:s ', $item->meta['_created_timestamp'][0] ); ?>
290
  <?php } ?>
291
- <br/><span class="label label-default"><?php _e( 'Uploaded', 'grand-media' ) ?>:</span> <?php echo $item->date; ?>
292
- <br/><span class="label label-default"><?php _e( 'Last Edited', 'grand-media' ) ?>:</span> <span class="gm-last-edited modified"><?php echo $item->modified; ?></span>
293
- </p>
294
- </div>
295
- </div>
296
  <?php
297
  $gmCore->gmedia_custom_meta_box( $item->ID );
298
  do_action( 'gmedia_edit_form' );
299
  ?>
300
- </div>
301
- </form>
1
  <?php
2
+ // don't load directly.
3
  if ( ! defined( 'ABSPATH' ) ) {
4
  die( '-1' );
5
  }
8
  * Edit Gmedia Item
9
  */
10
  ?>
11
+ <form class="cb_list-item list-group-item row d-row edit-gmedia <?php echo implode( ' ', $item->classes ); ?>" id="list-item-<?php echo absint( $item->ID ); ?>" data-id="<?php echo absint( $item->ID ); ?>" data-type="<?php echo esc_attr( $item->type ); ?>" role="form">
12
+ <div class="col-sm-4" style="max-width:340px;">
13
+ <input name="ID" type="hidden" value="<?php echo absint( $item->ID ); ?>"/>
14
+ <div class="thumbwrap">
15
+ <div class="cb_media-object">
16
+ <span data-clicktarget="gmimageedit<?php echo absint( $item->ID ); ?>" class="thumbnail gmedia-cover-image">
17
  <?php echo gmedia_item_thumbnail( $item ); ?>
18
  </span>
19
+ </div>
20
+ <label class="gm-item-check"><input name="doaction[]" type="checkbox"<?php echo $item->selected ? ' checked="checked"' : ''; ?> data-type="<?php echo esc_attr( $item->type ); ?>" value="<?php echo absint( $item->ID ); ?>"/></label>
21
+ <label class="gm-stack hidden"><input name="stack[]" type="checkbox"<?php echo $item->in_stack ? ' checked="checked"' : ''; ?> data-type="<?php echo esc_attr( $item->type ); ?>" value="<?php echo absint( $item->ID ); ?>"/></label>
22
+ </div>
23
+ <div class="gmedia-actions">
24
  <?php $media_action_links = gmedia_item_actions( $item );
25
  unset( $media_action_links['edit_data'] );
26
  echo implode( ' | ', $media_action_links );
27
  ?>
28
+ </div>
29
  <?php
30
+ if ( 'audio' === $item->type ) {
31
  echo gmedia_waveform_player( $item );
32
  }
33
  ?>
34
+ <div class="form-group">
35
+ <label><?php _e( 'Related Media', 'grand-media' ); ?>:
36
+ <a href="<?php echo esc_url( $gmCore->get_admin_url(
37
+ [
38
  'page' => 'GrandMedia',
39
  'mode' => 'select_multiple',
40
+ 'gmediablank' => 'library',
41
+ ], [], true ) ); ?>"
42
+ class="preview-modal"
43
+ data-target="#previewModal"
44
+ data-width="1200"
45
+ data-height="500"
46
+ data-cls="select_gmedia_related"
47
+ title="<?php _e( 'Choose Related Media', 'grand-media' ); ?>">
48
  <?php _e( 'choose' ); ?>
49
+ <span class="glyphicon glyphicon-picture"></span>
50
+ </a>
51
+ </label>
52
+ <div class="related-media-previews">
53
  <?php
54
+ $related_ids = isset( $item->meta['_related'][0] ) ? $item->meta['_related'][0] : [];
55
+ if ( ! empty( $related_ids ) ) {
56
+ $related_media = $gmDB->get_gmedias( [ 'gmedia__in' => $related_ids, 'orderby' => 'gmedia__in' ] );
57
+ foreach ( $related_media as $r_item ) {
58
+ ?><p class="thumbnail gmedia-related-image">
59
+ <span class="image-wrapper"><?php echo gmedia_item_thumbnail( $r_item ); ?></span>
60
+ <span class="gm-remove">&times;</span>
61
+ <input type="hidden" name="meta[_related][]" value="<?php echo absint( $r_item->ID ); ?>"/>
62
+ </p><?php
63
+ }
64
+ }
65
  ?>
66
+ </div>
67
+ </div>
68
+ </div>
69
+ <div class="col-sm-8">
70
+ <div class="row">
71
+ <div class="form-group col-lg-6">
72
+ <label><?php _e( 'Title', 'grand-media' ); ?></label>
73
+ <input name="title" type="text" class="form-control input-sm" placeholder="<?php _e( 'Title', 'grand-media' ); ?>" value="<?php echo esc_attr( $item->title ); ?>">
74
+ </div>
75
+ <div class="form-group col-lg-6">
76
+ <label><?php _e( 'Link URL', 'grand-media' ); ?></label>
77
+ <div class="input-group">
78
+ <input name="link" type="text" class="form-control input-sm gmedia-custom-link-field" id="gmlink<?php echo absint( $item->ID ); ?>" value="<?php echo esc_attr( $item->link ); ?>"/>
79
+ <span class="input-group-btn"><button type="button" class="btn btn-sm btn-primary gmedia-custom-link" data-target="gmlink<?php echo absint( $item->ID ); ?>" title="<?php _e( 'Link to existing WP content', 'grand-media' ); ?>"><span class="glyphicon glyphicon-link"></span></button></span>
80
+ </div>
81
+ </div>
82
+ </div>
83
+ <div class="row">
84
+ <div class="form-group col-lg-6">
85
+ <label><?php _e( 'Description', 'grand-media' ); ?></label>
86
+ <?php if ( ( 'false' !== $gmedia_user_options['library_edit_quicktags'] ) || ( $gmProcessor->gmediablank && ( 1 === $resultPerPage ) ) ) {
87
+ wp_editor( esc_textarea( $item->description ), "gm{$item->ID}_description", [
88
  'editor_class' => 'form-control input-sm',
89
  'editor_height' => 140,
90
  'wpautop' => false,
92
  'textarea_name' => 'description',
93
  'textarea_rows' => '4',
94
  'tinymce' => false,
95
+ 'quicktags' => [ 'buttons' => apply_filters( 'gmedia_editor_quicktags', 'strong,em,link,ul,li,close' ) ],
96
+ ] );
97
  } else {
98
  echo "<textarea id='gm{$item->ID}_description' class='form-control input-sm' name='description' cols='20' rows='4' style='height:174px'>" . esc_textarea( $item->description ) . '</textarea>';
99
  } ?>
100
+ </div>
101
+ <div class="col-lg-6">
102
  <?php if ( gm_user_can( 'terms' ) ) { ?>
103
  <?php
104
  $alb_id = empty( $item->album ) ? 0 : reset( $item->album )->term_id;
105
  $term_type = 'gmedia_album';
106
+ $args = [];
107
  if ( ! gm_user_can( 'edit_others_media' ) ) {
108
+ $args = [ 'global' => [ 0, $user_ID ], 'orderby' => 'global_desc_name' ];
109
  }
110
  $gm_terms = $gmDB->get_terms( $term_type, $args );
111
 
116
  $author_name = '';
117
  if ( $term->global ) {
118
  if ( gm_user_can( 'edit_others_media' ) ) {
119
+ $author_name .= ' &nbsp; ' . sprintf( __( 'by %s', 'grand-media' ), esc_html( get_the_author_meta( 'display_name', $term->global ) ) );
120
  }
121
  } else {
122
  $author_name .= ' &nbsp; (' . __( 'shared', 'grand-media' ) . ')';
123
  }
124
+ if ( 'publish' !== $term->status ) {
125
  $author_name .= ' [' . $term->status . ']';
126
  }
127
 
128
  $selected_option = '';
129
+ if ( $alb_id === $term->term_id ) {
130
  $selected_option = ' selected="selected"';
131
  $album_status = $term->status;
132
  }
134
  }
135
  }
136
  ?>
137
+ <div class="form-group status-album bg-status-<?php echo $album_status; ?>">
138
+ <label><?php _e( 'Album ', 'grand-media' ); ?></label>
139
+ <input type="text" class="gm-order-input" name="gmedia_album_order" title="<?php _e( 'Sort order (custom) in the chosen Album', 'grand-media' ); ?>" value="<?php echo absint( $alb_id ? reset( $item->album )->gmedia_order : 0 ); ?>" <?php echo $alb_id ? '' : 'disabled' ?>/>
140
+ <select name="terms[gmedia_album]" data-create="<?php echo esc_attr( gm_user_can( 'album_manage' ) ? 'true' : 'false' ); ?>" class="combobox_gmedia_album form-control input-sm" placeholder="<?php _e( 'Album Name...', 'grand-media' ); ?>">
141
+ <option<?php echo $alb_id ? '' : ' selected="selected"'; ?> value=""></option>
142
  <?php echo $terms_album; ?>
143
+ </select>
144
+ </div>
145
 
146
  <?php
147
  if ( ! empty( $item->categories ) ) {
148
+ $terms_category = [];
149
  foreach ( $item->categories as $c ) {
150
  $terms_category[] = esc_html( $c->name );
151
  }
154
  $terms_category = '';
155
  }
156
  ?>
157
+ <div class="form-group">
158
+ <label><?php _e( 'Categories', 'grand-media' ); ?></label>
159
+ <input name="terms[gmedia_category]" data-create="<?php echo esc_attr( gm_user_can( 'category_manage' ) ? 'true' : 'false' ); ?>" class="combobox_gmedia_category form-control input-sm" value="<?php echo esc_attr( $terms_category ); ?>" placeholder="<?php _e( 'Uncategorized', 'grand-media' ); ?>"/>
160
+ </div>
161
 
162
  <?php
163
  if ( ! empty( $item->tags ) ) {
164
+ $terms_tag = [];
165
  foreach ( $item->tags as $c ) {
166
  $terms_tag[] = esc_html( $c->name );
167
  }
170
  $terms_tag = '';
171
  }
172
  ?>
173
+ <div class="form-group">
174
+ <label><?php _e( 'Tags ', 'grand-media' ); ?></label>
175
+ <input name="terms[gmedia_tag]" data-create="<?php echo esc_attr( gm_user_can( 'tag_manage' ) ? 'true' : 'false' ); ?>" class="combobox_gmedia_tag form-control input-sm" value="<?php echo esc_attr( $terms_tag ); ?>"/>
176
+ </div>
177
  <?php } ?>
178
+ </div>
179
+ </div>
180
+ <div class="row">
181
+ <div class="col-lg-6">
182
+ <?php if ( 'image' === $item->type ) { ?>
183
+ <div class="form-group">
184
+ <label><?php _e( 'Alternative Text', 'grand-media' ); ?></label>
185
+ <input type="text" class="form-control input-sm" name="meta[_image_alt]" value="<?php echo esc_attr( isset( $item->meta['_image_alt'][0] ) ? esc_attr( $item->meta['_image_alt'][0] ) : '' ); ?>" placeholder="<?php _e( 'if empty, same as Title', 'grand-media' ); ?>"/>
186
+ </div>
187
  <?php } ?>
188
+ <div class="form-group">
189
+ <label><?php _e( 'Filename', 'grand-media' ); ?>
190
+ <small style="white-space:nowrap;">(ext: .<?php echo $item->ext; ?>)</small>
191
+ </label>
192
+ <input name="filename" type="text" class="form-control input-sm gmedia-filename" <?php echo ( ! gm_user_can( 'delete_others_media' ) && ( (int) $item->author !== $user_ID ) ) ? 'readonly' : ''; ?> value="<?php echo esc_attr( pathinfo( $item->gmuid, PATHINFO_FILENAME ) ); ?>"/>
193
+ </div>
194
+ <div class="form-group">
195
+ <label><?php _e( 'Date', 'grand-media' ); ?></label>
196
 
197
+ <div class="input-group gmedia_date input-group-sm" data-date-format="YYYY-MM-DD HH:mm:ss">
198
+ <input name="date" type="text" class="form-control input-sm" value="<?php echo esc_attr( $item->date ); ?>" readonly/>
199
+ <span class="input-group-addon btn-primary"><span class="glyphicon glyphicon-calendar"></span></span>
200
+ </div>
201
+ </div>
202
+ <div class="form-group status-item bg-status-<?php echo $item->status; ?>">
203
+ <label><?php _e( 'Status', 'grand-media' ); ?></label>
204
+ <select name="status" class="form-control input-sm">
205
+ <option <?php selected( $item->status, 'publish' ); ?> value="publish"><?php _e( 'Public', 'grand-media' ); ?></option>
206
+ <option <?php selected( $item->status, 'private' ); ?> value="private"><?php _e( 'Private', 'grand-media' ); ?></option>
207
+ <option <?php selected( $item->status, 'draft' ); ?> value="draft"><?php _e( 'Draft', 'grand-media' ); ?></option>
208
+ </select>
209
+ </div>
210
  <?php if ( ! empty( $item->post_id ) ) { ?>
211
+ <div class="form-group">
212
+ <a href="<?php echo esc_url( add_query_arg( [ 'page' => 'GrandMedia', 'gmediablank' => 'comments', 'gmedia_id' => $item->ID ], $gmProcessor->url ) ); ?>" data-target="#previewModal" data-width="900" data-height="500" class="preview-modal gmpost-com-count pull-right" title="<?php esc_attr_e( 'Comments', 'grand-media' ); ?>">
213
+ <b class="comment-count"><?php echo $item->comment_count; ?></b>
214
+ <span class="glyphicon glyphicon-comment"></span>
215
+ </a>
216
+ <label><?php _e( 'Comment Status', 'grand-media' ); ?></label>
217
+ <select name="comment_status" class="form-control input-sm">
218
+ <option <?php selected( $item->comment_status, 'open' ); ?> value="open"><?php _e( 'Open', 'grand-media' ); ?></option>
219
+ <option <?php selected( $item->comment_status, 'closed' ); ?> value="closed"><?php _e( 'Closed', 'grand-media' ); ?></option>
220
+ </select>
221
+ </div>
222
  <?php } ?>
223
+ </div>
224
+ <div class="col-lg-6">
225
+ <?php if ( 'image' !== $item->type || ( 'image' === $item->type && ! $item->editor ) ) { ?>
226
+ <div class="form-group">
227
+ <label><?php _e( 'Custom Cover', 'grand-media' );
228
  echo ' <small>(' . __( 'media image ID', 'grand-media' ) . ')</small>'; ?></label>
229
+ <div class="input-group">
230
+ <input type="text" class="form-control input-sm gmedia-cover-id" name="meta[_cover]" value="<?php echo esc_attr( isset( $item->meta['_cover'][0] ) ? $item->meta['_cover'][0] : '' ); ?>" placeholder="<?php _e( 'Gmedia Image ID', 'grand-media' ); ?>"/>
231
+ <span class="input-group-btn"><a href="<?php echo esc_url( $gmCore->get_admin_url( [
232
  'page' => 'GrandMedia',
233
  'mode' => 'select_single',
234
  'gmediablank' => 'library',
235
+ 'filter' => 'image',
236
+ ], [], true ) ); ?>" class="btn btn-sm btn-primary preview-modal" data-target="#previewModal" data-width="1200" data-height="500" data-cls="select_gmedia_image" title="<?php _e( 'Choose Cover Image', 'grand-media' ); ?>"><span class="glyphicon glyphicon-picture"></span></a></span>
237
+ </div>
238
+ </div>
239
  <?php } ?>
240
+ <?php if ( ( 'image' === $item->type ) || ( 'video' === $item->type ) ) { ?>
241
+ <div class="form-group">
242
+ <label><?php _e( 'GPS Location', 'grand-media' ); ?></label>
243
 
244
+ <div class="input-group input-group-sm">
245
+ <input name="meta[_gps]" type="text" class="form-control input-sm gps_map_coordinates" value="<?php echo esc_attr( $item->gps ); ?>" placeholder="<?php _e( 'Latitude, Longtitude', 'grand-media' ); ?>" autocomplete="off"/>
246
+ <span class="input-group-btn"><a href="<?php echo esc_url( add_query_arg( [ 'page' => 'GrandMedia', 'gmediablank' => 'map_editor', 'id' => $item->ID ], $gmProcessor->url ) ); ?>" class="btn btn-primary gmedit-modal" data-target="#gmeditModal">
247
  <span class="glyphicon glyphicon-map-marker"></span></a></span>
248
+ </div>
249
+ </div>
250
  <?php } ?>
251
+ <p class="media-meta">
252
+ <span class="label label-default"><?php _e( 'Author', 'grand-media' ); ?>:</span> <?php echo esc_html( get_the_author_meta( 'display_name', $item->author ) ); ?>
253
+ <br/><span class="label label-default"><?php _e( 'ID', 'grand-media' ) ?>:</span> <strong><?php echo absint( $item->ID ); ?></strong>
254
+ <br/><span class="label label-default"><?php _e( 'Post ID', 'grand-media' ) ?>:</span> <strong><?php echo $item->post_id; ?></strong>
255
+ <br/><span class="label label-default"><?php _e( 'Type', 'grand-media' ); ?>:</span> <?php echo $item->mime_type; ?>
256
+ <?php if ( ( 'image' === $item->type ) && $item->editor && ! empty( $item->meta['_metadata'] ) ) { ?>
257
+ <br/><span class="label label-default"><?php _e( 'Dimensions', 'grand-media' ); ?>:</span>
258
  <?php
259
  $is_file_original = (bool) $item->path_original;
260
  if ( $is_file_original ) { ?>
261
+ <a href="<?php echo esc_url( $item->url_original ); ?>"
262
+ data-target="#previewModal"
263
+ data-width="<?php echo esc_attr( $item->meta['_metadata'][0]['original']['width'] ); ?>"
264
+ data-height="<?php echo esc_attr( $item->meta['_metadata'][0]['original']['height'] ); ?>"
265
+ class="preview-modal"
266
+ title="<?php _e( 'Original', 'grand-media' ); ?>"><?php echo $item->meta['_metadata'][0]['original']['width'] . '×' . $item->meta['_metadata'][0]['original']['height']; ?></a>,
267
  <?php } else { ?>
268
+ <span title="<?php _e( 'Original', 'grand-media' ); ?>"><?php echo $item->meta['_metadata'][0]['original']['width'] . '×' . $item->meta['_metadata'][0]['original']['height']; ?></span>,
269
  <?php } ?>
270
+ <a href="<?php echo esc_url( $item->url ); ?>"
271
+ data-target="#previewModal"
272
+ data-width="<?php echo esc_attr( $item->meta['_metadata'][0]['web']['width'] ); ?>"
273
+ data-height="<?php echo esc_attr( $item->meta['_metadata'][0]['web']['height'] ); ?>"
274
+ class="preview-modal"
275
+ title="<?php _e( 'Webimage', 'grand-media' ); ?>"><?php echo $item->meta['_metadata'][0]['web']['width'] . '×' . $item->meta['_metadata'][0]['web']['height']; ?></a>,
276
+ <a href="<?php echo esc_url( $item->url_thumb ); ?>"
277
+ data-target="#previewModal"
278
+ data-width="<?php echo esc_attr( $item->meta['_metadata'][0]['thumb']['width'] ); ?>"
279
+ data-height="<?php echo esc_attr( $item->meta['_metadata'][0]['thumb']['height'] ); ?>"
280
+ class="preview-modal"
281
+ title="<?php _e( 'Thumbnail', 'grand-media' ); ?>"><?php echo $item->meta['_metadata'][0]['thumb']['width'] . '×' . $item->meta['_metadata'][0]['thumb']['height']; ?></a>
282
+ <br/><span class="label label-default"><?php _e( 'File Size', 'grand-media' ) ?>:</span> <?php
283
  echo ( $is_file_original ? $gmCore->filesize( $item->path_original ) : '&#8212;' ) . ', ';
284
  echo $gmCore->filesize( $item->path ) . ', ' . $gmCore->filesize( $item->path_thumb ); ?>
285
  <?php } else { ?>
286
+ <br/><span class="label label-default"><?php _e( 'File Size', 'grand-media' ) ?>:</span> <?php echo $gmCore->filesize( $item->path ); ?>
287
  <?php } ?>
288
  <?php if ( ! empty( $item->meta['_created_timestamp'][0] ) ) { ?>
289
+ <br/><span class="label label-default"><?php _e( 'Created', 'grand-media' ) ?>:</span> <?php echo date( 'Y-m-d H:i:s ', $item->meta['_created_timestamp'][0] ); ?>
290
  <?php } ?>
291
+ <br/><span class="label label-default"><?php _e( 'Uploaded', 'grand-media' ) ?>:</span> <?php echo $item->date; ?>
292
+ <br/><span class="label label-default"><?php _e( 'Last Edited', 'grand-media' ) ?>:</span> <span class="gm-last-edited modified"><?php echo $item->modified; ?></span>
293
+ </p>
294
+ </div>
295
+ </div>
296
  <?php
297
  $gmCore->gmedia_custom_meta_box( $item->ID );
298
  do_action( 'gmedia_edit_form' );
299
  ?>
300
+ </div>
301
+ </form>
admin/pages/library/tpl/grid-item.php CHANGED
@@ -1,98 +1,98 @@
1
  <?php
2
- // don't load directly
3
- if(!defined('ABSPATH')){
4
- die('-1');
5
  }
6
 
7
  /**
8
  * Gmedia Item for Grid View in Library
9
  */
10
  ?>
11
- <div class="cb_list-item gm-item-cell col-xs-6 col-sm-4 col-md-3 col-lg-2 <?php echo implode(' ', $item->classes); ?>" id="list-item-<?php echo $item->ID; ?>" data-id="<?php echo $item->ID; ?>" data-type="<?php echo $item->type; ?>">
12
- <div class="thumbnail <?php echo ($item->img_ratio >= 1)? 'landscape' : 'portrait'; ?>">
13
- <div class="cb_media-object">
14
- <span<?php echo in_array($gmProcessor->mode, array('select_single', 'select_multiple'))? '' : ' data-clicktarget="gmdataedit' . $item->ID . '"'; ?> class="centered">
15
- <?php echo gmedia_item_thumbnail($item); ?>
16
  </span>
17
- </div>
18
- <label class="gm-item-check">
19
- <?php if($gmProcessor->mode != 'select_single'){ ?>
20
- <input name="doaction[]" type="checkbox"<?php echo $item->selected? ' checked="checked"' : ''; ?> data-type="<?php echo $item->type; ?>" value="<?php echo $item->ID; ?>"/>
21
- <?php } else{ ?>
22
- <input name="doaction[]" type="radio" data-type="<?php echo $item->type; ?>" value="<?php echo $item->ID; ?>"/>
23
- <?php } ?>
24
- </label>
25
- <label class="gm-stack hidden"><input name="stack[]" type="checkbox"<?php echo $item->in_stack? ' checked="checked"' : ''; ?> data-type="<?php echo $item->type; ?>" value="<?php echo $item->ID; ?>"/></label>
26
- <div class="gm-cell-more">
27
- <span class="gm-cell-more-btn glyphicon glyphicon-menu-hamburger"></span>
28
- <div class="gm-cell-more-content">
29
- <p class="media-meta"><span class="label label-default"><?php _e('ID', 'grand-media'); ?>:</span> #<?php echo $item->ID; ?>
30
- <br/><span class="label label-default"><?php _e('Album', 'grand-media'); ?>:</span>
31
- <?php
32
- if($item->album){
33
- $terms_album = array();
34
- foreach($item->album as $c){
35
- $terms_album[] = sprintf('<a class="album" href="%s">%s</a>', esc_url(add_query_arg(array('album__in' => $c->term_id), $gmedia_url)), esc_html($c->name));
36
- }
37
- $terms_album = join(', ', $terms_album);
38
- } else{
39
- $terms_album = sprintf('<a class="album" href="%s">%s</a>', esc_url(add_query_arg(array('album__in' => 0), $gmedia_url)), '&#8212;');
40
- }
41
- echo $terms_album;
42
- ?>
43
- <br/><span class="label label-default"><?php _e('Category', 'grand-media'); ?>:</span>
44
- <?php
45
- if($item->categories){
46
- $terms_category = array();
47
- foreach($item->categories as $c){
48
- $terms_category[] = sprintf('<a class="category" href="%s">%s</a>', esc_url(add_query_arg(array('category__in' => $c->term_id), $gmedia_url)), esc_html($c->name));
49
- }
50
- $terms_category = join(', ', $terms_category);
51
- } else{
52
- $terms_category = sprintf('<a class="category" href="%s">%s</a>', esc_url(add_query_arg(array('category__in' => 0), $gmedia_url)), __('Uncategorized', 'grand-media'));
53
- }
54
- echo $terms_category;
55
- ?>
56
- <br/><span class="label label-default"><?php _e('Tags', 'grand-media'); ?>:</span>
57
- <?php
58
- if($item->tags){
59
- $terms_tag = array();
60
- foreach($item->tags as $c){
61
- $terms_tag[] = sprintf('<a class="tag" href="%s">%s</a>', esc_url(add_query_arg(array('tag__in' => $c->term_id), $gmedia_url)), esc_html($c->name));
62
- }
63
- $terms_tag = join(', ', $terms_tag);
64
- } else{
65
- $terms_tag = '&#8212;';
66
- }
67
- echo $terms_tag;
68
- ?>
69
 
70
- <?php if(isset($item->post_id)){ ?>
71
- <br/><span class="label label-default"><?php _e('Comments', 'grand-media'); ?>:</span>
72
- <a href="<?php echo add_query_arg(array('page' => 'GrandMedia', 'gmediablank' => 'comments', 'gmedia_id' => $item->ID), $gmProcessor->url); ?>" data-target="#previewModal" data-width="900" data-height="500" class="preview-modal gmpost-com-count" title="<?php esc_attr_e('Comments', 'grand-media'); ?>">
73
- <b class="comment-count"><?php echo $item->comment_count; ?></b>
74
- <span class="glyphicon glyphicon-comment"></span>
75
- </a>
76
- <?php } ?>
77
- <br/><span class="label label-default"><?php _e('Views / Likes', 'grand-media'); ?>:</span>
78
- <?php echo (isset($item->meta['views'][0])? $item->meta['views'][0] : '0') . ' / ' . (isset($item->meta['likes'][0])? $item->meta['likes'][0] : '0'); ?>
79
 
80
- <?php if(isset($item->meta['_rating'][0])){
81
- $ratings = maybe_unserialize($item->meta['_rating'][0]); ?>
82
- <br/><span class="label label-default"><?php _e('Rating', 'grand-media'); ?>:</span> <?php echo $ratings['value'] . ' / ' . $ratings['votes']; ?>
83
- <?php } ?>
84
- </p>
85
- </div>
86
- </div>
87
- </div>
88
- <div class="gm-cell-bottom">
89
- <div class="gm-cell-title"><span><?php echo esc_html($item->title); ?>&nbsp;</span></div>
90
- <div class="gmedia-actions">
91
- <?php $media_action_links = gmedia_item_actions($item);
92
- echo implode(' ', $media_action_links);
93
- ?>
94
- </div>
95
- </div>
96
  </div>
97
 
98
 
1
  <?php
2
+ // don't load directly.
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ die( '-1' );
5
  }
6
 
7
  /**
8
  * Gmedia Item for Grid View in Library
9
  */
10
  ?>
11
+ <div class="cb_list-item gm-item-cell col-xs-6 col-sm-4 col-md-3 col-lg-2 <?php echo implode( ' ', $item->classes ); ?>" id="list-item-<?php echo absint( $item->ID ); ?>" data-id="<?php echo absint( $item->ID ); ?>" data-type="<?php echo esc_attr( $item->type ); ?>">
12
+ <div class="thumbnail <?php echo ( $item->img_ratio >= 1 ) ? 'landscape' : 'portrait'; ?>">
13
+ <div class="cb_media-object">
14
+ <span<?php echo in_array( $gmProcessor->mode, [ 'select_single', 'select_multiple' ], true ) ? '' : ' data-clicktarget="gmdataedit' . $item->ID . '"'; ?> class="centered">
15
+ <?php echo gmedia_item_thumbnail( $item ); ?>
16
  </span>
17
+ </div>
18
+ <label class="gm-item-check">
19
+ <?php if ( $gmProcessor->mode !== 'select_single' ) { ?>
20
+ <input name="doaction[]" type="checkbox"<?php echo $item->selected ? ' checked="checked"' : ''; ?> data-type="<?php echo esc_attr( $item->type ); ?>" value="<?php echo absint( $item->ID ); ?>"/>
21
+ <?php } else { ?>
22
+ <input name="doaction[]" type="radio" data-type="<?php echo esc_attr( $item->type ); ?>" value="<?php echo absint( $item->ID ); ?>"/>
23
+ <?php } ?>
24
+ </label>
25
+ <label class="gm-stack hidden"><input name="stack[]" type="checkbox"<?php echo $item->in_stack ? ' checked="checked"' : ''; ?> data-type="<?php echo esc_attr( $item->type ); ?>" value="<?php echo absint( $item->ID ); ?>"/></label>
26
+ <div class="gm-cell-more">
27
+ <span class="gm-cell-more-btn glyphicon glyphicon-menu-hamburger"></span>
28
+ <div class="gm-cell-more-content">
29
+ <p class="media-meta"><span class="label label-default"><?php _e( 'ID', 'grand-media' ); ?>:</span> #<?php echo absint( $item->ID ); ?>
30
+ <br/><span class="label label-default"><?php _e( 'Album', 'grand-media' ); ?>:</span>
31
+ <?php
32
+ if ( $item->album ) {
33
+ $terms_album = [];
34
+ foreach ( $item->album as $c ) {
35
+ $terms_album[] = sprintf( '<a class="album" href="%s">%s</a>', esc_url( add_query_arg( [ 'album__in' => $c->term_id ], $gmedia_url ) ), esc_html( $c->name ) );
36
+ }
37
+ $terms_album = join( ', ', $terms_album );
38
+ } else {
39
+ $terms_album = sprintf( '<a class="album" href="%s">%s</a>', esc_url( add_query_arg( [ 'album__in' => 0 ], $gmedia_url ) ), '&#8212;' );
40
+ }
41
+ echo $terms_album;
42
+ ?>
43
+ <br/><span class="label label-default"><?php _e( 'Category', 'grand-media' ); ?>:</span>
44
+ <?php
45
+ if ( $item->categories ) {
46
+ $terms_category = [];
47
+ foreach ( $item->categories as $c ) {
48
+ $terms_category[] = sprintf( '<a class="category" href="%s">%s</a>', esc_url( add_query_arg( [ 'category__in' => $c->term_id ], $gmedia_url ) ), esc_html( $c->name ) );
49
+ }
50
+ $terms_category = join( ', ', $terms_category );
51
+ } else {
52
+ $terms_category = sprintf( '<a class="category" href="%s">%s</a>', esc_url( add_query_arg( [ 'category__in' => 0 ], $gmedia_url ) ), __( 'Uncategorized', 'grand-media' ) );
53
+ }
54
+ echo $terms_category;
55
+ ?>
56
+ <br/><span class="label label-default"><?php _e( 'Tags', 'grand-media' ); ?>:</span>
57
+ <?php
58
+ if ( $item->tags ) {
59
+ $terms_tag = [];
60
+ foreach ( $item->tags as $c ) {
61
+ $terms_tag[] = sprintf( '<a class="tag" href="%s">%s</a>', esc_url( add_query_arg( [ 'tag__in' => $c->term_id ], $gmedia_url ) ), esc_html( $c->name ) );
62
+ }
63
+ $terms_tag = join( ', ', $terms_tag );
64
+ } else {
65
+ $terms_tag = '&#8212;';
66
+ }
67
+ echo $terms_tag;
68
+ ?>
69
 
70
+ <?php if ( isset( $item->post_id ) ) { ?>
71
+ <br/><span class="label label-default"><?php _e( 'Comments', 'grand-media' ); ?>:</span>
72
+ <a href="<?php echo esc_url( add_query_arg( [ 'page' => 'GrandMedia', 'gmediablank' => 'comments', 'gmedia_id' => $item->ID ], $gmProcessor->url ) ); ?>" data-target="#previewModal" data-width="900" data-height="500" class="preview-modal gmpost-com-count" title="<?php esc_attr_e( 'Comments', 'grand-media' ); ?>">
73
+ <b class="comment-count"><?php echo $item->comment_count; ?></b>
74
+ <span class="glyphicon glyphicon-comment"></span>
75
+ </a>
76
+ <?php } ?>
77
+ <br/><span class="label label-default"><?php _e( 'Views / Likes', 'grand-media' ); ?>:</span>
78
+ <?php echo ( isset( $item->meta['views'][0] ) ? $item->meta['views'][0] : '0' ) . ' / ' . ( isset( $item->meta['likes'][0] ) ? $item->meta['likes'][0] : '0' ); ?>
79
 
80
+ <?php if ( isset( $item->meta['_rating'][0] ) ) {
81
+ $ratings = maybe_unserialize( $item->meta['_rating'][0] ); ?>
82
+ <br/><span class="label label-default"><?php _e( 'Rating', 'grand-media' ); ?>:</span> <?php echo round( $ratings['value'], 2 ) . ' / ' . $ratings['votes']; ?>
83
+ <?php } ?>
84
+ </p>
85
+ </div>
86
+ </div>
87
+ </div>
88
+ <div class="gm-cell-bottom">
89
+ <div class="gm-cell-title"><span><?php echo esc_html( $item->title ); ?>&nbsp;</span></div>
90
+ <div class="gmedia-actions">
91
+ <?php $media_action_links = gmedia_item_actions( $item );
92
+ echo implode( ' ', $media_action_links );
93
+ ?>
94
+ </div>
95
+ </div>
96
  </div>
97
 
98
 
admin/pages/library/tpl/list-item.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- // don't load directly
3
- if(!defined('ABSPATH')) {
4
- die('-1');
5
  }
6
 
7
  /**
@@ -11,159 +11,158 @@ if(!defined('ABSPATH')) {
11
  * @var $item
12
  */
13
  ?>
14
- <div class="cb_list-item list-group-item d-row clearfix <?php echo implode(' ', $item->classes); ?>" id="list-item-<?php echo $item->ID; ?>" data-id="<?php echo $item->ID; ?>" data-type="<?php echo $item->type; ?>">
15
- <div class="gmedia_id">#<?php echo $item->ID; ?></div>
16
- <div class="col-sm-4" style="max-width:340px;">
17
- <div class="thumbwrap">
18
- <div class="cb_media-object">
19
- <span data-clicktarget="gmdataedit<?php echo $item->ID; ?>" class="thumbnail">
20
- <?php echo gmedia_item_thumbnail($item); ?>
21
  </span>
22
- </div>
23
- <label class="gm-item-check"><input name="doaction[]" type="checkbox"<?php echo $item->selected? ' checked="checked"' : ''; ?> data-type="<?php echo $item->type; ?>" value="<?php echo $item->ID; ?>"/></label>
24
- <label class="gm-stack hidden"><input name="stack[]" type="checkbox"<?php echo $item->in_stack? ' checked="checked"' : ''; ?> data-type="<?php echo $item->type; ?>" value="<?php echo $item->ID; ?>"/></label>
25
- </div>
26
- <?php
27
- if('audio' == $item->type) {
28
- echo gmedia_waveform_player($item);
29
- }
30
- ?>
31
- <div class="related-media-previews">
32
- <?php
33
- $related_ids = isset( $item->meta['_related'][0] ) ? $item->meta['_related'][0] : array();
34
- if(!empty($related_ids)){
35
- $related_media = $gmDB->get_gmedias(array('gmedia__in' => $related_ids, 'orderby' => 'gmedia__in'));
36
- foreach($related_media as $r_item){
37
- ?><p class="thumbnail gmedia-related-image"><span class="image-wrapper"><?php echo gmedia_item_thumbnail( $r_item ); ?></span></p><?php
38
- }
39
- }
40
- ?>
41
- </div>
42
- </div>
43
- <div class="col-sm-8">
44
- <div class="row" style="margin:0;">
45
- <div class="col-lg-6">
46
- <p class="media-title"><?php echo esc_html($item->title); ?>&nbsp;</p>
47
 
48
- <div class="in-library media-caption"><?php echo nl2br(esc_html($item->description)); ?></div>
49
 
50
- <p class="media-meta">
51
- <span class="label label-default"><?php _e('Author', 'grand-media'); ?>:</span> <?php printf('<a class="gmedia-author" href="%s">%s</a>', esc_url(add_query_arg(array('author' => $item->author), $gmedia_url)), get_user_option('display_name', $item->author)); ?>
52
- <br/><span class="label label-default"><?php _e('Album', 'grand-media'); ?>:</span>
53
- <?php
54
- if($item->album) {
55
- $terms_album = array();
56
- foreach($item->album as $c) {
57
- $terms_album[] = sprintf('<a class="album" href="%s">%s</a>', esc_url(add_query_arg(array('album__in' => $c->term_id), $gmedia_url)), esc_html($c->name));
58
- }
59
- $terms_album = join(', ', $terms_album);
60
- } else {
61
- $terms_album = sprintf('<a class="album" href="%s">%s</a>', esc_url(add_query_arg(array('album__in' => 0), $gmedia_url)), '&#8212;');
62
- }
63
- echo $terms_album;
64
- ?>
65
- <br/><span class="label label-default"><?php _e('Category', 'grand-media'); ?>:</span>
66
- <?php
67
- if($item->categories) {
68
- $terms_category = array();
69
- foreach($item->categories as $c) {
70
- $terms_category[] = sprintf('<a class="category" href="%s">%s</a>', esc_url(add_query_arg(array('category__in' => $c->term_id), $gmedia_url)), esc_html($c->name));
71
- }
72
- $terms_category = join(', ', $terms_category);
73
- } else {
74
- $terms_category = sprintf('<a class="category" href="%s">%s</a>', esc_url(add_query_arg(array('category__in' => 0), $gmedia_url)), __('Uncategorized', 'grand-media'));
75
- }
76
- echo $terms_category;
77
- ?>
78
- <br/><span class="label label-default"><?php _e('Tags', 'grand-media'); ?>:</span>
79
- <?php
80
- if($item->tags) {
81
- $terms_tag = array();
82
- foreach($item->tags as $c) {
83
- $terms_tag[] = sprintf('<a class="tag" href="%s">%s</a>', esc_url(add_query_arg(array('tag__in' => $c->term_id), $gmedia_url)), esc_html($c->name));
84
- }
85
- $terms_tag = join(', ', $terms_tag);
86
- } else {
87
- $terms_tag = '&#8212;';
88
- }
89
- echo $terms_tag;
90
- ?>
91
- </p>
92
- </div>
93
- <div class="col-lg-6">
94
- <div class="media-meta gmedia-actions" style="margin:0 0 10px 0;">
95
- <?php $media_action_links = gmedia_item_actions($item);
96
- echo implode(' | ', $media_action_links);
97
- ?>
98
- </div>
99
- <?php if(isset($item->post_id)) { ?>
100
- <p class="media-meta">
101
- <span class="label label-default"><?php _e('Comments', 'grand-media'); ?>:</span>
102
- <a href="<?php echo add_query_arg(array('page' => 'GrandMedia', 'gmediablank' => 'comments', 'gmedia_id' => $item->ID), $gmProcessor->url); ?>" data-target="#previewModal" data-width="900" data-height="500" class="preview-modal gmpost-com-count" title="<?php esc_attr_e('Comments', 'grand-media'); ?>">
103
- <b class="comment-count"><?php echo $item->comment_count; ?></b>
104
- <span class="glyphicon glyphicon-comment"></span>
105
- </a>
106
- </p>
107
- <?php } ?>
108
- <p class="media-meta">
109
- <span class="label label-default"><?php _e('Views / Likes', 'grand-media'); ?>:</span>
110
- <?php echo (isset($item->meta['views'][0])? $item->meta['views'][0] : '0') . ' / ' . (isset($item->meta['likes'][0])? $item->meta['likes'][0] : '0'); ?>
111
 
112
- <?php if(isset($item->meta['_rating'][0])) {
113
- $ratings = maybe_unserialize($item->meta['_rating'][0]); ?>
114
- <br/><span class="label label-default"><?php _e('Rating', 'grand-media'); ?>:</span> <?php echo $ratings['value'] . ' / ' . $ratings['votes']; ?>
115
- <?php } ?>
116
- <br/><span class="label label-default"><?php _e('Status', 'grand-media'); ?>:</span> <?php echo $item->status; ?>
117
- <br/><span class="label label-default"><?php _e('Link', 'grand-media'); ?>:</span>
118
- <?php if(!empty($item->link)) { ?>
119
- <a href="<?php echo $item->link; ?>"><?php echo $item->link; ?></a>
120
- <?php
121
- } else {
122
- echo '&#8212;';
123
- } ?>
124
- <?php if(!empty($item->gps)) { ?>
125
- <br/><span class="label label-default"><?php _e('GPS Location', 'grand-media'); ?>:</span> <?php echo $item->gps; ?>
126
- <?php } ?>
127
- </p>
128
- <p class="media-meta">
129
- <span class="label label-default"><?php _e('Type', 'grand-media'); ?>:</span> <?php echo $item->mime_type; ?>
130
- <?php if(('image' == $item->type) && $item->editor && !empty($item->meta['_metadata'])) {
131
- ?>
132
- <br/><span class="label label-default"><?php _e('Dimensions', 'grand-media'); ?>:</span>
133
- <?php
134
- $is_file_original = (bool)$item->path_original;
135
- if($is_file_original){ ?>
136
- <a href="<?php echo $item->url_original; ?>"
137
- data-target="#previewModal"
138
- data-width="<?php echo $item->meta['_metadata'][0]['original']['width']; ?>"
139
- data-height="<?php echo $item->meta['_metadata'][0]['original']['height']; ?>"
140
- class="preview-modal"
141
- title="<?php _e('Original', 'grand-media'); ?>"><?php echo $item->meta['_metadata'][0]['original']['width'] . '×' . $item->meta['_metadata'][0]['original']['height']; ?></a>,
142
- <?php } else{ ?>
143
- <span title="<?php _e('Original', 'grand-media'); ?>"><?php echo $item->meta['_metadata'][0]['original']['width'] . '×' . $item->meta['_metadata'][0]['original']['height']; ?></span>,
144
- <?php } ?>
145
- <a href="<?php echo $item->url; ?>"
146
- data-target="#previewModal"
147
- data-width="<?php echo $item->meta['_metadata'][0]['web']['width']; ?>"
148
- data-height="<?php echo $item->meta['_metadata'][0]['web']['height']; ?>"
149
- class="preview-modal"
150
- title="<?php _e('Webimage', 'grand-media'); ?>"><?php echo $item->meta['_metadata'][0]['web']['width'] . '×' . $item->meta['_metadata'][0]['web']['height']; ?></a>,
151
- <a href="<?php echo $item->url_thumb; ?>"
152
- data-target="#previewModal"
153
- data-width="<?php echo $item->meta['_metadata'][0]['thumb']['width']; ?>"
154
- data-height="<?php echo $item->meta['_metadata'][0]['thumb']['height']; ?>"
155
- class="preview-modal"
156
- title="<?php _e('Thumbnail', 'grand-media'); ?>"><?php echo $item->meta['_metadata'][0]['thumb']['width'] . '×' . $item->meta['_metadata'][0]['thumb']['height']; ?></a>
157
- <?php } ?>
158
- <br/><span class="label label-default"><?php _e('Filename', 'grand-media'); ?>:</span> <a href="<?php echo $item->url; ?>" download="<?php echo $item->gmuid; ?>"><?php echo $item->gmuid; ?></a>
159
- <?php if(!empty($item->meta['_created_timestamp'][0])) { ?>
160
- <br/><span class="label label-default"><?php _e('Created', 'grand-media') ?>:</span> <?php echo date('Y-m-d H:i:s ', $item->meta['_created_timestamp'][0]); ?>
161
- <?php } ?>
162
- <br/><span class="label label-default"><?php _e('Uploaded', 'grand-media') ?>:</span> <?php echo $item->date; ?>
163
- <br/><span class="label label-default"><?php _e('Last Edited', 'grand-media') ?>:</span> <span class="gm-last-edited modified"><?php echo $item->modified; ?></span>
164
- </p>
165
- </div>
166
- </div>
167
- </div>
168
  </div>
169
-
1
  <?php
2
+ // don't load directly.
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ die( '-1' );
5
  }
6
 
7
  /**
11
  * @var $item
12
  */
13
  ?>
14
+ <div class="cb_list-item list-group-item d-row clearfix <?php echo implode( ' ', $item->classes ); ?>" id="list-item-<?php echo absint( $item->ID ); ?>" data-id="<?php echo absint( $item->ID ); ?>" data-type="<?php echo esc_attr( $item->type ); ?>">
15
+ <div class="gmedia_id">#<?php echo absint( $item->ID ); ?></div>
16
+ <div class="col-sm-4" style="max-width:340px;">
17
+ <div class="thumbwrap">
18
+ <div class="cb_media-object">
19
+ <span data-clicktarget="gmdataedit<?php echo absint( $item->ID ); ?>" class="thumbnail">
20
+ <?php echo gmedia_item_thumbnail( $item ); ?>
21
  </span>
22
+ </div>
23
+ <label class="gm-item-check"><input name="doaction[]" type="checkbox"<?php echo $item->selected ? ' checked="checked"' : ''; ?> data-type="<?php echo esc_attr( $item->type ); ?>" value="<?php echo absint( $item->ID ); ?>"/></label>
24
+ <label class="gm-stack hidden"><input name="stack[]" type="checkbox"<?php echo $item->in_stack ? ' checked="checked"' : ''; ?> data-type="<?php echo esc_attr( $item->type ); ?>" value="<?php echo absint( $item->ID ); ?>"/></label>
25
+ </div>
26
+ <?php
27
+ if ( 'audio' === $item->type ) {
28
+ echo gmedia_waveform_player( $item );
29
+ }
30
+ ?>
31
+ <div class="related-media-previews">
32
+ <?php
33
+ $related_ids = isset( $item->meta['_related'][0] ) ? $item->meta['_related'][0] : [];
34
+ if ( ! empty( $related_ids ) ) {
35
+ $related_media = $gmDB->get_gmedias( [ 'gmedia__in' => $related_ids, 'orderby' => 'gmedia__in' ] );
36
+ foreach ( $related_media as $r_item ) {
37
+ ?><p class="thumbnail gmedia-related-image"><span class="image-wrapper"><?php echo gmedia_item_thumbnail( $r_item ); ?></span></p><?php
38
+ }
39
+ }
40
+ ?>
41
+ </div>
42
+ </div>
43
+ <div class="col-sm-8">
44
+ <div class="row" style="margin:0;">
45
+ <div class="col-lg-6">
46
+ <p class="media-title"><?php echo esc_html( $item->title ); ?>&nbsp;</p>
47
 
48
+ <div class="in-library media-caption"><?php echo nl2br( esc_html( $item->description ) ); ?></div>
49
 
50
+ <p class="media-meta">
51
+ <span class="label label-default"><?php _e( 'Author', 'grand-media' ); ?>:</span> <?php printf( '<a class="gmedia-author" href="%s">%s</a>', esc_url( add_query_arg( [ 'author' => $item->author ], $gmedia_url ) ), get_user_option( 'display_name', $item->author ) ); ?>
52
+ <br/><span class="label label-default"><?php _e( 'Album', 'grand-media' ); ?>:</span>
53
+ <?php
54
+ if ( $item->album ) {
55
+ $terms_album = [];
56
+ foreach ( $item->album as $c ) {
57
+ $terms_album[] = sprintf( '<a class="album" href="%s">%s</a>', esc_url( add_query_arg( [ 'album__in' => $c->term_id ], $gmedia_url ) ), esc_html( $c->name ) );
58
+ }
59
+ $terms_album = join( ', ', $terms_album );
60
+ } else {
61
+ $terms_album = sprintf( '<a class="album" href="%s">%s</a>', esc_url( add_query_arg( [ 'album__in' => 0 ], $gmedia_url ) ), '&#8212;' );
62
+ }
63
+ echo $terms_album;
64
+ ?>
65
+ <br/><span class="label label-default"><?php _e( 'Category', 'grand-media' ); ?>:</span>
66
+ <?php
67
+ if ( $item->categories ) {
68
+ $terms_category = [];
69
+ foreach ( $item->categories as $c ) {
70
+ $terms_category[] = sprintf( '<a class="category" href="%s">%s</a>', esc_url( add_query_arg( [ 'category__in' => $c->term_id ], $gmedia_url ) ), esc_html( $c->name ) );
71
+ }
72
+ $terms_category = join( ', ', $terms_category );
73
+ } else {
74
+ $terms_category = sprintf( '<a class="category" href="%s">%s</a>', esc_url( add_query_arg( [ 'category__in' => 0 ], $gmedia_url ) ), __( 'Uncategorized', 'grand-media' ) );
75
+ }
76
+ echo $terms_category;
77
+ ?>
78
+ <br/><span class="label label-default"><?php _e( 'Tags', 'grand-media' ); ?>:</span>
79
+ <?php
80
+ if ( $item->tags ) {
81
+ $terms_tag = [];
82
+ foreach ( $item->tags as $c ) {
83
+ $terms_tag[] = sprintf( '<a class="tag" href="%s">%s</a>', esc_url( add_query_arg( [ 'tag__in' => $c->term_id ], $gmedia_url ) ), esc_html( $c->name ) );
84
+ }
85
+ $terms_tag = join( ', ', $terms_tag );
86
+ } else {
87
+ $terms_tag = '&#8212;';
88
+ }
89
+ echo $terms_tag;
90
+ ?>
91
+ </p>
92
+ </div>
93
+ <div class="col-lg-6">
94
+ <div class="media-meta gmedia-actions" style="margin:0 0 10px 0;">
95
+ <?php $media_action_links = gmedia_item_actions( $item );
96
+ echo implode( ' | ', $media_action_links );
97
+ ?>
98
+ </div>
99
+ <?php if ( isset( $item->post_id ) ) { ?>
100
+ <p class="media-meta">
101
+ <span class="label label-default"><?php _e( 'Comments', 'grand-media' ); ?>:</span>
102
+ <a href="<?php echo esc_url( add_query_arg( [ 'page' => 'GrandMedia', 'gmediablank' => 'comments', 'gmedia_id' => $item->ID ], $gmProcessor->url ) ); ?>" data-target="#previewModal" data-width="900" data-height="500" class="preview-modal gmpost-com-count" title="<?php esc_attr_e( 'Comments', 'grand-media' ); ?>">
103
+ <b class="comment-count"><?php echo $item->comment_count; ?></b>
104
+ <span class="glyphicon glyphicon-comment"></span>
105
+ </a>
106
+ </p>
107
+ <?php } ?>
108
+ <p class="media-meta">
109
+ <span class="label label-default"><?php _e( 'Views / Likes', 'grand-media' ); ?>:</span>
110
+ <?php echo ( isset( $item->meta['views'][0] ) ? $item->meta['views'][0] : '0' ) . ' / ' . ( isset( $item->meta['likes'][0] ) ? $item->meta['likes'][0] : '0' ); ?>
111
 
112
+ <?php if ( isset( $item->meta['_rating'][0] ) ) {
113
+ $ratings = maybe_unserialize( $item->meta['_rating'][0] ); ?>
114
+ <br/><span class="label label-default"><?php _e( 'Rating', 'grand-media' ); ?>:</span> <?php echo round( $ratings['value'], 2 ) . ' / ' . $ratings['votes']; ?>
115
+ <?php } ?>
116
+ <br/><span class="label label-default"><?php _e( 'Status', 'grand-media' ); ?>:</span> <?php echo $item->status; ?>
117
+ <br/><span class="label label-default"><?php _e( 'Link', 'grand-media' ); ?>:</span>
118
+ <?php if ( ! empty( $item->link ) ) { ?>
119
+ <a href="<?php echo esc_url( $item->link ); ?>"><?php echo esc_attr( $item->link ); ?></a>
120
+ <?php
121
+ } else {
122
+ echo '&#8212;';
123
+ } ?>
124
+ <?php if ( ! empty( $item->gps ) ) { ?>
125
+ <br/><span class="label label-default"><?php _e( 'GPS Location', 'grand-media' ); ?>:</span> <?php echo $item->gps; ?>
126
+ <?php } ?>
127
+ </p>
128
+ <p class="media-meta">
129
+ <span class="label label-default"><?php _e( 'Type', 'grand-media' ); ?>:</span> <?php echo $item->mime_type; ?>
130
+ <?php if ( ( 'image' === $item->type ) && $item->editor && ! empty( $item->meta['_metadata'] ) ) {
131
+ ?>
132
+ <br/><span class="label label-default"><?php _e( 'Dimensions', 'grand-media' ); ?>:</span>
133
+ <?php
134
+ $is_file_original = (bool) $item->path_original;
135
+ if ( $is_file_original ) { ?>
136
+ <a href="<?php echo esc_url( $item->url_original ); ?>"
137
+ data-target="#previewModal"
138
+ data-width="<?php echo esc_attr( $item->meta['_metadata'][0]['original']['width'] ); ?>"
139
+ data-height="<?php echo esc_attr( $item->meta['_metadata'][0]['original']['height'] ); ?>"
140
+ class="preview-modal"
141
+ title="<?php _e( 'Original', 'grand-media' ); ?>"><?php echo $item->meta['_metadata'][0]['original']['width'] . '×' . $item->meta['_metadata'][0]['original']['height']; ?></a>,
142
+ <?php } else { ?>
143
+ <span title="<?php _e( 'Original', 'grand-media' ); ?>"><?php echo $item->meta['_metadata'][0]['original']['width'] . '×' . $item->meta['_metadata'][0]['original']['height']; ?></span>,
144
+ <?php } ?>
145
+ <a href="<?php echo esc_url( $item->url ); ?>"
146
+ data-target="#previewModal"
147
+ data-width="<?php echo esc_attr( $item->meta['_metadata'][0]['web']['width'] ); ?>"
148
+ data-height="<?php echo esc_attr( $item->meta['_metadata'][0]['web']['height'] ); ?>"
149
+ class="preview-modal"
150
+ title="<?php _e( 'Webimage', 'grand-media' ); ?>"><?php echo $item->meta['_metadata'][0]['web']['width'] . '×' . $item->meta['_metadata'][0]['web']['height']; ?></a>,
151
+ <a href="<?php echo esc_url( $item->url_thumb ); ?>"
152
+ data-target="#previewModal"
153
+ data-width="<?php echo esc_attr( $item->meta['_metadata'][0]['thumb']['width'] ); ?>"
154
+ data-height="<?php echo esc_attr( $item->meta['_metadata'][0]['thumb']['height'] ); ?>"
155
+ class="preview-modal"
156
+ title="<?php _e( 'Thumbnail', 'grand-media' ); ?>"><?php echo $item->meta['_metadata'][0]['thumb']['width'] . '×' . $item->meta['_metadata'][0]['thumb']['height']; ?></a>
157
+ <?php } ?>
158
+ <br/><span class="label label-default"><?php _e( 'Filename', 'grand-media' ); ?>:</span> <a href="<?php echo esc_url( $item->url ); ?>" download="<?php echo esc_attr( $item->gmuid ); ?>"><?php echo $item->gmuid; ?></a>
159
+ <?php if ( ! empty( $item->meta['_created_timestamp'][0] ) ) { ?>
160
+ <br/><span class="label label-default"><?php _e( 'Created', 'grand-media' ) ?>:</span> <?php echo date( 'Y-m-d H:i:s ', $item->meta['_created_timestamp'][0] ); ?>
161
+ <?php } ?>
162
+ <br/><span class="label label-default"><?php _e( 'Uploaded', 'grand-media' ) ?>:</span> <?php echo $item->date; ?>
163
+ <br/><span class="label label-default"><?php _e( 'Last Edited', 'grand-media' ) ?>:</span> <span class="gm-last-edited modified"><?php echo $item->modified; ?></span>
164
+ </p>
165
+ </div>
166
+ </div>
167
+ </div>
168
  </div>
 
admin/pages/library/tpl/no-items.php CHANGED
@@ -1,29 +1,29 @@
1
  <?php
2
- // don't load directly
3
- if(!defined('ABSPATH')){
4
- die('-1');
5
  }
6
  global $gmCore, $gmProcessor;
7
  ?>
8
  <div class="list-group-item">
9
- <div class="well well-lg text-center">
10
- <?php if('duplicates' === $gmCore->_get('gmedia__in')){
11
- echo '<h4>' . __('No duplicates in Gmedia Library.', 'grand-media') . '</h4>';
12
- } else{
13
- echo '<h4>' . __('No items to show.', 'grand-media') . '</h4>';
14
- if(gm_user_can('upload') && !$gmProcessor->gmediablank){
15
- $args = array('page' => 'GrandMedia_AddMedia');
16
- if($gmProcessor->edit_term){
17
- $taxterm = $gmProcessor->taxterm;
18
- $args[ $taxterm ] = $gmProcessor->edit_term;
19
- }
20
- ?>
21
- <p>
22
- <a href="<?php echo gm_get_admin_url($args, array(), true); ?>" class="btn btn-success">
23
- <span class="glyphicon glyphicon-plus"></span> <?php _e('Add Media', 'grand-media'); ?>
24
- </a>
25
- </p>
26
- <?php }
27
- } ?>
28
- </div>
29
  </div>
1
  <?php
2
+ // don't load directly.
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ die( '-1' );
5
  }
6
  global $gmCore, $gmProcessor;
7
  ?>
8
  <div class="list-group-item">
9
+ <div class="well well-lg text-center">
10
+ <?php if ( 'duplicates' === $gmCore->_get( 'gmedia__in' ) ) {
11
+ echo '<h4>' . __( 'No duplicates in Gmedia Library.', 'grand-media' ) . '</h4>';
12
+ } else {
13
+ echo '<h4>' . __( 'No items to show.', 'grand-media' ) . '</h4>';
14
+ if ( gm_user_can( 'upload' ) && ! $gmProcessor->gmediablank ) {
15
+ $args = [ 'page' => 'GrandMedia_AddMedia' ];
16
+ if ( $gmProcessor->edit_term ) {
17
+ $taxterm = $gmProcessor->taxterm;
18
+ $args[ $taxterm ] = $gmProcessor->edit_term;
19
+ }
20
+ ?>
21
+ <p>
22
+ <a href="<?php echo esc_url( gm_get_admin_url( $args, [], true ) ); ?>" class="btn btn-success">
23
+ <span class="glyphicon glyphicon-plus"></span> <?php _e( 'Add Media', 'grand-media' ); ?>
24
+ </a>
25
+ </p>
26
+ <?php }
27
+ } ?>
28
+ </div>
29
  </div>
admin/pages/library/tpl/panel-footer.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
- // don't load directly
3
- if(!defined('ABSPATH')) {
4
- die('-1');
5
  }
6
  ?>
7
  <div class="panel-footer clearfix">
8
- <?php echo $gmedia_pager; ?>
9
 
10
- <a href="#top" class="btn btn-default btn-sm"><span class="glyphicon glyphicon-arrow-up"></span> <?php _e('Back to top', 'grand-media'); ?></a>
11
  </div>
1
  <?php
2
+ // don't load directly.
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ die( '-1' );
5
  }
6
  ?>
7
  <div class="panel-footer clearfix">
8
+ <?php echo $gmedia_pager; ?>
9
 
10
+ <a href="#top" class="btn btn-default btn-sm"><span class="glyphicon glyphicon-arrow-up"></span> <?php _e( 'Back to top', 'grand-media' ); ?></a>
11
  </div>
admin/pages/library/tpl/panel-heading.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- // don't load directly
3
- if(!defined('ABSPATH')){
4
- die('-1');
5
  }
6
 
7
  /**
@@ -11,247 +11,253 @@ if(!defined('ABSPATH')){
11
  ?>
12
  <div class="panel-heading-fake"></div>
13
  <div class="panel-heading clearfix" style="padding-bottom:2px;">
14
- <div class="pull-right" style="margin-bottom:3px;">
15
- <div class="clearfix">
16
- <?php include(GMEDIA_ABSPATH . 'admin/tpl/search-form.php'); ?>
17
 
18
- <div class="btn-toolbar pull-right" style="margin-bottom:4px; margin-left:4px;">
19
- <?php if(!$gmProcessor->gmediablank){ ?>
20
- <a title="<?php _e('More Screen Settings', 'grand-media'); ?>" class="show-settings-link pull-right btn btn-default btn-xs"><span class="glyphicon glyphicon-cog"></span></a>
21
- <?php } ?>
22
 
23
- <?php if($gmProcessor->mode != 'edit'){
24
- $view = $gmProcessor->gmediablank? '_frame' : '';
25
- $display_mode_gmedia = $gmProcessor->display_mode;
26
- if(!$gmProcessor->edit_term && !in_array($gmProcessor->mode, array('select_single', 'select_mutiple'))){ ?>
27
- <div class="btn-group pull-right">
28
- <a title="<?php _e('Show as Grid', 'grand-media'); ?>" href="<?php echo gm_get_admin_url(array('display_mode' => 'grid')); ?>" class="btn btn<?php echo ($display_mode_gmedia == 'grid')? '-primary active' : '-default'; ?> btn-xs"><span class="glyphicon glyphicon-th"></span></a>
29
- <a title="<?php _e('Show as List', 'grand-media'); ?>" href="<?php echo gm_get_admin_url(array('display_mode' => 'list')); ?>" class="btn btn<?php echo ($display_mode_gmedia == 'list')? '-primary active' : '-default'; ?> btn-xs"><span class="glyphicon glyphicon-th-list"></span></a>
30
- </div>
31
- <?php
32
- }
33
- if($display_mode_gmedia == 'grid'){ ?>
34
- <a title="<?php _e('Thumbnails Fit/Fill Cell', 'grand-media'); ?>" href="<?php echo gm_get_admin_url(array('grid_cell_fit' => 'toggle')); ?>" class="fit-thumbs pull-right btn btn<?php echo ($gmedia_user_options["grid_cell_fit_gmedia{$view}"] == 'true')? '-success active' : '-default'; ?> btn-xs"><span class="glyphicon glyphicon-eye-open"></span></a>
35
- <?php } ?>
36
- <?php } ?>
37
- </div>
38
- </div>
39
 
40
- <?php echo $gmedia_pager; ?>
41
 
42
- <div class="spinner"></div>
43
 
44
- </div>
45
- <div class="btn-toolbar pull-left" style="margin-bottom:7px;">
46
- <?php if($gmProcessor->mode != 'select_single'){ ?>
47
- <div class="btn-group gm-checkgroup" id="cb_global-btn">
48
- <span class="btn btn-default active"><input class="doaction" id="cb_global" data-group="gm-item-check" type="checkbox"/></span>
49
- <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span>
50
- <span class="sr-only"><?php _e('Toggle Dropdown', 'grand-media'); ?></span></button>
51
- <ul class="dropdown-menu" role="menu">
52
- <li><a data-select="total" href="#"><?php _e('All', 'grand-media'); ?></a></li>
53
- <li><a data-select="none" href="#"><?php _e('None', 'grand-media'); ?></a></li>
54
- <li class="divider"></li>
55
- <li><a data-select="image" href="#"><?php _e('Images', 'grand-media'); ?></a></li>
56
- <li><a data-select="audio" href="#"><?php _e('Audio', 'grand-media'); ?></a></li>
57
- <li><a data-select="video" href="#"><?php _e('Video', 'grand-media'); ?></a></li>
58
- <li class="divider"></li>
59
- <li><a data-select="reverse" href="#" title="<?php _e('Reverse only visible items', 'grand-media'); ?>"><?php _e('Reverse', 'grand-media'); ?></a></li>
60
- </ul>
61
- </div>
62
- <?php } ?>
63
 
64
- <div class="btn-group">
65
- <?php // todo: !!!!!
66
- $curr_mime = explode(',', $gmCore->_get('mime_type', 'total'));
67
- if(('show' == $gmCore->_get('stack') || 'selected' == $gmCore->_get('filter')) && isset($gmedia_filter['gmedia__in'])){
68
- if($gmProcessor->selected_items == $gmedia_filter['gmedia__in'] || $gmProcessor->stack_items == $gmedia_filter['gmedia__in']){
69
- unset($gmedia_filter['gmedia__in']);
70
- }
71
- }
72
- ?>
73
- <?php if(!empty($gmedia_filter)){ ?>
74
- <a class="btn btn-warning" title="<?php _e('Reset Filter', 'grand-media'); ?>" rel="total" href="<?php echo gm_get_admin_url(array(), array(), $gmedia_url); ?>"><?php _e('Reset Filter', 'grand-media'); ?></a>
75
- <?php } else{ ?>
76
- <button type="button" class="btn btn-default" data-toggle="dropdown"><?php _e('Filter', 'grand-media'); ?></button>
77
- <?php } ?>
78
- <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
79
- <span class="caret"></span>
80
- <span class="sr-only"><?php _e('Toggle Dropdown', 'grand-media'); ?></span>
81
- </button>
82
- <ul class="dropdown-menu" role="menu">
83
- <?php if(gm_user_can('show_others_media')){ ?>
84
- <li role="presentation" class="dropdown-header"><?php _e('FILTER BY AUTHOR', 'grand-media'); ?></li>
85
- <li class="gmedia_author">
86
- <a href="#libModal" data-modal="filter_author" data-action="gmedia_get_modal" class="gmedia-modal"><?php _e('Choose authors', 'grand-media'); ?></a>
87
- </li>
88
- <?php } ?>
 
 
 
 
89
 
90
- <?php
91
 
92
- $gm_qty_badge = array('total' => '',
93
- 'image' => '',
94
- 'audio' => '',
95
- 'video' => '',
96
- 'text' => '',
97
- 'application' => '',
98
- 'other' => ''
99
- );
 
100
 
101
- foreach($gmedia_count as $key => $value){
102
- $gm_qty_badge[ $key ] = '<span class="badge pull-right">' . (int)$value . '</span>';
103
- }
104
- ?>
105
- <li role="presentation" class="dropdown-header"><?php _e('TYPE', 'grand-media'); ?></li>
106
- <li class="total<?php echo in_array('total', $curr_mime)? ' active' : ''; ?>"><a rel="total" href="<?php echo gm_get_admin_url(array(), array('mime_type', 'pager')); ?>"><?php echo $gm_qty_badge['total'] . __('All', 'grand-media'); ?></a></li>
107
- <?php if($gmProcessor->mode != 'select_single'){ ?>
108
- <li class="image<?php echo (in_array('image', $curr_mime)? ' active' : '') . ($gmedia_count['image']? '' : ' disabled'); ?>"><a rel="image" href="<?php echo gm_get_admin_url(array('mime_type' => 'image'), array('pager')); ?>"><?php echo $gm_qty_badge['image'] . __('Images', 'grand-media'); ?></a></li>
109
- <li class="audio<?php echo (in_array('audio', $curr_mime)? ' active' : '') . ($gmedia_count['audio']? '' : ' disabled'); ?>"><a rel="audio" href="<?php echo gm_get_admin_url(array('mime_type' => 'audio'), array('pager')); ?>"><?php echo $gm_qty_badge['audio'] . __('Audio', 'grand-media'); ?></a></li>
110
- <li class="video<?php echo (in_array('video', $curr_mime)? ' active' : '') . ($gmedia_count['video']? '' : ' disabled'); ?>"><a rel="video" href="<?php echo gm_get_admin_url(array('mime_type' => 'video'), array('pager')); ?>"><?php echo $gm_qty_badge['video'] . __('Video', 'grand-media'); ?></a></li>
111
- <li class="application<?php echo ((in_array('application', $curr_mime) || in_array('text', $curr_mime))? ' active' : '') . ($gmedia_count['other']? '' : ' disabled'); ?>">
112
- <a rel="application" href="<?php echo gm_get_admin_url(array('mime_type' => 'application,text'), array('pager')); ?>"><?php echo $gm_qty_badge['other'] . __('Other', 'grand-media'); ?></a></li>
113
- <?php } ?>
114
 
115
- <li role="presentation" class="dropdown-header"><?php _e('COLLECTIONS', 'grand-media'); ?></li>
116
- <li class="filter_categories<?php echo isset($gmedia_filter['category__in'])? ' active' : ''; ?>"><a href="#libModal" data-modal="filter_categories" data-action="gmedia_get_modal" class="gmedia-modal"><?php _e('Categories', 'grand-media'); ?></a></li>
117
- <?php if(!($gmProcessor->edit_term && 'album' === $gmProcessor->taxterm)){ ?>
118
- <li class="filter_albums<?php echo isset($gmedia_filter['album__in'])? ' active' : ''; ?>"><a href="#libModal" data-modal="filter_albums" data-action="gmedia_get_modal" class="gmedia-modal"><?php _e('Albums', 'grand-media'); ?></a></li>
119
- <?php } ?>
120
- <li class="filter_tags<?php echo isset($gmedia_filter['tag__in'])? ' active' : ''; ?>"><a href="#libModal" data-modal="filter_tags" data-action="gmedia_get_modal" class="gmedia-modal"><?php _e('Tags', 'grand-media'); ?></a></li>
121
- <?php do_action('gmedia_filter_list'); ?>
122
- </ul>
123
- </div>
124
 
125
- <?php if(!in_array($gmProcessor->mode, array('select_single', 'select_mutiple'))){ ?>
126
- <div class="btn-group">
127
- <?php if($gmProcessor->mode != 'edit'){
128
- $edit_mode_href = gm_get_admin_url(array('mode' => 'edit'));
129
- } else{
130
- $edit_mode_href = gm_get_admin_url(array(), array('mode'));
131
- } ?>
132
- <?php if(gm_user_can('edit_media')){ ?>
133
- <a class="btn btn-default edit-mode-link" title="<?php _e('Toggle Edit Mode', 'grand-media'); ?>" href="<?php echo $edit_mode_href; ?>"><?php _e('Action', 'grand-media'); ?></a>
134
- <?php } else{ ?>
135
- <button type="button" class="btn btn-default"><?php _e('Action', 'grand-media'); ?></button>
136
- <?php } ?>
137
- <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span>
138
- <span class="sr-only"><?php _e('Toggle Dropdown', 'grand-media'); ?></span></button>
139
- <?php
140
- $rel_selected_show = 'rel-selected-show';
141
- $rel_selected_hide = 'rel-selected-hide';
142
- ?>
143
- <ul class="dropdown-menu" role="menu">
144
- <?php if(!($gmProcessor->mode == 'edit')){ ?>
145
- <li class="<?php echo gm_user_can('edit_media')? '' : 'disabled'; ?>">
146
- <a class="edit-mode-link" href="<?php echo $edit_mode_href; ?>"><?php _e('Enter Edit Mode', 'grand-media'); ?></a>
147
- </li>
148
- <?php } else{ ?>
149
- <li><a href="<?php echo $edit_mode_href; ?>"><?php _e('Exit Edit Mode', 'grand-media'); ?></a></li>
150
- <?php } ?>
151
- <li class="<?php echo $rel_selected_show . (gm_user_can('edit_media')? '' : ' disabled'); ?>">
152
- <a href="#libModal" data-modal="batch_edit" data-action="gmedia_get_modal" data-ckey="<?php echo GmediaProcessor_Library::$cookie_key; ?>" class="gmedia-modal"><?php _e('Batch Edit', 'grand-media'); ?></a></li>
153
 
154
- <li class="divider <?php echo $rel_selected_show; ?>"></li>
155
- <li class="<?php echo $rel_selected_show . (gm_user_can('terms')? '' : ' disabled'); ?>">
156
- <a href="#libModal" data-modal="assign_album" data-action="gmedia_get_modal" data-ckey="<?php echo GmediaProcessor_Library::$cookie_key; ?>" class="gmedia-modal"><?php _e('Move to Album...', 'grand-media'); ?></a>
157
- </li>
158
- <li class="<?php echo $rel_selected_show . (gm_user_can('terms')? '' : ' disabled'); ?>">
159
- <a href="<?php echo wp_nonce_url(gm_get_admin_url(array('do_gmedia' => 'unassign_album')), 'gmedia_action', '_wpnonce_action') ?>" data-confirm="<?php _e("You are about to remove the selected items from assigned albums.\n\r'Cancel' to stop, 'OK' to delete.", "grand-media"); ?>"><?php _e('Remove from Album', 'grand-media'); ?></a>
160
- </li>
161
- <li class="<?php echo $rel_selected_show . (gm_user_can('terms')? '' : ' disabled'); ?>">
162
- <a href="#libModal" data-modal="assign_category" data-action="gmedia_get_modal" data-ckey="<?php echo GmediaProcessor_Library::$cookie_key; ?>" class="gmedia-modal"><?php _e('Assign Categories...', 'grand-media'); ?></a>
163
- </li>
164
- <li class="<?php echo $rel_selected_show . (gm_user_can('terms')? '' : ' disabled'); ?>">
165
- <a href="#libModal" data-modal="unassign_category" data-action="gmedia_get_modal" data-ckey="<?php echo GmediaProcessor_Library::$cookie_key; ?>" class="gmedia-modal"><?php _e('Unassign Categories...', 'grand-media'); ?></a>
166
- </li>
167
- <li class="<?php echo $rel_selected_show . (gm_user_can('terms')? '' : ' disabled'); ?>">
168
- <a href="#libModal" data-modal="add_tags" data-action="gmedia_get_modal" data-ckey="<?php echo GmediaProcessor_Library::$cookie_key; ?>" class="gmedia-modal"><?php _e('Add Tags...', 'grand-media'); ?></a></li>
169
- <li class="<?php echo $rel_selected_show . (gm_user_can('terms')? '' : ' disabled'); ?>">
170
- <a href="#libModal" data-modal="delete_tags" data-action="gmedia_get_modal" data-ckey="<?php echo GmediaProcessor_Library::$cookie_key; ?>" class="gmedia-modal"><?php _e('Delete Tags...', 'grand-media'); ?></a>
171
- </li>
172
- <li class="<?php echo $rel_selected_show . (gm_user_can('delete_media')? '' : ' disabled'); ?>">
173
- <a href="<?php echo wp_nonce_url(gm_get_admin_url(array('do_gmedia' => 'delete',
174
- 'ids' => 'selected'
175
- ), array('filter')), 'gmedia_delete', '_wpnonce_delete') ?>" class="gmedia-delete" data-confirm="<?php _e("You are about to permanently delete the selected items.\n\r'Cancel' to stop, 'OK' to delete.", "grand-media"); ?>"><?php _e('Delete Selected Items', 'grand-media'); ?></a>
176
- </li>
 
177
 
178
- <?php if(!$gmProcessor->gmediablank){ ?>
179
- <li class="divider <?php echo $rel_selected_show; ?>"></li>
180
- <li class="<?php echo $rel_selected_show . (gm_user_can('edit_media')? '' : ' disabled'); ?>">
181
- <a href="<?php echo wp_nonce_url(gm_get_admin_url(array('do_gmedia' => 'recreate'), array()), 'gmedia_action', '_wpnonce_action') ?>" class="gmedia-update"><?php _e('Re-create Images (heavy process)', 'grand-media'); ?></a>
182
- </li>
183
- <li class="<?php echo $rel_selected_show . (gm_user_can('edit_media')? '' : ' disabled'); ?>">
184
- <a href="<?php echo wp_nonce_url(gm_get_admin_url(array('do_gmedia' => 'update_meta'), array()), 'gmedia_action', '_wpnonce_action') ?>" class="gmedia-update"><?php _e('Update Metadata in Database', 'grand-media'); ?></a>
185
- </li>
186
 
187
- <li class="divider"></li>
188
- <li>
189
- <a href="<?php echo gm_get_admin_url(array('page' => 'GrandMedia', 'gmedia__in' => 'duplicates'), array(), true); ?>"><?php _e('Show Duplicates in Library', 'grand-media'); ?></a>
190
- </li>
191
- <?php } ?>
192
 
193
- <li class="divider <?php echo $rel_selected_hide; ?>"></li>
194
- <li class="dropdown-header <?php echo $rel_selected_hide; ?>"><span><?php _e("Select items to see more actions", "grand-media"); ?></span></li>
195
- <?php do_action('gmedia_action_list'); ?>
196
 
197
- </ul>
198
- </div>
199
- <?php }
200
- do_action('gmedia_library_btn_toolbar');
201
- ?>
202
 
203
- <?php
204
- $filter_stack = $gmCore->_req('stack');
205
- $filter_stack_arg = $filter_stack? false : 'show';
206
 
207
- $filter_selected = ('selected' == $gmCore->_req('filter'));
208
- $filter_selected_arg = $filter_selected? false : 'selected';
209
- ?>
210
- <form class="btn-group" id="gm-stack-btn" name="gm-stack-form" action="<?php echo gm_get_admin_url(array('stack' => $filter_stack_arg, 'filter' => $filter_selected), array(), $gmedia_url); ?>" method="post">
211
- <button type="submit" class="btn btn<?php echo ('show' == $filter_stack)? '-success' : '-info' ?>"><?php printf(__('%s in Stack', 'grand-media'), '<span id="gm-stack-qty">' . count($gmProcessor->stack_items) . '</span>'); ?></button>
212
- <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown"><span class="caret"></span>
213
- <span class="sr-only"><?php _e('Toggle Dropdown', 'grand-media'); ?></span></button>
214
- <input type="hidden" id="gm-stack" data-userid="<?php echo $user_ID; ?>" data-key="gmedia_<?php echo $user_ID; ?>_libstack" name="stack_items" value="<?php echo implode(',', $gmProcessor->stack_items); ?>"/>
215
- <ul class="dropdown-menu" role="menu">
216
- <li><a id="gm-stack-show" href="#show"><?php
217
- if(!$filter_stack){
218
- _e('Show Stack', 'grand-media');
219
- } else{
220
- _e('Show Library', 'grand-media');
221
- }
222
- ?></a></li>
223
- <li><a id="gm-stack-clear" href="#clear"><?php _e('Clear Stack', 'grand-media'); ?></a></li>
224
- <li class="<?php echo gm_user_can('gallery_manage')? '' : 'disabled'; ?>">
225
- <a href="#libModal" data-modal="quick_gallery_stack" data-action="gmedia_get_modal" data-ckey="gmedia_<?php echo $user_ID; ?>_libstack" class="gmedia-modal"><?php _e('Quick Gallery from Stack', 'grand-media'); ?></a>
226
- </li>
227
- </ul>
228
- </form>
229
 
230
- <?php if($gmProcessor->mode != 'select_single'){ ?>
231
- <form class="btn-group<?php echo $filter_selected? ' gm-active' : ''; ?>" id="gm-selected-btn" name="gm-selected-form" action="<?php echo gm_get_admin_url(array('stack' => $filter_stack, 'filter' => $filter_selected_arg), array(), $gmedia_url); ?>" method="post">
232
- <button type="submit" class="btn btn<?php echo ('selected' == $filter_selected)? '-success' : '-info' ?>"><?php printf(__('%s selected', 'grand-media'), '<span id="gm-selected-qty">' . count($gmProcessor->selected_items) . '</span>'); ?></button>
233
- <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown"><span class="caret"></span>
234
- <span class="sr-only"><?php _e('Toggle Dropdown', 'grand-media'); ?></span></button>
235
- <input type="hidden" id="gm-selected" data-userid="<?php echo $user_ID; ?>" data-key="<?php echo GmediaProcessor_Library::$cookie_key; ?>" name="selected_items" value="<?php echo implode(',', $gmProcessor->selected_items); ?>"/>
236
- <ul class="dropdown-menu" role="menu">
237
- <li><a id="gm-selected-show" href="#show"><?php
238
- if(!$filter_selected){
239
- _e('Show only selected items', 'grand-media');
240
- } else{
241
- _e('Show all gmedia items', 'grand-media');
242
- }
243
- ?></a></li>
244
- <li><a id="gm-selected-clear" href="#clear"><?php _e('Clear selected items', 'grand-media'); ?></a></li>
245
- <li><a id="gm-stack-in" href="#stack_add"><?php _e('Add selected items to Stack', 'grand-media'); ?></a></li>
246
- <li><a id="gm-stack-out" href="#stack_remove"><?php _e('Remove selected items from Stack', 'grand-media'); ?></a></li>
247
- <?php if($gmProcessor->mode != 'select_multiple'){ ?>
248
- <li class="<?php echo gm_user_can('gallery_manage')? '' : 'disabled'; ?>">
249
- <a href="#libModal" data-modal="quick_gallery" data-action="gmedia_get_modal" data-ckey="<?php echo GmediaProcessor_Library::$cookie_key; ?>" class="gmedia-modal"><?php _e('Quick Gallery from Selected', 'grand-media'); ?></a>
250
- </li>
251
- <?php } ?>
252
- </ul>
253
- </form>
254
- <?php } ?>
255
- </div>
256
 
257
  </div>
1
  <?php
2
+ // don't load directly.
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ die( '-1' );
5
  }
6
 
7
  /**
11
  ?>
12
  <div class="panel-heading-fake"></div>
13
  <div class="panel-heading clearfix" style="padding-bottom:2px;">
14
+ <div class="pull-right" style="margin-bottom:3px;">
15
+ <div class="clearfix">
16
+ <?php include GMEDIA_ABSPATH . 'admin/tpl/search-form.php'; ?>
17
 
18
+ <div class="btn-toolbar pull-right" style="margin-bottom:4px; margin-left:4px;">
19
+ <?php if ( ! $gmProcessor->gmediablank ) { ?>
20
+ <a title="<?php _e( 'More Screen Settings', 'grand-media' ); ?>" class="show-settings-link pull-right btn btn-default btn-xs"><span class="glyphicon glyphicon-cog"></span></a>
21
+ <?php } ?>
22
 
23
+ <?php if ( $gmProcessor->mode !== 'edit' ) {
24
+ $view = $gmProcessor->gmediablank ? '_frame' : '';
25
+ $display_mode_gmedia = $gmProcessor->display_mode;
26
+ if ( ! $gmProcessor->edit_term && ! in_array( $gmProcessor->mode, [ 'select_single', 'select_mutiple' ], true ) ) { ?>
27
+ <div class="btn-group pull-right">
28
+ <a title="<?php _e( 'Show as Grid', 'grand-media' ); ?>" href="<?php echo esc_url( gm_get_admin_url( [ 'display_mode' => 'grid' ] ) ); ?>" class="btn btn<?php echo ( $display_mode_gmedia === 'grid' ) ? '-primary active' : '-default'; ?> btn-xs"><span class="glyphicon glyphicon-th"></span></a>
29
+ <a title="<?php _e( 'Show as List', 'grand-media' ); ?>" href="<?php echo esc_url( gm_get_admin_url( [ 'display_mode' => 'list' ] ) ); ?>" class="btn btn<?php echo ( $display_mode_gmedia === 'list' ) ? '-primary active' : '-default'; ?> btn-xs"><span class="glyphicon glyphicon-th-list"></span></a>
30
+ </div>
31
+ <?php
32
+ }
33
+ if ( $display_mode_gmedia === 'grid' ) { ?>
34
+ <a title="<?php _e( 'Thumbnails Fit/Fill Cell', 'grand-media' ); ?>" href="<?php echo esc_url( gm_get_admin_url( [ 'grid_cell_fit' => 'toggle' ] ) ); ?>" class="fit-thumbs pull-right btn btn<?php echo ( $gmedia_user_options["grid_cell_fit_gmedia{$view}"] === 'true' ) ? '-success active' : '-default'; ?> btn-xs"><span class="glyphicon glyphicon-eye-open"></span></a>
35
+ <?php } ?>
36
+ <?php } ?>
37
+ </div>
38
+ </div>
39
 
40
+ <?php echo $gmedia_pager; ?>
41
 
42
+ <div class="spinner"></div>
43
 
44
+ </div>
45
+ <div class="btn-toolbar pull-left" style="margin-bottom:7px;">
46
+ <?php if ( $gmProcessor->mode !== 'select_single' ) { ?>
47
+ <div class="btn-group gm-checkgroup" id="cb_global-btn">
48
+ <span class="btn btn-default active"><input class="doaction" id="cb_global" data-group="gm-item-check" type="checkbox"/></span>
49
+ <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span>
50
+ <span class="sr-only"><?php _e( 'Toggle Dropdown', 'grand-media' ); ?></span></button>
51
+ <ul class="dropdown-menu" role="menu">
52
+ <li><a data-select="total" href="#"><?php _e( 'All', 'grand-media' ); ?></a></li>
53
+ <li><a data-select="none" href="#"><?php _e( 'None', 'grand-media' ); ?></a></li>
54
+ <li class="divider"></li>
55
+ <li><a data-select="image" href="#"><?php _e( 'Images', 'grand-media' ); ?></a></li>
56
+ <li><a data-select="audio" href="#"><?php _e( 'Audio', 'grand-media' ); ?></a></li>
57
+ <li><a data-select="video" href="#"><?php _e( 'Video', 'grand-media' ); ?></a></li>
58
+ <li class="divider"></li>
59
+ <li><a data-select="reverse" href="#" title="<?php _e( 'Reverse only visible items', 'grand-media' ); ?>"><?php _e( 'Reverse', 'grand-media' ); ?></a></li>
60
+ </ul>
61
+ </div>
62
+ <?php } ?>
63
 
64
+ <div class="btn-group">
65
+ <?php // todo: !!!!!
66
+ $curr_mime = explode( ',', $gmCore->_get( 'mime_type', 'total' ) );
67
+ if ( isset( $gmedia_filter['gmedia__in'] ) ) {
68
+ if ( ( 'show' === $gmCore->_get( 'stack' ) || 'selected' === $gmCore->_get( 'filter' ) ) ) {
69
+ if ( $gmProcessor->selected_items === $gmedia_filter['gmedia__in'] || $gmProcessor->stack_items === $gmedia_filter['gmedia__in'] ) {
70
+ unset( $gmedia_filter['gmedia__in'] );
71
+ }
72
+ } elseif ( $gmProcessor->edit_term ) {
73
+ unset( $gmedia_filter['gmedia__in'] );
74
+ }
75
+ }
76
+ ?>
77
+ <?php if ( ! empty( $gmedia_filter ) ) { ?>
78
+ <a class="btn btn-warning" title="<?php _e( 'Reset Filter', 'grand-media' ); ?>" rel="total" href="<?php echo esc_url( gm_get_admin_url( [], [], $gmedia_url ) ); ?>"><?php _e( 'Reset Filter', 'grand-media' ); ?></a>
79
+ <?php } else { ?>
80
+ <button type="button" class="btn btn-default" data-toggle="dropdown"><?php _e( 'Filter', 'grand-media' ); ?></button>
81
+ <?php } ?>
82
+ <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
83
+ <span class="caret"></span>
84
+ <span class="sr-only"><?php _e( 'Toggle Dropdown', 'grand-media' ); ?></span>
85
+ </button>
86
+ <ul class="dropdown-menu" role="menu">
87
+ <?php if ( gm_user_can( 'show_others_media' ) ) { ?>
88
+ <li role="presentation" class="dropdown-header"><?php _e( 'FILTER BY AUTHOR', 'grand-media' ); ?></li>
89
+ <li class="gmedia_author">
90
+ <a href="#libModal" data-modal="filter_author" data-action="gmedia_get_modal" class="gmedia-modal"><?php _e( 'Choose authors', 'grand-media' ); ?></a>
91
+ </li>
92
+ <?php } ?>
93
 
94
+ <?php
95
 
96
+ $gm_qty_badge = [
97
+ 'total' => '',
98
+ 'image' => '',
99
+ 'audio' => '',
100
+ 'video' => '',
101
+ 'text' => '',
102
+ 'application' => '',
103
+ 'other' => '',
104
+ ];
105
 
106
+ foreach ( $gmedia_count as $key => $value ) {
107
+ $gm_qty_badge[ $key ] = '<span class="badge pull-right">' . (int) $value . '</span>';
108
+ }
109
+ ?>
110
+ <li role="presentation" class="dropdown-header"><?php _e( 'TYPE', 'grand-media' ); ?></li>
111
+ <li class="total<?php echo in_array( 'total', $curr_mime, true ) ? ' active' : ''; ?>"><a rel="total" href="<?php echo esc_url( gm_get_admin_url( [], [ 'mime_type', 'pager' ] ) ); ?>"><?php echo $gm_qty_badge['total'] . __( 'All', 'grand-media' ); ?></a></li>
112
+ <?php if ( $gmProcessor->mode !== 'select_single' ) { ?>
113
+ <li class="image<?php echo ( in_array( 'image', $curr_mime, true ) ? ' active' : '' ) . ( $gmedia_count['image'] ? '' : ' disabled' ); ?>"><a rel="image" href="<?php echo esc_url( gm_get_admin_url( [ 'mime_type' => 'image' ], [ 'pager' ] ) ); ?>"><?php echo $gm_qty_badge['image'] . __( 'Images', 'grand-media' ); ?></a></li>
114
+ <li class="audio<?php echo ( in_array( 'audio', $curr_mime, true ) ? ' active' : '' ) . ( $gmedia_count['audio'] ? '' : ' disabled' ); ?>"><a rel="audio" href="<?php echo esc_url( gm_get_admin_url( [ 'mime_type' => 'audio' ], [ 'pager' ] ) ); ?>"><?php echo $gm_qty_badge['audio'] . __( 'Audio', 'grand-media' ); ?></a></li>
115
+ <li class="video<?php echo ( in_array( 'video', $curr_mime, true ) ? ' active' : '' ) . ( $gmedia_count['video'] ? '' : ' disabled' ); ?>"><a rel="video" href="<?php echo esc_url( gm_get_admin_url( [ 'mime_type' => 'video' ], [ 'pager' ] ) ); ?>"><?php echo $gm_qty_badge['video'] . __( 'Video', 'grand-media' ); ?></a></li>
116
+ <li class="application<?php echo ( ( in_array( 'application', $curr_mime, true ) || in_array( 'text', $curr_mime, true ) ) ? ' active' : '' ) . ( $gmedia_count['other'] ? '' : ' disabled' ); ?>">
117
+ <a rel="application" href="<?php echo esc_url( gm_get_admin_url( [ 'mime_type' => 'application,text' ], [ 'pager' ] ) ); ?>"><?php echo $gm_qty_badge['other'] . __( 'Other', 'grand-media' ); ?></a></li>
118
+ <?php } ?>
119
 
120
+ <li role="presentation" class="dropdown-header"><?php _e( 'COLLECTIONS', 'grand-media' ); ?></li>
121
+ <li class="filter_categories<?php echo isset( $gmedia_filter['category__in'] ) ? ' active' : ''; ?>"><a href="#libModal" data-modal="filter_categories" data-action="gmedia_get_modal" class="gmedia-modal"><?php _e( 'Categories', 'grand-media' ); ?></a></li>
122
+ <?php if ( ! ( $gmProcessor->edit_term && 'album' === $gmProcessor->taxterm ) ) { ?>
123
+ <li class="filter_albums<?php echo isset( $gmedia_filter['album__in'] ) ? ' active' : ''; ?>"><a href="#libModal" data-modal="filter_albums" data-action="gmedia_get_modal" class="gmedia-modal"><?php _e( 'Albums', 'grand-media' ); ?></a></li>
124
+ <?php } ?>
125
+ <li class="filter_tags<?php echo isset( $gmedia_filter['tag__in'] ) ? ' active' : ''; ?>"><a href="#libModal" data-modal="filter_tags" data-action="gmedia_get_modal" class="gmedia-modal"><?php _e( 'Tags', 'grand-media' ); ?></a></li>
126
+ <?php do_action( 'gmedia_filter_list' ); ?>
127
+ </ul>
128
+ </div>
129
 
130
+ <?php if ( ! in_array( $gmProcessor->mode, [ 'select_single', 'select_mutiple' ], true ) ) { ?>
131
+ <div class="btn-group">
132
+ <?php if ( $gmProcessor->mode !== 'edit' ) {
133
+ $edit_mode_href = gm_get_admin_url( [ 'mode' => 'edit' ] );
134
+ } else {
135
+ $edit_mode_href = gm_get_admin_url( [], [ 'mode' ] );
136
+ } ?>
137
+ <?php if ( gm_user_can( 'edit_media' ) ) { ?>
138
+ <a class="btn btn-default edit-mode-link" title="<?php _e( 'Toggle Edit Mode', 'grand-media' ); ?>" href="<?php echo esc_url( $edit_mode_href ); ?>"><?php _e( 'Action', 'grand-media' ); ?></a>
139
+ <?php } else { ?>
140
+ <button type="button" class="btn btn-default"><?php _e( 'Action', 'grand-media' ); ?></button>
141
+ <?php } ?>
142
+ <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span>
143
+ <span class="sr-only"><?php _e( 'Toggle Dropdown', 'grand-media' ); ?></span></button>
144
+ <?php
145
+ $rel_selected_show = 'rel-selected-show';
146
+ $rel_selected_hide = 'rel-selected-hide';
147
+ ?>
148
+ <ul class="dropdown-menu" role="menu">
149
+ <?php if ( ! ( $gmProcessor->mode === 'edit' ) ) { ?>
150
+ <li class="<?php echo esc_attr( gm_user_can( 'edit_media' ) ? '' : 'disabled' ); ?>">
151
+ <a class="edit-mode-link" href="<?php echo esc_url( $edit_mode_href ); ?>"><?php _e( 'Enter Edit Mode', 'grand-media' ); ?></a>
152
+ </li>
153
+ <?php } else { ?>
154
+ <li><a href="<?php echo esc_url( $edit_mode_href ); ?>"><?php _e( 'Exit Edit Mode', 'grand-media' ); ?></a></li>
155
+ <?php } ?>
156
+ <li class="<?php echo esc_attr( $rel_selected_show . ( gm_user_can( 'edit_media' ) ? '' : ' disabled' ) ); ?>">
157
+ <a href="#libModal" data-modal="batch_edit" data-action="gmedia_get_modal" data-ckey="<?php echo esc_attr( GmediaProcessor_Library::$cookie_key ); ?>" class="gmedia-modal"><?php _e( 'Batch Edit', 'grand-media' ); ?></a></li>
158
 
159
+ <li class="divider <?php echo $rel_selected_show; ?>"></li>
160
+ <li class="<?php echo esc_attr( $rel_selected_show . ( gm_user_can( 'terms' ) ? '' : ' disabled' ) ); ?>">
161
+ <a href="#libModal" data-modal="assign_album" data-action="gmedia_get_modal" data-ckey="<?php echo esc_attr( GmediaProcessor_Library::$cookie_key ); ?>" class="gmedia-modal"><?php _e( 'Move to Album...', 'grand-media' ); ?></a>
162
+ </li>
163
+ <li class="<?php echo esc_attr( $rel_selected_show . ( gm_user_can( 'terms' ) ? '' : ' disabled' ) ); ?>">
164
+ <a href="<?php echo esc_url( wp_nonce_url( gm_get_admin_url( [ 'do_gmedia' => 'unassign_album' ] ), 'gmedia_action', '_wpnonce_action' ) ); ?>" data-confirm="<?php _e( "You are about to remove the selected items from assigned albums.\n\r'Cancel' to stop, 'OK' to delete.", "grand-media" ); ?>"><?php _e( 'Remove from Album', 'grand-media' ); ?></a>
165
+ </li>
166
+ <li class="<?php echo esc_attr( $rel_selected_show . ( gm_user_can( 'terms' ) ? '' : ' disabled' ) ); ?>">
167
+ <a href="#libModal" data-modal="assign_category" data-action="gmedia_get_modal" data-ckey="<?php echo esc_attr( GmediaProcessor_Library::$cookie_key ); ?>" class="gmedia-modal"><?php _e( 'Assign Categories...', 'grand-media' ); ?></a>
168
+ </li>
169
+ <li class="<?php echo esc_attr( $rel_selected_show . ( gm_user_can( 'terms' ) ? '' : ' disabled' ) ); ?>">
170
+ <a href="#libModal" data-modal="unassign_category" data-action="gmedia_get_modal" data-ckey="<?php echo esc_attr( GmediaProcessor_Library::$cookie_key ); ?>" class="gmedia-modal"><?php _e( 'Unassign Categories...', 'grand-media' ); ?></a>
171
+ </li>
172
+ <li class="<?php echo esc_attr( $rel_selected_show . ( gm_user_can( 'terms' ) ? '' : ' disabled' ) ); ?>">
173
+ <a href="#libModal" data-modal="add_tags" data-action="gmedia_get_modal" data-ckey="<?php echo esc_attr( GmediaProcessor_Library::$cookie_key ); ?>" class="gmedia-modal"><?php _e( 'Add Tags...', 'grand-media' ); ?></a></li>
174
+ <li class="<?php echo esc_attr( $rel_selected_show . ( gm_user_can( 'terms' ) ? '' : ' disabled' ) ); ?>">
175
+ <a href="#libModal" data-modal="delete_tags" data-action="gmedia_get_modal" data-ckey="<?php echo esc_attr( GmediaProcessor_Library::$cookie_key ); ?>" class="gmedia-modal"><?php _e( 'Delete Tags...', 'grand-media' ); ?></a>
176
+ </li>
177
+ <li class="<?php echo esc_attr( $rel_selected_show . ( gm_user_can( 'delete_media' ) ? '' : ' disabled' ) ); ?>">
178
+ <a href="<?php echo esc_url( wp_nonce_url( gm_get_admin_url( [
179
+ 'do_gmedia' => 'delete',
180
+ 'ids' => 'selected',
181
+ ], [ 'filter' ] ), 'gmedia_delete', '_wpnonce_delete' ) ); ?>" class="gmedia-delete" data-confirm="<?php _e( "You are about to permanently delete the selected items.\n\r'Cancel' to stop, 'OK' to delete.", "grand-media" ); ?>"><?php _e( 'Delete Selected Items', 'grand-media' ); ?></a>
182
+ </li>
183
 
184
+ <?php if ( ! $gmProcessor->gmediablank ) { ?>
185
+ <li class="divider <?php echo $rel_selected_show; ?>"></li>
186
+ <li class="<?php echo esc_attr( $rel_selected_show . ( gm_user_can( 'edit_media' ) ? '' : ' disabled' ) ); ?>">
187
+ <a href="<?php echo esc_url( wp_nonce_url( gm_get_admin_url( [ 'do_gmedia' => 'recreate' ], [] ), 'gmedia_action', '_wpnonce_action' ) ); ?>" class="gmedia-update"><?php _e( 'Re-create Images (heavy process)', 'grand-media' ); ?></a>
188
+ </li>
189
+ <li class="<?php echo esc_attr( $rel_selected_show . ( gm_user_can( 'edit_media' ) ? '' : ' disabled' ) ); ?>">
190
+ <a href="<?php echo esc_url( wp_nonce_url( gm_get_admin_url( [ 'do_gmedia' => 'update_meta' ], [] ), 'gmedia_action', '_wpnonce_action' ) ); ?>" class="gmedia-update"><?php _e( 'Update Metadata in Database', 'grand-media' ); ?></a>
191
+ </li>
192
 
193
+ <li class="divider"></li>
194
+ <li>
195
+ <a href="<?php echo esc_url( gm_get_admin_url( [ 'page' => 'GrandMedia', 'gmedia__in' => 'duplicates' ], [], true ) ); ?>"><?php _e( 'Show Duplicates in Library', 'grand-media' ); ?></a>
196
+ </li>
197
+ <?php } ?>
198
 
199
+ <li class="divider <?php echo $rel_selected_hide; ?>"></li>
200
+ <li class="dropdown-header <?php echo $rel_selected_hide; ?>"><span><?php _e( "Select items to see more actions", "grand-media" ); ?></span></li>
201
+ <?php do_action( 'gmedia_action_list' ); ?>
202
 
203
+ </ul>
204
+ </div>
205
+ <?php }
206
+ do_action( 'gmedia_library_btn_toolbar' );
207
+ ?>
208
 
209
+ <?php
210
+ $filter_stack = $gmCore->_req( 'stack' );
211
+ $filter_stack_arg = $filter_stack ? false : 'show';
212
 
213
+ $filter_selected = ( 'selected' === $gmCore->_req( 'filter' ) );
214
+ $filter_selected_arg = $filter_selected ? false : 'selected';
215
+ ?>
216
+ <form class="btn-group" id="gm-stack-btn" name="gm-stack-form" action="<?php echo esc_url( gm_get_admin_url( [ 'stack' => $filter_stack_arg, 'filter' => $filter_selected ], [], $gmedia_url ) ); ?>" method="post">
217
+ <button type="submit" class="btn btn<?php echo ( 'show' === $filter_stack ) ? '-success' : '-info' ?>"><?php printf( __( '%s in Stack', 'grand-media' ), '<span id="gm-stack-qty">' . count( $gmProcessor->stack_items ) . '</span>' ); ?></button>
218
+ <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown"><span class="caret"></span>
219
+ <span class="sr-only"><?php _e( 'Toggle Dropdown', 'grand-media' ); ?></span></button>
220
+ <input type="hidden" id="gm-stack" data-userid="<?php echo absint( $user_ID ); ?>" data-key="gmedia_<?php echo $user_ID; ?>_libstack" name="stack_items" value="<?php echo esc_attr( implode( ',', $gmProcessor->stack_items ) ); ?>"/>
221
+ <ul class="dropdown-menu" role="menu">
222
+ <li><a id="gm-stack-show" href="#show"><?php
223
+ if ( ! $filter_stack ) {
224
+ _e( 'Show Stack', 'grand-media' );
225
+ } else {
226
+ _e( 'Show Library', 'grand-media' );
227
+ }
228
+ ?></a></li>
229
+ <li><a id="gm-stack-clear" href="#clear"><?php _e( 'Clear Stack', 'grand-media' ); ?></a></li>
230
+ <li class="<?php echo esc_attr( gm_user_can( 'gallery_manage' ) ? '' : 'disabled' ); ?>">
231
+ <a href="#libModal" data-modal="quick_gallery_stack" data-action="gmedia_get_modal" data-ckey="gmedia_<?php echo absint( $user_ID ); ?>_libstack" class="gmedia-modal"><?php _e( 'Quick Gallery from Stack', 'grand-media' ); ?></a>
232
+ </li>
233
+ </ul>
234
+ </form>
235
 
236
+ <?php if ( $gmProcessor->mode !== 'select_single' ) { ?>
237
+ <form class="btn-group<?php echo $filter_selected ? ' gm-active' : ''; ?>" id="gm-selected-btn" name="gm-selected-form" action="<?php echo esc_url( gm_get_admin_url( [ 'stack' => $filter_stack, 'filter' => $filter_selected_arg ], [], $gmedia_url ) ); ?>" method="post">
238
+ <button type="submit" class="btn btn<?php echo ( 'selected' === $filter_selected ) ? '-success' : '-info' ?>"><?php printf( __( '%s selected', 'grand-media' ), '<span id="gm-selected-qty">' . count( $gmProcessor->selected_items ) . '</span>' ); ?></button>
239
+ <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown"><span class="caret"></span>
240
+ <span class="sr-only"><?php _e( 'Toggle Dropdown', 'grand-media' ); ?></span></button>
241
+ <input type="hidden" id="gm-selected" data-userid="<?php echo absint( $user_ID ); ?>" data-key="<?php echo esc_attr( GmediaProcessor_Library::$cookie_key ); ?>" name="selected_items" value="<?php echo esc_attr( implode( ',', $gmProcessor->selected_items ) ); ?>"/>
242
+ <ul class="dropdown-menu" role="menu">
243
+ <li><a id="gm-selected-show" href="#show"><?php
244
+ if ( ! $filter_selected ) {
245
+ _e( 'Show only selected items', 'grand-media' );
246
+ } else {
247
+ _e( 'Show all gmedia items', 'grand-media' );
248
+ }
249
+ ?></a></li>
250
+ <li><a id="gm-selected-clear" href="#clear"><?php _e( 'Clear selected items', 'grand-media' ); ?></a></li>
251
+ <li><a id="gm-stack-in" href="#stack_add"><?php _e( 'Add selected items to Stack', 'grand-media' ); ?></a></li>
252
+ <li><a id="gm-stack-out" href="#stack_remove"><?php _e( 'Remove selected items from Stack', 'grand-media' ); ?></a></li>
253
+ <?php if ( $gmProcessor->mode !== 'select_multiple' ) { ?>
254
+ <li class="<?php echo esc_attr( gm_user_can( 'gallery_manage' ) ? '' : 'disabled' ); ?>">
255
+ <a href="#libModal" data-modal="quick_gallery" data-action="gmedia_get_modal" data-ckey="<?php echo esc_attr( GmediaProcessor_Library::$cookie_key ); ?>" class="gmedia-modal"><?php _e( 'Quick Gallery from Selected', 'grand-media' ); ?></a>
256
+ </li>
257
+ <?php } ?>
258
+ </ul>
259
+ </form>
260
+ <?php } ?>
261
+ </div>
262
 
263
  </div>
admin/pages/modules/edit-preset.php CHANGED
@@ -3,21 +3,21 @@
3
  * Gmedia Gallery Edit
4
  */
5
 
6
- // don't load directly
7
  if ( ! defined( 'ABSPATH' ) ) {
8
- die( '-1' );
9
  }
10
 
11
  global $user_ID, $gmDB, $gmCore, $gmGallery, $gmProcessor;
12
 
13
  $term_id = (int) $gmCore->_get( 'preset', 0 );
14
  $preset_module = $gmCore->_get( 'preset_module' );
15
- $gmedia_url = add_query_arg( array( 'preset_module' => $preset_module, 'preset' => $term_id ), $gmProcessor->url );
16
  $gmedia_term_taxonomy = 'gmedia_module';
17
  $taxterm = str_replace( 'gmedia_', '', $gmedia_term_taxonomy );
18
 
19
  if ( ! gm_user_can( "{$taxterm}_manage" ) ) {
20
- die( '-1' );
21
  }
22
 
23
  $term = $gmDB->get_term( $term_id );
@@ -27,58 +27,58 @@ $term_id = $term->term_id;
27
 
28
  $gmedia_modules = get_gmedia_modules( false );
29
 
30
- $default_module_demo_query_args = get_user_option('gmedia_preset_demo_query_args');
31
- $gmedia_filter = gmedia_gallery_query_data($default_module_demo_query_args);
32
- $default_options = array();
33
 
34
  if ( isset( $gmedia_modules['in'][ $term->module['name'] ] ) ) {
35
 
36
- /**
37
- * @var $module_name
38
- * @var $module_path
39
- * @var $options_tree
40
- * @var $default_options
41
- */
42
- extract( $gmedia_modules['in'][ $term->module['name'] ] );
43
- if ( is_file( $module_path . '/index.php' ) && is_file( $module_path . '/settings.php' ) ) {
44
- /** @noinspection PhpIncludeInspection */
45
- include( $module_path . '/index.php' );
46
- /** @noinspection PhpIncludeInspection */
47
- include( $module_path . '/settings.php' );
48
-
49
- } else {
50
- $alert[] = sprintf( __( 'Module `%s` is broken. Choose another module from the list.' ), $module_name );
51
- }
52
  } else {
53
- $alert[] = sprintf( __( 'Can\'t get module with name `%s`. Choose module from the list.' ), $term->module['name'] );
54
  }
55
 
56
  if ( ! empty( $alert ) ) {
57
- echo $gmCore->alert( 'danger', $alert );
58
  }
59
 
60
  if ( ! empty( $term->module['settings'] ) ) {
61
- $gallery_settings = $gmCore->array_replace_recursive( $default_options, $term->module['settings'] );
62
  } else {
63
- $gallery_settings = $default_options;
64
  }
65
 
66
- $params = array();
67
- $gallery_link_default = add_query_arg( array( 'page' => 'GrandMedia', 'gmediablank' => 'module_preview', 'module' => $term->module['name'], 'preset' => $term->term_id, 'query' => $gmedia_filter['query_args'] ), admin_url( 'admin.php' ) );
68
 
69
  /** @noinspection PhpIncludeInspection */
70
- include_once( GMEDIA_ABSPATH . 'inc/module.options.php' );
71
 
72
  do_action( 'gmedia_module_preset_before_panel' );
73
  ?>
74
 
75
  <div class="panel panel-default panel-fixed-header">
76
 
77
- <?php
78
- include( dirname( __FILE__ ) . '/tpl/module-preset-panel-heading.php' );
79
 
80
- include( dirname( __FILE__ ) . "/tpl/module-preset-edit-item.php" );
81
- ?>
82
 
83
  </div>
84
 
@@ -86,16 +86,16 @@ do_action( 'gmedia_module_preset_before_panel' );
86
  do_action( 'gmedia_module_preset_after_panel' );
87
  ?>
88
  <div class="modal fade gmedia-modal" id="previewModal" tabindex="-1" role="dialog" aria-hidden="true">
89
- <div class="modal-dialog">
90
- <div class="modal-content">
91
- <div class="modal-header">
92
- <div class="btn-toolbar pull-right" style="margin-top:-4px;">
93
- <button type="button" class="btn btn-primary"><?php _e('Submit', 'grand-media'); ?></button>
94
- <button type="button" class="btn btn-default" data-dismiss="modal"><?php _e('Close', 'grand-media'); ?></button>
95
- </div>
96
- <h4 class="modal-title"></h4>
97
- </div>
98
- <div class="modal-body"></div>
99
- </div>
100
- </div>
101
  </div>
3
  * Gmedia Gallery Edit
4
  */
5
 
6
+ // don't load directly.
7
  if ( ! defined( 'ABSPATH' ) ) {
8
+ die( '-1' );
9
  }
10
 
11
  global $user_ID, $gmDB, $gmCore, $gmGallery, $gmProcessor;
12
 
13
  $term_id = (int) $gmCore->_get( 'preset', 0 );
14
  $preset_module = $gmCore->_get( 'preset_module' );
15
+ $gmedia_url = add_query_arg( [ 'preset_module' => $preset_module, 'preset' => $term_id ], $gmProcessor->url );
16
  $gmedia_term_taxonomy = 'gmedia_module';
17
  $taxterm = str_replace( 'gmedia_', '', $gmedia_term_taxonomy );
18
 
19
  if ( ! gm_user_can( "{$taxterm}_manage" ) ) {
20
+ die( '-1' );
21
  }
22
 
23
  $term = $gmDB->get_term( $term_id );
27
 
28
  $gmedia_modules = get_gmedia_modules( false );
29
 
30
+ $default_module_demo_query_args = get_user_option( 'gmedia_preset_demo_query_args' );
31
+ $gmedia_filter = gmedia_gallery_query_data( $default_module_demo_query_args );
32
+ $default_options = [];
33
 
34
  if ( isset( $gmedia_modules['in'][ $term->module['name'] ] ) ) {
35
 
36
+ /**
37
+ * @var $module_name
38
+ * @var $module_path
39
+ * @var $options_tree
40
+ * @var $default_options
41
+ */
42
+ extract( $gmedia_modules['in'][ $term->module['name'] ] );
43
+ if ( is_file( $module_path . '/index.php' ) && is_file( $module_path . '/settings.php' ) ) {
44
+ /** @noinspection PhpIncludeInspection */
45
+ include $module_path . '/index.php';
46
+ /** @noinspection PhpIncludeInspection */
47
+ include $module_path . '/settings.php';
48
+
49
+ } else {
50
+ $alert[] = sprintf( __( 'Module `%s` is broken. Choose another module from the list.' ), $module_name );
51
+ }
52
  } else {
53
+ $alert[] = sprintf( __( 'Can\'t get module with name `%s`. Choose module from the list.' ), $term->module['name'] );
54
  }
55
 
56
  if ( ! empty( $alert ) ) {
57
+ echo $gmCore->alert( 'danger', $alert );
58
  }
59
 
60
  if ( ! empty( $term->module['settings'] ) ) {
61
+ $gallery_settings = $gmCore->array_replace_recursive( $default_options, $term->module['settings'] );
62
  } else {
63
+ $gallery_settings = $default_options;
64
  }
65
 
66
+ $params = [];
67
+ $gallery_link_default = add_query_arg( [ 'page' => 'GrandMedia', 'gmediablank' => 'module_preview', 'module' => $term->module['name'], 'preset' => $term->term_id, 'query' => $gmedia_filter['query_args'] ], admin_url( 'admin.php' ) );
68
 
69
  /** @noinspection PhpIncludeInspection */
70
+ include_once GMEDIA_ABSPATH . 'inc/module.options.php';
71
 
72
  do_action( 'gmedia_module_preset_before_panel' );
73
  ?>
74
 
75
  <div class="panel panel-default panel-fixed-header">
76
 
77
+ <?php
78
+ include dirname( __FILE__ ) . '/tpl/module-preset-panel-heading.php';
79
 
80
+ include dirname( __FILE__ ) . "/tpl/module-preset-edit-item.php";
81
+ ?>
82
 
83
  </div>
84
 
86
  do_action( 'gmedia_module_preset_after_panel' );
87
  ?>
88
  <div class="modal fade gmedia-modal" id="previewModal" tabindex="-1" role="dialog" aria-hidden="true">
89
+ <div class="modal-dialog">
90
+ <div class="modal-content">
91
+ <div class="modal-header">
92
+ <div class="btn-toolbar pull-right" style="margin-top:-4px;">
93
+ <button type="button" class="btn btn-primary"><?php _e( 'Submit', 'grand-media' ); ?></button>
94
+ <button type="button" class="btn btn-default" data-dismiss="modal"><?php _e( 'Close', 'grand-media' ); ?></button>
95
+ </div>
96
+ <h4 class="modal-title"></h4>
97
+ </div>
98
+ <div class="modal-body"></div>
99
+ </div>
100
+ </div>
101
  </div>
admin/pages/modules/functions.php CHANGED
@@ -7,7 +7,7 @@ function gmedia_module_action_buttons( $module ) {
7
  global $gmCore, $gmProcessor, $gmGallery;
8
 
9
  $buttons = [];
10
- if ( ( 'remote' == $module['place'] ) && ! empty( $module['buy'] ) ) {
11
  //$sale = !empty($module['sale'])? 'onsale' : '';
12
  $buttons['buy'] = '<a class="btn btn-primary" href="' . $module['buy'] . '" target="_blank">' . __( 'Buy Now (no license required)', 'grand-media' ) . ' <span>' . $module['price'] . '</span></a>';
13
  }
@@ -15,21 +15,21 @@ function gmedia_module_action_buttons( $module ) {
15
  if ( ( ! empty( $module['status'] ) && 'premium' === $module['status'] ) && empty( $module['buy'] ) && empty( $gmGallery->options['license_name'] ) ) {
16
  $buttons['premium'] = '<a class="btn btn-success" style="font-weight: bold;" target="_blank" href="https://codeasily.com/gmedia-premium/">' . __( 'Get Premium', 'grand-media' ) . '</a>';
17
  } else {
18
- if ( 'remote' == $module['place'] && ! empty( $module['download'] ) ) {
19
  if ( ( ! empty( $module['status'] ) && 'premium' === $module['status'] ) && empty( $gmGallery->options['license_name'] ) ) {
20
  $buttons['premium'] = '<a class="btn btn-success" style="font-weight: bold;" target="_blank" href="https://codeasily.com/gmedia-premium/">' . __( 'Get Premium', 'grand-media' ) . '</a>';
21
  } else {
22
  $buttons['install'] = '<a class="btn btn-primary ' . ( gm_user_can( 'module_manage' ) ? 'module_install' : 'disabled' ) . '" data-module="' . $module['name'] . '" data-loading-text="' . __( 'Loading...', 'grand-media' ) . '" href="' . esc_url( $module['download'] ) . '">' . __( 'Install Module', 'grand-media' ) . '</a>';
23
  }
24
- } elseif ( 'remote' != $module['place'] ) {
25
  $buttons['create'] = '<a class="btn btn-success" href="' . $gmCore->get_admin_url( [ 'page' => 'GrandMedia_Galleries', 'gallery_module' => $module['name'] ], [], true ) . '">' . __( 'Create Gallery', 'grand-media' ) . '</a>';
26
  }
27
  }
28
 
29
- if ( ! empty( $module['demo'] ) && $module['demo'] != '#' ) {
30
  $buttons['demo'] = '<a class="btn btn-default" target="_blank" href="' . $module['demo'] . '">' . __( 'View Demo', 'grand-media' ) . '</a>';
31
  }
32
- if ( ! empty( $module['update'] ) && 'remote' != $module['place'] ) {
33
  if ( empty( $module['buy'] ) ) {
34
  if ( 'free' === $module['status'] || ! empty( $gmGallery->options['license_name'] ) ) {
35
  $buttons['update'] = '<a class="btn btn-warning module_install" data-module="' . $module['name'] . '" data-loading-text="' . __( 'Loading...', 'grand-media' ) . '" href="' . esc_url( $module['download'] ) . '">' . __( 'Update Module', 'grand-media' ) . " (v{$module['update']})</a>";
@@ -41,7 +41,7 @@ function gmedia_module_action_buttons( $module ) {
41
  $buttons['update2'] = '<a class="btn btn-warning" target="_blank" href="' . esc_url( $module['buy'] ) . '">' . __( 'Download Update (no license required)', 'grand-media' ) . " (v{$module['update']})</a>";
42
  }
43
  }
44
- if ( ( 'remote' != $module['place'] ) && ( 'amron' != $module['name'] ) && gm_user_can( 'module_manage' ) ) {
45
  $buttons['delete'] = '<a class="btn btn-danger" href="' . wp_nonce_url( $gmCore->get_admin_url( [ 'delete_module' => $module['name'] ], [], $gmProcessor->url ), 'gmedia_module_delete', '_wpnonce_module_delete' ) . '">' . __( 'Delete Module', 'grand-media' ) . '</a>';
46
  }
47
  if ( ! empty( $module['download'] ) && ( 'free' === $module['status'] || ! empty( $gmGallery->options['license_name'] ) ) ) {
@@ -70,7 +70,7 @@ function gmedia_module_preset_more_data( &$item ) {
70
  $item->global = $user_ID;
71
  $item->status = $gmCore->_get( 'preset_module', 'amron' );
72
  } else {
73
- if ( ( $preset_module = $gmCore->_get( 'preset_module' ) ) && $item->status != $preset_module ) {
74
  $item = new stdClass();
75
  gmedia_module_preset_more_data( $item );
76
 
@@ -84,7 +84,7 @@ function gmedia_module_preset_more_data( &$item ) {
84
 
85
  $module_info = [ 'type' => '&#8212;' ];
86
  if ( is_file( $item->module['path'] . '/index.php' ) ) {
87
- include( $item->module['path'] . '/index.php' );
88
 
89
  $item->module['info'] = $module_info;
90
  } else {
7
  global $gmCore, $gmProcessor, $gmGallery;
8
 
9
  $buttons = [];
10
+ if ( ( 'remote' === $module['place'] ) && ! empty( $module['buy'] ) ) {
11
  //$sale = !empty($module['sale'])? 'onsale' : '';
12
  $buttons['buy'] = '<a class="btn btn-primary" href="' . $module['buy'] . '" target="_blank">' . __( 'Buy Now (no license required)', 'grand-media' ) . ' <span>' . $module['price'] . '</span></a>';
13
  }
15
  if ( ( ! empty( $module['status'] ) && 'premium' === $module['status'] ) && empty( $module['buy'] ) && empty( $gmGallery->options['license_name'] ) ) {
16
  $buttons['premium'] = '<a class="btn btn-success" style="font-weight: bold;" target="_blank" href="https://codeasily.com/gmedia-premium/">' . __( 'Get Premium', 'grand-media' ) . '</a>';
17
  } else {
18
+ if ( 'remote' === $module['place'] && ! empty( $module['download'] ) ) {
19
  if ( ( ! empty( $module['status'] ) && 'premium' === $module['status'] ) && empty( $gmGallery->options['license_name'] ) ) {
20
  $buttons['premium'] = '<a class="btn btn-success" style="font-weight: bold;" target="_blank" href="https://codeasily.com/gmedia-premium/">' . __( 'Get Premium', 'grand-media' ) . '</a>';
21
  } else {
22
  $buttons['install'] = '<a class="btn btn-primary ' . ( gm_user_can( 'module_manage' ) ? 'module_install' : 'disabled' ) . '" data-module="' . $module['name'] . '" data-loading-text="' . __( 'Loading...', 'grand-media' ) . '" href="' . esc_url( $module['download'] ) . '">' . __( 'Install Module', 'grand-media' ) . '</a>';
23
  }
24
+ } elseif ( 'remote' !== $module['place'] ) {
25
  $buttons['create'] = '<a class="btn btn-success" href="' . $gmCore->get_admin_url( [ 'page' => 'GrandMedia_Galleries', 'gallery_module' => $module['name'] ], [], true ) . '">' . __( 'Create Gallery', 'grand-media' ) . '</a>';
26
  }
27
  }
28
 
29
+ if ( ! empty( $module['demo'] ) && $module['demo'] !== '#' ) {
30
  $buttons['demo'] = '<a class="btn btn-default" target="_blank" href="' . $module['demo'] . '">' . __( 'View Demo', 'grand-media' ) . '</a>';
31
  }
32
+ if ( ! empty( $module['update'] ) && 'remote' !== $module['place'] ) {
33
  if ( empty( $module['buy'] ) ) {
34
  if ( 'free' === $module['status'] || ! empty( $gmGallery->options['license_name'] ) ) {
35
  $buttons['update'] = '<a class="btn btn-warning module_install" data-module="' . $module['name'] . '" data-loading-text="' . __( 'Loading...', 'grand-media' ) . '" href="' . esc_url( $module['download'] ) . '">' . __( 'Update Module', 'grand-media' ) . " (v{$module['update']})</a>";
41
  $buttons['update2'] = '<a class="btn btn-warning" target="_blank" href="' . esc_url( $module['buy'] ) . '">' . __( 'Download Update (no license required)', 'grand-media' ) . " (v{$module['update']})</a>";
42
  }
43
  }
44
+ if ( ( 'remote' !== $module['place'] ) && ( 'amron' !== $module['name'] ) && gm_user_can( 'module_manage' ) ) {
45
  $buttons['delete'] = '<a class="btn btn-danger" href="' . wp_nonce_url( $gmCore->get_admin_url( [ 'delete_module' => $module['name'] ], [], $gmProcessor->url ), 'gmedia_module_delete', '_wpnonce_module_delete' ) . '">' . __( 'Delete Module', 'grand-media' ) . '</a>';
46
  }
47
  if ( ! empty( $module['download'] ) && ( 'free' === $module['status'] || ! empty( $gmGallery->options['license_name'] ) ) ) {
70
  $item->global = $user_ID;
71
  $item->status = $gmCore->_get( 'preset_module', 'amron' );
72
  } else {
73
+ if ( ( $preset_module = $gmCore->_get( 'preset_module' ) ) && $item->status !== $preset_module ) {
74
  $item = new stdClass();
75
  gmedia_module_preset_more_data( $item );
76
 
84
 
85
  $module_info = [ 'type' => '&#8212;' ];
86
  if ( is_file( $item->module['path'] . '/index.php' ) ) {
87
+ include $item->module['path'] . '/index.php';
88
 
89
  $item->module['info'] = $module_info;
90
  } else {
admin/pages/modules/modules.php CHANGED
@@ -1,118 +1,117 @@
1
- <?php
2
- /**
3
- * Gmedia Modules
4
- */
5
-
6
- // don't load directly
7
- if( !defined('ABSPATH')){
8
- die('-1');
9
- }
10
-
11
- global $gmCore, $gmProcessor, $gmGallery, $gmDB;
12
-
13
- $gmedia_url = $gmProcessor->url;
14
- $modules = $gmProcessor->modules;
15
- $tags = array();
16
- if(!empty($modules['xml'])){
17
- foreach($modules['xml'] as $module){
18
- $tags = array_merge($tags, $module['tags']);
19
- }
20
- }
21
- if(!empty($tags)){
22
- $tags = array_unique($tags);
23
- sort($tags);
24
- }
25
- //echo '<pre style="max-height: 500px; overflow:auto;">' . print_r($modules, true) . '</pre>';
26
-
27
- if(isset($modules['error'])){
28
- echo $gmCore->alert('danger', $modules['error']);
29
- }
30
-
31
- ?>
32
- <div id="gmedia_modules">
33
- <div id="gmedia_modules_wrapper" data-update="<?php echo $gmGallery->options['modules_update'] ?>">
34
- <div class="panel panel-default">
35
- <div class="panel-heading clearfix">
36
- <div class="clearfix">
37
- <a href="#installModuleModal" class="btn btn-primary pull-right<?php echo current_user_can('manage_options')? '' : ' disabled'; ?>" data-toggle="modal"><?php _e('Install Module ZIP'); ?></a>
38
-
39
- <div class="btn-group pull-left filter-modules" style="margin-right: 10px;">
40
- <button type="button" data-filter="collection" class="btn btn-primary"><?php _e('All Modules', 'grand-media'); ?> <span class="badge badge-error gm-module-count-<?php echo $gmGallery->options['modules_update']; ?>" title="<?php _e( 'Modules Updates', 'grand-media' ); ?>"><?php echo $gmGallery->options['modules_update']; ?></span></button>
41
- <button type="button" data-filter="not-installed" class="btn btn-default"><?php _e('New Modules', 'grand-media'); ?> <span class="badge badge-success gm-module-count-<?php echo $gmGallery->options['modules_new']; ?>" title="<?php _e( 'New Modules', 'grand-media' ); ?>"><?php echo $gmGallery->options['modules_new']; ?></span></button>
42
- <button type="button" data-filter="tag-trend" class="btn btn-default"><?php _e('Trends', 'grand-media'); ?></button>
43
- </div>
44
-
45
- <?php if(!empty($tags)){ ?>
46
- <div class="btn-group pull-left">
47
- <button type="button" class="btn btn-default" onclick="jQuery(this).toggleClass('active');" data-toggle="collapse" data-target="#collapseFeatures" aria-expanded="false" aria-controls="collapseFeatures">
48
- Feature Filters <span class="caret"></span>
49
- </button>
50
- </div>
51
- <?php } ?>
52
- </div>
53
- <?php if(!empty($tags)){ ?>
54
- <div class="collapse" id="collapseFeatures">
55
- <div class="filter-modules" style="padding-top: 10px;">
56
- <?php foreach($tags as $tag){ ?>
57
- <span style="cursor: pointer;" data-filter="tag-<?php echo sanitize_key($tag); ?>" class="label label-default"><?php echo strtoupper($tag); ?></span>
58
- <?php } ?>
59
- </div>
60
- </div>
61
- <?php } ?>
62
- </div>
63
- <div class="panel-body" id="gmedia-msg-panel"></div>
64
- <div class="panel-body modules-body">
65
- <?php
66
- // installed modules
67
- if( !empty($modules['in'])){
68
- foreach($modules['in'] as $module){
69
- $module['screenshot_url'] = $module['module_url'] . '/screenshot.png';
70
- $module['mclass'] = ' module-filtered module-collection module-installed';
71
- if($module['update']){
72
- $module['mclass'] .= ' module-update';
73
- }
74
- foreach($module['tags'] as $tag){
75
- $module['mclass'] .= ' module-tag-' . sanitize_key($tag);
76
- }
77
-
78
- include(dirname(__FILE__) . '/tpl/module-item.php');
79
-
80
- }
81
- }
82
-
83
- if( !empty($modules['out'])){ ?>
84
- <?php
85
- //$out_dirpath = dirname($gmGallery->options['modules_xml']);
86
- $out_dirpath = 'https://codeasily.com/gmedia_modules';
87
- foreach($modules['out'] as $module){
88
- $module['mclass'] = ' module-filtered module-collection module-not-installed';
89
- if($module['update']){
90
- $module['mclass'] .= ' module-update';
91
- }
92
- foreach($module['tags'] as $tag){
93
- $module['mclass'] .= ' module-tag-' . sanitize_key($tag);
94
- }
95
- $module['screenshot_url'] = $out_dirpath . '/' . $module['name'] . '.png';
96
-
97
- include(dirname(__FILE__) . '/tpl/module-item.php');
98
-
99
- }
100
- }
101
- wp_nonce_field('GmediaGallery');
102
- ?>
103
- <div class="media nomodules nomodule-not-installed">
104
- <h4 class="media-heading"><?php _e('No modules to show', 'grand-media'); ?></h4>
105
- </div>
106
- <div class="media nomodules nomodule-tag">
107
- <h4 class="media-heading"><?php _e('No modules to show', 'grand-media'); ?></h4>
108
- </div>
109
- </div>
110
- </div>
111
-
112
- </div>
113
- </div>
114
-
115
- <?php if($gmCore->caps['gmedia_module_manage']){
116
- include(dirname(__FILE__) . '/tpl/modal-modulezip.php');
117
- } ?>
118
-
1
+ <?php
2
+ /**
3
+ * Gmedia Modules
4
+ */
5
+
6
+ // don't load directly.
7
+ if ( ! defined( 'ABSPATH' ) ) {
8
+ die( '-1' );
9
+ }
10
+
11
+ global $gmCore, $gmProcessor, $gmGallery, $gmDB;
12
+
13
+ $gmedia_url = $gmProcessor->url;
14
+ $modules = $gmProcessor->modules;
15
+ $tags = [];
16
+ if ( ! empty( $modules['xml'] ) ) {
17
+ foreach ( $modules['xml'] as $module ) {
18
+ $tags = array_merge( $tags, $module['tags'] );
19
+ }
20
+ }
21
+ if ( ! empty( $tags ) ) {
22
+ $tags = array_unique( $tags );
23
+ sort( $tags );
24
+ }
25
+ //echo '<pre style="max-height: 500px; overflow:auto;">' . print_r($modules, true) . '</pre>';
26
+
27
+ if ( isset( $modules['error'] ) ) {
28
+ echo $gmCore->alert( 'danger', $modules['error'] );
29
+ }
30
+
31
+ ?>
32
+ <div id="gmedia_modules">
33
+ <div id="gmedia_modules_wrapper" data-update="<?php echo esc_attr( $gmGallery->options['modules_update'] ); ?>">
34
+ <div class="panel panel-default">
35
+ <div class="panel-heading clearfix">
36
+ <div class="clearfix">
37
+ <a href="#installModuleModal" class="btn btn-primary pull-right<?php echo current_user_can( 'manage_options' ) ? '' : ' disabled'; ?>" data-toggle="modal"><?php _e( 'Install Module ZIP' ); ?></a>
38
+
39
+ <div class="btn-group pull-left filter-modules" style="margin-right: 10px;">
40
+ <button type="button" data-filter="collection" class="btn btn-primary"><?php _e( 'All Modules', 'grand-media' ); ?> <span class="badge badge-error gm-module-count-<?php echo $gmGallery->options['modules_update']; ?>" title="<?php _e( 'Modules Updates', 'grand-media' ); ?>"><?php echo $gmGallery->options['modules_update']; ?></span></button>
41
+ <button type="button" data-filter="not-installed" class="btn btn-default"><?php _e( 'New Modules', 'grand-media' ); ?> <span class="badge badge-success gm-module-count-<?php echo $gmGallery->options['modules_new']; ?>" title="<?php _e( 'New Modules', 'grand-media' ); ?>"><?php echo $gmGallery->options['modules_new']; ?></span></button>
42
+ <button type="button" data-filter="tag-trend" class="btn btn-default"><?php _e( 'Trends', 'grand-media' ); ?></button>
43
+ </div>
44
+
45
+ <?php if ( ! empty( $tags ) ) { ?>
46
+ <div class="btn-group pull-left">
47
+ <button type="button" class="btn btn-default" onclick="jQuery(this).toggleClass('active');" data-toggle="collapse" data-target="#collapseFeatures" aria-expanded="false" aria-controls="collapseFeatures">
48
+ Feature Filters <span class="caret"></span>
49
+ </button>
50
+ </div>
51
+ <?php } ?>
52
+ </div>
53
+ <?php if ( ! empty( $tags ) ) { ?>
54
+ <div class="collapse" id="collapseFeatures">
55
+ <div class="filter-modules" style="padding-top: 10px;">
56
+ <?php foreach ( $tags as $tag ) { ?>
57
+ <span style="cursor: pointer;" data-filter="tag-<?php echo sanitize_key( $tag ); ?>" class="label label-default"><?php echo strtoupper( $tag ); ?></span>
58
+ <?php } ?>
59
+ </div>
60
+ </div>
61
+ <?php } ?>
62
+ </div>
63
+ <div class="panel-body" id="gmedia-msg-panel"></div>
64
+ <div class="panel-body modules-body">
65
+ <?php
66
+ // installed modules.
67
+ if ( ! empty( $modules['in'] ) ) {
68
+ foreach ( $modules['in'] as $module ) {
69
+ $module['screenshot_url'] = $module['module_url'] . '/screenshot.png';
70
+ $module['mclass'] = ' module-filtered module-collection module-installed';
71
+ if ( $module['update'] ) {
72
+ $module['mclass'] .= ' module-update';
73
+ }
74
+ foreach ( $module['tags'] as $tag ) {
75
+ $module['mclass'] .= ' module-tag-' . sanitize_key( $tag );
76
+ }
77
+
78
+ include( dirname( __FILE__ ) . '/tpl/module-item.php' );
79
+
80
+ }
81
+ }
82
+
83
+ if ( ! empty( $modules['out'] ) ) { ?>
84
+ <?php
85
+ //$out_dirpath = dirname($gmGallery->options['modules_xml']);
86
+ $out_dirpath = 'https://codeasily.com/gmedia_modules';
87
+ foreach ( $modules['out'] as $module ) {
88
+ $module['mclass'] = ' module-filtered module-collection module-not-installed';
89
+ if ( $module['update'] ) {
90
+ $module['mclass'] .= ' module-update';
91
+ }
92
+ foreach ( $module['tags'] as $tag ) {
93
+ $module['mclass'] .= ' module-tag-' . sanitize_key( $tag );
94
+ }
95
+ $module['screenshot_url'] = $out_dirpath . '/' . $module['name'] . '.png';
96
+
97
+ include dirname( __FILE__ ) . '/tpl/module-item.php';
98
+
99
+ }
100
+ }
101
+ wp_nonce_field( 'GmediaGallery' );
102
+ ?>
103
+ <div class="media nomodules nomodule-not-installed">
104
+ <h4 class="media-heading"><?php _e( 'No modules to show', 'grand-media' ); ?></h4>
105
+ </div>
106
+ <div class="media nomodules nomodule-tag">
107
+ <h4 class="media-heading"><?php _e( 'No modules to show', 'grand-media' ); ?></h4>
108
+ </div>
109
+ </div>
110
+ </div>
111
+
112
+ </div>
113
+ </div>
114
+
115
+ <?php if ( $gmCore->caps['gmedia_module_manage'] ) {
116
+ include dirname( __FILE__ ) . '/tpl/modal-modulezip.php';
117
+ } ?>
 
admin/pages/modules/tpl/modal-modulezip.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- // don't load directly
3
- if(!defined('ABSPATH')) {
4
- die('-1');
5
  }
6
 
7
  /**
@@ -9,23 +9,22 @@ if(!defined('ABSPATH')) {
9
  */
10
  ?>
11
  <div class="modal fade gmedia-modal" id="installModuleModal" tabindex="-1" role="dialog" aria-hidden="true">
12
- <div class="modal-dialog">
13
- <form class="modal-content" method="post" enctype="multipart/form-data" action="<?php echo $gmedia_url; ?>">
14
- <div class="modal-header">
15
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
16
- <h4 class="modal-title"><?php _e('Install a module in .zip format'); ?></h4>
17
- </div>
18
- <div class="modal-body">
19
- <p class="install-help"><?php _e('If you have a module in a .zip format, you may install it by uploading it here.'); ?></p>
20
- <?php wp_nonce_field('gmedia_module', '_wpnonce_module'); ?>
21
- <label class="screen-reader-text" for="modulezip"><?php _e('Module zip file'); ?></label>
22
- <input type="file" id="modulezip" name="modulezip"/>
23
- </div>
24
- <div class="modal-footer">
25
- <button type="button" class="btn btn-default" data-dismiss="modal"><?php _e('Cancel', 'grand-media'); ?></button>
26
- <button type="submit" class="btn btn-primary"><?php _e('Install', 'grand-media'); ?></button>
27
- </div>
28
- </form>
29
- </div>
30
  </div>
31
-
1
  <?php
2
+ // don't load directly.
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ die( '-1' );
5
  }
6
 
7
  /**
9
  */
10
  ?>
11
  <div class="modal fade gmedia-modal" id="installModuleModal" tabindex="-1" role="dialog" aria-hidden="true">
12
+ <div class="modal-dialog">
13
+ <form class="modal-content" method="post" enctype="multipart/form-data" action="<?php echo esc_url( $gmedia_url ); ?>">
14
+ <div class="modal-header">
15
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
16
+ <h4 class="modal-title"><?php _e( 'Install a module in .zip format' ); ?></h4>
17
+ </div>
18
+ <div class="modal-body">
19
+ <p class="install-help"><?php _e( 'If you have a module in a .zip format, you may install it by uploading it here.' ); ?></p>
20
+ <?php wp_nonce_field( 'gmedia_module', '_wpnonce_module' ); ?>
21
+ <label class="screen-reader-text" for="modulezip"><?php _e( 'Module zip file' ); ?></label>
22
+ <input type="file" id="modulezip" name="modulezip"/>
23
+ </div>
24
+ <div class="modal-footer">
25
+ <button type="button" class="btn btn-default" data-dismiss="modal"><?php _e( 'Cancel', 'grand-media' ); ?></button>
26
+ <button type="submit" class="btn btn-primary"><?php _e( 'Install', 'grand-media' ); ?></button>
27
+ </div>
28
+ </form>
29
+ </div>
30
  </div>
 
admin/pages/modules/tpl/module-item.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- // don't load directly
3
- if(!defined('ABSPATH')){
4
- die('-1');
5
  }
6
 
7
  /**
@@ -11,90 +11,90 @@ if(!defined('ABSPATH')){
11
  global $gmGallery, $gmDB, $gmCore, $user_ID;
12
  ?>
13
  <div class="media<?php echo $module['mclass']; ?>">
14
- <div class="row">
15
- <div class="col-sm-3">
16
- <div class="thumbnail">
17
- <img class="media-object" src="<?php echo $module['screenshot_url']; ?>" alt="<?php esc_attr_e($module['title']); ?>" width="320" height="240"/>
18
- </div>
19
- </div>
20
- <div class="<?php echo(($module['place'] === 'remote')? 'col-sm-9' : 'col-sm-5'); ?>">
21
- <h4 class="media-heading"><?php echo $module['title']; ?></h4>
22
 
23
- <p class="version"><?php echo __('Version', 'grand-media') . ': ' . $module['version']; ?></p>
24
- <?php if(isset($module['info'])){ ?>
25
- <div class="module_info"><?php echo str_replace("\n", '<br />', (string)$module['info']); ?></div>
26
- <?php } ?>
27
- <div class="description"><?php echo str_replace("\n", '<br />', (string)$module['description']); ?></div>
28
- <hr/>
29
- <p class="buttons">
30
- <?php
31
- $buttons = gmedia_module_action_buttons($module);
32
- echo implode(' ', $buttons);
33
- ?>
34
- </p>
35
- </div>
36
- <?php
37
- if( 'remote' !== $module['place'] ){
38
- ?>
39
- <div class="col-sm-4">
40
- <div id="module_presets_list" class="module_presets module_presets_<?php echo $module['name'] ?>">
41
- <h4 class="media-heading" style="margin-bottom:10px;">
42
- <?php if ( 'free' === $module['status'] || ! empty( $gmGallery->options['license_name'] ) || ! empty( $module['buy'] ) ) { ?>
43
- <a href="<?php echo $gmCore->get_admin_url(array('page' => 'GrandMedia_Modules', 'preset_module' => $module['name']), array(), admin_url('admin.php')); ?>" class="addpreset pull-right"><span class="label label-success">+</span></a>
44
- <?php } else { ?>
45
- <a href="https://codeasily.com/gmedia-premium/" title="<?php _e( 'Get Premium', 'grand-media' ); ?>" class="addpreset pull-right"><span class="label label-success">+</span></a>
46
- <?php } ?>
47
- <?php _e('Presets', 'grand-media'); ?></h4>
48
- <?php
49
- $presets = $gmDB->get_terms('gmedia_module', array('status' => $module['name']));
50
- if(!empty($presets)){
51
- ?>
52
- <ul class="list-group presetlist">
53
- <?php
54
- $li = array();
55
- foreach($presets as $preset){
56
- $href = $gmCore->get_admin_url(array('page' => 'GrandMedia_Modules', 'preset' => $preset->term_id), array(), admin_url('admin.php'));
57
 
58
- $count = 1;
59
- $name = trim(str_replace('[' . $module['name'] . ']', '', $preset->name, $count));
60
- $by = '';
61
- $global_preset = false;
62
- if(!$name){
63
- if((int)$preset->global){
64
- $name = __('Default Settings', 'grand-media');
65
- } else{
66
- $name = __('Global Settings', 'grand-media');
67
- $global_preset = true;
68
- }
69
- }
70
- if((int)$preset->global){
71
- $by = ' <small style="white-space:nowrap">[' . get_the_author_meta('display_name', $preset->global) . ']</small>';
72
- }
73
- $li_item = '
74
  <li class="list-group-item" id="gm-preset-' . $preset->term_id . '">
75
  <span class="gm-preset-id">ID: ' . $preset->term_id . '</span>';
76
- if($user_ID == $preset->global || $gmCore->caps['gmedia_edit_others_media']){
77
- $li_item .= '<span class="delpreset"><span class="label label-danger" data-id="' . $preset->term_id . '">&times;</span></span>';
78
- }
79
- $li_item .= '
80
- <a href="' . $href . '">' . $name . $by . '</a>
81
  </li>';
82
- if($global_preset){
83
- if(current_user_can('manage_options')){
84
- array_unshift($li, $li_item);
85
- }
86
- } else{
87
- $li[] = $li_item;
88
- }
89
- }
90
- echo implode('', $li);
91
- ?>
92
- </ul>
93
- <?php } ?>
94
- </div>
95
- </div>
96
- <?php
97
- }
98
- ?>
99
- </div>
100
  </div>
1
  <?php
2
+ // don't load directly.
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ die( '-1' );
5
  }
6
 
7
  /**
11
  global $gmGallery, $gmDB, $gmCore, $user_ID;
12
  ?>
13
  <div class="media<?php echo $module['mclass']; ?>">
14
+ <div class="row">
15
+ <div class="col-sm-3">
16
+ <div class="thumbnail">
17
+ <img class="media-object" src="<?php echo esc_url( $module['screenshot_url'] ); ?>" alt="<?php echo esc_attr( $module['title'] ); ?>" width="320" height="240"/>
18
+ </div>
19
+ </div>
20
+ <div class="<?php echo( ( $module['place'] === 'remote' ) ? 'col-sm-9' : 'col-sm-5' ); ?>">
21
+ <h4 class="media-heading"><?php echo $module['title']; ?></h4>
22
 
23
+ <p class="version"><?php echo __( 'Version', 'grand-media' ) . ': ' . $module['version']; ?></p>
24
+ <?php if ( isset( $module['info'] ) ) { ?>
25
+ <div class="module_info"><?php echo str_replace( "\n", '<br />', (string) $module['info'] ); ?></div>
26
+ <?php } ?>
27
+ <div class="description"><?php echo str_replace( "\n", '<br />', (string) $module['description'] ); ?></div>
28
+ <hr/>
29
+ <p class="buttons">
30
+ <?php
31
+ $buttons = gmedia_module_action_buttons( $module );
32
+ echo implode( ' ', $buttons );
33
+ ?>
34
+ </p>
35
+ </div>
36
+ <?php
37
+ if ( 'remote' !== $module['place'] ) {
38
+ ?>
39
+ <div class="col-sm-4">
40
+ <div id="module_presets_list" class="module_presets module_presets_<?php echo $module['name'] ?>">
41
+ <h4 class="media-heading" style="margin-bottom:10px;">
42
+ <?php if ( 'free' === $module['status'] || ! empty( $gmGallery->options['license_name'] ) || ! empty( $module['buy'] ) ) { ?>
43
+ <a href="<?php echo esc_url( $gmCore->get_admin_url( [ 'page' => 'GrandMedia_Modules', 'preset_module' => $module['name'] ], [], admin_url( 'admin.php' ) ) ); ?>" class="addpreset pull-right"><span class="label label-success">+</span></a>
44
+ <?php } else { ?>
45
+ <a href="https://codeasily.com/gmedia-premium/" title="<?php _e( 'Get Premium', 'grand-media' ); ?>" class="addpreset pull-right"><span class="label label-success">+</span></a>
46
+ <?php } ?>
47
+ <?php _e( 'Presets', 'grand-media' ); ?></h4>
48
+ <?php
49
+ $presets = $gmDB->get_terms( 'gmedia_module', [ 'status' => $module['name'] ] );
50
+ if ( ! empty( $presets ) ) {
51
+ ?>
52
+ <ul class="list-group presetlist">
53
+ <?php
54
+ $li = [];
55
+ foreach ( $presets as $preset ) {
56
+ $href = $gmCore->get_admin_url( [ 'page' => 'GrandMedia_Modules', 'preset' => $preset->term_id ], [], admin_url( 'admin.php' ) );
57
 
58
+ $count = 1;
59
+ $name = trim( str_replace( '[' . $module['name'] . ']', '', $preset->name, $count ) );
60
+ $by = '';
61
+ $global_preset = false;
62
+ if ( ! $name ) {
63
+ if ( (int) $preset->global ) {
64
+ $name = __( 'Default Settings', 'grand-media' );
65
+ } else {
66
+ $name = __( 'Global Settings', 'grand-media' );
67
+ $global_preset = true;
68
+ }
69
+ }
70
+ if ( (int) $preset->global ) {
71
+ $by = ' <small style="white-space:nowrap">[' . esc_html( get_the_author_meta( 'display_name', $preset->global ) ) . ']</small>';
72
+ }
73
+ $li_item = '
74
  <li class="list-group-item" id="gm-preset-' . $preset->term_id . '">
75
  <span class="gm-preset-id">ID: ' . $preset->term_id . '</span>';
76
+ if ( $user_ID === $preset->global || $gmCore->caps['gmedia_edit_others_media'] ) {
77
+ $li_item .= '<span class="delpreset"><span class="label label-danger" data-id="' . $preset->term_id . '">&times;</span></span>';
78
+ }
79
+ $li_item .= '
80
+ <a href="' . $href . '">' . esc_html( $name ) . $by . '</a>
81
  </li>';
82
+ if ( $global_preset ) {
83
+ if ( current_user_can( 'manage_options' ) ) {
84
+ array_unshift( $li, $li_item );
85
+ }
86
+ } else {
87
+ $li[] = $li_item;
88
+ }
89
+ }
90
+ echo implode( '', $li );
91
+ ?>
92
+ </ul>
93
+ <?php } ?>
94
+ </div>
95
+ </div>
96
+ <?php
97
+ }
98
+ ?>
99
+ </div>
100
  </div>
admin/pages/modules/tpl/module-preset-edit-item.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- // don't load directly
3
- if(!defined('ABSPATH')){
4
- die('-1');
5
  }
6
 
7
  /**
@@ -10,95 +10,95 @@ if(!defined('ABSPATH')){
10
  global $user_ID;
11
  ?>
12
 
13
- <form method="post" id="gmedia-edit-term" name="gmEditTerm" data-id="<?php echo $term_id; ?>" action="<?php echo $gmedia_url; ?>">
14
- <div class="panel-body">
15
- <h4 style="margin-top:0;">
16
- <?php if($term_id){
17
- $is_preset = 'edit';
18
- ?>
19
- <span class="pull-right"><?php echo __('ID', 'grand-media') . ": {$term->term_id}"; ?></span>
20
- <?php printf(__('Edit %s Preset', 'grand-media'), $term->module['info']['title']); ?>: <em><?php echo esc_html($term->name); ?></em>
21
- <?php } else{
22
- $is_preset = 'new';
23
- printf(__('New %s Preset', 'grand-media'), $term->module['info']['title']);
24
- } ?>
25
- </h4>
26
- <div class="row">
27
- <div class="col-sm-5">
28
- <div class="form-group">
29
- <label><?php _e('Name', 'grand-media'); ?></label>
30
- <?php if($term_id && !$term->name){
31
- if((int)$term->global){
32
- $is_preset = 'default';
33
- } else{
34
- $is_preset = 'global';
35
- }
36
- ?>
37
- <input type="text" class="form-control input-sm" name="term[name]" value="<?php $is_preset === 'global'? _e('Global Settings', 'grand-media') : _e('Default Settings', 'grand-media'); ?>" readonly/>
38
- <input type="hidden" name="module_preset_save_default" value="1"/>
39
- <?php } else{ ?>
40
- <input type="text" class="form-control input-sm" name="term[name]" value="<?php esc_attr_e($term->name); ?>" placeholder="<?php echo $term->name? esc_attr($term->name) : __('Preset Name', 'grand-media'); ?>"/>
41
- <?php } ?>
42
- </div>
43
- <div class="form-group">
44
- <label><?php _e('Author', 'grand-media'); ?></label>
45
- <?php
46
- if($is_preset === 'global'){
47
- echo '<input type="hidden" name="term[global]" value="0"/>';
48
- echo '<div>' . __('Global Preset', 'grand-media') . '</div>';
49
- } else{
50
- $_args = array('show_option_all' => '');
51
- if(!(int)$term->global){
52
- $_args['selected'] = $user_ID;
53
- }
54
- gmedia_term_choose_author_field($term->global, $_args);
55
- } ?>
56
- </div>
57
- <input type="hidden" name="term[term_id]" value="<?php echo $term_id; ?>"/>
58
- <input type="hidden" name="term[module]" value="<?php esc_attr_e($term->module['name']); ?>"/>
59
- <input type="hidden" name="term[taxonomy]" value="<?php echo $gmedia_term_taxonomy; ?>"/>
60
- <?php
61
- wp_nonce_field('GmediaGallery');
62
- wp_referer_field();
63
- ?>
64
- <div class="pull-right" id="save_buttons">
65
- <?php if($is_preset !== 'global'){ ?>
66
- <button type="submit" name="module_preset_save_global" class="btn btn-default btn-sm"><?php _e('Save as Global Preset', 'grand-media'); ?></button>
67
- <?php if($is_preset !== 'default'){ ?>
68
- <button type="submit" name="module_preset_save_default" class="btn btn-default btn-sm"><?php _e('Save as Default User Preset', 'grand-media'); ?></button>
69
- <?php
70
- }
71
- }
72
- $submit_name = 'module_preset_save';
73
- if($is_preset === 'default'){
74
- $submit_name = 'module_preset_save_default';
75
- }
76
- if($is_preset === 'global'){
77
- $submit_name = 'module_preset_save_global';
78
- }
79
- ?>
80
- <button type="submit" name="<?php echo $submit_name; ?>" class="btn btn-primary btn-sm"><?php _e('Save', 'grand-media'); ?></button>
81
- </div>
82
- </div>
83
 
84
- <div class="col-sm-5 col-sm-offset-2">
85
- <div class="form-group">
86
- <div class="pull-right"><a id="build_query" class="label label-primary buildquery-modal" href="#buildQuery" style="font-size:90%;"><?php _e('Build Query', 'grand-media'); ?></a></div>
87
- <label><?php _e('Query Args. for Preset Demo', 'grand-media'); ?></label>
88
- <textarea class="form-control input-sm" id="build_query_field" style="height:64px;" rows="2" name="term[query]"><?php echo(empty($gmedia_filter['query_args'])? 'limit=20' : urldecode(build_query($gmedia_filter['query_args']))); ?></textarea>
89
- </div>
90
- </div>
91
- </div>
92
 
93
- <hr/>
94
- <?php
95
- include(GMEDIA_ABSPATH . 'admin/pages/galleries/tpl/module-settings.php');
96
- ?>
97
 
98
- </div>
99
 
100
  </form>
101
 
102
  <?php
103
- include(GMEDIA_ABSPATH . 'admin/pages/galleries/tpl/modal-build-query.php');
104
  ?>
1
  <?php
2
+ // don't load directly.
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ die( '-1' );
5
  }
6
 
7
  /**
10
  global $user_ID;
11
  ?>
12
 
13
+ <form method="post" id="gmedia-edit-term" name="gmEditTerm" data-id="<?php echo absint( $term_id ); ?>" action="<?php echo esc_url( $gmedia_url ); ?>">
14
+ <div class="panel-body">
15
+ <h4 style="margin-top:0;">
16
+ <?php if ( $term_id ) {
17
+ $is_preset = 'edit';
18
+ ?>
19
+ <span class="pull-right"><?php echo __( 'ID', 'grand-media' ) . ": {$term->term_id}"; ?></span>
20
+ <?php printf( __( 'Edit %s Preset', 'grand-media' ), $term->module['info']['title'] ); ?>: <em><?php echo esc_html( $term->name ); ?></em>
21
+ <?php } else {
22
+ $is_preset = 'new';
23
+ printf( __( 'New %s Preset', 'grand-media' ), $term->module['info']['title'] );
24
+ } ?>
25
+ </h4>
26
+ <div class="row">
27
+ <div class="col-sm-5">
28
+ <div class="form-group">
29
+ <label><?php _e( 'Name', 'grand-media' ); ?></label>
30
+ <?php if ( $term_id && ! $term->name ) {
31
+ if ( (int) $term->global ) {
32
+ $is_preset = 'default';
33
+ } else {
34
+ $is_preset = 'global';
35
+ }
36
+ ?>
37
+ <input type="text" class="form-control input-sm" name="term[name]" value="<?php $is_preset === 'global' ? _e( 'Global Settings', 'grand-media' ) : _e( 'Default Settings', 'grand-media' ); ?>" readonly/>
38
+ <input type="hidden" name="module_preset_save_default" value="1"/>
39
+ <?php } else { ?>
40
+ <input type="text" class="form-control input-sm" name="term[name]" value="<?php echo esc_attr( $term->name ); ?>" placeholder="<?php echo esc_attr( $term->name ? $term->name : __( 'Preset Name', 'grand-media' ) ); ?>"/>
41
+ <?php } ?>
42
+ </div>
43
+ <div class="form-group">
44
+ <label><?php _e( 'Author', 'grand-media' ); ?></label>
45
+ <?php
46
+ if ( $is_preset === 'global' ) {
47
+ echo '<input type="hidden" name="term[global]" value="0"/>';
48
+ echo '<div>' . __( 'Global Preset', 'grand-media' ) . '</div>';
49
+ } else {
50
+ $_args = [ 'show_option_all' => '' ];
51
+ if ( ! (int) $term->global ) {
52
+ $_args['selected'] = $user_ID;
53
+ }
54
+ gmedia_term_choose_author_field( $term->global, $_args );
55
+ } ?>
56
+ </div>
57
+ <input type="hidden" name="term[term_id]" value="<?php echo absint( $term_id ); ?>"/>
58
+ <input type="hidden" name="term[module]" value="<?php echo esc_attr( $term->module['name'] ); ?>"/>
59
+ <input type="hidden" name="term[taxonomy]" value="<?php echo esc_attr( $gmedia_term_taxonomy ); ?>"/>
60
+ <?php
61
+ wp_nonce_field( 'GmediaGallery' );
62
+ wp_referer_field();
63
+ ?>
64
+ <div class="pull-right" id="save_buttons">
65
+ <?php if ( $is_preset !== 'global' ) { ?>
66
+ <button type="submit" name="module_preset_save_global" class="btn btn-default btn-sm"><?php _e( 'Save as Global Preset', 'grand-media' ); ?></button>
67
+ <?php if ( $is_preset !== 'default' ) { ?>
68
+ <button type="submit" name="module_preset_save_default" class="btn btn-default btn-sm"><?php _e( 'Save as Default User Preset', 'grand-media' ); ?></button>
69
+ <?php
70
+ }
71
+ }
72
+ $submit_name = 'module_preset_save';
73
+ if ( $is_preset === 'default' ) {
74
+ $submit_name = 'module_preset_save_default';
75
+ }
76
+ if ( $is_preset === 'global' ) {
77
+ $submit_name = 'module_preset_save_global';
78
+ }
79
+ ?>
80
+ <button type="submit" name="<?php echo esc_attr( $submit_name ); ?>" class="btn btn-primary btn-sm"><?php _e( 'Save', 'grand-media' ); ?></button>
81
+ </div>
82
+ </div>
83
 
84
+ <div class="col-sm-5 col-sm-offset-2">
85
+ <div class="form-group">
86
+ <div class="pull-right"><a id="build_query" class="label label-primary buildquery-modal" href="#buildQuery" style="font-size:90%;"><?php _e( 'Build Query', 'grand-media' ); ?></a></div>
87
+ <label><?php _e( 'Query Args. for Preset Demo', 'grand-media' ); ?></label>
88
+ <textarea class="form-control input-sm" id="build_query_field" style="height:64px;" rows="2" name="term[query]"><?php echo( empty( $gmedia_filter['query_args'] ) ? 'limit=20' : urldecode( build_query( $gmedia_filter['query_args'] ) ) ); ?></textarea>
89
+ </div>
90
+ </div>
91
+ </div>
92
 
93
+ <hr/>
94
+ <?php
95
+ include GMEDIA_ABSPATH . 'admin/pages/galleries/tpl/module-settings.php';
96
+ ?>
97
 
98
+ </div>
99
 
100
  </form>
101
 
102
  <?php
103
+ include GMEDIA_ABSPATH . 'admin/pages/galleries/tpl/modal-build-query.php';
104
  ?>
admin/pages/modules/tpl/module-preset-panel-heading.php CHANGED
@@ -1,11 +1,12 @@
1
  <?php
2
- // don't load directly
3
- if(!defined('ABSPATH')){
4
- die('-1');
5
  }
6
 
7
  /**
8
  * Panel heading for term
 
9
  * @var $gmCore
10
  * @var $term_id
11
  * @var $term
@@ -13,23 +14,23 @@ if(!defined('ABSPATH')){
13
  ?>
14
  <div class="panel-heading-fake"></div>
15
  <div class="panel-heading clearfix">
16
- <div class="btn-toolbar pull-left">
17
- <a class="btn btn-default pull-left" style="margin-right:20px;" href="<?php echo remove_query_arg(array('preset_module', 'preset'), wp_get_referer()); ?>"><?php _e('Go Back', 'grand-media'); ?></a>
18
 
19
- <?php if($term_id){ ?>
20
- <div class="btn-group">
21
- <a class="btn btn-default" href="#"><?php _e('Action', 'grand-media'); ?></a>
22
- <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
23
- <span class="caret"></span>
24
- <span class="sr-only"><?php _e('Toggle Dropdown', 'grand-media'); ?></span>
25
- </button>
26
- <ul class="dropdown-menu" role="menu">
27
- <li><a href="<?php echo add_query_arg(array('page' => 'GrandMedia_Galleries', 'gallery_module' => $term->module['name'], 'preset' => $term->term_id), admin_url('admin.php')); ?>"><?php _e('Create Gallery with this preset', 'grand-media'); ?></a></li>
28
- </ul>
29
- </div>
30
 
31
- <a class="btn btn-info pull-left" style="margin-left:20px;" href="<?php echo $gmCore->get_admin_url(array('preset_module' => $term->module['name']), array('preset')); ?>"><?php printf(__('New %s Preset', 'grand-media'), $term->module['info']['title']); ?></a>
32
- <?php } ?>
33
- </div>
34
- <div class="spinner"></div>
35
  </div>
1
  <?php
2
+ // don't load directly.
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ die( '-1' );
5
  }
6
 
7
  /**
8
  * Panel heading for term
9
+ *
10
  * @var $gmCore
11
  * @var $term_id
12
  * @var $term
14
  ?>
15
  <div class="panel-heading-fake"></div>
16
  <div class="panel-heading clearfix">
17
+ <div class="btn-toolbar pull-left">
18
+ <a class="btn btn-default pull-left" style="margin-right:20px;" href="<?php echo esc_url( remove_query_arg( [ 'preset_module', 'preset' ], wp_get_referer() ) ); ?>"><?php _e( 'Go Back', 'grand-media' ); ?></a>
19
 
20
+ <?php if ( $term_id ) { ?>
21
+ <div class="btn-group">
22
+ <a class="btn btn-default" href="#"><?php _e( 'Action', 'grand-media' ); ?></a>
23
+ <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
24
+ <span class="caret"></span>
25
+ <span class="sr-only"><?php _e( 'Toggle Dropdown', 'grand-media' ); ?></span>
26
+ </button>
27
+ <ul class="dropdown-menu" role="menu">
28
+ <li><a href="<?php echo esc_url( add_query_arg( [ 'page' => 'GrandMedia_Galleries', 'gallery_module' => $term->module['name'], 'preset' => $term->term_id ], admin_url( 'admin.php' ) ) ); ?>"><?php _e( 'Create Gallery with this preset', 'grand-media' ); ?></a></li>
29
+ </ul>
30
+ </div>
31
 
32
+ <a class="btn btn-info pull-left" style="margin-left:20px;" href="<?php echo esc_url( $gmCore->get_admin_url( [ 'preset_module' => $term->module['name'] ], [ 'preset' ] ) ); ?>"><?php printf( __( 'New %s Preset', 'grand-media' ), $term->module['info']['title'] ); ?></a>
33
+ <?php } ?>
34
+ </div>
35
+ <div class="spinner"></div>
36
  </div>
admin/pages/settings/settings.php CHANGED
@@ -1,71 +1,71 @@
1
- <?php
2
- /**
3
- * Gmedia Settings
4
- */
5
-
6
- // don't load directly
7
- if(!defined('ABSPATH')) {
8
- die('-1');
9
- }
10
-
11
-
12
- global $user_ID, $gmDB, $gmCore, $gmGallery, $gmProcessor;
13
-
14
- $url = $gmProcessor->url;
15
- $pk = isset($gmGallery->options['purchase_key'])? $gmGallery->options['purchase_key'] : '';
16
- $lk = isset($gmGallery->options['license_key'])? $gmGallery->options['license_key'] : '';
17
- ?>
18
-
19
- <form id="gmediaSettingsForm" class="panel panel-default" method="post" action="<?php echo $url; ?>">
20
- <div class="panel-heading clearfix">
21
- <div class="btn-toolbar pull-left">
22
- <div class="btn-group">
23
- <button type="submit" name="gmedia_settings_reset" class="btn btn-default" data-confirm="<?php _e('Reset all Gmedia settings?', 'grand-media') ?>"><?php _e('Reset Settings', 'grand-media'); ?></button>
24
- <button type="submit" name="gmedia_settings_save" class="btn btn-primary"><?php _e('Update', 'grand-media'); ?></button>
25
- </div>
26
- </div>
27
- <?php
28
- wp_nonce_field('gmedia_settings', '_wpnonce_settings');
29
- ?>
30
- </div>
31
- <div class="panel-body" id="gmedia-msg-panel"></div>
32
- <div class="container-fluid">
33
- <div class="tabable tabs-left">
34
- <ul id="settingsTabs" class="nav nav-tabs" style="padding:10px 0;">
35
- <li class="active"><a href="#gmedia_premium" data-toggle="tab"><?php _e('Premium Settings', 'grand-media'); ?></a></li>
36
- <li><a href="#gmedia_settings_other" data-toggle="tab"><?php _e('Other Settings', 'grand-media'); ?></a></li>
37
- <?php if(current_user_can('manage_options')) { ?>
38
- <li><a href="#gmedia_settings_permalinks" data-toggle="tab"><?php _e('Permalinks', 'grand-media'); ?></a></li>
39
- <li><a href="#gmedia_settings_cloud" data-toggle="tab"><?php _e('GmediaCloud Page', 'grand-media'); ?></a></li>
40
- <li><a href="#gmedia_settings_roles" data-toggle="tab"><?php _e('Roles/Capabilities Manager', 'grand-media'); ?></a></li>
41
- <?php } ?>
42
- <li><a href="#gmedia_settings_sysinfo" data-toggle="tab"><?php _e('System Info', 'grand-media'); ?></a></li>
43
- </ul>
44
- <div class="tab-content" style="padding-top:21px;">
45
- <?php
46
- include(dirname(__FILE__) . '/tpl/license.php');
47
- include(dirname(__FILE__) . '/tpl/common.php');
48
- if(current_user_can('manage_options')) {
49
- include(dirname(__FILE__) . '/tpl/permalinks.php');
50
- include(dirname(__FILE__) . '/tpl/roles.php');
51
- }
52
- include(dirname(__FILE__) . '/tpl/system.php');
53
- ?>
54
-
55
- </div>
56
- <div class="clear"></div>
57
- </div>
58
- <script type="text/javascript">
59
- jQuery(function($) {
60
- var hash = window.location.hash;
61
- if(hash) {
62
- hash = hash.replace('_tab', '');
63
- $('#settingsTabs a[href="' + hash + '"]').tab('show');
64
- }
65
- $('#gmediaSettingsForm').on('submit', function() {
66
- $(this).attr('action', $(this).attr('action') + $('#settingsTabs li.active a').attr('href') + '_tab');
67
- });
68
- });
69
- </script>
70
- </div>
71
- </form>
1
+ <?php
2
+ /**
3
+ * Gmedia Settings
4
+ */
5
+
6
+ // don't load directly.
7
+ if ( ! defined( 'ABSPATH' ) ) {
8
+ die( '-1' );
9
+ }
10
+
11
+
12
+ global $user_ID, $gmDB, $gmCore, $gmGallery, $gmProcessor;
13
+
14
+ $url = $gmProcessor->url;
15
+ $pk = isset( $gmGallery->options['purchase_key'] ) ? $gmGallery->options['purchase_key'] : '';
16
+ $lk = isset( $gmGallery->options['license_key'] ) ? $gmGallery->options['license_key'] : '';
17
+ ?>
18
+
19
+ <form id="gmediaSettingsForm" class="panel panel-default" method="post" action="<?php echo esc_url( $url ); ?>">
20
+ <div class="panel-heading clearfix">
21
+ <div class="btn-toolbar pull-left">
22
+ <div class="btn-group">
23
+ <button type="submit" name="gmedia_settings_reset" class="btn btn-default" data-confirm="<?php _e( 'Reset all Gmedia settings?', 'grand-media' ) ?>"><?php _e( 'Reset Settings', 'grand-media' ); ?></button>
24
+ <button type="submit" name="gmedia_settings_save" class="btn btn-primary"><?php _e( 'Update', 'grand-media' ); ?></button>
25
+ </div>
26
+ </div>
27
+ <?php
28
+ wp_nonce_field( 'gmedia_settings', '_wpnonce_settings' );
29
+ ?>
30
+ </div>
31
+ <div class="panel-body" id="gmedia-msg-panel"></div>
32
+ <div class="container-fluid">
33
+ <div class="tabable tabs-left">
34
+ <ul id="settingsTabs" class="nav nav-tabs" style="padding:10px 0;">
35
+ <li class="active"><a href="#gmedia_premium" data-toggle="tab"><?php _e( 'Premium Settings', 'grand-media' ); ?></a></li>
36
+ <li><a href="#gmedia_settings_other" data-toggle="tab"><?php _e( 'Other Settings', 'grand-media' ); ?></a></li>
37
+ <?php if ( current_user_can( 'manage_options' ) ) { ?>
38
+ <li><a href="#gmedia_settings_permalinks" data-toggle="tab"><?php _e( 'Permalinks', 'grand-media' ); ?></a></li>
39
+ <li><a href="#gmedia_settings_cloud" data-toggle="tab"><?php _e( 'GmediaCloud Page', 'grand-media' ); ?></a></li>
40
+ <li><a href="#gmedia_settings_roles" data-toggle="tab"><?php _e( 'Roles/Capabilities Manager', 'grand-media' ); ?></a></li>
41
+ <?php } ?>
42
+ <li><a href="#gmedia_settings_sysinfo" data-toggle="tab"><?php _e( 'System Info', 'grand-media' ); ?></a></li>
43
+ </ul>
44
+ <div class="tab-content" style="padding-top:21px;">
45
+ <?php
46
+ include dirname( __FILE__ ) . '/tpl/license.php';
47
+ include dirname( __FILE__ ) . '/tpl/common.php';
48
+ if ( current_user_can( 'manage_options' ) ) {
49
+ include dirname( __FILE__ ) . '/tpl/permalinks.php';
50
+ include dirname( __FILE__ ) . '/tpl/roles.php';
51
+ }
52
+ include dirname( __FILE__ ) . '/tpl/system.php';
53
+ ?>
54
+
55
+ </div>
56
+ <div class="clear"></div>
57
+ </div>
58
+ <script type="text/javascript">
59
+ jQuery(function($) {
60
+ var hash = window.location.hash;
61
+ if (hash) {
62
+ hash = hash.replace('_tab', '');
63
+ $('#settingsTabs a[href="' + hash + '"]').tab('show');
64
+ }
65
+ $('#gmediaSettingsForm').on('submit', function() {
66
+ $(this).attr('action', $(this).attr('action') + $('#settingsTabs li.active a').attr('href') + '_tab');
67
+ });
68
+ });
69
+ </script>
70
+ </div>
71
+ </form>
admin/pages/settings/tpl/common.php CHANGED
@@ -1,251 +1,252 @@
1
  <?php
2
- // don't load directly
3
- if(!defined('ABSPATH')){
4
- die('-1');
5
  }
6
 
7
  /**
8
  * Common Settings
 
9
  * @var $gmGallery
10
  * @var $gmDB
11
  */
12
  ?>
13
  <fieldset id="gmedia_settings_other" class="tab-pane">
14
- <div class="form-group">
15
- <label><?php _e('When delete (uninstall) plugin', 'grand-media') ?>:</label>
16
- <select name="set[uninstall_dropdata]" class="form-control input-sm">
17
- <option value="all" <?php selected($gmGallery->options['uninstall_dropdata'], 'all'); ?>><?php _e('Delete database and all uploaded files', 'grand-media'); ?></option>
18
- <option value="db" <?php selected($gmGallery->options['uninstall_dropdata'], 'db'); ?>><?php _e('Delete database only and leave uploaded files', 'grand-media'); ?></option>
19
- <option value="none" <?php selected($gmGallery->options['uninstall_dropdata'], 'none'); ?>><?php _e('Do not delete database and uploaded files', 'grand-media'); ?></option>
20
- </select>
21
- </div>
22
-
23
- <hr />
24
- <div class="form-group">
25
- <label><?php esc_html_e('Google API Key', 'grand-media') ?></label>
26
- <div class="row">
27
- <div class="col-xs-6">
28
- <input type="text" name="set[google_api_key]" class="form-control input-sm" value="<?php echo esc_attr($gmGallery->options['google_api_key']) ?>">
29
- </div>
30
- <div class="col-xs-6">
31
- <p style="padding-top: 5px"><a target="_blank" href="https://support.google.com/googleapi/answer/6158862"><?php _e('How to create a Google API Key', 'grand-media') ?></a></p>
32
- </div>
33
- </div>
34
- <p class="help-block"><?php _e('This API key is required to using Google Map in admin and in the gallery modules.', 'grand-media'); ?></p>
35
- </div>
36
-
37
- <hr />
38
- <div class="form-group">
39
- <label><?php esc_html_e('Cache expiration', 'grand-media') ?></label>
40
- <div class="row">
41
- <div class="col-xs-6">
42
- <input type="number" name="set[cache_expiration]" class="form-control input-sm" value="<?php echo (int) $gmGallery->options['cache_expiration']; ?>">
43
- </div>
44
- </div>
45
- <p class="help-block"><?php _e('Set 0 to disable cache for Gmedia Modules. Cache also reset automatically every time you save or update item in Gmedia Library or update any term or gallery.', 'grand-media'); ?></p>
46
- </div>
47
-
48
- <hr />
49
- <div class="form-group row">
50
- <div class="col-xs-6">
51
- <label><?php _e('In Tags order gmedia', 'grand-media'); ?></label>
52
- <select name="set[in_tag_orderby]" class="form-control input-sm">
53
- <option value="ID" <?php selected($gmGallery->options['in_tag_orderby'], 'ID'); ?>><?php _e('by ID', 'grand-media'); ?></option>
54
- <option value="title" <?php selected($gmGallery->options['in_tag_orderby'], 'title'); ?>><?php _e('by title', 'grand-media'); ?></option>
55
- <option value="gmuid" <?php selected($gmGallery->options['in_tag_orderby'], 'gmuid'); ?>><?php _e('by filename', 'grand-media'); ?></option>
56
- <option value="date" <?php selected($gmGallery->options['in_tag_orderby'], 'date'); ?>><?php _e('by date', 'grand-media'); ?></option>
57
- <option value="modified" <?php selected($gmGallery->options['in_tag_orderby'], 'modified'); ?>><?php _e('by last modified date', 'grand-media'); ?></option>
58
- <option value="comment_count" <?php selected($gmGallery->options['in_tag_orderby'], 'comment_count'); ?>><?php _e('by comment count', 'grand-media'); ?></option>
59
- <option value="rand" <?php selected($gmGallery->options['in_tag_orderby'], 'rand'); ?>><?php _e('Random', 'grand-media'); ?></option>
60
- </select>
61
- </div>
62
- <div class="col-xs-6">
63
- <label><?php _e('Sort order', 'grand-media'); ?></label>
64
- <select name="set[in_tag_order]" class="form-control input-sm">
65
- <option value="DESC" <?php selected($gmGallery->options['in_tag_order'], 'DESC'); ?>><?php _e('DESC', 'grand-media'); ?></option>
66
- <option value="ASC" <?php selected($gmGallery->options['in_tag_order'], 'ASC'); ?>><?php _e('ASC', 'grand-media'); ?></option>
67
- </select>
68
- </div>
69
- </div>
70
-
71
- <hr />
72
- <div class="form-group">
73
- <div class="row">
74
- <div class="col-xs-6">
75
- <label><?php _e('In Category order gmedia (set default order)', 'grand-media'); ?></label>
76
- <select name="set[in_category_orderby]" class="form-control input-sm">
77
- <option value="ID" <?php selected($gmGallery->options['in_category_orderby'], 'ID'); ?>><?php _e('by ID', 'grand-media'); ?></option>
78
- <option value="title" <?php selected($gmGallery->options['in_category_orderby'], 'title'); ?>><?php _e('by title', 'grand-media'); ?></option>
79
- <option value="gmuid" <?php selected($gmGallery->options['in_category_orderby'], 'gmuid'); ?>><?php _e('by filename', 'grand-media'); ?></option>
80
- <option value="date" <?php selected($gmGallery->options['in_category_orderby'], 'date'); ?>><?php _e('by date', 'grand-media'); ?></option>
81
- <option value="modified" <?php selected($gmGallery->options['in_category_orderby'], 'modified'); ?>><?php _e('by last modified date', 'grand-media'); ?></option>
82
- <option value="comment_count" <?php selected($gmGallery->options['in_category_orderby'], 'comment_count'); ?>><?php _e('by comment count', 'grand-media'); ?></option>
83
- <option value="rand" <?php selected($gmGallery->options['in_category_orderby'], 'rand'); ?>><?php _e('Random', 'grand-media'); ?></option>
84
- </select>
85
- </div>
86
- <div class="col-xs-6">
87
- <label><?php _e('Sort order', 'grand-media'); ?></label>
88
- <select name="set[in_category_order]" class="form-control input-sm">
89
- <option value="DESC" <?php selected($gmGallery->options['in_category_order'], 'DESC'); ?>><?php _e('DESC', 'grand-media'); ?></option>
90
- <option value="ASC" <?php selected($gmGallery->options['in_category_order'], 'ASC'); ?>><?php _e('ASC', 'grand-media'); ?></option>
91
- </select>
92
- </div>
93
- </div>
94
- <p class="help-block"><?php _e('This option could be rewritten by individual category settings.', 'grand-media'); ?></p>
95
- </div>
96
-
97
- <hr />
98
- <div class="form-group">
99
- <div class="row">
100
- <div class="col-xs-6">
101
- <label><?php _e('In Album order gmedia (set default order)', 'grand-media'); ?></label>
102
- <select name="set[in_album_orderby]" class="form-control input-sm">
103
- <option value="ID" <?php selected($gmGallery->options['in_album_orderby'], 'ID'); ?>><?php _e('by ID', 'grand-media'); ?></option>
104
- <option value="title" <?php selected($gmGallery->options['in_album_orderby'], 'title'); ?>><?php _e('by title', 'grand-media'); ?></option>
105
- <option value="gmuid" <?php selected($gmGallery->options['in_album_orderby'], 'gmuid'); ?>><?php _e('by filename', 'grand-media'); ?></option>
106
- <option value="date" <?php selected($gmGallery->options['in_album_orderby'], 'date'); ?>><?php _e('by date', 'grand-media'); ?></option>
107
- <option value="modified" <?php selected($gmGallery->options['in_album_orderby'], 'modified'); ?>><?php _e('by last modified date', 'grand-media'); ?></option>
108
- <option value="comment_count" <?php selected($gmGallery->options['in_album_orderby'], 'comment_count'); ?>><?php _e('by comment count', 'grand-media'); ?></option>
109
- <option value="rand" <?php selected($gmGallery->options['in_album_orderby'], 'rand'); ?>><?php _e('Random', 'grand-media'); ?></option>
110
- </select>
111
- </div>
112
- <div class="col-xs-6">
113
- <label><?php _e('Sort order', 'grand-media'); ?></label>
114
- <select name="set[in_album_order]" class="form-control input-sm">
115
- <option value="DESC" <?php selected($gmGallery->options['in_album_order'], 'DESC'); ?>><?php _e('DESC', 'grand-media'); ?></option>
116
- <option value="ASC" <?php selected($gmGallery->options['in_album_order'], 'ASC'); ?>><?php _e('ASC', 'grand-media'); ?></option>
117
- </select>
118
- </div>
119
- </div>
120
- <p class="help-block"><?php _e('This option could be rewritten by individual category settings.', 'grand-media'); ?></p>
121
- </div>
122
- <div class="form-group">
123
- <label><?php _e('Set default Album status', 'grand-media'); ?></label>
124
- <select name="set[in_album_status]" class="form-control input-sm">
125
- <option value="publish" <?php selected($gmGallery->options['in_album_status'], 'publish'); ?>><?php _e('Public', 'grand-media'); ?></option>
126
- <option value="private" <?php selected($gmGallery->options['in_album_status'], 'private'); ?>><?php _e('Private', 'grand-media'); ?></option>
127
- <option value="draft" <?php selected($gmGallery->options['in_album_status'], 'draft'); ?>><?php _e('Draft', 'grand-media'); ?></option>
128
- </select>
129
- </div>
130
-
131
- <hr />
132
- <?php $gmedia_modules = get_gmedia_modules(false); ?>
133
- <div class="form-group">
134
- <label><?php _e('Choose default module', 'grand-media') ?>:</label>
135
- <select class="form-control input-sm" name="set[default_gmedia_module]">
136
- <?php foreach($gmedia_modules['in'] as $mfold => $module){
137
- echo '<optgroup label="' . esc_attr($module['title']) . '">';
138
- $presets = $gmDB->get_terms('gmedia_module', array('status' => $mfold));
139
- $selected = selected($gmGallery->options['default_gmedia_module'], esc_attr($mfold), false);
140
- $option = array();
141
- $option[] = '<option ' . $selected . ' value="' . esc_attr($mfold) . '">' . $module['title'] . ' - ' . __('Default Settings') . '</option>';
142
- foreach($presets as $preset){
143
- if(!(int)$preset->global && '[' . $mfold . ']' === $preset->name){
144
- continue;
145
- }
146
- $selected = selected($gmGallery->options['default_gmedia_module'], $preset->term_id, false);
147
- $by_author = '';
148
- if((int)$preset->global){
149
- $by_author = ' [' . get_the_author_meta('display_name', $preset->global) . ']';
150
- }
151
- if('[' . $mfold . ']' === $preset->name){
152
- $option[] = '<option ' . $selected . ' value="' . $preset->term_id . '">' . $module['title'] . $by_author . ' - ' . __('Default Settings') . '</option>';
153
- } else{
154
- $preset_name = str_replace('[' . $mfold . '] ', '', $preset->name);
155
- $option[] = '<option ' . $selected . ' value="' . $preset->term_id . '">' . $module['title'] . $by_author . ' - ' . $preset_name . '</option>';
156
- }
157
- }
158
- echo implode('', $option);
159
- echo '</optgroup>';
160
- } ?>
161
- </select>
162
-
163
- <p class="help-block"><?php _e('Chosen module will be used for terms pages.', 'grand-media'); ?></p>
164
- </div>
165
-
166
- <hr />
167
- <div class="form-group">
168
- <label><?php _e('Notifications', 'grand-media'); ?></label>
169
- <div class="checkbox" style="margin:0;">
170
- <input type="hidden" name="set[notify_new_modules]" value="0"/>
171
- <label><input type="checkbox" name="set[notify_new_modules]" value="1" <?php checked($gmGallery->options['notify_new_modules'], '1'); ?> /> <?php _e('Show notification label about new modules (green conter)', 'grand-media'); ?> </label>
172
- </div>
173
- </div>
174
-
175
- <hr />
176
- <div class="form-group">
177
- <label><?php _e('Choose what to show on Author Profile pages', 'grand-media'); ?></label>
178
- <div class="checkbox" style="margin:0;">
179
- <input type="hidden" name="set[wp_author_related_gmedia]" value="0"/>
180
- <label><input type="checkbox" name="set[wp_author_related_gmedia]" value="1" <?php checked($gmGallery->options['wp_author_related_gmedia'], '1'); ?> /> <?php _e('Gmedia Posts (media items from Gmedia Libary)', 'grand-media'); ?> </label>
181
- </div>
182
- <div class="checkbox" style="margin:0;">
183
- <input type="hidden" name="set[wp_author_related_gmedia_album]" value="0"/>
184
- <label><input type="checkbox" name="set[wp_author_related_gmedia_album]" value="1" <?php checked($gmGallery->options['wp_author_related_gmedia_album'], '1'); ?> /> <?php _e('Gmedia Albums', 'grand-media'); ?> </label>
185
- </div>
186
- <div class="checkbox" style="margin:0;">
187
- <input type="hidden" name="set[wp_author_related_gmedia_gallery]" value="0"/>
188
- <label><input type="checkbox" name="set[wp_author_related_gmedia_gallery]" value="1" <?php checked($gmGallery->options['wp_author_related_gmedia_gallery'], '1'); ?> /> <?php _e('Gmedia Galleries', 'grand-media'); ?> </label>
189
- </div>
190
- </div>
191
-
192
- <hr />
193
- <div class="form-group">
194
- <label><?php _e('When set title from filename', 'grand-media') ?>:</label>
195
-
196
- <div class="checkbox" style="margin:0;">
197
- <input type="hidden" name="set[name2title_capitalize]" value="0"/>
198
- <label><input type="checkbox" name="set[name2title_capitalize]" value="1" <?php checked($gmGallery->options['name2title_capitalize'], '1'); ?> /> <?php _e('Make the first letter of each word capitalized (Title Case)', 'grand-media'); ?> </label>
199
- </div>
200
- </div>
201
-
202
- <hr />
203
- <div class="form-group">
204
- <label><?php _e('Forbid other plugins to load their JS and CSS on Gmedia admin pages', 'grand-media') ?>:</label>
205
-
206
- <div class="checkbox" style="margin:0;">
207
- <input type="hidden" name="set[isolation_mode]" value="0"/>
208
- <label><input type="checkbox" name="set[isolation_mode]" value="1" <?php checked($gmGallery->options['isolation_mode'], '1'); ?> /> <?php _e('Enable Gmedia admin panel Isolation Mode', 'grand-media'); ?> </label>
209
-
210
- <p class="help-block"><?php _e('This option could help to avoid JS and CSS conflicts with other plugins in admin panel.', 'grand-media'); ?></p>
211
- </div>
212
- </div>
213
- <div class="form-group">
214
- <label><?php _e('Forbid theme to format Gmedia shortcode\'s content', 'grand-media') ?>:</label>
215
-
216
- <div class="checkbox" style="margin:0;">
217
- <input type="hidden" name="set[shortcode_raw]" value="0"/>
218
- <label><input type="checkbox" name="set[shortcode_raw]" value="1" <?php checked($gmGallery->options['shortcode_raw'], '1'); ?> /> <?php _e('Raw output for Gmedia Shortcode', 'grand-media'); ?> </label>
219
-
220
- <p class="help-block"><?php _e('Some themes reformat shortcodes and break it functionality (mostly when you add description to images). Turning this on should solve this problem.', 'grand-media'); ?></p>
221
- </div>
222
- </div>
223
- <div class="form-group">
224
- <label><?php _e('Debug Mode', 'grand-media') ?>:</label>
225
-
226
- <div class="checkbox" style="margin:0;">
227
- <input type="hidden" name="set[debug_mode]" value=""/>
228
- <label><input type="checkbox" name="set[debug_mode]" value="1" <?php checked($gmGallery->options['debug_mode'], '1'); ?> /> <?php _e('Enable Debug Mode on Gmedia admin pages', 'grand-media'); ?> </label>
229
- </div>
230
- </div>
231
- <?php
232
- $allowed_post_types = (array)$gmGallery->options['gmedia_post_types_support'];
233
- $args = array('public' => true,
234
- 'show_ui' => true,
235
- '_builtin' => false
236
- );
237
- $output = 'objects'; // names or objects, note names is the default
238
- $operator = 'and'; // 'and' or 'or'
239
- $post_types = get_post_types($args, $output, $operator);
240
- if(!empty($post_types)){ ?>
241
- <div class="form-group">
242
- <label style="margin-bottom:-5px;"><?php _e('Enable Gmedia Library button on custom post types', 'grand-media') ?>:</label>
243
- <input type="hidden" name="set[gmedia_post_types_support]" value=""/>
244
- <?php
245
- foreach($post_types as $post_type){ ?>
246
- <div class="checkbox"><label><input type="checkbox" name="set[gmedia_post_types_support][]" value="<?php echo $post_type->name; ?>" <?php echo in_array($post_type->name, $allowed_post_types)? 'checked="checked"' : ''; ?> /> <?php echo $post_type->label . ' (' . $post_type->name . ')'; ?></label></div>
247
- <?php } ?>
248
- </div>
249
- <?php } ?>
 
250
  </fieldset>
251
-
1
  <?php
2
+ // don't load directly.
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ die( '-1' );
5
  }
6
 
7
  /**
8
  * Common Settings
9
+ *
10
  * @var $gmGallery
11
  * @var $gmDB
12
  */
13
  ?>
14
  <fieldset id="gmedia_settings_other" class="tab-pane">
15
+ <div class="form-group">
16
+ <label><?php _e( 'When delete (uninstall) plugin', 'grand-media' ) ?>:</label>
17
+ <select name="set[uninstall_dropdata]" class="form-control input-sm">
18
+ <option value="all" <?php selected( $gmGallery->options['uninstall_dropdata'], 'all' ); ?>><?php _e( 'Delete database and all uploaded files', 'grand-media' ); ?></option>
19
+ <option value="db" <?php selected( $gmGallery->options['uninstall_dropdata'], 'db' ); ?>><?php _e( 'Delete database only and leave uploaded files', 'grand-media' ); ?></option>
20
+ <option value="none" <?php selected( $gmGallery->options['uninstall_dropdata'], 'none' ); ?>><?php _e( 'Do not delete database and uploaded files', 'grand-media' ); ?></option>
21
+ </select>
22
+ </div>
23
+
24
+ <hr/>
25
+ <div class="form-group">
26
+ <label><?php esc_html_e( 'Google API Key', 'grand-media' ) ?></label>
27
+ <div class="row">
28
+ <div class="col-xs-6">
29
+ <input type="text" name="set[google_api_key]" class="form-control input-sm" value="<?php echo esc_attr( $gmGallery->options['google_api_key'] ) ?>">
30
+ </div>
31
+ <div class="col-xs-6">
32
+ <p style="padding-top: 5px"><a target="_blank" href="https://support.google.com/googleapi/answer/6158862"><?php _e( 'How to create a Google API Key', 'grand-media' ) ?></a></p>
33
+ </div>
34
+ </div>
35
+ <p class="help-block"><?php _e( 'This API key is required to using Google Map in admin and in the gallery modules.', 'grand-media' ); ?></p>
36
+ </div>
37
+
38
+ <hr/>
39
+ <div class="form-group">
40
+ <label><?php esc_html_e( 'Cache expiration', 'grand-media' ) ?></label>
41
+ <div class="row">
42
+ <div class="col-xs-6">
43
+ <input type="number" name="set[cache_expiration]" class="form-control input-sm" value="<?php echo absint( $gmGallery->options['cache_expiration'] ); ?>">
44
+ </div>
45
+ </div>
46
+ <p class="help-block"><?php _e( 'Set 0 to disable cache for Gmedia Modules. Cache also reset automatically every time you save or update item in Gmedia Library or update any term or gallery.', 'grand-media' ); ?></p>
47
+ </div>
48
+
49
+ <hr/>
50
+ <div class="form-group row">
51
+ <div class="col-xs-6">
52
+ <label><?php _e( 'In Tags order gmedia', 'grand-media' ); ?></label>
53
+ <select name="set[in_tag_orderby]" class="form-control input-sm">
54
+ <option value="ID" <?php selected( $gmGallery->options['in_tag_orderby'], 'ID' ); ?>><?php _e( 'by ID', 'grand-media' ); ?></option>
55
+ <option value="title" <?php selected( $gmGallery->options['in_tag_orderby'], 'title' ); ?>><?php _e( 'by title', 'grand-media' ); ?></option>
56
+ <option value="gmuid" <?php selected( $gmGallery->options['in_tag_orderby'], 'gmuid' ); ?>><?php _e( 'by filename', 'grand-media' ); ?></option>
57
+ <option value="date" <?php selected( $gmGallery->options['in_tag_orderby'], 'date' ); ?>><?php _e( 'by date', 'grand-media' ); ?></option>
58
+ <option value="modified" <?php selected( $gmGallery->options['in_tag_orderby'], 'modified' ); ?>><?php _e( 'by last modified date', 'grand-media' ); ?></option>
59
+ <option value="comment_count" <?php selected( $gmGallery->options['in_tag_orderby'], 'comment_count' ); ?>><?php _e( 'by comment count', 'grand-media' ); ?></option>
60
+ <option value="rand" <?php selected( $gmGallery->options['in_tag_orderby'], 'rand' ); ?>><?php _e( 'Random', 'grand-media' ); ?></option>
61
+ </select>
62
+ </div>
63
+ <div class="col-xs-6">
64
+ <label><?php _e( 'Sort order', 'grand-media' ); ?></label>
65
+ <select name="set[in_tag_order]" class="form-control input-sm">
66
+ <option value="DESC" <?php selected( $gmGallery->options['in_tag_order'], 'DESC' ); ?>><?php _e( 'DESC', 'grand-media' ); ?></option>
67
+ <option value="ASC" <?php selected( $gmGallery->options['in_tag_order'], 'ASC' ); ?>><?php _e( 'ASC', 'grand-media' ); ?></option>
68
+ </select>
69
+ </div>
70
+ </div>
71
+
72
+ <hr/>
73
+ <div class="form-group">
74
+ <div class="row">
75
+ <div class="col-xs-6">
76
+ <label><?php _e( 'In Category order gmedia (set default order)', 'grand-media' ); ?></label>
77
+ <select name="set[in_category_orderby]" class="form-control input-sm">
78
+ <option value="ID" <?php selected( $gmGallery->options['in_category_orderby'], 'ID' ); ?>><?php _e( 'by ID', 'grand-media' ); ?></option>
79
+ <option value="title" <?php selected( $gmGallery->options['in_category_orderby'], 'title' ); ?>><?php _e( 'by title', 'grand-media' ); ?></option>
80
+ <option value="gmuid" <?php selected( $gmGallery->options['in_category_orderby'], 'gmuid' ); ?>><?php _e( 'by filename', 'grand-media' ); ?></option>
81
+ <option value="date" <?php selected( $gmGallery->options['in_category_orderby'], 'date' ); ?>><?php _e( 'by date', 'grand-media' ); ?></option>
82
+ <option value="modified" <?php selected( $gmGallery->options['in_category_orderby'], 'modified' ); ?>><?php _e( 'by last modified date', 'grand-media' ); ?></option>
83
+ <option value="comment_count" <?php selected( $gmGallery->options['in_category_orderby'], 'comment_count' ); ?>><?php _e( 'by comment count', 'grand-media' ); ?></option>
84
+ <option value="rand" <?php selected( $gmGallery->options['in_category_orderby'], 'rand' ); ?>><?php _e( 'Random', 'grand-media' ); ?></option>
85
+ </select>
86
+ </div>
87
+ <div class="col-xs-6">
88
+ <label><?php _e( 'Sort order', 'grand-media' ); ?></label>
89
+ <select name="set[in_category_order]" class="form-control input-sm">
90
+ <option value="DESC" <?php selected( $gmGallery->options['in_category_order'], 'DESC' ); ?>><?php _e( 'DESC', 'grand-media' ); ?></option>
91
+ <option value="ASC" <?php selected( $gmGallery->options['in_category_order'], 'ASC' ); ?>><?php _e( 'ASC', 'grand-media' ); ?></option>
92
+ </select>
93
+ </div>
94
+ </div>
95
+ <p class="help-block"><?php _e( 'This option could be rewritten by individual category settings.', 'grand-media' ); ?></p>
96
+ </div>
97
+
98
+ <hr/>
99
+ <div class="form-group">
100
+ <div class="row">
101
+ <div class="col-xs-6">
102
+ <label><?php _e( 'In Album order gmedia (set default order)', 'grand-media' ); ?></label>
103
+ <select name="set[in_album_orderby]" class="form-control input-sm">
104
+ <option value="ID" <?php selected( $gmGallery->options['in_album_orderby'], 'ID' ); ?>><?php _e( 'by ID', 'grand-media' ); ?></option>
105
+ <option value="title" <?php selected( $gmGallery->options['in_album_orderby'], 'title' ); ?>><?php _e( 'by title', 'grand-media' ); ?></option>
106
+ <option value="gmuid" <?php selected( $gmGallery->options['in_album_orderby'], 'gmuid' ); ?>><?php _e( 'by filename', 'grand-media' ); ?></option>
107
+ <option value="date" <?php selected( $gmGallery->options['in_album_orderby'], 'date' ); ?>><?php _e( 'by date', 'grand-media' ); ?></option>
108
+ <option value="modified" <?php selected( $gmGallery->options['in_album_orderby'], 'modified' ); ?>><?php _e( 'by last modified date', 'grand-media' ); ?></option>
109
+ <option value="comment_count" <?php selected( $gmGallery->options['in_album_orderby'], 'comment_count' ); ?>><?php _e( 'by comment count', 'grand-media' ); ?></option>
110
+ <option value="rand" <?php selected( $gmGallery->options['in_album_orderby'], 'rand' ); ?>><?php _e( 'Random', 'grand-media' ); ?></option>
111
+ </select>
112
+ </div>
113
+ <div class="col-xs-6">
114
+ <label><?php _e( 'Sort order', 'grand-media' ); ?></label>
115
+ <select name="set[in_album_order]" class="form-control input-sm">
116
+ <option value="DESC" <?php selected( $gmGallery->options['in_album_order'], 'DESC' ); ?>><?php _e( 'DESC', 'grand-media' ); ?></option>
117
+ <option value="ASC" <?php selected( $gmGallery->options['in_album_order'], 'ASC' ); ?>><?php _e( 'ASC', 'grand-media' ); ?></option>
118
+ </select>
119
+ </div>
120
+ </div>
121
+ <p class="help-block"><?php _e( 'This option could be rewritten by individual category settings.', 'grand-media' ); ?></p>
122
+ </div>
123
+ <div class="form-group">
124
+ <label><?php _e( 'Set default Album status', 'grand-media' ); ?></label>
125
+ <select name="set[in_album_status]" class="form-control input-sm">
126
+ <option value="publish" <?php selected( $gmGallery->options['in_album_status'], 'publish' ); ?>><?php _e( 'Public', 'grand-media' ); ?></option>
127
+ <option value="private" <?php selected( $gmGallery->options['in_album_status'], 'private' ); ?>><?php _e( 'Private', 'grand-media' ); ?></option>
128
+ <option value="draft" <?php selected( $gmGallery->options['in_album_status'], 'draft' ); ?>><?php _e( 'Draft', 'grand-media' ); ?></option>
129
+ </select>
130
+ </div>
131
+
132
+ <hr/>
133
+ <?php $gmedia_modules = get_gmedia_modules( false ); ?>
134
+ <div class="form-group">
135
+ <label><?php _e( 'Choose default module', 'grand-media' ) ?>:</label>
136
+ <select class="form-control input-sm" name="set[default_gmedia_module]">
137
+ <?php foreach ( $gmedia_modules['in'] as $mfold => $module ) {
138
+ echo '<optgroup label="' . esc_attr( $module['title'] ) . '">';
139
+ $presets = $gmDB->get_terms( 'gmedia_module', [ 'status' => $mfold ] );
140
+ $selected = selected( $gmGallery->options['default_gmedia_module'], esc_attr( $mfold ), false );
141
+ $option = [];
142
+ $option[] = '<option ' . $selected . ' value="' . esc_attr( $mfold ) . '">' . esc_html( $module['title'] ) . ' - ' . __( 'Default Settings' ) . '</option>';
143
+ foreach ( $presets as $preset ) {
144
+ if ( ! (int) $preset->global && '[' . $mfold . ']' === $preset->name ) {
145
+ continue;
146
+ }
147
+ $selected = selected( $gmGallery->options['default_gmedia_module'], $preset->term_id, false );
148
+ $by_author = '';
149
+ if ( (int) $preset->global ) {
150
+ $by_author = ' [' . get_the_author_meta( 'display_name', $preset->global ) . ']';
151
+ }
152
+ if ( '[' . $mfold . ']' === $preset->name ) {
153
+ $option[] = '<option ' . $selected . ' value="' . $preset->term_id . '">' . esc_html( $module['title'] . $by_author ) . ' - ' . __( 'Default Settings' ) . '</option>';
154
+ } else {
155
+ $preset_name = str_replace( '[' . $mfold . '] ', '', $preset->name );
156
+ $option[] = '<option ' . $selected . ' value="' . $preset->term_id . '">' . esc_html( $module['title'] . $by_author . ' - ' . $preset_name ) . '</option>';
157
+ }
158
+ }
159
+ echo implode( '', $option );
160
+ echo '</optgroup>';
161
+ } ?>
162
+ </select>
163
+
164
+ <p class="help-block"><?php _e( 'Chosen module will be used for terms pages.', 'grand-media' ); ?></p>
165
+ </div>
166
+
167
+ <hr/>
168
+ <div class="form-group">
169
+ <label><?php _e( 'Notifications', 'grand-media' ); ?></label>
170
+ <div class="checkbox" style="margin:0;">
171
+ <input type="hidden" name="set[notify_new_modules]" value="0"/>
172
+ <label><input type="checkbox" name="set[notify_new_modules]" value="1" <?php checked( $gmGallery->options['notify_new_modules'], '1' ); ?> /> <?php _e( 'Show notification label about new modules (green conter)', 'grand-media' ); ?> </label>
173
+ </div>
174
+ </div>
175
+
176
+ <hr/>
177
+ <div class="form-group">
178
+ <label><?php _e( 'Choose what to show on Author Profile pages', 'grand-media' ); ?></label>
179
+ <div class="checkbox" style="margin:0;">
180
+ <input type="hidden" name="set[wp_author_related_gmedia]" value="0"/>
181
+ <label><input type="checkbox" name="set[wp_author_related_gmedia]" value="1" <?php checked( $gmGallery->options['wp_author_related_gmedia'], '1' ); ?> /> <?php _e( 'Gmedia Posts (media items from Gmedia Libary)', 'grand-media' ); ?> </label>
182
+ </div>
183
+ <div class="checkbox" style="margin:0;">
184
+ <input type="hidden" name="set[wp_author_related_gmedia_album]" value="0"/>
185
+ <label><input type="checkbox" name="set[wp_author_related_gmedia_album]" value="1" <?php checked( $gmGallery->options['wp_author_related_gmedia_album'], '1' ); ?> /> <?php _e( 'Gmedia Albums', 'grand-media' ); ?> </label>
186
+ </div>
187
+ <div class="checkbox" style="margin:0;">
188
+ <input type="hidden" name="set[wp_author_related_gmedia_gallery]" value="0"/>
189
+ <label><input type="checkbox" name="set[wp_author_related_gmedia_gallery]" value="1" <?php checked( $gmGallery->options['wp_author_related_gmedia_gallery'], '1' ); ?> /> <?php _e( 'Gmedia Galleries', 'grand-media' ); ?> </label>
190
+ </div>
191
+ </div>
192
+
193
+ <hr/>
194
+ <div class="form-group">
195
+ <label><?php _e( 'When set title from filename', 'grand-media' ) ?>:</label>
196
+
197
+ <div class="checkbox" style="margin:0;">
198
+ <input type="hidden" name="set[name2title_capitalize]" value="0"/>
199
+ <label><input type="checkbox" name="set[name2title_capitalize]" value="1" <?php checked( $gmGallery->options['name2title_capitalize'], '1' ); ?> /> <?php _e( 'Make the first letter of each word capitalized (Title Case)', 'grand-media' ); ?> </label>
200
+ </div>
201
+ </div>
202
+
203
+ <hr/>
204
+ <div class="form-group">
205
+ <label><?php _e( 'Forbid other plugins to load their JS and CSS on Gmedia admin pages', 'grand-media' ) ?>:</label>
206
+
207
+ <div class="checkbox" style="margin:0;">
208
+ <input type="hidden" name="set[isolation_mode]" value="0"/>
209
+ <label><input type="checkbox" name="set[isolation_mode]" value="1" <?php checked( $gmGallery->options['isolation_mode'], '1' ); ?> /> <?php _e( 'Enable Gmedia admin panel Isolation Mode', 'grand-media' ); ?> </label>
210
+
211
+ <p class="help-block"><?php _e( 'This option could help to avoid JS and CSS conflicts with other plugins in admin panel.', 'grand-media' ); ?></p>
212
+ </div>
213
+ </div>
214
+ <div class="form-group">
215
+ <label><?php _e( 'Forbid theme to format Gmedia shortcode\'s content', 'grand-media' ) ?>:</label>
216
+
217
+ <div class="checkbox" style="margin:0;">
218
+ <input type="hidden" name="set[shortcode_raw]" value="0"/>
219
+ <label><input type="checkbox" name="set[shortcode_raw]" value="1" <?php checked( $gmGallery->options['shortcode_raw'], '1' ); ?> /> <?php _e( 'Raw output for Gmedia Shortcode', 'grand-media' ); ?> </label>
220
+
221
+ <p class="help-block"><?php _e( 'Some themes reformat shortcodes and break it functionality (mostly when you add description to images). Turning this on should solve this problem.', 'grand-media' ); ?></p>
222
+ </div>
223
+ </div>
224
+ <div class="form-group">
225
+ <label><?php _e( 'Debug Mode', 'grand-media' ) ?>:</label>
226
+
227
+ <div class="checkbox" style="margin:0;">
228
+ <input type="hidden" name="set[debug_mode]" value=""/>
229
+ <label><input type="checkbox" name="set[debug_mode]" value="1" <?php checked( $gmGallery->options['debug_mode'], '1' ); ?> /> <?php _e( 'Enable Debug Mode on Gmedia admin pages', 'grand-media' ); ?> </label>
230
+ </div>
231
+ </div>
232
+ <?php
233
+ $allowed_post_types = (array) $gmGallery->options['gmedia_post_types_support'];
234
+ $args = [
235
+ 'public' => true,
236
+ 'show_ui' => true,
237
+ '_builtin' => false,
238
+ ];
239
+ $output = 'objects'; // names or objects, note names is the default
240
+ $operator = 'and'; // 'and' or 'or'
241
+ $post_types = get_post_types( $args, $output, $operator );
242
+ if ( ! empty( $post_types ) ) { ?>
243
+ <div class="form-group">
244
+ <label style="margin-bottom:-5px;"><?php _e( 'Enable Gmedia Library button on custom post types', 'grand-media' ) ?>:</label>
245
+ <input type="hidden" name="set[gmedia_post_types_support]" value=""/>
246
+ <?php
247
+ foreach ( $post_types as $post_type ) { ?>
248
+ <div class="checkbox"><label><input type="checkbox" name="set[gmedia_post_types_support][]" value="<?php echo esc_attr( $post_type->name ); ?>" <?php echo in_array( $post_type->name, $allowed_post_types ) ? 'checked="checked"' : ''; ?> /> <?php echo $post_type->label . ' (' . $post_type->name . ')'; ?></label></div>
249
+ <?php } ?>
250
+ </div>
251
+ <?php } ?>
252
  </fieldset>
 
admin/pages/settings/tpl/license.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- // don't load directly
3
- if( !defined('ABSPATH')){
4
- die('-1');
5
  }
6
 
7
  /**
@@ -9,94 +9,94 @@ if( !defined('ABSPATH')){
9
  */
10
  ?>
11
  <fieldset id="gmedia_premium" class="tab-pane active">
12
- <p><?php _e('Enter Gmedia Premium Key to remove backlink label from premium gallery modules and unlock settings below.') ?></p>
13
 
14
- <div class="row">
15
- <div class="form-group col-xs-5">
16
- <label><?php _e('Gmedia Premium Key', 'grand-media') ?>: <?php if(isset($gmGallery->options['license_name'])){
17
- echo '<em>' . $gmGallery->options['license_name'] . '</em>';
18
- } ?></label>
19
- <input type="text" name="set[purchase_key]" id="purchase_key" class="form-control input-sm" value="<?php echo $pk; ?>"/>
20
 
21
- <div class="manual_license_activate"<?php echo(('manual' == $gmCore->_get('license_activate'))? '' : ' style="display:none;"'); ?>>
22
- <label style="margin-top:7px;"><?php _e('License Name', 'grand-media') ?>:</label>
23
- <input type="text" name="set[license_name]" id="license_name" class="form-control input-sm" value="<?php echo $gmGallery->options['license_name']; ?>"/>
24
- <label style="margin-top:7px;"><?php _e('License Key', 'grand-media') ?>:</label>
25
- <input type="text" name="set[license_key]" id="license_key" class="form-control input-sm" value="<?php echo $lk; ?>"/>
26
- <label style="margin-top:7px;"><?php _e('Additional Key', 'grand-media') ?>:</label>
27
- <input type="text" name="set[license_key2]" id="license_key2" class="form-control input-sm" value="<?php echo $gmGallery->options['license_key2']; ?>"/>
28
- </div>
29
- </div>
30
- <?php if( !('manual' == $gmCore->_get('license_activate') || !empty($pk))){ ?>
31
- <div class="form-group col-xs-7">
32
- <label>&nbsp;</label>
33
- <button style="display:block;" class="btn btn-success btn-sm" type="submit" name="license-key-activate"><?php _e('Activate Key', 'grand-media'); ?></button>
34
- </div>
35
- <?php } ?>
36
- </div>
37
- <fieldset <?php echo (empty($gmGallery->options['license_name'])? 'disabled' : ''); ?>>
38
- <hr/>
39
- <div class="form-group">
40
- <label><?php _e('Delete original images', 'grand-media') ?>:</label>
41
- <div class="checkbox" style="margin:0;">
42
- <input type="hidden" name="set[delete_originals]" value="0"/>
43
- <label><input type="checkbox" name="set[delete_originals]" value="1" <?php checked($gmGallery->options['delete_originals'], '1'); ?> /> <?php _e('Do not keep original images on the server', 'grand-media'); ?>
44
- </label>
45
- </div>
46
- <p class="help-block"><?php _e('Warning: You can\'t undo this operation. Checking this option you agree to delete original images. You will not be able: restore images after modification in the Image Editor; re-create web-optimized images; ...', 'grand-media'); ?></p>
47
- </div>
48
 
49
- <div class="form-group">
50
- <label><?php _e('Disable Logs', 'grand-media') ?>:</label>
51
- <div class="checkbox" style="margin:0;">
52
- <input type="hidden" name="set[disable_logs]" value="0"/>
53
- <label><input type="checkbox" name="set[disable_logs]" value="1" <?php checked($gmGallery->options['disable_logs'], '1'); ?> /> <?php _e('Disable Gmedia Logs page', 'grand-media'); ?>
54
- </label>
55
- </div>
56
- </div>
57
 
58
- <hr/>
59
- <div class="form-group">
60
- <label><?php _e('Gmedia Tags & Categories', 'grand-media'); ?></label>
61
- <div class="checkbox" style="margin:0;">
62
- <input type="hidden" name="set[wp_term_related_gmedia]" value="0"/>
63
- <label><input type="checkbox" name="set[wp_term_related_gmedia]" value="1" <?php checked($gmGallery->options['wp_term_related_gmedia'], '1'); ?> /> <?php _e('Show Related Media from Gmedia library for Wordpress native tags & categories', 'grand-media'); ?>
64
- </label>
65
- </div>
66
- <div class="checkbox" style="margin:0;">
67
- <input type="hidden" name="set[wp_post_related_gmedia]" value="0"/>
68
- <label><input type="checkbox" name="set[wp_post_related_gmedia]" value="1" <?php checked($gmGallery->options['wp_post_related_gmedia'], '1'); ?> /> <?php _e('Show Related Media from Gmedia library for Wordpress Posts based on tags', 'grand-media'); ?>
69
- </label>
70
- </div>
71
- </div>
72
 
73
- <hr/>
74
- <div class="form-group">
75
- <label><?php _e('Show "Any Feedback?" in the Sidebar', 'grand-media') ?>:</label>
76
- <div class="checkbox" style="margin:0;">
77
- <input type="hidden" name="set[feedback]" value="0"/>
78
- <label><input type="checkbox" name="set[feedback]" value="1" <?php checked($gmGallery->options['feedback'], '1'); ?> /> <?php _e('Show "Any Feedback?"', 'grand-media'); ?>
79
- </label>
80
- </div>
81
- <p class="help-block"><?php _e('I\'d be very happy if you leave positive feedback about plugin on the WordPress.org Directory. Thank You!', 'grand-media'); ?></p>
82
- </div>
83
- <div class="form-group">
84
- <label><?php _e('Show Twitter News in the Sidebar', 'grand-media') ?>:</label>
85
- <div class="checkbox" style="margin:0;">
86
- <input type="hidden" name="set[twitter]" value="0"/>
87
- <label><input type="checkbox" name="set[twitter]" value="1" <?php checked($gmGallery->options['twitter'], '1'); ?> /> <?php _e('Show Twitter News', 'grand-media'); ?>
88
- </label>
89
- </div>
90
- <p class="help-block"><?php _e('Follow Gmedia on twitter to not miss info about new modules and plugin updates.', 'grand-media'); ?></p>
91
- </div>
92
- <div class="form-group">
93
- <label><?php _e('Hide WoowBox Ad Banner', 'grand-media') ?>:</label>
94
- <div class="checkbox" style="margin:0;">
95
- <input type="hidden" name="set[disable_ads]" value="0"/>
96
- <label><input type="checkbox" name="set[disable_ads]" value="1" <?php checked($gmGallery->options['disable_ads'], '1'); ?> /> <?php _e('Hide WoowBox Banner', 'grand-media'); ?>
97
- </label>
98
- </div>
99
- </div>
100
- </fieldset>
101
 
102
  </fieldset>
1
  <?php
2
+ // don't load directly.
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ die( '-1' );
5
  }
6
 
7
  /**
9
  */
10
  ?>
11
  <fieldset id="gmedia_premium" class="tab-pane active">
12
+ <p><?php _e( 'Enter Gmedia Premium Key to remove backlink label from premium gallery modules and unlock settings below.' ) ?></p>
13
 
14
+ <div class="row">
15
+ <div class="form-group col-xs-5">
16
+ <label><?php _e( 'Gmedia Premium Key', 'grand-media' ) ?>: <?php if ( isset( $gmGallery->options['license_name'] ) ) {
17
+ echo '<em>' . $gmGallery->options['license_name'] . '</em>';
18
+ } ?></label>
19
+ <input type="text" name="set[purchase_key]" id="purchase_key" class="form-control input-sm" value="<?php echo esc_attr( $pk ); ?>"/>
20
 
21
+ <div class="manual_license_activate"<?php echo( ( 'manual' === $gmCore->_get( 'license_activate' ) ) ? '' : ' style="display:none;"' ); ?>>
22
+ <label style="margin-top:7px;"><?php _e( 'License Name', 'grand-media' ) ?>:</label>
23
+ <input type="text" name="set[license_name]" id="license_name" class="form-control input-sm" value="<?php echo esc_attr( $gmGallery->options['license_name'] ); ?>"/>
24
+ <label style="margin-top:7px;"><?php _e( 'License Key', 'grand-media' ) ?>:</label>
25
+ <input type="text" name="set[license_key]" id="license_key" class="form-control input-sm" value="<?php echo esc_attr( $lk ); ?>"/>
26
+ <label style="margin-top:7px;"><?php _e( 'Additional Key', 'grand-media' ) ?>:</label>
27
+ <input type="text" name="set[license_key2]" id="license_key2" class="form-control input-sm" value="<?php echo esc_attr( $gmGallery->options['license_key2'] ); ?>"/>
28
+ </div>
29
+ </div>
30
+ <?php if ( ! ( 'manual' === $gmCore->_get( 'license_activate' ) || ! empty( $pk ) ) ) { ?>
31
+ <div class="form-group col-xs-7">
32
+ <label>&nbsp;</label>
33
+ <button style="display:block;" class="btn btn-success btn-sm" type="submit" name="license-key-activate"><?php _e( 'Activate Key', 'grand-media' ); ?></button>
34
+ </div>
35
+ <?php } ?>
36
+ </div>
37
+ <fieldset <?php echo( empty( $gmGallery->options['license_name'] ) ? 'disabled' : '' ); ?>>
38
+ <hr/>
39
+ <div class="form-group">
40
+ <label><?php _e( 'Delete original images', 'grand-media' ) ?>:</label>
41
+ <div class="checkbox" style="margin:0;">
42
+ <input type="hidden" name="set[delete_originals]" value="0"/>
43
+ <label><input type="checkbox" name="set[delete_originals]" value="1" <?php checked( $gmGallery->options['delete_originals'], '1' ); ?> /> <?php _e( 'Do not keep original images on the server', 'grand-media' ); ?>
44
+ </label>
45
+ </div>
46
+ <p class="help-block"><?php _e( 'Warning: You can\'t undo this operation. Checking this option you agree to delete original images. You will not be able: restore images after modification in the Image Editor; re-create web-optimized images; ...', 'grand-media' ); ?></p>
47
+ </div>
48
 
49
+ <div class="form-group">
50
+ <label><?php _e( 'Disable Logs', 'grand-media' ) ?>:</label>
51
+ <div class="checkbox" style="margin:0;">
52
+ <input type="hidden" name="set[disable_logs]" value="0"/>
53
+ <label><input type="checkbox" name="set[disable_logs]" value="1" <?php checked( $gmGallery->options['disable_logs'], '1' ); ?> /> <?php _e( 'Disable Gmedia Logs page', 'grand-media' ); ?>
54
+ </label>
55
+ </div>
56
+ </div>
57
 
58
+ <hr/>
59
+ <div class="form-group">
60
+ <label><?php _e( 'Gmedia Tags & Categories', 'grand-media' ); ?></label>
61
+ <div class="checkbox" style="margin:0;">
62
+ <input type="hidden" name="set[wp_term_related_gmedia]" value="0"/>
63
+ <label><input type="checkbox" name="set[wp_term_related_gmedia]" value="1" <?php checked( $gmGallery->options['wp_term_related_gmedia'], '1' ); ?> /> <?php _e( 'Show Related Media from Gmedia library for Wordpress native tags & categories', 'grand-media' ); ?>
64
+ </label>
65
+ </div>
66
+ <div class="checkbox" style="margin:0;">
67
+ <input type="hidden" name="set[wp_post_related_gmedia]" value="0"/>
68
+ <label><input type="checkbox" name="set[wp_post_related_gmedia]" value="1" <?php checked( $gmGallery->options['wp_post_related_gmedia'], '1' ); ?> /> <?php _e( 'Show Related Media from Gmedia library for Wordpress Posts based on tags', 'grand-media' ); ?>
69
+ </label>
70
+ </div>
71
+ </div>
72
 
73
+ <hr/>
74
+ <div class="form-group">
75
+ <label><?php _e( 'Show "Any Feedback?" in the Sidebar', 'grand-media' ) ?>:</label>
76
+ <div class="checkbox" style="margin:0;">
77
+ <input type="hidden" name="set[feedback]" value="0"/>
78
+ <label><input type="checkbox" name="set[feedback]" value="1" <?php checked( $gmGallery->options['feedback'], '1' ); ?> /> <?php _e( 'Show "Any Feedback?"', 'grand-media' ); ?>
79
+ </label>
80
+ </div>
81
+ <p class="help-block"><?php _e( 'I\'d be very happy if you leave positive feedback about plugin on the WordPress.org Directory. Thank You!', 'grand-media' ); ?></p>
82
+ </div>
83
+ <div class="form-group">
84
+ <label><?php _e( 'Show Twitter News in the Sidebar', 'grand-media' ) ?>:</label>
85
+ <div class="checkbox" style="margin:0;">
86
+ <input type="hidden" name="set[twitter]" value="0"/>
87
+ <label><input type="checkbox" name="set[twitter]" value="1" <?php checked( $gmGallery->options['twitter'], '1' ); ?> /> <?php _e( 'Show Twitter News', 'grand-media' ); ?>
88
+ </label>
89
+ </div>
90
+ <p class="help-block"><?php _e( 'Follow Gmedia on twitter to not miss info about new modules and plugin updates.', 'grand-media' ); ?></p>
91
+ </div>
92
+ <div class="form-group">
93
+ <label><?php _e( 'Hide WoowGallery Ad Banner', 'grand-media' ) ?>:</label>
94
+ <div class="checkbox" style="margin:0;">
95
+ <input type="hidden" name="set[disable_ads]" value="0"/>
96
+ <label><input type="checkbox" name="set[disable_ads]" value="1" <?php checked( $gmGallery->options['disable_ads'], '1' ); ?> /> <?php _e( 'Hide WoowGallery Banner', 'grand-media' ); ?>
97
+ </label>
98
+ </div>
99
+ </div>
100
+ </fieldset>
101
 
102
  </fieldset>
admin/pages/settings/tpl/permalinks.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- // don't load directly
3
- if(!defined('ABSPATH')) {
4
- die('-1');
5
  }
6
 
7
  /**
@@ -14,110 +14,110 @@ if(!defined('ABSPATH')) {
14
  */
15
  ?>
16
  <fieldset id="gmedia_settings_permalinks" class="tab-pane">
17
- <h4><?php _e('Gmedia Library Items', 'grand-media'); ?></h4>
18
- <div class="form-group">
19
- <label><?php _e('Gmedia Base', 'grand-media') ?>:</label>
20
- <input type="text" name="set[gmedia_post_slug]" value="<?php echo $gmGallery->options['gmedia_post_slug']; ?>" class="form-control input-sm"/>
21
 
22
- <p class="help-block"><?php _e('Base for gmedia post url.', 'grand-media'); ?></p>
23
- </div>
24
- <div class="form-group">
25
- <div class="checkbox" style="margin:0;">
26
- <input type="hidden" name="set[gmedia_has_archive]" value="0"/>
27
- <label><input type="checkbox" name="set[gmedia_has_archive]" value="1" <?php checked($gmGallery->options['gmedia_has_archive'], '1'); ?> /> <?php _e('Allow Gmedia Posts Archive page', 'grand-media'); ?> </label>
28
- </div>
29
- </div>
30
- <div class="form-group">
31
- <div class="checkbox" style="margin:0;">
32
- <input type="hidden" name="set[gmedia_exclude_from_search]" value="0"/>
33
- <label><input type="checkbox" name="set[gmedia_exclude_from_search]" value="1" <?php checked($gmGallery->options['gmedia_exclude_from_search'], '1'); ?> /> <?php _e('Exclude Gmedia Library Items from WordPress search results on the Frontend', 'grand-media'); ?> </label>
34
- </div>
35
- </div>
36
- <div class="form-group">
37
- <label><?php _e('Default comment status for new gmedia items', 'grand-media') ?>:</label>
38
- <select name="set[default_gmedia_comment_status]" class="form-control input-sm">
39
- <option value="open" <?php selected($gmGallery->options['default_gmedia_comment_status'], 'open'); ?>><?php _e('Open', 'grand-media'); ?></option>
40
- <option value="closed" <?php selected($gmGallery->options['default_gmedia_comment_status'], 'closed'); ?>><?php _e('Closed', 'grand-media'); ?></option>
41
- </select>
42
 
43
- <p class="help-block"><?php _e('(These setting may be overridden for individual gmedia items.)', 'grand-media'); ?></p>
44
- </div>
45
 
46
- <hr />
47
- <h4><?php _e('Gmedia Albums', 'grand-media'); ?></h4>
48
- <div class="form-group">
49
- <label><?php _e('Gmedia Album Base', 'grand-media') ?>:</label>
50
- <input type="text" name="set[gmedia_album_post_slug]" value="<?php echo $gmGallery->options['gmedia_album_post_slug']; ?>" class="form-control input-sm"/>
51
 
52
- <p class="help-block"><?php _e('Base for gmedia album post url.', 'grand-media'); ?></p>
53
- </div>
54
- <div class="form-group">
55
- <div class="checkbox" style="margin:0;">
56
- <input type="hidden" name="set[gmedia_album_has_archive]" value="0"/>
57
- <label><input type="checkbox" name="set[gmedia_album_has_archive]" value="1" <?php checked($gmGallery->options['gmedia_album_has_archive'], '1'); ?> /> <?php _e('Allow Gmedia Albums Archive page', 'grand-media'); ?> </label>
58
- </div>
59
- </div>
60
- <div class="form-group">
61
- <div class="checkbox" style="margin:0;">
62
- <input type="hidden" name="set[gmedia_album_exclude_from_search]" value="0"/>
63
- <label><input type="checkbox" name="set[gmedia_album_exclude_from_search]" value="1" <?php checked($gmGallery->options['gmedia_album_exclude_from_search'], '1'); ?> /> <?php _e('Exclude Gmedia Albums from WordPress search results on the Frontend', 'grand-media'); ?> </label>
64
- </div>
65
- </div>
66
 
67
- <hr />
68
- <h4><?php _e('Gmedia Galleries', 'grand-media'); ?></h4>
69
- <div class="form-group">
70
- <label><?php _e('Gmedia Gallery Base', 'grand-media') ?>:</label>
71
- <input type="text" name="set[gmedia_gallery_post_slug]" value="<?php echo $gmGallery->options['gmedia_gallery_post_slug']; ?>" class="form-control input-sm"/>
72
 
73
- <p class="help-block"><?php _e('Base for gmedia gallery post url.', 'grand-media'); ?></p>
74
- </div>
75
- <div class="form-group">
76
- <div class="checkbox" style="margin:0;">
77
- <input type="hidden" name="set[gmedia_gallery_has_archive]" value="0"/>
78
- <label><input type="checkbox" name="set[gmedia_gallery_has_archive]" value="1" <?php checked($gmGallery->options['gmedia_gallery_has_archive'], '1'); ?> /> <?php _e('Allow Gmedia Galleries Archive page', 'grand-media'); ?> </label>
79
- </div>
80
- </div>
81
- <div class="form-group">
82
- <div class="checkbox" style="margin:0;">
83
- <input type="hidden" name="set[gmedia_gallery_exclude_from_search]" value="0"/>
84
- <label><input type="checkbox" name="set[gmedia_gallery_exclude_from_search]" value="1" <?php checked($gmGallery->options['gmedia_gallery_exclude_from_search'], '1'); ?> /> <?php _e('Exclude Gmedia Galleries from WordPress search results on the Frontend', 'grand-media'); ?> </label>
85
- </div>
86
- </div>
87
 
88
  </fieldset>
89
 
90
  <fieldset id="gmedia_settings_cloud" class="tab-pane">
91
- <p><?php _e('GmediaCloud is full window template to show your galleries, albums and other gmedia content', 'grand-media'); ?></p>
92
 
93
- <p><?php _e('Each module can have it\'s own design for GmediaCloud. Here you can set default module wich will be used for sharing Albums, Tags, Categories and single Gmedia Items.', 'grand-media'); ?></p>
94
- <br/>
95
 
96
- <div class="form-group">
97
- <label><?php _e('HashID salt for unique template URL', 'grand-media') ?>:</label>
98
- <input type="text" name="GmediaHashID_salt" value="<?php echo get_option('GmediaHashID_salt'); ?>" class="form-control input-sm"/>
99
 
100
- <p class="help-block"><?php _e('Changing this string you\'ll change Gmedia template URLs.', 'grand-media'); ?></p>
101
- </div>
102
- <div class="form-group">
103
- <label><?php _e('Permalink Endpoint (GmediaCloud base)', 'grand-media') ?>:</label>
104
- <input type="text" name="set[endpoint]" value="<?php echo $gmGallery->options['endpoint']; ?>" class="form-control input-sm"/>
105
 
106
- <p class="help-block"><?php _e('Changing endpoint you\'ll change Gmedia template URLs.', 'grand-media'); ?></p>
107
- </div>
108
- <div class="form-group">
109
- <label><?php _e('Top Bar Social Buttons', 'grand-media'); ?></label>
110
- <select name="set[gmediacloud_socialbuttons]" class="form-control input-sm">
111
- <option value="1" <?php selected($gmGallery->options['gmediacloud_socialbuttons'], '1'); ?>><?php _e('Show Social Buttons', 'grand-media'); ?></option>
112
- <option value="0" <?php selected($gmGallery->options['gmediacloud_socialbuttons'], '0'); ?>><?php _e('Hide Social Buttons', 'grand-media'); ?></option>
113
- </select>
114
- </div>
115
- <div class="form-group">
116
- <label><?php _e('Additional JS code for GmediaCloud Page', 'grand-media') ?>:</label>
117
- <textarea name="set[gmediacloud_footer_js]" rows="4" cols="20" class="form-control input-sm"><?php echo esc_textarea(stripslashes($gmGallery->options['gmediacloud_footer_js'])); ?></textarea>
118
- </div>
119
- <div class="form-group">
120
- <label><?php _e('Additional CSS code for GmediaCloud Page', 'grand-media') ?>:</label>
121
- <textarea name="set[gmediacloud_footer_css]" rows="4" cols="20" class="form-control input-sm"><?php echo esc_textarea(stripslashes($gmGallery->options['gmediacloud_footer_css'])); ?></textarea>
122
- </div>
1
  <?php
2
+ // don't load directly.
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ die( '-1' );
5
  }
6
 
7
  /**
14
  */
15
  ?>
16
  <fieldset id="gmedia_settings_permalinks" class="tab-pane">
17
+ <h4><?php _e( 'Gmedia Library Items', 'grand-media' ); ?></h4>
18
+ <div class="form-group">
19
+ <label><?php _e( 'Gmedia Base', 'grand-media' ) ?>:</label>
20
+ <input type="text" name="set[gmedia_post_slug]" value="<?php echo esc_attr( $gmGallery->options['gmedia_post_slug'] ); ?>" class="form-control input-sm"/>
21
 
22
+ <p class="help-block"><?php _e( 'Base for gmedia post url.', 'grand-media' ); ?></p>
23
+ </div>
24
+ <div class="form-group">
25
+ <div class="checkbox" style="margin:0;">
26
+ <input type="hidden" name="set[gmedia_has_archive]" value="0"/>
27
+ <label><input type="checkbox" name="set[gmedia_has_archive]" value="1" <?php checked( $gmGallery->options['gmedia_has_archive'], '1' ); ?> /> <?php _e( 'Allow Gmedia Posts Archive page', 'grand-media' ); ?> </label>
28
+ </div>
29
+ </div>
30
+ <div class="form-group">
31
+ <div class="checkbox" style="margin:0;">
32
+ <input type="hidden" name="set[gmedia_exclude_from_search]" value="0"/>
33
+ <label><input type="checkbox" name="set[gmedia_exclude_from_search]" value="1" <?php checked( $gmGallery->options['gmedia_exclude_from_search'], '1' ); ?> /> <?php _e( 'Exclude Gmedia Library Items from WordPress search results on the Frontend', 'grand-media' ); ?> </label>
34
+ </div>
35
+ </div>
36
+ <div class="form-group">
37
+ <label><?php _e( 'Default comment status for new gmedia items', 'grand-media' ) ?>:</label>
38
+ <select name="set[default_gmedia_comment_status]" class="form-control input-sm">
39
+ <option value="open" <?php selected( $gmGallery->options['default_gmedia_comment_status'], 'open' ); ?>><?php _e( 'Open', 'grand-media' ); ?></option>
40
+ <option value="closed" <?php selected( $gmGallery->options['default_gmedia_comment_status'], 'closed' ); ?>><?php _e( 'Closed', 'grand-media' ); ?></option>
41
+ </select>
42
 
43
+ <p class="help-block"><?php _e( '(These setting may be overridden for individual gmedia items.)', 'grand-media' ); ?></p>
44
+ </div>
45
 
46
+ <hr/>
47
+ <h4><?php _e( 'Gmedia Albums', 'grand-media' ); ?></h4>
48
+ <div class="form-group">
49
+ <label><?php _e( 'Gmedia Album Base', 'grand-media' ) ?>:</label>
50
+ <input type="text" name="set[gmedia_album_post_slug]" value="<?php echo esc_attr( $gmGallery->options['gmedia_album_post_slug'] ); ?>" class="form-control input-sm"/>
51
 
52
+ <p class="help-block"><?php _e( 'Base for gmedia album post url.', 'grand-media' ); ?></p>
53
+ </div>
54
+ <div class="form-group">
55
+ <div class="checkbox" style="margin:0;">
56
+ <input type="hidden" name="set[gmedia_album_has_archive]" value="0"/>
57
+ <label><input type="checkbox" name="set[gmedia_album_has_archive]" value="1" <?php checked( $gmGallery->options['gmedia_album_has_archive'], '1' ); ?> /> <?php _e( 'Allow Gmedia Albums Archive page', 'grand-media' ); ?> </label>
58
+ </div>
59
+ </div>
60
+ <div class="form-group">
61
+ <div class="checkbox" style="margin:0;">
62
+ <input type="hidden" name="set[gmedia_album_exclude_from_search]" value="0"/>
63
+ <label><input type="checkbox" name="set[gmedia_album_exclude_from_search]" value="1" <?php checked( $gmGallery->options['gmedia_album_exclude_from_search'], '1' ); ?> /> <?php _e( 'Exclude Gmedia Albums from WordPress search results on the Frontend', 'grand-media' ); ?> </label>
64
+ </div>
65
+ </div>
66
 
67
+ <hr/>
68
+ <h4><?php _e( 'Gmedia Galleries', 'grand-media' ); ?></h4>
69
+ <div class="form-group">
70
+ <label><?php _e( 'Gmedia Gallery Base', 'grand-media' ) ?>:</label>
71
+ <input type="text" name="set[gmedia_gallery_post_slug]" value="<?php echo esc_attr( $gmGallery->options['gmedia_gallery_post_slug'] ); ?>" class="form-control input-sm"/>
72
 
73
+ <p class="help-block"><?php _e( 'Base for gmedia gallery post url.', 'grand-media' ); ?></p>
74
+ </div>
75
+ <div class="form-group">
76
+ <div class="checkbox" style="margin:0;">
77
+ <input type="hidden" name="set[gmedia_gallery_has_archive]" value="0"/>
78
+ <label><input type="checkbox" name="set[gmedia_gallery_has_archive]" value="1" <?php checked( $gmGallery->options['gmedia_gallery_has_archive'], '1' ); ?> /> <?php _e( 'Allow Gmedia Galleries Archive page', 'grand-media' ); ?> </label>
79
+ </div>
80
+ </div>
81
+ <div class="form-group">
82
+ <div class="checkbox" style="margin:0;">
83
+ <input type="hidden" name="set[gmedia_gallery_exclude_from_search]" value="0"/>
84
+ <label><input type="checkbox" name="set[gmedia_gallery_exclude_from_search]" value="1" <?php checked( $gmGallery->options['gmedia_gallery_exclude_from_search'], '1' ); ?> /> <?php _e( 'Exclude Gmedia Galleries from WordPress search results on the Frontend', 'grand-media' ); ?> </label>
85
+ </div>
86
+ </div>
87
 
88
  </fieldset>
89
 
90
  <fieldset id="gmedia_settings_cloud" class="tab-pane">
91
+ <p><?php _e( 'GmediaCloud is full window template to show your galleries, albums and other gmedia content', 'grand-media' ); ?></p>
92
 
93
+ <p><?php _e( 'Each module can have it\'s own design for GmediaCloud. Here you can set default module wich will be used for sharing Albums, Tags, Categories and single Gmedia Items.', 'grand-media' ); ?></p>
94
+ <br/>
95
 
96
+ <div class="form-group">
97
+ <label><?php _e( 'HashID salt for unique template URL', 'grand-media' ) ?>:</label>
98
+ <input type="text" name="GmediaHashID_salt" value="<?php echo esc_attr( get_option( 'GmediaHashID_salt' ) ); ?>" class="form-control input-sm"/>
99
 
100
+ <p class="help-block"><?php _e( 'Changing this string you\'ll change Gmedia template URLs.', 'grand-media' ); ?></p>
101
+ </div>
102
+ <div class="form-group">
103
+ <label><?php _e( 'Permalink Endpoint (GmediaCloud base)', 'grand-media' ) ?>:</label>
104
+ <input type="text" name="set[endpoint]" value="<?php echo esc_attr( $gmGallery->options['endpoint'] ); ?>" class="form-control input-sm"/>
105
 
106
+ <p class="help-block"><?php _e( 'Changing endpoint you\'ll change Gmedia template URLs.', 'grand-media' ); ?></p>
107
+ </div>
108
+ <div class="form-group">
109
+ <label><?php _e( 'Top Bar Social Buttons', 'grand-media' ); ?></label>
110
+ <select name="set[gmediacloud_socialbuttons]" class="form-control input-sm">
111
+ <option value="1" <?php selected( $gmGallery->options['gmediacloud_socialbuttons'], '1' ); ?>><?php _e( 'Show Social Buttons', 'grand-media' ); ?></option>
112
+ <option value="0" <?php selected( $gmGallery->options['gmediacloud_socialbuttons'], '0' ); ?>><?php _e( 'Hide Social Buttons', 'grand-media' ); ?></option>
113
+ </select>
114
+ </div>
115
+ <div class="form-group">
116
+ <label><?php _e( 'Additional JS code for GmediaCloud Page', 'grand-media' ) ?>:</label>
117
+ <textarea name="set[gmediacloud_footer_js]" rows="4" cols="20" class="form-control input-sm"><?php echo esc_textarea( stripslashes( $gmGallery->options['gmediacloud_footer_js'] ) ); ?></textarea>
118
+ </div>
119
+ <div class="form-gro