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
/** | |
* Wrapper around get_posts that utilizes object caching | |
* | |
* @access public | |
* @param mixed $args (default: NUL) | |
* @param bool $force_refresh (default: false) | |
* @return void | |
*/ | |
function get_posts_cached( $args = NULL, $force_refresh = false ) { | |
$cache_incrementor = wp_cache_get( 'get_posts_cached', 'cache_incrementors' ); |
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
location ~* /(wp-login\.php|administrator|admin\.php) { | |
set $humantest 0; | |
if ($http_cookie !~* "humans=fucking_love_cookies") { | |
set $humantest 1; | |
} | |
if ($args ~* (callback|logout|lostpassword)) { | |
set $humantest 0; | |
} | |
if ($humantest = 1) { | |
add_header Content-Type text/html; |
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 | |
session_start(); // start the current/old session (loads the $_SESSION variables) | |
$base_name = '/sess_'; // the base name for the session data files | |
$old_sessionid = session_id(); // get the current/old id | |
$_SESSION['test'] = 123; // some test data | |
session_regenerate_id(); // generate a new id and a new data file | |
$new_sessionid = session_id(); // get the new session id to store in the user table for the current visitor |
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
$GLOBALS['wp_object_cache']->delete( 'your_option_name', 'options' ); | |
$value = get_option( 'your_option_name' ); |
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
if (is_category()) { | |
$this_category = get_category($cat); | |
if (get_category_children($this_category->cat_ID) != "") { | |
echo "<h1>Subcategories</h1>"; | |
echo "<ul>"; | |
wp_list_categories('orderby=id&show_count=0&title_li= | |
&use_desc_for_title=1&child_of='.$this_category->cat_ID); | |
echo "</ul>"; | |
} | |
} |
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
get_categories('child_of=92&hide_empty=false&orderby=meta_value&meta_key=date&order=ASC'); | |
//----------------------------------------------------------------------- | |
function category_custom_field_get_terms_orderby( $orderby, $args ){ | |
if($args['orderby'] == 'category_custom_field' && isset($args['category_custom_field'])) | |
return 'cv.field_value'; | |
return $orderby; | |
} | |
function category_custom_field_get_terms_fields( $selects, $args ){ |
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
function pm_remove_all_scripts() { | |
global $wp_scripts; | |
$wp_scripts->queue = array(); | |
} | |
add_action('wp_print_scripts', 'pm_remove_all_scripts', 100); | |
function pm_remove_all_styles() { | |
global $wp_styles; | |
$wp_styles->queue = array(); | |
} | |
add_action('wp_print_styles', 'pm_remove_all_styles', 100); |
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
VK.init({apiId:"...", onlyWidgets: false}); | |
VK.Api.call('likes.getList', {type: "sitepage", owner_id: "...[apiId]",page_url:pageuri}, | |
function(r) { | |
if(r.response && r.response.count) { | |
$.getJSON('...?rating=vk&ratingvalue=' + r.response.count); | |
} | |
}); |
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
$.getJSON('https://graph.facebook.com/fql?q=select like_count, share_count from link_stat where url="' + encodeURI(page_url) + '"' | |
+ '&callback=?', function(response) { | |
var count = 0; | |
if (response.data !== undefined) { | |
if (response.data[0].like_count !== undefined) { | |
count += response.data[0].like_count; | |
} | |
if (response.data[0].share_count !== undefined) { | |
count += response.data[0].share_count; | |
} |
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
server { | |
[...] | |
set $cache_uri $request_uri; | |
# POST requests and urls with a query string should always go to PHP | |
if ($request_method = POST) { | |
set $cache_uri 'null cache'; | |
} | |
if ($query_string != "") { | |
set $cache_uri 'null cache'; |