Skip to content

Instantly share code, notes, and snippets.

@johnpbloch
johnpbloch / README.md
Created August 23, 2012 13:55
A bash script to make .pot files for WordPress plugins

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 file (with no trailing slash):

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

@GaryJones
GaryJones / functions.php
Last active August 25, 2018 11:44
Conditionally add IE style sheets in WP
<?php
add_action( 'wp_print_styles', 'child_add_ie7_style_sheet', 200 );
/**
* Enqueue an IE-specific style sheet (for all browsers).
*
* @author Gary Jones
* @link https://garyjones.io/ie-conditional-style-sheets-wordpress
*/
function child_add_ie7_style_sheet() {
@chrisdc
chrisdc / navigation.js
Last active November 2, 2018 19:49
Object Orientated navigation.js
( function() {
function Menu( containerId, options ) {
var container,
menu,
button;
function init() {
container = document.getElementById( containerId );
if ( ! container ) {
@GaryJones
GaryJones / .csscomb.json
Last active November 2, 2018 19:49
[Replaced] CSSComb file for WP core.
See https://github.com/cedaro/grunt-wp-css/blob/develop/tasks/config/default.json
@nacin
nacin / auto-update.php
Last active March 11, 2019 17:17
This is how @dd32 and I test automatic background updates in WordPress 3.7. Then just do example.com/?wp_maybe_auto_update. (If you use a checkout of develop.svn.wordpress.org, you can run this on the `build` directory, then simply run `grunt copy` between updates to copy over the latest code from `src`. This is how we are able to make adjustmen…
<?php
// Add this as a mu-plugin.
if ( isset( $_GET['wp_maybe_auto_update'] ) ) {
add_filter( 'automatic_updates_is_vcs_checkout', '__return_false' );
add_action( 'template_redirect', function() {
$time = date( 'r' );
echo "Starting... $time<br />";
delete_site_option( 'auto_core_update_failed' );
@jgoyon
jgoyon / menu.html
Created November 1, 2012 12:02
Horizontal menu, full width sub menu
<div id="menu">
<ul id="nav">
<li><a href="#">Menu 1</a>
<ul>
<li><a href="#">Menu 1 Submenu item 1</a></li>
<li><a href="#">Menu 1 Submenu item 2</a></li>
<li><a href="#">Menu 1 Submenu item 3</a></li>
</ul>
</li>
@jrfnl
jrfnl / bccalc.php
Last active October 17, 2019 01:13
Do simple reliable math calculations without the risk of wrong results using bcmath
<?php
/**
* Do simple reliable floating point calculations without the risk of wrong results.
*
* @see http://floating-point-gui.de/
* @see the big red warning on http://php.net/language.types.float.php
*
* In the rare case that the bcmath extension would not be loaded, it will return the
* normal calculation results.
*
@willybahuaud
willybahuaud / translate-taxonomy-slug.php
Last active February 13, 2020 18:38
Translate Taxonomy base slug wpml
<?php
add_action( 'init', 'register_my_taxo' );
function register_my_taxo() {
register_taxonomy( 'immo_cat', 'immobilier', array(
'hierarchical' => false,
'label' => 'Type de biens',
// je déclare le slug de taxo de manière à pouvoir le traduire
'rewrite' => array( 'slug' => icl_t('nebula', 'property-type-slug', 'type-bien-immobilier' ) ),
) );
}
@kevinwhoffman
kevinwhoffman / responsive-images-notes.md
Last active May 18, 2020 13:31
WordPress 4.4 Responsive Images Notes

Notes and Resources for Responsive Images in WordPress 4.4

Following the addition of responsive images support in WordPress 4.4, there has been a lot of confusion over what WordPress does "automatically" and what is left up to the developer. I've gathered the following notes from chatting with members of the core team and also my own investigation of the 4.4 source. Here's what I've discovered:

  • Following the 4.4 update, WordPress automatically serves the following images responsively:

    • Content images added via the main content editor will now be served with srcset markup. This is accomplished by filtering the_content() prior to display, which means it applies to existing posts and new posts going forward.
    • Featured images called by the_post_thumbnail() also get srcset markup without any additional steps required.
  • Images that are referenced from custom fields will not be served responsively unless the theme calls the image via wp_get_attachment_image() OR constructst the responsive m

@bfintal
bfintal / base-frame-template.php
Last active January 7, 2021 18:33
Since it's hard to find an example of how to create a readily usable modal popup using Backbone & WordPress, here's one that you can drop in your code and use right away.
<script type="text/html" id="tmpl-my-frame">
<div class="media-frame-title">
<h1>My Frame</h1>
</div>
<div class="media-frame-content"></div>
<div class="media-frame-toolbar">
<div class="media-toolbar">
<div class="media-toolbar-secondary"></div>
<div class="media-toolbar-primary search-form">
<button type="button" class="button button-primary media-button button-large">My Button</button>