Skip to content

Instantly share code, notes, and snippets.

View birgire's full-sized avatar

Birgir Erlendsson birgire

View GitHub Profile
<?php
/**
* Plugin Name: Change the size of the Image preview on the media edit page
* Author: Birgir Erlendsson (birgire)
* Plugin URI: http://wordpress.stackexchange.com/questions/204280/change-the-size-of-the-image-preview-on-the-media-edit-page
*
* ------------------------------------------------------------------------------------
* Possible workaround, without core modifications,
* but note that the javascript crop-selection numbers will not be accurate,
* when $inf <> 400
@birgire
birgire / hueman-theme-sharrre-sharing-bar-on-pages.php
Last active September 10, 2015 09:51
WordPress: Add the Hueman theme's sharing bar to pages. (Fix for those who don't have a recommended child theme)
<?php
/**
* Plugin Name: Hueman Theme - Sharrre Sharing Bar On Pages
* Description: Add the Hueman theme's sharing-bar to pages. (Fix for those who don't have a recommended child theme)
* Plugin URI: https://gist.github.com/birgire/be3dc8174e227233fa70
* Author: Birgir Erlendsson (birgire)
* Author URI: https://github.com/birgire
* Version: 0.0.1
* Licence: MIT
*/
@birgire
birgire / functions.php
Last active August 29, 2015 14:15
Match any numbers in given a meta-key for WP_Query (PHP 5.2+ )
/**
* Match any numbers in given a meta-key for WP_Query (PHP 5.2+)
*
* @see http://wordpress.stackexchange.com/a/177331/26350
*/
! is_admin() && add_filter( 'posts_where', 'wpse_posts_where' );
function wpse_posts_where( $where )
{
@birgire
birgire / simple-redirections.php
Last active August 29, 2015 14:09
WordPress Plugin: Redirect to the newest or the latest post via a GET parameter
<?php
/**
* Plugin Name: Simple Redirections
* Plugin URI: https://gist.github.com/birgire/b1c8b3b94da4ee2f94ba
* Author: Birgir Erlendsson (birgire)
* Version: 0.0.1
* Licence: GPLv2+
* Description: Redirect to the newest or the latest post with a GET parameter
*/
@birgire
birgire / auto-posts-injector-infinite-scroll.php
Last active August 29, 2015 14:07
WordPress plugin: Auto Posts Injector For Infinite Scroll
<?php
/**
* Plugin Name: Auto Posts Injector For Infinite Scroll
* Description: This plugin helps you to automatically inject posts into the main loop. You must use custom code to start the injection. See the example.
* Plugin URI: https://gist.github.com/birgire/252b72448646d29a64b6
* Author: birgire
* Author URI: https://github.com/birgire
* Version: 0.0.1
*/
@birgire
birgire / comments.php
Last active August 29, 2015 14:06
WordPress: Comments count
/**
* Usage Examples:
*/
$post_id = 3522;
echo 'Counting all normal comments for a given post: ' . wpq_get_normal_comments_count( $post_id );
echo 'Counting all extra comments for a given post:' . wpq_get_extra_comments_count( $post_id );
echo 'Counting all extra comments, without replies, for a given post:' . wpq_get_extra_comments_without_replies_count( $post_id );
@birgire
birgire / function-merge-user-edits.php
Last active August 29, 2015 14:05
WordPress: Merge array edits made by a given user.
/**
* function merge_user_edits()
*
* Merge the user edits to the existing meta data:
*
* @author birgire
* @version 0.0.1
* @param integer $user_id
* @param array $data
* @param array $edits
@birgire
birgire / functions.php
Last active August 29, 2015 14:05
Fetch taxonomy terms statistics for all posts before due date, with a single database query.
/**
* Fetch taxonomy terms statistics for all posts before due date, with a single database query.
*
* Assumes that the 'due' values are saved as YYYYMMDD
*
* @see http://www.wpquestions.com/question/showChronoLoggedIn/id/9770
* @param string $taxonomy
* @param string $meta_key
* @return mixed Database query results
* @version 0.0.2
@birgire
birgire / wpse-current-child-pages-metabox.php
Last active August 29, 2015 14:05
WordPress: Child Pages Meta Box For Hierarchial Post Types
<?php
/**
* Plugin Name: Child Pages Meta Box
* Description: Child pages meta box for hierarchial post types
* Author: Birgir Erlendsson (birgire)
* Plugin URI: http://wordpress.stackexchange.com/a/158636/26350
* Version: 0.0.2
*/
@birgire
birgire / wp-plugin-woo-product-attributes-debug.php
Last active August 29, 2015 14:05
WooCommerce Product Attributes - Dump them in a metabox for debugging
<?php
/**
* Plugin Name: Product Attributes - Debug
* Description: Dump the product attributes in a metabox.
* Author: birgire
* Author URI: Https://github.com/birgire
* Version: 0.0.1
*/
// PHP 5.3.3+