public static function init($more = array()) { if (self::$options === null) { self::$options = new Slickr_Flickr_DIY_Options(self::OPTIONS_NAME, self::$defaults); } if (count($more) > 0) { self::$options->add_defaults($more); } }
static function upgrade() { Slickr_Flickr_Options::upgrade_options(); //save any new options on plugin update delete_option(self::ACTIVATE_KEY); //delete key so upgrade runs only on activation Slickr_Flickr_Cache::clear_cache(); //clear out the cache }
function fetch_feed() { if ($this->cache_expiry != Slickr_Flickr_Options::get_default('cache_expiry')) { add_filter('wp_feed_cache_transient_lifetime', array(&$this, 'feed_cache_expiry'), 10, 2); } $rss = fetch_feed($this->get_feed_url()); //use WordPress simple pie feed handler if (is_wp_error($rss)) { $this->message = "<p>Error fetching Flickr photos: " . $rss->get_error_message() . "</p>"; $this->error = true; } else { $numitems = $rss->get_item_quantity($this->args["per_page"]); if ($numitems == 0) { $this->message = '<p>No photos available right now.</p><p>Please verify your settings, clear your RSS cache on the Slickr Flickr Admin page and check your <a target="_blank" href="' . $this->get_feed_url() . '">Flickr feed</a></p>'; } else { if ($numitems > $this->args["per_page"] - 5) { $this->pages++; } $rss_items = $rss->get_items(0, $numitems); foreach ($rss_items as $item) { $this->photos[] = new Slickr_Flickr_Photo($item); //feed items and load into object } } } }
function get_meta_form_data($metakey, $prefix, $values) { $content = array(); if (($post_id = Slickr_Flickr_Utils::get_post_id()) && ($meta = Slickr_Flickr_Utils::get_meta($post_id, $metakey))) { $values = Slickr_Flickr_Options::validate_options($values, $meta); } foreach ($values as $key => $val) { $content[$key] = array(); $content[$key]['value'] = $val; $content[$key]['id'] = $prefix . $key; $content[$key]['name'] = $metakey . '[' . $key . ']'; } return $content; }
static function load_galleria_theme() { $options = Slickr_Flickr_Options::get_options(); if ('galleria-latest' != $options['galleria'] || 'dynamic' != $options['galleria_theme_loading'] || count(self::$galleria_themes) == 0) { return; } print <<<LOAD_THEME_START <script type="text/javascript"> //<![CDATA[ jQuery(document).ready(function() { LOAD_THEME_START; foreach (self::$galleria_themes as $theme) { printf('Galleria.loadTheme("%1$s");', self::get_galleria_theme_path($theme)); } print <<<LOAD_THEME_END }) //]]> </script> LOAD_THEME_END; }
function set_options($options) { if (count($options) > 0) { $s = sprintf('jQuery("#%1$s").data("options",%2$s);', $this->id, json_encode($options)); if (Slickr_Flickr_Options::get_option('scripts_in_footer')) { Slickr_Flickr_Public::add_jquery($s); //save for later } else { return sprintf('<script type="text/javascript">%1$s</script>', $s); //output it now } } return ''; }
function save() { check_admin_referer(__CLASS__); $updated = false; $settings = 'Slickr Flickr Settings '; $options = explode(',', stripslashes($_POST['page_options'])); if ($options) { $flickr_options = array(); // retrieve option values from POST variables foreach ($options as $option) { $option = trim($option); $key = substr($option, 7); $val = array_key_exists($option, $_POST) ? trim(stripslashes($_POST[$option])) : ''; switch ($option) { case 'flickr_per_page': $flickr_options[$key] = $this->check_numeric_range($val, 50, 50, 500); break; default: $flickr_options[$key] = $val; } } //end for $updates = Slickr_Flickr_Options::save_options($flickr_options); if ($updates) { $updated = true; $this->add_admin_notice($settings, __('saved', SLICKR_FLICKR_DOMAIN)); } else { $this->add_admin_notice($settings, __('are unchanged since last update', SLICKR_FLICKR_DOMAIN), true); } } else { $this->add_admin_notice($settings, __('not found', SLICKR_FLICKR_DOMAIN), true); } return $updated; }