Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 21: Add custom "pulse" menu icon #22

Merged
merged 2 commits into from
Dec 6, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 57 additions & 3 deletions includes/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public static function load() {

// Load admin scripts and styles
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_enqueue_scripts' ) );
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_menu_css' ) );

// Reset Streams database
add_action( 'wp_ajax_wp_stream_reset', array( __CLASS__, 'wp_ajax_reset' ) );
Expand All @@ -52,7 +53,7 @@ public static function register_menu() {
$cap,
'wp_stream',
array( __CLASS__, 'stream_page' ),
null,
'div',
3
);

Expand All @@ -79,8 +80,61 @@ public static function admin_enqueue_scripts( $hook ) {
if ( ! isset( self::$screen_id['main'] ) || $hook !== self::$screen_id['main'] ) {
return;
}
wp_enqueue_script( 'wp-stream-admin', plugins_url( 'ui/admin.js' , dirname( __FILE__ ) ), array( 'jquery' ) );
wp_enqueue_style( 'wp-stream-admin', plugins_url( 'ui/admin.css' , dirname( __FILE__ ) ), array() );
wp_enqueue_script( 'wp-stream-admin', WP_STREAM_URL . 'ui/admin.js', array( 'jquery' ) );
wp_enqueue_style( 'wp-stream-admin', WP_STREAM_URL . 'ui/admin.css', array() );
}

/**
* Add menu styles for various WP Admin skins
*
* @action admin_enqueue_scripts
* @return wp_add_inline_style
*/
public static function admin_menu_css() {
wp_register_style( 'wp-stream-icons', WP_STREAM_URL . 'ui/stream-icons/style.css' );

// Make sure we're working off a clean version.
include( ABSPATH . WPINC . '/version.php' );
if ( version_compare( $wp_version, '3.8-alpha', '>=' ) ) {
wp_enqueue_style( 'wp-stream-icons' );
$css = "
#toplevel_page_wp_stream .wp-menu-image:before {
font-family: 'WP Stream' !important;
content: '\\73' !important;
}
#toplevel_page_wp_stream .wp-menu-image {
background-repeat: no-repeat;
}
#menu-posts-feedback .wp-menu-image:before {
font-family: dashicons !important;
content: '\\f175';
}
#adminmenu #menu-posts-feedback div.wp-menu-image {
background: none !important;
background-repeat: no-repeat;
}";
} else {
$css = "
#toplevel_page_wp_stream .wp-menu-image {
background: url( " . WP_STREAM_URL . 'ui/stream-icons/menuicon-sprite.png' . " ) 0 90% no-repeat;
}
/* Retina Stream Menu Icon */
@media only screen and (-moz-min-device-pixel-ratio: 1.5),
only screen and (-o-min-device-pixel-ratio: 3/2),
only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (min-device-pixel-ratio: 1.5) {
#toplevel_page_wp_stream .wp-menu-image {
background: url( " . WP_STREAM_URL . 'ui/stream-icons/menuicon-sprite-2x.png' . " ) 0 90% no-repeat;
background-size:30px 64px;
}
}
#toplevel_page_wp_stream.current .wp-menu-image,
#toplevel_page_wp_stream.wp-has-current-submenu .wp-menu-image,
#toplevel_page_wp_stream:hover .wp-menu-image {
background-position: top left;
}";
}
wp_add_inline_style( 'wp-admin', $css );
}

/**
Expand Down
Binary file added ui/stream-icons/font/stream.eot
Binary file not shown.
11 changes: 11 additions & 0 deletions ui/stream-icons/font/stream.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ui/stream-icons/font/stream.ttf
Binary file not shown.
Binary file added ui/stream-icons/font/stream.woff
Binary file not shown.
Binary file added ui/stream-icons/menuicon-sprite-2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ui/stream-icons/menuicon-sprite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions ui/stream-icons/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@font-face {
font-family: 'WP Stream';
src:url('font/stream.eot');
src:url('font/stream.eot?#iefix') format('embedded-opentype'),
url('font/stream.ttf') format('truetype'),
url('font/stream.woff') format('woff'),
url('font/stream.svg#icomoon') format('svg');
font-weight: normal;
font-style: normal;
}

.icon-stream:before {
content: "\73";
}