set_replacer - adds shortcodes in the frontend themes
set_replacer is a function for the Frontend Midrub Themes which allows to replace the placeholders added in the content.
The feature is similar to the shortcodes which you've seen in other CMS. I have no idea if someone has patent for shortcodes and for this reason i've invented the replacers which could replace the placeholders. This could be useful for ads or other scopes.
How a replacer works? In your content you could add one of these codes:
- {any_keyword}
- {any_keyword}content here{|any_keyword}
- {any_keyword id="any id"}
- {any_keyword id="any id"}content here{|any_keyword}
In your Inc's files from your theme add once:
set_replacer('code', function ($args = array()) {
if ( isset($args['start']) ) {
return str_replace('{ code}', '', $args['content']);
} else if ( isset($args['end']) ) {
return str_replace('{| code}', '', $args['content']);
} else {
return $args['content'];
} });
- code is the keyword which should be replaced with the content provided by the replacer.
- $args contains the parameters provided based on the placeholder. $args['start'] is provided when the placeholder starts and end when the placeholder is {| code}.
- if a placeholder has parameters you will receive them as keywords with values. Look in the video below,
Suggested Articles
- How to update the frontend themes
- How to change the favicon in the default Frontend's theme
- How to change the logo in the frontend's default theme
- How to install a frontend theme
- the_replacers - adds support for the replacers
- set_replacer - adds shortcodes in the frontend themes
- How works the search feature in the Midrub Frontend Themes
- get_pagination - displays pagination for contents
- the_pagination - create a pagination as you need
- Contents Introduction for Frontend Themes