1. Go to this page and download the library: Download yaml-ns/wpp-framework 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/ */
yaml-ns / wpp-framework example snippets
YamlNs\WppFramework
/**
* Plugin Name: My Plugin
*/
declare(strict_types=1);
use YamlNs\WppFramework\Wpp;
if (!defined('ABSPATH')) {
exit;
}
$pluginFile = __FILE__;
$pluginDir = plugin_dir_path($pluginFile);
plugins_loaded', static function () use ($pluginFile, $config): void {
Wpp::boot($pluginFile, $config);
});
register_deactivation_hook($pluginFile, static function () use ($pluginFile, $config): void {
Wpp::deactivate($pluginFile, $config);
});
declare(strict_types=1);
use YamlNs\WppFramework\Wpp;
if (!defined('WP_UNINSTALL_PLUGIN')) {
exit;
}
$pluginFile = __DIR__ . '/my-plugin.php';
final class BookListShortcode extends BaseShortcode
{
public function __construct(ViewRenderer $viewRenderer)
{
parent::__construct($viewRenderer);
}
public function render(): string
{
return $this->view('shortcodes/book-list', [
'books' => [],
]);
}
}
$view->extends('layouts/admin');
<div class="wrap">
echo $view->yield('content');
use Psr\Log\LoggerInterface;
use YamlNs\WppFramework\Providers\ServiceProvider;
final class AppServiceProvider extends ServiceProvider
{
public function register(): void
{
$this->container->singleton(ProductImporter::class);
$this->container->tag([CsvImporter::class, ApiImporter::class], 'importers');
$this->container
->when(ProductSyncService::class)
->needs(LoggerInterface::class)
->give(SyncLogger::class);
}
}