PHP Program code for Shortcode Exec PHP plugin in Wordpress

KITANI Kimiya:

Japanese | English

  • 11th July, 2011: Published.
  • 13th July, 2011: Added [get_bookmark_link] and fixed [get_post_link] in case of empty post and status.
  • 14th July, 2011: Added [get_media_link], fixed [child_content_view] (link), [get_post_link] (permanent link) and fixed the security check of [child_content_view], [get_post_link], [get_bookmark_link]. Please replace all code if you use them.
  • 3rd August, 2011: [get_bookmark_link] 1.1 Released for corresponding the link in page.
  • 11th July, 2012: [list_bookmarks], [put_rss] was released.
  • 15th January, 2013: [passed-event-list] was released.

The page is the comfortable php program code for Shortcode Exec PHP plugin. For using the code, please install Shortcode Exec PHP plugin, first. By using the shortcode, various effects or changes will be able to be added.

About the method of the shortcode registration, please see How to register the shortcode.

1. child_content_view (11th July, 2011)
PHP source code (sha1: 7f6574b62d4e6e481ded3bafdbed776816942799)
  • [child_content_view query="parent ID" orderby="modified" hide_dev='']
    • query (*): Please input parent ID number
    • orderby (optional): Default is "modified". About the categories, please see $orderby in WP_Query
    • hide_dev (optional): The option can be hidden the contents in the specified HTML Tag. If you'd like to use multi keywords, please separate "," (comma).
    • Don't use the shortcode in the content of parent ID.
    • Status: If the page or post is not "publish", the link information will be removed (Only title name).
  • Detail information of "hide_div" option
    • This option adds [style="display:none;"] to the head of the HTML tag when the keyword in "hide_div" is discovered in the contents. Basically, the priority of "style" is higher than "class" and "id".
  • [For Example]
    • Case 1: I'd like to remove the contents within HTML tag including [class="test"]
      • [child_content_view query="parent ID" div_hide='class="test"']
    • Case 2: View of the child lists in WP DS FAQ Plus 1.0.8
      • [child_content_view query="parent ID" div_hide='class="dsfaq_qa_block",class="dsfaq_plus_under_construction"']
2. get_post_link (July 11, 2011: 1.0, August 3rd, 2011: 1.1)
PHP source code (sha1: 56c63a68a2c00354fd0c62baa54ab6448dbde65e)
  • [get_post_link query="post ID" target=""]
    • query (*): Input ID number.
    • target (optional): This "target" is the target option in "a" html tag. (<a> href="" target="target">
    • plink (otional): ex. plink="example" is the hogehoge#example
    • title (optional): Replaced link title instead of post title and page title. when you use plink option, I think that you'd like to use this option, too
  • Comment
    • This is the shortcode for making the link with title. I hope that this function adds to normal wordpress system.
3. get_bookmark_link (July 13, 2011)
PHP source code (sha1: f9a713e8670a7a411e31af07476c5e91c0da0f22)
  • [get_bookmark_link query="bookmark ID"]
    • query: Input ID number.
    • <a target="if target option was enabled" title="if description was inputed" href="url">title name</a>
4. get_media_link (July 14, 2011)
PHP source code (sha1: 1a1d0e4fa8350939f055586da2eb5793c47b6582)
  • [get_media_link query="attachment ID" format=""]
    • query (*): Please input "attachment ID" (in media library).
    • format: If input "download", only appears image URL.
    [get_media_link query="id" format=""]
    * if there is the image thumbnail, 
      <a href="original image url">
        <img width="thumbnail width" height="thumbnail height" 
           src="thumbnail image url" alt="image caption"
           title="image description"></a>
    * Else,
      <a href="original image url">
        <img src="original image url" alt="image caption"
           title="image description"></a>
    [get_media_link query="id" format="download"]
      original image url
5. put_rss (July 22, 2011)
PHP source code (sha1: 365381109900f636f41042bf5b0599bf4731d230)

The tool aims to show the RSS icon with RSS link for a specific RSS or a category in the internal Wordpress.
  • [put_rss url="a URL or a category in the internal WordPress" img=""]
    • url (*): Please input "RSS link" or "A category in the internal WordPress". When the line head begins from "http://" or "https://", the tool will judge that the URL is a category information in the internal WordPress. (ex. In case of using url="information", the URL will be converted "Internal WordPress Site URL/information/feed".
    • img: If you want to use a special icon, please input the URL. If the option is not specified, Mozilla RSS icon will be specified.
6. link_bookmarks (July 11, 2012)
PHP source code (sha1: 5d4ff6040793bbfa65a69d79cb044b3b2c02b26e)

It aims to show the category list for "Bookmark".
  • [list_bookmarks query="category ID" options=""]
    • query: Please input "Category ID". If this value is not specified, all data in all categories will be displayed.
    • options: Default value is "show_description=0&orderby=updated&title_li=&categorize=0". the ul and li tag is used by wp_bookmarks_list. However, tag option in wp_bookmarks_list cannot be used by the security issue.
7. passed-event-list (January 15, 2013)
PHP source code (sha1: 4d08916e258c1f19ed27649a2233ca1c47efb313)

  • The passed event information using The Event Calendar plugin is showed.

    • [passed-event-list]
    Appendix 1: How to register shortcode.
    1. Please open the setting of "Shortcode Exec PHP" in the tool menu.
    2. Input the shortcode name and import the PHP code to the big text box. And click "Add" button.
    3. Click "Test" button.
    4. If the Error message appears, please check the PHP code.