Skip to content

Instantly share code, notes, and snippets.

View JAW-Dev's full-sized avatar

Jason Witt JAW-Dev

View GitHub Profile
@JAW-Dev
JAW-Dev / valet.sh
Created July 16, 2017 14:39
Bash script for strating and stopping Valet and MySQL
#!/bin/sh
# Check if a service is running.
function running() {
if ps ax | grep -v grep | grep "$1" &> /dev/null; then
return 0
else
return 1
fi;
}
@JAW-Dev
JAW-Dev / autoload-dir-files.php
Last active September 20, 2017 20:58
Autoloading files in directory with PHP
// $dir = path/to/directory/
function load_files( $dir ) {
// Declare the results array to return.
$results = array();
// Scan the dir for files.
$files = scandir( $dir );
// Loop through the files in the directory.
@JAW-Dev
JAW-Dev / allowed-characters.php
Created April 19, 2017 14:03
Allowed Characters
// Add the allowed characters in an array.
$args = array( '!', '(', ')' );
function maybe_do_allowed_characters( $string, $args ) {
// Bail if fails string sanity check.
if ( ! $string && ! is_string( $string ) ) { return; }
$allowed = array();
$defaults = array(
@JAW-Dev
JAW-Dev / disable-wordpress-updates.php
Last active August 21, 2022 23:08
Disable WordPress updates
//Disable all automatic updates from wp-core, themes, plugins
$this->addFilter('auto_update_translation', '__return_false');
$this->addFilter('automatic_updater_disabled', '__return_true');
$this->addFilter('allow_minor_auto_core_updates', '__return_false');
$this->addFilter('allow_major_auto_core_updates', '__return_false');
$this->addFilter('allow_dev_auto_core_updates', '__return_false');
$this->addFilter('auto_update_core', '__return_false');
$this->addFilter('wp_auto_update_core', '__return_false');
$this->addFilter('auto_core_update_send_email', '__return_false');
$this->addFilter('send_core_update_notification_email', '__return_false');
@JAW-Dev
JAW-Dev / gist:45842b416a142113f4ad6de7ed6dda3a
Last active January 17, 2017 19:32
Bash script to setup WordPress for Mamp
#!/bin/bash
clear
# ----------------------------------------------------------------
# Variables
# ----------------------------------------------------------------
# Get current directory name
# ---------------------------------
@JAW-Dev
JAW-Dev / country-list.json
Created November 7, 2016 13:35
json country list
[
{ "AF":"Afghanistan" },
{ "AX":"Åland Islands" },
{ "AL":"Albania" },
{ "DZ":"Algeria" },
{ "AS":"American Samoa" },
{ "AD":"Andorra" },
{ "AO":"Angola" },
{ "AI":"Anguilla" },
{ "AQ":"Antarctica" },
@JAW-Dev
JAW-Dev / wordpress-split-queried-posts-into-rows.php
Created April 29, 2016 09:28
WordPress - Split queried posts into rows
$query = new WP_Query(array(
'post_type' => 'post',
));
$posts_per_row = 2;
$post_counter = 0;
if( have_posts() ) :
while( $query->have_posts() ) :
$query->the_post();
if( ( ++$post_counter % $posts_per_row ) == 1 || $posts_per_row == 1 ) :
if( $post_counter > 1 ) :
@JAW-Dev
JAW-Dev / repeatable.php
Last active October 22, 2015 21:25
Repeatable Option Fields
if( !class_exists( 'OU_Settings' ) ) {
class OU_Settings {
/**
* Option
*
* @since 0.0.1
* @var array $ordered_uploads_options The settings option array
*/
private $ordered_uploads_options;
@JAW-Dev
JAW-Dev / hasel.php
Created April 18, 2015 15:46
Header Already Sent Error Log
add_action('activated_plugin','save_error');
function save_error(){
file_put_contents(ABSPATH. 'wp-content/error_activation.html', ob_get_contents());
}
@JAW-Dev
JAW-Dev / WordPress - Even Odd.php
Created January 18, 2015 19:02
Add Even and Odd classes to WordPress loop items
class="<?php echo ($query->current_post%2 == 0?'odd':'even'); ?>"