Nuxy
  • Nuxy
  • Installation
  • Adding Page Options
  • Adding Post Options
  • Adding Taxonomy Options
  • Adding Frontend Options
  • Getting Fields
  • Adding to admin bar
  • Tabs
    • General tab parameters
    • Add submenu
  • Field parameters
  • Registering field
  • Fields dependency
  • Fields group
  • Field types
    • General field parameters
    • 1. Text
    • 2. Number
    • 3. Textarea
    • 4. Checkbox
    • 5. Select
    • 6. Radio
    • 7. Color
    • 8. Image
    • 9. Editor
    • 10. Autocomplete
    • 11. Datepicker
    • 12. Datepicker range
    • 13. Time
    • 14. Sortable
    • 15. Sortable multi input
    • 16. Gallery
    • 17. Repeater
    • 18. Range slider
    • 19. Image Select
    • 20. Button group
    • 21. Icon picker
    • 22. Ace Editor
    • 23. Spacings
    • 24. Link color
    • 25. Multi checkbox
    • 26. Color Gradient
    • 27. Textarea with hints
    • 28. Typography
    • 29. Multiselect
    • 30. Notification Message
    • 31. Button List
    • 32. Group Title with Preview && Icon
  • Download Nuxy
Powered by GitBook
On this page

Adding Page Options

Add custom admin page with setting fields

Theme Options

The framework will create a menu or submenu item in the WordPress menu. The script will auto-load itself on the correct admin hooks. You need to add a filter with next parameters:

add_filter('wpcfto_options_page_setup', function ($setups) {
    $setups[] = array(
        /*
         * Here we specify option name. It will be a key for storing in wp_options table
         */
        'option_name' => 'my_awesome_settings',
        
        'title' => esc_html__('Theme options', 'my-domain'),
        'sub_title' => esc_html__('by StylemixThemes', 'my-domain'),
        'logo' => 'https://s3.envato.com/files/235051023/avatar-80x80.png',

        /*
         * Next we add a page to display our awesome settings.
         * All parameters are required and same as WordPress add_menu_page.
         */
        'page' => array(
            'page_title' => 'Awesome Settings',
            'menu_title' => 'Settings',
            'menu_slug' => 'my_awesome_settings',
            'icon' => 'dashicons-editor-unlink',
            'position' => 40,
        ),

        /*
         * And Our fields to display on a page. We use tabs to separate settings on groups.
         */
        'fields' => array(
            // Even single tab should be specified
            'tab_1' => array(
                // And its name obviously
                'name' => esc_html__('Tab 1', 'my-domain'),
                'fields' => array(
                    // Field key and its settings. Full info about fields read in documentation.
                    'awesome_1' => array(
                        'type' => 'text',
                        'label' => esc_html__('Awesome Field label', 'my-domain'),
                        'value' => 'Awesome default value',
                    ),
                    'awesome_2' => array(
                        'type' => 'text',
                        'label' => esc_html__('Awesome Field label 2', 'my-domain'),
                        'value' => 'Awesome default value 2',
                    ),
                )
            ),

           /*
            * Other tabs you can add below
            */
            // ....
        )
    );

    return $setups;
});

And in your template, you can get your option as:

$my_awesome_options = get_option('my_awesome_settings', array());
/*
 * Where 'my_awesome_settings' is the same setup option name.
 */
PreviousInstallationNextAdding Post Options

Last updated 11 months ago