【问题标题】:While of activation of plugin of wordpress developed by my self getting error在激活我自己开发的wordpress插件时出现错误
【发布时间】:2015-04-26 02:06:27
【问题描述】:

我自己开发的wordpress插件在激活过程中报错:插件在激活过程中产生了6个字符的意外输出。如果您发现“标头已发送”消息、联合提要问题或其他问题,请尝试停用或删除此插件。!

这是插件的代码,请告诉我reson谢谢我的建议

<?php 
/*
Plugin Name: MNG image effect wp - options
Plugin URI: http://mngitservices.com/
Description: This is the plugin used for a gallery page of images or can be used in frent of the webpage apear much effectively.
Author: srinivas
version:1.0
Author URI: http://mngitservices.com/
*/

add_action( 'admin_menu', 'my_plugin_image' );
function my_plugin_image() {
    add_options_page( 'MNG image effect', 'MNG_image_effect', 'manage_options',__FILE__, 'my_plugin_options_images' );
}

// showing in the page 
function my_plugin_options_images() {
add_option('mng_image_plugin',array(
'1'=> 'url1',
'2' => 'url2'
));

if($_POST['mng_gallery']){
$frent_image = $_POST['frent_img1'];
$back_image =   $_POST['back_img1'];
$new_mng_images = array($frent_image,$back_image);
$new_mng_images_options = get_option('mng_image_plugin'); // Getting array from the database of wp options
$new_mng_images = array_merge(array_values($new_mng_images), array_values($new_mng_images_options));

//$new_mng_images = array_push($new_mng_images_options);
update_option('mng_image_plugin',$new_mng_images);
echo 'Updated Successfully';
}
?>
<form action='options-general.php?page=mngimageeffects/mngimageeffects.php' method ="post" >
  <div class="col-md-12">
   <div class="form-group">
    <label for="exampleInputEmail1">Frent images</label>
    <input type="text" name="frent_img1" class="form-control" id="exampleInputEmail1" placeholder="frent image">
  </div>
  <div class="form-group">
    <label for="exampleInputPassword1">Back images</label>
    <input type="text" class="form-control" name="back_img1" id="exampleInputPassword1" placeholder="back image">
  </div>
     <input  type="submit" value="submit" name="mng_gallery" class="btn btn-primary">
     </div>
  </form>     
  <?php 
 }    
add_shortcode('mng_gallery_images','mng_gallery_images' ); 
    function mng_gallery_images(){
    // Dynamic Slider
    $mng_gallery_images = get_option('mng_image_plugin');
    foreach($mng_gallery_images as $option) {
        ?>
        <div class="col-md-3">
        <img src="<?php echo $option; ?>" class="thumbnail" alt="..." width="100%">
        </div>      
        <?php       
            }
}
?>

【问题讨论】:

标签: wordpress plugins stylesheet


【解决方案1】:

我检查了您的代码,没有任何问题。它工作正常,我已成功激活插件。我会建议你检查你的 wordpress 安装文件。如果一切正常,请尝试停用您拥有的其他插件。

【讨论】:

  • 我可以在这个插件的顶部包含css代码吗?
  • 它工作正常但它产生错误是:插件在激活过程中产生了 6 个字符的意外输出。如果您发现“标头已发送”消息、联合提要问题或其他问题,请尝试停用或删除此插件。!
  • 是的,您可以在插件中包含 css。像这样add_action('admin_enqueue_scripts','My_styles_scripts'); function My_styles_scripts(){ $screen = get_current_screen(); if ( 'your_page_id_here' == $screen-&gt;id ){ wp_enqueue_style('My_CSS', plugins_url('css/My.css',__FILE__) ); } } 那是链接一个外部文件。
猜你喜欢
  • 2017-11-11
  • 2014-11-05
  • 2012-07-16
  • 1970-01-01
  • 2021-06-19
  • 2021-12-31
  • 2022-01-23
  • 2019-04-27
  • 1970-01-01
相关资源
最近更新 更多