Last active
June 30, 2017 16:21
-
-
Save jb510/128315379654659fb019bf1787798974 to your computer and use it in GitHub Desktop.
Hello Bar (Offical) plugin for WordPress done properly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Hello Bar (Official - modified by 9seeds to only show when admin bar isn't and to WP code standards) | |
Plugin URI: http://www.hellobar.com | |
Description: Inserts your custom Hello Bar on mauitime.com. Because of the WordPress User Bar, you might need to log out and visit your WordPress site again to see your Hello Bar. Please note that this plugin is only valid for mauitime.com. If you want to edit your Hello Bar click "Visit plugin site" below. | |
Version: 1.0 | |
Author: Hello Bar | |
Author URI: http://www.hellobar.com | |
License: GPL v2 | |
This program is free software; you can redistribute it and/or modify | |
it under the terms of the GNU General Public License, version 2, as | |
published by the Free Software Foundation. | |
This program is distributed in the hope that it will be useful, | |
but WITHOUT ANY WARRANTY; without even the implied warranty of | |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
GNU General Public License for more details. | |
You should have received a copy of the GNU General Public License | |
along with this program; if not, write to the Free Software | |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
*/ | |
/* The "offical" Hello Bar script is poorly written and clobbers the WP admin bar, so bye bye */ | |
/* Offical garbage | |
function add_hellobar_script() { | |
echo "<script src=\"//my.hellobar.com/__some_really_long_hash__.js\" type=\"text/javascript\" async=\"async\"></script>"; | |
} | |
add_action( 'wp_footer', 'add_hellobar_script' ); | |
*/ | |
/** | |
* The proper way... | |
*/ | |
function s9_hellobar_script() { | |
if ( ! is_admin_bar_showing() ) { | |
wp_enqueue_script( 's9-hello-bar', 'https://my.hellobar.com/__some_really_long_hash__.js', '', '1.0', true ); | |
} | |
} | |
add_action( 'wp_enqueue_scripts', 's9_hellobar_script' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment