Hot answers tagged

4

The cool thing is a filter is the same as an action, only it returns a value, so just set it up as a filter instead: add_filter( 'myplugin_clean_logs', array( 'MyPlugin_Logs', 'clean_logs' ) ); Then something like: $affected_rows = ''; $affected_rows = apply_filters( 'myplugin_clean_logs', $affected_rows ); should pass $affected_rows to clean_logs() ...


2

You can call add_settings_section and add_settings_field any time before you do_settings_sections: add_action( 'my_plugin_add_settings_sections', function() { wp_remote_get( ... ); add_settings_section( ... ); add_settings_field( ... ); }); // On the plugin settings page output do_action( 'my_plugin_add_settings_sections' ); ...


1

I think a better implementation would be a "message" class e.g.: class WPSE_224485_Message { private $_message; function __construct( $message ) { $this->_message = $message; add_action( 'admin_notices', array( $this, 'render' ) ); } function render() { printf( '<div class="updated">%s</div>', ...



Only top voted, non community-wiki answers of a minimum length are eligible