By: Jonas Nordström, @windyjonas
Date: 2013-04-16
esc_attr( $text );
Encodes the <, >, &, " and ' (less than, greater than, ampersand, double quote and single quote) characters. Will never double encode entities.
Example:
<?php | |
function my_stuff_only( $query ) { | |
if ( $query->is_admin && !current_user_can( 'manage_options' ) ) { | |
global $user_ID; | |
$query->set( 'author', $user_ID ); | |
} | |
return $query; | |
} | |
add_filter( 'pre_get_posts', 'my_stuff_only' ); |
########################################### | |
# Constants, set and forget | |
########################################### | |
# temp storage for the wordpress tarball | |
TMP_STORAGE=/home/USER/wptemp | |
# web root for the wordpress site | |
WWWROOT=/var/www | |
# Privileged db use/pwd for creating database and granting rights |
fastcgi_intercept_errors on; | |
if ($http_user_agent ~* (HTTrack|HTMLParser|discobot|Exabot|Casper|kmccrew|plaNETWORK|RPT-HTTPClient)) { | |
return 444; | |
} | |
if ($http_referer ~* (sex|vigra|viagra) ) { | |
return 444; | |
} |
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
I hereby claim:
To claim this, I am signing this object:
CREATE TABLE `wp_posts_new` ( | |
`ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT, | |
`post_author` bigint(20) unsigned NOT NULL DEFAULT '0', | |
`post_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', | |
`post_date_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', | |
`post_content` longtext NOT NULL, | |
`post_title` text NOT NULL, | |
`post_excerpt` text NOT NULL, | |
`post_status` varchar(20) NOT NULL DEFAULT 'publish', | |
`comment_status` varchar(20) NOT NULL DEFAULT 'open', |
/** | |
* Search users by first/last name in addition to the built-in nicename search | |
* @param string $wp_user_query User query | |
* @return string Modified user query | |
*/ | |
function ws_user_search_by_name( $wp_user_query ) { | |
if ( false === strpos( $wp_user_query->query_where, '@' ) && ! empty( $_GET['s'] ) ) { | |
global $wpdb; | |
$uids = array(); |
<?php | |
$relations = array( | |
'malin' => array( 'jonas', 'jack' ), | |
'jonas' => array( 'malin', 'jack' ), | |
'anna' => array( 'mats', 'filippa' ), | |
'mats' => array( 'anna', 'filippa' ), | |
'filippa' => array( 'anna', 'mats' ), | |
'gussi' => array( 'stefan', 'emma' ), | |
'stefan' => array( 'gussi' ), | |
'emma' => array( 'gussi', 'ted' ), |
class Sanitize_Filename { | |
public function __construct() { | |
add_filter( 'wp_handle_upload_prefilter', [ $this, 'sanitize_decomposed_utf8_file' ] ); | |
} | |
/** | |
* Sanitize the filename in a file object | |
* | |
* @param array $file In file |