Skip to content

Instantly share code, notes, and snippets.

Steppo steppohub

Block or report user

Report or block steppohub

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Groups vs Woo code (doesn't work)
<?php $user_id = get_current_user_id();
$groups_user = new Groups_User( $user_id );
$groups = $groups_user->groups;
$my_groups = array();
foreach($groups as $g) {
$my_groups[] = $g->name;
@steppohub
steppohub / Woocommerce alphabetical sorting with cool ignore 'the' and 'an' function
Created Jan 22, 2015
order posts (woocommerce products) alphabetically but ignore certain words, eg 'The' and 'An'
View Woocommerce alphabetical sorting with cool ignore 'the' and 'an' function
/**
* Cool orderby function from Monkey Puzzle. Adapted from:
* Tutorial: http://www.skyverge.com/blog/sort-woocommerce-products-custom-fields/
**/
function monkey_ordering_args( $sort_args ) {
$orderby_value = isset( $_GET['orderby'] ) ? woocommerce_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
switch( $orderby_value ) {
// Name your sortby key whatever you'd like; must correspond to the $sortby in the next function
@steppohub
steppohub / jquery scrolling goodness
Created Dec 23, 2014
jquery scrolling goodness
View jquery scrolling goodness
jquery scrolling goodness
jQuery(".scroll").click(function() {
var target = jQuery(this).attr("href");
jQuery("html, body").animate({
scrollTop: jQuery(target).offset().top}, 1000);
});
@steppohub
steppohub / editor style
Created Dec 8, 2014
editor styles adding
View editor style
function my_theme_add_editor_styles() {
add_editor_style( 'editor-style.css' );
}
add_action( 'after_setup_theme', 'my_theme_add_editor_styles' );
@steppohub
steppohub / Aussie gravity forms address
Created Dec 2, 2014
Aussie Gravity Forms address
View Aussie gravity forms address
// gravity form hacks
add_filter("gform_address_zip", "change_address_zip", 10, 2);
function change_address_zip($label, $form_id){
return "Postcode";
}
add_filter("gform_address_state", "change_address_state", 10, 2);
function change_address_state($label, $form_id){
return "State";
@steppohub
steppohub / Remove default password nag
Created Nov 27, 2014
Remove annoying (problematic!) default password nag that doesn't disappear
View Remove default password nag
add_action('admin_notices', 'aa99_delete_pass_nag', 1);
function aa99_delete_pass_nag() {
remove_action('admin_notices','default_password_nag');
}
function aa99_add_password_nag() {
global $pagenow;
if ( 'profile.php' == $pagenow || ! get_user_option('default_password_nag') )
return;
@steppohub
steppohub / add custom taxonomy for custom post type
Created Nov 13, 2014
Add custom taxonomy for a custom post type
View add custom taxonomy for custom post type
function my_taxonomies_news() {
$labels = array(
'name' => _x( 'News Categories', 'taxonomy general name' ),
'singular_name' => _x( 'News Category', 'taxonomy singular name' ),
'search_items' => __( 'Search News Categories' ),
'all_items' => __( 'All News Categories' ),
'parent_item' => __( 'Parent News Category' ),
'parent_item_colon' => __( 'Parent News Category:' ),
'edit_item' => __( 'Edit News Category' ),
'update_item' => __( 'Update News Category' ),
@steppohub
steppohub / add new custom post type
Last active Aug 29, 2015
Add new custom post type
View add new custom post type
function my_custom_post_product() {
$labels = array(
'name' => _x( 'Products', 'post type general name' ),
'singular_name' => _x( 'Product', 'post type singular name' ),
'add_new' => _x( 'Add New', 'book' ),
'add_new_item' => __( 'Add New Product' ),
'edit_item' => __( 'Edit Product' ),
'new_item' => __( 'New Product' ),
'all_items' => __( 'All Products' ),
'view_item' => __( 'View Product' ),
@steppohub
steppohub / rename posts
Last active Aug 29, 2015
Re-name posts to something different
View rename posts
function revcon_change_post_label() {
global $menu;
global $submenu;
$menu[5][0] = 'Books';
$submenu['edit.php'][5][0] = 'Books';
$submenu['edit.php'][10][0] = 'Add Books';
$submenu['edit.php'][16][0] = 'Books Tags';
echo '';
}
function revcon_change_post_object() {
@steppohub
steppohub / editor-hide
Created Nov 3, 2014
Hide Editor on specific pages
View editor-hide
<?php
/**
* Hide editor on specific pages.
*
*/
function hide_editor() {
global $pagenow;
if( !( 'post.php' == $pagenow ) ) return;
You can’t perform that action at this time.