Integrate Google Drive Shortcode

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

Before starting, here is an overview of the Integrate Google Drive Plugin and the shortcodes it provides:

Plugin Icon
Integrate Google Drive – Browse, Upload, Download, Embed, Play, Share, Gallery, and Manage Your Google Drive Files Into Your WordPress Site

"Integrate Google Drive is a WordPress plugin that seamlessly blends Google Drive with your site. Upload, download, embed, play, share, create galleries, and manage Drive files all within WordPress."

★★★★☆ (70) Active Installs: 4000+ Tested with: 6.3.2 PHP Version: 7.0
Included Shortcodes:
  • [integrate_google_drive]

Integrate Google Drive [integrate_google_drive] Shortcode

The Integrate Google Drive shortcode facilitates the display of Google Drive content on WordPress. The shortcode fetches data based on attributes and checks its status. If the status is active, it enqueues a stylesheet. It also verifies user access and displays an ‘Access Denied’ message for unauthorized users. The shortcode enqueues scripts, verifies file action permissions, sets filters and notifications, processes files, and sets up the account. Finally, it generates HTML output to display the content.

Shortcode: [integrate_google_drive]

Examples and Usage

Basic Example – Embed Google Drive content on your page using the ‘integrate_google_drive’ shortcode. This basic usage will render the content based on the default settings defined in the plugin.

[integrate_google_drive /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'integrate_google_drive', [ $this, 'render_shortcode' ] );

Shortcode PHP function:

function render_shortcode( $atts = array(), $data = null )
    {
        $this->fetch_data( $atts, $data );
        // If the shortcode is not found, return nothing
        if ( empty($this->data) ) {
            return;
        }
        if ( $this->check_status() ) {
            return;
        }
        wp_enqueue_style( 'igd-frontend' );
        
        if ( !$this->check_should_show() || !$this->check_use_private_folders() ) {
            $default_message = '<img width="100" src="' . IGD_ASSETS . '/images/access-denied.png" ><h3 class="placeholder-title">' . __( 'Access Denied', 'integrate-google-drive' ) . '</h3><p class="placeholder-description">' . __( "We're sorry, but your account does not currently have access to this content. To gain access, please contact the site administrator who can assist in linking your account to the appropriate content. Thank you.", 'integrate-google-drive' ) . '</p>';
            $access_denied_message = ( !empty($this->data['accessDeniedMessage']) ? $this->data['accessDeniedMessage'] : $default_message );
            return ( !empty($this->data['showAccessDeniedMessage']) ? sprintf( '<div class="igd-access-denied-placeholder">%s</div>', $access_denied_message ) : false );
        }
        
        $this->enqueue_scripts();
        $this->check_file_actions_permissions();
        $this->get_initial_search_term();
        $this->set_filters();
        $this->set_notifications();
        $this->process_files();
        $this->set_account();
        return $this->generate_html();
    }

Code file location:

integrate-google-drive/integrate-google-drive/includes/class-shortcode.php

Conclusion

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