Plugin Directory

Changeset 1662019


Ignore:
Timestamp:
05/22/2017 07:06:04 AM (9 years ago)
Author:
chithien175
Message:

update 1.0.6

Location:
wp-rest-api-contact
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • wp-rest-api-contact/assets/readme.txt

    r1661938 r1662019  
    55Requires at least: 4.5
    66Tested up to: 4.7.4
    7 Stable tag: 1.0.5
     7Stable tag: 1.0.6
    88License: MIT
    99License URI: http://opensource.org/licenses/MIT
     
    3333== Changelog ==
    3434
     35= 1.0.6 =
     36* Generate token for Contact API / Subscribe Newsletter API .
     37
    3538= 1.0.5 =
    3639* New Page: NPA Tools .
     
    5255
    5356== Upgrade Notice ==
     57
     58= 1.0.6 =
     59* Generate token for Contact API / Subscribe Newsletter API .
    5460
    5561= 1.0.5 =
  • wp-rest-api-contact/trunk/includes/api-custom/class.wprac-api-contact-controller.php

    r1658980 r1662019  
    5151        // Notification count in Newsletter Admin Menu.
    5252        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'));
    5356        return $instance;
    5457    }
     
    335338            echo '<input name="contact-config-custom" type="checkbox" '.$checked.'>';
    336339        }, 'tp-contact-config', 'tp_contact_options_section');
    337 
    338        
    339340    }
    340341    public static function wprac_save_data($input){
     
    343344        echo '</pre>';
    344345        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        }
    345386    }
    346387
  • wp-rest-api-contact/trunk/includes/api-custom/class.wprac-api-newsletter-controller.php

    r1658980 r1662019  
    4444        // Đăng ký ajax
    4545        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'));
    4647
    4748        // Notification count in Newsletter Admin Menu.
     
    261262
    262263    //====================================
    263     // Hàm xử lý ajax
     264    // Hàm xử lý ajax send mail
    264265    //====================================
    265266    public static function do_send_mail_newsletter() {
     
    337338            }
    338339           
     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            ));
    339380        }
    340381    }
  • wp-rest-api-contact/trunk/includes/class.wprac-custom-controller.php

    r1661938 r1662019  
    163163
    164164        // truyền dữ liệu qua admin-js.js
    165         wp_localize_script('tp_admin_js', 'wprac_api_newsletter', array(
     165        wp_localize_script('tp_admin_js', 'wprac_ajax_config', array(
    166166            "url" => admin_url('admin-ajax.php')
    167167        ));
  • wp-rest-api-contact/trunk/js/admin-js.js

    r1654887 r1662019  
    11jQuery(document).ready(function() {
    2 
     2    /*********************************************
     3     * AJAX SEND MAIL - Subcribe Newsletter Module
     4     *********************************************/
    35    jQuery("#check_sm_all_non").click(function(event){
    46        jQuery('.select-multi-email').show();
     
    1012    jQuery('#submit-newsletter-sendmail').click(function(event) {
    1113        event.preventDefault();             //tránh load lại trang
    12         // console.log(wprac_api_newsletter);
     14        // console.log(wprac_ajax_config);
    1315        jQuery('.wprac-loading').show();    // hiển thị icon loading
    1416        jQuery('#submit-newsletter-sendmail').prop('disabled', true); // khóa nút submit
     
    3032        //AJAX
    3133        jQuery.ajax({
    32             'url' : wprac_api_newsletter.url,
     34            'url' : wprac_ajax_config.url,
    3335            'type' : 'POST',
    3436            'data' : {
     
    100102        }, animationLength);
    101103    }
     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
    102171});
    103172
  • wp-rest-api-contact/trunk/readme.txt

    r1661938 r1662019  
    55Requires at least: 4.5
    66Tested up to: 4.7.4
    7 Stable tag: 1.0.5
     7Stable tag: 1.0.6
    88License: MIT
    99License URI: http://opensource.org/licenses/MIT
     
    3333== Changelog ==
    3434
     35= 1.0.6 =
     36* Generate token for Contact API / Subscribe Newsletter API .
     37
    3538= 1.0.5 =
    3639* New Page: NPA Tools .
     
    5255
    5356== Upgrade Notice ==
     57
     58= 1.0.6 =
     59* Generate token for Contact API / Subscribe Newsletter API .
    5460
    5561= 1.0.5 =
  • wp-rest-api-contact/trunk/views/backend/contact/config-contacts.php

    r1658980 r1662019  
    5050
    5151    <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>
    5358
    5459    <div class="contact-api-info">
  • wp-rest-api-contact/trunk/views/backend/newsletter/config-newsletter.php

    r1658980 r1662019  
    4141        </tfoot>
    4242    </table>
    43 
     43    <br>
    4444    <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>
    4651
    4752    <div class="contact-api-info">
  • wp-rest-api-contact/trunk/wp-rest-api-npa.php

    r1661938 r1662019  
    55Description: 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.
    66Author: Thien Pham, NPA
    7 Version: 1.0.5
     7Version: 1.0.6
    88Author URI: https://www.facebook.com/thien.pham.5074
    99Text Domain: tp-custom
     
    1818}
    1919
    20 define('WPRAC_VERSION', '1.0.5');
     20define('WPRAC_VERSION', '1.0.6');
    2121define('WPRAC_MINIMUM_WP_VERSION', '4.6');
    2222define('WPRAC_PLUGIN_URL', plugin_dir_url(__FILE__));
Note: See TracChangeset for help on using the changeset viewer.