Skip to content

Instantly share code, notes, and snippets.

View sfgarza's full-sized avatar
🏠
Working from home

Santiago Garza sfgarza

🏠
Working from home
View GitHub Profile
@sfgarza
sfgarza / ajax_class.php
Created March 15, 2016 23:04
Boilerplate code for making AJAX calls to wordpress.
<?php
if (!defined('ABSPATH')) {
exit;
}
class ajax_class
{
public function __construct()
{
//Hook = 'wp_ajax_{$action}' where $action must equal the AJAX request's 'action' property.
<?php
### PHP command line wrapper for WP Engine's web based WP-CLI
### Example command line: php wp_engine_cli.php -i wp_install_name -c "cli info"
$all_installs = array(
'install1',
'install2',
'install3,
);
#\bsrc="http:\/\/search.cesipagano.com# => src="//search.cesipagano.com

Keybase proof

I hereby claim:

  • I am sfgarza on github.
  • I am sfgarza (https://keybase.io/sfgarza) on keybase.
  • I have a public key whose fingerprint is 97FF A8FA 6B1F 866C C3C9 9ACA 455D 225D 2CF8 5BD2

To claim this, I am signing this object:

#!/bin/bash
apt-get update -y;
apt-get install git curl vim wget npm -y;
npm install n npm@latest imforza-cli -g;
npm cache clean -f;
n lts;
wget https://getcomposer.org/installer;
php installer --install-dir=/usr/local/bin --filename=composer;
rm installer;
@sfgarza
sfgarza / debug_wp-config.php
Last active June 1, 2018 09:32
Add to wp-config.php to activate debug log
<?
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*/
define('WP_DEBUG', true);
define( 'WP_DEBUG_LOG', true );
@sfgarza
sfgarza / pre-commit-gulp.bash
Last active February 13, 2018 22:12
Pre commit hook for ensuring files get built before committing.
#!/usr/bin/env bash
#
# Commands to be run before a commit can be made to the repository:
#
# Make sure gulp build always runs before commiting.
# Constants for terminal colors
GREEN='\033[00;32m'
YELLOW='\033[00;93m'
RED='\033[00;91m'
@sfgarza
sfgarza / activate-plugin.php
Created September 27, 2017 19:05
Activate plugin using code (in another plugin)
<?php
$result = activate_plugin( 'jetpack/jetpack.php' );
if ( is_wp_error( $result ) ) {
error_log( 'Couldnt activate plugin');
}
@sfgarza
sfgarza / destroy_user_session_cron.php
Created November 30, 2017 00:34
Expire a particular WordPress users session everyday at midnight
<?php
$time = my_strtolocaltime( 'midnight' );
my_schedule_cron( 'my_destroy_sessions_cron', 'daily', $time );
add_action( 'my_destroy_sessions_cron', 'my_destroy_sessions' );
/**
* Destroy all sessions for guest user.
*
* @return void
*/
@sfgarza
sfgarza / post-merge
Last active February 6, 2018 23:26 — forked from sindresorhus/post-merge
git hook to run a command after `git pull` if a specified file was changed.In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed.Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"