Skip to content

Commit

Permalink
Merge pull request #12 from jdmdigital/develop
Browse files Browse the repository at this point in the history
Bug Fixes
  • Loading branch information
jdmdigital committed May 5, 2016
2 parents 9911e81 + f2336de commit 0356b03
Show file tree
Hide file tree
Showing 10 changed files with 252 additions and 30 deletions.
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,30 @@ The WordPress admin bar gets in the way of basic frontend management of your Wor
A few goals we had in making this plugin:

* Keep it free and feature-rich
* Keep it simple (stupid)
* Keep it simple
* Must be SUPER lightweight (we hate plugin bloat)
* Build for developers and noobs alike

The plugin is still in BETA, but you're welcome to take a look at how it's coming over on <a href="http://labs.jdmdigital.co/plugins/frontend-admin-buttons/" target="_blank">JDM Labs</a>.

## Installation
This plugin is not, yet, avaliable on the WordPress repo. To install it, you'll need to use the [GitHub Updater](https://github.com/afragen/github-updater) plugin for automatic updates. Of course, you could just install/upgrade it manually using FTP, but that's boring.

1. Install the plugin, and the updater - [tutorial here for using GitHub Updater](http://labs.jdmdigital.co/plugins/github-updates/)
2. Activate the plugin
3. That's it!
3. That's it! Seriously.

There's no settings page. It does all the feature and role detection work for you.

## Changelog

**1.2**
* Add better support for different access roles
* Add tiny font-icon suite if none already found
* Update README

**1.1**
* Fix possible function conflicts
* Version Bump

**1.0**
* Production-Ready
* Several Bug Fixes
Expand Down
61 changes: 56 additions & 5 deletions css/jdm-fab.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,61 @@
/* JDM FAB Styles */
.no-js #hide-admin-buttons{display:none;}

/* @since v1.2 */
@font-face {
font-family: 'fab-icons';
src: url('../font/fab-icons.eot?66843222');
src: url('../font/fab-icons.eot?66843222#iefix') format('embedded-opentype'),
url('../font/fab-icons.woff2?66843222') format('woff2'),
url('../font/fab-icons.woff?66843222') format('woff'),
url('../font/fab-icons.ttf?66843222') format('truetype'),
url('../font/fab-icons.svg?66843222#fab-icons') format('svg');
font-weight: normal;
font-style: normal;
}
.fab-icon:before {
font-family: "fab-icons";
font-style: normal;
font-weight: normal;
speak: none;
display: inline-block;
text-decoration: inherit;
width: 1em;
margin-right: .2em;
margin-left:0;
text-align: center;
font-variant: normal;
text-transform: none;
line-height: 1em;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.fab-pencil-neg:before { content: '\e800'; }
.fab-resize-full:before { content: '\e801'; }
.fab-cog:before { content: '\e802'; }
.fab-equalizer:before { content: '\e803'; }
.fab-block:before { content: '\e804'; }
.fab-brush:before { content: '\e805'; }
.fab-user:before { content: '\e806'; }
.fab-eye:before { content: '\e807'; }
.fab-cw:before { content: '\e808'; }
/* IE7 hack @since v1.2 - Assumes Modernizr is loaded and that test is run */
.ie8compat .fab-pencil-neg { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '&#xe800;&nbsp;'); }
.ie8compat .fab-resize-full { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '&#xe801;&nbsp;'); }
.ie8compat .fab-cog { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '&#xe802;&nbsp;'); }
.ie8compat .fab-equalizer { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '&#xe803;&nbsp;'); }
.ie8compat .fab-block { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '&#xe804;&nbsp;'); }
.ie8compat .fab-brush { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '&#xe805;&nbsp;'); }
.ie8compat .fab-user { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '&#xe806;&nbsp;'); }
.ie8compat .fab-eye { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '&#xe807;&nbsp;'); }
.ie8compat .fab-cw { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '&#xe808;&nbsp;'); }

/* in case of no Bootstrap - since v0.7 */
.no-bs .btn{ opacity:0.8; -moz-user-select: none; -webkit-user-select:none; -ms-user-select: none; background-image: none; border-radius: 4px; cursor: pointer; font-size: 16px; line-height:22px; font-weight: normal; padding: 6px 12px; vertical-align: middle; white-space: nowrap; text-transform:none; letter-spacing:normal;}
.no-bs .btn{ margin-left:0; opacity:0.8; -moz-user-select: none; -webkit-user-select:none; -ms-user-select: none; background-image: none; border-radius: 4px; cursor: pointer; font-size: 16px; line-height:22px; font-weight: normal; padding: 6px 12px; vertical-align: middle; white-space: nowrap; text-transform:none; letter-spacing:normal;}
.no-bs a.btn:hover{opacity:1;}
.no-bs .btn .genericon{font-size:22px; line-height:22px; vertical-align:middle;}
.no-bs .btn-block { display: block; width: 100%;}
.no-bs .btn-default { background-color: #f6f6f6; border-color: #999; color: #333;}
.no-bs .btn-default { background-color: #f6f6f6; border-color: #ccc; color: #444;}
.no-bs .btn-info { background-color: #5bc0de; border-color: #46b8da; color: #fff;}
.no-bs .btn-primary { background-color: #007acc; border-color: #0171bc; color: #fff;}
.no-bs .btn-danger { background-color: #d9534f; border-color: #d43f3a; color: #fff;}
Expand All @@ -24,12 +73,14 @@
.jdm-fab{-webkit-transition: all 300ms ease; -moz-transition: all 300ms ease;-ms-transition: all 300ms ease;-o-transition: all 300ms ease;transition: all 300ms ease;}
.admin-btns-wrapper .btn{font-family:"Open Sans",sans-serif; margin-bottom:2px; margin-right:0; text-align:left; line-height:2; border-top-right-radius:0; border-bottom-right-radius:0;}
.admin-btns-wrapper .btn span{margin-right:15px; margin-left:5px;}
.jdm-fab .genericon{height:1em; width:1em;}

.jdm-fab, .jdm-fab:hover, .jdm-fab:focus, .jdm-fab:active{-moz-transform: translateX(115px);-webkit-transform: translateX(115px);-o-transform: translateX(115px);-ms-transform: translateX(115px);transform: translateX(115px);}
.jdm-fab.fontawesome {-moz-transform: translateX(125px);-webkit-transform: translateX(125px);-o-transform: translateX(115px);-ms-transform: translateX(125px);transform: translateX(125px);}
.jdm-fab.genericons {-moz-transform: translateX(105px);-webkit-transform: translateX(105px);-o-transform: translateX(105px);-ms-transform: translateX(105px);transform: translateX(105px);}
.jdm-fab.genericons {-moz-transform: translateX(115px);-webkit-transform: translateX(115px);-o-transform: translateX(115px);-ms-transform: translateX(115px);transform: translateX(115px);}
.jdm-fab.fab-icons {-moz-transform: translateX(120px);-webkit-transform: translateX(120px);-o-transform: translateX(120px);-ms-transform: translateX(120px);transform: translateX(120px);}

.jdm-fab.genericons.has-hover, .jdm-fab.fontawesome.has-hover, .jdm-fab.has-hover, .no-js .jdm-fab:hover{opacity:1;-moz-transform: translateX(0);-webkit-transform: translateX(0);-o-transform: translateX(0);-ms-transform: translateX(0);transform: translateX(0);}
.jdm-fab.genericons.has-hover, .jdm-fab.fontawesome.has-hover, .jdm-fab.fab-icons.has-hover, .jdm-fab.has-hover, .no-js .jdm-fab:hover{opacity:1;-moz-transform: translateX(0);-webkit-transform: translateX(0);-o-transform: translateX(0);-ms-transform: translateX(0);transform: translateX(0);}


#fab-admin-btns.not-ready{opacity:0;}
#fab-admin-btns.not-ready{opacity:0;}
64 changes: 64 additions & 0 deletions font/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"name": "fab-icons",
"css_prefix_text": "fab-",
"css_use_suffix": false,
"hinting": true,
"units_per_em": 1000,
"ascent": 850,
"glyphs": [
{
"uid": "e3e12be877eab92e593ca185223e7a5b",
"css": "pencil-neg",
"code": 59392,
"src": "iconic"
},
{
"uid": "4815ddddea76d90e367a9694a93b7e24",
"css": "resize-full",
"code": 59393,
"src": "iconic"
},
{
"uid": "e3699d145bd628d2a35d4a508b616f0c",
"css": "equalizer",
"code": 59395,
"src": "iconic"
},
{
"uid": "fc94b92194752796654c96c7b7dccebb",
"css": "cog",
"code": 59394,
"src": "iconic"
},
{
"uid": "7cf0c6fefa5327473dec91427434ae26",
"css": "block",
"code": 59396,
"src": "iconic"
},
{
"uid": "b3a9e2dab4d19ea3b2f628242c926bfe",
"css": "brush",
"code": 59397,
"src": "iconic"
},
{
"uid": "86ee1fc7ff57e9c9c60d8a5e57183776",
"css": "user",
"code": 59398,
"src": "iconic"
},
{
"uid": "fbb01025c73ffb726bf28b98619df36d",
"css": "eye",
"code": 59399,
"src": "iconic"
},
{
"uid": "5889f24614ead600acce1af6a861b97c",
"css": "cw",
"code": 59400,
"src": "iconic"
}
]
}
Binary file added font/fab-icons.eot
Binary file not shown.
28 changes: 28 additions & 0 deletions font/fab-icons.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added font/fab-icons.ttf
Binary file not shown.
Binary file added font/fab-icons.woff
Binary file not shown.
Binary file added font/fab-icons.woff2
Binary file not shown.
96 changes: 78 additions & 18 deletions jdm-frontend-admin-buttons.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
/**
* Plugin Name: JDM Frontend Admin Buttons
* Plugin URI: http://labs.jdmdigital.co/code/frontend-admin-buttons/
* Plugin URI: http://jdmdig.it/jdm-fab
* Description: JDM Frontend Admin Buttons is a lightweight WordPress plugin that hides the default Admin Bar and replaces it with out of the way, contextually-aware, floating buttons for basic admin tasks.
* Version: 1.1
* Version: 1.2
* Author: JDM Digital
* Author URI: http://jdmdigital.co
* License: GPLv2 or later
Expand All @@ -15,10 +15,10 @@
if(!function_exists('jdmfab_enqueued_assets')) {
add_action( 'wp_enqueue_scripts', 'jdmfab_enqueued_assets' );
function jdmfab_enqueued_assets() {
//wp_enqueue_style( 'bootstrap', '//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css' );
if(is_user_logged_in() && current_user_can('edit_pages') ) {
wp_enqueue_style( 'jdm-fab', plugin_dir_url( __FILE__ ) . 'css/jdm-fab.css' );
wp_enqueue_script( 'jdm-fab', plugin_dir_url( __FILE__ ) . 'js/jdm-fab.js', array( 'jquery' ), '', true );
// changed in Fix #10 - if(is_user_logged_in() && current_user_can('edit_pages') ) {
if(is_user_logged_in()) {
wp_enqueue_style( 'jdm-fab', plugin_dir_url( __FILE__ ) . 'css/jdm-fab.css', array(), null, 'screen' );
wp_enqueue_script( 'jdm-fab', plugin_dir_url( __FILE__ ) . 'js/jdm-fab.js', array( 'jquery' ), null, true );
}
}
}
Expand All @@ -36,17 +36,20 @@ function jdm_fab_hide_admin_bar_settings() {
<?php
}
}
function jdm_fab_disable_admin_bar() {
add_filter( 'show_admin_bar', '__return_false' );
add_action( 'admin_print_scripts-profile.php', 'jdm_fab_hide_admin_bar_settings' );

if(!function_exists('jdm_fab_disable_admin_bar')) {
function jdm_fab_disable_admin_bar() {
add_filter( 'show_admin_bar', '__return_false' );
add_action( 'admin_print_scripts-profile.php', 'jdm_fab_hide_admin_bar_settings' );
}
add_action( 'init', 'jdm_fab_disable_admin_bar' , 9 );
}
add_action( 'init', 'jdm_fab_disable_admin_bar' , 9 );

include_once( ABSPATH . 'wp-admin/includes/plugin.php' );

// If Visual Composer Plugin is active, return the edit front-page link.
if(!function_exists('jdm_edit_with_vc')) {
function jdm_edit_with_vc(){
function jdm_edit_with_vc($icon_prefix = 'glyphicon'){
global $page, $post;
$id = $post->ID;
$adminURL = admin_url();
Expand All @@ -61,7 +64,7 @@ function jdm_edit_with_vc(){
$vcEditlink = $adminURL.'post.php?vc_action=vc_inline&amp;post_id='.$id.'&amp;post_type='.$type;

if($vc) {
return '<a id="fab-vcedit" href="'.$vcEditlink.'" class="btn btn-block btn-warning"><span class="glyphicon glyphicon-fullscreen genericon genericon-maximize"></span> Visual Editor</a>';
return '<a id="fab-vcedit" href="'.$vcEditlink.'" class="btn btn-block btn-warning"><span class="glyphicon glyphicon-fullscreen genericon genericon-maximize fab-icon fab-brush"></span> Visual Editor</a>';
}

}
Expand All @@ -72,22 +75,25 @@ function jdm_edit_with_vc(){
add_action( 'wp_footer', 'jdmfab_show_admin_buttons', 5 );

function jdmfab_show_admin_buttons() {
$bootstrapclass = true;
if(wp_style_is('bootstrap')) {
$fabclass = 'jdm-fab bs';
$fabclass = 'jdm-fab bs';
} elseif(wp_style_is('bootstrap-css')) {
$fabclass = 'jdm-fab bs';
} elseif(wp_style_is('bootstrap-style')) {
$fabclass = 'jdm-fab bs';
} else {
// Bootstrap CSS not enqueued
// Bootstrap CSS not enqueued (we don't think)
$fabclass = 'jdm-fab no-bs';
$bootstrapclass = false;
}

if(wp_style_is('fontawesome')) {
$icon_prefix = 'fa';
$icon_edit = 'fa-pencil';
$icon_customize = 'fa-paint-brush';
$icon_admin = 'fa-cog';
$icon_profile = 'fa-user';
$icon_close = 'fa-eye-slash';
$icon_logout = 'fa-power-off';
$fabclass .= ' fontawesome';
Expand All @@ -97,25 +103,35 @@ function jdmfab_show_admin_buttons() {
$icon_edit = 'genericon-edit';
$icon_customize = 'genericon-maximize';
$icon_admin = 'genericon-cog';
$icon_profile = 'genericon-user';
$icon_close = 'genericon-close';
$icon_logout = 'genericon-unapprove';
} else {
} elseif($bootstrapclass) {
$fabclass .= ' glyphicons';
$icon_prefix = 'glyphicon';
$icon_edit = 'glyphicon-edit';
$icon_customize = 'glyphicon-fullscreen bp-link';
$icon_admin = 'glyphicon-cog';
$icon_profile = 'glyphicon-user';
$icon_close = 'glyphicon-eye-close';
$icon_logout = 'glyphicon-log-out';
} else {
$fabclass .= ' fab-icons';
$icon_prefix = 'fab-icon';
$icon_edit = 'fab-pencil-neg';
$icon_customize = 'fab-equalizer';
$icon_admin = 'fab-cog';
$icon_profile = 'fab-user';
$icon_close = 'fab-eye';
$icon_logout = 'fab-cw';
}

if( current_user_can('edit_others_pages') ) {
$adminurl = get_admin_url();

// Admin/Super-Admin Roles
$html = '<div id="fab-admin-btns" class="not-ready '.$fabclass.'">';
$html .= ' <div class="admin-btns-wrapper">';

// Several If/else statements here to make sure these look good.
$html .= ' <button id="hide-admin-buttons" type="button" class="btn btn-block btn-default"><span class="'.$icon_prefix.' '.$icon_close.'"></span> Hide Btns</button>';

if(is_page()) {
Expand Down Expand Up @@ -145,8 +161,52 @@ function jdmfab_show_admin_buttons() {
$html .= ' </div>';
$html .= '</div>';

echo $html;

} elseif (current_user_can('edit_posts')) {
// "Author" Role
$html = '<div id="fab-admin-btns" class="not-ready '.$fabclass.'">';
$html .= ' <div class="admin-btns-wrapper">';

$html .= ' <button id="hide-admin-buttons" type="button" class="btn btn-block btn-default"><span class="'.$icon_prefix.' '.$icon_close.'"></span> Hide Btns</button>';

if(is_single()) {
$html .= ' <a id="fab-post" href="'. get_edit_post_link().'" class="btn btn-block btn-info"><span class="'.$icon_prefix.' '.$icon_edit.'"></span> Edit Post</a>';
} else {
$html .= ' <a id="fab-else" href="'. get_edit_post_link().'" class="btn btn-block btn-info"><span class="'.$icon_prefix.' '.$icon_edit.'"></span> Edit This</a>';
}

if(is_plugin_active('js_composer/js_composer.php')) {
$html .= ' '.jdm_edit_with_vc();
} else {
if ( current_user_can( 'customize' ) ) {
$html .= ' <a id="fab-customize" href="'. get_admin_url().'customize.php?return='.get_permalink().'" class="btn btn-block btn-warning"><span class="'.$icon_prefix.' '.$icon_customize.'"></span> Customize</a>';
}
}

$html .= ' <a id="fab-wpadmin" href="'. get_edit_user_link().'" class="btn btn-block btn-primary"><span class="'.$icon_prefix.' '.$icon_profile.'"></span> Edit Profile</a>';
$html .= ' <a id="fab-logout" href="'. wp_logout_url( get_permalink() ).'" class="btn btn-block btn-danger"><span class="'.$icon_prefix.' '.$icon_logout.'"></span> Logout</a>';

$html .= ' </div>';
$html .= '</div>';

echo $html;

} elseif (current_user_can('read')) {
// Subscriber Role
$html = '<div id="fab-admin-btns" class="not-ready '.$fabclass.'">';
$html .= ' <div class="admin-btns-wrapper">';

$html .= ' <button id="hide-admin-buttons" type="button" class="btn btn-block btn-default"><span class="'.$icon_prefix.' '.$icon_close.'"></span> Hide Btns</button>';

$html .= ' <a id="fab-wpadmin" href="'. get_edit_user_link().'" class="btn btn-block btn-primary"><span class="'.$icon_prefix.' '.$icon_profile.'"></span> Edit Profile</a>';
$html .= ' <a id="fab-logout" href="'. wp_logout_url( get_permalink() ).'" class="btn btn-block btn-danger"><span class="'.$icon_prefix.' '.$icon_logout.'"></span> Logout</a>';

$html .= ' </div>';
$html .= '</div>';

echo $html;
}

}
}

0 comments on commit 0356b03

Please sign in to comment.