Skip to content

Instantly share code, notes, and snippets.

View TwisterMc's full-sized avatar

Thomas McMahon TwisterMc

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', [
@avillegasn
avillegasn / settings-link.php
Last active August 22, 2022 08:55
Add a settings link under your plugin title in the list of plugins
@JeremyEnglert
JeremyEnglert / beaver.php
Last active October 2, 2019 11:22
Set BeaverBuilder as Default Editor
<?php
// Sets Beaver Builder as the default editor.
function make_beaver_builder_default( $post_ID, $post, $update ) {
if ( ! $update ) {
update_post_meta( $post_ID, '_fl_builder_enabled', true );
}
}
add_action( 'wp_insert_post', 'make_beaver_builder_default', 10, 3 );
@shaunkane
shaunkane / bear-backup.py
Created January 9, 2017 17:38
Script for automating Bear note backups. Note that you must fill in the BEAR_DB and EXPORT_DIR variables for this to work.
# export notes from the Bear db to markdown files
import sqlite3
BEAR_DB = '/Users/<your username>/Library/Containers/net.shinyfrog.bear/Data/Library/Application Support/net.shinyfrog.bear/database.sqlite'
EXPORT_DIR = '<set an export directory>'
conn = sqlite3.connect(BEAR_DB)
c = conn.cursor()
for row in c.execute('SELECT ZTITLE, ZTEXT FROM ZSFNOTE'):
@maddisondesigns
maddisondesigns / functions.php
Last active January 1, 2019 11:07
Remove Yoast SEO nag after update
<?php
/*
* Remove the annoying Yoast SEO nag for all Admin Users. Tested with v3.4.2
*/
class ahRemoveYoastNag_Remove_Yoast_SEO_Nag {
private $yoastPluginFile;
public function __construct() {
$this->yoastPluginFile = "wordpress-seo/wp-seo.php";
register_activation_hook( $this->yoastPluginFile, array( $this, 'ryn_remove_yoast_nag_on_activation' ) );
@medmunds
medmunds / find-focus-stealer.py
Created February 6, 2015 00:51
Find the Mac OSX app that's stealing the active window away
#!/usr/bin/python
# Print the active OSX app whenever it changes.
# (Use to figure out which ill-behaved app is stealing focus away from you.)
# Adapted from http://apple.stackexchange.com/a/148094/112614
try:
from AppKit import NSWorkspace
except ImportError:
print "Can't import AppKit -- maybe you're running python from brew?"
print "Try running with Apple's /usr/bin/python instead."
@vladimirtsyupko
vladimirtsyupko / gist:10964772
Created April 17, 2014 08:32
Git force pull to overwrite local files
git fetch --all
git reset --hard origin/master
git pull origin master
@chadothompson
chadothompson / wordpress-csv-export.php
Created July 24, 2013 14:33
Exporting WordPress post types, titles and URLs in a CSV format.
<?php
/*
export.php - a script for outputting post type, title and URL in CSV format.
All commas are also stripped from titles in order to keep the CSV format (for HootSuite import) versus keeping the titles as is.
*/
include "wp-load.php";
$posts = new WP_Query('post_type=any&posts_per_page=-1&post_status=publish');