Redux Framework Shortcodes

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

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

Plugin Icon
Redux Framework

"Redux Framework is a comprehensive toolkit for WordPress developers. It provides a robust platform for developing themes and plugins with ease and efficiency."

★★★★✩ (262) Active Installs: 1000000+ Tested with: 6.3.2 PHP Version: 7.1
Included Shortcodes:
  • [bloginfo]
  • [themeinfo]
  • [date]

Redux Framework [bloginfo] Shortcode

The Redux-Framework plugin shortcode, ‘bloginfo’, is designed to retrieve and display various blog information based on provided attributes. It operates by checking the ‘data’ attribute and returning the corresponding information. For instance, it can return stylesheet directory, template URLs, text direction, multisite status, and various URLs like home, site, stylesheet, login, register, and lost password. It defaults to returning general blog information if no specific ‘data’ attribute is provided.

Shortcode: [bloginfo]

Parameters

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

  • stylesheet_directory – Returns the directory of the active theme’s stylesheet.
  • child_template_directory – Returns the directory of the child theme’s template.
  • parent_template_url – Gives the URL of the parent theme’s template.
  • child_template_url – Provides the URL of the child theme’s template.
  • template_url – Returns the URL of the active theme’s template.
  • template_directory – Returns the directory of the active theme’s template.
  • text_direction, text_direction_bool, text_direction_boolean – Determines if the text direction is right-to-left.
  • is_multisite – Checks if WordPress is in multisite mode.
  • url – Returns the home URL of the website.
  • root_url – Provides the site URL of the website.
  • stylesheet_url – Returns the URL of the active theme’s stylesheet.
  • logout_url – Provides the URL for logging out of WordPress.
  • login_url – Returns the URL for logging into WordPress.
  • register_url – Provides the URL for registering a new user account.
  • lostpassword_url, lost_password_url – Returns the URL for the lost password page.

Examples and Usage

Basic example – A simple use of the ‘bloginfo’ shortcode to retrieve the URL of the current site.

[bloginfo data=url /]

Advanced examples

Using the ‘bloginfo’ shortcode to retrieve the directory of the current theme’s stylesheet. This is useful when you need to reference the stylesheet’s directory in your posts or pages.

[bloginfo data=stylesheet_directory /]

Using the ‘bloginfo’ shortcode to check if the current WordPress installation is a multisite network. This can be helpful when you need to conditionally display content based on whether the site is part of a network or not.

[bloginfo data=is_multisite /]

Using the ‘bloginfo’ shortcode to retrieve the login URL. This can be used to create a custom login link in your posts or pages.

[bloginfo data=login_url /]

Using the ‘bloginfo’ shortcode to retrieve the URL for the lost password page. This can be useful when you want to provide a direct link to the lost password page in your content.

[bloginfo data=lostpassword_url /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'bloginfo', array( $this, 'blog_info' ) );

Shortcode PHP function:

function blog_info( $atts = array(), string $content = null ) {
			if ( ! is_array( $atts ) ) {
				$atts = array();
			}

			if ( ! empty( $content ) && ! isset( $atts['data'] ) ) {
				$atts['data'] = $content;
			}

			switch ( $atts['data'] ) {
				case 'stylesheet_directory':
				case 'child_template_directory':
					return get_stylesheet_directory();
				case 'parent_template_url':
					return get_template_directory_uri();
				case 'child_template_url':
				case 'template_url':
					return get_stylesheet_directory_uri();
				case 'template_directory':
					return get_template_directory();
				case 'text_direction':
				case 'text_direction_bool':
				case 'text_direction_boolean':
					return is_rtl();
				case 'is_multisite':
					return is_multisite();
				case 'url':
					return esc_url( home_url() );
				case 'root_url':
					return esc_url( site_url() );
				case 'stylesheet_url':
					return esc_url( get_stylesheet_uri() );
				case 'logout_url':
					return esc_url( wp_logout_url() );
				case 'login_url':
					return esc_url( wp_login_url() );
				case 'register_url':
					return esc_url( wp_registration_url() );
				case 'lostpassword_url':
				case 'lost_password_url':
					return esc_url( wp_lostpassword_url() );
				default:
					return get_bloginfo( $atts['data'] );
			}
		}

Code file location:

redux-framework/redux-framework/redux-core/inc/extensions/shortcodes/class-redux-shortcodes.php

Redux Framework [themeinfo] Shortcode

The Redux-Framework plugin shortcode ‘themeinfo’ retrieves and displays various information about the current theme. By calling the shortcode in your content, you can access details such as theme name, author, version, and more. It also checks if the theme is a child theme. The retrieved data is then returned for display.

Shortcode: [themeinfo]

Parameters

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

  • name – Displays the name of the theme
  • themeuri – Shows the theme’s URI
  • theme_uri – Alternative way to show the theme’s URI
  • description – Outputs the theme’s description
  • author – Displays the theme’s author
  • authoruri – Shows the URI of the theme’s author
  • author_uri – Alternative way to show the author’s URI
  • version – Outputs the version of the theme
  • template – Displays the theme’s template
  • status – Shows the theme’s status
  • tags – Outputs the theme’s tags
  • textdomain – Displays the theme’s text domain
  • text_domain – Alternative way to show the theme’s text domain
  • domainpath – Shows the theme’s domain path
  • domain_path – Alternative way to display the theme’s domain path
  • is_child – Indicates if the theme is a child theme

Examples and Usage

Basic example – Display the theme name using the ‘themeinfo’ shortcode.

[themeinfo data="name" /]

Advanced examples

Display the theme’s author and version using the ‘themeinfo’ shortcode. Two separate shortcodes are used to display each piece of information.

[themeinfo data="author" /]
[themeinfo data="version" /]

Using the shortcode to display if the theme is a child theme or not. If it is a child theme, it will return true, otherwise, it will return false.

[themeinfo data="is_child" /]

Using the shortcode to display the theme’s description. The ‘description’ attribute is used to fetch and display the theme’s description.

[themeinfo data="description" /]

Using the shortcode to display the theme’s text domain. The ‘textdomain’ attribute is used to fetch and display the theme’s text domain.

[themeinfo data="textdomain" /]

Using the shortcode to display the theme’s tags. The ‘tags’ attribute is used to fetch and display the theme’s tags.

[themeinfo data="tags" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'themeinfo', array( $this, 'theme_info' ) );

Shortcode PHP function:

function theme_info( array $atts = array(), string $content = null ) {
			if ( ! is_array( $atts ) ) {
				$atts = array();
			}

			if ( ! empty( $content ) && ! isset( $atts['data'] ) ) {
				$atts['data'] = $content;
			}

			if ( empty( $this->theme_info ) ) {
				$this->theme_info = wp_get_theme();
			}

			$keys = array(
				'name'        => 'Name',
				'themeuri'    => 'ThemeURI',
				'theme_uri'   => 'ThemeURI',
				'description' => 'Description',
				'author'      => 'Author',
				'authoruri'   => 'AuthorURI',
				'author_uri'  => 'AuthorURI',
				'version'     => 'Version',
				'template'    => 'Template',
				'status'      => 'Status',
				'tags'        => 'Tags',
				'textdomain'  => 'TextDomain',
				'text_domain' => 'TextDomain',
				'domainpath'  => 'DomainPath',
				'domain_path' => 'DomainPath',
				'is_child'    => 'is_child',
			);

			$atts['data'] = $keys[ strtolower( $atts['data'] ) ];

			switch ( $atts['data'] ) {
				case 'is_child':
					return Redux_Helpers::is_child_theme( get_template_directory() );
				default:
					$return = $this->theme_info->get( $atts['data'] );

					if ( is_array( $return ) ) {
						$return = implode( ', ', $return );
					}

					return $return;
			}
		}

Code file location:

redux-framework/redux-framework/redux-core/inc/extensions/shortcodes/class-redux-shortcodes.php

Redux Framework [date] Shortcode

The Redux-Framework plugin shortcode ‘date’ is a handy tool that returns the current date. It takes an optional ‘data’ attribute to format the date. The shortcode starts by checking if ‘atts’ is an array and if ‘content’ is not empty. If ‘content’ is not empty and ‘data’ is not set, it assigns ‘content’ to ‘data’. If ‘data’ is still empty, it defaults to ‘Y’ which represents the current year in PHP. The shortcode then returns the date in the specified format.

Shortcode: [date]

Parameters

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

  • atts – It’s an optional array that can store various attributes.
  • content – An optional string that provides the custom date format.
  • data – A part of attributes, it sets the date format. Default is ‘Y’.

Examples and Usage

Basic example – A simple usage of the ‘date’ shortcode without any parameters. By default, it will return the current year in ‘Y’ format.

[date /]

Advanced examples

Using the ‘date’ shortcode with the ‘data’ parameter. This parameter allows you to specify the format of the date you want to display. In this example, ‘d-m-Y’ will display the current date in the format ‘Day-Month-Year’.

[date data='d-m-Y' /]

Another advanced usage of the ‘date’ shortcode is to display the current time along with the date. For this, you can use the ‘H:i:s’ format in the ‘data’ parameter. This will display the current date and time in the format ‘Hour:Minute:Second’.

[date data='d-m-Y H:i:s' /]

Lastly, you can also use the ‘date’ shortcode to display the name of the current month by using the ‘F’ format in the ‘data’ parameter.

[date data='F' /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'date', array( $this, 'date' ) );

Shortcode PHP function:

function date( $atts = array(), string $content = null ) {
			if ( ! is_array( $atts ) ) {
				$atts = array();
			}

			if ( ! empty( $content ) && ! isset( $atts['data'] ) ) {
				$atts['data'] = $content;
			}

			if ( empty( $atts['data'] ) ) {
				$atts['data'] = 'Y';
			}

			return gmdate( $atts['data'] );
		}

Code file location:

redux-framework/redux-framework/redux-core/inc/extensions/shortcodes/class-redux-shortcodes.php

Conclusion

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