File tree 1 file changed +31
-15
lines changed
1 file changed +31
-15
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,10 @@ public function __construct(array $options = array())
25
25
$ options = array_merge (array (
26
26
'sanitize_callback ' => '' ,
27
27
'sections ' => array (),
28
- 'fields ' => array ()
28
+ 'fields ' => array (),
29
+ 'parent_slug ' => 'options-general.php ' ,
30
+ 'icon_url ' => '' ,
31
+ 'position ' => null ,
29
32
), $ options );
30
33
31
34
$ this ->registry = $ options ;
@@ -74,17 +77,16 @@ public function addField(Field $field)
74
77
public function render ()
75
78
{
76
79
$ reg = $ this ->registry ;
77
- ?>
80
+ ?>
78
81
<div class="wrap">
79
- <div class="icon32" id="icon-options-general"><br></div>
80
- <h2><?php echo $ reg ['page_title ' ]; ?> </h2>
82
+ <h1><?php echo $ reg ['page_title ' ]; ?> </h1>
81
83
<form action="options.php" method="post">
82
- <?php settings_fields ($ reg ['option_name ' ]); ?>
83
- <?php do_settings_sections ($ reg ['option_name ' ]); ?>
84
- <?php submit_button (); ?>
84
+ <?php settings_fields ($ reg ['option_name ' ]); ?>
85
+ <?php do_settings_sections ($ reg ['option_name ' ]); ?>
86
+ <?php submit_button (); ?>
85
87
</form>
86
88
</div>
87
- <?php
89
+ <?php
88
90
}
89
91
90
92
/** @Hook(tag="admin_init") */
@@ -110,12 +112,26 @@ public function setMenu()
110
112
{
111
113
$ reg = $ this ->registry ;
112
114
113
- add_options_page (
114
- $ reg ['page_title ' ],
115
- $ reg ['menu_title ' ],
116
- $ reg ['capability ' ],
117
- $ reg ['option_name ' ],
118
- array ($ this , 'render ' )
119
- );
115
+ if ($ reg ['parent_slug ' ] == 'own ' ) {
116
+
117
+ add_menu_page (
118
+ $ reg ['page_title ' ],
119
+ $ reg ['menu_title ' ],
120
+ $ reg ['capability ' ],
121
+ $ reg ['option_name ' ],
122
+ array ($ this , 'render ' ),
123
+ $ reg ['icon_url ' ],
124
+ $ reg ['position ' ]
125
+ );
126
+ } else {
127
+ add_submenu_page (
128
+ $ reg ['parent_slug ' ],
129
+ $ reg ['page_title ' ],
130
+ $ reg ['menu_title ' ],
131
+ $ reg ['capability ' ],
132
+ $ reg ['option_name ' ],
133
+ array ($ this , 'render ' )
134
+ );
135
+ }
120
136
}
121
137
}
You can’t perform that action at this time.
0 commit comments