Skip to content

Instantly share code, notes, and snippets.

Avatar
💻
Coding.

Russell Heimlich kingkool68

💻
Coding.
View GitHub Profile
@kingkool68
kingkool68 / class-mailchimp.php
Last active Feb 13, 2020
A MailChimp API wrapper for WordPress
View class-mailchimp.php
<?php
/**
* Let's nail down some concepts
* - Each site has it's own list of contacts, all subscribers belong to a list
* - Contacts can be part of groups and we can send a campaign to a group of subscribers
* - Groups can be categorized (a requirement of MailChimp)
*/
namespace Pedestal\Objects;
View 1st-map.html
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.21.0/mapbox-gl.js'></script> <section class="inter-map"> <div class="inter-map__inner"> <style> <!-- @font-face {
font-family: DINRoundOT;
src: url('https://a.americares.org/mapbox/fonts/FontFont - DINRoundOT.otf');
}
@font-face {
font-family: BlockBQBol;
src: url('https://a.americares.org/mapbox/fonts/BlockBQBol.otf');
}
View tags.php
<?php
class CTF_Register_Taxonomies {
/**
* Initialize the class
*/
public function __construct() {
add_action( 'init', array( $this, 'tags_support_all' ) );
add_action( 'pre_get_posts', array( $this, 'tags_support_query' ) );
}
View schema.xml
<?xml version="1.0" encoding="UTF-8" ?>
<schema name="wpdata" version="1.1">
<types>
<!-- Geo location fields -->
<fieldType name="latitude_longitude" class="solr.LatLonType" subFieldSuffix="_coordinate"/>
<fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
<fieldType name="boolean" class="solr.BoolField" sortMissingLast="true" omitNorms="true"/>
<fieldType name="integer" class="solr.TrieIntField" omitNorms="true"/>
<fieldType name="long" class="solr.TrieLongField" omitNorms="true"/>
<fieldType name="float" class="solr.TrieFloatField" omitNorms="true"/>
View filter-by-dates.php
<?php
function action_pre_get_posts( $query ) {
if ( $query->is_tax() && $query->is_main_query() ) {
$meta_query = array(
array(
'key' => 'date',
'compare' => '>=',
'value' => date( 'Ymd' ),
),
array(
View pre-get-posts.php
<?php
function action_pre_get_posts( $query ) {
if ( $query->is_tax() && $query->is_main_query() ) {
$meta_query = array(
array(
'key' => 'date',
'compare' => '>=',
'value' => date( 'Ymd' ),
),
);
View pre-get-posts.php
<?php
function action_pre_get_posts( $query ) {
if ( $query->is_tax() && $query->is_main_query() ) {
$meta_query = array(
array(
'key' => 'date',
'compare' => '>=',
'value' => date( 'Ymd' ),
),
);
View pre-get-posts.php
<?php
function action_pre_get_posts( $query ) {
if ( $query->is_tax() && $query->is_main_query() ) {
$meta_query = array(
array(
'key' => 'date',
'compare' => '>=',
'value' => date( 'Ymd' ),
),
);
@kingkool68
kingkool68 / cache-busting-file-src.php
Last active Mar 25, 2019
Replace the `ver` query arg with the file's last modified timestamp (WordPress CSS/JS Cache Busting)
View cache-busting-file-src.php
<?php
/**
* Replace the `ver` query arg with the file's last modified timestamp
*
* @param string $src URL to a file
* @return string Modified URL to a file
*/
function filter_cache_busting_file_src( $src = '' ) {
global $wp_scripts;
// If $wp_scripts hasn't been initialized then bail.
@kingkool68
kingkool68 / basic-class-with-actions-and-filters.php
Created May 4, 2018
A basic example of a class using actions and filters in WordPress
View basic-class-with-actions-and-filters.php
<?php
class Thing {
/**
* Get an instance of this class
*/
static function get_instance() {
static $instance = null;
if ( null === $instance ) {
$instance = new static();
$instance->setup_actions();