Plugin Directory

Changeset 1656319


Ignore:
Timestamp:
05/13/2017 04:03:35 AM (9 years ago)
Author:
chithien175
Message:

update 1.0.3

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

Legend:

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

    r1655229 r1656319  
    11=== WP REST API NPA ===
    2 Contributors: Thien Pham NPA
     2Contributors: Thien Pham, NPA
    33Donate link: https://www.paypal.me/ThienPham175
    44Tags: wp rest api contact, rest api contact, api contact, wp rest api newsletter, rest api newsletter, api newsletter
    55Requires at least: 4.5
    66Tested up to: 4.7.4
    7 Stable tag: 1.0.2
     7Stable tag: 1.0.3
    88License: MIT
    99License URI: http://opensource.org/licenses/MIT
     
    3535== Changelog ==
    3636
     37= 1.0.3 =
     38* Show notification bubble icon when there is a new subscription .
     39
    3740= 1.0.2 =
    3841* Create WP Rest API Subscribe Newsletter.
     
    4548
    4649== Upgrade Notice ==
     50
     51= 1.0.3 =
     52* Show notification bubble icon when there is a new subscription .
    4753
    4854= 1.0.2 =
  • wp-rest-api-contact/trunk/css/admin-style.css

    r1654887 r1656319  
    4949  display: none;
    5050}
     51
  • wp-rest-api-contact/trunk/includes/api-custom/class.wprac-api-contact-controller.php

    r1656300 r1656319  
    4848        // Đăng ký fields cho trang contact config
    4949        add_action( 'admin_init', array( $instance, 'wprac_setup_contact_options' ) );
     50
     51        // Notification count in Newsletter Admin Menu.
     52        add_action('admin_menu', array($instance, 'wprac_notification_count_in_contact_menu'));
    5053        return $instance;
    5154    }
     
    8083            city varchar(255) NOT NULL,
    8184            content text NOT NULL,
    82             status int(1) DEFAULT 1 NOT NULL,
     85            status int(1) DEFAULT 0 NOT NULL,
    8386            time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL
    8487        ) $charset_collate;";
     
    273276        $instance = self::getInstance();
    274277
     278        //update status newsletter = 1
     279        $sql = 'SELECT id FROM '.self::$table.' WHERE status = 0';
     280        $list_mails_status_0 = self::$wpdb->get_results( $sql, ARRAY_A );
     281
     282        if($list_mails_status_0){
     283            // print_r($list_mails_status_0);
     284            // die();
     285            foreach ($list_mails_status_0 as $value) {
     286                self::$wpdb->update(self::$table, array('status' => 1), array('id' => $value['id']));
     287            }
     288        }
     289       
     290        //----------------------------
     291
    275292        $contacts_obj = new WPRAC_Contact_List();
    276293       
     
    279296        return $instance;
    280297    }
    281 
     298    //view config page
    282299    public static function wprac_config_page(){
    283300        $instance = self::getInstance();
     
    313330        echo '</pre>';
    314331        return $input;
    315 
     332    }
     333
     334    //====================================
     335    // Notification bubble for newsletter menu
     336    //====================================
     337    public static function wprac_notification_count_in_contact_menu()
     338    {
     339        $instance = self::getInstance();
     340
     341        global $menu;
     342       
     343        $sql = 'SELECT COUNT(id) as count FROM '.self::$table.' WHERE status=0';
     344       
     345        $post_count = self::$wpdb->get_var($sql);
     346   
     347        if(!empty($post_count))
     348        {
     349            foreach ( (array)$menu as $key => $item )
     350            {
     351                if ( $item[2] == 'tp-contact' )
     352                {
     353                    $menu[$key][0] = $menu[$key][0].' <span class="update-plugins count-'.$post_count.'"><span class="plugin-count" aria-hidden="true">'.$post_count.'</span><span class="screen-reader-text">'.$post_count.' notifications</span></span>';
     354                }
     355            }
     356        }
     357       
     358        return $instance;
    316359    }
    317360   
  • wp-rest-api-contact/trunk/includes/api-custom/class.wprac-api-newsletter-controller.php

    r1656300 r1656319  
    4545        add_action('wp_ajax_do_send_mail_newsletter', array($instance, 'do_send_mail_newsletter'));
    4646
    47         //Add hook to Admin Menu.
    48         // add_action('admin_menu', array($instance, 'notification_count_in_admin_menu'));
     47        // Notification count in Newsletter Admin Menu.
     48        add_action('admin_menu', array($instance, 'wprac_notification_count_in_newsletter_menu'));
    4949
    5050        return $instance;
     
    7575        $sql = "CREATE TABLE IF NOT EXISTS $table (
    7676            email varchar(255) NOT NULL PRIMARY KEY,
    77             status int(1) DEFAULT 1 NOT NULL,
     77            status int(1) DEFAULT 0 NOT NULL,
    7878            time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL
    7979        ) $charset_collate;";
     
    213213        $instance = self::getInstance();
    214214
     215        //update status newsletter = 1
     216        $sql = 'SELECT email FROM '.self::$table.' WHERE status = 0';
     217        $list_mails_status_0 = self::$wpdb->get_results( $sql, ARRAY_A );
     218
     219        if($list_mails_status_0){
     220            // print_r($list_mails_status_0);
     221            // die();
     222            foreach ($list_mails_status_0 as $value) {
     223                self::$wpdb->update(self::$table, array('status' => 1), array('email' => $value['email']));
     224            }
     225        }
     226       
     227        //----------------------------
    215228        $newsletter_obj = new WPRAC_Newsletter_List();
    216229       
     
    225238        $table = self::$table;
    226239
    227         $sql = 'SELECT email FROM '.$table.' WHERE status = 1';
     240        $sql = 'SELECT email FROM '.$table.'';
    228241        $list_mails = self::$wpdb->get_results( $sql, ARRAY_A );
    229242
     
    325338    }
    326339
    327     public static function notification_count_in_admin_menu()
     340
     341    //====================================
     342    // Notification bubble for newsletter menu
     343    //====================================
     344    public static function wprac_notification_count_in_newsletter_menu()
    328345    {
    329346        $instance = self::getInstance();
    330347
    331348        global $menu;
    332         // echo "<pre>";
    333         // print_r($menu);
    334         // echo "</pre>";
    335         // die();
    336349       
    337         $post_count = 1;
     350        $sql = 'SELECT COUNT(email) as count FROM '.self::$table.' WHERE status=0';
     351       
     352        $post_count = self::$wpdb->get_var($sql);
     353   
    338354        if(!empty($post_count))
    339355        {
    340356            foreach ( (array)$menu as $key => $item )
    341357            {
    342                 if ( $item[2] == 'tp-contact' )
     358                if ( $item[2] == 'wprac-newsletter' )
    343359                {
    344                     $menu[$key][0] = $menu[$key][0].'<span class="update-count">'.$post_count.'</span>';
     360                    $menu[$key][0] = $menu[$key][0].' <span class="update-plugins count-'.$post_count.'"><span class="plugin-count" aria-hidden="true">'.$post_count.'</span><span class="screen-reader-text">'.$post_count.' notifications</span></span>';
    345361                }
    346362            }
     
    349365        return $instance;
    350366    }
    351     public static function get_number_of_pending_post_by_type($type)
    352     {
    353         global $wpdb;
    354         return $wpdb->get_var( "SELECT COUNT(ID) as count FROM {$wpdb->post} WHERE `post_status`='pending' AND `post_type`='{$type}';" );
    355     }
     367   
    356368}
    357369
  • wp-rest-api-contact/trunk/readme.txt

    r1656300 r1656319  
    55Requires at least: 4.5
    66Tested up to: 4.7.4
    7 Stable tag: 1.0.2
     7Stable tag: 1.0.3
    88License: MIT
    99License URI: http://opensource.org/licenses/MIT
     
    3535== Changelog ==
    3636
     37= 1.0.3 =
     38* Show notification bubble icon when there is a new subscription .
     39
    3740= 1.0.2 =
    3841* Create WP Rest API Subscribe Newsletter.
     
    4346= 1.0.0 =
    4447* First version.
     48
    4549== Upgrade Notice ==
    4650
     51= 1.0.3 =
     52* Show notification bubble icon when there is a new subscription .
     53
     54= 1.0.2 =
     55* Create WP Rest API Subscribe Newsletter.
     56
     57= 1.0.1 =
     58* Create WP Rest API Contact.
     59
    4760= 1.0.0 =
    48 * First version
     61* First version.
    4962
    5063== Features you will love ==
  • wp-rest-api-contact/trunk/wp-rest-api-npa.php

    r1654890 r1656319  
    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.2
     7Version: 1.0.3
    88Author URI: https://www.facebook.com/thien.pham.5074
    99Text Domain: tp-custom
     
    1818}
    1919
    20 define('WPRAC_VERSION', '1.0.2');
     20define('WPRAC_VERSION', '1.0.3');
    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.