Below, you’ll find a detailed guide on how to add the WebMan Amplifier 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 WebMan Amplifier Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the WebMan Amplifier Plugin and the shortcodes it provides:
"WebMan Amplifier is a powerful WordPress plugin designed to amplify your website's functionality. It enhances your site's features, improving its performance and user experience."
- [webman_amplifier]
WebMan Amplifier [webman_amplifier] Shortcode
The Webman Amplifier shortcode is a powerful tool for customizing content display. It dynamically renders content based on specific attributes and content given. The shortcode function, ‘shortcode_render’, takes in three parameters: attributes, content, and the shortcode itself. It checks for the shortcode’s existence, retrieves global codes, and applies filters for output manipulation. If the shortcode is an alias with a custom renderer file, the function can use a default alias renderer file, a custom renderer file, or a custom shortcode prefix. The function finally returns the processed output, giving developers immense flexibility in content presentation.
Shortcode: [webman_amplifier]
Examples and Usage
Basic example – Display a custom post type with a specific ID using the shortcode.
[custom_post id=15 /]
Advanced examples
Display a custom post type with a specific ID and also specify the number of posts to display. If the number of posts is not found, it will display all posts of that custom post type.
[custom_post id=15 posts=5 /]
Utilize the shortcode to display a gallery by referencing both ID and size. The gallery will first try to load by ID, but if not found, it will display the default size.
Use the shortcode to show a list of related posts by specifying the post ID and the number of related posts to display.
[related_posts id=25 count=3 /]
Display a custom menu by using the shortcode and specifying the menu’s location in the theme.
[menu location="header" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [webman_amplifier]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( $shortcode, __CLASS__ . '::shortcode_render' );
Shortcode PHP function:
function shortcode_render( $atts = array(), $content = '', $shortcode = '' ) {
// Requirements check
$prefix_shortcode = self::$prefix_shortcode; // Used inside shortcode renderer file.
$shortcode = trim( str_replace( $prefix_shortcode, '', $shortcode ) );
if ( empty( $shortcode ) ) {
return;
}
// Helper variables
$codes_globals = self::get_codes_globals(); // Used inside shortcode renderer file.
$output = (string) apply_filters( 'wmhook_shortcode_' . $shortcode, '', $atts, $content, $codes_globals );
// Processing
// Premature output
if ( $output ) {
return $output;
}
// Is this alias shortcode (with custom renderer file)?
$custom_render_shortcodes = self::get_definitions_processed( 'renderer' );
$path_folder = self::get_path_renderers();
$path_file = $path_folder . $shortcode . '.php';
if ( isset( $custom_render_shortcodes[ $shortcode ] ) ) {
$custom_render_code = $custom_render_shortcodes[ $shortcode ];
// Use default alias renderer file
if (
isset( $custom_render_code['alias'] )
&& $custom_render_code['alias']
) {
$path_file = $path_folder . trim( $custom_render_code['alias'] ) . '.php';
}
// Use custom renderer file instead
if (
isset( $custom_render_code['path'] )
&& $custom_render_code['path']
) {
$path_file = trim( $custom_render_code['path'] );
}
// Use custom shortcode prefix (even empty)
if ( isset( $custom_render_code['custom_prefix'] ) ) {
$prefix_shortcode = trim( $custom_render_code['custom_prefix'] );
}
}
$path_file = apply_filters( 'wmhook_shortcode_renderer_path', $path_file, $shortcode );
// The shortcode file contains `$output` variable
/**
* @todo Use PHP buffer instead?
* @todo But maybe still keep `include()` below as we are passing some variables (see above).
*/
if ( file_exists( $path_file ) ) {
include( $path_file );
}
$output = apply_filters( 'wmhook_shortcode_output', $output, $shortcode, $atts );
// Output
return apply_filters( 'wmhook_shortcode_' . $shortcode . '_output', $output, $atts );
}
Code file location:
webman-amplifier/webman-amplifier/includes/shortcodes/class-shortcodes.php
Conclusion
Now that you’ve learned how to embed the WebMan Amplifier 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.
Leave a Reply