Filters
Our WP Cloud Plugins include a set of WordPress Filters designed to modify data before it is displayed or saved. Filters allow you to intercept and change plugin outputs or values, offering a flexible way to customize functionality. With these filters, you can adjust settings, content, or behavior in a seamless and efficient manner.
Slugs
The plugin provides several WordPress actions to hook into its functionality. These actions use a {slug}
placeholder, which you should replace with the slug corresponding to your plugin variant:
shareonedrive
for Share-One-Drive (OneDrive & SharePoint)useyourdrive
for Use-your-Drive (Google Drive)outofthebox
for Out-of-the-Box (Dropbox)letsbox
for Lets-Box (Box)
For example, the action {slug}_render_formfield_data()
, which is applied when rendering a form submission in a form plugin entries overview, would be useyourdrive_after_module
for Use-your-Drive.
All examples below use useyourdrive as slug. Make sure you update this for the plugin you are using.
Available filters
{slug}_render_formfield_data()
Fires after a module module has been rendered.
add_filter('useyourdrive_render_formfield_data', 'render_formfield_data', 10);
function render_formfield_data($data, $ashtml = true){
// Read the array of files stored in the submission
$uploaded_files = json_decode($data, true);
// Continue if we aren't receiving any files
if (empty($uploaded_files) || (0 === count($uploaded_files))) {
return $data;
}
// Render a very basic list
$formated_value = '';
foreach ($uploaded_files as $file) {
$formated_value .= basename($file['path'])." ({$file['size']})\r\n";
}
return $formated_value;
}
{slug}_apply_placeholders()
Replaces placeholders with values. You can add your own custom placeholders.
add_filter('useyourdrive_apply_placeholders', 'custom_placeholder', 10, 3);
function custom_placeholder($string_with_placeholders, $context = null, $extra = [])
{
// $extra['user_data'] contains current WP_User object if available
// Set placeholders
$placeholders = [
'%my_custom_placeholder%' => 'My Value',
'%another_placeholder%' => 'Another Value',
];
return strtr($string_with_placeholders, $placeholders);
}
{slug}_is_entry_authorized()
Check to see if an item has the correct permissions to be displayed in the front end.
add_filter('useyourdrive_is_entry_authorized', 'custom_placeholder', 10, 3);
function is_entry_authorized($is_authorized, $node)
{
$entry = $node->get_entry();
// Skip entry if its a dir or has the PHP extension
if ($node->is_dir() || 'php' === $entry->get_extension()) {
return false;
}
return $is_authorized;
}
Last updated