Frank Bültge · Inpsyde GmbH
Usage
Dokumentation im Codex
set_theme_mod
, get_theme_mod
set_option
bzw. get_option
after_setup_theme
add_action( 'after_setup_theme', 'documentation_setup' );
function documentation_setup() {
add_theme_support( 'documentation_customizer', array( 'all' ) );
require_if_theme_supports(
'documentation_customizer',
get_template_directory() . '/inc/theme-customize.php'
);
}
add_action( 'customize_register', array( $this, 'customize_register' ) );
public function customize_register( $wp_customize ) {
// get options, default options
$defaults = $this->get_default_theme_options();
// do it
}
$wp_customize
Zugriff auf alle Methoden
$wp_customize->add_section( $this->option_key . '_layout', array(
'title' => __( 'Layout', 'documentation' ),
'description' => __( 'Define main Layout', 'documentation' ),
'priority' => 30
) );
$wp_customize->add_setting( $this->option_key . '[layout]', array(
'default' => $defaults[ 'layout' ],
'type' => 'option',
'capability' => 'edit_theme_options',
) );
$wp_customize->add_control( $this->option_key . '_layout', array(
'label' => __( 'Color Scheme', 'documentation' ),
'section' => $this->option_key . '_layout',
'settings' => $this->option_key . '[layout]',
'type' => 'radio',
'choices' => array(
'sidebar-left' => __( 'Sidebar on left', 'documentation' ),
'sidebar-right' => __( 'Sidebar on right', 'documentation' )
),
) );
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
$this->option_key . '_text_color', array(
'label' => __( 'Text Color', 'documentation' ),
'section' => 'colors',
'settings' => $this->option_key . '[text_color]',
)
)
);
class Documentation_Customize_Textarea_Control extends WP_Customize_Control {
public $type = 'textarea';
public function render_content() {
?>
<label>
<span class="customize-control-title">
<?php echo esc_html( $this->label ); ?>
</span>
<textarea class="large-text" cols="20" rows="5" <?php $this->link(); ?>>
<?php echo esc_textarea( $this->value() ); ?>
</textarea>
</label>
<?php
}
}
$wp_customize->add_control(
new Documentation_Customize_Textarea_Control(
$wp_customize, $this->option_key . '_rewrite_url', array(
'label' => __( 'Rewrite URL', 'documentation' ),
'section' => $this->option_key . '_rewrite_url',
'settings' => $this->option_key . '[rewrite_url]',
)
)
);
echo get_theme_mod( 'textarea_setting', 'default_value' );
get_option
get_option
customize_*
wp-admin/customize.php
wp-includes/class-wp-customize-control.php
wp-includes/class-wp-customize-manager.php
wp-includes/class-wp-customize-section.php
wp-includes/class-wp-customize-setting.php
WP_Customize_Control
Für Menschen
Seien Sie begeistert und Sie werden begeistern.
Frank Bültge · Inpsyde GmbH
Illustrationen: Thies Schwarz Illustration