• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress a2z

WordPress a2z

WordPress Dynamic API Reference

  • Home
  • Plugins
  • Themes
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / Twenty_Twenty_One_Customize::register() – Register customizer options.

You appear to be a bot. Output may be restricted

Description

Register customizer options.

Usage

$void = Twenty_Twenty_One_Customize::register( $wp_customize );

Parameters

$wp_customize
( WP_Customize_Manager ) required – Theme Customizer object.

Returns

void

Source

File name: twentytwentyone/classes/class-twenty-twenty-one-customize.php


Lines:

1 to 100 of 112
    public function register( $wp_customize ) {

      // Change site-title & description to postMessage.
      $wp_customize->get_setting( 'blogname' )->transport        = 'postMessage'; // @phpstan-ignore-line. Assume that this setting exists.
      $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; // @phpstan-ignore-line. Assume that this setting exists.

      // Add partial for blogname.
      $wp_customize->selective_refresh->add_partial(
        'blogname',
        array(
          'selector'        => '.site-title',
          'render_callback' => array( $this, 'partial_blogname' ),
        )
      );

      // Add partial for blogdescription.
      $wp_customize->selective_refresh->add_partial(
        'blogdescription',
        array(
          'selector'        => '.site-description',
          'render_callback' => array( $this, 'partial_blogdescription' ),
        )
      );

      // Add "display_title_and_tagline" setting for displaying the site-title & tagline.
      $wp_customize->add_setting(
        'display_title_and_tagline',
        array(
          'capability'        => 'edit_theme_options',
          'default'           => true,
          'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ),
        )
      );

      // Add control for the "display_title_and_tagline" setting.
      $wp_customize->add_control(
        'display_title_and_tagline',
        array(
          'type'    => 'checkbox',
          'section' => 'title_tagline',
          'label'   => esc_html__( 'Display Site Title & Tagline', 'twentytwentyone' ),
        )
      );

      
/**
 * Add excerpt or full text selector to customizer
 */
      $wp_customize->add_section(
        'excerpt_settings',
        array(
          'title'    => esc_html__( 'Excerpt Settings', 'twentytwentyone' ),
          'priority' => 120,
        )
      );

      $wp_customize->add_setting(
        'display_excerpt_or_full_post',
        array(
          'capability'        => 'edit_theme_options',
          'default'           => 'excerpt',
          'sanitize_callback' => static function( $value ) {
            return 'excerpt' === $value || 'full' === $value ? $value : 'excerpt';
          },
        )
      );

      $wp_customize->add_control(
        'display_excerpt_or_full_post',
        array(
          'type'    => 'radio',
          'section' => 'excerpt_settings',
          'label'   => esc_html__( 'On Archive Pages, posts show:', 'twentytwentyone' ),
          'choices' => array(
            'excerpt' => esc_html__( 'Summary', 'twentytwentyone' ),
            'full'    => esc_html__( 'Full text', 'twentytwentyone' ),
          ),
        )
      );

      // Background color.
      // Include the custom control class.
      include_once get_theme_file_path( 'classes/class-twenty-twenty-one-customize-color-control.php' ); // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound

      // Register the custom control.
      $wp_customize->register_control_type( 'Twenty_Twenty_One_Customize_Color_Control' );

      // Get the palette from theme-supports.
      $palette = get_theme_support( 'editor-color-palette' );

      // Build the colors array from theme-support.
      $colors = array();
      if ( isset( $palette[0] ) && is_array( $palette[0] ) ) {
        foreach ( $palette[0] as $palette_color ) {
          $colors[] = $palette_color['color'];
        }
      }

      // Add the control. Overrides the default background-color control.
      $wp_customize->add_control(
[1] [2] Next »

 View on GitHub View on Trac

Published: 9th December 2020 | Last updated: 26th January 2022

Primary Sidebar

Information

Function name: Twenty_Twenty_One_Customize::register
Class ref: Twenty_Twenty_One_Customize
Plugin ref: Twenty Twenty-One
Version: 1.7
Sourcefile: classes/class-twenty-twenty-one-customize.php
File ref: classes/class-twenty-twenty-one-customize.php
Deprecated?: No
API Letters: C,O,R,T

Footer

WordPress a2z
WordPress a2z
WordPress Dynamic API Reference
WordPress 6.1.1. PHP: 8.0.28
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  wp-a2z.org
© Copyright WordPress a2z 2014-2023. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites