Skip to content

Instantly share code, notes, and snippets.

<?php
if ( ! empty( $_SERVER['REQUEST_URI'] ) &&
strpos( $_SERVER['REQUEST_URI'], '/content/uploads' ) === 0 ) {
http_response_code(404);
exit;
}
@mathieuhays
mathieuhays / fix.php
Created February 25, 2016 16:53
Fix PMPRO username issue
<?php
function pmpro_fix_username_issue( $pmpro_continue_registration ) {
if (!$pmpro_continue_registration) {
return $pmpro_continue_registration;
}
global $username, $pmpro_error_fields;
$safe_username = sanitize_user($username, true);
@mathieuhays
mathieuhays / console_log.php
Last active August 29, 2015 14:21
Console_log
<?php
function console_log(){
$log = array();
foreach( func_get_args() as $arg ){
$_arg = is_object( $arg ) && get_class( $arg ) != "stdClass" ? "[Class: ".get_class( $arg ). "]" : $arg;
$log[] = json_encode( $_arg );
}
@mathieuhays
mathieuhays / cache_busting.conf
Last active August 29, 2015 14:08
Cache busting apache config
# ----------------------------------------------------------------------
# | Filename-based cache busting |
# ----------------------------------------------------------------------
# If you're not using a build process to manage your filename version
# revving, you might want to consider enabling the following directives
# to route all requests such as `/style.12345.css` to `/style.css`.
#
# To understand why this is important and even a better solution than
@mathieuhays
mathieuhays / uk_phone_regex.php
Last active August 29, 2015 14:07
UK Phone Regex
<?php
$uk_phone = '/(\+44|0[0-9]|0044[0-9]?)[ |-]?([0-9])?[ |-]?([0-9]{2,3}[ |-]?){2,3}([0-9]{2,3})/';
$test_string = "
Uk format recognised:
+44 7 909 987 987 or
02987765543 or
00447 987 654 432 or
07-908-908-908";
@mathieuhays
mathieuhays / app.js
Created July 30, 2014 13:17
Express.js - Get req, res value inside socket.io connection
var module = require('./module');
// ..... //
app.use( express.methodOverride() );
app.use( module.setup );
app.use( app.router );
// ..... //
io.on('connection', module.process );