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 | |
/** | |
* This class will cause WP_Query to ignore a 'post_type' parameter when 'post_type__not_in' is set. | |
* | |
* Class Post_Type__Not_In | |
*/ | |
class Post_Type__Not_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
package test | |
// | |
// Initial source for benchmark from https://stackoverflow.com/a/40678026/102699 | |
// Added BenchmarkConcatAppendPreAllocate() | |
// | |
import "testing" | |
func BenchmarkConcatCopyPreAllocate(b *testing.B) { | |
for n := 0; n < b.N; n++ { | |
B = concatCopyPreAllocate(slices) |
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 GrantLogonAsAService([string]$Username) { | |
Write-Host "Grant Logon-as-a-Service for $Username" | |
$SecurityId = $null | |
try { | |
$Principal = new-object System.Security.Principal.NTAccount $Username | |
$SecurityId = $Principal.Translate([System.Security.Principal.SecurityIdentifier]).Value.ToString() | |
} catch { | |
Write-Host "Attempt to access SecurityID failed." | |
$SecurityId = $null |
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 | |
/* | |
Description: Adds a taxonomy filter in the admin list page for a custom post type. | |
Written for: http://wordpress.stackexchange.com/posts/582/ | |
By: Mike Schinkel - http://mikeschinkel.com/custom-workpress-plugins | |
Instructions: Put this code in your theme's functions.php file or inside your own plugin. Edit to suite your post types and taxonomies. Hope this helps... | |
*/ | |
add_filter('manage_listing_posts_columns', 'add_businesses_column_to_listing_list'); | |
function add_businesses_column_to_listing_list( $posts_columns ) { | |
if (!isset($posts_columns['author'])) { |
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 declare(strict_types=1); | |
/* | |
* This file is part of sebastian/type. | |
* | |
* (c) Sebastian Bergmann <sebastian@phpunit.de> | |
* | |
* For the full copyright and license information, please view the LICENSE | |
* file that was distributed with this source code. | |
*/ | |
namespace SebastianBergmann\Type; |
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 | |
/* | |
* Code Examples for Master WordPress Custom Post Types - WordCamp Atlanta 2012 | |
* | |
* Author: Mike Schinkel | |
* Author URI: http://about.me/mikeschinkel | |
* | |
*/ | |
add_action( 'init', 'mikes_theme_init' ); | |
function mikes_theme_init() { |
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 | |
// Put this in wp-config.php | |
define('PREPARED_SQL_REQUIRED',true); | |
// A site builder who wants to use prepared statements and parameterized queries | |
// could run these in various hooks before $wpdb->query() below is run. | |
$question_fragment = $wpdb->prepare( '`question_id` = %d', $question_id ); | |
$answer_fragment = $wpdb->prepare( '`answer_name` = %s', $new_answer ); | |
$wpdb->compose('UPDATE %s polls SET vote = vote+1 WHERE %s AND %s', |
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 | |
$safe_var = 'all your base they belong to us'; | |
file_put_contents('/tmp/exploit.txt',$safe_var ); | |
// imagine lots of stuff going on here... | |
$safe_var = file_get_contents('/tmp/exploit.txt'); | |
function make_literal(string $non_literal):string { | |
$literal = ''; |
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 | |
class Custom_Hooks { | |
/** | |
* Adds a filter hook for an object | |
* | |
* Custom_Hooks::add_filter( 'filter_data', array( $this, 'filter_data' ) ); | |
* Custom_Hooks::add_filter( 'filter_data', array( $this, 'filter_data' ), 11 ); | |
* Custom_Hooks::add_filter( 'filter_data', 'special_func' ); | |
* Custom_Hooks::add_filter( 'filter_data', 'special_func', 11 ); |