PageRenderTime 49ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/discovery-minimum/functions.php

https://github.com/jbreitenbucher/GenesisChildThemes
PHP | 140 lines | 88 code | 22 blank | 30 comment | 10 complexity | 273ad7826860e4960386d11657e2722f MD5 | raw file
  1. <?php
  2. /** Start the engine */
  3. require_once( TEMPLATEPATH . '/lib/init.php' );
  4. /** Child theme (do not remove) */
  5. define( 'CHILD_THEME_NAME', 'Discovery Minimum Theme' );
  6. define( 'CHILD_THEME_URL', 'http://instructionaltechnology.wooster.edu' );
  7. $content_width = apply_filters( 'content_width', 640, 470, 740, 940 );
  8. /** Add new image sizes */
  9. add_image_size( 'slider', 940, 588, TRUE );
  10. add_image_size( 'featured', 500, 313, TRUE );
  11. add_image_size( 'portfolio', 160, 100, TRUE );
  12. add_image_size( 'middle', 250, 156, TRUE );
  13. add_image_size( 'footer', 156, 98, TRUE );
  14. /** Add suport for custom background */
  15. add_custom_background();
  16. /** Add support for custom header */
  17. add_theme_support( 'genesis-custom-header', array( 'width' => 940, 'height' => 100, 'textcolor' => '444', 'admin_header_callback' => 'dm_admin_style' ) );
  18. /**
  19. * Register a custom admin callback to display the custom header preview with the
  20. * same style as is shown on the front end.
  21. *
  22. */
  23. function dm_admin_style() {
  24. $headimg = sprintf( '.appearance_page_custom-header #headimg { background: url(%s) no-repeat; font-family: Oswald, arial, serif; min-height: %spx; }', get_header_image(), HEADER_IMAGE_HEIGHT );
  25. $h1 = sprintf( '#headimg h1, #headimg h1 a { color: #%s; font-size: 48px; font-weight: normal; line-height: 48px; margin: 25px 0 0; text-decoration: none; }', esc_html( get_header_textcolor() ) );
  26. $desc = sprintf( '#headimg #desc { color: #%s; display: none; }', esc_html( get_header_textcolor() ) );
  27. printf( '<style type="text/css">%1$s %2$s %3$s</style>', $headimg, $h1, $desc );
  28. }
  29. /** Tell WordPress to run dm_setup() when the 'after_setup_theme' hook is run. **/
  30. add_action( 'after_setup_theme', 'dm_setup' );
  31. if ( !function_exists( 'dm_setup' ) ):
  32. function dm_setup() {
  33. /** Add default posts and comments RSS feed links to head **/
  34. add_theme_support( 'automatic-feed-links' );
  35. /** Make theme available for translation **/
  36. /** Translations can be filed in the /languages/ directory **/
  37. load_theme_textdomain( 'genesis', TEMPLATEPATH . '/languages' );
  38. $locale = get_locale();
  39. $locale_file = TEMPLATEPATH . "/languages/$locale.php";
  40. if ( is_readable( $locale_file ) )
  41. require_once( $locale_file );
  42. /** ... and thus ends the changeable header business. **/
  43. /** Wordpress 3.1 support to remove header upload. **/
  44. /** remove_theme_support( 'custom-header-uploads' ); **/
  45. /**
  46. * Customize the footer section
  47. *
  48. * @param string $creds
  49. * @return string
  50. */
  51. function dm_footer_creds_text($creds) {
  52. $creds = __('Copyright', 'genesis') . ' [footer_copyright] ' . ' [footer_childtheme_link] '. __('on', 'genesis') .' [footer_genesis_link] &middot; [footer_wordpress_link] &middot; [footer_loginout]';
  53. return $creds;
  54. }
  55. add_filter('genesis_footer_creds_text', 'dm_footer_creds_text');
  56. /** Add our own custom headers packaged with the theme. in the theme template directory 'images/headers/' **/
  57. register_default_headers( cms_theme_headers() );
  58. }
  59. endif;
  60. /** Automatically add header options that you put in the images/header folder to the options users have **/
  61. function cms_theme_headers() {
  62. global $themename;
  63. $list = array();
  64. $imagepath = STYLESHEETPATH .'/images/headers/';
  65. $imageurl = get_bloginfo('stylesheet_directory');
  66. $dir_handle = @opendir($imagepath) or die("Unable to open $path");
  67. while($file = readdir($dir_handle)){
  68. if($file == "." || $file == ".."){continue;}
  69. $filename = explode(".",$file);
  70. $cnt = count($filename); $cnt--; $ext = $filename[$cnt];
  71. if(strtolower($ext) == ('png' || 'jpg')){
  72. if (!strpos($file, '-thumbnail') > 0) {
  73. $header = array(
  74. 'url' => $imageurl .'/images/headers/' .$file,
  75. 'thumbnail_url' => $imageurl .'/images/headers/' .$filename[0] .'-thumbnail.' .$ext,
  76. 'description' => __( $filename[0], $themename )
  77. );
  78. array_push($list, $header);
  79. }
  80. }
  81. }
  82. return $list;
  83. }
  84. /**
  85. * Add branding section
  86. */
  87. function dm_include_branding() {
  88. require_once(CHILD_DIR . '/branding.php');
  89. }
  90. add_action('genesis_before_header', 'dm_include_branding');
  91. /** Add support for 3-column footer widgets */
  92. add_theme_support( 'genesis-footer-widgets', 3 );
  93. /** Register widget areas */
  94. genesis_register_sidebar( array(
  95. 'id' => 'welcome',
  96. 'name' => __( 'Welcome', 'minimum' ),
  97. 'description' => __( 'This is the welcome section.', 'minimum' ),
  98. ) );
  99. genesis_register_sidebar( array(
  100. 'id' => 'featured',
  101. 'name' => __( 'Featured', 'minimum' ),
  102. 'description' => __( 'This is the featured section.', 'minimum' ),
  103. ) );
  104. genesis_register_sidebar( array(
  105. 'id' => 'portfolio',
  106. 'name' => __( 'Portfolio', 'minimum' ),
  107. 'description' => __( 'This is the portfolio section.', 'minimum' ),
  108. ) );
  109. genesis_register_sidebar( array(
  110. 'id' => 'middle_left',
  111. 'name' => __( 'Middle Left', 'minimum' ),
  112. 'description' => __( 'This is the middle left section.', 'minimum' ),
  113. ) );
  114. genesis_register_sidebar( array(
  115. 'id' => 'middle_right',
  116. 'name' => __( 'Middle Right', 'minimum' ),
  117. 'description' => __( 'This is the middle section.', 'minimum' ),
  118. ) );