shinerweb
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: [Plugin: wp mail from] Breaks Contact Form 7Funnily enough, the author of Contact Form 7 is not showing much interest in changing their code to use the add_filter() and priorities.
Because wp-mailfrom uses a higher priority (than whatever default is set by Contact Form 7), it breaks the use of Contact Form 7.
The CF7 plugin developer doesn’t seem to think he needs to change his plugin to make another plugin work. (He doesn’t see it as ‘his’ plugin isn’t as ‘plugin friendly’ as it could be).
I just have to work out how to word my request without offending him.
Forum: Fixing WordPress
In reply to: [Plugin: Contact Form 7] email address not working at all…..Did that solve your problem, or are you using another plugin such as “WP Mail From” ?
Forum: Plugins
In reply to: WP Mail From breaks Contact Form 7But since WordPress 1.5.1+ you should (and) have been using the add_filter function to change the value of wp_mail_from and wp_mail_from_name
This allows your plugin to safely interact with other plugins that may also alter the same variable(s).
Like so:
add_filter(‘wp_mail_from’,’site_mail_from’,x);
add_filter(‘wp_mail_from_name’,’site_mail_from_name’,x);where x is the priority.
The 3rd parameter is the priority. This is important as it allows the interaction with other plugins.
see:
http://phpdoc.wordpress.org/trunk/WordPress/Plugin/_wp-includes—plugin.php.html#functionadd_filterBecause your plugin uses wp_mail, you are therefore using wp_mail_from and wp_mail_from_name, so you should really use the methods which allow the rest of the system to use it too.
What you are doing at the moment is in fact over riding the default system settings when you call wp_mail ignoring any other ‘modules’By ignoring the priority of the other parts of the system, I’d argue it’s your plugin at fault.
See wp_mail info at http://phpdoc.wordpress.org/trunk/WordPress/_wp-includes—pluggable.php.html#functionwp_mail
Note:
uses: apply_filters() – Calls ‘wp_mail_from’ hook to get the from email address.
uses: apply_filters() – Calls ‘wp_mail_from_name’ hook to get the from address name.
You already do call apply_filters:extract( apply_filters( ‘wpcf7_mail_components’,
compact( ‘subject’, ‘sender’, ‘body’, ‘recipient’, ‘additional_headers’ ) ) );But you are not allowing the changing of the priority.
This means your plugin isn’t compatible with other plugins that also change those variables.
At the moment, because you don’t set the priority, it defaults to ‘0’
This means that what ever you set it to using apply_filters is then overridden by other plugins.As for making it more complicated, all you need to do is have a default priority >1 and perhaps allow users to change it via settings if required.