Skip to content

Instantly share code, notes, and snippets.

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]);
}
}
}
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 shortcode.css
.wp-video, video.wp-video-shortcode, .mejs-container, .mejs-overlay.load {
width: 100% !important;
height: 100% !important;
}
.mejs-container {
padding-top: 56.25%;
}
.wp-video, video.wp-video-shortcode {
max-width: 100% !important;
}
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 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 paginate_links.php
View mailpoet-wp_mail.php
function mailpoet_enable_wpmail(){
if(class_exists('WYSIJA')){
$model_config = WYSIJA::get('config','model');
$model_config->save(array('allow_wpmail' => true));
}
}
add_action('init', 'mailpoet_enable_wpmail');
@cfxd
cfxd / Gruntfile.js
Last active Apr 24, 2019
Remove Unused CSS from WordPress Automatically with Grunt. See http://cfxdesign.com/remove-unused-css-from-roots-theme-automatically-with-grunt/
View Gruntfile.js
'use strict';
module.exports = function(grunt) {
// Load all tasks
require('load-grunt-tasks')(grunt);
// Show elapsed time
require('time-grunt')(grunt);
var jsFileList = [
'assets/vendor/bootstrap/js/transition.js',
'assets/vendor/bootstrap/js/alert.js',
@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"]))
@cfxd
cfxd / gulp_module_installation
Last active Jan 29, 2019
Gulpfile and module installation for UnCSS + Gulp + Sage 8.3.0
View gulp_module_installation
$ npm install gulp-uncss gulp-exec --save-dev
You can’t perform that action at this time.