Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Register the settings for our settings page.
/**
* Register the settings for our settings page.
*
* @since 1.0.0
*/
public function register_settings() {
// Here we are going to register our setting.
register_setting(
$this->plugin_name . '-settings',
$this->plugin_name . '-settings',
array( $this, 'sandbox_register_setting' )
);
// Here we are going to add a section for our setting.
add_settings_section(
$this->plugin_name . '-settings-section',
__( 'Settings', 'toptal-save' ),
array( $this, 'sandbox_add_settings_section' ),
$this->plugin_name . '-settings'
);
// Here we are going to add fields to our section.
add_settings_field(
'post-types',
__( 'Post Types', 'toptal-save' ),
array( $this, 'sandbox_add_settings_field_multiple_checkbox' ),
$this->plugin_name . '-settings',
$this->plugin_name . '-settings-section',
array(
'label_for' => 'post-types',
'description' => __( 'Save button will be added only to the checked post types.', 'toptal-save' )
)
);
add_settings_field(
'toggle-content-override',
__( 'Append Button', 'toptal-save' ),
array( $this, 'sandbox_add_settings_field_single_checkbox' ),
$this->plugin_name . '-settings',
$this->plugin_name . '-settings-section',
array(
'label_for' => 'toggle-content-override',
'description' => __( 'If checked, it will append save button to the content.', 'toptal-save' )
)
);
add_settings_field(
'toggle-status-override',
__( 'Membership', 'toptal-save' ),
array( $this, 'sandbox_add_settings_field_single_checkbox' ),
$this->plugin_name . '-settings',
$this->plugin_name . '-settings-section',
array(
'label_for' => 'toggle-status-override',
'description' => __( 'If checked, this feature will be available only to logged in users. ', 'toptal-save' )
)
);
add_settings_field(
'toggle-css-override',
__( 'Our Styles', 'toptal-save' ),
array( $this, 'sandbox_add_settings_field_single_checkbox' ),
$this->plugin_name . '-settings',
$this->plugin_name . '-settings-section',
array(
'label_for' => 'toggle-css-override',
'description' => __( 'If checked, our style will be used.', 'toptal-save' )
)
);
add_settings_field(
'text-save',
__( 'Save Item', 'toptal-save' ),
array( $this, 'sandbox_add_settings_field_input_text' ),
$this->plugin_name . '-settings',
$this->plugin_name . '-settings-section',
array(
'label_for' => 'text-save',
'default' => __( 'Save Item', 'toptal-save' )
)
);
add_settings_field(
'text-unsave',
__( 'Unsave Item', 'toptal-save' ),
array( $this, 'sandbox_add_settings_field_input_text' ),
$this->plugin_name . '-settings',
$this->plugin_name . '-settings-section',
array(
'label_for' => 'text-unsave',
'default' => __( 'Unsave Item', 'toptal-save' )
)
);
add_settings_field(
'text-saved',
__( 'Saved. See saved items.', 'toptal-save' ),
array( $this, 'sandbox_add_settings_field_input_text' ),
$this->plugin_name . '-settings',
$this->plugin_name . '-settings-section',
array(
'label_for' => 'text-saved',
'default' => __( 'Saved. See saved items.', 'toptal-save' )
)
);
add_settings_field(
'text-no-saved',
__( 'You don\'t have any saved items.', 'toptal-save' ),
array( $this, 'sandbox_add_settings_field_input_text' ),
$this->plugin_name . '-settings',
$this->plugin_name . '-settings-section',
array(
'label_for' => 'text-no-saved',
'default' => __( 'You don\'t have any saved items.', 'toptal-save' )
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment