Skip to content

Commit

Permalink
Release new version 2.6.9
Browse files Browse the repository at this point in the history
* This maintenance update is for compatibility with WordPress 5.0.2 and PHP 7.3. It also includes performance updates to the plugin framework.
* Tweak - Test for compatibility with WordPress 5.0.2 and WordPress 4.9.9
* Tweak - Create new structure for future development of Gutenberg Blocks
* Framework - Performance improvement.  Replace wp_remote_fopen  with file_get_contents for get web fonts
* Framework - Performance improvement. Define new variable `is_load_google_fonts` if admin does not require to load google fonts
* Credit - Props to Derek for alerting us to the framework google fonts performance issue
* Framework - Register style name for dynamic style of plugin for use with Gutenberg block
* Framework - Update Modal script and style to version 4.1.1
* Framework - Update a3rev Plugin Framework to version 2.1.0
* Framework - Test and update for compatibility with PHP 7.3
  • Loading branch information
alextuan committed Jan 5, 2019
1 parent 7cd6cd1 commit 91ba7e3
Show file tree
Hide file tree
Showing 25 changed files with 1,976 additions and 594 deletions.
9 changes: 5 additions & 4 deletions a3-portfolio.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
/*
Plugin Name: a3 Portfolio
Description: Creates a beautiful fully mobile responsive, fully customizable, Google images style portfolio to showcase your work.
Version: 2.6.8
Version: 2.6.9
Author: a3rev Software
Author URI: https://a3rev.com/
Requires at least: 4.1
Tested up to: 4.9.8
Requires at least: 4.6
Tested up to: 5.0.2
Text Domain: a3-portfolio
Domain Path: /languages
License: GPLv2 or later
Expand All @@ -33,7 +33,8 @@
define('A3_PORTFOLIO_TEMPLATE_IMAGES_URL', A3_PORTFOLIO_URL . '/templates/images');

define( 'A3_PORTFOLIO_KEY', 'a3_portfolios' );
define( 'A3_PORTFOLIO_VERSION', '2.6.8' );
define( 'A3_PORTFOLIO_VERSION', '2.6.9' );
define( 'A3_PORTFOLIO_G_FONTS', true );

/**
* Load Localisation files.
Expand Down
119 changes: 110 additions & 9 deletions admin/admin-interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,30 @@ public function register_fontawesome_style() {
public function register_modal_scripts() {
$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
wp_register_style( 'bootstrap-modal', $this->admin_plugin_url() . '/assets/css/modal' . $suffix . '.css', array(), '4.1.1', 'all' );
wp_register_script( 'bootstrap-util', $this->admin_plugin_url() . '/assets/js/bootstrap/util' . $suffix . '.js', array( 'jquery' ), '4.1.1', false );

if ( ! wp_script_is( 'bootstrap-util', 'registered' ) ) {
wp_register_script( 'bootstrap-util', $this->admin_plugin_url() . '/assets/js/bootstrap/util' . $suffix . '.js', array( 'jquery' ), '4.1.1', false );
}

wp_register_script( 'bootstrap-modal', $this->admin_plugin_url() . '/assets/js/bootstrap/modal' . $suffix . '.js', array( 'jquery', 'bootstrap-util' ), '4.1.1', false );
}

public function register_popover_scripts() {
$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
wp_enqueue_style( 'bootstrap-popover', $this->admin_plugin_url() . '/assets/css/popover' . $suffix . '.css', array(), '4.1.1', 'all' );

wp_register_script( 'bootstrap-popper', $this->admin_plugin_url() . '/assets/js/bootstrap/popper.min.js', array( 'jquery' ), '4.1.1', false );

if ( ! wp_script_is( 'bootstrap-tooltip', 'registered' ) ) {
wp_register_script( 'bootstrap-tooltip', $this->admin_plugin_url() . '/assets/js/bootstrap/tooltip' . $suffix . '.js', array( 'jquery' ), '4.1.1', false );
}

if ( ! wp_script_is( 'bootstrap-util', 'registered' ) ) {
wp_register_script( 'bootstrap-util', $this->admin_plugin_url() . '/assets/js/bootstrap/util' . $suffix . '.js', array( 'jquery' ), '4.1.1', false );
}

wp_register_script( 'bootstrap-popover', $this->admin_plugin_url() . '/assets/js/bootstrap/popover' . $suffix . '.js', array( 'jquery', 'bootstrap-popper', 'bootstrap-util', 'bootstrap-tooltip' ), '4.1.1', false );
}

/*-----------------------------------------------------------------------------------*/
/* admin_script_load */
Expand All @@ -102,16 +123,18 @@ public function admin_script_load() {

$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
$rtl = is_rtl() ? '.rtl' : '';

$this->register_popover_scripts();

wp_register_script( 'chosen', $this->admin_plugin_url() . '/assets/js/chosen/chosen.jquery' . $suffix . '.js', array( 'jquery' ), true, false );
wp_register_script( 'a3rev-chosen-new', $this->admin_plugin_url() . '/assets/js/chosen/chosen.jquery' . $suffix . '.js', array( 'jquery' ), $this->framework_version, false );
wp_register_script( 'a3rev-chosen-ajaxify', $this->admin_plugin_url() . '/assets/js/chosen/chosen.ajaxify.js', array( 'jquery', 'a3rev-chosen-new' ), $this->framework_version, false );
wp_register_script( 'a3rev-style-checkboxes', $this->admin_plugin_url() . '/assets/js/iphone-style-checkboxes' . $rtl . '.js', array('jquery'), $this->framework_version, false );
wp_register_script( 'jquery-ui-slider-rtl', $this->admin_plugin_url() . '/assets/js/ui-slider/jquery.ui.slider.rtl' . $suffix . '.js', array('jquery'), true, true );

wp_register_script( 'a3rev-admin-ui-script', $this->admin_plugin_url() . '/assets/js/admin-ui-script.js', array('jquery'), $this->framework_version, true );
wp_register_script( 'a3rev-admin-ui-script', $this->admin_plugin_url() . '/assets/js/admin-ui-script.js', array('jquery', 'bootstrap-popover' ), $this->framework_version, true );
wp_register_script( 'a3rev-typography-preview', $this->admin_plugin_url() . '/assets/js/a3rev-typography-preview.js', array('jquery'), $this->framework_version, true );
wp_register_script( 'a3rev-settings-preview', $this->admin_plugin_url() . '/assets/js/a3rev-settings-preview.js', array('jquery'), $this->framework_version, true );
wp_register_script( 'jquery-tiptip', $this->admin_plugin_url() . '/assets/js/tipTip/jquery.tipTip' . $suffix . '.js', array( 'jquery' ), true, true );
wp_register_script( 'a3rev-metabox-ui', $this->admin_plugin_url() . '/assets/js/data-meta-boxes.js', array( 'jquery' ), $this->framework_version, true );
wp_register_script( 'jquery-rwd-image-maps', $this->admin_plugin_url() . '/assets/js/rwdImageMaps/jquery.rwdImageMaps.min.js', array( 'jquery' ), true, true );
wp_register_script( 'jquery-datetime-picker', $this->admin_plugin_url() . '/assets/js/datetimepicker/jquery.datetimepicker.js', array( 'jquery' ), true, true );
Expand All @@ -125,12 +148,11 @@ public function admin_script_load() {
wp_enqueue_script( 'jquery-ui-slider' );
}
wp_enqueue_script( 'chosen' );
wp_enqueue_script( 'a3rev-chosen-new' );
wp_enqueue_script( 'a3rev-chosen-ajaxify' );
wp_enqueue_script( 'a3rev-style-checkboxes' );
wp_enqueue_script( 'a3rev-admin-ui-script' );
wp_enqueue_script( 'a3rev-typography-preview' );
wp_enqueue_script( 'a3rev-settings-preview' );
wp_enqueue_script( 'jquery-tiptip' );
wp_enqueue_script( 'a3rev-metabox-ui' );

} // End admin_script_load()
Expand Down Expand Up @@ -235,7 +257,6 @@ public function admin_css_load () {
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_style( 'jquery-datetime-picker', $this->admin_plugin_url() . '/assets/css/jquery.datetimepicker.css' );
wp_enqueue_style( 'a3rev-chosen-new-style', $this->admin_plugin_url() . '/assets/js/chosen/chosen' . $suffix . '.css', array(), $this->framework_version );
wp_enqueue_style( 'a3rev-tiptip-style', $this->admin_plugin_url() . '/assets/js/tipTip/tipTip.css' );
wp_enqueue_style( 'a3rev-metabox-ui-style', $this->admin_plugin_url() . '/assets/css/a3_admin_metabox.css', array(), $this->framework_version );

if ( is_rtl() ) {
Expand Down Expand Up @@ -363,7 +384,7 @@ public function get_settings_default( $options, $option_name = '' ) {

default :
// Do not include when it's separate option
if ( isset( $value['separate_option'] ) && $value['separate_option'] != false ) continue;
if ( isset( $value['separate_option'] ) && $value['separate_option'] != false ) break;

// Remove [, ] characters from id argument
if ( strstr( $value['id'], '[' ) ) {
Expand Down Expand Up @@ -1123,7 +1144,7 @@ public function settings_get_option( $option_name, $default = '' ) {
* @return void
* ========================================================================
* Option Array Structure :
* type => row | column | heading | ajax_submit | ajax_multi_submit | google_api_key | onoff_toggle_box
* type => row | column | heading | ajax_submit | ajax_multi_submit | google_api_key | google_map_api_key | onoff_toggle_box
* | text | email | number | password | color | bg_color | textarea | select | multiselect | radio | onoff_radio | checkbox | onoff_checkbox
* | switcher_checkbox | image_size | single_select_page | typography | border | border_styles | border_corner | box_shadow
* | slider | upload | wp_editor | array_textfields | time_picker
Expand Down Expand Up @@ -1160,6 +1181,7 @@ public function settings_get_option( $option_name, $default = '' ) {
* checked_label => text : apply for onoff_checkbox, switcher_checkbox only ( set it to show the text instead ON word default )
* unchecked_label => text : apply for onoff_checkbox, switcher_checkbox only ( set it to show the text instead OFF word default )
* options => array : apply for select, multiselect, radio types
* options_url => url : apply for select, multiselect
*
* onoff_options => array : apply for onoff_radio only
* ---------------- example ---------------------
Expand Down Expand Up @@ -1459,7 +1481,7 @@ public function admin_forms( $options, $form_key, $option_name = '', $form_messa

} elseif ( $tip ) {

$tip = '<div class="help_tip a3-plugin-ui-icon a3-plugin-ui-help-icon" data-tip="' . esc_attr( $tip ) . '"></div>';
$tip = '<div class="help_tip a3-plugin-ui-icon a3-plugin-ui-help-icon" data-trigger="hover" data-content="' . esc_attr( $tip ) . '"></div>';

}

Expand Down Expand Up @@ -1812,6 +1834,62 @@ class="a3rev-ui-text a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?> <?p

break;

// Google Map API Key input
case 'google_map_api_key':

$google_map_api_key = $this->settings_get_option( $this->google_map_api_key_option );
$google_map_api_key_enable = $this->settings_get_option( $this->google_map_api_key_option . '_enable', 0 );
if ( ! isset( $value['checked_label'] ) ) $value['checked_label'] = __( 'ON', 'a3-portfolio' );
if ( ! isset( $value['unchecked_label'] ) ) $value['unchecked_label'] = __( 'OFF', 'a3-portfolio' );

?><tr valign="top">
<th scope="row" class="titledesc">
<?php echo $tip; ?>
<label for="<?php echo $this->google_map_api_key_option; ?>"><?php echo __( 'Google Maps API', 'a3-portfolio' ); ?></label>
</th>
<td class="forminp forminp-onoff_checkbox forminp-<?php echo sanitize_title( $value['type'] ) ?>">
<input
name="<?php echo $this->google_map_api_key_option; ?>_enable"
id="<?php echo $this->google_map_api_key_option; ?>_enable"
class="a3rev-ui-onoff_checkbox a3rev-ui-onoff_google_api_key_enable"
checked_label="<?php echo esc_html( $value['checked_label'] ); ?>"
unchecked_label="<?php echo esc_html( $value['unchecked_label'] ); ?>"
type="checkbox"
value="1"
<?php checked( $google_map_api_key_enable, 1 ); ?>
/> <span class="description" style="margin-left:5px;"><?php echo __( 'Switch ON to connect to Google Maps API', 'a3-portfolio' ); ?></span>

<div>&nbsp;</div>
<div class="a3rev-ui-google-api-key-container" style="<?php if( 1 != $google_map_api_key_enable ) { echo 'display: none;'; } ?>">
<div class="a3rev-ui-google-api-key-description"><?php echo sprintf( __( "Enter your existing Google Map API Key below. Don't have a key? Visit <a href='%s' target='_blank'>Google Maps API</a> to create a key", 'a3-portfolio' ), 'https://developers.google.com/maps/documentation/javascript/get-api-key' ); ?></div>
<div class="a3rev-ui-google-api-key-inside
<?php
if ( $this->is_valid_google_map_api_key() ) {
echo 'a3rev-ui-google-valid-key';
} elseif ( '' != $google_map_api_key ) {
echo 'a3rev-ui-google-unvalid-key';
}
?>
">
<input
name="<?php echo $this->google_map_api_key_option; ?>"
id="<?php echo $this->google_map_api_key_option; ?>"
type="text"
style="<?php echo esc_attr( $value['css'] ); ?>"
value="<?php echo esc_attr( $google_map_api_key ); ?>"
class="a3rev-ui-text a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?> <?php echo esc_attr( $value['class'] ); ?>"
placeholder="<?php echo __( 'Google Map API Key', 'a3-portfolio' ); ?>"
<?php echo implode( ' ', $custom_attributes ); ?>
/>
<p class="a3rev-ui-google-valid-key-message"><?php echo __( 'Your Google API Key is valid and automatic font updates are enabled.', 'a3-portfolio' ); ?></p>
<p class="a3rev-ui-google-unvalid-key-message"><?php echo __( 'Please enter a valid Google API Key.', 'a3-portfolio' ); ?></p>
</div>
</div>
</td>
</tr><?php

break;

// Manual Check New Version when click on the button instead of wait for daily
case 'manual_check_version':

Expand Down Expand Up @@ -1893,6 +1971,12 @@ class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-button <?php echo
$errors_text = $value['errors_text'];
$statistic_column = isset( $value['statistic_column'] ) ? $value['statistic_column'] : 1;

$notice = isset( $value['notice'] ) ? $value['notice'] : '';
$confirm_message = '';
if ( isset( $value['confirm_run'] ) && $value['confirm_run']['allow'] ) {
$confirm_message = isset( $value['confirm_run']['message'] ) ? $value['confirm_run']['message'] : '';
}

$multi_current_items = 0;
$multi_total_items = 0;

Expand Down Expand Up @@ -1933,11 +2017,17 @@ class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-button <?php echo
class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-button <?php echo esc_attr( $value['class'] ); ?>"
style="<?php echo esc_attr( $value['css'] ); ?>"
<?php echo implode( ' ', $custom_attributes ); ?>
<?php if ( ! empty( $confirm_message ) ) { ?>
data-confirm_message="<?php echo esc_attr( $confirm_message ); ?>"
<?php } ?>
><?php echo $button_name; ?></button>
<span class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-successed"><?php echo $successed_text; ?></span>
<span class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-errors"><?php echo $errors_text; ?></span>

<!-- Progress Bar -->
<?php if ( ! empty( $notice ) ) { ?>
<div class="a3rev-ui-progress-notice"><?php echo $notice; ?></div>
<?php } ?>
<div class="a3rev-ui-progress-bar-wrap">
<div class="a3rev-ui-progress-inner" data-current="<?php echo $multi_current_items; ?>" data-total="<?php echo $multi_total_items; ?>" ></div>
<div class="a3rev-ui-progressing-text"><?php echo $progressing_text; ?></div>
Expand Down Expand Up @@ -2161,6 +2251,12 @@ class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?> <?php echo esc_at
$value['class'] .= ' chzn-rtl';
}
if ( ! isset( $value['options'] ) ) $value['options'] = array();

$is_ajax = false;
if ( isset( $value['options_url'] ) && ! empty( $value['options_url'] ) ) {
$is_ajax = true;
$value['class'] .= ' chzn-select-ajaxify';
}

?><tr valign="top">
<th scope="row" class="titledesc">
Expand All @@ -2176,6 +2272,11 @@ class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?> <?php echo esc_at
data-placeholder="<?php echo esc_html( $value['placeholder'] ); ?>"
<?php echo implode( ' ', $custom_attributes ); ?>
<?php if ( $value['type'] == 'multiselect' ) echo 'multiple="multiple"'; ?>
<?php if ( $is_ajax ) {
echo 'options_url="'.esc_url( $value['options_url'] ).'"';
echo 'data-no_results_text="Please enter 3 or more characters"';
}
?>
>
<?php
if ( is_array( $value['options'] ) && count( $value['options'] ) > 0 ) {
Expand Down
106 changes: 102 additions & 4 deletions admin/admin-ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ class A3_Portfolio_Admin_UI
* You must change to correct plugin name that you are working
*/

public $framework_version = '2.0.5';
public $framework_version = '2.1.0';
public $plugin_name = A3_PORTFOLIO_KEY;
public $plugin_path = A3_PORTFOLIO_NAME;
public $google_api_key_option = '';
public $google_map_api_key_option = '';
public $toggle_box_open_option = '';
public $version_transient = '';
public $is_free_plugin = true;
public $is_load_google_fonts = true;

public $support_url = '';

Expand Down Expand Up @@ -71,11 +73,18 @@ class A3_Portfolio_Admin_UI
public $admin_pages = array();

public function __construct() {
$this->google_api_key_option = A3_PORTFOLIO_KEY . '_google_api_key';
$this->toggle_box_open_option = A3_PORTFOLIO_KEY . '_toggle_box_open';
$this->version_transient = A3_PORTFOLIO_KEY . '_licinfo';
$this->google_api_key_option = A3_PORTFOLIO_KEY . '_google_api_key';
$this->google_map_api_key_option = A3_PORTFOLIO_KEY . '_google_map_api_key';
$this->toggle_box_open_option = A3_PORTFOLIO_KEY . '_toggle_box_open';
$this->version_transient = A3_PORTFOLIO_KEY . '_licinfo';

if ( defined( 'A3_PORTFOLIO_G_FONTS' ) ) {
$this->is_load_google_fonts = (boolean) A3_PORTFOLIO_G_FONTS;
}

$this->support_url = 'https://wordpress.org/support/plugin/a3-portfolio/';

$this->update_google_map_api_key();
}


Expand Down Expand Up @@ -104,6 +113,95 @@ public function admin_pages() {
return (array)$admin_pages;
}

public function is_valid_google_map_api_key( $cache=true ) {
$is_valid = false;

$this->google_map_api_key = get_option( $this->google_map_api_key_option, '' );
$google_map_api_key_enable = get_option( $this->google_map_api_key_option . '_enable', 0 );

if ( '' != trim( $this->google_map_api_key ) && 1 == $google_map_api_key_enable ) {

$google_map_api_key_status = get_transient( $this->google_map_api_key_option . '_status' );

if ( ! $cache ) {
$google_map_api_key_status = null;
}

if ( ! $google_map_api_key_status ) {
$respone_api = wp_remote_get( "https://maps.googleapis.com/maps/api/geocode/json?address=Australia&key=" . trim( $this->google_map_api_key ),
array(
'sslverify' => false,
'timeout' => 45
)
);

$response_map = array();

// Check it is a valid request
if ( ! is_wp_error( $respone_api ) ) {

$json_string = get_magic_quotes_gpc() ? stripslashes( $respone_api['body'] ) : $respone_api['body'];
$response_map = json_decode( $json_string, true );

// Make sure that the valid response from google is not an error message
if ( ! isset( $response_map['error_message'] ) ) {
$google_map_api_key_status = 'valid';
} else {
$google_map_api_key_status = 'invalid';
}

} else {
$google_map_api_key_status = 'invalid';
}

//caching google map api status for 24 hours
set_transient( $this->google_map_api_key_option . '_status', $google_map_api_key_status, 86400 );
}

if ( 'valid' == $google_map_api_key_status ) {
$is_valid = true;
}

}

return $is_valid;
}

public function update_google_map_api_key() {
// Enable Google Map API Key
if ( isset( $_POST[ $this->google_map_api_key_option . '_enable' ] ) ) {
$old_google_map_api_key_enable = get_option( $this->google_map_api_key_option . '_enable', 0 );

update_option( $this->google_map_api_key_option . '_enable', 1 );

$option_value = trim( $_POST[ $this->google_map_api_key_option ] );

$old_google_map_api_key_option = get_option( $this->google_map_api_key_option );

if ( 1 != $old_google_map_api_key_enable || $option_value != $old_google_map_api_key_option ) {

update_option( $this->google_map_api_key_option, $option_value );

// Clear cached of google map api key status
delete_transient( $this->google_map_api_key_option . '_status' );
}

// Disable Google Map API Key
} elseif ( isset( $_POST[ $this->google_map_api_key_option ] ) ) {
$old_google_map_api_key_enable = get_option( $this->google_map_api_key_option . '_enable', 0 );

update_option( $this->google_map_api_key_option . '_enable', 0 );

$option_value = trim( $_POST[ $this->google_map_api_key_option ] );
update_option( $this->google_map_api_key_option, $option_value );

if ( 0 != $old_google_map_api_key_enable ) {
// Clear cached of google map api key status
delete_transient( $this->google_map_api_key_option . '_status' );
}
}
}

/**
* get_premium_video_data()
* return array
Expand Down
Loading

0 comments on commit 91ba7e3

Please sign in to comment.