Skip to content

Instantly share code, notes, and snippets.

Avatar

Hugh Lashbrooke hlashbrooke

View GitHub Profile
@hlashbrooke
hlashbrooke / style.css
Created Apr 10, 2013
CSS transforms on catherinelashbrooke.com
View style.css
#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 Jun 26, 2013
Adding filter to woocommerce_prevent_admin_access()
View function.php
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 Sep 17, 2020
WooCommerce Product Vendors: Change vendor URL slug
View function.php
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 Dec 19, 2015
WooThemes Tweets widget
View snippet.php
<?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 Jul 12, 2013
PHP function to easily generate a month select box
View function.php
<?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 Jul 12, 2013
A .gitignore file for multiple site in one repo
View .gitignore
.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 Jul 12, 2013
Simple animated scroll for jQuery
View function.js
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 Jul 12, 2013
Simplest jQuery method for selecting all checkboxes in a form
View function.js
$( '.selectall' ).click( function () {
$( this ).closest( 'form' ).find( ':checkbox' ).attr( 'checked' , this.checked );
});
@hlashbrooke
hlashbrooke / add_widget_area.php
Created Jul 12, 2013
WordPress: Create a new widget area
View add_widget_area.php
<?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 Jul 12, 2013
WordPress: Add plugin settings link to plugins list table
View function.php
<?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' );
?>