Skip to content

Instantly share code, notes, and snippets.

View apple_news_remove_empty_p_tags.php
function apple_news_remove_empty_p_tags($content, $post_id) {
$new_content = preg_replace('/<span[^>]*>[\s\040\t\r\n\W]*<\/span>/', '', $content);
$new_content = preg_replace('/<span[^>]*>&nbsp;*<\/span>/', '', $new_content);
$new_content = preg_replace('/<span[^>]*> <\/span>/', '', $new_content);
$new_content = preg_replace('/<p[^>]*>[\s\040\t\r\n\W]*<\/p>/', '', $new_content);
$new_content = preg_replace('/<p[^>]*>&nbsp;*<\/p>/', '', $new_content);
$new_content = preg_replace('/<p[^>]*> <\/p>/', '', $new_content);
return $new_content;
View sortby-es6.js
// Save existing sort parameters
Shopify.queryParams = {};
if(location.search.length) {
for(var aKeyValue, i = 0, aCouples = location.search.substr(1).split('&'); i < aCouples.length; i++) {
aKeyValue = aCouples[i].split('=');
if (aKeyValue.length > 1) {
Shopify.queryParams[decodeURIComponent(aKeyValue[0])] = decodeURIComponent(aKeyValue[1]);
}
}
}
@cfxd
cfxd / class-membership.php
Created Feb 15, 2019 — forked from wturnerharris/class-membership.php
Class to make things members-only in WordPress.--This class depends on a custom capability called 'is_approved_member' for user member access and the custom post meta key '_members_only' as a post-level custom field.
View class-membership.php
<?php
/**
* Custom class for WP_Membership routines.
*
*
* @package WP_Membership
* @since WP_Membership 0.1
*/
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
View _quickview.scss.liquid
#quick-view {
display: flex;
height: 100%;
justify-content: flex-end;
flex-wrap: wrap;
position: relative;
-ms-overflow-style: -ms-autohiding-scrollbar;
.qv-product-images {
width: 60%;
height: auto;
View gist:1e8b929851bbd1dbe008073997008ad3
// Update PHP version when using AMP setup from https://alanthing.com/blog/2014/12/22/os-x-1010-yosemite-local-development-environment-apache-php-and-mysql-homebrew/
$ brew install php72 --with-fpm --without-apache --with-homebrew-curl --with-homebrew-openssl --without-snmp
View filter.php
<?php
/*
* THE FILTER
*
*/
function custom_responsive_image_sizes($sizes, $img_name, $attachment_id) {
$sizes = wp_get_attachment_image_sizes($attachment_id, 'original');
$meta = wp_get_attachment_metadata($attachment_id);
$width = $meta['width'];
View woocommerce_loop-custom.php
<?php
if(!function_exists('wc_get_products')) {
return;
}
$paged = (get_query_var('paged')) ? absint(get_query_var('paged')) : 1;
$ordering = WC()->query->get_catalog_ordering_args();
$ordering['orderby'] = array_shift(explode(' ', $ordering['orderby']));
$ordering['orderby'] = stristr($ordering['orderby'], 'price') ? 'meta_value_num' : $ordering['orderby'];
View load_existing_product_gallery_into_acf_gallery_field.php
@cfxd
cfxd / keybindings.json
Last active Nov 21, 2017
Visual Studio Code settings
View keybindings.json
// Place your key bindings in this file to overwrite the defaults
[
{ "key": "ctrl+1", "command": "" },
{ "key": "ctrl+2", "command": "" },
{ "key": "ctrl+3", "command": "" },
{ "key": "ctrl+4", "command": "" },
{ "key": "ctrl+5", "command": "" },
{ "key": "ctrl+6", "command": "" },
{ "key": "ctrl+7", "command": "" },
{ "key": "ctrl+8", "command": "" },
View add_initial_file_size_postmeta.php
<?php
// Adds initial meta to each attachment
function add_initial_file_size_postmeta($column_name, $post_id) {
static $query_ran;
if($query_ran !== null) {
$all_imgs = new WP_Query(array(
'post_type' => 'attachment',
'post_status' => 'inherit',
You can’t perform that action at this time.