@@ -267,6 +267,9 @@ discard block |
||
| 267 | 267 | <?php |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | + /** |
|
| 271 | + * @param string $param_name |
|
| 272 | + */ |
|
| 270 | 273 | private function hidden_search_inputs( $param_name ) { |
| 271 | 274 | if ( ! empty( $_REQUEST[ $param_name ] ) ) { |
| 272 | 275 | echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[ $param_name ] ) . '" />'; |
@@ -405,6 +408,9 @@ discard block |
||
| 405 | 408 | return $action; |
| 406 | 409 | } |
| 407 | 410 | |
| 411 | + /** |
|
| 412 | + * @param string $action_name |
|
| 413 | + */ |
|
| 408 | 414 | private static function get_bulk_action( $action_name ) { |
| 409 | 415 | $action = false; |
| 410 | 416 | $action_param = self::get_param( |
@@ -67,10 +67,10 @@ discard block |
||
| 67 | 67 | protected $modes = array(); |
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | - * |
|
| 71 | - * @var array |
|
| 72 | - */ |
|
| 73 | - protected $params; |
|
| 70 | + * |
|
| 71 | + * @var array |
|
| 72 | + */ |
|
| 73 | + protected $params; |
|
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | 76 | * Stores the value returned by ->get_column_info() |
@@ -84,8 +84,8 @@ discard block |
||
| 84 | 84 | protected $compat_methods = array( 'set_pagination_args', 'get_views', 'get_bulk_actions', 'bulk_actions', 'row_actions', 'view_switcher', 'get_items_per_page', 'pagination', 'get_sortable_columns', 'get_column_info', 'get_table_classes', 'display_tablenav', 'extra_tablenav', 'single_row_columns' ); |
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | - * Construct the table object |
|
| 88 | - */ |
|
| 87 | + * Construct the table object |
|
| 88 | + */ |
|
| 89 | 89 | public function __construct( $args ) { |
| 90 | 90 | $args = wp_parse_args( |
| 91 | 91 | $args, |
@@ -6,10 +6,10 @@ discard block |
||
| 6 | 6 | protected $field; |
| 7 | 7 | |
| 8 | 8 | public function prepare_items() { |
| 9 | - global $per_page; |
|
| 9 | + global $per_page; |
|
| 10 | 10 | |
| 11 | 11 | $per_page = $this->get_items_per_page( 'formidable_page_formidable_entries_per_page' ); |
| 12 | - $form_id = $this->params['form']; |
|
| 12 | + $form_id = $this->params['form']; |
|
| 13 | 13 | |
| 14 | 14 | $s_query = array(); |
| 15 | 15 | |
@@ -88,16 +88,16 @@ discard block |
||
| 88 | 88 | ); |
| 89 | 89 | if ( ! empty( $s ) ) { |
| 90 | 90 | esc_html_e( 'No Entries Found', 'formidable' ); |
| 91 | - return; |
|
| 92 | - } |
|
| 91 | + return; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | 94 | $form_id = $this->params['form']; |
| 95 | 95 | $form = $this->params['form']; |
| 96 | 96 | |
| 97 | - if ( $form_id ) { |
|
| 97 | + if ( $form_id ) { |
|
| 98 | 98 | $form = FrmForm::getOne( $form_id ); |
| 99 | - } |
|
| 100 | - $colspan = $this->get_column_count(); |
|
| 99 | + } |
|
| 100 | + $colspan = $this->get_column_count(); |
|
| 101 | 101 | |
| 102 | 102 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php' ); |
| 103 | 103 | } |
@@ -117,12 +117,12 @@ discard block |
||
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | - * Gets the name of the primary column in the Entries screen |
|
| 121 | - * |
|
| 122 | - * @since 2.0.14 |
|
| 123 | - * |
|
| 124 | - * @return string $primary_column |
|
| 125 | - */ |
|
| 120 | + * Gets the name of the primary column in the Entries screen |
|
| 121 | + * |
|
| 122 | + * @since 2.0.14 |
|
| 123 | + * |
|
| 124 | + * @return string $primary_column |
|
| 125 | + */ |
|
| 126 | 126 | protected function get_primary_column_name() { |
| 127 | 127 | $columns = get_column_headers( $this->screen ); |
| 128 | 128 | $hidden = get_hidden_columns( $this->screen ); |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | $this->get_actions( $actions, $item, $view_link ); |
| 148 | 148 | |
| 149 | - $action_links = $this->row_actions( $actions ); |
|
| 149 | + $action_links = $this->row_actions( $actions ); |
|
| 150 | 150 | |
| 151 | 151 | // Set up the checkbox ( because the user is editable, otherwise its empty ) |
| 152 | 152 | $checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />"; |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | $r = "<tr id='item-action-{$item->id}'$style>"; |
| 155 | 155 | |
| 156 | 156 | list( $columns, $hidden, , $primary ) = $this->get_column_info(); |
| 157 | - $action_col = false; |
|
| 157 | + $action_col = false; |
|
| 158 | 158 | |
| 159 | 159 | foreach ( $columns as $column_name => $column_display_name ) { |
| 160 | 160 | $class = $column_name . ' column-' . $column_name; |
@@ -166,8 +166,8 @@ discard block |
||
| 166 | 166 | if ( in_array( $column_name, $hidden ) ) { |
| 167 | 167 | $class .= ' frm_hidden'; |
| 168 | 168 | } else if ( ! $action_col && ! in_array( $column_name, array( 'cb', 'id', 'form_id', 'post_id' ) ) ) { |
| 169 | - $action_col = $column_name; |
|
| 170 | - } |
|
| 169 | + $action_col = $column_name; |
|
| 170 | + } |
|
| 171 | 171 | |
| 172 | 172 | $attributes = 'class="' . esc_attr( $class ) . '"'; |
| 173 | 173 | unset( $class ); |
@@ -185,15 +185,15 @@ discard block |
||
| 185 | 185 | $val = $this->column_value( $item ); |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - $r .= "<td $attributes>"; |
|
| 188 | + $r .= "<td $attributes>"; |
|
| 189 | 189 | if ( $column_name == $action_col ) { |
| 190 | 190 | $edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id; |
| 191 | 191 | $r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> '; |
| 192 | - $r .= $action_links; |
|
| 192 | + $r .= $action_links; |
|
| 193 | 193 | } else { |
| 194 | - $r .= $val; |
|
| 195 | - } |
|
| 196 | - $r .= '</td>'; |
|
| 194 | + $r .= $val; |
|
| 195 | + } |
|
| 196 | + $r .= '</td>'; |
|
| 197 | 197 | } |
| 198 | 198 | unset( $val ); |
| 199 | 199 | } |
@@ -246,19 +246,19 @@ discard block |
||
| 246 | 246 | return $val; |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - /** |
|
| 250 | - * @param string $view_link |
|
| 251 | - */ |
|
| 252 | - private function get_actions( &$actions, $item, $view_link ) { |
|
| 249 | + /** |
|
| 250 | + * @param string $view_link |
|
| 251 | + */ |
|
| 252 | + private function get_actions( &$actions, $item, $view_link ) { |
|
| 253 | 253 | $actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>'; |
| 254 | 254 | |
| 255 | 255 | if ( current_user_can( 'frm_delete_entries' ) ) { |
| 256 | 256 | $delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form']; |
| 257 | 257 | $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" data-frmverify="' . esc_attr__( 'Are you sure?', 'formidable' ) . '">' . __( 'Delete' ) . '</a>'; |
| 258 | - } |
|
| 258 | + } |
|
| 259 | 259 | |
| 260 | 260 | $actions = apply_filters( 'frm_row_actions', $actions, $item ); |
| 261 | - } |
|
| 261 | + } |
|
| 262 | 262 | |
| 263 | 263 | private function get_column_value( $item, &$val ) { |
| 264 | 264 | $col_name = $this->column_name; |
@@ -118,10 +118,10 @@ discard block |
||
| 118 | 118 | foreach ( self::$fields as $col ) { |
| 119 | 119 | $field_headings = array(); |
| 120 | 120 | if ( isset( $col->field_options['separate_value'] ) && $col->field_options['separate_value'] && ! in_array( $col->type, array( 'user_id', 'file', 'data', 'date' ), true ) ) { |
| 121 | - $field_headings[ $col->id . '_label' ] = strip_tags( $col->name . ' ' . __( '(label)', 'formidable' ) ); |
|
| 121 | + $field_headings[$col->id . '_label'] = strip_tags( $col->name . ' ' . __( '(label)', 'formidable' ) ); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - $field_headings[ $col->id ] = strip_tags( $col->name ); |
|
| 124 | + $field_headings[$col->id] = strip_tags( $col->name ); |
|
| 125 | 125 | $field_headings = apply_filters( |
| 126 | 126 | 'frm_csv_field_columns', |
| 127 | 127 | $field_headings, |
@@ -133,10 +133,10 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | if ( self::$comment_count ) { |
| 136 | - for ( $i = 0; $i < self::$comment_count; $i++ ) { |
|
| 137 | - $headings[ 'comment' . $i ] = __( 'Comment', 'formidable' ); |
|
| 138 | - $headings[ 'comment_user_id' . $i ] = __( 'Comment User', 'formidable' ); |
|
| 139 | - $headings[ 'comment_created_at' . $i ] = __( 'Comment Date', 'formidable' ); |
|
| 136 | + for ( $i = 0; $i < self::$comment_count; $i ++ ) { |
|
| 137 | + $headings['comment' . $i] = __( 'Comment', 'formidable' ); |
|
| 138 | + $headings['comment_user_id' . $i] = __( 'Comment User', 'formidable' ); |
|
| 139 | + $headings['comment_created_at' . $i] = __( 'Comment Date', 'formidable' ); |
|
| 140 | 140 | } |
| 141 | 141 | unset( $i ); |
| 142 | 142 | } |
@@ -205,30 +205,30 @@ discard block |
||
| 205 | 205 | continue; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - if ( ! isset( $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] ) ) { |
|
| 209 | - $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] = array(); |
|
| 210 | - } elseif ( ! is_array( $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] ) ) { |
|
| 208 | + if ( ! isset( $entries[self::$entry->parent_item_id]->metas[$meta_id] ) ) { |
|
| 209 | + $entries[self::$entry->parent_item_id]->metas[$meta_id] = array(); |
|
| 210 | + } elseif ( ! is_array( $entries[self::$entry->parent_item_id]->metas[$meta_id] ) ) { |
|
| 211 | 211 | // if the data is here, it should be an array but if this field has collected data |
| 212 | 212 | // both while inside and outside of the repeating section, it's possible this is a string |
| 213 | - $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] = (array) $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ]; |
|
| 213 | + $entries[self::$entry->parent_item_id]->metas[$meta_id] = (array) $entries[self::$entry->parent_item_id]->metas[$meta_id]; |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | //add the repeated values |
| 217 | - $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ][] = $meta_value; |
|
| 217 | + $entries[self::$entry->parent_item_id]->metas[$meta_id][] = $meta_value; |
|
| 218 | 218 | } |
| 219 | - $entries[ self::$entry->parent_item_id ]->metas += self::$entry->metas; |
|
| 219 | + $entries[self::$entry->parent_item_id]->metas += self::$entry->metas; |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | // add the embedded form id |
| 223 | - if ( ! isset( $entries[ self::$entry->parent_item_id ]->embedded_fields ) ) { |
|
| 224 | - $entries[ self::$entry->parent_item_id ]->embedded_fields = array(); |
|
| 223 | + if ( ! isset( $entries[self::$entry->parent_item_id]->embedded_fields ) ) { |
|
| 224 | + $entries[self::$entry->parent_item_id]->embedded_fields = array(); |
|
| 225 | 225 | } |
| 226 | - $entries[ self::$entry->parent_item_id ]->embedded_fields[ self::$entry->id ] = self::$entry->form_id; |
|
| 226 | + $entries[self::$entry->parent_item_id]->embedded_fields[self::$entry->id] = self::$entry->form_id; |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | private static function add_field_values_to_csv( &$row ) { |
| 230 | 230 | foreach ( self::$fields as $col ) { |
| 231 | - $field_value = isset( self::$entry->metas[ $col->id ] ) ? self::$entry->metas[ $col->id ] : false; |
|
| 231 | + $field_value = isset( self::$entry->metas[$col->id] ) ? self::$entry->metas[$col->id] : false; |
|
| 232 | 232 | |
| 233 | 233 | $field_value = maybe_unserialize( $field_value ); |
| 234 | 234 | self::add_array_values_to_columns( $row, compact( 'col', 'field_value' ) ); |
@@ -253,14 +253,14 @@ discard block |
||
| 253 | 253 | 'show_icon' => false, |
| 254 | 254 | 'entry_id' => self::$entry->id, |
| 255 | 255 | 'sep' => self::$separator, |
| 256 | - 'embedded_field_id' => ( isset( self::$entry->embedded_fields ) && isset( self::$entry->embedded_fields[ self::$entry->id ] ) ) ? 'form' . self::$entry->embedded_fields[ self::$entry->id ] : 0, |
|
| 256 | + 'embedded_field_id' => ( isset( self::$entry->embedded_fields ) && isset( self::$entry->embedded_fields[self::$entry->id] ) ) ? 'form' . self::$entry->embedded_fields[self::$entry->id] : 0, |
|
| 257 | 257 | ) |
| 258 | 258 | ); |
| 259 | - $row[ $col->id . '_label' ] = $sep_value; |
|
| 259 | + $row[$col->id . '_label'] = $sep_value; |
|
| 260 | 260 | unset( $sep_value ); |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - $row[ $col->id ] = $field_value; |
|
| 263 | + $row[$col->id] = $field_value; |
|
| 264 | 264 | |
| 265 | 265 | unset( $col, $field_value ); |
| 266 | 266 | } |
@@ -273,8 +273,8 @@ discard block |
||
| 273 | 273 | if ( is_array( $atts['field_value'] ) ) { |
| 274 | 274 | foreach ( $atts['field_value'] as $key => $sub_value ) { |
| 275 | 275 | $column_key = $atts['col']->id . '_' . $key; |
| 276 | - if ( ! is_numeric( $key ) && isset( self::$headings[ $column_key ] ) ) { |
|
| 277 | - $row[ $column_key ] = $sub_value; |
|
| 276 | + if ( ! is_numeric( $key ) && isset( self::$headings[$column_key] ) ) { |
|
| 277 | + $row[$column_key] = $sub_value; |
|
| 278 | 278 | } |
| 279 | 279 | } |
| 280 | 280 | } |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | $sep = ''; |
| 299 | 299 | |
| 300 | 300 | foreach ( self::$headings as $k => $heading ) { |
| 301 | - $row = isset( $rows[ $k ] ) ? $rows[ $k ] : ''; |
|
| 301 | + $row = isset( $rows[$k] ) ? $rows[$k] : ''; |
|
| 302 | 302 | if ( is_array( $row ) ) { |
| 303 | 303 | // implode the repeated field values |
| 304 | 304 | $row = implode( self::$separator, FrmAppHelper::array_flatten( $row, 'reset' ) ); |
@@ -33,24 +33,24 @@ discard block |
||
| 33 | 33 | 'styles' => 0, |
| 34 | 34 | ); |
| 35 | 35 | |
| 36 | - $imported = array( |
|
| 37 | - 'imported' => $defaults, |
|
| 36 | + $imported = array( |
|
| 37 | + 'imported' => $defaults, |
|
| 38 | 38 | 'updated' => $defaults, |
| 39 | 39 | 'forms' => array(), |
| 40 | 40 | 'terms' => array(), |
| 41 | - ); |
|
| 41 | + ); |
|
| 42 | 42 | |
| 43 | 43 | unset( $defaults ); |
| 44 | 44 | |
| 45 | 45 | if ( ! defined( 'WP_IMPORTING' ) ) { |
| 46 | 46 | define( 'WP_IMPORTING', true ); |
| 47 | - } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | if ( ! class_exists( 'DOMDocument' ) ) { |
| 50 | - return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() ); |
|
| 51 | - } |
|
| 50 | + return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() ); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - $dom = new DOMDocument; |
|
| 53 | + $dom = new DOMDocument; |
|
| 54 | 54 | $success = $dom->loadXML( file_get_contents( $file ) ); |
| 55 | 55 | if ( ! $success ) { |
| 56 | 56 | return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() ); |
@@ -68,25 +68,25 @@ discard block |
||
| 68 | 68 | return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() ); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order |
|
| 71 | + // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order |
|
| 72 | 72 | foreach ( array( 'term', 'form', 'view' ) as $item_type ) { |
| 73 | - // grab cats, tags, and terms, or forms or posts |
|
| 73 | + // grab cats, tags, and terms, or forms or posts |
|
| 74 | 74 | if ( isset( $xml->{$item_type} ) ) { |
| 75 | 75 | $function_name = 'import_xml_' . $item_type . 's'; |
| 76 | 76 | $imported = self::$function_name( $xml->{$item_type}, $imported ); |
| 77 | 77 | unset( $function_name, $xml->{$item_type} ); |
| 78 | - } |
|
| 79 | - } |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | 81 | $return = apply_filters( 'frm_importing_xml', $imported, $xml ); |
| 82 | 82 | |
| 83 | - return $return; |
|
| 84 | - } |
|
| 83 | + return $return; |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | 86 | public static function import_xml_terms( $terms, $imported ) { |
| 87 | - foreach ( $terms as $t ) { |
|
| 87 | + foreach ( $terms as $t ) { |
|
| 88 | 88 | if ( term_exists( (string) $t->term_slug, (string) $t->term_taxonomy ) ) { |
| 89 | - continue; |
|
| 89 | + continue; |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | $parent = self::get_term_parent_id( $t ); |
@@ -102,15 +102,15 @@ discard block |
||
| 102 | 102 | ); |
| 103 | 103 | |
| 104 | 104 | if ( $term && is_array( $term ) ) { |
| 105 | - $imported['imported']['terms']++; |
|
| 105 | + $imported['imported']['terms']++; |
|
| 106 | 106 | $imported['terms'][ (int) $t->term_id ] = $term['term_id']; |
| 107 | - } |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | 109 | unset( $term, $t ); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | return $imported; |
| 113 | - } |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | 115 | /** |
| 116 | 116 | * @since 2.0.8 |
@@ -135,11 +135,11 @@ discard block |
||
| 135 | 135 | self::put_child_forms_first( $forms ); |
| 136 | 136 | |
| 137 | 137 | foreach ( $forms as $item ) { |
| 138 | - $form = self::fill_form( $item ); |
|
| 138 | + $form = self::fill_form( $item ); |
|
| 139 | 139 | |
| 140 | 140 | self::update_custom_style_setting_on_import( $form ); |
| 141 | 141 | |
| 142 | - $this_form = self::maybe_get_form( $form ); |
|
| 142 | + $this_form = self::maybe_get_form( $form ); |
|
| 143 | 143 | |
| 144 | 144 | $old_id = false; |
| 145 | 145 | $form_fields = false; |
@@ -151,25 +151,25 @@ discard block |
||
| 151 | 151 | $form_fields = self::get_form_fields( $form_id ); |
| 152 | 152 | } else { |
| 153 | 153 | $form_id = FrmForm::create( $form ); |
| 154 | - if ( $form_id ) { |
|
| 155 | - $imported['imported']['forms']++; |
|
| 156 | - // Keep track of whether this specific form was updated or not |
|
| 154 | + if ( $form_id ) { |
|
| 155 | + $imported['imported']['forms']++; |
|
| 156 | + // Keep track of whether this specific form was updated or not |
|
| 157 | 157 | $imported['form_status'][ $form_id ] = 'imported'; |
| 158 | 158 | self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms ); |
| 159 | - } |
|
| 159 | + } |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported ); |
| 163 | 163 | |
| 164 | 164 | self::delete_removed_fields( $form_fields ); |
| 165 | 165 | |
| 166 | - // Update field ids/keys to new ones |
|
| 166 | + // Update field ids/keys to new ones |
|
| 167 | 167 | do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) ); |
| 168 | 168 | |
| 169 | 169 | $imported['forms'][ (int) $item->id ] = $form_id; |
| 170 | 170 | |
| 171 | - // Send pre 2.0 form options through function that creates actions |
|
| 172 | - self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true ); |
|
| 171 | + // Send pre 2.0 form options through function that creates actions |
|
| 172 | + self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true ); |
|
| 173 | 173 | |
| 174 | 174 | do_action( 'frm_after_import_form', $form_id, $form ); |
| 175 | 175 | |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms ); |
| 180 | 180 | |
| 181 | 181 | return $imported; |
| 182 | - } |
|
| 182 | + } |
|
| 183 | 183 | |
| 184 | 184 | private static function fill_form( $item ) { |
| 185 | 185 | $form = array( |
@@ -250,11 +250,11 @@ discard block |
||
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
| 253 | - * Put child forms first so they will be imported before parents |
|
| 254 | - * |
|
| 255 | - * @since 2.0.16 |
|
| 256 | - * @param array $forms |
|
| 257 | - */ |
|
| 253 | + * Put child forms first so they will be imported before parents |
|
| 254 | + * |
|
| 255 | + * @since 2.0.16 |
|
| 256 | + * @param array $forms |
|
| 257 | + */ |
|
| 258 | 258 | private static function put_child_forms_first( &$forms ) { |
| 259 | 259 | $child_forms = array(); |
| 260 | 260 | $regular_forms = array(); |
@@ -273,13 +273,13 @@ discard block |
||
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
| 276 | - * Keep track of all imported child forms |
|
| 277 | - * |
|
| 278 | - * @since 2.0.16 |
|
| 279 | - * @param int $form_id |
|
| 280 | - * @param int $parent_form_id |
|
| 281 | - * @param array $child_forms |
|
| 282 | - */ |
|
| 276 | + * Keep track of all imported child forms |
|
| 277 | + * |
|
| 278 | + * @since 2.0.16 |
|
| 279 | + * @param int $form_id |
|
| 280 | + * @param int $parent_form_id |
|
| 281 | + * @param array $child_forms |
|
| 282 | + */ |
|
| 283 | 283 | private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) { |
| 284 | 284 | if ( $parent_form_id ) { |
| 285 | 285 | $child_forms[ $form_id ] = $parent_form_id; |
@@ -287,13 +287,13 @@ discard block |
||
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | /** |
| 290 | - * Update the parent_form_id on imported child forms |
|
| 291 | - * Child forms are imported first so their parent_form_id will need to be updated after the parent is imported |
|
| 292 | - * |
|
| 293 | - * @since 2.0.6 |
|
| 294 | - * @param array $imported_forms |
|
| 295 | - * @param array $child_forms |
|
| 296 | - */ |
|
| 290 | + * Update the parent_form_id on imported child forms |
|
| 291 | + * Child forms are imported first so their parent_form_id will need to be updated after the parent is imported |
|
| 292 | + * |
|
| 293 | + * @since 2.0.6 |
|
| 294 | + * @param array $imported_forms |
|
| 295 | + * @param array $child_forms |
|
| 296 | + */ |
|
| 297 | 297 | private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) { |
| 298 | 298 | foreach ( $child_forms as $child_form_id => $old_parent_form_id ) { |
| 299 | 299 | |
@@ -307,11 +307,11 @@ discard block |
||
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | /** |
| 310 | - * Import all fields for a form |
|
| 311 | - * @since 2.0.13 |
|
| 312 | - * |
|
| 313 | - * TODO: Cut down on params |
|
| 314 | - */ |
|
| 310 | + * Import all fields for a form |
|
| 311 | + * @since 2.0.13 |
|
| 312 | + * |
|
| 313 | + * TODO: Cut down on params |
|
| 314 | + */ |
|
| 315 | 315 | private static function import_xml_fields( $xml_fields, $form_id, $this_form, &$form_fields, &$imported ) { |
| 316 | 316 | $in_section = 0; |
| 317 | 317 | |
@@ -404,12 +404,12 @@ discard block |
||
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | /** |
| 407 | - * Switch the form_select on a repeating field or embedded form if it needs to be switched |
|
| 408 | - * |
|
| 409 | - * @since 2.0.16 |
|
| 410 | - * @param array $f |
|
| 411 | - * @param array $imported |
|
| 412 | - */ |
|
| 407 | + * Switch the form_select on a repeating field or embedded form if it needs to be switched |
|
| 408 | + * |
|
| 409 | + * @since 2.0.16 |
|
| 410 | + * @param array $f |
|
| 411 | + * @param array $imported |
|
| 412 | + */ |
|
| 413 | 413 | private static function maybe_update_form_select( &$f, $imported ) { |
| 414 | 414 | if ( ! isset( $imported['forms'] ) ) { |
| 415 | 415 | return; |
@@ -461,13 +461,13 @@ discard block |
||
| 461 | 461 | } |
| 462 | 462 | |
| 463 | 463 | /** |
| 464 | - * Updates the custom style setting on import |
|
| 465 | - * Convert the post slug to an ID |
|
| 466 | - * |
|
| 467 | - * @since 2.0.19 |
|
| 468 | - * @param array $form |
|
| 469 | - * |
|
| 470 | - */ |
|
| 464 | + * Updates the custom style setting on import |
|
| 465 | + * Convert the post slug to an ID |
|
| 466 | + * |
|
| 467 | + * @since 2.0.19 |
|
| 468 | + * @param array $form |
|
| 469 | + * |
|
| 470 | + */ |
|
| 471 | 471 | private static function update_custom_style_setting_on_import( &$form ) { |
| 472 | 472 | if ( ! isset( $form['options']['custom_style'] ) ) { |
| 473 | 473 | return; |
@@ -521,16 +521,16 @@ discard block |
||
| 521 | 521 | } |
| 522 | 522 | |
| 523 | 523 | public static function import_xml_views( $views, $imported ) { |
| 524 | - $imported['posts'] = array(); |
|
| 525 | - $form_action_type = FrmFormActionsController::$action_post_type; |
|
| 524 | + $imported['posts'] = array(); |
|
| 525 | + $form_action_type = FrmFormActionsController::$action_post_type; |
|
| 526 | 526 | |
| 527 | - $post_types = array( |
|
| 528 | - 'frm_display' => 'views', |
|
| 529 | - $form_action_type => 'actions', |
|
| 530 | - 'frm_styles' => 'styles', |
|
| 531 | - ); |
|
| 527 | + $post_types = array( |
|
| 528 | + 'frm_display' => 'views', |
|
| 529 | + $form_action_type => 'actions', |
|
| 530 | + 'frm_styles' => 'styles', |
|
| 531 | + ); |
|
| 532 | 532 | |
| 533 | - foreach ( $views as $item ) { |
|
| 533 | + foreach ( $views as $item ) { |
|
| 534 | 534 | $post = array( |
| 535 | 535 | 'post_title' => (string) $item->title, |
| 536 | 536 | 'post_name' => (string) $item->post_name, |
@@ -549,52 +549,52 @@ discard block |
||
| 549 | 549 | 'post_date' => (string) $item->post_date, |
| 550 | 550 | 'post_date_gmt' => (string) $item->post_date_gmt, |
| 551 | 551 | 'ping_status' => (string) $item->ping_status, |
| 552 | - 'postmeta' => array(), |
|
| 553 | - 'tax_input' => array(), |
|
| 552 | + 'postmeta' => array(), |
|
| 553 | + 'tax_input' => array(), |
|
| 554 | 554 | ); |
| 555 | 555 | |
| 556 | - $old_id = $post['post_id']; |
|
| 556 | + $old_id = $post['post_id']; |
|
| 557 | 557 | self::populate_post( $post, $item, $imported ); |
| 558 | 558 | |
| 559 | 559 | unset( $item ); |
| 560 | 560 | |
| 561 | 561 | $post_id = false; |
| 562 | - if ( $post['post_type'] == $form_action_type ) { |
|
| 563 | - $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] ); |
|
| 562 | + if ( $post['post_type'] == $form_action_type ) { |
|
| 563 | + $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] ); |
|
| 564 | 564 | if ( $action_control && is_object( $action_control ) ) { |
| 565 | 565 | $post_id = $action_control->maybe_create_action( $post, $imported['form_status'] ); |
| 566 | 566 | } |
| 567 | 567 | unset( $action_control ); |
| 568 | - } else if ( $post['post_type'] == 'frm_styles' ) { |
|
| 569 | - // Properly encode post content before inserting the post |
|
| 570 | - $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] ); |
|
| 568 | + } else if ( $post['post_type'] == 'frm_styles' ) { |
|
| 569 | + // Properly encode post content before inserting the post |
|
| 570 | + $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] ); |
|
| 571 | 571 | $custom_css = isset( $post['post_content']['custom_css'] ) ? $post['post_content']['custom_css'] : ''; |
| 572 | - $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] ); |
|
| 572 | + $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] ); |
|
| 573 | 573 | |
| 574 | - // Create/update post now |
|
| 575 | - $post_id = wp_insert_post( $post ); |
|
| 574 | + // Create/update post now |
|
| 575 | + $post_id = wp_insert_post( $post ); |
|
| 576 | 576 | self::maybe_update_custom_css( $custom_css ); |
| 577 | - } else { |
|
| 578 | - // Create/update post now |
|
| 579 | - $post_id = wp_insert_post( $post ); |
|
| 580 | - } |
|
| 577 | + } else { |
|
| 578 | + // Create/update post now |
|
| 579 | + $post_id = wp_insert_post( $post ); |
|
| 580 | + } |
|
| 581 | 581 | |
| 582 | 582 | if ( ! is_numeric( $post_id ) ) { |
| 583 | - continue; |
|
| 584 | - } |
|
| 583 | + continue; |
|
| 584 | + } |
|
| 585 | 585 | |
| 586 | 586 | self::update_postmeta( $post, $post_id ); |
| 587 | 587 | |
| 588 | - $this_type = 'posts'; |
|
| 588 | + $this_type = 'posts'; |
|
| 589 | 589 | if ( isset( $post_types[ $post['post_type'] ] ) ) { |
| 590 | 590 | $this_type = $post_types[ $post['post_type'] ]; |
| 591 | - } |
|
| 591 | + } |
|
| 592 | 592 | |
| 593 | 593 | if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) { |
| 594 | - $imported['updated'][ $this_type ]++; |
|
| 595 | - } else { |
|
| 596 | - $imported['imported'][ $this_type ]++; |
|
| 597 | - } |
|
| 594 | + $imported['updated'][ $this_type ]++; |
|
| 595 | + } else { |
|
| 596 | + $imported['imported'][ $this_type ]++; |
|
| 597 | + } |
|
| 598 | 598 | |
| 599 | 599 | $imported['posts'][ (int) $old_id ] = $post_id; |
| 600 | 600 | |
@@ -606,16 +606,16 @@ discard block |
||
| 606 | 606 | self::maybe_update_stylesheet( $imported ); |
| 607 | 607 | |
| 608 | 608 | return $imported; |
| 609 | - } |
|
| 609 | + } |
|
| 610 | 610 | |
| 611 | - private static function populate_post( &$post, $item, $imported ) { |
|
| 611 | + private static function populate_post( &$post, $item, $imported ) { |
|
| 612 | 612 | if ( isset( $item->attachment_url ) ) { |
| 613 | 613 | $post['attachment_url'] = (string) $item->attachment_url; |
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) { |
| 617 | - // update to new form id |
|
| 618 | - $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ]; |
|
| 617 | + // update to new form id |
|
| 618 | + $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ]; |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | // Don't allow default styles to take over a site's default style |
@@ -631,57 +631,57 @@ discard block |
||
| 631 | 631 | self::populate_taxonomies( $post, $item ); |
| 632 | 632 | |
| 633 | 633 | self::maybe_editing_post( $post ); |
| 634 | - } |
|
| 634 | + } |
|
| 635 | 635 | |
| 636 | - private static function populate_postmeta( &$post, $meta, $imported ) { |
|
| 637 | - global $frm_duplicate_ids; |
|
| 636 | + private static function populate_postmeta( &$post, $meta, $imported ) { |
|
| 637 | + global $frm_duplicate_ids; |
|
| 638 | 638 | |
| 639 | - $m = array( |
|
| 639 | + $m = array( |
|
| 640 | 640 | 'key' => (string) $meta->meta_key, |
| 641 | 641 | 'value' => (string) $meta->meta_value, |
| 642 | 642 | ); |
| 643 | 643 | |
| 644 | 644 | //switch old form and field ids to new ones |
| 645 | 645 | if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][ (int) $m['value'] ] ) ) { |
| 646 | - $m['value'] = $imported['forms'][ (int) $m['value'] ]; |
|
| 646 | + $m['value'] = $imported['forms'][ (int) $m['value'] ]; |
|
| 647 | 647 | } else { |
| 648 | - $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] ); |
|
| 648 | + $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] ); |
|
| 649 | 649 | |
| 650 | 650 | if ( ! empty( $frm_duplicate_ids ) ) { |
| 651 | 651 | |
| 652 | - if ( $m['key'] == 'frm_dyncontent' ) { |
|
| 652 | + if ( $m['key'] == 'frm_dyncontent' ) { |
|
| 653 | 653 | $m['value'] = FrmFieldsHelper::switch_field_ids( $m['value'] ); |
| 654 | - } else if ( $m['key'] == 'frm_options' ) { |
|
| 654 | + } else if ( $m['key'] == 'frm_options' ) { |
|
| 655 | 655 | |
| 656 | 656 | foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) { |
| 657 | 657 | if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) { |
| 658 | 658 | $m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ]; |
| 659 | - } |
|
| 660 | - } |
|
| 661 | - |
|
| 662 | - $check_dup_array = array(); |
|
| 663 | - if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) { |
|
| 664 | - if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) { |
|
| 665 | - $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ]; |
|
| 666 | - } else if ( is_array( $m['value']['order_by'] ) ) { |
|
| 667 | - $check_dup_array[] = 'order_by'; |
|
| 668 | - } |
|
| 669 | - } |
|
| 670 | - |
|
| 671 | - if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) { |
|
| 672 | - $check_dup_array[] = 'where'; |
|
| 673 | - } |
|
| 674 | - |
|
| 675 | - foreach ( $check_dup_array as $check_k ) { |
|
| 659 | + } |
|
| 660 | + } |
|
| 661 | + |
|
| 662 | + $check_dup_array = array(); |
|
| 663 | + if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) { |
|
| 664 | + if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) { |
|
| 665 | + $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ]; |
|
| 666 | + } else if ( is_array( $m['value']['order_by'] ) ) { |
|
| 667 | + $check_dup_array[] = 'order_by'; |
|
| 668 | + } |
|
| 669 | + } |
|
| 670 | + |
|
| 671 | + if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) { |
|
| 672 | + $check_dup_array[] = 'where'; |
|
| 673 | + } |
|
| 674 | + |
|
| 675 | + foreach ( $check_dup_array as $check_k ) { |
|
| 676 | 676 | foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) { |
| 677 | 677 | if ( isset( $frm_duplicate_ids[ $mv ] ) ) { |
| 678 | 678 | $m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ]; |
| 679 | - } |
|
| 679 | + } |
|
| 680 | 680 | unset( $mk, $mv ); |
| 681 | - } |
|
| 682 | - } |
|
| 683 | - } |
|
| 684 | - } |
|
| 681 | + } |
|
| 682 | + } |
|
| 683 | + } |
|
| 684 | + } |
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | if ( ! is_array( $m['value'] ) ) { |
@@ -689,31 +689,31 @@ discard block |
||
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | $post['postmeta'][ (string) $meta->meta_key ] = $m['value']; |
| 692 | - } |
|
| 693 | - |
|
| 694 | - /** |
|
| 695 | - * Add terms to post |
|
| 696 | - * @param array $post by reference |
|
| 697 | - * @param object $item The XML object data |
|
| 698 | - */ |
|
| 699 | - private static function populate_taxonomies( &$post, $item ) { |
|
| 692 | + } |
|
| 693 | + |
|
| 694 | + /** |
|
| 695 | + * Add terms to post |
|
| 696 | + * @param array $post by reference |
|
| 697 | + * @param object $item The XML object data |
|
| 698 | + */ |
|
| 699 | + private static function populate_taxonomies( &$post, $item ) { |
|
| 700 | 700 | foreach ( $item->category as $c ) { |
| 701 | 701 | $att = $c->attributes(); |
| 702 | 702 | if ( ! isset( $att['nicename'] ) ) { |
| 703 | - continue; |
|
| 704 | - } |
|
| 703 | + continue; |
|
| 704 | + } |
|
| 705 | 705 | |
| 706 | - $taxonomy = (string) $att['domain']; |
|
| 706 | + $taxonomy = (string) $att['domain']; |
|
| 707 | 707 | if ( is_taxonomy_hierarchical( $taxonomy ) ) { |
| 708 | - $name = (string) $att['nicename']; |
|
| 708 | + $name = (string) $att['nicename']; |
|
| 709 | 709 | $h_term = get_term_by( 'slug', $name, $taxonomy ); |
| 710 | - if ( $h_term ) { |
|
| 711 | - $name = $h_term->term_id; |
|
| 712 | - } |
|
| 710 | + if ( $h_term ) { |
|
| 711 | + $name = $h_term->term_id; |
|
| 712 | + } |
|
| 713 | 713 | unset( $h_term ); |
| 714 | - } else { |
|
| 715 | - $name = (string) $c; |
|
| 716 | - } |
|
| 714 | + } else { |
|
| 715 | + $name = (string) $c; |
|
| 716 | + } |
|
| 717 | 717 | |
| 718 | 718 | if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) { |
| 719 | 719 | $post['tax_input'][ $taxonomy ] = array(); |
@@ -722,21 +722,21 @@ discard block |
||
| 722 | 722 | $post['tax_input'][ $taxonomy ][] = $name; |
| 723 | 723 | unset( $name ); |
| 724 | 724 | } |
| 725 | - } |
|
| 725 | + } |
|
| 726 | 726 | |
| 727 | - /** |
|
| 728 | - * Edit post if the key and created time match |
|
| 729 | - */ |
|
| 730 | - private static function maybe_editing_post( &$post ) { |
|
| 727 | + /** |
|
| 728 | + * Edit post if the key and created time match |
|
| 729 | + */ |
|
| 730 | + private static function maybe_editing_post( &$post ) { |
|
| 731 | 731 | $match_by = array( |
| 732 | - 'post_type' => $post['post_type'], |
|
| 733 | - 'name' => $post['post_name'], |
|
| 734 | - 'post_status' => $post['post_status'], |
|
| 735 | - 'posts_per_page' => 1, |
|
| 732 | + 'post_type' => $post['post_type'], |
|
| 733 | + 'name' => $post['post_name'], |
|
| 734 | + 'post_status' => $post['post_status'], |
|
| 735 | + 'posts_per_page' => 1, |
|
| 736 | 736 | ); |
| 737 | 737 | |
| 738 | 738 | if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) { |
| 739 | - $match_by['include'] = $post['post_id']; |
|
| 739 | + $match_by['include'] = $post['post_id']; |
|
| 740 | 740 | unset( $match_by['name'] ); |
| 741 | 741 | } |
| 742 | 742 | |
@@ -746,23 +746,23 @@ discard block |
||
| 746 | 746 | // set the id of the post to edit |
| 747 | 747 | $post['ID'] = current( $editing )->ID; |
| 748 | 748 | } |
| 749 | - } |
|
| 749 | + } |
|
| 750 | 750 | |
| 751 | - private static function update_postmeta( &$post, $post_id ) { |
|
| 752 | - foreach ( $post['postmeta'] as $k => $v ) { |
|
| 753 | - if ( '_edit_last' == $k ) { |
|
| 751 | + private static function update_postmeta( &$post, $post_id ) { |
|
| 752 | + foreach ( $post['postmeta'] as $k => $v ) { |
|
| 753 | + if ( '_edit_last' == $k ) { |
|
| 754 | 754 | $v = FrmAppHelper::get_user_id_param( $v ); |
| 755 | - } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) { |
|
| 756 | - //change the attachment ID |
|
| 755 | + } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) { |
|
| 756 | + //change the attachment ID |
|
| 757 | 757 | $field_obj = FrmFieldFactory::get_field_type( 'file' ); |
| 758 | 758 | $v = $field_obj->get_file_id( $v ); |
| 759 | - } |
|
| 759 | + } |
|
| 760 | 760 | |
| 761 | 761 | update_post_meta( $post_id, $k, $v ); |
| 762 | 762 | |
| 763 | 763 | unset( $k, $v ); |
| 764 | - } |
|
| 765 | - } |
|
| 764 | + } |
|
| 765 | + } |
|
| 766 | 766 | |
| 767 | 767 | /** |
| 768 | 768 | * If a template includes custom css, let's include it. |
@@ -795,32 +795,32 @@ discard block |
||
| 795 | 795 | } |
| 796 | 796 | } |
| 797 | 797 | |
| 798 | - /** |
|
| 799 | - * @param string $message |
|
| 800 | - */ |
|
| 798 | + /** |
|
| 799 | + * @param string $message |
|
| 800 | + */ |
|
| 801 | 801 | public static function parse_message( $result, &$message, &$errors ) { |
| 802 | 802 | if ( is_wp_error( $result ) ) { |
| 803 | - $errors[] = $result->get_error_message(); |
|
| 804 | - } else if ( ! $result ) { |
|
| 805 | - return; |
|
| 806 | - } |
|
| 803 | + $errors[] = $result->get_error_message(); |
|
| 804 | + } else if ( ! $result ) { |
|
| 805 | + return; |
|
| 806 | + } |
|
| 807 | 807 | |
| 808 | 808 | if ( ! is_array( $result ) ) { |
| 809 | - $message = is_string( $result ) ? $result : htmlentities( print_r( $result, 1 ) ); |
|
| 810 | - return; |
|
| 811 | - } |
|
| 809 | + $message = is_string( $result ) ? $result : htmlentities( print_r( $result, 1 ) ); |
|
| 810 | + return; |
|
| 811 | + } |
|
| 812 | 812 | |
| 813 | - $t_strings = array( |
|
| 814 | - 'imported' => __( 'Imported', 'formidable' ), |
|
| 815 | - 'updated' => __( 'Updated', 'formidable' ), |
|
| 816 | - ); |
|
| 813 | + $t_strings = array( |
|
| 814 | + 'imported' => __( 'Imported', 'formidable' ), |
|
| 815 | + 'updated' => __( 'Updated', 'formidable' ), |
|
| 816 | + ); |
|
| 817 | 817 | |
| 818 | - $message = '<ul>'; |
|
| 819 | - foreach ( $result as $type => $results ) { |
|
| 818 | + $message = '<ul>'; |
|
| 819 | + foreach ( $result as $type => $results ) { |
|
| 820 | 820 | if ( ! isset( $t_strings[ $type ] ) ) { |
| 821 | - // only print imported and updated |
|
| 822 | - continue; |
|
| 823 | - } |
|
| 821 | + // only print imported and updated |
|
| 822 | + continue; |
|
| 823 | + } |
|
| 824 | 824 | |
| 825 | 825 | $s_message = array(); |
| 826 | 826 | foreach ( $results as $k => $m ) { |
@@ -833,34 +833,34 @@ discard block |
||
| 833 | 833 | $message .= implode( ', ', $s_message ); |
| 834 | 834 | $message .= '</li>'; |
| 835 | 835 | } |
| 836 | - } |
|
| 836 | + } |
|
| 837 | 837 | |
| 838 | - if ( $message == '<ul>' ) { |
|
| 839 | - $message = ''; |
|
| 840 | - $errors[] = __( 'Nothing was imported or updated', 'formidable' ); |
|
| 841 | - } else { |
|
| 842 | - $message .= '</ul>'; |
|
| 843 | - } |
|
| 844 | - } |
|
| 838 | + if ( $message == '<ul>' ) { |
|
| 839 | + $message = ''; |
|
| 840 | + $errors[] = __( 'Nothing was imported or updated', 'formidable' ); |
|
| 841 | + } else { |
|
| 842 | + $message .= '</ul>'; |
|
| 843 | + } |
|
| 844 | + } |
|
| 845 | 845 | |
| 846 | 846 | public static function item_count_message( $m, $type, &$s_message ) { |
| 847 | - if ( ! $m ) { |
|
| 848 | - return; |
|
| 849 | - } |
|
| 850 | - |
|
| 851 | - $strings = array( |
|
| 852 | - 'forms' => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ), |
|
| 853 | - 'fields' => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ), |
|
| 854 | - 'items' => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ), |
|
| 855 | - 'views' => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ), |
|
| 856 | - 'posts' => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ), |
|
| 857 | - 'styles' => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ), |
|
| 858 | - 'terms' => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ), |
|
| 859 | - 'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ), |
|
| 860 | - ); |
|
| 847 | + if ( ! $m ) { |
|
| 848 | + return; |
|
| 849 | + } |
|
| 850 | + |
|
| 851 | + $strings = array( |
|
| 852 | + 'forms' => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ), |
|
| 853 | + 'fields' => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ), |
|
| 854 | + 'items' => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ), |
|
| 855 | + 'views' => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ), |
|
| 856 | + 'posts' => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ), |
|
| 857 | + 'styles' => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ), |
|
| 858 | + 'terms' => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ), |
|
| 859 | + 'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ), |
|
| 860 | + ); |
|
| 861 | 861 | |
| 862 | 862 | $s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type ); |
| 863 | - } |
|
| 863 | + } |
|
| 864 | 864 | |
| 865 | 865 | /** |
| 866 | 866 | * Prepare the form options for export |
@@ -899,8 +899,8 @@ discard block |
||
| 899 | 899 | } |
| 900 | 900 | |
| 901 | 901 | if ( is_numeric( $str ) ) { |
| 902 | - return $str; |
|
| 903 | - } |
|
| 902 | + return $str; |
|
| 903 | + } |
|
| 904 | 904 | |
| 905 | 905 | self::remove_invalid_characters_from_xml( $str ); |
| 906 | 906 | |
@@ -921,54 +921,54 @@ discard block |
||
| 921 | 921 | $str = str_replace( '\x1F', '', $str ); |
| 922 | 922 | } |
| 923 | 923 | |
| 924 | - public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) { |
|
| 925 | - // Get post type |
|
| 926 | - $post_type = FrmFormActionsController::$action_post_type; |
|
| 924 | + public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) { |
|
| 925 | + // Get post type |
|
| 926 | + $post_type = FrmFormActionsController::$action_post_type; |
|
| 927 | 927 | |
| 928 | - // Set up imported index, if not set up yet |
|
| 929 | - if ( ! isset( $imported['imported']['actions'] ) ) { |
|
| 930 | - $imported['imported']['actions'] = 0; |
|
| 931 | - } |
|
| 928 | + // Set up imported index, if not set up yet |
|
| 929 | + if ( ! isset( $imported['imported']['actions'] ) ) { |
|
| 930 | + $imported['imported']['actions'] = 0; |
|
| 931 | + } |
|
| 932 | 932 | |
| 933 | - // Migrate post settings to action |
|
| 934 | - self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
| 933 | + // Migrate post settings to action |
|
| 934 | + self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
| 935 | 935 | |
| 936 | - // Migrate email settings to action |
|
| 937 | - self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
| 938 | - } |
|
| 936 | + // Migrate email settings to action |
|
| 937 | + self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
| 938 | + } |
|
| 939 | 939 | |
| 940 | - /** |
|
| 941 | - * Migrate post settings to form action |
|
| 942 | - * |
|
| 943 | - * @param string $post_type |
|
| 944 | - */ |
|
| 945 | - private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
| 940 | + /** |
|
| 941 | + * Migrate post settings to form action |
|
| 942 | + * |
|
| 943 | + * @param string $post_type |
|
| 944 | + */ |
|
| 945 | + private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
| 946 | 946 | if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) { |
| 947 | - return; |
|
| 948 | - } |
|
| 947 | + return; |
|
| 948 | + } |
|
| 949 | 949 | |
| 950 | - $new_action = array( |
|
| 951 | - 'post_type' => $post_type, |
|
| 952 | - 'post_excerpt' => 'wppost', |
|
| 950 | + $new_action = array( |
|
| 951 | + 'post_type' => $post_type, |
|
| 952 | + 'post_excerpt' => 'wppost', |
|
| 953 | 953 | 'post_title' => __( 'Create Posts', 'formidable' ), |
| 954 | - 'menu_order' => $form_id, |
|
| 955 | - 'post_status' => 'publish', |
|
| 956 | - 'post_content' => array(), |
|
| 954 | + 'menu_order' => $form_id, |
|
| 955 | + 'post_status' => 'publish', |
|
| 956 | + 'post_content' => array(), |
|
| 957 | 957 | 'post_name' => $form_id . '_wppost_1', |
| 958 | - ); |
|
| 958 | + ); |
|
| 959 | 959 | |
| 960 | 960 | $post_settings = array( 'post_type', 'post_category', 'post_content', 'post_excerpt', 'post_title', 'post_name', 'post_date', 'post_status', 'post_custom_fields', 'post_password' ); |
| 961 | 961 | |
| 962 | - foreach ( $post_settings as $post_setting ) { |
|
| 962 | + foreach ( $post_settings as $post_setting ) { |
|
| 963 | 963 | if ( isset( $form_options[ $post_setting ] ) ) { |
| 964 | 964 | $new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ]; |
| 965 | - } |
|
| 965 | + } |
|
| 966 | 966 | unset( $post_setting ); |
| 967 | - } |
|
| 967 | + } |
|
| 968 | 968 | |
| 969 | 969 | $new_action['event'] = array( 'create', 'update' ); |
| 970 | 970 | |
| 971 | - if ( $switch ) { |
|
| 971 | + if ( $switch ) { |
|
| 972 | 972 | // Fields with string or int saved |
| 973 | 973 | $basic_fields = array( 'post_title', 'post_content', 'post_excerpt', 'post_password', 'post_date', 'post_status' ); |
| 974 | 974 | |
@@ -976,7 +976,7 @@ discard block |
||
| 976 | 976 | $array_fields = array( 'post_category', 'post_custom_fields' ); |
| 977 | 977 | |
| 978 | 978 | $new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields ); |
| 979 | - } |
|
| 979 | + } |
|
| 980 | 980 | $new_action['post_content'] = json_encode( $new_action['post_content'] ); |
| 981 | 981 | |
| 982 | 982 | $exists = get_posts( |
@@ -988,12 +988,12 @@ discard block |
||
| 988 | 988 | ) |
| 989 | 989 | ); |
| 990 | 990 | |
| 991 | - if ( ! $exists ) { |
|
| 991 | + if ( ! $exists ) { |
|
| 992 | 992 | // this isn't an email, but we need to use a class that will always be included |
| 993 | 993 | FrmDb::save_json_post( $new_action ); |
| 994 | - $imported['imported']['actions']++; |
|
| 995 | - } |
|
| 996 | - } |
|
| 994 | + $imported['imported']['actions']++; |
|
| 995 | + } |
|
| 996 | + } |
|
| 997 | 997 | |
| 998 | 998 | /** |
| 999 | 999 | * Switch old field IDs for new field IDs in emails and post |
@@ -1006,71 +1006,71 @@ discard block |
||
| 1006 | 1006 | * @return string $post_content - new field IDs |
| 1007 | 1007 | */ |
| 1008 | 1008 | private static function switch_action_field_ids( $post_content, $basic_fields, $array_fields = array() ) { |
| 1009 | - global $frm_duplicate_ids; |
|
| 1009 | + global $frm_duplicate_ids; |
|
| 1010 | 1010 | |
| 1011 | - // If there aren't IDs that were switched, end now |
|
| 1012 | - if ( ! $frm_duplicate_ids ) { |
|
| 1013 | - return; |
|
| 1014 | - } |
|
| 1011 | + // If there aren't IDs that were switched, end now |
|
| 1012 | + if ( ! $frm_duplicate_ids ) { |
|
| 1013 | + return; |
|
| 1014 | + } |
|
| 1015 | 1015 | |
| 1016 | - // Get old IDs |
|
| 1017 | - $old = array_keys( $frm_duplicate_ids ); |
|
| 1016 | + // Get old IDs |
|
| 1017 | + $old = array_keys( $frm_duplicate_ids ); |
|
| 1018 | 1018 | |
| 1019 | - // Get new IDs |
|
| 1020 | - $new = array_values( $frm_duplicate_ids ); |
|
| 1019 | + // Get new IDs |
|
| 1020 | + $new = array_values( $frm_duplicate_ids ); |
|
| 1021 | 1021 | |
| 1022 | - // Do a str_replace with each item to set the new IDs |
|
| 1023 | - foreach ( $post_content as $key => $setting ) { |
|
| 1024 | - if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) { |
|
| 1025 | - // Replace old IDs with new IDs |
|
| 1022 | + // Do a str_replace with each item to set the new IDs |
|
| 1023 | + foreach ( $post_content as $key => $setting ) { |
|
| 1024 | + if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) { |
|
| 1025 | + // Replace old IDs with new IDs |
|
| 1026 | 1026 | $post_content[ $key ] = str_replace( $old, $new, $setting ); |
| 1027 | - } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) { |
|
| 1028 | - foreach ( $setting as $k => $val ) { |
|
| 1029 | - // Replace old IDs with new IDs |
|
| 1027 | + } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) { |
|
| 1028 | + foreach ( $setting as $k => $val ) { |
|
| 1029 | + // Replace old IDs with new IDs |
|
| 1030 | 1030 | $post_content[ $key ][ $k ] = str_replace( $old, $new, $val ); |
| 1031 | - } |
|
| 1032 | - } |
|
| 1033 | - unset( $key, $setting ); |
|
| 1034 | - } |
|
| 1035 | - return $post_content; |
|
| 1036 | - } |
|
| 1037 | - |
|
| 1038 | - private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
| 1039 | - // No old notifications or autoresponders to carry over |
|
| 1031 | + } |
|
| 1032 | + } |
|
| 1033 | + unset( $key, $setting ); |
|
| 1034 | + } |
|
| 1035 | + return $post_content; |
|
| 1036 | + } |
|
| 1037 | + |
|
| 1038 | + private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
| 1039 | + // No old notifications or autoresponders to carry over |
|
| 1040 | 1040 | if ( ! isset( $form_options['auto_responder'] ) && ! isset( $form_options['notification'] ) && ! isset( $form_options['email_to'] ) ) { |
| 1041 | - return; |
|
| 1042 | - } |
|
| 1041 | + return; |
|
| 1042 | + } |
|
| 1043 | 1043 | |
| 1044 | - // Initialize notifications array |
|
| 1045 | - $notifications = array(); |
|
| 1044 | + // Initialize notifications array |
|
| 1045 | + $notifications = array(); |
|
| 1046 | 1046 | |
| 1047 | - // Migrate regular notifications |
|
| 1048 | - self::migrate_notifications_to_action( $form_options, $form_id, $notifications ); |
|
| 1047 | + // Migrate regular notifications |
|
| 1048 | + self::migrate_notifications_to_action( $form_options, $form_id, $notifications ); |
|
| 1049 | 1049 | |
| 1050 | - // Migrate autoresponders |
|
| 1051 | - self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications ); |
|
| 1050 | + // Migrate autoresponders |
|
| 1051 | + self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications ); |
|
| 1052 | 1052 | |
| 1053 | - if ( empty( $notifications ) ) { |
|
| 1054 | - return; |
|
| 1055 | - } |
|
| 1053 | + if ( empty( $notifications ) ) { |
|
| 1054 | + return; |
|
| 1055 | + } |
|
| 1056 | 1056 | |
| 1057 | - foreach ( $notifications as $new_notification ) { |
|
| 1058 | - $new_notification['post_type'] = $post_type; |
|
| 1059 | - $new_notification['post_excerpt'] = 'email'; |
|
| 1057 | + foreach ( $notifications as $new_notification ) { |
|
| 1058 | + $new_notification['post_type'] = $post_type; |
|
| 1059 | + $new_notification['post_excerpt'] = 'email'; |
|
| 1060 | 1060 | $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
| 1061 | - $new_notification['menu_order'] = $form_id; |
|
| 1062 | - $new_notification['post_status'] = 'publish'; |
|
| 1061 | + $new_notification['menu_order'] = $form_id; |
|
| 1062 | + $new_notification['post_status'] = 'publish'; |
|
| 1063 | 1063 | |
| 1064 | - // Switch field IDs and keys, if needed |
|
| 1065 | - if ( $switch ) { |
|
| 1064 | + // Switch field IDs and keys, if needed |
|
| 1065 | + if ( $switch ) { |
|
| 1066 | 1066 | |
| 1067 | 1067 | // Switch field IDs in email conditional logic |
| 1068 | 1068 | self::switch_email_contition_field_ids( $new_notification['post_content'] ); |
| 1069 | 1069 | |
| 1070 | 1070 | // Switch all other field IDs in email |
| 1071 | - $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] ); |
|
| 1072 | - } |
|
| 1073 | - $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
| 1071 | + $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] ); |
|
| 1072 | + } |
|
| 1073 | + $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
| 1074 | 1074 | |
| 1075 | 1075 | $exists = get_posts( |
| 1076 | 1076 | array( |
@@ -1083,13 +1083,13 @@ discard block |
||
| 1083 | 1083 | |
| 1084 | 1084 | if ( empty( $exists ) ) { |
| 1085 | 1085 | FrmDb::save_json_post( $new_notification ); |
| 1086 | - $imported['imported']['actions']++; |
|
| 1087 | - } |
|
| 1086 | + $imported['imported']['actions']++; |
|
| 1087 | + } |
|
| 1088 | 1088 | unset( $new_notification ); |
| 1089 | - } |
|
| 1089 | + } |
|
| 1090 | 1090 | |
| 1091 | 1091 | self::remove_deprecated_notification_settings( $form_id, $form_options ); |
| 1092 | - } |
|
| 1092 | + } |
|
| 1093 | 1093 | |
| 1094 | 1094 | /** |
| 1095 | 1095 | * Remove deprecated notification settings after migration |
@@ -1109,17 +1109,17 @@ discard block |
||
| 1109 | 1109 | FrmForm::update( $form_id, array( 'options' => $form_options ) ); |
| 1110 | 1110 | } |
| 1111 | 1111 | |
| 1112 | - private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) { |
|
| 1113 | - if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) { |
|
| 1114 | - // add old settings into notification array |
|
| 1112 | + private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) { |
|
| 1113 | + if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) { |
|
| 1114 | + // add old settings into notification array |
|
| 1115 | 1115 | $form_options['notification'] = array( 0 => $form_options ); |
| 1116 | - } else if ( isset( $form_options['notification']['email_to'] ) ) { |
|
| 1117 | - // make sure it's in the correct format |
|
| 1116 | + } else if ( isset( $form_options['notification']['email_to'] ) ) { |
|
| 1117 | + // make sure it's in the correct format |
|
| 1118 | 1118 | $form_options['notification'] = array( 0 => $form_options['notification'] ); |
| 1119 | - } |
|
| 1119 | + } |
|
| 1120 | 1120 | |
| 1121 | 1121 | if ( isset( $form_options['notification'] ) && is_array( $form_options['notification'] ) ) { |
| 1122 | - foreach ( $form_options['notification'] as $email_key => $notification ) { |
|
| 1122 | + foreach ( $form_options['notification'] as $email_key => $notification ) { |
|
| 1123 | 1123 | |
| 1124 | 1124 | $atts = array( |
| 1125 | 1125 | 'email_to' => '', |
@@ -1130,119 +1130,119 @@ discard block |
||
| 1130 | 1130 | 'email_key' => $email_key, |
| 1131 | 1131 | ); |
| 1132 | 1132 | |
| 1133 | - // Format the email data |
|
| 1134 | - self::format_email_data( $atts, $notification ); |
|
| 1133 | + // Format the email data |
|
| 1134 | + self::format_email_data( $atts, $notification ); |
|
| 1135 | 1135 | |
| 1136 | 1136 | if ( isset( $notification['twilio'] ) && $notification['twilio'] ) { |
| 1137 | 1137 | do_action( 'frm_create_twilio_action', $atts, $notification ); |
| 1138 | 1138 | } |
| 1139 | 1139 | |
| 1140 | - // Setup the new notification |
|
| 1141 | - $new_notification = array(); |
|
| 1142 | - self::setup_new_notification( $new_notification, $notification, $atts ); |
|
| 1140 | + // Setup the new notification |
|
| 1141 | + $new_notification = array(); |
|
| 1142 | + self::setup_new_notification( $new_notification, $notification, $atts ); |
|
| 1143 | 1143 | |
| 1144 | - $notifications[] = $new_notification; |
|
| 1145 | - } |
|
| 1146 | - } |
|
| 1147 | - } |
|
| 1144 | + $notifications[] = $new_notification; |
|
| 1145 | + } |
|
| 1146 | + } |
|
| 1147 | + } |
|
| 1148 | 1148 | |
| 1149 | - private static function format_email_data( &$atts, $notification ) { |
|
| 1150 | - // Format email_to |
|
| 1151 | - self::format_email_to_data( $atts, $notification ); |
|
| 1149 | + private static function format_email_data( &$atts, $notification ) { |
|
| 1150 | + // Format email_to |
|
| 1151 | + self::format_email_to_data( $atts, $notification ); |
|
| 1152 | 1152 | |
| 1153 | - // Format the reply to email and name |
|
| 1153 | + // Format the reply to email and name |
|
| 1154 | 1154 | $reply_fields = array( |
| 1155 | 1155 | 'reply_to' => '', |
| 1156 | 1156 | 'reply_to_name' => '', |
| 1157 | 1157 | ); |
| 1158 | - foreach ( $reply_fields as $f => $val ) { |
|
| 1158 | + foreach ( $reply_fields as $f => $val ) { |
|
| 1159 | 1159 | if ( isset( $notification[ $f ] ) ) { |
| 1160 | 1160 | $atts[ $f ] = $notification[ $f ]; |
| 1161 | 1161 | if ( 'custom' == $notification[ $f ] ) { |
| 1162 | 1162 | $atts[ $f ] = $notification[ 'cust_' . $f ]; |
| 1163 | 1163 | } else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) { |
| 1164 | 1164 | $atts[ $f ] = '[' . $atts[ $f ] . ']'; |
| 1165 | - } |
|
| 1166 | - } |
|
| 1167 | - unset( $f, $val ); |
|
| 1168 | - } |
|
| 1165 | + } |
|
| 1166 | + } |
|
| 1167 | + unset( $f, $val ); |
|
| 1168 | + } |
|
| 1169 | 1169 | |
| 1170 | - // Format event |
|
| 1170 | + // Format event |
|
| 1171 | 1171 | $atts['event'] = array( 'create' ); |
| 1172 | - if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) { |
|
| 1173 | - $atts['event'][] = 'update'; |
|
| 1172 | + if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) { |
|
| 1173 | + $atts['event'][] = 'update'; |
|
| 1174 | 1174 | } elseif ( isset( $notification['update_email'] ) && 2 == $notification['update_email'] ) { |
| 1175 | 1175 | $atts['event'] = array( 'update' ); |
| 1176 | - } |
|
| 1177 | - } |
|
| 1176 | + } |
|
| 1177 | + } |
|
| 1178 | 1178 | |
| 1179 | - private static function format_email_to_data( &$atts, $notification ) { |
|
| 1180 | - if ( isset( $notification['email_to'] ) ) { |
|
| 1179 | + private static function format_email_to_data( &$atts, $notification ) { |
|
| 1180 | + if ( isset( $notification['email_to'] ) ) { |
|
| 1181 | 1181 | $atts['email_to'] = preg_split( '/ (,|;) /', $notification['email_to'] ); |
| 1182 | - } else { |
|
| 1183 | - $atts['email_to'] = array(); |
|
| 1184 | - } |
|
| 1182 | + } else { |
|
| 1183 | + $atts['email_to'] = array(); |
|
| 1184 | + } |
|
| 1185 | 1185 | |
| 1186 | - if ( isset( $notification['also_email_to'] ) ) { |
|
| 1187 | - $email_fields = (array) $notification['also_email_to']; |
|
| 1188 | - $atts['email_to'] = array_merge( $email_fields, $atts['email_to'] ); |
|
| 1189 | - unset( $email_fields ); |
|
| 1190 | - } |
|
| 1186 | + if ( isset( $notification['also_email_to'] ) ) { |
|
| 1187 | + $email_fields = (array) $notification['also_email_to']; |
|
| 1188 | + $atts['email_to'] = array_merge( $email_fields, $atts['email_to'] ); |
|
| 1189 | + unset( $email_fields ); |
|
| 1190 | + } |
|
| 1191 | 1191 | |
| 1192 | - foreach ( $atts['email_to'] as $key => $email_field ) { |
|
| 1192 | + foreach ( $atts['email_to'] as $key => $email_field ) { |
|
| 1193 | 1193 | |
| 1194 | - if ( is_numeric( $email_field ) ) { |
|
| 1194 | + if ( is_numeric( $email_field ) ) { |
|
| 1195 | 1195 | $atts['email_to'][ $key ] = '[' . $email_field . ']'; |
| 1196 | - } |
|
| 1196 | + } |
|
| 1197 | 1197 | |
| 1198 | 1198 | if ( strpos( $email_field, '|' ) ) { |
| 1199 | - $email_opt = explode( '|', $email_field ); |
|
| 1200 | - if ( isset( $email_opt[0] ) ) { |
|
| 1199 | + $email_opt = explode( '|', $email_field ); |
|
| 1200 | + if ( isset( $email_opt[0] ) ) { |
|
| 1201 | 1201 | $atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
| 1202 | - } |
|
| 1203 | - unset( $email_opt ); |
|
| 1204 | - } |
|
| 1205 | - } |
|
| 1202 | + } |
|
| 1203 | + unset( $email_opt ); |
|
| 1204 | + } |
|
| 1205 | + } |
|
| 1206 | 1206 | $atts['email_to'] = implode( ', ', $atts['email_to'] ); |
| 1207 | - } |
|
| 1208 | - |
|
| 1209 | - private static function setup_new_notification( &$new_notification, $notification, $atts ) { |
|
| 1210 | - // Set up new notification |
|
| 1211 | - $new_notification = array( |
|
| 1212 | - 'post_content' => array( |
|
| 1213 | - 'email_to' => $atts['email_to'], |
|
| 1214 | - 'event' => $atts['event'], |
|
| 1215 | - ), |
|
| 1207 | + } |
|
| 1208 | + |
|
| 1209 | + private static function setup_new_notification( &$new_notification, $notification, $atts ) { |
|
| 1210 | + // Set up new notification |
|
| 1211 | + $new_notification = array( |
|
| 1212 | + 'post_content' => array( |
|
| 1213 | + 'email_to' => $atts['email_to'], |
|
| 1214 | + 'event' => $atts['event'], |
|
| 1215 | + ), |
|
| 1216 | 1216 | 'post_name' => $atts['form_id'] . '_email_' . $atts['email_key'], |
| 1217 | - ); |
|
| 1217 | + ); |
|
| 1218 | 1218 | |
| 1219 | - // Add more fields to the new notification |
|
| 1220 | - $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' ); |
|
| 1221 | - foreach ( $add_fields as $add_field ) { |
|
| 1219 | + // Add more fields to the new notification |
|
| 1220 | + $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' ); |
|
| 1221 | + foreach ( $add_fields as $add_field ) { |
|
| 1222 | 1222 | if ( isset( $notification[ $add_field ] ) ) { |
| 1223 | 1223 | $new_notification['post_content'][ $add_field ] = $notification[ $add_field ]; |
| 1224 | - } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) { |
|
| 1224 | + } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) { |
|
| 1225 | 1225 | $new_notification['post_content'][ $add_field ] = 0; |
| 1226 | - } else { |
|
| 1226 | + } else { |
|
| 1227 | 1227 | $new_notification['post_content'][ $add_field ] = ''; |
| 1228 | - } |
|
| 1229 | - unset( $add_field ); |
|
| 1230 | - } |
|
| 1228 | + } |
|
| 1229 | + unset( $add_field ); |
|
| 1230 | + } |
|
| 1231 | 1231 | |
| 1232 | 1232 | // Set reply to |
| 1233 | 1233 | $new_notification['post_content']['reply_to'] = $atts['reply_to']; |
| 1234 | 1234 | |
| 1235 | - // Set from |
|
| 1235 | + // Set from |
|
| 1236 | 1236 | if ( ! empty( $atts['reply_to'] ) || ! empty( $atts['reply_to_name'] ) ) { |
| 1237 | 1237 | $new_notification['post_content']['from'] = ( empty( $atts['reply_to_name'] ) ? '[sitename]' : $atts['reply_to_name'] ) . ' <' . ( empty( $atts['reply_to'] ) ? '[admin_email]' : $atts['reply_to'] ) . '>'; |
| 1238 | - } |
|
| 1239 | - } |
|
| 1238 | + } |
|
| 1239 | + } |
|
| 1240 | 1240 | |
| 1241 | 1241 | /** |
| 1242 | - * Switch field IDs in pre-2.0 email conditional logic |
|
| 1243 | - * |
|
| 1244 | - * @param $post_content array, pass by reference |
|
| 1245 | - */ |
|
| 1242 | + * Switch field IDs in pre-2.0 email conditional logic |
|
| 1243 | + * |
|
| 1244 | + * @param $post_content array, pass by reference |
|
| 1245 | + */ |
|
| 1246 | 1246 | private static function switch_email_contition_field_ids( &$post_content ) { |
| 1247 | 1247 | // Switch field IDs in conditional logic |
| 1248 | 1248 | if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) { |
@@ -1255,7 +1255,7 @@ discard block |
||
| 1255 | 1255 | } |
| 1256 | 1256 | } |
| 1257 | 1257 | |
| 1258 | - private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) { |
|
| 1258 | + private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) { |
|
| 1259 | 1259 | if ( isset( $form_options['auto_responder'] ) && $form_options['auto_responder'] && isset( $form_options['ar_email_message'] ) && $form_options['ar_email_message'] ) { |
| 1260 | 1260 | // migrate autoresponder |
| 1261 | 1261 | |
@@ -1271,8 +1271,8 @@ discard block |
||
| 1271 | 1271 | $email_field = '[' . $email_field . ']'; |
| 1272 | 1272 | } |
| 1273 | 1273 | |
| 1274 | - $notification = $form_options; |
|
| 1275 | - $new_notification2 = array( |
|
| 1274 | + $notification = $form_options; |
|
| 1275 | + $new_notification2 = array( |
|
| 1276 | 1276 | 'post_content' => array( |
| 1277 | 1277 | 'email_message' => $notification['ar_email_message'], |
| 1278 | 1278 | 'email_subject' => isset( $notification['ar_email_subject'] ) ? $notification['ar_email_subject'] : '', |
@@ -1281,7 +1281,7 @@ discard block |
||
| 1281 | 1281 | 'inc_user_info' => 0, |
| 1282 | 1282 | ), |
| 1283 | 1283 | 'post_name' => $form_id . '_email_' . count( $notifications ), |
| 1284 | - ); |
|
| 1284 | + ); |
|
| 1285 | 1285 | |
| 1286 | 1286 | $reply_to = isset( $notification['ar_reply_to'] ) ? $notification['ar_reply_to'] : ''; |
| 1287 | 1287 | $reply_to_name = isset( $notification['ar_reply_to_name'] ) ? $notification['ar_reply_to_name'] : ''; |
@@ -1294,9 +1294,9 @@ discard block |
||
| 1294 | 1294 | $new_notification2['post_content']['from'] = ( empty( $reply_to_name ) ? '[sitename]' : $reply_to_name ) . ' <' . ( empty( $reply_to ) ? '[admin_email]' : $reply_to ) . '>'; |
| 1295 | 1295 | } |
| 1296 | 1296 | |
| 1297 | - $notifications[] = $new_notification2; |
|
| 1298 | - unset( $new_notification2 ); |
|
| 1299 | - } |
|
| 1300 | - } |
|
| 1297 | + $notifications[] = $new_notification2; |
|
| 1298 | + unset( $new_notification2 ); |
|
| 1299 | + } |
|
| 1300 | + } |
|
| 1301 | 1301 | } |
| 1302 | 1302 | |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | ); |
| 103 | 103 | |
| 104 | 104 | if ( $term && is_array( $term ) ) { |
| 105 | - $imported['imported']['terms']++; |
|
| 106 | - $imported['terms'][ (int) $t->term_id ] = $term['term_id']; |
|
| 105 | + $imported['imported']['terms'] ++; |
|
| 106 | + $imported['terms'][(int) $t->term_id] = $term['term_id']; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | unset( $term, $t ); |
@@ -152,9 +152,9 @@ discard block |
||
| 152 | 152 | } else { |
| 153 | 153 | $form_id = FrmForm::create( $form ); |
| 154 | 154 | if ( $form_id ) { |
| 155 | - $imported['imported']['forms']++; |
|
| 155 | + $imported['imported']['forms'] ++; |
|
| 156 | 156 | // Keep track of whether this specific form was updated or not |
| 157 | - $imported['form_status'][ $form_id ] = 'imported'; |
|
| 157 | + $imported['form_status'][$form_id] = 'imported'; |
|
| 158 | 158 | self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms ); |
| 159 | 159 | } |
| 160 | 160 | } |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | // Update field ids/keys to new ones |
| 167 | 167 | do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) ); |
| 168 | 168 | |
| 169 | - $imported['forms'][ (int) $item->id ] = $form_id; |
|
| 169 | + $imported['forms'][(int) $item->id] = $form_id; |
|
| 170 | 170 | |
| 171 | 171 | // Send pre 2.0 form options through function that creates actions |
| 172 | 172 | self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true ); |
@@ -218,17 +218,17 @@ discard block |
||
| 218 | 218 | private static function update_form( $this_form, $form, &$imported ) { |
| 219 | 219 | $form_id = $this_form->id; |
| 220 | 220 | FrmForm::update( $form_id, $form ); |
| 221 | - $imported['updated']['forms']++; |
|
| 221 | + $imported['updated']['forms'] ++; |
|
| 222 | 222 | // Keep track of whether this specific form was updated or not |
| 223 | - $imported['form_status'][ $form_id ] = 'updated'; |
|
| 223 | + $imported['form_status'][$form_id] = 'updated'; |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | private static function get_form_fields( $form_id ) { |
| 227 | 227 | $form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' ); |
| 228 | 228 | $old_fields = array(); |
| 229 | 229 | foreach ( $form_fields as $f ) { |
| 230 | - $old_fields[ $f->id ] = $f; |
|
| 231 | - $old_fields[ $f->field_key ] = $f->id; |
|
| 230 | + $old_fields[$f->id] = $f; |
|
| 231 | + $old_fields[$f->field_key] = $f->id; |
|
| 232 | 232 | unset( $f ); |
| 233 | 233 | } |
| 234 | 234 | $form_fields = $old_fields; |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | */ |
| 283 | 283 | private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) { |
| 284 | 284 | if ( $parent_form_id ) { |
| 285 | - $child_forms[ $form_id ] = $parent_form_id; |
|
| 285 | + $child_forms[$form_id] = $parent_form_id; |
|
| 286 | 286 | } |
| 287 | 287 | } |
| 288 | 288 | |
@@ -297,9 +297,9 @@ discard block |
||
| 297 | 297 | private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) { |
| 298 | 298 | foreach ( $child_forms as $child_form_id => $old_parent_form_id ) { |
| 299 | 299 | |
| 300 | - if ( isset( $imported_forms[ $old_parent_form_id ] ) && $imported_forms[ $old_parent_form_id ] != $old_parent_form_id ) { |
|
| 300 | + if ( isset( $imported_forms[$old_parent_form_id] ) && $imported_forms[$old_parent_form_id] != $old_parent_form_id ) { |
|
| 301 | 301 | // Update all children with this old parent_form_id |
| 302 | - $new_parent_form_id = (int) $imported_forms[ $old_parent_form_id ]; |
|
| 302 | + $new_parent_form_id = (int) $imported_forms[$old_parent_form_id]; |
|
| 303 | 303 | |
| 304 | 304 | FrmForm::update( $child_form_id, array( 'parent_form_id' => $new_parent_form_id ) ); |
| 305 | 305 | } |
@@ -333,25 +333,25 @@ discard block |
||
| 333 | 333 | |
| 334 | 334 | if ( ! empty( $this_form ) ) { |
| 335 | 335 | // check for field to edit by field id |
| 336 | - if ( isset( $form_fields[ $f['id'] ] ) ) { |
|
| 336 | + if ( isset( $form_fields[$f['id']] ) ) { |
|
| 337 | 337 | FrmField::update( $f['id'], $f ); |
| 338 | - $imported['updated']['fields']++; |
|
| 338 | + $imported['updated']['fields'] ++; |
|
| 339 | 339 | |
| 340 | - unset( $form_fields[ $f['id'] ] ); |
|
| 340 | + unset( $form_fields[$f['id']] ); |
|
| 341 | 341 | |
| 342 | 342 | //unset old field key |
| 343 | - if ( isset( $form_fields[ $f['field_key'] ] ) ) { |
|
| 344 | - unset( $form_fields[ $f['field_key'] ] ); |
|
| 343 | + if ( isset( $form_fields[$f['field_key']] ) ) { |
|
| 344 | + unset( $form_fields[$f['field_key']] ); |
|
| 345 | 345 | } |
| 346 | - } else if ( isset( $form_fields[ $f['field_key'] ] ) ) { |
|
| 346 | + } else if ( isset( $form_fields[$f['field_key']] ) ) { |
|
| 347 | 347 | // check for field to edit by field key |
| 348 | 348 | unset( $f['id'] ); |
| 349 | 349 | |
| 350 | - FrmField::update( $form_fields[ $f['field_key'] ], $f ); |
|
| 351 | - $imported['updated']['fields']++; |
|
| 350 | + FrmField::update( $form_fields[$f['field_key']], $f ); |
|
| 351 | + $imported['updated']['fields'] ++; |
|
| 352 | 352 | |
| 353 | - unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id |
|
| 354 | - unset( $form_fields[ $f['field_key'] ] ); //unset old field key |
|
| 353 | + unset( $form_fields[$form_fields[$f['field_key']]] ); //unset old field id |
|
| 354 | + unset( $form_fields[$f['field_key']] ); //unset old field key |
|
| 355 | 355 | } else { |
| 356 | 356 | // if no matching field id or key in this form, create the field |
| 357 | 357 | self::create_imported_field( $f, $imported ); |
@@ -418,8 +418,8 @@ discard block |
||
| 418 | 418 | if ( $f['type'] == 'form' || ( $f['type'] == 'divider' && FrmField::is_option_true( $f['field_options'], 'repeat' ) ) ) { |
| 419 | 419 | if ( FrmField::is_option_true( $f['field_options'], 'form_select' ) ) { |
| 420 | 420 | $form_select = (int) $f['field_options']['form_select']; |
| 421 | - if ( isset( $imported['forms'][ $form_select ] ) ) { |
|
| 422 | - $f['field_options']['form_select'] = $imported['forms'][ $form_select ]; |
|
| 421 | + if ( isset( $imported['forms'][$form_select] ) ) { |
|
| 422 | + $f['field_options']['form_select'] = $imported['forms'][$form_select]; |
|
| 423 | 423 | } |
| 424 | 424 | } |
| 425 | 425 | } |
@@ -439,8 +439,8 @@ discard block |
||
| 439 | 439 | |
| 440 | 440 | if ( FrmField::is_option_true_in_array( $f['field_options'], 'get_values_form' ) ) { |
| 441 | 441 | $old_form = $f['field_options']['get_values_form']; |
| 442 | - if ( isset( $imported['forms'][ $old_form ] ) ) { |
|
| 443 | - $f['field_options']['get_values_form'] = $imported['forms'][ $old_form ]; |
|
| 442 | + if ( isset( $imported['forms'][$old_form] ) ) { |
|
| 443 | + $f['field_options']['get_values_form'] = $imported['forms'][$old_form]; |
|
| 444 | 444 | } |
| 445 | 445 | } |
| 446 | 446 | } |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | private static function create_imported_field( $f, &$imported ) { |
| 456 | 456 | $new_id = FrmField::create( $f ); |
| 457 | 457 | if ( $new_id != false ) { |
| 458 | - $imported['imported']['fields']++; |
|
| 458 | + $imported['imported']['fields'] ++; |
|
| 459 | 459 | do_action( 'frm_after_field_is_imported', $f, $new_id ); |
| 460 | 460 | } |
| 461 | 461 | } |
@@ -586,17 +586,17 @@ discard block |
||
| 586 | 586 | self::update_postmeta( $post, $post_id ); |
| 587 | 587 | |
| 588 | 588 | $this_type = 'posts'; |
| 589 | - if ( isset( $post_types[ $post['post_type'] ] ) ) { |
|
| 590 | - $this_type = $post_types[ $post['post_type'] ]; |
|
| 589 | + if ( isset( $post_types[$post['post_type']] ) ) { |
|
| 590 | + $this_type = $post_types[$post['post_type']]; |
|
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) { |
| 594 | - $imported['updated'][ $this_type ]++; |
|
| 594 | + $imported['updated'][$this_type] ++; |
|
| 595 | 595 | } else { |
| 596 | - $imported['imported'][ $this_type ]++; |
|
| 596 | + $imported['imported'][$this_type] ++; |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | - $imported['posts'][ (int) $old_id ] = $post_id; |
|
| 599 | + $imported['posts'][(int) $old_id] = $post_id; |
|
| 600 | 600 | |
| 601 | 601 | do_action( 'frm_after_import_view', $post_id, $post ); |
| 602 | 602 | |
@@ -613,9 +613,9 @@ discard block |
||
| 613 | 613 | $post['attachment_url'] = (string) $item->attachment_url; |
| 614 | 614 | } |
| 615 | 615 | |
| 616 | - if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) { |
|
| 616 | + if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][(int) $post['menu_order']] ) ) { |
|
| 617 | 617 | // update to new form id |
| 618 | - $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ]; |
|
| 618 | + $post['menu_order'] = $imported['forms'][(int) $post['menu_order']]; |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | // Don't allow default styles to take over a site's default style |
@@ -642,8 +642,8 @@ discard block |
||
| 642 | 642 | ); |
| 643 | 643 | |
| 644 | 644 | //switch old form and field ids to new ones |
| 645 | - if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][ (int) $m['value'] ] ) ) { |
|
| 646 | - $m['value'] = $imported['forms'][ (int) $m['value'] ]; |
|
| 645 | + if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][(int) $m['value']] ) ) { |
|
| 646 | + $m['value'] = $imported['forms'][(int) $m['value']]; |
|
| 647 | 647 | } else { |
| 648 | 648 | $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] ); |
| 649 | 649 | |
@@ -654,15 +654,15 @@ discard block |
||
| 654 | 654 | } else if ( $m['key'] == 'frm_options' ) { |
| 655 | 655 | |
| 656 | 656 | foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) { |
| 657 | - if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) { |
|
| 658 | - $m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ]; |
|
| 657 | + if ( isset( $m['value'][$setting_name] ) && is_numeric( $m['value'][$setting_name] ) && isset( $frm_duplicate_ids[$m['value'][$setting_name]] ) ) { |
|
| 658 | + $m['value'][$setting_name] = $frm_duplicate_ids[$m['value'][$setting_name]]; |
|
| 659 | 659 | } |
| 660 | 660 | } |
| 661 | 661 | |
| 662 | 662 | $check_dup_array = array(); |
| 663 | 663 | if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) { |
| 664 | - if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) { |
|
| 665 | - $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ]; |
|
| 664 | + if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[$m['value']['order_by']] ) ) { |
|
| 665 | + $m['value']['order_by'] = $frm_duplicate_ids[$m['value']['order_by']]; |
|
| 666 | 666 | } else if ( is_array( $m['value']['order_by'] ) ) { |
| 667 | 667 | $check_dup_array[] = 'order_by'; |
| 668 | 668 | } |
@@ -673,9 +673,9 @@ discard block |
||
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | foreach ( $check_dup_array as $check_k ) { |
| 676 | - foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) { |
|
| 677 | - if ( isset( $frm_duplicate_ids[ $mv ] ) ) { |
|
| 678 | - $m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ]; |
|
| 676 | + foreach ( (array) $m['value'][$check_k] as $mk => $mv ) { |
|
| 677 | + if ( isset( $frm_duplicate_ids[$mv] ) ) { |
|
| 678 | + $m['value'][$check_k][$mk] = $frm_duplicate_ids[$mv]; |
|
| 679 | 679 | } |
| 680 | 680 | unset( $mk, $mv ); |
| 681 | 681 | } |
@@ -688,7 +688,7 @@ discard block |
||
| 688 | 688 | $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] ); |
| 689 | 689 | } |
| 690 | 690 | |
| 691 | - $post['postmeta'][ (string) $meta->meta_key ] = $m['value']; |
|
| 691 | + $post['postmeta'][(string) $meta->meta_key] = $m['value']; |
|
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | /** |
@@ -715,11 +715,11 @@ discard block |
||
| 715 | 715 | $name = (string) $c; |
| 716 | 716 | } |
| 717 | 717 | |
| 718 | - if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) { |
|
| 719 | - $post['tax_input'][ $taxonomy ] = array(); |
|
| 718 | + if ( ! isset( $post['tax_input'][$taxonomy] ) ) { |
|
| 719 | + $post['tax_input'][$taxonomy] = array(); |
|
| 720 | 720 | } |
| 721 | 721 | |
| 722 | - $post['tax_input'][ $taxonomy ][] = $name; |
|
| 722 | + $post['tax_input'][$taxonomy][] = $name; |
|
| 723 | 723 | unset( $name ); |
| 724 | 724 | } |
| 725 | 725 | } |
@@ -817,7 +817,7 @@ discard block |
||
| 817 | 817 | |
| 818 | 818 | $message = '<ul>'; |
| 819 | 819 | foreach ( $result as $type => $results ) { |
| 820 | - if ( ! isset( $t_strings[ $type ] ) ) { |
|
| 820 | + if ( ! isset( $t_strings[$type] ) ) { |
|
| 821 | 821 | // only print imported and updated |
| 822 | 822 | continue; |
| 823 | 823 | } |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | } |
| 830 | 830 | |
| 831 | 831 | if ( ! empty( $s_message ) ) { |
| 832 | - $message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> '; |
|
| 832 | + $message .= '<li><strong>' . $t_strings[$type] . ':</strong> '; |
|
| 833 | 833 | $message .= implode( ', ', $s_message ); |
| 834 | 834 | $message .= '</li>'; |
| 835 | 835 | } |
@@ -859,7 +859,7 @@ discard block |
||
| 859 | 859 | 'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ), |
| 860 | 860 | ); |
| 861 | 861 | |
| 862 | - $s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type ); |
|
| 862 | + $s_message[] = isset( $strings[$type] ) ? $strings[$type] : ' ' . $m . ' ' . ucfirst( $type ); |
|
| 863 | 863 | } |
| 864 | 864 | |
| 865 | 865 | /** |
@@ -960,8 +960,8 @@ discard block |
||
| 960 | 960 | $post_settings = array( 'post_type', 'post_category', 'post_content', 'post_excerpt', 'post_title', 'post_name', 'post_date', 'post_status', 'post_custom_fields', 'post_password' ); |
| 961 | 961 | |
| 962 | 962 | foreach ( $post_settings as $post_setting ) { |
| 963 | - if ( isset( $form_options[ $post_setting ] ) ) { |
|
| 964 | - $new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ]; |
|
| 963 | + if ( isset( $form_options[$post_setting] ) ) { |
|
| 964 | + $new_action['post_content'][$post_setting] = $form_options[$post_setting]; |
|
| 965 | 965 | } |
| 966 | 966 | unset( $post_setting ); |
| 967 | 967 | } |
@@ -991,7 +991,7 @@ discard block |
||
| 991 | 991 | if ( ! $exists ) { |
| 992 | 992 | // this isn't an email, but we need to use a class that will always be included |
| 993 | 993 | FrmDb::save_json_post( $new_action ); |
| 994 | - $imported['imported']['actions']++; |
|
| 994 | + $imported['imported']['actions'] ++; |
|
| 995 | 995 | } |
| 996 | 996 | } |
| 997 | 997 | |
@@ -1023,11 +1023,11 @@ discard block |
||
| 1023 | 1023 | foreach ( $post_content as $key => $setting ) { |
| 1024 | 1024 | if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) { |
| 1025 | 1025 | // Replace old IDs with new IDs |
| 1026 | - $post_content[ $key ] = str_replace( $old, $new, $setting ); |
|
| 1026 | + $post_content[$key] = str_replace( $old, $new, $setting ); |
|
| 1027 | 1027 | } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) { |
| 1028 | 1028 | foreach ( $setting as $k => $val ) { |
| 1029 | 1029 | // Replace old IDs with new IDs |
| 1030 | - $post_content[ $key ][ $k ] = str_replace( $old, $new, $val ); |
|
| 1030 | + $post_content[$key][$k] = str_replace( $old, $new, $val ); |
|
| 1031 | 1031 | } |
| 1032 | 1032 | } |
| 1033 | 1033 | unset( $key, $setting ); |
@@ -1057,7 +1057,7 @@ discard block |
||
| 1057 | 1057 | foreach ( $notifications as $new_notification ) { |
| 1058 | 1058 | $new_notification['post_type'] = $post_type; |
| 1059 | 1059 | $new_notification['post_excerpt'] = 'email'; |
| 1060 | - $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
|
| 1060 | + $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
|
| 1061 | 1061 | $new_notification['menu_order'] = $form_id; |
| 1062 | 1062 | $new_notification['post_status'] = 'publish'; |
| 1063 | 1063 | |
@@ -1070,7 +1070,7 @@ discard block |
||
| 1070 | 1070 | // Switch all other field IDs in email |
| 1071 | 1071 | $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] ); |
| 1072 | 1072 | } |
| 1073 | - $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
| 1073 | + $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
| 1074 | 1074 | |
| 1075 | 1075 | $exists = get_posts( |
| 1076 | 1076 | array( |
@@ -1083,7 +1083,7 @@ discard block |
||
| 1083 | 1083 | |
| 1084 | 1084 | if ( empty( $exists ) ) { |
| 1085 | 1085 | FrmDb::save_json_post( $new_notification ); |
| 1086 | - $imported['imported']['actions']++; |
|
| 1086 | + $imported['imported']['actions'] ++; |
|
| 1087 | 1087 | } |
| 1088 | 1088 | unset( $new_notification ); |
| 1089 | 1089 | } |
@@ -1102,8 +1102,8 @@ discard block |
||
| 1102 | 1102 | private static function remove_deprecated_notification_settings( $form_id, $form_options ) { |
| 1103 | 1103 | $delete_settings = array( 'notification', 'autoresponder', 'email_to' ); |
| 1104 | 1104 | foreach ( $delete_settings as $index ) { |
| 1105 | - if ( isset( $form_options[ $index ] ) ) { |
|
| 1106 | - unset( $form_options[ $index ] ); |
|
| 1105 | + if ( isset( $form_options[$index] ) ) { |
|
| 1106 | + unset( $form_options[$index] ); |
|
| 1107 | 1107 | } |
| 1108 | 1108 | } |
| 1109 | 1109 | FrmForm::update( $form_id, array( 'options' => $form_options ) ); |
@@ -1156,12 +1156,12 @@ discard block |
||
| 1156 | 1156 | 'reply_to_name' => '', |
| 1157 | 1157 | ); |
| 1158 | 1158 | foreach ( $reply_fields as $f => $val ) { |
| 1159 | - if ( isset( $notification[ $f ] ) ) { |
|
| 1160 | - $atts[ $f ] = $notification[ $f ]; |
|
| 1161 | - if ( 'custom' == $notification[ $f ] ) { |
|
| 1162 | - $atts[ $f ] = $notification[ 'cust_' . $f ]; |
|
| 1163 | - } else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) { |
|
| 1164 | - $atts[ $f ] = '[' . $atts[ $f ] . ']'; |
|
| 1159 | + if ( isset( $notification[$f] ) ) { |
|
| 1160 | + $atts[$f] = $notification[$f]; |
|
| 1161 | + if ( 'custom' == $notification[$f] ) { |
|
| 1162 | + $atts[$f] = $notification['cust_' . $f]; |
|
| 1163 | + } else if ( is_numeric( $atts[$f] ) && ! empty( $atts[$f] ) ) { |
|
| 1164 | + $atts[$f] = '[' . $atts[$f] . ']'; |
|
| 1165 | 1165 | } |
| 1166 | 1166 | } |
| 1167 | 1167 | unset( $f, $val ); |
@@ -1192,13 +1192,13 @@ discard block |
||
| 1192 | 1192 | foreach ( $atts['email_to'] as $key => $email_field ) { |
| 1193 | 1193 | |
| 1194 | 1194 | if ( is_numeric( $email_field ) ) { |
| 1195 | - $atts['email_to'][ $key ] = '[' . $email_field . ']'; |
|
| 1195 | + $atts['email_to'][$key] = '[' . $email_field . ']'; |
|
| 1196 | 1196 | } |
| 1197 | 1197 | |
| 1198 | 1198 | if ( strpos( $email_field, '|' ) ) { |
| 1199 | 1199 | $email_opt = explode( '|', $email_field ); |
| 1200 | 1200 | if ( isset( $email_opt[0] ) ) { |
| 1201 | - $atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
|
| 1201 | + $atts['email_to'][$key] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
|
| 1202 | 1202 | } |
| 1203 | 1203 | unset( $email_opt ); |
| 1204 | 1204 | } |
@@ -1219,12 +1219,12 @@ discard block |
||
| 1219 | 1219 | // Add more fields to the new notification |
| 1220 | 1220 | $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' ); |
| 1221 | 1221 | foreach ( $add_fields as $add_field ) { |
| 1222 | - if ( isset( $notification[ $add_field ] ) ) { |
|
| 1223 | - $new_notification['post_content'][ $add_field ] = $notification[ $add_field ]; |
|
| 1222 | + if ( isset( $notification[$add_field] ) ) { |
|
| 1223 | + $new_notification['post_content'][$add_field] = $notification[$add_field]; |
|
| 1224 | 1224 | } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) { |
| 1225 | - $new_notification['post_content'][ $add_field ] = 0; |
|
| 1225 | + $new_notification['post_content'][$add_field] = 0; |
|
| 1226 | 1226 | } else { |
| 1227 | - $new_notification['post_content'][ $add_field ] = ''; |
|
| 1227 | + $new_notification['post_content'][$add_field] = ''; |
|
| 1228 | 1228 | } |
| 1229 | 1229 | unset( $add_field ); |
| 1230 | 1230 | } |
@@ -1248,7 +1248,7 @@ discard block |
||
| 1248 | 1248 | if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) { |
| 1249 | 1249 | foreach ( $post_content['conditions'] as $email_key => $val ) { |
| 1250 | 1250 | if ( is_numeric( $email_key ) ) { |
| 1251 | - $post_content['conditions'][ $email_key ] = self::switch_action_field_ids( $val, array( 'hide_field' ) ); |
|
| 1251 | + $post_content['conditions'][$email_key] = self::switch_action_field_ids( $val, array( 'hide_field' ) ); |
|
| 1252 | 1252 | } |
| 1253 | 1253 | unset( $email_key, $val ); |
| 1254 | 1254 | } |
@@ -13,15 +13,15 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | public static $plug_version = '3.03.02'; |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * @since 1.07.02 |
|
| 18 | - * |
|
| 19 | - * @param none |
|
| 20 | - * @return string The version of this plugin |
|
| 21 | - */ |
|
| 22 | - public static function plugin_version() { |
|
| 23 | - return self::$plug_version; |
|
| 24 | - } |
|
| 16 | + /** |
|
| 17 | + * @since 1.07.02 |
|
| 18 | + * |
|
| 19 | + * @param none |
|
| 20 | + * @return string The version of this plugin |
|
| 21 | + */ |
|
| 22 | + public static function plugin_version() { |
|
| 23 | + return self::$plug_version; |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | 26 | public static function plugin_folder() { |
| 27 | 27 | return basename( self::plugin_path() ); |
@@ -31,29 +31,29 @@ discard block |
||
| 31 | 31 | return dirname( dirname( dirname( __FILE__ ) ) ); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public static function plugin_url() { |
|
| 35 | - //prevously FRM_URL constant |
|
| 34 | + public static function plugin_url() { |
|
| 35 | + //prevously FRM_URL constant |
|
| 36 | 36 | return plugins_url( '', self::plugin_path() . '/formidable.php' ); |
| 37 | - } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | 39 | public static function relative_plugin_url() { |
| 40 | 40 | return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() ); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @return string Site URL |
|
| 45 | - */ |
|
| 46 | - public static function site_url() { |
|
| 47 | - return site_url(); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Get the name of this site |
|
| 52 | - * Used for [sitename] shortcode |
|
| 53 | - * |
|
| 54 | - * @since 2.0 |
|
| 55 | - * @return string |
|
| 56 | - */ |
|
| 43 | + /** |
|
| 44 | + * @return string Site URL |
|
| 45 | + */ |
|
| 46 | + public static function site_url() { |
|
| 47 | + return site_url(); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Get the name of this site |
|
| 52 | + * Used for [sitename] shortcode |
|
| 53 | + * |
|
| 54 | + * @since 2.0 |
|
| 55 | + * @return string |
|
| 56 | + */ |
|
| 57 | 57 | public static function site_name() { |
| 58 | 58 | return get_option( 'blogname' ); |
| 59 | 59 | } |
@@ -71,14 +71,14 @@ discard block |
||
| 71 | 71 | return absint( apply_filters( 'frm_affiliate_id', 0 ) ); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Get the Formidable settings |
|
| 76 | - * |
|
| 77 | - * @since 2.0 |
|
| 78 | - * |
|
| 79 | - * @param None |
|
| 80 | - * @return FrmSettings $frm_setings |
|
| 81 | - */ |
|
| 74 | + /** |
|
| 75 | + * Get the Formidable settings |
|
| 76 | + * |
|
| 77 | + * @since 2.0 |
|
| 78 | + * |
|
| 79 | + * @param None |
|
| 80 | + * @return FrmSettings $frm_setings |
|
| 81 | + */ |
|
| 82 | 82 | public static function get_settings() { |
| 83 | 83 | global $frm_settings; |
| 84 | 84 | if ( empty( $frm_settings ) ) { |
@@ -119,50 +119,50 @@ discard block |
||
| 119 | 119 | return $is_formidable; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - /** |
|
| 123 | - * Check for certain page in Formidable settings |
|
| 124 | - * |
|
| 125 | - * @since 2.0 |
|
| 126 | - * |
|
| 127 | - * @param string $page The name of the page to check |
|
| 128 | - * @return boolean |
|
| 129 | - */ |
|
| 122 | + /** |
|
| 123 | + * Check for certain page in Formidable settings |
|
| 124 | + * |
|
| 125 | + * @since 2.0 |
|
| 126 | + * |
|
| 127 | + * @param string $page The name of the page to check |
|
| 128 | + * @return boolean |
|
| 129 | + */ |
|
| 130 | 130 | public static function is_admin_page( $page = 'formidable' ) { |
| 131 | - global $pagenow; |
|
| 131 | + global $pagenow; |
|
| 132 | 132 | $get_page = self::simple_get( 'page', 'sanitize_title' ); |
| 133 | - if ( $pagenow ) { |
|
| 133 | + if ( $pagenow ) { |
|
| 134 | 134 | // allow this to be true during ajax load i.e. ajax form builder loading |
| 135 | 135 | return ( $pagenow == 'admin.php' || $pagenow == 'admin-ajax.php' ) && $get_page == $page; |
| 136 | - } |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | 138 | return is_admin() && $get_page == $page; |
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * Check for the form preview page |
|
| 143 | - * |
|
| 144 | - * @since 2.0 |
|
| 145 | - * |
|
| 146 | - * @param None |
|
| 147 | - * @return boolean |
|
| 148 | - */ |
|
| 149 | - public static function is_preview_page() { |
|
| 150 | - global $pagenow; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * Check for the form preview page |
|
| 143 | + * |
|
| 144 | + * @since 2.0 |
|
| 145 | + * |
|
| 146 | + * @param None |
|
| 147 | + * @return boolean |
|
| 148 | + */ |
|
| 149 | + public static function is_preview_page() { |
|
| 150 | + global $pagenow; |
|
| 151 | 151 | $action = FrmAppHelper::simple_get( 'action', 'sanitize_title' ); |
| 152 | 152 | return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview'; |
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * Check for ajax except the form preview page |
|
| 157 | - * |
|
| 158 | - * @since 2.0 |
|
| 159 | - * |
|
| 160 | - * @param None |
|
| 161 | - * @return boolean |
|
| 162 | - */ |
|
| 163 | - public static function doing_ajax() { |
|
| 164 | - return self::wp_doing_ajax() && ! self::is_preview_page(); |
|
| 165 | - } |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * Check for ajax except the form preview page |
|
| 157 | + * |
|
| 158 | + * @since 2.0 |
|
| 159 | + * |
|
| 160 | + * @param None |
|
| 161 | + * @return boolean |
|
| 162 | + */ |
|
| 163 | + public static function doing_ajax() { |
|
| 164 | + return self::wp_doing_ajax() && ! self::is_preview_page(); |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | 167 | public static function js_suffix() { |
| 168 | 168 | return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
@@ -189,81 +189,81 @@ discard block |
||
| 189 | 189 | return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching']; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - /** |
|
| 193 | - * Check if on an admin page |
|
| 194 | - * |
|
| 195 | - * @since 2.0 |
|
| 196 | - * |
|
| 197 | - * @param None |
|
| 198 | - * @return boolean |
|
| 199 | - */ |
|
| 200 | - public static function is_admin() { |
|
| 201 | - return is_admin() && ! self::wp_doing_ajax(); |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - /** |
|
| 205 | - * Check if value contains blank value or empty array |
|
| 206 | - * |
|
| 207 | - * @since 2.0 |
|
| 208 | - * @param mixed $value - value to check |
|
| 192 | + /** |
|
| 193 | + * Check if on an admin page |
|
| 194 | + * |
|
| 195 | + * @since 2.0 |
|
| 196 | + * |
|
| 197 | + * @param None |
|
| 198 | + * @return boolean |
|
| 199 | + */ |
|
| 200 | + public static function is_admin() { |
|
| 201 | + return is_admin() && ! self::wp_doing_ajax(); |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + /** |
|
| 205 | + * Check if value contains blank value or empty array |
|
| 206 | + * |
|
| 207 | + * @since 2.0 |
|
| 208 | + * @param mixed $value - value to check |
|
| 209 | 209 | * @param string |
| 210 | - * @return boolean |
|
| 211 | - */ |
|
| 212 | - public static function is_empty_value( $value, $empty = '' ) { |
|
| 213 | - return ( is_array( $value ) && empty( $value ) ) || $value === $empty; |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 217 | - return ! self::is_empty_value( $value, $empty ); |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - /** |
|
| 221 | - * Get any value from the $_SERVER |
|
| 222 | - * |
|
| 223 | - * @since 2.0 |
|
| 224 | - * @param string $value |
|
| 225 | - * @return string |
|
| 226 | - */ |
|
| 210 | + * @return boolean |
|
| 211 | + */ |
|
| 212 | + public static function is_empty_value( $value, $empty = '' ) { |
|
| 213 | + return ( is_array( $value ) && empty( $value ) ) || $value === $empty; |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 217 | + return ! self::is_empty_value( $value, $empty ); |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * Get any value from the $_SERVER |
|
| 222 | + * |
|
| 223 | + * @since 2.0 |
|
| 224 | + * @param string $value |
|
| 225 | + * @return string |
|
| 226 | + */ |
|
| 227 | 227 | public static function get_server_value( $value ) { |
| 228 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * Check for the IP address in several places |
|
| 233 | - * Used by [ip] shortcode |
|
| 234 | - * |
|
| 235 | - * @return string The IP address of the current user |
|
| 236 | - */ |
|
| 237 | - public static function get_ip_address() { |
|
| 228 | + return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * Check for the IP address in several places |
|
| 233 | + * Used by [ip] shortcode |
|
| 234 | + * |
|
| 235 | + * @return string The IP address of the current user |
|
| 236 | + */ |
|
| 237 | + public static function get_ip_address() { |
|
| 238 | 238 | $ip = ''; |
| 239 | 239 | foreach ( array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR' ) as $key ) { |
| 240 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 241 | - continue; |
|
| 242 | - } |
|
| 240 | + if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 241 | + continue; |
|
| 242 | + } |
|
| 243 | 243 | |
| 244 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 244 | + foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 245 | 245 | $ip = trim( $ip ); // just to be safe |
| 246 | 246 | |
| 247 | 247 | if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) { |
| 248 | - return sanitize_text_field( $ip ); |
|
| 249 | - } |
|
| 250 | - } |
|
| 251 | - } |
|
| 248 | + return sanitize_text_field( $ip ); |
|
| 249 | + } |
|
| 250 | + } |
|
| 251 | + } |
|
| 252 | 252 | |
| 253 | 253 | return sanitize_text_field( $ip ); |
| 254 | - } |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | - public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 256 | + public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 257 | 257 | if ( strpos( $param, '[' ) ) { |
| 258 | 258 | $params = explode( '[', $param ); |
| 259 | - $param = $params[0]; |
|
| 260 | - } |
|
| 259 | + $param = $params[0]; |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | 262 | if ( $src == 'get' ) { |
| 263 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 264 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 265 | - $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 266 | - } |
|
| 263 | + $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 264 | + if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 265 | + $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 266 | + } |
|
| 267 | 267 | self::sanitize_value( $sanitize, $value ); |
| 268 | 268 | } else { |
| 269 | 269 | $value = self::get_simple_request( |
@@ -287,8 +287,8 @@ discard block |
||
| 287 | 287 | } |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - return $value; |
|
| 291 | - } |
|
| 290 | + return $value; |
|
| 291 | + } |
|
| 292 | 292 | |
| 293 | 293 | public static function get_post_param( $param, $default = '', $sanitize = '' ) { |
| 294 | 294 | return self::get_simple_request( |
@@ -356,12 +356,12 @@ discard block |
||
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | /** |
| 359 | - * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 360 | - * |
|
| 361 | - * @since 2.0.8 |
|
| 362 | - * @param string $value |
|
| 363 | - * @return string $value |
|
| 364 | - */ |
|
| 359 | + * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 360 | + * |
|
| 361 | + * @since 2.0.8 |
|
| 362 | + * @param string $value |
|
| 363 | + * @return string $value |
|
| 364 | + */ |
|
| 365 | 365 | public static function preserve_backslashes( $value ) { |
| 366 | 366 | // If backslashes have already been added, don't add them again |
| 367 | 367 | if ( strpos( $value, '\\\\' ) === false ) { |
@@ -383,14 +383,14 @@ discard block |
||
| 383 | 383 | } |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | - public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 387 | - $temp_values = $values; |
|
| 388 | - foreach ( $temp_values as $k => $val ) { |
|
| 389 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 386 | + public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 387 | + $temp_values = $values; |
|
| 388 | + foreach ( $temp_values as $k => $val ) { |
|
| 389 | + if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 390 | 390 | $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
| 391 | - } |
|
| 392 | - } |
|
| 393 | - } |
|
| 391 | + } |
|
| 392 | + } |
|
| 393 | + } |
|
| 394 | 394 | |
| 395 | 395 | /** |
| 396 | 396 | * @deprecated 3.01 |
@@ -516,39 +516,39 @@ discard block |
||
| 516 | 516 | ); |
| 517 | 517 | } |
| 518 | 518 | |
| 519 | - /** |
|
| 520 | - * Used when switching the action for a bulk action |
|
| 521 | - * @since 2.0 |
|
| 522 | - */ |
|
| 519 | + /** |
|
| 520 | + * Used when switching the action for a bulk action |
|
| 521 | + * @since 2.0 |
|
| 522 | + */ |
|
| 523 | 523 | public static function remove_get_action() { |
| 524 | 524 | if ( ! isset( $_GET ) ) { |
| 525 | 525 | return; |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | - $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 529 | - if ( ! empty( $new_action ) ) { |
|
| 528 | + $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 529 | + if ( ! empty( $new_action ) ) { |
|
| 530 | 530 | $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); |
| 531 | - } |
|
| 532 | - } |
|
| 531 | + } |
|
| 532 | + } |
|
| 533 | 533 | |
| 534 | - /** |
|
| 535 | - * Check the WP query for a parameter |
|
| 536 | - * |
|
| 537 | - * @since 2.0 |
|
| 538 | - * @return string|array |
|
| 539 | - */ |
|
| 540 | - public static function get_query_var( $value, $param ) { |
|
| 541 | - if ( $value != '' ) { |
|
| 542 | - return $value; |
|
| 543 | - } |
|
| 534 | + /** |
|
| 535 | + * Check the WP query for a parameter |
|
| 536 | + * |
|
| 537 | + * @since 2.0 |
|
| 538 | + * @return string|array |
|
| 539 | + */ |
|
| 540 | + public static function get_query_var( $value, $param ) { |
|
| 541 | + if ( $value != '' ) { |
|
| 542 | + return $value; |
|
| 543 | + } |
|
| 544 | 544 | |
| 545 | - global $wp_query; |
|
| 546 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 547 | - $value = $wp_query->query_vars[ $param ]; |
|
| 548 | - } |
|
| 545 | + global $wp_query; |
|
| 546 | + if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 547 | + $value = $wp_query->query_vars[ $param ]; |
|
| 548 | + } |
|
| 549 | 549 | |
| 550 | - return $value; |
|
| 551 | - } |
|
| 550 | + return $value; |
|
| 551 | + } |
|
| 552 | 552 | |
| 553 | 553 | /** |
| 554 | 554 | * @since 3.0 |
@@ -570,16 +570,16 @@ discard block |
||
| 570 | 570 | } |
| 571 | 571 | } |
| 572 | 572 | |
| 573 | - /** |
|
| 574 | - * @param string $type |
|
| 575 | - */ |
|
| 576 | - public static function trigger_hook_load( $type, $object = null ) { |
|
| 577 | - // only load the form hooks once |
|
| 573 | + /** |
|
| 574 | + * @param string $type |
|
| 575 | + */ |
|
| 576 | + public static function trigger_hook_load( $type, $object = null ) { |
|
| 577 | + // only load the form hooks once |
|
| 578 | 578 | $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object ); |
| 579 | - if ( ! $hooks_loaded ) { |
|
| 579 | + if ( ! $hooks_loaded ) { |
|
| 580 | 580 | do_action( 'frm_load_' . $type . '_hooks' ); |
| 581 | - } |
|
| 582 | - } |
|
| 581 | + } |
|
| 582 | + } |
|
| 583 | 583 | |
| 584 | 584 | /** |
| 585 | 585 | * Save all front-end js scripts into a single file |
@@ -604,29 +604,29 @@ discard block |
||
| 604 | 604 | $new_file->combine_files( $files ); |
| 605 | 605 | } |
| 606 | 606 | |
| 607 | - /** |
|
| 608 | - * Check a value from a shortcode to see if true or false. |
|
| 609 | - * True when value is 1, true, 'true', 'yes' |
|
| 610 | - * |
|
| 611 | - * @since 1.07.10 |
|
| 612 | - * |
|
| 613 | - * @param string $value The value to compare |
|
| 614 | - * @return boolean True or False |
|
| 615 | - */ |
|
| 607 | + /** |
|
| 608 | + * Check a value from a shortcode to see if true or false. |
|
| 609 | + * True when value is 1, true, 'true', 'yes' |
|
| 610 | + * |
|
| 611 | + * @since 1.07.10 |
|
| 612 | + * |
|
| 613 | + * @param string $value The value to compare |
|
| 614 | + * @return boolean True or False |
|
| 615 | + */ |
|
| 616 | 616 | public static function is_true( $value ) { |
| 617 | - return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 618 | - } |
|
| 617 | + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 618 | + } |
|
| 619 | 619 | |
| 620 | - /** |
|
| 621 | - * Used to filter shortcode in text widgets |
|
| 620 | + /** |
|
| 621 | + * Used to filter shortcode in text widgets |
|
| 622 | 622 | * |
| 623 | 623 | * @deprecated 2.5.4 |
| 624 | 624 | * @codeCoverageIgnore |
| 625 | - */ |
|
| 626 | - public static function widget_text_filter_callback( $matches ) { |
|
| 625 | + */ |
|
| 626 | + public static function widget_text_filter_callback( $matches ) { |
|
| 627 | 627 | _deprecated_function( __METHOD__, '2.5.4' ); |
| 628 | - return do_shortcode( $matches[0] ); |
|
| 629 | - } |
|
| 628 | + return do_shortcode( $matches[0] ); |
|
| 629 | + } |
|
| 630 | 630 | |
| 631 | 631 | public static function get_pages() { |
| 632 | 632 | $query = array( |
@@ -639,10 +639,10 @@ discard block |
||
| 639 | 639 | return get_posts( $query ); |
| 640 | 640 | } |
| 641 | 641 | |
| 642 | - public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 643 | - $pages = self::get_pages(); |
|
| 642 | + public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 643 | + $pages = self::get_pages(); |
|
| 644 | 644 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
| 645 | - ?> |
|
| 645 | + ?> |
|
| 646 | 646 | <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown"> |
| 647 | 647 | <option value=""> </option> |
| 648 | 648 | <?php foreach ( $pages as $page ) { ?> |
@@ -652,16 +652,16 @@ discard block |
||
| 652 | 652 | <?php } ?> |
| 653 | 653 | </select> |
| 654 | 654 | <?php |
| 655 | - } |
|
| 655 | + } |
|
| 656 | 656 | |
| 657 | 657 | public static function post_edit_link( $post_id ) { |
| 658 | 658 | $post = get_post( $post_id ); |
| 659 | - if ( $post ) { |
|
| 659 | + if ( $post ) { |
|
| 660 | 660 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
| 661 | 661 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
| 662 | - } |
|
| 663 | - return ''; |
|
| 664 | - } |
|
| 662 | + } |
|
| 663 | + return ''; |
|
| 664 | + } |
|
| 665 | 665 | |
| 666 | 666 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
| 667 | 667 | ?> |
@@ -672,73 +672,73 @@ discard block |
||
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | public static function roles_options( $capability ) { |
| 675 | - global $frm_vars; |
|
| 675 | + global $frm_vars; |
|
| 676 | 676 | if ( isset( $frm_vars['editable_roles'] ) ) { |
| 677 | - $editable_roles = $frm_vars['editable_roles']; |
|
| 678 | - } else { |
|
| 679 | - $editable_roles = get_editable_roles(); |
|
| 680 | - $frm_vars['editable_roles'] = $editable_roles; |
|
| 681 | - } |
|
| 677 | + $editable_roles = $frm_vars['editable_roles']; |
|
| 678 | + } else { |
|
| 679 | + $editable_roles = get_editable_roles(); |
|
| 680 | + $frm_vars['editable_roles'] = $editable_roles; |
|
| 681 | + } |
|
| 682 | 682 | |
| 683 | - foreach ( $editable_roles as $role => $details ) { |
|
| 683 | + foreach ( $editable_roles as $role => $details ) { |
|
| 684 | 684 | $name = translate_user_role( $details['name'] ); |
| 685 | 685 | ?> |
| 686 | 686 | <option value="<?php echo esc_attr( $role ); ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ); ?> </option> |
| 687 | 687 | <?php |
| 688 | 688 | unset( $role, $details ); |
| 689 | - } |
|
| 690 | - } |
|
| 689 | + } |
|
| 690 | + } |
|
| 691 | 691 | |
| 692 | 692 | public static function frm_capabilities( $type = 'auto' ) { |
| 693 | - $cap = array( |
|
| 694 | - 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 695 | - 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 696 | - 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 697 | - 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 698 | - 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 699 | - 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 700 | - ); |
|
| 693 | + $cap = array( |
|
| 694 | + 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 695 | + 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 696 | + 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 697 | + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 698 | + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 699 | + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 700 | + ); |
|
| 701 | 701 | |
| 702 | 702 | if ( ! self::pro_is_installed() && 'pro' != $type ) { |
| 703 | - return $cap; |
|
| 704 | - } |
|
| 703 | + return $cap; |
|
| 704 | + } |
|
| 705 | 705 | |
| 706 | - $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 707 | - $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 708 | - $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 709 | - $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 706 | + $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 707 | + $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 708 | + $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 709 | + $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 710 | 710 | |
| 711 | - return $cap; |
|
| 712 | - } |
|
| 711 | + return $cap; |
|
| 712 | + } |
|
| 713 | 713 | |
| 714 | 714 | public static function user_has_permission( $needed_role ) { |
| 715 | - if ( $needed_role == '-1' ) { |
|
| 716 | - return false; |
|
| 715 | + if ( $needed_role == '-1' ) { |
|
| 716 | + return false; |
|
| 717 | 717 | } |
| 718 | 718 | |
| 719 | - // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 720 | - if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 721 | - return true; |
|
| 722 | - } |
|
| 719 | + // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 720 | + if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 721 | + return true; |
|
| 722 | + } |
|
| 723 | 723 | |
| 724 | - $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 725 | - foreach ( $roles as $role ) { |
|
| 724 | + $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 725 | + foreach ( $roles as $role ) { |
|
| 726 | 726 | if ( current_user_can( $role ) ) { |
| 727 | - return true; |
|
| 727 | + return true; |
|
| 728 | 728 | } |
| 729 | - if ( $role == $needed_role ) { |
|
| 730 | - break; |
|
| 729 | + if ( $role == $needed_role ) { |
|
| 730 | + break; |
|
| 731 | 731 | } |
| 732 | - } |
|
| 733 | - return false; |
|
| 734 | - } |
|
| 735 | - |
|
| 736 | - /** |
|
| 737 | - * Make sure administrators can see Formidable menu |
|
| 738 | - * |
|
| 739 | - * @since 2.0 |
|
| 740 | - */ |
|
| 741 | - public static function maybe_add_permissions() { |
|
| 732 | + } |
|
| 733 | + return false; |
|
| 734 | + } |
|
| 735 | + |
|
| 736 | + /** |
|
| 737 | + * Make sure administrators can see Formidable menu |
|
| 738 | + * |
|
| 739 | + * @since 2.0 |
|
| 740 | + */ |
|
| 741 | + public static function maybe_add_permissions() { |
|
| 742 | 742 | self::force_capability( 'frm_view_entries' ); |
| 743 | 743 | |
| 744 | 744 | if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) { |
@@ -747,12 +747,12 @@ discard block |
||
| 747 | 747 | |
| 748 | 748 | $user_id = get_current_user_id(); |
| 749 | 749 | $user = new WP_User( $user_id ); |
| 750 | - $frm_roles = self::frm_capabilities(); |
|
| 751 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 750 | + $frm_roles = self::frm_capabilities(); |
|
| 751 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 752 | 752 | $user->add_cap( $frm_role ); |
| 753 | 753 | unset( $frm_role, $frm_role_description ); |
| 754 | - } |
|
| 755 | - } |
|
| 754 | + } |
|
| 755 | + } |
|
| 756 | 756 | |
| 757 | 757 | /** |
| 758 | 758 | * Make sure admins have permission to see the menu items |
@@ -768,28 +768,28 @@ discard block |
||
| 768 | 768 | } |
| 769 | 769 | } |
| 770 | 770 | |
| 771 | - /** |
|
| 772 | - * Check if the user has permision for action. |
|
| 773 | - * Return permission message and stop the action if no permission |
|
| 774 | - * @since 2.0 |
|
| 775 | - * @param string $permission |
|
| 776 | - */ |
|
| 771 | + /** |
|
| 772 | + * Check if the user has permision for action. |
|
| 773 | + * Return permission message and stop the action if no permission |
|
| 774 | + * @since 2.0 |
|
| 775 | + * @param string $permission |
|
| 776 | + */ |
|
| 777 | 777 | public static function permission_check( $permission, $show_message = 'show' ) { |
| 778 | 778 | $permission_error = self::permission_nonce_error( $permission ); |
| 779 | - if ( $permission_error !== false ) { |
|
| 780 | - if ( 'hide' == $show_message ) { |
|
| 781 | - $permission_error = ''; |
|
| 782 | - } |
|
| 779 | + if ( $permission_error !== false ) { |
|
| 780 | + if ( 'hide' == $show_message ) { |
|
| 781 | + $permission_error = ''; |
|
| 782 | + } |
|
| 783 | 783 | wp_die( esc_html( $permission_error ) ); |
| 784 | - } |
|
| 785 | - } |
|
| 786 | - |
|
| 787 | - /** |
|
| 788 | - * Check user permission and nonce |
|
| 789 | - * @since 2.0 |
|
| 790 | - * @param string $permission |
|
| 791 | - * @return false|string The permission message or false if allowed |
|
| 792 | - */ |
|
| 784 | + } |
|
| 785 | + } |
|
| 786 | + |
|
| 787 | + /** |
|
| 788 | + * Check user permission and nonce |
|
| 789 | + * @since 2.0 |
|
| 790 | + * @param string $permission |
|
| 791 | + * @return false|string The permission message or false if allowed |
|
| 792 | + */ |
|
| 793 | 793 | public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) { |
| 794 | 794 | if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) { |
| 795 | 795 | $frm_settings = self::get_settings(); |
@@ -798,22 +798,22 @@ discard block |
||
| 798 | 798 | |
| 799 | 799 | $error = false; |
| 800 | 800 | if ( empty( $nonce_name ) ) { |
| 801 | - return $error; |
|
| 802 | - } |
|
| 801 | + return $error; |
|
| 802 | + } |
|
| 803 | 803 | |
| 804 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 805 | - $frm_settings = self::get_settings(); |
|
| 806 | - $error = $frm_settings->admin_permission; |
|
| 807 | - } |
|
| 804 | + if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 805 | + $frm_settings = self::get_settings(); |
|
| 806 | + $error = $frm_settings->admin_permission; |
|
| 807 | + } |
|
| 808 | 808 | |
| 809 | - return $error; |
|
| 810 | - } |
|
| 809 | + return $error; |
|
| 810 | + } |
|
| 811 | 811 | |
| 812 | - public static function checked( $values, $current ) { |
|
| 812 | + public static function checked( $values, $current ) { |
|
| 813 | 813 | if ( self::check_selected( $values, $current ) ) { |
| 814 | - echo ' checked="checked"'; |
|
| 814 | + echo ' checked="checked"'; |
|
| 815 | 815 | } |
| 816 | - } |
|
| 816 | + } |
|
| 817 | 817 | |
| 818 | 818 | public static function check_selected( $values, $current ) { |
| 819 | 819 | $values = self::recursive_function_map( $values, 'trim' ); |
@@ -851,24 +851,24 @@ discard block |
||
| 851 | 851 | return (bool) count( array_filter( array_keys( $array ), 'is_string' ) ); |
| 852 | 852 | } |
| 853 | 853 | |
| 854 | - /** |
|
| 855 | - * Flatten a multi-dimensional array |
|
| 856 | - */ |
|
| 854 | + /** |
|
| 855 | + * Flatten a multi-dimensional array |
|
| 856 | + */ |
|
| 857 | 857 | public static function array_flatten( $array, $keys = 'keep' ) { |
| 858 | - $return = array(); |
|
| 859 | - foreach ( $array as $key => $value ) { |
|
| 858 | + $return = array(); |
|
| 859 | + foreach ( $array as $key => $value ) { |
|
| 860 | 860 | if ( is_array( $value ) ) { |
| 861 | 861 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
| 862 | - } else { |
|
| 862 | + } else { |
|
| 863 | 863 | if ( $keys == 'keep' ) { |
| 864 | 864 | $return[ $key ] = $value; |
| 865 | 865 | } else { |
| 866 | 866 | $return[] = $value; |
| 867 | 867 | } |
| 868 | - } |
|
| 869 | - } |
|
| 870 | - return $return; |
|
| 871 | - } |
|
| 868 | + } |
|
| 869 | + } |
|
| 870 | + return $return; |
|
| 871 | + } |
|
| 872 | 872 | |
| 873 | 873 | public static function esc_textarea( $text, $is_rich_text = false ) { |
| 874 | 874 | $safe_text = str_replace( '"', '"', $text ); |
@@ -879,10 +879,10 @@ discard block |
||
| 879 | 879 | return apply_filters( 'esc_textarea', $safe_text, $text ); |
| 880 | 880 | } |
| 881 | 881 | |
| 882 | - /** |
|
| 883 | - * Add auto paragraphs to text areas |
|
| 884 | - * @since 2.0 |
|
| 885 | - */ |
|
| 882 | + /** |
|
| 883 | + * Add auto paragraphs to text areas |
|
| 884 | + * @since 2.0 |
|
| 885 | + */ |
|
| 886 | 886 | public static function use_wpautop( $content ) { |
| 887 | 887 | if ( apply_filters( 'frm_use_wpautop', true ) ) { |
| 888 | 888 | $content = wpautop( str_replace( '<br>', '<br />', $content ) ); |
@@ -891,26 +891,26 @@ discard block |
||
| 891 | 891 | } |
| 892 | 892 | |
| 893 | 893 | public static function replace_quotes( $val ) { |
| 894 | - //Replace double quotes |
|
| 894 | + //Replace double quotes |
|
| 895 | 895 | $val = str_replace( array( '“', '”', '″' ), '"', $val ); |
| 896 | - //Replace single quotes |
|
| 897 | - $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 898 | - return $val; |
|
| 899 | - } |
|
| 900 | - |
|
| 901 | - /** |
|
| 902 | - * @since 2.0 |
|
| 903 | - * @return string The base Google APIS url for the current version of jQuery UI |
|
| 904 | - */ |
|
| 905 | - public static function jquery_ui_base_url() { |
|
| 896 | + //Replace single quotes |
|
| 897 | + $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 898 | + return $val; |
|
| 899 | + } |
|
| 900 | + |
|
| 901 | + /** |
|
| 902 | + * @since 2.0 |
|
| 903 | + * @return string The base Google APIS url for the current version of jQuery UI |
|
| 904 | + */ |
|
| 905 | + public static function jquery_ui_base_url() { |
|
| 906 | 906 | $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' ); |
| 907 | 907 | $url = apply_filters( 'frm_jquery_ui_base_url', $url ); |
| 908 | - return $url; |
|
| 909 | - } |
|
| 908 | + return $url; |
|
| 909 | + } |
|
| 910 | 910 | |
| 911 | - /** |
|
| 912 | - * @param string $handle |
|
| 913 | - */ |
|
| 911 | + /** |
|
| 912 | + * @param string $handle |
|
| 913 | + */ |
|
| 914 | 914 | public static function script_version( $handle, $default = 0 ) { |
| 915 | 915 | global $wp_scripts; |
| 916 | 916 | if ( ! $wp_scripts ) { |
@@ -932,12 +932,12 @@ discard block |
||
| 932 | 932 | |
| 933 | 933 | public static function js_redirect( $url ) { |
| 934 | 934 | return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>'; |
| 935 | - } |
|
| 935 | + } |
|
| 936 | 936 | |
| 937 | 937 | public static function get_user_id_param( $user_id ) { |
| 938 | 938 | if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) { |
| 939 | - return $user_id; |
|
| 940 | - } |
|
| 939 | + return $user_id; |
|
| 940 | + } |
|
| 941 | 941 | |
| 942 | 942 | $user_id = sanitize_text_field( $user_id ); |
| 943 | 943 | if ( $user_id == 'current' ) { |
@@ -949,14 +949,14 @@ discard block |
||
| 949 | 949 | $user = get_user_by( 'login', $user_id ); |
| 950 | 950 | } |
| 951 | 951 | |
| 952 | - if ( $user ) { |
|
| 953 | - $user_id = $user->ID; |
|
| 954 | - } |
|
| 952 | + if ( $user ) { |
|
| 953 | + $user_id = $user->ID; |
|
| 954 | + } |
|
| 955 | 955 | unset( $user ); |
| 956 | - } |
|
| 956 | + } |
|
| 957 | 957 | |
| 958 | - return $user_id; |
|
| 959 | - } |
|
| 958 | + return $user_id; |
|
| 959 | + } |
|
| 960 | 960 | |
| 961 | 961 | public static function get_file_contents( $filename, $atts = array() ) { |
| 962 | 962 | if ( ! is_file( $filename ) ) { |
@@ -971,28 +971,28 @@ discard block |
||
| 971 | 971 | return $contents; |
| 972 | 972 | } |
| 973 | 973 | |
| 974 | - /** |
|
| 975 | - * @param string $table_name |
|
| 976 | - * @param string $column |
|
| 974 | + /** |
|
| 975 | + * @param string $table_name |
|
| 976 | + * @param string $column |
|
| 977 | 977 | * @param int $id |
| 978 | 978 | * @param int $num_chars |
| 979 | - */ |
|
| 980 | - public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 981 | - $key = ''; |
|
| 979 | + */ |
|
| 980 | + public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 981 | + $key = ''; |
|
| 982 | 982 | |
| 983 | - if ( ! empty( $name ) ) { |
|
| 983 | + if ( ! empty( $name ) ) { |
|
| 984 | 984 | $key = sanitize_key( $name ); |
| 985 | - } |
|
| 985 | + } |
|
| 986 | 986 | |
| 987 | 987 | if ( empty( $key ) ) { |
| 988 | 988 | $max_slug_value = pow( 36, $num_chars ); |
| 989 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 989 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 990 | 990 | $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); |
| 991 | - } |
|
| 991 | + } |
|
| 992 | 992 | |
| 993 | 993 | if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
| 994 | 994 | $key = $key . 'a'; |
| 995 | - } |
|
| 995 | + } |
|
| 996 | 996 | |
| 997 | 997 | $key_check = FrmDb::get_var( |
| 998 | 998 | $table_name, |
@@ -1004,7 +1004,7 @@ discard block |
||
| 1004 | 1004 | ); |
| 1005 | 1005 | |
| 1006 | 1006 | if ( $key_check || is_numeric( $key_check ) ) { |
| 1007 | - $suffix = 2; |
|
| 1007 | + $suffix = 2; |
|
| 1008 | 1008 | do { |
| 1009 | 1009 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
| 1010 | 1010 | $key_check = FrmDb::get_var( |
@@ -1018,19 +1018,19 @@ discard block |
||
| 1018 | 1018 | $suffix++; |
| 1019 | 1019 | } while ( $key_check || is_numeric( $key_check ) ); |
| 1020 | 1020 | $key = $alt_post_name; |
| 1021 | - } |
|
| 1022 | - return $key; |
|
| 1023 | - } |
|
| 1024 | - |
|
| 1025 | - /** |
|
| 1026 | - * Editing a Form or Entry |
|
| 1027 | - * @param string $table |
|
| 1028 | - * @return bool|array |
|
| 1029 | - */ |
|
| 1030 | - public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1031 | - if ( ! $record ) { |
|
| 1032 | - return false; |
|
| 1033 | - } |
|
| 1021 | + } |
|
| 1022 | + return $key; |
|
| 1023 | + } |
|
| 1024 | + |
|
| 1025 | + /** |
|
| 1026 | + * Editing a Form or Entry |
|
| 1027 | + * @param string $table |
|
| 1028 | + * @return bool|array |
|
| 1029 | + */ |
|
| 1030 | + public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1031 | + if ( ! $record ) { |
|
| 1032 | + return false; |
|
| 1033 | + } |
|
| 1034 | 1034 | |
| 1035 | 1035 | if ( empty( $post_values ) ) { |
| 1036 | 1036 | $post_values = stripslashes_deep( $_POST ); |
@@ -1053,14 +1053,14 @@ discard block |
||
| 1053 | 1053 | |
| 1054 | 1054 | self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) ); |
| 1055 | 1055 | |
| 1056 | - if ( $table == 'entries' ) { |
|
| 1057 | - $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1058 | - } else if ( $table == 'forms' ) { |
|
| 1059 | - $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1060 | - } |
|
| 1056 | + if ( $table == 'entries' ) { |
|
| 1057 | + $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1058 | + } else if ( $table == 'forms' ) { |
|
| 1059 | + $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1060 | + } |
|
| 1061 | 1061 | |
| 1062 | - return $values; |
|
| 1063 | - } |
|
| 1062 | + return $values; |
|
| 1063 | + } |
|
| 1064 | 1064 | |
| 1065 | 1065 | private static function prepare_field_arrays( $fields, $record, array &$values, $args ) { |
| 1066 | 1066 | if ( ! empty( $fields ) ) { |
@@ -1073,15 +1073,15 @@ discard block |
||
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | 1075 | private static function fill_field_defaults( $field, $record, array &$values, $args ) { |
| 1076 | - $post_values = $args['post_values']; |
|
| 1076 | + $post_values = $args['post_values']; |
|
| 1077 | 1077 | |
| 1078 | - if ( $args['default'] ) { |
|
| 1079 | - $meta_value = $field->default_value; |
|
| 1080 | - } else { |
|
| 1078 | + if ( $args['default'] ) { |
|
| 1079 | + $meta_value = $field->default_value; |
|
| 1080 | + } else { |
|
| 1081 | 1081 | if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) { |
| 1082 | 1082 | if ( ! isset( $field->field_options['custom_field'] ) ) { |
| 1083 | - $field->field_options['custom_field'] = ''; |
|
| 1084 | - } |
|
| 1083 | + $field->field_options['custom_field'] = ''; |
|
| 1084 | + } |
|
| 1085 | 1085 | $meta_value = FrmProEntryMetaHelper::get_post_value( |
| 1086 | 1086 | $record->post_id, |
| 1087 | 1087 | $field->field_options['post_field'], |
@@ -1093,31 +1093,31 @@ discard block |
||
| 1093 | 1093 | 'field' => $field, |
| 1094 | 1094 | ) |
| 1095 | 1095 | ); |
| 1096 | - } else { |
|
| 1096 | + } else { |
|
| 1097 | 1097 | $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); |
| 1098 | - } |
|
| 1099 | - } |
|
| 1098 | + } |
|
| 1099 | + } |
|
| 1100 | 1100 | |
| 1101 | 1101 | $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
| 1102 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1102 | + $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1103 | 1103 | |
| 1104 | 1104 | $field_array = self::start_field_array( $field ); |
| 1105 | 1105 | $field_array['value'] = $new_value; |
| 1106 | 1106 | $field_array['type'] = apply_filters( 'frm_field_type', $field_type, $field, $new_value ); |
| 1107 | 1107 | $field_array['parent_form_id'] = $args['parent_form_id']; |
| 1108 | 1108 | |
| 1109 | - $args['field_type'] = $field_type; |
|
| 1109 | + $args['field_type'] = $field_type; |
|
| 1110 | 1110 | |
| 1111 | 1111 | FrmFieldsHelper::prepare_edit_front_field( $field_array, $field, $values['id'], $args ); |
| 1112 | 1112 | |
| 1113 | 1113 | if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) { |
| 1114 | - $field_array['unique_msg'] = ''; |
|
| 1115 | - } |
|
| 1114 | + $field_array['unique_msg'] = ''; |
|
| 1115 | + } |
|
| 1116 | 1116 | |
| 1117 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1117 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1118 | 1118 | |
| 1119 | - $values['fields'][ $field->id ] = $field_array; |
|
| 1120 | - } |
|
| 1119 | + $values['fields'][ $field->id ] = $field_array; |
|
| 1120 | + } |
|
| 1121 | 1121 | |
| 1122 | 1122 | /** |
| 1123 | 1123 | * @since 3.0 |
@@ -1138,20 +1138,20 @@ discard block |
||
| 1138 | 1138 | ); |
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | - /** |
|
| 1142 | - * @param string $table |
|
| 1143 | - */ |
|
| 1141 | + /** |
|
| 1142 | + * @param string $table |
|
| 1143 | + */ |
|
| 1144 | 1144 | private static function fill_form_opts( $record, $table, $post_values, array &$values ) { |
| 1145 | - if ( $table == 'entries' ) { |
|
| 1146 | - $form = $record->form_id; |
|
| 1145 | + if ( $table == 'entries' ) { |
|
| 1146 | + $form = $record->form_id; |
|
| 1147 | 1147 | FrmForm::maybe_get_form( $form ); |
| 1148 | - } else { |
|
| 1149 | - $form = $record; |
|
| 1150 | - } |
|
| 1148 | + } else { |
|
| 1149 | + $form = $record; |
|
| 1150 | + } |
|
| 1151 | 1151 | |
| 1152 | - if ( ! $form ) { |
|
| 1153 | - return; |
|
| 1154 | - } |
|
| 1152 | + if ( ! $form ) { |
|
| 1153 | + return; |
|
| 1154 | + } |
|
| 1155 | 1155 | |
| 1156 | 1156 | $values['form_name'] = isset( $record->form_id ) ? $form->name : ''; |
| 1157 | 1157 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
@@ -1160,26 +1160,26 @@ discard block |
||
| 1160 | 1160 | return; |
| 1161 | 1161 | } |
| 1162 | 1162 | |
| 1163 | - foreach ( $form->options as $opt => $value ) { |
|
| 1164 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1165 | - } |
|
| 1163 | + foreach ( $form->options as $opt => $value ) { |
|
| 1164 | + $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1165 | + } |
|
| 1166 | 1166 | |
| 1167 | 1167 | self::fill_form_defaults( $post_values, $values ); |
| 1168 | - } |
|
| 1168 | + } |
|
| 1169 | 1169 | |
| 1170 | - /** |
|
| 1171 | - * Set to POST value or default |
|
| 1172 | - */ |
|
| 1170 | + /** |
|
| 1171 | + * Set to POST value or default |
|
| 1172 | + */ |
|
| 1173 | 1173 | private static function fill_form_defaults( $post_values, array &$values ) { |
| 1174 | - $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1174 | + $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1175 | 1175 | |
| 1176 | - foreach ( $form_defaults as $opt => $default ) { |
|
| 1177 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1176 | + foreach ( $form_defaults as $opt => $default ) { |
|
| 1177 | + if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1178 | 1178 | $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
| 1179 | - } |
|
| 1179 | + } |
|
| 1180 | 1180 | |
| 1181 | 1181 | unset( $opt, $default ); |
| 1182 | - } |
|
| 1182 | + } |
|
| 1183 | 1183 | |
| 1184 | 1184 | if ( ! isset( $values['custom_style'] ) ) { |
| 1185 | 1185 | $values['custom_style'] = self::custom_style_value( $post_values ); |
@@ -1188,10 +1188,10 @@ discard block |
||
| 1188 | 1188 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
| 1189 | 1189 | if ( ! isset( $values[ $h . '_html' ] ) ) { |
| 1190 | 1190 | $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
| 1191 | - } |
|
| 1191 | + } |
|
| 1192 | 1192 | unset( $h ); |
| 1193 | - } |
|
| 1194 | - } |
|
| 1193 | + } |
|
| 1194 | + } |
|
| 1195 | 1195 | |
| 1196 | 1196 | /** |
| 1197 | 1197 | * @since 2.2.10 |
@@ -1214,33 +1214,33 @@ discard block |
||
| 1214 | 1214 | if ( $possible_email_field ) { |
| 1215 | 1215 | $class .= 'show_frm_not_email_to'; |
| 1216 | 1216 | } |
| 1217 | - ?> |
|
| 1217 | + ?> |
|
| 1218 | 1218 | <li> |
| 1219 | 1219 | <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr( $class ); ?>" data-code="<?php echo esc_attr( $args['id'] ); ?>" >[<?php echo esc_attr( $args['id'] ); ?>]</a> |
| 1220 | 1220 | <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr( $class ); ?>" data-code="<?php echo esc_attr( $args['key'] ); ?>" >[<?php echo esc_attr( self::truncate( $args['key'], 10 ) ); ?>]</a> |
| 1221 | 1221 | <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ); ?>" data-code="<?php echo esc_attr( $args['id'] ); ?>" ><?php echo esc_attr( self::truncate( $args['name'], 60 ) ); ?></a> |
| 1222 | 1222 | </li> |
| 1223 | 1223 | <?php |
| 1224 | - } |
|
| 1224 | + } |
|
| 1225 | 1225 | |
| 1226 | 1226 | public static function truncate( $str, $length, $minword = 3, $continue = '...' ) { |
| 1227 | - if ( is_array( $str ) ) { |
|
| 1228 | - return ''; |
|
| 1227 | + if ( is_array( $str ) ) { |
|
| 1228 | + return ''; |
|
| 1229 | 1229 | } |
| 1230 | 1230 | |
| 1231 | - $length = (int) $length; |
|
| 1231 | + $length = (int) $length; |
|
| 1232 | 1232 | $str = wp_strip_all_tags( $str ); |
| 1233 | 1233 | $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) ); |
| 1234 | 1234 | |
| 1235 | 1235 | if ( $length == 0 ) { |
| 1236 | - return ''; |
|
| 1237 | - } else if ( $length <= 10 ) { |
|
| 1236 | + return ''; |
|
| 1237 | + } else if ( $length <= 10 ) { |
|
| 1238 | 1238 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
| 1239 | 1239 | return $sub . ( ( $length < $original_len ) ? $continue : '' ); |
| 1240 | - } |
|
| 1240 | + } |
|
| 1241 | 1241 | |
| 1242 | - $sub = ''; |
|
| 1243 | - $len = 0; |
|
| 1242 | + $sub = ''; |
|
| 1243 | + $len = 0; |
|
| 1244 | 1244 | |
| 1245 | 1245 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
| 1246 | 1246 | |
@@ -1248,21 +1248,21 @@ discard block |
||
| 1248 | 1248 | $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; |
| 1249 | 1249 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
| 1250 | 1250 | if ( $total_len > $length && str_word_count( $sub ) ) { |
| 1251 | - break; |
|
| 1252 | - } |
|
| 1251 | + break; |
|
| 1252 | + } |
|
| 1253 | 1253 | |
| 1254 | - $sub .= $part; |
|
| 1254 | + $sub .= $part; |
|
| 1255 | 1255 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
| 1256 | 1256 | |
| 1257 | 1257 | if ( str_word_count( $sub ) > $minword && $total_len >= $length ) { |
| 1258 | - break; |
|
| 1259 | - } |
|
| 1258 | + break; |
|
| 1259 | + } |
|
| 1260 | 1260 | |
| 1261 | 1261 | unset( $total_len, $word ); |
| 1262 | - } |
|
| 1262 | + } |
|
| 1263 | 1263 | |
| 1264 | 1264 | return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
| 1265 | - } |
|
| 1265 | + } |
|
| 1266 | 1266 | |
| 1267 | 1267 | public static function mb_function( $function_names, $args ) { |
| 1268 | 1268 | $mb_function_name = $function_names[0]; |
@@ -1275,17 +1275,17 @@ discard block |
||
| 1275 | 1275 | |
| 1276 | 1276 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
| 1277 | 1277 | if ( empty( $date ) ) { |
| 1278 | - return $date; |
|
| 1279 | - } |
|
| 1278 | + return $date; |
|
| 1279 | + } |
|
| 1280 | 1280 | |
| 1281 | 1281 | if ( empty( $date_format ) ) { |
| 1282 | 1282 | $date_format = get_option( 'date_format' ); |
| 1283 | 1283 | } |
| 1284 | 1284 | |
| 1285 | 1285 | if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) { |
| 1286 | - $frmpro_settings = new FrmProSettings(); |
|
| 1286 | + $frmpro_settings = new FrmProSettings(); |
|
| 1287 | 1287 | $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' ); |
| 1288 | - } |
|
| 1288 | + } |
|
| 1289 | 1289 | |
| 1290 | 1290 | $formatted = self::get_localized_date( $date_format, $date ); |
| 1291 | 1291 | |
@@ -1294,8 +1294,8 @@ discard block |
||
| 1294 | 1294 | $formatted .= self::add_time_to_date( $time_format, $date ); |
| 1295 | 1295 | } |
| 1296 | 1296 | |
| 1297 | - return $formatted; |
|
| 1298 | - } |
|
| 1297 | + return $formatted; |
|
| 1298 | + } |
|
| 1299 | 1299 | |
| 1300 | 1300 | private static function add_time_to_date( $time_format, $date ) { |
| 1301 | 1301 | if ( empty( $time_format ) ) { |
@@ -1377,32 +1377,32 @@ discard block |
||
| 1377 | 1377 | ); |
| 1378 | 1378 | } |
| 1379 | 1379 | |
| 1380 | - // Pagination Methods |
|
| 1380 | + // Pagination Methods |
|
| 1381 | 1381 | |
| 1382 | - /** |
|
| 1383 | - * @param integer $current_p |
|
| 1384 | - */ |
|
| 1382 | + /** |
|
| 1383 | + * @param integer $current_p |
|
| 1384 | + */ |
|
| 1385 | 1385 | public static function get_last_record_num( $r_count, $current_p, $p_size ) { |
| 1386 | 1386 | return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); |
| 1387 | 1387 | } |
| 1388 | 1388 | |
| 1389 | - /** |
|
| 1390 | - * @param integer $current_p |
|
| 1391 | - */ |
|
| 1392 | - public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1393 | - if ( $current_p == 1 ) { |
|
| 1394 | - return 1; |
|
| 1395 | - } else { |
|
| 1396 | - return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1397 | - } |
|
| 1398 | - } |
|
| 1389 | + /** |
|
| 1390 | + * @param integer $current_p |
|
| 1391 | + */ |
|
| 1392 | + public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1393 | + if ( $current_p == 1 ) { |
|
| 1394 | + return 1; |
|
| 1395 | + } else { |
|
| 1396 | + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1397 | + } |
|
| 1398 | + } |
|
| 1399 | 1399 | |
| 1400 | 1400 | /** |
| 1401 | 1401 | * @return array |
| 1402 | 1402 | */ |
| 1403 | 1403 | public static function json_to_array( $json_vars ) { |
| 1404 | - $vars = array(); |
|
| 1405 | - foreach ( $json_vars as $jv ) { |
|
| 1404 | + $vars = array(); |
|
| 1405 | + foreach ( $json_vars as $jv ) { |
|
| 1406 | 1406 | $jv_name = explode( '[', $jv['name'] ); |
| 1407 | 1407 | $last = count( $jv_name ) - 1; |
| 1408 | 1408 | foreach ( $jv_name as $p => $n ) { |
@@ -1419,77 +1419,77 @@ discard block |
||
| 1419 | 1419 | $l3 = $name; |
| 1420 | 1420 | } |
| 1421 | 1421 | |
| 1422 | - $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1422 | + $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1423 | 1423 | |
| 1424 | - switch ( $p ) { |
|
| 1425 | - case 0: |
|
| 1426 | - $l1 = $name; |
|
| 1427 | - self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1424 | + switch ( $p ) { |
|
| 1425 | + case 0: |
|
| 1426 | + $l1 = $name; |
|
| 1427 | + self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1428 | 1428 | break; |
| 1429 | 1429 | |
| 1430 | - case 1: |
|
| 1431 | - $l2 = $name; |
|
| 1432 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1430 | + case 1: |
|
| 1431 | + $l2 = $name; |
|
| 1432 | + self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1433 | 1433 | break; |
| 1434 | 1434 | |
| 1435 | - case 2: |
|
| 1436 | - $l3 = $name; |
|
| 1437 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1435 | + case 2: |
|
| 1436 | + $l3 = $name; |
|
| 1437 | + self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1438 | 1438 | break; |
| 1439 | 1439 | |
| 1440 | - case 3: |
|
| 1441 | - $l4 = $name; |
|
| 1442 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1443 | - } |
|
| 1440 | + case 3: |
|
| 1441 | + $l4 = $name; |
|
| 1442 | + self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1443 | + } |
|
| 1444 | 1444 | |
| 1445 | 1445 | unset( $this_val, $n ); |
| 1446 | - } |
|
| 1446 | + } |
|
| 1447 | 1447 | |
| 1448 | 1448 | unset( $last, $jv ); |
| 1449 | - } |
|
| 1450 | - |
|
| 1451 | - return $vars; |
|
| 1452 | - } |
|
| 1453 | - |
|
| 1454 | - /** |
|
| 1455 | - * @param string $name |
|
| 1456 | - * @param string $l1 |
|
| 1457 | - */ |
|
| 1458 | - public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1459 | - if ( $name == '' ) { |
|
| 1460 | - $vars[] = $val; |
|
| 1461 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1462 | - $vars[ $l1 ] = $val; |
|
| 1463 | - } |
|
| 1464 | - } |
|
| 1449 | + } |
|
| 1450 | + |
|
| 1451 | + return $vars; |
|
| 1452 | + } |
|
| 1453 | + |
|
| 1454 | + /** |
|
| 1455 | + * @param string $name |
|
| 1456 | + * @param string $l1 |
|
| 1457 | + */ |
|
| 1458 | + public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1459 | + if ( $name == '' ) { |
|
| 1460 | + $vars[] = $val; |
|
| 1461 | + } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1462 | + $vars[ $l1 ] = $val; |
|
| 1463 | + } |
|
| 1464 | + } |
|
| 1465 | 1465 | |
| 1466 | 1466 | public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) { |
| 1467 | - $tooltips = array( |
|
| 1468 | - 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1469 | - 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ), |
|
| 1470 | - 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1471 | - 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1472 | - 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1473 | - 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1474 | - 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
|
| 1475 | - ); |
|
| 1476 | - |
|
| 1477 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1478 | - return; |
|
| 1479 | - } |
|
| 1480 | - |
|
| 1481 | - if ( 'open' == $class ) { |
|
| 1482 | - echo ' frm_help"'; |
|
| 1483 | - } else { |
|
| 1484 | - echo ' class="frm_help"'; |
|
| 1485 | - } |
|
| 1467 | + $tooltips = array( |
|
| 1468 | + 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1469 | + 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ), |
|
| 1470 | + 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1471 | + 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1472 | + 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1473 | + 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1474 | + 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
|
| 1475 | + ); |
|
| 1476 | + |
|
| 1477 | + if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1478 | + return; |
|
| 1479 | + } |
|
| 1480 | + |
|
| 1481 | + if ( 'open' == $class ) { |
|
| 1482 | + echo ' frm_help"'; |
|
| 1483 | + } else { |
|
| 1484 | + echo ' class="frm_help"'; |
|
| 1485 | + } |
|
| 1486 | 1486 | |
| 1487 | 1487 | echo ' title="' . esc_attr( $tooltips[ $name ] ); |
| 1488 | 1488 | |
| 1489 | - if ( 'open' != $class ) { |
|
| 1490 | - echo '"'; |
|
| 1491 | - } |
|
| 1492 | - } |
|
| 1489 | + if ( 'open' != $class ) { |
|
| 1490 | + echo '"'; |
|
| 1491 | + } |
|
| 1492 | + } |
|
| 1493 | 1493 | |
| 1494 | 1494 | /** |
| 1495 | 1495 | * Add the current_page class to that page in the form nav |
@@ -1505,35 +1505,35 @@ discard block |
||
| 1505 | 1505 | } |
| 1506 | 1506 | } |
| 1507 | 1507 | |
| 1508 | - /** |
|
| 1509 | - * Prepare and json_encode post content |
|
| 1510 | - * |
|
| 1511 | - * @since 2.0 |
|
| 1512 | - * |
|
| 1513 | - * @param array $post_content |
|
| 1514 | - * @return string $post_content ( json encoded array ) |
|
| 1515 | - */ |
|
| 1516 | - public static function prepare_and_encode( $post_content ) { |
|
| 1517 | - //Loop through array to strip slashes and add only the needed ones |
|
| 1508 | + /** |
|
| 1509 | + * Prepare and json_encode post content |
|
| 1510 | + * |
|
| 1511 | + * @since 2.0 |
|
| 1512 | + * |
|
| 1513 | + * @param array $post_content |
|
| 1514 | + * @return string $post_content ( json encoded array ) |
|
| 1515 | + */ |
|
| 1516 | + public static function prepare_and_encode( $post_content ) { |
|
| 1517 | + //Loop through array to strip slashes and add only the needed ones |
|
| 1518 | 1518 | foreach ( $post_content as $key => $val ) { |
| 1519 | 1519 | // Replace problematic characters (like ") |
| 1520 | 1520 | $val = str_replace( '"', '"', $val ); |
| 1521 | 1521 | |
| 1522 | 1522 | self::prepare_action_slashes( $val, $key, $post_content ); |
| 1523 | - unset( $key, $val ); |
|
| 1524 | - } |
|
| 1523 | + unset( $key, $val ); |
|
| 1524 | + } |
|
| 1525 | 1525 | |
| 1526 | - // json_encode the array |
|
| 1527 | - $post_content = json_encode( $post_content ); |
|
| 1526 | + // json_encode the array |
|
| 1527 | + $post_content = json_encode( $post_content ); |
|
| 1528 | 1528 | |
| 1529 | - // add extra slashes for \r\n since WP strips them |
|
| 1529 | + // add extra slashes for \r\n since WP strips them |
|
| 1530 | 1530 | $post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content ); |
| 1531 | 1531 | |
| 1532 | - // allow for " |
|
| 1533 | - $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1532 | + // allow for " |
|
| 1533 | + $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1534 | 1534 | |
| 1535 | - return $post_content; |
|
| 1536 | - } |
|
| 1535 | + return $post_content; |
|
| 1536 | + } |
|
| 1537 | 1537 | |
| 1538 | 1538 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
| 1539 | 1539 | if ( ! isset( $post_content[ $key ] ) ) { |
@@ -1556,54 +1556,54 @@ discard block |
||
| 1556 | 1556 | |
| 1557 | 1557 | public static function maybe_json_decode( $string ) { |
| 1558 | 1558 | if ( is_array( $string ) ) { |
| 1559 | - return $string; |
|
| 1560 | - } |
|
| 1559 | + return $string; |
|
| 1560 | + } |
|
| 1561 | 1561 | |
| 1562 | 1562 | $new_string = json_decode( $string, true ); |
| 1563 | 1563 | if ( function_exists( 'json_last_error' ) ) { |
| 1564 | 1564 | // php 5.3+ |
| 1565 | - if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1566 | - $string = $new_string; |
|
| 1567 | - } |
|
| 1565 | + if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1566 | + $string = $new_string; |
|
| 1567 | + } |
|
| 1568 | 1568 | } elseif ( isset( $new_string ) ) { |
| 1569 | 1569 | // php < 5.3 fallback |
| 1570 | - $string = $new_string; |
|
| 1571 | - } |
|
| 1572 | - return $string; |
|
| 1573 | - } |
|
| 1574 | - |
|
| 1575 | - /** |
|
| 1576 | - * @since 1.07.10 |
|
| 1577 | - * |
|
| 1578 | - * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1579 | - * echo The javascript to open and highlight the Formidable menu |
|
| 1580 | - */ |
|
| 1570 | + $string = $new_string; |
|
| 1571 | + } |
|
| 1572 | + return $string; |
|
| 1573 | + } |
|
| 1574 | + |
|
| 1575 | + /** |
|
| 1576 | + * @since 1.07.10 |
|
| 1577 | + * |
|
| 1578 | + * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1579 | + * echo The javascript to open and highlight the Formidable menu |
|
| 1580 | + */ |
|
| 1581 | 1581 | public static function maybe_highlight_menu( $post_type ) { |
| 1582 | - global $post; |
|
| 1582 | + global $post; |
|
| 1583 | 1583 | |
| 1584 | 1584 | if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) { |
| 1585 | - return; |
|
| 1586 | - } |
|
| 1585 | + return; |
|
| 1586 | + } |
|
| 1587 | 1587 | |
| 1588 | 1588 | if ( is_object( $post ) && $post->post_type != $post_type ) { |
| 1589 | - return; |
|
| 1590 | - } |
|
| 1589 | + return; |
|
| 1590 | + } |
|
| 1591 | 1591 | |
| 1592 | - self::load_admin_wide_js(); |
|
| 1593 | - echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1594 | - } |
|
| 1592 | + self::load_admin_wide_js(); |
|
| 1593 | + echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1594 | + } |
|
| 1595 | 1595 | |
| 1596 | - /** |
|
| 1597 | - * Load the JS file on non-Formidable pages in the admin area |
|
| 1598 | - * @since 2.0 |
|
| 1599 | - */ |
|
| 1596 | + /** |
|
| 1597 | + * Load the JS file on non-Formidable pages in the admin area |
|
| 1598 | + * @since 2.0 |
|
| 1599 | + */ |
|
| 1600 | 1600 | public static function load_admin_wide_js( $load = true ) { |
| 1601 | - $version = FrmAppHelper::plugin_version(); |
|
| 1601 | + $version = FrmAppHelper::plugin_version(); |
|
| 1602 | 1602 | wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version ); |
| 1603 | 1603 | |
| 1604 | 1604 | $global_strings = array( |
| 1605 | 1605 | 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ), |
| 1606 | - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1606 | + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1607 | 1607 | 'url' => FrmAppHelper::plugin_url(), |
| 1608 | 1608 | 'loading' => __( 'Loading…' ), |
| 1609 | 1609 | 'nonce' => wp_create_nonce( 'frm_ajax' ), |
@@ -1613,7 +1613,7 @@ discard block |
||
| 1613 | 1613 | if ( $load ) { |
| 1614 | 1614 | wp_enqueue_script( 'formidable_admin_global' ); |
| 1615 | 1615 | } |
| 1616 | - } |
|
| 1616 | + } |
|
| 1617 | 1617 | |
| 1618 | 1618 | /** |
| 1619 | 1619 | * @since 2.0.9 |
@@ -1622,9 +1622,9 @@ discard block |
||
| 1622 | 1622 | wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() ); |
| 1623 | 1623 | } |
| 1624 | 1624 | |
| 1625 | - /** |
|
| 1626 | - * @param string $location |
|
| 1627 | - */ |
|
| 1625 | + /** |
|
| 1626 | + * @param string $location |
|
| 1627 | + */ |
|
| 1628 | 1628 | public static function localize_script( $location ) { |
| 1629 | 1629 | $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); |
| 1630 | 1630 | $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url ); |
@@ -1687,27 +1687,27 @@ discard block |
||
| 1687 | 1687 | } |
| 1688 | 1688 | } |
| 1689 | 1689 | |
| 1690 | - /** |
|
| 1690 | + /** |
|
| 1691 | 1691 | * echo the message on the plugins listing page |
| 1692 | - * @since 1.07.10 |
|
| 1693 | - * |
|
| 1694 | - * @param float $min_version The version the add-on requires |
|
| 1695 | - */ |
|
| 1692 | + * @since 1.07.10 |
|
| 1693 | + * |
|
| 1694 | + * @param float $min_version The version the add-on requires |
|
| 1695 | + */ |
|
| 1696 | 1696 | public static function min_version_notice( $min_version ) { |
| 1697 | - $frm_version = self::plugin_version(); |
|
| 1697 | + $frm_version = self::plugin_version(); |
|
| 1698 | 1698 | |
| 1699 | - // check if Formidable meets minimum requirements |
|
| 1699 | + // check if Formidable meets minimum requirements |
|
| 1700 | 1700 | if ( version_compare( $frm_version, $min_version, '>=' ) ) { |
| 1701 | - return; |
|
| 1702 | - } |
|
| 1701 | + return; |
|
| 1702 | + } |
|
| 1703 | 1703 | |
| 1704 | 1704 | $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
| 1705 | 1705 | echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' . |
| 1706 | - esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1707 | - '</div></td></tr>'; |
|
| 1708 | - } |
|
| 1706 | + esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1707 | + '</div></td></tr>'; |
|
| 1708 | + } |
|
| 1709 | 1709 | |
| 1710 | - public static function locales( $type = 'date' ) { |
|
| 1710 | + public static function locales( $type = 'date' ) { |
|
| 1711 | 1711 | $locales = array( |
| 1712 | 1712 | 'en' => __( 'English', 'formidable' ), |
| 1713 | 1713 | '' => __( 'English/Western', 'formidable' ), |
@@ -1786,8 +1786,8 @@ discard block |
||
| 1786 | 1786 | $locales = array_diff_key( $locales, array_flip( $unset ) ); |
| 1787 | 1787 | $locales = apply_filters( 'frm_locales', $locales ); |
| 1788 | 1788 | |
| 1789 | - return $locales; |
|
| 1790 | - } |
|
| 1789 | + return $locales; |
|
| 1790 | + } |
|
| 1791 | 1791 | |
| 1792 | 1792 | /** |
| 1793 | 1793 | * Prepare and save settings in styles and actions |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | * @return string |
| 226 | 226 | */ |
| 227 | 227 | public static function get_server_value( $value ) { |
| 228 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 228 | + return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : ''; |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
@@ -237,11 +237,11 @@ discard block |
||
| 237 | 237 | public static function get_ip_address() { |
| 238 | 238 | $ip = ''; |
| 239 | 239 | foreach ( array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR' ) as $key ) { |
| 240 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 240 | + if ( ! isset( $_SERVER[$key] ) ) { |
|
| 241 | 241 | continue; |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 244 | + foreach ( explode( ',', $_SERVER[$key] ) as $ip ) { |
|
| 245 | 245 | $ip = trim( $ip ); // just to be safe |
| 246 | 246 | |
| 247 | 247 | if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) { |
@@ -260,9 +260,9 @@ discard block |
||
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | if ( $src == 'get' ) { |
| 263 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 264 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 265 | - $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 263 | + $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default ); |
|
| 264 | + if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) { |
|
| 265 | + $value = stripslashes_deep( htmlspecialchars_decode( $_GET[$param] ) ); |
|
| 266 | 266 | } |
| 267 | 267 | self::sanitize_value( $sanitize, $value ); |
| 268 | 268 | } else { |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | $p = trim( $p, ']' ); |
| 286 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
| 286 | + $value = isset( $value[$p] ) ? $value[$p] : $default; |
|
| 287 | 287 | } |
| 288 | 288 | } |
| 289 | 289 | |
@@ -338,16 +338,16 @@ discard block |
||
| 338 | 338 | |
| 339 | 339 | $value = $args['default']; |
| 340 | 340 | if ( $args['type'] == 'get' ) { |
| 341 | - if ( $_GET && isset( $_GET[ $args['param'] ] ) ) { |
|
| 342 | - $value = $_GET[ $args['param'] ]; |
|
| 341 | + if ( $_GET && isset( $_GET[$args['param']] ) ) { |
|
| 342 | + $value = $_GET[$args['param']]; |
|
| 343 | 343 | } |
| 344 | 344 | } else if ( $args['type'] == 'post' ) { |
| 345 | - if ( isset( $_POST[ $args['param'] ] ) ) { |
|
| 346 | - $value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) ); |
|
| 345 | + if ( isset( $_POST[$args['param']] ) ) { |
|
| 346 | + $value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) ); |
|
| 347 | 347 | } |
| 348 | 348 | } else { |
| 349 | - if ( isset( $_REQUEST[ $args['param'] ] ) ) { |
|
| 350 | - $value = $_REQUEST[ $args['param'] ]; |
|
| 349 | + if ( isset( $_REQUEST[$args['param']] ) ) { |
|
| 350 | + $value = $_REQUEST[$args['param']]; |
|
| 351 | 351 | } |
| 352 | 352 | } |
| 353 | 353 | |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | if ( is_array( $value ) ) { |
| 376 | 376 | $temp_values = $value; |
| 377 | 377 | foreach ( $temp_values as $k => $v ) { |
| 378 | - FrmAppHelper::sanitize_value( $sanitize, $value[ $k ] ); |
|
| 378 | + FrmAppHelper::sanitize_value( $sanitize, $value[$k] ); |
|
| 379 | 379 | } |
| 380 | 380 | } else { |
| 381 | 381 | $value = call_user_func( $sanitize, $value ); |
@@ -386,8 +386,8 @@ discard block |
||
| 386 | 386 | public static function sanitize_request( $sanitize_method, &$values ) { |
| 387 | 387 | $temp_values = $values; |
| 388 | 388 | foreach ( $temp_values as $k => $val ) { |
| 389 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 390 | - $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
|
| 389 | + if ( isset( $sanitize_method[$k] ) ) { |
|
| 390 | + $values[$k] = call_user_func( $sanitize_method[$k], $val ); |
|
| 391 | 391 | } |
| 392 | 392 | } |
| 393 | 393 | } |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | $allowed_html = $html; |
| 425 | 425 | } elseif ( ! empty( $allowed ) ) { |
| 426 | 426 | foreach ( (array) $allowed as $a ) { |
| 427 | - $allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array(); |
|
| 427 | + $allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array(); |
|
| 428 | 428 | } |
| 429 | 429 | } |
| 430 | 430 | |
@@ -543,8 +543,8 @@ discard block |
||
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | global $wp_query; |
| 546 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 547 | - $value = $wp_query->query_vars[ $param ]; |
|
| 546 | + if ( isset( $wp_query->query_vars[$param] ) ) { |
|
| 547 | + $value = $wp_query->query_vars[$param]; |
|
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | return $value; |
@@ -632,7 +632,7 @@ discard block |
||
| 632 | 632 | $query = array( |
| 633 | 633 | 'post_type' => 'page', |
| 634 | 634 | 'post_status' => array( 'publish', 'private' ), |
| 635 | - 'numberposts' => -1, |
|
| 635 | + 'numberposts' => - 1, |
|
| 636 | 636 | 'orderby' => 'title', |
| 637 | 637 | 'order' => 'ASC', |
| 638 | 638 | ); |
@@ -801,7 +801,7 @@ discard block |
||
| 801 | 801 | return $error; |
| 802 | 802 | } |
| 803 | 803 | |
| 804 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 804 | + if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) { |
|
| 805 | 805 | $frm_settings = self::get_settings(); |
| 806 | 806 | $error = $frm_settings->admin_permission; |
| 807 | 807 | } |
@@ -836,7 +836,7 @@ discard block |
||
| 836 | 836 | } else { |
| 837 | 837 | foreach ( $value as $k => $v ) { |
| 838 | 838 | if ( ! is_array( $v ) ) { |
| 839 | - $value[ $k ] = call_user_func( $original_function, $v ); |
|
| 839 | + $value[$k] = call_user_func( $original_function, $v ); |
|
| 840 | 840 | } |
| 841 | 841 | } |
| 842 | 842 | } |
@@ -861,7 +861,7 @@ discard block |
||
| 861 | 861 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
| 862 | 862 | } else { |
| 863 | 863 | if ( $keys == 'keep' ) { |
| 864 | - $return[ $key ] = $value; |
|
| 864 | + $return[$key] = $value; |
|
| 865 | 865 | } else { |
| 866 | 866 | $return[] = $value; |
| 867 | 867 | } |
@@ -918,11 +918,11 @@ discard block |
||
| 918 | 918 | } |
| 919 | 919 | |
| 920 | 920 | $ver = $default; |
| 921 | - if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
|
| 921 | + if ( ! isset( $wp_scripts->registered[$handle] ) ) { |
|
| 922 | 922 | return $ver; |
| 923 | 923 | } |
| 924 | 924 | |
| 925 | - $query = $wp_scripts->registered[ $handle ]; |
|
| 925 | + $query = $wp_scripts->registered[$handle]; |
|
| 926 | 926 | if ( is_object( $query ) && ! empty( $query->ver ) ) { |
| 927 | 927 | $ver = $query->ver; |
| 928 | 928 | } |
@@ -1015,7 +1015,7 @@ discard block |
||
| 1015 | 1015 | ), |
| 1016 | 1016 | $column |
| 1017 | 1017 | ); |
| 1018 | - $suffix++; |
|
| 1018 | + $suffix ++; |
|
| 1019 | 1019 | } while ( $key_check || is_numeric( $key_check ) ); |
| 1020 | 1020 | $key = $alt_post_name; |
| 1021 | 1021 | } |
@@ -1043,7 +1043,7 @@ discard block |
||
| 1043 | 1043 | |
| 1044 | 1044 | foreach ( array( 'name', 'description' ) as $var ) { |
| 1045 | 1045 | $default_val = isset( $record->{$var} ) ? $record->{$var} : ''; |
| 1046 | - $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
|
| 1046 | + $values[$var] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
|
| 1047 | 1047 | unset( $var, $default_val ); |
| 1048 | 1048 | } |
| 1049 | 1049 | |
@@ -1098,8 +1098,8 @@ discard block |
||
| 1098 | 1098 | } |
| 1099 | 1099 | } |
| 1100 | 1100 | |
| 1101 | - $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
|
| 1102 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1101 | + $field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type; |
|
| 1102 | + $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value; |
|
| 1103 | 1103 | |
| 1104 | 1104 | $field_array = self::start_field_array( $field ); |
| 1105 | 1105 | $field_array['value'] = $new_value; |
@@ -1116,7 +1116,7 @@ discard block |
||
| 1116 | 1116 | |
| 1117 | 1117 | $field_array = array_merge( $field->field_options, $field_array ); |
| 1118 | 1118 | |
| 1119 | - $values['fields'][ $field->id ] = $field_array; |
|
| 1119 | + $values['fields'][$field->id] = $field_array; |
|
| 1120 | 1120 | } |
| 1121 | 1121 | |
| 1122 | 1122 | /** |
@@ -1161,7 +1161,7 @@ discard block |
||
| 1161 | 1161 | } |
| 1162 | 1162 | |
| 1163 | 1163 | foreach ( $form->options as $opt => $value ) { |
| 1164 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1164 | + $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value; |
|
| 1165 | 1165 | } |
| 1166 | 1166 | |
| 1167 | 1167 | self::fill_form_defaults( $post_values, $values ); |
@@ -1174,8 +1174,8 @@ discard block |
||
| 1174 | 1174 | $form_defaults = FrmFormsHelper::get_default_opts(); |
| 1175 | 1175 | |
| 1176 | 1176 | foreach ( $form_defaults as $opt => $default ) { |
| 1177 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1178 | - $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
|
| 1177 | + if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) { |
|
| 1178 | + $values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default; |
|
| 1179 | 1179 | } |
| 1180 | 1180 | |
| 1181 | 1181 | unset( $opt, $default ); |
@@ -1186,8 +1186,8 @@ discard block |
||
| 1186 | 1186 | } |
| 1187 | 1187 | |
| 1188 | 1188 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
| 1189 | - if ( ! isset( $values[ $h . '_html' ] ) ) { |
|
| 1190 | - $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
|
| 1189 | + if ( ! isset( $values[$h . '_html'] ) ) { |
|
| 1190 | + $values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) ); |
|
| 1191 | 1191 | } |
| 1192 | 1192 | unset( $h ); |
| 1193 | 1193 | } |
@@ -1345,10 +1345,10 @@ discard block |
||
| 1345 | 1345 | $time_strings = self::get_time_strings(); |
| 1346 | 1346 | |
| 1347 | 1347 | foreach ( $time_strings as $k => $v ) { |
| 1348 | - if ( $diff[ $k ] ) { |
|
| 1349 | - $time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] ); |
|
| 1348 | + if ( $diff[$k] ) { |
|
| 1349 | + $time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] ); |
|
| 1350 | 1350 | } else { |
| 1351 | - unset( $time_strings[ $k ] ); |
|
| 1351 | + unset( $time_strings[$k] ); |
|
| 1352 | 1352 | } |
| 1353 | 1353 | } |
| 1354 | 1354 | |
@@ -1429,17 +1429,17 @@ discard block |
||
| 1429 | 1429 | |
| 1430 | 1430 | case 1: |
| 1431 | 1431 | $l2 = $name; |
| 1432 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1432 | + self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] ); |
|
| 1433 | 1433 | break; |
| 1434 | 1434 | |
| 1435 | 1435 | case 2: |
| 1436 | 1436 | $l3 = $name; |
| 1437 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1437 | + self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] ); |
|
| 1438 | 1438 | break; |
| 1439 | 1439 | |
| 1440 | 1440 | case 3: |
| 1441 | 1441 | $l4 = $name; |
| 1442 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1442 | + self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] ); |
|
| 1443 | 1443 | } |
| 1444 | 1444 | |
| 1445 | 1445 | unset( $this_val, $n ); |
@@ -1458,8 +1458,8 @@ discard block |
||
| 1458 | 1458 | public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
| 1459 | 1459 | if ( $name == '' ) { |
| 1460 | 1460 | $vars[] = $val; |
| 1461 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1462 | - $vars[ $l1 ] = $val; |
|
| 1461 | + } else if ( ! isset( $vars[$l1] ) ) { |
|
| 1462 | + $vars[$l1] = $val; |
|
| 1463 | 1463 | } |
| 1464 | 1464 | } |
| 1465 | 1465 | |
@@ -1474,7 +1474,7 @@ discard block |
||
| 1474 | 1474 | 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
| 1475 | 1475 | ); |
| 1476 | 1476 | |
| 1477 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1477 | + if ( ! isset( $tooltips[$name] ) ) { |
|
| 1478 | 1478 | return; |
| 1479 | 1479 | } |
| 1480 | 1480 | |
@@ -1484,7 +1484,7 @@ discard block |
||
| 1484 | 1484 | echo ' class="frm_help"'; |
| 1485 | 1485 | } |
| 1486 | 1486 | |
| 1487 | - echo ' title="' . esc_attr( $tooltips[ $name ] ); |
|
| 1487 | + echo ' title="' . esc_attr( $tooltips[$name] ); |
|
| 1488 | 1488 | |
| 1489 | 1489 | if ( 'open' != $class ) { |
| 1490 | 1490 | echo '"'; |
@@ -1536,13 +1536,13 @@ discard block |
||
| 1536 | 1536 | } |
| 1537 | 1537 | |
| 1538 | 1538 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
| 1539 | - if ( ! isset( $post_content[ $key ] ) ) { |
|
| 1539 | + if ( ! isset( $post_content[$key] ) ) { |
|
| 1540 | 1540 | return; |
| 1541 | 1541 | } |
| 1542 | 1542 | |
| 1543 | 1543 | if ( is_array( $val ) ) { |
| 1544 | 1544 | foreach ( $val as $k1 => $v1 ) { |
| 1545 | - self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] ); |
|
| 1545 | + self::prepare_action_slashes( $v1, $k1, $post_content[$key] ); |
|
| 1546 | 1546 | unset( $k1, $v1 ); |
| 1547 | 1547 | } |
| 1548 | 1548 | } else { |
@@ -1550,7 +1550,7 @@ discard block |
||
| 1550 | 1550 | $val = stripslashes( $val ); |
| 1551 | 1551 | |
| 1552 | 1552 | // Add backslashes before double quotes and forward slashes only |
| 1553 | - $post_content[ $key ] = addcslashes( $val, '"\\/' ); |
|
| 1553 | + $post_content[$key] = addcslashes( $val, '"\\/' ); |
|
| 1554 | 1554 | } |
| 1555 | 1555 | } |
| 1556 | 1556 | |
@@ -51,21 +51,21 @@ discard block |
||
| 51 | 51 | ), |
| 52 | 52 | ); |
| 53 | 53 | switch ( $this->status ) { |
| 54 | - case 'template': |
|
| 55 | - $s_query['is_template'] = 1; |
|
| 56 | - $s_query['status !'] = 'trash'; |
|
| 57 | - break; |
|
| 58 | - case 'draft': |
|
| 59 | - $s_query['is_template'] = 0; |
|
| 60 | - $s_query['status'] = 'draft'; |
|
| 61 | - break; |
|
| 62 | - case 'trash': |
|
| 63 | - $s_query['status'] = 'trash'; |
|
| 64 | - break; |
|
| 65 | - default: |
|
| 66 | - $s_query['is_template'] = 0; |
|
| 67 | - $s_query['status !'] = 'trash'; |
|
| 68 | - break; |
|
| 54 | + case 'template': |
|
| 55 | + $s_query['is_template'] = 1; |
|
| 56 | + $s_query['status !'] = 'trash'; |
|
| 57 | + break; |
|
| 58 | + case 'draft': |
|
| 59 | + $s_query['is_template'] = 0; |
|
| 60 | + $s_query['status'] = 'draft'; |
|
| 61 | + break; |
|
| 62 | + case 'trash': |
|
| 63 | + $s_query['status'] = 'trash'; |
|
| 64 | + break; |
|
| 65 | + default: |
|
| 66 | + $s_query['is_template'] = 0; |
|
| 67 | + $s_query['status !'] = 'trash'; |
|
| 68 | + break; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | $s = self::get_param( |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | 'sanitize' => 'sanitize_text_field', |
| 75 | 75 | ) |
| 76 | 76 | ); |
| 77 | - if ( $s != '' ) { |
|
| 77 | + if ( $s != '' ) { |
|
| 78 | 78 | preg_match_all( '/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches ); |
| 79 | 79 | $search_terms = array_map( 'trim', $matches[0] ); |
| 80 | 80 | foreach ( (array) $search_terms as $term ) { |
@@ -86,10 +86,10 @@ discard block |
||
| 86 | 86 | ); |
| 87 | 87 | unset( $term ); |
| 88 | 88 | } |
| 89 | - } |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | 91 | $this->items = FrmForm::getAll( $s_query, $orderby . ' ' . $order, $start . ',' . $per_page ); |
| 92 | - $total_items = FrmDb::get_count( 'frm_forms', $s_query ); |
|
| 92 | + $total_items = FrmDb::get_count( 'frm_forms', $s_query ); |
|
| 93 | 93 | |
| 94 | 94 | $this->set_pagination_args( |
| 95 | 95 | array( |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | public function no_items() { |
| 103 | - if ( 'template' == $this->status ) { |
|
| 103 | + if ( 'template' == $this->status ) { |
|
| 104 | 104 | esc_html_e( 'No Templates Found.', 'formidable' ); |
| 105 | 105 | } else { |
| 106 | 106 | esc_html_e( 'No Forms Found.', 'formidable' ); |
@@ -111,29 +111,29 @@ discard block |
||
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | public function get_bulk_actions() { |
| 114 | - $actions = array(); |
|
| 114 | + $actions = array(); |
|
| 115 | 115 | |
| 116 | - if ( 'trash' == $this->status ) { |
|
| 116 | + if ( 'trash' == $this->status ) { |
|
| 117 | 117 | if ( current_user_can( 'frm_edit_forms' ) ) { |
| 118 | - $actions['bulk_untrash'] = __( 'Restore', 'formidable' ); |
|
| 119 | - } |
|
| 118 | + $actions['bulk_untrash'] = __( 'Restore', 'formidable' ); |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | 121 | if ( current_user_can( 'frm_delete_forms' ) ) { |
| 122 | - $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' ); |
|
| 123 | - } |
|
| 122 | + $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' ); |
|
| 123 | + } |
|
| 124 | 124 | } elseif ( EMPTY_TRASH_DAYS && current_user_can( 'frm_delete_forms' ) ) { |
| 125 | - $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' ); |
|
| 125 | + $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' ); |
|
| 126 | 126 | } elseif ( current_user_can( 'frm_delete_forms' ) ) { |
| 127 | 127 | $actions['bulk_delete'] = __( 'Delete' ); |
| 128 | - } |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - return $actions; |
|
| 131 | - } |
|
| 130 | + return $actions; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | 133 | public function extra_tablenav( $which ) { |
| 134 | - if ( 'top' != $which ) { |
|
| 135 | - return; |
|
| 136 | - } |
|
| 134 | + if ( 'top' != $which ) { |
|
| 135 | + return; |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | 138 | if ( 'trash' == $this->status && current_user_can( 'frm_delete_forms' ) ) { |
| 139 | 139 | ?> |
@@ -141,21 +141,21 @@ discard block |
||
| 141 | 141 | <?php submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); ?> |
| 142 | 142 | </div> |
| 143 | 143 | <?php |
| 144 | - return; |
|
| 145 | - } |
|
| 144 | + return; |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - if ( 'template' != $this->status ) { |
|
| 148 | - return; |
|
| 149 | - } |
|
| 147 | + if ( 'template' != $this->status ) { |
|
| 148 | + return; |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | 151 | $where = apply_filters( 'frm_forms_dropdown', array(), '' ); |
| 152 | 152 | $forms = FrmForm::get_published_forms( $where ); |
| 153 | 153 | |
| 154 | 154 | $base = admin_url( 'admin.php?page=formidable&form_type=template' ); |
| 155 | - $args = array( |
|
| 156 | - 'frm_action' => 'duplicate', |
|
| 157 | - 'template' => true, |
|
| 158 | - ); |
|
| 155 | + $args = array( |
|
| 156 | + 'frm_action' => 'duplicate', |
|
| 157 | + 'template' => true, |
|
| 158 | + ); |
|
| 159 | 159 | |
| 160 | 160 | ?> |
| 161 | 161 | <div class="alignleft actions frm_visible_overflow"> |
@@ -167,16 +167,16 @@ discard block |
||
| 167 | 167 | ?> |
| 168 | 168 | <li class="frm_dropdown_li"><?php esc_html_e( 'You have not created any forms yet. You must create a form before you can make a template.', 'formidable' ) ?></li> |
| 169 | 169 | <?php |
| 170 | - } else { |
|
| 171 | - foreach ( $forms as $form ) { |
|
| 170 | + } else { |
|
| 171 | + foreach ( $forms as $form ) { |
|
| 172 | 172 | $args['id'] = $form->id; |
| 173 | 173 | ?> |
| 174 | 174 | <li><a href="<?php echo esc_url( add_query_arg( $args, $base ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li> |
| 175 | 175 | <?php |
| 176 | 176 | unset( $form ); |
| 177 | 177 | } |
| 178 | - } |
|
| 179 | - ?> |
|
| 178 | + } |
|
| 179 | + ?> |
|
| 180 | 180 | </ul> |
| 181 | 181 | </div> |
| 182 | 182 | </div> |
@@ -186,14 +186,14 @@ discard block |
||
| 186 | 186 | public function get_views() { |
| 187 | 187 | |
| 188 | 188 | $statuses = array( |
| 189 | - 'published' => __( 'My Forms', 'formidable' ), |
|
| 190 | - 'template' => __( 'Templates', 'formidable' ), |
|
| 191 | - 'draft' => __( 'Drafts', 'formidable' ), |
|
| 192 | - 'trash' => __( 'Trash', 'formidable' ), |
|
| 189 | + 'published' => __( 'My Forms', 'formidable' ), |
|
| 190 | + 'template' => __( 'Templates', 'formidable' ), |
|
| 191 | + 'draft' => __( 'Drafts', 'formidable' ), |
|
| 192 | + 'trash' => __( 'Trash', 'formidable' ), |
|
| 193 | 193 | ); |
| 194 | 194 | |
| 195 | - $links = array(); |
|
| 196 | - $counts = FrmForm::get_count(); |
|
| 195 | + $links = array(); |
|
| 196 | + $counts = FrmForm::get_count(); |
|
| 197 | 197 | $form_type = self::get_param( |
| 198 | 198 | array( |
| 199 | 199 | 'param' => 'form_type', |
@@ -201,20 +201,20 @@ discard block |
||
| 201 | 201 | ) |
| 202 | 202 | ); |
| 203 | 203 | |
| 204 | - foreach ( $statuses as $status => $name ) { |
|
| 204 | + foreach ( $statuses as $status => $name ) { |
|
| 205 | 205 | |
| 206 | - if ( $status == $form_type ) { |
|
| 207 | - $class = ' class="current"'; |
|
| 208 | - } else { |
|
| 209 | - $class = ''; |
|
| 210 | - } |
|
| 206 | + if ( $status == $form_type ) { |
|
| 207 | + $class = ' class="current"'; |
|
| 208 | + } else { |
|
| 209 | + $class = ''; |
|
| 210 | + } |
|
| 211 | 211 | |
| 212 | - if ( $counts->{$status} || 'published' == $status || 'template' == $status ) { |
|
| 212 | + if ( $counts->{$status} || 'published' == $status || 'template' == $status ) { |
|
| 213 | 213 | $links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>'; |
| 214 | - } |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | 216 | unset( $status, $name ); |
| 217 | - } |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | 219 | return $links; |
| 220 | 220 | } |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | public function single_row( $item, $style = '' ) { |
| 233 | - global $frm_vars, $mode; |
|
| 233 | + global $frm_vars, $mode; |
|
| 234 | 234 | |
| 235 | 235 | // Set up the hover actions for this user |
| 236 | 236 | $actions = array(); |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | $this->get_actions( $actions, $item, $edit_link ); |
| 240 | 240 | |
| 241 | - $action_links = $this->row_actions( $actions ); |
|
| 241 | + $action_links = $this->row_actions( $actions ); |
|
| 242 | 242 | |
| 243 | 243 | // Set up the checkbox ( because the user is editable, otherwise its empty ) |
| 244 | 244 | $checkbox = '<input type="checkbox" name="item-action[]" id="cb-item-action-' . absint( $item->id ) . '" value="' . esc_attr( $item->id ) . '" />'; |
@@ -247,9 +247,9 @@ discard block |
||
| 247 | 247 | |
| 248 | 248 | list( $columns, $hidden ) = $this->get_column_info(); |
| 249 | 249 | |
| 250 | - $format = 'Y/m/d'; |
|
| 251 | - if ( 'list' != $mode ) { |
|
| 252 | - $format .= ' \<\b\r \/\> g:i:s a'; |
|
| 250 | + $format = 'Y/m/d'; |
|
| 251 | + if ( 'list' != $mode ) { |
|
| 252 | + $format .= ' \<\b\r \/\> g:i:s a'; |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | foreach ( $columns as $column_name => $column_display_name ) { |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | |
| 258 | 258 | $style = ''; |
| 259 | 259 | if ( in_array( $column_name, $hidden ) ) { |
| 260 | - $class .= ' frm_hidden'; |
|
| 260 | + $class .= ' frm_hidden'; |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | $class = 'class="' . esc_attr( $class ) . '"'; |
@@ -270,24 +270,24 @@ discard block |
||
| 270 | 270 | break; |
| 271 | 271 | case 'id': |
| 272 | 272 | case 'form_key': |
| 273 | - $val = $item->{$column_name}; |
|
| 274 | - break; |
|
| 273 | + $val = $item->{$column_name}; |
|
| 274 | + break; |
|
| 275 | 275 | case 'name': |
| 276 | - $val = $this->get_form_name( $item, $actions, $edit_link, $mode ); |
|
| 277 | - $val .= $action_links; |
|
| 276 | + $val = $this->get_form_name( $item, $actions, $edit_link, $mode ); |
|
| 277 | + $val .= $action_links; |
|
| 278 | 278 | |
| 279 | - break; |
|
| 279 | + break; |
|
| 280 | 280 | case 'created_at': |
| 281 | 281 | $date = date( $format, strtotime( $item->created_at ) ); |
| 282 | 282 | $val = '<abbr title="' . esc_attr( date( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>'; |
| 283 | 283 | break; |
| 284 | 284 | case 'shortcode': |
| 285 | 285 | $val = '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable id=' . $item->id . ']' ) . '" /><br/>'; |
| 286 | - if ( 'excerpt' == $mode ) { |
|
| 286 | + if ( 'excerpt' == $mode ) { |
|
| 287 | 287 | $val .= '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable key=' . $item->form_key . ']' ) . '" />'; |
| 288 | - } |
|
| 289 | - break; |
|
| 290 | - case 'entries': |
|
| 288 | + } |
|
| 289 | + break; |
|
| 290 | + case 'entries': |
|
| 291 | 291 | if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) { |
| 292 | 292 | $val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr( 'Saving entries is disabled for this form', 'formidable' ) . '"></i>'; |
| 293 | 293 | } else { |
@@ -295,16 +295,16 @@ discard block |
||
| 295 | 295 | $val = current_user_can( 'frm_view_entries' ) ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text; |
| 296 | 296 | unset( $text ); |
| 297 | 297 | } |
| 298 | - break; |
|
| 299 | - case 'type': |
|
| 300 | - $val = ( $item->is_template && $item->default_template ) ? __( 'Default', 'formidable' ) : __( 'Custom', 'formidable' ); |
|
| 301 | - break; |
|
| 298 | + break; |
|
| 299 | + case 'type': |
|
| 300 | + $val = ( $item->is_template && $item->default_template ) ? __( 'Default', 'formidable' ) : __( 'Custom', 'formidable' ); |
|
| 301 | + break; |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | if ( isset( $val ) ) { |
| 305 | - $r .= "<td $attributes>"; |
|
| 306 | - $r .= $val; |
|
| 307 | - $r .= '</td>'; |
|
| 305 | + $r .= "<td $attributes>"; |
|
| 306 | + $r .= $val; |
|
| 307 | + $r .= '</td>'; |
|
| 308 | 308 | } |
| 309 | 309 | unset( $val ); |
| 310 | 310 | } |
@@ -313,9 +313,9 @@ discard block |
||
| 313 | 313 | return $r; |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - /** |
|
| 317 | - * @param string $edit_link |
|
| 318 | - */ |
|
| 316 | + /** |
|
| 317 | + * @param string $edit_link |
|
| 318 | + */ |
|
| 319 | 319 | private function get_actions( &$actions, $item, $edit_link ) { |
| 320 | 320 | $new_actions = FrmFormsHelper::get_action_links( $item->id, $item ); |
| 321 | 321 | foreach ( $new_actions as $link => $action ) { |
@@ -339,13 +339,13 @@ discard block |
||
| 339 | 339 | |
| 340 | 340 | $actions = array_merge( $actions, $new_actions ); |
| 341 | 341 | $actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview' ) . '</a>'; |
| 342 | - } |
|
| 342 | + } |
|
| 343 | 343 | |
| 344 | - /** |
|
| 345 | - * @param string $edit_link |
|
| 346 | - */ |
|
| 344 | + /** |
|
| 345 | + * @param string $edit_link |
|
| 346 | + */ |
|
| 347 | 347 | private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) { |
| 348 | - $form_name = $item->name; |
|
| 348 | + $form_name = $item->name; |
|
| 349 | 349 | if ( trim( $form_name ) == '' ) { |
| 350 | 350 | $form_name = __( '(no title)' ); |
| 351 | 351 | } |
@@ -354,37 +354,37 @@ discard block |
||
| 354 | 354 | $form_name = FrmAppHelper::truncate( $form_name, 50 ); |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - $val = '<strong>'; |
|
| 358 | - if ( 'trash' == $this->status ) { |
|
| 359 | - $val .= $form_name; |
|
| 360 | - } else { |
|
| 357 | + $val = '<strong>'; |
|
| 358 | + if ( 'trash' == $this->status ) { |
|
| 359 | + $val .= $form_name; |
|
| 360 | + } else { |
|
| 361 | 361 | $val .= '<a href="' . esc_url( isset( $actions['frm_edit'] ) ? $edit_link : FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" class="row-title">' . FrmAppHelper::kses( $form_name ) . '</a> '; |
| 362 | - } |
|
| 362 | + } |
|
| 363 | 363 | |
| 364 | - $this->add_draft_label( $item, $val ); |
|
| 365 | - $val .= '</strong>'; |
|
| 364 | + $this->add_draft_label( $item, $val ); |
|
| 365 | + $val .= '</strong>'; |
|
| 366 | 366 | |
| 367 | - $this->add_form_description( $item, $val ); |
|
| 367 | + $this->add_form_description( $item, $val ); |
|
| 368 | 368 | |
| 369 | - return $val; |
|
| 370 | - } |
|
| 369 | + return $val; |
|
| 370 | + } |
|
| 371 | 371 | |
| 372 | - /** |
|
| 373 | - * @param string $val |
|
| 374 | - */ |
|
| 375 | - private function add_draft_label( $item, &$val ) { |
|
| 376 | - if ( 'draft' == $item->status && 'draft' != $this->status ) { |
|
| 372 | + /** |
|
| 373 | + * @param string $val |
|
| 374 | + */ |
|
| 375 | + private function add_draft_label( $item, &$val ) { |
|
| 376 | + if ( 'draft' == $item->status && 'draft' != $this->status ) { |
|
| 377 | 377 | $val .= ' - <span class="post-state">' . __( 'Draft', 'formidable' ) . '</span>'; |
| 378 | - } |
|
| 379 | - } |
|
| 380 | - |
|
| 381 | - /** |
|
| 382 | - * @param string $val |
|
| 383 | - */ |
|
| 384 | - private function add_form_description( $item, &$val ) { |
|
| 385 | - global $mode; |
|
| 386 | - if ( 'excerpt' == $mode ) { |
|
| 378 | + } |
|
| 379 | + } |
|
| 380 | + |
|
| 381 | + /** |
|
| 382 | + * @param string $val |
|
| 383 | + */ |
|
| 384 | + private function add_form_description( $item, &$val ) { |
|
| 385 | + global $mode; |
|
| 386 | + if ( 'excerpt' == $mode ) { |
|
| 387 | 387 | $val .= FrmAppHelper::truncate( strip_tags( $item->description ), 50 ); |
| 388 | - } |
|
| 389 | - } |
|
| 388 | + } |
|
| 389 | + } |
|
| 390 | 390 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | $page = $this->get_pagenum(); |
| 19 | 19 | $per_page = $this->get_items_per_page( 'formidable_page_formidable_per_page' ); |
| 20 | 20 | |
| 21 | - $mode = self::get_param( |
|
| 21 | + $mode = self::get_param( |
|
| 22 | 22 | array( |
| 23 | 23 | 'param' => 'mode', |
| 24 | 24 | 'default' => 'list', |
@@ -30,13 +30,13 @@ discard block |
||
| 30 | 30 | 'default' => 'name', |
| 31 | 31 | ) |
| 32 | 32 | ); |
| 33 | - $order = self::get_param( |
|
| 33 | + $order = self::get_param( |
|
| 34 | 34 | array( |
| 35 | 35 | 'param' => 'order', |
| 36 | 36 | 'default' => 'ASC', |
| 37 | 37 | ) |
| 38 | 38 | ); |
| 39 | - $start = self::get_param( |
|
| 39 | + $start = self::get_param( |
|
| 40 | 40 | array( |
| 41 | 41 | 'param' => 'start', |
| 42 | 42 | 'default' => ( $page - 1 ) * $per_page, |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | if ( $counts->{$status} || 'published' == $status || 'template' == $status ) { |
| 213 | - $links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>'; |
|
| 213 | + $links[$status] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>'; |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | unset( $status, $name ); |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | private function get_actions( &$actions, $item, $edit_link ) { |
| 320 | 320 | $new_actions = FrmFormsHelper::get_action_links( $item->id, $item ); |
| 321 | 321 | foreach ( $new_actions as $link => $action ) { |
| 322 | - $new_actions[ $link ] = FrmFormsHelper::format_link_html( $action, 'short' ); |
|
| 322 | + $new_actions[$link] = FrmFormsHelper::format_link_html( $action, 'short' ); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | if ( 'trash' == $this->status ) { |
@@ -29,17 +29,17 @@ discard block |
||
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - return $values; |
|
| 33 | - } |
|
| 32 | + return $values; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | 35 | public static function get_html_id( $field, $plus = '' ) { |
| 36 | 36 | return apply_filters( 'frm_field_html_id', 'field_' . $field['field_key'] . $plus, $field ); |
| 37 | - } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - public static function setup_edit_vars( $field, $doing_ajax = false ) { |
|
| 39 | + public static function setup_edit_vars( $field, $doing_ajax = false ) { |
|
| 40 | 40 | $values = self::field_object_to_array( $field ); |
| 41 | 41 | return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) ); |
| 42 | - } |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | 44 | public static function field_object_to_array( $field ) { |
| 45 | 45 | $values = (array) $field; |
@@ -239,18 +239,18 @@ discard block |
||
| 239 | 239 | return $field_type->get_new_field_defaults(); |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - public static function fill_field( &$values, $field, $form_id, $new_key = '' ) { |
|
| 243 | - global $wpdb; |
|
| 242 | + public static function fill_field( &$values, $field, $form_id, $new_key = '' ) { |
|
| 243 | + global $wpdb; |
|
| 244 | 244 | |
| 245 | 245 | $values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
| 246 | - $values['form_id'] = $form_id; |
|
| 246 | + $values['form_id'] = $form_id; |
|
| 247 | 247 | $values['options'] = maybe_serialize( $field->options ); |
| 248 | 248 | $values['default_value'] = maybe_serialize( $field->default_value ); |
| 249 | 249 | |
| 250 | - foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
|
| 251 | - $values[ $col ] = $field->{$col}; |
|
| 252 | - } |
|
| 253 | - } |
|
| 250 | + foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
|
| 251 | + $values[ $col ] = $field->{$col}; |
|
| 252 | + } |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | 255 | /** |
| 256 | 256 | * @since 2.0 |
@@ -405,8 +405,8 @@ discard block |
||
| 405 | 405 | */ |
| 406 | 406 | public static function get_shortcode_tag( $shortcodes, $short_key, $args ) { |
| 407 | 407 | _deprecated_function( __FUNCTION__, '3.0', 'FrmShortcodeHelper::get_shortcode_tag' ); |
| 408 | - return FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key, $args ); |
|
| 409 | - } |
|
| 408 | + return FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key, $args ); |
|
| 409 | + } |
|
| 410 | 410 | |
| 411 | 411 | public static function get_checkbox_id( $field, $opt_key ) { |
| 412 | 412 | $id = $field['id']; |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | */ |
| 423 | 423 | public static function display_recaptcha( $field ) { |
| 424 | 424 | _deprecated_function( __FUNCTION__, '3.0', 'FrmFieldCaptcha::field_input' ); |
| 425 | - } |
|
| 425 | + } |
|
| 426 | 426 | |
| 427 | 427 | public static function show_single_option( $field ) { |
| 428 | 428 | if ( ! is_array( $field['options'] ) ) { |
@@ -433,26 +433,26 @@ discard block |
||
| 433 | 433 | $html_id = isset( $field['html_id'] ) ? $field['html_id'] : self::get_html_id( $field ); |
| 434 | 434 | |
| 435 | 435 | foreach ( $field['options'] as $opt_key => $opt ) { |
| 436 | - $field_val = self::get_value_from_array( $opt, $opt_key, $field ); |
|
| 437 | - $opt = self::get_label_from_array( $opt, $opt_key, $field ); |
|
| 436 | + $field_val = self::get_value_from_array( $opt, $opt_key, $field ); |
|
| 437 | + $opt = self::get_label_from_array( $opt, $opt_key, $field ); |
|
| 438 | 438 | |
| 439 | 439 | // Get string for Other text field, if needed |
| 440 | 440 | $other_val = self::get_other_val( compact( 'opt_key', 'field' ) ); |
| 441 | 441 | |
| 442 | 442 | $checked = ( $other_val || isset( $field['value'] ) && ( ( ! is_array( $field['value'] ) && $field['value'] == $field_val ) || ( is_array( $field['value'] ) && in_array( $field_val, $field['value'] ) ) ) ) ? ' checked="checked"' : ''; |
| 443 | 443 | |
| 444 | - // If this is an "Other" option, get the HTML for it |
|
| 444 | + // If this is an "Other" option, get the HTML for it |
|
| 445 | 445 | if ( self::is_other_opt( $opt_key ) ) { |
| 446 | 446 | if ( FrmAppHelper::pro_is_installed() ) { |
| 447 | 447 | require( FrmProAppHelper::plugin_path() . '/classes/views/frmpro-fields/other-option.php' ); |
| 448 | 448 | } |
| 449 | - } else { |
|
| 449 | + } else { |
|
| 450 | 450 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
| 451 | - } |
|
| 451 | + } |
|
| 452 | 452 | |
| 453 | 453 | unset( $checked, $other_val ); |
| 454 | 454 | } |
| 455 | - } |
|
| 455 | + } |
|
| 456 | 456 | |
| 457 | 457 | public static function get_value_from_array( $opt, $opt_key, $field ) { |
| 458 | 458 | $opt = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field ); |
@@ -471,9 +471,9 @@ discard block |
||
| 471 | 471 | */ |
| 472 | 472 | public static function get_term_link( $tax_id ) { |
| 473 | 473 | $tax = get_taxonomy( $tax_id ); |
| 474 | - if ( ! $tax ) { |
|
| 475 | - return ''; |
|
| 476 | - } |
|
| 474 | + if ( ! $tax ) { |
|
| 475 | + return ''; |
|
| 476 | + } |
|
| 477 | 477 | |
| 478 | 478 | $link = sprintf( |
| 479 | 479 | esc_html__( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
@@ -481,8 +481,8 @@ discard block |
||
| 481 | 481 | ); |
| 482 | 482 | unset( $tax ); |
| 483 | 483 | |
| 484 | - return $link; |
|
| 485 | - } |
|
| 484 | + return $link; |
|
| 485 | + } |
|
| 486 | 486 | |
| 487 | 487 | public static function value_meets_condition( $observed_value, $cond, $hide_opt ) { |
| 488 | 488 | $hide_opt = self::get_value_for_comparision( $hide_opt ); |
@@ -490,9 +490,9 @@ discard block |
||
| 490 | 490 | |
| 491 | 491 | if ( is_array( $observed_value ) ) { |
| 492 | 492 | return self::array_value_condition( $observed_value, $cond, $hide_opt ); |
| 493 | - } |
|
| 493 | + } |
|
| 494 | 494 | |
| 495 | - $m = false; |
|
| 495 | + $m = false; |
|
| 496 | 496 | if ( $cond == '==' ) { |
| 497 | 497 | $m = $observed_value == $hide_opt; |
| 498 | 498 | } elseif ( $cond == '!=' ) { |
@@ -513,8 +513,8 @@ discard block |
||
| 513 | 513 | $m = ( $m === false ) ? false : true; |
| 514 | 514 | } |
| 515 | 515 | } |
| 516 | - return $m; |
|
| 517 | - } |
|
| 516 | + return $m; |
|
| 517 | + } |
|
| 518 | 518 | |
| 519 | 519 | /** |
| 520 | 520 | * Trim and sanitize the values |
@@ -530,8 +530,8 @@ discard block |
||
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | public static function array_value_condition( $observed_value, $cond, $hide_opt ) { |
| 533 | - $m = false; |
|
| 534 | - if ( $cond == '==' ) { |
|
| 533 | + $m = false; |
|
| 534 | + if ( $cond == '==' ) { |
|
| 535 | 535 | if ( is_array( $hide_opt ) ) { |
| 536 | 536 | $m = array_intersect( $hide_opt, $observed_value ); |
| 537 | 537 | $m = empty( $m ) ? false : true; |
@@ -555,35 +555,35 @@ discard block |
||
| 555 | 555 | } |
| 556 | 556 | } |
| 557 | 557 | |
| 558 | - if ( $cond == 'not LIKE' ) { |
|
| 559 | - $m = ( $m === false ) ? true : false; |
|
| 560 | - } |
|
| 561 | - } |
|
| 558 | + if ( $cond == 'not LIKE' ) { |
|
| 559 | + $m = ( $m === false ) ? true : false; |
|
| 560 | + } |
|
| 561 | + } |
|
| 562 | 562 | |
| 563 | - return $m; |
|
| 564 | - } |
|
| 563 | + return $m; |
|
| 564 | + } |
|
| 565 | 565 | |
| 566 | - /** |
|
| 567 | - * Replace a few basic shortcodes and field ids |
|
| 568 | - * @since 2.0 |
|
| 569 | - * @return string |
|
| 570 | - */ |
|
| 566 | + /** |
|
| 567 | + * Replace a few basic shortcodes and field ids |
|
| 568 | + * @since 2.0 |
|
| 569 | + * @return string |
|
| 570 | + */ |
|
| 571 | 571 | public static function basic_replace_shortcodes( $value, $form, $entry ) { |
| 572 | 572 | if ( strpos( $value, '[sitename]' ) !== false ) { |
| 573 | - $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 573 | + $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 574 | 574 | $value = str_replace( '[sitename]', $new_value, $value ); |
| 575 | - } |
|
| 575 | + } |
|
| 576 | 576 | |
| 577 | 577 | $value = apply_filters( 'frm_content', $value, $form, $entry ); |
| 578 | 578 | $value = do_shortcode( $value ); |
| 579 | 579 | |
| 580 | - return $value; |
|
| 581 | - } |
|
| 580 | + return $value; |
|
| 581 | + } |
|
| 582 | 582 | |
| 583 | 583 | public static function get_shortcodes( $content, $form_id ) { |
| 584 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 584 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 585 | 585 | return FrmProDisplaysHelper::get_shortcodes( $content, $form_id ); |
| 586 | - } |
|
| 586 | + } |
|
| 587 | 587 | |
| 588 | 588 | $fields = FrmField::getAll( |
| 589 | 589 | array( |
@@ -596,23 +596,23 @@ discard block |
||
| 596 | 596 | |
| 597 | 597 | preg_match_all( "/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER ); |
| 598 | 598 | |
| 599 | - return $matches; |
|
| 600 | - } |
|
| 599 | + return $matches; |
|
| 600 | + } |
|
| 601 | 601 | |
| 602 | 602 | public static function allowed_shortcodes( $fields = array() ) { |
| 603 | 603 | $tagregexp = array( 'editlink', 'id', 'key', 'ip', 'siteurl', 'sitename', 'admin_email', 'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by', 'parent[-|_]id' ); |
| 604 | 604 | |
| 605 | - foreach ( $fields as $field ) { |
|
| 606 | - $tagregexp[] = $field->id; |
|
| 607 | - $tagregexp[] = $field->field_key; |
|
| 608 | - } |
|
| 605 | + foreach ( $fields as $field ) { |
|
| 606 | + $tagregexp[] = $field->id; |
|
| 607 | + $tagregexp[] = $field->field_key; |
|
| 608 | + } |
|
| 609 | 609 | |
| 610 | 610 | $tagregexp = implode( '|', $tagregexp ); |
| 611 | - return $tagregexp; |
|
| 612 | - } |
|
| 611 | + return $tagregexp; |
|
| 612 | + } |
|
| 613 | 613 | |
| 614 | 614 | public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
| 615 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 615 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 616 | 616 | if ( empty( $tag ) ) { |
| 617 | 617 | continue; |
| 618 | 618 | } |
@@ -633,7 +633,7 @@ discard block |
||
| 633 | 633 | } |
| 634 | 634 | |
| 635 | 635 | return $content; |
| 636 | - } |
|
| 636 | + } |
|
| 637 | 637 | |
| 638 | 638 | /** |
| 639 | 639 | * Prevent shortcodes in fields from being processed |
@@ -742,44 +742,44 @@ discard block |
||
| 742 | 742 | return $replace_with; |
| 743 | 743 | } |
| 744 | 744 | |
| 745 | - /** |
|
| 746 | - * Get the value to replace a few standard shortcodes |
|
| 747 | - * |
|
| 748 | - * @since 2.0 |
|
| 749 | - * @return string |
|
| 750 | - */ |
|
| 751 | - public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) { |
|
| 752 | - $new_value = ''; |
|
| 753 | - switch ( $tag ) { |
|
| 754 | - case 'admin_email': |
|
| 745 | + /** |
|
| 746 | + * Get the value to replace a few standard shortcodes |
|
| 747 | + * |
|
| 748 | + * @since 2.0 |
|
| 749 | + * @return string |
|
| 750 | + */ |
|
| 751 | + public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) { |
|
| 752 | + $new_value = ''; |
|
| 753 | + switch ( $tag ) { |
|
| 754 | + case 'admin_email': |
|
| 755 | 755 | $new_value = get_option( 'admin_email' ); |
| 756 | - break; |
|
| 757 | - case 'siteurl': |
|
| 758 | - $new_value = FrmAppHelper::site_url(); |
|
| 759 | - break; |
|
| 760 | - case 'frmurl': |
|
| 761 | - $new_value = FrmAppHelper::plugin_url(); |
|
| 762 | - break; |
|
| 763 | - case 'sitename': |
|
| 764 | - $new_value = FrmAppHelper::site_name(); |
|
| 765 | - break; |
|
| 766 | - case 'get': |
|
| 767 | - $new_value = self::process_get_shortcode( $atts, $return_array ); |
|
| 768 | - } |
|
| 769 | - |
|
| 770 | - return $new_value; |
|
| 771 | - } |
|
| 772 | - |
|
| 773 | - /** |
|
| 774 | - * Process the [get] shortcode |
|
| 775 | - * |
|
| 776 | - * @since 2.0 |
|
| 777 | - * @return string|array |
|
| 778 | - */ |
|
| 779 | - public static function process_get_shortcode( $atts, $return_array = false ) { |
|
| 756 | + break; |
|
| 757 | + case 'siteurl': |
|
| 758 | + $new_value = FrmAppHelper::site_url(); |
|
| 759 | + break; |
|
| 760 | + case 'frmurl': |
|
| 761 | + $new_value = FrmAppHelper::plugin_url(); |
|
| 762 | + break; |
|
| 763 | + case 'sitename': |
|
| 764 | + $new_value = FrmAppHelper::site_name(); |
|
| 765 | + break; |
|
| 766 | + case 'get': |
|
| 767 | + $new_value = self::process_get_shortcode( $atts, $return_array ); |
|
| 768 | + } |
|
| 769 | + |
|
| 770 | + return $new_value; |
|
| 771 | + } |
|
| 772 | + |
|
| 773 | + /** |
|
| 774 | + * Process the [get] shortcode |
|
| 775 | + * |
|
| 776 | + * @since 2.0 |
|
| 777 | + * @return string|array |
|
| 778 | + */ |
|
| 779 | + public static function process_get_shortcode( $atts, $return_array = false ) { |
|
| 780 | 780 | if ( ! isset( $atts['param'] ) ) { |
| 781 | - return ''; |
|
| 782 | - } |
|
| 781 | + return ''; |
|
| 782 | + } |
|
| 783 | 783 | |
| 784 | 784 | if ( strpos( $atts['param'], '[' ) ) { |
| 785 | 785 | $atts['param'] = str_replace( '[', '[', $atts['param'] ); |
@@ -787,22 +787,22 @@ discard block |
||
| 787 | 787 | } |
| 788 | 788 | |
| 789 | 789 | $new_value = FrmAppHelper::get_param( $atts['param'], '', 'get', 'sanitize_text_field' ); |
| 790 | - $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
|
| 790 | + $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
|
| 791 | 791 | |
| 792 | - if ( $new_value == '' ) { |
|
| 792 | + if ( $new_value == '' ) { |
|
| 793 | 793 | if ( ! isset( $atts['prev_val'] ) ) { |
| 794 | - $atts['prev_val'] = ''; |
|
| 795 | - } |
|
| 794 | + $atts['prev_val'] = ''; |
|
| 795 | + } |
|
| 796 | 796 | |
| 797 | 797 | $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val']; |
| 798 | - } |
|
| 798 | + } |
|
| 799 | 799 | |
| 800 | 800 | if ( is_array( $new_value ) && ! $return_array ) { |
| 801 | 801 | $new_value = implode( ', ', $new_value ); |
| 802 | 802 | } |
| 803 | 803 | |
| 804 | - return $new_value; |
|
| 805 | - } |
|
| 804 | + return $new_value; |
|
| 805 | + } |
|
| 806 | 806 | |
| 807 | 807 | public static function get_display_value( $value, $field, $atts = array() ) { |
| 808 | 808 | |
@@ -872,27 +872,27 @@ discard block |
||
| 872 | 872 | |
| 873 | 873 | $field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() ); |
| 874 | 874 | |
| 875 | - $field_types = array(); |
|
| 875 | + $field_types = array(); |
|
| 876 | 876 | if ( in_array( $type, $single_input ) ) { |
| 877 | - self::field_types_for_input( $single_input, $field_selection, $field_types ); |
|
| 877 | + self::field_types_for_input( $single_input, $field_selection, $field_types ); |
|
| 878 | 878 | } elseif ( in_array( $type, $multiple_input ) ) { |
| 879 | - self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
|
| 879 | + self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
|
| 880 | 880 | } elseif ( in_array( $type, $other_type ) ) { |
| 881 | - self::field_types_for_input( $other_type, $field_selection, $field_types ); |
|
| 881 | + self::field_types_for_input( $other_type, $field_selection, $field_types ); |
|
| 882 | 882 | } elseif ( isset( $field_selection[ $type ] ) ) { |
| 883 | - $field_types[ $type ] = $field_selection[ $type ]; |
|
| 884 | - } |
|
| 883 | + $field_types[ $type ] = $field_selection[ $type ]; |
|
| 884 | + } |
|
| 885 | 885 | |
| 886 | 886 | $field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) ); |
| 887 | - return $field_types; |
|
| 888 | - } |
|
| 887 | + return $field_types; |
|
| 888 | + } |
|
| 889 | 889 | |
| 890 | - private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
|
| 891 | - foreach ( $inputs as $input ) { |
|
| 892 | - $field_types[ $input ] = $fields[ $input ]; |
|
| 890 | + private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
|
| 891 | + foreach ( $inputs as $input ) { |
|
| 892 | + $field_types[ $input ] = $fields[ $input ]; |
|
| 893 | 893 | unset( $input ); |
| 894 | - } |
|
| 895 | - } |
|
| 894 | + } |
|
| 895 | + } |
|
| 896 | 896 | |
| 897 | 897 | /** |
| 898 | 898 | * Check if current field option is an "other" option |
@@ -906,14 +906,14 @@ discard block |
||
| 906 | 906 | return $opt_key && strpos( $opt_key, 'other_' ) === 0; |
| 907 | 907 | } |
| 908 | 908 | |
| 909 | - /** |
|
| 910 | - * Get value that belongs in "Other" text box |
|
| 911 | - * |
|
| 912 | - * @since 2.0.6 |
|
| 913 | - * |
|
| 914 | - * @param array $args |
|
| 915 | - */ |
|
| 916 | - public static function get_other_val( $args ) { |
|
| 909 | + /** |
|
| 910 | + * Get value that belongs in "Other" text box |
|
| 911 | + * |
|
| 912 | + * @since 2.0.6 |
|
| 913 | + * |
|
| 914 | + * @param array $args |
|
| 915 | + */ |
|
| 916 | + public static function get_other_val( $args ) { |
|
| 917 | 917 | $defaults = array( |
| 918 | 918 | 'opt_key' => 0, |
| 919 | 919 | 'field' => array(), |
@@ -991,20 +991,20 @@ discard block |
||
| 991 | 991 | } |
| 992 | 992 | |
| 993 | 993 | return $other_val; |
| 994 | - } |
|
| 995 | - |
|
| 996 | - /** |
|
| 997 | - * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 998 | - * Intended for front-end use |
|
| 999 | - * |
|
| 1000 | - * @since 2.0.6 |
|
| 1001 | - * |
|
| 1002 | - * @param array $args should include field, opt_key and field name |
|
| 1003 | - * @param boolean $other_opt |
|
| 1004 | - * @param string $checked |
|
| 1005 | - * @return array $other_args |
|
| 1006 | - */ |
|
| 1007 | - public static function prepare_other_input( $args, &$other_opt, &$checked ) { |
|
| 994 | + } |
|
| 995 | + |
|
| 996 | + /** |
|
| 997 | + * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 998 | + * Intended for front-end use |
|
| 999 | + * |
|
| 1000 | + * @since 2.0.6 |
|
| 1001 | + * |
|
| 1002 | + * @param array $args should include field, opt_key and field name |
|
| 1003 | + * @param boolean $other_opt |
|
| 1004 | + * @param string $checked |
|
| 1005 | + * @return array $other_args |
|
| 1006 | + */ |
|
| 1007 | + public static function prepare_other_input( $args, &$other_opt, &$checked ) { |
|
| 1008 | 1008 | //Check if this is an "Other" option |
| 1009 | 1009 | if ( ! self::is_other_opt( $args['opt_key'] ) ) { |
| 1010 | 1010 | return; |
@@ -1020,8 +1020,8 @@ discard block |
||
| 1020 | 1020 | $checked = 'checked="checked" '; |
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | - return $other_args; |
|
| 1024 | - } |
|
| 1023 | + return $other_args; |
|
| 1024 | + } |
|
| 1025 | 1025 | |
| 1026 | 1026 | /** |
| 1027 | 1027 | * @param array $args |
@@ -1078,8 +1078,8 @@ discard block |
||
| 1078 | 1078 | * @since 2.0.6 |
| 1079 | 1079 | */ |
| 1080 | 1080 | public static function include_other_input( $args ) { |
| 1081 | - if ( ! $args['other_opt'] ) { |
|
| 1082 | - return; |
|
| 1081 | + if ( ! $args['other_opt'] ) { |
|
| 1082 | + return; |
|
| 1083 | 1083 | } |
| 1084 | 1084 | |
| 1085 | 1085 | $classes = array( 'frm_other_input' ); |
@@ -1104,15 +1104,15 @@ discard block |
||
| 1104 | 1104 | } |
| 1105 | 1105 | |
| 1106 | 1106 | /** |
| 1107 | - * Get the HTML id for an "Other" text field |
|
| 1108 | - * Note: This does not affect fields in repeating sections |
|
| 1109 | - * |
|
| 1110 | - * @since 2.0.08 |
|
| 1111 | - * @param string $type - field type |
|
| 1112 | - * @param string $html_id |
|
| 1113 | - * @param string|boolean $opt_key |
|
| 1114 | - * @return string $other_id |
|
| 1115 | - */ |
|
| 1107 | + * Get the HTML id for an "Other" text field |
|
| 1108 | + * Note: This does not affect fields in repeating sections |
|
| 1109 | + * |
|
| 1110 | + * @since 2.0.08 |
|
| 1111 | + * @param string $type - field type |
|
| 1112 | + * @param string $html_id |
|
| 1113 | + * @param string|boolean $opt_key |
|
| 1114 | + * @return string $other_id |
|
| 1115 | + */ |
|
| 1116 | 1116 | public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) { |
| 1117 | 1117 | $other_id = $html_id; |
| 1118 | 1118 | |
@@ -1176,10 +1176,10 @@ discard block |
||
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | 1178 | public static function switch_field_ids( $val ) { |
| 1179 | - global $frm_duplicate_ids; |
|
| 1180 | - $replace = array(); |
|
| 1181 | - $replace_with = array(); |
|
| 1182 | - foreach ( (array) $frm_duplicate_ids as $old => $new ) { |
|
| 1179 | + global $frm_duplicate_ids; |
|
| 1180 | + $replace = array(); |
|
| 1181 | + $replace_with = array(); |
|
| 1182 | + foreach ( (array) $frm_duplicate_ids as $old => $new ) { |
|
| 1183 | 1183 | $replace[] = '[if ' . $old . ']'; |
| 1184 | 1184 | $replace_with[] = '[if ' . $new . ']'; |
| 1185 | 1185 | $replace[] = '[if ' . $old . ' '; |
@@ -1195,18 +1195,18 @@ discard block |
||
| 1195 | 1195 | $replace[] = '[' . $old . ' '; |
| 1196 | 1196 | $replace_with[] = '[' . $new . ' '; |
| 1197 | 1197 | unset( $old, $new ); |
| 1198 | - } |
|
| 1198 | + } |
|
| 1199 | 1199 | if ( is_array( $val ) ) { |
| 1200 | 1200 | foreach ( $val as $k => $v ) { |
| 1201 | - $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1201 | + $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1202 | 1202 | unset( $k, $v ); |
| 1203 | - } |
|
| 1204 | - } else { |
|
| 1203 | + } |
|
| 1204 | + } else { |
|
| 1205 | 1205 | $val = str_replace( $replace, $replace_with, $val ); |
| 1206 | - } |
|
| 1206 | + } |
|
| 1207 | 1207 | |
| 1208 | - return $val; |
|
| 1209 | - } |
|
| 1208 | + return $val; |
|
| 1209 | + } |
|
| 1210 | 1210 | |
| 1211 | 1211 | public static function get_us_states() { |
| 1212 | 1212 | $states = array( |
@@ -1272,7 +1272,7 @@ discard block |
||
| 1272 | 1272 | public static function get_bulk_prefilled_opts( array &$prepop ) { |
| 1273 | 1273 | $prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries(); |
| 1274 | 1274 | |
| 1275 | - $states = FrmFieldsHelper::get_us_states(); |
|
| 1275 | + $states = FrmFieldsHelper::get_us_states(); |
|
| 1276 | 1276 | $state_abv = array_keys( $states ); |
| 1277 | 1277 | sort( $state_abv ); |
| 1278 | 1278 | $prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv; |
@@ -1321,7 +1321,7 @@ discard block |
||
| 1321 | 1321 | ); |
| 1322 | 1322 | |
| 1323 | 1323 | $prepop = apply_filters( 'frm_bulk_field_choices', $prepop ); |
| 1324 | - } |
|
| 1324 | + } |
|
| 1325 | 1325 | |
| 1326 | 1326 | /** |
| 1327 | 1327 | * Display a field value selector |
@@ -1331,10 +1331,10 @@ discard block |
||
| 1331 | 1331 | * @param int $selector_field_id |
| 1332 | 1332 | * @param array $selector_args |
| 1333 | 1333 | */ |
| 1334 | - public static function display_field_value_selector( $selector_field_id, $selector_args ) { |
|
| 1335 | - $field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args ); |
|
| 1336 | - $field_value_selector->display(); |
|
| 1337 | - } |
|
| 1334 | + public static function display_field_value_selector( $selector_field_id, $selector_args ) { |
|
| 1335 | + $field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args ); |
|
| 1336 | + $field_value_selector->display(); |
|
| 1337 | + } |
|
| 1338 | 1338 | |
| 1339 | 1339 | /** |
| 1340 | 1340 | * Convert a field object to a flat array |
@@ -2,25 +2,25 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmFieldsController { |
| 4 | 4 | |
| 5 | - public static function load_field() { |
|
| 5 | + public static function load_field() { |
|
| 6 | 6 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 7 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 7 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 8 | 8 | |
| 9 | - $fields = $_POST['field']; |
|
| 10 | - if ( empty( $fields ) ) { |
|
| 11 | - wp_die(); |
|
| 12 | - } |
|
| 9 | + $fields = $_POST['field']; |
|
| 10 | + if ( empty( $fields ) ) { |
|
| 11 | + wp_die(); |
|
| 12 | + } |
|
| 13 | 13 | |
| 14 | - $_GET['page'] = 'formidable'; |
|
| 15 | - $fields = stripslashes_deep( $fields ); |
|
| 14 | + $_GET['page'] = 'formidable'; |
|
| 15 | + $fields = stripslashes_deep( $fields ); |
|
| 16 | 16 | |
| 17 | 17 | $values = array( |
| 18 | 18 | 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ), |
| 19 | 19 | 'doing_ajax' => true, |
| 20 | 20 | ); |
| 21 | - $field_html = array(); |
|
| 21 | + $field_html = array(); |
|
| 22 | 22 | |
| 23 | - foreach ( $fields as $field ) { |
|
| 23 | + foreach ( $fields as $field ) { |
|
| 24 | 24 | $field = htmlspecialchars_decode( nl2br( $field ) ); |
| 25 | 25 | $field = json_decode( $field ); |
| 26 | 26 | if ( ! isset( $field->id ) || ! is_numeric( $field->id ) ) { |
@@ -39,19 +39,19 @@ discard block |
||
| 39 | 39 | self::load_single_field( $field, $values ); |
| 40 | 40 | $field_html[ absint( $field->id ) ] = ob_get_contents(); |
| 41 | 41 | ob_end_clean(); |
| 42 | - } |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | 44 | echo json_encode( $field_html ); |
| 45 | 45 | |
| 46 | - wp_die(); |
|
| 47 | - } |
|
| 46 | + wp_die(); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * Create a new field with ajax |
| 51 | 51 | */ |
| 52 | - public static function create() { |
|
| 52 | + public static function create() { |
|
| 53 | 53 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 54 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 54 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 55 | 55 | |
| 56 | 56 | $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' ); |
| 57 | 57 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
@@ -61,25 +61,25 @@ discard block |
||
| 61 | 61 | // this hook will allow for multiple fields to be added at once |
| 62 | 62 | do_action( 'frm_after_field_created', $field, $form_id ); |
| 63 | 63 | |
| 64 | - wp_die(); |
|
| 65 | - } |
|
| 64 | + wp_die(); |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * Set up and create a new field |
|
| 69 | - * |
|
| 70 | - * @param string $field_type |
|
| 71 | - * @param integer $form_id |
|
| 72 | - * @return array|bool |
|
| 73 | - */ |
|
| 67 | + /** |
|
| 68 | + * Set up and create a new field |
|
| 69 | + * |
|
| 70 | + * @param string $field_type |
|
| 71 | + * @param integer $form_id |
|
| 72 | + * @return array|bool |
|
| 73 | + */ |
|
| 74 | 74 | public static function include_new_field( $field_type, $form_id ) { |
| 75 | 75 | $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id ); |
| 76 | - $field_values = apply_filters( 'frm_before_field_created', $field_values ); |
|
| 76 | + $field_values = apply_filters( 'frm_before_field_created', $field_values ); |
|
| 77 | 77 | |
| 78 | - $field_id = FrmField::create( $field_values ); |
|
| 78 | + $field_id = FrmField::create( $field_values ); |
|
| 79 | 79 | |
| 80 | - if ( ! $field_id ) { |
|
| 81 | - return false; |
|
| 82 | - } |
|
| 80 | + if ( ! $field_id ) { |
|
| 81 | + return false; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | 84 | $field = self::get_field_array_from_id( $field_id ); |
| 85 | 85 | |
@@ -95,8 +95,8 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | self::load_single_field( $field, $values, $form_id ); |
| 97 | 97 | |
| 98 | - return $field; |
|
| 99 | - } |
|
| 98 | + return $field; |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * @deprecated 3.0 |
@@ -112,29 +112,29 @@ discard block |
||
| 112 | 112 | $field = 'name'; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - if ( empty( $id ) ) { |
|
| 115 | + if ( empty( $id ) ) { |
|
| 116 | 116 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 117 | 117 | $id = str_replace( 'field_label_', '', $id ); |
| 118 | - } |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | 120 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
| 121 | 121 | $value = trim( $value ); |
| 122 | - if ( trim( strip_tags( $value ) ) === '' ) { |
|
| 123 | - // set blank value if there is no content |
|
| 124 | - $value = ''; |
|
| 125 | - } |
|
| 122 | + if ( trim( strip_tags( $value ) ) === '' ) { |
|
| 123 | + // set blank value if there is no content |
|
| 124 | + $value = ''; |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | 127 | FrmField::update( $id, array( $field => $value ) ); |
| 128 | 128 | |
| 129 | 129 | do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) ); |
| 130 | 130 | |
| 131 | 131 | echo stripslashes( wp_kses_post( $value ) ); // WPCS: XSS ok. |
| 132 | - wp_die(); |
|
| 133 | - } |
|
| 132 | + wp_die(); |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - public static function update_ajax_option() { |
|
| 135 | + public static function update_ajax_option() { |
|
| 136 | 136 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 137 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 137 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 138 | 138 | |
| 139 | 139 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
| 140 | 140 | if ( ! $field_id ) { |
@@ -156,20 +156,20 @@ discard block |
||
| 156 | 156 | 'form_id' => $field->form_id, |
| 157 | 157 | ) |
| 158 | 158 | ); |
| 159 | - wp_die(); |
|
| 160 | - } |
|
| 159 | + wp_die(); |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - public static function duplicate() { |
|
| 162 | + public static function duplicate() { |
|
| 163 | 163 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 164 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 164 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 165 | 165 | |
| 166 | 166 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 167 | 167 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 168 | 168 | |
| 169 | 169 | $copy_field = FrmField::getOne( $field_id ); |
| 170 | - if ( ! $copy_field ) { |
|
| 171 | - wp_die(); |
|
| 172 | - } |
|
| 170 | + if ( ! $copy_field ) { |
|
| 171 | + wp_die(); |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | 174 | do_action( 'frm_duplicate_field', $copy_field, $form_id ); |
| 175 | 175 | do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id ); |
@@ -183,8 +183,8 @@ discard block |
||
| 183 | 183 | self::load_single_field( $field_id, $values ); |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - wp_die(); |
|
| 187 | - } |
|
| 186 | + wp_die(); |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | 189 | /** |
| 190 | 190 | * Load a single field in the form builder along with all needed variables |
@@ -276,21 +276,21 @@ discard block |
||
| 276 | 276 | return $li_classes; |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - public static function destroy() { |
|
| 279 | + public static function destroy() { |
|
| 280 | 280 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 281 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 281 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 282 | 282 | |
| 283 | 283 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 284 | 284 | FrmField::destroy( $field_id ); |
| 285 | - wp_die(); |
|
| 286 | - } |
|
| 285 | + wp_die(); |
|
| 286 | + } |
|
| 287 | 287 | |
| 288 | - /* Field Options */ |
|
| 288 | + /* Field Options */ |
|
| 289 | 289 | |
| 290 | - //Add Single Option or Other Option |
|
| 291 | - public static function add_option() { |
|
| 290 | + //Add Single Option or Other Option |
|
| 291 | + public static function add_option() { |
|
| 292 | 292 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 293 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 293 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 294 | 294 | |
| 295 | 295 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 296 | 296 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
@@ -315,69 +315,69 @@ discard block |
||
| 315 | 315 | FrmFieldsHelper::show_single_option( $field ); |
| 316 | 316 | |
| 317 | 317 | wp_die(); |
| 318 | - } |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | 320 | /** |
| 321 | 321 | * @deprecated 2.3 |
| 322 | 322 | * @codeCoverageIgnore |
| 323 | 323 | */ |
| 324 | - public static function edit_option() { |
|
| 324 | + public static function edit_option() { |
|
| 325 | 325 | _deprecated_function( __FUNCTION__, '2.3' ); |
| 326 | - } |
|
| 326 | + } |
|
| 327 | 327 | |
| 328 | 328 | /** |
| 329 | 329 | * @deprecated 2.3 |
| 330 | 330 | * @codeCoverageIgnore |
| 331 | 331 | */ |
| 332 | - public static function delete_option() { |
|
| 332 | + public static function delete_option() { |
|
| 333 | 333 | _deprecated_function( __FUNCTION__, '2.3' ); |
| 334 | - } |
|
| 334 | + } |
|
| 335 | 335 | |
| 336 | - public static function import_choices() { |
|
| 337 | - FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
| 336 | + public static function import_choices() { |
|
| 337 | + FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
| 338 | 338 | |
| 339 | 339 | $field_id = absint( $_REQUEST['field_id'] ); |
| 340 | 340 | |
| 341 | - global $current_screen, $hook_suffix; |
|
| 341 | + global $current_screen, $hook_suffix; |
|
| 342 | 342 | |
| 343 | - // Catch plugins that include admin-header.php before admin.php completes. |
|
| 344 | - if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
| 345 | - $hook_suffix = ''; |
|
| 346 | - set_current_screen(); |
|
| 347 | - } |
|
| 343 | + // Catch plugins that include admin-header.php before admin.php completes. |
|
| 344 | + if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
| 345 | + $hook_suffix = ''; |
|
| 346 | + set_current_screen(); |
|
| 347 | + } |
|
| 348 | 348 | |
| 349 | - if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
| 350 | - register_admin_color_schemes(); |
|
| 351 | - } |
|
| 349 | + if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
| 350 | + register_admin_color_schemes(); |
|
| 351 | + } |
|
| 352 | 352 | |
| 353 | 353 | $hook_suffix = ''; |
| 354 | 354 | $admin_body_class = ''; |
| 355 | 355 | |
| 356 | - if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
| 357 | - $admin_body_class .= ' folded'; |
|
| 358 | - } |
|
| 356 | + if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
| 357 | + $admin_body_class .= ' folded'; |
|
| 358 | + } |
|
| 359 | 359 | |
| 360 | - if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
| 361 | - $admin_body_class .= ' admin-bar'; |
|
| 362 | - } |
|
| 360 | + if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
| 361 | + $admin_body_class .= ' admin-bar'; |
|
| 362 | + } |
|
| 363 | 363 | |
| 364 | - if ( is_rtl() ) { |
|
| 365 | - $admin_body_class .= ' rtl'; |
|
| 366 | - } |
|
| 364 | + if ( is_rtl() ) { |
|
| 365 | + $admin_body_class .= ' rtl'; |
|
| 366 | + } |
|
| 367 | 367 | |
| 368 | - $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
| 369 | - $prepop = array(); |
|
| 368 | + $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
| 369 | + $prepop = array(); |
|
| 370 | 370 | FrmFieldsHelper::get_bulk_prefilled_opts( $prepop ); |
| 371 | 371 | |
| 372 | 372 | $field = FrmField::getOne( $field_id ); |
| 373 | 373 | |
| 374 | - wp_enqueue_script( 'utils' ); |
|
| 374 | + wp_enqueue_script( 'utils' ); |
|
| 375 | 375 | wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' ); |
| 376 | - FrmAppHelper::load_admin_wide_js(); |
|
| 376 | + FrmAppHelper::load_admin_wide_js(); |
|
| 377 | 377 | |
| 378 | 378 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' ); |
| 379 | - wp_die(); |
|
| 380 | - } |
|
| 379 | + wp_die(); |
|
| 380 | + } |
|
| 381 | 381 | |
| 382 | 382 | public static function import_options() { |
| 383 | 383 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
@@ -391,8 +391,8 @@ discard block |
||
| 391 | 391 | $field = FrmField::getOne( $field_id ); |
| 392 | 392 | |
| 393 | 393 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
| 394 | - return; |
|
| 395 | - } |
|
| 394 | + return; |
|
| 395 | + } |
|
| 396 | 396 | |
| 397 | 397 | $field = FrmFieldsHelper::setup_edit_vars( $field ); |
| 398 | 398 | $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' ); |
@@ -415,10 +415,10 @@ discard block |
||
| 415 | 415 | } |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | - //Keep other options after bulk update |
|
| 419 | - if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
| 420 | - $other_array = array(); |
|
| 421 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 418 | + //Keep other options after bulk update |
|
| 419 | + if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
| 420 | + $other_array = array(); |
|
| 421 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 422 | 422 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
| 423 | 423 | $other_array[ $opt_key ] = $opt; |
| 424 | 424 | } |
@@ -429,36 +429,36 @@ discard block |
||
| 429 | 429 | } |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | - $field['options'] = $opts; |
|
| 432 | + $field['options'] = $opts; |
|
| 433 | 433 | |
| 434 | 434 | FrmFieldsHelper::show_single_option( $field ); |
| 435 | 435 | |
| 436 | - wp_die(); |
|
| 437 | - } |
|
| 436 | + wp_die(); |
|
| 437 | + } |
|
| 438 | 438 | |
| 439 | - public static function update_order() { |
|
| 439 | + public static function update_order() { |
|
| 440 | 440 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 441 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 441 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 442 | 442 | |
| 443 | 443 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
| 444 | 444 | foreach ( (array) $fields as $position => $item ) { |
| 445 | 445 | FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) ); |
| 446 | 446 | } |
| 447 | - wp_die(); |
|
| 448 | - } |
|
| 447 | + wp_die(); |
|
| 448 | + } |
|
| 449 | 449 | |
| 450 | 450 | public static function change_type( $type ) { |
| 451 | - $type_switch = array( |
|
| 452 | - 'scale' => 'radio', |
|
| 451 | + $type_switch = array( |
|
| 452 | + 'scale' => 'radio', |
|
| 453 | 453 | 'star' => 'radio', |
| 454 | - '10radio' => 'radio', |
|
| 455 | - 'rte' => 'textarea', |
|
| 456 | - 'website' => 'url', |
|
| 454 | + '10radio' => 'radio', |
|
| 455 | + 'rte' => 'textarea', |
|
| 456 | + 'website' => 'url', |
|
| 457 | 457 | 'image' => 'url', |
| 458 | - ); |
|
| 459 | - if ( isset( $type_switch[ $type ] ) ) { |
|
| 460 | - $type = $type_switch[ $type ]; |
|
| 461 | - } |
|
| 458 | + ); |
|
| 459 | + if ( isset( $type_switch[ $type ] ) ) { |
|
| 460 | + $type = $type_switch[ $type ]; |
|
| 461 | + } |
|
| 462 | 462 | |
| 463 | 463 | $pro_fields = FrmField::pro_field_selection(); |
| 464 | 464 | $types = array_keys( $pro_fields ); |
@@ -466,8 +466,8 @@ discard block |
||
| 466 | 466 | $type = 'text'; |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | - return $type; |
|
| 470 | - } |
|
| 469 | + return $type; |
|
| 470 | + } |
|
| 471 | 471 | |
| 472 | 472 | /** |
| 473 | 473 | * @param array $settings |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | return apply_filters( 'frm_display_field_options', $settings ); |
| 485 | - } |
|
| 485 | + } |
|
| 486 | 486 | |
| 487 | 487 | /** |
| 488 | 488 | * Display the format option |
@@ -494,8 +494,8 @@ discard block |
||
| 494 | 494 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/value-format.php' ); |
| 495 | 495 | } |
| 496 | 496 | |
| 497 | - public static function input_html( $field, $echo = true ) { |
|
| 498 | - $class = array(); //$field['type']; |
|
| 497 | + public static function input_html( $field, $echo = true ) { |
|
| 498 | + $class = array(); //$field['type']; |
|
| 499 | 499 | self::add_input_classes( $field, $class ); |
| 500 | 500 | |
| 501 | 501 | $add_html = array(); |
@@ -514,85 +514,85 @@ discard block |
||
| 514 | 514 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
| 515 | 515 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
| 516 | 516 | |
| 517 | - if ( $echo ) { |
|
| 518 | - echo $add_html; // WPCS: XSS ok. |
|
| 519 | - } |
|
| 517 | + if ( $echo ) { |
|
| 518 | + echo $add_html; // WPCS: XSS ok. |
|
| 519 | + } |
|
| 520 | 520 | |
| 521 | - return $add_html; |
|
| 522 | - } |
|
| 521 | + return $add_html; |
|
| 522 | + } |
|
| 523 | 523 | |
| 524 | 524 | private static function add_input_classes( $field, array &$class ) { |
| 525 | 525 | if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) { |
| 526 | 526 | $class[] = $field['input_class']; |
| 527 | 527 | } |
| 528 | 528 | |
| 529 | - if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
| 530 | - return; |
|
| 531 | - } |
|
| 529 | + if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
| 530 | + return; |
|
| 531 | + } |
|
| 532 | 532 | |
| 533 | 533 | if ( isset( $field['size'] ) && $field['size'] > 0 ) { |
| 534 | 534 | $class[] = 'auto_width'; |
| 535 | 535 | } |
| 536 | - } |
|
| 536 | + } |
|
| 537 | 537 | |
| 538 | 538 | private static function add_html_size( $field, array &$add_html ) { |
| 539 | 539 | if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden', 'file', 'lookup' ) ) ) { |
| 540 | - return; |
|
| 541 | - } |
|
| 540 | + return; |
|
| 541 | + } |
|
| 542 | 542 | |
| 543 | 543 | if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
| 544 | - return; |
|
| 545 | - } |
|
| 544 | + return; |
|
| 545 | + } |
|
| 546 | 546 | |
| 547 | 547 | if ( is_numeric( $field['size'] ) ) { |
| 548 | 548 | $field['size'] .= 'px'; |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | $important = apply_filters( 'frm_use_important_width', 1, $field ); |
| 552 | - // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
| 552 | + // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
| 553 | 553 | $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"'; |
| 554 | 554 | |
| 555 | 555 | self::add_html_cols( $field, $add_html ); |
| 556 | - } |
|
| 556 | + } |
|
| 557 | 557 | |
| 558 | 558 | private static function add_html_cols( $field, array &$add_html ) { |
| 559 | 559 | if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) { |
| 560 | - return; |
|
| 561 | - } |
|
| 560 | + return; |
|
| 561 | + } |
|
| 562 | 562 | |
| 563 | - // convert to cols for textareas |
|
| 564 | - $calc = array( |
|
| 565 | - '' => 9, |
|
| 566 | - 'px' => 9, |
|
| 567 | - 'rem' => 0.444, |
|
| 568 | - 'em' => 0.544, |
|
| 569 | - ); |
|
| 563 | + // convert to cols for textareas |
|
| 564 | + $calc = array( |
|
| 565 | + '' => 9, |
|
| 566 | + 'px' => 9, |
|
| 567 | + 'rem' => 0.444, |
|
| 568 | + 'em' => 0.544, |
|
| 569 | + ); |
|
| 570 | 570 | |
| 571 | 571 | // include "col" for valid html |
| 572 | 572 | $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) ); |
| 573 | 573 | |
| 574 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
| 575 | - return; |
|
| 576 | - } |
|
| 574 | + if ( ! isset( $calc[ $unit ] ) ) { |
|
| 575 | + return; |
|
| 576 | + } |
|
| 577 | 577 | |
| 578 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 578 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 579 | 579 | |
| 580 | 580 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
| 581 | - } |
|
| 581 | + } |
|
| 582 | 582 | |
| 583 | 583 | private static function add_html_length( $field, array &$add_html ) { |
| 584 | - // check for max setting and if this field accepts maxlength |
|
| 584 | + // check for max setting and if this field accepts maxlength |
|
| 585 | 585 | if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden', 'file' ) ) ) { |
| 586 | - return; |
|
| 587 | - } |
|
| 586 | + return; |
|
| 587 | + } |
|
| 588 | 588 | |
| 589 | 589 | if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
| 590 | - // don't load on form builder page |
|
| 591 | - return; |
|
| 592 | - } |
|
| 590 | + // don't load on form builder page |
|
| 591 | + return; |
|
| 592 | + } |
|
| 593 | 593 | |
| 594 | 594 | $add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"'; |
| 595 | - } |
|
| 595 | + } |
|
| 596 | 596 | |
| 597 | 597 | private static function add_html_placeholder( $field, array &$add_html, array &$class ) { |
| 598 | 598 | if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
@@ -701,27 +701,27 @@ discard block |
||
| 701 | 701 | } |
| 702 | 702 | } |
| 703 | 703 | |
| 704 | - private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
| 705 | - if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
| 706 | - return; |
|
| 707 | - } |
|
| 704 | + private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
| 705 | + if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
| 706 | + return; |
|
| 707 | + } |
|
| 708 | 708 | |
| 709 | - foreach ( $field['shortcodes'] as $k => $v ) { |
|
| 710 | - if ( 'opt' === $k ) { |
|
| 711 | - continue; |
|
| 712 | - } |
|
| 709 | + foreach ( $field['shortcodes'] as $k => $v ) { |
|
| 710 | + if ( 'opt' === $k ) { |
|
| 711 | + continue; |
|
| 712 | + } |
|
| 713 | 713 | |
| 714 | 714 | if ( is_numeric( $k ) && strpos( $v, '=' ) ) { |
| 715 | - $add_html[] = $v; |
|
| 716 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 715 | + $add_html[] = $v; |
|
| 716 | + } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 717 | 717 | $add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] ); |
| 718 | - } else { |
|
| 718 | + } else { |
|
| 719 | 719 | $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
| 720 | - } |
|
| 720 | + } |
|
| 721 | 721 | |
| 722 | 722 | unset( $k, $v ); |
| 723 | - } |
|
| 724 | - } |
|
| 723 | + } |
|
| 724 | + } |
|
| 725 | 725 | |
| 726 | 726 | /** |
| 727 | 727 | * Add pattern attribute |
@@ -745,16 +745,16 @@ discard block |
||
| 745 | 745 | } |
| 746 | 746 | } |
| 747 | 747 | |
| 748 | - public static function check_value( $opt, $opt_key, $field ) { |
|
| 749 | - if ( is_array( $opt ) ) { |
|
| 750 | - if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
| 751 | - $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 752 | - } else { |
|
| 753 | - $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
| 754 | - } |
|
| 755 | - } |
|
| 756 | - return $opt; |
|
| 757 | - } |
|
| 748 | + public static function check_value( $opt, $opt_key, $field ) { |
|
| 749 | + if ( is_array( $opt ) ) { |
|
| 750 | + if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
| 751 | + $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 752 | + } else { |
|
| 753 | + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
| 754 | + } |
|
| 755 | + } |
|
| 756 | + return $opt; |
|
| 757 | + } |
|
| 758 | 758 | |
| 759 | 759 | public static function check_label( $opt ) { |
| 760 | 760 | if ( is_array( $opt ) ) { |
@@ -1,23 +1,23 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmStylesController { |
| 4 | - public static $post_type = 'frm_styles'; |
|
| 5 | - public static $screen = 'formidable_page_formidable-styles'; |
|
| 4 | + public static $post_type = 'frm_styles'; |
|
| 5 | + public static $screen = 'formidable_page_formidable-styles'; |
|
| 6 | 6 | |
| 7 | - public static function load_pro_hooks() { |
|
| 8 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 9 | - FrmProStylesController::load_pro_hooks(); |
|
| 10 | - } |
|
| 11 | - } |
|
| 7 | + public static function load_pro_hooks() { |
|
| 8 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 9 | + FrmProStylesController::load_pro_hooks(); |
|
| 10 | + } |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - public static function register_post_types() { |
|
| 13 | + public static function register_post_types() { |
|
| 14 | 14 | register_post_type( |
| 15 | 15 | self::$post_type, |
| 16 | 16 | array( |
| 17 | - 'label' => __( 'Styles', 'formidable' ), |
|
| 18 | - 'public' => false, |
|
| 19 | - 'show_ui' => false, |
|
| 20 | - 'capability_type' => 'page', |
|
| 17 | + 'label' => __( 'Styles', 'formidable' ), |
|
| 18 | + 'public' => false, |
|
| 19 | + 'show_ui' => false, |
|
| 20 | + 'capability_type' => 'page', |
|
| 21 | 21 | 'capabilities' => array( |
| 22 | 22 | 'edit_post' => 'frm_change_settings', |
| 23 | 23 | 'edit_posts' => 'frm_change_settings', |
@@ -27,11 +27,11 @@ discard block |
||
| 27 | 27 | 'delete_posts' => 'frm_change_settings', |
| 28 | 28 | 'read_private_posts' => 'read_private_posts', |
| 29 | 29 | ), |
| 30 | - 'supports' => array( |
|
| 30 | + 'supports' => array( |
|
| 31 | 31 | 'title', |
| 32 | - ), |
|
| 33 | - 'has_archive' => false, |
|
| 34 | - 'labels' => array( |
|
| 32 | + ), |
|
| 33 | + 'has_archive' => false, |
|
| 34 | + 'labels' => array( |
|
| 35 | 35 | 'name' => __( 'Styles', 'formidable' ), |
| 36 | 36 | 'singular_name' => __( 'Style', 'formidable' ), |
| 37 | 37 | 'menu_name' => __( 'Style', 'formidable' ), |
@@ -41,18 +41,18 @@ discard block |
||
| 41 | 41 | ), |
| 42 | 42 | ) |
| 43 | 43 | ); |
| 44 | - } |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - public static function menu() { |
|
| 46 | + public static function menu() { |
|
| 47 | 47 | add_submenu_page( 'formidable', 'Formidable | ' . __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route' ); |
| 48 | - } |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | public static function admin_init() { |
| 51 | 51 | if ( ! FrmAppHelper::is_admin_page( 'formidable-styles' ) ) { |
| 52 | 52 | return; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - self::load_pro_hooks(); |
|
| 55 | + self::load_pro_hooks(); |
|
| 56 | 56 | |
| 57 | 57 | $style_tab = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
| 58 | 58 | if ( $style_tab == 'manage' || $style_tab == 'custom_css' ) { |
@@ -65,10 +65,10 @@ discard block |
||
| 65 | 65 | wp_enqueue_style( 'frm-custom-theme', admin_url( 'admin-ajax.php?action=frmpro_css' ) ); |
| 66 | 66 | |
| 67 | 67 | $style = apply_filters( 'frm_style_head', false ); |
| 68 | - if ( $style ) { |
|
| 68 | + if ( $style ) { |
|
| 69 | 69 | wp_enqueue_style( 'frm-single-custom-theme', admin_url( 'admin-ajax.php?action=frmpro_load_css&flat=1' ) . '&' . http_build_query( $style->post_content ) ); |
| 70 | - } |
|
| 71 | - } |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | 73 | public static function enqueue_css( $register = 'enqueue' ) { |
| 74 | 74 | global $frm_vars; |
@@ -217,10 +217,10 @@ discard block |
||
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | public static function load_styler( $style, $message = '' ) { |
| 220 | - global $frm_settings; |
|
| 220 | + global $frm_settings; |
|
| 221 | 221 | |
| 222 | - $frm_style = new FrmStyle(); |
|
| 223 | - $styles = $frm_style->get_all(); |
|
| 222 | + $frm_style = new FrmStyle(); |
|
| 223 | + $styles = $frm_style->get_all(); |
|
| 224 | 224 | |
| 225 | 225 | if ( is_numeric( $style ) ) { |
| 226 | 226 | $style = $styles[ $style ]; |
@@ -228,10 +228,10 @@ discard block |
||
| 228 | 228 | $style = $frm_style->get_default_style( $styles ); |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - self::add_meta_boxes(); |
|
| 231 | + self::add_meta_boxes(); |
|
| 232 | 232 | |
| 233 | 233 | include( FrmAppHelper::plugin_path() . '/classes/views/styles/show.php' ); |
| 234 | - } |
|
| 234 | + } |
|
| 235 | 235 | |
| 236 | 236 | /** |
| 237 | 237 | * @param string $message |
@@ -249,31 +249,31 @@ discard block |
||
| 249 | 249 | include( FrmAppHelper::plugin_path() . '/classes/views/styles/manage.php' ); |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - private static function manage_styles() { |
|
| 252 | + private static function manage_styles() { |
|
| 253 | 253 | $style_nonce = FrmAppHelper::get_post_param( 'frm_manage_style', '', 'sanitize_text_field' ); |
| 254 | 254 | if ( ! $_POST || ! isset( $_POST['style'] ) || ! wp_verify_nonce( $style_nonce, 'frm_manage_style_nonce' ) ) { |
| 255 | - return self::manage(); |
|
| 256 | - } |
|
| 255 | + return self::manage(); |
|
| 256 | + } |
|
| 257 | 257 | |
| 258 | - global $wpdb; |
|
| 258 | + global $wpdb; |
|
| 259 | 259 | |
| 260 | 260 | $forms = FrmForm::get_published_forms(); |
| 261 | - foreach ( $forms as $form ) { |
|
| 262 | - if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
| 263 | - continue; |
|
| 264 | - } |
|
| 261 | + foreach ( $forms as $form ) { |
|
| 262 | + if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
| 263 | + continue; |
|
| 264 | + } |
|
| 265 | 265 | |
| 266 | - $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
| 266 | + $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
| 267 | 267 | |
| 268 | 268 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 269 | 269 | unset( $form ); |
| 270 | - } |
|
| 270 | + } |
|
| 271 | 271 | |
| 272 | - $message = __( 'Your form styles have been saved.', 'formidable' ); |
|
| 272 | + $message = __( 'Your form styles have been saved.', 'formidable' ); |
|
| 273 | 273 | return self::manage( $message, $forms ); |
| 274 | - } |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - public static function custom_css( $message = '', $style = null ) { |
|
| 276 | + public static function custom_css( $message = '', $style = null ) { |
|
| 277 | 277 | if ( function_exists( 'wp_enqueue_code_editor' ) ) { |
| 278 | 278 | $id = 'frm_codemirror_box'; |
| 279 | 279 | $settings = wp_enqueue_code_editor( |
@@ -315,41 +315,41 @@ discard block |
||
| 315 | 315 | return self::custom_css( $message ); |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - public static function route() { |
|
| 318 | + public static function route() { |
|
| 319 | 319 | $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
| 320 | 320 | |
| 321 | - switch ( $action ) { |
|
| 322 | - case 'edit': |
|
| 323 | - case 'save': |
|
| 324 | - case 'manage': |
|
| 325 | - case 'manage_styles': |
|
| 326 | - case 'custom_css': |
|
| 327 | - case 'save_css': |
|
| 321 | + switch ( $action ) { |
|
| 322 | + case 'edit': |
|
| 323 | + case 'save': |
|
| 324 | + case 'manage': |
|
| 325 | + case 'manage_styles': |
|
| 326 | + case 'custom_css': |
|
| 327 | + case 'save_css': |
|
| 328 | 328 | return self::$action(); |
| 329 | - default: |
|
| 330 | - do_action( 'frm_style_action_route', $action ); |
|
| 331 | - if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) { |
|
| 332 | - return; |
|
| 333 | - } |
|
| 329 | + default: |
|
| 330 | + do_action( 'frm_style_action_route', $action ); |
|
| 331 | + if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) { |
|
| 332 | + return; |
|
| 333 | + } |
|
| 334 | 334 | |
| 335 | - if ( 'new_style' == $action || 'duplicate' == $action ) { |
|
| 336 | - return self::$action(); |
|
| 337 | - } |
|
| 335 | + if ( 'new_style' == $action || 'duplicate' == $action ) { |
|
| 336 | + return self::$action(); |
|
| 337 | + } |
|
| 338 | 338 | |
| 339 | - return self::edit(); |
|
| 340 | - } |
|
| 341 | - } |
|
| 339 | + return self::edit(); |
|
| 340 | + } |
|
| 341 | + } |
|
| 342 | 342 | |
| 343 | - public static function reset_styling() { |
|
| 343 | + public static function reset_styling() { |
|
| 344 | 344 | FrmAppHelper::permission_check( 'frm_change_settings' ); |
| 345 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 345 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 346 | 346 | |
| 347 | - $frm_style = new FrmStyle(); |
|
| 348 | - $defaults = $frm_style->get_defaults(); |
|
| 347 | + $frm_style = new FrmStyle(); |
|
| 348 | + $defaults = $frm_style->get_defaults(); |
|
| 349 | 349 | |
| 350 | - echo json_encode( $defaults ); |
|
| 351 | - wp_die(); |
|
| 352 | - } |
|
| 350 | + echo json_encode( $defaults ); |
|
| 351 | + wp_die(); |
|
| 352 | + } |
|
| 353 | 353 | |
| 354 | 354 | public static function change_styling() { |
| 355 | 355 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
@@ -364,21 +364,21 @@ discard block |
||
| 364 | 364 | wp_die(); |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | - private static function add_meta_boxes() { |
|
| 368 | - |
|
| 369 | - // setup meta boxes |
|
| 370 | - $meta_boxes = array( |
|
| 371 | - 'general' => __( 'General', 'formidable' ), |
|
| 372 | - 'form-title' => __( 'Form Title', 'formidable' ), |
|
| 373 | - 'form-description' => __( 'Form Description', 'formidable' ), |
|
| 374 | - 'field-labels' => __( 'Field Labels', 'formidable' ), |
|
| 375 | - 'field-description' => __( 'Field Description', 'formidable' ), |
|
| 376 | - 'field-colors' => __( 'Field Colors', 'formidable' ), |
|
| 377 | - 'field-sizes' => __( 'Field Settings', 'formidable' ), |
|
| 378 | - 'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ), |
|
| 379 | - 'buttons' => __( 'Buttons', 'formidable' ), |
|
| 380 | - 'form-messages' => __( 'Form Messages', 'formidable' ), |
|
| 381 | - ); |
|
| 367 | + private static function add_meta_boxes() { |
|
| 368 | + |
|
| 369 | + // setup meta boxes |
|
| 370 | + $meta_boxes = array( |
|
| 371 | + 'general' => __( 'General', 'formidable' ), |
|
| 372 | + 'form-title' => __( 'Form Title', 'formidable' ), |
|
| 373 | + 'form-description' => __( 'Form Description', 'formidable' ), |
|
| 374 | + 'field-labels' => __( 'Field Labels', 'formidable' ), |
|
| 375 | + 'field-description' => __( 'Field Description', 'formidable' ), |
|
| 376 | + 'field-colors' => __( 'Field Colors', 'formidable' ), |
|
| 377 | + 'field-sizes' => __( 'Field Settings', 'formidable' ), |
|
| 378 | + 'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ), |
|
| 379 | + 'buttons' => __( 'Buttons', 'formidable' ), |
|
| 380 | + 'form-messages' => __( 'Form Messages', 'formidable' ), |
|
| 381 | + ); |
|
| 382 | 382 | |
| 383 | 383 | /** |
| 384 | 384 | * Add custom boxes to the styling settings |
@@ -410,18 +410,18 @@ discard block |
||
| 410 | 410 | $file_name = apply_filters( 'frm_style_settings_' . $sec['args'], $file_name ); |
| 411 | 411 | |
| 412 | 412 | include( $file_name ); |
| 413 | - } |
|
| 413 | + } |
|
| 414 | 414 | |
| 415 | - public static function load_css() { |
|
| 415 | + public static function load_css() { |
|
| 416 | 416 | header( 'Content-type: text/css' ); |
| 417 | 417 | |
| 418 | - $frm_style = new FrmStyle(); |
|
| 419 | - $defaults = $frm_style->get_defaults(); |
|
| 418 | + $frm_style = new FrmStyle(); |
|
| 419 | + $defaults = $frm_style->get_defaults(); |
|
| 420 | 420 | $style = ''; |
| 421 | 421 | |
| 422 | 422 | include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' ); |
| 423 | - wp_die(); |
|
| 424 | - } |
|
| 423 | + wp_die(); |
|
| 424 | + } |
|
| 425 | 425 | |
| 426 | 426 | public static function load_saved_css() { |
| 427 | 427 | $css = get_transient( 'frmpro_css' ); |
@@ -430,49 +430,49 @@ discard block |
||
| 430 | 430 | wp_die(); |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | - /** |
|
| 434 | - * Check if the Formidable styling should be loaded, |
|
| 435 | - * then enqueue it for the footer |
|
| 436 | - * @since 2.0 |
|
| 437 | - */ |
|
| 438 | - public static function enqueue_style() { |
|
| 439 | - global $frm_vars; |
|
| 440 | - |
|
| 441 | - if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) { |
|
| 442 | - // the CSS has already been loaded |
|
| 443 | - return; |
|
| 444 | - } |
|
| 445 | - |
|
| 446 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 447 | - if ( $frm_settings->load_style != 'none' ) { |
|
| 448 | - wp_enqueue_style( 'formidable' ); |
|
| 449 | - $frm_vars['css_loaded'] = true; |
|
| 450 | - } |
|
| 451 | - } |
|
| 452 | - |
|
| 453 | - // Get the stylesheets for the form settings page |
|
| 454 | - public static function get_style_opts() { |
|
| 455 | - $frm_style = new FrmStyle(); |
|
| 456 | - $styles = $frm_style->get_all(); |
|
| 457 | - |
|
| 458 | - return $styles; |
|
| 459 | - } |
|
| 460 | - |
|
| 461 | - public static function get_form_style( $form = 'default' ) { |
|
| 462 | - $style = FrmFormsHelper::get_form_style( $form ); |
|
| 463 | - |
|
| 464 | - if ( empty( $style ) || 1 == $style ) { |
|
| 465 | - $style = 'default'; |
|
| 466 | - } |
|
| 467 | - |
|
| 468 | - $frm_style = new FrmStyle( $style ); |
|
| 469 | - return $frm_style->get_one(); |
|
| 470 | - } |
|
| 471 | - |
|
| 472 | - /** |
|
| 473 | - * @param string $class |
|
| 474 | - * @param string $style |
|
| 475 | - */ |
|
| 433 | + /** |
|
| 434 | + * Check if the Formidable styling should be loaded, |
|
| 435 | + * then enqueue it for the footer |
|
| 436 | + * @since 2.0 |
|
| 437 | + */ |
|
| 438 | + public static function enqueue_style() { |
|
| 439 | + global $frm_vars; |
|
| 440 | + |
|
| 441 | + if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) { |
|
| 442 | + // the CSS has already been loaded |
|
| 443 | + return; |
|
| 444 | + } |
|
| 445 | + |
|
| 446 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 447 | + if ( $frm_settings->load_style != 'none' ) { |
|
| 448 | + wp_enqueue_style( 'formidable' ); |
|
| 449 | + $frm_vars['css_loaded'] = true; |
|
| 450 | + } |
|
| 451 | + } |
|
| 452 | + |
|
| 453 | + // Get the stylesheets for the form settings page |
|
| 454 | + public static function get_style_opts() { |
|
| 455 | + $frm_style = new FrmStyle(); |
|
| 456 | + $styles = $frm_style->get_all(); |
|
| 457 | + |
|
| 458 | + return $styles; |
|
| 459 | + } |
|
| 460 | + |
|
| 461 | + public static function get_form_style( $form = 'default' ) { |
|
| 462 | + $style = FrmFormsHelper::get_form_style( $form ); |
|
| 463 | + |
|
| 464 | + if ( empty( $style ) || 1 == $style ) { |
|
| 465 | + $style = 'default'; |
|
| 466 | + } |
|
| 467 | + |
|
| 468 | + $frm_style = new FrmStyle( $style ); |
|
| 469 | + return $frm_style->get_one(); |
|
| 470 | + } |
|
| 471 | + |
|
| 472 | + /** |
|
| 473 | + * @param string $class |
|
| 474 | + * @param string $style |
|
| 475 | + */ |
|
| 476 | 476 | public static function get_form_style_class( $class, $style ) { |
| 477 | 477 | if ( 1 == $style ) { |
| 478 | 478 | $style = 'default'; |
@@ -502,9 +502,9 @@ discard block |
||
| 502 | 502 | } |
| 503 | 503 | } |
| 504 | 504 | |
| 505 | - /** |
|
| 506 | - * @param string $val |
|
| 507 | - */ |
|
| 505 | + /** |
|
| 506 | + * @param string $val |
|
| 507 | + */ |
|
| 508 | 508 | public static function get_style_val( $val, $form = 'default' ) { |
| 509 | 509 | $style = self::get_form_style( $form ); |
| 510 | 510 | if ( $style && isset( $style->post_content[ $val ] ) ) { |
@@ -514,72 +514,72 @@ discard block |
||
| 514 | 514 | |
| 515 | 515 | public static function show_entry_styles( $default_styles ) { |
| 516 | 516 | $frm_style = new FrmStyle( 'default' ); |
| 517 | - $style = $frm_style->get_one(); |
|
| 518 | - |
|
| 519 | - if ( ! $style ) { |
|
| 520 | - return $default_styles; |
|
| 521 | - } |
|
| 522 | - |
|
| 523 | - foreach ( $default_styles as $name => $val ) { |
|
| 524 | - $setting = $name; |
|
| 525 | - if ( 'border_width' == $name ) { |
|
| 526 | - $setting = 'field_border_width'; |
|
| 527 | - } else if ( 'alt_bg_color' == $name ) { |
|
| 528 | - $setting = 'bg_color_active'; |
|
| 529 | - } |
|
| 530 | - $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
| 517 | + $style = $frm_style->get_one(); |
|
| 518 | + |
|
| 519 | + if ( ! $style ) { |
|
| 520 | + return $default_styles; |
|
| 521 | + } |
|
| 522 | + |
|
| 523 | + foreach ( $default_styles as $name => $val ) { |
|
| 524 | + $setting = $name; |
|
| 525 | + if ( 'border_width' == $name ) { |
|
| 526 | + $setting = 'field_border_width'; |
|
| 527 | + } else if ( 'alt_bg_color' == $name ) { |
|
| 528 | + $setting = 'bg_color_active'; |
|
| 529 | + } |
|
| 530 | + $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
| 531 | 531 | unset( $name, $val ); |
| 532 | - } |
|
| 532 | + } |
|
| 533 | 533 | |
| 534 | - return $default_styles; |
|
| 535 | - } |
|
| 534 | + return $default_styles; |
|
| 535 | + } |
|
| 536 | 536 | |
| 537 | 537 | public static function &important_style( $important, $field ) { |
| 538 | 538 | $important = self::get_style_val( 'important_style', $field['form_id'] ); |
| 539 | - return $important; |
|
| 540 | - } |
|
| 539 | + return $important; |
|
| 540 | + } |
|
| 541 | 541 | |
| 542 | - /** |
|
| 543 | - * Fallback for WP < 3.6 |
|
| 544 | - */ |
|
| 545 | - public static function do_accordion_sections( $screen, $context, $object ) { |
|
| 546 | - if ( function_exists( 'do_accordion_sections' ) ) { |
|
| 547 | - return do_accordion_sections( $screen, $context, $object ); |
|
| 548 | - } |
|
| 542 | + /** |
|
| 543 | + * Fallback for WP < 3.6 |
|
| 544 | + */ |
|
| 545 | + public static function do_accordion_sections( $screen, $context, $object ) { |
|
| 546 | + if ( function_exists( 'do_accordion_sections' ) ) { |
|
| 547 | + return do_accordion_sections( $screen, $context, $object ); |
|
| 548 | + } |
|
| 549 | 549 | |
| 550 | - global $wp_meta_boxes; |
|
| 550 | + global $wp_meta_boxes; |
|
| 551 | 551 | |
| 552 | - $screen = 'formidable_page_formidable-styles'; |
|
| 553 | - $screen = convert_to_screen( $screen ); |
|
| 552 | + $screen = 'formidable_page_formidable-styles'; |
|
| 553 | + $screen = convert_to_screen( $screen ); |
|
| 554 | 554 | |
| 555 | - $page = $screen->id; |
|
| 555 | + $page = $screen->id; |
|
| 556 | 556 | |
| 557 | - $hidden = get_hidden_meta_boxes( $screen ); |
|
| 558 | - ?> |
|
| 557 | + $hidden = get_hidden_meta_boxes( $screen ); |
|
| 558 | + ?> |
|
| 559 | 559 | <div id="side-sortables" class="accordion-container"> |
| 560 | 560 | <?php |
| 561 | - $i = 0; |
|
| 562 | - $first_open = false; |
|
| 563 | - do { |
|
| 561 | + $i = 0; |
|
| 562 | + $first_open = false; |
|
| 563 | + do { |
|
| 564 | 564 | if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[ $page ] ) || ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) { |
| 565 | 565 | break; |
| 566 | 566 | } |
| 567 | 567 | |
| 568 | - foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
|
| 569 | - if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
| 570 | - foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
| 571 | - if ( false == $box || ! $box['title'] ) { |
|
| 572 | - continue; |
|
| 568 | + foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
|
| 569 | + if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
| 570 | + foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
| 571 | + if ( false == $box || ! $box['title'] ) { |
|
| 572 | + continue; |
|
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - $i++; |
|
| 576 | - $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
|
| 575 | + $i++; |
|
| 576 | + $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
|
| 577 | 577 | |
| 578 | - if ( ! $first_open && empty( $hidden_class ) ) { |
|
| 579 | - $first_open = true; |
|
| 580 | - } |
|
| 578 | + if ( ! $first_open && empty( $hidden_class ) ) { |
|
| 579 | + $first_open = true; |
|
| 580 | + } |
|
| 581 | 581 | |
| 582 | - ?> |
|
| 582 | + ?> |
|
| 583 | 583 | <div class="postbox <?php echo esc_attr( $box['id'] ); ?>"> |
| 584 | 584 | <div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'formidable' ); ?>"><br/></div> |
| 585 | 585 | <h3 class='hndle'><span><?php echo esc_html( $box['title'] ); ?></span></h3> |
@@ -590,13 +590,13 @@ discard block |
||
| 590 | 590 | </div><!-- .accordion-section-content --> |
| 591 | 591 | </div><!-- .postbox --> |
| 592 | 592 | <?php |
| 593 | - } |
|
| 594 | - } |
|
| 595 | - } |
|
| 596 | - } while ( 0 ); |
|
| 597 | - ?> |
|
| 593 | + } |
|
| 594 | + } |
|
| 595 | + } |
|
| 596 | + } while ( 0 ); |
|
| 597 | + ?> |
|
| 598 | 598 | </div><!-- .accordion-container --> |
| 599 | 599 | <?php |
| 600 | - return $i; |
|
| 601 | - } |
|
| 600 | + return $i; |
|
| 601 | + } |
|
| 602 | 602 | } |