Skip to content

Instantly share code, notes, and snippets.

View EvanHerman's full-sized avatar
🐈
Cats, Code, WordPress

Evan Herman EvanHerman

🐈
Cats, Code, WordPress
View GitHub Profile
@EvanHerman
EvanHerman / custom-function.php
Last active February 9, 2018 16:36
Timeline Express - Enable Announcement Date & Time Pickers
<?php
/**
* Add date/time picker field to Timeline Express announcements
*
* @param array $custom_field Array of custom fields to append to our announcements.
*/
function add_custom_fields_to_announcements( $custom_fields ) {
$custom_fields[] = array(
'name' => esc_html__( 'Announcement Date & Time', 'text-domain' ),
@EvanHerman
EvanHerman / circle.yml
Last active August 25, 2017 23:24 — forked from petersuhm/circle.yml
Example CircleCi configuration for WP Pusher
machine:
timezone:
Europe/Copenhagen
php:
version: 5.3.3
# This will be added to the `/etc/hosts` file
hosts:
wordpress.dev: 127.0.0.1
@EvanHerman
EvanHerman / apache-ci.conf
Last active August 25, 2017 21:10 — forked from petersuhm/apache-ci.conf
Circle CI Apache configuration file
<VirtualHost *:80>
LoadModule php7_module /opt/circleci/php/7.1.3/usr/lib/apache2/modules/libphp7.so
DocumentRoot "/home/ubuntu/wordpress"
ServerName wordpress.dev
ServerAlias *.dev
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
@EvanHerman
EvanHerman / circle.yml
Created August 24, 2017 17:49 — forked from Arjeno/circle.yml
Always use the latest version of Chrome on CircleCI
# This makes sure Chrome is always up to date in your test suite
# On average this adds about 10 seconds to your build suite
# Be sure to use Ubuntu 14.04 (Trusty) in the CircleCI's OS setting (Settings > Build Environment)
dependencies:
pre:
- curl -L -o google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
- sudo dpkg -i google-chrome.deb
- sudo sed -i 's|HERE/chrome\"|HERE/chrome\" --disable-setuid-sandbox|g' /opt/google/chrome/google-chrome
- rm google-chrome.deb
@EvanHerman
EvanHerman / dynamic-post-tags.php
Last active May 3, 2017 12:43
Populate the WordPress post tags with the values from the WordPress post categories on the save_post action hook.
<?php
/**
* Dynamically set the post tags to mirror the post categories.
*
* @action save_post
*
* @param integer $post_id The post ID.
*/
function dynamic_post_tags( $post_id ) {
@EvanHerman
EvanHerman / enable-sorting-custom-taxonomies.php
Last active April 2, 2017 12:13
Enable taxonomy sorting (tax_position) for custom taxonomies
<?php
/*
* If you've registered a custom taxonomy to assign to one of your custom post types,
* you'll want to add an additional paprameter to the $args array
*
*/
// Register Custom Taxonomy
function custom_taxonomy() {
@EvanHerman
EvanHerman / create-admin-user.php
Created December 23, 2015 14:44
Programatically create an admin user (WordPress)
<?php
add_action('init', 'prefix_add_user');
function prefix_add_user() {
$username = 'username123';
$password = 'azerty321';
$email = 'example@example.com';
@EvanHerman
EvanHerman / update-user-by-email.php
Created January 31, 2017 13:59
Update WordPress user password by email address
<?php
/**
* Update an existing user by email address
*
* @author Code Parrots <support@codeparrots.com>
*/
function update_user_password_by_email() {
$user = get_user_by( 'email', 'email@example.com' );
@EvanHerman
EvanHerman / gist:dfd2a8c4f2f129b65a54344a97ffd80e
Created December 17, 2016 19:08 — forked from paulallies/gist:0052fab554b14bbfa3ef
Remove node_modules from git repo
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master
@EvanHerman
EvanHerman / custom-interior-image-timeline-express.php
Created May 18, 2016 21:54
Use a different image on the single announcement page, than what is used on the timeline.
/**
* Timeline Express Add Custom Metabox
* @param array $options Array of options for Timeline Express.
*/
function define_custom_excerpt_metabox( $options ) {
$announcement_custom_metabox = new_cmb2_box( array(
'id' => 'custom_meta',
'title' => __( 'Additional Announcement Meta', 'text-domain' ),
'object_types' => array( 'te_announcements' ), // Post type
'context' => 'advanced',