Skip to content

Scope global WordPress hooks to Feedzy-imported posts only #1191

@ineagu

Description

@ineagu

Problem

Feedzy hooks into several global WordPress filters (post_thumbnail_html, has_post_thumbnail, wp_get_attachment_image_src, admin_footer, wp_targeted_link_rel) without scoping them to Feedzy post types. This causes interference with other plugins — e.g., Slider Hero's images get hijacked when wp_get_attachment_image_src fires on posts with $attachment_id === 0, and modals/JS intended for Feedzy admin pages load on every admin screen.

Root Cause

Functions in feedzy-rss-feeds-feed-tweaks.php and feedzy-rss-feeds-admin.php fire on ALL posts/pages, not just Feedzy-imported ones. The wp_targeted_link_rel filter in feedzy-rss-feeds-actions.php uses an anonymous closure that leaks after import jobs complete.

Solution

feed-tweaks.php — Add get_post_meta($post_id, 'feedzy', true) guard to:

  • feedzy_display_external_post_image() — early return if not Feedzy post
  • feedzy_enable_external_url_support() — early return if not Feedzy post
  • feedzy_get_attachment_image_src() — nest external URL logic inside Feedzy meta check

admin.php — Add get_current_screen() check to add_modals(), only fire on feedzy_categories and feedzy_imports post types.

actions.php — Capture wp_targeted_link_rel callback reference, apply filter, save HTML result, remove_filter() immediately after, then return.

Files Affected

  • includes/feedzy-rss-feeds-feed-tweaks.php
  • includes/admin/feedzy-rss-feeds-admin.php
  • includes/admin/feedzy-rss-feeds-actions.php

Acceptance Criteria

  • Non-Feedzy posts with $attachment_id === 0 are not affected by feedzy_get_attachment_image_src
  • has_post_thumbnail returns unchanged value for non-Feedzy posts
  • Feedzy modals/JS do not load on non-Feedzy admin screens
  • wp_targeted_link_rel filter is removed after each import job HTML save
  • Feedzy-imported posts continue to display external thumbnails correctly

Priority: High — compatibility fix, prevents cross-plugin interference
Regression risk: Isolated (guards are early-return only)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions