lightspeedwp / tour-operator

The LSX Tour Operators Plugin provides 3 post types (Accommodations, Destinations and Tours) that are the core of any Tour Operator. Use them to build day-by-day itineraries for tours.
https://lsx.design/products/tour-operator/
GNU General Public License v3.0
12 stars 0 forks source link

Core filter hooks for non-core things #53

Closed justintadlock closed 4 years ago

justintadlock commented 7 years ago

This is related to issue #50 where you're using the_content filter hook.

Right now, I'm looking over classes/class-itinerary.php and seeing this:

echo wp_kses_post(apply_filters('the_title',$tour_itinerary->itinerary['tagline']));

Using the_title here isn't going to have the same issues as the_content issue from #50. However, it could have its own problems. Note that all sorts of plugins can filter the_title and do all sorts of things. With that in mind, I wouldn't necessarily want all of those filters running over my itinerary item title.

I'd do something like:

echo wp_kses_post( apply_filters( 'lsx_to_itinerary_title', $tour_itinerary->itinerary['tagline'] ) );

Then, add the exact filters that I want, such as:

add_filter( 'lsx_to_itinerary_title', 'wptexturize'   );
add_filter( 'lsx_to_itinerary_title', 'convert_chars' );
add_filter( 'lsx_to_itinerary_title', 'trim'          );

This goes for any "core" hook that you want to use. Instead of reusing the core hook, create your own and add your own default filters to it. Plus, this makes your plugin more flexible because other plugin/theme developers could target specific hooks without affecting something like all instances of the_title, for example.

github-actions[bot] commented 4 years ago

Stale issue message