Floating Button Shortcode

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

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

Plugin Icon
Floating Button

"Floating Button is a user-friendly WordPress plugin that adds a customizable, eye-catching button to your website. It enhances navigation, boosts user engagement, and improves overall site functionality."

★★★✩✩ (13) Active Installs: 4000+ Tested with: 6.3.2 PHP Version: 7.4
Included Shortcodes:
  • [WOW_Plugin::SHORTCODE]

Floating Button [WOW_Plugin::SHORTCODE] Shortcode

The WOW_Plugin shortcode is a powerful tool that generates a dynamic menu based on the ID provided. It retrieves data from the database using the ID, then creates a menu using the Menu_Maker function. If no ID is provided or the ID doesn’t exist in the database, the shortcode will return false. The shortcode also initializes styles and stores the result in a Singleton instance for later use.

Shortcode: [WOW_Plugin::SHORTCODE]

Parameters

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

  • id – Unique ID that identifies the specific floating button

Examples and Usage

Basic example – Use the shortcode to display a floating button by referencing its ID.

[wow_plugin id=1 /]

PHP Function Code

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

Shortcode line:

add_shortcode( WOW_Plugin::SHORTCODE, [ $this, 'shortcode' ] );

Shortcode PHP function:

                    function shortcode( $atts ) {

		$atts = shortcode_atts(
			[ 'id' => "" ],
			$atts,
			WOW_Plugin::SHORTCODE
		);

		if ( ! empty( $atts['id'] ) ) {
			$result = DBManager::get_data_by_id( $atts['id'] );
		} else {
			return false;
		}

		if ( empty( $result ) ) {
			return false;
		}

		$param  = maybe_unserialize( $result->param );
		$walker = new Menu_Maker( $atts['id'], $param, $result->title );
		$menu = $walker->init();

		$style = new EnqueueStyle($result);
		$style->init();

		$singleton = Singleton::getInstance();
		$singleton->setValue( $result->id, $result );

		return $menu;

	}
                    

Code file location:

floating-button/floating-button/includes/class-wowp-public.php

Conclusion

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