Skip to content

Instantly share code, notes, and snippets.

@grappler
grappler / functions.php
Created August 14, 2013 10:02
replace on load
<?php
function replace_custom_word( $text ){
$replace = array(
'thesis' => '<a style="color:sienna; border-bottom: 1px dotted #ba0000;" href="http://www.site1.com/">Thesis</a>',
'studiopress' => '<a style="color:sienna; border-bottom: 1px dotted #ba0000;" href="http://www.site2.com/">Studiopress</a>'
);
$text = str_replace( array_keys( $replace ), $replace, $text );
return $text;
}
<?php
function your_shortcode_scripts()
{
global $post;
if( function_exists( 'has_shortcode' ) )
{
if( has_shortcode( $post->post_content, 'your-shortcode' ) )
{
wp_enqueue_script( 'whatever' );
}
@grappler
grappler / plugin.php
Created August 23, 2013 11:36
create post type and replace old shortcode
<?php
/**
* Flowplayer 5 for WordPress
*
* @package Flowplayer 5 for WordPress
* @author Ulrich Pogson <[email protected]>
* @license GPL-2.0+
* @link http://flowplayer.org/
* @copyright 2013 Flowplayer Ltd
*/
@grappler
grappler / adaptive-shortcode.php
Last active December 21, 2015 16:49
This short plugin allows users to display content according to the device the page is being viewed on.
<?php
/**
*
* @package Adaptive Shortcode
* @author Ulrich Pogson <[email protected]>
* @license GPL-2.0+
* @link http://ulrich.pogson.ch
* @copyright 2013 Ulrich Pogson
*
* @wordpress-plugin
@grappler
grappler / style.css
Created September 8, 2013 19:51
mobile menu for desktop
@media(min-width:979px) {
.navbar-fixed-top,.navbar-fixed-bottom {
position: static;
}
.navbar-fixed-top {
margin-bottom: 20px;
}
@grappler
grappler / potomo.sh
Last active December 23, 2015 22:39
#! /bin/sh
for file in `/usr/bin/find . -name '*.po'` ; do /usr/bin/msgfmt -o ${file/.po/.mo} $file ; done
<script src="//fast.wistia.com/static/embed_shepherd-v1.js"></script>
<script>
wistiaEmbeds.onFind(function(video) {
video.videoFoam(true);
});
</script>
<iframe src="http://fast.wistia.net/embed/iframe/3bfl0abrog?videoFoam=true" allowtransparency="true" frameborder="0" scrolling="no" class="wistia_embed" name="wistia_embed" width="640" height="360"></iframe>
<script src='//fast.wistia.com/static/iframe-api-v1.js'></script>
<h3>What is internationalization?</h3>
Internationalization is the process of developing your plugin so it can easily be translated into other languages. Internationalization is often abbreviated as <code>i18n</code> (because there are 18 letters between the i and the n).
<h3>Why is internationalization important?</h3>
WordPress is used all over the world, it is a good idea to prepare WordPress plugins so that it can be easily translated into other languages. As a developer, you may not have an easy time providing localizations for all your users however, any translator can successfully localize the plugin without needing to modify the source code itself.
<h3>How to internationalize your plugin?</h3>
In order to make a string translatable in your application you have to wrap the original strings in a call to one of a set of special functions.
<h4>Introduction to Gettext</h4>
WordPress uses the <a href="http://www.gnu.org/software/gettext/">gettext</a> libraries and tools for i18n. Note that if you look online
@grappler
grappler / potomo.sh
Created October 12, 2013 19:41
Bash file to create .mo files without keeping the .po files.
#! /bin/sh
for file in `/usr/bin/find . -name '*.po'` ; do /usr/bin/msgfmt -o ${file/.po/.mo} $file && /usr/bin/rm $file ; done