Skip to content

Instantly share code, notes, and snippets.

@timersys
timersys / geot-redirects.php
Created December 12, 2016 12:29
Redirect sitepress WPML + Geotargeting
<?php
/**
* Redirect WPML + Geotargeting shared by thomsonreuters.com
*/
function redirect_ip_country(){
global $wpdb, $post, $sitepress;
@timersys
timersys / functions.php
Last active October 8, 2016 19:05
Change default currency on woocommerce depending on user country
<?php
/**
* Change default WPML Woocommerce currency
* depending on user's country
* https://timersys.com/?p=21090&preview=true
*/
function geot_woo_default_currency( $currency ) {
if( ! function_exists( 'geot_country_code' ) || isset( $_COOKIE['geot_currency'] ) )
return $currency;
@timersys
timersys / remove-woo-slug.php
Last active December 10, 2024 02:25
Remove product-category slug from Woocommerce
<?php
/*
Plugin Name: Remove product-category slug
Plugin URI: https://timersys.com/
Description: Check if url slug matches a woocommerce product category and use it instead
Version: 0.1
Author: Timersys
License: GPLv2 or later
*/
@timersys
timersys / functions.php
Created September 22, 2016 17:54
Change geotargeting hook to be able to use template functions
<?php
/**
* Change geotargeting hook to be able to use template functions
* */
add_action('init', 'change_geot_hook',5);
function change_geot_hook(){
global $geot;
remove_action( 'init', array( $geot->public, 'geot_redirections' ));
add_action( 'template_redirect', array( $geot->public, 'geot_redirections' ));
}
@timersys
timersys / functions.php
Created July 28, 2016 12:56
Create a whitelist for geotargeting redirections in WordPress
<?php
/**
* Create a whitelist for geotargeting redirections
* to be used with Geotargeting Pro plugin https://timersys.com/plugins/geotargeting-pro/
* */
// add filter before redirects are performed
add_action( 'init', 'geot_redirects', 9 );
function geot_redirects() {
add_filter( 'geot/perform_redirect', 'geot_redirect_whitelist');
}
@timersys
timersys / custom-email-template.php
Last active June 11, 2016 14:49
Custom email templates for WordPress Plugin
<?php
/**
* Custom Email Template
*
* @wordpress-plugin
* Plugin Name: Custom Email Template
* Plugin URI: http://wordpress.org/plugins/email-templates
* Description: Custom template for Email templates plugin
* Version: 1.0.0
* Author: Damian Logghe
@timersys
timersys / geot-widget.php
Last active June 1, 2016 13:17
Custom dropdown widget for geotargeting plugin
<?php
/**
* Geotargeting dropdown
* @link https://timersys.com/geotargeting/
*
* @wordpress-plugin
* Plugin Name: GeoTargeting Pro Custom Redirects
* Plugin URI: https://timersys.com/geotargeting/
* Description: Geo Targeting custom dropdown widget values
* Version: 1.0.0
@timersys
timersys / header.php
Created May 9, 2016 12:46
Show different WordPress menus depending on user country.
<?php
/**
* Show different WordPress menus depending on user country
* by using Geotargeting plugin API functions
* https://timersys.com/plugins/geotargeting-pro/
**/
if( function_exists( 'geot_target' ) ) {
//USA menu
if( geot_target( 'US' ) ) {
wp_nav_menu( array(
@timersys
timersys / functions.php
Last active March 6, 2016 15:19
Display Maxmind shortcodes in your own language
<?php
/**
* In Geotargeting Pro plugin you can print countries and states using shortcodes
* These are printed in English by default but Maxmind provide more languages
* Get WordPress Geotargeting plugin in https://timersys.com/plugins/geotargeting-pro/
* Cities languages are only included in premium databases or insights services ( https://www.maxmind.com/en/geoip2-precision-services&rld=timersys )
* Avilable languages:
* de German
* en English English names may still include accented characters if that is the accepted spelling in English. In other words, English does not mean ASCII.
* es Spanish
@timersys
timersys / script.js
Created March 3, 2016 16:43
Open a Popup programatically using Javascript
/**
* Function to open or close Popups programatically using Javascript
* Popup Plugin https://wordpress.org/plugins/popups/
*
**/
SPU.show(120);
SPU.hide(120, false, true);