get_option( 'admin_email' ), 'name' => 'Name:', 'message' => 'Message:', 'submit' => 'Send message', 'width' => '100%', 'btn_color' => '#000', 'btn_text_color' => '#fff', 'from' => get_option( 'blogname' ), 'subject' => 'Ajax Message', 'success' => 'Thank you, message sent', 'error' => 'Error: Message not sent', 'textarea' => '', 'captcha_on' => '1', 'captcha_value' => '333' ); update_option( $option_name, $data ); $notices = get_option( 'keksus_ae_plugin_admin_notices', array() ); $notices = array( 'content' => __( 'Thank you for installing this plugin! Plugin settings are available on the page', 'ae' ) . ' Settings - Ajax Message' ); update_option( 'keksus_ae_plugin_admin_notices', $notices ); } function keksus_ae_deactivate() { global $option_name; delete_option( $option_name ); delete_option( 'keksus_ae_plugin_admin_notices' ); } function keksus_ae_plugin_admin_notices() { if ( $notices = get_option( 'keksus_ae_plugin_admin_notices' ) ) { foreach ( $notices as $notice) { echo "

$notice

"; } delete_option( 'keksus_ae_plugin_admin_notices' ); } } add_action( 'admin_notices', 'keksus_ae_plugin_admin_notices' ); function keksus_ae_scripts_frontend() { wp_enqueue_style( 'frontend-css', plugins_url( 'css/frontend.css',__FILE__ ) ); wp_enqueue_style( 'admin-icons', plugins_url( 'css/ionicons.min.css',__FILE__ ) ); wp_enqueue_script( 'frontend-ajax', plugins_url( 'js/frontend.js',__FILE__ ), array(jquery) ); wp_localize_script( 'frontend-ajax', 'ajax', array( 'url' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'helloworld' ) ) ); } add_action( 'wp_enqueue_scripts', 'keksus_ae_scripts_frontend' ); function keksus_ae_scripts_admin() { $current_screen = get_current_screen(); if ( $current_screen->id === "settings_page_ae_options_group" ) { wp_enqueue_style( 'admin-css', plugins_url( 'css/admin.css',__FILE__ ) ); wp_enqueue_style( 'admin-icons', plugins_url( 'css/ionicons.min.css',__FILE__ ) ); wp_enqueue_script( 'admin-js', plugins_url( 'js/admin.js',__FILE__ ), array(jquery) ); wp_localize_script( 'admin-js', 'ajax', array( 'url' => admin_url( 'admin-ajax.php' ) //'nonce' => wp_create_nonce( 'helloadmin' ) ) ); } } add_action( 'admin_enqueue_scripts', 'keksus_ae_scripts_admin' ); // show plugin footer text function keksus_ae_this_screen() { $current_screen = get_current_screen(); if ( $current_screen->id === "settings_page_ae_options_group" ) { add_filter( 'update_footer', 'right_admin_footer_text_output', 11); function right_admin_footer_text_output( $text ) { $text = current_time( 'Y-m-d' ); return $text; } add_filter( 'admin_footer_text', 'left_admin_footer_text_output' ); function left_admin_footer_text_output( $text ) { $text = __( 'Thank you for installing this plugin! Created by', 'ae' ).' Keksus'; return $text; } } } add_action( 'current_screen', 'keksus_ae_this_screen' ); // add custom styles to header function keksus_ae_style_to_header() { global $option_name,$options; ?>
'>
'> '> '>
; color: ' value=''/>
LOADING!
'>
'> '> '>
; color: ' value=''/>
LOADING!
'. __( 'Name required', 'ae' ) . ''; echo '
'; } elseif ( '' == $message ) { echo '
'. __( 'Message required', 'ae' ) . ''; echo '
'; } elseif ( isset( $captcha_value ) ) { if ( $captcha == $captcha_value ) { keksus_ae_mail( $from,$subject,$name,$message ); } else { echo '
'. __( 'Wrong captcha code', 'ae' ) . ''; echo '
'; } } else { keksus_ae_mail( $from,$subject,$name,$message ); } //echo wp_json_encode( $_POST); wp_die(); } } add_action( 'wp_ajax_ae_action', 'keksus_ae_action_callback' ); add_action( 'wp_ajax_nopriv_ae_action', 'keksus_ae_action_callback' ); // function used in callback function keksus_ae_mail( $from,$subject,$name,$message ) { global $option_name,$options; $to_email = $options['email']; $body = "

From: $from

"; $body .= "

Subject: $subject

"; $body .= '==============================='; $body .= "

Name: $name

"; //$body .= "

Email: $from_email

"; $body .= "

Message:

$message

"; $headers = 'Content-type: text/html; charset=utf-8' . "\r\n"; $headers .= "From: $name " . "\r\n"; if ( wp_mail( $to_email, $subject, $body, $headers ) ) { echo '
'. __( $options['success'], 'ae' ) .''; echo '
'; wp_die(); } else { echo '
'. __( $options['error'], 'ae' ) .''; echo '
'; wp_die(); } } // captcha value function keksus_ae_captcha() { global $option_name,$options; if ( $options['captcha_on'] == '1' ) { return $options['captcha_value']; } } add_action( 'captcha', 'keksus_ae_captcha' ); // register plugin settings function keksus_ae_plugin_settings() { global $option_name,$options; register_setting( 'ae_options_group', $option_name, 'keksus_ae_sanitize_callback' ); } add_action( 'admin_init', 'keksus_ae_plugin_settings' ); // settings page for admin dashboard function keksus_ae_admin_page_settings() { add_options_page( 'Ajax Message settings', 'Ajax Message', 'manage_options', 'ae_options_group', 'keksus_ae_options_output' ); } add_action( 'admin_menu', 'keksus_ae_admin_page_settings' ); function keksus_ae_options_output() { global $option_name,$options; $checked = ( is_array( $options ) && $options['captcha_on'] == '1' ) ? 'checked="checked"' : ''; ?>

'> '> '>

'> '> '>

'> '>

'> '> '>

'> />

1.

[ae_message]

2.

[ae_message_widget]

3.

";
													echo "?php" ." echo do_shortcode('[ae_message]');" . " ?>"; ?>

GPL v3 license

Keksus.com

' />
LOADING!
$val ) { $val = sanitize_text_field( $val); } return $options; //die(print_r( $options ) ); } // Widget function ajax_message_widget() { register_widget( 'Ajax_Message_Widget' ); } add_action( 'widgets_init', 'ajax_message_widget' ); class Ajax_Message_Widget extends WP_Widget { public function __construct() { $widget_ops = array( 'classname' => 'ajax_message_widget', 'description' => __( 'Shortcode or HTML or Plain Text.', 'ae' ) ); parent::__construct( 'ae', __( 'Ajax Message', 'ae' ), $widget_ops ); } public function widget( $args, $instance ) { $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); $text = apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance ); $shortcode = apply_filters( 'widget_shortcode', empty( $instance['shortcode']) ? '' : $instance['shortcode'], $instance ); echo $args['before_widget']; if ( $title ) { echo $args['before_title'] . $title . $args['after_title']; } ?>
'', 'text' => '' ) ); ?>

/>