Plugin Directory

Changeset 690895


Ignore:
Timestamp:
04/03/2013 01:34:08 AM (13 years ago)
Author:
kobenland
Message:

WPDH: Get ready for v2.1.0.

Location:
wp-display-header/trunk
Files:
3 edited
1 copied
1 moved

Legend:

Unmodified
Added
Removed
  • wp-display-header/trunk/obenland-wp-plugins.php

    r541580 r690895  
    22/** obenland-wp-plugins.php
    33 *
    4  * @author      Konstantin Obenland
    5  * @version     2.0.0
     4 * @author  Konstantin Obenland
     5 * @version 3.0.1
    66 */
    77
    88
    9 class Obenland_Wp_Plugins_v200 {
    10 
     9class Obenland_Wp_Plugins_v301 {
    1110
    1211    /////////////////////////////////////////////////////////////////////////////
     
    1514
    1615    /**
    17      * The plugins' text domain
    18      *
    19      * @author  Konstantin Obenland
    20      * @since   1.1 - 03.04.2011
    21      * @access  protected
    22      *
    23      * @var     string
     16     * The plugins' text domain.
     17     *
     18     * @author Konstantin Obenland
     19     * @since  1.1 - 03.04.2011
     20     * @access protected
     21     *
     22     * @var    string
    2423     */
    2524    protected $textdomain;
     
    2726
    2827    /**
    29      * The name of the calling plugin
    30      *
    31      * @author  Konstantin Obenland
    32      * @since   1.0 - 23.03.2011
    33      * @access  protected
    34      *
    35      * @var     string
     28     * The name of the calling plugin.
     29     *
     30     * @author Konstantin Obenland
     31     * @since  1.0 - 23.03.2011
     32     * @access protected
     33     *
     34     * @var    string
    3635     */
    3736    protected $plugin_name;
     
    3938
    4039    /**
    41      * The donate link for the plugin
    42      *
    43      * @author  Konstantin Obenland
    44      * @since   1.0 - 23.03.2011
    45      * @access  protected
    46      *
    47      * @var     string
     40     * The donate link for the plugin.
     41     *
     42     * @author Konstantin Obenland
     43     * @since  1.0 - 23.03.2011
     44     * @access protected
     45     *
     46     * @var    string
    4847     */
    4948    protected $donate_link;
     
    5150
    5251    /**
    53      * The path to the plugin folder
     52     * The path to the plugin file.
     53     *
     54     * /path/to/wp-content/plugins/{plugin-name}/{plugin-name}.php
     55     *
     56     * @author Konstantin Obenland
     57     * @since  2.0.0 - 30.05.2012
     58     * @access protected
     59     *
     60     * @var    string
     61     */
     62    protected $plugin_path;
     63
     64
     65    /**
     66     * The path to the plugin directory.
    5467     *
    5568     * /path/to/wp-content/plugins/{plugin-name}/
    5669     *
    57      * @author  Konstantin Obenland
    58      * @since   1.2 - 21.04.2011
    59      * @access  protected
    60      *
    61      * @var     string
    62      */
    63     protected $plugin_path;
     70     * @author Konstantin Obenland
     71     * @since  1.2 - 21.04.2011
     72     * @access protected
     73     *
     74     * @var    string
     75     */
     76    protected $plugin_dir_path;
    6477
    6578
     
    7184     * Constructor
    7285     *
    73      * @author  Konstantin Obenland
    74      * @since   1.0 - 23.03.2011
    75      * @access  public
    76      *
    77      * @param   string  $plugin_name
    78      * @param   string  $donate_link_id
    79      *
    80      * @return  Obenland_Wp_Plugins
     86     * @author Konstantin Obenland
     87     * @since  1.0 - 23.03.2011
     88     * @access public
     89     *
     90     * @param  string $plugin_name
     91     * @param  string $donate_link_id
     92     *
     93     * @return Obenland_Wp_Plugins
    8194     */
    8295    public function __construct( $args = array() ) {
    8396
    8497        // Set class properties
    85         $this->textdomain   =   $args['textdomain'];
    86         $this->plugin_path  =   plugin_dir_path( $args['plugin_path'] );
    87         $this->plugin_name  =   plugin_basename( $args['plugin_path'] );
     98        $this->textdomain      = $args['textdomain'];
     99        $this->plugin_path     = $args['plugin_path'];
     100        $this->plugin_dir_path = plugin_dir_path( $args['plugin_path'] );
     101        $this->plugin_name     = plugin_basename( $args['plugin_path'] );
     102
     103        load_plugin_textdomain( 'obenland-wp', false, $this->textdomain . '/lang' );
    88104
    89105        load_plugin_textdomain( 'obenland-wp' , false, $this->textdomain . '/lang' );
    90        
     106
    91107        $this->set_donate_link( $args['donate_link_id'] );
    92108        $this->hook( 'plugins_loaded', 'parent_plugins_loaded' );
    93109    }
    94    
    95    
     110
     111
    96112    /**
    97113     * Hooks in all the hooks :)
    98114     *
    99      * @author  Konstantin Obenland
    100      * @since   2.0.0 - 12.04.2012
    101      * @access  public
    102      *
    103      * @return  void
     115     * @author Konstantin Obenland
     116     * @since  2.0.0 - 12.04.2012
     117     * @access public
     118     *
     119     * @return void
    104120     */
    105121    public function parent_plugins_loaded() {
    106122        $this->hook( 'plugin_row_meta' );
    107         $this->hook( 'obenland_side_info_column', 'donate_box', 1 );
    108         $this->hook( 'obenland_side_info_column', 'feed_box' );
    109     }
    110 
    111 
    112     /**
    113      *
    114      * @author  Konstantin Obenland
    115      * @since   1.0 - 23.03.2011
    116      * @access  public
    117      *
    118      * @param   array   $plugin_meta
    119      * @param   string  $plugin_file
    120      *
    121      * @return  string
     123        if ( ! has_action( 'obenland_side_info_column' ) ) {
     124            $this->hook( 'obenland_side_info_column', 'donate_box', 1 );
     125            $this->hook( 'obenland_side_info_column', 'feed_box'      );
     126        }
     127    }
     128
     129
     130    /**
     131     *
     132     * @author Konstantin Obenland
     133     * @since  1.0 - 23.03.2011
     134     * @access public
     135     *
     136     * @param  array  $plugin_meta
     137     * @param  string $plugin_file
     138     *
     139     * @return string
    122140     */
    123141    public function plugin_row_meta( $plugin_meta, $plugin_file ) {
    124142        if ( $this->plugin_name == $plugin_file ) {
    125             $plugin_meta[]  =   sprintf('
    126                 <a href="%1$s" target="_blank" title="%2$s">%2$s</a>',
     143            $plugin_meta[] = sprintf(
     144                '<a href="%1$s" target="_blank" title="%2$s">%2$s</a>',
    127145                $this->donate_link,
    128                 __('Donate', $this->textdomain)
     146                __( 'Donate', 'obenland-wp' )
    129147            );
    130148        }
    131149        return $plugin_meta;
    132150    }
    133    
    134    
     151
     152
    135153    /**
    136154     * Displays a box with a donate button and call to action links
     
    168186        <?php
    169187    }
    170        
    171        
     188
     189
    172190    /**
    173191     * Displays a box with feed items and social media links
    174      * 
     192     *
    175193     * Props Joost de Valk, as this is almost entirely from his awesome WordPress
    176194     * SEO Plugin
     
    184202     */
    185203    public function feed_box() {
    186        
     204
    187205        include_once( ABSPATH . WPINC . '/feed.php' );
    188206        $feed_url = 'http://en.wp.obenland.it/feed/';
    189207        $rss = fetch_feed( $feed_url );
    190        
     208
    191209        // Bail if feed doesn't work
    192210        if ( is_wp_error($rss) )
    193211            return false;
    194        
     212
    195213        $rss_items = $rss->get_items( 0, $rss->get_item_quantity( 5 ) );
    196        
     214
    197215        // If the feed was erroneously
    198216        if ( ! $rss_items ) {
     
    224242
    225243
     244    /**
     245     * Displays a box with a donate button and call to action links.
     246     *
     247     * Props Joost de Valk, as this is almost entirely from his awesome WordPress
     248     * SEO Plugin.
     249     * @see    http://plugins.svn.wordpress.org/wordpress-seo/tags/1.1.5/admin/class-config.php
     250     *
     251     * @author Joost de Valk, Konstantin Obenland
     252     * @since  2.0.0 - 31.03.2012
     253     * @access public
     254     *
     255     * @return void
     256     */
     257    public function donate_box() {
     258        $plugin_data = get_plugin_data( $this->plugin_path );
     259        ?>
     260        <div id="formatdiv" class="postbox">
     261            <h3 class="hndle"><span><?php esc_html_e( 'Help spread the word!', 'obenland-wp' ); ?></span></h3>
     262            <div class="inside">
     263                <p><strong><?php printf( _x( 'Want to help make this plugin even better? All donations are used to improve %1$s, so donate $20, $50 or $100 now!', 'Plugin Name', 'obenland-wp' ), esc_html($plugin_data['Name']) ); ?></strong></p>
     264                <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
     265                    <input type="hidden" name="cmd" value="_s-xclick">
     266                    <input type="hidden" name="hosted_button_id" value="G65Y5CM3HVRNY">
     267                    <input type="image" src="https://www.paypalobjects.com/<?php echo get_locale(); ?>/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal Ñ The safer, easier way to pay online.">
     268                    <img alt="" border="0" src="https://www.paypalobjects.com/de_DE/i/scr/pixel.gif" width="1" height="1">
     269                </form>
     270                <p><?php _e( 'Or you could:', 'obenland-wp' ); ?></p>
     271                <ul>
     272                    <li><a href="http://wordpress.org/extend/plugins/wp-approve-user/"><?php _e( 'Rate the plugin 5&#9733; on WordPress.org', 'obenland-wp' ); ?></a></li>
     273                    <li><a href="<?php echo esc_url( $plugin_data['PluginURI'] ); ?>"><?php _e( 'Blog about it &amp; link to the plugin page', 'obenland-wp' ); ?></a></li>
     274                </ul>
     275            </div>
     276        </div>
     277        <?php
     278    }
     279
     280
     281    /**
     282     * Displays a box with feed items and social media links.
     283     *
     284     * Props Joost de Valk, as this is almost entirely from his awesome WordPress
     285     * SEO Plugin.
     286     * @see    http://plugins.svn.wordpress.org/wordpress-seo/tags/1.1.5/admin/yst_plugin_tools.php
     287     *
     288     * @author Joost de Valk, Konstantin Obenland
     289     * @since  2.0.0 - 31.03.2012
     290     * @access public
     291     *
     292     * @return void
     293     */
     294    public function feed_box() {
     295
     296        include_once( ABSPATH . WPINC . '/feed.php' );
     297        $feed_url = 'http://en.wp.obenland.it/feed/';
     298        $rss      = fetch_feed( $feed_url );
     299
     300        // Bail if feed doesn't work.
     301        if ( is_wp_error( $rss ) )
     302            return;
     303
     304        $rss_items = $rss->get_items( 0, $rss->get_item_quantity( 5 ) );
     305
     306        // If the feed was erroneously.
     307        if ( ! $rss_items ) {
     308            $md5 = md5( $feed_url );
     309            delete_transient( 'feed_' . $md5 );
     310            delete_transient( 'feed_mod_' . $md5 );
     311            $rss       = fetch_feed( $feed_url );
     312            $rss_items = $rss->get_items( 0, $rss->get_item_quantity( 5 ) );
     313        }
     314        ?>
     315        <div id="formatdiv" class="postbox">
     316            <h3 class="hndle"><span><?php esc_html_e( 'News from Konstantin', 'obenland-wp' ); ?></span></h3>
     317            <div class="inside">
     318                <ul>
     319                    <?php if ( ! $rss_items ) : ?>
     320                    <li><?php _e( 'No news items, feed might be broken...', 'obenland-wp' ); ?></li>
     321                    <?php else :
     322                    foreach ( $rss_items as $item ) :
     323                        $url = preg_replace( '/#.*/', '#utm_source=wordpress&utm_medium=sidebannerpostbox&utm_term=rssitem&utm_campaign=' . $this->textdomain, $item->get_permalink() ); ?>
     324                <li><a class="rsswidget" href="<?php echo esc_url( $url ); ?>"><?php echo esc_html( $item->get_title() ); ?></a></li>
     325                <?php endforeach; endif; ?>
     326                    <li class="twitter"><a href="http://twitter.com/obenland"><?php _e( 'Follow Konstantin on Twitter', 'obenland-wp' ); ?></a></li>
     327                    <li class="rss"><a href="<?php echo esc_url( $feed_url ); ?>"><?php _e( 'Subscribe via RSS', 'obenland-wp' ); ?></a></li>
     328                </ul>
     329            </div>
     330        </div>
     331        <?php
     332    }
     333
     334
    226335    ///////////////////////////////////////////////////////////////////////////
    227336    // METHODS, PROTECTED
     
    229338
    230339    /**
    231      * Hooks methods their WordPress Actions and Filters
     340     * Hooks methods to their WordPress Actions and Filters.
    232341     *
    233342     * @example:
     
    236345     * $this->hook( 'omg', 'is_really_tedious', 3 );
    237346     *
    238      * @author  Mark Jaquith
    239      * @see     http://sliwww.slideshare.net/markjaquith/creating-and-maintaining-wordpress-plugins
    240      * @since   1.5 - 12.02.2012
    241      * @access  protected
    242      *
    243      * @param   string  $hook Action or Filter Hook name
    244      *
    245      * @return  boolean true
     347     * @author Mark Jaquith
     348     * @see    http://sliwww.slideshare.net/markjaquith/creating-and-maintaining-wordpress-plugins
     349     * @since  1.5 - 12.02.2012
     350     * @access protected
     351     *
     352     * @param  string $hook Action or Filter Hook name.
     353     *
     354     * @return boolean true
    246355     */
    247356    protected function hook( $hook ) {
    248         $priority   =   10;
    249         $method     =   $this->sanitize_method( $hook );
    250         $args       =   func_get_args();
     357        $priority = 10;
     358        $method   = $this->sanitize_method( $hook );
     359        $args     = func_get_args();
    251360        unset( $args[0] ); // Filter name
    252361
    253362        foreach ( (array) $args as $arg ) {
    254             if ( is_int( $arg ) ) {
    255                 $priority   =   $arg;
    256             }
    257             else {
    258                 $method     =   $arg;
    259 
    260             }
     363            if ( is_int( $arg ) )
     364                $priority = $arg;
     365            else
     366                $method   = $arg;
    261367        }
    262368
    263         return add_action(  $hook, array( $this, $method ), $priority , 999 );
    264     }
    265    
    266    
    267     /**
    268      * Sets the donate link
    269      *
    270      * @author  Konstantin Obenland
    271      * @since   1.1 - 03.04.2011
    272      * @access  protected
    273      *
    274      * @param   string  $donate_link_id
    275      *
    276      * @return  void
     369        return add_action( $hook, array( $this, $method ), $priority , 999 );
     370    }
     371
     372
     373    /**
     374     * Sets the donate link.
     375     *
     376     * @author Konstantin Obenland
     377     * @since  1.1 - 03.04.2011
     378     * @access protected
     379     *
     380     * @param  string $donate_link_id
     381     *
     382     * @return void
    277383     */
    278384    protected function set_donate_link( $donate_link_id ) {
    279         $this->donate_link  =   add_query_arg( array(
    280             'cmd'               =>  '_s-xclick',
    281             'hosted_button_id'  =>  $donate_link_id
     385        $this->donate_link = add_query_arg( array(
     386            'cmd'              => '_s-xclick',
     387            'hosted_button_id' => $donate_link_id
    282388        ), 'https://www.paypal.com/cgi-bin/webscr' );
    283389    }
     
    286392    // METHODS, PRIVATE
    287393    ///////////////////////////////////////////////////////////////////////////
    288    
    289     /**
    290      * Sanitizes method names
    291      *
    292      * @author  Mark Jaquith
    293      * @see     http://sliwww.slideshare.net/markjaquith/creating-and-maintaining-wordpress-plugins
    294      * @since   1.5 - 12.02.2012
    295      * @access  private
    296      *
    297      * @param   string  $method     Method name to be sanitized
    298      *
    299      * @return  string  Sanitized method name
     394
     395    /**
     396     * Sanitizes method names.
     397     *
     398     * @author Mark Jaquith
     399     * @see    http://sliwww.slideshare.net/markjaquith/creating-and-maintaining-wordpress-plugins
     400     * @since  1.5 - 12.02.2012
     401     * @access private
     402     *
     403     * @param  string $method Method name to be sanitized.
     404     *
     405     * @return string Sanitized method name
    300406     */
    301407    private function sanitize_method( $method ) {
  • wp-display-header/trunk/readme.txt

    r541921 r690895  
    44Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MWUA92KA2TL6Q
    55Requires at least: 3.2
    6 Tested up to: 3.4-beta4
    7 Stable tag: 2.0.1
     6Tested up to: 3.6
     7Stable tag: 2.1.0
    88
    99Select a specific header or random header image for each content item or archive page.
     
    6868== Changelog ==
    6969
     70= 2.1.0 =
     71* Added an option to not display a header at all.
     72* Updated utility class.
     73* Tested for WordPress 3.6.
     74
    7075= 2.0.1 =
    71 * Fixed a bug, where the fallback to the default header did not work. Props carloscorrela
     76* Fixed a bug, where the fallback to the default header did not work. Props carloscorrela.
    7277
    7378= 2.0.0 =
    7479* **IMPORTANT**: Version 2.0.0 breaks compatibility with WordPress versions **prior** to 3.2!
    7580* Added the header selection field to Taxonomy and Author Edit screens.
    76 * Fixed a minor bug for themes that have no header images registered
     81* Fixed a minor bug for themes that have no header images registered.
    7782
    7883= 1.5.3 =
    7984* Improved user experience when current theme does not support custom headers, on activation of the plugin.
    80 * Deprecated settings functions for WP Save Custom Header in preparation for overhaul in v2.0.0
    81 * Updated utility class
     85* Deprecated settings functions for WP Save Custom Header in preparation for overhaul in v2.0.0.
     86* Updated utility class.
    8287
    8388= 1.5.2 =
     
    8893
    8994= 1.5 =
    90 * Adjusted meta box layout to WordPress core
    91 * Transfered CSS in external file
    92 * Updated FAQ section (thanks Brian!)
    93 * Tested for WordPress 3.3.1
     95* Adjusted meta box layout to WordPress core.
     96* Transfered CSS in external file.
     97* Updated FAQ section. Props Brian.
     98* Tested for WordPress 3.3.1.
    9499
    95100= 1.4 =
    96 * Added support for WordPress 3.2 core header uploads
     101* Added support for WordPress 3.2 core header uploads.
    97102
    98103= 1.3 =
     
    101106
    102107= 1.2.1 =
    103 * WordPress Plugin Repository update bug
     108* WordPress Plugin Repository update bug.
    104109
    105110= 1.2 =
    106 * Tested for WordPress 3.1.2
    107 * Now a custom folder name can be specified. See: Settings > Media
    108 * Added Italian translation (Thanks to Pietro Rossi)
     111* Tested for WordPress 3.1.2.
     112* Now a custom folder name can be specified. See: Settings > Media.
     113* Added Italian translation. Props Pietro Rossi.
    109114
    110115= 1.1 =
    111116* Tested for WordPress 3.1.1
    112 * Adopted [WP Save Custom Header](http://wordpress.org/extend/plugins/wp-save-custom-header/ "This plugin lets you save and reuse your uploaded header images.") multisite capability
    113 * Made HTML W3C valid
     117* Adopted [WP Save Custom Header](http://wordpress.org/extend/plugins/wp-save-custom-header/ "This plugin lets you save and reuse your uploaded header images.") multisite capability.
     118* Made HTML W3C valid.
    114119
    115120= 1.0 =
    116 * Initial Release
     121* Initial Release.
    117122
    118123== Upgrade Notice ==
  • wp-display-header/trunk/wp-display-header.php

    r690454 r690895  
    22/** wp-display-header.php
    33 *
    4  * Plugin Name: WP Display Header
    5  * Plugin URI:  http://en.wp.obenland.it/wp-display-header/?utm_source=wordpress&utm_medium=plugin&utm_campaign=wp-display-header
    6  * Description: This plugin lets you specify a header image for each post and taxonomy/author archive page individually, from your default headers and custom headers.
    7  * Version:     2.0.1
    8  * Author:      Konstantin Obenland
    9  * Author URI:  http://en.wp.obenland.it/?utm_source=wordpress&utm_medium=plugin&utm_campaign=wp-display-header
    10  * Text Domain: wp-display-header
    11  * Domain Path: /lang
    12  * License:     GPLv2
     4 * Plugin Name: WP Display Header
     5 * Plugin URI:  http://en.wp.obenland.it/wp-display-header/?utm_source=wordpress&utm_medium=plugin&utm_campaign=wp-display-header
     6 * Description: This plugin lets you specify a header image for each post and taxonomy/author archive page individually, from your default headers and custom headers.
     7 * Version:     2.1.0
     8 * Author:      Konstantin Obenland
     9 * Author URI:  http://en.wp.obenland.it/?utm_source=wordpress&utm_medium=plugin&utm_campaign=wp-display-header
     10 * Text Domain: wp-display-header
     11 * Domain Path: /lang
     12 * License:     GPLv2
    1313 */
    1414
    1515
    16 if ( ! class_exists('Obenland_Wp_Plugins_v200') ) {
     16if ( ! class_exists( 'Obenland_Wp_Plugins_v301' ) )
    1717    require_once( 'obenland-wp-plugins.php' );
    18 }
    19 
    20 
    21 register_activation_hook(__FILE__, array(
     18
     19
     20register_activation_hook( __FILE__, array(
    2221    'Obenland_Wp_Display_Header',
    2322    'activation'
    24 ));
    25 
    26 
    27 class Obenland_Wp_Display_Header extends Obenland_Wp_Plugins_v200 {
    28 
     23) );
     24
     25
     26class Obenland_Wp_Display_Header extends Obenland_Wp_Plugins_v301 {
    2927
    3028    ///////////////////////////////////////////////////////////////////////////
     
    3533     * Constructor
    3634     *
    37      * @author  Konstantin Obenland
    38      * @since   1.0 - 23.03.2011
    39      * @access  public
    40      *
    41      * @return  Obenland_Wp_Display_Header
     35     * @author Konstantin Obenland
     36     * @since  1.0 - 23.03.2011
     37     * @access public
     38     *
     39     * @return Obenland_Wp_Display_Header
    4240     */
    4341    public function __construct() {
    4442
    4543        parent::__construct( array(
    46             'textdomain'        =>  'wp-display-header',
    47             'plugin_path'       =>  __FILE__,
    48             'donate_link_id'    =>  'MWUA92KA2TL6Q'
     44            'textdomain'     => 'wp-display-header',
     45            'plugin_path'    => __FILE__,
     46            'donate_link_id' => 'MWUA92KA2TL6Q',
    4947        ));
    5048
     
    5957     * if it doesn't. The plugin will stay deactivated.
    6058     *
    61      * @author  Konstantin Obenland
    62      * @since   1.0 - 23.03.2011
    63      * @access  public
     59     * @author Konstantin Obenland
     60     * @since  1.0 - 23.03.2011
     61     * @access public
    6462     * @static
    6563     *
    66      * @return  void
     64     * @return void
    6765     */
    6866    public static function activation() {
     
    7169        if ( ! current_theme_supports( 'custom-header' ) ) {
    7270            wp_die( __( 'Your current theme does not support Custom Headers.', 'wp-display-header' ), '', array(
    73                 'back_link' =>  true
     71                'back_link' => true
    7472            ) );
    7573        }
    7674
    77         if ( version_compare( get_bloginfo('version'), '3.2', '<' ) ) {
     75        if ( version_compare( get_bloginfo( 'version' ), '3.2', '<' ) ) {
    7876            wp_die( __( 'WP Display Headers requires WordPress version 3.2 or later.', 'wp-display-header' ), '', array(
    79                 'back_link' =>  true
     77                'back_link' => true
    8078            ) );
    8179        }
     
    8684     * Hooks in all the hooks :)
    8785     *
    88      * @author  Konstantin Obenland
    89      * @since   1.5.3 - 24.02.2012
    90      * @access  public
    91      *
    92      * @return  void
     86     * @author Konstantin Obenland
     87     * @since  1.5.3 - 24.02.2012
     88     * @access public
     89     *
     90     * @return void
    9391     */
    9492    public function init() {
     
    10098        $this->hook( 'save_post' );
    10199        $this->hook( 'edit_term' );
    102         $this->hook( 'personal_options_update',             'update_user' );
    103         $this->hook( 'edit_user_profile_update',            'update_user' );
     100        $this->hook( 'personal_options_update',             'update_user'                );
     101        $this->hook( 'edit_user_profile_update',            'update_user'                );
    104102
    105103        // Styles
    106         $this->hook( 'admin_init', 'register_scripts_styles', 9 ); // Set priority to 9, so they can easily be deregistered
    107         $this->hook( 'admin_print_styles-post-new.php',     'admin_print_styles' );
    108         $this->hook( 'admin_print_styles-post.php',         'admin_print_styles' );
    109         $this->hook( 'admin_print_styles-edit-tags.php',    'admin_print_styles' );
    110         $this->hook( 'admin_print_styles-profile.php',      'admin_print_styles' );
    111         $this->hook( 'admin_print_styles-user-edit.php',    'admin_print_styles' );
     104        $this->hook( 'admin_init',                          'register_scripts_styles', 9 ); // Set priority to 9, so they can easily be deregistered.
     105        $this->hook( 'admin_print_styles-post-new.php',     'admin_print_styles'        );
     106        $this->hook( 'admin_print_styles-post.php',         'admin_print_styles'        );
     107        $this->hook( 'admin_print_styles-edit-tags.php',    'admin_print_styles'        );
     108        $this->hook( 'admin_print_styles-profile.php',      'admin_print_styles'        );
     109        $this->hook( 'admin_print_styles-user-edit.php',    'admin_print_styles'        );
    112110
    113111        // Edit forms
    114         foreach ( get_taxonomies( array('show_ui' => true) ) as $_tax ) {
    115             $this->hook( "{$_tax}_edit_form",               'edit_form' , 9 ); //Let's make us a bit more important than we are
    116         }
    117         $this->hook( 'admin_init',                          'add_settings_field' );
    118         $this->hook( 'show_user_profile',                   'edit_form' );
    119         $this->hook( 'show_user_profile',                   'edit_form' );
    120     }
    121 
    122 
    123     /**
    124      * Returns the header url
     112        foreach ( get_taxonomies( array( 'show_ui' => true ) ) as $_tax )
     113            $this->hook( "{$_tax}_edit_form",               'edit_form',               9 ); // Let's make us a bit more important than we are.
     114
     115        $this->hook( 'admin_init',                          'add_settings_field'        );
     116        $this->hook( 'show_user_profile',                   'edit_form'                  );
     117        $this->hook( 'show_user_profile',                   'edit_form'                  );
     118    }
     119
     120
     121    /**
     122     * Returns the header url.
    125123     *
    126124     * Returns the default header when we are on the blog page, the header
     
    128126     * filtered!
    129127     *
    130      * @author  Konstantin Obenland
    131      * @since   1.0 - 23.03.2011
    132      * @access  public
    133      *
    134      * @param   string  $header_url The header url as saved in the theme mods
    135      *
    136      * @return  string
     128     * @author Konstantin Obenland
     129     * @since  1.0 - 23.03.2011
     130     * @access public
     131     *
     132     * @param  string $header_url The header url as saved in the theme mods.
     133     *
     134     * @return string
    137135     */
    138136    public function theme_mod_header_image( $header_url ) {
    139137
    140         if ( is_category() OR is_tag() OR is_tax() ) {
     138        if ( is_category() OR is_tag() OR is_tax() )
    141139            $active_header = $this->get_active_tax_header();
    142         }
    143         else if ( is_author() ) {
     140
     141        else if ( is_author() )
    144142            $active_header = $this->get_active_author_header();
    145         }
    146         else if ( is_singular() ) {
     143
     144        else if ( is_singular() )
    147145            $active_header = $this->get_active_post_header();
    148         }
    149 
    150         if ( isset($active_header) AND $active_header ) {
     146
     147        if ( isset( $active_header ) AND $active_header )
    151148            $header_url = $active_header;
    152         }
    153149
    154150        return $header_url;
     
    157153
    158154    /**
    159      * Adds the header post meta box
    160      *
    161      * @author  Konstantin Obenland
    162      * @since   1.0 - 23.03.2011
    163      * @access  public
    164      *
    165      * @param   string  $post_type
    166      *
    167      * @return  void
     155     * Adds the header post meta box.
     156     *
     157     * @author Konstantin Obenland
     158     * @since  1.0 - 23.03.2011
     159     * @access public
     160     *
     161     * @param  string $post_type
     162     *
     163     * @return void
    168164     */
    169165    public function add_meta_boxes( $post_type ) {
    170         add_meta_box( 'wp-display-header', __('Header'), array( &$this, 'display_meta_box' ), $post_type, 'normal', 'high' );
    171     }
    172 
    173 
    174     /**
    175      * Registers the stylesheet
     166        add_meta_box( 'wp-display-header', __( 'Header' ), array( &$this, 'display_meta_box' ), $post_type, 'normal', 'high' );
     167    }
     168
     169
     170    /**
     171     * Registers the stylesheet.
    176172     *
    177173     * The stylesheets can easily be deregistered be calling
    178174     * <code>wp_deregister_style( 'wp-display-header' );</code> on the
    179      * admin_init hook
    180      *
    181      * @author  Konstantin Obenland
    182      * @since   1.5 - 22.01.2012
    183      * @access  public
    184      *
    185      * @return  void
     175     * admin_init hook.
     176     *
     177     * @author Konstantin Obenland
     178     * @since  1.5 - 22.01.2012
     179     * @access public
     180     *
     181     * @return void
    186182     */
    187183    public function register_scripts_styles() {
    188184        $plugin_data = get_plugin_data( __FILE__, false, false );
    189         $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
     185        $suffix      = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
    190186
    191187        wp_register_style(
     
    201197     * Enqueues the CSS so the Header meta box looks nice :)
    202198     *
    203      * @author  Konstantin Obenland
    204      * @since   1.0 - 23.03.2011
    205      * @access  public
    206      *
    207      * @return  void
     199     * @author Konstantin Obenland
     200     * @since  1.0 - 23.03.2011
     201     * @access public
     202     *
     203     * @return void
    208204     */
    209205    public function admin_print_styles() {
     
    214210    /**
    215211     * Registers the setting and the settings field if it does not already
    216      * exist
    217      *
    218      * @author  Konstantin Obenland
    219      * @since   1.0 - 22.01.2012
    220      * @access  public
    221      *
    222      * return   void
     212     * exist.
     213     *
     214     * @author Konstantin Obenland
     215     * @since  1.0 - 22.01.2012
     216     * @access public
     217     *
     218     * return void
    223219     */
    224220    public function add_settings_field() {
     
    226222        add_settings_section(
    227223            $this->textdomain,
    228             __('Header'),
     224            __( 'Header' ),
    229225            array(
    230226                &$this,
     
    236232        add_settings_field(
    237233            $this->textdomain,
    238             __('Choose Header', 'wp-display-header-pro'),
     234            __( 'Choose Header', 'wp-display-header' ),
    239235            array(
    240236                &$this,
     
    248244
    249245    /**
    250      * Adds a settings section to the category edit screen
    251      *
    252      * @author  Konstantin Obenland
    253      * @since   1.0 - 22.01.2012
    254      * @access  public
    255      *
    256      * @param   stdClass    $object
    257      *
    258      * @return  void
     246     * Adds a settings section to the category edit screen.
     247     *
     248     * @author Konstantin Obenland
     249     * @since  1.0 - 22.01.2012
     250     * @access public
     251     *
     252     * @param  stdClass $object
     253     *
     254     * @return void
    259255     */
    260256    public function edit_form( $object ) {
     
    264260
    265261    /**
    266      * Renders the content of the post meta box
    267      *
    268      * @author  Konstantin Obenland
    269      * @since   1.0 - 22.01.2012
    270      * @access  public
    271      *
    272      * @param   stdClass    $post
    273      *
    274      * @return  void
     262     * Renders the content of the post meta box.
     263     *
     264     * @author Konstantin Obenland
     265     * @since  1.0 - 22.01.2012
     266     * @access public
     267     *
     268     * @param  stdClass $post
     269     *
     270     * @return void
    275271     */
    276272    public function display_meta_box( $post ) {
    277         $active =   $this->get_active_post_header( $post->ID, true );
     273        $active = $this->get_active_post_header( $post->ID, true );
    278274        $this->header_selection_form( $active );
    279275    }
     
    284280     * fields).
    285281     *
    286      * @author  Konstantin Obenland
    287      * @since   1.0 - 22.01.2012
    288      * @access  public
    289      *
    290      * return   void
     282     * @author Konstantin Obenland
     283     * @since  1.0 - 22.01.2012
     284     * @access public
     285     *
     286     * return  void
    291287     */
    292288    public function settings_section_callback() {
    293 
    294         switch ( get_current_screen()->base ) {
    295             case 'profile':
    296                 _e( 'Select a header image for the author page.', 'wp-display-header-pro' );
    297                 break;
    298 
    299             case 'edit-tags':
    300                 _e( 'Select a header image for the taxonomy archive page.', 'wp-display-header-pro' );
    301                 break;
    302         }
    303     }
    304 
    305 
    306     /**
    307      * Displays the settings field HTML
    308      *
    309      * @author  Konstantin Obenland
    310      * @since   1.0 - 22.01.2012
    311      * @access  public
    312      *
    313      * @return  void
     289        if ( 'profile' == get_current_screen()->base )
     290            _e( 'Select a header image for the author page.', 'wp-display-header' );
     291
     292        elseif ( 'edit-tags' == get_current_screen()->base )
     293            _e( 'Select a header image for the taxonomy archive page.', 'wp-display-header' );
     294    }
     295
     296
     297    /**
     298     * Displays the settings field HTML.
     299     *
     300     * @author Konstantin Obenland
     301     * @since  1.0 - 22.01.2012
     302     * @access public
     303     *
     304     * @return void
    314305     */
    315306    public function header_selection_callback() {
    316 
    317         $active =   '';
     307        $active = '';
    318308
    319309        switch ( get_current_screen()->base ) {
     
    325315            case 'edit-tags':
    326316                global $tag;
    327                 if ( $active = get_option( 'wpdh_tax_meta', '' ) ) {
    328                     $active =   isset($active[$tag->term_taxonomy_id]) ? $active[$tag->term_taxonomy_id] : '';
    329                 }
     317                if ( $active = get_option( 'wpdh_tax_meta', '' ) )
     318                    $active = isset( $active[ $tag->term_taxonomy_id ] ) ? $active[ $tag->term_taxonomy_id ] : '';
    330319                break;
    331320        }
    332321
    333322        // If no header set yet, get default header
    334         if ( ! $active ) {
    335             $active =   get_theme_mod( 'header_image' );
    336         }
     323        if ( ! $active )
     324            $active = get_theme_mod( 'header_image' );
    337325
    338326        $this->header_selection_form( $active );
     
    341329
    342330    /**
    343      * Saves the selected header for this post
    344      *
    345      * @author  Konstantin Obenland
    346      * @since   1.0 - 23.03.2011
    347      * @access  public
    348      *
    349      * @param   int     $post_ID
    350      *
    351      * @return  int     Post ID
     331     * Saves the selected header for this post.
     332     *
     333     * @author Konstantin Obenland
     334     * @since  1.0 - 23.03.2011
     335     * @access public
     336     *
     337     * @param  int $post_ID
     338     *
     339     * @return int Post ID
    352340     */
    353341    public function save_post( $post_ID ) {
    354342
    355343        if ( ( ! defined('DOING_AUTOSAVE') OR ! DOING_AUTOSAVE ) AND
    356             ( isset($_POST[$this->textdomain]) ) AND
    357             ( wp_verify_nonce($_POST["{$this->textdomain}-nonce"], $this->textdomain) ) ) {
    358 
    359             $value  =   ('random' == $_POST[$this->textdomain]) ? 'random' : esc_url_raw( $_POST[$this->textdomain] );
    360 
    361             if ( isset($_POST['wpdh-reset-header']) ) {
     344            isset( $_POST[ $this->textdomain ] ) AND
     345            wp_verify_nonce( $_POST["{$this->textdomain}-nonce"], $this->textdomain ) ) {
     346
     347            if ( isset( $_POST['wpdh-reset-header'] ) ) {
    362348                delete_post_meta( $post_ID, '_wpdh_display_header' );
    363             }
    364             else {
     349
     350            } else {
     351                $value = in_array( $_POST[ $this->textdomain ], array( 'random', 'remove-header' ) ) ? $_POST[ $this->textdomain ] : esc_url_raw( $_POST[ $this->textdomain ] );
    365352                update_post_meta( $post_ID, '_wpdh_display_header', $value );
    366353            }
     
    373360
    374361    /**
    375      * Sanitizes the settings field input
    376      *
    377      * @author  Konstantin Obenland
    378      * @since   2.0.0 - 12.03.2012
    379      * @access  public
    380      *
    381      * @param   int     $term_id
    382      * @param   string  $tt_id
    383      * @param   string  $taxonomy
    384      *
    385      * @return  int     Term ID
     362     * Sanitizes the settings field input.
     363     *
     364     * @author Konstantin Obenland
     365     * @since  2.0.0 - 12.03.2012
     366     * @access public
     367     *
     368     * @param  int    $term_id
     369     * @param  string $tt_id
     370     * @param  string $taxonomy
     371     *
     372     * @return int Term ID
    386373     */
    387374    public function edit_term( $term_id, $tt_id, $taxonomy ) {
    388375
    389376        if ( ( ! defined('DOING_AUTOSAVE') OR ! DOING_AUTOSAVE ) AND
    390             ( isset($_POST[$this->textdomain]) ) AND
    391             ( wp_verify_nonce($_POST["{$this->textdomain}-nonce"], $this->textdomain) ) ) {
    392 
    393             $term_meta          =   get_option( 'wpdh_tax_meta', array() );
    394 
    395             if ( isset($_POST['wpdh-reset-header']) ) {
    396                 unset( $term_meta[$tt_id] );
    397             }
    398             else {
    399                 $term_meta[$tt_id]  =   ('random' == $_POST[$this->textdomain]) ? 'random' : esc_url_raw( $_POST[$this->textdomain] );
    400             }
     377            isset( $_POST[ $this->textdomain] ) AND
     378            wp_verify_nonce($_POST["{$this->textdomain}-nonce"], $this->textdomain) ) {
     379
     380            $term_meta = get_option( 'wpdh_tax_meta', array() );
     381
     382            if ( isset( $_POST['wpdh-reset-header'] ) )
     383                unset( $term_meta[ $tt_id ] );
     384
     385            else
     386                $term_meta[ $tt_id ] = in_array( $_POST[ $this->textdomain ], array( 'random', 'remove-header' ) ) ? $_POST[ $this->textdomain ] : esc_url_raw( $_POST[ $this->textdomain ] );
     387
    401388            update_option( 'wpdh_tax_meta', $term_meta );
    402389        }
     
    407394
    408395    /**
    409      * Sanitizes the settings field input
    410      *
    411      * @author  Konstantin Obenland
    412      * @since   2.0.0 - 12.03.2012
    413      * @access  public
    414      *
    415      * @param   int     $user_id
    416      *
    417      * @return  int     User ID
     396     * Sanitizes the settings field input.
     397     *
     398     * @author Konstantin Obenland
     399     * @since  2.0.0 - 12.03.2012
     400     * @access public
     401     *
     402     * @param  int $user_id
     403     *
     404     * @return int User ID
    418405     */
    419406    public function update_user( $user_id ) {
    420407
    421408        if ( ( ! defined('DOING_AUTOSAVE') OR ! DOING_AUTOSAVE ) AND
    422             ( isset($_POST[$this->textdomain]) ) AND
    423             ( wp_verify_nonce($_POST["{$this->textdomain}-nonce"], $this->textdomain) ) ) {
    424 
    425             if ( isset($_POST['wpdh-reset-header']) ) {
     409            isset( $_POST[ $this->textdomain ] ) AND
     410            wp_verify_nonce($_POST["{$this->textdomain}-nonce"], $this->textdomain ) ) {
     411
     412            if ( isset( $_POST['wpdh-reset-header'] ) ) {
    426413                delete_user_meta( $user_id, $this->textdomain );
    427             }
    428             else {
    429                 $value  =   ('random' == $_POST[$this->textdomain]) ? 'random' : esc_url_raw( $_POST[$this->textdomain] );
     414
     415            } else {
     416                $value = in_array( $_POST[ $this->textdomain ], array( 'random', 'remove-header' ) ) ? $_POST[ $this->textdomain ] : esc_url_raw( $_POST[ $this->textdomain ] );
    430417                update_user_meta( $user_id, $this->textdomain, $value );
    431418            }
     
    441428
    442429    /**
    443      * Displays the settings field HTML
    444      *
    445      * @author  Konstantin Obenland
    446      * @since   1.0 - 22.01.2012
    447      * @access  protected
    448      *
    449      * @param   string  $active
    450      *
    451      * @return  void
     430     * Displays the settings field HTML.
     431     *
     432     * @author Konstantin Obenland
     433     * @since  1.0 - 22.01.2012
     434     * @access protected
     435     *
     436     * @param  string $active
     437     *
     438     * @return void
    452439     */
    453440    protected function header_selection_form( $active = '' ) {
    454441
    455         $headers    =   $this->get_headers();
    456 
    457         if ( empty($headers) ) {
     442        $headers = $this->get_headers();
     443
     444        if ( empty( $headers ) ) {
    458445            printf(
    459                 __('The are no headers available. Please <a href="%s">upload a header image</a>!', 'wp-display-header'),
    460                 admin_url('themes.php?page=custom-header')
     446                __( 'The are no headers available. Please <a href="%s">upload a header image</a>!', 'wp-display-header' ),
     447                add_query_arg( array( 'page' => 'custom-header' ), admin_url( 'themes.php' ) )
    461448            );
    462449            return;
    463450        }
    464451
    465         foreach ( array_keys($headers) as $header ) {
    466             foreach ( array('url', 'thumbnail_url') as $url ) {
    467                 $headers[$header][$url] = sprintf(
    468                     $headers[$header][$url],
     452        foreach ( array_keys( $headers ) as $header ) {
     453            foreach ( array( 'url', 'thumbnail_url' ) as $url ) {
     454                $headers[ $header ][ $url ] = sprintf(
     455                    $headers[ $header ][ $url ],
    469456                    get_template_directory_uri(),
    470457                    get_stylesheet_directory_uri()
     
    477464        <div class="available-headers">
    478465            <div class="random-header">
    479                 <label>
    480                     <input name="wp-display-header" type="radio" value="random" <?php checked( 'random', $active ); ?> />
    481                     <?php _e( '<strong>Random:</strong> Show a different image on each page.' ); ?>
    482                 </label>
     466                <p>
     467                    <label>
     468                        <input name="wp-display-header" type="radio" value="random" <?php checked( 'random', $active ); ?> />
     469                        <?php _e( '<strong>Random:</strong> Show a different image on each page.' ); ?>
     470                    </label>
     471                </p>
     472                <p>
     473                    <label>
     474                        <input name="wp-display-header" type="radio" value="remove-header" <?php checked( 'remove-header', $active ); ?> />
     475                        <?php _e( '<strong>None:</strong> Show no header image.' ); ?>
     476                    </label>
     477                </p>
    483478            </div>
    484479            <?php
    485480            foreach ( $headers as $header_key => $header ) {
    486                 $header_url         =   $header['url'];
    487                 $header_thumbnail   =   $header['thumbnail_url'];
    488                 $header_desc        =   isset($header['description']) ? $header['description'] : '';
     481                $header_url       = $header['url'];
     482                $header_thumbnail = $header['thumbnail_url'];
     483                $header_desc      = isset( $header['description'] ) ? $header['description'] : '';
    489484            ?>
    490485            <div class="default-header">
    491486                <label>
    492                     <input name="wp-display-header" type="radio" value="<?php echo esc_attr($header_url); ?>" <?php checked($header_url, $active); ?> />
    493                     <img width="230" src="<?php echo esc_url($header_thumbnail); ?>" alt="<?php echo esc_attr($header_desc); ?>" title="<?php echo esc_attr($header_desc); ?>" />
     487                    <input name="wp-display-header" type="radio" value="<?php echo esc_attr( $header_url ); ?>" <?php checked( $header_url, $active ); ?> />
     488                    <img width="230" src="<?php echo esc_url( $header_thumbnail ); ?>" alt="<?php echo esc_attr( $header_desc ); ?>" title="<?php echo esc_attr( $header_desc ); ?>" />
    494489                </label>
    495490            </div>
     
    505500
    506501    /**
    507      * Returns all registered headers
     502     * Returns all registered headers.
    508503     *
    509504     * If there are uploaded headers via the WP Save Custom Header Plugin, they
    510505     * will be loaded, too.
    511506     *
    512      * @author  Konstantin Obenland
    513      * @since   1.0 - 23.03.2011
    514      * @access  public
    515      * @global  $_wp_default_headers
    516      *
    517      * @return  array
     507     * @author Konstantin Obenland
     508     * @since  1.0 - 23.03.2011
     509     * @access public
     510     * @global $_wp_default_headers
     511     *
     512     * @return array
    518513     */
    519514    protected function get_headers() {
    520515        global $_wp_default_headers;
    521516
    522         // Cast $_wp_default_headers to an array, in case there are no headers
    523517        $headers = array_merge( (array) $_wp_default_headers, get_uploaded_header_images() );
    524518
    525         return apply_filters( 'wpdh_get_headers', (array) $headers );
    526     }
    527 
    528 
    529     /**
    530      * Determines the active header for the post and returns the url
     519        return (array) apply_filters( 'wpdh_get_headers', $headers );
     520    }
     521
     522
     523    /**
     524     * Determines the active header for the post and returns the url.
    531525     *
    532526     * The $raw variable is necessary so that the 'random' option stays
    533      * selected in post edit screens
    534      *
    535      * @author  Konstantin Obenland
    536      * @since   2.0.0 - 12.03.2012
    537      * @access  protected
    538      *
    539      * @param   string  $post_ID
    540      * @param   boolean $raw
    541      *
    542      * @return  string
     527     * selected in post edit screens.
     528     *
     529     * @author Konstantin Obenland
     530     * @since  2.0.0 - 12.03.2012
     531     * @access protected
     532     *
     533     * @param  string  $post_ID
     534     * @param  boolean $raw
     535     *
     536     * @return string
    543537     */
    544538    protected function get_active_post_header( $post_ID = 0, $raw = false ) {
     
    546540        if ( ! $post_ID ) {
    547541            global $post;
    548             $post_ID    =   $post->ID;
    549         }
    550 
    551         $active =   get_post_meta( $post_ID, '_wpdh_display_header', true );
     542            $post_ID = $post->ID;
     543        }
     544
     545        $active = get_post_meta( $post_ID, '_wpdh_display_header', true );
    552546
    553547        return apply_filters( 'wpdh_get_active_post_header', $this->get_active_header( $active, $raw ) );
     
    556550
    557551    /**
    558      * Determines the active header for the category and returns the url
     552     * Determines the active header for the category and returns the url.
    559553     *
    560554     * The $raw variable is necessary so that the 'random' option stays
    561      * selected in post edit screens
    562      *
    563      * @author  Konstantin Obenland
    564      * @since   2.0.0 - 12.03.2012
    565      * @access  protected
    566      *
    567      * @return  string
     555     * selected in post edit screens.
     556     *
     557     * @author Konstantin Obenland
     558     * @since  2.0.0 - 12.03.2012
     559     * @access protected
     560     *
     561     * @return string
    568562     */
    569563    protected function get_active_tax_header() {
    570564
    571565        if ( $active = get_option( 'wpdh_tax_meta', false ) ) {
    572             $tt_id  =   get_queried_object()->term_taxonomy_id;
    573             $active =   isset($active[$tt_id]) ? $active[$tt_id] : '';
     566            $tt_id  = get_queried_object()->term_taxonomy_id;
     567            $active = isset( $active[ $tt_id ] ) ? $active[ $tt_id ] : '';
    574568        }
    575569
     
    579573
    580574    /**
    581      * Determines the active header for the author and returns the url
     575     * Determines the active header for the author and returns the url.
    582576     *
    583577     * The $raw variable is necessary so that the 'random' option stays
    584      * selected in post edit screens
    585      *
    586      * @author  Konstantin Obenland
    587      * @since   2.0.0 - 12.03.2012
    588      * @access  protected
    589      *
    590      * @return  string
     578     * selected in post edit screens.
     579     *
     580     * @author Konstantin Obenland
     581     * @since  2.0.0 - 12.03.2012
     582     * @access protected
     583     *
     584     * @return string
    591585     */
    592586    protected function get_active_author_header() {
    593 
    594         $active =   get_user_meta( get_queried_object()->ID, $this->textdomain, true );
    595 
     587        $active = get_user_meta( get_queried_object()->ID, $this->textdomain, true );
    596588        return apply_filters( 'wpdh_get_active_author_header', $this->get_active_header( $active ) );
    597589    }
     
    599591
    600592    /**
    601      * Determines the active header for the post and returns the url
     593     * Determines the active header for the post and returns the url.
    602594     *
    603595     * The $raw variable is necessary so that the 'random' option stays
    604      * selected in post edit screens
    605      *
    606      * @author  Konstantin Obenland
    607      * @since   1.0 - 23.03.2011
    608      * @access  public
    609      *
    610      * @param   string  $header Header URL
    611      * @param   boolean $raw
    612      *
    613      * @return  string
     596     * selected in post edit screens.
     597     *
     598     * @author Konstantin Obenland
     599     * @since  1.0 - 23.03.2011
     600     * @access public
     601     *
     602     * @param  string  $header Header URL
     603     * @param  boolean $raw
     604     *
     605     * @return string
    614606     */
    615607    protected function get_active_header( $header, $raw = false ) {
    616608
    617         if ( ! $header ) {
    618             $header = get_theme_mod( 'header_image' );
    619         }
    620 
    621         if ( is_random_header_image() OR 'random' == $header ) {
    622             if ( $raw ) {
    623                 $header = 'random';
    624             }
    625             else {
    626                 $headers    =   $this->get_headers();
    627                 $header     =   sprintf(
    628                     $headers[array_rand($headers)]['url'],
    629                     get_template_directory_uri(),
    630                     get_stylesheet_directory_uri()
    631                 );
    632             }
     609        if ( 'random' == $header AND ! $raw ) {
     610            $headers = $this->get_headers();
     611            $header  = sprintf(
     612                $headers[ array_rand( $headers ) ]['url'],
     613                get_template_directory_uri(),
     614                get_stylesheet_directory_uri()
     615            );
    633616        }
    634617
    635618        return apply_filters( 'wpdh_get_active_header', $header );
    636619    }
    637 
    638 } // End of class Obenland_Wp_Display_Header
     620} // End of class Obenland_Wp_Display_Header.
    639621
    640622
    641623/**
    642  * Instantiates the class if current theme supports Custom Headers
     624 * Instantiates the class if current theme supports Custom Headers.
    643625 *
    644  * @author  Konstantin Obenland
    645  * @since   1.2 - 03.05.2011
     626 * @author Konstantin Obenland
     627 * @since  1.2 - 03.05.2011
    646628 *
    647  * @return  void
     629 * @return void
    648630 */
    649631function Obenland_wpdh_instantiate() {
    650632
    651     if ( current_theme_supports('custom-header') ) {
     633    if ( current_theme_supports( 'custom-header' ) )
    652634        new Obenland_Wp_Display_Header;
    653     }
    654635}
    655636add_action( 'init', 'Obenland_wpdh_instantiate', 1 );
Note: See TracChangeset for help on using the changeset viewer.