Utilizing WordPress’ Admin UI for plugin settings: getting accordion style

Here’s how I do it for my plugin/options page (which is inside a class, thus the $this-> construct):

/* enqueue our css */
public function enqueue_options_style( $hook ) {
    if( $hook == $this->admin_page )
        wp_enqueue_style( 'my-options', '/some-directory/my-options.css', false, $this->version );  // only present for our plugin's settings page
}

$this->admin_page is the slug returned from prior options page init:

$this->admin_page = add_menu_page( __( 'Settings' ), __( 'Settings' ), 'some-user-capability', 'my-options', array( &$this, 'display_page' ), 'dashicons-my-icon' );

and, the call to enqueue the options style is hooked thusly:

add_action( 'admin_enqueue_scripts', array( &$this, 'enqueue_options_style' ), 10, 1 );     // add the css we need for our options settings page

Now, it’s just a matter of constructing that my-options.css file, with the appropriate markup for your .accordion h3 element.

tech