oik Shortcode

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

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

Plugin Icon
oik

"oik is a versatile WordPress plugin designed to enhance your website's functionality. It simplifies site creation, offering numerous shortcodes and widgets for a customized experience."

★★★☆✩ (3) Active Installs: 3000+ Tested with: 6.3.2 PHP Version: false
Included Shortcodes:
  • []

oik [null] Shortcode

The Oik plugin shortcode [bw_shortcode_event] is designed to expand and process specific functions within your WordPress content. It checks the current filter and tag, determines whether to expand, and identifies the shortcode function to apply. If a post-processing function exists for the result, it applies it. The shortcode ensures seamless content processing, enhancing your site’s functionality.

Shortcode: [null]

Examples and Usage

Basic example – Displaying a shortcode by referencing its unique identifier.

[bw_shortcode_event id="unique_id" /]

Advanced examples

Displaying a shortcode by referencing its unique identifier and setting the ‘expand’ attribute to true. This will allow the shortcode to be expanded and its content to be displayed.

[bw_shortcode_event id="unique_id" expand="true" /]

Using the shortcode to display a specific event by referencing its unique identifier and setting the ‘tag’ attribute. The tag attribute allows you to specify a particular event that you want to display.

[bw_shortcode_event id="unique_id" tag="event_tag" /]

Using the shortcode to display a specific event by referencing its unique identifier, setting the ‘tag’ attribute, and applying a filter to the shortcode attributes and content. The ‘oik_shortcode_atts’ and ‘oik_shortcode_content’ filters allow you to modify the shortcode’s attributes and content before they are displayed.

[bw_shortcode_event id="unique_id" tag="event_tag" oik_shortcode_atts="filter_atts" oik_shortcode_content="filter_content" /]

PHP Function Code

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

Shortcode line:

add_shortcode( $shortcode, "bw_shortcode_event" );

Shortcode PHP function:

                    function bw_shortcode_event( $atts, $content=null, $tag=null ) {
		global $bw_sc_ev, $bw_sc_ev_pp, $bw_sc_te;
		// bw_trace( "<$tag>", __FUNCTION__, __LINE__, __FILE__, "tag" );
		$cf=current_filter();
		if ( ! isset( $tag ) || $tag == null ) {
			$tag=bw_array_get( $atts, 0, null );
		}
		if ( $cf == "the_title" ) {
			$expand=bw_get_shortcode_title_expansion( $tag );
		} else {
			$expand=true;
		}
		$shortcodefunc=null;
		bw_trace2( $cf, "current_filter $tag $expand $shortcodefunc", true, BW_TRACE_DEBUG );
		if ( $expand ) {
			if ( isset( $bw_sc_ev[ $tag ]['all'] ) ) {
				$shortcodefunc=$bw_sc_ev[ $tag ]['all'];
			} else {
				if ( empty( $cf ) ) {
					$cf='all'; // was 'wp_footer';
				}
				if ( isset( $bw_sc_ev[ $tag ][ $cf ] ) ) {
					$shortcodefunc=$bw_sc_ev[ $tag ][ $cf ];
				}
			}
		}
		//bw_trace( $tag, __FUNCTION__, __LINE__, __FILE__, "tag" );
		$saved_post=bw_global_post();
		$result    ='<span>&#91;</span>' . $tag . ']';
		//bw_trace( $cf, __FUNCTION__, __LINE__, __FILE__, "current_filter" );
		if ( $shortcodefunc ) {
			//bw_trace( $bw_sc_ev, __FUNCTION__, __LINE__, __FILE__, "bw_sc_ev" );
			$atts         =bw_cast_array( $atts );
			$atts         =apply_filters( "oik_shortcode_atts", $atts, $content, $tag );
			$content      =apply_filters( "oik_shortcode_content", $content, $atts, $tag );
			$shortcodefunc=bw_load_shortcodefunc( $shortcodefunc, $tag );
			$result       =call_user_func( $shortcodefunc, $atts, $content, $tag );
			$result       =apply_filters( "oik_shortcode_result", $result, $atts, $content, $tag );
		}

		/**
		 * Regardless of what routine we used to expand the shortcode we still need to check
		 * if there's a specific function to post process the result. e.g. remove attrs in admin processing
		 */
		//bw_trace( $result, __FUNCTION__, __LINE__, __FILE__, "result" );
		if ( isset( $bw_sc_ev_pp[ $tag ][ $cf ] ) ) {
			$ppfunc=$bw_sc_ev_pp[ $tag ][ $cf ];
			if ( function_exists( $ppfunc ) ) {
				$result=$ppfunc( $result, $cf );
			} else {
			    /* translators: %s: function name */
				$result.='<b>' . sprintf( __( 'missing post processing function: %1$s', 'oik' ), $ppfunc ) . '</b>';
			}

			//bw_trace( $result, __FUNCTION__, __LINE__, __FILE__, "result" );

		}
		bw_global_post( $saved_post );

		return $result;
	}
                    

Code file location:

oik/oik/libs/oik-shortcodes.php

Conclusion

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