Widgetize Pages Light Shortcodes

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

Before starting, here is an overview of the Widgetize Pages Light Plugin and the shortcodes it provides:

Plugin Icon
Widgetize Pages Light

"Widgetize Pages Light is a versatile WordPress plugin. It offers a user-friendly interface allowing you to embed widgets in pages, enhancing functionality and design flexibility."

★★★★✩ (32) Active Installs: 5000+ Tested with: 5.9.8 PHP Version: false
Included Shortcodes:
  • [otw_shortcode_grid_column]
  • [widgetize-pages-light]
  • [otw_is]

Widgetize Pages Light [otw_shortcode_grid_column] Shortcode

The ‘otw_shortcode_grid_column’ shortcode from the widgetize-pages-light plugin is used to create responsive grid columns. It accepts parameters like ‘from_rows’, ‘rows’, ‘mobile_rows’, ‘mobile_from_rows’, and ‘last’ to define the grid structure.

Shortcode: [otw_shortcode_grid_column]

Parameters

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

  • from_rows – defines the total number of rows in a grid
  • rows – sets the number of rows the column spans
  • mobile_rows – sets the number of rows the column spans on mobile
  • mobile_from_rows – defines the total number of rows in a mobile grid
  • last – indicates if the column is the last in the row

Examples and Usage

Basic Example – A simple usage of the ‘otw_shortcode_grid_column’ shortcode to create a grid column with a specified number of rows.

[otw_shortcode_grid_column from_rows=3 rows=2]

Advanced Examples

Using the shortcode to create a grid column with specified rows and mobile rows. The grid will adjust according to the device screen size.

[otw_shortcode_grid_column from_rows=3 rows=2 mobile_rows=2 mobile_from_rows=3]

Using the shortcode to create a grid column with specified rows and marking it as the last column. This can be used when you want to indicate that this is the final column in a row.

[otw_shortcode_grid_column from_rows=3 rows=2 last=1]

Using the shortcode to create a grid column with specified rows, mobile rows, and marking it as the last column. This is a combination of all available attributes for the most flexible grid column creation.

[otw_shortcode_grid_column from_rows=3 rows=2 mobile_rows=2 mobile_from_rows=3 last=1]

PHP Function Code

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

Shortcode line:

add_shortcode( 'otw_shortcode_grid_column', array( &$this, 'otw_shortcode_grid_column' ) );

Shortcode PHP function:

function otw_shortcode_grid_column( $attributes, $content ){
	
		$column_class = $this->number_names[ ( ( $this->grid_size / $attributes['from_rows'] ) * $attributes['rows'] ) ];
		
		if( isset( $attributes['mobile_rows'] ) && isset( $attributes['mobile_from_rows'] ) && ( $attributes['mobile_rows'] > 0 ) && ( $attributes['mobile_from_rows'] > 0 ) ){
			$column_class .= ' mobile-'.$this->number_names[ ( ( $this->mobile_grid_size / $attributes['mobile_from_rows'] ) * $attributes['mobile_rows'] ) ];
		}
		
		$is_last = '';
		if( isset( $attributes['last'] ) && ( $attributes['last'] == 1 ) ){
			$is_last = ' end';
		}
		$html  = "";
		$html .= "<div class=\"otw-".$column_class." otw-columns".$is_last."\">";
		$html .= $this->otw_shortcode_remove_wpautop( $content );
		$html .= "</div>";
	
		return $html;
	}

Code file location:

widgetize-pages-light/widgetize-pages-light/include/otw_components/otw_grid_manager/otw_grid_manager.class.php

Widgetize Pages Light [widgetize-pages-light] Shortcode

The ‘widgetize-pages-light’ plugin shortcode enables the display of specific sidebars within your content. It uses the ‘display_shortcode’ function to output the chosen sidebar.

Shortcode: [widgetize-pages-light]

Parameters

Here is a list of all possible widgetize-pages-light shortcode parameters and attributes:

  • attributes – It is an array that contains the attributes passed to the shortcode.
  • content – The enclosed content within the shortcode tags, if any.
  • sidebar_id – It is an attribute that specifies the unique ID of the sidebar to be displayed.

Examples and Usage

Basic example – A simple usage of the shortcode to display a particular sidebar by referencing its ID.

[otw_is sidebar=1 /]

Advanced examples

Using the shortcode to display a sidebar by referencing its ID, and also including additional content within the shortcode. The content will be displayed if the sidebar with the given ID is not found.

[otw_is sidebar=1]Additional content to display if sidebar not found[/otw_is]

Using the shortcode to display a sidebar by referencing its ID, but also specifying an alternative sidebar to display if the first one is not found. This is achieved by nesting one shortcode inside another.

[otw_is sidebar=1][otw_is sidebar=2][/otw_is][/otw_is]

These examples demonstrate the flexibility of the shortcode, allowing you to conditionally display different sidebars or content based on the presence or absence of a particular sidebar.

PHP Function Code

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

Shortcode line:

add_shortcode( $shortcode_data['object']->shortcode_name, array( &$this->shortcodes[ $shortcode_key ]['object'], 'display_shortcode' ) );

Shortcode PHP function:

function display_shortcode( $attributes, $content ){
		
		$html = '';
		if( is_admin() ){
			$html = '<img src="'.$this->component_url.'img/sidebars-icon-placeholder.png'.'" alt=""/>';
		}elseif( isset( $attributes['sidebar_id'] ) ){
			$html = do_shortcode( '[otw_is sidebar="'.esc_attr( $attributes['sidebar_id'] ).'"]' );
		}
		
		return $this->format_shortcode_output( $html );
	}

Code file location:

widgetize-pages-light/widgetize-pages-light/include/otw_components/otw_shortcode/otw_shortcode.class.php

Widgetize Pages Light [otw_is] Shortcode

The widgetize-pages-light plugin shortcode ‘otw_is’ is used to call a specific sidebar within your WordPress site. This shortcode checks if a sidebar is active, filters its widgets, and displays them either vertically or horizontally. It also applies custom CSS classes to the first and last widget for styling purposes.

Shortcode: [otw_is]

Parameters

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

  • sidebar – Specifies the unique identifier of the sidebar to display

Examples and Usage

Basic example – A simple way to use the shortcode to call a sidebar. You just need to specify the sidebar ID in the ‘sidebar’ attribute.

[otw_is sidebar="sidebar-1" /]

Advanced examples

Using the shortcode to display a specific sidebar by referencing the sidebar ID. The sidebar will load only if it’s active and has widgets assigned to it.

[otw_is sidebar="sidebar-2" /]

Another advanced usage could be to call multiple sidebars at once by specifying their IDs separated by commas. This will display all the sidebars that are active and have widgets.

[otw_is sidebar="sidebar-1,sidebar-2,sidebar-3" /]

PHP Function Code

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

Shortcode line:

add_shortcode('otw_is', 'otw_call_sidebar');

Shortcode PHP function:

function otw_call_sidebar( $attributes ){
		
		global $wp_registered_sidebars, $wp_registered_widgets;
		
		$sidebar_output = '';
		
		if( isset( $attributes['sidebar'] ) ){
			
			if( is_active_sidebar( $attributes['sidebar'] ) && otw_is_active_sidebar( $attributes['sidebar'] ) ){
				
				$index = otw_sidebar_index( $attributes['sidebar'] );
				
				$sidebars_widgets = wp_get_sidebars_widgets();
				
				//filter widgets for ths sidebar
				$sidebars_widgets[ $index ] = otw_filter_siderbar_widgets( $index, $sidebars_widgets );
				
				if( !count( $sidebars_widgets[ $index ] ) ){
					return;
				}
				
				$container = '<div class="otw-sidebar '.$attributes['sidebar'].'';
				$sidebar = $wp_registered_sidebars[ $index ];
				
				$widget_percentage = 0;
				
				$widget_alignement = 'vertical';
				
				switch( $widget_alignement ){
					
					case 'horizontal':
							$container .= ' otw-sidebar-horizontal';
							
							$widget_percentage = round( 100 / count( $sidebars_widgets[$index] ), 1 );
							
						break;
					default:
							$container .= ' otw-sidebar-vertical';
						break;
				}
				$container .= '">';
				
				ob_start();
				echo $container;
				
				$widget_number = 0;
				foreach( $sidebars_widgets[$index] as $id ) {
					
					if( !isset( $wp_registered_widgets[$id] ) ){
						continue;
					}
					$widget_number++;
					
					$params = array_merge(
						array( array_merge( $sidebar, array('widget_id' => $id, 'widget_name' => $wp_registered_widgets[$id]['name']) ) ),
						(array) $wp_registered_widgets[$id]['params']
					);
					$classname_ = 'widget otw-widget-'.$widget_number;
					
					if( $widget_number == 1 ){
						$classname_ .= ' widget-first';
					}elseif( $widget_number == count( $sidebars_widgets[$index] ) ){
						$classname_ .= ' widget-last';
					}
					
					foreach ( (array) $wp_registered_widgets[$id]['classname'] as $cn ) {
						if ( is_string($cn) ){
							$classname_ .= ' ' . $cn;
						}elseif ( is_object($cn) ){
							$classname_ .= ' ' . get_class($cn);
						}
					}
					$classname_ = ltrim($classname_, '_');
					
					if( $widget_percentage ){
						$params[0]['before_widget'] = '<div class="'.esc_attr( $classname_ ).'" style="width: '.$widget_percentage.'%;">';
					}else{
						$params[0]['before_widget'] = '<div class="'.esc_attr( $classname_ ).'">';
					}
					$params[0]['after_widget'] = '</div>';
					
					$params = apply_filters( 'otw_shortcode_sidebar_params', $params );
					
					$callback = $wp_registered_widgets[$id]['callback'];
					
					do_action( 'dynamic_sidebar', $wp_registered_widgets[$id] );
					
					if( is_callable($callback) ) {
						call_user_func_array($callback, $params);
					}
				}
				
				echo '</div>';
				$sidebar_output = ob_get_contents();
				ob_end_clean();
			}
		}
		return $sidebar_output;
	}

Code file location:

widgetize-pages-light/widgetize-pages-light/otw_sidebar_manager.php

Conclusion

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