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 / functions.php
Last active October 13, 2015 02:29
WordPress: Redirect visits to the attachment pages to the parent page or the home page
/**
* Redirect attachment page visits to the parent page, else the home page.
*/
add_action( 'template_redirect', function()
{
if( ! is_attachment() )
return;
if( $parent_id = wp_get_post_parent_id() )
wp_safe_redirect( esc_url( get_permalink( $parent_id ) ) );
@birgire
birgire / wpse.php
Created December 27, 2015 17:43
Must Use WordPress Plugin - Print the clean basedomain in the admin footer
<?php
/**
* Print the clean basedomain in the admin footer
*
* Place the file under /wp-content/mu-plugins/wpse.php
*
* @uses get_clean_basedomain()
*/
add_action( 'in_admin_footer', function(){
if( function_exists( 'get_clean_basedomain' ) )
@birgire
birgire / get_the_category_list.php
Last active October 13, 2019 04:47
WordPress: Draft idea on how one could simplify the get_the_category_list() to address code duplication - WP 4.4.2
/**
* Retrieve category list in either HTML list or custom format.
*
* @since 1.5.1
*
* @global WP_Rewrite $wp_rewrite
*
* @param string $separator Optional, default is empty string. Separator for between the categories.
* @param string $parents Optional. How to display the parents.
* @param int $post_id Optional. Post ID to retrieve categories.
@birgire
birgire / menu-quick-search-tags-enhancements.php
Created June 21, 2016 14:59
WordPress Plugin: Search For Name Or Description In The Quick Search For Tags In The Menu Editor
<?php
/**
* Plugin Name: Quick Search Menu Enhancement
* Description: Search for name or description in the quick-search for tags in the menu editor
* Plugin URI: https://gist.github.com/birgire/b7001f51b3ad970f37fee2b8f854d939
* Author: birgire
* Version: 1.0.0
*/
/**
@birgire
birgire / extended-admin-tag-search.php
Last active July 6, 2021 19:08
WordPress Plugin:Search for name, slug or description in the tag search in /wp-admin/edit-tags.php?taxonomy=post_tag.
<?php
/**
* Plugin Name: Extend the tag search
* Description: Search for name, slug or description in the tag search in /wp-admin/edit-tags.php?taxonomy=post_tag.
* Plugin URI: https://gist.github.com/birgire/4a43dbe1b7566aa0f162b59066276d15
* Author: birgire
* Version: 1.0.0
*/
/**
@birgire
birgire / term-editor-search-field.php
Last active July 6, 2021 19:04
WordPress Plugin: Add custom search fields to the term editor.
<?php
/**
* Plugin Name: Term Editor Search Field
* Description: Adds Search fields to the term editor.
* Plugin URI: https://gist.github.com/birgire/22a57ad1eed45e366cc1d47575bba0b1
* Author: birgire
* Version: 1.0.2
*/
/**
@birgire
birgire / ping-screenshot-capture.php
Last active September 18, 2020 20:35
WordPress Plugin: Ping screenshots capture generation using an hidden iframe only once for published posts
<?php
/**
* Plugin Name: Ping Screenshots Capture
* Description: Ping screenshots capture generation using an hidden iframe only once for published posts
* Version: 1.0.0
* Author: birgire
*/
namespace PingScreenshotCapture;
<?php
/**
* @version: 1.0.3
* @see http://stackoverflow.com/questions/38551606/do-not-submit-form-after-wrong-code/38602177
*/
add_filter( 'login_form', function()
{
$options = get_option( 'authcode_settings' );
@birgire
birgire / functions.php
Last active February 21, 2025 18:17
Inject Ads To WordPress Comments - See https://wordpress.stackexchange.com/a/328155/26350
/**
* Inject Ads To WordPress Comments - end-callback for wp_list_comments().
*
* The Ads HTML is sanitized through wp_kses_post().
*
* @version 1.0.11
* @see https://wordpress.stackexchange.com/a/328155/26350
*/
function wpse_comments_ads_injection( $comment, $args, $depth ) {
static $instance = 0;