Plugin Directory

Changeset 849217


Ignore:
Timestamp:
02/01/2014 01:36:57 AM (12 years ago)
Author:
eightface
Message:

Renaming flickrrss-settingspage.php to admin.php and adding early work on version 6.0

Location:
flickr-rss/trunk
Files:
3 edited
1 moved

Legend:

Unmodified
Added
Removed
  • flickr-rss/trunk

    • Property svn:ignore set to
      .git
  • flickr-rss/trunk/flickrrss.php

    r472311 r849217  
    33Plugin Name: flickrRSS
    44Plugin URI: http://wordpress.org/extend/plugins/flickr-rss/
    5 Description: Allows you to integrate the photos from a Flickr RSS feed into your site.
    6 Version: 5.2
     5Description: Allows you to easily integrate Flickr photos into your site's templates.
     6Version: 6.0
    77License: GPL
    88Author: Dave Kellam
     
    1010*/
    1111
    12 if (!class_exists('flickrRSS')) {
     12if ( ! class_exists( 'flickrRSS' ) ) {
     13
    1314    class flickrRSS {
    1415   
    15         function flickrRSS() {
    16             $this->version = "5.2";
    17         }
    18    
    19         function get_and_delete_option($setting) { $v = get_option($setting); delete_option($setting); return $v; }
    20        
    21         function setupActivation() {
    22        
    23             // check for previously installed version 4.0 or older
    24             if (get_option('flickrRSS_flickrid')) {
    25                 // let's port previous settings and delete them
    26                 $settings = $this->fixArguments(array(
    27                     get_and_delete_option('flickrRSS_display_numitems'),
    28                     get_and_delete_option('flickrRSS_display_type'),
    29                     get_and_delete_option('flickrRSS_tags'),
    30                     get_and_delete_option('flickrRSS_display_imagesize'),
    31                     get_and_delete_option('flickrRSS_before'),
    32                     get_and_delete_option('flickrRSS_after'),
    33                     get_and_delete_option('flickrRSS_flickrid'),
    34                     get_and_delete_option('flickrRSS_set'),
    35                     get_and_delete_option('flickrRSS_use_image_cache'),
    36                     get_and_delete_option('flickrRSS_image_cache_uri'),
    37                     get_and_delete_option('flickrRSS_image_cache_dest')
    38                 ));
    39                 update_option('flickrRSS_settings', $settings);
    40             }
    41        
    42             // update version number
    43             if (get_option('flickrRSS_version') != $this->version)
    44                 update_option('flickrRSS_version', $this->version);
    45         }
    46    
    47         function fixArguments($args) {
     16        function fixArguments( $args ) {
    4817            $settings = array();
    4918       
    50             if (isset($args[0])) $settings['num_items'] = $args[0];
    51             if (isset($args[1])) $settings['type'] = $args[1];
    52             if (isset($args[2])) $settings['tags'] = $args[2];
    53             if (isset($args[6])) $settings['id'] = $args[6];
    54             if (isset($args[7])) $settings['set'] = $args[7];
    55             if (isset($args[8])) $settings['do_cache'] = $args[8];
    56             if (isset($args[9])) $settings['cache_uri'] = $args[9];
    57             if (isset($args[10])) $settings['cache_path'] = $args[10];
     19            if ( isset( $args[0] ) ) $settings['num_items'] = $args[0];
     20            if ( isset( $args[1] ) ) $settings['type'] = $args[1];
     21            if ( isset( $args[2] ) ) $settings['tags'] = $args[2];
     22            if ( isset( $args[6] ) ) $settings['id'] = $args[6];
     23            if ( isset( $args[7] ) ) $settings['set'] = $args[7];
     24            if ( isset( $args[8] ) ) $settings['do_cache'] = $args[8];
     25            if ( isset( $args[9] ) ) $settings['cache_uri'] = $args[9];
     26            if ( isset( $args[10] ) ) $settings['cache_path'] = $args[10];
    5827   
    5928            $imagesize = $args[3]?$args[3]:"square";
     
    6736   
    6837        function getSettings() {
    69            
    70             if (!get_option('flickrRSS_settings')) $this->setupActivation();
    7138           
    7239            $settings = array(
     
    10976        }
    11077   
    111         function getRSS($settings) {
    112             if (!function_exists('MagpieRSS')) {
    113                 // Check if another plugin is using RSS, may not work
    114                 include_once (ABSPATH . WPINC . '/rss.php');
    115                 error_reporting(E_ERROR);
    116             }
    117             // get the feeds
     78        function getRSS( $settings ) {
     79            // Construct feed URL
    11880            if ($settings['type'] == "user") { $rss_url = 'http://api.flickr.com/services/feeds/photos_public.gne?id=' . $settings['id'] . '&tags=' . $settings['tags'] . '&format=rss_200'; }
    11981            elseif ($settings['type'] == "favorite") { $rss_url = 'http://api.flickr.com/services/feeds/photos_faves.gne?id=' . $settings['id'] . '&format=rss_200'; }
     
    12587                die();
    12688            }
    127             # get rss file
    128             return @fetch_rss($rss_url);
     89            // Retrieve feed
     90            return fetch_feed( $rss_url );
    12991        }
    13092   
     
    223185   
    224186        function setupSettingsPage() {
    225             if (function_exists('add_options_page')) {
    226                 add_options_page('flickrRSS Settings', 'flickrRSS', 8, basename(__FILE__), array(&$this, 'printSettingsPage'));
     187            if ( function_exists( 'add_options_page') ) {
     188                add_options_page( 'flickrRSS Settings', 'flickrRSS', 'manage_options', 'flickrrss-settingspage.php', array( &$this, 'printSettingsPage' ) );
    227189            }
    228190        }
    229191   
    230192        function printSettingsPage() {
     193           
    231194            $settings = $this->getSettings();
    232             if (isset($_POST['save_flickrRSS_settings'])) {
    233                 foreach ($settings as $name => $value) {
     195
     196            if ( isset( $_POST['save_flickrRSS_settings'] ) ) {
     197               
     198                foreach ( $settings as $name => $value ) {
    234199                    $settings[$name] = $_POST['flickrRSS_'.$name];
    235200                }
     201
    236202                $settings['cache_sizes'] = array();
    237                 foreach (array("small", "square", "thumbnail", "medium", "large") as $size) {
     203               
     204                foreach ( array("small", "square", "thumbnail", "medium", "large") as $size ) {
    238205                    if ($_POST['flickrRSS_cache_'.$size]) $settings['cache_sizes'][] = $size;
    239206                }
    240                 update_option('flickrRSS_settings', $settings);
     207               
     208                update_option( 'flickrRSS_settings', $settings );
     209               
    241210                echo '<div class="updated"><p>flickrRSS settings saved!</p></div>';
    242211            }
    243             if (isset($_POST['reset_flickrRSS_settings'])) {
    244                 delete_option('flickrRSS_settings');
     212
     213            if ( isset( $_POST['reset_flickrRSS_settings'] ) ) {
     214                delete_option( 'flickrRSS_settings' );
    245215                echo '<div class="updated"><p>flickrRSS settings restored to default!</p></div>';
    246216            }
    247             include ("flickrrss-settingspage.php");
     217
     218            // add setting page
     219            include ( 'flickrrss-settingspage.php' );
     220
    248221        }
    249222    }
    250223}
    251224$flickrRSS = new flickrRSS();
    252 add_action( 'admin_menu', array(&$flickrRSS, 'setupSettingsPage') );
    253 add_action( 'plugins_loaded', array(&$flickrRSS, 'setupWidget') );
    254 register_activation_hook( __FILE__, array( &$flickrRSS, 'setupActivation' ));
    255 
    256 function get_flickrRSS($settings = array()) {
     225add_action( 'admin_menu', array( &$flickrRSS, 'setupSettingsPage' ) );
     226add_action( 'plugins_loaded', array( &$flickrRSS, 'setupWidget' ) );
     227
     228/**
     229 * Main function to call flickrRSS in your templates
     230 */
     231function get_flickrRSS( $settings = array() ) {
    257232    global $flickrRSS;
    258     if (func_num_args() > 1 ) {
     233
     234    if ( func_num_args() > 1 ) {
    259235        $old_array = func_get_args();
    260         $flickrRSS->printGallery($flickrRSS->fixArguments($old_array));
     236        $flickrRSS->printGallery( $flickrRSS->fixArguments( $old_array ) );
    261237    }
    262     else $flickrRSS->printGallery($settings);
     238    else $flickrRSS->printGallery( $settings );
    263239}
    264 
    265 ?>
  • flickr-rss/trunk/readme.txt

    r472311 r849217  
    11=== flickrRSS ===
    2 Contributors: eightface, stefano.verna
    3 Tags: flickr, photos, images, sidebar, widget, rss
    4 Requires at least: 3.0
    5 Tested up to: 3.2.1
     2Contributors: eightface
     3Tags: flickr, photos, images, sidebar, widget
     4Requires at least: 3.5
     5Tested up to: 3.8.1
    66Stable tag: 5.2
    77
     
    8181== Plugin History ==
    8282
    83 **Latest Release:** December 8, 2011
     83**Latest Release:** January 31, 2014
    8484
     85* 6.0 - Primary development on GitHub, see repo there for details. Removing old functionality and revamping plugin.
    8586* 5.2 - Fixed image cache server name change, also had a nested function for some reason which was messing up multiple instances for people
    8687* 5.1 - Minor interface tweaks to avoid confusion
Note: See TracChangeset for help on using the changeset viewer.