Daniele Scasciafratte
#oscal

WordPress Plugin Boilerplate Powered 3.2

Created by Daniele Scasciafratte / Mte90Net

Daniele Scasciafratte

  • Co Founder/CTO Codeat
  • Italian Linux Society Council member
  • LUG Rieti founder
  • WordPress Core Contributor/Developer
  • WordPress Rome/Terni meetup
  • Mozillian & Mozilla Reps & Mozilla Italia
  • Open Source Addicted

WPBP is

  • a Framework-Free solution
  • boilerplate plugin with examples
  • snippets
  • many libraries available
  • Codeception, GrumPHP, PHPStan
  • SASS support
  • WordPress compliant at 100%

WPBP Original Modules:

The modules are indipendent each other with a specific things in mind.
  • Be simple
  • By parameters
  • Examples included
  • Easy API
  • Be simple again

WPBP/PointerPlus

WPBP/CronPlus:

$args = array(
    // hourly,daily,twicedaily,weekly,monthly or timestamp for single event
    'recurrence' => 'hourly',
    // schedule (specific interval) or single (at the time specified)
    'schedule' => 'schedule',
    // Name of the Cron job used internally
    'name' => 'cronplusexample',
    // Callback to execute when the cron job is launched
    'cb' => 'cronplus_example',
    // Args passed to the hook executed during the cron
    'args' => array( get_the_ID() )
);

function cronplus_example( $id ) {
	echo $id;
}

$cronplus = new CronPlus( $args );
// Schedule the event
$cronplus->schedule_event();
// Remove the event by the schedule
$cronplus->clear_schedule();
// Jump the scheduled event
$cronplus->unschedule_event();
						

WPBP/Widgets-Helper

A class that extends the built-in WP_Widget class to provide an easier/faster way to create Widgets for WordPress.

WPBP/FakePage

new Fake_Page(
	array(
    'slug' => 'fake_slug',
    'post_title' => 'Fake Page Title',
    'post_content' => 'This is the fake page content'
	)
);.

WPBP/Template

// This is like the woocommerce function
function load_content_demo( $original_template ) {
        if ( is_singular( 'demo' ) && in_the_loop() ) {
            return wpbp_get_template_part( 'plugin-name-folder', 'content',
					'demo', false );
        } else {
            return $original_template;
        }
}
add_filter( 'template_include', 'load_content_demo' );

// This is an extended version that search for folder with names based on locales like it_IT
$get_template_email = wpbp_get_template_part( 'plugin-name-folder' , 'header', 'prefix' );

WPBP/Debug

$debug = new WPBP_Debug();
$debug->log( __( 'Plugin Loaded', 'your-textdomain' ) );
$debug->qm_log(
	__( 'Error inside the log panel of Query Monitor', 'your-textdomain' )
, 'error' );
$debug->qm_timer( 'profile_that_callback', function () {
	echo 'I need to be profiled!'; }
);

WPBP/CPT_Columns

$post_columns = new CPT_columns( 'demo' );
$post_columns->add_column( 'cmb2_field', array(
    'label' => __( 'CMB2 Field' ),
    'type' => 'post_meta', //text, thumbnail, post_meta, author, custom_tax, custom_value
    'meta_key' => '_demo_meta_text',
    'orderby' => 'meta_value', // For WP-Query
    'sortable' => true,
    'prefix' => '',
    'suffix' => '',
    'def' => 'Not defined', // Default value in case post meta not found
    'order' => '-1' // This is the last column
	)
);

WPBP/Language

Wrap specific methods to get string or register it or get the language for Ceceppa Multilingua, Polylang and WPML plugins.

Integrated modules

Snippet included

  • Dashicons as dependency of admin stylesheet
  • Bubble notification on pending CPTs
  • Import/Export settings
  • Custom capabilities with CPTs and taxonomy support
  • wp_localize_script for passing PHP variables to JavaScript on the frontend
  • Class in frontend body with the slug of plugin
  • Shortcode example included
  • WP-CLI support
  • Support for CMB2 in the options page
  • Transient examples with caching
  • engine includes the basic classes or initialize the plugin itself
  • assets includes coffee/sass and js/css files
  • backend includes the features for the dashboard, like import/export settings
  • ajax/rest includes the basic code for ajax(logged/non)/rest integrations
  • cli includes the basic code for cli integrations
  • public includes the code for the frontend
  • tests includes the Codeception tests
  • templates includes the files for templating that can be copied in theme folders
  • internals includes the code shared between all the various folders or the website
  • integrations includes the integration with libraries
  • languages includes the mo/po file for the localization

Code Generator

https://github.com/wpbp/generator

Wiki

THE END

- WordPress Plugin Boilerplate Powered