array( 'key' => 'wu_system_email_event', 'value' => wu_get_isset($query, 'event'), ), ); } return Email::query($query); } /** * Get all saved system email. * * @since 2.0.0 * * @return array With all system emails. */ function wu_get_all_system_emails() { return Email::query( array( 'status__in' => array('draft', 'publish'), 'type__in' => array('system_email'), ) ); } /** * Get a single or all default registered system emails. * * @since 2.0.0 * * @param string $slug Default system email slug. * @return array All default system emails. */ function wu_get_default_system_emails($slug = '') { return Email_Manager::get_instance()->get_default_system_emails($slug); } /** * Create a single default system email. * * @since 2.0.0 * * @param string $slug Default system email slug to be create. * @return array */ function wu_create_default_system_email($slug) { $args = wu_get_default_system_emails($slug); return Email_Manager::get_instance()->create_system_email($args); } /** * Send an email to one or more users. * * @since 2.0.0 * * @param array $from From whom will be send this mail. * @param mixed $to To who this email is. * @param array $args With content, subject and other arguments, has shortcodes, mail type. * @return array */ function wu_send_mail($from = array(), $to = array(), $args = array()) { return Sender::send_mail($from, $to, $args); } /** * Returns email-like strings. * * E.g.: Robert Smith * * @since 2.0.0 * * @param string $email The email address. * @param false|string $name The customer/user display name. * @return string */ function wu_format_email_string($email, $name = false) { return $name ? sprintf('%s <%s>', $name, $email) : $email; } /** * Creates a new email. * * Check the wp_parse_args below to see what parameters are necessary. * * @since 2.0.0 * * @param array $email_data Email attributes. * @return \WP_Error|Email */ function wu_create_email($email_data) { $email_data = wp_parse_args( $email_data, array( 'type' => 'system_email', 'event' => 'Laborum consectetur', 'title' => 'Lorem Ipsum', 'slug' => 'lorem-ipsum', 'target' => 'admin', 'date_created' => wu_get_current_time('mysql', true), 'date_modified' => wu_get_current_time('mysql', true), ) ); $email = new Email($email_data); $saved = $email->save(); return is_wp_error($saved) ? $saved : $email; }