Gs Logo Slider Shortcodes

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

Before starting, here is an overview of the Gs Logo Slider Plugin and the shortcodes it provides:

Plugin Icon
Logo Slider – Logo Showcase, Logo Carousel, Logo Gallery and Client Logo Presentation

"Logo Slider – Logo Showcase, Logo Carousel, Logo Gallery and Client Logo Presentation is a versatile WordPress plugin. It offers dynamic features for displaying your business logos in an interactive slider, carousel, or gallery format."

★★★★☆ (195) Active Installs: 20000+ Tested with: 6.3.2 PHP Version: 5.6
Included Shortcodes:
  • [gs_logo]
  • [gs_logo]

Gs Logo Slider [gs_logo] Shortcode

The gs-logo-slider plugin shortcode is primarily used to display company logos in a slider format on a WordPress site. It allows for customization of the title, mode, speed, loop, color, theme, and tooltip. The shortcode function ‘gs_logo_shortcode’ takes in attributes, changes keys for better readability, and sets up a query for the logos. It then generates a unique ID for each logo slider and includes the correct theme template based on the attributes provided. The shortcode ends by returning the HTML for the logo slider, ready to be inserted into a WordPress post or page.

Shortcode: [gs_logo]

Parameters

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

  • title – The title of the logo slider.
  • mode – The display mode of the logo slider.
  • speed – The transition speed of the logo slider.
  • inf_loop – To enable or disable infinite looping of logos.
  • logo_color – The color effect of the logos.
  • theme – The theme of the logo slider.
  • tooltip – To enable or disable tooltips on logos.
  • order – The order of the logos to be displayed.
  • orderby – The parameter by which the logos are sorted.
  • posts – The number of logos to be displayed.
  • logo_cat – The category of logos to be displayed.
  • id – The unique identifier of the logo slider.

Examples and Usage

Basic Example – Displays logos from all categories using the default settings.

[gs_logo /]

Advanced Examples

Displays logos from a specific category ‘tech’ with a slider theme and infinite loop.

[gs_logo logo_cat='tech' theme='slider1' inf_loop='yes' /]

Displays logos in a grid format, from multiple categories ‘tech’ and ‘startups’, with a slide speed of 500 ms.

[gs_logo logo_cat='tech,startups' theme='grid1' speed='500' /]

Displays logos in a list format, with tooltips enabled and logos displayed in grayscale.

[gs_logo theme='list1' tooltip='yes' logo_color='gray' /]

These examples demonstrate the flexibility of the gs-logo-slider plugin shortcode. By changing the attributes, you can customize the display of logos to suit your website’s design and your specific needs.

PHP Function Code

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

Shortcode line:

add_shortcode( 'gs_logo', 'gs_logo_shortcode' );

Shortcode PHP function:

function gs_logo_shortcode( $atts ) {
	
	$atts = shortcode_atts( gs_logo_get_shortcode_defaults(), $atts );

    $atts = gslogo_change_key( $atts, 'gs_l_title', 'title' );
    $atts = gslogo_change_key( $atts, 'gs_l_mode', 'mode' );
    $atts = gslogo_change_key( $atts, 'gs_l_slide_speed', 'speed' );
    $atts = gslogo_change_key( $atts, 'gs_l_inf_loop', 'inf_loop' );
    $atts = gslogo_change_key( $atts, 'gs_l_gray', 'logo_color' );
    $atts = gslogo_change_key( $atts, 'gs_l_theme', 'theme' );
    $atts = gslogo_change_key( $atts, 'gs_l_tooltip', 'tooltip' );

	extract( $atts );

	$args = [
		'order'				=> $order,
		'orderby'			=> $orderby,
		'posts_per_page'	=> $posts,
	];

	if ( !empty($logo_cat) ) {

		$args['tax_query'] = [
			[
				'taxonomy' => 'logo-category',
				'field'    => 'slug',
				'terms'    => explode(',', $logo_cat),
				'operator' => 'IN'
			],
		];

	}

	$GLOBALS['gs_logo_loop'] = get_gs_logo_query( $args );

	$id = empty($id) ? uniqid() : sanitize_key( $id );

	if ( $theme == '2rows' ) $theme = 'slider-2rows';
	
	$classes = [
		"gs_logo_area",
		"gs_logo_area_$id",
		$theme
	];

	ob_start();
	?>

	<div class="<?php echo implode( ' ', $classes ); ?>" style="opacity: 0; visibility: hidden;">
		<div class="gs_logo_area--inner">

			<?php
				do_action( 'gs_logo_template_before__loaded', $theme );

				if ( $theme == 'slider1' ) {
					include GS_Logo_Template_Loader::locate_template( 'gs-logo-theme-slider-1.php' );
				} else if ( $theme == 'grid1' ) {
					include GS_Logo_Template_Loader::locate_template( 'gs-logo-theme-grid-1.php' );
				} else if ( $theme == 'list1' ) {
					include GS_Logo_Template_Loader::locate_template( 'gs-logo-theme-list-1.php' );
				} else if ( $theme == 'table1' ) {
					include GS_Logo_Template_Loader::locate_template( 'gs-logo-theme-table-1.php' );
				} else if ( !gs_logo_is_pro_active() ) {
					printf('<div class="gs-logo-template-upgrade"><p>%s</p></div>', __('Please upgrade to pro version to use this template', 'gslogo'));
				}

				do_action( 'gs_logo_template_after__loaded', $theme,  $atts );
				
				wp_reset_postdata();
			?>
		</div>
	</div>

	<?php
	return ob_get_clean();
}

Code file location:

gs-logo-slider/gs-logo-slider/includes/gs-logo-shortcode.php

Gs Logo Slider [gs_logo] Shortcode

The gs-logo-slider plugin shortcode is responsible for generating and displaying a logo slider on a webpage. It checks for shortcode ID, and if not found, it returns an error message. It also handles preview mode. The shortcode fetches the settings for the logo slider based on the ID and preview mode. If no settings found, it returns an empty string. The shortcode also determines whether to force load assets or not. It checks for image size and if set to ‘custom’, it validates the custom image size parameters. If any parameter is missing, it sets the image size to ‘full’. Finally, it generates the logo slider, enqueues necessary assets, triggers script reprocessing, and generates custom CSS if necessary. It then frees up the memory and returns the output.

Shortcode: [gs_logo]

Parameters

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

  • id – Unique identifier for the gs-logo-slider shortcode
  • preview – Displays a preview of the gs-logo-slider when set
  • image_size – Defines the size of the logo image
  • custom_image_size_width – Sets a custom width for the logo image
  • custom_image_size_crop – Decides whether to crop the logo image to the custom width

Examples and Usage

Basic example – Display a logo slider by referencing the slider ID.

[gslogo id=1 /]

Advanced examples

Display a logo slider with ID and enable preview mode. Preview mode allows you to see the changes instantly without saving them.

[gslogo id=1 preview=true /]

Display a logo slider with custom image size. You must specify the width, height, and crop parameters for the custom image size to take effect.

[gslogo id=1 image_size=custom custom_image_size_width=200 custom_image_size_height=100 custom_image_size_crop=true /]

Display a logo slider and force the asset loading. This can be useful when you want to make sure that the necessary scripts and styles are loaded for the slider, regardless of the page’s asset handling.

[gslogo id=1 force_asset_load=true /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'gslogo', 'register_gslogo_shortcode_builder' );

Shortcode PHP function:

function register_gslogo_shortcode_builder( $atts ) {

    if ( empty($atts['id']) ) {
        return __( 'No shortcode ID found', 'gslogo' );
    }

    $is_preview = ! empty($atts['preview']);

    $settings = gslogo_get_temp_settings( $atts['id'], $is_preview );

    if ( empty($settings) ) return '';

    $settings['id'] = $atts['id'];
    $settings['is_preview'] = $is_preview;

    // Cache the $settings from being changed
    $_settings = $settings;

    // By default force mode
    $force_asset_load = true;

    if ( ! $is_preview && ! gs_logo_should_custom_script_render() ) {
    
        // For Asset Generator
        $main_post_id = gsLogoAssetGenerator()->get_current_page_id();

        $asset_data = gsLogoAssetGenerator()->get_assets_data( $main_post_id );

        if ( empty($asset_data) ) {
            // Saved assets not found
            // Force load the assets for first time load
            // Generate the assets for later use
            gsLogoAssetGenerator()->generate( $main_post_id, $_settings );
        } else {
            // Saved assets found
            // Stop force loading the assets
            // Leave the job for Asset Loader
            $force_asset_load = false;
        }

    }

    if ( isset($settings['image_size']) && $settings['image_size'] == 'custom' ) {

        if ( empty( $settings['custom_image_size_width'] ) || empty( $settings['custom_image_size_width'] ) || empty( $settings['custom_image_size_crop'] ) ) {
            $settings['image_size'] = 'full';
        }

    }

    $shortcode_params = gslogo_get_shortcode_params( $settings );

    ob_start();
    
    echo do_shortcode("[gs_logo $shortcode_params]");

	if ( gs_logo_should_custom_script_render() || $force_asset_load ) {

        gsLogoAssetGenerator()->force_enqueue_assets( $_settings );

        wp_add_inline_script( 'gs-logo-public', "jQuery(document).trigger( 'gslogo:scripts:reprocess' );jQuery(function() { jQuery(document).trigger( 'gslogo:scripts:reprocess' ) })" );

		$css = gsLogoAssetGenerator()->generateCustomCss( $_settings, $_settings['id'], gs_logo_is_pro_active() );
		
		if ( !empty($css) ) {
			$css = gs_logo_minimizeCSSsimple($css);
			echo "<style>".$css."</style>";
		}

	}

    $settings = $_settings = null; // Free up the memory

    return ob_get_clean();

}

Code file location:

gs-logo-slider/gs-logo-slider/includes/shortcode-builder/gs-logo-shortcode-builder-shortcode.php

Conclusion

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