Skip to content

Instantly share code, notes, and snippets.

@zorzv
zorzv / functions.php
Created February 3, 2017 19:15
Autocomplete Taxonomy Terms in Wordpress
//Custom Autocomplete
add_action('wp_ajax_nopriv_get_listing_names', 'ajax_listings');
add_action('wp_ajax_get_listing_names', 'ajax_listings');
function ajax_listings() {
global $wpdb; //get access to the WordPress database object variable
//get names of all taxonomy terms
$name = '%'.$wpdb->esc_like(stripslashes($_GET['name'])).'%'; //escape for use in LIKE statement
$sql = "SELECT term.term_id as id, term.name as post_title, term.slug as guid, tax.taxonomy FROM $wpdb->term_taxonomy tax
@zorzv
zorzv / functions.php
Created February 3, 2017 19:18
Include Taxonomy in Search
//Custom Search on Homepage
function custom_search_where($where){
global $wpdb;
if (is_search() && get_search_query())
$where .= "OR ((t.name LIKE '%".get_search_query()."%' OR t.slug LIKE '%".get_search_query()."%') AND {$wpdb->posts}.post_status = 'publish')";
return $where;
}
function custom_search_join($join){
global $wpdb;
@zorzv
zorzv / functions.php
Created November 6, 2019 19:15
Redirect Logged Out Users To Homepag
/**
* Redirect Logged Out Users To Homepage
*
* @uses template_redirect() Template Redirect action hook
* @uses is_user_logged_in() conditional tag
* @uses is_page() conditional tag
* @uses is_front_page() conditional tag
* @uses wp_redirect() WP Redirect function
*
*/
@zorzv
zorzv / functions.php
Last active November 6, 2019 19:20
Redirect Logged Out Users To Homepage
/**
* Redirect Logged Out Users To Homepage
*
* @uses template_redirect() Template Redirect action hook
* @uses is_user_logged_in() conditional tag
* @uses is_page() conditional tag
* @uses is_front_page() conditional tag
* @uses wp_redirect() WP Redirect function
* @uses home_url() Home URL function
*
@zorzv
zorzv / functions.php
Created November 6, 2019 19:19
Redirect Non-Members to Login Page
/**
* Redirect Visitors To Login Page
*
* @author Zo Rizvi
*
* @uses template_redirect() Template Redirect action hook
* @uses is_user_logged_in() conditional tag
* @uses is_page() conditional tag
* @uses is_front_page() conditional tag
* @uses wp_redirect() WP Redirect function
import android.content.Intent;
import android.util.SparseArray;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.navigation.NavController;
import androidx.navigation.fragment.NavHostFragment;
@zorzv
zorzv / cpt-to-cpt.php
Created August 17, 2021 12:13 — forked from HarishChaudhari/cpt-to-cpt.php
Copy posts from one Custom Post Type to another. (It doesn't handle post attachments for now)
<?php
add_action('admin_init', 'foo_duplicate_posts', 99999);
function foo_duplicate_posts(){
// Only allow admins to run the script
if(!current_user_can('manage_options'))
return;
// Check if keyword is set
if(!isset($_GET['duplicate-posts']))
@zorzv
zorzv / footer.liquid
Created August 17, 2021 12:14
Modify Powered by Shopify text in footer.liquid
@zorzv
zorzv / ld-auto-mark-complete.php
Created August 17, 2021 12:26 — forked from weismannweb/ld-auto-mark-complete.php
Auto complete learndash topics and lessons
//thanks to https://gist.github.com/sultann/24baa5483b4632c3cf214a8de5648204#file-ld-auto-mark-complete-php-L17 for most of
//this code, i just corrected it to work with ld_lesson_tag to grab the tags as the original version returned empty
//array since it was looking for standard wp tags
function ld_is_tagged($postId) {
//get all learndash tags on post
$tags = wp_get_post_terms($postId,'ld_lesson_tag');
foreach ($tags as $tag) {
//need to check for auto-mark-complete tag exists on this post
@zorzv
zorzv / Order Confirmation
Created September 8, 2021 12:38
Shopify Order Confirmation with Line Properties
{% capture email_title %}Thank you for your purchase! {% endcapture %}
{% capture email_body %}
{% if requires_shipping %}
{% case delivery_method %}
{% when 'pick-up' %}
You’ll receive an email when your order is ready for pickup.
{% when 'local' %}
Hi {{ customer.first_name }}, we're getting your order ready for delivery.
{% else %}
Hi {{ customer.first_name }}, we're getting your order ready to be shipped. We will notify you when it has been sent.