Collapse-Pro-Matic Expand_On Attribute
[expand title="Trigger Text" expand_on="is_search"]Target Text[/expand]
This new conditional expand feature is based on a request by user thisimnot. We introduce a new attribute called expand_on
that accepts a comma separated list of WordPress Conditional Tags that will auto-expand the element if true.
For example. The following element should be displayed as collapsed when viewing the front (blog) page, but when viewing the single post or the search results page it will be shown as expanded.
[expand title="Trigger Text" expand_on="is_single, is_search"]Target Text[/expand]
Adding Custom Conditional
To create a custom conditional that checks for a custom query_var, for example, is_hilite:
Step 1: Place the following in your child theme’s function.php file:
//Add query vars
add_filter( 'query_vars', 'my_query_vars' );
function my_query_vars( $qvars ) {
$qvars[] = 'hilite';
return $qvars;
}
//Add custom hilite conditional
function is_hilite(){
if(get_query_var( 'hilite')){
return true;
}
return false;
}
The shortcode:
[expand title="Trigger Text" expand_on="is_hilite"]Target Text[/expand]
Example:
Here, at the very bottom of this page is a little collapse element to test the internal WordPress Search.
Collapse-O-Matic & Fancy Box Test
This is an expand element from Collapse-O-Matic:
[expand title='trigger']target[/expand]
and this is an example of a link to an image that should pop up using fancy box:
Responsive Countdown Test
Here are the responsive countdown styles.
carbonite-responsive
cloud-city
Collapse-O-Matic Left And Right Arrows
Normally, expand elements display the arrow on the left:
[expand title="trigger"]target[/expand]
However, we can move the arrow all the way to the right by assigning the the trigger the arrowright
class:
[expand title="trigger" trigclass="arrowright"]target[/expand]
We can move the trigger closer to the text by changing the width of the trigger element using css:
CSS
.shorty {
width: 70px;
}
[expand title="trigger" trigclass="arrowright shorty"]target[/expand]
What if we want both left and right arrows? We first start with a roll-your-own expand element with no arrows by assigning the noarrow
class to the trigger:
<div class="collapseomatic noarrow" id="my_double_arrow_01">trigger</div>
<div id="target-my_double_arrow_01" class="collapseomatic_content">target</div>
Then we manually upload the arrows we want to use and place them in the title:
<div class="collapseomatic noarrow" id="my_double_arrow_02"><img src="https://spacedonkey.de/wp-content/uploads/2014/10/arrow-down.png" width="12" height="14" /> trigger <img src="https://spacedonkey.de/wp-content/uploads/2014/10/arrow-down.png" width="12" height="14" /></div>
<div id="target-my_double_arrow_02" class="collapseomatic_content">target</div>
Finally we need to add a swap title element for the close arrows:
<div class="collapseomatic noarrow" id="my_double_arrow_03"><img src="https://spacedonkey.de/wp-content/uploads/2014/10/arrow-down.png" width="12" height="14" /> trigger <img src="https://spacedonkey.de/wp-content/uploads/2014/10/arrow-down.png" width="12" height="14" /></div>
<div id="swap-my_double_arrow_03" alt="" class="colomat-swap" style="display:none;"><img src="https://spacedonkey.de/wp-content/uploads/2014/10/arrow-up.png" width="12" height="14" /> target <img src="https://spacedonkey.de/wp-content/uploads/2014/10/arrow-up.png" width="12" height="14" /></div>
<div id="target-my_double_arrow_03" class="collapseomatic_content">target</div>
New Plugin Test: Collapse Command
This is a test of the Collapse Command stystem:
[expand cid="1398"/]
Trigger Shortcode
[expand_trig cid="1403"]Target Shortcode
[expand_targ cid="1403"]Escaping Shortcode Examples
Shortcodes
Normally when a shortcode is used, it would trigger the WordPress magic that makes a shortcode a short code:
Now, if we wanted to show what shortcode was used to make that magic happen, we simply need to escape it like so:
[[expand title=”trigger”]content[/expand]]
and that renders:
[expand title="trigger"]content[/expand]
we can even wrap it in a nice code tag to set it apart:
[expand title="trigger"]content[/expand]
so far so good.
HTML
Now lets say we want to escape a bit of HTML! Well, lets first try simply wrapping it in the code tag:
- item 1
- item 2
- item 3
Hmm… no good. All that seems to have done is render the HTML in the special css of a code tag.
What about using Markdown! Let’s wrap the HTML in backticks and see what happens…
<ul>
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
</ul>
Perfect! It even added that monospace font that makes code look even more code-like.
Now for the test…
Shortcode and HTML
Since we are using HTML we need to use Markup… what happens when we add in the shortcode?
<ul>
<li>item 1</li>
<li>item 2
<li>item 3</li>
</ul>
The HTML looks rockin’ but the shortcode… well that was just processed as normal. Hmm… lets try doing the double bracket thing:
<ul>
<li>item 1</li>
<li>item 2 [expand title="trigger"]content[/expand]</li>
<li>item 3</li>
</ul>
Wow! that totally worked. So there you have it: Problem solved!
Collapse-O-Matic ID Anchor with Expanded Attribute
[expand title="Pocket Calculator" id="kraftwerk" ]Target Content[/expand]
With my pocket calculator
[expand title="Special Key" id="special_key" expanded="true"]Target Content[/expand]
T(-) Countdown Control Wrapper Class Toggle
Based on launch state the wrapping element will toggle classes between tminus_countdown
and tminus_launched
The css:
.tminus_countdown{
border: 1px dotted green;
}
.tminus_launched{
border: 1px dotted red;
}
Collapse-O-Matic Unordered List Test
`
<ul>
<li>first item</li>
<li>second item
[ expand title="read more" ]
<ul>
<li>sub item one</li>
<li>sub item two</li>
<li>sub item three</li>
</ul>
<p>a paragraph of text</p>
[ /expand ]
- first item
- second item
read more- sub item one
- sub item two
- sub item three
a paragraph of text
- third item