cpt_name = apply_filters( 'modula_cpt_name', 'modula-gallery' ); add_action( 'init', array( $this, 'register_cpt' ) ); //Bring the settings in Rest add_action( 'rest_api_init', array( $this, 'register_post_meta_rest') ); /* Fire our meta box setup function on the post editor screen. */ add_action( 'load-post.php', array( $this, 'meta_boxes_setup' ) ); add_action( 'load-post-new.php', array( $this, 'meta_boxes_setup' ) ); add_action( 'admin_menu', array( $this, 'replace_submit_meta_box' ) ); add_filter( 'views_edit-modula-gallery', array( $this, 'add_extensions_tab_onboarding' ), 10, 1 ); // Post Table Columns add_filter( "manage_{$this->cpt_name}_posts_columns", array( $this, 'add_columns' ) ); add_action( "manage_{$this->cpt_name}_posts_custom_column", array( $this, 'outpu_column' ), 10, 2 ); add_filter( 'submenu_file', array( $this, 'remove_add_new_submenu_item' ) ); // Add the last visited tab to link add_filter( 'get_edit_post_link', array( $this, 'modula_remember_tab' ), 2, 99 ); add_action( 'wp_ajax_modula_remember_tab', array( $this, 'modula_remember_tab_save' ) ); /* Load Fields Helper */ require_once MODULA_PATH . 'includes/admin/class-modula-cpt-fields-helper.php'; /* Load Builder */ require_once MODULA_PATH . 'includes/admin/class-modula-field-builder.php'; $this->builder = Modula_Field_Builder::get_instance(); /* Initiate Image Resizer */ $this->resizer = new Modula_Image(); // Ajax for removing notices add_action( 'wp_ajax_modula-edit-notice', array( $this, 'dismiss_edit_notice' ) ); } public function register_cpt() { $this->labels = apply_filters( 'modula_cpt_labels', array( 'name' => esc_html__( 'Galleries', 'modula-best-grid-gallery' ), 'singular_name' => esc_html__( 'Gallery', 'modula-best-grid-gallery' ), 'menu_name' => esc_html__( 'Modula', 'modula-best-grid-gallery' ), 'name_admin_bar' => esc_html__( 'Modula', 'modula-best-grid-gallery' ), 'archives' => esc_html__( 'Item Archives', 'modula-best-grid-gallery' ), 'attributes' => esc_html__( 'Item Attributes', 'modula-best-grid-gallery' ), 'parent_item_colon' => esc_html__( 'Parent Item:', 'modula-best-grid-gallery' ), 'all_items' => esc_html__( 'Galleries', 'modula-best-grid-gallery' ), 'add_new_item' => esc_html__( 'Add New Item', 'modula-best-grid-gallery' ), 'add_new' => esc_html__( 'Add New', 'modula-best-grid-gallery' ), 'new_item' => esc_html__( 'New Item', 'modula-best-grid-gallery' ), 'edit_item' => esc_html__( 'Edit Item', 'modula-best-grid-gallery' ), 'update_item' => esc_html__( 'Update Item', 'modula-best-grid-gallery' ), 'view_item' => esc_html__( 'View Item', 'modula-best-grid-gallery' ), 'view_items' => esc_html__( 'View Items', 'modula-best-grid-gallery' ), 'search_items' => esc_html__( 'Search Item', 'modula-best-grid-gallery' ), 'not_found' => ''.esc_html__( 'Add your first gallery ','modula-best-grid-gallery').''.esc_html__('now or check out our ','modula-best-grid-gallery'). ''.esc_html__('documentation ','modula-best-grid-gallery').''.esc_html__('if you need help figuring things out.', 'modula-best-grid-gallery' ), 'not_found_in_trash' => esc_html__( 'Not found in Trash', 'modula-best-grid-gallery' ), 'featured_image' => esc_html__( 'Featured Image', 'modula-best-grid-gallery' ), 'set_featured_image' => esc_html__( 'Set featured image', 'modula-best-grid-gallery' ), 'remove_featured_image' => esc_html__( 'Remove featured image', 'modula-best-grid-gallery' ), 'use_featured_image' => esc_html__( 'Use as featured image', 'modula-best-grid-gallery' ), 'insert_into_item' => esc_html__( 'Insert into item', 'modula-best-grid-gallery' ), 'uploaded_to_this_item' => esc_html__( 'Uploaded to this item', 'modula-best-grid-gallery' ), 'items_list' => esc_html__( 'Items list', 'modula-best-grid-gallery' ), 'items_list_navigation' => esc_html__( 'Items list navigation', 'modula-best-grid-gallery' ), 'filter_items_list' => esc_html__( 'Filter items list', 'modula-best-grid-gallery' ), ), $this->labels ); $this->args = apply_filters( 'modula_cpt_args', array( 'label' => esc_html__( 'Modula Gallery', 'modula-best-grid-gallery' ), 'description' => esc_html__( 'Modula is the most powerful, user-friendly WordPress gallery plugin. Add galleries, masonry grids and more in a few clicks.', 'modula-best-grid-gallery' ), 'supports' => array( 'title' ), 'public' => false, 'show_ui' => true, 'show_in_menu' => true, 'menu_position' => 25, 'menu_icon' => MODULA_URL . 'assets/images/modula.png', 'show_in_admin_bar' => true, 'show_in_nav_menus' => false, 'can_export' => true, 'has_archive' => false, 'exclude_from_search' => true, 'rewrite' => false, 'show_in_rest' => true, ) ); $this->metaboxes = array( 'modula-preview-gallery' => array( 'title' => esc_html__( 'Gallery', 'modula-best-grid-gallery' ), 'callback' => 'output_gallery_images', 'context' => 'normal', 'priority' => 10, ), 'modula-settings' => array( 'title' => esc_html__( 'Settings', 'modula-best-grid-gallery' ), 'callback' => 'output_gallery_settings', 'context' => 'normal', 'priority' => 20, ), 'modula-shortcode' => array( 'title' => esc_html__( 'Shortcode', 'modula-best-grid-gallery' ), 'callback' => 'output_gallery_shortcode', 'context' => 'side', 'priority' => 10, ), ); $args = $this->args; $args['labels'] = $this->labels; register_post_type( $this->cpt_name, $args ); } /** * Rest field for modula settings * * @since 2.5.0 */ public function register_post_meta_rest() { register_rest_field( 'modula-gallery', 'modulaSettings', array( 'get_callback' => function( $post_arr ) { return get_post_meta( $post_arr['id'], 'modula-settings', true ); }, ) ); } /** * Remove Add New link from menu item * * @param $submenu_file * * @return mixed * * @since 2.3.4 */ public function remove_add_new_submenu_item( $submenu_file ) { remove_submenu_page( 'edit.php?post_type=modula-gallery', 'post-new.php?post_type=modula-gallery' ); return $submenu_file; } public function meta_boxes_setup() { /* Add meta boxes on the 'add_meta_boxes' hook. */ add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) ); /* Save post meta on the 'save_post' hook. */ add_action( 'save_post', array( $this, 'save_meta_boxes' ), 10, 2 ); } public function add_meta_boxes() { global $post; $this->metaboxes = apply_filters( 'modula_cpt_metaboxes', $this->metaboxes ); // Sort tabs based on priority. uasort( $this->metaboxes, array( 'Modula_Helper', 'sort_data_by_priority' ) ); foreach ( $this->metaboxes as $metabox_id => $metabox ) { if ( 'modula-shortcode' == $metabox_id && 'auto-draft' == $post->post_status ) { continue; } add_meta_box( $metabox_id, // Unique ID $metabox['title'], // Title array( $this, $metabox['callback'] ), // Callback function 'modula-gallery', // Admin page (or post type) $metabox['context'], // Context 'high' // Priority ); } } public function output_gallery_images() { $this->builder->render( 'gallery' ); } public function output_gallery_settings() { $this->builder->render( 'settings' ); } public function output_gallery_shortcode( $post ) { $this->builder->render( 'shortcode', $post ); } public function save_meta_boxes( $post_id, $post ) { /* Get the post type object. */ $post_type = get_post_type_object( $post->post_type ); /* Check if the current user has permission to edit the post. */ if ( !current_user_can( $post_type->cap->edit_post, $post_id ) || 'modula-gallery' != $post_type->name ) { return $post_id; } if ( isset( $_POST['modula-settings'] ) ) { $fields_with_tabs = Modula_CPT_Fields_Helper::get_fields( 'all' ); // Here we will save all our settings $modula_settings = array(); // We will save only our settings. foreach ( $fields_with_tabs as $tab => $fields ) { // We will iterate through all fields of current tab foreach ( $fields as $field_id => $field ) { if ( isset( $_POST['modula-settings'][$field_id] ) ) { // Values for selects $lightbox_values = apply_filters( 'modula_lightbox_values', array( 'no-link', 'direct', 'fancybox', 'attachment-page' ) ); $effect_values = apply_filters( 'modula_effect_values', array( 'none', 'pufrobo' ) ); $cursor_value = apply_filters( 'modula_cursor_values', array( 'pointer', 'zoom-in' ) ); switch ( $field_id ) { case 'description': $modula_settings[$field_id] = wp_filter_post_kses( $_POST['modula-settings'][$field_id] ); break; case 'randomFactor': case 'captionFontSize': case 'titleFontSize': case 'loadedScale': case 'inView': case 'borderSize': case 'borderRadius': case 'shadowSize': case 'socialIconSize': case 'socialIconPadding': $modula_settings[$field_id] = absint( $_POST['modula-settings'][$field_id] ); break; case 'lightbox' : if ( in_array( $_POST['modula-settings'][$field_id], $lightbox_values ) ) { $modula_settings[$field_id] = sanitize_text_field( wp_unslash( $_POST['modula-settings'][$field_id] ) ); } else { $modula_settings[$field_id] = 'fancybox'; } break; case 'enableSocial': case 'enableTwitter' : case 'enableWhatsapp': case 'enableFacebook' : case 'enablePinterest' : case 'enableEmail': case 'emailSubject': $modula_settings[$field_id] = sanitize_text_field( wp_unslash( $_POST['modula-settings'][$field_id] ) ); break; case 'imageMessage': $modula_settings[$field_id] = sanitize_text_field( wp_unslash( $_POST['modula-settings'][$field_id] ) ); break; case 'galleryMessage': $modula_settings[$field_id] = sanitize_text_field( wp_unslash( $_POST['modula-settings'][$field_id] ) ); break; case 'shuffle' : if ( isset( $_POST['modula-settings'][$field_id] ) ) { $modula_settings[$field_id] = '1'; } else { $modula_settings[$field_id] = '0'; } break; case 'captionColor': case 'socialIconColor': case 'borderColor': case 'shadowColor': $modula_settings[$field_id] = Modula_Helper::sanitize_rgba_colour( wp_unslash( $_POST['modula-settings'][$field_id] ) ); break; case 'effect' : if ( in_array( $_POST['modula-settings'][$field_id], $effect_values ) ) { $modula_settings[$field_id] = $_POST['modula-settings'][$field_id]; } else { $modula_settings[$field_id] = 'pufrobo'; } break; case 'gutterInput' : $modula_settings[$field_id] = absint( $_POST['modula-settings'][$field_id] ); break; case 'height' : $modula_settings[$field_id] = array_map( 'absint', $_POST['modula-settings'][$field_id] ); break; default: if ( is_array( $_POST['modula-settings'][$field_id] ) ) { $sanitized = array_map( 'sanitize_text_field', wp_unslash( $_POST['modula-settings'][$field_id] ) ); $modula_settings[$field_id] = apply_filters( 'modula_settings_field_sanitization', $sanitized, wp_unslash( $_POST['modula-settings'][$field_id] ), $field_id, $field ); } else { $modula_settings[$field_id] = apply_filters( 'modula_settings_field_sanitization', sanitize_text_field( wp_unslash( $_POST['modula-settings'][$field_id] ) ), $_POST['modula-settings'][$field_id], $field_id, $field ); } break; } } else { if ( 'toggle' == $field['type'] ) { $modula_settings[$field_id] = '0'; } else if ( 'hidden' == $field['type'] ) { $hidden_set = get_post_meta( $post_id, 'modula-settings', true ); if ( isset( $hidden_set['last_visited_tab'] ) && '' != $hidden_set['last_visited_tab'] ) { $modula_settings[$field_id] = $hidden_set['last_visited_tab']; } else { $modula_settings[$field_id] = 'modula-general'; } } else { $modula_settings[$field_id] = ''; } } } } // Save the value of helpergrid if ( isset( $_POST['modula-settings']['helpergrid'] ) ) { $modula_settings['helpergrid'] = 1; } else { $modula_settings['helpergrid'] = 0; } // Add settings to gallery meta update_post_meta( $post_id, 'modula-settings', $modula_settings ); } } public function add_extensions_tab_onboarding( $views ) { $query = new WP_Query(array( 'post_type' => 'modula-gallery', 'post_status' => array( 'publish', 'future', 'trash', 'draft', 'inherit', 'pending', 'private' ), )); $this->display_feedback_notice(); $this->display_extension_tab(); if( !$query->have_posts() ){ global $wp_list_table; $wp_list_table = new Modula_Onboarding(); return array(); } return $views; } public function display_extension_tab() { ?>

' ); ?>

'; echo ''; echo ''; echo ''; } } public function dismiss_edit_notice() { $modula_options = get_option( 'modula-checks', array() ); $modula_options['edit-notice'] = 1; update_option( 'modula-checks', $modula_options ); die( '1' ); } public function replace_submit_meta_box() { global $post; $post_type = 'modula-gallery'; remove_meta_box( 'submitdiv', $post_type, 'side' ); add_meta_box( 'submitdiv', __( 'Publish' ), array( $this, 'post_submit_meta_box' ), $post_type, 'side', 'high' ); } public function post_submit_meta_box() { global $action, $post; $post_type = $post->post_type; // get current post_type $post_type_object = get_post_type_object( $post_type ); $can_publish = current_user_can( $post_type_object->cap->publish_posts ); ?>
post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { $private_style = ''; if ( 'private' == $post->post_status ) { $private_style = 'style="display:none"'; } ?> type="submit" name="save" id="save-post" value="" class="button"/> post_status && $can_publish ) { ?>
post_status ) { $preview_button_text = esc_html__( 'Preview Changes', 'modula-best-grid-gallery' ); } else { $preview_button_text = esc_html__( 'Preview', 'modula-best-grid-gallery' ); } $preview_button = sprintf( '%1$s %2$s', $preview_button_text, /* translators: Accessibility text. */ esc_html__( '(opens in a new tab)', 'modula-best-grid-gallery' ) ); ?>
post_status ) { case 'private': esc_html_e( 'Privately Published' ); break; case 'publish': esc_html_e( 'Published' ); break; case 'future': esc_html_e( 'Scheduled' ); break; case 'pending': esc_html_e( 'Pending Review' ); break; case 'draft': case 'auto-draft': esc_html_e( 'Draft' ); break; } ?> post_status || 'private' == $post->post_status || $can_publish ) { $private_style = ''; if ( 'private' == $post->post_status ) { $private_style = 'style="display:none"'; } ?> class="edit-post-status hide-if-no-js" role="button">
post_status ) { $post->post_password = ''; $visibility = 'private'; $visibility_trans = __( 'Private' ); } elseif ( !empty( $post->post_password ) ) { $visibility = 'password'; $visibility_trans = __( 'Password protected' ); } elseif ( $post_type == 'post' && is_sticky( $post->ID ) ) { $visibility = 'public'; $visibility_trans = __( 'Public, Sticky' ); } else { $visibility = 'public'; $visibility_trans = __( 'Public' ); } echo esc_html( $visibility_trans ); ?>
ID ) ); ?> /> />
ID ) ); ?> />
/>

/>

ID ) { if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date /* translators: Post date information. %s: Date on which the post is currently scheduled to be published. */ $stamp = __( 'Scheduled for: %s' ); } elseif ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published /* translators: Post date information. %s: Date on which the post was published. */ $stamp = __( 'Published on: %s' ); } elseif ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified $stamp = __( 'Publish immediately' ); } elseif ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified /* translators: Post date information. %s: Date on which the post is to be published. */ $stamp = __( 'Schedule for: %s' ); } else { // draft, 1 or more saves, date specified /* translators: Post date information. %s: Date on which the post is to be published. */ $stamp = __( 'Publish on: %s' ); } $date = sprintf( $date_string, date_i18n( $date_format, strtotime( $post->post_date ) ), date_i18n( $time_format, strtotime( $post->post_date ) ) ); } else { // draft (no saves, and thus no date specified) $stamp = __( 'Publish immediately' ); $date = sprintf( $date_string, date_i18n( $date_format, strtotime( current_time( 'mysql' ) ) ), date_i18n( $time_format, strtotime( current_time( 'mysql' ) ) ) ); } if ( !empty( $args['args']['revisions_count'] ) ) : ?>
' . esc_html( number_format_i18n( $args['args']['revisions_count'] ) ) . '' ); ?>
' . $date . '' ); ?>
post_status && get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ) : ?>

unpublished customization changes. You can edit, but there’s no need to publish now. It will be published automatically with those changes.' ), esc_url( add_query_arg( 'changeset_uuid', rawurlencode( get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ), admin_url( 'customize.php' ) ) ) ) ); ?>

CTRL/CMD + S
ID ) ) { if ( !EMPTY_TRASH_DAYS ) { $delete_text = __( 'Delete Permanently' ); } else { $delete_text = __( 'Move to Trash' ); } ?>
post_status, array( 'publish', 'future', 'private' ) ) || 0 == $post->ID ) { if ( $can_publish ) : if ( !empty( $post->post_date_gmt ) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?>
'failed' ) ); } $id = isset( $_POST['id'] ) ? absint( $_POST['id'] ) : 0; // Check if post exists and is modula-gallery CPT if ( ! get_post_type( $id ) || 'modula-gallery' !== get_post_type( $id ) ) { wp_send_json( array( 'status' => 'failed' ) ); } $settings = wp_parse_args( get_post_meta( $id, 'modula-settings', true ), Modula_CPT_Fields_Helper::get_defaults() ); $settings['last_visited_tab'] = isset( $_POST['tab'] ) ? sanitize_text_field( wp_unslash( $_POST['tab'] ) ) : ''; update_post_meta( $id, 'modula-settings', $settings ); die(); } public function output_upsell_albums() { ?>