/** * Format individual email fields * * @since 2.0 * @param array $atts pass by reference * @param string $f (to, from, reply_to, etc) * @param string $val value saved in field * @param int $key if in array, this will be set */ private static function format_single_field(&$atts, $f, $val, $key = false) { $val = trim($val); // If just a plain email is used if (is_email($val)) { // add sender's name if not included in $from if ($f == 'from') { $part_2 = $atts[$f]; $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode(FrmAppHelper::site_name(), ENT_QUOTES); } else { return; } } else { $parts = explode(' ', $val); $part_2 = end($parts); // If inputted correcly, $part_2 should be an email if (is_email($part_2)) { $part_1 = trim(str_replace($part_2, '', $val)); } else { if (in_array($f, array('from', 'reply_to'))) { // In case someone just puts a name in the From or Reply To field $part_1 = $val; $part_2 = get_option('admin_email'); } else { // In case someone just puts a name in any other email field if (false !== $key) { unset($atts[$f][$key]); return; } $atts[$f] = ''; return; } } } // if sending the email from a yahoo address, change it to the WordPress default if ($f == 'from' && strpos($part_2, '@yahoo.com')) { // Get the site domain and get rid of www. $sitename = strtolower(FrmAppHelper::get_server_value('SERVER_NAME')); if (substr($sitename, 0, 4) == 'www.') { $sitename = substr($sitename, 4); } $part_2 = 'wordpress@' . $sitename; } // Set up formatted value $final_val = '"' . str_replace('"', '', $part_1) . '" <' . $part_2 . '>'; // If value is an array if (false !== $key) { $atts[$f][$key] = $final_val; return; } $atts[$f] = $final_val; }
/** * Get the value to replace a few standard shortcodes * * @since 2.0 * @return string */ public static function dynamic_default_values($tag, $atts = array(), $return_array = false) { $new_value = ''; switch ($tag) { case 'admin_email': $new_value = get_option('admin_email'); break; case 'siteurl': $new_value = FrmAppHelper::site_url(); break; case 'frmurl': $new_value = FrmAppHelper::plugin_url(); break; case 'sitename': $new_value = FrmAppHelper::site_name(); break; case 'get': $new_value = self::process_get_shortcode($atts, $return_array); break; } return $new_value; }