This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Beer { | |
const NAME = 'Beer!'; | |
public static function printed(){ | |
echo 'static Beer:NAME = '. static::NAME . '<br />'; | |
} | |
} | |
class Ale extends Beer { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Adds 'Affiliates' Toolbar links in the My Sites drop-down. | |
* | |
* @param WP_Admin_Bar $wp_admin_bar Toolbar instance. | |
*/ | |
function affiliate_toolbar_links( $wp_admin_bar ) { | |
foreach ( $wp_admin_bar->user->blogs as $blog ) { | |
$blog_id = $blog->userblog_id; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql -u wp -p wp -e "drop database wptests; create database wptests;" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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' ) ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Data provider. | |
* | |
* Description. | |
* | |
* @since x.x.x | |
* | |
* @see {method name receiving data} | |
* | |
* @otherPHPUnitSpecificItems |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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. | |
*/ |