Plugin Directory

Changeset 1236662


Ignore:
Timestamp:
09/02/2015 09:01:57 PM (10 years ago)
Author:
wpsmith
Message:

Fixed Genesis notification error

File:
1 edited

Legend:

Unmodified
Added
Removed
  • genesis-featured-images/trunk/genesis-featured-images.php

    r1222768 r1236662  
    44Plugin URI: http://www.wpsmith.net/genesis-featured-images
    55Description: Sets a default image for post thumbnails for the Genesis framework.
    6 Version: 0.5.1
     6Version: 0.5.2
    77Author: Travis Smith
    88Author URI: http://www.wpsmith.net/
     
    2727*/
    2828
    29 define( 'GFI_DOMAIN' , 'genesis-featured-images' );
     29define( 'GFI_DOMAIN', 'genesis-featured-images' );
    3030define( 'GFI_PLUGIN_DIR', dirname( __FILE__ ) );
    31 define( 'GFI_URL' , WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)) );
     31define( 'GFI_URL', WP_PLUGIN_URL . '/' . str_replace( basename( __FILE__ ), "", plugin_basename( __FILE__ ) ) );
    3232define( 'GFI_PREFIX', '_gfi_' );
    3333
    3434/* Prevent direct access to the plugin */
    35 if ( !defined( 'ABSPATH' ) ) {
    36     wp_die( __( 'Sorry, you are not allowed to access this page directly.', 'GFI' ) );
     35if ( ! defined( 'ABSPATH' ) ) {
     36    wp_die( __( 'Sorry, you are not allowed to access this page directly.', 'GFI' ) );
    3737}
    3838
     
    4242 * Checks for minimum Genesis Theme version before allowing plugin to activate
    4343 *
    44  * @author Nathan Rice
    45  * @uses gfi_truncate()
    46  * @since 0.1
     44 * @author  Nathan Rice
     45 * @uses    gfi_truncate()
     46 * @since   0.1
    4747 * @version 0.2
    4848 */
    4949function gfi_activation_check() {
    5050
    51     $latest = '2.0';
     51    $latest = '2.0';
    5252
    53     $theme_info = get_theme_data( TEMPLATEPATH . '/style.css' );
     53    $theme_info = wp_get_theme( 'genesis' );
    5454
    55     if ( basename( TEMPLATEPATH ) != 'genesis' ) {
    56         deactivate_plugins( plugin_basename( __FILE__ ) ); // Deactivate ourself
    57         wp_die( sprintf( __( 'Sorry, you can\'t activate unless you have installed and actived %1$sGenesis%2$s or a %3$sGenesis Child Theme%2$s', 'GFI' ), '<a href="http://wpsmith.net/go/genesis">', '</a>', '<a href="http://wpsmith.net/go/spthemes">' ) );
    58     }
     55    if ( is_wp_error() ) {
     56        deactivate_plugins( plugin_basename( __FILE__ ) ); // Deactivate ourself
     57        wp_die( sprintf( __( 'Sorry, you can\'t activate unless you have installed and actived %1$sGenesis%2$s or a %3$sGenesis Child Theme%2$s', 'GFI' ), '<a href="http://wpsmith.net/go/genesis">', '</a>', '<a href="http://wpsmith.net/go/spthemes">' ) );
     58    }
    5959
    60     $version = gfi_truncate( $theme_info['Version'], 3 );
     60    $version = gfi_truncate( $theme_info->get( 'Version' ), 3 );
    6161
    62     if ( version_compare( $version, $latest, '<' ) ) {
    63         deactivate_plugins( plugin_basename( __FILE__ ) ); // Deactivate ourself
    64         wp_die( sprintf( __( 'Sorry, you can\'t activate without %1$sGenesis %2$s%3$s or greater', 'GFI' ), '<a href="http://wpsmith.net/go/genesis">', $latest, '</a>' ) );
    65     }
     62    if ( version_compare( $version, $latest, '<' ) ) {
     63        deactivate_plugins( plugin_basename( __FILE__ ) ); // Deactivate ourself
     64        wp_die( sprintf( __( 'Sorry, you can\'t activate without %1$sGenesis %2$s%3$s or greater', 'GFI' ), '<a href="http://wpsmith.net/go/genesis">', $latest, '</a>' ) );
     65    }
    6666}
    6767
     
    7070 * Used to cutoff a string to a set length if it exceeds the specified length
    7171 *
    72  * @author Nick Croft
    73  * @since 0.1
     72 * @author  Nick Croft
     73 * @since   0.1
    7474 * @version 0.2
     75 *
    7576 * @param string $str Any string that might need to be shortened
    7677 * @param string $length Any whole integer
     78 *
    7779 * @return string
    7880 */
    79 function gfi_truncate( $str, $length=10 ) {
     81function gfi_truncate( $str, $length = 10 ) {
    8082
    81     if ( strlen( $str ) > $length ) {
    82         return substr( $str, 0, $length );
    83     } else {
    84         $res = $str;
    85     }
     83    if ( strlen( $str ) > $length ) {
     84        return substr( $str, 0, $length );
     85    } else {
     86        $res = $str;
     87    }
    8688
    87     return $res;
     89    return $res;
    8890}
    8991
    90 add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ) , 'gfi_action_links' );
     92add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'gfi_action_links' );
    9193/**
    9294 * Add "Settings" link to plugin page
    9395 */
    94 function gfi_action_links($links) {
     96function gfi_action_links( $links ) {
    9597    $gif_settings_link = sprintf( '<a href="%s">%s</a>',
    9698        admin_url( 'admin.php?page=genesis' ),
    9799        __( 'Settings', GFI_DOMAIN ) );
    98100    array_unshift( $links, $gif_settings_link );
     101
    99102    return $links;
    100103}
     
    124127 */
    125128function gfi_remove_do_post_image() {
    126  
    127     global $wp_filter;
    128  
    129     // List of genesis_* functions to be replaced with gfi_* functions.
    130     // We save some bytes and add the ubiquitous 'genesis_' later on.
    131     $functions = array(
    132         'do_post_image',
    133     );
    134  
    135     // Loop through all hooks (yes, stored under the $wp_filter global)
    136     foreach ( $wp_filter as $hook => $priority) {
    137  
    138         // Loop through our array of functions for each hook
    139         foreach( $functions as $function) {
    140  
    141             // has_action returns int for the priority
    142             if ( $priority = has_action( $hook, 'genesis_' . $function ) ) {
    143  
    144                 // If there's a function hooked in, remove the genesis_* function
    145                 // from whichever hook we're looping through at the time.
    146                 remove_action( $hook, 'genesis_' . $function, $priority );
    147  
    148                 // Add a replacement function in at an earlier time.
    149                 add_action( $hook, 'gfi_' . $function, 5 );
    150             }
    151         }
    152     }
     129
     130    global $wp_filter;
     131
     132    // List of genesis_* functions to be replaced with gfi_* functions.
     133    // We save some bytes and add the ubiquitous 'genesis_' later on.
     134    $functions = array(
     135        'do_post_image',
     136    );
     137
     138    // Loop through all hooks (yes, stored under the $wp_filter global)
     139    foreach ( $wp_filter as $hook => $priority ) {
     140
     141        // Loop through our array of functions for each hook
     142        foreach ( $functions as $function ) {
     143
     144            // has_action returns int for the priority
     145            if ( $priority = has_action( $hook, 'genesis_' . $function ) ) {
     146
     147                // If there's a function hooked in, remove the genesis_* function
     148                // from whichever hook we're looping through at the time.
     149                remove_action( $hook, 'genesis_' . $function, $priority );
     150
     151                // Add a replacement function in at an earlier time.
     152                add_action( $hook, 'gfi_' . $function, 5 );
     153            }
     154        }
     155    }
    153156}
    154157
     
    157160    global $prefix;
    158161    if ( ! is_singular() && genesis_get_option( 'content_archive_thumbnail' ) ) {
    159         if ( genesis_get_custom_field( $prefix . 'custom_feat_img' ) )
    160             $img = genesis_get_image( array( 'format' => 'html', 'size' => genesis_get_custom_field( $prefix . 'custom_feat_img' ), 'attr' => array( 'class' => 'alignleft post-image' ) ) );
    161         else
    162             $img = genesis_get_image( array( 'format' => 'html', 'size' => genesis_get_option( 'image_size' ), 'attr' => array( 'class' => 'alignleft post-image' ) ) );
     162        if ( genesis_get_custom_field( $prefix . 'custom_feat_img' ) ) {
     163            $img = genesis_get_image( array(
     164                'format' => 'html',
     165                'size'   => genesis_get_custom_field( $prefix . 'custom_feat_img' ),
     166                'attr'   => array( 'class' => 'alignleft post-image' )
     167            ) );
     168        } else {
     169            $img = genesis_get_image( array(
     170                'format' => 'html',
     171                'size'   => genesis_get_option( 'image_size' ),
     172                'attr'   => array( 'class' => 'alignleft post-image' )
     173            ) );
     174        }
    163175        printf( '<a href="%s" title="%s">%s</a>', get_permalink(), the_title_attribute( 'echo=0' ), $img );
    164176    }
     
    166178
    167179
    168 
    169180?>
Note: See TracChangeset for help on using the changeset viewer.