Skip to content

Instantly share code, notes, and snippets.


Thomas Maier webzunft

View GitHub Profile
webzunft / fix-unclosed-query.php
Created Sep 25, 2020
Fixes an unclosed WP_Query() or query_posts() before Advanced Ads loads an ad
View fix-unclosed-query.php
* Fix the "Current post is not identical to main post."
* and "Current query is not identical to main query." warnings in Advanced Ads
* caused by custom queries not using wp_reset_postdata() or wp_reset_query()
* @source
* @source
* @source
* Developers should not use this and rather add wp_reset_postdata() or wp_reset_query() to their code
webzunft / shortcodes.php
Last active Dec 10, 2019
Extend edd_aa_all_access() function in EDD All Access to work for multiple All Access passes
View shortcodes.php
* Shortcode which can be used to easily give a user the option to log in or purchase an All Access Pass.
* If the user is already logged in but does not have a valid All Access Pass, they will see a buy button.
* If the user is both logged in and has a valid All Access Pass, they will be redirected to the page defined by the shortcode args.
* Can also be used to restrict content.
* @since 1.0.0
* @param array $atts Shortcode attributes
* @param string $content
webzunft / helper-functions.php
Last active Dec 10, 2019
Suggestion for improved edd_all_access_user_has_pass() in EDD All Access
View helper-functions.php
* Check if a specific customer has a valid, specific All Access Pass.
* @since 1.0.0
* @param int - The ID of the user
* @param mixed - The ID of the All Access product, separate multiple IDs using comma
* @param mixed - The price_id (price variation) of the All Access product, separate multiple IDs using comma, leave empty for all price IDs
* @param string - The status of the pass we want to check if the user has.
* @return object/int - The All Access Pass if it exists or false if not.
View geo-targeting.php
<div style="min-width: 300px; height: auto; padding: 10px; background: #fff; color: #333; text-align: center; border: solid 1px #ddd;">
<p>Your location:</p>
if( class_exists( 'Advanced_Ads_Geo_Api' ) ) :
$api = Advanced_Ads_Geo_Api::get_instance();
$ip = $api->get_real_IP_address();
$error = false;
$my_country = '';
$my_country_isoCode = '';
$my_city = '';
webzunft / advanced-ads-company-category.php
Last active Mar 5, 2019
Add a company taxonomy to ads managed by the Advanced Ads plugin.
View advanced-ads-company-category.php
* Advanced AdsCompany Category
* @wordpress-plugin
* Plugin Name: Advanced AdsCompany Category
* Plugin URI:
* Description: Add a Company category to ads so that you can group them.
* Version: 0.1
* Author: Thomas Maier
webzunft / css
Created Sep 17, 2018
Reserve ad space with a ratio
View css
/** this code allows to reserve ad space with a ratio, e.g., when width is 100% and height needs to be adjusted dynamically
"top-banner-ads" is the class of the main container, in Advanced Ads derived from the placement name
.top-banner-ads {
width: 100%;
height: auto;
padding-top: 12.4%; /* 728:90 ratio */
position: relative;
webzunft / functions.php
Created Feb 18, 2014
Sample code for an adblocker check based on BlockAlyzer for WordPress
View functions.php
function adblock_alert(){
?><script type="text/javascript">
jQuery(document).ready(function($) {
if ( ba_blocked == true ) alert("You are using adblock.");
add_action('wp_footer', 'adblock_alert');
webzunft / body section
Created Jan 29, 2014
asynchronous Google DFP for Publishers Tag code with explanations
View body section
<!-- the id must match the id defined in the slot -->
<!-- style attribut is optional, but useful to prevent to shift layout after ad is loaded -->
<div id="banner1" style="width:300px; height:250px;">
<script type="text/javascript">
// id 'banner1' is used here, again
googletag.cmd.push(function() { googletag.display('banner1'); });
webzunft / log.php
Last active Dec 18, 2015
function to log events for themes in WordPress functions.php
View log.php
function log( $input ){
$time = date('d-m-Y H:i T');
$file = get_template_directory() . '/log.txt';
$handle = fopen($file, 'a');
$data = '--------------- ' . $time."--------------- \r\n".$input."\r\n";
fwrite($handle, $data);
webzunft / gist:5598039
Created May 17, 2013
Code to allow to create and update a user in WordPress without an e-mail address. It simply removes the error message. This code was written to be used in a plugin written as a class
View gist:5598039
public function __construct () {
// other code...
add_action( 'user_profile_update_errors', array( $this, 'remove_empty_email_error' ));
function remove_empty_email_error( $arg ) {
if ( !empty( $arg->errors['empty_email'] ) ) unset( $arg->errors['empty_email'] );