Plugin Directory

Changeset 221693


Ignore:
Timestamp:
03/25/2010 08:25:56 PM (16 years ago)
Author:
UnderWordPressure
Message:

Settings Link verlagert

File:
1 edited

Legend:

Unmodified
Added
Removed
  • faviroll/trunk/faviroll.php

    r221691 r221693  
    33Plugin Name: FAVIROLL - FAVIcons for blogROLL
    44Plugin URI: http://www.grobator.de/wordpress-stuff/plugins/faviroll
    5 Description: Locally caches all favicon.ico in PNG format and use this into the blogroll. Native ICO Images are not supported from all browsers/operating systems. <strong><a href="link-manager.php?page=faviroll.php">For Settings jump to: Links &raquo; Faviroll</a></strong>
     5Description: Locally caches all favicon.ico in PNG format and use this into the blogroll. Native ICO Images are not supported from all browsers/operating systems.
    66Author: grobator
    77Version:  0.4.7
     
    6969
    7070
    71 /**
    72  * Add option page
    73  */
    74 function faviroll_options(){
    75 
    76     $message = null;
    77     $removeSettings = isset($_REQUEST['faviroll_remove_settings']);
    78 
    79     // Initialize plugin options if not remove settings is requested
    80     $faviroll = new Faviroll(!$removeSettings);
    81 
    82     $nonce = isset($_REQUEST['_wpnonce']) ? $_REQUEST['_wpnonce'] : null;
    83     if (wp_verify_nonce($nonce, 'my-nonce') ) {
    84 
    85         if($removeSettings) {
    86 
    87             $faviroll->flush(true);
    88             $faviroll->removeSettings();
    89 
    90             $message = 'Plugin settings and cached icons removed.<br /><a href="./plugins.php?plugin_status=active">Now you can deactivate the plugin</a>';
    91 
    92         } else {
    93 
    94             $was_transparency = (get_option('faviroll_transparency') == 'on');
    95 
    96             $defico = trim($_REQUEST['faviroll_default_favicon']);
    97             update_option('faviroll_default_favicon', (empty($defico) ? $faviroll->getFavirollDefaultIcon() : $defico));
    98 
    99             update_option('faviroll_revisit'       , (int) trim($_REQUEST['faviroll_revisit']));
    100             update_option('faviroll_transparency'  , (isset($_REQUEST['faviroll_transparency']) ? 'on' : 'off') );
    101             update_option('faviroll_debug'         , (isset($_REQUEST['faviroll_debug']) ? 'on' : 'off') );
    102             update_option('faviroll_use_stylesheet', (isset($_REQUEST['faviroll_use_stylesheet']) ? 'on' : 'off') );
    103 
    104             $message = 'Settings updated';
     71#################
     72#  Admin Area   #
     73#################
     74if (is_admin()) {
     75
     76    /**
     77     * Add Settings link to plugin page
     78     * @param unknown_type $links
     79     */
     80    function faviroll_addConfigureLink( $links ) {
     81        $settings_link = '<a href="link-manager.php?page='.basename(__FILE__).'">'. __('Settings').'</a>';
     82        array_unshift( $links, $settings_link );
     83        return $links;
     84    }
     85    $plugin = plugin_basename(__FILE__);
     86    add_filter("plugin_action_links_$plugin", 'faviroll_addConfigureLink' );
     87
     88    /**
     89     * Register Faviroll menu in general options menu
     90     */
     91    function faviroll_menu() {
     92        add_submenu_page('link-manager.php', __('FaviRoll', 'faviroll'), __('FaviRoll', 'faviroll'), 8, basename(__FILE__), 'faviroll_options');
     93    }
     94    add_action('admin_menu', 'faviroll_menu');
     95
     96
     97    /**
     98     * Add option page
     99     */
     100    function faviroll_options(){
     101
     102        $message = null;
     103        $removeSettings = isset($_REQUEST['faviroll_remove_settings']);
     104
     105        // Initialize plugin options if not remove settings is requested
     106        $faviroll = new Faviroll(!$removeSettings);
     107
     108        $nonce = isset($_REQUEST['_wpnonce']) ? $_REQUEST['_wpnonce'] : null;
     109        if (wp_verify_nonce($nonce, 'my-nonce') ) {
     110
     111            if($removeSettings) {
     112
     113                $faviroll->flush(true);
     114                $faviroll->removeSettings();
     115
     116                $message = 'Plugin settings and cached icons removed.<br /><a href="./plugins.php?plugin_status=active">Now you can deactivate the plugin</a>';
     117
     118            } else {
     119
     120                $was_transparency = (get_option('faviroll_transparency') == 'on');
     121
     122                $defico = trim($_REQUEST['faviroll_default_favicon']);
     123                update_option('faviroll_default_favicon', (empty($defico) ? $faviroll->getFavirollDefaultIcon() : $defico));
     124
     125                update_option('faviroll_revisit'       , (int) trim($_REQUEST['faviroll_revisit']));
     126                update_option('faviroll_transparency'  , (isset($_REQUEST['faviroll_transparency']) ? 'on' : 'off') );
     127                update_option('faviroll_debug'         , (isset($_REQUEST['faviroll_debug']) ? 'on' : 'off') );
     128                update_option('faviroll_use_stylesheet', (isset($_REQUEST['faviroll_use_stylesheet']) ? 'on' : 'off') );
     129
     130                $message = 'Settings updated';
     131            }
    105132        }
    106     }
    107 
    108     // create nonce
    109     $nonce = wp_create_nonce('my-nonce');
    110 
    111     $default_favicon = get_option('faviroll_default_favicon');
    112     $revisit = ($removeSettings) ? null : (int) get_option('faviroll_revisit');
    113 
    114     $is_transparency = (get_option('faviroll_transparency') == 'on');
    115     $is_debugMode    = (get_option('faviroll_debug') == 'on');
    116     $use_stylesheet  = (get_option('faviroll_use_stylesheet') == 'on');
    117 
    118     if (!$removeSettings) {
    119 
    120         if (isset($was_transparency) && ($is_transparency != $was_transparency)) {
    121             $message = 'Transparency switched';
    122             $_REQUEST['faviroll_renew_icons'] = 'true';
     133
     134        // create nonce
     135        $nonce = wp_create_nonce('my-nonce');
     136
     137        $default_favicon = get_option('faviroll_default_favicon');
     138        $revisit = ($removeSettings) ? null : (int) get_option('faviroll_revisit');
     139
     140        $is_transparency = (get_option('faviroll_transparency') == 'on');
     141        $is_debugMode    = (get_option('faviroll_debug') == 'on');
     142        $use_stylesheet  = (get_option('faviroll_use_stylesheet') == 'on');
     143
     144        if (!$removeSettings) {
     145
     146            if (isset($was_transparency) && ($is_transparency != $was_transparency)) {
     147                $message = 'Transparency switched';
     148                $_REQUEST['faviroll_renew_icons'] = 'true';
     149            }
     150            if(isset($_REQUEST['faviroll_renew_icons']))
     151            $faviroll->reset();
     152
    123153        }
    124         if(isset($_REQUEST['faviroll_renew_icons']))
    125             $faviroll->reset();
    126 
    127     }
    128 
    129     if (!is_null($message))
     154
     155        if (!is_null($message))
    130156        $message = '<div class="updated fade below-h2" id="message"><p>'.$message.'</p></div>';
    131157
    132     echo '
     158        echo '
    133159 <div class="wrap">
    134160  <div id="icon-options-general" class="icon32"><br /></div>
     
    176202     </tr>
    177203';
    178 /*
    179                 <tr>
    180                     <td title="Write debug informations as comments into the HTML code">Debug mode:</td>
    181                 <td><input type="checkbox" name="faviroll_debug" value="true" '.($is_debugMode ? ' checked="checked"' : null).' /> &nbsp; ( just for Developers, normally switch off )
    182                 </tr>
    183 */
    184     echo '     <tr>
     204        /*
     205         <tr>
     206         <td title="Write debug informations as comments into the HTML code">Debug mode:</td>
     207        <td><input type="checkbox" name="faviroll_debug" value="true" '.($is_debugMode ? ' checked="checked"' : null).' /> &nbsp; ( just for Developers, normally switch off )
     208         </tr>
     209         */
     210        echo '     <tr>
    185211      <td class="submit"><input type="submit" name="submit_button" value="Submit" /><input type="hidden" name="_wpnonce" value="'.$nonce.'" /></td>
    186212     </tr>
     
    190216';
    191217
    192         ob_flush();
    193         flush();
    194 }
    195 
    196 
    197 /**
    198  * Register Faviroll menu in general options menu
    199  */
    200 function faviroll_menu() {
    201     add_submenu_page('link-manager.php', __('FaviRoll', 'faviroll'), __('FaviRoll', 'faviroll'), 8, basename(__FILE__), 'faviroll_options');
    202 }
    203 add_action('admin_menu', 'faviroll_menu');
    204 
    205 
    206 /**
    207  * Register Enqueue CSS, if option is activated in Faviroll-Settings
    208  */
    209 if (get_option('faviroll_use_stylesheet') == 'on') {
    210     function faviroll_enqueue_scripts() {
    211         wp_enqueue_style('faviroll', WP_PLUGIN_URL.'/faviroll/style.css', false, false, 'all');
    212     }
    213     add_action('wp_enqueue_scripts', 'faviroll_enqueue_scripts');
    214 }
    215 
    216 /**
    217  * Actions on plugin activation
    218  */
    219 function faviroll_activate() {
    220     $faviroll = new Faviroll();
    221     return $faviroll->patchPlugin('wp-render-blogroll-links',true);
    222 }
    223 register_activation_hook(__FILE__, 'faviroll_activate');
    224 
    225 
    226 /**
    227  * Actions on plugin deactivation
    228  */
    229 function faviroll_deactivate() {
    230     $faviroll = new Faviroll();
    231     return $faviroll->patchPlugin('wp-render-blogroll-links',false);
    232 }
    233 register_deactivation_hook(__FILE__, 'faviroll_deactivate');
     218    }
     219
     220
     221    /**
     222     * Register Enqueue CSS, if option is activated in Faviroll-Settings
     223     */
     224    if (get_option('faviroll_use_stylesheet') == 'on') {
     225        function faviroll_enqueue_scripts() {
     226            wp_enqueue_style('faviroll', WP_PLUGIN_URL.'/faviroll/style.css', false, false, 'all');
     227        }
     228        add_action('wp_enqueue_scripts', 'faviroll_enqueue_scripts');
     229    }
     230
     231    /**
     232     * Actions on plugin activation
     233     */
     234    function faviroll_activate() {
     235        $faviroll = new Faviroll();
     236        return $faviroll->patchPlugin('wp-render-blogroll-links',true);
     237    }
     238    register_activation_hook(__FILE__, 'faviroll_activate');
     239
     240    /**
     241     * Actions on plugin deactivation
     242     */
     243    function faviroll_deactivate() {
     244        $faviroll = new Faviroll();
     245        return $faviroll->patchPlugin('wp-render-blogroll-links',false);
     246    }
     247    register_deactivation_hook(__FILE__, 'faviroll_deactivate');
     248
     249}
    234250
    235251/* eof */
Note: See TracChangeset for help on using the changeset viewer.