WordPress.org

Plugin Directory

Changeset 606352


Ignore:
Timestamp:
10/01/12 02:27:51 (19 months ago)
Author:
japh
Message:

Feature parity with WordPress 3.5

Location:
favorite-plugins/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • favorite-plugins/trunk/favorite-plugins.php

    r604205 r606352  
    44Plugin URI: http://japh.wordpress.com/plugins/favorite-plugins 
    55Description: Quickly and easily access and install your favorited plugins from WordPress.org, right from your dashboard. 
    6 Version: 0.5 
     6Version: 0.6 
    77Author: Japh 
    88Author URI: http://japh.wordpress.com 
     
    3636 * @copyright 2012 Japh 
    3737 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt GPL2 
    38  * @version 0.5 
     38 * @version 0.6 
    3939 * @link http://japh.wordpress.com/plugins/favorite-plugins 
    4040 * @since 0.1 
     
    6262 * @copyright 2012 Japh 
    6363 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt GPL2 
    64  * @version 0.5 
     64 * @version 0.6 
    6565 * @since 0.1 
    6666 */ 
    6767class Japh_Favorite_Plugins { 
    6868 
    69     public $version = '0.5'; 
     69    public $version = '0.6'; 
    7070    public $username = null; 
    7171 
     
    7777    function __construct() { 
    7878 
    79         $current_version = get_option( 'jfp_favourite_plugins_version' ); 
    80  
    81         if ( $current_version != $this->version ) { 
    82             update_option( 'jfp_favourite_plugins_version', $this->do_update( $current_version ) ); 
     79        if ( (float) get_bloginfo( 'version' ) < 3.5 ) { 
     80 
     81            $current_version = get_option( 'jfp_favourite_plugins_version' ); 
     82 
     83            if ( $current_version != $this->version ) { 
     84                update_option( 'jfp_favourite_plugins_version', $this->do_update( $current_version ) ); 
     85            } 
     86 
     87            add_action( 'init', array( &$this, 'textdomain' ) ); 
     88            add_filter( 'install_plugins_tabs', array( &$this, 'add_favorites_tab' ) ); 
     89 
     90            add_action( 'install_plugins_pre_favorites', array( &$this, 'do_favorites_tab' ) ); 
     91            add_action( 'install_plugins_favorites', array( &$this, 'install_plugins_favorites' ), 10, 1 ); 
     92            add_action( 'install_plugins_favorites', 'display_plugins_table'); 
     93 
     94            $this->username = get_user_option( 'wporg_favorites' ); 
    8395        } 
    84  
    85         add_action( 'init', array( &$this, 'textdomain' ) ); 
    86         add_filter( 'install_plugins_tabs', array( &$this, 'add_favorites_tab' ) ); 
    87  
    88         add_action( 'install_plugins_pre_favorites', array( &$this, 'do_favorites_tab' ) ); 
    89         add_action( 'install_plugins_favorites', array( &$this, 'install_plugins_favorites' ), 10, 1 ); 
    90         add_action( 'install_plugins_favorites', 'display_plugins_table'); 
    91  
    92         $this->username = get_option( 'jfp_favorite_user' ); 
    93  
    9496    } 
    9597 
     
    101103    function activate() { 
    102104 
    103         add_option( 'jfp_favorite_user' ); 
     105        // Nothing to do... 
    104106 
    105107    } 
     
    112114    function deactivate() { 
    113115 
    114         delete_option( 'jfp_favorite_user' ); 
     116        // Nothing to do... 
    115117 
    116118    } 
     
    147149 
    148150        $this->username = isset( $_REQUEST['user'] ) ? stripslashes( $_REQUEST['user'] ) : $this->username; 
    149         update_option( 'jfp_favorite_user', $this->username ); 
    150  
    151         $args = array( 'user' => $this->username ); 
    152         $api = plugins_api( 'query_plugins', $args ); 
    153  
    154         $wp_list_table->items = $api->plugins; 
    155         $wp_list_table->set_pagination_args( 
    156             array( 
    157                 'total_items' => $api->info['results'], 
    158                 'per_page' => 10, 
    159             ) 
    160         ); 
     151 
     152        if ( $this->username ) { 
     153            $args = array( 'user' => $this->username ); 
     154            update_user_meta( get_current_user_id(), 'wporg_favorites', $this->username ); 
     155 
     156            $api = plugins_api( 'query_plugins', $args ); 
     157 
     158            $wp_list_table->items = $api->plugins; 
     159            $wp_list_table->set_pagination_args( 
     160                array( 
     161                    'total_items' => $api->info['results'], 
     162                    'per_page' => 24, 
     163                ) 
     164            ); 
     165        } else { 
     166            $args = false; 
     167        } 
    161168    } 
    162169 
     
    166173     * Props @Otto42 : http://core.trac.wordpress.org/ticket/22002 
    167174     * Any code here from Otto is used with permission. 
     175     * 
     176     * Updated for feature parity with WordPress 3.5 
    168177     * 
    169178     * @since 0.5 
     
    174183        $this->username = isset( $_REQUEST['user'] ) ? stripslashes( $_REQUEST['user'] ) : $this->username; 
    175184        ?> 
    176             <h4><?php _e( 'Find Favorite Plugins for a WordPress.org username:' ); ?></h4> 
    177             <form method="post" enctype="multipart/form-data" action="<?php echo self_admin_url( 'plugin-install.php?tab=favorites' ); ?>"> 
    178                 <label class="screen-reader-text" for="user"><?php _e( 'WordPress.org username' ); ?></label> 
    179                 <input type="search" id="user" name="user" value="<?php echo esc_attr( $this->username ); ?>" /> 
    180                 <input type="submit" class="button" value="<?php esc_attr_e( 'Find Favorites' ); ?>" /> 
     185            <p class="install-help"><?php _e( 'If you have marked plugins as favorites on WordPress.org, you can browse them here.' ); ?></p> 
     186            <form method="get" action=""> 
     187                <input type="hidden" name="tab" value="favorites" /> 
     188                <p> 
     189                    <label for="user"><?php _e( 'Your WordPress.org username:' ); ?></label> 
     190                    <input type="search" id="user" name="user" value="<?php echo esc_attr( $this->username ); ?>" /> 
     191                    <input type="submit" class="button" value="<?php esc_attr_e( 'Get Favorites' ); ?>" /> 
     192                </p> 
    181193            </form> 
    182194        <?php 
     
    212224            case '0.1': 
    213225                delete_option( 'jfp_favorite_plugins' ); 
     226            case '0.5': 
     227                update_user_meta( get_current_user_id(), 'wporg_favorites', get_option( 'jfp_favorite_user' ) ); 
     228                delete_option( 'jfp_favorite_user' ); 
    214229        } 
    215230 
     
    219234} 
    220235 
    221 // Kick everything into action... 
    222 $japh_favorite_plugins = new Japh_Favorite_Plugins(); 
     236function jfp_execute() { 
     237    // Kick everything into action... 
     238    $japh_favorite_plugins = new Japh_Favorite_Plugins(); 
     239} 
     240add_action( 'admin_init', 'jfp_execute' ); 
  • favorite-plugins/trunk/readme.txt

    r604234 r606352  
    44Requires at least: 3.4 
    55Tested up to: 3.4.2 
    6 Stable tag: 0.5 
     6Stable tag: 0.6 
    77License: GPLv2 or later 
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    4444== Changelog == 
    4545 
     46= 0.6 = 
     47* Moved screenshot to assets directory to make plugin download smaller 
     48* Removed vestigial /lib directory 
     49* Implementing feature parity with upcoming Favorites tab in WordPress 3.5 
     50* Now uses same meta data as WordPress 3.5 will, to save you time 
     51* Added redundancy check for WordPress 3.5, plugin will stop execution to avoid conflicts 
     52 
    4653= 0.5 = 
    4754* Switched to utilise the new Favourites API. Props @Otto42. 
Note: See TracChangeset for help on using the changeset viewer.