WooCommerce shortcodes you definitely need to know

With over 15 million downloads on WordPress.org, WooCommerce is the popular e-commerce plugin among WordPress community. If you’re developing theme for WooCommerce, there are few shortcodes that might help you in theme development.

Here are our list of  WooCommerce shortcodes, you might not be aware of but definitely need to know for better theme customization. Continue reading “WooCommerce shortcodes you definitely need to know”

Data Validation, Sanitization and Escaping

Data Validation, Sanitization and Escaping

Don’t ever trust your users. Always validate, sanitize and escape every piece of information that saves into and read out of your database.

So, what exactly validation, sanitization and escaping? Do we really need them?

  • Validation is the ruleset to make sure data received from end user is in correct format that you expect it to be.
  • Sanitization is the process of removing unwanted character or information received from end user before saving it to the database.
  • Escaping is the process of cleaning data that you have in your database before displaying it to the end user.

Continue reading “Data Validation, Sanitization and Escaping”

Quick Tip: How to Use Shortcodes Within Widgets

Shortcodes has been in WordPress for quite some time. It allows developers to add more or less complex features in plugins and themes without user having to write single HTML code.

By default, shortcodes runs only in editor. If you want to use shortcodes in widgets, it’s not possible. But a single line of code will allow you to add shortcode in widget.

WordPress comes with plethora of widgets by default. One of such widget is “Text Widget”. This widget allows you to add any text and HTML code in it. To run shortcode in it, we will be using “widget_text” filter. This filter allows you to modify content of “Text Widget”. We will be using “do_shortcode” as a callback function in this filter. “do_shortcode” function renders shortcode for you.

The code below can be used in a theme functions.php file to run shortcode:

add_filter('widget_text', 'do_shortcode');

You can learn more about built-in shortcode in WordPress here.

You can get more details regarding shortcode API here.