Skip to content

Instantly share code, notes, and snippets.

View steppohub's full-sized avatar

Steppo steppohub

View GitHub Profile
<?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 January 22, 2015 23:18
order posts (woocommerce products) alphabetically but ignore certain words, eg 'The' and 'An'
/**
* 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 December 23, 2014 03:45
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 December 8, 2014 03:11
editor styles adding
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 December 2, 2014 00:51
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 November 27, 2014 22:53
Remove annoying (problematic!) default password nag that doesn't disappear
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 / rename posts
Last active August 29, 2015 14:09
Re-name posts to something different
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 / add new custom post type
Last active August 29, 2015 14:09
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 / add custom taxonomy for custom post type
Created November 13, 2014 00:15
Add custom taxonomy for a 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 / editor-hide
Created November 3, 2014 01:52
Hide Editor on specific pages
<?php
/**
* Hide editor on specific pages.
*
*/
function hide_editor() {
global $pagenow;
if( !( 'post.php' == $pagenow ) ) return;