Version Description
- Fixed compatibility with PHP v5.2
- Small fixes and improvements
Download this release
Release Info
Developer | pasyuk |
Plugin | Gmedia Photo Gallery |
Version | 1.5.91 |
Comparing to | |
See all releases |
Code changes from version 1.4.2 to 1.5.91
- access.php +46 -21
- admin/addmedia.php +10 -7
- admin/admin.php +85 -26
- admin/ajax.php +459 -19
- admin/css/grand-media.css +71 -24
- admin/galleries.php +103 -26
- admin/gmedia.php +93 -37
- admin/import.php +0 -493
- admin/js/grand-media.js +92 -26
- admin/processor.php +155 -90
- admin/settings.php +211 -60
- admin/terms.php +843 -678
- admin/upload.php +0 -75
- admin/wpmedia.php +1 -1
- assets/bootstrap/css/bootstrap.css +0 -21
- assets/icons/favicon.png +0 -0
- assets/icons/icon_gmedia_120.png +0 -0
- assets/icons/icon_gmedia_152.png +0 -0
- assets/icons/icon_gmedia_180.png +0 -0
- assets/icons/icon_gmedia_60.png +0 -0
- assets/icons/icon_gmedia_76.png +0 -0
- gallery.php +0 -122
- grand-media.php +58 -22
- inc/core.php +539 -12
- inc/db.connect.php +169 -105
- inc/hashids.php +338 -0
- inc/media-upload.php +646 -610
- inc/permalinks.php +38 -38
- inc/shortcodes.php +152 -144
- inc/sitemap.php +67 -0
- load-template.php +88 -0
- module/afflux/init.php +1 -1
- module/jq-mplayer/index.php +1 -1
- module/jq-mplayer/init.php +2 -1
- module/jq-mplayer/js/gm-music-player.js +7 -4
- module/jq-mplayer/settings.php +1 -1
- module/minima/gallery.swf +0 -0
- module/minima/index.php +1 -1
- module/minima/init.php +1 -1
- module/minima/js/jquery.gmMinima.js +1 -1
- module/phantom/index.php +1 -1
- module/phantom/init.php +20 -11
- module/phantom/js/jquery.gmPhantom.js +13 -10
- module/wp-videoplayer/init.php +1 -1
- readme.txt +82 -87
- setup.php +26 -3
- template/album.php +31 -0
- template/category.php +34 -0
- template/foot.php +3 -0
- template/functions.php +476 -0
- template/gallery.php +31 -0
- template/head.php +15 -0
- template/single.php +59 -0
- template/tag.php +33 -0
- uninstall.php +1 -0
- update.php +14 -1
access.php
CHANGED
@@ -167,11 +167,11 @@ function gmedia_ios_app_library_data( $data = array( 'site', 'authors', 'filter'
|
|
167 |
|
168 |
$out = array();
|
169 |
|
170 |
-
|
171 |
-
|
172 |
-
$share_link = home_url(
|
173 |
-
} else
|
174 |
-
$share_link =
|
175 |
}
|
176 |
|
177 |
if ( in_array( 'site', $data ) ) {
|
@@ -200,6 +200,7 @@ function gmedia_ios_app_library_data( $data = array( 'site', 'authors', 'filter'
|
|
200 |
}*/
|
201 |
}
|
202 |
if ( in_array( 'filter', $data ) ) {
|
|
|
203 |
$out['filter'] = $gmDB->count_gmedia();
|
204 |
$out['filter'] = array_map( 'intval', $out['filter'] );
|
205 |
}
|
@@ -222,7 +223,10 @@ function gmedia_ios_app_library_data( $data = array( 'site', 'authors', 'filter'
|
|
222 |
foreach ( $gmediaTerms as $name => $term ) {
|
223 |
unset( $gmediaTerms[ $name ]->description, $gmediaTerms[ $name ]->global, $gmediaTerms[ $name ]->status );
|
224 |
$gmediaTerms[ $name ]->title = $terms[ $name ];
|
225 |
-
|
|
|
|
|
|
|
226 |
$gmediaTerms[ $name ]->cap = 0;
|
227 |
}
|
228 |
|
@@ -255,9 +259,15 @@ function gmedia_ios_app_library_data( $data = array( 'site', 'authors', 'filter'
|
|
255 |
continue;
|
256 |
}
|
257 |
$authordata = get_userdata( $author_id );
|
258 |
-
$
|
259 |
-
|
260 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
261 |
} else {
|
262 |
$display_name = __( 'Shared', 'gmLang' );
|
263 |
$first_name = $last_name = '';
|
@@ -273,7 +283,10 @@ function gmedia_ios_app_library_data( $data = array( 'site', 'authors', 'filter'
|
|
273 |
$term_meta = array_map( 'reset', $term_meta );
|
274 |
$term_meta = array_merge( array( 'orderby' => 'ID', 'order' => 'DESC' ), $term_meta );
|
275 |
$gmediaTerms[ $i ]->meta = $term_meta;
|
276 |
-
|
|
|
|
|
|
|
277 |
$gmediaTerms[ $i ]->cap = ( 4 == $cap ) ? 4 : 0;
|
278 |
}
|
279 |
$out['albums'] = array(
|
@@ -290,7 +303,10 @@ function gmedia_ios_app_library_data( $data = array( 'site', 'authors', 'filter'
|
|
290 |
$gmediaTerms = $gmDB->get_terms( 'gmedia_tag' );
|
291 |
foreach ( $gmediaTerms as $i => $term ) {
|
292 |
unset( $gmediaTerms[ $i ]->description, $gmediaTerms[ $i ]->global, $gmediaTerms[ $i ]->status );
|
293 |
-
|
|
|
|
|
|
|
294 |
$gmediaTerms[ $i ]->cap = ( 4 == $cap ) ? 4 : 0;
|
295 |
}
|
296 |
$out['tags'] = array(
|
@@ -594,11 +610,11 @@ function gmedia_ios_app_processor( $action, $data, $filter = true ) {
|
|
594 |
break;
|
595 |
|
596 |
case 'library':
|
597 |
-
|
598 |
-
|
599 |
-
$share_link = home_url(
|
600 |
-
} else
|
601 |
-
$share_link =
|
602 |
}
|
603 |
$filter = $filter ? gmedia_ios_app_library_data( array( 'filter' ) ) : array();
|
604 |
|
@@ -659,10 +675,16 @@ function gmedia_ios_app_processor( $action, $data, $filter = true ) {
|
|
659 |
}
|
660 |
|
661 |
$author_id = $item->author;
|
662 |
-
$authordata
|
663 |
-
$
|
664 |
-
|
665 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
666 |
$gmedias[ $i ]->user = array( 'id' => $author_id, 'displayname' => $display_name, 'firstname' => $first_name, 'last_name' => $last_name );
|
667 |
|
668 |
$meta = $gmDB->get_metadata( 'gmedia', $item->ID );
|
@@ -735,7 +757,10 @@ function gmedia_ios_app_processor( $action, $data, $filter = true ) {
|
|
735 |
if ( isset( $meta['rating'][0] ) ) {
|
736 |
$gmedias[ $i ]->meta['rating'] = maybe_unserialize( $meta['rating'][0] );
|
737 |
}
|
738 |
-
|
|
|
|
|
|
|
739 |
}
|
740 |
$out = array_merge( $filter, array(
|
741 |
'properties' => array(
|
167 |
|
168 |
$out = array();
|
169 |
|
170 |
+
$ep = $gmGallery->options['endpoint'];
|
171 |
+
if(get_option('permalink_structure')){
|
172 |
+
$share_link = home_url(urlencode($ep) . '/$2/$1');
|
173 |
+
} else{
|
174 |
+
$share_link = add_query_arg(array("$ep" => '$1', 't' => '$2'), home_url('index.php'));
|
175 |
}
|
176 |
|
177 |
if ( in_array( 'site', $data ) ) {
|
200 |
}*/
|
201 |
}
|
202 |
if ( in_array( 'filter', $data ) ) {
|
203 |
+
$gmDB->clauses = array();
|
204 |
$out['filter'] = $gmDB->count_gmedia();
|
205 |
$out['filter'] = array_map( 'intval', $out['filter'] );
|
206 |
}
|
223 |
foreach ( $gmediaTerms as $name => $term ) {
|
224 |
unset( $gmediaTerms[ $name ]->description, $gmediaTerms[ $name ]->global, $gmediaTerms[ $name ]->status );
|
225 |
$gmediaTerms[ $name ]->title = $terms[ $name ];
|
226 |
+
|
227 |
+
$gmedia_hashid = gmedia_hash_id_encode($gmediaTerms[ $name ]->term_id, 'category');
|
228 |
+
$gmediaTerms[ $name ]->sharelink = str_replace( array( '$1', '$2' ), array( urlencode($gmedia_hashid), 'k' ), $share_link );
|
229 |
+
|
230 |
$gmediaTerms[ $name ]->cap = 0;
|
231 |
}
|
232 |
|
259 |
continue;
|
260 |
}
|
261 |
$authordata = get_userdata( $author_id );
|
262 |
+
if($authordata){
|
263 |
+
$display_name = $authordata->display_name;
|
264 |
+
$first_name = $authordata->first_name;
|
265 |
+
$last_name = $authordata->last_name;
|
266 |
+
} else{
|
267 |
+
$display_name = __('Deleted User', 'gmLang');
|
268 |
+
$first_name = '';
|
269 |
+
$last_name = '';
|
270 |
+
}
|
271 |
} else {
|
272 |
$display_name = __( 'Shared', 'gmLang' );
|
273 |
$first_name = $last_name = '';
|
283 |
$term_meta = array_map( 'reset', $term_meta );
|
284 |
$term_meta = array_merge( array( 'orderby' => 'ID', 'order' => 'DESC' ), $term_meta );
|
285 |
$gmediaTerms[ $i ]->meta = $term_meta;
|
286 |
+
|
287 |
+
$gmedia_hashid = gmedia_hash_id_encode($term->term_id, 'album');
|
288 |
+
$gmediaTerms[ $i ]->sharelink = str_replace( array( '$1', '$2' ), array( urlencode($gmedia_hashid), 'a' ), $share_link );
|
289 |
+
|
290 |
$gmediaTerms[ $i ]->cap = ( 4 == $cap ) ? 4 : 0;
|
291 |
}
|
292 |
$out['albums'] = array(
|
303 |
$gmediaTerms = $gmDB->get_terms( 'gmedia_tag' );
|
304 |
foreach ( $gmediaTerms as $i => $term ) {
|
305 |
unset( $gmediaTerms[ $i ]->description, $gmediaTerms[ $i ]->global, $gmediaTerms[ $i ]->status );
|
306 |
+
|
307 |
+
$gmedia_hashid = gmedia_hash_id_encode($term->term_id, 'tag');
|
308 |
+
$gmediaTerms[ $i ]->sharelink = str_replace( array( '$1', '$2' ), array( urlencode($gmedia_hashid), 't' ), $share_link );
|
309 |
+
|
310 |
$gmediaTerms[ $i ]->cap = ( 4 == $cap ) ? 4 : 0;
|
311 |
}
|
312 |
$out['tags'] = array(
|
610 |
break;
|
611 |
|
612 |
case 'library':
|
613 |
+
$ep = $gmGallery->options['endpoint'];
|
614 |
+
if(get_option('permalink_structure')){
|
615 |
+
$share_link = home_url(urlencode($ep) . '/$2/$1');
|
616 |
+
} else{
|
617 |
+
$share_link = add_query_arg(array("$ep" => '$1', 't' => '$2'), home_url('index.php'));
|
618 |
}
|
619 |
$filter = $filter ? gmedia_ios_app_library_data( array( 'filter' ) ) : array();
|
620 |
|
675 |
}
|
676 |
|
677 |
$author_id = $item->author;
|
678 |
+
$authordata = get_userdata( $author_id );
|
679 |
+
if($authordata){
|
680 |
+
$display_name = $authordata->display_name;
|
681 |
+
$first_name = $authordata->first_name;
|
682 |
+
$last_name = $authordata->last_name;
|
683 |
+
} else{
|
684 |
+
$display_name = __('Deleted User', 'gmLang');
|
685 |
+
$first_name = '';
|
686 |
+
$last_name = '';
|
687 |
+
}
|
688 |
$gmedias[ $i ]->user = array( 'id' => $author_id, 'displayname' => $display_name, 'firstname' => $first_name, 'last_name' => $last_name );
|
689 |
|
690 |
$meta = $gmDB->get_metadata( 'gmedia', $item->ID );
|
757 |
if ( isset( $meta['rating'][0] ) ) {
|
758 |
$gmedias[ $i ]->meta['rating'] = maybe_unserialize( $meta['rating'][0] );
|
759 |
}
|
760 |
+
|
761 |
+
$item_name = $item->title? $item->title : pathinfo($item->gmuid, PATHINFO_FILENAME);
|
762 |
+
$gmedia_hashid = gmedia_hash_id_encode($item->ID, 'single');
|
763 |
+
$gmedias[ $i ]->sharelink = str_replace( array( '$1', '$2' ), array( urlencode($gmedia_hashid), 's' ), $share_link );
|
764 |
}
|
765 |
$out = array_merge( $filter, array(
|
766 |
'properties' => array(
|
admin/addmedia.php
CHANGED
@@ -189,6 +189,7 @@ function gmedia_upload_files() {
|
|
189 |
options: items,
|
190 |
labelField: 'item',
|
191 |
valueField: 'item',
|
|
|
192 |
hideSelected: true
|
193 |
});
|
194 |
<?php } ?>
|
@@ -228,14 +229,14 @@ function gmedia_upload_files() {
|
|
228 |
<?php if('auto' != $gm_screen_options['uploader_runtime']){ ?>
|
229 |
runtimes: '<?php echo $gm_screen_options['uploader_runtime']; ?>',
|
230 |
<?php } ?>
|
231 |
-
url: '<?php echo
|
232 |
<?php if(('true' == $gm_screen_options['uploader_urlstream_upload']) && ('html4' != $gm_screen_options['uploader_runtime'])){ ?>
|
233 |
urlstream_upload: true,
|
234 |
multipart: false,
|
235 |
<?php } else{ ?>
|
236 |
multipart: true,
|
237 |
<?php } ?>
|
238 |
-
multipart_params: {params: ''},
|
239 |
<?php if('true' == $gm_screen_options['uploader_chunking'] && ('html4' != $gm_screen_options['uploader_runtime'])){ ?>
|
240 |
max_file_size: '2000Mb',
|
241 |
chunk_size: 200000<?php //echo min($maxupsize, $gm_screen_options['uploader_chunk_size']*1024*1024); ?>,
|
@@ -261,7 +262,7 @@ function gmedia_upload_files() {
|
|
261 |
var uploader = $("#pluploadUploader").plupload('getUploader');
|
262 |
uploader.bind('StateChanged', function (up) {
|
263 |
if (up.state == plupload.STARTED) {
|
264 |
-
up.settings.multipart_params =
|
265 |
}
|
266 |
//console.log('[StateChanged]', up.state, up.settings.multipart_params);
|
267 |
});
|
@@ -319,10 +320,11 @@ function gmedia_import() {
|
|
319 |
|
320 |
$gmediaURL = plugins_url( GMEDIA_FOLDER );
|
321 |
?>
|
322 |
-
<form class="row" id="import_form" name="import_form" target="import_window" action="<?php echo
|
323 |
<div class="col-md-4">
|
324 |
<fieldset id="import_params" class="import-params">
|
325 |
<?php wp_nonce_field( 'GmediaImport' ); ?>
|
|
|
326 |
<input type="hidden" id="import-action" name="import" value=""/>
|
327 |
|
328 |
<?php if ( $gmCore->caps['gmedia_terms'] ) { ?>
|
@@ -409,6 +411,7 @@ function gmedia_import() {
|
|
409 |
options: items,
|
410 |
labelField: 'item',
|
411 |
valueField: 'item',
|
|
|
412 |
hideSelected: true
|
413 |
});
|
414 |
<?php } ?>
|
@@ -443,7 +446,7 @@ function gmedia_import() {
|
|
443 |
<div class="tab-footer">
|
444 |
<div class="checkbox pull-left"><label><input type="checkbox" name="delete_source" value="1"/> <?php _e( 'delete source files after importing', 'gmLang' ) ?>
|
445 |
</label></div>
|
446 |
-
<button class="pull-right btn btn-info gmedia-import" type="button" name="import-folder"><?php _e( 'Import folder', 'gmLang' ); ?></button>
|
447 |
</div>
|
448 |
<script type="text/javascript">
|
449 |
/* <![CDATA[ */
|
@@ -484,7 +487,7 @@ function gmedia_import() {
|
|
484 |
</div>
|
485 |
</div>
|
486 |
<div class="tab-footer">
|
487 |
-
<button class="pull-right btn btn-info gmedia-import" type="button" name="import-flagallery"><?php _e( 'Import', 'gmLang' ); ?></button>
|
488 |
</div>
|
489 |
<?php } else { ?>
|
490 |
<p class="tab-inside"><?php _e( 'There are no created galleries in this plugin.', 'gmLang' ) ?></p>
|
@@ -516,7 +519,7 @@ function gmedia_import() {
|
|
516 |
</div>
|
517 |
</div>
|
518 |
<div class="tab-footer">
|
519 |
-
<button class="pull-right btn btn-info gmedia-import" type="button" name="import-nextgen"><?php _e( 'Import', 'gmLang' ); ?></button>
|
520 |
</div>
|
521 |
<?php } else { ?>
|
522 |
<p class="tab-inside"><?php _e( 'There are no created galleries in this plugin.', 'gmLang' ) ?></p>
|
189 |
options: items,
|
190 |
labelField: 'item',
|
191 |
valueField: 'item',
|
192 |
+
searchField: ['item'],
|
193 |
hideSelected: true
|
194 |
});
|
195 |
<?php } ?>
|
229 |
<?php if('auto' != $gm_screen_options['uploader_runtime']){ ?>
|
230 |
runtimes: '<?php echo $gm_screen_options['uploader_runtime']; ?>',
|
231 |
<?php } ?>
|
232 |
+
url: '<?php echo admin_url( 'admin-ajax.php' ); ?>',
|
233 |
<?php if(('true' == $gm_screen_options['uploader_urlstream_upload']) && ('html4' != $gm_screen_options['uploader_runtime'])){ ?>
|
234 |
urlstream_upload: true,
|
235 |
multipart: false,
|
236 |
<?php } else{ ?>
|
237 |
multipart: true,
|
238 |
<?php } ?>
|
239 |
+
multipart_params: {action: 'gmedia_upload_handler', _ajax_nonce: '<?php echo wp_create_nonce('GmediaUpload'); ?>', params: ''},
|
240 |
<?php if('true' == $gm_screen_options['uploader_chunking'] && ('html4' != $gm_screen_options['uploader_runtime'])){ ?>
|
241 |
max_file_size: '2000Mb',
|
242 |
chunk_size: 200000<?php //echo min($maxupsize, $gm_screen_options['uploader_chunk_size']*1024*1024); ?>,
|
262 |
var uploader = $("#pluploadUploader").plupload('getUploader');
|
263 |
uploader.bind('StateChanged', function (up) {
|
264 |
if (up.state == plupload.STARTED) {
|
265 |
+
up.settings.multipart_params.params = jQuery('#uploader_multipart_params :input').serialize();
|
266 |
}
|
267 |
//console.log('[StateChanged]', up.state, up.settings.multipart_params);
|
268 |
});
|
320 |
|
321 |
$gmediaURL = plugins_url( GMEDIA_FOLDER );
|
322 |
?>
|
323 |
+
<form class="row" id="import_form" name="import_form" target="import_window" action="<?php echo admin_url('admin-ajax.php'); ?>" method="POST" accept-charset="utf-8" style="padding:20px 0 10px;">
|
324 |
<div class="col-md-4">
|
325 |
<fieldset id="import_params" class="import-params">
|
326 |
<?php wp_nonce_field( 'GmediaImport' ); ?>
|
327 |
+
<input type="hidden" name="action" value="gmedia_import_handler"/>
|
328 |
<input type="hidden" id="import-action" name="import" value=""/>
|
329 |
|
330 |
<?php if ( $gmCore->caps['gmedia_terms'] ) { ?>
|
411 |
options: items,
|
412 |
labelField: 'item',
|
413 |
valueField: 'item',
|
414 |
+
searchField: ['item'],
|
415 |
hideSelected: true
|
416 |
});
|
417 |
<?php } ?>
|
446 |
<div class="tab-footer">
|
447 |
<div class="checkbox pull-left"><label><input type="checkbox" name="delete_source" value="1"/> <?php _e( 'delete source files after importing', 'gmLang' ) ?>
|
448 |
</label></div>
|
449 |
+
<button class="pull-right btn btn-info gmedia-import" type="button" name="import-folder" value="true"><?php _e( 'Import folder', 'gmLang' ); ?></button>
|
450 |
</div>
|
451 |
<script type="text/javascript">
|
452 |
/* <![CDATA[ */
|
487 |
</div>
|
488 |
</div>
|
489 |
<div class="tab-footer">
|
490 |
+
<button class="pull-right btn btn-info gmedia-import" type="button" name="import-flagallery" value="true"><?php _e( 'Import', 'gmLang' ); ?></button>
|
491 |
</div>
|
492 |
<?php } else { ?>
|
493 |
<p class="tab-inside"><?php _e( 'There are no created galleries in this plugin.', 'gmLang' ) ?></p>
|
519 |
</div>
|
520 |
</div>
|
521 |
<div class="tab-footer">
|
522 |
+
<button class="pull-right btn btn-info gmedia-import" type="button" name="import-nextgen" value="true"><?php _e( 'Import', 'gmLang' ); ?></button>
|
523 |
</div>
|
524 |
<?php } else { ?>
|
525 |
<p class="tab-inside"><?php _e( 'There are no created galleries in this plugin.', 'gmLang' ) ?></p>
|
admin/admin.php
CHANGED
@@ -396,12 +396,13 @@ class GmediaAdmin {
|
|
396 |
$settings = '
|
397 |
<div class="form-inline pull-left">
|
398 |
<div class="form-group">
|
399 |
-
<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:
|
400 |
</div>
|
401 |
<div class="form-group">
|
402 |
<select name="gm_screen_options[orderby_gmedia]" class="form-control input-sm">
|
403 |
<option' . selected( $gm_screen_options['orderby_gmedia'], 'ID', false ) . ' value="ID">' . __( 'ID', 'gmLang' ) . '</option>
|
404 |
<option' . selected( $gm_screen_options['orderby_gmedia'], 'title', false ) . ' value="title">' . __( 'Title', 'gmLang' ) . '</option>
|
|
|
405 |
<option' . selected( $gm_screen_options['orderby_gmedia'], 'date', false ) . ' value="date">' . __( 'Date', 'gmLang' ) . '</option>
|
406 |
<option' . selected( $gm_screen_options['orderby_gmedia'], 'modified', false ) . ' value="modified">' . __( 'Last Modified', 'gmLang' ) . '</option>
|
407 |
<option' . selected( $gm_screen_options['orderby_gmedia'], 'mime_type', false ) . ' value="mime_type">' . __( 'MIME Type', 'gmLang' ) . '</option>
|
@@ -429,31 +430,6 @@ class GmediaAdmin {
|
|
429 |
</div>
|
430 |
';
|
431 |
break;
|
432 |
-
case 'GrandMedia_WordpressLibrary' :
|
433 |
-
$settings = '<p>' . __( 'Set query options for this page to be loaded by default.', 'gmLang' ) . '</p>
|
434 |
-
<div class="form-inline pull-left">
|
435 |
-
<div class="form-group">
|
436 |
-
<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: auto;" value="' . $gm_screen_options['per_page_wpmedia'] . '" /> <span>' . __( 'items per page', 'gmLang' ) . '</span>
|
437 |
-
</div>
|
438 |
-
<div class="form-group">
|
439 |
-
<select name="gm_screen_options[orderby_wpmedia]" class="form-control input-sm">
|
440 |
-
<option' . selected( $gm_screen_options['orderby_wpmedia'], 'ID', false ) . ' value="ID">' . __( 'ID', 'gmLang' ) . '</option>
|
441 |
-
<option' . selected( $gm_screen_options['orderby_wpmedia'], 'title', false ) . ' value="title">' . __( 'Title', 'gmLang' ) . '</option>
|
442 |
-
<option' . selected( $gm_screen_options['orderby_wpmedia'], 'date', false ) . ' value="date">' . __( 'Date', 'gmLang' ) . '</option>
|
443 |
-
<option' . selected( $gm_screen_options['orderby_wpmedia'], 'modified', false ) . ' value="modified">' . __( 'Last Modified', 'gmLang' ) . '</option>
|
444 |
-
<option' . selected( $gm_screen_options['orderby_wpmedia'], 'mime_type', false ) . ' value="mime_type">' . __( 'MIME Type', 'gmLang' ) . '</option>
|
445 |
-
<option' . selected( $gm_screen_options['orderby_wpmedia'], 'author', false ) . ' value="author">' . __( 'Author', 'gmLang' ) . '</option>
|
446 |
-
</select> <span>' . __( 'order items', 'gmLang' ) . '</span>
|
447 |
-
</div>
|
448 |
-
<div class="form-group">
|
449 |
-
<select name="gm_screen_options[sortorder_wpmedia]" class="form-control input-sm">
|
450 |
-
<option' . selected( $gm_screen_options['sortorder_wpmedia'], 'DESC', false ) . ' value="DESC">' . __( 'DESC', 'gmLang' ) . '</option>
|
451 |
-
<option' . selected( $gm_screen_options['sortorder_wpmedia'], 'ASC', false ) . ' value="ASC">' . __( 'ASC', 'gmLang' ) . '</option>
|
452 |
-
</select> <span>' . __( 'sort order', 'gmLang' ) . '</span>
|
453 |
-
</div>
|
454 |
-
</div>
|
455 |
-
';
|
456 |
-
break;
|
457 |
case 'GrandMedia_AddMedia' :
|
458 |
$tab = $gmCore->_get( 'tab', 'upload' );
|
459 |
if ( 'upload' == $tab ) {
|
@@ -484,6 +460,89 @@ class GmediaAdmin {
|
|
484 |
';
|
485 |
}
|
486 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
487 |
}
|
488 |
|
489 |
if ( $settings ) {
|
396 |
$settings = '
|
397 |
<div class="form-inline pull-left">
|
398 |
<div class="form-group">
|
399 |
+
<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', 'gmLang' ) . '</span>
|
400 |
</div>
|
401 |
<div class="form-group">
|
402 |
<select name="gm_screen_options[orderby_gmedia]" class="form-control input-sm">
|
403 |
<option' . selected( $gm_screen_options['orderby_gmedia'], 'ID', false ) . ' value="ID">' . __( 'ID', 'gmLang' ) . '</option>
|
404 |
<option' . selected( $gm_screen_options['orderby_gmedia'], 'title', false ) . ' value="title">' . __( 'Title', 'gmLang' ) . '</option>
|
405 |
+
<option' . selected( $gm_screen_options['orderby_gmedia'], 'gmuid', false ) . ' value="gmuid">' . __( 'Filename', 'gmLang' ) . '</option>
|
406 |
<option' . selected( $gm_screen_options['orderby_gmedia'], 'date', false ) . ' value="date">' . __( 'Date', 'gmLang' ) . '</option>
|
407 |
<option' . selected( $gm_screen_options['orderby_gmedia'], 'modified', false ) . ' value="modified">' . __( 'Last Modified', 'gmLang' ) . '</option>
|
408 |
<option' . selected( $gm_screen_options['orderby_gmedia'], 'mime_type', false ) . ' value="mime_type">' . __( 'MIME Type', 'gmLang' ) . '</option>
|
430 |
</div>
|
431 |
';
|
432 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
433 |
case 'GrandMedia_AddMedia' :
|
434 |
$tab = $gmCore->_get( 'tab', 'upload' );
|
435 |
if ( 'upload' == $tab ) {
|
460 |
';
|
461 |
}
|
462 |
break;
|
463 |
+
case 'GrandMedia_Terms' :
|
464 |
+
if ( $gmCore->_get( 'edit_album' ) ) {
|
465 |
+
$settings = '
|
466 |
+
<div class="form-inline pull-left">
|
467 |
+
<div class="form-group">
|
468 |
+
<input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_sort_gmedia]" class="form-control input-sm" style="width: 5em;" value="' . $gm_screen_options['per_page_sort_gmedia'] . '" /> <span>' . __( 'items per page', 'gmLang' ) . '</span>
|
469 |
+
</div>
|
470 |
+
</div>
|
471 |
+
';
|
472 |
+
} elseif( 'gmedia_category' !== $gmCore->_get( 'term', 'gmedia_album' ) ){
|
473 |
+
$settings = '
|
474 |
+
<div class="form-inline pull-left">
|
475 |
+
<div class="form-group">
|
476 |
+
<input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_gmedia_terms]" class="form-control input-sm" style="width: 5em;" value="' . $gm_screen_options['per_page_gmedia_terms'] . '" /> <span>' . __( 'items per page', 'gmLang' ) . '</span>
|
477 |
+
</div>
|
478 |
+
<div class="form-group">
|
479 |
+
<select name="gm_screen_options[orderby_gmedia_terms]" class="form-control input-sm">
|
480 |
+
<option' . selected( $gm_screen_options['orderby_gmedia_terms'], 'id', false ) . ' value="id">' . __( 'ID', 'gmLang' ) . '</option>
|
481 |
+
<option' . selected( $gm_screen_options['orderby_gmedia_terms'], 'name', false ) . ' value="name">' . __( 'Name', 'gmLang' ) . '</option>
|
482 |
+
<option' . selected( $gm_screen_options['orderby_gmedia_terms'], 'count', false ) . ' value="count">' . __( 'Gmedia Count', 'gmLang' ) . '</option>
|
483 |
+
<option' . selected( $gm_screen_options['orderby_gmedia_terms'], 'global', false ) . ' value="global">' . __( 'Author ID (for albums only)', 'gmLang' ) . '</option>
|
484 |
+
</select> <span>' . __( 'order items', 'gmLang' ) . '</span>
|
485 |
+
</div>
|
486 |
+
<div class="form-group">
|
487 |
+
<select name="gm_screen_options[sortorder_gmedia_terms]" class="form-control input-sm">
|
488 |
+
<option' . selected( $gm_screen_options['sortorder_gmedia_terms'], 'DESC', false ) . ' value="DESC">' . __( 'DESC', 'gmLang' ) . '</option>
|
489 |
+
<option' . selected( $gm_screen_options['sortorder_gmedia_terms'], 'ASC', false ) . ' value="ASC">' . __( 'ASC', 'gmLang' ) . '</option>
|
490 |
+
</select> <span>' . __( 'sort order', 'gmLang' ) . '</span>
|
491 |
+
</div>
|
492 |
+
</div>
|
493 |
+
';
|
494 |
+
}
|
495 |
+
break;
|
496 |
+
case 'GrandMedia_Galleries' :
|
497 |
+
if ( !$gmCore->_get( 'edit_gallery' ) && !$gmCore->_get( 'gallery_module' ) ) {
|
498 |
+
$settings = '
|
499 |
+
<div class="form-inline pull-left">
|
500 |
+
<div class="form-group">
|
501 |
+
<input type="number" max="999" min="0" step="5" size="3" name="gm_screen_options[per_page_gmedia_galleries]" class="form-control input-sm" style="width: 5em;" value="' . $gm_screen_options['per_page_gmedia_galleries'] . '" /> <span>' . __( 'items per page', 'gmLang' ) . '</span>
|
502 |
+
</div>
|
503 |
+
<div class="form-group">
|
504 |
+
<select name="gm_screen_options[orderby_gmedia_galleries]" class="form-control input-sm">
|
505 |
+
<option' . selected( $gm_screen_options['orderby_gmedia_galleries'], 'id', false ) . ' value="id">' . __( 'ID', 'gmLang' ) . '</option>
|
506 |
+
<option' . selected( $gm_screen_options['orderby_gmedia_galleries'], 'name', false ) . ' value="name">' . __( 'Name', 'gmLang' ) . '</option>
|
507 |
+
<option' . selected( $gm_screen_options['orderby_gmedia_galleries'], 'global', false ) . ' value="global">' . __( 'Author ID', 'gmLang' ) . '</option>
|
508 |
+
</select> <span>' . __( 'order items', 'gmLang' ) . '</span>
|
509 |
+
</div>
|
510 |
+
<div class="form-group">
|
511 |
+
<select name="gm_screen_options[sortorder_gmedia_galleries]" class="form-control input-sm">
|
512 |
+
<option' . selected( $gm_screen_options['sortorder_gmedia_galleries'], 'DESC', false ) . ' value="DESC">' . __( 'DESC', 'gmLang' ) . '</option>
|
513 |
+
<option' . selected( $gm_screen_options['sortorder_gmedia_galleries'], 'ASC', false ) . ' value="ASC">' . __( 'ASC', 'gmLang' ) . '</option>
|
514 |
+
</select> <span>' . __( 'sort order', 'gmLang' ) . '</span>
|
515 |
+
</div>
|
516 |
+
</div>
|
517 |
+
';
|
518 |
+
}
|
519 |
+
break;
|
520 |
+
case 'GrandMedia_WordpressLibrary' :
|
521 |
+
$settings = '<p>' . __( 'Set query options for this page to be loaded by default.', 'gmLang' ) . '</p>
|
522 |
+
<div class="form-inline pull-left">
|
523 |
+
<div class="form-group">
|
524 |
+
<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', 'gmLang' ) . '</span>
|
525 |
+
</div>
|
526 |
+
<div class="form-group">
|
527 |
+
<select name="gm_screen_options[orderby_wpmedia]" class="form-control input-sm">
|
528 |
+
<option' . selected( $gm_screen_options['orderby_wpmedia'], 'ID', false ) . ' value="ID">' . __( 'ID', 'gmLang' ) . '</option>
|
529 |
+
<option' . selected( $gm_screen_options['orderby_wpmedia'], 'title', false ) . ' value="title">' . __( 'Title', 'gmLang' ) . '</option>
|
530 |
+
<option' . selected( $gm_screen_options['orderby_wpmedia'], 'filename', false ) . ' value="filename">' . __( 'Filename', 'gmLang' ) . '</option>
|
531 |
+
<option' . selected( $gm_screen_options['orderby_wpmedia'], 'date', false ) . ' value="date">' . __( 'Date', 'gmLang' ) . '</option>
|
532 |
+
<option' . selected( $gm_screen_options['orderby_wpmedia'], 'modified', false ) . ' value="modified">' . __( 'Last Modified', 'gmLang' ) . '</option>
|
533 |
+
<option' . selected( $gm_screen_options['orderby_wpmedia'], 'mime_type', false ) . ' value="mime_type">' . __( 'MIME Type', 'gmLang' ) . '</option>
|
534 |
+
<option' . selected( $gm_screen_options['orderby_wpmedia'], 'author', false ) . ' value="author">' . __( 'Author', 'gmLang' ) . '</option>
|
535 |
+
</select> <span>' . __( 'order items', 'gmLang' ) . '</span>
|
536 |
+
</div>
|
537 |
+
<div class="form-group">
|
538 |
+
<select name="gm_screen_options[sortorder_wpmedia]" class="form-control input-sm">
|
539 |
+
<option' . selected( $gm_screen_options['sortorder_wpmedia'], 'DESC', false ) . ' value="DESC">' . __( 'DESC', 'gmLang' ) . '</option>
|
540 |
+
<option' . selected( $gm_screen_options['sortorder_wpmedia'], 'ASC', false ) . ' value="ASC">' . __( 'ASC', 'gmLang' ) . '</option>
|
541 |
+
</select> <span>' . __( 'sort order', 'gmLang' ) . '</span>
|
542 |
+
</div>
|
543 |
+
</div>
|
544 |
+
';
|
545 |
+
break;
|
546 |
}
|
547 |
|
548 |
if ( $settings ) {
|
admin/ajax.php
CHANGED
@@ -499,6 +499,14 @@ function gmedia_get_modal() {
|
|
499 |
$modal_button = false;
|
500 |
}
|
501 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
502 |
case 'batch_edit':
|
503 |
if ( ! current_user_can( 'gmedia_edit_media' ) ) {
|
504 |
die( '-1' );
|
@@ -511,8 +519,10 @@ function gmedia_get_modal() {
|
|
511 |
$modal_button = false;
|
512 |
break;
|
513 |
}
|
|
|
|
|
514 |
?>
|
515 |
-
<form class="modal-content" id="ajax-modal-form" autocomplete="off" method="post">
|
516 |
<div class="modal-header">
|
517 |
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
518 |
<h4 class="modal-title"><?php echo $modal_title; ?></h4>
|
@@ -788,7 +798,11 @@ function gmedia_get_modal() {
|
|
788 |
if (count( $gm_terms )){
|
789 |
?>
|
790 |
<div class="form-group">
|
791 |
-
<input id="combobox_gmedia_tag" name="tag_names" class="form-control input-sm" value="" placeholder="<?php _e( 'Add Tags...', 'gmLang' ); ?>"
|
|
|
|
|
|
|
|
|
792 |
<script type="text/javascript">
|
793 |
jQuery(function ($) {
|
794 |
var gm_terms = <?php echo json_encode($gm_terms); ?>;
|
@@ -834,19 +848,21 @@ function gmedia_get_modal() {
|
|
834 |
}
|
835 |
break;
|
836 |
case 'delete_tags':
|
837 |
-
|
838 |
-
|
839 |
-
|
|
|
|
|
840 |
}
|
841 |
if (count( $gm_terms )){
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
} else {
|
851 |
$modal_button = false; ?>
|
852 |
<p class="notags"><?php _e( 'No tags', 'gmLang' ); ?></p>
|
@@ -854,6 +870,7 @@ function gmedia_get_modal() {
|
|
854 |
}
|
855 |
break;
|
856 |
case 'filter_authors':
|
|
|
857 |
if ($gmCore->caps['gmedia_show_others_media']){
|
858 |
?>
|
859 |
<div class="form-group">
|
@@ -900,7 +917,7 @@ function gmedia_get_modal() {
|
|
900 |
<label><?php _e( 'Description', 'gmLang' ); ?></label>
|
901 |
<select class="form-control input-sm batch_set" name="batch_description">
|
902 |
<option value=""><?php _e( 'Skip. Do not change', 'gmLang' ); ?></option>
|
903 |
-
<option value="metadata"><?php _e( 'Add
|
904 |
<option value="empty"><?php _e( 'Empty Description', 'gmLang' ); ?></option>
|
905 |
<option value="custom"><?php _e( 'Custom', 'gmLang' ); ?></option>
|
906 |
</select>
|
@@ -1115,8 +1132,8 @@ function gmedia_module_install() {
|
|
1115 |
}
|
1116 |
|
1117 |
|
1118 |
-
add_action( '
|
1119 |
-
function
|
1120 |
global $user_ID, $gmDB, $gmCore, $gmGallery;
|
1121 |
|
1122 |
check_ajax_referer( 'GmediaGallery' );
|
@@ -1131,9 +1148,10 @@ function gmedia_import_modal() {
|
|
1131 |
<h4 class="modal-title"><?php _e( 'Import from WP Media Library' ); ?></h4>
|
1132 |
</div>
|
1133 |
<div class="modal-body" style="position:relative; min-height:270px;">
|
1134 |
-
<form id="import_form" name="import_form" target="import_window" action="<?php echo
|
1135 |
<?php wp_nonce_field( 'GmediaImport' ); ?>
|
1136 |
-
<input type="hidden"
|
|
|
1137 |
<input type="hidden" name="selected" value="<?php $ckey = "gmuser_{$user_ID}_wpmedia";
|
1138 |
if ( isset( $_COOKIE[ $ckey ] ) ) {
|
1139 |
echo $_COOKIE[ $ckey ];
|
@@ -1190,7 +1208,7 @@ function gmedia_import_modal() {
|
|
1190 |
<?php } else { ?>
|
1191 |
<p><?php _e( 'You are not allowed to assign terms', 'gmLang' ) ?></p>
|
1192 |
<?php } ?>
|
1193 |
-
|
1194 |
<script type="text/javascript">
|
1195 |
jQuery(function ($) {
|
1196 |
<?php if($gmCore->caps['gmedia_terms']){ ?>
|
@@ -1225,6 +1243,7 @@ function gmedia_import_modal() {
|
|
1225 |
options: items,
|
1226 |
labelField: 'item',
|
1227 |
valueField: 'item',
|
|
|
1228 |
hideSelected: true
|
1229 |
});
|
1230 |
<?php } ?>
|
@@ -1487,6 +1506,286 @@ function gmedia_set_post_thumbnail() {
|
|
1487 |
die( '0' );
|
1488 |
}
|
1489 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1490 |
add_action( 'wp_ajax_gmedia_application', 'gmedia_application' );
|
1491 |
function gmedia_application() {
|
1492 |
global $gmCore, $gmProcessor;
|
@@ -1512,3 +1811,144 @@ function gmedia_application() {
|
|
1512 |
die();
|
1513 |
}
|
1514 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
499 |
$modal_button = false;
|
500 |
}
|
501 |
break;
|
502 |
+
case 'select_author':
|
503 |
+
$modal_title = __( 'Select Author', 'gmLang' );
|
504 |
+
if ( $gmCore->caps['gmedia_show_others_media'] ) {
|
505 |
+
$modal_button = __( 'Select', 'gmLang' );
|
506 |
+
} else {
|
507 |
+
$modal_button = false;
|
508 |
+
}
|
509 |
+
break;
|
510 |
case 'batch_edit':
|
511 |
if ( ! current_user_can( 'gmedia_edit_media' ) ) {
|
512 |
die( '-1' );
|
519 |
$modal_button = false;
|
520 |
break;
|
521 |
}
|
522 |
+
|
523 |
+
$form_action = !empty($_SERVER['HTTP_REFERER'])? $gmCore->get_admin_url(array(),array(), $_SERVER['HTTP_REFERER']) : '';
|
524 |
?>
|
525 |
+
<form class="modal-content" id="ajax-modal-form" autocomplete="off" method="post" action="<?php echo $form_action; ?>">
|
526 |
<div class="modal-header">
|
527 |
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
528 |
<h4 class="modal-title"><?php echo $modal_title; ?></h4>
|
798 |
if (count( $gm_terms )){
|
799 |
?>
|
800 |
<div class="form-group">
|
801 |
+
<input id="combobox_gmedia_tag" name="tag_names" class="form-control input-sm" value="" placeholder="<?php _e( 'Add Tags...', 'gmLang' ); ?>"/>
|
802 |
+
</div>
|
803 |
+
<div class="checkbox">
|
804 |
+
<label><input type="checkbox" name="iptc_tags" value="1"> <?php _e('Import IPTC Keywords from selected images to Tags'); ?></label>
|
805 |
+
</div>
|
806 |
<script type="text/javascript">
|
807 |
jQuery(function ($) {
|
808 |
var gm_terms = <?php echo json_encode($gm_terms); ?>;
|
848 |
}
|
849 |
break;
|
850 |
case 'delete_tags':
|
851 |
+
// get selected items in Gmedia Library
|
852 |
+
$ckey = "gmuser_{$user_ID}_library";
|
853 |
+
$selected_items = array_filter(explode(',', $_COOKIE[$ckey]), 'is_numeric');
|
854 |
+
if ( ! empty( $selected_items ) ) {
|
855 |
+
$gm_terms = $gmDB->get_gmedia_terms( $selected_items, 'gmedia_tag' );
|
856 |
}
|
857 |
if (count( $gm_terms )){
|
858 |
+
foreach ($gm_terms as $term){
|
859 |
+
?>
|
860 |
+
<div class="checkbox">
|
861 |
+
<label><input type="checkbox" name="tag_id[]" value="<?php echo $term->term_id; ?>"> <?php echo esc_html( $term->name ); ?></label>
|
862 |
+
<span class="badge pull-right"><?php echo $term->count; ?></span>
|
863 |
+
</div>
|
864 |
+
<?php
|
865 |
+
}
|
866 |
} else {
|
867 |
$modal_button = false; ?>
|
868 |
<p class="notags"><?php _e( 'No tags', 'gmLang' ); ?></p>
|
870 |
}
|
871 |
break;
|
872 |
case 'filter_authors':
|
873 |
+
case 'select_author':
|
874 |
if ($gmCore->caps['gmedia_show_others_media']){
|
875 |
?>
|
876 |
<div class="form-group">
|
917 |
<label><?php _e( 'Description', 'gmLang' ); ?></label>
|
918 |
<select class="form-control input-sm batch_set" name="batch_description">
|
919 |
<option value=""><?php _e( 'Skip. Do not change', 'gmLang' ); ?></option>
|
920 |
+
<option value="metadata"><?php _e( 'Add MetaInfo to Description', 'gmLang' ); ?></option>
|
921 |
<option value="empty"><?php _e( 'Empty Description', 'gmLang' ); ?></option>
|
922 |
<option value="custom"><?php _e( 'Custom', 'gmLang' ); ?></option>
|
923 |
</select>
|
1132 |
}
|
1133 |
|
1134 |
|
1135 |
+
add_action( 'wp_ajax_gmedia_import_wpmedia_modal', 'gmedia_import_wpmedia_modal' );
|
1136 |
+
function gmedia_import_wpmedia_modal() {
|
1137 |
global $user_ID, $gmDB, $gmCore, $gmGallery;
|
1138 |
|
1139 |
check_ajax_referer( 'GmediaGallery' );
|
1148 |
<h4 class="modal-title"><?php _e( 'Import from WP Media Library' ); ?></h4>
|
1149 |
</div>
|
1150 |
<div class="modal-body" style="position:relative; min-height:270px;">
|
1151 |
+
<form id="import_form" name="import_form" target="import_window" action="<?php echo admin_url('admin-ajax.php'); ?>" method="POST" accept-charset="utf-8">
|
1152 |
<?php wp_nonce_field( 'GmediaImport' ); ?>
|
1153 |
+
<input type="hidden" name="action" value="gmedia_import_handler"/>
|
1154 |
+
<input type="hidden" id="import-action" name="import" value="import-wpmedia"/>
|
1155 |
<input type="hidden" name="selected" value="<?php $ckey = "gmuser_{$user_ID}_wpmedia";
|
1156 |
if ( isset( $_COOKIE[ $ckey ] ) ) {
|
1157 |
echo $_COOKIE[ $ckey ];
|
1208 |
<?php } else { ?>
|
1209 |
<p><?php _e( 'You are not allowed to assign terms', 'gmLang' ) ?></p>
|
1210 |
<?php } ?>
|
1211 |
+
<div class="checkbox"><label><input type="checkbox" name="skip_exists" value="skip"> <?php _e('Skip if file with the same name already exists in Gmedia Library', 'gmLang'); ?></label></div>
|
1212 |
<script type="text/javascript">
|
1213 |
jQuery(function ($) {
|
1214 |
<?php if($gmCore->caps['gmedia_terms']){ ?>
|
1243 |
options: items,
|
1244 |
labelField: 'item',
|
1245 |
valueField: 'item',
|
1246 |
+
searchField: ['item'],
|
1247 |
hideSelected: true
|
1248 |
});
|
1249 |
<?php } ?>
|
1506 |
die( '0' );
|
1507 |
}
|
1508 |
|
1509 |
+
add_action( 'wp_ajax_gmedia_upload_handler', 'gmedia_upload_handler' );
|
1510 |
+
function gmedia_upload_handler() {
|
1511 |
+
global $gmCore;
|
1512 |
+
|
1513 |
+
//ini_set( 'display_errors', 0 );
|
1514 |
+
//ini_set( 'error_reporting', 0 );
|
1515 |
+
ini_set( 'max_execution_time', 300 );
|
1516 |
+
|
1517 |
+
// HTTP headers for no cache etc
|
1518 |
+
nocache_headers();
|
1519 |
+
|
1520 |
+
// if nonce is not correct it returns -1
|
1521 |
+
check_ajax_referer( 'GmediaUpload' );
|
1522 |
+
if ( ! current_user_can( 'gmedia_upload' ) ) {
|
1523 |
+
wp_die( __( 'You do not have permission to upload files in Gmedia Library.' ) );
|
1524 |
+
}
|
1525 |
+
|
1526 |
+
// 5 minutes execution time
|
1527 |
+
@set_time_limit( 5 * 60 );
|
1528 |
+
|
1529 |
+
// fake upload time
|
1530 |
+
usleep( 10 );
|
1531 |
+
|
1532 |
+
$filename = $gmCore->_req('name');
|
1533 |
+
|
1534 |
+
// Get parameters
|
1535 |
+
if ( !$filename ) {
|
1536 |
+
$return = json_encode( array( "error" => array( "code" => 100, "message" => __( "No file name.", 'gmLang' ) ) ) );
|
1537 |
+
die( $return );
|
1538 |
+
}
|
1539 |
+
|
1540 |
+
$fileinfo = $gmCore->fileinfo( $filename );
|
1541 |
+
if ( false === $fileinfo ) {
|
1542 |
+
$return = json_encode( array( "error" => array( "code" => 100, "message" => __( "File type not allowed.", 'gmLang' ) ), "id" => $filename ) );
|
1543 |
+
die( $return );
|
1544 |
+
}
|
1545 |
+
|
1546 |
+
// Look for the content type header
|
1547 |
+
$contentType = '';
|
1548 |
+
if ( isset( $_SERVER["HTTP_CONTENT_TYPE"] ) ) {
|
1549 |
+
$contentType = $_SERVER["HTTP_CONTENT_TYPE"];
|
1550 |
+
}
|
1551 |
+
|
1552 |
+
if ( isset( $_SERVER["CONTENT_TYPE"] ) ) {
|
1553 |
+
$contentType = $_SERVER["CONTENT_TYPE"];
|
1554 |
+
}
|
1555 |
+
|
1556 |
+
// Handle non multipart uploads older WebKit versions didn't support multipart in HTML5
|
1557 |
+
$file_tmp = '';
|
1558 |
+
if ( strpos( $contentType, "multipart" ) !== false ) {
|
1559 |
+
if ( isset( $_FILES['file']['tmp_name'] ) && is_uploaded_file( $_FILES['file']['tmp_name'] ) ) {
|
1560 |
+
$file_tmp = $_FILES['file']['tmp_name'];
|
1561 |
+
}
|
1562 |
+
} else {
|
1563 |
+
$file_tmp = "php://input";
|
1564 |
+
}
|
1565 |
+
|
1566 |
+
if(empty($file_tmp)){
|
1567 |
+
$return = json_encode( array( "error" => array( "code" => 103, "message" => __( "Failed to move uploaded file.", 'gmLang' ) ), "id" => $filename ) );
|
1568 |
+
die( $return );
|
1569 |
+
}
|
1570 |
+
|
1571 |
+
$post_data = array();
|
1572 |
+
if ( ($params = $gmCore->_req('params', '')) ) {
|
1573 |
+
parse_str( $params, $post_data );
|
1574 |
+
}
|
1575 |
+
|
1576 |
+
$return = $gmCore->gmedia_upload_handler( $file_tmp, $fileinfo, $contentType, $post_data );
|
1577 |
+
$return = json_encode( $return );
|
1578 |
+
|
1579 |
+
die( $return );
|
1580 |
+
}
|
1581 |
+
|
1582 |
+
add_action( 'wp_ajax_gmedia_import_handler', 'gmedia_import_handler' );
|
1583 |
+
function gmedia_import_handler() {
|
1584 |
+
global $wpdb, $gmCore, $gmDB;
|
1585 |
+
|
1586 |
+
//ini_set( 'display_errors', 0 );
|
1587 |
+
//ini_set( 'error_reporting', 0 );
|
1588 |
+
ini_set( 'max_execution_time', 600 );
|
1589 |
+
|
1590 |
+
// HTTP headers for no cache etc
|
1591 |
+
nocache_headers();
|
1592 |
+
|
1593 |
+
check_admin_referer( 'GmediaImport' );
|
1594 |
+
if ( ! current_user_can( 'gmedia_import' ) ) {
|
1595 |
+
wp_die( __( 'You do not have permission to upload files.' ) );
|
1596 |
+
}
|
1597 |
+
|
1598 |
+
// 10 minutes execution time
|
1599 |
+
@set_time_limit( 10 * 60 );
|
1600 |
+
|
1601 |
+
// fake upload time
|
1602 |
+
usleep( 10 );
|
1603 |
+
|
1604 |
+
$import = $gmCore->_post( 'import' );
|
1605 |
+
$terms = $gmCore->_post( 'terms', array() );
|
1606 |
+
|
1607 |
+
if ( ob_get_level() == 0 ) {
|
1608 |
+
ob_start();
|
1609 |
+
}
|
1610 |
+
echo str_pad( ' ', 4096 ) . PHP_EOL;
|
1611 |
+
wp_ob_end_flush_all();
|
1612 |
+
flush();
|
1613 |
+
?>
|
1614 |
+
<html>
|
1615 |
+
<style type="text/css">
|
1616 |
+
* {
|
1617 |
+
margin: 0;
|
1618 |
+
padding: 0;
|
1619 |
+
}
|
1620 |
+
|
1621 |
+
pre {
|
1622 |
+
display: block;
|
1623 |
+
}
|
1624 |
+
|
1625 |
+
p {
|
1626 |
+
padding: 10px 0;
|
1627 |
+
font-size: 14px;
|
1628 |
+
}
|
1629 |
+
|
1630 |
+
.ok {
|
1631 |
+
color: darkgreen;
|
1632 |
+
}
|
1633 |
+
|
1634 |
+
.ko {
|
1635 |
+
color: darkred;
|
1636 |
+
}
|
1637 |
+
</style>
|
1638 |
+
<body>
|
1639 |
+
<?php
|
1640 |
+
if ( ('import-folder' == $import) || isset($_POST['import-folder']) ) {
|
1641 |
+
|
1642 |
+
$path = $gmCore->_post( 'path' );
|
1643 |
+
echo '<h4 style="margin: 0 0 10px">' . __( 'Import Server Folder' ) . " `$path`:</h4>" . PHP_EOL;
|
1644 |
+
|
1645 |
+
if ( $path ) {
|
1646 |
+
$path = trim( urldecode( $path ), '/' );
|
1647 |
+
if ( ! empty( $path ) ) {
|
1648 |
+
$fullpath = ABSPATH . trailingslashit( $path );
|
1649 |
+
$files = glob( $fullpath . '?*.?*', GLOB_NOSORT );
|
1650 |
+
if ( ! empty( $files ) ) {
|
1651 |
+
$allowed_ext = get_allowed_mime_types();
|
1652 |
+
$allowed_ext = array_keys( $allowed_ext );
|
1653 |
+
$allowed_ext = implode( '|', $allowed_ext );
|
1654 |
+
$allowed_ext = explode( '|', $allowed_ext );
|
1655 |
+
if ( ( GMEDIA_UPLOAD_FOLDER == basename( dirname( dirname( $path ) ) ) ) || ( GMEDIA_UPLOAD_FOLDER == basename( dirname( $path ) ) ) ) {
|
1656 |
+
global $wpdb;
|
1657 |
+
$gmedias = $wpdb->get_col( "SELECT gmuid FROM {$wpdb->prefix}gmedia" );
|
1658 |
+
foreach ( $files as $i => $filepath ) {
|
1659 |
+
$gmuid = basename( $filepath );
|
1660 |
+
if ( in_array( $gmuid, $gmedias ) ) {
|
1661 |
+
$fileinfo = $gmCore->fileinfo( $gmuid, false );
|
1662 |
+
if ( ! ( ( 'image' == $fileinfo['dirname'] ) && ! file_exists( $fileinfo['filepath'] ) ) ) {
|
1663 |
+
unset( $files[ $i ] );
|
1664 |
+
}
|
1665 |
+
}
|
1666 |
+
}
|
1667 |
+
$move = false;
|
1668 |
+
$exists = false;
|
1669 |
+
} else {
|
1670 |
+
$move = $gmCore->_post( 'delete_source' );
|
1671 |
+
$exists = 0;
|
1672 |
+
}
|
1673 |
+
foreach ( $files as $i => $filepath ) {
|
1674 |
+
$ext = pathinfo( $filepath, PATHINFO_EXTENSION );
|
1675 |
+
if ( ! in_array( strtolower($ext), $allowed_ext ) ) {
|
1676 |
+
unset( $files[ $i ] );
|
1677 |
+
}
|
1678 |
+
}
|
1679 |
+
$gmCore->gmedia_import_files( $files, $terms, $move, $exists );
|
1680 |
+
} else {
|
1681 |
+
echo sprintf( __( 'Folder `%s` is empty', 'gmLang' ), $path ) . PHP_EOL;
|
1682 |
+
}
|
1683 |
+
} else {
|
1684 |
+
echo __( 'No folder chosen', 'gmLang' ) . PHP_EOL;
|
1685 |
+
}
|
1686 |
+
}
|
1687 |
+
} elseif ( ('import-flagallery' == $import) || isset($_POST['import-flagallery']) ) {
|
1688 |
+
|
1689 |
+
echo '<h4 style="margin: 0 0 10px">' . __( 'Import from Flagallery plugin' ) . ":</h4>" . PHP_EOL;
|
1690 |
+
|
1691 |
+
$gallery = $gmCore->_post( 'gallery' );
|
1692 |
+
if ( ! empty( $gallery ) ) {
|
1693 |
+
$album = ( ! isset( $terms['gmedia_album'] ) || empty( $terms['gmedia_album'] ) ) ? false : true;
|
1694 |
+
foreach ( $gallery as $gid ) {
|
1695 |
+
$flag_gallery = $wpdb->get_row( $wpdb->prepare( "SELECT gid, path, title, galdesc FROM {$wpdb->prefix}flag_gallery WHERE gid = %d", $gid ), ARRAY_A );
|
1696 |
+
if ( empty( $flag_gallery ) ) {
|
1697 |
+
continue;
|
1698 |
+
}
|
1699 |
+
|
1700 |
+
if ( ! $album ) {
|
1701 |
+
$terms['gmedia_album'] = $flag_gallery['title'];
|
1702 |
+
if ( ! $gmDB->term_exists( $flag_gallery['title'], 'gmedia_album' ) ) {
|
1703 |
+
$term_id = $gmDB->insert_term( $flag_gallery['title'], 'gmedia_album', array( 'description' => htmlspecialchars_decode( stripslashes( $flag_gallery['galdesc'] ) ) ) );
|
1704 |
+
}
|
1705 |
+
}
|
1706 |
+
|
1707 |
+
$path = ABSPATH . trailingslashit( $flag_gallery['path'] );
|
1708 |
+
|
1709 |
+
echo '<h5 style="margin: 10px 0 5px">' . sprintf( __( 'Import `%s` gallery', 'gmLang' ), $flag_gallery['title'] ) . ":</h5>" . PHP_EOL;
|
1710 |
+
|
1711 |
+
$flag_pictures = $wpdb->get_results( $wpdb->prepare( "SELECT CONCAT('%s', filename) AS file, description, alttext AS title, link FROM {$wpdb->prefix}flag_pictures WHERE galleryid = %d", $path, $flag_gallery['gid'] ), ARRAY_A );
|
1712 |
+
if ( empty( $flag_pictures ) ) {
|
1713 |
+
echo '<pre>' . __( 'gallery contains 0 images', 'gmLang' ) . '</pre>';
|
1714 |
+
continue;
|
1715 |
+
}
|
1716 |
+
//echo '<pre>'.print_r($flag_pictures, true).'</pre>';
|
1717 |
+
$gmCore->gmedia_import_files( $flag_pictures, $terms, false );
|
1718 |
+
}
|
1719 |
+
} else {
|
1720 |
+
echo __( 'No gallery chosen', 'gmLang' ) . PHP_EOL;
|
1721 |
+
}
|
1722 |
+
} elseif ( ('import-nextgen' == $import) || isset($_POST['import-nextgen']) ) {
|
1723 |
+
|
1724 |
+
echo '<h4 style="margin: 0 0 10px">' . __( 'Import from NextGen plugin' ) . ":</h4>" . PHP_EOL;
|
1725 |
+
|
1726 |
+
$gallery = $gmCore->_post( 'gallery' );
|
1727 |
+
if ( ! empty( $gallery ) ) {
|
1728 |
+
$album = ( ! isset( $terms['gmedia_album'] ) || empty( $terms['gmedia_album'] ) ) ? false : true;
|
1729 |
+
foreach ( $gallery as $gid ) {
|
1730 |
+
$ngg_gallery = $wpdb->get_row( $wpdb->prepare( "SELECT gid, path, title, galdesc FROM {$wpdb->prefix}ngg_gallery WHERE gid = %d", $gid ), ARRAY_A );
|
1731 |
+
if ( empty( $ngg_gallery ) ) {
|
1732 |
+
continue;
|
1733 |
+
}
|
1734 |
+
|
1735 |
+
if ( ! $album ) {
|
1736 |
+
$terms['gmedia_album'] = $ngg_gallery['title'];
|
1737 |
+
if ( ! $gmDB->term_exists( $ngg_gallery['title'], 'gmedia_album' ) ) {
|
1738 |
+
$term_id = $gmDB->insert_term( $ngg_gallery['title'], 'gmedia_album', array( 'description' => htmlspecialchars_decode( stripslashes( $ngg_gallery['galdesc'] ) ) ) );
|
1739 |
+
}
|
1740 |
+
}
|
1741 |
+
|
1742 |
+
$path = ABSPATH . trailingslashit( $ngg_gallery['path'] );
|
1743 |
+
|
1744 |
+
echo '<h5 style="margin: 10px 0 5px">' . sprintf( __( 'Import `%s` gallery', 'gmLang' ), $ngg_gallery['title'] ) . ":</h5>" . PHP_EOL;
|
1745 |
+
|
1746 |
+
$ngg_pictures = $wpdb->get_results( $wpdb->prepare( "SELECT CONCAT('%s', filename) AS file, description, alttext AS title FROM {$wpdb->prefix}ngg_pictures WHERE galleryid = %d", $path, $ngg_gallery['gid'] ), ARRAY_A );
|
1747 |
+
if ( empty( $ngg_pictures ) ) {
|
1748 |
+
echo '<pre>' . __( 'gallery contains 0 images', 'gmLang' ) . '</pre>';
|
1749 |
+
continue;
|
1750 |
+
}
|
1751 |
+
$gmCore->gmedia_import_files( $ngg_pictures, $terms, false );
|
1752 |
+
}
|
1753 |
+
} else {
|
1754 |
+
echo __( 'No gallery chosen', 'gmLang' ) . PHP_EOL;
|
1755 |
+
}
|
1756 |
+
} elseif ( ('import-wpmedia' == $import) || isset($_POST['import-wpmedia']) ) {
|
1757 |
+
|
1758 |
+
echo '<h4 style="margin: 0 0 10px">' . __( 'Import from WP Media Library' ) . ":</h4>" . PHP_EOL;
|
1759 |
+
|
1760 |
+
$wpMediaLib = $gmDB->get_wp_media_lib( array( 'filter' => 'selected', 'selected' => $gmCore->_post( 'selected' ) ) );
|
1761 |
+
|
1762 |
+
if ( ! empty( $wpMediaLib ) ) {
|
1763 |
+
|
1764 |
+
$wp_media = array();
|
1765 |
+
foreach ( $wpMediaLib as $item ) {
|
1766 |
+
$wp_media[] = array(
|
1767 |
+
'file' => get_attached_file( $item->ID ),
|
1768 |
+
'title' => $item->post_title,
|
1769 |
+
'description' => $item->post_content
|
1770 |
+
);
|
1771 |
+
}
|
1772 |
+
$exists = $gmCore->_post('skip_exists', 0);
|
1773 |
+
//echo '<pre>' . print_r($wp_media, true) . '</pre>';
|
1774 |
+
$gmCore->gmedia_import_files( $wp_media, $terms, false, $exists );
|
1775 |
+
|
1776 |
+
} else {
|
1777 |
+
echo __( 'No items chosen', 'gmLang' ) . PHP_EOL;
|
1778 |
+
}
|
1779 |
+
}
|
1780 |
+
?>
|
1781 |
+
</body>
|
1782 |
+
</html>
|
1783 |
+
<?php
|
1784 |
+
wp_ob_end_flush_all();
|
1785 |
+
|
1786 |
+
die();
|
1787 |
+
}
|
1788 |
+
|
1789 |
add_action( 'wp_ajax_gmedia_application', 'gmedia_application' );
|
1790 |
function gmedia_application() {
|
1791 |
global $gmCore, $gmProcessor;
|
1811 |
die();
|
1812 |
}
|
1813 |
|
1814 |
+
add_action( 'wp_ajax_gmedia_share_page', 'gmedia_share_page' );
|
1815 |
+
function gmedia_share_page() {
|
1816 |
+
global $gmCore, $gmProcessor, $user_ID;
|
1817 |
+
// if nonce is not correct it returns -1
|
1818 |
+
check_ajax_referer( 'share_modal', '_sharenonce' );
|
1819 |
+
|
1820 |
+
$sharelink = $gmCore->_post('sharelink', '');
|
1821 |
+
$email = $gmCore->_post('email', '');
|
1822 |
+
$sharemessage = $gmCore->_post('message', '');
|
1823 |
+
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
1824 |
+
echo $gmProcessor->alert( 'danger', __('Invalid email', 'gmLang'). ': '. esc_html($email) );
|
1825 |
+
die();
|
1826 |
+
}
|
1827 |
+
|
1828 |
+
$display_name = get_the_author_meta( 'display_name', $user_ID );
|
1829 |
+
$subject = sprintf(__('%s shared GmediaCloud Page with you', 'gmLang'), $display_name);
|
1830 |
+
$sharetitle = sprintf(__('%s used Gmedia to share something interesting with you!', 'gmLang'), $display_name);
|
1831 |
+
$sharelinktext = __('Click here to view page', 'gmLang');
|
1832 |
+
if($sharemessage){
|
1833 |
+
$sharemessage = '<blockquote>"'.nl2br(esc_html($sharemessage)).'"</blockquote>';
|
1834 |
+
}
|
1835 |
+
$footer = '© '.date('Y').' Gmedia';
|
1836 |
+
$message = <<<EOT
|
1837 |
+
<center>
|
1838 |
+
<table cellpadding="0" cellspacing="0" style="border-radius:4px;border:1px #dceaf5 solid;" border="0" align="center">
|
1839 |
+
<tr><td colspan="3" height="20"></td></tr>
|
1840 |
+
<tr style="line-height:0;">
|
1841 |
+
<td width="100%" style="font-size:0;" align="center" height="1">
|
1842 |
+
<img width="72" style="max-height:72px;width:72px;" alt="GmediaGallery" src="http://mypgc.co/images/email/logo-128.png" />
|
1843 |
+
</td>
|
1844 |
+
</tr>
|
1845 |
+
<tr><td>
|
1846 |
+
<table cellpadding="0" cellspacing="0" style="line-height:25px;" border="0" align="center">
|
1847 |
+
<tr><td colspan="3" height="20"></td></tr>
|
1848 |
+
<tr>
|
1849 |
+
<td width="36"></td>
|
1850 |
+
<td width="454" align="left" style="color:#444444;border-collapse:collapse;font-size:11pt;font-family:proxima_nova,'Open Sans','Lucida Grande','Segoe UI',Arial,Verdana,'Lucida Sans Unicode',Tahoma,'Sans Serif';max-width:454px;" valign="top">{$sharetitle}<br />
|
1851 |
+
{$sharemessage}
|
1852 |
+
<br /><a style="color:#0D8FB3" href="{$sharelink}">{$sharelinktext}</a>.</td>
|
1853 |
+
<td width="36"></td>
|
1854 |
+
</tr>
|
1855 |
+
<tr><td colspan="3" height="36"></td></tr>
|
1856 |
+
</table>
|
1857 |
+
</td>
|
1858 |
+
</tr>
|
1859 |
+
</table>
|
1860 |
+
<table cellpadding="0" cellspacing="0" align="center" border="0">
|
1861 |
+
<tr><td height="10"></td></tr>
|
1862 |
+
<tr><td style="padding:0;border-collapse:collapse;">
|
1863 |
+
<table cellpadding="0" cellspacing="0" align="center" border="0">
|
1864 |
+
<tr style="color:#a8b9c6;font-size:11px;font-family:proxima_nova,'Open Sans','Lucida Grande','Segoe UI',Arial,Verdana,'Lucida Sans Unicode',Tahoma,'Sans Serif';">
|
1865 |
+
<td width="128" align="left"></td>
|
1866 |
+
<td width="400" align="right">{$footer}</td>
|
1867 |
+
</tr>
|
1868 |
+
</table>
|
1869 |
+
</td>
|
1870 |
+
</tr>
|
1871 |
+
</table>
|
1872 |
+
</center>
|
1873 |
+
EOT;
|
1874 |
+
|
1875 |
+
$headers = array('Content-Type: text/html; charset=UTF-8');
|
1876 |
+
if(wp_mail( $email, $subject, $message, $headers )){
|
1877 |
+
echo $gmProcessor->alert( 'success', sprintf(__('Message sent to %s', 'gmLang'), $email) );
|
1878 |
+
}
|
1879 |
+
|
1880 |
+
die();
|
1881 |
+
}
|
1882 |
+
|
1883 |
+
add_action( 'wp_ajax_gmedia_module_interaction', 'gmedia_module_interaction' );
|
1884 |
+
add_action( 'wp_ajax_nopriv_gmedia_module_interaction', 'gmedia_module_interaction' );
|
1885 |
+
function gmedia_module_interaction() {
|
1886 |
+
global $gmDB, $gmCore;
|
1887 |
+
|
1888 |
+
if ( empty( $_SERVER['HTTP_REFERER'] ) ) {
|
1889 |
+
die();
|
1890 |
+
}
|
1891 |
+
|
1892 |
+
$ref = $_SERVER['HTTP_REFERER'];
|
1893 |
+
//$uip = str_replace('.', '', $_SERVER['REMOTE_ADDR'])
|
1894 |
+
if ( (false === strpos( $ref, get_home_url() )) && (false === strpos( $ref, get_site_url()) )) {
|
1895 |
+
echo 'referer:'.$_SERVER['HTTP_REFERER']."\n";
|
1896 |
+
echo 'home_url:'.get_home_url()."\n";
|
1897 |
+
echo 'site_url:'.get_site_url()."\n";
|
1898 |
+
die('-1');
|
1899 |
+
}
|
1900 |
+
|
1901 |
+
if ( isset($_POST['hit']) && ($gmID = intval($_POST['hit'])) ) {
|
1902 |
+
if(null === $gmDB->get_gmedia($gmID)){
|
1903 |
+
die('0');
|
1904 |
+
}
|
1905 |
+
$meta['views'] = $gmDB->get_metadata('gmedia', $gmID, 'views', true);
|
1906 |
+
$meta['likes'] = $gmDB->get_metadata('gmedia', $gmID, 'likes', true);
|
1907 |
+
|
1908 |
+
$meta = array_map('intval', $meta);
|
1909 |
+
$meta = $gmCore->gm_hitcounter($gmID, $meta);
|
1910 |
+
|
1911 |
+
header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ), true );
|
1912 |
+
echo json_encode($meta);
|
1913 |
+
die();
|
1914 |
+
}
|
1915 |
+
|
1916 |
+
if ( isset($_POST['rate']) ) {
|
1917 |
+
/**
|
1918 |
+
* @var $uip
|
1919 |
+
* @var $gmid
|
1920 |
+
* @var $rate
|
1921 |
+
*/
|
1922 |
+
extract($_POST['rate'], EXTR_OVERWRITE);
|
1923 |
+
if(!intval($gmid) || (null === $gmDB->get_gmedia($gmid))){
|
1924 |
+
die('0');
|
1925 |
+
}
|
1926 |
+
$rating = $gmDB->get_metadata('gmedia', $gmid, 'rating', true);
|
1927 |
+
$old_rate = 0;
|
1928 |
+
|
1929 |
+
$transient_key = 'gm_rate_day'.date('w');
|
1930 |
+
$transient_value = get_transient($transient_key);
|
1931 |
+
if($transient_value){
|
1932 |
+
if(isset($transient_value[$uip][$gmid])){
|
1933 |
+
$old_rate = $transient_value[$uip][$gmid];
|
1934 |
+
}
|
1935 |
+
$transient_value[$uip][$gmid] = $rate;
|
1936 |
+
} else{
|
1937 |
+
$transient_value = array($uip => array($gmid => $rate));
|
1938 |
+
}
|
1939 |
+
set_transient($transient_key, $transient_value, 18 * HOUR_IN_SECONDS);
|
1940 |
+
|
1941 |
+
$rating_votes = $old_rate? $rating['votes'] : $rating['votes'] + 1;
|
1942 |
+
$rating_value = ($rating['value']*$rating['votes'] + $rate - $old_rate)/$rating_votes;
|
1943 |
+
$rating = array('value' => $rating_value, 'votes' => $rating_votes);
|
1944 |
+
|
1945 |
+
$gmDB->update_metadata('gmedia', $gmid, 'rating', $rating);
|
1946 |
+
|
1947 |
+
header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ), true );
|
1948 |
+
echo json_encode(array($rating));
|
1949 |
+
die();
|
1950 |
+
}
|
1951 |
+
|
1952 |
+
die();
|
1953 |
+
}
|
1954 |
+
|
admin/css/grand-media.css
CHANGED
@@ -78,6 +78,7 @@ div#gmedia-container {
|
|
78 |
position: relative;
|
79 |
z-index: 1;
|
80 |
direction: ltr;
|
|
|
81 |
}
|
82 |
|
83 |
div#gmedia-header {
|
@@ -140,6 +141,7 @@ form.gmedia-search-form {
|
|
140 |
form.gmedia-search-form .form-group {
|
141 |
margin: 0;
|
142 |
display: inline-block;
|
|
|
143 |
}
|
144 |
|
145 |
.gmedia-pager {
|
@@ -172,6 +174,8 @@ a.text-danger {
|
|
172 |
height: 16px;
|
173 |
}
|
174 |
|
|
|
|
|
175 |
.dropdown-menu > li > a:hover, .dropdown-menu > li > a:focus {
|
176 |
background-color: #e8e8e8;
|
177 |
}
|
@@ -217,14 +221,14 @@ div#gm-list-table {
|
|
217 |
background-color: #fcfcfc;
|
218 |
}
|
219 |
|
220 |
-
.list-group-item.d-row.active {
|
221 |
color: #444;
|
222 |
border-color: #ddd;
|
223 |
background-color: rgb(250, 255, 245);
|
224 |
box-shadow: inset -1px 0 0 2px rgb(250, 255, 245), inset 7px 0 0 0 #1e8cbe;
|
225 |
}
|
226 |
|
227 |
-
.no-touch .list-group-item.d-row.active:hover {
|
228 |
color: #444;
|
229 |
border-color: #ddd;
|
230 |
background-color: rgb(245, 255, 240);
|
@@ -251,18 +255,10 @@ div#gmedia-container .list-group-item-warning:hover {
|
|
251 |
box-shadow: 3px 0 0 5px #fcf8e3, -2px 0 0 5px #ffd87c;
|
252 |
}
|
253 |
|
254 |
-
label.cb_media-object {
|
255 |
-
margin-right: 15px;
|
256 |
-
float: left;
|
257 |
-
width: 310px;
|
258 |
-
max-width: 100%;
|
259 |
-
}
|
260 |
-
|
261 |
-
div.li_media-object {
|
262 |
margin-right: 15px;
|
263 |
-
padding-left: 15px;
|
264 |
float: left;
|
265 |
-
width:
|
266 |
max-width: 100%;
|
267 |
}
|
268 |
|
@@ -270,7 +266,7 @@ div.li_media-object {
|
|
270 |
margin-bottom: 0;
|
271 |
}
|
272 |
|
273 |
-
.active .thumbnail {
|
274 |
border-color: #428bca;
|
275 |
}
|
276 |
|
@@ -339,12 +335,10 @@ div.li_media-object {
|
|
339 |
display: none;
|
340 |
height: 100%;
|
341 |
box-shadow: -10px 0 5px -2px #fff;
|
342 |
-
z-index:
|
343 |
}
|
344 |
|
345 |
-
.term-list-item.active .term_id {
|
346 |
-
background-color: #337ab7;
|
347 |
-
box-shadow: -10px 0 3px -2px #337ab7;
|
348 |
display: block;
|
349 |
}
|
350 |
|
@@ -380,6 +374,9 @@ form.changed .gm-last-edited {
|
|
380 |
display: none;
|
381 |
}
|
382 |
|
|
|
|
|
|
|
383 |
div#pluploadUploader {
|
384 |
padding: 0;
|
385 |
}
|
@@ -465,7 +462,12 @@ div#gmedia-msg-panel .alert {
|
|
465 |
padding-top: 0;
|
466 |
padding-bottom: 0;
|
467 |
}
|
468 |
-
|
|
|
|
|
|
|
|
|
|
|
469 |
.term-list-item .term-label .checkbox {
|
470 |
padding-left: 35px;
|
471 |
}
|
@@ -492,21 +494,25 @@ div#gmedia-msg-panel .alert {
|
|
492 |
|
493 |
.term-list-item .term-images {
|
494 |
padding-top: 5px;
|
495 |
-
padding-bottom:
|
496 |
overflow: hidden;
|
497 |
white-space: nowrap;
|
498 |
}
|
499 |
|
500 |
.term-list-item .term-images img {
|
501 |
position: relative;
|
502 |
-
height:
|
503 |
width: auto;
|
504 |
background-color: #ffffff;
|
505 |
}
|
506 |
|
|
|
|
|
|
|
507 |
.term-list-item .term_info_author {
|
508 |
font-size: 80%;
|
509 |
-
|
|
|
510 |
}
|
511 |
|
512 |
.no-touch .term-list-item .term-images img:hover {
|
@@ -540,7 +546,7 @@ a.edit_tag_save.btn {
|
|
540 |
float: left;
|
541 |
position: relative;
|
542 |
margin-right: 5px;
|
543 |
-
margin-bottom:
|
544 |
max-width: 100%;
|
545 |
height: auto;
|
546 |
padding: 4px;
|
@@ -575,6 +581,22 @@ a.edit_tag_save.btn {
|
|
575 |
line-height: 120%;
|
576 |
pointer-events: none;
|
577 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
578 |
|
579 |
.ui-highlight-placeholder {
|
580 |
border: 1px solid #0074a2;
|
@@ -699,6 +721,10 @@ body#media-upload .panel-body .list-group-item:first-child {
|
|
699 |
border-width: 0;
|
700 |
}
|
701 |
|
|
|
|
|
|
|
|
|
702 |
body#media-upload .term-list-item .term-label .no-checkbox {
|
703 |
display: inline-block;
|
704 |
width: 100%;
|
@@ -782,6 +808,8 @@ body#media-upload .plupload_wrapper {
|
|
782 |
box-sizing: border-box;
|
783 |
}
|
784 |
|
|
|
|
|
785 |
body#media-upload div#pluploadUploader .plupload_container {
|
786 |
height: 100%;
|
787 |
min-height: inherit !important;
|
@@ -898,6 +926,8 @@ body.gmedia-blank .media-edit-sidebar .panel-footer {
|
|
898 |
overflow-x:auto;
|
899 |
}
|
900 |
|
|
|
|
|
901 |
@media (min-width: 782px) {
|
902 |
div.modal {
|
903 |
top: 32px;
|
@@ -909,7 +939,7 @@ body.gmedia-blank .media-edit-sidebar .panel-footer {
|
|
909 |
|
910 |
}
|
911 |
|
912 |
-
@media
|
913 |
div#wpwrap {
|
914 |
background: #708090;
|
915 |
}
|
@@ -923,8 +953,25 @@ body.gmedia-blank .media-edit-sidebar .panel-footer {
|
|
923 |
display: block;
|
924 |
}
|
925 |
|
926 |
-
label.cb_media-object {float:none;}
|
927 |
.media-body {display:block;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
928 |
}
|
929 |
|
930 |
/* custom inclusion of right, left tabs */
|
78 |
position: relative;
|
79 |
z-index: 1;
|
80 |
direction: ltr;
|
81 |
+
min-width:560px;
|
82 |
}
|
83 |
|
84 |
div#gmedia-header {
|
141 |
form.gmedia-search-form .form-group {
|
142 |
margin: 0;
|
143 |
display: inline-block;
|
144 |
+
vertical-align:middle;
|
145 |
}
|
146 |
|
147 |
.gmedia-pager {
|
174 |
height: 16px;
|
175 |
}
|
176 |
|
177 |
+
.va-middle {vertical-align:middle}
|
178 |
+
|
179 |
.dropdown-menu > li > a:hover, .dropdown-menu > li > a:focus {
|
180 |
background-color: #e8e8e8;
|
181 |
}
|
221 |
background-color: #fcfcfc;
|
222 |
}
|
223 |
|
224 |
+
.list-group-item.d-row.active-row {
|
225 |
color: #444;
|
226 |
border-color: #ddd;
|
227 |
background-color: rgb(250, 255, 245);
|
228 |
box-shadow: inset -1px 0 0 2px rgb(250, 255, 245), inset 7px 0 0 0 #1e8cbe;
|
229 |
}
|
230 |
|
231 |
+
.no-touch .list-group-item.d-row.active-row:hover {
|
232 |
color: #444;
|
233 |
border-color: #ddd;
|
234 |
background-color: rgb(245, 255, 240);
|
255 |
box-shadow: 3px 0 0 5px #fcf8e3, -2px 0 0 5px #ffd87c;
|
256 |
}
|
257 |
|
258 |
+
label.cb_media-object-gallery {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
259 |
margin-right: 15px;
|
|
|
260 |
float: left;
|
261 |
+
width: 135px;
|
262 |
max-width: 100%;
|
263 |
}
|
264 |
|
266 |
margin-bottom: 0;
|
267 |
}
|
268 |
|
269 |
+
.active-row .thumbnail {
|
270 |
border-color: #428bca;
|
271 |
}
|
272 |
|
335 |
display: none;
|
336 |
height: 100%;
|
337 |
box-shadow: -10px 0 5px -2px #fff;
|
338 |
+
z-index: 1000;
|
339 |
}
|
340 |
|
341 |
+
.term-list-item.active-row .term_id {
|
|
|
|
|
342 |
display: block;
|
343 |
}
|
344 |
|
374 |
display: none;
|
375 |
}
|
376 |
|
377 |
+
.plupload_wrapper {
|
378 |
+
min-width:unset;
|
379 |
+
}
|
380 |
div#pluploadUploader {
|
381 |
padding: 0;
|
382 |
}
|
462 |
padding-top: 0;
|
463 |
padding-bottom: 0;
|
464 |
}
|
465 |
+
#gmedia-container .cb_term-object { min-height:70px; }
|
466 |
+
.object-actions { text-align:right; font-size:16px;}
|
467 |
+
.object-actions.gallery-object-actions { text-align:left; margin-bottom:5px;}
|
468 |
+
.object-actions > * { margin:0 0 0 10px; vertical-align:middle; display:inline-block; }
|
469 |
+
a.trash-icon:hover {color:#843534;}
|
470 |
+
.action-inactive {color:#b8b8b8;}
|
471 |
.term-list-item .term-label .checkbox {
|
472 |
padding-left: 35px;
|
473 |
}
|
494 |
|
495 |
.term-list-item .term-images {
|
496 |
padding-top: 5px;
|
497 |
+
padding-bottom: 5px;
|
498 |
overflow: hidden;
|
499 |
white-space: nowrap;
|
500 |
}
|
501 |
|
502 |
.term-list-item .term-images img {
|
503 |
position: relative;
|
504 |
+
height: 60px;
|
505 |
width: auto;
|
506 |
background-color: #ffffff;
|
507 |
}
|
508 |
|
509 |
+
.term-list-item .term_name {
|
510 |
+
margin-right:10px;
|
511 |
+
}
|
512 |
.term-list-item .term_info_author {
|
513 |
font-size: 80%;
|
514 |
+
white-space:nowrap;
|
515 |
+
color:#444;
|
516 |
}
|
517 |
|
518 |
.no-touch .term-list-item .term-images img:hover {
|
546 |
float: left;
|
547 |
position: relative;
|
548 |
margin-right: 5px;
|
549 |
+
margin-bottom: 25px;
|
550 |
max-width: 100%;
|
551 |
height: auto;
|
552 |
padding: 4px;
|
581 |
line-height: 120%;
|
582 |
pointer-events: none;
|
583 |
}
|
584 |
+
.gm-img-thumbnail .gm-img-thumb-title {
|
585 |
+
position: absolute;
|
586 |
+
left: 0;
|
587 |
+
top: 100%;
|
588 |
+
font-size:90%;
|
589 |
+
line-height: 120%;
|
590 |
+
width:100%;
|
591 |
+
padding:3px;
|
592 |
+
text-overflow:ellipsis;
|
593 |
+
white-space:nowrap;
|
594 |
+
overflow:hidden;
|
595 |
+
text-align:left;
|
596 |
+
}
|
597 |
+
.gm-img-thumbnail.ui-sortable-helper .gm-img-thumb-title {
|
598 |
+
visibility:hidden;
|
599 |
+
}
|
600 |
|
601 |
.ui-highlight-placeholder {
|
602 |
border: 1px solid #0074a2;
|
721 |
border-width: 0;
|
722 |
}
|
723 |
|
724 |
+
body#media-upload .term-list-item .term-images img {
|
725 |
+
height: 30px;
|
726 |
+
}
|
727 |
+
|
728 |
body#media-upload .term-list-item .term-label .no-checkbox {
|
729 |
display: inline-block;
|
730 |
width: 100%;
|
808 |
box-sizing: border-box;
|
809 |
}
|
810 |
|
811 |
+
.addtags-gap { height: 200px; }
|
812 |
+
|
813 |
body#media-upload div#pluploadUploader .plupload_container {
|
814 |
height: 100%;
|
815 |
min-height: inherit !important;
|
926 |
overflow-x:auto;
|
927 |
}
|
928 |
|
929 |
+
input.sharelink[readonly] {cursor:text;}
|
930 |
+
|
931 |
@media (min-width: 782px) {
|
932 |
div.modal {
|
933 |
top: 32px;
|
939 |
|
940 |
}
|
941 |
|
942 |
+
@media (max-width: 782px) {
|
943 |
div#wpwrap {
|
944 |
background: #708090;
|
945 |
}
|
953 |
display: block;
|
954 |
}
|
955 |
|
|
|
956 |
.media-body {display:block;}
|
957 |
+
|
958 |
+
}
|
959 |
+
@media (max-width: 991px) {
|
960 |
+
body#media-upload .panel-body > #gmUpload.row {
|
961 |
+
overflow-y:auto;
|
962 |
+
}
|
963 |
+
|
964 |
+
body#media-upload .panel-body > #gmUpload.row > div {
|
965 |
+
height: auto;
|
966 |
+
}
|
967 |
+
body#media-upload .plupload_wrapper {
|
968 |
+
height: auto;
|
969 |
+
}
|
970 |
+
|
971 |
+
body#media-upload div#pluploadUploader .plupload_container {
|
972 |
+
height: auto;
|
973 |
+
min-height: 300px !important;
|
974 |
+
}
|
975 |
}
|
976 |
|
977 |
/* custom inclusion of right, left tabs */
|
admin/galleries.php
CHANGED
@@ -12,21 +12,23 @@ function gmediaGalleries(){
|
|
12 |
global $user_ID, $gmDB, $gmCore, $gmGallery, $gmProcessor;
|
13 |
|
14 |
$url = add_query_arg(array('page' => $gmProcessor->page), admin_url('admin.php'));
|
|
|
15 |
|
16 |
-
/* todo: per_page and order options for gmedia_terms
|
17 |
$gm_screen_options = get_user_meta($user_ID, 'gm_screen_options', true);
|
18 |
if(!is_array($gm_screen_options)){
|
19 |
$gm_screen_options = array();
|
20 |
}
|
21 |
$gm_screen_options = array_merge($gmGallery->options['gm_screen_options'], $gm_screen_options);
|
22 |
-
|
|
|
|
|
23 |
|
24 |
$filter = ('selected' == $gmCore->_req('filter'))? $gmProcessor->selected_items : null;
|
25 |
$args = array(
|
26 |
-
'orderby' => $gmCore->_get('orderby',
|
27 |
-
'order' => $gmCore->_get('order',
|
28 |
'search' => $gmCore->_get('s', ''),
|
29 |
-
'number' => $gmCore->_get('number',
|
30 |
'hide_empty' => 0,
|
31 |
'page' => $gmCore->_get('pager', 1),
|
32 |
'include' => $filter
|
@@ -159,9 +161,9 @@ function gmediaGalleries(){
|
|
159 |
}
|
160 |
|
161 |
if($term->global == $user_ID){
|
162 |
-
$allow_edit = true;
|
163 |
} else{
|
164 |
-
$allow_edit = $gmCore->caps['gmedia_edit_others_media'];
|
165 |
}
|
166 |
|
167 |
$is_selected = in_array($term->term_id, $gmProcessor->selected_items)? true : false;
|
@@ -175,10 +177,10 @@ function gmediaGalleries(){
|
|
175 |
}
|
176 |
}
|
177 |
?>
|
178 |
-
<div class="list-group-item row d-row<?php echo $list_row_class . ($is_selected? ' active' : ''); ?>" id="list-item-<?php echo $term->term_id; ?>" data-id="<?php echo $term->term_id; ?>" data-type="<?php echo $term_meta['module']; ?>">
|
179 |
<div class="term_id">#<?php echo $term->term_id; ?></div>
|
180 |
<div class="col-xs-7">
|
181 |
-
<label class="cb_media-object
|
182 |
<input name="doaction[]" type="checkbox"<?php echo $is_selected? ' checked="checked"' : ''; ?> data-type="<?php echo $term_meta['module']; ?>" class="hidden" value="<?php echo $term->term_id; ?>"/>
|
183 |
<?php if(!$broken){ ?>
|
184 |
<span class="thumbnail"><img src="<?php echo $module['url'] . '/screenshot.png'; ?>" alt="<?php echo esc_attr($term->name); ?>"/></span>
|
@@ -187,7 +189,7 @@ function gmediaGalleries(){
|
|
187 |
<?php } ?>
|
188 |
</label>
|
189 |
|
190 |
-
<div class="media-body" style="margin-left:
|
191 |
<p class="media-title">
|
192 |
<?php if($allow_edit){ ?>
|
193 |
<a href="<?php echo add_query_arg(array('edit_gallery' => $term->term_id), $url); ?>"><?php echo esc_html($term->name); ?></a>
|
@@ -209,6 +211,44 @@ function gmediaGalleries(){
|
|
209 |
</div>
|
210 |
</div>
|
211 |
<div class="col-xs-5">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
<p class="media-meta">
|
213 |
<span class="label label-default"><?php _e('Module', 'gmLang'); ?>:</span> <?php echo $term_meta['module']; ?>
|
214 |
<br><span class="label label-default"><?php _e('Type', 'gmLang'); ?>:</span> <?php echo $module_info['type']; ?>
|
@@ -326,6 +366,34 @@ function gmediaGalleries(){
|
|
326 |
</div>
|
327 |
</div>
|
328 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
329 |
<?php
|
330 |
}
|
331 |
|
@@ -593,7 +661,7 @@ function gmediaGalleryEdit(){
|
|
593 |
|
594 |
<p><b><?php _e('Gallery author:', 'gmLang'); ?></b>
|
595 |
<?php if($gmCore->caps['gmedia_delete_others_media']){ ?>
|
596 |
-
<a href="#gallModal" data-modal="
|
597 |
<?php if($author_new){
|
598 |
echo '<br /><span class="text-danger">' . __('Note: Author changed but not saved yet. You can see Albums list only of chosen author') . '</span>';
|
599 |
} ?>
|
@@ -728,22 +796,27 @@ function gmediaGalleryEdit(){
|
|
728 |
<p><b><?php _e('Last edited:'); ?></b> <?php echo $gallery['edited']; ?></p>
|
729 |
<?php if($gallery_id){
|
730 |
$params = array();
|
731 |
-
$params['
|
732 |
$params['iframe'] = 1;
|
733 |
?>
|
734 |
<p><b><?php _e('Gallery ID:'); ?></b> #<?php echo $gallery_id; ?></p>
|
735 |
-
<p><b><?php _e('
|
736 |
-
$
|
|
|
|
|
737 |
if(get_option('permalink_structure')){
|
738 |
-
$
|
739 |
-
$gallery_link = home_url($ep . '/' . $gallery_id);
|
740 |
} else{
|
741 |
$gallery_link = $gallery_link_default;
|
742 |
} ?>
|
743 |
-
<a target="_blank" href="<?php echo $gallery_link; ?>"><?php echo $gallery_link; ?></a>
|
744 |
-
<br/><?php _e('update <a href="options-permalink.php">Permalink Settings</a> if above link not working', 'gmLang'); ?>
|
745 |
</p>
|
746 |
-
|
|
|
|
|
|
|
|
|
|
|
747 |
<div><b><?php _e('Gallery Preview:'); ?></b></div>
|
748 |
<div class="gallery_preview" style="overflow:hidden;">
|
749 |
<iframe id="gallery_preview" name="gallery_preview" src="<?php echo add_query_arg($params, $gallery_link_default); ?>"></iframe>
|
@@ -803,12 +876,15 @@ function gmediaGalleryEdit(){
|
|
803 |
$('[data-watch]', main).each(function(){
|
804 |
var el = $(this);
|
805 |
gmedia_options_conditional_logic(el, 0);
|
806 |
-
el.
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
|
|
|
|
|
|
812 |
});
|
813 |
|
814 |
function gmedia_options_conditional_logic(el, slide){
|
@@ -819,7 +895,7 @@ function gmediaGalleryEdit(){
|
|
819 |
val = '0';
|
820 |
}
|
821 |
$('[data-' + id + ']', main).each(function(){
|
822 |
-
var key = $(this).data
|
823 |
key = key.split(':');
|
824 |
//var hidden = $(this).data('hidden')? parseInt($(this).data('hidden')) : 0;
|
825 |
var hidden = $(this).data('hidden')? $(this).data('hidden') : {};
|
@@ -913,6 +989,7 @@ function gmediaGalleryEdit(){
|
|
913 |
}
|
914 |
}
|
915 |
});
|
|
|
916 |
</script>
|
917 |
</div>
|
918 |
<?php
|
12 |
global $user_ID, $gmDB, $gmCore, $gmGallery, $gmProcessor;
|
13 |
|
14 |
$url = add_query_arg(array('page' => $gmProcessor->page), admin_url('admin.php'));
|
15 |
+
$endpoint = $gmGallery->options['endpoint'];
|
16 |
|
|
|
17 |
$gm_screen_options = get_user_meta($user_ID, 'gm_screen_options', true);
|
18 |
if(!is_array($gm_screen_options)){
|
19 |
$gm_screen_options = array();
|
20 |
}
|
21 |
$gm_screen_options = array_merge($gmGallery->options['gm_screen_options'], $gm_screen_options);
|
22 |
+
$orderby = !empty($gm_screen_options['orderby_gmedia_galleries'])? $gm_screen_options['orderby_gmedia_galleries'] : 'name';
|
23 |
+
$order = !empty($gm_screen_options['sortorder_gmedia_galleries'])? $gm_screen_options['sortorder_gmedia_galleries'] : 'ASC';
|
24 |
+
$per_page = !empty($gm_screen_options['per_page_gmedia_galleries'])? $gm_screen_options['per_page_gmedia_galleries'] : 30;
|
25 |
|
26 |
$filter = ('selected' == $gmCore->_req('filter'))? $gmProcessor->selected_items : null;
|
27 |
$args = array(
|
28 |
+
'orderby' => $gmCore->_get('orderby', $orderby),
|
29 |
+
'order' => $gmCore->_get('order', $order),
|
30 |
'search' => $gmCore->_get('s', ''),
|
31 |
+
'number' => $gmCore->_get('number', $per_page),
|
32 |
'hide_empty' => 0,
|
33 |
'page' => $gmCore->_get('pager', 1),
|
34 |
'include' => $filter
|
161 |
}
|
162 |
|
163 |
if($term->global == $user_ID){
|
164 |
+
$allow_edit = $allow_delete = true;
|
165 |
} else{
|
166 |
+
$allow_edit = $allow_delete = $gmCore->caps['gmedia_edit_others_media'];
|
167 |
}
|
168 |
|
169 |
$is_selected = in_array($term->term_id, $gmProcessor->selected_items)? true : false;
|
177 |
}
|
178 |
}
|
179 |
?>
|
180 |
+
<div class="list-group-item row d-row<?php echo $list_row_class . ($is_selected? ' active-row' : ''); ?>" id="list-item-<?php echo $term->term_id; ?>" data-id="<?php echo $term->term_id; ?>" data-type="<?php echo $term_meta['module']; ?>">
|
181 |
<div class="term_id">#<?php echo $term->term_id; ?></div>
|
182 |
<div class="col-xs-7">
|
183 |
+
<label class="cb_media-object cb_media-object-gallery">
|
184 |
<input name="doaction[]" type="checkbox"<?php echo $is_selected? ' checked="checked"' : ''; ?> data-type="<?php echo $term_meta['module']; ?>" class="hidden" value="<?php echo $term->term_id; ?>"/>
|
185 |
<?php if(!$broken){ ?>
|
186 |
<span class="thumbnail"><img src="<?php echo $module['url'] . '/screenshot.png'; ?>" alt="<?php echo esc_attr($term->name); ?>"/></span>
|
189 |
<?php } ?>
|
190 |
</label>
|
191 |
|
192 |
+
<div class="media-info-body" style="margin-left:150px;">
|
193 |
<p class="media-title">
|
194 |
<?php if($allow_edit){ ?>
|
195 |
<a href="<?php echo add_query_arg(array('edit_gallery' => $term->term_id), $url); ?>"><?php echo esc_html($term->name); ?></a>
|
211 |
</div>
|
212 |
</div>
|
213 |
<div class="col-xs-5">
|
214 |
+
<div class="object-actions gallery-object-actions">
|
215 |
+
<?php
|
216 |
+
/*
|
217 |
+
$filter_icon = '<span class="glyphicon glyphicon-filter"></span>';
|
218 |
+
echo '<a title="' . __('Filter in Gmedia Library', 'gmLang') . '" href="#">'.$filter_icon.'</a>';
|
219 |
+
*/
|
220 |
+
|
221 |
+
$gmedia_hashid = gmedia_hash_id_encode($term->term_id, 'gallery');
|
222 |
+
if(get_option('permalink_structure')){
|
223 |
+
$cloud_link = home_url(urlencode($endpoint) . '/g/' . $gmedia_hashid);
|
224 |
+
} else{
|
225 |
+
$cloud_link = add_query_arg(array("$endpoint" => $gmedia_hashid, 't' => 'g'), home_url('index.php'));
|
226 |
+
}
|
227 |
+
$share_icon = '<span class="glyphicon glyphicon-share"></span>';
|
228 |
+
if ( 'draft' !== $term->status ){
|
229 |
+
echo '<a target="_blank" data-target="#shareModal" data-share="' . $term->term_id . '" class="share-modal" title="' . __('Share', 'gmLang') . '" href="' . $cloud_link . '">'.$share_icon.'</a>';
|
230 |
+
} else{
|
231 |
+
echo "<span class='action-inactive'>$share_icon</span>";
|
232 |
+
}
|
233 |
+
|
234 |
+
$edit_icon = '<span class="glyphicon glyphicon-edit"></span>';
|
235 |
+
if ( $allow_edit ){
|
236 |
+
echo '<a title="' . __('Edit', 'gmLang') . '" href="' . add_query_arg( array( 'edit_gallery' => $term->term_id ), $url ) . '">'.$edit_icon.'</a>';
|
237 |
+
} else{
|
238 |
+
echo "<span class='action-inactive'>$edit_icon</span>";
|
239 |
+
}
|
240 |
+
|
241 |
+
$trash_icon = '<span class="glyphicon glyphicon-trash"></span>';
|
242 |
+
if($allow_delete){
|
243 |
+
echo '<a class="trash-icon" title="' . __('Delete', 'gmLang') . '" href="' . wp_nonce_url(add_query_arg(array(
|
244 |
+
'term' => $taxonomy,
|
245 |
+
'delete' => $term->term_id
|
246 |
+
), $url), 'gmedia_delete') . '" data-confirm="' . __("You are about to permanently delete the selected items.\n\r'Cancel' to stop, 'OK' to delete.", "gmLang") . '">' . $trash_icon . '</a>';
|
247 |
+
} else{
|
248 |
+
echo "<span class='action-inactive'>$trash_icon</span>";
|
249 |
+
}
|
250 |
+
?>
|
251 |
+
</div>
|
252 |
<p class="media-meta">
|
253 |
<span class="label label-default"><?php _e('Module', 'gmLang'); ?>:</span> <?php echo $term_meta['module']; ?>
|
254 |
<br><span class="label label-default"><?php _e('Type', 'gmLang'); ?>:</span> <?php echo $module_info['type']; ?>
|
366 |
</div>
|
367 |
</div>
|
368 |
</div>
|
369 |
+
|
370 |
+
<div class="modal fade gmedia-modal" id="shareModal" tabindex="-1" role="dialog" aria-hidden="true">
|
371 |
+
<div class="modal-dialog">
|
372 |
+
<div class="modal-content">
|
373 |
+
<div class="modal-header">
|
374 |
+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
375 |
+
<h4 class="modal-title"><?php _e('GmediaCloud Page'); ?></h4>
|
376 |
+
</div>
|
377 |
+
<form class="modal-body" method="post" id="shareForm">
|
378 |
+
<div class="form-group">
|
379 |
+
<label><?php _e('Link to page', 'gmLang'); ?></label>
|
380 |
+
<input name="sharelink" type="text" class="form-control sharelink" readonly="readonly" value="" />
|
381 |
+
</div>
|
382 |
+
<div class="form-group">
|
383 |
+
<label><?php _e('Send this link to', 'gmLang'); ?></label>
|
384 |
+
<input name="email" type="email" class="form-control sharetoemail" value="" placeholder="<?php _e('Email', 'gmLang'); ?>" />
|
385 |
+
<textarea name="message" cols="20" rows="3" class="form-control" placeholder="<?php _e('Message (optional)', 'gmLang'); ?>"></textarea>
|
386 |
+
</div>
|
387 |
+
<input type="hidden" name="action" value="gmedia_share_page" />
|
388 |
+
<?php wp_nonce_field( 'share_modal', '_sharenonce' ); ?>
|
389 |
+
</form>
|
390 |
+
<div class="modal-footer">
|
391 |
+
<button type="button" class="btn btn-primary sharebutton" disabled="disabled"><?php _e( 'Send', 'gmLang' ); ?></button>
|
392 |
+
<button type="button" class="btn btn-default" data-dismiss="modal"><?php _e( 'Close', 'gmLang' ); ?></button>
|
393 |
+
</div>
|
394 |
+
</div>
|
395 |
+
</div>
|
396 |
+
</div>
|
397 |
<?php
|
398 |
}
|
399 |
|
661 |
|
662 |
<p><b><?php _e('Gallery author:', 'gmLang'); ?></b>
|
663 |
<?php if($gmCore->caps['gmedia_delete_others_media']){ ?>
|
664 |
+
<a href="#gallModal" data-modal="select_author" data-action="gmedia_get_modal" class="gmedia-modal" title="<?php _e('Click to choose author for gallery', 'gmLang'); ?>"><?php echo $gallery['global']? get_the_author_meta('display_name', $gallery['global']) : __('(no author / shared albums)'); ?></a>
|
665 |
<?php if($author_new){
|
666 |
echo '<br /><span class="text-danger">' . __('Note: Author changed but not saved yet. You can see Albums list only of chosen author') . '</span>';
|
667 |
} ?>
|
796 |
<p><b><?php _e('Last edited:'); ?></b> <?php echo $gallery['edited']; ?></p>
|
797 |
<?php if($gallery_id){
|
798 |
$params = array();
|
799 |
+
$params['set_module'] = ($gallery['module'] != $module_name)? $module_name : false;
|
800 |
$params['iframe'] = 1;
|
801 |
?>
|
802 |
<p><b><?php _e('Gallery ID:'); ?></b> #<?php echo $gallery_id; ?></p>
|
803 |
+
<p><b><?php _e('GmediaCloud page URL for current gallery:'); ?></b> <?php
|
804 |
+
$endpoint = $gmGallery->options['endpoint'];
|
805 |
+
$gmedia_hashid = gmedia_hash_id_encode($gallery_id, 'gallery');
|
806 |
+
$gallery_link_default = add_query_arg(array("$endpoint" => $gmedia_hashid, 't' => 'g'), home_url('index.php'));
|
807 |
if(get_option('permalink_structure')){
|
808 |
+
$gallery_link = home_url(urlencode($endpoint) . '/g/' . $gmedia_hashid);
|
|
|
809 |
} else{
|
810 |
$gallery_link = $gallery_link_default;
|
811 |
} ?>
|
812 |
+
<br/><a target="_blank" href="<?php echo $gallery_link; ?>"><?php echo $gallery_link; ?></a>
|
|
|
813 |
</p>
|
814 |
+
<div class="help-block">
|
815 |
+
<?php _e('update <a href="options-permalink.php">Permalink Settings</a> if above link not working', 'gmLang'); ?>
|
816 |
+
<?php if(current_user_can('manage_options')){
|
817 |
+
echo '<br>' . __('More info about GmediaCloud Pages and GmediaCloud Settings can be found <a href="admin.php?page=GrandMedia_Settings#gmedia_settings_cloud">here</a>', 'gmLang');
|
818 |
+
} ?>
|
819 |
+
</div>
|
820 |
<div><b><?php _e('Gallery Preview:'); ?></b></div>
|
821 |
<div class="gallery_preview" style="overflow:hidden;">
|
822 |
<iframe id="gallery_preview" name="gallery_preview" src="<?php echo add_query_arg($params, $gallery_link_default); ?>"></iframe>
|
876 |
$('[data-watch]', main).each(function(){
|
877 |
var el = $(this);
|
878 |
gmedia_options_conditional_logic(el, 0);
|
879 |
+
var event = el.attr('data-watch');
|
880 |
+
if(event){
|
881 |
+
el.on(event, function(){
|
882 |
+
if('change' == el.attr('data-watch')){
|
883 |
+
$(this).blur().focus();
|
884 |
+
}
|
885 |
+
gmedia_options_conditional_logic($(this), 400);
|
886 |
+
});
|
887 |
+
}
|
888 |
});
|
889 |
|
890 |
function gmedia_options_conditional_logic(el, slide){
|
895 |
val = '0';
|
896 |
}
|
897 |
$('[data-' + id + ']', main).each(function(){
|
898 |
+
var key = $(this).attr('data-'+id);
|
899 |
key = key.split(':');
|
900 |
//var hidden = $(this).data('hidden')? parseInt($(this).data('hidden')) : 0;
|
901 |
var hidden = $(this).data('hidden')? $(this).data('hidden') : {};
|
989 |
}
|
990 |
}
|
991 |
});
|
992 |
+
|
993 |
</script>
|
994 |
</div>
|
995 |
<?php
|
admin/gmedia.php
CHANGED
@@ -12,6 +12,7 @@ function gmediaLib(){
|
|
12 |
global $user_ID, $gmDB, $gmCore, $gmGallery, $gmProcessor;
|
13 |
|
14 |
$url = add_query_arg(array('page' => $gmProcessor->page, 'mode' => $gmProcessor->mode), admin_url('admin.php'));
|
|
|
15 |
|
16 |
$gm_screen_options = get_user_meta($user_ID, 'gm_screen_options', true);
|
17 |
if(!is_array($gm_screen_options)){
|
@@ -71,7 +72,7 @@ function gmediaLib(){
|
|
71 |
}
|
72 |
?>
|
73 |
<?php if(!empty($author)){ ?>
|
74 |
-
<div class="library-author alert alert-info">
|
75 |
<strong><?php _e('Selected Author:', 'gmLang'); ?></strong>
|
76 |
<a href="#libModal" data-modal="filter_authors" data-action="gmedia_get_modal" class="gmedia-modal"><?php echo get_the_author_meta('display_name', $author); ?></a>
|
77 |
</div>
|
@@ -353,9 +354,9 @@ function gmediaLib(){
|
|
353 |
?>
|
354 |
<?php if (!$gmProcessor->mode){
|
355 |
$is_selected = in_array($item->ID, $gmProcessor->selected_items)? true : false; ?>
|
356 |
-
<div class="list-group-item d-row clearfix<?php echo ($is_selected? ' active' : '') . $list_row_class; ?>" id="list-item-<?php echo $item->ID; ?>" data-id="<?php echo $item->ID; ?>" data-type="<?php echo $type[0]; ?>">
|
357 |
<div class="gmedia_id">#<?php echo $item->ID; ?></div>
|
358 |
-
<label class="cb_media-object">
|
359 |
<input name="doaction[]" type="checkbox"<?php echo $is_selected? ' checked="checked"' : ''; ?> data-type="<?php echo $type[0]; ?>" class="hidden" value="<?php echo $item->ID; ?>"/>
|
360 |
<span data-target="<?php echo $item_url; ?>" class="thumbnail">
|
361 |
<?php if(('image' == $type[0])){ ?>
|
@@ -381,7 +382,7 @@ function gmediaLib(){
|
|
381 |
</span>
|
382 |
</label>
|
383 |
|
384 |
-
<div class="
|
385 |
<div class="row" style="margin:0;">
|
386 |
<div class="col-lg-6">
|
387 |
<p class="media-title"><?php echo esc_html($item->title); ?> </p>
|
@@ -429,6 +430,13 @@ function gmediaLib(){
|
|
429 |
}
|
430 |
echo $terms_tag;
|
431 |
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
432 |
</p>
|
433 |
</div>
|
434 |
<div class="col-lg-6">
|
@@ -459,9 +467,18 @@ function gmediaLib(){
|
|
459 |
} else{
|
460 |
echo '—';
|
461 |
} ?></div>
|
|
|
462 |
<p class="media-meta" style="margin:5px 4px;">
|
463 |
<?php $media_action_links = array();
|
464 |
if(($gmCore->caps['gmedia_edit_media'] && ((int) $item->author == get_current_user_id())) || $gmCore->caps['gmedia_edit_others_media']){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
465 |
$media_action_links[] = '<a href="' . admin_url("admin.php?page=GrandMedia&mode=edit&gmedia__in={$item->ID}") . '">' . __('Edit Data', 'gmLang') . '</a>';
|
466 |
}
|
467 |
if('image' == $type[0]){
|
@@ -473,16 +490,28 @@ function gmediaLib(){
|
|
473 |
} elseif(in_array($type[1], array('mp4', 'mp3', 'mpeg', 'webm', 'ogg', 'wave', 'wav'))){
|
474 |
$media_action_links[] = '<a href="' . $item_url . '" data-target="#previewModal" data-width="'.$modal_web_width.'" data-height="'.$modal_web_height.'" class="preview-modal" title="'.esc_attr($item->title).'">' . __('Play', 'gmLang') . '</a>';
|
475 |
}
|
|
|
|
|
|
|
|
|
476 |
if(($gmCore->caps['gmedia_delete_media'] && ((int) $item->author == get_current_user_id())) || $gmCore->caps['gmedia_delete_others_media']){
|
477 |
$media_action_links[] = '<a class="text-danger" href="' . wp_nonce_url($gmCore->get_admin_url(array('delete' => $item->ID)), 'gmedia_delete') . '" data-confirm="' . sprintf(__("You are about to permanently delete %s file.\n\r'Cancel' to stop, 'OK' to delete.", "gmLang"), $item->gmuid) . '">' . __('Delete', 'gmLang') . '</a>';
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
|
|
|
|
482 |
}
|
483 |
echo implode(' | ', $media_action_links);
|
484 |
?>
|
485 |
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
486 |
</div>
|
487 |
</div>
|
488 |
</div>
|
@@ -492,7 +521,7 @@ function gmediaLib(){
|
|
492 |
<?php if(((int) $item->author != $user_ID) && !$gmCore->caps['gmedia_edit_others_media']){ ?>
|
493 |
<div class="list-group-item row d-row" id="list-item-<?php echo $item->ID; ?>" data-id="<?php echo $item->ID; ?>" data-type="<?php echo $type[0]; ?>">
|
494 |
<div class="gmedia_id">#<?php echo $item->ID; ?></div>
|
495 |
-
<div class="li_media-object">
|
496 |
<span data-target="<?php echo $item_url; ?>" class="thumbnail">
|
497 |
<?php if(('image' == $type[0])){ ?>
|
498 |
<img class="gmedia-thumb" src="<?php echo $gmCore->gm_get_media_image($item, 'thumb'); ?>" alt=""/>
|
@@ -517,7 +546,7 @@ function gmediaLib(){
|
|
517 |
</span>
|
518 |
</div>
|
519 |
|
520 |
-
<div class="
|
521 |
<div class="col-md-6">
|
522 |
<p class="media-title"><?php echo esc_html($item->title); ?> </p>
|
523 |
|
@@ -619,25 +648,16 @@ function gmediaLib(){
|
|
619 |
<form class="list-group-item row d-row edit-gmedia" id="list-item-<?php echo $item->ID; ?>" data-id="<?php echo $item->ID; ?>" data-type="<?php echo $type[0]; ?>" role="form">
|
620 |
<div class="col-sm-4" style="max-width:350px;">
|
621 |
<input name="ID" type="hidden" value="<?php echo $item->ID; ?>"/>
|
622 |
-
<?php
|
|
|
623 |
<a href="<?php echo $item_url; ?>" data-target="#previewModal" data-width="<?php echo $modal_web_width; ?>" data-height="<?php echo $modal_web_height; ?>" class="thumbnail preview-modal" title="<?php echo esc_attr($item->title); ?>">
|
624 |
<img class="gmedia-thumb" src="<?php echo $gmCore->gm_get_media_image($item, 'thumb'); ?>" alt=""/>
|
625 |
</a>
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
<?php _e('View Original', 'gmLang'); ?>
|
632 |
-
</a>
|
633 |
-
<?php if(($gmCore->caps['gmedia_delete_media'] && ((int) $item->author == get_current_user_id())) || $gmCore->caps['gmedia_delete_others_media']){ ?>
|
634 |
-
|
|
635 |
-
<a class="btn btn-link btn-sm text-danger" href="<?php echo wp_nonce_url($gmCore->get_admin_url(array('delete' => $item->ID)), 'gmedia_delete') ?>" data-confirm="<?php printf(__("You are about to permanently delete %s file.\n\r'Cancel' to stop, 'OK' to delete.", "gmLang"), $item->gmuid); ?>">
|
636 |
-
<?php _e('Delete', 'gmLang'); ?>
|
637 |
-
</a>
|
638 |
-
<?php } ?>
|
639 |
-
</p>
|
640 |
-
<?php } else{ ?>
|
641 |
<a href="<?php echo $item_url; ?>" data-target="#previewModal" data-width="<?php echo $modal_web_width; ?>" data-height="<?php echo $modal_web_height; ?>" class="thumbnail preview-modal" title="<?php echo esc_attr($item->title); ?>">
|
642 |
<?php $typethumb = false;
|
643 |
if(isset($meta['cover'][0]) && !empty($meta['cover'][0])){
|
@@ -655,16 +675,25 @@ function gmediaLib(){
|
|
655 |
<img class="gmedia-typethumb" src="<?php echo $gmCore->gm_get_media_image($item, 'thumb', false); ?>" alt=""/>
|
656 |
<?php } ?>
|
657 |
</a>
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
668 |
<?php } ?>
|
669 |
</div>
|
670 |
<div class="col-sm-8">
|
@@ -950,7 +979,7 @@ function gmediaLib(){
|
|
950 |
</div>
|
951 |
<?php } ?>
|
952 |
<div class="modal fade gmedia-modal" id="previewModal" tabindex="-1" role="dialog" aria-hidden="true">
|
953 |
-
<div class="modal-dialog
|
954 |
<div class="modal-content">
|
955 |
<div class="modal-header">
|
956 |
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
@@ -960,5 +989,32 @@ function gmediaLib(){
|
|
960 |
</div>
|
961 |
</div>
|
962 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
963 |
<?php
|
964 |
}
|
12 |
global $user_ID, $gmDB, $gmCore, $gmGallery, $gmProcessor;
|
13 |
|
14 |
$url = add_query_arg(array('page' => $gmProcessor->page, 'mode' => $gmProcessor->mode), admin_url('admin.php'));
|
15 |
+
$endpoint = $gmGallery->options['endpoint'];
|
16 |
|
17 |
$gm_screen_options = get_user_meta($user_ID, 'gm_screen_options', true);
|
18 |
if(!is_array($gm_screen_options)){
|
72 |
}
|
73 |
?>
|
74 |
<?php if(!empty($author)){ ?>
|
75 |
+
<div class="library-author alert alert-info" xmlns="http://www.w3.org/1999/html">
|
76 |
<strong><?php _e('Selected Author:', 'gmLang'); ?></strong>
|
77 |
<a href="#libModal" data-modal="filter_authors" data-action="gmedia_get_modal" class="gmedia-modal"><?php echo get_the_author_meta('display_name', $author); ?></a>
|
78 |
</div>
|
354 |
?>
|
355 |
<?php if (!$gmProcessor->mode){
|
356 |
$is_selected = in_array($item->ID, $gmProcessor->selected_items)? true : false; ?>
|
357 |
+
<div class="list-group-item d-row clearfix<?php echo ($is_selected? ' active-row' : '') . $list_row_class; ?>" id="list-item-<?php echo $item->ID; ?>" data-id="<?php echo $item->ID; ?>" data-type="<?php echo $type[0]; ?>">
|
358 |
<div class="gmedia_id">#<?php echo $item->ID; ?></div>
|
359 |
+
<label class="cb_media-object col-sm-4" style="max-width:350px;">
|
360 |
<input name="doaction[]" type="checkbox"<?php echo $is_selected? ' checked="checked"' : ''; ?> data-type="<?php echo $type[0]; ?>" class="hidden" value="<?php echo $item->ID; ?>"/>
|
361 |
<span data-target="<?php echo $item_url; ?>" class="thumbnail">
|
362 |
<?php if(('image' == $type[0])){ ?>
|
382 |
</span>
|
383 |
</label>
|
384 |
|
385 |
+
<div class="col-sm-8">
|
386 |
<div class="row" style="margin:0;">
|
387 |
<div class="col-lg-6">
|
388 |
<p class="media-title"><?php echo esc_html($item->title); ?> </p>
|
430 |
}
|
431 |
echo $terms_tag;
|
432 |
?>
|
433 |
+
|
434 |
+
<br/><span class="label label-default"><?php _e('Views / Likes', 'gmLang'); ?>:</span>
|
435 |
+
<?php echo (isset($meta['views'][0])? $meta['views'][0] : '0') . ' / ' . (isset($meta['likes'][0])? $meta['likes'][0] : '0'); ?>
|
436 |
+
<?php if(isset($meta['rating'][0])){
|
437 |
+
$ratings = maybe_unserialize($meta['rating'][0]); ?>
|
438 |
+
<br/><span class="label label-default"><?php _e('Rating', 'gmLang'); ?>:</span> <?php echo $ratings['value'].' / '.$ratings['votes']; ?>
|
439 |
+
<?php } ?>
|
440 |
</p>
|
441 |
</div>
|
442 |
<div class="col-lg-6">
|
467 |
} else{
|
468 |
echo '—';
|
469 |
} ?></div>
|
470 |
+
|
471 |
<p class="media-meta" style="margin:5px 4px;">
|
472 |
<?php $media_action_links = array();
|
473 |
if(($gmCore->caps['gmedia_edit_media'] && ((int) $item->author == get_current_user_id())) || $gmCore->caps['gmedia_edit_others_media']){
|
474 |
+
$gmedia_hashid = gmedia_hash_id_encode($item->ID, 'single');
|
475 |
+
if(get_option('permalink_structure')){
|
476 |
+
$cloud_link = home_url(urlencode($endpoint) . '/s/' . $gmedia_hashid);
|
477 |
+
} else{
|
478 |
+
$cloud_link = add_query_arg(array("$endpoint" => $gmedia_hashid, 't' => 's'), home_url('index.php'));
|
479 |
+
}
|
480 |
+
$media_action_links[] = '<a target="_blank" data-target="#shareModal" data-share="' . $item->ID . '" class="share-modal" title="'.__('GmediaCloud Page', 'gmLang').'" href="' . $cloud_link . '">' . __('Share', 'gmLang') . '</a>';
|
481 |
+
|
482 |
$media_action_links[] = '<a href="' . admin_url("admin.php?page=GrandMedia&mode=edit&gmedia__in={$item->ID}") . '">' . __('Edit Data', 'gmLang') . '</a>';
|
483 |
}
|
484 |
if('image' == $type[0]){
|
490 |
} elseif(in_array($type[1], array('mp4', 'mp3', 'mpeg', 'webm', 'ogg', 'wave', 'wav'))){
|
491 |
$media_action_links[] = '<a href="' . $item_url . '" data-target="#previewModal" data-width="'.$modal_web_width.'" data-height="'.$modal_web_height.'" class="preview-modal" title="'.esc_attr($item->title).'">' . __('Play', 'gmLang') . '</a>';
|
492 |
}
|
493 |
+
$metainfo = $gmCore->metadata_text($item->ID);
|
494 |
+
if($metainfo){
|
495 |
+
$media_action_links[] = '<a href="#metaInfo" data-target="#previewModal" data-metainfo="' . $item->ID . '" class="preview-modal" title="'.__('Meta Info', 'gmLang').'">' . __('Meta Info', 'gmLang') . '</a>';
|
496 |
+
}
|
497 |
if(($gmCore->caps['gmedia_delete_media'] && ((int) $item->author == get_current_user_id())) || $gmCore->caps['gmedia_delete_others_media']){
|
498 |
$media_action_links[] = '<a class="text-danger" href="' . wp_nonce_url($gmCore->get_admin_url(array('delete' => $item->ID)), 'gmedia_delete') . '" data-confirm="' . sprintf(__("You are about to permanently delete %s file.\n\r'Cancel' to stop, 'OK' to delete.", "gmLang"), $item->gmuid) . '">' . __('Delete', 'gmLang') . '</a>';
|
499 |
+
if($gmCore->_get('showmore')){
|
500 |
+
$media_action_links[] = '<a class="text-danger" href="' . wp_nonce_url($gmCore->get_admin_url(array(
|
501 |
+
'delete' => $item->ID,
|
502 |
+
'save_original_file' => 1
|
503 |
+
)), 'gmedia_delete') . '" data-confirm="' . sprintf(__("You are about to delete record from DB for %s file.\n\r'Cancel' to stop, 'OK' to delete.", "gmLang"), $item->gmuid) . '">' . __('Delete DB record (leave file on the server)', 'gmLang') . '</a>';
|
504 |
+
}
|
505 |
}
|
506 |
echo implode(' | ', $media_action_links);
|
507 |
?>
|
508 |
</p>
|
509 |
+
<?php if($metainfo){ ?>
|
510 |
+
<div class="metainfo hidden" id="metainfo_<?php echo $item->ID; ?>">
|
511 |
+
<?php echo nl2br($metainfo); ?>
|
512 |
+
</div>
|
513 |
+
<?php } ?>
|
514 |
+
|
515 |
</div>
|
516 |
</div>
|
517 |
</div>
|
521 |
<?php if(((int) $item->author != $user_ID) && !$gmCore->caps['gmedia_edit_others_media']){ ?>
|
522 |
<div class="list-group-item row d-row" id="list-item-<?php echo $item->ID; ?>" data-id="<?php echo $item->ID; ?>" data-type="<?php echo $type[0]; ?>">
|
523 |
<div class="gmedia_id">#<?php echo $item->ID; ?></div>
|
524 |
+
<div class="li_media-object col-sm-4" style="max-width:350px;">
|
525 |
<span data-target="<?php echo $item_url; ?>" class="thumbnail">
|
526 |
<?php if(('image' == $type[0])){ ?>
|
527 |
<img class="gmedia-thumb" src="<?php echo $gmCore->gm_get_media_image($item, 'thumb'); ?>" alt=""/>
|
546 |
</span>
|
547 |
</div>
|
548 |
|
549 |
+
<div class="col-sm-8">
|
550 |
<div class="col-md-6">
|
551 |
<p class="media-title"><?php echo esc_html($item->title); ?> </p>
|
552 |
|
648 |
<form class="list-group-item row d-row edit-gmedia" id="list-item-<?php echo $item->ID; ?>" data-id="<?php echo $item->ID; ?>" data-type="<?php echo $type[0]; ?>" role="form">
|
649 |
<div class="col-sm-4" style="max-width:350px;">
|
650 |
<input name="ID" type="hidden" value="<?php echo $item->ID; ?>"/>
|
651 |
+
<?php $media_action_links = array();
|
652 |
+
if(('image' == $type[0])){ ?>
|
653 |
<a href="<?php echo $item_url; ?>" data-target="#previewModal" data-width="<?php echo $modal_web_width; ?>" data-height="<?php echo $modal_web_height; ?>" class="thumbnail preview-modal" title="<?php echo esc_attr($item->title); ?>">
|
654 |
<img class="gmedia-thumb" src="<?php echo $gmCore->gm_get_media_image($item, 'thumb'); ?>" alt=""/>
|
655 |
</a>
|
656 |
+
<?php
|
657 |
+
$media_action_links[] = '<a href="'.admin_url("admin.php?page=GrandMedia&gmediablank=image_editor&id={$item->ID}").'" data-target="#gmeditModal" class="btn btn-link btn-sm gmedit-modal">'.__('Edit Image', 'gmLang').'</a>';
|
658 |
+
$media_action_links[] = '<a href="'.$gmCore->gm_get_media_image($item, 'original').'" data-target="#previewModal" data-width="'.$modal_width.'" data-height="'.$modal_height.'" class="btn btn-link btn-sm preview-modal" title="'.esc_attr($item->title).'">'.__('View Original', 'gmLang').'</a>';
|
659 |
+
|
660 |
+
} else{ ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
661 |
<a href="<?php echo $item_url; ?>" data-target="#previewModal" data-width="<?php echo $modal_web_width; ?>" data-height="<?php echo $modal_web_height; ?>" class="thumbnail preview-modal" title="<?php echo esc_attr($item->title); ?>">
|
662 |
<?php $typethumb = false;
|
663 |
if(isset($meta['cover'][0]) && !empty($meta['cover'][0])){
|
675 |
<img class="gmedia-typethumb" src="<?php echo $gmCore->gm_get_media_image($item, 'thumb', false); ?>" alt=""/>
|
676 |
<?php } ?>
|
677 |
</a>
|
678 |
+
<?php
|
679 |
+
if(in_array($type[1], array('mp4', 'mp3', 'mpeg', 'webm', 'ogg', 'wave', 'wav'))){
|
680 |
+
$media_action_links[] = '<a href="' . $item_url . '" data-target="#previewModal" data-width="' . $modal_width . '" data-height="' . $modal_height . '" class="btn btn-link btn-sm preview-modal" title="' . esc_attr($item->title) . '">' . __('Play', 'gmLang') . '</a>';
|
681 |
+
}
|
682 |
+
}
|
683 |
+
|
684 |
+
$metainfo = $gmCore->metadata_text($item->ID);
|
685 |
+
if($metainfo){
|
686 |
+
$media_action_links[] = '<a href="#metaInfo" data-target="#previewModal" data-metainfo="' . $item->ID . '" class="btn btn-link btn-sm preview-modal" title="'.__('Meta Info', 'gmLang').'">' . __('Meta Info', 'gmLang') . '</a>';
|
687 |
+
}
|
688 |
+
if(($gmCore->caps['gmedia_delete_media'] && ((int) $item->author == get_current_user_id())) || $gmCore->caps['gmedia_delete_others_media']){
|
689 |
+
$media_action_links[] = '<a class="btn btn-link btn-sm text-danger" href="'.wp_nonce_url($gmCore->get_admin_url(array('delete' => $item->ID)), 'gmedia_delete').'" data-confirm="'.sprintf(__("You are about to permanently delete %s file.\n\r'Cancel' to stop, 'OK' to delete.", "gmLang"), $item->gmuid).'">'.__('Delete', 'gmLang').'</a>';
|
690 |
+
}
|
691 |
+
echo '<p>'.implode(' | ', $media_action_links).'</p>';
|
692 |
+
?>
|
693 |
+
<?php if($metainfo){ ?>
|
694 |
+
<div class="metainfo hidden" id="metainfo_<?php echo $item->ID; ?>">
|
695 |
+
<?php echo nl2br($metainfo); ?>
|
696 |
+
</div>
|
697 |
<?php } ?>
|
698 |
</div>
|
699 |
<div class="col-sm-8">
|
979 |
</div>
|
980 |
<?php } ?>
|
981 |
<div class="modal fade gmedia-modal" id="previewModal" tabindex="-1" role="dialog" aria-hidden="true">
|
982 |
+
<div class="modal-dialog">
|
983 |
<div class="modal-content">
|
984 |
<div class="modal-header">
|
985 |
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
989 |
</div>
|
990 |
</div>
|
991 |
</div>
|
992 |
+
<div class="modal fade gmedia-modal" id="shareModal" tabindex="-1" role="dialog" aria-hidden="true">
|
993 |
+
<div class="modal-dialog">
|
994 |
+
<div class="modal-content">
|
995 |
+
<div class="modal-header">
|
996 |
+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
997 |
+
<h4 class="modal-title"><?php _e('GmediaCloud Page'); ?></h4>
|
998 |
+
</div>
|
999 |
+
<form class="modal-body" method="post" id="shareForm">
|
1000 |
+
<div class="form-group">
|
1001 |
+
<label><?php _e('Link to page', 'gmLang'); ?></label>
|
1002 |
+
<input name="sharelink" type="text" class="form-control sharelink" readonly="readonly" value="" />
|
1003 |
+
</div>
|
1004 |
+
<div class="form-group">
|
1005 |
+
<label><?php _e('Send this link to', 'gmLang'); ?></label>
|
1006 |
+
<input name="email" type="email" class="form-control sharetoemail" value="" placeholder="<?php _e('Email', 'gmLang'); ?>" />
|
1007 |
+
<textarea name="message" cols="20" rows="3" class="form-control" placeholder="<?php _e('Message (optional)', 'gmLang'); ?>"></textarea>
|
1008 |
+
</div>
|
1009 |
+
<input type="hidden" name="action" value="gmedia_share_page" />
|
1010 |
+
<?php wp_nonce_field( 'share_modal', '_sharenonce' ); ?>
|
1011 |
+
</form>
|
1012 |
+
<div class="modal-footer">
|
1013 |
+
<button type="button" class="btn btn-primary sharebutton" disabled="disabled"><?php _e( 'Send', 'gmLang' ); ?></button>
|
1014 |
+
<button type="button" class="btn btn-default" data-dismiss="modal"><?php _e( 'Close', 'gmLang' ); ?></button>
|
1015 |
+
</div>
|
1016 |
+
</div>
|
1017 |
+
</div>
|
1018 |
+
</div>
|
1019 |
<?php
|
1020 |
}
|
admin/import.php
DELETED
@@ -1,493 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
ini_set( 'display_errors', 0 );
|
4 |
-
ini_set( 'error_reporting', 0 );
|
5 |
-
ini_set( 'max_execution_time', 600 );
|
6 |
-
/*
|
7 |
-
@apache_setenv('no-gzip', 1);
|
8 |
-
@ini_set('zlib.output_compression', 0);
|
9 |
-
@ini_set('implicit_flush', 1);
|
10 |
-
for ($i = 0; $i < ob_get_level(); $i++) { ob_end_flush(); }
|
11 |
-
ob_implicit_flush(1);
|
12 |
-
*/
|
13 |
-
|
14 |
-
require_once( dirname( dirname( __FILE__ ) ) . '/config.php' );
|
15 |
-
|
16 |
-
/** WordPress Image Administration API */
|
17 |
-
require_once( ABSPATH . 'wp-admin/includes/image.php' );
|
18 |
-
|
19 |
-
// HTTP headers for no cache etc
|
20 |
-
nocache_headers();
|
21 |
-
|
22 |
-
check_admin_referer( 'GmediaImport' );
|
23 |
-
if ( ! current_user_can( 'gmedia_import' ) ) {
|
24 |
-
wp_die( __( 'You do not have permission to upload files.' ) );
|
25 |
-
}
|
26 |
-
|
27 |
-
// 10 minutes execution time
|
28 |
-
@set_time_limit( 10 * 60 );
|
29 |
-
|
30 |
-
// fake upload time
|
31 |
-
usleep( 10 );
|
32 |
-
|
33 |
-
global $gmCore, $gmGallery;
|
34 |
-
|
35 |
-
$import = $gmCore->_post( 'import' );
|
36 |
-
$terms = $gmCore->_post( 'terms', array() );
|
37 |
-
|
38 |
-
/**
|
39 |
-
* @param $files
|
40 |
-
* @param $terms
|
41 |
-
* @param $move
|
42 |
-
* @param int $exists
|
43 |
-
*/
|
44 |
-
function gmedia_import_files( $files, $terms, $move, $exists = 0 ) {
|
45 |
-
global $gmCore, $gmGallery, $gmDB;
|
46 |
-
|
47 |
-
if ( ob_get_level() == 0 ) {
|
48 |
-
ob_start();
|
49 |
-
}
|
50 |
-
$eol = '</pre>' . PHP_EOL;
|
51 |
-
|
52 |
-
$_terms = $terms;
|
53 |
-
|
54 |
-
$gmedia_album = isset( $_terms['gmedia_album'] ) ? $_terms['gmedia_album'] : false;
|
55 |
-
if ( $gmedia_album && $gmCore->is_digit( $gmedia_album ) ) {
|
56 |
-
$album = $gmDB->get_term( $gmedia_album, 'gmedia_album' );
|
57 |
-
if ( empty( $album ) || is_wp_error( $album ) ) {
|
58 |
-
$status = 'public';
|
59 |
-
} else {
|
60 |
-
$status = $album->status;
|
61 |
-
$album_name = $album->name;
|
62 |
-
}
|
63 |
-
} else {
|
64 |
-
$status = 'public';
|
65 |
-
}
|
66 |
-
|
67 |
-
$c = count( $files );
|
68 |
-
$i = 0;
|
69 |
-
foreach ( $files as $file ) {
|
70 |
-
|
71 |
-
if ( is_array( $file ) ) {
|
72 |
-
if ( isset( $file['file'] ) ) {
|
73 |
-
extract( $file );
|
74 |
-
} else {
|
75 |
-
_e( 'Something went wrong...', 'gmLang' );
|
76 |
-
die();
|
77 |
-
}
|
78 |
-
}
|
79 |
-
|
80 |
-
wp_ob_end_flush_all();
|
81 |
-
flush();
|
82 |
-
|
83 |
-
$i ++;
|
84 |
-
$prefix = "\n<pre>$i/$c - ";
|
85 |
-
$prefix_ko = "\n<pre class='ko'>$i/$c - ";
|
86 |
-
|
87 |
-
if ( ! is_file( $file ) ) {
|
88 |
-
echo $prefix_ko . sprintf( __( 'File not exists: %s', 'gmLang' ), $file ) . $eol;
|
89 |
-
continue;
|
90 |
-
}
|
91 |
-
|
92 |
-
|
93 |
-
$fileinfo = $gmCore->fileinfo( $file, $exists );
|
94 |
-
|
95 |
-
// try to make grand-media dir if not exists
|
96 |
-
if ( ! wp_mkdir_p( $fileinfo['dirpath'] ) ) {
|
97 |
-
echo $prefix_ko . sprintf( __( 'Unable to create directory `%s`. Is its parent directory writable by the server?', 'gmLang' ), $fileinfo['dirpath'] ) . $eol;
|
98 |
-
continue;
|
99 |
-
}
|
100 |
-
// Check if grand-media dir is writable
|
101 |
-
if ( ! is_writable( $fileinfo['dirpath'] ) ) {
|
102 |
-
@chmod( $fileinfo['dirpath'], 0755 );
|
103 |
-
if ( ! is_writable( $fileinfo['dirpath'] ) ) {
|
104 |
-
echo $prefix_ko . sprintf( __( 'Directory `%s` or its subfolders are not writable by the server.', 'gmLang' ), dirname( $fileinfo['dirpath'] ) ) . $eol;
|
105 |
-
continue;
|
106 |
-
}
|
107 |
-
}
|
108 |
-
|
109 |
-
if ( ! copy( $file, $fileinfo['filepath'] ) ) {
|
110 |
-
echo $prefix_ko . sprintf( __( "Can't copy file from `%s` to `%s`", 'gmLang' ), $file, $fileinfo['filepath'] ) . $eol;
|
111 |
-
continue;
|
112 |
-
}
|
113 |
-
|
114 |
-
$gmCore->file_chmod( $fileinfo['filepath'] );
|
115 |
-
|
116 |
-
$size = false;
|
117 |
-
$is_webimage = false;
|
118 |
-
if ( 'image' == $fileinfo['dirname'] ) {
|
119 |
-
$size = @getimagesize( $fileinfo['filepath'] );
|
120 |
-
if ( $size && file_is_displayable_image( $fileinfo['filepath'] ) ) {
|
121 |
-
if ( function_exists( 'memory_get_usage' ) ) {
|
122 |
-
$extensions = array( '1' => 'GIF', '2' => 'JPG', '3' => 'PNG', '6' => 'BMP' );
|
123 |
-
switch ( $extensions[ $size[2] ] ) {
|
124 |
-
case 'GIF':
|
125 |
-
$CHANNEL = 1;
|
126 |
-
break;
|
127 |
-
case 'JPG':
|
128 |
-
$CHANNEL = $size['channels'];
|
129 |
-
break;
|
130 |
-
case 'PNG':
|
131 |
-
$CHANNEL = 3;
|
132 |
-
break;
|
133 |
-
case 'BMP':
|
134 |
-
default:
|
135 |
-
$CHANNEL = 6;
|
136 |
-
break;
|
137 |
-
}
|
138 |
-
$MB = 1048576; // number of bytes in 1M
|
139 |
-
$K64 = 65536; // number of bytes in 64K
|
140 |
-
$TWEAKFACTOR = 1.8; // Or whatever works for you
|
141 |
-
$memoryNeeded = round( ( $size[0] * $size[1] * $size['bits'] * $CHANNEL / 8 + $K64 ) * $TWEAKFACTOR );
|
142 |
-
$memoryNeeded = memory_get_usage() + $memoryNeeded;
|
143 |
-
$current_limit = @ini_get( 'memory_limit' );
|
144 |
-
$current_limit_int = intval( $current_limit );
|
145 |
-
if ( false !== strpos( $current_limit, 'M' ) ) {
|
146 |
-
$current_limit_int *= $MB;
|
147 |
-
}
|
148 |
-
if ( false !== strpos( $current_limit, 'G' ) ) {
|
149 |
-
$current_limit_int *= 1024;
|
150 |
-
}
|
151 |
-
|
152 |
-
if ( - 1 != $current_limit && $memoryNeeded > $current_limit_int ) {
|
153 |
-
$newLimit = $current_limit_int / $MB + ceil( ( $memoryNeeded - $current_limit_int ) / $MB );
|
154 |
-
@ini_set( 'memory_limit', $newLimit . 'M' );
|
155 |
-
}
|
156 |
-
}
|
157 |
-
|
158 |
-
if ( ! wp_mkdir_p( $fileinfo['dirpath_thumb'] ) ) {
|
159 |
-
echo $prefix_ko . sprintf( __( 'Unable to create directory `%s`. Is its parent directory writable by the server?', 'gmLang' ), $fileinfo['dirpath_thumb'] ) . $eol;
|
160 |
-
continue;
|
161 |
-
}
|
162 |
-
if ( ! is_writable( $fileinfo['dirpath_thumb'] ) ) {
|
163 |
-
@chmod( $fileinfo['dirpath_thumb'], 0755 );
|
164 |
-
if ( ! is_writable( $fileinfo['dirpath_thumb'] ) ) {
|
165 |
-
@unlink( $fileinfo['filepath'] );
|
166 |
-
echo $prefix_ko . sprintf( __( 'Directory `%s` is not writable by the server.', 'gmLang' ), $fileinfo['dirpath_thumb'] ) . $eol;
|
167 |
-
continue;
|
168 |
-
}
|
169 |
-
}
|
170 |
-
if ( ! wp_mkdir_p( $fileinfo['dirpath_original'] ) ) {
|
171 |
-
echo $prefix_ko . sprintf( __( 'Unable to create directory `%s`. Is its parent directory writable by the server?', 'gmLang' ), $fileinfo['dirpath_original'] ) . $eol;
|
172 |
-
continue;
|
173 |
-
}
|
174 |
-
if ( ! is_writable( $fileinfo['dirpath_original'] ) ) {
|
175 |
-
@chmod( $fileinfo['dirpath_original'], 0755 );
|
176 |
-
if ( ! is_writable( $fileinfo['dirpath_original'] ) ) {
|
177 |
-
@unlink( $fileinfo['filepath'] );
|
178 |
-
echo $prefix_ko . sprintf( __( 'Directory `%s` is not writable by the server.', 'gmLang' ), $fileinfo['dirpath_original'] ) . $eol;
|
179 |
-
continue;
|
180 |
-
}
|
181 |
-
}
|
182 |
-
|
183 |
-
// Optimized image
|
184 |
-
$webimg = $gmGallery->options['image'];
|
185 |
-
$thumbimg = $gmGallery->options['thumb'];
|
186 |
-
|
187 |
-
$webimg['resize'] = ( ( $webimg['width'] < $size[0] ) || ( $webimg['height'] < $size[1] ) ) ? true : false;
|
188 |
-
$thumbimg['resize'] = ( ( $thumbimg['width'] < $size[0] ) || ( $thumbimg['height'] < $size[1] ) ) ? true : false;
|
189 |
-
|
190 |
-
if ( $webimg['resize'] ) {
|
191 |
-
rename( $fileinfo['filepath'], $fileinfo['filepath_original'] );
|
192 |
-
} else {
|
193 |
-
copy( $fileinfo['filepath'], $fileinfo['filepath_original'] );
|
194 |
-
}
|
195 |
-
if ( $webimg['resize'] || $thumbimg['resize'] ) {
|
196 |
-
$editor = wp_get_image_editor( $fileinfo['filepath_original'] );
|
197 |
-
if ( is_wp_error( $editor ) ) {
|
198 |
-
@unlink( $fileinfo['filepath_original'] );
|
199 |
-
echo $prefix_ko . $fileinfo['basename'] . " (wp_get_image_editor): " . $editor->get_error_message() . $eol;
|
200 |
-
continue;
|
201 |
-
}
|
202 |
-
|
203 |
-
if ( $webimg['resize'] ) {
|
204 |
-
$editor->set_quality( $webimg['quality'] );
|
205 |
-
|
206 |
-
$resized = $editor->resize( $webimg['width'], $webimg['height'], $webimg['crop'] );
|
207 |
-
if ( is_wp_error( $resized ) ) {
|
208 |
-
@unlink( $fileinfo['filepath_original'] );
|
209 |
-
echo $prefix_ko . $fileinfo['basename'] . " (" . $resized->get_error_code() . " | editor->resize->webimage({$webimg['width']}, {$webimg['height']}, {$webimg['crop']})): " . $resized->get_error_message() . $eol;
|
210 |
-
continue;
|
211 |
-
}
|
212 |
-
|
213 |
-
$saved = $editor->save( $fileinfo['filepath'] );
|
214 |
-
if ( is_wp_error( $saved ) ) {
|
215 |
-
@unlink( $fileinfo['filepath_original'] );
|
216 |
-
echo $prefix_ko . $fileinfo['basename'] . " (" . $saved->get_error_code() . " | editor->save->webimage): " . $saved->get_error_message() . $eol;
|
217 |
-
continue;
|
218 |
-
}
|
219 |
-
}
|
220 |
-
|
221 |
-
// Thumbnail
|
222 |
-
$editor->set_quality( $thumbimg['quality'] );
|
223 |
-
|
224 |
-
$resized = $editor->resize( $thumbimg['width'], $thumbimg['height'], $thumbimg['crop'] );
|
225 |
-
if ( is_wp_error( $resized ) ) {
|
226 |
-
@unlink( $fileinfo['filepath'] );
|
227 |
-
@unlink( $fileinfo['filepath_original'] );
|
228 |
-
echo $prefix_ko . $fileinfo['basename'] . " (" . $resized->get_error_code() . " | editor->resize->thumb({$thumbimg['width']}, {$thumbimg['height']}, {$thumbimg['crop']})): " . $resized->get_error_message() . $eol;
|
229 |
-
continue;
|
230 |
-
}
|
231 |
-
|
232 |
-
$saved = $editor->save( $fileinfo['filepath_thumb'] );
|
233 |
-
if ( is_wp_error( $saved ) ) {
|
234 |
-
@unlink( $fileinfo['filepath'] );
|
235 |
-
@unlink( $fileinfo['filepath_original'] );
|
236 |
-
echo $prefix_ko . $fileinfo['basename'] . " (" . $saved->get_error_code() . " | editor->save->thumb): " . $saved->get_error_message() . $eol;
|
237 |
-
continue;
|
238 |
-
}
|
239 |
-
} else {
|
240 |
-
copy( $fileinfo['filepath'], $fileinfo['filepath_thumb'] );
|
241 |
-
}
|
242 |
-
$is_webimage = true;
|
243 |
-
} else {
|
244 |
-
@unlink( $fileinfo['filepath'] );
|
245 |
-
echo $prefix_ko . $fileinfo['basename'] . ": " . __( "Could not read image size. Invalid image was deleted.", 'gmLang' ) . $eol;
|
246 |
-
continue;
|
247 |
-
}
|
248 |
-
}
|
249 |
-
|
250 |
-
// Write media data to DB
|
251 |
-
// TODO Option to set title empty string or from metadata or from filename or both
|
252 |
-
// use image exif/iptc data for title and caption defaults if possible
|
253 |
-
if ( $size && ! isset( $title ) && ! isset( $description ) ) {
|
254 |
-
$image_meta = @wp_read_image_metadata( $fileinfo['filepath_original'] );
|
255 |
-
if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) {
|
256 |
-
$title = $image_meta['title'];
|
257 |
-
}
|
258 |
-
if ( trim( $image_meta['caption'] ) ) {
|
259 |
-
$description = $image_meta['caption'];
|
260 |
-
}
|
261 |
-
}
|
262 |
-
if ( ! isset( $title ) || empty( $title ) ) {
|
263 |
-
$title = $fileinfo['title'];
|
264 |
-
}
|
265 |
-
if ( ! isset( $description ) ) {
|
266 |
-
$description = '';
|
267 |
-
}
|
268 |
-
if ( ! isset( $link ) ) {
|
269 |
-
$link = '';
|
270 |
-
}
|
271 |
-
|
272 |
-
if ( ! $is_webimage ) {
|
273 |
-
unset( $_terms['gmedia_category'] );
|
274 |
-
}
|
275 |
-
|
276 |
-
// Construct the media_data array
|
277 |
-
$media_data = array(
|
278 |
-
'mime_type' => $fileinfo['mime_type'],
|
279 |
-
'gmuid' => $fileinfo['basename'],
|
280 |
-
'title' => $title,
|
281 |
-
'link' => $link,
|
282 |
-
'description' => $description,
|
283 |
-
'status' => $status,
|
284 |
-
'terms' => $_terms
|
285 |
-
);
|
286 |
-
if ( ! current_user_can( 'gmedia_delete_others_media' ) ) {
|
287 |
-
$media_data['author'] = get_current_user_id();
|
288 |
-
}
|
289 |
-
|
290 |
-
unset( $title, $description );
|
291 |
-
|
292 |
-
// Save the data
|
293 |
-
$id = $gmDB->insert_gmedia( $media_data );
|
294 |
-
$gmDB->update_metadata( $meta_type = 'gmedia', $id, $meta_key = '_metadata', $gmDB->generate_gmedia_metadata( $id, $fileinfo ) );
|
295 |
-
|
296 |
-
echo $prefix . $fileinfo['basename'] . ': <span class="ok">' . sprintf( __( 'success (ID #%s)', 'gmLang' ), $id ) . '</span>' . $eol;
|
297 |
-
|
298 |
-
if ( $move ) {
|
299 |
-
@unlink( $file );
|
300 |
-
}
|
301 |
-
|
302 |
-
}
|
303 |
-
|
304 |
-
echo '<p><b>' . __( 'Category' ) . ':</b> ' . ( ( isset( $terms['gmedia_category'] ) && ! empty( $terms['gmedia_category'] ) ) ? esc_html( $gmGallery->options['taxonomies']['gmedia_category'][ $terms['gmedia_category'] ] ) : '-' ) . PHP_EOL;
|
305 |
-
echo '<br /><b>' . __( 'Album' ) . ':</b> ' . ( ( isset( $terms['gmedia_album'] ) && ! empty( $terms['gmedia_album'] ) ) ? ( isset($album_name)? $album_name : esc_html( $terms['gmedia_album'] ) ) : '-' ) . PHP_EOL;
|
306 |
-
echo '<br /><b>' . __( 'Tags' ) . ':</b> ' . ( ( isset( $terms['gmedia_tag'] ) && ! empty( $terms['gmedia_tag'] ) ) ? esc_html( str_replace( ',', ', ', $terms['gmedia_tag'] ) ) : '-' ) . '</p>' . PHP_EOL;
|
307 |
-
|
308 |
-
wp_ob_end_flush_all();
|
309 |
-
flush();
|
310 |
-
}
|
311 |
-
|
312 |
-
if ( ob_get_level() == 0 ) {
|
313 |
-
ob_start();
|
314 |
-
}
|
315 |
-
echo str_pad( ' ', 4096 ) . PHP_EOL;
|
316 |
-
wp_ob_end_flush_all();
|
317 |
-
flush();
|
318 |
-
?>
|
319 |
-
<html>
|
320 |
-
<style type="text/css">
|
321 |
-
* {
|
322 |
-
margin: 0;
|
323 |
-
padding: 0;
|
324 |
-
}
|
325 |
-
|
326 |
-
pre {
|
327 |
-
display: block;
|
328 |
-
}
|
329 |
-
|
330 |
-
p {
|
331 |
-
padding: 10px 0;
|
332 |
-
font-size: 14px;
|
333 |
-
}
|
334 |
-
|
335 |
-
.ok {
|
336 |
-
color: darkgreen;
|
337 |
-
}
|
338 |
-
|
339 |
-
.ko {
|
340 |
-
color: darkred;
|
341 |
-
}
|
342 |
-
</style>
|
343 |
-
<body>
|
344 |
-
<?php
|
345 |
-
if ( 'import-folder' == $import ) {
|
346 |
-
|
347 |
-
$path = $gmCore->_post( 'path' );
|
348 |
-
echo '<h4 style="margin: 0 0 10px">' . __( 'Import Server Folder' ) . " `$path`:</h4>" . PHP_EOL;
|
349 |
-
|
350 |
-
if ( $path ) {
|
351 |
-
$path = trim( urldecode( $path ), '/' );
|
352 |
-
if ( ! empty( $path ) ) {
|
353 |
-
$fullpath = ABSPATH . trailingslashit( $path );
|
354 |
-
$files = glob( $fullpath . '?*.?*', GLOB_NOSORT );
|
355 |
-
if ( ! empty( $files ) ) {
|
356 |
-
$allowed_ext = get_allowed_mime_types();
|
357 |
-
$allowed_ext = array_keys( $allowed_ext );
|
358 |
-
$allowed_ext = implode( '|', $allowed_ext );
|
359 |
-
$allowed_ext = explode( '|', $allowed_ext );
|
360 |
-
if ( ( GMEDIA_UPLOAD_FOLDER == basename( dirname( dirname( $path ) ) ) ) || ( GMEDIA_UPLOAD_FOLDER == basename( dirname( $path ) ) ) ) {
|
361 |
-
global $wpdb;
|
362 |
-
$gmedias = $wpdb->get_col( "SELECT gmuid FROM {$wpdb->prefix}gmedia" );
|
363 |
-
foreach ( $files as $i => $filepath ) {
|
364 |
-
$gmuid = basename( $filepath );
|
365 |
-
if ( in_array( $gmuid, $gmedias ) ) {
|
366 |
-
$fileinfo = $gmCore->fileinfo( $gmuid, false );
|
367 |
-
if ( ! ( ( 'image' == $fileinfo['dirname'] ) && ! file_exists( $fileinfo['filepath'] ) ) ) {
|
368 |
-
unset( $files[ $i ] );
|
369 |
-
}
|
370 |
-
}
|
371 |
-
}
|
372 |
-
$move = false;
|
373 |
-
$exists = false;
|
374 |
-
} else {
|
375 |
-
$move = $gmCore->_post( 'delete_source' );
|
376 |
-
$exists = 0;
|
377 |
-
}
|
378 |
-
foreach ( $files as $i => $filepath ) {
|
379 |
-
$ext = pathinfo( $filepath, PATHINFO_EXTENSION );
|
380 |
-
if ( ! in_array( strtolower($ext), $allowed_ext ) ) {
|
381 |
-
unset( $files[ $i ] );
|
382 |
-
}
|
383 |
-
}
|
384 |
-
gmedia_import_files( $files, $terms, $move, $exists );
|
385 |
-
} else {
|
386 |
-
echo sprintf( __( 'Folder `%s` is empty', 'gmLang' ), $path ) . PHP_EOL;
|
387 |
-
}
|
388 |
-
} else {
|
389 |
-
echo __( 'No folder chosen', 'gmLang' ) . PHP_EOL;
|
390 |
-
}
|
391 |
-
}
|
392 |
-
} elseif ( 'import-flagallery' == $import ) {
|
393 |
-
|
394 |
-
echo '<h4 style="margin: 0 0 10px">' . __( 'Import from Flagallery plugin' ) . ":</h4>" . PHP_EOL;
|
395 |
-
|
396 |
-
$gallery = $gmCore->_post( 'gallery' );
|
397 |
-
if ( ! empty( $gallery ) ) {
|
398 |
-
global $wpdb, $gmDB;
|
399 |
-
|
400 |
-
$album = ( ! isset( $terms['gmedia_album'] ) || empty( $terms['gmedia_album'] ) ) ? false : true;
|
401 |
-
foreach ( $gallery as $gid ) {
|
402 |
-
$flag_gallery = $wpdb->get_row( $wpdb->prepare( "SELECT gid, path, title, galdesc FROM `{$wpdb->prefix}flag_gallery` WHERE gid = %d", $gid ), ARRAY_A );
|
403 |
-
if ( empty( $flag_gallery ) ) {
|
404 |
-
continue;
|
405 |
-
}
|
406 |
-
|
407 |
-
if ( ! $album ) {
|
408 |
-
$terms['gmedia_album'] = $flag_gallery['title'];
|
409 |
-
if ( ! $gmDB->term_exists( $flag_gallery['title'], 'gmedia_album' ) ) {
|
410 |
-
$term_id = $gmDB->insert_term( $flag_gallery['title'], 'gmedia_album', array( 'description' => htmlspecialchars_decode( stripslashes( $flag_gallery['galdesc'] ) ) ) );
|
411 |
-
}
|
412 |
-
}
|
413 |
-
|
414 |
-
$path = ABSPATH . trailingslashit( $flag_gallery['path'] );
|
415 |
-
|
416 |
-
echo '<h5 style="margin: 10px 0 5px">' . sprintf( __( 'Import `%s` gallery', 'gmLang' ), $flag_gallery['title'] ) . ":</h5>" . PHP_EOL;
|
417 |
-
|
418 |
-
$flag_pictures = $wpdb->get_results( $wpdb->prepare( "SELECT CONCAT('%s', filename) AS file, description, alttext AS title, link FROM `{$wpdb->prefix}flag_pictures` WHERE galleryid = %d", $path, $flag_gallery['gid'] ), ARRAY_A );
|
419 |
-
if ( empty( $flag_pictures ) ) {
|
420 |
-
echo '<pre>' . __( 'gallery contains 0 images', 'gmLang' ) . '</pre>';
|
421 |
-
continue;
|
422 |
-
}
|
423 |
-
//echo '<pre>'.print_r($flag_pictures, true).'</pre>';
|
424 |
-
gmedia_import_files( $flag_pictures, $terms, false );
|
425 |
-
}
|
426 |
-
} else {
|
427 |
-
echo __( 'No gallery chosen', 'gmLang' ) . PHP_EOL;
|
428 |
-
}
|
429 |
-
} elseif ( 'import-nextgen' == $import ) {
|
430 |
-
|
431 |
-
echo '<h4 style="margin: 0 0 10px">' . __( 'Import from NextGen plugin' ) . ":</h4>" . PHP_EOL;
|
432 |
-
|
433 |
-
$gallery = $gmCore->_post( 'gallery' );
|
434 |
-
if ( ! empty( $gallery ) ) {
|
435 |
-
global $wpdb, $gmDB;
|
436 |
-
|
437 |
-
$album = ( ! isset( $terms['gmedia_album'] ) || empty( $terms['gmedia_album'] ) ) ? false : true;
|
438 |
-
foreach ( $gallery as $gid ) {
|
439 |
-
$ngg_gallery = $wpdb->get_row( $wpdb->prepare( "SELECT gid, path, title, galdesc FROM `{$wpdb->prefix}ngg_gallery` WHERE gid = %d", $gid ), ARRAY_A );
|
440 |
-
if ( empty( $ngg_gallery ) ) {
|
441 |
-
continue;
|
442 |
-
}
|
443 |
-
|
444 |
-
if ( ! $album ) {
|
445 |
-
$terms['gmedia_album'] = $ngg_gallery['title'];
|
446 |
-
if ( ! $gmDB->term_exists( $ngg_gallery['title'], 'gmedia_album' ) ) {
|
447 |
-
$term_id = $gmDB->insert_term( $ngg_gallery['title'], 'gmedia_album', array( 'description' => htmlspecialchars_decode( stripslashes( $ngg_gallery['galdesc'] ) ) ) );
|
448 |
-
}
|
449 |
-
}
|
450 |
-
|
451 |
-
$path = ABSPATH . trailingslashit( $ngg_gallery['path'] );
|
452 |
-
|
453 |
-
echo '<h5 style="margin: 10px 0 5px">' . sprintf( __( 'Import `%s` gallery', 'gmLang' ), $ngg_gallery['title'] ) . ":</h5>" . PHP_EOL;
|
454 |
-
|
455 |
-
$ngg_pictures = $wpdb->get_results( $wpdb->prepare( "SELECT CONCAT('%s', filename) AS file, description, alttext AS title FROM `{$wpdb->prefix}ngg_pictures` WHERE galleryid = %d", $path, $ngg_gallery['gid'] ), ARRAY_A );
|
456 |
-
if ( empty( $ngg_pictures ) ) {
|
457 |
-
echo '<pre>' . __( 'gallery contains 0 images', 'gmLang' ) . '</pre>';
|
458 |
-
continue;
|
459 |
-
}
|
460 |
-
gmedia_import_files( $ngg_pictures, $terms, false );
|
461 |
-
}
|
462 |
-
} else {
|
463 |
-
echo __( 'No gallery chosen', 'gmLang' ) . PHP_EOL;
|
464 |
-
}
|
465 |
-
} elseif ( 'import-wpmedia' == $import ) {
|
466 |
-
global $user_ID, $gmDB;
|
467 |
-
|
468 |
-
echo '<h4 style="margin: 0 0 10px">' . __( 'Import from WP Media Library' ) . ":</h4>" . PHP_EOL;
|
469 |
-
|
470 |
-
$wpMediaLib = $gmDB->get_wp_media_lib( array( 'filter' => 'selected', 'selected' => $gmCore->_post( 'selected' ) ) );
|
471 |
-
|
472 |
-
if ( ! empty( $wpMediaLib ) ) {
|
473 |
-
|
474 |
-
$wp_media = array();
|
475 |
-
foreach ( $wpMediaLib as $item ) {
|
476 |
-
$wp_media[] = array(
|
477 |
-
'file' => get_attached_file( $item->ID ),
|
478 |
-
'title' => $item->post_title,
|
479 |
-
'description' => $item->post_content
|
480 |
-
);
|
481 |
-
}
|
482 |
-
//echo '<pre>' . print_r($wp_media, true) . '</pre>';
|
483 |
-
gmedia_import_files( $wp_media, $terms, false );
|
484 |
-
|
485 |
-
} else {
|
486 |
-
echo __( 'No items chosen', 'gmLang' ) . PHP_EOL;
|
487 |
-
}
|
488 |
-
}
|
489 |
-
?>
|
490 |
-
</body>
|
491 |
-
</html>
|
492 |
-
<?php
|
493 |
-
wp_ob_end_flush_all();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/js/grand-media.js
CHANGED
@@ -66,12 +66,12 @@ jQuery(function($){
|
|
66 |
chk_all: function(type, obj){
|
67 |
$('.' + obj + ' input').filter(function(){
|
68 |
return type? $(this).data('type') == type : true;
|
69 |
-
}).prop('checked', true).closest('div.list-group-item').addClass('active');
|
70 |
},
|
71 |
chk_none: function(type, obj){
|
72 |
$('.' + obj + ' input').filter(function(){
|
73 |
return type? $(this).data('type') == type : true;
|
74 |
-
}).prop('checked', false).closest('div.list-group-item').removeClass('active');
|
75 |
},
|
76 |
chk_toggle: function(type, obj){
|
77 |
if(type){
|
@@ -84,7 +84,7 @@ jQuery(function($){
|
|
84 |
}
|
85 |
} else{
|
86 |
$('.' + obj + ' input').each(function(){
|
87 |
-
$(this).prop("checked", !$(this).prop("checked")).closest('div.list-group-item').toggleClass('active');
|
88 |
});
|
89 |
}
|
90 |
},
|
@@ -148,7 +148,7 @@ jQuery(function($){
|
|
148 |
return a != cur;
|
149 |
}).join(',');
|
150 |
}
|
151 |
-
$('#list-item-' + cur).toggleClass('active');
|
152 |
$('#gm-selected').val(arr);
|
153 |
GmediaSelect.msg_selected(cb_obj);
|
154 |
});
|
@@ -157,6 +157,7 @@ jQuery(function($){
|
|
157 |
if(!$('#gm-list-table').data('edit')){
|
158 |
var cb = $('input:checkbox', this);
|
159 |
cb.prop("checked", !cb.prop("checked")).change();
|
|
|
160 |
} else{
|
161 |
$('#gm-list-table').data('edit', false);
|
162 |
}
|
@@ -208,7 +209,8 @@ jQuery(function($){
|
|
208 |
$('.modal-dialog', modal_div).html(data);
|
209 |
modal_div.modal({
|
210 |
backdrop: 'static',
|
211 |
-
show: true
|
|
|
212 |
}).on('hidden.bs.modal', function(e){
|
213 |
$('.modal-dialog', this).empty();
|
214 |
});
|
@@ -231,7 +233,8 @@ jQuery(function($){
|
|
231 |
);
|
232 |
modal_div.modal({
|
233 |
backdrop: true,
|
234 |
-
show: true
|
|
|
235 |
}).on('hidden.bs.modal', function(e){
|
236 |
$('.modal-content', this).empty();
|
237 |
});
|
@@ -242,26 +245,78 @@ jQuery(function($){
|
|
242 |
var data = $(this).data(),
|
243 |
modal_div = $(data['target']);
|
244 |
$('.modal-title', modal_div).text($(this).attr('title'));
|
245 |
-
|
246 |
-
|
247 |
-
$('
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
259 |
modal_div.modal({
|
260 |
backdrop: true,
|
261 |
show: true
|
262 |
}).on('hidden.bs.modal', function(e){
|
263 |
$('.modal-title', this).empty();
|
264 |
$('.modal-body', this).empty();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
265 |
});
|
266 |
});
|
267 |
|
@@ -298,7 +353,8 @@ jQuery(function($){
|
|
298 |
$('#import-action').val($(this).attr('name'));
|
299 |
$('#importModal').modal({
|
300 |
backdrop: 'static',
|
301 |
-
show: true
|
|
|
302 |
}).on('shown.bs.modal',function(){
|
303 |
$('#import_form').submit();
|
304 |
}).on('hidden.bs.modal', function(){
|
@@ -324,11 +380,17 @@ jQuery(function($){
|
|
324 |
});
|
325 |
});
|
326 |
|
327 |
-
$('form').on('keydown', 'input
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
332 |
}
|
333 |
e.preventDefault();
|
334 |
return false;
|
@@ -398,6 +460,10 @@ jQuery(function($){
|
|
398 |
|
399 |
});
|
400 |
|
|
|
|
|
|
|
|
|
401 |
|
402 |
function getStorage(keyPprefix){
|
403 |
// use document.cookie:
|
66 |
chk_all: function(type, obj){
|
67 |
$('.' + obj + ' input').filter(function(){
|
68 |
return type? $(this).data('type') == type : true;
|
69 |
+
}).prop('checked', true).closest('div.list-group-item').addClass('active-row');
|
70 |
},
|
71 |
chk_none: function(type, obj){
|
72 |
$('.' + obj + ' input').filter(function(){
|
73 |
return type? $(this).data('type') == type : true;
|
74 |
+
}).prop('checked', false).closest('div.list-group-item').removeClass('active-row');
|
75 |
},
|
76 |
chk_toggle: function(type, obj){
|
77 |
if(type){
|
84 |
}
|
85 |
} else{
|
86 |
$('.' + obj + ' input').each(function(){
|
87 |
+
$(this).prop("checked", !$(this).prop("checked")).closest('div.list-group-item').toggleClass('active-row');
|
88 |
});
|
89 |
}
|
90 |
},
|
148 |
return a != cur;
|
149 |
}).join(',');
|
150 |
}
|
151 |
+
$('#list-item-' + cur).toggleClass('active-row');
|
152 |
$('#gm-selected').val(arr);
|
153 |
GmediaSelect.msg_selected(cb_obj);
|
154 |
});
|
157 |
if(!$('#gm-list-table').data('edit')){
|
158 |
var cb = $('input:checkbox', this);
|
159 |
cb.prop("checked", !cb.prop("checked")).change();
|
160 |
+
$(this).closest('.term-list-item').toggleClass('active-row');
|
161 |
} else{
|
162 |
$('#gm-list-table').data('edit', false);
|
163 |
}
|
209 |
$('.modal-dialog', modal_div).html(data);
|
210 |
modal_div.modal({
|
211 |
backdrop: 'static',
|
212 |
+
show: true,
|
213 |
+
keyboard: false
|
214 |
}).on('hidden.bs.modal', function(e){
|
215 |
$('.modal-dialog', this).empty();
|
216 |
});
|
233 |
);
|
234 |
modal_div.modal({
|
235 |
backdrop: true,
|
236 |
+
show: true,
|
237 |
+
keyboard: false
|
238 |
}).on('hidden.bs.modal', function(e){
|
239 |
$('.modal-content', this).empty();
|
240 |
});
|
245 |
var data = $(this).data(),
|
246 |
modal_div = $(data['target']);
|
247 |
$('.modal-title', modal_div).text($(this).attr('title'));
|
248 |
+
|
249 |
+
if(data['metainfo']){
|
250 |
+
$('.modal-dialog', modal_div).addClass('modal-sm');
|
251 |
+
$('.modal-body', modal_div).html($('#metainfo_'+data['metainfo']).html());
|
252 |
+
} else{
|
253 |
+
$('.modal-dialog', modal_div).css('width', (data['width'] + 32));
|
254 |
+
$('.modal-body', modal_div).html(
|
255 |
+
$('<iframe />', {
|
256 |
+
name: 'previewFrame',
|
257 |
+
id: 'previewFrame',
|
258 |
+
width: '100%',
|
259 |
+
height: (data['height'] + 7),
|
260 |
+
src: $(this).attr('href'),
|
261 |
+
load: function(){
|
262 |
+
$(this.contentWindow.document.body).css('margin', 0);
|
263 |
+
$('.modal-backdrop', modal_div).css({'width': (data['width'] + 32), 'min-width': '100%'});
|
264 |
+
}
|
265 |
+
}).css({display: 'block', margin: '4px 0'})
|
266 |
+
);
|
267 |
+
}
|
268 |
+
|
269 |
modal_div.modal({
|
270 |
backdrop: true,
|
271 |
show: true
|
272 |
}).on('hidden.bs.modal', function(e){
|
273 |
$('.modal-title', this).empty();
|
274 |
$('.modal-body', this).empty();
|
275 |
+
$('.modal-dialog', this).removeAttr('style').attr('class', 'modal-dialog');
|
276 |
+
});
|
277 |
+
});
|
278 |
+
|
279 |
+
$('input.sharelink').on('click focus', function(){
|
280 |
+
this.setSelectionRange(0, this.value.length);
|
281 |
+
});
|
282 |
+
$('input.sharetoemail').on('keyup', function(){
|
283 |
+
$('.sharebutton').prop('disabled', !validateEmail(this.value));
|
284 |
+
});
|
285 |
+
$('.sharebutton').on('click', function(){
|
286 |
+
var sharetoemail = $('input.sharetoemail');
|
287 |
+
if(!validateEmail(sharetoemail.val())){
|
288 |
+
sharetoemail.focus();
|
289 |
+
sharetoemail.parent().addClass('has-error');
|
290 |
+
return false;
|
291 |
+
}
|
292 |
+
var post_data = $('#shareForm').serialize();
|
293 |
+
$.post(ajaxurl, post_data, function(data, textStatus, jqXHR){
|
294 |
+
console.log(data);
|
295 |
+
$('body').removeClass('gmedia-busy');
|
296 |
+
if(data){
|
297 |
+
$('#gm-message').append(data);
|
298 |
+
}
|
299 |
+
});
|
300 |
+
$('#shareModal').modal('hide');
|
301 |
+
});
|
302 |
+
$('a.share-modal').click(function(e){
|
303 |
+
e.preventDefault();
|
304 |
+
var data = $(this).data(),
|
305 |
+
modal_div = $(data['target']),
|
306 |
+
link = $(this).attr('href'),
|
307 |
+
sharetoemail = $('input.sharetoemail');
|
308 |
+
|
309 |
+
$('input.sharelink', modal_div).val(link);
|
310 |
+
$('.sharebutton').prop('disabled', !validateEmail(sharetoemail.val()));
|
311 |
+
|
312 |
+
modal_div.modal({
|
313 |
+
backdrop: false,
|
314 |
+
show: true,
|
315 |
+
keyboard: false
|
316 |
+
}).on('shown.bs.modal', function(){
|
317 |
+
$('input.sharelink', this).focus();
|
318 |
+
}).on('hidden.bs.modal', function(){
|
319 |
+
$('input.sharelink', this).val('');
|
320 |
});
|
321 |
});
|
322 |
|
353 |
$('#import-action').val($(this).attr('name'));
|
354 |
$('#importModal').modal({
|
355 |
backdrop: 'static',
|
356 |
+
show: true,
|
357 |
+
keyboard: false
|
358 |
}).on('shown.bs.modal',function(){
|
359 |
$('#import_form').submit();
|
360 |
}).on('hidden.bs.modal', function(){
|
380 |
});
|
381 |
});
|
382 |
|
383 |
+
$('form').on('keydown', ':input:visible:not(:submit,:button,:reset,textarea)', function (e) {
|
384 |
+
var charCode = e.charCode || e.keyCode || e.which;
|
385 |
+
if (13 == charCode && !$(this).parent().hasClass('selectize-input')) {
|
386 |
+
var inputs = $(this).parents("form").eq(0).find(":input:visible");
|
387 |
+
var inp = inputs[inputs.index(this) + 1];
|
388 |
+
if (inp !== null) {
|
389 |
+
$(inp).focus();
|
390 |
+
var inp_type = $(this).attr('type');
|
391 |
+
if(!!inp_type && (inp_type == 'text' || inp_type == 'number')){
|
392 |
+
inp.setSelectionRange(0, inp.value.length);
|
393 |
+
}
|
394 |
}
|
395 |
e.preventDefault();
|
396 |
return false;
|
460 |
|
461 |
});
|
462 |
|
463 |
+
function validateEmail(email) {
|
464 |
+
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
465 |
+
return re.test(email);
|
466 |
+
}
|
467 |
|
468 |
function getStorage(keyPprefix){
|
469 |
// use document.cookie:
|
admin/processor.php
CHANGED
@@ -178,7 +178,7 @@ class GmediaProcessor{
|
|
178 |
foreach($selected_items as $item){
|
179 |
$gmDB->delete_gmedia_term_relationships($item, 'gmedia_category');
|
180 |
}
|
181 |
-
$this->msg[] = sprintf(__('%d
|
182 |
} else{
|
183 |
foreach($selected_items as $item){
|
184 |
$result = $gmDB->set_gmedia_terms($item, $term, 'gmedia_category', $append = 0);
|
@@ -191,7 +191,7 @@ class GmediaProcessor{
|
|
191 |
}
|
192 |
if(isset($gmGallery->options['taxonomies']['gmedia_category'][$term])){
|
193 |
$cat_name = $gmGallery->options['taxonomies']['gmedia_category'][$term];
|
194 |
-
$this->msg[] = sprintf(__("Category `%s` assigned to %d
|
195 |
} else{
|
196 |
$this->error[] = sprintf(__("Category `%s` can't be assigned.", 'gmLang'), $term);
|
197 |
}
|
@@ -218,7 +218,7 @@ class GmediaProcessor{
|
|
218 |
foreach($selected_items as $item){
|
219 |
$gmDB->delete_gmedia_term_relationships($item, 'gmedia_album');
|
220 |
}
|
221 |
-
$this->msg[] = sprintf(__('%d
|
222 |
} else{
|
223 |
$term_ids = array();
|
224 |
foreach($selected_items as $item){
|
@@ -248,7 +248,7 @@ class GmediaProcessor{
|
|
248 |
}
|
249 |
}
|
250 |
}
|
251 |
-
$this->msg[] = sprintf(__('Album `%s` assigned to %d
|
252 |
}
|
253 |
}
|
254 |
}
|
@@ -259,30 +259,43 @@ class GmediaProcessor{
|
|
259 |
}
|
260 |
if(isset($_POST['add_tags'])){
|
261 |
check_admin_referer('gmedia_modal');
|
262 |
-
if(
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
267 |
}
|
268 |
-
|
269 |
-
$
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
$
|
|
|
|
|
|
|
|
|
|
|
280 |
}
|
|
|
281 |
}
|
282 |
-
|
|
|
283 |
}
|
284 |
-
} else{
|
285 |
-
$this->error[] = __('You are not allowed to assign terms', 'gmLang');
|
286 |
}
|
287 |
}
|
288 |
if(isset($_POST['delete_tags'])){
|
@@ -307,7 +320,7 @@ class GmediaProcessor{
|
|
307 |
$count--;
|
308 |
}
|
309 |
}
|
310 |
-
$this->msg[] = sprintf(__('%d
|
311 |
}
|
312 |
} else{
|
313 |
$this->error[] = __('You are not allowed to assign terms', 'gmLang');
|
@@ -363,7 +376,7 @@ class GmediaProcessor{
|
|
363 |
case 'metadata':
|
364 |
$metatext = $gmCore->metadata_text($id);
|
365 |
if($gmedia['description']){
|
366 |
-
$gmedia['description'] .= "\n
|
367 |
}
|
368 |
$batch_data['description'] = $gmedia['description'] . $metatext;
|
369 |
break;
|
@@ -390,16 +403,17 @@ class GmediaProcessor{
|
|
390 |
$batch_data['link'] = $fileinfo['fileurl_original'];
|
391 |
break;
|
392 |
case 'custom':
|
393 |
-
$link_custom = $gmCore->_post('
|
394 |
if(false !== $link_custom){
|
395 |
$batch_data['link'] = $link_custom;
|
396 |
}
|
397 |
break;
|
398 |
}
|
399 |
-
|
|
|
400 |
$gmDB->insert_gmedia($gmedia_data);
|
401 |
}
|
402 |
-
$this->msg[] = sprintf(__('%d
|
403 |
}
|
404 |
} else{
|
405 |
$this->error[] = __('You are not allowed to edit media', 'gmLang');
|
@@ -414,7 +428,7 @@ class GmediaProcessor{
|
|
414 |
$id = (int)$item;
|
415 |
$gmDB->update_metadata($meta_type = 'gmedia', $id, $meta_key = '_metadata', $gmDB->generate_gmedia_metadata($id));
|
416 |
}
|
417 |
-
$this->msg[] = sprintf(__('%d
|
418 |
}
|
419 |
} else{
|
420 |
$this->error[] = __('You are not allowed to edit media', 'gmLang');
|
@@ -478,41 +492,47 @@ class GmediaProcessor{
|
|
478 |
wp_die(__('You are not allowed to be here', 'gmLang'));
|
479 |
}
|
480 |
$taxonomy = $gmCore->_get('term', 'gmedia_album');
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
|
|
485 |
$selected_items = $this->selected_items;
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
}
|
494 |
}
|
495 |
-
if(($
|
496 |
-
;
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
|
|
|
|
506 |
}
|
507 |
-
setcookie("gmuser_{$user_ID}_{$taxonomy}", '', time() - 3600);
|
508 |
-
unset($_COOKIE["gmuser_{$user_ID}_{$taxonomy}"]);
|
509 |
-
$this->selected_items = array();
|
510 |
}
|
511 |
-
|
512 |
-
|
|
|
|
|
|
|
|
|
513 |
}
|
|
|
|
|
514 |
}
|
515 |
}
|
|
|
516 |
if(isset($_POST['gmedia_album_save'])){
|
517 |
check_admin_referer('GmediaTerms', 'term_save_wpnonce');
|
518 |
$edit_term = (int)$gmCore->_get('edit_album');
|
@@ -551,25 +571,52 @@ class GmediaProcessor{
|
|
551 |
$term_id = $gmDB->update_term($edit_term, $term['taxonomy'], $term);
|
552 |
} else{
|
553 |
$term_id = $gmDB->insert_term($term['name'], $term['taxonomy'], $term);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
554 |
}
|
555 |
if(is_wp_error($term_id)){
|
556 |
$this->error[] = $term_id->get_error_message();
|
557 |
break;
|
558 |
}
|
559 |
|
560 |
-
$
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
571 |
|
572 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
573 |
|
574 |
} while(0);
|
575 |
}
|
@@ -606,7 +653,7 @@ class GmediaProcessor{
|
|
606 |
if(!$gmCore->caps['gmedia_gallery_manage']){
|
607 |
wp_die(__('You are not allowed to manage gmedia galleries', 'gmLang'));
|
608 |
}
|
609 |
-
if(isset($_POST['
|
610 |
$authors = $gmCore->_post('author_ids');
|
611 |
$location = $gmCore->get_admin_url(array('author' => (int)$authors));
|
612 |
wp_redirect($location);
|
@@ -805,32 +852,34 @@ class GmediaProcessor{
|
|
805 |
} while(0);
|
806 |
}
|
807 |
|
808 |
-
if(
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
$
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
}
|
826 |
$delete = $gmDB->delete_term($item, $taxonomy);
|
827 |
-
if(
|
|
|
|
|
|
|
828 |
$this->error[] = $delete->get_error_message();
|
829 |
$count--;
|
830 |
}
|
831 |
}
|
832 |
if($count){
|
833 |
-
$this->msg[] = sprintf(__('%d
|
834 |
}
|
835 |
setcookie("gmuser_{$user_ID}_{$taxonomy}", '', time() - 3600);
|
836 |
unset($_COOKIE["gmuser_{$user_ID}_{$taxonomy}"]);
|
@@ -906,6 +955,7 @@ class GmediaProcessor{
|
|
906 |
check_admin_referer('GmediaSettings');
|
907 |
|
908 |
$set = $gmCore->_post('set', array());
|
|
|
909 |
if(!empty($set['license_key']) && empty($set['license_key2'])){
|
910 |
$lk_check = true;
|
911 |
}
|
@@ -915,6 +965,15 @@ class GmediaProcessor{
|
|
915 |
$set['license_key2'] = '';
|
916 |
$this->error[] = __('License Key deactivated', 'gmLang');
|
917 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
918 |
foreach($set as $key => $val){
|
919 |
$gmGallery->options[$key] = $val;
|
920 |
}
|
@@ -972,6 +1031,12 @@ class GmediaProcessor{
|
|
972 |
}
|
973 |
|
974 |
update_option('gmediaOptions', $gmGallery->options);
|
|
|
|
|
|
|
|
|
|
|
|
|
975 |
$this->msg[] .= __('Settings saved', 'gmLang');
|
976 |
}
|
977 |
|
178 |
foreach($selected_items as $item){
|
179 |
$gmDB->delete_gmedia_term_relationships($item, 'gmedia_category');
|
180 |
}
|
181 |
+
$this->msg[] = sprintf(__('%d item(s) was uncategorized', 'gmLang'), $count);
|
182 |
} else{
|
183 |
foreach($selected_items as $item){
|
184 |
$result = $gmDB->set_gmedia_terms($item, $term, 'gmedia_category', $append = 0);
|
191 |
}
|
192 |
if(isset($gmGallery->options['taxonomies']['gmedia_category'][$term])){
|
193 |
$cat_name = $gmGallery->options['taxonomies']['gmedia_category'][$term];
|
194 |
+
$this->msg[] = sprintf(__("Category `%s` assigned to %d image(s).", 'gmLang'), esc_html($cat_name), $count);
|
195 |
} else{
|
196 |
$this->error[] = sprintf(__("Category `%s` can't be assigned.", 'gmLang'), $term);
|
197 |
}
|
218 |
foreach($selected_items as $item){
|
219 |
$gmDB->delete_gmedia_term_relationships($item, 'gmedia_album');
|
220 |
}
|
221 |
+
$this->msg[] = sprintf(__('%d item(s) updated with "No Album"', 'gmLang'), $count);
|
222 |
} else{
|
223 |
$term_ids = array();
|
224 |
foreach($selected_items as $item){
|
248 |
}
|
249 |
}
|
250 |
}
|
251 |
+
$this->msg[] = sprintf(__('Album `%s` assigned to %d item(s)', 'gmLang'), esc_html($term->name), count($item_ids));
|
252 |
}
|
253 |
}
|
254 |
}
|
259 |
}
|
260 |
if(isset($_POST['add_tags'])){
|
261 |
check_admin_referer('gmedia_modal');
|
262 |
+
if(!$gmCore->caps['gmedia_terms']){
|
263 |
+
$this->error[] = __('You are not allowed to assign terms', 'gmLang');
|
264 |
+
} else{
|
265 |
+
$term = $gmCore->_post('tag_names');
|
266 |
+
$iptc_tags = $gmCore->_post('iptc_tags');
|
267 |
+
if($term || $iptc_tags){
|
268 |
+
if(!$gmCore->caps['gmedia_edit_others_media']){
|
269 |
+
$selected_items = $gmDB->get_gmedias(array('fields' => 'ids', 'author' => $user_ID, 'gmedia__in' => $this->selected_items));
|
270 |
+
if(count($selected_items) < count($this->selected_items)){
|
271 |
+
$this->error[] = __('You are not allowed to edit others media', 'gmLang');
|
272 |
+
}
|
273 |
+
} else{
|
274 |
+
$selected_items = $this->selected_items;
|
275 |
}
|
276 |
+
$term = explode(',', $term);
|
277 |
+
if(($count = count($selected_items))){
|
278 |
+
foreach($selected_items as $item){
|
279 |
+
$_term = $term;
|
280 |
+
if($iptc_tags){
|
281 |
+
$_metadata = $gmDB->get_metadata('gmedia', $item, '_metadata', true);
|
282 |
+
if(isset($_metadata['image_meta']['keywords']) && is_array($_metadata['image_meta']['keywords'])){
|
283 |
+
$_term = array_merge($_metadata['image_meta']['keywords'], $term);
|
284 |
+
}
|
285 |
+
}
|
286 |
+
$result = $gmDB->set_gmedia_terms($item, $_term, 'gmedia_tag', $append = 1);
|
287 |
+
if(is_wp_error($result)){
|
288 |
+
$this->error[] = $result;
|
289 |
+
$count --;
|
290 |
+
} elseif(!$result){
|
291 |
+
$count --;
|
292 |
+
}
|
293 |
}
|
294 |
+
$this->msg[] = sprintf(__('Tags added to %d item(s)', 'gmLang'), count($term), $count);
|
295 |
}
|
296 |
+
} else{
|
297 |
+
$this->error[] = __('No tags specified', 'gmLang');
|
298 |
}
|
|
|
|
|
299 |
}
|
300 |
}
|
301 |
if(isset($_POST['delete_tags'])){
|
320 |
$count--;
|
321 |
}
|
322 |
}
|
323 |
+
$this->msg[] = sprintf(__('%d tag(s) deleted from %d item(s)', 'gmLang'), count($term), $count);
|
324 |
}
|
325 |
} else{
|
326 |
$this->error[] = __('You are not allowed to assign terms', 'gmLang');
|
376 |
case 'metadata':
|
377 |
$metatext = $gmCore->metadata_text($id);
|
378 |
if($gmedia['description']){
|
379 |
+
$gmedia['description'] .= "\n";
|
380 |
}
|
381 |
$batch_data['description'] = $gmedia['description'] . $metatext;
|
382 |
break;
|
403 |
$batch_data['link'] = $fileinfo['fileurl_original'];
|
404 |
break;
|
405 |
case 'custom':
|
406 |
+
$link_custom = $gmCore->_post('batch_link_custom');
|
407 |
if(false !== $link_custom){
|
408 |
$batch_data['link'] = $link_custom;
|
409 |
}
|
410 |
break;
|
411 |
}
|
412 |
+
//$gmedia_data = array_replace($gmedia, $batch_data);
|
413 |
+
$gmedia_data = array_merge($gmedia, $batch_data);
|
414 |
$gmDB->insert_gmedia($gmedia_data);
|
415 |
}
|
416 |
+
$this->msg[] = sprintf(__('%d item(s) updated successfuly', 'gmLang'), $count);
|
417 |
}
|
418 |
} else{
|
419 |
$this->error[] = __('You are not allowed to edit media', 'gmLang');
|
428 |
$id = (int)$item;
|
429 |
$gmDB->update_metadata($meta_type = 'gmedia', $id, $meta_key = '_metadata', $gmDB->generate_gmedia_metadata($id));
|
430 |
}
|
431 |
+
$this->msg[] = sprintf(__('%d item(s) updated successfuly', 'gmLang'), $count);
|
432 |
}
|
433 |
} else{
|
434 |
$this->error[] = __('You are not allowed to edit media', 'gmLang');
|
492 |
wp_die(__('You are not allowed to be here', 'gmLang'));
|
493 |
}
|
494 |
$taxonomy = $gmCore->_get('term', 'gmedia_album');
|
495 |
+
|
496 |
+
if(($delete = $gmCore->_get('delete'))){
|
497 |
+
check_admin_referer('gmedia_delete');
|
498 |
+
if($gmCore->caps['gmedia_terms_delete']){
|
499 |
+
if('selected' == $gmCore->_get('delete')){
|
500 |
$selected_items = $this->selected_items;
|
501 |
+
} else{
|
502 |
+
$selected_items = wp_parse_id_list($delete);
|
503 |
+
}
|
504 |
+
if(!$gmCore->caps['gmedia_delete_others_media']){
|
505 |
+
$_selected_items = array();
|
506 |
+
if('gmedia_album' == $taxonomy){
|
507 |
+
$_selected_items = $gmDB->get_terms($taxonomy, array('fields' => 'ids', 'global' => $user_ID, 'include' => $selected_items));
|
|
|
508 |
}
|
509 |
+
if(count($_selected_items) < count($selected_items)){
|
510 |
+
$this->error[] = __('You are not allowed to delete others media', 'gmLang');
|
511 |
+
}
|
512 |
+
$selected_items = $_selected_items;
|
513 |
+
}
|
514 |
+
if(($count = count($selected_items))){
|
515 |
+
foreach($selected_items as $item){
|
516 |
+
$delete = $gmDB->delete_term($item, $taxonomy);
|
517 |
+
if(!$delete){
|
518 |
+
$count--;
|
519 |
+
} elseif(is_wp_error($delete)){
|
520 |
+
$this->error[] = $delete->get_error_message();
|
521 |
+
$count--;
|
522 |
}
|
|
|
|
|
|
|
523 |
}
|
524 |
+
if($count){
|
525 |
+
$this->msg[] = sprintf(__('%d item(s) deleted successfuly', 'gmLang'), $count);
|
526 |
+
}
|
527 |
+
setcookie("gmuser_{$user_ID}_{$taxonomy}", '', time() - 3600);
|
528 |
+
unset($_COOKIE["gmuser_{$user_ID}_{$taxonomy}"]);
|
529 |
+
$this->selected_items = array();
|
530 |
}
|
531 |
+
} else{
|
532 |
+
$this->error[] = __('You are not allowed to delete terms', 'gmLang');
|
533 |
}
|
534 |
}
|
535 |
+
|
536 |
if(isset($_POST['gmedia_album_save'])){
|
537 |
check_admin_referer('GmediaTerms', 'term_save_wpnonce');
|
538 |
$edit_term = (int)$gmCore->_get('edit_album');
|
571 |
$term_id = $gmDB->update_term($edit_term, $term['taxonomy'], $term);
|
572 |
} else{
|
573 |
$term_id = $gmDB->insert_term($term['name'], $term['taxonomy'], $term);
|
574 |
+
if(is_int($term_id)){
|
575 |
+
$term_meta = array(
|
576 |
+
'orderby' => $term['orderby'],
|
577 |
+
'order' => $term['order']
|
578 |
+
);
|
579 |
+
foreach($term_meta as $key => $value){
|
580 |
+
$gmDB->add_metadata('gmedia_term', $term_id, $key, $value);
|
581 |
+
}
|
582 |
+
}
|
583 |
}
|
584 |
if(is_wp_error($term_id)){
|
585 |
$this->error[] = $term_id->get_error_message();
|
586 |
break;
|
587 |
}
|
588 |
|
589 |
+
$this->msg[] = sprintf(__('Album `%s` successfuly saved', 'gmLang'), $term['name']);
|
590 |
+
|
591 |
+
} while(0);
|
592 |
+
}
|
593 |
+
if(isset($_POST['gmedia_term_sort_save'])){
|
594 |
+
check_admin_referer('GmediaTerms', 'term_save_wpnonce');
|
595 |
+
do{
|
596 |
+
if(!$gmCore->caps['gmedia_album_manage']){
|
597 |
+
$this->error[] = __('You are not allowed to manage albums', 'gmLang');
|
598 |
+
break;
|
599 |
}
|
600 |
+
$term_data = $gmCore->_post('term');
|
601 |
+
$taxonomy = 'gmedia_album';
|
602 |
+
if(!($term_id = $gmDB->term_exists($term_data['term_id'], $taxonomy))){
|
603 |
+
$this->error[] = __('A term with the id provided do not exists', 'gmLang');
|
604 |
+
break;
|
605 |
+
}else {
|
606 |
+
$_term = $gmDB->get_term($term_id, $taxonomy);
|
607 |
+
if(((int)$_term->global != (int)$user_ID) && !current_user_can('gmedia_edit_others_media')){
|
608 |
+
$this->error[] = __('You are not allowed to edit others media', 'gmLang');
|
609 |
+
break;
|
610 |
+
}
|
611 |
+
$term_id = $gmDB->update_term_sortorder($term_id, $taxonomy, $term_data);
|
612 |
|
613 |
+
if(is_wp_error($term_id)){
|
614 |
+
$this->error[] = $term_id->get_error_message();
|
615 |
+
break;
|
616 |
+
}
|
617 |
+
|
618 |
+
$this->msg[] = sprintf(__('Album `%s` successfuly saved', 'gmLang'), $_term->name);
|
619 |
+
}
|
620 |
|
621 |
} while(0);
|
622 |
}
|
653 |
if(!$gmCore->caps['gmedia_gallery_manage']){
|
654 |
wp_die(__('You are not allowed to manage gmedia galleries', 'gmLang'));
|
655 |
}
|
656 |
+
if(isset($_POST['select_author'])){
|
657 |
$authors = $gmCore->_post('author_ids');
|
658 |
$location = $gmCore->get_admin_url(array('author' => (int)$authors));
|
659 |
wp_redirect($location);
|
852 |
} while(0);
|
853 |
}
|
854 |
|
855 |
+
if(($delete = $gmCore->_get('delete'))){
|
856 |
+
check_admin_referer('gmedia_delete');
|
857 |
+
$taxonomy = 'gmedia_gallery';
|
858 |
+
if('selected' == $delete){
|
859 |
+
$selected_items = $this->selected_items;
|
860 |
+
} else{
|
861 |
+
$selected_items = wp_parse_id_list($delete);
|
862 |
+
}
|
863 |
+
if(!$gmCore->caps['gmedia_delete_others_media']){
|
864 |
+
$_selected_items = $gmDB->get_terms($taxonomy, array('fields' => 'ids', 'global' => $user_ID, 'include' => $selected_items));
|
865 |
+
if(count($_selected_items) < count($selected_items)){
|
866 |
+
$this->error[] = __('You are not allowed to delete others media', 'gmLang');
|
867 |
+
}
|
868 |
+
$selected_items = $_selected_items;
|
869 |
+
}
|
870 |
+
if(($count = count($selected_items))){
|
871 |
+
foreach($selected_items as $item){
|
|
|
872 |
$delete = $gmDB->delete_term($item, $taxonomy);
|
873 |
+
if(!$delete){
|
874 |
+
$this->error[] = sprintf(__('Error while delete gallery #%d', 'gmLang'), $item);
|
875 |
+
$count--;
|
876 |
+
} elseif(is_wp_error($delete)){
|
877 |
$this->error[] = $delete->get_error_message();
|
878 |
$count--;
|
879 |
}
|
880 |
}
|
881 |
if($count){
|
882 |
+
$this->msg[] = sprintf(__('%d item(s) deleted successfuly', 'gmLang'), $count);
|
883 |
}
|
884 |
setcookie("gmuser_{$user_ID}_{$taxonomy}", '', time() - 3600);
|
885 |
unset($_COOKIE["gmuser_{$user_ID}_{$taxonomy}"]);
|
955 |
check_admin_referer('GmediaSettings');
|
956 |
|
957 |
$set = $gmCore->_post('set', array());
|
958 |
+
|
959 |
if(!empty($set['license_key']) && empty($set['license_key2'])){
|
960 |
$lk_check = true;
|
961 |
}
|
965 |
$set['license_key2'] = '';
|
966 |
$this->error[] = __('License Key deactivated', 'gmLang');
|
967 |
}
|
968 |
+
|
969 |
+
$flush_rewrite_rules = false;
|
970 |
+
if(empty($set['endpoint'])){
|
971 |
+
$set['endpoint'] = 'gmedia';
|
972 |
+
}
|
973 |
+
if($set['endpoint'] !== $gmGallery->options['endpoint']){
|
974 |
+
$flush_rewrite_rules = true;
|
975 |
+
}
|
976 |
+
|
977 |
foreach($set as $key => $val){
|
978 |
$gmGallery->options[$key] = $val;
|
979 |
}
|
1031 |
}
|
1032 |
|
1033 |
update_option('gmediaOptions', $gmGallery->options);
|
1034 |
+
if(isset($_POST['GmediaHashID_salt'])){
|
1035 |
+
update_option('GmediaHashID_salt', (string) $_POST['GmediaHashID_salt']);
|
1036 |
+
}
|
1037 |
+
if($flush_rewrite_rules){
|
1038 |
+
flush_rewrite_rules(false);
|
1039 |
+
}
|
1040 |
$this->msg[] .= __('Settings saved', 'gmLang');
|
1041 |
}
|
1042 |
|
admin/settings.php
CHANGED
@@ -9,11 +9,13 @@ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])){
|
|
9 |
* @return mixed content
|
10 |
*/
|
11 |
function gmSettings(){
|
12 |
-
global $gmDB, $gmCore, $gmGallery;
|
|
|
|
|
13 |
|
14 |
?>
|
15 |
|
16 |
-
<form class="panel panel-default" method="post">
|
17 |
<div class="panel-heading clearfix">
|
18 |
<div class="btn-toolbar pull-left">
|
19 |
<div class="btn-group">
|
@@ -28,12 +30,14 @@ function gmSettings(){
|
|
28 |
<div class="panel-body" id="gmedia-msg-panel"></div>
|
29 |
<div class="container-fluid">
|
30 |
<div class="tabable tabs-left">
|
31 |
-
<ul class="nav nav-tabs" style="padding:10px 0;">
|
32 |
<li class="active"><a href="#gmedia_premium" data-toggle="tab"><?php _e('Premium Settings', 'gmLang'); ?></a></li>
|
|
|
33 |
<?php if(current_user_can('manage_options')){ ?>
|
34 |
-
<li><a href="#
|
35 |
-
|
36 |
-
|
|
|
37 |
</ul>
|
38 |
<div class="tab-content" style="padding-top:21px;">
|
39 |
<fieldset id="gmedia_premium" class="tab-pane active">
|
@@ -56,8 +60,195 @@ function gmSettings(){
|
|
56 |
</div>
|
57 |
</div>
|
58 |
</fieldset>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
<?php if(current_user_can('manage_options')){ ?>
|
60 |
-
<fieldset id="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
<p><?php _e('Select the lowest role which should be able to access the follow capabilities. Gmedia Gallery supports the standard roles from WordPress.', 'gmLang'); ?></p>
|
62 |
|
63 |
<div class="form-group">
|
@@ -168,60 +359,8 @@ function gmSettings(){
|
|
168 |
|
169 |
</fieldset>
|
170 |
<?php } ?>
|
171 |
-
<fieldset id="gmedia_settings2" class="tab-pane">
|
172 |
-
<div class="form-group">
|
173 |
-
<label><?php _e('When delete (uninstall) plugin', 'gmLang') ?>:</label>
|
174 |
-
<select name="set[uninstall_dropdata]" class="form-control input-sm">
|
175 |
-
<option value="all" <?php selected($gmGallery->options['uninstall_dropdata'], 'all'); ?>><?php _e('Delete database and all uploaded files', 'gmLang'); ?></option>
|
176 |
-
<option value="db" <?php selected($gmGallery->options['uninstall_dropdata'], 'db'); ?>><?php _e('Delete database only and leave uploaded files', 'gmLang'); ?></option>
|
177 |
-
<option value="none" <?php selected($gmGallery->options['uninstall_dropdata'], 'none'); ?>><?php _e('Do not delete database and uploaded files', 'gmLang'); ?></option>
|
178 |
-
</select>
|
179 |
-
</div>
|
180 |
-
<div class="form-group">
|
181 |
-
<label><?php _e('Forbid other plugins to load their JS and CSS on Gmedia admin pages', 'gmLang') ?>:</label>
|
182 |
-
|
183 |
-
<div class="checkbox" style="margin:0;">
|
184 |
-
<input type="hidden" name="set[isolation_mode]" value="0"/>
|
185 |
-
<label><input type="checkbox" name="set[isolation_mode]" value="1" <?php checked($gmGallery->options['isolation_mode'], '1'); ?> /> <?php _e('Enable Gmedia admin panel Isolation Mode', 'gmLang'); ?></label>
|
186 |
-
|
187 |
-
<p class="help-block"><?php _e('This option could help to avoid JS and CSS conflicts with other plugins in admin panel.', 'gmLang'); ?></p>
|
188 |
-
</div>
|
189 |
-
</div>
|
190 |
-
<div class="form-group">
|
191 |
-
<label><?php _e('Forbid theme to format Gmedia shortcode\'s content', 'gmLang') ?>:</label>
|
192 |
|
193 |
-
|
194 |
-
<input type="hidden" name="set[shortcode_raw]" value="0"/>
|
195 |
-
<label><input type="checkbox" name="set[shortcode_raw]" value="1" <?php checked($gmGallery->options['shortcode_raw'], '1'); ?> /> <?php _e('Raw output for Gmedia Shortcode', 'gmLang'); ?></label>
|
196 |
-
|
197 |
-
<p class="help-block"><?php _e('Some themes reformat shortcodes and break it functionality (mostly when you add description to images). Turning this on should solve this problem.', 'gmLang'); ?></p>
|
198 |
-
</div>
|
199 |
-
</div>
|
200 |
-
<?php
|
201 |
-
$allowed_post_types = (array) $gmGallery->options['gmedia_post_types_support'];
|
202 |
-
$args = array(
|
203 |
-
'public' => true,
|
204 |
-
'_builtin' => false
|
205 |
-
);
|
206 |
-
$output = 'objects'; // names or objects, note names is the default
|
207 |
-
$operator = 'and'; // 'and' or 'or'
|
208 |
-
$post_types = get_post_types($args, $output, $operator);
|
209 |
-
if(!empty($post_types)){ ?>
|
210 |
-
<div class="form-group">
|
211 |
-
<label style="margin-bottom:-5px;"><?php _e('Enable Gmedia Library button on custom post types', 'gmLang') ?>:</label>
|
212 |
-
<input type="hidden" name="set[gmedia_post_types_support]" value=""/>
|
213 |
-
<?php
|
214 |
-
foreach($post_types as $post_type){ ?>
|
215 |
-
<div class="checkbox">
|
216 |
-
<label><input type="checkbox" name="set[gmedia_post_types_support][]" value="<?php echo $post_type->name; ?>" <?php if(in_array($post_type->name, $allowed_post_types)){
|
217 |
-
echo 'checked="checked"';
|
218 |
-
}; ?> /> <?php echo $post_type->label . ' (' . $post_type->name . ')'; ?></label>
|
219 |
-
</div>
|
220 |
-
<?php } ?>
|
221 |
-
</div>
|
222 |
-
<?php } ?>
|
223 |
-
</fieldset>
|
224 |
-
<fieldset id="gmedia_settings3" class="tab-pane">
|
225 |
<?php
|
226 |
if((function_exists('memory_get_usage')) && (ini_get('memory_limit'))){
|
227 |
$memory_limit = ini_get('memory_limit');
|
@@ -251,6 +390,18 @@ function gmSettings(){
|
|
251 |
</div>
|
252 |
<div class="clear"></div>
|
253 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
</div>
|
255 |
</form>
|
256 |
<?php
|
9 |
* @return mixed content
|
10 |
*/
|
11 |
function gmSettings(){
|
12 |
+
global $user_ID, $gmDB, $gmCore, $gmGallery, $gmProcessor;
|
13 |
+
|
14 |
+
$url = add_query_arg(array('page' => $gmProcessor->page), admin_url('admin.php'));
|
15 |
|
16 |
?>
|
17 |
|
18 |
+
<form id="gmediaSettingsForm" class="panel panel-default" method="post" action="<?php echo $url; ?>">
|
19 |
<div class="panel-heading clearfix">
|
20 |
<div class="btn-toolbar pull-left">
|
21 |
<div class="btn-group">
|
30 |
<div class="panel-body" id="gmedia-msg-panel"></div>
|
31 |
<div class="container-fluid">
|
32 |
<div class="tabable tabs-left">
|
33 |
+
<ul id="settingsTabs" class="nav nav-tabs" style="padding:10px 0;">
|
34 |
<li class="active"><a href="#gmedia_premium" data-toggle="tab"><?php _e('Premium Settings', 'gmLang'); ?></a></li>
|
35 |
+
<li><a href="#gmedia_settings_other" data-toggle="tab"><?php _e('Other Settings', 'gmLang'); ?></a></li>
|
36 |
<?php if(current_user_can('manage_options')){ ?>
|
37 |
+
<li><a href="#gmedia_settings_cloud" data-toggle="tab"><?php _e('GmediaCloud Page', 'gmLang'); ?></a></li>
|
38 |
+
<li><a href="#gmedia_settings_roles" data-toggle="tab"><?php _e('Roles/Capabilities Manager', 'gmLang'); ?></a></li>
|
39 |
+
<?php } ?>
|
40 |
+
<li><a href="#gmedia_settings_sysinfo" data-toggle="tab"><?php _e('System Info', 'gmLang'); ?></a></li>
|
41 |
</ul>
|
42 |
<div class="tab-content" style="padding-top:21px;">
|
43 |
<fieldset id="gmedia_premium" class="tab-pane active">
|
60 |
</div>
|
61 |
</div>
|
62 |
</fieldset>
|
63 |
+
|
64 |
+
<fieldset id="gmedia_settings_other" class="tab-pane">
|
65 |
+
<div class="form-group">
|
66 |
+
<label><?php _e('When delete (uninstall) plugin', 'gmLang') ?>:</label>
|
67 |
+
<select name="set[uninstall_dropdata]" class="form-control input-sm">
|
68 |
+
<option value="all" <?php selected($gmGallery->options['uninstall_dropdata'], 'all'); ?>><?php _e('Delete database and all uploaded files', 'gmLang'); ?></option>
|
69 |
+
<option value="db" <?php selected($gmGallery->options['uninstall_dropdata'], 'db'); ?>><?php _e('Delete database only and leave uploaded files', 'gmLang'); ?></option>
|
70 |
+
<option value="none" <?php selected($gmGallery->options['uninstall_dropdata'], 'none'); ?>><?php _e('Do not delete database and uploaded files', 'gmLang'); ?></option>
|
71 |
+
</select>
|
72 |
+
</div>
|
73 |
+
<div class="form-group row">
|
74 |
+
<div class="col-xs-6">
|
75 |
+
<label><?php _e('In Tags order gmedia', 'gmLang'); ?></label>
|
76 |
+
<select name="set[in_tag_orderby]" class="form-control input-sm">
|
77 |
+
<option value="ID" <?php selected($gmGallery->options['in_tag_orderby'], 'ID'); ?>><?php _e('by ID', 'gmLang'); ?></option>
|
78 |
+
<option value="title ID" <?php selected($gmGallery->options['in_tag_orderby'], 'title ID'); ?>><?php _e('by title', 'gmLang'); ?></option>
|
79 |
+
<option value="gmuid" <?php selected($gmGallery->options['in_tag_orderby'], 'gmuid'); ?>><?php _e('by filename', 'gmLang'); ?></option>
|
80 |
+
<option value="date ID" <?php selected($gmGallery->options['in_tag_orderby'], 'date ID'); ?>><?php _e('by date', 'gmLang'); ?></option>
|
81 |
+
<option value="modified ID" <?php selected($gmGallery->options['in_tag_orderby'], 'modified ID'); ?>><?php _e('by last modified date', 'gmLang'); ?></option>
|
82 |
+
<option value="rand" <?php selected($gmGallery->options['in_tag_orderby'], 'rand'); ?>><?php _e('Random', 'gmLang'); ?></option>
|
83 |
+
</select>
|
84 |
+
</div>
|
85 |
+
<div class="col-xs-6">
|
86 |
+
<label><?php _e('Sort order', 'gmLang'); ?></label>
|
87 |
+
<select name="set[in_tag_order]" class="form-control input-sm">
|
88 |
+
<option value="DESC" <?php selected($gmGallery->options['in_tag_order'], 'DESC'); ?>><?php _e('DESC', 'gmLang'); ?></option>
|
89 |
+
<option value="ASC" <?php selected($gmGallery->options['in_tag_order'], 'ASC'); ?>><?php _e('ASC', 'gmLang'); ?></option>
|
90 |
+
</select>
|
91 |
+
</div>
|
92 |
+
</div>
|
93 |
+
<div class="form-group row">
|
94 |
+
<div class="col-xs-6">
|
95 |
+
<label><?php _e('In Category order gmedia', 'gmLang'); ?></label>
|
96 |
+
<select name="set[in_category_orderby]" class="form-control input-sm">
|
97 |
+
<option value="ID" <?php selected($gmGallery->options['in_category_orderby'], 'ID'); ?>><?php _e('by ID', 'gmLang'); ?></option>
|
98 |
+
<option value="title ID" <?php selected($gmGallery->options['in_category_orderby'], 'title ID'); ?>><?php _e('by title', 'gmLang'); ?></option>
|
99 |
+
<option value="gmuid" <?php selected($gmGallery->options['in_category_orderby'], 'gmuid'); ?>><?php _e('by filename', 'gmLang'); ?></option>
|
100 |
+
<option value="date ID" <?php selected($gmGallery->options['in_category_orderby'], 'date ID'); ?>><?php _e('by date', 'gmLang'); ?></option>
|
101 |
+
<option value="modified ID" <?php selected($gmGallery->options['in_category_orderby'], 'modified ID'); ?>><?php _e('by last modified date', 'gmLang'); ?></option>
|
102 |
+
<option value="rand" <?php selected($gmGallery->options['in_category_orderby'], 'rand'); ?>><?php _e('Random', 'gmLang'); ?></option>
|
103 |
+
</select>
|
104 |
+
</div>
|
105 |
+
<div class="col-xs-6">
|
106 |
+
<label><?php _e('Sort order', 'gmLang'); ?></label>
|
107 |
+
<select name="set[in_category_order]" class="form-control input-sm">
|
108 |
+
<option value="DESC" <?php selected($gmGallery->options['in_category_order'], 'DESC'); ?>><?php _e('DESC', 'gmLang'); ?></option>
|
109 |
+
<option value="ASC" <?php selected($gmGallery->options['in_category_order'], 'ASC'); ?>><?php _e('ASC', 'gmLang'); ?></option>
|
110 |
+
</select>
|
111 |
+
</div>
|
112 |
+
</div>
|
113 |
+
<div class="form-group">
|
114 |
+
<label><?php _e('Forbid other plugins to load their JS and CSS on Gmedia admin pages', 'gmLang') ?>:</label>
|
115 |
+
|
116 |
+
<div class="checkbox" style="margin:0;">
|
117 |
+
<input type="hidden" name="set[isolation_mode]" value="0"/>
|
118 |
+
<label><input type="checkbox" name="set[isolation_mode]" value="1" <?php checked($gmGallery->options['isolation_mode'], '1'); ?> /> <?php _e('Enable Gmedia admin panel Isolation Mode', 'gmLang'); ?></label>
|
119 |
+
|
120 |
+
<p class="help-block"><?php _e('This option could help to avoid JS and CSS conflicts with other plugins in admin panel.', 'gmLang'); ?></p>
|
121 |
+
</div>
|
122 |
+
</div>
|
123 |
+
<div class="form-group">
|
124 |
+
<label><?php _e('Forbid theme to format Gmedia shortcode\'s content', 'gmLang') ?>:</label>
|
125 |
+
|
126 |
+
<div class="checkbox" style="margin:0;">
|
127 |
+
<input type="hidden" name="set[shortcode_raw]" value="0"/>
|
128 |
+
<label><input type="checkbox" name="set[shortcode_raw]" value="1" <?php checked($gmGallery->options['shortcode_raw'], '1'); ?> /> <?php _e('Raw output for Gmedia Shortcode', 'gmLang'); ?></label>
|
129 |
+
|
130 |
+
<p class="help-block"><?php _e('Some themes reformat shortcodes and break it functionality (mostly when you add description to images). Turning this on should solve this problem.', 'gmLang'); ?></p>
|
131 |
+
</div>
|
132 |
+
</div>
|
133 |
+
<?php
|
134 |
+
$allowed_post_types = (array) $gmGallery->options['gmedia_post_types_support'];
|
135 |
+
$args = array(
|
136 |
+
'public' => true,
|
137 |
+
'_builtin' => false
|
138 |
+
);
|
139 |
+
$output = 'objects'; // names or objects, note names is the default
|
140 |
+
$operator = 'and'; // 'and' or 'or'
|
141 |
+
$post_types = get_post_types($args, $output, $operator);
|
142 |
+
if(!empty($post_types)){ ?>
|
143 |
+
<div class="form-group">
|
144 |
+
<label style="margin-bottom:-5px;"><?php _e('Enable Gmedia Library button on custom post types', 'gmLang') ?>:</label>
|
145 |
+
<input type="hidden" name="set[gmedia_post_types_support]" value=""/>
|
146 |
+
<?php
|
147 |
+
foreach($post_types as $post_type){ ?>
|
148 |
+
<div class="checkbox">
|
149 |
+
<label><input type="checkbox" name="set[gmedia_post_types_support][]" value="<?php echo $post_type->name; ?>" <?php if(in_array($post_type->name, $allowed_post_types)){
|
150 |
+
echo 'checked="checked"';
|
151 |
+
}; ?> /> <?php echo $post_type->label . ' (' . $post_type->name . ')'; ?></label>
|
152 |
+
</div>
|
153 |
+
<?php } ?>
|
154 |
+
</div>
|
155 |
+
<?php } ?>
|
156 |
+
</fieldset>
|
157 |
+
|
158 |
<?php if(current_user_can('manage_options')){ ?>
|
159 |
+
<fieldset id="gmedia_settings_cloud" class="tab-pane">
|
160 |
+
<p><?php _e('GmediaCloud is full window template to show your galleries, albums and other gmedia content', 'gmLang'); ?></p>
|
161 |
+
<p><?php _e('Each module can have it\'s own design for GmediaCloud. Here you can set default module wich will be used for sharing Albums, Tags, Categories and single Gmedia Items.', 'gmLang'); ?></p>
|
162 |
+
<br/>
|
163 |
+
<div class="form-group">
|
164 |
+
<label><?php _e('HashID salt for unique template URL', 'gmLang') ?>:</label>
|
165 |
+
<input type="text" name="GmediaHashID_salt" value="<?php echo get_option('GmediaHashID_salt'); ?>" class="form-control input-sm" />
|
166 |
+
|
167 |
+
<p class="help-block"><?php _e('Changing this string you\'ll change Gmedia template URLs.', 'gmLang'); ?></p>
|
168 |
+
</div>
|
169 |
+
<div class="form-group">
|
170 |
+
<label><?php _e('Permalink Endpoint (GmediaCloud base)', 'gmLang') ?>:</label>
|
171 |
+
<input type="text" name="set[endpoint]" value="<?php echo $gmGallery->options['endpoint']; ?>" class="form-control input-sm" />
|
172 |
+
|
173 |
+
<p class="help-block"><?php _e('Changing endpoint you\'ll change Gmedia template URLs.', 'gmLang'); ?></p>
|
174 |
+
</div>
|
175 |
+
<?php
|
176 |
+
$modules = array();
|
177 |
+
if ( ( $plugin_modules = glob( GMEDIA_ABSPATH . 'module/*', GLOB_ONLYDIR | GLOB_NOSORT ) ) ) {
|
178 |
+
foreach ( $plugin_modules as $path ) {
|
179 |
+
if ( ! file_exists( $path . '/index.php' ) ) {
|
180 |
+
continue;
|
181 |
+
}
|
182 |
+
$module_info = array();
|
183 |
+
include( $path . '/index.php' );
|
184 |
+
if ( empty( $module_info ) ) {
|
185 |
+
continue;
|
186 |
+
}
|
187 |
+
$mfold = basename( $path );
|
188 |
+
$modules[ $mfold ] = array(
|
189 |
+
'module_name' => $mfold,
|
190 |
+
'module_title' => $module_info['title'] . ' v' . $module_info['version'],
|
191 |
+
'module_url' => $gmCore->gmedia_url . "/module/{$mfold}",
|
192 |
+
'module_path' => $path
|
193 |
+
);
|
194 |
+
}
|
195 |
+
}
|
196 |
+
if ( ( $upload_modules = glob( $gmCore->upload['path'] . '/' . $gmGallery->options['folder']['module'] . '/*', GLOB_ONLYDIR | GLOB_NOSORT ) ) ) {
|
197 |
+
foreach ( $upload_modules as $path ) {
|
198 |
+
if ( ! file_exists( $path . '/index.php' ) ) {
|
199 |
+
continue;
|
200 |
+
}
|
201 |
+
$module_info = array();
|
202 |
+
include( $path . '/index.php' );
|
203 |
+
if ( empty( $module_info ) ) {
|
204 |
+
continue;
|
205 |
+
}
|
206 |
+
$mfold = basename( $path );
|
207 |
+
$modules[ $mfold ] = array(
|
208 |
+
'module_name' => $mfold,
|
209 |
+
'module_title' => $module_info['title'] . ' v' . $module_info['version'],
|
210 |
+
'module_url' => $gmCore->upload['url'] . "/{$gmGallery->options['folder']['module']}/{$mfold}",
|
211 |
+
'module_path' => $path
|
212 |
+
);
|
213 |
+
}
|
214 |
+
}
|
215 |
+
?>
|
216 |
+
<div class="form-group">
|
217 |
+
<label><?php _e('Choose module/preset for GmediaCloud Page', 'gmLang') ?>:</label>
|
218 |
+
<select class="form-control input-sm" name="set[gmediacloud_module]">
|
219 |
+
<option value=""><?php _e('Choose module/preset', 'gmLang'); ?></option>
|
220 |
+
<?php foreach ( $modules as $mfold => $module ) {
|
221 |
+
echo '<optgroup label="' . esc_attr($module['module_title']) . '">';
|
222 |
+
$presets = $gmDB->get_terms( 'gmedia_module', array( 'global' => $user_ID, 'status' => $mfold ) );
|
223 |
+
$selected = selected($gmGallery->options['gmediacloud_module'], esc_attr($mfold), false);
|
224 |
+
$option = array();
|
225 |
+
$option['default'] = '<option '.$selected.' value="' . esc_attr($mfold) . '">' . '[' . $mfold . '] ' . __( 'Default Settings' ) . '</option>';
|
226 |
+
foreach ( $presets as $preset ) {
|
227 |
+
$selected = selected($gmGallery->options['gmediacloud_module'], $preset->term_id, false);
|
228 |
+
if ( '[' . $mfold . ']' == $preset->name ) {
|
229 |
+
$option['default'] = '<option '.$selected.' value="' . $preset->term_id . '">' . '[' . $mfold . '] ' . __( 'Default Settings' ) . '</option>';
|
230 |
+
} else {
|
231 |
+
$option[] = '<option '.$selected.' value="' . $preset->term_id . '">' . $preset->name . '</option>';
|
232 |
+
}
|
233 |
+
}
|
234 |
+
echo implode('', $option);
|
235 |
+
echo '</optgroup>';
|
236 |
+
} ?>
|
237 |
+
</select>
|
238 |
+
|
239 |
+
<p class="help-block"><?php _e('by default will be used Phantom module', 'gmLang'); ?></p>
|
240 |
+
</div>
|
241 |
+
<div class="form-group">
|
242 |
+
<label><?php _e('Additional JS code for GmediaCloud Page', 'gmLang') ?>:</label>
|
243 |
+
<textarea name="set[gmediacloud_footer_js]" rows="4" cols="20" class="form-control input-sm"><?php echo esc_html(stripslashes($gmGallery->options['gmediacloud_footer_js'])); ?></textarea>
|
244 |
+
</div>
|
245 |
+
<div class="form-group">
|
246 |
+
<label><?php _e('Additional CSS code for GmediaCloud Page', 'gmLang') ?>:</label>
|
247 |
+
<textarea name="set[gmediacloud_footer_css]" rows="4" cols="20" class="form-control input-sm"><?php echo esc_html(stripslashes($gmGallery->options['gmediacloud_footer_css'])); ?></textarea>
|
248 |
+
</div>
|
249 |
+
</fieldset>
|
250 |
+
|
251 |
+
<fieldset id="gmedia_settings_roles" class="tab-pane">
|
252 |
<p><?php _e('Select the lowest role which should be able to access the follow capabilities. Gmedia Gallery supports the standard roles from WordPress.', 'gmLang'); ?></p>
|
253 |
|
254 |
<div class="form-group">
|
359 |
|
360 |
</fieldset>
|
361 |
<?php } ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
362 |
|
363 |
+
<fieldset id="gmedia_settings_sysinfo" class="tab-pane">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
364 |
<?php
|
365 |
if((function_exists('memory_get_usage')) && (ini_get('memory_limit'))){
|
366 |
$memory_limit = ini_get('memory_limit');
|
390 |
</div>
|
391 |
<div class="clear"></div>
|
392 |
</div>
|
393 |
+
<script type="text/javascript">
|
394 |
+
jQuery(function($){
|
395 |
+
var hash = window.location.hash;
|
396 |
+
if(hash){
|
397 |
+
hash = hash.replace('_tab', '');
|
398 |
+
$('#settingsTabs a[href="'+hash+'"]').tab('show');
|
399 |
+
}
|
400 |
+
$('#gmediaSettingsForm').on('submit', function(){
|
401 |
+
$(this).attr('action', $(this).attr('action') + $('#settingsTabs li.active a').attr('href') + '_tab');
|
402 |
+
});
|
403 |
+
});
|
404 |
+
</script>
|
405 |
</div>
|
406 |
</form>
|
407 |
<?php
|
admin/terms.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
-
if
|
3 |
-
die(
|
4 |
}
|
5 |
|
6 |
/**
|
@@ -8,593 +8,726 @@ if ( preg_match( '#' . basename( __FILE__ ) . '#', $_SERVER['PHP_SELF'] ) ) {
|
|
8 |
*
|
9 |
* @return mixed content
|
10 |
*/
|
11 |
-
function gmediaTerms()
|
12 |
global $user_ID, $gmDB, $gmCore, $gmGallery, $gmProcessor;
|
13 |
|
14 |
-
$url = add_query_arg(
|
|
|
15 |
|
16 |
-
/* todo: per_page options for gmedia_terms
|
17 |
$gm_screen_options = get_user_meta($user_ID, 'gm_screen_options', true);
|
18 |
if(!is_array($gm_screen_options)){
|
19 |
$gm_screen_options = array();
|
20 |
}
|
21 |
$gm_screen_options = array_merge($gmGallery->options['gm_screen_options'], $gm_screen_options);
|
22 |
-
|
23 |
-
|
24 |
-
$
|
25 |
-
|
26 |
-
$
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
);
|
36 |
-
$args['offset'] = (
|
37 |
|
38 |
-
$taxonomy = $gmCore->_get(
|
39 |
|
40 |
$allow_edit = 0;
|
41 |
-
switch
|
42 |
case 'gmedia_album':
|
43 |
-
$allow_edit
|
44 |
-
$args['global'] = $gmCore->_get(
|
45 |
-
if
|
46 |
-
$args['global'] = wp_parse_id_list(
|
47 |
-
$args['global'] = array_intersect(
|
48 |
-
if
|
49 |
-
$args['global'] = array(
|
50 |
}
|
51 |
}
|
52 |
-
if ( ! $gmCore->caps['gmedia_edit_others_media'] ) {
|
53 |
-
$args['orderby'] = $gmCore->_get( 'orderby', 'global_desc_name' );
|
54 |
-
}
|
55 |
break;
|
56 |
case 'gmedia_tag':
|
57 |
$allow_edit = $gmCore->caps['gmedia_tag_manage'];
|
|
|
|
|
|
|
58 |
break;
|
59 |
case 'gmedia_category':
|
60 |
-
$args
|
61 |
-
$args['offset'] = '';
|
62 |
-
$args['search'] = '';
|
63 |
-
$args['include'] = null;
|
64 |
break;
|
65 |
}
|
66 |
-
|
67 |
-
$gmediaTerms = $gmDB->get_terms( $taxonomy, $args );
|
68 |
|
69 |
?>
|
70 |
<div class="panel panel-default" id="gmedia-panel">
|
71 |
-
|
72 |
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
<span class="btn btn-default active"><input class="doaction" id="cb_global"
|
92 |
data-group="cb_term-object" type="checkbox"/></span>
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
</div>
|
106 |
-
<?php } ?>
|
107 |
-
|
108 |
-
<div class="btn-group" style="margin-right:20px;">
|
109 |
-
<a class="btn btn<?php echo ( 'gmedia_album' == $taxonomy ) ? "-primary active" : '-default'; ?>"
|
110 |
-
href="<?php echo add_query_arg( array( 'term' => 'gmedia_album' ), $url ); ?>"><?php _e( 'Albums', 'gmLang' ); ?></a>
|
111 |
-
<a class="btn btn<?php echo ( 'gmedia_tag' == $taxonomy ) ? "-primary active" : '-default'; ?>"
|
112 |
-
href="<?php echo add_query_arg( array( 'term' => 'gmedia_tag' ), $url ); ?>"><?php _e( 'Tags', 'gmLang' ); ?></a>
|
113 |
-
<a class="btn btn<?php echo ( 'gmedia_category' == $taxonomy ) ? "-primary active" : '-default'; ?>"
|
114 |
-
href="<?php echo add_query_arg( array( 'term' => 'gmedia_category' ), $url ); ?>"><?php _e( 'Categories', 'gmLang' ); ?></a>
|
115 |
</div>
|
|
|
116 |
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
$rel_selected_show = 'rel-selected-show';
|
126 |
-
$rel_selected_hide = 'rel-selected-hide';
|
127 |
-
?>
|
128 |
-
<ul class="dropdown-menu" role="menu">
|
129 |
-
<li class="dropdown-header <?php echo $rel_selected_hide; ?>">
|
130 |
-
<span><?php _e( "Select items to see more actions", "gmLang" ); ?></span></li>
|
131 |
-
<li class="<?php echo $rel_selected_show;
|
132 |
-
if ( ! $gmCore->caps['gmedia_terms_delete'] ) {
|
133 |
-
echo ' disabled';
|
134 |
-
} ?>">
|
135 |
-
<a href="<?php echo wp_nonce_url( $gmCore->get_admin_url( array( 'delete' => 'selected' ), array( 'filter' ) ), 'gmedia_delete' ) ?>"
|
136 |
-
class="gmedia-delete"
|
137 |
-
data-confirm="<?php _e( "You are about to permanently delete the selected items.\n\r'Cancel' to stop, 'OK' to delete.", "gmLang" ); ?>"><?php _e( 'Delete Selected Items', 'gmLang' ); ?></a>
|
138 |
-
</li>
|
139 |
-
<?php do_action( 'gmedia_term_action_list' ); ?>
|
140 |
-
</ul>
|
141 |
-
</div>
|
142 |
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
<
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
|
165 |
-
</div>
|
166 |
</div>
|
|
|
167 |
|
168 |
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
<textarea class="form-control input-sm" style="height:75px;" rows="2"
|
183 |
name="term[description]"></textarea>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
</div>
|
185 |
</div>
|
186 |
-
<div class="
|
187 |
-
<div class="form-group
|
188 |
-
<
|
189 |
-
|
190 |
-
<
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
<option value="date"><?php _e( 'by date', 'gmLang' ); ?></option>
|
195 |
-
<option value="modified"><?php _e( 'by last modified date', 'gmLang' ); ?></option>
|
196 |
-
<option value="rand"><?php _e( 'Random', 'gmLang' ); ?></option>
|
197 |
-
</select>
|
198 |
-
</div>
|
199 |
-
<div class="col-xs-6">
|
200 |
-
<label><?php _e( 'Sort order', 'gmLang' ); ?></label>
|
201 |
-
<select name="term[order]" class="form-control input-sm">
|
202 |
-
<option value="ASC"><?php _e( 'ASC', 'gmLang' ); ?></option>
|
203 |
-
<option selected="selected" value="DESC"><?php _e( 'DESC', 'gmLang' ); ?></option>
|
204 |
-
</select>
|
205 |
-
</div>
|
206 |
</div>
|
207 |
-
<div class="
|
208 |
-
<div class="form-group
|
209 |
-
<label><?php _e(
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
</select>
|
215 |
-
</div>
|
216 |
-
<div class="col-xs-6">
|
217 |
-
<div class="form-group">
|
218 |
-
<label><?php _e( 'Author', 'gmLang' ); ?></label>
|
219 |
-
<?php $user_ids = $gmCore->caps['gmedia_delete_others_media'] ? $gmCore->get_editable_user_ids() : array( $user_ID );
|
220 |
-
if ( $user_ids && $gmCore->caps['gmedia_edit_others_media'] ) {
|
221 |
-
if ( ! in_array( $user_ID, $user_ids ) ) {
|
222 |
-
array_push( $user_ids, $user_ID );
|
223 |
-
}
|
224 |
-
wp_dropdown_users( array(
|
225 |
-
'include' => $user_ids,
|
226 |
-
'include_selected' => true,
|
227 |
-
'name' => 'term[global]',
|
228 |
-
'selected' => $user_ID,
|
229 |
-
'class' => 'form-control input-sm',
|
230 |
-
'multi' => true,
|
231 |
-
'show_option_all' => __( 'Shared', 'gmLang' )
|
232 |
-
) );
|
233 |
-
} else {
|
234 |
-
echo '<input type="hidden" name="term[global]" value="' . $user_ID . '"/>';
|
235 |
-
echo '<div>' . get_the_author_meta( 'display_name', $user_ID ) . '</div>';
|
236 |
}
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
</div>
|
249 |
</div>
|
250 |
</div>
|
251 |
</div>
|
252 |
-
</form>
|
253 |
-
<?php } else { ?>
|
254 |
-
<div class="alert alert-warning alert-dismissible" role="alert" style="margin-bottom:0">
|
255 |
-
<button type="button" class="close" data-dismiss="alert">
|
256 |
-
<span aria-hidden="true">×</span><span class="sr-only"><?php _e( 'Close', 'gmLang' ); ?></span>
|
257 |
-
</button>
|
258 |
-
<strong><?php _e( 'Info:', 'gmLang' ); ?></strong> <?php _e( 'You are not allowed to add new terms', 'gmLang' ); ?>
|
259 |
</div>
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
270 |
}
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
$row_class .= ' current_user';
|
278 |
-
$allow_edit = $gmCore->caps['gmedia_album_manage'];
|
279 |
-
} else {
|
280 |
-
$row_class .= ' other_user';
|
281 |
-
$allow_edit = $gmCore->caps['gmedia_edit_others_media'];
|
282 |
-
}
|
283 |
-
} else {
|
284 |
-
$author_name .= '(' . __( 'shared', 'gmLang' ) . ')';
|
285 |
-
$row_class .= ' shared';
|
286 |
$allow_edit = $gmCore->caps['gmedia_edit_others_media'];
|
|
|
287 |
}
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
|
|
|
|
|
|
|
|
|
|
295 |
}
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
<span class="
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
|
|
|
|
332 |
}
|
333 |
-
|
334 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
335 |
}
|
336 |
?>
|
337 |
</div>
|
338 |
</div>
|
339 |
</div>
|
340 |
-
|
341 |
-
<div class="term-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
351 |
</div>
|
|
|
|
|
|
|
352 |
</div>
|
353 |
-
<?php } ?>
|
354 |
<?php
|
355 |
-
|
356 |
-
|
357 |
?>
|
358 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
359 |
|
360 |
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
</div>
|
383 |
</div>
|
384 |
-
</form>
|
385 |
-
<?php } else { ?>
|
386 |
-
<div class="alert alert-warning alert-dismissible" role="alert" style="margin-bottom:0">
|
387 |
-
<button type="button" class="close" data-dismiss="alert">
|
388 |
-
<span aria-hidden="true">×</span><span class="sr-only"><?php _e( 'Close', 'gmLang' ); ?></span>
|
389 |
-
</button>
|
390 |
-
<strong><?php _e( 'Info:', 'gmLang' ); ?></strong> <?php _e( 'You are not allowed to add new terms', 'gmLang' ); ?>
|
391 |
</div>
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
$
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
?>
|
446 |
-
<img style="z-index:<?php echo $per_page --; ?>;"
|
447 |
-
src="<?php echo $gmCore->gm_get_media_image( $i, 'thumb', false ); ?>"
|
448 |
-
alt="<?php echo $i->ID; ?>" title="<?php echo esc_attr( $i->title ); ?>"/>
|
449 |
<?php
|
|
|
|
|
|
|
|
|
|
|
450 |
}
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
456 |
</div>
|
457 |
</div>
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
var charCode = e.charCode || e.keyCode || e.which;
|
467 |
-
if (charCode == 13) {
|
468 |
-
e.preventDefault();
|
469 |
-
edit_tag(tagdiv);
|
470 |
}
|
471 |
-
}
|
472 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
473 |
edit_tag(tagdiv);
|
474 |
-
}
|
|
|
|
|
|
|
|
|
475 |
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
493 |
tagdiv.find('.edit_tag_form').hide();
|
494 |
-
tagdiv.find('.edit_tag_link').show();
|
495 |
-
return;
|
496 |
}
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
} else {
|
509 |
-
//new_tag_name = new_tag_name.replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
|
510 |
-
inp.attr('placeholder', new_tag_name);
|
511 |
-
tagdiv.find('.edit_tag_link').text(new_tag_name).show();
|
512 |
-
$('#gmedia-panel').before(data.msg);
|
513 |
-
tagdiv.find('.edit_tag_form').hide();
|
514 |
-
}
|
515 |
-
});
|
516 |
-
}
|
517 |
-
});
|
518 |
-
</script>
|
519 |
-
<?php } ?>
|
520 |
-
<?php
|
521 |
-
} else {
|
522 |
-
?>
|
523 |
-
<div class="list-group-item">
|
524 |
-
<div class="well well-lg text-center">
|
525 |
-
<h4><?php _e( 'No items to show.', 'gmLang' ); ?></h4>
|
526 |
-
</div>
|
527 |
</div>
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
|
|
534 |
|
535 |
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
}
|
556 |
-
} else {
|
557 |
-
$count = 0;
|
558 |
-
$term_id = '##';
|
559 |
}
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
<?php
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
foreach ( $termItems as $i ) {
|
578 |
-
?>
|
579 |
-
<img style="z-index:<?php echo $per_page --; ?>;"
|
580 |
-
src="<?php echo $gmCore->gm_get_media_image( $i, 'thumb', false ); ?>"
|
581 |
-
alt="<?php echo $i->ID; ?>" title="<?php echo esc_attr( $i->title ); ?>"/>
|
582 |
-
<?php
|
583 |
-
}
|
584 |
}
|
585 |
-
|
586 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
587 |
}
|
|
|
|
|
|
|
|
|
|
|
588 |
?>
|
589 |
</div>
|
590 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
591 |
</div>
|
592 |
-
|
593 |
-
|
594 |
-
|
|
|
595 |
|
596 |
</div>
|
597 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
598 |
<?php
|
599 |
}
|
600 |
|
@@ -604,42 +737,47 @@ function gmediaTerms() {
|
|
604 |
*
|
605 |
* @return mixed content
|
606 |
*/
|
607 |
-
function gmediaAlbumEdit()
|
608 |
-
global $gmDB, $gmCore, $gmProcessor, $user_ID;
|
609 |
|
610 |
-
if
|
611 |
-
die(
|
612 |
}
|
613 |
|
614 |
-
$url = add_query_arg(
|
|
|
|
|
|
|
|
|
|
|
|
|
615 |
|
616 |
$taxonomy = 'gmedia_album';
|
617 |
-
$term_id
|
618 |
|
619 |
-
$term = $gmDB->get_term(
|
620 |
|
621 |
-
if
|
622 |
|
623 |
-
$term_meta = $gmDB->get_metadata(
|
624 |
-
$term_meta = array_map(
|
625 |
-
$term_meta = array_merge(
|
626 |
-
$per_page
|
627 |
-
$
|
628 |
-
$
|
629 |
|
630 |
$termItems = array();
|
631 |
-
if
|
632 |
-
$args = array(
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
|
|
639 |
|
640 |
-
|
641 |
-
$pager = $gmDB->query_pager();
|
642 |
-
}
|
643 |
}
|
644 |
|
645 |
?>
|
@@ -647,238 +785,265 @@ function gmediaAlbumEdit() {
|
|
647 |
<div class="panel-heading clearfix">
|
648 |
<div class="btn-toolbar pull-left">
|
649 |
<div class="btn-group" style="margin-right:20px;">
|
650 |
-
<a class="btn btn-primary active" href="<?php echo add_query_arg(
|
651 |
-
<a class="btn btn-default" href="<?php echo add_query_arg(
|
652 |
-
<a class="btn btn-default" href="<?php echo add_query_arg(
|
653 |
</div>
|
654 |
|
655 |
<div class="btn-group">
|
656 |
-
<a class="btn btn-default" href="#"><?php _e(
|
657 |
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
|
658 |
<span class="caret"></span>
|
659 |
-
<span class="sr-only"><?php _e(
|
660 |
</button>
|
661 |
<ul class="dropdown-menu" role="menu">
|
662 |
-
<?php
|
663 |
-
<li>
|
664 |
-
<a href="<?php echo $gmCore->get_admin_url( array(), array( 'sort' ) ); ?>"><?php _e( 'Disable Drag and Drop Sorting', 'gmLang' ); ?></a>
|
665 |
-
</li>
|
666 |
-
<?php } else { ?>
|
667 |
-
<li>
|
668 |
-
<a href="<?php echo $gmCore->get_admin_url( array( 'sort' => 'drag-n-drop' ), array( 'pager' ) ); ?>"><?php _e( 'Enable Drag and Drop Sorting', 'gmLang' ); ?></a>
|
669 |
-
</li>
|
670 |
-
<?php } ?>
|
671 |
-
<li><a href="<?php echo add_query_arg( array(
|
672 |
'page' => 'GrandMedia',
|
673 |
-
'alb'
|
674 |
-
), admin_url(
|
675 |
</li>
|
676 |
</ul>
|
677 |
</div>
|
678 |
</div>
|
679 |
|
680 |
-
<?php echo $pager; ?>
|
681 |
-
|
682 |
</div>
|
683 |
|
684 |
<form method="post" id="gmedia-edit-term" name="gmEditTerm" class="panel-body">
|
685 |
<h4 style="margin-top:0;">
|
686 |
-
<span class="pull-right"><?php echo __(
|
687 |
-
<?php _e(
|
688 |
</h4>
|
689 |
|
690 |
-
<div class="row"
|
691 |
<div class="col-xs-6">
|
692 |
<div class="form-group">
|
693 |
-
<label><?php _e(
|
694 |
<input type="text" class="form-control input-sm" name="term[name]"
|
695 |
-
value="<?php echo esc_attr(
|
696 |
-
placeholder="<?php _e(
|
697 |
</div>
|
698 |
<div class="form-group">
|
699 |
-
<label><?php _e(
|
700 |
<textarea class="form-control input-sm" style="height:53px;" rows="2"
|
701 |
name="term[description]"><?php echo $term->description; ?></textarea>
|
702 |
</div>
|
703 |
</div>
|
704 |
<div class="col-xs-6">
|
705 |
-
<div class="form-group row">
|
706 |
-
<div class="col-xs-6">
|
707 |
-
<label><?php _e( 'Order gmedia', 'gmLang' ); ?></label>
|
708 |
-
<select name="term[orderby]" class="form-control input-sm">
|
709 |
-
<option
|
710 |
-
value="custom"<?php selected( $term_meta['orderby'], 'custom' ); ?>><?php _e( 'user defined', 'gmLang' ); ?></option>
|
711 |
-
<option
|
712 |
-
value="ID"<?php selected( $term_meta['orderby'], 'ID' ); ?>><?php _e( 'by ID', 'gmLang' ); ?></option>
|
713 |
-
<option
|
714 |
-
value="title"<?php selected( $term_meta['orderby'], 'title' ); ?>><?php _e( 'by title', 'gmLang' ); ?></option>
|
715 |
-
<option
|
716 |
-
value="date"<?php selected( $term_meta['orderby'], 'date' ); ?>><?php _e( 'by date', 'gmLang' ); ?></option>
|
717 |
-
<option
|
718 |
-
value="modified"<?php selected( $term_meta['orderby'], 'modified' ); ?>><?php _e( 'by last modified date', 'gmLang' ); ?></option>
|
719 |
-
<option
|
720 |
-
value="rand"<?php selected( $term_meta['orderby'], 'rand' ); ?>><?php _e( 'Random', 'gmLang' ); ?></option>
|
721 |
-
</select>
|
722 |
-
</div>
|
723 |
-
<div class="col-xs-6">
|
724 |
-
<label><?php _e( 'Sort order', 'gmLang' ); ?></label>
|
725 |
-
<select name="term[order]" class="form-control input-sm">
|
726 |
-
<option
|
727 |
-
value="ASC"<?php selected( $term_meta['order'], 'ASC' ); ?>><?php _e( 'ASC', 'gmLang' ); ?></option>
|
728 |
-
<option
|
729 |
-
value="DESC"<?php selected( $term_meta['order'], 'DESC' ); ?>><?php _e( 'DESC', 'gmLang' ); ?></option>
|
730 |
-
</select>
|
731 |
-
</div>
|
732 |
-
</div>
|
733 |
<div class="row">
|
734 |
<div class="col-xs-6">
|
735 |
<div class="form-group">
|
736 |
-
<label><?php _e(
|
737 |
<select name="term[status]" class="form-control input-sm">
|
738 |
<option
|
739 |
-
value="public"<?php selected(
|
740 |
<option
|
741 |
-
value="private"<?php selected(
|
742 |
<option
|
743 |
-
value="draft"<?php selected(
|
744 |
</select>
|
745 |
</div>
|
746 |
<div class="form-group">
|
747 |
-
<div class="checkbox"><label><input type="checkbox" name="term[status_global]" value="1"> <?php _e(
|
748 |
</div>
|
749 |
</div>
|
750 |
<div class="col-xs-6">
|
751 |
<div class="form-group">
|
752 |
-
<label><?php _e(
|
753 |
-
<?php $user_ids = $gmCore->caps['gmedia_delete_others_media']
|
754 |
-
if
|
755 |
-
if
|
756 |
-
array_push(
|
757 |
}
|
758 |
-
|
759 |
-
|
|
|
760 |
'include_selected' => true,
|
761 |
-
'name'
|
762 |
-
'selected'
|
763 |
-
'class'
|
764 |
-
'multi'
|
765 |
-
'show_option_all'
|
766 |
-
)
|
767 |
-
} else
|
768 |
echo '<input type="hidden" name="term[global]" value="' . $user_ID . '"/>';
|
769 |
-
echo '<div>' . get_the_author_meta(
|
770 |
}
|
771 |
?>
|
772 |
</div>
|
773 |
<div class="form-group">
|
774 |
-
<?php wp_nonce_field(
|
775 |
<input type="hidden" name="term[term_id]" value="<?php echo $term->term_id; ?>"/>
|
776 |
<input type="hidden" name="term[taxonomy]" value="gmedia_album"/>
|
777 |
<button style="display:block" type="submit" class="btn btn-primary btn-sm"
|
778 |
-
name="gmedia_album_save"><?php _e(
|
779 |
</div>
|
780 |
</div>
|
781 |
</div>
|
782 |
</div>
|
783 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
784 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
785 |
<div class="termItems clearfix" id="termItems">
|
786 |
-
<?php if
|
787 |
-
foreach
|
788 |
?>
|
789 |
<div class="gm-img-thumbnail" data-gmid="<?php echo $item->ID; ?>"><?php
|
|
|
|
|
|
|
790 |
?>
|
791 |
-
<
|
792 |
-
|
793 |
-
?>
|
794 |
-
<input type="text" name="term[gmedia_ids][<?php echo $item->ID; ?>]"
|
795 |
-
value="<?php echo isset( $item->gmedia_order ) ? $item->gmedia_order : '0'; ?>"/><?php
|
796 |
-
?><span class="label label-default">ID: <?php echo $item->ID; ?></span></div>
|
797 |
<?php
|
798 |
}
|
799 |
} ?>
|
800 |
|
801 |
</div>
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
e.preventDefault();
|
808 |
-
var nextInput = inputs.get(inputs.index(this) + 1);
|
809 |
-
if (nextInput) {
|
810 |
-
nextInput.focus();
|
811 |
-
} else {
|
812 |
-
$(this).blur();
|
813 |
-
}
|
814 |
-
}
|
815 |
-
});
|
816 |
-
|
817 |
-
var img_order_asc = <?php echo ('ASC' == $term_meta['order'])? 'true' : 'false'; ?>;
|
818 |
-
var sortdiv = $('#termItems');
|
819 |
-
var items = $('.gm-img-thumbnail', sortdiv);
|
820 |
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
placeholder: 'gm-img-thumbnail ui-highlight-placeholder',
|
826 |
-
forcePlaceholderSize: true,
|
827 |
-
//revert: true,
|
828 |
-
stop: function (event, ui) {
|
829 |
-
items = $('.gm-img-thumbnail', this);
|
830 |
-
var qty = items.length - 1;
|
831 |
-
items.each(function (i) {
|
832 |
-
var order = img_order_asc ? i : (qty - i);
|
833 |
-
$(this).find('input').val(order);
|
834 |
-
});
|
835 |
-
}
|
836 |
-
});
|
837 |
|
838 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
839 |
|
840 |
-
|
841 |
-
|
842 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
843 |
|
844 |
-
|
845 |
-
|
|
|
|
|
846 |
|
847 |
-
|
848 |
-
|
849 |
-
var pos = $(el).position();
|
850 |
-
$.data(el, 'pos', pos);
|
851 |
-
ipos[i] = pos;
|
852 |
-
});
|
853 |
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
var to = ipos[i];
|
861 |
-
$(el).css({position: 'absolute', top: from.top, left: from.left}).animate({
|
862 |
-
top: to.top,
|
863 |
-
left: to.left
|
864 |
-
}, 500);
|
865 |
-
}).promise().done(function () {
|
866 |
-
items.removeAttr('style');
|
867 |
-
sortdiv.removeAttr('style');
|
868 |
-
});
|
869 |
|
870 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
871 |
});
|
|
|
|
|
872 |
});
|
873 |
-
|
874 |
-
</
|
875 |
-
|
876 |
-
<div class="well well-sm pull-left"
|
877 |
-
style="margin:0;"><?php printf( __( 'Total items: %d' ), $term->count ); ?></div>
|
878 |
-
</div>
|
879 |
</div>
|
880 |
<?php
|
881 |
-
} else
|
882 |
|
883 |
}
|
884 |
}
|
1 |
<?php
|
2 |
+
if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])){
|
3 |
+
die('You are not allowed to call this page directly.');
|
4 |
}
|
5 |
|
6 |
/**
|
8 |
*
|
9 |
* @return mixed content
|
10 |
*/
|
11 |
+
function gmediaTerms(){
|
12 |
global $user_ID, $gmDB, $gmCore, $gmGallery, $gmProcessor;
|
13 |
|
14 |
+
$url = add_query_arg(array('page' => $gmProcessor->page), admin_url('admin.php'));
|
15 |
+
$endpoint = $gmGallery->options['endpoint'];
|
16 |
|
|
|
17 |
$gm_screen_options = get_user_meta($user_ID, 'gm_screen_options', true);
|
18 |
if(!is_array($gm_screen_options)){
|
19 |
$gm_screen_options = array();
|
20 |
}
|
21 |
$gm_screen_options = array_merge($gmGallery->options['gm_screen_options'], $gm_screen_options);
|
22 |
+
$orderby = !empty($gm_screen_options['orderby_gmedia_terms'])? $gm_screen_options['orderby_gmedia_terms'] : 'name';
|
23 |
+
$order = !empty($gm_screen_options['sortorder_gmedia_terms'])? $gm_screen_options['sortorder_gmedia_terms'] : 'ASC';
|
24 |
+
$per_page = !empty($gm_screen_options['per_page_gmedia_terms'])? $gm_screen_options['per_page_gmedia_terms'] : 30;
|
25 |
+
|
26 |
+
$author = $gmCore->caps['gmedia_show_others_media']? 0 : $user_ID;
|
27 |
+
|
28 |
+
$filter = ('selected' == $gmCore->_req('filter'))? $gmProcessor->selected_items : null;
|
29 |
+
$search_string = $gmCore->_get('s', '');
|
30 |
+
if('#' == substr($search_string, 0, 1)){
|
31 |
+
$filter = substr($search_string, 1);
|
32 |
+
$search_string = '';
|
33 |
+
}
|
34 |
+
$args = array(
|
35 |
+
'orderby' => $gmCore->_get('orderby', $orderby),
|
36 |
+
'order' => $gmCore->_get('order', $order),
|
37 |
+
'search' => $search_string,
|
38 |
+
'number' => $gmCore->_get('number', $per_page),
|
39 |
+
'hide_empty' => $gmCore->_get('hide_empty', 0),
|
40 |
+
'page' => $gmCore->_get('pager', 1),
|
41 |
+
'include' => $filter
|
42 |
);
|
43 |
+
$args['offset'] = ($args['page'] - 1) * $args['number'];
|
44 |
|
45 |
+
$taxonomy = $gmCore->_get('term', 'gmedia_album');
|
46 |
|
47 |
$allow_edit = 0;
|
48 |
+
switch($taxonomy){
|
49 |
case 'gmedia_album':
|
50 |
+
$allow_edit = $gmCore->caps['gmedia_album_manage'];
|
51 |
+
$args['global'] = $gmCore->_get('author', $gmCore->caps['gmedia_edit_others_media']? '' : array(0, $user_ID));
|
52 |
+
if(!$gmCore->caps['gmedia_show_others_media']){
|
53 |
+
$args['global'] = wp_parse_id_list($args['global']);
|
54 |
+
$args['global'] = array_intersect(array(0, $user_ID), $args['global']);
|
55 |
+
if(empty($args['global'])){
|
56 |
+
$args['global'] = array(0, $user_ID);
|
57 |
}
|
58 |
}
|
|
|
|
|
|
|
59 |
break;
|
60 |
case 'gmedia_tag':
|
61 |
$allow_edit = $gmCore->caps['gmedia_tag_manage'];
|
62 |
+
if('global' == $args['orderby']){
|
63 |
+
$args['orderby'] = 'id';
|
64 |
+
}
|
65 |
break;
|
66 |
case 'gmedia_category':
|
67 |
+
$args = array();
|
|
|
|
|
|
|
68 |
break;
|
69 |
}
|
70 |
+
$gmediaTerms = $gmDB->get_terms($taxonomy, $args);
|
|
|
71 |
|
72 |
?>
|
73 |
<div class="panel panel-default" id="gmedia-panel">
|
74 |
+
<div class="panel-heading clearfix">
|
75 |
|
76 |
+
<?php if('gmedia_category' != $taxonomy){ ?>
|
77 |
+
<form class="form-inline gmedia-search-form" role="search" method="get">
|
78 |
+
<div class="form-group">
|
79 |
+
<input type="hidden" name="page" value="<?php echo $gmProcessor->page; ?>"/>
|
80 |
+
<input type="hidden" name="term" value="<?php echo $taxonomy; ?>"/>
|
81 |
+
<input id="gmedia-search" class="form-control input-sm" type="text" name="s"
|
82 |
+
placeholder="<?php _e('Search...', 'gmLang'); ?>"
|
83 |
+
value="<?php echo $gmCore->_get('s', ''); ?>"/>
|
84 |
+
</div>
|
85 |
+
<button type="submit" class="btn btn-default input-sm"><span class="glyphicon glyphicon-search"></span>
|
86 |
+
</button>
|
87 |
+
</form>
|
88 |
+
<?php echo $gmDB->query_pager(); ?>
|
89 |
+
<?php } ?>
|
90 |
|
91 |
+
<div class="btn-toolbar pull-left">
|
92 |
+
<?php if('gmedia_category' != $taxonomy){ ?>
|
93 |
+
<div class="btn-group gm-checkgroup" id="cb_global-btn">
|
94 |
<span class="btn btn-default active"><input class="doaction" id="cb_global"
|
95 |
data-group="cb_term-object" type="checkbox"/></span>
|
96 |
+
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
|
97 |
+
<span class="caret"></span>
|
98 |
+
<span class="sr-only"><?php _e('Toggle Dropdown', 'gmLang'); ?></span>
|
99 |
+
</button>
|
100 |
+
<ul class="dropdown-menu" role="menu">
|
101 |
+
<li><a data-select="total" href="#"><?php _e('All', 'gmLang'); ?></a></li>
|
102 |
+
<li><a data-select="none" href="#"><?php _e('None', 'gmLang'); ?></a></li>
|
103 |
+
<li class="divider"></li>
|
104 |
+
<li><a data-select="reverse" href="#"
|
105 |
+
title="<?php _e('Reverse only visible items', 'gmLang'); ?>"><?php _e('Reverse', 'gmLang'); ?></a>
|
106 |
+
</li>
|
107 |
+
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
</div>
|
109 |
+
<?php } ?>
|
110 |
|
111 |
+
<div class="btn-group" style="margin-right:20px;">
|
112 |
+
<a class="btn btn<?php echo ('gmedia_album' == $taxonomy)? "-primary active" : '-default'; ?>"
|
113 |
+
href="<?php echo add_query_arg(array('term' => 'gmedia_album'), $url); ?>"><?php _e('Albums', 'gmLang'); ?></a>
|
114 |
+
<a class="btn btn<?php echo ('gmedia_tag' == $taxonomy)? "-primary active" : '-default'; ?>"
|
115 |
+
href="<?php echo add_query_arg(array('term' => 'gmedia_tag'), $url); ?>"><?php _e('Tags', 'gmLang'); ?></a>
|
116 |
+
<a class="btn btn<?php echo ('gmedia_category' == $taxonomy)? "-primary active" : '-default'; ?>"
|
117 |
+
href="<?php echo add_query_arg(array('term' => 'gmedia_category'), $url); ?>"><?php _e('Categories', 'gmLang'); ?></a>
|
118 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
|
120 |
+
<?php if(('gmedia_category' != $taxonomy)){ ?>
|
121 |
+
<div class="btn-group">
|
122 |
+
<a class="btn btn-default" href="#"><?php _e('Action', 'gmLang'); ?></a>
|
123 |
+
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
|
124 |
+
<span class="caret"></span>
|
125 |
+
<span class="sr-only"><?php _e('Toggle Dropdown', 'gmLang'); ?></span>
|
126 |
+
</button>
|
127 |
+
<?php
|
128 |
+
$rel_selected_show = 'rel-selected-show';
|
129 |
+
$rel_selected_hide = 'rel-selected-hide';
|
130 |
+
?>
|
131 |
+
<ul class="dropdown-menu" role="menu">
|
132 |
+
<li class="dropdown-header <?php echo $rel_selected_hide; ?>">
|
133 |
+
<span><?php _e("Select items to see more actions", "gmLang"); ?></span></li>
|
134 |
+
<li class="<?php echo $rel_selected_show;
|
135 |
+
if(!$gmCore->caps['gmedia_terms_delete']){
|
136 |
+
echo ' disabled';
|
137 |
+
} ?>">
|
138 |
+
<a href="<?php echo wp_nonce_url($gmCore->get_admin_url(array('delete' => 'selected'), array('filter')), 'gmedia_delete') ?>"
|
139 |
+
class="gmedia-delete"
|
140 |
+
data-confirm="<?php _e("You are about to permanently delete the selected items.\n\r'Cancel' to stop, 'OK' to delete.", "gmLang"); ?>"><?php _e('Delete Selected Items', 'gmLang'); ?></a>
|
141 |
+
</li>
|
142 |
+
<?php do_action('gmedia_term_action_list'); ?>
|
143 |
+
</ul>
|
144 |
+
</div>
|
145 |
+
|
146 |
+
<form class="btn-group" id="gm-selected-btn" name="gm-selected-form"
|
147 |
+
action="<?php echo add_query_arg(array(
|
148 |
+
'term' => $taxonomy,
|
149 |
+
'filter' => 'selected'
|
150 |
+
), $url); ?>" method="post">
|
151 |
+
<button type="submit"
|
152 |
+
class="btn btn<?php echo ('selected' == $gmCore->_req('filter'))? '-success' : '-info' ?>"><?php printf(__('%s selected', 'gmLang'), '<span id="gm-selected-qty">' . count($gmProcessor->selected_items) . '</span>'); ?></button>
|
153 |
+
<button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown"><span
|
154 |
+
class="caret"></span>
|
155 |
+
<span class="sr-only"><?php _e('Toggle Dropdown', 'gmLang'); ?></span></button>
|
156 |
+
<input type="hidden" id="gm-selected" data-userid="<?php echo $user_ID; ?>"
|
157 |
+
data-key="<?php echo $taxonomy; ?>" name="selected_items"
|
158 |
+
value="<?php echo implode(',', $gmProcessor->selected_items); ?>"/>
|
159 |
+
<ul class="dropdown-menu" role="menu">
|
160 |
+
<li><a id="gm-selected-show" href="#show"><?php _e('Show only selected items', 'gmLang'); ?></a>
|
161 |
+
</li>
|
162 |
+
<li><a id="gm-selected-clear" href="#clear"><?php _e('Clear selected items', 'gmLang'); ?></a>
|
163 |
+
</li>
|
164 |
+
</ul>
|
165 |
+
</form>
|
166 |
+
<?php } ?>
|
167 |
|
|
|
168 |
</div>
|
169 |
+
</div>
|
170 |
|
171 |
|
172 |
+
<?php if('gmedia_album' == $taxonomy){ ?>
|
173 |
+
<?php if($allow_edit){ ?>
|
174 |
+
<form method="post" id="gmedia-edit-term" name="gmAddTerms" class="panel-body" action="<?php echo $url; ?>"
|
175 |
+
style="padding-bottom:0; border-bottom:1px solid #ddd;">
|
176 |
+
<div class="row">
|
177 |
+
<div class="col-xs-6">
|
178 |
+
<div class="form-group">
|
179 |
+
<label><?php _e('Name', 'gmLang'); ?></label>
|
180 |
+
<input type="text" class="form-control input-sm" name="term[name]"
|
181 |
+
placeholder="<?php _e('Album Name', 'gmLang'); ?>" required/>
|
182 |
+
</div>
|
183 |
+
<div class="form-group">
|
184 |
+
<label><?php _e('Description', 'gmLang'); ?></label>
|
185 |
<textarea class="form-control input-sm" style="height:75px;" rows="2"
|
186 |
name="term[description]"></textarea>
|
187 |
+
</div>
|
188 |
+
</div>
|
189 |
+
<div class="col-xs-6">
|
190 |
+
<div class="form-group row">
|
191 |
+
<div class="col-xs-6">
|
192 |
+
<label><?php _e('Order gmedia', 'gmLang'); ?></label>
|
193 |
+
<select name="term[orderby]" class="form-control input-sm">
|
194 |
+
<option value="custom"><?php _e('user defined', 'gmLang'); ?></option>
|
195 |
+
<option selected="selected" value="ID"><?php _e('by ID', 'gmLang'); ?></option>
|
196 |
+
<option value="title ID"><?php _e('by title', 'gmLang'); ?></option>
|
197 |
+
<option value="gmuid"><?php _e('by filename', 'gmLang'); ?></option>
|
198 |
+
<option value="date ID"><?php _e('by date', 'gmLang'); ?></option>
|
199 |
+
<option value="modified ID"><?php _e('by last modified date', 'gmLang'); ?></option>
|
200 |
+
<option value="rand"><?php _e('Random', 'gmLang'); ?></option>
|
201 |
+
</select>
|
202 |
+
</div>
|
203 |
+
<div class="col-xs-6">
|
204 |
+
<label><?php _e('Sort order', 'gmLang'); ?></label>
|
205 |
+
<select name="term[order]" class="form-control input-sm">
|
206 |
+
<option selected="selected" value="DESC"><?php _e('DESC', 'gmLang'); ?></option>
|
207 |
+
<option value="ASC"><?php _e('ASC', 'gmLang'); ?></option>
|
208 |
+
</select>
|
209 |
</div>
|
210 |
</div>
|
211 |
+
<div class="row">
|
212 |
+
<div class="form-group col-xs-6">
|
213 |
+
<label><?php _e('Status', 'gmLang'); ?></label>
|
214 |
+
<select name="term[status]" class="form-control input-sm">
|
215 |
+
<option selected="selected" value="public"><?php _e('Public', 'gmLang'); ?></option>
|
216 |
+
<option value="private"><?php _e('Private', 'gmLang'); ?></option>
|
217 |
+
<option value="draft"><?php _e('Draft', 'gmLang'); ?></option>
|
218 |
+
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
</div>
|
220 |
+
<div class="col-xs-6">
|
221 |
+
<div class="form-group">
|
222 |
+
<label><?php _e('Author', 'gmLang'); ?></label>
|
223 |
+
<?php $user_ids = $gmCore->caps['gmedia_delete_others_media']? $gmCore->get_editable_user_ids() : array($user_ID);
|
224 |
+
if($user_ids && $gmCore->caps['gmedia_edit_others_media']){
|
225 |
+
if(!in_array($user_ID, $user_ids)){
|
226 |
+
array_push($user_ids, $user_ID);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
}
|
228 |
+
wp_dropdown_users(array(
|
229 |
+
'include' => $user_ids,
|
230 |
+
'include_selected' => true,
|
231 |
+
'name' => 'term[global]',
|
232 |
+
'selected' => $user_ID,
|
233 |
+
'class' => 'form-control input-sm',
|
234 |
+
'multi' => true,
|
235 |
+
'show_option_all' => __('Shared', 'gmLang')
|
236 |
+
));
|
237 |
+
} else{
|
238 |
+
echo '<input type="hidden" name="term[global]" value="' . $user_ID . '"/>';
|
239 |
+
echo '<div>' . get_the_author_meta('display_name', $user_ID) . '</div>';
|
240 |
+
}
|
241 |
+
?>
|
242 |
+
</div>
|
243 |
+
<div class="form-group">
|
244 |
+
<?php
|
245 |
+
wp_original_referer_field(true, 'previous');
|
246 |
+
wp_nonce_field('GmediaTerms', 'term_save_wpnonce');
|
247 |
+
?>
|
248 |
+
<input type="hidden" name="term[taxonomy]" value="gmedia_album"/>
|
249 |
+
<button style="display:block" type="submit" class="btn btn-primary btn-sm"
|
250 |
+
name="gmedia_album_save"><?php _e('Add New Album', 'gmLang'); ?></button>
|
251 |
</div>
|
252 |
</div>
|
253 |
</div>
|
254 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
</div>
|
256 |
+
</form>
|
257 |
+
<?php } else{ ?>
|
258 |
+
<div class="alert alert-warning alert-dismissible" role="alert" style="margin-bottom:0">
|
259 |
+
<button type="button" class="close" data-dismiss="alert">
|
260 |
+
<span aria-hidden="true">×</span><span class="sr-only"><?php _e('Close', 'gmLang'); ?></span>
|
261 |
+
</button>
|
262 |
+
<strong><?php _e('Info:', 'gmLang'); ?></strong> <?php _e('You are not allowed to add new terms', 'gmLang'); ?>
|
263 |
+
</div>
|
264 |
+
<?php } ?>
|
265 |
+
<form class="list-group" id="gm-list-table" style="margin-bottom:4px;">
|
266 |
+
<?php
|
267 |
+
if(count($gmediaTerms)){
|
268 |
+
foreach($gmediaTerms as $item){
|
269 |
+
$termItems = array();
|
270 |
+
$per_page = 7;
|
271 |
+
if($item->count){
|
272 |
+
$term_meta = $gmDB->get_metadata('gmedia_term', $item->term_id);
|
273 |
+
$term_meta = array_map('reset', $term_meta);
|
274 |
+
$term_meta = array_merge(array('orderby' => 'ID', 'order' => 'DESC'), $term_meta);
|
275 |
+
/*
|
276 |
+
$term_meta_default = array('orderby' => 'ID', 'order' => 'DESC');
|
277 |
+
$term_meta = array_intersect_key($term_meta, $term_meta_default) + $term_meta_default;
|
278 |
+
*/
|
279 |
+
$args = array('no_found_rows' => true, 'per_page' => $per_page, 'album__in' => array($item->term_id), 'author' => $author, 'orderby' => $term_meta['orderby'], 'order' => $term_meta['order']);
|
280 |
+
$termItems = $gmDB->get_gmedias($args);
|
281 |
+
}
|
282 |
+
$is_selected = in_array($item->term_id, $gmProcessor->selected_items)? true : false;
|
283 |
+
$author_name = '';
|
284 |
+
$list_row_class = $row_class = '';
|
285 |
+
$allow_terms_delete = $gmCore->caps['gmedia_terms_delete'];
|
286 |
+
if($item->global){
|
287 |
+
if(($display_author_name = get_the_author_meta('display_name', $item->global))){
|
288 |
+
$author_name .= sprintf(__('by %s', 'gmLang'), $display_author_name);
|
289 |
+
} else{
|
290 |
+
$author_name .= '(' . __('deleted author', 'gmLang') . ')';
|
291 |
}
|
292 |
+
if($item->global == $user_ID){
|
293 |
+
$row_class .= ' current_user';
|
294 |
+
$allow_edit = $gmCore->caps['gmedia_album_manage'];
|
295 |
+
$allow_delete = $allow_terms_delete;
|
296 |
+
} else{
|
297 |
+
$row_class .= ' other_user';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
298 |
$allow_edit = $gmCore->caps['gmedia_edit_others_media'];
|
299 |
+
$allow_delete = ($allow_edit && $allow_terms_delete);
|
300 |
}
|
301 |
+
} else{
|
302 |
+
$author_name .= '(' . __('no author', 'gmLang') . ')';
|
303 |
+
$row_class .= ' shared';
|
304 |
+
$allow_edit = $gmCore->caps['gmedia_edit_others_media'];
|
305 |
+
$allow_delete = ($allow_edit && $allow_terms_delete);
|
306 |
+
}
|
307 |
+
if('public' != $item->status){
|
308 |
+
$author_name .= ' [' . $item->status . ']';
|
309 |
+
if('private' == $item->status){
|
310 |
+
$list_row_class = ' list-group-item-info';
|
311 |
+
} elseif('draft' == $item->status){
|
312 |
+
$list_row_class = ' list-group-item-warning';
|
313 |
}
|
314 |
+
}
|
315 |
+
?>
|
316 |
+
<div class="list-group-item term-list-item<?php echo $is_selected? ' active-row' : '';
|
317 |
+
echo $list_row_class; ?>">
|
318 |
+
<div class="row cb_term-object<?php echo $row_class; ?>">
|
319 |
+
<div class="term_id">#<?php echo $item->term_id; ?></div>
|
320 |
+
<div class="col-xs-6 term-label">
|
321 |
+
<div class="checkbox">
|
322 |
+
<input name="doaction[]"
|
323 |
+
type="checkbox"<?php echo $is_selected? ' checked="checked"' : ''; ?>
|
324 |
+
value="<?php echo $item->term_id; ?>"/>
|
325 |
+
<?php if($allow_edit){ ?>
|
326 |
+
<a class="term_name" href="<?php echo add_query_arg(array('edit_album' => $item->term_id), $url); ?>"><?php echo esc_html($item->name); ?></a>
|
327 |
+
<?php } else{ ?>
|
328 |
+
<span class="term_name"><?php echo esc_html($item->name); ?></span>
|
329 |
+
<?php } ?>
|
330 |
+
<span class="term_info_author"><?php echo $author_name; ?></span>
|
331 |
+
|
332 |
+
<div class="object-actions">
|
333 |
+
<?php
|
334 |
+
$filter_icon = '<span class="badge">' . $item->count . '</span>';
|
335 |
+
if($item->count){
|
336 |
+
echo '<a title="' . __('Filter in Gmedia Library', 'gmLang') . '" href="' . $gmCore->get_admin_url(array('page' => 'GrandMedia', 'alb' => $item->term_id), array(), true) . '">' . $filter_icon . '</a>';
|
337 |
+
} else{
|
338 |
+
echo $filter_icon;
|
339 |
+
}
|
340 |
+
|
341 |
+
$gmedia_hashid = gmedia_hash_id_encode($item->term_id, 'album');
|
342 |
+
if(get_option('permalink_structure')){
|
343 |
+
$cloud_link = home_url(urlencode($endpoint) . '/a/' . $gmedia_hashid);
|
344 |
+
} else{
|
345 |
+
$cloud_link = add_query_arg(array("$endpoint" => $gmedia_hashid, 't' => 'a'), home_url('index.php'));
|
346 |
+
}
|
347 |
+
$share_icon = '<span class="glyphicon glyphicon-share"></span>';
|
348 |
+
if('draft' !== $item->status){
|
349 |
+
echo '<a target="_blank" data-target="#shareModal" data-share="' . $item->term_id . '" class="share-modal" title="' . __('Share', 'gmLang') . '" href="' . $cloud_link . '">' . $share_icon . '</a>';
|
350 |
+
} else{
|
351 |
+
echo "<span class='action-inactive'>$share_icon</span>";
|
352 |
}
|
353 |
+
|
354 |
+
$edit_icon = '<span class="glyphicon glyphicon-edit"></span>';
|
355 |
+
if($allow_edit){
|
356 |
+
echo '<a title="' . __('Edit', 'gmLang') . '" href="' . add_query_arg(array('edit_album' => $item->term_id), $url) . '">' . $edit_icon . '</a>';
|
357 |
+
} else{
|
358 |
+
echo "<span class='action-inactive'>$edit_icon</span>";
|
359 |
+
}
|
360 |
+
|
361 |
+
if($allow_terms_delete){
|
362 |
+
$trash_icon = '<span class="glyphicon glyphicon-trash"></span>';
|
363 |
+
if($allow_delete){
|
364 |
+
echo '<a class="trash-icon" title="' . __('Delete', 'gmLang') . '" href="' . wp_nonce_url(add_query_arg(array(
|
365 |
+
'term' => $taxonomy,
|
366 |
+
'delete' => $item->term_id
|
367 |
+
), $url), 'gmedia_delete') . '" data-confirm="' . __("You are about to permanently delete the selected items.\n\r'Cancel' to stop, 'OK' to delete.", "gmLang") . '">' . $trash_icon . '</a>';
|
368 |
+
} else{
|
369 |
+
echo "<span class='action-inactive'>$trash_icon</span>";
|
370 |
+
}
|
371 |
}
|
372 |
?>
|
373 |
</div>
|
374 |
</div>
|
375 |
</div>
|
376 |
+
<div class="col-xs-6">
|
377 |
+
<div class="term-images">
|
378 |
+
<?php if(!empty($termItems)){
|
379 |
+
foreach($termItems as $i){
|
380 |
+
?>
|
381 |
+
<img style="z-index:<?php echo $per_page --; ?>;"
|
382 |
+
src="<?php echo $gmCore->gm_get_media_image($i, 'thumb', false); ?>"
|
383 |
+
alt="<?php echo $i->ID; ?>"
|
384 |
+
title="<?php echo esc_attr($i->title); ?>"/>
|
385 |
+
<?php
|
386 |
+
}
|
387 |
+
}
|
388 |
+
if(count($termItems) < $item->count){
|
389 |
+
echo '...';
|
390 |
+
}
|
391 |
+
?>
|
392 |
+
</div>
|
393 |
+
</div>
|
394 |
</div>
|
395 |
+
<?php if(!empty($item->description)){ ?>
|
396 |
+
<div class="term-description"><?php echo nl2br(esc_html($item->description)); ?></div>
|
397 |
+
<?php } ?>
|
398 |
</div>
|
|
|
399 |
<?php
|
400 |
+
}
|
401 |
+
} else{
|
402 |
?>
|
403 |
+
<div class="list-group-item">
|
404 |
+
<div class="well well-lg text-center">
|
405 |
+
<h4><?php _e('No items to show.', 'gmLang'); ?></h4>
|
406 |
+
</div>
|
407 |
+
</div>
|
408 |
+
<?php } ?>
|
409 |
+
<?php
|
410 |
+
wp_original_referer_field(true, 'previous');
|
411 |
+
wp_nonce_field('GmediaTerms');
|
412 |
+
?>
|
413 |
+
</form>
|
414 |
|
415 |
|
416 |
+
<?php } elseif('gmedia_tag' == $taxonomy){ ?>
|
417 |
+
<?php if($allow_edit){ ?>
|
418 |
+
<form method="post" id="gmedia-edit-term" name="gmAddTerms" class="panel-body" action="<?php echo add_query_arg(array('term' => $taxonomy), $url); ?>"
|
419 |
+
style="padding-bottom:0; border-bottom:1px solid #ddd;">
|
420 |
+
<div class="row">
|
421 |
+
<div class="form-group col-xs-9">
|
422 |
+
<label><?php _e('Tags', 'gmLang'); ?>
|
423 |
+
<small class="text-muted">(<?php _e('you can type multiple tags separated by comma') ?>)
|
424 |
+
</small>
|
425 |
+
</label>
|
426 |
+
<input type="text" class="form-control input-sm" name="term[name]"
|
427 |
+
placeholder="<?php _e('Tag Names', 'gmLang'); ?>" required/>
|
428 |
+
</div>
|
429 |
+
<div class="col-xs-3" style="padding-top:24px;">
|
430 |
+
<?php
|
431 |
+
wp_original_referer_field(true, 'previous');
|
432 |
+
wp_nonce_field('GmediaTerms', 'term_save_wpnonce');
|
433 |
+
?>
|
434 |
+
<input type="hidden" name="term[taxonomy]" value="gmedia_tag"/>
|
435 |
+
<button type="submit" class="btn btn-primary btn-sm"
|
436 |
+
name="gmedia_tag_add"><?php _e('Add New Tags', 'gmLang'); ?></button>
|
|
|
437 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
438 |
</div>
|
439 |
+
</form>
|
440 |
+
<?php } else{ ?>
|
441 |
+
<div class="alert alert-warning alert-dismissible" role="alert" style="margin-bottom:0">
|
442 |
+
<button type="button" class="close" data-dismiss="alert">
|
443 |
+
<span aria-hidden="true">×</span><span class="sr-only"><?php _e('Close', 'gmLang'); ?></span>
|
444 |
+
</button>
|
445 |
+
<strong><?php _e('Info:', 'gmLang'); ?></strong> <?php _e('You are not allowed to add new terms', 'gmLang'); ?>
|
446 |
+
</div>
|
447 |
+
<?php } ?>
|
448 |
+
<form class="list-group" id="gm-list-table" style="margin-bottom:4px;">
|
449 |
+
<?php
|
450 |
+
if(count($gmediaTerms)){
|
451 |
+
if($gmCore->caps['gmedia_edit_others_media']){
|
452 |
+
$allow_edit = true;
|
453 |
+
$allow_delete = $gmCore->caps['gmedia_terms_delete'];
|
454 |
+
} else{
|
455 |
+
$allow_edit = false;
|
456 |
+
$allow_delete = false;
|
457 |
+
}
|
458 |
+
foreach($gmediaTerms as $item){
|
459 |
+
$termItems = array();
|
460 |
+
$per_page = 5;
|
461 |
+
if($item->count){
|
462 |
+
$args = array('no_found_rows' => true, 'per_page' => $per_page, 'orderby' => $gmGallery->options['in_tag_orderby'], 'order' => $gmGallery->options['in_tag_order'], 'tag_id' => $item->term_id, 'author' => $author);
|
463 |
+
$termItems = $gmDB->get_gmedias($args);
|
464 |
+
}
|
465 |
+
$is_selected = in_array($item->term_id, $gmProcessor->selected_items)? true : false;
|
466 |
+
?>
|
467 |
+
<div class="list-group-item term-list-item<?php echo $is_selected? ' active-row' : ''; ?>">
|
468 |
+
<div class="row cb_term-object" id="tag_<?php echo $item->term_id; ?>">
|
469 |
+
<div class="term_id">#<?php echo $item->term_id; ?></div>
|
470 |
+
<div class="col-xs-6 term-label">
|
471 |
+
<div class="checkbox">
|
472 |
+
<input name="doaction[]"
|
473 |
+
type="checkbox"<?php echo $is_selected? ' checked="checked"' : ''; ?>
|
474 |
+
value="<?php echo $item->term_id; ?>"/>
|
475 |
+
<?php if($allow_edit){ ?>
|
476 |
+
<a class="edit_tag_link"
|
477 |
+
href="#tag_<?php echo $item->term_id; ?>"><?php echo esc_html($item->name); ?></a>
|
478 |
+
<span class="edit_tag_form" style="display:none;"><input class="edit_tag_input"
|
479 |
+
type="text"
|
480 |
+
data-tag_id="<?php echo $item->term_id; ?>"
|
481 |
+
name="gmedia_tag_name[<?php echo $item->term_id; ?>]"
|
482 |
+
value="<?php echo esc_attr($item->name); ?>"
|
483 |
+
placeholder="<?php echo esc_attr($item->name); ?>"/><a
|
484 |
+
href="#tag_<?php echo $item->term_id; ?>"
|
485 |
+
class="edit_tag_save btn btn-link glyphicon glyphicon-pencil"></a></span>
|
486 |
+
|
487 |
+
<?php } else{ ?>
|
488 |
+
<span><?php echo esc_html($item->name); ?></span>
|
489 |
+
<?php } ?>
|
490 |
+
|
491 |
+
<div class="object-actions">
|
|
|
|
|
|
|
|
|
492 |
<?php
|
493 |
+
$filter_icon = '<span class="badge">' . $item->count . '</span>';
|
494 |
+
if($item->count){
|
495 |
+
echo '<a title="' . __('Filter in Gmedia Library', 'gmLang') . '" href="' . $gmCore->get_admin_url(array('page' => 'GrandMedia', 'tag__in' => $item->term_id), array(), true) . '">' . $filter_icon . '</a>';
|
496 |
+
} else{
|
497 |
+
echo $filter_icon;
|
498 |
}
|
499 |
+
|
500 |
+
$gmedia_hashid = gmedia_hash_id_encode($item->term_id, 'tag');
|
501 |
+
if(get_option('permalink_structure')){
|
502 |
+
$cloud_link = home_url(urlencode($endpoint) . '/t/' . $gmedia_hashid);
|
503 |
+
} else{
|
504 |
+
$cloud_link = add_query_arg(array("$endpoint" => $gmedia_hashid, 't' => 't'), home_url('index.php'));
|
505 |
+
}
|
506 |
+
$share_icon = '<span class="glyphicon glyphicon-share"></span>';
|
507 |
+
echo '<a target="_blank" data-target="#shareModal" data-share="' . $item->term_id . '" class="share-modal" title="' . __('Share', 'gmLang') . '" href="' . $cloud_link . '">' . $share_icon . '</a>';
|
508 |
+
|
509 |
+
/*
|
510 |
+
$edit_icon = '<span class="glyphicon glyphicon-edit"></span>';
|
511 |
+
if ( $allow_edit ){
|
512 |
+
echo '<a class="edit_tag_link" title="' . __('Edit', 'gmLang') . '" href="#tag_' . $item->term_id . '">'.$edit_icon.'</a>';
|
513 |
+
}
|
514 |
+
*/
|
515 |
+
|
516 |
+
if($allow_delete){
|
517 |
+
$trash_icon = '<span class="glyphicon glyphicon-trash"></span>';
|
518 |
+
echo '<a title="' . __('Delete', 'gmLang') . '" href="' . wp_nonce_url(add_query_arg(array(
|
519 |
+
'term' => $taxonomy,
|
520 |
+
'delete' => $item->term_id
|
521 |
+
), $url), 'gmedia_delete') . '">' . $trash_icon . '</a>';
|
522 |
+
}
|
523 |
+
?>
|
524 |
+
</div>
|
525 |
</div>
|
526 |
</div>
|
527 |
+
<div class="col-xs-6 term-images">
|
528 |
+
<?php if(!empty($termItems)){
|
529 |
+
foreach($termItems as $i){
|
530 |
+
?>
|
531 |
+
<img style="z-index:<?php echo $per_page --; ?>;"
|
532 |
+
src="<?php echo $gmCore->gm_get_media_image($i, 'thumb', false); ?>"
|
533 |
+
alt="<?php echo $i->ID; ?>" title="<?php echo esc_attr($i->title); ?>"/>
|
534 |
+
<?php
|
|
|
|
|
|
|
|
|
535 |
}
|
536 |
+
}
|
537 |
+
if(count($termItems) < $item->count){
|
538 |
+
echo '...';
|
539 |
+
}
|
540 |
+
?>
|
541 |
+
</div>
|
542 |
+
</div>
|
543 |
+
</div>
|
544 |
+
<?php } ?>
|
545 |
+
<?php if ($allow_edit){ ?>
|
546 |
+
<script type="text/javascript">
|
547 |
+
jQuery(function($){
|
548 |
+
$('#gm-list-table').data('edit', false);
|
549 |
+
$('input.edit_tag_input').keypress(function(e){
|
550 |
+
var tagdiv = $('#tag_' + $(this).data('tag_id'));
|
551 |
+
var charCode = e.charCode || e.keyCode || e.which;
|
552 |
+
if(charCode == 13){
|
553 |
+
e.preventDefault();
|
554 |
edit_tag(tagdiv);
|
555 |
+
}
|
556 |
+
}).blur(function(e){
|
557 |
+
var tagdiv = $('#tag_' + $(this).data('tag_id'));
|
558 |
+
edit_tag(tagdiv);
|
559 |
+
});
|
560 |
|
561 |
+
$('.edit_tag_link').click(function(e){
|
562 |
+
e.preventDefault();
|
563 |
+
var id = $(this).attr('href');
|
564 |
+
$(this).hide();
|
565 |
+
$(id).find('.edit_tag_form').show().find('input').focus();
|
566 |
+
$('#gm-list-table').data('edit', true);
|
567 |
+
});
|
568 |
+
$('.edit_tag_save').click(function(e){
|
569 |
+
e.preventDefault();
|
570 |
+
});
|
571 |
|
572 |
+
function edit_tag(tagdiv){
|
573 |
+
var inp = tagdiv.find('.edit_tag_form input');
|
574 |
+
var new_tag_name = $.trim(inp.val());
|
575 |
+
var old_tag_name = inp.attr('placeholder');
|
576 |
+
if((old_tag_name == new_tag_name) || ('' === new_tag_name) || $.isNumeric()){
|
577 |
+
inp.val(old_tag_name);
|
578 |
+
tagdiv.find('.edit_tag_form').hide();
|
579 |
+
tagdiv.find('.edit_tag_link').show();
|
580 |
+
return;
|
581 |
+
}
|
582 |
+
var post_data = {
|
583 |
+
action: 'gmedia_tag_edit',
|
584 |
+
tag_id: inp.data('tag_id'),
|
585 |
+
tag_name: new_tag_name,
|
586 |
+
_wpnonce: $('#_wpnonce').val()
|
587 |
+
};
|
588 |
+
$.post(ajaxurl, post_data, function(data, textStatus, jqXHR){
|
589 |
+
console.log(data);
|
590 |
+
if(data.error){
|
591 |
+
//inp.val(inp.attr('placeholder'));
|
592 |
+
$('#gmedia-panel').before(data.error);
|
593 |
+
} else{
|
594 |
+
//new_tag_name = new_tag_name.replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
|
595 |
+
inp.attr('placeholder', new_tag_name);
|
596 |
+
tagdiv.find('.edit_tag_link').text(new_tag_name).show();
|
597 |
+
$('#gmedia-panel').before(data.msg);
|
598 |
tagdiv.find('.edit_tag_form').hide();
|
|
|
|
|
599 |
}
|
600 |
+
});
|
601 |
+
}
|
602 |
+
});
|
603 |
+
</script>
|
604 |
+
<?php } ?>
|
605 |
+
<?php
|
606 |
+
} else {
|
607 |
+
?>
|
608 |
+
<div class="list-group-item">
|
609 |
+
<div class="well well-lg text-center">
|
610 |
+
<h4><?php _e('No items to show.', 'gmLang'); ?></h4>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
611 |
</div>
|
612 |
+
</div>
|
613 |
+
<?php } ?>
|
614 |
+
<?php
|
615 |
+
wp_original_referer_field(true, 'previous');
|
616 |
+
wp_nonce_field('GmediaTerms');
|
617 |
+
?>
|
618 |
+
</form>
|
619 |
|
620 |
|
621 |
+
<?php } elseif('gmedia_category' == $taxonomy){ ?>
|
622 |
+
<div class="panel-body"></div>
|
623 |
+
<div class="list-group" id="gm-list-table" style="margin-bottom:4px;">
|
624 |
+
<?php
|
625 |
+
$gmediaCategories = $gmGallery->options['taxonomies']['gmedia_category'];
|
626 |
+
foreach($gmediaTerms as $item){
|
627 |
+
$cat[$item->name] = $item;
|
628 |
+
}
|
629 |
+
unset($gmediaTerms);
|
630 |
|
631 |
+
foreach($gmediaCategories as $name => $title){
|
632 |
+
$termItems = array();
|
633 |
+
$per_page = 10;
|
634 |
+
if(isset($cat[$name])){
|
635 |
+
$count = $cat[$name]->count;
|
636 |
+
$term_id = $cat[$name]->term_id;
|
637 |
+
if($count){
|
638 |
+
$args = array('no_found_rows' => true, 'per_page' => $per_page, 'orderby' => $gmGallery->options['in_category_orderby'], 'order' => $gmGallery->options['in_category_order'], 'category__in' => array($term_id), 'author' => $author);
|
639 |
+
$termItems = $gmDB->get_gmedias($args);
|
|
|
|
|
|
|
|
|
640 |
}
|
641 |
+
} else{
|
642 |
+
$count = 0;
|
643 |
+
$term_id = '##';
|
644 |
+
}
|
645 |
+
?>
|
646 |
+
<div class="list-group-item term-list-item">
|
647 |
+
<div class="row cb_term-object">
|
648 |
+
<div class="term_id">#<?php echo $term_id; ?></div>
|
649 |
+
<div class="col-xs-6" style="padding-top:10px; padding-bottom:10px;">
|
650 |
+
<?php echo esc_html($title); ?>
|
651 |
+
<div class="object-actions">
|
652 |
+
<?php
|
653 |
+
$filter_icon = '<span class="badge">' . $count . '</span>';
|
654 |
+
if($count){
|
655 |
+
echo '<a title="' . __('Filter in Gmedia Library', 'gmLang') . '" href="' . $gmCore->get_admin_url(array('page' => 'GrandMedia', 'cat' => $term_id), array(), true) . '">' . $filter_icon . '</a>';
|
656 |
+
} else{
|
657 |
+
echo $filter_icon;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
658 |
}
|
659 |
+
|
660 |
+
$share_icon = '<span class="glyphicon glyphicon-share"></span>';
|
661 |
+
if(isset($cat[$name]->term_id)){
|
662 |
+
$gmedia_hashid = gmedia_hash_id_encode($term_id, 'tag');
|
663 |
+
if(get_option('permalink_structure')){
|
664 |
+
$cloud_link = home_url(urlencode($endpoint) . '/k/' . $gmedia_hashid);
|
665 |
+
} else{
|
666 |
+
$cloud_link = add_query_arg(array("$endpoint" => $gmedia_hashid, 't' => 'k'), home_url('index.php'));
|
667 |
+
}
|
668 |
+
echo '<a target="_blank" data-target="#shareModal" data-share="' . $term_id . '" class="share-modal" title="' . __('Share', 'gmLang') . '" href="' . $cloud_link . '">' . $share_icon . '</a>';
|
669 |
+
} else{
|
670 |
+
echo "<span class='action-inactive'>$share_icon</span>";
|
671 |
}
|
672 |
+
|
673 |
+
/*
|
674 |
+
$edit_icon = '<span class="glyphicon glyphicon-edit"></span>';
|
675 |
+
echo '<a title="' . __('Edit', 'gmLang') . '" href="' . add_query_arg( array( 'edit_album' => $item->term_id ), $url ) . '">'.$edit_icon.'</a>';
|
676 |
+
*/
|
677 |
?>
|
678 |
</div>
|
679 |
</div>
|
680 |
+
<div class="col-xs-6 term-images">
|
681 |
+
<?php if(!empty($termItems)){
|
682 |
+
foreach($termItems as $i){
|
683 |
+
?>
|
684 |
+
<img style="z-index:<?php echo $per_page --; ?>;"
|
685 |
+
src="<?php echo $gmCore->gm_get_media_image($i, 'thumb', false); ?>"
|
686 |
+
alt="<?php echo $i->ID; ?>" title="<?php echo esc_attr($i->title); ?>"/>
|
687 |
+
<?php
|
688 |
+
}
|
689 |
+
}
|
690 |
+
if(count($termItems) < $count){
|
691 |
+
echo '...';
|
692 |
+
}
|
693 |
+
?>
|
694 |
+
</div>
|
695 |
</div>
|
696 |
+
</div>
|
697 |
+
<?php } ?>
|
698 |
+
</div>
|
699 |
+
<?php } ?>
|
700 |
|
701 |
</div>
|
702 |
|
703 |
+
<div class="modal fade gmedia-modal" id="shareModal" tabindex="-1" role="dialog" aria-hidden="true">
|
704 |
+
<div class="modal-dialog">
|
705 |
+
<div class="modal-content">
|
706 |
+
<div class="modal-header">
|
707 |
+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
708 |
+
<h4 class="modal-title"><?php _e('GmediaCloud Page'); ?></h4>
|
709 |
+
</div>
|
710 |
+
<form class="modal-body" method="post" id="shareForm">
|
711 |
+
<div class="form-group">
|
712 |
+
<label><?php _e('Link to page', 'gmLang'); ?></label>
|
713 |
+
<input name="sharelink" type="text" class="form-control sharelink" readonly="readonly" value=""/>
|
714 |
+
</div>
|
715 |
+
<div class="form-group">
|
716 |
+
<label><?php _e('Send this link to', 'gmLang'); ?></label>
|
717 |
+
<input name="email" type="email" class="form-control sharetoemail" value="" placeholder="<?php _e('Email', 'gmLang'); ?>"/>
|
718 |
+
<textarea name="message" cols="20" rows="3" class="form-control" placeholder="<?php _e('Message (optional)', 'gmLang'); ?>"></textarea>
|
719 |
+
</div>
|
720 |
+
<input type="hidden" name="action" value="gmedia_share_page"/>
|
721 |
+
<?php wp_nonce_field('share_modal', '_sharenonce'); ?>
|
722 |
+
</form>
|
723 |
+
<div class="modal-footer">
|
724 |
+
<button type="button" class="btn btn-primary sharebutton" disabled="disabled"><?php _e('Send', 'gmLang'); ?></button>
|
725 |
+
<button type="button" class="btn btn-default" data-dismiss="modal"><?php _e('Close', 'gmLang'); ?></button>
|
726 |
+
</div>
|
727 |
+
</div>
|
728 |
+
</div>
|
729 |
+
</div>
|
730 |
+
|
731 |
<?php
|
732 |
}
|
733 |
|
737 |
*
|
738 |
* @return mixed content
|
739 |
*/
|
740 |
+
function gmediaAlbumEdit(){
|
741 |
+
global $gmDB, $gmCore, $gmProcessor, $gmGallery, $user_ID;
|
742 |
|
743 |
+
if(!$gmCore->caps['gmedia_album_manage']){
|
744 |
+
die('-1');
|
745 |
}
|
746 |
|
747 |
+
$url = add_query_arg(array('page' => $gmProcessor->page), admin_url('admin.php'));
|
748 |
+
|
749 |
+
$gm_screen_options = get_user_meta($user_ID, 'gm_screen_options', true);
|
750 |
+
if(!is_array($gm_screen_options)){
|
751 |
+
$gm_screen_options = array();
|
752 |
+
}
|
753 |
+
$gm_screen_options = array_merge($gmGallery->options['gm_screen_options'], $gm_screen_options);
|
754 |
|
755 |
$taxonomy = 'gmedia_album';
|
756 |
+
$term_id = $gmCore->_get('edit_album');
|
757 |
|
758 |
+
$term = $gmDB->get_term($term_id, $taxonomy);
|
759 |
|
760 |
+
if(!empty($term) && !is_wp_error($term)){
|
761 |
|
762 |
+
$term_meta = $gmDB->get_metadata('gmedia_term', $term->term_id);
|
763 |
+
$term_meta = array_map('reset', $term_meta);
|
764 |
+
$term_meta = array_merge(array('orderby' => 'ID', 'order' => 'DESC'), $term_meta);
|
765 |
+
$per_page = !empty($gm_screen_options['per_page_sort_gmedia'])? $gm_screen_options['per_page_sort_gmedia'] : 60;
|
766 |
+
$cur_page = $gmCore->_get('pager', 1);
|
767 |
+
$pager_html = '';
|
768 |
|
769 |
$termItems = array();
|
770 |
+
if($term->count){
|
771 |
+
$args = array(
|
772 |
+
'album__in' => $term->term_id,
|
773 |
+
'orderby' => $term_meta['orderby'],
|
774 |
+
'order' => $term_meta['order'],
|
775 |
+
'per_page' => $per_page,
|
776 |
+
'page' => $cur_page
|
777 |
+
);
|
778 |
+
$termItems = $gmDB->get_gmedias($args);
|
779 |
|
780 |
+
$pager_html = $gmDB->query_pager();
|
|
|
|
|
781 |
}
|
782 |
|
783 |
?>
|
785 |
<div class="panel-heading clearfix">
|
786 |
<div class="btn-toolbar pull-left">
|
787 |
<div class="btn-group" style="margin-right:20px;">
|
788 |
+
<a class="btn btn-primary active" href="<?php echo add_query_arg(array('term' => 'gmedia_album'), $url); ?>"><?php _e('Albums', 'gmLang'); ?></a>
|
789 |
+
<a class="btn btn-default" href="<?php echo add_query_arg(array('term' => 'gmedia_tag'), $url); ?>"><?php _e('Tags', 'gmLang'); ?></a>
|
790 |
+
<a class="btn btn-default" href="<?php echo add_query_arg(array('term' => 'gmedia_category'), $url); ?>"><?php _e('Categories', 'gmLang'); ?></a>
|
791 |
</div>
|
792 |
|
793 |
<div class="btn-group">
|
794 |
+
<a class="btn btn-default" href="#"><?php _e('Action', 'gmLang'); ?></a>
|
795 |
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
|
796 |
<span class="caret"></span>
|
797 |
+
<span class="sr-only"><?php _e('Toggle Dropdown', 'gmLang'); ?></span>
|
798 |
</button>
|
799 |
<ul class="dropdown-menu" role="menu">
|
800 |
+
<li><a href="<?php echo add_query_arg(array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
801 |
'page' => 'GrandMedia',
|
802 |
+
'alb' => $term->term_id
|
803 |
+
), admin_url('admin.php')); ?>"><?php _e('Show Album in Gmedia Library', 'gmLang'); ?></a>
|
804 |
</li>
|
805 |
</ul>
|
806 |
</div>
|
807 |
</div>
|
808 |
|
|
|
|
|
809 |
</div>
|
810 |
|
811 |
<form method="post" id="gmedia-edit-term" name="gmEditTerm" class="panel-body">
|
812 |
<h4 style="margin-top:0;">
|
813 |
+
<span class="pull-right"><?php echo __('ID', 'gmLang') . ": {$term->term_id}"; ?></span>
|
814 |
+
<?php _e('Edit Album'); ?>: <em><?php echo esc_html($term->name); ?></em>
|
815 |
</h4>
|
816 |
|
817 |
+
<div class="row">
|
818 |
<div class="col-xs-6">
|
819 |
<div class="form-group">
|
820 |
+
<label><?php _e('Name', 'gmLang'); ?></label>
|
821 |
<input type="text" class="form-control input-sm" name="term[name]"
|
822 |
+
value="<?php echo esc_attr($term->name); ?>"
|
823 |
+
placeholder="<?php _e('Album Name', 'gmLang'); ?>" required/>
|
824 |
</div>
|
825 |
<div class="form-group">
|
826 |
+
<label><?php _e('Description', 'gmLang'); ?></label>
|
827 |
<textarea class="form-control input-sm" style="height:53px;" rows="2"
|
828 |
name="term[description]"><?php echo $term->description; ?></textarea>
|
829 |
</div>
|
830 |
</div>
|
831 |
<div class="col-xs-6">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
832 |
<div class="row">
|
833 |
<div class="col-xs-6">
|
834 |
<div class="form-group">
|
835 |
+
<label><?php _e('Status', 'gmLang'); ?></label>
|
836 |
<select name="term[status]" class="form-control input-sm">
|
837 |
<option
|
838 |
+
value="public"<?php selected($term->status, 'public'); ?>><?php _e('Public', 'gmLang'); ?></option>
|
839 |
<option
|
840 |
+
value="private"<?php selected($term->status, 'private'); ?>><?php _e('Private', 'gmLang'); ?></option>
|
841 |
<option
|
842 |
+
value="draft"<?php selected($term->status, 'draft'); ?>><?php _e('Draft', 'gmLang'); ?></option>
|
843 |
</select>
|
844 |
</div>
|
845 |
<div class="form-group">
|
846 |
+
<div class="checkbox"><label><input type="checkbox" name="term[status_global]" value="1"> <?php _e('Apply Status for all items in album', 'gmLang'); ?></label></div>
|
847 |
</div>
|
848 |
</div>
|
849 |
<div class="col-xs-6">
|
850 |
<div class="form-group">
|
851 |
+
<label><?php _e('Author', 'gmLang'); ?></label>
|
852 |
+
<?php $user_ids = $gmCore->caps['gmedia_delete_others_media']? $gmCore->get_editable_user_ids() : array($user_ID);
|
853 |
+
if($user_ids && $gmCore->caps['gmedia_edit_others_media']){
|
854 |
+
if(!in_array($user_ID, $user_ids)){
|
855 |
+
array_push($user_ids, $user_ID);
|
856 |
}
|
857 |
+
$selected_user = get_the_author_meta('display_name', $term->global)? $term->global : 0;
|
858 |
+
wp_dropdown_users(array(
|
859 |
+
'include' => $user_ids,
|
860 |
'include_selected' => true,
|
861 |
+
'name' => 'term[global]',
|
862 |
+
'selected' => $selected_user,
|
863 |
+
'class' => 'form-control input-sm',
|
864 |
+
'multi' => true,
|
865 |
+
'show_option_all' => __('Shared', 'gmLang')
|
866 |
+
));
|
867 |
+
} else{
|
868 |
echo '<input type="hidden" name="term[global]" value="' . $user_ID . '"/>';
|
869 |
+
echo '<div>' . get_the_author_meta('display_name', $user_ID) . '</div>';
|
870 |
}
|
871 |
?>
|
872 |
</div>
|
873 |
<div class="form-group">
|
874 |
+
<?php wp_nonce_field('GmediaTerms', 'term_save_wpnonce'); ?>
|
875 |
<input type="hidden" name="term[term_id]" value="<?php echo $term->term_id; ?>"/>
|
876 |
<input type="hidden" name="term[taxonomy]" value="gmedia_album"/>
|
877 |
<button style="display:block" type="submit" class="btn btn-primary btn-sm"
|
878 |
+
name="gmedia_album_save"><?php _e('Update', 'gmLang'); ?></button>
|
879 |
</div>
|
880 |
</div>
|
881 |
</div>
|
882 |
</div>
|
883 |
</div>
|
884 |
+
</form>
|
885 |
+
</div>
|
886 |
+
<div class="panel panel-default">
|
887 |
+
<div class="panel-heading clearfix">
|
888 |
+
<h4 style="margin:7px 0;" class="pull-left"><?php _e('Sort Album'); ?></h4>
|
889 |
+
|
890 |
+
<?php echo $pager_html; ?>
|
891 |
|
892 |
+
</div>
|
893 |
+
<form method="post" id="gmedia-sort-term" name="gmSortTerm" class="panel-body">
|
894 |
+
<div class="order-form" style="border-bottom:1px solid #ddd; margin-bottom:15px;">
|
895 |
+
<div class="row">
|
896 |
+
<div class="col-xs-3">
|
897 |
+
<div class="form-group">
|
898 |
+
<label><?php _e('Order gmedia', 'gmLang'); ?></label>
|
899 |
+
<select name="term[orderby]" id="gmedia_term_orderby" class="form-control input-sm">
|
900 |
+
<option value="custom"<?php selected($term_meta['orderby'], 'custom'); ?>><?php _e('Custom Order', 'gmLang'); ?></option>
|
901 |
+
<option value="ID"<?php selected($term_meta['orderby'], 'ID'); ?>><?php _e('by ID', 'gmLang'); ?></option>
|
902 |
+
<option value="title ID"<?php selected($term_meta['orderby'], 'title ID'); ?>><?php _e('by title', 'gmLang'); ?></option>
|
903 |
+
<option value="gmuid"<?php selected($term_meta['orderby'], 'gmuid'); ?>><?php _e('by filename', 'gmLang'); ?></option>
|
904 |
+
<option value="date ID"<?php selected($term_meta['orderby'], 'date ID'); ?>><?php _e('by date', 'gmLang'); ?></option>
|
905 |
+
<option value="modified ID"<?php selected($term_meta['orderby'], 'modified ID'); ?>><?php _e('by last modified date', 'gmLang'); ?></option>
|
906 |
+
<option value="rand"<?php selected($term_meta['orderby'], 'rand'); ?>><?php _e('Random', 'gmLang'); ?></option>
|
907 |
+
</select>
|
908 |
+
</div>
|
909 |
+
</div>
|
910 |
+
<div class="col-xs-3">
|
911 |
+
<div class="form-group">
|
912 |
+
<label><?php _e('Sort order', 'gmLang'); ?></label>
|
913 |
+
<select id="gmedia_term_order" name="term[order]" class="form-control input-sm">
|
914 |
+
<option value="DESC"<?php selected($term_meta['order'], 'DESC'); ?>><?php _e('DESC', 'gmLang'); ?></option>
|
915 |
+
<option value="ASC"<?php selected($term_meta['order'], 'ASC'); ?>><?php _e('ASC', 'gmLang'); ?></option>
|
916 |
+
</select>
|
917 |
+
</div>
|
918 |
+
</div>
|
919 |
+
<div class="col-xs-6">
|
920 |
+
<div class="form-group pull-left" style="margin-right:30px;">
|
921 |
+
<label style="visibility:hidden;">-</label>
|
922 |
+
<div class="checkbox"><label><input id="reset_order_option" type="checkbox" name="term[reset_custom_order]" value="1"> <?php _e('Reset custom order', 'gmLang'); ?></label></div>
|
923 |
+
</div>
|
924 |
+
<div class="form-group pull-left">
|
925 |
+
<label style="visibility:hidden;">-</label>
|
926 |
+
<button style="display:block" type="submit" class="btn btn-primary btn-sm"
|
927 |
+
name="gmedia_term_sort_save"><?php _e('Update', 'gmLang'); ?></button>
|
928 |
+
</div>
|
929 |
+
<?php wp_nonce_field('GmediaTerms', 'term_save_wpnonce'); ?>
|
930 |
+
<input type="hidden" name="term[term_id]" value="<?php echo $term->term_id; ?>"/>
|
931 |
+
<input type="hidden" name="term[taxonomy]" value="gmedia_album"/>
|
932 |
+
</div>
|
933 |
+
</div>
|
934 |
+
<p><?php _e('Use your mouse (drag&drop) for custom sorting of images or manually enter index number in top right field of each image.') ?></p>
|
935 |
+
</div>
|
936 |
<div class="termItems clearfix" id="termItems">
|
937 |
+
<?php if(!empty($termItems)){
|
938 |
+
foreach($termItems as $item){
|
939 |
?>
|
940 |
<div class="gm-img-thumbnail" data-gmid="<?php echo $item->ID; ?>"><?php
|
941 |
+
?><img src="<?php echo $gmCore->gm_get_media_image($item, 'thumb', false); ?>" alt="<?php echo $item->ID; ?>" title="<?php echo esc_attr($item->title); ?>"/><?php
|
942 |
+
?><input type="text" name="term[gmedia_ids][<?php echo $item->ID; ?>]" value="<?php echo isset($item->gmedia_order)? $item->gmedia_order : '0'; ?>"/><?php
|
943 |
+
?><span class="label label-default">ID: <?php echo $item->ID; ?></span><?php
|
944 |
?>
|
945 |
+
<div class="gm-img-thumb-title"><?php echo esc_html($item->title); ?></div>
|
946 |
+
</div>
|
|
|
|
|
|
|
|
|
947 |
<?php
|
948 |
}
|
949 |
} ?>
|
950 |
|
951 |
</div>
|
952 |
+
</form>
|
953 |
+
<div class="panel-footer clearfix" style="margin-top:20px;"><?php echo $pager_html; ?>
|
954 |
+
<div class="well well-sm pull-left"
|
955 |
+
style="margin:0;"><?php printf(__('Total items: %d'), $term->count); ?></div>
|
956 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
957 |
|
958 |
+
<script type="text/javascript">
|
959 |
+
jQuery(function($){
|
960 |
+
var sortdiv = $('#termItems');
|
961 |
+
var items = $('.gm-img-thumbnail', sortdiv);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
962 |
|
963 |
+
sortdiv.sortable({
|
964 |
+
items: '.gm-img-thumbnail',
|
965 |
+
handle: 'img',
|
966 |
+
placeholder: 'gm-img-thumbnail ui-highlight-placeholder',
|
967 |
+
forcePlaceholderSize: true,
|
968 |
+
//revert: true,
|
969 |
+
stop: function(event, ui){
|
970 |
+
$('#gmedia_term_orderby').val('custom');
|
971 |
+
var cur_order, prev_order, next_order;
|
972 |
+
var self = ui.item,
|
973 |
+
prev_item = self.prev(),
|
974 |
+
next_item = self.next();
|
975 |
+
prev_order = prev_item.length? parseInt($('input', prev_item).val()) : 0;
|
976 |
+
var img_order_asc = ('ASC' == $('#gmedia_term_order').val());
|
977 |
+
if(img_order_asc){
|
978 |
+
cur_order = prev_order + 1;
|
979 |
+
$('input', self).val(cur_order);
|
980 |
+
while(next_item.length){
|
981 |
+
next_order = parseInt(next_item.find('input').val());
|
982 |
+
if(cur_order < next_order){
|
983 |
+
break;
|
984 |
+
}
|
985 |
+
cur_order += 1;
|
986 |
+
next_item.find('input').val(cur_order);
|
987 |
+
next_item = next_item.next();
|
988 |
+
}
|
989 |
|
990 |
+
} else{
|
991 |
+
next_order = next_item.length? parseInt($('input', next_item).val()) : (prev_order? (prev_order - 1) : 0);
|
992 |
+
cur_order = next_order + 1;
|
993 |
+
$('input', self).val(cur_order);
|
994 |
+
while(prev_item.length){
|
995 |
+
prev_order = parseInt(prev_item.find('input').val());
|
996 |
+
if(cur_order < prev_order){
|
997 |
+
break;
|
998 |
+
}
|
999 |
+
cur_order += 1;
|
1000 |
+
prev_item.find('input').val(cur_order);
|
1001 |
+
prev_item = prev_item.prev();
|
1002 |
+
}
|
1003 |
+
}
|
1004 |
+
}
|
1005 |
+
});
|
1006 |
|
1007 |
+
$('input', items).on('change', function(){
|
1008 |
+
$('#gmedia_term_orderby').val('custom');
|
1009 |
+
sortdiv.css({height: sortdiv.height()});
|
1010 |
+
var items = $('.gm-img-thumbnail', sortdiv);
|
1011 |
|
1012 |
+
var new_order = $.isNumeric($(this).val())? parseInt($(this).val()) : -1;
|
1013 |
+
$(this).val(new_order).closest('.gm-img-thumbnail').css({zIndex: 1000});
|
|
|
|
|
|
|
|
|
1014 |
|
1015 |
+
var ipos = [];
|
1016 |
+
items.each(function(i, el){
|
1017 |
+
var pos = $(el).position();
|
1018 |
+
$.data(el, 'pos', pos);
|
1019 |
+
ipos[i] = pos;
|
1020 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1021 |
|
1022 |
+
var img_order_asc = ('ASC' == $('#gmedia_term_order').val());
|
1023 |
+
var order = img_order_asc? 'asc' : 'desc';
|
1024 |
+
items.tsort('input', {
|
1025 |
+
useVal: true,
|
1026 |
+
order: order
|
1027 |
+
}, 'span.label', {order: order}).each(function(i, el){
|
1028 |
+
var from = $.data(el, 'pos');
|
1029 |
+
var to = ipos[i];
|
1030 |
+
$(el).css({position: 'absolute', top: from.top, left: from.left}).animate({
|
1031 |
+
top: to.top,
|
1032 |
+
left: to.left
|
1033 |
+
}, 500);
|
1034 |
+
}).promise().done(function(){
|
1035 |
+
items.removeAttr('style');
|
1036 |
+
sortdiv.removeAttr('style');
|
1037 |
});
|
1038 |
+
|
1039 |
+
$(this).val(((0 > new_order)? 0 : new_order));
|
1040 |
});
|
1041 |
+
});
|
1042 |
+
</script>
|
1043 |
+
|
|
|
|
|
|
|
1044 |
</div>
|
1045 |
<?php
|
1046 |
+
} else{
|
1047 |
|
1048 |
}
|
1049 |
}
|
admin/upload.php
DELETED
@@ -1,75 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* upload.php
|
4 |
-
* Copyright 2009, Moxiecode Systems AB
|
5 |
-
* Released under GPL License.
|
6 |
-
* License: http://www.plupload.com/license
|
7 |
-
* Contributing: http://www.plupload.com/contributing
|
8 |
-
*/
|
9 |
-
|
10 |
-
ini_set( 'display_errors', 0 );
|
11 |
-
ini_set( 'error_reporting', 0 );
|
12 |
-
|
13 |
-
require_once( dirname( dirname( __FILE__ ) ) . '/config.php' );
|
14 |
-
|
15 |
-
// HTTP headers for no cache etc
|
16 |
-
nocache_headers();
|
17 |
-
|
18 |
-
if ( ! current_user_can( 'gmedia_upload' ) ) {
|
19 |
-
wp_die( __( 'You do not have permission to upload files in Gmedia Library.' ) );
|
20 |
-
}
|
21 |
-
|
22 |
-
check_admin_referer( 'grandMedia' );
|
23 |
-
|
24 |
-
// 5 minutes execution time
|
25 |
-
@set_time_limit( 5 * 60 );
|
26 |
-
|
27 |
-
// fake upload time
|
28 |
-
usleep( 10 );
|
29 |
-
|
30 |
-
$return = '';
|
31 |
-
// Get parameters
|
32 |
-
if ( ! isset( $_REQUEST["name"] ) ) {
|
33 |
-
$return = json_encode( array( "error" => array( "code" => 100, "message" => __( "No file name.", 'gmLang' ) ), "id" => $_REQUEST["name"] ) );
|
34 |
-
die( $return );
|
35 |
-
}
|
36 |
-
|
37 |
-
global $gmCore;
|
38 |
-
$filename = $_REQUEST["name"];
|
39 |
-
$fileinfo = $gmCore->fileinfo( $filename );
|
40 |
-
if ( false === $fileinfo ) {
|
41 |
-
$return = json_encode( array( "error" => array( "code" => 100, "message" => __( "File type not allowed.", 'gmLang' ) ), "id" => $_REQUEST["name"] ) );
|
42 |
-
die( $return );
|
43 |
-
}
|
44 |
-
|
45 |
-
// Look for the content type header
|
46 |
-
$contentType = '';
|
47 |
-
if ( isset( $_SERVER["HTTP_CONTENT_TYPE"] ) ) {
|
48 |
-
$contentType = $_SERVER["HTTP_CONTENT_TYPE"];
|
49 |
-
}
|
50 |
-
|
51 |
-
if ( isset( $_SERVER["CONTENT_TYPE"] ) ) {
|
52 |
-
$contentType = $_SERVER["CONTENT_TYPE"];
|
53 |
-
}
|
54 |
-
|
55 |
-
// Handle non multipart uploads older WebKit versions didn't support multipart in HTML5
|
56 |
-
if ( strpos( $contentType, "multipart" ) !== false ) {
|
57 |
-
if ( isset( $_FILES['file']['tmp_name'] ) && is_uploaded_file( $_FILES['file']['tmp_name'] ) ) {
|
58 |
-
$file_tmp = $_FILES['file']['tmp_name'];
|
59 |
-
} else {
|
60 |
-
$return = json_encode( array( "error" => array( "code" => 103, "message" => __( "Failed to move uploaded file.", 'gmLang' ) ), "id" => $filename ) );
|
61 |
-
die( $return );
|
62 |
-
}
|
63 |
-
} else {
|
64 |
-
$file_tmp = "php://input";
|
65 |
-
}
|
66 |
-
|
67 |
-
$post_data = array();
|
68 |
-
if ( isset( $_REQUEST['params'] ) ) {
|
69 |
-
parse_str( $_REQUEST['params'], $post_data );
|
70 |
-
}
|
71 |
-
|
72 |
-
$return = $gmCore->gmedia_upload_handler( $file_tmp, $fileinfo, $contentType, $post_data );
|
73 |
-
$return = json_encode( $return );
|
74 |
-
|
75 |
-
die( $return );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/wpmedia.php
CHANGED
@@ -143,7 +143,7 @@ function grandWPMedia(){
|
|
143 |
if(!$gmCore->caps['gmedia_import']){
|
144 |
echo ' disabled';
|
145 |
} ?>">
|
146 |
-
<a href="#importModal" data-modal="import-wpmedia" data-action="
|
147 |
</li>
|
148 |
<!-- <li class="divider <?php echo $rel_selected_hide; ?>"></li> -->
|
149 |
<li class="dropdown-header <?php echo $rel_selected_hide; ?>"><span><?php _e("Select items to see more actions", "gmLang"); ?></span></li>
|
143 |
if(!$gmCore->caps['gmedia_import']){
|
144 |
echo ' disabled';
|
145 |
} ?>">
|
146 |
+
<a href="#importModal" data-modal="import-wpmedia" data-action="gmedia_import_wpmedia_modal" class="gmedia-modal"><?php _e('Import to Gmedia Library...', 'gmLang'); ?></a>
|
147 |
</li>
|
148 |
<!-- <li class="divider <?php echo $rel_selected_hide; ?>"></li> -->
|
149 |
<li class="dropdown-header <?php echo $rel_selected_hide; ?>"><span><?php _e("Select items to see more actions", "gmLang"); ?></span></li>
|
assets/bootstrap/css/bootstrap.css
CHANGED
@@ -5,14 +5,6 @@
|
|
5 |
*/
|
6 |
|
7 |
/*! normalize.css v3.0.2 | MIT License | git.io/normalize */
|
8 |
-
html {
|
9 |
-
font-family: sans-serif;
|
10 |
-
-webkit-text-size-adjust: 100%;
|
11 |
-
-ms-text-size-adjust: 100%;
|
12 |
-
}
|
13 |
-
body {
|
14 |
-
margin: 0;
|
15 |
-
}
|
16 |
article,
|
17 |
aside,
|
18 |
details,
|
@@ -894,18 +886,6 @@ th {
|
|
894 |
-moz-box-sizing: border-box;
|
895 |
box-sizing: border-box;
|
896 |
}
|
897 |
-
html {
|
898 |
-
font-size: 10px;
|
899 |
-
|
900 |
-
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
901 |
-
}
|
902 |
-
body {
|
903 |
-
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
904 |
-
font-size: 14px;
|
905 |
-
line-height: 1.42857143;
|
906 |
-
color: #333;
|
907 |
-
background-color: #fff;
|
908 |
-
}
|
909 |
input,
|
910 |
button,
|
911 |
select,
|
@@ -6114,7 +6094,6 @@ button.close {
|
|
6114 |
}
|
6115 |
.hidden {
|
6116 |
display: none !important;
|
6117 |
-
visibility: hidden !important;
|
6118 |
}
|
6119 |
.affix {
|
6120 |
position: fixed;
|
5 |
*/
|
6 |
|
7 |
/*! normalize.css v3.0.2 | MIT License | git.io/normalize */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
article,
|
9 |
aside,
|
10 |
details,
|
886 |
-moz-box-sizing: border-box;
|
887 |
box-sizing: border-box;
|
888 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
889 |
input,
|
890 |
button,
|
891 |
select,
|
6094 |
}
|
6095 |
.hidden {
|
6096 |
display: none !important;
|
|
|
6097 |
}
|
6098 |
.affix {
|
6099 |
position: fixed;
|
assets/icons/favicon.png
ADDED
Binary file
|
assets/icons/icon_gmedia_120.png
ADDED
Binary file
|
assets/icons/icon_gmedia_152.png
ADDED
Binary file
|
assets/icons/icon_gmedia_180.png
ADDED
Binary file
|
assets/icons/icon_gmedia_60.png
ADDED
Binary file
|
assets/icons/icon_gmedia_76.png
ADDED
Binary file
|
gallery.php
DELETED
@@ -1,122 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
//ini_set('display_errors', '1');
|
3 |
-
//ini_set('error_reporting', E_ALL);
|
4 |
-
|
5 |
-
if(!defined('ABSPATH')){
|
6 |
-
@require_once(dirname(__FILE__) . '/config.php');
|
7 |
-
}
|
8 |
-
|
9 |
-
global $wp, $wp_styles, $wp_scripts, $gmCore;
|
10 |
-
|
11 |
-
$content = '';
|
12 |
-
$styles = '';
|
13 |
-
$type = isset($_GET['type'])? $_GET['type'] : (isset($wp->query_vars['type'])? $wp->query_vars['type'] : 'gallery');
|
14 |
-
if(empty($type)){
|
15 |
-
$type = 'gallery';
|
16 |
-
}
|
17 |
-
$gmedia = isset($_GET['gmedia'])? $_GET['gmedia'] : (isset($wp->query_vars['gmedia'])? $wp->query_vars['gmedia'] : false);
|
18 |
-
$gmedia = rawurldecode($gmedia);
|
19 |
-
if($gmedia){
|
20 |
-
global $gmDB;
|
21 |
-
if('gallery' == $type || 'album' == $type || 'tag' == $type || 'category' == $type){
|
22 |
-
$term_id = $gmDB->term_exists($gmedia, 'gmedia_' . $type);
|
23 |
-
if($term_id){
|
24 |
-
$atts = array(
|
25 |
-
'id' => $term_id,
|
26 |
-
'preview' => $gmCore->_get('preview', ''),
|
27 |
-
'preset' => $gmCore->_get('preset', 0),
|
28 |
-
'_tax' => $type
|
29 |
-
);
|
30 |
-
$content = gmedia_shortcode($atts);
|
31 |
-
}
|
32 |
-
} elseif('single' == $type && $gmCore->is_digit($gmedia)){
|
33 |
-
$gmedia_obj = $gmDB->get_gmedia($gmedia);
|
34 |
-
$type = explode('/', $gmedia_obj->mime_type, 2);
|
35 |
-
if('image' == $type[0]){
|
36 |
-
$content .= '<div class="single_view">';
|
37 |
-
$content .= '<img src="' . $gmCore->gm_get_media_image($gmedia_obj->ID) . '">';
|
38 |
-
$content .= "<h2>{$gmedia_obj->title}</h2>";
|
39 |
-
$content .= "<div>{$gmedia_obj->description}</div>";
|
40 |
-
$content .= "</div>";
|
41 |
-
$styles .= '.single_view { width:100%; height:100%; oveflow:auto; }';
|
42 |
-
} elseif('video' == $type[0]){
|
43 |
-
$meta = $gmDB->get_metadata('gmedia', $gmedia_obj->ID, '_metadata', true);
|
44 |
-
$width = isset($meta['width'])? $meta['width'] : 640;
|
45 |
-
$height = isset($meta['height'])? $meta['height'] : 480;
|
46 |
-
$url = $gmCore->fileinfo($gmedia_obj->gmuid, false);
|
47 |
-
$content .= '<video src="' . $url['fileurl'] . '" width="' . $width . '" height="' . $height . '" style="width:100%;height:100%;"></video>';
|
48 |
-
$content .= '
|
49 |
-
<script type="text/javascript">
|
50 |
-
jQuery(function($){
|
51 |
-
var video = $("video");
|
52 |
-
function video_responsive(){
|
53 |
-
var vw = video.width(),
|
54 |
-
vh = video.height(),
|
55 |
-
r = vw/vh,
|
56 |
-
bw = $(window).width(),
|
57 |
-
bh = $(window).height(),
|
58 |
-
mar = 0;
|
59 |
-
if(r > bw/bh){
|
60 |
-
vh = bw/r;
|
61 |
-
vw = bw;
|
62 |
-
mar = (bh - vh)/2;
|
63 |
-
mar = (mar > 0)? mar + "px 0 0 0" : "0";
|
64 |
-
} else{
|
65 |
-
vw = bh*r;
|
66 |
-
vh = bh;
|
67 |
-
mar = (bh - vh)/2;
|
68 |
-
mar = (mar > 0)? "0 0 0 " + mar + "px" : "0";
|
69 |
-
}
|
70 |
-
$("body").css({margin: mar});
|
71 |
-
video.attr("width", vw).attr("height", vh);
|
72 |
-
}
|
73 |
-
video_responsive();
|
74 |
-
$(window).on("resize", function(){
|
75 |
-
video_responsive();
|
76 |
-
});
|
77 |
-
video.mediaelementplayer();
|
78 |
-
});
|
79 |
-
</script>
|
80 |
-
';
|
81 |
-
add_action('gmedia_head_scripts', 'gmedia_additional_scripts');
|
82 |
-
function gmedia_additional_scripts(){
|
83 |
-
wp_enqueue_style('mediaelement');
|
84 |
-
wp_enqueue_script('mediaelement');
|
85 |
-
}
|
86 |
-
}
|
87 |
-
}
|
88 |
-
}
|
89 |
-
|
90 |
-
?><!DOCTYPE html>
|
91 |
-
<html <?php language_attributes(); ?>>
|
92 |
-
<head>
|
93 |
-
<meta charset="<?php bloginfo('charset'); ?>">
|
94 |
-
<meta name="viewport" content="width=device-width">
|
95 |
-
<!-- <meta name='GmediaGallery' content='<?php echo GMEDIA_VERSION . ' / ' . GMEDIA_DBVERSION ?>' /> -->
|
96 |
-
<title><?php wp_title('|', true, 'right'); ?></title>
|
97 |
-
<link rel="profile" href="http://gmpg.org/xfn/11">
|
98 |
-
|
99 |
-
<style type="text/css">
|
100 |
-
html { width:100%; height:100%; }
|
101 |
-
body { margin:0; padding:0; width:100%; height:100%; overflow:hidden; min-height:120px; min-width:160px; }
|
102 |
-
<?php echo $styles; ?>
|
103 |
-
</style>
|
104 |
-
<?php
|
105 |
-
do_action( 'wp_enqueue_scripts' );
|
106 |
-
$wp_styles->queue = array();
|
107 |
-
$wp_scripts->queue = array();
|
108 |
-
|
109 |
-
do_action('gmedia_head_scripts');
|
110 |
-
do_action('gmedia_footer_scripts');
|
111 |
-
if(isset($_GET['iframe'])){
|
112 |
-
wp_dequeue_script('swfaddress');
|
113 |
-
}
|
114 |
-
wp_print_styles();
|
115 |
-
wp_print_scripts();
|
116 |
-
?>
|
117 |
-
</head>
|
118 |
-
<body>
|
119 |
-
<?php echo $content; ?>
|
120 |
-
|
121 |
-
</body>
|
122 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 - powerfull media library plugin for creating beautiful galleries and managing files.
|
6 |
-
Version: 1.
|
7 |
Author: Rattus
|
8 |
Author URI: http://codeasily.com/
|
9 |
|
@@ -39,11 +39,13 @@ if(!class_exists('Gmedia')){
|
|
39 |
*/
|
40 |
class Gmedia{
|
41 |
|
42 |
-
var $version = '1.
|
43 |
var $dbversion = '0.9.6';
|
44 |
var $minium_WP = '3.5';
|
45 |
var $options = '';
|
46 |
var $do_module = array();
|
|
|
|
|
47 |
|
48 |
/**
|
49 |
*
|
@@ -96,6 +98,7 @@ if(!class_exists('Gmedia')){
|
|
96 |
// Check for upgrade
|
97 |
$this->upgrade();
|
98 |
|
|
|
99 |
require_once(dirname(__FILE__) . '/inc/permalinks.php');
|
100 |
|
101 |
// Load the admin panel or the frontend functions
|
@@ -116,15 +119,24 @@ if(!class_exists('Gmedia')){
|
|
116 |
add_action('wp_enqueue_scripts', array(&$this, 'load_scripts'), 4);
|
117 |
|
118 |
// Add a version number to the header
|
119 |
-
add_action('wp_head',
|
120 |
add_action('wp_footer', array(&$this, 'load_module_scripts'));
|
121 |
|
122 |
-
add_action('
|
123 |
-
add_action('
|
|
|
124 |
}
|
125 |
|
126 |
}
|
127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
function admin_notices(){
|
129 |
echo '<div id="message" class="error"><p><strong>' . get_option('gmediaInitCheck') . '</strong></p></div>';
|
130 |
delete_option('gmediaInitCheck');
|
@@ -166,23 +178,23 @@ if(!class_exists('Gmedia')){
|
|
166 |
$current_db_version = get_option('gmediaDbVersion', null);
|
167 |
|
168 |
require_once(dirname(__FILE__) . '/update.php');
|
169 |
-
if(
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
if(isset($_GET['do_update']) && ('gmedia' == $_GET['do_update'])){
|
174 |
add_action('admin_notices', 'gmedia_wait_admin_notice');
|
175 |
} else{
|
176 |
add_action('admin_notices', 'gmedia_update_admin_notice');
|
177 |
}
|
178 |
-
} else{
|
179 |
-
if((null !== $current_version) && version_compare($current_version, GMEDIA_VERSION, '<')){
|
180 |
-
gmedia_quite_update();
|
181 |
-
}
|
182 |
-
update_option("gmediaDbVersion", GMEDIA_DBVERSION);
|
183 |
-
update_option("gmediaVersion", GMEDIA_VERSION);
|
184 |
}
|
185 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
}
|
187 |
|
188 |
function define_tables(){
|
@@ -232,6 +244,12 @@ if(!class_exists('Gmedia')){
|
|
232 |
require_once(dirname(__FILE__) . '/inc/shortcodes.php');
|
233 |
}
|
234 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
}
|
236 |
|
237 |
function load_textdomain(){
|
@@ -252,8 +270,8 @@ if(!class_exists('Gmedia')){
|
|
252 |
'pluginPath' => $gmCore->gmedia_url
|
253 |
));
|
254 |
|
255 |
-
wp_register_style('grand-media', $gmCore->gmedia_url . '/admin/css/grand-media.css', array(), '1.
|
256 |
-
wp_register_script('grand-media', $gmCore->gmedia_url . '/admin/js/grand-media.js', array('jquery', 'gmedia-global-backend'), '1.
|
257 |
wp_localize_script('grand-media', 'grandMedia', array(
|
258 |
'error3' => __('Disable your Popup Blocker and try again.', 'gmLang'),
|
259 |
'download' => __('downloading...', 'gmLang'),
|
@@ -302,31 +320,32 @@ if(!class_exists('Gmedia')){
|
|
302 |
}
|
303 |
|
304 |
function load_scripts(){
|
|
|
305 |
wp_enqueue_script('gmedia-global-frontend');
|
306 |
}
|
307 |
|
308 |
function load_module_scripts(){
|
|
|
309 |
$deps = array();
|
310 |
foreach($this->do_module as $m => $module){
|
311 |
$deps = array_merge($deps, explode(',', $module['info']['dependencies']));
|
312 |
-
$deps = apply_filters('
|
313 |
foreach($deps as $handle){
|
314 |
if(wp_script_is($handle, 'registered')){
|
315 |
wp_enqueue_script($handle, $_src = false, $_deps = array('jquery'), $_ver = false, $_in_footer = true);
|
316 |
}
|
317 |
if(wp_style_is($handle, 'registered')) //wp_enqueue_style( $handle );
|
318 |
{
|
319 |
-
wp_print_styles($handle);
|
|
|
320 |
}
|
321 |
}
|
322 |
$files = glob($module['path'] . '/css/*.css', GLOB_NOSORT);
|
323 |
if(!empty($files)){
|
324 |
$files = array_map('basename', $files);
|
325 |
-
echo "\n" . '<style type="text/css">' . "\n";
|
326 |
foreach($files as $file){
|
327 |
-
|
328 |
}
|
329 |
-
echo '</style>' . "\n";
|
330 |
}
|
331 |
$files = glob($module['path'] . '/js/*.js', GLOB_NOSORT);
|
332 |
if(!empty($files)){
|
@@ -336,6 +355,23 @@ if(!class_exists('Gmedia')){
|
|
336 |
}
|
337 |
}
|
338 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
339 |
}
|
340 |
|
341 |
/**
|
3 |
Plugin Name: Gmedia Gallery
|
4 |
Plugin URI: http://wordpress.org/extend/plugins/grand-media/
|
5 |
Description: Gmedia Gallery - powerfull media library plugin for creating beautiful galleries and managing files.
|
6 |
+
Version: 1.5.91
|
7 |
Author: Rattus
|
8 |
Author URI: http://codeasily.com/
|
9 |
|
39 |
*/
|
40 |
class Gmedia{
|
41 |
|
42 |
+
var $version = '1.5.91';
|
43 |
var $dbversion = '0.9.6';
|
44 |
var $minium_WP = '3.5';
|
45 |
var $options = '';
|
46 |
var $do_module = array();
|
47 |
+
var $import_styles = array();
|
48 |
+
var $shortcode = array();
|
49 |
|
50 |
/**
|
51 |
*
|
98 |
// Check for upgrade
|
99 |
$this->upgrade();
|
100 |
|
101 |
+
require_once(dirname(__FILE__) . '/inc/hashids.php');
|
102 |
require_once(dirname(__FILE__) . '/inc/permalinks.php');
|
103 |
|
104 |
// Load the admin panel or the frontend functions
|
119 |
add_action('wp_enqueue_scripts', array(&$this, 'load_scripts'), 4);
|
120 |
|
121 |
// Add a version number to the header
|
122 |
+
add_action('wp_head', array(&$this, 'gmedia_head_meta'));
|
123 |
add_action('wp_footer', array(&$this, 'load_module_scripts'));
|
124 |
|
125 |
+
add_action('gmedia_head', array(&$this, 'gmedia_head_meta'));
|
126 |
+
add_action('gmedia_head', array(&$this, 'load_scripts'), 2);
|
127 |
+
add_action('gmedia_enqueue_scripts', array(&$this, 'load_module_scripts'));
|
128 |
}
|
129 |
|
130 |
}
|
131 |
|
132 |
+
function gmedia_head_meta(){
|
133 |
+
$lk = strtolower($this->options['license_key']);
|
134 |
+
echo "\n<!-- <meta name='GmediaGallery' version='{$this->version}/{$this->dbversion}' /> -->\n";
|
135 |
+
if($lk){
|
136 |
+
echo "<script type='text/javascript'>var GmediaGallery = {'lk':'{$lk}'}</script>\n";
|
137 |
+
}
|
138 |
+
}
|
139 |
+
|
140 |
function admin_notices(){
|
141 |
echo '<div id="message" class="error"><p><strong>' . get_option('gmediaInitCheck') . '</strong></p></div>';
|
142 |
delete_option('gmediaInitCheck');
|
178 |
$current_db_version = get_option('gmediaDbVersion', null);
|
179 |
|
180 |
require_once(dirname(__FILE__) . '/update.php');
|
181 |
+
if(null === $current_db_version){
|
182 |
+
add_option("gmediaDbVersion", GMEDIA_DBVERSION);
|
183 |
+
} elseif(version_compare($current_db_version, GMEDIA_DBVERSION, '<')){
|
|
|
184 |
if(isset($_GET['do_update']) && ('gmedia' == $_GET['do_update'])){
|
185 |
add_action('admin_notices', 'gmedia_wait_admin_notice');
|
186 |
} else{
|
187 |
add_action('admin_notices', 'gmedia_update_admin_notice');
|
188 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
}
|
190 |
|
191 |
+
if(null === $current_version){
|
192 |
+
add_option("gmediaVersion", GMEDIA_VERSION);
|
193 |
+
add_action('init', 'gmedia_flush_rewrite_rules', 1000);
|
194 |
+
} elseif(version_compare($current_version, GMEDIA_VERSION, '<')){
|
195 |
+
gmedia_quite_update();
|
196 |
+
add_action('init', 'gmedia_flush_rewrite_rules', 1000);
|
197 |
+
}
|
198 |
}
|
199 |
|
200 |
function define_tables(){
|
244 |
require_once(dirname(__FILE__) . '/inc/shortcodes.php');
|
245 |
}
|
246 |
}
|
247 |
+
|
248 |
+
$current_plugins = get_option('active_plugins');
|
249 |
+
if (in_array('wordpress-seo/wp-seo.php', $current_plugins)) {
|
250 |
+
require_once (dirname (__FILE__) . '/inc/sitemap.php');
|
251 |
+
}
|
252 |
+
|
253 |
}
|
254 |
|
255 |
function load_textdomain(){
|
270 |
'pluginPath' => $gmCore->gmedia_url
|
271 |
));
|
272 |
|
273 |
+
wp_register_style('grand-media', $gmCore->gmedia_url . '/admin/css/grand-media.css', array(), '1.5.8', 'all');
|
274 |
+
wp_register_script('grand-media', $gmCore->gmedia_url . '/admin/js/grand-media.js', array('jquery', 'gmedia-global-backend'), '1.5.8');
|
275 |
wp_localize_script('grand-media', 'grandMedia', array(
|
276 |
'error3' => __('Disable your Popup Blocker and try again.', 'gmLang'),
|
277 |
'download' => __('downloading...', 'gmLang'),
|
320 |
}
|
321 |
|
322 |
function load_scripts(){
|
323 |
+
wp_enqueue_script('jquery');
|
324 |
wp_enqueue_script('gmedia-global-frontend');
|
325 |
}
|
326 |
|
327 |
function load_module_scripts(){
|
328 |
+
global $wp_styles;
|
329 |
$deps = array();
|
330 |
foreach($this->do_module as $m => $module){
|
331 |
$deps = array_merge($deps, explode(',', $module['info']['dependencies']));
|
332 |
+
$deps = apply_filters('gmedia_module_js_dependencies', $deps, $m);
|
333 |
foreach($deps as $handle){
|
334 |
if(wp_script_is($handle, 'registered')){
|
335 |
wp_enqueue_script($handle, $_src = false, $_deps = array('jquery'), $_ver = false, $_in_footer = true);
|
336 |
}
|
337 |
if(wp_style_is($handle, 'registered')) //wp_enqueue_style( $handle );
|
338 |
{
|
339 |
+
//wp_print_styles($handle);
|
340 |
+
$this->import_styles[] = $wp_styles->registered[$handle]->src;
|
341 |
}
|
342 |
}
|
343 |
$files = glob($module['path'] . '/css/*.css', GLOB_NOSORT);
|
344 |
if(!empty($files)){
|
345 |
$files = array_map('basename', $files);
|
|
|
346 |
foreach($files as $file){
|
347 |
+
$this->import_styles[] = "{$module['url']}/css/{$file}";
|
348 |
}
|
|
|
349 |
}
|
350 |
$files = glob($module['path'] . '/js/*.js', GLOB_NOSORT);
|
351 |
if(!empty($files)){
|
355 |
}
|
356 |
}
|
357 |
}
|
358 |
+
$this->do_module = array();
|
359 |
+
if(!empty($this->import_styles)){
|
360 |
+
add_action('wp_print_styles', array(&$this, 'print_import_styles'));
|
361 |
+
add_action('wp_print_footer_scripts', array(&$this, 'print_import_styles'));
|
362 |
+
}
|
363 |
+
}
|
364 |
+
|
365 |
+
function print_import_styles(){
|
366 |
+
if(!empty($this->import_styles)){
|
367 |
+
echo "\n<style type='text/css'>";
|
368 |
+
foreach($this->import_styles as $src){
|
369 |
+
echo "\n@import url('{$src}') all;";
|
370 |
+
}
|
371 |
+
//echo "\n" . implode("\n", $this->inline_styles);
|
372 |
+
echo "\n</style>\n";
|
373 |
+
$this->import_styles = array();
|
374 |
+
}
|
375 |
}
|
376 |
|
377 |
/**
|
inc/core.php
CHANGED
@@ -72,7 +72,7 @@ class GmediaCore {
|
|
72 |
* Check REQUEST data
|
73 |
*
|
74 |
* @param string $var
|
75 |
-
* @param
|
76 |
*
|
77 |
* @return mixed
|
78 |
*/
|
@@ -1039,6 +1039,203 @@ class GmediaCore {
|
|
1039 |
}
|
1040 |
}
|
1041 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1042 |
/**
|
1043 |
* Retrieve metadata from a video file's ID3 tags
|
1044 |
*
|
@@ -1451,7 +1648,7 @@ class GmediaCore {
|
|
1451 |
}
|
1452 |
}
|
1453 |
|
1454 |
-
global $gmDB;
|
1455 |
|
1456 |
// Write media data to DB
|
1457 |
$title = '';
|
@@ -1463,10 +1660,11 @@ class GmediaCore {
|
|
1463 |
if ( ! isset( $post_data['set_status'] ) ) {
|
1464 |
$post_data['set_status'] = isset( $post_data['status'] ) ? $post_data['status'] : 'inherit';
|
1465 |
}
|
1466 |
-
|
|
|
1467 |
// use image exif/iptc data for title and caption defaults if possible
|
1468 |
if ( $size ) {
|
1469 |
-
$image_meta =
|
1470 |
if ( trim( $image_meta['caption'] ) ) {
|
1471 |
$description = $image_meta['caption'];
|
1472 |
}
|
@@ -1475,6 +1673,7 @@ class GmediaCore {
|
|
1475 |
$title = $image_meta['title'];
|
1476 |
}
|
1477 |
}
|
|
|
1478 |
}
|
1479 |
if ( ( 'empty' != $post_data['set_title'] ) && empty( $title ) ) {
|
1480 |
$title = $fileinfo['title'];
|
@@ -1500,6 +1699,12 @@ class GmediaCore {
|
|
1500 |
unset( $post_data['terms']['gmedia_category'] );
|
1501 |
}
|
1502 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1503 |
// Construct the media array
|
1504 |
$media_data = array(
|
1505 |
'mime_type' => $fileinfo['mime_type'],
|
@@ -1509,7 +1714,12 @@ class GmediaCore {
|
|
1509 |
'description' => $description,
|
1510 |
'status' => $status
|
1511 |
);
|
1512 |
-
|
|
|
|
|
|
|
|
|
|
|
1513 |
if ( ! current_user_can( 'gmedia_delete_others_media' ) ) {
|
1514 |
$media_data['author'] = get_current_user_id();
|
1515 |
}
|
@@ -1537,6 +1747,293 @@ class GmediaCore {
|
|
1537 |
}
|
1538 |
}
|
1539 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1540 |
/**
|
1541 |
* @param string $service
|
1542 |
* @param array $data
|
@@ -1600,9 +2097,15 @@ class GmediaCore {
|
|
1600 |
$result['message'] = $gmProcessor->alert( 'info', $result['message'] );
|
1601 |
}
|
1602 |
|
1603 |
-
$
|
1604 |
-
|
1605 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1606 |
}
|
1607 |
}
|
1608 |
update_option('gmediaOptions', $gm_options);
|
@@ -1719,15 +2222,17 @@ class GmediaCore {
|
|
1719 |
function metadata_text($id){
|
1720 |
$metatext = '';
|
1721 |
if(($metadata = $this->metadata_info($id))){
|
1722 |
-
$metatext .= '<h4>' . __('Meta Data', 'gmLang') . '</h4>';
|
1723 |
foreach($metadata as $meta){
|
|
|
|
|
|
|
1724 |
if(!is_array($meta['value'])){
|
1725 |
-
$metatext .= "
|
1726 |
} else{
|
1727 |
-
$metatext .= "
|
1728 |
foreach($meta['value'] as $key => $value){
|
1729 |
$key_name = ucwords(str_replace('_', ' ', $key));
|
1730 |
-
$metatext .= "
|
1731 |
}
|
1732 |
}
|
1733 |
}
|
@@ -1736,6 +2241,28 @@ class GmediaCore {
|
|
1736 |
return $metatext;
|
1737 |
}
|
1738 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1739 |
}
|
1740 |
|
1741 |
global $gmCore;
|
72 |
* Check REQUEST data
|
73 |
*
|
74 |
* @param string $var
|
75 |
+
* @param mixed $def
|
76 |
*
|
77 |
* @return mixed
|
78 |
*/
|
1039 |
}
|
1040 |
}
|
1041 |
|
1042 |
+
/**
|
1043 |
+
* Get extended image metadata, exif or iptc as available.
|
1044 |
+
*
|
1045 |
+
* Retrieves the EXIF metadata aperture, credit, camera, caption, copyright, iso
|
1046 |
+
* created_timestamp, focal_length, shutter_speed, and title.
|
1047 |
+
*
|
1048 |
+
* The IPTC metadata that is retrieved is APP13, credit, byline, created date
|
1049 |
+
* and time, caption, copyright, and title. Also includes FNumber, Model,
|
1050 |
+
* DateTimeDigitized, FocalLength, ISOSpeedRatings, and ExposureTime.
|
1051 |
+
*
|
1052 |
+
* @todo Try other exif libraries if available.
|
1053 |
+
* @since 2.5.0
|
1054 |
+
*
|
1055 |
+
* @param string $file
|
1056 |
+
* @return bool|array False on failure. Image metadata array on success.
|
1057 |
+
*/
|
1058 |
+
function wp_read_image_metadata( $file ) {
|
1059 |
+
if ( ! file_exists( $file ) )
|
1060 |
+
return false;
|
1061 |
+
|
1062 |
+
list( , , $sourceImageType ) = getimagesize( $file );
|
1063 |
+
|
1064 |
+
/*
|
1065 |
+
* EXIF contains a bunch of data we'll probably never need formatted in ways
|
1066 |
+
* that are difficult to use. We'll normalize it and just extract the fields
|
1067 |
+
* that are likely to be useful. Fractions and numbers are converted to
|
1068 |
+
* floats, dates to unix timestamps, and everything else to strings.
|
1069 |
+
*/
|
1070 |
+
$meta = array(
|
1071 |
+
'aperture' => 0,
|
1072 |
+
'credit' => '',
|
1073 |
+
'camera' => '',
|
1074 |
+
'caption' => '',
|
1075 |
+
'created_timestamp' => 0,
|
1076 |
+
'copyright' => '',
|
1077 |
+
'focal_length' => 0,
|
1078 |
+
'iso' => 0,
|
1079 |
+
'keywords' => array(),
|
1080 |
+
'shutter_speed' => 0,
|
1081 |
+
'title' => '',
|
1082 |
+
'orientation' => 0,
|
1083 |
+
);
|
1084 |
+
|
1085 |
+
/*
|
1086 |
+
* Read IPTC first, since it might contain data not available in exif such
|
1087 |
+
* as caption, description etc.
|
1088 |
+
*/
|
1089 |
+
if ( is_callable( 'iptcparse' ) ) {
|
1090 |
+
getimagesize( $file, $info );
|
1091 |
+
|
1092 |
+
if ( ! empty( $info['APP13'] ) ) {
|
1093 |
+
$iptc = iptcparse( $info['APP13'] );
|
1094 |
+
|
1095 |
+
// Headline, "A brief synopsis of the caption."
|
1096 |
+
if ( ! empty( $iptc['2#105'][0] ) ) {
|
1097 |
+
$meta['title'] = trim( $iptc['2#105'][0] );
|
1098 |
+
/*
|
1099 |
+
* Title, "Many use the Title field to store the filename of the image,
|
1100 |
+
* though the field may be used in many ways."
|
1101 |
+
*/
|
1102 |
+
} elseif ( ! empty( $iptc['2#005'][0] ) ) {
|
1103 |
+
$meta['title'] = trim( $iptc['2#005'][0] );
|
1104 |
+
}
|
1105 |
+
|
1106 |
+
if ( ! empty( $iptc['2#120'][0] ) ) { // description / legacy caption
|
1107 |
+
$caption = trim( $iptc['2#120'][0] );
|
1108 |
+
if ( empty( $meta['title'] ) ) {
|
1109 |
+
mbstring_binary_safe_encoding();
|
1110 |
+
$caption_length = strlen( $caption );
|
1111 |
+
reset_mbstring_encoding();
|
1112 |
+
|
1113 |
+
// Assume the title is stored in 2:120 if it's short.
|
1114 |
+
if ( $caption_length < 80 ) {
|
1115 |
+
$meta['title'] = $caption;
|
1116 |
+
} else {
|
1117 |
+
$meta['caption'] = $caption;
|
1118 |
+
}
|
1119 |
+
} elseif ( $caption != $meta['title'] ) {
|
1120 |
+
$meta['caption'] = $caption;
|
1121 |
+
}
|
1122 |
+
}
|
1123 |
+
|
1124 |
+
if ( ! empty( $iptc['2#110'][0] ) ) // credit
|
1125 |
+
$meta['credit'] = trim( $iptc['2#110'][0] );
|
1126 |
+
elseif ( ! empty( $iptc['2#080'][0] ) ) // creator / legacy byline
|
1127 |
+
$meta['credit'] = trim( $iptc['2#080'][0] );
|
1128 |
+
|
1129 |
+
if ( ! empty( $iptc['2#055'][0] ) and ! empty( $iptc['2#060'][0] ) ) // created date and time
|
1130 |
+
$meta['created_timestamp'] = strtotime( $iptc['2#055'][0] . ' ' . $iptc['2#060'][0] );
|
1131 |
+
|
1132 |
+
if ( ! empty( $iptc['2#116'][0] ) ) // copyright
|
1133 |
+
$meta['copyright'] = trim( $iptc['2#116'][0] );
|
1134 |
+
|
1135 |
+
if ( ! empty( $iptc['2#025'] ) ) // keywords
|
1136 |
+
$meta['keywords'] = $iptc['2#025'];
|
1137 |
+
}
|
1138 |
+
}
|
1139 |
+
|
1140 |
+
/**
|
1141 |
+
* Filter the image types to check for exif data.
|
1142 |
+
*
|
1143 |
+
* @since 2.5.0
|
1144 |
+
*
|
1145 |
+
* @param array $image_types Image types to check for exif data.
|
1146 |
+
*/
|
1147 |
+
if ( is_callable( 'exif_read_data' ) && in_array( $sourceImageType, apply_filters( 'wp_read_image_metadata_types', array( IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM ) ) ) ) {
|
1148 |
+
$exif = @exif_read_data( $file );
|
1149 |
+
|
1150 |
+
if ( empty( $meta['title'] ) && ! empty( $exif['Title'] ) ) {
|
1151 |
+
$meta['title'] = trim( $exif['Title'] );
|
1152 |
+
}
|
1153 |
+
|
1154 |
+
if ( ! empty( $exif['ImageDescription'] ) ) {
|
1155 |
+
mbstring_binary_safe_encoding();
|
1156 |
+
$description_length = strlen( $exif['ImageDescription'] );
|
1157 |
+
reset_mbstring_encoding();
|
1158 |
+
|
1159 |
+
if ( empty( $meta['title'] ) && $description_length < 80 ) {
|
1160 |
+
// Assume the title is stored in ImageDescription
|
1161 |
+
$meta['title'] = trim( $exif['ImageDescription'] );
|
1162 |
+
if ( empty( $meta['caption'] ) && ! empty( $exif['COMPUTED']['UserComment'] ) && trim( $exif['COMPUTED']['UserComment'] ) != $meta['title'] ) {
|
1163 |
+
$meta['caption'] = trim( $exif['COMPUTED']['UserComment'] );
|
1164 |
+
}
|
1165 |
+
} elseif ( empty( $meta['caption'] ) && trim( $exif['ImageDescription'] ) != $meta['title'] ) {
|
1166 |
+
$meta['caption'] = trim( $exif['ImageDescription'] );
|
1167 |
+
}
|
1168 |
+
} elseif ( empty( $meta['caption'] ) && ! empty( $exif['Comments'] ) && trim( $exif['Comments'] ) != $meta['title'] ) {
|
1169 |
+
$meta['caption'] = trim( $exif['Comments'] );
|
1170 |
+
}
|
1171 |
+
|
1172 |
+
if ( empty( $meta['credit'] ) ) {
|
1173 |
+
if ( ! empty( $exif['Artist'] ) ) {
|
1174 |
+
$meta['credit'] = trim( $exif['Artist'] );
|
1175 |
+
} elseif ( ! empty($exif['Author'] ) ) {
|
1176 |
+
$meta['credit'] = trim( $exif['Author'] );
|
1177 |
+
}
|
1178 |
+
}
|
1179 |
+
|
1180 |
+
if ( empty( $meta['copyright'] ) && ! empty( $exif['Copyright'] ) ) {
|
1181 |
+
$meta['copyright'] = trim( $exif['Copyright'] );
|
1182 |
+
}
|
1183 |
+
if ( ! empty( $exif['FNumber'] ) ) {
|
1184 |
+
$meta['aperture'] = round( wp_exif_frac2dec( $exif['FNumber'] ), 2 );
|
1185 |
+
}
|
1186 |
+
if ( ! empty( $exif['Model'] ) ) {
|
1187 |
+
$meta['camera'] = trim( $exif['Model'] );
|
1188 |
+
}
|
1189 |
+
if ( empty( $meta['created_timestamp'] ) && ! empty( $exif['DateTimeDigitized'] ) ) {
|
1190 |
+
$meta['created_timestamp'] = wp_exif_date2ts( $exif['DateTimeDigitized'] );
|
1191 |
+
}
|
1192 |
+
if ( ! empty( $exif['FocalLength'] ) ) {
|
1193 |
+
$meta['focal_length'] = (string) wp_exif_frac2dec( $exif['FocalLength'] );
|
1194 |
+
}
|
1195 |
+
if ( ! empty( $exif['ISOSpeedRatings'] ) ) {
|
1196 |
+
$meta['iso'] = is_array( $exif['ISOSpeedRatings'] ) ? reset( $exif['ISOSpeedRatings'] ) : $exif['ISOSpeedRatings'];
|
1197 |
+
$meta['iso'] = trim( $meta['iso'] );
|
1198 |
+
}
|
1199 |
+
if ( ! empty( $exif['ExposureTime'] ) ) {
|
1200 |
+
$meta['shutter_speed'] = (string) wp_exif_frac2dec( $exif['ExposureTime'] );
|
1201 |
+
}
|
1202 |
+
if ( ! empty( $exif['Orientation'] ) ) {
|
1203 |
+
$meta['orientation'] = $exif['Orientation'];
|
1204 |
+
}
|
1205 |
+
}
|
1206 |
+
|
1207 |
+
foreach ( array( 'title', 'caption', 'credit', 'copyright', 'camera', 'iso' ) as $key ) {
|
1208 |
+
if ( $meta[ $key ] && ! seems_utf8( $meta[ $key ] ) ) {
|
1209 |
+
$meta[ $key ] = utf8_encode( $meta[ $key ] );
|
1210 |
+
}
|
1211 |
+
}
|
1212 |
+
if(!empty($meta['keywords'])){
|
1213 |
+
foreach ( $meta['keywords'] as $i => $key ) {
|
1214 |
+
if ( ! seems_utf8( $key ) ) {
|
1215 |
+
$meta['keywords'][$i] = utf8_encode( $key );
|
1216 |
+
}
|
1217 |
+
}
|
1218 |
+
}
|
1219 |
+
|
1220 |
+
foreach ( $meta as &$value ) {
|
1221 |
+
if ( is_string( $value ) ) {
|
1222 |
+
$value = wp_kses_post( $value );
|
1223 |
+
}
|
1224 |
+
}
|
1225 |
+
|
1226 |
+
/**
|
1227 |
+
* Filter the array of meta data read from an image's exif data.
|
1228 |
+
*
|
1229 |
+
* @since 2.5.0
|
1230 |
+
*
|
1231 |
+
* @param array $meta Image meta data.
|
1232 |
+
* @param string $file Path to image file.
|
1233 |
+
* @param int $sourceImageType Type of image.
|
1234 |
+
*/
|
1235 |
+
return apply_filters( 'wp_read_image_metadata', $meta, $file, $sourceImageType );
|
1236 |
+
|
1237 |
+
}
|
1238 |
+
|
1239 |
/**
|
1240 |
* Retrieve metadata from a video file's ID3 tags
|
1241 |
*
|
1648 |
}
|
1649 |
}
|
1650 |
|
1651 |
+
global $gmDB, $gmCore;
|
1652 |
|
1653 |
// Write media data to DB
|
1654 |
$title = '';
|
1660 |
if ( ! isset( $post_data['set_status'] ) ) {
|
1661 |
$post_data['set_status'] = isset( $post_data['status'] ) ? $post_data['status'] : 'inherit';
|
1662 |
}
|
1663 |
+
|
1664 |
+
$keywords = array();
|
1665 |
// use image exif/iptc data for title and caption defaults if possible
|
1666 |
if ( $size ) {
|
1667 |
+
$image_meta = @$gmCore->wp_read_image_metadata( $fileinfo['filepath_original'] );
|
1668 |
if ( trim( $image_meta['caption'] ) ) {
|
1669 |
$description = $image_meta['caption'];
|
1670 |
}
|
1673 |
$title = $image_meta['title'];
|
1674 |
}
|
1675 |
}
|
1676 |
+
$keywords = $image_meta['keywords'];
|
1677 |
}
|
1678 |
if ( ( 'empty' != $post_data['set_title'] ) && empty( $title ) ) {
|
1679 |
$title = $fileinfo['title'];
|
1699 |
unset( $post_data['terms']['gmedia_category'] );
|
1700 |
}
|
1701 |
|
1702 |
+
if(isset( $post_data['terms']['gmedia_tag'] ) && !empty($post_data['terms']['gmedia_tag']) && !is_array($post_data['terms']['gmedia_tag'])){
|
1703 |
+
$post_data['terms']['gmedia_tag'] = explode(',', $post_data['terms']['gmedia_tag']);
|
1704 |
+
} else{
|
1705 |
+
$post_data['terms']['gmedia_tag'] = array();
|
1706 |
+
}
|
1707 |
+
|
1708 |
// Construct the media array
|
1709 |
$media_data = array(
|
1710 |
'mime_type' => $fileinfo['mime_type'],
|
1714 |
'description' => $description,
|
1715 |
'status' => $status
|
1716 |
);
|
1717 |
+
|
1718 |
+
if(!empty($keywords)){
|
1719 |
+
$media_data['terms']['gmedia_tag'] = $keywords;
|
1720 |
+
}
|
1721 |
+
$media_data = $this->array_replace_recursive( $media_data, $post_data );
|
1722 |
+
|
1723 |
if ( ! current_user_can( 'gmedia_delete_others_media' ) ) {
|
1724 |
$media_data['author'] = get_current_user_id();
|
1725 |
}
|
1747 |
}
|
1748 |
}
|
1749 |
|
1750 |
+
/**
|
1751 |
+
* @param $files
|
1752 |
+
* @param $terms
|
1753 |
+
* @param $move
|
1754 |
+
* @param int|string $exists
|
1755 |
+
*/
|
1756 |
+
function gmedia_import_files( $files, $terms, $move, $exists = 0 ) {
|
1757 |
+
global $gmCore, $gmGallery, $gmDB;
|
1758 |
+
|
1759 |
+
if ( ob_get_level() == 0 ) {
|
1760 |
+
ob_start();
|
1761 |
+
}
|
1762 |
+
$eol = '</pre>' . PHP_EOL;
|
1763 |
+
|
1764 |
+
$_terms = $terms;
|
1765 |
+
|
1766 |
+
$gmedia_album = isset( $_terms['gmedia_album'] ) ? $_terms['gmedia_album'] : false;
|
1767 |
+
if ( $gmedia_album && $gmCore->is_digit( $gmedia_album ) ) {
|
1768 |
+
$album = $gmDB->get_term( $gmedia_album, 'gmedia_album' );
|
1769 |
+
if ( empty( $album ) || is_wp_error( $album ) ) {
|
1770 |
+
$status = 'public';
|
1771 |
+
} else {
|
1772 |
+
$status = $album->status;
|
1773 |
+
$album_name = $album->name;
|
1774 |
+
}
|
1775 |
+
} else {
|
1776 |
+
$status = 'public';
|
1777 |
+
}
|
1778 |
+
|
1779 |
+
$c = count( $files );
|
1780 |
+
$i = 0;
|
1781 |
+
foreach ( $files as $file ) {
|
1782 |
+
|
1783 |
+
if ( is_array( $file ) ) {
|
1784 |
+
if ( isset( $file['file'] ) ) {
|
1785 |
+
extract( $file );
|
1786 |
+
} else {
|
1787 |
+
_e( 'Something went wrong...', 'gmLang' );
|
1788 |
+
die();
|
1789 |
+
}
|
1790 |
+
}
|
1791 |
+
|
1792 |
+
wp_ob_end_flush_all();
|
1793 |
+
flush();
|
1794 |
+
|
1795 |
+
$i ++;
|
1796 |
+
$prefix = "\n<pre>$i/$c - ";
|
1797 |
+
$prefix_ko = "\n<pre class='ko'>$i/$c - ";
|
1798 |
+
|
1799 |
+
if ( ! is_file( $file ) ) {
|
1800 |
+
echo $prefix_ko . sprintf( __( 'File not exists: %s', 'gmLang' ), $file ) . $eol;
|
1801 |
+
continue;
|
1802 |
+
}
|
1803 |
+
|
1804 |
+
if('skip' === $exists){
|
1805 |
+
$file_suffix = false;
|
1806 |
+
} else{
|
1807 |
+
$file_suffix = $exists;
|
1808 |
+
}
|
1809 |
+
$fileinfo = $gmCore->fileinfo( $file, $file_suffix );
|
1810 |
+
|
1811 |
+
if(('skip' === $exists) && file_exists( $fileinfo['filepath'] )){
|
1812 |
+
echo $prefix . $fileinfo['basename'] . ': ' . __( 'file already exists', 'gmLang' ) . $eol;
|
1813 |
+
continue;
|
1814 |
+
}
|
1815 |
+
|
1816 |
+
|
1817 |
+
// try to make grand-media dir if not exists
|
1818 |
+
if ( ! wp_mkdir_p( $fileinfo['dirpath'] ) ) {
|
1819 |
+
echo $prefix_ko . sprintf( __( 'Unable to create directory `%s`. Is its parent directory writable by the server?', 'gmLang' ), $fileinfo['dirpath'] ) . $eol;
|
1820 |
+
continue;
|
1821 |
+
}
|
1822 |
+
// Check if grand-media dir is writable
|
1823 |
+
if ( ! is_writable( $fileinfo['dirpath'] ) ) {
|
1824 |
+
@chmod( $fileinfo['dirpath'], 0755 );
|
1825 |
+
if ( ! is_writable( $fileinfo['dirpath'] ) ) {
|
1826 |
+
echo $prefix_ko . sprintf( __( 'Directory `%s` or its subfolders are not writable by the server.', 'gmLang' ), dirname( $fileinfo['dirpath'] ) ) . $eol;
|
1827 |
+
continue;
|
1828 |
+
}
|
1829 |
+
}
|
1830 |
+
|
1831 |
+
if ( ! copy( $file, $fileinfo['filepath'] ) ) {
|
1832 |
+
echo $prefix_ko . sprintf( __( "Can't copy file from `%s` to `%s`", 'gmLang' ), $file, $fileinfo['filepath'] ) . $eol;
|
1833 |
+
continue;
|
1834 |
+
}
|
1835 |
+
|
1836 |
+
$gmCore->file_chmod( $fileinfo['filepath'] );
|
1837 |
+
|
1838 |
+
$size = false;
|
1839 |
+
$is_webimage = false;
|
1840 |
+
if ( 'image' == $fileinfo['dirname'] ) {
|
1841 |
+
/** WordPress Image Administration API */
|
1842 |
+
require_once( ABSPATH . 'wp-admin/includes/image.php' );
|
1843 |
+
|
1844 |
+
$size = @getimagesize( $fileinfo['filepath'] );
|
1845 |
+
if ( $size && file_is_displayable_image( $fileinfo['filepath'] ) ) {
|
1846 |
+
if ( function_exists( 'memory_get_usage' ) ) {
|
1847 |
+
$extensions = array( '1' => 'GIF', '2' => 'JPG', '3' => 'PNG', '6' => 'BMP' );
|
1848 |
+
switch ( $extensions[ $size[2] ] ) {
|
1849 |
+
case 'GIF':
|
1850 |
+
$CHANNEL = 1;
|
1851 |
+
break;
|
1852 |
+
case 'JPG':
|
1853 |
+
$CHANNEL = $size['channels'];
|
1854 |
+
break;
|
1855 |
+
case 'PNG':
|
1856 |
+
$CHANNEL = 3;
|
1857 |
+
break;
|
1858 |
+
case 'BMP':
|
1859 |
+
default:
|
1860 |
+
$CHANNEL = 6;
|
1861 |
+
break;
|
1862 |
+
}
|
1863 |
+
$MB = 1048576; // number of bytes in 1M
|
1864 |
+
$K64 = 65536; // number of bytes in 64K
|
1865 |
+
$TWEAKFACTOR = 1.8; // Or whatever works for you
|
1866 |
+
$memoryNeeded = round( ( $size[0] * $size[1] * $size['bits'] * $CHANNEL / 8 + $K64 ) * $TWEAKFACTOR );
|
1867 |
+
$memoryNeeded = memory_get_usage() + $memoryNeeded;
|
1868 |
+
$current_limit = @ini_get( 'memory_limit' );
|
1869 |
+
$current_limit_int = intval( $current_limit );
|
1870 |
+
if ( false !== strpos( $current_limit, 'M' ) ) {
|
1871 |
+
$current_limit_int *= $MB;
|
1872 |
+
}
|
1873 |
+
if ( false !== strpos( $current_limit, 'G' ) ) {
|
1874 |
+
$current_limit_int *= 1024;
|
1875 |
+
}
|
1876 |
+
|
1877 |
+
if ( - 1 != $current_limit && $memoryNeeded > $current_limit_int ) {
|
1878 |
+
$newLimit = $current_limit_int / $MB + ceil( ( $memoryNeeded - $current_limit_int ) / $MB );
|
1879 |
+
@ini_set( 'memory_limit', $newLimit . 'M' );
|
1880 |
+
}
|
1881 |
+
}
|
1882 |
+
|
1883 |
+
if ( ! wp_mkdir_p( $fileinfo['dirpath_thumb'] ) ) {
|
1884 |
+
echo $prefix_ko . sprintf( __( 'Unable to create directory `%s`. Is its parent directory writable by the server?', 'gmLang' ), $fileinfo['dirpath_thumb'] ) . $eol;
|
1885 |
+
continue;
|
1886 |
+
}
|
1887 |
+
if ( ! is_writable( $fileinfo['dirpath_thumb'] ) ) {
|
1888 |
+
@chmod( $fileinfo['dirpath_thumb'], 0755 );
|
1889 |
+
if ( ! is_writable( $fileinfo['dirpath_thumb'] ) ) {
|
1890 |
+
@unlink( $fileinfo['filepath'] );
|
1891 |
+
echo $prefix_ko . sprintf( __( 'Directory `%s` is not writable by the server.', 'gmLang' ), $fileinfo['dirpath_thumb'] ) . $eol;
|
1892 |
+
continue;
|
1893 |
+
}
|
1894 |
+
}
|
1895 |
+
if ( ! wp_mkdir_p( $fileinfo['dirpath_original'] ) ) {
|
1896 |
+
echo $prefix_ko . sprintf( __( 'Unable to create directory `%s`. Is its parent directory writable by the server?', 'gmLang' ), $fileinfo['dirpath_original'] ) . $eol;
|
1897 |
+
continue;
|
1898 |
+
}
|
1899 |
+
if ( ! is_writable( $fileinfo['dirpath_original'] ) ) {
|
1900 |
+
@chmod( $fileinfo['dirpath_original'], 0755 );
|
1901 |
+
if ( ! is_writable( $fileinfo['dirpath_original'] ) ) {
|
1902 |
+
@unlink( $fileinfo['filepath'] );
|
1903 |
+
echo $prefix_ko . sprintf( __( 'Directory `%s` is not writable by the server.', 'gmLang' ), $fileinfo['dirpath_original'] ) . $eol;
|
1904 |
+
continue;
|
1905 |
+
}
|
1906 |
+
}
|
1907 |
+
|
1908 |
+
// Optimized image
|
1909 |
+
$webimg = $gmGallery->options['image'];
|
1910 |
+
$thumbimg = $gmGallery->options['thumb'];
|
1911 |
+
|
1912 |
+
$webimg['resize'] = ( ( $webimg['width'] < $size[0] ) || ( $webimg['height'] < $size[1] ) ) ? true : false;
|
1913 |
+
$thumbimg['resize'] = ( ( $thumbimg['width'] < $size[0] ) || ( $thumbimg['height'] < $size[1] ) ) ? true : false;
|
1914 |
+
|
1915 |
+
if ( $webimg['resize'] ) {
|
1916 |
+
rename( $fileinfo['filepath'], $fileinfo['filepath_original'] );
|
1917 |
+
} else {
|
1918 |
+
copy( $fileinfo['filepath'], $fileinfo['filepath_original'] );
|
1919 |
+
}
|
1920 |
+
if ( $webimg['resize'] || $thumbimg['resize'] ) {
|
1921 |
+
$editor = wp_get_image_editor( $fileinfo['filepath_original'] );
|
1922 |
+
if ( is_wp_error( $editor ) ) {
|
1923 |
+
@unlink( $fileinfo['filepath_original'] );
|
1924 |
+
echo $prefix_ko . $fileinfo['basename'] . " (wp_get_image_editor): " . $editor->get_error_message() . $eol;
|
1925 |
+
continue;
|
1926 |
+
}
|
1927 |
+
|
1928 |
+
if ( $webimg['resize'] ) {
|
1929 |
+
$editor->set_quality( $webimg['quality'] );
|
1930 |
+
|
1931 |
+
$resized = $editor->resize( $webimg['width'], $webimg['height'], $webimg['crop'] );
|
1932 |
+
if ( is_wp_error( $resized ) ) {
|
1933 |
+
@unlink( $fileinfo['filepath_original'] );
|
1934 |
+
echo $prefix_ko . $fileinfo['basename'] . " (" . $resized->get_error_code() . " | editor->resize->webimage({$webimg['width']}, {$webimg['height']}, {$webimg['crop']})): " . $resized->get_error_message() . $eol;
|
1935 |
+
continue;
|
1936 |
+
}
|
1937 |
+
|
1938 |
+
$saved = $editor->save( $fileinfo['filepath'] );
|
1939 |
+
if ( is_wp_error( $saved ) ) {
|
1940 |
+
@unlink( $fileinfo['filepath_original'] );
|
1941 |
+
echo $prefix_ko . $fileinfo['basename'] . " (" . $saved->get_error_code() . " | editor->save->webimage): " . $saved->get_error_message() . $eol;
|
1942 |
+
continue;
|
1943 |
+
}
|
1944 |
+
}
|
1945 |
+
|
1946 |
+
// Thumbnail
|
1947 |
+
$editor->set_quality( $thumbimg['quality'] );
|
1948 |
+
|
1949 |
+
$resized = $editor->resize( $thumbimg['width'], $thumbimg['height'], $thumbimg['crop'] );
|
1950 |
+
if ( is_wp_error( $resized ) ) {
|
1951 |
+
@unlink( $fileinfo['filepath'] );
|
1952 |
+
@unlink( $fileinfo['filepath_original'] );
|
1953 |
+
echo $prefix_ko . $fileinfo['basename'] . " (" . $resized->get_error_code() . " | editor->resize->thumb({$thumbimg['width']}, {$thumbimg['height']}, {$thumbimg['crop']})): " . $resized->get_error_message() . $eol;
|
1954 |
+
continue;
|
1955 |
+
}
|
1956 |
+
|
1957 |
+
$saved = $editor->save( $fileinfo['filepath_thumb'] );
|
1958 |
+
if ( is_wp_error( $saved ) ) {
|
1959 |
+
@unlink( $fileinfo['filepath'] );
|
1960 |
+
@unlink( $fileinfo['filepath_original'] );
|
1961 |
+
echo $prefix_ko . $fileinfo['basename'] . " (" . $saved->get_error_code() . " | editor->save->thumb): " . $saved->get_error_message() . $eol;
|
1962 |
+
continue;
|
1963 |
+
}
|
1964 |
+
} else {
|
1965 |
+
copy( $fileinfo['filepath'], $fileinfo['filepath_thumb'] );
|
1966 |
+
}
|
1967 |
+
$is_webimage = true;
|
1968 |
+
} else {
|
1969 |
+
@unlink( $fileinfo['filepath'] );
|
1970 |
+
echo $prefix_ko . $fileinfo['basename'] . ": " . __( "Could not read image size. Invalid image was deleted.", 'gmLang' ) . $eol;
|
1971 |
+
continue;
|
1972 |
+
}
|
1973 |
+
}
|
1974 |
+
|
1975 |
+
// Write media data to DB
|
1976 |
+
// TODO Option to set title empty string or from metadata or from filename or both
|
1977 |
+
// use image exif/iptc data for title and caption defaults if possible
|
1978 |
+
if ( $size && ! isset( $title ) && ! isset( $description ) ) {
|
1979 |
+
$image_meta = @$gmCore->wp_read_image_metadata( $fileinfo['filepath_original'] );
|
1980 |
+
if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) {
|
1981 |
+
$title = $image_meta['title'];
|
1982 |
+
}
|
1983 |
+
if ( trim( $image_meta['caption'] ) ) {
|
1984 |
+
$description = $image_meta['caption'];
|
1985 |
+
}
|
1986 |
+
}
|
1987 |
+
if ( ! isset( $title ) || empty( $title ) ) {
|
1988 |
+
$title = $fileinfo['title'];
|
1989 |
+
}
|
1990 |
+
if ( ! isset( $description ) ) {
|
1991 |
+
$description = '';
|
1992 |
+
}
|
1993 |
+
if ( ! isset( $link ) ) {
|
1994 |
+
$link = '';
|
1995 |
+
}
|
1996 |
+
|
1997 |
+
if ( ! $is_webimage ) {
|
1998 |
+
unset( $_terms['gmedia_category'] );
|
1999 |
+
}
|
2000 |
+
|
2001 |
+
// Construct the media_data array
|
2002 |
+
$media_data = array(
|
2003 |
+
'mime_type' => $fileinfo['mime_type'],
|
2004 |
+
'gmuid' => $fileinfo['basename'],
|
2005 |
+
'title' => $title,
|
2006 |
+
'link' => $link,
|
2007 |
+
'description' => $description,
|
2008 |
+
'status' => $status,
|
2009 |
+
'terms' => $_terms
|
2010 |
+
);
|
2011 |
+
if ( ! current_user_can( 'gmedia_delete_others_media' ) ) {
|
2012 |
+
$media_data['author'] = get_current_user_id();
|
2013 |
+
}
|
2014 |
+
|
2015 |
+
unset( $title, $description );
|
2016 |
+
|
2017 |
+
// Save the data
|
2018 |
+
$id = $gmDB->insert_gmedia( $media_data );
|
2019 |
+
$gmDB->update_metadata( $meta_type = 'gmedia', $id, $meta_key = '_metadata', $gmDB->generate_gmedia_metadata( $id, $fileinfo ) );
|
2020 |
+
|
2021 |
+
echo $prefix . $fileinfo['basename'] . ': <span class="ok">' . sprintf( __( 'success (ID #%s)', 'gmLang' ), $id ) . '</span>' . $eol;
|
2022 |
+
|
2023 |
+
if ( $move ) {
|
2024 |
+
@unlink( $file );
|
2025 |
+
}
|
2026 |
+
|
2027 |
+
}
|
2028 |
+
|
2029 |
+
echo '<p><b>' . __( 'Category' ) . ':</b> ' . ( ( isset( $terms['gmedia_category'] ) && ! empty( $terms['gmedia_category'] ) ) ? esc_html( $gmGallery->options['taxonomies']['gmedia_category'][ $terms['gmedia_category'] ] ) : '-' ) . PHP_EOL;
|
2030 |
+
echo '<br /><b>' . __( 'Album' ) . ':</b> ' . ( ( isset( $terms['gmedia_album'] ) && ! empty( $terms['gmedia_album'] ) ) ? ( isset($album_name)? $album_name : esc_html( $terms['gmedia_album'] ) ) : '-' ) . PHP_EOL;
|
2031 |
+
echo '<br /><b>' . __( 'Tags' ) . ':</b> ' . ( ( isset( $terms['gmedia_tag'] ) && ! empty( $terms['gmedia_tag'] ) ) ? esc_html( str_replace( ',', ', ', $terms['gmedia_tag'] ) ) : '-' ) . '</p>' . PHP_EOL;
|
2032 |
+
|
2033 |
+
wp_ob_end_flush_all();
|
2034 |
+
flush();
|
2035 |
+
}
|
2036 |
+
|
2037 |
/**
|
2038 |
* @param string $service
|
2039 |
* @param array $data
|
2097 |
$result['message'] = $gmProcessor->alert( 'info', $result['message'] );
|
2098 |
}
|
2099 |
|
2100 |
+
if(isset($result['site_ID'])){
|
2101 |
+
$gm_options['site_ID'] = $result['site_ID'];
|
2102 |
+
}
|
2103 |
+
if(isset($result['mobile_app'])){
|
2104 |
+
$gm_options['mobile_app'] = $result['mobile_app'];
|
2105 |
+
}
|
2106 |
+
if(isset($result['site_category'])){
|
2107 |
+
$gm_options['site_category'] = $result['site_category'];
|
2108 |
+
}
|
2109 |
}
|
2110 |
}
|
2111 |
update_option('gmediaOptions', $gm_options);
|
2222 |
function metadata_text($id){
|
2223 |
$metatext = '';
|
2224 |
if(($metadata = $this->metadata_info($id))){
|
|
|
2225 |
foreach($metadata as $meta){
|
2226 |
+
if($meta['name'] == 'Image'){
|
2227 |
+
continue;
|
2228 |
+
}
|
2229 |
if(!is_array($meta['value'])){
|
2230 |
+
$metatext .= "<b>{$meta['name']}:</b> {$meta['value']}\n";
|
2231 |
} else{
|
2232 |
+
$metatext .= "<b>{$meta['name']}:</b>\n";
|
2233 |
foreach($meta['value'] as $key => $value){
|
2234 |
$key_name = ucwords(str_replace('_', ' ', $key));
|
2235 |
+
$metatext .= " - <b>{$key_name}:</b> {$value}\n";
|
2236 |
}
|
2237 |
}
|
2238 |
}
|
2241 |
return $metatext;
|
2242 |
}
|
2243 |
|
2244 |
+
/**
|
2245 |
+
* Update media meta in the database
|
2246 |
+
*
|
2247 |
+
* @param $gmID
|
2248 |
+
* @param $meta
|
2249 |
+
*
|
2250 |
+
* @return
|
2251 |
+
*/
|
2252 |
+
function gm_hitcounter($gmID, $meta) {
|
2253 |
+
/** @var wpdb $wpdb */
|
2254 |
+
global $gmDB;
|
2255 |
+
if( isset($_POST['vote']) ) {
|
2256 |
+
$meta['likes'] +=1;
|
2257 |
+
$gmDB->update_metadata('gmedia', $gmID, 'likes', $meta['likes']);
|
2258 |
+
}
|
2259 |
+
else {
|
2260 |
+
$meta['views'] +=1;
|
2261 |
+
$gmDB->update_metadata('gmedia', $gmID, 'views', $meta['views']);
|
2262 |
+
}
|
2263 |
+
return $meta;
|
2264 |
+
}
|
2265 |
+
|
2266 |
}
|
2267 |
|
2268 |
global $gmCore;
|
inc/db.connect.php
CHANGED
@@ -372,6 +372,9 @@ class GmediaDB{
|
|
372 |
if(isset($object['link'])){
|
373 |
$object['link'] = esc_url_raw($object['link']);
|
374 |
}
|
|
|
|
|
|
|
375 |
|
376 |
// export array as variables
|
377 |
extract($object, EXTR_SKIP);
|
@@ -414,10 +417,10 @@ class GmediaDB{
|
|
414 |
if(isset($terms) && is_array($terms) && count($terms)){
|
415 |
foreach($terms as $taxonomy => $_terms){
|
416 |
$taxonomy = trim($taxonomy);
|
417 |
-
if('gmedia_tag' == $taxonomy){
|
418 |
$_terms = explode(',', $_terms);
|
419 |
} else{
|
420 |
-
$_terms = array
|
421 |
}
|
422 |
if(!empty($taxonomy)){
|
423 |
$this->set_gmedia_terms($media_ID, $_terms, $taxonomy, $append = 0);
|
@@ -428,7 +431,7 @@ class GmediaDB{
|
|
428 |
wp_cache_delete($media_ID, 'gmedias');
|
429 |
wp_cache_delete($media_ID, 'gmedia_meta');
|
430 |
|
431 |
-
$this->
|
432 |
|
433 |
do_action('clean_gmedia_cache', $media_ID);
|
434 |
|
@@ -465,7 +468,7 @@ class GmediaDB{
|
|
465 |
return $gmedia;
|
466 |
}
|
467 |
|
468 |
-
//$meta = $
|
469 |
|
470 |
$this->delete_gmedia_term_relationships($gmedia_id, array('gmedia_album', 'gmedia_tag', 'gmedia_category'));
|
471 |
|
@@ -534,7 +537,7 @@ class GmediaDB{
|
|
534 |
|
535 |
wp_cache_delete($gmedia_id, 'gmedias');
|
536 |
wp_cache_delete($gmedia_id, 'gmedia_meta');
|
537 |
-
$this->
|
538 |
|
539 |
do_action('clean_gmedia_cache', $gmedia_id);
|
540 |
|
@@ -556,7 +559,7 @@ class GmediaDB{
|
|
556 |
*/
|
557 |
function delete_gmedia_term_relationships($object_id, $taxonomies){
|
558 |
/** @var $wpdb wpdb */
|
559 |
-
global $wpdb
|
560 |
|
561 |
$object_id = (int)$object_id;
|
562 |
|
@@ -565,12 +568,12 @@ class GmediaDB{
|
|
565 |
}
|
566 |
|
567 |
foreach((array)$taxonomies as $taxonomy){
|
568 |
-
$term_ids = $
|
569 |
$in_term_ids = "'" . implode("', '", $term_ids) . "'";
|
570 |
do_action('delete_gmedia_term_relationships', $object_id, $term_ids);
|
571 |
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}gmedia_term_relationships WHERE gmedia_id = %d AND gmedia_term_id IN ($in_term_ids)", $object_id));
|
572 |
do_action('deleted_gmedia_term_relationships', $object_id, $term_ids);
|
573 |
-
$
|
574 |
}
|
575 |
}
|
576 |
|
@@ -605,7 +608,7 @@ class GmediaDB{
|
|
605 |
$metadata['file'] = $this->_gm_relative_upload_path($fileinfo['filepath']);
|
606 |
|
607 |
// fetch additional metadata from exif/iptc
|
608 |
-
$image_meta = wp_read_image_metadata($fileinfo['filepath_original']);
|
609 |
if($image_meta){
|
610 |
$metadata['image_meta'] = $image_meta;
|
611 |
}
|
@@ -1511,7 +1514,7 @@ class GmediaDB{
|
|
1511 |
$orderby = "{$wpdb->prefix}gmedia.ID " . $q['order'];
|
1512 |
} else{
|
1513 |
// Used to filter values TODO make orderby comment count
|
1514 |
-
$allowed_keys = array('
|
1515 |
if($album['order'] && !empty($album['alias'])){
|
1516 |
$allowed_keys[] = 'custom';
|
1517 |
}
|
@@ -1548,6 +1551,9 @@ class GmediaDB{
|
|
1548 |
$orderby = "{$wpdb->prefix}gmedia.ID";
|
1549 |
}
|
1550 |
break;
|
|
|
|
|
|
|
1551 |
case 'custom':
|
1552 |
$orderby = "{$album['alias']}.gmedia_order {$q['order']}, {$wpdb->prefix}gmedia.ID";
|
1553 |
break;
|
@@ -2313,40 +2319,34 @@ class GmediaDB{
|
|
2313 |
return $cache;
|
2314 |
}
|
2315 |
|
|
|
|
|
|
|
|
|
|
|
2316 |
$_orderby = strtolower($orderby);
|
2317 |
if('count' == $_orderby){
|
2318 |
-
$orderby =
|
2319 |
} else if('name' == $_orderby){
|
2320 |
-
$orderby =
|
2321 |
} else if('description' == $_orderby){
|
2322 |
-
$orderby =
|
2323 |
} else if('global' == $_orderby){
|
2324 |
-
$orderby =
|
2325 |
} else if('global_desc_name' == $_orderby){
|
2326 |
-
$orderby =
|
2327 |
} else if('global_asc_name' == $_orderby){
|
2328 |
-
$orderby =
|
2329 |
} else if('none' == $_orderby){
|
2330 |
$orderby = '';
|
2331 |
} elseif(empty($_orderby) || 'id' == $_orderby){
|
2332 |
-
$orderby =
|
2333 |
} else{
|
2334 |
-
$orderby =
|
2335 |
}
|
2336 |
|
2337 |
$orderby = apply_filters('gmedia_get_terms_orderby', $orderby, $args);
|
2338 |
|
2339 |
-
if(!empty($orderby)){
|
2340 |
-
$orderby = "ORDER BY $orderby";
|
2341 |
-
} else{
|
2342 |
-
$order = '';
|
2343 |
-
}
|
2344 |
-
|
2345 |
-
$order = strtoupper($order);
|
2346 |
-
if('' !== $order && !in_array($order, array('ASC', 'DESC'))){
|
2347 |
-
$order = 'ASC';
|
2348 |
-
}
|
2349 |
-
|
2350 |
$where_ = "t.taxonomy IN ('" . implode("', '", $taxonomies) . "')";
|
2351 |
$where = '';
|
2352 |
$inclusions = '';
|
@@ -2442,7 +2442,6 @@ class GmediaDB{
|
|
2442 |
break;
|
2443 |
case 'count':
|
2444 |
$orderby = '';
|
2445 |
-
$order = '';
|
2446 |
$selects = array('COUNT(*)');
|
2447 |
break;
|
2448 |
case 'all':
|
@@ -2469,7 +2468,7 @@ class GmediaDB{
|
|
2469 |
}
|
2470 |
|
2471 |
$where_where = $where_ . $where;
|
2472 |
-
$query = "SELECT $found_rows $fields FROM {$wpdb->prefix}gmedia_term AS t $join WHERE $where_where $orderby $
|
2473 |
|
2474 |
$fields = $_fields;
|
2475 |
|
@@ -2574,7 +2573,6 @@ class GmediaDB{
|
|
2574 |
*
|
2575 |
* @uses apply_filters() Calls 'pre_insert_gmedia_term' hook with term and taxonomy as parameters.
|
2576 |
* @uses do_action() Calls 'create_gmedia_term' hook with the term id and taxonomy id as parameters.
|
2577 |
-
* @uses apply_filters() Calls 'gmedia_term_id_filter' hook with term id and taxonomy id as parameters.
|
2578 |
* @uses do_action() Calls 'created_gmedia_term' hook with the term id and taxonomy id as parameters.
|
2579 |
*
|
2580 |
* @param string $term The term to add or update.
|
@@ -2585,7 +2583,7 @@ class GmediaDB{
|
|
2585 |
*/
|
2586 |
function insert_term($term, $taxonomy, $args = array()){
|
2587 |
/** @var $wpdb wpdb */
|
2588 |
-
global $wpdb, $
|
2589 |
|
2590 |
if(!isset($gmGallery->options['taxonomies'][$taxonomy])){
|
2591 |
return new WP_Error('gm_invalid_taxonomy', __('Invalid taxonomy'));
|
@@ -2636,10 +2634,8 @@ class GmediaDB{
|
|
2636 |
|
2637 |
do_action("create_gmedia_term", $term_id, $taxonomy);
|
2638 |
|
2639 |
-
$term_id = apply_filters('gmedia_term_id_filter', $term_id);
|
2640 |
-
|
2641 |
// ? maybe move function to plugin core (refactor!)
|
2642 |
-
$
|
2643 |
|
2644 |
do_action("created_gmedia_term", $term_id, $taxonomy);
|
2645 |
|
@@ -2653,26 +2649,9 @@ class GmediaDB{
|
|
2653 |
* Care must be taken to not override important information need to update or
|
2654 |
* update will fail (or perhaps create a new term, neither would be acceptable).
|
2655 |
*
|
2656 |
-
* Defaults will set 'alias_of', 'description', 'parent', and 'slug' if not
|
2657 |
-
* defined in $args already.
|
2658 |
-
*
|
2659 |
-
* 'alias_of' will create a term group, if it doesn't already exist, and update
|
2660 |
-
* it for the $term.
|
2661 |
-
*
|
2662 |
-
* If the 'slug' argument in $args is missing, then the 'name' in $args will be
|
2663 |
-
* used. It should also be noted that if you set 'slug' and it isn't unique then
|
2664 |
-
* a WP_Error will be passed back. If you don't pass any slug, then a unique one
|
2665 |
-
* will be created for you.
|
2666 |
-
*
|
2667 |
-
* For what can be overrode in $args, check the term scheme can contain and stay
|
2668 |
-
* away from the term keys.
|
2669 |
-
*
|
2670 |
-
*
|
2671 |
* @see wp_update_term()
|
2672 |
* @uses $wpdb
|
2673 |
-
* @uses do_action() Will call both 'edit_gmedia_term' and 'edit_$taxonomy'
|
2674 |
-
* @uses apply_filters() Will call the 'gmedia_term_id_filter' filter and pass the term
|
2675 |
-
* id and taxonomy id.
|
2676 |
*
|
2677 |
* @param int $term_id The ID of the term
|
2678 |
* @param string $taxonomy The context in which to relate the term to the object.
|
@@ -2682,7 +2661,7 @@ class GmediaDB{
|
|
2682 |
*/
|
2683 |
function update_term($term_id, $taxonomy, $args = array()){
|
2684 |
/** @var $wpdb wpdb */
|
2685 |
-
global $wpdb
|
2686 |
|
2687 |
$gmOptions = get_option('gmediaOptions');
|
2688 |
if(!isset($gmOptions['taxonomies'][$taxonomy])){
|
@@ -2692,7 +2671,7 @@ class GmediaDB{
|
|
2692 |
$term_id = (int)$term_id;
|
2693 |
|
2694 |
// First, get all of the original args
|
2695 |
-
$term = $
|
2696 |
|
2697 |
if(is_wp_error($term)){
|
2698 |
return $term;
|
@@ -2704,7 +2683,7 @@ class GmediaDB{
|
|
2704 |
// Merge old and new args with new args overwriting old ones.
|
2705 |
$args = array_merge($term, $args);
|
2706 |
|
2707 |
-
$defaults = array('global' => $term['global'], 'name' => $term['name'], 'description' => '', 'status' => 'public', 'orderby' => 'ID', 'order' => 'DESC'
|
2708 |
$args = wp_parse_args($args, $defaults);
|
2709 |
|
2710 |
/** @var $name
|
@@ -2713,7 +2692,6 @@ class GmediaDB{
|
|
2713 |
* @var $order
|
2714 |
* @var $status
|
2715 |
* @var $global
|
2716 |
-
* @var $gmedia_ids
|
2717 |
*/
|
2718 |
extract($args, EXTR_SKIP);
|
2719 |
|
@@ -2737,39 +2715,19 @@ class GmediaDB{
|
|
2737 |
$term_id = $wpdb->get_var($wpdb->prepare("SELECT t.term_id FROM {$wpdb->prefix}gmedia_term AS t WHERE t.taxonomy = %s AND t.term_id = %d", $taxonomy, $term_id));
|
2738 |
do_action("edit_gmedia_term", $term_id, $taxonomy);
|
2739 |
$wpdb->update($wpdb->prefix . 'gmedia_term', compact('term_id', 'name', 'taxonomy', 'description', 'global', 'status'), array('term_id' => $term_id));
|
2740 |
-
do_action('edited_gmedia_term', $term_id, $taxonomy);
|
2741 |
|
2742 |
-
if(('gmedia_album' == $taxonomy) &&
|
2743 |
-
$db_gmedia_ids = $this->get_gmedias(array('no_found_rows' => true, 'album__in' => $term_id, '
|
2744 |
if(!empty($db_gmedia_ids)){
|
2745 |
-
|
2746 |
-
|
2747 |
-
|
2748 |
-
|
2749 |
-
}
|
2750 |
-
if ($values) {
|
2751 |
-
$status = esc_sql($status);
|
2752 |
-
if (false === $wpdb->query("UPDATE {$wpdb->prefix}gmedia SET status = '{$status}' WHERE ID IN (" . join(',', $values) . ")")) {
|
2753 |
-
return new WP_Error('db_insert_error', __('Could not update statuses for gmedia items in the database'), $wpdb->last_error);
|
2754 |
-
}
|
2755 |
-
}
|
2756 |
}
|
2757 |
-
if
|
2758 |
-
$
|
2759 |
-
if ($
|
2760 |
-
|
2761 |
-
asort($final_gmedia_ids, SORT_NUMERIC);
|
2762 |
-
$final_gmedia_ids = array_keys($final_gmedia_ids);
|
2763 |
-
|
2764 |
-
$values = array();
|
2765 |
-
foreach ($final_gmedia_ids as $gmedia_order => $gmedia_id) {
|
2766 |
-
$values[] = $wpdb->prepare("(%d, %d, %d)", $gmedia_id, $term_id, $gmedia_order);
|
2767 |
-
}
|
2768 |
-
if ($values) {
|
2769 |
-
if (false === $wpdb->query("INSERT INTO {$wpdb->prefix}gmedia_term_relationships (gmedia_id, gmedia_term_id, gmedia_order) VALUES " . join(',', $values) . " ON DUPLICATE KEY UPDATE gmedia_order = VALUES(gmedia_order)")) {
|
2770 |
-
return new WP_Error('db_insert_error', __('Could not insert gmedia term relationship into the database'), $wpdb->last_error);
|
2771 |
-
}
|
2772 |
-
}
|
2773 |
}
|
2774 |
}
|
2775 |
}
|
@@ -2779,7 +2737,7 @@ class GmediaDB{
|
|
2779 |
|
2780 |
$term_id = apply_filters('gmedia_term_id_filter', $term_id);
|
2781 |
|
2782 |
-
$
|
2783 |
|
2784 |
do_action("edited_gmedia_term", $term_id, $taxonomy);
|
2785 |
do_action("edited_$taxonomy", $term_id);
|
@@ -2787,6 +2745,103 @@ class GmediaDB{
|
|
2787 |
return $term_id;
|
2788 |
}
|
2789 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2790 |
/**
|
2791 |
* Check if Term exists.
|
2792 |
*
|
@@ -3169,11 +3224,11 @@ class GmediaDB{
|
|
3169 |
*/
|
3170 |
function delete_term($term_id, $taxonomy, $args = array()){
|
3171 |
/** @var $wpdb wpdb */
|
3172 |
-
global $wpdb
|
3173 |
|
3174 |
$term_id = (int)$term_id;
|
3175 |
|
3176 |
-
if(!$term_id = $
|
3177 |
return false;
|
3178 |
}
|
3179 |
if(is_wp_error($term_id)){
|
@@ -3185,10 +3240,10 @@ class GmediaDB{
|
|
3185 |
$objects = $wpdb->get_col($wpdb->prepare("SELECT gmedia_id FROM {$wpdb->prefix}gmedia_term_relationships WHERE gmedia_term_id = %d", $term_id));
|
3186 |
|
3187 |
foreach((array)$objects as $object){
|
3188 |
-
$terms = $
|
3189 |
$terms = array_diff($terms, array($term_id));
|
3190 |
$terms = array_map('intval', $terms);
|
3191 |
-
$
|
3192 |
}
|
3193 |
|
3194 |
$gmedia_term_meta_ids = $wpdb->get_col($wpdb->prepare("SELECT meta_id FROM {$wpdb->prefix}gmedia_term_meta WHERE gmedia_term_id = %d ", $term_id));
|
@@ -3203,7 +3258,7 @@ class GmediaDB{
|
|
3203 |
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}gmedia_term WHERE term_id = %d", $term_id));
|
3204 |
do_action('deleted_gmedia_term', $term_id);
|
3205 |
|
3206 |
-
$
|
3207 |
|
3208 |
do_action("delete_$taxonomy", $term_id);
|
3209 |
|
@@ -3262,7 +3317,7 @@ class GmediaDB{
|
|
3262 |
wp_cache_delete('get', $taxonomy);
|
3263 |
}
|
3264 |
|
3265 |
-
do_action('
|
3266 |
}
|
3267 |
|
3268 |
wp_cache_set('last_changed', time(), 'gmedia_terms');
|
@@ -3432,17 +3487,20 @@ class GmediaDB{
|
|
3432 |
*
|
3433 |
* @see clean_object_term_cache()
|
3434 |
* @see get_object_taxonomies() for more on $object_type
|
3435 |
-
* @uses do_action() Will call action hook named, '
|
3436 |
* Passes, function params in same order.
|
3437 |
*
|
3438 |
* @param int|array $object_ids Single or list of term object ID(s)
|
|
|
3439 |
*/
|
3440 |
-
function
|
3441 |
if(!is_array($object_ids)){
|
3442 |
$object_ids = array($object_ids);
|
3443 |
}
|
3444 |
-
$
|
3445 |
-
|
|
|
|
|
3446 |
|
3447 |
foreach($object_ids as $id){
|
3448 |
foreach($taxonomies as $taxonomy){
|
@@ -3450,7 +3508,7 @@ class GmediaDB{
|
|
3450 |
}
|
3451 |
}
|
3452 |
|
3453 |
-
do_action('
|
3454 |
}
|
3455 |
|
3456 |
/**
|
@@ -3466,7 +3524,7 @@ class GmediaDB{
|
|
3466 |
*/
|
3467 |
function update_term_count($terms, $taxonomy){
|
3468 |
/** @var $wpdb wpdb */
|
3469 |
-
global $wpdb
|
3470 |
|
3471 |
if(!is_array($terms)){
|
3472 |
$terms = array($terms);
|
@@ -3480,7 +3538,7 @@ class GmediaDB{
|
|
3480 |
do_action('edited_gmedia_term_taxonomy', $term_id, $taxonomy);
|
3481 |
}
|
3482 |
|
3483 |
-
$
|
3484 |
|
3485 |
return true;
|
3486 |
}
|
@@ -3577,10 +3635,11 @@ class GmediaDB{
|
|
3577 |
*/
|
3578 |
function reassign_media($user_id, $reassign){
|
3579 |
$gmedias = $this->get_gmedias(array('nopaging' => true, 'author' => $user_id));
|
|
|
|
|
|
|
|
|
3580 |
if(!empty($gmedias)){
|
3581 |
-
if(empty($reassign)){
|
3582 |
-
$reassign = get_current_user_id();
|
3583 |
-
}
|
3584 |
$modified = current_time('mysql');
|
3585 |
foreach($gmedias as $item){
|
3586 |
$item->author = $reassign;
|
@@ -3588,6 +3647,11 @@ class GmediaDB{
|
|
3588 |
$this->insert_gmedia($item);
|
3589 |
}
|
3590 |
}
|
|
|
|
|
|
|
|
|
|
|
3591 |
}
|
3592 |
|
3593 |
}
|
372 |
if(isset($object['link'])){
|
373 |
$object['link'] = esc_url_raw($object['link']);
|
374 |
}
|
375 |
+
if(!isset($object['status']) || empty($object['status'])){
|
376 |
+
$object['status'] = 'public';
|
377 |
+
}
|
378 |
|
379 |
// export array as variables
|
380 |
extract($object, EXTR_SKIP);
|
417 |
if(isset($terms) && is_array($terms) && count($terms)){
|
418 |
foreach($terms as $taxonomy => $_terms){
|
419 |
$taxonomy = trim($taxonomy);
|
420 |
+
if(('gmedia_tag' == $taxonomy) && !is_array($_terms)){
|
421 |
$_terms = explode(',', $_terms);
|
422 |
} else{
|
423 |
+
$_terms = (array) $_terms;
|
424 |
}
|
425 |
if(!empty($taxonomy)){
|
426 |
$this->set_gmedia_terms($media_ID, $_terms, $taxonomy, $append = 0);
|
431 |
wp_cache_delete($media_ID, 'gmedias');
|
432 |
wp_cache_delete($media_ID, 'gmedia_meta');
|
433 |
|
434 |
+
$this->clean_object_term_cache($media_ID);
|
435 |
|
436 |
do_action('clean_gmedia_cache', $media_ID);
|
437 |
|
468 |
return $gmedia;
|
469 |
}
|
470 |
|
471 |
+
//$meta = $this->get_metadata( 'gmedia', $gmedia->ID, '_metadata', true );
|
472 |
|
473 |
$this->delete_gmedia_term_relationships($gmedia_id, array('gmedia_album', 'gmedia_tag', 'gmedia_category'));
|
474 |
|
537 |
|
538 |
wp_cache_delete($gmedia_id, 'gmedias');
|
539 |
wp_cache_delete($gmedia_id, 'gmedia_meta');
|
540 |
+
$this->clean_object_term_cache($gmedia_id);
|
541 |
|
542 |
do_action('clean_gmedia_cache', $gmedia_id);
|
543 |
|
559 |
*/
|
560 |
function delete_gmedia_term_relationships($object_id, $taxonomies){
|
561 |
/** @var $wpdb wpdb */
|
562 |
+
global $wpdb;
|
563 |
|
564 |
$object_id = (int)$object_id;
|
565 |
|
568 |
}
|
569 |
|
570 |
foreach((array)$taxonomies as $taxonomy){
|
571 |
+
$term_ids = $this->get_gmedia_terms($object_id, $taxonomy, array('fields' => 'ids'));
|
572 |
$in_term_ids = "'" . implode("', '", $term_ids) . "'";
|
573 |
do_action('delete_gmedia_term_relationships', $object_id, $term_ids);
|
574 |
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}gmedia_term_relationships WHERE gmedia_id = %d AND gmedia_term_id IN ($in_term_ids)", $object_id));
|
575 |
do_action('deleted_gmedia_term_relationships', $object_id, $term_ids);
|
576 |
+
$this->update_term_count($term_ids, $taxonomy);
|
577 |
}
|
578 |
}
|
579 |
|
608 |
$metadata['file'] = $this->_gm_relative_upload_path($fileinfo['filepath']);
|
609 |
|
610 |
// fetch additional metadata from exif/iptc
|
611 |
+
$image_meta = $gmCore->wp_read_image_metadata($fileinfo['filepath_original']);
|
612 |
if($image_meta){
|
613 |
$metadata['image_meta'] = $image_meta;
|
614 |
}
|
1514 |
$orderby = "{$wpdb->prefix}gmedia.ID " . $q['order'];
|
1515 |
} else{
|
1516 |
// Used to filter values TODO make orderby comment count
|
1517 |
+
$allowed_keys = array('ID', 'author', 'date', 'title', 'filename', 'gmuid', 'modified', 'mime_type', 'gmedia__in', 'rand');
|
1518 |
if($album['order'] && !empty($album['alias'])){
|
1519 |
$allowed_keys[] = 'custom';
|
1520 |
}
|
1551 |
$orderby = "{$wpdb->prefix}gmedia.ID";
|
1552 |
}
|
1553 |
break;
|
1554 |
+
case 'filename':
|
1555 |
+
$orderby = "{$wpdb->prefix}gmedia.gmuid";
|
1556 |
+
break;
|
1557 |
case 'custom':
|
1558 |
$orderby = "{$album['alias']}.gmedia_order {$q['order']}, {$wpdb->prefix}gmedia.ID";
|
1559 |
break;
|
2319 |
return $cache;
|
2320 |
}
|
2321 |
|
2322 |
+
$order = strtoupper($order);
|
2323 |
+
if('' !== $order && !in_array($order, array('ASC', 'DESC'))){
|
2324 |
+
$order = 'ASC';
|
2325 |
+
}
|
2326 |
+
|
2327 |
$_orderby = strtolower($orderby);
|
2328 |
if('count' == $_orderby){
|
2329 |
+
$orderby = "ORDER BY t.count $order, t.term_id $order";
|
2330 |
} else if('name' == $_orderby){
|
2331 |
+
$orderby = "ORDER BY t.name $order";
|
2332 |
} else if('description' == $_orderby){
|
2333 |
+
$orderby = "ORDER BY t.description $order, t.term_id $order";
|
2334 |
} else if('global' == $_orderby){
|
2335 |
+
$orderby = "ORDER BY t.global ASC, t.term_id $order";
|
2336 |
} else if('global_desc_name' == $_orderby){
|
2337 |
+
$orderby = "ORDER BY t.global DESC, t.name $order";
|
2338 |
} else if('global_asc_name' == $_orderby){
|
2339 |
+
$orderby = "ORDER BY t.global ASC, t.name $order";
|
2340 |
} else if('none' == $_orderby){
|
2341 |
$orderby = '';
|
2342 |
} elseif(empty($_orderby) || 'id' == $_orderby){
|
2343 |
+
$orderby = "ORDER BY t.term_id $order";
|
2344 |
} else{
|
2345 |
+
$orderby = "ORDER BY t.name $order";
|
2346 |
}
|
2347 |
|
2348 |
$orderby = apply_filters('gmedia_get_terms_orderby', $orderby, $args);
|
2349 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2350 |
$where_ = "t.taxonomy IN ('" . implode("', '", $taxonomies) . "')";
|
2351 |
$where = '';
|
2352 |
$inclusions = '';
|
2442 |
break;
|
2443 |
case 'count':
|
2444 |
$orderby = '';
|
|
|
2445 |
$selects = array('COUNT(*)');
|
2446 |
break;
|
2447 |
case 'all':
|
2468 |
}
|
2469 |
|
2470 |
$where_where = $where_ . $where;
|
2471 |
+
$query = "SELECT $found_rows $fields FROM {$wpdb->prefix}gmedia_term AS t $join WHERE $where_where $orderby $limits";
|
2472 |
|
2473 |
$fields = $_fields;
|
2474 |
|
2573 |
*
|
2574 |
* @uses apply_filters() Calls 'pre_insert_gmedia_term' hook with term and taxonomy as parameters.
|
2575 |
* @uses do_action() Calls 'create_gmedia_term' hook with the term id and taxonomy id as parameters.
|
|
|
2576 |
* @uses do_action() Calls 'created_gmedia_term' hook with the term id and taxonomy id as parameters.
|
2577 |
*
|
2578 |
* @param string $term The term to add or update.
|
2583 |
*/
|
2584 |
function insert_term($term, $taxonomy, $args = array()){
|
2585 |
/** @var $wpdb wpdb */
|
2586 |
+
global $wpdb, $gmGallery, $user_ID;
|
2587 |
|
2588 |
if(!isset($gmGallery->options['taxonomies'][$taxonomy])){
|
2589 |
return new WP_Error('gm_invalid_taxonomy', __('Invalid taxonomy'));
|
2634 |
|
2635 |
do_action("create_gmedia_term", $term_id, $taxonomy);
|
2636 |
|
|
|
|
|
2637 |
// ? maybe move function to plugin core (refactor!)
|
2638 |
+
$this->clean_term_cache($term_id, $taxonomy, false);
|
2639 |
|
2640 |
do_action("created_gmedia_term", $term_id, $taxonomy);
|
2641 |
|
2649 |
* Care must be taken to not override important information need to update or
|
2650 |
* update will fail (or perhaps create a new term, neither would be acceptable).
|
2651 |
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2652 |
* @see wp_update_term()
|
2653 |
* @uses $wpdb
|
2654 |
+
* @uses do_action() Will call both 'edit_gmedia_term' and 'edit_$taxonomy'.
|
|
|
|
|
2655 |
*
|
2656 |
* @param int $term_id The ID of the term
|
2657 |
* @param string $taxonomy The context in which to relate the term to the object.
|
2661 |
*/
|
2662 |
function update_term($term_id, $taxonomy, $args = array()){
|
2663 |
/** @var $wpdb wpdb */
|
2664 |
+
global $wpdb;
|
2665 |
|
2666 |
$gmOptions = get_option('gmediaOptions');
|
2667 |
if(!isset($gmOptions['taxonomies'][$taxonomy])){
|
2671 |
$term_id = (int)$term_id;
|
2672 |
|
2673 |
// First, get all of the original args
|
2674 |
+
$term = $this->get_term($term_id, $taxonomy, ARRAY_A);
|
2675 |
|
2676 |
if(is_wp_error($term)){
|
2677 |
return $term;
|
2683 |
// Merge old and new args with new args overwriting old ones.
|
2684 |
$args = array_merge($term, $args);
|
2685 |
|
2686 |
+
$defaults = array('global' => $term['global'], 'name' => $term['name'], 'description' => '', 'status' => 'public', 'orderby' => 'ID', 'order' => 'DESC');
|
2687 |
$args = wp_parse_args($args, $defaults);
|
2688 |
|
2689 |
/** @var $name
|
2692 |
* @var $order
|
2693 |
* @var $status
|
2694 |
* @var $global
|
|
|
2695 |
*/
|
2696 |
extract($args, EXTR_SKIP);
|
2697 |
|
2715 |
$term_id = $wpdb->get_var($wpdb->prepare("SELECT t.term_id FROM {$wpdb->prefix}gmedia_term AS t WHERE t.taxonomy = %s AND t.term_id = %d", $taxonomy, $term_id));
|
2716 |
do_action("edit_gmedia_term", $term_id, $taxonomy);
|
2717 |
$wpdb->update($wpdb->prefix . 'gmedia_term', compact('term_id', 'name', 'taxonomy', 'description', 'global', 'status'), array('term_id' => $term_id));
|
|
|
2718 |
|
2719 |
+
if(('gmedia_album' == $taxonomy) && isset($status_global)){
|
2720 |
+
$db_gmedia_ids = $this->get_gmedias(array('no_found_rows' => true, 'album__in' => $term_id, 'fields' => 'ids'));
|
2721 |
if(!empty($db_gmedia_ids)){
|
2722 |
+
$values = array();
|
2723 |
+
foreach ($db_gmedia_ids as $gmedia_id) {
|
2724 |
+
$values[] = $wpdb->prepare("%d", $gmedia_id);
|
2725 |
+
wp_cache_delete($gmedia_id, 'gmedias');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2726 |
}
|
2727 |
+
if ($values) {
|
2728 |
+
$status = esc_sql($status);
|
2729 |
+
if (false === $wpdb->query("UPDATE {$wpdb->prefix}gmedia SET status = '{$status}' WHERE ID IN (" . join(',', $values) . ")")) {
|
2730 |
+
return new WP_Error('db_insert_error', __('Could not update statuses for gmedia items in the database'), $wpdb->last_error);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2731 |
}
|
2732 |
}
|
2733 |
}
|
2737 |
|
2738 |
$term_id = apply_filters('gmedia_term_id_filter', $term_id);
|
2739 |
|
2740 |
+
$this->clean_term_cache($term_id, $taxonomy);
|
2741 |
|
2742 |
do_action("edited_gmedia_term", $term_id, $taxonomy);
|
2743 |
do_action("edited_$taxonomy", $term_id);
|
2745 |
return $term_id;
|
2746 |
}
|
2747 |
|
2748 |
+
/**
|
2749 |
+
* Update term's items sort order based on arguments provided.
|
2750 |
+
*
|
2751 |
+
* @uses $wpdb
|
2752 |
+
* @uses do_action() Will call both 'sort_gmedia_term' and 'sort_$taxonomy'.
|
2753 |
+
*
|
2754 |
+
* @param int $term_id The ID of the term
|
2755 |
+
* @param string $taxonomy The context in which to relate the term to the object.
|
2756 |
+
* @param array|string $args default array(orderby => ID, order => DESC)
|
2757 |
+
*
|
2758 |
+
* @return int|WP_Error Returns Term ID
|
2759 |
+
*/
|
2760 |
+
function update_term_sortorder($term_id, $taxonomy, $args = array()){
|
2761 |
+
/** @var $wpdb wpdb */
|
2762 |
+
global $wpdb;
|
2763 |
+
|
2764 |
+
$gmOptions = get_option('gmediaOptions');
|
2765 |
+
if(!isset($gmOptions['taxonomies'][$taxonomy])){
|
2766 |
+
return new WP_Error('gm_invalid_taxonomy', __('Invalid taxonomy'));
|
2767 |
+
}
|
2768 |
+
|
2769 |
+
$term_id = $this->term_exists($term_id, $taxonomy);
|
2770 |
+
if(!$term_id){
|
2771 |
+
return new WP_Error('gm_invalid_term_id', __('Invalid term ID'));
|
2772 |
+
}
|
2773 |
+
|
2774 |
+
do_action("sort_gmedia_term", $term_id, $taxonomy);
|
2775 |
+
|
2776 |
+
$default_args = array('gmedia_ids' => array(), 'reset_custom_order' => false);
|
2777 |
+
$args = array_merge($default_args, $args);
|
2778 |
+
|
2779 |
+
/** @var $gmedia_ids
|
2780 |
+
* @var $reset_custom_order
|
2781 |
+
*/
|
2782 |
+
extract($args, EXTR_SKIP);
|
2783 |
+
|
2784 |
+
$default_meta = array(
|
2785 |
+
'orderby' => 'ID',
|
2786 |
+
'order' => 'DESC'
|
2787 |
+
);
|
2788 |
+
$sortorder_meta = array_intersect_key($args, $default_meta) + $default_meta;
|
2789 |
+
foreach($sortorder_meta as $key => $value){
|
2790 |
+
$this->update_metadata('gmedia_term', $term_id, $key, $value);
|
2791 |
+
}
|
2792 |
+
|
2793 |
+
$save_order = false;
|
2794 |
+
|
2795 |
+
if(!empty($reset_custom_order)){
|
2796 |
+
if($sortorder_meta['orderby'] == 'custom'){
|
2797 |
+
$sortorder_meta['orderby'] = $default_meta['orderby'];
|
2798 |
+
}
|
2799 |
+
$gmedia_ids = $this->get_gmedias(array('no_found_rows' => true, 'album__in' => $term_id, 'orderby' => $sortorder_meta['orderby'], 'order' => 'ASC', 'fields' => 'ids'));
|
2800 |
+
$gmedia_ids = array_merge(array(0), $gmedia_ids);
|
2801 |
+
unset($gmedia_ids[0]);
|
2802 |
+
$gmedia_ids = array_flip($gmedia_ids);
|
2803 |
+
$save_order = true;
|
2804 |
+
}
|
2805 |
+
|
2806 |
+
if('custom' == $sortorder_meta['orderby']){
|
2807 |
+
$save_order = true;
|
2808 |
+
}
|
2809 |
+
|
2810 |
+
if(!empty($gmedia_ids) && $save_order){
|
2811 |
+
$_db_gmedia_ids = $this->get_gmedias(array('no_found_rows' => true, 'album__in' => $term_id, 'orderby' => 'custom', 'order' => 'ASC', 'fields' => 'ids'));
|
2812 |
+
$db_gmedia_ids = array_merge(array(0), $_db_gmedia_ids);
|
2813 |
+
unset($db_gmedia_ids[0]);
|
2814 |
+
$db_gmedia_ids = array_flip($db_gmedia_ids);
|
2815 |
+
|
2816 |
+
if ($gmedia_ids != $db_gmedia_ids) {
|
2817 |
+
$final_gmedia_ids = array_intersect_key($gmedia_ids, $db_gmedia_ids) + $db_gmedia_ids;
|
2818 |
+
asort($final_gmedia_ids, SORT_NUMERIC);
|
2819 |
+
$final_gmedia_ids = array_keys($final_gmedia_ids);
|
2820 |
+
$final_gmedia_ids = array_diff_assoc($final_gmedia_ids, $_db_gmedia_ids);
|
2821 |
+
|
2822 |
+
$values = array();
|
2823 |
+
foreach ($final_gmedia_ids as $gmedia_order => $gmedia_id) {
|
2824 |
+
$values[] = $wpdb->prepare("(%d, %d, %d)", $gmedia_id, $term_id, ($gmedia_order + 1));
|
2825 |
+
}
|
2826 |
+
if ($values) {
|
2827 |
+
if (false === $wpdb->query("INSERT INTO {$wpdb->prefix}gmedia_term_relationships (gmedia_id, gmedia_term_id, gmedia_order) VALUES " . join(',', $values) . " ON DUPLICATE KEY UPDATE gmedia_order = VALUES(gmedia_order)")) {
|
2828 |
+
return new WP_Error('db_insert_error', __('Could not insert gmedia term relationship into the database'), $wpdb->last_error);
|
2829 |
+
}
|
2830 |
+
}
|
2831 |
+
$this->clean_object_term_cache($final_gmedia_ids, array($taxonomy) );
|
2832 |
+
}
|
2833 |
+
}
|
2834 |
+
|
2835 |
+
do_action("sort_$taxonomy", $term_id);
|
2836 |
+
|
2837 |
+
$this->clean_term_cache($term_id, $taxonomy);
|
2838 |
+
|
2839 |
+
do_action("sorted_gmedia_term", $term_id, $taxonomy);
|
2840 |
+
do_action("sorted_$taxonomy", $term_id);
|
2841 |
+
|
2842 |
+
return $term_id;
|
2843 |
+
}
|
2844 |
+
|
2845 |
/**
|
2846 |
* Check if Term exists.
|
2847 |
*
|
3224 |
*/
|
3225 |
function delete_term($term_id, $taxonomy, $args = array()){
|
3226 |
/** @var $wpdb wpdb */
|
3227 |
+
global $wpdb;
|
3228 |
|
3229 |
$term_id = (int)$term_id;
|
3230 |
|
3231 |
+
if(!$term_id = $this->term_exists($term_id, $taxonomy)){
|
3232 |
return false;
|
3233 |
}
|
3234 |
if(is_wp_error($term_id)){
|
3240 |
$objects = $wpdb->get_col($wpdb->prepare("SELECT gmedia_id FROM {$wpdb->prefix}gmedia_term_relationships WHERE gmedia_term_id = %d", $term_id));
|
3241 |
|
3242 |
foreach((array)$objects as $object){
|
3243 |
+
$terms = $this->get_gmedia_terms($object, $taxonomy, array('fields' => 'ids', 'orderby' => 'none'));
|
3244 |
$terms = array_diff($terms, array($term_id));
|
3245 |
$terms = array_map('intval', $terms);
|
3246 |
+
$this->set_gmedia_terms($object, $terms, $taxonomy);
|
3247 |
}
|
3248 |
|
3249 |
$gmedia_term_meta_ids = $wpdb->get_col($wpdb->prepare("SELECT meta_id FROM {$wpdb->prefix}gmedia_term_meta WHERE gmedia_term_id = %d ", $term_id));
|
3258 |
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}gmedia_term WHERE term_id = %d", $term_id));
|
3259 |
do_action('deleted_gmedia_term', $term_id);
|
3260 |
|
3261 |
+
$this->clean_term_cache($term_id, $taxonomy);
|
3262 |
|
3263 |
do_action("delete_$taxonomy", $term_id);
|
3264 |
|
3317 |
wp_cache_delete('get', $taxonomy);
|
3318 |
}
|
3319 |
|
3320 |
+
do_action('gmedia_clean_term_cache', $ids, $taxonomy);
|
3321 |
}
|
3322 |
|
3323 |
wp_cache_set('last_changed', time(), 'gmedia_terms');
|
3487 |
*
|
3488 |
* @see clean_object_term_cache()
|
3489 |
* @see get_object_taxonomies() for more on $object_type
|
3490 |
+
* @uses do_action() Will call action hook named, 'gmedia_clean_object_term_cache' after completion.
|
3491 |
* Passes, function params in same order.
|
3492 |
*
|
3493 |
* @param int|array $object_ids Single or list of term object ID(s)
|
3494 |
+
* @param array $taxonomies
|
3495 |
*/
|
3496 |
+
function clean_object_term_cache($object_ids, $taxonomies = array()){
|
3497 |
if(!is_array($object_ids)){
|
3498 |
$object_ids = array($object_ids);
|
3499 |
}
|
3500 |
+
if(empty($taxonomies)){
|
3501 |
+
$gmOptions = get_option('gmediaOptions');
|
3502 |
+
$taxonomies = array_keys($gmOptions['taxonomies']);
|
3503 |
+
}
|
3504 |
|
3505 |
foreach($object_ids as $id){
|
3506 |
foreach($taxonomies as $taxonomy){
|
3508 |
}
|
3509 |
}
|
3510 |
|
3511 |
+
do_action('gmedia_clean_object_term_cache', $object_ids, $taxonomies);
|
3512 |
}
|
3513 |
|
3514 |
/**
|
3524 |
*/
|
3525 |
function update_term_count($terms, $taxonomy){
|
3526 |
/** @var $wpdb wpdb */
|
3527 |
+
global $wpdb;
|
3528 |
|
3529 |
if(!is_array($terms)){
|
3530 |
$terms = array($terms);
|
3538 |
do_action('edited_gmedia_term_taxonomy', $term_id, $taxonomy);
|
3539 |
}
|
3540 |
|
3541 |
+
$this->clean_term_cache($terms, $taxonomy, false);
|
3542 |
|
3543 |
return true;
|
3544 |
}
|
3635 |
*/
|
3636 |
function reassign_media($user_id, $reassign){
|
3637 |
$gmedias = $this->get_gmedias(array('nopaging' => true, 'author' => $user_id));
|
3638 |
+
$taxonomies = $this->get_terms(array('gmedia_album', 'gmedia_gallery', 'gmedia_module'), array('global' => $user_id));
|
3639 |
+
if(empty($reassign)){
|
3640 |
+
$reassign = get_current_user_id();
|
3641 |
+
}
|
3642 |
if(!empty($gmedias)){
|
|
|
|
|
|
|
3643 |
$modified = current_time('mysql');
|
3644 |
foreach($gmedias as $item){
|
3645 |
$item->author = $reassign;
|
3647 |
$this->insert_gmedia($item);
|
3648 |
}
|
3649 |
}
|
3650 |
+
if(!empty($taxonomies)){
|
3651 |
+
foreach($taxonomies as $item){
|
3652 |
+
$this->update_term($item->term_id, $item->taxonomy, array('global' => $reassign));
|
3653 |
+
}
|
3654 |
+
}
|
3655 |
}
|
3656 |
|
3657 |
}
|
inc/hashids.php
ADDED
@@ -0,0 +1,338 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Hashids
|
4 |
+
* http://hashids.org/php
|
5 |
+
* https://github.com/ivanakimov/hashids.php
|
6 |
+
*/
|
7 |
+
class GmediaHashIDs {
|
8 |
+
/* internal settings */
|
9 |
+
const MIN_ALPHABET_LENGTH = 16;
|
10 |
+
const SEP_DIV = 3.5;
|
11 |
+
const GUARD_DIV = 12;
|
12 |
+
/* error messages */
|
13 |
+
const E_ALPHABET_LENGTH = 'alphabet must contain at least %d unique characters';
|
14 |
+
const E_ALPHABET_SPACE = 'alphabet cannot contain spaces';
|
15 |
+
/* set at constructor */
|
16 |
+
private $_alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
|
17 |
+
private $_seps = 'cfhistuCFHISTU';
|
18 |
+
private $_min_hash_length = 0;
|
19 |
+
private $_math_functions = array();
|
20 |
+
private $_max_int_value = 1000000000;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @param string $salt
|
24 |
+
* @param int $min_hash_length
|
25 |
+
* @param string $alphabet
|
26 |
+
*
|
27 |
+
* @throws Exception
|
28 |
+
*/
|
29 |
+
public function __construct($salt = '', $min_hash_length = 0, $alphabet = '') {
|
30 |
+
/* if either math precision library is present, raise $this->_max_int_value */
|
31 |
+
if (function_exists('gmp_add')) {
|
32 |
+
$this->_math_functions['add'] = 'gmp_add';
|
33 |
+
$this->_math_functions['div'] = 'gmp_div';
|
34 |
+
$this->_math_functions['str'] = 'gmp_strval';
|
35 |
+
} else if (function_exists('bcadd')) {
|
36 |
+
$this->_math_functions['add'] = 'bcadd';
|
37 |
+
$this->_math_functions['div'] = 'bcdiv';
|
38 |
+
$this->_math_functions['str'] = 'strval';
|
39 |
+
}
|
40 |
+
$this->_lower_max_int_value = $this->_max_int_value;
|
41 |
+
if ($this->_math_functions) {
|
42 |
+
$this->_max_int_value = PHP_INT_MAX;
|
43 |
+
}
|
44 |
+
/* handle parameters */
|
45 |
+
$this->_salt = $salt;
|
46 |
+
if ((int)$min_hash_length > 0) {
|
47 |
+
$this->_min_hash_length = (int)$min_hash_length;
|
48 |
+
}
|
49 |
+
if ($alphabet) {
|
50 |
+
$this->_alphabet = implode('', array_unique(str_split($alphabet)));
|
51 |
+
}
|
52 |
+
if (strlen($this->_alphabet) < self::MIN_ALPHABET_LENGTH) {
|
53 |
+
throw new Exception(sprintf(self::E_ALPHABET_LENGTH, self::MIN_ALPHABET_LENGTH));
|
54 |
+
}
|
55 |
+
if (is_int(strpos($this->_alphabet, ' '))) {
|
56 |
+
throw new Exception(self::E_ALPHABET_SPACE);
|
57 |
+
}
|
58 |
+
$alphabet_array = str_split($this->_alphabet);
|
59 |
+
$seps_array = str_split($this->_seps);
|
60 |
+
$this->_seps = implode('', array_intersect($alphabet_array, $seps_array));
|
61 |
+
$this->_alphabet = implode('', array_diff($alphabet_array, $seps_array));
|
62 |
+
$this->_seps = $this->_consistent_shuffle($this->_seps, $this->_salt);
|
63 |
+
if (!$this->_seps || (strlen($this->_alphabet) / strlen($this->_seps)) > self::SEP_DIV) {
|
64 |
+
$seps_length = (int)ceil(strlen($this->_alphabet) / self::SEP_DIV);
|
65 |
+
if ($seps_length == 1) {
|
66 |
+
$seps_length++;
|
67 |
+
}
|
68 |
+
if ($seps_length > strlen($this->_seps)) {
|
69 |
+
$diff = $seps_length - strlen($this->_seps);
|
70 |
+
$this->_seps .= substr($this->_alphabet, 0, $diff);
|
71 |
+
$this->_alphabet = substr($this->_alphabet, $diff);
|
72 |
+
} else {
|
73 |
+
$this->_seps = substr($this->_seps, 0, $seps_length);
|
74 |
+
}
|
75 |
+
}
|
76 |
+
$this->_alphabet = $this->_consistent_shuffle($this->_alphabet, $this->_salt);
|
77 |
+
$guard_count = (int)ceil(strlen($this->_alphabet) / self::GUARD_DIV);
|
78 |
+
if (strlen($this->_alphabet) < 3) {
|
79 |
+
$this->_guards = substr($this->_seps, 0, $guard_count);
|
80 |
+
$this->_seps = substr($this->_seps, $guard_count);
|
81 |
+
} else {
|
82 |
+
$this->_guards = substr($this->_alphabet, 0, $guard_count);
|
83 |
+
$this->_alphabet = substr($this->_alphabet, $guard_count);
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* @return string
|
89 |
+
*/
|
90 |
+
public function encode() {
|
91 |
+
$ret = '';
|
92 |
+
$numbers = func_get_args();
|
93 |
+
if (func_num_args() == 1 && is_array(func_get_arg(0))) {
|
94 |
+
$numbers = $numbers[0];
|
95 |
+
}
|
96 |
+
if (!$numbers) {
|
97 |
+
return $ret;
|
98 |
+
}
|
99 |
+
foreach ($numbers as $number) {
|
100 |
+
$is_number = ctype_digit((string)$number);
|
101 |
+
if (!$is_number || $number < 0 || $number > $this->_max_int_value) {
|
102 |
+
return $ret;
|
103 |
+
}
|
104 |
+
}
|
105 |
+
return $this->_encode($numbers);
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* @param $hash
|
110 |
+
*
|
111 |
+
* @return array
|
112 |
+
*/
|
113 |
+
public function decode($hash) {
|
114 |
+
$ret = array();
|
115 |
+
if (!$hash || !is_string($hash) || !trim($hash)) {
|
116 |
+
return $ret;
|
117 |
+
}
|
118 |
+
return $this->_decode(trim($hash), $this->_alphabet);
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* @param $str
|
123 |
+
*
|
124 |
+
* @return mixed|string
|
125 |
+
*/
|
126 |
+
public function encode_hex($str) {
|
127 |
+
if (!ctype_xdigit((string)$str)) {
|
128 |
+
return '';
|
129 |
+
}
|
130 |
+
$numbers = trim(chunk_split($str, 12, ' '));
|
131 |
+
$numbers = explode(' ', $numbers);
|
132 |
+
foreach ($numbers as $i => $number) {
|
133 |
+
$numbers[$i] = hexdec('1' . $number);
|
134 |
+
}
|
135 |
+
return call_user_func_array(array($this, 'encode'), $numbers);
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* @param $hash
|
140 |
+
*
|
141 |
+
* @return string
|
142 |
+
*/
|
143 |
+
public function decode_hex($hash) {
|
144 |
+
$ret = "";
|
145 |
+
$numbers = $this->decode($hash);
|
146 |
+
foreach ($numbers as $i => $number) {
|
147 |
+
$ret .= substr(dechex($number), 1);
|
148 |
+
}
|
149 |
+
return $ret;
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* @return int
|
154 |
+
*/
|
155 |
+
public function get_max_int_value() {
|
156 |
+
return $this->_max_int_value;
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* @param array $numbers
|
161 |
+
*
|
162 |
+
* @return string
|
163 |
+
*/
|
164 |
+
private function _encode(array $numbers) {
|
165 |
+
$alphabet = $this->_alphabet;
|
166 |
+
$numbers_size = sizeof($numbers);
|
167 |
+
$numbers_hash_int = 0;
|
168 |
+
foreach ($numbers as $i => $number) {
|
169 |
+
$numbers_hash_int += ($number % ($i + 100));
|
170 |
+
}
|
171 |
+
$lottery = $ret = $alphabet[$numbers_hash_int % strlen($alphabet)];
|
172 |
+
foreach ($numbers as $i => $number) {
|
173 |
+
$alphabet = $this->_consistent_shuffle($alphabet, substr($lottery . $this->_salt . $alphabet, 0, strlen($alphabet)));
|
174 |
+
$ret .= $last = $this->_hash($number, $alphabet);
|
175 |
+
if ($i + 1 < $numbers_size) {
|
176 |
+
$number %= (ord($last) + $i);
|
177 |
+
$seps_index = $number % strlen($this->_seps);
|
178 |
+
$ret .= $this->_seps[$seps_index];
|
179 |
+
}
|
180 |
+
}
|
181 |
+
if (strlen($ret) < $this->_min_hash_length) {
|
182 |
+
$guard_index = ($numbers_hash_int + ord($ret[0])) % strlen($this->_guards);
|
183 |
+
$guard = $this->_guards[$guard_index];
|
184 |
+
$ret = $guard . $ret;
|
185 |
+
if (strlen($ret) < $this->_min_hash_length) {
|
186 |
+
$guard_index = ($numbers_hash_int + ord($ret[2])) % strlen($this->_guards);
|
187 |
+
$guard = $this->_guards[$guard_index];
|
188 |
+
$ret .= $guard;
|
189 |
+
}
|
190 |
+
}
|
191 |
+
$half_length = (int)(strlen($alphabet) / 2);
|
192 |
+
while (strlen($ret) < $this->_min_hash_length) {
|
193 |
+
$alphabet = $this->_consistent_shuffle($alphabet, $alphabet);
|
194 |
+
$ret = substr($alphabet, $half_length) . $ret . substr($alphabet, 0, $half_length);
|
195 |
+
$excess = strlen($ret) - $this->_min_hash_length;
|
196 |
+
if ($excess > 0) {
|
197 |
+
$ret = substr($ret, $excess / 2, $this->_min_hash_length);
|
198 |
+
}
|
199 |
+
}
|
200 |
+
return $ret;
|
201 |
+
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* @param $hash
|
205 |
+
* @param $alphabet
|
206 |
+
*
|
207 |
+
* @return array
|
208 |
+
*/
|
209 |
+
private function _decode($hash, $alphabet) {
|
210 |
+
$ret = array();
|
211 |
+
$hash_breakdown = str_replace(str_split($this->_guards), ' ', $hash);
|
212 |
+
$hash_array = explode(' ', $hash_breakdown);
|
213 |
+
$i = 0;
|
214 |
+
if (sizeof($hash_array) == 3 || sizeof($hash_array) == 2) {
|
215 |
+
$i = 1;
|
216 |
+
}
|
217 |
+
$hash_breakdown = $hash_array[$i];
|
218 |
+
if (isset($hash_breakdown[0])) {
|
219 |
+
$lottery = $hash_breakdown[0];
|
220 |
+
$hash_breakdown = substr($hash_breakdown, 1);
|
221 |
+
$hash_breakdown = str_replace(str_split($this->_seps), ' ', $hash_breakdown);
|
222 |
+
$hash_array = explode(' ', $hash_breakdown);
|
223 |
+
foreach ($hash_array as $sub_hash) {
|
224 |
+
$alphabet = $this->_consistent_shuffle($alphabet, substr($lottery . $this->_salt . $alphabet, 0, strlen($alphabet)));
|
225 |
+
$ret[] = (int)$this->_unhash($sub_hash, $alphabet);
|
226 |
+
}
|
227 |
+
if ($this->_encode($ret) != $hash) {
|
228 |
+
$ret = array();
|
229 |
+
}
|
230 |
+
}
|
231 |
+
return $ret;
|
232 |
+
}
|
233 |
+
|
234 |
+
/**
|
235 |
+
* @param $alphabet
|
236 |
+
* @param $salt
|
237 |
+
*
|
238 |
+
* @return mixed
|
239 |
+
*/
|
240 |
+
private function _consistent_shuffle($alphabet, $salt) {
|
241 |
+
if (!strlen($salt)) {
|
242 |
+
return $alphabet;
|
243 |
+
}
|
244 |
+
for ($i = strlen($alphabet) - 1, $v = 0, $p = 0; $i > 0; $i--, $v++) {
|
245 |
+
$v %= strlen($salt);
|
246 |
+
$p += $int = ord($salt[$v]);
|
247 |
+
$j = ($int + $v + $p) % $i;
|
248 |
+
$temp = $alphabet[$j];
|
249 |
+
$alphabet[$j] = $alphabet[$i];
|
250 |
+
$alphabet[$i] = $temp;
|
251 |
+
}
|
252 |
+
return $alphabet;
|
253 |
+
}
|
254 |
+
|
255 |
+
/**
|
256 |
+
* @param $input
|
257 |
+
* @param $alphabet
|
258 |
+
*
|
259 |
+
* @return string
|
260 |
+
*/
|
261 |
+
private function _hash($input, $alphabet) {
|
262 |
+
$hash = '';
|
263 |
+
$alphabet_length = strlen($alphabet);
|
264 |
+
do {
|
265 |
+
$hash = $alphabet[$input % $alphabet_length] . $hash;
|
266 |
+
if ($input > $this->_lower_max_int_value && $this->_math_functions) {
|
267 |
+
$input = $this->_math_functions['str']($this->_math_functions['div']($input, $alphabet_length));
|
268 |
+
} else {
|
269 |
+
$input = (int)($input / $alphabet_length);
|
270 |
+
}
|
271 |
+
} while ($input);
|
272 |
+
return $hash;
|
273 |
+
}
|
274 |
+
|
275 |
+
/**
|
276 |
+
* @param $input
|
277 |
+
* @param $alphabet
|
278 |
+
*
|
279 |
+
* @return bool|int
|
280 |
+
*/
|
281 |
+
private function _unhash($input, $alphabet) {
|
282 |
+
$number = 0;
|
283 |
+
if (strlen($input) && $alphabet) {
|
284 |
+
$alphabet_length = strlen($alphabet);
|
285 |
+
$input_chars = str_split($input);
|
286 |
+
foreach ($input_chars as $i => $char) {
|
287 |
+
$pos = strpos($alphabet, $char);
|
288 |
+
if ($this->_math_functions) {
|
289 |
+
$number = $this->_math_functions['str']($this->_math_functions['add']($number, $pos * pow($alphabet_length, (strlen($input) - $i - 1))));
|
290 |
+
} else {
|
291 |
+
$number += $pos * pow($alphabet_length, (strlen($input) - $i - 1));
|
292 |
+
}
|
293 |
+
}
|
294 |
+
}
|
295 |
+
return $number;
|
296 |
+
}
|
297 |
+
}
|
298 |
+
|
299 |
+
/**
|
300 |
+
* @param $id
|
301 |
+
* @param string $_salt
|
302 |
+
* @param int $min_hash_length
|
303 |
+
* @param string $alphabet
|
304 |
+
*
|
305 |
+
* @return string
|
306 |
+
*/
|
307 |
+
function gmedia_hash_id_encode($id, $_salt = '', $min_hash_length = 5, $alphabet = ''){
|
308 |
+
$salt = get_option('GmediaHashID_salt');
|
309 |
+
if($_salt){
|
310 |
+
$salt .= $_salt.'_'.$salt;
|
311 |
+
}
|
312 |
+
$hashid = new GmediaHashIDs($salt, $min_hash_length, $alphabet);
|
313 |
+
|
314 |
+
return $hashid->encode($id);
|
315 |
+
}
|
316 |
+
|
317 |
+
/**
|
318 |
+
* @param $id
|
319 |
+
* @param string $_salt
|
320 |
+
* @param int $min_hash_length
|
321 |
+
* @param string $alphabet
|
322 |
+
* @param bool $return_int
|
323 |
+
*
|
324 |
+
* @return int|array
|
325 |
+
*/
|
326 |
+
function gmedia_hash_id_decode($id, $_salt = '', $min_hash_length = 5, $alphabet = '', $return_int = true){
|
327 |
+
$salt = get_option('GmediaHashID_salt');
|
328 |
+
if($_salt){
|
329 |
+
$salt .= $_salt.'_'.$salt;
|
330 |
+
}
|
331 |
+
$hashid = new GmediaHashIDs($salt, $min_hash_length, $alphabet);
|
332 |
+
if($return_int){
|
333 |
+
$id_arr = $hashid->decode($id);
|
334 |
+
return $id_arr[0];
|
335 |
+
} else{
|
336 |
+
return $hashid->decode($id);
|
337 |
+
}
|
338 |
+
}
|
inc/media-upload.php
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?php
|
2 |
-
if
|
3 |
-
die(
|
4 |
}
|
5 |
|
6 |
/**
|
7 |
* @title Add action/filter for the upload tab
|
8 |
*/
|
9 |
|
10 |
-
if
|
11 |
-
add_filter(
|
12 |
-
add_filter(
|
13 |
-
add_action(
|
14 |
-
add_action(
|
15 |
-
add_action(
|
16 |
}
|
17 |
|
18 |
|
@@ -21,10 +21,10 @@ if ( current_user_can( 'gmedia_library' ) ) {
|
|
21 |
*
|
22 |
* @return string
|
23 |
*/
|
24 |
-
function gmedia_media_buttons_context(
|
25 |
$button = '
|
26 |
<div style="display:inline-block;">
|
27 |
-
<a id="gmedia-modal" title="Gmedia Galleries" class="gmedia_button button" href="#gmedia"><span class="wp-media-buttons-icon" style="background: url(' . plugins_url(
|
28 |
</div>';
|
29 |
|
30 |
return $context . $button;
|
@@ -35,64 +35,64 @@ function gmedia_media_buttons_context( $context ) {
|
|
35 |
*
|
36 |
* @return array
|
37 |
*/
|
38 |
-
function gmedia_upload_tabs(
|
39 |
|
40 |
$newtab = array(
|
41 |
-
'gmedia_library'
|
42 |
-
'gmedia_terms'
|
43 |
-
'gmedia_galleries' => __(
|
44 |
);
|
45 |
|
46 |
-
if
|
47 |
-
return array_merge(
|
48 |
}
|
49 |
|
50 |
return $newtab;
|
51 |
}
|
52 |
|
53 |
-
function media_upload_gmedia()
|
54 |
global $gmCore, $gmDB;
|
55 |
|
56 |
-
add_action(
|
57 |
-
|
58 |
-
$action = $gmCore->_get(
|
59 |
-
if
|
60 |
-
wp_iframe(
|
61 |
-
} elseif
|
62 |
-
wp_iframe(
|
63 |
-
} elseif
|
64 |
-
if
|
65 |
-
wp_iframe(
|
66 |
-
} else
|
67 |
-
wp_iframe(
|
68 |
}
|
69 |
}
|
70 |
|
71 |
// Generate TinyMCE HTML output
|
72 |
-
if
|
73 |
|
74 |
-
$id = $gmCore->_post(
|
75 |
|
76 |
-
if
|
77 |
|
78 |
-
$meta = $gmDB->get_metadata(
|
79 |
|
80 |
-
$size
|
81 |
-
$src
|
82 |
-
$width
|
83 |
-
$height
|
84 |
-
$title
|
85 |
-
$align
|
86 |
-
$link
|
87 |
-
$caption = trim(
|
88 |
|
89 |
$html = "<img src='{$src}' width='{$width}' height='{$height}' alt='{$title}' title='{$title}' id='gmedia-image-{$id}' class='gmedia-singlepic align{$align}' />";
|
90 |
|
91 |
-
if
|
92 |
$html = "<a href='{$link}'>{$html}</a>";
|
93 |
}
|
94 |
-
if
|
95 |
-
$html = image_add_caption(
|
96 |
}
|
97 |
|
98 |
?>
|
@@ -104,11 +104,11 @@ function media_upload_gmedia() {
|
|
104 |
</script>
|
105 |
<?php
|
106 |
// Return it to TinyMCE
|
107 |
-
media_send_to_editor(
|
108 |
}
|
109 |
}
|
110 |
-
if
|
111 |
-
$sc = $gmCore->_post(
|
112 |
?>
|
113 |
<script type="text/javascript">
|
114 |
/* <![CDATA[ */
|
@@ -118,15 +118,15 @@ function media_upload_gmedia() {
|
|
118 |
</script>
|
119 |
<?php
|
120 |
// Return it to TinyMCE
|
121 |
-
media_send_to_editor(
|
122 |
}
|
123 |
-
if
|
124 |
$module_preset = $gmCore->_post('module_preset');
|
125 |
if($gmCore->is_digit($module_preset)){
|
126 |
-
$module_preset = $gmDB->get_term(
|
127 |
$module = $module_preset->status;
|
128 |
$preset = ' preset=' . $module_preset->term_id;
|
129 |
-
} else
|
130 |
$module = $module_preset;
|
131 |
$preset = '';
|
132 |
}
|
@@ -144,95 +144,104 @@ function media_upload_gmedia() {
|
|
144 |
</script>
|
145 |
<?php
|
146 |
// Return it to TinyMCE
|
147 |
-
media_send_to_editor(
|
148 |
}
|
149 |
}
|
150 |
|
151 |
}
|
152 |
|
153 |
-
function gmedia_add_media_popup_enqueue_scripts()
|
154 |
global $gmCore;
|
155 |
|
156 |
-
wp_dequeue_script(
|
157 |
-
wp_dequeue_script(
|
158 |
-
wp_dequeue_script(
|
159 |
-
wp_dequeue_script(
|
160 |
-
wp_dequeue_script(
|
161 |
-
wp_dequeue_script(
|
162 |
-
wp_dequeue_style(
|
163 |
-
|
164 |
-
wp_enqueue_style(
|
165 |
-
wp_enqueue_script(
|
166 |
-
|
167 |
-
wp_enqueue_style(
|
168 |
-
wp_enqueue_script(
|
169 |
-
|
170 |
-
$action = $gmCore->_get(
|
171 |
-
if
|
172 |
-
if
|
173 |
-
wp_enqueue_style(
|
174 |
-
wp_enqueue_script(
|
175 |
}
|
176 |
-
wp_enqueue_style(
|
177 |
-
wp_enqueue_script(
|
178 |
|
179 |
-
wp_enqueue_script(
|
180 |
|
181 |
-
wp_enqueue_style(
|
182 |
-
wp_enqueue_script(
|
183 |
}
|
184 |
|
185 |
}
|
186 |
|
187 |
-
function gmedia_add_media_galleries()
|
188 |
|
189 |
global $user_ID, $gmCore, $gmDB, $gmGallery, $gmProcessor;
|
190 |
|
191 |
-
$post_id = intval(
|
192 |
|
193 |
-
$
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
'hide_empty' => 0,
|
199 |
-
'page'
|
200 |
-
'status'
|
201 |
);
|
202 |
-
$args['offset'] = (
|
203 |
|
204 |
|
205 |
-
if
|
206 |
-
$args['global'] = $gmCore->_get(
|
207 |
-
} else
|
208 |
-
$args['global'] = array(
|
209 |
}
|
210 |
|
211 |
-
$taxonomy
|
212 |
-
$gmediaTerms = $gmDB->get_terms(
|
213 |
-
$alert
|
214 |
-
if
|
215 |
-
$alert
|
216 |
$gmediaTerms = array();
|
217 |
}
|
218 |
|
219 |
$modules = array();
|
220 |
-
if
|
221 |
-
foreach
|
222 |
-
$mfold
|
223 |
-
$modules[
|
224 |
'module_name' => $mfold,
|
225 |
-
'module_url'
|
226 |
'module_path' => $path
|
227 |
);
|
228 |
}
|
229 |
}
|
230 |
-
if
|
231 |
-
foreach
|
232 |
-
$mfold
|
233 |
-
$modules[
|
234 |
'module_name' => $mfold,
|
235 |
-
'module_url'
|
236 |
'module_path' => $path
|
237 |
);
|
238 |
}
|
@@ -244,25 +253,25 @@ function gmedia_add_media_galleries() {
|
|
244 |
<div class="panel-heading clearfix">
|
245 |
<form class="form-inline gmedia-search-form" role="search" method="get">
|
246 |
<div class="form-group">
|
247 |
-
<?php foreach
|
248 |
-
if
|
249 |
?>
|
250 |
<input type="hidden" name="<?php echo $key; ?>" value="<?php echo $value; ?>"/>
|
251 |
<?php
|
252 |
}
|
253 |
} ?>
|
254 |
-
<input id="gmedia-search" class="form-control input-sm" type="text" name="s" placeholder="<?php _e(
|
255 |
</div>
|
256 |
<button type="submit" class="btn btn-default input-sm"><span class="glyphicon glyphicon-search"></span></button>
|
257 |
</form>
|
258 |
<?php echo $gmDB->query_pager(); ?>
|
259 |
|
260 |
<div class="btn-group" style="margin-right:20px;">
|
261 |
-
<a class="btn btn-primary" target="_blank" href="<?php echo add_query_arg(
|
262 |
</div>
|
263 |
|
264 |
<div class="btn-group" style="margin-right:20px;">
|
265 |
-
<a class="btn btn-success" href="#" onclick="location.reload(true); return false;"><?php _e(
|
266 |
</div>
|
267 |
|
268 |
</div>
|
@@ -272,108 +281,111 @@ function gmedia_add_media_galleries() {
|
|
272 |
<div class="col-xs-7 col-md-9" style="padding: 0">
|
273 |
<div class="list-group">
|
274 |
<?php
|
275 |
-
if
|
276 |
-
$lib_url = add_query_arg(
|
277 |
-
foreach
|
278 |
|
279 |
-
$term_meta = $gmDB->get_metadata(
|
280 |
-
$term_meta = array_map(
|
281 |
-
$term_meta = array_map(
|
282 |
|
283 |
-
$module
|
284 |
-
$module_info = array(
|
285 |
-
if
|
286 |
$broken = false;
|
287 |
-
include(
|
288 |
-
} else
|
289 |
$broken = true;
|
290 |
}
|
291 |
|
292 |
$list_row_class = '';
|
293 |
-
if
|
294 |
$list_row_class = ' list-group-item-info';
|
295 |
}
|
296 |
?>
|
297 |
<div class="gmedia-insert-item list-group-item clearfix d-row<?php echo $list_row_class; ?>" id="list-item-<?php echo $term->term_id; ?>" data-id="<?php echo $term->term_id; ?>" data-type="<?php echo $term_meta['module']; ?>">
|
298 |
<div class="media-object pull-left" style="width:130px;margin-right:15px;">
|
299 |
-
<?php if
|
300 |
-
<span class="thumbnail"><img src="<?php echo $module['url'] . '/screenshot.png'; ?>" alt="<?php echo esc_attr(
|
301 |
-
<?php } else
|
302 |
-
<div class="bg-danger text-center"><?php _e(
|
303 |
<?php } ?>
|
304 |
</div>
|
305 |
|
306 |
<div class="media-body" style="margin-left:145px;">
|
307 |
<p class="media-title">
|
308 |
-
<span><?php echo esc_html(
|
309 |
</p>
|
310 |
|
311 |
<p class="media-meta">
|
312 |
-
<span class="label label-default"><?php _e(
|
313 |
</p>
|
314 |
|
315 |
-
<p class="media-caption"><?php echo nl2br(esc_html(
|
316 |
</div>
|
317 |
|
318 |
<p class="media-meta hidden" style="font-weight:bold">
|
319 |
-
<span class="label label-default"><?php _e(
|
320 |
<input type="hidden" name="shortcode" value="[gmedia id=<?php echo $term->term_id; ?>]"/>
|
321 |
</p>
|
322 |
|
323 |
<p class="media-meta clear hidden">
|
324 |
-
<span class="label label-default"><?php _e(
|
325 |
-
<br><span class="label label-default"><?php _e(
|
326 |
-
<br><span class="label label-default"><?php _e(
|
327 |
-
<br><span class="label label-default"><?php _e(
|
328 |
-
<br><span class="label label-default"><?php _e(
|
329 |
<?php
|
330 |
-
$gallery_tabs = reset(
|
331 |
-
$tax_tabs
|
332 |
-
if
|
333 |
-
_e(
|
334 |
-
if
|
335 |
-
$gmedia_ids = wp_parse_id_list(
|
336 |
-
$gal_source = sprintf(
|
337 |
echo " ($gal_source)";
|
338 |
}
|
339 |
-
} else
|
340 |
-
$tabs
|
341 |
$terms_source = array();
|
342 |
-
if
|
343 |
-
_e(
|
344 |
-
foreach
|
345 |
-
$terms_source[] = sprintf(
|
346 |
}
|
347 |
-
} elseif
|
348 |
-
_e(
|
349 |
-
foreach
|
350 |
-
$terms_source[] = sprintf(
|
351 |
}
|
352 |
-
} elseif
|
353 |
-
_e(
|
354 |
-
foreach
|
355 |
-
$terms_source[] = sprintf(
|
356 |
}
|
357 |
-
} elseif
|
358 |
-
_e(
|
359 |
-
foreach
|
360 |
-
$terms_source[] = sprintf(
|
361 |
}
|
362 |
}
|
363 |
-
if
|
364 |
-
$terms_source = join(
|
365 |
-
if
|
366 |
-
$terms_source = strip_tags(
|
367 |
}
|
368 |
echo " ({$terms_source})";
|
369 |
}
|
370 |
}
|
371 |
?>
|
372 |
</p>
|
373 |
-
<?php if
|
374 |
-
if
|
375 |
?>
|
376 |
-
<p class="media-meta hidden"><a target="_blank" href="<?php echo add_query_arg(
|
|
|
|
|
|
|
377 |
<?php
|
378 |
}
|
379 |
} ?>
|
@@ -381,11 +393,11 @@ function gmedia_add_media_galleries() {
|
|
381 |
</div>
|
382 |
<?php
|
383 |
}
|
384 |
-
} else
|
385 |
?>
|
386 |
<div class="list-group-item">
|
387 |
<div class="well well-lg text-center">
|
388 |
-
<h4><?php _e(
|
389 |
</div>
|
390 |
</div>
|
391 |
<?php } ?>
|
@@ -396,31 +408,31 @@ function gmedia_add_media_galleries() {
|
|
396 |
<div id="media-upload-form-container" class="media-upload-form-container"></div>
|
397 |
<div class="panel-footer">
|
398 |
<input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>"/>
|
399 |
-
<?php wp_nonce_field(
|
400 |
-
<button type="submit" id="media-upload-form-submit" disabled class="btn btn-primary pull-right" name="gmedia_gallery_insert"><?php _e(
|
401 |
</div>
|
402 |
</form>
|
403 |
</div>
|
404 |
</div>
|
405 |
</div>
|
406 |
<script type="text/javascript">
|
407 |
-
jQuery(function
|
408 |
-
function divFrame()
|
409 |
$('.panel-body').css({top: $('.panel-heading').outerHeight()});
|
410 |
}
|
411 |
|
412 |
divFrame();
|
413 |
-
$(window).on('resize', function
|
414 |
divFrame();
|
415 |
});
|
416 |
-
$('.gmedia-insert-item').on('click', function
|
417 |
-
if
|
418 |
-
$(this).removeClass('active');
|
419 |
$('#media-upload-form-container').empty();
|
420 |
$('#media-upload-form-submit').prop('disabled', true);
|
421 |
return;
|
422 |
}
|
423 |
-
$(this).addClass('active').siblings().removeClass('active');
|
424 |
var info = $(this).clone();
|
425 |
info.find('.media-caption').remove().end().find('.hidden').removeClass('hidden');
|
426 |
$('#media-upload-form-container').html(info.html());
|
@@ -432,103 +444,104 @@ function gmedia_add_media_galleries() {
|
|
432 |
<?php
|
433 |
}
|
434 |
|
435 |
-
function gmedia_add_media_terms()
|
436 |
|
437 |
global $user_ID, $gmCore, $gmDB, $gmGallery, $gmProcessor;
|
438 |
|
439 |
-
$post_id = intval(
|
440 |
|
441 |
-
$url = add_query_arg(
|
442 |
|
443 |
-
/* todo: per_page options for gmedia_terms
|
444 |
$gm_screen_options = get_user_meta($user_ID, 'gm_screen_options', true);
|
445 |
if(!is_array($gm_screen_options)){
|
446 |
$gm_screen_options = array();
|
447 |
}
|
448 |
$gm_screen_options = array_merge($gmGallery->options['gm_screen_options'], $gm_screen_options);
|
449 |
-
|
450 |
-
|
451 |
-
$
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
'
|
456 |
-
'
|
457 |
-
'
|
|
|
|
|
|
|
458 |
);
|
459 |
-
$args['offset'] = (
|
460 |
|
461 |
-
$taxonomy = $gmCore->_get(
|
462 |
-
if
|
463 |
$taxonomy = 'gmedia_album';
|
464 |
}
|
465 |
|
466 |
-
switch
|
467 |
case 'gmedia_album':
|
468 |
-
$args['status'] = array(
|
469 |
-
$args['global'] = $gmCore->_get(
|
470 |
-
if
|
471 |
-
$args['global'] = wp_parse_id_list(
|
472 |
-
$args['global'] = array_intersect(
|
473 |
-
if
|
474 |
-
$args['global'] = array(
|
475 |
}
|
476 |
}
|
477 |
-
|
478 |
-
|
|
|
|
|
479 |
}
|
480 |
break;
|
481 |
case 'gmedia_category':
|
482 |
-
$args
|
483 |
-
$args['offset'] = '';
|
484 |
-
$args['search'] = '';
|
485 |
-
$args['include'] = null;
|
486 |
break;
|
487 |
}
|
488 |
|
489 |
-
$gmediaTerms = $gmDB->get_terms(
|
490 |
-
$alert
|
491 |
-
if
|
492 |
-
$alert
|
493 |
$gmediaTerms = array();
|
494 |
}
|
495 |
|
496 |
$modules = array();
|
497 |
-
if
|
498 |
-
foreach
|
499 |
-
if
|
500 |
continue;
|
501 |
}
|
502 |
$module_info = array();
|
503 |
-
include(
|
504 |
-
if
|
505 |
continue;
|
506 |
}
|
507 |
-
$mfold
|
508 |
-
$modules[
|
509 |
-
'module_name'
|
510 |
'module_title' => $module_info['title'] . ' v' . $module_info['version'],
|
511 |
-
'module_url'
|
512 |
-
'module_path'
|
513 |
);
|
514 |
}
|
515 |
}
|
516 |
-
if
|
517 |
-
foreach
|
518 |
-
if
|
519 |
continue;
|
520 |
}
|
521 |
$module_info = array();
|
522 |
-
include(
|
523 |
-
if
|
524 |
continue;
|
525 |
}
|
526 |
-
$mfold
|
527 |
-
$modules[
|
528 |
-
'module_name'
|
529 |
'module_title' => $module_info['title'] . ' v' . $module_info['version'],
|
530 |
-
'module_url'
|
531 |
-
'module_path'
|
532 |
);
|
533 |
}
|
534 |
}
|
@@ -537,30 +550,30 @@ function gmedia_add_media_terms() {
|
|
537 |
|
538 |
<div class="panel panel-default">
|
539 |
<div class="panel-heading clearfix">
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
|
557 |
<div class="btn-group" style="margin-right:20px;">
|
558 |
-
<a class="btn btn<?php echo (
|
559 |
-
href="<?php echo add_query_arg(
|
560 |
-
<a class="btn btn<?php echo (
|
561 |
-
href="<?php echo add_query_arg(
|
562 |
-
<a class="btn btn<?php echo (
|
563 |
-
href="<?php echo add_query_arg(
|
564 |
</div>
|
565 |
|
566 |
</div>
|
@@ -570,80 +583,98 @@ function gmedia_add_media_terms() {
|
|
570 |
<div class="col-xs-7 col-md-9" style="padding: 0">
|
571 |
<div class="list-group" id="gm-list-table" style="margin-bottom:4px;">
|
572 |
<?php
|
573 |
-
if
|
574 |
-
$author = $gmCore->caps['gmedia_show_others_media']
|
575 |
$allow_edit = $gmCore->caps['gmedia_edit_others_media'];
|
576 |
$gmediaCategories = $gmGallery->options['taxonomies']['gmedia_category'];
|
577 |
-
foreach
|
578 |
$author_name = $owner = '';
|
579 |
$list_row_class = $row_class = '';
|
580 |
$termItems = array();
|
581 |
-
$per_page
|
582 |
$item_name = $item->name;
|
583 |
-
if('gmedia_album' == $taxonomy)
|
584 |
-
|
585 |
-
|
586 |
-
$
|
587 |
-
$
|
588 |
-
if ( $item->global == $user_ID ) {
|
589 |
$row_class .= ' current_user';
|
590 |
$allow_edit = $gmCore->caps['gmedia_album_manage'];
|
591 |
-
} else
|
592 |
$row_class .= ' other_user';
|
593 |
$allow_edit = $gmCore->caps['gmedia_edit_others_media'];
|
594 |
}
|
595 |
-
} else
|
596 |
$owner = '—';
|
597 |
-
$author_name .= '(' . __(
|
598 |
$row_class .= ' shared';
|
599 |
$allow_edit = $gmCore->caps['gmedia_edit_others_media'];
|
600 |
}
|
601 |
-
if
|
602 |
$author_name .= ' [' . $item->status . ']';
|
603 |
-
if
|
604 |
$list_row_class = ' list-group-item-info';
|
605 |
-
} elseif
|
606 |
//$list_row_class = ' list-group-item-warning';
|
607 |
continue;
|
608 |
}
|
609 |
}
|
610 |
-
}
|
611 |
-
if('gmedia_tag' == $taxonomy){
|
612 |
-
$args = array('no_found_rows' => true, 'per_page' => $per_page, 'tag_id' => $item->term_id, 'author' => $author);
|
613 |
-
}
|
614 |
-
if('gmedia_category' == $taxonomy){
|
615 |
-
$args = array('no_found_rows' => true, 'per_page' => $per_page, 'category__in' => $item->term_id, 'author' => $author);
|
616 |
$item_name = $gmediaCategories[$item_name];
|
617 |
$allow_edit = false;
|
618 |
}
|
619 |
|
620 |
-
if
|
621 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
622 |
}
|
623 |
?>
|
624 |
-
<div class="list-group-item term-list-item<?php echo $list_row_class; ?>">
|
625 |
<div class="row<?php echo $row_class; ?>">
|
626 |
<div class="term_id">#<?php echo $item->term_id; ?></div>
|
627 |
<div class="col-xs-5 term-label">
|
628 |
<div class="no-checkbox">
|
629 |
-
<
|
630 |
<span class="term_info_author"><?php echo $author_name; ?></span>
|
631 |
<span class="badge pull-right"><?php echo $item->count; ?></span>
|
632 |
</div>
|
633 |
</div>
|
634 |
<div class="col-xs-7">
|
635 |
<div class="term-images">
|
636 |
-
<?php if
|
637 |
-
foreach
|
638 |
?>
|
639 |
<img style="z-index:<?php echo $per_page --; ?>;"
|
640 |
-
src="<?php echo $gmCore->gm_get_media_image(
|
641 |
alt="<?php echo $i->ID; ?>"
|
642 |
-
title="<?php echo esc_attr(
|
643 |
<?php
|
644 |
}
|
645 |
}
|
646 |
-
if
|
647 |
echo '...';
|
648 |
}
|
649 |
?>
|
@@ -666,43 +697,46 @@ function gmedia_add_media_terms() {
|
|
666 |
'gmedia_category' => 'cat'
|
667 |
);
|
668 |
?>
|
669 |
-
<input type="hidden" name="taxonomy" value="<?php echo $taxonomy; ?>"
|
670 |
-
<input type="hidden" name="term_id" value="<?php echo $item->term_id; ?>"
|
671 |
<p><strong><?php echo $tax_name[$taxonomy]; ?>:</strong> <?php echo esc_html($item_name); ?>
|
672 |
-
<br
|
673 |
<?php if('gmedia_album' == $taxonomy){
|
674 |
$orderby = array(
|
675 |
'custom' => __('user defined', 'gmLang'),
|
676 |
-
'ID' =>
|
677 |
'title' => __('by title', 'gmLang'),
|
678 |
'date' => __('by date', 'gmLang'),
|
679 |
'modified' => __('by last modified date', 'gmLang'),
|
680 |
'rand' => __('Random', 'gmLang')
|
681 |
); ?>
|
682 |
-
<br
|
683 |
-
<br
|
684 |
-
<br
|
685 |
-
<br
|
686 |
<?php } ?>
|
687 |
</p>
|
688 |
<p>
|
689 |
<a href="<?php echo add_query_arg(array('page' => 'GrandMedia', $lib_arg[$taxonomy] => $item->term_id), admin_url('admin.php')); ?>" target="_blank"><?php _e('Open in Gmedia Library', 'gmLang'); ?></a>
|
690 |
<?php if(('gmedia_album' == $taxonomy) && $allow_edit){ ?>
|
691 |
-
| <a href="<?php echo add_query_arg(array(
|
|
|
|
|
|
|
692 |
<?php } ?>
|
693 |
</p>
|
694 |
</div>
|
695 |
-
<?php if
|
696 |
-
<div class="term-description"><?php echo nl2br(esc_html(
|
697 |
<?php } ?>
|
698 |
</div>
|
699 |
<?php
|
700 |
}
|
701 |
-
} else
|
702 |
?>
|
703 |
<div class="list-group-item">
|
704 |
<div class="well well-lg text-center">
|
705 |
-
<h4><?php _e(
|
706 |
</div>
|
707 |
</div>
|
708 |
<?php } ?>
|
@@ -712,18 +746,18 @@ function gmedia_add_media_terms() {
|
|
712 |
<form method="post" id="gmedia-form" role="form">
|
713 |
<div class="media-upload-form-container">
|
714 |
<div class="form-group">
|
715 |
-
<label><?php _e(
|
716 |
<select class="form-control input-sm" id="module_preset" name="module_preset" required="required">
|
717 |
<option value=""><?php _e('Choose module/preset', 'gmLang'); ?></option>
|
718 |
-
<?php foreach
|
719 |
echo '<optgroup label="' . esc_attr($module['module_title']) . '">';
|
720 |
-
$presets = $gmDB->get_terms(
|
721 |
$option = array();
|
722 |
-
$option['default'] = '<option value="' . esc_attr($mfold) . '">' . '[' . $mfold . '] ' . __(
|
723 |
-
foreach
|
724 |
-
if
|
725 |
-
$option['default'] = '<option value="' . $preset->term_id . '">' . '[' . $mfold . '] ' . __(
|
726 |
-
} else
|
727 |
$option[] = '<option value="' . $preset->term_id . '">' . $preset->name . '</option>';
|
728 |
}
|
729 |
}
|
@@ -736,28 +770,28 @@ function gmedia_add_media_terms() {
|
|
736 |
</div>
|
737 |
<div class="panel-footer">
|
738 |
<input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>"/>
|
739 |
-
<?php wp_nonce_field(
|
740 |
-
<button type="submit" id="media-upload-form-submit" disabled class="btn btn-primary pull-right" name="gmedia_term_insert"><?php _e(
|
741 |
</div>
|
742 |
</form>
|
743 |
</div>
|
744 |
</div>
|
745 |
</div>
|
746 |
<script type="text/javascript">
|
747 |
-
jQuery(function
|
748 |
-
function divFrame()
|
749 |
$('.panel-body').css({top: $('.panel-heading').outerHeight()});
|
750 |
}
|
751 |
|
752 |
divFrame();
|
753 |
-
$(window).on('resize', function
|
754 |
divFrame();
|
755 |
});
|
756 |
-
$('.term-list-item').on('click', function
|
757 |
-
$(this).addClass('active').siblings().removeClass('active');
|
758 |
var info = $('.term-info', this).clone();
|
759 |
$('#media-upload-form-container').html(info.html());
|
760 |
-
if($('#module_preset').val())
|
761 |
$('#media-upload-form-submit').prop('disabled', false);
|
762 |
}
|
763 |
});
|
@@ -775,33 +809,33 @@ function gmedia_add_media_terms() {
|
|
775 |
}
|
776 |
|
777 |
|
778 |
-
function gmedia_add_media_library()
|
779 |
|
780 |
global $user_ID, $gmCore, $gmDB, $gmGallery;
|
781 |
|
782 |
-
wp_enqueue_style(
|
783 |
-
wp_enqueue_script(
|
784 |
|
785 |
-
wp_enqueue_style(
|
786 |
-
wp_enqueue_script(
|
787 |
|
788 |
-
$post_id = intval(
|
789 |
|
790 |
-
if
|
791 |
$author = 0;
|
792 |
-
} else
|
793 |
$author = $user_ID;
|
794 |
}
|
795 |
-
$args
|
796 |
-
'mime_type' => $gmCore->_get(
|
797 |
-
'author'
|
798 |
-
'orderby'
|
799 |
-
'order'
|
800 |
-
'per_page'
|
801 |
-
'page'
|
802 |
-
's'
|
803 |
);
|
804 |
-
$gmediaQuery = $gmDB->get_gmedias(
|
805 |
|
806 |
|
807 |
?>
|
@@ -810,14 +844,14 @@ function gmedia_add_media_library() {
|
|
810 |
<div class="panel-heading clearfix">
|
811 |
<form class="form-inline gmedia-search-form" role="search">
|
812 |
<div class="form-group">
|
813 |
-
<?php foreach
|
814 |
-
if
|
815 |
?>
|
816 |
<input type="hidden" name="<?php echo $key; ?>" value="<?php echo $value; ?>"/>
|
817 |
<?php
|
818 |
}
|
819 |
} ?>
|
820 |
-
<input id="gmedia-search" class="form-control input-sm" type="text" name="s" placeholder="<?php _e(
|
821 |
</div>
|
822 |
<button type="submit" class="btn btn-default input-sm"><span class="glyphicon glyphicon-search"></span></button>
|
823 |
</form>
|
@@ -828,10 +862,10 @@ function gmedia_add_media_library() {
|
|
828 |
<div class="row">
|
829 |
<div class="col-xs-7 col-md-9" style="text-align:justify;">
|
830 |
<?php
|
831 |
-
if
|
832 |
-
foreach
|
833 |
-
$meta = $gmDB->get_metadata(
|
834 |
-
$type = explode(
|
835 |
|
836 |
/*
|
837 |
$item_url = $gmCore->upload['url'] . '/' . $gmGallery->options['folder'][$type[0]] . '/' . $item->gmuid;
|
@@ -851,36 +885,36 @@ function gmedia_add_media_library() {
|
|
851 |
*/
|
852 |
?>
|
853 |
<form class="thumbnail" id="list-item-<?php echo $item->ID; ?>" data-id="<?php echo $item->ID; ?>" data-type="<?php echo $type[0]; ?>">
|
854 |
-
<img src="<?php echo $gmCore->gm_get_media_image(
|
855 |
<span class="glyphicon glyphicon-ok text-success"></span>
|
856 |
|
857 |
<div class="media-upload-form" style="display:none;">
|
858 |
<input name="ID" type="hidden" value="<?php echo $item->ID; ?>"/>
|
859 |
|
860 |
<div class="form-group">
|
861 |
-
<label><?php _e(
|
862 |
-
<input name="title" type="text" class="form-control input-sm" placeholder="<?php _e(
|
863 |
</div>
|
864 |
<div class="form-group">
|
865 |
-
<label><?php _e(
|
866 |
<select id="gmedia_url" class="form-control input-sm" style="display:block;margin-bottom:5px;">
|
867 |
-
<option value="customurl" selected="selected"><?php _e(
|
868 |
-
<option value="weburl"><?php _e(
|
869 |
-
<option value="originalurl"><?php _e(
|
870 |
</select>
|
871 |
<input name="link" type="text" class="customurl form-control input-sm" value="<?php echo $item->link; ?>" placeholder="http://"/>
|
872 |
<input name="link" type="text" style="display:none;font-size:80%;" readonly="readonly" disabled="disabled" class="weburl form-control input-sm" value="<?php echo $gmCore->upload['url'] . '/' . $gmGallery->options['folder']['image'] . '/' . $item->gmuid; ?>"/>
|
873 |
<input name="link" type="text" style="display:none;font-size:80%;" readonly="readonly" disabled="disabled" class="originalurl form-control input-sm" value="<?php echo $gmCore->upload['url'] . '/' . $gmGallery->options['folder']['image_original'] . '/' . $item->gmuid; ?>"/>
|
874 |
</div>
|
875 |
<div class="form-group">
|
876 |
-
<label><?php _e(
|
877 |
-
<textarea name="description" class="form-control input-sm" rows="4" cols="10"><?php echo esc_html(
|
878 |
</div>
|
879 |
<?php //if($is_webimage){ ?>
|
880 |
-
<?php if
|
881 |
-
$_metadata = unserialize(
|
882 |
<div class="form-group">
|
883 |
-
<label><?php _e(
|
884 |
<select name="size" class="form-control input-sm">
|
885 |
<option value="thumb"><?php echo 'Thumb - ' . $_metadata['thumb']['width'] . ' × ' . $_metadata['thumb']['height']; ?></option>
|
886 |
<option value="web" selected="selected"><?php echo 'Web - ' . $_metadata['web']['width'] . ' × ' . $_metadata['web']['height']; ?></option>
|
@@ -890,26 +924,26 @@ function gmedia_add_media_library() {
|
|
890 |
<?php } ?>
|
891 |
<?php //} ?>
|
892 |
<div class="form-group">
|
893 |
-
<label><?php _e(
|
894 |
<select name="align" class="form-control input-sm">
|
895 |
-
<option value="none" selected="selected"><?php _e(
|
896 |
-
<option value="left"><?php _e(
|
897 |
-
<option value="center"><?php _e(
|
898 |
-
<option value="right"><?php _e(
|
899 |
</select>
|
900 |
</div>
|
901 |
</div>
|
902 |
</form>
|
903 |
<?php
|
904 |
}
|
905 |
-
} else
|
906 |
?>
|
907 |
<div class="list-group-item">
|
908 |
<div class="well well-lg text-center">
|
909 |
-
<h4><?php _e(
|
910 |
-
<?php if
|
911 |
<p>
|
912 |
-
<a target="_blank" href="<?php echo admin_url(
|
913 |
</a></p>
|
914 |
<?php } ?>
|
915 |
</div>
|
@@ -921,10 +955,10 @@ function gmedia_add_media_library() {
|
|
921 |
<div id="media-upload-form-container" class="media-upload-form-container"></div>
|
922 |
<div class="panel-footer">
|
923 |
<input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>"/>
|
924 |
-
<?php wp_nonce_field(
|
925 |
-
<button type="submit" id="media-upload-form-submit" disabled class="btn btn-primary pull-right" name="gmedia_library_insert"><?php _e(
|
926 |
-
<?php if
|
927 |
-
<a id="gmedia-post-thumbnail" class="btn disabled" href="javascript:void(0);"><?php _e(
|
928 |
<?php } ?>
|
929 |
</div>
|
930 |
</form>
|
@@ -932,19 +966,19 @@ function gmedia_add_media_library() {
|
|
932 |
</div>
|
933 |
</div>
|
934 |
<script type="text/javascript">
|
935 |
-
jQuery(function
|
936 |
-
function divFrame()
|
937 |
$('.panel-body').css({top: $('.panel-heading').outerHeight()});
|
938 |
}
|
939 |
|
940 |
divFrame();
|
941 |
-
$(window).on('resize', function
|
942 |
divFrame();
|
943 |
});
|
944 |
-
$('.thumbnail').on('click', function
|
945 |
var form = $('#media-upload-form-container');
|
946 |
var but = $('.panel-footer .btn');
|
947 |
-
if
|
948 |
$(this).removeClass('active');
|
949 |
form.empty();
|
950 |
but.prop('disabled', true).addClass('disabled');
|
@@ -954,7 +988,7 @@ function gmedia_add_media_library() {
|
|
954 |
form.html($('.media-upload-form', this).html());
|
955 |
but.prop('disabled', false).removeClass('disabled');
|
956 |
});
|
957 |
-
$('#gmedia-form').on('change', '#gmedia_url', function
|
958 |
var val = $(this).val();
|
959 |
$(this).nextAll('input.' + val).show().prop('disabled', false).siblings('input').hide().prop('disabled', true);
|
960 |
});
|
@@ -964,20 +998,20 @@ function gmedia_add_media_library() {
|
|
964 |
$featured_nonce = wp_create_nonce( "set_post_thumbnail-$post_id" );
|
965 |
?>
|
966 |
|
967 |
-
$('#gmedia-post-thumbnail').on('click', function
|
968 |
-
if
|
969 |
return false;
|
970 |
}
|
971 |
var id = $('form.active').data('id');
|
972 |
$.post(ajaxurl, {
|
973 |
action: "gmedia_set_post_thumbnail", post_id: '<?php echo $post_id; ?>', img_id: id, _wpnonce: '<?php echo $featured_nonce; ?>'
|
974 |
-
}, function
|
975 |
var win = window.dialogArguments || opener || parent || top;
|
976 |
-
if
|
977 |
alert(win.setPostThumbnailL10n.error);
|
978 |
-
} else if
|
979 |
// image removed
|
980 |
-
} else
|
981 |
win.WPSetThumbnailID(id);
|
982 |
win.WPSetThumbnailHTML(str);
|
983 |
}
|
@@ -993,260 +1027,262 @@ function gmedia_add_media_library() {
|
|
993 |
<?php
|
994 |
}
|
995 |
|
996 |
-
function gmedia_add_media_upload()
|
997 |
|
998 |
global $gmCore, $gmDB, $gmProcessor, $gmGallery, $user_ID;
|
999 |
|
1000 |
-
if
|
1001 |
-
_e(
|
1002 |
|
1003 |
return;
|
1004 |
}
|
1005 |
|
1006 |
-
$maxupsize
|
1007 |
-
$maxupsize
|
1008 |
-
$maxupsize_mb = floor(
|
1009 |
|
1010 |
$gm_screen_options = $gmProcessor->user_options();
|
1011 |
|
1012 |
?>
|
1013 |
<div class="panel panel-default">
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1045 |
|
1046 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1047 |
|
1048 |
-
|
1049 |
-
<div class="form-group">
|
1050 |
-
<?php
|
1051 |
-
$term_type = 'gmedia_category';
|
1052 |
-
$gm_terms = $gmGallery->options['taxonomies'][ $term_type ];
|
1053 |
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
}
|
1060 |
-
?>
|
1061 |
-
<label><?php _e( 'Assign Category', 'gmLang' ); ?>
|
1062 |
-
<small><?php _e( '(for images only)' ) ?></small>
|
1063 |
-
</label>
|
1064 |
-
<select id="gmedia_category" name="terms[gmedia_category]" class="form-control input-sm">
|
1065 |
-
<option value=""><?php _e( 'Uncategorized', 'gmLang' ); ?></option>
|
1066 |
-
<?php echo $terms_category; ?>
|
1067 |
-
</select>
|
1068 |
-
</div>
|
1069 |
-
<div class="form-group">
|
1070 |
-
<?php
|
1071 |
-
$term_type = 'gmedia_album';
|
1072 |
-
$gm_terms = $gmDB->get_terms( $term_type, array( 'global' => array( 0, $user_ID ), 'orderby' => 'global_desc_name' ) );
|
1073 |
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
<input id="combobox_gmedia_tag" name="terms[gmedia_tag]" class="form-control input-sm" value="" placeholder="<?php _e( 'Add Tags...', 'gmLang' ); ?>"/>
|
1094 |
-
</div>
|
1095 |
-
<?php } else { ?>
|
1096 |
-
<p><?php _e( 'You are not allowed to assign terms', 'gmLang' ) ?></p>
|
1097 |
-
<?php } ?>
|
1098 |
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
},
|
1122 |
-
createOnBlur: true,
|
1123 |
-
<?php } else{ ?>
|
1124 |
-
create: false,
|
1125 |
-
<?php } ?>
|
1126 |
-
delimiter: ',',
|
1127 |
-
maxItems: null,
|
1128 |
-
openOnFocus: false,
|
1129 |
-
persist: false,
|
1130 |
-
options: items,
|
1131 |
-
labelField: 'item',
|
1132 |
-
valueField: 'item',
|
1133 |
-
hideSelected: true
|
1134 |
-
});
|
1135 |
-
<?php } ?>
|
1136 |
-
$('#uploader_runtime select').change(function () {
|
1137 |
-
if ('html4' == $(this).val()) {
|
1138 |
-
$('#uploader_chunking').addClass('hide');
|
1139 |
-
$('#uploader_urlstream_upload').addClass('hide');
|
1140 |
-
} else {
|
1141 |
-
$('#uploader_chunking').removeClass('hide');
|
1142 |
-
$('#uploader_urlstream_upload').removeClass('hide');
|
1143 |
-
}
|
1144 |
-
});
|
1145 |
-
});
|
1146 |
-
</script>
|
1147 |
-
</div>
|
1148 |
-
<div class="col-md-8" id="pluploadUploader" style="padding: 0;">
|
1149 |
-
<p><?php _e( "You browser doesn't have Flash or HTML5 support. Check also if page have no JavaScript errors.", 'gmLang' ); ?></p>
|
1150 |
-
<?php
|
1151 |
-
$mime_types = get_allowed_mime_types( $user_ID );
|
1152 |
-
$type_ext = array();
|
1153 |
-
$filters = array();
|
1154 |
-
foreach ( $mime_types as $ext => $mime ) {
|
1155 |
-
$type = strtok( $mime, '/' );
|
1156 |
-
$type_ext[ $type ][] = $ext;
|
1157 |
-
}
|
1158 |
-
foreach ( $type_ext as $filter => $ext ) {
|
1159 |
-
$filters[] = array(
|
1160 |
-
'title' => $filter,
|
1161 |
-
'extensions' => str_replace( '|', ',', implode( ',', $ext ) )
|
1162 |
-
);
|
1163 |
-
}
|
1164 |
-
?>
|
1165 |
-
<script type="text/javascript">
|
1166 |
-
// Convert divs to queue widgets when the DOM is ready
|
1167 |
-
jQuery(function ($) {
|
1168 |
-
$("#pluploadUploader").plupload({
|
1169 |
-
<?php if('auto' != $gm_screen_options['uploader_runtime']){ ?>
|
1170 |
-
runtimes: '<?php echo $gm_screen_options['uploader_runtime']; ?>',
|
1171 |
-
<?php } ?>
|
1172 |
-
url: '<?php echo wp_nonce_url($gmCore->gmedia_url . '/admin/upload.php', 'grandMedia' ); ?>',
|
1173 |
-
<?php if(('true' == $gm_screen_options['uploader_urlstream_upload']) && ('html4' != $gm_screen_options['uploader_runtime'])){ ?>
|
1174 |
-
urlstream_upload: true,
|
1175 |
-
multipart: false,
|
1176 |
-
<?php } else{ ?>
|
1177 |
-
multipart: true,
|
1178 |
-
<?php } ?>
|
1179 |
-
multipart_params: {params: ''},
|
1180 |
-
<?php if('true' == $gm_screen_options['uploader_chunking'] && ('html4' != $gm_screen_options['uploader_runtime'])){ ?>
|
1181 |
-
max_file_size: '2000Mb',
|
1182 |
-
chunk_size: 200000<?php //echo min($maxupsize, $gm_screen_options['uploader_chunk_size']*1024*1024); ?>,
|
1183 |
<?php } else{ ?>
|
1184 |
-
|
1185 |
<?php } ?>
|
1186 |
-
max_retries: 2,
|
1187 |
-
unique_names: false,
|
1188 |
-
rename: true,
|
1189 |
-
sortable: true,
|
1190 |
-
dragdrop: true,
|
1191 |
-
views: {
|
1192 |
-
list: true,
|
1193 |
-
thumbs: true,
|
1194 |
-
active: 'thumbs'
|
1195 |
-
},
|
1196 |
-
filters: <?php echo json_encode($filters); ?>,
|
1197 |
-
flash_swf_url: '<?php echo $gmCore->gmedia_url; ?>/assets/plupload/Moxie.swf',
|
1198 |
-
silverlight_xap_url: '<?php echo $gmCore->gmedia_url; ?>/assets/plupload/Moxie.xap'
|
1199 |
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
|
|
|
|
1250 |
</div>
|
1251 |
<?php
|
1252 |
}
|
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 |
* @title Add action/filter for the upload tab
|
8 |
*/
|
9 |
|
10 |
+
if(current_user_can('gmedia_library')){
|
11 |
+
add_filter('media_buttons_context', 'gmedia_media_buttons_context', 4);
|
12 |
+
add_filter('media_upload_tabs', 'gmedia_upload_tabs');
|
13 |
+
add_action('media_upload_gmedia_library', 'media_upload_gmedia');
|
14 |
+
add_action('media_upload_gmedia_terms', 'media_upload_gmedia');
|
15 |
+
add_action('media_upload_gmedia_galleries', 'media_upload_gmedia');
|
16 |
}
|
17 |
|
18 |
|
21 |
*
|
22 |
* @return string
|
23 |
*/
|
24 |
+
function gmedia_media_buttons_context($context){
|
25 |
$button = '
|
26 |
<div style="display:inline-block;">
|
27 |
+
<a id="gmedia-modal" title="Gmedia Galleries" class="gmedia_button button" href="#gmedia"><span class="wp-media-buttons-icon" style="background: url(' . plugins_url(GMEDIA_FOLDER . '/admin/images/gm-icon.png') . ') no-repeat top left;"></span> ' . __('Gmedia', 'gmLang') . '</a>
|
28 |
</div>';
|
29 |
|
30 |
return $context . $button;
|
35 |
*
|
36 |
* @return array
|
37 |
*/
|
38 |
+
function gmedia_upload_tabs($tabs){
|
39 |
|
40 |
$newtab = array(
|
41 |
+
'gmedia_library' => __('Gmedia Library', 'gmLang'),
|
42 |
+
'gmedia_terms' => __('Gmedia Collections', 'gmLang'),
|
43 |
+
'gmedia_galleries' => __('Gmedia Galleries', 'gmLang')
|
44 |
);
|
45 |
|
46 |
+
if(is_array($tabs)){
|
47 |
+
return array_merge($tabs, $newtab);
|
48 |
}
|
49 |
|
50 |
return $newtab;
|
51 |
}
|
52 |
|
53 |
+
function media_upload_gmedia(){
|
54 |
global $gmCore, $gmDB;
|
55 |
|
56 |
+
add_action('admin_enqueue_scripts', 'gmedia_add_media_popup_enqueue_scripts');
|
57 |
+
|
58 |
+
$action = $gmCore->_get('action');
|
59 |
+
if(did_action('media_upload_gmedia_galleries')){
|
60 |
+
wp_iframe('gmedia_add_media_galleries');
|
61 |
+
} elseif(did_action('media_upload_gmedia_terms')){
|
62 |
+
wp_iframe('gmedia_add_media_terms');
|
63 |
+
} elseif(did_action('media_upload_gmedia_library')){
|
64 |
+
if(('upload' == $action) && current_user_can('gmedia_upload')){
|
65 |
+
wp_iframe('gmedia_add_media_upload');
|
66 |
+
} else{
|
67 |
+
wp_iframe('gmedia_add_media_library');
|
68 |
}
|
69 |
}
|
70 |
|
71 |
// Generate TinyMCE HTML output
|
72 |
+
if(isset($_POST['gmedia_library_insert'])){
|
73 |
|
74 |
+
$id = $gmCore->_post('ID', 0);
|
75 |
|
76 |
+
if(($gmedia = $gmDB->get_gmedia($id))){
|
77 |
|
78 |
+
$meta = $gmDB->get_metadata('gmedia', $gmedia->ID, '_metadata', true);
|
79 |
|
80 |
+
$size = $gmCore->_post('size', 'web');
|
81 |
+
$src = $gmCore->gm_get_media_image($gmedia, $size);
|
82 |
+
$width = $meta[$size]['width'];
|
83 |
+
$height = $meta[$size]['height'];
|
84 |
+
$title = esc_attr($gmCore->_post('title', ''));
|
85 |
+
$align = esc_attr($gmCore->_post('align', 'none'));
|
86 |
+
$link = trim(esc_attr($gmCore->_post('link', '')));
|
87 |
+
$caption = trim($gmCore->_post('description', ''));
|
88 |
|
89 |
$html = "<img src='{$src}' width='{$width}' height='{$height}' alt='{$title}' title='{$title}' id='gmedia-image-{$id}' class='gmedia-singlepic align{$align}' />";
|
90 |
|
91 |
+
if($link){
|
92 |
$html = "<a href='{$link}'>{$html}</a>";
|
93 |
}
|
94 |
+
if($caption){
|
95 |
+
$html = image_add_caption($html, false, $caption, $title, $align, $src, $size, $title);
|
96 |
}
|
97 |
|
98 |
?>
|
104 |
</script>
|
105 |
<?php
|
106 |
// Return it to TinyMCE
|
107 |
+
media_send_to_editor($html);
|
108 |
}
|
109 |
}
|
110 |
+
if(isset($_POST['gmedia_gallery_insert'])){
|
111 |
+
$sc = $gmCore->_post('shortcode');
|
112 |
?>
|
113 |
<script type="text/javascript">
|
114 |
/* <![CDATA[ */
|
118 |
</script>
|
119 |
<?php
|
120 |
// Return it to TinyMCE
|
121 |
+
media_send_to_editor($sc);
|
122 |
}
|
123 |
+
if(isset($_POST['gmedia_term_insert'])){
|
124 |
$module_preset = $gmCore->_post('module_preset');
|
125 |
if($gmCore->is_digit($module_preset)){
|
126 |
+
$module_preset = $gmDB->get_term((int) $module_preset, 'gmedia_module');
|
127 |
$module = $module_preset->status;
|
128 |
$preset = ' preset=' . $module_preset->term_id;
|
129 |
+
} else{
|
130 |
$module = $module_preset;
|
131 |
$preset = '';
|
132 |
}
|
144 |
</script>
|
145 |
<?php
|
146 |
// Return it to TinyMCE
|
147 |
+
media_send_to_editor($sc);
|
148 |
}
|
149 |
}
|
150 |
|
151 |
}
|
152 |
|
153 |
+
function gmedia_add_media_popup_enqueue_scripts(){
|
154 |
global $gmCore;
|
155 |
|
156 |
+
wp_dequeue_script('imgareaselect');
|
157 |
+
wp_dequeue_script('image-edit');
|
158 |
+
wp_dequeue_script('set-post-thumbnail');
|
159 |
+
wp_dequeue_script('media-gallery');
|
160 |
+
wp_dequeue_script('plupload');
|
161 |
+
wp_dequeue_script('plupload-handlers');
|
162 |
+
wp_dequeue_style('imgareaselect');
|
163 |
+
|
164 |
+
wp_enqueue_style('gmedia-bootstrap');
|
165 |
+
wp_enqueue_script('gmedia-bootstrap');
|
166 |
+
|
167 |
+
wp_enqueue_style('grand-media');
|
168 |
+
wp_enqueue_script('grand-media');
|
169 |
+
|
170 |
+
$action = $gmCore->_get('action');
|
171 |
+
if(did_action('media_upload_gmedia_library') && ('upload' == $action) && current_user_can('gmedia_upload')){
|
172 |
+
if(current_user_can('gmedia_terms')){
|
173 |
+
wp_enqueue_style('selectize', $gmCore->gmedia_url . '/assets/selectize/selectize.bootstrap3.css', array('gmedia-bootstrap'), '0.8.5', 'screen');
|
174 |
+
wp_enqueue_script('selectize', $gmCore->gmedia_url . '/assets/selectize/selectize.min.js', array('jquery'), '0.8.5');
|
175 |
}
|
176 |
+
wp_enqueue_style('jquery-ui-smoothness', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/smoothness/jquery-ui.min.css', array(), '1.10.2', 'screen');
|
177 |
+
wp_enqueue_script('jquery-ui-full', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js', array(), '1.10.2');
|
178 |
|
179 |
+
wp_enqueue_script('gmedia-plupload', $gmCore->gmedia_url . '/assets/plupload/plupload.full.min.js', array('jquery', 'jquery-ui-full'), '2.1.2');
|
180 |
|
181 |
+
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');
|
182 |
+
wp_enqueue_script('jquery.ui.plupload', $gmCore->gmedia_url . '/assets/plupload/jquery.ui.plupload/jquery.ui.plupload.min.js', array('gmedia-plupload', 'jquery-ui-full'), '2.1.2');
|
183 |
}
|
184 |
|
185 |
}
|
186 |
|
187 |
+
function gmedia_add_media_galleries(){
|
188 |
|
189 |
global $user_ID, $gmCore, $gmDB, $gmGallery, $gmProcessor;
|
190 |
|
191 |
+
$post_id = intval($gmCore->_get('post_id'));
|
192 |
|
193 |
+
$gm_screen_options = get_user_meta($user_ID, 'gm_screen_options', true);
|
194 |
+
if(!is_array($gm_screen_options)){
|
195 |
+
$gm_screen_options = array();
|
196 |
+
}
|
197 |
+
$gm_screen_options = array_merge($gmGallery->options['gm_screen_options'], $gm_screen_options);
|
198 |
+
$orderby = !empty($gm_screen_options['orderby_gmedia_galleries'])? $gm_screen_options['orderby_gmedia_galleries'] : 'name';
|
199 |
+
$order = !empty($gm_screen_options['sortorder_gmedia_galleries'])? $gm_screen_options['sortorder_gmedia_galleries'] : 'ASC';
|
200 |
+
$per_page = !empty($gm_screen_options['per_page_gmedia_galleries'])? $gm_screen_options['per_page_gmedia_galleries'] : 30;
|
201 |
+
|
202 |
+
$args = array(
|
203 |
+
'orderby' => $gmCore->_get('orderby', $orderby),
|
204 |
+
'order' => $gmCore->_get('order', $order),
|
205 |
+
'search' => $gmCore->_get('s', ''),
|
206 |
+
'number' => $gmCore->_get('number', $per_page),
|
207 |
'hide_empty' => 0,
|
208 |
+
'page' => $gmCore->_get('pager', 1),
|
209 |
+
'status' => array('public', 'private')
|
210 |
);
|
211 |
+
$args['offset'] = ($args['page'] - 1) * $args['number'];
|
212 |
|
213 |
|
214 |
+
if(current_user_can('gmedia_show_others_media')){
|
215 |
+
$args['global'] = $gmCore->_get('author', '');
|
216 |
+
} else{
|
217 |
+
$args['global'] = array($user_ID);
|
218 |
}
|
219 |
|
220 |
+
$taxonomy = 'gmedia_gallery';
|
221 |
+
$gmediaTerms = $gmDB->get_terms($taxonomy, $args);
|
222 |
+
$alert = '';
|
223 |
+
if(is_wp_error($gmediaTerms)){
|
224 |
+
$alert = $gmProcessor->alert('danger', $gmediaTerms->get_error_message());
|
225 |
$gmediaTerms = array();
|
226 |
}
|
227 |
|
228 |
$modules = array();
|
229 |
+
if(($plugin_modules = glob(GMEDIA_ABSPATH . 'module/*', GLOB_ONLYDIR | GLOB_NOSORT))){
|
230 |
+
foreach($plugin_modules as $path){
|
231 |
+
$mfold = basename($path);
|
232 |
+
$modules[$mfold] = array(
|
233 |
'module_name' => $mfold,
|
234 |
+
'module_url' => $gmCore->gmedia_url . "/module/{$mfold}",
|
235 |
'module_path' => $path
|
236 |
);
|
237 |
}
|
238 |
}
|
239 |
+
if(($upload_modules = glob($gmCore->upload['path'] . '/' . $gmGallery->options['folder']['module'] . '/*', GLOB_ONLYDIR | GLOB_NOSORT))){
|
240 |
+
foreach($upload_modules as $path){
|
241 |
+
$mfold = basename($path);
|
242 |
+
$modules[$mfold] = array(
|
243 |
'module_name' => $mfold,
|
244 |
+
'module_url' => $gmCore->upload['url'] . "/{$gmGallery->options['folder']['module']}/{$mfold}",
|
245 |
'module_path' => $path
|
246 |
);
|
247 |
}
|
253 |
<div class="panel-heading clearfix">
|
254 |
<form class="form-inline gmedia-search-form" role="search" method="get">
|
255 |
<div class="form-group">
|
256 |
+
<?php foreach($_GET as $key => $value){
|
257 |
+
if(in_array($key, array('chromeless', 'post_id', 'tab', 'orderby', 'order', 'number', 'global'))){
|
258 |
?>
|
259 |
<input type="hidden" name="<?php echo $key; ?>" value="<?php echo $value; ?>"/>
|
260 |
<?php
|
261 |
}
|
262 |
} ?>
|
263 |
+
<input id="gmedia-search" class="form-control input-sm" type="text" name="s" placeholder="<?php _e('Search...', 'gmLang'); ?>" value="<?php echo $gmCore->_get('s', ''); ?>"/>
|
264 |
</div>
|
265 |
<button type="submit" class="btn btn-default input-sm"><span class="glyphicon glyphicon-search"></span></button>
|
266 |
</form>
|
267 |
<?php echo $gmDB->query_pager(); ?>
|
268 |
|
269 |
<div class="btn-group" style="margin-right:20px;">
|
270 |
+
<a class="btn btn-primary" target="_blank" href="<?php echo add_query_arg(array('page' => 'GrandMedia_Modules'), admin_url('admin.php')); ?>"><?php _e('Create New Gallery', 'gmLang'); ?></a>
|
271 |
</div>
|
272 |
|
273 |
<div class="btn-group" style="margin-right:20px;">
|
274 |
+
<a class="btn btn-success" href="#" onclick="location.reload(true); return false;"><?php _e('Refresh', 'gmLang'); ?></a>
|
275 |
</div>
|
276 |
|
277 |
</div>
|
281 |
<div class="col-xs-7 col-md-9" style="padding: 0">
|
282 |
<div class="list-group">
|
283 |
<?php
|
284 |
+
if(count($gmediaTerms)){
|
285 |
+
$lib_url = add_query_arg(array('page' => 'GrandMedia'), admin_url('admin.php'));
|
286 |
+
foreach($gmediaTerms as $term){
|
287 |
|
288 |
+
$term_meta = $gmDB->get_metadata('gmedia_term', $term->term_id);
|
289 |
+
$term_meta = array_map('reset', $term_meta);
|
290 |
+
$term_meta = array_map('maybe_unserialize', $term_meta);
|
291 |
|
292 |
+
$module = $gmCore->get_module_path($term_meta['module']);
|
293 |
+
$module_info = array('type' => '—');
|
294 |
+
if(file_exists($module['path'] . '/index.php')){
|
295 |
$broken = false;
|
296 |
+
include($module['path'] . '/index.php');
|
297 |
+
} else{
|
298 |
$broken = true;
|
299 |
}
|
300 |
|
301 |
$list_row_class = '';
|
302 |
+
if('private' == $term->status){
|
303 |
$list_row_class = ' list-group-item-info';
|
304 |
}
|
305 |
?>
|
306 |
<div class="gmedia-insert-item list-group-item clearfix d-row<?php echo $list_row_class; ?>" id="list-item-<?php echo $term->term_id; ?>" data-id="<?php echo $term->term_id; ?>" data-type="<?php echo $term_meta['module']; ?>">
|
307 |
<div class="media-object pull-left" style="width:130px;margin-right:15px;">
|
308 |
+
<?php if(!$broken){ ?>
|
309 |
+
<span class="thumbnail"><img src="<?php echo $module['url'] . '/screenshot.png'; ?>" alt="<?php echo esc_attr($term->name); ?>"/></span>
|
310 |
+
<?php } else{ ?>
|
311 |
+
<div class="bg-danger text-center"><?php _e('Module broken <br>Reinstall module', 'gmLang') ?></div>
|
312 |
<?php } ?>
|
313 |
</div>
|
314 |
|
315 |
<div class="media-body" style="margin-left:145px;">
|
316 |
<p class="media-title">
|
317 |
+
<span><?php echo esc_html($term->name); ?></span>
|
318 |
</p>
|
319 |
|
320 |
<p class="media-meta">
|
321 |
+
<span class="label label-default"><?php _e('Author', 'gmLang'); ?>:</span> <?php echo $term->global? get_the_author_meta('display_name', $term->global) : '—'; ?>
|
322 |
</p>
|
323 |
|
324 |
+
<p class="media-caption"><?php echo nl2br(esc_html($term->description)); ?></p>
|
325 |
</div>
|
326 |
|
327 |
<p class="media-meta hidden" style="font-weight:bold">
|
328 |
+
<span class="label label-default"><?php _e('Shortcode', 'gmLang'); ?>:</span> [gmedia id=<?php echo $term->term_id; ?>]
|
329 |
<input type="hidden" name="shortcode" value="[gmedia id=<?php echo $term->term_id; ?>]"/>
|
330 |
</p>
|
331 |
|
332 |
<p class="media-meta clear hidden">
|
333 |
+
<span class="label label-default"><?php _e('Module', 'gmLang'); ?>:</span> <?php echo $term_meta['module']; ?>
|
334 |
+
<br><span class="label label-default"><?php _e('Type', 'gmLang'); ?>:</span> <?php echo $module_info['type']; ?>
|
335 |
+
<br><span class="label label-default"><?php _e('Last Edited', 'gmLang'); ?>:</span> <?php echo $term_meta['edited']; ?>
|
336 |
+
<br><span class="label label-default"><?php _e('Status', 'gmLang'); ?>:</span> <?php echo $term->status; ?>
|
337 |
+
<br><span class="label label-default"><?php _e('Source', 'gmLang'); ?>:</span>
|
338 |
<?php
|
339 |
+
$gallery_tabs = reset($term_meta['query']);
|
340 |
+
$tax_tabs = key($term_meta['query']);
|
341 |
+
if('gmedia__in' == $tax_tabs){
|
342 |
+
_e('Selected Gmedia', 'gmLang');
|
343 |
+
if(!(((int) $term->global != $user_ID) && !current_user_can('gmedia_show_others_media'))){
|
344 |
+
$gmedia_ids = wp_parse_id_list($gallery_tabs[0]);
|
345 |
+
$gal_source = sprintf('<a class="selected__in" target="_blank" href="%s">' . __('Show %d items in Gmedia Library', 'gmLang') . '</a>', esc_url(add_query_arg(array('gmedia__in' => implode(',', $gmedia_ids)), $lib_url)), count($gmedia_ids));
|
346 |
echo " ($gal_source)";
|
347 |
}
|
348 |
+
} else{
|
349 |
+
$tabs = $gmDB->get_terms($tax_tabs, array('include' => $gallery_tabs));
|
350 |
$terms_source = array();
|
351 |
+
if('gmedia_category' == $tax_tabs){
|
352 |
+
_e('Categories', 'gmLang');
|
353 |
+
foreach($tabs as $t){
|
354 |
+
$terms_source[] = sprintf('<a class="category" target="_blank" href="%s">%s</a>', esc_url(add_query_arg(array('cat' => $t->term_id), $lib_url)), esc_html($gmGallery->options['taxonomies']['gmedia_category'][$t->name]));
|
355 |
}
|
356 |
+
} elseif('gmedia_album' == $tax_tabs){
|
357 |
+
_e('Albums', 'gmLang');
|
358 |
+
foreach($tabs as $t){
|
359 |
+
$terms_source[] = sprintf('<a class="album" target="_blank" href="%s">%s</a>', esc_url(add_query_arg(array('alb' => $t->term_id), $lib_url)), esc_html($t->name));
|
360 |
}
|
361 |
+
} elseif('gmedia_tag' == $tax_tabs){
|
362 |
+
_e('Tags', 'gmLang');
|
363 |
+
foreach($tabs as $t){
|
364 |
+
$terms_source[] = sprintf('<a class="tag" target="_blank" href="%s">%s</a>', esc_url(add_query_arg(array('tag_id' => $t->term_id), $lib_url)), esc_html($t->name));
|
365 |
}
|
366 |
+
} elseif('gmedia_filter' == $tax_tabs){
|
367 |
+
_e('Filters', 'gmLang');
|
368 |
+
foreach($tabs as $t){
|
369 |
+
$terms_source[] = sprintf('<a class="filter" target="_blank" href="%s">%s</a>', esc_url(add_query_arg(array('stack_id' => $t->term_id), $lib_url)), esc_html($t->name));
|
370 |
}
|
371 |
}
|
372 |
+
if(!empty($terms_source)){
|
373 |
+
$terms_source = join(', ', $terms_source);
|
374 |
+
if(((int) $term->global != $user_ID) && !current_user_can('gmedia_show_others_media')){
|
375 |
+
$terms_source = strip_tags($terms_source);
|
376 |
}
|
377 |
echo " ({$terms_source})";
|
378 |
}
|
379 |
}
|
380 |
?>
|
381 |
</p>
|
382 |
+
<?php if(current_user_can('gmedia_gallery_manage')){
|
383 |
+
if(!(((int) $term->global != $user_ID) && !current_user_can('gmedia_edit_others_media'))){
|
384 |
?>
|
385 |
+
<p class="media-meta hidden"><a target="_blank" href="<?php echo add_query_arg(array(
|
386 |
+
'page' => 'GrandMedia_Galleries',
|
387 |
+
'edit_gallery' => $term->term_id
|
388 |
+
), admin_url('admin.php')); ?>"><?php _e('Edit gallery', 'gmLang'); ?></a></p>
|
389 |
<?php
|
390 |
}
|
391 |
} ?>
|
393 |
</div>
|
394 |
<?php
|
395 |
}
|
396 |
+
} else{
|
397 |
?>
|
398 |
<div class="list-group-item">
|
399 |
<div class="well well-lg text-center">
|
400 |
+
<h4><?php _e('No items to show.', 'gmLang'); ?></h4>
|
401 |
</div>
|
402 |
</div>
|
403 |
<?php } ?>
|
408 |
<div id="media-upload-form-container" class="media-upload-form-container"></div>
|
409 |
<div class="panel-footer">
|
410 |
<input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>"/>
|
411 |
+
<?php wp_nonce_field('media-form'); ?>
|
412 |
+
<button type="submit" id="media-upload-form-submit" disabled class="btn btn-primary pull-right" name="gmedia_gallery_insert"><?php _e('Insert into post', 'gmLang'); ?></button>
|
413 |
</div>
|
414 |
</form>
|
415 |
</div>
|
416 |
</div>
|
417 |
</div>
|
418 |
<script type="text/javascript">
|
419 |
+
jQuery(function($){
|
420 |
+
function divFrame(){
|
421 |
$('.panel-body').css({top: $('.panel-heading').outerHeight()});
|
422 |
}
|
423 |
|
424 |
divFrame();
|
425 |
+
$(window).on('resize', function(){
|
426 |
divFrame();
|
427 |
});
|
428 |
+
$('.gmedia-insert-item').on('click', function(){
|
429 |
+
if($(this).hasClass('active-row')){
|
430 |
+
$(this).removeClass('active-row');
|
431 |
$('#media-upload-form-container').empty();
|
432 |
$('#media-upload-form-submit').prop('disabled', true);
|
433 |
return;
|
434 |
}
|
435 |
+
$(this).addClass('active-row').siblings().removeClass('active-row');
|
436 |
var info = $(this).clone();
|
437 |
info.find('.media-caption').remove().end().find('.hidden').removeClass('hidden');
|
438 |
$('#media-upload-form-container').html(info.html());
|
444 |
<?php
|
445 |
}
|
446 |
|
447 |
+
function gmedia_add_media_terms(){
|
448 |
|
449 |
global $user_ID, $gmCore, $gmDB, $gmGallery, $gmProcessor;
|
450 |
|
451 |
+
$post_id = intval($gmCore->_get('post_id'));
|
452 |
|
453 |
+
$url = add_query_arg(array('post_id' => $post_id, 'tab' => 'gmedia_terms', 'chromeless' => true), admin_url('media-upload.php'));
|
454 |
|
|
|
455 |
$gm_screen_options = get_user_meta($user_ID, 'gm_screen_options', true);
|
456 |
if(!is_array($gm_screen_options)){
|
457 |
$gm_screen_options = array();
|
458 |
}
|
459 |
$gm_screen_options = array_merge($gmGallery->options['gm_screen_options'], $gm_screen_options);
|
460 |
+
$orderby = !empty($gm_screen_options['orderby_gmedia_terms'])? $gm_screen_options['orderby_gmedia_terms'] : 'name';
|
461 |
+
$order = !empty($gm_screen_options['sortorder_gmedia_terms'])? $gm_screen_options['sortorder_gmedia_terms'] : 'ASC';
|
462 |
+
$per_page = !empty($gm_screen_options['per_page_gmedia_terms'])? $gm_screen_options['per_page_gmedia_terms'] : 30;
|
463 |
+
$search_string = $gmCore->_get('s', '');
|
464 |
+
|
465 |
+
$args = array(
|
466 |
+
'orderby' => $gmCore->_get('orderby', $orderby),
|
467 |
+
'order' => $gmCore->_get('order', $order),
|
468 |
+
'search' => $search_string,
|
469 |
+
'number' => $gmCore->_get('number', $per_page),
|
470 |
+
'hide_empty' => $gmCore->_get('hide_empty', 0),
|
471 |
+
'page' => $gmCore->_get('pager', 1)
|
472 |
);
|
473 |
+
$args['offset'] = ($args['page'] - 1) * $args['number'];
|
474 |
|
475 |
+
$taxonomy = $gmCore->_get('term', 'gmedia_album');
|
476 |
+
if(!in_array($taxonomy, array('gmedia_album', 'gmedia_tag', 'gmedia_category'))){
|
477 |
$taxonomy = 'gmedia_album';
|
478 |
}
|
479 |
|
480 |
+
switch($taxonomy){
|
481 |
case 'gmedia_album':
|
482 |
+
$args['status'] = array('public', 'private');
|
483 |
+
$args['global'] = $gmCore->_get('author', $gmCore->caps['gmedia_edit_others_media']? '' : array(0, $user_ID));
|
484 |
+
if(!$gmCore->caps['gmedia_show_others_media']){
|
485 |
+
$args['global'] = wp_parse_id_list($args['global']);
|
486 |
+
$args['global'] = array_intersect(array(0, $user_ID), $args['global']);
|
487 |
+
if(empty($args['global'])){
|
488 |
+
$args['global'] = array(0, $user_ID);
|
489 |
}
|
490 |
}
|
491 |
+
break;
|
492 |
+
case 'gmedia_tag':
|
493 |
+
if('global' == $args['orderby']){
|
494 |
+
$args['orderby'] = 'id';
|
495 |
}
|
496 |
break;
|
497 |
case 'gmedia_category':
|
498 |
+
$args = array();
|
|
|
|
|
|
|
499 |
break;
|
500 |
}
|
501 |
|
502 |
+
$gmediaTerms = $gmDB->get_terms($taxonomy, $args);
|
503 |
+
$alert = '';
|
504 |
+
if(is_wp_error($gmediaTerms)){
|
505 |
+
$alert = $gmProcessor->alert('danger', $gmediaTerms->get_error_message());
|
506 |
$gmediaTerms = array();
|
507 |
}
|
508 |
|
509 |
$modules = array();
|
510 |
+
if(($plugin_modules = glob(GMEDIA_ABSPATH . 'module/*', GLOB_ONLYDIR | GLOB_NOSORT))){
|
511 |
+
foreach($plugin_modules as $path){
|
512 |
+
if(!file_exists($path . '/index.php')){
|
513 |
continue;
|
514 |
}
|
515 |
$module_info = array();
|
516 |
+
include($path . '/index.php');
|
517 |
+
if(empty($module_info)){
|
518 |
continue;
|
519 |
}
|
520 |
+
$mfold = basename($path);
|
521 |
+
$modules[$mfold] = array(
|
522 |
+
'module_name' => $mfold,
|
523 |
'module_title' => $module_info['title'] . ' v' . $module_info['version'],
|
524 |
+
'module_url' => $gmCore->gmedia_url . "/module/{$mfold}",
|
525 |
+
'module_path' => $path
|
526 |
);
|
527 |
}
|
528 |
}
|
529 |
+
if(($upload_modules = glob($gmCore->upload['path'] . '/' . $gmGallery->options['folder']['module'] . '/*', GLOB_ONLYDIR | GLOB_NOSORT))){
|
530 |
+
foreach($upload_modules as $path){
|
531 |
+
if(!file_exists($path . '/index.php')){
|
532 |
continue;
|
533 |
}
|
534 |
$module_info = array();
|
535 |
+
include($path . '/index.php');
|
536 |
+
if(empty($module_info)){
|
537 |
continue;
|
538 |
}
|
539 |
+
$mfold = basename($path);
|
540 |
+
$modules[$mfold] = array(
|
541 |
+
'module_name' => $mfold,
|
542 |
'module_title' => $module_info['title'] . ' v' . $module_info['version'],
|
543 |
+
'module_url' => $gmCore->upload['url'] . "/{$gmGallery->options['folder']['module']}/{$mfold}",
|
544 |
+
'module_path' => $path
|
545 |
);
|
546 |
}
|
547 |
}
|
550 |
|
551 |
<div class="panel panel-default">
|
552 |
<div class="panel-heading clearfix">
|
553 |
+
<?php if('gmedia_category' != $taxonomy){ ?>
|
554 |
+
<form class="form-inline gmedia-search-form" role="search" method="get">
|
555 |
+
<div class="form-group">
|
556 |
+
<?php foreach($_GET as $key => $value){
|
557 |
+
if(in_array($key, array('chromeless', 'post_id', 'tab', 'orderby', 'order', 'number', 'global'))){
|
558 |
+
?>
|
559 |
+
<input type="hidden" name="<?php echo $key; ?>" value="<?php echo $value; ?>"/>
|
560 |
+
<?php
|
561 |
+
}
|
562 |
+
} ?>
|
563 |
+
<input id="gmedia-search" class="form-control input-sm" type="text" name="s" placeholder="<?php _e('Search...', 'gmLang'); ?>" value="<?php echo $gmCore->_get('s', ''); ?>"/>
|
564 |
+
</div>
|
565 |
+
<button type="submit" class="btn btn-default input-sm"><span class="glyphicon glyphicon-search"></span></button>
|
566 |
+
</form>
|
567 |
+
<?php echo $gmDB->query_pager(); ?>
|
568 |
+
<?php } ?>
|
569 |
|
570 |
<div class="btn-group" style="margin-right:20px;">
|
571 |
+
<a class="btn btn<?php echo ('gmedia_album' == $taxonomy)? "-primary active" : '-default'; ?>"
|
572 |
+
href="<?php echo add_query_arg(array('term' => 'gmedia_album'), $url); ?>"><?php _e('Albums', 'gmLang'); ?></a>
|
573 |
+
<a class="btn btn<?php echo ('gmedia_tag' == $taxonomy)? "-primary active" : '-default'; ?>"
|
574 |
+
href="<?php echo add_query_arg(array('term' => 'gmedia_tag'), $url); ?>"><?php _e('Tags', 'gmLang'); ?></a>
|
575 |
+
<a class="btn btn<?php echo ('gmedia_category' == $taxonomy)? "-primary active" : '-default'; ?>"
|
576 |
+
href="<?php echo add_query_arg(array('term' => 'gmedia_category'), $url); ?>"><?php _e('Categories', 'gmLang'); ?></a>
|
577 |
</div>
|
578 |
|
579 |
</div>
|
583 |
<div class="col-xs-7 col-md-9" style="padding: 0">
|
584 |
<div class="list-group" id="gm-list-table" style="margin-bottom:4px;">
|
585 |
<?php
|
586 |
+
if(count($gmediaTerms)){
|
587 |
+
$author = $gmCore->caps['gmedia_show_others_media']? 0 : $user_ID;
|
588 |
$allow_edit = $gmCore->caps['gmedia_edit_others_media'];
|
589 |
$gmediaCategories = $gmGallery->options['taxonomies']['gmedia_category'];
|
590 |
+
foreach($gmediaTerms as $item){
|
591 |
$author_name = $owner = '';
|
592 |
$list_row_class = $row_class = '';
|
593 |
$termItems = array();
|
594 |
+
$per_page = 10;
|
595 |
$item_name = $item->name;
|
596 |
+
if('gmedia_album' == $taxonomy){
|
597 |
+
if($item->global){
|
598 |
+
$owner = get_the_author_meta('display_name', $item->global);
|
599 |
+
$author_name .= sprintf(__('by %s', 'gmLang'), $owner);
|
600 |
+
if($item->global == $user_ID){
|
|
|
601 |
$row_class .= ' current_user';
|
602 |
$allow_edit = $gmCore->caps['gmedia_album_manage'];
|
603 |
+
} else{
|
604 |
$row_class .= ' other_user';
|
605 |
$allow_edit = $gmCore->caps['gmedia_edit_others_media'];
|
606 |
}
|
607 |
+
} else{
|
608 |
$owner = '—';
|
609 |
+
$author_name .= '(' . __('shared', 'gmLang') . ')';
|
610 |
$row_class .= ' shared';
|
611 |
$allow_edit = $gmCore->caps['gmedia_edit_others_media'];
|
612 |
}
|
613 |
+
if('public' != $item->status){
|
614 |
$author_name .= ' [' . $item->status . ']';
|
615 |
+
if('private' == $item->status){
|
616 |
$list_row_class = ' list-group-item-info';
|
617 |
+
} elseif('draft' == $item->status){
|
618 |
//$list_row_class = ' list-group-item-warning';
|
619 |
continue;
|
620 |
}
|
621 |
}
|
622 |
+
} elseif('gmedia_category' == $taxonomy){
|
|
|
|
|
|
|
|
|
|
|
623 |
$item_name = $gmediaCategories[$item_name];
|
624 |
$allow_edit = false;
|
625 |
}
|
626 |
|
627 |
+
if($item->count){
|
628 |
+
if('gmedia_album' == $taxonomy){
|
629 |
+
$term_meta = $gmDB->get_metadata('gmedia_term', $item->term_id);
|
630 |
+
$term_meta = array_map('reset', $term_meta);
|
631 |
+
$term_meta = array_merge(array('orderby' => 'ID', 'order' => 'DESC'), $term_meta);
|
632 |
+
$args = array('no_found_rows' => true, 'per_page' => $per_page, 'album__in' => array($item->term_id), 'author' => $author, 'orderby' => $term_meta['orderby'], 'order' => $term_meta['order']);
|
633 |
+
} elseif('gmedia_tag' == $taxonomy){
|
634 |
+
$args = array(
|
635 |
+
'no_found_rows' => true,
|
636 |
+
'per_page' => $per_page,
|
637 |
+
'tag_id' => $item->term_id,
|
638 |
+
'author' => $author,
|
639 |
+
'orderby' => $gmGallery->options['in_tag_orderby'],
|
640 |
+
'order' => $gmGallery->options['in_tag_order']
|
641 |
+
);
|
642 |
+
} elseif('gmedia_category' == $taxonomy){
|
643 |
+
$args = array(
|
644 |
+
'no_found_rows' => true,
|
645 |
+
'per_page' => $per_page,
|
646 |
+
'category__in' => $item->term_id,
|
647 |
+
'author' => $author,
|
648 |
+
'orderby' => $gmGallery->options['in_category_orderby'],
|
649 |
+
'order' => $gmGallery->options['in_category_order']
|
650 |
+
);
|
651 |
+
}
|
652 |
+
$termItems = $gmDB->get_gmedias($args);
|
653 |
}
|
654 |
?>
|
655 |
+
<div class="list-group-item term-list-item d-row<?php echo $list_row_class; ?>">
|
656 |
<div class="row<?php echo $row_class; ?>">
|
657 |
<div class="term_id">#<?php echo $item->term_id; ?></div>
|
658 |
<div class="col-xs-5 term-label">
|
659 |
<div class="no-checkbox">
|
660 |
+
<strong class="term_name"><?php echo esc_html($item_name); ?></strong>
|
661 |
<span class="term_info_author"><?php echo $author_name; ?></span>
|
662 |
<span class="badge pull-right"><?php echo $item->count; ?></span>
|
663 |
</div>
|
664 |
</div>
|
665 |
<div class="col-xs-7">
|
666 |
<div class="term-images">
|
667 |
+
<?php if(!empty($termItems)){
|
668 |
+
foreach($termItems as $i){
|
669 |
?>
|
670 |
<img style="z-index:<?php echo $per_page --; ?>;"
|
671 |
+
src="<?php echo $gmCore->gm_get_media_image($i, 'thumb', false); ?>"
|
672 |
alt="<?php echo $i->ID; ?>"
|
673 |
+
title="<?php echo esc_attr($i->title); ?>"/>
|
674 |
<?php
|
675 |
}
|
676 |
}
|
677 |
+
if(count($termItems) < $item->count){
|
678 |
echo '...';
|
679 |
}
|
680 |
?>
|
697 |
'gmedia_category' => 'cat'
|
698 |
);
|
699 |
?>
|
700 |
+
<input type="hidden" name="taxonomy" value="<?php echo $taxonomy; ?>"/>
|
701 |
+
<input type="hidden" name="term_id" value="<?php echo $item->term_id; ?>"/>
|
702 |
<p><strong><?php echo $tax_name[$taxonomy]; ?>:</strong> <?php echo esc_html($item_name); ?>
|
703 |
+
<br/><strong><?php _e('ID', 'gmLang'); ?>:</strong> <?php echo $item->term_id; ?>
|
704 |
<?php if('gmedia_album' == $taxonomy){
|
705 |
$orderby = array(
|
706 |
'custom' => __('user defined', 'gmLang'),
|
707 |
+
'ID' => __('by ID', 'gmLang'),
|
708 |
'title' => __('by title', 'gmLang'),
|
709 |
'date' => __('by date', 'gmLang'),
|
710 |
'modified' => __('by last modified date', 'gmLang'),
|
711 |
'rand' => __('Random', 'gmLang')
|
712 |
); ?>
|
713 |
+
<br/><strong><?php _e('Order', 'gmLang'); ?>:</strong> <?php echo $orderby[$term_meta['orderby']]; ?>
|
714 |
+
<br/><strong><?php _e('Sort order', 'gmLang'); ?>:</strong> <?php echo $term_meta['order']; ?>
|
715 |
+
<br/><strong><?php _e('Status', 'gmLang'); ?>:</strong> <?php echo $item->status; ?>
|
716 |
+
<br/><strong><?php _e('Author', 'gmLang'); ?>:</strong> <?php echo $owner; ?>
|
717 |
<?php } ?>
|
718 |
</p>
|
719 |
<p>
|
720 |
<a href="<?php echo add_query_arg(array('page' => 'GrandMedia', $lib_arg[$taxonomy] => $item->term_id), admin_url('admin.php')); ?>" target="_blank"><?php _e('Open in Gmedia Library', 'gmLang'); ?></a>
|
721 |
<?php if(('gmedia_album' == $taxonomy) && $allow_edit){ ?>
|
722 |
+
| <a href="<?php echo add_query_arg(array(
|
723 |
+
'page' => 'GrandMedia_Terms',
|
724 |
+
'edit_album' => $item->term_id
|
725 |
+
), admin_url('admin.php')); ?>" target="_blank"><?php _e('Edit Album', 'gmLang'); ?></a>
|
726 |
<?php } ?>
|
727 |
</p>
|
728 |
</div>
|
729 |
+
<?php if(!empty($item->description)){ ?>
|
730 |
+
<div class="term-description"><?php echo nl2br(esc_html($item->description)); ?></div>
|
731 |
<?php } ?>
|
732 |
</div>
|
733 |
<?php
|
734 |
}
|
735 |
+
} else{
|
736 |
?>
|
737 |
<div class="list-group-item">
|
738 |
<div class="well well-lg text-center">
|
739 |
+
<h4><?php _e('No items to show.', 'gmLang'); ?></h4>
|
740 |
</div>
|
741 |
</div>
|
742 |
<?php } ?>
|
746 |
<form method="post" id="gmedia-form" role="form">
|
747 |
<div class="media-upload-form-container">
|
748 |
<div class="form-group">
|
749 |
+
<label><?php _e('Choose module/preset', 'gmLang'); ?></label>
|
750 |
<select class="form-control input-sm" id="module_preset" name="module_preset" required="required">
|
751 |
<option value=""><?php _e('Choose module/preset', 'gmLang'); ?></option>
|
752 |
+
<?php foreach($modules as $mfold => $module){
|
753 |
echo '<optgroup label="' . esc_attr($module['module_title']) . '">';
|
754 |
+
$presets = $gmDB->get_terms('gmedia_module', array('global' => $user_ID, 'status' => $mfold));
|
755 |
$option = array();
|
756 |
+
$option['default'] = '<option value="' . esc_attr($mfold) . '">' . '[' . $mfold . '] ' . __('Default Settings') . '</option>';
|
757 |
+
foreach($presets as $preset){
|
758 |
+
if('[' . $mfold . ']' == $preset->name){
|
759 |
+
$option['default'] = '<option value="' . $preset->term_id . '">' . '[' . $mfold . '] ' . __('Default Settings') . '</option>';
|
760 |
+
} else{
|
761 |
$option[] = '<option value="' . $preset->term_id . '">' . $preset->name . '</option>';
|
762 |
}
|
763 |
}
|
770 |
</div>
|
771 |
<div class="panel-footer">
|
772 |
<input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>"/>
|
773 |
+
<?php wp_nonce_field('media-form'); ?>
|
774 |
+
<button type="submit" id="media-upload-form-submit" disabled class="btn btn-primary pull-right" name="gmedia_term_insert"><?php _e('Insert into post', 'gmLang'); ?></button>
|
775 |
</div>
|
776 |
</form>
|
777 |
</div>
|
778 |
</div>
|
779 |
</div>
|
780 |
<script type="text/javascript">
|
781 |
+
jQuery(function($){
|
782 |
+
function divFrame(){
|
783 |
$('.panel-body').css({top: $('.panel-heading').outerHeight()});
|
784 |
}
|
785 |
|
786 |
divFrame();
|
787 |
+
$(window).on('resize', function(){
|
788 |
divFrame();
|
789 |
});
|
790 |
+
$('.term-list-item').on('click', function(){
|
791 |
+
$(this).addClass('active-row').siblings().removeClass('active-row');
|
792 |
var info = $('.term-info', this).clone();
|
793 |
$('#media-upload-form-container').html(info.html());
|
794 |
+
if($('#module_preset').val()){
|
795 |
$('#media-upload-form-submit').prop('disabled', false);
|
796 |
}
|
797 |
});
|
809 |
}
|
810 |
|
811 |
|
812 |
+
function gmedia_add_media_library(){
|
813 |
|
814 |
global $user_ID, $gmCore, $gmDB, $gmGallery;
|
815 |
|
816 |
+
wp_enqueue_style('gmedia-bootstrap');
|
817 |
+
wp_enqueue_script('gmedia-bootstrap');
|
818 |
|
819 |
+
wp_enqueue_style('grand-media');
|
820 |
+
wp_enqueue_script('grand-media');
|
821 |
|
822 |
+
$post_id = intval($gmCore->_get('post_id'));
|
823 |
|
824 |
+
if(current_user_can('gmedia_show_others_media')){
|
825 |
$author = 0;
|
826 |
+
} else{
|
827 |
$author = $user_ID;
|
828 |
}
|
829 |
+
$args = array(
|
830 |
+
'mime_type' => $gmCore->_get('mime_type', 'image/*'),
|
831 |
+
'author' => $author,
|
832 |
+
'orderby' => 'ID',
|
833 |
+
'order' => 'DESC',
|
834 |
+
'per_page' => 50,
|
835 |
+
'page' => $gmCore->_get('pager', 1),
|
836 |
+
's' => $gmCore->_get('s', null)
|
837 |
);
|
838 |
+
$gmediaQuery = $gmDB->get_gmedias($args);
|
839 |
|
840 |
|
841 |
?>
|
844 |
<div class="panel-heading clearfix">
|
845 |
<form class="form-inline gmedia-search-form" role="search">
|
846 |
<div class="form-group">
|
847 |
+
<?php foreach($_GET as $key => $value){
|
848 |
+
if(in_array($key, array('chromeless', 'post_id', 'tab', 'mime_type', 'tag_id', 'tag__in', 'cat', 'category__in', 'alb', 'album__in'))){
|
849 |
?>
|
850 |
<input type="hidden" name="<?php echo $key; ?>" value="<?php echo $value; ?>"/>
|
851 |
<?php
|
852 |
}
|
853 |
} ?>
|
854 |
+
<input id="gmedia-search" class="form-control input-sm" type="text" name="s" placeholder="<?php _e('Search...', 'gmLang'); ?>" value="<?php echo $gmCore->_get('s', ''); ?>"/>
|
855 |
</div>
|
856 |
<button type="submit" class="btn btn-default input-sm"><span class="glyphicon glyphicon-search"></span></button>
|
857 |
</form>
|
862 |
<div class="row">
|
863 |
<div class="col-xs-7 col-md-9" style="text-align:justify;">
|
864 |
<?php
|
865 |
+
if(count($gmediaQuery)){
|
866 |
+
foreach($gmediaQuery as $item){
|
867 |
+
$meta = $gmDB->get_metadata('gmedia', $item->ID);
|
868 |
+
$type = explode('/', $item->mime_type);
|
869 |
|
870 |
/*
|
871 |
$item_url = $gmCore->upload['url'] . '/' . $gmGallery->options['folder'][$type[0]] . '/' . $item->gmuid;
|
885 |
*/
|
886 |
?>
|
887 |
<form class="thumbnail" id="list-item-<?php echo $item->ID; ?>" data-id="<?php echo $item->ID; ?>" data-type="<?php echo $type[0]; ?>">
|
888 |
+
<img src="<?php echo $gmCore->gm_get_media_image($item, 'thumb'); ?>" style="height:100px;width:auto;" alt=""/>
|
889 |
<span class="glyphicon glyphicon-ok text-success"></span>
|
890 |
|
891 |
<div class="media-upload-form" style="display:none;">
|
892 |
<input name="ID" type="hidden" value="<?php echo $item->ID; ?>"/>
|
893 |
|
894 |
<div class="form-group">
|
895 |
+
<label><?php _e('Title', 'gmLang'); ?></label>
|
896 |
+
<input name="title" type="text" class="form-control input-sm" placeholder="<?php _e('Title', 'gmLang'); ?>" value="<?php echo esc_attr($item->title); ?>">
|
897 |
</div>
|
898 |
<div class="form-group">
|
899 |
+
<label><?php _e('Link To', 'gmLang'); ?></label>
|
900 |
<select id="gmedia_url" class="form-control input-sm" style="display:block;margin-bottom:5px;">
|
901 |
+
<option value="customurl" selected="selected"><?php _e('Custom URL'); ?></option>
|
902 |
+
<option value="weburl"><?php _e('Web size image'); ?></option>
|
903 |
+
<option value="originalurl"><?php _e('Original image'); ?></option>
|
904 |
</select>
|
905 |
<input name="link" type="text" class="customurl form-control input-sm" value="<?php echo $item->link; ?>" placeholder="http://"/>
|
906 |
<input name="link" type="text" style="display:none;font-size:80%;" readonly="readonly" disabled="disabled" class="weburl form-control input-sm" value="<?php echo $gmCore->upload['url'] . '/' . $gmGallery->options['folder']['image'] . '/' . $item->gmuid; ?>"/>
|
907 |
<input name="link" type="text" style="display:none;font-size:80%;" readonly="readonly" disabled="disabled" class="originalurl form-control input-sm" value="<?php echo $gmCore->upload['url'] . '/' . $gmGallery->options['folder']['image_original'] . '/' . $item->gmuid; ?>"/>
|
908 |
</div>
|
909 |
<div class="form-group">
|
910 |
+
<label><?php _e('Description', 'gmLang'); ?></label>
|
911 |
+
<textarea name="description" class="form-control input-sm" rows="4" cols="10"><?php echo esc_html($item->description); ?></textarea>
|
912 |
</div>
|
913 |
<?php //if($is_webimage){ ?>
|
914 |
+
<?php if('image' == $type[0]){
|
915 |
+
$_metadata = unserialize($meta['_metadata'][0]); ?>
|
916 |
<div class="form-group">
|
917 |
+
<label><?php _e('Size', 'gmLang'); ?></label>
|
918 |
<select name="size" class="form-control input-sm">
|
919 |
<option value="thumb"><?php echo 'Thumb - ' . $_metadata['thumb']['width'] . ' × ' . $_metadata['thumb']['height']; ?></option>
|
920 |
<option value="web" selected="selected"><?php echo 'Web - ' . $_metadata['web']['width'] . ' × ' . $_metadata['web']['height']; ?></option>
|
924 |
<?php } ?>
|
925 |
<?php //} ?>
|
926 |
<div class="form-group">
|
927 |
+
<label><?php _e('Alignment', 'gmLang'); ?></label>
|
928 |
<select name="align" class="form-control input-sm">
|
929 |
+
<option value="none" selected="selected"><?php _e('None', 'gmLang'); ?></option>
|
930 |
+
<option value="left"><?php _e('Left', 'gmLang'); ?></option>
|
931 |
+
<option value="center"><?php _e('Center', 'gmLang'); ?></option>
|
932 |
+
<option value="right"><?php _e('Right', 'gmLang'); ?></option>
|
933 |
</select>
|
934 |
</div>
|
935 |
</div>
|
936 |
</form>
|
937 |
<?php
|
938 |
}
|
939 |
+
} else{
|
940 |
?>
|
941 |
<div class="list-group-item">
|
942 |
<div class="well well-lg text-center">
|
943 |
+
<h4><?php _e('No items to show.', 'gmLang'); ?></h4>
|
944 |
+
<?php if($gmCore->caps['gmedia_upload']){ ?>
|
945 |
<p>
|
946 |
+
<a target="_blank" href="<?php echo admin_url('admin.php?page=GrandMedia_AddMedia') ?>" class="btn btn-success"><span class="glyphicon glyphicon-plus"></span> <?php _e('Add Media', 'gmLang'); ?>
|
947 |
</a></p>
|
948 |
<?php } ?>
|
949 |
</div>
|
955 |
<div id="media-upload-form-container" class="media-upload-form-container"></div>
|
956 |
<div class="panel-footer">
|
957 |
<input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>"/>
|
958 |
+
<?php wp_nonce_field('media-form'); ?>
|
959 |
+
<button type="submit" id="media-upload-form-submit" disabled class="btn btn-primary pull-right" name="gmedia_library_insert"><?php _e('Insert into post', 'gmLang'); ?></button>
|
960 |
+
<?php if($post_id && current_theme_supports('post-thumbnails', get_post_type($post_id))){ ?>
|
961 |
+
<a id="gmedia-post-thumbnail" class="btn disabled" href="javascript:void(0);"><?php _e('Use as featured image', 'gmLang'); ?></a>
|
962 |
<?php } ?>
|
963 |
</div>
|
964 |
</form>
|
966 |
</div>
|
967 |
</div>
|
968 |
<script type="text/javascript">
|
969 |
+
jQuery(function($){
|
970 |
+
function divFrame(){
|
971 |
$('.panel-body').css({top: $('.panel-heading').outerHeight()});
|
972 |
}
|
973 |
|
974 |
divFrame();
|
975 |
+
$(window).on('resize', function(){
|
976 |
divFrame();
|
977 |
});
|
978 |
+
$('.thumbnail').on('click', function(){
|
979 |
var form = $('#media-upload-form-container');
|
980 |
var but = $('.panel-footer .btn');
|
981 |
+
if($(this).hasClass('active')){
|
982 |
$(this).removeClass('active');
|
983 |
form.empty();
|
984 |
but.prop('disabled', true).addClass('disabled');
|
988 |
form.html($('.media-upload-form', this).html());
|
989 |
but.prop('disabled', false).removeClass('disabled');
|
990 |
});
|
991 |
+
$('#gmedia-form').on('change', '#gmedia_url', function(){
|
992 |
var val = $(this).val();
|
993 |
$(this).nextAll('input.' + val).show().prop('disabled', false).siblings('input').hide().prop('disabled', true);
|
994 |
});
|
998 |
$featured_nonce = wp_create_nonce( "set_post_thumbnail-$post_id" );
|
999 |
?>
|
1000 |
|
1001 |
+
$('#gmedia-post-thumbnail').on('click', function(){
|
1002 |
+
if($(this).hasClass('disabled')){
|
1003 |
return false;
|
1004 |
}
|
1005 |
var id = $('form.active').data('id');
|
1006 |
$.post(ajaxurl, {
|
1007 |
action: "gmedia_set_post_thumbnail", post_id: '<?php echo $post_id; ?>', img_id: id, _wpnonce: '<?php echo $featured_nonce; ?>'
|
1008 |
+
}, function(str){
|
1009 |
var win = window.dialogArguments || opener || parent || top;
|
1010 |
+
if(str == '0'){
|
1011 |
alert(win.setPostThumbnailL10n.error);
|
1012 |
+
} else if(str == '-1'){
|
1013 |
// image removed
|
1014 |
+
} else{
|
1015 |
win.WPSetThumbnailID(id);
|
1016 |
win.WPSetThumbnailHTML(str);
|
1017 |
}
|
1027 |
<?php
|
1028 |
}
|
1029 |
|
1030 |
+
function gmedia_add_media_upload(){
|
1031 |
|
1032 |
global $gmCore, $gmDB, $gmProcessor, $gmGallery, $user_ID;
|
1033 |
|
1034 |
+
if(!current_user_can('gmedia_upload')){
|
1035 |
+
_e('You do not have permissions to upload media', 'gmLang');
|
1036 |
|
1037 |
return;
|
1038 |
}
|
1039 |
|
1040 |
+
$maxupsize = wp_max_upload_size();
|
1041 |
+
$maxupsize = floor($maxupsize * 0.99);
|
1042 |
+
$maxupsize_mb = floor($maxupsize / 1024 / 1024);
|
1043 |
|
1044 |
$gm_screen_options = $gmProcessor->user_options();
|
1045 |
|
1046 |
?>
|
1047 |
<div class="panel panel-default">
|
1048 |
+
<div class="panel-body" style="top:0">
|
1049 |
+
<form class="row" id="gmUpload" name="upload_form" method="POST" accept-charset="utf-8" onsubmit="return false;">
|
1050 |
+
<div class="col-md-8 col-md-push-4" id="pluploadUploader" style="padding: 0;">
|
1051 |
+
<p><?php _e("You browser doesn't have Flash or HTML5 support. Check also if page have no JavaScript errors.", 'gmLang'); ?></p>
|
1052 |
+
<?php
|
1053 |
+
$mime_types = get_allowed_mime_types($user_ID);
|
1054 |
+
$type_ext = array();
|
1055 |
+
$filters = array();
|
1056 |
+
foreach($mime_types as $ext => $mime){
|
1057 |
+
$type = strtok($mime, '/');
|
1058 |
+
$type_ext[$type][] = $ext;
|
1059 |
+
}
|
1060 |
+
foreach($type_ext as $filter => $ext){
|
1061 |
+
$filters[] = array(
|
1062 |
+
'title' => $filter,
|
1063 |
+
'extensions' => str_replace('|', ',', implode(',', $ext))
|
1064 |
+
);
|
1065 |
+
}
|
1066 |
+
?>
|
1067 |
+
<script type="text/javascript">
|
1068 |
+
// Convert divs to queue widgets when the DOM is ready
|
1069 |
+
jQuery(function($){
|
1070 |
+
$("#pluploadUploader").plupload({
|
1071 |
+
<?php if('auto' != $gm_screen_options['uploader_runtime']){ ?>
|
1072 |
+
runtimes: '<?php echo $gm_screen_options['uploader_runtime']; ?>',
|
1073 |
+
<?php } ?>
|
1074 |
+
url: '<?php echo admin_url( 'admin-ajax.php' ); ?>',
|
1075 |
+
<?php if(('true' == $gm_screen_options['uploader_urlstream_upload']) && ('html4' != $gm_screen_options['uploader_runtime'])){ ?>
|
1076 |
+
urlstream_upload: true,
|
1077 |
+
multipart: false,
|
1078 |
+
<?php } else{ ?>
|
1079 |
+
multipart: true,
|
1080 |
+
<?php } ?>
|
1081 |
+
multipart_params: {action: 'gmedia_upload_handler', _ajax_nonce: '<?php echo wp_create_nonce('GmediaUpload'); ?>', params: ''},
|
1082 |
+
<?php if('true' == $gm_screen_options['uploader_chunking'] && ('html4' != $gm_screen_options['uploader_runtime'])){ ?>
|
1083 |
+
max_file_size: '2000Mb',
|
1084 |
+
chunk_size: 200000<?php //echo min($maxupsize, $gm_screen_options['uploader_chunk_size']*1024*1024); ?>,
|
1085 |
+
<?php } else{ ?>
|
1086 |
+
max_file_size: <?php echo $maxupsize; ?>,
|
1087 |
+
<?php } ?>
|
1088 |
+
max_retries: 2,
|
1089 |
+
unique_names: false,
|
1090 |
+
rename: true,
|
1091 |
+
sortable: true,
|
1092 |
+
dragdrop: true,
|
1093 |
+
views: {
|
1094 |
+
list: true,
|
1095 |
+
thumbs: true,
|
1096 |
+
active: 'thumbs'
|
1097 |
+
},
|
1098 |
+
filters: <?php echo json_encode($filters); ?>,
|
1099 |
+
flash_swf_url: '<?php echo $gmCore->gmedia_url; ?>/assets/plupload/Moxie.swf',
|
1100 |
+
silverlight_xap_url: '<?php echo $gmCore->gmedia_url; ?>/assets/plupload/Moxie.xap'
|
1101 |
+
|
1102 |
+
});
|
1103 |
+
var closebtn = '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>';
|
1104 |
+
var uploader = $("#pluploadUploader").plupload('getUploader');
|
1105 |
+
uploader.bind('StateChanged', function(up){
|
1106 |
+
if(up.state == plupload.STARTED){
|
1107 |
+
up.settings.multipart_params.params = jQuery('#uploader_multipart_params :input').serialize();
|
1108 |
+
}
|
1109 |
+
console.log('[StateChanged]', up.state, up.settings.multipart_params);
|
1110 |
+
});
|
1111 |
+
uploader.bind('ChunkUploaded', function(up, file, info){
|
1112 |
+
console.log('[ChunkUploaded] File:', file, "Info:", info);
|
1113 |
+
var response = $.parseJSON(info.response);
|
1114 |
+
if(response && response.error){
|
1115 |
+
up.stop();
|
1116 |
+
file.status = plupload.FAILED;
|
1117 |
+
$('<div/>').addClass('alert alert-danger alert-dismissable').html(closebtn + '<strong>' + response.id + ':</strong> ' + response.error.message).appendTo('#gmedia-msg-panel');
|
1118 |
+
console.log(response.error);
|
1119 |
+
up.trigger('QueueChanged StateChanged');
|
1120 |
+
up.trigger('UploadProgress', file);
|
1121 |
+
up.start();
|
1122 |
+
}
|
1123 |
+
});
|
1124 |
+
uploader.bind('FileUploaded', function(up, file, info){
|
1125 |
+
console.log('[FileUploaded] File:', file, "Info:", info);
|
1126 |
+
var response = jQuery.parseJSON(info.response);
|
1127 |
+
if(response && response.error){
|
1128 |
+
file.status = plupload.FAILED;
|
1129 |
+
$('<div/>').addClass('alert alert-danger alert-dismissable').html(closebtn + '<strong>' + response.id + ':</strong> ' + response.error.message).appendTo('#gmedia-msg-panel');
|
1130 |
+
console.log(response.error);
|
1131 |
+
}
|
1132 |
+
});
|
1133 |
+
uploader.bind('UploadProgress', function(up, file){
|
1134 |
+
var percent = uploader.total.percent;
|
1135 |
+
$('#total-progress-info .progress-bar').css('width', percent + "%").attr('aria-valuenow', percent);
|
1136 |
+
});
|
1137 |
+
uploader.bind('Error', function(up, args){
|
1138 |
+
console.log('[Error] ', args);
|
1139 |
+
$('<div/>').addClass('alert alert-danger alert-dismissable').html(closebtn + '<strong>' + args.file.name + ':</strong> ' + args.message + ' ' + args.status).appendTo('#gmedia-msg-panel');
|
1140 |
+
});
|
1141 |
+
uploader.bind('UploadComplete', function(up, files){
|
1142 |
+
console.log('[UploadComplete]', files);
|
1143 |
+
$('<div/>').addClass('alert alert-success alert-dismissable').html(closebtn + "<?php echo esc_attr(__('Upload finished', 'gmLang')); ?>").appendTo('#gmedia-msg-panel');
|
1144 |
+
$('#total-progress-info .progress-bar').css('width', '0').attr('aria-valuenow', '0');
|
1145 |
+
});
|
1146 |
+
|
1147 |
+
});
|
1148 |
+
</script>
|
1149 |
+
</div>
|
1150 |
+
<div class="col-md-4 col-md-pull-8" id="uploader_multipart_params">
|
1151 |
+
<div id="gmedia-msg-panel"></div>
|
1152 |
+
<br/>
|
1153 |
+
<?php if('false' == $gm_screen_options['uploader_chunking'] || ('html4' == $gm_screen_options['uploader_runtime'])){ ?>
|
1154 |
+
<p class="clearfix text-right"><span class="label label-default"><?php echo __('Maximum file size', 'gmLang') . ": {$maxupsize_mb}Mb"; ?></span></p>
|
1155 |
+
<?php } else{ ?>
|
1156 |
+
<p class="clearfix text-right hidden">
|
1157 |
+
<span class="label label-default"><?php echo __('Maximum $_POST size', 'gmLang') . ": {$maxupsize_mb}Mb"; ?></span>
|
1158 |
+
<span class="label label-default"><?php echo __('Chunk size', 'gmLang') . ': ' . min($maxupsize_mb, $gm_screen_options['uploader_chunk_size']) . 'Mb'; ?></span>
|
1159 |
+
</p>
|
1160 |
+
<?php } ?>
|
1161 |
|
1162 |
+
<div class="form-group">
|
1163 |
+
<label><?php _e('Title', 'gmLang'); ?></label>
|
1164 |
+
<select name="set_title" class="form-control input-sm">
|
1165 |
+
<option value="exif"><?php _e('EXIF or File Name', 'gmLang'); ?></option>
|
1166 |
+
<option value="filename"><?php _e('File Name', 'gmLang'); ?></option>
|
1167 |
+
<option value="empty"><?php _e('Empty', 'gmLang'); ?></option>
|
1168 |
+
</select>
|
1169 |
+
</div>
|
1170 |
+
<div class="form-group">
|
1171 |
+
<label><?php _e('Status', 'gmLang'); ?></label>
|
1172 |
+
<select name="set_status" class="form-control input-sm">
|
1173 |
+
<option value="inherit"><?php _e('Same as Album or Public', 'gmLang'); ?></option>
|
1174 |
+
<option value="public"><?php _e('Public', 'gmLang'); ?></option>
|
1175 |
+
<option value="private"><?php _e('Private', 'gmLang'); ?></option>
|
1176 |
+
<option value="draft"><?php _e('Draft', 'gmLang'); ?></option>
|
1177 |
+
</select>
|
1178 |
+
</div>
|
1179 |
|
1180 |
+
<hr/>
|
|
|
|
|
|
|
|
|
1181 |
|
1182 |
+
<?php if($gmCore->caps['gmedia_terms']){ ?>
|
1183 |
+
<div class="form-group">
|
1184 |
+
<?php
|
1185 |
+
$term_type = 'gmedia_category';
|
1186 |
+
$gm_terms = $gmGallery->options['taxonomies'][$term_type];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1187 |
|
1188 |
+
$terms_category = '';
|
1189 |
+
if(count($gm_terms)){
|
1190 |
+
foreach($gm_terms as $term_name => $term_title){
|
1191 |
+
$terms_category .= '<option value="' . $term_name . '">' . esc_html($term_title) . '</option>' . "\n";
|
1192 |
+
}
|
1193 |
+
}
|
1194 |
+
?>
|
1195 |
+
<label><?php _e('Assign Category', 'gmLang'); ?>
|
1196 |
+
<small><?php _e('(for images only)') ?></small>
|
1197 |
+
</label>
|
1198 |
+
<select id="gmedia_category" name="terms[gmedia_category]" class="form-control input-sm">
|
1199 |
+
<option value=""><?php _e('Uncategorized', 'gmLang'); ?></option>
|
1200 |
+
<?php echo $terms_category; ?>
|
1201 |
+
</select>
|
1202 |
+
</div>
|
1203 |
+
<div class="form-group">
|
1204 |
+
<?php
|
1205 |
+
$term_type = 'gmedia_album';
|
1206 |
+
$gm_terms = $gmDB->get_terms($term_type, array('global' => array(0, $user_ID), 'orderby' => 'global_desc_name'));
|
|
|
|
|
|
|
|
|
|
|
1207 |
|
1208 |
+
$terms_album = '';
|
1209 |
+
if(count($gm_terms)){
|
1210 |
+
foreach($gm_terms as $term){
|
1211 |
+
$terms_album .= '<option value="' . esc_attr($term->term_id) . '">' . esc_html($term->name) . ($term->global? '' : __(' (shared)', 'gmLang')) . ('public' == $term->status? '' : " [{$term->status}]") . '</option>' . "\n";
|
1212 |
+
}
|
1213 |
+
}
|
1214 |
+
?>
|
1215 |
+
<label><?php _e('Add to Album', 'gmLang'); ?> </label>
|
1216 |
+
<select id="combobox_gmedia_album" name="terms[gmedia_album]" class="form-control input-sm" placeholder="<?php _e('Album Name...', 'gmLang'); ?>">
|
1217 |
+
<option value=""></option>
|
1218 |
+
<?php echo $terms_album; ?>
|
1219 |
+
</select>
|
1220 |
+
</div>
|
1221 |
+
<div class="form-group">
|
1222 |
+
<?php
|
1223 |
+
$term_type = 'gmedia_tag';
|
1224 |
+
$gm_terms = $gmDB->get_terms($term_type, array('fields' => 'names'));
|
1225 |
+
?>
|
1226 |
+
<label><?php _e('Add Tags', 'gmLang'); ?> </label>
|
1227 |
+
<input id="combobox_gmedia_tag" name="terms[gmedia_tag]" class="form-control input-sm" value="" placeholder="<?php _e('Add Tags...', 'gmLang'); ?>"/>
|
1228 |
+
</div>
|
1229 |
+
<div class="addtags-gap"> </div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1230 |
<?php } else{ ?>
|
1231 |
+
<p><?php _e('You are not allowed to assign terms', 'gmLang') ?></p>
|
1232 |
<?php } ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1233 |
|
1234 |
+
<script type="text/javascript">
|
1235 |
+
jQuery(function($){
|
1236 |
+
<?php if($gmCore->caps['gmedia_terms']){ ?>
|
1237 |
+
$('#combobox_gmedia_album').selectize({
|
1238 |
+
<?php if($gmCore->caps['gmedia_album_manage']){ ?>
|
1239 |
+
create: true,
|
1240 |
+
createOnBlur: true,
|
1241 |
+
<?php } else{ ?>
|
1242 |
+
create: false,
|
1243 |
+
<?php } ?>
|
1244 |
+
persist: false
|
1245 |
+
});
|
1246 |
+
var gm_terms = <?php echo json_encode($gm_terms); ?>;
|
1247 |
+
var items = gm_terms.map(function(x){
|
1248 |
+
return {item: x};
|
1249 |
+
});
|
1250 |
+
$('#combobox_gmedia_tag').selectize({
|
1251 |
+
<?php if($gmCore->caps['gmedia_tag_manage']){ ?>
|
1252 |
+
create: function(input){
|
1253 |
+
return {
|
1254 |
+
item: input
|
1255 |
+
}
|
1256 |
+
},
|
1257 |
+
createOnBlur: true,
|
1258 |
+
<?php } else{ ?>
|
1259 |
+
create: false,
|
1260 |
+
<?php } ?>
|
1261 |
+
delimiter: ',',
|
1262 |
+
maxItems: null,
|
1263 |
+
openOnFocus: false,
|
1264 |
+
persist: false,
|
1265 |
+
options: items,
|
1266 |
+
labelField: 'item',
|
1267 |
+
valueField: 'item',
|
1268 |
+
searchField: ['item'],
|
1269 |
+
hideSelected: true
|
1270 |
+
});
|
1271 |
+
<?php } ?>
|
1272 |
+
$('#uploader_runtime select').change(function(){
|
1273 |
+
if('html4' == $(this).val()){
|
1274 |
+
$('#uploader_chunking').addClass('hide');
|
1275 |
+
$('#uploader_urlstream_upload').addClass('hide');
|
1276 |
+
} else{
|
1277 |
+
$('#uploader_chunking').removeClass('hide');
|
1278 |
+
$('#uploader_urlstream_upload').removeClass('hide');
|
1279 |
+
}
|
1280 |
+
});
|
1281 |
+
});
|
1282 |
+
</script>
|
1283 |
+
</div>
|
1284 |
+
</form>
|
1285 |
+
</div>
|
1286 |
</div>
|
1287 |
<?php
|
1288 |
}
|
inc/permalinks.php
CHANGED
@@ -8,7 +8,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
8 |
*/
|
9 |
class gmediaPermalinks {
|
10 |
|
11 |
-
private $endpoint;
|
12 |
|
13 |
/**
|
14 |
* __construct function.
|
@@ -17,9 +17,6 @@ class gmediaPermalinks {
|
|
17 |
* @return \gmediaPermalinks
|
18 |
*/
|
19 |
public function __construct() {
|
20 |
-
global $gmGallery;
|
21 |
-
$this->endpoint = ( isset( $gmGallery->options['endpoint'] ) && ( $endpoint = $gmGallery->options['endpoint'] ) ) ? $endpoint : 'gmedia';
|
22 |
-
|
23 |
add_filter( 'rewrite_rules_array', array( $this, 'add_rewrite_rules' ) );
|
24 |
add_filter( 'query_vars', array( $this, 'add_query_vars' ) );
|
25 |
add_action( 'parse_request', array( $this, 'handler' ) );
|
@@ -27,31 +24,20 @@ class gmediaPermalinks {
|
|
27 |
add_filter( 'post_thumbnail_html', array( $this, 'gmedia_post_thumbnail' ), 10, 5 );
|
28 |
}
|
29 |
|
30 |
-
/**
|
31 |
-
* add_endpoint function.
|
32 |
-
*
|
33 |
-
* @access public
|
34 |
-
* @return void
|
35 |
-
*/
|
36 |
-
public function add_endpoint() {
|
37 |
-
add_rewrite_endpoint( $this->endpoint, EP_NONE );
|
38 |
-
add_rewrite_endpoint( 'gmedia-app', EP_NONE );
|
39 |
-
//add_rewrite_rule('gmedia(/(gallery|single|album|tag|category))?/(.+?)/?$', 'index.php?gmedia=$matches[3]&type=$matches[2]', 'top');
|
40 |
-
}
|
41 |
-
|
42 |
/**
|
43 |
* @param $rules
|
44 |
*
|
45 |
* @return array
|
46 |
*/
|
47 |
function add_rewrite_rules( $rules ) {
|
48 |
-
global $wp_rewrite;
|
|
|
49 |
|
50 |
$this->add_endpoint();
|
51 |
|
52 |
$new_rules = array(
|
53 |
-
$this->endpoint . '
|
54 |
-
'gmedia-app/?$'
|
55 |
);
|
56 |
|
57 |
$new_rules = $new_rules + $rules;
|
@@ -59,6 +45,17 @@ class gmediaPermalinks {
|
|
59 |
return $new_rules;
|
60 |
}
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
/**
|
63 |
* add_query_vars function.
|
64 |
*
|
@@ -69,8 +66,13 @@ class gmediaPermalinks {
|
|
69 |
* @return array
|
70 |
*/
|
71 |
public function add_query_vars( $vars ) {
|
72 |
-
$
|
73 |
-
$
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
return $vars;
|
76 |
}
|
@@ -79,20 +81,14 @@ class gmediaPermalinks {
|
|
79 |
* Listen for gmedia requets and show gallery template.
|
80 |
*
|
81 |
* @access public
|
82 |
-
*
|
|
|
83 |
*/
|
84 |
-
public function handler() {
|
85 |
-
global $
|
86 |
-
|
87 |
-
if ( isset( $_GET['gmedia'] ) && ! empty( $_GET['gmedia'] ) ) {
|
88 |
-
$wp->query_vars['gmedia'] = $_GET['gmedia'];
|
89 |
-
}
|
90 |
-
|
91 |
-
if ( isset( $_GET['type'] ) && ! empty( $_GET['type'] ) ) {
|
92 |
-
$wp->query_vars['type'] = $_GET['type'];
|
93 |
-
}
|
94 |
|
95 |
-
if ( isset(
|
96 |
|
97 |
global $wp_query;
|
98 |
$wp_query->is_single = false;
|
@@ -101,21 +97,25 @@ class gmediaPermalinks {
|
|
101 |
$wp_query->is_search = false;
|
102 |
$wp_query->is_home = false;
|
103 |
|
|
|
104 |
$template = get_query_template( 'gmedia-gallery' );
|
105 |
// Get default slug-name.php
|
106 |
if ( ! $template ) {
|
107 |
-
$template = GMEDIA_ABSPATH . "/
|
108 |
}
|
109 |
|
110 |
load_template( $template, false );
|
|
|
|
|
|
|
|
|
111 |
exit();
|
112 |
|
113 |
}
|
114 |
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
if ( isset( $wp->query_vars['gmedia-app'] ) && ! empty( $wp->query_vars['gmedia-app'] ) ) {
|
119 |
|
120 |
global $wp_query;
|
121 |
$wp_query->is_single = false;
|
8 |
*/
|
9 |
class gmediaPermalinks {
|
10 |
|
11 |
+
private $endpoint = 'gmedia';
|
12 |
|
13 |
/**
|
14 |
* __construct function.
|
17 |
* @return \gmediaPermalinks
|
18 |
*/
|
19 |
public function __construct() {
|
|
|
|
|
|
|
20 |
add_filter( 'rewrite_rules_array', array( $this, 'add_rewrite_rules' ) );
|
21 |
add_filter( 'query_vars', array( $this, 'add_query_vars' ) );
|
22 |
add_action( 'parse_request', array( $this, 'handler' ) );
|
24 |
add_filter( 'post_thumbnail_html', array( $this, 'gmedia_post_thumbnail' ), 10, 5 );
|
25 |
}
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
/**
|
28 |
* @param $rules
|
29 |
*
|
30 |
* @return array
|
31 |
*/
|
32 |
function add_rewrite_rules( $rules ) {
|
33 |
+
global $wp_rewrite, $gmGallery;
|
34 |
+
$this->endpoint = !empty($gmGallery->options['endpoint'])? $gmGallery->options['endpoint'] : 'gmedia';
|
35 |
|
36 |
$this->add_endpoint();
|
37 |
|
38 |
$new_rules = array(
|
39 |
+
$this->endpoint . '/(g|s|a|t|k)/(.+?)/?$' => 'index.php?' . $this->endpoint . '=' . $wp_rewrite->preg_index( 2 ) . '&t=' . $wp_rewrite->preg_index( 1 ),
|
40 |
+
'gmedia-app/?$' => 'index.php?gmedia-app=1'
|
41 |
);
|
42 |
|
43 |
$new_rules = $new_rules + $rules;
|
45 |
return $new_rules;
|
46 |
}
|
47 |
|
48 |
+
/**
|
49 |
+
* add_endpoint function.
|
50 |
+
*
|
51 |
+
* @access public
|
52 |
+
* @return void
|
53 |
+
*/
|
54 |
+
public function add_endpoint() {
|
55 |
+
add_rewrite_endpoint( $this->endpoint, EP_NONE );
|
56 |
+
add_rewrite_endpoint( 'gmedia-app', EP_NONE );
|
57 |
+
}
|
58 |
+
|
59 |
/**
|
60 |
* add_query_vars function.
|
61 |
*
|
66 |
* @return array
|
67 |
*/
|
68 |
public function add_query_vars( $vars ) {
|
69 |
+
global $gmGallery;
|
70 |
+
$endpoint = !empty($gmGallery->options['endpoint'])? $gmGallery->options['endpoint'] : 'gmedia';
|
71 |
+
|
72 |
+
$vars[] = $endpoint;
|
73 |
+
$vars[] = 't';
|
74 |
+
|
75 |
+
$vars[] = 'gmedia-app';
|
76 |
|
77 |
return $vars;
|
78 |
}
|
81 |
* Listen for gmedia requets and show gallery template.
|
82 |
*
|
83 |
* @access public
|
84 |
+
*
|
85 |
+
* @param $wp - global variable
|
86 |
*/
|
87 |
+
public function handler($wp) {
|
88 |
+
global $gmGallery;
|
89 |
+
$endpoint = !empty($gmGallery->options['endpoint'])? $gmGallery->options['endpoint'] : 'gmedia';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
|
91 |
+
if ( isset($wp->query_vars[$endpoint]) ) {
|
92 |
|
93 |
global $wp_query;
|
94 |
$wp_query->is_single = false;
|
97 |
$wp_query->is_search = false;
|
98 |
$wp_query->is_home = false;
|
99 |
|
100 |
+
/*
|
101 |
$template = get_query_template( 'gmedia-gallery' );
|
102 |
// Get default slug-name.php
|
103 |
if ( ! $template ) {
|
104 |
+
$template = GMEDIA_ABSPATH . "/load-template.php";
|
105 |
}
|
106 |
|
107 |
load_template( $template, false );
|
108 |
+
*/
|
109 |
+
|
110 |
+
require_once(GMEDIA_ABSPATH . "/load-template.php");
|
111 |
+
|
112 |
exit();
|
113 |
|
114 |
}
|
115 |
|
116 |
+
/* Application only template */
|
117 |
+
$is_app = (isset($wp->query_vars['gmedia-app']) && !empty($wp->query_vars['gmedia-app']));
|
118 |
+
if ( $is_app ) {
|
|
|
119 |
|
120 |
global $wp_query;
|
121 |
$wp_query->is_single = false;
|
inc/shortcodes.php
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
<?php
|
2 |
-
if
|
3 |
-
die(
|
4 |
}
|
5 |
|
6 |
/** *********************** **/
|
7 |
/** Shortcodes Declarations **/
|
8 |
/** *********************** **/
|
9 |
-
add_shortcode(
|
10 |
-
add_shortcode(
|
11 |
|
12 |
//add_filter('the_content', 'do_shortcode');
|
13 |
-
add_filter(
|
14 |
|
15 |
/** ******************************* **/
|
16 |
/** Shortcodes Functions and Markup **/
|
@@ -23,7 +23,7 @@ $gmedia_shortcode_instance = array();
|
|
23 |
*
|
24 |
* @return string
|
25 |
*/
|
26 |
-
function gmedia_term_shortcode(
|
27 |
/**
|
28 |
* @var $album
|
29 |
* @var $tag
|
@@ -31,32 +31,32 @@ function gmedia_term_shortcode( $atts, $content = '' ) {
|
|
31 |
* @var $module
|
32 |
* @var $preset
|
33 |
*/
|
34 |
-
extract(
|
35 |
-
'album'
|
36 |
-
'tag'
|
37 |
'category' => 0,
|
38 |
-
'module'
|
39 |
-
'preset'
|
40 |
-
), $atts
|
41 |
-
if
|
42 |
$_tax = 'album';
|
43 |
-
$id
|
44 |
-
} elseif
|
45 |
$_tax = 'tag';
|
46 |
-
$id
|
47 |
-
} elseif
|
48 |
$_tax = 'category';
|
49 |
-
$id
|
50 |
-
} else
|
51 |
return '';
|
52 |
}
|
53 |
$sc_atts = array(
|
54 |
-
'id'
|
55 |
-
'
|
56 |
-
'preset'
|
57 |
-
'_tax'
|
58 |
);
|
59 |
-
$out
|
60 |
|
61 |
return $out;
|
62 |
}
|
@@ -67,178 +67,186 @@ function gmedia_term_shortcode( $atts, $content = '' ) {
|
|
67 |
*
|
68 |
* @return string
|
69 |
*/
|
70 |
-
function gmedia_shortcode(
|
71 |
global $gmDB, $gmGallery, $gmCore;
|
72 |
global $gmedia_shortcode_instance;
|
73 |
/**
|
74 |
* @var $id
|
75 |
-
* @var $
|
76 |
* @var $preset
|
77 |
* @var $_tax
|
78 |
* @var $_raw
|
79 |
*/
|
80 |
-
extract(
|
81 |
-
'id'
|
82 |
-
'
|
83 |
-
'preset'
|
84 |
-
'_tax'
|
85 |
-
'_raw'
|
86 |
-
), $atts
|
87 |
-
|
88 |
-
$shortcode_raw = (
|
89 |
-
if
|
90 |
-
return $gmedia_shortcode_instance['shortcode_raw'][
|
91 |
}
|
92 |
|
93 |
-
$id = intval(
|
94 |
-
if
|
95 |
return $content;
|
96 |
}
|
97 |
|
98 |
$_gallery = array(
|
99 |
-
'term_id'
|
100 |
-
'name'
|
101 |
'description' => '',
|
102 |
-
'status'
|
103 |
-
'edited'
|
104 |
-
'module'
|
105 |
-
'query'
|
106 |
-
'settings'
|
107 |
);
|
108 |
|
109 |
$taxonomy = 'gmedia_' . $_tax;
|
110 |
-
$gallery
|
111 |
-
if
|
112 |
return '<div class="gmedia_gallery gmediaShortcodeError">#' . $id . ': ' . $gallery->get_error_message() . '<br />' . $content . '</div>';
|
113 |
-
} elseif
|
114 |
-
return '<div class="gmedia_gallery gmediaShortcodeError">#' . $id . ': ' . sprintf(
|
115 |
-
} else
|
116 |
-
if
|
117 |
-
if
|
118 |
return '';
|
119 |
}
|
120 |
-
} else
|
121 |
-
if
|
122 |
return '';
|
123 |
}
|
124 |
}
|
125 |
-
$gallery
|
126 |
-
$gallery_meta = $gmDB->get_metadata(
|
127 |
-
$gallery_meta = array_map(
|
128 |
-
$gallery_meta = array_map(
|
129 |
-
$gallery
|
130 |
}
|
131 |
|
132 |
-
if
|
133 |
-
$gallery['module']
|
134 |
-
$gallery['settings'][
|
135 |
-
} elseif
|
136 |
-
$gallery['settings'][
|
137 |
}
|
138 |
|
139 |
-
if
|
140 |
-
$gallery['query'][
|
141 |
}
|
142 |
|
143 |
-
$module = $gmCore->get_module_path(
|
144 |
-
if
|
145 |
-
return '<div class="gmedia_gallery gmediaShortcodeError">#' . $id . ': ' . __(
|
146 |
}
|
147 |
|
148 |
-
if
|
149 |
-
$module_info = array(
|
150 |
-
include(
|
151 |
$module['info'] = $module_info;
|
152 |
/** @var $default_options */
|
153 |
-
include(
|
154 |
-
if
|
155 |
$module['options'] = $default_options;
|
156 |
-
} else
|
157 |
-
return '<div class="gmedia_gallery gmediaShortcodeError">#' . $id . ': ' . sprintf(
|
158 |
}
|
159 |
-
} else
|
160 |
-
return '<div class="gmedia_gallery gmediaShortcodeError">#' . $id . ': ' . sprintf(
|
161 |
}
|
162 |
|
163 |
-
$settings = $gmCore->array_diff_keyval_recursive(
|
164 |
|
165 |
-
if
|
166 |
-
$preset = $gmDB->get_term(
|
167 |
-
if
|
168 |
-
$presettings = maybe_unserialize(
|
169 |
-
$settings
|
170 |
}
|
171 |
}
|
172 |
|
173 |
-
$terms
|
174 |
$gmedia = array();
|
175 |
-
if
|
176 |
-
$gmedia_status = array(
|
177 |
-
if
|
178 |
$gmedia_status[] = 'private';
|
179 |
}
|
180 |
-
foreach
|
181 |
-
if
|
182 |
-
if
|
183 |
-
$term_id
|
184 |
-
$terms[
|
185 |
-
$term_ids
|
186 |
-
$gmedia[
|
187 |
continue;
|
188 |
}
|
189 |
-
foreach
|
190 |
-
$terms[
|
191 |
-
if
|
192 |
-
if
|
193 |
-
$terms[
|
194 |
-
$
|
195 |
-
|
196 |
-
|
197 |
-
|
|
|
198 |
continue;
|
199 |
}
|
200 |
-
$term_meta
|
201 |
-
$term_meta
|
202 |
-
$term_meta
|
203 |
-
$args
|
204 |
-
$gmedia[
|
205 |
-
} elseif
|
206 |
-
$
|
|
|
207 |
}
|
208 |
-
} else
|
209 |
-
unset(
|
210 |
}
|
211 |
}
|
212 |
-
} else
|
213 |
-
return '<div class="gmedia_gallery gmediaShortcodeError">#' . $id . ': ' . sprintf(
|
214 |
}
|
215 |
}
|
216 |
-
} else
|
217 |
-
return '<div class="gmedia_gallery gmediaShortcodeError">#' . $id . ': ' . sprintf(
|
218 |
}
|
219 |
|
220 |
-
$gmGallery->do_module[
|
|
|
221 |
|
222 |
-
$
|
223 |
-
$
|
224 |
-
|
225 |
-
if ( ! ( $is_bot = wp_is_mobile() ) ) {
|
226 |
$is_bot = $gmCore->is_bot();
|
227 |
}
|
228 |
|
|
|
|
|
|
|
|
|
|
|
229 |
ob_start();
|
230 |
-
include(
|
231 |
$out .= ob_get_contents();
|
232 |
ob_end_clean();
|
233 |
|
234 |
-
if
|
235 |
$out .= "<style type='text/css' scoped='scoped'>/**** Custom CSS {$gallery['module']} #{$id} ****/" . $settings['customCSS'] . "</style>";
|
236 |
}
|
237 |
|
238 |
$out .= '</div>';
|
239 |
|
240 |
-
|
241 |
-
|
|
|
|
|
242 |
}
|
243 |
|
244 |
return $out;
|
@@ -261,10 +269,10 @@ function gmedia_shortcode( $atts, $content = '' ) {
|
|
261 |
*
|
262 |
* @return string Content with shortcode parsed
|
263 |
*/
|
264 |
-
function get_gmedia_unformatted_shortcode_blocks(
|
265 |
global $gmGallery;
|
266 |
|
267 |
-
if
|
268 |
return $content;
|
269 |
}
|
270 |
|
@@ -275,10 +283,10 @@ function get_gmedia_unformatted_shortcode_blocks( $content ) {
|
|
275 |
remove_all_shortcodes();
|
276 |
|
277 |
// my_shortcode_handler1(), below, saves the rawr blocks into $this->unformatted_shortcode_blocks[]
|
278 |
-
add_shortcode(
|
279 |
|
280 |
// Do the shortcode (only the [rawr] shortcode is now registered)
|
281 |
-
$content = do_shortcode(
|
282 |
|
283 |
// Put the original shortcodes back for normal processing at priority 11
|
284 |
$shortcode_tags = $orig_shortcode_tags;
|
@@ -292,30 +300,30 @@ function get_gmedia_unformatted_shortcode_blocks( $content ) {
|
|
292 |
*
|
293 |
* @return string
|
294 |
*/
|
295 |
-
function gmedia_raw_shortcode(
|
296 |
global $wp_filter, $merged_filters, $wp_current_filter;
|
297 |
-
$wp_filter_
|
298 |
-
$merged_filters_
|
299 |
$wp_current_filter_ = $wp_current_filter;
|
300 |
-
$noraw
|
301 |
-
$wp_filter
|
302 |
-
$merged_filters
|
303 |
-
$wp_current_filter
|
304 |
|
305 |
global $gmedia_shortcode_instance;
|
306 |
// Store the unformatted content for later:
|
307 |
-
$gmedia_shortcode_instance['shortcode_raw'][] = gmedia_shortcode(
|
308 |
-
$raw_index
|
309 |
-
$shortcode_atts
|
310 |
// Put the shortcode tag back with raw index, so it gets processed again below.
|
311 |
$atts['_raw'] = $raw_index;
|
312 |
-
foreach
|
313 |
$shortcode_atts .= " $key=$value";
|
314 |
}
|
315 |
-
if
|
316 |
//return "[raw]".gmedia_shortcode($atts, $content)."[/raw]";
|
317 |
return "[raw][gmedia{$shortcode_atts}]{$content}[/gmedia][/raw]";
|
318 |
-
} else
|
319 |
return "[gmedia{$shortcode_atts}]{$content}[/gmedia]";
|
320 |
}
|
321 |
}
|
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_term_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_term_shortcode($atts, $content = ''){
|
27 |
/**
|
28 |
* @var $album
|
29 |
* @var $tag
|
31 |
* @var $module
|
32 |
* @var $preset
|
33 |
*/
|
34 |
+
extract(shortcode_atts(array(
|
35 |
+
'album' => 0,
|
36 |
+
'tag' => 0,
|
37 |
'category' => 0,
|
38 |
+
'module' => '',
|
39 |
+
'preset' => 0,
|
40 |
+
), $atts));
|
41 |
+
if($album){
|
42 |
$_tax = 'album';
|
43 |
+
$id = $album;
|
44 |
+
} elseif($tag){
|
45 |
$_tax = 'tag';
|
46 |
+
$id = $tag;
|
47 |
+
} elseif($category){
|
48 |
$_tax = 'category';
|
49 |
+
$id = $category;
|
50 |
+
} else{
|
51 |
return '';
|
52 |
}
|
53 |
$sc_atts = array(
|
54 |
+
'id' => $id,
|
55 |
+
'set_module' => $module,
|
56 |
+
'preset' => $preset,
|
57 |
+
'_tax' => $_tax
|
58 |
);
|
59 |
+
$out = gmedia_shortcode($sc_atts, $content);
|
60 |
|
61 |
return $out;
|
62 |
}
|
67 |
*
|
68 |
* @return string
|
69 |
*/
|
70 |
+
function gmedia_shortcode($atts, $content = ''){
|
71 |
global $gmDB, $gmGallery, $gmCore;
|
72 |
global $gmedia_shortcode_instance;
|
73 |
/**
|
74 |
* @var $id
|
75 |
+
* @var $set_module
|
76 |
* @var $preset
|
77 |
* @var $_tax
|
78 |
* @var $_raw
|
79 |
*/
|
80 |
+
extract(shortcode_atts(array(
|
81 |
+
'id' => 0,
|
82 |
+
'set_module' => '',
|
83 |
+
'preset' => 0,
|
84 |
+
'_tax' => 'gallery',
|
85 |
+
'_raw' => false
|
86 |
+
), $atts));
|
87 |
+
|
88 |
+
$shortcode_raw = (isset($gmGallery->options['shortcode_raw']) && '1' === $gmGallery->options['shortcode_raw']);
|
89 |
+
if($shortcode_raw && false !== $_raw){
|
90 |
+
return $gmedia_shortcode_instance['shortcode_raw'][$_raw];
|
91 |
}
|
92 |
|
93 |
+
$id = intval($id);
|
94 |
+
if(!$id){
|
95 |
return $content;
|
96 |
}
|
97 |
|
98 |
$_gallery = array(
|
99 |
+
'term_id' => 0,
|
100 |
+
'name' => '',
|
101 |
'description' => '',
|
102 |
+
'status' => 'public',
|
103 |
+
'edited' => '—',
|
104 |
+
'module' => 'phantom',
|
105 |
+
'query' => array(),
|
106 |
+
'settings' => array()
|
107 |
);
|
108 |
|
109 |
$taxonomy = 'gmedia_' . $_tax;
|
110 |
+
$gallery = $gmDB->get_term($id, $taxonomy, ARRAY_A);
|
111 |
+
if(is_wp_error($gallery)){
|
112 |
return '<div class="gmedia_gallery gmediaShortcodeError">#' . $id . ': ' . $gallery->get_error_message() . '<br />' . $content . '</div>';
|
113 |
+
} elseif(empty($gallery)){
|
114 |
+
return '<div class="gmedia_gallery gmediaShortcodeError">#' . $id . ': ' . sprintf(__('No gallery with ID #%s in database'), $id) . '<br />' . $content . '</div>';
|
115 |
+
} else{
|
116 |
+
if(is_user_logged_in()){
|
117 |
+
if(($gallery['status'] == 'draft') && ($gallery['global'] != get_current_user_id())){
|
118 |
return '';
|
119 |
}
|
120 |
+
} else{
|
121 |
+
if(in_array($gallery['status'], array('private', 'draft'))){
|
122 |
return '';
|
123 |
}
|
124 |
}
|
125 |
+
$gallery = array_merge($_gallery, $gallery);
|
126 |
+
$gallery_meta = $gmDB->get_metadata('gmedia_term', $id);
|
127 |
+
$gallery_meta = array_map('reset', $gallery_meta);
|
128 |
+
$gallery_meta = array_map('maybe_unserialize', $gallery_meta);
|
129 |
+
$gallery = array_merge($gallery, $gallery_meta);
|
130 |
}
|
131 |
|
132 |
+
if(!empty($set_module) && $gallery['module'] != $set_module){
|
133 |
+
$gallery['module'] = sanitize_key($set_module);
|
134 |
+
$gallery['settings'][$gallery['module']] = array();
|
135 |
+
} elseif(!isset($gallery['settings'][$gallery['module']])){
|
136 |
+
$gallery['settings'][$gallery['module']] = array();
|
137 |
}
|
138 |
|
139 |
+
if(empty($gallery['query']) && ('gallery' !== $_tax)){
|
140 |
+
$gallery['query']['gmedia_' . $_tax] = array($id);
|
141 |
}
|
142 |
|
143 |
+
$module = $gmCore->get_module_path($gallery['module']);
|
144 |
+
if(!$module){
|
145 |
+
return '<div class="gmedia_gallery gmediaShortcodeError">#' . $id . ': ' . __('Gmedia Module folder missed.', 'gmLang') . '<br />' . $content . '</div>';
|
146 |
}
|
147 |
|
148 |
+
if(file_exists($module['path'] . '/index.php') && file_exists($module['path'] . '/settings.php')){
|
149 |
+
$module_info = array('dependencies' => '');
|
150 |
+
include($module['path'] . '/index.php');
|
151 |
$module['info'] = $module_info;
|
152 |
/** @var $default_options */
|
153 |
+
include($module['path'] . '/settings.php');
|
154 |
+
if(isset($default_options)){
|
155 |
$module['options'] = $default_options;
|
156 |
+
} else{
|
157 |
+
return '<div class="gmedia_gallery gmediaShortcodeError">#' . $id . ': ' . sprintf(__('Module `%s` is outdated. Update module to latest version'), $gallery['module']) . '<br />' . $content . '</div>';
|
158 |
}
|
159 |
+
} else{
|
160 |
+
return '<div class="gmedia_gallery gmediaShortcodeError">#' . $id . ': ' . sprintf(__('Module `%s` is broken. Choose another module for this gallery'), $gallery['module']) . '<br />' . $content . '</div>';
|
161 |
}
|
162 |
|
163 |
+
$settings = $gmCore->array_diff_keyval_recursive($gallery['settings'][$gallery['module']], $module['options'], false);
|
164 |
|
165 |
+
if(!empty($preset)){
|
166 |
+
$preset = $gmDB->get_term($preset, 'gmedia_module');
|
167 |
+
if(!empty($preset) && !is_wp_error($preset) && ($gallery['module'] == $preset->status)){
|
168 |
+
$presettings = maybe_unserialize($preset->description);
|
169 |
+
$settings = $gmCore->array_diff_keyval_recursive($presettings, $settings, false);
|
170 |
}
|
171 |
}
|
172 |
|
173 |
+
$terms = array();
|
174 |
$gmedia = array();
|
175 |
+
if(!empty($gallery['query'])){
|
176 |
+
$gmedia_status = array('public');
|
177 |
+
if(is_user_logged_in()){
|
178 |
$gmedia_status[] = 'private';
|
179 |
}
|
180 |
+
foreach($gallery['query'] as $tax => $term_ids){
|
181 |
+
if(!empty($term_ids)){
|
182 |
+
if('gmedia__in' == $tax){
|
183 |
+
$term_id = (int) $gallery['term_id'];
|
184 |
+
$terms[$term_id] = $gmDB->get_term($term_id, 'gmedia_gallery');
|
185 |
+
$term_ids = implode(',', wp_parse_id_list($term_ids[0]));
|
186 |
+
$gmedia[$term_id] = $gmDB->get_gmedias(array('gmedia__in' => $term_ids, 'orderby' => 'gmedia__in', 'order' => 'ASC', 'status' => $gmedia_status));
|
187 |
continue;
|
188 |
}
|
189 |
+
foreach($term_ids as $term_id){
|
190 |
+
$terms[$term_id] = $gmDB->get_term($term_id, $tax);
|
191 |
+
if(!empty($terms[$term_id]) && !is_wp_error($terms[$term_id]) && $terms[$term_id]->count){
|
192 |
+
if('gmedia_category' == $tax){
|
193 |
+
$terms[$term_id]->name = $gmGallery->options['taxonomies']['gmedia_category'][$terms[$term_id]->name];
|
194 |
+
$args = array('category__in' => $term_id, 'orderby' => $gmGallery->options['in_category_orderby'], 'order' => $gmGallery->options['in_category_order'], 'status' => $gmedia_status);
|
195 |
+
$gmedia[$term_id] = $gmDB->get_gmedias($args);
|
196 |
+
} elseif('gmedia_album' == $tax){
|
197 |
+
if(('draft' == $terms[$term_id]->status) || (('private' == $terms[$term_id]->status) && !is_user_logged_in())){
|
198 |
+
unset($terms[$term_id]);
|
199 |
continue;
|
200 |
}
|
201 |
+
$term_meta = $gmDB->get_metadata('gmedia_term', $term_id);
|
202 |
+
$term_meta = array_map('reset', $term_meta);
|
203 |
+
$term_meta = array_merge(array('orderby' => 'ID', 'order' => 'DESC'), $term_meta);
|
204 |
+
$args = array('album__in' => $term_id, 'orderby' => $term_meta['orderby'], 'order' => $term_meta['order'], 'status' => $gmedia_status);
|
205 |
+
$gmedia[$term_id] = $gmDB->get_gmedias($args);
|
206 |
+
} elseif('gmedia_tag' == $tax){
|
207 |
+
$args = array('tag__in' => $term_id, 'orderby' => $gmGallery->options['in_tag_orderby'], 'order' => $gmGallery->options['in_tag_order'], 'status' => $gmedia_status);
|
208 |
+
$gmedia[$term_id] = $gmDB->get_gmedias($args);
|
209 |
}
|
210 |
+
} else{
|
211 |
+
unset($terms[$term_id]);
|
212 |
}
|
213 |
}
|
214 |
+
} else{
|
215 |
+
return '<div class="gmedia_gallery gmediaShortcodeError">#' . $id . ': ' . sprintf(__('Choose gallery source, please.'), $gallery['module']) . '<br />' . $content . '</div>';
|
216 |
}
|
217 |
}
|
218 |
+
} else{
|
219 |
+
return '<div class="gmedia_gallery gmediaShortcodeError">#' . $id . ': ' . sprintf(__('Choose gallery source, please.'), $gallery['module']) . '<br />' . $content . '</div>';
|
220 |
}
|
221 |
|
222 |
+
$gmGallery->do_module[$gallery['module']] = $module;
|
223 |
+
$gmGallery->shortcode = compact('module', 'gallery', 'terms', 'gmedia');
|
224 |
|
225 |
+
$is_bot = false;
|
226 |
+
if(!($is_mob = wp_is_mobile())){
|
|
|
|
|
227 |
$is_bot = $gmCore->is_bot();
|
228 |
}
|
229 |
|
230 |
+
do_action('pre_gmedia_shortcode');
|
231 |
+
|
232 |
+
$out = '<div class="gmedia_gallery ' . $gallery['module'] . '_module' . ($is_mob? ' is_mobile' : '') . '" id="GmediaGallery_' . $id . '" data-gallery="' . $id . '" data-module="' . $gallery['module'] . '">';
|
233 |
+
$out .= $content;
|
234 |
+
|
235 |
ob_start();
|
236 |
+
include($module['path'] . '/init.php');
|
237 |
$out .= ob_get_contents();
|
238 |
ob_end_clean();
|
239 |
|
240 |
+
if(isset($settings['customCSS']) && ('' != trim($settings['customCSS']))){
|
241 |
$out .= "<style type='text/css' scoped='scoped'>/**** Custom CSS {$gallery['module']} #{$id} ****/" . $settings['customCSS'] . "</style>";
|
242 |
}
|
243 |
|
244 |
$out .= '</div>';
|
245 |
|
246 |
+
do_action('gmedia_shortcode');
|
247 |
+
|
248 |
+
if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
|
249 |
+
do_action('gmedia_footer_scripts');
|
250 |
}
|
251 |
|
252 |
return $out;
|
269 |
*
|
270 |
* @return string Content with shortcode parsed
|
271 |
*/
|
272 |
+
function get_gmedia_unformatted_shortcode_blocks($content){
|
273 |
global $gmGallery;
|
274 |
|
275 |
+
if('0' == $gmGallery->options['shortcode_raw']){
|
276 |
return $content;
|
277 |
}
|
278 |
|
283 |
remove_all_shortcodes();
|
284 |
|
285 |
// my_shortcode_handler1(), below, saves the rawr blocks into $this->unformatted_shortcode_blocks[]
|
286 |
+
add_shortcode('gmedia', 'gmedia_raw_shortcode');
|
287 |
|
288 |
// Do the shortcode (only the [rawr] shortcode is now registered)
|
289 |
+
$content = do_shortcode($content);
|
290 |
|
291 |
// Put the original shortcodes back for normal processing at priority 11
|
292 |
$shortcode_tags = $orig_shortcode_tags;
|
300 |
*
|
301 |
* @return string
|
302 |
*/
|
303 |
+
function gmedia_raw_shortcode($atts, $content = ''){
|
304 |
global $wp_filter, $merged_filters, $wp_current_filter;
|
305 |
+
$wp_filter_ = $wp_filter;
|
306 |
+
$merged_filters_ = $merged_filters;
|
307 |
$wp_current_filter_ = $wp_current_filter;
|
308 |
+
$noraw = do_shortcode(apply_filters('the_content', '[raw][/raw]'));
|
309 |
+
$wp_filter = $wp_filter_;
|
310 |
+
$merged_filters = $merged_filters_;
|
311 |
+
$wp_current_filter = $wp_current_filter_;
|
312 |
|
313 |
global $gmedia_shortcode_instance;
|
314 |
// Store the unformatted content for later:
|
315 |
+
$gmedia_shortcode_instance['shortcode_raw'][] = gmedia_shortcode($atts, $content);
|
316 |
+
$raw_index = count($gmedia_shortcode_instance['shortcode_raw']) - 1;
|
317 |
+
$shortcode_atts = '';
|
318 |
// Put the shortcode tag back with raw index, so it gets processed again below.
|
319 |
$atts['_raw'] = $raw_index;
|
320 |
+
foreach($atts as $key => $value){
|
321 |
$shortcode_atts .= " $key=$value";
|
322 |
}
|
323 |
+
if(!$noraw){
|
324 |
//return "[raw]".gmedia_shortcode($atts, $content)."[/raw]";
|
325 |
return "[raw][gmedia{$shortcode_atts}]{$content}[/gmedia][/raw]";
|
326 |
+
} else{
|
327 |
return "[gmedia{$shortcode_atts}]{$content}[/gmedia]";
|
328 |
}
|
329 |
}
|
inc/sitemap.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP Class for Wordpress SEO plugin
|
4 |
+
*
|
5 |
+
*/
|
6 |
+
class gmediaSitemaps {
|
7 |
+
|
8 |
+
var $images = array();
|
9 |
+
|
10 |
+
/**
|
11 |
+
* gmediaSitemaps::__construct()
|
12 |
+
*/
|
13 |
+
function __construct() {
|
14 |
+
|
15 |
+
add_filter('wpseo_sitemap_urlimages', array( &$this, 'add_wpseo_xml_sitemap_images'), 10, 2);
|
16 |
+
|
17 |
+
add_filter('the_content_feed', 'do_shortcode');
|
18 |
+
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Filter support for WordPress SEO by Yoast 0.4.0 or higher ( http://wordpress.org/extend/plugins/wordpress-seo/ )
|
23 |
+
*
|
24 |
+
* @param array $images
|
25 |
+
* @param int $post_id
|
26 |
+
*
|
27 |
+
* @return array $image list of all founded images
|
28 |
+
*/
|
29 |
+
function add_wpseo_xml_sitemap_images( $images, $post_id ) {
|
30 |
+
global $gmGallery, $gmCore;
|
31 |
+
|
32 |
+
$this->images = $images;
|
33 |
+
|
34 |
+
// first get the content of the post/page
|
35 |
+
$p = get_post($post_id);
|
36 |
+
|
37 |
+
$content = $p->post_content;
|
38 |
+
|
39 |
+
// Don't process the images in the normal way
|
40 |
+
remove_all_shortcodes();
|
41 |
+
|
42 |
+
add_shortcode('gmedia', 'gmedia_shortcode');
|
43 |
+
add_shortcode('gm', 'gmedia_term_shortcode');
|
44 |
+
|
45 |
+
// Search now for shortcodes
|
46 |
+
do_shortcode( $content );
|
47 |
+
|
48 |
+
if(isset($gmGallery->shortcode['gmedia'])){
|
49 |
+
foreach($gmGallery->shortcode['gmedia'] as $termitems){
|
50 |
+
foreach($termitems as $item){
|
51 |
+
$newimage = array();
|
52 |
+
$newimage['src'] = $gmCore->gm_get_media_image($item, 'web');
|
53 |
+
if(!empty($item->title)) {
|
54 |
+
$newimage['title'] = strip_tags( $item->title );
|
55 |
+
}
|
56 |
+
if(!empty($item->description)) {
|
57 |
+
$newimage['alt'] = strip_tags( $item->description );
|
58 |
+
}
|
59 |
+
$this->images[] = $newimage;
|
60 |
+
}
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
return $this->images;
|
65 |
+
}
|
66 |
+
}
|
67 |
+
$gmediaSitemaps = new gmediaSitemaps();
|
load-template.php
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
//ini_set('display_errors', '1');
|
3 |
+
//ini_set('error_reporting', E_ALL);
|
4 |
+
if(!defined('ABSPATH')){
|
5 |
+
exit;
|
6 |
+
}
|
7 |
+
/**
|
8 |
+
* @var $wp
|
9 |
+
* @var $endpoint
|
10 |
+
*/
|
11 |
+
|
12 |
+
global $gmedia, $gmedia_id, $gmedia_type, $gmedia_module, $gmedia_module_preset, $gmedia_shortcode_content, $gmedia_share_img;
|
13 |
+
|
14 |
+
$gmedia_hashid = urldecode($wp->query_vars[$endpoint]);
|
15 |
+
$type = isset($wp->query_vars['t'])? $wp->query_vars['t'] : 'g';
|
16 |
+
|
17 |
+
$template = array(
|
18 |
+
'g' => 'gallery',
|
19 |
+
'a' => 'album',
|
20 |
+
't' => 'tag',
|
21 |
+
's' => 'single',
|
22 |
+
'k' => 'category'
|
23 |
+
);
|
24 |
+
if(!isset($template[$type])){
|
25 |
+
locate_template(array('404'), true);
|
26 |
+
exit();
|
27 |
+
}
|
28 |
+
|
29 |
+
$gmedia_type = $template[$type];
|
30 |
+
$gmedia_id = gmedia_hash_id_decode($gmedia_hashid, $gmedia_type);
|
31 |
+
if(empty($gmedia_id)){
|
32 |
+
exit();
|
33 |
+
}
|
34 |
+
|
35 |
+
global $user_ID, $gmCore, $gmDB, $gmGallery;
|
36 |
+
|
37 |
+
switch($gmedia_type){
|
38 |
+
case 'gallery':
|
39 |
+
$gmedia = $gmDB->get_term($gmedia_id, 'gmedia_gallery');
|
40 |
+
if($gmCore->_get('set_module') && $user_ID){
|
41 |
+
$gmedia_module = $_GET['set_module'];
|
42 |
+
} else{
|
43 |
+
$gmedia_module = $gmDB->get_metadata( 'gmedia_term', $gmedia_id, 'module', true);
|
44 |
+
}
|
45 |
+
break;
|
46 |
+
case 'album':
|
47 |
+
case 'tag':
|
48 |
+
case 'category':
|
49 |
+
$gmedia = $gmDB->get_term($gmedia_id, "gmedia_{$gmedia_type}");
|
50 |
+
|
51 |
+
if(empty($gmGallery->options['gmediacloud_module'])){
|
52 |
+
$gmedia_module = 'phantom';
|
53 |
+
} else{
|
54 |
+
if($gmCore->is_digit($gmGallery->options['gmediacloud_module'])){
|
55 |
+
$get_preset = $gmDB->get_term( (int) $gmGallery->options['gmediacloud_module'], 'gmedia_module');
|
56 |
+
if(!empty($get_preset) && !is_wp_error($get_preset)){
|
57 |
+
$gmedia_module = $get_preset->status;
|
58 |
+
$gmedia_module_preset = $get_preset->term_id;
|
59 |
+
}
|
60 |
+
} else {
|
61 |
+
$gmedia_module = $gmGallery->options['gmediacloud_module'];
|
62 |
+
}
|
63 |
+
}
|
64 |
+
break;
|
65 |
+
case 'single':
|
66 |
+
$gmedia = $gmDB->get_gmedia($gmedia_id);
|
67 |
+
break;
|
68 |
+
}
|
69 |
+
if(!$gmedia_module){
|
70 |
+
$gmedia_module = 'phantom';
|
71 |
+
}
|
72 |
+
|
73 |
+
$module = $gmCore->get_module_path($gmedia_module);
|
74 |
+
require_once(GMEDIA_ABSPATH . 'template/functions.php');
|
75 |
+
|
76 |
+
if(file_exists($module['path'] . "/template/functions.php")){
|
77 |
+
include_once($module['path'] . "/template/functions.php");
|
78 |
+
}
|
79 |
+
|
80 |
+
if(file_exists($module['path'] . "/template/{$gmedia_type}.php")){
|
81 |
+
require_once($module['path'] . "/template/{$gmedia_type}.php");
|
82 |
+
} elseif(in_array($gmedia_type, array('album', 'tag', 'category')) && file_exists($module['path'] . "/template/gallery.php")){
|
83 |
+
require_once($module['path'] . "/template/gallery.php");
|
84 |
+
} else{
|
85 |
+
/* only for default template */
|
86 |
+
add_action('gmedia_head', 'gmedia_default_template_styles');
|
87 |
+
require_once( GMEDIA_ABSPATH . "template/{$gmedia_type}.php" );
|
88 |
+
}
|
module/afflux/init.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* @var $gallery
|
6 |
* @var $module
|
7 |
* @var $settings
|
8 |
-
* @var $
|
9 |
* @var $gmedia
|
10 |
* @var $is_bot
|
11 |
**/
|
5 |
* @var $gallery
|
6 |
* @var $module
|
7 |
* @var $settings
|
8 |
+
* @var $terms
|
9 |
* @var $gmedia
|
10 |
* @var $is_bot
|
11 |
**/
|
module/jq-mplayer/index.php
CHANGED
@@ -3,7 +3,7 @@ $module_info = array(
|
|
3 |
'base' => 'jq-mplayer',
|
4 |
'name' => 'jq-mplayer',
|
5 |
'title' => 'Music Player',
|
6 |
-
'version' => '2.
|
7 |
'author' => 'CodEasily.com',
|
8 |
'description' => 'This beautiful audio player is totally written in JQuery and HTML5 + visitors can set rating for each track',
|
9 |
'type' => 'music',
|
3 |
'base' => 'jq-mplayer',
|
4 |
'name' => 'jq-mplayer',
|
5 |
'title' => 'Music Player',
|
6 |
+
'version' => '2.3',
|
7 |
'author' => 'CodEasily.com',
|
8 |
'description' => 'This beautiful audio player is totally written in JQuery and HTML5 + visitors can set rating for each track',
|
9 |
'type' => 'music',
|
module/jq-mplayer/init.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* @var $gallery
|
6 |
* @var $module
|
7 |
* @var $settings
|
8 |
-
* @var $
|
9 |
* @var $gmedia
|
10 |
* @var $is_bot
|
11 |
**/
|
@@ -50,6 +50,7 @@ if(!empty($content)){
|
|
50 |
'moduleUrl' => $module['url'],
|
51 |
'pluginUrl' => $gmCore->gmedia_url,
|
52 |
'libraryUrl' => $gmCore->upload['url'],
|
|
|
53 |
'ip' => str_replace('.', '', $_SERVER['REMOTE_ADDR'])
|
54 |
));
|
55 |
$allsettings = array_merge($module['options'], $settings);
|
5 |
* @var $gallery
|
6 |
* @var $module
|
7 |
* @var $settings
|
8 |
+
* @var $terms
|
9 |
* @var $gmedia
|
10 |
* @var $is_bot
|
11 |
**/
|
50 |
'moduleUrl' => $module['url'],
|
51 |
'pluginUrl' => $gmCore->gmedia_url,
|
52 |
'libraryUrl' => $gmCore->upload['url'],
|
53 |
+
'ajaxurl' => admin_url('admin-ajax.php'),
|
54 |
'ip' => str_replace('.', '', $_SERVER['REMOTE_ADDR'])
|
55 |
));
|
56 |
$allsettings = array_merge($module['options'], $settings);
|
module/jq-mplayer/js/gm-music-player.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/*
|
2 |
* Title : Music Player Module for Gmedia Gallery plugin
|
3 |
-
* Version : 2.
|
4 |
* Copyright : 2013 CodEasily.com
|
5 |
* Website : http://www.codeasily.com
|
6 |
*/
|
@@ -39,7 +39,8 @@
|
|
39 |
opt_str = {
|
40 |
width:'auto',
|
41 |
buttonText:'Download',
|
42 |
-
moreText:'View More...'
|
|
|
43 |
};
|
44 |
opt_int = {
|
45 |
maxwidth:0,
|
@@ -351,7 +352,9 @@
|
|
351 |
|
352 |
$this.prevAll().add($this).addClass(attr(cssSelector.ratingLevelOn)).end().end().nextAll().removeClass(attr(cssSelector.ratingLevelOn));
|
353 |
|
354 |
-
|
|
|
|
|
355 |
});
|
356 |
}
|
357 |
|
@@ -359,7 +362,7 @@
|
|
359 |
myPlaylist[index].rating = rating;
|
360 |
var gmid = myPlaylist[index].id,
|
361 |
uip = userOptions.ip;
|
362 |
-
$.post(
|
363 |
console.log(r);
|
364 |
});
|
365 |
|
1 |
/*
|
2 |
* Title : Music Player Module for Gmedia Gallery plugin
|
3 |
+
* Version : 2.3
|
4 |
* Copyright : 2013 CodEasily.com
|
5 |
* Website : http://www.codeasily.com
|
6 |
*/
|
39 |
opt_str = {
|
40 |
width:'auto',
|
41 |
buttonText:'Download',
|
42 |
+
moreText:'View More...',
|
43 |
+
ajaxurl:''
|
44 |
};
|
45 |
opt_int = {
|
46 |
maxwidth:0,
|
352 |
|
353 |
$this.prevAll().add($this).addClass(attr(cssSelector.ratingLevelOn)).end().end().nextAll().removeClass(attr(cssSelector.ratingLevelOn));
|
354 |
|
355 |
+
if(options.ajaxurl){
|
356 |
+
processRating(index, rating);
|
357 |
+
}
|
358 |
});
|
359 |
}
|
360 |
|
362 |
myPlaylist[index].rating = rating;
|
363 |
var gmid = myPlaylist[index].id,
|
364 |
uip = userOptions.ip;
|
365 |
+
$.post(options.ajaxurl, { action: 'gmedia_module_interaction', rate: {uip:uip,gmid:gmid,rate:rating} }, function(r){
|
366 |
console.log(r);
|
367 |
});
|
368 |
|
module/jq-mplayer/settings.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
$default_options = array(
|
3 |
'maxwidth' => '0',
|
4 |
'rating' => '1',
|
5 |
-
'autoplay' => '
|
6 |
'buttonText' => 'Download',
|
7 |
'tracksToShow' => '5',
|
8 |
'moreText' => 'View More...',
|
2 |
$default_options = array(
|
3 |
'maxwidth' => '0',
|
4 |
'rating' => '1',
|
5 |
+
'autoplay' => '0',
|
6 |
'buttonText' => 'Download',
|
7 |
'tracksToShow' => '5',
|
8 |
'moreText' => 'View More...',
|
module/minima/gallery.swf
CHANGED
Binary file
|
module/minima/index.php
CHANGED
@@ -3,7 +3,7 @@ $module_info = array(
|
|
3 |
'base' => 'minima',
|
4 |
'name' => 'minima',
|
5 |
'title' => 'Minima',
|
6 |
-
'version' => '2.
|
7 |
'author' => 'CodEasily.com',
|
8 |
'description' => 'Multi-tab professional image gallery skin with slideshow feature. This is the free light version of <a target="_blank" href="http://codeasily.com/portfolio-item/gmedia-optima/">Optima Module</a>.',
|
9 |
'type' => 'gallery',
|
3 |
'base' => 'minima',
|
4 |
'name' => 'minima',
|
5 |
'title' => 'Minima',
|
6 |
+
'version' => '2.7',
|
7 |
'author' => 'CodEasily.com',
|
8 |
'description' => 'Multi-tab professional image gallery skin with slideshow feature. This is the free light version of <a target="_blank" href="http://codeasily.com/portfolio-item/gmedia-optima/">Optima Module</a>.',
|
9 |
'type' => 'gallery',
|
module/minima/init.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* @var $gallery
|
6 |
* @var $module
|
7 |
* @var $settings
|
8 |
-
* @var $
|
9 |
* @var $gmedia
|
10 |
* @var $is_bot
|
11 |
**/
|
5 |
* @var $gallery
|
6 |
* @var $module
|
7 |
* @var $settings
|
8 |
+
* @var $terms
|
9 |
* @var $gmedia
|
10 |
* @var $is_bot
|
11 |
**/
|
module/minima/js/jquery.gmMinima.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/*
|
2 |
* Title : Minima Gallery Module
|
3 |
-
* Version : 2.
|
4 |
* Copyright : 2013 CodEasily.com
|
5 |
* Website : http://www.codeasily.com
|
6 |
*/
|
1 |
/*
|
2 |
* Title : Minima Gallery Module
|
3 |
+
* Version : 2.7
|
4 |
* Copyright : 2013 CodEasily.com
|
5 |
* Website : http://www.codeasily.com
|
6 |
*/
|
module/phantom/index.php
CHANGED
@@ -3,7 +3,7 @@ $module_info = array(
|
|
3 |
'base' => 'phantom',
|
4 |
'name' => 'phantom',
|
5 |
'title' => 'Phantom',
|
6 |
-
'version' => '2.
|
7 |
'author' => 'CodEasily.com',
|
8 |
'description' => 'This module will help you to easily add a grid gallery to your WordPress website or blog. The gallery is completely customizable, resizable and is compatible with all browsers and devices (iPhone, iPad and Android smartphones).
|
9 |
|
3 |
'base' => 'phantom',
|
4 |
'name' => 'phantom',
|
5 |
'title' => 'Phantom',
|
6 |
+
'version' => '2.4',
|
7 |
'author' => 'CodEasily.com',
|
8 |
'description' => 'This module will help you to easily add a grid gallery to your WordPress website or blog. The gallery is completely customizable, resizable and is compatible with all browsers and devices (iPhone, iPad and Android smartphones).
|
9 |
|
module/phantom/init.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* @var $gallery
|
6 |
* @var $module
|
7 |
* @var $settings
|
8 |
-
* @var $
|
9 |
* @var $gmedia
|
10 |
* @var $is_bot
|
11 |
**/
|
@@ -56,15 +56,24 @@ if(!empty($content)){
|
|
56 |
$json_settings = json_encode($settings);
|
57 |
$settings = array_merge($module['options'], $settings);
|
58 |
?>
|
59 |
-
<?php if(
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
<div class="gmPhantom_Background"></div>
|
69 |
<div class="gmPhantom_thumbsWrapper">
|
70 |
<?php $i = 0; $wrapper_r = $settings['thumbWidth']/$settings['thumbHeight'];
|
@@ -89,7 +98,7 @@ if(!empty($content)){
|
|
89 |
|
90 |
<?php
|
91 |
} else{
|
92 |
-
echo GMEDIA_GALLERY_EMPTY;
|
93 |
}
|
94 |
|
95 |
|
5 |
* @var $gallery
|
6 |
* @var $module
|
7 |
* @var $settings
|
8 |
+
* @var $terms
|
9 |
* @var $gmedia
|
10 |
* @var $is_bot
|
11 |
**/
|
56 |
$json_settings = json_encode($settings);
|
57 |
$settings = array_merge($module['options'], $settings);
|
58 |
?>
|
59 |
+
<?php if(!$is_bot) {
|
60 |
+
if ( $shortcode_raw ) {
|
61 |
+
echo '<pre style="display:none">';
|
62 |
+
}
|
63 |
+
?>
|
64 |
+
<script type="text/javascript">
|
65 |
+
jQuery(function(){
|
66 |
+
var settings = <?php echo $json_settings; ?>;
|
67 |
+
var content = <?php echo json_encode($content); ?>;
|
68 |
+
jQuery('#GmediaGallery_<?php echo $gallery['term_id'] ?>').gmPhantom([content, settings]);
|
69 |
+
});
|
70 |
+
</script><?php
|
71 |
+
if ( $shortcode_raw ) {
|
72 |
+
echo '</pre>';
|
73 |
+
}
|
74 |
+
}
|
75 |
+
?>
|
76 |
+
<div class="gmPhantom_Container delay"<?php if(!$is_bot){ echo ' style="opacity:0.01"'; } ?>>
|
77 |
<div class="gmPhantom_Background"></div>
|
78 |
<div class="gmPhantom_thumbsWrapper">
|
79 |
<?php $i = 0; $wrapper_r = $settings['thumbWidth']/$settings['thumbHeight'];
|
98 |
|
99 |
<?php
|
100 |
} else{
|
101 |
+
echo '<div class="gmedia-no-files">' . GMEDIA_GALLERY_EMPTY . '</div>';
|
102 |
}
|
103 |
|
104 |
|
module/phantom/js/jquery.gmPhantom.js
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
/*
|
2 |
* Title : gmPhantom
|
3 |
-
* Version : 2.
|
4 |
* Copyright : 2013 CodEasily.com
|
5 |
* Website : http://www.codeasily.com
|
6 |
*/
|
7 |
if(typeof jQuery.fn.gmPhantom == 'undefined'){
|
8 |
-
(function($, window, document
|
9 |
$.fn.gmPhantom = function(method){
|
10 |
var Container = this,
|
11 |
ID = '',
|
@@ -101,6 +101,8 @@ if(typeof jQuery.fn.gmPhantom == 'undefined'){
|
|
101 |
methods.parseContent();
|
102 |
|
103 |
$(window).bind('resize.gmPhantom', methods.initRP);
|
|
|
|
|
104 |
},
|
105 |
parseContent: function(){// Parse Content.
|
106 |
$.each(Content, function(index){
|
@@ -143,6 +145,7 @@ if(typeof jQuery.fn.gmPhantom == 'undefined'){
|
|
143 |
methods.rpResponsive();
|
144 |
|
145 |
methods.initGallery();
|
|
|
146 |
},
|
147 |
initGallery: function(){// Init the Gallery
|
148 |
var LightboxHTML = [];
|
@@ -486,8 +489,8 @@ if(typeof jQuery.fn.gmPhantom == 'undefined'){
|
|
486 |
return width;
|
487 |
},
|
488 |
initLightbox: function(){// Init Lightbox
|
489 |
-
startGalleryID = prototypes.$_GET('gmedia_gallery_id')
|
490 |
-
startWith = prototypes.$_GET('gmedia_gallery_share')
|
491 |
if(startWith){
|
492 |
startWith = IDs.indexOf(startWith);
|
493 |
}
|
@@ -595,7 +598,7 @@ if(typeof jQuery.fn.gmPhantom == 'undefined'){
|
|
595 |
} else{
|
596 |
setTimeout(function(){
|
597 |
var zoomlevel = 100, dpr = 1;
|
598 |
-
if(window.devicePixelRatio !== undefined){
|
599 |
dpr = window.devicePixelRatio;
|
600 |
}
|
601 |
if(window.innerWidth > window.innerHeight){
|
@@ -904,7 +907,7 @@ if(typeof jQuery.fn.gmPhantom == 'undefined'){
|
|
904 |
$('.gmPhantom_Lightbox img', touchContainer).css({'transform': transform_scale + ' ' + transform_translate, '-webkit-transform': transform_scale + ' ' + transform_translate});
|
905 |
|
906 |
var zoomlevel = 100, dpr = 1;
|
907 |
-
if(window.devicePixelRatio !== undefined){
|
908 |
dpr = window.devicePixelRatio;
|
909 |
}
|
910 |
if(window.innerWidth > window.innerHeight){
|
@@ -1155,7 +1158,7 @@ if(typeof jQuery.fn.gmPhantom == 'undefined'){
|
|
1155 |
twitter: '{{title}} {{url}}'
|
1156 |
}
|
1157 |
};
|
1158 |
-
if(window.addthis === undefined){
|
1159 |
|
1160 |
$.getScript('http://s7.addthis.com/js/300/addthis_widget.js')
|
1161 |
.done(function(){
|
@@ -1322,7 +1325,7 @@ if(typeof jQuery.fn.gmPhantom == 'undefined'){
|
|
1322 |
var url = window.location.href.split('?')[1];
|
1323 |
if(url){
|
1324 |
url = url.split('#')[0];
|
1325 |
-
var variables = url === undefined? [] : url.split('&'),
|
1326 |
i;
|
1327 |
|
1328 |
for(i = 0; i < variables.length; i++){
|
@@ -1332,13 +1335,13 @@ if(typeof jQuery.fn.gmPhantom == 'undefined'){
|
|
1332 |
}
|
1333 |
}
|
1334 |
|
1335 |
-
return
|
1336 |
},
|
1337 |
doHideBuster: function(item){// Make all parents & current item visible
|
1338 |
var parent = item.parent(),
|
1339 |
items = [];
|
1340 |
|
1341 |
-
if(item.prop('tagName') !== undefined && item.prop('tagName').toLowerCase() != 'body'){
|
1342 |
items = prototypes.doHideBuster(parent);
|
1343 |
}
|
1344 |
|
1 |
/*
|
2 |
* Title : gmPhantom
|
3 |
+
* Version : 2.4
|
4 |
* Copyright : 2013 CodEasily.com
|
5 |
* Website : http://www.codeasily.com
|
6 |
*/
|
7 |
if(typeof jQuery.fn.gmPhantom == 'undefined'){
|
8 |
+
(function($, window, document){
|
9 |
$.fn.gmPhantom = function(method){
|
10 |
var Container = this,
|
11 |
ID = '',
|
101 |
methods.parseContent();
|
102 |
|
103 |
$(window).bind('resize.gmPhantom', methods.initRP);
|
104 |
+
|
105 |
+
setTimeout(methods.initRP, 0);
|
106 |
},
|
107 |
parseContent: function(){// Parse Content.
|
108 |
$.each(Content, function(index){
|
145 |
methods.rpResponsive();
|
146 |
|
147 |
methods.initGallery();
|
148 |
+
|
149 |
},
|
150 |
initGallery: function(){// Init the Gallery
|
151 |
var LightboxHTML = [];
|
489 |
return width;
|
490 |
},
|
491 |
initLightbox: function(){// Init Lightbox
|
492 |
+
startGalleryID = prototypes.$_GET('gmedia_gallery_id')? parseInt(prototypes.$_GET('gmedia_gallery_id')) : 0;
|
493 |
+
startWith = (prototypes.$_GET('gmedia_gallery_share') && (startGalleryID == ID))? prototypes.$_GET('gmedia_gallery_share') : 0;
|
494 |
if(startWith){
|
495 |
startWith = IDs.indexOf(startWith);
|
496 |
}
|
598 |
} else{
|
599 |
setTimeout(function(){
|
600 |
var zoomlevel = 100, dpr = 1;
|
601 |
+
if(typeof(window.devicePixelRatio) !== 'undefined'){
|
602 |
dpr = window.devicePixelRatio;
|
603 |
}
|
604 |
if(window.innerWidth > window.innerHeight){
|
907 |
$('.gmPhantom_Lightbox img', touchContainer).css({'transform': transform_scale + ' ' + transform_translate, '-webkit-transform': transform_scale + ' ' + transform_translate});
|
908 |
|
909 |
var zoomlevel = 100, dpr = 1;
|
910 |
+
if(typeof(window.devicePixelRatio) !== 'undefined'){
|
911 |
dpr = window.devicePixelRatio;
|
912 |
}
|
913 |
if(window.innerWidth > window.innerHeight){
|
1158 |
twitter: '{{title}} {{url}}'
|
1159 |
}
|
1160 |
};
|
1161 |
+
if((typeof(window.addthis) === 'undefined') || (typeof(window.addthis.toolbox) === 'undefined')){
|
1162 |
|
1163 |
$.getScript('http://s7.addthis.com/js/300/addthis_widget.js')
|
1164 |
.done(function(){
|
1325 |
var url = window.location.href.split('?')[1];
|
1326 |
if(url){
|
1327 |
url = url.split('#')[0];
|
1328 |
+
var variables = (typeof(url) === 'undefined')? [] : url.split('&'),
|
1329 |
i;
|
1330 |
|
1331 |
for(i = 0; i < variables.length; i++){
|
1335 |
}
|
1336 |
}
|
1337 |
|
1338 |
+
return false;
|
1339 |
},
|
1340 |
doHideBuster: function(item){// Make all parents & current item visible
|
1341 |
var parent = item.parent(),
|
1342 |
items = [];
|
1343 |
|
1344 |
+
if(typeof(item.prop('tagName')) !== 'undefined' && item.prop('tagName').toLowerCase() != 'body'){
|
1345 |
items = prototypes.doHideBuster(parent);
|
1346 |
}
|
1347 |
|
module/wp-videoplayer/init.php
CHANGED
@@ -8,7 +8,7 @@ ini_set('error_reporting', 0);
|
|
8 |
* @var $gallery
|
9 |
* @var $module
|
10 |
* @var $settings
|
11 |
-
* @var $
|
12 |
* @var $gmedia
|
13 |
* @var $is_bot
|
14 |
**/
|
8 |
* @var $gallery
|
9 |
* @var $module
|
10 |
* @var $settings
|
11 |
+
* @var $terms
|
12 |
* @var $gmedia
|
13 |
* @var $is_bot
|
14 |
**/
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: Rattus
|
|
3 |
Donate link: http://codeasily.com/donate/
|
4 |
Tags: gallery, image, images, library, music, video, slideshow, responsive, admin, Post, posts, easy gallery, iphone gallery, best gallery, portfolio, image gallery, photo gallery, photo, slider, header slider, admin, page, relative image, gallery slider, iOS app
|
5 |
Requires at least: 3.5
|
6 |
-
Tested up to: 4.1.
|
7 |
Stable tag: trunk
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -36,6 +36,7 @@ Gmedia Gallery is the result of hundreds of hours of working to bring you the ul
|
|
36 |
|
37 |
See demo of Gmedia Gallery Modules:
|
38 |
|
|
|
39 |
* [RealSlider Module](http://codeasily.com/portfolio-item/gmedia-realslider/) is an image/video gallery slider module built on jQuery. RealSlider module is responsive and touch friendly gallery with 50+ options for customization.
|
40 |
* [Phantom Module](http://codeasily.com/portfolio-item/gmedia-phantom/) is the Wall/Grid Gallery with social sharing - you can easily change thumbnail sizes, colors, navigation, borders, add stylish labels to thumbnails ... and much more. PhotoSwipe like theme on touch devices.. only better.
|
41 |
* [PhotoBox Module](http://codeasily.com/portfolio-item/gmedia-photobox/) - a lightweight image gallery which uses only CSS3 for silky-smooth animations and transitions.
|
@@ -62,6 +63,8 @@ Help me make it best gallery plugin: test it and [write suggestions](http://code
|
|
62 |
Features:
|
63 |
|
64 |
* (NEW) Gmedia for iOS - [iOS manage application](https://itunes.apple.com/ua/app/gmedia/id947515626?mt=8) to manage your Library with your iPhone
|
|
|
|
|
65 |
* Mobile friendly, responsive galleries
|
66 |
* Add tags, assign categories and group images in albums
|
67 |
* Drag'n'drop sorting for files in Album
|
@@ -74,7 +77,8 @@ Features:
|
|
74 |
* Import Wordpress Media Library files
|
75 |
* Uses WordPress' native Image Resizer
|
76 |
* Import files from server folder or from others gallery plugins
|
77 |
-
* Full Window Gallery
|
|
|
78 |
* Role/Capability Manager intergrated
|
79 |
* Statuses: public, private (only for logged in users), etc. for files, albums
|
80 |
* Batch operations with selected Gmedia items
|
@@ -82,16 +86,15 @@ Features:
|
|
82 |
|
83 |
TODO List:
|
84 |
|
|
|
85 |
* Cover for Album. It will be also used for music without cover (work in progress..)
|
86 |
-
*
|
87 |
* More Batch operations with selected Gmedia items (work in progress..)
|
88 |
* Related Post images on Edit Post. Option to automatically create gallery in Post with related images (work in progress..)
|
89 |
* Share albums to socials from admin panel (in queue)
|
90 |
-
* Different templates to display Gmedia Library (something like GRAND Pages in Flagallery plugin) (in queue)
|
91 |
* More modules for creating photo gallery, audio playlist, video playlist
|
92 |
* Easily add to Post audio and video files with tags related to post tags
|
93 |
* Watermark feature
|
94 |
-
* Intergration with social services (plans)
|
95 |
|
96 |
|
97 |
== Installation ==
|
@@ -121,8 +124,74 @@ Use [Gmedia Gallery support forum](http://codeasily.com/community/forum/gmedia-g
|
|
121 |
|
122 |
== Changelog ==
|
123 |
|
124 |
-
=
|
125 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
|
127 |
= 1.4.2 =
|
128 |
* Fixed music and video Custom Cover when image url is set instead of ID
|
@@ -334,89 +403,15 @@ Use [Gmedia Gallery support forum](http://codeasily.com/community/forum/gmedia-g
|
|
334 |
* More intuitive interface
|
335 |
* Backup before updating. After update plugin go to Manage Modules page and update modules to latest versions. Then check your galleries.
|
336 |
|
337 |
-
= 0.9.4 =
|
338 |
-
* Security fix for jplayer library
|
339 |
-
* Updated css for Wordpress 3.8
|
340 |
-
* Changed Music Player CSS classes for compatibility with some themes
|
341 |
-
|
342 |
-
= 0.9.3 =
|
343 |
-
* Fix for modern themes compatibility (Music player not worked)
|
344 |
-
* Updated Phantom Module css compatibility with some themes
|
345 |
-
|
346 |
-
= 0.9.2 =
|
347 |
-
* Fixed js scripts for modules not loading
|
348 |
-
|
349 |
-
= 0.9.1 =
|
350 |
-
* Fixed Music Player on FireFox
|
351 |
-
* Moved all javascript libraries in 'assets' folder
|
352 |
-
* Fixed Add Images on Post page
|
353 |
-
* Other small fixes and improvements
|
354 |
-
|
355 |
-
= 0.9.0 =
|
356 |
-
* Added new Minima Gallery Module
|
357 |
-
* Added button for upload images right from the post page
|
358 |
-
* Added quick button for creating gallery
|
359 |
-
* Fixed wrong module name in metabox
|
360 |
-
* Fixed unzip module error handler
|
361 |
-
* Added loading new modules info via cURL
|
362 |
-
* Other fixes and improvements
|
363 |
-
|
364 |
-
= 0.8.6 =
|
365 |
-
* Improved Messages fixed at top if window scroll
|
366 |
-
* Improved Key saved on Activation
|
367 |
-
* Fixed hitcounter for flash modules
|
368 |
-
* Fixed Afflux Module js error
|
369 |
-
|
370 |
-
= 0.8.5 =
|
371 |
-
* New Slider Module available for install
|
372 |
-
* Added compatibility with Slider Module
|
373 |
-
* Fixed deprecated js properties in ui-tabs
|
374 |
-
* Fixed module settings reset now skip query builder
|
375 |
-
|
376 |
-
= 0.8.4 =
|
377 |
-
* Added FancyBox script for future modules
|
378 |
-
* Fixed images with extension in uppercase not working
|
379 |
-
* Fixed slashes in title and description
|
380 |
-
* Fixed checkbox settings not worked in module
|
381 |
-
* Fixed delete old module before install new version
|
382 |
-
|
383 |
-
= 0.8.3 =
|
384 |
-
* Added Music Player
|
385 |
-
* Added jplayer sources
|
386 |
-
* Added link field to audio items
|
387 |
-
* Fixed update module button not worked
|
388 |
-
* Added handle errors when installing skins
|
389 |
-
|
390 |
-
= 0.8.2 =
|
391 |
-
* Added compatibility with future modules
|
392 |
-
* Updated Afflux Module and other gallery modules
|
393 |
-
|
394 |
-
= 0.8.1 =
|
395 |
-
* Fix for 30 images limit
|
396 |
-
|
397 |
-
= 0.8.0 =
|
398 |
-
* A Lot of Fixes and improvements
|
399 |
-
* Added Link to Images
|
400 |
-
* Added Related Images on Post Edit page
|
401 |
-
|
402 |
-
= 0.7.0 =
|
403 |
-
* Fixes and improvements
|
404 |
-
* Added Import feature from different sources
|
405 |
-
* Fixed Phantom Module (update to latest version, please)
|
406 |
-
|
407 |
-
= 0.6.3 =
|
408 |
-
* Fixes and improvements
|
409 |
-
* Added Error Handler to File Uploader
|
410 |
-
|
411 |
-
= 0.6.2 =
|
412 |
-
* Fixes and improvements
|
413 |
-
* Added new gallery module
|
414 |
-
|
415 |
-
= 0.6.0 =
|
416 |
-
* First public release
|
417 |
|
418 |
== Upgrade Notice ==
|
419 |
|
|
|
|
|
|
|
|
|
|
|
|
|
420 |
= 0.9.6 =
|
421 |
Backup before updating.
|
422 |
After update plugin go to Manage Modules page and update modules to latest versions.
|
3 |
Donate link: http://codeasily.com/donate/
|
4 |
Tags: gallery, image, images, library, music, video, slideshow, responsive, admin, Post, posts, easy gallery, iphone gallery, best gallery, portfolio, image gallery, photo gallery, photo, slider, header slider, admin, page, relative image, gallery slider, iOS app
|
5 |
Requires at least: 3.5
|
6 |
+
Tested up to: 4.1.1
|
7 |
Stable tag: trunk
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
36 |
|
37 |
See demo of Gmedia Gallery Modules:
|
38 |
|
39 |
+
* [Mosaic Module](http://codeasily.com/portfolio-item/gmedia-mosaic/) is an image gallery with masonry layout built on jQuery. Responsive gallery with built in prettyPhoto lightbox for big images.
|
40 |
* [RealSlider Module](http://codeasily.com/portfolio-item/gmedia-realslider/) is an image/video gallery slider module built on jQuery. RealSlider module is responsive and touch friendly gallery with 50+ options for customization.
|
41 |
* [Phantom Module](http://codeasily.com/portfolio-item/gmedia-phantom/) is the Wall/Grid Gallery with social sharing - you can easily change thumbnail sizes, colors, navigation, borders, add stylish labels to thumbnails ... and much more. PhotoSwipe like theme on touch devices.. only better.
|
42 |
* [PhotoBox Module](http://codeasily.com/portfolio-item/gmedia-photobox/) - a lightweight image gallery which uses only CSS3 for silky-smooth animations and transitions.
|
63 |
Features:
|
64 |
|
65 |
* (NEW) Gmedia for iOS - [iOS manage application](https://itunes.apple.com/ua/app/gmedia/id947515626?mt=8) to manage your Library with your iPhone
|
66 |
+
* (NEW) Full Page Template for Galleries with permalink support
|
67 |
+
* (NEW) Share Images, Albums, Tags, Galleries via admin panel
|
68 |
* Mobile friendly, responsive galleries
|
69 |
* Add tags, assign categories and group images in albums
|
70 |
* Drag'n'drop sorting for files in Album
|
77 |
* Import Wordpress Media Library files
|
78 |
* Uses WordPress' native Image Resizer
|
79 |
* Import files from server folder or from others gallery plugins
|
80 |
+
* Gmedia Cloud Pages - Full Window Gallery Templates (like GRAND Page in Flagallery) - you can copy gallery permalink or any items's permalink and insert it in the website menu
|
81 |
+
* Custom Templates for GmediaCloud pages (can be selected on Gmedia Settings page)
|
82 |
* Role/Capability Manager intergrated
|
83 |
* Statuses: public, private (only for logged in users), etc. for files, albums
|
84 |
* Batch operations with selected Gmedia items
|
86 |
|
87 |
TODO List:
|
88 |
|
89 |
+
* Create custom query filters with selected parameters (work in progress..)
|
90 |
* Cover for Album. It will be also used for music without cover (work in progress..)
|
91 |
+
* Duplicate item in Gmedia Library (work in progress..)
|
92 |
* More Batch operations with selected Gmedia items (work in progress..)
|
93 |
* Related Post images on Edit Post. Option to automatically create gallery in Post with related images (work in progress..)
|
94 |
* Share albums to socials from admin panel (in queue)
|
|
|
95 |
* More modules for creating photo gallery, audio playlist, video playlist
|
96 |
* Easily add to Post audio and video files with tags related to post tags
|
97 |
* Watermark feature
|
|
|
98 |
|
99 |
|
100 |
== Installation ==
|
124 |
|
125 |
== Changelog ==
|
126 |
|
127 |
+
= Modules Updated =
|
128 |
+
* Go to Gmedia Modules page and update installed premium modules to latest versions
|
129 |
+
|
130 |
+
= 1.5.91 =
|
131 |
+
* Fixed compatibility with PHP v5.2
|
132 |
+
* Small fixes and improvements
|
133 |
+
|
134 |
+
= 1.5.9 =
|
135 |
+
* Fixed Batch Edit -> Custom Link
|
136 |
+
* Added sitemap integration with WP SEO by Yoast plugin
|
137 |
+
* Small fixes and improvements
|
138 |
+
|
139 |
+
= 1.5.8 =
|
140 |
+
* Fixed Upload and Import now works with .htaccess which deny *.php direct access in wp-content folder
|
141 |
+
* Improved Album Sorting
|
142 |
+
* Added settings for default gmedia sorting in tags and categories (in modules)
|
143 |
+
* Added Screen Options for Galleries, Albums, Tags. Now you can sort terms in way you need on admin pages
|
144 |
+
* Added option to sort gmedia by filename
|
145 |
+
* Added "Views / Likes" (and ratings for audio) meta information to Gmedia Library
|
146 |
+
* Added setting to add own CSS to GmediaCloud page
|
147 |
+
* Small fixes and improvements
|
148 |
+
|
149 |
+
= 1.5.7 =
|
150 |
+
* New Mosaic Gallery Module
|
151 |
+
* Fixed javascript error on Gmedia Edit Gallery page
|
152 |
+
* Fixed generating json settings for some modules
|
153 |
+
* Fixed GmediaCloud json module settings
|
154 |
+
* Fixed: iOS application loads images without status
|
155 |
+
* Added Home and Back menu buttons to GmediaCloud pages
|
156 |
+
* Small fixes and improvements
|
157 |
+
|
158 |
+
= 1.5.6 =
|
159 |
+
* Added Settings option to change module for GmediaCloud Page
|
160 |
+
* Added Settings option to add analytics code for GmediaCloud Page
|
161 |
+
* Added Social Share buttons to GmediaCloud Page
|
162 |
+
* Fixed: iOS application loads images without status
|
163 |
+
* Small fixes and improvements
|
164 |
+
|
165 |
+
= 1.5.5 =
|
166 |
+
* Added Import IPTC Keywords to image tags
|
167 |
+
* Fixed deleting tags from selected items in Gmedia Library
|
168 |
+
* Fixed tags search while typing in combobox
|
169 |
+
* Modals with forms inside now not closing on keyboard Esc
|
170 |
+
* Small fixes and improvements
|
171 |
+
|
172 |
+
= 1.5.4 =
|
173 |
+
* Fixed RealSlider not playing selfhosted video (Update RealSlider to latest version too)
|
174 |
+
* Small fixes and improvements
|
175 |
+
|
176 |
+
= 1.5.3 =
|
177 |
+
* Fixed PhotoBox module not working
|
178 |
+
* Fixed VideoPlayer module not working
|
179 |
+
* Improved flush_rewrite_rules when plugin update
|
180 |
+
* Improved GmediaCloud Template Page
|
181 |
+
|
182 |
+
= 1.5.1 =
|
183 |
+
* Fixed css not loading for modules
|
184 |
+
|
185 |
+
= 1.5.0 =
|
186 |
+
* Changed permalinks for Gmedia pages
|
187 |
+
* Added Templates for Full Page Galleries and Single Template Page
|
188 |
+
* Added "Share GmediaCloud Page" option for items in Library, terms and galleries
|
189 |
+
* Added options for changing gmedia permalink base and salt for creating unique urls
|
190 |
+
* Added actions icons for albums, tags and galleries
|
191 |
+
* Added Meta Info popup for Library items
|
192 |
+
* Added Terms search by term ID (enter # before numbers separated by comma)
|
193 |
+
* Fixed Albums with deleted authors
|
194 |
+
* Admin CSS improvemens
|
195 |
|
196 |
= 1.4.2 =
|
197 |
* Fixed music and video Custom Cover when image url is set instead of ID
|
403 |
* More intuitive interface
|
404 |
* Backup before updating. After update plugin go to Manage Modules page and update modules to latest versions. Then check your galleries.
|
405 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
406 |
|
407 |
== Upgrade Notice ==
|
408 |
|
409 |
+
= 1.5.5 =
|
410 |
+
If you want to import IPTC Keywords to Tags for already uploaded images, you need:
|
411 |
+
1) Select images with IPTC Keywords in Gmedia Library
|
412 |
+
2) In Action menu choose "Update Metadata in Database"
|
413 |
+
3) In Action menu choose "Add Tags.." -> check "Import IPTC Keywords from selected images to Tags" -> click "Add Tags" button
|
414 |
+
|
415 |
= 0.9.6 =
|
416 |
Backup before updating.
|
417 |
After update plugin go to Manage Modules page and update modules to latest versions.
|
setup.php
CHANGED
@@ -12,16 +12,25 @@ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])){
|
|
12 |
*/
|
13 |
function gmedia_default_options(){
|
14 |
|
15 |
-
$gm['site_email'] =
|
16 |
$gm['site_category'] = '';
|
17 |
$gm['site_ID'] = '';
|
18 |
$gm['mobile_app'] = 0;
|
19 |
|
20 |
$gm['uninstall_dropdata'] = 'all'; // can be 'all', 'none', 'db'
|
21 |
|
|
|
|
|
|
|
|
|
|
|
22 |
$gm['isolation_mode'] = '0';
|
23 |
$gm['shortcode_raw'] = '0';
|
|
|
24 |
$gm['endpoint'] = 'gmedia';
|
|
|
|
|
|
|
25 |
|
26 |
$gm['gmedia_post_types_support'] = '';
|
27 |
|
@@ -34,8 +43,8 @@ function gmedia_default_options(){
|
|
34 |
$gm['folder']['application'] = 'application';
|
35 |
$gm['folder']['module'] = 'module';
|
36 |
|
37 |
-
$gm['thumb'] = array('width' => 300, 'height' => 300, 'quality' =>
|
38 |
-
$gm['image'] = array('width' =>
|
39 |
|
40 |
$gm['modules_xml'] = 'https://dl.dropboxusercontent.com/u/6295502/gmedia_modules/modules_v1.xml';
|
41 |
$gm['license_name'] = '';
|
@@ -78,10 +87,20 @@ function gmedia_default_options(){
|
|
78 |
$gm['taxonomies']['gmedia_gallery'] = array(); // not linked with gmedia_term_relationships table
|
79 |
$gm['taxonomies']['gmedia_module'] = array(); // not linked with gmedia_term_relationships table
|
80 |
|
|
|
|
|
81 |
$gm['gm_screen_options']['per_page_gmedia'] = 30;
|
82 |
$gm['gm_screen_options']['orderby_gmedia'] = 'ID';
|
83 |
$gm['gm_screen_options']['sortorder_gmedia'] = 'DESC';
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
$gm['gm_screen_options']['per_page_wpmedia'] = 30;
|
86 |
$gm['gm_screen_options']['orderby_wpmedia'] = 'ID';
|
87 |
$gm['gm_screen_options']['sortorder_wpmedia'] = 'DESC';
|
@@ -240,6 +259,10 @@ function gmedia_install(){
|
|
240 |
if(empty($gmGallery->options['installDate'])){
|
241 |
$gmGallery->options['installDate'] = time();
|
242 |
}
|
|
|
|
|
|
|
|
|
243 |
|
244 |
// set the default settings, if we didn't upgrade
|
245 |
if(empty($gmGallery->options)){
|
12 |
*/
|
13 |
function gmedia_default_options(){
|
14 |
|
15 |
+
$gm['site_email'] = '';
|
16 |
$gm['site_category'] = '';
|
17 |
$gm['site_ID'] = '';
|
18 |
$gm['mobile_app'] = 0;
|
19 |
|
20 |
$gm['uninstall_dropdata'] = 'all'; // can be 'all', 'none', 'db'
|
21 |
|
22 |
+
$gm['in_tag_orderby'] = 'ID';
|
23 |
+
$gm['in_tag_order'] = 'DESC';
|
24 |
+
$gm['in_category_orderby'] = 'ID';
|
25 |
+
$gm['in_category_order'] = 'DESC';
|
26 |
+
|
27 |
$gm['isolation_mode'] = '0';
|
28 |
$gm['shortcode_raw'] = '0';
|
29 |
+
|
30 |
$gm['endpoint'] = 'gmedia';
|
31 |
+
$gm['gmediacloud_module'] = '';
|
32 |
+
$gm['gmediacloud_footer_js'] = '';
|
33 |
+
$gm['gmediacloud_footer_css'] = '';
|
34 |
|
35 |
$gm['gmedia_post_types_support'] = '';
|
36 |
|
43 |
$gm['folder']['application'] = 'application';
|
44 |
$gm['folder']['module'] = 'module';
|
45 |
|
46 |
+
$gm['thumb'] = array('width' => 300, 'height' => 300, 'quality' => 80, 'crop' => 0);
|
47 |
+
$gm['image'] = array('width' => 2200, 'height' => 2200, 'quality' => 85, 'crop' => 0);
|
48 |
|
49 |
$gm['modules_xml'] = 'https://dl.dropboxusercontent.com/u/6295502/gmedia_modules/modules_v1.xml';
|
50 |
$gm['license_name'] = '';
|
87 |
$gm['taxonomies']['gmedia_gallery'] = array(); // not linked with gmedia_term_relationships table
|
88 |
$gm['taxonomies']['gmedia_module'] = array(); // not linked with gmedia_term_relationships table
|
89 |
|
90 |
+
$gm['gm_screen_options']['per_page_sort_gmedia'] = 60;
|
91 |
+
|
92 |
$gm['gm_screen_options']['per_page_gmedia'] = 30;
|
93 |
$gm['gm_screen_options']['orderby_gmedia'] = 'ID';
|
94 |
$gm['gm_screen_options']['sortorder_gmedia'] = 'DESC';
|
95 |
|
96 |
+
$gm['gm_screen_options']['per_page_gmedia_terms'] = 30;
|
97 |
+
$gm['gm_screen_options']['orderby_gmedia_terms'] = 'name';
|
98 |
+
$gm['gm_screen_options']['sortorder_gmedia_terms'] = 'DESC';
|
99 |
+
|
100 |
+
$gm['gm_screen_options']['per_page_gmedia_galleries'] = 30;
|
101 |
+
$gm['gm_screen_options']['orderby_gmedia_galleries'] = 'name';
|
102 |
+
$gm['gm_screen_options']['sortorder_gmedia_galleries'] = 'DESC';
|
103 |
+
|
104 |
$gm['gm_screen_options']['per_page_wpmedia'] = 30;
|
105 |
$gm['gm_screen_options']['orderby_wpmedia'] = 'ID';
|
106 |
$gm['gm_screen_options']['sortorder_wpmedia'] = 'DESC';
|
259 |
if(empty($gmGallery->options['installDate'])){
|
260 |
$gmGallery->options['installDate'] = time();
|
261 |
}
|
262 |
+
if(!get_option('GmediaHashID_salt')){
|
263 |
+
$ustr = wp_generate_password(12, false);
|
264 |
+
add_option('GmediaHashID_salt', $ustr);
|
265 |
+
}
|
266 |
|
267 |
// set the default settings, if we didn't upgrade
|
268 |
if(empty($gmGallery->options)){
|
template/album.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php get_gmedia_header();
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @var $gmedia
|
5 |
+
*/
|
6 |
+
?>
|
7 |
+
|
8 |
+
<header>
|
9 |
+
<menu class="gmedia-menu">
|
10 |
+
<?php gmediacloud_social_sharing();
|
11 |
+
$home_url = home_url();
|
12 |
+
?>
|
13 |
+
<div class="gmedia-menu-items">
|
14 |
+
<a href="<?php echo $home_url; ?>" class="btn" title="<?php echo esc_attr(get_bloginfo('name')); ?>"><i class="fa fa-home"><span><?php _e('Home', 'gmLang') ?></span></i></a>
|
15 |
+
<?php if(!empty($_SERVER['HTTP_REFERER']) && ($home_url != $_SERVER['HTTP_REFERER'])){
|
16 |
+
echo "<a href='{$_SERVER['HTTP_REFERER']}' class='btn'><i class='fa fa-arrow-left'><span>".__('Go Back', 'gmLang')."</span></i></a>";
|
17 |
+
} ?>
|
18 |
+
</div>
|
19 |
+
</menu>
|
20 |
+
<div class="gmedia-header-title"><?php the_gmedia_title(); ?></div>
|
21 |
+
<?php if($gmedia->description){ ?>
|
22 |
+
<div class="gmedia-header-description"><?php echo $gmedia->description; ?></div>
|
23 |
+
<span class="gmedia-header-description-button" onclick="jQuery('.gmedia-header-description').toggle()"></span>
|
24 |
+
<?php } ?>
|
25 |
+
</header>
|
26 |
+
|
27 |
+
<div class="gmedia-main-wrapper">
|
28 |
+
<?php the_gmedia_content(); ?>
|
29 |
+
</div>
|
30 |
+
|
31 |
+
<?php get_gmedia_footer(); ?>
|
template/category.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* only for default template */
|
3 |
+
add_action('gmedia_head', 'gmedia_default_template_styles');
|
4 |
+
|
5 |
+
/**
|
6 |
+
* @var $gmedia
|
7 |
+
* @var $gmGallery
|
8 |
+
*/
|
9 |
+
get_gmedia_header(); ?>
|
10 |
+
|
11 |
+
<header>
|
12 |
+
<menu class="gmedia-menu">
|
13 |
+
<?php gmediacloud_social_sharing();
|
14 |
+
$home_url = home_url();
|
15 |
+
?>
|
16 |
+
<div class="gmedia-menu-items">
|
17 |
+
<a href="<?php echo $home_url; ?>" class="btn" title="<?php echo esc_attr(get_bloginfo('name')); ?>"><i class="fa fa-home"><span><?php _e('Home', 'gmLang') ?></span></i></a>
|
18 |
+
<?php if(!empty($_SERVER['HTTP_REFERER']) && ($home_url != $_SERVER['HTTP_REFERER'])){
|
19 |
+
echo "<a href='{$_SERVER['HTTP_REFERER']}' class='btn'><i class='fa fa-arrow-left'><span>".__('Go Back', 'gmLang')."</span></i></a>";
|
20 |
+
} ?>
|
21 |
+
</div>
|
22 |
+
</menu>
|
23 |
+
<div class="gmedia-header-title"><?php the_gmedia_title(); ?></div>
|
24 |
+
</header>
|
25 |
+
<div class="gmedia-main-wrapper">
|
26 |
+
<?php
|
27 |
+
/**
|
28 |
+
* @var $gmedia_id
|
29 |
+
*/
|
30 |
+
the_gmedia_content();
|
31 |
+
?>
|
32 |
+
</div>
|
33 |
+
|
34 |
+
<?php get_gmedia_footer(); ?>
|
template/foot.php
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<?php gmedia_footer(); ?>
|
2 |
+
</body>
|
3 |
+
</html>
|
template/functions.php
ADDED
@@ -0,0 +1,476 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
//add_action('gmedia_head', 'gmediacloud_appbaner');
|
4 |
+
add_action('gmedia_head', 'gmediacloud_meta_generator');
|
5 |
+
add_action('gmedia_head', 'wp_print_styles', 1000);
|
6 |
+
add_action('gmedia_head', 'wp_print_head_scripts', 1000);
|
7 |
+
add_action('gmedia_footer', 'wp_print_styles');
|
8 |
+
add_action('gmedia_footer', 'print_footer_scripts');
|
9 |
+
add_action('gmedia_footer', 'wp_print_footer_scripts');
|
10 |
+
|
11 |
+
$gmedia_share_img = array( plugins_url(GMEDIA_FOLDER) . '/assets/icons/icon_gmedia_180.png' );
|
12 |
+
|
13 |
+
function gmediacloud_appbaner(){
|
14 |
+
global $gmedia_id, $gmedia_type;
|
15 |
+
if(in_array($gmedia_type, array('gallery', 'album', 'tag'))){
|
16 |
+
echo '<meta name="apple-itunes-app" content="app-id=947515626, app-argument=' . add_query_arg(array('type' => $gmedia_type, 'id' => $gmedia_id), trailingslashit(home_url())) . '">';
|
17 |
+
}
|
18 |
+
|
19 |
+
}
|
20 |
+
|
21 |
+
function gmediacloud_meta_generator(){
|
22 |
+
global $gmedia, $gmedia_type, $wp, $gmGallery, $gmCore, $gmedia_share_img;
|
23 |
+
$icon_url = plugins_url(GMEDIA_FOLDER) . '/assets/icons';
|
24 |
+
$current_url = home_url(add_query_arg(array(), $wp->request));
|
25 |
+
?>
|
26 |
+
<link href="<?php echo $icon_url; ?>/favicon.png" rel="shortcut icon"/>
|
27 |
+
<link href="<?php echo $icon_url; ?>/icon_gmedia_60.png" rel="apple-touch-icon"/>
|
28 |
+
<link href="<?php echo $icon_url; ?>/icon_gmedia_76.png" rel="apple-touch-icon" sizes="76x76"/>
|
29 |
+
<link href="<?php echo $icon_url; ?>/icon_gmedia_120.png" rel="apple-touch-icon" sizes="120x120"/>
|
30 |
+
<link href="<?php echo $icon_url; ?>/icon_gmedia_152.png" rel="apple-touch-icon" sizes="152x152"/>
|
31 |
+
<link href="<?php echo $icon_url; ?>/icon_gmedia_180.png" rel="apple-touch-icon" sizes="180x180"/>
|
32 |
+
|
33 |
+
<meta content="<?php the_gmedia_title(); ?>" property="og:title"/>
|
34 |
+
<meta content="<?php _e('Shared with GmediaGallery', 'gmLang'); ?>" property="og:description"/>
|
35 |
+
<?php if($gmedia_type != 'single'){
|
36 |
+
if(did_action('gmedia_shortcode')){
|
37 |
+
$og_imgs = array();
|
38 |
+
foreach($gmGallery->shortcode['gmedia'] as $items){
|
39 |
+
if(empty($items)){
|
40 |
+
continue;
|
41 |
+
}
|
42 |
+
$og_imgs[] = $gmCore->gm_get_media_image($items[0]->ID);
|
43 |
+
}
|
44 |
+
$gmedia_share_img = array_merge($og_imgs, $gmedia_share_img);
|
45 |
+
}
|
46 |
+
} else{
|
47 |
+
array_unshift($gmedia_share_img, $gmCore->gm_get_media_image($gmedia->ID));
|
48 |
+
}
|
49 |
+
foreach($gmedia_share_img as $og_image){
|
50 |
+
echo "<meta content='{$og_image}' property='og:image' />\n";
|
51 |
+
}
|
52 |
+
?>
|
53 |
+
<meta content="<?php echo $current_url; ?>" property="og:url"/>
|
54 |
+
<meta content="article" property="og:type"/>
|
55 |
+
<meta content="<?php bloginfo('name') ?>" property="og:site_name"/>
|
56 |
+
|
57 |
+
<meta content="<?php echo $icon_url; ?>/icon_gmedia_180.png" name="msapplication-TileImage"/>
|
58 |
+
<meta content="#ffffff" name="msapplication-TileColor"/>
|
59 |
+
<?php
|
60 |
+
}
|
61 |
+
|
62 |
+
function gmedia_head(){
|
63 |
+
global $wp_styles, $wp_scripts, $gmCore;
|
64 |
+
global $gmedia_id, $gmedia_type, $gmedia_shortcode_content;
|
65 |
+
|
66 |
+
do_action('wp_enqueue_scripts');
|
67 |
+
if($gmCore->_get('iframe')){
|
68 |
+
wp_deregister_script('swfaddress');
|
69 |
+
add_filter('show_admin_bar', '__return_false');
|
70 |
+
}
|
71 |
+
$wp_styles->queue = array();
|
72 |
+
$wp_scripts->queue = array();
|
73 |
+
|
74 |
+
if(is_admin_bar_showing()){
|
75 |
+
add_action('gmedia_head', 'wp_admin_bar_header', 0);
|
76 |
+
add_action('gmedia_head', '_admin_bar_bump_cb', 0);
|
77 |
+
add_action('gmedia_head', '_wp_admin_bar_init');
|
78 |
+
add_action('gmedia_footer', 'wp_admin_bar_render', 1000);
|
79 |
+
}
|
80 |
+
|
81 |
+
$gmedia_shortcode_content = get_the_gmedia_content($gmedia_id, $gmedia_type);
|
82 |
+
|
83 |
+
do_action('gmedia_head');
|
84 |
+
}
|
85 |
+
|
86 |
+
function gmedia_footer(){
|
87 |
+
global $gmGallery;
|
88 |
+
|
89 |
+
do_action('gmedia_footer');
|
90 |
+
|
91 |
+
if(!empty($gmGallery->options['gmediacloud_footer_css'])){
|
92 |
+
$css_code = stripslashes($gmGallery->options['gmediacloud_footer_css']);
|
93 |
+
echo "\n<style type=\"text/css\">\n{$css_code}\n</style>\n";
|
94 |
+
}
|
95 |
+
if(!empty($gmGallery->options['gmediacloud_footer_js'])){
|
96 |
+
$js_code = stripslashes($gmGallery->options['gmediacloud_footer_js']);
|
97 |
+
echo "\n<script type=\"text/javascript\">\n{$js_code}\n</script>\n";
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* @param string $sep
|
103 |
+
* @param bool $display
|
104 |
+
*
|
105 |
+
* @return string|void
|
106 |
+
*/
|
107 |
+
function gmedia_title($sep = '|', $display = true){
|
108 |
+
global $gmedia, $gmedia_type, $gmGallery;
|
109 |
+
|
110 |
+
$_title = __('GmediaGallery', 'gmLang');
|
111 |
+
if(is_object($gmedia) && !is_wp_error($gmedia)){
|
112 |
+
if(in_array($gmedia_type, array('gallery', 'album', 'tag'))){
|
113 |
+
$_title = $gmedia->name;
|
114 |
+
} elseif('category' == $gmedia_type){
|
115 |
+
$gm_terms_all = $gmGallery->options['taxonomies']['gmedia_category'];
|
116 |
+
$_title = $gm_terms_all[$gmedia->name];
|
117 |
+
} elseif('single' == $gmedia_type){
|
118 |
+
$_title = $gmedia->title;
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
$title[] = $_title;
|
123 |
+
|
124 |
+
if(current_theme_supports('title-tag')){
|
125 |
+
$title[] = get_bloginfo('name', 'display');
|
126 |
+
}
|
127 |
+
|
128 |
+
$title = implode(" $sep ", $title);
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Filter the text of the gmedia title.
|
132 |
+
*
|
133 |
+
* @param string $title Page title.
|
134 |
+
* @param string $sep Title separator.
|
135 |
+
*/
|
136 |
+
$title = apply_filters('gmedia_title', $title, $sep);
|
137 |
+
|
138 |
+
// Send it out
|
139 |
+
if($display){
|
140 |
+
echo $title;
|
141 |
+
} else{
|
142 |
+
return $title;
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* @param bool $return
|
148 |
+
*
|
149 |
+
* @return mixed|string|void
|
150 |
+
*/
|
151 |
+
function the_gmedia_title($return = false){
|
152 |
+
global $gmedia, $gmedia_type, $gmGallery;
|
153 |
+
|
154 |
+
$title = __('GmediaGallery', 'gmLang');
|
155 |
+
if(is_object($gmedia) && !is_wp_error($gmedia)){
|
156 |
+
if(in_array($gmedia_type, array('gallery', 'album', 'tag'))){
|
157 |
+
$title = $gmedia->name;
|
158 |
+
} elseif('category' == $gmedia_type){
|
159 |
+
$gm_terms_all = $gmGallery->options['taxonomies']['gmedia_category'];
|
160 |
+
$title = $gm_terms_all[$gmedia->name];
|
161 |
+
} elseif('single' == $gmedia_type){
|
162 |
+
$title = $gmedia->title;
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
/**
|
167 |
+
* Filter the text of the gmedia title.
|
168 |
+
*
|
169 |
+
* @param string $title Page title.
|
170 |
+
* @param string $sep Title separator.
|
171 |
+
*/
|
172 |
+
$title = apply_filters('the_gmedia_title', $title);
|
173 |
+
|
174 |
+
if($return){
|
175 |
+
return $title;
|
176 |
+
} else{
|
177 |
+
echo $title;
|
178 |
+
}
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* @param $classes
|
183 |
+
*
|
184 |
+
* @return array
|
185 |
+
*/
|
186 |
+
function gmedia_body_class($classes){
|
187 |
+
global $gmedia_type;
|
188 |
+
$classes = array_merge($classes, array('gmedia-template', "gmedia-template-{$gmedia_type}"));
|
189 |
+
if(wp_is_mobile()){
|
190 |
+
$classes[] = 'is_mobile';
|
191 |
+
}
|
192 |
+
$classes = apply_filters('gmedia_body_class', $classes);
|
193 |
+
|
194 |
+
return (array) $classes;
|
195 |
+
}
|
196 |
+
|
197 |
+
add_filter('body_class', 'gmedia_body_class');
|
198 |
+
|
199 |
+
function get_gmedia_header(){
|
200 |
+
global $gmedia_module, $gmedia_id, $gmedia_type, $gmCore;
|
201 |
+
$module = $gmCore->get_module_path($gmedia_module);
|
202 |
+
if(file_exists($module['path'] . '/template/head.php')){
|
203 |
+
include_once($module['path'] . '/template/head.php');
|
204 |
+
} else{
|
205 |
+
if('single' == $gmedia_type){
|
206 |
+
add_filter('show_admin_bar', '__return_false');
|
207 |
+
}
|
208 |
+
include_once(GMEDIA_ABSPATH . 'template/head.php');
|
209 |
+
}
|
210 |
+
}
|
211 |
+
|
212 |
+
function get_gmedia_footer(){
|
213 |
+
global $gmedia_module, $gmedia_id, $gmedia_type, $gmCore;
|
214 |
+
$module = $gmCore->get_module_path($gmedia_module);
|
215 |
+
if(file_exists($module['path'] . '/template/foot.php')){
|
216 |
+
include_once($module['path'] . '/template/foot.php');
|
217 |
+
} else{
|
218 |
+
include_once(GMEDIA_ABSPATH . 'template/foot.php');
|
219 |
+
}
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* @param $gmedia_id
|
224 |
+
* @param $gmedia_type
|
225 |
+
*
|
226 |
+
* @param null $gmedia_module
|
227 |
+
* @param null $gmedia_module_preset
|
228 |
+
*
|
229 |
+
* @return string
|
230 |
+
*/
|
231 |
+
function get_the_gmedia_content($gmedia_id, $gmedia_type, $gmedia_module = null, $gmedia_module_preset = null){
|
232 |
+
global $user_ID, $gmCore;
|
233 |
+
|
234 |
+
if(!$gmedia_module){
|
235 |
+
global $gmedia_module;
|
236 |
+
}
|
237 |
+
if(!$gmedia_module_preset){
|
238 |
+
global $gmedia_module_preset;
|
239 |
+
}
|
240 |
+
|
241 |
+
$content = '';
|
242 |
+
if(in_array($gmedia_type, array('gallery', 'album', 'tag', 'category'))){
|
243 |
+
$atts = array(
|
244 |
+
'id' => $gmedia_id,
|
245 |
+
'set_module' => ($user_ID? $gmCore->_get('set_module', $gmedia_module) : $gmedia_module),
|
246 |
+
'preset' => ($user_ID? $gmCore->_get('preset', $gmedia_module_preset) : $gmedia_module_preset),
|
247 |
+
'_tax' => $gmedia_type
|
248 |
+
);
|
249 |
+
$content = gmedia_shortcode($atts);
|
250 |
+
do_action('gmedia_enqueue_scripts');
|
251 |
+
}
|
252 |
+
|
253 |
+
return $content;
|
254 |
+
}
|
255 |
+
|
256 |
+
function the_gmedia_content(){
|
257 |
+
global $gmedia_shortcode_content;
|
258 |
+
echo $gmedia_shortcode_content;
|
259 |
+
}
|
260 |
+
|
261 |
+
function gmediacloud_social_sharing(){
|
262 |
+
|
263 |
+
if(apply_filters('gmediacloud_social_sharing', wp_is_mobile())){
|
264 |
+
return;
|
265 |
+
}
|
266 |
+
|
267 |
+
global $wp, $gmedia_share_img;
|
268 |
+
|
269 |
+
$url =urlencode(home_url(add_query_arg(array(), $wp->request)));
|
270 |
+
$text =urlencode(__('Shared with GmediaGallery', 'gmLang'));
|
271 |
+
$title =urlencode(the_gmedia_title(true));
|
272 |
+
$image =urlencode($gmedia_share_img[0]);
|
273 |
+
?>
|
274 |
+
<style>
|
275 |
+
@import url('//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css') all;
|
276 |
+
.gmedia-socialsharebuttons { float:right; margin-right:30px; margin-top:2px; }
|
277 |
+
.share-btn,
|
278 |
+
.share-btn:visited {
|
279 |
+
display: inline-block;
|
280 |
+
color: #ffffff;
|
281 |
+
border: none;
|
282 |
+
padding: 2px 7px;
|
283 |
+
min-width:2.1em;
|
284 |
+
opacity: 0.9;
|
285 |
+
box-shadow: 0 2px 0 0 rgba(0,0,0,0.2);
|
286 |
+
outline: none;
|
287 |
+
text-align: center;
|
288 |
+
box-sizing: border-box;
|
289 |
+
}
|
290 |
+
.share-btn:hover {
|
291 |
+
color: #eeeeee;
|
292 |
+
}
|
293 |
+
.share-btn:active {
|
294 |
+
position: relative;
|
295 |
+
top: 2px;
|
296 |
+
box-shadow: none;
|
297 |
+
color: #e2e2e2;
|
298 |
+
outline: none;
|
299 |
+
}
|
300 |
+
.fa span { display:none; }
|
301 |
+
.share-btn.facebook { background: #3B5998; }
|
302 |
+
.share-btn.twitter { background: #55acee; }
|
303 |
+
.share-btn.google-plus { background: #dd4b39; }
|
304 |
+
.share-btn.pinterest-p { background: #cb2027; }
|
305 |
+
.share-btn.vk { background:#2a6db4; }
|
306 |
+
.share-btn.email { background: #444444; }
|
307 |
+
</style>
|
308 |
+
<div class="gmedia-socialsharebuttons">
|
309 |
+
<!-- Facebook -->
|
310 |
+
<a href="http://www.facebook.com/sharer/sharer.php?u=<?php echo $url; ?>&t=<?php echo $title; ?>" target="_blank" class="share-btn facebook">
|
311 |
+
<i class="fa fa-facebook"><span>Facebook</span></i>
|
312 |
+
</a>
|
313 |
+
<!-- Twitter -->
|
314 |
+
<a href="http://twitter.com/share?url=<?php echo $url; ?>&text=<?php echo $text; ?>" target="_blank" class="share-btn twitter">
|
315 |
+
<i class="fa fa-twitter"><span>Twitter</span></i>
|
316 |
+
</a>
|
317 |
+
<!-- Google Plus -->
|
318 |
+
<a href="https://plus.google.com/share?url=<?php echo $url; ?>" target="_blank" class="share-btn google-plus">
|
319 |
+
<i class="fa fa-google-plus"><span>Google+</span></i>
|
320 |
+
</a>
|
321 |
+
<!-- Pinterest -->
|
322 |
+
<a href="http://pinterest.com/pin/create/button/?url=<?php echo $url; ?>&description=<?php echo $text; ?>&media=<?php echo $image; ?>" target="_blank" class="share-btn pinterest-p">
|
323 |
+
<i class="fa fa-pinterest-p"><span>Pinterest</span></i>
|
324 |
+
</a>
|
325 |
+
<!-- VK -->
|
326 |
+
<a href="http://vk.com/share.php?url=<?php echo $url; ?>" target="_blank" class="share-btn vk">
|
327 |
+
<i class="fa fa-vk"><span>VK</span></i>
|
328 |
+
</a>
|
329 |
+
<!-- Email -->
|
330 |
+
<a href="mailto:?subject=<?php echo $title; ?>&body=<?php echo $url; ?>" target="_blank" class="share-btn email">
|
331 |
+
<i class="fa fa-envelope"><span>Email</span></i>
|
332 |
+
</a>
|
333 |
+
</div>
|
334 |
+
<?php
|
335 |
+
}
|
336 |
+
|
337 |
+
function gmedia_default_template_styles(){ ?>
|
338 |
+
<style type="text/css" media="screen">
|
339 |
+
* { box-sizing:border-box; }
|
340 |
+
body { font-family:"Arial", "Verdana", serif; font-size:13px; }
|
341 |
+
header { position:relative; min-height:30px; background-color:#0f0f0f; color:#f1f1f1; padding:5px 0 3px 30px; font-family:"Arial", "Verdana", serif; z-index:10; }
|
342 |
+
header.has-description { padding-right:30px; }
|
343 |
+
.gmedia-header-title { display:inline-block; font-size:16px; vertical-align:bottom; margin-top:2px; }
|
344 |
+
.gmedia-header-description { position:absolute; top:100%; left:0; right:0; font-size:13px; overflow:visible; background-color:#0f0f0f; padding:10px 30px; border-bottom:1px solid #444444; }
|
345 |
+
.gmedia-header-description { display:none; }
|
346 |
+
.gmedia-header-description-button {
|
347 |
+
position:absolute;
|
348 |
+
top:5px;
|
349 |
+
right:15px;
|
350 |
+
width:18px;
|
351 |
+
height:20px;
|
352 |
+
background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxNi4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+DQo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IiB3aWR0aD0iNTEycHgiIGhlaWdodD0iNTEycHgiIHZpZXdCb3g9IjAgMCA1MTIgNTEyIiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCA1MTIgNTEyIiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxwYXRoIGZpbGw9IiNGRkZGRkYiIGQ9Ik0yOTMuNzUxLDQ1NS44NjhjLTIwLjE4MSwyMC4xNzktNTMuMTY1LDE5LjkxMy03My42NzMtMC41OTVsMCwwYy0yMC41MDgtMjAuNTA4LTIwLjc3My01My40OTMtMC41OTQtNzMuNjcyICBsMTg5Ljk5OS0xOTBjMjAuMTc4LTIwLjE3OCw1My4xNjQtMTkuOTEzLDczLjY3MiwwLjU5NWwwLDBjMjAuNTA4LDIwLjUwOSwyMC43NzIsNTMuNDkyLDAuNTk1LDczLjY3MUwyOTMuNzUxLDQ1NS44Njh6Ii8+DQo8cGF0aCBmaWxsPSIjRkZGRkZGIiBkPSJNMjIwLjI0OSw0NTUuODY4YzIwLjE4LDIwLjE3OSw1My4xNjQsMTkuOTEzLDczLjY3Mi0wLjU5NWwwLDBjMjAuNTA5LTIwLjUwOCwyMC43NzQtNTMuNDkzLDAuNTk2LTczLjY3MiAgbC0xOTAtMTkwYy0yMC4xNzgtMjAuMTc4LTUzLjE2NC0xOS45MTMtNzMuNjcxLDAuNTk1bDAsMGMtMjAuNTA4LDIwLjUwOS0yMC43NzIsNTMuNDkyLTAuNTk1LDczLjY3MUwyMjAuMjQ5LDQ1NS44Njh6Ii8+DQo8L3N2Zz4=);
|
353 |
+
background-size:contain;
|
354 |
+
cursor:pointer;
|
355 |
+
}
|
356 |
+
.gmedia-menu { float:right; margin:0; padding:0; }
|
357 |
+
.gmedia-menu .gmedia-menu-items { margin-right:30px; float:right; margin-top:2px; }
|
358 |
+
.gmedia-menu .gmedia-menu-items a,
|
359 |
+
.gmedia-menu .gmedia-menu-items a:visited {
|
360 |
+
display: inline-block;
|
361 |
+
color: #ffffff;
|
362 |
+
background: #444444;
|
363 |
+
border: none;
|
364 |
+
padding: 2px 7px;
|
365 |
+
min-width:2.1em;
|
366 |
+
opacity: 0.9;
|
367 |
+
box-shadow: 0 2px 0 0 rgba(0,0,0,0.2);
|
368 |
+
outline: none;
|
369 |
+
text-align: center;
|
370 |
+
box-sizing: border-box;
|
371 |
+
text-decoration:none;
|
372 |
+
}
|
373 |
+
.gmedia-menu .gmedia-menu-items a i span { font-style:normal; }
|
374 |
+
.gmedia-menu .gmedia-menu-items a:hover { color:#eeeeee; }
|
375 |
+
.gmedia-menu .gmedia-menu-items a:active {
|
376 |
+
position: relative;
|
377 |
+
top: 2px;
|
378 |
+
box-shadow: none;
|
379 |
+
color: #e2e2e2;
|
380 |
+
outline: none;
|
381 |
+
}
|
382 |
+
|
383 |
+
.gmedia-main-wrapper {
|
384 |
+
position:absolute;
|
385 |
+
top:30px; left:0; right:0; bottom:0;
|
386 |
+
overflow:auto;
|
387 |
+
}
|
388 |
+
body.gmedia-template-single .gmedia-main-wrapper,
|
389 |
+
body.is_mobile .gmedia-main-wrapper {
|
390 |
+
position:absolute;
|
391 |
+
top:30px; left:0; right:0; bottom:auto;
|
392 |
+
overflow:visible;
|
393 |
+
}
|
394 |
+
body.admin-bar .gmedia-main-wrapper {
|
395 |
+
top:62px;
|
396 |
+
}
|
397 |
+
.gmedia-main-wrapper .gmedia_gallery {
|
398 |
+
width:100%;
|
399 |
+
height:100%;
|
400 |
+
text-align:center;
|
401 |
+
}
|
402 |
+
body.is_mobile .gmedia-main-wrapper .gmedia_gallery {
|
403 |
+
height:auto;
|
404 |
+
}
|
405 |
+
.gmedia-main-wrapper .gmedia_gallery > div {
|
406 |
+
margin-left:auto;
|
407 |
+
margin-right:auto;
|
408 |
+
text-align:left;
|
409 |
+
}
|
410 |
+
.gmedia-main-wrapper .gmedia_gallery.is_mobile {
|
411 |
+
height:auto;
|
412 |
+
min-height:100%;
|
413 |
+
}
|
414 |
+
.gmedia-main-wrapper object {
|
415 |
+
width:100% !important;
|
416 |
+
height:100% !important;
|
417 |
+
}
|
418 |
+
a { color:#2e6286; text-decoration:underline; }
|
419 |
+
a:hover, a:active, a:visited { color:#2e6286; text-decoration:none; }
|
420 |
+
body.gmedia-template-single { background-color:#bbbbbb; }
|
421 |
+
.single-view { max-width:1280px; min-width:320px; padding:10px 10px 20px; margin:0 auto; }
|
422 |
+
.single-view img { max-width:100%; height:auto; }
|
423 |
+
.single-title { font-size:18px; font-weight:bold; }
|
424 |
+
.type-download .single-title { font-size:18px; }
|
425 |
+
.image-description { text-align:left }
|
426 |
+
.gmedia-no-files { text-align:center; font-size:16px; padding:30px 10px; }
|
427 |
+
.gmediaShortcodeError { text-align:left; font-size:14px; padding:30px 10px; }
|
428 |
+
@media screen and ( max-width:782px ) {
|
429 |
+
body.admin-bar .gmedia-main-wrapper {
|
430 |
+
top:76px;
|
431 |
+
}
|
432 |
+
}
|
433 |
+
</style>
|
434 |
+
<?php }
|
435 |
+
|
436 |
+
function gmedia_video_head_scripts(){
|
437 |
+
wp_enqueue_style('mediaelement');
|
438 |
+
wp_enqueue_script('mediaelement');
|
439 |
+
}
|
440 |
+
|
441 |
+
function gmedia_video_foot_scripts(){ ?>
|
442 |
+
<script type="text/javascript">
|
443 |
+
jQuery(function($){
|
444 |
+
var video = $("video");
|
445 |
+
|
446 |
+
function video_responsive(){
|
447 |
+
var vw = video.width(),
|
448 |
+
vh = video.height(),
|
449 |
+
r = vw / vh,
|
450 |
+
bw = $(window).width(),
|
451 |
+
bh = $(window).height(),
|
452 |
+
mar = 0;
|
453 |
+
if(r > bw / bh){
|
454 |
+
vh = bw / r;
|
455 |
+
vw = bw;
|
456 |
+
mar = (bh - vh) / 2;
|
457 |
+
mar = (mar > 0)? mar + "px 0 0 0" : "0";
|
458 |
+
} else{
|
459 |
+
vw = bh * r;
|
460 |
+
vh = bh;
|
461 |
+
mar = (bh - vh) / 2;
|
462 |
+
mar = (mar > 0)? "0 0 0 " + mar + "px" : "0";
|
463 |
+
}
|
464 |
+
$("body").css({margin: mar});
|
465 |
+
video.attr("width", vw).attr("height", vh);
|
466 |
+
}
|
467 |
+
|
468 |
+
video_responsive();
|
469 |
+
$(window).on("resize", function(){
|
470 |
+
video_responsive();
|
471 |
+
});
|
472 |
+
video.mediaelementplayer();
|
473 |
+
});
|
474 |
+
</script>
|
475 |
+
<?php
|
476 |
+
}
|
template/gallery.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php get_gmedia_header();
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @var $gmedia
|
5 |
+
*/
|
6 |
+
?>
|
7 |
+
|
8 |
+
<header<?php if($gmedia->description){ echo ' class="has-description"'; }?>>
|
9 |
+
<menu class="gmedia-menu">
|
10 |
+
<?php gmediacloud_social_sharing();
|
11 |
+
$home_url = home_url();
|
12 |
+
?>
|
13 |
+
<div class="gmedia-menu-items">
|
14 |
+
<a href="<?php echo $home_url; ?>" class="btn" title="<?php echo esc_attr(get_bloginfo('name')); ?>"><i class="fa fa-home"><span><?php _e('Home', 'gmLang') ?></span></i></a>
|
15 |
+
<?php if(!empty($_SERVER['HTTP_REFERER']) && ($home_url != $_SERVER['HTTP_REFERER'])){
|
16 |
+
echo "<a href='{$_SERVER['HTTP_REFERER']}' class='btn'><i class='fa fa-arrow-left'><span>".__('Go Back', 'gmLang')."</span></i></a>";
|
17 |
+
} ?>
|
18 |
+
</div>
|
19 |
+
</menu>
|
20 |
+
<div class="gmedia-header-title"><?php the_gmedia_title(); ?></div>
|
21 |
+
<?php if($gmedia->description){ ?>
|
22 |
+
<div class="gmedia-header-description"><?php echo $gmedia->description; ?></div>
|
23 |
+
<span class="gmedia-header-description-button" onclick="jQuery('.gmedia-header-description').toggle()"></span>
|
24 |
+
<?php } ?>
|
25 |
+
</header>
|
26 |
+
|
27 |
+
<div class="gmedia-main-wrapper">
|
28 |
+
<?php the_gmedia_content(); ?>
|
29 |
+
</div>
|
30 |
+
|
31 |
+
<?php get_gmedia_footer(); ?>
|
template/head.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html <?php language_attributes(); ?> class="no-js">
|
3 |
+
<head>
|
4 |
+
<meta charset="<?php bloginfo('charset'); ?>">
|
5 |
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6 |
+
<title><?php gmedia_title('|', true); ?></title>
|
7 |
+
<link rel="profile" href="http://gmpg.org/xfn/11">
|
8 |
+
|
9 |
+
<style type="text/css">
|
10 |
+
body { margin:0; padding:0; }
|
11 |
+
</style>
|
12 |
+
<script>(function(){document.documentElement.className = 'js'})();</script>
|
13 |
+
<?php gmedia_head(); ?>
|
14 |
+
</head>
|
15 |
+
<body <?php body_class(); ?>>
|
template/single.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php get_gmedia_header();
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @var $gmedia
|
5 |
+
*/
|
6 |
+
?>
|
7 |
+
|
8 |
+
<header>
|
9 |
+
<menu class="gmedia-menu">
|
10 |
+
<?php gmediacloud_social_sharing();
|
11 |
+
$home_url = home_url();
|
12 |
+
?>
|
13 |
+
<div class="gmedia-menu-items">
|
14 |
+
<a href="<?php echo $home_url; ?>" class="btn" title="<?php echo esc_attr(get_bloginfo('name')); ?>"><i class="fa fa-home"><span><?php _e('Home', 'gmLang') ?></span></i></a>
|
15 |
+
<?php if(!empty($_SERVER['HTTP_REFERER']) && ($home_url != $_SERVER['HTTP_REFERER'])){
|
16 |
+
echo "<a href='{$_SERVER['HTTP_REFERER']}' class='btn'><i class='fa fa-arrow-left'><span>".__('Go Back', 'gmLang')."</span></i></a>";
|
17 |
+
} ?>
|
18 |
+
</div>
|
19 |
+
</menu>
|
20 |
+
<div class="gmedia-header-title"><?php the_gmedia_title(); ?></div>
|
21 |
+
</header>
|
22 |
+
|
23 |
+
<div class="gmedia-main-wrapper">
|
24 |
+
<?php
|
25 |
+
/**
|
26 |
+
* @var $gmCore
|
27 |
+
* @var $gmDB
|
28 |
+
* @var $gmGallery
|
29 |
+
*/
|
30 |
+
$type = explode('/', $gmedia->mime_type, 2);
|
31 |
+
if('image' == $type[0]){ ?>
|
32 |
+
<div class="single-view type-image">
|
33 |
+
<img class="gmedia-image" src="<?php echo $gmCore->gm_get_media_image($gmedia->ID); ?>">
|
34 |
+
<div class="gmedia-text">
|
35 |
+
<h2 class="single-title"><?php echo $gmedia->title; ?></h2>
|
36 |
+
<div class="image-description"><?php echo wpautop($gmedia->description); ?></div>
|
37 |
+
</div>
|
38 |
+
</div>
|
39 |
+
<?php } else{ ?>
|
40 |
+
<div class="single-view type-download type-<?php echo $type[0]; ?>">
|
41 |
+
<img class="gmedia-image" src="<?php echo $gmCore->gm_get_media_image($gmedia->ID); ?>">
|
42 |
+
<div class="gmedia-text">
|
43 |
+
<h2 class="single-title"><?php _e('Download', 'gmLang'); ?>: <a href="<?php echo "{$gmCore->upload['url']}/{$gmGallery->options['folder'][$type[0]]}/{$gmedia->gmuid}"; ?>" download="download"><?php echo $gmedia->title; ?></a></h2>
|
44 |
+
<div class="image-description"><?php echo wpautop($gmedia->description); ?></div>
|
45 |
+
</div>
|
46 |
+
</div>
|
47 |
+
<?php } /*elseif('video' == $type[0]){
|
48 |
+
$meta = $gmDB->get_metadata('gmedia', $gmedia->ID, '_metadata', true);
|
49 |
+
$width = isset($meta['width'])? $meta['width'] : 640;
|
50 |
+
$height = isset($meta['height'])? $meta['height'] : 480;
|
51 |
+
$url = $gmCore->fileinfo($gmedia->gmuid, false);
|
52 |
+
?>
|
53 |
+
<div class="single-view type-video">
|
54 |
+
<video src="<?php echo $url['fileurl']; ?>" width="<?php echo $width; ?>" height="<?php echo $height; ?>"></video>
|
55 |
+
</div>
|
56 |
+
<?php }*/ ?>
|
57 |
+
</div>
|
58 |
+
|
59 |
+
<?php get_gmedia_footer(); ?>
|
template/tag.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* only for default template */
|
3 |
+
add_action('gmedia_head', 'gmedia_default_template_styles');
|
4 |
+
|
5 |
+
/**
|
6 |
+
* @var $gmedia
|
7 |
+
*/
|
8 |
+
get_gmedia_header(); ?>
|
9 |
+
|
10 |
+
<header>
|
11 |
+
<menu class="gmedia-menu">
|
12 |
+
<?php gmediacloud_social_sharing();
|
13 |
+
$home_url = home_url();
|
14 |
+
?>
|
15 |
+
<div class="gmedia-menu-items">
|
16 |
+
<a href="<?php echo $home_url; ?>" class="btn" title="<?php echo esc_attr(get_bloginfo('name')); ?>"><i class="fa fa-home"><span><?php _e('Home', 'gmLang') ?></span></i></a>
|
17 |
+
<?php if(!empty($_SERVER['HTTP_REFERER']) && ($home_url != $_SERVER['HTTP_REFERER'])){
|
18 |
+
echo "<a href='{$_SERVER['HTTP_REFERER']}' class='btn'><i class='fa fa-arrow-left'><span>".__('Go Back', 'gmLang')."</span></i></a>";
|
19 |
+
} ?>
|
20 |
+
</div>
|
21 |
+
</menu>
|
22 |
+
<div class="gmedia-header-title"><?php the_gmedia_title(); ?></div>
|
23 |
+
</header>
|
24 |
+
<div class="gmedia-main-wrapper">
|
25 |
+
<?php
|
26 |
+
/**
|
27 |
+
* @var $gmedia_id
|
28 |
+
*/
|
29 |
+
the_gmedia_content();
|
30 |
+
?>
|
31 |
+
</div>
|
32 |
+
|
33 |
+
<?php get_gmedia_footer(); ?>
|
uninstall.php
CHANGED
@@ -65,6 +65,7 @@ function gmedia_uninstall(){
|
|
65 |
delete_option('gmediaOptions');
|
66 |
delete_option('gmediaDbVersion');
|
67 |
delete_option('gmediaVersion');
|
|
|
68 |
delete_metadata('user', 0, 'gm_screen_options', '', true);
|
69 |
|
70 |
if(!$upload['error']){
|
65 |
delete_option('gmediaOptions');
|
66 |
delete_option('gmediaDbVersion');
|
67 |
delete_option('gmediaVersion');
|
68 |
+
delete_option('GmediaHashID_salt');
|
69 |
delete_metadata('user', 0, 'gm_screen_options', '', true);
|
70 |
|
71 |
if(!$upload['error']){
|
update.php
CHANGED
@@ -228,7 +228,6 @@ window.onload = function() {
|
|
228 |
wp_ob_end_flush_all();
|
229 |
|
230 |
update_option("gmediaDbVersion", GMEDIA_DBVERSION);
|
231 |
-
update_option("gmediaVersion", GMEDIA_VERSION);
|
232 |
|
233 |
echo '<p>' . __('GmediaGallery plugin update complete.', 'gmLang') . '</p>';
|
234 |
|
@@ -426,6 +425,11 @@ function gmedia_images_update($files){
|
|
426 |
wp_ob_end_flush_all();
|
427 |
}
|
428 |
|
|
|
|
|
|
|
|
|
|
|
429 |
function gmedia_quite_update(){
|
430 |
global $gmCore, $gmGallery;
|
431 |
$current_version = get_option('gmediaVersion', null);
|
@@ -456,10 +460,19 @@ function gmedia_quite_update(){
|
|
456 |
gmedia_capabilities();
|
457 |
}
|
458 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
459 |
$gmCore->delete_folder($gmCore->upload['path'] . '/module/afflux');
|
460 |
$gmCore->delete_folder($gmCore->upload['path'] . '/module/jq-mplayer');
|
461 |
$gmCore->delete_folder($gmCore->upload['path'] . '/module/minima');
|
462 |
$gmCore->delete_folder($gmCore->upload['path'] . '/module/phantom');
|
463 |
$gmCore->delete_folder($gmCore->upload['path'] . '/module/wp-videoplayer');
|
|
|
|
|
464 |
}
|
465 |
}
|
228 |
wp_ob_end_flush_all();
|
229 |
|
230 |
update_option("gmediaDbVersion", GMEDIA_DBVERSION);
|
|
|
231 |
|
232 |
echo '<p>' . __('GmediaGallery plugin update complete.', 'gmLang') . '</p>';
|
233 |
|
425 |
wp_ob_end_flush_all();
|
426 |
}
|
427 |
|
428 |
+
function gmedia_flush_rewrite_rules(){
|
429 |
+
flush_rewrite_rules(false);
|
430 |
+
}
|
431 |
+
|
432 |
+
|
433 |
function gmedia_quite_update(){
|
434 |
global $gmCore, $gmGallery;
|
435 |
$current_version = get_option('gmediaVersion', null);
|
460 |
gmedia_capabilities();
|
461 |
}
|
462 |
|
463 |
+
if(version_compare($current_version, '1.4.4', '<')){
|
464 |
+
if(!get_option('GmediaHashID_salt')){
|
465 |
+
$ustr = wp_generate_password(12, false);
|
466 |
+
add_option('GmediaHashID_salt', $ustr);
|
467 |
+
}
|
468 |
+
}
|
469 |
+
|
470 |
$gmCore->delete_folder($gmCore->upload['path'] . '/module/afflux');
|
471 |
$gmCore->delete_folder($gmCore->upload['path'] . '/module/jq-mplayer');
|
472 |
$gmCore->delete_folder($gmCore->upload['path'] . '/module/minima');
|
473 |
$gmCore->delete_folder($gmCore->upload['path'] . '/module/phantom');
|
474 |
$gmCore->delete_folder($gmCore->upload['path'] . '/module/wp-videoplayer');
|
475 |
+
|
476 |
+
update_option("gmediaVersion", GMEDIA_VERSION);
|
477 |
}
|
478 |
}
|