Skip to content

Instantly share code, notes, and snippets.

@timersys
timersys / file.php
Created April 23, 2021 16:33
AJAX PHP functions in GeotargetingWP
<?php
/**
* Practical example on how to use ajax php functions
**/
$html = '<p>This is your HTML you want to apply geotargeting, if you have complex and large content you could use ob_start() and ob_get_clean() to fill this variable with the HTML</p>';
$html_world = '<p>Some other HTML for everyone except US and CA</p>';
// We echo the part for and US,CA. Javascript will take care of hide or show the $html
echo ajax_geotwp_filter( ['country' => 'US,CA'],$html);
@timersys
timersys / gist:4480bccf64a1147abb3d
Last active February 22, 2021 18:42
wp_remote_get debug script
<?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
*/
@timersys
timersys / functions.php
Created January 19, 2021 14:11
Wrap functions to be safe
<?php
if( function_exists( 'geot_target' ) ) {
if( geot_target( 'AR' ) ) {
echo 'Only show to Argentina';
}
}
@timersys
timersys / class-geot-dropdown-widget.php
Created August 26, 2020 20:56
Custom ZIP switcher for GeotargetingWP
<?php
/**
* Adds GeoTarget Widget
* @since 1.0.0
*/
class GeotS_Widget extends WP_Widget {
/**
* Register widget with WordPress.
@timersys
timersys / gist:13af6af06ea0bbb38c73
Created March 6, 2015 17:09
Protect files in Easy Digital Downloads + Nginx
#EDD + Nginx - protect your files
location ~ ^/wp-content/uploads/edd/(.*?)\.zip$ {
rewrite / permanent;
}
@timersys
timersys / script.js
Last active May 28, 2020 21:06
Simple Content locker Plugin
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 April 13, 2020 14:12
Tiny plugin to enable State cache to Wp Rocket + GeotargetingWP
<?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 March 18, 2020 15:47
Enable support for WooCommerce Price Based on Country
<?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 February 18, 2020 08:25
How to add your email to multiple newsletter lists
<?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) {
@timersys
timersys / geot.php
Created January 20, 2020 15:01
Disable GeotargetingWP Sessions
<?php
/**
* Plugin Name: Disable GeotargetingWP Sessions
* Plugin Author: Damian Logghe
*/
// disable geotwp sessions
add_filter( 'geot/sessions/start_session', '__return_false');