Php 替换函数中变量的值
我正在尝试修改WordPress插件(现代部落的事件日历)的函数输出。我正试图使用Php 替换函数中变量的值,php,wordpress,Php,Wordpress,我正在尝试修改WordPress插件(现代部落的事件日历)的函数输出。我正试图使用apply\u filter来完成这项工作,但没有效果。以下是我想要与之交互的函数: function tribe_events_recurrence_tooltip( $post_id = null ) { if ( empty( $post_id ) ) { $post_id = get_the_ID(); } $tooltip = ''; if ( tribe_is_recurring
apply\u filter
来完成这项工作,但没有效果。以下是我想要与之交互的函数:
function tribe_events_recurrence_tooltip( $post_id = null ) {
if ( empty( $post_id ) ) {
$post_id = get_the_ID();
}
$tooltip = '';
if ( tribe_is_recurring_event( $post_id ) ) {
$tooltip .= '<div class="recurringinfo">';
$tooltip .= '<div class="event-is-recurring">';
$tooltip .= '<span class="tribe-events-divider">|</span>';
$tooltip .= sprintf( __( 'Recurring %s', 'tribe-events-calendar-pro' ), tribe_get_event_label_singular() );
$tooltip .= sprintf( ' <a href="%s">%s</a>',
esc_url( tribe_all_occurences_link( $post_id, false ) ),
__( '(See all)', 'tribe-events-calendar-pro' )
);
$tooltip .= '<div id="tribe-events-tooltip-'. $post_id .'" class="tribe-events-tooltip recurring-info-tooltip">';
$tooltip .= '<div class="tribe-events-event-body">';
$tooltip .= tribe_get_recurrence_text( $post_id );
$tooltip .= '</div>';
$tooltip .= '<span class="tribe-events-arrow"></span>';
$tooltip .= '</div>';
$tooltip .= '</div>';
$tooltip .= '</div>';
}
if ( has_filter( 'tribe_events_event_recurring_info_tooltip' ) ) {
_deprecated_function( "The 'tribe_get_related_events' filter", '3.9', " the 'tribe_events_recurrence_tooltip' filter" );
$tooltip = apply_filters( 'tribe_events_event_recurring_info_tooltip', $tooltip ); // for backwards-compat, will be removed
}
return apply_filters( 'tribe_events_recurrence_tooltip', $tooltip );
}
function-tribe\u-events\u-recurrence\u工具提示($post\u-id=null){
if(空($post_id)){
$post_id=获取_id();
}
$tooltip='';
如果(部落是重复发生的事件($post\u id)){
$tooltip.='';
$tooltip.='';
$tooltip.='|';
$tooltip.=sprintf(uuuuu('recurtive%s','tribe events calendar pro'),tribe_get_event_label_singular());
$tooltip.=sprintf(“”,
esc_url(部落所有事件链接($post_id,false)),
__(“(请参阅全部)”“部落活动日历专业版”)
);
$tooltip.='';
$tooltip.='';
$tooltip.=tribe\u get\u recurrence\u text($post\u id);
$tooltip.='';
$tooltip.='';
$tooltip.='';
$tooltip.='';
$tooltip.='';
}
如果(有过滤器('tribe\u events\u event\u Recurrence\u info\u tooltip')){
_不推荐使用的_函数(“tribe_get_related_events”过滤器、“3.9”过滤器、“tribe_events_recurrence_tooltip”过滤器”);
$tooltip=apply_过滤器('tribe_events_event_Recurrency_info_tooltip',$tooltip);//对于向后兼容,将被删除
}
返回应用过滤器('tribe\u events\u recurrence\u tooltip',$tooltip);
}
我基本上只想操纵
$tooltip
的输出值。我不确定是否需要使用str\u replace
或parse\u str
,但我尝试过的函数都无法使用。如果有人能帮我清空$tooltip
,我应该可以从那里得到它。使用apply\u filter
时,我本应该使用add\u filter
来钩住函数(我是新手)。下面是我如何修改函数,使值为空,然后我可以插入任何我想要的值:
add_filter( 'tribe_events_recurrence_tooltip',
'my_function');
function my_function($tooltip) {
$tooltip = null;
return $tooltip;
}
我想其他人可能会搜索这个并找到有用的答案