WP Manifestindependent plugin directory
manifest / content / tukutoi-shortcodes

TukuToi ShortCodes

Indispensable ShortCodes for ClassicPress (and WordPress without Blocks) Websites.

by TukuToi · github.com/tukutoi/tukutoi-shortcodes · website

1stars
42release downloads
≈20active sites
0forks

Install

The author publishes release zips, so WP-CLI can install straight from GitHub:

wp plugin install https://github.com/tukutoi/tukutoi-shortcodes/releases/download/1.26.2/tukutoi-shortcodes.zip

Readme

TukuToi ShortCodes

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:

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

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.

  • post_termsinfo — 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...

[tkt_scs_bloginfo show="language" filter="raw" sanitize="text_field"]</br>

[tkt_scs_bloginfo show="version" filter="raw" sanitize="text_field"]</br>

[tkt_scs_bloginfo show="html_type" filter="raw" sanitize="text_field"]</br>

[tkt_scs_bloginfo show="charset" filter="raw" sanitize="text_field"]</br>

[tkt_scs_bloginfo show="admin_email" filter="raw" sanitize="text_field"]</br>

[tkt_scs_bloginfo show="template_url" filter="raw" sanitize="text_field"]</br>

[tkt_scs_bloginfo show="stylesheet_directory" filter="raw" sanitize="text_field"]</br>

[tkt_scs_bloginfo show="stylesheet_url" filter="raw" sanitize="text_field"]</br>

[tkt_scs_bloginfo show="pingback_url" filter="raw" sanitize="text_field"]</br>

[tkt_scs_bloginfo show="comments_rss2_url" filter="raw" sanitize="text_field"]</br>

[tkt_scs_bloginfo show="comments_atom_url" filter="raw" sanitize="text_field"]</br>

[tkt_scs_bloginfo show="atom_url" filter="raw" sanitize="text_field"]</br>

[tkt_scs_bloginfo show="rss2_url" filter="raw" sanitize="text_field"]</br>

[tkt_scs_bloginfo show="rss_url" filter="raw" sanitize="text_field"]</br>

[tkt_scs_bloginfo show="rdf_url" filter="raw" sanitize="text_field"]</br>

[tkt_scs_bloginfo show="description" filter="raw" sanitize="text_field"]</br>

[tkt_scs_bloginfo show="wpurl" filter="raw" sanitize="text_field"]</br>

[tkt_scs_bloginfo show="url" filter="raw" sanitize="text_field"]</br>

[tkt_scs_bloginfo show="name" filter="raw" sanitize="text_field"]</br>

[tkt_scs_postinfo item="" show="post_name" filter="raw" sanitize="text_field"]</br>
[tkt_scs_postinfo item="" show="ID" filter="raw" sanitize="text_field"]</br>
[tkt_scs_postinfo item="" show="post_author" filter="raw" sanitize="text_field"]</br>
[tkt_scs_postinfo item="" show="post_date" filter="raw" sanitize="text_field"]</br>
[tkt_scs_postinfo item="" show="post_date_gmt" filter="raw" sanitize="text_field"]</br>
[tkt_scs_postinfo item="" show="post_content" filter="raw" sanitize="text_field"]</br>
[tkt_scs_postinfo item="" show="post_title" filter="raw" sanitize="text_field"]</br>
[tkt_scs_postinfo item="" show="post_excerpt" filter="raw" sanitize="text_field"]</br>
[tkt_scs_postinfo item="" show="post_status" filter="raw" sanitize="text_field"]</br>
[tkt_scs_postinfo item="" show="comment_status" filter="raw" sanitize="text_field"]</br>
[tkt_scs_postinfo item="" show="ping_status" filter="raw" sanitize="text_field"]</br>
[tkt_scs_postinfo item="" show="post_password" filter="raw" sanitize="text_field"]</br>
[tkt_scs_postinfo item="" show="post_name" filter="raw" sanitize="text_field"]</br>
[tkt_scs_postinfo item="" show="to_ping" filter="raw" sanitize="text_field"]</br>
[tkt_scs_postinfo item="" show="pinged" filter="raw" sanitize="text_field"]</br>
[tkt_scs_postinfo item="" show="post_modified" filter="raw" sanitize="text_field"]</br>
[tkt_scs_postinfo item="" show="post_modified_gmt" filter="raw" sanitize="text_field"]</br>
[tkt_scs_postinfo item="" show="post_content_filtered" filter="raw" sanitize="text_field"]</br>
[tkt_scs_postinfo item="" show="post_parent" filter="raw" sanitize="text_field"]</br>
[tkt_scs_postinfo item="" show="guid" filter="raw" sanitize="text_field"]</br>
[tkt_scs_postinfo item="" show="menu_order" filter="raw" sanitize="text_field"]</br>
[tkt_scs_postinfo item="" show="post_type" filter="raw" sanitize="text_field"]</br>
[tkt_scs_postinfo item="" show="post_mime_type" filter="raw" sanitize="text_field"]</br>
[tkt_scs_postinfo item="" show="comment_count" filter="raw" sanitize="text_field"]</br>
[tkt_scs_postinfo item="" show="filter" filter="raw" sanitize="text_field"]</br>


[tkt_scs_userinfo item="" field="id" value="" show="ID" sanitize="text_field"]</br>
[tkt_scs_userinfo item="" field="id" value="" show="user_login" sanitize="text_field"]</br>
[tkt_scs_userinfo item="" field="id" value="" show="user_pass" sanitize="text_field"]</br>
[tkt_scs_userinfo item="" field="id" value="" show="user_nicename" sanitize="text_field"]</br>
[tkt_scs_userinfo item="" field="id" value="" show="user_email" sanitize="text_field"]</br>
[tkt_scs_userinfo item="" field="id" value="" show="user_url" sanitize="text_field"]</br>
[tkt_scs_userinfo item="" field="id" value="" show="user_registered" sanitize="text_field"]</br>
[tkt_scs_userinfo item="" field="id" value="" show="user_activation_key" sanitize="text_field"]</br>
[tkt_scs_userinfo item="" field="id" value="" show="user_status" sanitize="text_field"]</br>
[tkt_scs_userinfo item="" field="id" value="" show="display_name" sanitize="text_field"]</br>
[tkt_scs_userinfo item="" field="id" value="" show="caps" sanitize="text_field"]</br>
[tkt_scs_userinfo item="" field="id" value="" show="cap_key" sanitize="text_field"]</br>
[tkt_scs_userinfo item="" field="id" value="" show="roles" sanitize="text_field"]</br>
[tkt_scs_userinfo item="" field="id" value="" show="allcaps" sanitize="text_field"]</br>
[tkt_scs_userinfo item="" field="id" value="" show="filter" sanitize="text_field"]</br>

[tkt_scs_terminfo item="1" show="term_id" filter="raw" sanitize="text_field"]</br>
[tkt_scs_terminfo item="1" show="name" filter="raw" sanitize="text_field"]</br>
[tkt_scs_terminfo item="1" show="slug" filter="raw" sanitize="text_field"]</br>
[tkt_scs_terminfo item="1" show="term_group" filter="raw" sanitize="text_field"]</br>
[tkt_scs_terminfo item="1" show="term_taxonomy_id" filter="raw" sanitize="text_field"]</br>
[tkt_scs_terminfo item="1" show="taxonomy" filter="raw" sanitize="text_field"]</br>
[tkt_scs_terminfo item="1" show="description" filter="raw" sanitize="text_field"]</br>
[tkt_scs_terminfo item="1" show="parent" filter="raw" sanitize="text_field"]</br>
[tkt_scs_terminfo item="1" show="count" filter="raw" sanitize="text_field"]</br>
[tkt_scs_terminfo item="1" show="filter" filter="raw" sanitize="text_field"]</br>

[tkt_scs_post_termsinfo item="" taxonomy="category" show="term_id" delimiter=", " sanitize="text_field"]</br>
[tkt_scs_post_termsinfo item="" taxonomy="category" show="name" delimiter=", " sanitize="text_field"]</br>
[tkt_scs_post_termsinfo item="" taxonomy="category" show="slug" delimiter=", " sanitize="text_field"]</br>
[tkt_scs_post_termsinfo item="" taxonomy="category" show="term_group" delimiter=", " sanitize="text_field"]</br>
[tkt_scs_post_termsinfo item="" taxonomy="category" show="term_taxonomy_id" delimiter=", " sanitize="text_field"]</br>
[tkt_scs_post_termsinfo item="" taxonomy="category" show="taxonomy" delimiter=", " sanitize="text_field"]</br>
[tkt_scs_post_termsinfo item="" taxonomy="category" show="description" delimiter=", " sanitize="text_field"]</br>
[tkt_scs_post_termsinfo item="" taxonomy="category" show="parent" delimiter=", " sanitize="text_field"]</br>
[tkt_scs_post_termsinfo item="" taxonomy="category" show="count" delimiter=", " sanitize="text_field"]</br>
[tkt_scs_post_termsinfo item="" taxonomy="category" show="filter" delimiter=", " sanitize="text_field"]</br>

[tkt_scs_usermeta item="" key="first_name" single="true" delimiter="" sanitize="text_field"]</br>
[tkt_scs_usermeta item="" key="last_name" single="true" delimiter="" sanitize="text_field"]

[tkt_scs_termmeta item="3" key="mikes"  delimiter="" sanitize="text_field"]

[tkt_scs_postmeta item="" key="testing_the_field" single="true" delimiter="" filter="raw" sanitize="text_field"]

[tkt_scs_conditional left="[tkt_scs_postinfo item="" show="ID" filter="raw" sanitize="text_field"]" right="1" operator="eq" else="no true!"][tkt_scs_postinfo item="" show="post_name" filter="raw" sanitize="text_field"][/tkt_scs_conditional]

[tkt_scs_math operand_one="2" operand_two="3" operator="+" sanitize="intval"]

You have your own ShortCode?

Duh, just add it to the GUI. It requires 2 simple filters and a classic "add_shortcode" 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
 */
add_filter( 'tkt_scs_register_shortcode', 'register_my_new_shortcode' );
function register_my_new_shortcode( $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)
 */
add_filter( 'tkt_scs_newcode_shortcode_form_gui', 'add_newcode_shortcode_gui', 10, 2 );
function add_newcode_shortcode_gui( $file, $shortcode ){

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

  return $file;

}
/**
 * Add your new shortcode.
 * 
 * You MUST use the tkt_scs_ prefix for the shortcode tag.
 * You MAY use any callback name you want.
 */
add_shortcode( 'tkt_scs_newcode', '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:

add_filter( 'tkt_scs_custom_inner_shortcodes', 'my_shortcodes', 10, 1 );
function my_shortcodes( $shortcodes ) {

  $shortcodes[] = 'my_shortcode_tag';

  return $shortcodes;

}

Changelog

1.26.2

  • [Fixed] Uninstall checked on wrong plugin slug

1.26.1

  • [Fixed] Missing Text Domains and some Comments for CPCS Review.

1.26.0

  • [Added] Added a JS method to show/hide items in the GUI conditionally

1.25.0

  • [Fixed] Pass the post content shortcode output thru the_content filter
  • [Added] fx and fx_args $atts (Custom PHP Function) to Conditional ShortCode
  • [Removed] wp_kses_post filter from Conditional ShortCode $content

1.24.1

  • [Fixed] Run plugin at init:20 so other (coming later in alphabet) Plugins can hook in

Read the full README on GitHub →

Releases

TagPublishedAssetDownloads
1.26.2 Jun 28, 2022 tukutoi-shortcodes.zip 24
1.26.1 Jun 11, 2022 tukutoi-shortcodes.zip 18

Active-site estimate ≈20 comes from the median of recent superseded releases. Method.