Skip to content

Instantly share code, notes, and snippets.

@timersys
timersys / functions.php
Created July 9, 2018 21:15
Open popup after submitting contact form 7
<?php
// Print javascript code in the footer of the site to trigger the popup upon form submission
add_action('wp_footer', 'add_popups_trigger_code',150 );
function add_popups_trigger_code(){
// show code on certain page, comment out to print code on every page
if( ! is_page('520') )
return;
?>
<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
@timersys
timersys / functions.php
Last active March 7, 2018 12:02
Pass custom data to GeotargetingWP plugins instead of the API
<?php
/**
* If you want to cancel API calls for any reason or to pass custom that you can use the following
* filter. Note that we use json_decode(json_encode to pass an object instead of an array
**/
// Cancel query only for admins
add_filter('geot/cancel_query', function() {
if( ! current_user_can('administrator') )
return false;
@timersys
timersys / functions.php
Last active May 10, 2018 20:14
Change WpRocket cache level for Geotargeting WP or disable it
<?php
/**
* By default WpRocket plugin will create different cache pages at a country level
* To add more levels (states or cities) you need to add the following filter
*/
add_filter('rocket_geotargetingwp_enabled_cookies', function($enable){
$enable[] = 'state';
//$enable[] = 'city';
return $enable;
@timersys
timersys / functions.php
Created December 14, 2017 19:33
Disable Images Loaded plugin in Popups premium javascript
<?php // don't include opening tag if already exist
// Popups premium disable images loaded plugin
add_filter('spu/spuvar/imagesloaded', '__return_false');
@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 / functions.php
Last active January 9, 2020 20:25
Custom scopes with Facebook Login WordPress plugin https://timersys.com/plugins/facebook-login-pro/
<?php
/**
* Collect custom scopes with Facebook Login WordPress plugin
* https://timersys.com/plugins/facebook-login-pro/
**/
// Change default scopes
add_filter('fbl/app_scopes', function( $scopes ) {
return 'email,public_profile,user_posts'; // pass custom scopes
});
@timersys
timersys / popups.js
Created July 31, 2017 16:57
Videos on Popups plugin
/**
* Snippet for WordPress popup plugin
* https://wordpress.org/plugins/popups/
* Add this in your theme javascript files
*/
/**
* How to pause videos when popup is closed
* Replace 123 with your popup id
*/
@timersys
timersys / functions.php
Last active April 10, 2017 14:03
Remove Popups plugin side metaboxes
<?php // don't include this line if php already started
function remove_spu_boxes() {
remove_meta_box( 'spu-support', 'spucpt', 'side' );
remove_meta_box( 'spu-donate', 'spucpt', 'side' );
remove_meta_box( 'spu-links', 'spucpt', 'side' );
}
add_action( 'add_meta_boxes', 'remove_spu_boxes',15 );
@timersys
timersys / style.css
Created January 31, 2017 12:42
Popups premium placeholder change colors
.spu-fields::-webkit-input-placeholder { /* WebKit, Blink, Edge */
color: #909 !important;
}
.spu-fields:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
color: #909 !important;
opacity: 1;
}
.spu-fields::-moz-placeholder { /* Mozilla Firefox 19+ */
color: #909 !important;
opacity: 1;
@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;