Skip to content

Instantly share code, notes, and snippets.

View samikeijonen's full-sized avatar
🏠
Working from home

Sami Keijonen samikeijonen

🏠
Working from home
View GitHub Profile

Installation

To install, you need to have the WordPress i18n library on your computer. Check it out using SVN:

sudo svn co http://i18n.svn.wordpress.org/tools/trunk/ /usr/lib/wpi18n

You don't have to put the library in /usr/lib/wpi18n, but if you don't put it there, make sure to set the $WP_I18N_LIB environment variable in your .bashrc or .bash_profile file (with no trailing slash):

export WP_I18N_LIB="/path/to/i18n/lib"

@pento
pento / commercial-client.php
Created July 2, 2013 12:29
Sample Commercial Plugin update server and client
<?php
/*
* Plugin Name: Commercial Client
* Plugin URI: http://pento.net/
* Description: A sample client plugin for showing updates for non-WordPress.org plugins
* Author: pento
* Version: 0.1
* Author URI: http://pento.net/
* License: GPL2+
*/
@devinsays
devinsays / custom_edd_sl_license_response
Last active August 29, 2015 14:02
Allow "Package" downloads. Multiple file downloads using the same license.
/**
* This code requires one additional filter param to be added to edd_sl_license_response in EDD_Software_Licensing.php:
* $response = apply_filters( 'edd_sl_license_response', $params, $download, $data)
*/
/**
* Allows EDD to bypass the name check for files
*/
define( 'EDD_BYPASS_NAME_CHECK', true );
@chriscct7
chriscct7 / gist:d7d077afb01011b1839d
Last active January 24, 2024 04:20
Plugins that need to be updated to be ready for the move to PHP 5 constructors

Important Notice for WordPress Plugins Using PHP 4 Style Constructors

The ability to use PHP 4 style constructors is getting removed from PHP. Without an update, many plugins will eventually no longer work (this is PHP breaking this backwards compatibility, not WordPress)

One of the more common uses of the PHP 4 style constructor (as opposed to PHP 5 style __construct() ) are plugins with widgets calling WP_Widget::WP_Widget() and/or parent::WP_Widget() and/or {object}->WP_Widget()

Note: Starting in WordPress 4.3, regardless of the PHP version in use on a server, WordPress will throw a deprecated notice when one of the PHP 4 style constructors is called specifically for widgets.

Basically instead of doing these:

<?php
add_action( 'wp_enqueue_scripts', 'jt_enqueue_scripts' );
function jt_enqueue_scripts() {
wp_enqueue_script( 'wp-api' );
wp_enqueue_script( 'wp-util' );
}
add_action( 'wp_footer', 'jt_print_post_template', 25 );

I thought it would be pertinent to respond to some points presented by Andrey "Rarst" Savchenko in recent post Progressive Enhancement.

Progressive Enhancement

Unlike Rarst, I don't value progressive enhancement very highly and don't agree it's a fundamental principle of the web that should be universally employed. Quite frankly, I don't care about not supporting JavaScript, and neither does virtually anyone else. It's not that it doesn't have any value, or utility - but in a world where we don't have unlimited resources and time, one has to prioritise what we'll support and not support.

I'm a proponent of putting my ideas and creations into the world for people to make use of; and if I had to cover 100% of use cases for doing that, I wouldn't put much out there. I'm fine with losing the 1.1% of

@justintadlock
justintadlock / fonts.php
Last active July 13, 2016 15:15
Enqueue fonts in WP
<?php
/**
* Functions for handling font enqueueing, registration, etc. This works with the
* Google Fonts API.
*
* Extending an idea from Jose Castaneda. This is a small script for loading Google fonts
* with an easy method for adding/removing/editing the fonts loaded via child theme.
*
* @link http://blog.josemcastaneda.com/2016/02/29/adding-removing-fonts-from-a-theme/
*/
@marcysutton
marcysutton / chrome-a11y-experiment-instructions.md
Last active January 31, 2023 22:07
Enable Chrome Accessibility Experiment

NOTE: This is no longer an experiment! You can use the accessibility inspector in Chrome Devtools now, including a fantastic color contrast inspection tool. Read more: https://developers.google.com/web/updates/2018/01/devtools#a11y


Just like any good element inspector helps you debug styles, accessibility inspection in the browser can help you debug HTML and ARIA exposed for assistive technologies such as screen readers. There's a similar tool in Safari (and reportedly one in Edge) but I like the Chrome one best.

As an internal Chrome experiment, this tool differs from the Accessibility Developer Tools extension in that it has privileged Accessibility API access and reports more information as a result. You can still use the audit feature in the Chrome Accessibility Developer Tools, or you could use the aXe Chrome extension. :)

To enable the accessibility inspector in Chrome stable:

@justintadlock
justintadlock / font-awesome.php
Last active September 28, 2021 11:09
PHP array of Font Awesome icons.
<?php
// Font Awesome v. 4.6.
function jt_get_font_icons() {
return array(
'fa-glass' => 'f000',
'fa-music' => 'f001',
'fa-search' => 'f002',
'fa-envelope-o' => 'f003',
/**
* Add support for correct UTF8 orderby for post_title (äöå)
*
* @param string $orderby ordering clause for query
*
* @return string ordering clause for query
*/
add_filter('posts_orderby', function($orderby) use ($wpdb) {
if(strstr($orderby, 'post_title')) {