is_main_query() ) return; $is_static = get_option( 'list-in-static')['check01']; $ignore_tag = get_option( 'list-ignore-tag')['text']; $ignore_cat = get_option( 'list-ignore-category')['text']; $filter_day = get_option( 'list-rule-day')['date']; if ( $ignore_tag ) $ignore_tag = explode( ',', $ignore_tag ); if ( $ignore_cat ) $ignore_cat = explode( ',', $ignore_cat ); if ( $filter_day == 'none' ) $filter_day = null; if ( $is_static ) $query->set( 'post_type', ['post','page'] ); if ( $ignore_tag ) $query->set( 'tag__not_in', $ignore_tag ); if ( $ignore_cat ) $query->set( 'category__not_in', $ignore_cat ); if ( $filter_day ) $query->set( 'date_query', array( 'after' => '1 '. $filter_day .' ago' ) ); } add_action( 'pre_get_posts', 'bone_filter_index_posts' ); /** * Add Options for the Customizer. * * @since Bone 1.0 */ function bone_add_customize($wp_customize) { /** * Add Layout section. * * @since Bone 1.0 */ $wp_customize->add_section( 'layout', array( 'title' => __( 'Layout', 'bone' ), 'priority' => 20, ) ); /** * Add Filter section for Filter index posts. * * @since Bone 1.0 */ $wp_customize->add_section( 'rule', array( 'title' => __( 'Filter', 'bone' ), 'priority' => 30, 'description' => __( 'Filter for Index loop.', 'bone' ), ) ); /** * Include page type in index post loop. * Add setting and Control. * * @since Bone 1.0 */ $wp_customize->add_setting( 'list-in-static[check01]', array( 'type' => 'option', 'sanitize_callback' => 'bone_sanitize_checkbox', ) ); $wp_customize->add_control( 'list-in-static', array( 'section' => 'rule', 'label' => __( 'Include Pages', 'bone' ), 'settings' => 'list-in-static[check01]', 'type' => 'checkbox', ) ); /** * Exclude tags from index post loop. * Add setting and Control. * * @since Bone 1.0 */ $wp_customize->add_setting( 'list-ignore-tag[text]', array( 'type' => 'option', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'list-ignore-tag', array( 'section' => 'rule', 'label' => __( 'Exclude tags', 'bone' ), 'settings' => 'list-ignore-tag[text]', 'type' => 'text', 'input_attrs' => array( 'placeholder' => 'id, id, id...', ), ) ); /** * Exclude categories from index post loop. * Add setting and Control. * * @since Bone 1.0 */ $wp_customize->add_setting( 'list-ignore-category[text]', array( 'type' => 'option', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'list-ignore-category', array( 'section' => 'rule', 'label' => __( 'Exclude categories', 'bone' ), 'settings' => 'list-ignore-category[text]', 'type' => 'text', 'input_attrs' => array( 'placeholder' => 'id, id, id...', ), ) ); /** * Add filter by Period. * Add setting and Control. * * @since Bone 1.0 */ $wp_customize->add_setting( 'list-rule-day[date]', array( 'type' => 'option', 'default' => 'none', 'sanitize_callback' => 'bone_sanitize_choice', ) ); $wp_customize->add_control( 'list-rule-day[date]', array( 'section' => 'rule', 'label' => __( 'Day Filter', 'bone' ), 'settings' => 'list-rule-day[date]', 'type' => 'radio', 'choices' => array( 'none' => __( 'Allways', 'bone' ), 'day' => __( 'Today', 'bone' ), 'week' => __( 'one week', 'bone' ), 'month' => __( 'one month', 'bone' ), 'year' => __( 'one year', 'bone' ), ) ) ); /** * Change a main color. * This change CDN path as Material Design Lite. * Add setting and Control. * * @link http://www.getmdl.io/customize/index.html * @since Bone 1.0 */ $wp_customize->add_setting( 'color_set[main]', array( 'type' => 'option', 'default' => 'indigo', 'sanitize_callback' => 'bone_sanitize_choice', ) ); $wp_customize->add_control( 'color_set[main]', array( 'section' => 'colors', 'description' => __('There needs to be Different Color.', 'bone' ), 'label' => __( 'Main color', 'bone' ), 'settings' => 'color_set[main]', 'type' => 'select', 'choices' => array( 'red' => 'Red', 'pink' => 'Pink', 'purple' => 'Purple', 'deep_purple' => 'Deep Purple', 'indigo' => 'Indigo', 'blue' => 'Blue', 'light_blue' => 'Light Blue', 'cyan' => 'Cyan', 'teal' => 'Teal', 'green' => 'Green', 'light_green' => 'Light Green', 'lime' => 'Lime', 'yellow' => 'Yellow', 'amber' => 'Amber', 'orange' => 'Orange', 'deep_orange' => 'Deep Orange', 'brown' => 'Brown', 'grey' => 'Grey', 'blue_grey' => 'Blue Grey', ) ) ); /** * Change a sub color. * This change CDN path as Material Design Lite. * Add setting and Control. * * @link http://www.getmdl.io/customize/index.html * @since Bone 1.0 */ $wp_customize->add_setting( 'color_set[sub]', array( 'type' => 'option', 'default' => 'pink', 'sanitize_callback' => 'bone_sanitize_choice', ) ); $wp_customize->add_control( 'color_set[sub]', array( 'section' => 'colors', 'label' => __( 'Sub color', 'bone' ), 'settings' => 'color_set[sub]', 'type' => 'select', 'choices' => array( 'red' => 'Red', 'pink' => 'Pink', 'purple' => 'Purple', 'deep_purple' => 'Deep Purple', 'indigo' => 'Indigo', 'blue' => 'Blue', 'light_blue' => 'Light Blue', 'cyan' => 'Cyan', 'teal' => 'Teal', 'green' => 'Green', 'light_green' => 'Light Green', 'lime' => 'Lime', 'yellow' => 'Yellow', 'amber' => 'Amber', 'orange' => 'Orange', 'deep_orange' => 'Deep Orange', ) ) ); /** * Transparent Heading bar. * Add setting and Control. * * @since Bone 1.0 */ $wp_customize->add_setting( 'header_transparent[check01]', array( 'type' => 'option', 'sanitize_callback' => 'bone_sanitize_checkbox', ) ); $wp_customize->add_control( 'header_transparent', array( 'section' => 'colors', 'label' => __( 'Transparent Header', 'bone' ), 'settings' => 'header_transparent[check01]', 'type' => 'checkbox', ) ); /** * Hide excerpt. * Add setting and Control. * * @since Bone 1.0 */ $wp_customize->add_setting( 'hide_excerpt[check01]', array( 'type' => 'option', 'sanitize_callback' => 'bone_sanitize_checkbox', ) ); $wp_customize->add_control( 'hide_excerpt', array( 'section' => 'layout', 'label' => __( 'Hide excerpt', 'bone' ), 'settings' => 'hide_excerpt[check01]', 'type' => 'checkbox', ) ); /** * Fix Heading bar. * Add setting and Control. * * @since Bone 1.0 */ $wp_customize->add_setting( 'header_fix[check01]', array( 'type' => 'option', 'default' => true, 'sanitize_callback' => 'bone_sanitize_checkbox', ) ); $wp_customize->add_control( 'header_fix_c', array( 'section' => 'layout', 'label' => __( 'Fix heading bar', 'bone' ), 'settings' => 'header_fix[check01]', 'type' => 'checkbox', ) ); /** * Fix side navigation. * Add setting and Control. * * @since Bone 1.0 */ $wp_customize->add_setting( 'side_fix[check01]', array( 'type' => 'option', 'sanitize_callback' => 'bone_sanitize_checkbox', ) ); $wp_customize->add_control( 'side_fix_c', array( 'section' => 'layout', 'label' => __( 'Fix side navigation.', 'bone' ), 'settings' => 'side_fix[check01]', 'type' => 'checkbox', ) ); /** * Adjust the grid margins. * Add setting and Control. * * @since Bone 1.0 */ $wp_customize->add_setting( 'grid-space[radio]', array( 'type' => 'option', 'default' => 'midium', 'sanitize_callback' => 'bone_sanitize_choice', ) ); $wp_customize->add_control( 'grid-space[radio]', array( 'section' => 'layout', 'label' => __( 'Grid margins.', 'bone' ), 'settings' => 'grid-space[radio]', 'type' => 'radio', 'choices' => array( 'none' => __( 'fit', 'bone' ), 'small' => __( 'small', 'bone' ), 'midium' => __( 'midium', 'bone' ), 'large' => __( 'large', 'bone' ), ), ) ); /** * Background to full screen. * Add setting and Control. * * @since Bone 1.0 */ $wp_customize->add_setting('bg_cover[check01]', array( 'type' => 'option', 'sanitize_callback' => 'bone_sanitize_checkbox', ) ); $wp_customize->add_control( 'bg_cover', array( 'section' => 'background_image', 'label' => __( 'Full screen background', 'bone' ), 'settings' => 'bg_cover[check01]', 'type' => 'checkbox', ) ); /** * Column adjustment. * Add setting and Control. * * @since Bone 1.0 */ $wp_customize->add_setting( 'column[select01]', array( 'type' => 'option', 'default' => '3', 'sanitize_callback' => 'bone_sanitize_choice', ) ); $wp_customize->add_control( 'column[select01]', array( 'section' => 'layout', 'label' => __( 'Column', 'bone' ), 'settings' => 'column[select01]', 'type' => 'select', 'choices' => array( '1' => 1, '2' => 2, '3' => 3, '4' => 4, '6' => 6, '12' => 12, ), ) ); /** * Change Logo * Add setting and Control. * * @since Bone 1.0 */ $wp_customize->add_setting( 'logo[img]', array( 'type' => 'option', 'sanitize_callback' => 'esc_url_raw', ) ); $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'logo', array( 'label' => __( 'Logo image', 'bone' ), 'settings' => 'logo[img]', 'section' => 'title_tagline' ) ) ); /** * Main Twitter acount * Add setting and Control. * * @since Bone 1.0 */ $wp_customize->add_setting( 'twitter[text]', array( 'type' => 'option', 'sanitize_callback' => 'esc_url_raw', ) ); $wp_customize->add_control( 'twitter', array( 'section' => 'title_tagline', 'label' => 'Twitter', 'settings' => 'twitter[text]', 'type' => 'text', 'input_attrs' => array( 'placeholder' => 'http://twitter.com/sisio4', ), ) ); /** * Main Facebook account * Add setting and Control. * * @since Bone 1.0 */ $wp_customize->add_setting( 'facebook[text]', array( 'type' => 'option', 'sanitize_callback' => 'esc_url_raw', ) ); $wp_customize->add_control( 'facebook', array( 'section' => 'title_tagline', 'label' => 'Facebook', 'settings' => 'facebook[text]', 'type' => 'text', 'input_attrs' => array( 'placeholder' => 'https://www.facebook.com/xxx', ), ) ); /** * Main Google+ account * Add setting and Control. * * @since Bone 1.0 */ $wp_customize->add_setting( 'google-plus[text]', array( 'type' => 'option', 'sanitize_callback' => 'esc_url_raw', ) ); $wp_customize->add_control( 'google-plus', array( 'section' => 'title_tagline', 'label' => 'Google+', 'settings' => 'google-plus[text]', 'type' => 'text', 'input_attrs' => array( 'placeholder' => 'https://plus.google.com/xxx', ), ) ); /** * Main LINE account * Add setting and Control. * * @since Bone 1.0 */ $wp_customize->add_setting( 'youtube[text]', array( 'type' => 'option', 'sanitize_callback' => 'esc_url_raw', ) ); $wp_customize->add_control( 'youtube', array( 'section' => 'title_tagline', 'label' => 'YouTube', 'settings' => 'youtube[text]', 'type' => 'text', 'input_attrs' => array( 'placeholder' => 'https://www.youtube.com/user/YouTubeJapan', ), ) ); /** * Main Instagram account * Add setting and Control. * * @since Bone 1.0 */ $wp_customize->add_setting( 'instagram[text]', array( 'type' => 'option', 'sanitize_callback' => 'esc_url_raw', ) ); $wp_customize->add_control( 'instagram', array( 'section' => 'title_tagline', 'label' => 'Instagram', 'settings' => 'instagram[text]', 'type' => 'text', 'input_attrs' => array( 'placeholder' => 'http://', ), ) ); } add_action( 'customize_register', 'bone_add_customize' ); /** * Echo a header text color. * This changed by customizer option. * * @since Bone 1.0 */ function bone_opt_header_color() { if ( get_header_textcolor() ) { $css = 'h1.bone-hero__title { color: #' . get_header_textcolor() . '}'; $css .= 'p.bone-hero__sub-title { color: #' . get_header_textcolor() . '}'; $css .= '.bone-drawer__title { color: #' . get_header_textcolor() . '}'; wp_add_inline_style( 'bone-main-style', $css ); } } add_action( 'wp_enqueue_scripts', 'bone_opt_header_color' ); /** * Sanitize Checkbox * * @since Bone 1.0 */ function bone_sanitize_checkbox( $input ){ if($input==true){ return true; }else{ return false; } } /** * Sanitize radio and select field. * * @since Bone 1.0 */ function bone_sanitize_choice( $input, $setting ) { global $wp_customize; $control = $wp_customize->get_control( $setting->id ); if ( array_key_exists( $input, $control->choices ) ) { return $input; } else { return $setting->default; } }