2

我正在尝试在我的主题的functions.php中扩展一个wordpress核心类,并且我要扩展的WP_Customize_Image_Control类来自wp-customize-control.phpwp-includes中的类。

它已经扩展了“WP_Customize_Upload_Control”。

我想允许在主题定制器中上传 .svg mime-type。

在我的主题的functions.php中,我添加了这些行:

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

但可悲的是,这打破了一切。

任何帮助,提示或提示表示赞赏。

4

1 回答 1

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”操作中

只要确保您注册的是这个而不是普通的图像控件。

于 2014-06-03T23:42:30.733 回答