Survey Maker Shortcodes

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

Before starting, here is an overview of the Survey Maker – Best WordPress Survey Plugin and the shortcodes it provides:

Plugin Icon
Survey Maker – Best WordPress Survey Plugin

"Survey Maker is a superior WordPress plugin designed to create and manage engaging surveys. Ideal for gathering in-depth insights and feedback effortlessly."

★★★★☆ (44) Active Installs: 4000+ Tested with: 6.3.2 PHP Version: false
Included Shortcodes:
  • [ays_survey]
  • [ays_survey_popup]
  • [ays_survey_most_popular]
  • [ays_survey_submissions_summary]
  • [ays_survey_links_by_category]

Survey Maker [ays_survey] Shortcode

The Survey Maker shortcode is used to generate a survey on a page. It’s implemented via the ‘ays_survey’ shortcode. The shortcode function ‘ays_generate_survey_method’ takes an ID as an attribute. If the ID is not set, it returns a warning message. If the ID is valid, it enqueues necessary styles and scripts, then displays the survey associated with the given ID. It also removes any line breaks from the content.

Shortcode: [ays_survey]

Parameters

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

  • id – A unique number that specifies the survey to be displayed.

Examples and Usage

Basic example – The shortcode below is used to generate a survey with the ID of 1. The ID is the only parameter required to generate a survey.

[ays_survey id=1 /]

Advanced examples

1. This shortcode is an example of a survey with an ID of 2, and it also includes additional attributes. These attributes may be used to customize the survey’s appearance and functionality.

[ays_survey id=2 attr1='value1' attr2='value2' /]

2. This shortcode is used to generate a survey with an ID of 3, and it includes multiple additional attributes. These attributes can be used to further customize the survey’s appearance and functionality.

[ays_survey id=3 attr1='value1' attr2='value2' attr3='value3' /]

Note: In these examples, ‘attr1’, ‘attr2’, and ‘attr3’ are placeholder attribute names, and ‘value1’, ‘value2’, and ‘value3’ are placeholder values. You would replace these with the actual attribute names and values you wish to use.

PHP Function Code

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

Shortcode line:

add_shortcode('ays_survey', array($this, 'ays_generate_survey_method'));

Shortcode PHP function:

function ays_generate_survey_method( $attr ){
        $id = (isset($attr['id'])) ? absint(intval($attr['id'])) : null;
        
        if (is_null($id)) {
            $content = "<p class='wrong_shortcode_text' style='color:red;'>" . __( 'Wrong shortcode initialized', "survey-maker" ) . "</p>";
            return $content;
        }
        
        $this->enqueue_styles();
        $this->enqueue_scripts();

        $content = $this->show_survey($id, $attr);
        return str_replace( array( "\r\n", "\n", "\r" ), '', $content );
    }

Code file location:

survey-maker/survey-maker/public/class-survey-maker-public.php

Survey Maker [ays_survey_popup] Shortcode

The ‘ays_survey_popup’ shortcode from the AYS Survey Maker plugin generates a popup survey on your website. It enqueues necessary scripts and replaces line breaks for smooth display.

Shortcode: [ays_survey_popup]

Parameters

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

  • id – Unique identifier for the specific survey
  • attr – Additional attributes for the survey popup

Examples and Usage

Basic example – The shortcode is used to generate a survey popup by referencing the survey’s ID.

[ays_survey_popup id=1 /]

Advanced examples

Generating a survey popup by referencing the survey’s ID and including additional attributes. The additional attributes can be used to customize the display of the survey popup.

[ays_survey_popup id=1 attr1='value1' attr2='value2' /]

Using the shortcode to generate a survey popup without specifying the survey’s ID. In this case, the function will return an empty string.

[ays_survey_popup /]

Using the shortcode to generate a survey popup by referencing an invalid survey’s ID. In this case, the function will also return an empty string.

[ays_survey_popup id='invalid' /]

PHP Function Code

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

Shortcode line:

add_shortcode('ays_survey_popup', array($this, 'ays_generate_survey_popup_method'));

Shortcode PHP function:

function ays_generate_survey_popup_method( $attr ){

        $id = (isset($attr['id'])) ? absint(intval($attr['id'])) : null;
        if (is_null($id)) {
            return '';
        }
        
        $this->enqueue_scripts_popups();

        $content = $this->ays_popup_shortcode_content($id, $attr);
        return $content ? str_replace( array( "\r\n", "\n", "\r" ), "\n", $content ) : '';  
    }

Code file location:

survey-maker/survey-maker/public/class-survey-maker-public.php

Survey Maker [ays_survey_most_popular] Shortcode

The ‘ays_survey_most_popular’ shortcode from the AYS Survey plugin generates the most popular surveys. This code creates a unique ID, then generates HTML for the most popular surveys. It also replaces all types of line breaks with a newline character, ensuring consistent formatting.

Shortcode: [ays_survey_most_popular]

Examples and Usage

Basic example – Generate the most popular survey using its default settings.

[ays_survey_most_popular]

Advanced examples

Generate the most popular survey with specific attributes. Here, ‘id’ refers to the unique identifier of the survey, ‘title’ refers to the title of the survey, and ‘description’ refers to a brief description of the survey.

[ays_survey_most_popular id="1" title="Customer Satisfaction Survey" description="This is a survey to measure customer satisfaction."]

Generate the most popular survey with additional parameters. The ‘limit’ parameter limits the number of surveys displayed, while the ‘category’ parameter allows you to specify the category of the survey.

[ays_survey_most_popular limit="5" category="Customer Feedback"]

Generate the most popular survey with a custom style. The ‘style’ parameter allows you to apply custom CSS to the survey.

[ays_survey_most_popular style="background-color: #f9f9f9; color: #333;"]

Please note that the actual parameters and their usage will depend on the specific implementation of the ‘ays_generate_most_popular_method’ function.

PHP Function Code

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

Shortcode line:

add_shortcode('ays_survey_most_popular', array($this, 'ays_generate_most_popular_method'));

Shortcode PHP function:

function ays_generate_most_popular_method( $attr ){

        $unique_id = uniqid();
        $this->unique_id = $unique_id;
        $this->unique_id_in_class = "-" . $unique_id;

        $survey_most_popular_html = $this->ays_survey_most_popular_html( $attr );
        return str_replace(array("\r\n", "\n", "\r"), "\n", $survey_most_popular_html);
    }

Code file location:

survey-maker/survey-maker/public/partials/class-survey-maker-most-popular-shortcode.php

Survey Maker [ays_survey_submissions_summary] Shortcode

The Survey Maker shortcode is designed to generate a summary of survey submissions. It validates and retrieves data from a specific survey using its ID. If the ID is incorrect or missing, it displays an error message. It also assigns a unique ID to each survey instance, ensuring data integrity. This shortcode also enqueues necessary styles and scripts for proper functionality.

Shortcode: [ays_survey_submissions_summary]

Parameters

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

  • id – Unique identifier of the survey to display submissions summary

Examples and Usage

Basic example – A simple usage of the shortcode to display a survey submission summary by referencing the ID.

[ays_survey_submissions_summary id=1 /]

Advanced examples

Using the shortcode to display a survey submission summary by referencing both ID and other parameters. The survey will first try to load by ID, but if not found, it will try to load by other parameters.

[ays_survey_submissions_summary id=1 param1='value1' param2='value2' /]

Another advanced example is to use the shortcode to display a survey submission summary by only referencing other parameters, without specifying the ID. The survey will try to load by the parameters specified.

[ays_survey_submissions_summary param1='value1' param2='value2' /]

Please note that ‘param1’, ‘param2’, ‘value1’, and ‘value2’ are placeholders for actual parameters and values that you might need to specify based on your requirements.

PHP Function Code

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

Shortcode line:

add_shortcode('ays_survey_submissions_summary', array($this, 'ays_generate_submissions_summary_method'));

Shortcode PHP function:

function ays_generate_submissions_summary_method( $attr ) {

        $id = (isset($attr['id']) && $attr['id'] != '') ? absint(intval($attr['id'])) : null;

        if (is_null($id)) {
            $content = "<p class='wrong_shortcode_text' style='color:red;'>" . __('Wrong shortcode initialized', "survey-maker") . "</p>";
            return str_replace(array("\r\n", "\n", "\r"), '', $content);
        }

        $this->enqueue_styles();
        $this->enqueue_scripts();

        $unique_id = uniqid();
        $this->unique_id = $unique_id;
        $this->unique_id_in_class = $id . "-" . $unique_id;

        $survey = Survey_Maker_Data::get_survey_by_id( $id );

        $this->options = Survey_Maker_Data::get_survey_validated_data_from_array( $survey, $attr );

        $content = $this->ays_submissions_summary_html( $attr );

        return str_replace(array("\r\n", "\n", "\r"), "\n", $content);
    }

Code file location:

survey-maker/survey-maker/public/partials/class-survey-maker-submissions-summary-shortcode.php

Survey Maker [ays_survey_links_by_category] Shortcode

The Ays Survey Links By Category shortcode is a function that generates unique IDs for surveys and returns survey links by category. This shortcode uses the method ‘ays_survey_links_by_category_method’ to create a unique ID for each survey. It then calls the ‘ays_survey_links_by_category_html’ function using the attributes provided. The resulting HTML is cleaned up, replacing any line breaks with a single newline character, and returned as output.

Shortcode: [ays_survey_links_by_category]

Examples and Usage

Basic example – Display survey links by referencing a specific category ID.

[ays_survey_links_by_category id=1 /]

Advanced examples

Display survey links by referencing a specific category ID and limit the number of links to 5.

[ays_survey_links_by_category id=1 limit=5 /]

Display survey links by referencing a specific category ID, limit the number of links to 5, and order them by title in ascending order.

[ays_survey_links_by_category id=1 limit=5 orderby="title" order="ASC" /]

Display survey links by referencing a specific category ID and show only those surveys that are currently active.

[ays_survey_links_by_category id=1 status="active" /]

Display survey links by referencing a specific category ID and filter them by a specific keyword in their title.

[ays_survey_links_by_category id=1 keyword="feedback" /]

PHP Function Code

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

Shortcode line:

add_shortcode('ays_survey_links_by_category', array($this, 'ays_survey_links_by_category_method'));

Shortcode PHP function:

function ays_survey_links_by_category_method( $attr ){

            $unique_id = uniqid();
            $this->unique_id = $unique_id;
            $this->unique_id_in_class = "-" . $unique_id;

            $survey_links_by_category_html = $this->ays_survey_links_by_category_html( $attr );
            return str_replace(array("\r\n", "\n", "\r"), "\n", $survey_links_by_category_html);
        }

Code file location:

survey-maker/survey-maker/public/partials/class-survey-maker-survey-links-by-category.php

Conclusion

Now that you’ve learned how to embed the Survey Maker – Best WordPress Survey 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 *