簡(jiǎn)碼(Shortcode)是WordPress一個(gè)非常有用的功能,你可以先了解 WordPress Shortcode(簡(jiǎn)碼)介紹及使用詳解,今天要說的就是如何在WordPress后臺(tái)顯示所有當(dāng)前可用的簡(jiǎn)碼。

只要使用下面的PHP代碼就可以輸出所有簡(jiǎn)碼:
<?php
global $shortcode_tags;
echo '
<pre>';
print_r($shortcode_tags);
echo '</pre>
';
?>
如果你想在WordPress后臺(tái)一個(gè)頁面羅列所有可用簡(jiǎn)碼,下載安裝 view-all-shortcodes 插件,就可以在 后臺(tái) >設(shè)置>View All Shortcodes 下查看 。以下是該插件的所有代碼:
<?php
/*
Plugin Name: Paulund View All Shortcodes
Plugin URI: http://www.paulund.co.uk
Description: View all the available shortcodes on your WordPress blog. This page will show you everything that is currently registered so you can use these in the text editor of WordPress
Version: 1
Author: Paul Underwood
Author URI: http://www.paulund.co.uk
*/
if(is_admin())
{
// Create the Paulund toolbar
$shortcodes = new View_All_Available_Shortcodes();
}
/**
* View all available shrotcodes on an admin page
*
* @author
**/
class View_All_Available_Shortcodes
{
public function __construct()
{
$this->Admin();
}
/**
* Create the admin area
*/
public function Admin(){
add_action( 'admin_menu', array(&$this,'Admin_Menu') );
}
/**
* Function for the admin menu to create a menu item in the settings tree
*/
public function Admin_Menu(){
add_submenu_page(
'options-general.php',
'View All Shortcodes',
'View All Shortcodes',
'manage_options',
'view-all-shortcodes',
array(&$this,'Display_Admin_Page'));
}
/**
* Display the admin page
*/
public function Display_Admin_Page(){
global $shortcode_tags;
?>
<div class="wrap">
<div id="icon-options-general" class="icon32"></div>
<h2>View All Available Shortcodes</h2>
<div class="section panel">
This page will display all of the available shortcodes that you can use on your WordPress blog.
<table class="widefat importers">
<tr>
<td><strong>Shortcodes</strong></td>
</tr>
<?php
foreach($shortcode_tags as $code => $function)
{
?>
<tr>
<td>[<?php echo $code; ?>]</td>
</tr>
<?php
}
?>
</table></div>
</div>
<?php
}
} // END class View_All_Available_Shortcodes
?>
聲明:本站所有文章,如無特殊說明或標(biāo)注,均為本站原創(chuàng)發(fā)布。任何個(gè)人或組織,在未征得本站同意時(shí),禁止復(fù)制、盜用、采集、發(fā)布本站內(nèi)容到任何網(wǎng)站、書籍等各類媒體平臺(tái)。如若本站內(nèi)容侵犯了原著者的合法權(quán)益,可聯(lián)系我們進(jìn)行處理。





竟然還有這個(gè)變量。