在functions.php中扩展wordpress核心类

在functions.php中扩展wordpress核心类,wordpress,class,extend,Wordpress,Class,Extend,我试图在我的主题的functions.php中扩展wordpress核心类,我试图扩展的类是WP\u Customize\u Image\u Controlfrom classWP Customize Control.phpinwp includes 它已经扩展了“WP_自定义_上载_控制” 我想允许在主题定制器中上载.svg mime类型 在我的主题的functions.php中,我添加了以下几行: class WP_Customize_Image_Control_SVG extends WP

我试图在我的主题的functions.php中扩展wordpress核心类,我试图扩展的类是
WP\u Customize\u Image\u Control
from class
WP Customize Control.php
inwp includes

它已经扩展了“WP_自定义_上载_控制”

我想允许在主题定制器中上载.svg mime类型

在我的主题的functions.php中,我添加了以下几行:

class WP_Customize_Image_Control_SVG extends WP_Customize_Image_Control {
      public $extensions = array( 'jpg', 'jpeg', 'gif', 'png', 'svg' );
};
但不幸的是,这破坏了一切

任何帮助、提示或提示都将不胜感激。

您就快到了

/* 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' );
        }
}
这将进入“自定义注册”操作


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

如果您描述有关您遇到的错误的更多详细信息,您可能会得到一些帮助。“这会破坏一切”并不是特别有用。