Email Encoder Bundle Shortcodes

Below, you’ll find a detailed guide on how to add the Email Encoder Bundle Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Email Encoder Bundle Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Email Encoder Bundle Plugin and the shortcodes it provides:

Plugin Icon
Email Encoder – Protect Email Addresses and Phone Numbers

"Email Encoder – Protect Email Addresses and Phone Numbers is a WordPress plugin designed to safeguard your contact details. It encrypts email addresses and phone numbers, preventing them from being misused by spammers."

★★★★☆ (73) Active Installs: 80000+ Tested with: 6.3.2 PHP Version: 5.1
Included Shortcodes:
  • [eeb_protect_emails]
  • [eeb_protect_content]
  • [eeb_mailto]
  • []

Email Encoder Bundle [eeb_protect_emails] Shortcode

The Email Encoder Bundle shortcode ‘eeb_protect_emails’ helps secure email addresses in your content from spambots. It checks if protection is activated and applies the specified protection method.

Shortcode: [eeb_protect_emails]

Examples and Usage

Basic example – Protects the content using the default protection method set in the plugin settings.

[eeb_protect_emails]Your email content here[/eeb_protect_emails]

Advanced examples

Protects the content using a specific protection method, regardless of what is set in the plugin settings. The ‘protect_using’ attribute can be set to ‘enc_ascii’, ‘enc_html’, ‘enc_javascript’, ‘enc_css’, ‘enc_escape’, ‘enc_hex’, ‘enc_html_all’, ‘enc_url’, ‘enc_quoted_printable’, ‘enc_base64’, ‘enc_base64_url’, ‘enc_uu’, ‘enc_uu_url’, ‘enc_all’, ‘enc_all_url’, ‘enc_random’, or ‘enc_random_url’.

[eeb_protect_emails protect_using='enc_ascii']Your email content here[/eeb_protect_emails]

Protects multiple pieces of content using different protection methods. The shortcodes can be nested and each one can have its own ‘protect_using’ attribute.

[eeb_protect_emails protect_using='enc_ascii']Your email content here[eeb_protect_emails protect_using='enc_html']Your other email content here[/eeb_protect_emails][/eeb_protect_emails]

PHP Function Code

In case you have difficulties debugging what causing issues with [eeb_protect_emails] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'eeb_protect_emails', array( $this, 'protect_content_shortcode' ) );

Shortcode PHP function:

function protect_content_shortcode( $atts, $content = null ){
		$protect = (int) EEB()->settings->get_setting( 'protect', true );
		$protect_using = (string) EEB()->settings->get_setting( 'protect_using', true );
		$protection_activated = ( $protect === 1 || $protect === 2 ) ? true : false;

        if ( ! $protection_activated ) {
			return $content;
		}
		
		if( isset( $atts['protect_using'] ) ){
			$protect_using = $atts['protect_using'];
		}

        $content = EEB()->validate->filter_content( $content, $protect_using );

        return $content;
	}

Code file location:

email-encoder-bundle/email-encoder-bundle/core/includes/classes/class-email-encoder-bundle-run.php

Email Encoder Bundle [eeb_protect_content] Shortcode

The Email Encoder Bundle shortcode protects your email content from spambots. It uses various encoding methods like ASCII, ROT13, Escape, and HTML encoding. The shortcode also allows the customization of protection text and the execution of nested shortcodes.

Shortcode: [eeb_protect_content]

Parameters

Here is a list of all possible eeb_protect_content shortcode parameters and attributes:

  • protection_text – Text to show when content is protected
  • method – The encoding method to be used
  • do_shortcode – Allows shortcodes within the protected content

Examples and Usage

Basic example – Here’s a simple usage of the email-encoder-bundle plugin shortcode. This example will encode the email content using the default method (‘rot13’).

[eeb_protect_content]YourEmail@example.com[/eeb_protect_content]

Advanced examples – You can customize the shortcode with various parameters for different purposes.

Encoding the email content using the ASCII method:

[eeb_protect_content method="enc_ascii"]YourEmail@example.com[/eeb_protect_content]

Setting a custom protection text:

[eeb_protect_content protection_text="Protected Email"]YourEmail@example.com[/eeb_protect_content]

Using the shortcode within another shortcode:

[eeb_protect_content do_shortcode="yes"]YourEmail@example.com[/eeb_protect_content]

Combining multiple parameters:

[eeb_protect_content method="enc_escape" protection_text="Protected Email" do_shortcode="yes"]YourEmail@example.com[/eeb_protect_content]

PHP Function Code

In case you have difficulties debugging what causing issues with [eeb_protect_content] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'eeb_protect_content', array( $this, 'shortcode_eeb_content' ) );

Shortcode PHP function:

function shortcode_eeb_content( $atts = array(), $content = null ){

		$original_content = $content;
		$show_encoded_check = (string) EEB()->settings->get_setting( 'show_encoded_check', true );

		if( ! isset( $atts['protection_text'] ) ){
			$protection_text = __( EEB()->settings->get_setting( 'protection_text', true ), 'email-protection-text-eeb-content' );
		} else {
			$protection_text = wp_kses_post( $atts['protection_text'] );
		}

		if( isset( $atts['method'] ) ){
			$method = sanitize_title( $atts['method'] );
		} else {
			$method = 'rot13';
		}

		if( isset( $atts['do_shortcode'] ) && $atts['do_shortcode'] === 'yes' ){
			$content = do_shortcode( $content );
		}

        switch( $method ){
			case 'enc_ascii':
			case 'rot13':
				$content = EEB()->validate->encode_ascii( $content, $protection_text );
				break;
			case 'enc_escape':
			case 'escape':
				$content = EEB()->validate->encode_escape( $content, $protection_text );
				break;
			case 'enc_html':
			case 'encode':
			default:
				$content = antispambot( $content );
				break;
		}

		 // mark link as successfullly encoded (for admin users)
		 if ( current_user_can( EEB()->settings->get_admin_cap( 'frontend-display-security-check' ) ) && $show_encoded_check ) {
            $content .= EEB()->validate->get_encoded_email_icon();
        }

		return apply_filters( 'eeb/frontend/shortcode/eeb_protect_content', $content, $atts, $original_content );
	}

Code file location:

email-encoder-bundle/email-encoder-bundle/core/includes/classes/class-email-encoder-bundle-run.php

Email Encoder Bundle [eeb_mailto] Shortcode

The Email Encoder Bundle shortcode is designed to protect email addresses from spambots. It encodes email addresses in your content using various methods like ASCII, ROT13, and JavaScript. . This shortcode checks if the email attribute is empty, sanitizes it if not. It also checks and sanitizes the ‘method’ attribute. The ‘display’ and ‘noscript’ attributes are decoded and used to create the email link. The method of encoding is determined by the ‘method’ attribute. If it’s empty, the default method from the settings is used. The resulting email link is marked as successfully encoded for admin users.

Shortcode: [eeb_mailto]

Parameters

Here is a list of all possible eeb_mailto shortcode parameters and attributes:

  • email – The email address that the link will point to.
  • extra_attrs – Additional attributes for the email link.
  • method – The method to use for encoding the email link.
  • display – The text that will be displayed for the email link.
  • noscript – The text that will be displayed if JavaScript is disabled.

Examples and Usage

Basic example – Display an encoded email with default settings

[eeb_mailto email="example@example.com"]

Advanced examples

Display an encoded email with extra attributes, specific encoding method, and custom display text

[eeb_mailto email="example@example.com" extra_attrs="id=my-email" method="rot13" display="Contact me"]

Display an encoded email with a custom class, noscript message and using a strong encoding method

[eeb_mailto email="example@example.com" extra_attrs="class=my-custom-class" method="strong_method" noscript="Email not visible without JavaScript"]

Display an encoded email with a custom display text and encoded using ASCII encoding

[eeb_mailto email="example@example.com" display="Email me" method="enc_ascii"]

These examples show how you can use the ‘eeb_mailto’ shortcode to display encoded emails on your WordPress site. The shortcode is flexible and allows you to specify the email, extra attributes, encoding method, display text, noscript message, and custom class.

PHP Function Code

In case you have difficulties debugging what causing issues with [eeb_mailto] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'eeb_mailto', array( $this, 'shortcode_eeb_email' ) );

Shortcode PHP function:

function shortcode_eeb_email( $atts = array(), $content = null ){

		$show_encoded_check = (bool) EEB()->settings->get_setting( 'show_encoded_check', true );
		$protection_text = __( EEB()->settings->get_setting( 'protection_text', true ), 'email-encoder-bundle' );

		if( empty( $atts['email'] ) ){
			return '';
		} else {
			$email = sanitize_email( $atts['email'] );
		}

		if( empty( $atts['extra_attrs'] ) ){
			$extra_attrs = '';
		} else {
			$extra_attrs = $atts['extra_attrs'];
		}

		if( ! isset( $atts['method'] ) || empty( $atts['method'] ) ){
			$protect_using = (string) EEB()->settings->get_setting( 'protect_using', true );
			if( ! empty( $protect_using ) ){
				$method = $protect_using;
			} else {
				$method = 'rot13'; //keep as fallback
			}
		} else {
			$method = sanitize_title( $atts['method'] );
		}

		$custom_class = (string) EEB()->settings->get_setting( 'class_name', true );
		
		if( empty( $atts['display'] ) ) {
			$display = $email;
		} else {
			$display = html_entity_decode( $atts['display'] );
		}
		
		if( empty( $atts['noscript'] ) ) {
			$noscript = $protection_text;
		} else {
			$noscript = html_entity_decode( $atts['noscript'] );
		}
		
		$class_name = ' ' . trim( $extra_attrs );
		$class_name .= ' class="' . esc_attr( $custom_class ) . '"';
		$mailto = '<a href="mailto:' . $email . '"'. $class_name . '>' . $display . '</a>';
		
		switch( $method ){
			case 'enc_ascii':
			case 'rot13':
				$mailto = EEB()->validate->encode_ascii( $mailto, $noscript );
				break;
			case 'enc_escape':
			case 'escape':
				$mailto = EEB()->validate->encode_escape( $mailto, $noscript );
				break;
			case 'with_javascript':
				$mailto = EEB()->validate->dynamic_js_email_encoding( $mailto, $noscript );
				break;
			case 'without_javascript':
				$mailto = EEB()->validate->encode_email_css( $mailto );
				break;
			case 'char_encode':
				$mailto = EEB()->validate->filter_plain_emails( $mailto, null, 'char_encode' );
				break;
			case 'strong_method':
				$mailto = EEB()->validate->filter_plain_emails( $mailto );
				break;
			case 'enc_html':
			case 'encode':
			default:
				$mailto = '<a href="mailto:' . antispambot( $email ) . '"'. $class_name . '>' . antispambot( $display ) . '</a>';
				break;
		}

		// mark link as successfullly encoded (for admin users)
		if ( current_user_can( EEB()->settings->get_admin_cap( 'frontend-display-security-check' ) ) && $show_encoded_check ) {
            $mailto .= EEB()->validate->get_encoded_email_icon();
        }

		return apply_filters( 'eeb/frontend/shortcode/eeb_mailto', $mailto );
	}

Code file location:

email-encoder-bundle/email-encoder-bundle/core/includes/classes/class-email-encoder-bundle-run.php

Conclusion

Now that you’ve learned how to embed the Email Encoder Bundle Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *