This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl --header 'Authorization: token INSERTACCESSTOKENHERE' \ | |
--header 'Accept: application/vnd.github.v3.raw' \ | |
--remote-name \ | |
--location https://api.github.com/repos/owner/repo/contents/path | |
# Example... | |
TOKEN="INSERTACCESSTOKENHERE" | |
OWNER="BBC-News" | |
REPO="responsive-news" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Disable REST API user endpoints | |
add_filter( 'rest_endpoints', function( $endpoints ){ | |
if ( isset( $endpoints['/wp/v2/users'] ) ) { | |
unset( $endpoints['/wp/v2/users'] ); | |
} | |
if ( isset( $endpoints['/wp/v2/users/(?P<id>[\d]+)'] ) ) { | |
unset( $endpoints['/wp/v2/users/(?P<id>[\d]+)'] ); | |
} | |
return $endpoints; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_before_cart', 'apply_matched_coupons' ); | |
function apply_matched_coupons() { | |
global $woocommerce; | |
$get1 = 'getonech'; // your coupon code here | |
$get2 = 'gettwoch'; // your coupon code here | |
$get3 = 'getthreech'; // your coupon code here | |
$get4 = 'getfourch'; // your coupon code here | |
$get5 = 'getfivech'; // your coupon code here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Register new endpoint to use inside My Account page. | |
* | |
* @see https://developer.wordpress.org/reference/functions/add_rewrite_endpoint/ | |
*/ | |
function my_custom_endpoints() { | |
add_rewrite_endpoint( 'refer-a-friend', EP_ROOT | EP_PAGES ); | |
} | |
add_action( 'init', 'my_custom_endpoints' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The dashboard-specific functionality of the plugin. | |
* | |
* Defines the plugin name, version, and two examples hooks for how to | |
* enqueue the dashboard-specific stylesheet and JavaScript. | |
* | |
* @package Gens_RAF | |
* @subpackage Gens_RAF/admin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_shortcode('my-referals','raf_show_coupons'); | |
function raf_show_coupons($atts, $content = null) { | |
$user_info = get_userdata(get_current_user_id()); | |
$user_email = $user_info->user_email; | |
$date_format = get_option( 'date_format' ); | |
$args = array( | |
'posts_per_page' => -1, | |
'post_type' => 'shop_coupon', | |
'post_status' => 'publish', | |
'meta_query' => array ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function gens_send_buyer_email($order_email,$coupon_code) { | |
if ( !$order_email || !$coupon_code) { | |
return false; | |
} | |
global $woocommerce; | |
$mailer = $woocommerce->mailer(); | |
$user_message = get_option( 'gens_raf_buyer_email_message' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Stop referrals if product isnt in category | |
function only_specific_cat($not_active,$num_friends_refered,$order) { | |
$items = $order->get_items(); | |
$not_active = "yes"; // if this function returns "yes", order wont be saved as referral. | |
foreach ( $items as $item ) { | |
$product_id = $item['product_id']; | |
$term_list = wp_get_post_terms($product_id, 'product_cat', array('fields' => 'ids')); | |
if (is_array($term_list) && in_array("add_your_cat_id_here", $term_list)) { | |
$not_active = "no"; // this means there is product cat here, and coupon will be generated |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Povuci sve lokacije najblize lat i lon koji su prosledjeni | |
function get_posts_by_geo_distance($post_type,$lat_key,$lng_key,$source_lat,$source_lng) { | |
global $wpdb; | |
$sql =<<<SQL | |
SELECT | |
rl.ID, | |
rl.post_title AS location, | |
ROUND(6371*2*ASIN(SQRT(POWER(SIN(({$source_lat}-abs(lat.lat))*pi()/180/2),2)+ | |
COS({$source_lat}*pi()/180)*COS(abs(lat.lat)*pi()/180)* |