Skip to content

Instantly share code, notes, and snippets.

View omniacode's full-sized avatar

Jason Ryan omniacode

View GitHub Profile
@mgibbs189
mgibbs189 / test.php
Last active October 16, 2020 19:05
Show the reset button only when facets are active
<script>
(function($) {
$(document).on('facetwp-loaded', function() {
var in_use = ('' != FWP.build_query_string());
$('.your-reset-btn').toggleClass('hidden', ! in_use);
});
})(jQuery);
</script>
@ribeiroeder
ribeiroeder / relevanssi-attachment-metaboxio.php
Last active September 5, 2018 03:32
Relevanssi index attachment Metabox.io File Advanced titles for parent post
add_filter( 'relevanssi_content_to_index', 'rlv_index_attachment_names', 10, 2 );
function rlv_index_attachment_names( $content, $post_id ) {
if ($post_id->post_type == "your_post_type") {
$files = rwmb_meta( '_your_meta_file_advanced' );
foreach ( $files as $file ) {
$content .= ' ' . $file['title'];
}
}
return $content;
}
@djrmom
djrmom / script.js
Created July 23, 2018 17:17
facetwp check specifc filters in use
(function($) {
$(document).on('facetwp-loaded', function() {
var facets_in_use = function() {
var in_use = false;
var checking = ["who", "what", "where", "when"];
$.each(FWP.facets, function(name, val) {
if (0 < val.length && $.inArray( name, checking ) > -1) {
in_use = true;
return false; // exit loop
}
@woogists
woogists / wc-custom-sorting-options-asc-dec.php
Last active January 30, 2022 16:55
[Frontend Snippets] Custom sorting options (asc/desc)
/**
* Add custom sorting options (asc/desc)
*/
add_filter( 'woocommerce_get_catalog_ordering_args', 'custom_woocommerce_get_catalog_ordering_args' );
function custom_woocommerce_get_catalog_ordering_args( $args ) {
$orderby_value = isset( $_GET['orderby'] ) ? wc_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
if ( 'random_list' == $orderby_value ) {
$args['orderby'] = 'rand';
$args['order'] = '';
$args['meta_key'] = '';
@omniamike
omniamike / omnia-base.css
Last active November 10, 2022 15:21
Base CSS for Omnia Creative Studio site builds; global styles
/*
Omnia Base Styles
Version: 1.0
Author: Omnia Creative Studio
Author URI: https://omniacreativestudio.com/
*/
/* -- Alignment Helpers -- */
.align_left { text-align: left;}
@mattradford
mattradford / facetwp_load_more_and_all.php
Last active February 3, 2022 23:17
FacetWP load more and load all
// Adapted from https://gist.github.com/mgibbs189/f2469009a7039159e229efe5a01dab23
function fwp_load_more() {
?>
<script>
(function($) {
$(function() {
if ('object' != typeof FWP) {
return;
}
<?php
/**
* @package Smashing_plugin
* @version 1.0
*/
/*
Plugin Name: Smashing plugin
Plugin URI: https://www.smashingmagazine.com/2016/03/advanced-wordpress-search-with-wp_query/
Description: This is an example plugin for Smashing Magazine readers.
Author: Carlo Daniele
@kellenmace
kellenmace / get-users-first-last-name-wordpress.php
Created September 20, 2016 20:43
Get User's First and Last Name in WordPress
<?php
/**
* Get user's first and last name, else just their first name, else their
* display name. Defalts to the current user if $user_id is not provided.
*
* @param mixed $user_id The user ID or object. Default is current user.
* @return string The user's name.
*/
function km_get_users_name( $user_id = null ) {
@sarahmonster
sarahmonster / add-span-to-count.php
Created August 22, 2016 13:22
Adds a span around post counts in category archives widget and general archives widgets. This allows for easy styling of the count—for instance, using leading dots. (The SCSS file adds leading dots.)
/**
* Filter the categories archive widget to add a span around post count
*/
function smittenkitchen_cat_count_span( $links ) {
$links = str_replace( '</a> (', '</a><span class="post-count">(', $links );
$links = str_replace( ')', ')</span>', $links );
return $links;
}
add_filter( 'wp_list_categories', 'smittenkitchen_cat_count_span' );
add_action( 'pmxi_saved_post', 'post_saved', 10, 1 );
function post_saved( $id ) {
global $wpdb;
$pass = get_user_meta( $id, 'xfer_user_pass', true );
$table = $wpdb->prefix . 'users';
$wpdb->query( $wpdb->prepare(
"
UPDATE `" . $table . "`
SET `user_pass` = %s