Skip to content

Instantly share code, notes, and snippets.

View dimadin's full-sized avatar

Milan Dinić dimadin

View GitHub Profile
@dimadin
dimadin / export.php
Created July 29, 2015 13:45
GlotPress Serbian transliteration
<?php
function __construct() {
$this->short_options .= 'o:v:';
$this->usage .= ' [-o <format (default=po)>] [-v <variant>]';
$this->add_filters_to_options_and_usage();
parent::__construct();
}
function action_on_translation_set( $translation_set ) {
@dimadin
dimadin / curly-quotes.php
Created May 11, 2015 16:01
Filtering WordPress curly quotes
<?php
function md_filter_curly_double_quotes( $translations, $text, $context, $domain ) {
if ( 'opening curly double quote' == $context && '&#8220;' == $text ) {
$translations = '&#0171;';
} else if ( 'closing curly double quote' == $context && '&#8221;' == $text ) {
$translations = '&#0187;';
}
return $translations;
@dimadin
dimadin / gist:e4445d21002ccdade530
Last active August 29, 2015 14:02
WP Links Widgets Customizing
<?php
/**
* Replace <ul> from blogroll widget with <div>.
*/
function md_replace_ul_blogroll( $output ) {
$output = str_replace( "<ul class='xoxo blogroll'>", "<div>", $output );
$output = str_replace( "</ul>", "</div>", $output );
return $output;
}
@dimadin
dimadin / conditional-simple-colorbox.php
Last active December 30, 2015 17:49
Used in combination with (heavily) modified Simple Colorbox plugin.
<?php
if ( class_exists( 'Simple_Colorbox' ) ) :
/**
* Conditional Simple Colorbox loader.
*
* Enqueue Colorbox files only when needed on page to improve
* performance by avoiding unnecessary external requests and
* inline content.
*
* If Colorbox is needed only when galleries are used,
@dimadin
dimadin / gist:4247291
Created December 9, 2012 22:29
Filter WordPress admin bar text
/**
* Filter admin bar strings.
*/
function md_filter_admin_bar_strings( $translation, $original_text, $domain ) {
if ( 'About WordPress' == $original_text )
$translation = 'About this site';
return $translation;
}
@dimadin
dimadin / gist:4247285
Created December 9, 2012 22:27
Load only admin bar translation on WordPress frontend
/**
* Set en_US lang code if not in admin.
*/
function md_set_en_us_locale( $locale ) {
if ( ! is_admin() ) {
if ( ! defined( 'MD_REAL_LANG' ) )
define( 'MD_REAL_LANG', $locale );
$locale = 'en_US';
}