Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Sameer Borate:
Adding WordPress like shortcodes to your web applications
Apr 24, 2015 @ 14:14:50

Sameer Borate has posted a new tutorial showing you how to add shortcode-like handling to your application. Shortcodes are a feature that's common in tools like WordPress to make adding custom markup easier (like "[tag][/tag]").

One of the cool features of WordPress is its shortcode feature. There may be times one wished to add this capability to your PHP web applications. Recently I found one such library which allows you to add shortcode features to your web apps. The library discussed here implements WordPress style shortcode syntax as a standalone package. Its a small package and so can be easily integrated into you existing applications. Content from editors, databases, etc. can be scanned by the Shortcode Manager and the contents replaced by a custom callback.

He makes use of the maiorano84/shortcodes library (installable through Composer) that makes it simple to add the functionality to your existing application. He includes a few examples of tag formats that the library can parse and the code needed to parse and handle the formatting. The custom tags are processed via callbacks and can modify the incoming value easily. He also shows how to access any attributes that may be set on the codes and grouping all of his functionality into one self-contained class.

tagged: shortcode wordpress tag custom library maiorano84 tutorial

Link: http://www.codediesel.com/php/adding-wordpress-like-shortcodes-to-your-web-applications/

PHPMaster.com:
Master Dynamic Content with WordPress Shortcodes
Jul 09, 2012 @ 16:47:13

On PHPMaster.com today there's a new tutorial for the WordPress users out there looking to work with dynamic content and shortcodes to make your site easier to use and to bring more content to user's attention.

The advantages to using shortcodes are obvious. First and foremost, it allows page designs to become far more unique. It also relieves the website administrator from having to create a large list of custom fields in order to perform basic content insertion. [...] And, finally, shortcodes allow a design to come alive and be truly dynamic and interesting to the end user. Too many WordPress blogs and magazine websites have adhered to the format of a big title, a standard block of text, and comments. That no longer has to be case.

They talk about using the "functions.php" file for the custom functionality, who to use them in your posts and how to use them in the theme-specific instances. Using the "add_shortcode" you can relate these custom functions to their codes for both simple and more advanced calls (code included).

tagged: wordpress dynamic content shortcode

Link:

SitePoint PHP Blog:
How to Create Your Own WordPress Shortcodes
Nov 11, 2010 @ 14:26:36

On the SitePoint PHP blog today there's a new post showing how how to make your own "short code" system that allows for custom function execution.

WordPress doesn’t normally allow you to add PHP code to pages or posts. That’s for the best: you don’t want clients to discover the power of the unlink function! However, you can create custom functions which are executed when a shortcode is encountered within the post text.

There's two code snippets included - one showing a simple function call, "Hello World" style, and another version that lets you define parameters to feed into the method. There's also a simple example of how you could allow them to include CSS styling into the code example too.

tagged: wordpress shortcode tutorial function callback

Link:


Trending Topics: