|

Add Settings To Extensions Page

To add settings for your extension, you can add these right to the extensions tab of the SureFeedback settings. There’s a neat filter that lets you do this called ph_settings_extensions. Here’s an example:

<?php
// filter plugin settings 
add_filter( 'ph_settings_extensions', 'my_extension_plugin_settings' );

// add our settings
function my_extension_plugin_settings($settings) {
	// add fields

	// divider with title
	$settings['fields'][] = array(
		'id'          => 'highlight_divider',
		'label'       => __( 'JIRA Integration', 'my-text-domain' ),
		'description' => '',
		'type'        => 'divider',
	);

	// see all field types in includes/admin/settings/settings-fields.php
    
    // text box example
	$settings['fields'][] = array(
		'id'          => 'my_extension_text_box',
		'label'       => __( 'A Text Box', 'my-text-domain' ),
		'description' => __( 'This is a description for a text box.', 'my-text-domain' ),
		'type'        => 'text',
		'default'     => '',
		'placeholder' => __( 'Enter some text.', 'my-text-domain' ),
	);
    
    // color picker	
    $settings['fields'][] = array(
	    'id'          => 'my_extension_color',
        'label'       => __( 'Color Picker Example', 'project-huddle' ),
        'description' => __( 'Color picker description.', 'project-huddle' ),
        'type'        => 'color',
        'default'     => '#23282d'
    ),
	
    // checkbox example
	$settings['fields'][] = array(
		'id'          => 'my_extension_checkbox',
        'label'       => __( 'Checkbox Example', 'project-huddle' ),
        'description' => __( 'Checkbox description.', 'project-huddle' ),
        'type'        => 'checkbox',
        'default'     => 'on', // on by default
	);

	return $settings;
}


/**
 * Get our options
 */
$text_box = get_option('ph_my_extension_text_box');
$color    = get_option('ph_my_extension_color');
$checkbox = get_option('ph_my_extension_checkbox');

Then to get your options, use the get_option function with the “ph_” prefix.

Was this doc helpful?
What went wrong?

We don't respond to the article feedback, we use it to improve our support content.

Need help? Contact Support
On this page
Scroll to Top