Skip to content

Instantly share code, notes, and snippets.

Phil Kurth mishterk

Block or report user

Report or block mishterk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mishterk
mishterk / bypass-elementors-maintenance-mode.php
Last active Aug 22, 2019
Using this snippet, you can bypass Elementor's maintenance mode by adding ?bypass_maintenance=1 to the query string
View bypass-elementors-maintenance-mode.php
<?php
add_filter( 'pre_option_elementor_maintenance_mode_mode', function ( $option ) {
$parameter = 'bypass_maintenance'; // change this to whatever you like
if ( isset( $_GET['bypass_maintenance'] ) and $_GET['bypass_maintenance'] ) {
return 0; // needs to be falsy but not FALSE
}
@mishterk
mishterk / custom-wordpress-menu-items-template.php
Last active Aug 22, 2019
How to render WordPress menu items without a custom walker
View custom-wordpress-menu-items-template.php
<?php $menu_location = 'some_menu_location'; ?>
<?php if ( has_nav_menu( $menu_location ) ): ?>
<?php $menu_items = wp_get_nav_menu_items( wp_get_nav_menu_name( $menu_location ) ); ?>
<?php foreach ( $menu_items as $menu_item ): ?>
<a href="<?= $menu_item->url ?>"
target="<?= $menu_item->target ?: '_self' ?>"
class="<?= implode( ' ', $menu_item->classes ) ?>"><?= $menu_item->title ?></a>
<?php endforeach; ?>
<?php endif; ?>
View MagnificPopupModal.vue
<template>
<div class="Modal mfp-hide" ref="modal">
<div class="Modal__inner">
<slot></slot>
</div>
</div>
</template>
@mishterk
mishterk / LocalValetDriver.php
Last active Jun 16, 2019
A local Valet driver for proxying images to a remote host
View LocalValetDriver.php
<?php
/**
* Class LocalValetDriver
*
* This class demonstrates how we might go about proxying any missing local images to a remote host. i.e; the production
* site. This has been created with WordPress in mind but could be adjusted to work with any other system.
*/
class LocalValetDriver extends WordPressValetDriver {
View procedural-wp-rest-api-get-requests.php
<?php
/**
* Really simple GET request
*/
add_action( 'rest_api_init', function ( WP_REST_Server $wp_rest_server ) {
register_rest_route( '/custom-namespace/v1', '/no-param', [
'methods' => 'GET',
'callback' => function ( WP_REST_Request $request ) {
if ( $throw_error = false ) {
@mishterk
mishterk / 0-readme.md
Last active Apr 14, 2019
A basic, static view handler for WordPress
View 0-readme.md

Basic Usage

// set up
View::$view_dir = '/some/path';

// echos the view
View::render('relative/template', [
  'var1' => 'data',
  'var2' => 'more data'
@mishterk
mishterk / CustomOrderEmail.php
Last active Mar 19, 2019
Registering custom emails for WooCommerce
View CustomOrderEmail.php
<?php
class CustomOrderEmail extends \WC_Email {
// This is a just a simple example. See \WC_Email and child classes for more examples
public function __construct() {
$this->id = 'custom_order_email';
$this->title = 'Custom Order Email';
@mishterk
mishterk / acfcdt-relevanssi-support.php
Created Mar 11, 2019
How to add custom table data to Relevanssi's search index
View acfcdt-relevanssi-support.php
<?php
add_filter( 'relevanssi_content_to_index', 'acfcdt_relevanssi_support', 10, 2 );
add_filter( 'relevanssi_excerpt_content', 'acfcdt_relevanssi_support', 10, 2 );
function acfcdt_relevanssi_support( $content, $post ) {
/**
* Approach A (recommended): Using SQL to minimise database queries during Relevanssi's indexing process.
*/
global $wpdb;
@mishterk
mishterk / count-new-members-between-two-dates.sql
Last active Jun 1, 2018
Helpful SQL queries for working with the MemberPress WordPress plugin
View count-new-members-between-two-dates.sql
SELECT count(DISTINCT txns.user_id)
FROM (
SELECT
user_id,
min(created_at) AS first_txn_created_at
FROM wp_mepr_transactions
WHERE status IN ('complete', 'confirmed')
GROUP BY user_id
) AS first_txns
INNER JOIN wp_mepr_transactions AS txns
@mishterk
mishterk / example-table-definition-structure.json
Last active May 27, 2018
ACF Custom Database Tables plugin: Table definition JSON structure
View example-table-definition-structure.json
{
"name": "{custom_database_table_name}",
"relationship": "{post_type}",
"columns": [
"{acf_field_name_1}",
"{acf_field_name_1}",
"{acf_field_name_3}"
]
}
You can’t perform that action at this time.