is_rtl(),
);
wp_localize_script( 'travel-magazine-custom-js', 'tm_data', $array );
}
add_action( 'wp_enqueue_scripts', 'travel_magazine_enqueue_styles_and_scripts' );
/**
* Remove action from parent
*/
function travel_magazine_remove_parent_action(){
remove_action( 'customize_register', 'numinous_customizer_theme_info' );
}
add_action( 'init', 'travel_magazine_remove_parent_action' );
/**
* Travel Magazine Theme Info
*/
function travel_magazine_customizer_theme_info( $wp_customize ) {
$wp_customize->add_section( 'theme_info' , array(
'title' => __( 'Demo and Documentation' , 'travel-magazine' ),
'priority' => 6,
));
$wp_customize->add_setting(
'setup_instruction',
array(
'sanitize_callback' => 'sanitize_text_field'
)
);
$wp_customize->add_control(
new Numinous_Theme_Info(
$wp_customize,
'setup_instruction',
array(
'settings' => 'setup_instruction',
'section' => 'theme_info',
)
)
);
$wp_customize->add_setting('theme_info_theme',array(
'default' => '',
'sanitize_callback' => 'wp_kses_post',
));
$theme_info = '';
$theme_info .= '' . __( 'Click here', 'travel-magazine' ) . '
';
$theme_info .= '' . __( 'Click here', 'travel-magazine' ) . '
';
$theme_info .= '' . __( 'Click here', 'travel-magazine' ) . '
';
$theme_info .= '' . __( 'Click here', 'travel-magazine' ) . '
';
$theme_info .= '' . __( 'Click here', 'travel-magazine' ) . '
';
$wp_customize->add_control( new Numinous_Theme_Info( $wp_customize ,'theme_info_theme',array(
'label' => __( 'About Travel Magazine' , 'travel-magazine' ),
'section' => 'theme_info',
'description' => $theme_info
)));
}
add_action( 'customize_register', 'travel_magazine_customizer_theme_info' );
/**
* Customize resgister settings and controls
*/
function travel_magazine_customize_register( $wp_customize ){
// Load our custom control.
require_once get_stylesheet_directory() . '/inc/custom-controls/select/class-select-control.php';
require_once get_stylesheet_directory() . '/inc/custom-controls/radioimg/class-radio-image-control.php';
// Register the control type.
$wp_customize->register_control_type( 'Travel_Magazine_Select_Control' );
$wp_customize->register_control_type( 'Travel_Magazine_Radio_Image_Control' );
$wp_customize->add_panel(
'travel_magazine_header_setting',
array(
'priority' => 10,
'title' => __( 'Header Settings', 'travel-magazine' ),
'capability' => 'edit_theme_options',
)
);
$wp_customize->add_section(
'travel_magazine_header_misc_setting',
array(
'title' => __( 'Misc Settings', 'travel-magazine' ),
'panel' => 'travel_magazine_header_setting'
)
);
$wp_customize->get_control( 'numinous_ed_search_form' )->section = 'travel_magazine_header_misc_setting';
$wp_customize->get_control( 'numinous_breaking_news_label' )->section = 'travel_magazine_header_misc_setting';
$wp_customize->get_control( 'numinous_breaking_news_cat' )->section = 'travel_magazine_header_misc_setting';
$wp_customize->add_section(
'travel_magazine_header_slider_setting',
array(
'title' => __( 'Header Slider Settings', 'travel-magazine' ),
'priority' => 22,
'panel' => 'travel_magazine_header_setting',
)
);
/** Toggle Slider */
$wp_customize->add_setting(
'travel_magazine_ed_slider',
array(
'default' => '',
'sanitize_callback' => 'numinous_sanitize_checkbox',
)
);
$wp_customize->add_control(
'travel_magazine_ed_slider',
array(
'label' => __( 'Enable header slider in homepage', 'travel-magazine' ),
'section' => 'travel_magazine_header_slider_setting',
'type' => 'checkbox',
)
);
/** Header slider category */
$wp_customize->add_setting(
'travel_magazine_header_slider_cat',
array(
'default' => '',
'sanitize_callback' => 'numinous_sanitize_select',
)
);
/** Select Category */
$wp_customize->add_control(
new Travel_Magazine_Select_Control(
$wp_customize,
'travel_magazine_header_slider_cat',
array(
'label' => __( 'Slider Category', 'travel-magazine' ),
'section' => 'travel_magazine_header_slider_setting',
'type' => 'select',
'choices' => travel_magazine_get_categories(),
)
)
);
/** Top section Layout */
$wp_customize->add_setting( 'travel_magazine_top_layout', array(
'default' => 'layout1',
'sanitize_callback' => 'travel_magazine_sanitize_radio'
) );
$wp_customize->add_control(
new Travel_Magazine_Radio_Image_Control(
$wp_customize,
'travel_magazine_top_layout',
array(
'section' => 'numinous_top_news_settings',
'label' => __( 'Top Section Layout', 'travel-magazine' ),
'description' => __( 'Choose the layout for top section.', 'travel-magazine' ),
'choices' => array(
'layout1' => get_stylesheet_directory_uri() . '/images/top1.png',
'layout2' => get_stylesheet_directory_uri() . '/images/top2.png',
)
)
)
);
/** Middle section */
$wp_customize->add_section(
'travel_magazine_middle_section_setting',
array(
'title' => __( 'Middle Section', 'travel-magazine' ),
'priority' => 25,
'panel' => 'numinous_home_page_settings',
)
);
/** Enable Middle Section */
$wp_customize->add_setting(
'travel_magazine_ed_middle_section',
array(
'default' => '',
'sanitize_callback' => 'numinous_sanitize_checkbox',
)
);
$wp_customize->add_control(
'travel_magazine_ed_middle_section',
array(
'label' => __( 'Enable Middle Section', 'travel-magazine' ),
'section' => 'travel_magazine_middle_section_setting',
'type' => 'checkbox',
)
);
/** Middle News Label */
$wp_customize->add_setting(
'travel_magazine_middle_section_label',
array(
'default' => __( 'Latest News', 'travel-magazine' ),
'sanitize_callback' => 'sanitize_text_field',
)
);
$wp_customize->add_control(
'travel_magazine_middle_section_label',
array(
'label' => __( 'Middle Section Label', 'travel-magazine' ),
'section' => 'travel_magazine_middle_section_setting',
'type' => 'text',
)
);
/** Header slider category */
$wp_customize->add_setting(
'travel_magazine_middle_section_cat',
array(
'default' => '',
'sanitize_callback' => 'numinous_sanitize_select',
)
);
/** Middle Section Category */
$wp_customize->add_control(
new Travel_Magazine_Select_Control(
$wp_customize,
'travel_magazine_middle_section_cat',
array(
'label' => __( 'Middle Section Category', 'travel-magazine' ),
'section' => 'travel_magazine_middle_section_setting',
'choices' => travel_magazine_get_categories()
)
)
);
}
add_action( 'customize_register', 'travel_magazine_customize_register', 100 );
function travel_magazine_get_categories(){
/* Option list of all categories */
$option_categories = array();
$args = array( 'hide_empty' => false );
$category_lists = get_categories( $args );
$option_categories[''] = __( 'Choose Category', 'travel-magazine' );
foreach( $category_lists as $category ){
$option_categories[$category->term_id] = $category->name;
}
return $option_categories;
}
function travel_magazine_sanitize_radio( $input, $setting ) {
// Ensure input is a slug.
$input = sanitize_key( $input );
// Get list of choices from the control associated with the setting.
$choices = $setting->manager->get_control( $setting->id )->choices;
// If the input is a valid key, return it; otherwise, return the default.
return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
}
function travel_magazine_header_slider(){
$enable_slider = get_theme_mod( 'travel_magazine_ed_slider' );
$slider_cat = get_theme_mod( 'travel_magazine_header_slider_cat' );
if( $enable_slider && $slider_cat && ( is_page_template( 'template-home.php' ) || ( is_front_page() && ! is_home() ) ) ){
$args = array(
'post_type' => 'post',
'cat' => $slider_cat,
'post_status' => 'publish',
'posts_per_page' => -1,
'ignore_sticky_posts' => true
);
$qry = new WP_Query( $args );
if( $qry->have_posts() ){ ?>