Drive Hooks

Google Drive Embedder hooks


Filter: gde_gather_custom_properties

Available in Google Drive Embedder Enterprise plugin only.
The Drive Enterprise plugin applies this filter to allow your extension to add custom properties to Google Drive folders and files that you associate with your WordPress site.
For example, you could mark all auto-created folders with a special tag that you can use in Drive search calls elsewhere.

Params:

$custom_properties – Array of properties to add to file/folder, from other plugins, or null if none added yet.
$type – A string (either ‘root’, ‘post’, or ‘blog’) indicating where the folder/file is being embedded in your site. ‘root’ means the base folder is being created in the Settings page (this is a one-off); ‘blog’ means a multisite sub-blog is having its top-level folder created within your base folder hierarchy; ‘post’ means a folder/file is being attached to a post (or page etc) in your site.
$id – The blog_id or post_id of the relevant sub-blog (multisite only) or post. This parameter is null if $type equals ‘root’.

Return:

Array of properties to add to file/folder, adding your own properties, or null if no properties are to be added.

Each custom property is an associative array containing the keys: ‘key’, ‘value’, and (optionally) ‘visibility’. These correspond to the values required by the Drive API. Visibility defaults to PUBLIC, not PRIVATE.

Example:

function my_gde_gather_custom_properties($custom_properties, $type, $id) {
   return array_merge(is_null($custom_properties) ? array() : $custom_properties,
                   Array( 
                      Array('key' => 'intranetfile', 'value' => $type, 'visibility' => 'PRIVATE') 
                   ) );
   }

add_filter('gde_gather_custom_properties', 'my_gde_gather_custom_properties', 10, 3 );

Hook: gde_after_do_create_folder (Enterprise only)

Available in Google Drive Embedder Enterprise plugin only.
The Drive Enterprise plugin fires this hook after an attachments folder is auto-created.

Params:

$id – the newly created Google Drive folder ID
$driveservice – an object for calling Drive API
$parent_folderid – Drive folder ID of the parent folder it was created within
$post_name – Name of the post/page of which the folder is an attachment (this name will also be the name of the folder in Drive)
$owner_email – User who should own the folder
$writer_email – Users who should have edit rights
$custom_properties – meta properties assigned to the Drive folder

See core/folders/drive_helper.php to further understand the context in which the hook is fired.


Hook: gde_attachment_folder_atts (Enterprise v3.8.6+ only)

Available in Google Drive Embedder Enterprise plugin only.

A filter to obtain the equivalent of folder shortcode parameters for an Attachment Folder.

Params:

$folderparams – PHP Array containing key/value pairs of the default shortcode params. You can add or modify entries before returning this array.

Return:

Array of shortcode params – $folderparams as provided as an input.

Example:

Change the columns that are displayed – removes author column compared to the default columns that you’d see without this filter:

function my_gde_attachment_folder_atts ($folderparams) {
   $folderparams['columns'] = 'title,lastmodified,size';
   return $folderparams;
}

add_filter('gde_attachment_folder_atts', 'my_gde_attachment_folder_atts', 10, 1);

Hook: gde_shortcode_folder_atts (Enterprise v3.9.4+ only)

Available in Google Drive Embedder Enterprise plugin only.

A filter to obtain the equivalent of folder shortcode parameters for a folder shortcode. This works identically to the equivalent filter for attachment folders (gde_attachment_folder_atts), but applies instead to explicit google-drive-folder shortcodes.

Params:

$folderparams – PHP Array containing key/value pairs of the default shortcode params. You can add or modify entries before returning this array.

Return:

Array of shortcode params – $folderparams as provided as an input.

Example:

Regardless of the columns parameter that the page author might have added to the shortcode, ensure that every embedded folder only displays the title column. Apply this to attachment folders too using the gde_attachment_folder_atts filter:

function my_gde_folder_atts ($folderparams) {
   $folderparams['columns'] = 'title';
   return $folderparams;
} 
add_filter('gde_attachment_folder_atts', 'my_gde_folder_atts', 10, 1);
add_filter('gde_shortcode_folder_atts', 'my_gde_folder_atts', 10, 1);

Hook: gde_toplevel_foldername_for_post (Enterprise v3.9.5+ only)

Available in Google Drive Embedder Enterprise plugin only.

A filter to insert extra top-level folders so you can better organize Attachment Folders within your base folder. This will only be called the first time the Attachment Folder is created for a particular post (or page or custom type). It will only be called again if the folder is ever recreated, e.g. if you switch to a different base folder in the plugin settings.

Params:

$foldername – The default suggested top-level folder.
$post – The WP_Post object of the post that is to have its corresponding Attachment Folder created.

Return:

String containing the suggested folder name – just return $foldername to avoid inserting an extra level of folder within the hierarchy.

Example:

To insert an extra ‘Articles’ folder to contain all custom posts if type ‘article’:

function my_gde_toplevel_foldername_for_post($foldername, $post) {
   if (isset($post->post_type) && $post->post_type == 'article') {
      return 'Articles';
   }
   return $foldername;
}

add_filter('gde_toplevel_foldername_for_post', 'my_gde_toplevel_foldername_for_post', 10, 2);

Folder Javascript Hooks

Enterprise-style folder embeds also fire some Javascript events when certain things happen. See Folder JS Hooks.

Google Apps Login is trusted by thousands of organizations from small businesses to NASDAQ-listed companies and government organizations.
Users click their way through Login via Google (just one click after the first time)

Users click their way through Login via Google (just one click after the first time)

You can try it out by clicking below to auto-create a test account on this site! This will show you the basic Google login process.
Try out Google login
 

Logging in is only the start – Google Apps Login takes care of all your WordPress user management. Find out more here.

[user_show_avatar]

See [user_first_name] – that was easy!

Your account has been created, and you are now logged in. On your own site, you will specify your Google Apps domain – e.g. mycompany.com – and only users on that domain will be allowed to auto-create accounts.
Logging in is only the start – Google Apps Login takes care of all your WordPress user management.
Find out more

×