{"id":52962,"date":"2013-12-02T21:55:22","date_gmt":"2013-12-02T21:55:22","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/wp-conditional-content\/"},"modified":"2013-12-02T21:55:22","modified_gmt":"2013-12-02T21:55:22","slug":"wp-conditional-content","status":"closed","type":"plugin","link":"https:\/\/wordpress.org\/plugins\/wp-conditional-content\/","author":479176,"comment_status":"closed","ping_status":"closed","template":"","meta":{"version":"0.1","stable_tag":"0.1","tested":"3.7.41","requires":"3.0","requires_php":"","requires_plugins":"","header_name":"WordPress Conditional Content","header_author":"superinteractive","header_description":"","assets_banners_color":"","last_updated":"2013-12-02 21:55:22","external_support_url":"","external_repository_url":"","donate_link":"https:\/\/www.paypal.com\/cgi-bin\/webscr?cmd=_donations&business=bastiaanvandreunen%40gmail%2ecom&lc=US&item_name=Donation%20for%20WordPress%20Conditional%20Content%20plugin&no_note=0&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest","header_plugin_uri":"http:\/\/www.superinteractive.com","header_author_uri":"http:\/\/www.superinteractive.com\/","rating":4.6,"author_block_rating":0,"active_installs":50,"downloads":7828,"num_ratings":5,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":[],"upgrade_notice":[],"ratings":{"1":0,"2":0,"3":0,"4":"2","5":"3"},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["0.1"],"block_files":[],"assets_screenshots":{"screenshot-1.png":{"filename":"screenshot-1.png","revision":"813980","resolution":"1","location":"assets"}},"screenshots":{"1":"What if statements look like in your content editor."},"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[4060,5106,529,35790,35786],"plugin_category":[],"plugin_contributors":[97784],"plugin_business_model":[],"class_list":["post-52962","plugin","type-plugin","status-closed","hentry","plugin_tags-conditional","plugin_tags-conditions","plugin_tags-content","plugin_tags-else","plugin_tags-if","plugin_contributors-superinteractive","plugin_committers-superinteractive"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/wp-conditional-content.svg","icon_2x":false,"generated":true},"screenshots":[{"src":"https:\/\/ps.w.org\/wp-conditional-content\/assets\/screenshot-1.png?rev=813980","caption":"What if statements look like in your content editor."}],"raw_content":"<!--section=description-->\n<h4>How to use<\/h4>\n\n<p>You can place conditional content between <code>if<\/code> <a href=\"http:\/\/codex.wordpress.org\/Shortcode\">shortcodes<\/a>, and use its attributes to define conditions. The content between the shortcodes will only be displayed if all defined conditions are met.<\/p>\n\n<h4>Defining conditions<\/h4>\n\n<p>Conditions are defined by setting the attributes of the shortcode in the following format:<\/p>\n\n<pre><code>[if &lt;type&gt;=&lt;condition&gt;]\n Conditional content\n[\/if]\n<\/code><\/pre>\n\n<p>A basic example:<\/p>\n\n<pre><code>[if qs=\"product-type:shoes\"]\n Thank you for buying shoes\n[\/if]\n<\/code><\/pre>\n\n<p>The text in this example will only be displayed if the current URL has a GET paramater of \"product-type\" with the value \"shoes\".<\/p>\n\n<p>Available condition types are:<\/p>\n\n<ul>\n<li><p><strong><code>qs<\/code><\/strong> - Match on the key\/value pair of the defined query string\/GET parameter. Query string conditions are formatted like this:<\/p>\n\n<pre><code>[if qs=\"&lt;qskey&gt;:&lt;qsvalue&gt;\"] \u2026 [\/if]\n\nqskey is the name of the query string variable and `qsvalue` the value to test for. For example, the condition `qs=\"product-type:2\"` will match `?product-type=2`.\n<\/code><\/pre><\/li>\n<li><p><strong><code>referrer<\/code><\/strong> - To check on the current referrer. The condition will be true if <code>HTTP_REFERER<\/code> contains <code>&lt;value&gt;<\/code>. The match doesn't need to be exact, so if a user arrives from google and <code>&lt;value&gt;<\/code> is set to \"google.com\" the condition will be true.<\/p><\/li>\n<li><p><strong><code>role<\/code><\/strong> - Matches the current user's role. The match needs to be exact so \"admin\" will not match \"administrator\". Use <code>role<\/code> with and empty value if you want to match users that are not logged in.<\/p><\/li>\n<\/ul>\n\n<h4>Examples<\/h4>\n\n<p>Display content based on query string:<\/p>\n\n<p>[if qs=\"utm_source:partner-site\"]\n     This content is only displayed if the current URL contains a GET paramater 'utm_source' with value 'partner-site'\n    [\/if]<\/p>\n\n<p>Display content based on referrer:<\/p>\n\n<pre><code>[if referrer=\"www.google.com\"]\n This content is only displayed if the referring URL contains 'www.google.com'\n[\/if]\n<\/code><\/pre>\n\n<p>Display content based on user role:<\/p>\n\n<pre><code>[if role=\"editor\"]\n This content is only displayed if the user is logged in with the role 'editor'\n[\/if]\n<\/code><\/pre>\n\n<p>Setting multiple conditions and combining condition types:<\/p>\n\n<pre><code>[if referrer=\"www.example.com\" qs=\"utm_source:partner-site\"]\n This content is displayed to users coming from example.com who clicked on a link originating from our RSS feed.\n[\/if]\n<\/code><\/pre>\n\n<h4>Matching with `exact` or `contain`<\/h4>\n\n<p>By default query string conditions are matched on the exact value as defined in the shortcode. For looser 'wildcard' matching you can add a <code>match<\/code> attribute with the value <code>contain<\/code>:<\/p>\n\n<pre><code>[if qs=\"product-type:cashmere-\" match=\"contain\"]\n Good choice! Cashmere is a wonderful fabric.\n[\/if]\n<\/code><\/pre>\n\n<p>This will match both <code>?product-type=cashmere-sweater<\/code> and <code>?product-type=cashmere-coat<\/code><\/p>\n\n<h4>Matching on multiple values<\/h4>\n\n<p>You can have a condition match on multiple values by using the semicolon as a seperator when defining allowed values. Example:<\/p>\n\n<pre><code>[if qs=\"product-type:shoes;coat\"]\n  This text is displayed for people who bought either a nice pair of shoes or a great fashionable coat.\n[\/if]\n<\/code><\/pre>\n\n<h4>Nesting `if` statements<\/h4>\n\n<p>You can nest statements but you have to use iteration. This has to do with the limitations of the built-in shortcode API.<\/p>\n\n<pre><code>[if qs=\"tonight:the-night\"]\n\n  Tonight's the night.\n\n  [if2 qs=\"future:beautiful\"]\n\n    We create our own destiny every day we live.\n\n  [\/if2]\n\n  [if2 qs=\"future:platic\"]\n\n    I see sheets of plastic in your future.\n\n  [\/if2]\n\n[\/if]\n<\/code><\/pre>\n\n<p>You can nest up to if4 (4 levels).<\/p>\n\n<!--section=installation-->\n<ol>\n<li>Upload the 'wp-conditional-content' folder to your plugins directory<\/li>\n<li>Activate the plugin through the 'Plugins' menu in your WordPress admin<\/li>\n<li>You can now use the [if] shortcode in your post content. Read the documentation for details.<\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt>Can I use `else` statements?<\/dt>\n<dd><p>Not yet, but it's on the to-do list<\/p><\/dd>\n<dt>I have a request for a certain condition I want to be able to check.<\/dt>\n<dd><p>Great, feel free to send me your suggestion through Twitter: <a href=\"https:\/\/twitter.com\/bvandreunen\">@bvandreunen<\/a><\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<ul>\n<li>0.1 First release<\/li>\n<\/ul>","raw_excerpt":"Allows you to use shortcodes as if statements in your content to display text only if certain conditions are met.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/52962","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=52962"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/superinteractive"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=52962"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=52962"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=52962"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=52962"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=52962"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=52962"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}