2013-08-07 106 views
2

我想在我的主题的functions.php中加入wordpress核心类,&我试图扩展的类是wp-includes中类wp-customize-control.phpWP_Customize_Image_Control在functions.php中扩展wordpress核心类

它已经扩展了“WP_Customize_Upload_Control”。

我想允许在主题定制程序中上传.svg mime类型。

在我的主题的functions.php的我加上几行:

class WP_Customize_Image_Control_SVG extends WP_Customize_Image_Control { 
     public $extensions = array('jpg', 'jpeg', 'gif', 'png', 'svg'); 
}; 

但遗憾的是这打破了一切。

任何帮助,提示或技巧赞赏。

+0

如果您介绍有关您遇到的错误的更多详细信息,您可能会对此有所帮助。 “这打破了一切”并不是特别有用。 – cfx

回答

1

你就近了。

/* Extend the Image Control */ 

class WP_Customize_Image_Control_SVG extends WP_Customize_Image_Control 
{ 
     public function __construct($manager, $id, $args = array()) 
     { 
       parent::__construct($manager, $id, $args); 
       $this->remove_tab('uploaded'); 
       $this->extensions = array('jpg', 'jpeg', 'gif', 'png', 'svg'); 
     } 
} 

这正好你的“customize_register”行动

内只要确保你要注册这个而不是正常的图像控制。