Skip to content

Instantly share code, notes, and snippets.

@BHWD
Created September 25, 2016 18:23
Show Gist options
  • Save BHWD/b7356598de48602c393f26de48269944 to your computer and use it in GitHub Desktop.
Save BHWD/b7356598de48602c393f26de48269944 to your computer and use it in GitHub Desktop.
<?php
class NoouDAT extends NoouDAT_AdminPageFramework {
/**
* Sets up pages.
*/
public function setUp() {
$this->setRootMenuPageBySlug( 'edit.php?post_type=dat_cpt' );
$this->addSubMenuItem(
array(
'title' => 'Settings',
'page_slug' => 'dat_settings'
)
);
$this->addInPageTabs(
'dat_settings', // set the target page slug so that the 'page_slug' key can be omitted from the next continuing in-page tab arrays.
array(
'tab_slug' => 'dat_email_settings', // avoid hyphen(dash), dots, and white spaces
'title' => __( 'Email Notification Settings', 'dat-email-notification-settings' ),
),
array(
'tab_slug' => 'dat_custom_template', // avoid hyphen(dash), dots, and white spaces
'title' => __( 'Custom Template', 'dat-custom-template' ),
),
array(
'tab_slug' => 'dat_support',
'title' => __( 'Support', 'dat-support' ),
)
);
$this->setPageHeadingTabsVisibility( false ); // disables the page heading tabs by passing false.
$this->setInPageTabTag( 'h2' ); // sets the tag used for in-page tabs
}
public function load() {
new NoouDAT_AceCustomFieldType( $this->oProp->sClassName );
}
/**
* One of the predefined callback method.
*
* @remark content_{page slug}_{tab slug}
*/
function content_dat_settings_dat_support( $sContent ) {
return $sContent
. '<h3>Plugin Support</h3>'
. '<p>For support of this plugin please contact us at: [email protected]</p><p>Thank you,<br>Noou</p>';
}
/**
* One of the pre-defined methods which is triggered when the registered page loads.
*
* Here we add form fields.
* @callback action load_{page slug}
*/
public function load_dat_settings_dat_email_settings( $oAdminPage ) {
$this->addSettingFields(
array( // Checkbox
'field_id' => 'dat_disable_email_notifications',
'type' => 'checkbox',
'default' => '0',
'title' => 'Disable Email Notifications',
'description' => 'If you would not like to get email notifications of new testimonial submissions then check this box.',
),
array( // Single text field
'field_id' => 'dat_change_email_notification_address',
//'repeatable' => true,
'type' => 'text',
'title' => 'Change Notification Recipient Email Address',
'description' => 'By default the plugin sends to the site admin emaill address. If however, you would like to change that please enter the desired recipients email address here.',
),
array( // Submit button
'field_id' => 'submit_button',
'type' => 'submit',
'value' => 'Save Settings',
)
);
}
/**
* One of the pre-defined methods which is triggered when the registered page loads.
*
* Here we add form fields.
* @callback action load_{page slug}
*/
public function load_dat_settings_dat_custom_template( $oAdminPage ) {
$this->addSettingFields(
array( // Ace Custom Field
'field_id' => 'style_editor',
'section_id' => 'a_section',
'title' => __('Style Editor', 'l10n' ),
'description' => __('Type a text string here.', 'l10n' ),
'type' => 'ace',
'default' => '',
//'repeatable' => true,
// The attributes below are the defaults, i.e. if you want theses you don't have to set them
'attributes' => array(
'cols' => 60,
'rows' => 4,
),
// The options below are the defaults, i.e. if you want theses you don't have to set them
'options' => array(
'language' => 'css', // available languages https://github.com/ajaxorg/ace/tree/master/lib/ace/mode
'theme' => 'chrome', //available themes https://github.com/ajaxorg/ace/tree/master/lib/ace/theme
'gutter' => false,
'readonly' => false,
'fontsize' => 12,
),
),
array( // Submit button
'field_id' => 'ct_submit_button',
'type' => 'submit',
'value' => 'Update Custom Template',
)
);
}
}
new NoouDAT;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment