ID ) ? $post->ID : (int) $id; } return $post_id; } /** * Helper method for retrieving settings values. * * @since 2.0.0 * * @global int $id The current post ID. * @global object $post The current post object. * @param string $key The setting key to retrieve. * @param string $default A default value to use. * @return string Key value on success, empty string on failure. */ public function get_setting( $key, $default = false ) { // Get config if ( empty( $this->settings ) ) { $this->settings = get_post_meta( $this->get_id(), 'modula-settings', true ); } // Check config key exists if ( isset( $this->settings[ $key ] ) ) { $value = $this->settings[ $key ]; } else { $value = $default ? $default : ''; } return apply_filters( 'modula_admin_field_value', $value, $key, $this->settings ); } public function render( $metabox, $post = false ) { switch ( $metabox ) { case 'gallery': $this->_render_gallery_metabox(); break; case 'settings': $this->_render_settings_metabox(); break; case 'shortcode': $this->_render_shortcode_metabox( $post ); break; default: do_action( "modula_metabox_fields_{$metabox}" ); break; } } /* Create HMTL for gallery metabox */ private function _render_gallery_metabox() { $images = get_post_meta( $this->get_id(), 'modula-images', true ); $helper_guidelines = $this->get_setting( 'helpergrid' ); $max_upload_size = wp_max_upload_size(); if ( ! $max_upload_size ) { $max_upload_size = 0; } echo '
'; echo '
'; echo '
'; echo '
'; if (current_user_can('upload_files')) { echo sprintf( wp_kses_post( __( 'Drag and drop files here (max %s per file), or drag images around to change their order', 'modula-best-grid-gallery' ) ), esc_html( size_format( $max_upload_size ) ) ); echo '
'; echo '
'; echo '

' . esc_html__( 'Uploading image', 'modula-best-grid-gallery' ) . ' ' . esc_html__( 'of', 'modula-best-grid-gallery' ) . ' '; echo '

'; echo '
'; echo '
'; echo '
'; echo '' . esc_html__( 'Upload image files', 'modula-best-grid-gallery' ) . '' . esc_html__( 'Select from Library', 'modula-best-grid-gallery' ) . ''; do_action( 'modula_gallery_media_button'); } else { echo '' . esc_html__( 'Drag images around to change their order', 'modula-best-grid-gallery' ) . ''; echo '
'; } echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; echo '

' . esc_html__( 'Drag & Drop files here!', 'modula-best-grid-gallery' ) . '

'; echo ''; echo '
'; echo '

' . esc_html__( 'Drop files to upload', 'modula-best-grid-gallery' ) . '

'; echo '
'; // Helper Guildelines Toggle echo '
'; do_action( 'modula_before_helper_grid' ); echo '
'; echo ''; echo '
'; echo ''; echo ''; echo ''; echo ''; echo '
'; echo '' . esc_html__( 'Disable Helper Grid', 'modula-best-grid-gallery' ) . ''; echo '
'; do_action( 'modula_after_helper_grid' ); echo '
'; echo ''; } /* Create HMTL for settings metabox */ private function _render_settings_metabox() { $tabs = Modula_CPT_Fields_Helper::get_tabs(); // Sort tabs based on priority. uasort( $tabs, array( 'Modula_Helper', 'sort_data_by_priority' ) ); $tabs_html = ''; $tabs_content_html = ''; $first = true; // Generate HTML for each tab. foreach ( $tabs as $tab_id => $tab ) { $tab['id'] = $tab_id; $tabs_html .= $this->_render_tab( $tab, $first ); $fields = Modula_CPT_Fields_Helper::get_fields( $tab_id ); // Sort fields based on priority. uasort( $fields, array( 'Modula_Helper', 'sort_data_by_priority' ) ); $current_tab_content = '
'; // Check if our tab have title & description if ( isset( $tab['title'] ) || isset( $tab['description'] ) ) { $current_tab_content .= '
'; $current_tab_content .= '
'; if ( isset( $tab['title'] ) && '' != $tab['title'] ) { $current_tab_content .= '

' . esc_html( $tab['title'] ) . '

'; } if ( isset( $tab['description'] ) && '' != $tab['description'] ) { $current_tab_content .= '
[?]'; $current_tab_content .= '
' . wp_kses_post( $tab['description'] ) . '
'; $current_tab_content .= '
'; } $current_tab_content .= '
'; $current_tab_content .= '
'; $current_tab_content .= apply_filters('modula_admin_documentation_link', '' . esc_html__( 'Documentation', 'modula-best-grid-gallery' ) . ''); $current_tab_content .= ' - or - '; $current_tab_content .= apply_filters('modula_admin_contact_link', '' . esc_html__( 'Get in touch', 'modula-best-grid-gallery' ) . ''); $current_tab_content .= '
'; $current_tab_content .= '
'; } // Generate all fields for current tab $current_tab_content .= '
'; $current_tab_content .= ''; foreach ( $fields as $field_id => $field ) { $field['id'] = $field_id; $current_tab_content .= $this->_render_row( $field ); } $current_tab_content .= '
'; // Filter to add extra content to a specific tab $current_tab_content .= apply_filters( 'modula_' . $tab_id . '_tab_content', '' ); $current_tab_content .= '
'; $current_tab_content .= '
'; $tabs_content_html .= $current_tab_content; if ( $first ) { $first = false; } } $html = '
%s
%s
'; printf( $html, $tabs_html, $tabs_content_html ); } /* Create HMTL for shortcode metabox */ private function _render_shortcode_metabox( $post ) { $shortcode = '[modula id="' . $post->ID . '"]'; do_action( 'modula_admin_before_shortcode_metabox', $post ); echo '
'; echo ''; echo ''; echo '

' . sprintf( esc_html__( 'You can use this to display your newly created gallery inside a %s post or a page %s', 'modula-best-grid-gallery'), '', '' ) . '

'; echo '
'; do_action( 'modula_admin_after_shortcode_metabox', $post ); } /* Create HMTL for a tab */ private function _render_tab( $tab, $first = false ) { $icon = ''; $badge = ''; if ( isset( $tab['icon'] ) ) { $icon = ''; } if ( isset( $tab['badge'] ) ) { $badge = '' . esc_html( $tab['badge'] ) . ''; } return '
' . $icon . wp_kses_post( $tab['label'] ) . $badge . '
'; } /* Create HMTL for a row */ private function _render_row( $field ) { $child = ''; $field_name = wp_kses_post( $field[ 'name' ] ); // Generate tooltip $tooltip = ''; if ( isset( $field[ 'description' ] ) && '' != $field[ 'description' ] ) { $tooltip .= '
[?]'; $tooltip .= '
' . wp_kses_post( $field[ 'description' ] ) . '
'; $tooltip .= '
'; } if(isset($field['is_child']) && $field['is_child'] && is_bool($field['is_child'])){ $child = 'child_setting'; } if(isset($field['is_child']) && $field['is_child'] && is_string($field['is_child'])){ $child = $field['is_child'].'_child_setting'; } $format = '%s%s'; if( isset( $field['children'] ) && is_array( $field['children'] ) && 0 < count( $field['children'] ) ){ $children = htmlspecialchars(json_encode( $field['children'] ), ENT_QUOTES, 'UTF-8'); $parent = ''; if( isset( $field['parent'] ) && '' != $field['parent'] ){ $parent = 'data-parent="' . $field['parent'] . '"'; } $format = '%s%s'; } // Formats for General Gutter if ( 'gutterInput' == $field['type'] ) { if ( 'desktop' == $field['media'] ) { $format = '%s%spx'; } if ( 'tablet' == $field['media'] ) { $field_name = ''; $tooltip = ''; $format = '%s%s%spx'; } if ( 'mobile' == $field['media'] ) { $field_name = ''; $tooltip = ''; $format = '%s%s%spx'; } } // End formats for General Gutter if ( 'textarea' == $field['type'] || 'custom_code' == $field['type'] || 'hover-effect' == $field['type'] ) { $format = '%s
%s
'; } $format = apply_filters( "modula_field_type_{$field['type']}_format", $format, $field ); $default = ''; // Check if our field have a default value if ( isset( $field['default'] ) ) { $default = $field['default']; } // Get the current value of the field $value = $this->get_setting( $field['id'], $default ); return sprintf( $format, $tooltip, $field_name, $this->_render_field( $field, $value ) ); } /* Create HMTL for a field */ private function _render_field( $field, $value = '' ) { $html = ''; $default = ''; // Check if our field have a default value if ( isset( $field['default'] ) ) { $default = $field['default']; } switch ( $field['type'] ) { case 'image-size': $html = '
'; $html .= ''; $html .= 'x'; $html .= ''; $html .= 'px'; $html .= '
'; break; case 'text': $html = ''; if(isset($field['afterrow'])){ $html .= '

'. wp_kses_post( $field['afterrow'] ) .'

'; } break; case 'number': $html = ''; if ( isset( $field['after'] ) ) { $html .= '' . esc_html( $field['after'] ) . ''; } if(isset($field['afterrow'])){ $html .= '

'. wp_kses_post( $field['afterrow'] ) .'

'; } break; case 'gutterInput': $html = ''; if ( isset( $field['after'] ) ) { $html .= '' . esc_html( $field['after'] ) . ''; } if(isset($field['afterrow'])){ $html .= '

'. wp_kses_post( $field['afterrow'] ) .'

'; } break; case 'responsiveInput': $html = 'px'; $html .= 'px'; $html .= 'px'; if ( isset( $field['after'] ) ) { $html .= '' . esc_html( $field['after'] ) . ''; } if(isset($field['afterrow'])){ $html .= '

'. wp_kses_post( $field['afterrow'] ) .'

'; } break; case 'select' : $html = ''; if(isset($field['afterrow'])){ $html .= '

'.esc_html($field['afterrow']).'

'; } break; case 'icon-radio' : $wpchill_upsell = false; if ( class_exists( 'WPChill_Upsells' ) ) { // Initialize WPChill upsell class $args = apply_filters( 'modula_upsells_args', array( 'shop_url' => 'https://wp-modula.com', 'slug' => 'modula', ) ); $wpchill_upsell = WPChill_Upsells::get_instance( $args ); } $html .= '
'; foreach ( $field['values'] as $key => $name ) { $icon = esc_url( MODULA_URL .'assets/images/settings/' . $key . '.png' ); $html .= ''; $html .= ''; } foreach ( $field['disabled']['values'] as $key => $name ) { if ( $wpchill_upsell && ! $wpchill_upsell->is_upgradable_addon( 'modula-' . $key ) ) { $class = 'modula-radio-icon-install'; } else { $class = 'modula-radio-icon-disabled'; } $icon = esc_url( MODULA_URL .'assets/images/settings/' . $key . '-disabled.png' ); $html .= ''; } $html .= '
'; if ( isset( $field['afterrow'] ) ) { $html .= '

' . esc_html( $field['afterrow'] ) . '

'; } break; case 'ui-slider': $min = isset( $field['min'] ) ? $field['min'] : 0; $max = isset( $field['max'] ) ? $field['max'] : 100; $step = isset( $field['step'] ) ? $field['step'] : 1; if ( '' === $value ) { if ( isset( $field['default'] ) ) { $value = $field['default']; }else{ $value = $min; } } $attributes = 'data-min="' . esc_attr( $min ) . '" data-max="' . esc_attr( $max ) . '" data-step="' . esc_attr( $step ) . '"'; $html .= '
'; $html .= ''; $html .= '
'; $html .= '
'; break; case 'color' : $html .= '
'; if ( isset( $field['alpha'] ) && $field['alpha'] ) { $html .= ''; }else{ $html .= ''; } $html .= '
'; if(isset($field['afterrow'])){ $html .= '

'.esc_html($field['afterrow']).'

'; } break; case "toggle": $html .= '
'; $html .= ''; $html .= '
'; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= '
'; $html .= '
'; if(isset($field['afterrow'])){ $html .= '

'. wp_kses_post($field['afterrow'], array( 'a' => array( 'href' => array() ), 'target' => array() )).'

'; } break; case "custom_code": $html = '
'; $html .= ''; $html .= '
'; if(isset($field['afterrow'])){ $html .= '

'.esc_html($field['afterrow']).'

'; } break; case "hover-effect": $hovers = apply_filters( 'modula_available_hover_effects', array( 'none' => esc_html__( 'None', 'modula-best-grid-gallery' ), 'pufrobo' => esc_html__( 'Pufrobo', 'modula-best-grid-gallery' ), ) ); $pro_hovers = apply_filters( 'modula_pro_hover_effects', array( 'fluid-up' => esc_html__( 'Fluid Up', 'modula-best-grid-gallery' ), 'greyscale' => esc_html__( 'Greyscale', 'modula-best-grid-gallery' ), 'under' => esc_html__( 'Under Image', 'modula-best-grid-gallery' ), 'hide' => esc_html__( 'Hide', 'modula-best-grid-gallery' ), 'quiet' => esc_html__( 'Quiet', 'modula-best-grid-gallery' ), 'catinelle' => esc_html__( 'Catinelle', 'modula-best-grid-gallery' ), 'reflex' => esc_html__( 'Reflex', 'modula-best-grid-gallery' ), 'curtain' => esc_html__( 'Curtain', 'modula-best-grid-gallery' ), 'lens' => esc_html__( 'Lens', 'modula-best-grid-gallery' ), 'appear' => esc_html__( 'Appear', 'modula-best-grid-gallery' ), 'crafty' => esc_html__( 'Crafty', 'modula-best-grid-gallery' ), 'seemo' => esc_html__( 'Seemo', 'modula-best-grid-gallery' ), 'comodo' => esc_html__( 'Comodo', 'modula-best-grid-gallery' ), 'lily' => esc_html__( 'Lily', 'modula-best-grid-gallery' ), 'sadie' => esc_html__( 'Sadie', 'modula-best-grid-gallery' ), 'honey' => esc_html__( 'Honey', 'modula-best-grid-gallery' ), 'layla' => esc_html__( 'Layla', 'modula-best-grid-gallery' ), 'zoe' => esc_html__( 'Zoe', 'modula-best-grid-gallery' ), 'oscar' => esc_html__( 'Oscar', 'modula-best-grid-gallery' ), 'marley' => esc_html__( 'Marley', 'modula-best-grid-gallery' ), 'ruby' => esc_html__( 'Ruby', 'modula-best-grid-gallery' ), 'roxy' => esc_html__( 'Roxy', 'modula-best-grid-gallery' ), 'bubba' => esc_html__( 'Bubba', 'modula-best-grid-gallery' ), 'dexter' => esc_html__( 'Dexter', 'modula-best-grid-gallery' ), 'sarah' => esc_html__( 'Sarah', 'modula-best-grid-gallery' ), 'chico' => esc_html__( 'Chico', 'modula-best-grid-gallery' ), 'milo' => esc_html__( 'Milo', 'modula-best-grid-gallery' ), 'julia' => esc_html__( 'Julia', 'modula-best-grid-gallery' ), 'hera' => esc_html__( 'Hera', 'modula-best-grid-gallery' ), 'winston' => esc_html__( 'Winston', 'modula-best-grid-gallery' ), 'selena' => esc_html__( 'Selena', 'modula-best-grid-gallery' ), 'terry' => esc_html__( 'Terry', 'modula-best-grid-gallery' ), 'phoebe' => esc_html__( 'Phoebe', 'modula-best-grid-gallery' ), 'apollo' => esc_html__( 'Apollo', 'modula-best-grid-gallery' ), 'steve' => esc_html__( 'Steve', 'modula-best-grid-gallery' ), 'jazz' => esc_html__( 'Jazz', 'modula-best-grid-gallery' ), 'ming' => esc_html__( 'Ming', 'modula-best-grid-gallery' ), 'lexi' => esc_html__( 'Lexi', 'modula-best-grid-gallery' ), 'duke' => esc_html__( 'Duke', 'modula-best-grid-gallery' ), 'tilt_1' => esc_html__( 'Tilt Effect 1', 'modula-best-grid-gallery' ), 'tilt_3' => esc_html__( 'Tilt Effect 2', 'modula-best-grid-gallery' ), 'tilt_7' => esc_html__( 'Tilt Effect 3', 'modula-best-grid-gallery' ), 'centered-bottom' => esc_html__( 'Center Bottom', 'modula-best-grid-gallery' ), ) ); $html .= '

' . esc_html__( 'Select one of the below hover effects.', 'modula-best-grid-gallery' ) . '

'; // Creates effects preview // Check if the PRO hovers are used for preview in LITE or PRO version is active if ( $pro_hovers ) { $hovers = array_merge( $hovers, $pro_hovers ); } $html .= ''; // Hook to change how hover effects field is rendered $html = apply_filters( "modula_render_hover_effect_field_type", $html, $field ); if(isset($field['afterrow'])){ $html .= '

'.esc_html($field['afterrow']).'

'; } break; case 'dimensions-select' : $sizes = Modula_Helper::get_image_sizes(); $html = ''; if ( '' != $infos ) { $html .= '
' . $infos . '
'; } break; case 'textarea-placeholder' : $html = '
'; $html .= ''; $html .= '
'; $html .= '
'; foreach ( $field['values'] as $key => $value ) { $html .= ""; $html .= esc_html__( $value, 'modula-best-grid-gallery' ); $html .= ''; } $html .= '
'; if(isset($field['afterrow'])){ $html .= '

'.esc_html($field['afterrow']).'

'; } break; case 'placeholder' : $html = ''; $html .= '
'; foreach ( $field['values'] as $key => $value ) { $html .= ""; $html .= esc_html__( $value, 'modula-best-grid-gallery' ); $html .= ''; } $html .= '
'; if(isset($field['afterrow'])){ $html .= '

'.esc_html($field['afterrow']).'

'; } break; default: /* Filter for render custom field types */ $html = apply_filters( "modula_render_{$field['type']}_field_type", $html, $field, $value ); if(isset($field['afterrow'])){ $html .= '

'.esc_html($field['afterrow']).'

'; } break; } if( isset( $field['children'] ) && is_array( $field['children'] ) && 0 < count( $field['children'] ) ){ $children = htmlspecialchars(json_encode( $field['children'] ), ENT_QUOTES, 'UTF-8'); $html .= '' . absint( count( $field['children'] ) ) . esc_html__(' other settings') . ' '; } return apply_filters( "modula_render_field_type", $html, $field, $value ); } public function print_modula_templates() { include 'modula-js-templates.php'; } }