Make WordPress Core

Changeset 20263


Ignore:
Timestamp:
03/22/2012 08:07:44 AM (12 years ago)
Author:
koopersmith
Message:

Theme Customizer: Add background repeat, position, and attachment settings. Change visibility parameter to accept a string or array( , ). see #19910.

Location:
trunk/wp-includes
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-wp-customize-setting.php

    r20261 r20263  
    309309        $style = '';
    310310        if ( $this->visibility ) {
    311             $visibility_setting = $this->manager->get_setting( $this->visibility[0] );
    312             $visibility_value   = isset( $this->visibility[1] ) ? $this->visibility[1] : true;
     311            if ( is_string( $this->visibility ) ) {
     312                $visibility_id    = $this->visibility;
     313                $visibility_value = true;
     314            } else {
     315                $visibility_id    = $this->visibility[0];
     316                $visibility_value = $this->visibility[1];
     317            }
     318            $visibility_setting = $this->manager->get_setting( $visibility_id );
    313319
    314320            if ( $visibility_setting && $visibility_value != $visibility_setting->value() )
  • trunk/wp-includes/class-wp-customize.php

    r20260 r20263  
    562562
    563563        $this->add_setting( 'background_image', array(
    564             'label'             => 'Background Image',
    565             'section'           => 'background',
    566             'control'           => 'upload',
     564            'label'   => 'Background Image',
     565            'section' => 'background',
     566            'control' => 'upload',
     567            'default' => get_theme_support( 'custom-background', 'default-image' ),
     568        ) );
     569
     570        $this->add_setting( 'background_repeat', array(
     571            'label'      => 'Background Repeat',
     572            'section'    => 'background',
     573            'visibility' => 'background_image',
     574            'control'    => 'radio',
     575            'choices'    => array(
     576                'no-repeat'  => __('No Repeat'),
     577                'repeat'     => __('Tile'),
     578                'repeat-x'   => __('Tile Horizontally'),
     579                'repeat-y'   => __('Tile Vertically'),
     580            ),
     581            'default'    => 'repeat',
     582        ) );
     583
     584        $this->add_setting( 'background_position_x', array(
     585            'label'      => 'Background Position',
     586            'section'    => 'background',
     587            'visibility' => 'background_image',
     588            'control'    => 'radio',
     589            'choices'    => array(
     590                'left'       => __('Left'),
     591                'center'     => __('Center'),
     592                'right'      => __('Right'),
     593            ),
     594            'default'    => 'left',
     595        ) );
     596
     597        $this->add_setting( 'background_attachment', array(
     598            'label'      => 'Background Attachment',
     599            'section'    => 'background',
     600            'visibility' => 'background_image',
     601            'control'    => 'radio',
     602            'choices'    => array(
     603                'fixed'      => __('Fixed'),
     604                'scroll'     => __('Scroll'),
     605            ),
     606            'default'    => 'fixed',
    567607        ) );
    568608
  • trunk/wp-includes/customize-controls.php

    r20260 r20263  
    107107
    108108        if ( $setting->visibility ) {
    109             $settings['controls'][ $id ]['visibility'] = array(
    110                 'id'    => $setting->visibility[0],
    111                 'value' => isset( $setting->visibility[1] ) ? $setting->visibility[1] : true,
    112             );
     109            if ( is_string( $setting->visibility ) ) {
     110                $settings['controls'][ $id ]['visibility'] = array(
     111                    'id'    => $setting->visibility,
     112                    'value' => true,
     113                );
     114            } else {
     115                $settings['controls'][ $id ]['visibility'] = array(
     116                    'id'    => $setting->visibility[0],
     117                    'value' => $setting->visibility[1],
     118                );
     119            }
     120
    113121        }
    114122    }
  • trunk/wp-includes/js/customize-controls.dev.js

    r20261 r20263  
    246246            if ( data.visibility ) {
    247247                api( data.visibility.id, function( other ) {
    248                     other.bind( function( to ) {
    249                         control.container.toggle( to == data.visibility.value );
    250                     });
     248                    if ( 'boolean' === typeof data.visibility.value ) {
     249                        other.bind( function( to ) {
     250                            control.container.toggle( !! to == data.visibility.value );
     251                        });
     252                    } else {
     253                        other.bind( function( to ) {
     254                            control.container.toggle( to == data.visibility.value );
     255                        });
     256                    }
    251257                });
    252258            }
Note: See TracChangeset for help on using the changeset viewer.