Skip to content

Instantly share code, notes, and snippets.

View idpokute's full-sized avatar
🎲
Focusing

Mike Sehui Park idpokute

🎲
Focusing
  • Toronto
View GitHub Profile
@MelMacaluso
MelMacaluso / expose_ACF_fields_to_REST.php
Created June 4, 2019 22:54
Automatically expose all the ACF fields to the Wordpress REST API in Pages and in your custom post types.
<?php
function create_ACF_meta_in_REST() {
$postypes_to_exclude = ['acf-field-group','acf-field'];
$extra_postypes_to_include = ["page"];
$post_types = array_diff(get_post_types(["_builtin" => false], 'names'),$postypes_to_exclude);
array_push($post_types, $extra_postypes_to_include);
foreach ($post_types as $post_type) {
register_rest_field( $post_type, 'ACF', [
@jb510
jb510 / gist:206de7fb03da2bae51941251fc26215d
Created April 3, 2017 21:13
WordPress check and then force disable autoload in wp_options
# Useful to inspect first
# Return autoload options ordered by length/size
SELECT LENGTH(option_value),option_name FROM wp_options WHERE autoload='yes' ORDER BY length(option_value) DESC LIMIT 20;
# disable autoload on all options
UPDATE wp_options SET autoload='No' WHERE autoload='Yes';
# re-enable autoload on first 100 options
UPDATE wp_options SET autoload='Yes' LIMIT 100;
@wesbos
wesbos / async-await.js
Created February 22, 2017 14:02
Simple Async/Await Example
// 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works
const axios = require('axios'); // promised based requests - like fetch()
function getCoffee() {
return new Promise(resolve => {
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee
});
}
@dersam
dersam / gitkraken.zsh
Last active September 17, 2024 20:22
Open GitKraken using the current repo directory in the cli.
## Open GitKraken using the current repo directory.
## For when you want a prettier view of your current repo,
## but prefer staying in the cli for most things.
## This will break if GitKraken ever removes the -p flag.
## If you're not using OSX, the path is definitely different.
kraken () {
~/Applications/GitKraken.app/Contents/MacOS/GitKraken -p $(pwd)
}
@noelboss
noelboss / git-deployment.md
Last active October 12, 2024 16:09
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like deepl.io to act upon a Web-Hook that's triggered that service.

@bryanwillis
bryanwillis / actual-filtering-function.php
Last active February 13, 2020 04:05
Easily Modify genesis theme framework classes on the fly using genesis_attr();
<?php
/**
* Adds Filters Automatically from Array Keys
*/
add_action('genesis_meta', 'bw_add_array_filters_genesis_attr');
function bw_add_array_filters_genesis_attr()
{
$filters = bw_merge_genesis_attr_classes();
foreach(array_keys($filters) as $context) {
@Falconerd
Falconerd / gulpfile.js
Last active April 10, 2019 17:16
Gulp + Watchify + Babelify + BrowserSync
/**
* This gulpfile will copy static libraries and a index.html file as well as
* merge, babelify and uglify the rest of the javascript project.
*
* TODO:
* - Separate media, libs and src with different watchers.
* - Media and libs should only be copied to dist if they are different sizes.
*
* The expected project is to be laid out as such:
*
@neilgee
neilgee / addinfunctions.php
Last active January 30, 2023 20:34
Gravity Form Word Count
<?php
/* Gravity Forms Word Count Script */
function els_load_scripts() {
wp_enqueue_script('gravity-forms-word-count', get_stylesheet_directory_uri() . '/js/jquery.gravity_word_count.js', array('jquery'), '0.1', true);
}
add_action('wp_enqueue_scripts', 'els_load_scripts');
/*Then in the form, for fields that need the word count, add the class ‘els-word-count[300].' Change [300] as needed for the maximum words that can be added to that particular field.*/
/*Source http://www.gravityhelp.com/forums/topic/maximum-word-count#post-149331*/
@verteb
verteb / count-posts-by-term.php
Created June 26, 2013 13:56
Wordpress: Count posts by term
function fc_count_posts_with_term($term_slug, $taxonomy)
{
global $wpdb;
$term = get_term_by( 'slug', $term_slug, $taxonomy );
$st = $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->posts p
INNER JOIN $wpdb->term_relationships tr
ON (p.ID = tr.object_id)
INNER JOIN $wpdb->term_taxonomy tt
ON (tr.term_taxonomy_id = tt.term_taxonomy_id)