php Genesis Framework - WP Customizer

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php Genesis Framework - WP Customizer相关的知识,希望对你有一定的参考价值。

<?php

//* Add Image upload to WordPress Theme Customizer
add_action( 'customize_register', 'sixteen_nine_customizer' );
function sixteen_nine_customizer(){

	require_once( get_stylesheet_directory() . '/lib/customize.php' );
	
}


//* Enable & Disable elements on single post
add_action( 'genesis_meta', 'single_post_elements' );
function single_post_elements(){
	if (is_singular('post')) {

	// * Featured Images
	add_action('genesis_before_entry_content','featured_images_on_single_post',5);
	function featured_images_on_single_post(){
		$image = get_theme_mod( 'enable_featured_images_single', true );
		if($image){
			if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
            the_post_thumbnail( 'custom-size', array( 'alt'  => esc_html ( get_the_title() ),'class'  => 'featured-images' )); 
        	} // custom-size is the images size for featured images
		}
	}

	// * Author Box
	$author = get_theme_mod( 'enable_author_single', true );
	if(!$author){
		//* Remove the author box on single posts HTML5 Themes
		remove_action( 'genesis_after_entry', 'genesis_do_author_box_single', 8 );
	}


	// * Prev Next Layout
	$prevnext = get_theme_mod( 'enable_prev_next_single', true );
		
	if(!$prevnext){
		//* Remove the author box on single posts HTML5 Themes
		remove_action( 'genesis_after_entry', 'custom_prev_next_post_nav',10);
	}

	// * Site Layout
	$sitelayout = get_theme_mod( 'layout_single', genesis_site_layout() );

	if($sitelayout === 'site-default' ){
		//* no action
	};
		
	if($sitelayout === 'content-sidebar' ){
		add_filter( 'genesis_site_layout', '__genesis_return_content_sidebar' );
	};
	if($sitelayout === 'full-width-content' ){
		add_filter( 'genesis_site_layout', '__genesis_return_full_width_content' );
	};
		
	};
}

<?php

global $wp_customize;

//* SECTION  OF GENESIS

$wp_customize->add_section( 'enable_single_post_elements', array(
	'title' => __( 'Single Post' ),
	'description' => __( 'to enable & disable element on single post' ),
	'panel' => 'genesis', // Not typically needed.
	'priority' => 75,
	'capability' => 'edit_theme_options',
	'theme_supports' => '', // Rarely needed.
) );

//* ENABLE & DISABLE FEATURED IMAGES

$wp_customize->add_setting( 'enable_featured_images_single', array(
	'type' => 'theme_mod', // or 'option'
	'capability' => 'edit_theme_options',
	'theme_supports' => '', // Rarely needed.
	'default' => true,
	'transport' => 'refresh', // or postMessage
	'sanitize_callback' => '',
	'sanitize_js_callback' => '', // Basically to_json.
) );

$wp_customize->add_control( 'enable_featured_images_single', array(
	'type' => 'checkbox',
	'priority' => 10, // Within the section.
	'section' => 'enable_single_post_elements', // Required, core or custom.
	'label' => __( 'Show Featured Image' ),
	'description' => __( '' ),
	//'active_callback' => 'is_front_page',
) );

//* ENABLE & DISABLE AUTHOR BOX

$wp_customize->add_setting( 'enable_author_single', array(
	'type' => 'theme_mod', // or 'option'
	'capability' => 'edit_theme_options',
	'theme_supports' => '', // Rarely needed.
	'default' => true,
	'transport' => 'refresh', // or postMessage
	'sanitize_callback' => '',
	'sanitize_js_callback' => '', // Basically to_json.
) );

$wp_customize->add_control( 'enable_author_single', array(
	'type' => 'checkbox',
	'priority' => 10, // Within the section.
	'section' => 'enable_single_post_elements', // Required, core or custom.
	'label' => __( 'Show Author Box ' ),
	'description' => __( '' ),
	//'active_callback' => 'is_front_page',
) );


//* ENABLE & DISABLE PREV/NEXT POST PAGINATION

$wp_customize->add_setting( 'enable_prev_next_single', array(
	'type' => 'theme_mod', // or 'option'
	'capability' => 'edit_theme_options',
	'theme_supports' => '', // Rarely needed.
	'default' => true,
	'transport' => 'refresh', // or postMessage
	'sanitize_callback' => '',
	'sanitize_js_callback' => '', // Basically to_json.
) );

$wp_customize->add_control( 'enable_prev_next_single', array(
	'type' => 'checkbox',
	'priority' => 10, // Within the section.
	'section' => 'enable_single_post_elements', // Required, core or custom.
	'label' => __( 'Show Prev & Next Post Pagination ' ),
	'description' => __( '' ),
	//'active_callback' => 'is_front_page',
) );

//* SINGLE POST LAYOUT

$wp_customize->add_setting( 'layout_single', array(
	'type' => 'theme_mod', // or 'option'
	'capability' => 'edit_theme_options',
	'theme_supports' => '', // Rarely needed.
	'default' => 'site-default',
	'transport' => 'refresh', // or postMessage
	'sanitize_callback' => '',
	'sanitize_js_callback' => '', // Basically to_json.
) );

$wp_customize->add_control( 'layout_single', array(
	'type' => 'select',
  	'choices' => array(
  	  'site-default' => __( 'Site Default' ),
		  'content-sidebar' => __( 'Content, Primary Sidebar' ),
		  'full-width-content' => __( 'Full Width Content' ),
		),
	'priority' => 15, // Within the section.
	'section' => 'genesis_layout', // Required, core or custom.
	'label' => __( 'Single Post Layout' ),
	'description' => __( '' ),
	//'active_callback' => 'is_front_page',
) );

以上是关于php Genesis Framework - WP Customizer的主要内容,如果未能解决你的问题,请参考以下文章

php 使用Genesis Framework自定义网站页脚。

php 使用Genesis Framework自定义网站页脚。

php 使用Genesis Framework将Ionicons排入您的网站。

php 使用Genesis Framework将Ionicons排入您的网站。

html 示例HTML使用Genesis Framework自定义网站页脚。

html 示例HTML使用Genesis Framework自定义网站页脚。