/** * Grabs an email message template and merges it with any variables you pass. Use this for * any emails you want to send through Tina MVC. Templates are like normal Tina MVC view files except * they are named *_email.php. * * The templates are stored in the user or Tina MVC 'pages', 'shortcodes' and 'widgets' folders * (just like controllers, views and models). * * Variables are extract() ed into the local scope of the message template. $to, $cc, $bcc and $subject will * also be added to that scope. Beware: this will overwrite variables of the same name passed through * $message_variables. * * You can also send an email without using a template by passing the content of your email as a string to * $message_variables and leaving $message_template FALSE. * * @param mixed $to The recipients address (array or string) * @param mixed $cc * @param mixed $bcc * @param string $subject * @param string $message_template Template to use (without the '_email.php') * @param array $message_variables Data to be merged into the message (usually array or object ) * @todo sending attachments * @return boolean */ function mail($to = FALSE, $cc = FALSE, $bcc = FALSE, $subject, $message_template = FALSE, $message_variables = array()) { if (!$to or is_string($to) and !is_email($to)) { return FALSE; } $headers = array(); $headers[] = 'From: ' . get_mailer_from_address(); // make sure the to, cc, bcc and subject data is included in the message variables $message_variables['to'] = $to; $message_variables['cc'] = $cc; $message_variables['bcc'] = $bcc; $message_variables['subject'] = $subject; if ($message_template) { $search_errors = array(); $tpl_file = find_app_file($message_template . '_email.php', $this->tina_mvc_page, $this->called_from, $search_errors); if (!$tpl_file) { // if we get here we've an error $e = "Can't find email file:\r\n"; $e .= "<small><pre>" . $tpl_file . "</pre></small>\r\n"; $e .= "Looked in:\r\n"; $e .= "<small><pre>"; foreach ($search_errors as $d) { $e .= str_replace(plugin_folder(), '', $d) . "\r\n"; } $e .= "</pre></small>\r\n"; error($e, $suppress_esc = TRUE); } else { $email_body = $this->parse_view_file($tpl_file, $message_variables, FALSE); } } elseif (is_string($message_variables)) { $email_body = $message_variables; } else { // $message_variables is not a string and no template file passed to us error('$message_variables must be a string if $message_template is FALSE.'); } if ($cc) { if (is_array($cc)) { foreach ($cc as $email) { $headers[] = 'Cc: ' . $email; } } else { $headers[] = 'Cc: ' . $cc; } } if ($bcc) { if (is_array($bcc)) { foreach ($bcc as $email) { $headers[] = 'Bcc: ' . $email; } } else { $headers[] = 'Bcc: ' . $bcc; } } return wp_mail($to, $subject, $email_body, $headers, $attachments = FALSE); }
?> </th> <td> <input type="text" name="feed-stats-entries" id="feed-stats-entries" class="fs-text" value="<?php $q = get_option('feedburner_feed_stats_entries'); echo $q !== '' && $q !== false ? $q : 10; ?> " /> </td> </tr> </table> <p class="fs-icons-credit"> <?php _e('Icons by', 'feed-stats-plugin'); ?> <a href="http://www.famfamfam.com/">FamFamFam</a>. </p> <p class="submit"> <input type="submit" name="submit" id="submit" class="button-primary" value="<?php _e('Save Changes', 'feed-stats-plugin'); ?> " /> </p> <p class="feed-stats-clear"></p> </form> <script type="text/javascript" src="<?php plugin_folder(); ?> js/test.js"></script>
/** * Searches for a file in the standard Tina MVC application folders * * In case of error the locations we looked in are stored in $find_app_file_error for * use in an error message later. * * @param string $filename * @param string $tina_mvc_page the page the controller is accessed through * @param string $called_from PAGE_FILTER, WIDGET, SHORTCODE, CALLABLE_CONTROLLER * @param array $find_app_file_error contains a list of places searched (for use in case of error) * @return mixed FALSE or the full path and filename to the file to be included */ function find_app_file($filename = '', $tina_mvc_page = '', $called_from = 'PAGE_FILTER', &$find_app_file_error) { $find_app_file_error = array(); $looked_for = array(); if ($called_from == 'PAGE_FILTER') { // this is left empty if a custom folder location is used if ($tina_mvc_page) { $page_folder = $tina_mvc_page . '/'; } /** * Is demo mode enabled? */ if (get_tina_mvc_setting('demo_mode')) { if (file_exists($f = plugin_folder() . "/demo/pages/tina_mvc_demo_and_docs/{$filename}")) { return $f; } $looked_for[] = $f; } if (file_exists($f = app_folder() . '/pages/' . $page_folder . $filename)) { return $f; } $looked_for[] = $f; // don't bother looking if there is no $tina_mvc_page - we've already looked in the location in the check above if ($tina_mvc_page and get_tina_mvc_setting('app_cascade')) { if (file_exists($f = app_folder() . '/pages/' . $filename)) { return $f; } $looked_for[] = $f; } if ($secondary_folder = app_folder(TRUE)) { // multisite and multisite app cascade enabled if (file_exists($f = $secondary_folder . '/pages/' . $page_folder . $filename)) { return $f; } $looked_for[] = $f; if (get_tina_mvc_setting('app_cascade')) { if (file_exists($f = $secondary_folder . '/pages/' . $filename)) { return $f; } } $looked_for[] = $f; } if (file_exists($f = tina_mvc_folder() . '/pages/' . $filename)) { return $f; } $looked_for[] = $f; } elseif ($called_from == 'WIDGET' or $called_from == 'SHORTCODE' or $called_from == 'CALLABLE_CONTROLLER') { $search_folder = strtolower($called_from) . 's'; // i.e. "widget" -> "widgets", etc if (file_exists($f = app_folder() . "/{$search_folder}/{$filename}")) { return $f; } $looked_for[] = $f; if ($secondary_folder = app_folder(TRUE)) { // multisite and multisite app cascade enabled if (file_exists($f = $secondary_folder . "/{$search_folder}/{$filename}")) { return $f; } $looked_for[] = $f; } } else { error("Invalid parameter. No action for '\$called_from' == '{$called_from}'"); } // we have an error $find_app_file_error = $looked_for; return FALSE; }