Skip to content

Instantly share code, notes, and snippets.

Avatar

Damian timersys

View GitHub Profile
@timersys
timersys / gist:4480bccf64a1147abb3d
Last active Feb 22, 2021
wp_remote_get debug script
View gist:4480bccf64a1147abb3d
<?php
/**
* Plugin Name: Wp Remote Test
* Plugin URI:
* Version: 0.1
* Description: Debug wp_remote_get and wp_remote_post
* Author: Damian Logghe
* Author URI: http://wp.timersys.com
*/
View functions.php
<?php
// geot_user_country
// Return object of current user country details
$country = geot_user_country();
echo $country->name;
echo $country->isoCode;
//geot_country_code
// return current user country code
@timersys
timersys / functions.php
Created Jan 19, 2021
Wrap functions to be safe
View functions.php
<?php
if( function_exists( 'geot_target' ) ) {
if( geot_target( 'AR' ) ) {
echo 'Only show to Argentina';
}
}
@timersys
timersys / functions.php
Last active Dec 18, 2020
GeotargetingWP PHP functions
View functions.php
<?php
/**
* geot_target()
*
* Main function that return true or false depending if current user
* target the given countries
*
* @param string/Array $country - Pass an array of countries ,country name or country code
* @param string $country_region - Region name
* @param string $exclude/Array -Pass an array of countries ,country name or country code
@timersys
timersys / class-geot-dropdown-widget.php
Created Aug 26, 2020
Custom ZIP switcher for GeotargetingWP
View class-geot-dropdown-widget.php
<?php
/**
* Adds GeoTarget Widget
* @since 1.0.0
*/
class GeotS_Widget extends WP_Widget {
/**
* Register widget with WordPress.
@timersys
timersys / gist:13af6af06ea0bbb38c73
Created Mar 6, 2015
Protect files in Easy Digital Downloads + Nginx
View gist:13af6af06ea0bbb38c73
#EDD + Nginx - protect your files
location ~ ^/wp-content/uploads/edd/(.*?)\.zip$ {
rewrite / permanent;
}
@timersys
timersys / script.js
Last active May 28, 2020
Simple Content locker Plugin
View script.js
jQuery( document ).ready(function(){
FB.Event.subscribe( 'edge.create', function( href ) {
createCookie('wptuts-lock_'+wptuts_content_locker.ID,true,9999);
location.reload(); //if you use cache maybe you want to add a ?nocache=true to this url
});
});
function createCookie( name, value, days ) {
@timersys
timersys / geot-wprocket.php
Created Apr 13, 2020
Tiny plugin to enable State cache to Wp Rocket + GeotargetingWP
View geot-wprocket.php
<?php
/**
* Plugin Name: Wp Rocket + GeotargetingWP States
* Plugin URI: https://geotargetingwp.com
* Description: Enable states cache for WPRocket.
* Author: timersys
* Author URI: https://geotargetingwp.com
*/
/**
@timersys
timersys / functions.php
Last active Mar 18, 2020
Enable support for WooCommerce Price Based on Country
View functions.php
<?php // don't include this line
/**
* Enable support for WooCommerce Price Based on Country and GeotargetingWP
* First enable cache mode or you will consume lot of credits.
*/
if( function_exists('geot_country_code')) {
add_action( 'init', 'geotwp_wcpb_set_country', 10 );
function geotwp_wcpb_set_country(){
if( ! function_exists('wcpbc_set_woocommerce_country') )
@timersys
timersys / wppopups-lists.php
Created Feb 18, 2020
How to add your email to multiple newsletter lists
View wppopups-lists.php
<?php
/**
* Plugin Name: WP Popups newsletter lists
* Plugin URI: https://wppopups.com
* Description: Beginner friendly WordPress popup builder plugin.
* Author: timersys
* Author URI: https://wppopups.com
* Version: 1.0.0
*/
add_filter( 'wppopups/newsletter/subscribe_data', function($data) {