Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
… into AEU-110
  • Loading branch information
kcppdevelopers committed Jun 24, 2020
2 parents a0134f7 + bce3b3e commit f238b8a
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 26 deletions.
76 changes: 64 additions & 12 deletions admin/class-angelleye-updater-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ public function __construct($file) {

add_action('angelleye_updater_license_screen_before', array($this, 'ensure_keys_are_actually_active'));

add_action('admin_notices', array($this, 'angelleye_cache_refresh'));

add_action('wp_ajax_angelleye_activate_license_keys', array($this, 'ajax_process_request'));
add_action('admin_notices', array($this, 'angelleye_check_product_license_key_status'));
}
Expand Down Expand Up @@ -145,6 +147,13 @@ public function maybe_process_dismiss_link() {
* @return void
*/
public function maybe_display_activation_notice() {

$angelleye_helper_fresh_notice = get_transient( 'angelleye_helper_fresh_notice');
if( !empty($angelleye_helper_fresh_notice)) {
echo $angelleye_helper_fresh_notice;
delete_transient('angelleye_helper_fresh_notice');
}

if (isset($_GET['page']) && 'angelleye-helper' == $_GET['page'])
return;
if (!current_user_can('manage_options'))
Expand Down Expand Up @@ -200,7 +209,7 @@ public function register_settings_screen() {
*/
public function settings_screen() {
?>
<div id="welcome-panel" class="wrap about-wrap angelleye-updater-wrap">
<div id="welcome-panel" class="wrap angelleye-updater-wrap">
<h1><?php _e('Welcome to Angell EYE Updater', 'angelleye-updater'); ?></h1>

<div class="about-text angelleye-helper-about-text">
Expand Down Expand Up @@ -228,9 +237,15 @@ public function settings_screen() {
default:
if ($this->api->ping()) {
$this->installed_products = $this->get_detected_products();
$this->pending_products = $this->get_pending_products();

do_action('angelleye_updater_license_screen_before');
$this->pending_products = $this->get_pending_products();
$refresh_url = add_query_arg(
array(
'page' => 'angelleye-helper',
'cache-refresh' => 1
),
admin_url( 'admin.php' )
);
require_once( $this->screens_path . 'screen-manage.php' );
do_action('angelleye_updater_license_screen_after');
} else {
Expand Down Expand Up @@ -351,7 +366,7 @@ private function get_post_or_get_action($supported_actions) {
* @return void
*/
public function enqueue_styles() {
wp_enqueue_style('angelleye-updater-admin', esc_url($this->assets_url . 'css/angelleye-updater-admin.css'), array(), '1.0.0', 'all');
wp_enqueue_style('angelleye-updater-admin', esc_url($this->assets_url . 'css/angelleye-updater-admin.css'), array(), AU_PLUGIN_VERSION, 'all');
}

// End enqueue_styles()
Expand Down Expand Up @@ -465,15 +480,10 @@ public function ajax_process_request() {
$return .= '</div>' . "\n";
$return_json = array('success' => 'true', 'message' => $return, 'url' => add_query_arg(array('page' => 'angelleye-helper', 'status' => 'true', 'type' => 'activate-products'), admin_url('index.php')));
} else {
$return = '<div class="error fade">' . "\n";
$return .= wpautop(__('There was an error and not all products were activated.', 'angelleye-updater'));
$return .= '</div>' . "\n";

$message = '';
foreach ($request_errors as $k => $v) {
$message .= wpautop($v);
}

$return .= '<div class="error fade">' . "\n";
$return .= make_clickable($message);
$return .= '</div>' . "\n";
Expand Down Expand Up @@ -671,6 +681,7 @@ protected function get_pending_products() {
*/
protected function activate_products($products) {
$response = false;
delete_transient('license_key_status_check');
if (!is_array($products) || ( 0 >= count($products) )) {
return false;
} // Get out if we have incorrect data.
Expand All @@ -688,7 +699,7 @@ protected function activate_products($products) {
if(isset($product_keys[$k]['product_id']) && !empty($product_keys[$k]['product_id'])) {
$product_id = $product_keys[$k]['product_id'];
} else {
$plugin_data = get_plugin_data($k);
$plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/' . $k);
if( !empty($plugin_data)) {
$product_id = $plugin_data['TextDomain'];
}
Expand Down Expand Up @@ -737,6 +748,22 @@ protected function deactivate_product($filename, $local_only = false) {
if (false == $local_only) {
$deactivated = $this->api->deactivate($key);
}
} else {
$plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/' . $filename);
if( !empty($plugin_data)) {
$product_id = $plugin_data['TextDomain'];
}
if( !empty($product_id)) {
foreach ($already_active as $key => $value) {
if(isset($value[0]) && $value[0] == $product_id ) {
$filename = $key;
if (false == $local_only) {
$deactivated = $this->api->deactivate($value[2]);
}
break;
}
}
}
}

if ($deactivated) {
Expand Down Expand Up @@ -826,8 +853,15 @@ public function angelleye_check_product_license_key_status() {
if( !empty($value[2])) {
$message = $this->api->check_product_license_key_status($value[2]);
if( !empty($message->message) ) {
$dismiss_url = add_query_arg('action', 'angelleye-helper-expired-notice-dismiss', add_query_arg('nonce', wp_create_nonce('angelleye-helper-expired-notice-dismiss')));
$dismiss_url = add_query_arg('product', $message->product_id, $dismiss_url);
$url = add_query_arg('page', 'angelleye-helper', network_admin_url('index.php'));

$dismiss_url = add_query_arg( array(
'screen' => 'licenses',
'action' => 'angelleye-helper-expired-notice-dismiss',
'nonce' => wp_create_nonce('angelleye-helper-expired-notice-dismiss'),
'product' => $message->product_id
), $url );

$notice = '<div class="notice notice-error"><p class="alignleft">' . sprintf(__($message->message, 'angelleye-updater')) . '</p><p class="alignright"><a href="' . esc_url($dismiss_url) . '">' . __('Dismiss', 'angelleye-updater') . '</a></p><div class="clear"></div></div>' . "\n";
$notice_array[$message->product_id] = $notice;
echo $notice;
Expand All @@ -841,12 +875,16 @@ public function angelleye_check_product_license_key_status() {
$angelleye_helper_dismiss_activation_notice = get_site_option('angelleye_helper_dismiss_activation_notice', false);
foreach ($license_key_status_check as $key => $value) {
if($angelleye_helper_dismiss_activation_notice != false) {
if(!empty($angelleye_helper_dismiss_activation_notice) && is_array($angelleye_helper_dismiss_activation_notice)) {
if(!in_array($key, $angelleye_helper_dismiss_activation_notice)) {
echo $value;
}
} else {
echo $value;
}
} else {
echo $value;
}
}
}
}
Expand Down Expand Up @@ -1059,4 +1097,18 @@ public function angelleye_is_plugin_activated($product_id) {
}
return false;
}

public function angelleye_cache_refresh() {
if(isset($_GET['cache-refresh'])) {
delete_transient('license_key_status_check');
delete_site_transient( 'update_plugins' );
delete_site_option('angelleye_helper_dismiss_activation_notice');
$angelleye_helper_fresh_notice = '<div id="message" class="updated notice is-dismissible"><p><strong>' . esc_html( __( 'Caches refreshed successfully.', 'angelleye-updater' ) ) . '</strong></p></div>';
set_transient( 'angelleye_helper_fresh_notice', $angelleye_helper_fresh_notice, HOUR_IN_SECONDS );
$url = add_query_arg('page', 'angelleye-helper', network_admin_url('index.php'));
$dismiss_url = add_query_arg( 'screen', 'licenses', $url );
wp_redirect($dismiss_url);
exit();
}
}
}
37 changes: 37 additions & 0 deletions admin/css/angelleye-updater-admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,41 @@
}
.dashboard_page_angelleye-helper .green-font {
color: green;
}
.ag-helper {
float: right;
}
.ag-helper .button-update, .ag-helper .button-update:hover {
background-color:
#e6e6e6;
border-radius: 4px;
color:
#333;
font-weight: 800;
font-size: 10px;
line-height: 20px;
margin-left: 6px;
opacity: .75;
padding: 3px 7px;
text-transform: uppercase;
}
.ag-helper .button, .ag-helper .button:active, .ag-helper .button:focus, .ag-helper .button:hover {
background-color: #955a89;
border-width: 0;
box-shadow: none;
border-radius: 3px;
color: #fff;
height: auto;
padding: 3px 14px;
text-align: center;
white-space: normal !important;
}
.ag-helper .button-update .dashicons, .ag-helper .button-update:hover .dashicons {
font-size: 12px;
height: 12px;
width: 12px;
vertical-align: text-bottom;
}
.angelleye-helper-about-text {
margin-top: 20px;
}
6 changes: 4 additions & 2 deletions angelleye-updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Plugin Name: Angell EYE Updater
* Plugin URI: http://www.angelleye.com/
* Description: Manage activations and updates for premium extensions to Angell EYE plugins.
* Version: 2.0.10
* Version: 2.0.11
* Author: Angell EYE
* Author URI: http://www.angelleye.com/
* License: GNU General Public License v3.0
Expand All @@ -19,6 +19,8 @@
die;
}

define('AU_PLUGIN_VERSION', '2.0.11');

/**
* define plugin basename
*/
Expand Down Expand Up @@ -59,7 +61,7 @@
define('AU_PLUGIN_BASENAME', plugin_basename(__FILE__));
}
if (!defined('AU_FREE_LICENSE_KEY_TEXT')) {
define('AU_FREE_LICENSE_KEY_TEXT', __('N/A', 'angelleye-updater'));
define('AU_FREE_LICENSE_KEY_TEXT', __('FREE', 'angelleye-updater'));
}
if (!defined('AU_EMPTY_ACTION_TEXT')) {
define('AU_EMPTY_ACTION_TEXT', __('N/A', 'angelleye-updater'));
Expand Down
2 changes: 1 addition & 1 deletion includes/class-angelleye-updater-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ private function request($endpoint = 'check', $params = array(), $method = 'post
// Store errors in a transient, to be cleared on each request.
if (isset($data->error) && ( '' != $data->error )) {
$error = html_entity_decode($data->error);
$error = '<strong>' . $error . '</strong>';
$error = $error;
if (isset($data->additional_info)) {
$error .= '<br /><br />' . html_entity_decode($data->additional_info);
}
Expand Down
5 changes: 3 additions & 2 deletions includes/class-angelleye-updater-deactivator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ class AngellEYE_Updater_Deactivator {
* @since 1.0.0
*/
public static function deactivate() {


delete_transient('license_key_status_check');
delete_site_transient( 'update_plugins' );
delete_site_option('angelleye_helper_dismiss_activation_notice');
}

}
12 changes: 9 additions & 3 deletions includes/class-angelleye-updater-licenses-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,13 @@ public function column_license_key($item) {
if (isset($item['license_key']) && !empty($item['license_key'])) {
return wpautop($item['license_key']);
} else {
if ($item['is_paid'] == true) {
if ($item['is_paid'] == true && $item['plugin_status'] == 'Not Installed') {
$more_info = sprintf('<a class="" href="%s" target="_blank">%s</a>', isset($this->angelleye_plugin_more_info_page[$item['product_id']]['web_page']) ? $this->angelleye_plugin_more_info_page[$item['product_id']]['web_page'] : '' , __('Buy Now', 'angelleye-updater'));
return $more_info;
} elseif ($item['is_paid'] == false && $item['plugin_status'] == 'Not Installed') {
$more_info = sprintf('<a class="" href="%s" target="_blank">%s</a>', isset($this->angelleye_plugin_more_info_page[$item['product_id']]['web_page']) ? $this->angelleye_plugin_more_info_page[$item['product_id']]['web_page'] : '' , __('Download Now', 'angelleye-updater'));
return $more_info;
} elseif ($item['is_paid'] == true) {
$response = '';
$response .= '<input name="license_keys[' . esc_attr($item['product_file_path']) . ']" id="license_keys-' . esc_attr($item['product_file_path']) . '" type="text" value="" size="37" aria-required="true" placeholder="' . esc_attr(__('Enter license key here', 'angelleye-updater')) . '" />' . "\n";
return $response;
Expand Down Expand Up @@ -228,8 +234,8 @@ public function column_product_status($item) {

public function column_plugin_status($item) {
if ($item['plugin_status'] == 'Not Installed') {
$more_info = sprintf('<a class="" href="%s" target="_blank">%s</a>', isset($this->angelleye_plugin_more_info_page[$item['product_id']]['web_page']) ? $this->angelleye_plugin_more_info_page[$item['product_id']]['web_page'] : '' , __('More Info', 'angelleye-updater'));
return '<span class="red-font">' . $item['plugin_status'] . '</span>' . str_repeat('&nbsp;', 2) . $more_info;
$more_info = sprintf('<a class="" href="%s" target="_blank">%s</a>', isset($this->angelleye_plugin_more_info_page[$item['product_id']]['web_page']) ? $this->angelleye_plugin_more_info_page[$item['product_id']]['web_page'] : '' , __('Read More', 'angelleye-updater'));
return $more_info;
} else {
return '<span class="green-font">' . $item['plugin_status'] . '</span>';
}
Expand Down
7 changes: 4 additions & 3 deletions includes/class-angelleye-updater-update-checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public function __construct($file, $product_id, $file_id, $license_hash = '') {
*/
public function init() {
// Check For Updates
add_filter('pre_set_site_transient_update_plugins', array($this, 'update_check'), 0);
add_filter('pre_set_site_transient_update_plugins', array($this, 'update_check'), 20, 1);

// Check For Plugin Information
add_filter('plugins_api', array($this, 'plugin_information'), 0, 3);
add_filter( "upgrader_post_install", array( $this, "angelleye_post_install" ), 10, 3 );
add_filter('plugins_api', array($this, 'plugin_information'), 20, 3);
add_filter( "upgrader_post_install", array( $this, "angelleye_post_install" ), 20, 3 );
}

// End init()
Expand All @@ -80,6 +80,7 @@ public function init() {
*/
public function update_check($transient) {


// Check if the transient contains the 'checked' information
// If no, just return its value without hacking it
if (empty($transient->checked))
Expand Down
7 changes: 5 additions & 2 deletions includes/class-angelleye-updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ class AngellEYE_Updater {
public function __construct($file) {

$this->plugin_name = 'angelleye-updater';
$this->version = '2.0.10';

if (defined('AU_PLUGIN_VERSION')) {
$this->version = AU_PLUGIN_VERSION;
} else {
$this->version = '2.0.11';
}
$this->angelleye_plugin_more_info_page = array(
'paypal-ipn-for-wordpress-forwarder' => array(
'web_page' => 'https://www.angelleye.com/product/wordpress-paypal-ipn-forwarder/'
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
Tags: angelleye, activation, extensions, updates
Requires at least: 3.0.1
Tested up to: 5.4.1
Stable tag: 2.0.10
Stable tag: 2.0.11
License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html

Expand Down
3 changes: 3 additions & 0 deletions screens/screen-manage.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php if (!defined('ABSPATH')) exit; // Exit if accessed directly ?>

<div id="col-container" class="about-wrap">
<div class="ag-helper">
<a class="button button-update" href="<?php echo esc_url( $refresh_url ); ?>"><span class="dashicons dashicons-image-rotate"></span> <?php _e( 'Update', 'woocommerce' ); ?></a>
</div>

<div class="col-wrap">
<form id="activate-products" method="post" action="" class="validate">
Expand Down

0 comments on commit f238b8a

Please sign in to comment.