-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.php
61 lines (53 loc) · 1.73 KB
/
example.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
use ItalyStrap\Settings\Page;
use ItalyStrap\Settings\SettingsBuilder;
$text_domain = 'ItalyStrap';
$option_name = 'italystrap';
$settings_config = \ItalyStrap\Config\ConfigFactory::make(
require __DIR__ . '/tests/_data/fixtures/config/settings.php'
);
// Initialize the builder
$settings = new SettingsBuilder(
$option_name,
ITALYSTRAP_BASENAME,
ITALYSTRAP_FILE
);
// You can add configuration via the \ItalyStrap\Config\ConfigFactory::class
$settings->addPage(
$settings_config->get( 'page' ),
$settings_config->get( 'sections' )
);
// Ora manually
// The section parameter is optional
// Not every page need a section with fields
// For example in a docs page
// Manu title and slug are mandatory
$settings->addPage(
[
Page::PARENT => 'italystrap-dashboard',
Page::PAGE_TITLE => \__( 'Dashboard 2', 'italystrap' ),
Page::MENU_TITLE => \__( 'Child1', 'italystrap' ),
Page::SLUG => 'slug-for-child-page',
Page::VIEW => __DIR__ . '/tests/_data/fixtures/view/empty_form.php',
]
);
// You can also add a sub page either for you parent page or for the WP admin pages
$settings->addPage(
[
Page::PARENT => 'options-general.php',
// Page::PAGE_TITLE => \__( 'ItalyStrap Dashboard 2', 'italystrap' ),
Page::MENU_TITLE => \__( 'Child-general', 'italystrap' ),
Page::SLUG => 'slug-for-child-general',
Page::VIEW => __DIR__ . '/tests/_data/fixtures/view/empty_form.php',
]
);
// You can also add a link to the plugins.php page in your plugin link for activation
// For example if you want to add an external link to your docs.
$settings->addCustomPluginLink(
'key-for-css',
'http://localhost.com',
'Custom',
[ 'target' => '_blank' ]
);
// After you added pages[?section] and/or link call the build() method.
$settings->build();