I'm using a function to execute a code that sends an email with an attachment. This function is hooked on to a filter from woocommerce.
I'd like to rebuild this function to execute the code from an external php file. Is this possible in Wordpress?
The reason I want to execute it from an external script is because I want some more functionality, the sender of the email and the attachment are generated from sessions.
In my child theme's function.php-
function send_invoice ()
{
$attachments = array( WP_CONTENT_DIR . '/themes/mytheme/invoices/invoice.pdf' );
wp_mail( '[email protected]', 'Attachment test', 'The message', 'header', $attachments);
}
add_filter( 'woocommerce_email_attachments', 'send_invoice' );
Is there a way to execute a php file from my functions.php?
Further elaboration: I'm trying to convert the previous script to something like: Functions.php
function execute_send_invoice () {
send_invoice();
}
add_filter( 'woocommerce_email_attachments', 'execute_send_invoice' );
And then the code for send_invoice(); somewhere outside my functions.php, for instance, in myscript.php which is located in my template directory.
functions.php
is automatically included when the theme is active. – ಠ_ಠ Aug 26 '13 at 14:49