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
nbachiyski = Nikolay Bachiyski <nb@nikolay.bg>
matt = Matt Mullenweg <m@mullenweg.com>
nacin = Andrew Nacin <andrewnacin@gmail.com>
tellyworth = Alex Shiels <alex@automattic.com>
markjaquith = Mark Jaquith <markjaquith@gmail.com>
westi = Peter Westwood <peter@automattic.com>
ryan = Ryan Boren <ryan@boren.me>
convissor = Daniel Convissor <danielc@analysisandsolutions.com>
duck_ = Jon Cave <jon@lionsgoroar.co.uk>
dd32 = Dion Hulse <dd32@dd32.id.au>
@meloniq
meloniq / functions.php
Last active December 19, 2015 10:19
ClassiPress - add sponsored ads to search results
function childtheme_add_ads_to_search() {
if ( ! is_search() )
return;
// display ads
cp_adbox_336x280();
}
add_action( 'appthemes_before_loop', 'childtheme_add_ads_to_search' ); // before listings
add_action( 'appthemes_after_loop', 'childtheme_add_ads_to_search' ); // after listings
@meloniq
meloniq / functions.php
Created July 11, 2013 08:18
QualityControl - disable Assignment and Milestones components
function childtheme_remove_theme_supports() {
remove_theme_support( 'ticket-milestones' );
remove_theme_support( 'ticket-assignment' );
}
add_action( 'after_setup_theme', 'childtheme_remove_theme_supports', 11 );
@meloniq
meloniq / functions.php
Last active December 20, 2015 05:19
Clipper - prevent duplicate import of coupons
<?php
function childtheme_duplicate_check_of_id_field( $post_meta ) {
global $wpdb;
foreach ( $post_meta as $meta_key => $meta_value ) {
if ( $meta_key == 'clpr_id' && ! empty( $meta_value ) ) {
$sql = $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'clpr_id' AND meta_value = %s", $meta_value );
if ( $wpdb->get_var( $sql ) ) {
$post_meta[ $meta_key ] = 'delete_this_post';
@meloniq
meloniq / functions.php
Created July 29, 2013 13:58
Disable AppThemes themed login pages
function childtheme_remove_theme_supports() {
remove_theme_support( 'app-login' );
}
add_action( 'appthemes_init', 'childtheme_remove_theme_supports' );
@meloniq
meloniq / functions.php
Created August 5, 2013 14:01
Remove deprecated file on child theme activation
function childtheme_remove_deprecated_files() {
if ( file_exists( get_stylesheet_directory() . '/some-file.php' ) ) {
unlink( get_stylesheet_directory() . '/some-file.php' );
}
}
add_action( 'appthemes_first_run', 'childtheme_remove_deprecated_files' );
@meloniq
meloniq / functions.php
Created October 8, 2013 16:48
Restrict access to 'wp-admin' only to admins
function childtheme_block_wp_admin() {
if ( ! current_user_can( 'manage_options' ) && ! defined( 'DOING_AJAX' ) ) {
wp_redirect( home_url( '/' ) );
}
}
add_action( 'admin_init', 'childtheme_block_wp_admin' );
@meloniq
meloniq / functions.php
Created October 8, 2013 17:57
Reorder WP image editors to use GD over Imagick (useful when you have installed buggy version of ImageMagic and you can not update it)
function childtheme_prefer_gd_lib_over_imagic( $editors ) {
return array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' );
}
add_filter( 'wp_image_editors', 'childtheme_prefer_gd_lib_over_imagic', 9, 1 );
@meloniq
meloniq / functions.php
Last active December 30, 2015 03:29
Set Poland as default country in dropdown of ClassiPress submission form
function childtheme_set_poland_as_default_country( $args, $result, $post ) {
if ( ! $post && $args['value'] == 'Poland' ) {
$args['selected'] = 'selected';
}
return $args;
}
add_filter( 'cp_formbuilder_cp_country_option', 'childtheme_set_poland_as_default_country', 10, 3 );
@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;
}
});