Skip to content

Instantly share code, notes, and snippets.

View coderaaron's full-sized avatar

Aaron Graham coderaaron

  • St. Louis, MO
  • 15:11 (UTC -05:00)
View GitHub Profile
@coderaaron
coderaaron / washu-people-places-items.php
Created February 3, 2017 21:58
Load template from theme first, fall back to plugin template
add_filter( 'template_include', array( self::$instance, 'ppi_load_single_template' ), 99 );
...
function ppi_load_single_template( $template ) {
...
if ( is_singular( 'things' ) ) {
// look in child or parent themes for template files first
if ( $theme_template = locate_template( 'single-items.php' ) ) {
$template = $theme_template;
} else {
$template = self::$directories['templates'] . 'single-items.php';
@coderaaron
coderaaron / washu-people-places-items.php
Created February 1, 2017 21:36
Set the default map center
add_filter( 'acf/load_field/name=washu_ppi_map', array( self::$instance, 'set_default_google_maps_center' ) );
...
public static function set_default_google_maps_center( $field ) {
$google_map_center = get_field( 'washu_ppi_places_map_center', 'option' );
$field[ 'center_lat' ] = $google_map_center[ 'lat' ];
$field[ 'center_lng' ] = $google_map_center[ 'lng' ];
return $field;
@coderaaron
coderaaron / group_58545ba3a2777.json
Created February 1, 2017 21:34
Map Field on CPT
...
{
"height": "",
"center_lat": "38.641265",
"center_lng": "-90.2881593",
"zoom": "",
"key": "field_58545be03c13a",
"label": "Location\/Map",
"name": "washu_ppi_map",
"type": "google_map",
@coderaaron
coderaaron / group_585839e690eb1.json
Created February 1, 2017 21:32
Default Google Map center (on options page)
...
{
"height": "",
"center_lat": "38.641265",
"center_lng": "-90.2881593",
"zoom": "",
"key": "field_5858518f3db94",
"label": "Map Center",
"name": "washu_ppi_places_map_center",
"type": "google_map",
// add style selector drop down
function my_mce_buttons_2( $buttons ) {
array_unshift( $buttons, 'styleselect' );
return $buttons;
}
add_filter( 'mce_buttons_2', 'my_mce_buttons_2' );
// customize the MCE editor
function aah_customize_mce( $init ) {
@coderaaron
coderaaron / dropdown.php
Created May 12, 2014 20:17
How to safely add custom style to TinyMCE 4.0 "Formats" dropdown
<?php
// Add new styles to the TinyMCE "formats" menu dropdown
if ( ! function_exists( 'wusm_styles_dropdown' ) ) {
function wusm_styles_dropdown( $settings ) {
// Create array of new styles
// array of arrays, see example here: http://codex.wordpress.org/TinyMCE_Custom_Styles
$new_styles = array(
array(
'title' => 'Custom Styles',