From 11af84e6c9466216a811102f88e0ce7ebf177b08 Mon Sep 17 00:00:00 2001 From: Dovy Date: Wed, 20 Nov 2013 07:36:37 +0100 Subject: [PATCH] EDD field works --- .../edd/edd_license/field_edd_license.js | 103 +++++++++--------- .../edd/edd_license/field_edd_license.min.js | 2 +- .../edd/edd_license/field_edd_license.php | 18 ++- 3 files changed, 64 insertions(+), 59 deletions(-) diff --git a/ReduxCore/extensions/edd/edd_license/field_edd_license.js b/ReduxCore/extensions/edd/edd_license/field_edd_license.js index 7d89ee806..10dfbccc5 100644 --- a/ReduxCore/extensions/edd/edd_license/field_edd_license.js +++ b/ReduxCore/extensions/edd/edd_license/field_edd_license.js @@ -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); \ No newline at end of file diff --git a/ReduxCore/extensions/edd/edd_license/field_edd_license.min.js b/ReduxCore/extensions/edd/edd_license/field_edd_license.min.js index a01b63699..b75f97cbd 100644 --- a/ReduxCore/extensions/edd/edd_license/field_edd_license.min.js +++ b/ReduxCore/extensions/edd/edd_license/field_edd_license.min.js @@ -1 +1 @@ -/*global jQuery, document */(function(e){"use strict";e.redux=e.redux||{};e(document).ready(function(){e.redux.edd()});e.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 t=jQuery(this).parents(".redux-container-edd_license:first"),n=jQuery(this).attr("data-id"),r={};t.find(".redux-edd").each(function(){r[jQuery(this).attr("id").replace(n+"-","")]=jQuery(this).val()});r.edd_action=jQuery(this).attr("data-edd_action");r.opt_name=redux_opts.opt_name;jQuery.post(ajaxurl,{action:"redux_edd_"+redux_opts.opt_name+"_license",data:r},function(e){e=jQuery.parseJSON(e);console.log(e);jQuery("#"+n+"-status").val(e.status);jQuery("#"+n+"-status_notice").html(e.status);e.response==="valid"?jQuery("#"+n+"-notice").attr("class","redux-info-field redux-success"):e.response==="deactivated"&&jQuery("#"+n+"-notice").attr("class","redux-info-field redux-warning")})})}})(jQuery); \ No newline at end of file +/*global jQuery, document, redux_opts, ajaxurl */(function(e){"use strict";e.redux=e.redux||{};e(document).ready(function(){e.redux.edd()});e.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 t=jQuery(this).parents(".redux-container-edd_license:first"),n=jQuery(this).attr("data-id"),r={};t.find(".redux-edd").each(function(){r[jQuery(this).attr("id").replace(n+"-","")]=jQuery(this).val()});r.edd_action=jQuery(this).attr("data-edd_action");r.opt_name=redux_opts.opt_name;jQuery.post(ajaxurl,{action:"redux_edd_"+redux_opts.opt_name+"_license",data:r},function(e){e=jQuery.parseJSON(e);jQuery("#"+n+"-status").val(e.status);jQuery("#"+n+"-status_notice").html(e.status);if(e.response==="valid"){jQuery("#"+n+"-notice").attr("class","redux-info-field redux-success");jQuery("#"+n+"-activate").fadeOut("medium",function(){jQuery("#"+n+"-deactivate").fadeIn().css("display","inline-block")})}else if(e.response==="deactivated"){jQuery("#"+n+"-notice").attr("class","redux-info-field redux-warning");jQuery("#"+n+"-deactivate").fadeOut("medium",function(){jQuery("#"+n+"-activate").fadeIn().css("display","inline-block")})}else jQuery("#"+n+"-deactivate").fadeOut("medium",function(){jQuery("#"+n+"-notice").attr("class","redux-info-field redux-critical");jQuery("#"+n+"-activate").fadeIn().css("display","inline-block")})})})}})(jQuery); \ No newline at end of file diff --git a/ReduxCore/extensions/edd/edd_license/field_edd_license.php b/ReduxCore/extensions/edd/edd_license/field_edd_license.php index 360d2e2bd..3ba30bda5 100644 --- a/ReduxCore/extensions/edd/edd_license/field_edd_license.php +++ b/ReduxCore/extensions/edd/edd_license/field_edd_license.php @@ -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', @@ -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 { @@ -129,9 +129,17 @@ public function render() { echo ''; echo ''; echo ''; - echo '  Verify License'; - echo '  Activate License'; - echo '  Deactivate License'; + echo ''.__('Verify License', 'redux-framework').''; + $hide = ""; + if ($this->value['status'] == "Valid") { + $hide = " hide"; + } + echo '  '.__('Activate License', 'redux-framework').''; + $hide = ""; + if ($this->value['status'] != "Valid") { + $hide = " hide"; + } + echo '  '.__('Deactivate License', 'redux-framework').''; if (isset($this->parent->args['edd'])) { foreach( $this->parent->args['edd'] as $k => $v ) { echo '';