Skip to content

Fix the two faults behind the broken demo: WP_Error terms and the Font Awesome handle collision - #348

Merged
puikinsh merged 4 commits into
masterfrom
fix/related-posts-wp-error
Aug 11, 2026
Merged

Fix the two faults behind the broken demo: WP_Error terms and the Font Awesome handle collision#348
puikinsh merged 4 commits into
masterfrom
fix/related-posts-wp-error

Conversation

@puikinsh

Copy link
Copy Markdown
Member

Found while diagnosing the fatal on https://colorlibhub.com/shapely/ (fixed in shapely-companion #42). The theme has the same unguarded pattern.

wp_get_object_terms() returns a WP_Error when the taxonomy is not registered — the case whenever whatever supplied the portfolio post type is deactivated while its posts remain. ! empty() is true for an object, so the WP_Error was pushed straight into tax_query:

$types = wp_get_object_terms( get_the_ID(), 'jetpack-portfolio-type', $terms_args );
if ( ! empty( $types ) ) {                    // true for WP_Error
    array_push( $tax_query, array( 'terms' => $types, ... ) );
}

Not fatal here — unlike the plugin's Portfolio widget, which passed the WP_Error to implode() and raised a TypeError that truncated the page. The consequence is quieter: WP_Query receives a malformed tax_query and returns the wrong related posts instead of none.

Both wp_get_object_terms() calls are now checked with is_wp_error(). After this, all four term lookups across the theme are guarded (archive-jetpack-portfolio.php already was).

Verified: php -l clean across 85 files, front-end sweep shows all pages complete with 0 PHP notices and 0 JS errors.

🤖 Generated with Claude Code

puikinsh and others added 2 commits August 11, 2026 10:18
wp_get_object_terms() returns a WP_Error when the taxonomy is not registered,
which happens whenever whatever supplied the portfolio post type is
deactivated while its posts remain. ! empty() is true for an object, so the
WP_Error was pushed straight into tax_query and WP_Query then returned the
wrong related posts rather than none.

Not fatal here -- unlike the same pattern in the companion plugin's Portfolio
widget, which raised a TypeError in implode() and truncated the page -- but
wrong in the same way and worth closing off.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
WordPress deduplicates enqueues by handle: whichever caller registers a handle
first wins, and every later enqueue of the same handle is silently a no-op.
The theme registered its Font Awesome 6 as plain 'font-awesome', which is the
same handle Elementor uses for the Font Awesome 4.7 it bundles.

On any site running Elementor -- including the official demo -- Elementor
registers first, so the theme's Font Awesome 6 never loaded. The theme then
rendered fa-brands / fa-solid / fa-x-twitter / fa-mobile-screen against
Font Awesome 4, where none of those classes exist, and the social, search and
menu icons came out as blank boxes.

Verified on the demo's markup:

  id='font-awesome-css' href='.../elementor/.../font-awesome.min.css?ver=4.7.0'

and the theme's own fontawesome6/all.min.css absent from the page entirely
while every other theme stylesheet loaded normally.

Renaming to 'shapely-font-awesome' means the theme always gets the version its
markup is written against, whatever plugins are installed.

Note for child themes: anything calling wp_dequeue_style( 'font-awesome' ) to
swap the icon set now needs the new handle. The theme's other generic handles
('bootstrap', 'flexslider', 'owl.carousel') carry the same collision risk but
are left alone here -- they are not currently broken anywhere, and renaming
them would break dequeues for no present benefit.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@puikinsh puikinsh changed the title Guard the related-posts term lookups against WP_Error Fix the two faults behind the broken demo: WP_Error terms and the Font Awesome handle collision Aug 11, 2026
puikinsh and others added 2 commits August 11, 2026 10:23
… collision

The Epsilon framework enqueues Font Awesome for the customizer screens with

    wp_enqueue_style( 'font-awesome', EPSILON_URI . '../../assets/css/...' );

which is wrong twice over.

EPSILON_URI is already trailingslashit'd to

    .../themes/shapely/inc/libraries/epsilon-framework/

so '../../' climbs to .../themes/shapely/inc/ -- one level short of the theme
root. The resulting .../shapely/inc/assets/css/fontawesome6/all.min.css does
not exist and never has, so the customizer has been 404ing on its own icon
font. Confirmed against the working tree: the old path resolves to a file that
is not there, the new one to the real 102 KB stylesheet.

It also reuses the generic 'font-awesome' handle, so on any site where a plugin
registers that handle first the enqueue is a silent no-op regardless of path.

Now points at get_template_directory_uri() and shares the theme's
'shapely-font-awesome' handle, so the admin and front end load one file, once,
with a real version string for cache busting.

This library is vendored rather than a submodule, so it is patched in place --
same as the two existing PHP-compatibility patches in inc/libraries/.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Same failure as the companion plugin's CI: phpcodesniffer-composer-installer is
a Composer plugin, and current Composer refuses to execute plugins that are not
explicitly allow-listed. The require aborted with "contains a Composer plugin
which is blocked by your allow-plugins config" before PHPCS was installed, so
the coding-standards job had been failing on infrastructure rather than on
anything in the theme.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@puikinsh
puikinsh merged commit 77d8dc9 into master Aug 11, 2026
10 checks passed
@puikinsh
puikinsh deleted the fix/related-posts-wp-error branch August 11, 2026 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant