This file contains 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 | |
function my_is_valid_domain( $url ) { | |
$whitelisted_domains = array( 'mydomain.com', 'mydomain.net' ); | |
$domain = parse_url( $url, PHP_URL_HOST ); | |
// Check if we match the domain exactly | |
if ( in_array( $domain, $whitelisted_domains ) ) | |
return true; | |
$valid = false; |
This file contains 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 | |
<?php | |
namespace Automattic\VIP\Files\Acl; | |
use WP_Error; | |
class VIP_Files_Acl_Unpublished_Files_Test extends \WP_UnitTestCase { | |
const TEST_IMAGE_PATH = VIP_GO_MUPLUGINS_TESTS__DIR__ . '/fixtures/image.jpg'; |
This file contains 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( WPMU_PLUGIN_DIR . '/cache/class-vary-cache.php' ); | |
use Automattic\VIP\Cache\Vary_Cache; | |
Vary_Cache::register_group( 'beta' ); | |
add_action( 'wp_head', function() { | |
// TODO: if possible, load this directly very early in the header.php (instead of wp_head) |
This file contains 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 | |
/** | |
* Remove a given term from the specified post | |
* | |
* Helper function since this functionality doesn't exist in core | |
*/ | |
function my_remove_post_term( $post_id, $term, $taxonomy ) { | |
if ( ! is_numeric( $term ) ) { |
This file contains 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
// Must be in an external file or loaded at the end of wp_footer() | |
jQuery(document).ajaxSend(function(e, x, a) { | |
var awesome = 1; | |
a.data += '&' + jQuery.param( {is_awesome: awesome} ); | |
}); |
This file contains 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 | |
/** | |
* WordPress Multisite upgrade script | |
* | |
* IMPORTANT: While a simple safeguard has been added to the script, | |
* you'll want to add another layer that prevents this script from | |
* being called via the browser. | |
* | |
* Usage: | |
* 1) Place in the root of your install (or another place, but modify the wp-load.php path to match) |
This file contains 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
jQuery( function( $ ) { | |
if ( 'undefined' === typeof FB ) | |
return; | |
if ( $( 'body' ).hasClass( 'single-post' ) || $( 'body' ).hasClass( 'page' ) ) { | |
var $comments_div = $( '<div/>' ); | |
$comments_div.addClass( 'fb-comments' ); | |
$comments_div.attr( 'data-href', document.location ); | |
$comments_div.appendTo( $( '.primary-content' ) ); |
This file contains 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 | |
add_filter( 'allowed_http_origins', 'my_add_origins' ); | |
function my_add_origins( $origins ) { | |
$origins[] = 'http://www.example.com'; // this will add www.example.com to the list of allowed origins when send_origin_headers() is called | |
return $origins; | |
} |
This file contains 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 | |
/* | |
Plugin Name: Feed Killah! | |
Plugin URI: http://digitalize.ca | |
Description: Kills feeds like a mo-fo! | |
Author: Mohammad Jangda | |
Version: 0.1 | |
Author URI: http://digitalize.ca | |
Be nice, and use sort of GPL License, okay? |
This file contains 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 | |
add_action( 'init', function() { | |
$html_map = [ | |
'howdy/world' => 'howdy', | |
]; | |
$current_path = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ); | |
if ( in_array( $current_path, array_keys( $html_map ), true ) ) { | |
$filename = $html_map[ $current_path ]; |