Pixelgrade Assistant Shortcodes

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

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

Plugin Icon
Pixelgrade Assistant

"Pixelgrade Assistant is a dynamic WordPress plugin designed to enhance designing experience. It provides a seamless way to manage WordPress themes, offering users a streamlined, efficient workflow."

✩✩✩✩✩ () Active Installs: 4000+ Tested with: 5.9.8 PHP Version: 5.6.40
Included Shortcodes:
  • [portfolio]
  • [jetpack_nova_menu]
  • [pixassist_create_page_shortcode]
  • [ot_reservation_widget]

Pixelgrade Assistant [portfolio] Shortcode

The Pixelgrade Assistant ‘portfolio’ shortcode is designed to display a portfolio grid on your WordPress site. It allows you to customize the display of types, tags, content, and author. The shortcode attributes control the columns, posts shown, order, and sorting method. You can also specify the inclusion or exclusion of certain types, tags, or IDs. It ensures data sanitization and proper formatting for a seamless portfolio display.

Shortcode: [portfolio]

Parameters

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

  • display_types – Allows to show or hide portfolio types.
  • display_tags – Controls visibility of portfolio tags.
  • display_content – Determines if portfolio content is displayed.
  • display_author – Option to show or hide the author.
  • include_type – Includes specific types in portfolio.
  • include_tag – Includes specific tags in portfolio.
  • exclude_ids – Excludes specific portfolio IDs.
  • columns – Sets the number of portfolio columns.
  • showposts – Defines the number of posts to show.
  • order – Sets the order of portfolio items (ASC or DESC).
  • orderby – Determines the portfolio items’ order by parameter.

Examples and Usage

Basic example – Display the portfolio with default attributes

[portfolio /]

Advanced examples

Display the portfolio with specific types and tags, and limit the number of posts displayed

[portfolio display_types=true display_tags=true showposts=5 /]

Display the portfolio excluding certain IDs, ordering by title in ascending order

[portfolio exclude_ids="1,2,3" order="asc" orderby="title" /]

Display the portfolio including only certain types and tags, with specific columns

[portfolio include_type="type1,type2" include_tag="tag1,tag2" columns=4 /]

Display the portfolio without author and content, ordering randomly

[portfolio display_author=false display_content=false orderby="rand" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'portfolio', array( $this, 'portfolio_shortcode' ) );

Shortcode PHP function:

function portfolio_shortcode( $atts ) {
		// Default attributes
		$atts = shortcode_atts( array(
			'display_types'   => true,
			'display_tags'    => true,
			'display_content' => true,
			'display_author'  => false,
			'include_type'    => false,
			'include_tag'     => false,
			'exclude_ids'     => false,
			'columns'         => 3,
			'showposts'       => -1,
			'order'           => 'desc',
			'orderby'         => 'date',
		), $atts, 'portfolio' );

		// A little sanitization
		if ( $atts['display_types'] && 'true' != $atts['display_types'] ) {
			$atts['display_types'] = false;
		}

		if ( $atts['display_tags'] && 'true' != $atts['display_tags'] ) {
			$atts['display_tags'] = false;
		}

		if ( $atts['display_author'] && 'true' != $atts['display_author'] ) {
			$atts['display_author'] = false;
		}

		if ( $atts['display_content'] && 'true' != $atts['display_content'] && 'full' != $atts['display_content'] ) {
			$atts['display_content'] = false;
		}

		if ( $atts['include_type'] ) {
			$atts['include_type'] = explode( ',', str_replace( ' ', '', $atts['include_type'] ) );
		}

		if ( $atts['include_tag'] ) {
			$atts['include_tag'] = explode( ',', str_replace( ' ', '', $atts['include_tag'] ) );
		}

		if ( $atts['exclude_ids'] ) {
			$atts['exclude_ids'] = explode( ',', str_replace( ' ', '', $atts['exclude_ids'] ) );
		}

		$atts['columns'] = absint( $atts['columns'] );

		$atts['showposts'] = intval( $atts['showposts'] );


		if ( $atts['order'] ) {
			$atts['order'] = urldecode( $atts['order'] );
			$atts['order'] = strtoupper( $atts['order'] );
			if ( 'DESC' != $atts['order'] ) {
				$atts['order'] = 'ASC';
			}
		}

		if ( $atts['orderby'] ) {
			$atts['orderby'] = urldecode( $atts['orderby'] );
			$atts['orderby'] = strtolower( $atts['orderby'] );
			$allowed_keys = array( 'author', 'date', 'title', 'rand' );

			$parsed = array();
			foreach ( explode( ',', $atts['orderby'] ) as $portfolio_index_number => $orderby ) {
				if ( ! in_array( $orderby, $allowed_keys ) ) {
					continue;
				}
				$parsed[] = $orderby;
			}

			if ( empty( $parsed ) ) {
				unset( $atts['orderby'] );
			} else {
				$atts['orderby'] = implode( ' ', $parsed );
			}
		}

		return self::portfolio_shortcode_html( $atts );
	}

Code file location:

pixelgrade-assistant/pixelgrade-assistant/includes/theme-helpers/jetpack-fallbacks/portfolio-shortcode/class-jetpack-portfolio-shortcode.php

Pixelgrade Assistant [jetpack_nova_menu] Shortcode

The Pixelgrade Assistant plugin shortcode ‘jetpack_nova_menu’ is designed to customize the display of menu sections on a webpage. It allows control over the visibility of sections, labels, and content.

Shortcode: [jetpack_nova_menu]

Parameters

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

  • display_sections – Decides whether to show menu sections or not
  • display_labels – Controls if labels are shown
  • display_content – Determines if content is displayed, can be ‘full’ for full content
  • link_items – Decides if menu items are linked
  • featured_label – Sets the label for highlighted menu items
  • style – Changes the style of the menu, can be ‘dotted’
  • include_section – Includes specific sections in the menu
  • include_label – Includes specific labels in the menu
  • showposts – Dictates the number of posts to be shown
  • order – Sets the order of posts, can be ascending (‘ASC’) or descending (‘DESC’)
  • orderby – Determines the basis for post order, options include ‘date’, ‘title’, ‘rand’

Examples and Usage

Basic Example – The shortcode is used to display a menu with default parameters. It does not require any attributes, making it a simple and straightforward implementation.

[jetpack_nova_menu /]

Advanced Examples

1. Display a menu without sections and labels, and limit the number of posts to 5. The ‘display_sections’ and ‘display_labels’ attributes are set to false, and ‘showposts’ is set to 5.

[jetpack_nova_menu display_sections=false display_labels=false showposts=5 /]

2. Display a menu with a specific style, featured label, and content. The ‘style’ attribute is set to ‘dotted’, ‘featured_label’ is set to ‘special’, and ‘display_content’ is set to ‘full’.

[jetpack_nova_menu style=dotted featured_label=special display_content=full /]

3. Display a menu and include specific sections and labels. The ‘include_section’ and ‘include_label’ attributes are set with specific values.

[jetpack_nova_menu include_section=desserts,drinks include_label=vegan,gluten-free /]

4. Display a menu with a specific order and orderby parameters. The ‘order’ attribute is set to ‘desc’ and ‘orderby’ is set to ‘title’.

[jetpack_nova_menu order=desc orderby=title /]

These examples show how flexible the ‘jetpack_nova_menu’ shortcode is, allowing you to customize the menu display to fit your specific needs.

PHP Function Code

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

Shortcode line:

add_shortcode( 'jetpack_nova_menu', array( $this, 'nova_menu_shortcode' ) );

Shortcode PHP function:

function nova_menu_shortcode( $atts ) {
		// Default attributes
		$atts = shortcode_atts( array(
			'display_sections'   => false,
			'display_labels'    => true,
			'display_content' => true, // this can be either false, true for the_excerpt() or `full` for the_content()
			'link_items' => false,
			'featured_label' => 'featured', // we are going to use this label as a marker for highlighting certain menu items
			'style' => 'regular', // this can be `dotted` if that is what one fancies
			'include_section'    => false,
			'include_label'     => false,
			'showposts'       => -1,
			'order'           => 'asc',
			'orderby'         => 'date',
		), $atts, 'nova_menu' );

		// A little sanitization
		if ( $atts['display_sections'] && true != filter_var( $atts['display_sections'], FILTER_VALIDATE_BOOLEAN ) ) {
			$atts['display_sections'] = false;
		}

		if ( $atts['display_labels'] && true != filter_var( $atts['display_labels'], FILTER_VALIDATE_BOOLEAN ) ) {
			$atts['display_labels'] = false;
		}

		if ( $atts['display_content'] && true != filter_var( $atts['display_content'], FILTER_VALIDATE_BOOLEAN ) && 'full' != $atts['display_content'] ) {
			$atts['display_content'] = false;
		}

		if ( $atts['link_items'] && true != filter_var( $atts['link_items'], FILTER_VALIDATE_BOOLEAN ) ) {
			$atts['link_items'] = false;
		}

		if ( ! empty( $atts['featured_label'] ) ) {
			$atts['featured_label'] = explode( ',', str_replace( ' ', '', $atts['featured_label'] ) );
		} else {
			$atts['featured_label'] = false;
		}

		if ( $atts['style'] ) {
			$atts['style'] = trim( $atts['style'] );
		} else {
			$atts['style'] = 'regular';
		}

		if ( ! empty( $atts['include_section'] ) ) {
			$atts['include_section'] = explode( ',', str_replace( ' ', '', $atts['include_section'] ) );
		} else {
			$atts['include_section'] = false;
		}

		if ( ! empty( $atts['include_label'] ) ) {
			$atts['include_label'] = explode( ',', str_replace( ' ', '', $atts['include_label'] ) );
		} else {
			$atts['include_label'] = false;
		}

		$atts['showposts'] = intval( $atts['showposts'] );


		if ( $atts['order'] ) {
			$atts['order'] = urldecode( $atts['order'] );
			$atts['order'] = strtoupper( $atts['order'] );
			if ( 'DESC' != $atts['order'] ) {
				$atts['order'] = 'ASC';
			}
		}

		if ( $atts['orderby'] ) {
			$atts['orderby'] = urldecode( $atts['orderby'] );
			$atts['orderby'] = strtolower( $atts['orderby'] );
			$allowed_keys = array( 'date', 'title', 'rand' );

			$parsed = array();
			foreach ( explode( ',', $atts['orderby'] ) as $menu_item_index_number => $orderby ) {
				if ( ! in_array( $orderby, $allowed_keys ) ) {
					continue;
				}
				$parsed[] = $orderby;
			}

			if ( empty( $parsed ) ) {
				unset( $atts['orderby'] );
			} else {
				$atts['orderby'] = implode( ' ', $parsed );
			}
		}

		// If we don't need to display menu section titles then prevent them
		if ( false == $atts['display_sections'] ) {
			add_filter( 'jetpack_nova_menu_item_loop_open_element' , array( $this, 'menu_item_open_hidden' ), 10, 4 );
			add_filter( 'jetpack_nova_menu_item_loop_close_element' , array( $this, 'menu_item_close_hidden' ), 10, 4 );
		} else {
			// make sure that we wrap each section items in `<div class="menu-list__items">`
			add_filter( 'jetpack_nova_menu_item_loop_close_element' , array( $this, 'menu_item_close_wrap_section_items' ), 10, 4 );
		}

		// We need to make sure that we have the proper actions for each shortcode
		// Jetpack's Nova_Restaurant() class runs only once, so we have the action only for the first shortcode
		$instance = Nova_Restaurant::init( $this->menu_item_loop_markup );
		add_action( 'loop_start', array( $instance, 'start_menu_item_loop' ) );

		$output = $this->nova_menu_shortcode_html( $atts );

		// Remove the filters in case we've added them
		if ( false == $atts['display_sections'] ) {
			remove_filter( 'jetpack_nova_menu_item_loop_open_element' , array( $this, 'menu_item_open_hidden' ), 10 );
			remove_filter( 'jetpack_nova_menu_item_loop_close_element' , array( $this, 'menu_item_close_hidden' ), 10 );
		} else {
			remove_filter( 'jetpack_nova_menu_item_loop_close_element' , array( $this, 'menu_item_close_wrap_section_items' ), 10 );
		}

		return $output;
	}

Code file location:

pixelgrade-assistant/pixelgrade-assistant/includes/theme-helpers/nova-menu/class-nova-menu.php

Pixelgrade Assistant [pixassist_create_page_shortcode] Shortcode

The Pixelgrade Assistant shortcode is a versatile tool that generates a page title based on the specified ID. The shortcode extracts the ‘id’ attribute from the passed parameters. It then fetches the title of the corresponding page, effectively creating a dynamic reference to any page within the site.

Shortcode: [pixassist_create_page_shortcode]

Parameters

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

  • id – The unique identifier of a specific page
  • title – Displays the title of the specified page

Examples and Usage

Basic example – A simple usage of the shortcode to fetch and display the title of a specific page using its ID.

[page id=2 /]

Advanced examples

Using the shortcode to display the title of a specific page by referencing its ID. If the ‘title’ attribute is included, the shortcode will fetch and display the title of the page.

[page id=2 title /]

Another advanced usage of the shortcode is to display the title of the current page if no ID is specified. Adding ‘title’ or ‘Title’ in the attributes will fetch and display the title of the current page.

[page title /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'page', 'pixassist_create_page_shortcode' );

Shortcode PHP function:

function pixassist_create_page_shortcode( $atts ) {
	$output = '';

	// Attributes
	extract( shortcode_atts(
			array(
				'id' => '',
			), $atts )
	);

	$post = get_the_ID();

	if ( ! empty( $id ) && intval( $id ) ) {
		$post = intval( $id );
	}

	if ( in_array( 'title', $atts ) || in_array( 'Title', $atts ) ) {
		$output .= get_the_title( $post );
	}

	return $output;
}

Code file location:

pixelgrade-assistant/pixelgrade-assistant/includes/theme-helpers/shortcodes.php

Pixelgrade Assistant [ot_reservation_widget] Shortcode

The Pixelgrade Assistant shortcode, ‘ot_reservation_widget’, is designed to embed an OpenTable reservation widget on your website. The widget’s appearance can be customized as ‘standard’, ‘tall’, ‘wide’, or ‘button’. The shortcode checks for the embed code from the Customizer and extracts the necessary parameters. If the ‘type’ attribute is ‘button’, it adjusts the parameters accordingly. If no embed code is found, it prompts users to add it.

Shortcode: [ot_reservation_widget]

Parameters

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

  • type – Determines the style of the reservation widget, can be ‘standard’, ‘tall’, ‘wide’, or ‘button’.

Examples and Usage

Basic example – Utilizing the shortcode to display a standard OpenTable reservation widget.

[ot_reservation_widget type='standard']

Advanced examples

Using the shortcode to display a tall OpenTable reservation widget.

[ot_reservation_widget type='tall']

Using the shortcode to display a wide OpenTable reservation widget.

[ot_reservation_widget type='wide']

Using the shortcode to display an OpenTable reservation button.

[ot_reservation_widget type='button']

Note: The ‘type’ attribute can take four values: ‘standard’, ‘tall’, ‘wide’, or ‘button’. If an invalid value is provided, the shortcode will default to the ‘standard’ type. The ‘standard’, ‘tall’, and ‘wide’ types correspond to different themes of the OpenTable reservation widget, while the ‘button’ type displays a reservation button instead of a widget.

PHP Function Code

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

Shortcode line:

add_shortcode( 'ot_reservation_widget', 'pixelgrade_ot_reservation_widget_shortcode' );

Shortcode PHP function:

function pixelgrade_ot_reservation_widget_shortcode( $atts ) {
	// Default attributes
	$atts = shortcode_atts( array(
		'type'   => 'standard', // this can be 'standard', 'tall', 'wide' or 'button'
	), $atts, 'ot_reservation_widget' );

	// A little sanitization
	if ( $atts['type'] && ! in_array( $atts['type'], array( 'standard', 'tall', 'wide', 'button' ) ) ) {
		// in case of illegal value fallback to 'standard'
		$atts['type'] = 'standard';
	}

	// get the embed code from the Customizer
	$open_table_embed_code = pixelgrade_option( 'open_table_embed_code' );
	if ( ! empty( $open_table_embed_code ) ) {
		// we need to process it a bit - extract the parameters
		$params = Pixassist_Open_Table_Widget::extract_embed_params( $open_table_embed_code );

		if ( ! empty( $atts['type'] ) ) {
			// The button type is a little special - meaning is not a theme but an actual type, parameters wise
			if ( 'button' == $atts['type'] ) {
				$params['type'] = 'button';
				$params['theme'] = 'standard';
			} else {
				$params['theme'] = $atts['type'];
			}
		}

		// Now rebuild the parameters with out special alterations depending on widget options
		return '<script type="text/javascript" src="' . esc_attr( Pixassist_Open_Table_Widget::build_embed_url( $params ) ) . '"></script>';
	} else {
		return sprintf( __( '<p>You first need to copy&paste your EMBED code from <a href="%s">OpenTable Reservations</a> in <a href="%s">Appearance > Customize > General</a>.</p>', 'pixelgrade_assistant' ),
			'https://www.otrestaurant.com/marketing/ReservationWidget" target="_blank',
			esc_url( add_query_arg(
				array(
					array( 'autofocus' => array( 'section' => 'pixelgrade_options[general]' ) ),
					'return' => urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ),
				),
				admin_url( 'customize.php' )
			) )
		);
	}
}

Code file location:

pixelgrade-assistant/pixelgrade-assistant/includes/theme-helpers/theme-dependent.php

Conclusion

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