Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #139 from godaddy/credit-toggle
Browse files Browse the repository at this point in the history
Add author credit toggle to site identity section of the customizer.
  • Loading branch information
frankiejarrett committed Dec 16, 2016
2 parents 452341d + 7e2c880 commit d1edbe2
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
7 changes: 7 additions & 0 deletions inc/customizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ public function __construct() {
*/
require_once get_template_directory() . '/inc/customizer/layouts.php';

/**
* Load additional site identity options
*
* @since NEXT
*/
require_once get_template_directory() . '/inc/customizer/site-identity.php';

add_action( 'after_setup_theme', array( $this, 'logo' ) );
add_action( 'customize_register', array( $this, 'selective_refresh' ), 11 );
add_action( 'customize_register', array( $this, 'use_featured_hero_image' ) );
Expand Down
84 changes: 84 additions & 0 deletions inc/customizer/site-identity.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php
/**
* Additional site identity customizer options.
*
* @package Primer
* @since NEXT
*/

class Primer_Site_Identity_Options {

/**
* Class constructor.
*/
public function __construct() {

/**
* Filter the site identity settings display.
*
* @since NEXT
*
* @var bool
*/
if ( ! (bool) apply_filters( 'primer_show_site_identity_settings', true ) ) {

return;

}

add_filter( 'primer_author_credit', array( $this, 'toggle_primer_author_credit' ) );

add_action( 'customize_register', array( $this, 'customize_register' ) );

}

/**
* Toggle the visibility of the site credits in the footer.
*
* @filter primer_author_credit
* @since NEXT
*
* @return bool
*/
public function toggle_primer_author_credit() {

$show_author_credit = get_theme_mod( 'show_author_credit' );

return ! empty( $show_author_credit );

}

/**
* Register additional site identity options.
*
* @action customize_register
* @since NEXT
*
* @param WP_Customize_Manager $wp_customize
*/
public function customize_register( WP_Customize_Manager $wp_customize ) {

$wp_customize->add_setting(
'show_author_credit',
array(
'default' => 1,
'sanitize_callback' => 'absint',
)
);

$wp_customize->add_control(
'page_width',
array(
'label' => esc_html__( 'Display theme author credit', 'primer' ),
'section' => 'title_tagline',
'settings' => 'show_author_credit',
'type' => 'checkbox',
'priority' => 40,
)
);

}

}

$GLOBALS['primer_site_identity_options'] = new Primer_Site_Identity_Options;

0 comments on commit d1edbe2

Please sign in to comment.