Gmedia Photo Gallery - Version 1.14.7

Version Description

Download this release

Release Info

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

Code changes from version 1.13.4 to 1.14.7

admin/admin.php CHANGED
@@ -4,182 +4,184 @@
4
  * GmediaAdmin - Admin Section for GRAND Media
5
  */
6
  class GmediaAdmin {
7
- var $pages = array();
8
- var $body_classes = array();
9
-
10
- /**
11
- * constructor
12
- */
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_filter('screen_settings', array(&$this, 'screen_settings'), 10, 2);
26
- add_filter('set-screen-option', array(&$this, 'screen_settings_save'), 11, 3);
27
-
28
- if(isset($_GET['page']) && (false !== strpos($_GET['page'], 'GrandMedia'))){
29
- $this->body_classes[] = 'grand-media-admin-page';
30
-
31
- if( !isset($_GET['gmediablank']) || 'library' === $_GET['gmediablank']){
32
- $this->body_classes[] = $_GET['page'];
33
- if( !empty($_GET['mode'])){
34
- $this->body_classes[] = $_GET['page'] . '_' . $_GET['mode'];
35
- }
36
- if(isset($_GET['edit_term']) || isset($_GET['gallery_module']) || isset($_GET['preset'])){
37
- $this->body_classes[] = $_GET['page'] . '_edit';
38
- }
39
- }
40
-
41
- if(('admin.php' == $pagenow) && isset($_GET['gmediablank'])){
42
- add_action('admin_init', array(&$this, 'gmedia_blank_page'));
43
- }
44
-
45
- add_action('admin_footer', array(&$this, 'admin_footer'));
46
- }
47
-
48
- }
49
-
50
- /**
51
- * admin_head
52
- */
53
- function admin_head(){
54
- add_filter('admin_body_class', array(&$this, 'admin_body_class'));
55
-
56
- if(isset($_GET['page']) && (false !== strpos($_GET['page'], 'GrandMedia'))){
57
- ?>
58
- <style type="text/css" id="gmedia_admin_css">html, body { background: <?php echo isset( $_GET['gmediablank'] )? 'transparent' : '#708090'; ?>; }</style>
59
- <?php
60
- }
61
- }
62
-
63
- /**
64
- * admin_body_class
65
- *
66
- * @param $classes_string
67
- *
68
- * @return string
69
- */
70
- function admin_body_class($classes_string){
71
- $classes = $this->body_classes;
72
-
73
- $classes[] = $classes_string;
74
- if(isset($_GET["gmediablank"])){
75
- $classes[] = "gmedia-blank gmedia_{$_GET['gmediablank']}";
76
- }
77
- $classes = array_filter($classes);
78
-
79
- return implode(' ', $classes);
80
- }
81
-
82
- /**
83
- * Load gmedia pages in wpless interface
84
- */
85
- function gmedia_blank_page(){
86
- set_current_screen('GrandMedia_Settings');
87
-
88
- global $gmCore, $gmProcessor;
89
- $gmediablank = $gmCore->_get('gmediablank', '');
90
- define('IFRAME_REQUEST', true);
91
-
92
- iframe_header('GmediaGallery');
93
-
94
- echo '<div id="gmedia-container">';
95
- switch($gmediablank){
96
- case 'update_plugin':
97
- require_once(dirname(dirname(__FILE__)) . '/config/update.php');
98
- gmedia_do_update();
99
- break;
100
- case 'image_editor':
101
- require_once(dirname(dirname(__FILE__)) . '/inc/image-editor.php');
102
- gmedia_image_editor();
103
- break;
104
- case 'map_editor':
105
- require_once(dirname(dirname(__FILE__)) . '/inc/map-editor.php');
106
- gmedia_map_editor();
107
- break;
108
- case 'library':
109
- echo '<div id="gmedia_iframe_content">';
110
- echo '<div id="gm-message">' . $gmCore->alert('success', $gmProcessor->msg) . $gmCore->alert('danger', $gmProcessor->error) . '</div>';
111
- include(GMEDIA_ABSPATH . 'admin/pages/library/library.php');
112
- echo '</div>';
113
- break;
114
- case 'comments':
115
- require_once(dirname(__FILE__) . '/tpl/comments.php');
116
- break;
117
- case 'module_preview':
118
- require_once(dirname(__FILE__) . '/tpl/module-preview.php');
119
- break;
120
- }
121
- echo '</div>';
122
-
123
- iframe_footer();
124
- exit;
125
- }
126
-
127
- // integrate the menu
128
- function add_menu(){
129
-
130
- $count = '';
131
- if(current_user_can('gmedia_module_manage')){
132
- global $gmGallery;
133
- if($gmGallery->options['modules_update']){
134
- $count = " <span class='update-plugins count-{$gmGallery->options['modules_update']}'><span class='plugin-count gm-module-count'>" . $gmGallery->options['modules_update'] . "</span></span>";
135
- }
136
- }
137
-
138
- $gmediaURL = plugins_url(GMEDIA_FOLDER);
139
- $this->pages = array();
140
- $this->pages[] = add_menu_page(__('Gmedia Library', 'grand-media'), "Gmedia{$count}", 'gmedia_library', 'GrandMedia', array(
141
- &$this,
142
- 'shell'
143
- ), 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+CjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSIyMHB4IiBoZWlnaHQ9IjIwcHgiIHZpZXdCb3g9IjAgMCAyMCAyMCIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgMjAgMjAiIHhtbDpzcGFjZT0icHJlc2VydmUiPiAgPGltYWdlIGlkPSJpbWFnZTAiIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgeD0iMCIgeT0iMCIKICAgIHhsaW5rOmhyZWY9ImRhdGE6aW1hZ2UvcG5nO2Jhc2U2NCxpVkJPUncwS0dnb0FBQUFOU1VoRVVnQUFBQlFBQUFBVUNBTUFBQUM2ViswL0FBQUFCR2RCVFVFQUFMR1BDL3hoQlFBQUFDQmpTRkpOCkFBQjZKZ0FBZ0lRQUFQb0FBQUNBNkFBQWRUQUFBT3BnQUFBNm1BQUFGM0NjdWxFOEFBQUJrbEJNVkVVeFpua3haM2d4WjNoQ2RJTnUKbEtBK2NZQnBrSjJRcmJhb3Y4YTV5OUdadEx5UnJyZG1qcHMzYTN4WmhKS0txYktPckxXcndjaW52c1dWc2JxM3l0Q1hzcnRWZ1k5UwpmNDZndWNGN25hZzdibjVFZFlWeGxxS01xclN3eGN1aHVzS2Z1TUMrejlSMm1xWTZibjZ1dzhyNy9QekYxTm0weU03dDh2UHo5dmVGCnBhL2Y1K3BiaHBSSWVJZCtvS3FOcTdTZHQ3OWhpcGN5YUhuSDF0clMzdUZIZDRiSzJOMzUrL3YzK2ZxOXp0UmFoWk5QZll5Qm9xeUMKbzYwOGIzOUdkb1poaTVoT2ZJdnE3L0dwdjhiLy8vLzIrUG45L2YzQjBkWkFjb0tZczd3emFIbSt6OVZxa1oxWGc1SFQzK0xZNHVaNgpuYWh3bGFGRGRJVFAzT0JLZVloTWU0bnc5UFhoNmV2eDlmYkwyZDFUZ0k1em1LTXphWHJUM3VLWXM3dlAyOS9WNE9PY3RyN2c2T3VVCnNMbE5mSXU0eTlEbzd2QkZkb1YzbTZibTdlODViWDNJMXR1RHBLN1EzT0JZaEpHUHJMWEMwdGVsdmNSSmVZamI1ZWpOMnQ1eWw2S1cKc3JyYjVPZUFvYXhqakpuZTUrbDJtcVhFMDlpSHByQnRrNTl5bDZOOG5xazRiSDNXNGVUVTMrUFIzZUdxd01jY1RNSnpBQUFBQW5SUwpUbE51MlhMaTRXRUFBQUFCWWt0SFJFVDV0SmpCQUFBQUNYQklXWE1BQUFzVEFBQUxFd0VBbXB3WUFBQUFCM1JKVFVVSDRBc0NDRGNJCmw0WXhCZ0FBQVIxSlJFRlVHTk5qWUdCa1FnT01ESmhpSUZFNGs1bUZGY2FFQzdLeGMzQnljZlB3SWd2eWNmRUxDQW9KYzRxSThvdEIKQmNVRkpDU2xtS1JsWklYbDVCVVVsVUNDeWlxcWF1b2FtbHJhT3N4TXVucjZCb1pBUVNOakUxTW1Kak56QzBzQkt5WW1hMTBiUHFDZwpyWWFkdllLRG81T3ppNnVidTRlOHA1QVhVTkJiMGNmWHo5OHVJRkNDS1VneE9NUk9DR2hScUdaWU9MTmRSR1JVZ0FFVGsxU0VYMVEwCkUwTk1ySGRjZklKVVlwSzdiRExRMHBUVXRIUW1ob3pNTEgzVGhPd2MzY3pjUExEelRMU1lHUElMbUR3S2k0cExtRXFUSWQ3Z0tHUmkKWUF1elk3SXJpeXV2cUlTSVNWVlZBeTJxQ2ErdERtU3BxMk1KckZkcXlNbjN5MjRFQ25weEp6UWxOUHZGeHBxMDVBWUh4N2Z5SW9VUwpNc0FleU5paUF3Q3FwalN3RnBqcGxnQUFBQ1YwUlZoMFpHRjBaVHBqY21WaGRHVUFNakF4TmkweE1TMHdNbFF3T0RvMU5Ub3dPQzB3Ck56b3dNSWl4dXBvQUFBQWxkRVZZZEdSaGRHVTZiVzlrYVdaNUFESXdNVFl0TVRFdE1ESlVNRGc2TlRVNk1EZ3RNRGM2TURENTdBSW0KQUFBQUFFbEZUa1N1UW1DQyIgLz4KPC9zdmc+Cg==', 11);
144
- $this->pages[] = add_submenu_page('GrandMedia', __('Gmedia Library', 'grand-media'), __('Gmedia Library', 'grand-media'), 'gmedia_library', 'GrandMedia', array(&$this, 'shell'));
145
- if(current_user_can('gmedia_library')){
146
- $this->pages[] = add_submenu_page('GrandMedia', __('Add Media Files', 'grand-media'), __('Add/Import Files', 'grand-media'), 'gmedia_upload', 'GrandMedia_AddMedia', array(&$this, 'shell'));
147
- $this->pages[] = add_submenu_page('GrandMedia', __('Tags', 'grand-media'), __('Tags', 'grand-media'), 'gmedia_tag_manage', 'GrandMedia_Tags', array(&$this, 'shell'));
148
- $this->pages[] = add_submenu_page('GrandMedia', __('Categories', 'grand-media'), __('Categories', 'grand-media'), 'gmedia_category_manage', 'GrandMedia_Categories', array(&$this, 'shell'));
149
- $this->pages[] = add_submenu_page('GrandMedia', __('Albums', 'grand-media'), __('Albums', 'grand-media'), 'gmedia_album_manage', 'GrandMedia_Albums', array(&$this, 'shell'));
150
- $this->pages[] = add_submenu_page('GrandMedia', __('Gmedia Galleries', 'grand-media'), __('Galleries', 'grand-media'), 'gmedia_gallery_manage', 'GrandMedia_Galleries', array(&$this, 'shell'));
151
- $this->pages[] = add_submenu_page('GrandMedia', __('Modules', 'grand-media'), __('Modules', 'grand-media'), 'gmedia_gallery_manage', 'GrandMedia_Modules', array(&$this, 'shell'));
152
- $this->pages[] = add_submenu_page('GrandMedia', __('Gmedia Settings', 'grand-media'), __('Settings', 'grand-media'), 'manage_options', 'GrandMedia_Settings', array(&$this, 'shell'));
153
- $this->pages[] = add_submenu_page('GrandMedia', __('iOS Application', 'grand-media'), __('iOS Application', 'grand-media'), 'gmedia_settings', 'GrandMedia_App', array(&$this, 'shell'));
154
- $this->pages[] = add_submenu_page('GrandMedia', __('Wordpress Media Library', 'grand-media'), __('WP Media Library', 'grand-media'), 'gmedia_import', 'GrandMedia_WordpressLibrary', array(&$this, 'shell'));
155
- $this->pages[] = add_submenu_page('GrandMedia', __('Gmedia Logs', 'grand-media'), __('Gmedia Logs', 'grand-media'), 'manage_options', 'GrandMedia_Logs', array(&$this, 'shell'));
156
- $this->pages[] = add_submenu_page('GrandMedia', __('Gmedia Support', 'grand-media'), __('Support', 'grand-media'), 'manage_options', 'GrandMedia_Support', array(&$this, 'shell'));
157
- }
158
-
159
- foreach($this->pages as $page){
160
- add_action("load-$page", array(&$this, 'screen_help'));
161
- }
162
- }
163
-
164
- /**
165
- * Load the script for the defined page and load only this code
166
- * Display shell of plugin
167
- */
168
- function shell(){
169
- global $gmCore, $gmProcessor, $gmGallery;
170
-
171
- $sideLinks = $this->sideLinks();
172
-
173
- // check for upgrade
174
- if(get_option('gmediaDbVersion') != GMEDIA_DBVERSION){
175
- if(get_transient('gmediaUpgrade') || (isset($_GET['do_update']) && ('gmedia' == $_GET['do_update']))){
176
- $sideLinks['grandTitle'] = __('Updating GmediaGallery Plugin', 'grand-media');
177
- $sideLinks['sideLinks'] = '';
178
- $gmProcessor->page = 'GrandMedia_Update';
179
- } else{
180
- return;
181
- }
182
- }
 
 
183
 
184
  // global $wpdb;
185
  // $query = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}gmedia_term");
@@ -189,784 +191,936 @@ class GmediaAdmin {
189
  // }
190
  // echo '<pre>' . print_r($query, true) . '</pre>';
191
 
192
- ?>
193
- <div id="gmedia-container" class="gmedia-admin">
194
- <?php
195
- if($gmProcessor->page !== 'GrandMedia_App' && !isset($gmGallery->options['gmedia_service']) && current_user_can('manage_options')){
196
- $this->collect_data_permission();
197
- }
198
- ?>
199
- <div id="gmedia-header" class="clearfix">
200
- <div id="gmedia-logo">Gmedia
201
- <small> by CodEasily.com</small>
202
- </div>
203
- <h2><?php echo $sideLinks['grandTitle']; ?></h2>
204
- <?php
205
- if ( ! is_plugin_active( 'woowbox/woowbox.php' ) ){
206
- ?>
207
- <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>
208
- <?php
209
- }
210
- ?>
211
- </div>
212
- <div class="container-fluid">
213
- <div class="row row-fx180-fl">
214
- <div class="col-sm-2 hidden-xs" id="sidebar" role="navigation">
215
- <?php echo $sideLinks['sideLinks']; ?>
216
-
217
- <?php
218
- if((int) $gmGallery->options['feedback']){
219
- $installDate = get_option('gmediaInstallDate');
220
- if($installDate && (strtotime($installDate) < strtotime('2 weeks ago'))){ ?>
221
- <div class="row panel panel-default visible-lg-block">
222
- <div class="panel-heading" data-toggle="collapse" data-target="#support_div_collapse" aria-expanded="true" aria-controls="support_div_collapse" style="cursor:pointer;">
223
- <b><?php _e('Any feedback?', 'grand-media'); ?></b>
224
- </div>
225
- <div class="collapse<?php if(empty($gmGallery->options['license_key'])){
226
- echo ' in';
227
- } ?>" id="support_div_collapse">
228
- <div class="panel-body">
229
- <p><?php _e('You can help me spread the word about GmediaGallery among the users striving to get awesome galleries on their WordPress sites.', 'grand-media'); ?></p>
230
-
231
- <p>
232
- <a class="btn btn-primary" href="https://wordpress.org/support/view/plugin-reviews/grand-media?filter=5" target="_blank"><?php _e('Rate Gmedia Gallery', 'grand-media'); ?></a>
233
- </p>
234
-
235
- <p><?php _e('Your reviews and ideas helps me to create new awesome modules and to improve plugin.', 'grand-media'); ?></p>
236
- </div>
237
- </div>
238
- </div>
239
- <?php }
240
- }
241
- if((int) $gmGallery->options['twitter']){
242
- ?>
243
- <div class="row panel visible-lg-block">
244
- <a class="twitter-timeline" href="https://twitter.com/CodEasily/timelines/648240437141086212" data-widget-id="648245214201692161"></a>
245
- <script>!function(d, s, id){
246
- var js, fjs = d.getElementsByTagName(s)[0],
247
- p = /^http:/.test(d.location)? 'http' : 'https';
248
- if(!d.getElementById(id)){
249
- js = d.createElement(s);
250
- js.id = id;
251
- js.src = p + "://platform.twitter.com/widgets.js";
252
- fjs.parentNode.insertBefore(js, fjs);
253
- }
254
- }(document, "script", "twitter-wjs");</script>
255
- </div>
256
- <?php
257
- } ?>
258
- </div>
259
- <div class="col-sm-10 col-xs-12">
260
- <div id="gm-message"><?php
261
- echo $gmCore->alert('success', $gmProcessor->msg);
262
- echo $gmCore->alert('danger', $gmProcessor->error);
263
- ?></div>
264
 
265
- <?php $this->controller(); ?>
266
 
267
- </div>
268
- </div>
269
- </div>
270
- </div>
271
- <?php
272
- }
273
-
274
- function sideLinks(){
275
- global $submenu, $gmProcessor, $gmGallery;
276
- $content['sideLinks'] = '
277
  <div id="gmedia-navbar">
278
  <div class="row">
279
  <ul class="list-group"><li>';
280
- if(empty($gmGallery->options['license_key'])){
281
- $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>';
282
- }
283
- foreach($submenu['GrandMedia'] as $menuKey => $menuItem){
284
- if($menuItem[2] == $gmProcessor->page){
285
- $iscur = ' active';
286
- $content['grandTitle'] = $menuItem[3];
287
- } else{
288
- $iscur = '';
289
- }
290
- $menuData = '';
291
- if($menuItem[2] == 'GrandMedia_Modules' && gm_user_can('module_manage')){
292
- if($gmGallery->options['modules_update']){
293
- $menuData = '<span class="badge badge-error pull-right gm-module-count" title="' . __('Module Updates') . '">' . $gmGallery->options['modules_update'] . '</span>';
294
- }
295
- }
296
-
297
- $content['sideLinks'] .= "\n" . '<a class="list-group-item' . $iscur . '" href="' . admin_url('admin.php?page=' . $menuItem[2]) . '">' . $menuItem[0] . $menuData . '</a>';
298
- }
299
- $content['sideLinks'] .= '
300
  </li></ul>
301
  </div>
302
  </div>';
303
 
304
- return $content;
305
- }
306
-
307
- function collect_data_permission(){
308
- $current_user = wp_get_current_user();
309
- $nonce = wp_create_nonce('GmediaService');
310
- ?>
311
- <div class="notice updated gm-message gmedia-service__message">
312
- <div class="gm-message-content">
313
- <div class="gm-plugin-icon">
314
- <img src="<?php echo plugins_url('/grand-media/admin/assets/img/icon-128x128.png') ?>" width="90" height="90">
315
- </div>
316
- <?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>.
317
  These data also required if you will use Gmedia iOS application on your iPhone.
318
- If you skip this, that\'s okay! <b>Gmedia Gallery</b> will still work just fine.</p>', 'grand-media'), $current_user->display_name ); ?>
319
- </div>
320
- <div class="gm-message-actions">
321
- <button class="button button-secondary gm_service_action" data-action="skip" data-nonce="<?php echo $nonce; ?>"><?php _e('Skip', 'grand-media'); ?></button>
322
- <button class="button button-primary gm_service_action" data-action="allow" data-nonce="<?php echo $nonce; ?>"><?php _e('Allow &amp; Continue', 'grand-media'); ?></button>
323
- </div>
324
- <div class="gm-message-plus gm-closed">
325
- <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>
326
- <ul>
327
- <li>
328
- <i class="dashicons dashicons-admin-users"></i>
329
-
330
- <div>
331
- <span><?php _e('Your Profile Overview', 'grand-media'); ?></span>
332
-
333
- <p><?php _e('Name and email address', 'grand-media'); ?></p>
334
- </div>
335
- </li>
336
- <li>
337
- <i class="dashicons dashicons-admin-settings"></i>
338
 
339
- <div>
340
- <span><?php _e('Your Site Overview', 'grand-media'); ?></span>
341
 
342
- <p><?php _e('Site URL, WP version, PHP version, active theme &amp; plugins', 'grand-media'); ?></p>
343
- </div>
344
- </li>
345
- </ul>
346
- </div>
347
- </div>
348
- <?php
349
- }
350
-
351
- function admin_footer(){
352
- $ajax_operations = get_option('gmedia_ajax_long_operations');
353
- if( empty($ajax_operations) || !is_array($ajax_operations)){
354
- return;
355
- }
356
- reset($ajax_operations);
357
- $ajax = key($ajax_operations);
358
- if(empty($ajax)){
359
- delete_option('gmedia_ajax_long_operations');
360
- return;
361
- }
362
- $nonce = wp_create_nonce('gmedia_ajax_long_operations');
363
- ?>
364
- <script type="text/javascript">
365
- jQuery(document).ready(function($){
366
- var header = $('#gmedia-header');
367
- 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>');
368
- gmAjaxLongOperation = function(){
369
- jQuery.post(ajaxurl, {action: '<?php echo $ajax; ?>', _wpnonce_ajax_long_operations: '<?php echo $nonce; ?>'}, function(r){
370
- if(r.data){
371
- jQuery('.progress-bar-info', header).width(r.data.progress);
372
- var indicator = r.data.info? r.data.info + ' ' + r.data.progress : r.data.progress;
373
- jQuery('.progress-bar-indicator', header).html(indicator);
374
-
375
- if(r.data.done){
376
- return;
377
- }
378
- }
379
- gmAjaxLongOperation();
380
- });
 
 
 
 
 
 
 
381
  }
382
  gmAjaxLongOperation();
383
- });
384
- </script>
385
- <?php
386
- }
387
-
388
- function controller(){
389
-
390
- global $gmProcessor;
391
- switch($gmProcessor->page){
392
- case 'GrandMedia_AddMedia':
393
- include_once(dirname(__FILE__) . '/pages/addmedia/addmedia.php');
394
- break;
395
- case 'GrandMedia_Albums':
396
- if(isset($_GET['edit_term'])){
397
- include_once(dirname(__FILE__) . '/pages/terms/edit-term.php');
398
- } else{
399
- include_once(dirname(__FILE__) . '/pages/terms/terms.php');
400
- }
401
- break;
402
- case 'GrandMedia_Categories':
403
- if(isset($_GET['edit_term'])){
404
- include_once(dirname(__FILE__) . '/pages/terms/edit-term.php');
405
- } else{
406
- include_once(dirname(__FILE__) . '/pages/terms/terms.php');
407
- }
408
- break;
409
- case 'GrandMedia_Tags':
410
- include_once(dirname(__FILE__) . '/pages/terms/terms.php');
411
- break;
412
- case 'GrandMedia_Galleries':
413
- if(isset($_GET['gallery_module']) || isset($_GET['edit_term'])){
414
- include_once(dirname(__FILE__) . '/pages/galleries/edit-gallery.php');
415
- } else{
416
- include_once(dirname(__FILE__) . '/pages/galleries/galleries.php');
417
- }
418
- break;
419
- case 'GrandMedia_Modules':
420
- if(isset($_GET['preset_module']) || isset($_GET['preset'])){
421
- include_once(dirname(__FILE__) . '/pages/modules/edit-preset.php');
422
- } else{
423
- include_once(dirname(__FILE__) . '/pages/modules/modules.php');
424
- }
425
- break;
426
- case 'GrandMedia_Settings':
427
- include_once(dirname(__FILE__) . '/pages/settings/settings.php');
428
- break;
429
- case 'GrandMedia_App':
430
- include_once(dirname(__FILE__) . '/app.php');
431
- gmediaApp();
432
- break;
433
- case 'GrandMedia_WordpressLibrary':
434
- include_once(dirname(__FILE__) . '/wpmedia.php');
435
- grandWPMedia();
436
- break;
437
- case 'GrandMedia_Logs':
438
- include_once(dirname(__FILE__) . '/logs.php');
439
- break;
440
- case 'GrandMedia_Support':
441
- include_once(dirname(__FILE__) . '/support.php');
442
- gmediaSupport();
443
- break;
444
- case 'GrandMedia_Update':
445
- include_once(GMEDIA_ABSPATH . 'config/update.php');
446
- gmedia_upgrade_progress_panel();
447
- break;
448
- case 'GrandMedia':
449
- include_once(dirname(__FILE__) . '/pages/library/library.php');
450
- break;
451
- default:
452
- do_action('gmedia_admin_page-' . $gmProcessor->page);
453
- break;
454
- }
455
- }
456
-
457
- /**
458
- * @param $hook
459
- */
460
- function load_scripts($hook){
461
- global $gmCore, $gmProcessor, $gmGallery;
462
- // no need to go on if it's not a plugin page
463
- if('admin.php' != $hook && strpos($gmCore->_get('page'), 'GrandMedia') === false){
464
- return;
465
- }
466
-
467
- if($gmGallery->options['isolation_mode']){
468
- global $wp_scripts, $wp_styles;
469
- foreach($wp_scripts->registered as $handle => $wp_script){
470
- if(((false !== strpos($wp_script->src, '/plugins/')) || (false !== strpos($wp_script->src, '/themes/'))) && (false === strpos($wp_script->src, GMEDIA_FOLDER))){
471
- if(in_array($handle, $wp_scripts->queue)){
472
- wp_dequeue_script($handle);
473
- }
474
- wp_deregister_script($handle);
475
- }
476
- }
477
- foreach($wp_styles->registered as $handle => $wp_style){
478
- if(((false !== strpos($wp_style->src, '/plugins/')) || (false !== strpos($wp_style->src, '/themes/'))) && (false === strpos($wp_style->src, GMEDIA_FOLDER))){
479
- if(in_array($handle, $wp_styles->queue)){
480
- wp_dequeue_style($handle);
481
- }
482
- wp_deregister_style($handle);
483
- }
484
- }
485
- }
486
-
487
- wp_enqueue_style('gmedia-bootstrap');
488
- wp_enqueue_script('gmedia-bootstrap');
489
-
490
- wp_register_script('selectize', $gmCore->gmedia_url . '/assets/selectize/selectize.min.js', array('jquery'), '0.12.1');
491
- wp_register_style('selectize', $gmCore->gmedia_url . '/assets/selectize/selectize.bootstrap3.css', array('gmedia-bootstrap'), '0.12.1', 'screen');
492
-
493
- wp_register_style('spectrum', $gmCore->gmedia_url . '/assets/spectrum/spectrum.min.css', array(), '1.8.0');
494
- wp_register_script('spectrum', $gmCore->gmedia_url . '/assets/spectrum/spectrum.min.js', array('jquery'), '1.8.0', true);
495
-
496
- if(isset($_GET['page'])){
497
- switch($_GET['page']){
498
- case "GrandMedia" :
499
- if($gmCore->caps['gmedia_edit_media']){
500
- if($gmCore->_get('gmediablank') == 'image_editor'){
501
- wp_enqueue_script('camanjs', $gmCore->gmedia_url . '/assets/image-editor/camanjs/caman.full.min.js', array(), '4.1.2');
502
-
503
- wp_enqueue_style('nouislider', $gmCore->gmedia_url . '/assets/image-editor/js/jquery.nouislider.css', array('gmedia-bootstrap'), '6.1.0');
504
- wp_enqueue_script('nouislider', $gmCore->gmedia_url . '/assets/image-editor/js/jquery.nouislider.min.js', array('jquery'), '6.1.0');
505
-
506
- wp_enqueue_style('gmedia-image-editor', $gmCore->gmedia_url . '/assets/image-editor/style.css', array('gmedia-bootstrap'), '0.9.16', 'screen');
507
- wp_enqueue_script('gmedia-image-editor', $gmCore->gmedia_url . '/assets/image-editor/image-editor.js', array('jquery', 'camanjs'), '0.9.16');
508
- break;
509
- }
510
- if($gmProcessor->mode == 'edit'){
511
- wp_enqueue_script('alphanum', $gmCore->gmedia_url . '/assets/jq-plugins/jquery.alphanum.js', array('jquery'), '1.0.16');
512
-
513
- wp_enqueue_script('jquery-ui-sortable');
514
-
515
- wp_enqueue_script('moment', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/moment.min.js', array('jquery'), '2.22.2');
516
- wp_enqueue_style('datetimepicker', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css', array('gmedia-bootstrap'), '4.17.47');
517
- wp_enqueue_script('datetimepicker', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js', array(
518
- 'jquery',
519
- 'moment',
520
- 'gmedia-bootstrap'
521
- ), '4.17.47');
522
- }
523
- }
524
- wp_enqueue_script('wavesurfer', $gmCore->gmedia_url . '/assets/wavesurfer/wavesurfer.min.js', array('jquery'), '1.1.5');
525
- break;
526
- case "GrandMedia_WordpressLibrary" :
527
- break;
528
- case "GrandMedia_Albums" :
529
- if(isset($_GET['edit_term'])){
530
- if($gmCore->caps['gmedia_album_manage']){
531
- 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');
532
- wp_enqueue_script('jquery-ui-full', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js', array(), '1.10.2');
533
- }
534
-
535
- wp_enqueue_script('moment', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/moment.min.js', array('jquery'), '2.5.1');
536
- wp_enqueue_style('datetimepicker', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css', array('gmedia-bootstrap'), '2.1.32');
537
- wp_enqueue_script('datetimepicker', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js', array(
538
- 'jquery',
539
- 'moment',
540
- 'gmedia-bootstrap'
541
- ), '2.1.32');
542
- }
543
- break;
544
- case "GrandMedia_Categories" :
545
- break;
546
- case "GrandMedia_AddMedia" :
547
- if($gmCore->caps['gmedia_upload']){
548
- $tab = $gmCore->_get('tab', 'upload');
549
- if($tab == 'upload'){
550
- 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');
551
- wp_enqueue_script('jquery-ui-full', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js', array(), '1.10.2');
552
-
553
- wp_enqueue_script('gmedia-plupload', $gmCore->gmedia_url . '/assets/plupload/plupload.full.min.js', array('jquery', 'jquery-ui-full'), '2.1.2');
554
-
555
- 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');
556
- wp_enqueue_script('jquery.ui.plupload', $gmCore->gmedia_url . '/assets/plupload/jquery.ui.plupload/jquery.ui.plupload.min.js', array(
557
- 'gmedia-plupload',
558
- 'jquery-ui-full'
559
- ), '2.1.2');
560
-
561
- }
562
- }
563
- break;
564
- case "GrandMedia_Settings" :
565
- case "GrandMedia_App" :
566
- // under construction
567
- break;
568
- case "GrandMedia_Galleries" :
569
- if($gmCore->caps['gmedia_gallery_manage'] && (isset($_GET['gallery_module']) || isset($_GET['edit_term']))){
570
-
571
- 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');
572
- wp_enqueue_script('jquery-ui-resizable');
573
-
574
- wp_enqueue_script('jquery-ui-sortable');
575
-
576
- wp_enqueue_style('jquery.minicolors', $gmCore->gmedia_url . '/assets/minicolors/jquery.minicolors.css', array('gmedia-bootstrap'), '0.9.13');
577
- wp_enqueue_script('jquery.minicolors', $gmCore->gmedia_url . '/assets/minicolors/jquery.minicolors.js', array('jquery'), '0.9.13');
578
-
579
- wp_enqueue_style('spectrum');
580
- wp_enqueue_script('spectrum');
581
- }
582
- break;
583
- case "GrandMedia_Modules" :
584
- if(isset($_GET['preset_module']) || isset($_GET['preset'])){
585
-
586
- 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');
587
- wp_enqueue_script('jquery-ui-resizable');
588
-
589
- wp_enqueue_script('jquery-ui-sortable');
590
-
591
- wp_enqueue_style('jquery.minicolors', $gmCore->gmedia_url . '/assets/minicolors/jquery.minicolors.css', array('gmedia-bootstrap'), '0.9.13');
592
- wp_enqueue_script('jquery.minicolors', $gmCore->gmedia_url . '/assets/minicolors/jquery.minicolors.js', array('jquery'), '0.9.13');
593
-
594
- wp_enqueue_style('spectrum');
595
- wp_enqueue_script('spectrum');
596
- }
597
- break;
598
- }
599
- }
600
- wp_enqueue_style('selectize');
601
- wp_enqueue_script('selectize');
602
-
603
- wp_enqueue_style('grand-media');
604
- wp_enqueue_script('grand-media');
605
-
606
- }
607
-
608
- function gmedia_widget_scripts(){
609
-
610
- }
611
-
612
- function screen_help(){
613
- $screen = get_current_screen();
614
- $screen_id = explode('page_', $screen->id, 2);
615
- $screen_id = $screen_id[1];
616
-
617
- $screen->add_help_tab(array(
618
- 'id' => 'help_' . $screen_id . '_support',
619
- 'title' => __('Support'),
620
- 'content' => __('<h4>First steps</h4>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
621
  <p>If you have any problems with displaying Gmedia Gallery in admin or on website. Before posting to the Forum try next:</p>
622
  <ul>
623
  <li>Exclude plugin conflicts: Disable other plugins one by one and check if it resolve problem</li>
624
  <li>Exclude theme conflict: Temporary switch to one of default themes and check if gallery works</li>
625
  </ul>
626
- <h4>Links</h4>', 'grand-media')
627
- . '<p><a href="https://codeasily.com/community/forum/gmedia-gallery-wordpress-plugin/" target="_blank">' . __('Support Forum', 'grand-media') . '</a>
628
- | <a href="https://codeasily.com/contact/" target="_blank">' . __('Contact', 'grand-media') . '</a>
629
- | <a href="https://codeasily.com/portfolio/gmedia-gallery-modules/" target="_blank">' . __('Demo', 'grand-media') . '</a>
630
- | <a href="https://codeasily.com/product/one-site-license/" target="_blank">' . __('Premium', 'grand-media') . '</a>
631
  </p>',
632
- ));
633
-
634
- switch($screen_id){
635
- case 'GrandMedia' :
636
- break;
637
- case 'GrandMedia_Settings' :
638
- if(current_user_can('manage_options')){
639
- $screen->add_help_tab(array(
640
- 'id' => 'help_' . $screen_id . '_license',
641
- 'title' => __('License Key'),
642
- 'content' => sprintf(__('<h4>Should I buy it, to use plugin?</h4>
643
  <p>No, plugin is absolutely free and all modules for it are free to install.</p>
644
  <p>Even premium modules are fully functional and free to test, but have backlink labels. To remove baclink labels from premium modules you need license key.</p>
645
  <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>
646
  <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>
647
  <h4>I have license key but I can\'t activate it</h4>
648
- <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')
649
- . '<div><a class="btn btn-default" href="' . admin_url('admin.php?page=' . $screen_id . '&license_activate=manual') . '">' . __('Manual Activation', 'grand-media') . '</a></div>',
650
- ));
651
- }
652
- break;
653
- case 'GrandMedia_App' :
654
- $gm_options = get_option('gmediaOptions');
655
- $nonce = wp_create_nonce('GmediaService');
656
- if(current_user_can('manage_options') && (int)$gm_options['mobile_app']){
657
- $screen->add_help_tab(array(
658
- 'id' => 'help_' . $screen_id . '_optout',
659
- 'title' => __('Opt Out'),
660
- 'content' => __('<h4>We appreciate your help in making the plugin better by letting us track some usage data.</h4>
661
  <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>
662
  <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>
663
- <p>You\'ll also not be able to use Gmedia iOS application.</p>', 'grand-media')
664
- . '<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>'
665
- . '<div style="display:none;">Test:
666
  <button type="button" data-action="app_updateinfo" data-nonce="' . $nonce . '" class="btn btn-sm btn-primary gm_service_action">Update</button>
667
  <button type="button" data-action="app_updatecron" data-nonce="' . $nonce . '" class="btn btn-sm btn-primary gm_service_action">CronJob</button> &nbsp;&nbsp;
668
  <button type="button" data-action="app_deactivateplugin" data-nonce="' . $nonce . '" class="btn btn-sm btn-primary gm_service_action">Deactivate Plugin</button>
669
  <button type="button" data-action="app_uninstallplugin" data-nonce="' . $nonce . '" class="btn btn-sm btn-primary gm_service_action">Uninstall Plugin</button>
670
  </div>
671
  ',
672
- ));
673
- }
674
- break;
675
- }
676
- }
677
-
678
- /**
679
- * @param $current
680
- * @param $screen
681
- *
682
- * @return string
683
- */
684
- function screen_settings($current, $screen){
685
- global $gmProcessor, $gmCore;
686
- if(in_array($screen->id, $this->pages)){
687
-
688
- $gm_screen_options = $gmProcessor->user_options;
689
-
690
- $title = '<h5><strong>' . __('Settings', 'grand-media') . '</strong></h5>';
691
- $wp_screen_options = '<input type="hidden" name="wp_screen_options[option]" value="gm_screen_options" /><input type="hidden" name="wp_screen_options[value]" value="' . $screen->id . '" />';
692
- $button = get_submit_button(__('Apply', 'grand-media'), 'button', 'screen-options-apply', false);
693
-
694
- $settings = false;
695
-
696
- $screen_id = explode('page_', $screen->id, 2);
697
-
698
- switch($screen_id[1]){
699
- case 'GrandMedia' :
700
- $settings = '
701
  <div class="form-inline pull-left">
702
  <div class="form-group">
703
- <input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_gmedia]" class="form-control input-sm" style="width: 5em;" value="' . $gm_screen_options['per_page_gmedia'] . '" /> <span>' . __('items per page', 'grand-media') . '</span>
704
  </div>
705
  <div class="form-group">
706
  <select name="gm_screen_options[orderby_gmedia]" class="form-control input-sm">
707
- <option' . selected($gm_screen_options['orderby_gmedia'], 'ID', false) . ' value="ID">' . __('ID', 'grand-media') . '</option>
708
- <option' . selected($gm_screen_options['orderby_gmedia'], 'title', false) . ' value="title">' . __('Title', 'grand-media') . '</option>
709
- <option' . selected($gm_screen_options['orderby_gmedia'], 'gmuid', false) . ' value="gmuid">' . __('Filename', 'grand-media') . '</option>
710
- <option' . selected($gm_screen_options['orderby_gmedia'], 'mime_type', false) . ' value="mime_type">' . __('MIME Type', 'grand-media') . '</option>
711
- <option' . selected($gm_screen_options['orderby_gmedia'], 'author', false) . ' value="author">' . __('Author', 'grand-media') . '</option>
712
- <option' . selected($gm_screen_options['orderby_gmedia'], 'date', false) . ' value="date">' . __('Date', 'grand-media') . '</option>
713
- <option' . selected($gm_screen_options['orderby_gmedia'], 'modified', false) . ' value="modified">' . __('Last Modified', 'grand-media') . '</option>
714
- <option' . selected($gm_screen_options['orderby_gmedia'], '_created_timestamp', false) . ' value="_created_timestamp">' . __('Created Timestamp', 'grand-media') . '</option>
715
- <option' . selected($gm_screen_options['orderby_gmedia'], 'comment_count', false) . ' value="comment_count">' . __('Comment Count', 'grand-media') . '</option>
716
- <option' . selected($gm_screen_options['orderby_gmedia'], 'views', false) . ' value="views">' . __('Views Count', 'grand-media') . '</option>
717
- <option' . selected($gm_screen_options['orderby_gmedia'], 'likes', false) . ' value="likes">' . __('Likes Count', 'grand-media') . '</option>
718
- <option' . selected($gm_screen_options['orderby_gmedia'], '_size', false) . ' value="_size">' . __('File Size', 'grand-media') . '</option>
719
- </select> <span>' . __('order items', 'grand-media') . '</span>
720
  </div>
721
  <div class="form-group">
722
  <select name="gm_screen_options[sortorder_gmedia]" class="form-control input-sm">
723
- <option' . selected($gm_screen_options['sortorder_gmedia'], 'DESC', false) . ' value="DESC">' . __('DESC', 'grand-media') . '</option>
724
- <option' . selected($gm_screen_options['sortorder_gmedia'], 'ASC', false) . ' value="ASC">' . __('ASC', 'grand-media') . '</option>
725
- </select> <span>' . __('sort order', 'grand-media') . '</span>
726
  </div>
727
  ';
728
- if('edit' == $gmCore->_get('mode')){
729
- $settings .= '
730
  <div class="form-group">
731
  <select name="gm_screen_options[library_edit_quicktags]" class="form-control input-sm">
732
- <option' . selected($gm_screen_options['library_edit_quicktags'], 'false', false) . ' value="false">' . __('FALSE', 'grand-media') . '</option>
733
- <option' . selected($gm_screen_options['library_edit_quicktags'], 'true', false) . ' value="true">' . __('TRUE', 'grand-media') . '</option>
734
- </select> <span>' . __('Quick Tags panel for Description field', 'grand-media') . '</span>
735
  </div>
736
  ';
737
- }
738
- $settings .= '
739
  </div>
740
  ';
741
- break;
742
- case 'GrandMedia_AddMedia' :
743
- $tab = $gmCore->_get('tab', 'upload');
744
- if('upload' == $tab){
745
- $html4_hide = ('html4' == $gm_screen_options['uploader_runtime'])? ' hide' : '';
746
- $settings = '
747
  <div class="form-inline pull-left">
748
- <div id="uploader_runtime" class="form-group"><span>' . __('Uploader runtime:', 'grand-media') . ' </span>
749
  <select name="gm_screen_options[uploader_runtime]" class="form-control input-sm">
750
- <option' . selected($gm_screen_options['uploader_runtime'], 'auto', false) . ' value="auto">' . __('Auto', 'grand-media') . '</option>
751
- <option' . selected($gm_screen_options['uploader_runtime'], 'html5', false) . ' value="html5">' . __('HTML5 Uploader', 'grand-media') . '</option>
752
- <option' . selected($gm_screen_options['uploader_runtime'], 'flash', false) . ' value="flash">' . __('Flash Uploader', 'grand-media') . '</option>
753
- <option' . selected($gm_screen_options['uploader_runtime'], 'html4', false) . ' value="html4">' . __('HTML4 Uploader', 'grand-media') . '</option>
754
  </select>
755
  </div>
756
- <div id="uploader_chunking" class="form-group' . $html4_hide . '"><span>' . __('Chunking:', 'grand-media') . ' </span>
757
  <select name="gm_screen_options[uploader_chunking]" class="form-control input-sm">
758
- <option' . selected($gm_screen_options['uploader_chunking'], 'true', false) . ' value="true">' . __('TRUE', 'grand-media') . '</option>
759
- <option' . selected($gm_screen_options['uploader_chunking'], 'false', false) . ' value="false">' . __('FALSE', 'grand-media') . '</option>
760
  </select>
761
  </div>
762
- <div id="uploader_urlstream_upload" class="form-group' . $html4_hide . '"><span>' . __('URL streem upload:', 'grand-media') . ' </span>
763
  <select name="gm_screen_options[uploader_urlstream_upload]" class="form-control input-sm">
764
- <option' . selected($gm_screen_options['uploader_urlstream_upload'], 'true', false) . ' value="true">' . __('TRUE', 'grand-media') . '</option>
765
- <option' . selected($gm_screen_options['uploader_urlstream_upload'], 'false', false) . ' value="false">' . __('FALSE', 'grand-media') . '</option>
766
  </select>
767
  </div>
768
  </div>
769
  ';
770
- }
771
- break;
772
- case 'GrandMedia_Albums' :
773
- if(isset($_GET['edit_term'])){
774
- $settings = '
775
  <div class="form-inline pull-left">
776
  <div class="form-group">
777
- <input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_gmedia_album_edit]" class="form-control input-sm" style="width: 5em;" value="' . $gm_screen_options['per_page_gmedia_album_edit'] . '" /> <span>' . __('items per page', 'grand-media') . '</span>
778
  </div>
779
  </div>
780
  ';
781
- } else{
782
- $settings = '
783
  <div class="form-inline pull-left">
784
  <div class="form-group">
785
- <input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_gmedia_album]" class="form-control input-sm" style="width: 5em;" value="' . $gm_screen_options['per_page_gmedia_album'] . '" /> <span>' . __('items per page', 'grand-media') . '</span>
786
  </div>
787
  <div class="form-group">
788
  <select name="gm_screen_options[orderby_gmedia_album]" class="form-control input-sm">
789
- <option' . selected($gm_screen_options['orderby_gmedia_album'], 'id', false) . ' value="id">' . __('ID', 'grand-media') . '</option>
790
- <option' . selected($gm_screen_options['orderby_gmedia_album'], 'name', false) . ' value="name">' . __('Name', 'grand-media') . '</option>
791
- <option' . selected($gm_screen_options['orderby_gmedia_album'], 'count', false) . ' value="count">' . __('Gmedia Count', 'grand-media') . '</option>
792
- <option' . selected($gm_screen_options['orderby_gmedia_album'], 'global', false) . ' value="global">' . __('Author ID', 'grand-media') . '</option>
793
- </select> <span>' . __('order items', 'grand-media') . '</span>
794
  </div>
795
  <div class="form-group">
796
  <select name="gm_screen_options[sortorder_gmedia_album]" class="form-control input-sm">
797
- <option' . selected($gm_screen_options['sortorder_gmedia_album'], 'DESC', false) . ' value="DESC">' . __('DESC', 'grand-media') . '</option>
798
- <option' . selected($gm_screen_options['sortorder_gmedia_album'], 'ASC', false) . ' value="ASC">' . __('ASC', 'grand-media') . '</option>
799
- </select> <span>' . __('sort order', 'grand-media') . '</span>
800
  </div>
801
  </div>
802
  ';
803
- }
804
- break;
805
- case 'GrandMedia_Categories' :
806
- if(isset($_GET['edit_term'])){
807
- $settings = '
808
  <div class="form-inline pull-left">
809
  <div class="form-group">
810
- <input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_gmedia_category_edit]" class="form-control input-sm" style="width: 5em;" value="' . $gm_screen_options['per_page_gmedia_category_edit'] . '" /> <span>' . __('items per page', 'grand-media') . '</span>
811
  </div>
812
  </div>
813
  ';
814
- } else{
815
- $settings = '
816
  <div class="form-inline pull-left">
817
  <div class="form-group">
818
- <input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_gmedia_category]" class="form-control input-sm" style="width: 5em;" value="' . $gm_screen_options['per_page_gmedia_category'] . '" /> <span>' . __('items per page', 'grand-media') . '</span>
819
  </div>
820
  <div class="form-group">
821
  <select name="gm_screen_options[orderby_gmedia_category]" class="form-control input-sm">
822
- <option' . selected($gm_screen_options['orderby_gmedia_category'], 'id', false) . ' value="id">' . __('ID', 'grand-media') . '</option>
823
- <option' . selected($gm_screen_options['orderby_gmedia_category'], 'name', false) . ' value="name">' . __('Name', 'grand-media') . '</option>
824
- <option' . selected($gm_screen_options['orderby_gmedia_category'], 'count', false) . ' value="count">' . __('Gmedia Count', 'grand-media') . '</option>
825
- </select> <span>' . __('order items', 'grand-media') . '</span>
826
  </div>
827
  <div class="form-group">
828
  <select name="gm_screen_options[sortorder_gmedia_category]" class="form-control input-sm">
829
- <option' . selected($gm_screen_options['sortorder_gmedia_category'], 'DESC', false) . ' value="DESC">' . __('DESC', 'grand-media') . '</option>
830
- <option' . selected($gm_screen_options['sortorder_gmedia_category'], 'ASC', false) . ' value="ASC">' . __('ASC', 'grand-media') . '</option>
831
- </select> <span>' . __('sort order', 'grand-media') . '</span>
832
  </div>
833
  </div>
834
  ';
835
- }
836
- break;
837
- case 'GrandMedia_Tags' :
838
- $settings = '
839
  <div class="form-inline pull-left">
840
  <div class="form-group">
841
- <input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_gmedia_tag]" class="form-control input-sm" style="width: 5em;" value="' . $gm_screen_options['per_page_gmedia_tag'] . '" /> <span>' . __('items per page', 'grand-media') . '</span>
842
  </div>
843
  <div class="form-group">
844
  <select name="gm_screen_options[orderby_gmedia_tag]" class="form-control input-sm">
845
- <option' . selected($gm_screen_options['orderby_gmedia_tag'], 'id', false) . ' value="id">' . __('ID', 'grand-media') . '</option>
846
- <option' . selected($gm_screen_options['orderby_gmedia_tag'], 'name', false) . ' value="name">' . __('Name', 'grand-media') . '</option>
847
- <option' . selected($gm_screen_options['orderby_gmedia_tag'], 'count', false) . ' value="count">' . __('Gmedia Count', 'grand-media') . '</option>
848
- </select> <span>' . __('order items', 'grand-media') . '</span>
849
  </div>
850
  <div class="form-group">
851
  <select name="gm_screen_options[sortorder_gmedia_tag]" class="form-control input-sm">
852
- <option' . selected($gm_screen_options['sortorder_gmedia_tag'], 'DESC', false) . ' value="DESC">' . __('DESC', 'grand-media') . '</option>
853
- <option' . selected($gm_screen_options['sortorder_gmedia_tag'], 'ASC', false) . ' value="ASC">' . __('ASC', 'grand-media') . '</option>
854
- </select> <span>' . __('sort order', 'grand-media') . '</span>
855
  </div>
856
  </div>
857
  ';
858
- break;
859
- case 'GrandMedia_Galleries' :
860
- if( !$gmCore->_get('edit_term') && !$gmCore->_get('gallery_module')){
861
- $settings = '
862
  <div class="form-inline pull-left">
863
  <div class="form-group">
864
- <input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_gmedia_gallery]" class="form-control input-sm" style="width: 5em;" value="' . $gm_screen_options['per_page_gmedia_gallery'] . '" /> <span>' . __('items per page', 'grand-media') . '</span>
865
  </div>
866
  <div class="form-group">
867
  <select name="gm_screen_options[orderby_gmedia_gallery]" class="form-control input-sm">
868
- <option' . selected($gm_screen_options['orderby_gmedia_gallery'], 'id', false) . ' value="id">' . __('ID', 'grand-media') . '</option>
869
- <option' . selected($gm_screen_options['orderby_gmedia_gallery'], 'name', false) . ' value="name">' . __('Name', 'grand-media') . '</option>
870
- <option' . selected($gm_screen_options['orderby_gmedia_gallery'], 'global', false) . ' value="global">' . __('Author ID', 'grand-media') . '</option>
871
- </select> <span>' . __('order items', 'grand-media') . '</span>
872
  </div>
873
  <div class="form-group">
874
  <select name="gm_screen_options[sortorder_gmedia_gallery]" class="form-control input-sm">
875
- <option' . selected($gm_screen_options['sortorder_gmedia_gallery'], 'DESC', false) . ' value="DESC">' . __('DESC', 'grand-media') . '</option>
876
- <option' . selected($gm_screen_options['sortorder_gmedia_gallery'], 'ASC', false) . ' value="ASC">' . __('ASC', 'grand-media') . '</option>
877
- </select> <span>' . __('sort order', 'grand-media') . '</span>
878
  </div>
879
  </div>
880
  ';
881
- }
882
- break;
883
- case 'GrandMedia_WordpressLibrary' :
884
- $settings = '<p>' . __('Set query options for this page to be loaded by default.', 'grand-media') . '</p>
885
  <div class="form-inline pull-left">
886
  <div class="form-group">
887
- <input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_wpmedia]" class="form-control input-sm" style="width: 5em;" value="' . $gm_screen_options['per_page_wpmedia'] . '" /> <span>' . __('items per page', 'grand-media') . '</span>
888
  </div>
889
  <div class="form-group">
890
  <select name="gm_screen_options[orderby_wpmedia]" class="form-control input-sm">
891
- <option' . selected($gm_screen_options['orderby_wpmedia'], 'ID', false) . ' value="ID">' . __('ID', 'grand-media') . '</option>
892
- <option' . selected($gm_screen_options['orderby_wpmedia'], 'title', false) . ' value="title">' . __('Title', 'grand-media') . '</option>
893
- <option' . selected($gm_screen_options['orderby_wpmedia'], 'filename', false) . ' value="filename">' . __('Filename', 'grand-media') . '</option>
894
- <option' . selected($gm_screen_options['orderby_wpmedia'], 'date', false) . ' value="date">' . __('Date', 'grand-media') . '</option>
895
- <option' . selected($gm_screen_options['orderby_wpmedia'], 'modified', false) . ' value="modified">' . __('Last Modified', 'grand-media') . '</option>
896
- <option' . selected($gm_screen_options['orderby_wpmedia'], 'mime_type', false) . ' value="mime_type">' . __('MIME Type', 'grand-media') . '</option>
897
- <option' . selected($gm_screen_options['orderby_wpmedia'], 'author', false) . ' value="author">' . __('Author', 'grand-media') . '</option>
898
- </select> <span>' . __('order items', 'grand-media') . '</span>
899
  </div>
900
  <div class="form-group">
901
  <select name="gm_screen_options[sortorder_wpmedia]" class="form-control input-sm">
902
- <option' . selected($gm_screen_options['sortorder_wpmedia'], 'DESC', false) . ' value="DESC">' . __('DESC', 'grand-media') . '</option>
903
- <option' . selected($gm_screen_options['sortorder_wpmedia'], 'ASC', false) . ' value="ASC">' . __('ASC', 'grand-media') . '</option>
904
- </select> <span>' . __('sort order', 'grand-media') . '</span>
905
  </div>
906
  </div>
907
  ';
908
- break;
909
- case 'GrandMedia_Logs' :
910
- $settings = '
911
  <div class="form-inline pull-left">
912
  <div class="form-group">
913
- <input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_gmedia_log]" class="form-control input-sm" style="width: 5em;" value="' . $gm_screen_options['per_page_gmedia_log'] . '" /> <span>' . __('items per page', 'grand-media') . '</span>
914
  </div>
915
  <div class="form-group">
916
  <select name="gm_screen_options[orderby_gmedia_log]" class="form-control input-sm">
917
- <option' . selected($gm_screen_options['orderby_gmedia_log'], 'log_date', false) . ' value="log_date">' . __('Date', 'grand-media') . '</option>
918
- <option' . selected($gm_screen_options['orderby_gmedia_log'], 'ID', false) . ' value="ID">' . __('Gmedia ID', 'grand-media') . '</option>
919
- <option' . selected($gm_screen_options['orderby_gmedia_log'], 'author', false) . ' value="author">' . __('Author ID', 'grand-media') . '</option>
920
- </select> <span>' . __('order items', 'grand-media') . '</span>
921
  </div>
922
  <div class="form-group">
923
  <select name="gm_screen_options[sortorder_gmedia_log]" class="form-control input-sm">
924
- <option' . selected($gm_screen_options['sortorder_gmedia_log'], 'DESC', false) . ' value="DESC">' . __('DESC', 'grand-media') . '</option>
925
- <option' . selected($gm_screen_options['sortorder_gmedia_log'], 'ASC', false) . ' value="ASC">' . __('ASC', 'grand-media') . '</option>
926
- </select> <span>' . __('sort order', 'grand-media') . '</span>
927
  </div>
928
  </div>
929
  ';
930
- break;
931
- }
932
-
933
- if($settings){
934
- $current = $title . $settings . $wp_screen_options . $button;
935
- }
936
-
937
- }
938
-
939
- return $current;
940
- }
941
-
942
- /**
943
- * @param $status
944
- * @param $option
945
- * @param $value
946
- *
947
- * @return array
948
- */
949
- function screen_settings_save($status, $option, $value){
950
- global $user_ID;
951
- if('gm_screen_options' == $option){
952
- /*
953
- global $gmGallery;
954
- foreach ( $_POST['gm_screen_options'] as $key => $val ) {
955
- $gmGallery->options['gm_screen_options'][$key] = $val;
956
- }
957
- update_option( 'gmediaOptions', $gmGallery->options );
958
- */
959
- $gm_screen_options = get_user_meta($user_ID, 'gm_screen_options', true);
960
- if( !is_array($gm_screen_options)){
961
- $gm_screen_options = array();
962
- }
963
- $value = array_merge($gm_screen_options, $_POST['gm_screen_options']);
964
-
965
- return $value;
966
- }
967
-
968
- return $status;
969
- }
970
 
971
  }
972
 
4
  * GmediaAdmin - Admin Section for GRAND Media
5
  */
6
  class GmediaAdmin {
7
+ var $pages = array();
8
+ var $body_classes = array();
9
+
10
+ /**
11
+ * constructor
12
+ */
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';
32
+
33
+ if ( ! isset( $_GET['gmediablank'] ) || 'library' === $_GET['gmediablank'] ) {
34
+ $this->body_classes[] = $_GET['page'];
35
+ if ( ! empty( $_GET['mode'] ) ) {
36
+ $this->body_classes[] = $_GET['page'] . '_' . $_GET['mode'];
37
+ }
38
+ if ( isset( $_GET['edit_term'] ) || isset( $_GET['gallery_module'] ) || isset( $_GET['preset'] ) ) {
39
+ $this->body_classes[] = $_GET['page'] . '_edit';
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
+ }
51
+
52
+ /**
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
+ ?>
60
+ <style type="text/css" id="gmedia_admin_css">html, body { background: <?php echo isset( $_GET['gmediablank'] )? 'transparent' : '#708090'; ?>; }</style>
61
+ <?php
62
+ }
63
+ }
64
+
65
+ /**
66
+ * admin_body_class
67
+ *
68
+ * @param $classes_string
69
+ *
70
+ * @return string
71
+ */
72
+ function admin_body_class( $classes_string ) {
73
+ $classes = $this->body_classes;
74
+
75
+ $classes[] = $classes_string;
76
+ if ( isset( $_GET["gmediablank"] ) ) {
77
+ $classes[] = "gmedia-blank gmedia_{$_GET['gmediablank']}";
78
+ }
79
+ $classes = array_filter( $classes );
80
+
81
+ return implode( ' ', $classes );
82
+ }
83
+
84
+ /**
85
+ * Load gmedia pages in wpless interface
86
+ */
87
+ function gmedia_blank_page() {
88
+ set_current_screen( 'GrandMedia_Settings' );
89
+
90
+ global $gmCore, $gmProcessor;
91
+ $gmediablank = $gmCore->_get( 'gmediablank', '' );
92
+ define( 'IFRAME_REQUEST', true );
93
+
94
+ iframe_header( 'GmediaGallery' );
95
+
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>';
124
+
125
+ iframe_footer();
126
+ exit;
127
+ }
128
+
129
+ // integrate the menu
130
+ function add_menu() {
131
+
132
+ $count = '';
133
+ if ( current_user_can( 'gmedia_module_manage' ) ) {
134
+ global $gmGallery;
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
+ $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>";
138
+ }
139
+ }
140
+
141
+ $this->pages = array();
142
+ $this->pages[] = add_menu_page( __( 'Gmedia Library', 'grand-media' ), "Gmedia{$count}", 'gmedia_library', 'GrandMedia', array(
143
+ &$this,
144
+ 'shell',
145
+ ), 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+CjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSIyMHB4IiBoZWlnaHQ9IjIwcHgiIHZpZXdCb3g9IjAgMCAyMCAyMCIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgMjAgMjAiIHhtbDpzcGFjZT0icHJlc2VydmUiPiAgPGltYWdlIGlkPSJpbWFnZTAiIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgeD0iMCIgeT0iMCIKICAgIHhsaW5rOmhyZWY9ImRhdGE6aW1hZ2UvcG5nO2Jhc2U2NCxpVkJPUncwS0dnb0FBQUFOU1VoRVVnQUFBQlFBQUFBVUNBTUFBQUM2ViswL0FBQUFCR2RCVFVFQUFMR1BDL3hoQlFBQUFDQmpTRkpOCkFBQjZKZ0FBZ0lRQUFQb0FBQUNBNkFBQWRUQUFBT3BnQUFBNm1BQUFGM0NjdWxFOEFBQUJrbEJNVkVVeFpua3haM2d4WjNoQ2RJTnUKbEtBK2NZQnBrSjJRcmJhb3Y4YTV5OUdadEx5UnJyZG1qcHMzYTN4WmhKS0txYktPckxXcndjaW52c1dWc2JxM3l0Q1hzcnRWZ1k5UwpmNDZndWNGN25hZzdibjVFZFlWeGxxS01xclN3eGN1aHVzS2Z1TUMrejlSMm1xWTZibjZ1dzhyNy9QekYxTm0weU03dDh2UHo5dmVGCnBhL2Y1K3BiaHBSSWVJZCtvS3FOcTdTZHQ3OWhpcGN5YUhuSDF0clMzdUZIZDRiSzJOMzUrL3YzK2ZxOXp0UmFoWk5QZll5Qm9xeUMKbzYwOGIzOUdkb1poaTVoT2ZJdnE3L0dwdjhiLy8vLzIrUG45L2YzQjBkWkFjb0tZczd3emFIbSt6OVZxa1oxWGc1SFQzK0xZNHVaNgpuYWh3bGFGRGRJVFAzT0JLZVloTWU0bnc5UFhoNmV2eDlmYkwyZDFUZ0k1em1LTXphWHJUM3VLWXM3dlAyOS9WNE9PY3RyN2c2T3VVCnNMbE5mSXU0eTlEbzd2QkZkb1YzbTZibTdlODViWDNJMXR1RHBLN1EzT0JZaEpHUHJMWEMwdGVsdmNSSmVZamI1ZWpOMnQ1eWw2S1cKc3JyYjVPZUFvYXhqakpuZTUrbDJtcVhFMDlpSHByQnRrNTl5bDZOOG5xazRiSDNXNGVUVTMrUFIzZUdxd01jY1RNSnpBQUFBQW5SUwpUbE51MlhMaTRXRUFBQUFCWWt0SFJFVDV0SmpCQUFBQUNYQklXWE1BQUFzVEFBQUxFd0VBbXB3WUFBQUFCM1JKVFVVSDRBc0NDRGNJCmw0WXhCZ0FBQVIxSlJFRlVHTk5qWUdCa1FnT01ESmhpSUZFNGs1bUZGY2FFQzdLeGMzQnljZlB3SWd2eWNmRUxDQW9KYzRxSThvdEIKQmNVRkpDU2xtS1JsWklYbDVCVVVsVUNDeWlxcWF1b2FtbHJhT3N4TXVucjZCb1pBUVNOakUxTW1Kak56QzBzQkt5WW1hMTBiUHFDZwpyWWFkdllLRG81T3ppNnVidTRlOHA1QVhVTkJiMGNmWHo5OHVJRkNDS1VneE9NUk9DR2hScUdaWU9MTmRSR1JVZ0FFVGsxU0VYMVEwCkUwTk1ySGRjZklKVVlwSzdiRExRMHBUVXRIUW1ob3pNTEgzVGhPd2MzY3pjUExEelRMU1lHUElMbUR3S2k0cExtRXFUSWQ3Z0tHUmkKWUF1elk3SXJpeXV2cUlTSVNWVlZBeTJxQ2ErdERtU3BxMk1KckZkcXlNbjN5MjRFQ25weEp6UWxOUHZGeHBxMDVBWUh4N2Z5SW9VUwpNc0FleU5paUF3Q3FwalN3RnBqcGxnQUFBQ1YwUlZoMFpHRjBaVHBqY21WaGRHVUFNakF4TmkweE1TMHdNbFF3T0RvMU5Ub3dPQzB3Ck56b3dNSWl4dXBvQUFBQWxkRVZZZEdSaGRHVTZiVzlrYVdaNUFESXdNVFl0TVRFdE1ESlVNRGc2TlRVNk1EZ3RNRGM2TURENTdBSW0KQUFBQUFFbEZUa1N1UW1DQyIgLz4KPC9zdmc+Cg==', 11 );
146
+ $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Gmedia Library', 'grand-media' ), __( 'Gmedia Library', 'grand-media' ), 'gmedia_library', 'GrandMedia', array( &$this, 'shell' ) );
147
+ if ( current_user_can( 'gmedia_library' ) ) {
148
+ $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Add Media Files', 'grand-media' ), __( 'Add/Import Files', 'grand-media' ), 'gmedia_upload', 'GrandMedia_AddMedia', array( &$this, 'shell' ) );
149
+ $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Tags', 'grand-media' ), __( 'Tags', 'grand-media' ), 'gmedia_tag_manage', 'GrandMedia_Tags', array( &$this, 'shell' ) );
150
+ $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Categories', 'grand-media' ), __( 'Categories', 'grand-media' ), 'gmedia_category_manage', 'GrandMedia_Categories', array( &$this, 'shell' ) );
151
+ $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Albums', 'grand-media' ), __( 'Albums', 'grand-media' ), 'gmedia_album_manage', 'GrandMedia_Albums', array( &$this, 'shell' ) );
152
+ $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Gmedia Galleries', 'grand-media' ), __( 'Galleries', 'grand-media' ), 'gmedia_gallery_manage', 'GrandMedia_Galleries', array( &$this, 'shell' ) );
153
+ $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Modules', 'grand-media' ), __( 'Modules', 'grand-media' ), 'gmedia_gallery_manage', 'GrandMedia_Modules', array( &$this, 'shell' ) );
154
+ $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Gmedia Settings', 'grand-media' ), __( 'Settings', 'grand-media' ), 'manage_options', 'GrandMedia_Settings', array( &$this, 'shell' ) );
155
+ $this->pages[] = add_submenu_page( 'GrandMedia', __( 'iOS Application', 'grand-media' ), __( 'iOS Application', 'grand-media' ), 'gmedia_settings', 'GrandMedia_App', array( &$this, 'shell' ) );
156
+ $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Wordpress Media Library', 'grand-media' ), __( 'WP Media Library', 'grand-media' ), 'gmedia_import', 'GrandMedia_WordpressLibrary', array( &$this, 'shell' ) );
157
+ $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Gmedia Logs', 'grand-media' ), __( 'Gmedia Logs', 'grand-media' ), 'manage_options', 'GrandMedia_Logs', array( &$this, 'shell' ) );
158
+ $this->pages[] = add_submenu_page( 'GrandMedia', __( 'Gmedia Support', 'grand-media' ), __( 'Support', 'grand-media' ), 'manage_options', 'GrandMedia_Support', array( &$this, 'shell' ) );
159
+ }
160
+
161
+ foreach ( $this->pages as $page ) {
162
+ add_action( "load-$page", array( &$this, 'screen_help' ) );
163
+ }
164
+ }
165
+
166
+ /**
167
+ * Load the script for the defined page and load only this code
168
+ * Display shell of plugin
169
+ */
170
+ function shell() {
171
+ global $gmCore, $gmProcessor, $gmGallery;
172
+
173
+ $sideLinks = $this->sideLinks();
174
+
175
+ // check for upgrade
176
+ if ( get_option( 'gmediaDbVersion' ) != GMEDIA_DBVERSION ) {
177
+ if ( get_transient( 'gmediaUpgrade' ) || ( isset( $_GET['do_update'] ) && ( 'gmedia' == $_GET['do_update'] ) ) ) {
178
+ $sideLinks['grandTitle'] = __( 'Updating GmediaGallery Plugin', 'grand-media' );
179
+ $sideLinks['sideLinks'] = '';
180
+ $gmProcessor->page = 'GrandMedia_Update';
181
+ } else {
182
+ return;
183
+ }
184
+ }
185
 
186
  // global $wpdb;
187
  // $query = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}gmedia_term");
191
  // }
192
  // echo '<pre>' . print_r($query, true) . '</pre>';
193
 
194
+ ?>
195
+ <div id="gmedia-container" class="gmedia-admin">
196
+ <?php
197
+ if ( $gmProcessor->page !== 'GrandMedia_App' && ! isset( $gmGallery->options['gmedia_service'] ) && current_user_can( 'manage_options' ) ) {
198
+ $this->collect_data_permission();
199
+ }
200
+ ?>
201
+ <div id="gmedia-header" class="clearfix">
202
+ <div id="gmedia-logo">Gmedia
203
+ <small> by CodEasily.com</small>
204
+ </div>
205
+ <h2><?php echo $sideLinks['grandTitle']; ?></h2>
206
+ <?php
207
+ if ( ! is_plugin_active( 'woowbox/woowbox.php' ) && empty( $gmGallery->options['disable_ads'] ) ) {
208
+ ?>
209
+ <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>
210
+ <?php
211
+ }
212
+ ?>
213
+ </div>
214
+ <div class="container-fluid">
215
+ <div class="row row-fx180-fl">
216
+ <div class="col-sm-2 hidden-xs" id="sidebar" role="navigation">
217
+ <?php echo $sideLinks['sideLinks']; ?>
218
+
219
+ <?php
220
+ if ( (int) $gmGallery->options['feedback'] ) {
221
+ $installDate = get_option( 'gmediaInstallDate' );
222
+ if ( $installDate && ( strtotime( $installDate ) < strtotime( '2 weeks ago' ) ) ) { ?>
223
+ <div class="row panel panel-default visible-lg-block">
224
+ <div class="panel-heading" data-toggle="collapse" data-target="#support_div_collapse" aria-expanded="true" aria-controls="support_div_collapse" style="cursor:pointer;">
225
+ <b><?php _e( 'Any feedback?', 'grand-media' ); ?></b>
226
+ </div>
227
+ <div class="collapse<?php if ( empty( $gmGallery->options['license_key'] ) ) {
228
+ echo ' in';
229
+ } ?>" id="support_div_collapse">
230
+ <div class="panel-body">
231
+ <p><?php _e( 'You can help me spread the word about GmediaGallery among the users striving to get awesome galleries on their WordPress sites.', 'grand-media' ); ?></p>
232
+
233
+ <p>
234
+ <a class="btn btn-primary" href="https://wordpress.org/support/view/plugin-reviews/grand-media?filter=5" target="_blank"><?php _e( 'Rate Gmedia Gallery', 'grand-media' ); ?></a>
235
+ </p>
236
+
237
+ <p><?php _e( 'Your reviews and ideas helps me to create new awesome modules and to improve plugin.', 'grand-media' ); ?></p>
238
+ </div>
239
+ </div>
240
+ </div>
241
+ <?php }
242
+ }
243
+ if ( (int) $gmGallery->options['twitter'] ) {
244
+ ?>
245
+ <div class="row panel visible-lg-block">
246
+ <a class="twitter-timeline" href="https://twitter.com/CodEasily/timelines/648240437141086212?ref_src=twsrc%5Etfw">#GmediaGallery - Curated tweets by CodEasily</a>
247
+ <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
248
+ </div>
249
+ <?php
250
+ } ?>
251
+ </div>
252
+ <div class="col-sm-10 col-xs-12">
253
+ <div id="gm-message"><?php
254
+ echo $gmCore->alert( 'success', $gmProcessor->msg );
255
+ echo $gmCore->alert( 'danger', $gmProcessor->error );
256
+ ?></div>
 
 
 
 
 
 
 
 
 
257
 
258
+ <?php $this->controller(); ?>
259
 
260
+ </div>
261
+ </div>
262
+ </div>
263
+ </div>
264
+ <?php
265
+ }
266
+
267
+ function sideLinks() {
268
+ global $submenu, $gmProcessor, $gmGallery;
269
+ $content['sideLinks'] = '
270
  <div id="gmedia-navbar">
271
  <div class="row">
272
  <ul class="list-group"><li>';
273
+ if ( empty( $gmGallery->options['license_key'] ) ) {
274
+ $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>';
275
+ }
276
+ foreach ( $submenu['GrandMedia'] as $menuKey => $menuItem ) {
277
+ if ( $menuItem[2] == $gmProcessor->page ) {
278
+ $iscur = ' active';
279
+ $content['grandTitle'] = $menuItem[3];
280
+ } else {
281
+ $iscur = '';
282
+ }
283
+ $menuData = '';
284
+ if ( $menuItem[2] == 'GrandMedia_Modules' && gm_user_can( 'module_manage' ) ) {
285
+ $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>';
286
+ $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>';
287
+ }
288
+
289
+ $content['sideLinks'] .= "\n" . '<a class="list-group-item' . $iscur . '" href="' . admin_url( 'admin.php?page=' . $menuItem[2] ) . '">' . $menuItem[0] . $menuData . '</a>';
290
+ }
291
+ $content['sideLinks'] .= '
 
292
  </li></ul>
293
  </div>
294
  </div>';
295
 
296
+ return $content;
297
+ }
298
+
299
+ function collect_data_permission() {
300
+ $current_user = wp_get_current_user();
301
+ $nonce = wp_create_nonce( 'GmediaService' );
302
+ ?>
303
+ <div class="notice updated gm-message gmedia-service__message">
304
+ <div class="gm-message-content">
305
+ <div class="gm-plugin-icon">
306
+ <img src="<?php echo plugins_url( '/grand-media/admin/assets/img/icon-128x128.png' ) ?>" width="90" height="90">
307
+ </div>
308
+ <?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>.
309
  These data also required if you will use Gmedia iOS application on your iPhone.
310
+ If you skip this, that\'s okay! <b>Gmedia Gallery</b> will still work just fine.</p>', 'grand-media' ), $current_user->display_name ); ?>
311
+ </div>
312
+ <div class="gm-message-actions">
313
+ <button class="button button-secondary gm_service_action" data-action="skip" data-nonce="<?php echo $nonce; ?>"><?php _e( 'Skip', 'grand-media' ); ?></button>
314
+ <button class="button button-primary gm_service_action" data-action="allow" data-nonce="<?php echo $nonce; ?>"><?php _e( 'Allow &amp; Continue', 'grand-media' ); ?></button>
315
+ </div>
316
+ <div class="gm-message-plus gm-closed">
317
+ <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>
318
+ <ul>
319
+ <li>
320
+ <i class="dashicons dashicons-admin-users"></i>
 
 
 
 
 
 
 
 
 
321
 
322
+ <div>
323
+ <span><?php _e( 'Your Profile Overview', 'grand-media' ); ?></span>
324
 
325
+ <p><?php _e( 'Name and email address', 'grand-media' ); ?></p>
326
+ </div>
327
+ </li>
328
+ <li>
329
+ <i class="dashicons dashicons-admin-settings"></i>
330
+
331
+ <div>
332
+ <span><?php _e( 'Your Site Overview', 'grand-media' ); ?></span>
333
+
334
+ <p><?php _e( 'Site URL, WP version, PHP version, active theme &amp; plugins', 'grand-media' ); ?></p>
335
+ </div>
336
+ </li>
337
+ </ul>
338
+ </div>
339
+ </div>
340
+ <?php
341
+ }
342
+
343
+ function admin_footer() {
344
+ $ajax_operations = get_option( 'gmedia_ajax_long_operations' );
345
+ if ( empty( $ajax_operations ) || ! is_array( $ajax_operations ) ) {
346
+ return;
347
+ }
348
+ reset( $ajax_operations );
349
+ $ajax = key( $ajax_operations );
350
+ if ( empty( $ajax ) ) {
351
+ delete_option( 'gmedia_ajax_long_operations' );
352
+
353
+ return;
354
+ }
355
+ $nonce = wp_create_nonce( 'gmedia_ajax_long_operations' );
356
+ ?>
357
+ <script type="text/javascript">
358
+ jQuery(document).ready(function($) {
359
+ var header = $('#gmedia-header');
360
+ 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>');
361
+ gmAjaxLongOperation = function() {
362
+ jQuery.post(ajaxurl, {action: '<?php echo $ajax; ?>', _wpnonce_ajax_long_operations: '<?php echo $nonce; ?>'}, function(r) {
363
+ if(r.data) {
364
+ jQuery('.progress-bar-info', header).width(r.data.progress);
365
+ var indicator = r.data.info ? r.data.info + ' ' + r.data.progress : r.data.progress;
366
+ jQuery('.progress-bar-indicator', header).html(indicator);
367
+
368
+ if(r.data.done) {
369
+ return;
370
+ }
371
  }
372
  gmAjaxLongOperation();
373
+ });
374
+ };
375
+ gmAjaxLongOperation();
376
+ });
377
+ </script>
378
+ <?php
379
+ }
380
+
381
+ function controller() {
382
+
383
+ global $gmProcessor;
384
+ switch ( $gmProcessor->page ) {
385
+ case 'GrandMedia_AddMedia':
386
+ include_once( dirname( __FILE__ ) . '/pages/addmedia/addmedia.php' );
387
+ break;
388
+ case 'GrandMedia_Albums':
389
+ if ( isset( $_GET['edit_term'] ) ) {
390
+ include_once( dirname( __FILE__ ) . '/pages/terms/edit-term.php' );
391
+ } else {
392
+ include_once( dirname( __FILE__ ) . '/pages/terms/terms.php' );
393
+ }
394
+ break;
395
+ case 'GrandMedia_Categories':
396
+ if ( isset( $_GET['edit_term'] ) ) {
397
+ include_once( dirname( __FILE__ ) . '/pages/terms/edit-term.php' );
398
+ } else {
399
+ include_once( dirname( __FILE__ ) . '/pages/terms/terms.php' );
400
+ }
401
+ break;
402
+ case 'GrandMedia_Tags':
403
+ include_once( dirname( __FILE__ ) . '/pages/terms/terms.php' );
404
+ break;
405
+ case 'GrandMedia_Galleries':
406
+ if ( isset( $_GET['gallery_module'] ) || isset( $_GET['edit_term'] ) ) {
407
+ include_once( dirname( __FILE__ ) . '/pages/galleries/edit-gallery.php' );
408
+ } else {
409
+ include_once( dirname( __FILE__ ) . '/pages/galleries/galleries.php' );
410
+ }
411
+ break;
412
+ case 'GrandMedia_Modules':
413
+ if ( isset( $_GET['preset_module'] ) || isset( $_GET['preset'] ) ) {
414
+ include_once( dirname( __FILE__ ) . '/pages/modules/edit-preset.php' );
415
+ } else {
416
+ include_once( dirname( __FILE__ ) . '/pages/modules/modules.php' );
417
+ }
418
+ break;
419
+ case 'GrandMedia_Settings':
420
+ include_once( dirname( __FILE__ ) . '/pages/settings/settings.php' );
421
+ break;
422
+ case 'GrandMedia_App':
423
+ include_once( dirname( __FILE__ ) . '/app.php' );
424
+ gmediaApp();
425
+ break;
426
+ case 'GrandMedia_WordpressLibrary':
427
+ include_once( dirname( __FILE__ ) . '/wpmedia.php' );
428
+ grandWPMedia();
429
+ break;
430
+ case 'GrandMedia_Logs':
431
+ include_once( dirname( __FILE__ ) . '/logs.php' );
432
+ break;
433
+ case 'GrandMedia_Support':
434
+ include_once( dirname( __FILE__ ) . '/support.php' );
435
+ gmediaSupport();
436
+ break;
437
+ case 'GrandMedia_Update':
438
+ include_once( GMEDIA_ABSPATH . 'config/update.php' );
439
+ gmedia_upgrade_progress_panel();
440
+ break;
441
+ case 'GrandMedia':
442
+ include_once( dirname( __FILE__ ) . '/pages/library/library.php' );
443
+ break;
444
+ default:
445
+ do_action( 'gmedia_admin_page-' . $gmProcessor->page );
446
+ break;
447
+ }
448
+ }
449
+
450
+ /**
451
+ * @param $hook
452
+ */
453
+ function load_scripts( $hook ) {
454
+ global $gmCore, $gmProcessor, $gmGallery;
455
+ // no need to go on if it's not a plugin page
456
+ if ( 'admin.php' != $hook && strpos( $gmCore->_get( 'page' ), 'GrandMedia' ) === false ) {
457
+ return;
458
+ }
459
+
460
+ if ( $gmGallery->options['isolation_mode'] ) {
461
+ global $wp_scripts, $wp_styles;
462
+ foreach ( $wp_scripts->registered as $handle => $wp_script ) {
463
+ if ( ( ( false !== strpos( $wp_script->src, '/plugins/' ) ) || ( false !== strpos( $wp_script->src, '/themes/' ) ) ) && ( false === strpos( $wp_script->src, GMEDIA_FOLDER ) ) ) {
464
+ if ( in_array( $handle, $wp_scripts->queue ) ) {
465
+ wp_dequeue_script( $handle );
466
+ }
467
+ wp_deregister_script( $handle );
468
+ }
469
+ }
470
+ foreach ( $wp_styles->registered as $handle => $wp_style ) {
471
+ if ( ( ( false !== strpos( $wp_style->src, '/plugins/' ) ) || ( false !== strpos( $wp_style->src, '/themes/' ) ) ) && ( false === strpos( $wp_style->src, GMEDIA_FOLDER ) ) ) {
472
+ if ( in_array( $handle, $wp_styles->queue ) ) {
473
+ wp_dequeue_style( $handle );
474
+ }
475
+ wp_deregister_style( $handle );
476
+ }
477
+ }
478
+ }
479
+
480
+ wp_enqueue_style( 'gmedia-bootstrap' );
481
+ wp_enqueue_script( 'gmedia-bootstrap' );
482
+
483
+ wp_register_script( 'selectize', $gmCore->gmedia_url . '/assets/selectize/selectize.min.js', array( 'jquery' ), '0.12.1' );
484
+ wp_register_style( 'selectize', $gmCore->gmedia_url . '/assets/selectize/selectize.bootstrap3.css', array( 'gmedia-bootstrap' ), '0.12.1', 'screen' );
485
+
486
+ wp_register_style( 'spectrum', $gmCore->gmedia_url . '/assets/spectrum/spectrum.min.css', array(), '1.8.0' );
487
+ wp_register_script( 'spectrum', $gmCore->gmedia_url . '/assets/spectrum/spectrum.min.js', array( 'jquery' ), '1.8.0', true );
488
+
489
+ if ( isset( $_GET['page'] ) ) {
490
+ switch ( $_GET['page'] ) {
491
+ case "GrandMedia" :
492
+ if ( $gmCore->caps['gmedia_edit_media'] ) {
493
+ if ( $gmCore->_get( 'gmediablank' ) == 'image_editor' ) {
494
+ wp_enqueue_script( 'camanjs', $gmCore->gmedia_url . '/assets/image-editor/camanjs/caman.full.min.js', array(), '4.1.2' );
495
+
496
+ wp_enqueue_style( 'nouislider', $gmCore->gmedia_url . '/assets/image-editor/js/jquery.nouislider.css', array( 'gmedia-bootstrap' ), '6.1.0' );
497
+ wp_enqueue_script( 'nouislider', $gmCore->gmedia_url . '/assets/image-editor/js/jquery.nouislider.min.js', array( 'jquery' ), '6.1.0' );
498
+
499
+ wp_enqueue_style( 'gmedia-image-editor', $gmCore->gmedia_url . '/assets/image-editor/style.css', array( 'gmedia-bootstrap' ), '0.9.16', 'screen' );
500
+ wp_enqueue_script( 'gmedia-image-editor', $gmCore->gmedia_url . '/assets/image-editor/image-editor.js', array( 'jquery', 'camanjs' ), '0.9.16' );
501
+ break;
502
+ }
503
+ if ( $gmProcessor->mode == 'edit' ) {
504
+ wp_enqueue_script( 'alphanum', $gmCore->gmedia_url . '/assets/jq-plugins/jquery.alphanum.js', array( 'jquery' ), '1.0.16' );
505
+
506
+ wp_enqueue_script( 'jquery-ui-sortable' );
507
+
508
+ wp_enqueue_script( 'moment', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/moment.min.js', array( 'jquery' ), '2.22.2' );
509
+ wp_enqueue_style( 'datetimepicker', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css', array( 'gmedia-bootstrap' ), '4.17.47' );
510
+ wp_enqueue_script( 'datetimepicker', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js', array(
511
+ 'jquery',
512
+ 'moment',
513
+ 'gmedia-bootstrap',
514
+ ), '4.17.47' );
515
+ }
516
+ }
517
+ wp_enqueue_script( 'wavesurfer', $gmCore->gmedia_url . '/assets/wavesurfer/wavesurfer.min.js', array( 'jquery' ), '1.1.5' );
518
+ break;
519
+ case "GrandMedia_WordpressLibrary" :
520
+ break;
521
+ case "GrandMedia_Albums" :
522
+ if ( isset( $_GET['edit_term'] ) ) {
523
+ if ( $gmCore->caps['gmedia_album_manage'] ) {
524
+ 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' );
525
+ wp_enqueue_script( 'jquery-ui-full', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js', array(), '1.10.2' );
526
+ }
527
+
528
+ wp_enqueue_script( 'moment', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/moment.min.js', array( 'jquery' ), '2.5.1' );
529
+ wp_enqueue_style( 'datetimepicker', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css', array( 'gmedia-bootstrap' ), '2.1.32' );
530
+ wp_enqueue_script( 'datetimepicker', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js', array(
531
+ 'jquery',
532
+ 'moment',
533
+ 'gmedia-bootstrap',
534
+ ), '2.1.32' );
535
+ }
536
+ break;
537
+ case "GrandMedia_Categories" :
538
+ break;
539
+ case "GrandMedia_AddMedia" :
540
+ if ( $gmCore->caps['gmedia_upload'] ) {
541
+ $tab = $gmCore->_get( 'tab', 'upload' );
542
+ if ( $tab == 'upload' ) {
543
+ 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' );
544
+ wp_enqueue_script( 'jquery-ui-full', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js', array(), '1.10.2' );
545
+
546
+ wp_enqueue_script( 'gmedia-plupload', $gmCore->gmedia_url . '/assets/plupload/plupload.full.min.js', array( 'jquery', 'jquery-ui-full' ), '2.1.2' );
547
+
548
+ 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' );
549
+ wp_enqueue_script( 'jquery.ui.plupload', $gmCore->gmedia_url . '/assets/plupload/jquery.ui.plupload/jquery.ui.plupload.min.js', array(
550
+ 'gmedia-plupload',
551
+ 'jquery-ui-full',
552
+ ), '2.1.2' );
553
+
554
+ }
555
+ }
556
+ break;
557
+ case "GrandMedia_Settings" :
558
+ case "GrandMedia_App" :
559
+ // under construction
560
+ break;
561
+ case "GrandMedia_Galleries" :
562
+ if ( $gmCore->caps['gmedia_gallery_manage'] && ( isset( $_GET['gallery_module'] ) || isset( $_GET['edit_term'] ) ) ) {
563
+
564
+ 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' );
565
+ wp_enqueue_script( 'jquery-ui-resizable' );
566
+
567
+ wp_enqueue_script( 'jquery-ui-sortable' );
568
+
569
+ wp_enqueue_style( 'jquery.minicolors', $gmCore->gmedia_url . '/assets/minicolors/jquery.minicolors.css', array( 'gmedia-bootstrap' ), '0.9.13' );
570
+ wp_enqueue_script( 'jquery.minicolors', $gmCore->gmedia_url . '/assets/minicolors/jquery.minicolors.js', array( 'jquery' ), '0.9.13' );
571
+
572
+ wp_enqueue_style( 'spectrum' );
573
+ wp_enqueue_script( 'spectrum' );
574
+ }
575
+ break;
576
+ case "GrandMedia_Modules" :
577
+ if ( isset( $_GET['preset_module'] ) || isset( $_GET['preset'] ) ) {
578
+
579
+ 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' );
580
+ wp_enqueue_script( 'jquery-ui-resizable' );
581
+
582
+ wp_enqueue_script( 'jquery-ui-sortable' );
583
+
584
+ wp_enqueue_style( 'jquery.minicolors', $gmCore->gmedia_url . '/assets/minicolors/jquery.minicolors.css', array( 'gmedia-bootstrap' ), '0.9.13' );
585
+ wp_enqueue_script( 'jquery.minicolors', $gmCore->gmedia_url . '/assets/minicolors/jquery.minicolors.js', array( 'jquery' ), '0.9.13' );
586
+
587
+ wp_enqueue_style( 'spectrum' );
588
+ wp_enqueue_script( 'spectrum' );
589
+ }
590
+ break;
591
+ }
592
+ }
593
+ wp_enqueue_style( 'selectize' );
594
+ wp_enqueue_script( 'selectize' );
595
+
596
+ wp_enqueue_style( 'grand-media' );
597
+ wp_enqueue_script( 'grand-media' );
598
+
599
+ }
600
+
601
+ function gmedia_widget_scripts() {
602
+
603
+ }
604
+
605
+ /**
606
+ * Enqueue the block's assets for the gutenberg editor.
607
+ */
608
+ function gutenberg_assets() {
609
+ global $gmGallery, $gmDB, $gmCore;
610
+
611
+ wp_enqueue_style( 'gmedia-block-editor', $gmCore->gmedia_url . '/admin/assets/css/gmedia-block.css', array(), $gmGallery->version );
612
+ wp_register_script(
613
+ 'gmedia-block-editor',
614
+ $gmCore->gmedia_url . '/admin/assets/js/gmedia-block.js',
615
+ array( 'wp-blocks', 'wp-element' ),
616
+ $gmGallery->version
617
+ );
618
+
619
+ $default_module = $gmGallery->options['default_gmedia_module'];
620
+ $default_preset = $gmCore->getModulePreset( $default_module );
621
+ $default_module = $default_preset['module'];
622
+
623
+ $modules_data = get_gmedia_modules( false );
624
+ $modules = array();
625
+ $modules_options = array();
626
+ if ( ! empty( $modules_data['in'] ) ) {
627
+ foreach ( $modules_data['in'] as $module_name => $module_data ) {
628
+
629
+ $presets = $gmDB->get_terms( 'gmedia_module', array( 'status' => $module_name ) );
630
+ $option = array();
631
+ $option[ $module_name ] = $module_data['title'] . ' - ' . __( 'Default Settings' );
632
+ foreach ( $presets as $preset ) {
633
+ if ( ! (int) $preset->global && '[' . $module_name . ']' === $preset->name ) {
634
+ continue;
635
+ }
636
+ $by_author = '';
637
+ if ( (int) $preset->global ) {
638
+ $display_name = get_the_author_meta( 'display_name', $preset->global );
639
+ $by_author = $display_name ? ' [' . $display_name . ']' : '';
640
+ }
641
+ if ( '[' . $module_name . ']' === $preset->name ) {
642
+ $option[ $preset->term_id ] = $module_data['title'] . $by_author . ' - ' . __( 'Default Settings' );
643
+ } else {
644
+ $preset_name = str_replace( '[' . $module_name . '] ', '', $preset->name );
645
+ $option[ $preset->term_id ] = $module_data['title'] . $by_author . ' - ' . $preset_name;
646
+ }
647
+ }
648
+ $modules_options[ $module_name ] = array( 'title' => $module_data['title'], 'options' => $option );
649
+
650
+ $modules[ $module_name ] = array(
651
+ 'name' => $module_data['title'],
652
+ 'screenshot' => $module_data['module_url'] . '/screenshot.png',
653
+ );
654
+ }
655
+ }
656
+
657
+ $gm_galleries = array();
658
+ $gm_albums = array();
659
+ $gm_categories = array();
660
+ $gm_tags = array();
661
+
662
+ $gm_terms = $gmDB->get_terms( 'gmedia_gallery' );
663
+ if ( count( $gm_terms ) ) {
664
+ foreach ( $gm_terms as $_term ) {
665
+ unset( $_term->description );
666
+ unset( $_term->taxonomy );
667
+ $_term->module_name = $gmDB->get_metadata( 'gmedia_term', $_term->term_id, '_module', true );
668
+ if ( $_term->global ) {
669
+ $display_name = sprintf( __( 'by %s', 'grand-media' ), get_the_author_meta( 'display_name', $_term->global ) );
670
+ $_term->name .= 'by ' === $display_name ? '' : ' ' . $display_name;
671
+ }
672
+ if ( $_term->status && 'publish' !== $_term->status ) {
673
+ $_term->name .= " [{$_term->status}]";
674
+ }
675
+ $gm_galleries[ $_term->term_id ] = $_term;
676
+ }
677
+ }
678
+ $gm_galleries = array(
679
+ 0 => array(
680
+ 'term_id' => 0,
681
+ 'name' => __( ' - select gallery - ', 'grand-media' ),
682
+ ),
683
+ ) + $gm_galleries;
684
+
685
+ $gm_terms = $gmDB->get_terms( 'gmedia_album' );
686
+ if ( count( $gm_terms ) ) {
687
+ foreach ( $gm_terms as $_term ) {
688
+ unset( $_term->description );
689
+ unset( $_term->taxonomy );
690
+ $module_preset = $gmDB->get_metadata( 'gmedia_term', $_term->term_id, '_module_preset', true );
691
+ if ( $module_preset ) {
692
+ $preset = $gmCore->getModulePreset( $module_preset );
693
+ $_term->module_name = $preset['module'];
694
+ } else {
695
+ $_term->module_name = '';
696
+ }
697
+ if ( $_term->global ) {
698
+ $display_name = sprintf( __( 'by %s', 'grand-media' ), get_the_author_meta( 'display_name', $_term->global ) );
699
+ $_term->name .= 'by ' === $display_name ? '' : ' ' . $display_name;
700
+ }
701
+ if ( $_term->status && 'publish' !== $_term->status ) {
702
+ $_term->name .= " [{$_term->status}]";
703
+ }
704
+ $_term->name .= " ({$_term->count})";
705
+ $gm_albums[ $_term->term_id ] = $_term;
706
+ }
707
+ }
708
+ $gm_albums = array(
709
+ 0 => array(
710
+ 'term_id' => 0,
711
+ 'name' => __( ' - select album - ', 'grand-media' ),
712
+ ),
713
+ ) + $gm_albums;
714
+
715
+ $gm_terms = $gmDB->get_terms( 'gmedia_category' );
716
+ if ( count( $gm_terms ) ) {
717
+ foreach ( $gm_terms as $_term ) {
718
+ unset( $_term->description );
719
+ unset( $_term->taxonomy );
720
+ unset( $_term->global );
721
+ unset( $_term->status );
722
+ $_term->name .= " ({$_term->count})";
723
+ $gm_categories[ $_term->term_id ] = $_term;
724
+ }
725
+ }
726
+ $gm_categories = array(
727
+ 0 => array(
728
+ 'term_id' => 0,
729
+ 'name' => __( ' - select category - ', 'grand-media' ),
730
+ ),
731
+ ) + $gm_categories;
732
+
733
+ $gm_terms = $gmDB->get_terms( 'gmedia_tag' );
734
+ if ( count( $gm_terms ) ) {
735
+ foreach ( $gm_terms as $_term ) {
736
+ unset( $_term->description );
737
+ unset( $_term->taxonomy );
738
+ unset( $_term->global );
739
+ unset( $_term->status );
740
+ $_term->name .= " ({$_term->count})";
741
+ $gm_tags[ $_term->term_id ] = $_term;
742
+ }
743
+ }
744
+ $gm_tags = array(
745
+ 0 => array(
746
+ 'term_id' => 0,
747
+ 'name' => __( ' - select tag - ', 'grand-media' ),
748
+ ),
749
+ ) + $gm_tags;
750
+
751
+ $data = array(
752
+ 'modules' => $modules,
753
+ 'default_module' => $default_module,
754
+ 'modules_options' => $modules_options,
755
+ 'gmedia_image' => $gmCore->gmedia_url . '/admin/assets/img/gmedia-icon-320x240.png',
756
+ 'galleries' => $gm_galleries,
757
+ 'albums' => $gm_albums,
758
+ 'categories' => $gm_categories,
759
+ 'tags' => $gm_tags,
760
+ );
761
+
762
+ wp_localize_script( 'gmedia-block-editor', 'gmedia_data', $data );
763
+ wp_enqueue_script( 'gmedia-block-editor' );
764
+ }
765
+
766
+ function screen_help() {
767
+ $screen = get_current_screen();
768
+ $screen_id = explode( 'page_', $screen->id, 2 );
769
+ $screen_id = $screen_id[1];
770
+
771
+ $screen->add_help_tab( array(
772
+ 'id' => 'help_' . $screen_id . '_support',
773
+ 'title' => __( 'Support' ),
774
+ 'content' => __( '<h4>First steps</h4>
775
  <p>If you have any problems with displaying Gmedia Gallery in admin or on website. Before posting to the Forum try next:</p>
776
  <ul>
777
  <li>Exclude plugin conflicts: Disable other plugins one by one and check if it resolve problem</li>
778
  <li>Exclude theme conflict: Temporary switch to one of default themes and check if gallery works</li>
779
  </ul>
780
+ <h4>Links</h4>', 'grand-media' )
781
+ . '<p><a href="https://codeasily.com/community/forum/gmedia-gallery-wordpress-plugin/" target="_blank">' . __( 'Support Forum', 'grand-media' ) . '</a>
782
+ | <a href="https://codeasily.com/contact/" target="_blank">' . __( 'Contact', 'grand-media' ) . '</a>
783
+ | <a href="https://codeasily.com/portfolio/gmedia-gallery-modules/" target="_blank">' . __( 'Demo', 'grand-media' ) . '</a>
784
+ | <a href="https://codeasily.com/product/one-site-license/" target="_blank">' . __( 'Premium', 'grand-media' ) . '</a>
785
  </p>',
786
+ ) );
787
+
788
+ switch ( $screen_id ) {
789
+ case 'GrandMedia' :
790
+ break;
791
+ case 'GrandMedia_Settings' :
792
+ if ( current_user_can( 'manage_options' ) ) {
793
+ $screen->add_help_tab( array(
794
+ 'id' => 'help_' . $screen_id . '_license',
795
+ 'title' => __( 'License Key' ),
796
+ 'content' => sprintf( __( '<h4>Should I buy it, to use plugin?</h4>
797
  <p>No, plugin is absolutely free and all modules for it are free to install.</p>
798
  <p>Even premium modules are fully functional and free to test, but have backlink labels. To remove baclink labels from premium modules you need license key.</p>
799
  <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>
800
  <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>
801
  <h4>I have license key but I can\'t activate it</h4>
802
+ <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' )
803
+ . '<div><a class="btn btn-default" href="' . admin_url( 'admin.php?page=' . $screen_id . '&license_activate=manual' ) . '">' . __( 'Manual Activation', 'grand-media' ) . '</a></div>',
804
+ ) );
805
+ }
806
+ break;
807
+ case 'GrandMedia_App' :
808
+ $gm_options = get_option( 'gmediaOptions' );
809
+ $nonce = wp_create_nonce( 'GmediaService' );
810
+ if ( current_user_can( 'manage_options' ) && (int) $gm_options['mobile_app'] ) {
811
+ $screen->add_help_tab( array(
812
+ 'id' => 'help_' . $screen_id . '_optout',
813
+ 'title' => __( 'Opt Out' ),
814
+ 'content' => __( '<h4>We appreciate your help in making the plugin better by letting us track some usage data.</h4>
815
  <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>
816
  <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>
817
+ <p>You\'ll also not be able to use Gmedia iOS application.</p>', 'grand-media' )
818
+ . '<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>'
819
+ . '<div style="display:none;">Test:
820
  <button type="button" data-action="app_updateinfo" data-nonce="' . $nonce . '" class="btn btn-sm btn-primary gm_service_action">Update</button>
821
  <button type="button" data-action="app_updatecron" data-nonce="' . $nonce . '" class="btn btn-sm btn-primary gm_service_action">CronJob</button> &nbsp;&nbsp;
822
  <button type="button" data-action="app_deactivateplugin" data-nonce="' . $nonce . '" class="btn btn-sm btn-primary gm_service_action">Deactivate Plugin</button>
823
  <button type="button" data-action="app_uninstallplugin" data-nonce="' . $nonce . '" class="btn btn-sm btn-primary gm_service_action">Uninstall Plugin</button>
824
  </div>
825
  ',
826
+ ) );
827
+ }
828
+ break;
829
+ }
830
+ }
831
+
832
+ /**
833
+ * @param $current
834
+ * @param $screen
835
+ *
836
+ * @return string
837
+ */
838
+ function screen_settings( $current, $screen ) {
839
+ global $gmProcessor, $gmCore;
840
+ if ( in_array( $screen->id, $this->pages ) ) {
841
+
842
+ $gm_screen_options = $gmProcessor->user_options;
843
+
844
+ $title = '<h5><strong>' . __( 'Settings', 'grand-media' ) . '</strong></h5>';
845
+ $wp_screen_options = '<input type="hidden" name="wp_screen_options[option]" value="gm_screen_options" /><input type="hidden" name="wp_screen_options[value]" value="' . $screen->id . '" />';
846
+ $button = get_submit_button( __( 'Apply', 'grand-media' ), 'button', 'screen-options-apply', false );
847
+
848
+ $settings = false;
849
+
850
+ $screen_id = explode( 'page_', $screen->id, 2 );
851
+
852
+ switch ( $screen_id[1] ) {
853
+ case 'GrandMedia' :
854
+ $settings = '
855
  <div class="form-inline pull-left">
856
  <div class="form-group">
857
+ <input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_gmedia]" class="form-control input-sm" style="width: 5em;" value="' . $gm_screen_options['per_page_gmedia'] . '" /> <span>' . __( 'items per page', 'grand-media' ) . '</span>
858
  </div>
859
  <div class="form-group">
860
  <select name="gm_screen_options[orderby_gmedia]" class="form-control input-sm">
861
+ <option' . selected( $gm_screen_options['orderby_gmedia'], 'ID', false ) . ' value="ID">' . __( 'ID', 'grand-media' ) . '</option>
862
+ <option' . selected( $gm_screen_options['orderby_gmedia'], 'title', false ) . ' value="title">' . __( 'Title', 'grand-media' ) . '</option>
863
+ <option' . selected( $gm_screen_options['orderby_gmedia'], 'gmuid', false ) . ' value="gmuid">' . __( 'Filename', 'grand-media' ) . '</option>
864
+ <option' . selected( $gm_screen_options['orderby_gmedia'], 'mime_type', false ) . ' value="mime_type">' . __( 'MIME Type', 'grand-media' ) . '</option>
865
+ <option' . selected( $gm_screen_options['orderby_gmedia'], 'author', false ) . ' value="author">' . __( 'Author', 'grand-media' ) . '</option>
866
+ <option' . selected( $gm_screen_options['orderby_gmedia'], 'date', false ) . ' value="date">' . __( 'Date', 'grand-media' ) . '</option>
867
+ <option' . selected( $gm_screen_options['orderby_gmedia'], 'modified', false ) . ' value="modified">' . __( 'Last Modified', 'grand-media' ) . '</option>
868
+ <option' . selected( $gm_screen_options['orderby_gmedia'], '_created_timestamp', false ) . ' value="_created_timestamp">' . __( 'Created Timestamp', 'grand-media' ) . '</option>
869
+ <option' . selected( $gm_screen_options['orderby_gmedia'], 'comment_count', false ) . ' value="comment_count">' . __( 'Comment Count', 'grand-media' ) . '</option>
870
+ <option' . selected( $gm_screen_options['orderby_gmedia'], 'views', false ) . ' value="views">' . __( 'Views Count', 'grand-media' ) . '</option>
871
+ <option' . selected( $gm_screen_options['orderby_gmedia'], 'likes', false ) . ' value="likes">' . __( 'Likes Count', 'grand-media' ) . '</option>
872
+ <option' . selected( $gm_screen_options['orderby_gmedia'], '_size', false ) . ' value="_size">' . __( 'File Size', 'grand-media' ) . '</option>
873
+ </select> <span>' . __( 'order items', 'grand-media' ) . '</span>
874
  </div>
875
  <div class="form-group">
876
  <select name="gm_screen_options[sortorder_gmedia]" class="form-control input-sm">
877
+ <option' . selected( $gm_screen_options['sortorder_gmedia'], 'DESC', false ) . ' value="DESC">' . __( 'DESC', 'grand-media' ) . '</option>
878
+ <option' . selected( $gm_screen_options['sortorder_gmedia'], 'ASC', false ) . ' value="ASC">' . __( 'ASC', 'grand-media' ) . '</option>
879
+ </select> <span>' . __( 'sort order', 'grand-media' ) . '</span>
880
  </div>
881
  ';
882
+ if ( 'edit' == $gmCore->_get( 'mode' ) ) {
883
+ $settings .= '
884
  <div class="form-group">
885
  <select name="gm_screen_options[library_edit_quicktags]" class="form-control input-sm">
886
+ <option' . selected( $gm_screen_options['library_edit_quicktags'], 'false', false ) . ' value="false">' . __( 'FALSE', 'grand-media' ) . '</option>
887
+ <option' . selected( $gm_screen_options['library_edit_quicktags'], 'true', false ) . ' value="true">' . __( 'TRUE', 'grand-media' ) . '</option>
888
+ </select> <span>' . __( 'Quick Tags panel for Description field', 'grand-media' ) . '</span>
889
  </div>
890
  ';
891
+ }
892
+ $settings .= '
893
  </div>
894
  ';
895
+ break;
896
+ case 'GrandMedia_AddMedia' :
897
+ $tab = $gmCore->_get( 'tab', 'upload' );
898
+ if ( 'upload' == $tab ) {
899
+ $html4_hide = ( 'html4' == $gm_screen_options['uploader_runtime'] ) ? ' hide' : '';
900
+ $settings = '
901
  <div class="form-inline pull-left">
902
+ <div id="uploader_runtime" class="form-group"><span>' . __( 'Uploader runtime:', 'grand-media' ) . ' </span>
903
  <select name="gm_screen_options[uploader_runtime]" class="form-control input-sm">
904
+ <option' . selected( $gm_screen_options['uploader_runtime'], 'auto', false ) . ' value="auto">' . __( 'Auto', 'grand-media' ) . '</option>
905
+ <option' . selected( $gm_screen_options['uploader_runtime'], 'html5', false ) . ' value="html5">' . __( 'HTML5 Uploader', 'grand-media' ) . '</option>
906
+ <option' . selected( $gm_screen_options['uploader_runtime'], 'flash', false ) . ' value="flash">' . __( 'Flash Uploader', 'grand-media' ) . '</option>
907
+ <option' . selected( $gm_screen_options['uploader_runtime'], 'html4', false ) . ' value="html4">' . __( 'HTML4 Uploader', 'grand-media' ) . '</option>
908
  </select>
909
  </div>
910
+ <div id="uploader_chunking" class="form-group' . $html4_hide . '"><span>' . __( 'Chunking:', 'grand-media' ) . ' </span>
911
  <select name="gm_screen_options[uploader_chunking]" class="form-control input-sm">
912
+ <option' . selected( $gm_screen_options['uploader_chunking'], 'true', false ) . ' value="true">' . __( 'TRUE', 'grand-media' ) . '</option>
913
+ <option' . selected( $gm_screen_options['uploader_chunking'], 'false', false ) . ' value="false">' . __( 'FALSE', 'grand-media' ) . '</option>
914
  </select>
915
  </div>
916
+ <div id="uploader_urlstream_upload" class="form-group' . $html4_hide . '"><span>' . __( 'URL streem upload:', 'grand-media' ) . ' </span>
917
  <select name="gm_screen_options[uploader_urlstream_upload]" class="form-control input-sm">
918
+ <option' . selected( $gm_screen_options['uploader_urlstream_upload'], 'true', false ) . ' value="true">' . __( 'TRUE', 'grand-media' ) . '</option>
919
+ <option' . selected( $gm_screen_options['uploader_urlstream_upload'], 'false', false ) . ' value="false">' . __( 'FALSE', 'grand-media' ) . '</option>
920
  </select>
921
  </div>
922
  </div>
923
  ';
924
+ }
925
+ break;
926
+ case 'GrandMedia_Albums' :
927
+ if ( isset( $_GET['edit_term'] ) ) {
928
+ $settings = '
929
  <div class="form-inline pull-left">
930
  <div class="form-group">
931
+ <input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_gmedia_album_edit]" class="form-control input-sm" style="width: 5em;" value="' . $gm_screen_options['per_page_gmedia_album_edit'] . '" /> <span>' . __( 'items per page', 'grand-media' ) . '</span>
932
  </div>
933
  </div>
934
  ';
935
+ } else {
936
+ $settings = '
937
  <div class="form-inline pull-left">
938
  <div class="form-group">
939
+ <input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_gmedia_album]" class="form-control input-sm" style="width: 5em;" value="' . $gm_screen_options['per_page_gmedia_album'] . '" /> <span>' . __( 'items per page', 'grand-media' ) . '</span>
940
  </div>
941
  <div class="form-group">
942
  <select name="gm_screen_options[orderby_gmedia_album]" class="form-control input-sm">
943
+ <option' . selected( $gm_screen_options['orderby_gmedia_album'], 'id', false ) . ' value="id">' . __( 'ID', 'grand-media' ) . '</option>
944
+ <option' . selected( $gm_screen_options['orderby_gmedia_album'], 'name', false ) . ' value="name">' . __( 'Name', 'grand-media' ) . '</option>
945
+ <option' . selected( $gm_screen_options['orderby_gmedia_album'], 'count', false ) . ' value="count">' . __( 'Gmedia Count', 'grand-media' ) . '</option>
946
+ <option' . selected( $gm_screen_options['orderby_gmedia_album'], 'global', false ) . ' value="global">' . __( 'Author ID', 'grand-media' ) . '</option>
947
+ </select> <span>' . __( 'order items', 'grand-media' ) . '</span>
948
  </div>
949
  <div class="form-group">
950
  <select name="gm_screen_options[sortorder_gmedia_album]" class="form-control input-sm">
951
+ <option' . selected( $gm_screen_options['sortorder_gmedia_album'], 'DESC', false ) . ' value="DESC">' . __( 'DESC', 'grand-media' ) . '</option>
952
+ <option' . selected( $gm_screen_options['sortorder_gmedia_album'], 'ASC', false ) . ' value="ASC">' . __( 'ASC', 'grand-media' ) . '</option>
953
+ </select> <span>' . __( 'sort order', 'grand-media' ) . '</span>
954
  </div>
955
  </div>
956
  ';
957
+ }
958
+ break;
959
+ case 'GrandMedia_Categories' :
960
+ if ( isset( $_GET['edit_term'] ) ) {
961
+ $settings = '
962
  <div class="form-inline pull-left">
963
  <div class="form-group">
964
+ <input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_gmedia_category_edit]" class="form-control input-sm" style="width: 5em;" value="' . $gm_screen_options['per_page_gmedia_category_edit'] . '" /> <span>' . __( 'items per page', 'grand-media' ) . '</span>
965
  </div>
966
  </div>
967
  ';
968
+ } else {
969
+ $settings = '
970
  <div class="form-inline pull-left">
971
  <div class="form-group">
972
+ <input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_gmedia_category]" class="form-control input-sm" style="width: 5em;" value="' . $gm_screen_options['per_page_gmedia_category'] . '" /> <span>' . __( 'items per page', 'grand-media' ) . '</span>
973
  </div>
974
  <div class="form-group">
975
  <select name="gm_screen_options[orderby_gmedia_category]" class="form-control input-sm">
976
+ <option' . selected( $gm_screen_options['orderby_gmedia_category'], 'id', false ) . ' value="id">' . __( 'ID', 'grand-media' ) . '</option>
977
+ <option' . selected( $gm_screen_options['orderby_gmedia_category'], 'name', false ) . ' value="name">' . __( 'Name', 'grand-media' ) . '</option>
978
+ <option' . selected( $gm_screen_options['orderby_gmedia_category'], 'count', false ) . ' value="count">' . __( 'Gmedia Count', 'grand-media' ) . '</option>
979
+ </select> <span>' . __( 'order items', 'grand-media' ) . '</span>
980
  </div>
981
  <div class="form-group">
982
  <select name="gm_screen_options[sortorder_gmedia_category]" class="form-control input-sm">
983
+ <option' . selected( $gm_screen_options['sortorder_gmedia_category'], 'DESC', false ) . ' value="DESC">' . __( 'DESC', 'grand-media' ) . '</option>
984
+ <option' . selected( $gm_screen_options['sortorder_gmedia_category'], 'ASC', false ) . ' value="ASC">' . __( 'ASC', 'grand-media' ) . '</option>
985
+ </select> <span>' . __( 'sort order', 'grand-media' ) . '</span>
986
  </div>
987
  </div>
988
  ';
989
+ }
990
+ break;
991
+ case 'GrandMedia_Tags' :
992
+ $settings = '
993
  <div class="form-inline pull-left">
994
  <div class="form-group">
995
+ <input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_gmedia_tag]" class="form-control input-sm" style="width: 5em;" value="' . $gm_screen_options['per_page_gmedia_tag'] . '" /> <span>' . __( 'items per page', 'grand-media' ) . '</span>
996
  </div>
997
  <div class="form-group">
998
  <select name="gm_screen_options[orderby_gmedia_tag]" class="form-control input-sm">
999
+ <option' . selected( $gm_screen_options['orderby_gmedia_tag'], 'id', false ) . ' value="id">' . __( 'ID', 'grand-media' ) . '</option>
1000
+ <option' . selected( $gm_screen_options['orderby_gmedia_tag'], 'name', false ) . ' value="name">' . __( 'Name', 'grand-media' ) . '</option>
1001
+ <option' . selected( $gm_screen_options['orderby_gmedia_tag'], 'count', false ) . ' value="count">' . __( 'Gmedia Count', 'grand-media' ) . '</option>
1002
+ </select> <span>' . __( 'order items', 'grand-media' ) . '</span>
1003
  </div>
1004
  <div class="form-group">
1005
  <select name="gm_screen_options[sortorder_gmedia_tag]" class="form-control input-sm">
1006
+ <option' . selected( $gm_screen_options['sortorder_gmedia_tag'], 'DESC', false ) . ' value="DESC">' . __( 'DESC', 'grand-media' ) . '</option>
1007
+ <option' . selected( $gm_screen_options['sortorder_gmedia_tag'], 'ASC', false ) . ' value="ASC">' . __( 'ASC', 'grand-media' ) . '</option>
1008
+ </select> <span>' . __( 'sort order', 'grand-media' ) . '</span>
1009
  </div>
1010
  </div>
1011
  ';
1012
+ break;
1013
+ case 'GrandMedia_Galleries' :
1014
+ if ( ! $gmCore->_get( 'edit_term' ) && ! $gmCore->_get( 'gallery_module' ) ) {
1015
+ $settings = '
1016
  <div class="form-inline pull-left">
1017
  <div class="form-group">
1018
+ <input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_gmedia_gallery]" class="form-control input-sm" style="width: 5em;" value="' . $gm_screen_options['per_page_gmedia_gallery'] . '" /> <span>' . __( 'items per page', 'grand-media' ) . '</span>
1019
  </div>
1020
  <div class="form-group">
1021
  <select name="gm_screen_options[orderby_gmedia_gallery]" class="form-control input-sm">
1022
+ <option' . selected( $gm_screen_options['orderby_gmedia_gallery'], 'id', false ) . ' value="id">' . __( 'ID', 'grand-media' ) . '</option>
1023
+ <option' . selected( $gm_screen_options['orderby_gmedia_gallery'], 'name', false ) . ' value="name">' . __( 'Name', 'grand-media' ) . '</option>
1024
+ <option' . selected( $gm_screen_options['orderby_gmedia_gallery'], 'global', false ) . ' value="global">' . __( 'Author ID', 'grand-media' ) . '</option>
1025
+ </select> <span>' . __( 'order items', 'grand-media' ) . '</span>
1026
  </div>
1027
  <div class="form-group">
1028
  <select name="gm_screen_options[sortorder_gmedia_gallery]" class="form-control input-sm">
1029
+ <option' . selected( $gm_screen_options['sortorder_gmedia_gallery'], 'DESC', false ) . ' value="DESC">' . __( 'DESC', 'grand-media' ) . '</option>
1030
+ <option' . selected( $gm_screen_options['sortorder_gmedia_gallery'], 'ASC', false ) . ' value="ASC">' . __( 'ASC', 'grand-media' ) . '</option>
1031
+ </select> <span>' . __( 'sort order', 'grand-media' ) . '</span>
1032
  </div>
1033
  </div>
1034
  ';
1035
+ }
1036
+ break;
1037
+ case 'GrandMedia_WordpressLibrary' :
1038
+ $settings = '<p>' . __( 'Set query options for this page to be loaded by default.', 'grand-media' ) . '</p>
1039
  <div class="form-inline pull-left">
1040
  <div class="form-group">
1041
+ <input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_wpmedia]" class="form-control input-sm" style="width: 5em;" value="' . $gm_screen_options['per_page_wpmedia'] . '" /> <span>' . __( 'items per page', 'grand-media' ) . '</span>
1042
  </div>
1043
  <div class="form-group">
1044
  <select name="gm_screen_options[orderby_wpmedia]" class="form-control input-sm">
1045
+ <option' . selected( $gm_screen_options['orderby_wpmedia'], 'ID', false ) . ' value="ID">' . __( 'ID', 'grand-media' ) . '</option>
1046
+ <option' . selected( $gm_screen_options['orderby_wpmedia'], 'title', false ) . ' value="title">' . __( 'Title', 'grand-media' ) . '</option>
1047
+ <option' . selected( $gm_screen_options['orderby_wpmedia'], 'filename', false ) . ' value="filename">' . __( 'Filename', 'grand-media' ) . '</option>
1048
+ <option' . selected( $gm_screen_options['orderby_wpmedia'], 'date', false ) . ' value="date">' . __( 'Date', 'grand-media' ) . '</option>
1049
+ <option' . selected( $gm_screen_options['orderby_wpmedia'], 'modified', false ) . ' value="modified">' . __( 'Last Modified', 'grand-media' ) . '</option>
1050
+ <option' . selected( $gm_screen_options['orderby_wpmedia'], 'mime_type', false ) . ' value="mime_type">' . __( 'MIME Type', 'grand-media' ) . '</option>
1051
+ <option' . selected( $gm_screen_options['orderby_wpmedia'], 'author', false ) . ' value="author">' . __( 'Author', 'grand-media' ) . '</option>
1052
+ </select> <span>' . __( 'order items', 'grand-media' ) . '</span>
1053
  </div>
1054
  <div class="form-group">
1055
  <select name="gm_screen_options[sortorder_wpmedia]" class="form-control input-sm">
1056
+ <option' . selected( $gm_screen_options['sortorder_wpmedia'], 'DESC', false ) . ' value="DESC">' . __( 'DESC', 'grand-media' ) . '</option>
1057
+ <option' . selected( $gm_screen_options['sortorder_wpmedia'], 'ASC', false ) . ' value="ASC">' . __( 'ASC', 'grand-media' ) . '</option>
1058
+ </select> <span>' . __( 'sort order', 'grand-media' ) . '</span>
1059
  </div>
1060
  </div>
1061
  ';
1062
+ break;
1063
+ case 'GrandMedia_Logs' :
1064
+ $settings = '
1065
  <div class="form-inline pull-left">
1066
  <div class="form-group">
1067
+ <input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_gmedia_log]" class="form-control input-sm" style="width: 5em;" value="' . $gm_screen_options['per_page_gmedia_log'] . '" /> <span>' . __( 'items per page', 'grand-media' ) . '</span>
1068
  </div>
1069
  <div class="form-group">
1070
  <select name="gm_screen_options[orderby_gmedia_log]" class="form-control input-sm">
1071
+ <option' . selected( $gm_screen_options['orderby_gmedia_log'], 'log_date', false ) . ' value="log_date">' . __( 'Date', 'grand-media' ) . '</option>
1072
+ <option' . selected( $gm_screen_options['orderby_gmedia_log'], 'ID', false ) . ' value="ID">' . __( 'Gmedia ID', 'grand-media' ) . '</option>
1073
+ <option' . selected( $gm_screen_options['orderby_gmedia_log'], 'author', false ) . ' value="author">' . __( 'Author ID', 'grand-media' ) . '</option>
1074
+ </select> <span>' . __( 'order items', 'grand-media' ) . '</span>
1075
  </div>
1076
  <div class="form-group">
1077
  <select name="gm_screen_options[sortorder_gmedia_log]" class="form-control input-sm">
1078
+ <option' . selected( $gm_screen_options['sortorder_gmedia_log'], 'DESC', false ) . ' value="DESC">' . __( 'DESC', 'grand-media' ) . '</option>
1079
+ <option' . selected( $gm_screen_options['sortorder_gmedia_log'], 'ASC', false ) . ' value="ASC">' . __( 'ASC', 'grand-media' ) . '</option>
1080
+ </select> <span>' . __( 'sort order', 'grand-media' ) . '</span>
1081
  </div>
1082
  </div>
1083
  ';
1084
+ break;
1085
+ }
1086
+
1087
+ if ( $settings ) {
1088
+ $current = $title . $settings . $wp_screen_options . $button;
1089
+ }
1090
+
1091
+ }
1092
+
1093
+ return $current;
1094
+ }
1095
+
1096
+ /**
1097
+ * @param $status
1098
+ * @param $option
1099
+ * @param $value
1100
+ *
1101
+ * @return array
1102
+ */
1103
+ function screen_settings_save( $status, $option, $value ) {
1104
+ global $user_ID;
1105
+ if ( 'gm_screen_options' == $option ) {
1106
+ /*
1107
+ global $gmGallery;
1108
+ foreach ( $_POST['gm_screen_options'] as $key => $val ) {
1109
+ $gmGallery->options['gm_screen_options'][$key] = $val;
1110
+ }
1111
+ update_option( 'gmediaOptions', $gmGallery->options );
1112
+ */
1113
+ $gm_screen_options = get_user_meta( $user_ID, 'gm_screen_options', true );
1114
+ if ( ! is_array( $gm_screen_options ) ) {
1115
+ $gm_screen_options = array();
1116
+ }
1117
+ $value = array_merge( $gm_screen_options, $_POST['gm_screen_options'] );
1118
+
1119
+ return $value;
1120
+ }
1121
+
1122
+ return $status;
1123
+ }
1124
 
1125
  }
1126
 
admin/ajax.php CHANGED
@@ -134,6 +134,7 @@ function gmedia_update_data(){
134
  if( !empty($meta_error)){
135
  $result->meta_error = $meta_error;
136
  }
 
137
 
138
  header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
139
  echo json_encode($result);
@@ -2322,6 +2323,7 @@ function gmedia_save_waveform(){
2322
  }
2323
 
2324
  $gmDB->update_metadata('gmedia', $id, '_peaks', $peaks);
 
2325
  wp_send_json_success(array('peaks' => $peaks));
2326
  } else{
2327
  wp_send_json_error();
@@ -2452,21 +2454,38 @@ function gmedia_module_load_comments(){
2452
  }
2453
 
2454
  add_action('wp_ajax_gmedia_get_data', 'gmedia_get_data');
 
2455
  function gmedia_get_data(){
2456
- global $gmDB, $gmProcessor;
2457
 
2458
  /** @var $gmProcessorLibrary */
2459
  include_once(GMEDIA_ABSPATH . 'admin/processor/class.processor.library.php');
2460
 
2461
  $gmProcessorLibrary->user_options = $gmProcessor::user_options();
2462
  $query_args = $gmProcessorLibrary->query_args();
2463
- $gmedia_query = $gmDB->get_gmedias($query_args);
2464
- foreach($gmedia_query as &$item) {
2465
- gmedia_item_more_data( $item );
 
 
2466
  }
2467
 
2468
- header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
2469
- echo json_encode($gmedia_query);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2470
 
2471
  die();
2472
  }
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);
2323
  }
2324
 
2325
  $gmDB->update_metadata('gmedia', $id, '_peaks', $peaks);
2326
+ do_action( 'clean_gmedia_cache', $id );
2327
  wp_send_json_success(array('peaks' => $peaks));
2328
  } else{
2329
  wp_send_json_error();
2454
  }
2455
 
2456
  add_action('wp_ajax_gmedia_get_data', 'gmedia_get_data');
2457
+ add_action('wp_ajax_nopriv_gmedia_get_data', 'gmedia_get_data');
2458
  function gmedia_get_data(){
2459
+ global $gmDB, $gmProcessor, $gmGallery;
2460
 
2461
  /** @var $gmProcessorLibrary */
2462
  include_once(GMEDIA_ABSPATH . 'admin/processor/class.processor.library.php');
2463
 
2464
  $gmProcessorLibrary->user_options = $gmProcessor::user_options();
2465
  $query_args = $gmProcessorLibrary->query_args();
2466
+
2467
+ $cache_expiration = isset($gmGallery->options['cache_expiration'])? (int) $gmGallery->options['cache_expiration'] * HOUR_IN_SECONDS : 24 * HOUR_IN_SECONDS;
2468
+ if($cache_expiration) {
2469
+ $cache_key = 'gm_cache_' . md5( json_encode( $query_args ) );
2470
+ $cache_value = get_transient( $cache_key );
2471
  }
2472
 
2473
+ if(!empty( $cache_value)) {
2474
+ header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
2475
+ echo $cache_value;
2476
+ } else {
2477
+ $gmedia_query = $gmDB->get_gmedias( $query_args );
2478
+ foreach ( $gmedia_query as &$item ) {
2479
+ gmedia_item_more_data( $item );
2480
+ }
2481
+ $json_string = json_encode( $gmedia_query );
2482
+ if($cache_expiration) {
2483
+ set_transient( $cache_key, $json_string, $cache_expiration );
2484
+ }
2485
+
2486
+ header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ), true );
2487
+ echo $json_string;
2488
+ }
2489
 
2490
  die();
2491
  }
admin/app.php CHANGED
@@ -84,10 +84,10 @@ function gmediaApp(){
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>
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>
admin/assets/css/gmedia-block.css ADDED
@@ -0,0 +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
+ }
admin/assets/css/gmedia.admin.css CHANGED
@@ -1,3 +1,4 @@
 
1
  .grand-media-admin-page #wpbody-content > .update-nag,
2
  .grand-media-admin-page #wpbody-content > .updated.fade {display:none;}
3
  #adminmenuback {z-index:0}
@@ -110,6 +111,10 @@ div#gmedia-container {
110
  div#gmedia-container * {
111
  box-sizing:inherit;
112
  }
 
 
 
 
113
 
114
  body.gmedia-blank div#gmedia-container {
115
  margin:0;
@@ -1314,7 +1319,7 @@ div#wp-link-wrap label {
1314
  }
1315
 
1316
  .input-group.gmedia_date input {
1317
- pointer-events: none;
1318
  }
1319
 
1320
  @media (min-width:782px) {
@@ -1443,12 +1448,12 @@ div#wp-link-wrap label {
1443
  *border-left-color:#ffffff;
1444
  }
1445
  /* custom badge colors */
1446
- .badge-error {background-color: #b94a48;}
1447
- .badge-error:hover {background-color: #953b39;}
1448
  .badge-warning {background-color: #f89406;}
1449
  .badge-warning:hover {background-color: #c67605;}
1450
- .badge-success {background-color: #468847;}
1451
- .badge-success:hover {background-color: #356635; }
1452
  .badge-info {background-color: #3a87ad;}
1453
  .badge-info:hover {background-color: #2d6987;}
1454
  .badge-inverse {background-color: #333333;}
@@ -1631,6 +1636,10 @@ select[multiple].input-group-xs > .input-group-btn > .btn {
1631
  margin: 2px 0 0 0
1632
  }
1633
 
 
 
 
 
1634
  /* Spectrum */
1635
  .form-group .sp-replacer {
1636
  width: 100%;
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}
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
  body.gmedia-blank div#gmedia-container {
120
  margin:0;
1319
  }
1320
 
1321
  .input-group.gmedia_date input {
1322
+ background: #ffffff;
1323
  }
1324
 
1325
  @media (min-width:782px) {
1448
  *border-left-color:#ffffff;
1449
  }
1450
  /* custom badge colors */
1451
+ .badge-error {background-color: #b94a48 !important; color: #fff !important;}
1452
+ .badge-error:hover {background-color: #953b39 !important; color: #fff !important;}
1453
  .badge-warning {background-color: #f89406;}
1454
  .badge-warning:hover {background-color: #c67605;}
1455
+ .badge-success {background-color: #468847 !important; color: #fff !important;}
1456
+ .badge-success:hover {background-color: #356635 !important; color: #fff !important;}
1457
  .badge-info {background-color: #3a87ad;}
1458
  .badge-info:hover {background-color: #2d6987;}
1459
  .badge-inverse {background-color: #333333;}
1636
  margin: 2px 0 0 0
1637
  }
1638
 
1639
+ .gm-module-count-0 {
1640
+ display: none;
1641
+ }
1642
+
1643
  /* Spectrum */
1644
  .form-group .sp-replacer {
1645
  width: 100%;
admin/assets/css/gmedia.metabox.css CHANGED
@@ -2,7 +2,7 @@
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%; padding: }
6
  .inside #gmedia-wraper .form-group select { display:block; width:100%; }
7
  /*
8
  div#gmedia-MetaBox .inside { margin:0; padding:0; }
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; }
admin/assets/img/gmedia-icon-320x240.png ADDED
Binary file
admin/assets/js/gmedia-block.js ADDED
@@ -0,0 +1,434 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function(blocks, element) {
2
+ var el = element.createElement,
3
+ source = blocks.source;
4
+
5
+ function GmediaGallery(atts) {
6
+ var id = atts.id;
7
+ var tagtext = '[gmedia id=' + id + ']';
8
+
9
+ return el('div', {className: 'gmedia-shortcode'}, tagtext);
10
+ }
11
+
12
+ function GmediaTerm(atts, type) {
13
+ var id = atts.id;
14
+ var module = atts.module_name ? ' module=' + atts.module_name : '';
15
+ var preset = atts.module_preset ? ' preset=' + atts.module_preset : '';
16
+ type = type || 'id';
17
+ var tagtext = '[gm ' + type + '=' + id + module + preset + ']';
18
+
19
+ return el('div', {className: 'gmedia-shortcode'}, tagtext);
20
+ }
21
+
22
+ blocks.registerBlockType('gmedia/gallery', {
23
+ title: 'Gmedia Gallery',
24
+ icon: 'format-gallery',
25
+ category: 'common',
26
+ attributes: {
27
+ id: {
28
+ type: 'integer'
29
+ }
30
+ },
31
+
32
+ edit: function(props) {
33
+ var id = props.attributes.id;
34
+ var elclass = 'gmedia-id';
35
+ var image = gmedia_data.gmedia_image;
36
+ var form_fields = [];
37
+ var children = [];
38
+ var options = [];
39
+
40
+ function setGallery(event) {
41
+ event.preventDefault();
42
+ var form = jQuery(event.target).closest('form.gmedia-preview');
43
+ var id = parseInt(form.find('.gmedia-id').val());
44
+ props.setAttributes({
45
+ id: id
46
+ });
47
+ }
48
+
49
+ form_fields.push(
50
+ el('h3', null, 'Gmedia Gallery')
51
+ );
52
+
53
+ // Choose galleries
54
+ Object.keys(gmedia_data.galleries).forEach(function(key) {
55
+ options.push(
56
+ el('option', {value: gmedia_data.galleries[key].term_id}, gmedia_data.galleries[key].name)
57
+ );
58
+ });
59
+ if(!id) {
60
+ elclass += ' gmedia-required';
61
+ }
62
+ form_fields.push(
63
+ el('select', {className: elclass, value: id, onChange: setGallery}, options)
64
+ );
65
+
66
+ if(id) {
67
+ form_fields.push(GmediaGallery(props.attributes));
68
+ }
69
+
70
+ children.push(
71
+ el('div', {className: 'form-fields'}, form_fields)
72
+ );
73
+
74
+ if(id) {
75
+ var module = gmedia_data.galleries[id].module_name;
76
+ image = gmedia_data.modules[module].screenshot;
77
+ }
78
+ children.push(
79
+ el('img', {className: 'gmedia-module-screenshot', src: image})
80
+ );
81
+
82
+ return el('form', {className: 'gmedia-preview', onSubmit: setGallery}, children);
83
+ },
84
+
85
+ save: function(props) {
86
+ if(typeof props.attributes.id == 'undefined') {
87
+ return;
88
+ }
89
+ return GmediaGallery(props.attributes);
90
+ }
91
+
92
+ });
93
+
94
+ blocks.registerBlockType('gmedia/album', {
95
+ title: 'Gmedia Album',
96
+ icon: 'format-gallery',
97
+ category: 'common',
98
+ attributes: {
99
+ id: {
100
+ type: 'integer'
101
+ },
102
+ module_name: {
103
+ type: 'string'
104
+ },
105
+ module_preset: {
106
+ type: 'string'
107
+ }
108
+ },
109
+
110
+ edit: function(props) {
111
+ var id = props.attributes.id;
112
+ var module_name = props.attributes.module_name;
113
+ var module = props.attributes.module_preset? props.attributes.module_preset : module_name;
114
+ var default_module = gmedia_data.default_module;
115
+ var elclass = 'gmedia-id';
116
+ var image = gmedia_data.gmedia_image;
117
+ var form_fields = [];
118
+ var children = [];
119
+ var modules = [];
120
+ var options = [];
121
+
122
+ function setGallery(event) {
123
+ event.preventDefault();
124
+ var form = jQuery(event.target).closest('form.gmedia-preview');
125
+ var id = parseInt(form.find('.gmedia-id').val());
126
+ var module = form.find('.gmedia-overwrite-module');
127
+ var module_name = module.find('option:selected');
128
+ var module_preset = '';
129
+ if(module_name.attr('value')) {
130
+ module_name = module_name.closest('optgroup').attr('module');
131
+ if(module.val() != module_name){
132
+ module_preset = module.val();
133
+ }
134
+ } else {
135
+ module_name = ''
136
+ }
137
+ props.setAttributes({
138
+ id: id,
139
+ module_name: module_name,
140
+ module_preset: module_preset
141
+ });
142
+ }
143
+
144
+ form_fields.push(
145
+ el('h3', null, 'Gmedia Album')
146
+ );
147
+
148
+ // Choose galleries
149
+ Object.keys(gmedia_data.albums).forEach(function(key) {
150
+ options.push(
151
+ el('option', {value: gmedia_data.albums[key].term_id}, gmedia_data.albums[key].name)
152
+ );
153
+ });
154
+ if(!id) {
155
+ elclass += ' gmedia-required';
156
+ }
157
+ form_fields.push(
158
+ el('select', {className: elclass, value: id, onChange: setGallery}, options)
159
+ );
160
+
161
+ modules.push(
162
+ el('option', {value: ''}, ' - default module -')
163
+ );
164
+ Object.keys(gmedia_data.modules_options).forEach(function(key) {
165
+ options = [];
166
+ Object.keys(gmedia_data.modules_options[key].options).forEach(function(m) {
167
+ options.push(
168
+ el('option', {value: m}, gmedia_data.modules_options[key].options[m])
169
+ );
170
+ });
171
+ modules.push(
172
+ el('optgroup', {label: gmedia_data.modules_options[key].title, module: key}, null, options),
173
+ );
174
+ });
175
+ form_fields.push(
176
+ el('select', {className: 'gmedia-overwrite-module', value: module, onChange: setGallery}, modules)
177
+ );
178
+
179
+ if(id) {
180
+ form_fields.push(GmediaTerm(props.attributes, 'album'));
181
+ }
182
+
183
+ children.push(
184
+ el('div', {className: 'form-fields'}, form_fields)
185
+ );
186
+
187
+ if(id) {
188
+ var term_module = gmedia_data.albums[id].module_name;
189
+ image = module_name ? gmedia_data.modules[module_name].screenshot : (term_module ? gmedia_data.modules[term_module].screenshot : gmedia_data.modules[default_module].screenshot);
190
+ }
191
+ children.push(
192
+ el('img', {className: 'gmedia-module-screenshot', src: image})
193
+ );
194
+
195
+ return el('form', {className: 'gmedia-preview', onSubmit: setGallery}, children);
196
+ },
197
+
198
+ save: function(props) {
199
+ if(typeof props.attributes.id == 'undefined') {
200
+ return;
201
+ }
202
+ return GmediaTerm(props.attributes, 'album');
203
+ }
204
+
205
+ });
206
+
207
+ blocks.registerBlockType('gmedia/category', {
208
+ title: 'Gmedia Category',
209
+ icon: 'format-gallery',
210
+ category: 'common',
211
+ attributes: {
212
+ id: {
213
+ type: 'integer'
214
+ },
215
+ module_name: {
216
+ type: 'string'
217
+ },
218
+ module_preset: {
219
+ type: 'string'
220
+ }
221
+ },
222
+
223
+ edit: function(props) {
224
+ var id = props.attributes.id;
225
+ var module_name = props.attributes.module_name;
226
+ var module = props.attributes.module_preset? props.attributes.module_preset : module_name;
227
+ var default_module = gmedia_data.default_module;
228
+ var elclass = 'gmedia-id';
229
+ var image = gmedia_data.gmedia_image;
230
+ var form_fields = [];
231
+ var children = [];
232
+ var modules = [];
233
+ var options = [];
234
+
235
+ function setGallery(event) {
236
+ event.preventDefault();
237
+ var form = jQuery(event.target).closest('form.gmedia-preview');
238
+ var id = parseInt(form.find('.gmedia-id').val());
239
+ var module = form.find('.gmedia-overwrite-module');
240
+ var module_name = module.find('option:selected');
241
+ var module_preset = '';
242
+ if(module_name.attr('value')) {
243
+ module_name = module_name.closest('optgroup').attr('module');
244
+ if(module.val() != module_name){
245
+ module_preset = module.val();
246
+ }
247
+ } else {
248
+ module_name = ''
249
+ }
250
+ props.setAttributes({
251
+ id: id,
252
+ module_name: module_name,
253
+ module_preset: module_preset
254
+ });
255
+ }
256
+
257
+ form_fields.push(
258
+ el('h3', null, 'Gmedia Category')
259
+ );
260
+
261
+ // Choose galleries
262
+ Object.keys(gmedia_data.categories).forEach(function(key) {
263
+ options.push(
264
+ el('option', {value: gmedia_data.categories[key].term_id}, gmedia_data.categories[key].name)
265
+ );
266
+ });
267
+ if(!id) {
268
+ elclass += ' gmedia-required';
269
+ }
270
+ form_fields.push(
271
+ el('select', {className: elclass, value: id, onChange: setGallery}, options)
272
+ );
273
+
274
+ modules.push(
275
+ el('option', {value: ''}, ' - default module -')
276
+ );
277
+ Object.keys(gmedia_data.modules_options).forEach(function(key) {
278
+ options = [];
279
+ Object.keys(gmedia_data.modules_options[key].options).forEach(function(m) {
280
+ options.push(
281
+ el('option', {value: m}, gmedia_data.modules_options[key].options[m])
282
+ );
283
+ });
284
+ modules.push(
285
+ el('optgroup', {label: gmedia_data.modules_options[key].title, module: key}, null, options),
286
+ );
287
+ });
288
+ form_fields.push(
289
+ el('select', {className: 'gmedia-overwrite-module', value: module, onChange: setGallery}, modules)
290
+ );
291
+
292
+ if(id) {
293
+ form_fields.push(GmediaTerm(props.attributes, 'category'));
294
+ }
295
+
296
+ children.push(
297
+ el('div', {className: 'form-fields'}, form_fields)
298
+ );
299
+
300
+ if(id) {
301
+ var term_module = gmedia_data.categories[id].module_name;
302
+ image = module_name ? gmedia_data.modules[module_name].screenshot : (term_module ? gmedia_data.modules[term_module].screenshot : gmedia_data.modules[default_module].screenshot);
303
+ }
304
+ children.push(
305
+ el('img', {className: 'gmedia-module-screenshot', src: image})
306
+ );
307
+
308
+ return el('form', {className: 'gmedia-preview', onSubmit: setGallery}, children);
309
+ },
310
+
311
+ save: function(props) {
312
+ if(typeof props.attributes.id == 'undefined') {
313
+ return;
314
+ }
315
+ return GmediaTerm(props.attributes, 'category');
316
+ }
317
+
318
+ });
319
+
320
+ blocks.registerBlockType('gmedia/tag', {
321
+ title: 'Gmedia Tag',
322
+ icon: 'format-gallery',
323
+ category: 'common',
324
+ attributes: {
325
+ id: {
326
+ type: 'integer'
327
+ },
328
+ module_name: {
329
+ type: 'string'
330
+ },
331
+ module_preset: {
332
+ type: 'string'
333
+ }
334
+ },
335
+
336
+ edit: function(props) {
337
+ var id = props.attributes.id;
338
+ var module_name = props.attributes.module_name;
339
+ var module = props.attributes.module_preset? props.attributes.module_preset : module_name;
340
+ var default_module = gmedia_data.default_module;
341
+ var elclass = 'gmedia-id';
342
+ var image = gmedia_data.gmedia_image;
343
+ var form_fields = [];
344
+ var children = [];
345
+ var modules = [];
346
+ var options = [];
347
+
348
+ function setGallery(event) {
349
+ event.preventDefault();
350
+ var form = jQuery(event.target).closest('form.gmedia-preview');
351
+ var id = parseInt(form.find('.gmedia-id').val());
352
+ var module = form.find('.gmedia-overwrite-module');
353
+ var module_name = module.find('option:selected');
354
+ var module_preset = '';
355
+ if(module_name.attr('value')) {
356
+ module_name = module_name.closest('optgroup').attr('module');
357
+ if(module.val() != module_name){
358
+ module_preset = module.val();
359
+ }
360
+ } else {
361
+ module_name = ''
362
+ }
363
+ props.setAttributes({
364
+ id: id,
365
+ module_name: module_name,
366
+ module_preset: module_preset
367
+ });
368
+ }
369
+
370
+ form_fields.push(
371
+ el('h3', null, 'Gmedia Tag')
372
+ );
373
+ // Choose galleries
374
+ Object.keys(gmedia_data.tags).forEach(function(key) {
375
+ options.push(
376
+ el('option', {value: gmedia_data.tags[key].term_id}, gmedia_data.tags[key].name)
377
+ );
378
+ });
379
+ if(!id) {
380
+ elclass += ' gmedia-required';
381
+ }
382
+ form_fields.push(
383
+ el('select', {className: elclass, value: id, onChange: setGallery}, options)
384
+ );
385
+
386
+ modules.push(
387
+ el('option', {value: ''}, ' - default module -')
388
+ );
389
+ Object.keys(gmedia_data.modules_options).forEach(function(key) {
390
+ options = [];
391
+ Object.keys(gmedia_data.modules_options[key].options).forEach(function(m) {
392
+ options.push(
393
+ el('option', {value: m}, gmedia_data.modules_options[key].options[m])
394
+ );
395
+ });
396
+ modules.push(
397
+ el('optgroup', {label: gmedia_data.modules_options[key].title, module: key}, null, options),
398
+ );
399
+ });
400
+ form_fields.push(
401
+ el('select', {className: 'gmedia-overwrite-module', value: module, onChange: setGallery}, modules)
402
+ );
403
+
404
+ if(id) {
405
+ form_fields.push(GmediaTerm(props.attributes, 'tag'));
406
+ }
407
+
408
+ children.push(
409
+ el('div', {className: 'form-fields'}, form_fields)
410
+ );
411
+
412
+ if(id) {
413
+ var term_module = gmedia_data.tags[id].module_name;
414
+ image = module_name ? gmedia_data.modules[module_name].screenshot : (term_module ? gmedia_data.modules[term_module].screenshot : gmedia_data.modules[default_module].screenshot);
415
+ }
416
+ children.push(
417
+ el('img', {className: 'gmedia-module-screenshot', src: image})
418
+ );
419
+
420
+ return el('form', {className: 'gmedia-preview', onSubmit: setGallery}, children);
421
+ },
422
+
423
+ save: function(props) {
424
+ if(typeof props.attributes.id == 'undefined') {
425
+ return;
426
+ }
427
+ return GmediaTerm(props.attributes, 'tag');
428
+ }
429
+
430
+ });
431
+ })(
432
+ window.wp.blocks,
433
+ window.wp.element
434
+ );
admin/assets/js/gmedia.admin.js CHANGED
@@ -298,11 +298,11 @@ var GmediaLibrary = {
298
 
299
  // Date/Time picker
300
  var gmedia_date_temp;
301
- jQuery('.input-group.gmedia_date').datetimepicker({format: 'YYYY-MM-DD HH:mm:ss', focusOnShow: false}).on('dp.show', function() {
302
  gmedia_date_temp = jQuery('input', this).val();
303
  }).on('dp.hide', function() {
304
- if(gmedia_date_temp != jQuery('input', this).val()) {
305
- jQuery('input', this).trigger('change');
306
  }
307
  });
308
 
@@ -1288,7 +1288,7 @@ var GmediaFunction = {
1288
  return !!jQuery(this).val();
1289
  });
1290
 
1291
- var qform = decodeURIComponent(qform.serialize());
1292
  console.log(qform);
1293
  jQuery('#build_query_field').val(qform);
1294
  jQuery('#buildQuery').modal('hide');
@@ -1371,7 +1371,7 @@ var GmediaFunction = {
1371
  });
1372
 
1373
 
1374
- gmedia_DOM.on('change', 'form.edit-gmedia :input:not([name="doaction[]"])', function() {
1375
  if(jQuery(this).hasClass('edit-gmedia-ignore')) {
1376
  return;
1377
  }
298
 
299
  // Date/Time picker
300
  var gmedia_date_temp;
301
+ jQuery('.input-group.gmedia_date').datetimepicker({format: 'YYYY-MM-DD HH:mm:ss', focusOnShow: true, ignoreReadonly: true, allowInputToggle: true}).on('dp.show', function() {
302
  gmedia_date_temp = jQuery('input', this).val();
303
  }).on('dp.hide', function() {
304
+ if(jQuery('input', this).val() !== gmedia_date_temp) {
305
+ jQuery('input', this).trigger('modified');
306
  }
307
  });
308
 
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');
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
  }
admin/logs.php CHANGED
@@ -55,7 +55,7 @@ if(isset($_GET['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(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]);
59
 
60
  $n = '%';
61
  $searchand = '';
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 = '';
admin/pages/galleries/tpl/modal-build-query.php CHANGED
@@ -154,8 +154,7 @@ global $user_ID, $gmDB, $gmCore
154
  <div class="pull-right">
155
  <a id="_use_lib_selected" title="<?php _e('Select Media', 'grand-media'); ?>" href="<?php echo $gmCore->get_admin_url(array('page' => 'GrandMedia',
156
  'mode' => 'select_multiple',
157
- 'gmediablank' => 'library',
158
- 'filter' => 'image'
159
  ), 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>
160
  </div>
161
  <label><?php _e('Gmedia IDs <small class="text-muted">separated by comma</small>', 'grand-media'); ?> </label>
@@ -519,7 +518,7 @@ global $user_ID, $gmDB, $gmCore
519
  $('input.gm-selectize, select.gm-selectize', '#buildQuery').each(function(){
520
  this.selectize.clear();
521
  });
522
- $('input[type="text"], select', '#buildQuery').each(function(){
523
  $(this).val('');
524
  });
525
  $('input[type="checkbox"]', '#buildQuery').prop('checked', false);
154
  <div class="pull-right">
155
  <a id="_use_lib_selected" title="<?php _e('Select Media', 'grand-media'); ?>" href="<?php echo $gmCore->get_admin_url(array('page' => 'GrandMedia',
156
  'mode' => 'select_multiple',
157
+ 'gmediablank' => 'library'
 
158
  ), 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>
159
  </div>
160
  <label><?php _e('Gmedia IDs <small class="text-muted">separated by comma</small>', 'grand-media'); ?> </label>
518
  $('input.gm-selectize, select.gm-selectize', '#buildQuery').each(function(){
519
  this.selectize.clear();
520
  });
521
+ $('input[type="text"], select, textarea', '#buildQuery').each(function(){
522
  $(this).val('');
523
  });
524
  $('input[type="checkbox"]', '#buildQuery').prop('checked', false);
admin/pages/library/tpl/edit-item.php CHANGED
@@ -195,7 +195,7 @@ if ( ! defined( 'ABSPATH' ) ) {
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; ?>" tabindex="-1"/>
199
  <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
200
  </div>
201
  </div>
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"><span class="glyphicon glyphicon-calendar"></span></span>
200
  </div>
201
  </div>
admin/pages/modules/modules.php CHANGED
@@ -37,8 +37,8 @@ if(isset($modules['error'])){
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="installed" class="btn btn-primary"><?php _e('Modules', 'grand-media'); ?></button>
41
- <button type="button" data-filter="not-installed" class="btn btn-default"><?php _e('Add New', 'grand-media'); ?></button>
42
  <button type="button" data-filter="tag-trend" class="btn btn-default"><?php _e('Trends', 'grand-media'); ?></button>
43
  </div>
44
 
@@ -67,7 +67,7 @@ if(isset($modules['error'])){
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-installed';
71
  if($module['update']){
72
  $module['mclass'] .= ' module-update';
73
  }
@@ -85,7 +85,7 @@ if(isset($modules['error'])){
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-not-installed';
89
  if($module['update']){
90
  $module['mclass'] .= ' module-update';
91
  }
@@ -101,7 +101,7 @@ if(isset($modules['error'])){
101
  wp_nonce_field('GmediaGallery');
102
  ?>
103
  <div class="media nomodules nomodule-not-installed">
104
- <h4 class="media-heading"><?php _e('No uninstalled modules', '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>
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
 
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
  }
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
  }
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>
admin/pages/settings/tpl/common.php CHANGED
@@ -34,6 +34,17 @@ if(!defined('ABSPATH')){
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 row">
39
  <div class="col-xs-6">
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">
admin/pages/settings/tpl/license.php CHANGED
@@ -89,6 +89,14 @@ if( !defined('ABSPATH')){
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
  </fieldset>
93
 
94
  </fieldset>
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>
admin/processor/class.processor.modules.php CHANGED
@@ -118,6 +118,7 @@ class GmediaProcessor_Modules extends GmediaProcessor{
118
  if(('save' == $gmCore->_get('message')) && ($term_id = $gmCore->_get('preset'))){
119
  $gmedia_new_preset_id = get_transient('gmedia_new_preset_id');
120
  if(false !== $gmedia_new_preset_id){
 
121
  delete_transient('gmedia_new_preset_id');
122
  $this->msg[] = sprintf(__('Preset #%d successfully saved', 'grand-media'), $term_id);
123
  }
@@ -176,6 +177,7 @@ class GmediaProcessor_Modules extends GmediaProcessor{
176
  $this->msg[] = sprintf(__("The `%s` file unzipped to module's directory", 'grand-media'), $filename);
177
  }
178
  }
 
179
  } else{
180
  $this->error[] = __('No file specified', 'grand-media');
181
  }
@@ -193,6 +195,7 @@ class GmediaProcessor_Modules extends GmediaProcessor{
193
  wp_redirect($location);
194
  }
195
  } elseif(false !== ($message = get_transient('gmedia_module_deleted'))){
 
196
  delete_transient('gmedia_module_deleted');
197
  $this->msg[] = $message;
198
  }
118
  if(('save' == $gmCore->_get('message')) && ($term_id = $gmCore->_get('preset'))){
119
  $gmedia_new_preset_id = get_transient('gmedia_new_preset_id');
120
  if(false !== $gmedia_new_preset_id){
121
+ gmedia_delete_transients( 'gm_cache' );
122
  delete_transient('gmedia_new_preset_id');
123
  $this->msg[] = sprintf(__('Preset #%d successfully saved', 'grand-media'), $term_id);
124
  }
177
  $this->msg[] = sprintf(__("The `%s` file unzipped to module's directory", 'grand-media'), $filename);
178
  }
179
  }
180
+ gmedia_delete_transients( 'gm_cache' );
181
  } else{
182
  $this->error[] = __('No file specified', 'grand-media');
183
  }
195
  wp_redirect($location);
196
  }
197
  } elseif(false !== ($message = get_transient('gmedia_module_deleted'))){
198
+ gmedia_delete_transients( 'gm_cache' );
199
  delete_transient('gmedia_module_deleted');
200
  $this->msg[] = $message;
201
  }
admin/processor/class.processor.settings.php CHANGED
@@ -29,6 +29,8 @@ class GmediaProcessor_Settings extends GmediaProcessor {
29
  $this->error[] = __('License Key empty...', 'grand-media');
30
  }
31
 
 
 
32
  $flush_rewrite_rules = false;
33
  if(empty($set['endpoint'])){
34
  $set['endpoint'] = 'gmedia';
@@ -127,6 +129,7 @@ class GmediaProcessor_Settings extends GmediaProcessor {
127
  if(isset($_POST['GmediaHashID_salt'])){
128
  update_option('GmediaHashID_salt', (string) $_POST['GmediaHashID_salt']);
129
  }
 
130
  if($flush_rewrite_rules){
131
  flush_rewrite_rules(false);
132
  }
@@ -208,6 +211,7 @@ class GmediaProcessor_Settings extends GmediaProcessor {
208
  $gmDB->set_capability('administrator', $cap);
209
  }
210
  }
 
211
  $this->msg[] .= __('All settings set to default', 'grand-media');
212
  }
213
 
29
  $this->error[] = __('License Key empty...', 'grand-media');
30
  }
31
 
32
+ $set['google_api_key'] = trim($set['google_api_key']);
33
+
34
  $flush_rewrite_rules = false;
35
  if(empty($set['endpoint'])){
36
  $set['endpoint'] = 'gmedia';
129
  if(isset($_POST['GmediaHashID_salt'])){
130
  update_option('GmediaHashID_salt', (string) $_POST['GmediaHashID_salt']);
131
  }
132
+ gmedia_delete_transients( 'gm_cache' );
133
  if($flush_rewrite_rules){
134
  flush_rewrite_rules(false);
135
  }
211
  $gmDB->set_capability('administrator', $cap);
212
  }
213
  }
214
+ gmedia_delete_transients( 'gm_cache' );
215
  $this->msg[] .= __('All settings set to default', 'grand-media');
216
  }
217
 
admin/processor/class.processor.wpmedia.php CHANGED
@@ -15,8 +15,6 @@ class GmediaProcessor_WordpressLibrary extends GmediaProcessor {
15
  public function __construct() {
16
  parent::__construct();
17
 
18
- global $user_ID;
19
-
20
  self::$cookie_key = "gmedia_library:wpmedia";
21
  $this->selected_items = parent::selected_items(self::$cookie_key);
22
 
15
  public function __construct() {
16
  parent::__construct();
17
 
 
 
18
  self::$cookie_key = "gmedia_library:wpmedia";
19
  $this->selected_items = parent::selected_items(self::$cookie_key);
20
 
app/access.php CHANGED
@@ -212,7 +212,16 @@ function gmedia_ios_app_library_data($data = array('site', 'authors', 'filter',
212
  }
213
  $args = array_merge(array('number' => $terms_per_page), (array)$args);
214
 
215
- $out = array();
 
 
 
 
 
 
 
 
 
216
 
217
  $ep = $gmGallery->options['endpoint'];
218
  if(get_option('permalink_structure')){
@@ -408,7 +417,11 @@ function gmedia_ios_app_library_data($data = array('site', 'authors', 'filter',
408
  );
409
  }
410
 
411
- return $out;
 
 
 
 
412
  }
413
 
414
  /**
@@ -494,7 +507,7 @@ function gmedia_ios_app_term_data_extend(&$term, $share_link_base, $logic = 0, $
494
  }
495
  if($term_meta['_cover']){
496
  $cover_id = (int)$term_meta['_cover'];
497
- $cover = gmedia_ios_app_processor('library', array('gmedia__in' => array($cover_id)), false);
498
  if(isset($cover['data'][0])){
499
  $term_meta['_cover'] = $cover['data'][0];
500
  $term->thumbnail = $gmCore->gm_get_media_image($cover_id, 'thumb', false);
@@ -519,7 +532,7 @@ function gmedia_ios_app_term_data_extend(&$term, $share_link_base, $logic = 0, $
519
 
520
  $termItems = $gmDB->get_gmedias($gmargs);
521
  if(!empty($termItems)){
522
- $cover = gmedia_ios_app_processor('library', array('gmedia__in' => array($termItems[0]->ID)), false);
523
  if(isset($cover['data'][0])){
524
  $term_meta['_cover'] = $cover['data'][0];
525
  $term->thumbnail = $gmCore->gm_get_media_image($termItems[0], 'thumb', false);
@@ -556,10 +569,11 @@ function gmedia_object_to_array($obj) {
556
  * @param $action
557
  * @param $data
558
  * @param bool $filter
 
559
  *
560
  * @return array
561
  */
562
- function gmedia_ios_app_processor($action, $data, $filter = true){
563
  global $gmCore, $gmDB, $gmGallery, $user_ID, $gmapp_version, $gmmodule;
564
 
565
  $out = array();
@@ -976,7 +990,17 @@ function gmedia_ios_app_processor($action, $data, $filter = true){
976
  break;
977
 
978
  case 'library':
979
- $ep = $gmGallery->options['endpoint'];
 
 
 
 
 
 
 
 
 
 
980
  if(get_option('permalink_structure')){
981
  $share_link_base = home_url(urlencode($ep) . '/$2/$1');
982
  } else{
@@ -1270,7 +1294,12 @@ function gmedia_ios_app_processor($action, $data, $filter = true){
1270
  $out = array_merge($filter, array('properties' => $properties,
1271
  'data' => array_values($gmedias)
1272
  ));
1273
- break;
 
 
 
 
 
1274
  case 'delete_term':
1275
  $taxonomy = $data['taxonomy'];
1276
  if(!empty($data['items'])){
@@ -1391,7 +1420,7 @@ function gmedia_ios_app_processor($action, $data, $filter = true){
1391
  if(!empty($data['per_page'])){
1392
  $lib_data['per_page'] = $data['per_page'];
1393
  }
1394
- $out = gmedia_ios_app_processor('library', $lib_data);
1395
  } else{
1396
  $out = gmedia_ios_app_library_data(array('filter', $taxonomy), $args);
1397
  }
@@ -1481,7 +1510,7 @@ function gmedia_ios_app_processor($action, $data, $filter = true){
1481
  if(!empty($data['per_page'])){
1482
  $lib_data['per_page'] = $data['per_page'];
1483
  }
1484
- $out = gmedia_ios_app_processor('library', $lib_data);
1485
  } else{
1486
  $out = gmedia_ios_app_library_data(array('filter', $taxonomy), $args);
1487
  }
@@ -1552,7 +1581,7 @@ function gmedia_ios_app_processor($action, $data, $filter = true){
1552
  if(!empty($data['per_page'])){
1553
  $lib_data['per_page'] = $data['per_page'];
1554
  }
1555
- $out = gmedia_ios_app_processor('library', $lib_data);
1556
  } else{
1557
  $out = gmedia_ios_app_library_data(array('filter', $taxonomy), $args);
1558
  }
212
  }
213
  $args = array_merge(array('number' => $terms_per_page), (array)$args);
214
 
215
+ $cache_expiration = isset($gmGallery->options['cache_expiration'])? (int) $gmGallery->options['cache_expiration'] * HOUR_IN_SECONDS : 24 * HOUR_IN_SECONDS;
216
+ if($cache_expiration) {
217
+ $cache_key = 'gm_cache_' . md5( json_encode( array( (int) $user_ID, $data, $args, $gmmodule, $gmapp_version ) ) );
218
+ $cache_value = get_transient( $cache_key );
219
+ if ( ! empty( $cache_value ) && is_array( $cache_value ) ) {
220
+ return $cache_value;
221
+ }
222
+ }
223
+
224
+ $out = array();
225
 
226
  $ep = $gmGallery->options['endpoint'];
227
  if(get_option('permalink_structure')){
417
  );
418
  }
419
 
420
+ if($cache_expiration) {
421
+ set_transient( $cache_key, $out, $cache_expiration );
422
+ }
423
+
424
+ return $out;
425
  }
426
 
427
  /**
507
  }
508
  if($term_meta['_cover']){
509
  $cover_id = (int)$term_meta['_cover'];
510
+ $cover = gmedia_ios_app_processor('library', array('gmedia__in' => array($cover_id)), false, false);
511
  if(isset($cover['data'][0])){
512
  $term_meta['_cover'] = $cover['data'][0];
513
  $term->thumbnail = $gmCore->gm_get_media_image($cover_id, 'thumb', false);
532
 
533
  $termItems = $gmDB->get_gmedias($gmargs);
534
  if(!empty($termItems)){
535
+ $cover = gmedia_ios_app_processor('library', array('gmedia__in' => array($termItems[0]->ID)), false, false);
536
  if(isset($cover['data'][0])){
537
  $term_meta['_cover'] = $cover['data'][0];
538
  $term->thumbnail = $gmCore->gm_get_media_image($termItems[0], 'thumb', false);
569
  * @param $action
570
  * @param $data
571
  * @param bool $filter
572
+ * @param bool $cache
573
  *
574
  * @return array
575
  */
576
+ function gmedia_ios_app_processor($action, $data, $filter = true, $cache = true){
577
  global $gmCore, $gmDB, $gmGallery, $user_ID, $gmapp_version, $gmmodule;
578
 
579
  $out = array();
990
  break;
991
 
992
  case 'library':
993
+ $cache_expiration = isset($gmGallery->options['cache_expiration'])? (int) $gmGallery->options['cache_expiration'] * HOUR_IN_SECONDS : 24 * HOUR_IN_SECONDS;
994
+ if($cache && $cache_expiration) {
995
+ $cache_key = 'gm_cache_' . md5( json_encode( array( (int) $user_ID, $data, $filter, $gmmodule, $gmapp_version ) ) );
996
+ $cache_value = get_transient( $cache_key );
997
+ if ( ! empty( $cache_value ) && is_array( $cache_value ) ) {
998
+ $out = $cache_value;
999
+ break;
1000
+ }
1001
+ }
1002
+
1003
+ $ep = $gmGallery->options['endpoint'];
1004
  if(get_option('permalink_structure')){
1005
  $share_link_base = home_url(urlencode($ep) . '/$2/$1');
1006
  } else{
1294
  $out = array_merge($filter, array('properties' => $properties,
1295
  'data' => array_values($gmedias)
1296
  ));
1297
+
1298
+ if($cache && $cache_expiration) {
1299
+ set_transient( $cache_key, $out, $cache_expiration );
1300
+ }
1301
+
1302
+ break;
1303
  case 'delete_term':
1304
  $taxonomy = $data['taxonomy'];
1305
  if(!empty($data['items'])){
1420
  if(!empty($data['per_page'])){
1421
  $lib_data['per_page'] = $data['per_page'];
1422
  }
1423
+ $out = gmedia_ios_app_processor('library', $lib_data, true, false);
1424
  } else{
1425
  $out = gmedia_ios_app_library_data(array('filter', $taxonomy), $args);
1426
  }
1510
  if(!empty($data['per_page'])){
1511
  $lib_data['per_page'] = $data['per_page'];
1512
  }
1513
+ $out = gmedia_ios_app_processor('library', $lib_data, true, false);
1514
  } else{
1515
  $out = gmedia_ios_app_library_data(array('filter', $taxonomy), $args);
1516
  }
1581
  if(!empty($data['per_page'])){
1582
  $lib_data['per_page'] = $data['per_page'];
1583
  }
1584
+ $out = gmedia_ios_app_processor('library', $lib_data, true, false);
1585
  } else{
1586
  $out = gmedia_ios_app_library_data(array('filter', $taxonomy), $args);
1587
  }
assets/jq-plugins/jquery.alphanum.js CHANGED
@@ -58,7 +58,7 @@
58
  allowLower : true, // Allow lower case characters
59
  allowCaseless : true, // Allow characters that don't have both upper & lower variants - eg Arabic or Chinese
60
  allowLatin : true, // a-z A-Z
61
- allowOtherCharSets : true, // eg �, �, Arabic, Chinese etc
62
  forceUpper : false, // Convert lower case characters to upper case
63
  forceLower : false, // Convert upper case characters to lower case
64
  maxLength : NaN // eg Max Length
@@ -132,10 +132,10 @@
132
  // Not too worried about comments containing higher order characters for now (let's wait and see if it becomes a problem)
133
  function getBlacklistNonAscii(){
134
  var blacklist =
135
- "\xAC" //
136
- + "\u20AC" //
137
- + "\xA3" //
138
- + "\xA6" //
139
  ;
140
  return blacklist;
141
  }
58
  allowLower : true, // Allow lower case characters
59
  allowCaseless : true, // Allow characters that don't have both upper & lower variants - eg Arabic or Chinese
60
  allowLatin : true, // a-z A-Z
61
+ allowOtherCharSets : true, // eg é, Á, Arabic, Chinese etc
62
  forceUpper : false, // Convert lower case characters to upper case
63
  forceLower : false, // Convert upper case characters to lower case
64
  maxLength : NaN // eg Max Length
132
  // Not too worried about comments containing higher order characters for now (let's wait and see if it becomes a problem)
133
  function getBlacklistNonAscii(){
134
  var blacklist =
135
+ "\xAC" // ¬
136
+ + "\u20AC" // €
137
+ + "\xA3" // £
138
+ + "\xA6" // ¦
139
  ;
140
  return blacklist;
141
  }
config/setup.php CHANGED
@@ -17,7 +17,10 @@ function gmedia_default_options(){
17
  $gm['site_ID'] = '';
18
  $gm['mobile_app'] = 0;
19
 
20
- $gm['modules_update'] = 0;
 
 
 
21
 
22
  $gm['gmedia_post_slug'] = 'gmedia';
23
  $gm['gmedia_exclude_from_search'] = '0';
17
  $gm['site_ID'] = '';
18
  $gm['mobile_app'] = 0;
19
 
20
+ $gm['modules_update'] = 0;
21
+ $gm['modules_new'] = 0;
22
+ $gm['cache_expiration'] = 24;
23
+ $gm['disable_ads'] = '0';
24
 
25
  $gm['gmedia_post_slug'] = 'gmedia';
26
  $gm['gmedia_exclude_from_search'] = '0';
config/update.php CHANGED
@@ -788,7 +788,7 @@ function gmedia_quite_update(){
788
  foreach($categories as $c){
789
  if(isset($cats[ $c->name ])){
790
  $wpdb->update($wpdb->prefix . 'gmedia_term', array('name' => $cats[ $c->name ]), array('term_id' => $c->term_id));
791
- $gmDB->clean_term_cache($c->term_id, 'gmedia_category');
792
  }
793
  }
794
  }
788
  foreach($categories as $c){
789
  if(isset($cats[ $c->name ])){
790
  $wpdb->update($wpdb->prefix . 'gmedia_term', array('name' => $cats[ $c->name ]), array('term_id' => $c->term_id));
791
+ $gmDB->clean_term_cache($c->term_id);
792
  }
793
  }
794
  }
grand-media.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Gmedia Gallery
4
  * Plugin URI: http://wordpress.org/extend/plugins/grand-media/
5
  * Description: Gmedia Gallery - powerful media library plugin for creating beautiful galleries and managing files.
6
- * Version: 1.13.4
7
  * Author: Rattus
8
  * Author URI: https://codeasily.com/
9
  * Requires at least: 3.7
@@ -42,7 +42,7 @@ if( !class_exists('Gmedia')){
42
  */
43
  class Gmedia {
44
 
45
- var $version = '1.13.4';
46
  var $dbversion = '1.8.0';
47
  var $minium_WP = '3.7';
48
  var $options = '';
@@ -102,6 +102,7 @@ if( !class_exists('Gmedia')){
102
  add_action('deleted_user', array(&$this, 'reassign_media'), 10, 2);
103
 
104
  add_action('init', array(&$this, 'gmedia_post_type'), 0);
 
105
  //add_action('init', array(&$this, 'gm_schedule_update_checks'), 0);
106
 
107
  // register widget
@@ -121,16 +122,16 @@ if( !class_exists('Gmedia')){
121
  function start_plugin(){
122
 
123
  $this->load_dependencies();
124
- $this->compatibility();
125
 
126
  // Load the language file
127
  $this->load_textdomain();
128
 
129
- // Check for upgrade
130
- $this->upgrade();
131
 
132
- require_once(dirname(__FILE__) . '/inc/hashids.php');
133
- require_once(dirname(__FILE__) . '/inc/functions.php');
 
 
134
  require_once(dirname(__FILE__) . '/inc/shortcodes.php');
135
 
136
  // Load the admin panel or the frontend functions
@@ -200,9 +201,6 @@ if( !class_exists('Gmedia')){
200
  }
201
  if(version_compare('5.3', phpversion(), '>')){
202
  $note = sprintf(__('Attention! Your server php version is: %s. Gmedia Gallery requires php version 5.3+ in order to run properly. Please upgrade your server!', 'grand-media'), phpversion());
203
- if(ini_get('safe_mode')){
204
- $note .= '<br/>' . __('Attention! Your server safe mode is: ON. Gmedia Gallery requires safe mode to be OFF in order to run properly. Please set your server safe mode option!', 'grand-media');
205
- }
206
  update_option('gmediaInitCheck', $note);
207
  add_action('admin_notices', array(&$this, 'admin_notices'));
208
 
@@ -261,6 +259,7 @@ if( !class_exists('Gmedia')){
261
  require_once(dirname(__FILE__) . '/config/update.php');
262
 
263
  gmedia_quite_update();
 
264
  add_action('init', 'gmedia_flush_rewrite_rules', 1000);
265
 
266
  if((int) $this->options['mobile_app']){
@@ -352,8 +351,8 @@ if( !class_exists('Gmedia')){
352
  'google_api_key'=> $this->options['google_api_key']
353
  ));
354
 
355
- wp_register_style('grand-media', $gmCore->gmedia_url . '/admin/assets/css/gmedia.admin.css', array(), '1.13.0', 'all');
356
- wp_register_script('grand-media', $gmCore->gmedia_url . '/admin/assets/js/gmedia.admin.js', array('jquery', 'gmedia-global-backend'), '1.13.0');
357
  wp_localize_script('grand-media', 'grandMedia', array(
358
  'error3' => __('Disable your Popup Blocker and try again.', 'grand-media'),
359
  'download' => __('downloading...', 'grand-media'),
@@ -369,7 +368,7 @@ if( !class_exists('Gmedia')){
369
  }
370
 
371
  function register_scripts_frontend(){
372
- global $gmCore, $wp_scripts, $wp;
373
 
374
  wp_register_style('gmedia-global-frontend', $gmCore->gmedia_url . '/assets/gmedia.global.front.css', array(), '1.12.11');
375
  wp_register_script('gmedia-global-frontend', $gmCore->gmedia_url . '/assets/gmedia.global.front.js', array('jquery'), '1.13.0');
3
  * Plugin Name: Gmedia Gallery
4
  * Plugin URI: http://wordpress.org/extend/plugins/grand-media/
5
  * Description: Gmedia Gallery - powerful media library plugin for creating beautiful galleries and managing files.
6
+ * Version: 1.14.7
7
  * Author: Rattus
8
  * Author URI: https://codeasily.com/
9
  * Requires at least: 3.7
42
  */
43
  class Gmedia {
44
 
45
+ var $version = '1.14.7';
46
  var $dbversion = '1.8.0';
47
  var $minium_WP = '3.7';
48
  var $options = '';
102
  add_action('deleted_user', array(&$this, 'reassign_media'), 10, 2);
103
 
104
  add_action('init', array(&$this, 'gmedia_post_type'), 0);
105
+ add_action('init', array(&$this, 'compatibility'), 11);
106
  //add_action('init', array(&$this, 'gm_schedule_update_checks'), 0);
107
 
108
  // register widget
122
  function start_plugin(){
123
 
124
  $this->load_dependencies();
 
125
 
126
  // Load the language file
127
  $this->load_textdomain();
128
 
129
+ require_once(dirname(__FILE__) . '/inc/functions.php');
 
130
 
131
+ // Check for upgrade
132
+ $this->upgrade();
133
+
134
+ require_once(dirname(__FILE__) . '/inc/hashids.php');
135
  require_once(dirname(__FILE__) . '/inc/shortcodes.php');
136
 
137
  // Load the admin panel or the frontend functions
201
  }
202
  if(version_compare('5.3', phpversion(), '>')){
203
  $note = sprintf(__('Attention! Your server php version is: %s. Gmedia Gallery requires php version 5.3+ in order to run properly. Please upgrade your server!', 'grand-media'), phpversion());
 
 
 
204
  update_option('gmediaInitCheck', $note);
205
  add_action('admin_notices', array(&$this, 'admin_notices'));
206
 
259
  require_once(dirname(__FILE__) . '/config/update.php');
260
 
261
  gmedia_quite_update();
262
+ gmedia_delete_transients( 'gm_cache' );
263
  add_action('init', 'gmedia_flush_rewrite_rules', 1000);
264
 
265
  if((int) $this->options['mobile_app']){
351
  'google_api_key'=> $this->options['google_api_key']
352
  ));
353
 
354
+ wp_register_style('grand-media', $gmCore->gmedia_url . '/admin/assets/css/gmedia.admin.css', array(), '1.14.7', 'all');
355
+ wp_register_script('grand-media', $gmCore->gmedia_url . '/admin/assets/js/gmedia.admin.js', array('jquery', 'gmedia-global-backend'), '1.14.7');
356
  wp_localize_script('grand-media', 'grandMedia', array(
357
  'error3' => __('Disable your Popup Blocker and try again.', 'grand-media'),
358
  'download' => __('downloading...', 'grand-media'),
368
  }
369
 
370
  function register_scripts_frontend(){
371
+ global $gmCore, $wp_scripts;
372
 
373
  wp_register_style('gmedia-global-frontend', $gmCore->gmedia_url . '/assets/gmedia.global.front.css', array(), '1.12.11');
374
  wp_register_script('gmedia-global-frontend', $gmCore->gmedia_url . '/assets/gmedia.global.front.js', array('jquery'), '1.13.0');
inc/compatibility.php CHANGED
@@ -19,6 +19,33 @@ function jetpack_photon_skip_gmedia($skip, $src){
19
  return $skip;
20
  }
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  /**
23
  * WP-SpamShield plugin compatibility
24
  * @param $pass
19
  return $skip;
20
  }
21
 
22
+ /**
23
+ * Skip Gmedia images for Jetpack lazy load.
24
+ * @param bool $skip
25
+ * @param array $attributes
26
+ *
27
+ * @return bool
28
+ */
29
+ function jetpack_no_lazy_for_gmedia( $skip, $attributes ) {
30
+ if ( isset( $attributes['src'] ) && strpos( $attributes['src'], 'grand-media' ) ) {
31
+ return true;
32
+ }
33
+
34
+ return $skip;
35
+ }
36
+ add_filter( 'jetpack_lazy_images_skip_image_with_attributes', 'jetpack_no_lazy_for_gmedia', 10, 2 );
37
+
38
+ /**
39
+ * Skip Gmedia images for a3 Lazy Load.
40
+ * @param string $classes
41
+ *
42
+ * @return string
43
+ */
44
+ function a3_no_lazy_for_gmedia( $classes ) {
45
+ return 'noLazy,' . $classes;
46
+ }
47
+ add_filter( 'a3_lazy_load_skip_images_classes', 'a3_no_lazy_for_gmedia', 10 );
48
+
49
  /**
50
  * WP-SpamShield plugin compatibility
51
  * @param $pass
inc/core.php CHANGED
@@ -17,7 +17,6 @@ class GmediaCore {
17
  *
18
  */
19
  function __construct(){
20
- global $gmGallery;
21
 
22
  $this->upload = $this->gm_upload_dir();
23
  $this->gmedia_url = plugins_url(GMEDIA_FOLDER);
@@ -33,7 +32,7 @@ class GmediaCore {
33
  // add_action( 'updated_gmedia_term_meta', array( &$this, 'clear_cache' ) );
34
  // add_action( 'deleted_gmedia_meta', array( &$this, 'clear_cache' ) );
35
  // add_action( 'deleted_gmedia_term_meta', array( &$this, 'clear_cache' ) );
36
- add_action('created_gmedia_term', array(&$this, 'clear_cache'));
37
  add_action('edited_gmedia_term', array(&$this, 'clear_cache'));
38
  add_action('deleted_gmedia_term', array(&$this, 'clear_cache'));
39
  // add_action( 'gmedia_clean_object_term_cache', array( &$this, 'clear_cache' ) );
@@ -3138,6 +3137,7 @@ class GmediaCore {
3138
 
3139
  $gmGallery->options = get_option('gmediaOptions');
3140
  $gmGallery->options['modules_update'] = $modules_update_count;
 
3141
 
3142
  update_option('gmediaOptions', $gmGallery->options);
3143
  }
@@ -3667,6 +3667,8 @@ class GmediaCore {
3667
  */
3668
  function modules_order(){
3669
  return array(
 
 
3670
  'albumsListMasonry' => '',
3671
  'albumsList' => '',
3672
  'woowslider' => '',
@@ -3683,12 +3685,13 @@ class GmediaCore {
3683
  'mosaic' => '',
3684
  'photobox' => '',
3685
  'wavesurfer' => '',
3686
- 'phantom' => '',
3687
  'flipgrid' => '',
 
3688
  'cubik-lite' => '',
3689
  'photomania' => '',
3690
  'jq-mplayer' => '',
3691
  'wp-videoplayer' => '',
 
3692
  'photo-pro' => '',
3693
  'optima' => '',
3694
  'afflux' => '',
@@ -3746,6 +3749,9 @@ class GmediaCore {
3746
  * Clear the caches!
3747
  */
3748
  function clear_cache(){
 
 
 
3749
  // if W3 Total Cache is being used, clear the cache
3750
  if(function_exists('w3tc_pgcache_flush')){
3751
  w3tc_pgcache_flush();
@@ -3947,7 +3953,7 @@ class GmediaCore {
3947
  'log_author' => (int) $user_ID,
3948
  'log_date' => current_time('mysql'),
3949
  'log_data' => '1',
3950
- 'ip_address' => $this->ip()
3951
  );
3952
  $id = $wpdb->insert($wpdb->prefix . 'gmedia_log', $data);
3953
  }
@@ -3969,7 +3975,7 @@ class GmediaCore {
3969
  'log_author' => (int) $user_ID,
3970
  'log_date' => current_time('mysql'),
3971
  'log_data' => '1',
3972
- 'ip_address' => $this->ip()
3973
  );
3974
  $wpdb->insert($wpdb->prefix . 'gmedia_log', $data);
3975
  }
@@ -3992,7 +3998,7 @@ class GmediaCore {
3992
  'log_author' => (int) $user_ID,
3993
  'log_date' => current_time('mysql'),
3994
  'log_data' => $val,
3995
- 'ip_address' => $this->ip()
3996
  );
3997
  $wpdb->insert($wpdb->prefix . 'gmedia_log', $data);
3998
  }
17
  *
18
  */
19
  function __construct(){
 
20
 
21
  $this->upload = $this->gm_upload_dir();
22
  $this->gmedia_url = plugins_url(GMEDIA_FOLDER);
32
  // add_action( 'updated_gmedia_term_meta', array( &$this, 'clear_cache' ) );
33
  // add_action( 'deleted_gmedia_meta', array( &$this, 'clear_cache' ) );
34
  // add_action( 'deleted_gmedia_term_meta', array( &$this, 'clear_cache' ) );
35
+ // add_action('created_gmedia_term', array(&$this, 'clear_cache'));
36
  add_action('edited_gmedia_term', array(&$this, 'clear_cache'));
37
  add_action('deleted_gmedia_term', array(&$this, 'clear_cache'));
38
  // add_action( 'gmedia_clean_object_term_cache', array( &$this, 'clear_cache' ) );
3137
 
3138
  $gmGallery->options = get_option('gmediaOptions');
3139
  $gmGallery->options['modules_update'] = $modules_update_count;
3140
+ $gmGallery->options['modules_new'] = isset($modules['out'])? count($modules['out']) : 0;
3141
 
3142
  update_option('gmediaOptions', $gmGallery->options);
3143
  }
3667
  */
3668
  function modules_order(){
3669
  return array(
3670
+ 'photoblog' => '',
3671
+ 'cicerone' => '',
3672
  'albumsListMasonry' => '',
3673
  'albumsList' => '',
3674
  'woowslider' => '',
3685
  'mosaic' => '',
3686
  'photobox' => '',
3687
  'wavesurfer' => '',
 
3688
  'flipgrid' => '',
3689
+ 'phantom' => '',
3690
  'cubik-lite' => '',
3691
  'photomania' => '',
3692
  'jq-mplayer' => '',
3693
  'wp-videoplayer' => '',
3694
+
3695
  'photo-pro' => '',
3696
  'optima' => '',
3697
  'afflux' => '',
3749
  * Clear the caches!
3750
  */
3751
  function clear_cache(){
3752
+ // Delete cache transients.
3753
+ gmedia_delete_transients('gm_cache');
3754
+
3755
  // if W3 Total Cache is being used, clear the cache
3756
  if(function_exists('w3tc_pgcache_flush')){
3757
  w3tc_pgcache_flush();
3953
  'log_author' => (int) $user_ID,
3954
  'log_date' => current_time('mysql'),
3955
  'log_data' => '1',
3956
+ 'ip_address' => preg_replace('/(?!\d{1,3}\.\d{1,3}\.)\d/', '*', $this->ip())
3957
  );
3958
  $id = $wpdb->insert($wpdb->prefix . 'gmedia_log', $data);
3959
  }
3975
  'log_author' => (int) $user_ID,
3976
  'log_date' => current_time('mysql'),
3977
  'log_data' => '1',
3978
+ 'ip_address' => preg_replace('/(?!\d{1,3}\.\d{1,3}\.)\d/', '*', $this->ip())
3979
  );
3980
  $wpdb->insert($wpdb->prefix . 'gmedia_log', $data);
3981
  }
3998
  'log_author' => (int) $user_ID,
3999
  'log_date' => current_time('mysql'),
4000
  'log_data' => $val,
4001
+ 'ip_address' => preg_replace('/(?!\d{1,3}\.\d{1,3}\.)\d/', '*', $this->ip())
4002
  );
4003
  $wpdb->insert($wpdb->prefix . 'gmedia_log', $data);
4004
  }
inc/db.connect.php CHANGED
@@ -29,7 +29,7 @@ class GmediaDB{
29
  */
30
  function get_wp_media_lib($arg){
31
  /** @var $wpdb wpdb */
32
- global $user_ID, $wpdb, $gmCore;
33
  $default_arg = array('mime_type' => '', 'orderby' => 'ID', 'order' => '', 'limit' => '0', 'filter' => '', 'selected' => false, 's' => '');
34
  $arg = array_merge($default_arg, $arg);
35
  /** @var $mime_type
@@ -78,7 +78,7 @@ class GmediaDB{
78
 
79
  // split the words it a array if seperated by a space or comma
80
  preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
81
- $search_terms = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]);
82
 
83
  $n = '%';
84
  $searchand = '';
@@ -181,7 +181,6 @@ class GmediaDB{
181
  * @return mixed
182
  */
183
  function count_wp_media($arg){
184
- global $user_ID;
185
  /** @var $wpdb wpdb */
186
  global $wpdb;
187
  /** @var $filter
@@ -216,7 +215,7 @@ class GmediaDB{
216
 
217
  // split the words it a array if seperated by a space or comma
218
  preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
219
- $search_terms = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]);
220
 
221
  $n = '%';
222
  $searchand = '';
@@ -1751,6 +1750,7 @@ class GmediaDB{
1751
  AND name = {$q['category_name']}
1752
  ");
1753
  if($cat){
 
1754
  $q['category__in'][] = $cat;
1755
  }
1756
  }
@@ -1826,6 +1826,7 @@ class GmediaDB{
1826
  AND name = {$q['album_name']}
1827
  ");
1828
  if($alb){
 
1829
  $q['album__in'][] = $alb;
1830
  }
1831
  }
@@ -1921,6 +1922,34 @@ class GmediaDB{
1921
  }
1922
  }
1923
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1924
  if(isset($q['tag__in']) && !empty($q['tag__in'])){
1925
  $q['tag__in'] = wp_parse_id_list($q['tag__in']);
1926
  } elseif(isset($q['tag_id']) && !empty($q['tag_id'])){
@@ -1935,32 +1964,6 @@ class GmediaDB{
1935
  if(isset($q['tag__and']) && !empty($q['tag__and'])){
1936
  $q['tag__and'] = wp_parse_id_list($q['tag__and']);
1937
  }
1938
-
1939
- if(isset($q['tag_name__in']) && !empty($q['tag_name__in'])){
1940
- $q['tag_name__in'] = "'" . implode("','", array_map('esc_sql', array_unique((array)$q['tag_name__in']))) . "'";
1941
- $q['tag_name__in'] = $wpdb->get_col("
1942
- SELECT term_id
1943
- FROM {$wpdb->prefix}gmedia_term
1944
- WHERE taxonomy = 'gmedia_tag'
1945
- AND name IN ({$q['tag_name__in']})
1946
- ");
1947
- if(empty($q['tag_name__in'])){
1948
- $q['tag_name__in_null'] = true;
1949
- }
1950
- }
1951
-
1952
- if(isset($q['tag_name__and']) && !empty($q['tag_name__and'])){
1953
- $q['tag_name__and'] = "'" . implode("','", array_map('esc_sql', array_unique((array)$q['tag_name__and']))) . "'";
1954
- $q['tag_name__and'] = $wpdb->get_col("
1955
- SELECT term_id
1956
- FROM {$wpdb->prefix}gmedia_term
1957
- WHERE taxonomy = 'gmedia_tag'
1958
- AND name IN ({$q['tag_name__and']})
1959
- ");
1960
- if(empty($q['tag_name__and'])){
1961
- $q['tag_name__and_null'] = true;
1962
- }
1963
- }
1964
  }
1965
 
1966
  /**
@@ -3655,7 +3658,7 @@ class GmediaDB{
3655
  *
3656
  * @return array|bool False on failure. Array of term objects on success.
3657
  */
3658
- function get_the_gmedia_terms($id = 0, $taxonomy){
3659
  $id = (int)$id;
3660
 
3661
  if(!$id){
29
  */
30
  function get_wp_media_lib($arg){
31
  /** @var $wpdb wpdb */
32
+ global $wpdb, $gmCore;
33
  $default_arg = array('mime_type' => '', 'orderby' => 'ID', 'order' => '', 'limit' => '0', 'filter' => '', 'selected' => false, 's' => '');
34
  $arg = array_merge($default_arg, $arg);
35
  /** @var $mime_type
78
 
79
  // split the words it a array if seperated by a space or comma
80
  preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
81
+ $search_terms = array_map(function($a){ return trim($a, "\"'\n\r "); }, $matches[0]);
82
 
83
  $n = '%';
84
  $searchand = '';
181
  * @return mixed
182
  */
183
  function count_wp_media($arg){
 
184
  /** @var $wpdb wpdb */
185
  global $wpdb;
186
  /** @var $filter
215
 
216
  // split the words it a array if seperated by a space or comma
217
  preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
218
+ $search_terms = array_map(function($a){ return trim($a, "\"'\n\r "); }, $matches[0]);
219
 
220
  $n = '%';
221
  $searchand = '';
1750
  AND name = {$q['category_name']}
1751
  ");
1752
  if($cat){
1753
+ unset($q['category_name']);
1754
  $q['category__in'][] = $cat;
1755
  }
1756
  }
1826
  AND name = {$q['album_name']}
1827
  ");
1828
  if($alb){
1829
+ unset($q['album_name']);
1830
  $q['album__in'][] = $alb;
1831
  }
1832
  }
1922
  }
1923
  }
1924
 
1925
+ if(isset($q['tag_name__in']) && !empty($q['tag_name__in'])){
1926
+ $q['tag_name__in'] = "'" . implode("','", array_map('esc_sql', array_unique((array)$q['tag_name__in']))) . "'";
1927
+ $tag__in = $wpdb->get_col("
1928
+ SELECT term_id
1929
+ FROM {$wpdb->prefix}gmedia_term
1930
+ WHERE taxonomy = 'gmedia_tag'
1931
+ AND name IN ({$q['tag_name__in']})
1932
+ ");
1933
+ if(!empty($tag__in)){
1934
+ unset($q['tag_name__in']);
1935
+ $q['tag__in'] = $tag__in;
1936
+ }
1937
+ }
1938
+
1939
+ if(isset($q['tag_name__and']) && !empty($q['tag_name__and'])){
1940
+ $q['tag_name__and'] = "'" . implode("','", array_map('esc_sql', array_unique((array)$q['tag_name__and']))) . "'";
1941
+ $tag__and = $wpdb->get_col("
1942
+ SELECT term_id
1943
+ FROM {$wpdb->prefix}gmedia_term
1944
+ WHERE taxonomy = 'gmedia_tag'
1945
+ AND name IN ({$q['tag_name__and']})
1946
+ ");
1947
+ if(!empty($tag__and)){
1948
+ unset($q['tag_name__and']);
1949
+ $q['tag__and'] = $tag__and;
1950
+ }
1951
+ }
1952
+
1953
  if(isset($q['tag__in']) && !empty($q['tag__in'])){
1954
  $q['tag__in'] = wp_parse_id_list($q['tag__in']);
1955
  } elseif(isset($q['tag_id']) && !empty($q['tag_id'])){
1964
  if(isset($q['tag__and']) && !empty($q['tag__and'])){
1965
  $q['tag__and'] = wp_parse_id_list($q['tag__and']);
1966
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1967
  }
1968
 
1969
  /**
3658
  *
3659
  * @return array|bool False on failure. Array of term objects on success.
3660
  */
3661
+ function get_the_gmedia_terms($id, $taxonomy){
3662
  $id = (int)$id;
3663
 
3664
  if(!$id){
inc/frontend.filters.php CHANGED
@@ -2,148 +2,148 @@
2
  /**
3
  * FrontEnd Filters
4
  */
5
- if( !defined('ABSPATH')){
6
- exit;
7
  } // Exit if accessed directly
8
 
9
  global $gmGallery;
10
 
11
- add_action('wp_head', 'gmogmeta_header', 2); // Generate og:image meta tag
12
- add_action('pre_get_posts', 'gmedia_alter_query'); // Show taxonomy archives for gmedia tags and categories
13
- add_action('pre_get_posts', 'gmedia_alter_query_author', 100); // Show gmedia posts on author profile page
14
- if((int) $gmGallery->options['wp_term_related_gmedia']){
15
- add_filter('the_posts', 'gmedia_the_posts_filter_taxonomy', 10, 2); // Prepend related gmedia for tags and categories archives
16
  }
17
- add_action('the_post', 'gmedia_the_post'); // Show Gmedia post types
18
 
19
  add_filter( 'widget_comments_args', 'gmedia_widget_comments_args', 10 );
20
 
21
  /**
22
  * Generate og:image meta tag
23
  */
24
- function gmogmeta_header(){
25
- global $gmDB, $gmCore;
26
- $share_ref = (int) $gmCore->_get('gmedia_share', 0);
27
- $gmedia = false;
28
- $is_single = is_single();
29
- if($share_ref && ($gmedia = $gmDB->get_gmedia($share_ref))){
30
- //$og_url_id = $gmedia->post_id;
31
- }
32
- if($is_single){
33
- global $post;
34
- if( !$gmedia && isset($post->post_type) && $post->post_type == 'gmedia'){
35
- $gmedia = $gmDB->get_post_gmedia($post->ID);
36
- }
37
- //$og_url_id = $post->ID;
38
- }
39
- if($gmedia){
40
- remove_action('wp_head', 'rel_canonical');
41
- $image_url = $gmCore->gm_get_media_image($gmedia, 'web');
42
- $description = strip_tags($gmedia->description);
43
- if( !$description){
44
- $description = get_bloginfo('description');
45
- }
46
- ?>
47
- <!-- Gmedia Open Graph Meta Image -->
48
- <meta property="og:title" content="<?php echo esc_attr($gmedia->title); ?>"/>
49
- <meta property="og:description" content="<?php echo esc_attr($description); ?>"/>
50
- <meta property="og:image" content="<?php echo $image_url; ?>"/>
51
- <!-- End Gmedia Open Graph Meta Image -->
52
- <?php
53
- }
54
  }
55
 
56
  /** Show taxonomy archives for gmedia tags and categories
57
  *
58
  * @param $query
59
  */
60
- function gmedia_alter_query($query){
61
- if( !empty($query->query['gmedia_tag'])){
62
- $gm_tax = 'gmedia_tag';
63
- } elseif( !empty($query->query['gmedia_category'])){
64
- $gm_tax = 'gmedia_category';
65
- } else{
66
- return;
67
- }
68
-
69
- global $wp_query, $gmDB, $gmGallery;
70
- $term = urldecode($query->query[ $gm_tax ]);
71
- if( !$term || !($term_id = $gmDB->term_exists($term, $gm_tax))){
72
- return;
73
- }
74
-
75
- $args = array('fields' => 'post_ids', 'status' => array('publish'));
76
- if(get_current_user_id()){
77
- $args['status'][] = 'private';
78
- }
79
- if('gmedia_tag' == $gm_tax){
80
- $args['tag__in'] = $term_id;
81
- $args['orderby'] = $gmGallery->options['in_tag_orderby'];
82
- $args['order'] = $gmGallery->options['in_tag_order'];
83
- $wp_query->is_tag = true;
84
- } elseif('gmedia_category' == $gm_tax){
85
- $args['category__in'] = $term_id;
86
- $term_meta = $gmDB->get_metadata('gmedia_term', $term_id);
87
- $args['orderby'] = isset($term_meta['_orderby'][0])? $term_meta['_orderby'][0] : $gmGallery->options['in_category_orderby'];
88
- $args['order'] = isset($term_meta['_order'][0])? $term_meta['_order'][0] : $gmGallery->options['in_category_order'];
89
- $wp_query->is_category = true;
90
- }
91
- $gmedias = $gmDB->get_gmedias($args);
92
- $post_ids = array();
93
- foreach($gmedias as $item){
94
- $post_ids[] = $item->post_id;
95
- }
96
- if( !empty($post_ids)){
97
- $query->set($gm_tax, null);
98
- $query->set('post_type', 'gmedia');
99
- $query->set('post__in', $post_ids);
100
- $query->set('orderby', 'post__in');
101
-
102
- $wp_query->is_tag = false;
103
- $wp_query->is_category = false;
104
- $wp_query->is_tax = false;
105
- $wp_query->is_archive = true;
106
-
107
- //we remove the actions hooked on the '__after_loop' (post navigation)
108
- remove_all_actions('__after_loop');
109
- }
110
  }
111
 
112
  /** Show gmedia posts on author profile page
113
  *
114
  * @param WP_Query $query
115
  */
116
- function gmedia_alter_query_author($query){
117
- if(empty($query->query['author']) && empty($query->query['author_name'])){
118
- return;
119
- }
120
- global $gmGallery;
121
-
122
- $gmedia_post_type = array();
123
- if((int) $gmGallery->options['wp_author_related_gmedia']){
124
- $gmedia_post_type[] = 'gmedia';
125
- }
126
- if((int) $gmGallery->options['wp_author_related_gmedia_album']){
127
- $gmedia_post_type[] = 'gmedia_album';
128
- }
129
- if((int) $gmGallery->options['wp_author_related_gmedia_gallery']){
130
- $gmedia_post_type[] = 'gmedia_gallery';
131
- }
132
-
133
- if(empty($gmedia_post_type)){
134
- return;
135
- }
136
-
137
- $post_type = $query->get('post_type', array('post'));
138
- $post_type = array_unique(array_merge($gmedia_post_type, (array) $post_type));
139
- $query->set('post_type', $post_type);
140
-
141
- if(get_current_user_id()){
142
- $query->set('post_status', array('publish', 'private'));
143
  }
144
 
145
  //we remove the actions hooked on the '__after_loop' (post navigation)
146
- remove_all_actions('__after_loop');
147
  }
148
 
149
  /** Add related media for tags and categories
@@ -153,111 +153,111 @@ function gmedia_alter_query_author($query){
153
  *
154
  * @return mixed
155
  */
156
- function gmedia_the_posts_filter_taxonomy($posts, $query){
157
-
158
- $paged = (get_query_var('paged'))? get_query_var('paged') : 1;
159
- if($paged != 1){
160
- return $posts;
161
- }
162
-
163
- if( !empty($query->query['tag'])){
164
- $tax = 'tag';
165
- } elseif( !empty($query->query['category'])){
166
- $tax = 'category';
167
- } else{
168
- return $posts;
169
- }
170
-
171
- global $wp_query, $gmDB, $gmGallery;
172
- $term = urldecode($query->query[ $tax ]);
173
- $gm_tax = "gmedia_{$tax}";
174
- if( !$term || !($term_id = $gmDB->term_exists($term, $gm_tax))){
175
- return $posts;
176
- }
177
-
178
- $args = array('fields' => 'post_ids', 'status' => array('publish'), 'limit' => 1);
179
- if(get_current_user_id()){
180
- $args['status'][] = 'private';
181
- }
182
- if('tag' == $tax){
183
- $args['tag__in'] = $term_id;
184
- $args['orderby'] = $gmGallery->options['in_tag_orderby'];
185
- $args['order'] = $gmGallery->options['in_tag_order'];
186
- $wp_query->is_tag = true;
187
- } elseif('category' == $tax){
188
- $args['category__in'] = $term_id;
189
- $term_meta = $gmDB->get_metadata('gmedia_term', $term_id);
190
- $args['orderby'] = isset($term_meta['_orderby'][0])? $term_meta['_orderby'][0] : $gmGallery->options['in_category_orderby'];
191
- $args['order'] = isset($term_meta['_order'][0])? $term_meta['_order'][0] : $gmGallery->options['in_category_order'];
192
- $wp_query->is_category = true;
193
- }
194
- $gmedia_ids = $gmDB->get_gmedias($args);
195
- if(count($gmedia_ids)){
196
- $query->gmedia_term_post = $term_id;
197
- array_unshift($posts, $gmedia_ids[0]->post_id);
198
- }
199
-
200
- return $posts;
201
  }
202
 
203
  /** Show related media for tags and categories
204
  *
205
  * @param $post
206
  */
207
- function gmedia_the_post($post){
208
- global $gmGallery;
209
- if('gmedia' == substr($post->post_type, 0, 6)){
210
- global $wp_query, $gmDB;
211
- if(isset($wp_query->gmedia_term_post)){
212
- global $post;
213
- $term = $gmDB->get_term($wp_query->gmedia_term_post);
214
- $date = gmdate('Y-m-d H:i:s');
215
- $post = (object) array(
216
- 'ID' => 0,
217
- 'term_id' => $term->term_id,
218
- 'post_author' => 0,
219
- 'post_date' => $date,
220
- 'post_date_gmt' => $date,
221
- 'post_content' => "[gm id={$term->term_id}]",
222
- 'post_title' => __('Related Media', 'grand-media') . ': ' . $term->name,
223
- 'post_excerpt' => '',
224
- 'post_status' => 'publish',
225
- 'comment_status' => 'closed',
226
- 'ping_status' => 'closed',
227
- 'post_password' => '',
228
- 'post_name' => '',
229
- 'to_ping' => '',
230
- 'pinged' => '',
231
- 'post_modified' => $date,
232
- 'post_modified_gmt' => $date,
233
- 'post_content_filtered' => '',
234
- 'post_parent' => '0',
235
- 'guid' => '',
236
- 'menu_order' => '0',
237
- 'post_type' => $term->taxonomy,
238
- 'post_mime_type' => '',
239
- 'comment_count' => '0',
240
- 'filter' => 'raw',
241
- );
242
- $wp_query->posts[0] = $post;
243
- $wp_query->post = $post;
244
- unset($wp_query->gmedia_term_post);
245
- }
246
- add_filter('get_the_excerpt', 'gmedia_post_type__the_excerpt', 150);
247
- add_filter('the_content', 'gmedia_post_type__the_content', 200);
248
- } elseif(is_single()){
249
- $gmedia_post_types = array_merge(array(
250
- 'post',
251
- 'page'
252
- ), (array) $gmGallery->options['gmedia_post_types_support']);
253
- $gm_post_types = apply_filters('gmedia-post-types', $gmedia_post_types);
254
- if(in_array($post->post_type, $gm_post_types)){
255
- $show_related = get_post_meta($post->ID, '_related_gmedia', true);
256
- if(('1' === $show_related) || (('' === $show_related) && (int) $gmGallery->options['wp_post_related_gmedia'])){
257
- add_filter('the_content', 'gmedia_related__the_content', 200);
258
- }
259
- }
260
- }
261
  }
262
 
263
  /**
@@ -265,18 +265,18 @@ function gmedia_the_post($post){
265
  *
266
  * @return mixed|string
267
  */
268
- function gmedia_post_type__the_excerpt($content){
269
- global $post;
270
 
271
- if('gmedia' !== substr($post->post_type, 0, 6)){
272
- return $content;
273
- }
274
 
275
- remove_filter('get_the_excerpt', 'gmedia_post_type__the_excerpt', 150);
276
- remove_filter('the_content', 'gmedia_post_type__the_content', 200);
277
- $content = wp_trim_excerpt();
278
 
279
- return gmedia_post_type__the_content($content);
280
  }
281
 
282
  /**
@@ -284,165 +284,172 @@ function gmedia_post_type__the_excerpt($content){
284
  *
285
  * @return mixed|string
286
  */
287
- function gmedia_post_type__the_content($content){
288
- global $post, $gmDB, $gmCore, $gmGallery;
289
-
290
- if('gmedia' !== substr($post->post_type, 0, 6)){
291
- return $content;
292
- }
293
-
294
- if(isset($post->gmedia_content)){
295
- $post->post_content = $post->gmedia_content;
296
-
297
- return $post->gmedia_content;
298
- }
299
-
300
- remove_filter('the_content', 'gmedia_post_type__the_content', 200);
301
-
302
- $output = '';
303
- if($post->post_type == 'gmedia'){
304
- $gmedia_id = get_post_meta($post->ID, '_gmedia_ID', true);
305
- $gmedia = $gmDB->get_gmedia($gmedia_id);
306
- if($gmedia){
307
- gmedia_item_more_data($gmedia);
308
-
309
- ob_start();
310
-
311
- if($gmedia->link){
312
- $gmedia_link = $gmedia->link;
313
- $base_url_host = parse_url($gmCore->upload['url'], PHP_URL_HOST);
314
- $url_host = parse_url($gmedia->link, PHP_URL_HOST);
315
- if($url_host == $base_url_host || empty($url_host)){
316
- $link_target = ' target="_self"';
317
- } else{
318
- $link_target = ' target="_blank"';
319
- }
320
- if(isset($gmedia->meta['link_target'][0])){
321
- $link_target = ' target="' . $gmedia->meta['link_target'][0] . '"';
322
- }
323
- } else{
324
- $gmedia_link = $gmedia->url;
325
- $link_target = '';
326
- }
327
-
328
- if('image' == $gmedia->type){
329
- ?>
330
- <a class="gmedia-item-link" rel="gmedia-item"
331
- href="<?php echo $gmedia_link; ?>"<?php echo $link_target; ?>><img class="gmedia-item"
332
- style="max-width:100%;"
333
- src="<?php echo $gmedia->url; ?>"
334
- alt="<?php esc_attr_e($gmedia->title); ?>"/></a>
335
- <?php
336
-
337
- if(is_single()){
338
- /** more info */
339
-
340
- $author_name = get_the_author_meta('display_name', $gmedia->author);
341
- $author_posts_link = get_author_posts_url($gmedia->author);
342
- $avatar_img = get_avatar($gmedia->author, 60);
343
- if(preg_match("/src=['\"](.*?)['\"]/i", $avatar_img, $matches)){
344
- $author_avatar = $matches[1];
345
- }
346
- ?>
347
- <div class="gmsingle_wrapper gmsingle_clearfix">
348
- <script type="text/html" class="gm_script2html">
349
- <div class="gmsingle_photo_header gmsingle_clearfix">
350
- <div class="gmsingle_name_wrap gmsingle_clearfix">
351
- <?php if( !empty($author_avatar)){ ?>
352
- <div class="gmsingle_user_avatar">
353
- <a class="gmsingle_user_avatar_link"
354
- href="<?php echo urldecode($author_posts_link); ?>"><img
355
- src="<?php echo $author_avatar; ?>" alt=""/></a>
356
- </div>
357
- <?php } ?>
358
- <div class="gmsingle_title_author">
359
- <div class="gmsingle_title"><?php
360
- if(('image' != $gmedia->type) && $gmedia->link){
361
- echo "<a href='{$gmedia_link}'{$link_target}>{$gmedia->title}&nbsp;&#x1f517;</a>";
362
- } else{
363
- echo $gmedia->title;
364
- }
365
- ?>&nbsp;</div>
366
- <div class="gmsingle_author_name">
367
- <a class="gmsingle_author_link"
368
- href="<?php echo urldecode($author_posts_link); ?>"><?php echo $author_name; ?></a>
369
- </div>
370
- </div>
371
- </div>
372
- </div>
373
- </script>
374
- <div class="gmsingle_photo_info">
375
- <div class="gmsingle_description_wrap">
376
- <?php echo apply_filters('the_gmedia_content', wpautop($gmedia->description)); ?>
377
- <script type="text/html" class="gm_script2html">
378
- <?php
379
- if( !empty($gmedia->album)){
380
- $term_name = $gmedia->album[0]->name;
381
- $term_post_id = $gmDB->get_metadata('gmedia_term', $gmedia->album[0]->term_id, '_post_ID', true);
382
- if( !empty($term_post_id)){
383
- $term_url = get_permalink($term_post_id);
384
- } else{
385
- $term_url = $gmCore->gmcloudlink($gmedia->album[0]->term_id, 'album');
386
- }
387
- ?>
388
- <div class="gmsingle_terms">
389
- <span class="gmsingle_term_label"><?php _e('Album'); ?>:</span>
390
- <span class="gmsingle_album"><span class="gmsingle_term"><a
391
- href="<?php echo $term_url; ?>"><?php echo $term_name; ?></a></span></span>
392
- </div>
393
- <?php
394
- }
395
- if( !empty($gmedia->categories)){
396
- $item_cats = array();
397
- foreach($gmedia->categories as $term){
398
- $term->slug = $term->name;
399
- $term_url = get_term_link($term);
400
- //$term_url = $gmCore->gmcloudlink($term->term_id, 'category');
401
- $item_cats[] = "<span class='gmsingle_term'><a href='{$term_url}'>{$term->name}</a></span>";
402
- }
403
- ?>
404
- <div class="gmsingle_terms">
405
- <span class="gmsingle_term_label"><?php _e('Categories'); ?>:</span>
406
- <span class="gmsingle_categories"><?php echo implode(' ', $item_cats); ?></span>
407
- </div>
408
- <?php
409
- }
410
- if( !empty($gmedia->tags)){
411
- $item_tags = array();
412
- foreach($gmedia->tags as $term){
413
- $term->slug = $term->name;
414
- $term_url = get_term_link($term);
415
- //$term_url = $gmCore->gmcloudlink($term->term_id, 'tag');
416
- $item_tags[] = "<span class='gmsingle_term'><a href='{$term_url}'>#{$term->name}</a></span>";
417
- }
418
- ?>
419
- <div class="gmsingle_terms">
420
- <span class="gmsingle_term_label"><?php _e('Tags'); ?>:</span>
421
- <span class="gmsingle_tags"><?php echo implode(' ', $item_tags); ?></span>
422
- </div>
423
- <?php } ?>
424
- </script>
425
- </div>
426
- <script type="text/html" class="gm_script2html">
427
- <?php if($gmedia->gps){
428
- $loc = str_replace(' ', '', $gmedia->gps);
429
- ?>
430
- <div class="gmsingle_location_section">
431
- <div class="gmsingle_details_title"><?php _e('Location'); ?></div>
432
-
433
- <div class="gmsingle_location_info">
434
- <a href='https://www.google.com/maps/place/<?php echo $loc; ?>'
435
- target='_blank'><img
436
- src='//maps.googleapis.com/maps/api/staticmap?key=<?php esc_attr_e($gmGallery->options['google_api_key']); ?>&size=320x240&zoom=10&scale=2&maptype=roadmap&markers=<?php echo $loc; ?>'
437
- alt='' width='320' height='240'/></a>
438
- </div>
439
- </div>
440
- <?php } ?>
441
- <div class="gmsingle_details_section">
442
- <div class="gmsingle_details_title"><?php _e('Details', 'grand-media'); ?></div>
443
 
444
- <div class="gmsingle_slide_details">
445
- <?php /* ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
446
  <div class='gmsingle_badges'>
447
  <div class='gmsingle_badges__column'>
448
  <div class='gmsingle_badges__label'><?php _e('Views', 'grand-media'); ?></div>
@@ -456,375 +463,475 @@ function gmedia_post_type__the_content($content){
456
  </div>
457
  <?php
458
  */
459
- $exif = $gmCore->metadata_info($gmedia->ID);
460
-
461
- $details = array();
462
- if( !empty($exif)){
463
- $details['model'] = empty($exif['model'])? '' : $exif['model']['value'];
464
- $details['lens'] = empty($exif['lens'])? '' : $exif['lens']['value'];
465
- $details['camera_settings'] = array(
466
- 'focallength' => empty($exif['focallength'])? (empty($exif['focallength35'])? '' : $exif['focallength35']['value']) : $exif['focallength']['value'],
467
- 'aperture' => empty($exif['aperture'])? '' : str_replace('f', 'ƒ', $exif['aperture']['value']),
468
- 'exposure' => empty($exif['exposure'])? '' : $exif['exposure']['value'],
469
- 'iso' => empty($exif['iso'])? '' : 'ISO ' . $exif['iso']['value']
470
- );
471
- $details['camera_settings'] = array_filter($details['camera_settings']);
472
- $details['taken'] = empty($exif['created_timestamp'])? '' : date_i18n(get_option('date_format'), $exif['created_timestamp']['value']);
473
- }
474
- $details['uploaded'] = date_i18n(get_option('date_format'), strtotime($gmedia->date));
475
-
476
- if( !empty($details['model'])){ ?>
477
- <div class='gmsingle_exif'>
478
- <div class='gmsingle_label gmsingle_exif_model'><?php echo $details['model']; ?></div>
479
- <?php if( !empty($details['lens'])){ ?>
480
- <div class='gmsingle_label_small gmsingle_exif_lens'><?php echo $details['lens']; ?></div>
481
- <?php }
482
- $camera_settings = array();
483
- foreach($details['camera_settings'] as $key => $value){
484
- $camera_settings[] = "<span class='gmsingle_exif_{$key}'>{$value}</span>";
485
- }
486
- if( !empty($camera_settings)){ ?>
487
- <div class='gmsingle_label_small gmsingle_camera_settings'><?php echo implode('<span class="gmsingle_separator"> / </span>', $camera_settings); ?></div>
488
- <?php } ?>
489
- </div>
490
- <?php } ?>
491
- <div class='gmsingle_meta'>
492
- <?php if( !empty($details['taken'])){ ?>
493
- <div class='gmsingle_clearfix'>
494
- <span class='gmsingle_meta_key'><?php _e('Created', 'grand-media'); ?></span>
495
- <span class='gmsingle_meta_value'><?php echo $details['taken']; ?></span>
496
- </div>
497
- <?php } ?>
498
- <div class='gmsingle_clearfix'>
499
- <span class='gmsingle_meta_key'><?php _e('Uploaded', 'grand-media'); ?></span>
500
- <span class='gmsingle_meta_value'><?php echo $details['uploaded']; ?></span>
501
- </div>
502
- </div>
503
- </div>
504
- </div>
505
- </script>
506
- </div>
507
- </div>
508
- <style type="text/css">
509
- .gmsingle_clearfix {
510
- display: block;
511
- }
512
-
513
- .gmsingle_clearfix::after {
514
- visibility: hidden;
515
- display: block;
516
- font-size: 0;
517
- content: ' ';
518
- clear: both;
519
- height: 0;
520
- }
521
-
522
- .gmsingle_wrapper {
523
- margin: 0 auto;
524
- }
525
-
526
- .gmsingle_wrapper * {
527
- -webkit-box-sizing: border-box;
528
- -moz-box-sizing: border-box;
529
- box-sizing: border-box;
530
- }
531
-
532
- .gmsingle_photo_header {
533
- margin-bottom: 15px;
534
- }
535
-
536
- .gmsingle_name_wrap {
537
- padding: 24px 0 2px 80px;
538
- height: 85px;
539
- max-width: 100%;
540
- overflow: hidden;
541
- white-space: nowrap;
542
- position: relative;
543
- }
544
-
545
- .gmsingle_name_wrap .gmsingle_user_avatar {
546
- position: absolute;
547
- top: 20px;
548
- left: 0;
549
- }
550
-
551
- .gmsingle_name_wrap .gmsingle_user_avatar a.gmsingle_user_avatar_link {
552
- display: block;
553
- text-decoration: none;
554
- }
555
-
556
- .gmsingle_name_wrap .gmsingle_user_avatar img {
557
- height: 60px !important;
558
- width: auto;
559
- overflow: hidden;
560
- border-radius: 3px;
561
- }
562
-
563
- .gmsingle_name_wrap .gmsingle_title_author {
564
- display: inline-block;
565
- vertical-align: top;
566
- max-width: 100%;
567
- }
568
-
569
- .gmsingle_name_wrap .gmsingle_title_author .gmsingle_title {
570
- text-rendering: auto;
571
- font-weight: 100;
572
- font-size: 24px;
573
- width: 100%;
574
- overflow: hidden;
575
- white-space: nowrap;
576
- text-overflow: ellipsis;
577
- margin: 0;
578
- padding: 1px 0;
579
- height: 1.1em;
580
- line-height: 1;
581
- box-sizing: content-box;
582
- text-transform: none;
583
- letter-spacing: 0px;
584
- text-transform: capitalize;
585
- }
586
-
587
- .gmsingle_name_wrap .gmsingle_title_author > div {
588
- font-size: 14px;
589
- }
590
-
591
- .gmsingle_name_wrap .gmsingle_title_author .gmsingle_author_name {
592
- float: left;
593
- }
594
-
595
- .gmsingle_name_wrap .gmsingle_title_author a {
596
- font-size: inherit;
597
- }
598
-
599
- .gmsingle_photo_info {
600
- display: flex;
601
- flex-wrap: wrap;
602
- }
603
-
604
- .gmsingle_details_title {
605
- margin: 0;
606
- padding: 0;
607
- text-transform: uppercase;
608
- font-size: 18px;
609
- line-height: 1em;
610
- font-weight: 300;
611
- height: 1.1em;
612
- display: inline-block;
613
- overflow: visible;
614
- border: none;
615
- }
616
-
617
- .gmsingle_description_wrap {
618
- flex: 1;
619
- overflow: hidden;
620
- min-width: 220px;
621
- max-width: 100%;
622
- padding-right: 7px;
623
- margin-bottom: 30px;
624
- }
625
-
626
- .gmsingle_description_wrap .gmsingle_terms {
627
- overflow: hidden;
628
- margin: 0;
629
- position: relative;
630
- font-size: 14px;
631
- font-weight: 300;
632
- }
633
-
634
- .gmsingle_description_wrap .gmsingle_term_label {
635
- margin-right: 10px;
636
- }
637
-
638
- .gmsingle_description_wrap .gmsingle_term_label:empty {
639
- display: none;
640
- }
641
-
642
- .gmsingle_description_wrap .gmsingle_terms .gmsingle_term {
643
- display: inline-block;
644
- margin: 0 12px 1px 0;
645
- }
646
-
647
- .gmsingle_description_wrap .gmsingle_terms .gmsingle_term a {
648
- white-space: nowrap;
649
- }
650
-
651
- .gmsingle_details_section {
652
- flex: 1;
653
- width: 33%;
654
- padding-right: 7px;
655
- padding-left: 7px;
656
- min-width: 220px;
657
- max-width: 100%;
658
- }
659
-
660
- .gmsingle_details_section .gmsingle_slide_details {
661
- margin: 20px 0;
662
- }
663
-
664
- .gmsingle_location_section {
665
- flex: 1;
666
- width: 27%;
667
- padding-right: 7px;
668
- padding-left: 7px;
669
- min-width: 220px;
670
- max-width: 100%;
671
- }
672
-
673
- .gmsingle_location_section .gmsingle_location_info {
674
- margin: 20px 0;
675
- }
676
-
677
- .gmsingle_location_section .gmsingle_location_info * {
678
- display: block;
679
- }
680
-
681
- .gmsingle_location_section .gmsingle_location_info img {
682
- width: 100%;
683
- height: auto;
684
- }
685
-
686
- .gmsingle_badges {
687
- border-bottom: 1px solid rgba(0, 0, 0, 0.1);
688
- padding-bottom: 17px;
689
- margin-bottom: 12px;
690
- text-align: left;
691
- font-weight: 300;
692
- }
693
-
694
- .gmsingle_badges__column {
695
- display: inline-block;
696
- vertical-align: top;
697
- width: 40%;
698
- min-width: 80px;
699
- }
700
-
701
- .gmsingle_badges__column .gmsingle_badges__label {
702
- font-size: 14px;
703
- }
704
-
705
- .gmsingle_badges__column .gmsingle_badges__count {
706
- font-size: 20px;
707
- line-height: 1em;
708
- margin-top: 1px;
709
- }
710
-
711
- .gmsingle_exif {
712
- border-bottom: 1px solid rgba(0, 0, 0, 0.1);
713
- padding-bottom: 12px;
714
- margin-bottom: 12px;
715
- text-align: left;
716
- font-size: 14px;
717
- line-height: 1.7em;
718
- font-weight: 300;
719
- }
720
-
721
- .gmsingle_exif .gmsingle_camera_settings .gmsingle_separator {
722
- font-weight: 200;
723
- padding: 0 5px;
724
- display: inline-block;
725
- }
726
-
727
- .gmsingle_meta {
728
- padding-bottom: 12px;
729
- margin-bottom: 12px;
730
- text-align: left;
731
- font-size: 14px;
732
- line-height: 1.2em;
733
- font-weight: 300;
734
- }
735
-
736
- .gmsingle_meta .gmsingle_meta_key {
737
- float: left;
738
- padding: 3px 0;
739
- width: 40%;
740
- min-width: 80px;
741
- }
742
-
743
- .gmsingle_meta .gmsingle_meta_value {
744
- float: left;
745
- white-space: nowrap;
746
- padding: 3px 0;
747
- text-transform: capitalize;
748
- }
749
- </style>
750
- <?php
751
- } else{
752
- echo apply_filters('the_gmedia_content', wpautop($gmedia->description));
753
- }
754
-
755
- } elseif('audio' == $gmedia->type && ($module = $gmCore->get_module_path('wavesurfer')) && $module['name'] === 'wavesurfer'){
756
- echo gmedia_shortcode(array('module' => 'wavesurfer', 'library' => $gmedia->ID, 'native' => true));
757
- if(is_single()){
758
- echo apply_filters('the_gmedia_content', wpautop($gmedia->description));
759
- }
760
- } else{
761
- $ext1 = wp_get_audio_extensions();
762
- $ext2 = wp_get_video_extensions();
763
- $ext = array_merge($ext1, $ext2);
764
- if(in_array($gmedia->ext, $ext)){
765
- global $wp_embed;
766
- $embed = $wp_embed->run_shortcode("[embed]$gmedia->url[/embed]");
767
- if('[' == substr($embed, 0, 1)){
768
- $embed = do_shortcode($embed);
769
- }
770
- echo $embed;
771
- } else{
772
- $cover_url = $gmCore->gm_get_media_image($gmedia, 'web');
773
- ?>
774
- <a class="gmedia-item-link" href="<?php echo $gmedia->url; ?>" download="true"><img
775
- class="gmedia-item" style="max-width:100%;" src="<?php echo $cover_url; ?>"
776
- alt="<?php esc_attr_e($gmedia->title); ?>"/></a>
777
- <?php
778
- }
779
- }
780
-
781
- $output = ob_get_contents();
782
- ob_end_clean();
783
-
784
- }
785
-
786
- } else{
787
- if( !isset($post->term_id)){
788
- $post->term_id = get_post_meta($post->ID, '_gmedia_term_ID', true);
789
- }
790
- $output = '';
791
- $gmedia_term = $gmDB->get_term($post->term_id);
792
- if($gmedia_term && !is_wp_error($gmedia_term)){
793
- add_filter( 'comments_open', '__return_false' );
794
- $current_filter = current_filter();
795
- if('get_the_excerpt' == $current_filter){
796
- $cover_id = $gmDB->get_metadata('gmedia_term', $post->term_id, '_cover', true);
797
- if((int) $cover_id && ($cover = $gmDB->get_gmedia((int) $cover_id))){
798
- $output .= '<div class="gmedia-term-cover"><img class="gmedia-item" style="max-width:100%;" src="' . $gmCore->gm_get_media_image($cover, 'web', true) . '" alt="' . esc_attr_e($gmedia_term->name) . '"/></div>';
799
- }
800
- }
801
-
802
- $output .= apply_filters('the_gmedia_content', wpautop($gmedia_term->description));
803
-
804
- if('get_the_excerpt' != $current_filter){
805
- $output .= do_shortcode("[gmedia id={$post->term_id}]");
806
- }
807
- }
808
- }
809
-
810
- if(is_single()){
811
- $before = '<div class="GmediaGallery_SinglePage">';
812
- $after = '</div>';
813
- } else{
814
- $before = '<div class="GmediaGallery_ArchivePage">';
815
- $after = '</div>';
816
- }
817
-
818
-
819
- $output = $before . $output . $after;
820
-
821
- $output = str_replace(array("\r\n", "\r", "\n"), '', $output);
822
- $output = preg_replace('/ {2,}/', ' ', $output);
823
-
824
- $post->post_content = $output;
825
- $post->gmedia_content = $output;
826
-
827
- return $output;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
828
  }
829
 
830
  /**
@@ -832,55 +939,55 @@ function gmedia_post_type__the_content($content){
832
  *
833
  * @return mixed|string
834
  */
835
- function gmedia_related__the_content($content){
836
- global $post, $gmDB, $gmGallery, $user_ID;
837
-
838
- remove_filter('the_content', 'gmedia_related__the_content', 200);
839
-
840
- $post_terms = get_the_tags($post->ID);
841
- if(empty($post_terms)){
842
- return $content;
843
- }
844
-
845
- $args = array(
846
- 'status' => array('publish'),
847
- 'orderby' => $gmGallery->options['in_tag_orderby'],
848
- 'order' => $gmGallery->options['in_tag_order'],
849
- 'null_tags' => true
850
- );
851
- if($user_ID){
852
- $args['status'][] = 'private';
853
- }
854
- foreach($post_terms as $term){
855
- $args['tag_name__in'][] = $term->name;
856
- }
857
-
858
- $per_page = (int) get_post_meta($post->ID, '_related_gmedia_per_page', true);
859
- if($per_page){
860
- $args['per_page'] = $per_page;
861
- }
862
-
863
- $gmedias = $gmDB->get_gmedias($args);
864
- if(empty($gmedias)){
865
- return $content;
866
- }
867
-
868
- unset($args['null_tags']);
869
- $gmedia_content = gmedia_shortcode(array('query' => $args));
870
-
871
- $gmedia_content = str_replace(array("\r\n", "\r", "\n"), '', $gmedia_content);
872
- $gmedia_content = preg_replace('/ {2,}/', ' ', $gmedia_content);
873
-
874
- $content .= apply_filters('before_gmedia_related__the_content', '');
875
- $content .= $gmedia_content;
876
- $content .= apply_filters('after_gmedia_related__the_content', '');
877
-
878
- return $content;
879
  }
880
 
881
- function gmedia_widget_comments_args($args){
882
- if(get_current_user_id()){
883
- $args['post_status'] = array('publish', 'private');
884
  }
885
 
886
  return $args;
2
  /**
3
  * FrontEnd Filters
4
  */
5
+ if ( ! defined( 'ABSPATH' ) ) {
6
+ exit;
7
  } // Exit if accessed directly
8
 
9
  global $gmGallery;
10
 
11
+ add_action( 'wp_head', 'gmogmeta_header', 2 ); // Generate og:image meta tag
12
+ add_action( 'pre_get_posts', 'gmedia_alter_query' ); // Show taxonomy archives for gmedia tags and categories
13
+ add_action( 'pre_get_posts', 'gmedia_alter_query_author', 100 ); // Show gmedia posts on author profile page
14
+ if ( (int) $gmGallery->options['wp_term_related_gmedia'] ) {
15
+ add_filter( 'the_posts', 'gmedia_the_posts_filter_taxonomy', 10, 2 ); // Prepend related gmedia for tags and categories archives
16
  }
17
+ add_action( 'the_post', 'gmedia_the_post' ); // Show Gmedia post types
18
 
19
  add_filter( 'widget_comments_args', 'gmedia_widget_comments_args', 10 );
20
 
21
  /**
22
  * Generate og:image meta tag
23
  */
24
+ function gmogmeta_header() {
25
+ global $gmDB, $gmCore;
26
+ $share_ref = (int) $gmCore->_get( 'gmedia_share', 0 );
27
+ $gmedia = false;
28
+ $is_single = is_single();
29
+ if ( $share_ref && ( $gmedia = $gmDB->get_gmedia( $share_ref ) ) ) {
30
+ //$og_url_id = $gmedia->post_id;
31
+ }
32
+ if ( $is_single ) {
33
+ global $post;
34
+ if ( ! $gmedia && isset( $post->post_type ) && $post->post_type == 'gmedia' ) {
35
+ $gmedia = $gmDB->get_post_gmedia( $post->ID );
36
+ }
37
+ //$og_url_id = $post->ID;
38
+ }
39
+ if ( $gmedia ) {
40
+ remove_action( 'wp_head', 'rel_canonical' );
41
+ $image_url = $gmCore->gm_get_media_image( $gmedia, 'web' );
42
+ $description = strip_tags( $gmedia->description );
43
+ if ( ! $description ) {
44
+ $description = get_bloginfo( 'description' );
45
+ }
46
+ ?>
47
+ <!-- Gmedia Open Graph Meta Image -->
48
+ <meta property="og:title" content="<?php echo esc_attr( $gmedia->title ); ?>"/>
49
+ <meta property="og:description" content="<?php echo esc_attr( $description ); ?>"/>
50
+ <meta property="og:image" content="<?php echo $image_url; ?>"/>
51
+ <!-- End Gmedia Open Graph Meta Image -->
52
+ <?php
53
+ }
54
  }
55
 
56
  /** Show taxonomy archives for gmedia tags and categories
57
  *
58
  * @param $query
59
  */
60
+ function gmedia_alter_query( $query ) {
61
+ if ( ! empty( $query->query['gmedia_tag'] ) ) {
62
+ $gm_tax = 'gmedia_tag';
63
+ } elseif ( ! empty( $query->query['gmedia_category'] ) ) {
64
+ $gm_tax = 'gmedia_category';
65
+ } else {
66
+ return;
67
+ }
68
+
69
+ global $wp_query, $gmDB, $gmGallery;
70
+ $term = urldecode( $query->query[ $gm_tax ] );
71
+ if ( ! $term || ! ( $term_id = $gmDB->term_exists( $term, $gm_tax ) ) ) {
72
+ return;
73
+ }
74
+
75
+ $args = array( 'fields' => 'post_ids', 'status' => array( 'publish' ) );
76
+ if ( get_current_user_id() ) {
77
+ $args['status'][] = 'private';
78
+ }
79
+ if ( 'gmedia_tag' == $gm_tax ) {
80
+ $args['tag__in'] = $term_id;
81
+ $args['orderby'] = $gmGallery->options['in_tag_orderby'];
82
+ $args['order'] = $gmGallery->options['in_tag_order'];
83
+ $wp_query->is_tag = true;
84
+ } elseif ( 'gmedia_category' == $gm_tax ) {
85
+ $args['category__in'] = $term_id;
86
+ $term_meta = $gmDB->get_metadata( 'gmedia_term', $term_id );
87
+ $args['orderby'] = isset( $term_meta['_orderby'][0] ) ? $term_meta['_orderby'][0] : $gmGallery->options['in_category_orderby'];
88
+ $args['order'] = isset( $term_meta['_order'][0] ) ? $term_meta['_order'][0] : $gmGallery->options['in_category_order'];
89
+ $wp_query->is_category = true;
90
+ }
91
+ $gmedias = $gmDB->get_gmedias( $args );
92
+ $post_ids = array();
93
+ foreach ( $gmedias as $item ) {
94
+ $post_ids[] = $item->post_id;
95
+ }
96
+ if ( ! empty( $post_ids ) ) {
97
+ $query->set( $gm_tax, null );
98
+ $query->set( 'post_type', 'gmedia' );
99
+ $query->set( 'post__in', $post_ids );
100
+ $query->set( 'orderby', 'post__in' );
101
+
102
+ $wp_query->is_tag = false;
103
+ $wp_query->is_category = false;
104
+ $wp_query->is_tax = false;
105
+ $wp_query->is_archive = true;
106
+
107
+ //we remove the actions hooked on the '__after_loop' (post navigation)
108
+ remove_all_actions( '__after_loop' );
109
+ }
110
  }
111
 
112
  /** Show gmedia posts on author profile page
113
  *
114
  * @param WP_Query $query
115
  */
116
+ function gmedia_alter_query_author( $query ) {
117
+ if ( empty( $query->query['author'] ) && empty( $query->query['author_name'] ) ) {
118
+ return;
119
+ }
120
+ global $gmGallery;
121
+
122
+ $gmedia_post_type = array();
123
+ if ( (int) $gmGallery->options['wp_author_related_gmedia'] ) {
124
+ $gmedia_post_type[] = 'gmedia';
125
+ }
126
+ if ( (int) $gmGallery->options['wp_author_related_gmedia_album'] ) {
127
+ $gmedia_post_type[] = 'gmedia_album';
128
+ }
129
+ if ( (int) $gmGallery->options['wp_author_related_gmedia_gallery'] ) {
130
+ $gmedia_post_type[] = 'gmedia_gallery';
131
+ }
132
+
133
+ if ( empty( $gmedia_post_type ) ) {
134
+ return;
135
+ }
136
+
137
+ $post_type = $query->get( 'post_type', array( 'post' ) );
138
+ $post_type = array_unique( array_merge( $gmedia_post_type, (array) $post_type ) );
139
+ $query->set( 'post_type', $post_type );
140
+
141
+ if ( get_current_user_id() ) {
142
+ $query->set( 'post_status', array( 'publish', 'private' ) );
143
  }
144
 
145
  //we remove the actions hooked on the '__after_loop' (post navigation)
146
+ remove_all_actions( '__after_loop' );
147
  }
148
 
149
  /** Add related media for tags and categories
153
  *
154
  * @return mixed
155
  */
156
+ function gmedia_the_posts_filter_taxonomy( $posts, $query ) {
157
+
158
+ $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
159
+ if ( $paged != 1 ) {
160
+ return $posts;
161
+ }
162
+
163
+ if ( ! empty( $query->query['tag'] ) ) {
164
+ $tax = 'tag';
165
+ } elseif ( ! empty( $query->query['category'] ) ) {
166
+ $tax = 'category';
167
+ } else {
168
+ return $posts;
169
+ }
170
+
171
+ global $wp_query, $gmDB, $gmGallery;
172
+ $term = urldecode( $query->query[ $tax ] );
173
+ $gm_tax = "gmedia_{$tax}";
174
+ if ( ! $term || ! ( $term_id = $gmDB->term_exists( $term, $gm_tax ) ) ) {
175
+ return $posts;
176
+ }
177
+
178
+ $args = array( 'fields' => 'post_ids', 'status' => array( 'publish' ), 'limit' => 1 );
179
+ if ( get_current_user_id() ) {
180
+ $args['status'][] = 'private';
181
+ }
182
+ if ( 'tag' == $tax ) {
183
+ $args['tag__in'] = $term_id;
184
+ $args['orderby'] = $gmGallery->options['in_tag_orderby'];
185
+ $args['order'] = $gmGallery->options['in_tag_order'];
186
+ $wp_query->is_tag = true;
187
+ } elseif ( 'category' == $tax ) {
188
+ $args['category__in'] = $term_id;
189
+ $term_meta = $gmDB->get_metadata( 'gmedia_term', $term_id );
190
+ $args['orderby'] = isset( $term_meta['_orderby'][0] ) ? $term_meta['_orderby'][0] : $gmGallery->options['in_category_orderby'];
191
+ $args['order'] = isset( $term_meta['_order'][0] ) ? $term_meta['_order'][0] : $gmGallery->options['in_category_order'];
192
+ $wp_query->is_category = true;
193
+ }
194
+ $gmedia_ids = $gmDB->get_gmedias( $args );
195
+ if ( count( $gmedia_ids ) ) {
196
+ $query->gmedia_term_post = $term_id;
197
+ array_unshift( $posts, $gmedia_ids[0]->post_id );
198
+ }
199
+
200
+ return $posts;
201
  }
202
 
203
  /** Show related media for tags and categories
204
  *
205
  * @param $post
206
  */
207
+ function gmedia_the_post( $post ) {
208
+ global $gmGallery;
209
+ if ( 'gmedia' == substr( $post->post_type, 0, 6 ) ) {
210
+ global $wp_query, $gmDB;
211
+ if ( isset( $wp_query->gmedia_term_post ) ) {
212
+ global $post;
213
+ $term = $gmDB->get_term( $wp_query->gmedia_term_post );
214
+ $date = gmdate( 'Y-m-d H:i:s' );
215
+ $post = (object) array(
216
+ 'ID' => 0,
217
+ 'term_id' => $term->term_id,
218
+ 'post_author' => 0,
219
+ 'post_date' => $date,
220
+ 'post_date_gmt' => $date,
221
+ 'post_content' => "[gm id={$term->term_id}]",
222
+ 'post_title' => __( 'Related Media', 'grand-media' ) . ': ' . $term->name,
223
+ 'post_excerpt' => '',
224
+ 'post_status' => 'publish',
225
+ 'comment_status' => 'closed',
226
+ 'ping_status' => 'closed',
227
+ 'post_password' => '',
228
+ 'post_name' => '',
229
+ 'to_ping' => '',
230
+ 'pinged' => '',
231
+ 'post_modified' => $date,
232
+ 'post_modified_gmt' => $date,
233
+ 'post_content_filtered' => '',
234
+ 'post_parent' => '0',
235
+ 'guid' => '',
236
+ 'menu_order' => '0',
237
+ 'post_type' => $term->taxonomy,
238
+ 'post_mime_type' => '',
239
+ 'comment_count' => '0',
240
+ 'filter' => 'raw',
241
+ );
242
+ $wp_query->posts[0] = $post;
243
+ $wp_query->post = $post;
244
+ unset( $wp_query->gmedia_term_post );
245
+ }
246
+ add_filter( 'get_the_excerpt', 'gmedia_post_type__the_excerpt', 150 );
247
+ add_filter( 'the_content', 'gmedia_post_type__the_content', 200 );
248
+ } elseif ( is_single() ) {
249
+ $gmedia_post_types = array_merge( array(
250
+ 'post',
251
+ 'page',
252
+ ), (array) $gmGallery->options['gmedia_post_types_support'] );
253
+ $gm_post_types = apply_filters( 'gmedia-post-types', $gmedia_post_types );
254
+ if ( in_array( $post->post_type, $gm_post_types ) ) {
255
+ $show_related = get_post_meta( $post->ID, '_related_gmedia', true );
256
+ if ( ( '1' === $show_related ) || ( ( '' === $show_related ) && (int) $gmGallery->options['wp_post_related_gmedia'] ) ) {
257
+ add_filter( 'the_content', 'gmedia_related__the_content', 200 );
258
+ }
259
+ }
260
+ }
261
  }
262
 
263
  /**
265
  *
266
  * @return mixed|string
267
  */
268
+ function gmedia_post_type__the_excerpt( $content ) {
269
+ global $post;
270
 
271
+ if ( 'gmedia' !== substr( $post->post_type, 0, 6 ) ) {
272
+ return $content;
273
+ }
274
 
275
+ remove_filter( 'get_the_excerpt', 'gmedia_post_type__the_excerpt', 150 );
276
+ remove_filter( 'the_content', 'gmedia_post_type__the_content', 200 );
277
+ $content = wp_trim_excerpt();
278
 
279
+ return gmedia_post_type__the_content( $content );
280
  }
281
 
282
  /**
284
  *
285
  * @return mixed|string
286
  */
287
+ function gmedia_post_type__the_content( $content ) {
288
+ global $post, $gmDB, $gmCore, $gmGallery;
289
+
290
+ if ( 'gmedia' !== substr( $post->post_type, 0, 6 ) ) {
291
+ return $content;
292
+ }
293
+
294
+ if ( isset( $post->gmedia_content ) ) {
295
+ $post->post_content = $post->gmedia_content;
296
+
297
+ return $post->gmedia_content;
298
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
299
 
300
+ remove_filter( 'the_content', 'gmedia_post_type__the_content', 200 );
301
+
302
+ $output = '';
303
+ if ( $post->post_type == 'gmedia' ) {
304
+ $gmedia_id = get_post_meta( $post->ID, '_gmedia_ID', true );
305
+ $gmedia = $gmDB->get_gmedia( $gmedia_id );
306
+ if ( $gmedia ) {
307
+ gmedia_item_more_data( $gmedia );
308
+
309
+ ob_start();
310
+
311
+ $embed_code = false;
312
+ if ( $gmedia->link ) {
313
+ $gmedia_link = $gmedia->link;
314
+ $base_url_host = parse_url( $gmCore->upload['url'], PHP_URL_HOST );
315
+ $url_host = parse_url( $gmedia->link, PHP_URL_HOST );
316
+ if ( $url_host == $base_url_host || empty( $url_host ) ) {
317
+ $link_target = ' target="_self"';
318
+ } else {
319
+ $link_target = ' target="_blank"';
320
+ $embed_code = wp_oembed_get( $gmedia_link );
321
+ }
322
+ if ( isset( $gmedia->meta['link_target'][0] ) ) {
323
+ $link_target = ' target="' . $gmedia->meta['link_target'][0] . '"';
324
+ }
325
+ } else {
326
+ $gmedia_link = $gmedia->url;
327
+ $link_target = '';
328
+ }
329
+
330
+ if ( 'image' == $gmedia->type ) {
331
+ if ( $embed_code ) {
332
+ echo '<div class="gmedia-item">' . $embed_code . '</div>';
333
+ } else {
334
+ ?>
335
+ <a class="gmedia-item-link" rel="gmedia-item"
336
+ href="<?php echo $gmedia_link; ?>"<?php echo $link_target; ?>><img class="gmedia-item"
337
+ style="max-width:100%;"
338
+ src="<?php echo $gmedia->url; ?>"
339
+ alt="<?php esc_attr_e( $gmedia->title ); ?>"/></a>
340
+ <?php
341
+ }
342
+
343
+ if ( is_single() && ! $embed_code ) {
344
+ /** more info */
345
+
346
+ $author_name = get_the_author_meta( 'display_name', $gmedia->author );
347
+ $author_posts_link = get_author_posts_url( $gmedia->author );
348
+ $avatar_img = get_avatar( $gmedia->author, 60 );
349
+ if ( preg_match( "/src=['\"](.*?)['\"]/i", $avatar_img, $matches ) ) {
350
+ $author_avatar = $matches[1];
351
+ }
352
+ ?>
353
+ <div class="gmsingle_wrapper gmsingle_clearfix">
354
+ <script type="text/html" class="gm_script2html">
355
+ <div class="gmsingle_photo_header gmsingle_clearfix">
356
+ <div class="gmsingle_name_wrap gmsingle_clearfix">
357
+ <?php if ( ! empty( $author_avatar ) ) { ?>
358
+ <div class="gmsingle_user_avatar">
359
+ <a class="gmsingle_user_avatar_link"
360
+ href="<?php echo urldecode( $author_posts_link ); ?>"><img
361
+ src="<?php echo $author_avatar; ?>" alt=""/></a>
362
+ </div>
363
+ <?php } ?>
364
+ <div class="gmsingle_title_author">
365
+ <div class="gmsingle_title"><?php
366
+ if ( ( 'image' != $gmedia->type ) && $gmedia->link ) {
367
+ echo "<a href='{$gmedia_link}'{$link_target}>{$gmedia->title}&nbsp;&#x1f517;</a>";
368
+ } else {
369
+ echo $gmedia->title;
370
+ }
371
+ ?>&nbsp;
372
+ </div>
373
+ <div class="gmsingle_author_name">
374
+ <a class="gmsingle_author_link"
375
+ href="<?php echo urldecode( $author_posts_link ); ?>"><?php echo $author_name; ?></a>
376
+ </div>
377
+ </div>
378
+ </div>
379
+ </div>
380
+ </script>
381
+ <div class="gmsingle_photo_info">
382
+ <div class="gmsingle_description_wrap">
383
+ <?php echo apply_filters( 'the_gmedia_content', wpautop( $gmedia->description ) ); ?>
384
+ <script type="text/html" class="gm_script2html">
385
+ <?php
386
+ if ( ! empty( $gmedia->album ) ) {
387
+ $term_name = $gmedia->album[0]->name;
388
+ $term_post_id = $gmDB->get_metadata( 'gmedia_term', $gmedia->album[0]->term_id, '_post_ID', true );
389
+ if ( ! empty( $term_post_id ) ) {
390
+ $term_url = get_permalink( $term_post_id );
391
+ } else {
392
+ $term_url = $gmCore->gmcloudlink( $gmedia->album[0]->term_id, 'album' );
393
+ }
394
+ ?>
395
+ <div class="gmsingle_terms">
396
+ <span class="gmsingle_term_label"><?php _e( 'Album' ); ?>:</span>
397
+ <span class="gmsingle_album"><span class="gmsingle_term"><a
398
+ href="<?php echo $term_url; ?>"><?php echo $term_name; ?></a></span></span>
399
+ </div>
400
+ <?php
401
+ }
402
+ if ( ! empty( $gmedia->categories ) ) {
403
+ $item_cats = array();
404
+ foreach ( $gmedia->categories as $term ) {
405
+ $term->slug = $term->name;
406
+ $term_url = get_term_link( $term );
407
+ //$term_url = $gmCore->gmcloudlink($term->term_id, 'category');
408
+ $item_cats[] = "<span class='gmsingle_term'><a href='{$term_url}'>{$term->name}</a></span>";
409
+ }
410
+ ?>
411
+ <div class="gmsingle_terms">
412
+ <span class="gmsingle_term_label"><?php _e( 'Categories' ); ?>:</span>
413
+ <span class="gmsingle_categories"><?php echo implode( ' ', $item_cats ); ?></span>
414
+ </div>
415
+ <?php
416
+ }
417
+ if ( ! empty( $gmedia->tags ) ) {
418
+ $item_tags = array();
419
+ foreach ( $gmedia->tags as $term ) {
420
+ $term->slug = $term->name;
421
+ $term_url = get_term_link( $term );
422
+ //$term_url = $gmCore->gmcloudlink($term->term_id, 'tag');
423
+ $item_tags[] = "<span class='gmsingle_term'><a href='{$term_url}'>#{$term->name}</a></span>";
424
+ }
425
+ ?>
426
+ <div class="gmsingle_terms">
427
+ <span class="gmsingle_term_label"><?php _e( 'Tags' ); ?>:</span>
428
+ <span class="gmsingle_tags"><?php echo implode( ' ', $item_tags ); ?></span>
429
+ </div>
430
+ <?php } ?>
431
+ </script>
432
+ </div>
433
+ <script type="text/html" class="gm_script2html">
434
+ <?php if ( $gmedia->gps ) {
435
+ $loc = str_replace( ' ', '', $gmedia->gps );
436
+ ?>
437
+ <div class="gmsingle_location_section">
438
+ <div class="gmsingle_details_title"><?php _e( 'Location' ); ?></div>
439
+
440
+ <div class="gmsingle_location_info">
441
+ <a href='https://www.google.com/maps/place/<?php echo $loc; ?>'
442
+ target='_blank'><img
443
+ src='//maps.googleapis.com/maps/api/staticmap?key=<?php esc_attr_e( $gmGallery->options['google_api_key'] ); ?>&size=320x240&zoom=10&scale=2&maptype=roadmap&markers=<?php echo $loc; ?>'
444
+ alt='' width='320' height='240'/></a>
445
+ </div>
446
+ </div>
447
+ <?php } ?>
448
+ <div class="gmsingle_details_section">
449
+ <div class="gmsingle_details_title"><?php _e( 'Details', 'grand-media' ); ?></div>
450
+
451
+ <div class="gmsingle_slide_details">
452
+ <?php /* ?>
453
  <div class='gmsingle_badges'>
454
  <div class='gmsingle_badges__column'>
455
  <div class='gmsingle_badges__label'><?php _e('Views', 'grand-media'); ?></div>
463
  </div>
464
  <?php
465
  */
466
+ $exif = $gmCore->metadata_info( $gmedia->ID );
467
+
468
+ $details = array();
469
+ if ( ! empty( $exif ) ) {
470
+ $details['model'] = empty( $exif['model'] ) ? '' : $exif['model']['value'];
471
+ $details['lens'] = empty( $exif['lens'] ) ? '' : $exif['lens']['value'];
472
+ $details['camera_settings'] = array(
473
+ 'focallength' => empty( $exif['focallength'] ) ? ( empty( $exif['focallength35'] ) ? '' : $exif['focallength35']['value'] ) : $exif['focallength']['value'],
474
+ 'aperture' => empty( $exif['aperture'] ) ? '' : str_replace( 'f', 'ƒ', $exif['aperture']['value'] ),
475
+ 'exposure' => empty( $exif['exposure'] ) ? '' : $exif['exposure']['value'],
476
+ 'iso' => empty( $exif['iso'] ) ? '' : 'ISO ' . $exif['iso']['value'],
477
+ );
478
+ $details['camera_settings'] = array_filter( $details['camera_settings'] );
479
+ $details['taken'] = empty( $exif['created_timestamp'] ) ? '' : date_i18n( get_option( 'date_format' ), $exif['created_timestamp']['value'] );
480
+ }
481
+ $details['uploaded'] = date_i18n( get_option( 'date_format' ), strtotime( $gmedia->date ) );
482
+
483
+ if ( ! empty( $details['model'] ) ) { ?>
484
+ <div class='gmsingle_exif'>
485
+ <div class='gmsingle_label gmsingle_exif_model'><?php echo $details['model']; ?></div>
486
+ <?php if ( ! empty( $details['lens'] ) ) { ?>
487
+ <div class='gmsingle_label_small gmsingle_exif_lens'><?php echo $details['lens']; ?></div>
488
+ <?php }
489
+ $camera_settings = array();
490
+ foreach ( $details['camera_settings'] as $key => $value ) {
491
+ $camera_settings[] = "<span class='gmsingle_exif_{$key}'>{$value}</span>";
492
+ }
493
+ if ( ! empty( $camera_settings ) ) { ?>
494
+ <div class='gmsingle_label_small gmsingle_camera_settings'><?php echo implode( '<span class="gmsingle_separator"> / </span>', $camera_settings ); ?></div>
495
+ <?php } ?>
496
+ </div>
497
+ <?php } ?>
498
+ <div class='gmsingle_meta'>
499
+ <?php if ( ! empty( $details['taken'] ) ) { ?>
500
+ <div class='gmsingle_clearfix'>
501
+ <span class='gmsingle_meta_key'><?php _e( 'Created', 'grand-media' ); ?></span>
502
+ <span class='gmsingle_meta_value'><?php echo $details['taken']; ?></span>
503
+ </div>
504
+ <?php } ?>
505
+ <div class='gmsingle_clearfix'>
506
+ <span class='gmsingle_meta_key'><?php _e( 'Uploaded', 'grand-media' ); ?></span>
507
+ <span class='gmsingle_meta_value'><?php echo $details['uploaded']; ?></span>
508
+ </div>
509
+ </div>
510
+ </div>
511
+ </div>
512
+ </script>
513
+ </div>
514
+ </div>
515
+ <style type="text/css">
516
+ .gmsingle_clearfix {
517
+ display: block;
518
+ }
519
+
520
+ .gmsingle_clearfix::after {
521
+ visibility: hidden;
522
+ display: block;
523
+ font-size: 0;
524
+ content: ' ';
525
+ clear: both;
526
+ height: 0;
527
+ }
528
+
529
+ .gmsingle_wrapper {
530
+ margin: 0 auto;
531
+ }
532
+
533
+ .gmsingle_wrapper * {
534
+ -webkit-box-sizing: border-box;
535
+ -moz-box-sizing: border-box;
536
+ box-sizing: border-box;
537
+ }
538
+
539
+ .gmsingle_photo_header {
540
+ margin-bottom: 15px;
541
+ }
542
+
543
+ .gmsingle_name_wrap {
544
+ padding: 24px 0 2px 80px;
545
+ height: 85px;
546
+ max-width: 100%;
547
+ overflow: hidden;
548
+ white-space: nowrap;
549
+ position: relative;
550
+ }
551
+
552
+ .gmsingle_name_wrap .gmsingle_user_avatar {
553
+ position: absolute;
554
+ top: 20px;
555
+ left: 0;
556
+ }
557
+
558
+ .gmsingle_name_wrap .gmsingle_user_avatar a.gmsingle_user_avatar_link {
559
+ display: block;
560
+ text-decoration: none;
561
+ }
562
+
563
+ .gmsingle_name_wrap .gmsingle_user_avatar img {
564
+ height: 60px !important;
565
+ width: auto;
566
+ overflow: hidden;
567
+ border-radius: 3px;
568
+ }
569
+
570
+ .gmsingle_name_wrap .gmsingle_title_author {
571
+ display: inline-block;
572
+ vertical-align: top;
573
+ max-width: 100%;
574
+ }
575
+
576
+ .gmsingle_name_wrap .gmsingle_title_author .gmsingle_title {
577
+ text-rendering: auto;
578
+ font-weight: 100;
579
+ font-size: 24px;
580
+ width: 100%;
581
+ overflow: hidden;
582
+ white-space: nowrap;
583
+ text-overflow: ellipsis;
584
+ margin: 0;
585
+ padding: 1px 0;
586
+ height: 1.1em;
587
+ line-height: 1;
588
+ box-sizing: content-box;
589
+ text-transform: none;
590
+ letter-spacing: 0px;
591
+ text-transform: capitalize;
592
+ }
593
+
594
+ .gmsingle_name_wrap .gmsingle_title_author > div {
595
+ font-size: 14px;
596
+ }
597
+
598
+ .gmsingle_name_wrap .gmsingle_title_author .gmsingle_author_name {
599
+ float: left;
600
+ }
601
+
602
+ .gmsingle_name_wrap .gmsingle_title_author a {
603
+ font-size: inherit;
604
+ }
605
+
606
+ .gmsingle_photo_info {
607
+ display: flex;
608
+ flex-wrap: wrap;
609
+ }
610
+
611
+ .gmsingle_details_title {
612
+ margin: 0;
613
+ padding: 0;
614
+ text-transform: uppercase;
615
+ font-size: 18px;
616
+ line-height: 1em;
617
+ font-weight: 300;
618
+ height: 1.1em;
619
+ display: inline-block;
620
+ overflow: visible;
621
+ border: none;
622
+ }
623
+
624
+ .gmsingle_description_wrap {
625
+ flex: 1;
626
+ overflow: hidden;
627
+ min-width: 220px;
628
+ max-width: 100%;
629
+ padding-right: 7px;
630
+ margin-bottom: 30px;
631
+ }
632
+
633
+ .gmsingle_description_wrap .gmsingle_terms {
634
+ overflow: hidden;
635
+ margin: 0;
636
+ position: relative;
637
+ font-size: 14px;
638
+ font-weight: 300;
639
+ }
640
+
641
+ .gmsingle_description_wrap .gmsingle_term_label {
642
+ margin-right: 10px;
643
+ }
644
+
645
+ .gmsingle_description_wrap .gmsingle_term_label:empty {
646
+ display: none;
647
+ }
648
+
649
+ .gmsingle_description_wrap .gmsingle_terms .gmsingle_term {
650
+ display: inline-block;
651
+ margin: 0 12px 1px 0;
652
+ }
653
+
654
+ .gmsingle_description_wrap .gmsingle_terms .gmsingle_term a {
655
+ white-space: nowrap;
656
+ }
657
+
658
+ .gmsingle_details_section {
659
+ flex: 1;
660
+ width: 33%;
661
+ padding-right: 7px;
662
+ padding-left: 7px;
663
+ min-width: 220px;
664
+ max-width: 100%;
665
+ }
666
+
667
+ .gmsingle_details_section .gmsingle_slide_details {
668
+ margin: 20px 0;
669
+ }
670
+
671
+ .gmsingle_location_section {
672
+ flex: 1;
673
+ width: 27%;
674
+ padding-right: 7px;
675
+ padding-left: 7px;
676
+ min-width: 220px;
677
+ max-width: 100%;
678
+ }
679
+
680
+ .gmsingle_location_section .gmsingle_location_info {
681
+ margin: 20px 0;
682
+ }
683
+
684
+ .gmsingle_location_section .gmsingle_location_info * {
685
+ display: block;
686
+ }
687
+
688
+ .gmsingle_location_section .gmsingle_location_info img {
689
+ width: 100%;
690
+ height: auto;
691
+ }
692
+
693
+ .gmsingle_badges {
694
+ border-bottom: 1px solid rgba(0, 0, 0, 0.1);
695
+ padding-bottom: 17px;
696
+ margin-bottom: 12px;
697
+ text-align: left;
698
+ font-weight: 300;
699
+ }
700
+
701
+ .gmsingle_badges__column {
702
+ display: inline-block;
703
+ vertical-align: top;
704
+ width: 40%;
705
+ min-width: 80px;
706
+ }
707
+
708
+ .gmsingle_badges__column .gmsingle_badges__label {
709
+ font-size: 14px;
710
+ }
711
+
712
+ .gmsingle_badges__column .gmsingle_badges__count {
713
+ font-size: 20px;
714
+ line-height: 1em;
715
+ margin-top: 1px;
716
+ }
717
+
718
+ .gmsingle_exif {
719
+ border-bottom: 1px solid rgba(0, 0, 0, 0.1);
720
+ padding-bottom: 12px;
721
+ margin-bottom: 12px;
722
+ text-align: left;
723
+ font-size: 14px;
724
+ line-height: 1.7em;
725
+ font-weight: 300;
726
+ }
727
+
728
+ .gmsingle_exif .gmsingle_camera_settings .gmsingle_separator {
729
+ font-weight: 200;
730
+ padding: 0 5px;
731
+ display: inline-block;
732
+ }
733
+
734
+ .gmsingle_meta {
735
+ padding-bottom: 12px;
736
+ margin-bottom: 12px;
737
+ text-align: left;
738
+ font-size: 14px;
739
+ line-height: 1.2em;
740
+ font-weight: 300;
741
+ }
742
+
743
+ .gmsingle_meta .gmsingle_meta_key {
744
+ float: left;
745
+ padding: 3px 0;
746
+ width: 40%;
747
+ min-width: 80px;
748
+ }
749
+
750
+ .gmsingle_meta .gmsingle_meta_value {
751
+ float: left;
752
+ white-space: nowrap;
753
+ padding: 3px 0;
754
+ text-transform: capitalize;
755
+ }
756
+ </style>
757
+ <?php
758
+ } else {
759
+ echo apply_filters( 'the_gmedia_content', wpautop( $gmedia->description ) );
760
+
761
+ if ( ! empty( $gmedia->album ) ) {
762
+ $term_name = $gmedia->album[0]->name;
763
+ $term_post_id = $gmDB->get_metadata( 'gmedia_term', $gmedia->album[0]->term_id, '_post_ID', true );
764
+ if ( ! empty( $term_post_id ) ) {
765
+ $term_url = get_permalink( $term_post_id );
766
+ } else {
767
+ $term_url = $gmCore->gmcloudlink( $gmedia->album[0]->term_id, 'album' );
768
+ }
769
+ ?>
770
+ <p class="gmsingle_terms">
771
+ <span class="gmsingle_term_label"><?php _e( 'Album' ); ?>:</span>
772
+ <span class="gmsingle_album"><span class="gmsingle_term"><a
773
+ href="<?php echo $term_url; ?>"><?php echo $term_name; ?></a></span></span>
774
+ </p>
775
+ <?php
776
+ }
777
+ if ( ! empty( $gmedia->categories ) ) {
778
+ $item_cats = array();
779
+ foreach ( $gmedia->categories as $term ) {
780
+ $term->slug = $term->name;
781
+ $term_url = get_term_link( $term );
782
+ //$term_url = $gmCore->gmcloudlink($term->term_id, 'category');
783
+ $item_cats[] = "<span class='gmsingle_term'><a href='{$term_url}'>{$term->name}</a></span>";
784
+ }
785
+ ?>
786
+ <p class="gmsingle_terms">
787
+ <span class="gmsingle_term_label"><?php _e( 'Categories' ); ?>:</span>
788
+ <span class="gmsingle_categories"><?php echo implode( ' ', $item_cats ); ?></span>
789
+ </p>
790
+ <?php
791
+ }
792
+ if ( ! empty( $gmedia->tags ) ) {
793
+ $item_tags = array();
794
+ foreach ( $gmedia->tags as $term ) {
795
+ $term->slug = $term->name;
796
+ $term_url = get_term_link( $term );
797
+ //$term_url = $gmCore->gmcloudlink($term->term_id, 'tag');
798
+ $item_tags[] = "<span class='gmsingle_term'><a href='{$term_url}'>#{$term->name}</a></span>";
799
+ }
800
+ ?>
801
+ <p class="gmsingle_terms">
802
+ <span class="gmsingle_term_label"><?php _e( 'Tags' ); ?>:</span>
803
+ <span class="gmsingle_tags"><?php echo implode( ' ', $item_tags ); ?></span>
804
+ </p>
805
+ <?php } ?>
806
+ <style type="text/css">
807
+ .gmsingle_terms { margin-top: 10px; }
808
+ </style>
809
+ <?php
810
+ }
811
+
812
+ } elseif ( 'audio' == $gmedia->type && ( $module = $gmCore->get_module_path( 'wavesurfer' ) ) && $module['name'] === 'wavesurfer' ) {
813
+ echo gmedia_shortcode( array( 'module' => 'wavesurfer', 'library' => $gmedia->ID, 'native' => true ) );
814
+ if ( is_single() ) {
815
+ echo apply_filters( 'the_gmedia_content', wpautop( $gmedia->description ) );
816
+ }
817
+ } else {
818
+ $ext1 = wp_get_audio_extensions();
819
+ $ext2 = wp_get_video_extensions();
820
+ $ext = array_merge( $ext1, $ext2 );
821
+ if ( in_array( $gmedia->ext, $ext ) ) {
822
+ global $wp_embed;
823
+ $embed = $wp_embed->run_shortcode( "[embed]$gmedia->url[/embed]" );
824
+ if ( '[' == substr( $embed, 0, 1 ) ) {
825
+ $embed = do_shortcode( $embed );
826
+ }
827
+ echo $embed;
828
+ } else {
829
+ $cover_url = $gmCore->gm_get_media_image( $gmedia, 'web' );
830
+ ?>
831
+ <a class="gmedia-item-link" href="<?php echo $gmedia->url; ?>" download="true"><img
832
+ class="gmedia-item" style="max-width:100%;" src="<?php echo $cover_url; ?>"
833
+ alt="<?php esc_attr_e( $gmedia->title ); ?>"/></a>
834
+ <?php
835
+ }
836
+
837
+ if ( ! empty( $gmedia->album ) ) {
838
+ $term_name = $gmedia->album[0]->name;
839
+ $term_post_id = $gmDB->get_metadata( 'gmedia_term', $gmedia->album[0]->term_id, '_post_ID', true );
840
+ if ( ! empty( $term_post_id ) ) {
841
+ $term_url = get_permalink( $term_post_id );
842
+ } else {
843
+ $term_url = $gmCore->gmcloudlink( $gmedia->album[0]->term_id, 'album' );
844
+ }
845
+ ?>
846
+ <p class="gmsingle_terms">
847
+ <span class="gmsingle_term_label"><?php _e( 'Album' ); ?>:</span>
848
+ <span class="gmsingle_album"><span class="gmsingle_term"><a
849
+ href="<?php echo $term_url; ?>"><?php echo $term_name; ?></a></span></span>
850
+ </p>
851
+ <?php
852
+ }
853
+ if ( ! empty( $gmedia->categories ) ) {
854
+ $item_cats = array();
855
+ foreach ( $gmedia->categories as $term ) {
856
+ $term->slug = $term->name;
857
+ $term_url = get_term_link( $term );
858
+ //$term_url = $gmCore->gmcloudlink($term->term_id, 'category');
859
+ $item_cats[] = "<span class='gmsingle_term'><a href='{$term_url}'>{$term->name}</a></span>";
860
+ }
861
+ ?>
862
+ <p class="gmsingle_terms">
863
+ <span class="gmsingle_term_label"><?php _e( 'Categories' ); ?>:</span>
864
+ <span class="gmsingle_categories"><?php echo implode( ' ', $item_cats ); ?></span>
865
+ </p>
866
+ <?php
867
+ }
868
+ if ( ! empty( $gmedia->tags ) ) {
869
+ $item_tags = array();
870
+ foreach ( $gmedia->tags as $term ) {
871
+ $term->slug = $term->name;
872
+ $term_url = get_term_link( $term );
873
+ //$term_url = $gmCore->gmcloudlink($term->term_id, 'tag');
874
+ $item_tags[] = "<span class='gmsingle_term'><a href='{$term_url}'>#{$term->name}</a></span>";
875
+ }
876
+ ?>
877
+ <p class="gmsingle_terms">
878
+ <span class="gmsingle_term_label"><?php _e( 'Tags' ); ?>:</span>
879
+ <span class="gmsingle_tags"><?php echo implode( ' ', $item_tags ); ?></span>
880
+ </p>
881
+ <?php } ?>
882
+ <style type="text/css">
883
+ .gmsingle_terms { margin-top: 10px; }
884
+ </style>
885
+ <?php
886
+ }
887
+
888
+ $output = ob_get_contents();
889
+ ob_end_clean();
890
+
891
+ }
892
+
893
+ } else {
894
+ if ( ! isset( $post->term_id ) ) {
895
+ $post->term_id = get_post_meta( $post->ID, '_gmedia_term_ID', true );
896
+ }
897
+ $output = '';
898
+ $gmedia_term = $gmDB->get_term( $post->term_id );
899
+ if ( $gmedia_term && ! is_wp_error( $gmedia_term ) ) {
900
+ add_filter( 'comments_open', '__return_false' );
901
+ $current_filter = current_filter();
902
+ if ( 'get_the_excerpt' == $current_filter ) {
903
+ $cover_id = $gmDB->get_metadata( 'gmedia_term', $post->term_id, '_cover', true );
904
+ if ( (int) $cover_id && ( $cover = $gmDB->get_gmedia( (int) $cover_id ) ) ) {
905
+ $output .= '<div class="gmedia-term-cover"><img class="gmedia-item" style="max-width:100%;" src="' . $gmCore->gm_get_media_image( $cover, 'web', true ) . '" alt="' . esc_attr_e( $gmedia_term->name ) . '"/></div>';
906
+ }
907
+ }
908
+
909
+ $output .= apply_filters( 'the_gmedia_content', wpautop( $gmedia_term->description ) );
910
+
911
+ if ( 'get_the_excerpt' != $current_filter ) {
912
+ $output .= do_shortcode( "[gmedia id={$post->term_id}]" );
913
+ }
914
+ }
915
+ }
916
+
917
+ if ( is_single() ) {
918
+ $before = '<div class="GmediaGallery_SinglePage">';
919
+ $after = '</div>';
920
+ } else {
921
+ $before = '<div class="GmediaGallery_ArchivePage">';
922
+ $after = '</div>';
923
+ }
924
+
925
+
926
+ $output = $before . $output . $after;
927
+
928
+ $output = str_replace( array( "\r\n", "\r", "\n" ), '', $output );
929
+ $output = preg_replace( '/ {2,}/', ' ', $output );
930
+
931
+ $post->post_content = $output;
932
+ $post->gmedia_content = $output;
933
+
934
+ return $output;
935
  }
936
 
937
  /**
939
  *
940
  * @return mixed|string
941
  */
942
+ function gmedia_related__the_content( $content ) {
943
+ global $post, $gmDB, $gmGallery, $user_ID;
944
+
945
+ remove_filter( 'the_content', 'gmedia_related__the_content', 200 );
946
+
947
+ $post_terms = get_the_tags( $post->ID );
948
+ if ( empty( $post_terms ) ) {
949
+ return $content;
950
+ }
951
+
952
+ $args = array(
953
+ 'status' => array( 'publish' ),
954
+ 'orderby' => $gmGallery->options['in_tag_orderby'],
955
+ 'order' => $gmGallery->options['in_tag_order'],
956
+ 'null_tags' => true,
957
+ );
958
+ if ( $user_ID ) {
959
+ $args['status'][] = 'private';
960
+ }
961
+ foreach ( $post_terms as $term ) {
962
+ $args['tag_name__in'][] = $term->name;
963
+ }
964
+
965
+ $per_page = (int) get_post_meta( $post->ID, '_related_gmedia_per_page', true );
966
+ if ( $per_page ) {
967
+ $args['per_page'] = $per_page;
968
+ }
969
+
970
+ $gmedias = $gmDB->get_gmedias( $args );
971
+ if ( empty( $gmedias ) ) {
972
+ return $content;
973
+ }
974
+
975
+ unset( $args['null_tags'] );
976
+ $gmedia_content = gmedia_shortcode( array( 'query' => $args ) );
977
+
978
+ $gmedia_content = str_replace( array( "\r\n", "\r", "\n" ), '', $gmedia_content );
979
+ $gmedia_content = preg_replace( '/ {2,}/', ' ', $gmedia_content );
980
+
981
+ $content .= apply_filters( 'before_gmedia_related__the_content', '' );
982
+ $content .= $gmedia_content;
983
+ $content .= apply_filters( 'after_gmedia_related__the_content', '' );
984
+
985
+ return $content;
986
  }
987
 
988
+ function gmedia_widget_comments_args( $args ) {
989
+ if ( get_current_user_id() ) {
990
+ $args['post_status'] = array( 'publish', 'private' );
991
  }
992
 
993
  return $args;
inc/functions.php CHANGED
@@ -95,9 +95,9 @@ function get_gmedia_modules($including_remote = true){
95
  $modules['in'][ $name ] = array_merge($modules['in'][ $name ], $xml_module);
96
  if(version_compare($modules['xml'][ $name ]['version'], $modules['in'][ $name ]['version'], '>')){
97
  $modules['in'][ $name ]['update'] = $modules['xml'][ $name ]['version'];
98
- $modules['xml'][ $name ]['place'] = 'remote';
99
- $modules['xml'][ $name ]['update'] = true;
100
- $modules['out'][ $name ] = $modules['xml'][ $name ];
101
  }
102
  } else{
103
  $modules['xml'][ $name ]['place'] = 'remote';
@@ -227,32 +227,35 @@ function gmedia_term_item_more_data(&$item){
227
 
228
  if($item->global){
229
  $item->author_name = get_the_author_meta('display_name', $item->global);
 
 
 
230
  } else{
231
  $item->author_name = false;
232
  }
233
 
234
  $item->taxterm = str_replace('gmedia_', '', $item->taxonomy);
235
  if('gmedia_album' == $item->taxonomy){
236
- $post_id = isset($meta['_post_ID'][0])? (int)$meta['_post_ID'][0] : 0;
237
- $item->post_id = $post_id;
238
- if($post_id){
239
- $post_item = get_post($post_id);
240
- if($post_item){
241
- $item->post_date = $post_item->post_date;
242
- $item->slug = $post_item->post_name;
243
- $item->post_password = $post_item->post_password;
244
- $item->comment_count = $post_item->comment_count;
245
- $item->comment_status = $post_item->comment_status;
246
- }
 
 
 
 
 
 
247
  }
248
  }
249
-
250
  $item->cloud_link = $gmCore->gmcloudlink($item->term_id, $item->taxterm);
251
- if(!empty($item->meta['_post_ID'][0])){
252
- $item->post_link = get_permalink($item->meta['_post_ID'][0]);
253
- } else{
254
- $item->post_link = '';
255
- }
256
 
257
  if(is_user_logged_in()){
258
  $allow_terms_delete = gm_user_can('terms_delete');
@@ -319,24 +322,24 @@ function gmedia_gallery_more_data(&$item){
319
  }
320
  }
321
 
322
- $post_id = isset($meta['_post_ID'][0])? (int)$meta['_post_ID'][0] : 0;
323
- $item->post_id = $post_id;
324
- if($post_id){
325
- $post_item = get_post($post_id);
326
- if($post_item){
327
- $item->slug = $post_item->post_name;
328
- $item->post_password = $post_item->post_password;
329
- $item->comment_count = $post_item->comment_count;
330
- $item->comment_status = $post_item->comment_status;
331
- }
 
 
 
 
 
 
332
  }
333
-
334
  $item->cloud_link = $gmCore->gmcloudlink($item->term_id, $item->taxterm);
335
- if(!empty($item->meta['_post_ID'])){
336
- $item->post_link = get_permalink($item->meta['_post_ID']);
337
- } else{
338
- $item->post_link = '';
339
- }
340
 
341
  if(is_user_logged_in()){
342
  $allow_terms_delete = gm_user_can('terms_delete');
@@ -370,6 +373,9 @@ function gmedia_gallery_more_data(&$item){
370
 
371
  if($item->global){
372
  $item->author_name = get_the_author_meta('display_name', $item->global);
 
 
 
373
  } else{
374
  $item->author_name = false;
375
  }
@@ -435,4 +441,88 @@ function gmedia_array_filter_recursive( $input ) {
435
  return array_filter( $input, function( $val ) {
436
  return is_string( $val ) ? strlen( $val ) : ! empty( $val );
437
  } );
438
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  $modules['in'][ $name ] = array_merge($modules['in'][ $name ], $xml_module);
96
  if(version_compare($modules['xml'][ $name ]['version'], $modules['in'][ $name ]['version'], '>')){
97
  $modules['in'][ $name ]['update'] = $modules['xml'][ $name ]['version'];
98
+ //$modules['xml'][ $name ]['place'] = 'remote';
99
+ //$modules['xml'][ $name ]['update'] = true;
100
+ //$modules['out'][ $name ] = $modules['xml'][ $name ];
101
  }
102
  } else{
103
  $modules['xml'][ $name ]['place'] = 'remote';
227
 
228
  if($item->global){
229
  $item->author_name = get_the_author_meta('display_name', $item->global);
230
+ if(!$item->author_name){
231
+ $item->global = 0;
232
+ }
233
  } else{
234
  $item->author_name = false;
235
  }
236
 
237
  $item->taxterm = str_replace('gmedia_', '', $item->taxonomy);
238
  if('gmedia_album' == $item->taxonomy){
239
+ $post_id = isset( $meta['_post_ID'][0] ) ? (int) $meta['_post_ID'][0] : 0;
240
+ $item->post_id = $post_id;
241
+ $item->slug = '';
242
+ $item->post_link = '';
243
+ if($post_id) {
244
+ $post_item = get_post( $post_id );
245
+ if($post_item){
246
+ $item->post_date = $post_item->post_date;
247
+ $item->slug = $post_item->post_name;
248
+ $item->post_password = $post_item->post_password;
249
+ $item->comment_count = $post_item->comment_count;
250
+ $item->comment_status = $post_item->comment_status;
251
+
252
+ if(!empty($item->meta['_post_ID'][0])){
253
+ $item->post_link = (string) get_permalink($item->meta['_post_ID'][0]);
254
+ }
255
+ }
256
  }
257
  }
 
258
  $item->cloud_link = $gmCore->gmcloudlink($item->term_id, $item->taxterm);
 
 
 
 
 
259
 
260
  if(is_user_logged_in()){
261
  $allow_terms_delete = gm_user_can('terms_delete');
322
  }
323
  }
324
 
325
+ $post_id = isset( $meta['_post_ID'][0] ) ? (int) $meta['_post_ID'][0] : 0;
326
+ $item->post_id = $post_id;
327
+ $item->slug = '';
328
+ $item->post_link = '';
329
+ if($post_id) {
330
+ $post_item = get_post( $post_id );
331
+ if($post_item){
332
+ $item->slug = $post_item->post_name;
333
+ $item->post_password = $post_item->post_password;
334
+ $item->comment_count = $post_item->comment_count;
335
+ $item->comment_status = $post_item->comment_status;
336
+
337
+ if(!empty($item->meta['_post_ID'])){
338
+ $item->post_link = (string) get_permalink($item->meta['_post_ID']);
339
+ }
340
+ }
341
  }
 
342
  $item->cloud_link = $gmCore->gmcloudlink($item->term_id, $item->taxterm);
 
 
 
 
 
343
 
344
  if(is_user_logged_in()){
345
  $allow_terms_delete = gm_user_can('terms_delete');
373
 
374
  if($item->global){
375
  $item->author_name = get_the_author_meta('display_name', $item->global);
376
+ if( !$item->author_name ) {
377
+ $item->global = 0;
378
+ }
379
  } else{
380
  $item->author_name = false;
381
  }
441
  return array_filter( $input, function( $val ) {
442
  return is_string( $val ) ? strlen( $val ) : ! empty( $val );
443
  } );
444
+ }
445
+
446
+ /**
447
+ * Delete all transients with a key prefix.
448
+ *
449
+ * @param string $prefix The key prefix.
450
+ */
451
+ function gmedia_delete_transients( $prefix ) {
452
+ gmedia_delete_transients_from_keys( gmedia_search_database_for_transients_by_prefix( $prefix ) );
453
+ }
454
+
455
+ /**
456
+ * Searches the database for transients stored there that match a specific prefix.
457
+ *
458
+ * @param string $prefix Prefix to search for.
459
+ * @return array|bool Nested array response for wpdb->get_results or false on failure.
460
+ */
461
+ function gmedia_search_database_for_transients_by_prefix( $prefix ) {
462
+ global $wpdb;
463
+
464
+ // Add our prefix after concating our prefix with the _transient prefix.
465
+ $prefix = $wpdb->esc_like( '_transient_' . $prefix . '_' );
466
+
467
+ // Build up our SQL query.
468
+ $sql = "SELECT `option_name` FROM $wpdb->options WHERE `option_name` LIKE '%s'";
469
+
470
+ // Execute our query
471
+ $transients = $wpdb->get_results( $wpdb->prepare( $sql, $prefix . '%' ), ARRAY_A );
472
+
473
+ // If if looks good, pass it back.
474
+ if ( $transients && ! is_wp_error( $transients ) ) {
475
+ return $transients;
476
+ }
477
+
478
+ // Otherwise return false.
479
+ return false;
480
+ }
481
+
482
+ /**
483
+ * Expects a passed in multidimensional array of transient keys.
484
+ *
485
+ * array(
486
+ * array( 'option_name' => '_transient_blah_blah' ),
487
+ * array( 'option_name' => 'transient_another_one' ),
488
+ * )
489
+ *
490
+ * Can also pass in an array of transient names.
491
+ *
492
+ * @param array|string $transients Nested array of transients, keyed by option_name, or array of names of transients.
493
+ * @return array|bool Count of total vs deleted or false on failure.
494
+ */
495
+ function gmedia_delete_transients_from_keys( $transients ) {
496
+ if ( ! isset( $transients ) ) {
497
+ return false;
498
+ }
499
+
500
+ // If we get a string key passed in, might as well use it correctly.
501
+ if ( is_string( $transients ) ) {
502
+ $transients = array( array( 'option_name' => $transients ) );
503
+ }
504
+
505
+ // If its not an array, we can't do anything.
506
+ if ( ! is_array( $transients ) ) {
507
+ return false;
508
+ }
509
+
510
+ $results = array();
511
+
512
+ // Loop through our transients.
513
+ foreach ( $transients as $transient ) {
514
+ if ( is_array( $transient ) ) {
515
+ // If we have an array, grab the first element.
516
+ $transient = current( $transient );
517
+ }
518
+
519
+ // Remove that sucker.
520
+ $results[ $transient ] = delete_transient( str_replace( '_transient_', '', $transient ) );
521
+ }
522
+
523
+ // Return an array of total number, and number deleted.
524
+ return array(
525
+ 'total' => count( $results ),
526
+ 'deleted' => array_sum( $results ),
527
+ );
528
+ }
inc/media-upload.php CHANGED
@@ -744,7 +744,7 @@ function gmedia_add_media_terms(){
744
 
745
  function gmedia_add_media_library(){
746
 
747
- global $user_ID, $gmCore, $gmDB, $gmGallery;
748
 
749
  wp_enqueue_style('gmedia-bootstrap');
750
  wp_enqueue_script('gmedia-bootstrap');
744
 
745
  function gmedia_add_media_library(){
746
 
747
+ global $user_ID, $gmCore, $gmDB;
748
 
749
  wp_enqueue_style('gmedia-bootstrap');
750
  wp_enqueue_script('gmedia-bootstrap');
inc/permalinks.php CHANGED
@@ -239,11 +239,13 @@ class gmediaPermalinks {
239
  *
240
  * @return string html output
241
  */
242
- function gmedia_post_thumbnail( $html, $post_id, $post_thumbnail_id, $size = 'post-thumbnail', $attr = '' ) {
243
 
244
- $gmedia_id = get_post_meta( $post_thumbnail_id, '_gmedia_image_id', true );
245
- if ( ! empty( $gmedia_id ) ) {
246
- $html = str_replace( 'wp-post-image', 'wp-post-image gmedia-post-thumbnail-' . $gmedia_id, $html );
 
 
247
  }
248
 
249
  return $html;
239
  *
240
  * @return string html output
241
  */
242
+ function gmedia_post_thumbnail( $html, $post_id = 0, $post_thumbnail_id = 0, $size = 'post-thumbnail', $attr = '' ) {
243
 
244
+ if ( $post_thumbnail_id ) {
245
+ $gmedia_id = get_post_meta( $post_thumbnail_id, '_gmedia_image_id', true );
246
+ if ( ! empty( $gmedia_id ) ) {
247
+ $html = str_replace( 'wp-post-image', 'wp-post-image gmedia-post-thumbnail-' . $gmedia_id, $html );
248
+ }
249
  }
250
 
251
  return $html;
inc/shortcodes.php CHANGED
@@ -1,16 +1,16 @@
1
  <?php
2
- if(preg_match('#' . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])){
3
- die('You are not allowed to call this page directly.');
4
  }
5
 
6
  /** *********************** **/
7
  /** Shortcodes Declarations **/
8
  /** *********************** **/
9
- add_shortcode('gmedia', 'gmedia_shortcode');
10
- add_shortcode('gm', 'gmedia_shortcode');
11
 
12
  //add_filter('the_content', 'do_shortcode');
13
- add_filter('the_content', 'get_gmedia_unformatted_shortcode_blocks', 4);
14
 
15
  /** ******************************* **/
16
  /** Shortcodes Functions and Markup **/
@@ -23,347 +23,404 @@ $gmedia_shortcode_instance = array();
23
  *
24
  * @return string
25
  */
26
- function gmedia_shortcode($atts, $shortcode_post_content = ''){
27
- global $gmDB, $gmGallery, $gmCore;
28
- global $gmedia_shortcode_instance, $gmedia_shortcode_ids;
29
-
30
- $shortcode_raw = (isset($atts['_raw']) && '1' === $atts['_raw']);
31
- $shortcode_copy = isset($atts['_copy'])? (int)$atts['_copy'] : null;
32
- unset($atts['_raw'], $atts['_copy']);
33
-
34
- $atts_hash = md5(build_query($atts));
35
- if(!isset($atts['id'])){
36
- if(!empty($atts['album'])){
37
- $atts['id'] = $atts['album'];
38
- unset($atts['album']);
39
- } elseif(!empty($atts['category'])){
40
- $atts['id'] = $atts['category'];
41
- unset($atts['category']);
42
- } elseif(!empty($atts['tag'])){
43
- $atts['id'] = $atts['tag'];
44
- unset($atts['tag']);
45
- }
46
- }
47
-
48
- if(isset($gmedia_shortcode_instance[ $atts_hash ])){
49
- $out = $gmedia_shortcode_instance[ $atts_hash ]['shortcode'];
50
- ++ $gmedia_shortcode_instance[ $atts_hash ]['copy'];
51
- if(!$shortcode_raw){
52
- $sc_id = $gmedia_shortcode_instance[ $atts_hash ]['id'];
53
- $sc_copy = (null === $shortcode_copy)? $gmedia_shortcode_instance[ $atts_hash ]['copy'] : $shortcode_copy;
54
- if($sc_copy){
55
- $out = str_replace($sc_id, "{$sc_id}_{$sc_copy}", $out);
56
- }
57
- }
58
-
59
- return $out;
60
- } else{
61
- $gmedia_shortcode_instance[ $atts_hash ] = array('shortcode' => '',
62
- 'id' => '',
63
- 'copy' => 0
64
- );
65
- }
66
- $shortcode_raw = (isset($gmGallery->options['shortcode_raw']) && '1' === $gmGallery->options['shortcode_raw']);
67
-
68
- $query = array();
69
- if(!empty($atts['query'])){
70
- if(is_string($atts['query'])){
71
- $atts['query'] = html_entity_decode($atts['query']);
72
- }
73
- $query = wp_parse_args($atts['query'], array());
74
- }
75
-
76
- $atts_module = !empty($atts['module']);
77
- $_module = $atts_module? $atts['module'] : $gmGallery->options['default_gmedia_module'];
78
- $preset = $gmCore->getModulePreset($_module);
79
- $_module = $preset['module'];
80
- $settings = $preset['settings'];
81
-
82
- $id = isset($atts['id'])? (int)$atts['id'] : 0;
83
- $userid = get_current_user_id();
84
- if($id && ($term = gmedia_shortcode_id_data($id))){
85
- $is_gallery_visible = ('publish' !== $term->status && !$userid) || ('draft' === $term->status && $userid != $term->global && !is_super_admin());
86
- if(apply_filters('is_gmedia_gallery_visible', $is_gallery_visible)){
87
- return '';
88
- }
89
-
90
- $taxterm = str_replace('gmedia_', '', $term->taxonomy);
91
- if($taxterm === 'gallery'){
92
- if(!empty($term->meta['_query'])){
93
- $query = array_merge($query, $term->meta['_query']);
94
- }
95
- } else{
96
- $query = array_merge($query, array("{$taxterm}__in" => $term->term_id));
97
- }
98
-
99
- if(!empty($term->meta['_module'])){
100
- $_module = $term->meta['_module'];
101
- } elseif(!$atts_module && !empty($term->meta['_module_preset'])){
102
- $preset = $gmCore->getModulePreset($term->meta['_module_preset']);
103
- $_module = $preset['module'];
104
- $settings = $preset['settings'];
105
-
106
- $term->meta['_module'] = $_module;
107
- $term->meta['_settings'][ $_module ] = (array)$settings[ $_module ];
108
- }
109
- if(isset($term->meta['_settings'][ $_module ])){
110
- $settings = (array)$term->meta['_settings'];
111
- }
112
- } elseif(isset($atts['library']) && ($quick_gallery = wp_parse_id_list($atts['library']))){
113
- $query = array_merge($query, array('gmedia__in' => $quick_gallery));
114
- if(!isset($query['orderby'])){
115
- $query['orderby'] = 'gmedia__in';
116
- }
117
- }
118
- if(empty($term)){
119
- $term = (object) array(
120
- 'name' => '',
121
- 'description' => '',
122
- );
123
- }
124
- if(isset($atts['orderby'])){
125
- $query['orderby'] = $atts['orderby'];
126
- }
127
- if(isset($atts['order'])){
128
- $query['order'] = $atts['order'];
129
- }
130
-
131
- if($userid && current_user_can('gmedia_gallery_manage') && ($preview_module = $gmCore->_get('gmedia_module'))){
132
- if($preview_module != $_module){
133
- $_module = $preview_module;
134
- $preset = $gmCore->getModulePreset($_module);
135
- if($preset['module'] == $_module){
136
- $settings = $preset['settings'];
137
- } else{
138
- $settings = array($_module => array());
139
- }
140
- }
141
- }
142
-
143
- $gallery = array();
144
- if(!$id){
145
- $id = $atts_hash;
146
- // Backward compatibility
147
- $gallery = array('term_id' => $id,
148
- 'name' => __('Gallery', 'grand-media'),
149
- 'description' => ''
150
- );
151
- }
152
-
153
- $module = $gmCore->get_module_path($_module);
154
- if(!$module || !is_file($module['path'] . '/index.php') || !is_file($module['path'] . '/settings.php')){
155
- return '<div class="gmedia_gallery gmediaShortcodeError" data-gmid="' . $id . '" data-error="' . $_module . ': folder missed or module broken">' . $shortcode_post_content . '</div>';
156
- }
157
-
158
- if($_module !== $module['name']){
159
- $_module = $module['name'];
160
- $settings = array($_module => array());
161
- }
162
-
163
- if(!empty($atts['preset'])){
164
- $preset = $gmDB->get_term($atts['preset'], 'gmedia_module');
165
- if(!empty($preset) && !is_wp_error($preset) && ($module['name'] == $preset->status)){
166
- $settings = array($module['name'] => (array)maybe_unserialize($preset->description));
167
- }
168
- }
169
-
170
- $protected_query_args = array('status' => array('publish'));
171
- if($userid){
172
- $protected_query_args['status'][] = 'private';
173
- }
174
- $query = array_merge(apply_filters('gmedia_shortcode_query', $query, $id), $protected_query_args);
175
-
176
- include($module['path'] . '/index.php');
177
- include($module['path'] . '/settings.php');
178
- $module['info'] = isset($module_info)? $module_info : array('dependencies' => '');
179
- $module['options'] = isset($default_options)? $default_options : array();
180
-
181
- $settings = apply_filters('gmedia_shortcode_settings', $gmCore->array_diff_keyval_recursive((array)$settings[ $module['name'] ], $module['options'], false));
182
-
183
- $moduleCSS = isset($gmGallery->do_module[ $_module ])? '' : $gmGallery->load_module_styles($module);
184
- $customCSS = (isset($settings['customCSS']) && ('' !== trim($settings['customCSS'])))? $settings['customCSS'] : '';
185
-
186
- $gmGallery->do_module[ $_module ] = $module;
187
- $gmGallery->shortcode[ $id ] = compact('id', 'query', 'module', 'settings', 'term');
188
-
189
- unset($settings['customCSS']);
190
-
191
- if(empty($module['info']['branch'])){
192
- $query = array($id => $query);
193
- if(!empty($term)){
194
- if(in_array($_module, array('afflux', 'afflux-mod', 'cube', 'flatwall', 'green-style', 'minima', 'optima', 'photo-blog', 'photo-pro', 'slider', 'sphere'))){
195
- add_filter('jetpack_photon_skip_image', 'jetpack_photon_skip_gmedia', 10, 3);
196
- $_query = array_merge($query[ $id ], array('album__status' => $protected_query_args['status']));
197
- $gmDB->gmedias_album_stuff($_query);
198
- if(!empty($_query['album__in']) && empty($_query['album__not_in'])){
199
- $album__in = wp_parse_id_list($_query['album__in']);
200
- foreach($_query as $key => $q){
201
- if('alb' === substr($key, 0, 3)){
202
- unset($_query[ $key ]);
203
- }
204
- }
205
- foreach($album__in as $alb){
206
- $album = $gmDB->get_term($alb);
207
- if(empty($album) || is_wp_error($album) || $album->count == 0){
208
- continue;
209
- }
210
- $terms[ $alb ] = $album;
211
- $new_query[ $alb ] = array_merge($_query, array('album__in' => $alb));
212
- }
213
- if(!empty($new_query)){
214
- $query = $new_query;
215
- }
216
- }
217
- }
218
- if(empty($terms)){
219
- $terms = array($id => $term);
220
- }
221
- $gallery = (array)$term;
222
- } else{
223
- $terms = array($id => (object)$gallery);
224
- }
225
-
226
- $gmedia = array();
227
- foreach($query as $term_id => $args){
228
- if(empty($args['orderby']) || empty($args['order'])){
229
- $term_query_order = null;
230
- if(isset($args['tag__in']) && (!isset($args['category__in']) && !isset($args['album__in']))){
231
- $term_query_order = array('orderby' => $gmGallery->options['in_tag_orderby'],
232
- 'order' => $gmGallery->options['in_tag_order']
233
- );
234
- }
235
- if(isset($args['category__in']) && !isset($args['album__in'])){
236
- $cat_ids = wp_parse_id_list($args['category__in']);
237
- if(1 === count($cat_ids)){
238
- $cat_meta = $gmDB->get_metadata('gmedia_term', $cat_ids[0]);
239
- $term_query_order = array('orderby' => !empty($cat_meta['_orderby'][0])? $cat_meta['_orderby'][0] : $gmGallery->options['in_category_orderby'],
240
- 'order' => !empty($cat_meta['_order'][0])? $cat_meta['_order'][0] : $gmGallery->options['in_category_order']
241
- );
242
- }
243
- }
244
- if(isset($args['album__in'])){
245
- $alb_ids = wp_parse_id_list($args['album__in']);
246
- if(1 === count($alb_ids)){
247
- $album_meta = $gmDB->get_metadata('gmedia_term', $alb_ids[0]);
248
- $term_query_order = array('orderby' => !empty($album_meta['_orderby'][0])? $album_meta['_orderby'][0] : $gmGallery->options['in_album_orderby'],
249
- 'order' => !empty($album_meta['_order'][0])? $album_meta['_order'][0] : $gmGallery->options['in_album_order']
250
- );
251
- }
252
- }
253
- if($term_query_order){
254
- $args = array_merge($term_query_order, $args);
255
- }
256
- }
257
- $gmedia[ $term_id ] = $gmDB->get_gmedias($args);
258
- }
259
-
260
- if(0 === count($gmedia)){
261
- return '<div class="gmedia_gallery gmedia_gallery_empty" data-gmid="' . esc_attr($id) . '" data-module="' . $_module . '">' . __('Gallery is empty') . '<br />' . $shortcode_post_content . '</div>';
262
- }
263
- } else {
264
- $gmDB->gmedias_album_stuff($query);
265
- $gmDB->gmedias_category_stuff($query);
266
- $gmDB->gmedias_tag_stuff($query);
267
- if(isset($query['album__in'])){
268
- $query['album__in'] = join( ',', $query['album__in']);
269
- }
270
- if(isset($query['category__in'])){
271
- $query['category__in'] = join( ',', $query['category__in']);
272
- }
273
- if(isset($query['tag__in'])){
274
- $query['tag__in'] = join( ',', $query['tag__in']);
275
- }
276
- }
277
-
278
- $is_bot = false;
279
- if(!($is_mob = wp_is_mobile())){
280
- $is_bot = $gmCore->is_bot();
281
- }
282
-
283
- $sc_id = str_replace(' ', '_', "GmediaGallery_{$id}");
284
-
285
- $sc_classes = "gmedia_gallery {$_module}_module";
286
- if($is_bot){
287
- $sc_classes .= " is_bot";
288
- }
289
- if($is_mob){
290
- $sc_classes .= " is_mobile";
291
- }
292
- if(!empty($atts['class'])){
293
- $sc_classes .= ' ' . esc_attr($atts['class']);
294
- }
295
-
296
- $sc_styles = '';
297
- if(!empty($atts['style'])){
298
- $sc_styles = ' style="' . esc_attr($atts['style']) . '"';
299
- }
300
-
301
- do_action('pre_gmedia_shortcode');
302
-
303
- $out = '<div class="' . $sc_classes . '" id="' . esc_attr($sc_id) . '" data-gmid="' . esc_attr($id) . '" data-module="' . esc_attr($_module) . '"' . $sc_styles . '>';
304
-
305
- if(
306
- in_array($_module, array('albums-switcher', 'photocluster', 'albumsview'))
307
- && empty($query['album__in']) && empty($query['category__in']) && empty($query['tag__in'])
308
- ){
309
- $out = __('This Gmedia gallery module require at least one term (album, category or tag) to be chosen in Query Builder.', 'grand-media');
310
- $module_content = '';
311
- } else {
312
-
313
- ob_start();
314
- /** @noinspection PhpIncludeInspection */
315
- include( $module['path'] . '/init.php' );
316
- $module_content = ob_get_contents();
317
- ob_end_clean();
318
-
319
- }
320
-
321
- if($moduleCSS || $customCSS){
322
- $out .= "<style type='text/css' class='gmedia_module_style_import'>{$moduleCSS}";
323
- if($customCSS){
324
- $out .= "/**** .{$_module}_module #{$sc_id} ****/{$customCSS}";
325
- }
326
- $out .= '</style>';
327
- }
328
- $out .= $shortcode_post_content;
329
- $out .= $module_content;
330
- $out .= '</div>';
331
-
332
- $id_duplicount = 0;
333
- if(empty($gmedia_shortcode_ids)){
334
- $gmedia_shortcode_ids[] = (string)$id;
335
- } else{
336
- if(in_array($id, $gmedia_shortcode_ids)){
337
- $id_duplicount = 1;
338
- while(true){
339
- if(in_array("{$id}_{$id_duplicount}", $gmedia_shortcode_ids)){
340
- $id_duplicount ++;
341
- } else{
342
- $gmedia_shortcode_ids[] = "{$id}_{$id_duplicount}";
343
- break;
344
- }
345
- }
346
- } else{
347
- $gmedia_shortcode_ids[] = (string)$id;
348
- }
349
- }
350
-
351
- if($id_duplicount){
352
- $_sc_id = "{$sc_id}_{$id_duplicount}";
353
- $out = str_replace($sc_id, $_sc_id, $out);
354
-
355
- $gmedia_shortcode_instance[ $atts_hash ]['_id'] = $_sc_id;
356
- }
357
- $gmedia_shortcode_instance[ $atts_hash ]['id'] = $sc_id;
358
- $gmedia_shortcode_instance[ $atts_hash ]['shortcode'] = $out;
359
-
360
- do_action('gmedia_shortcode');
361
-
362
- if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
363
- do_action('gmedia_enqueue_scripts');
364
- }
365
-
366
- return $out;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
367
 
368
  }
369
 
@@ -372,6 +429,7 @@ function gmedia_shortcode($atts, $shortcode_post_content = ''){
372
  * Since the gmedia raw shortcode needs to be run earlier than other shortcodes,
373
  * this function removes all existing shortcodes, uses the shortcode parser to grab all [gmedia blocks],
374
  * calls {@link do_shortcode()}, and then re-registers the old shortcodes.
 
375
  * @uses $shortcode_tags
376
  * @uses remove_all_shortcodes()
377
  * @uses add_shortcode()
@@ -381,30 +439,30 @@ function gmedia_shortcode($atts, $shortcode_post_content = ''){
381
  *
382
  * @return string Content with shortcode parsed
383
  */
384
- function get_gmedia_unformatted_shortcode_blocks($content){
385
- global $gmGallery;
386
 
387
- if(!(int)$gmGallery->options['shortcode_raw']){
388
- return $content;
389
- }
390
 
391
- global $shortcode_tags;
392
 
393
- // Back up current registered shortcodes and clear them all out
394
- $orig_shortcode_tags = $shortcode_tags;
395
- remove_all_shortcodes();
396
 
397
- // gmedia_raw_shortcode(), below, saves the rawr blocks into $this->unformatted_shortcode_blocks[]
398
- add_shortcode('gmedia', 'gmedia_raw_shortcode');
399
- add_shortcode('gm', 'gmedia_raw_shortcode');
400
 
401
- // Do the shortcode (only the [gmedia] shortcodes are now registered)
402
- $content = do_shortcode($content);
403
 
404
- // Put the original shortcodes back for normal processing at priority 11
405
- $shortcode_tags = $orig_shortcode_tags;
406
 
407
- return $content;
408
  }
409
 
410
  /**
@@ -413,35 +471,35 @@ function get_gmedia_unformatted_shortcode_blocks($content){
413
  *
414
  * @return string
415
  */
416
- function gmedia_raw_shortcode($atts, $shortcode_post_content = ''){
417
- global $wp_filter, $merged_filters, $wp_current_filter;
418
- $wp_filter_ = $wp_filter;
419
- $merged_filters_ = $merged_filters;
420
- $wp_current_filter_ = $wp_current_filter;
421
- $noraw = do_shortcode(apply_filters('the_content', '[raw][/raw]'));
422
- $wp_filter = $wp_filter_;
423
- $merged_filters = $merged_filters_;
424
- $wp_current_filter = $wp_current_filter_;
425
-
426
- global $gmedia_shortcode_instance;
427
-
428
- unset($atts['_raw'], $atts['_copy']);
429
- $atts_hash = md5(build_query($atts));
430
- $atts['_raw'] = '1';
431
- gmedia_shortcode($atts, $shortcode_post_content);
432
- unset($atts['_raw']);
433
-
434
- $atts['_copy'] = $gmedia_shortcode_instance[ $atts_hash ]['copy'];
435
- $shortcode_atts = '';
436
- // Put the shortcode tag back with raw index, so it gets processed again below.
437
- foreach($atts as $key => $value){
438
- $shortcode_atts .= " {$key}='{$value}'";
439
- }
440
- if(!$noraw){
441
- return "[raw][gmedia{$shortcode_atts}]{$shortcode_post_content}[/gmedia][/raw]";
442
- } else{
443
- return "[gmedia{$shortcode_atts}]{$shortcode_post_content}[/gmedia]";
444
- }
445
  }
446
 
447
  /**
@@ -449,44 +507,44 @@ function gmedia_raw_shortcode($atts, $shortcode_post_content = ''){
449
  *
450
  * @return object
451
  */
452
- function gmedia_shortcode_id_data($id){
453
- global $gmDB, $gmCore;
454
-
455
- $item = $gmDB->get_term($id);
456
-
457
- if(empty($item) || is_wp_error($item)){
458
- return false;
459
- }
460
-
461
- $meta = $gmDB->get_metadata('gmedia_term', $item->term_id);
462
-
463
- if($item->global){
464
- $item->author_name = get_the_author_meta('display_name', $item->global);
465
- } else{
466
- $item->author_name = '';
467
- }
468
-
469
- $post_id = isset($meta['_post_ID'][0])? (int)$meta['_post_ID'][0] : 0;
470
- $item->post_id = $post_id;
471
- if($post_id){
472
- $post_item = get_post($post_id);
473
- if($post_item){
474
- $item->slug = $post_item->post_name;
475
- $item->post_password = $post_item->post_password;
476
- $item->comment_count = $post_item->comment_count;
477
- $item->comment_status = $post_item->comment_status;
478
- }
479
- }
480
-
481
- $item->custom_meta = array();
482
- $item->meta = array();
483
- foreach($meta as $key => $value){
484
- if($gmCore->is_protected_meta($key, 'gmedia_term')){
485
- $item->meta[ $key ] = $value[0];
486
- } else{
487
- $item->custom_meta[ $key ] = $value;
488
- }
489
- }
490
-
491
- return apply_filters('gmedia_shortcode_id_data', $item);
492
  }
1
  <?php
2
+ if ( preg_match( '#' . basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ) . '#', $_SERVER['PHP_SELF'] ) ) {
3
+ die( 'You are not allowed to call this page directly.' );
4
  }
5
 
6
  /** *********************** **/
7
  /** Shortcodes Declarations **/
8
  /** *********************** **/
9
+ add_shortcode( 'gmedia', 'gmedia_shortcode' );
10
+ add_shortcode( 'gm', 'gmedia_shortcode' );
11
 
12
  //add_filter('the_content', 'do_shortcode');
13
+ add_filter( 'the_content', 'get_gmedia_unformatted_shortcode_blocks', 4 );
14
 
15
  /** ******************************* **/
16
  /** Shortcodes Functions and Markup **/
23
  *
24
  * @return string
25
  */
26
+ function gmedia_shortcode( $atts, $shortcode_post_content = '' ) {
27
+ global $gmDB, $gmGallery, $gmCore;
28
+ global $gmedia_shortcode_instance, $gmedia_shortcode_ids;
29
+
30
+ $shortcode_raw = ( isset( $atts['_raw'] ) && '1' === $atts['_raw'] );
31
+ $shortcode_copy = isset( $atts['_copy'] ) ? (int) $atts['_copy'] : null;
32
+ unset( $atts['_raw'], $atts['_copy'] );
33
+
34
+ $atts_hash = md5( build_query( $atts ) );
35
+ if ( ! isset( $atts['id'] ) ) {
36
+ if ( ! empty( $atts['album'] ) ) {
37
+ $atts['id'] = $atts['album'];
38
+ unset( $atts['album'] );
39
+ } elseif ( ! empty( $atts['category'] ) ) {
40
+ $atts['id'] = $atts['category'];
41
+ unset( $atts['category'] );
42
+ } elseif ( ! empty( $atts['tag'] ) ) {
43
+ $atts['id'] = $atts['tag'];
44
+ unset( $atts['tag'] );
45
+ }
46
+ }
47
+
48
+ if ( isset( $gmedia_shortcode_instance[ $atts_hash ] ) ) {
49
+ $out = $gmedia_shortcode_instance[ $atts_hash ]['shortcode'];
50
+ ++ $gmedia_shortcode_instance[ $atts_hash ]['copy'];
51
+ if ( ! $shortcode_raw ) {
52
+ $sc_id = $gmedia_shortcode_instance[ $atts_hash ]['id'];
53
+ $sc_copy = ( null === $shortcode_copy ) ? $gmedia_shortcode_instance[ $atts_hash ]['copy'] : $shortcode_copy;
54
+ if ( $sc_copy ) {
55
+ $out = str_replace( $sc_id, "{$sc_id}_{$sc_copy}", $out );
56
+ }
57
+ }
58
+
59
+ return $out;
60
+ } else {
61
+ $gmedia_shortcode_instance[ $atts_hash ] = array(
62
+ 'shortcode' => '',
63
+ 'id' => '',
64
+ 'copy' => 0,
65
+ );
66
+ }
67
+ $shortcode_raw = ( isset( $gmGallery->options['shortcode_raw'] ) && '1' === $gmGallery->options['shortcode_raw'] );
68
+ $cache_expiration = isset( $gmGallery->options['cache_expiration'] ) ? (int) $gmGallery->options['cache_expiration'] * HOUR_IN_SECONDS : 24 * HOUR_IN_SECONDS;
69
+
70
+ $query = array();
71
+ if ( ! empty( $atts['query'] ) ) {
72
+ if ( is_string( $atts['query'] ) ) {
73
+ $atts['query'] = html_entity_decode( $atts['query'] );
74
+ }
75
+ $query = wp_parse_args( $atts['query'], array() );
76
+ }
77
+
78
+ $atts_module = ! empty( $atts['module'] );
79
+ $_module = $atts_module ? $atts['module'] : $gmGallery->options['default_gmedia_module'];
80
+ $preset = $gmCore->getModulePreset( $_module );
81
+ $_module = $preset['module'];
82
+ $settings = $preset['settings'];
83
+
84
+ $id = isset( $atts['id'] ) ? (int) $atts['id'] : 0;
85
+ $userid = get_current_user_id();
86
+ if ( $id && ( $term = gmedia_shortcode_id_data( $id ) ) ) {
87
+ $is_gallery_visible = ( 'publish' !== $term->status && ! $userid ) || ( 'draft' === $term->status && $userid != $term->global && ! is_super_admin() );
88
+ if ( apply_filters( 'is_gmedia_gallery_visible', $is_gallery_visible ) ) {
89
+ return '';
90
+ }
91
+
92
+ $taxterm = str_replace( 'gmedia_', '', $term->taxonomy );
93
+ if ( $taxterm === 'gallery' ) {
94
+ if ( ! empty( $term->meta['_query'] ) ) {
95
+ $query = array_merge( $query, $term->meta['_query'] );
96
+ }
97
+ } else {
98
+ $query = array_merge( $query, array( "{$taxterm}__in" => $term->term_id ) );
99
+ }
100
+
101
+ if ( ! empty( $term->meta['_module'] ) ) {
102
+ $_module = $term->meta['_module'];
103
+ } elseif ( ! $atts_module && ! empty( $term->meta['_module_preset'] ) ) {
104
+ $preset = $gmCore->getModulePreset( $term->meta['_module_preset'] );
105
+ $_module = $preset['module'];
106
+ $settings = $preset['settings'];
107
+
108
+ $term->meta['_module'] = $_module;
109
+ $term->meta['_settings'][ $_module ] = (array) $settings[ $_module ];
110
+ }
111
+ if ( isset( $term->meta['_settings'][ $_module ] ) ) {
112
+ $settings = (array) $term->meta['_settings'];
113
+ }
114
+ } elseif ( isset( $atts['library'] ) && ( $quick_gallery = wp_parse_id_list( $atts['library'] ) ) ) {
115
+ $query = array_merge( $query, array( 'gmedia__in' => $quick_gallery ) );
116
+ if ( ! isset( $query['orderby'] ) ) {
117
+ $query['orderby'] = 'gmedia__in';
118
+ }
119
+ }
120
+ if ( empty( $term ) ) {
121
+ $term = (object) array(
122
+ 'name' => '',
123
+ 'description' => '',
124
+ );
125
+ }
126
+ if ( isset( $atts['orderby'] ) ) {
127
+ $query['orderby'] = $atts['orderby'];
128
+ }
129
+ if ( isset( $atts['order'] ) ) {
130
+ $query['order'] = $atts['order'];
131
+ }
132
+
133
+ if ( $userid && current_user_can( 'gmedia_gallery_manage' ) && ( $preview_module = $gmCore->_get( 'gmedia_module' ) ) ) {
134
+ if ( $preview_module != $_module ) {
135
+ $_module = $preview_module;
136
+ $preset = $gmCore->getModulePreset( $_module );
137
+ if ( $preset['module'] == $_module ) {
138
+ $settings = $preset['settings'];
139
+ } else {
140
+ $settings = array( $_module => array() );
141
+ }
142
+ }
143
+ }
144
+
145
+ $gallery = array();
146
+ if ( ! $id ) {
147
+ $id = $atts_hash;
148
+ // Backward compatibility
149
+ $gallery = array(
150
+ 'term_id' => $id,
151
+ 'name' => __( 'Gallery', 'grand-media' ),
152
+ 'description' => '',
153
+ );
154
+ }
155
+
156
+ $module = $gmCore->get_module_path( $_module );
157
+ if ( ! $module || ! is_file( $module['path'] . '/index.php' ) || ! is_file( $module['path'] . '/settings.php' ) ) {
158
+ return '<div class="gmedia_gallery gmediaShortcodeError" data-gmid="' . $id . '" data-error="' . $_module . ': folder missed or module broken">' . $shortcode_post_content . '</div>';
159
+ }
160
+
161
+ if ( $_module !== $module['name'] ) {
162
+ $_module = $module['name'];
163
+ $settings = array( $_module => array() );
164
+ }
165
+
166
+ if ( ! empty( $atts['preset'] ) ) {
167
+ $preset = $gmDB->get_term( $atts['preset'], 'gmedia_module' );
168
+ if ( ! empty( $preset ) && ! is_wp_error( $preset ) && ( $module['name'] == $preset->status ) ) {
169
+ $settings = array( $module['name'] => (array) maybe_unserialize( $preset->description ) );
170
+ }
171
+ }
172
+
173
+ $protected_query_args = array( 'status' => array( 'publish' ) );
174
+ if ( $userid ) {
175
+ $protected_query_args['status'][] = 'private';
176
+ }
177
+ $query = array_merge( apply_filters( 'gmedia_shortcode_query', $query, $id ), $protected_query_args );
178
+
179
+ include( $module['path'] . '/index.php' );
180
+ include( $module['path'] . '/settings.php' );
181
+ $module['info'] = isset( $module_info ) ? $module_info : array( 'dependencies' => '' );
182
+ $module['options'] = isset( $default_options ) ? $default_options : array();
183
+
184
+ $settings = apply_filters( 'gmedia_shortcode_settings', $gmCore->array_diff_keyval_recursive( (array) $settings[ $module['name'] ], $module['options'], false ) );
185
+
186
+ $moduleCSS = isset( $gmGallery->do_module[ $_module ] ) ? '' : $gmGallery->load_module_styles( $module );
187
+ $customCSS = ( isset( $settings['customCSS'] ) && ( '' !== trim( $settings['customCSS'] ) ) ) ? $settings['customCSS'] : '';
188
+
189
+ $gmGallery->do_module[ $_module ] = $module;
190
+ $gmGallery->shortcode[ $id ] = compact( 'id', 'query', 'module', 'settings', 'term' );
191
+
192
+ $is_bot = false;
193
+ if ( ! ( $is_mob = wp_is_mobile() ) ) {
194
+ $is_bot = $gmCore->is_bot();
195
+ }
196
+ $mob_cache_key = $is_mob ? '_mob' : '';
197
+
198
+ if ( $cache_expiration ) {
199
+ $cache_key = md5( json_encode( $gmGallery->shortcode[ $id ] ) );
200
+ $cache_value = get_transient( 'gm_cache_' . $cache_key );
201
+ if ( ! $is_bot ) {
202
+ $cache_value_m = get_transient( 'gm_cache_m_' . $cache_key . $mob_cache_key );
203
+ } else {
204
+ $cache_value_m = false;
205
+ }
206
+ }
207
+
208
+ unset( $settings['customCSS'] );
209
+
210
+ if ( empty( $module['info']['branch'] ) ) {
211
+ $gmedia = array();
212
+ if ( ! empty( $cache_value ) && is_array( $cache_value ) ) {
213
+ extract( $cache_value, EXTR_OVERWRITE );
214
+ } else {
215
+ $query = array( $id => $query );
216
+ if ( ! empty( $term ) ) {
217
+ if ( in_array( $_module, array( 'afflux', 'afflux-mod', 'cube', 'flatwall', 'green-style', 'minima', 'optima', 'photo-blog', 'photo-pro', 'slider', 'sphere' ) ) ) {
218
+ add_filter( 'jetpack_photon_skip_image', 'jetpack_photon_skip_gmedia', 10, 3 );
219
+ $_query = array_merge( $query[ $id ], array( 'album__status' => $protected_query_args['status'] ) );
220
+ $gmDB->gmedias_album_stuff( $_query );
221
+ if ( ! empty( $_query['album__in'] ) && empty( $_query['album__not_in'] ) ) {
222
+ $album__in = wp_parse_id_list( $_query['album__in'] );
223
+ foreach ( $_query as $key => $q ) {
224
+ if ( 'alb' === substr( $key, 0, 3 ) ) {
225
+ unset( $_query[ $key ] );
226
+ }
227
+ }
228
+ foreach ( $album__in as $alb ) {
229
+ $album = $gmDB->get_term( $alb );
230
+ if ( empty( $album ) || is_wp_error( $album ) || $album->count == 0 ) {
231
+ continue;
232
+ }
233
+ $terms[ $alb ] = $album;
234
+ $new_query[ $alb ] = array_merge( $_query, array( 'album__in' => $alb ) );
235
+ }
236
+ if ( ! empty( $new_query ) ) {
237
+ $query = $new_query;
238
+ }
239
+ }
240
+ }
241
+ if ( empty( $terms ) ) {
242
+ $terms = array( $id => $term );
243
+ }
244
+ $gallery = (array) $term;
245
+ } else {
246
+ $terms = array( $id => (object) $gallery );
247
+ }
248
+
249
+ foreach ( $query as $term_id => $args ) {
250
+ if ( empty( $args['orderby'] ) || empty( $args['order'] ) ) {
251
+ $term_query_order = null;
252
+ if ( isset( $args['tag__in'] ) && ( ! isset( $args['category__in'] ) && ! isset( $args['album__in'] ) ) ) {
253
+ $term_query_order = array(
254
+ 'orderby' => $gmGallery->options['in_tag_orderby'],
255
+ 'order' => $gmGallery->options['in_tag_order'],
256
+ );
257
+ }
258
+ if ( isset( $args['category__in'] ) && ! isset( $args['album__in'] ) ) {
259
+ $cat_ids = wp_parse_id_list( $args['category__in'] );
260
+ if ( 1 === count( $cat_ids ) ) {
261
+ $cat_meta = $gmDB->get_metadata( 'gmedia_term', $cat_ids[0] );
262
+ $term_query_order = array(
263
+ 'orderby' => ! empty( $cat_meta['_orderby'][0] ) ? $cat_meta['_orderby'][0] : $gmGallery->options['in_category_orderby'],
264
+ 'order' => ! empty( $cat_meta['_order'][0] ) ? $cat_meta['_order'][0] : $gmGallery->options['in_category_order'],
265
+ );
266
+ }
267
+ }
268
+ if ( isset( $args['album__in'] ) ) {
269
+ $alb_ids = wp_parse_id_list( $args['album__in'] );
270
+ if ( 1 === count( $alb_ids ) ) {
271
+ $album_meta = $gmDB->get_metadata( 'gmedia_term', $alb_ids[0] );
272
+ $term_query_order = array(
273
+ 'orderby' => ! empty( $album_meta['_orderby'][0] ) ? $album_meta['_orderby'][0] : $gmGallery->options['in_album_orderby'],
274
+ 'order' => ! empty( $album_meta['_order'][0] ) ? $album_meta['_order'][0] : $gmGallery->options['in_album_order'],
275
+ );
276
+ }
277
+ }
278
+ if ( $term_query_order ) {
279
+ $args = array_merge( $term_query_order, $args );
280
+ }
281
+ }
282
+ $gmedia[ $term_id ] = $gmDB->get_gmedias( $args );
283
+ }
284
+
285
+ if ( $cache_expiration ) {
286
+ set_transient( 'gm_cache_' . $cache_key, array( 'gallery' => $gallery, 'gmedia' => $gmedia, 'terms' => $terms, 'query' => $query ), $cache_expiration );
287
+ }
288
+ }
289
+
290
+ if ( 0 === count( $gmedia ) ) {
291
+ return '<div class="gmedia_gallery gmedia_gallery_empty" data-gmid="' . esc_attr( $id ) . '" data-module="' . $_module . '">' . __( 'Gallery is empty' ) . '<br />' . $shortcode_post_content . '</div>';
292
+ }
293
+ } else {
294
+ if ( ! empty( $cache_value ) && is_array( $cache_value ) ) {
295
+ $query = $cache_value;
296
+ } else {
297
+ $gmDB->gmedias_album_stuff( $query );
298
+ $gmDB->gmedias_category_stuff( $query );
299
+ $gmDB->gmedias_tag_stuff( $query );
300
+ if ( isset( $query['album__in'] ) ) {
301
+ $query['album__in'] = join( ',', $query['album__in'] );
302
+ }
303
+ if ( isset( $query['category__in'] ) ) {
304
+ $query['category__in'] = join( ',', $query['category__in'] );
305
+ }
306
+ if ( isset( $query['tag__in'] ) ) {
307
+ $query['tag__in'] = join( ',', $query['tag__in'] );
308
+ }
309
+
310
+ if ( $cache_expiration ) {
311
+ set_transient( 'gm_cache_' . $cache_key, $query, $cache_expiration );
312
+ }
313
+ }
314
+ }
315
+
316
+ $sc_id = str_replace( ' ', '_', "GmediaGallery_{$id}" );
317
+
318
+ $sc_classes = "gmedia_gallery {$_module}_module";
319
+ if ( $is_bot ) {
320
+ $sc_classes .= " is_bot";
321
+ }
322
+ if ( $is_mob ) {
323
+ $sc_classes .= " is_mobile";
324
+ }
325
+ if ( ! empty( $atts['class'] ) ) {
326
+ $sc_classes .= ' ' . esc_attr( $atts['class'] );
327
+ }
328
+
329
+ $sc_styles = '';
330
+ if ( ! empty( $atts['style'] ) ) {
331
+ $sc_styles = ' style="' . esc_attr( $atts['style'] ) . '"';
332
+ }
333
+
334
+ do_action( 'pre_gmedia_shortcode' );
335
+
336
+ if ( ! empty( $cache_value_m ) ) {
337
+ $out = $cache_value_m;
338
+ } else {
339
+ $out = '<div class="' . $sc_classes . '" id="' . esc_attr( $sc_id ) . '" data-gmid="' . esc_attr( $id ) . '" data-module="' . esc_attr( $_module ) . '"' . $sc_styles . '>';
340
+
341
+ if (
342
+ in_array( $_module, array( 'albums-switcher', 'photocluster', 'albumsview' ) )
343
+ && empty( $query['album__in'] ) && empty( $query['category__in'] ) && empty( $query['tag__in'] )
344
+ ) {
345
+ $out = __( 'This Gmedia gallery module require at least one term (album, category or tag) to be chosen in Query Builder.', 'grand-media' );
346
+ $module_content = '';
347
+ } else {
348
+ ob_start();
349
+ /** @noinspection PhpIncludeInspection */
350
+ include( $module['path'] . '/init.php' );
351
+ $module_content = ob_get_contents();
352
+ ob_end_clean();
353
+
354
+ $matches = array();
355
+ preg_match_all( '/<img[\s\r\n]+.*?>/is', $module_content, $matches );
356
+ $search = array();
357
+ $replace = array();
358
+ foreach ( $matches[0] as $img_html ) {
359
+ // add the noLazy class to the img element.
360
+ if ( preg_match( '/class=["\']/i', $img_html ) ) {
361
+ $replace_html = preg_replace( '/class=(["\'])(.*?)["\']/is', 'class=$1noLazy $2$1', $img_html );
362
+ } else {
363
+ $replace_html = preg_replace( '/<img/is', '<img class="noLazy"', $img_html );
364
+ }
365
+ array_push( $search, $img_html );
366
+ array_push( $replace, $replace_html );
367
+ }
368
+ $search = array_unique( $search );
369
+ $replace = array_unique( $replace );
370
+ $module_content = str_replace( $search, $replace, $module_content );
371
+ }
372
+
373
+ if ( $moduleCSS || $customCSS ) {
374
+ $out .= "<style type='text/css' class='gmedia_module_style_import'>{$moduleCSS}";
375
+ if ( $customCSS ) {
376
+ $out .= "/**** .{$_module}_module #{$sc_id} ****/{$customCSS}";
377
+ }
378
+ $out .= '</style>';
379
+ }
380
+ $out .= $shortcode_post_content;
381
+ $out .= $module_content;
382
+ $out .= '</div>';
383
+
384
+ if ( $cache_expiration && ! $is_bot ) {
385
+ set_transient( 'gm_cache_m_' . $cache_key . $mob_cache_key, $out, $cache_expiration );
386
+ }
387
+ }
388
+
389
+ $id_duplicount = 0;
390
+ if ( empty( $gmedia_shortcode_ids ) ) {
391
+ $gmedia_shortcode_ids[] = (string) $id;
392
+ } else {
393
+ if ( in_array( $id, $gmedia_shortcode_ids ) ) {
394
+ $id_duplicount = 1;
395
+ while ( true ) {
396
+ if ( in_array( "{$id}_{$id_duplicount}", $gmedia_shortcode_ids ) ) {
397
+ $id_duplicount ++;
398
+ } else {
399
+ $gmedia_shortcode_ids[] = "{$id}_{$id_duplicount}";
400
+ break;
401
+ }
402
+ }
403
+ } else {
404
+ $gmedia_shortcode_ids[] = (string) $id;
405
+ }
406
+ }
407
+
408
+ if ( $id_duplicount ) {
409
+ $_sc_id = "{$sc_id}_{$id_duplicount}";
410
+ $out = str_replace( $sc_id, $_sc_id, $out );
411
+
412
+ $gmedia_shortcode_instance[ $atts_hash ]['_id'] = $_sc_id;
413
+ }
414
+ $gmedia_shortcode_instance[ $atts_hash ]['id'] = $sc_id;
415
+ $gmedia_shortcode_instance[ $atts_hash ]['shortcode'] = $out;
416
+
417
+ do_action( 'gmedia_shortcode' );
418
+
419
+ if ( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && strtolower( $_SERVER['HTTP_X_REQUESTED_WITH'] ) == 'xmlhttprequest' ) {
420
+ do_action( 'gmedia_enqueue_scripts' );
421
+ }
422
+
423
+ return $out;
424
 
425
  }
426
 
429
  * Since the gmedia raw shortcode needs to be run earlier than other shortcodes,
430
  * this function removes all existing shortcodes, uses the shortcode parser to grab all [gmedia blocks],
431
  * calls {@link do_shortcode()}, and then re-registers the old shortcodes.
432
+ *
433
  * @uses $shortcode_tags
434
  * @uses remove_all_shortcodes()
435
  * @uses add_shortcode()
439
  *
440
  * @return string Content with shortcode parsed
441
  */
442
+ function get_gmedia_unformatted_shortcode_blocks( $content ) {
443
+ global $gmGallery;
444
 
445
+ if ( ! (int) $gmGallery->options['shortcode_raw'] ) {
446
+ return $content;
447
+ }
448
 
449
+ global $shortcode_tags;
450
 
451
+ // Back up current registered shortcodes and clear them all out
452
+ $orig_shortcode_tags = $shortcode_tags;
453
+ remove_all_shortcodes();
454
 
455
+ // gmedia_raw_shortcode(), below, saves the rawr blocks into $this->unformatted_shortcode_blocks[]
456
+ add_shortcode( 'gmedia', 'gmedia_raw_shortcode' );
457
+ add_shortcode( 'gm', 'gmedia_raw_shortcode' );
458
 
459
+ // Do the shortcode (only the [gmedia] shortcodes are now registered)
460
+ $content = do_shortcode( $content );
461
 
462
+ // Put the original shortcodes back for normal processing at priority 11
463
+ $shortcode_tags = $orig_shortcode_tags;
464
 
465
+ return $content;
466
  }
467
 
468
  /**
471
  *
472
  * @return string
473
  */
474
+ function gmedia_raw_shortcode( $atts, $shortcode_post_content = '' ) {
475
+ global $wp_filter, $merged_filters, $wp_current_filter;
476
+ $wp_filter_ = $wp_filter;
477
+ $merged_filters_ = $merged_filters;
478
+ $wp_current_filter_ = $wp_current_filter;
479
+ $noraw = do_shortcode( apply_filters( 'the_content', '[raw][/raw]' ) );
480
+ $wp_filter = $wp_filter_;
481
+ $merged_filters = $merged_filters_;
482
+ $wp_current_filter = $wp_current_filter_;
483
+
484
+ global $gmedia_shortcode_instance;
485
+
486
+ unset( $atts['_raw'], $atts['_copy'] );
487
+ $atts_hash = md5( build_query( $atts ) );
488
+ $atts['_raw'] = '1';
489
+ gmedia_shortcode( $atts, $shortcode_post_content );
490
+ unset( $atts['_raw'] );
491
+
492
+ $atts['_copy'] = $gmedia_shortcode_instance[ $atts_hash ]['copy'];
493
+ $shortcode_atts = '';
494
+ // Put the shortcode tag back with raw index, so it gets processed again below.
495
+ foreach ( $atts as $key => $value ) {
496
+ $shortcode_atts .= " {$key}='{$value}'";
497
+ }
498
+ if ( ! $noraw ) {
499
+ return "[raw][gmedia{$shortcode_atts}]{$shortcode_post_content}[/gmedia][/raw]";
500
+ } else {
501
+ return "[gmedia{$shortcode_atts}]{$shortcode_post_content}[/gmedia]";
502
+ }
503
  }
504
 
505
  /**
507
  *
508
  * @return object
509
  */
510
+ function gmedia_shortcode_id_data( $id ) {
511
+ global $gmDB, $gmCore;
512
+
513
+ $item = $gmDB->get_term( $id );
514
+
515
+ if ( empty( $item ) || is_wp_error( $item ) ) {
516
+ return false;
517
+ }
518
+
519
+ $meta = $gmDB->get_metadata( 'gmedia_term', $item->term_id );
520
+
521
+ if ( $item->global ) {
522
+ $item->author_name = get_the_author_meta( 'display_name', $item->global );
523
+ } else {
524
+ $item->author_name = '';
525
+ }
526
+
527
+ $post_id = isset( $meta['_post_ID'][0] ) ? (int) $meta['_post_ID'][0] : 0;
528
+ $item->post_id = $post_id;
529
+ if ( $post_id ) {
530
+ $post_item = get_post( $post_id );
531
+ if ( $post_item ) {
532
+ $item->slug = $post_item->post_name;
533
+ $item->post_password = $post_item->post_password;
534
+ $item->comment_count = $post_item->comment_count;
535
+ $item->comment_status = $post_item->comment_status;
536
+ }
537
+ }
538
+
539
+ $item->custom_meta = array();
540
+ $item->meta = array();
541
+ foreach ( $meta as $key => $value ) {
542
+ if ( $gmCore->is_protected_meta( $key, 'gmedia_term' ) ) {
543
+ $item->meta[ $key ] = $value[0];
544
+ } else {
545
+ $item->custom_meta[ $key ] = $value;
546
+ }
547
+ }
548
+
549
+ return apply_filters( 'gmedia_shortcode_id_data', $item );
550
  }
load-template.php CHANGED
@@ -78,6 +78,9 @@ if ( is_file( $module['path'] . "/template/functions.php" ) ) {
78
  include_once( $module['path'] . "/template/functions.php" );
79
  }
80
 
 
 
 
81
  if ( is_file( $module['path'] . "/template/{$gmedia_type}.php" ) ) {
82
  /** @noinspection PhpIncludeInspection */
83
  require_once( $module['path'] . "/template/{$gmedia_type}.php" );
78
  include_once( $module['path'] . "/template/functions.php" );
79
  }
80
 
81
+ global $posts;
82
+ $posts = array();
83
+
84
  if ( is_file( $module['path'] . "/template/{$gmedia_type}.php" ) ) {
85
  /** @noinspection PhpIncludeInspection */
86
  require_once( $module['path'] . "/template/{$gmedia_type}.php" );
module/jq-mplayer/js/gm-music-player.js CHANGED
@@ -24,7 +24,6 @@
24
  ratingLevelOn: '.gmmp-on',
25
  title: '.gmmp-track-title',
26
  text: '.gmmp-track-description',
27
- duration: '.gmmp-duration',
28
  button: '.gmmp-button',
29
  buttonNotActive: '.gmmp-not-active',
30
  playing: '.gmmp-playing',
24
  ratingLevelOn: '.gmmp-on',
25
  title: '.gmmp-track-title',
26
  text: '.gmmp-track-description',
 
27
  button: '.gmmp-button',
28
  buttonNotActive: '.gmmp-not-active',
29
  playing: '.gmmp-playing',
module/photomania/js/photomania.js CHANGED
@@ -620,7 +620,7 @@
620
  if (!item.viewed) {
621
  this.content.data[ai].viewed = true;
622
  this.storage[item.id].status = 'viewed';
623
- var item = this.content.data[ai];
624
  sessionStorage.setItem(elid, JSON.stringify(this.storage));
625
  if (this.opts.ajaxurl) {
626
  $.ajax({
@@ -640,7 +640,7 @@
640
  this.content.data[ai].liked = true;
641
  this.content.data[ai].meta.likes += 1;
642
  this.storage[item.id].status = 'liked';
643
- var item = this.content.data[ai];
644
  sessionStorage.setItem(elid, JSON.stringify(this.storage));
645
  if (this.opts.ajaxurl) {
646
  $.ajax({
620
  if (!item.viewed) {
621
  this.content.data[ai].viewed = true;
622
  this.storage[item.id].status = 'viewed';
623
+ item = this.content.data[ai];
624
  sessionStorage.setItem(elid, JSON.stringify(this.storage));
625
  if (this.opts.ajaxurl) {
626
  $.ajax({
640
  this.content.data[ai].liked = true;
641
  this.content.data[ai].meta.likes += 1;
642
  this.storage[item.id].status = 'liked';
643
+ item = this.content.data[ai];
644
  sessionStorage.setItem(elid, JSON.stringify(this.storage));
645
  if (this.opts.ajaxurl) {
646
  $.ajax({
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: pasyuk
3
  Donate link: https://codeasily.com/donate/
4
  Tags: gallery, image gallery, photo gallery, albums gallery, wordpress gallery plugin
5
  Requires at least: 3.7
6
- Tested up to: 4.9.1
7
  Stable tag: trunk
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -143,6 +143,39 @@ Use [Gmedia Support Forum](https://codeasily.com/community/forum/gmedia-gallery-
143
  = Modules Updated =
144
  * Go to Gmedia Modules page and update installed premium modules to latest versions
145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  = v1.13.4 =
147
  * Fixed insert shortcode popup not load content in some cases
148
 
3
  Donate link: https://codeasily.com/donate/
4
  Tags: gallery, image gallery, photo gallery, albums gallery, wordpress gallery plugin
5
  Requires at least: 3.7
6
+ Tested up to: 5.0.2
7
  Stable tag: trunk
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
143
  = Modules Updated =
144
  * Go to Gmedia Modules page and update installed premium modules to latest versions
145
 
146
+ = v1.14.7 =
147
+ * Fixed conflict with Lazy load plugins
148
+ * Added badge count for new modules
149
+ * Changed Modules page
150
+ * Updated twitter widget
151
+ * Fixed module preview PHP Notice with Enfold theme
152
+
153
+ = v1.14.5 =
154
+ * Fixed CSS for Gutenberg editor
155
+
156
+ = v1.14.4 =
157
+ * Added compatibility with Gutenberg
158
+ * Added Gutenberg blocks for Galleries, Albums, Categories and Tags
159
+ * Fixed related gmedia images by tags for WP Posts
160
+ * Fixed compatibility with some themes
161
+ * Changed: the full IP address now not saved to database in logger
162
+
163
+ = v1.14.2 =
164
+ * Added option to disable WoowBox Banner
165
+ * Added compatibility with PHP 7.2
166
+ * Added compatibility with PHP 5.3
167
+ * Fixed cache of gallery modules
168
+ * Fixed uninstall error
169
+ * Fixed clear button in Build Query
170
+
171
+
172
+ = v1.14.0 =
173
+ * Added cache for Gmedia Modules queries
174
+ * Fixed gmedia edit date picker
175
+ * Fixed Google API key trim white spaces on save
176
+ * Fixed filter in BuildQuery -> select items
177
+ * Added oEmbed for Gmedia Posts
178
+
179
  = v1.13.4 =
180
  * Fixed insert shortcode popup not load content in some cases
181
 
uninstall.php CHANGED
@@ -9,6 +9,7 @@ if(!defined('WP_UNINSTALL_PLUGIN')) {
9
  }
10
 
11
  require_once(dirname(__FILE__) . '/grand-media.php');
 
12
 
13
  if(function_exists('is_multisite') && is_multisite()) {
14
  global $wpdb;
@@ -102,6 +103,7 @@ function gmedia_uninstall() {
102
  delete_metadata('user', 0, 'gm_screen_options', '', true);
103
  wp_clear_scheduled_hook('gmedia_app_cronjob');
104
  wp_clear_scheduled_hook('gmedia_modules_update');
 
105
 
106
  if(empty($upload['error'])) {
107
  if('all' == $options['uninstall_dropdata']) {
9
  }
10
 
11
  require_once(dirname(__FILE__) . '/grand-media.php');
12
+ require_once(dirname(__FILE__) . '/inc/functions.php');
13
 
14
  if(function_exists('is_multisite') && is_multisite()) {
15
  global $wpdb;
103
  delete_metadata('user', 0, 'gm_screen_options', '', true);
104
  wp_clear_scheduled_hook('gmedia_app_cronjob');
105
  wp_clear_scheduled_hook('gmedia_modules_update');
106
+ gmedia_delete_transients( 'gm_cache' );
107
 
108
  if(empty($upload['error'])) {
109
  if('all' == $options['uninstall_dropdata']) {