Ticket #20265: 20265.2.diff

File 20265.2.diff, 8.6 KB (added by sabreuse, 14 months ago)
Line 
1Index: wp-content/themes/twentyten/functions.php
2===================================================================
3--- wp-content/themes/twentyten/functions.php   (revision 20220)
4+++ wp-content/themes/twentyten/functions.php   (working copy)
5@@ -101,34 +101,27 @@
6        ) );
7 
8        // This theme allows users to set a custom background
9-       add_custom_background();
10+       add_theme_support('custom-background', array('callback' => ''));
11 
12        // Your changeable header business starts here
13-       if ( ! defined( 'HEADER_TEXTCOLOR' ) )
14-               define( 'HEADER_TEXTCOLOR', '' );
15+       $header_args = array(
16+               'random-default' => false,
17+               'height' => 198,
18+               'width' => 940,
19+               'header-text' => false,
20+               'default-image' => '%s/images/headers/path.jpg',
21+               'callback' => '',
22+               'admin-header-callback' => 'twentyten_admin_header_style',
23+       );
24+       add_theme_support( 'custom-header', $header_args );
25 
26-       // No CSS, just IMG call. The %s is a placeholder for the theme template directory URI.
27-       if ( ! defined( 'HEADER_IMAGE' ) )
28-               define( 'HEADER_IMAGE', '%s/images/headers/path.jpg' );
29 
30-       // The height and width of your custom header. You can hook into the theme's own filters to change these values.
31-       // Add a filter to twentyten_header_image_width and twentyten_header_image_height to change these values.
32-       define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 940 ) );
33-       define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 198 ) );
34-
35        // We'll be using post thumbnails for custom header images on posts and pages.
36        // We want them to be 940 pixels wide by 198 pixels tall.
37        // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
38-       set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
39+       set_post_thumbnail_size( get_theme_support( 'custom-header', 'width' ), get_theme_support( 'custom-header', 'height' ), true );
40 
41-       // Don't support text inside the header image.
42-       if ( ! defined( 'NO_HEADER_TEXT' ) )
43-               define( 'NO_HEADER_TEXT', true );
44 
45-       // Add a way for the custom header to be styled in the admin panel that controls
46-       // custom headers. See twentyten_admin_header_style(), below.
47-       add_custom_image_header( '', 'twentyten_admin_header_style' );
48-
49        // ... and thus ends the changeable header business.
50 
51        // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
52Index: wp-content/themes/twentyeleven/functions.php
53===================================================================
54--- wp-content/themes/twentyeleven/functions.php        (revision 20220)
55+++ wp-content/themes/twentyeleven/functions.php        (working copy)
56@@ -62,10 +62,8 @@
57  *
58  * @uses load_theme_textdomain() For translation/localization support.
59  * @uses add_editor_style() To style the visual editor.
60- * @uses add_theme_support() To add support for post thumbnails, automatic feed links, and Post Formats.
61+ * @uses add_theme_support() To add support for post thumbnails, automatic feed links, custom backgrounds, and custom image headers, and Post Formats.
62  * @uses register_nav_menus() To add support for navigation menus.
63- * @uses add_custom_background() To add support for a custom background.
64- * @uses add_custom_image_header() To add support for a custom header.
65  * @uses register_default_headers() To register the default custom header images provided with the theme.
66  * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
67  *
68@@ -104,40 +102,39 @@
69        add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote', 'image' ) );
70 
71        // Add support for custom backgrounds
72-       add_custom_background();
73+       add_theme_support('custom-background', array('callback' => ''));
74 
75        // This theme uses Featured Images (also known as post thumbnails) for per-post/per-page Custom Header images
76        add_theme_support( 'post-thumbnails' );
77 
78-       // The next four constants set how Twenty Eleven supports custom headers.
79-
80-       // The default header text color
81-       define( 'HEADER_TEXTCOLOR', '000' );
82-
83-       // By leaving empty, we allow for random image rotation.
84-       define( 'HEADER_IMAGE', '' );
85-
86-       // The height and width of your custom header.
87-       // Add a filter to twentyeleven_header_image_width and twentyeleven_header_image_height to change these values.
88-       define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyeleven_header_image_width', 1000 ) );
89-       define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyeleven_header_image_height', 288 ) );
90-
91        // We'll be using post thumbnails for custom header images on posts and pages.
92        // We want them to be the size of the header image that we just defined
93        // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
94-       set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
95+       set_post_thumbnail_size( get_theme_support( 'custom-header', 'width' ), get_theme_support( 'custom-header', 'height' ), true );
96 
97        // Add Twenty Eleven's custom image sizes
98-       add_image_size( 'large-feature', HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true ); // Used for large feature (header) images
99+       add_image_size(
100+               'large-feature',
101+               get_theme_support( 'custom-header', 'width' ),
102+               get_theme_support( 'custom-header', 'height' ),
103+               true
104+       ); // Used for large feature (header) images
105+       
106        add_image_size( 'small-feature', 500, 300 ); // Used for featured posts if a large-feature doesn't exist
107 
108+       // Add support for custom headers
109        // Turn on random header image rotation by default.
110-       add_theme_support( 'custom-header', array( 'random-default' => true ) );
111+       add_theme_support( 'custom-header', array(
112+               'default-image' => '',
113+               'random-default' => true,
114+               'width' => 1000,
115+               'height' => 288,
116+               'default-text-color' => '000',
117+               'callback' => 'twentyeleven_header_style',
118+               'admin-header-callback' => 'twentyeleven_admin_header_style',
119+               'admin-image-div-callback' => 'twentyeleven_admin_header_image',
120+       ) );
121 
122-       // Add a way for the custom header to be styled in the admin panel that controls
123-       // custom headers. See twentyeleven_admin_header_style(), below.
124-       add_custom_image_header( 'twentyeleven_header_style', 'twentyeleven_admin_header_style', 'twentyeleven_admin_header_image' );
125-
126        // ... and thus ends the changeable header business.
127 
128        // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
129@@ -203,8 +200,8 @@
130 function twentyeleven_header_style() {
131 
132        // If no custom options for text are set, let's bail
133-       // get_header_textcolor() options: HEADER_TEXTCOLOR is default, hide text (returns 'blank') or any hex value
134-       if ( HEADER_TEXTCOLOR == get_header_textcolor() )
135+       // get_header_textcolor() options: get_theme_support( 'custom-header', 'default-text-color' ) is default, hide text (returns 'blank') or any hex value
136+       if ( get_theme_support( 'custom-header', 'default-text-color' ) == get_header_textcolor() )
137                return;
138        // If we get this far, we have custom styles. Let's do this.
139        ?>
140@@ -237,7 +234,7 @@
141 /**
142  * Styles the header image displayed on the Appearance > Header admin panel.
143  *
144- * Referenced via add_custom_image_header() in twentyeleven_setup().
145+ * Referenced via add_theme_support() in twentyeleven_setup().
146  *
147  * @since Twenty Eleven 1.0
148  */
149@@ -266,7 +263,7 @@
150        }
151        <?php
152                // If the user has set a custom color for the text use that
153-               if ( get_header_textcolor() != HEADER_TEXTCOLOR ) :
154+               if ( get_header_textcolor() != get_theme_support( 'custom-header', 'default-text-color' ) ) :
155        ?>
156                #site-title a,
157                #site-description {
158@@ -287,17 +284,17 @@
159 /**
160  * Custom header image markup displayed on the Appearance > Header admin panel.
161  *
162- * Referenced via add_custom_image_header() in twentyeleven_setup().
163+ * Referenced via add_theme_support() in twentyeleven_setup().
164  *
165  * @since Twenty Eleven 1.0
166  */
167 function twentyeleven_admin_header_image() { ?>
168        <div id="headimg">
169                <?php
170-               if ( 'blank' == get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ) || '' == get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ) )
171+               if ( 'blank' == get_theme_mod( 'header_textcolor', get_theme_support( 'custom-header', 'default-text-color' ) ) || '' == get_theme_mod( 'header_textcolor', get_theme_support( 'custom-header', 'default-text-color' ) ) )
172                        $style = ' style="display:none;"';
173                else
174-                       $style = ' style="color:#' . get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ) . ';"';
175+                       $style = ' style="color:#' . get_theme_mod( 'header_textcolor', get_theme_support( 'custom-header', 'default-text-color' ) ) . ';"';
176                ?>
177                <h1><a id="name"<?php echo $style; ?> onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a></h1>
178                <div id="desc"<?php echo $style; ?>><?php bloginfo( 'description' ); ?></div>