WP Affiliate Disclosure Shortcode

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

Before starting, here is an overview of the WP Affiliate Disclosure Plugin and the shortcodes it provides:

Plugin Icon
WP Affiliate Disclosure

"WP Affiliate Disclosure is a powerful WordPress plugin that helps bloggers and marketers comply with FTC regulations by automatically adding affiliate disclaimers to their posts."

★★★★★ (1) Active Installs: 3000+ Tested with: 6.2.3 PHP Version: 5.6
Included Shortcodes:
  • [wpadc]

WP Affiliate Disclosure [wpadc] Shortcode

The WP Affiliate Disclosure shortcode is designed to generate a disclosure statement on your website. It extracts the ‘id’ attribute from the shortcode and uses it to create a unique CSS id for the disclosure statement. The shortcode then initiates a new WPADC_Disclosure_Statement object and renders it within a div. The output is buffered, cleaned, and returned as HTML. Shortcode: [wpadc_sc] The ‘apply_filters’ function allows for additional customization, making this shortcode a versatile tool for any WordPress site. Shortcode: [wpadc_sc]

Shortcode: [wpadc]

Parameters

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

  • id – The unique identifier for the disclosure statement.

Examples and Usage

Basic example – A shortcode that displays the affiliate disclosure statement without any specific ID.

[wpadc /]

Advanced examples

Using the shortcode to display a specific affiliate disclosure statement by referencing its ID. This will load the disclosure statement associated with the given ID.

[wpadc id=2 /]

Another advanced usage could be applying filters to the shortcode. This can be done by passing the filter name as an attribute to the shortcode. The following example shows how to apply a filter named ‘custom_filter’ to the shortcode.

[wpadc filter='custom_filter' /]

It’s important to note that the actual effect of the filter will depend on how it’s been defined in your WordPress installation. Filters allow you to modify the output of the shortcode, providing a high degree of customization.

PHP Function Code

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

Shortcode line:

add_shortcode( 'wpadc' , array(&$this, 'wpadc_sc') );

Shortcode PHP function:

                    function wpadc_sc( $atts ) {

		extract( shortcode_atts( array(
			'id' => ''
		), $atts , 'wpadc' ) );

		$component = new WPADC_Disclosure_Statement();

		ob_start();
		?>
		<div id="wp-affiliate-disclosure<?php echo ( !empty( $id ) ? '-' . $id : '' ); ?>" class="wpadc_sc">
			<?php echo $component->render( 'shortcode' ); ?>
		</div>
		<?php
		$html = ob_get_clean();

		return apply_filters( $this->_hook_prefix . 'wpadc_sc' , ( !empty( $html ) ? $html : '' ) , $atts , $this );
		
	}
                    

Code file location:

wp-affiliate-disclosure/wp-affiliate-disclosure/builder/builder/controller.php

Conclusion

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