Changeset 641 for trunk/extras/my_themes/functions.php
- Timestamp:
- Aug 24, 2010, 8:35:47 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/extras/my_themes/functions.php
r627 r641 1 1 <?php 2 load_theme_textdomain('xpress'); 2 /** Tell WordPress to run xpress_setup() when the 'after_setup_theme' hook is run. */ 3 add_action( 'after_setup_theme', 'xpress_setup' ); 4 if ( ! function_exists( 'xpress_setup' ) ): 5 function xpress_setup() { 6 // This theme uses post thumbnails 7 add_theme_support( 'post-thumbnails' ); 8 // Add default posts and comments RSS feed links to head 9 add_theme_support( 'automatic-feed-links' ); 10 11 // Make theme available for translation 12 // Translations can be filed in the /languages/ directory 13 load_theme_textdomain( 'xpress', TEMPLATEPATH . '/languages' ); 14 15 $locale = get_locale(); 16 $locale_file = TEMPLATEPATH . "/languages/$locale.php"; 17 if ( is_readable( $locale_file ) ) 18 require_once( $locale_file ); 19 20 // This theme uses wp_nav_menu() 21 if ( function_exists('add_theme_support') )add_theme_support( 'nav-menus' ); 22 // This theme uses wp_nav_menu() in one location. 23 if ( function_exists('register_nav_menus') ){ 24 register_nav_menus( array( 25 'primary' => __('Primary Navigation','xpress'), 26 ) ); 27 } 28 29 } 30 endif; 3 31 4 32 if ( function_exists('register_sidebar') ) … … 10 38 )); 11 39 12 // This theme uses wp_nav_menu()13 if ( function_exists('add_theme_support') )add_theme_support( 'nav-menus' );14 // This theme uses wp_nav_menu() in one location.15 if ( function_exists('register_nav_menus') ){16 register_nav_menus( array(17 'primary' => __('Primary Navigation','xpress'),18 ) );19 }20 40 21 41 function xpress_head() { … … 150 170 } 151 171 } 172 173 152 174 //print_r($_REQUEST); 153 175 wp_redirect("themes.php?page=functions.php&saved=true"); … … 155 177 } 156 178 add_action('admin_head', 'xpress_theme_page_head'); 157 } 158 add_theme_page(__('Customize Header', 'xpress'), __('Header Image and Color', 'xpress'), 'edit_themes', basename(__FILE__), 'xpress_theme_page'); 159 } 179 180 if ( isset( $_REQUEST['action'] ) && 'update_footer' == $_REQUEST['action'] ) { 181 check_admin_referer('xpress-footer'); 182 if ( isset($_REQUEST['xpress_footer_sidebars_count']) ) { 183 check_admin_referer('xpress-footer'); 184 if ( '' == $_REQUEST['xpress_footer_sidebars_count'] || '0' == $_REQUEST['xpress_footer_sidebars_count'] ){ 185 delete_option('xpress_footer_sidebars_count'); 186 } else { 187 update_option('xpress_footer_sidebars_count', $_REQUEST['xpress_footer_sidebars_count']); 188 } 189 } 190 191 //print_r($_REQUEST); 192 wp_redirect("themes.php?page=functions.php&footer_saved=true"); 193 die; 194 } 195 } 196 add_theme_page(__('Header & Footer', 'xpress'), __('Header & Footer', 'xpress'), 'edit_themes', basename(__FILE__), 'xpress_theme_header_page'); 197 } 198 160 199 161 200 function xpress_theme_page_head() { … … 361 400 border-bottom: 0px; 362 401 } 402 #footer_submit { 403 margin-top: 20px; 404 text-align: center; 405 } 406 #footer_form{ 407 padding-left: 40px; 408 } 409 363 410 </style> 364 411 <?php 365 412 } 366 413 367 function xpress_theme_page() { 368 if ( isset( $_REQUEST['saved'] ) ) echo '<div id="message" class="updated fade"><p><strong>'.__('Options saved.', 'xpress').'</strong></p></div>'; 414 function xpress_theme_header_page() { 415 if ( isset( $_REQUEST['saved'] ) ) echo '<div id="message" class="updated fade"><p><strong>'.__('Header Options saved.', 'xpress').'</strong></p></div>'; 416 if ( isset( $_REQUEST['footer_saved'] ) ) echo '<div id="message" class="updated fade"><p><strong>'.__('Footer Options saved.', 'xpress').'</strong></p></div>'; 369 417 ?> 370 418 <div class='wrap'> … … 424 472 </div> 425 473 </div> 474 <div id="xpress-footer"> 475 <h2><?php _e('Footer', 'xpress'); ?></h2> 476 <form id="footer_setting" style="display:inline;" method="post" action=""> 477 <div id="footer_form"> 478 <?php wp_nonce_field('xpress-footer'); ?> 479 <?php 480 if ( function_exists('register_sidebar') ){ 481 echo __('Set number of the sidebar to display in the footer.','xpress'); 482 echo '<select name="xpress_footer_sidebars_count">'."\n"; 483 $side_bar_num = get_option('xpress_footer_sidebars_count'); 484 if (empty($side_bar_num)) $side_bar_num = 0; 485 for($i=0;$i<=5;$i++){ 486 if ($i== 0) $sel_name = __('none','xpress'); else $sel_name = $i; 487 if ($i == $side_bar_num) $selected = ' selected '; else $selected = ''; 488 echo "\t\t\t\t<option value=\"{$i}\" label=\"{$i}\" {$selected}>{$sel_name}</option>\n"; 489 } 490 echo "</select>\n"; 491 } 492 ?> 493 <input type="hidden" name="action" value="update_footer" /> 494 </div> 495 <div id="footer_submit"> 496 <input type="submit" name="footer_submit" id="footer_submit" value="<?php echo attribute_escape(__('Update Footer »', 'xpress')); ?>" /> 497 </div> 498 </form> 499 </div> 500 426 501 </div> 427 <?php } ?> 502 <?php } 503 504 function footer_widgets_init() { 505 if (!function_exists('register_sidebar') ) return; 506 507 $side_bar_num = get_option('xpress_footer_sidebars_count'); 508 if (empty($side_bar_num)) return; 509 for($i=1;$i <= $side_bar_num;$i++){ 510 switch($i){ 511 case 1: 512 $name = __( 'First Footer Widget Area', 'kubrick' ); 513 $description = __( 'The first footer widget area', 'kubrick' ); 514 break; 515 case 2: 516 $name = __( 'Second Footer Widget Area', 'kubrick' ); 517 $description = __( 'The second footer widget area', 'kubrick' ); 518 break; 519 case 3: 520 $name = __( 'Third Footer Widget Area', 'kubrick' ); 521 $description = __( 'The third footer widget area', 'kubrick' ); 522 break; 523 case 4: 524 $name = __( 'Fourth Footer Widget Area', 'kubrick' ); 525 $description = __( 'The fourth footer widget area', 'kubrick' ); 526 break; 527 case 5: 528 $name = __( 'Fifth Footer Widget Area', 'kubrick' ); 529 $description = __( 'The fifth footer widget area', 'kubrick' ); 530 break; 531 532 } 533 534 register_sidebar( array( 535 'name' => $name, 536 'id' => 'footer-widget-area-'.$i, 537 'description' => $description, 538 'before_widget' => '<li id="%1$s" class="widget-container %2$s">', 539 'after_widget' => '</li>', 540 'before_title' => '<h3 class="widget-title">', 541 'after_title' => '</h3>', 542 ) ); 543 } 544 } 545 546 add_action( 'widgets_init', 'footer_widgets_init' ); 547 548 549 550 ?>
Note: See TracChangeset
for help on using the changeset viewer.