Skip to content

Instantly share code, notes, and snippets.

@ngearing
ngearing / acf-pro-db-update.php
Created March 9, 2017 03:28
ACF Pro update db script works on manageWP
<?php
include $_SERVER['DOCUMENT_ROOT'].'/wp-content/plugins/advanced-custom-fields-pro/acf.php';
include $_SERVER['DOCUMENT_ROOT'].'/wp-content/plugins/advanced-custom-fields-pro/admin/install.php';
$acf_admin = new acf_admin_install();
$updates = acf_get_db_updates();
$message = '';
@ngearing
ngearing / acf-pro-license-update.php
Created March 1, 2017 02:56
ACF Pro License update ManageWP
<?php
$pro_license = maybe_unserialize(base64_decode(get_option('acf_pro_license')));
if (!$pro_license || $pro_license['url'] != home_url()) {
$save = array(
'key' => 'license_here',
'url' => home_url()
);
$save = maybe_serialize(base64_encode($save));
@ngearing
ngearing / installvagrant
Last active June 8, 2017 00:43 — forked from rrgrs/installvagrant
installs brew, virtualbox, and vagrant in osx
if ! type "brew" > /dev/null; then
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
brew install git cask brew-cask-completion &&
brew cask install vagrant virtualbox &&
vagrant plugin install vagrant-berkshelf vagrant-hostmanager vagrant-hostsupdater vagrant-omnibus vagrant-share vagrant-vbguest;
@ngearing
ngearing / .htaccess
Last active February 1, 2018 01:09
Wordpress htacces for local dev
# Credits: https://stevegrunwell.com/blog/keeping-wordpress-under-version-control-with-git/
# ADD THIS IN YOUR UPLOADS DIRECTORY
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) http://{SITE_URL}/wp-content/uploads/$1
</IfModule>
@ngearing
ngearing / wordpress-style-script-queue.php
Created February 21, 2018 00:16
List the current queue of styles and scripts for WordPress
<?php
global $wp_styles;
global $wp_scripts;
echo '<pre>' . print_r( $wp_styles->queue, true ) . '</pre>';
echo '<pre>' . print_r( $wp_scripts->queue, true ) . '</pre>';
@ngearing
ngearing / functions.php
Last active June 8, 2018 00:05
Exclude terms in term lists from non Admins in WordPress
<?php
/**
* Exclude some terms from the term lists.
*
* @param WP_Term_Query $term_query The class instance instance.
* @return void
*/
function exclude_terms( $term_query ) {
if (
is_feed() ||
@ngearing
ngearing / functions.php
Created June 8, 2018 01:38
Remove Missing Attachment text from WordPress feed
<?php
/**
* Remove text from rss feed content and excerpt.
*
* @param string $content
* @return string
*/
function remove_feed_text( $content ) {
@ngearing
ngearing / functions.php
Created June 8, 2018 02:48
Add media and images to rss feed in WordPress.
<?php
/**
* Add 'Featured Image' to a rss feed.
*
* @return void
*/
function add_feed_item() {
$query = get_queried_object();
@ngearing
ngearing / functions.php
Created June 8, 2018 04:31
Exclude posts from child categories on archive pages
<?php
/**
* Filter the archive posts to only display posts of the current Term not child Terms.
*
* @param WP_Query $query The query instance.
* @return void
*/
function filter_archive_posts( $query ) {
@ngearing
ngearing / functions.php
Last active June 8, 2018 05:42
Get list of terms for a post.
<?php
/**
* Get an array of WP_Term objects for a post.
*
* @param integer $post_id The post id.
* @return array
*/
function get_post_terms( $post_id ) {
$terms_array = [];