Widgets) __('Contact Us Widget', 'contactus-localization'), // Widget Options: // - Description (what user sees under Appearance > Widgets) array( 'description' => __( 'Encrypt your email address (to protect from spammers) within a block of contact information.', 'contactus-localization' ), ) ); } //End __construct // Widget User Interface (accessed via WordPress Admin) public function form( $instance ) { //Grab user choices or define defaults for 1st time $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : 'Contact Us'; $before = isset( $instance['before'] ) ? esc_attr( $instance['before'] ) : 'Email us at'; $email = isset( $instance['email'] ) ? esc_attr( $instance['email'] ) : 'yourname@yourcompany.com'; $after = isset( $instance['after'] ) ? esc_attr( $instance['after'] ) : 'for more information.'; // Widget Form ?>

Encrypt your email address (to protect from spammers) within a block of contact information. The 'Before' text will be placed before the encrypted email followed by the 'After' text.

'.antispambot($email).''; $text .= ' ' . $after; echo '

' . trim($text) . '

'; echo $after_widget; //End of widget output } } //End widget() } // End contactus_widget class // Register and load the widget function load_contact_us_widget() { register_widget( 'contactus_widget' ); } add_action( 'widgets_init', 'load_contact_us_widget' ); /****************************************************************************** * Shortcode Section ******************************************************************************/ //Allow shortcodes to be executed within widgets add_filter( 'widget_text', 'do_shortcode'); /** * Shortcode function - Version 1 * * functions as [email]yourname@yourcompany.com[/email] * * @param array atts Shortcode attributes * @param array content Shortcode content */ function email_encode_function( $atts, $content = null){ return ''.antispambot($content).''; } //Add shortcode for [email] add_shortcode( 'email', 'email_encode_function' ); /** * Shortcode function - Version 2 * * functions as [email address="yourname@yourcompany.com" class="classname"] * * @param array atts Shortcode attributes * @param array content Shortcode content */ function email_encode_function2( $atts, $content = null){ extract( shortcode_atts( array( 'address' => '', 'class' => 'email' ), $atts ) ); if ($class != '') $classtext = ' class="' . $class . '"'; return ''.antispambot($address).''; } //Add shortcode for [email] add_shortcode( 'email2', 'email_encode_function2' );