Changeset 2302452
- Timestamp:
- 05/11/2020 08:10:29 AM (6 years ago)
- Location:
- wp-phone-message/trunk
- Files:
-
- 1 added
- 2 edited
-
includes/WpPhoneMessageAdmin.php (modified) (4 diffs)
-
includes/WpPhoneMessageModel.php (added)
-
views/shortcode-form.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wp-phone-message/trunk/includes/WpPhoneMessageAdmin.php
r2300742 r2302452 4 4 class WpPhoneMessageAdmin { 5 5 6 private $model; 7 6 8 public function __construct(){ 7 9 add_action( 'admin_menu', array( $this, 'adminMenu' ) ); 8 10 add_action( 'admin_post', array( $this, 'adminSave' ) ); 9 11 add_action( 'admin_enqueue_scripts', array( $this, 'adminStyle' ) ); 12 $this->model = new WpPhoneMessageModel; 10 13 } 11 14 … … 16 19 'manage_options', 17 20 'wp-phone-message-admin', 18 array( $this, ' WhatappMeAdminPage' ),21 array( $this, 'adminPage' ), 19 22 91 20 23 ); 21 24 } 22 25 23 public function WhatappMeAdminPage() {26 public function adminPage() { 24 27 //show the form 25 28 include_once( PLUGIN_WPM_PATH . 'views/admin-form.php' ); … … 29 32 // save data 30 33 if( ( $_POST['wp-phone-message-phone-number'] ) && ( $_POST['wp-phone-message-phone-prefix'] ) ) { 31 $this-> saveData();32 update_option( 'wp-phone-message-form-message','Settings saved.');34 $this->model->setData($_POST); 35 $this->model->setMessage('Settings saved.'); 33 36 } 34 37 else{ 35 $this-> saveData();36 update_option( 'wp-phone-message-form-message','International prefix and Whatsapp phone number are required.');38 $this->model->setData($_POST); 39 $this->model->setMessage('International prefix and Whatsapp phone number are required.'); 37 40 } 38 41 39 42 $this->adminRedirect(); 40 }41 42 private function saveData(){43 44 $phone = sanitize_text_field( $_POST['wp-phone-message-phone-number'] );45 $prefix = (int) str_replace(' ', '', sanitize_text_field( $_POST['wp-phone-message-phone-prefix'] ));46 $title = sanitize_text_field( $_POST['wp-phone-message-title'] );47 $text = sanitize_text_field( $_POST['wp-phone-message-text'] );48 $button = sanitize_text_field( $_POST['wp-phone-message-button'] );49 $textarea = sanitize_text_field( $_POST['wp-phone-message-textarea'] );50 $name_place = sanitize_text_field( $_POST['wp-phone-message-name'] );51 $name_active = sanitize_text_field( $_POST['wp-phone-message-name-active'] );52 $name_mandatory = sanitize_text_field( $_POST['wp-phone-message-name-mandatory'] );53 $address_place = sanitize_text_field( $_POST['wp-phone-message-address'] );54 $address_active = sanitize_text_field( $_POST['wp-phone-message-address-active'] );55 $address_mandatory = sanitize_text_field( $_POST['wp-phone-message-address-mandatory'] );56 $phone_place = sanitize_text_field( $_POST['wp-phone-message-phone'] );57 $phone_active = sanitize_text_field( $_POST['wp-phone-message-phone-active'] );58 $phone_mandatory = sanitize_text_field( $_POST['wp-phone-message-phone-mandatory'] );59 $email_place = sanitize_text_field( $_POST['wp-phone-message-email'] );60 $email_active = sanitize_text_field( $_POST['wp-phone-message-email-active'] );61 $email_mandatory = sanitize_text_field( $_POST['wp-phone-message-email-mandatory'] );62 63 $fullPhoneNumber = (int) str_replace(' ', '', $prefix) . ltrim(str_replace(' ', '', $phone), '0') ;64 65 update_option( 'wp-phone-message-phone-number', $phone );66 update_option( 'wp-phone-message-phone-prefix', $prefix );67 update_option( 'wp-phone-message-full-phone-number', $fullPhoneNumber );68 update_option( 'wp-phone-message-title', $title );69 update_option( 'wp-phone-message-text', $text );70 update_option( 'wp-phone-message-button', $button );71 update_option( 'wp-phone-message-textarea', $textarea );72 update_option( 'wp-phone-message-name', $name_place );73 update_option( 'wp-phone-message-name-active', $name_active );74 update_option( 'wp-phone-message-name-mandatory', $name_mandatory );75 update_option( 'wp-phone-message-address', $address_place );76 update_option( 'wp-phone-message-address-active', $address_active );77 update_option( 'wp-phone-message-address-mandatory', $address_mandatory );78 update_option( 'wp-phone-message-phone', $phone_place );79 update_option( 'wp-phone-message-phone-active', $phone_active );80 update_option( 'wp-phone-message-phone-mandatory', $phone_mandatory );81 update_option( 'wp-phone-message-email', $email_place );82 update_option( 'wp-phone-message-email-active', $email_active );83 update_option( 'wp-phone-message-email-mandatory', $email_mandatory );84 85 43 } 86 44 … … 109 67 } 110 68 111 p ublicfunction adminCallback() { // Section Callback69 private function adminCallback() { // Section Callback 112 70 echo '<p>This section is part of WP Phone Message Plugin</p>'; 113 71 } -
wp-phone-message/trunk/views/shortcode-form.php
r2298356 r2302452 2 2 $shortcode_form = '<div class="whatapp-wrapper">'; 3 3 $shortcode_form .= '<form class="whatapp-form" id="whatapp-form">'; 4 5 4 $shortcode_form .= '<h3 class="whatapp-title">' . get_option('wp-phone-message-title') . '</h3>'; 6 5 $shortcode_form .= '<p class="whatapp-text">' . get_option('wp-phone-message-text') . '</p>'; 6 7 7 if(get_option('wp-phone-message-name-active')){ 8 8 $shortcode_form .= '<input type="text" class="wp-phone-message-name" id="wp-phone-message-name" placeholder="' . get_option('wp-phone-message-name') . '" ' . get_option('wp-phone-message-name-mandatory') . ' />';
Note: See TracChangeset
for help on using the changeset viewer.