-
-
Save Ratko-Solaja/993ec245d8d2cf73c8f4bc5ccd387577 to your computer and use it in GitHub Desktop.
Register the settings for our settings page.
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
/** | |
* 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