Changeset 1662019
- Timestamp:
- 05/22/2017 07:06:04 AM (9 years ago)
- Location:
- wp-rest-api-contact
- Files:
-
- 9 edited
-
assets/readme.txt (modified) (3 diffs)
-
trunk/includes/api-custom/class.wprac-api-contact-controller.php (modified) (3 diffs)
-
trunk/includes/api-custom/class.wprac-api-newsletter-controller.php (modified) (3 diffs)
-
trunk/includes/class.wprac-custom-controller.php (modified) (1 diff)
-
trunk/js/admin-js.js (modified) (4 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/views/backend/contact/config-contacts.php (modified) (1 diff)
-
trunk/views/backend/newsletter/config-newsletter.php (modified) (1 diff)
-
trunk/wp-rest-api-npa.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-rest-api-contact/assets/readme.txt
r1661938 r1662019 5 5 Requires at least: 4.5 6 6 Tested up to: 4.7.4 7 Stable tag: 1.0. 57 Stable tag: 1.0.6 8 8 License: MIT 9 9 License URI: http://opensource.org/licenses/MIT … … 33 33 == Changelog == 34 34 35 = 1.0.6 = 36 * Generate token for Contact API / Subscribe Newsletter API . 37 35 38 = 1.0.5 = 36 39 * New Page: NPA Tools . … … 52 55 53 56 == Upgrade Notice == 57 58 = 1.0.6 = 59 * Generate token for Contact API / Subscribe Newsletter API . 54 60 55 61 = 1.0.5 = -
wp-rest-api-contact/trunk/includes/api-custom/class.wprac-api-contact-controller.php
r1658980 r1662019 51 51 // Notification count in Newsletter Admin Menu. 52 52 add_action('admin_menu', array($instance, 'wprac_notification_count_in_contact_menu')); 53 54 // Đăng ký ajax 55 add_action('wp_ajax_do_generate_contact_token', array($instance, 'do_generate_contact_token')); 53 56 return $instance; 54 57 } … … 335 338 echo '<input name="contact-config-custom" type="checkbox" '.$checked.'>'; 336 339 }, 'tp-contact-config', 'tp_contact_options_section'); 337 338 339 340 } 340 341 public static function wprac_save_data($input){ … … 343 344 echo '</pre>'; 344 345 return $input; 346 } 347 348 //==================================== 349 // Hàm xử lý ajax generate token 350 //==================================== 351 public static function do_generate_contact_token() { 352 $instance = self::getInstance(); 353 354 $retrieved_nonce = $_POST["wprac_generate_contact_token_security"]; 355 356 if ( !wp_verify_nonce( $retrieved_nonce,'wprac_generate_contact_token_action') ) { 357 358 wp_send_json_success(array( 359 'status' => false, 360 'message' => 'Sorry, your nonce did not verify.' 361 )); 362 363 } 364 365 /************************************* 366 * Kiểm tra token contact option 367 *************************************/ 368 $token_contact_options = get_option('wprac-token-contact'); 369 if(!$token_contact_options){ 370 //tạo mới 371 add_option('wprac-token-contact', md5(uniqid(rand(), true)) ); 372 wp_send_json_success(array( 373 'status' => true, 374 'message' => 'Generate Token Successful !!!', 375 'token' => get_option('wprac-token-contact') 376 )); 377 }else{ 378 //update 379 update_option('wprac-token-contact', md5(uniqid(rand(), true)) ); 380 wp_send_json_success(array( 381 'status' => true, 382 'message' => 'Generate Token Successful !!!', 383 'token' => get_option('wprac-token-contact') 384 )); 385 } 345 386 } 346 387 -
wp-rest-api-contact/trunk/includes/api-custom/class.wprac-api-newsletter-controller.php
r1658980 r1662019 44 44 // Đăng ký ajax 45 45 add_action('wp_ajax_do_send_mail_newsletter', array($instance, 'do_send_mail_newsletter')); 46 add_action('wp_ajax_do_generate_newsletter_token', array($instance, 'do_generate_newsletter_token')); 46 47 47 48 // Notification count in Newsletter Admin Menu. … … 261 262 262 263 //==================================== 263 // Hàm xử lý ajax 264 // Hàm xử lý ajax send mail 264 265 //==================================== 265 266 public static function do_send_mail_newsletter() { … … 337 338 } 338 339 340 } 341 } 342 343 //==================================== 344 // Hàm xử lý ajax generate token 345 //==================================== 346 public static function do_generate_newsletter_token() { 347 $instance = self::getInstance(); 348 349 $retrieved_nonce = $_POST["wprac_generate_newsletter_token_security"]; 350 351 if ( !wp_verify_nonce( $retrieved_nonce,'wprac_generate_newsletter_token_action') ) { 352 353 wp_send_json_success(array( 354 'status' => false, 355 'message' => 'Sorry, your nonce did not verify.' 356 )); 357 358 } 359 360 /************************************* 361 * Kiểm tra token newsletter option 362 *************************************/ 363 $token_newsletter_options = get_option('wprac-token-newsletter'); 364 if(!$token_newsletter_options){ 365 //tạo mới 366 add_option('wprac-token-newsletter', md5(uniqid(rand(), true)) ); 367 wp_send_json_success(array( 368 'status' => true, 369 'message' => 'Generate Token Successful !!!', 370 'token' => get_option('wprac-token-newsletter') 371 )); 372 }else{ 373 //update 374 update_option('wprac-token-newsletter', md5(uniqid(rand(), true)) ); 375 wp_send_json_success(array( 376 'status' => true, 377 'message' => 'Generate Token Successful !!!', 378 'token' => get_option('wprac-token-newsletter') 379 )); 339 380 } 340 381 } -
wp-rest-api-contact/trunk/includes/class.wprac-custom-controller.php
r1661938 r1662019 163 163 164 164 // truyền dữ liệu qua admin-js.js 165 wp_localize_script('tp_admin_js', 'wprac_a pi_newsletter', array(165 wp_localize_script('tp_admin_js', 'wprac_ajax_config', array( 166 166 "url" => admin_url('admin-ajax.php') 167 167 )); -
wp-rest-api-contact/trunk/js/admin-js.js
r1654887 r1662019 1 1 jQuery(document).ready(function() { 2 2 /********************************************* 3 * AJAX SEND MAIL - Subcribe Newsletter Module 4 *********************************************/ 3 5 jQuery("#check_sm_all_non").click(function(event){ 4 6 jQuery('.select-multi-email').show(); … … 10 12 jQuery('#submit-newsletter-sendmail').click(function(event) { 11 13 event.preventDefault(); //tránh load lại trang 12 // console.log(wprac_a pi_newsletter);14 // console.log(wprac_ajax_config); 13 15 jQuery('.wprac-loading').show(); // hiển thị icon loading 14 16 jQuery('#submit-newsletter-sendmail').prop('disabled', true); // khóa nút submit … … 30 32 //AJAX 31 33 jQuery.ajax({ 32 'url' : wprac_a pi_newsletter.url,34 'url' : wprac_ajax_config.url, 33 35 'type' : 'POST', 34 36 'data' : { … … 100 102 }, animationLength); 101 103 } 104 105 /********************************************* 106 * Generate Newsletter Token - Subcribe Newsletter Module 107 *********************************************/ 108 jQuery("#submit-generate-newsletter-token").click(function(event){ 109 event.preventDefault(); //tránh load lại trang 110 if(confirm('WOULD YOU LIKE TO GENEGATE A NEW TOKEN???\nYOU WILL HAVE TO CHANGE THE API ROUTE!!!\nARE YOU SURE TO DO THIS???')){ 111 112 var nonce = jQuery('[name="wprac_generate_newsletter_token_security"]').val(); 113 // console.log(wprac_ajax_config); 114 //AJAX 115 jQuery.ajax({ 116 'url' : wprac_ajax_config.url, 117 'type' : 'POST', 118 'data' : { 119 'action' : 'do_generate_newsletter_token', 120 'wprac_generate_newsletter_token_security' : nonce 121 } 122 }).done(function(result) { 123 // console.log(result); 124 if(result.data.status){ 125 jQuery('#wprac_input_generate_newsletter_token').val(result.data.token); 126 jQuery('#wprac-message-success p').html(''); 127 jQuery('#wprac-message-success p').append(result.data.message); 128 jQuery('#wprac-message-success').fadeIn("slow"); 129 }else{ 130 131 } 132 }); 133 }else{ 134 console.log('cancel'); 135 } 136 }); 137 138 /********************************************* 139 * Generate Contact Token - Subcribe Contact Module 140 *********************************************/ 141 jQuery("#submit-generate-contact-token").click(function(event){ 142 event.preventDefault(); //tránh load lại trang 143 if(confirm('WOULD YOU LIKE TO GENEGATE A NEW TOKEN???\nYOU WILL HAVE TO CHANGE THE API ROUTE!!!\nARE YOU SURE TO DO THIS???')){ 144 145 var nonce = jQuery('[name="wprac_generate_contact_token_security"]').val(); 146 // console.log(wprac_ajax_config); 147 //AJAX 148 jQuery.ajax({ 149 'url' : wprac_ajax_config.url, 150 'type' : 'POST', 151 'data' : { 152 'action' : 'do_generate_contact_token', 153 'wprac_generate_contact_token_security' : nonce 154 } 155 }).done(function(result) { 156 // console.log(result); 157 if(result.data.status){ 158 jQuery('#wprac_input_generate_contact_token').val(result.data.token); 159 jQuery('#wprac-message-success-generate-token p').html(''); 160 jQuery('#wprac-message-success-generate-token p').append(result.data.message); 161 jQuery('#wprac-message-success-generate-token').fadeIn("slow"); 162 }else{ 163 164 } 165 }); 166 }else{ 167 console.log('cancel'); 168 } 169 }); 170 102 171 }); 103 172 -
wp-rest-api-contact/trunk/readme.txt
r1661938 r1662019 5 5 Requires at least: 4.5 6 6 Tested up to: 4.7.4 7 Stable tag: 1.0. 57 Stable tag: 1.0.6 8 8 License: MIT 9 9 License URI: http://opensource.org/licenses/MIT … … 33 33 == Changelog == 34 34 35 = 1.0.6 = 36 * Generate token for Contact API / Subscribe Newsletter API . 37 35 38 = 1.0.5 = 36 39 * New Page: NPA Tools . … … 52 55 53 56 == Upgrade Notice == 57 58 = 1.0.6 = 59 * Generate token for Contact API / Subscribe Newsletter API . 54 60 55 61 = 1.0.5 = -
wp-rest-api-contact/trunk/views/backend/contact/config-contacts.php
r1658980 r1662019 50 50 51 51 <h1>Token for WP REST API Contact</h1> 52 <input type="text" onfocus="this.select();" readonly="readonly" value="<?php echo $token; ?>" class="code" style="width:50%"> 52 <div id="wprac-message-success-generate-token" style="color: green; font-weight: bold;"> 53 <p></p> 54 </div> 55 <input id="wprac_input_generate_contact_token" type="text" onfocus="this.select();" readonly="readonly" value="<?php echo $token; ?>" class="code" style="width:50%"> 56 <?php wp_nonce_field( 'wprac_generate_contact_token_action', 'wprac_generate_contact_token_security'); ?> 57 <button id="submit-generate-contact-token" class="button button-primary">Generate Token </button> 53 58 54 59 <div class="contact-api-info"> -
wp-rest-api-contact/trunk/views/backend/newsletter/config-newsletter.php
r1658980 r1662019 41 41 </tfoot> 42 42 </table> 43 43 <br> 44 44 <h1>Token for WP REST API Newsletter</h1> 45 <input type="text" onfocus="this.select();" readonly="readonly" value="<?php echo $token; ?>" class="code" style="width:50%"> 45 <div id="wprac-message-success" style="color: green; font-weight: bold;"> 46 <p></p> 47 </div> 48 <input id="wprac_input_generate_newsletter_token" type="text" onfocus="this.select();" readonly="readonly" value="<?php echo $token; ?>" class="code" style="width:50%"> 49 <?php wp_nonce_field( 'wprac_generate_newsletter_token_action', 'wprac_generate_newsletter_token_security'); ?> 50 <button id="submit-generate-newsletter-token" class="button button-primary">Generate Token </button> 46 51 47 52 <div class="contact-api-info"> -
wp-rest-api-contact/trunk/wp-rest-api-npa.php
r1661938 r1662019 5 5 Description: Create REST API endpoint for Contact and Subscribe Newsletter, manager to list all contacts, manager to list all subscribe newsletter, send mail to the list all subscibers. 6 6 Author: Thien Pham, NPA 7 Version: 1.0. 57 Version: 1.0.6 8 8 Author URI: https://www.facebook.com/thien.pham.5074 9 9 Text Domain: tp-custom … … 18 18 } 19 19 20 define('WPRAC_VERSION', '1.0. 5');20 define('WPRAC_VERSION', '1.0.6'); 21 21 define('WPRAC_MINIMUM_WP_VERSION', '4.6'); 22 22 define('WPRAC_PLUGIN_URL', plugin_dir_url(__FILE__));
Note: See TracChangeset
for help on using the changeset viewer.