Skip to content

Instantly share code, notes, and snippets.

Avatar

Bjorn Holine bjorn2404

View GitHub Profile
@bjorn2404
bjorn2404 / functions.php
Last active Jan 27, 2021
ElasticPress exclude post type from "Weight results by date" decay
View functions.php
<?php
/**
* Filter the arguments sent to EP query
*
* @param array $formatted_args Formatted Elasticsearch query
* @param array $query_vars Query variables
* @param array $query Query part
*
* @return array
@bjorn2404
bjorn2404 / locations-import.csv
Created Jan 17, 2021
Cardinal Locator CSV import structure
View locations-import.csv
name description website address city state postal country hours1 hours2 hours3 hours4 hours5 hours6 hours7 phone email categories
@bjorn2404
bjorn2404 / functions.php
Last active May 11, 2018
CSL manual front-end filters register example
View functions.php
<?php
/**
* Manually add categories for static data.
* The property ('category' below) should match the property/attribute name in your JSON or XML data.
* The value ('category-filter' below) should match the ID of the HTML container element around the input fields.
*/
function bh_sl_manual_categories() {
?>
<script>
@bjorn2404
bjorn2404 / page-template.php
Last active May 11, 2018
CSL manual front-end filters markup example
View page-template.php
<div class="bh-sl-container">
<div class="bh-sl-form-container">
<form id="bh-sl-user-location" method="post" action="#">
<div class="form-input">
<label for="bh-sl-address">Enter Address or Zip Code:</label>
<input type="text" id="bh-sl-address" name="bh-sl-address" />
</div>
<button id="bh-sl-submit" type="submit">Submit</button>
@bjorn2404
bjorn2404 / wp_kses_post_tags.php
Last active Jul 20, 2021
WordPress allow iFrames with wp_kses_post filter
View wp_kses_post_tags.php
<?php
/**
* Add iFrame to allowed wp_kses_post tags
*
* @param array $tags Allowed tags, attributes, and/or entities.
* @param string $context Context to judge allowed tags by. Allowed values are 'post'.
*
* @return array
*/
@bjorn2404
bjorn2404 / nginx.conf
Created Mar 28, 2016
WordPress load remote images if they don't exist on the local development server NGINX. vagrant provision after editing site conf file.
View nginx.conf
location ~ ^/wp-content/uploads/(.*) {
if (!-f $request_filename) {
rewrite ^/wp-content/uploads/(.*)$ http://www.remotesite.com/wp-content/uploads/$1 redirect;
}
}
@bjorn2404
bjorn2404 / favicon.txt
Created Nov 10, 2015
Imagemagick favicon
View favicon.txt
convert favicon.png -bordercolor white -border 0 \
\( -clone 0 -resize 16x16 \) \
\( -clone 0 -resize 32x32 \) \
\( -clone 0 -resize 48x48 \) \
\( -clone 0 -resize 64x64 \) \
\( -clone 0 -resize 128x128 \) \
\( -clone 0 -resize 256x256 \) \
-delete 0 -alpha off -colors 256 favicon.ico
@bjorn2404
bjorn2404 / php_format_address
Last active Aug 29, 2015
PHP format street address
View php_format_address
/**
* Format a street address
*
* @param array $address Address.
*
* @return null|string
*/
function format_address( $address ) {
$formatted_address = null;
@bjorn2404
bjorn2404 / wordpress_remote_images
Created May 21, 2015
WordPress load remote images if they don't exist on the local development server htaccess
View wordpress_remote_images
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/wp-content/uploads/(.*)$
RewriteCond %{DOCUMENT_ROOT}/wp-content/uploads/%1 !-f
RewriteRule ^wp-content/uploads/(.*)$ http://www.remotesite.com/wp-content/uploads/$1 [R=301,L]
</IfModule>
@bjorn2404
bjorn2404 / gist:276741cce5cacd35a4ab
Created Jul 2, 2014
Remove duplicate WordPress post meta
View gist:276741cce5cacd35a4ab
<?php
require_once('../../../wp-load.php'); //File was temporarily placed in the theme
define( 'WP_DEBUG_DISPLAY', true );
ini_set( 'display_errors', true );
$allposts = get_posts('numberposts=-1&post_type=guide&post_status=any'); //Post query
$keys = array('address', 'address2', 'city', 'state', 'zip'); //Add post meta keys here
foreach ( $keys as $key ) {
foreach( $allposts as $postinfo) {