Skip to content

Instantly share code, notes, and snippets.

View meloniq's full-sized avatar
👣
Don't overthink!

Andrzej Piotrowski meloniq

👣
Don't overthink!
View GitHub Profile
@meloniq
meloniq / general.js
Created February 6, 2014 08:04
Displays error if user choose featured ad and did not selected any image
// displays error if user choose featured ad and did not selected any image
if ( typeof window.appFileCount != 'undefined' ) {
jQuery('input[type=submit]').on('click', function() {
window.appFileCountBrowser = 0;
jQuery('input[type="file"]').each(function() {
if ( jQuery(this).val() != '' ) {
window.appFileCountBrowser += 1;
}
});
@meloniq
meloniq / functions.php
Created February 12, 2014 13:42
Redirect to SEO search url
function childtheme_redirect_to_seo_search_url() {
if ( is_search() && false === strpos( $_SERVER['REQUEST_URI'], '/search/' ) ) {
$s = trim( get_query_var( 's' ) );
if ( empty( $s ) ) {
return;
}
$seo_url = home_url( 'search' ) . '/' . str_replace( ' ', '+', str_replace( '%20', '+', $s ) ) . '/';
@meloniq
meloniq / functions.php
Created February 12, 2014 17:02
Custom template wrapped with wrapper.php
function childtheme_trust_template( $template ) {
global $wp_query;
if ( ! isset( $wp_query->query_vars['trust'] ) || ! is_singular() ) {
return $template;
}
if ( $trust_template = locate_template( 'trust-template.php' ) ) {
return $trust_template;
} else {
@meloniq
meloniq / functions.php
Created March 1, 2014 16:28
[Clipper] Do not display unreliable coupons in featured coupons slider
function childtheme_do_not_display_unreliable_coupons_in_slider( $args ) {
$args['post_status'] = 'publish';
return $args;
}
add_filter( 'clpr_featured_slider_args', 'childtheme_do_not_display_unreliable_coupons_in_slider' );
@meloniq
meloniq / no_emails.php
Created March 1, 2014 20:21
Preventing WordPress from Sending emails
function childtheme_no_emails( &$phpmailer ) {
// Empty out the values that may be set
$phpmailer->ClearAllRecipients();
$phpmailer->ClearAttachments();
$phpmailer->ClearCustomHeaders();
$phpmailer->ClearReplyTos();
}
add_action( 'phpmailer_init', 'childtheme_no_emails', 99, 1 );
@meloniq
meloniq / functions.php
Created March 3, 2014 13:31
Do not display featured slider if contains less than 5 featured ads
function childtheme_control_when_to_display_featured_slider( $featured ) {
if ( count( $featured->posts ) < 5 ) {
return false;
}
return $featured;
}
add_filter( 'cp_featured_slider_ads', 'childtheme_control_when_to_display_featured_slider' );
@meloniq
meloniq / functions.php
Created June 9, 2014 12:37
[ClassiPress] Import geo coordinates from CSV
function childtheme_import_geo_coordinates_args( $args ) {
$args['custom_fields']['lat'] = 'lat';
$args['custom_fields']['lng'] = 'lng';
return $args;
}
add_filter( 'cp_csv_importer_args', 'childtheme_import_geo_coordinates_args', 10, 1 );
@meloniq
meloniq / functions.php
Created June 23, 2014 17:31
[ClassiPress] Do not use the user data in email header when message is sent from contact form
function childtheme_ad_contact_do_not_use_user_data( $email, $post_id ) {
$email['from'] = get_option( 'admin_email' );
$email['from_name'] = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
return $email;
}
add_filter( 'cp_email_user_ad_contact', 'childtheme_ad_contact_do_not_use_user_data', 10, 2 );
<?php
add_action('init', 'tribe_allow_large_joins');
function tribe_allow_large_joins(){
global $wpdb;
$wpdb->query('SET SQL_BIG_SELECTS=1');
}
@meloniq
meloniq / functions.php
Created June 26, 2014 14:33
[Vantage] Add unique identifier
function childtheme_add_unique_id( $post_id ) {
$post = get_post( $post_id );
if ( $post->post_type != VA_LISTING_PTYPE ) {
return;
}
$id = get_post_meta( $post_id, 'va_id', true );
if ( empty( $id ) ) {
$id = uniqid( rand( 10, 1000 ), false );