Download the PHP package badabingbreda/savvy-panel without Composer

On this page you can find all versions of the php package badabingbreda/savvy-panel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package savvy-panel

SavvyPanel

SavvyPanel is a helper library to create more compelling setttings dashboards using tabs, sections and controls.

Include the library by adding it via composer:

composer require badabingbreda/savvy-panel dev-main

It assumes a dashboard panel is added using a plugin, the constant SAVVYPANEL_URL will automatically be created if not defined early. Set this constant yourself to the right location if loading in another location.

Adding Dashboard

Make sure to autoload the vendor/autoload.php file after installing the composer packages.

<?php
class PluginDashboard {

    public function __construct() {

        add_action( 'init' , __CLASS__ . '::init' , 10 );
    }

    public static function init() {

        new \SavvyPanel\Dashboard( [ 
            'id' => 'beavercss',
            'menu_title' => 'Beaver CSS',
            'title' => 'Beaver CSS',
            'heading' => 'Beaver CSS Settings',
            'type' => 'menu',
        ] ); 

        /**
        * 
        * Viewport
        * 
        */
        new \SavvyPanel\Tab( [
            'id' => 'viewport',
            'dashboard' => 'beavercss',     // our dashboard id
            'title' => 'Main',              // comment out this key if you don't want the title rendered above the controls
            'menu_title' => 'Viewport',
            'menu_slug' => 'viewport',
            'priority' => 10,
        ]);

        new \SavvyPanel\Controls\ControlSection([
            'id' => 'breakpoints',
            'dashboard' => 'beavercss',
            'tab' => 'viewport',
            'label' => 'Breakpoints',
        ]);

        new \SavvyPanel\Controls\ControlText([
            'dashboard' => 'beavercss',
            'tab' => 'viewport',
            'section' => 'breakpoints',
            'id' => 'media-breakpoint-s',
            'label' => "Breakpoint Small",
            'suffix' => "px",
            'value' => \get_option( 'media-breakpoint-s' , 640 ),
        ]);

    }
}

new PluginDashboard();

Sending updated settings

You can hook into the Savvy Panel update action by adding javascript that loads in the header, like so:

<?php
class ScriptStyle {

    public function __construct() {
        add_action( 'admin_enqueue_scripts' , __CLASS__ . '::admin_files' , 10 , 1 );
    }

    public static function admin_files() {
        wp_enqueue_script( 'savvypanel-handler', plugin_url( '/' , __FILE__ ) . 'js/savvy-panel.js', null, '1.0.0', false );
    }
}

new ScriptStyle();

You could add additional checks to your loading strategy to make sure they are loading on the admin and page only.

In your savvy-panel.js file, add your callback for the savvy hooks, like so:

document.savvyPanelActions = [
    { 
        hook : 'savvyUpdate',
        priority : 10,
        callback: ( savvy ) => {

            savvy.sending = true;

            const settings = savvy.collectSettings();

            // use fetch
            fetch( SAVVYPANEL_LOCAL.admin_ajax_url + `?action=savvypanel_update`,
            {
                method: 'POST',
                headers: { 
                    'Accept' : 'application/json',
                    'Content-Type': 'application/json',
                    'X-WP-Nonce': SAVVYPANEL_LOCAL._wpnonce,
                },
                body: savvy.asFormData( settings ),
            } )
            .then( ( response ) => response.json() )
            .then( ( data ) => {
                    savvy.sending = false;
                    data.notifications.forEach( (noti, index) => {
                        setTimeout( () => { notis.create( { title : noti.title , description : noti.description , duration: 5 ,  status: noti.status, destroyOnClick: true } ); } , index * 300 );
                    });
            })
            .catch( (error) => {
                savvy.sending = false;
                console.log( 'I messed up ' , error );
            } );
        }
    }
];

In this example, the callback will be triggered when the "Save Changes" button is clicked on the panel. The savvy variable is the instance of the Savvy Panel that exists in your browser and can be used for collecting the Settings across all tabs and formatting them as form data. Also note that you can use the SAVVYPANEL_LOCAL variable, which is used to localize the savvy script with the admin-ajax.php url and a server generated nonce.

In this callback, the action savvypanel_update is used and this is something you will need to register yourself within your plugin, using

add_action( 'wp_ajax_savvypanel_update' , 'your_custom_callback' , 10 , 1 );

In there, make sure to check the nonce before anything else:

function your_custom_callback() {

    if ( !wp_verify_nonce( $_SERVER[ 'HTTP_X_WP_NONCE' ] , 'savvypanel_update_settings' ) ) {
        return wp_encode_json( [ 
            'success' => false, 
            'notifications' => [
                [ 
                    'status' => 'error',
                    'title' => 'Nonce Failed',
                    'description' => 'Unable to verify nonce or failed.',
                ]
            ],
        ] );
        wp_die();
    }

    //
    // rest of your code
    //

    return wp_encode_json( [ 
        'success' => true, 
        'notifications' => [
                [ 
                    'status' => 'success',
                    'title' => 'Well done!',
                    'description' => 'Settings have been updated. Feel free to make some more!',
                ]
        ],
    ] );

    wp_die();
}

filters

You can use filter hooks to disable enqueueing of the default notofications and/or dashboard css:

add_filter( 'savvypanel/css/notifications' , '__return_false' );
add_filter( 'savvypanel/css/dashboard' , '__return_false' );

You can use the scss files located in the package to generate your own using a preprocessor of choice.


All versions of savvy-panel with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package badabingbreda/savvy-panel contains the following files

Loading the files please wait ....