Plugin Directory

Changeset 1473209


Ignore:
Timestamp:
08/12/2016 04:46:40 PM (10 years ago)
Author:
prashaddey
Message:

Added new styles, added new dashboard option page for the plugin and made responsive.

Location:
wp-mail-sending-widget-form
Files:
29 added
4 edited

Legend:

Unmodified
Added
Removed
  • wp-mail-sending-widget-form/trunk/init.php

    r1473196 r1473209  
    22
    33/**
    4  * Plugin Name: WP mail Widget Plugin
     4 * Plugin Name: WP mail-sending Widget
    55 * Plugin URI: http://prashaddey.com
    66 * Author: Prashad
    77 * Author URI: http://prashaddey.com
    8  * version: 1.01
     8 * version: 2.01
    99 * Description: This Plugin will create a widget which will help you to create a submit form on the frontend of your website.
    1010 * The form will not only send an email with the infos of the subscribers to your email address but also save those infos on the plugin setting page on your dashboard.
     
    1818include dirname( __FILE__ ) . '/wpwp.php';
    1919
     20// Plugin Activation Hook
     21register_activation_hook( __FILE__, 'callback_of_plugin_activation' );
     22
     23// Plugin Activation function
     24// Creating a table for the plugin
     25function callback_of_plugin_activation(){
     26    global $wpdb;
     27    $table = $wpdb->prefix . 'a_wp_mail';
     28    $charset_collate = $wpdb->get_charset_collate();    // What does this line do? Allah knows..
     29
     30    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
     31    $sql = "CREATE TABLE $table (
     32      id INT NOT NULL AUTO_INCREMENT,
     33      name varchar(50) NOT NULL,
     34      email varchar(50) NOT NULL,
     35      phone varchar(20) NOT NULL,
     36      UNIQUE KEY id (id)
     37    ) $charset_collate;";
     38    dbDelta( $sql );
     39
     40}
     41
    2042new WPWP;
    2143
    2244
    2345
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
  • wp-mail-sending-widget-form/trunk/readme.txt

    r1473196 r1473209  
    33Requires at least: 3.0.1
    44Tested up to: 4.5.3
    5 Stable tag: 1.02
     5Stable tag: 2.0.1
    66License: GPLv2 or later
    77License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    6161
    6262= 1.01 =
    63 * Adding two new classes, WPMWP & WPWP.
     63* Added two new classes, WPMWP & WPWP.
     64
     65= 2.0.1 =
     66* Added dashboard options page for the plugin.
     67* Added new styles.
     68* Made Responsive and mobile friendly.
    6469
    6570
    6671
     72
     73
  • wp-mail-sending-widget-form/trunk/wpmwp.php

    r1473196 r1473209  
    1818    // Creating widget method to display on frontend
    1919    public function widget( $args, $db ){
     20        global $wpdb;
     21
    2022        $title = ! empty( $db['title'] ) ? $db['title'] : "Edit this title from your widget option.";
    2123        $admin_mail = ! empty($db['admin_mail']) ? $db['admin_mail'] : ''; 
    22 
     24       
    2325        ?>
    2426        <?php echo $args['before_widget']; ?>
     
    3032
    3133                <form action="" method="POST">
    32                     <label for="id_name">Your Namee:</label> <br>
     34                    <label for="id_name">Your Name:</label> <br>
    3335                    <input type="text" name="id_name" id="id_name" value="" placeholder="Enter name.." required>
    3436                    <br>
     
    4244                </form>
    4345
    44                 <p>
     46                <p style="color: #FFF;">
    4547                    <?php 
    4648                    if(isset($_POST['submit_form'])){
     
    5557                            $id_email = $_POST['id_email'];
    5658                        }
     59
     60                        // SENDING MAIL
    5761                        $msg = "Your newly subscriber name is " . $id_name . ", phone number: " . $id_number . " & email address: " . $id_email;
    58 
    5962                        $mail = mail($admin_mail, 'A new subscriber!', $msg);
    6063                       
     
    6669                        }
    6770                        echo $err;
     71
     72
     73
     74                        // INSERTING TO OUR DATABASE
     75                        // $tablename = $wpdb->prefix . 'a_wp_mail';
     76                        // cols = id, name, email, phone
     77                        $tablename = $wpdb->prefix . 'a_wp_mail';
     78                        $wpdb->insert($tablename, array(
     79                            'name'  => $id_name,
     80                            'email' => $id_email,
     81                            'phone' => $id_number
     82                            ));
     83
    6884
    6985                    }
  • wp-mail-sending-widget-form/trunk/wpwp.php

    r1473196 r1473209  
    88class WPWP{
    99    public function __construct(){
     10
     11    // Enqueueing Style and Scripts files - FRONTEND
     12    add_action('wp_enqueue_scripts', array( &$this, 'callback_of_wp_enqueue') );
     13
     14    // Enqueueing Style and Scripts files - BACKEND
     15    add_action('admin_enqueue_scripts', array( &$this, 'callback_of_admin_enqueue'));
     16
     17    // Adding Menu for the plugin
     18    add_action('admin_menu', array( &$this, 'callback_of_admin_menu') );
     19
    1020    // Creating Widget
    1121    add_action('widgets_init', array( &$this, 'callback_of_widgets_init') );   
    12    
    13     // Enqueueing Style and Scripts files
    14     add_action('wp_enqueue_scripts', array( &$this, 'callback_of_wp_enqueue') );
     22
    1523    }
    1624
    17     // ALL Plublic functions
     25
     26                    /******* ALL Plublic functions *******/
     27
    1828    public function callback_of_widgets_init(){
    1929        register_widget( 'WPMWP' );
    2030    }
    2131
     32    // FRONTEND Enqueue
    2233    public function callback_of_wp_enqueue(){
    2334        // Enqueueing Style files
     
    2536       
    2637    }
     38
     39    // BACKEND Enqueue
     40    public function callback_of_admin_enqueue(){
     41        // Style files
     42        wp_enqueue_style( 'bootstrap-css', plugins_url('/css/bootstrap.min.css', __FILE__));
     43
     44        // Scripts files
     45        wp_enqueue_script( 'bootstrap-script', plugins_url( '/js/bootstrap.min.js', __FILE__ ), array('jquery'));
     46        wp_enqueue_script( 'custom-script', plugins_url( '/js/custom.js', __FILE__ ), array('bootstrap-script'));
     47    }
     48
     49
     50    // Adding Menu Options
     51    public function callback_of_admin_menu(){
     52        add_menu_page('WP mail-sending Widget', 'WP mail Widget', 'manage_options', 'slug-wp-mail-widget', array( &$this, 'callback_of_add_menu_page'), 'dashicons-email', 59);
     53    }
     54
     55
     56    // Menu Displaying function
     57    public function callback_of_add_menu_page(){
     58        ?>
     59        <div class="wrap container">
     60            <h2>WP mail-sending Widget Setting</h2> <br>
     61            <form action="options.php" method="POST">
     62                <table class="table table-striped table-hover">
     63                    <thead>
     64                      <tr>
     65                        <th>#</th>
     66                        <th>Firstname</th>
     67                        <th>Email</th>
     68                        <th>Phone #</th>
     69                      </tr>
     70                    </thead>
     71                    <tbody>
     72                    <?php 
     73
     74                        global $wpdb;
     75                        $tablename = $wpdb->prefix . 'a_wp_mail';
     76                        $sql = "SELECT * FROM $tablename";
     77                        $infos = $wpdb->get_results( $sql, 'OBJECT_K' );
     78                        $i = 1;
     79
     80                    foreach( $infos as $info ) :
     81                    ?>
     82                        <tr>
     83                            <td><?php echo $i; ?></td>
     84                            <td><?php echo $info->name; ?></td>
     85                            <td><?php echo $info->email; ?></td>
     86                            <td><?php echo $info->phone; ?></td>
     87                        </tr>
     88                    <?php
     89                    $i++;
     90                    endforeach;
     91                    ?>
     92
     93                    </tbody>
     94                </table>
     95
     96
     97            </form>
     98        </div>
     99        <?php
     100    }
     101
     102
    27103}
Note: See TracChangeset for help on using the changeset viewer.