Per Søderlind

I code for fun

Page 4 of 34

Testing WP CLI and WP Gears.

WP Gears integrates Gearman with WordPress for asynchronous task running.

Prerequisite, please see the installation guide.

Read More

Project Oxford Spell Check for WordPress TinyMCE

spellcheck

Get it at https://github.com/soderlind/poxford-spellchecker

A faster load_textdomain() for WordPress

Somehow, living outsite the 7 bit world of the US, we’ve missed that loading translations in WordPress is extreamly slow. Using the pluging below, you can improve your pageload by 40ms per request.

Read More

Best practice enqueuing a dynamic CSS or JavaScript in WordPress

 

TL;DR I’m using WordPress Ajax and Nonces, a plugin that demonstrates how to enqueue dynamic CSS and JavaScript in WordPress is available at GitHub.

I’m boldly claiming that this is best practice for dynamically loading a style or script in WordPress. Why?  The loaded code is protected by a nonce. Disagree? Please tell me why, I’m learning every day.

The dynamic CSS

 `require_once dirname( __FILE__ ) . /dynamic-css.php;`

The dynamic CSS (and JavaScript) is simple to create, and since the script is included you have access to all the WordPress functions, actions and filters. Forinstance, you can get the value using get_option , add the value and write to standard out:

<?php
//prevent direct access
if ( ! defined( 'ABSPATH' ) ) {
	die();
}
header( "Content-type: text/css; charset: UTF-8" );

//get value from options, settings etc
$color = 'blue';
?>

a {
	color: <?php echo $color;?> !important;
}

 

WordPress, how to modify the HTML of an oEmbed link

Introduction

Background: EPiServer is the CMS for the Norwegian Government main site, www.regjeringen.no and we use WordPress for more ad hoc sites.

Task: Based on the design guide for regjeringen.no, add 23 video to WordPress.

Read More

Page 4 of 34

Powered by WordPress & Theme by Anders Norén