If Shortcode

By : geomagas

This plugin provides an "if" shortcode to conditionally render content. The syntax is the following:

[if condition1 condition2=false condition3]{content}[/if]

Conditions are passed as attribute names. Multiple conditions evaluate to the result of ORing all of them. In other words, if at least one condition evaluates to the desired boolean result, {content} is rendered, otherwise it is discarded. Attribute values determine if we want the condition to be true or false. A value of '0', 'false', '' (the empty string), 'null' or 'no' means we expect the condition to be false. Anything else, including the absense of a value, is interpreted as true.

For example, suppose that we want to include a sentence in a post, but only for anonymous visitors:

[if is_user_logged_in=no]The Sentence.[/if]

It also provides an [else] shortcode and an [eitherway] one for use inside [if] blocks. [else] will render its content if the condition evaluates to false, and [eitherway] will render its content regardless of the evaluation result. When used outside an [if] block, these shortcodes behave as if the whole content is surrounded by an [if] shortcode whose condition evaluates to true. In other words, an [else] shortcode would not render any content, while a [eitherway] one would. You can use as many of these shortcodes as you like in a single [if] block, which gives you the ability to do things like:

    - Am I logged in?
    [if is_user_logged_in]- Yes you are.
    [else]- No you are not.
    [/else][eitherway]- I'm sorry, what?
    [/eitherway]- I said YOU A-R-E LOGGED IN!!!
    [else]- YOU ARE NOT LOGGED IN!!! What's the matter with you?[/else][/if]

A multitude of conditions are supported out-of-the-box. The following evaluate to the result of the corresponding WordPress Conditional Tag, using the no-parameter syntax:

    is_single
    is_singular
    is_page
    is_home
    is_front_page
    is_category
    is_tag
    is_tax
    is_sticky
    is_author
    is_archive
    is_year
    is_month
    is_day
    is_time
    is_feed
    is_search
    comments_open
    pings_open
    is_404
    is_user_logged_in
    is_super_admin

For example, the evaluation of the is_page condition is equivalent to calling is_page() with no parameter.

The functionality of the plugin can be extended by other plugins, by means of adding custom conditions through filters. To add a custom condition, a filter hook must be defined in the following manner:

add_filter($if_shortcode_filter_prefix.'my_condition','my_condition_evaluator');

function my_condition_evaluator($value)
    {
    $evaluate=.... /* add your evaluation code here */
    return $evaluate;
    }

A big thanks to M Miller for the normalize_empty_atts() function found here: http://wordpress.stackexchange.com/a/123073/39275

WP Conditional Shortcodes

This plugin gives content developers shortcode equivalents to the conditional tags that WordPress provides for theme developments. Each shortcode only includes its contents if a certain condition is true. This allows them to modify what content is shown in any given context on a post-by-post basis.........

Similar: 60%

Conditional Tags Shortcode

With this shortcode you can take control of where the content is displayed. More information can be found at: http://shazdeh.me/wordpress-plugins/conditional-tags-shortcode/...

Similar: 50%

WordPress Conditional Content

How to use You can place conditional content between if shortcodes, and use its attributes to define conditions. The content between the shortcodes will only be displayed if all defined conditions are met....

Similar: 45%

Administrative Shortcodes

A set of shortcodes for the website administrators....

Similar: 34%

WP file_get_contents()

A WordPress shortcode for PHP's file_get_contents() function. Examples: [wp-file-get-contents url="http://example.com/dir/file.html"] [wp-file-get-contents url="http://example.com/counter/" cache="0"] [wp-file-get-contents url="file://dir/file.html"] [wp-.........

Similar: 23%

Tea Page Content

Tea Page Content is a powerful plugin that allows create blocks with content of any page, post, etc, and customize look of blocks via template system. You can select one or more entries, choose template (or create your own) and display it by widget or shortcode. Templates presents very flexible syst.........

Similar: 23%

BadgeOS Achievement Shortcode Add On

This BadgeOS Add on adds a shortcode to show or hide content depending on if the user has earned a specific achievement. Note: You will need to install the free BadgeOS plugin™ (version 1.4 or higher) to use the BadgeOS Community Add-on. Get the BadgeOS plugin. This plugin was originally de.........

Similar: 9%

my press articles

Current features include 1) Google Analytics 2) Related Posts 3) Sticky Posts Widget 4) Social Media Widget and buttons in post content 5) Google Map with shortcode 6) Facebook Fan Page 7) Customize feature for wordpress login form. 8) Database optimization...

Similar: 8%

Smart AD Tags

Smart AD Tags is an easy to use all in one advertisement package plugin which helps bloggers to insert advertisement in various locations of a post. Besides that, you can also insert ad on the sidebar of your blog, comment area as well as on any individual page. Preview banners when editing them. Th.........

Similar: 8%

Archive Post Tabs

Archive Post Tabs is used to show list and grid view of the archive posts with months and years tabs. This plugin allows to created unlimited widget and shortcodes for the home and sup-pages. It's fully responsive and customizable archive posts list and grid view using ajax load more functionality....

Similar: 8%