duanqiang9212
2017-10-27 18:21
浏览 28
已采纳

从函数中替换变量的值

I'm trying to modify the output of a function from a WordPress plugin (Modern Tribe's The Events Calendar). I'm attempting to use apply_filter to accomplish this, but to no avail. Here is the function I want to interact with:

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 );
}

I basically just want to manipulate the output value for $tooltip. I'm not sure if I need to utilize str_replace or parse_str, but neither have worked in the functions I've tried. If someone can help with getting $tooltip emptied out, I should be able to take it from there.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题