我试图覆盖子主题中某个主题的函数,但无法使其正常工作。在functions.php
在这个主题上我可以看到require_once
生产线:
require_once("inc/alterna-functions.php");
我想重写该文件中的一个函数。我刚从
alterna/functions.php
到
alterna-child/functions.php
并做了如下更改:
if (!function_exists(\'alterna_get_social_list\')) :
function alterna_get_social_list($extra_name = \'\', $topbar = false, $data = null, $target = \'_blank\')
{
global $alterna_options;
$str = "";
$social_list = array(
array(\'twitter\', \'Twitter\'),
array(\'twitter_1\', \'Twitter #1\'), // this is new
array(\'twitter_2\', \'Twitter #2\'), // this is new
array(\'twitter_3\', \'Twitter #3\'), // this is new
array(\'twitter_4\', \'Twitter #4\'), // this is new
array(\'facebook\', \'Facebook\'),
array(\'facebook_1\', \'Facebook #1\'), // this is new
array(\'facebook_2\', \'Facebook #2\'), // this is new
array(\'facebook_3\', \'Facebook #3\'), // this is new
array(\'facebook_4\', \'Facebook #4\'), // this is new
array(\'google\', \'Google Plus\', \'google-plus\'),
array(\'google_1\', \'Google Plus #1\', \'google-plus_1\'), // this is new
array(\'google_2\', \'Google Plus #2\', \'google-plus_2\'), // this is new
array(\'google_3\', \'Google Plus #3\', \'google-plus_3\'), // this is new
array(\'google_4\', \'Google Plus #4\', \'google-plus_4\'), // this is new
array(\'youtube\', \'Youtube\'),
array(\'linkedin\', \'Linkedin\'),
array(\'instagram\', \'instagram\'),
array(\'whatsapp\', \'Whatsapp\'),
array(\'email\', \'Email\', \'envelope\'),
array(\'rss\', \'Rss\')
);
if ($data != null) {
foreach ($social_list as $social_item) {
if (isset($data[\'type\']) && $data[\'type\'] == $social_item[0]) {
if (!isset($data[\'url\'])) {
$data[\'url\'] = \'#\';
}
if (!isset($data[\'target\'])) {
$data[\'target\'] = \'_blank\';
}
$str .= \'<li class="social"><a href="\' . esc_attr($data[\'url\']) . \'" target="\' . esc_attr($data[\'target\']) . \'"\';
if (isset($data[\'tooltip\']) && $data[\'tooltip\'] == "yes") {
$str .= \' title="\' . esc_attr($social_item[1]) . \'" class="show-tooltip"\';
if (isset($data[\'placement\']) && $data[\'placement\'] != "") {
$str .= \' data-placement="\' . esc_attr($data[\'placement\']) . \'"\';
}
}
$str .= \'><span class="alterna-icon-\' . esc_attr($social_item[0]) . \'"\';
if ($data[\'bg_color\'] != "" || $data[\'color\'] != "") {
$str .= \' style="\';
if ($data[\'bg_color\'] != "") {
$str .= \'background:\' . esc_attr($data[\'bg_color\']) . \';\';
}
if ($data[\'color\'] != "") {
$str .= \'color:\' . esc_attr($data[\'color\']) . \';\';
}
$str .= \'"\';
}
$str .= \'><i class="fa fa-\' . (isset($social_item[2]) ? esc_attr($social_item[2]) : esc_attr($social_item[0])) . \'"></i></span></a></li>\';
}
}
} else {
foreach ($social_list as $social_item) {
if (penguin_get_options_key(\'social-\' . $social_item[0]) != \'\') {
if (!$topbar) {
$str .= \'<li class="social"><a title="\' . esc_attr($social_item[1]) . \'" href="\' . esc_attr(penguin_get_options_key(\'social-\' . $social_item[0])) . \'" target="\' . esc_attr($target) . \'" ><span class="alterna-icon-\' . esc_attr($social_item[0]) . \'"><i class="fa fa-\' . (isset($social_item[2]) ? esc_attr($social_item[2]) : esc_attr($social_item[0])) . \'"></i></span></a></li>\';
} else {
$str .= \'<li class="social"><a href="\' . esc_attr(penguin_get_options_key(\'social-\' . $social_item[0])) . \'" target="\' . esc_attr($target) . \'" ><i class="fa fa-\' . (isset($social_item[2]) ? esc_attr($social_item[2]) : esc_attr($social_item[0])) . \'"></i></a></li>\';
}
}
}
}
return $str;
}
endif;
但它不起作用,因为我看不到主题的变化。我做错了什么?实现这一目标的正确方法是什么?