Plugin Directory

Changeset 1473196


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

Adding two new classes, WPMWP & WPWP.

Location:
wp-mail-sending-widget-form/trunk
Files:
3 added
2 deleted
2 edited

Legend:

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

    r1473192 r1473196  
    66 * Author: Prashad
    77 * Author URI: http://prashaddey.com
    8  * version: 1.0
     8 * version: 1.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.
     
    1212**/
    1313
    14 class WPMWP extends WP_Widget{
    15    
    16     // Creating __construct method for our widget class WPMWP
    17     public function __construct(){
    18         parent::__construct('id_of_widget', 'WP mail Widget', array(
    19             'description' => 'The best widget to create form on your sidebar.'
    20             ));
    21     }
     14// Including file that creates a widget to get information about the admin
     15include dirname( __FILE__ ) . '/wpmwp.php';
    2216
    23     // Creating widget method to display on frontend
    24     public function widget( $args, $db ){
    25         $title = ! empty( $db['title'] ) ? $db['title'] : "Edit this title from your widget option.";
    26         $admin_mail = ! empty($db['admin_mail']) ? $db['admin_mail'] : ''; 
    27        
    28         ?>
    29         <?php echo $args['before_widget']; ?>
    30             <?php echo $args['before_title']; ?>
    31                 <?php echo $title; ?>
    32             <?php echo $args['after_title']; ?>
    33            
     17// Including the main class for this plugin
     18include dirname( __FILE__ ) . '/wpwp.php';
    3419
    35             <form action="" method="POST">
    36                 <label for="id_name">Your Name:</label> <br>
    37                 <input type="text" name="id_name" id="id_name" value="" placeholder="Enter name..">
    38                 <br>
    39                 <label for="id_number">Your Number:</label> <br>
    40                 <input type="number" name="id_number" id="id_number" value="" placeholder="Enter number..">
    41                 <br>
    42                 <label for="id_email">Your Email:</label> <br>
    43                 <input type="email" name="id_email" id="id_email" value="" placeholder="Enter email..">
    44                 <br>
    45                 <input type="submit" value="SEND" name="submit_form">
    46             </form>
    47 
    48             <p>
    49                 <?php 
    50                 if(isset($_POST['submit_form'])){
    51 
    52                     if(isset($_POST['id_name'])){
    53                         $id_name = $_POST['id_name'];
    54                     }
    55                     if(isset($_POST['id_number'])){
    56                         $id_number = $_POST['id_number'];
    57                     }
    58                     if(isset($_POST['id_email'])){
    59                         $id_email = $_POST['id_email'];
    60                     }
    61                     $msg = "Your newly subscriber name is " . $id_name . ", phone number: " . $id_number . " & email address: " . $id_email;
    62 
    63                     $mail = mail($admin_mail, 'A new subscriber!', $msg);
    64                    
    65                     $err = '';
    66                     if($mail){
    67                         $err = "Message has been sent!";
    68                     }else{
    69                         $err = "Message has not been sent!";
    70                     }
    71                     echo $err;
    72 
    73                 }
    74                 ?>
    75             </p>
    76 
    77         <?php echo $args['after_widget']; ?>
    78            
    79         <?php
    80     }
    81 
    82     // Creating form method to display widget on backend
    83     public function form( $db ){
    84         $title = ! empty($db['title']) ? $db['title'] : 'New Title';
    85         $admin_mail = ! empty($db['admin_mail']) ? $db['admin_mail'] : '';
    86         ?>
    87         <p>
    88             <label for="<?php echo $this->get_field_id('title'); ?>">Title:</label>
    89             <input type="text" value="<?php echo esc_attr( $title ); ?>" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" class="widefat" placeholder="Title of your form">
    90         </p>
    91         <p>
    92             <label for="<?php echo $this->get_field_id('admin_mail'); ?>">Set Your Email Address:</label>
    93             <input type="email" id="<?php echo $this->get_field_id('admin_mail'); ?>" name="<?php echo $this->get_field_name('admin_mail'); ?>" value="<?php echo $admin_mail; ?>" class="widefat" placeholder="Enter Your email">
    94             <span class="description">All the mail infos will be sent to this email address.</span>
    95         </p>
    96 
    97         <?php
    98 
    99     }
    100 
    101     // Creating update function
    102     public function update( $new, $old ){
    103         $db                 = array();
    104         $db['title']        = !empty($new['title']) ? strip_tags($new['title']) : '';
    105         $db['admin_mail']   = !empty($new['admin_mail']) ? strip_tags($new['admin_mail']) : '';
    106 
    107         return $db;
    108     }
    109 }
     20new WPWP;
    11021
    11122
    112 add_action('widgets_init', 'callback_of_widgets_init');
    11323
    114 function callback_of_widgets_init(){
    115     register_widget( 'WPMWP' );
    116 }
  • wp-mail-sending-widget-form/trunk/readme.txt

    r1473192 r1473196  
    33Requires at least: 3.0.1
    44Tested up to: 4.5.3
    5 Stable tag: 1.0
     5Stable tag: 1.02
    66License: GPLv2 or later
    77License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    6060* No changed yet.
    6161
     62= 1.01 =
     63* Adding two new classes, WPMWP & WPWP.
     64
     65
     66
Note: See TracChangeset for help on using the changeset viewer.