Last active
April 19, 2017 07:43
-
-
Save sukhikh18/24450342be82b2776bbf229c40b1d1ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* WP Admin Settings Page | |
* | |
* before use: | |
* download requires | |
* change MY_PAGE_SLUG constant | |
* change render functions | |
* | |
*/ | |
require 'inc/class-wp-form-render.php'; | |
require 'inc/class-wp-admin-page-render.php'; | |
define('MY_PAGE_SLUG', 'page_slug'); | |
$args = array( | |
'title' => __('Test Page h1 Title','domain'), // default: '' | |
'menu' => __('Test page','domain'), | |
// defaults: | |
//'parent' => 'options-general.php', | |
// 'permissions' => 'manage_options' | |
); | |
$page = new WPAdminPageRender( MY_PAGE_SLUG, $args, 'page_body' ); | |
function page_body(){ | |
echo 'Its page for test classes <br>'; | |
var_dump(get_option(MY_PAGE_SLUG)); | |
$inputs = array( | |
array( | |
'type' => 'checkbox', | |
'id' => 'test', | |
'label'=> 'test label', | |
'desc' => 'test description' | |
), | |
array( | |
'type' => 'number', | |
'id' => 'year', | |
'label'=> 'Year', | |
'before' => 'Now: ', | |
'after' => ' year.', | |
'desc' => 'Second Test field', | |
'default' => '2017' | |
), | |
); | |
// default args: | |
$args = array( | |
'item_wrap' => array('<p>', '</p>'), | |
'form_wrap' => array('<table class="table form-table"><tbody>', '</tbody></table>'), | |
'label_tag' => 'th', | |
'hide_desc' => false, | |
'clear_value' => 'false' | |
); | |
$sub_name = false; | |
$is_admin_options = true; | |
WPForm::render( | |
apply_filters( 'dt_admin_options', $inputs, MY_PAGE_SLUG ), | |
WPForm::active(MY_PAGE_SLUG, $sub_name, $is_admin_options), | |
$is_table, | |
$args, | |
$is_not_echo | |
); | |
} | |
add_filter( MY_PAGE_SLUG . '_columns', function(){return 2;} ); | |
$page->add_metabox( 'handle', 'metabox label', 'metabox_body', 'side'); | |
function metabox_body(){ | |
echo "Its metabox render body function. How easy? "; | |
submit_button(); | |
} | |
// add_action( MY_PAGE_SLUG . '_inside_side_container', 'submit_button', 20 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment