Skip to content

Instantly share code, notes, and snippets.

View DrewAPicture's full-sized avatar

Drew Jaynes DrewAPicture

View GitHub Profile
add_filter( 'rewrite_rules_array', function( $rules ) {
if ( ! function_exists( 'WC' ) || ! function_exists( 'affiliate_wp' ) ) {
return $rules;
}
if ( true === version_compare( WC()->version, '3.0.0', '>=' ) ) {
$permalinks = wc_get_permalink_structure();
} else {
$permalinks = get_option( 'woocommerce_permalinks' );
<?php
class Beer {
const NAME = 'Beer!';
public static function printed(){
echo 'static Beer:NAME = '. static::NAME . '<br />';
}
}
class Ale extends Beer {
@DrewAPicture
DrewAPicture / class-project-customizer.php
Last active February 18, 2016 04:55
Re-adding core menus and widgets panels back if removed via 'customizer_loaded_components' hook. Note rehooking the nav menus customize_register() method at a later priority.
<?php
require_once( ABSPATH . WPINC . '/class-wp-customize-widgets.php' );
$this->wp_customize->widgets = new WP_Customize_Widgets( $this->wp_customize );
require_once( ABSPATH . WPINC . '/class-wp-customize-nav-menus.php' );
$this->wp_customize->nav_menus = new WP_Customize_Nav_Menus( $this->wp_customize );
// Restore setup for nav menus (normally hooked at priority 11).
add_action( 'customize_register', array( $this->wp_customize->nav_menus, 'customize_register' ), 501 );
mysql -u wp -p wp -e "drop database wptests; create database wptests;"
<?php
/*
* If hierarchical is false, and child_of is not empty, pages will (apparently) be returned
* hierarchically anyway in order of creation: 3, 4, 5.
*/
$this->assertEqualSets( array( $page_3, $page_4, $page_5 ), wp_list_pluck( $pages, 'ID' ) );
// How it should work.
$found_pages = wp_list_filter( $pages, array( 'post_parent' => $page_1 ) );
$this->assertEqualSets( array( $page_3, $page_5 ), wp_list_pluck( $found_pages, 'ID' ) );
wp_nav_menu( apply_filters( 'widget_nav_menu_args', $nav_menu_args, $nav_menu, $args, $instance, $this ) );
// $nav_menu_args
Array
(
[fallback_cb] =>
[menu] => stdClass Object
(
[term_id] => 176
[name] => Short
/**
* Data provider.
*
* Description.
*
* @since x.x.x
*
* @see {method name receiving data}
*
* @otherPHPUnitSpecificItems
/**
* Hide media buttons from the default editor.
*
* @param array $settings _WP_Editors::editor() settings.
* @param string $editor_id Editor ID.
* @return array (maybe) modified editor settings.
*/
function hide_media_buttons( $settings, $editor_id ) {
if ( 'post' == get_post_type() && 'content' == $editor_id ) {
$settings['media_buttons'] = false;
/**
* Filter whether to skip parsing duplicate hooks.
*
* "Duplicate hooks" are characterized in WordPress core by a preceding DocBlock comment
* including the phrases "This action is documented in" or "This filter is documented in".
*
* Passing a truthy value will skip the parsing of duplicate hooks.
*
* @param bool $skip Whether to skip parsing duplicate hooks. Default false.
*/