Skip to content

Instantly share code, notes, and snippets.

/* REMOVE SELF PINGING */
function remove_self_pinging(&$links,&$pung) {
$self = get_option('siteurl');
foreach ($links as $link => $data) {
if (false !== strpos($link,$self))
unset($links[$link]);
}
}
add_action('pre_ping','remove_self_pinging',0,2);
/* END REMOVE SELF PINGING */
<?php
/*
Plugin Name: [RPC] XMLRPCless Blog
Plugin URI: http://earnestodev.com/
Description: Disable XMLRPC advertising/functionality blog-wide.
Version: 0.0.7
Author: EarnestoDev
Author URI: http://earnestodev.com/
*/
// Disable X-Pingback HTTP Header.
@un1ko85
un1ko85 / new_gist_file.php
Created May 6, 2013 15:00
default wp-config.php and why WP_UPLOAD_PATH and WP_UPLOAD_URL are logical constants
<?php
/**
* The base configurations of the WordPress.
*
* This file has the following configurations: MySQL settings, Table Prefix,
* Secret Keys, WordPress Language, and ABSPATH. You can find more information
* by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
* wp-config.php} Codex page. You can get the MySQL settings from your web host.
*
* This file is used by the wp-config.php creation script during the
@un1ko85
un1ko85 / new_gist_file
Created May 9, 2013 06:52
Git: extract branch name in post update hook But if branch was deleted (for example by git push origin :branch-name), you will receive errors from this command, so I think it’s safer to use another method: As post-update hook receives branch’s path as first parameter (something like refs/heads/branch-name), you can extract the branch name using …
branch=$(git rev-parse --symbolic --abbrev-ref $1)
branch=$(echo $1 | awk -F'/' '{print $3}')
if [ ! -f $1 ]; then
echo "Branch $branch was deleted! Do something then.."
else
echo "Branch $branch was updated! Do something then.."
fi
@un1ko85
un1ko85 / new_gist_file.sh
Created May 10, 2013 06:52
git hooks per branch
if [ `git rev-parse --abbrev-ref HEAD` == "development" ]; then
echo "development-script"
elif [ `git rev-parse --abbrev-ref HEAD` == "staging" ]; then
echo "staging-script"
elif [ `git rev-parse --abbrev-ref HEAD` == "production" ]; then
echo "production-script"
fi
@un1ko85
un1ko85 / new_gist_file.sh
Created May 10, 2013 07:18
Starting and stopping NginX / MySQL / PHP-FPM on Mac OS X
#! /bin/bash
MYSQL="/opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper"
NGINX="/opt/local/sbin/nginx"
PHPFPM="/opt/local/sbin/php-fpm"
PIDPATH="/opt/local/var/run"
MEMCACHED="/opt/local/bin/memcached -m 24 -P /opt/local/var/run/memcached.pid -u root"
if [ $1 = "start" ]; then
sudo $MYSQL start
echo "Starting php-fpm ..."
@un1ko85
un1ko85 / get_posts_cached.php
Created July 4, 2013 11:27
Wrapper around get_posts that utilizes object caching
/**
* 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' );
@un1ko85
un1ko85 / new_gist_file.sh
Created August 26, 2013 08:05
Nginx WP AntiBrute + PHP CGI
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;
@un1ko85
un1ko85 / new_gist_file.php
Created September 11, 2013 12:08
delete session file
<?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
@un1ko85
un1ko85 / new_gist_file.php
Created September 17, 2013 16:29
force get_option to go back to the DB instead of cache
$GLOBALS['wp_object_cache']->delete( 'your_option_name', 'options' );
$value = get_option( 'your_option_name' );