AnyComment Shortcodes

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

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

Plugin Icon
AnyComment

"AnyComment is a dynamic WordPress plugin designed to boost user engagement on your website. It facilitates interactive and social-friendly commenting, transforming your site's user experience."

★★★★☆ (152) Active Installs: 3000+ Tested with: 5.9.8 PHP Version: 5.4
Included Shortcodes:
  • [anycomment]
  • [anycomment_socials]

AnyComment [anycomment] Shortcode

The AnyComment shortcode is a powerful tool that allows you to override default settings. It checks if the page is singular and if SASS comments are enabled. If both are true, it prevents the enqueueing of scripts. It then renders the ‘shortcode-comments’ template.

Shortcode: [anycomment]

Examples and Usage

Basic example – The AnyComment shortcode is used to override the default comment section on a singular post or page. If the SaaS comment function is activated, it will prevent the default scripts from loading. The comments will be rendered using the ‘shortcode-comments’ template.

[anycomment /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'anycomment', [ $this, 'shortcode_override' ] );

Shortcode PHP function:

                    function shortcode_override() {
		if ( ! is_singular() || AnyCommentIntegrationSettings::is_sass_comments_show() ) {
			remove_action( 'wp_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
		}

		return AnyCommentTemplate::render( 'shortcode-comments' );
	}
                    

Code file location:

anycomment/anycomment/includes/AnyCommentRender.php

AnyComment [anycomment_socials] Shortcode

The AnyComment shortcode, ‘anycomment_socials’, generates a list of social media platforms for user login. It accepts parameters to customize its output, such as displaying only socials or a specific target URL.

Shortcode: [anycomment_socials]

Parameters

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

  • only_socials – controls whether to display only social login options.
  • output – decides whether to return the HTML or output it directly.
  • target_url – defines the URL where users will be redirected after login.

Examples and Usage

Basic example – The shortcode ‘anycomment_socials’ can be used to display a list of social media links on your website. This is a basic usage of the shortcode without any additional parameters.

[anycomment_socials /]

Advanced examples

Using the shortcode ‘anycomment_socials’ with the ‘only_socials’ parameter set to true. This will display only the social media links without any additional text.

[anycomment_socials only_socials=true /]

Using the shortcode ‘anycomment_socials’ with the ‘output’ parameter set to true. This will echo the output immediately instead of returning it.

[anycomment_socials output=true /]

Using the shortcode ‘anycomment_socials’ with the ‘target_url’ parameter. This allows you to specify a different target URL for the social media links.

[anycomment_socials target_url="https://www.example.com" /]

Using the shortcode ‘anycomment_socials’ with multiple parameters. This example sets the ‘only_socials’ parameter to true, the ‘output’ parameter to true, and specifies a ‘target_url’.

[anycomment_socials only_socials=true output=true target_url="https://www.example.com" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'anycomment_socials', [ $this, 'social_list' ] );

Shortcode PHP function:

                    function social_list( $atts ) {
		$params = shortcode_atts( array(
			'only_socials' => false,
			'output'       => false,
			'target_url'   => home_url( isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : '' ),
		), $atts );

		$socials = $this->login_with( $params['target_url'] );
		$html    = '';

		if ( ! $params['only_socials'] ) {
			$word_line = esc_html( __( 'or use any social:', 'anycomment' ) );
			$html      .= <<<HTML
<div style="margin: 0 0 10px;">
	<div class="anycomment-socials-preparagraph">$word_line</div>
</div>
HTML;
		}

		$html .= $socials;

		if ( false === $params['output'] ) {
			return $html;
		}

		echo wp_kses( $html, [
			'div'   => [
				'class' => [],
				'style' => []
			],
			'ul'    => [
				'class' => [],
			],
			'li'    => [],
			'a'     => [ 'href' => [], 'title' => [] ],
			'img'   => [ 'src' => [], 'alt' => [] ],
			'style' => [],
		] );
	}
                    

Code file location:

anycomment/anycomment/includes/Hooks/AnyCommentNativeLoginForm.php

Conclusion

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