Skip to main content
added 488 characters in body
Source Link
scribu
  • 13.2k
  • 38
  • 49

That would not work. Just because a callback is registered to a hook doesn't mean that the hook will be triggered when expected. The only thing that would sort-of-kind-of work is using the 'shutdown' hook, which you mentioned before:

add_action( 'shutdown', function() {
  if ( !did_action( 'template_tag_like_hook' ) )
    echo 'Problem.';
} );

Of course, this would be printed at the very bottom, after the </html> tag, on the front-end (since that's where template tags are normally used), which is not of much use.

You could try to store the message in wp_options and then display it in the admin area, but that would open a whole new can of worms: invalidation, caching plugins etc.


That would not work. Just because a callback is registered to a hook doesn't mean that the hook will be triggered when expected. The only thing that would sort-of-kind-of work is using the 'shutdown' hook, which you mentioned before:

add_action( 'shutdown', function() {
  if ( !did_action( 'template_tag_like_hook' ) )
    echo 'Problem.';
} );

Of course, this would be printed at the very bottom, after the </html> tag, on the front-end (since that's where template tags are normally used), which is not of much use.

You could try to store the message in wp_options and then display it in the admin area, but that would open a whole new can of worms: invalidation, caching plugins etc.

added 750 characters in body
Source Link
kaiser
  • 50.8k
  • 27
  • 150
  • 244

Using hooks would works well for 'normal' and 'weak' dependencies. The only drawback is that you would still need to use function_exists() or is_plugin_active() if you want to stop if the dependency is not met. Using the 'all' filter for that would be too expensive IMO.

Using hooks would works well for 'normal'@scibu This was targeted at "your" topic. (I already dropped talking about mine). :)

So basically, if you need a dependency - and 'weak' dependenciesyou have a nice author - then he could offer a hook instead/as replacement for a template tag. TheBecause the plugin would only drawback is that youhook into it if the hook would stillbe present, or simply do nothing. And on the other side you wouldn't have an error, when the plugins not present.

Here's the tough part (or more of a Q): To write an admin notice to inform the user about the dependancy "You need to use function_exists() orinstall »DisneyWonderLinks«", you could check the is_plugin_activearray_keys( $GLOBALS['wp_filter']['template_tag_like_hook'] ) if you want to stop if the dependency is not met. Using the 'all' filter for thatI'm not sure if this would work, but afaik the array should be too expensive IMOaccessible on both (public/admin) sides.

Using hooks would works well for 'normal' and 'weak' dependencies. The only drawback is that you would still need to use function_exists() or is_plugin_active() if you want to stop if the dependency is not met. Using the 'all' filter for that would be too expensive IMO.

Using hooks would works well for 'normal' and 'weak' dependencies. The only drawback is that you would still need to use function_exists() or is_plugin_active() if you want to stop if the dependency is not met. Using the 'all' filter for that would be too expensive IMO.

@scibu This was targeted at "your" topic. (I already dropped talking about mine). :)

So basically, if you need a dependency - and you have a nice author - then he could offer a hook instead/as replacement for a template tag. Because the plugin would only hook into it if the hook would be present, or simply do nothing. And on the other side you wouldn't have an error, when the plugins not present.

Here's the tough part (or more of a Q): To write an admin notice to inform the user about the dependancy "You need to install »DisneyWonderLinks«", you could check the array_keys( $GLOBALS['wp_filter']['template_tag_like_hook'] ). I'm not sure if this would work, but afaik the array should be accessible on both (public/admin) sides.

added 284 characters in body
Source Link
scribu
  • 13.2k
  • 38
  • 49

Using hooks would works well for 'normal' and 'weak' dependencies. The only drawback is that you would still need to use function_exists() or is_plugin_active() if you want to stop if the dependency is not met. Using the 'all' filter for that would be too expensive IMO.


Using hooks would works well for 'normal' and 'weak' dependencies. The only drawback is that you would still need to use function_exists() or is_plugin_active() if you want to stop if the dependency is not met. Using the 'all' filter for that would be too expensive IMO.

added 554 characters in body
Source Link
kaiser
  • 50.8k
  • 27
  • 150
  • 244
Loading
edited body
Source Link
scribu
  • 13.2k
  • 38
  • 49
Loading
added 570 characters in body
Source Link
scribu
  • 13.2k
  • 38
  • 49
Loading
Source Link
kaiser
  • 50.8k
  • 27
  • 150
  • 244
Loading