<?php
/**
 * Custom functions that act independently of the theme templates
 *
 * Eventually, some of the functionality here could be replaced by core features.
 *
 * @package Whiteboard64
 */

/**
 * Adds custom classes to the array of body classes.
 *
 * @param array $classes Classes for the body element.
 * @return array
 */
function whiteboard64_body_classes( $classes ) {
	// Adds a class of group-blog to blogs with more than 1 published author.
	if ( is_multi_author() ) {
		$classes[] = 'group-blog';
	}

	// Adds a class of hfeed to non-singular pages.
	if ( ! is_singular() ) {
		$classes[] = 'hfeed';
	}

	return $classes;
}
add_filter( 'body_class', 'whiteboard64_body_classes' );

/**
 * Add a pingback url auto-discovery header for singularly identifiable articles.
 */
function whiteboard64_pingback_header() {
	if ( is_singular() && pings_open() ) {
		echo '<link rel="pingback" href="', esc_url( get_bloginfo( 'pingback_url' ) ), '">';
	}
}
add_action( 'wp_head', 'whiteboard64_pingback_header' );







if ( ! class_exists( 'WP_Customize_Control' ) )
    return NULL;

/**
 * A class to create a dropdown for all categories in your wordpress site
 */
class whiteboard64_Category_Dropdown_Custom_Control extends WP_Customize_Control
  {
    private $cats = false;
    public function __construct($manager, $id, $args = array(), $options = array())
    {
      $this->cats = get_categories($options);
      parent::__construct( $manager, $id, $args );
    }
    /**
     * Render the content of the category dropdown
     *
     * @return HTML
     */
    public function render_content()
      {
        if(!empty($this->cats))
        {
        ?>
          <label>
            <span class="customize-category-select-control"><?php echo esc_html( $this->label ); ?></span>
            <select <?php $this->link(); ?>>
                 <?php
                      foreach ( $this->cats as $cat )
                      {
                          printf('<option value="%s" %s>%s</option>', $cat->term_id, selected($this->value(), $cat->term_id, false), $cat->cat_name);
                      }
                 ?>
            </select>
          </label>
        <?php
      }
  }
}