Skip to content

Instantly share code, notes, and snippets.

Avatar

Damian timersys

View GitHub Profile
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 / 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 / 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 / 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) {
@timersys
timersys / geot.php
Created Jan 20, 2020
Disable GeotargetingWP Sessions
View geot.php
<?php
/**
* Plugin Name: Disable GeotargetingWP Sessions
* Plugin Author: Damian Logghe
*/
// disable geotwp sessions
add_filter( 'geot/sessions/start_session', '__return_false');
@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 / functions.php
Created Dec 3, 2019
custom shortcode to insert javascript
View functions.php
// insert javascript into WordPress posts or popups
// use shortcode [wpp_insert]
add_shortcode( 'wpp_insert', 'wpp_insert_code' );
function wpp_insert_code() {
ob_start();
?>
<!-- paste your html and javascript here -->
<?php
$html = ob_get_clean();
return $html;
@timersys
timersys / functions.php
Created Oct 18, 2019
Cancel post geotargeting on certain pages
View functions.php
<?php
// cancel geotargeted posts on certain pages
add_filter('geot/cancel_posts_where', 'geotwp_cancel_geo' );
function geotwp_cancel_geo( $query ) {
// cancel for every page that is not search
if( ! is_page('search') ) {
return true;
View functions.php
<?php // don' add this tag
// Open popup after WpForms submission
add_action( 'wpforms_process_complete_534', 'spu_popup_trigger' );
function spu_popup_trigger(){
add_action('wp_footer','spu_open_popup',99);
}
function spu_open_popup(){
echo '<script>setTimeout(function(){SPU.show(529)},1000);</script>';
}