-1

这是我的插件代码,激活和停用挂钩在服务器上工作正常,但是当我添加 HTML 部分时,它会在发布帖子后显示白屏。

register_activation_hook(__FILE__,'hs_install');
register_deactivation_hook(__FILE__,'hs_uninstall');
//<--------- Installation ----------->
function hs_install(){
global $wpdb;
$table_name1=$wpdb->prefix.'hs_image_tag';
 //Table structure for table `image_tag`
    $wpdb->query("CREATE TABLE IF NOT EXISTS $table_name1 (
  id int(11) NOT NULL auto_increment,
  pic_id int(11) NOT NULL,
  name varchar(100) NOT NULL,
  pic_x int(11) NOT NULL,
  pic_y int(11) NOT NULL,
  PRIMARY KEY  (`id`),
  KEY pic_id (pic_id))");

$table_name2=$wpdb->prefix.'hs_categories';
//Table structure for table `wp_hs_categories` `$table_name2`
$query = $wpdb->query("CREATE TABLE IF NOT EXISTS $table_name2 (
 id int(11) NOT NULL AUTO_INCREMENT,
  cat_name varchar(30) NOT NULL,
  PRIMARY KEY (id))");


//Dumping data for table `wp_hs_categories`
if($query)
$wpdb->query("INSERT INTO $table_name2 (id,cat_name) VALUES
(1, 'Fruits'),
(2, 'Cars'),
(3, 'Electronics'),
(4, 'Laptops'),
(5, 'Nature'),
(6, 'Sports'),
(7, 'Cats')");

//--------------------------------------------------------

//Table structure for table `wp_hs_image_details`

$table_name3=$wpdb->prefix.'hs_image_details';
$query = $wpdb->query("CREATE TABLE IF NOT EXISTS $table_name3 (
  id int(11) NOT NULL AUTO_INCREMENT,
  title varchar(30) NOT NULL,
  image_name varchar(30) NOT NULL,
  category varchar(30) NOT NULL,
  last_save varchar(20) NOT NULL,
  path varchar(200) NOT NULL,
  PRIMARY KEY (id)
)");

//Dumping data for table `wp_hs_image_details`

if($query)
$query = $wpdb->query("INSERT INTO $table_name3 
(id,title,image_name,category,last_save,path) VALUES
(1, 'Title 1', 'm1.jpg', 'Electronics', '13-10-2012', 'uploads/m1.jpg'),
(2, 'Title 2', 'm2.jpg', 'Electronics', '13-10-2012', 'uploads/m2.jpg'),
(3, 'Title 3', 'm3.jpg', 'Electronics', '13-10-2012', 'uploads/m3.jpg'),
(4, 'Title 4', 'm4.jpg', 'Electronics', '13-10-2012', 'uploads/m4.jpg'),
(5, 'Title 5', 'car1.jpg', 'Cars', '13-10-2012', 'uploads/car1.jpg'),
(6, 'Title 6', 'car2.jpg', 'Cars', '13-10-2012', 'uploads/car2.jpg'),
(7, 'Title 7', 'car3.jpg', 'Cars', '13-10-2012', 'uploads/car3.jpg'),
(8, 'Title 8', 'car4.jpg', 'Cars', '13-10-2012', 'uploads/car4.jpg'),
(9, 'Title 9', 'cat1.jpg', 'Cats', '13-10-2012', 'uploads/cat1.jpg'),
(10, 'Title 10', 'cat2.jpg', 'Cats', '13-10-2012', 'uploads/cat2.jpg'),
(11, 'Title 11', 'cat3.jpg', 'Cats', '13-10-2012', 'uploads/cat3.jpg'),
(12, 'Title 12', 'cat4.jpg', 'Cats', '13-10-2012', 'uploads/cat4.jpg')");


//--------------------------------------------------------

//Table structure for table `wp_hs_template_images`
$table_name4=$wpdb->prefix.'hs_template_images';

$query = $wpdb->query("CREATE TABLE IF NOT EXISTS $table_name4 (
  id int(11) NOT NULL AUTO_INCREMENT,
  image_name varchar(30) NOT NULL,
  category varchar(30) NOT NULL,
  path varchar(200) NOT NULL,
  PRIMARY KEY (id)
)");

//Dumping data for table `wp_hs_template_images`

if($query)
$wpdb->query("INSERT INTO $table_name4 (id,image_name,category,path) VALUES
(1, 'Laptop 1', 'Laptops', 'template_images/l1.jpg'),
(2, 'Laptop 2', 'Laptops', 'template_images/l2.jpg'),
(3, 'Laptop 3', 'Laptops', 'template_images/l3.jpg'),
(4, 'Laptop 4', 'Laptops', 'template_images/l4.jpg'),
(5, 'Laptop 5', 'Laptops', 'template_images/l5.jpg'),
(6, 'Car 1', 'Cars', 'template_images/c1.jpg'),
(7, 'Car 2', 'Cars', 'template_images/c2.jpg'),
(8, 'Car 3', 'Cars', 'template_images/c3.jpg'),
(9, 'Car 4', 'Cars', 'template_images/c4.jpg'),
(10, 'Car 5', 'Cars', 'template_images/c5.jpg'),
(11, 'Device 1', 'Electronics', 'template_images/e1.jpg'),
(12, 'Device 2', 'Electronics', 'template_images/e2.jpg'),
(13, 'Device 3', 'Electronics', 'template_images/e3.jpg'),
(14, 'Device 4', 'Electronics', 'template_images/e4.jpg'),
(15, 'Device 5', 'Electronics', 'template_images/e5.jpg')");
}
//Table structure for table `wp_hs_categories`
//<--------- Uninstallation ----------->
function hs_uninstall(){
    global $wpdb;
    $table_name1=$wpdb->prefix.'hs_image_tag';
    $table_name2=$wpdb->prefix.'hs_categories';
    $table_name3=$wpdb->prefix.'hs_image_details';
    $table_name4=$wpdb->prefix.'hs_template_images';
    $wpdb->query("DROP TABLE IF EXISTS    
$table_name2,$table_name3,$table_name4,$table_name1");
}
function addYouTube($atts, $content = null) {
        extract(shortcode_atts(array( "id" => '' ), $atts));
        return '<p style="text-align:center"><a href="http://www.youtube.com   
/v/'.$id.'"><img src="http://img.youtube.com/vi/'.$id.'/0.jpg" width="400"   
height="300" class="aligncenter" /><span>Watch the video</span></a></p>';
}
    add_shortcode('youtube', 'addYouTube');

    function add_youtube_button() {
   // Don't bother doing this stuff if the current user lacks permissions
   if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') )
     return;

  // Add only in Rich Editor mode
   if ( get_user_option('rich_editing') == 'true') {
     add_filter("mce_external_plugins", "add_youtube_tinymce_plugin");
     add_filter('mce_buttons', 'register_youtube_button');
     ?>
//the problem is with this section,, i tried placing this section in init_admin() hook
// and related hooks but out of luck.   
<script type="text/javascript" src="<?php echo plugins_url();      
    ?>/brettsyoutube/js/jquery-1.9.0.min.js"></script>
  <script type="text/javascript" src="../wp-content/plugins/brettsyoutube 
/multizoom.js" />
</script>


<!-- Add fancyBox main JS and CSS files -->

<style type="text/css">
#fancy_close{
background: url("<?php echo plugins_url(); ?>/brettsyoutube/images
/fancy_buttons.png")     
repeat scroll 0 0 transparent;
float: right;
height: 34px;
 position: relative;
top: 0;
width: 37px;
z-index: 9800;
display:block;  }   
</style>

     <div id="fancydiv" style="background-color:#FFF;
    display: none;
    height: 540px;
    left: 172px;
    position: absolute;
    top: 298px;
    width: 840px;
    z-index: 999;">
    <span id="fancy_close"></span>


     <div id="myfancybox" style="margin:0; background-color:#FFF;">
<?php global $d_path; 
     $d_path= '../wp-content/plugins/brettsyoutube/';
     include('../wp-content/plugins/brettsyoutube/main.php');?>
     </div>
     <div id="nxt" style="color: red;
    display: none;
    font-size: 38px;
    font-weight: bold;
    height: 100px;
    left: 309px;
    position: absolute;
    top: 489px;
    width: 238px;">Add to post</div>
   </div>
<?php
   }
}

function register_youtube_button($buttons) {
   array_push($buttons, "|", "youryoutube");
   return $buttons;
}

// Load the TinyMCE plugin : editor_plugin.js (wp2.5)
function add_youtube_tinymce_plugin($plugin_array) {
   $plugin_array['youryoutube'] = plugins_url().'/brettsyoutube/editor_plugin.js';
   return $plugin_array;
}

function my_refresh_mce($ver) {
  $ver += 3;
  return $ver;
}

add_filter( 'tiny_mce_version', 'my_refresh_mce');
add_action('init', 'add_youtube_button');
?>
4

1 回答 1

0

在您的文件中设置WP_DEBUG,您将能够看到导致该白屏的错误。truewp-config.php

于 2013-02-13T09:28:03.610 回答