Last active
June 29, 2023 09:04
-
-
Save Crocoblock/8f2cc20eb43b0ef8f4a968f833e8a063 to your computer and use it in GitHub Desktop.
JetEngine Register Options page programmatically
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
<?php | |
add_action( 'init', 'register_my_custom_options_page', 20 ); | |
function register_my_custom_options_page() { | |
$args = array ( | |
'slug' => 'option-slug', | |
'labels' => | |
array ( | |
'name' => 'JSF - Update Total On Filtering', | |
'menu_name' => 'JSF - Update Total On Filtering', | |
), | |
'fields' => | |
array ( | |
array ( | |
'title' => 'Field preferences', | |
'name' => 'field-preferences', | |
'object_type' => 'field', | |
'width' => '100%', | |
'type' => 'repeater', | |
'repeater-fields' => | |
array ( | |
array ( | |
'title' => 'Selector', | |
'name' => 'selector', | |
'object_type' => 'field', | |
'width' => '100%', | |
'type' => 'text', | |
'description' => 'Selector to be updated', | |
), | |
array ( | |
'title' => 'SQL query', | |
'name' => 'sql', | |
'object_type' => 'field', | |
'width' => '100%', | |
'type' => 'textarea', | |
), | |
array ( | |
'title' => 'Prefix', | |
'name' => 'prefix', | |
'object_type' => 'field', | |
'width' => '100%', | |
'type' => 'text', | |
), | |
array ( | |
'title' => 'Suffix', | |
'name' => 'suffix', | |
'object_type' => 'field', | |
'width' => '100%', | |
'type' => 'text', | |
), | |
array ( | |
'title' => 'Decimal separator', | |
'name' => 'd_sep', | |
'object_type' => 'field', | |
'width' => '100%', | |
'type' => 'text', | |
), | |
array ( | |
'title' => 'Thousand separator', | |
'name' => 't_sep', | |
'object_type' => 'field', | |
'width' => '100%', | |
'type' => 'text', | |
), | |
array ( | |
'title' => 'Decimals count', | |
'name' => 'd_count', | |
'object_type' => 'field', | |
'width' => '100%', | |
'type' => 'number', | |
'min_value' => '0', | |
), | |
), | |
'repeater_collapsed' => false, | |
'repeater_title_field' => 'selector', | |
), | |
), | |
'parent' => 'options-general.php', | |
'icon' => 'dashicons-bell', | |
'capability' => 'manage_options', | |
'position' => '', | |
'hide_field_names' => false, | |
); | |
//create new instance if you do not need the option to appear in select fields in UI | |
new \Jet_Engine_Options_Page_Factory( $args ); | |
//if you do need it to be selectable (say, in Dynamic Repeater), use this instead | |
//jet_engine()->options_pages->register_new_options_page( $args ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment