• Thanks for the great plugin!!

    How can I add these Filebird functions to the WP functions.php file to apply sitewide changes?

    Get Folder Detail
    use FileBird\Model\Folder as FolderModel;
    FolderModel::findById( $folder_id, 'id, name, parent' );
    
    Get Folders
    use FileBird\Classes\Tree;
    Tree::getFolders( null );
    
    Create New Folder
    use FileBird\Model\Folder as FolderModel;
    FolderModel::newOrGet( $name, $parent_id );
    
    Get Attachment Ids by Folder Id
    use FileBird\Classes\Helpers as Helpers;
    Helpers::getAttachmentIdsByFolderId( $folder_id );
    
    Add attachment(s) to folder
    use FileBird\Model\Folder as FolderModel;
    FolderModel::setFoldersForPosts( $ids, $folder );

    Enclosing them within a function results in “syntax error, unexpected ‘use’ (T_USE)” but putting them outside the function and attempting to use global throws no errors, but no results either.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Support Bruce

    (@ninjateamwp)

    Hi @zoinks ,

    Thanks for writing to us today!

    Please allow me to check this with the developers unit and get back to you as soon as possible.

    Kind regards,
    -Bruce-

    Hi @zoinks,

    You can move “use” on the top of the code like the image below:
    https://screenrec.com/share/6kURWm1iQV

    Please let me know if it works.

    Cheers,
    -Rose-

    Thread Starter Zoinks! Graphics

    (@zoinks)

    Thank you for the response!

    As instructed, in functions.php I replaced…

    <?php
    if(!defined('ABSPATH')) exit;

    …with…

    <?php
    namespace FileBird\Controller;
    use FileBird\Model\Folder as FolderModel;
    use FileBird\Classes\Helpers as Helpers;
    use FileBird\Classes\Tree;
    
    if(!defined('ABSPATH')) exit;

    Instead of working, however, that made my site only show the header and footer. Any other ideas?

    Thread Starter Zoinks! Graphics

    (@zoinks)

    Interestingly, including the following code anywhere in the header.php file works. But I’d much rather have it in the functions.php if at all possible!

    use FileBird\Classes\Helpers as Helpers;
    $ids = Helpers::getAttachmentIdsByFolderId(2);
    
    define('FILEBIRD_PIC', $ids[0]);
    Plugin Support Bruce

    (@ninjateamwp)

    Hi @zoinks ,

    Glad to know that you got a way around it now ??
    I will also get this to our developers for their opinion in addition.

    Kind regards,
    -Bruce-

    Thread Starter Zoinks! Graphics

    (@zoinks)

    Thanks! Looking forward to hearing back.

    Including the code in header.php is a temporary solution. I’d much prefer to have all my customizations in functions.php

    Hi there,
    Thanks for your patience.

    You can put the code below at the end of the file functions.php if you want to have all customizations.

    use FileBird\Classes\Helpers as Helpers;
    $ids = Helpers::getAttachmentIdsByFolderId(2);
    
    define('FILEBIRD_PIC', $ids[0]);

    Here is the screenshot: https://screenrec.com/share/Uk8EXDAiP4
    Please let me know if it works for you.

    Cheers,
    Rose

    • This reply was modified 2 years, 5 months ago by Rose.
    Thread Starter Zoinks! Graphics

    (@zoinks)

    Awesome, that did it! Thanks!!

    Hi @zoinks,

    Thank you so much for choosing our plugin. If it’s possible, can you leave a review for the plugin? https://www.ads-software.com/plugins/filebird/#reviews
    Your review will motivate us to develop more works and have awesome customers like you.

    Cheers,
    Rose

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Filebird functions into WP functions.php ?’ is closed to new replies.