Skip to content

Instantly share code, notes, and snippets.

View ihorvorotnov's full-sized avatar
🇺🇦
Working remotely since 1999

Ihor Vorotnov ihorvorotnov

🇺🇦
Working remotely since 1999
View GitHub Profile
@danielbachhuber
danielbachhuber / Show author metadata if available
Created May 16, 2010 03:58
Shows WordPress author metadata if available
<?php $author = get_post_meta($post->ID, 'author', true);
if ($author) { echo $author; } else { the_author(); } ?>
@rmccue
rmccue / gist:507168
Created August 3, 2010 21:13
(WordPress) Get posts filtered by meta key
<?php
$posts = get_posts( 'post_type=any&meta_key=producer&meta_value=' . $producer_id );
<?php
/*
* Hook WordPress to add a category field to a taxonomny term edit screen.
*
* Modified by Ulrich SOSSOU from:
*
* http://lists.automattic.com/pipermail/wp-hackers/2010-August/033671.html
*
* By:
*
anonymous
anonymous / gist:666394
Created November 7, 2010 20:23
<!-- http://benalman.com/projects/jquery-urlinternal-plugin/ -->
<script src='<?php bloginfo('template_directory'); ?>/js/jquery.ba-urlinternal.min.js'></script>
<!-- http://www.asual.com/jquery/address/ -->
<script src='<?php bloginfo('template_directory'); ?>/js/jquery.address-1.3.min.js'></script>
<script>
// Original JavaScript by Chris Coyier
// Updated October 2010 by Stewart Heckenberg & Chris Coyier
<?php
/*
* Example code showing how to hook WordPress to add several fields to the taxonomny term edit screen.
* To-Do: Add field types other than text fields.
*
* Original author:
*
* Mike Schinkel (http://mikeschinkel.com/custom-wordpress-plugins/)
*
* NOTE:
@danielbachhuber
danielbachhuber / gist:1117115
Created July 31, 2011 19:31
Set WordPress user display name
<?php
require_once('./wp-load.php');
$all_users = get_users();
foreach( $all_users as $user ) {
if ( $user->user_login == $user->display_name ) {
$user_info = get_userdata( $user->ID );
$new_display_name = $user_info->first_name . ' ' . $user_info->last_name;
@perusio
perusio / gist:1326701
Created October 31, 2011 01:28
Mobile device detection in Nginx with just 7 lines of configuration
### Testing if the client is a mobile or a desktop.
### The selection is based on the usual UA strings for desktop browsers.
## Testing a user agent using a method that reverts the logic of the
## UA detection. Inspired by notnotmobile.appspot.com.
map $http_user_agent $is_desktop {
default 0;
~*linux.*android|windows\s+(?:ce|phone) 0; # exceptions to the rule
~*spider|crawl|slurp|bot 1; # bots
~*windows|linux|os\s+x\s*[\d\._]+|solaris|bsd 1; # OSes
@danielbachhuber
danielbachhuber / gist:1409229
Created November 30, 2011 14:23
Handling WordPress search
<?php
/**
* Give the user a 404 if they do an internal WP search
*/
function db_unresolve_search() {
global $wp_query;
if ( $wp_query->is_search )
$wp_query->is_404 = true;
}
add_action( 'template_redirect', 'db_unresolve_search' );
@sorich87
sorich87 / .gitignore
Created December 13, 2011 17:06 — forked from redoPop/.gitignore
Template .gitignore file for WordPress projects
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your
@thefuxia
thefuxia / defer-cf7-scripts.php
Last active March 21, 2021 20:59
Plugin: Defer Contact Form 7 Scripts
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: Defer Contact Form 7 Scripts
* Description: Adds <code>defer='defer'</code> to enqueued javascripts.
* Version: 1.0
* Required: 3.3
* Author: Fuxia Scholz
* Author URI: https://fuxia.me
* License: GPL
* License URI: http://www.gnu.org/copyleft/gpl.html