Skip to content

Instantly share code, notes, and snippets.

@bueltge
bueltge / gist:757903
Created December 28, 2010 23:27
This WordPress Plugin demonstrates how you can build your own plugin pages using the WordPress provided draggable metaboxes, requires WordPress 2.7 version, supports WordPress 2.8 changed boxing layout engine
<?php
/*
Plugin Name: HowTo Plugin
Plugin URI:
Description: This Plugin demonstrates how you can build your own plugin pages using the WordPress provided draggable metaboxes, requires WordPress 2.7 version, supports WordPress 2.8 changed boxing layout engine
Author: Heiko, Frank
Author URI: http://bueltge.de
Version: 0.1
License:
@keithmorris
keithmorris / remove-words.php
Created November 27, 2012 16:22
PHP remove common words from a string
<?php
function removeCommonWords($input){
// EEEEEEK Stop words
$commonWords = array('a','able','about','above','abroad','according','accordingly','across','actually','adj','after','afterwards','again','against','ago','ahead','ain\'t','all','allow','allows','almost','alone','along','alongside','already','also','although','always','am','amid','amidst','among','amongst','an','and','another','any','anybody','anyhow','anyone','anything','anyway','anyways','anywhere','apart','appear','appreciate','appropriate','are','aren\'t','around','as','a\'s','aside','ask','asking','associated','at','available','away','awfully','b','back','backward','backwards','be','became','because','become','becomes','becoming','been','before','beforehand','begin','behind','being','believe','below','beside','besides','best','better','between','beyond','both','brief','but','by','c','came','can','cannot','cant','can\'t','caption','cause','causes','certain','certainly','changes','clearly','c\'mon','co','co.','com','come','comes','concerni
@KartikTalwar
KartikTalwar / Documentation.md
Last active April 13, 2024 23:09
Rsync over SSH - (40MB/s over 1GB NICs)

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
@sheabunge
sheabunge / uninstall.php
Created January 13, 2013 05:03
WordPress multisite plugin uninstall
<?php
if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
exit();
if ( is_multisite() ) {
$blogs = $wpdb->get_results( "SELECT blog_id FROM $wpdb->blogs", ARRAY_A );
if ( $blogs ) {
foreach ( $blogs as $blog ) {
switch_to_blog( $blog['blog_id'] );
@jfloff
jfloff / mamp.md
Last active March 6, 2024 09:43
How to get MAMP to work with SSL ... Yes really.

First of all you need to be able to run MAMP in port 80. This is a "heat check" if you don't have any process jamming http ports. You can check it like this:

sudo lsof | grep LISTEN

If you do happen to have any process with something like this *:http (LISTEN), you are in trouble. Before with adventure check if it isn't MAMP itself (yeah, you should close that beforehand)

ps <pid of that process>

If you don't see MAMP, you are in good hands, I have just the thing for you:

@WerdsWords
WerdsWords / the_editor_content.php
Last active December 20, 2015 01:49
#14: the_editor_content
<?php
/**
* Inject a post template into the post editor
*
* @see _WP_Editors::editor(), wp_editor()
*
* @param string $content The editor content.
*
* @return string The filtered editor content.
*/
@MikeRogers0
MikeRogers0 / backup-to-s3.sh
Last active May 19, 2020 15:33
A method of backing up your website to Amazon S3.
#!/bin/bash
## Email Variables
EMAILDATE=`date --date="today" +%y-%m-%d`
EMAIL="you@yourdomain.com"
SUBJECT="[servername] Backup Script Started! - "$EMAILDATE
EMAILMESSAGE="/tmp/emailmessage1.txt"
echo "Just to let you know that the backup script has started."> $EMAILMESSAGE
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
@justintadlock
justintadlock / register-post-type.php
Last active October 22, 2023 05:55
Help file when registering post types.
<?php
# Register custom post types on the 'init' hook.
add_action( 'init', 'my_register_post_types' );
/**
* Registers post types needed by the plugin.
*
* @since 1.0.0
* @access public
@paulund
paulund / example-wp-list-table.php
Last active March 31, 2024 05:40
An example code of using the WP_List_Table class. With Pagination.
<?php
/*
* Plugin Name: Paulund WP List Table Example
* Description: An example of how to use the WP_List_Table class to display data in your WordPress Admin area
* Plugin URI: http://www.paulund.co.uk
* Author: Paul Underwood
* Author URI: http://www.paulund.co.uk
* Version: 1.0
* License: GPL2
*/
@retgef
retgef / psuedo-static-js.php
Last active April 7, 2017 22:00
Add a pseudo static JS file to WordPress
<?php
#Add a query var to sniff requests
add_filter( 'query_vars', 'my_query_var_callback', 10, 1 );
function my_query_var_callback( $vars ){
$vars[] = 'dynamic_js';
return $vars;
}
#Dynamic JavaScript
add_rewrite_rule( '^assets/js/dynamic\.js$', 'index.php?dynamic_js=1', 'top' ); //Note the hidden query variable