Knu*_*han 1 php wordpress plugins class function
我正在使用一个名为Lightweight Social Icons的插件,我想添加自己的自定义图标,而无需编辑父插件.
这是父插件的片段:
class lsi_Widget extends WP_Widget {
... (class functions are in here)
}
function lsi_icons( $options = '' ) {
$options = array (
'email' => array(
'id' => 'email',
'name' => __( 'Contact', 'lightweight-social-icons' )
),
'delicious' => array(
'id' => 'delicious',
'name' => __( 'Delicious', 'lightweight-social-icons' )
),
'deviantart' => array(
'id' => 'deviantart',
'name' => __( 'DeviantArt', 'lightweight-social-icons' )
),
'digg' => array(
'id' => 'digg',
'name' => __( 'Digg', 'lightweight-social-icons' )
),
'facebook' => array(
'id' => 'facebook',
'name' => __( 'Facebook', 'lightweight-social-icons' )
),
);
return apply_filters( 'lsi_icons_defaults', $options );
}
Run Code Online (Sandbox Code Playgroud)
我想编辑该lsi_icons()功能,以便我可以添加自己的图标,但它不在lsi_Widget课堂上.我有一个带有functions.php文件的子主题,我用它来使用动作和钩子对其他插件进行更改,但是,我不知道如何对此插件执行相同操作,因为我要修改的函数不在类.我一直在寻找一种创建"儿童插件"的方法,就像你做儿童主题一样,但我似乎无法找到如何做到这一点的明确答案.那么还有其他方法可以做我想做的事情吗?
链接到LSI插件Github页面:https://github.com/tomusborne/lightweight-social-icons
没关系,过滤器位于何处.您可以从functions.php主题/子主题的文件中访问它.
这是代码:
function ww_change_lsi_icons($options){
//here you can see all icons added. Add, delete, change them through $options variable
return $options;
}
add_filter( 'lsi_icons_defaults', 'ww_change_lsi_icons' );
Run Code Online (Sandbox Code Playgroud)