Created
June 30, 2022 10:50
-
-
Save Firsh/3195fa2e2878bcfb7fb38993cf195321 to your computer and use it in GitHub Desktop.
Filebird custom code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// FileBird Justified Gallery shortcode [filebird_justified_gallery folder="Folder name in FileBird"] | |
// integrates FileBird (https://wordpress.org/plugins/filebird/) and Justified Image Grid (https://justifiedgrid.com/) plugins | |
function filebird_justified_gallery_function( $atts ) { | |
$a = shortcode_atts( array( 'folder' => '', ), $atts ); | |
$foldername = esc_attr($a['folder']); | |
if ($foldername != '') { | |
global $wpdb; | |
$folderid = $wpdb->get_var($wpdb->prepare("SELECT id FROM {$wpdb->prefix}fbv WHERE name = %s", $foldername)); | |
if ($folderid != '') { | |
$images = $wpdb->get_col( $wpdb->prepare("SELECT attachment_id FROM {$wpdb->prefix}fbv_attachment_folder WHERE folder_id = %s", $folderid)); | |
$imageids = implode(', ' , $images); | |
return do_shortcode( '[justified_image_grid ids="'. $imageids . '"]' ); | |
} | |
else { | |
return '<p style="color:red;">FileBird Justified Gallery: Folder name not found.</p>'; | |
} | |
} | |
} | |
add_shortcode('filebird_justified_gallery', 'filebird_justified_gallery_function'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment