Settings',
);
// remove edit link
unset( $links['edit'] );
// return new links
return array_merge( $mylinks, $links );
}
/**
* Add options page
*/
public function add_plugin_page()
{
// This page will be under "Settings"
add_theme_page(
'Settings Admin',
'Android Status Bar',
'manage_options',
'wn-android-statusbar',
array( $this, 'settings_page' )
);
}
/**
* Add media files
*/
public function load_media_files()
{
wp_enqueue_media();
wp_enqueue_script( 'wn-script', plugins_url( 'js/wn-script.js', __FILE__ ), array(), '1.0.0', true );
}
/**
* Options page callback
*/
public function settings_page()
{
// Set class property
$this->options = get_option( 'wn_android_statusbar' );
?>
Androind 5.0 Lollipop Statusbar
options = get_option( 'wn_android_statusbar' );
$output = '' . PHP_EOL;
if ( is_front_page() ) {
$output .= '' . PHP_EOL;
} else if ( is_single() ) {
$cats = get_the_category();
if ( isset( $cats[0] ) && isset( $this->options['cat_'.$cats[0]->cat_ID] ) && !empty( $this->options['cat_'.$cats[0]->cat_ID] ) ) {
// category specific colour
$output .= '' . PHP_EOL;
} else {
// default post colour
$output .= '' . PHP_EOL;
}
} else if ( is_page() ) {
$output .= '' . PHP_EOL;
} else {
$output .= '' . PHP_EOL;
}
if ( isset( $this->options['android-icon'] ) ) {
$output .= '' . PHP_EOL;
}
echo $output;
}
/**
* Register and add settings
*/
public function page_init()
{
register_setting(
'wn_android_options', // Option group
'wn_android_statusbar', // Option name
array( $this, 'sanitize' ) // Sanitize
);
add_settings_section(
'android-colours', // ID
'Status Bar Colour', // Title
array( $this, 'print_section_info_colours' ), // Callback
'wn-android-statusbar' // Page
);
add_settings_field(
'default-colour', // ID
'Default Colour', // Title
array( $this, 'colour_callback' ), // Callback
'wn-android-statusbar', // Page
'android-colours', // Section
array( 'id' => 'default-colour' )
);
add_settings_field(
'home-colour', // ID
'Home Page Colour', // Title
array( $this, 'colour_callback' ), // Callback
'wn-android-statusbar', // Page
'android-colours', // Section
array( 'id' => 'home-colour' )
);
add_settings_field(
'page-colour', // ID
'Page Colour', // Title
array( $this, 'colour_callback' ), // Callback
'wn-android-statusbar', // Page
'android-colours', // Section
array( 'id' => 'page-colour' )
);
add_settings_field(
'post-colour', // ID
'Post Colour', // Title
array( $this, 'colour_callback' ), // Callback
'wn-android-statusbar', // Page
'android-colours', // Section
array( 'id' => 'post-colour' )
);
add_settings_section(
'android-icons', // ID
'Icon', // Title
array( $this, 'print_section_info_icons' ), // Callback
'wn-android-statusbar' // Page
);
add_settings_field(
'android-icon', // ID
'Android Icon (192px × 192px)', // Title
array( $this, 'file_callback' ), // Callback
'wn-android-statusbar', // Page
'android-icons', // Section
array( 'id' => 'android-icon' )
);
add_settings_section(
'categories', // ID
'Category Colours', // Title
array( $this, 'print_section_category_colours' ), // Callback
'wn-android-statusbar' // Page
);
$categories = get_categories();
foreach ( $categories as $cat ) {
add_settings_field(
'cat_' . $cat->cat_ID, // ID
$cat->cat_name, // Title
array( $this, 'colour_callback' ), // Callback
'wn-android-statusbar', // Page
'categories', // Section
array( 'id' => 'cat_' . $cat->cat_ID )
);
}
}
/**
* Sanitize each setting field as needed
*
* @param array $input Contains all settings fields as array keys
*/
public function sanitize( $input )
{
$new_input = array();
foreach ( $input as $id => $val )
$new_input[$id] = esc_attr( $val );
return $new_input;
}
/**
* Print the Section text for Colours
*/
public function print_section_info_colours()
{
echo 'Enter a HEX colour below:';
}
/**
* Print the Section text for Icons
*/
public function print_section_info_icons()
{
echo 'Enter a URL or select a file to use from the Media Gallery. For best results, use an absolute URL.';
}
/**
* Print the Section text for Icons
*/
public function print_section_category_colours()
{
echo 'Configure category-specific colours here.';
}
/**
* Get the settings option array and print one of its values
*/
public function colour_callback( $args )
{
printf(
'#',
$args['id'],
isset( $this->options[ $args['id'] ] ) ? esc_attr( $this->options[ $args['id'] ] ) : ''
);
}
/**
* Get the settings option array and print one of its values
*/
public function file_callback( $args )
{
printf(
' ',
$args['id'],
isset( $this->options[ $args['id'] ] ) ? esc_attr( $this->options[ $args['id'] ] ) : ''
);
}
/**
* Get the settings option array and print one of its values
*/
public function vibrate_callback( $args )
{
printf(
'',
$args['id'],
isset( $this->options[ $args['id'] ] ) ? 'checked' : ''
);
}
}
// run plugin
$wn_android_statusbar = new WN_Android_50_Statusbar();