Usage

Description

TukuToi ShortCodes provides you with a bunch of ShortCodes useful for dynamic webdevelopment. Basically a bunch of WordPress methods and objects have been “ShortCode-ified” in this Plugin. You can display any kind of site, post, post term, user, taxonomy, usermeta, postmeta and termmeta information.

By nesting shortcodes inside each other you can have powerful dynamic output, such as this example" [tkt_scs_post_termsinfo item="[tkt_scs_postinfo item="" show="ID" filter="raw" sanitize="text_field"]" taxonomy="category" show="term_id" delimiter=", " sanitize="text_field"] Above would output all the Term IDs of the Post, where you inserted the shortcode. It gets the current Post ID with the Shortcode nested inside the Post Term Information ID attribute.

This is not possible in WordPress anymore since 4.2.3 https://wptavern.com/plugin-developers-demand-a-better-security-release-process-after-wordpress-4-2-3-breaks-thousands-of-websites but thanks to the crafty developers at Toolset, I was able to build a ShortCode Processor using their code as reference which allows just that.

The Plugin comes with a Backend GUI to insert the ShortCodes (and choose/insert options), look for the TukuToi ShortCodes Button on post or page editors.

One of the most powerful features in the Plugin is a “conditional” ShortCode allowing you to write “if/else” statements directly in your favourite WordPress Text Editor like so:


[tktscsconditional left="The past is WP" right="The Future is CP" operator="eqv" else="The Compared values where not true!"] The Compared values where true! [/tktscsconditional]

Above would return The Compared values where not true! as the values are not equal.

And no, it does not use eval(). It uses a custom set of expressions, and does not parse user input to PHP directly.

Duh, did I mention you can do math with the plugin too? All valid Mathematical operations are possible. Even the weirdest Modulo.

Available ShortCodes:

  • archivelinks — TukuToi [archivelinks] ShortCode.
  • attachmentimage — TukuToi [attachmentimage] ShortCode.
  • bloginfo — TukuToi [bloginfo] ShortCode.
  • conditional — TukuToi [conditional] ShortCode.
  • editlinks — TukuToi [editlinks] ShortCode.
  • math — TukuToi [math] ShortCode.
  • posttermsinfo — TukuToi [post_termsinfo] ShortCode.
  • postinfo — TukuToi [postinfo] ShortCode.
  • postmeta — TukuToi [postmeta] ShortCode.
  • round — TukuToi [round] ShortCode.
  • terminfo — TukuToi [terminfo] ShortCode.
  • termmeta — TukuToi [termmeta] ShortCode.
  • userinfo — TukuToi [userinfo] ShortCode.
  • usermeta — TukuToi [usermeta] ShortCode.

All ShortCodes take pretty much the same arguments as the corresponding WP/CP functions and the display attributes generally follow the WP/CP naming of object props or array keys.

As said, all ShortCodes can be inserted in the Post Editors using a Dymamic GUI that lets you compose the ShortCode attributes, with custom values or where appropriate with existing “object properties”.

Have a look at just some of the possible Output…


[tktscsbloginfo show="language" filter="raw" sanitize="textfield"]</br>

[tktscsbloginfo show="version" filter="raw" sanitize="textfield"]</br>

[tktscsbloginfo show="htmltype" filter="raw" sanitize="textfield"]</br>

[tktscsbloginfo show="charset" filter="raw" sanitize="textfield"]</br>

[tktscsbloginfo show="adminemail" filter="raw" sanitize="textfield"]</br>

[tktscsbloginfo show="templateurl" filter="raw" sanitize="textfield"]</br>

[tktscsbloginfo show="stylesheetdirectory" filter="raw" sanitize="textfield"]</br>

[tktscsbloginfo show="stylesheeturl" filter="raw" sanitize="textfield"]</br>

[tktscsbloginfo show="pingbackurl" filter="raw" sanitize="textfield"]</br>

[tktscsbloginfo show="commentsrss2url" filter="raw" sanitize="textfield"]</br>

[tktscsbloginfo show="commentsatomurl" filter="raw" sanitize="textfield"]</br>

[tktscsbloginfo show="atomurl" filter="raw" sanitize="textfield"]</br>

[tktscsbloginfo show="rss2url" filter="raw" sanitize="textfield"]</br>

[tktscsbloginfo show="rssurl" filter="raw" sanitize="textfield"]</br>

[tktscsbloginfo show="rdfurl" filter="raw" sanitize="textfield"]</br>

[tktscsbloginfo show="description" filter="raw" sanitize="textfield"]</br>

[tktscsbloginfo show="wpurl" filter="raw" sanitize="textfield"]</br>

[tktscsbloginfo show="url" filter="raw" sanitize="textfield"]</br>

[tktscsbloginfo show="name" filter="raw" sanitize="textfield"]</br>

[tktscspostinfo item="" show="postname" filter="raw" sanitize="textfield"]</br> [tktscspostinfo item="" show="ID" filter="raw" sanitize="textfield"]</br> [tktscspostinfo item="" show="postauthor" filter="raw" sanitize="textfield"]</br> [tktscspostinfo item="" show="postdate" filter="raw" sanitize="textfield"]</br> [tktscspostinfo item="" show="postdategmt" filter="raw" sanitize="textfield"]</br> [tktscspostinfo item="" show="postcontent" filter="raw" sanitize="textfield"]</br> [tktscspostinfo item="" show="posttitle" filter="raw" sanitize="textfield"]</br> [tktscspostinfo item="" show="postexcerpt" filter="raw" sanitize="textfield"]</br> [tktscspostinfo item="" show="poststatus" filter="raw" sanitize="textfield"]</br> [tktscspostinfo item="" show="commentstatus" filter="raw" sanitize="textfield"]</br> [tktscspostinfo item="" show="pingstatus" filter="raw" sanitize="textfield"]</br> [tktscspostinfo item="" show="postpassword" filter="raw" sanitize="textfield"]</br> [tktscspostinfo item="" show="postname" filter="raw" sanitize="textfield"]</br> [tktscspostinfo item="" show="toping" filter="raw" sanitize="textfield"]</br> [tktscspostinfo item="" show="pinged" filter="raw" sanitize="textfield"]</br> [tktscspostinfo item="" show="postmodified" filter="raw" sanitize="textfield"]</br> [tktscspostinfo item="" show="postmodifiedgmt" filter="raw" sanitize="textfield"]</br> [tktscspostinfo item="" show="postcontentfiltered" filter="raw" sanitize="textfield"]</br> [tktscspostinfo item="" show="postparent" filter="raw" sanitize="textfield"]</br> [tktscspostinfo item="" show="guid" filter="raw" sanitize="textfield"]</br> [tktscspostinfo item="" show="menuorder" filter="raw" sanitize="textfield"]</br> [tktscspostinfo item="" show="posttype" filter="raw" sanitize="textfield"]</br> [tktscspostinfo item="" show="postmimetype" filter="raw" sanitize="textfield"]</br> [tktscspostinfo item="" show="commentcount" filter="raw" sanitize="textfield"]</br> [tktscspostinfo item="" show="filter" filter="raw" sanitize="textfield"]</br>

[tktscsuserinfo item="" field="id" value="" show="ID" sanitize="textfield"]</br> [tktscsuserinfo item="" field="id" value="" show="userlogin" sanitize="textfield"]</br> [tktscsuserinfo item="" field="id" value="" show="userpass" sanitize="textfield"]</br> [tktscsuserinfo item="" field="id" value="" show="usernicename" sanitize="textfield"]</br> [tktscsuserinfo item="" field="id" value="" show="useremail" sanitize="textfield"]</br> [tktscsuserinfo item="" field="id" value="" show="userurl" sanitize="textfield"]</br> [tktscsuserinfo item="" field="id" value="" show="userregistered" sanitize="textfield"]</br> [tktscsuserinfo item="" field="id" value="" show="useractivationkey" sanitize="textfield"]</br> [tktscsuserinfo item="" field="id" value="" show="userstatus" sanitize="textfield"]</br> [tktscsuserinfo item="" field="id" value="" show="displayname" sanitize="textfield"]</br> [tktscsuserinfo item="" field="id" value="" show="caps" sanitize="textfield"]</br> [tktscsuserinfo item="" field="id" value="" show="capkey" sanitize="textfield"]</br> [tktscsuserinfo item="" field="id" value="" show="roles" sanitize="textfield"]</br> [tktscsuserinfo item="" field="id" value="" show="allcaps" sanitize="textfield"]</br> [tktscsuserinfo item="" field="id" value="" show="filter" sanitize="textfield"]</br>

[tktscsterminfo item="1" show="termid" filter="raw" sanitize="textfield"]</br> [tktscsterminfo item="1" show="name" filter="raw" sanitize="textfield"]</br> [tktscsterminfo item="1" show="slug" filter="raw" sanitize="textfield"]</br> [tktscsterminfo item="1" show="termgroup" filter="raw" sanitize="textfield"]</br> [tktscsterminfo item="1" show="termtaxonomyid" filter="raw" sanitize="textfield"]</br> [tktscsterminfo item="1" show="taxonomy" filter="raw" sanitize="textfield"]</br> [tktscsterminfo item="1" show="description" filter="raw" sanitize="textfield"]</br> [tktscsterminfo item="1" show="parent" filter="raw" sanitize="textfield"]</br> [tktscsterminfo item="1" show="count" filter="raw" sanitize="textfield"]</br> [tktscsterminfo item="1" show="filter" filter="raw" sanitize="textfield"]</br>

[tktscsposttermsinfo item="" taxonomy="category" show="termid" delimiter=", " sanitize="textfield"]</br> [tktscsposttermsinfo item="" taxonomy="category" show="name" delimiter=", " sanitize="textfield"]</br> [tktscsposttermsinfo item="" taxonomy="category" show="slug" delimiter=", " sanitize="textfield"]</br> [tktscsposttermsinfo item="" taxonomy="category" show="termgroup" delimiter=", " sanitize="textfield"]</br> [tktscsposttermsinfo item="" taxonomy="category" show="termtaxonomyid" delimiter=", " sanitize="textfield"]</br> [tktscsposttermsinfo item="" taxonomy="category" show="taxonomy" delimiter=", " sanitize="textfield"]</br> [tktscsposttermsinfo item="" taxonomy="category" show="description" delimiter=", " sanitize="textfield"]</br> [tktscsposttermsinfo item="" taxonomy="category" show="parent" delimiter=", " sanitize="textfield"]</br> [tktscsposttermsinfo item="" taxonomy="category" show="count" delimiter=", " sanitize="textfield"]</br> [tktscsposttermsinfo item="" taxonomy="category" show="filter" delimiter=", " sanitize="textfield"]</br>

[tktscsusermeta item="" key="firstname" single="true" delimiter="" sanitize="textfield"]</br> [tktscsusermeta item="" key="lastname" single="true" delimiter="" sanitize="textfield"]

[tktscstermmeta item="3" key="mikes" delimiter="" sanitize="textfield"]

[tktscspostmeta item="" key="testingthefield" single="true" delimiter="" filter="raw" sanitize="textfield"]

[tktscsconditional left="[tktscspostinfo item="" show="ID" filter="raw" sanitize="textfield"]" right="1" operator="eq" else="no true!"][tktscspostinfo item="" show="postname" filter="raw" sanitize="textfield"][/tktscsconditional]

[tktscsmath operandone="2" operandtwo="3" operator="+" sanitize="intval"]

You have your own ShortCode?

Duh, just add it to the GUI. It requires 2 simple filters and a classic “addshortcode” call. You can then use our API to add a full fledged GUI for your shortcode. That is simpler than you think - with 4 lines of code, you already would have 4 settings in the GUI, possibly select options populated dynamically with Post, User or Term data, and more. You can of course also pass your complete custom options and settings.


/* Register your new shortcode.
You MUST pass all array key=>values You MUST NOT return an empty array or reset the array / addfilter( 'tktscsregistershortcode', 'registermynewshortcode' ); function registermynewshortcode( $shortcodes ){

$shortcodes['newcode'] = array( 'label' => 'My New Thing', 'type' => 'informational', );

return $shortcodes;

}


/* Add your new shortcode's GUI.
You MUST check for your shortcode. You MUST pass a valid PHP file path in which you provide your Settings Form. You MAY or MAY NOT use our API to create the Settings Form, but you MUST use minimally: - a Form wrapping your ShortCode settings inputs `<form class="tkt-shortcode-form">* - a fieldset wrapping each of your inputs<fieldset>* - an input ID, NAME matching your ShortCode name * - you SHOULD add a label with corresponding for attribute<label for="">LABEL</label>* - you MAY add Descriptions inside a<small class="tkt-shortcode-option-explanation"><em>` wrapper You MUST escape every variable used in your custom labels, attributes, etc You SHOULD add sanitization, single or double quotes Settings to your GUI (Just the API for that, it is one call) / addfilter( 'tktscsnewcodeshortcodeformgui', 'addnewcodeshortcodegui', 10, 2 ); function addnewcodeshortcodegui( $file, $shortcode ){

if( $shortcode === 'newcode' ){ $file = gettemplatedirectory() . '/test.php'; }

return $file;

}


/* Add your new shortcode.
You MUST use the tktscs prefix for the shortcode tag. You MAY use any callback name you want. / addshortcode( 'tktscsnewcode', 'mewnewcode' ); function mewnewcode(){ $out = 'new shortcode'; return $out; }

Add your own shortcodes to supported inner ShortCodes

When you want to use your own ShortCodes inside HTML or ShortCode attributes, but do not register them with the TukuToi ShortCodes GUI, you can use this filter:


addfilter( 'tktscscustominnershortcodes', 'myshortcodes', 10, 1 ); function myshortcodes( $shortcodes ) {

$shortcodes[] = 'myshortcodetag';

return $shortcodes;

}

Search results