alanah_framework_post_id( $title ); } /** * Add color panel settings */ function alanah_colorpicker( $id ) { global $al_admin; return $al_admin->alanah_colorpicker( $id ); } /** * Background color settings */ function alanah_add_background_color_setting( $id ) { global $al_admin; return $al_admin->alanah_add_background_color_setting( $id ); } /** * Uploader settings */ function alanah_uploader( $id, $title = '' ) { global $al_admin; return $al_admin->alanah_uploader( $id, $title ); } /** * Upload Product Settings */ function alanah_add_upload_product_setting( $page_id, $id, $title = '' ) { global $al_admin; return $al_admin->alanah_add_upload_product_setting( $page_id, $id, $title ); } /** * Default Terms Thumbnails data for demo purpose */ function alanah_default_terms_thumb_data() { return array( 'digital-watches' => 'watch11', 'fashion-apparel' => 'cloth02', 'kids-fashion' => 'cloth21', 'mens-fashion' => 'cloth16', 'womens-fashion' => 'spec12', 'footwear' => 'shoes01', 'mens-footwear' => 'shoes03', 'women-footwear' => 'sandle01', 'furniture' => 'chair03', 'accessories' => 'watch05', 'table-chairs' => 'chair14', 'handbags' => 'bag06', 'side-products' => 'side04', 'glasses' => 'spec14', 'hats-caps' => 'cap01' ); } function alanah_default_megamenu_item_for_importer() { $ID1 = get_page_by_title( 'Appreals', OBJECT, 'nav_menu_item' ); $ID2 = get_page_by_title( 'Accessories', OBJECT, 'nav_menu_item' ); $ID3 = get_page_by_title( 'Furnitures', OBJECT, 'nav_menu_item' ); $ID4 = get_page_by_title( 'Electronics', OBJECT, 'nav_menu_item' ); $ID5 = get_page_by_title( 'Home Decors', OBJECT, 'nav_menu_item' ); $ID6 = get_page_by_title( 'Sports', OBJECT, 'nav_menu_item' ); $ID7 = get_page_by_title( 'Computer Peripherals', OBJECT, 'nav_menu_item' ); $ID8 = get_page_by_title( 'Mobile Accessories', OBJECT, 'nav_menu_item' ); return array( 'type' => 'grid', 'grid' => array( array( 'meta' => array( 'class' => '', 'hide-on-desktop' => false, 'hide-on-mobile' => false, 'columns' => 12 ), 'columns' => array( array( 'meta' => array( 'span' => 3, 'class' => '', 'hide-on-desktop' => false, 'hide-on-mobile' => false ), 'items' => array( array( 'id' => $ID1->ID, 'type' => 'item' ) ) ), array( 'meta' => array( 'span' => 3, 'class' => '', 'hide-on-desktop' => false, 'hide-on-mobile' => false ), 'items' => array( array( 'id' => $ID2->ID, 'type' => 'item' ) ) ), array( 'meta' => array( 'span' => 3, 'class' => '', 'hide-on-desktop' => false, 'hide-on-mobile' => false ), 'items' => array( array( 'id' => $ID3->ID, 'type' => 'item' ) ) ), array( 'meta' => array( 'span' => 3, 'class' => '', 'hide-on-desktop' => false, 'hide-on-mobile' => false ), 'items' => array( array( 'id' => $ID4->ID, 'type' => 'item' ) ) ) ) ), array( 'meta' => array( 'class' => '', 'hide-on-desktop' => false, 'hide-on-mobile' => false, 'columns' => 12 ), 'columns' => array( array( 'meta' => array( 'span' => 3, 'class' => '', 'hide-on-desktop' => false, 'hide-on-mobile' => false ), 'items' => array( array( 'id' => $ID5->ID, 'type' => 'item' ) ) ), array( 'meta' => array( 'span' => 3, 'class' => '', 'hide-on-desktop' => false, 'hide-on-mobile' => false ), 'items' => array( array( 'id' => $ID6->ID, 'type' => 'item' ) ) ), array( 'meta' => array( 'span' => 3, 'class' => '', 'hide-on-desktop' => false, 'hide-on-mobile' => false ), 'items' => array( array( 'id' => $ID7->ID, 'type' => 'item' ) ) ), array( 'meta' => array( 'span' => 3, 'class' => '', 'hide-on-desktop' => false, 'hide-on-mobile' => false ), 'items' => array( array( 'id' => $ID8->ID, 'type' => 'item' ) ) ) ) ) ) ); } /** * Admin google fonts Ajax Callback */ add_action( 'wp_ajax_alanah_update_gfonts', 'alanah_update_gfonts' ); function alanah_update_gfonts() { global $al_admin; if( isset( $_POST['action'] ) && $_POST['action'] == 'alanah_update_gfonts' ) : $current_font = $_POST['currentfont']; echo $al_admin->alanah_gfonts_style_dropdown( $current_font ); echo '--SEPERATOR--'; echo $al_admin->alanah_gfonts_weight_dropdown( $current_font ); die(0); endif; } /** * Admin google font weight Ajax Callback */ add_action( 'wp_ajax_alanah_update_gfonts_weight', 'alanah_update_gfonts_weight' ); function alanah_update_gfonts_weight() { global $al_admin; if( isset( $_POST['action'] ) && $_POST['action'] == 'alanah_update_gfonts_weight' ) : $current_font = $_POST['currentfont']; $current_style = $_POST['currentstyle']; echo $al_admin->alanah_gfonts_weight_dropdown( $current_font, $current_style ); die(0); endif; } /** * Alanah Options Handler */ add_action( 'wp_ajax_alanah_options_data', 'alanah_update_theme_options' ); function alanah_update_theme_options() { global $al_name, $al_prefix; if( isset( $_POST['action'] ) && $_POST['action'] == 'alanah_options_data' ) : //Unset unnecessary data unset( $_POST['action'] ); $options = []; foreach( $_POST as $key => $val ) { $key = str_replace( $al_prefix, '', $key ); $options[ $key ] = $val; } update_option( $al_name, $options ); die(0); endif; } /** * Update Page Options */ add_action( 'save_post', 'alanah_save_page_options', 10, 3 ); function alanah_save_page_options( $post_id, $post, $update ) { global $al_prefix; //Return if post type is not page if( $post->post_type !== 'page' ) return; //Return if page status is autodraft if( $post->post_status == 'auto-draft' ) return; //Return if autosave if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return; //No need to use if condition here. It will save blank if nothing selected if( array_key_exists( $al_prefix . 'page_title', $_POST ) ) update_post_meta( $post_id, 'page_title', $_POST[ $al_prefix . 'page_title' ] ); if( array_key_exists( $al_prefix . 'display_sidebar', $_POST ) ) update_post_meta( $post_id, 'display_sidebar', $_POST[ $al_prefix . 'display_sidebar' ] ); if( array_key_exists( $al_prefix . 'sidebar_position', $_POST ) ) update_post_meta( $post_id, 'sidebar_position', $_POST[ $al_prefix . 'sidebar_position' ] ); if( array_key_exists( $al_prefix . 'container_bg', $_POST ) ) update_post_meta( $post_id, 'container_bg', $_POST[ $al_prefix . 'container_bg' ] ); if( array_key_exists( $al_prefix . 'page_breadcrumb', $_POST ) ) update_post_meta( $post_id, 'page_breadcrumb', $_POST[ $al_prefix . 'page_breadcrumb' ] ); if( array_key_exists( $al_prefix . 'page_bg', $_POST ) ) update_post_meta( $post_id, 'page_bg', $_POST[ $al_prefix . 'page_bg' ] ); } /** * Reset Theme Settings */ add_action( 'admin_init', 'alanah_reset_theme_settings' ); function alanah_reset_theme_settings() { global $al_defaults, $al_name; if( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'ctresetoptions' ) : update_option( $al_name, $al_defaults->alanah_theme_settings_defaults() ); // update_option wp_safe_redirect( admin_url( 'admin.php?page=alanahoptions&success=1' ) ); exit; endif; } /** * Reset Theme settings to fix layout after demo imported * Only for demo data fixing. Its useful if demo data have things missing. */ add_action( 'alanah_demo_imported', 'alanah_settings_after_demo', 10, 1 ); function alanah_settings_after_demo( $name ) { global $wpdb, $al_defaults, $al_name; //Post table $table = $wpdb->prefix . "posts"; if( $name == 'fullwidth' ) : $settings = $al_defaults->alanah_theme_settings_defaults(); $newsettings = array(); foreach( $settings as $key => $val ) { if( $key == 'layout' ) $val = 'fullwidth'; $newsettings[$key] = $val; } update_option( $al_name, $newsettings ); endif; //Add Product Categories Thumbnails if its not automatically added by demo importer $term_data = alanah_default_terms_thumb_data(); foreach( $term_data as $key => $val ) { $term = get_term_by( 'slug', $key, 'product_cat' ); //Get attachment id $attachment = $wpdb->get_results("SELECT ID FROM $table WHERE post_name='$val' AND post_status='inherit' AND post_type='attachment'"); if( !empty( $term ) && !empty( $attachment ) ) : add_term_meta( $term->term_id, 'thumbnail_id', $attachment[0]->ID ); endif; } //Fix nav widgets $footer_menu = get_term_by( 'name', 'Footer Menu', 'nav_menu' ); $offers_menu = get_term_by( 'name', 'Offers', 'nav_menu' ); $account_menu = get_term_by( 'name', 'Our Account', 'nav_menu' ); $shipping_menu = get_term_by( 'name', 'Shipping', 'nav_menu' ); $support_menu = get_term_by( 'name', 'Support', 'nav_menu' ); $nav_widgets = array( array(), array( 'title' => '', //Footer menu widget 'nav_menu' => $footer_menu->term_id ), array( 'title' => __( 'Our Offers', 'alanah-free' ), //Offer widget 'nav_menu' => $offers_menu->term_id ), array( 'title' => __( 'Shipping Info', 'alanah-free' ), //Shipping widget 'nav_menu' => $shipping_menu->term_id ), array( 'title' => __( 'Our Account', 'alanah-free' ), //Account widget 'nav_menu' => $account_menu->term_id ), array( 'title' => __( 'Our Support', 'alanah-free' ), //Support widget 'nav_menu' => $support_menu->term_id ) ); update_option( 'widget_nav_menu', $nav_widgets ); //Arrange mega menu Items $menuitemarray = alanah_default_megamenu_item_for_importer(); $shop = get_page_by_title( 'Shop', OBJECT, 'nav_menu_item' ); if( isset( $shop->ID ) ) : update_post_meta( $shop->ID, '_megamenu', $menuitemarray ); endif; } /** * Update Notice when theme settings Resetted */ add_action( 'admin_notices', 'alanah_update_notice' ); function alanah_update_notice() { if( isset( $_REQUEST['page'] ) && isset( $_REQUEST['success'] ) && $_REQUEST['page'] == 'alanahoptions' ) : echo '
' . __( "Settings Successfully Resetted!", "alanah-free" ) . '