Skip to content

Commit

Permalink
Release v2.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
azurecurve committed Feb 3, 2024
1 parent 4f25d83 commit d6961ed
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 91 deletions.
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@ An example of the shortcode is `[gallery-from-folder alt_id="sample-gallery"]`.

# About azurecurve

**azurecurve** was one of the first plugin developers to start developing for ClassicPress; all plugins are available from [azurecurve Development](https://development.azurecurve.co.uk/) and are integrated with the [Update Manager plugin](https://directory.classicpress.net/plugins/update-manager) for fully integrated, no hassle, updates.
**azurecurve** was one of the first plugin developers to start developing for Classicpress; all plugins are available from [azurecurve Development](https://development.azurecurve.co.uk/) and are integrated with the [Update Manager plugin](https://directory.classicpress.net/plugins/update-manager) for fully integrated, no hassle, updates.

The other plugins available from **azurecurve** are:
* Add Open Graph Tags - [details](https://development.azurecurve.co.uk/classicpress-plugins/add-open-graph-tags/) / [download](https://github.com/azurecurve/azrcrv-add-open-graph-tags/releases/latest/)
* Add Twitter Cards - [details](https://development.azurecurve.co.uk/classicpress-plugins/add-twitter-cards/) / [download](https://github.com/azurecurve/azrcrv-add-twitter-cards/releases/latest/)
* Avatars - [details](https://development.azurecurve.co.uk/classicpress-plugins/avatars/) / [download](https://github.com/azurecurve/azrcrv-avatars/releases/latest/)
* BBCode - [details](https://development.azurecurve.co.uk/classicpress-plugins/bbcode/) / [download](https://github.com/azurecurve/azrcrv-bbcode/releases/latest/)
* Breadcrumbs - [details](https://development.azurecurve.co.uk/classicpress-plugins/breadcrumbs/) / [download](https://github.com/azurecurve/azrcrv-breadcrumbs/releases/latest/)
* Call-out Boxes - [details](https://development.azurecurve.co.uk/classicpress-plugins/call-out-boxes/) / [download](https://github.com/azurecurve/azrcrv-call-out-boxes/releases/latest/)
* Check Plugin Status - [details](https://development.azurecurve.co.uk/classicpress-plugins/check-plugin-status/) / [download](https://github.com/azurecurve/azrcrv-check-plugin-status/releases/latest/)
* Code - [details](https://development.azurecurve.co.uk/classicpress-plugins/code/) / [download](https://github.com/azurecurve/azrcrv-code/releases/latest/)
* Comment Validator - [details](https://development.azurecurve.co.uk/classicpress-plugins/comment-validator/) / [download](https://github.com/azurecurve/azrcrv-comment-validator/releases/latest/)
* Conditional Links - [details](https://development.azurecurve.co.uk/classicpress-plugins/conditional-links/) / [download](https://github.com/azurecurve/azrcrv-conditional-links/releases/latest/)
Expand All @@ -39,7 +37,7 @@ The other plugins available from **azurecurve** are:
* Filtered Categories - [details](https://development.azurecurve.co.uk/classicpress-plugins/filtered-categories/) / [download](https://github.com/azurecurve/azrcrv-filtered-categories/releases/latest/)
* Flags - [details](https://development.azurecurve.co.uk/classicpress-plugins/flags/) / [download](https://github.com/azurecurve/azrcrv-flags/releases/latest/)
* Floating Featured Image - [details](https://development.azurecurve.co.uk/classicpress-plugins/floating-featured-image/) / [download](https://github.com/azurecurve/azrcrv-floating-featured-image/releases/latest/)
* From Twitter - [details](https://development.azurecurve.co.uk/classicpress-plugins/from-twitter/) / [download](https://github.com/azurecurve/azrcrv-from-twitter/releases/latest/)
* Gallery From Folder - [details](https://development.azurecurve.co.uk/classicpress-plugins/gallery-from-folder/) / [download](https://github.com/azurecurve/azrcrv-gallery-from-folder/releases/latest/)
* Get GitHub File - [details](https://development.azurecurve.co.uk/classicpress-plugins/get-github-file/) / [download](https://github.com/azurecurve/azrcrv-get-github-file/releases/latest/)
* Icons - [details](https://development.azurecurve.co.uk/classicpress-plugins/icons/) / [download](https://github.com/azurecurve/azrcrv-icons/releases/latest/)
* Images - [details](https://development.azurecurve.co.uk/classicpress-plugins/images/) / [download](https://github.com/azurecurve/azrcrv-images/releases/latest/)
Expand Down Expand Up @@ -69,10 +67,8 @@ The other plugins available from **azurecurve** are:
* Taxonomy Order - [details](https://development.azurecurve.co.uk/classicpress-plugins/taxonomy-order/) / [download](https://github.com/azurecurve/azrcrv-taxonomy-order/releases/latest/)
* Theme Switcher - [details](https://development.azurecurve.co.uk/classicpress-plugins/theme-switcher/) / [download](https://github.com/azurecurve/azrcrv-theme-switcher/releases/latest/)
* Timelines - [details](https://development.azurecurve.co.uk/classicpress-plugins/timelines/) / [download](https://github.com/azurecurve/azrcrv-timelines/releases/latest/)
* To Twitter - [details](https://development.azurecurve.co.uk/classicpress-plugins/to-twitter/) / [download](https://github.com/azurecurve/azrcrv-to-twitter/releases/latest/)
* Toggle Show/Hide - [details](https://development.azurecurve.co.uk/classicpress-plugins/toggle-showhide/) / [download](https://github.com/azurecurve/azrcrv-toggle-showhide/releases/latest/)
* Update Admin Menu - [details](https://development.azurecurve.co.uk/classicpress-plugins/update-admin-menu/) / [download](https://github.com/azurecurve/azrcrv-update-admin-menu/releases/latest/)
* URL Shortener - [details](https://development.azurecurve.co.uk/classicpress-plugins/url-shortener/) / [download](https://github.com/azurecurve/azrcrv-url-shortener/releases/latest/)
* Username Protection - [details](https://development.azurecurve.co.uk/classicpress-plugins/username-protection/) / [download](https://github.com/azurecurve/azrcrv-username-protection/releases/latest/)
* Widget Announcements - [details](https://development.azurecurve.co.uk/classicpress-plugins/widget-announcements/) / [download](https://github.com/azurecurve/azrcrv-widget-announcements/releases/latest/)

* Widget Announcements - [details](https://development.azurecurve.co.uk/classicpress-plugins/widget-announcements/) / [download](https://github.com/azurecurve/azrcrv-widget-announcements/releases/latest/)
20 changes: 12 additions & 8 deletions azrcrv-gallery-from-folder.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
<?php
/**
* ------------------------------------------------------------------------------
* Plugin Name: Gallery From Folder
* Description: Gallery for all images in folder.
* Version: 2.1.3
* Author: azurecurve
* Author URI: https://development.azurecurve.co.uk/classicpress-plugins/
* Plugin URI: https://development.azurecurve.co.uk/classicpress-plugins/azrcrv-gallery-from-folder/
* Text Domain: gallery-from-folder
* Domain Path: /languages
* Plugin Name: Gallery From Folder
* Description: Gallery for all images in folder.
* Version: 2.1.4
* Requires CP: 1.0
* Author: azurecurve
* Author URI: https://development.azurecurve.co.uk/classicpress-plugins/
* Plugin URI: https://development.azurecurve.co.uk/classicpress-plugins/azrcrv-gallery-from-folder/
* Donate link: https://development.azurecurve.co.uk/support-development/
* Text Domain: gallery-from-folder
* Domain Path: /languages
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
* ------------------------------------------------------------------------------
* This is free software released under the terms of the General Public License,
* version 2, or later. It is distributed WITHOUT ANY WARRANTY; without even the
Expand Down
117 changes: 75 additions & 42 deletions libraries/updateclient/UpdateClient.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,37 @@
/**
* -----------------------------------------------------------------------------
* Purpose: Remote client to communicate with the Update Manager plugin.
* Author: Code Potent
* Author URI: https://codepotent.com
* Author: Simone Fioravanti
* Author URI: https://software.gieffeedizioni.it
* API Version: 2.0.0
* Last modified on Update Manager release: 2.5.0
* -----------------------------------------------------------------------------
* This is free software released under the terms of the General Public License,
* version 2, or later. It is distributed WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Full
* text of the license is available at https://www.gnu.org/licenses/gpl-2.0.txt.
* -----------------------------------------------------------------------------
* Copyright 2020, Code Potent
* -----------------------------------------------------------------------------
* ____ _ ____ _ _
* / ___|___ __| | ___| _ \ ___ | |_ ___ _ __ | |_
* | | / _ \ / _` |/ _ \ |_) / _ \| __/ _ \ '_ \| __|
* | |__| (_) | (_| | __/ __/ (_) | || __/ | | | |_
* \____\___/ \__,_|\___|_| \___/ \__\___|_| |_|\__|.com
*
* Copyright 2021, John Alarcon (Code Potent)
* 2021-2023, Simone Fioravanti
* -----------------------------------------------------------------------------
*/

// EDIT: Make this unique. Example: YourDevName\YourPluginName;
namespace azurecurve\azrcrv_gff;
namespace azurecurve\GalleryFromFolder;

// EDIT: URL where Update Manager is installed; with trailing slash!
const UPDATE_SERVER = 'https://update.development.azurecurve.co.uk/';

// EDIT: Choose what to do in ClassicPress v.2 and above.
// Set to true to disable UpdateClient if updates are provided
// using the Classicpress Plugin Directory.
const USE_DIRECTORY = false;

// EDIT: Comment this out and fill with the first part of the url
// of your Download link to make sure that updates
// are served from your trusted source.
// const SECURE_SOURCE = 'https://github.com/xxsimoxx/codepotent-update-manager/';

// EDIT: plugin or theme?
const UPDATE_TYPE = 'plugin';

Expand All @@ -36,6 +42,12 @@
die();
}

// Should directory take over?
$running_on = function_exists('classicpress_version') ? classicpress_version() : '0';
if (USE_DIRECTORY && version_compare($running_on, '2', '>=')) {
return;
}

/**
* Remote updater class for ClassicPress plugin and themes.
*
Expand All @@ -56,16 +68,7 @@ class UpdateClient {
private $config;

/**
* Default CP version.
*
* This value is used for comparison in the updates list table by core. This
* property can be set to 4.9.x (whatever x might be at the time,) if you're
* wanting to be exact. The issue with doing that is that you'd have to bump
* that number with every new release of 4.9.x to ensure that core indicates
* 100% compatibility in the table. If your plugin or theme is compatible to
* WordPress 4.9.x, it is compatible with ClassicPress 1.x.x, so, there will
* not be a need for this. Setting it to 4.9.99 ensures don't have to update
* it again.
* Latest CP version.
*/
private $cp_latest_version = '4.9.99';

Expand All @@ -77,6 +80,9 @@ class UpdateClient {
*/
private $component_data = '';

private $identifier = null;
private $server_slug = null;

/**
* Constructor.
*
Expand All @@ -103,7 +109,7 @@ private function __construct() {
];

// Find and store the latest CP version during update process.
$this->cp_latest_version = get_option('cp_latest_version', '');
$this->cp_latest_version = $this->get_latest_version_number();

// Hook the update client into the system.
$this->init();
Expand Down Expand Up @@ -188,11 +194,9 @@ public function print_admin_scripts() {
// Only need this JS/CSS on the plugin admin page and updates page.
if ($screen->base === 'plugins' || $screen->base === 'plugin-install') {
// This will make the jQuery below work with various languages.
$text1 = esc_html__('Compatible up to:');
$text2 = esc_html__('Reviews');
$text3 = esc_html__('Read all reviews');
// Swap "Compatible up to: 4.9.99" with "Compatible up to: 1.1.1".
echo '<script>jQuery(document).ready(function($){$("ul li:contains(4.9.99)").html("<strong>'.$text1.'</strong> '.$this->cp_latest_version.'");$(".fyi h3:contains('.$text2.')").hide();$(".fyi p:contains('.$text3.')").hide();});</script>'."\n";
// Text domains are missing because the strings are already in CP.
echo '<script>jQuery(document).ready(function($){$("ul li:contains(4.9.99)").html("<strong>'.esc_html__('Compatible up to:').'</strong> '.esc_html($this->cp_latest_version).'");$(".fyi h3:contains('.esc_html__('Reviews').')").hide();$(".fyi p:contains('.esc_html__('Read all reviews').')").hide();});</script>'."\n"; // phpcs:ignore WordPress.WP.I18n.MissingArgDomain
// Styles for the modal window.
echo '<style>'."\n";
// Hide the ratings text and links to WP.org reviews.
Expand Down Expand Up @@ -234,15 +238,18 @@ public function filter_component_update_transient($value) {
// Is there a response?
if (isset($value->response)) {

// Ensure the latest ClassicPress version number is available.
$this->get_latest_version_number();

// Get the installed components.
$components = $this->get_component_data('query_'.$this->config['type'].'s');

// Iterate over installed components.
foreach($components as $component=>$data) {

// If necessary check if the new package come from the right source.
if (defined(__NAMESPACE__.'\SECURE_SOURCE') && isset($data['package']) && strpos($data['package'], SECURE_SOURCE) !== 0) {
unset($value->response[$component]);
continue;
}

// Is there a new version?
if (isset($data['id'], $data['new_version'], $data['package'])) {

Expand Down Expand Up @@ -334,6 +341,11 @@ public function filter_components_api_result($res, $action, $args) {
// Get the component's information.
$info = $this->get_component_data($action, $list_components[$args->slug]);

// If the request failed, pass through an informative error message.
if (is_wp_error($info)) {
return $info;
}

// If the response has all the right properties, cast $info to object.
if (isset($info['name'], $info['slug'], $info['external'], $info['sections'])) {
$res = (object)$info;
Expand Down Expand Up @@ -380,9 +392,16 @@ public function filter_component_row_meta($component_meta, $component_file) {
// Add the link to the plugin's or theme's row, if not already existing.
if ($this->identifier === $component_file) {
$anchors_string = implode('', $component_meta);
$anchor_text = esc_html__('View details');
// Text domains are missing because the strings are already in CP.
$anchor_text = esc_html__('View details'); // phpcs:ignore WordPress.WP.I18n.MissingArgDomain
if (!preg_match('|(\<a[ \s\S\d]*)('.$anchor_text.')(<\/a>)|', $anchors_string)) {
$component_meta[] = '<a class="thickbox" href="'.admin_url('/'.$this->config['type'].'-install.php?tab='.$this->config['type'].'-information&'.$this->config['type'].'='.$this->server_slug.'&TB_iframe=true&width=600&height=550').'">'.$anchor_text.'</a>';
if (is_multisite()) {
if(current_user_can('update_plugins')) {
$component_meta[] = '<a class="thickbox" href="'.network_admin_url('/'.$this->config['type'].'-install.php?tab='.$this->config['type'].'-information&'.$this->config['type'].'='.$this->server_slug.'&TB_iframe=true&width=600&height=550').'">'.$anchor_text.'</a>';
}
} else {
$component_meta[] = '<a class="thickbox" href="'.admin_url('/'.$this->config['type'].'-install.php?tab='.$this->config['type'].'-information&'.$this->config['type'].'='.$this->server_slug.'&TB_iframe=true&width=600&height=550').'">'.$anchor_text.'</a>';
}
}
}

Expand Down Expand Up @@ -447,11 +466,11 @@ public function filter_upgrader_post_install($response, $hook_extra, $result) {
// Updating a plugin or theme?
if ($hook_suffix === 'update') {
// Got both of the needed arguments?
if (isset($_GET['action'], $_GET[$this->config['type']])) {
if (isset($_GET['action'], $_GET[$this->config['type']])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
// First argument is good?
if ($_GET['action'] === 'upgrade-'.$this->config['type']) {
if ($_GET['action'] === 'upgrade-'.$this->config['type']) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
// Next argument is good?
if ($_GET[$this->config['type']] === $hook_extra[$this->config['type']]) {
if ($_GET[$this->config['type']] === $hook_extra[$this->config['type']]) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
// Activate the component.
$function = ($this->config['type'] === 'plugin') ? 'activate_plugin' : 'activate_theme';
$function($hook_extra[$this->config['type']]);
Expand Down Expand Up @@ -573,7 +592,7 @@ private function get_component_data($action, $component='') {
global $cp_version;

// Initialize the data to be posted.
$body = $this->config['post'];
$body = apply_filters('codepotent_update_manager_filter_'.$this->config['id'].'_client_request', $this->config['post']);

if ($action === 'plugin_information') {

Expand Down Expand Up @@ -658,13 +677,22 @@ private function get_component_data($action, $component='') {
}

// Still an error? Hey, you tried. Bail.
if (is_wp_error($raw_response) || 200 != wp_remote_retrieve_response_code($raw_response)) {
return [];
if (is_wp_error($raw_response)) {
return new \WP_Error('update_manager_http_error', 'HTTP error. ' . $raw_response->get_error_message(), ['original_error' => $raw_response]);
}
$response_code = wp_remote_retrieve_response_code($raw_response);
if (200 != $response_code) {
return new \WP_Error('update_manager_http_error', 'HTTP error. ' . $response_code, compact('raw_response'));
}

// Get the response body; decode it as an array.
$data = json_decode(trim(wp_remote_retrieve_body($raw_response)), true);

// If decoding fails, bail.
if ($data === null) {
return new \WP_Error('update_manager_http_error', 'Invalid API response (invalid JSON)', $raw_response);
}

// Set retrieved data to the object for reuse elsewhere.
$this->component_data = is_array($data) ? $data : [];

Expand Down Expand Up @@ -723,10 +751,14 @@ public function get_plugin_images($type, $plugin) {
$image_path = untrailingslashit(WP_PLUGIN_DIR).'/'.$plugin.'/images';
$image_url = untrailingslashit(WP_PLUGIN_URL).'/'.$plugin.'/images';

// Allow directory location to be filtered.
// Allow directory location to be filtered. DEPRECATED FILTERS.
$image_path = apply_filters('codepotent_update_manager_image_path', $image_path);
$image_url = apply_filters('codepotent_update_manager_image_url', $image_url);

// Allow directory location to be filtered. NEW FILTERS.
$image_path = apply_filters('codepotent_update_manager_'.$this->config['id'].'_image_path', $image_path);
$image_url = apply_filters('codepotent_update_manager_'.$this->config['id'].'_image_url', $image_url);

// Banner and icon images are keyed differently; it's a core thing.
$image_qualities = [
'icon' => ['default', '1x', '2x'],
Expand Down Expand Up @@ -821,7 +853,7 @@ public function get_latest_version_number() {
$version = get_transient('codepotent_update_manager_cp_version');

// Return version number, if now known.
if (!empty($version)) {
if (false !== $version) {
return $version;
}

Expand Down Expand Up @@ -855,8 +887,9 @@ public function get_latest_version_number() {
$version = str_replace('.json', '', $version);
}

// A transient ensures the query is not run more than every 10 minutes.
set_transient('codepotent_update_manager_cp_version', $version, MINUTE_IN_SECONDS * 10);
// A transient ensures the query is not run more than every 6 hours.
set_transient('codepotent_update_manager_cp_version', $version, HOUR_IN_SECONDS * 6);
update_option('cp_latest_version', $version);

// Return the version string.
return $version;
Expand All @@ -866,4 +899,4 @@ public function get_latest_version_number() {
}

// Run it!
UpdateClient::get_instance();
UpdateClient::get_instance();

0 comments on commit d6961ed

Please sign in to comment.