Archive for the WordPress Tag

Shortcode Problems: WordPress 4.4

miqrogroove
2015-08-31T11:07:48+00:00

I will briefly summarize Shortcode API changes since WordPress 4.0 and then kick off some ideas for a roadmap.

The first major accomplishment was the expansion of the API documentation, including a new large section I wrote about the formal syntax for shortcode input.

I also put forward a robust parser concept for the function wptexturize() that promised to re-introduce the ability to use unrestricted HTML code inside of shortcodes and shortcode attributes.  That concept went through many, many changes before being introduced in v4.2.3.  After consulting with the WordPress security team, and after extensive testing of the shortcode parsing functions, we determined that the shortcodes-first parsing strategy was fundamentally flawed and could not be included with any version beyond v4.2.2.  This is why I added an HTML parser to the Shortcode API and ultimately curtailed the use of shortcodes inside HTML rather than expand the use of HTML inside shortcodes.

Read the rest of this entry »

22 Aug 2015

Category:
Systems Engineering

Tags:

Discuss:
3 Comments

Shortcode Problems to be Resolved in WordPress 4.1

miqrogroove
2014-11-06T10:38:13+00:00
Illustration of wptexturize_parse() concept.

Achieving correct and exact results in several steps.

When WordPress first introduced its Shortcode API, it included an all-too-simple line of code that was supposed to help curly quotes not appear inside of the shortcode attributes while still adding curly quotes outside of the shortcodes.  But there were several known problems with this one line of code, such as what would happen if a URL contained square braces, and what would happen if a plugin author wanted to use HTML inside a shortcode.

In version 4.0, I made a substantial effort to fix these problems, but it resulted in some new limitations being placed on the ways shortcodes could be used.  Although I couldn’t find any documented examples or official support for the HTML features, I did hear from several members of the WordPress community who enjoy the full power of customizing their website HTML by using shortcode attributes and HTML values.

My proposed solution is to write a new parser function that will exactly identify the shortcodes and HTML elements being used, so that the function wptexturize() will finally be able to create its curly quotes without interfering with shortcode features.  Click on the diagram to see how this new code works.

Read the rest of this entry »

6 Nov 2014

Category:
Systems Engineering

Tags:

Discuss:
3 Comments

WordPress Formatting Roadmap

miqrogroove
2014-07-08T18:39:25+00:00

I was asked for ideas about how to fix some old problems in the WordPress code base.  Specifically, bugs in the Formatting component, which includes the very heart of blog post processing for millions of websites.  This roadmap lays out recent changes and a plan for where to go next.

3.9

  • Implemented NBSP compatibility for curly quotes to fix common cosmetic flaws.
  • Revised all regex in wptexturize to avoid slow searches.
  • Added a large number of unit tests to cover all known behaviors of wptexturize.

4.0

  • Implemented NBSP compatibility for shortcodes and smilies.
  • Deprecated and replaced function like_escape().
  • Fixed wptexturize parsing for square braces inside of HTML.
  • Sorted the texturize patterns into groups for better performance.
  • Refactored the wptexturize stack function for better performance.
  • Wptexturize now runs up to 5x faster compared to v3.8.

4.1 or Future Releases

Wpautop Phase 1 – Research Problem

Read the rest of this entry »

8 Jul 2014

Category:
Systems Engineering

Tags:

Discuss:
Comments Go Here

like_escape() is Deprecated in WordPress 4.0

miqrogroove
2014-06-18T00:33:31+00:00

Plugin authors and website developers who work with WordPress database queries should notice an important change coming in WordPress 4.0.

The function like_escape() is no longer used in WordPress core code.  It is still available as a deprecated function, so it still works in any existing plugins that rely on it.  However, a new and different function is available that should be used in all new code.

Deprecated means that anyone using code that calls like_escape() with WP_DEBUG enabled will see an error message.  If WP_DEBUG_LOG is also enabled, the error message will appear in the /wp-content/debug.log file.

Let’s look at an example of core code where I removed like_escape() and implemented the new function $wpdb->esc_like().

3.9 Old Style

$search_orderby_s = like_escape( esc_sql( $q['s'] ) );
$search_orderby .= "WHEN $wpdb->posts.post_title LIKE '%{$search_orderby_s}%' THEN 1 ";

What did this do?  It was an old snippet from /wp-includes/query.php that set up a search for post titles.  The input $q[‘s’] was escaped using two functions before it was added to the post_title LIKE expression.  Now let’s see how I replaced that snippet in the next version.

4.0 New Style

$like = '%' . $wpdb->esc_like( $q['s'] ) . '%';
$search_orderby .= $wpdb->prepare( "WHEN $wpdb->posts.post_title LIKE %s THEN 1 ", $like );

Read the rest of this entry »

18 Jun 2014

Category:
Systems Engineering

Tags:
,

Discuss:
Comments Go Here

Merry Christmas

miqrogroove
2012-12-20T03:43:28+00:00

Screen shot showing Miqrogroove.com with the Christmas 2012 theme.In celebration of winter break, I decided to change my website’s blue marble theme to a deck-the-halls / red glow motif.

May the warm colors bring you a festive mood!

Credit for the background image goes to AreteStock at DeviantArt.  She has generously licensed her work for free use.

Also new here is the upgraded WordPress 3.5, to which I made some small but very important contributions.  Any WordPress author should be happy to know that I found and patched a bug that prior to version 3.5 caused WordPress to say your draft work had been saved automatically, when in fact WordPress was automatically discarding your work all along.  I first noticed the bug in September when my website ate a fairly long article to which I had devoted some hours.  I resolved the bug in the new version by removing the code that was causing the problem.

While tinkering with themes and WordPress, I also adjusted the printer styles so that it will be easier to print articles from this website.

Happy Holidays!

20 Dec 2012

Category:
Website Updates

Tags:

Discuss:
Comments Go Here

Retina Gravatars

miqrogroove
2012-11-03T16:56:02+00:00

I’ve released a new HiDPI Gravatars plugin for WordPress.  This is a slick website add-on for the iPad/iPhone audience, and future high-resolution displays.  Download the plugin here.

In addition to my regular blogging homework, I am doing some coding behind the scenes to make sure my classmates will be able to easily read and respond to articles using mobile devices and the latest web browsers.  HiDPI support is one of the main new features of the upcoming WordPress 3.5.  When I found out the Gravatar feature won’t be upgraded in the next version, I decided to write my own solution.

I also updated my Simple Short Links plugin, so if you want to share this article with a friend, you can also send this shorter address, miqrogroove.com?p=891

3 Nov 2012

Category:
Website Updates

Tags:
,

Discuss:
One Comment