本文整理汇总了PHP中add_settings_section函数的典型用法代码示例。如果您正苦于以下问题:PHP add_settings_section函数的具体用法?PHP add_settings_section怎么用?PHP add_settings_section使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_settings_section函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerSettings
/**
* register settings for our plugin
*/
function registerSettings()
{
//register our settings
register_setting('wtb_seo_settings_main_group', 'wtb_seo_main', array($this, 'sanitize'));
add_settings_section('wtb_seo_settings_main_section', __('On-Page and Post Options', 'wtb_seo'), null, 'wtb_seo_settings');
// ideal density
add_settings_field('ideal_density', __('Ideal keyword density (default: 3%)', 'wtb_seo'), array($this, 'create_an_ideal_density_field'), 'wtb_seo_settings', 'wtb_seo_settings_main_section');
// ideal lenght
add_settings_field('ideal_lenght', __('Ideal post lenght (default: 250)', 'wtb_seo'), array($this, 'create_an_ideal_lenght_field'), 'wtb_seo_settings', 'wtb_seo_settings_main_section');
// checkboxes to check
add_settings_field('to_check', __('Parameter to check', 'wtb_seo'), array($this, 'create_to_check_fields'), 'wtb_seo_settings', 'wtb_seo_settings_main_section');
// wfd or density
add_settings_field('wdf_vs_density', __('Keyword density or WDF to show', 'wtb_seo'), array($this, 'create_an_wdf_vs_density_field'), 'wtb_seo_settings', 'wtb_seo_settings_main_section');
// custom post types
add_settings_section('wtb_seo_settings_cpt_section', __('Activate in custom post types', 'wtb_seo'), null, 'wtb_seo_settings');
add_settings_field('cpt', __('Custom post types', 'wtb_seo'), array($this, 'create_an_custom_post_types_fields'), 'wtb_seo_settings', 'wtb_seo_settings_cpt_section');
// woocommerce
if (is_plugin_active('woocommerce/woocommerce.php')) {
add_settings_section('wtb_seo_settings_woo_section', __('WooCommerce settings', 'wtb_seo'), null, 'wtb_seo_settings');
add_settings_field('check_short_description', __('Check short description', 'wtb_seo'), array($this, 'create_check_short_description'), 'wtb_seo_settings', 'wtb_seo_settings_woo_section');
}
// auto refresh
add_settings_section('wtb_seo_settings_ar_section', __('Auto refresh settings', 'wtb_seo'), null, 'wtb_seo_settings');
add_settings_field('disable_auto_refresh', __('Disabled', 'wtb_seo'), array($this, 'create_auto_refresh_disable'), 'wtb_seo_settings', 'wtb_seo_settings_ar_section');
add_settings_field('auto_refresh_time', __('Auto refresh after (sec.)', 'wtb_seo'), array($this, 'create_auto_refresh_time'), 'wtb_seo_settings', 'wtb_seo_settings_ar_section');
}
示例2: progress_on_scroll_page_init
public function progress_on_scroll_page_init()
{
register_setting('progress_on_scroll_option_group', 'progress_on_scroll_option_name', array($this, 'progress_on_scroll_sanitize'));
add_settings_section('progress_on_scroll_setting_section', 'Settings', array($this, 'progress_on_scroll_section_info'), 'progress-on-scroll-admin');
add_settings_field('fill_0', 'Fill', array($this, 'fill_0_callback'), 'progress-on-scroll-admin', 'progress_on_scroll_setting_section');
add_settings_field('empty_1', 'empty', array($this, 'empty_1_callback'), 'progress-on-scroll-admin', 'progress_on_scroll_setting_section');
}
示例3: sunspot_theme_options_init
/**
* Register the form setting for our sunspot_options array.
*
* This function is attached to the admin_init action hook.
*
* This call to register_setting() registers a validation callback, sunspot_theme_options_validate(),
* which is used when the option is saved, to ensure that our option values are complete, properly
* formatted, and safe.
*
* We also use this function to add our theme option if it doesn't already exist.
*
* @since Sunspot 1.0
*/
function sunspot_theme_options_init() {
// If we have no options in the database, let's add them now.
if ( false === sunspot_get_theme_options() )
add_option( 'sunspot_theme_options', sunspot_get_default_theme_options() );
register_setting(
'sunspot_options', // Options group, see settings_fields() call in sunspot_theme_options_render_page()
'sunspot_theme_options', // Database option, see sunspot_get_theme_options()
'sunspot_theme_options_validate' // The sanitization callback, see sunspot_theme_options_validate()
);
// Register our settings field group
add_settings_section(
'general', // Unique identifier for the settings section
'', // Section title (we don't want one)
'__return_false', // Section callback (we don't want anything)
'theme_options' // Menu slug, used to uniquely identify the page; see sunspot_theme_options_add_page()
);
// Register our individual settings fields
add_settings_field(
'home_layout', // Unique identifier for the field for this section
__( 'How would you like to display posts on the front page?', 'sunspot' ), // Setting field label
'sunspot_settings_home_layout', // Function that renders the settings field
'theme_options', // Menu slug, used to uniquely identify the page; see sunspot_theme_options_add_page()
'general' // Settings section. Same as the first argument in the add_settings_section() above
);
}
示例4: page_init
/**
* Register and add settings
*/
public function page_init()
{
register_setting('my_option_group', 'my_option_name', array($this, 'sanitize'));
add_settings_section('setting_section_id', 'My Custom Settings', array($this, 'print_section_info'), 'my-setting-admin');
add_settings_field('id_number', 'ID Number', array($this, 'id_number_callback'), 'my-setting-admin', 'setting_section_id');
add_settings_field('title', 'Title', array($this, 'title_callback'), 'my-setting-admin', 'setting_section_id');
}
示例5: RegisterPluginOptions
/**
* Register plugin options
*
* The plugin settings options are registered
*
* @param $plugin_settings an array of options each element is an associative array with 1 key and 5 values
* the key is the short name of the field. the values are:
* name => field label,
* callback => the callback used to render the field
* default_value => the default value of the field
* hidden => used to indicate if the field is hidden
* short_name => the short field name
* args => the arguments for the callback function
*/
public final function RegisterPluginOptions($plugin_settings)
{
/**
* Used to indicate if the plugin option should be saved
* It allows the plugin options to be used even if the user has not saved the plugin settings from the settings page
*/
$save_plugin_option = false;
/** The wordpress configuration is fetched */
$wordpress_configuration = $this->GetConfig("wordpress");
/** The options id is fetched */
$options_id = $this->GetComponent("application")->GetOptionsId("options");
/** The current plugin options are fetched */
$options = $this->GetComponent("application")->GetPluginOptions($options_id);
/** The settings group is registered */
register_setting($wordpress_configuration['plugin_prefix'] . '_option_group', $options_id, array($this, 'Sanitize'));
/** If the print section info callback is not defined then an exception is thrown */
$print_section_info_callback = array($this, 'PrintSectionInfo');
if (!is_callable($print_section_info_callback)) {
throw new \Exception("PrintSectionInfo callback function is not defined");
}
/** The settings section is registered */
add_settings_section($wordpress_configuration['plugin_prefix'] . '_settings_id', '', $print_section_info_callback, $wordpress_configuration['settings_page_url']);
/** All of the plugin settings are registered */
foreach ($plugin_settings as $field_short_name => $field_information) {
/** The field callback. If it is given as an object name then the object is fetched from application configuration */
$field_callback = is_object($field_information['callback'][0]) ? $field_information['callback'][0] : $this->GetComponent($field_information['callback'][0]);
$field_callback = array($field_callback, $field_information['callback'][1]);
/** The field label */
$field_label = $field_information['name'];
/** Short field name. Used to create name of callback function */
$short_field_name = $field_information['short_name'];
/** Indicates if field is hidden */
$is_hidden = $field_information['hidden'];
/** Callback function arguments */
$args = $field_information['args'];
/** The default field value */
$default_value = $args['default_value'];
/** The default field value */
$args['field_name'] = $field_information['short_name'];
/** If the settings field is hidden then the field label is set to empty */
if ($is_hidden) {
$field_label = "";
}
/** If the field callback is not defined then an exception is thrown */
if (!is_callable($field_callback)) {
throw new \Exception("The callback for the field: " . $field_label . " was not defined");
}
/** The settings field is added to the plugin settings form */
add_settings_field($wordpress_configuration['plugin_prefix'] . '_' . $short_field_name, $field_label, $field_callback, $wordpress_configuration['settings_page_url'], $wordpress_configuration['plugin_prefix'] . '_settings_id', $args);
/** The default option value is set */
if (!isset($options[$short_field_name])) {
$options[$short_field_name] = $default_value;
$save_plugin_option = true;
}
}
/** The options are saved */
if ($save_plugin_option) {
$this->GetComponent("application")->SavePluginOptions($options, $options_id);
}
}
示例6: register_settings
/**
* Register settings.
*/
public function register_settings()
{
add_settings_section('ib_educator_learning_settings', __('Learning', 'ibeducator'), array($this, 'section_description'), 'ib_educator_learning_page');
// Setting:
add_settings_field('edu_lesson_comments', __('Enable comments on lessons', 'ibeducator'), array($this, 'setting_checkbox'), 'ib_educator_learning_page', 'ib_educator_learning_settings', array('name' => 'lesson_comments', 'settings_group' => 'ib_educator_learning', 'default' => 0, 'id' => 'edu_lesson_comments'));
register_setting('ib_educator_learning_settings', 'ib_educator_learning', array($this, 'validate'));
}
示例7: plugin_settings
/**
* Plugin settings form fields.
*
* @return void.
*/
public function plugin_settings()
{
$option = 'wcbcf_settings';
// Set Custom Fields cection.
add_settings_section('options_section', __('Checkout Custom Fields:', 'woocommerce-extra-checkout-fields-for-brazil'), array($this, 'section_options_callback'), $option);
// Person Type option.
add_settings_field('person_type', __('Display Person Type:', 'woocommerce-extra-checkout-fields-for-brazil'), array($this, 'select_element_callback'), $option, 'options_section', array('menu' => $option, 'id' => 'person_type', 'description' => __('Individuals enables CPF field and Legal Person enables CNPJ field.', 'woocommerce-extra-checkout-fields-for-brazil'), 'options' => array(0 => __('None', 'woocommerce-extra-checkout-fields-for-brazil'), 1 => __('Individuals and Legal Person', 'woocommerce-extra-checkout-fields-for-brazil'), 2 => __('Individuals only', 'woocommerce-extra-checkout-fields-for-brazil'), 3 => __('Legal Person only', 'woocommerce-extra-checkout-fields-for-brazil'))));
// Person Type is Required option.
add_settings_field('only_brazil', __('Person Type is requered only in Brazil?', 'woocommerce-extra-checkout-fields-for-brazil'), array($this, 'checkbox_element_callback'), $option, 'options_section', array('menu' => $option, 'id' => 'only_brazil', 'label' => __('If checked the Individuals and Legal Person options will be mandatory only in Brazil.', 'woocommerce-extra-checkout-fields-for-brazil')));
// RG option.
add_settings_field('rg', __('Display RG:', 'woocommerce-extra-checkout-fields-for-brazil'), array($this, 'checkbox_element_callback'), $option, 'options_section', array('menu' => $option, 'id' => 'rg', 'label' => __('If checked show the RG field in billing options.', 'woocommerce-extra-checkout-fields-for-brazil')));
// State Registration option.
add_settings_field('ie', __('Display State Registration:', 'woocommerce-extra-checkout-fields-for-brazil'), array($this, 'checkbox_element_callback'), $option, 'options_section', array('menu' => $option, 'id' => 'ie', 'label' => __('If checked show the State Registration field in billing options.', 'woocommerce-extra-checkout-fields-for-brazil')));
// Birthdate and Sex option.
add_settings_field('birthdate_sex', __('Display Birthdate and Sex:', 'woocommerce-extra-checkout-fields-for-brazil'), array($this, 'checkbox_element_callback'), $option, 'options_section', array('menu' => $option, 'id' => 'birthdate_sex', 'label' => __('If checked show the Birthdate and Sex field in billing options.', 'woocommerce-extra-checkout-fields-for-brazil')));
// Cell Phone option.
add_settings_field('cell_phone', __('Display Cell Phone:', 'woocommerce-extra-checkout-fields-for-brazil'), array($this, 'checkbox_element_callback'), $option, 'options_section', array('menu' => $option, 'id' => 'cell_phone', 'label' => __('If checked show the Cell Phone field in billing options.', 'woocommerce-extra-checkout-fields-for-brazil')));
// Set Custom Fields cection.
add_settings_section('jquery_section', __('jQuery Options:', 'woocommerce-extra-checkout-fields-for-brazil'), array($this, 'section_options_callback'), $option);
// Mail Check option.
add_settings_field('mailcheck', __('Enable Mail Check:', 'woocommerce-extra-checkout-fields-for-brazil'), array($this, 'checkbox_element_callback'), $option, 'jquery_section', array('menu' => $option, 'id' => 'mailcheck', 'label' => __('If checked informs typos in email to users.', 'woocommerce-extra-checkout-fields-for-brazil')));
// Input Mask option.
add_settings_field('maskedinput', __('Enable Input Mask:', 'woocommerce-extra-checkout-fields-for-brazil'), array($this, 'checkbox_element_callback'), $option, 'jquery_section', array('menu' => $option, 'id' => 'maskedinput', 'label' => __('If checked create masks fill for in fields of CPF, CNPJ, Birthdate, Phone and Cell Phone.', 'woocommerce-extra-checkout-fields-for-brazil')));
// Address Autocomplete option.
add_settings_field('addresscomplete', __('Enable Address Autocomplete:', 'woocommerce-extra-checkout-fields-for-brazil'), array($this, 'checkbox_element_callback'), $option, 'jquery_section', array('menu' => $option, 'id' => 'addresscomplete', 'label' => __('If checked automatically complete the address fields based on the zip code.', 'woocommerce-extra-checkout-fields-for-brazil')));
// Set Custom Fields cection.
add_settings_section('validation_section', __('Validation:', 'woocommerce-extra-checkout-fields-for-brazil'), array($this, 'section_options_callback'), $option);
// Validate CPF option.
add_settings_field('validate_cpf', __('Validate CPF:', 'woocommerce-extra-checkout-fields-for-brazil'), array($this, 'checkbox_element_callback'), $option, 'validation_section', array('menu' => $option, 'id' => 'validate_cpf', 'label' => __('Checks if the CPF is valid.', 'woocommerce-extra-checkout-fields-for-brazil')));
// Validate CPF option.
add_settings_field('validate_cnpj', __('Validate CNPJ:', 'woocommerce-extra-checkout-fields-for-brazil'), array($this, 'checkbox_element_callback'), $option, 'validation_section', array('menu' => $option, 'id' => 'validate_cnpj', 'label' => __('Checks if the CNPJ is valid.', 'woocommerce-extra-checkout-fields-for-brazil')));
// Register settings.
register_setting($option, $option, array($this, 'validate_options'));
}
开发者ID:pensesmart,项目名称:woocommerce-extra-checkout-fields-for-brazil,代码行数:39,代码来源:class-wc-ecfb-settings.php
示例8: add_settings_sections
/**
* Adds all the different settings sections
*/
private function add_settings_sections()
{
add_settings_section('email', __('Email Options', 'woocommerce-pdf-invoices'), array(&$this, 'email_desc_callback'), $this->settings_key);
add_settings_section('download', __('Download Options', 'woocommerce-pdf-invoices'), array(&$this, 'download_desc_callback'), $this->settings_key);
add_settings_section('cloud_storage', __('Cloud Storage Options', 'woocommerce-pdf-invoices'), array(&$this, 'cloud_storage_desc_callback'), $this->settings_key);
add_settings_section('debug', __('Debug Options', 'woocommerce-pdf-invoices'), array(&$this, 'debug_desc_callback'), $this->settings_key);
}
示例9: register_form_flg_settings
function register_form_flg_settings()
{
register_setting('form-flg-settings', 'form-flg-settings', 'validate_settings');
add_settings_section('section-one', 'FLG Setup', 'addsection_settings', 'form_flg_settings');
//FLG Key
add_settings_field('settingsfield_flg_key', 'FLG API Key', 'addsettingsfield_flg_key', 'form_flg_settings', 'section-one');
}
示例10: page_init
/**
* Register and add settings
*/
public function page_init()
{
register_setting('asso1901_settings_group', 'asso1901-settings', array($this, 'sanitize'));
add_settings_section('setting_section_id', 'Personnalisation du plugin', array($this, 'print_section_info'), 'asso1901-setting-admin');
add_settings_field('asso1901-name', 'Nom de l\'association', array($this, 'asso1901_name_callback'), 'asso1901-setting-admin', 'setting_section_id');
add_settings_field('asso1901-title', 'Title', array($this, 'asso1901_title_callback'), 'asso1901-setting-admin', 'setting_section_id');
}
示例11: plugin_admin_init
function plugin_admin_init()
{
register_setting('require_login', 'require_login', 'plugin_options_validate');
//register_setting('require_login', 'require_login');
add_settings_section('rl_main', 'Main Options', 'rl_section_text', 'require_login');
add_settings_field('require_login', 'Enabled?', 'rl_setting_string', 'require_login', 'rl_main');
}
示例12: register_settings
/**
* Register settings
*
* @since 1.3
*/
public function register_settings()
{
// Weed out all admin pages except the Jigoshop Settings page hits
global $pagenow;
if ($pagenow != 'admin.php' && $pagenow != 'options.php') {
return;
}
$screen = get_current_screen();
if ($screen->base != 'jigoshop_page_jigoshop_settings' && $screen->base != 'options') {
return;
}
$slug = $this->get_current_tab_slug();
$options = isset($this->our_parser->tabs[$slug]) ? $this->our_parser->tabs[$slug] : '';
if (!is_array($options)) {
jigoshop_log("Jigoshop Settings API: -NO- valid options for 'register_settings()' - EXITING with:");
jigoshop_log($slug);
return;
}
register_setting(JIGOSHOP_OPTIONS, JIGOSHOP_OPTIONS, array($this, 'validate_settings'));
if (is_array($options)) {
foreach ($options as $index => $option) {
switch ($option['type']) {
case 'title':
add_settings_section($option['section'], $option['name'], array($this, 'display_section'), JIGOSHOP_OPTIONS);
break;
default:
$this->create_setting($index, $option);
break;
}
}
}
add_action('admin_enqueue_styles', array($this, 'settings_styles'), 9);
add_action('admin_enqueue_scripts', array($this, 'settings_scripts'), 9);
}
示例13: registerSections
/**
* Calls the WordPress function add_settings_section() for each SettingSection attached to this Setting. *
* Do not call this function directly, it is tied to the admin_init hook in WordPress. *
* @link http://codex.wordpress.org/Function_Reference/add_settings_section
*
* @since 3.0.0
*
* @return void
*/
public function registerSections()
{
/** @var SettingsSection $section */
foreach ($this->settingsSections as $section) {
add_settings_section($section->getSlug(), $section->getName(), array($section, 'display'), $this->pageSlug);
}
}
示例14: my_general_section
function my_general_section()
{
add_settings_section('my_settings_section', 'My Options Title', 'my_section_options_callback', 'general');
add_settings_field('address', 'Address', 'my_textbox_callback', 'general', 'my_settings_section', array('address'));
add_settings_field('city', 'City', 'my_textbox_callback', 'general', 'my_settings_section', array('city'));
add_settings_field('telephone1', 'Telephone1', 'my_textbox_callback', 'general', 'my_settings_section', array('telephone1'));
add_settings_field('telephone2', 'Telephone2', 'my_textbox_callback', 'general', 'my_settings_section', array('telephone2'));
add_settings_field('fax', 'Fax', 'my_textbox_callback', 'general', 'my_settings_section', array('fax'));
add_settings_field('email', 'Email', 'my_textbox_callback', 'general', 'my_settings_section', array('email'));
add_settings_field('website', 'Website', 'my_textbox_callback', 'general', 'my_settings_section', array('website'));
add_settings_field('facebook', 'Facebook url', 'my_textbox_callback', 'general', 'my_settings_section', array('facebook'));
add_settings_field('instagram', 'Instagram url', 'my_textbox_callback', 'general', 'my_settings_section', array('instagram'));
add_settings_field('twitter', 'Twitter url', 'my_textbox_callback', 'general', 'my_settings_section', array('twitter'));
add_settings_field('pinterest', 'Pinterest url', 'my_textbox_callback', 'general', 'my_settings_section', array('pinterest'));
add_settings_field('phone', 'Header phone no', 'my_textbox_callback', 'general', 'my_settings_section', array('phone'));
add_settings_field('map-link', 'Map URL', 'my_textbox_callback', 'general', 'my_settings_section', array('map-link'));
register_setting('general', 'address', 'esc_attr');
register_setting('general', 'city', 'esc_attr');
register_setting('general', 'telephone1', 'esc_attr');
register_setting('general', 'telephone2', 'esc_attr');
register_setting('general', 'fax', 'esc_attr');
register_setting('general', 'email', 'esc_attr');
register_setting('general', 'website', 'esc_attr');
register_setting('general', 'facebook', 'esc_attr');
register_setting('general', 'instagram', 'esc_attr');
register_setting('general', 'twitter', 'esc_attr');
register_setting('general', 'pinterest', 'esc_attr');
register_setting('general', 'phone', 'esc_attr');
register_setting('general', 'map-link', 'esc_attr');
}
示例15: setup_settings
public function setup_settings()
{
// General
add_settings_section('bp-docs-general', __('General', 'bp-docs'), array($this, 'general_section'), 'bp-docs-settings');
// General - Docs slug
add_settings_field('bp-docs-slug', __('Slug', 'bp-docs'), array($this, 'slug_setting_markup'), 'bp-docs-settings', 'bp-docs-general');
register_setting('bp-docs-settings', 'bp-docs-slug', 'rawurlencode');
// General - Excerpt length
add_settings_field('bp-docs-excerpt-length', __('Directory Excerpt Length', 'bp-docs'), array($this, 'excerpt_length_setting_markup'), 'bp-docs-settings', 'bp-docs-general');
register_setting('bp-docs-settings', 'bp-docs-excerpt-length', 'absint');
// Users
add_settings_section('bp-docs-users', __('Users', 'bp-docs'), array($this, 'users_section'), 'bp-docs-settings');
// Users - Tab name
add_settings_field('bp-docs-user-tab-name', __('User Tab Name', 'bp-docs'), array($this, 'user_tab_name_setting_markup'), 'bp-docs-settings', 'bp-docs-users');
register_setting('bp-docs-settings', 'bp-docs-user-tab-name');
// Groups
if (bp_is_active('groups')) {
add_settings_section('bp-docs-groups', __('Groups', 'bp-docs'), array($this, 'groups_section'), 'bp-docs-settings');
// Groups - Tab name
add_settings_field('bp-docs-tab-name', __('Group Tab Name', 'bp-docs'), array($this, 'group_tab_name_setting_markup'), 'bp-docs-settings', 'bp-docs-groups');
register_setting('bp-docs-settings', 'bp-docs-tab-name');
}
// Attachments
add_settings_section('bp-docs-attachments', __('Attachments', 'bp-docs'), array($this, 'attachments_section'), 'bp-docs-settings');
// Users - Tab name
add_settings_field('bp-docs-enable-attachments', __('Enable Attachments', 'bp-docs'), array($this, 'enable_attachments_setting_markup'), 'bp-docs-settings', 'bp-docs-attachments');
register_setting('bp-docs-settings', 'bp-docs-enable-attachments');
}