post_type ) { return false; } // Get the metadata. $metadata = wp_get_attachment_metadata( $post_id ); if ( ! $metadata ) { return; } if ( !isset($metadata['file'] ) ) { return; } $info = pathinfo( $metadata['file'] ); $uploads = wp_upload_dir(); $filename = $info['filename']; $file_dir = $uploads['basedir'] . '/' . $info['dirname']; $ext = $info['extension']; if ( ! isset( $metadata['image_meta']['resized_images'] ) ) { return; } if ( count( $metadata['image_meta']['resized_images'] ) > 0 ) { foreach ( $metadata['image_meta']['resized_images'] as $value ) { $size = '-' . $value; // Format the files in the appropriate format $file = $file_dir . '/' . $filename . $size . '.' . $ext; // Delete found files wp_delete_file_from_directory( $file, $file_dir ); } } } public function register_submenus() { $tabs = array( 'shortcodes' => array( 'label' => esc_html__('Advanced Shortcodes', 'modula-best-grid-gallery'), 'priority' => 40, 'badge' => 'PRO' ), 'watermark' => array( 'label' => esc_html__('Watermark', 'modula-best-grid-gallery'), 'priority' => 50, 'badge' => 'PRO' ), 'compression' => array( 'label' => esc_html__('SpeedUp Settings', 'modula-best-grid-gallery'), 'priority' => 30, 'badge' => 'PRO' ), 'standalone' => array( 'label' => esc_html__('Standalone', 'modula-best-grid-gallery'), 'priority' => 20, 'badge' => 'PRO' ), 'roles' => array( 'label' => esc_html__('Roles', 'modula-best-grid-gallery'), 'priority' => 120, 'badge' => 'PRO' ) ); $this->tabs = apply_filters( 'modula_admin_page_tabs', $tabs ); $links = array( array( 'page_title' => esc_html__( 'Import/Export', 'modula-best-grid-gallery' ), 'menu_title' => esc_html__( 'Import/Export', 'modula-best-grid-gallery' ), 'capability' => 'manage_options', 'menu_slug' => 'modula-import-export', 'function' => array( $this, 'import_export_doc' ), 'priority' => 35, ), 'freevspro' => array( 'page_title' => esc_html__( 'Free vs PRO', 'modula-best-grid-gallery' ), 'menu_title' => esc_html__( 'Free vs PRO', 'modula-best-grid-gallery' ), 'capability' => 'manage_options', 'menu_slug' => 'modula-lite-vs-pro', 'function' => array( $this, 'lite_vs_pro' ), 'priority' => 100, ), ); $links['modulaalbums'] = array( 'page_title' => esc_html__( 'Albums', 'modula-best-grid-gallery' ), 'menu_title' => esc_html__( 'Albums', 'modula-best-grid-gallery' ), 'capability' => 'manage_options', 'menu_slug' => '#modula-albums', 'function' => array( $this, 'modula_albums' ), 'priority' => 25, ); $links['moduladefaults'] = array( 'page_title' => esc_html__( 'Gallery Defaults', 'modula-best-grid-gallery' ), 'menu_title' => esc_html__( 'Gallery Defaults', 'modula-best-grid-gallery' ), 'capability' => 'manage_options', 'menu_slug' => '#gallery-defaults', 'function' => array( $this, 'modula_gallery_defaults' ), 'priority' => 22, ); $links['albumsdefaults'] = array( 'page_title' => esc_html__( 'Albums Defaults', 'modula-best-grid-gallery' ), 'menu_title' => esc_html__( 'Albums Defaults', 'modula-best-grid-gallery' ), 'capability' => 'manage_options', 'menu_slug' => '#albums-defaults', 'function' => array( $this, 'modula_albums_defaults' ), 'priority' => 26, ); if ( current_user_can( 'install_plugins' ) ) { $links[] = array( 'page_title' => esc_html__( 'Extensions', 'modula-best-grid-gallery' ), 'menu_title' => esc_html__( 'Extensions', 'modula-best-grid-gallery' ), 'capability' => 'manage_options', 'menu_slug' => 'modula-addons', 'function' => array( $this, 'show_extension_page_tabs' ), 'priority' => 99, ); } if ( ! empty( $this->tabs ) ) { $links[] = array( 'page_title' => esc_html__( 'Settings', 'modula-best-grid-gallery' ), 'menu_title' => esc_html__( 'Settings', 'modula-best-grid-gallery' ), 'capability' => 'manage_options', 'menu_slug' => 'modula', 'function' => array( $this, 'show_submenu' ), 'priority' => 30, ); } $this->menu_links = apply_filters( 'modula_admin_page_link', $links ); // Sort tabs based on priority. uasort( $this->tabs, array( 'Modula_Helper', 'sort_data_by_priority' ) ); // Sort menu items based on priority uasort( $this->menu_links, array( 'Modula_Helper', 'sort_data_by_priority' ) ); if ( ! empty( $this->menu_links ) ) { foreach ( $this->menu_links as $link ) { if(!empty($link)){ add_submenu_page( 'edit.php?post_type=modula-gallery', $link['page_title'], $link['menu_title'], $link['capability'], $link['menu_slug'], $link['function'], $link['priority'] ); } } } } public function show_submenu() { // Get current tab if ( isset( $_GET['modula-tab'] ) && isset( $this->tabs[ $_GET['modula-tab'] ] ) ) { $this->current_tab = sanitize_text_field( wp_unslash( $_GET['modula-tab'] ) ); } else { $tabs = array_keys( $this->tabs ); $this->current_tab = $tabs[0]; } include 'tabs/modula.php'; } public function show_extension_page_tabs() { $tabs = array( 'galleries' => array( 'name' => esc_html__( 'Galleries', 'modula-best-grid-gallery' ), 'url' => admin_url( 'edit.php?post_type=modula-gallery' ), 'priority' => '1', ), 'suggest_feature' => array( 'name' => esc_html__( 'Suggest a feature', 'modula-best-grid-gallery' ), 'icon' => 'dashicons-external', 'url' => 'https://docs.google.com/forms/d/e/1FAIpQLSc5eAZbxGROm_WSntX_3JVji2cMfS3LIbCNDKG1yF_VNe3R4g/viewform', 'target' => '_blank', 'priority' => '10', ), ); if ( current_user_can( 'install_plugins' ) ) { $tabs[ 'extensions' ] = array( 'name' => esc_html__( 'Extensions', 'modula-best-grid-gallery' ), 'url' => admin_url( 'edit.php?post_type=modula-gallery&page=modula-addons' ), 'priority' => '5', ); } $tabs = apply_filters( 'modula_extesions_tabs', $tabs ); uasort( $tabs, array( 'Modula_Helper', 'sort_data_by_priority' ) ); $active_tab = 'extensions'; if ( isset( $_GET['tab'] ) && isset( $tabs[ $_GET['tab'] ] ) ) { $active_tab = sanitize_text_field( wp_unslash( $_GET['tab'] ) ); } ?>
check_free_addons() ){ ?>
render_addons(); ?>
check_free_addons() ){ ?>
render_free_addons(); ?>
'failed' ) ); } if ( ! isset( $_POST['gallery'] ) ) { wp_send_json( array( 'status' => 'failed' ) ); } $gallery_id = absint( $_POST['gallery'] ); if ( 'modula-gallery' != get_post_type( $gallery_id ) ) { wp_send_json( array( 'status' => 'failed' ) ); } $current_user = wp_get_current_user(); $ptype = get_post_type_object( 'modula-gallery' ); if ( ! current_user_can( $ptype->cap->edit_others_posts ) && absint( get_post_field( 'post_author', $gallery_id ) ) !== absint( $current_user->ID ) ) { wp_send_json( array( 'status' => __( 'Sorry, you do not have enough permissions.' ) ) ); } if ( ! isset( $_POST['images'] ) ) { wp_send_json( array( 'status' => 'failed' ) ); } $old_images = get_post_meta( $gallery_id, 'modula-images', true ); $images = json_decode( stripslashes( $_POST['images'] ), true ); $new_images = array(); if ( is_array( $images ) ) { foreach ( $images as $image ) { $new_images[] = $this->sanitize_image( $image ); } } update_post_meta( $gallery_id, 'modula-images', $new_images ); wp_send_json( array( 'status' => 'succes' ) ); } public function save_image() { $nonce = $_POST['_wpnonce']; if ( ! wp_verify_nonce( $nonce, 'modula-ajax-save' ) ) { wp_send_json( array( 'status' => 'failed' ) ); } if ( ! isset( $_POST['gallery'] ) ) { wp_send_json( array( 'status' => 'failed' ) ); } $gallery_id = absint( $_POST['gallery'] ); if ( 'modula-gallery' != get_post_type( $gallery_id ) ) { wp_send_json( array( 'status' => 'failed' ) ); } if ( ! isset( $_POST['image'] ) ) { wp_send_json( array( 'status' => 'failed' ) ); } $image = json_decode( stripslashes( $_POST['image'] ), true ); $old_images = get_post_meta( $gallery_id, 'modula-images', true ); foreach ( $old_images as $key => $old_image ) { if ( $old_image['id'] == $image['id'] ) { $old_images[ $key ] = $this->sanitize_image( $image ); } } update_post_meta( $gallery_id, 'modula-images', $old_images ); wp_send_json( array( 'status' => 'succes' ) ); } public function admin_custom_css() { ?>

Import" or click', 'modula-best-grid-gallery' ); ?>

' . esc_html__( 'Install WordPress Importer', 'modula-best-grid-gallery' ) . '' . esc_html__( '( if not installed ). If installed, click on WordPress "Run importer". After that select the export file you desire and click "Upload file and import".', 'modula-best-grid-gallery' ); ?>

Export" or click', 'modula-best-grid-gallery' ); ?>

have_posts() ) { $loop->the_post(); $suggestion['label'] = get_the_title(); $suggestion['type'] = get_post_type(); $suggestion['value'] = get_permalink(); $suggestions[] = $suggestion; } echo json_encode( $suggestions ); exit(); } public function register_affiliate_link() { register_setting( 'modula_affiliate', 'modula_affiliate' ); } public function add_affiliate_tab( $tabs ) { $tabs['affiliate'] = array( 'label' => esc_html__( 'Earn Money', 'modula-best-grid-gallery' ), 'priority' => 100, ); return $tabs; } public function show_affiliate_tab() { include MODULA_PATH . 'includes/admin/tabs/affiliate-options.php'; } /** * Add LITE vs PRO page * * @since 2.5.0 */ public function lite_vs_pro() { $pro_features = array( 'gallery-filters' => array( 'title' => esc_html__( 'Gallery Filters', 'modula-best-grid-gallery' ), 'description' => esc_html__( 'Let visitors filter your gallery items with a single click', 'modula-best-grid-gallery' ), ), 'gallery-sorting' => array( 'title' => esc_html__( 'Gallery Sorting', 'modula-best-grid-gallery' ), 'description' => esc_html__( 'Multiple choices for sorting out images from your gallery: manual, date created, date modified, alphabetically, reverse or random', 'modula-best-grid-gallery' ), ), 'hover-effects' => array( 'title' => esc_html__( 'Hover Effects', 'modula-best-grid-gallery' ), 'description' => esc_html__( 'Choose from 42 different hover effects.', 'modula-best-grid-gallery' ), ), 'loadng-effects' => array( 'title' => esc_html__( 'Loading Effects', 'modula-best-grid-gallery' ), 'description' => esc_html__( 'Build your own effects with these new customizations', 'modula-best-grid-gallery' ), ), ); echo '
'; do_action( 'modula_lite_vs_premium_page', $pro_features ); echo '
'; } public function modula_albums() { return; } public function modula_gallery_defaults() { return; } public function modula_albums_defaults() { return; } public function add_body_class( $classes ){ $screen = get_current_screen(); if ( 'modula-gallery' != $screen->post_type ) { return $classes; } if ( 'post' != $screen->base ) { return $classes; } $classes .= ' single-modula-gallery'; return $classes; } } new Modula_Admin();