FortAwesome / wordpress-fontawesome

Font Awesome Official WordPress Plugin
Other
56 stars 19 forks source link

Integration problem with theme #75

Closed MatteoN81 closed 4 years ago

MatteoN81 commented 4 years ago

Hello, I have some problems with the integration of wordpress-fontawesome, via composer, in my theme. Once downloaded via composer, in the function.php file insert:

require_once __DIR__ . '/vendor/fortawesome/wordpress-fontawesome/index.php';

use function FortAwesome\fa; register_activation_hook(__FILE__, 'FortAwesome\FontAwesome_Loader::initialize');

register_deactivation_hook(__FILE__, 'FortAwesome\FontAwesome_Loader::maybe_deactivate');

register_uninstall_hook(__FILE__, 'FortAwesome\FontAwesome_Loader::maybe_uninstall');

add_action( 'font_awesome_preferences', function() { fa()->register( array( 'name' => 'test', ) ); } );

but unfortunately it doesn't load the menu item and I don't see any icon in the front end

I don't understand why. I'm not getting any errors. If I try to activate the pligin-sigma, which as an integration is identical to my theme, this problem does not arise. I display the menu item on the back-end side, and my theme is shown in the list of "Other Theme or Plugin Preferences" and in the front-end I display the test icon of both the plugin and my theme.

Thanks for all

mlwilkerson commented 4 years ago

@mattedesing Thanks for the report. You've found a bug! I had designed for the case where a plugin requires Font Awesome WordPress as a composer package, but not where a theme does so.

It has to do with the difference between what action hooks fire for plugins vs. themes. I'm working on a fix.

mlwilkerson commented 4 years ago

@mattedesing I've released 4.0.0-rc20 which I think will resolve this problem. I'd love to hear your feedback if you try it.

See the revised documentation for how to require and use the composer package in the README here. Note that the guidelines for a theme are different than those for a plugin.

Also, I've added a theme-mu integration that shows a working demo.