1. Go to this page and download the library: Download uuur86/wasp 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/ */
uuur86 / wasp example snippets
use WaspCreators\Wasp;
$form = new Wasp( 'page_name( string )', 'settings_name( string )', 'localization_domain_name( string )' );
use WaspCreators\Wasp;
// multi row
$form = new Wasp(
'prefix-admin-page-name',
'wp_options_name',
'plugindomain',
'row' // gets row number from $_GET[ 'row' ]
);
// or single row
$form = new Wasp(
'prefix-admin-page-name',
'wp_options_name',
'plugindomain'
);
if( $form->is_ready() ) {
$form->wp_form_init( 'config_func' );
}
add_action( 'admin_menu', 'admin_menu' );
function config_func( $form ) {
$conf = [
// form sections and items array
];
$form->loadForm( $conf );
$form->register();
}
function admin_menu() {
add_menu_page(
'TestPlugin',
esc_html__( 'TestPlugin', 'testplugin' ),
'manage_options',
'testplugin',
'admin_page',
'dashicons-forms'
);
}
function admin_page() {
global $form;
echo "<p>Embedded form will shown in here!</p>";
// Echo form output
$form->run();
}
use WaspCreators\Wasp;
class TestPlugin {
public $test;
function __construct() {
$this->test = new Wasp(
'prefix-admin-page-name',
'wp_options_name',
'plugindomain'
);
if( $this->test->is_ready() ) {
$this->test->wp_form_init( [ $this, 'config_func' ] );
}
add_action( 'admin_menu', [ $this, 'admin_menu' ] );
}
function config_func() {
$conf = [
// form sections and items array
];
$this->test->loadForm( $conf );
$this->test->register();
}
function admin_menu() {
add_menu_page(
'TestPlugin',
esc_html__( 'TestPlugin', 'testplugin' ),
'manage_options',
'testplugin',
array( $this, 'admin_page' ),
'dashicons-forms'
);
}
function admin_page() {
echo "<p>Embedded form will shown in here!</p>";
// Echo form output
$this->test->run();
}
}
new TestPlugin();