Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 1.5.4 #6

Merged
merged 1 commit into from
Jul 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/js/widgets/conductor-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ var conductor = conductor || {};
}

var $this = $( event.currentTarget ),
paged_regex = new RegExp( '^' + conductor_widget.urls.current.permalink + '(?:.+)?([\\/?&](page[d]?)[\\/=])(\\d+)[\\/]?|^' + conductor_widget.urls.current.permalink + '[\\/](\\d+)[\\/]?$' ),
paged_regex = new RegExp( '^' + conductor_widget.urls.current.permalink + '(?:.+)?((?:[\\/?&]|%3[Ff])(page[d]?)(?:[\\/=]|%3[Dd]))(\\d+)[\\/]?|^' + conductor_widget.urls.current.permalink + '[\\/](\\d+)[\\/]?$' ),
$page_number,
$page_numbers = $this.parents( conductor_widget.css_selectors.pagination.page_numbers ),
$previous_page_number = $page_numbers.find( conductor_widget.css_selectors.pagination.previous ),
Expand Down
12 changes: 11 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@
Plugin: Conductor
Author: Slocum Themes/Slocum Design Studio
Author URI: https://conductorplugin.com/
Current Version: 1.5.3
Current Version: 1.5.4
==========================================


1.5.4 // July 19 2019
---------------------
- Fixed an issue where pagination in AJAX was using an incorrect base permalink on archive pages; Thanks Lê Hoàng Giang
- Added logic to detect the paged URL query argument surrounded by encoded characters (e.g. urlencode()) in preview
pagination links
- Fixed a possible PHP warning when Conductor add-ons data could not be fetched; Thanks Henry Porter
- Fixed an issue where free add-ons could not be installed via the Conductor Add-Ons page
- Fixed a typo where "WordPress" was spelled incorrectly


1.5.3 // May 20 2019
--------------------
- Added the "wp_rest" nonce to all Conductor REST API requests (allows for basic authentication checks
Expand Down
6 changes: 3 additions & 3 deletions conductor.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* Plugin Name: Conductor
* Plugin URI: https://www.conductorplugin.com/
* Description: Build content-rich layouts in minutes without code.
* Version: 1.5.3
* Version: 1.5.4
* Author: Slocum Studio
* Author URI: http://www.slocumstudio.com/
* Requires at least: 4.4
* Tested up to: 5.1.1
* Tested up to: 5.2.2
* License: GPL2+
*
* Text Domain: conductor
Expand All @@ -23,7 +23,7 @@ final class Conductor {
/**
* @var string
*/
public static $version = '1.5.3';
public static $version = '1.5.4';

/**
* @var Boolean, null by default so that we can cache the Boolean value
Expand Down
71 changes: 45 additions & 26 deletions includes/admin/class-conductor-admin-add-ons.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @class Conductor_Admin_Add_Ons
* @author Slocum Studio
* @version 1.5.0
* @version 1.5.4
* @since 1.0.0
*/

Expand All @@ -17,7 +17,7 @@ final class Conductor_Admin_Add_Ons {
/**
* @var string
*/
public $version = '1.5.0';
public $version = '1.5.4';

/**
* @var string
Expand Down Expand Up @@ -119,22 +119,25 @@ public function plugins_api_args( $args, $action ) {
$add_ons_data = self::get_add_ons_data();

// If we have add-ons data and can create a Conductor Updates instance
if ( ! is_wp_error( $add_ons_data ) && class_exists( 'Conductor_Updates' ) )
if ( ! empty( $add_ons_data ) && ! is_wp_error( $add_ons_data ) && class_exists( 'Conductor_Updates' ) )
// Loop through add-ons data
foreach ( $add_ons_data as $add_on_data )
// If this we have valid add-on data (basename and name)
if ( is_array( $add_on_data ) && isset( $add_on_data['basename'] ) && isset( $add_on_data['name'] ) )
// If this add-on is a valid add-on
if ( $args->slug === $add_on_data['basename'] ) {
// Create the Conductor Updates instance
$add_on_updater = new Conductor_Updates( array(
'version' => ( isset( $add_on_data['version'] ) && ! empty( $add_on_data['version'] ) ) ? $add_on_data['version'] : '1.0.0', // Default to 1.0.0
'name' => $add_on_data['name'],
'plugin_file' => $add_on_data['basename']
) );

// Initialize the updater (will hook into plugins_api and fetch the data from the API)
$add_on_updater->init_updater();
// If this isn't a free add-on
if ( ! isset( $add_on_data['free'] ) || ! $add_on_data['free'] ) {
// Create the Conductor Updates instance
$add_on_updater = new Conductor_Updates( array(
'version' => ( isset( $add_on_data['version'] ) && ! empty( $add_on_data['version'] ) ) ? $add_on_data['version'] : '1.0.0', // Default to 1.0.0
'name' => $add_on_data['name'],
'plugin_file' => $add_on_data['basename']
) );

// Initialize the updater (will hook into plugins_api and fetch the data from the API)
$add_on_updater->init_updater();
}

// Break from the loop
break;
Expand Down Expand Up @@ -225,35 +228,44 @@ public function wp_ajax_conductor_add_ons_install_single() {
// Get add-ons data
$add_ons_data = self::get_add_ons_data();

// If we have add-ons data
if ( ! is_wp_error( $add_ons_data ) ) {
// Flag to determine if this is a valid add-on
$is_valid_add_on = false;
// The add-on data
$the_add_on_data = array();

// Flag to determine if this is a valid add-on
$is_valid_add_on = false;

// If we have add-ons data
if ( ! empty( $add_ons_data ) && ! is_wp_error( $add_ons_data ) ) {
// Loop through add-ons data
foreach ( $add_ons_data as $add_on_data )
// If this we have valid add-on data (basename and name)
if ( is_array( $add_on_data ) && isset( $add_on_data['basename'] ) && $plugin_basename === $add_on_data['basename'] ) {
// Set the flag
$is_valid_add_on = true;

// Set the add-on data
$the_add_on_data = $add_on_data;

break;
}
}

// Return an error if the add-on isn't valid
if ( ! $is_valid_add_on ) {
$status['error'] = $error;
wp_send_json_error( $status );
}
// Return an error if the add-on isn't valid
if ( ! $is_valid_add_on ) {
$status['error'] = $error;
wp_send_json_error( $status );
}

// Flag to determine if this is a free add-on
$is_free_add_on = ( ! empty( $the_add_on_data ) && isset( $the_add_on_data['free'] ) && $the_add_on_data['free'] );

// Include necessary plugin installer functionality
include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';

// Grab the plugin information
$api = plugins_api( 'plugin_information', array(
'slug' => $plugin_basename,
'slug' => ( $is_free_add_on ) ? $the_add_on_data['slug'] : $plugin_basename,
) );

// Return an error if there was an error grabbing plugin information
Expand Down Expand Up @@ -380,7 +392,7 @@ public function wp_ajax_conductor_add_ons_activate_single() {
$status['message'] = sprintf( __( '%1$s activated.', 'conductor' ), sanitize_text_field( $_POST['plugin_name'] ) );

// If we have add-ons data
if ( ! is_wp_error( $add_ons_data ) ) {
if ( ! empty( $add_ons_data ) && ! is_wp_error( $add_ons_data ) ) {
// Loop through add-ons data
foreach ( $add_ons_data as $add_on_data )
// If this we have valid add-on data and this is a match
Expand Down Expand Up @@ -578,6 +590,13 @@ public static function maybe_fetch_add_ons_list() {
// Grab the add-on nonces
$add_on_nonces = self::get_add_on_nonces();

// Bail if we don't have the add-on nonces
if ( empty( $add_on_nonces ) ) {
$add_ons = '<div class="error"><p>' . __( 'There was an error retrieving the add-ons list. Please try again later.', 'conductor' ) . '</p></div>';

return $add_ons;
}

// Fetch the data
$args = wp_parse_args( array(
'feed' => 'add-ons',
Expand All @@ -589,7 +608,7 @@ public static function maybe_fetch_add_ons_list() {
$add_ons = wp_remote_post( self::$api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $args ) );

// If we have add-ons HTML
if ( ! is_wp_error( $add_ons ) )
if ( ! empty( $add_ons ) && ! is_wp_error( $add_ons ) )
// Retrieve the request body
$add_ons = wp_remote_retrieve_body( $add_ons );
// Otherwise there was an error
Expand Down Expand Up @@ -673,7 +692,7 @@ public static function get_add_ons_data() {
$add_ons_data = wp_remote_post( self::$api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $args ) );

// If we have add-ons HTML
if ( ! is_wp_error( $add_ons_data ) )
if ( ! empty( $add_ons_data ) && ! is_wp_error( $add_ons_data ) )
// Retrieve the request body
$add_ons_data = json_decode( wp_remote_retrieve_body( $add_ons_data ), true );

Expand All @@ -691,7 +710,7 @@ public static function get_add_on_nonces( $action = 'install' ) {
$add_ons_data = self::get_add_ons_data();

// If we have add-ons data
if ( ! is_wp_error( $add_ons_data ) ) {
if ( ! empty( $add_ons_data ) && ! is_wp_error( $add_ons_data ) ) {
// Loop through add-ons
foreach ( $add_ons_data as $add_on_data )
// If this we have valid add-on data
Expand Down
4 changes: 2 additions & 2 deletions includes/class-conductor-updates.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @class Conductor_Updates
* @author Slocum Studio
* @version 1.5.2
* @version 1.5.4
* @since 1.0.0
*/

Expand All @@ -17,7 +17,7 @@ final class Conductor_Updates {
/**
* @var string
*/
public $version = '1.5.2';
public $version = '1.5.4';

/**
* @var string, URL
Expand Down
14 changes: 6 additions & 8 deletions includes/class-conductor-widget-default-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* @class Conductor_Widget_Default_Query
* @author Slocum Studio
* @version 1.5.2
* @version 1.5.4
* @since 1.0.0
*/

Expand All @@ -18,7 +18,7 @@ class Conductor_Widget_Default_Query extends Conductor_Widget_Query {
/**
* @var string
*/
public $version = '1.5.2';
public $version = '1.5.4';

/**
* @var WP_Widget, Conductor Widget
Expand Down Expand Up @@ -418,21 +418,19 @@ public function get_pagination_links( $query = false, $echo = true ) {
if ( apply_filters( 'conductor_query_paginate_links_is_single', is_single(), $has_permalink_structure, $paginate_links_args, $query, $echo, $this ) )
$paginate_links_args['format'] = ( $has_permalink_structure ) ? '%#%/' : '?page=%#%'; // %#% will be replaced with page number

// If we don't have a permalink structure and this widget has AJAX enabled
if ( ! $has_permalink_structure && $this->widget->has_ajax( $this->widget_instance, array() ) ) {
// TODO: Future: On archive pages, this likely doesn't work correctly (need to use get_pagenum_link() here?)
// If we don't have a permalink structure or this is a preview and this widget has AJAX enabled
if ( ( ! $has_permalink_structure || is_preview() ) && $this->widget->has_ajax( $this->widget_instance, array() ) ) {
// Add the base argument to the paginate links arguments (remove the "page" and "paged" query arguments)
$paginate_links_args['base'] = html_entity_decode( remove_query_arg( array( 'page', 'paged' ), html_entity_decode( ( is_preview() ) ? esc_url( get_permalink() ) : get_pagenum_link() ) ) ) . '%_%';

// Replace question marks in the format argument with ampersands
$paginate_links_args['format'] = ( ! $permalink_structure ) ? str_replace( '?', '&', $paginate_links_args['format'] ) : $paginate_links_args['format'];
}

// TODO: Future: On archive pages, this likely doesn't work correctly (need to use get_pagenum_link() here?)
// If we have a permalink structure and we're paged
if ( $has_permalink_structure && ( is_paged() || $page > 1 ) )
// Add the base argument to the paginate links arguments
$paginate_links_args['base'] = get_permalink() . '%_%';
// Add the base argument to the paginate links arguments (remove the "page" and "paged" query arguments)
$paginate_links_args['base'] = html_entity_decode( remove_query_arg( array( 'page', 'paged' ), html_entity_decode( ( is_preview() ) ? esc_url( get_permalink() ) : get_pagenum_link() ) ) ) . '%_%';

$paginate_links_args = apply_filters( 'conductor_query_paginate_links_args', $paginate_links_args, $query, $echo, $this, $has_permalink_structure );

Expand Down
8 changes: 4 additions & 4 deletions includes/widgets/class-conductor-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @class Conductor_Widget
* @author Slocum Studio
* @version 1.5.3
* @version 1.5.4
* @since 1.0.0
*/

Expand All @@ -17,7 +17,7 @@ final class Conductor_Widget extends WP_Widget {
/**
* @var string
*/
public $version = '1.5.3';
public $version = '1.5.4';

/**
* @var array, Conductor Widget defaults
Expand Down Expand Up @@ -1758,7 +1758,7 @@ public static function wp_enqueue_scripts() {
'urls' => array(
// Current
'current' => array(
'permalink' => str_replace( '?', '\\?', untrailingslashit( get_permalink() ) ),
'permalink' => str_replace( '?', '\\?', untrailingslashit( html_entity_decode( remove_query_arg( array( 'page', 'paged' ), html_entity_decode( ( is_preview() ) ? esc_url( get_permalink() ) : get_pagenum_link() ) ) ) ) ),
),
// REST API
'rest' => array(
Expand Down Expand Up @@ -3211,7 +3211,7 @@ public function widget_settings_advanced_section( $instance, $raw_instance = arr
<input type="checkbox" class="conductor-input conductor-rest-enabled-value" id="<?php echo $this->get_field_id( 'rest_enabled' ); ?>" name="<?php echo $this->get_field_name( 'rest_enabled' ); ?>" <?php checked( $instance['rest']['enabled'] ); ?> <?php disabled( ! $conductor_options['rest']['enabled'] ); ?> data-default="<?php echo esc_attr( ( $this->defaults['rest']['enabled'] ) ? 'true' : false ); ?>" />
<label for="<?php echo $this->get_field_id( 'rest_enabled' ); ?>"><strong><?php _e( 'Enable in REST API', 'conductor' ); ?></strong></label>
<br />
<small class="description conductor-description"><?php _e( 'Enable this Conductor Widget in the Conductor REST API. If unchecked, this Conductor Widget will not be accessible via the Conductor WordPres REST API.', 'conductor' ); ?></small>
<small class="description conductor-description"><?php _e( 'Enable this Conductor Widget in the Conductor REST API. If unchecked, this Conductor Widget will not be accessible via the Conductor WordPress REST API.', 'conductor' ); ?></small>
<?php
// If the Conductor REST API is not enabled
if ( ! $conductor_options['rest']['enabled'] ) :
Expand Down