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 / functions.php
Created December 4, 2014 16:19
Allow PDF's upload on frontend in CP
function childtheme_allow_pdf_files( $config ) {
$config['plupload']['filters']['extensions'] = 'jpg,jpeg,gif,png,pdf';
return $config;
}
add_filter( 'appthemes_plupload_config', 'childtheme_allow_pdf_files', 10, 1 );
add_filter( 'app_plupload_config', 'childtheme_allow_pdf_files', 10, 1 ); // legacy, pre CP 3.4
@meloniq
meloniq / views.php
Created December 3, 2014 13:50
CP 3.4 - Buy Featured example
class MYCP_Buy_Featured extends APP_View {
function condition() {
return is_singular( APP_POST_TYPE ) && ! empty( $_GET['buy_featured'] );
}
function template_redirect() {
appthemes_require_login( array(
'login_text' => __( 'You must first login to feature ad listing.', APP_TD ),
'login_register_text' => __( 'You must first login or <a href="%s">register</a> to feature ad listing.', APP_TD )
@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 );
<?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 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 );
@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 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 / 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 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 / 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 {