Skip to content

Instantly share code, notes, and snippets.

View hlashbrooke's full-sized avatar
🎲

Hugh Lashbrooke hlashbrooke

🎲
View GitHub Profile
@hlashbrooke
hlashbrooke / style.css
Created April 10, 2013 13:22
CSS transforms on catherinelashbrooke.com
#polaroid1 {
top: 55px;
left: 44px;
transform: rotate(-10deg);
-webkit-transform: rotate(-10deg);
-ms-transform: rotate(-10deg);
-moz-transform: rotate(-10deg);
-o-transform: rotate(-10deg);
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1.5);
}
@hlashbrooke
hlashbrooke / function.php
Created June 26, 2013 12:01
Adding filter to woocommerce_prevent_admin_access()
function woocommerce_prevent_admin_access() {
$prevent_access = false;
if ( get_option('woocommerce_lock_down_admin') == 'yes' && ! is_ajax() && ! ( current_user_can('edit_posts') || current_user_can('manage_woocommerce') ) ) {
$prevent_access = true;
}
$prevent_access = apply_filters( 'woocommerce_prevent_admin_access', $prevent_access );
@hlashbrooke
hlashbrooke / function.php
Last active September 17, 2020 21:53
WooCommerce Product Vendors: Change vendor URL slug
add_filter( 'product_vendors_vendor_slug', 'change_vendor_url_slug' );
function change_vendor_url_slug( $slug ) {
$slug = 'new_url';
return $slug;
}
@hlashbrooke
hlashbrooke / snippet.php
Last active December 19, 2015 12:29
WooThemes Tweets widget
<?php if ( $woo_options['woo_twitter'] ) { ?>
<div id="twitter"<?php if ( $woo_options['woo_sub'] <> "true" ) echo ' class="twitter-if"'; ?>>
<a href="http://www.twitter.com/<?php echo urlencode( $woo_options['woo_twitter'] ); ?>" title="<?php esc_attr_e( 'Follow us on Twitter', 'woothemes' ); ?>" class="fl" ><img src="<?php bloginfo('template_directory'); ?>/images/ico-twitter.png" alt="" /></a>
<?php if ( class_exists( 'WooDojo_Widget_Tweets' ) ) {
the_widget( 'WooDojo_Widget_Tweets', array( 'twitter_handle' => esc_attr( $woo_options['woo_twitter'] ), 'limit' => 1, array( 'before_widget' => '<div id="twitter_update_list" class="twitter_container">', 'after_widget' => '</div>' ) );
} ?>
</div>
<?php } ?>
@hlashbrooke
hlashbrooke / function.php
Created July 12, 2013 11:00
PHP function to easily generate a month select box
<?php
function month_select_box( $field_name = 'month' ) {
$month_options = '';
for( $i = 1; $i <= 12; $i++ ) {
$month_num = str_pad( $i, 2, 0, STR_PAD_LEFT );
$month_name = date( 'F', mktime( 0, 0, 0, $i + 1, 0, 0, 0 ) );
$month_options .= '<option value="' . esc_attr( $month_num ) . '">' . $month_name . '</option>';
}
return '<select name="' . $field_name . '">' . $month_options . '</select>';
}
@hlashbrooke
hlashbrooke / .gitignore
Created July 12, 2013 11:02
A .gitignore file for multiple site in one repo
.htaccess
wp-admin/
wp-includes/
wp-config.php
*/wp-content/uploads/
*/wp-content/blogs.dir/
*/wp-content/upgrade/
*/wp-content/backup-db/
*/wp-content/advanced-cache.php
*/wp-content/wp-cache-config.php
@hlashbrooke
hlashbrooke / function.js
Created July 12, 2013 11:03
Simple animated scroll for jQuery
function scrollToElement( target ) {
var topoffset = 30;
var speed = 800;
var destination = jQuery( target ).offset().top - topoffset;
jQuery( 'html:not(:animated),body:not(:animated)' ).animate( { scrollTop: destination}, speed, function() {
window.location.hash = target;
});
return false;
}
@hlashbrooke
hlashbrooke / function.js
Created July 12, 2013 11:03
Simplest jQuery method for selecting all checkboxes in a form
$( '.selectall' ).click( function () {
$( this ).closest( 'form' ).find( ':checkbox' ).attr( 'checked' , this.checked );
});
@hlashbrooke
hlashbrooke / add_widget_area.php
Created July 12, 2013 11:10
WordPress: Create a new widget area
<?php
function register_widget_area() {
register_sidebar( array(
'name' => 'Widget Area Name',
'id' => 'new_widget_area',
'before_widget' => '<div class="widget">',
'after_widget' => '</div>',
'before_title' => '<h1 class="title">',
'after_title' => '</h1>',
) );
@hlashbrooke
hlashbrooke / function.php
Created July 12, 2013 11:13
WordPress: Add plugin settings link to plugins list table
<?php
function plugin_add_settings_link( $links ) {
$settings_link = '<a href="options-general.php?page=plugin_name">' . __( 'Settings' ) . '</a>';
array_push( $links, $settings_link );
return $links;
}
$plugin = plugin_basename( __FILE__ );
add_filter( "plugin_action_links_$plugin", 'plugin_add_settings_link' );
?>