Skip to content

Instantly share code, notes, and snippets.

View benallfree's full-sized avatar

Ben Allfree benallfree

  • Reno, NV
View GitHub Profile
@benallfree
benallfree / gist:5282099
Created March 31, 2013 21:37
Demo of WP media uploader in metabox
jQuery(function($) {
var element_clicked = false;
$('#my-button').click(function() {
formfield = jQuery('#my-button').attr('name');
tb_show('', 'media-upload.php?type=image&TB_iframe=true');
element_clicked = true;
return false;
@benallfree
benallfree / nextend-facebook-connect.diff
Last active December 31, 2015 02:09
Patches nextend FB to use login_redirect filter
Index: nextend-facebook-connect.php
===================================================================
--- nextend-facebook-connect.php (revision 819180)
+++ nextend-facebook-connect.php (working copy)
@@ -132,13 +132,13 @@
AND type = \'fb\'', $user_info->ID));
set_site_transient($user_info->ID.'_new_fb_admin_notice',__('Your Facebook profile is successfully unlinked from your account.', 'nextend-facebook-connect'), 3600);
}
- new_fb_redirect();
+ new_fb_redirect($user_info);
@benallfree
benallfree / custom-post-type-ui.diff
Created December 13, 2013 12:47
Add import/export to CPT.
Index: custom-post-type-ui.php
===================================================================
--- custom-post-type-ui.php (revision 821057)
+++ custom-post-type-ui.php (working copy)
@@ -59,6 +59,7 @@
add_submenu_page( 'cpt_main_menu', __( 'Add New', 'cpt-plugin' ), __( 'Add New', 'cpt-plugin' ), 'manage_options', 'cpt_sub_add_new', 'cpt_add_new' );
add_submenu_page( 'cpt_main_menu', __( 'Manage Post Types', 'cpt-plugin' ), __( 'Manage Post Types', 'cpt-plugin' ), 'manage_options', 'cpt_sub_manage_cpt', 'cpt_manage_cpt' );
add_submenu_page( 'cpt_main_menu', __( 'Manage Taxonomies', 'cpt-plugin' ), __( 'Manage Taxonomies', 'cpt-plugin' ), 'manage_options', 'cpt_sub_manage_taxonomies', 'cpt_manage_taxonomies' );
+ add_submenu_page( 'cpt_main_menu', __( 'Import/Export', 'cpt-plugin' ), __( 'Import/Export', 'cpt-plugin' ), 'manage_options', 'cpt_sub_import_export', 'cpt_import_export' );
}
@benallfree
benallfree / easy-theme-and-plugin-upgrades.diff
Created December 21, 2013 14:15
Zip files which do not contain a bare parent directory entry were not being detected correctly.
Index: modify-installer.php
===================================================================
--- modify-installer.php (revision 826618)
+++ modify-installer.php (working copy)
@@ -134,7 +134,7 @@
$contents = $archive->listContent();
foreach ( (array) $contents as $content ) {
- if ( preg_match( '|^([^/]+)/$|', $content['filename'], $matches ) ) {
+ if ( preg_match( '|^([^/]+)/|', $content['filename'], $matches ) ) {
@benallfree
benallfree / Wistia API
Created May 13, 2014 23:01
Wistia Upload and Status Demo
class WistiaApi
{
static $WISTIA_UPLOAD_URL='https://upload.wistia.com';
static $WISTIA_API_URL='https://api.wistia.com/v1';
function __construct($api_key)
{
$this->key = $api_key;
}
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /home/user/public_html
ErrorLog /home/user/public_html/error.log
CustomLog /home/user/public_html/access.log combined
<Directory /home/user/public_html>
Options Indexes FollowSymLinks
AllowOverride All
@benallfree
benallfree / setup.sh
Last active August 15, 2018 01:03
Ubuntu LAMP++ (Ubuntu 18.04.1 LTS / Apache / PHP 7.2 / Beanstalk / Certbot / git / composer / git-lfs)
#!/bin/bash
SSHPK="..."
MYSQLP="..."
MYSQLDB="..."
USERP="..."
ufw allow http
ufw allow https
ufw allow mysql
ufw allow ssh
echo y | ufw enable
@benallfree
benallfree / github.php
Last active August 29, 2015 14:04
github PHP webhook responder
<?php
if(!$_GET['pw']=='hFGw6DSxIFo8n7c4mb0RRCAdxAsK1jTDyZPyb6xlxqXKq6tM2') die('ok');
$data = json_decode($HTTP_RAW_POST_DATA,true);
chdir(dirname(__DIR__));
exec('bash update.sh', $output, $return);
die(join("\n",$output));
@benallfree
benallfree / update.sh
Created August 4, 2014 02:33
Update script for Laravel+Composer
#!/bin/bash
export HOME=/home/samplesale
git pull origin master
/usr/local/bin/composer install
php artisan migrate -n
chmod -R 755 .
chmod -R 775 app/storage