-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBootstrap.php
61 lines (49 loc) · 1.45 KB
/
Bootstrap.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
namespace WCM\AstroFields\Examples\SettingsSection;
/**
* Plugin Name: (WCM) AstroFields Settings Section Example
* Description: Settings section example plugin
*/
// Composer autoloader
if ( file_exists( __DIR__."/vendor/autoload.php" ) )
require_once __DIR__."/vendor/autoload.php";
use WCM\AstroFields\Core\Mediators\Entity;
use WCM\AstroFields\Core\Commands\ViewCmd;
use WCM\AstroFields\Settings\Commands\SettingsSection;
use WCM\AstroFields\Settings\Commands\DeleteOption;
use WCM\AstroFields\Settings\Commands\SanitizeString;
use WCM\AstroFields\Settings\Receivers\OptionValue;
use WCM\AstroFields\Settings\Templates\SectionTmpl;
use WCM\AstroFields\Standards\Templates\InputFieldTmpl;
add_action( 'admin_init', function()
{
if ( ! is_admin() )
return;
// Commands
$input_view = new ViewCmd;
$input_view
->setProvider( new OptionValue )
->setTemplate( new InputFieldTmpl );
// Entity: Field
$input_field = new Entity( 'wcm_settings_field', array(
'general',
'permalink',
) );
// Attach Commands to Field
$input_field
->attach( $input_view )
->attach( new DeleteOption )
->attach( new SanitizeString );
// Command: Settings Section
$section_cmd = new SettingsSection;
$section_cmd
->setTitle( 'Some Title' )
->attach( $input_field, 0 )
->setTemplate( new SectionTmpl );
// Entity: Settings Section
$section = new Entity( 'wcm_settings_section', array(
'general',
'permalink',
) );
$section->attach( $section_cmd );
} );