Sunrise: Class reference – Methods

class constructor ( string $file, array $args )

$file - just put here FILE constant. It must be full path (not URL) to main plugin file.

$args - class configuration. Here you can redefine some of class settings. Primarily it's paths to service folders, like assets or includes.

Example with defaults:

$example_plugin = new Sunrise_Plugin_Framework_2( __FILE__, array(
   'includes' => 'inc',
   'views' => 'inc/views',
   'assets' => 'assets'
) );

add_options_page( array $args, array $options )

Creates new options page with specified in $options fields. With $args you can change default menu and page titles, minimal capability to access options page and show or hide Settings link at plugins dashboard. See all the available options types here. Example with defaults:

$example_plugin->add_options_page( array(
   'parent' => 'options-general.php',
   'menu_title' => 'Plugin name',
   'page_title' => 'Plugin name',
   'capability' => 'manage_options',
   'link' => true
), $options );

assets( string $type = 'css', string $file = 'style.css' )

Return absolute URL to asset file depend on specified asset type. Without trailing slash. Example:

echo $example_plugin->assets( 'css', 'style.css' );
// Will output something like 'http://example.com/wp-content/plugins/plugin-name/assets/css/style.css'

get_option( mixed $option = false )

Returns value of specified option. Example:

echo $example_plugin->get_option( 'custom_logo' );
// Will output value of custom_logo option.

update_option( string $key, mixed $value )

Changes value of specified option. Value can be presented as an array. Example:

$example_plugin->update_option( 'custom_logo', '/wp-content/uploads/new-logo.png' );
echo $example_plugin->get_option( 'custom_logo' );
// Will output new value '/wp-content/uploads/new-logo.png'