如何在wordpress插件的按钮上调用wordpress插件设置页面中的功能

时间:2013-05-11 08:08:52

标签: php function wordpress-plugin wordpress

我是一个新的插件。基本上我想在我的插件选项页面中有一个更新按钮,它将从我的插件页面调用一些功能..

我的选项页面如下所示

<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>Plugin Options &raquo; Settings</h2>
    <table class="widefat">
        <thead>
           <tr>
             <th><input type="submit" name="submit" value="Save Settings" class="button-primary" style="padding:8px;" /></th>
           </tr>
        </thead>
        <tfoot>
           <tr>
    </table>

    </form>

</div>

我的插件页面包含以下几个功能

function get_images(){

    global $post; 
    global $wpdb;
    $query_images_args = array(
     'post_type' => 'attachment' , 'post_mime_type' =>'image','post_status' => 'published', 'posts_per_page' => -1,'numberposts' => 1
 );


 $query_images = new WP_Query( $query_images_args );
 $images = array();

         $abc=($images);
                 $count = count($images);
                 for ($i = 0; $i < $count; $i++)
 {

      $final[]= $images[$i];

 }

                 if(count($abc)>1){
                 $_SESSION['arrayImg']=$abc;  
                 }
                  $noofpics=  count($image);
    }
    register_activation_hook(__FILE__, 'get_images');

和我的插件页面中的另外两个函数。所以点击更新按钮我想调用这几个函数..Plz帮助我。

1 个答案:

答案 0 :(得分:0)

我实际上是通过使用

解决了这个问题
<INPUT TYPE="button" onClick="history.go(0), myFunction();" VALUE="Update">

运行时的PHP代码会执行代码行,因此当用户在此页面上时,可以通过点击update按钮执行该功能..

我的问题由此解决......

相关问题