2013-05-16 28 views
-1

我想在Wordpress主題定製器中擴展背景圖像控件。我一直試圖讓這個代碼的權利,現在,我想這應該是工作,我對這個函數接收一個意外T_Public:意外的T_Public功能。

public function tab_builtins() { 

我試圖去除掉它前面的公開聲明,儘管這將創建一個新問題:意想不到的t_function

我一直在尋找這個代碼很長一段時間試圖改變小事情,但問題依然存在。誰能幫我嗎?

這裏是有問題的全碼:

function WP_Customize_Background_Image_Control_Defaults($wp_customize) { 

/* Substitute the default control for our new one */ 
    $wp_customize->remove_control('background_image'); 
    $wp_customize->add_control(new WP_Customize_Background_Image_Control_Defaults($wp_customize)); 

class WP_Customize_Background_Image_Control_Defaults extends WP_Customize_Background_Image_Control { 
    public function __construct($manager) { 

     $this->add_tab('builtins', __('Built-ins'), array($this, 'tab_builtins')); 


    public function tab_builtins() { 

    $backgrounds = array(

      '/wp-content/themes/newtheme/img/backgrounds/background1.jpg', '/wp-content/themes/newtheme/img/backgrounds/background2.jpg', '/wp-content/themes/newtheme/img/backgrounds/background3.jpg', '/wp-content/themes/newtheme/img/backgrounds/background4.jpg', '/wp-content/themes/newtheme/img/backgrounds/background5.jpg' 

     ); 

      if (empty($backgrounds)) 
          return; 

        foreach ((array) $backgrounds as $background) 
         $this->print_tab_image(esc_url_raw($background->guid)); 



    } 
    } 

} 

} 

add_action('customize_register', 'wp_customize_background_image_control_defaults', 11, 1); 
+0

類的功能.. ?爲什麼你需要這樣做? –

+0

未正確關閉方法 – BlitZ

回答

2

你已經錯過了結束花括號右側前public function tab_builtins()

把它關閉您__construct定義正確

+0

啊,謝謝。我專注於底部,並有一個單一的思路。 – user1632018