Plugin Directory

Changeset 757707


Ignore:
Timestamp:
08/17/2013 09:47:11 PM (12 years ago)
Author:
bradmkjr
Message:

moved settings to their own class, also added more settings to build foundation of affiliate links

Location:
iphods-itunes-top-products-rss-widget/trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • iphods-itunes-top-products-rss-widget/trunk/iphods.php

    r757652 r757707  
    22/**
    33 * @package iphods
    4  * @version 8.16
     4 * @version 8.17
    55 */
    66/*
     
    99Description: This plugin is a simple plugin to generate widgets highlighting top mac apps, music, books, ios apps, audiobooks and university courses available on Apple iTunes Store. This is in development, but provides a starting point for experienced developers who want to customize the widget to their needs. At this time, the plugin does not support affiliate links but will in the near future.
    1010Author: Bradford Knowton
    11 Version: 8.16
     11Version: 8.17
    1212Author URI: http://bradknowlton.com/
    1313License: GPLv2 or later
     
    2121define('APPLE_ITUNES_URL','https://itunes.apple.com/');
    2222define('ACTIVATION_URL','http://iphods.com/activation.php');
     23define('IPHODS_TOP_PRODUCTS_WIDGET_VERSION','8.17');
    2324
    2425require(dirname(__FILE__)."/iphods_top_widget.php");
    2526require(dirname(__FILE__)."/iphods_shortcode.php");
     27require(dirname(__FILE__)."/iphods_settings.php");
    2628
    2729class iPhods {
     
    3638       
    3739        add_action( 'widgets_init', array($this,'register_iphods_widget') );
    38         add_action( 'wp_enqueue_scripts', array($this,'register_iphods_css') );
    3940       
    40         if ( is_admin() ){
    41             // add settings admin page
    42             add_action('admin_menu', array($this,'iphods_admin_menu'));
    43             add_action('admin_init', array( $this, 'iphods_page_init' ) );
     41        // only initate css on frontend
     42        if(!is_admin()){
     43            add_action( 'wp_enqueue_scripts', array($this,'register_iphods_css') );
     44        }
    4445       
    45             // add shortcut to settings from plugin page
    46             add_filter('plugin_action_links', array($this,'iphods_plugin_action_links'), 10, 2);
    47         }
     46       
    4847    } 
    4948   
     
    5554            // removed to confirm to site WP repository guidelines
    5655            /*
    57 else{
     56        else{
    5857            // otherwise use md5 hash of url
    5958            wp_remote_post( ACTIVATION_URL, array( 'body' => array( 'op'=> 'activate', 'bu' => md5(get_bloginfo('url')) ) ) ); 
     
    7069        // removed to confirm to site WP repository guidelines
    7170        /*
    72 else{
     71        else{
    7372            // otherwise use md5 hash of url
    7473            wp_remote_post( ACTIVATION_URL, array( 'body' => array( 'op'=> 'deactivate', 'bu' => md5(get_bloginfo('url')) ) ) );
    7574        }
    7675*/
    77        
    78      
    79     }
    80    
    81     public function iphods_admin_menu() {
    82         $page_title = 'iPhods Top Products Settings';
    83         $menu_title = 'iPhods Settings';
    84         $capability = 'manage_options';
    85         $menu_slug = 'iphods-settings';
    86         $function = array($this,'iphods_settings');
    87         add_options_page($page_title, $menu_title, $capability, $menu_slug, $function);
    88     }
    89    
    90     function iphods_settings() {
    91         if (!current_user_can('manage_options')) {
    92             wp_die('You do not have sufficient permissions to access this page.');
    93         }
    94    
    95      // Here is where you could start displaying the HTML needed for the settings
    96      // page, or you could include a file that handles the HTML output for you.
    97        
    98         ?>
    99     <div class="wrap">
    100         <?php screen_icon(); ?>
    101         <h2>iPhods Settings</h2>           
    102         <form method="post" action="options.php">
    103             <?php
    104             // This prints out all hidden setting fields
    105             settings_fields( 'iphods_option_group' );   
    106             do_settings_sections( 'iphods-settings' );
    107         ?>
    108             <?php submit_button(); ?>
    109         </form>
    110     </div>
    111     <?php
    112        
    113     }
    114    
    115         // initialize settings page
    116        
    117         public function iphods_page_init() {
    118                
    119         register_setting( 'iphods_option_group', 'iphods_activation_permission', array( $this, 'check_activation_permissions' ) );
    120         register_setting( 'iphods_option_group', 'iphods_backlink_permission', array( $this, 'check_backlink_permissions' ) );
    121            
    122          add_settings_section(
    123             'iphods_section_id',
    124             'Setting',
    125             array( $this, 'print_section_info' ),
    126             'iphods-settings'
    127         ); 
    128            
    129         add_settings_field(
    130             'iphods_activation_permissions',
    131             __('Permission to notify plugin author of site url during activation of plugin, default is turned OFF','iphods'),
    132             array( $this, 'create_activation_permissions_field' ),
    133             'iphods-settings',
    134             'iphods_section_id'         
    135         ); 
    136        
    137         add_settings_field(
    138             'iphods_backlink_permissions',
    139             __('Permission to display backlink below widget','iphods'),
    140             array( $this, 'create_backlink_permissions_field' ),
    141             'iphods-settings',
    142             'iphods_section_id'         
    143         );     
    144     }
    145    
    146     public function check_activation_permissions( $input ) {
    147         if ( is_numeric( $input['iphods_activation_permissions'] ) ) {
    148             $mid = $input['iphods_activation_permissions'];         
    149             if ( get_option( 'iphods_activation_permissions' ) === FALSE ) {
    150                 add_option( 'iphods_activation_permissions', $mid );
    151             } else {
    152                 update_option( 'iphods_activation_permissions', $mid );
    153             }
    154         } else {
    155             $mid = '';
    156         }
    157         return $mid;
    158     }
    159 
    160     public function check_backlink_permissions( $input ) {
    161         if ( is_numeric( $input['iphods_backlink_permissions'] ) ) {
    162             $mid = $input['iphods_backlink_permissions'];           
    163             if ( get_option( 'iphods_backlink_permissions' ) === FALSE ) {
    164                 add_option( 'iphods_backlink_permissions', $mid );
    165             } else {
    166                 update_option( 'iphods_backlink_permissions', $mid );
    167             }
    168         } else {
    169             $mid = '';
    170         }
    171         return $mid;
    172     }
    173 
    174    
    175     public function print_section_info(){
    176         print 'Enter your setting below:';
    177     }
    178    
    179     public function create_activation_permissions_field(){
    180         ?>
    181         <select id="input_iphods_activation_permissions" name="iphods_activation_permission[iphods_activation_permissions]">
    182             <option value="0" <?php echo (get_option( 'iphods_activation_permissions') != 1 )?'selected="selected"':''; ?>>Disabled</option>
    183             <option value="1" <?php echo (get_option( 'iphods_activation_permissions') == 1 )?'selected="selected"':''; ?>>Enabled</option>
    184         </select><?php
    185        
    186     }
    187    
    188      public function create_backlink_permissions_field(){
    189         ?>
    190         <select type="text" id="input_iphods_backlink_permission" name="iphods_backlink_permission[iphods_backlink_permissions]" >
    191             <option value="0" <?php echo (get_option( 'iphods_backlink_permissions') != 1 )?'selected="selected"':''; ?>>Disabled</option>
    192             <option value="1" <?php echo (get_option( 'iphods_backlink_permissions') == 1 )?'selected="selected"':''; ?>>Enabled</option>
    193         </select><?php
    194     }
    195 
    196     // End of settings code
    197 
    198 
    199     public function iphods_plugin_action_links($links, $file) {
    200         static $this_plugin;
    201    
    202         if (!$this_plugin) {
    203             $this_plugin = plugin_basename(__FILE__);
    204         }
    205    
    206         if ($file == $this_plugin) {
    207             // The "page" query string value must be equal to the slug
    208             // of the Settings admin page we defined earlier, which in
    209             // this case equals "myplugin-settings".
    210             $settings_link = '<a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=iphods-settings">Settings</a>';
    211             array_unshift($links, $settings_link);
    212         }
    213    
    214         return $links;
    215     }
     76  }
     77   
     78   
    21679   
    21780    // register iPhods_Widget widget
  • iphods-itunes-top-products-rss-widget/trunk/readme.txt

    r757652 r757707  
    55Requires at least: 3.2.1
    66Tested up to: 3.6.5
    7 Stable tag: 8.16
     7Stable tag: 8.17
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    9898* added setting for permission to add a backlink after widgets linking back to iPhods.com.
    9999
     100= 8.17 =
     101
     102* added settings to begin to use affiliate commission links in widgets and shortcodes.
     103
    100104== Upgrade Notice ==
    101105
     
    106110Added feed type dropdown to list, may not be compatible with previous widgets
    107111
     112= 8.17 =
     113Added more settings, but should be fully backwards compatible.
     114
    108115== Frequently Asked Questions ==
    109116
    110 1. Why did I write this plugin? I wanted to help others add unique dynamic content easily to their wordpress blog and sidebars.
     1171. Why did I write this plugin?
     118       I wanted to help others add unique dynamic content easily to their wordpress blog and sidebars.
     119       
     1202. Why so many updates?
     121       I'm having fun, adding new features and patching small bugs. I will slow down once I'm happy with the plugin and it does everything I want it to do.
     122
Note: See TracChangeset for help on using the changeset viewer.