Skip to content

Instantly share code, notes, and snippets.

View moskalukigor's full-sized avatar

Ihor moskalukigor

View GitHub Profile
@moskalukigor
moskalukigor / Add custom page to buddypress profile
Created April 7, 2021 13:11 — forked from modemlooper/php
Example on adding a page to user profile
<?php
/**
* Plugin Name: BP Add Page
* Plugin URI: https://webdevstudios.com
* Description: Example on adding a page to BuddyPress profiles
* Author: WebDevStudios
* Author URI: https://webdevstudios.com
* Version: 1.0.0
* License: GPLv2
*/
@moskalukigor
moskalukigor / USEinsta.php
Created January 30, 2018 09:16 — forked from Tusko/USEinsta.php
Instagram API + Wordpress Cache
<?php
/*
You need to authorize your app with scope=public_content
Example:
https://api.instagram.com/oauth/authorize/?client_id=YOUR_CLIENT_ID&redirect_uri=REDIRECT_URL&response_type=token&scope=public_content
*/
$get_my_insta = instagram_feed('USERNAME', 'APP_IP', 'ACCESS_TOKEN', 10);
if ( $get_my_insta ) {
@moskalukigor
moskalukigor / getTaxTermsByOtherTaxTerm.php
Created October 4, 2017 08:54 — forked from vovadocent/getTaxTermsByOtherTaxTerm.php
Get Taxonomy Terms By Other Taxonomy Term
<?php
function getTaxTermsByOtherTaxTerm($taxonomy_1, $term_id, $taxonomy_2, $post_type = NULL) {
global $wpdb;
$post_type_q = !empty($post_type_q) ? "AND p.post_type = '$post_type'" : "";
$sql = "SELECT r.object_id FROM $wpdb->terms AS t
INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id
INNER JOIN $wpdb->term_relationships AS r ON r.term_taxonomy_id = tt.term_taxonomy_id
INNER JOIN $wpdb->posts AS p ON (p.ID = r.object_id AND p.post_status = 'publish' $post_type_q)
WHERE tt.taxonomy = '$taxonomy_1' AND t.term_id = $term_id";
$res = $wpdb->get_col($sql);
@moskalukigor
moskalukigor / content-single-product.php
Created September 13, 2017 07:55 — forked from georgybu/content-single-product.php
WooCommerce - Show next\prev products from current product category (when viewing a single product) 1. If product is last -> Next product is first 2. If product is first -> Prev product is last forked from https://gist.github.com/2176823 (This question was in http://stackoverflow.com/questions/13597687/woocommerce-get-next-previous-product/13612387
<?php
// get next and prev products
// Author: Georgy Bunin (bunin.co.il@gmail.com)
// forked from https://gist.github.com/2176823
function ShowLinkToProduct($post_id, $categories_as_array, $label) {
// get post according post id
$query_args = array( 'post__in' => array($post_id), 'posts_per_page' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'tax_query' => array(
array(
'taxonomy' => 'product_cat',
@moskalukigor
moskalukigor / functions.php
Created August 28, 2017 13:01 — forked from zorzv/functions.php
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
@moskalukigor
moskalukigor / gist:792df0c6e379bc318ec0e118ea2f9f48
Created August 2, 2017 14:20 — forked from mikejolley/gist:1604009
WooCommerce - Add a special field to the checkout, order emails and user/order meta
/**
* Add the field to the checkout
**/
add_action('woocommerce_after_order_notes', 'my_custom_checkout_field');
function my_custom_checkout_field( $checkout ) {
echo '<div id="my_custom_checkout_field"><h3>'.__('My Field').'</h3>';
/**
@moskalukigor
moskalukigor / functions.php
Created January 9, 2017 12:27 — forked from Tusko/functions.php
WP Ajax search (ACF included)
<?php
/* Wordpress Custom Search by title, ACF, post_meta */
// Wordpress ?s= redirect to /search/
function wpa_search_redirect() {
global $wp_rewrite;
if (!isset($wp_rewrite) || !is_object($wp_rewrite) || !$wp_rewrite->using_permalinks()) { return; }
$search_base = $wp_rewrite->search_base;
if (is_search() && !is_admin() && strpos($_SERVER['REQUEST_URI'], "/{$search_base}/") === false) {
wp_redirect(home_url("/{$search_base}/" . urlencode(get_query_var('s'))));