我必须在插件的选项页面中获取博客的所有图像源,并且我正在制作一个插件选项页面,如下所示..请查看它..
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 是我想要所有图像源的变量..为此我编写了一个单独的函数
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'));