There is no license information available for the latest version (1.0.1) of this package.

WordPress utilities

1.0.1 2017-07-17 15:14 UTC


Latest Stable Version Total Downloads Latest Unstable Version

WordPress utilities classes for plugin development

Usage example

Include the Composer's autoloader first.

require_once( 'vendor/autoload.php' );


use underDEV\Utils\Singleton;

class Example extends Singleton {}



Helper for AJAX requests.

use underDEV\Utils\Ajax;

function ajax_callback() {

	$ajax = new Ajax();

	// verify nonce
	// you can pass the $_REQUEST array key for nonce as the second argument
	$ajax->verify_nonce( 'key_for_nonce' );

	// do stuff
	// ...

	// send output
	// if errors array will not be empty, it's considered as an error respose
	$ajax->response( $success = 'success message', $errors = array() );



Helper for plugin's files.

use underDEV\Utils\Files;

// argument should be the main plugin file
$files = new Files( __FILE__ );

// get asset url
// will return: your-plugin/assets/dist/css/style.css
$files->asset_url( 'css', 'style.css' )

// get vendor asset url
// will return: your-plugin/assets/vendor/vendor_name/asset.css
$files->vendor_asset_url( 'vendor_name', 'asset.css' )

For all methods please check the class source.


Helper for loading views. Uses the Files class.

use underDEV\Utils\Files;
use underDEV\Utils\View;

// argument should be the main plugin file
$files = new Files( __FILE__ );
$view  = new View( $files );

// set some view var
$view->set_var( 'var_name', 'value' );

// load view
// this will load ./views/parts/menu.php
$view->get_view( 'parts/menu' );

In template file you can get vars

<div><?php echo $this->get_var( 'var_name' ); ?></div>

To have different scopes in templates you have to instantinate different classes.