Skip to content

Instantly share code, notes, and snippets.

View korynorthrop's full-sized avatar

Kory Northrop korynorthrop

View GitHub Profile
@korynorthrop
korynorthrop / autoptimize-rtl-filter.php
Created May 26, 2020 13:40
Autoptimize RTL filter
<?php
public function rtl_logic( $input_condition ) {
if ( is_rtl() || strpos( $_SERVER['REQUEST_URI'], '/ar/' ) !== false || strpos( $_SERVER['REQUEST_URI'], '/he/' ) !== false || strpos( $_SERVER['REQUEST_URI'], '/fa/' ) !== false || strpos( $_SERVER['REQUEST_URI'], '/ur/' ) !== false ) {
error_log( "path-based rule set for: " . $_SERVER['REQUEST_URI'] );
return true;
} else {
error_log( "conditional tag used for: " . $_SERVER['REQUEST_URI'] );
if ( is_single() ) {
error_log( "and is_single() is true for: " . $_SERVER['REQUEST_URI'] );
@korynorthrop
korynorthrop / sample-learndash-query.sql
Created March 10, 2020 09:19
Inactive LearnDash user SQL query
SELECT u.user_email,
um.meta_key AS "login_type",
from_unixtime(um.meta_value,'%c/%e/%y') AS "login_date",
GROUP_CONCAT(p.post_title) AS "courses"
FROM nPJeAgtL_users u
INNER JOIN nPJeAgtL_usermeta um ON um.user_id = u.id AND um.meta_key = 'learndash-last-login'
LEFT JOIN nPJeAgtL_learndash_user_activity lua ON lua.user_id = u.id AND lua.activity_type = 'course'
LEFT JOIN nPJeAgtL_posts p ON lua.course_id = p.id
WHERE from_unixtime(um.meta_value) < '2019-03-01 00:00:00' AND p.id IN (1947,1938,7694,1932)
GROUP BY u.user_login
/**
* Interactions with MultilingualPress on the admin side ( hooks into the 'admin_enqueue_scripts' action )
*
* @var {Array} multilingualpress_settings Array of variables passed to this script via wp_localize_script
*/
wp.domReady( () => {
// If editing a post in the main site language
if ( multilingualpress_settings && multilingualpress_settings.isPostEditor == 'true' && multilingualpress_settings.currentBlogID == '1' ) {
const { registerBlockType } = wp.blocks;
const { __ } = wp.i18n;
const { createElement, Fragment, cloneElement } = wp.element;
const { RichText, URLInput, AlignmentToolbar, InspectorControls, BlockControls } = wp.editor;
const { createHigherOrderComponent, withState } = wp.compose;
const { Button, PanelBody, TextControl, ToggleControl, SelectControl, IconButton } = wp.components;
registerBlockType( 'hello-tools/newsletter-signup', {
title: __( 'Newsletter signup', 'hello-tools' ),
icon: 'email-alt',
/**
* Register all of our custom blocks
*
* @since 2.4.4
*/
public function register_blocks() {
// Newsletter signup block
register_block_type( 'hello-tools/newsletter-signup', array(
'style' => 'hello-tools-newsletter-signup',
@korynorthrop
korynorthrop / newsletter-post_content.html
Created September 17, 2019 04:25
This is what the dynamic newsletter block looks like when
<!-- wp:hello-tools/newsletter-signup {"headline":"This is the headline for the newsletter block","blurb":"\u003cp\u003eThis is the subtext for the newsletter block\u003c/p\u003e","bgColor":"blue","bgClass":"hello-bg\u002d\u002dblue hello-text\u002d\u002dwhite","btnClass":"hello-btn\u002d\u002dorange"} /-->
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>The Brian Paul Hotel</title>
<link href="https://fonts.googleapis.com/css?family=Josefin+Sans:300,400,600" rel="stylesheet">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<!--[if mso]>
<style type=”text/css”>
.fallback-text {
@korynorthrop
korynorthrop / acf-dynamic-field-set.php
Created March 8, 2017 19:42
ACF Dynamic Field Set
/**
* Dynamically load the Custom CTA image library from RCO Settings allowable images
*/
function acf_load_image_library( $field ) {
// reset CTA selector
$field['choices'] = array();
$images = get_field('cta_image_libary','option'); // get the images from the pre-approved list of images in RCO Settings