Wrc Pricing Tables Shortcode

Below, you’ll find a detailed guide on how to add the Wrc Pricing Tables Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Wrc Pricing Tables Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Wrc Pricing Tables Plugin and the shortcodes it provides:

Plugin Icon
WRC Pricing Tables – WordPress Responsive CSS3 Pricing Tables

"WRC Pricing Tables is a WordPress plugin that enables you to create responsive and stylish CSS3 pricing tables. It's easy to use, customizable, and perfect for showcasing your product pricing plans."

★★★★✩ (34) Active Installs: 2000+ Tested with: 6.3.2 PHP Version: 7.0
Included Shortcodes:
  • [wrc-pricing-table]

Wrc Pricing Tables [wrc-pricing-table] Shortcode

The ‘wrc-pricing-table’ shortcode is used to display a pricing table on a WordPress page. It accepts an ‘id’ attribute which corresponds to a specific pricing table. This shortcode fetches the pricing table details from the options stored in your WordPress database. It then processes this data to render the desired pricing table. Moreover, it sanitizes and validates all the data to ensure security. Shortcode: [wrc-pricing-table]

Shortcode: [wrc-pricing-table]

Parameters

Here is a list of all possible wrc-pricing-table shortcode parameters and attributes:

  • id – Unique identifier for the specific pricing table

Examples and Usage

Basic example – Display a pricing table by referencing its ID.

[wrc-pricing-table id=1 /]

Advanced examples

Display a pricing table with a specific ID. If the table with the given ID is not found, it will not show any table.

[wrc-pricing-table id=2 /]

Display a pricing table with a non-existent ID. This will not show any table as the table with the given ID does not exist.

[wrc-pricing-table id=999 /]

Display a pricing table without specifying an ID. This will show the default table (with ID 1) as no ID has been specified.

[wrc-pricing-table /]

PHP Function Code

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

Shortcode line:

add_shortcode('wrc-pricing-table', 'wrc_pricing_table_shortcode');

Shortcode PHP function:

function wrc_pricing_table_shortcode( $atts, $content = null ) {
    $atts = shortcode_atts( array(
        'id' => 1
    ), $atts, 'wrc-pricing-table' );

    // Sanitize and validate $id here
    $id = absint( $atts['id'] );

    $f_value = $f_tips = '';
    $total_feature = $flag = 0;

    $pricing_table_lists = get_option('packageTables');
    $pricing_id_lists = get_option('packageIDs');
    $pricing_table_lists = explode(', ', $pricing_table_lists);
    $pricing_id_lists = explode(', ', $pricing_id_lists);

    // Sanitize and validate $pricing_table_lists and $pricing_id_lists

    $key = array_search($id, $pricing_id_lists);
    if( $key !== false ) {
        $flag = 1;
    }

    $pricing_table = isset( $pricing_table_lists[ $key ] ) ? $pricing_table_lists[ $key ] : '';
    $tableID = $pricing_table ? strtolower($pricing_table) . '-' .$id : '';

    // Sanitize and validate $pricing_table and $tableID

    $package_feature = get_option( $pricing_table.'_feature' );
    $packageCombine = get_option( $pricing_table.'_option' );

    // Sanitize and validate $package_feature and $packageCombine

    if( $package_feature ) {
        $total_feature = count( $package_feature ) / 2;
    }

    $package_lists = get_option( $pricing_table );
    $packageOptions = explode( ', ', $package_lists );
    $package_count = count( $packageOptions );

    // Sanitize and validate $package_lists and $packageOptions

    require_once( WRCPT_PLUGIN_PATH . 'lib/process-shortcode.php' );

    ob_start();
    echo wrcpt_shortcode(
        $pricing_table,
        $tableID,
        $package_feature,
        $packageCombine,
        $total_feature,
        $package_lists,
        $packageOptions,
        $package_count,
        $flag
    );
    
    return ob_get_clean();
}

Code file location:

wrc-pricing-tables/wrc-pricing-tables/wrc-pricing-tables.php

Conclusion

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

Comments

Leave a Reply

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