Changeset 479547
- Timestamp:
- 12/22/2011 09:32:36 PM (14 years ago)
- Location:
- custom-sidebars/branches/nightly
- Files:
-
- 3 edited
-
cs.js (modified) (2 diffs)
-
customsidebars.php (modified) (2 diffs)
-
view-widgets-sidebar.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
custom-sidebars/branches/nightly/cs.js
r478228 r479547 176 176 var ajaxdata = { 177 177 action: 'cs-wpnonce', 178 nonce: 'show-create-sidebar' 178 nonce_action: 'cs-create-sidebar', 179 nonce_nonce: $('#_nonce_nonce').val() 179 180 }; 180 if(!$('.new-sidebar-holder').is(':visible')){ 181 $('#new-sidebar').append($('#new-sidebar-form')); 182 $('.new-sidebar-holder').hide().detach().insertAfter('#cs-title-options').slideDown().children(".sidebar-name").click(function(){var h=$(this).siblings(".widgets-sortables"),g=$(this).parent();if(!g.hasClass("closed")){h.sortable("disable");g.addClass("closed")}else{g.removeClass("closed");h.sortable("enable").sortable("refresh")}}); 183 } 181 $.post(ajaxurl, ajaxdata, function(response){ 182 if(!$('.new-sidebar-holder').is(':visible')){ 183 $('#_nonce_nonce').val(response.nonce_nonce); 184 $('#_create_nonce').val(response.nonce); 185 $('#new-sidebar').append($('#new-sidebar-form')); 186 $('.new-sidebar-holder').hide().detach().insertAfter('#cs-title-options').slideDown().children(".sidebar-name").click(function(){var h=$(this).siblings(".widgets-sortables"),g=$(this).parent();if(!g.hasClass("closed")){h.sortable("disable");g.addClass("closed")}else{g.removeClass("closed");h.sortable("enable").sortable("refresh")}}); 187 } 188 }, 'json'); 184 189 return false; 185 190 }); 191 } 192 193 setCreateSidebar = function($){ 194 $('#cs-create-sidebar').click(function(){ 195 var ajaxdata = { 196 action: 'cs-create-sidebar', 197 nonce: $('#_create_nonce').val(), 198 name: $('#sidebar_name').val(), 199 description: $('#sidebar_description').val() 200 }; 201 202 $.post(ajaxurl, ajaxdata, function(response){ 203 204 }, 'json'); 205 206 return false; 207 }); 186 208 } 187 209 … … 191 213 addCSControls($); 192 214 showCreateSidebar($); 215 setCreateSidebar($); 193 216 }); -
custom-sidebars/branches/nightly/customsidebars.php
r478228 r479547 874 874 return 1 + $this->getCategoryLevel($cat->category_parent); 875 875 } 876 877 function jsonResponse($obj){ 878 header('Content-Type: application/json'); 879 echo json_encode($obj); 880 die(); 881 } 882 883 function ajaxCreateNonce(){ 884 $nonce = $_POST['nonce_nonce']; 885 $action = $_POST['nonce_action']; 886 if(! wp_verify_nonce($nonce, 'cs-wpnonce')) 887 die('malo'); 888 889 $this->jsonResponse(array( 890 nonce_nonce => wp_create_nonce('cs-wpnonce'), 891 nonce => wp_create_nonce($action) 892 )); 893 } 894 895 function ajaxCreateSidebar(){ 896 $nonce = $_POST['nonce']; 897 if(! wp_verify_nonce($nonce, 'cs-create-sidebar')) 898 $this->jsonResponse (array( 899 success => false, 900 message => __('The operation is not secure and it cannot be completed.','custom-sidebars') 901 )); 902 903 $this->storeSidebar(); 904 905 if($this->message_class == 'error') 906 $this->jsonResponse (array( 907 success => false, 908 message => $this->message 909 )); 910 911 $this->jsonResponse (array( 912 success => true, 913 message => __('The sidebar has been created successfully.','custom-sidebars'), 914 name => trim($_POST['sidebar_name']), 915 description => trim($_POST['sidebar_description']), 916 id => $this->sidebar_prefix . sanitize_title_with_dashes($name) 917 )); 918 } 876 919 } 877 920 endif; //exists class … … 888 931 add_action( 'init', array($plugin_sidebars,'loadTextDomain')); 889 932 add_action( 'admin_enqueue_scripts', array($plugin_sidebars,'addStyles')); 933 //AJAX actions 934 add_action( 'wp_ajax_cs-wpnonce', array($plugin_sidebars, 'ajaxCreateNonce')); 935 add_action( 'wp_ajax_cs-create-sidebar', array($plugin_sidebars, 'ajaxCreateSidebar')); 936 890 937 } 891 938 if(! class_exists('CustomSidebarsEmptyPlugin')){ -
custom-sidebars/branches/nightly/view-widgets-sidebar.php
r478228 r479547 25 25 <div id="new-sidebar-form"> 26 26 <form action="themes.php?page=customsidebars" method="post"> 27 <?php wp_nonce_field( 'custom-sidebars-new');?> 27 <?php wp_nonce_field( 'cs-create-sidebar', '_create_nonce');?> 28 <?php wp_nonce_field( 'cs-wpnonce', '_nonce_nonce');?> 28 29 <div id="namediv"> 29 30 <label for="sidebar_name"><?php _e('Name','custom-sidebars'); ?></label> 30 <input type="text" name="sidebar_name" size="30" tabindex="1" value="" id=" link_name" />31 <input type="text" name="sidebar_name" size="30" tabindex="1" value="" id="sidebar_name" /> 31 32 <p class="description"><?php _e('The name has to be unique.','custom-sidebars')?></p> 32 33 </div> … … 34 35 <div id="addressdiv"> 35 36 <label for="sidebar_description"><?php echo _e('Description','custom-sidebars'); ?></label> 36 <input type="text" name="sidebar_description" size="30" class="code" tabindex="1" value="" id=" link_url" />37 <input type="text" name="sidebar_description" size="30" class="code" tabindex="1" value="" id="sidebar_description" /> 37 38 </div> 38 <p class="submit"><input type="submit" class="button-primary" name="create-sidebars" value="<?php _e('Create Sidebar','custom-sidebars'); ?>" /></p>39 <p class="submit"><input type="submit" class="button-primary" id="cs-create-sidebar" name="cs-create-sidebar" value="<?php _e('Create Sidebar','custom-sidebars'); ?>" /></p> 39 40 </form> 40 41 </div>
Note: See TracChangeset
for help on using the changeset viewer.