Skip to content

Instantly share code, notes, and snippets.

WPsites

Block or report user

Report or block WPsites

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@WPsites
WPsites / editor-style.css
Created Oct 23, 2012
WordPress tinymce style dropdown
View editor-style.css
/*
editor styles
*/
.Bold{
font-weight:bold;
}
.Medium{
@WPsites
WPsites / D3.js
Created Sep 12, 2012
D3.JS playground - UK map made of around 300 dots
View D3.js
var svg = createSVG();
// Associate each circle with a unique ID so that exit()
// and updates properly affect the correct element.
var circle = svg.selectAll("circle").data($data,ƒ('id'));
circle.enter().append('circle')
.attr('opacity',0)
.attr('class',"m")
.attr("cx", ƒ('x'))
@WPsites
WPsites / logstash.index.json
Last active Sep 17, 2017
Elasticsearch index template for logstash that contains additional NGINX fields
View logstash.index.json
{
"template_logstash":{
"template" : "logstash*",
"settings" : {
"number_of_shards" : 5,
"index.cache.field.type" : "soft",
"index.refresh_interval" : "5s",
"index.store.compress.stored" : true,
"index.query.default_field" : "message",
"index.routing.allocation.total_shards_per_node" : 5
@WPsites
WPsites / build-shape-detect.sh
Created Sep 12, 2012
Find contours in an image and output x,y data structure of all found contours (OpenCV)
View build-shape-detect.sh
#!/bin/sh
i="shape-detect.cpp"
echo "compiling $i"
g++ -ggdb `pkg-config --cflags opencv` -o `basename $i .cpp` $i `pkg-config --libs opencv`;
@WPsites
WPsites / gist:4128809
Created Nov 22, 2012
Hide admin menu items on a WordPress site.
View gist:4128809
<?php
/*
The code below hides the admin menu items for all users that don't have the 'manage_sites' capability.
On multisite that would mean only Super Admins can look at those menu items
This script only removes the menu items so users can still look at the page if they know the path, but it de-clutters the admin
*/
global $current_user;
if ( !current_user_can('manage_sites') ) {
@WPsites
WPsites / gist:3656189
Created Sep 6, 2012
WP-cron debug test - Add a WordPress cron event to email server variables every 2 minutes
View gist:3656189
<?php
function my_additional_schedules($schedules) {
// interval in seconds
$schedules['every2min'] = array('interval' => 2*60, 'display' => 'Every two minutes');
return $schedules;
}
add_filter('cron_schedules', 'my_additional_schedules');
// schedule the wp_cron_testing
@WPsites
WPsites / gist:6100723
Created Jul 28, 2013
Elasticsearch index mapping confirmation for debug..
View gist:6100723
curl -XGET 'http://192.168.11.3:9200/logstash-2013.07.29/_mapping?pretty=true'
{
"logstash-2013.07.29" : {
"syslog" : {
"_all" : {
"enabled" : false
},
"properties" : {
"@fields" : {
@WPsites
WPsites / gist:6083397
Last active Dec 20, 2015
Function to inspect WordPress filters/actions that match a regular expression
View gist:6083397
<?php
//hook into the 'shutdown' action and debug some filters... but not on the admin this time
if (! is_admin() )
add_action('shutdown', 'use_debug_filters',10);
function use_debug_filters(){
echo "<h3>Output hooks and filters that contain the string 'init'</h3>";
debug_filter("/init/i");
@WPsites
WPsites / gist:5783087
Created Jun 14, 2013
Example restore code added to a backup file created automatically with the WPide plugin
View gist:5783087
<?php /* start WPide restore code */
if ($_POST["restorewpnonce"] === "d859796ed783fd60ae9fc9db3a5e32a585e948a587"){
if ( file_put_contents ( "/var/www/sites/sites.co.uk/sites.co.uk/subdomains/site/html/wp-content/themes/mm/customer-comments.php" , preg_replace("#<\?php /\* start WPide(.*)end WPide restore code \*/ \?>#s", "", file_get_contents("/var/www/sites/sites.co.uk/sites.co.uk/subdomains/site/html/wp-content/plugins/wpide/backups/themes/handyman-mm/customer-comments_2013-04-11-23.php") ) ) ){
echo "Your file has been restored, overwritting the recently edited file! \n\n The active editor still contains the broken or unwanted code. If you no longer need that content then close the tab and start fresh with the restored file.";
}
}else{
echo "-1";
@WPsites
WPsites / time-stack.php
Created Jan 23, 2013
WordPress TimeStack plugin modified to write data to disk if a persistant object cache doesn't look like it's available
View time-stack.php
<?php
/*
Plugin Name: WordPress TimeStack
Description: WordPress Profiling
Author: Human Made Limited
Version: 0.9
*/
class HM_Time_Stack {
You can’t perform that action at this time.