Below, you’ll find a detailed guide on how to add the Email Address Encoder Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Email Address Encoder Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the Email Address Encoder Plugin and the shortcodes it provides:
"Email Address Encoder is a vital plugin for WordPress users. It helps protect your email addresses from email-harvesting robots, enhancing your website's security and privacy."
- [encode]
Email Address Encoder [encode] Shortcode
The Email Address Encoder shortcode is designed to protect email addresses from spam bots. It uses the ‘eae_method’ filter to encode the email address. The shortcode accepts a ‘link’ attribute. If provided, it creates an anchor tag with the encoded email address. If not, it just encodes the content within the shortcode.
Shortcode: [encode]
Parameters
Here is a list of all possible encode shortcode parameters and attributes:
link
– The URL to be encoded and displayed as a hyperlink.content
– The text to be encoded and displayed on the webpage.
Examples and Usage
Basic example – An instance of using the ‘encode’ shortcode to encode a simple email address.
[encode]example@example.com[/encode]
Advanced examples
Using the ‘encode’ shortcode to encode an email address and also provide a link to it. The email address is encoded and the link is also encoded to protect against email harvesting bots.
[encode link="mailto:example@example.com"]Email me[/encode]
Using the ‘encode’ shortcode to encode multiple email addresses in a piece of content. Each email address is individually encoded to keep them safe from harvesting.
[encode]example1@example.com, example2@example.com, example3@example.com[/encode]
Using the ‘encode’ shortcode to encode an email address in a hyperlink. The hyperlink is also encoded to protect against email harvesting bots.
[encode link="http://www.example.com"]example@example.com[/encode]
PHP Function Code
In case you have difficulties debugging what causing issues with [encode]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'encode', 'eae_shortcode' );
Shortcode PHP function:
function eae_shortcode( $attributes, $content = '' ) {
$atts = shortcode_atts( array(
'link' => null,
), $attributes, 'encode' );
// override encoding function with the 'eae_method' filter
$method = apply_filters( 'eae_method', 'eae_encode_str' );
if ( ! empty( $atts[ 'link' ] ) ) {
return sprintf(
'<a href="%s">%s</a>',
esc_attr( $method( $atts[ 'link' ] ) ),
$method( $content )
);
}
return $method( $content );
}
Code file location:
email-address-encoder/email-address-encoder/email-address-encoder.php
Conclusion
Now that you’ve learned how to embed the Email Address Encoder Plugin shortcode, 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.
Leave a Reply