1. Go to this page and download the library: Download camalote-wp/models 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/ */
camalote-wp / models example snippets
use CamaloteWP\Models\Core\BootstrapRunner;
// Standard usage (creates internal Loader)
$runner = new BootstrapRunner;
$runner->register([Page\Bootstrap::class])->run();
// With dependency injection (shares Loader instance)
$loader = new Loader;
$runner = new BootstrapRunner($loader);
$runner->register([Page\Bootstrap::class])->run();
// You can also access the shared loader for additional hook registration
$loader->add_action('plugins_loaded', $this, 'load_textdomain');
// PageBlocks.php
namespace MyPlugin\Page;
use CamaloteWP\Models\Abstracts\AbstractBlocks;
class PageBlocks extends AbstractBlocks
{
protected string $model_name = 'page';
protected function get_block_paths(): array
{
return [get_template_directory() . '/blocks'];
}
}
// Bootstrap.php
namespace MyPlugin\Page;
use CamaloteWP\Models\Abstracts\AbstractBootstrap;
class Bootstrap extends AbstractBootstrap
{
protected string $model_name = 'page';
public function get_components(): array
{
return [
PagePostType::class,
PageMeta::class,
PageBlocks::class,
];
}
}
// In your plugin's main file or service provider
use CamaloteWP\Models\Core\BootstrapRunner;
use MyPlugin\Page\Bootstrap;
$runner = new BootstrapRunner;
$runner->register([Bootstrap::class])->run();
// Default constructor (backward compatible)
$runner = new BootstrapRunner;
$runner->register([Bootstrap::class])->run();
// With dependency injection
$loader = new Loader;
$runner = new BootstrapRunner($loader);
$runner->register([Bootstrap::class])->run();
// Access shared loader (optional)
$loader = $runner->get_loader();
$loader->add_action('init', $this, 'custom_init');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.