Featured Products
- Home
- WordPress Plugins
- Peekaboo Randomizer
Peekaboo Randomizer
By : Oktal_Studio Published on Monday, October 03, 2016,09:06:44 in WordPress Plugins
Peekaboo Randomizer is a plugin that allows you to randomly display pieces of content at your Wordpress driven website. Itâs suitable for banner rotation, lucky visitor rewards, special offers⦠or just for making a webpage more exciting and fun.
Upon installing the plugin, you will be in the possesion of 3 shortcodes with which you can
choose which block of content you want to be randomly displayed to visitors, and with what
incidence.
Installation
...is simple. As with pretty much any other WP plugin, you should:
SHORTCODES
[pbr_single]
attribute: chanceThe most basic usage. This shortcode is used when you have a block of content that should appear on the page randomly, unrelated to what happens with the rest of the content.
Examples:
[pbr_single chance=â25%â]This sentence will appear on the page in 25% of the cases, or once in 4 loadings, in average.[/pbr_single]
[pbr_single chance=â3/8â]This sentence will appear on the page three times in eight calls.[/pbr_single]
[pbr_single chance=â0.01%â]The incidence of 0.01% means the content will appear on the page once in 10000 times.[/pbr_single]
[pbr_single chance=â1/10000â]Same as the above.[/pbr_single]As shown in the previous examples, the attribute chance can be expressed both as percentage or as fraction. Percentage value can have up to 6 decimals; which also means the lowest frequency of appearance is 0.000001%, or 1/1000000.
A WORD ABOUT NESTING
Wordpress doesnât support nesting of a shortcode inside itself.
[shortcode]Whatever [shortcode] this shortcode is supposed to do [/shortcode]- it will not do properly.[/shortcode]But, understanding that you may have a need to randomly display some content inside a larger randomly displayed block, Peekaboo Randomizer allows you to do so. Just add a number suffix to the shortcode name:
[pbr_single chance=â1/3â]The larger block appears once in three loadings [pbr_single2 chance=â50%â], while this inner block appears in 50% of those cases.[/pbr_single2] Which means the inner block will be present on the page in 1/6 cases in total.[/pbr_single]You can nest these shortcodes up to 10 levels deep; from [pbr_single2] to [pbr_single10]. Just be careful to properly close each shortcode.
[pbr_wrapper]
no attributes[pbr]
attributes: set and chanceYou can have several alternative blocks of content, while only one of them gets to be displayed on the page. For these cases you can create Peekaboo Randomizer sets.
In order for a [pbr] shortcode block to âknowâ if another block from the same set is randomly chosen this time, not him, we need to feed all blocks to PB Randomizer, which will then do the wiring between them.
For that purpose use [pbr_wrapper] shortcode, to nest all [pbr] shortcodes inside.
The easiest, but also the most reliable way to do so is to start writing the content of a page by placing [pbr_wrapper] first, before everything else in the WP text editor, and [/pbr_wrapper] last. The entire page content can be safely nested inside the wrapper.
Example:
[pbr_wrapper] Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. [pbr set=âowlsâ chance=â25%â]<img src="snowy.jpg" />[/pbr] [pbr set=âowlsâ chance=â50%â]<img src="âscops.jpg"" />[/pbr] [pbr set=âowlsâ chance=â1/10â]<img src="barn_owl.jpg" />[/pbr] [pbr set=âowlsâ chance=â15%â]<img src="strix.jpg" />[/pbr] Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. [/pbr_wrapper]There are four alternating blocks that belong to a set named âowlsâ in this example. Each block contains an image of an owl. Snowy owl will appear 25% of the time, scops owl 50%, strix owl â 15%, while the image of barn owl will load once in ten cases. Only one image loads each time.
IMPORTANT: The sum of all chances in one set has to be exactly 100% (i.e. 1/1) in order for the randomizer set to work properly.
You can have as many sets inside one pbr_wrapper as you wish.
Mind you, instances of a set do not have to reside next to each other.
Another example:
[pbr_wrapper] Bulldog [pbr set=âcatsâ chance=â50%â]Maine Coon[/pbr] [pbr set=âdogsâ chance=â40%â]German Shepherd[/pbr] Ragdoll Siberian Husky Poodle [pbr set=âdogsâ chance=â25%â]Labrador Retriever[/pbr] Border Collie [pbr set=âcatsâ chance=â50%â]Russian Blue[/pbr] Scottish Fold [pbr set=âdogsâ chance=â35%â]Dalmatian[/pbr] [/pbr_wrapper]A WORD ABOUT NESTING
Nesting of [pbr] shortcodes is also possible, but in a bit different way than [pbr_single] is, and only one level down.
If an item/instance/block of a set is nested inside an item/instance/block of another set, it is necessary to use [pbr2] shortcode for defining the inner block and all other blocks which belong to the set (regardless whether those blocks are also nested or not).
Also, there have to be two wrappers. A standard [pbr_wrapper], and [pbr_wrapper2]. As is the case with a single wrapper â the best and cleanest way is to open them both at the beginning, and close them at the very end of the content.
Take a careful look at this example:
[pbr_wrapper][pbr_wrapper2] [pbr set=âliving creaturesâ chance=â5/13â] [pbr2 set=âanimalsâ chance=â20%â]Koala[/pbr2] [pbr2 set=âanimalsâ chance=â20%â]Wolf[/pbr2] [pbr2 set=âanimalsâ chance=â20%â]Fox[/pbr2] [pbr2 set=âinsectsâ chance=â50%â]Wasp[/pbr2] [pbr2 set=âinsectsâ chance=â50%â]Mosquito[/pbr2] [/pbr] [pbr2 set=âanimalsâ chance=â40%â]Penguin[/pbr2] [pbr set=âpeopleâ chance=â28%â]Harry[/pbr] [pbr set=âliving creaturesâ chance=â8/13â] [pbr2 set=âtreesâ chance=â61%â]Cypress[/pbr2] [pbr2 set=âtreesâ chance=â39%â]Chestnut[/pbr2] [/pbr] [pbr set=âpeopleâ chance=â36%â]Jane[/pbr] [pbr set=âpeopleâ chance=â36%â]John[/pbr] [/pbr_wrapper2][/pbr_wrapper]Note that the âpenguinâ block of âanimalsâ set is also wrapped in [pbr2], even it is not inside âliving creaturesâ set. Since thereâs at least one block of âanimalsâ set nested inside âliving creaturesâ then all other items from the âanimalsâ have to have the sub-shortcode [pbr2].
No item of the set âpeopleâ is nested, so itâs just a regular [pbr] set.
SOME FINAL WORDS
As mentioned at the beginning, thereâs a convenient click-through dialog available in the Wordpressâ text editor, which should make inserting shortcodes a breeze.Bear in mind that the laws of probability sometimes may seem counter-intuitive and illogic. If you have set some content to appear on a page with a frequence of, say, 50%, donât be alarmed if sometimes the content appears 5 times in a row⦠or if 7 times in a row it doesnât⦠It may happen more often than youâd maybe expect.
So, if you suspect that something is wrong with the mechanism of randomizing inside the plugin, please test it thoroughly by reloading the page multiple (really multiple) times and taking notes of the (dis)appearance pattern. Probability is all about the Law of Large Numbers
Finally, let me inform you about the existance of Peekaboo Timer plugin, that you may find useful for combining with Randomizer.
Peekaboo Timer hides or shows any content in accordance with various time-related criteria. For example, you can make some blocks of content appear randomly on a page during working hours, while other blocks shall appear (randomly or not) on weekends and off-hours, etcâ¦
Take a closer look: https://codecanyon.pluginus.net/item/peekaboo-timer/7197988