2014-03-28 24 views
0

上的插件沒有有效的頭我創建了一個插件,由於某種原因,當我嘗試上傳,並通過拉鍊激活它。我收到消息「無效的頭文件」。如果我只是通過FTP下載文件夾,它似乎沒問題。有什麼建議麼?在WordPress

這裏是插件的主要文件:

<?php 
/* 
* Plugin Name: Album Gallery 
* Plugin URI: http://vinteractive.co.uk 
* Description: An Album based Slider Gallery. 
* Version: 1.0 
* Author: Vincent Stephens 
* Author URI: http://vinteractive.co.uk 
* License: Do Not Redistribute 
*/ 

define('ALBUM_GALLERY_URL', plugins_url() . '/album-gallery/'); 
define('ALBUM_GALLERY_ABSPATH', ABSPATH . 'wp-content/plugins/album-gallery/'); 

define('ACF_LITE' , true); 
include(ALBUM_GALLERY_ABSPATH . 'custom-fields/acf.php'); 
include(ALBUM_GALLERY_ABSPATH . 'custom-fields/album-fields.php'); 
include(ALBUM_GALLERY_ABSPATH . 'custom-post-types/albums-gallery-post-type.php'); 
include(ALBUM_GALLERY_ABSPATH . 'shortcodes/shortcodes.php'); 


// Enque Scripts and styles 
function album_gallery_scripts() { 
wp_register_script('jquery-for-nivo', plugins_url('/js/jquery-1.9.0.min.js', __FILE__), array('jquery'),'1.1', true); 
wp_enqueue_script('jquery-for-nivo'); 
wp_register_script('nivo-slider', plugins_url('/nivo/scripts/jquery.nivo.slider.js', __FILE__), array('jquery'),'1.1', true); 
wp_enqueue_script('nivo-slider'); 
wp_register_script('album-gallery-script', plugins_url('/js/album-gallery.jquery.js', __FILE__), array('jquery'),'1.1', true); 
wp_enqueue_script('album-gallery-script'); 

wp_register_style('album-gallery', plugins_url('/css/album-gallery.css', __FILE__)); 
wp_enqueue_style('album-gallery'); 
wp_register_style('nivo-slider', plugins_url('/nivo/nivo-slider.css', __FILE__)); 
wp_enqueue_style('nivo-slider'); 
wp_register_style('style', plugins_url('/nivo/style.css', __FILE__)); 
wp_enqueue_style('style'); 

// Nivo Theme 
wp_register_style('theme-default', plugins_url('/nivo/themes/default/default.css', __FILE__)); 
wp_enqueue_style('theme-default'); 
} 

add_action('wp_enqueue_scripts', 'album_gallery_scripts'); 


?> 

短代碼文件:

<?php 
    function album_gallery_shortcode() { 
?> 
     <span class="info_btn"></span> 

     <?php 
     // Loop for Album Gallery Post Type 
      $args = array(
       'post_type'   => 'albums_gallery', 
      ); 

      $loop = new WP_Query($args); 
      while ($loop->have_posts()) : $loop->the_post(); 

      $album_name = get_the_ID(); 
      $album_description = get_field('album_description'); 

     ?> 

     <div class="album album_<?php echo $album_name ?>"> 

     <?php for ($i = 0; $i <= 0; $i++) { ?> 
      <div class="description album_<?php echo $album_name ?>"> 
       <?php echo $album_description; ?> 
      </div> 
     <?php } ?> 

      <div class="slider-wrapper theme-default"> 
       <div class="slider" class="nivoSlider"> 

        <?php 

        $images = Array(); 
        for($i = 1; $i <= 6; $i++) { 
         $image = get_field("image_{$i}"); 
         if(!$image || !$image['url']) { 
          break; 
         } 
         $caption = get_field("image_{$i}_caption"); 
         ?> 

         <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" title="<?php echo $caption; ?>" /> 

        <?php } ?> 

       </div> 
      </div> 
     </div> 
     <!-- End Album --> 

     <?php endwhile; wp_reset_query(); ?> 
     <!-- // Loop for Album Gallery Post Type --> 

     <div class="thumbnails"> 
     <?php 

      $args = array(
       'taxonomy_albums' => '', 
       'post_type'   => 'albums_gallery', 
      ); 

      $loop = new WP_Query($args); 
      while ($loop->have_posts()) : $loop->the_post(); 

      // album name becomes post id 
      $album_name = get_the_id(); 
      $album_thumb = get_field('thumbnail'); 
      $album_caption = get_field('album_caption'); 

      if(!empty($album_thumb)): ?> 

       <div class="thumbs" style="width: 130px; float: left; margin: 5px;"> 
        <img class="thumb thumb_album_<?php echo $album_name; ?>" src="<?php echo $album_thumb['url']; ?>" alt="<?php echo $album_thumb['alt']; ?>" width="130" /> 
        <p class="title"><?php the_title(); ?></p> 
        <p class="caption"><?php echo $album_caption ?></p> 
       </div> 

     <?php endif; ?> 
     <?php endwhile; wp_reset_query(); ?> 

    </div> 
    <!-- end thumbnails --> 


<?php 

    } 
    add_shortcode('album-gallery', 'album_gallery_shortcode'); 
?> 
+0

無視以前的評論...你是如何創建ZIP?它只能是'/ plugin-folder/all-files。*'。 – brasofilo

+0

文件結構是: 專輯畫廊 -CSS -custom場 -custom-後類型 -images -js -nivo -shortcodes 我創建與上下文菜單中的取景器旗牌'compress' – vincentieo

+1

在專用應用程序中打開zip並確認結構。或者如果你想發佈一個zip文件,我可以查看它。 – brasofilo

回答

1

我懷疑它有事情做與高級定製文章插件,您包括您的插件。我有一個類似的問題,我通過移動acf文件夾來解決它。含義,而不是myplugin/advanced-custom-fields我把它放在myplugin/inc/advanced-custom-fields

和它的工作。

當然,不要忘了在你的插件的主要文件的路徑更改爲

include(ALBUM_GALLERY_ABSPATH . 'inc/custom-fields/acf.php'); 

BTW,我更願意把這樣的插件:

if(!class_exists('Acf')) 
{ 
    define('ACF_LITE' , true); // Hide it from admin 
    include_once('inc/advanced-custom-fields/acf.php'); 
} 

因爲你不」如果用戶已經安裝了它,你希望你的用戶再次加載它。

+0

是的,多數民衆贊成在多麼... ... :) – vincentieo

0

我在一個插件包括ACF時,也有類似的問題,我花了永遠的數字出來,尤其是因爲我每次我創建一個新的插件時下降一個插件頭模板以同樣的方式。

問題從包括acf.php插件頭莖。從該文件中刪除wordpress註釋標題,並且它似乎安裝得很好,無論您將其包含在哪個目錄級別。