Escaping built-in WP function return strings

Escaping is used to produce valid HTML or other formats, and it depends on context. Escaping a url in something like <a href=”https://wordpress.stackexchange.com/questions/215822/<?php echo $url?>”…. is needed in order to replace any “&” characters with & (although browsers will most likely fix it for you if you don’t do it). Escaping a url in an … Read more

Plugin Architecture/Design Pattern – is better to use a private Observer/Mediator Pattern for plugin subclasses or WP add_action?

I’m wondering if i should refactor my plugin using a ‘private’ Observer/Mediator pattern ie. collect all relevant add_actions to my parent class only and baking up a pattern to notify/forward subclasses of events, reducing the impact of my plugin to WP event ques. The event queue is fundamental to WP, so it’s pretty fast and … Read more

wp_localize_script $handle

It’s basically a unique id of the script you registered or enqueued before. Let’s say we enqueued a two scripts with wp_enqueue_script(): wp_enqueue_script( ‘my_script_1′,’/js/some_script.js’ ); wp_enqueue_script( ‘my_script_2′,’/js/some_other_script.js’ ); Now you want to pass your $data to the script #2 with wp_localize_script(): wp_localize_script( ‘my_script_2’, ‘my_script_2_local’, $data ); After this – when WordPress prints out your my_script_2 … Read more

Plugin development with unit tests

The unit tests transform all CREATE TABLE and DROP TABLE queries to CREATE TEMPORARY TABLE and DROP TEMPORARY TALBE, respectively. So in your tearDown the query will attempt to drop temporary tables with those names, but not the actual tables. To fix this, add this before your DROP queries: remove_filter( ‘query’, array( $this, ‘_drop_temporary_tables’ ) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)