Skip to content

Commit 2f90634

Browse files
committed
* 'master' of https://github.com/ReduxFramework/ReduxFramework: EDD field works # Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
2 parents 9ee1e7d + 11af84e commit 2f90634

File tree

3 files changed

+64
-59
lines changed

3 files changed

+64
-59
lines changed
Lines changed: 50 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,50 @@
1-
/*global jQuery, document */
2-
(function($){
3-
'use strict';
4-
5-
$.redux = $.redux || {};
6-
7-
$(document).ready(function(){
8-
$.redux.edd();
9-
});
10-
11-
$.redux.edd = function(){
12-
13-
jQuery('.redux-edd-input').change(function() {
14-
jQuery(this).parent().find('.redux-edd-status').val('');
15-
});
16-
jQuery( document ).on( "click", ".redux-EDDAction", function(e) {
17-
e.preventDefault();
18-
var parent = jQuery(this).parents('.redux-container-edd_license:first');
19-
var id = jQuery(this).attr('data-id');
20-
21-
var theData = {};
22-
parent.find('.redux-edd').each(function() {
23-
theData[jQuery(this).attr('id').replace(id+'-', '')] = jQuery(this).val();
24-
});
25-
theData['edd_action'] = jQuery(this).attr('data-edd_action');
26-
theData['opt_name'] = redux_opts.opt_name;
27-
28-
jQuery.post(
29-
ajaxurl, {
30-
'action': 'redux_edd_'+redux_opts.opt_name+'_license',
31-
'data': theData
32-
},
33-
function(response) {
34-
response = jQuery.parseJSON(response);
35-
console.log(response);
36-
jQuery('#'+id+'-status').val(response.status);
37-
jQuery('#'+id+'-status_notice').html(response.status);
38-
if (response.response === "valid") {
39-
//jQuery('#'+id+'-notice').switchClass( "big", "blue", 1000, "easeInOutQuad" );
40-
jQuery('#'+id+'-notice').attr('class', "redux-info-field redux-success" );
41-
} else if (response.response === "deactivated") {
42-
jQuery('#'+id+'-notice').attr('class', "redux-info-field redux-warning" );
43-
} else { // Inactive or bad
44-
45-
}
46-
47-
}
48-
);
49-
});
50-
51-
}
52-
53-
})(jQuery);
1+
/*global jQuery, document, redux_opts, ajaxurl */
2+
(function($) {
3+
'use strict';
4+
$.redux = $.redux || {};
5+
$(document).ready(function() {
6+
$.redux.edd();
7+
});
8+
$.redux.edd = function() {
9+
jQuery('.redux-edd-input').change(function() {
10+
jQuery(this).parent().find('.redux-edd-status').val('');
11+
});
12+
jQuery(document).on("click", ".redux-EDDAction", function(e) {
13+
e.preventDefault();
14+
var parent = jQuery(this).parents('.redux-container-edd_license:first');
15+
var id = jQuery(this).attr('data-id');
16+
var theData = {};
17+
parent.find('.redux-edd').each(function() {
18+
theData[jQuery(this).attr('id').replace(id + '-', '')] = jQuery(this).val();
19+
});
20+
theData.edd_action = jQuery(this).attr('data-edd_action');
21+
theData.opt_name = redux_opts.opt_name;
22+
jQuery.post(
23+
ajaxurl, {
24+
'action': 'redux_edd_' + redux_opts.opt_name + '_license',
25+
'data': theData
26+
}, function(response) {
27+
response = jQuery.parseJSON(response);
28+
jQuery('#' + id + '-status').val(response.status);
29+
jQuery('#' + id + '-status_notice').html(response.status);
30+
if (response.response === "valid") {
31+
//jQuery('#'+id+'-notice').switchClass( "big", "blue", 1000, "easeInOutQuad" );
32+
jQuery('#' + id + '-notice').attr('class', "redux-info-field redux-success");
33+
jQuery('#' + id + '-activate').fadeOut('medium', function() {
34+
jQuery('#' + id + '-deactivate').fadeIn().css("display", "inline-block");
35+
});
36+
} else if (response.response === "deactivated") {
37+
jQuery('#' + id + '-notice').attr('class', "redux-info-field redux-warning");
38+
jQuery('#' + id + '-deactivate').fadeOut('medium', function() {
39+
jQuery('#' + id + '-activate').fadeIn().css("display", "inline-block");
40+
});
41+
} else { // Inactive or bad
42+
jQuery('#' + id + '-deactivate').fadeOut('medium', function() {
43+
jQuery('#' + id + '-notice').attr('class', "redux-info-field redux-critical");
44+
jQuery('#' + id + '-activate').fadeIn().css("display", "inline-block");
45+
});
46+
}
47+
});
48+
});
49+
};
50+
})(jQuery);

ReduxCore/extensions/edd/edd_license/field_edd_license.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ReduxCore/extensions/edd/edd_license/field_edd_license.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ public function render() {
8686

8787
if ( !empty( $this->value['license'] ) ) {
8888
$transient = get_transient('redux_edd_license_'.$this->field['id'] . '_valid');
89-
echo $transient;
9089
if ( empty( $transient ) ) {
9190
$data = array(
9291
'edd_action' => 'check_license',
@@ -110,9 +109,10 @@ public function render() {
110109
} else {
111110
$this->value['status'] = __('Not Activated', 'redux-framework');
112111
}
112+
$this->value['status'] = ucfirst( $this->value['status'] );
113113

114114
if ( $this->value['status'] == __('Deactivated', 'redux-framework') ) {
115-
$noticeClasses = 'redux-info redux-info-field';
115+
$noticeClasses = 'redux-warning redux-info-field';
116116
} else if ( $this->value['status'] == __('Valid', 'redux-framework') ) {
117117
$noticeClasses = 'redux-success redux-info-field';
118118
} else {
@@ -129,9 +129,17 @@ public function render() {
129129
echo '<input type="hidden" class="redux-edd " type="text" id="' . $this->field['id'] . '-author" value="' . $this->field['author'] . '" " />';
130130
echo '<input name="' . $this->args['opt_name'] . '[' . $this->field['id'] . '][license]" id="' . $this->field['id'] . '-license" class="redux-edd-input redux-edd ' . $this->field['class'] . '" type="text" value="' . $this->value['license'] . '" " />';
131131
echo '<input type="hidden" name="' . $this->args['opt_name'] . '[' . $this->field['id'] . '][status]" id="' . $this->field['id'] . '-status" class="redux-edd redux-edd-status ' . $this->field['class'] . '" type="text" value="' . $this->value['status'] . '" " />';
132-
echo '&nbsp; <a href="#" data-id="'.$this->field['id'].'" class="button button-primary redux-EDDAction hide" data-edd_action="check_license">Verify License</a>';
133-
echo '&nbsp; <a href="#" data-id="'.$this->field['id'].'" class="button button-primary redux-EDDAction" data-edd_action="activate_license">Activate License</a>';
134-
echo '&nbsp; <a href="#" data-id="'.$this->field['id'].'" class="button redux-EDDAction" data-edd_action="deactivate_license">Deactivate License</a>';
132+
echo '<a href="#" data-id="'.$this->field['id'].'" class="button button-primary redux-EDDAction hide" data-edd_action="check_license">'.__('Verify License', 'redux-framework').'</a>';
133+
$hide = "";
134+
if ($this->value['status'] == "Valid") {
135+
$hide = " hide";
136+
}
137+
echo '&nbsp; <a href="#" id="'.$this->field['id'].'-activate" data-id="'.$this->field['id'].'" class="button button-primary redux-EDDAction'.$hide.'" data-edd_action="activate_license">'.__('Activate License', 'redux-framework').'</a>';
138+
$hide = "";
139+
if ($this->value['status'] != "Valid") {
140+
$hide = " hide";
141+
}
142+
echo '&nbsp; <a href="#" id="'.$this->field['id'].'-deactivate" data-id="'.$this->field['id'].'" class="button button-secondary redux-EDDAction'.$hide.'" data-edd_action="deactivate_license">'.__('Deactivate License', 'redux-framework').'</a>';
135143
if (isset($this->parent->args['edd'])) {
136144
foreach( $this->parent->args['edd'] as $k => $v ) {
137145
echo '<input type="hidden" data-id="'.$this->field['id'].'" id="' . $this->field['id'] . '-'.$k.'" class="redux-edd edd-'.$k.'" type="text" value="' . $v . '" " />';

0 commit comments

Comments
 (0)