Mailoptin Shortcodes

Below, you’ll find a detailed guide on how to add the Mailoptin 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 Mailoptin Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Mailoptin Plugin and the shortcodes it provides:

Plugin Icon
Popup, Optin Form & Email Newsletters for Mailchimp, HubSpot, AWeber – MailOptin

"MailOptin is a versatile plugin capable of creating popups, optin forms, and email newsletters. Perfectly compatible with Mailchimp, HubSpot, AWeber, it's a must-have tool for email marketing."

★★★★☆ (398) Active Installs: 30000+ Tested with: 6.3.2 PHP Version: 7.3
Included Shortcodes:
  • [posts-loop]
  • [unsubscribe]
  • [webversion]
  • [company-name]
  • [company-address]
  • [company-address2]
  • [company-city]
  • [company-state]
  • [company-zip]
  • [company-country]
  • [post-title]
  • [post-content]
  • [post-excerpt]
  • [post-feature-image]
  • [post-feature-image-url]
  • [post-url]
  • [post-date]
  • [post-date-gmt format="F j, Y"]
  • [post-categories]
  • [post-terms]
  • [post-id]
  • [post-author-name]
  • [post-author-website]
  • [post-author-email]
  • [post-author-avatar-url]
  • [post-meta]
  • [acf-field]
  • [mo-optin-form-wrapper]
  • [mo-optin-form-fields-wrapper]
  • [mo-optin-form-cta-wrapper]
  • [mo-optin-form-headline]
  • [mo-close-optin]
  • [mo-optin-form-image]
  • [mo-optin-form-background-image]
  • [mo-optin-form-description]
  • [mo-optin-form-error]
  • [mo-optin-form-name-field]
  • [mo-optin-form-email-field]
  • [mo-optin-form-custom-fields]
  • [mo-optin-form-submit-button]
  • [mo-optin-form-cta-button]
  • [mo-optin-form-note]
  • [mo-optin-form]
  • [mo-click-launch]

Mailoptin [posts-loop] Shortcode

The ‘posts-loop’ shortcode from MailOptin plugin is designed to loop through posts. It filters posts based on ‘post_type’, ‘category’, ‘tax’, and ‘values’ attributes. The shortcode fetches posts of type ‘post’ and belonging to a specified category. It also filters posts based on taxonomy and term values. The shortcode then processes the content within the loop, returning the output.

Shortcode: [posts-loop]

Parameters

Here is a list of all possible posts-loop shortcode parameters and attributes:

  • category – Specifies the post category to be displayed
  • tax – Defines the taxonomy related to the post
  • values – Specifies the taxonomy terms to be displayed

Examples and Usage

Basic example – Showcases a simple usage of the ‘posts-loop’ shortcode without any parameters.

[posts-loop /]

Advanced examples

Display posts from a specific category using the ‘category’ parameter. In this example, we are fetching posts from the ‘news’ category.

[posts-loop category="news" /]

Display posts associated with a specific taxonomy and its values using ‘tax’ and ‘values’ parameters. Here, we are fetching posts associated with the ‘genre’ taxonomy and ‘thriller’ value.

[posts-loop tax="genre" values="thriller" /]

Combine multiple parameters to fetch posts from a specific category and a specific taxonomy. In this example, posts are fetched from the ‘news’ category that are also associated with the ‘genre’ taxonomy and ‘thriller’ value.

[posts-loop category="news" tax="genre" values="thriller" /]

PHP Function Code

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

Shortcode line:

add_shortcode('posts-loop', [$this, 'posts_loop_tag']);

Shortcode PHP function:

function posts_loop_tag($atts, $content)
    {
        if (empty($this->posts)) return '';
        $output = '';
        /** @var \WP_Post $post */
        foreach ($this->posts as $post) {

            if ($post->post_type == 'post' && isset($atts['category'])) {
                $post_categories = wp_get_post_categories($post->ID, ['fields' => 'id=>slug']);

                $category_slugs = array_map(
                    'sanitize_text_field',
                    explode(',', sanitize_text_field($atts['category']))
                );

                $result = array_intersect($post_categories, $category_slugs);

                if (empty($result)) continue;
            }

            if (isset($atts['tax'], $atts['values'])) {
                $post_terms = wp_get_object_terms($post->ID, sanitize_text_field($atts['tax']), ['fields' => 'id=>slug']);

                $term_slugs = array_map(
                    'sanitize_text_field',
                    explode(',', sanitize_text_field($atts['values']))
                );

                $result = array_intersect($post_terms, $term_slugs);

                if (empty($result)) continue;
            }

            $this->from($post);
            $this->define_post_shortcodes();
            $output .= do_shortcode(html_entity_decode($content));
        }

        return $output;
    }

Code file location:

mailoptin/mailoptin/src/core/src/EmailCampaigns/Shortcodes.php

Mailoptin [unsubscribe] Shortcode

The MailOptin ‘unsubscribe’ shortcode is designed to provide an easy way for users to opt-out of emails. The shortcode, when added, displays an ‘unsubscribe’ link in your emails. When clicked, it removes the user from your mailing list. This function ensures compliance with email marketing laws.

Shortcode: [unsubscribe]

Examples and Usage

Basic example – A straightforward usage of the unsubscribe shortcode is to simply use it without any parameters. This will return the default unsubscribe link.

[unsubscribe /]

Advanced examples

Displaying a custom message along with the unsubscribe link. The shortcode accepts a ‘message’ parameter, which allows you to specify a custom message that will be displayed alongside the unsubscribe link.

[unsubscribe message='Click here to unsubscribe' /]

Adding a return URL to the unsubscribe shortcode. This can be done by including a ‘return_url’ parameter in the shortcode. Once the user clicks on the unsubscribe link, they will be redirected to the specified URL.

[unsubscribe return_url='https://www.yourwebsite.com' /]

Combining multiple parameters. The unsubscribe shortcode can accept multiple parameters at once. In this example, we’re specifying both a custom message and a return URL.

[unsubscribe message='Click here to unsubscribe' return_url='https://www.yourwebsite.com' /]

PHP Function Code

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

Shortcode line:

add_shortcode('unsubscribe', [$this, 'unsubscribe']);

Shortcode PHP function:

function unsubscribe()
    {
        return '{{unsubscribe}}';
    }

Code file location:

mailoptin/mailoptin/src/core/src/EmailCampaigns/Shortcodes.php

Mailoptin [webversion] Shortcode

The MailOptin ‘webversion’ shortcode is a functional tool that returns a web version of your email. It simplifies email marketing by providing a web-based version of your content.

Shortcode: [webversion]

Examples and Usage

Basic example – A simple usage of the provided shortcode to display the web version of the content.

[webversion]

PHP Function Code

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

Shortcode line:

add_shortcode('webversion', [$this, 'webversion']);

Shortcode PHP function:

function webversion()
    {
        return '{{webversion}}';
    }

Code file location:

mailoptin/mailoptin/src/core/src/EmailCampaigns/Shortcodes.php

Mailoptin [company-name] Shortcode

The ‘company-name’ shortcode from the MailOptin plugin retrieves and displays the company’s name. The function ‘company_name’ returns the value stored in ‘{{company_name}}’.

Shortcode: [company-name]

Examples and Usage

Basic example – A straightforward usage of the shortcode to display the company name on your webpage.

[company-name /]

PHP Function Code

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

Shortcode line:

add_shortcode('company-name', [$this, 'company_name']);

Shortcode PHP function:

function company_name()
    {
        return '{{company_name}}';
    }

Code file location:

mailoptin/mailoptin/src/core/src/EmailCampaigns/Shortcodes.php

Mailoptin [company-address] Shortcode

The ‘company-address’ shortcode from the MailOptin plugin is designed to return the company’s address. It’s a simple yet effective tool for developers. This shortcode fetches and displays the stored company address, making it easy for users to maintain consistency across their WordPress site.

Shortcode: [company-address]

Examples and Usage

Basic example – The following shortcode displays the company’s address as stored in the plugin’s settings.

[company-address /]

PHP Function Code

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

Shortcode line:

add_shortcode('company-address', [$this, 'company_address']);

Shortcode PHP function:

function company_address()
    {
        return '{{company_address}}';
    }

Code file location:

mailoptin/mailoptin/src/core/src/EmailCampaigns/Shortcodes.php

Mailoptin [company-address2] Shortcode

The MailOptin ‘company-address2’ shortcode is used to retrieve and display the second line of the company’s address. When inserted into a page or post, it pulls the data from the ‘company_address_2’ field and displays it on the frontend.

Shortcode: [company-address2]

Examples and Usage

Basic example – The shortcode is used to display the company’s second address on the website.

[company-address2 /]

PHP Function Code

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

Shortcode line:

add_shortcode('company-address2', [$this, 'company_address2']);

Shortcode PHP function:

function company_address2()
    {
        return '{{company_address_2}}';
    }

Code file location:

mailoptin/mailoptin/src/core/src/EmailCampaigns/Shortcodes.php

Mailoptin [company-city] Shortcode

The MailOptin ‘company-city’ shortcode is a custom WordPress plugin that returns the company’s city. This is a useful tool for businesses that want to display their location on their website. This shortcode, when added to a post or page, will automatically insert the city of the company. This can be particularly useful for local SEO purposes.

Shortcode: [company-city]

Examples and Usage

Basic example – The shortcode ‘company-city’ is used to display the city of the company.

[company-city /]

PHP Function Code

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

Shortcode line:

add_shortcode('company-city', [$this, 'company_city']);

Shortcode PHP function:

function company_city()
    {
        return '{{company_city}}';
    }

Code file location:

mailoptin/mailoptin/src/core/src/EmailCampaigns/Shortcodes.php

Mailoptin [company-state] Shortcode

The MailOptin ‘company-state’ shortcode is a function that retrieves and displays the company’s state. It’s a dynamic way to add specific location details to your site.

Shortcode: [company-state]

Examples and Usage

Basic example – The given shortcode is utilized to display the company’s state. The value of ‘company-state’ is fetched and displayed wherever this shortcode is placed.

[company-state /]

PHP Function Code

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

Shortcode line:

add_shortcode('company-state', [$this, 'company_state']);

Shortcode PHP function:

function company_state()
    {
        return '{{company_state}}';
    }

Code file location:

mailoptin/mailoptin/src/core/src/EmailCampaigns/Shortcodes.php

Mailoptin [company-zip] Shortcode

The MailOptin ‘company-zip’ shortcode is a handy tool that allows you to display the company’s zip code on your WordPress site. It retrieves the zip code from the company’s profile.

Shortcode: [company-zip]

Examples and Usage

Basic example – A simple usage of the ‘company-zip’ shortcode to display the company’s zip code on the webpage.

[company-zip]

PHP Function Code

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

Shortcode line:

add_shortcode('company-zip', [$this, 'company_zip']);

Shortcode PHP function:

function company_zip()
    {
        return '{{company_zip}}';
    }

Code file location:

mailoptin/mailoptin/src/core/src/EmailCampaigns/Shortcodes.php

Mailoptin [company-country] Shortcode

The MailOptin ‘company-country’ shortcode is a simple yet powerful tool. It allows you to dynamically display the country of your company on your WordPress site. This shortcode retrieves the country data stored under ‘company_country’ and displays it where the shortcode is inserted.

Shortcode: [company-country]

Examples and Usage

Basic example – An instance where the company_country shortcode is used without any parameters

[company-country]

PHP Function Code

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

Shortcode line:

add_shortcode('company-country', [$this, 'company_country']);

Shortcode PHP function:

function company_country()
    {
        return '{{company_country}}';
    }

Code file location:

mailoptin/mailoptin/src/core/src/EmailCampaigns/Shortcodes.php

Mailoptin [post-title] Shortcode

The MailOptin plugin shortcode ‘post-title’ retrieves the title of the current WordPress post. It’s a simple yet powerful tool for customizing content.

Shortcode: [post-title]

Examples and Usage

Basic Example – A simple usage of the ‘post-title’ shortcode without any parameters. This will display the title of the current post.

[post-title]

PHP Function Code

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

Shortcode line:

add_shortcode('post-title', [$this, 'post_title_tag']);

Shortcode PHP function:

function post_title_tag()
    {
        return $this->wp_post_obj->post_title;
    }

Code file location:

mailoptin/mailoptin/src/core/src/EmailCampaigns/Shortcodes.php

Mailoptin [post-content] Shortcode

The MailOptin ‘post-content’ shortcode allows you to display the content of a post in your email campaign. It retrieves the content from the WordPress post object and applies it to the email campaign.

Shortcode: [post-content]

Examples and Usage

Basic example – A simple usage of the ‘post-content’ shortcode to display the content of a specific post in an email campaign.

[post-content id=3 /]

PHP Function Code

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

Shortcode line:

add_shortcode('post-content', [$this, 'post_content_tag']);

Shortcode PHP function:

function post_content_tag()
    {
        return apply_filters(
            'mo_email_campaign_shortcode_post_content',
            $this->post_content($this->wp_post_obj),
            $this->wp_post_obj,
            $this->email_campaign_id
        );
    }

Code file location:

mailoptin/mailoptin/src/core/src/EmailCampaigns/Shortcodes.php

Mailoptin [post-excerpt] Shortcode

The MailOptin ‘post-excerpt’ shortcode is a handy tool for displaying post excerpts. This shortcode calls the ‘post_excerpt_tag’ function, which returns the excerpt of a WordPress post. It uses ‘wpautop’ for formatting the excerpt in a paragraph.

Shortcode: [post-excerpt]

Examples and Usage

Basic example – The shortcode ‘post-excerpt’ is used to display the excerpt of a post. Here, no additional parameters are required.

[post-excerpt /]

PHP Function Code

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

Shortcode line:

add_shortcode('post-excerpt', [$this, 'post_excerpt_tag']);

Shortcode PHP function:

function post_excerpt_tag()
    {
        return wpautop($this->wp_post_obj->post_excerpt);
    }

Code file location:

mailoptin/mailoptin/src/core/src/EmailCampaigns/Shortcodes.php

Mailoptin [post-feature-image] Shortcode

MailOptin’s ‘post-feature-image’ shortcode is a handy tool for WordPress users. It generates an HTML image tag for the featured image of a post. The shortcode can also accept a default image URL as an attribute. If the post doesn’t have a featured image, it will use the default image. This ensures that an image is always displayed, enhancing the visual appeal of your content.

Shortcode: [post-feature-image]

Parameters

Here is a list of all possible post-feature-image shortcode parameters and attributes:

  • default – a fallback image if the post feature image is not set

Examples and Usage

Basic example – A simple usage of the ‘post-feature-image’ shortcode to display the featured image of a post.

[post-feature-image /]

For more advanced usage, you can specify a default image to be displayed when the post doesn’t have a featured image. This is done by passing the ‘default’ attribute to the shortcode with the URL of the default image.

Advanced examples

Example 1: Using the ‘post-feature-image’ shortcode with a default image URL. If the post doesn’t have a featured image, the specified default image will be displayed.

[post-feature-image default="https://yourwebsite.com/path/to/default/image.jpg" /]

Example 2: Using the ‘post-feature-image’ shortcode within a loop to display the featured images of multiple posts. If a post doesn’t have a featured image, the specified default image will be displayed.


<?php
if ( have_posts() ) :
    while ( have_posts() ) : the_post();
        echo do_shortcode('[post-feature-image default="https://yourwebsite.com/path/to/default/image.jpg" /]');
    endwhile;
endif;
?>

PHP Function Code

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

Shortcode line:

add_shortcode('post-feature-image', [$this, 'post_feature_image_tag']);

Shortcode PHP function:

function post_feature_image_tag($att)
    {
        $default_feature_image = ! empty($att['default']) ? $att['default'] : '';

        return sprintf(
            '<img class="mo-post-feature-image" src="%s" alt="%s">',
            $this->feature_image($this->wp_post_obj, $this->email_campaign_id, $default_feature_image),
            $this->feature_image_alt($this->wp_post_obj)
        );
    }

Code file location:

mailoptin/mailoptin/src/core/src/EmailCampaigns/Shortcodes.php

Mailoptin [post-feature-image-url] Shortcode

The MailOptin plugin shortcode ‘post-feature-image-url’ retrieves the URL of the post’s featured image. This shortcode allows you to specify a default image URL if the post does not have a featured image. It uses the ‘feature_image’ function to return the URL, ensuring seamless integration with your email campaigns.

Shortcode: [post-feature-image-url]

Parameters

Here is a list of all possible post-feature-image-url shortcode parameters and attributes:

  • default – default image URL if there’s no feature image for the post

Examples and Usage

Basic Example – A simple usage of the shortcode to fetch the default featured image URL of a post:

[post-feature-image-url /]

Advanced Examples

Using the shortcode with a specific default image URL. If the post does not have a featured image, this URL will be returned:

[post-feature-image-url default='https://example.com/default-image.jpg' /]

Another advanced usage could be to use the shortcode within a PHP template file. This would allow you to programmatically set the default image URL based on certain conditions:

<?php echo do_shortcode("[post-feature-image-url default='https://example.com/default-image.jpg']"); ?>

These examples demonstrate the flexibility of the ‘post-feature-image-url’ shortcode. It can be used in a variety of contexts, from simply fetching the featured image URL of a post, to providing a fallback image URL, to being used programmatically within your theme’s template files.

PHP Function Code

In case you have difficulties debugging what causing issues with [post-feature-image-url] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('post-feature-image-url', [$this, 'post_feature_image_url_tag']);

Shortcode PHP function:

function post_feature_image_url_tag($att)
    {
        $default_feature_image = ! empty($att['default']) ? $att['default'] : '';

        return $this->feature_image($this->wp_post_obj, $this->email_campaign_id, $default_feature_image);
    }

Code file location:

mailoptin/mailoptin/src/core/src/EmailCampaigns/Shortcodes.php

Mailoptin [post-url] Shortcode

The MailOptin plugin shortcode, ‘post-url’, is designed to retrieve and return the URL of a specific post. This is achieved by invoking the ‘post_url’ function on the WordPress post object.

Shortcode: [post-url]

Examples and Usage

Basic example – A simple usage of the shortcode to fetch and display the URL of the current post.

[post-url /]

PHP Function Code

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

Shortcode line:

add_shortcode('post-url', [$this, 'post_url_tag']);

Shortcode PHP function:

function post_url_tag()
    {
        return $this->post_url($this->wp_post_obj);
    }

Code file location:

mailoptin/mailoptin/src/core/src/EmailCampaigns/Shortcodes.php

Mailoptin [post-date] Shortcode

The MailOptin ‘post-date’ shortcode is a powerful tool for displaying the date of a post. It allows users to customize the date format. The associated PHP code enables the shortcode to fetch and display the post’s date. If a specific date format is provided, it will display the date in that format. The shortcode is versatile and can be used wherever date information is required in your WordPress posts.

Shortcode: [post-date]

Parameters

Here is a list of all possible post-date shortcode parameters and attributes:

  • format – Determines the date format of the post

Examples and Usage

Basic example – The ‘post-date’ shortcode can be used to display the date of a particular post.

[post-date /]

By default, this shortcode will display the post date in the format stored in the WordPress database. However, you can customize the format by passing the ‘format’ parameter to the shortcode. The ‘format’ parameter accepts any valid PHP date format string.

Advanced examples

Display the post date in a custom format. For instance, if you want to display the date in the format ‘Y-m-d’, you can do so by using the shortcode like this:

[post-date format="Y-m-d" /]

Another advanced usage of the shortcode is to display the date and time of the post. To do this, you can use the ‘format’ parameter with the value ‘Y-m-d H:i:s’.

[post-date format="Y-m-d H:i:s" /]

Please note that the ‘format’ parameter in the ‘post-date’ shortcode is optional. If not provided, the shortcode will default to the date format stored in the WordPress database.

PHP Function Code

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

Shortcode line:

add_shortcode('post-date', [$this, 'post_date_tag']);

Shortcode PHP function:

function post_date_tag($atts = [])
    {
        $atts = shortcode_atts(['format' => ''], $atts);

        if ( ! empty($atts['format'])) {
            return date($atts['format'], strtotime_utc($this->wp_post_obj->post_date));
        }

        return $this->wp_post_obj->post_date;
    }

Code file location:

mailoptin/mailoptin/src/core/src/EmailCampaigns/Shortcodes.php

Mailoptin [post-date-gmt format=”F j, Y”] Shortcode

The MailOptin ‘post-date-gmt’ shortcode retrieves the GMT date of a post. It accepts a ‘format’ attribute to customize the date display. By default, it returns the raw GMT date. If a format is specified, it returns the date in that format.

Shortcode: [post-date-gmt format="F j, Y"]

Parameters

Here is a list of all possible post-date-gmt format=”F j, Y” shortcode parameters and attributes:

  • format – Defines the date format in the GMT version of the post date.

Examples and Usage

Basic example – The shortcode displays the GMT date of the post without any specific format.

[post-date-gmt /]

With this shortcode, the post GMT date will be displayed as it is stored in the WordPress database.

Advanced examples

In this example, the shortcode is used to display the GMT date of the post in a specific format. The format attribute is passed to the shortcode to specify the desired date format.

[post-date-gmt format="Y-m-d" /]

This shortcode will display the post GMT date in the “Y-m-d” format (for example, 2022-03-20).

In the next example, the shortcode is used to display the GMT date and time of the post in a specific format.

[post-date-gmt format="Y-m-d H:i:s" /]

This shortcode will display the post GMT date and time in the “Y-m-d H:i:s” format (for example, 2022-03-20 14:30:00).

Note that the format attribute uses the PHP date() function’s format strings. You can customize the format string to display the date and time in any format you want.

PHP Function Code

In case you have difficulties debugging what causing issues with [post-date-gmt format="F j, Y"] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('post-date-gmt', [$this, 'post_date_gmt_tag']);

Shortcode PHP function:

function post_date_gmt_tag($atts)
    {
        $atts = shortcode_atts(['format' => ''], $atts);

        if ( ! empty($atts['format'])) {
            return date($atts['format'], strtotime_utc($this->wp_post_obj->post_date_gmt));
        }

        return $this->wp_post_obj->post_date_gmt;
    }

Code file location:

mailoptin/mailoptin/src/core/src/EmailCampaigns/Shortcodes.php

Mailoptin [post-categories] Shortcode

The MailOptin ‘post-categories’ shortcode is designed to display the categories of a post. . It accepts a ‘link’ attribute which, when set to ‘true’, will display the categories as clickable links. If ‘link’ is set to ‘false’, it will only show the category names.

Shortcode: [post-categories]

Parameters

Here is a list of all possible post-categories shortcode parameters and attributes:

  • link – Determines if category names are clickable links.

Examples and Usage

Basic example – Utilize the shortcode to display the categories related to a specific post. This example uses the default attribute where the link is set to true. Thus, each category will be linked to its respective archive page.

[post-categories]

Advanced examples

Display the categories related to a specific post, but without any links. This can be useful if you want to show the categories as plain text rather than hyperlinked text. To achieve this, set the ‘link’ attribute to ‘false’.

[post-categories link=false]

Another advanced usage could be to use the shortcode within a PHP function. This is helpful when you want to programmatically display the categories of a post within your theme or plugin. Use the ‘do_shortcode’ function to execute the shortcode within PHP.

<?php echo do_shortcode('[post-categories link=false]'); ?>

PHP Function Code

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

Shortcode line:

add_shortcode('post-categories', [$this, 'post_categories_tag']);

Shortcode PHP function:

function post_categories_tag($atts)
    {
        $atts = shortcode_atts(['link' => 'true'], $atts);

        $output = '';

        $categories = get_the_term_list($this->wp_post_obj->ID, 'category', '', ', ');

        if ( ! is_wp_error($categories)) {
            $output = $atts['link'] == 'true' ? $categories : strip_tags($categories);
        }

        return $output;
    }

Code file location:

mailoptin/mailoptin/src/core/src/EmailCampaigns/Shortcodes.php

Mailoptin [post-terms] Shortcode

The MailOptin plugin shortcode ‘post-terms’ generates a list of terms associated with a post for a specified taxonomy. It sanitizes and retrieves these terms, and if ‘link’ is set to ‘true’, it outputs them as clickable links.

Shortcode: [post-terms]

Parameters

Here is a list of all possible post-terms shortcode parameters and attributes:

  • tax – Defines the taxonomy to retrieve terms from.
  • link – If set to true, the terms will be linked. If false, they won’t be linked.

Examples and Usage

Basic Example – Displaying terms of a post without links.

[post-terms tax="category" link="false"]

In this example, the shortcode is used to display the terms of a post from the “category” taxonomy. The ‘link’ attribute is set to ‘false’, meaning the terms will be displayed as plain text without any links.

Advanced Examples

Displaying terms of a post with links from a custom taxonomy.

[post-terms tax="custom_taxonomy"]

In this advanced example, the shortcode is used to display terms from a custom taxonomy named ‘custom_taxonomy’. By default, the ‘link’ attribute is set to ‘true’, so each term will be displayed as a link to its respective term archive page.

Displaying terms of a post without links from a custom taxonomy.

[post-terms tax="custom_taxonomy" link="false"]

In this advanced example, the shortcode is used to display terms from a custom taxonomy named ‘custom_taxonomy’. The ‘link’ attribute is set to ‘false’, so the terms will be displayed as plain text without any links.

PHP Function Code

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

Shortcode line:

add_shortcode('post-terms', [$this, 'post_terms_tag']);

Shortcode PHP function:

function post_terms_tag($atts)
    {
        $output = '';

        $atts = shortcode_atts(['tax' => '', 'link' => 'true'], $atts);

        $tax = sanitize_key($atts['tax']);

        if ( ! empty($tax)) {

            $terms = get_the_term_list($this->wp_post_obj->ID, $tax, '', ', ');

            if ( ! is_wp_error($terms)) {
                $output = $atts['link'] == 'true' ? $terms : strip_tags($terms);
            }
        }

        return $output;
    }

Code file location:

mailoptin/mailoptin/src/core/src/EmailCampaigns/Shortcodes.php

Mailoptin [post-id] Shortcode

The MailOptin ‘post-id’ shortcode is a powerful tool that retrieves and displays the ID of a current WordPress post. This shortcode, when added to a post, calls the ‘post_id_tag’ function, which in turn accesses the WordPress post object and returns the ID of the post. This is especially useful for developers needing to reference specific posts programmatically.

Shortcode: [post-id]

Examples and Usage

Basic example – The shortcode below displays the post ID of the current post.

[post-id /]

Advanced examples

Below, we use the shortcode in conjunction with other shortcodes and parameters to create more complex outputs.

1. Displaying the post ID within a custom text:

The ID of this post is: [post-id /]

2. Using the shortcode to display the post ID within a table. This can be useful if you want to create a list of posts and their IDs.

[table][row][cell]Post ID: [post-id /][/cell][/row][/table]

3. Using the shortcode to link to the current post. This can be useful if you want to create a “read more” link that points to the current post.

[link url="https://yourwebsite.com/?p=[post-id /]"]Read more[/link]

Please note that these are just examples. The actual output will depend on the other shortcodes and parameters you are using.

PHP Function Code

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

Shortcode line:

add_shortcode('post-id', [$this, 'post_id_tag']);

Shortcode PHP function:

function post_id_tag()
    {
        return $this->wp_post_obj->ID;
    }

Code file location:

mailoptin/mailoptin/src/core/src/EmailCampaigns/Shortcodes.php

Mailoptin [post-author-name] Shortcode

The MailOptin shortcode ‘post-author-name’ displays the name of the post author. It allows the option to link the name to the author’s website. The PHP function ‘post_author_name_tag’ fetches the author’s details using their ID and outputs the display name. If ‘link’ is set to ‘true’, the author’s name will be hyperlinked.

Shortcode: [post-author-name]

Parameters

Here is a list of all possible post-author-name shortcode parameters and attributes:

  • link – Determines whether the author’s name is linked to their website or not

Examples and Usage

Basic example – The following shortcode is used to display the name of the post author, with a link to their profile page.

[post-author-name link=true /]

Advanced examples

In this example, the shortcode is used to display the name of the post author without a link to their profile page. This can be useful in situations where you want to display the author’s name, but don’t want to provide a link to their profile.

[post-author-name link=false /]

Another advanced usage could be to use the shortcode within a text block, to display the author’s name in a sentence or paragraph. In this case, the shortcode is embedded within a paragraph of text, providing a more integrated and seamless user experience.

<p>This post was written by [post-author-name link=true /].</p>

PHP Function Code

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

Shortcode line:

add_shortcode('post-author-name', [$this, 'post_author_name_tag']);

Shortcode PHP function:

function post_author_name_tag($atts)
    {
        $atts    = shortcode_atts(['link' => 'true'], $atts);
        $wp_user = get_user_by('id', $this->wp_post_obj->post_author);

        $output = $wp_user->display_name;

        if ($atts['link'] == 'true') {
            $output = '<a href="' . $wp_user->user_url . '">' . $wp_user->display_name . '</a>';
        }

        return $output;
    }

Code file location:

mailoptin/mailoptin/src/core/src/EmailCampaigns/Shortcodes.php

Mailoptin [post-author-website] Shortcode

The MailOptin shortcode, ‘post-author-website’, returns the website URL of the author of a specific post. This shortcode functions by fetching the user’s ID associated with the post and retrieving the linked website URL.

Shortcode: [post-author-website]

Examples and Usage

Basic example – Utilizing the given shortcode to display the website of the author of a post.

[post-author-website /]

PHP Function Code

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

Shortcode line:

add_shortcode('post-author-website', [$this, 'post_author_website_tag']);

Shortcode PHP function:

function post_author_website_tag()
    {
        return get_user_by('id', $this->wp_post_obj->post_author)->user_url;
    }

Code file location:

mailoptin/mailoptin/src/core/src/EmailCampaigns/Shortcodes.php

Mailoptin [post-author-email] Shortcode

The MailOptin plugin shortcode ‘post-author-email’ retrieves the email of the post’s author. This is achieved by using the ‘get_user_by’ function which fetches the user’s email based on their ID.

Shortcode: [post-author-email]

Parameters

Here is a list of all possible post-author-email shortcode parameters and attributes:

  • post-author-email – Displays the email address of the post author.
  • id – Unique identifier for the specific user.

Examples and Usage

Basic example – Showcases the usage of the ‘post-author-email’ shortcode to display the email of the author of a specific post.

[post-author-email id=1 /]

Advanced examples

Example 1: Using the shortcode to display the author’s email of a specific post by referencing the post ID. If the post with the given ID is not found, the shortcode will return an error message.

[post-author-email id=123 /]

Example 2: In this example, the shortcode is used within a loop to display the email of the author for each post in a list. This could be useful in a blog archive or category page, for example.


<?php
if ( have_posts() ) : 
    while ( have_posts() ) : the_post();
        echo do_shortcode('[post-author-email id='.get_the_ID().' /]');
    endwhile; 
endif;
?>

Example 3: This example demonstrates how the shortcode can be used directly within a PHP script. This might be useful in a custom template file, for example.


<?php
$post_id = 123; // Change this to your post ID
echo do_shortcode('[post-author-email id='.$post_id.' /]');
?>

PHP Function Code

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

Shortcode line:

add_shortcode('post-author-email', [$this, 'post_author_email_tag']);

Shortcode PHP function:

function post_author_email_tag()
    {
        return get_user_by('id', $this->wp_post_obj->post_author)->user_email;
    }

Code file location:

mailoptin/mailoptin/src/core/src/EmailCampaigns/Shortcodes.php

Mailoptin [post-author-avatar-url] Shortcode

The MailOptin shortcode ‘post-author-avatar-url’ fetches the avatar URL of the post author. It allows customization of avatar size, defaulting to ‘512’ if no size is specified.

Shortcode: [post-author-avatar-url]

Parameters

Here is a list of all possible post-author-avatar-url shortcode parameters and attributes:

  • size – defines the size of the author’s avatar in pixels

Examples and Usage

Basic example – The shortcode displays the avatar of the post author. The default size is 512.

[post-author-avatar-url /]

Advanced examples

Using the shortcode to display the post author’s avatar with a custom size. The size parameter allows you to specify the size of the avatar you want to display.

[post-author-avatar-url size=256 /]

Using the shortcode to display the post author’s avatar with a different size. This example shows how you can use the shortcode to display an avatar of a different size.

[post-author-avatar-url size=128 /]

Note: The size parameter in the shortcode is optional. If not specified, the default size of 512 will be used.

PHP Function Code

In case you have difficulties debugging what causing issues with [post-author-avatar-url] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('post-author-avatar-url', [$this, 'post_author_avatar_url']);

Shortcode PHP function:

function post_author_avatar_url($atts)
    {
        if (empty($atts)) $atts = [];

        $atts['size'] = $atts['size'] ?? '512';

        return apply_filters(
            'mailoptin_post_author_avatar_url',
            get_avatar_url($this->post_author_email_tag(), $atts),
            $this->post_author_email_tag(),
            $this
        );
    }

Code file location:

mailoptin/mailoptin/src/core/src/EmailCampaigns/Shortcodes.php

Mailoptin [post-meta] Shortcode

The MailOptin plugin shortcode ‘post-meta’ retrieves and displays custom metadata from posts. This shortcode requires a ‘key’ parameter, which corresponds to the custom field name. It sanitizes the key and fetches the associated value, returning an empty string if the key is not found.

Shortcode: [post-meta]

Parameters

Here is a list of all possible post-meta shortcode parameters and attributes:

  • key – The specific metadata key you want to retrieve from a post

Examples and Usage

Basic example – In this example, we are using the ‘post-meta’ shortcode to fetch and display the value of a specific post meta field. We are specifying the ‘key’ attribute to select the required post meta field.

[post-meta key='author' /]

Advanced examples

Displaying the post meta field value with a default value. If the specified post meta field is not found or its value is empty, the default value will be displayed.

[post-meta key='publisher' default='Not available' /]

Using the ‘post-meta’ shortcode inside a text block. This allows us to include the value of a post meta field within a larger block of text.


<p>This post was written by [post-meta key='author' /].</p>

Note: In the above examples, ‘author’ and ‘publisher’ are the keys of the post meta fields. You should replace them with the keys of the post meta fields you want to display.

PHP Function Code

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

Shortcode line:

add_shortcode('post-meta', [$this, 'post_meta_tag']);

Shortcode PHP function:

function post_meta_tag($atts)
    {
        $atts = shortcode_atts(['key' => ''], $atts);

        $key = sanitize_key($atts['key']);

        if (empty($key)) return '';

        return get_post_meta($this->wp_post_obj->ID, $key, true);
    }

Code file location:

mailoptin/mailoptin/src/core/src/EmailCampaigns/Shortcodes.php

Mailoptin [acf-field] Shortcode

The MailOptin plugin shortcode ‘acf-field’ retrieves custom field data. It accepts parameters like ‘field’, ‘post_id’, and ‘format_value’. The ‘field’ parameter is sanitized and ‘post_id’ is converted into an absolute integer. If ‘field’ is empty or ‘get_field’ function doesn’t exist, it returns an empty string. If ‘post_id’ is empty, it defaults to the current post ID. The ‘get_field’ function fetches the field value. If the value is an array, it’s converted into a string.

Shortcode: [acf-field]

Parameters

Here is a list of all possible acf-field shortcode parameters and attributes:

  • field – the specific data field you want to display
  • post_id – the ID of the post where the field is located
  • format_value – determines if the value should be formatted

Examples and Usage

Basic example – Displaying a custom field value by specifying the field name.

[acf-field field="my_custom_field"]

Advanced examples

Using the shortcode to display a custom field value by specifying the field name and the post ID. This allows you to fetch and display the value of a custom field from a specific post.

[acf-field field="my_custom_field" post_id="123"]

Using the shortcode to display a custom field value by specifying the field name, the post ID, and the format value. The format value parameter determines whether the returned value should be formatted or not. If set to true, the value will be formatted according to its field type. If set to false, the raw value will be returned.

[acf-field field="my_custom_field" post_id="123" format_value="true"]

PHP Function Code

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

Shortcode line:

add_shortcode('acf-field', [$this, 'acf_custom_field']);

Shortcode PHP function:

function acf_custom_field($atts)
    {
        $atts = shortcode_atts(['field' => '', 'post_id' => '', 'format_value' => true], $atts);

        $field        = sanitize_key($atts['field']);
        $post_id      = absint($atts['post_id']);
        $format_value = in_array($atts['format_value'], ['true', true], true);

        if (empty($field) || ! function_exists('get_field')) return '';

        if (empty($post_id)) $post_id = $this->wp_post_obj->ID;

        $value = get_field($field, $post_id, $format_value);

        if (is_array($value)) {
            $value = @implode(', ', $value);
        }

        return $value;
    }

Code file location:

mailoptin/mailoptin/src/core/src/EmailCampaigns/Shortcodes.php

Mailoptin [mo-optin-form-wrapper] Shortcode

The MailOptin shortcode is a powerful tool that generates an opt-in form. It allows customization of the form’s class, style, and content. The shortcode function creates a form container with unique identifiers and styles. It also checks if the name field is hidden, adjusting the class accordingly. The form itself is built using either a standard or custom HTML structure, with the option to include branding inside or outside the form. It then returns the complete HTML for the opt-in form.

Shortcode: [mo-optin-form-wrapper]

Parameters

Here is a list of all possible mo-optin-form-wrapper shortcode parameters and attributes:

  • class – adds extra CSS classes to the form wrapper
  • style – adds inline CSS styles to the form wrapper

Examples and Usage

Basic example – Display the opt-in form with default settings

[mo-optin-form-wrapper /]

Advanced examples

Display the opt-in form with a specific class and style. The class and style attributes allow you to further customize the appearance of the opt-in form.

[mo-optin-form-wrapper class="my-custom-class" style="background-color: yellow; color: black;" /]

Display the opt-in form with a specific class. This allows you to apply custom CSS styles to the opt-in form wrapper.

[mo-optin-form-wrapper class="my-custom-class" /]

Display the opt-in form with a specific style. This allows you to directly apply CSS styles to the opt-in form wrapper.

[mo-optin-form-wrapper style="background-color: yellow; color: black;" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [mo-optin-form-wrapper] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('mo-optin-form-wrapper', [$this, 'shortcode_optin_form_wrapper']);

Shortcode PHP function:

function shortcode_optin_form_wrapper($atts, $content)
    {
        $optin_campaign_uuid        = $this->optin_campaign_uuid;
        $optin_css_id               = $this->optin_css_id;
        $form_container_styles      = $this->form_container_styles();
        $name_email_class_indicator = $this->get_customizer_value('hide_name_field') === true ? 'mo-has-email' : 'mo-has-name-email';

        $atts = shortcode_atts(
            array(
                'class' => '',
                'style' => '',
            ),
            $atts
        );

        $class = esc_attr($atts['class']);
        $class = "mo-optin-form-wrapper $name_email_class_indicator $class";

        $style = esc_html($atts['style']);
        $style = "$form_container_styles $style";

        $html = "<div id=\"$optin_css_id\" class=\"$class\" style=\"$style\">";
        $html .= apply_filters('mo_optin_form_before_form_tag', '', $this->optin_campaign_id, $this->optin_campaign_type, $optin_campaign_uuid, $optin_css_id);

        if ( ! $this->get_customizer_value('use_custom_html')) {
            $html .= "<form method=\"post\" class='mo-optin-form' id='{$optin_css_id}_form' style='margin:0;'>";
        } else {
            // remove text alignment to center set in lightbox modal div container.
            $html .= "<style type=\"text/css\">#{$optin_campaign_uuid}.moOptinForm.moModal{text-align:initial !important;}</style>";
        }

        $html .= do_shortcode($content);

        // Don't change type from text to email to prevent "An invalid form control with name='text' is not focusable." error
        $html .= "<input id='{$this->optin_css_id}_honeypot_email_field' type='text' name='mo-hp-email' value='' style='display:none'/>";
        $html .= '<input id="' . $this->optin_css_id . '_honeypot_website_field" type="text" name="mo-hp-website" value="" style="display:none" />';

        $html .= apply_filters('mo_optin_form_before_closing_form_tag', '', $this->optin_campaign_id, $this->optin_campaign_type, $optin_campaign_uuid, $optin_css_id);
        if ( ! $this->get_customizer_value('use_custom_html')) {
            $html .= '</form>';
        }
        $html .= apply_filters('mo_optin_form_after_form_tag', '', $this->optin_campaign_id, $this->optin_campaign_type, $optin_campaign_uuid, $optin_css_id);

        $html .= $this->processing_success_structure();

        if ( ! $this->customizer_defaults['mo_optin_branding_outside_form'] && $this->optin_campaign_type != 'lightbox') {
            $html .= $this->branding_attribute();
        }

        $html .= "</div>";

        if ($this->customizer_defaults['mo_optin_branding_outside_form'] || $this->optin_campaign_type == 'lightbox') {
            $html .= $this->branding_attribute();
        }

        return $html;
    }

Code file location:

mailoptin/mailoptin/src/core/src/OptinForms/AbstractOptinTheme.php

Mailoptin [mo-optin-form-fields-wrapper] Shortcode

The MailOptin shortcode ‘mo-optin-form-fields-wrapper’ is used to customize the appearance of opt-in forms. It allows users to define the HTML tag, class, and style. If ‘use_custom_html’ is enabled, it returns the custom HTML content. It also supports the ‘display_only_button’ option, hiding the form fields when enabled.

Shortcode: [mo-optin-form-fields-wrapper]

Parameters

Here is a list of all possible mo-optin-form-fields-wrapper shortcode parameters and attributes:

  • tag – HTML tag to wrap the optin form fields, default is ‘div’
  • class – Optional additional CSS classes for the wrapper
  • style – Additional inline CSS styles for the wrapper

Examples and Usage

Basic example – The following shortcode is a simple usage of the ‘mo-optin-form-fields-wrapper’ shortcode without any additional parameters.

[mo-optin-form-fields-wrapper][/mo-optin-form-fields-wrapper]

Advanced examples

Using the shortcode to define a wrapper with a specific HTML tag and class. The ‘tag’ parameter is used to define the HTML tag for the wrapper, and the ‘class’ parameter is used to assign a class to it.

[mo-optin-form-fields-wrapper tag="section" class="my-custom-class"][/mo-optin-form-fields-wrapper]

Using the shortcode to define a wrapper with a specific HTML tag, class, and style. The ‘style’ parameter is used to apply inline CSS to the wrapper. In this example, the wrapper is hidden by setting the ‘display’ property to ‘none’.

[mo-optin-form-fields-wrapper tag="div" class="my-custom-class" style="display:none;"][/mo-optin-form-fields-wrapper]

Using the shortcode to define a wrapper with a specific HTML tag, class, and style. The ‘style’ parameter is used to apply inline CSS to the wrapper. In this example, the wrapper is given a red background color and a width of 100%.

[mo-optin-form-fields-wrapper tag="div" class="my-custom-class" style="background-color:red; width: 100%;"][/mo-optin-form-fields-wrapper]

PHP Function Code

In case you have difficulties debugging what causing issues with [mo-optin-form-fields-wrapper] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('mo-optin-form-fields-wrapper', [$this, 'shortcode_optin_form_fields_wrapper']);

Shortcode PHP function:

function shortcode_optin_form_fields_wrapper($atts, $content)
    {
        if ($this->get_customizer_value('use_custom_html')) {
            return do_shortcode($this->get_customizer_value('custom_html_content'));
        }

        $atts = shortcode_atts(
            array(
                'tag'   => 'div',
                'class' => '',
                'style' => '',
            ),
            $atts
        );

        $tag = $atts['tag'];

        $class = '';
        if ( ! empty($atts['class'])) {
            $class = ' ' . esc_attr($atts['class']);
        }

        $class = "mo-optin-fields-wrapper{$class}";

        $style = '';
        if ($this->get_customizer_value('display_only_button')) {
            $style .= 'display:none;';
        }

        $style .= esc_attr($atts['style']);

        $html = "<$tag class=\"$class\" style=\"$style\">";
        $html .= do_shortcode($content);
        $html .= "</$tag>";

        return $html;
    }

Code file location:

mailoptin/mailoptin/src/core/src/OptinForms/AbstractOptinTheme.php

Mailoptin [mo-optin-form-cta-wrapper] Shortcode

The MailOptin plugin shortcode, ‘mo-optin-form-cta-wrapper’, generates a wrapper for Call-to-Action (CTA) forms. It allows customization of the tag, class, and style attributes. The shortcode hides the CTA button if it’s inactive and applies additional styles if specified. It wraps the content within the designated HTML tag, creating a flexible layout.

Shortcode: [mo-optin-form-cta-wrapper]

Parameters

Here is a list of all possible mo-optin-form-cta-wrapper shortcode parameters and attributes:

  • tag – defines the HTML tag for the wrapper, default is ‘div’.
  • class – adds additional CSS classes to the wrapper.
  • style – allows inline CSS styles to be added to the wrapper.

Examples and Usage

Basic example – In this example, we will use the shortcode to add a wrapper for our opt-in form Call-To-Action (CTA). The wrapper will be a div and will have the class “my-cta-class”.

[mo-optin-form-cta-wrapper tag="div" class="my-cta-class"]Your CTA Content Here[/mo-optin-form-cta-wrapper]

Advanced examples

In the following example, we will add some inline CSS to our wrapper. We will also change the tag to a section instead of a div. The inline CSS will give our CTA a background color of light blue and a padding of 10px.

[mo-optin-form-cta-wrapper tag="section" class="my-cta-class" style="background-color:lightblue; padding:10px;"]Your CTA Content Here[/mo-optin-form-cta-wrapper]

In another advanced example, we will use the shortcode to hide our CTA if the CTA button is inactive. We do this by setting the display style to none if the CTA button is not active.

[mo-optin-form-cta-wrapper tag="div" class="my-cta-class" style="display:none;"]Your CTA Content Here[/mo-optin-form-cta-wrapper]

PHP Function Code

In case you have difficulties debugging what causing issues with [mo-optin-form-cta-wrapper] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('mo-optin-form-cta-wrapper', [$this, 'shortcode_optin_form_cta_wrapper']);

Shortcode PHP function:

function shortcode_optin_form_cta_wrapper($atts, $content)
    {
        $atts = shortcode_atts(
            array(
                'tag'   => 'div',
                'class' => '',
                'style' => '',
            ),
            $atts
        );

        $tag = $atts['tag'];

        $class = ' ' . esc_attr($atts['class']);
        $class = "mo-optin-form-cta-wrapper{$class}";

        $style = '';
        if ( ! OptinCampaignsRepository::is_cta_button_active($this->optin_campaign_id)) {
            $style .= 'display:none;';
        }

        $style .= esc_attr($atts['style']);

        $html = "<$tag class=\"$class\" style=\"$style\">";
        $html .= do_shortcode($content);
        $html .= "</$tag>";

        return $html;
    }

Code file location:

mailoptin/mailoptin/src/core/src/OptinForms/AbstractOptinTheme.php

Mailoptin [mo-optin-form-headline] Shortcode

The MailOptin shortcode ‘mo-optin-form-headline’ is used to customize the headline of your opt-in form. It applies filters before and after the headline, allowing for custom styling and additional content. This shortcode also includes attributes for class, style, and tag. The ‘class’ attribute adds a custom CSS class, ‘style’ allows inline CSS, and ‘tag’ defines the HTML tag for the headline.

Shortcode: [mo-optin-form-headline]

Parameters

Here is a list of all possible mo-optin-form-headline shortcode parameters and attributes:

  • class – Adds a custom CSS class to the headline
  • style – Adds inline CSS styles to the headline
  • tag – Changes the HTML tag of the headline, default is ‘h2’

Examples and Usage

Basic example – The shortcode is used to display the headline of an opt-in form with default parameters.

[mo-optin-form-headline /]

Advanced examples

Using the shortcode to display the headline of an opt-in form and modifying the tag, class, and style attributes. The headline will be displayed within an h1 tag, with a custom class and custom style.

[mo-optin-form-headline tag="h1" class="custom-headline" style="color: red; font-size: 24px;" /]

Using the shortcode to display the headline of an opt-in form and modifying only the class attribute. The headline will be displayed within the default h2 tag, with a custom class and default style.

[mo-optin-form-headline class="custom-headline" /]

Using the shortcode to display the headline of an opt-in form and modifying only the style attribute. The headline will be displayed within the default h2 tag, with a default class and custom style.

[mo-optin-form-headline style="color: red; font-size: 24px;" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [mo-optin-form-headline] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('mo-optin-form-headline', [$this, 'shortcode_optin_form_headline']);

Shortcode PHP function:

function shortcode_optin_form_headline($atts)
    {
        $headline = apply_filters('mo_optin_form_before_headline', '', $this->optin_campaign_id, $this->optin_campaign_type, $this->optin_campaign_uuid, $atts);
        $headline .= $this->get_customizer_value('headline');
        $headline .= apply_filters('mo_optin_form_after_headline', '', $this->optin_campaign_id, $this->optin_campaign_type, $this->optin_campaign_uuid, $atts);

        $headline = $this->embed_shortcode_parser($headline);

        $headline_styles = $this->headline_styles();

        $atts = shortcode_atts(
            array(
                'class' => '',
                'style' => '',
                'tag'   => 'h2',
            ),
            $atts
        );

        $tag = esc_html($atts['tag']);

        $class = "mo-optin-form-headline " . esc_attr($atts['class']);

        $style = esc_attr($atts['style']);
        $style = "$headline_styles $style";

        if ($atts['tag'] == 'h2') {
            $style .= "padding: 0;";
        }

        $html = "<$tag class=\"$class\" style=\"$style\">$headline</$tag>";

        return $html;
    }

Code file location:

mailoptin/mailoptin/src/core/src/OptinForms/AbstractOptinTheme.php

Mailoptin [mo-close-optin] Shortcode

The MailOptin shortcode is a functional tool that enables the closing of an optin form. It checks if the ‘hide_close_button’ option is enabled. If not, it generates a close button with customizable class and style attributes. This button, when clicked, closes the optin form.

Shortcode: [mo-close-optin]

Parameters

Here is a list of all possible mo-close-optin shortcode parameters and attributes:

  • class – Adds a custom CSS class to the close button.
  • style – Applies inline CSS styles to the close button.

Examples and Usage

Basic example – The following code represents a basic usage of the ‘mo-close-optin’ shortcode. Here, we are not passing any parameters to the shortcode, so it will display the close button with default settings.

[mo-close-optin /]

Advanced examples

In the first advanced example, we are passing the ‘class’ parameter to the shortcode. This will add a custom CSS class to the close button, allowing you to style it in a specific way. Replace ‘my-custom-class’ with your own CSS class.

[mo-close-optin class='my-custom-class' /]

In the second advanced example, we are passing both the ‘class’ and ‘style’ parameters to the shortcode. This allows you to add a custom CSS class and inline styles to the close button. Replace ‘my-custom-class’ with your own CSS class and ‘color: red;’ with your own CSS styles.

[mo-close-optin class='my-custom-class' style='color: red;' /]

In the third advanced example, we are passing the ‘style’ parameter only. This allows you to add inline styles to the close button without adding a custom CSS class. Replace ‘color: blue;’ with your own CSS styles.

[mo-close-optin style='color: blue;' /]

PHP Function Code

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

Shortcode line:

add_shortcode('mo-close-optin', [$this, 'shortcode_optin_form_close_button']);

Shortcode PHP function:

function shortcode_optin_form_close_button($atts, $content = '')
    {
        if ($this->get_customizer_value('hide_close_button')) return '';

        $atts = array_map('esc_attr', shortcode_atts(
                array(
                    'class' => '',
                    'style' => '',
                ),
                $atts
            )
        );

        $title = __('Close optin form', 'mailoptin');

        $class = "mo-optin-form-close-icon " . esc_attr($atts['class']);

        $close_button = "<a href='#' rel=\"moOptin:close\" title=\"$title\" class=\"$class\" style='" . $atts['style'] . "'>";
        $close_button .= $content;
        $close_button .= '</a>';

        return $close_button;
    }

Code file location:

mailoptin/mailoptin/src/core/src/OptinForms/AbstractOptinTheme.php

Mailoptin [mo-optin-form-image] Shortcode

The MailOptin shortcode ‘mo-optin-form-image’ is used to display an opt-in form image. It offers customization options such as default image, style, and wrapper attributes. The shortcode checks if the form image is hidden. If not, it fetches the image URL and displays it with the specified style. It also wraps the image in a tag if wrapper is enabled.

Shortcode: [mo-optin-form-image]

Parameters

Here is a list of all possible mo-optin-form-image shortcode parameters and attributes:

  • default – sets the default image if no image is specified.
  • style – allows to apply custom CSS styles to the image.
  • wrapper_enabled – if set to ‘true’, it wraps the image with a specified tag.
  • wrapper_tag – specifies the HTML tag for wrapping the image.
  • wrapper_class – adds a custom class to the wrapper tag for styling.

Examples and Usage

Basic example – This shortcode example displays an optin form image with default settings.

[mo-optin-form-image]

Advanced examples

Displaying an optin form image with a specific style attribute and a default image URL. If the form image is hidden in the customizer settings, it will not be displayed.

[mo-optin-form-image style="width:100%; height:auto;" default="https://example.com/default-image.jpg"]

Using the shortcode to display an optin form image within a wrapper. The wrapper is enabled and uses a div tag. The wrapper also has a custom class.

[mo-optin-form-image wrapper_enabled="true" wrapper_tag="div" wrapper_class="custom-class"]

Combining multiple attributes for a more complex usage. In this example, the optin form image has a specific style, a default image URL, and is wrapped within a div tag with a custom class.

[mo-optin-form-image style="width:100%; height:auto;" default="https://example.com/default-image.jpg" wrapper_enabled="true" wrapper_tag="div" wrapper_class="custom-class"]

PHP Function Code

In case you have difficulties debugging what causing issues with [mo-optin-form-image] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('mo-optin-form-image', [$this, 'shortcode_optin_form_image']);

Shortcode PHP function:

function shortcode_optin_form_image($atts)
    {
        if ($this->get_customizer_value('hide_form_image', false)) return '';

        $atts = shortcode_atts(
            array(
                'default'         => '',
                'style'           => '',
                'wrapper_enabled' => false,
                'wrapper_tag'     => 'div',
                'wrapper_class'   => '',
            ),
            $atts
        );

        $style = esc_attr($atts['style']);

        $src = $this->get_form_image_url($atts['default']);

        $wrapper_class = ' ' . $atts['wrapper_class'];
        $tag           = $atts['wrapper_tag'];

        $html = '';
        if ($atts['wrapper_enabled'] == 'true') {
            $html .= sprintf('<%s class="mo-optin-form-image-wrapper%s">', $tag, $wrapper_class);
        }

        $alt = $this->get_form_image_alt();

        $html .= sprintf('<img alt="%s" src="%s" class="mo-optin-form-image" style="%s"/>', esc_attr($alt), esc_url_raw($src), $style);

        if ($atts['wrapper_enabled'] == 'true') {
            $html .= "</$tag>";
        }

        return $html;
    }

Code file location:

mailoptin/mailoptin/src/core/src/OptinForms/AbstractOptinTheme.php

Mailoptin [mo-optin-form-background-image] Shortcode

The MailOptin plugin shortcode ‘mo-optin-form-background-image’ allows users to customize the background image of their opt-in form. It accepts parameters for ‘default’ and ‘style’. ‘Default’ sets the initial image while ‘style’ modifies the image’s look. It retrieves the image URL through ‘get_form_background_image_url’ function, then returns an image tag with the specified style and source.

Shortcode: [mo-optin-form-background-image]

Parameters

Here is a list of all possible mo-optin-form-background-image shortcode parameters and attributes:

  • default – Specifies the default background image when none is set.
  • style – Defines the CSS style for the background image.

Examples and Usage

Basic example – The shortcode below utilizes the MailOptin plugin to display a form’s background image. It uses the default image provided by the plugin.

[mo-optin-form-background-image default='default_image' /]

Advanced examples

Customizing the style of the background image by adding a CSS style attribute. This example changes the image’s display to block, aligns it to the center, and sets the maximum width to 100%.

[mo-optin-form-background-image default='default_image' style='display: block; margin-left: auto; margin-right: auto; max-width: 100%;' /]

Another advanced usage of the shortcode could be to specify a different default image. This example uses a custom image with the filename ‘custom_image.jpg’ as the default image.

[mo-optin-form-background-image default='custom_image.jpg' /]

Finally, combining both advanced examples, this shortcode specifies a custom default image and also customizes the style of the image.

[mo-optin-form-background-image default='custom_image.jpg' style='display: block; margin-left: auto; margin-right: auto; max-width: 100%;' /]

PHP Function Code

In case you have difficulties debugging what causing issues with [mo-optin-form-background-image] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('mo-optin-form-background-image', [$this, 'shortcode_optin_form_background_image']);

Shortcode PHP function:

function shortcode_optin_form_background_image($atts)
    {
        $atts = shortcode_atts(
            array(
                'default' => '',
                'style'   => '',
            ),
            $atts
        );

        $style = esc_attr($atts['style']);

        $src = $this->get_form_background_image_url($atts['default_image']);

        return sprintf('<img src="%s" class="mo-optin-form-background-image" style="%s"/>', esc_url($src), $style);
    }

Code file location:

mailoptin/mailoptin/src/core/src/OptinForms/AbstractOptinTheme.php

Mailoptin [mo-optin-form-description] Shortcode

The MailOptin shortcode is an essential tool that generates an opt-in form description. It applies filters before and after the description, allowing customization based on the campaign. The shortcode uses the ‘description’ value from the customizer and parses any embedded shortcodes within it. It also applies custom styles to the description. Shortcode: [shortcode_optin_form_description] The output is an HTML div element with a class and style attributes, which can be modified via shortcode attributes for further customization.

Shortcode: [mo-optin-form-description]

Parameters

Here is a list of all possible mo-optin-form-description shortcode parameters and attributes:

  • class – additional CSS classes for the description div element.
  • style – inline CSS styles for the description div element.

Examples and Usage

Basic example – The following shortcode displays the description of the optin form. This includes any customizer value and applies any filters set up in your WordPress theme.

[mo-optin-form-description /]

Advanced examples

In this example, we’re adding a custom class to the optin form description. This allows you to style the description separately from other elements on your page.

[mo-optin-form-description class="my-custom-class" /]

In this next example, we’re adding both a custom class and custom style to the optin form description. The style attribute allows you to add inline CSS to the description, providing even more control over its appearance.

[mo-optin-form-description class="my-custom-class" style="color: red; font-size: 20px;" /]

It’s important to note that the ‘class’ and ‘style’ attributes are optional. If you don’t specify them, the optin form description will use the default styles from your WordPress theme.

PHP Function Code

In case you have difficulties debugging what causing issues with [mo-optin-form-description] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('mo-optin-form-description', [$this, 'shortcode_optin_form_description']);

Shortcode PHP function:

function shortcode_optin_form_description($atts)
    {
        $description = apply_filters('mo_optin_form_before_description', '', $this->optin_campaign_id, $this->optin_campaign_type, $this->optin_campaign_uuid, $atts);
        $description .= $this->get_customizer_value('description');
        $description .= apply_filters('mo_optin_form_after_description', '', $this->optin_campaign_id, $this->optin_campaign_type, $this->optin_campaign_uuid, $atts);

        $description = $this->embed_shortcode_parser($description);

        $description_styles = $this->description_styles();

        $atts = shortcode_atts(
            array(
                'class' => '',
                'style' => '',
            ),
            $atts
        );

        $class = esc_attr($atts['class']);
        $class = "mo-optin-form-description $class";

        $style = esc_attr($atts['style']);
        $style = "$description_styles $style";

        $html = "<div class=\"$class\" style=\"$style\">$description</div>";

        return $html;
    }

Code file location:

mailoptin/mailoptin/src/core/src/OptinForms/AbstractOptinTheme.php

Mailoptin [mo-optin-form-error] Shortcode

The MailOptin plugin shortcode ‘mo-optin-form-error’ is used to display error messages on form submissions. It allows customization of the message, style, and class. This shortcode generates an error message when an invalid email is entered in the opt-in form. It also allows for customization of the error message’s CSS class and style.

Shortcode: [mo-optin-form-error]

Parameters

Here is a list of all possible mo-optin-form-error shortcode parameters and attributes:

  • class – Defines the CSS class to style the error message
  • style – Allows inline CSS for further customization
  • label – Sets the text of the error message

Examples and Usage

Basic example – A standard implementation of the shortcode with no additional attributes. This will display an error message with the default label ‘Invalid email address’.

[mo-optin-form-error /]

Advanced examples

Using the shortcode to customize the error message. This will display an error message with the label ‘Please enter a valid email address’.

[mo-optin-form-error label='Please enter a valid email address' /]

Using the shortcode to add a CSS class and style to the error message. This will display an error message with the CSS class ‘my-error-class’ and the CSS style ‘color: red; font-size: 16px;’

[mo-optin-form-error class='my-error-class' style='color: red; font-size: 16px;' /]

Using the shortcode to customize the error message, add a CSS class and style. This will display an error message with the label ‘Please enter a valid email address’, the CSS class ‘my-error-class’, and the CSS style ‘color: red; font-size: 16px;’

[mo-optin-form-error label='Please enter a valid email address' class='my-error-class' style='color: red; font-size: 16px;' /]

PHP Function Code

In case you have difficulties debugging what causing issues with [mo-optin-form-error] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('mo-optin-form-error', [$this, 'shortcode_optin_form_error']);

Shortcode PHP function:

function shortcode_optin_form_error($atts)
    {
        $atts = shortcode_atts(
            array(
                'class' => '',
                'style' => '',
                'label' => __('Invalid email address', 'mailoptin'),
            ),
            $atts
        );

        $class = esc_attr($atts['class']);
        $class = "mo-optin-error $class";

        $style = esc_attr($atts['style']);

        $label = $atts['label'];

        $html = "<div class=\"$class\" style='$style'>$label</div>";

        return $html;
    }

Code file location:

mailoptin/mailoptin/src/core/src/OptinForms/AbstractOptinTheme.php

Mailoptin [mo-optin-form-name-field] Shortcode

The MailOptin shortcode ‘mo-optin-form-name-field’ displays a name input field in the subscription form. It styles the field, sets placeholder text, and pre-fills the data if the user is logged in.

Shortcode: [mo-optin-form-name-field]

Parameters

Here is a list of all possible mo-optin-form-name-field shortcode parameters and attributes:

  • class – Adds additional CSS classes to the name field.
  • style – Applies inline CSS styles to the name field.

Examples and Usage

Basic example – In this example, we are using the shortcode to display a simple opt-in form with a name field. The form will use the default styles and placeholder text defined in the plugin settings.

[mo-optin-form-name-field /]

Advanced examples

Here, we are using the shortcode to display an opt-in form with a name field, but we’re adding a custom class and style to the name field. In this case, the class is ‘custom-class’ and the style is ‘color: red;’. The form will still use the default placeholder text defined in the plugin settings.

[mo-optin-form-name-field class="custom-class" style="color: red;" /]

In this next example, we are using the shortcode to display an opt-in form with a name field, but we’re adding a custom class, style, and placeholder text to the name field. The class is ‘custom-class’, the style is ‘color: red;’, and the placeholder text is ‘Enter your full name here’.

[mo-optin-form-name-field class="custom-class" style="color: red;" placeholder="Enter your full name here" /]

Remember, the ‘class’ and ‘style’ attributes allow you to add custom CSS classes and inline styles to the name field, while the ‘placeholder’ attribute allows you to customize the placeholder text of the name field.

PHP Function Code

In case you have difficulties debugging what causing issues with [mo-optin-form-name-field] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('mo-optin-form-name-field', [$this, 'shortcode_optin_form_name_field']);

Shortcode PHP function:

function shortcode_optin_form_name_field($atts)
    {
        $optin_css_id           = $this->optin_css_id;
        $name_field_styles      = $this->name_field_styles();
        $name_field_placeholder = $this->get_customizer_value('name_field_placeholder');

        $atts = shortcode_atts(
            array(
                'class' => '',
                'style' => '',
            ),
            $atts
        );

        $class = esc_attr($atts['class']);
        $class = "mo-optin-field mo-optin-form-name-field $class";

        $style = esc_attr($atts['style']);
        $style = "$name_field_styles $style";

        $value = '';
        if ($this->get_customizer_value('prefill_logged_user_data')) {
            $cache = wp_get_current_user();
            if ( ! empty($cache->first_name) || ! empty($cache->last_name)) {
                $value = $cache->first_name . ' ' . $cache->last_name;
            }
        }

        $input_attr = apply_filters('mo_optin_form_name_field_attributes', ['autocomplete' => 'on'], $this->optin_campaign_id, $this->optin_campaign_type, $this->optin_campaign_uuid, $atts);

        $attributes = [];
        foreach ($input_attr as $i => $v) {
            $attributes[] = "$i='$v'";
        }

        $attributeString = implode(' ', $attributes);

        $html = apply_filters('mo_optin_form_before_form_name_field', '', $this->optin_campaign_id, $this->optin_campaign_type, $this->optin_campaign_uuid, $atts);
        $html .= "<input id=\"{$optin_css_id}_name_field\" class=\"$class\" style='$style' type=\"text\" placeholder=\"$name_field_placeholder\" name=\"mo-name\" value=\"$value\" $attributeString>";
        $html .= apply_filters('mo_optin_form_after_form_name_field', '', $this->optin_campaign_id, $this->optin_campaign_type, $this->optin_campaign_uuid, $atts);

        return $html;
    }

Code file location:

mailoptin/mailoptin/src/core/src/OptinForms/AbstractOptinTheme.php

Mailoptin [mo-optin-form-email-field] Shortcode

The MailOptin shortcode ‘mo-optin-form-email-field’ is used to generate an email input field in opt-in forms. It includes customizable features such as CSS styling and prefilling logged user data. This shortcode allows for the customization of class and style attributes. It also has the capability to prefill the email field with the logged-in user’s email. The shortcode ensures a seamless user experience by enabling autocomplete.

Shortcode: [mo-optin-form-email-field]

Parameters

Here is a list of all possible mo-optin-form-email-field shortcode parameters and attributes:

  • class – Adds additional CSS classes to the email input field.
  • style – Applies custom CSS styles directly to the email input field.

Examples and Usage

Basic example – The following shortcode will display a basic email opt-in form with the default styles and settings.

[mo-optin-form-email-field /]

Advanced examples

Below are some advanced examples of how you can use the shortcode with various parameters to customize the form.

1. Displaying the email opt-in form with a custom CSS class and style:

[mo-optin-form-email-field class="custom-class" style="color: red;"]

This will apply the “custom-class” CSS class and a red text color to the email field.

2. Prefilling the email field for logged in users:

[mo-optin-form-email-field prefill_logged_user_data="true"]

This will prefill the email field with the email of the currently logged in user, if there is one.

3. Changing the placeholder text of the email field:

[mo-optin-form-email-field email_field_placeholder="Enter your email here"]

This will change the placeholder text of the email field to “Enter your email here”.

Remember, you can combine multiple parameters in a single shortcode to customize the email opt-in form to your liking.

PHP Function Code

In case you have difficulties debugging what causing issues with [mo-optin-form-email-field] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('mo-optin-form-email-field', [$this, 'shortcode_optin_form_email_field']);

Shortcode PHP function:

function shortcode_optin_form_email_field($atts)
    {
        $optin_css_id            = $this->optin_css_id;
        $email_field_styles      = $this->email_field_styles();
        $email_field_placeholder = $this->get_customizer_value('email_field_placeholder');

        $atts = shortcode_atts(
            array(
                'class' => '',
                'style' => '',
            ),
            $atts
        );

        $class = esc_attr($atts['class']);
        $class = "mo-optin-field mo-optin-form-email-field $class";

        $style = esc_attr($atts['style']);
        $style = "$email_field_styles $style";

        $value = '';
        if ($this->get_customizer_value('prefill_logged_user_data')) {
            $email = wp_get_current_user()->user_email;
            if ( ! empty($email)) {
                $value = wp_get_current_user()->user_email;
            }
        }

        $input_attr = apply_filters('mo_optin_form_email_field_attributes', ['autocomplete' => 'on'], $this->optin_campaign_id, $this->optin_campaign_type, $this->optin_campaign_uuid, $atts);

        $attributes = [];
        foreach ($input_attr as $i => $v) {
            $attributes[] = "$i='$v'";
        }

        $attributeString = implode(' ', $attributes);

        $html = apply_filters('mo_optin_form_before_form_name_field', '', $this->optin_campaign_id, $this->optin_campaign_type, $this->optin_campaign_uuid, $atts);
        $html .= "<input id=\"{$optin_css_id}_email_field\" class=\"$class\" style=\"$style\" type=\"email\" placeholder=\"$email_field_placeholder\" name=\"mo-email\" value=\"$value\" $attributeString>";
        $html .= apply_filters('mo_optin_form_after_form_email_field', '', $this->optin_campaign_id, $this->optin_campaign_type, $this->optin_campaign_uuid, $atts);

        return $html;
    }

Code file location:

mailoptin/mailoptin/src/core/src/OptinForms/AbstractOptinTheme.php

Mailoptin [mo-optin-form-custom-fields] Shortcode

The MailOptin plugin shortcode is a function that generates custom fields for opt-in forms. It allows the addition of various field types like text, date, password, textarea, checkbox, radio, select and country. It also provides options for hidden fields and list subscriptions. The shortcode ensures the fields are properly styled, have the correct attributes, and are displayed according to the user’s preferences.

Shortcode: [mo-optin-form-custom-fields]

Parameters

Here is a list of all possible mo-optin-form-custom-fields shortcode parameters and attributes:

  • class – assigns a custom CSS class to the form field
  • style – adds inline CSS styles to the form field
  • tag_start – specifies the HTML tag to start wrapping the form field
  • tag_end – specifies the HTML tag to end wrapping the form field

Examples and Usage

Basic example – Displaying a custom opt-in form with default styling.

[mo-optin-form-custom-fields /]

Advanced examples

Displaying a custom opt-in form with a specific CSS class for advanced styling.

[mo-optin-form-custom-fields class="my-custom-class" /]

Displaying a custom opt-in form with inline CSS style for quick customization.

[mo-optin-form-custom-fields style="background-color: #f0f0f0; padding: 20px;" /]

Using the shortcode to display a custom opt-in form with specific HTML tags wrapping the form fields. This can be used to further customize the form’s layout.

[mo-optin-form-custom-fields tag_start="
" tag_end="
" /]

Combining multiple attributes to fully customize the display of the opt-in form.

[mo-optin-form-custom-fields class="my-custom-class" style="background-color: #f0f0f0; padding: 20px;" tag_start="
" tag_end="
" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [mo-optin-form-custom-fields] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('mo-optin-form-custom-fields', [$this, 'shortcode_optin_form_custom_fields']);

Shortcode PHP function:

function shortcode_optin_form_custom_fields($atts)
    {
        if ( ! defined('MAILOPTIN_DETACH_LIBSODIUM')) return;

        $atts = shortcode_atts(
            array(
                'class'     => '',
                'style'     => '',
                'tag_start' => '',
                'tag_end'   => ''
            ),
            $atts
        );

        $saved_values = $this->get_customizer_value('fields');

        $html = '';

        if ( ! empty($saved_values) && is_string($saved_values)) {
            $result = json_decode($saved_values, true);
            if (is_array($result)) {
                $saved_values = $result;

                foreach ($saved_values as $index => $field) {
                    $optin_css_id = $this->optin_css_id;
                    $field_type   = empty($field['field_type']) ? 'text' : esc_html($field['field_type']);
                    $field_styles = $this->custom_field_styles($field);

                    $field_id    = esc_html($field['cid']);
                    $placeholder = isset($field['placeholder']) ? esc_html($field['placeholder']) : '';

                    $style = esc_attr($atts['style']);
                    $style = "$field_styles $style";

                    $id = "{$optin_css_id}_{$field_type}_{$field_id}";

                    $options = [];
                    if ( ! empty($field['field_options'])) {
                        $options = array_map('trim', explode(',', $field['field_options']));
                        $options = array_filter($options, function ($field) {
                            return ! empty($field);
                        });
                    }

                    $class = ' ' . esc_attr($atts['class']);
                    $class = "mo-optin-field mo-optin-form-custom-field {$field_type}-field field-{$field_id}{$class}";

                    $data_attr = sprintf('data-field-id="%s"', $field_id);

                    $html .= apply_filters('mo_optin_form_custom_field_output', '', $field_type, $field, $atts);

                    $input_attr = apply_filters('mo_optin_form_custom_field_attributes', [], $field_type, $this->optin_campaign_id, $this->optin_campaign_type, $this->optin_campaign_uuid, $atts);

                    $attributes = [];
                    foreach ($input_attr as $i => $v) {
                        $attributes[] = "$i='$v'";
                    }

                    $attributeString = implode(' ', $attributes);

                    switch ($field_type) {
                        case 'text':
                        case 'date':
                            $html .= $atts['tag_start'];
                            $html .= "<input $data_attr id=\"$id\" class=\"$class\" style=\"$style\" type=\"text\" placeholder=\"$placeholder\" name=\"$field_id\" $attributeString>";
                            $html .= $atts['tag_end'];
                            break;
                        case 'hidden':
                            $value = moVar($field, 'hidden_value', '', true);
                            $html  .= $atts['tag_start'];
                            $html  .= "<input $data_attr id=\"$id\" class=\"$class\" style=\"display:none\" type=\"hidden\" value=\"$value\" name=\"$field_id\" $attributeString>";
                            $html  .= $atts['tag_end'];
                            break;
                        case 'password':
                            $html .= $atts['tag_start'];
                            $html .= "<input $data_attr id=\"$id\" class=\"$class\" style=\"$style\" type=\"password\" placeholder=\"$placeholder\" name=\"$field_id\" $attributeString>";
                            $html .= $atts['tag_end'];
                            break;
                        case 'textarea':
                            $html .= $atts['tag_start'];
                            $html .= "<textarea $data_attr id=\"$id\" class=\"$class\" style=\"$style\" placeholder=\"$placeholder\" name=\"$field_id\" $attributeString></textarea>";
                            $html .= $atts['tag_end'];
                            break;
                        case 'checkbox':
                            $html .= $atts['tag_start'];
                            $html .= "<div $data_attr class=\"$class\" style=\"$style\" id=\"$id\">";
                            if (count($options) < 2) {
                                $value = empty($options) ? 'true' : esc_attr(trim($options[0]));
                                $html  .= "<input type=\"hidden\" value=\"false\" name=\"{$field_id}\"><label><input type=\"checkbox\" value=\"$value\" name=\"{$field_id}\" $attributeString><span>$placeholder</span></label>";
                            } else {
                                $html .= "<div class='mo-checkbox-title'>$placeholder</div>";
                                foreach ($options as $option) {
                                    $option_value = esc_attr($option);
                                    $option_label = esc_html($option);

                                    if (false !== strpos($option, '|')) {
                                        list($label, $value) = explode('|', $option);
                                        $option_value = esc_attr($value);
                                        $option_label = esc_html($label);
                                    }
                                    $html .= "<label><input type=\"checkbox\" value=\"$option_value\" name=\"{$field_id}[]\" $attributeString><span>$option_label</span></label>";
                                }
                            }
                            $html .= '</div>';
                            $html .= $atts['tag_end'];
                            break;
                        case 'radio':
                            $html .= $atts['tag_start'];
                            $html .= "<div $data_attr class=\"$class\" id=\"$id\" style=\"$style\"><div class='mo-radio-title'>$placeholder</div>";

                            //Display options
                            foreach ($options as $option) {
                                $option_value = esc_attr($option);
                                $option_label = esc_html($option);

                                if (false !== strpos($option, '|')) {
                                    list($label, $value) = explode('|', $option);
                                    $option_value = esc_attr($value);
                                    $option_label = esc_html($label);
                                }
                                if (empty ($option_label)) {
                                    continue;
                                }
                                $html .= "<label><input type=\"radio\" value=\"$option_value\" name=\"$field_id\" $attributeString><span>$option_label</span></label>";
                            }
                            $html .= "</div>" . $atts['tag_end'];
                            break;
                        case 'select':
                            $placeholder = ! empty($placeholder) ? $placeholder : esc_html__('Select...', 'mailoptin');
                            $html        .= $atts['tag_start'];
                            $html        .= "<select name=\"$field_id\" $data_attr class=\"$class\" id=\"$id\" style=\"$style\" $attributeString>";
                            $html        .= "<option value='' selected='selected'>$placeholder</option>";
                            //Display options
                            foreach ($options as $option) {
                                $option_value = esc_attr($option);
                                $option_label = esc_html($option);

                                if (false !== strpos($option, '|')) {
                                    list($label, $value) = explode('|', $option);
                                    $option_value = esc_attr($value);
                                    $option_label = esc_html($label);
                                }
                                if (empty ($option_label)) {
                                    continue;
                                }
                                $html .= "<option value=\"$option_value\" >$option_label</option>";
                            }
                            $html .= "</select>" . $atts['tag_end'];
                            break;
                        case 'country':

                            $display_type = moVar($field, 'country_field_options', 'alpha-2', true);

                            $html .= $atts['tag_start'];

                            switch ($display_type) {
                                case 'alpha-2':
                                    $countries_lists = \MailOptin\Core\countries_array();
                                    if (is_array($countries_lists) && ! empty($countries_lists)) {
                                        $placeholder = ! empty($placeholder) ? $placeholder : esc_html__('Select...', 'mailoptin');
                                        $html        .= "<select name=\"$field_id\" $data_attr class=\"$class\" id=\"$id\" style=\"$style\" $attributeString>";
                                        $html        .= "<option value='' selected='selected'>$placeholder</option>";

                                        foreach ($countries_lists as $key => $countries_list) {
                                            $html .= sprintf('<option value="%1$s">%2$s</option>', $key, $countries_list);
                                        }
                                        $html .= '</select>';
                                    }
                                    break;
                                case 'alpha-3':
                                    $countries_lists = \MailOptin\Core\countries_array('alpha-3');
                                    if (is_array($countries_lists) && ! empty($countries_lists)) {
                                        $placeholder = ! empty($placeholder) ? $placeholder : esc_html__('Select...', 'mailoptin');
                                        $html        .= "<select name=\"$field_id\" $data_attr class=\"$class\" id=\"$id\" style=\"$style\" $attributeString>";
                                        $html        .= "<option value='' selected='selected'>$placeholder</option>";

                                        foreach ($countries_lists as $key => $countries_list) {
                                            $html .= sprintf('<option value="%1$s">%2$s</option>', $key, $countries_list);
                                        }
                                        $html .= '</select>';
                                    }
                                    break;
                            }
                            $html .= $atts['tag_end'];
                            break;
                        case 'list_subscription':
                            $display_type = moVar($field, 'list_subscription_display_type', 'checkbox', true);
                            $integration  = moVar($field, 'list_subscription_integration');

                            $name_attribute = 'mo-list-subscription';

                            $integration_email_list = ConnectionsRepository::connection_email_list($integration);

                            if (empty($integration) || empty($integration_email_list)) return '';

                            $options         = moVar($field, 'list_subscription_lists', [], true);
                            $alignment_style = sprintf("text-align: %s;", moVar($field, 'list_subscription_alignment', 'left', true));
                            $style           .= $alignment_style;

                            $html .= $atts['tag_start'];
                            $html .= sprintf('<input type="hidden" name="mo-list-subscription-integration" value="%s">', $integration);
                            switch ($display_type) {
                                case 'checkbox':
                                    if (is_array($options) && ! empty($options)) {
                                        $html .= sprintf('<div %s class="%s" style="%s" id="%s">', $data_attr, $class, $style, $id);
                                        $html .= "<div class='mo-checkbox-title' style='$alignment_style'>$placeholder</div>";

                                        foreach ($options as $option) {
                                            $html .= sprintf('<label class="mo-list-subscription-checkbox" style="%s">', $alignment_style);
                                            $html .= sprintf('<input style="%s" type="checkbox" name="%s[]" value="%s"> %s', $style, $name_attribute, $option, $integration_email_list[$option]);
                                            $html .= '</label>';
                                        }
                                        $html .= '</div>';
                                    }
                                    break;
                                case 'radio':
                                    if (is_array($options) && ! empty($options)) {
                                        $html .= sprintf('<div %s class="%s" style="%s" id="%s">', $data_attr, $class, $style, $id);
                                        $html .= "<div class='mo-radio-title' style='$alignment_style'>$placeholder</div>";
                                        foreach ($options as $option) {
                                            $html .= sprintf('<label class="mo-list-subscription-checkbox" style="%s">', $alignment_style);
                                            $html .= sprintf('<input style="%s" type="radio" name="%s" value="%s"> %s', $style, $name_attribute, $option, $integration_email_list[$option]);
                                            $html .= '</label>';
                                        }
                                        $html .= '</div>';
                                    }
                                    break;
                                case 'select':
                                    if (is_array($options) && ! empty($options)) {
                                        $placeholder = ! empty($placeholder) ? $placeholder : esc_html__('Select...', 'mailoptin');
                                        $html        .= "<select name=\"$name_attribute\" $data_attr class=\"$class\" id=\"$id\" style=\"$style\">";
                                        $html        .= "<option value='' selected='selected'>$placeholder</option>";
                                        foreach ($options as $option) {
                                            $html .= sprintf('<option value="%s">%s</option>', $option, $integration_email_list[$option]);
                                        }
                                        $html .= '</select>';
                                    }
                                    break;
                            }

                            $html .= $atts['tag_end'];
                            break;
                    }
                }
            }
        }

        return $html;
    }

Code file location:

mailoptin/mailoptin/src/core/src/OptinForms/AbstractOptinTheme.php

Mailoptin [mo-optin-form-submit-button] Shortcode

The MailOptin shortcode is a tool that enables the addition of a submit button to opt-in forms. The function ‘shortcode_optin_form_submit_button’ generates the HTML for the button. It applies styles and classes specified in the shortcode attributes, and uses filters to allow for customization before and after the button.

Shortcode: [mo-optin-form-submit-button]

Parameters

Here is a list of all possible mo-optin-form-submit-button shortcode parameters and attributes:

  • class – Additional CSS classes to style the submit button
  • style – Inline CSS styles to directly modify the submit button

Examples and Usage

Basic example – A MailOptin form submit button with default settings can be added to a page or post using the following shortcode:

[mo-optin-form-submit-button /]

Advanced examples

Customize the submit button’s appearance by adding ‘class’ and ‘style’ parameters to the shortcode. Here’s an example of a shortcode that adds a custom CSS class and inline style to the submit button:

[mo-optin-form-submit-button class="my-custom-class" style="background-color:blue;color:white;"]

Use the ‘mo_optin_form_before_form_submit_button’ and ‘mo_optin_form_after_form_submit_button’ filters to add custom HTML before and after the submit button. This can be useful for adding additional information or styling elements. Here’s an example of how you might use these filters:


function add_html_before_submit_button($html, $optin_campaign_id, $optin_campaign_type, $optin_campaign_uuid, $atts) {
    return $html . '
Some custom HTML here
'; } add_filter('mo_optin_form_before_form_submit_button', 'add_html_before_submit_button', 10, 5); function add_html_after_submit_button($html, $optin_campaign_id, $optin_campaign_type, $optin_campaign_uuid, $atts) { return $html . '
Some custom HTML here
'; } add_filter('mo_optin_form_after_form_submit_button', 'add_html_after_submit_button', 10, 5);

Please note that these are just examples and you should replace ‘Some custom HTML here’ with your own HTML content.

PHP Function Code

In case you have difficulties debugging what causing issues with [mo-optin-form-submit-button] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('mo-optin-form-submit-button', [$this, 'shortcode_optin_form_submit_button']);

Shortcode PHP function:

function shortcode_optin_form_submit_button($atts)
    {
        $optin_css_id         = $this->optin_css_id;
        $submit_button_styles = $this->submit_button_styles();
        $submit_button        = $this->get_customizer_value('submit_button');

        $atts = shortcode_atts(
            array(
                'class' => '',
                'style' => '',
            ),
            $atts
        );

        $class = esc_attr($atts['class']);
        $class = "mo-optin-form-submit-button $class";

        $style = esc_attr($atts['style']);
        $style = "$submit_button_styles $style";

        $html = apply_filters('mo_optin_form_before_form_submit_button', '', $this->optin_campaign_id, $this->optin_campaign_type, $this->optin_campaign_uuid, $atts);
        $html .= "<input id=\"{$optin_css_id}_submit_button\" class=\"$class\" style=\"$style\" type=\"submit\" value=\"$submit_button\">";
        $html .= apply_filters('mo_optin_form_after_form_submit_button', '', $this->optin_campaign_id, $this->optin_campaign_type, $this->optin_campaign_uuid, $atts);

        return $html;
    }

Code file location:

mailoptin/mailoptin/src/core/src/OptinForms/AbstractOptinTheme.php

Mailoptin [mo-optin-form-cta-button] Shortcode

The MailOptin plugin shortcode ‘mo-optin-form-cta-button’ is designed to create a customizable call-to-action button for opt-in forms. It applies filters before and after the CTA button, allowing for additional customization. The button’s style and class attributes can be modified via the shortcode’s parameters. The button’s text is retrieved from the plugin’s customizer settings.

Shortcode: [mo-optin-form-cta-button]

Parameters

Here is a list of all possible mo-optin-form-cta-button shortcode parameters and attributes:

  • class – sets additional CSS classes for the button.
  • style – applies custom inline CSS styles to the button.

Examples and Usage

Basic example – An instance of the shortcode without any additional attributes, simply calling the ‘mo-optin-form-cta-button’ shortcode.

[mo-optin-form-cta-button /]

Advanced examples

Adding a custom class to the CTA button. In this case, we’re adding the class ‘my-custom-button’ to style the button separately in our CSS.

[mo-optin-form-cta-button class="my-custom-button" /]

Adding a custom style directly to the CTA button. Here, we’re changing the button’s color to red and setting the font-size to 18px.

[mo-optin-form-cta-button style="color:red; font-size:18px;" /]

Using both ‘class’ and ‘style’ attributes together. This allows us to add a class and also directly apply some styles to the CTA button.

[mo-optin-form-cta-button class="my-custom-button" style="color:red; font-size:18px;" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [mo-optin-form-cta-button] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('mo-optin-form-cta-button', [$this, 'shortcode_optin_form_cta_button']);

Shortcode PHP function:

function shortcode_optin_form_cta_button($atts)
    {
        $optin_css_id      = $this->optin_css_id;
        $cta_button_styles = $this->cta_button_styles();
        $cta_button        = $this->get_customizer_value('cta_button');

        $atts = shortcode_atts(
            array(
                'class' => '',
                'style' => ''
            ),
            $atts
        );

        $class = esc_attr($atts['class']);
        $class = "mo-optin-form-cta-button $class";

        $style = esc_attr($atts['style']);
        $style = "$cta_button_styles $style";

        $html = apply_filters('mo_optin_form_before_cta_button', '', $this->optin_campaign_id, $this->optin_campaign_type, $this->optin_campaign_uuid, $atts);
        $html .= "<input id=\"{$optin_css_id}_cta_button\" class=\"$class\" style=\"$style\" type=\"submit\" value=\"$cta_button\">";
        $html .= apply_filters('mo_optin_form_after_cta_button', '', $this->optin_campaign_id, $this->optin_campaign_type, $this->optin_campaign_uuid, $atts);

        return $html;
    }

Code file location:

mailoptin/mailoptin/src/core/src/OptinForms/AbstractOptinTheme.php

Mailoptin [mo-optin-form-note] Shortcode

The MailOptin plugin shortcode ‘mo-optin-form-note’ is used to customize the note section of an opt-in form. It allows adding custom text, styles, and an optional acceptance checkbox. This shortcode manages the display of notes in the opt-in form, with the ability to add a class and style. It also includes the functionality to close the opt-in form on click.

Shortcode: [mo-optin-form-note]

Parameters

Here is a list of all possible mo-optin-form-note shortcode parameters and attributes:

  • class – Adds an extra CSS class to the opt-in form’s HTML.
  • style – Directly applies CSS styles to the opt-in form.

Examples and Usage

Basic example – Displaying a simple opt-in form note without any additional classes or styles

[mo-optin-form-note /]

Advanced examples

Adding a custom CSS class to the opt-in form note. This allows you to style the note differently from other notes on your site.

[mo-optin-form-note class="my-custom-class" /]

Applying inline CSS to the opt-in form note. This can be useful if you want to make a one-off style change that doesn’t warrant creating a whole new CSS class.

[mo-optin-form-note style="color: red; font-size: 20px;" /]

Combining both class and style attributes. This allows for the greatest flexibility in styling your opt-in form note.

[mo-optin-form-note class="my-custom-class" style="color: red; font-size: 20px;" /]

Using the shortcode to close the opt-in form when the note is clicked. This can be useful if you want to give users an easy way to dismiss the opt-in form.

[mo-optin-form-note class="mo-close-optin" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [mo-optin-form-note] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('mo-optin-form-note', [$this, 'shortcode_optin_form_note']);

Shortcode PHP function:

function shortcode_optin_form_note($atts)
    {
        $note                          = apply_filters('mo_optin_form_before_note', '', $this->optin_campaign_id, $this->optin_campaign_type, $this->optin_campaign_uuid, $atts);
        $is_acceptance_checkbox_active = $this->get_customizer_value('note_acceptance_checkbox');

        $note .= '<span class="mo-note-content">' . $this->get_customizer_value('note') . '</span>';

        if ($is_acceptance_checkbox_active) {
            $note .= '</label>';
        }

        $note .= apply_filters('mo_optin_form_after_note', '', $this->optin_campaign_id, $this->optin_campaign_type, $this->optin_campaign_uuid, $atts);

        $note = do_shortcode($note);

        $note_styles = $this->note_styles();

        $atts = shortcode_atts(
            array(
                'class' => '',
                'style' => '',
            ),
            $atts
        );

        $class = esc_attr($atts['class']);

        if ($this->get_customizer_value('note_close_optin_onclick')) {
            $class .= ' mo-close-optin';
        }

        $class = "mo-optin-form-note $class";

        $style = $note_styles . esc_attr($atts['style']);

        $html = '';

        if ($is_acceptance_checkbox_active) {
            $html .= '<label class="mo-acceptance-label">';
            $html .= '<input name="mo-acceptance" class="mo-acceptance-checkbox" type="checkbox" value="yes">';
        }

        $html .= str_replace(
            ['<p', '</p', '<div', '</div'],
            ['<span', '</span', '<span', '</span'],
            $note
        );

        if ($is_acceptance_checkbox_active) {
            $html .= '</label>';
        }

        return "<div class=\"$class\" style=\"$style\">$html</div>";
    }

Code file location:

mailoptin/mailoptin/src/core/src/OptinForms/AbstractOptinTheme.php

Mailoptin [mo-optin-form] Shortcode

The MailOptin shortcode ‘mo-optin-form’ is designed to display an opt-in form on your WordPress site. It takes an ‘id’ attribute which represents the opt-in campaign ID. This shortcode fetches the opt-in form associated with the given ID and displays it on the site. If the ID is not provided or is invalid, it will return nothing.

Shortcode: [mo-optin-form]

Parameters

Here is a list of all possible mo-optin-form shortcode parameters and attributes:

  • id – Unique identifier for the opt-in form.

Examples and Usage

Basic example – Optin form display using its unique ID

[mo-optin-form id=1 /]

Advanced examples

Displaying an optin form using its unique ID, but if the ID is not found, the shortcode will try to load the form using its unique UUID.

[mo-optin-form id="unique-uuid" /]

Another advanced usage of the shortcode can be to display multiple optin forms on the same page. You can do this by using the shortcode multiple times with different IDs.

[mo-optin-form id=1 /]
[mo-optin-form id=2 /]
[mo-optin-form id=3 /]

PHP Function Code

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

Shortcode line:

add_shortcode('mo-optin-form', [$this, 'optin_shortcode']);

Shortcode PHP function:

function optin_shortcode($atts)
    {
        if ( ! isset($atts['id']) || empty($atts['id'])) return;

        $optin_campaign_id = is_numeric($atts['id']) ? $atts['id'] : OCR::get_optin_campaign_id_by_uuid(sanitize_text_field($atts['id']));

        return $this->get_optin($optin_campaign_id);
    }

Code file location:

mailoptin/mailoptin/src/core/src/OptinForms/Shortcodes.php

Mailoptin [mo-click-launch] Shortcode

The MailOptin shortcode ‘mo-click-launch’ triggers an opt-in form when a link is clicked. It allows customization of the link text and CSS class. The shortcode checks if the opt-in form exists, then generates an HTML anchor tag with the opt-in form ID and link text. If the form type is ‘inpost’ or ‘sidebar’, it returns a message stating that click triggers are unsupported for these types.

Shortcode: [mo-click-launch]

Parameters

Here is a list of all possible mo-click-launch shortcode parameters and attributes:

  • id – Unique identifier for the optin campaign
  • class – Additional CSS class to style the link
  • link – Default text for the link if no content is provided

Examples and Usage

Basic example – A shortcode that triggers an opt-in form when a link is clicked. The ‘id’ attribute is required to specify the opt-in form to be displayed.

[mo-click-launch id="optin-form-1" /]

Advanced examples

Adding a custom class to the link. This can be helpful for styling the link with CSS. The ‘class’ attribute is optional.

[mo-click-launch id="optin-form-1" class="custom-class" /]

Changing the default link text. The ‘link’ attribute is optional and defaults to ‘click here’ if not specified.

[mo-click-launch id="optin-form-1" link="Sign up now!" /]

Using all attributes together. This example includes a custom class for the link and custom link text.

[mo-click-launch id="optin-form-1" class="custom-class" link="Join our newsletter!" /]

Note: The ‘id’ attribute can also accept a UUID instead of a numeric ID. The UUID is a unique identifier for the opt-in form, which can be useful if you have multiple forms with the same name or if you want to avoid potential conflicts with other plugins that use numeric IDs.

PHP Function Code

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

Shortcode line:

add_shortcode('mo-click-launch', [$this, 'optin_click_launch']);

Shortcode PHP function:

function optin_click_launch($atts, $content = null)
    {
        if ( ! defined('MAILOPTIN_DETACH_LIBSODIUM')) return;

        $atts = shortcode_atts(
            [
                'id'    => '',
                'class' => '',
                'link'  => __('click here', 'mailoptin'),
            ],
            $atts
        );

        $id    = esc_attr($atts['id']);
        $class = esc_attr($atts['class']);
        if ( ! empty($class)) {
            $class = " $class";
        }

        $link = esc_html($atts['link']);

        if (empty($id)) return;

        $optin_campaign_uuid = is_numeric($id) ? OCR::get_optin_campaign_uuid($id) : $id;
        $optin_campaign_id   = OCR::get_optin_campaign_id_by_uuid($optin_campaign_uuid);

        $optin_type = OCR::get_optin_campaign_type($optin_campaign_id);

        if (in_array($optin_type, ['inpost', 'sidebar'])) {
            return sprintf(__('Click trigger does not support %s optin.', 'mailoptin'), $optin_type);
        }

        $anchor_text = ! empty($content) ? $content : $link;

        return sprintf(
            '<a href="#" class="mailoptin-click-trigger%s" data-optin-uuid="%s">%s</a>',
            $class,
            $optin_campaign_uuid,
            $anchor_text
        );
    }

Code file location:

mailoptin/mailoptin/src/core/src/OptinForms/Shortcodes.php

Conclusion

Now that you’ve learned how to embed the Mailoptin 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 *