/
home
/
henzagold
/
blog
/
wp-content
/
themes
/
gillion
/
inc
/
plugins
/
metaboxes
/
File Upload :
llllll
Current File: /home/henzagold/blog/wp-content/themes/gillion/inc/plugins/metaboxes/metaboxes-megamenu.php
<?php /* ** Shufflehound Mega Menu Options - HTML */ if( gillion_framework() == 'redux' ) : function gillion_menus_custom_fields( $item_id = 0, $item = [], $depth = 0 ) { // $item_id, $item, $depth, $args, $id if( !$depth ) : $mega_menu = get_post_meta( $item_id, 'gillion-mega-menu', true ); $dynamic_elements = get_post_meta( $item_id, 'gillion-dynamic-elements', true ); $categories_order = get_post_meta( $item_id, 'gillion-categories-order', true ); $per_page = get_post_meta( $item_id, 'gillion-per-page', true ); $categories = get_post_meta( $item_id, 'gillion-categories', true ); $limit = get_post_meta( $item_id, 'gillion-limit', true ); ?> <div class="sh-menus-mega-menu-status-container"> <label> <input type="checkbox" name="menu_item_gillion-mega-menu[<?php echo intval( $item_id ); ?>]" value="on" <?php echo ( $mega_menu == 'on' ) ? ' checked' : ''; ?> class="sh-menus-mega-menu-checkbox"> <?php echo esc_attr__( 'Use as Mega Menu', 'gillion' ); ?> <br> </label> </div> <div class="sh-menus-mega-menu-options-container<?php echo ( $mega_menu == 'on' ) ? ' active' : ''; ?>"> <div class="sh-menus-mega-menu-options"> <div> <label> <?php echo esc_attr__( 'Show Blog Posts', 'gillion' ); ?> <br> <select name="menu_item_gillion-dynamic-elements[<?php echo intval( $item_id ); ?>]"> <option value="">Off</option> <option value="cat" <?php echo ( $dynamic_elements == 'cat' ) ? ' selected' : ''; ?>>On</option> </select> </label> </div> <div> <label> <?php echo esc_attr__( 'Categories Order', 'gillion' ); ?> <br> <select name="menu_item_gillion-categories-order[<?php echo intval( $item_id ); ?>]"> <option value="">Default</option> <option value="insert" <?php echo ( $categories_order == 'insert' ) ? ' selected' : ''; ?>>Custom Order (entered IDs order)</option> </select> </label> </div> <div> <label> <?php echo esc_attr__( 'Posts Per Page', 'gillion' ); ?> <br> <select name="menu_item_gillion-per-page[<?php echo intval( $item_id ); ?>]"> <option value="">Default (4 or 5 posts)</option> <option value="4" <?php echo ( $per_page == '4' ) ? ' selected' : ''; ?>>4 posts</option> <option value="5" <?php echo ( $per_page == '5' ) ? ' selected' : ''; ?>>5 posts</option> <option value="10" <?php echo ( $per_page == '10' ) ? ' selected' : ''; ?>>10 posts</option> </select> </label> </div> </div> <div class="sh-menus-mega-menu-options sh-menus-mega-menu-options-columns2"> <div> <label> <?php echo esc_attr__( 'Categories', 'gillion' ); ?> <a href="<?php echo esc_url( admin_url( 'edit-tags.php?taxonomy=category' ) ); ?>" target=_blank""> <?php echo esc_attr__( '(IDs: 1,2,3)', 'gillion' ); ?> </a> <br> <input type="text" name="menu_item_gillion-categories[<?php echo intval( $item_id ); ?>]" value="<?php echo esc_attr( $categories ); ?>" /> </label> </div> <div> <label> <?php echo esc_attr__( 'Posts Limit (max)', 'gillion' ); ?> <br> <input type="text" name="menu_item_gillion-limit[<?php echo intval( $item_id ); ?>]" value="<?php echo esc_attr( $limit ); ?>" placeholder="Default (8 posts)" /> </label> </div> </div> </div> <?php endif; } add_action( 'wp_nav_menu_item_custom_fields', 'gillion_menus_custom_fields', 10, 4 ); endif; /* ** Shufflehound Mega Menu Options - Save */ function gillion_menus_custom_fields_update( $menu_id, $menu_item_db_id ) { if( isset( $_POST['menu_item_gillion-mega-menu'][$menu_item_db_id] ) ) : // Mega menu status $mega_menu = sanitize_text_field( $_POST['menu_item_gillion-mega-menu'][$menu_item_db_id] ); if( $mega_menu == 'on' ) : update_post_meta( $menu_item_db_id, 'gillion-mega-menu', $mega_menu ); endif; if( $mega_menu ) : // Dynamic Elements if( isset( $_POST['menu_item_gillion-dynamic-elements'][$menu_item_db_id] ) ) : $sanitized_data = sanitize_text_field( $_POST['menu_item_gillion-dynamic-elements'][$menu_item_db_id] ); if( $sanitized_data ) : update_post_meta( $menu_item_db_id, 'gillion-dynamic-elements', $sanitized_data ); else : delete_post_meta( $menu_item_db_id, 'gillion-dynamic-elements' ); endif; endif; // Categories Order if( isset( $_POST['menu_item_gillion-categories-order'][$menu_item_db_id] ) ) : $sanitized_data = sanitize_text_field( $_POST['menu_item_gillion-categories-order'][$menu_item_db_id] ); if( $sanitized_data ) : update_post_meta( $menu_item_db_id, 'gillion-categories-order', $sanitized_data ); else : delete_post_meta( $menu_item_db_id, 'gillion-categories-order' ); endif; endif; // Per Page if( isset( $_POST['menu_item_gillion-per-page'][$menu_item_db_id] ) ) : $sanitized_data = sanitize_text_field( $_POST['menu_item_gillion-per-page'][$menu_item_db_id] ); if( $sanitized_data ) : update_post_meta( $menu_item_db_id, 'gillion-per-page', $sanitized_data ); else : delete_post_meta( $menu_item_db_id, 'gillion-per-page' ); endif; endif; // Categories if( isset( $_POST['menu_item_gillion-categories'][$menu_item_db_id] ) ) : $sanitized_data = sanitize_text_field( $_POST['menu_item_gillion-categories'][$menu_item_db_id] ); if( $sanitized_data ) : update_post_meta( $menu_item_db_id, 'gillion-categories', $sanitized_data ); else : delete_post_meta( $menu_item_db_id, 'gillion-categories' ); endif; endif; // Limit if( isset( $_POST['menu_item_gillion-limit'][$menu_item_db_id] ) ) : $sanitized_data = sanitize_text_field( $_POST['menu_item_gillion-limit'][$menu_item_db_id] ); if( $sanitized_data ) : update_post_meta( $menu_item_db_id, 'gillion-limit', $sanitized_data ); else : delete_post_meta( $menu_item_db_id, 'gillion-limit' ); endif; endif; endif; else : delete_post_meta( $menu_item_db_id, 'gillion-mega-menu' ); // return $menu_id; endif; } add_action( 'wp_update_nav_menu_item', 'gillion_menus_custom_fields_update', 10, 2 );
Copyright ©2k19 -
Hexid
|
Tex7ure