Skip to content

Commit

Permalink
Merge pull request #1 from jdmdigital/develop
Browse files Browse the repository at this point in the history
Support non-Bootstrap
  • Loading branch information
jdmdigital committed Apr 1, 2016
2 parents e97022a + 720cb89 commit 2e56737
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 19 deletions.
25 changes: 21 additions & 4 deletions css/jdm-fab.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
/* JDM FAB Styles */
.jdm-fab{width:170px; position:fixed; top:60px; right:0; opacity:0.8;-webkit-transition: all 300ms ease; -moz-transition: all 300ms ease;-ms-transition: all 300ms ease;-o-transition: all 300ms ease;transition: all 300ms ease;}

/* in case 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 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-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;}

.no-bs .btn-default:hover, .no-bs .btn-default:focus { opacity:1; background-color: #f1f1f1; border-color: #999; color: #222;}
.no-bs .btn-info:hover, .no-bs .btn-info:focus { opacity:1; background-color: #46b8da; border-color: #46b8da; color: #fff;}
.no-bs .btn-primary:hover, .no-bs .btn-primary:focus { opacity:1; background-color: #0171bc; border-color: #0171bc; color: #fff;}
.no-bs .btn-danger:hover, .no-bs .btn-danger:focus { opacity:1; background-color: #d43f3a; border-color: #d43f3a; color: #fff;}

/* general styles */
.jdm-fab{width:170px; position:fixed; top:60px; right:0; opacity:0.7;-webkit-transition: all 300ms ease; -moz-transition: all 300ms ease;-ms-transition: all 300ms ease;-o-transition: all 300ms ease;transition: all 300ms ease;}
.home .jdm-fab{ top:105px;}
.jdm-fab:hover{opacity:1;-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;}
.jdm-fab:hover{-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{-moz-transform: translateX(115px);-webkit-transform: translateX(115px);-o-transform: translateX(115px);-ms-transform: translateX(115px);transform: translateX(115px);}
.jdm-fab{opacity:1;-moz-transform: translateX(115px);-webkit-transform: translateX(115px);-o-transform: translateX(115px);-ms-transform: translateX(115px);transform: translateX(115px);}
.jdm-fab:hover, #admin-btns:focus, #admin-btns:active{-moz-transform: translateX(0);-webkit-transform: translateX(0);-o-transform: translateX(0);-ms-transform: translateX(0);transform: translateX(0);}

53 changes: 42 additions & 11 deletions jdm-frontend-admin-buttons.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: JDM Frontend Admin Buttons
* Plugin URI: https://github.com/jdmdigital/jdm-frontend-admin-buttons/
* 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: 0.6
* Version: 0.7
* Author: JDM Digital
* Author URI: http://jdmdigital.co
* License: GPLv2 or later
Expand Down Expand Up @@ -59,7 +59,7 @@ function jdm_edit_with_vc(){
$vcEditlink = $adminURL.'post.php?vc_action=vc_inline&post_id='.$id.'&post_type='.$type;

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

}
Expand All @@ -70,34 +70,65 @@ function jdm_edit_with_vc(){
add_action( 'wp_footer', 'jdmfab_show_admin_buttons', 5 );

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

if(wp_style_is('fontawesome')) {
$icon_prefix = 'fa';
$icon_edit = 'fa-pencil';
$icon_admin = 'fa-cog';
$icon_close = 'fa-eye-slash';
$icon_logout = 'fa-power-off';
} elseif (wp_style_is('genericons')) {
$icon_prefix = 'genericon';
$icon_edit = 'genericon-edit';
$icon_admin = 'genericon-cog';
$icon_close = 'genericon-close';
$icon_logout = 'genericon-unapprove';
} else {
$icon_prefix = 'glyphicon';
$icon_edit = 'glyphicon-edit';
$icon_admin = 'glyphicon-cog';
$icon_close = 'glyphicon-eye-close';
$icon_logout = 'glyphicon-log-out';
}

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

$html = '<div id="fab-admin-btns" class="jdm-fab">';
$html = '<div id="fab-admin-btns" class="'.$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="glyphicon glyphicon-eye-close"></span> Hide Btns</button>';
$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()) {
$html .= ' <a href="'. get_edit_post_link().'" class="btn btn-block btn-info"><span class="glyphicon glyphicon-edit"></span> Edit Page</a>';
$html .= ' <a href="'. get_edit_post_link().'" class="btn btn-block btn-info"><span class="'.$icon_prefix.' '.$icon_edit.'"></span> Edit Page</a>';
} elseif(is_front_page() || is_home()) {
$html .= ' <a href="'. get_edit_post_link().'" class="btn btn-block btn-info"><span class="glyphicon glyphicon-edit"></span> Edit Home</a>';
$html .= ' <a href="'. get_edit_post_link().'" class="btn btn-block btn-info"><span class="'.$icon_prefix.' '.$icon_edit.'"></span> Edit Home</a>';
} elseif(is_single()) {
$html .= ' <a href="'. get_edit_post_link().'" class="btn btn-block btn-info"><span class="glyphicon glyphicon-edit"></span> Edit Post</a>';
$html .= ' <a href="'. get_edit_post_link().'" class="btn btn-block btn-info"><span class="'.$icon_prefix.' '.$icon_edit.'"></span> Edit Post</a>';
} elseif(is_category()) {
$catid = get_query_var('cat');
$html .= ' <a href="'.$adminurl.'edit-tags.php?action=edit&taxonomy=category&tag_ID='.$catid.'&post_type=post" class="btn btn-block btn-info"><span class="glyphicon glyphicon-edit"></span> Edit Category</a>';
$html .= ' <a href="'.$adminurl.'edit-tags.php?action=edit&taxonomy=category&tag_ID='.$catid.'&post_type=post" class="btn btn-block btn-info"><span class="'.$icon_prefix.' '.$icon_edit.'"></span> Edit Category</a>';
} else {
$html .= ' <a href="'. get_edit_post_link().'" class="btn btn-block btn-info"><span class="glyphicon glyphicon-edit"></span> Edit This</a>';
$html .= ' <a 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();
}

$html .= ' <a href="'. network_admin_url().'" class="btn btn-block btn-primary"><span class="glyphicon glyphicon-cog"></span> WP Admin</a>';
$html .= ' <a href="'. wp_logout_url( get_permalink() ).'" class="btn btn-block btn-danger"><span class="glyphicon glyphicon-log-out"></span> Logout</a>';
$html .= ' <a href="'. network_admin_url().'" class="btn btn-block btn-primary"><span class="'.$icon_prefix.' '.$icon_admin.'"></span> WP Admin</a>';
$html .= ' <a 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>';
Expand Down
6 changes: 3 additions & 3 deletions js/jdm-fab.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$( document ).ready(function() {
$('#hide-admin-buttons').click(function() {
$('#fab-admin-btns').fadeOut();
jQuery( document ).ready(function() {
jQuery('#hide-admin-buttons').click(function() {
jQuery('#fab-admin-btns').fadeOut();
});
});
8 changes: 7 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: http://jdmdigital.co
Tags: administration, admin, frontend, buttons.
Requires at least: 3.0.1
Tested up to: 4.4.2
Stable tag: 0.6
Stable tag: 0.7
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -38,6 +38,12 @@ TBD

== Upgrade Notice ==

= 0.7 =
* Test if Bootstrap enqueued
* jdm-fab.css file updated
* add support for genericons and fontawesome
* Version Bump

= 0.6 =
* First well-tested version
* version Bump
Expand Down

0 comments on commit 2e56737

Please sign in to comment.