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 = version_compare( PHP_VERSION, '7.4', '>=' ) || 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( sanitize_text_field( $_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( sanitize_text_field( $_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
* Data is used for Premium Video Box
*/
public function get_premium_video_data() {
$premium_video_data = array(
'box_title' => __( 'Premium Version Enhanced Features', 'a3-lazy-load' ),
'image_url' => A3_LAZY_LOAD_IMAGES_URL. '/video.jpg',
'video_url' => 'https://www.youtube.com/embed/9dGw-ORfMIk?version=3&autoplay=1',
'left_title' => __( 'Premium Version Enhanced Features', 'a3-lazy-load' ),
'left_text' => __( 'WooCommerce Dynamic Gallery Premium', 'a3-lazy-load' )
. "\n\n" . __( 'Quick Video showing the main (not all) enhanced features that are built into the WooCommerce Dynamic Gallery Premium version', 'a3-lazy-load' ),
'right_title' => __( 'Developer Support and Premium Features', 'a3-lazy-load' ),
'right_text' => __( 'Limited Time Offer. Purchase the Premium Version Lifetime License. That is a Lifetime of maintenance updates, feature upgrades and developer support for a once only fee. Offer ending soon.', 'a3-lazy-load' )
. "\n\n" . '' . __( 'Get Premium Features and Support', '' ) . '',
);
return $premium_video_data;
}
public function plugin_premium_video_box( $echo = true ) {
$premium_video_data = apply_filters( $this->plugin_name . '_plugin_premium_video_data', $this->get_premium_video_data() );
$output = '
';
$output .= '
';
$output .= '
';
$output .= '
';
$output .= '
'.$premium_video_data['box_title'].'
';
$output .= '';
$output .= '
';
$output .= $this->plugin_premium_video();
$output .= $this->plugin_premium_video_text();
$output .= '
';
$output .= '
';
$output .= '
';
$output .= '
';
$output = apply_filters( $this->plugin_name . '_plugin_premium_video', $output );
if ( $echo )
echo $output;
else
return $output;
}
public function plugin_premium_video( $echo = false ) {
$premium_video_data = apply_filters( $this->plugin_name . '_plugin_premium_video_data', $this->get_premium_video_data() );
wp_enqueue_style('thickbox');
wp_enqueue_script('thickbox');
$output = '';
if ( $echo )
echo $output;
else
return $output;
}
public function plugin_premium_video_text( $echo = false ) {
$premium_video_data = apply_filters( $this->plugin_name . '_plugin_premium_video_data', $this->get_premium_video_data() );
$output = '';
if ( '' != trim( $premium_video_data['right_text'] ) ) {
$output .= '';
$output .= '';
$output .= '
' . $premium_video_data['right_title'] . '
';
$output .= wpautop( $premium_video_data['right_text'] );
$output .= '';
}
if ( $echo )
echo $output;
else
return $output;
}
public function plugin_extension_boxes( $echo = false ) {
/**
* extension_boxes
* =============================================
* array (
* 'id' => 'box_id' : Enter unique your box id
* 'content' => 'html_content' : (required) Enter the html content to show inside the box
* 'css' => 'custom style' : custom style for the box container
* )
*
*/
$extension_boxes = apply_filters( $this->plugin_name . '_plugin_extension_boxes', array() );
$output = '';
if ( is_array( $extension_boxes ) && count( $extension_boxes ) > 0 ) {
foreach ( $extension_boxes as $box ) {
if ( ! isset( $box['id'] ) ) $box['id'] = '';
if ( ! isset( $box['class'] ) ) $box['class'] = '';
if ( ! isset( $box['css'] ) ) $box['css'] = '';
if ( ! isset( $box['content'] ) ) $box['content'] = '';
$output .= '';
$output .= $box['content'];
$output .= '
';
}
}
if ( $echo )
echo $output;
else
return $output;
}
/*-----------------------------------------------------------------------------------*/
/* plugin_extension_start() */
/* Start of yellow box on right for pro fields
/*-----------------------------------------------------------------------------------*/
public function plugin_extension_start( $echo = true ) {
$output = '';
$output .= '
';
$output .= '
';
$output .= $this->plugin_extension_boxes( false );
$output .= '
';
$output .= '
';
$output .= '
';
$output = apply_filters( $this->plugin_name . '_plugin_extension_start', $output );
if ( $echo )
echo $output;
else
return $output;
}
/*-----------------------------------------------------------------------------------*/
/* plugin_extension_start() */
/* End of yellow box on right for pro fields
/*-----------------------------------------------------------------------------------*/
public function plugin_extension_end( $echo = true ) {
$output = '
';
$output .= '
';
$output = apply_filters( $this->plugin_name . '_plugin_extension_end', $output );
if ( $echo )
echo $output;
else
return $output;
}
/*-----------------------------------------------------------------------------------*/
/* upgrade_top_message() */
/* Show upgrade top message for pro fields
/*-----------------------------------------------------------------------------------*/
public function upgrade_top_message( $echo = false, $setting_id = '' ) {
$upgrade_top_message = sprintf( ''
. __( 'Advanced Settings - Upgrade to the
%s License to activate these settings.', 'a3-lazy-load' )
. '
'
, apply_filters( $this->plugin_name . '_' . $setting_id . '_pro_plugin_page_url', apply_filters( $this->plugin_name . '_pro_plugin_page_url', $this->pro_plugin_page_url ) )
, apply_filters( $this->plugin_name . '_' . $setting_id . '_pro_version_name', apply_filters( $this->plugin_name . '_pro_version_name', __( 'Pro Version', 'a3-lazy-load' ) ) )
);
$upgrade_top_message = apply_filters( $this->plugin_name . '_upgrade_top_message', $upgrade_top_message, $setting_id );
if ( $echo ) echo $upgrade_top_message;
else return $upgrade_top_message;
}
/*-----------------------------------------------------------------------------------*/
/* pro_fields_before() */
/* Start of yellow box on right for pro fields
/*-----------------------------------------------------------------------------------*/
public function pro_fields_before( $echo = true ) {
echo apply_filters( $this->plugin_name . '_pro_fields_before', ''. $this->upgrade_top_message() );
}
/*-----------------------------------------------------------------------------------*/
/* pro_fields_after() */
/* End of yellow border for pro fields
/*-----------------------------------------------------------------------------------*/
public function pro_fields_after( $echo = true ) {
echo apply_filters( $this->plugin_name . '_pro_fields_after', '
' );
}
/*-----------------------------------------------------------------------------------*/
/* blue_message_box() */
/* Blue Message Box
/*-----------------------------------------------------------------------------------*/
public function blue_message_box( $message = '', $width = '600px' ) {
$message = '';
$message = apply_filters( $this->plugin_name . '_blue_message_box', $message );
return $message;
}
/*-----------------------------------------------------------------------------------*/
/* get_version_message() */
/* Get new version message, also include error connect
/*-----------------------------------------------------------------------------------*/
public function get_version_message() {
$version_message = '';
//Getting version number
$version_transient = get_transient( $this->version_transient );
if ( false !== $version_transient ) {
$transient_timeout = '_transient_timeout_' . $this->version_transient;
$timeout = get_option( $transient_timeout, false );
if ( false === $timeout ) {
$version_message = __( 'You should check now to see if have any new version is available', 'a3-lazy-load' );
} elseif ( 'cannot_connect_api' == $version_transient ) {
$version_message = sprintf( __( 'Connection Failure! Please try again. If this issue persists please create a support request on the plugin a3rev support forum.', 'a3-lazy-load' ), $this->support_url );
} else {
$version_info = explode( '||', $version_transient );
if ( FALSE !== stristr( $version_transient, '||' )
&& is_array( $version_info )
&& isset( $version_info[1] ) && $version_info[1] == 'valid'
&& version_compare( A3_LAZY_VERSION , $version_info[0], '<' ) ) {
$version_message = sprintf( __( 'There is a new version %s available, update now or download direct from My Account on a3rev.com', 'a3-lazy-load' ),
$version_info[0],
wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' . $this->plugin_path ), 'upgrade-plugin_' . $this->plugin_path ),
'https://a3rev.com/my-account/downloads/'
);
}
}
} else {
$version_message = __( 'You should check now to see if have any new version is available', 'a3-lazy-load' );
}
return $version_message;
}
}
}