APIs on form builder & plugin menu modification

Following APIs are available for modifying form builder and eForm plugin menu.

Filter: ipt_fsqm_admin_tab_settings

API-adding-tabs

The ipt_fsqm_admin_tab_settings filter is used to filter the form builder settings tabs.

Filter Uses

When being called, it passes two parameters. First one is an associative array of settings tabs and their callback functions. The second is the IPT_FSQM_Form_Elements_Admin object that has called this filter.

/**
 * Sample usage of ipt_fsqm_admin_tab_settings filter
 */
class FSQM_Extend_Settings {
	protected $fsqm_admin_obj;

	public function __construct() {
		add_filter( 'ipt_fsqm_admin_tab_settings', array( $this, 'my_own_fsqm_settings' ), 10, 2 );
	}

	function my_own_fsqm_settings( $tab_settings, $obj ) {
		// Store the pointer to the object for later use
		$this->fsqm_admin_obj = $obj;

		// Modify the tab settings to add our own tab
		$tab_settings[] = array(
			'id' => 'my_own_fsqm_settings_panel', // HTML ID of the new settings tab
			'label' => __( 'Custom Settings', 'domain' ), // Label of the tab
			'callback' => array( $this, 'settings_cb' ), // Valid callback method/function
		);

		return $tab_settings;
	}

	public function settings_cb() {
		// Get the options
		$options = $this->fsqm_admin_obj->settings['custom_options'];
		// Print your settings panel
	}
}

$fsqm_settings = new FSQM_Extend_Settings();

Do note that any function that hooks into the filter, must return an associative array of the mentioned format. Otherwise the settings tabs would not get printed. Also other functions filtering into the same might throw errors.

Examples:

Source:

Located in classes/class-ipt-fsqm-form-elements-admin.php.

Filter: ipt_fsqm_admin_menus

API-FSQMPro-Pages

The ipt_fsqm_admin_menus is used to dynamically insert a new admin page inside eForm admin menu and also register your own addon inside eForm. Any class reference returned/modified by this filter is expected to be a child class of IPT_FSQM_Admin_Base. If not, then unexpected errors may occur.

Filter Uses:

The filter passes only one argument. An array of class names (child classes of IPT_FSQM_Admin_Base) that would populate eForm menus. The return should also be an array of the same.

/**
 * Sample usage of ipt_fsqm_admin_menus filter
 */

class FSQM_Custom_Admin extends IPT_FSQM_Admin_Base {
	/**
	 * Filter eForm Admin Menu to insert our own page
	 */
	public static function admin_menu_filter( $admin_classes ) {
		// Insert just the class name that extends admin base
		$admin_classes[] = 'FSQM_Custom_Admin';
		return $admin_classes;
	}

	public function __construct() {
		$this->capability = 'manage_feedback';
		$this->action_nonce = 'ipt_fsqm_demo_nonce';

		parent::__construct();

		$this->icon = 'stack';
	}

	public function admin_menu() {
		$this->pagehook = add_submenu_page('ipt_fsqm_dashboard', __('IPT eForm Custom Admin', 'domain'), __('Custom Admin', 'domain'), $this->capability, 'ipt_fsqm_custom_admin', array($this, 'index'));
		parent::admin_menu();
	}

	public function index() {
		$this->index_head( __( 'WP Feedback, Survey & Quiz Manager - Pro <span class="icon-arrow-right-2"></span> Custom Admin', 'domain' ), true );
		// Do your thing
		// The way you want
		$this->index_foot();
	}
}
add_filter( 'ipt_fsqm_admin_menus', array( 'FSQM_Custom_Admin', 'admin_menu_filter' ), 10, 1 );

The system would check if the class actually exists before instantiating it. So if you give erroneous class name then it would silently fail. Also it calls for get_pagehook method. So if you decide not to pass a child of IPT_FSQM_Admin_Base, then make sure your class has the same method that returns the new pagehook.

Examples:

Source:

Located in classes/class-ipt-fsqm-loader.php.

Filter: ipt_fsqm_integration_settings_tabs

API-adding-integration-tabs

The ipt_fsqm_integration_settings_tabs is used to extend the vertical tabs inside the integration settings. It comes in handy when you are planning to extend the third party integration of eForm.

Filter Uses

The filter accepts two arguments (much like the ipt_fsqm_admin_tab_settings). The first one is an associative array of tab settings and their callback. The second is the reference of IPT_FSQM_Form_Elements_Admin class that has called this filter.

/**
 * Sample usage of ipt_fsqm_integration_settings_tabs filter
 */
class FSQM_Extend_Integration {
	protected $fsqm_admin_obj;

	public function __construct() {
		add_filter( 'ipt_fsqm_integration_settings_tabs', array( $this, 'my_own_fsqm_settings' ), 10, 2 );
	}

	function my_own_fsqm_settings( $tab_settings, $obj ) {
		// Store the pointer to the object for later use
		$this->fsqm_admin_obj = $obj;

		// Modify the tab settings to add our own tab
		$tab_settings[] = array(
			'id' => 'my_own_fsqm_settings_panel', // HTML ID of the new settings tab
			'label' => __( 'Custom Settings', 'domain' ), // Label of the tab
			'callback' => array( $this, 'settings_cb' ), // Valid callback method/function
		);

		return $tab_settings;
	}

	public function settings_cb() {
		// Get the options
		$options = $this->fsqm_admin_obj->settings['integration']['custom'];
		// Print your settings panel
	}
}

$fsqm_settings = new FSQM_Extend_Integration();

The return should be an associative array with valid elements as mentioned. Otherwise none of the integration settings would work.

Examples:

Source:

Located in classes/class-ipt-fsqm-form-elements-admin.php.

Swashata has written 247 articles

Hi there, I am the Lead Developer at WPQuark.com. I love to create something beautiful for WordPress and here I write about how to use them. When I am not working, usually I am doing a number of other creative things ;).