Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…work

* '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.
  • Loading branch information
dovy committed Nov 20, 2013
2 parents 9ee1e7d + 11af84e commit 2f90634
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 59 deletions.
103 changes: 50 additions & 53 deletions ReduxCore/extensions/edd/edd_license/field_edd_license.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,50 @@
/*global jQuery, document */
(function($){
'use strict';

$.redux = $.redux || {};

$(document).ready(function(){
$.redux.edd();
});

$.redux.edd = function(){

jQuery('.redux-edd-input').change(function() {
jQuery(this).parent().find('.redux-edd-status').val('');
});
jQuery( document ).on( "click", ".redux-EDDAction", function(e) {
e.preventDefault();
var parent = jQuery(this).parents('.redux-container-edd_license:first');
var id = jQuery(this).attr('data-id');

var theData = {};
parent.find('.redux-edd').each(function() {
theData[jQuery(this).attr('id').replace(id+'-', '')] = jQuery(this).val();
});
theData['edd_action'] = jQuery(this).attr('data-edd_action');
theData['opt_name'] = redux_opts.opt_name;

jQuery.post(
ajaxurl, {
'action': 'redux_edd_'+redux_opts.opt_name+'_license',
'data': theData
},
function(response) {
response = jQuery.parseJSON(response);
console.log(response);
jQuery('#'+id+'-status').val(response.status);
jQuery('#'+id+'-status_notice').html(response.status);
if (response.response === "valid") {
//jQuery('#'+id+'-notice').switchClass( "big", "blue", 1000, "easeInOutQuad" );
jQuery('#'+id+'-notice').attr('class', "redux-info-field redux-success" );
} else if (response.response === "deactivated") {
jQuery('#'+id+'-notice').attr('class', "redux-info-field redux-warning" );
} else { // Inactive or bad

}

}
);
});

}

})(jQuery);
/*global jQuery, document, redux_opts, ajaxurl */
(function($) {
'use strict';
$.redux = $.redux || {};
$(document).ready(function() {
$.redux.edd();
});
$.redux.edd = function() {
jQuery('.redux-edd-input').change(function() {
jQuery(this).parent().find('.redux-edd-status').val('');
});
jQuery(document).on("click", ".redux-EDDAction", function(e) {
e.preventDefault();
var parent = jQuery(this).parents('.redux-container-edd_license:first');
var id = jQuery(this).attr('data-id');
var theData = {};
parent.find('.redux-edd').each(function() {
theData[jQuery(this).attr('id').replace(id + '-', '')] = jQuery(this).val();
});
theData.edd_action = jQuery(this).attr('data-edd_action');
theData.opt_name = redux_opts.opt_name;
jQuery.post(
ajaxurl, {
'action': 'redux_edd_' + redux_opts.opt_name + '_license',
'data': theData
}, function(response) {
response = jQuery.parseJSON(response);
jQuery('#' + id + '-status').val(response.status);
jQuery('#' + id + '-status_notice').html(response.status);
if (response.response === "valid") {
//jQuery('#'+id+'-notice').switchClass( "big", "blue", 1000, "easeInOutQuad" );
jQuery('#' + id + '-notice').attr('class', "redux-info-field redux-success");
jQuery('#' + id + '-activate').fadeOut('medium', function() {
jQuery('#' + id + '-deactivate').fadeIn().css("display", "inline-block");
});
} else if (response.response === "deactivated") {
jQuery('#' + id + '-notice').attr('class', "redux-info-field redux-warning");
jQuery('#' + id + '-deactivate').fadeOut('medium', function() {
jQuery('#' + id + '-activate').fadeIn().css("display", "inline-block");
});
} else { // Inactive or bad
jQuery('#' + id + '-deactivate').fadeOut('medium', function() {
jQuery('#' + id + '-notice').attr('class', "redux-info-field redux-critical");
jQuery('#' + id + '-activate').fadeIn().css("display", "inline-block");
});
}
});
});
};
})(jQuery);

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 13 additions & 5 deletions ReduxCore/extensions/edd/edd_license/field_edd_license.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public function render() {

if ( !empty( $this->value['license'] ) ) {
$transient = get_transient('redux_edd_license_'.$this->field['id'] . '_valid');
echo $transient;
if ( empty( $transient ) ) {
$data = array(
'edd_action' => 'check_license',
Expand All @@ -110,9 +109,10 @@ public function render() {
} else {
$this->value['status'] = __('Not Activated', 'redux-framework');
}
$this->value['status'] = ucfirst( $this->value['status'] );

if ( $this->value['status'] == __('Deactivated', 'redux-framework') ) {
$noticeClasses = 'redux-info redux-info-field';
$noticeClasses = 'redux-warning redux-info-field';
} else if ( $this->value['status'] == __('Valid', 'redux-framework') ) {
$noticeClasses = 'redux-success redux-info-field';
} else {
Expand All @@ -129,9 +129,17 @@ public function render() {
echo '<input type="hidden" class="redux-edd " type="text" id="' . $this->field['id'] . '-author" value="' . $this->field['author'] . '" " />';
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'] . '" " />';
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'] . '" " />';
echo '&nbsp; <a href="#" data-id="'.$this->field['id'].'" class="button button-primary redux-EDDAction hide" data-edd_action="check_license">Verify License</a>';
echo '&nbsp; <a href="#" data-id="'.$this->field['id'].'" class="button button-primary redux-EDDAction" data-edd_action="activate_license">Activate License</a>';
echo '&nbsp; <a href="#" data-id="'.$this->field['id'].'" class="button redux-EDDAction" data-edd_action="deactivate_license">Deactivate License</a>';
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>';
$hide = "";
if ($this->value['status'] == "Valid") {
$hide = " hide";
}
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>';
$hide = "";
if ($this->value['status'] != "Valid") {
$hide = " hide";
}
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>';
if (isset($this->parent->args['edd'])) {
foreach( $this->parent->args['edd'] as $k => $v ) {
echo '<input type="hidden" data-id="'.$this->field['id'].'" id="' . $this->field['id'] . '-'.$k.'" class="redux-edd edd-'.$k.'" type="text" value="' . $v . '" " />';
Expand Down

0 comments on commit 2f90634

Please sign in to comment.