Skip to content

Instantly share code, notes, and snippets.

View karlazz's full-sized avatar

Karla Leibowitz karlazz

  • herself
  • Walnut Creek, CA
View GitHub Profile
@karlazz
karlazz / gist:c9b1420e4eb47dfb529f
Created June 9, 2015 22:46
Change table prefix in wordpress db
RENAME TABLE wp_8_options TO wp_5_options,
wp_8_posts TO wp_5_posts,
wp_8_commentmeta TO wp_5_commentmeta,
wp_8_comments to wp_5_comments,
wp_8_links to wp_5_links,
wp_8_postmeta to wp_5_postmeta,
wp_8_users to wp_5_users,
wp_8_usermeta to wp_5_usermeta,
wp_8_terms to wp_5_terms,
wp_8_term_taxonomy to wp_5_term_taxonomy,
@karlazz
karlazz / gist:b32ffdac7afd2ffb9f59
Created March 5, 2015 21:41
WGET to bring down a website
wget --limit-rate=200k --no-clobber --convert-links --random-wait -r -p -E -e robots=off -U mozilla http://www.oldwebsite.com
@karlazz
karlazz / gist:d6330b8192c413259452
Last active August 29, 2015 14:14
enhance wp-config to easily toggle debugging
if (isset($_GET['debug']) ) {
define('WP_DEBUG',true);
if ( $_GET['debug']=='log') {
// Enable Debug logging to the /wp-content/debug.log file
// The web user will have to have write permission to the file
/* uncomment next to use wordpress file default of wp-content/debug.log, make sure of write permission */
//define('WP_DEBUG_LOG', true);
/* or use a file in the wp-content/uploads directory, which should always have write perms on it */
@ini_set('error_log', dirname(__FILE__) . '/wp-content/uploads/debug.log');
// Disable display of errors and warnings
@karlazz
karlazz / gist:aff9c80aa804c12d0f60
Created November 29, 2014 00:24
Create an event handler for jquery from viralpatel.net
(function ($) {
$.each(['show', 'hide'], function (i, ev) {
var el = $.fn[ev];
$.fn[ev] = function () {
this.trigger(ev);
return el.apply(this, arguments);
};
});
})(jQuery);
@karlazz
karlazz / gist:97820f3a17f90f421ca0
Last active September 7, 2016 01:03
WP_ajax basics with nonce security part not tested
// this goes in the page template or where you need it
// make sure that your add_action and your callback are in functions, not in a page template
wp_enqueue_script('karla');
$ajax_nonce = wp_create_nonce( "karla-nonce" );
wp_localize_script('karla','getter',array('ajax_url' => admin_url( 'admin-ajax.php' ),'sugar'=>$_GET['sugar']), 'security'=> $ajax_nonce );
@karlazz
karlazz / gist:019ed5666079ec9a3f9c
Created October 2, 2014 22:17
redirect debug output to debug.log with wordpress
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@karlazz
karlazz / gist:e207417e5165f49bee1d
Created July 3, 2014 16:41
Some gravity form field manipulations: character counter (requires plugin), field validations, preset form values, post set form value.
<?php
add_action('wp_footer', 'add_char_counter');
function add_char_counter() {
if ( is_page( array( 'add-a-highlight', 'add-a-publication' ) ) ) { ?>
<script src="/wp-content/themes/ameriflux/library/js/textcounter.min.js"></script>
<script type="text/javascript">
jQuery('.amx-title input').textcounter({
max: 250,
countDownText: "Characters Left: "
});
@karlazz
karlazz / gist:4a9feba239d548d54bb5
Created June 25, 2014 22:26
Read from a file into a multi-selector field in gravity forms
/* http://www.gravityhelp.com/documentation/page/Dynamically_Populating_Drop_Down_Fields
*/
add_filter('gform_pre_render_5', 'populate_posts');
function populate_posts($form){
foreach($form['fields'] as &$field){
if( strpos($field['cssClass'], 'multi-selector') === false) /* original had a check for $field['type'] != 'select' */
continue;
@karlazz
karlazz / gist:9511441
Created March 12, 2014 17:05
How to clear DNS cache on mavericks OS
dscacheutil -flushcache;sudo killall -HUP mDNSResponder
@karlazz
karlazz / gist:8152703
Created December 27, 2013 21:16
Quickly display multiple values on separate lines.
foreach ($d = array('<br>', self::USER, self::ENDPOINT, $query_string) as $e) {echo $e . $d[0];}