PHP code example of geistpress / wp-helpers

1. Go to this page and download the library: Download geistpress/wp-helpers library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

geistpress / wp-helpers example snippets


// Init WP-Helpers
add_action('init', function () {
    // Init Loader
    $loader = new \GeistPress\Helpers\Foundation\Loader();

    // Register all class in sidebars directory with the App\Sidebars namespace
    $loader->register(__DIR__ . '/resources/sidebars', 'App\Sidebars'); 

    // Register only the Bar class and return its instance
    $foobar = $loader->register(\Foo\Bar::class); 

    // Init Views
    \GeistPress\Helpers\Facades\View::init(__DIR__ . '/resources/views/');
});

namespace App\Sidebars;

use GeistPress\Helpers\Foundation\Registerable;

class HeaderBar implements Registerable
{
    /**
     * Register sidebar
     */
    public function register()
    {
        register_sidebar([
            'name'          => __('Header Bar', 'app'),
            'id'            => 'header-bar',
            'description'   => __('Top Bar above the navbar', 'app'),
            'before_widget' => '<div id="%1$s" class="widget %2$s">',
            'after_widget'  => '</div>',
        ]);
    }
}


// Render /resources/views/breadcrumbs.phtml and pass the variable $current='home' to it
\GeistPress\Helpers\Facades\View::render('breadcrumbs', ['current' => 'home']);