Skip to content

Instantly share code, notes, and snippets.

View birgire's full-sized avatar

Birgir Erlendsson birgire

View GitHub Profile
@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 / 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 / json-api-custom-fields-support-for-create-post.php
Last active August 31, 2017 05:12
WordPress plugin: JSON API - Custom fields support for the create_post method
<?php
/**
* Plugin Name: JSON API - Custom fields support for the create_post method
* Version: 0.0.1
* Author: Birgir Erlendsson (birgire)
* Author URI: https://github.com/birgire
* Plugin URI: https://gist.github.com/birgire/02dfadbcb0ddc3fdb064
* Description: Extension to the JSON API plugin, to enable custom fields to be added with the "create_post" method
* Licence: GPLv2+
*/
@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 / 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 / woo-product-attributes-bulk-modifier.php
Last active March 4, 2024 10:09
WordPress: WooCommerce Product Attributes - Bulk Modifier ( from custom meta attributes to taxonomy attributes)
<?php
/**
* Plugin Name: WooPAM: Woo Product Attributes Modifier
* Description: Bulk update 'custom meta product attributes' to 'taxonomy product attributes' in WooCommerce. Supports the GET variables, like: woopam_mode=run&woopam_from_attribute_meta=colour&woopam_to_attribute_tax=pa_colour&woopam_keep_attribute_meta&woopam_posts_per_page=10&woopam_paged=0&woopam_post_type=product&woopam_post_status=any. WARNING: Backup DB first!!!
* Plugin Author: birgire
* Author URI: https://github.com/birgire
* Plugin URI: https://gist.github.com/birgire/0ed300ae4436fcaf508c
* Version: 1.0.0
* License: GPL2+
* Text Domain: woopam
@birgire
birgire / field_query.php
Last active January 17, 2018 14:37
WordPress: Nested field queries - An idea for a plugin to support the "field_query" argument in the WP_Query class
<?php
/**
* Plugin Name: Field Query
* Description: Support the "field_query" argument in the WP_Query class
* Plugin URI: https://gist.github.com/birgire/ebf79ab6b12258a0e489
* Plugin Author: Birgir Erlendsson (birgire)
* Version: Proposal (2015-07-28)
**/
/**
@birgire
birgire / export-single-day.php
Last active May 14, 2023 13:24
WordPress Plugin: Enhance the native XML export - with a single day selection
<?php
/**
* Plugin Name: Single Day Posts Export
* Plugin URL: http://wordpress.stackexchange.com/a/199527/26350
* Plugin Author: Birgir Erlendsson (birgire)
* Version: 0.0.1
*/
/**
* Add our extra HTML
@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 / actions_and_filters.log
Last active December 13, 2021 22:27
WordPress: Here we list all (exl. gettext) actions & filters that run when the `edit.php` (post) screen is loaded without any plugins and with a default theme activated:
Here we list all do_action, do_action_ref_array, apply_filters and apply_filters_ref_array calls (excluding gettext) for the edit.php (post) screen.php:
---
muplugins_loaded - do_action
pre_site_option_siteurl - apply_filters
default_site_option_siteurl - apply_filters
pre_option_siteurl - apply_filters
option_siteurl - apply_filters
site_option_siteurl - apply_filters