執行函數在某個網站時,下面的函數直接調用:覆寫在PHP
<div class="entry-meta">
<?php sparkling_posted_on(); ?>
功能是這樣定義:
if (! function_exists('sparkling_posted_on')) :
function sparkling_posted_on() {
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time>';
if (get_the_time('U') !== get_the_modified_time('U')) {
$time_string .= '<time class="updated" datetime="%3$s">%4$s</time>';
}
$time_string = sprintf($time_string,
esc_attr(get_the_date('c')),
esc_html(get_the_date()),
esc_attr(get_the_modified_date('c')),
esc_html(get_the_modified_date())
);
printf('<span class="posted-on"><i class="fa fa-calendar"></i> %1$s</span><span class="byline"> <i class="fa fa-user"></i> %2$s</span>',
sprintf('<a href="%1$s" rel="bookmark">%2$s</a>',
esc_url(get_permalink()),
$time_string
),
sprintf('<span class="author vcard"><a class="url fn n" href="%1$s">%2$s</a></span>',
esc_url(get_author_posts_url(get_the_author_meta('ID'))),
esc_html(get_the_author())
)
); } endif;
如何防止功能的運行,或導致它不返回任何值,也無法更改原始代碼(即只能添加更多的外部代碼)。
我嘗試使用以下,但它不會有任何影響:
add_filter('sparkling_posted_on', '__return_false', 100);
注:這是正在發生一個WordPress網站上。然而,Wordpress SE建議像SO這樣的問題,這與一般的PHP實踐相關。
我的目標是從本質上阻止此功能顯示博客帖子的元數據(作者/日期),而無法控制主題的原始代碼。
使用兒童主題覆蓋功能? –
@SebastianBrosch這是可能的,但問題仍然是需要將哪些代碼放在那裏。由於兒童主題的PHP會覆蓋它們,所以編輯出的代碼使用子主題的問題(根據我的理解)後續PHP文件的主題更新將不適用。 – Thredolsen