An OOP Layer for WordPress
This library wraps WordPress functionality and tries to make WordPress easy to use in object orientated PHP. We also put a little magic in this for less effort on programming.
At first the Lib WP have to be added by requiring it with composer.
composer require awsm/lib-wp
After that the main plugin file have to be created.
The main work is done in creating a plugin file with the necessary comments. Please take care that the comments section is important for the library. It reads all data and works with it.
Setting this data is needed for loading the textdomain.
If langauage files are stored within the plugin, you have to add the path to these files here.
Be sure that the the language files have the syntax [Textdomain]_[language].mo. For example
mytextdomain_de_DE.mo
.
The minimum WordPress version which is needed for the plugin.
The minumum PHP version which is needed for the Plugin.
<?php
/**
* Plugin Name: My Plugin
* Description: A wonderfull plugin.
* Author: Sven Wagener
* Author URI: https://sven-wagener.com
* Version: 1.2.3
* Text Domain: myplugin
* Domain Path: /assets/langauges/
* Network: true
* Requires at least: 5.4.0
* Requires PHP: 7.1.0
*/
namespace AWSM\LibWP\Examples\Plugin;
require dirname( __DIR__ ) . '/vendor/autoload.php';
use AWSM\LibWP\WP\Exception;
use AWSM\LibWP\WP\Core\Plugin;
use AWSM\LibWP\WP\Core\AdminNotices;
use AWSM\LibWP\Examples\Plugin\Components\HelloWorld\HelloWorld;
try {
Plugin::init()->addComponent( HelloWorld::class );
} catch ( Exception $e ) {
ExceptionCatcher::error( sprintf( 'Error executing call %s. Error message: %s', $methodName, $e->getMessage() ) );
}