Skip to content

Instantly share code, notes, and snippets.

View danielhomer's full-sized avatar

Daniel Homer danielhomer

View GitHub Profile
@danielhomer
danielhomer / gist:10739957
Last active August 29, 2015 13:59
BBWF Social Bar CSS
.social-bar {
position: fixed;
left: 0;
top: 260px;
font-size: 1.5em;
z-index: 1000;
}
.social-bar.horizontal {
bottom: 0;
@danielhomer
danielhomer / gist:10739996
Last active August 29, 2015 13:59
BBWF Social Bar Markup
<div class="hidden-xs social-bar horizontal">
<ul class="social-buttons">
<li class="linkedin first">
<a target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&url={articleUrl}&title={articleTitle}&summary={articleSummary}&source={articleSource}" title="Share on LinkedIn"><span class="fa fa-linkedin"></span></a>
</li>
<li class="twitter">
<a href="#" title="Share on Twitter"><span class="fa fa-twitter"></span></a>
</li>
<li class="facebook">
<a href="#" title="Share on Facebook"><span class="fa fa-facebook"></span></a>
@danielhomer
danielhomer / functions.php
Last active August 29, 2015 14:05
WordPress pretty timestamp function. 'Posted 1 day ago' / 'Posted 2 hours ago' etc.
/**
* Echoes a pretty timestamp if the post is younger than max_days.
* Must be used inside the loop.
*
* Examples:
* - Posted 3 days ago
* - Posted 12 hours ago
* - Posted 5 minutes ago
* - Posted just now (less than a minute ago)
* - 2014-07-25 08:33:54 (post is older than $max_days)
@danielhomer
danielhomer / gist:44dd62b68c0a2244f767
Created February 11, 2015 15:17
Force login on WP
<?php
function force_login() {
if ( ! is_user_logged_in() ) {
wp_safe_redirect( wp_login_url(), 301 );
exit();
}
}
add_action( 'template_redirect', 'force_login' );
<?php
add_filter( 'check_less_compile', function( $value ) {
if ( defined( 'KEYSTONE_CACHE_BUST' ) && KEYSTONE_CACHE_BUST ) {
$less_cache_bust = get_option( 'less_cache_bust', false );
if ( $less_cache_bust === KEYSTONE_CACHE_BUST ) {
$value = false;
} else {
update_option( 'less_cache_bust', KEYSTONE_CACHE_BUST );
(function($) {
$.ajax({
url: ajaxurl,
action: 'my_wp_ajax_action'
})
.success(function(response) {
if (typeof response.success === 'undefined') {
// undefined error
} else if (response.success === false) {
$(document).on('click', 'keystone_newsletter_delete_image', function(event) {
var image = $('#'+$(this).attr('data-image'));
var input = $('#'+$(this).attr('data-input'));
input.val('');
image.attr('src','');
});
@danielhomer
danielhomer / gist:10dd2015e0e91f81bf05
Created November 3, 2015 11:00
Update Guest Additions to 5.0.2 on CentOS
vagrant ssh
cd /opt
sudo wget -c http://download.virtualbox.org/virtualbox/5.0.2/VBoxGuestAdditions_5.0.2.iso -O VBoxGuestAdditions_5.0.2.iso
sudo mount VBoxGuestAdditions_5.0.2.iso -o loop /mnt
cd /mnt
sudo sh VBoxLinuxAdditions.run --nox11
cd /opt
sudo /etc/init.d/vboxadd setup
sudo chkconfig --add vboxadd
sudo chkconfig vboxadd on
cd /path/to/root
for url in $(wp site list --field=domain)
do
echo ${url}
wp --url=${url} option update db_version 30133
echo
done
wp --url=${url} core update-db --network
cd /path/to/root
for id in $(wp site list --field=blog_id)
do
echo ${id}
mysql -h##HOST## -u##USER## -p##PASSWORD## -e "DELETE FROM wp_${id}_postmeta WHERE meta_key LIKE '_oembed_%' and meta_key NOT LIKE '_oembed_time_%' and meta_value NOT LIKE '%>' AND meta_value != '{{unknown}}';" ##DB_NAME##
echo Flushed dodgy OEmbeds from site ${id}
done