array( 'top-header'=>array( '0' => array( 'panel' => 'bingle_headercustom_section', 'section' => 'customhtml', 'enable' => '0' ), '1' => array( 'panel' => 'bingle_headersocial_section', 'section' => 'social', 'enable' => '0' ), ), 'main-header' => array( '0' => array( 'panel' => 'title_tagline', 'section' => 'site-branding', 'enable' => '1' ) , '1' => array( 'panel' => 'bingle_headeraddress_section', 'section' => 'address', 'enable' => '0' ), '2' => array( 'panel' => 'bingle_headerphone_section', 'section' => 'phone', 'enable' => '0' ), '3' => array( 'panel' => 'bingle_headeremail_section', 'section' => 'email', 'enable' => '0' ), '4' => array( 'panel' => 'bingle_headercart_section', 'section' => 'cart', 'enable' => '0' ), '5' => array( 'panel' => 'bingle_headersidemenu_section', 'section' => 'sidemenu', 'enable' => '1' ), ), 'bottom-header' => array ( '0' => array( 'panel' => 'bingle_headermenu_section', 'section' => 'nav-menu', 'enable' => '0' ), '1' => array( 'panel' => 'bingle_headersearch_section', 'section' => 'search', 'enable' => '0' ), '2' => array( 'panel' => 'bingle_headerbutton_section', 'section' => 'button', 'enable' => '0' ) ), ), 'footer'=> array( 'top-footer' => array( '0' => array( 'panel' => 'bingle_footer_menu_section', 'section' => 'footermenu', 'enable' => '0' ) ), 'main-footer' => array( '0' => array( 'panel' => 'bingle_footer_copyright_section', 'section' => 'copyright', 'enable' => '1' ), '1' => array( 'panel' => 'bingle_footer_social', 'section' => 'footersocial', 'enable' => '0' ) ) ) ); if(empty($section)){ return $bingle_defaults; } if(!class_exists('WooCommerce')){ unset($bingle_defaults['header']['main-header'][4]); } return $bingle_defaults[$section]; } } if ( ! function_exists( 'bingle_get_section_position' ) ) { function bingle_get_section_position( $key,$section='' ) { if(empty($section)){ $section = 'header'; } $bingle_sortsec_pos = bingle_get_section_order($section); $return = '0'; if(($bingle_sortsec_pos!='[]')){ $position = array_search( $key, array_column( $bingle_sortsec_pos, 'panel' )); $return = ( $position + 1 ) * 10; } return $return; } } if(!function_exists('bingle_get_section_order')){ function bingle_get_section_order($section=''){ $bingle_defaults = json_encode(bingle_get_sortable_defaults()); //$bingle_sections_order = $bingle_defaults; //reset values if sections are added $bingle_sections_order = get_theme_mod('bingle_dragndrop_sections_order',$bingle_defaults); $bingle_sections_order = json_decode($bingle_sections_order,true); if(($bingle_sections_order!='[]' && ($bingle_sections_order!=null))){ $order_return = $bingle_sections_order; }else{ $order_return = json_decode($bingle_defaults,true); } if(!empty($section)){ return $order_return[$section]; } else{ return $order_return; } } } add_action( 'wp_ajax_bingle_save_sections_order', 'bingle_save_sections_order_cb' ); function bingle_save_sections_order_cb() { if ( isset( $_POST['binglesecOrder']) ) { $binglesecOrder = wp_unslash($_POST['binglesecOrder']); $binglesecOrder = stripslashes($binglesecOrder); $binglesecOrder = json_decode($binglesecOrder,true); $newbinglesecOrder = array(); foreach($binglesecOrder as $bsk=>$bsv){ foreach ($bsv as $key => $value) { $newbinglesecOrder[$key] = $value; } } $newbinglesecOrder = json_encode($newbinglesecOrder); set_theme_mod( 'bingle_dragndrop_sections_order',$newbinglesecOrder); echo 'success'; } wp_die(); } if(is_admin()): add_action( 'admin_enqueue_scripts', 'bingle_admin_dragndrop' ); function bingle_admin_dragndrop($hook){ wp_enqueue_style( 'bingle-dndstyle', get_template_directory_uri() . '/assets/binglednd/bingle-dnd.css'); wp_enqueue_script( 'bingle-dnd', get_template_directory_uri().'/assets/binglednd/bingle-dnd.js', array( 'jquery','jquery-ui-sortable','jquery-ui-resizable' ), '20190918', true ); $bingle_dnd = array(); $bingle_dnd['ajax_url'] = admin_url( 'admin-ajax.php' ); wp_localize_script( 'bingle-dnd', 'bingleDnDAjax', $bingle_dnd ); } add_action( 'customize_controls_print_footer_scripts', 'bingle_customzier_drag_drop_template' ); if(!function_exists('bingle_customzier_drag_drop_template')){ function bingle_customzier_drag_drop_template(){ ?>