Custom Fields
Re-Envisioned
Support MB Settings Page Backup & Restore not working with Composer loading

  • Creator
    Topic
  • #19510
    Resolved Joe Anderson
    Participant

    I’m using loading meta box and all extensions through composer for my plugin. I am currently trying to setup the Backup & Restore field type but it doesn’t seem to work when using composer. I tested this feature by installing/activating the all in one plugin, enabling the Settings extension and then the textarea seemed to show up correctly… Though, it still didn’t contain json of my saved settings. Is this feature fully functional yet?

    Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Author
    Replies
  • #19525
    Long Nguyen
    Moderator

    Hi Joe,

    Could you please share the code to create the Settings page and Backup & Restore field type? I will take a closer look and check it on my end.

    #19530
    Joe Anderson
    Participant

    For sure. The code is below. I have removed other tabs for simplicity. Thanks for the help!

    https://pastebin.com/4UnBqKfv

    /**
     * Register settings pages
     *
     * @since    3.0
     * @access   public
     * @var      array $settings_pages    
    */
    function ditty_settings_pages() {
      $settings_pages[] = array(
        'id'          => 'ditty_settings',
        'option_name' => 'ditty_settings',
        'menu_title'  => __( 'Settings', 'ditty-news-ticker' ),
        'capability'  => 'manage_ditty_settings',
        'parent'          => 'edit.php?post_type=ditty_ticker',
        'style'       => 'no-boxes',
        'columns'     => 2,
        'tabs'        => array(
          'backup'  => __( 'Backup & Restore', 'ditty-news-ticker' ),
        ),
      );
      return $settings_pages;
    }
    add_filter( 'mb_settings_pages', 'ditty_settings_pages' );
    
    /**
     * Register settings metaboxes
     *
     * @since    3.0
     * @access   public
     * @var      array $meta_boxes    
    */
    function ditty_settings_metaboxes( $meta_boxes ) {
        $meta_boxes[] = array(
          'id'             => 'backup',
          'title'          => __( 'Backup & Restore', 'ditty-news-ticker' ),
          'settings_pages' => 'ditty_settings',
          'tab'            => 'backup',
          'fields'         => array(
              array(
                  'name' => __( 'Backup & Restore', 'ditty-news-ticker' ),
                'type' => 'backup',
              ),
          ),
        );
        return $meta_boxes;
    }
    add_filter( 'rwmb_meta_boxes', 'ditty_settings_metaboxes' );
    #19538
    Long Nguyen
    Moderator

    Hi,

    I’m using the sample code from the documentation

    'fields' => array(
        array(
            'name' => 'Logo',
            'id'   => 'logo',
            'type' => 'file_input',
        ),
        array(
            'name'    => 'Layout',
            'id'      => 'layout',
            'type'    => 'image_select',
            'options' => array(
                'sidebar-left'  => 'https://i.imgur.com/Y2sxQ2R.png',
                'sidebar-right' => 'https://i.imgur.com/h7ONxhz.png',
                'no-sidebar'    => 'https://i.imgur.com/m7oQKvk.png',
            ),
        ),
        array(
            'name' => __( 'Backup & Restore', 'ditty-news-ticker' ),
            'type' => 'backup',
        ),
    ),

    and the field type backup works as well, see my screen record https://cl.ly/303ff96d3190.

    Could you please try to clear the cache and check this field again?

    #19541
    Joe Anderson
    Participant

    Are you loading metabox and the settings extension through composer? I am able to get it working when loading metabox through the standalone plugins or the AIO plugin. But, when I switch to just using composer (with latest available files) it still doesn’t work. See screenshots.

    Using Plugins

    Using Composer

    #19552
    Anh Tran
    Keymaster

    Hi Joe,

    I’ve just set up a simple test plugin with nothing than just Meta Box + MB Settings Page and I see the backup & restore field works properly. Please see my video for details:

    https://www.loom.com/share/e4c5122a25fd47ad8f6a364bbac779f0

    #19561
    Joe Anderson
    Participant

    Thanks for looking into this. I’m not seeing any difference between my setup and what you are showing, but it still doesn’t seem to work. Can you take a look at my video and let me know if you see anything wrong with my process? (I have a license code, but cleared it out for the video)

    https://www.loom.com/share/d6ee367f782f4d259137643177156b49

    Thanks!

    #19579
    Anh Tran
    Keymaster

    Strange, I see it’s similar to my setup. I can think only about the downloaded version via Composer. Can you check the files in the vendor folder to see if they’re the same as in the individual plugin?

    #19587
    Joe Anderson
    Participant

    It seems my composer package was loading version 1.3.4 of the settings page, as opposed to version 2.1.0 of the single plugin… I’m not sure why.

    I had run composer update, but for some reason the packages weren’t updating. I trashed all the packages and re-ran composer update to install them all fresh again and now have the latest versions.

    All seems to be working fine now. Thanks again for the support!

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.