Last active
December 21, 2015 00:49
-
-
Save ninnypants/6223592 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($){ | |
$(document).ready(function(){ | |
$('a').click(function(e){ | |
var el = $(this).prev('input[type="checkbox"]'); | |
if(el.is(':checked')){ | |
el.prop('checked',false); | |
} | |
$.ajax({ | |
url : 'http://localhost/wordpress/wp-admin/admin-ajax.php', | |
type : 'POST', | |
data : { | |
action : 'uncheck_package', | |
element_value : el.val() | |
}, | |
success: function(result){ | |
console.log(result); | |
}, | |
error: function(jqXHR, textStatus, errorThrown ){ | |
console.log(jqXHR, textStatus, errorThrown); | |
} | |
}) | |
e.preventDefault(); | |
}); | |
}); | |
})(jQuery); | |
<?php | |
function uncheck_package(){ | |
if(isset($_POST['element_value'])){ | |
$element = $_POST['element_value']; | |
} | |
if(isset($element)){ | |
$option = get_option('aisis_options'); | |
if(isset($option[$element])){ | |
$option[$element] = 'test'; | |
echo json_encode(update_option('aisis_options', $option)); | |
exit; | |
} | |
} | |
} | |
add_action( 'wp_ajax_nopriv_uncheck_package', 'uncheck_package' ); | |
add_action( 'wp_ajax_uncheck_package', 'uncheck_package' ); | |
// Out put - in the order of the above var-dumps, echos and final var_dump | |
//This is as top down as it gets. | |
print_r($option[$element]) | |
package_RelatedPosts | |
//echo json_encode(update_option($option[$element], 'test')) | |
true | |
//print_r($option) | |
Array | |
( | |
[category_header] => | |
[author_posts] => | |
[tag_header] => | |
[carousel_global] => | |
[carousel_home] => | |
[carousel_single] => | |
[mini_feed_global] => | |
[mini_feed_home] => | |
[mini_feed_single] => | |
[author_image] => | |
[author_bio] => | |
[author_sidebar] => | |
[jumbotron] => | |
[socialbar] => | |
[category_description] => | |
[category_tags] => | |
[category_sidebar] => | |
[tag_description] => | |
[tag_sidebar] => | |
[twitter_admin] => | |
[package_Aisis-Related-Posts-Package-master] => package_Aisis-Related-Posts-Package-master | |
[package_RelatedPosts] => package_RelatedPosts // -> should be test | |
[package_TextShortCodes] => package_TextShortCodes | |
[lists_more_posts] => | |
[lists_more_posts_rows] => | |
[jumbo_title] => | |
[jumbo_text] => | |
[jumbo_image] => | |
[jumbo_link] => | |
[social] => Array | |
( | |
[facebook] => | |
[twitter] => | |
[google-plus] => | |
[linkedin] => | |
[github] => | |
) | |
[footer_text] => | |
) | |
0 //WP -Ajax Return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment