@@ -2,128 +2,128 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmNotification { |
| 4 | 4 | public function __construct() { |
| 5 | - if ( ! defined('ABSPATH') ) { |
|
| 6 | - die('You are not allowed to call this page directly.'); |
|
| 7 | - } |
|
| 8 | - add_action('frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3); |
|
| 9 | - } |
|
| 5 | + if ( ! defined('ABSPATH') ) { |
|
| 6 | + die('You are not allowed to call this page directly.'); |
|
| 7 | + } |
|
| 8 | + add_action('frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3); |
|
| 9 | + } |
|
| 10 | 10 | |
| 11 | 11 | public static function trigger_email( $action, $entry, $form ) { |
| 12 | - $notification = $action->post_content; |
|
| 13 | - $email_key = $action->ID; |
|
| 14 | - |
|
| 15 | - // Set the subject |
|
| 16 | - if ( empty($notification['email_subject']) ) { |
|
| 17 | - $notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]'); |
|
| 18 | - } |
|
| 19 | - |
|
| 20 | - $plain_text = $notification['plain_text'] ? true : false; |
|
| 21 | - |
|
| 22 | - //Filter these fields |
|
| 23 | - $filter_fields = array( |
|
| 24 | - 'email_to', 'cc', 'bcc', |
|
| 25 | - 'reply_to', 'from', |
|
| 26 | - 'email_subject', 'email_message', |
|
| 27 | - ); |
|
| 28 | - |
|
| 29 | - add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false')); |
|
| 30 | - |
|
| 31 | - //Get all values in entry in order to get User ID field ID |
|
| 32 | - $values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' ); |
|
| 33 | - $user_id_field = $user_id_key = ''; |
|
| 34 | - foreach ( $values as $value ) { |
|
| 35 | - if ( $value->field_type == 'user_id' ) { |
|
| 36 | - $user_id_field = $value->field_id; |
|
| 37 | - $user_id_key = $value->field_key; |
|
| 38 | - break; |
|
| 39 | - } |
|
| 40 | - unset($value); |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - //Filter and prepare the email fields |
|
| 44 | - foreach ( $filter_fields as $f ) { |
|
| 45 | - //Don't allow empty From |
|
| 12 | + $notification = $action->post_content; |
|
| 13 | + $email_key = $action->ID; |
|
| 14 | + |
|
| 15 | + // Set the subject |
|
| 16 | + if ( empty($notification['email_subject']) ) { |
|
| 17 | + $notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]'); |
|
| 18 | + } |
|
| 19 | + |
|
| 20 | + $plain_text = $notification['plain_text'] ? true : false; |
|
| 21 | + |
|
| 22 | + //Filter these fields |
|
| 23 | + $filter_fields = array( |
|
| 24 | + 'email_to', 'cc', 'bcc', |
|
| 25 | + 'reply_to', 'from', |
|
| 26 | + 'email_subject', 'email_message', |
|
| 27 | + ); |
|
| 28 | + |
|
| 29 | + add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false')); |
|
| 30 | + |
|
| 31 | + //Get all values in entry in order to get User ID field ID |
|
| 32 | + $values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' ); |
|
| 33 | + $user_id_field = $user_id_key = ''; |
|
| 34 | + foreach ( $values as $value ) { |
|
| 35 | + if ( $value->field_type == 'user_id' ) { |
|
| 36 | + $user_id_field = $value->field_id; |
|
| 37 | + $user_id_key = $value->field_key; |
|
| 38 | + break; |
|
| 39 | + } |
|
| 40 | + unset($value); |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + //Filter and prepare the email fields |
|
| 44 | + foreach ( $filter_fields as $f ) { |
|
| 45 | + //Don't allow empty From |
|
| 46 | 46 | if ( $f == 'from' && empty( $notification[ $f ] ) ) { |
| 47 | 47 | $notification[ $f ] = '[admin_email]'; |
| 48 | 48 | } else if ( in_array( $f, array( 'email_to', 'cc', 'bcc', 'reply_to', 'from' ) ) ) { |
| 49 | 49 | //Remove brackets |
| 50 | - //Add a space in case there isn't one |
|
| 50 | + //Add a space in case there isn't one |
|
| 51 | 51 | $notification[ $f ] = str_replace( '<', ' ', $notification[ $f ] ); |
| 52 | 52 | $notification[ $f ] = str_replace( array( '"', '>' ), '', $notification[ $f ] ); |
| 53 | 53 | |
| 54 | - //Switch userID shortcode to email address |
|
| 54 | + //Switch userID shortcode to email address |
|
| 55 | 55 | if ( strpos( $notification[ $f ], '[' . $user_id_field . ']' ) !== false || strpos( $notification[ $f ], '[' . $user_id_key . ']' ) !== false ) { |
| 56 | 56 | $user_data = get_userdata( $entry->metas[ $user_id_field ] ); |
| 57 | - $user_email = $user_data->user_email; |
|
| 57 | + $user_email = $user_data->user_email; |
|
| 58 | 58 | $notification[ $f ] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[ $f ] ); |
| 59 | - } |
|
| 60 | - } |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | 62 | $notification[ $f ] = FrmFieldsHelper::basic_replace_shortcodes( $notification[ $f ], $form, $entry ); |
| 63 | - } |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - //Put recipients, cc, and bcc into an array if they aren't empty |
|
| 65 | + //Put recipients, cc, and bcc into an array if they aren't empty |
|
| 66 | 66 | $to_emails = self::explode_emails( $notification['email_to'] ); |
| 67 | 67 | $cc = self::explode_emails( $notification['cc'] ); |
| 68 | 68 | $bcc = self::explode_emails( $notification['bcc'] ); |
| 69 | 69 | |
| 70 | - $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form')); |
|
| 70 | + $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form')); |
|
| 71 | 71 | |
| 72 | - // Stop now if there aren't any recipients |
|
| 73 | - if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) { |
|
| 74 | - return; |
|
| 75 | - } |
|
| 72 | + // Stop now if there aren't any recipients |
|
| 73 | + if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) { |
|
| 74 | + return; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - $to_emails = array_unique( (array) $to_emails ); |
|
| 77 | + $to_emails = array_unique( (array) $to_emails ); |
|
| 78 | 78 | |
| 79 | - $prev_mail_body = $mail_body = $notification['email_message']; |
|
| 80 | - $mail_body = FrmEntriesHelper::replace_default_message($mail_body, array( |
|
| 81 | - 'id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text, |
|
| 82 | - 'user_info' => (isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false), |
|
| 83 | - ) ); |
|
| 79 | + $prev_mail_body = $mail_body = $notification['email_message']; |
|
| 80 | + $mail_body = FrmEntriesHelper::replace_default_message($mail_body, array( |
|
| 81 | + 'id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text, |
|
| 82 | + 'user_info' => (isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false), |
|
| 83 | + ) ); |
|
| 84 | 84 | |
| 85 | - // Add the user info if it isn't already included |
|
| 86 | - if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) { |
|
| 87 | - $data = maybe_unserialize($entry->description); |
|
| 85 | + // Add the user info if it isn't already included |
|
| 86 | + if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) { |
|
| 87 | + $data = maybe_unserialize($entry->description); |
|
| 88 | 88 | $mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n"; |
| 89 | 89 | $mail_body .= __( 'IP Address', 'formidable' ) . ': ' . $entry->ip . "\r\n"; |
| 90 | 90 | $mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntryFormat::get_browser( $data['browser'] ) . "\r\n"; |
| 91 | 91 | $mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n"; |
| 92 | - } |
|
| 93 | - unset($prev_mail_body); |
|
| 94 | - |
|
| 95 | - // Add attachments |
|
| 96 | - $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') ); |
|
| 97 | - |
|
| 98 | - if ( ! empty($notification['email_subject']) ) { |
|
| 99 | - $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key')); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - // check for a phone number |
|
| 103 | - foreach ( (array) $to_emails as $email_key => $e ) { |
|
| 104 | - if ( $e != '[admin_email]' && ! is_email($e) ) { |
|
| 105 | - $e = explode(' ', $e); |
|
| 106 | - |
|
| 107 | - //If to_email has name <[email protected]> format |
|
| 108 | - if ( is_email(end($e)) ) { |
|
| 109 | - continue; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - do_action('frm_send_to_not_email', array( |
|
| 113 | - 'e' => $e, |
|
| 114 | - 'subject' => $notification['email_subject'], |
|
| 115 | - 'mail_body' => $mail_body, |
|
| 116 | - 'reply_to' => $notification['reply_to'], |
|
| 117 | - 'from' => $notification['from'], |
|
| 118 | - 'plain_text' => $plain_text, |
|
| 119 | - 'attachments' => $attachments, |
|
| 120 | - 'form' => $form, |
|
| 121 | - 'email_key' => $email_key, |
|
| 122 | - ) ); |
|
| 92 | + } |
|
| 93 | + unset($prev_mail_body); |
|
| 94 | + |
|
| 95 | + // Add attachments |
|
| 96 | + $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') ); |
|
| 97 | + |
|
| 98 | + if ( ! empty($notification['email_subject']) ) { |
|
| 99 | + $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key')); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + // check for a phone number |
|
| 103 | + foreach ( (array) $to_emails as $email_key => $e ) { |
|
| 104 | + if ( $e != '[admin_email]' && ! is_email($e) ) { |
|
| 105 | + $e = explode(' ', $e); |
|
| 106 | + |
|
| 107 | + //If to_email has name <[email protected]> format |
|
| 108 | + if ( is_email(end($e)) ) { |
|
| 109 | + continue; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + do_action('frm_send_to_not_email', array( |
|
| 113 | + 'e' => $e, |
|
| 114 | + 'subject' => $notification['email_subject'], |
|
| 115 | + 'mail_body' => $mail_body, |
|
| 116 | + 'reply_to' => $notification['reply_to'], |
|
| 117 | + 'from' => $notification['from'], |
|
| 118 | + 'plain_text' => $plain_text, |
|
| 119 | + 'attachments' => $attachments, |
|
| 120 | + 'form' => $form, |
|
| 121 | + 'email_key' => $email_key, |
|
| 122 | + ) ); |
|
| 123 | 123 | |
| 124 | 124 | unset( $to_emails[ $email_key ] ); |
| 125 | - } |
|
| 126 | - } |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | 128 | /** |
| 129 | 129 | * Send a separate email for email address in the "to" section |
@@ -131,38 +131,38 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | $send_single_recipient = apply_filters( 'frm_send_separate_emails', false, compact( 'action', 'entry', 'form' ) ); |
| 133 | 133 | |
| 134 | - // Send the email now |
|
| 135 | - $sent_to = self::send_email( array( |
|
| 136 | - 'to_email' => $to_emails, |
|
| 137 | - 'subject' => $notification['email_subject'], |
|
| 138 | - 'message' => $mail_body, |
|
| 139 | - 'from' => $notification['from'], |
|
| 140 | - 'plain_text' => $plain_text, |
|
| 141 | - 'reply_to' => $notification['reply_to'], |
|
| 142 | - 'attachments' => $attachments, |
|
| 143 | - 'cc' => $cc, |
|
| 144 | - 'bcc' => $bcc, |
|
| 134 | + // Send the email now |
|
| 135 | + $sent_to = self::send_email( array( |
|
| 136 | + 'to_email' => $to_emails, |
|
| 137 | + 'subject' => $notification['email_subject'], |
|
| 138 | + 'message' => $mail_body, |
|
| 139 | + 'from' => $notification['from'], |
|
| 140 | + 'plain_text' => $plain_text, |
|
| 141 | + 'reply_to' => $notification['reply_to'], |
|
| 142 | + 'attachments' => $attachments, |
|
| 143 | + 'cc' => $cc, |
|
| 144 | + 'bcc' => $bcc, |
|
| 145 | 145 | 'single_recipient' => $send_single_recipient, |
| 146 | - ) ); |
|
| 146 | + ) ); |
|
| 147 | 147 | |
| 148 | - return $sent_to; |
|
| 149 | - } |
|
| 148 | + return $sent_to; |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | 151 | public function entry_created( $entry_id, $form_id ) { |
| 152 | 152 | $new_function = 'FrmFormActionsController::trigger_actions("create", ' . $form_id . ', ' . $entry_id . ', "email")'; |
| 153 | 153 | _deprecated_function( __FUNCTION__, '2.0', $new_function ); |
| 154 | - FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email'); |
|
| 155 | - } |
|
| 154 | + FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email'); |
|
| 155 | + } |
|
| 156 | 156 | |
| 157 | 157 | public function send_notification_email( $to_email, $subject, $message, $from = '', $from_name = '', $plain_text = true, $attachments = array(), $reply_to = '' ) { |
| 158 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' ); |
|
| 158 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' ); |
|
| 159 | 159 | |
| 160 | - return self::send_email(compact( |
|
| 161 | - 'to_email', 'subject', 'message', |
|
| 162 | - 'from', 'from_name', 'plain_text', |
|
| 163 | - 'attachments', 'reply_to' |
|
| 164 | - )); |
|
| 165 | - } |
|
| 160 | + return self::send_email(compact( |
|
| 161 | + 'to_email', 'subject', 'message', |
|
| 162 | + 'from', 'from_name', 'plain_text', |
|
| 163 | + 'attachments', 'reply_to' |
|
| 164 | + )); |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | 167 | /** |
| 168 | 168 | * Extract the emails from cc and bcc. Allow separation by , or ;. |
@@ -180,53 +180,53 @@ discard block |
||
| 180 | 180 | return $emails; |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - /** |
|
| 184 | - * Put To, BCC, CC, Reply To, and From fields in Name <[email protected]> format |
|
| 185 | - * Formats that should work: Name, "Name", [email protected], <[email protected]>, Name <[email protected]>, |
|
| 186 | - * "Name" <[email protected]>, Name [email protected], "Name" [email protected], Name<[email protected]>, "Name"<[email protected]> |
|
| 187 | - * "First Last" <[email protected]> |
|
| 188 | - * |
|
| 189 | - * Things that won't work: First Last (with no email entered) |
|
| 190 | - * @since 2.0 |
|
| 191 | - * @param array $atts array of email fields, pass by reference |
|
| 192 | - * @param $admin_email |
|
| 193 | - */ |
|
| 194 | - private static function format_email_fields( &$atts, $admin_email ) { |
|
| 195 | - |
|
| 196 | - // If from is empty or is set to admin_email, set it now |
|
| 197 | - $atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from']; |
|
| 198 | - |
|
| 199 | - // Filter values in these fields |
|
| 183 | + /** |
|
| 184 | + * Put To, BCC, CC, Reply To, and From fields in Name <[email protected]> format |
|
| 185 | + * Formats that should work: Name, "Name", [email protected], <[email protected]>, Name <[email protected]>, |
|
| 186 | + * "Name" <[email protected]>, Name [email protected], "Name" [email protected], Name<[email protected]>, "Name"<[email protected]> |
|
| 187 | + * "First Last" <[email protected]> |
|
| 188 | + * |
|
| 189 | + * Things that won't work: First Last (with no email entered) |
|
| 190 | + * @since 2.0 |
|
| 191 | + * @param array $atts array of email fields, pass by reference |
|
| 192 | + * @param $admin_email |
|
| 193 | + */ |
|
| 194 | + private static function format_email_fields( &$atts, $admin_email ) { |
|
| 195 | + |
|
| 196 | + // If from is empty or is set to admin_email, set it now |
|
| 197 | + $atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from']; |
|
| 198 | + |
|
| 199 | + // Filter values in these fields |
|
| 200 | 200 | $filter_fields = array( 'to_email', 'bcc', 'cc', 'from', 'reply_to' ); |
| 201 | 201 | |
| 202 | - foreach ( $filter_fields as $f ) { |
|
| 203 | - // If empty, just skip it |
|
| 202 | + foreach ( $filter_fields as $f ) { |
|
| 203 | + // If empty, just skip it |
|
| 204 | 204 | if ( empty( $atts[ $f ] ) ) { |
| 205 | - continue; |
|
| 206 | - } |
|
| 205 | + continue; |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | - // to_email, cc, and bcc can be an array |
|
| 208 | + // to_email, cc, and bcc can be an array |
|
| 209 | 209 | if ( is_array( $atts[ $f ] ) ) { |
| 210 | 210 | foreach ( $atts[ $f ] as $key => $val ) { |
| 211 | - self::format_single_field( $atts, $f, $val, $key ); |
|
| 212 | - unset( $key, $val ); |
|
| 213 | - } |
|
| 214 | - unset($f); |
|
| 215 | - continue; |
|
| 216 | - } |
|
| 211 | + self::format_single_field( $atts, $f, $val, $key ); |
|
| 212 | + unset( $key, $val ); |
|
| 213 | + } |
|
| 214 | + unset($f); |
|
| 215 | + continue; |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | 218 | self::format_single_field( $atts, $f, $atts[ $f ] ); |
| 219 | - } |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | - // If reply-to isn't set, make it match the from settings |
|
| 222 | - if ( empty( $atts['reply_to'] ) ) { |
|
| 223 | - $atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] ); |
|
| 224 | - } |
|
| 221 | + // If reply-to isn't set, make it match the from settings |
|
| 222 | + if ( empty( $atts['reply_to'] ) ) { |
|
| 223 | + $atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] ); |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) { |
|
| 227 | - $atts['to_email'] = $admin_email; |
|
| 228 | - } |
|
| 229 | - } |
|
| 226 | + if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) { |
|
| 227 | + $atts['to_email'] = $admin_email; |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | 230 | |
| 231 | 231 | private static function get_email_from_formatted_string( $value ) { |
| 232 | 232 | if ( strpos( $value, '<' ) !== false ) { |
@@ -236,48 +236,48 @@ discard block |
||
| 236 | 236 | return $value; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - /** |
|
| 240 | - * Format individual email fields |
|
| 241 | - * |
|
| 242 | - * @since 2.0 |
|
| 243 | - * @param array $atts pass by reference |
|
| 244 | - * @param string $f (to, from, reply_to, etc) |
|
| 245 | - * @param string $val value saved in field |
|
| 246 | - * @param int $key if in array, this will be set |
|
| 247 | - */ |
|
| 248 | - private static function format_single_field( &$atts, $f, $val, $key = false ) { |
|
| 249 | - $val = trim($val); |
|
| 250 | - |
|
| 251 | - // If just a plain email is used |
|
| 252 | - if ( is_email($val) ) { |
|
| 253 | - // add sender's name if not included in $from |
|
| 254 | - if ( $f == 'from' ) { |
|
| 239 | + /** |
|
| 240 | + * Format individual email fields |
|
| 241 | + * |
|
| 242 | + * @since 2.0 |
|
| 243 | + * @param array $atts pass by reference |
|
| 244 | + * @param string $f (to, from, reply_to, etc) |
|
| 245 | + * @param string $val value saved in field |
|
| 246 | + * @param int $key if in array, this will be set |
|
| 247 | + */ |
|
| 248 | + private static function format_single_field( &$atts, $f, $val, $key = false ) { |
|
| 249 | + $val = trim($val); |
|
| 250 | + |
|
| 251 | + // If just a plain email is used |
|
| 252 | + if ( is_email($val) ) { |
|
| 253 | + // add sender's name if not included in $from |
|
| 254 | + if ( $f == 'from' ) { |
|
| 255 | 255 | $part_2 = $atts[ $f ]; |
| 256 | - $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 257 | - } else { |
|
| 258 | - return; |
|
| 259 | - } |
|
| 260 | - } else { |
|
| 261 | - $parts = explode(' ', $val); |
|
| 262 | - $part_2 = end($parts); |
|
| 263 | - |
|
| 264 | - // If inputted correcly, $part_2 should be an email |
|
| 265 | - if ( is_email( $part_2 ) ) { |
|
| 266 | - $part_1 = trim( str_replace( $part_2, '', $val ) ); |
|
| 267 | - } else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) { |
|
| 256 | + $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 257 | + } else { |
|
| 258 | + return; |
|
| 259 | + } |
|
| 260 | + } else { |
|
| 261 | + $parts = explode(' ', $val); |
|
| 262 | + $part_2 = end($parts); |
|
| 263 | + |
|
| 264 | + // If inputted correcly, $part_2 should be an email |
|
| 265 | + if ( is_email( $part_2 ) ) { |
|
| 266 | + $part_1 = trim( str_replace( $part_2, '', $val ) ); |
|
| 267 | + } else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) { |
|
| 268 | 268 | // In case someone just puts a name in the From or Reply To field |
| 269 | 269 | $part_1 = $val; |
| 270 | - $part_2 = get_option('admin_email'); |
|
| 271 | - } else { |
|
| 270 | + $part_2 = get_option('admin_email'); |
|
| 271 | + } else { |
|
| 272 | 272 | // In case someone just puts a name in any other email field |
| 273 | - if ( false !== $key ) { |
|
| 273 | + if ( false !== $key ) { |
|
| 274 | 274 | unset( $atts[ $f ][ $key ] ); |
| 275 | - return; |
|
| 276 | - } |
|
| 275 | + return; |
|
| 276 | + } |
|
| 277 | 277 | $atts[ $f ] = ''; |
| 278 | - return; |
|
| 279 | - } |
|
| 280 | - } |
|
| 278 | + return; |
|
| 279 | + } |
|
| 280 | + } |
|
| 281 | 281 | |
| 282 | 282 | // if sending the email from a yahoo address, change it to the WordPress default |
| 283 | 283 | if ( $f == 'from' && strpos( $part_2, '@yahoo.com' ) ) { |
@@ -290,60 +290,60 @@ discard block |
||
| 290 | 290 | $part_2 = 'wordpress@' . $sitename; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - // Set up formatted value |
|
| 293 | + // Set up formatted value |
|
| 294 | 294 | $final_val = str_replace( '"', '', $part_1 ) . ' <' . $part_2 . '>'; |
| 295 | 295 | |
| 296 | - // If value is an array |
|
| 297 | - if ( false !== $key ) { |
|
| 296 | + // If value is an array |
|
| 297 | + if ( false !== $key ) { |
|
| 298 | 298 | $atts[ $f ][ $key ] = $final_val; |
| 299 | - return; |
|
| 300 | - } |
|
| 299 | + return; |
|
| 300 | + } |
|
| 301 | 301 | $atts[ $f ] = $final_val; |
| 302 | - } |
|
| 302 | + } |
|
| 303 | 303 | |
| 304 | 304 | public static function send_email( $atts ) { |
| 305 | - $admin_email = get_option('admin_email'); |
|
| 306 | - $defaults = array( |
|
| 307 | - 'to_email' => $admin_email, |
|
| 308 | - 'subject' => '', |
|
| 309 | - 'message' => '', |
|
| 310 | - 'from' => $admin_email, |
|
| 311 | - 'from_name' => '', |
|
| 312 | - 'cc' => '', |
|
| 313 | - 'bcc' => '', |
|
| 314 | - 'plain_text' => true, |
|
| 315 | - 'reply_to' => $admin_email, |
|
| 316 | - 'attachments' => array(), |
|
| 305 | + $admin_email = get_option('admin_email'); |
|
| 306 | + $defaults = array( |
|
| 307 | + 'to_email' => $admin_email, |
|
| 308 | + 'subject' => '', |
|
| 309 | + 'message' => '', |
|
| 310 | + 'from' => $admin_email, |
|
| 311 | + 'from_name' => '', |
|
| 312 | + 'cc' => '', |
|
| 313 | + 'bcc' => '', |
|
| 314 | + 'plain_text' => true, |
|
| 315 | + 'reply_to' => $admin_email, |
|
| 316 | + 'attachments' => array(), |
|
| 317 | 317 | 'single_recipient' => false, |
| 318 | - ); |
|
| 319 | - $atts = wp_parse_args($atts, $defaults); |
|
| 318 | + ); |
|
| 319 | + $atts = wp_parse_args($atts, $defaults); |
|
| 320 | 320 | |
| 321 | - // Put To, BCC, CC, Reply To, and From fields in the correct format |
|
| 322 | - self::format_email_fields( $atts, $admin_email ); |
|
| 321 | + // Put To, BCC, CC, Reply To, and From fields in the correct format |
|
| 322 | + self::format_email_fields( $atts, $admin_email ); |
|
| 323 | 323 | |
| 324 | - $header = array(); |
|
| 325 | - $header[] = 'From: ' . $atts['from']; |
|
| 324 | + $header = array(); |
|
| 325 | + $header[] = 'From: ' . $atts['from']; |
|
| 326 | 326 | |
| 327 | - //Allow for cc and bcc arrays |
|
| 327 | + //Allow for cc and bcc arrays |
|
| 328 | 328 | $array_fields = array( 'CC' => $atts['cc'], 'BCC' => $atts['bcc'] ); |
| 329 | 329 | $cc = array( 'CC' => array(), 'BCC' => array() ); |
| 330 | - foreach ( $array_fields as $key => $a_field ) { |
|
| 331 | - if ( empty($a_field) ) { |
|
| 332 | - continue; |
|
| 333 | - } |
|
| 330 | + foreach ( $array_fields as $key => $a_field ) { |
|
| 331 | + if ( empty($a_field) ) { |
|
| 332 | + continue; |
|
| 333 | + } |
|
| 334 | 334 | |
| 335 | 335 | foreach ( (array) $a_field as $email ) { |
| 336 | 336 | $cc[ $key ][] = $email; |
| 337 | - } |
|
| 338 | - unset($key, $a_field); |
|
| 339 | - } |
|
| 337 | + } |
|
| 338 | + unset($key, $a_field); |
|
| 339 | + } |
|
| 340 | 340 | $cc = array_filter( $cc ); // remove cc and bcc if they are empty |
| 341 | 341 | |
| 342 | 342 | foreach ( $cc as $k => $v ) { |
| 343 | 343 | $header[] = $k . ': ' . implode( ',', $v ); |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | - $content_type = $atts['plain_text'] ? 'text/plain' : 'text/html'; |
|
| 346 | + $content_type = $atts['plain_text'] ? 'text/plain' : 'text/html'; |
|
| 347 | 347 | $atts['charset'] = get_option('blog_charset'); |
| 348 | 348 | |
| 349 | 349 | $header[] = 'Reply-To: ' . $atts['reply_to']; |
@@ -352,12 +352,12 @@ discard block |
||
| 352 | 352 | |
| 353 | 353 | $atts['message'] = do_shortcode( $atts['message'] ); |
| 354 | 354 | |
| 355 | - if ( $atts['plain_text'] ) { |
|
| 355 | + if ( $atts['plain_text'] ) { |
|
| 356 | 356 | $atts['message'] = wp_specialchars_decode( strip_tags( $atts['message'] ), ENT_QUOTES ); |
| 357 | - } else { |
|
| 357 | + } else { |
|
| 358 | 358 | // remove line breaks in HTML emails to prevent conflicts with Mandrill |
| 359 | - add_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' ); |
|
| 360 | - } |
|
| 359 | + add_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' ); |
|
| 360 | + } |
|
| 361 | 361 | $atts['message'] = apply_filters( 'frm_email_message', $atts['message'], $atts ); |
| 362 | 362 | |
| 363 | 363 | /** |
@@ -386,10 +386,10 @@ discard block |
||
| 386 | 386 | // remove the filter now so other emails can still use it |
| 387 | 387 | remove_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' ); |
| 388 | 388 | |
| 389 | - if ( $sent ) { |
|
| 389 | + if ( $sent ) { |
|
| 390 | 390 | return self::return_emails_sent( $atts ); |
| 391 | - } |
|
| 392 | - } |
|
| 391 | + } |
|
| 392 | + } |
|
| 393 | 393 | |
| 394 | 394 | private static function send_single_email( $recipient, $atts, $header ) { |
| 395 | 395 | $header = apply_filters( 'frm_email_header', $header, array( |
@@ -2,10 +2,10 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmNotification { |
| 4 | 4 | public function __construct() { |
| 5 | - if ( ! defined('ABSPATH') ) { |
|
| 6 | - die('You are not allowed to call this page directly.'); |
|
| 5 | + if ( ! defined( 'ABSPATH' ) ) { |
|
| 6 | + die( 'You are not allowed to call this page directly.' ); |
|
| 7 | 7 | } |
| 8 | - add_action('frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3); |
|
| 8 | + add_action( 'frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3 ); |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | public static function trigger_email( $action, $entry, $form ) { |
@@ -13,8 +13,8 @@ discard block |
||
| 13 | 13 | $email_key = $action->ID; |
| 14 | 14 | |
| 15 | 15 | // Set the subject |
| 16 | - if ( empty($notification['email_subject']) ) { |
|
| 17 | - $notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]'); |
|
| 16 | + if ( empty( $notification['email_subject'] ) ) { |
|
| 17 | + $notification['email_subject'] = sprintf( __( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]' ); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | $plain_text = $notification['plain_text'] ? true : false; |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | 'email_subject', 'email_message', |
| 27 | 27 | ); |
| 28 | 28 | |
| 29 | - add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false')); |
|
| 29 | + add_filter( 'frm_plain_text_email', ( $plain_text ? '__return_true' : '__return_false' ) ); |
|
| 30 | 30 | |
| 31 | 31 | //Get all values in entry in order to get User ID field ID |
| 32 | 32 | $values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' ); |
@@ -37,29 +37,29 @@ discard block |
||
| 37 | 37 | $user_id_key = $value->field_key; |
| 38 | 38 | break; |
| 39 | 39 | } |
| 40 | - unset($value); |
|
| 40 | + unset( $value ); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | //Filter and prepare the email fields |
| 44 | 44 | foreach ( $filter_fields as $f ) { |
| 45 | 45 | //Don't allow empty From |
| 46 | - if ( $f == 'from' && empty( $notification[ $f ] ) ) { |
|
| 47 | - $notification[ $f ] = '[admin_email]'; |
|
| 46 | + if ( $f == 'from' && empty( $notification[$f] ) ) { |
|
| 47 | + $notification[$f] = '[admin_email]'; |
|
| 48 | 48 | } else if ( in_array( $f, array( 'email_to', 'cc', 'bcc', 'reply_to', 'from' ) ) ) { |
| 49 | 49 | //Remove brackets |
| 50 | 50 | //Add a space in case there isn't one |
| 51 | - $notification[ $f ] = str_replace( '<', ' ', $notification[ $f ] ); |
|
| 52 | - $notification[ $f ] = str_replace( array( '"', '>' ), '', $notification[ $f ] ); |
|
| 51 | + $notification[$f] = str_replace( '<', ' ', $notification[$f] ); |
|
| 52 | + $notification[$f] = str_replace( array( '"', '>' ), '', $notification[$f] ); |
|
| 53 | 53 | |
| 54 | 54 | //Switch userID shortcode to email address |
| 55 | - if ( strpos( $notification[ $f ], '[' . $user_id_field . ']' ) !== false || strpos( $notification[ $f ], '[' . $user_id_key . ']' ) !== false ) { |
|
| 56 | - $user_data = get_userdata( $entry->metas[ $user_id_field ] ); |
|
| 55 | + if ( strpos( $notification[$f], '[' . $user_id_field . ']' ) !== false || strpos( $notification[$f], '[' . $user_id_key . ']' ) !== false ) { |
|
| 56 | + $user_data = get_userdata( $entry->metas[$user_id_field] ); |
|
| 57 | 57 | $user_email = $user_data->user_email; |
| 58 | - $notification[ $f ] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[ $f ] ); |
|
| 58 | + $notification[$f] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[$f] ); |
|
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - $notification[ $f ] = FrmFieldsHelper::basic_replace_shortcodes( $notification[ $f ], $form, $entry ); |
|
| 62 | + $notification[$f] = FrmFieldsHelper::basic_replace_shortcodes( $notification[$f], $form, $entry ); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | //Put recipients, cc, and bcc into an array if they aren't empty |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | $cc = self::explode_emails( $notification['cc'] ); |
| 68 | 68 | $bcc = self::explode_emails( $notification['bcc'] ); |
| 69 | 69 | |
| 70 | - $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form')); |
|
| 70 | + $to_emails = apply_filters( 'frm_to_email', $to_emails, $values, $form->id, compact( 'email_key', 'entry', 'form' ) ); |
|
| 71 | 71 | |
| 72 | 72 | // Stop now if there aren't any recipients |
| 73 | 73 | if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) { |
@@ -77,39 +77,39 @@ discard block |
||
| 77 | 77 | $to_emails = array_unique( (array) $to_emails ); |
| 78 | 78 | |
| 79 | 79 | $prev_mail_body = $mail_body = $notification['email_message']; |
| 80 | - $mail_body = FrmEntriesHelper::replace_default_message($mail_body, array( |
|
| 80 | + $mail_body = FrmEntriesHelper::replace_default_message( $mail_body, array( |
|
| 81 | 81 | 'id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text, |
| 82 | - 'user_info' => (isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false), |
|
| 82 | + 'user_info' => ( isset( $notification['inc_user_info'] ) ? $notification['inc_user_info'] : false ), |
|
| 83 | 83 | ) ); |
| 84 | 84 | |
| 85 | 85 | // Add the user info if it isn't already included |
| 86 | 86 | if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) { |
| 87 | - $data = maybe_unserialize($entry->description); |
|
| 87 | + $data = maybe_unserialize( $entry->description ); |
|
| 88 | 88 | $mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n"; |
| 89 | 89 | $mail_body .= __( 'IP Address', 'formidable' ) . ': ' . $entry->ip . "\r\n"; |
| 90 | 90 | $mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntryFormat::get_browser( $data['browser'] ) . "\r\n"; |
| 91 | 91 | $mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n"; |
| 92 | 92 | } |
| 93 | - unset($prev_mail_body); |
|
| 93 | + unset( $prev_mail_body ); |
|
| 94 | 94 | |
| 95 | 95 | // Add attachments |
| 96 | - $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') ); |
|
| 96 | + $attachments = apply_filters( 'frm_notification_attachment', array(), $form, compact( 'entry', 'email_key' ) ); |
|
| 97 | 97 | |
| 98 | - if ( ! empty($notification['email_subject']) ) { |
|
| 99 | - $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key')); |
|
| 98 | + if ( ! empty( $notification['email_subject'] ) ) { |
|
| 99 | + $notification['email_subject'] = apply_filters( 'frm_email_subject', $notification['email_subject'], compact( 'form', 'entry', 'email_key' ) ); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | // check for a phone number |
| 103 | 103 | foreach ( (array) $to_emails as $email_key => $e ) { |
| 104 | - if ( $e != '[admin_email]' && ! is_email($e) ) { |
|
| 105 | - $e = explode(' ', $e); |
|
| 104 | + if ( $e != '[admin_email]' && ! is_email( $e ) ) { |
|
| 105 | + $e = explode( ' ', $e ); |
|
| 106 | 106 | |
| 107 | 107 | //If to_email has name <[email protected]> format |
| 108 | - if ( is_email(end($e)) ) { |
|
| 108 | + if ( is_email( end( $e ) ) ) { |
|
| 109 | 109 | continue; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - do_action('frm_send_to_not_email', array( |
|
| 112 | + do_action( 'frm_send_to_not_email', array( |
|
| 113 | 113 | 'e' => $e, |
| 114 | 114 | 'subject' => $notification['email_subject'], |
| 115 | 115 | 'mail_body' => $mail_body, |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | 'email_key' => $email_key, |
| 122 | 122 | ) ); |
| 123 | 123 | |
| 124 | - unset( $to_emails[ $email_key ] ); |
|
| 124 | + unset( $to_emails[$email_key] ); |
|
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | |
@@ -151,17 +151,17 @@ discard block |
||
| 151 | 151 | public function entry_created( $entry_id, $form_id ) { |
| 152 | 152 | $new_function = 'FrmFormActionsController::trigger_actions("create", ' . $form_id . ', ' . $entry_id . ', "email")'; |
| 153 | 153 | _deprecated_function( __FUNCTION__, '2.0', $new_function ); |
| 154 | - FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email'); |
|
| 154 | + FrmFormActionsController::trigger_actions( 'create', $form_id, $entry_id, 'email' ); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | public function send_notification_email( $to_email, $subject, $message, $from = '', $from_name = '', $plain_text = true, $attachments = array(), $reply_to = '' ) { |
| 158 | 158 | _deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' ); |
| 159 | 159 | |
| 160 | - return self::send_email(compact( |
|
| 160 | + return self::send_email( compact( |
|
| 161 | 161 | 'to_email', 'subject', 'message', |
| 162 | 162 | 'from', 'from_name', 'plain_text', |
| 163 | 163 | 'attachments', 'reply_to' |
| 164 | - )); |
|
| 164 | + ) ); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -194,28 +194,28 @@ discard block |
||
| 194 | 194 | private static function format_email_fields( &$atts, $admin_email ) { |
| 195 | 195 | |
| 196 | 196 | // If from is empty or is set to admin_email, set it now |
| 197 | - $atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from']; |
|
| 197 | + $atts['from'] = ( empty( $atts['from'] ) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from']; |
|
| 198 | 198 | |
| 199 | 199 | // Filter values in these fields |
| 200 | 200 | $filter_fields = array( 'to_email', 'bcc', 'cc', 'from', 'reply_to' ); |
| 201 | 201 | |
| 202 | 202 | foreach ( $filter_fields as $f ) { |
| 203 | 203 | // If empty, just skip it |
| 204 | - if ( empty( $atts[ $f ] ) ) { |
|
| 204 | + if ( empty( $atts[$f] ) ) { |
|
| 205 | 205 | continue; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | // to_email, cc, and bcc can be an array |
| 209 | - if ( is_array( $atts[ $f ] ) ) { |
|
| 210 | - foreach ( $atts[ $f ] as $key => $val ) { |
|
| 209 | + if ( is_array( $atts[$f] ) ) { |
|
| 210 | + foreach ( $atts[$f] as $key => $val ) { |
|
| 211 | 211 | self::format_single_field( $atts, $f, $val, $key ); |
| 212 | 212 | unset( $key, $val ); |
| 213 | 213 | } |
| 214 | - unset($f); |
|
| 214 | + unset( $f ); |
|
| 215 | 215 | continue; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - self::format_single_field( $atts, $f, $atts[ $f ] ); |
|
| 218 | + self::format_single_field( $atts, $f, $atts[$f] ); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | // If reply-to isn't set, make it match the from settings |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | $atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] ); |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) { |
|
| 226 | + if ( ! is_array( $atts['to_email'] ) && '[admin_email]' == $atts['to_email'] ) { |
|
| 227 | 227 | $atts['to_email'] = $admin_email; |
| 228 | 228 | } |
| 229 | 229 | } |
@@ -246,20 +246,20 @@ discard block |
||
| 246 | 246 | * @param int $key if in array, this will be set |
| 247 | 247 | */ |
| 248 | 248 | private static function format_single_field( &$atts, $f, $val, $key = false ) { |
| 249 | - $val = trim($val); |
|
| 249 | + $val = trim( $val ); |
|
| 250 | 250 | |
| 251 | 251 | // If just a plain email is used |
| 252 | - if ( is_email($val) ) { |
|
| 252 | + if ( is_email( $val ) ) { |
|
| 253 | 253 | // add sender's name if not included in $from |
| 254 | 254 | if ( $f == 'from' ) { |
| 255 | - $part_2 = $atts[ $f ]; |
|
| 256 | - $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 255 | + $part_2 = $atts[$f]; |
|
| 256 | + $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 257 | 257 | } else { |
| 258 | 258 | return; |
| 259 | 259 | } |
| 260 | 260 | } else { |
| 261 | - $parts = explode(' ', $val); |
|
| 262 | - $part_2 = end($parts); |
|
| 261 | + $parts = explode( ' ', $val ); |
|
| 262 | + $part_2 = end( $parts ); |
|
| 263 | 263 | |
| 264 | 264 | // If inputted correcly, $part_2 should be an email |
| 265 | 265 | if ( is_email( $part_2 ) ) { |
@@ -267,14 +267,14 @@ discard block |
||
| 267 | 267 | } else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) { |
| 268 | 268 | // In case someone just puts a name in the From or Reply To field |
| 269 | 269 | $part_1 = $val; |
| 270 | - $part_2 = get_option('admin_email'); |
|
| 270 | + $part_2 = get_option( 'admin_email' ); |
|
| 271 | 271 | } else { |
| 272 | 272 | // In case someone just puts a name in any other email field |
| 273 | 273 | if ( false !== $key ) { |
| 274 | - unset( $atts[ $f ][ $key ] ); |
|
| 274 | + unset( $atts[$f][$key] ); |
|
| 275 | 275 | return; |
| 276 | 276 | } |
| 277 | - $atts[ $f ] = ''; |
|
| 277 | + $atts[$f] = ''; |
|
| 278 | 278 | return; |
| 279 | 279 | } |
| 280 | 280 | } |
@@ -295,14 +295,14 @@ discard block |
||
| 295 | 295 | |
| 296 | 296 | // If value is an array |
| 297 | 297 | if ( false !== $key ) { |
| 298 | - $atts[ $f ][ $key ] = $final_val; |
|
| 298 | + $atts[$f][$key] = $final_val; |
|
| 299 | 299 | return; |
| 300 | 300 | } |
| 301 | - $atts[ $f ] = $final_val; |
|
| 301 | + $atts[$f] = $final_val; |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | public static function send_email( $atts ) { |
| 305 | - $admin_email = get_option('admin_email'); |
|
| 305 | + $admin_email = get_option( 'admin_email' ); |
|
| 306 | 306 | $defaults = array( |
| 307 | 307 | 'to_email' => $admin_email, |
| 308 | 308 | 'subject' => '', |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | 'attachments' => array(), |
| 317 | 317 | 'single_recipient' => false, |
| 318 | 318 | ); |
| 319 | - $atts = wp_parse_args($atts, $defaults); |
|
| 319 | + $atts = wp_parse_args( $atts, $defaults ); |
|
| 320 | 320 | |
| 321 | 321 | // Put To, BCC, CC, Reply To, and From fields in the correct format |
| 322 | 322 | self::format_email_fields( $atts, $admin_email ); |
@@ -328,14 +328,14 @@ discard block |
||
| 328 | 328 | $array_fields = array( 'CC' => $atts['cc'], 'BCC' => $atts['bcc'] ); |
| 329 | 329 | $cc = array( 'CC' => array(), 'BCC' => array() ); |
| 330 | 330 | foreach ( $array_fields as $key => $a_field ) { |
| 331 | - if ( empty($a_field) ) { |
|
| 331 | + if ( empty( $a_field ) ) { |
|
| 332 | 332 | continue; |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | foreach ( (array) $a_field as $email ) { |
| 336 | - $cc[ $key ][] = $email; |
|
| 336 | + $cc[$key][] = $email; |
|
| 337 | 337 | } |
| 338 | - unset($key, $a_field); |
|
| 338 | + unset( $key, $a_field ); |
|
| 339 | 339 | } |
| 340 | 340 | $cc = array_filter( $cc ); // remove cc and bcc if they are empty |
| 341 | 341 | |
@@ -343,8 +343,8 @@ discard block |
||
| 343 | 343 | $header[] = $k . ': ' . implode( ',', $v ); |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | - $content_type = $atts['plain_text'] ? 'text/plain' : 'text/html'; |
|
| 347 | - $atts['charset'] = get_option('blog_charset'); |
|
| 346 | + $content_type = $atts['plain_text'] ? 'text/plain' : 'text/html'; |
|
| 347 | + $atts['charset'] = get_option( 'blog_charset' ); |
|
| 348 | 348 | |
| 349 | 349 | $header[] = 'Reply-To: ' . $atts['reply_to']; |
| 350 | 350 | $header[] = 'Content-Type: ' . $content_type . '; charset="' . esc_attr( $atts['charset'] ) . '"'; |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | private static function encode_subject( $charset, &$subject ) { |
| 414 | - if ( apply_filters('frm_encode_subject', 1, $subject ) ) { |
|
| 414 | + if ( apply_filters( 'frm_encode_subject', 1, $subject ) ) { |
|
| 415 | 415 | $subject = '=?' . $charset . '?B?' . base64_encode( $subject ) . '?='; |
| 416 | 416 | } |
| 417 | 417 | } |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | |
| 428 | 428 | if ( apply_filters( 'frm_echo_emails', false ) ) { |
| 429 | 429 | $temp = str_replace( '<', '<', $sent_to ); |
| 430 | - echo ' ' . FrmAppHelper::kses( implode(', ', (array) $temp ) ); |
|
| 430 | + echo ' ' . FrmAppHelper::kses( implode( ', ', (array) $temp ) ); |
|
| 431 | 431 | } |
| 432 | 432 | return $sent_to; |
| 433 | 433 | } |
@@ -2,201 +2,201 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmEntriesController { |
| 4 | 4 | |
| 5 | - public static function menu() { |
|
| 5 | + public static function menu() { |
|
| 6 | 6 | FrmAppHelper::force_capability( 'frm_view_entries' ); |
| 7 | 7 | |
| 8 | - add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
| 8 | + add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
| 9 | 9 | |
| 10 | 10 | if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) { |
| 11 | 11 | $menu_name = FrmAppHelper::get_menu_name(); |
| 12 | 12 | add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_columns', 'FrmEntriesController::manage_columns' ); |
| 13 | 13 | add_filter( 'get_user_option_manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden', 'FrmEntriesController::hidden_columns' ); |
| 14 | 14 | add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_sortable_columns', 'FrmEntriesController::sortable_columns' ); |
| 15 | - } |
|
| 16 | - } |
|
| 15 | + } |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - /* Display in Back End */ |
|
| 19 | - public static function route() { |
|
| 18 | + /* Display in Back End */ |
|
| 19 | + public static function route() { |
|
| 20 | 20 | $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
| 21 | 21 | |
| 22 | - switch ( $action ) { |
|
| 23 | - case 'show': |
|
| 24 | - case 'destroy': |
|
| 25 | - case 'destroy_all': |
|
| 26 | - return self::$action(); |
|
| 22 | + switch ( $action ) { |
|
| 23 | + case 'show': |
|
| 24 | + case 'destroy': |
|
| 25 | + case 'destroy_all': |
|
| 26 | + return self::$action(); |
|
| 27 | 27 | |
| 28 | - default: |
|
| 29 | - do_action( 'frm_entry_action_route', $action ); |
|
| 30 | - if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) { |
|
| 31 | - return; |
|
| 32 | - } |
|
| 28 | + default: |
|
| 29 | + do_action( 'frm_entry_action_route', $action ); |
|
| 30 | + if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) { |
|
| 31 | + return; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - return self::display_list(); |
|
| 35 | - } |
|
| 36 | - } |
|
| 34 | + return self::display_list(); |
|
| 35 | + } |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | 38 | public static function contextual_help( $help, $screen_id, $screen ) { |
| 39 | - // Only add to certain screens. add_help_tab was introduced in WordPress 3.3 |
|
| 40 | - if ( ! method_exists( $screen, 'add_help_tab' ) ) { |
|
| 41 | - return $help; |
|
| 42 | - } |
|
| 39 | + // Only add to certain screens. add_help_tab was introduced in WordPress 3.3 |
|
| 40 | + if ( ! method_exists( $screen, 'add_help_tab' ) ) { |
|
| 41 | + return $help; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | 44 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
| 45 | 45 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
| 46 | 46 | if ( $page != 'formidable-entries' || ( ! empty( $action ) && $action != 'list' ) ) { |
| 47 | - return $help; |
|
| 48 | - } |
|
| 47 | + return $help; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | unset( $action, $page ); |
| 51 | 51 | |
| 52 | - $screen->add_help_tab( array( |
|
| 53 | - 'id' => 'formidable-entries-tab', |
|
| 54 | - 'title' => __( 'Overview', 'formidable' ), |
|
| 52 | + $screen->add_help_tab( array( |
|
| 53 | + 'id' => 'formidable-entries-tab', |
|
| 54 | + 'title' => __( 'Overview', 'formidable' ), |
|
| 55 | 55 | 'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>', |
| 56 | - )); |
|
| 56 | + )); |
|
| 57 | 57 | |
| 58 | - $screen->set_help_sidebar( |
|
| 58 | + $screen->set_help_sidebar( |
|
| 59 | 59 | '<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' . |
| 60 | 60 | '<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/knowledgebase/manage-entries-from-the-back-end/' ) ) . '" target="_blank">' . esc_html__( 'Documentation on Entries', 'formidable' ) . '</a></p>' . |
| 61 | 61 | '<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>' |
| 62 | - ); |
|
| 62 | + ); |
|
| 63 | 63 | |
| 64 | - return $help; |
|
| 65 | - } |
|
| 64 | + return $help; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | 67 | public static function manage_columns( $columns ) { |
| 68 | - global $frm_vars, $wpdb; |
|
| 68 | + global $frm_vars, $wpdb; |
|
| 69 | 69 | $form_id = FrmForm::get_current_form_id(); |
| 70 | 70 | |
| 71 | 71 | $columns[ $form_id . '_id' ] = 'ID'; |
| 72 | 72 | $columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' ); |
| 73 | 73 | |
| 74 | - if ( ! $form_id ) { |
|
| 75 | - return $columns; |
|
| 76 | - } |
|
| 74 | + if ( ! $form_id ) { |
|
| 75 | + return $columns; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - $form_cols = FrmField::get_all_for_form($form_id, '', 'include'); |
|
| 78 | + $form_cols = FrmField::get_all_for_form($form_id, '', 'include'); |
|
| 79 | 79 | |
| 80 | - foreach ( $form_cols as $form_col ) { |
|
| 80 | + foreach ( $form_cols as $form_col ) { |
|
| 81 | 81 | if ( FrmField::is_no_save_field( $form_col->type ) ) { |
| 82 | - continue; |
|
| 83 | - } |
|
| 82 | + continue; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) { |
|
| 85 | + if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) { |
|
| 86 | 86 | $sub_form_cols = FrmField::get_all_for_form( $form_col->field_options['form_select'] ); |
| 87 | 87 | |
| 88 | - if ( $sub_form_cols ) { |
|
| 89 | - foreach ( $sub_form_cols as $k => $sub_form_col ) { |
|
| 88 | + if ( $sub_form_cols ) { |
|
| 89 | + foreach ( $sub_form_cols as $k => $sub_form_col ) { |
|
| 90 | 90 | if ( FrmField::is_no_save_field( $sub_form_col->type ) ) { |
| 91 | - unset( $sub_form_cols[ $k ] ); |
|
| 92 | - continue; |
|
| 93 | - } |
|
| 91 | + unset( $sub_form_cols[ $k ] ); |
|
| 92 | + continue; |
|
| 93 | + } |
|
| 94 | 94 | $columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 ); |
| 95 | - unset($sub_form_col); |
|
| 96 | - } |
|
| 97 | - } |
|
| 98 | - unset($sub_form_cols); |
|
| 99 | - } else { |
|
| 100 | - $col_id = $form_col->field_key; |
|
| 101 | - if ( $form_col->form_id != $form_id ) { |
|
| 95 | + unset($sub_form_col); |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | + unset($sub_form_cols); |
|
| 99 | + } else { |
|
| 100 | + $col_id = $form_col->field_key; |
|
| 101 | + if ( $form_col->form_id != $form_id ) { |
|
| 102 | 102 | $col_id .= '-_-form' . $form_col->form_id; |
| 103 | - } |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) { |
|
| 105 | + if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) { |
|
| 106 | 106 | $columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
| 107 | - } |
|
| 107 | + } |
|
| 108 | 108 | $columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
| 109 | - } |
|
| 110 | - } |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | 112 | $columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' ); |
| 113 | 113 | $columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' ); |
| 114 | 114 | $columns[ $form_id . '_ip' ] = 'IP'; |
| 115 | 115 | |
| 116 | - $frm_vars['cols'] = $columns; |
|
| 116 | + $frm_vars['cols'] = $columns; |
|
| 117 | 117 | |
| 118 | 118 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
| 119 | 119 | if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) { |
| 120 | 120 | add_screen_option( 'per_page', array( 'label' => __( 'Entries', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page' ) ); |
| 121 | - } |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - return $columns; |
|
| 124 | - } |
|
| 123 | + return $columns; |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | 126 | public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) { |
| 127 | 127 | $menu_name = FrmAppHelper::get_menu_name(); |
| 128 | 128 | $this_page_name = 'manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden'; |
| 129 | 129 | if ( $meta_key != $this_page_name || $meta_value == $prev_value ) { |
| 130 | - return $check; |
|
| 131 | - } |
|
| 130 | + return $check; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | 133 | if ( empty( $prev_value ) ) { |
| 134 | 134 | $prev_value = get_metadata( 'user', $object_id, $meta_key, true ); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - global $frm_vars; |
|
| 138 | - //add a check so we don't create a loop |
|
| 139 | - $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
| 137 | + global $frm_vars; |
|
| 138 | + //add a check so we don't create a loop |
|
| 139 | + $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
| 140 | 140 | |
| 141 | - return $check; |
|
| 142 | - } |
|
| 141 | + return $check; |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - //add hidden columns back from other forms |
|
| 144 | + //add hidden columns back from other forms |
|
| 145 | 145 | public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) { |
| 146 | 146 | $menu_name = FrmAppHelper::get_menu_name(); |
| 147 | 147 | $sanitized = sanitize_title( $menu_name ); |
| 148 | 148 | $this_page_name = 'manage' . $sanitized . '_page_formidable-entriescolumnshidden'; |
| 149 | 149 | if ( $meta_key != $this_page_name ) { |
| 150 | - return; |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - global $frm_vars; |
|
| 154 | - if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) { |
|
| 155 | - return; //don't continue if there's no previous value |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - foreach ( $meta_value as $mk => $mv ) { |
|
| 159 | - //remove blank values |
|
| 160 | - if ( empty( $mv ) ) { |
|
| 161 | - unset( $meta_value[ $mk ] ); |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - $cur_form_prefix = reset($meta_value); |
|
| 166 | - $cur_form_prefix = explode('_', $cur_form_prefix); |
|
| 167 | - $cur_form_prefix = $cur_form_prefix[0]; |
|
| 168 | - $save = false; |
|
| 169 | - |
|
| 170 | - foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) { |
|
| 150 | + return; |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + global $frm_vars; |
|
| 154 | + if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) { |
|
| 155 | + return; //don't continue if there's no previous value |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + foreach ( $meta_value as $mk => $mv ) { |
|
| 159 | + //remove blank values |
|
| 160 | + if ( empty( $mv ) ) { |
|
| 161 | + unset( $meta_value[ $mk ] ); |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + $cur_form_prefix = reset($meta_value); |
|
| 166 | + $cur_form_prefix = explode('_', $cur_form_prefix); |
|
| 167 | + $cur_form_prefix = $cur_form_prefix[0]; |
|
| 168 | + $save = false; |
|
| 169 | + |
|
| 170 | + foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) { |
|
| 171 | 171 | if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) { |
| 172 | - //don't add blank cols or process included cols |
|
| 173 | - continue; |
|
| 174 | - } |
|
| 172 | + //don't add blank cols or process included cols |
|
| 173 | + continue; |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | 176 | $form_prefix = explode( '_', $prev_hidden ); |
| 177 | - $form_prefix = $form_prefix[0]; |
|
| 178 | - if ( $form_prefix == $cur_form_prefix ) { |
|
| 179 | - //don't add back columns that are meant to be hidden |
|
| 180 | - continue; |
|
| 181 | - } |
|
| 177 | + $form_prefix = $form_prefix[0]; |
|
| 178 | + if ( $form_prefix == $cur_form_prefix ) { |
|
| 179 | + //don't add back columns that are meant to be hidden |
|
| 180 | + continue; |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | - $meta_value[] = $prev_hidden; |
|
| 184 | - $save = true; |
|
| 185 | - unset($form_prefix); |
|
| 186 | - } |
|
| 183 | + $meta_value[] = $prev_hidden; |
|
| 184 | + $save = true; |
|
| 185 | + unset($form_prefix); |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | 188 | if ( $save ) { |
| 189 | - $user = wp_get_current_user(); |
|
| 189 | + $user = wp_get_current_user(); |
|
| 190 | 190 | update_user_option( $user->ID, $this_page_name, $meta_value, true ); |
| 191 | - } |
|
| 192 | - } |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | 194 | public static function save_per_page( $save, $option, $value ) { |
| 195 | - if ( $option == 'formidable_page_formidable_entries_per_page' ) { |
|
| 196 | - $save = (int) $value; |
|
| 197 | - } |
|
| 198 | - return $save; |
|
| 199 | - } |
|
| 195 | + if ( $option == 'formidable_page_formidable_entries_per_page' ) { |
|
| 196 | + $save = (int) $value; |
|
| 197 | + } |
|
| 198 | + return $save; |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | 201 | public static function sortable_columns() { |
| 202 | 202 | $form_id = FrmForm::get_current_form_id(); |
@@ -222,122 +222,122 @@ discard block |
||
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | public static function hidden_columns( $result ) { |
| 225 | - global $frm_vars; |
|
| 225 | + global $frm_vars; |
|
| 226 | 226 | |
| 227 | 227 | $form_id = FrmForm::get_current_form_id(); |
| 228 | 228 | |
| 229 | - $return = false; |
|
| 230 | - foreach ( (array) $result as $r ) { |
|
| 231 | - if ( ! empty( $r ) ) { |
|
| 232 | - $form_prefix = explode( '_', $r ); |
|
| 233 | - $form_prefix = $form_prefix[0]; |
|
| 229 | + $return = false; |
|
| 230 | + foreach ( (array) $result as $r ) { |
|
| 231 | + if ( ! empty( $r ) ) { |
|
| 232 | + $form_prefix = explode( '_', $r ); |
|
| 233 | + $form_prefix = $form_prefix[0]; |
|
| 234 | 234 | |
| 235 | - if ( (int) $form_prefix == (int) $form_id ) { |
|
| 236 | - $return = true; |
|
| 237 | - break; |
|
| 238 | - } |
|
| 235 | + if ( (int) $form_prefix == (int) $form_id ) { |
|
| 236 | + $return = true; |
|
| 237 | + break; |
|
| 238 | + } |
|
| 239 | 239 | |
| 240 | - unset($form_prefix); |
|
| 241 | - } |
|
| 242 | - } |
|
| 240 | + unset($form_prefix); |
|
| 241 | + } |
|
| 242 | + } |
|
| 243 | 243 | |
| 244 | - if ( $return ) { |
|
| 244 | + if ( $return ) { |
|
| 245 | 245 | return $result; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0; |
|
| 249 | - $max_columns = 8; |
|
| 250 | - if ( $i <= $max_columns ) { |
|
| 248 | + $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0; |
|
| 249 | + $max_columns = 8; |
|
| 250 | + if ( $i <= $max_columns ) { |
|
| 251 | 251 | return $result; |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - global $frm_vars; |
|
| 255 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) { |
|
| 256 | - $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options); |
|
| 257 | - } |
|
| 254 | + global $frm_vars; |
|
| 255 | + if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) { |
|
| 256 | + $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options); |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) { |
|
| 260 | - $result = $frm_vars['current_form']->options['hidden_cols']; |
|
| 261 | - } else { |
|
| 262 | - $cols = $frm_vars['cols']; |
|
| 263 | - $cols = array_reverse($cols, true); |
|
| 259 | + if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) { |
|
| 260 | + $result = $frm_vars['current_form']->options['hidden_cols']; |
|
| 261 | + } else { |
|
| 262 | + $cols = $frm_vars['cols']; |
|
| 263 | + $cols = array_reverse($cols, true); |
|
| 264 | 264 | |
| 265 | 265 | $result[] = $form_id . '_id'; |
| 266 | - $i--; |
|
| 266 | + $i--; |
|
| 267 | 267 | |
| 268 | 268 | $result[] = $form_id . '_item_key'; |
| 269 | - $i--; |
|
| 269 | + $i--; |
|
| 270 | 270 | |
| 271 | 271 | foreach ( $cols as $col_key => $col ) { |
| 272 | - if ( $i > $max_columns ) { |
|
| 272 | + if ( $i > $max_columns ) { |
|
| 273 | 273 | $result[] = $col_key; |
| 274 | 274 | } |
| 275 | - //remove some columns by default |
|
| 276 | - $i--; |
|
| 277 | - unset($col_key, $col); |
|
| 278 | - } |
|
| 279 | - } |
|
| 275 | + //remove some columns by default |
|
| 276 | + $i--; |
|
| 277 | + unset($col_key, $col); |
|
| 278 | + } |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | - return $result; |
|
| 282 | - } |
|
| 281 | + return $result; |
|
| 282 | + } |
|
| 283 | 283 | |
| 284 | 284 | public static function display_list( $message = '', $errors = array() ) { |
| 285 | - global $wpdb, $frm_vars; |
|
| 285 | + global $wpdb, $frm_vars; |
|
| 286 | 286 | |
| 287 | 287 | $form = FrmForm::get_current_form(); |
| 288 | 288 | $params = FrmForm::get_admin_params( $form ); |
| 289 | 289 | |
| 290 | - if ( $form ) { |
|
| 291 | - $params['form'] = $form->id; |
|
| 292 | - $frm_vars['current_form'] = $form; |
|
| 290 | + if ( $form ) { |
|
| 291 | + $params['form'] = $form->id; |
|
| 292 | + $frm_vars['current_form'] = $form; |
|
| 293 | 293 | |
| 294 | - if ( 'trash' == $form->status ) { |
|
| 295 | - $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); |
|
| 296 | - $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) ); |
|
| 297 | - $errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete ); |
|
| 298 | - unset( $time_to_delete, $delete_timestamp ); |
|
| 299 | - } |
|
| 294 | + if ( 'trash' == $form->status ) { |
|
| 295 | + $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); |
|
| 296 | + $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) ); |
|
| 297 | + $errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete ); |
|
| 298 | + unset( $time_to_delete, $delete_timestamp ); |
|
| 299 | + } |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | - $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' ); |
|
| 302 | + $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' ); |
|
| 303 | 303 | |
| 304 | - $wp_list_table = new $table_class( array( 'params' => $params ) ); |
|
| 304 | + $wp_list_table = new $table_class( array( 'params' => $params ) ); |
|
| 305 | 305 | |
| 306 | - $pagenum = $wp_list_table->get_pagenum(); |
|
| 306 | + $pagenum = $wp_list_table->get_pagenum(); |
|
| 307 | 307 | |
| 308 | - $wp_list_table->prepare_items(); |
|
| 308 | + $wp_list_table->prepare_items(); |
|
| 309 | 309 | |
| 310 | - $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 311 | - if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 310 | + $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 311 | + if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 312 | 312 | $url = add_query_arg( 'paged', $total_pages ); |
| 313 | - if ( headers_sent() ) { |
|
| 314 | - echo FrmAppHelper::js_redirect($url); |
|
| 315 | - } else { |
|
| 316 | - wp_redirect( esc_url_raw( $url ) ); |
|
| 317 | - } |
|
| 318 | - die(); |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - if ( empty($message) && isset($_GET['import-message']) ) { |
|
| 322 | - $message = __( 'Your import is complete', 'formidable' ); |
|
| 323 | - } |
|
| 313 | + if ( headers_sent() ) { |
|
| 314 | + echo FrmAppHelper::js_redirect($url); |
|
| 315 | + } else { |
|
| 316 | + wp_redirect( esc_url_raw( $url ) ); |
|
| 317 | + } |
|
| 318 | + die(); |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + if ( empty($message) && isset($_GET['import-message']) ) { |
|
| 322 | + $message = __( 'Your import is complete', 'formidable' ); |
|
| 323 | + } |
|
| 324 | 324 | |
| 325 | 325 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' ); |
| 326 | - } |
|
| 326 | + } |
|
| 327 | 327 | |
| 328 | - /* Back End CRUD */ |
|
| 328 | + /* Back End CRUD */ |
|
| 329 | 329 | public static function show( $id = 0 ) { |
| 330 | - FrmAppHelper::permission_check('frm_view_entries'); |
|
| 330 | + FrmAppHelper::permission_check('frm_view_entries'); |
|
| 331 | 331 | |
| 332 | - if ( ! $id ) { |
|
| 332 | + if ( ! $id ) { |
|
| 333 | 333 | $id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' ); |
| 334 | 334 | |
| 335 | - if ( ! $id ) { |
|
| 335 | + if ( ! $id ) { |
|
| 336 | 336 | $id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' ); |
| 337 | - } |
|
| 338 | - } |
|
| 337 | + } |
|
| 338 | + } |
|
| 339 | 339 | |
| 340 | - $entry = FrmEntry::getOne($id, true); |
|
| 340 | + $entry = FrmEntry::getOne($id, true); |
|
| 341 | 341 | if ( ! $entry ) { |
| 342 | 342 | echo '<div id="form_show_entry_page" class="wrap">' . |
| 343 | 343 | __( 'You are trying to view an entry that does not exist.', 'formidable' ) . |
@@ -345,110 +345,110 @@ discard block |
||
| 345 | 345 | return; |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | - $data = maybe_unserialize($entry->description); |
|
| 348 | + $data = maybe_unserialize($entry->description); |
|
| 349 | 349 | if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) { |
| 350 | 350 | $data = array( 'referrer' => $data ); |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | $fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' ); |
| 354 | - $to_emails = array(); |
|
| 354 | + $to_emails = array(); |
|
| 355 | 355 | |
| 356 | 356 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' ); |
| 357 | - } |
|
| 357 | + } |
|
| 358 | 358 | |
| 359 | - public static function destroy() { |
|
| 360 | - FrmAppHelper::permission_check('frm_delete_entries'); |
|
| 359 | + public static function destroy() { |
|
| 360 | + FrmAppHelper::permission_check('frm_delete_entries'); |
|
| 361 | 361 | |
| 362 | 362 | $params = FrmForm::get_admin_params(); |
| 363 | 363 | |
| 364 | - if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
| 365 | - //unlink entry from post |
|
| 366 | - global $wpdb; |
|
| 364 | + if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
| 365 | + //unlink entry from post |
|
| 366 | + global $wpdb; |
|
| 367 | 367 | $wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) ); |
| 368 | - } |
|
| 368 | + } |
|
| 369 | 369 | |
| 370 | - $message = ''; |
|
| 371 | - if ( FrmEntry::destroy( $params['id'] ) ) { |
|
| 372 | - $message = __( 'Entry was Successfully Destroyed', 'formidable' ); |
|
| 373 | - } |
|
| 370 | + $message = ''; |
|
| 371 | + if ( FrmEntry::destroy( $params['id'] ) ) { |
|
| 372 | + $message = __( 'Entry was Successfully Destroyed', 'formidable' ); |
|
| 373 | + } |
|
| 374 | 374 | |
| 375 | - self::display_list( $message ); |
|
| 376 | - } |
|
| 375 | + self::display_list( $message ); |
|
| 376 | + } |
|
| 377 | 377 | |
| 378 | - public static function destroy_all() { |
|
| 379 | - if ( ! current_user_can( 'frm_delete_entries' ) ) { |
|
| 380 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 381 | - wp_die( $frm_settings->admin_permission ); |
|
| 382 | - } |
|
| 378 | + public static function destroy_all() { |
|
| 379 | + if ( ! current_user_can( 'frm_delete_entries' ) ) { |
|
| 380 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 381 | + wp_die( $frm_settings->admin_permission ); |
|
| 382 | + } |
|
| 383 | 383 | |
| 384 | - global $wpdb; |
|
| 384 | + global $wpdb; |
|
| 385 | 385 | $params = FrmForm::get_admin_params(); |
| 386 | - $message = ''; |
|
| 387 | - $errors = array(); |
|
| 388 | - $form_id = (int) $params['form']; |
|
| 386 | + $message = ''; |
|
| 387 | + $errors = array(); |
|
| 388 | + $form_id = (int) $params['form']; |
|
| 389 | 389 | |
| 390 | - if ( $form_id ) { |
|
| 391 | - $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) ); |
|
| 390 | + if ( $form_id ) { |
|
| 391 | + $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) ); |
|
| 392 | 392 | $action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 ); |
| 393 | 393 | |
| 394 | - if ( $action ) { |
|
| 395 | - // this action takes a while, so only trigger it if there are posts to delete |
|
| 396 | - foreach ( $entry_ids as $entry_id ) { |
|
| 397 | - do_action( 'frm_before_destroy_entry', $entry_id ); |
|
| 398 | - unset( $entry_id ); |
|
| 399 | - } |
|
| 400 | - } |
|
| 401 | - |
|
| 402 | - $wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) ); |
|
| 403 | - $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) ); |
|
| 404 | - if ( $results ) { |
|
| 394 | + if ( $action ) { |
|
| 395 | + // this action takes a while, so only trigger it if there are posts to delete |
|
| 396 | + foreach ( $entry_ids as $entry_id ) { |
|
| 397 | + do_action( 'frm_before_destroy_entry', $entry_id ); |
|
| 398 | + unset( $entry_id ); |
|
| 399 | + } |
|
| 400 | + } |
|
| 401 | + |
|
| 402 | + $wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) ); |
|
| 403 | + $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) ); |
|
| 404 | + if ( $results ) { |
|
| 405 | 405 | FrmEntry::clear_cache(); |
| 406 | - $message = __( 'Entries were Successfully Destroyed', 'formidable' ); |
|
| 407 | - } |
|
| 408 | - } else { |
|
| 409 | - $errors = __( 'No entries were specified', 'formidable' ); |
|
| 410 | - } |
|
| 411 | - |
|
| 412 | - self::display_list( $message, $errors ); |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - public static function show_form( $id = '', $key = '', $title = false, $description = false ) { |
|
| 416 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' ); |
|
| 417 | - return FrmFormsController::show_form( $id, $key, $title, $description ); |
|
| 418 | - } |
|
| 419 | - |
|
| 420 | - public static function get_form( $filename, $form, $title, $description ) { |
|
| 421 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' ); |
|
| 422 | - return FrmFormsController::get_form( $form, $title, $description ); |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - public static function process_entry( $errors = '', $ajax = false ) { |
|
| 406 | + $message = __( 'Entries were Successfully Destroyed', 'formidable' ); |
|
| 407 | + } |
|
| 408 | + } else { |
|
| 409 | + $errors = __( 'No entries were specified', 'formidable' ); |
|
| 410 | + } |
|
| 411 | + |
|
| 412 | + self::display_list( $message, $errors ); |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + public static function show_form( $id = '', $key = '', $title = false, $description = false ) { |
|
| 416 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' ); |
|
| 417 | + return FrmFormsController::show_form( $id, $key, $title, $description ); |
|
| 418 | + } |
|
| 419 | + |
|
| 420 | + public static function get_form( $filename, $form, $title, $description ) { |
|
| 421 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' ); |
|
| 422 | + return FrmFormsController::get_form( $form, $title, $description ); |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + public static function process_entry( $errors = '', $ajax = false ) { |
|
| 426 | 426 | $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' ); |
| 427 | 427 | if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) { |
| 428 | - return; |
|
| 429 | - } |
|
| 428 | + return; |
|
| 429 | + } |
|
| 430 | 430 | |
| 431 | - global $frm_vars; |
|
| 431 | + global $frm_vars; |
|
| 432 | 432 | |
| 433 | 433 | $form = FrmForm::getOne( $form_id ); |
| 434 | - if ( ! $form ) { |
|
| 435 | - return; |
|
| 436 | - } |
|
| 434 | + if ( ! $form ) { |
|
| 435 | + return; |
|
| 436 | + } |
|
| 437 | 437 | |
| 438 | 438 | $params = FrmForm::get_params( $form ); |
| 439 | 439 | |
| 440 | - if ( ! isset( $frm_vars['form_params'] ) ) { |
|
| 441 | - $frm_vars['form_params'] = array(); |
|
| 442 | - } |
|
| 440 | + if ( ! isset( $frm_vars['form_params'] ) ) { |
|
| 441 | + $frm_vars['form_params'] = array(); |
|
| 442 | + } |
|
| 443 | 443 | $frm_vars['form_params'][ $form->id ] = $params; |
| 444 | 444 | |
| 445 | 445 | if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) { |
| 446 | - return; |
|
| 447 | - } |
|
| 446 | + return; |
|
| 447 | + } |
|
| 448 | 448 | |
| 449 | - if ( $errors == '' && ! $ajax ) { |
|
| 449 | + if ( $errors == '' && ! $ajax ) { |
|
| 450 | 450 | $errors = FrmEntryValidate::validate( $_POST ); |
| 451 | - } |
|
| 451 | + } |
|
| 452 | 452 | |
| 453 | 453 | /** |
| 454 | 454 | * Use this filter to add trigger actions and add errors after |
@@ -459,54 +459,54 @@ discard block |
||
| 459 | 459 | |
| 460 | 460 | $frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors ); |
| 461 | 461 | |
| 462 | - if ( empty( $errors ) ) { |
|
| 462 | + if ( empty( $errors ) ) { |
|
| 463 | 463 | $_POST['frm_skip_cookie'] = 1; |
| 464 | - if ( $params['action'] == 'create' ) { |
|
| 464 | + if ( $params['action'] == 'create' ) { |
|
| 465 | 465 | if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) { |
| 466 | 466 | $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); |
| 467 | - } |
|
| 468 | - } |
|
| 467 | + } |
|
| 468 | + } |
|
| 469 | 469 | |
| 470 | - do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); |
|
| 470 | + do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); |
|
| 471 | 471 | unset( $_POST['frm_skip_cookie'] ); |
| 472 | - } |
|
| 473 | - } |
|
| 474 | - |
|
| 475 | - public static function delete_entry_before_redirect( $url, $form, $atts ) { |
|
| 476 | - self::_delete_entry( $atts['id'], $form ); |
|
| 477 | - return $url; |
|
| 478 | - } |
|
| 479 | - |
|
| 480 | - //Delete entry if not redirected |
|
| 481 | - public static function delete_entry_after_save( $atts ) { |
|
| 482 | - self::_delete_entry( $atts['entry_id'], $atts['form'] ); |
|
| 483 | - } |
|
| 484 | - |
|
| 485 | - private static function _delete_entry( $entry_id, $form ) { |
|
| 486 | - if ( ! $form ) { |
|
| 487 | - return; |
|
| 488 | - } |
|
| 489 | - |
|
| 490 | - $form->options = maybe_unserialize( $form->options ); |
|
| 491 | - if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) { |
|
| 492 | - FrmEntry::destroy( $entry_id ); |
|
| 493 | - } |
|
| 494 | - } |
|
| 472 | + } |
|
| 473 | + } |
|
| 474 | + |
|
| 475 | + public static function delete_entry_before_redirect( $url, $form, $atts ) { |
|
| 476 | + self::_delete_entry( $atts['id'], $form ); |
|
| 477 | + return $url; |
|
| 478 | + } |
|
| 479 | + |
|
| 480 | + //Delete entry if not redirected |
|
| 481 | + public static function delete_entry_after_save( $atts ) { |
|
| 482 | + self::_delete_entry( $atts['entry_id'], $atts['form'] ); |
|
| 483 | + } |
|
| 484 | + |
|
| 485 | + private static function _delete_entry( $entry_id, $form ) { |
|
| 486 | + if ( ! $form ) { |
|
| 487 | + return; |
|
| 488 | + } |
|
| 489 | + |
|
| 490 | + $form->options = maybe_unserialize( $form->options ); |
|
| 491 | + if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) { |
|
| 492 | + FrmEntry::destroy( $entry_id ); |
|
| 493 | + } |
|
| 494 | + } |
|
| 495 | 495 | |
| 496 | 496 | public static function show_entry_shortcode( $atts ) { |
| 497 | 497 | return FrmEntryFormat::show_entry( $atts ); |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | public static function filter_shortcode_value( $value, $tag, $atts, $field ) { |
| 501 | - $plain_text = add_filter('frm_plain_text_email', true); |
|
| 501 | + $plain_text = add_filter('frm_plain_text_email', true); |
|
| 502 | 502 | FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value ); |
| 503 | 503 | |
| 504 | - if ( isset($atts['show']) && $atts['show'] == 'value' ) { |
|
| 505 | - return $value; |
|
| 506 | - } |
|
| 504 | + if ( isset($atts['show']) && $atts['show'] == 'value' ) { |
|
| 505 | + return $value; |
|
| 506 | + } |
|
| 507 | 507 | |
| 508 | - return $value; |
|
| 509 | - } |
|
| 508 | + return $value; |
|
| 509 | + } |
|
| 510 | 510 | |
| 511 | 511 | public static function get_params( $form = null ) { |
| 512 | 512 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_params' ); |
@@ -514,15 +514,15 @@ discard block |
||
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | public static function entry_sidebar( $entry ) { |
| 517 | - $data = maybe_unserialize($entry->description); |
|
| 518 | - $date_format = get_option('date_format'); |
|
| 519 | - $time_format = get_option('time_format'); |
|
| 517 | + $data = maybe_unserialize($entry->description); |
|
| 518 | + $date_format = get_option('date_format'); |
|
| 519 | + $time_format = get_option('time_format'); |
|
| 520 | 520 | if ( isset( $data['browser'] ) ) { |
| 521 | 521 | $browser = FrmEntryFormat::get_browser( $data['browser'] ); |
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' ); |
| 525 | - } |
|
| 525 | + } |
|
| 526 | 526 | |
| 527 | 527 | /*********************************************************************** |
| 528 | 528 | * Deprecated Functions |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | public static function menu() { |
| 6 | 6 | FrmAppHelper::force_capability( 'frm_view_entries' ); |
| 7 | 7 | |
| 8 | - add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
| 8 | + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
| 9 | 9 | |
| 10 | 10 | if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) { |
| 11 | 11 | $menu_name = FrmAppHelper::get_menu_name(); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | 'id' => 'formidable-entries-tab', |
| 54 | 54 | 'title' => __( 'Overview', 'formidable' ), |
| 55 | 55 | 'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>', |
| 56 | - )); |
|
| 56 | + ) ); |
|
| 57 | 57 | |
| 58 | 58 | $screen->set_help_sidebar( |
| 59 | 59 | '<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' . |
@@ -68,14 +68,14 @@ discard block |
||
| 68 | 68 | global $frm_vars, $wpdb; |
| 69 | 69 | $form_id = FrmForm::get_current_form_id(); |
| 70 | 70 | |
| 71 | - $columns[ $form_id . '_id' ] = 'ID'; |
|
| 72 | - $columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' ); |
|
| 71 | + $columns[$form_id . '_id'] = 'ID'; |
|
| 72 | + $columns[$form_id . '_item_key'] = esc_html__( 'Entry Key', 'formidable' ); |
|
| 73 | 73 | |
| 74 | 74 | if ( ! $form_id ) { |
| 75 | 75 | return $columns; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - $form_cols = FrmField::get_all_for_form($form_id, '', 'include'); |
|
| 78 | + $form_cols = FrmField::get_all_for_form( $form_id, '', 'include' ); |
|
| 79 | 79 | |
| 80 | 80 | foreach ( $form_cols as $form_col ) { |
| 81 | 81 | if ( FrmField::is_no_save_field( $form_col->type ) ) { |
@@ -88,30 +88,30 @@ discard block |
||
| 88 | 88 | if ( $sub_form_cols ) { |
| 89 | 89 | foreach ( $sub_form_cols as $k => $sub_form_col ) { |
| 90 | 90 | if ( FrmField::is_no_save_field( $sub_form_col->type ) ) { |
| 91 | - unset( $sub_form_cols[ $k ] ); |
|
| 91 | + unset( $sub_form_cols[$k] ); |
|
| 92 | 92 | continue; |
| 93 | 93 | } |
| 94 | - $columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 ); |
|
| 95 | - unset($sub_form_col); |
|
| 94 | + $columns[$form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id] = FrmAppHelper::truncate( $sub_form_col->name, 35 ); |
|
| 95 | + unset( $sub_form_col ); |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | - unset($sub_form_cols); |
|
| 98 | + unset( $sub_form_cols ); |
|
| 99 | 99 | } else { |
| 100 | 100 | $col_id = $form_col->field_key; |
| 101 | 101 | if ( $form_col->form_id != $form_id ) { |
| 102 | 102 | $col_id .= '-_-form' . $form_col->form_id; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) { |
|
| 106 | - $columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
| 105 | + if ( isset( $form_col->field_options['separate_value'] ) && $form_col->field_options['separate_value'] ) { |
|
| 106 | + $columns[$form_id . '_frmsep_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
| 107 | 107 | } |
| 108 | - $columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
| 108 | + $columns[$form_id . '_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - $columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' ); |
|
| 113 | - $columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' ); |
|
| 114 | - $columns[ $form_id . '_ip' ] = 'IP'; |
|
| 112 | + $columns[$form_id . '_created_at'] = __( 'Entry creation date', 'formidable' ); |
|
| 113 | + $columns[$form_id . '_updated_at'] = __( 'Entry update date', 'formidable' ); |
|
| 114 | + $columns[$form_id . '_ip'] = 'IP'; |
|
| 115 | 115 | |
| 116 | 116 | $frm_vars['cols'] = $columns; |
| 117 | 117 | |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | global $frm_vars; |
| 138 | 138 | //add a check so we don't create a loop |
| 139 | - $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
| 139 | + $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
| 140 | 140 | |
| 141 | 141 | return $check; |
| 142 | 142 | } |
@@ -151,19 +151,19 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | global $frm_vars; |
| 154 | - if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) { |
|
| 154 | + if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) { |
|
| 155 | 155 | return; //don't continue if there's no previous value |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | foreach ( $meta_value as $mk => $mv ) { |
| 159 | 159 | //remove blank values |
| 160 | - if ( empty( $mv ) ) { |
|
| 161 | - unset( $meta_value[ $mk ] ); |
|
| 160 | + if ( empty( $mv ) ) { |
|
| 161 | + unset( $meta_value[$mk] ); |
|
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - $cur_form_prefix = reset($meta_value); |
|
| 166 | - $cur_form_prefix = explode('_', $cur_form_prefix); |
|
| 165 | + $cur_form_prefix = reset( $meta_value ); |
|
| 166 | + $cur_form_prefix = explode( '_', $cur_form_prefix ); |
|
| 167 | 167 | $cur_form_prefix = $cur_form_prefix[0]; |
| 168 | 168 | $save = false; |
| 169 | 169 | |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | |
| 183 | 183 | $meta_value[] = $prev_hidden; |
| 184 | 184 | $save = true; |
| 185 | - unset($form_prefix); |
|
| 185 | + unset( $form_prefix ); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | if ( $save ) { |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | foreach ( $fields as $field ) { |
| 215 | 215 | if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) { |
| 216 | 216 | // Can't sort on checkboxes because they are stored serialized, or post fields |
| 217 | - $columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id; |
|
| 217 | + $columns[$form_id . '_' . $field->field_key] = 'meta_' . $field->id; |
|
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | break; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - unset($form_prefix); |
|
| 240 | + unset( $form_prefix ); |
|
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | 243 | |
@@ -245,36 +245,36 @@ discard block |
||
| 245 | 245 | return $result; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0; |
|
| 248 | + $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0; |
|
| 249 | 249 | $max_columns = 8; |
| 250 | 250 | if ( $i <= $max_columns ) { |
| 251 | 251 | return $result; |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | global $frm_vars; |
| 255 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) { |
|
| 256 | - $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options); |
|
| 255 | + if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] ) { |
|
| 256 | + $frm_vars['current_form']->options = maybe_unserialize( $frm_vars['current_form']->options ); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) { |
|
| 259 | + if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && isset( $frm_vars['current_form']->options['hidden_cols'] ) && ! empty( $frm_vars['current_form']->options['hidden_cols'] ) ) { |
|
| 260 | 260 | $result = $frm_vars['current_form']->options['hidden_cols']; |
| 261 | 261 | } else { |
| 262 | 262 | $cols = $frm_vars['cols']; |
| 263 | - $cols = array_reverse($cols, true); |
|
| 263 | + $cols = array_reverse( $cols, true ); |
|
| 264 | 264 | |
| 265 | 265 | $result[] = $form_id . '_id'; |
| 266 | - $i--; |
|
| 266 | + $i --; |
|
| 267 | 267 | |
| 268 | 268 | $result[] = $form_id . '_item_key'; |
| 269 | - $i--; |
|
| 269 | + $i --; |
|
| 270 | 270 | |
| 271 | 271 | foreach ( $cols as $col_key => $col ) { |
| 272 | 272 | if ( $i > $max_columns ) { |
| 273 | 273 | $result[] = $col_key; |
| 274 | 274 | } |
| 275 | 275 | //remove some columns by default |
| 276 | - $i--; |
|
| 277 | - unset($col_key, $col); |
|
| 276 | + $i --; |
|
| 277 | + unset( $col_key, $col ); |
|
| 278 | 278 | } |
| 279 | 279 | } |
| 280 | 280 | |
@@ -311,14 +311,14 @@ discard block |
||
| 311 | 311 | if ( $pagenum > $total_pages && $total_pages > 0 ) { |
| 312 | 312 | $url = add_query_arg( 'paged', $total_pages ); |
| 313 | 313 | if ( headers_sent() ) { |
| 314 | - echo FrmAppHelper::js_redirect($url); |
|
| 314 | + echo FrmAppHelper::js_redirect( $url ); |
|
| 315 | 315 | } else { |
| 316 | 316 | wp_redirect( esc_url_raw( $url ) ); |
| 317 | 317 | } |
| 318 | 318 | die(); |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - if ( empty($message) && isset($_GET['import-message']) ) { |
|
| 321 | + if ( empty( $message ) && isset( $_GET['import-message'] ) ) { |
|
| 322 | 322 | $message = __( 'Your import is complete', 'formidable' ); |
| 323 | 323 | } |
| 324 | 324 | |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | |
| 328 | 328 | /* Back End CRUD */ |
| 329 | 329 | public static function show( $id = 0 ) { |
| 330 | - FrmAppHelper::permission_check('frm_view_entries'); |
|
| 330 | + FrmAppHelper::permission_check( 'frm_view_entries' ); |
|
| 331 | 331 | |
| 332 | 332 | if ( ! $id ) { |
| 333 | 333 | $id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' ); |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | } |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - $entry = FrmEntry::getOne($id, true); |
|
| 340 | + $entry = FrmEntry::getOne( $id, true ); |
|
| 341 | 341 | if ( ! $entry ) { |
| 342 | 342 | echo '<div id="form_show_entry_page" class="wrap">' . |
| 343 | 343 | __( 'You are trying to view an entry that does not exist.', 'formidable' ) . |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | return; |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | - $data = maybe_unserialize($entry->description); |
|
| 348 | + $data = maybe_unserialize( $entry->description ); |
|
| 349 | 349 | if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) { |
| 350 | 350 | $data = array( 'referrer' => $data ); |
| 351 | 351 | } |
@@ -357,11 +357,11 @@ discard block |
||
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | public static function destroy() { |
| 360 | - FrmAppHelper::permission_check('frm_delete_entries'); |
|
| 360 | + FrmAppHelper::permission_check( 'frm_delete_entries' ); |
|
| 361 | 361 | |
| 362 | 362 | $params = FrmForm::get_admin_params(); |
| 363 | 363 | |
| 364 | - if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
| 364 | + if ( isset( $params['keep_post'] ) && $params['keep_post'] ) { |
|
| 365 | 365 | //unlink entry from post |
| 366 | 366 | global $wpdb; |
| 367 | 367 | $wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) ); |
@@ -440,9 +440,9 @@ discard block |
||
| 440 | 440 | if ( ! isset( $frm_vars['form_params'] ) ) { |
| 441 | 441 | $frm_vars['form_params'] = array(); |
| 442 | 442 | } |
| 443 | - $frm_vars['form_params'][ $form->id ] = $params; |
|
| 443 | + $frm_vars['form_params'][$form->id] = $params; |
|
| 444 | 444 | |
| 445 | - if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) { |
|
| 445 | + if ( isset( $frm_vars['created_entries'][$form_id] ) ) { |
|
| 446 | 446 | return; |
| 447 | 447 | } |
| 448 | 448 | |
@@ -457,13 +457,13 @@ discard block |
||
| 457 | 457 | */ |
| 458 | 458 | $errors = apply_filters( 'frm_entries_before_create', $errors, $form ); |
| 459 | 459 | |
| 460 | - $frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors ); |
|
| 460 | + $frm_vars['created_entries'][$form_id] = array( 'errors' => $errors ); |
|
| 461 | 461 | |
| 462 | 462 | if ( empty( $errors ) ) { |
| 463 | 463 | $_POST['frm_skip_cookie'] = 1; |
| 464 | 464 | if ( $params['action'] == 'create' ) { |
| 465 | - if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) { |
|
| 466 | - $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); |
|
| 465 | + if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) { |
|
| 466 | + $frm_vars['created_entries'][$form_id]['entry_id'] = FrmEntry::create( $_POST ); |
|
| 467 | 467 | } |
| 468 | 468 | } |
| 469 | 469 | |
@@ -498,10 +498,10 @@ discard block |
||
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | public static function filter_shortcode_value( $value, $tag, $atts, $field ) { |
| 501 | - $plain_text = add_filter('frm_plain_text_email', true); |
|
| 501 | + $plain_text = add_filter( 'frm_plain_text_email', true ); |
|
| 502 | 502 | FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value ); |
| 503 | 503 | |
| 504 | - if ( isset($atts['show']) && $atts['show'] == 'value' ) { |
|
| 504 | + if ( isset( $atts['show'] ) && $atts['show'] == 'value' ) { |
|
| 505 | 505 | return $value; |
| 506 | 506 | } |
| 507 | 507 | |
@@ -514,9 +514,9 @@ discard block |
||
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | public static function entry_sidebar( $entry ) { |
| 517 | - $data = maybe_unserialize($entry->description); |
|
| 518 | - $date_format = get_option('date_format'); |
|
| 519 | - $time_format = get_option('time_format'); |
|
| 517 | + $data = maybe_unserialize( $entry->description ); |
|
| 518 | + $date_format = get_option( 'date_format' ); |
|
| 519 | + $time_format = get_option( 'time_format' ); |
|
| 520 | 520 | if ( isset( $data['browser'] ) ) { |
| 521 | 521 | $browser = FrmEntryFormat::get_browser( $data['browser'] ); |
| 522 | 522 | } |