options = get_option( '123eworld_sms_option' ); if( is_admin() ) { add_action('admin_menu', array($this, 'admin_menu')); add_action( 'admin_init', array($this, 'admin_init')); } add_action("wp_ajax_eworld_send_sms", array($this, "sendAjaxSMS")); add_action('eworld_send_sms', array( $this, 'sendSMS' ), 10, 3 ); // Work if user is not login //add_action("wp_ajax_nopriv_send_sms", array($this, "sendAjaxSMS")); } public function admin_menu() { add_menu_page(__('123eworld SMS',"123eworld"), __('123eworld SMS',"123eworld"), 'manage_options', '123eworld_sms', array($this, 'settings'), 'dashicons-email-alt' ); add_submenu_page('123eworld_sms',__('Send SMS',"123eworld"),__('Send SMS',"123eworld"),'manage_options','send_sms', array($this, 'send_sms')); } public function admin_init() { register_setting( '123eworld_sms_options', // Option group '123eworld_sms_option', // Option name array( $this, 'option_sanitize' ) // Sanitize ); add_settings_section( 'sms_api_setting', // ID 'API Credentials', // Title '', //array( $this, 'print_section_info' ), // Callback '123eworld_sms_settings' // Page ); add_settings_field( 'user_name', // ID 'User Name', // Title array( $this, 'user_name_callback' ), // Callback '123eworld_sms_settings', // Page 'sms_api_setting' // Section ); add_settings_field( 'password', // ID 'Password', // Title array( $this, 'password_callback' ), // Callback '123eworld_sms_settings', // Page 'sms_api_setting' // Section ); add_settings_field( 'senderid', 'Sender ID', array( $this, 'senderid_callback' ), '123eworld_sms_settings', 'sms_api_setting' ); } public function option_sanitize( $data ) { $sanitized_data = array(); if( isset( $data['user_name'] ) ) $sanitized_data['user_name'] = sanitize_text_field( $data['user_name'] ); if( isset( $data['password'] ) ) $sanitized_data['password'] = sanitize_text_field( $data['password'] ); if( isset( $data['senderid'] ) ) $sanitized_data['senderid'] = sanitize_text_field( $data['senderid'] ); return $sanitized_data; } public function user_name_callback() { printf( '', isset( $this->options['user_name'] ) ? esc_attr( $this->options['user_name']) : '' ); } public function password_callback() { printf( '', isset( $this->options['password'] ) ? esc_attr( $this->options['password']) : '' ); } public function senderid_callback() { printf( '', isset( $this->options['senderid'] ) ? esc_attr( $this->options['senderid']) : '' ); } public function settings() { ?>

showHelp();?>
sendSMS(trim(sanitize_text_field($_POST['mobile_no'])), trim(sanitize_text_field($_POST['message']))); if (strpos($Msg,"_")===false) $MsgType = "error"; } } ?>

">

"/>

showHelp();?>
options['user_name'].'&pass='.$this->options['password'].'&senderid='.$this->options['senderid'].'&dest_mobileno='.$MobileNo.'&message='.urlencode($Message).'&response=Y'; $Result = wp_remote_get($Url); $Return = is_array($Result) && isset($Result['body'])?$Result['body']:""; if ($Print) echo $Return; else return $Return; } function sendAjaxSMS() { $MobileNo = sanitize_text_field($_REQUEST['mobile_no']); $Message = sanitize_text_field($_REQUEST['message']); echo $this->sendSMS($MobileNo, $Message); exit(); } function showHelp() { ?>

How to send SMS from programming?

1. You can call following method in your code to send SMS
$SMSSendStatus = $EworldSMS->sendSMS($MobileNo,$Message);

2. You can call action hook in your code to send SMS
do_action('eworld_send_sms', $MobileNo, $Message, $PrintTrueFalse);
$PrintTrueFalse - If 1 it will print result, If 0 then it will return result. Default 0

3. You can send sms by AJAX call.
Ajax action : send_sms
Data to send : a) mobile_no b) message

var AjaxUrl = ajax_object.ajax_url;
var formData = {'action':'eworld_send_sms'};
formData['mobile_no'] = '9823372069';
formData['message'] = "Sending SMS using 123eworld SMS API";
jQuery.ajax({
type: "post",
dataType: "json",
url: AjaxUrl,
data: formData,
success: function(msg){
console.log(msg);
},
error:function(xhr, status, error){
//var err = eval("(" + xhr.responseText + ")");
console.log( xhr.responseText);
console.log(xhr);
}
});