PluginProbe
Gallery – Photo Albums Plugin / trunk
Gallery – Photo Albums Plugin vtrunk
trunk 1.0.0 1.1.0 1.1.1 1.1.3 1.1.5 1.1.7 1.1.9 1.2.0 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.20 1.2.21 1.2.23 1.2.25 1.2.27 All 155 releases
easy-media-gallery / easy-media-gallery.php

easy-media-gallery.php in Gallery – Photo Albums Plugin trunk, at easy-media-gallery.php

712 lines 25.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Easy Media Gallery
4 Plugin URI: https://ghozylab.com/plugins/
5 Description: Easy Media Gallery (Lite) - Displaying your gallery, video (MP4, Youtube, Vimeo) and audio mp3 in elegant and fancy lightbox with very easy. Allows you to customize all media to get it looking exactly what you want. <a href="https://ghozy.link/q65dp" target="_blank"><strong> Upgrade to Pro Version Now</strong></a> and get a tons of awesome features.
6 Author: PT. GHOZY LAB LLC
7 Text Domain: easy-media-gallery
8 Domain Path: /languages
9 Version: 1.3.171
10 Requires at least: 4.6
11 Requires PHP: 7.2
12 License: GPLv3 or later
13 License URI: https://www.gnu.org/licenses/gpl-3.0.html
14 Author URI: https://ghozylab.com/
15 */
16
17 if ( ! defined( 'ABSPATH' ) ) {
18 die( 'Please do not load this file directly!' );
19 }
20
21 /*
22 |--------------------------------------------------------------------------
23 | Defines
24 |--------------------------------------------------------------------------
25 */
26 if ( ! defined( 'EASYMEDG_PLUGIN_URL' ) ) {
27 define( 'EASYMEDG_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
28 }
29
30 if ( ! defined( 'EMG_DIR' ) ) {
31 define( 'EMG_DIR', plugin_dir_path( __FILE__ ) );
32 }
33
34 // WP Version
35 if ( (float) substr( get_bloginfo( 'version' ), 0, 3 ) >= 3.5 ) {
36 define( 'EMG_WP_VER', 'g35' );
37 } else {
38 define( 'EMG_WP_VER', 'l35' );
39 }
40
41 // Plugin Name
42 if ( ! defined( 'EASYMEDIA_NAME' ) ) {
43 define( 'EASYMEDIA_NAME', 'Easy Media Gallery Lite' );
44 }
45
46 // Plugin Version
47 if ( ! defined( 'EASYMEDIA_VERSION' ) ) {
48 define( 'EASYMEDIA_VERSION', '1.3.171' );
49 }
50
51 // Pro Price
52 if ( ! defined( 'EASYMEDIA_PRO_PRICE' ) ) {
53 define( 'EASYMEDIA_PRO_PRICE', '24' );
54 }
55
56 // Pro+
57 if ( ! defined( 'EASYMEDIA_PRICE' ) ) {
58 define( 'EASYMEDIA_PRICE', '29' );
59 }
60
61 // Pro++ Price
62 if ( ! defined( 'EASYMEDIA_PLUS_PRICE' ) ) {
63 define( 'EASYMEDIA_PLUS_PRICE', '35' );
64 }
65
66 // Dev Price
67 if ( ! defined( 'EASYMEDIA_DEV_PRICE' ) ) {
68 define( 'EASYMEDIA_DEV_PRICE', '99' );
69 }
70
71 // WP Version
72 if ( ! defined( 'EMG_WPVER' ) ) {
73 define( 'EMG_WPVER', get_bloginfo( 'version' ) );
74 }
75
76 // PHP Version
77 if ( version_compare( PHP_VERSION, '7.1', '>' ) ) {
78 define( 'EMG_PHP7', true );
79 } else {
80 define( 'EMG_PHP7', false );
81 }
82
83 define( 'EASYMEDIA_PLUGIN_SLUG', 'easy-media-gallery/easy-media-gallery.php' );
84 define( 'EMG_API_URLCURL', 'https://secure.ghozylab.com/' );
85 define( 'EMG_API_URL', 'https://secure.ghozylab.com/' );
86
87 add_action( 'init', 'emg_first_load', 0 );
88 add_action( 'init', 'emg_init' );
89 add_action( 'plugins_loaded', 'emg_run_block' );
90 add_action( 'admin_init', 'emg_admin_init' );
91 add_action( 'admin_init', 'emg_plugin_updater', 0 );
92 add_action( 'admin_notices', 'emg_jetpack_modules_photon' );
93 add_filter( 'plugin_action_links', 'easmedia_settings_link', 10, 2 );
94 add_filter( 'plugin_row_meta', 'easmedia_settings_link_rowmeta', 10, 2 );
95 add_action( 'admin_print_styles', 'add_my_admin_stylesheet' );
96 add_action( 'admin_head', 'easmedia_easymediagallery_icons' );
97 add_filter( 'manage_edit-easymediagallery_columns', 'easmedia_edit_columns_easymedia' );
98 add_filter( 'manage_posts_custom_column', 'easmedia_custom_columns_easymedia', 10, 2 );
99 add_action( 'wp_ajax_easymedia_sort', 'easmedia_save_easymedia_sorted_order' );
100 add_action( 'manage_edit-easymediagallery_columns', 'easmedia_add_new_easymediagallery_column' );
101 add_action( 'manage_easymediagallery_posts_custom_column', 'easmedia_show_order_column' );
102 add_filter( 'manage_edit-easymediagallery_sortable_columns', 'easmedia_order_column_register_sortable' );
103 add_filter( 'pre_get_posts', 'easmedia_set_custom_post_types_admin_order' );
104 add_action( 'init', 'emg_custom_post_mod', 3 );
105 add_filter( 'widget_text', 'do_shortcode', 11 );
106 add_filter( 'the_excerpt', 'shortcode_unautop' );
107 add_filter( 'the_excerpt', 'do_shortcode' );
108 add_action( 'admin_menu', 'emg_rename_submenu' );
109 register_activation_hook( __FILE__, 'emg_plugin_activate' );
110
111 function emg_first_load()
112 {
113
114 include_once dirname( __FILE__ ).'/includes/easywidget.php';
115
116 }
117
118 function emg_run_block()
119 {
120
121 if ( emg_is_gutenberg() ) {
122 include_once plugin_dir_path( __FILE__ ).'includes/emg-block/init.php';
123 }
124
125 }
126
127 function emg_is_gutenberg()
128 {
129
130 // Gutenberg plugin is installed and activated.
131 $gutenberg = ! ( false === has_filter( 'replace_editor', 'gutenberg_init' ) );
132
133 // Block editor since 5.0.
134 $block_editor = version_compare( $GLOBALS['wp_version'], '5.0-beta', '>' );
135
136 if ( ! $gutenberg && ! $block_editor ) {
137 return false;
138 }
139
140 if ( function_exists( 'is_classic_editor_plugin_active' ) && is_classic_editor_plugin_active() ) {
141 $editor_option = get_option( 'classic-editor-replace' );
142 $block_editor_active = array( 'no-replace', 'block' );
143
144 return in_array( $editor_option, $block_editor_active, true );
145 }
146
147 return true;
148
149 }
150
151 /*
152 |--------------------------------------------------------------------------
153 | EMG Init
154 |--------------------------------------------------------------------------
155 */
156 function emg_init()
157 {
158
159 load_plugin_textdomain( 'easy-media-gallery', false, dirname( plugin_basename( __FILE__ ) ).'/languages/' );
160
161 if ( ! is_admin() ) {
162 wp_enqueue_script( 'jquery' );
163 }
164
165 include_once dirname( __FILE__ ).'/includes/functions/functions.php';
166 include_once dirname( __FILE__ ).'/includes/class/easymedia_resizer.php';
167 include_once dirname( __FILE__ ).'/includes/taxonomy.php';
168 include_once dirname( __FILE__ ).'/includes/shortcode.php';
169
170 if ( easy_get_option( 'easymedia_disen_plug' ) == '1' ) {
171 include_once dirname( __FILE__ ).'/includes/frontend.php';
172 include_once dirname( __FILE__ ).'/includes/dynamic-style.php'; //@since 1.2.9.5
173 }
174
175 if ( is_admin() ) {
176
177 include_once dirname( __FILE__ ).'/includes/tinymce_plugin/register_mce_button.php';
178 include_once dirname( __FILE__ ).'/includes/options.php';
179 include_once dirname( __FILE__ ).'/includes/emg-settings.php';
180 include_once dirname( __FILE__ ).'/includes/pages/emg-pricing.php';
181 include_once dirname( __FILE__ ).'/includes/pages/emg-freethemes.php';
182 include_once dirname( __FILE__ ).'/includes/pages/emg-welcome.php';
183 include_once dirname( __FILE__ ).'/includes/pages/emg-featured.php';
184 include_once dirname( __FILE__ ).'/includes/pages/emg-freeplugins.php';
185 include_once dirname( __FILE__ ).'/includes/pages/emg-addons.php';
186 include_once dirname( __FILE__ ).'/includes/pages/emg-demo.php';
187 include_once dirname( __FILE__ ).'/includes/metaboxes.php';
188 include_once dirname( __FILE__ ).'/includes/tinymce-dlg.php';
189
190 }
191
192 /*
193 |--------------------------------------------------------------------------
194 | Registers custom post type
195 |--------------------------------------------------------------------------
196 */
197 $labels = array(
198 'name' => _x( 'Easy Media Gallery Lite', 'post type general name', 'easy-media-gallery' ),
199 'singular_name' => _x( 'Easy Media Gallery Lite', 'post type singular name', 'easy-media-gallery' ),
200 'add_new' => __( 'Add New Media', 'easy-media-gallery' ),
201 'add_new_item' => __( 'Easy Media Item', 'easy-media-gallery' ),
202 'edit_item' => __( 'Edit Media', 'easy-media-gallery' ),
203 'new_item' => __( 'New Media', 'easy-media-gallery' ),
204 'view_item' => __( 'View Media', 'easy-media-gallery' ),
205 'search_items' => __( 'Search Media', 'easy-media-gallery' ),
206 'not_found' => __( 'No Media Found', 'easy-media-gallery' ),
207 'not_found_in_trash' => __( 'No Media Found In Trash', 'easy-media-gallery' ),
208 'parent_item_colon' => __( 'Parent Media', 'easy-media-gallery' ),
209 'menu_name' => __( 'Easy Media', 'easy-media-gallery' ),
210 );
211
212 $taxonomies = array();
213 $supports = array( 'title', 'thumbnail' );
214
215 $post_type_args = array(
216 'labels' => $labels,
217 'singular_label' => __( 'Easy Media', 'easy-media-gallery' ),
218 'public' => false,
219 'show_ui' => true,
220 'publicly_queryable' => true,
221 'query_var' => true,
222 'capability_type' => 'post',
223 'has_archive' => false,
224 'hierarchical' => false,
225 'rewrite' => array( 'slug' => 'easymedia', 'with_front' => false ),
226 'supports' => $supports,
227 'menu_position' => 20,
228 'menu_icon' => plugins_url( 'includes/images/emg-dash-icon.png', __FILE__ ),
229 'taxonomies' => $taxonomies,
230 );
231
232 register_post_type( 'easymediagallery', $post_type_args );
233
234 }
235
236 function emg_admin_init()
237 {
238
239 /*
240 |--------------------------------------------------------------------------
241 | Requires Wordpress Version
242 |--------------------------------------------------------------------------
243 */
244 $plugin = plugin_basename( __FILE__ );
245
246 if ( version_compare( EMG_WPVER, '3.3', '<' ) ) {
247
248 if ( is_plugin_active( $plugin ) ) {
249 deactivate_plugins( $plugin );
250 wp_die( sprintf( '%1$s requires WordPress 3.3 or higher, this plugin has been deactivated! Please upgrade WordPress and try again.<br /><br />Back to <a href="%2$s">WordPress admin</a>', esc_html( EASYMEDIA_NAME ), esc_url( admin_url() ) ) );
251 }
252
253 }
254
255 /*
256 |--------------------------------------------------------------------------
257 | Requires PHP Version (min version PHP 5.2)
258 |--------------------------------------------------------------------------
259 */
260 if ( version_compare( PHP_VERSION, '5.2', '<' ) ) {
261 if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
262 require_once ABSPATH.'/wp-admin/includes/plugin.php';
263 deactivate_plugins( __FILE__ );
264 wp_die( sprintf( '%1$s requires PHP 5.2 or higher. The plugin has now disabled itself. Please ask your hosting provider for this issue.<br /><br />Back to <a href="%2$s">WordPress admin</a>', esc_html( EASYMEDIA_NAME ), esc_url( admin_url() ) ) );
265 } else {
266 return;
267 }
268
269 }
270
271 /*
272 |--------------------------------------------------------------------------
273 | Requires GD Library
274 |--------------------------------------------------------------------------
275 */
276 if ( is_admin() ) {
277 if ( ! extension_loaded( 'gd' ) && ! function_exists( 'gd_info' ) ) {
278 require_once ABSPATH.'/wp-admin/includes/plugin.php';
279 deactivate_plugins( __FILE__ );
280 wp_die( sprintf( '<strong>GD Library</strong> for PHP is not installed on your server. %1$s requires it to function properly. The plugin has now disabled itself. Please ask your hosting provider for this issue.<br /><br />Back to <a href="%2$s">WordPress admin</a>', esc_html( EASYMEDIA_NAME ), esc_url( admin_url() ) ) );
281 }
282
283 }
284
285 // Learn more here https://www.webassist.com/tutorials/Enabling-the-GD-library-setting
286
287 }
288
289 /*-------------------------------------------------------------------------------*/
290 /* JetPack ( Photon Module ) Detect
291 /*-------------------------------------------------------------------------------*/
292 function emg_jetpack_modules_photon()
293 {
294
295 if ( class_exists( 'Jetpack' ) && in_array( 'photon', Jetpack::get_active_modules() ) ) {
296
297 // translators: 1: JetPack module name, 2: plugin name.
298 echo '<div class="error"><span class="emgwarning"><p class="emgwarningp">' . sprintf( esc_html__( 'You need to deactivate JetPack %1$s to make %2$s work!', 'easy-media-gallery' ), '<strong>Photon Module</strong>', '<strong>' . esc_html( EASYMEDIA_NAME ) . '</strong>' ) . '</p><p><a href="' . esc_url( wp_nonce_url( admin_url( 'admin.php?page=jetpack&action=deactivate&module=photon' ), 'jetpack_deactivate-photon' ) ) . '">' . esc_html__( 'Deactivate Now!', 'easy-media-gallery' ) . '</a></p></span></div>';
299
300 }
301
302 }
303
304 /*
305 |--------------------------------------------------------------------------
306 | Easymedia (Lite) Get Control Panel Options
307 |--------------------------------------------------------------------------
308 */
309 function easy_get_option( $name )
310 {
311
312 $easymedia_values = get_option( 'easy_media_opt' );
313
314 if ( is_array( $easymedia_values ) && array_key_exists( $name, $easymedia_values ) ) {
315 return $easymedia_values[$name];
316 }
317
318 return false;
319
320 }
321
322 /*
323 |--------------------------------------------------------------------------
324 | SETTINGS LINK 01
325 |--------------------------------------------------------------------------
326 */
327 function easmedia_settings_link( $link, $file )
328 {
329
330 static $this_plugin;
331
332 if ( ! $this_plugin ) {
333 $this_plugin = plugin_basename( __FILE__ );
334 }
335
336 if ( $file == $this_plugin ) {
337 $settings_link = '<a href="'.admin_url( 'edit.php?post_type=easymediagallery&page=emg_settings' ).'"><span class="emg_settings_icon dashicons dashicons-admin-generic"></span>&nbsp;'.__( 'Settings', 'easy-media-gallery' ).'</a>';
338 array_unshift( $link, $settings_link );
339 }
340
341 return $link;
342 }
343
344 /*
345 |--------------------------------------------------------------------------
346 | SETTINGS LINK 02
347 |--------------------------------------------------------------------------
348 */
349 function easmedia_settings_link_rowmeta( $link, $file )
350 {
351 static $this_plugin;
352
353 if ( ! $this_plugin ) {
354 $this_plugin = plugin_basename( __FILE__ );
355 }
356
357 if ( $file == $this_plugin ) {
358 $link[] = '<a href="https://ghozy.link/rs3bq" target="_blank"><span class="dashicons dashicons-heart"></span>&nbsp;'.__( 'Donate', 'easy-media-gallery' ).'</a>';
359 $link[] = '<a href="https://www.youtube.com/GhozyLab" target="_blank"><span class="dashicons dashicons-editor-help"></span>&nbsp;'.__( 'Tutorials', 'easy-media-gallery' ).'</a>';
360 $link[] = '<a href="https://wordpress.org/support/plugin/easy-media-gallery/reviews/#new-post" target="_blank"><span class="dashicons dashicons-star-filled"></span>&nbsp;'.__( 'Rate Us', 'easy-media-gallery' ).'</a>';
361 }
362
363 return $link;
364 }
365
366 /*-------------------------------------------------------------------------------*/
367 /* Put css file and add Custom Icon for Easy Media Gallery
368 /*-------------------------------------------------------------------------------*/
369 function add_my_admin_stylesheet()
370 {
371 wp_enqueue_style( 'easmedia_admin_styles', plugins_url( 'includes/css/admin.css', __FILE__ ) );
372 }
373
374 function easmedia_easymediagallery_icons()
375 {?>
376 <style type="text/css" media="screen">
377 #icon-edit.icon32-posts-easymediagallery {
378 background: url(<?php echo esc_url( plugins_url( 'includes/images/easymedia-32x32.png', __FILE__ ) ); ?>) no-repeat top left transparent !important;
379 }
380
381 #icon-edit.icon32-posts-easymedia {
382 background: url(<?php echo esc_url( plugins_url( 'includes/images/easymedia-32x32.png', __FILE__ ) ); ?>) no-repeat top left transparent !important;
383 }
384 </style>
385 <?php
386 }
387
388 /*--------------------------------------------------------------------------------*/
389 /* Add Custom Columns for Portfolios
390 /*--------------------------------------------------------------------------------*/
391 function easmedia_edit_columns_easymedia( $easymedia_columns )
392 {
393 $easymedia_columns = array(
394 'cb' => '<input type="checkbox" />',
395 'title' => _x( 'Title', 'column name', 'easy-media-gallery' ),
396 'psg_thumbnail' => __( 'Thumbnails', 'easy-media-gallery' ),
397 'psg_type' => __( 'Type', 'easy-media-gallery' ),
398 'psg_cat' => __( 'Categories', 'easy-media-gallery' ),
399 'psg_id' => __( 'ID', 'easy-media-gallery' ),
400
401 );
402 unset( $easymedia_columns['Date'] );
403
404 return $easymedia_columns;
405 }
406
407 function easmedia_custom_columns_easymedia( $easymedia_columns, $post_id )
408 {
409
410 if ( is_array( get_post_meta( $post_id, 'easmedia_metabox_media_gallery', true ) ) ) {
411 $ittl = array_filter( get_post_meta( $post_id, 'easmedia_metabox_media_gallery', true ) );
412 $ittl = count( $ittl );
413 } else {
414 $ittl = '0';
415 }
416
417 switch ( $easymedia_columns ) {
418 case 'psg_thumbnail':
419 $mediatype = get_post_meta( $post_id, 'easmedia_metabox_media_type', true );
420
421 switch ( $mediatype ) {
422 case 'Single Image':
423 $thumbmedia = get_post_meta( $post_id, 'easmedia_metabox_img', true );
424
425 if ( isset( $thumbmedia ) && $thumbmedia != '' ) {
426 $globalimgsize = wp_get_attachment_image_src( emg_get_attachment_id_from_src( $thumbmedia ), 'full' );
427 if ( ! $globalimgsize) {
428 $timthumbimg = plugins_url( 'includes/images/no-image-available.jpg', __FILE__ );
429 }
430 else {
431 $timthumbimg = easymedia_resizer( $thumbmedia, $globalimgsize[1], $globalimgsize[2], 70, 70, true );
432 }
433 echo '<img class="imgthumblist" width="70" height="70" alt="' . esc_attr__( 'Thumbnail', 'easy-media-gallery' ) . '" src="' . esc_url( $timthumbimg ) . '" />';
434 } else {
435 echo '<img class="imgthumblist" width="70" height="70" alt="' . esc_attr__( 'Thumbnail', 'easy-media-gallery' ) . '" src="' . esc_url( plugins_url( 'includes/images/no-image-available.jpg', __FILE__ ) ) . '" />';
436 }
437
438 break;
439
440 case 'Video':
441 echo '<img class="imgthumblist" width="70" height="70" alt="' . esc_attr__( 'Thumbnail', 'easy-media-gallery' ) . '" src="' . esc_url( plugins_url( 'images/video.png', __FILE__ ) ) . '" />';
442 break;
443
444 case 'Audio':
445 echo '<img class="imgthumblist" width="70" height="70" alt="' . esc_attr__( 'Thumbnail', 'easy-media-gallery' ) . '" src="' . esc_url( plugins_url( 'images/audio.png', __FILE__ ) ) . '" />';
446 break;
447
448 case 'Multiple Images (Slider)':
449 echo '<img class="imgthumblist" width="70" height="70" alt="' . esc_attr__( 'Thumbnail', 'easy-media-gallery' ) . '" src="' . esc_url( plugins_url( 'images/gallery.png', __FILE__ ) ) . '" />';
450 break;
451
452 }
453
454 break;
455 case 'psg_id':
456 echo absint( $post_id );
457
458 break;
459
460 case 'psg_type':
461
462 $mediatype = get_post_meta( $post_id, 'easmedia_metabox_media_type', true );
463
464 if ( isset( $mediatype ) && $mediatype != 'Select' ) {
465
466 if ( trim( $mediatype ) == 'Multiple Images (Slider)' ) {
467 // translators: %d: Total number of images.
468 echo esc_html( $mediatype ) . '<br><span class="emgttlimage">' . sprintf( esc_html__( 'Total image(s): %d', 'easy-media-gallery' ), absint( $ittl ) ) . '</span>';
469 } else {
470 echo esc_html( $mediatype );
471 }
472
473 } else {
474 esc_html_e( 'None', 'easy-media-gallery' );
475 }
476
477 break;
478
479 case 'psg_cat':
480 $cats = get_the_terms( $post_id, 'emediagallery' );
481
482 if ( is_array( $cats ) ) {
483 $item_cats = array();
484
485 foreach ( $cats as $cat ) {
486 $item_cats[] = $cat->name;
487 }
488
489 echo esc_html( implode( ', ', $item_cats ) );
490 } else {
491 esc_html_e( 'Uncategorized', 'easy-media-gallery' );
492 }
493
494 break;
495
496 default:
497 break;
498 }
499
500 }
501
502 // jQuery Auto Save Media Order
503 function easmedia_save_easymedia_sorted_order()
504 {
505 // Verify nonce for CSRF protection
506 check_ajax_referer( 'easymedia-sort-nonce', 'security' );
507
508 // Check user capability
509 if ( ! current_user_can( 'edit_posts' ) ) {
510 wp_die( -1, 403 );
511 }
512
513 if ( ! isset( $_POST['order'] ) ) {
514 wp_die( 0, 400 );
515 }
516
517 global $wpdb;
518
519 $raw_order = sanitize_text_field( wp_unslash( $_POST['order'] ) );
520 $order = ! empty( $raw_order ) ? explode( ',', $raw_order ) : array();
521 $counter = 0;
522
523 foreach ( $order as $easymedia_id ) {
524 $id = absint( $easymedia_id );
525 if ( $id > 0 ) {
526 $wpdb->update( $wpdb->posts, array( 'menu_order' => $counter ), array( 'ID' => $id ) );
527 $counter++;
528 }
529 }
530
531 echo 1;
532 wp_die();
533 }
534
535 function easmedia_print_sort_scripts()
536 {
537 wp_enqueue_script( 'jquery-ui-sortable' );
538 wp_enqueue_script( 'easmedia_easymedia_sort', plugins_url( 'includes/js/func/easymedia_sort.js', __FILE__ ), array( 'jquery', 'jquery-ui-sortable' ), false, true );
539 wp_localize_script(
540 'easmedia_easymedia_sort',
541 'easymedia_sort_vars',
542 array(
543 'nonce' => wp_create_nonce( 'easymedia-sort-nonce' ),
544 'error_msg' => __( 'There was an error saving the update.', 'easy-media-gallery' ),
545 )
546 );
547 }
548
549 function easmedia_print_sort_styles()
550 {
551 wp_enqueue_style( 'nav-menu' );
552 }
553
554 /*-------------------------------------------------------------------------------*/
555 /* Add The Custom Columns ( Thanks & Credit to Captain Slider Plugin )
556 /*-------------------------------------------------------------------------------*/
557 function easmedia_add_new_easymediagallery_column( $easmedia_col )
558 {
559 $easmedia_col['emg_menu_order'] = 'Order';
560
561 return $easmedia_col;
562 }
563
564 // Show Custom Order Values
565 function easmedia_show_order_column( $name )
566 {
567 global $post;
568
569 switch ( $name ) {
570 case 'emg_menu_order':
571
572 $order = $post->menu_order;
573 echo absint( $order );
574 break;
575 default:
576 break;
577 }
578
579 }
580
581 // Make It Sortable
582 function easmedia_order_column_register_sortable( $columns )
583 {
584 $columns['emg_menu_order'] = 'menu_order';
585
586 return $columns;
587 }
588
589 // Presets Media Order to be menu_order
590 function easmedia_set_custom_post_types_admin_order( $wp_query )
591 {
592
593 if ( is_admin() ) {
594
595 if ( ! isset( $wp_query->query['post_type'] ) ) {
596 return $wp_query;
597 }
598
599 // Get the post type from the query
600 $post_type = $wp_query->query['post_type'];
601
602 if ( $post_type == 'easymediagallery' ) {
603 $wp_query->set( 'orderby', 'menu_order' );
604 $wp_query->set( 'order', 'ASC' );
605 }
606
607 }
608
609 }
610
611 /*-------------------------------------------------------------------------------*/
612 /* Hide View, Quick Edit and Preview Button
613 /*-------------------------------------------------------------------------------*/
614 function emg_remove_row_actions( $actions )
615 {
616 global $post;
617
618 if ( $post->post_type == 'easymediagallery' ) {
619 unset( $actions['view'] );
620 unset( $actions['inline hide-if-no-js'] );
621 }
622
623 return $actions;
624 }
625
626 function emg_custom_post_mod()
627 {
628
629 if ( is_admin() ) {
630 add_filter( 'post_row_actions', 'emg_remove_row_actions', 10, 2 );
631 }
632
633 }
634
635 /*
636 |--------------------------------------------------------------------------
637 | RENAME SUBMENU
638 |--------------------------------------------------------------------------
639 */
640 function emg_rename_submenu()
641 {
642 global $submenu;
643 $submenu['edit.php?post_type=easymediagallery'][5][0] = __( 'Overview', 'easy-media-gallery' );
644 }
645
646 /*
647 |--------------------------------------------------------------------------
648 | CHECK PLUGIN DEFAULT SETTINGS
649 |--------------------------------------------------------------------------
650 */
651
652 function emg_plugin_activate()
653 {
654
655 add_option( 'Activated_Emg_Plugin', 'emg-activate' );
656
657 }
658
659 /*
660 |--------------------------------------------------------------------------
661 | PLUGIN AUTO UPDATE
662 |--------------------------------------------------------------------------
663 */
664
665 function emg_plugin_updater()
666 {
667
668 $emg_is_auto_update = easy_get_option( 'easymedia_disen_autoupdt' );
669
670 switch ( $emg_is_auto_update ) {
671
672 case '1':
673
674 if ( ! wp_next_scheduled( 'emg_auto_update' ) ) {
675 wp_schedule_event( time(), 'daily', 'emg_auto_update' );
676 }
677
678 add_action( 'emg_auto_update', 'plugin_emg_auto_update' );
679 break;
680
681 case '':
682 wp_clear_scheduled_hook( 'emg_auto_update' );
683 break;
684
685 }
686
687 }
688
689 function plugin_emg_auto_update()
690 {
691
692 try
693 {
694 require_once ABSPATH.'wp-admin/includes/class-wp-upgrader.php';
695 require_once ABSPATH.'wp-admin/includes/misc.php';
696
697 if ( ! defined( 'FS_METHOD' ) ) {
698 define( 'FS_METHOD', 'direct' );
699 }
700
701 require_once ABSPATH.'wp-includes/update.php';
702 require_once ABSPATH.'wp-admin/includes/file.php';
703 wp_update_plugins();
704 ob_start();
705 $plugin_upg = new Plugin_Upgrader();
706 $plugin_upg->upgrade( 'easy-media-gallery/easy-media-gallery.php' );
707 $output = @ob_get_contents();
708 @ob_end_clean();
709 } catch ( Exception $e ) {
710 }
711
712 }