Check
' target='_blank'>afg.css to see existing classes and properties for gallery which you can redefine here. Note that there is no validation applied to CSS Code entered here, so make sure that you enter valid CSS.
diff --git a/afg_libs.php b/afg_libs.php
index 231605f..b9a2a01 100644
--- a/afg_libs.php
+++ b/afg_libs.php
@@ -1,9 +1,9 @@
'Default',
@@ -110,6 +110,33 @@
'White' => 'Black',
);
+$afg_cache_refresh_interval_map = array(
+ '6h' => '6 Hours',
+ '12h' => '12 Hours',
+ '1d' => '1 Day',
+ '3d' => '3 Days',
+ '1w' => '1 Week',
+);
+
+function afg_get_cache_refresh_interval_secs ($interval)
+{
+ if ($interval == '6h') {
+ return 6 * 60 * 60;
+ }
+ else if ($interval == '12h') {
+ return 12 * 60 * 60;
+ }
+ else if ($interval == '1d') {
+ return 24 * 60 * 60;
+ }
+ else if ($interval == '3d') {
+ return 3 * 24 * 60 * 60;
+ }
+ else if ($interval == '1w') {
+ return 7 * 24 * 60 * 60;
+ }
+}
+
function afg_get_sets_groups_galleries (&$photosets_map, &$groups_map, &$galleries_map, $user_id) {
global $pf;
@@ -164,9 +191,8 @@ function create_afgFlickr_obj() {
$pf->setToken(get_option('afg_flickr_token'));
}
-function afg_error() {
- global $pf;
- return "
Awesome Flickr Gallery Error - $pf->error_msg
";
+function afg_error($error_msg) {
+ return "
Awesome Flickr Gallery Error - $error_msg
";
}
function date_taken_cmp_newest($a, $b) {
diff --git a/afg_update.php b/afg_update.php
index b692bec..a8ea427 100644
--- a/afg_update.php
+++ b/afg_update.php
@@ -8,7 +8,7 @@
// TEMP: Show which variables are being requested when query plugin API
add_filter('plugins_api_result', 'afg_aaa_result', 10, 3);
function afg_aaa_result($res, $action, $args) {
- print_r($res);
+ //print_r($res);
return $res;
}
}
@@ -30,6 +30,35 @@ function afg_ssl_verify($args, $url) {
return $args;
}
+/**
+ * Access this plugin’s working instance
+ *
+ * @wp-hook plugins_loaded
+ * @return object of this class
+ */
+add_filter( 'upgrader_source_selection', 'afg_rename_github_zip', 1, 3);
+
+/**
+ * Removes the prefix "-master" when updating from GitHub zip files
+ *
+ * See: https://github.com/YahnisElsts/plugin-update-checker/issues/1
+ *
+ * @param string $source
+ * @param string $remote_source
+ * @param object $thiz
+ * @return string
+ */
+function afg_rename_github_zip( $source, $remote_source, $thiz )
+{
+ if( strpos( $source, 'awesome-flickr-gallery-plugin') === false )
+ return $source;
+
+ $path_parts = pathinfo( $source );
+ $newsource = trailingslashit( $path_parts['dirname'] ) . trailingslashit( 'awesome-flickr-gallery-plugin' );
+ rename( $source, $newsource );
+ return $newsource;
+}
+
function afg_check_for_plugin_update($checked_data) {
global $api_url, $plugin_slug, $plugin_slug_file, $package_type;
diff --git a/index.php b/index.php
index e8cd729..7f24b85 100644
--- a/index.php
+++ b/index.php
@@ -3,7 +3,7 @@
Plugin Name: Awesome Flickr Gallery
Plugin URI: http://www.ronakg.com/projects/awesome-flickr-gallery-wordpress-plugin/
Description: Awesome Flickr Gallery is a simple, fast and light plugin to create a gallery of your Flickr photos on your WordPress enabled website. This plugin aims at providing a simple yet customizable way to create stunning Flickr gallery.
- Version: 3.5.0
+ Version: 3.5.1
Author: Ronak Gandhi
Author URI: http://www.ronakg.com
License: GPL2
@@ -159,6 +159,10 @@ function afg_display_gallery($atts) {
else $url_separator = '&';
$galleries = get_option('afg_galleries');
+ if (!isset($galleries) || array_key_exists($id, $galleries) == false) {
+ return afg_error("Gallery ID {$id} has been either deleted or not configured.");
+ }
+
$gallery = $galleries[$id];
$api_key = get_option('afg_api_key');
@@ -176,6 +180,7 @@ function afg_display_gallery($atts) {
$credit_note = get_afg_option($gallery, 'credit_note');
$gallery_width = get_afg_option($gallery, 'width');
$pagination = get_afg_option($gallery, 'pagination');
+ $cache_refresh_interval = get_afg_option($gallery, 'cache_refresh_interval');
if ($photo_size == 'custom') {
$custom_size = get_afg_option($gallery, 'custom_size');
@@ -232,84 +237,92 @@ function afg_display_gallery($atts) {
$extras = 'url_l, description, date_upload, date_taken, owner_name';
- if (isset($photoset_id) && $photoset_id) {
- $rsp_obj = $pf->photosets_getInfo($photoset_id);
- if ($pf->error_code) return afg_error();
- $total_photos = $rsp_obj['photos'];
- }
- else if (isset($gallery_id) && $gallery_id) {
- $rsp_obj = $pf->galleries_getInfo($gallery_id);
- if ($pf->error_code) return afg_error();
- $total_photos = $rsp_obj['gallery']['count_photos']['_content'];
- }
- else if (isset($group_id) && $group_id) {
- $rsp_obj = $pf->groups_pools_getPhotos($group_id, NULL, NULL, NULL, NULL, 1, 1);
- if ($pf->error_code) return afg_error();
- $total_photos = $rsp_obj['photos']['total'];
- if ($total_photos > 500) $total_photos = 500;
- }
- else if (isset($tags) && $tags) {
- $rsp_obj = $pf->photos_search(array('user_id'=>$user_id, 'tags'=>$tags, 'extras'=>$extras, 'per_page'=>1));
- if ($pf->error_code) return afg_error();
- $total_photos = $rsp_obj['photos']['total'];
- }
- else if (isset($popular) && $popular) {
- $rsp_obj = $pf->photos_search(array('user_id'=>$user_id, 'sort'=>'interestingness-desc', 'extras'=>$extras, 'per_page'=>1));
- if ($pf->error_code) return afg_error();
- $total_photos = $rsp_obj['photos']['total'];
+ if (!DEBUG) {
+ $photos = get_transient('afg_id_' . $id);
}
- else {
- $rsp_obj = $pf->people_getInfo($user_id);
- if ($pf->error_code) return afg_error();
- $total_photos = $rsp_obj['photos']['count']['_content'];
- }
-
- $photos = get_transient('afg_id_' . $id);
- if (DEBUG)
- $photos = NULL;
- if ($photos == false || $total_photos != count($photos)) {
+ if ($photos === false) {
$photos = array();
+
+ if (isset($photoset_id) && $photoset_id) {
+ $rsp_obj = $pf->photosets_getInfo($photoset_id);
+ if ($pf->error_code) return afg_error($pf->error_msg);
+ $total_photos = $rsp_obj['photos'];
+ }
+ else if (isset($gallery_id) && $gallery_id) {
+ $rsp_obj = $pf->galleries_getInfo($gallery_id);
+ if ($pf->error_code) return afg_error($pf->error_msg);
+ $total_photos = $rsp_obj['gallery']['count_photos']['_content'];
+ }
+ else if (isset($group_id) && $group_id) {
+ $rsp_obj = $pf->groups_pools_getPhotos($group_id, NULL, NULL, NULL, NULL, 1, 1);
+ if ($pf->error_code) return afg_error($pf->error_msg);
+ $total_photos = $rsp_obj['photos']['total'];
+ if ($total_photos > 500) $total_photos = 500;
+ }
+ else if (isset($tags) && $tags) {
+ $rsp_obj = $pf->photos_search(array('user_id'=>$user_id, 'tags'=>$tags, 'extras'=>$extras, 'per_page'=>1));
+ if ($pf->error_code) return afg_error($pf->error_msg);
+ $total_photos = $rsp_obj['photos']['total'];
+ }
+ else if (isset($popular) && $popular) {
+ $rsp_obj = $pf->photos_search(array('user_id'=>$user_id, 'sort'=>'interestingness-desc', 'extras'=>$extras, 'per_page'=>1));
+ if ($pf->error_code) return afg_error($pf->error_msg);
+ $total_photos = $rsp_obj['photos']['total'];
+ }
+ else {
+ $rsp_obj = $pf->people_getInfo($user_id);
+ if ($pf->error_code) return afg_error($pf->error_msg);
+ $total_photos = $rsp_obj['photos']['count']['_content'];
+ }
+
for($i=1; $i<($total_photos/500)+1; $i++) {
if ($photoset_id) {
$flickr_api = 'photoset';
$rsp_obj_total = $pf->photosets_getPhotos($photoset_id, $extras, NULL, 500, $i);
- if ($pf->error_code) return afg_error();
+ if ($pf->error_code) return afg_error($pf->error_msg);
}
else if ($gallery_id) {
$flickr_api = 'photos';
$rsp_obj_total = $pf->galleries_getPhotos($gallery_id, $extras, 500, $i);
- if ($pf->error_code) return afg_error();
+ if ($pf->error_code) return afg_error($pf->error_msg);
}
else if ($group_id) {
$flickr_api = 'photos';
$rsp_obj_total = $pf->groups_pools_getPhotos($group_id, NULL, NULL, NULL, $extras, 500, $i);
- if ($pf->error_code) return afg_error();
+ if ($pf->error_code) return afg_error($pf->error_msg);
}
else if ($tags) {
$flickr_api = 'photos';
$rsp_obj_total = $pf->photos_search(array('user_id'=>$user_id, 'tags'=>$tags, 'extras'=>$extras, 'per_page'=>500, 'page'=>$i));
- if ($pf->error_code) return afg_error();
+ if ($pf->error_code) return afg_error($pf->error_msg);
}
else if ($popular) {
$flickr_api = 'photos';
$rsp_obj_total = $pf->photos_search(array('user_id'=>$user_id, 'sort'=>'interestingness-desc', 'extras'=>$extras, 'per_page'=>500, 'page'=>$i));
- if ($pf->error_code) return afg_error();
+ if ($pf->error_code) return afg_error($pf->error_msg);
}
else {
$flickr_api = 'photos';
if (get_option('afg_flickr_token')) $rsp_obj_total = $pf->people_getPhotos($user_id, array('extras' => $extras, 'per_page' => 500, 'page' => $i));
else $rsp_obj_total = $pf->people_getPublicPhotos($user_id, NULL, $extras, 500, $i);
- if ($pf->error_code) return afg_error();
+ if ($pf->error_code) return afg_error($pf->error_msg);
}
$photos = array_merge($photos, $rsp_obj_total[$flickr_api]['photo']);
}
if (!DEBUG)
- set_transient('afg_id_' . $id, $photos, 60 * 60 * 24 * 3);
+ set_transient('afg_id_' . $id, $photos, afg_get_cache_refresh_interval_secs($cache_refresh_interval));
+ }
+ else {
+ $total_photos = count($photos);
}
- if (($total_photos % $per_page) == 0) $total_pages = (int)($total_photos / $per_page);
- else $total_pages = (int)($total_photos / $per_page) + 1;
+ if (($total_photos % $per_page) == 0) {
+ $total_pages = (int)($total_photos / $per_page);
+ }
+ else {
+ $total_pages = (int)($total_photos / $per_page) + 1;
+ }
if ($gallery_width == 'auto') $gallery_width = 100;
$text_color = isset($afg_text_color_map[$bg_color])? $afg_text_color_map[$bg_color]: '';
@@ -387,12 +400,12 @@ function afg_display_gallery($atts) {
if ($slideshow_option == 'highslide' && $p_description) {
$photo_title_text .= '
' . $p_description . '';
}
- $photo_title_text .= ' •
View on Flickr';
+ $photo_title_text .= ' •
View on Flickr';
$photo_title_text = esc_attr($photo_title_text);
if ($slideshow_option == 'flickr') {
- $photo_page_url = "http://www.flickr.com/photos/" . $photo['owner'] . "/" . $photo['id'];
+ $photo_page_url = "https://www.flickr.com/photos/" . $photo['owner'] . "/" . $photo['id'];
}
}
@@ -430,7 +443,7 @@ function afg_display_gallery($atts) {
if ($size_heading_map[$photo_size] && $photo_title == 'on') {
if ($group_id || $gallery_id)
- $owner_title = "- by
{$photo['ownername']}";
+ $owner_title = "- by
{$photo['ownername']}";
else
$owner_title = '';