Changeset 13041
- Timestamp:
- 02/09/2010 08:37:12 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-content/themes/twentyten/functions.php
r13029 r13041 29 29 // and thus ends the changeable header business 30 30 31 add_custom_background(); 31 32 32 33 // This theme needs post thumbnails -
trunk/wp-includes/theme.php
r13032 r13041 1336 1336 1337 1337 /** 1338 * Retrieve background image for custom background. 1339 * 1340 * @since 3.0.0 1341 * 1342 * @return string 1343 */ 1344 function get_background_image() { 1345 $default = defined('BACKGROUND_IMAGE') ? BACKGROUND_IMAGE : ''; 1346 1347 return get_theme_mod('background_image', $default); 1348 } 1349 1350 /** 1351 * Display background image path. 1352 * 1353 * @since 3.0.0 1354 */ 1355 function background_image() { 1356 echo get_background_image(); 1357 } 1358 1359 /** 1360 * Add callbacks for background image display. 1361 * 1362 * The parameter $header_callback callback will be required to display the 1363 * content for the 'wp_head' action. The parameter $admin_header_callback 1364 * callback will be added to Custom_Background class and that will be added 1365 * to the 'admin_menu' action. 1366 * 1367 * @since 3.0.0 1368 * @uses Custom_Background Sets up for $admin_header_callback for administration panel display. 1369 * 1370 * @param callback $header_callback Call on 'wp_head' action. 1371 * @param callback $admin_header_callback Call on custom background administration screen. 1372 * @param callback $admin_image_div_callback Output a custom background image div on the custom background administration screen. Optional. 1373 */ 1374 function add_custom_background($header_callback = '', $admin_header_callback = '', $admin_image_div_callback = '') { 1375 if ( empty($header_callback) ) 1376 $header_callback = '_custom_background_cb'; 1377 1378 add_action('wp_head', $header_callback); 1379 1380 if ( ! is_admin() ) 1381 return; 1382 require_once(ABSPATH . 'wp-admin/custom-background.php'); 1383 $GLOBALS['custom_background'] =& new Custom_Background($admin_header_callback, $admin_image_div_callback); 1384 add_action('admin_menu', array(&$GLOBALS['custom_background'], 'init')); 1385 } 1386 1387 /** 1388 * Default custom background callback. 1389 * 1390 * @since 3.0.0 1391 * @see add_custom_background() 1392 * @access protected 1393 */ 1394 function _custom_background_cb() { 1395 $background = get_background_image(); 1396 1397 if ( !$background ) 1398 return; 1399 1400 $repeat = get_theme_mod('background_repeat'); 1401 $repeat = $repeat ? '' : ' no-repeat'; 1402 ?> 1403 <style type="text/css"> 1404 body { 1405 background: url('<?php background_image(); ?>') fixed <?php echo $repeat ?>; 1406 } 1407 </style> 1408 <?php 1409 } 1410 1411 /** 1338 1412 * Allows a theme to register its support of a certain feature 1339 1413 *
Note: See TracChangeset
for help on using the changeset viewer.