我必須讓所有的圖像插件的選項頁博客的來源,我想提出一個插件選項頁面如下..Plz來看一下,它..如何在wordpress插件的選項頁中獲取整個博客的圖片?
public function add_plugin_page(){
add_options_page('Settings Admin', 'Plugin_options', 'manage_options', 'test-setting-admin', array($this, 'create_admin_page'));
}
下面的代碼是我的插件選項頁
public function create_admin_page(){
?>
<div class="wrap">
<?php screen_icon(); ?>
<form action="options.php" method="post" id="<?php echo $plugin_id; ?>_options_form" name="<?php echo $plugin_id; ?>_options_form">
<?php settings_fields($plugin_id.'_options'); ?>
<h2>kk Plugin Options » Settings</h2>
<table border="1" bordercolor="#FFCC00" style="background-color:#FFFFCC; margin-top:22px" width="25%" cellpadding="2" cellspacing="1">
<tbody>
<tr>
<td style="padding-left:8px;font-family:Verdana, Geneva, sans-serif;color:#666;"><h3>Blog Id:</h3></td>
<td><p><?php echo$abc?></p></td>
</tr>
<tr>
<td style="padding-left:8px;font-family:Verdana, Geneva, sans-serif;color:#666;"><h3>API Key:</h3></td>
<td><input type="text" name="kkpo_quote" value="<?php echo get_option('kkpo_quote'); ?>" /></td>
</tr>
</tbody>
</table>
<div id="mainCHImage" style="position:relative;height:'.$imgHeight.'px;width:'.$width.'px;">
<img id="paletlyIcon" style="position:absolute;left:'.$imgWidth.'px;top:'.$imgHeight.'px;z-index:9999;cursor:pointer;background:none;border:none;" src="http://Images/favIcon.png" onclick="get_images()">'.
<img style="background:none;border:none;"></div>
</form>
</div>
<?php
}
$ ABC是,我想所有的圖像源..For,我寫了一個單獨的函數
public function get_images(){
if(is_single() || is_page() || is_home()||!is_admin()){
global $post;
global $wpdb;
$query_images = new WP_Query($query_images_args);
$images = array();
foreach ($query_images->posts as $image) {
$images[]= wp_get_attachment_url($image->ID);
$abc=($images);
echo $abc;
}
}
}
但我變收到錯誤
ReferenceError: get_images is not defined
[Break On This Error]
get_images();
我已經加入該功能在我的構建,即
add_action('IMages_grab', array(&$this, 'get_images'));
add_filter('IMages_grab', array(&$this, 'get_images'));
(呵呵,我們再次見面..)請注意,我的僞反對意見不是單獨使用數組,而是因爲OP想要將它回顯到屏幕 –