Skip to content

Instantly share code, notes, and snippets.

Sam Holguin samholguin

Block or report user

Report or block samholguin

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
@samholguin
samholguin / wc-add-admin-page-endpoint.php
Created Apr 10, 2018
WordPress - add admin page endpoint
View wc-add-admin-page-endpoint.php
/**
* Account menu items.
*
* @param arr $items
*
* @return arr
*/
function swd_account_menu_items($items)
{
$items['profile'] = 'Profile';
@samholguin
samholguin / htaccess-rules
Last active Aug 29, 2015
.htaccess Rules
View htaccess-rules
Negative lookahead based rule:
RewriteRule ^products/(?!certain-category).*$ http://shop.newurl.co.uk/ [NC,L,R=301]
(?!certain-category) is a negative lookahead that will fail the match if certain-category comes right after /products/ in URL.
RedirectMatch 301 /products(.*) http://shop.sunwise.co.uk/
Redirect 301 /shop http://shop.sunwise.co.uk
@samholguin
samholguin / wp-process-remove_unwanted_shortcode_tags
Created Jun 27, 2015
WordPress - Remove empty <p> tags and <br> tags from shortcodes
View wp-process-remove_unwanted_shortcode_tags
remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );
function wpse_wpautop_nobr( $content ) {
return wpautop( $content, false );
}
add_filter( 'the_content', 'remove_empty_p', 20, 1 );
function remove_empty_p( $content ){
// clean up p tags around block elements
@samholguin
samholguin / wp-filter-add_custom_image_sizes
Last active Aug 29, 2015
WordPress - Filter [ image_size_names_choose ] - Adding Custom Images Sizes to the WordPress Media Library
View wp-filter-add_custom_image_sizes
/**
* Adding Custom Images Sizes to the WordPress Media Library
*
* @access public
* @param array $sizes
* @return array
*/
function shgist_add_image_sizes($sizes) {
$addsizes = array(
"new-size" => __( "New Size")
@samholguin
samholguin / wp-action-modify_the_post_object
Last active Aug 29, 2015
WordPress - Action [ the_post ] - Modify the WordPress post object
View wp-action-modify_the_post_object
/**
* Modify the WordPress post object
*
* @param obj $post_object
* @return obj
*/
function shgist_my_the_post_action( $post_object ) {
// modify post object here
}
add_action( 'the_post', 'shgist_my_the_post_action' );
@samholguin
samholguin / wp-filter-modify_nav_menu_objects
Last active Aug 29, 2015
WordPress - Filter [ wp_nav_menu_objects ] - Modify WordPress nav menu objects
View wp-filter-modify_nav_menu_objects
/**
* Modify WordPress nav menu objects
*
* @param array $menu_items
* @return array
*/
function shgist_nav_menu_item_classes( $menu_items ) {
foreach ( (array) $menu_items as $key => $menu_item ) {
// Work on menu item objects
@samholguin
samholguin / wp-func-get_child_pages
Last active Aug 29, 2015
WordPress - Function - Get child pages
View wp-func-get_child_pages
/**
* Get child pages
*
* @access public
* @return array
*/
function shgist_get_child_pages() {
global $post;
$args = array(
You can’t perform that action at this time.