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( 'loop_start', 'mark_posts_with_query' ); | |
function mark_posts_with_query( $query ) { | |
$in_main_query = $query->is_main_query(); | |
foreach ( $query->posts as $post ) { | |
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 is_user_logged_in() { | |
$loggedin = false; | |
foreach ( (array) $_COOKIE as $cookie => $value ) { | |
if ( stristr($cookie, 'wordpress_logged_in_') ) | |
$loggedin = true; | |
} | |
return $loggedin; | |
} | |
if ( ! stristr($_SERVER['REQUEST_URI'], '/wp-admin') && ! stristr($_SERVER['REQUEST_URI'], '/wp-login.php') && ! is_user_logged_in() ) |
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 | |
use Rarst\Profiler\Handler; | |
global $wp; | |
if ( Handler::$profiling && empty( $wp ) ) { | |
Handler::close(); | |
} |
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 | |
$bench = new Ubench(); | |
$total = 15000; | |
$count = 10; | |
$sql = " | |
SELECT l.ID, post_title, post_content, post_name, post_parent, post_author, post_modified_gmt, post_date, post_date_gmt | |
FROM ( | |
SELECT {$wpdb->posts}.ID |
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 | |
if ( isset( $_GET['grid'] ) ) { | |
add_action( 'wp_print_styles', function () { ?> | |
<style type="text/css"> | |
@media (min-width: 768px) { | |
body { | |
background: url("http://griddle.it/720px-12-30px") repeat-y center top !important; | |
} |
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 | |
error_reporting( E_ALL ^ E_STRICT ); // le sigh | |
require __DIR__ . '/wordpress/tools/i18n/makepot.php'; | |
/** | |
* Additionally scans for localized strings in Mustache templates. | |
*/ | |
class MustachePOT extends MakePOT { |
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_max = 7.0; | |
$php_min = 5.2; | |
$php_versions = array_filter( range( $php_max, $php_min + 0.1, 0.1 ), function ( $version ) { | |
return version_compare( $version, 5.6, '<=' ) || version_compare( $version, 7.0, '>=' ); | |
} ); | |
$wp_max = 4.6; |
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( 'shutdown', function () { | |
if ( ! defined( 'WPSEO_PATH' ) ) { | |
return; | |
} | |
$path = str_replace( '\\', '/', WPSEO_PATH ); | |
$includes = array_reduce( get_included_files(), function ( $plugin_includes, $include_path ) use ( $path ) { |
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 | |
// @link http://books.google.com/books?id=fvA7zLEFWZgC&pg=PA61&lpg=PA61#v=onepage&q&f=false | |
function nice_labels( $min, $max, $ticks = 5 ) { | |
$range = nice_number( $max, false ); | |
$d = nice_number( $range / ( $ticks - 1 ) ); | |
$graphmin = floor( $min / $d ) * $d; | |
$graphmax = ceil( $max / $d ) * $d; | |
$nfrac = max( array( - floor( log( $d, 10 ) ), 0 ) ); |