Skip to content

Instantly share code, notes, and snippets.

@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 / gist:d68690a85aed14a02318
Last active December 13, 2019 14:56
Wordpress popups - Open popup with link
// To open popup with ID 3 on same page (preferred)
<a href="" class="spu-open-3" title="Click here">Click here</a>
// Another way
<a href="#spu-3" title="Click here">Click here</a>
// To go to a new page and open a popup there
<a href="http://mydomain.com/new-page/#spu-3" title="Click here">Click here</a>
@timersys
timersys / functions.php
Created December 3, 2019 14:50
custom shortcode to insert javascript
// 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 October 18, 2019 17:20
Cancel post geotargeting on certain pages
<?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;
@timersys
timersys / gist:03067ac7594fdce288ca
Last active May 18, 2019 15:15
Wordpress popups plugin. Allow editors to edit popups
<?php // <-- don't add this in your functions.php if already there
/**
* https://wordpress.org/support/plugin/popups
* Allow editors to edit popups
* For more roles check https://codex.wordpress.org/Roles_and_Capabilities
*/
add_filter('spu/settings_page/roles', 'my_custom_role');
function my_custom_role(){
return 'edit_others_posts';
}
<?php // don't add this tag
// 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>
<?php // don't add this tag
// 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>
<?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>';
}
@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 May 16, 2018 14:21
Change geot IP for local development
<?php
/**
* Geotargeting Plugin. https://wordpress.org/plugins/geotargeting/
* Filter IP if you are for example in local host
*/
add_filter( 'geot/user_ip', 'geot_ip');
function geot_ip( $ip ) {
return '192.192.192.192';
}