@@ -151,6 +151,7 @@ |
||
| 151 | 151 | |
| 152 | 152 | /** |
| 153 | 153 | * @deprecated 2.04 |
| 154 | + * @param string $val |
|
| 154 | 155 | */ |
| 155 | 156 | private static function get_field_value( $atts, &$val ) { |
| 156 | 157 | _deprecated_function( __FUNCTION__, '2.04', 'instance of FrmEntryValues or FrmProEntryValues' ); |
@@ -98,15 +98,15 @@ discard block |
||
| 98 | 98 | self::prepare_field_output( $atts, $val ); |
| 99 | 99 | |
| 100 | 100 | if ( $atts['format'] != 'text' ) { |
| 101 | - $values[ $f->field_key ] = $val; |
|
| 101 | + $values[$f->field_key] = $val; |
|
| 102 | 102 | if ( $atts['entry'] && $f->type != 'textarea' ) { |
| 103 | - $prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] ); |
|
| 103 | + $prev_val = maybe_unserialize( $atts['entry']->metas[$f->id] ); |
|
| 104 | 104 | if ( $prev_val != $val ) { |
| 105 | - $values[ $f->field_key . '-value' ] = $prev_val; |
|
| 105 | + $values[$f->field_key . '-value'] = $prev_val; |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | } else { |
| 109 | - $values[ $f->id ] = array( 'label' => $f->name, 'val' => $val, 'type' => $f->type ); |
|
| 109 | + $values[$f->id] = array( 'label' => $f->name, 'val' => $val, 'type' => $f->type ); |
|
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | |
@@ -116,9 +116,9 @@ discard block |
||
| 116 | 116 | private static function fill_missing_fields( $atts, &$values ) { |
| 117 | 117 | _deprecated_function( __FUNCTION__, '2.04', 'instance of FrmEntryValues or FrmProEntryValues' ); |
| 118 | 118 | |
| 119 | - if ( $atts['entry'] && ! isset( $atts['entry']->metas[ $atts['field']->id ] ) ) { |
|
| 119 | + if ( $atts['entry'] && ! isset( $atts['entry']->metas[$atts['field']->id] ) ) { |
|
| 120 | 120 | // In case include_blank is set |
| 121 | - $atts['entry']->metas[ $atts['field']->id ] = ''; |
|
| 121 | + $atts['entry']->metas[$atts['field']->id] = ''; |
|
| 122 | 122 | $atts['entry'] = apply_filters( 'frm_prepare_entry_content', $atts['entry'], array( 'field' => $atts['field'] ) ); |
| 123 | 123 | self::fill_values_from_entry( $atts, $values ); |
| 124 | 124 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | 'type' => $f->type, |
| 147 | 147 | ); |
| 148 | 148 | |
| 149 | - $values[ $f->id ] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $field_shortcodes, $f ); |
|
| 149 | + $values[$f->id] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $field_shortcodes, $f ); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | $f = $atts['field']; |
| 159 | 159 | if ( $atts['entry'] ) { |
| 160 | - $prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] ); |
|
| 160 | + $prev_val = maybe_unserialize( $atts['entry']->metas[$f->id] ); |
|
| 161 | 161 | $meta = array( 'item_id' => $atts['id'], 'field_id' => $f->id, 'meta_value' => $prev_val, 'field_type' => $f->type ); |
| 162 | 162 | |
| 163 | 163 | //This filter applies to the default-message shortcode and frm-show-entry shortcode only |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <div class="field-group field-group-background clearfix frm-first-row"> |
| 2 | 2 | <label><?php _e( 'Color', 'formidable' ) ?></label> |
| 3 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('label_color') ) ?>" id="frm_label_color" class="hex" value="<?php echo esc_attr( $style->post_content['label_color'] ) ?>" /> |
|
| 3 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'label_color' ) ) ?>" id="frm_label_color" class="hex" value="<?php echo esc_attr( $style->post_content['label_color'] ) ?>" /> |
|
| 4 | 4 | </div> |
| 5 | 5 | <div class="field-group clearfix frm-first-row"> |
| 6 | 6 | <label><?php _e( 'Weight', 'formidable' ) ?></label> |
| 7 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('weight') ) ?>" id="frm_weight"> |
|
| 7 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'weight' ) ) ?>" id="frm_weight"> |
|
| 8 | 8 | <?php foreach ( FrmStyle::get_bold_options() as $value => $name ) { ?> |
| 9 | 9 | <option value="<?php echo esc_attr( $value ) ?>" <?php selected( $style->post_content['weight'], $value ) ?>><?php echo esc_html( $name ) ?></option> |
| 10 | 10 | <?php } ?> |
@@ -12,45 +12,45 @@ discard block |
||
| 12 | 12 | </div> |
| 13 | 13 | <div class="field-group clearfix frm-first-row"> |
| 14 | 14 | <label><?php _e( 'Size', 'formidable' ) ?></label> |
| 15 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('font_size') ) ?>" id="frm_font_size" value="<?php echo esc_attr($style->post_content['font_size']) ?>" size="3" /> |
|
| 15 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'font_size' ) ) ?>" id="frm_font_size" value="<?php echo esc_attr( $style->post_content['font_size'] ) ?>" size="3" /> |
|
| 16 | 16 | </div> |
| 17 | 17 | |
| 18 | 18 | <div class="field-group clearfix frm_clear"> |
| 19 | 19 | <label><?php _e( 'Position', 'formidable' ) ?></label> |
| 20 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('position') ) ?>" id="frm_position"> |
|
| 20 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'position' ) ) ?>" id="frm_position"> |
|
| 21 | 21 | <?php foreach ( FrmStylesHelper::get_css_label_positions() as $pos => $pos_label ) { ?> |
| 22 | - <option value="<?php echo esc_attr( $pos ) ?>" <?php selected($style->post_content['position'], $pos) ?>><?php echo esc_html( $pos_label ) ?></option> |
|
| 22 | + <option value="<?php echo esc_attr( $pos ) ?>" <?php selected( $style->post_content['position'], $pos ) ?>><?php echo esc_html( $pos_label ) ?></option> |
|
| 23 | 23 | <?php } ?> |
| 24 | 24 | </select> |
| 25 | 25 | </div> |
| 26 | 26 | |
| 27 | 27 | <div class="field-group clearfix"> |
| 28 | 28 | <label><?php _e( 'Align', 'formidable' ) ?></label> |
| 29 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('align') ) ?>" id="frm_align"> |
|
| 30 | - <option value="left" <?php selected($style->post_content['align'], 'left') ?>><?php _e( 'left', 'formidable' ) ?></option> |
|
| 31 | - <option value="right" <?php selected($style->post_content['align'], 'right') ?>><?php _e( 'right', 'formidable' ) ?></option> |
|
| 29 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'align' ) ) ?>" id="frm_align"> |
|
| 30 | + <option value="left" <?php selected( $style->post_content['align'], 'left' ) ?>><?php _e( 'left', 'formidable' ) ?></option> |
|
| 31 | + <option value="right" <?php selected( $style->post_content['align'], 'right' ) ?>><?php _e( 'right', 'formidable' ) ?></option> |
|
| 32 | 32 | </select> |
| 33 | 33 | </div> |
| 34 | 34 | |
| 35 | 35 | <div class="field-group clearfix"> |
| 36 | 36 | <label><?php _e( 'Width', 'formidable' ) ?></label> |
| 37 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('width') ) ?>" id="frm_width" value="<?php echo esc_attr( $style->post_content['width'] ) ?>" /> |
|
| 37 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'width' ) ) ?>" id="frm_width" value="<?php echo esc_attr( $style->post_content['width'] ) ?>" /> |
|
| 38 | 38 | </div> |
| 39 | 39 | |
| 40 | 40 | <div class="field-group clearfix frm_clear"> |
| 41 | 41 | <label><?php _e( 'Padding', 'formidable' ) ?></label> |
| 42 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('label_padding') ) ?>" id="frm_label_padding" value="<?php echo esc_attr( $style->post_content['label_padding'] ) ?>" /> |
|
| 42 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'label_padding' ) ) ?>" id="frm_label_padding" value="<?php echo esc_attr( $style->post_content['label_padding'] ) ?>" /> |
|
| 43 | 43 | </div> |
| 44 | 44 | |
| 45 | 45 | <div class="clear"></div> |
| 46 | 46 | <h3><?php _e( 'Required Indicator', 'formidable' ) ?></h3> |
| 47 | 47 | <div class="field-group field-group-border clearfix after-h3"> |
| 48 | 48 | <label class="background"><?php _e( 'Color', 'formidable' ) ?></label> |
| 49 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('required_color') ) ?>" id="frm_required_color" class="hex" value="<?php echo esc_attr( $style->post_content['required_color'] ) ?>" /> |
|
| 49 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'required_color' ) ) ?>" id="frm_required_color" class="hex" value="<?php echo esc_attr( $style->post_content['required_color'] ) ?>" /> |
|
| 50 | 50 | </div> |
| 51 | 51 | <div class="field-group clearfix after-h3"> |
| 52 | 52 | <label><?php _e( 'Weight', 'formidable' ) ?></label> |
| 53 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('required_weight') ) ?>" id="frm_required_weight"> |
|
| 53 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'required_weight' ) ) ?>" id="frm_required_weight"> |
|
| 54 | 54 | <?php foreach ( FrmStyle::get_bold_options() as $value => $name ) { ?> |
| 55 | 55 | <option value="<?php echo esc_attr( $value ) ?>" <?php selected( $style->post_content['required_weight'], $value ) ?>><?php echo esc_html( $name ) ?></option> |
| 56 | 56 | <?php } ?> |
@@ -83,12 +83,12 @@ discard block |
||
| 83 | 83 | ) ); |
| 84 | 84 | |
| 85 | 85 | foreach ( $this->style_settings as $key => $setting ) { |
| 86 | - if ( isset( $atts[ $key ] ) && $atts[ $key ] !== '' ) { |
|
| 87 | - $this->style_settings[ $key ] = $atts[ $key ]; |
|
| 86 | + if ( isset( $atts[$key] ) && $atts[$key] !== '' ) { |
|
| 87 | + $this->style_settings[$key] = $atts[$key]; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | if ( $this->is_color_setting( $key ) ) { |
| 91 | - $this->style_settings[ $key ] = $this->get_color_markup( $this->style_settings[ $key ] ); |
|
| 91 | + $this->style_settings[$key] = $this->get_color_markup( $this->style_settings[$key] ); |
|
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | } |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * |
| 159 | 159 | * @return boolean |
| 160 | 160 | */ |
| 161 | - private function is_color_setting ( $setting_key ) { |
|
| 161 | + private function is_color_setting( $setting_key ) { |
|
| 162 | 162 | return strpos( $setting_key, 'color' ) !== false; |
| 163 | 163 | } |
| 164 | 164 | |
@@ -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 | $default_orderby = 'id'; |
| 15 | 15 | $default_order = 'DESC'; |
@@ -25,27 +25,27 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : ''; |
| 27 | 27 | |
| 28 | - if ( $s != '' && FrmAppHelper::pro_is_installed() ) { |
|
| 29 | - $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : ''; |
|
| 30 | - $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid ); |
|
| 31 | - } |
|
| 28 | + if ( $s != '' && FrmAppHelper::pro_is_installed() ) { |
|
| 29 | + $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : ''; |
|
| 30 | + $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid ); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | 33 | $s_query = apply_filters( 'frm_entries_list_query', $s_query, compact( 'form_id' ) ); |
| 34 | 34 | |
| 35 | - $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby; |
|
| 36 | - if ( strpos($orderby, 'meta') !== false ) { |
|
| 37 | - $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) ); |
|
| 35 | + $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby; |
|
| 36 | + if ( strpos($orderby, 'meta') !== false ) { |
|
| 37 | + $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) ); |
|
| 38 | 38 | $orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : ''; |
| 39 | - } |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | 41 | $order = isset( $_REQUEST['order'] ) ? sanitize_title( $_REQUEST['order'] ) : $default_order; |
| 42 | 42 | $order = ' ORDER BY ' . $orderby . ' ' . $order; |
| 43 | 43 | |
| 44 | - $page = $this->get_pagenum(); |
|
| 44 | + $page = $this->get_pagenum(); |
|
| 45 | 45 | $start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page ); |
| 46 | 46 | |
| 47 | 47 | $this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, $join_form_in_query ); |
| 48 | - $total_items = FrmEntry::getRecordCount($s_query); |
|
| 48 | + $total_items = FrmEntry::getRecordCount($s_query); |
|
| 49 | 49 | |
| 50 | 50 | $this->set_pagination_args( array( |
| 51 | 51 | 'total_items' => $total_items, |
@@ -54,19 +54,19 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | public function no_items() { |
| 57 | - $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; |
|
| 58 | - if ( ! empty($s) ) { |
|
| 59 | - _e( 'No Entries Found', 'formidable' ); |
|
| 60 | - return; |
|
| 61 | - } |
|
| 57 | + $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; |
|
| 58 | + if ( ! empty($s) ) { |
|
| 59 | + _e( 'No Entries Found', 'formidable' ); |
|
| 60 | + return; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | 63 | $form_id = $this->params['form']; |
| 64 | 64 | $form = $this->params['form']; |
| 65 | 65 | |
| 66 | - if ( $form_id ) { |
|
| 67 | - $form = FrmForm::getOne($form_id); |
|
| 68 | - } |
|
| 69 | - $colspan = $this->get_column_count(); |
|
| 66 | + if ( $form_id ) { |
|
| 67 | + $form = FrmForm::getOne($form_id); |
|
| 68 | + } |
|
| 69 | + $colspan = $this->get_column_count(); |
|
| 70 | 70 | |
| 71 | 71 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php' ); |
| 72 | 72 | } |
@@ -86,12 +86,12 @@ discard block |
||
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | - * Gets the name of the primary column in the Entries screen |
|
| 90 | - * |
|
| 91 | - * @since 2.0.14 |
|
| 92 | - * |
|
| 93 | - * @return string $primary_column |
|
| 94 | - */ |
|
| 89 | + * Gets the name of the primary column in the Entries screen |
|
| 90 | + * |
|
| 91 | + * @since 2.0.14 |
|
| 92 | + * |
|
| 93 | + * @return string $primary_column |
|
| 94 | + */ |
|
| 95 | 95 | protected function get_primary_column_name() { |
| 96 | 96 | $columns = get_column_headers( $this->screen ); |
| 97 | 97 | $hidden = get_hidden_columns( $this->screen ); |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | $this->get_actions( $actions, $item, $view_link ); |
| 117 | 117 | |
| 118 | - $action_links = $this->row_actions( $actions ); |
|
| 118 | + $action_links = $this->row_actions( $actions ); |
|
| 119 | 119 | |
| 120 | 120 | // Set up the checkbox ( because the user is editable, otherwise its empty ) |
| 121 | 121 | $checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />"; |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | $r = "<tr id='item-action-{$item->id}'$style>"; |
| 124 | 124 | |
| 125 | 125 | list( $columns, $hidden, , $primary ) = $this->get_column_info(); |
| 126 | - $action_col = false; |
|
| 126 | + $action_col = false; |
|
| 127 | 127 | |
| 128 | 128 | foreach ( $columns as $column_name => $column_display_name ) { |
| 129 | 129 | $class = $column_name . ' column-' . $column_name; |
@@ -135,8 +135,8 @@ discard block |
||
| 135 | 135 | if ( in_array( $column_name, $hidden ) ) { |
| 136 | 136 | $class .= ' frm_hidden'; |
| 137 | 137 | } else if ( ! $action_col && ! in_array( $column_name, array( 'cb', 'id', 'form_id', 'post_id' ) ) ) { |
| 138 | - $action_col = $column_name; |
|
| 139 | - } |
|
| 138 | + $action_col = $column_name; |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | 141 | $attributes = 'class="' . esc_attr( $class ) . '"'; |
| 142 | 142 | unset($class); |
@@ -154,30 +154,30 @@ discard block |
||
| 154 | 154 | case 'ip': |
| 155 | 155 | case 'id': |
| 156 | 156 | case 'item_key': |
| 157 | - $val = $item->{$col_name}; |
|
| 158 | - break; |
|
| 157 | + $val = $item->{$col_name}; |
|
| 158 | + break; |
|
| 159 | 159 | case 'name': |
| 160 | 160 | case 'description': |
| 161 | - $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100); |
|
| 162 | - break; |
|
| 161 | + $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100); |
|
| 162 | + break; |
|
| 163 | 163 | case 'created_at': |
| 164 | 164 | case 'updated_at': |
| 165 | - $date = FrmAppHelper::get_formatted_time($item->{$col_name}); |
|
| 165 | + $date = FrmAppHelper::get_formatted_time($item->{$col_name}); |
|
| 166 | 166 | $val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>'; |
| 167 | 167 | break; |
| 168 | 168 | case 'is_draft': |
| 169 | - $val = empty($item->is_draft) ? __( 'No') : __( 'Yes'); |
|
| 170 | - break; |
|
| 169 | + $val = empty($item->is_draft) ? __( 'No') : __( 'Yes'); |
|
| 170 | + break; |
|
| 171 | 171 | case 'form_id': |
| 172 | - $val = FrmFormsHelper::edit_form_link($item->form_id); |
|
| 173 | - break; |
|
| 172 | + $val = FrmFormsHelper::edit_form_link($item->form_id); |
|
| 173 | + break; |
|
| 174 | 174 | case 'post_id': |
| 175 | - $val = FrmAppHelper::post_edit_link($item->post_id); |
|
| 176 | - break; |
|
| 175 | + $val = FrmAppHelper::post_edit_link($item->post_id); |
|
| 176 | + break; |
|
| 177 | 177 | case 'user_id': |
| 178 | - $user = get_userdata($item->user_id); |
|
| 179 | - $val = $user ? $user->user_login : ''; |
|
| 180 | - break; |
|
| 178 | + $user = get_userdata($item->user_id); |
|
| 179 | + $val = $user ? $user->user_login : ''; |
|
| 180 | + break; |
|
| 181 | 181 | case 'parent_item_id': |
| 182 | 182 | $val = $item->parent_item_id; |
| 183 | 183 | break; |
@@ -190,15 +190,15 @@ discard block |
||
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | if ( $col_name != 'cb' ) { |
| 193 | - $r .= "<td $attributes>"; |
|
| 193 | + $r .= "<td $attributes>"; |
|
| 194 | 194 | if ( $column_name == $action_col ) { |
| 195 | 195 | $edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id; |
| 196 | 196 | $r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> '; |
| 197 | - $r .= $action_links; |
|
| 197 | + $r .= $action_links; |
|
| 198 | 198 | } else { |
| 199 | - $r .= $val; |
|
| 200 | - } |
|
| 201 | - $r .= '</td>'; |
|
| 199 | + $r .= $val; |
|
| 200 | + } |
|
| 201 | + $r .= '</td>'; |
|
| 202 | 202 | } |
| 203 | 203 | unset($val); |
| 204 | 204 | } |
@@ -207,19 +207,19 @@ discard block |
||
| 207 | 207 | return $r; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - /** |
|
| 211 | - * @param string $view_link |
|
| 212 | - */ |
|
| 213 | - private function get_actions( &$actions, $item, $view_link ) { |
|
| 210 | + /** |
|
| 211 | + * @param string $view_link |
|
| 212 | + */ |
|
| 213 | + private function get_actions( &$actions, $item, $view_link ) { |
|
| 214 | 214 | $actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>'; |
| 215 | 215 | |
| 216 | - if ( current_user_can('frm_delete_entries') ) { |
|
| 216 | + if ( current_user_can('frm_delete_entries') ) { |
|
| 217 | 217 | $delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form']; |
| 218 | 218 | $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>'; |
| 219 | - } |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | - $actions = apply_filters('frm_row_actions', $actions, $item); |
|
| 222 | - } |
|
| 221 | + $actions = apply_filters('frm_row_actions', $actions, $item); |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | 224 | private function get_column_value( $item, &$val ) { |
| 225 | 225 | $col_name = $this->column_name; |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | $join_form_in_query = true; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : ''; |
|
| 26 | + $s = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : ''; |
|
| 27 | 27 | |
| 28 | 28 | if ( $s != '' && FrmAppHelper::pro_is_installed() ) { |
| 29 | 29 | $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : ''; |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | $s_query = apply_filters( 'frm_entries_list_query', $s_query, compact( 'form_id' ) ); |
| 34 | 34 | |
| 35 | 35 | $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby; |
| 36 | - if ( strpos($orderby, 'meta') !== false ) { |
|
| 36 | + if ( strpos( $orderby, 'meta' ) !== false ) { |
|
| 37 | 37 | $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) ); |
| 38 | 38 | $orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : ''; |
| 39 | 39 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | $start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page ); |
| 46 | 46 | |
| 47 | 47 | $this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, $join_form_in_query ); |
| 48 | - $total_items = FrmEntry::getRecordCount($s_query); |
|
| 48 | + $total_items = FrmEntry::getRecordCount( $s_query ); |
|
| 49 | 49 | |
| 50 | 50 | $this->set_pagination_args( array( |
| 51 | 51 | 'total_items' => $total_items, |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | public function no_items() { |
| 57 | 57 | $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; |
| 58 | - if ( ! empty($s) ) { |
|
| 58 | + if ( ! empty( $s ) ) { |
|
| 59 | 59 | _e( 'No Entries Found', 'formidable' ); |
| 60 | 60 | return; |
| 61 | 61 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $form = $this->params['form']; |
| 65 | 65 | |
| 66 | 66 | if ( $form_id ) { |
| 67 | - $form = FrmForm::getOne($form_id); |
|
| 67 | + $form = FrmForm::getOne( $form_id ); |
|
| 68 | 68 | } |
| 69 | 69 | $colspan = $this->get_column_count(); |
| 70 | 70 | |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | $r = "<tr id='item-action-{$item->id}'$style>"; |
| 124 | 124 | |
| 125 | - list( $columns, $hidden, , $primary ) = $this->get_column_info(); |
|
| 125 | + list( $columns, $hidden,, $primary ) = $this->get_column_info(); |
|
| 126 | 126 | $action_col = false; |
| 127 | 127 | |
| 128 | 128 | foreach ( $columns as $column_name => $column_display_name ) { |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | $attributes = 'class="' . esc_attr( $class ) . '"'; |
| 142 | - unset($class); |
|
| 142 | + unset( $class ); |
|
| 143 | 143 | $attributes .= ' data-colname="' . $column_display_name . '"'; |
| 144 | 144 | |
| 145 | 145 | $form_id = $this->params['form'] ? $this->params['form'] : 0; |
@@ -158,24 +158,24 @@ discard block |
||
| 158 | 158 | break; |
| 159 | 159 | case 'name': |
| 160 | 160 | case 'description': |
| 161 | - $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100); |
|
| 161 | + $val = FrmAppHelper::truncate( strip_tags( $item->{$col_name}), 100 ); |
|
| 162 | 162 | break; |
| 163 | 163 | case 'created_at': |
| 164 | 164 | case 'updated_at': |
| 165 | - $date = FrmAppHelper::get_formatted_time($item->{$col_name}); |
|
| 165 | + $date = FrmAppHelper::get_formatted_time( $item->{$col_name}); |
|
| 166 | 166 | $val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>'; |
| 167 | 167 | break; |
| 168 | 168 | case 'is_draft': |
| 169 | - $val = empty($item->is_draft) ? __( 'No') : __( 'Yes'); |
|
| 169 | + $val = empty( $item->is_draft ) ? __( 'No' ) : __( 'Yes' ); |
|
| 170 | 170 | break; |
| 171 | 171 | case 'form_id': |
| 172 | - $val = FrmFormsHelper::edit_form_link($item->form_id); |
|
| 172 | + $val = FrmFormsHelper::edit_form_link( $item->form_id ); |
|
| 173 | 173 | break; |
| 174 | 174 | case 'post_id': |
| 175 | - $val = FrmAppHelper::post_edit_link($item->post_id); |
|
| 175 | + $val = FrmAppHelper::post_edit_link( $item->post_id ); |
|
| 176 | 176 | break; |
| 177 | 177 | case 'user_id': |
| 178 | - $user = get_userdata($item->user_id); |
|
| 178 | + $user = get_userdata( $item->user_id ); |
|
| 179 | 179 | $val = $user ? $user->user_login : ''; |
| 180 | 180 | break; |
| 181 | 181 | case 'parent_item_id': |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | } |
| 201 | 201 | $r .= '</td>'; |
| 202 | 202 | } |
| 203 | - unset($val); |
|
| 203 | + unset( $val ); |
|
| 204 | 204 | } |
| 205 | 205 | $r .= '</tr>'; |
| 206 | 206 | |
@@ -213,12 +213,12 @@ discard block |
||
| 213 | 213 | private function get_actions( &$actions, $item, $view_link ) { |
| 214 | 214 | $actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>'; |
| 215 | 215 | |
| 216 | - if ( current_user_can('frm_delete_entries') ) { |
|
| 216 | + if ( current_user_can( 'frm_delete_entries' ) ) { |
|
| 217 | 217 | $delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form']; |
| 218 | 218 | $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>'; |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - $actions = apply_filters('frm_row_actions', $actions, $item); |
|
| 221 | + $actions = apply_filters( 'frm_row_actions', $actions, $item ); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | private function get_column_value( $item, &$val ) { |
@@ -285,7 +285,7 @@ |
||
| 285 | 285 | 'type' => $field->type, |
| 286 | 286 | ); |
| 287 | 287 | |
| 288 | - $this->array_content[ $field->id ] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $array, $field ); |
|
| 288 | + $this->array_content[$field->id] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $array, $field ); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | /** |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | public static function menu() { |
| 6 | 6 | FrmAppHelper::force_capability( 'frm_view_entries' ); |
| 7 | 7 | |
| 8 | - add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
| 8 | + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
| 9 | 9 | |
| 10 | 10 | if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) { |
| 11 | 11 | $menu_name = FrmAppHelper::get_menu_name(); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | 'id' => 'formidable-entries-tab', |
| 54 | 54 | 'title' => __( 'Overview', 'formidable' ), |
| 55 | 55 | 'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>', |
| 56 | - )); |
|
| 56 | + ) ); |
|
| 57 | 57 | |
| 58 | 58 | $screen->set_help_sidebar( |
| 59 | 59 | '<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' . |
@@ -68,19 +68,19 @@ discard block |
||
| 68 | 68 | global $frm_vars; |
| 69 | 69 | $form_id = FrmForm::get_current_form_id(); |
| 70 | 70 | |
| 71 | - $columns[ $form_id . '_id' ] = 'ID'; |
|
| 72 | - $columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' ); |
|
| 71 | + $columns[$form_id . '_id'] = 'ID'; |
|
| 72 | + $columns[$form_id . '_item_key'] = esc_html__( 'Entry Key', 'formidable' ); |
|
| 73 | 73 | |
| 74 | 74 | if ( $form_id ) { |
| 75 | 75 | self::get_columns_for_form( $form_id, $columns ); |
| 76 | 76 | } else { |
| 77 | - $columns[ $form_id . '_form_id' ] = __( 'Form', 'formidable' ); |
|
| 78 | - $columns[ $form_id . '_name' ] = __( 'Entry Name', 'formidable' ); |
|
| 79 | - $columns[ $form_id . '_user_id' ] = __( 'Created By', 'formidable' ); |
|
| 77 | + $columns[$form_id . '_form_id'] = __( 'Form', 'formidable' ); |
|
| 78 | + $columns[$form_id . '_name'] = __( 'Entry Name', 'formidable' ); |
|
| 79 | + $columns[$form_id . '_user_id'] = __( 'Created By', 'formidable' ); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - $columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' ); |
|
| 83 | - $columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' ); |
|
| 82 | + $columns[$form_id . '_created_at'] = __( 'Entry creation date', 'formidable' ); |
|
| 83 | + $columns[$form_id . '_updated_at'] = __( 'Entry update date', 'formidable' ); |
|
| 84 | 84 | self::maybe_add_ip_col( $form_id, $columns ); |
| 85 | 85 | |
| 86 | 86 | $frm_vars['cols'] = $columns; |
@@ -107,14 +107,14 @@ discard block |
||
| 107 | 107 | if ( $sub_form_cols ) { |
| 108 | 108 | foreach ( $sub_form_cols as $k => $sub_form_col ) { |
| 109 | 109 | if ( FrmField::is_no_save_field( $sub_form_col->type ) ) { |
| 110 | - unset( $sub_form_cols[ $k ] ); |
|
| 110 | + unset( $sub_form_cols[$k] ); |
|
| 111 | 111 | continue; |
| 112 | 112 | } |
| 113 | - $columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 ); |
|
| 114 | - unset($sub_form_col); |
|
| 113 | + $columns[$form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id] = FrmAppHelper::truncate( $sub_form_col->name, 35 ); |
|
| 114 | + unset( $sub_form_col ); |
|
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | - unset($sub_form_cols); |
|
| 117 | + unset( $sub_form_cols ); |
|
| 118 | 118 | } else { |
| 119 | 119 | $col_id = $form_col->field_key; |
| 120 | 120 | if ( $form_col->form_id != $form_id ) { |
@@ -124,16 +124,16 @@ discard block |
||
| 124 | 124 | $has_separate_value = ! FrmField::is_option_empty( $form_col, 'separate_value' ); |
| 125 | 125 | $is_post_status = FrmField::is_option_true( $form_col, 'post_field' ) && $form_col->field_options['post_field'] == 'post_status'; |
| 126 | 126 | if ( $has_separate_value && ! $is_post_status ) { |
| 127 | - $columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
| 127 | + $columns[$form_id . '_frmsep_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
| 128 | 128 | } |
| 129 | - $columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
| 129 | + $columns[$form_id . '_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | private static function maybe_add_ip_col( $form_id, &$columns ) { |
| 135 | 135 | if ( FrmAppHelper::ips_saved() ) { |
| 136 | - $columns[ $form_id . '_ip' ] = 'IP'; |
|
| 136 | + $columns[$form_id . '_ip'] = 'IP'; |
|
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | global $frm_vars; |
| 152 | 152 | //add a check so we don't create a loop |
| 153 | - $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
| 153 | + $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
| 154 | 154 | |
| 155 | 155 | return $check; |
| 156 | 156 | } |
@@ -165,19 +165,19 @@ discard block |
||
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | global $frm_vars; |
| 168 | - if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) { |
|
| 168 | + if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) { |
|
| 169 | 169 | return; //don't continue if there's no previous value |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | foreach ( $meta_value as $mk => $mv ) { |
| 173 | 173 | //remove blank values |
| 174 | 174 | if ( empty( $mv ) ) { |
| 175 | - unset( $meta_value[ $mk ] ); |
|
| 175 | + unset( $meta_value[$mk] ); |
|
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - $cur_form_prefix = reset($meta_value); |
|
| 180 | - $cur_form_prefix = explode('_', $cur_form_prefix); |
|
| 179 | + $cur_form_prefix = reset( $meta_value ); |
|
| 180 | + $cur_form_prefix = explode( '_', $cur_form_prefix ); |
|
| 181 | 181 | $cur_form_prefix = $cur_form_prefix[0]; |
| 182 | 182 | $save = false; |
| 183 | 183 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | |
| 197 | 197 | $meta_value[] = $prev_hidden; |
| 198 | 198 | $save = true; |
| 199 | - unset($form_prefix); |
|
| 199 | + unset( $form_prefix ); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | if ( $save ) { |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | foreach ( $fields as $field ) { |
| 229 | 229 | if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) { |
| 230 | 230 | // Can't sort on checkboxes because they are stored serialized, or post fields |
| 231 | - $columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id; |
|
| 231 | + $columns[$form_id . '_' . $field->field_key] = 'meta_' . $field->id; |
|
| 232 | 232 | } |
| 233 | 233 | } |
| 234 | 234 | |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | break; |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - unset($form_prefix); |
|
| 254 | + unset( $form_prefix ); |
|
| 255 | 255 | } |
| 256 | 256 | } |
| 257 | 257 | |
@@ -259,15 +259,15 @@ discard block |
||
| 259 | 259 | return $result; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0; |
|
| 262 | + $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0; |
|
| 263 | 263 | $max_columns = 8; |
| 264 | 264 | if ( $i <= $max_columns ) { |
| 265 | 265 | return $result; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | global $frm_vars; |
| 269 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) { |
|
| 270 | - $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options); |
|
| 269 | + if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] ) { |
|
| 270 | + $frm_vars['current_form']->options = maybe_unserialize( $frm_vars['current_form']->options ); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | $has_custom_hidden_columns = ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && isset( $frm_vars['current_form']->options['hidden_cols'] ) && ! empty( $frm_vars['current_form']->options['hidden_cols'] ) ); |
@@ -275,23 +275,23 @@ discard block |
||
| 275 | 275 | $result = $frm_vars['current_form']->options['hidden_cols']; |
| 276 | 276 | } else { |
| 277 | 277 | $cols = $frm_vars['cols']; |
| 278 | - $cols = array_reverse($cols, true); |
|
| 278 | + $cols = array_reverse( $cols, true ); |
|
| 279 | 279 | |
| 280 | 280 | if ( $form_id ) { |
| 281 | 281 | $result[] = $form_id . '_id'; |
| 282 | - $i--; |
|
| 282 | + $i --; |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | $result[] = $form_id . '_item_key'; |
| 286 | - $i--; |
|
| 286 | + $i --; |
|
| 287 | 287 | |
| 288 | 288 | foreach ( $cols as $col_key => $col ) { |
| 289 | 289 | if ( $i > $max_columns ) { |
| 290 | 290 | $result[] = $col_key; |
| 291 | 291 | } |
| 292 | 292 | //remove some columns by default |
| 293 | - $i--; |
|
| 294 | - unset($col_key, $col); |
|
| 293 | + $i --; |
|
| 294 | + unset( $col_key, $col ); |
|
| 295 | 295 | } |
| 296 | 296 | } |
| 297 | 297 | |
@@ -323,14 +323,14 @@ discard block |
||
| 323 | 323 | if ( $pagenum > $total_pages && $total_pages > 0 ) { |
| 324 | 324 | $url = add_query_arg( 'paged', $total_pages ); |
| 325 | 325 | if ( headers_sent() ) { |
| 326 | - echo FrmAppHelper::js_redirect($url); |
|
| 326 | + echo FrmAppHelper::js_redirect( $url ); |
|
| 327 | 327 | } else { |
| 328 | 328 | wp_redirect( esc_url_raw( $url ) ); |
| 329 | 329 | } |
| 330 | 330 | die(); |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - if ( empty($message) && isset($_GET['import-message']) ) { |
|
| 333 | + if ( empty( $message ) && isset( $_GET['import-message'] ) ) { |
|
| 334 | 334 | $message = __( 'Your import is complete', 'formidable' ); |
| 335 | 335 | } |
| 336 | 336 | |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | |
| 348 | 348 | /* Back End CRUD */ |
| 349 | 349 | public static function show( $id = 0 ) { |
| 350 | - FrmAppHelper::permission_check('frm_view_entries'); |
|
| 350 | + FrmAppHelper::permission_check( 'frm_view_entries' ); |
|
| 351 | 351 | |
| 352 | 352 | if ( ! $id ) { |
| 353 | 353 | $id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' ); |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | } |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - $entry = FrmEntry::getOne($id, true); |
|
| 360 | + $entry = FrmEntry::getOne( $id, true ); |
|
| 361 | 361 | if ( ! $entry ) { |
| 362 | 362 | echo '<div id="form_show_entry_page" class="wrap">' . |
| 363 | 363 | __( 'You are trying to view an entry that does not exist.', 'formidable' ) . |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | return; |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - $data = maybe_unserialize($entry->description); |
|
| 368 | + $data = maybe_unserialize( $entry->description ); |
|
| 369 | 369 | if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) { |
| 370 | 370 | $data = array( 'referrer' => $data ); |
| 371 | 371 | } |
@@ -377,11 +377,11 @@ discard block |
||
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | public static function destroy() { |
| 380 | - FrmAppHelper::permission_check('frm_delete_entries'); |
|
| 380 | + FrmAppHelper::permission_check( 'frm_delete_entries' ); |
|
| 381 | 381 | |
| 382 | 382 | $params = FrmForm::get_admin_params(); |
| 383 | 383 | |
| 384 | - if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
| 384 | + if ( isset( $params['keep_post'] ) && $params['keep_post'] ) { |
|
| 385 | 385 | //unlink entry from post |
| 386 | 386 | global $wpdb; |
| 387 | 387 | $wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) ); |
@@ -460,9 +460,9 @@ discard block |
||
| 460 | 460 | if ( ! isset( $frm_vars['form_params'] ) ) { |
| 461 | 461 | $frm_vars['form_params'] = array(); |
| 462 | 462 | } |
| 463 | - $frm_vars['form_params'][ $form->id ] = $params; |
|
| 463 | + $frm_vars['form_params'][$form->id] = $params; |
|
| 464 | 464 | |
| 465 | - if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) { |
|
| 465 | + if ( isset( $frm_vars['created_entries'][$form_id] ) ) { |
|
| 466 | 466 | return; |
| 467 | 467 | } |
| 468 | 468 | |
@@ -477,13 +477,13 @@ discard block |
||
| 477 | 477 | */ |
| 478 | 478 | $errors = apply_filters( 'frm_entries_before_create', $errors, $form ); |
| 479 | 479 | |
| 480 | - $frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors ); |
|
| 480 | + $frm_vars['created_entries'][$form_id] = array( 'errors' => $errors ); |
|
| 481 | 481 | |
| 482 | 482 | if ( empty( $errors ) ) { |
| 483 | 483 | $_POST['frm_skip_cookie'] = 1; |
| 484 | 484 | if ( $params['action'] == 'create' ) { |
| 485 | - if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) { |
|
| 486 | - $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); |
|
| 485 | + if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) { |
|
| 486 | + $frm_vars['created_entries'][$form_id]['entry_id'] = FrmEntry::create( $_POST ); |
|
| 487 | 487 | } |
| 488 | 488 | } |
| 489 | 489 | |
@@ -566,9 +566,9 @@ discard block |
||
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | public static function entry_sidebar( $entry ) { |
| 569 | - $data = maybe_unserialize($entry->description); |
|
| 570 | - $date_format = get_option('date_format'); |
|
| 571 | - $time_format = get_option('time_format'); |
|
| 569 | + $data = maybe_unserialize( $entry->description ); |
|
| 570 | + $date_format = get_option( 'date_format' ); |
|
| 571 | + $time_format = get_option( 'time_format' ); |
|
| 572 | 572 | if ( isset( $data['browser'] ) ) { |
| 573 | 573 | $browser = FrmEntriesHelper::get_browser( $data['browser'] ); |
| 574 | 574 | } |
@@ -2,70 +2,70 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmEntriesController { |
| 4 | 4 | |
| 5 | - public static function menu() { |
|
| 5 | + public static function menu() { |
|
| 6 | 6 | FrmAppHelper::force_capability( 'frm_view_entries' ); |
| 7 | 7 | |
| 8 | - add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
| 8 | + add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
| 9 | 9 | |
| 10 | 10 | if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) { |
| 11 | 11 | $menu_name = FrmAppHelper::get_menu_name(); |
| 12 | 12 | add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_columns', 'FrmEntriesController::manage_columns' ); |
| 13 | 13 | add_filter( 'get_user_option_manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden', 'FrmEntriesController::hidden_columns' ); |
| 14 | 14 | add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_sortable_columns', 'FrmEntriesController::sortable_columns' ); |
| 15 | - } |
|
| 16 | - } |
|
| 15 | + } |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - /* Display in Back End */ |
|
| 19 | - public static function route() { |
|
| 18 | + /* Display in Back End */ |
|
| 19 | + public static function route() { |
|
| 20 | 20 | $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
| 21 | 21 | |
| 22 | - switch ( $action ) { |
|
| 23 | - case 'show': |
|
| 24 | - case 'destroy': |
|
| 25 | - case 'destroy_all': |
|
| 26 | - return self::$action(); |
|
| 22 | + switch ( $action ) { |
|
| 23 | + case 'show': |
|
| 24 | + case 'destroy': |
|
| 25 | + case 'destroy_all': |
|
| 26 | + return self::$action(); |
|
| 27 | 27 | |
| 28 | - default: |
|
| 29 | - do_action( 'frm_entry_action_route', $action ); |
|
| 30 | - if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) { |
|
| 31 | - return; |
|
| 32 | - } |
|
| 28 | + default: |
|
| 29 | + do_action( 'frm_entry_action_route', $action ); |
|
| 30 | + if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) { |
|
| 31 | + return; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - return self::display_list(); |
|
| 35 | - } |
|
| 36 | - } |
|
| 34 | + return self::display_list(); |
|
| 35 | + } |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | 38 | public static function contextual_help( $help, $screen_id, $screen ) { |
| 39 | - // Only add to certain screens. add_help_tab was introduced in WordPress 3.3 |
|
| 40 | - if ( ! method_exists( $screen, 'add_help_tab' ) ) { |
|
| 41 | - return $help; |
|
| 42 | - } |
|
| 39 | + // Only add to certain screens. add_help_tab was introduced in WordPress 3.3 |
|
| 40 | + if ( ! method_exists( $screen, 'add_help_tab' ) ) { |
|
| 41 | + return $help; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | 44 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
| 45 | 45 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
| 46 | 46 | if ( $page != 'formidable-entries' || ( ! empty( $action ) && $action != 'list' ) ) { |
| 47 | - return $help; |
|
| 48 | - } |
|
| 47 | + return $help; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | unset( $action, $page ); |
| 51 | 51 | |
| 52 | - $screen->add_help_tab( array( |
|
| 53 | - 'id' => 'formidable-entries-tab', |
|
| 54 | - 'title' => __( 'Overview', 'formidable' ), |
|
| 52 | + $screen->add_help_tab( array( |
|
| 53 | + 'id' => 'formidable-entries-tab', |
|
| 54 | + 'title' => __( 'Overview', 'formidable' ), |
|
| 55 | 55 | 'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>', |
| 56 | - )); |
|
| 56 | + )); |
|
| 57 | 57 | |
| 58 | - $screen->set_help_sidebar( |
|
| 58 | + $screen->set_help_sidebar( |
|
| 59 | 59 | '<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' . |
| 60 | 60 | '<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/knowledgebase/manage-entries-from-the-back-end/' ) ) . '" target="_blank">' . esc_html__( 'Documentation on Entries', 'formidable' ) . '</a></p>' . |
| 61 | 61 | '<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>' |
| 62 | - ); |
|
| 62 | + ); |
|
| 63 | 63 | |
| 64 | - return $help; |
|
| 65 | - } |
|
| 64 | + return $help; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | 67 | public static function manage_columns( $columns ) { |
| 68 | - global $frm_vars; |
|
| 68 | + global $frm_vars; |
|
| 69 | 69 | $form_id = FrmForm::get_current_form_id(); |
| 70 | 70 | |
| 71 | 71 | $columns[ $form_id . '_id' ] = 'ID'; |
@@ -83,15 +83,15 @@ discard block |
||
| 83 | 83 | $columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' ); |
| 84 | 84 | self::maybe_add_ip_col( $form_id, $columns ); |
| 85 | 85 | |
| 86 | - $frm_vars['cols'] = $columns; |
|
| 86 | + $frm_vars['cols'] = $columns; |
|
| 87 | 87 | |
| 88 | 88 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
| 89 | 89 | if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) { |
| 90 | 90 | add_screen_option( 'per_page', array( 'label' => __( 'Entries', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page' ) ); |
| 91 | - } |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - return $columns; |
|
| 94 | - } |
|
| 93 | + return $columns; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | 96 | private static function get_columns_for_form( $form_id, &$columns ) { |
| 97 | 97 | $form_cols = FrmField::get_all_for_form( $form_id, '', 'include' ); |
@@ -141,76 +141,76 @@ discard block |
||
| 141 | 141 | $menu_name = FrmAppHelper::get_menu_name(); |
| 142 | 142 | $this_page_name = 'manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden'; |
| 143 | 143 | if ( $meta_key != $this_page_name || $meta_value == $prev_value ) { |
| 144 | - return $check; |
|
| 145 | - } |
|
| 144 | + return $check; |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | 147 | if ( empty( $prev_value ) ) { |
| 148 | 148 | $prev_value = get_metadata( 'user', $object_id, $meta_key, true ); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - global $frm_vars; |
|
| 152 | - //add a check so we don't create a loop |
|
| 153 | - $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
| 151 | + global $frm_vars; |
|
| 152 | + //add a check so we don't create a loop |
|
| 153 | + $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
| 154 | 154 | |
| 155 | - return $check; |
|
| 156 | - } |
|
| 155 | + return $check; |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - //add hidden columns back from other forms |
|
| 158 | + //add hidden columns back from other forms |
|
| 159 | 159 | public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) { |
| 160 | 160 | $menu_name = FrmAppHelper::get_menu_name(); |
| 161 | 161 | $sanitized = sanitize_title( $menu_name ); |
| 162 | 162 | $this_page_name = 'manage' . $sanitized . '_page_formidable-entriescolumnshidden'; |
| 163 | 163 | if ( $meta_key != $this_page_name ) { |
| 164 | - return; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - global $frm_vars; |
|
| 168 | - if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) { |
|
| 169 | - return; //don't continue if there's no previous value |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - foreach ( $meta_value as $mk => $mv ) { |
|
| 173 | - //remove blank values |
|
| 174 | - if ( empty( $mv ) ) { |
|
| 175 | - unset( $meta_value[ $mk ] ); |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - $cur_form_prefix = reset($meta_value); |
|
| 180 | - $cur_form_prefix = explode('_', $cur_form_prefix); |
|
| 181 | - $cur_form_prefix = $cur_form_prefix[0]; |
|
| 182 | - $save = false; |
|
| 183 | - |
|
| 184 | - foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) { |
|
| 164 | + return; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + global $frm_vars; |
|
| 168 | + if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) { |
|
| 169 | + return; //don't continue if there's no previous value |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + foreach ( $meta_value as $mk => $mv ) { |
|
| 173 | + //remove blank values |
|
| 174 | + if ( empty( $mv ) ) { |
|
| 175 | + unset( $meta_value[ $mk ] ); |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + $cur_form_prefix = reset($meta_value); |
|
| 180 | + $cur_form_prefix = explode('_', $cur_form_prefix); |
|
| 181 | + $cur_form_prefix = $cur_form_prefix[0]; |
|
| 182 | + $save = false; |
|
| 183 | + |
|
| 184 | + foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) { |
|
| 185 | 185 | if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) { |
| 186 | - //don't add blank cols or process included cols |
|
| 187 | - continue; |
|
| 188 | - } |
|
| 186 | + //don't add blank cols or process included cols |
|
| 187 | + continue; |
|
| 188 | + } |
|
| 189 | 189 | |
| 190 | 190 | $form_prefix = explode( '_', $prev_hidden ); |
| 191 | - $form_prefix = $form_prefix[0]; |
|
| 192 | - if ( $form_prefix == $cur_form_prefix ) { |
|
| 193 | - //don't add back columns that are meant to be hidden |
|
| 194 | - continue; |
|
| 195 | - } |
|
| 191 | + $form_prefix = $form_prefix[0]; |
|
| 192 | + if ( $form_prefix == $cur_form_prefix ) { |
|
| 193 | + //don't add back columns that are meant to be hidden |
|
| 194 | + continue; |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | - $meta_value[] = $prev_hidden; |
|
| 198 | - $save = true; |
|
| 199 | - unset($form_prefix); |
|
| 200 | - } |
|
| 197 | + $meta_value[] = $prev_hidden; |
|
| 198 | + $save = true; |
|
| 199 | + unset($form_prefix); |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | 202 | if ( $save ) { |
| 203 | - $user = wp_get_current_user(); |
|
| 203 | + $user = wp_get_current_user(); |
|
| 204 | 204 | update_user_option( $user->ID, $this_page_name, $meta_value, true ); |
| 205 | - } |
|
| 206 | - } |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | 208 | public static function save_per_page( $save, $option, $value ) { |
| 209 | - if ( $option == 'formidable_page_formidable_entries_per_page' ) { |
|
| 210 | - $save = (int) $value; |
|
| 211 | - } |
|
| 212 | - return $save; |
|
| 213 | - } |
|
| 209 | + if ( $option == 'formidable_page_formidable_entries_per_page' ) { |
|
| 210 | + $save = (int) $value; |
|
| 211 | + } |
|
| 212 | + return $save; |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | 215 | public static function sortable_columns() { |
| 216 | 216 | $form_id = FrmForm::get_current_form_id(); |
@@ -236,46 +236,46 @@ discard block |
||
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | public static function hidden_columns( $result ) { |
| 239 | - global $frm_vars; |
|
| 239 | + global $frm_vars; |
|
| 240 | 240 | |
| 241 | 241 | $form_id = FrmForm::get_current_form_id(); |
| 242 | 242 | |
| 243 | - $return = false; |
|
| 244 | - foreach ( (array) $result as $r ) { |
|
| 245 | - if ( ! empty( $r ) ) { |
|
| 246 | - $form_prefix = explode( '_', $r ); |
|
| 247 | - $form_prefix = $form_prefix[0]; |
|
| 243 | + $return = false; |
|
| 244 | + foreach ( (array) $result as $r ) { |
|
| 245 | + if ( ! empty( $r ) ) { |
|
| 246 | + $form_prefix = explode( '_', $r ); |
|
| 247 | + $form_prefix = $form_prefix[0]; |
|
| 248 | 248 | |
| 249 | - if ( (int) $form_prefix == (int) $form_id ) { |
|
| 250 | - $return = true; |
|
| 251 | - break; |
|
| 252 | - } |
|
| 249 | + if ( (int) $form_prefix == (int) $form_id ) { |
|
| 250 | + $return = true; |
|
| 251 | + break; |
|
| 252 | + } |
|
| 253 | 253 | |
| 254 | - unset($form_prefix); |
|
| 255 | - } |
|
| 256 | - } |
|
| 254 | + unset($form_prefix); |
|
| 255 | + } |
|
| 256 | + } |
|
| 257 | 257 | |
| 258 | - if ( $return ) { |
|
| 258 | + if ( $return ) { |
|
| 259 | 259 | return $result; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0; |
|
| 263 | - $max_columns = 8; |
|
| 264 | - if ( $i <= $max_columns ) { |
|
| 262 | + $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0; |
|
| 263 | + $max_columns = 8; |
|
| 264 | + if ( $i <= $max_columns ) { |
|
| 265 | 265 | return $result; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - global $frm_vars; |
|
| 269 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) { |
|
| 270 | - $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options); |
|
| 271 | - } |
|
| 268 | + global $frm_vars; |
|
| 269 | + if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) { |
|
| 270 | + $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options); |
|
| 271 | + } |
|
| 272 | 272 | |
| 273 | 273 | $has_custom_hidden_columns = ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && isset( $frm_vars['current_form']->options['hidden_cols'] ) && ! empty( $frm_vars['current_form']->options['hidden_cols'] ) ); |
| 274 | 274 | if ( $has_custom_hidden_columns ) { |
| 275 | - $result = $frm_vars['current_form']->options['hidden_cols']; |
|
| 276 | - } else { |
|
| 277 | - $cols = $frm_vars['cols']; |
|
| 278 | - $cols = array_reverse($cols, true); |
|
| 275 | + $result = $frm_vars['current_form']->options['hidden_cols']; |
|
| 276 | + } else { |
|
| 277 | + $cols = $frm_vars['cols']; |
|
| 278 | + $cols = array_reverse($cols, true); |
|
| 279 | 279 | |
| 280 | 280 | if ( $form_id ) { |
| 281 | 281 | $result[] = $form_id . '_id'; |
@@ -283,59 +283,59 @@ discard block |
||
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | $result[] = $form_id . '_item_key'; |
| 286 | - $i--; |
|
| 286 | + $i--; |
|
| 287 | 287 | |
| 288 | 288 | foreach ( $cols as $col_key => $col ) { |
| 289 | - if ( $i > $max_columns ) { |
|
| 289 | + if ( $i > $max_columns ) { |
|
| 290 | 290 | $result[] = $col_key; |
| 291 | 291 | } |
| 292 | - //remove some columns by default |
|
| 293 | - $i--; |
|
| 294 | - unset($col_key, $col); |
|
| 295 | - } |
|
| 296 | - } |
|
| 292 | + //remove some columns by default |
|
| 293 | + $i--; |
|
| 294 | + unset($col_key, $col); |
|
| 295 | + } |
|
| 296 | + } |
|
| 297 | 297 | |
| 298 | - return $result; |
|
| 299 | - } |
|
| 298 | + return $result; |
|
| 299 | + } |
|
| 300 | 300 | |
| 301 | 301 | public static function display_list( $message = '', $errors = array() ) { |
| 302 | - global $wpdb, $frm_vars; |
|
| 302 | + global $wpdb, $frm_vars; |
|
| 303 | 303 | |
| 304 | 304 | $form = FrmForm::maybe_get_current_form(); |
| 305 | 305 | $params = FrmForm::get_admin_params( $form ); |
| 306 | 306 | |
| 307 | - if ( $form ) { |
|
| 308 | - $params['form'] = $form->id; |
|
| 309 | - $frm_vars['current_form'] = $form; |
|
| 307 | + if ( $form ) { |
|
| 308 | + $params['form'] = $form->id; |
|
| 309 | + $frm_vars['current_form'] = $form; |
|
| 310 | 310 | |
| 311 | 311 | self::get_delete_form_time( $form, $errors ); |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' ); |
|
| 314 | + $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' ); |
|
| 315 | 315 | |
| 316 | - $wp_list_table = new $table_class( array( 'params' => $params ) ); |
|
| 316 | + $wp_list_table = new $table_class( array( 'params' => $params ) ); |
|
| 317 | 317 | |
| 318 | - $pagenum = $wp_list_table->get_pagenum(); |
|
| 318 | + $pagenum = $wp_list_table->get_pagenum(); |
|
| 319 | 319 | |
| 320 | - $wp_list_table->prepare_items(); |
|
| 320 | + $wp_list_table->prepare_items(); |
|
| 321 | 321 | |
| 322 | - $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 323 | - if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 322 | + $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 323 | + if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 324 | 324 | $url = add_query_arg( 'paged', $total_pages ); |
| 325 | - if ( headers_sent() ) { |
|
| 326 | - echo FrmAppHelper::js_redirect($url); |
|
| 327 | - } else { |
|
| 328 | - wp_redirect( esc_url_raw( $url ) ); |
|
| 329 | - } |
|
| 330 | - die(); |
|
| 331 | - } |
|
| 332 | - |
|
| 333 | - if ( empty($message) && isset($_GET['import-message']) ) { |
|
| 334 | - $message = __( 'Your import is complete', 'formidable' ); |
|
| 335 | - } |
|
| 325 | + if ( headers_sent() ) { |
|
| 326 | + echo FrmAppHelper::js_redirect($url); |
|
| 327 | + } else { |
|
| 328 | + wp_redirect( esc_url_raw( $url ) ); |
|
| 329 | + } |
|
| 330 | + die(); |
|
| 331 | + } |
|
| 332 | + |
|
| 333 | + if ( empty($message) && isset($_GET['import-message']) ) { |
|
| 334 | + $message = __( 'Your import is complete', 'formidable' ); |
|
| 335 | + } |
|
| 336 | 336 | |
| 337 | 337 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' ); |
| 338 | - } |
|
| 338 | + } |
|
| 339 | 339 | |
| 340 | 340 | private static function get_delete_form_time( $form, &$errors ) { |
| 341 | 341 | if ( 'trash' == $form->status ) { |
@@ -345,19 +345,19 @@ discard block |
||
| 345 | 345 | } |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | - /* Back End CRUD */ |
|
| 348 | + /* Back End CRUD */ |
|
| 349 | 349 | public static function show( $id = 0 ) { |
| 350 | - FrmAppHelper::permission_check('frm_view_entries'); |
|
| 350 | + FrmAppHelper::permission_check('frm_view_entries'); |
|
| 351 | 351 | |
| 352 | - if ( ! $id ) { |
|
| 352 | + if ( ! $id ) { |
|
| 353 | 353 | $id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' ); |
| 354 | 354 | |
| 355 | - if ( ! $id ) { |
|
| 355 | + if ( ! $id ) { |
|
| 356 | 356 | $id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' ); |
| 357 | - } |
|
| 358 | - } |
|
| 357 | + } |
|
| 358 | + } |
|
| 359 | 359 | |
| 360 | - $entry = FrmEntry::getOne($id, true); |
|
| 360 | + $entry = FrmEntry::getOne($id, true); |
|
| 361 | 361 | if ( ! $entry ) { |
| 362 | 362 | echo '<div id="form_show_entry_page" class="wrap">' . |
| 363 | 363 | __( 'You are trying to view an entry that does not exist.', 'formidable' ) . |
@@ -365,110 +365,110 @@ discard block |
||
| 365 | 365 | return; |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - $data = maybe_unserialize($entry->description); |
|
| 368 | + $data = maybe_unserialize($entry->description); |
|
| 369 | 369 | if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) { |
| 370 | 370 | $data = array( 'referrer' => $data ); |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | $fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' ); |
| 374 | - $to_emails = array(); |
|
| 374 | + $to_emails = array(); |
|
| 375 | 375 | |
| 376 | 376 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' ); |
| 377 | - } |
|
| 377 | + } |
|
| 378 | 378 | |
| 379 | - public static function destroy() { |
|
| 380 | - FrmAppHelper::permission_check('frm_delete_entries'); |
|
| 379 | + public static function destroy() { |
|
| 380 | + FrmAppHelper::permission_check('frm_delete_entries'); |
|
| 381 | 381 | |
| 382 | 382 | $params = FrmForm::get_admin_params(); |
| 383 | 383 | |
| 384 | - if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
| 385 | - //unlink entry from post |
|
| 386 | - global $wpdb; |
|
| 384 | + if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
| 385 | + //unlink entry from post |
|
| 386 | + global $wpdb; |
|
| 387 | 387 | $wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) ); |
| 388 | - } |
|
| 388 | + } |
|
| 389 | 389 | |
| 390 | - $message = ''; |
|
| 391 | - if ( FrmEntry::destroy( $params['id'] ) ) { |
|
| 392 | - $message = __( 'Entry was Successfully Destroyed', 'formidable' ); |
|
| 393 | - } |
|
| 390 | + $message = ''; |
|
| 391 | + if ( FrmEntry::destroy( $params['id'] ) ) { |
|
| 392 | + $message = __( 'Entry was Successfully Destroyed', 'formidable' ); |
|
| 393 | + } |
|
| 394 | 394 | |
| 395 | - self::display_list( $message ); |
|
| 396 | - } |
|
| 395 | + self::display_list( $message ); |
|
| 396 | + } |
|
| 397 | 397 | |
| 398 | - public static function destroy_all() { |
|
| 399 | - if ( ! current_user_can( 'frm_delete_entries' ) ) { |
|
| 400 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 401 | - wp_die( $frm_settings->admin_permission ); |
|
| 402 | - } |
|
| 398 | + public static function destroy_all() { |
|
| 399 | + if ( ! current_user_can( 'frm_delete_entries' ) ) { |
|
| 400 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 401 | + wp_die( $frm_settings->admin_permission ); |
|
| 402 | + } |
|
| 403 | 403 | |
| 404 | - global $wpdb; |
|
| 404 | + global $wpdb; |
|
| 405 | 405 | $params = FrmForm::get_admin_params(); |
| 406 | - $message = ''; |
|
| 407 | - $errors = array(); |
|
| 408 | - $form_id = (int) $params['form']; |
|
| 406 | + $message = ''; |
|
| 407 | + $errors = array(); |
|
| 408 | + $form_id = (int) $params['form']; |
|
| 409 | 409 | |
| 410 | - if ( $form_id ) { |
|
| 411 | - $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) ); |
|
| 410 | + if ( $form_id ) { |
|
| 411 | + $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) ); |
|
| 412 | 412 | $action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 ); |
| 413 | 413 | |
| 414 | - if ( $action ) { |
|
| 415 | - // this action takes a while, so only trigger it if there are posts to delete |
|
| 416 | - foreach ( $entry_ids as $entry_id ) { |
|
| 417 | - do_action( 'frm_before_destroy_entry', $entry_id ); |
|
| 418 | - unset( $entry_id ); |
|
| 419 | - } |
|
| 420 | - } |
|
| 421 | - |
|
| 422 | - $wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) ); |
|
| 423 | - $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) ); |
|
| 424 | - if ( $results ) { |
|
| 414 | + if ( $action ) { |
|
| 415 | + // this action takes a while, so only trigger it if there are posts to delete |
|
| 416 | + foreach ( $entry_ids as $entry_id ) { |
|
| 417 | + do_action( 'frm_before_destroy_entry', $entry_id ); |
|
| 418 | + unset( $entry_id ); |
|
| 419 | + } |
|
| 420 | + } |
|
| 421 | + |
|
| 422 | + $wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) ); |
|
| 423 | + $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) ); |
|
| 424 | + if ( $results ) { |
|
| 425 | 425 | FrmEntry::clear_cache(); |
| 426 | - $message = __( 'Entries were Successfully Destroyed', 'formidable' ); |
|
| 427 | - } |
|
| 428 | - } else { |
|
| 429 | - $errors = __( 'No entries were specified', 'formidable' ); |
|
| 430 | - } |
|
| 431 | - |
|
| 432 | - self::display_list( $message, $errors ); |
|
| 433 | - } |
|
| 434 | - |
|
| 435 | - public static function show_form( $id = '', $key = '', $title = false, $description = false ) { |
|
| 436 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' ); |
|
| 437 | - return FrmFormsController::show_form( $id, $key, $title, $description ); |
|
| 438 | - } |
|
| 439 | - |
|
| 440 | - public static function get_form( $filename, $form, $title, $description ) { |
|
| 441 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' ); |
|
| 442 | - return FrmFormsController::get_form( $form, $title, $description ); |
|
| 443 | - } |
|
| 444 | - |
|
| 445 | - public static function process_entry( $errors = '', $ajax = false ) { |
|
| 426 | + $message = __( 'Entries were Successfully Destroyed', 'formidable' ); |
|
| 427 | + } |
|
| 428 | + } else { |
|
| 429 | + $errors = __( 'No entries were specified', 'formidable' ); |
|
| 430 | + } |
|
| 431 | + |
|
| 432 | + self::display_list( $message, $errors ); |
|
| 433 | + } |
|
| 434 | + |
|
| 435 | + public static function show_form( $id = '', $key = '', $title = false, $description = false ) { |
|
| 436 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' ); |
|
| 437 | + return FrmFormsController::show_form( $id, $key, $title, $description ); |
|
| 438 | + } |
|
| 439 | + |
|
| 440 | + public static function get_form( $filename, $form, $title, $description ) { |
|
| 441 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' ); |
|
| 442 | + return FrmFormsController::get_form( $form, $title, $description ); |
|
| 443 | + } |
|
| 444 | + |
|
| 445 | + public static function process_entry( $errors = '', $ajax = false ) { |
|
| 446 | 446 | $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' ); |
| 447 | 447 | if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) { |
| 448 | - return; |
|
| 449 | - } |
|
| 448 | + return; |
|
| 449 | + } |
|
| 450 | 450 | |
| 451 | - global $frm_vars; |
|
| 451 | + global $frm_vars; |
|
| 452 | 452 | |
| 453 | 453 | $form = FrmForm::getOne( $form_id ); |
| 454 | - if ( ! $form ) { |
|
| 455 | - return; |
|
| 456 | - } |
|
| 454 | + if ( ! $form ) { |
|
| 455 | + return; |
|
| 456 | + } |
|
| 457 | 457 | |
| 458 | 458 | $params = FrmForm::get_params( $form ); |
| 459 | 459 | |
| 460 | - if ( ! isset( $frm_vars['form_params'] ) ) { |
|
| 461 | - $frm_vars['form_params'] = array(); |
|
| 462 | - } |
|
| 460 | + if ( ! isset( $frm_vars['form_params'] ) ) { |
|
| 461 | + $frm_vars['form_params'] = array(); |
|
| 462 | + } |
|
| 463 | 463 | $frm_vars['form_params'][ $form->id ] = $params; |
| 464 | 464 | |
| 465 | 465 | if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) { |
| 466 | - return; |
|
| 467 | - } |
|
| 466 | + return; |
|
| 467 | + } |
|
| 468 | 468 | |
| 469 | - if ( $errors == '' && ! $ajax ) { |
|
| 469 | + if ( $errors == '' && ! $ajax ) { |
|
| 470 | 470 | $errors = FrmEntryValidate::validate( $_POST ); |
| 471 | - } |
|
| 471 | + } |
|
| 472 | 472 | |
| 473 | 473 | /** |
| 474 | 474 | * Use this filter to add trigger actions and add errors after |
@@ -479,39 +479,39 @@ discard block |
||
| 479 | 479 | |
| 480 | 480 | $frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors ); |
| 481 | 481 | |
| 482 | - if ( empty( $errors ) ) { |
|
| 482 | + if ( empty( $errors ) ) { |
|
| 483 | 483 | $_POST['frm_skip_cookie'] = 1; |
| 484 | - if ( $params['action'] == 'create' ) { |
|
| 484 | + if ( $params['action'] == 'create' ) { |
|
| 485 | 485 | if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) { |
| 486 | 486 | $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); |
| 487 | - } |
|
| 488 | - } |
|
| 487 | + } |
|
| 488 | + } |
|
| 489 | 489 | |
| 490 | - do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); |
|
| 490 | + do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); |
|
| 491 | 491 | unset( $_POST['frm_skip_cookie'] ); |
| 492 | - } |
|
| 493 | - } |
|
| 494 | - |
|
| 495 | - public static function delete_entry_before_redirect( $url, $form, $atts ) { |
|
| 496 | - self::_delete_entry( $atts['id'], $form ); |
|
| 497 | - return $url; |
|
| 498 | - } |
|
| 499 | - |
|
| 500 | - //Delete entry if not redirected |
|
| 501 | - public static function delete_entry_after_save( $atts ) { |
|
| 502 | - self::_delete_entry( $atts['entry_id'], $atts['form'] ); |
|
| 503 | - } |
|
| 504 | - |
|
| 505 | - private static function _delete_entry( $entry_id, $form ) { |
|
| 506 | - if ( ! $form ) { |
|
| 507 | - return; |
|
| 508 | - } |
|
| 509 | - |
|
| 510 | - $form->options = maybe_unserialize( $form->options ); |
|
| 511 | - if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) { |
|
| 512 | - FrmEntry::destroy( $entry_id ); |
|
| 513 | - } |
|
| 514 | - } |
|
| 492 | + } |
|
| 493 | + } |
|
| 494 | + |
|
| 495 | + public static function delete_entry_before_redirect( $url, $form, $atts ) { |
|
| 496 | + self::_delete_entry( $atts['id'], $form ); |
|
| 497 | + return $url; |
|
| 498 | + } |
|
| 499 | + |
|
| 500 | + //Delete entry if not redirected |
|
| 501 | + public static function delete_entry_after_save( $atts ) { |
|
| 502 | + self::_delete_entry( $atts['entry_id'], $atts['form'] ); |
|
| 503 | + } |
|
| 504 | + |
|
| 505 | + private static function _delete_entry( $entry_id, $form ) { |
|
| 506 | + if ( ! $form ) { |
|
| 507 | + return; |
|
| 508 | + } |
|
| 509 | + |
|
| 510 | + $form->options = maybe_unserialize( $form->options ); |
|
| 511 | + if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) { |
|
| 512 | + FrmEntry::destroy( $entry_id ); |
|
| 513 | + } |
|
| 514 | + } |
|
| 515 | 515 | |
| 516 | 516 | /** |
| 517 | 517 | * @param $atts |
@@ -562,13 +562,13 @@ discard block |
||
| 562 | 562 | } |
| 563 | 563 | |
| 564 | 564 | public static function entry_sidebar( $entry ) { |
| 565 | - $data = maybe_unserialize($entry->description); |
|
| 566 | - $date_format = get_option('date_format'); |
|
| 567 | - $time_format = get_option('time_format'); |
|
| 565 | + $data = maybe_unserialize($entry->description); |
|
| 566 | + $date_format = get_option('date_format'); |
|
| 567 | + $time_format = get_option('time_format'); |
|
| 568 | 568 | if ( isset( $data['browser'] ) ) { |
| 569 | 569 | $browser = FrmEntriesHelper::get_browser( $data['browser'] ); |
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' ); |
| 573 | - } |
|
| 573 | + } |
|
| 574 | 574 | } |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | * |
| 364 | 364 | * @since 2.04 |
| 365 | 365 | * |
| 366 | - * @param array $field_values |
|
| 366 | + * @param FrmFieldValue[] $field_values |
|
| 367 | 367 | * @param array $output |
| 368 | 368 | */ |
| 369 | 369 | protected function push_field_values_to_array( $field_values, &$output ) { |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | * |
| 571 | 571 | * @param mixed $value |
| 572 | 572 | * |
| 573 | - * @return mixed|string |
|
| 573 | + * @return FrmFieldValue |
|
| 574 | 574 | */ |
| 575 | 575 | protected function prepare_display_value_for_array( $value ) { |
| 576 | 576 | return $this->strip_html( $value ); |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | * @param mixed $display_value |
| 586 | 586 | * @param string $field_type |
| 587 | 587 | * |
| 588 | - * @return mixed|string |
|
| 588 | + * @return string |
|
| 589 | 589 | */ |
| 590 | 590 | protected function prepare_display_value_for_html_table( $display_value, $field_type = '' ) { |
| 591 | 591 | $display_value = $this->flatten_array( $display_value ); |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | $conditionally_add = array( 'include_fields', 'fields', 'exclude_fields' ); |
| 162 | 162 | foreach ( $conditionally_add as $index ) { |
| 163 | - if ( isset( $atts[ $index ] ) ) { |
|
| 164 | - $entry_atts[ $index ] = $atts[ $index ]; |
|
| 163 | + if ( isset( $atts[$index] ) ) { |
|
| 164 | + $entry_atts[$index] = $atts[$index]; |
|
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | |
@@ -473,10 +473,10 @@ discard block |
||
| 473 | 473 | if ( $this->include_field_in_content( $field_value ) ) { |
| 474 | 474 | |
| 475 | 475 | $displayed_value = $this->prepare_display_value_for_array( $field_value->get_displayed_value() ); |
| 476 | - $output[ $this->get_key_or_id( $field_value ) ] = $displayed_value; |
|
| 476 | + $output[$this->get_key_or_id( $field_value )] = $displayed_value; |
|
| 477 | 477 | |
| 478 | 478 | if ( $displayed_value !== $field_value->get_saved_value() ) { |
| 479 | - $output[ $this->get_key_or_id( $field_value ) . '-value' ] = $field_value->get_saved_value(); |
|
| 479 | + $output[$this->get_key_or_id( $field_value ) . '-value'] = $field_value->get_saved_value(); |
|
| 480 | 480 | } |
| 481 | 481 | } |
| 482 | 482 | } |
@@ -864,7 +864,7 @@ discard block |
||
| 864 | 864 | |
| 865 | 865 | if ( is_array( $value ) ) { |
| 866 | 866 | foreach ( $value as $key => $single_value ) { |
| 867 | - $value[ $key ] = $this->strip_html( $single_value ); |
|
| 867 | + $value[$key] = $this->strip_html( $single_value ); |
|
| 868 | 868 | } |
| 869 | 869 | } else if ( $this->is_plain_text && ! is_array( $value ) ) { |
| 870 | 870 | if ( strpos( $value, '<img' ) !== false ) { |
@@ -102,6 +102,7 @@ |
||
| 102 | 102 | |
| 103 | 103 | /** |
| 104 | 104 | * @since 3.0 |
| 105 | + * @param string $property |
|
| 105 | 106 | */ |
| 106 | 107 | public static function field_has_property( $type, $property ) { |
| 107 | 108 | $field = self::get_field_type( $type ); |
@@ -86,7 +86,7 @@ |
||
| 86 | 86 | 'captcha' => 'FrmFieldCaptcha', |
| 87 | 87 | ); |
| 88 | 88 | |
| 89 | - $class = isset( $type_classes[ $field_type ] ) ? $type_classes[ $field_type ] : ''; |
|
| 89 | + $class = isset( $type_classes[$field_type] ) ? $type_classes[$field_type] : ''; |
|
| 90 | 90 | return apply_filters( 'frm_get_field_type_class', $class, $field_type ); |
| 91 | 91 | } |
| 92 | 92 | |
@@ -57,6 +57,9 @@ discard block |
||
| 57 | 57 | return get_option('blogname'); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | + /** |
|
| 61 | + * @param string $url |
|
| 62 | + */ |
|
| 60 | 63 | public static function make_affiliate_url( $url ) { |
| 61 | 64 | $affiliate_id = self::get_affiliate(); |
| 62 | 65 | if ( ! empty( $affiliate_id ) ) { |
@@ -349,7 +352,7 @@ discard block |
||
| 349 | 352 | * Sanitize the value, and allow some HTML |
| 350 | 353 | * @since 2.0 |
| 351 | 354 | * @param string $value |
| 352 | - * @param array $allowed |
|
| 355 | + * @param string[] $allowed |
|
| 353 | 356 | * @return string |
| 354 | 357 | */ |
| 355 | 358 | public static function kses( $value, $allowed = array() ) { |
@@ -477,6 +480,7 @@ discard block |
||
| 477 | 480 | /** |
| 478 | 481 | * Keep track of the keys cached in each group so they can be deleted |
| 479 | 482 | * in Redis and Memcache |
| 483 | + * @param string $group |
|
| 480 | 484 | */ |
| 481 | 485 | public static function add_key_to_group_cache( $key, $group ) { |
| 482 | 486 | $cached = self::get_group_cached_keys( $group ); |
@@ -752,6 +756,9 @@ discard block |
||
| 752 | 756 | return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current ); |
| 753 | 757 | } |
| 754 | 758 | |
| 759 | + /** |
|
| 760 | + * @param string $function |
|
| 761 | + */ |
|
| 755 | 762 | public static function recursive_function_map( $value, $function ) { |
| 756 | 763 | if ( is_array( $value ) ) { |
| 757 | 764 | $original_function = $function; |
@@ -799,6 +806,9 @@ discard block |
||
| 799 | 806 | return $return; |
| 800 | 807 | } |
| 801 | 808 | |
| 809 | + /** |
|
| 810 | + * @return string |
|
| 811 | + */ |
|
| 802 | 812 | public static function esc_textarea( $text, $is_rich_text = false ) { |
| 803 | 813 | $safe_text = str_replace( '"', '"', $text ); |
| 804 | 814 | if ( ! $is_rich_text ) { |
@@ -973,6 +983,9 @@ discard block |
||
| 973 | 983 | return $values; |
| 974 | 984 | } |
| 975 | 985 | |
| 986 | + /** |
|
| 987 | + * @param string $fields |
|
| 988 | + */ |
|
| 976 | 989 | private static function prepare_field_arrays( $fields, $record, array &$values, $args ) { |
| 977 | 990 | if ( ! empty( $fields ) ) { |
| 978 | 991 | foreach ( (array) $fields as $field ) { |
@@ -1183,6 +1196,9 @@ discard block |
||
| 1183 | 1196 | return $sub . (($len < $original_len) ? $continue : ''); |
| 1184 | 1197 | } |
| 1185 | 1198 | |
| 1199 | + /** |
|
| 1200 | + * @param string[] $function_names |
|
| 1201 | + */ |
|
| 1186 | 1202 | public static function mb_function( $function_names, $args ) { |
| 1187 | 1203 | $mb_function_name = $function_names[0]; |
| 1188 | 1204 | $function_name = $function_names[1]; |
@@ -1216,6 +1232,9 @@ discard block |
||
| 1216 | 1232 | return $formatted; |
| 1217 | 1233 | } |
| 1218 | 1234 | |
| 1235 | + /** |
|
| 1236 | + * @param string $time_format |
|
| 1237 | + */ |
|
| 1219 | 1238 | private static function add_time_to_date( $time_format, $date ) { |
| 1220 | 1239 | if ( empty( $time_format ) ) { |
| 1221 | 1240 | $time_format = get_option('time_format'); |
@@ -12,50 +12,50 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | public static $plug_version = '2.05.01'; |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @since 1.07.02 |
|
| 17 | - * |
|
| 18 | - * @param none |
|
| 19 | - * @return string The version of this plugin |
|
| 20 | - */ |
|
| 21 | - public static function plugin_version() { |
|
| 22 | - return self::$plug_version; |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - public static function plugin_folder() { |
|
| 26 | - return basename(self::plugin_path()); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - public static function plugin_path() { |
|
| 30 | - return dirname(dirname(dirname(__FILE__))); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - public static function plugin_url() { |
|
| 34 | - //prevously FRM_URL constant |
|
| 15 | + /** |
|
| 16 | + * @since 1.07.02 |
|
| 17 | + * |
|
| 18 | + * @param none |
|
| 19 | + * @return string The version of this plugin |
|
| 20 | + */ |
|
| 21 | + public static function plugin_version() { |
|
| 22 | + return self::$plug_version; |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + public static function plugin_folder() { |
|
| 26 | + return basename(self::plugin_path()); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + public static function plugin_path() { |
|
| 30 | + return dirname(dirname(dirname(__FILE__))); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + public static function plugin_url() { |
|
| 34 | + //prevously FRM_URL constant |
|
| 35 | 35 | return plugins_url( '', self::plugin_path() . '/formidable.php' ); |
| 36 | - } |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | 38 | public static function relative_plugin_url() { |
| 39 | 39 | return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() ); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @return string Site URL |
|
| 44 | - */ |
|
| 45 | - public static function site_url() { |
|
| 46 | - return site_url(); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * Get the name of this site |
|
| 51 | - * Used for [sitename] shortcode |
|
| 52 | - * |
|
| 53 | - * @since 2.0 |
|
| 54 | - * @return string |
|
| 55 | - */ |
|
| 56 | - public static function site_name() { |
|
| 57 | - return get_option('blogname'); |
|
| 58 | - } |
|
| 42 | + /** |
|
| 43 | + * @return string Site URL |
|
| 44 | + */ |
|
| 45 | + public static function site_url() { |
|
| 46 | + return site_url(); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * Get the name of this site |
|
| 51 | + * Used for [sitename] shortcode |
|
| 52 | + * |
|
| 53 | + * @since 2.0 |
|
| 54 | + * @return string |
|
| 55 | + */ |
|
| 56 | + public static function site_name() { |
|
| 57 | + return get_option('blogname'); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | 60 | public static function make_affiliate_url( $url ) { |
| 61 | 61 | $affiliate_id = self::get_affiliate(); |
@@ -69,21 +69,21 @@ discard block |
||
| 69 | 69 | return ''; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * Get the Formidable settings |
|
| 74 | - * |
|
| 75 | - * @since 2.0 |
|
| 76 | - * |
|
| 77 | - * @param None |
|
| 78 | - * @return FrmSettings $frm_setings |
|
| 79 | - */ |
|
| 80 | - public static function get_settings() { |
|
| 81 | - global $frm_settings; |
|
| 82 | - if ( empty($frm_settings) ) { |
|
| 83 | - $frm_settings = new FrmSettings(); |
|
| 84 | - } |
|
| 85 | - return $frm_settings; |
|
| 86 | - } |
|
| 72 | + /** |
|
| 73 | + * Get the Formidable settings |
|
| 74 | + * |
|
| 75 | + * @since 2.0 |
|
| 76 | + * |
|
| 77 | + * @param None |
|
| 78 | + * @return FrmSettings $frm_setings |
|
| 79 | + */ |
|
| 80 | + public static function get_settings() { |
|
| 81 | + global $frm_settings; |
|
| 82 | + if ( empty($frm_settings) ) { |
|
| 83 | + $frm_settings = new FrmSettings(); |
|
| 84 | + } |
|
| 85 | + return $frm_settings; |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | 88 | public static function get_menu_name() { |
| 89 | 89 | $frm_settings = FrmAppHelper::get_settings(); |
@@ -98,54 +98,54 @@ discard block |
||
| 98 | 98 | return ! $frm_settings->no_ips; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - public static function pro_is_installed() { |
|
| 102 | - return apply_filters('frm_pro_installed', false); |
|
| 103 | - } |
|
| 101 | + public static function pro_is_installed() { |
|
| 102 | + return apply_filters('frm_pro_installed', false); |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * Check for certain page in Formidable settings |
|
| 107 | - * |
|
| 108 | - * @since 2.0 |
|
| 109 | - * |
|
| 110 | - * @param string $page The name of the page to check |
|
| 111 | - * @return boolean |
|
| 112 | - */ |
|
| 105 | + /** |
|
| 106 | + * Check for certain page in Formidable settings |
|
| 107 | + * |
|
| 108 | + * @since 2.0 |
|
| 109 | + * |
|
| 110 | + * @param string $page The name of the page to check |
|
| 111 | + * @return boolean |
|
| 112 | + */ |
|
| 113 | 113 | public static function is_admin_page( $page = 'formidable' ) { |
| 114 | - global $pagenow; |
|
| 114 | + global $pagenow; |
|
| 115 | 115 | $get_page = self::simple_get( 'page', 'sanitize_title' ); |
| 116 | - if ( $pagenow ) { |
|
| 116 | + if ( $pagenow ) { |
|
| 117 | 117 | // allow this to be true during ajax load i.e. ajax form builder loading |
| 118 | 118 | return ( $pagenow == 'admin.php' || $pagenow == 'admin-ajax.php' ) && $get_page == $page; |
| 119 | - } |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | 121 | return is_admin() && $get_page == $page; |
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * Check for the form preview page |
|
| 126 | - * |
|
| 127 | - * @since 2.0 |
|
| 128 | - * |
|
| 129 | - * @param None |
|
| 130 | - * @return boolean |
|
| 131 | - */ |
|
| 132 | - public static function is_preview_page() { |
|
| 133 | - global $pagenow; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * Check for the form preview page |
|
| 126 | + * |
|
| 127 | + * @since 2.0 |
|
| 128 | + * |
|
| 129 | + * @param None |
|
| 130 | + * @return boolean |
|
| 131 | + */ |
|
| 132 | + public static function is_preview_page() { |
|
| 133 | + global $pagenow; |
|
| 134 | 134 | $action = FrmAppHelper::simple_get( 'action', 'sanitize_title' ); |
| 135 | 135 | return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview'; |
| 136 | - } |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * Check for ajax except the form preview page |
|
| 140 | - * |
|
| 141 | - * @since 2.0 |
|
| 142 | - * |
|
| 143 | - * @param None |
|
| 144 | - * @return boolean |
|
| 145 | - */ |
|
| 146 | - public static function doing_ajax() { |
|
| 147 | - return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
| 148 | - } |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * Check for ajax except the form preview page |
|
| 140 | + * |
|
| 141 | + * @since 2.0 |
|
| 142 | + * |
|
| 143 | + * @param None |
|
| 144 | + * @return boolean |
|
| 145 | + */ |
|
| 146 | + public static function doing_ajax() { |
|
| 147 | + return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | 150 | /** |
| 151 | 151 | * @since 2.0.8 |
@@ -155,102 +155,102 @@ discard block |
||
| 155 | 155 | return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching']; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - /** |
|
| 159 | - * Check if on an admin page |
|
| 160 | - * |
|
| 161 | - * @since 2.0 |
|
| 162 | - * |
|
| 163 | - * @param None |
|
| 164 | - * @return boolean |
|
| 165 | - */ |
|
| 166 | - public static function is_admin() { |
|
| 167 | - return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * Check if value contains blank value or empty array |
|
| 172 | - * |
|
| 173 | - * @since 2.0 |
|
| 174 | - * @param mixed $value - value to check |
|
| 158 | + /** |
|
| 159 | + * Check if on an admin page |
|
| 160 | + * |
|
| 161 | + * @since 2.0 |
|
| 162 | + * |
|
| 163 | + * @param None |
|
| 164 | + * @return boolean |
|
| 165 | + */ |
|
| 166 | + public static function is_admin() { |
|
| 167 | + return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * Check if value contains blank value or empty array |
|
| 172 | + * |
|
| 173 | + * @since 2.0 |
|
| 174 | + * @param mixed $value - value to check |
|
| 175 | 175 | * @param string |
| 176 | - * @return boolean |
|
| 177 | - */ |
|
| 178 | - public static function is_empty_value( $value, $empty = '' ) { |
|
| 179 | - return ( is_array( $value ) && empty( $value ) ) || $value === $empty; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 183 | - return ! self::is_empty_value( $value, $empty ); |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * Get any value from the $_SERVER |
|
| 188 | - * |
|
| 189 | - * @since 2.0 |
|
| 190 | - * @param string $value |
|
| 191 | - * @return string |
|
| 192 | - */ |
|
| 176 | + * @return boolean |
|
| 177 | + */ |
|
| 178 | + public static function is_empty_value( $value, $empty = '' ) { |
|
| 179 | + return ( is_array( $value ) && empty( $value ) ) || $value === $empty; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 183 | + return ! self::is_empty_value( $value, $empty ); |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * Get any value from the $_SERVER |
|
| 188 | + * |
|
| 189 | + * @since 2.0 |
|
| 190 | + * @param string $value |
|
| 191 | + * @return string |
|
| 192 | + */ |
|
| 193 | 193 | public static function get_server_value( $value ) { |
| 194 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - /** |
|
| 198 | - * Check for the IP address in several places |
|
| 199 | - * Used by [ip] shortcode |
|
| 200 | - * |
|
| 201 | - * @return string The IP address of the current user |
|
| 202 | - */ |
|
| 203 | - public static function get_ip_address() { |
|
| 194 | + return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + /** |
|
| 198 | + * Check for the IP address in several places |
|
| 199 | + * Used by [ip] shortcode |
|
| 200 | + * |
|
| 201 | + * @return string The IP address of the current user |
|
| 202 | + */ |
|
| 203 | + public static function get_ip_address() { |
|
| 204 | 204 | $ip = ''; |
| 205 | - foreach ( array( |
|
| 206 | - 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
|
| 207 | - 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
|
| 208 | - ) as $key ) { |
|
| 209 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 210 | - continue; |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 214 | - $ip = trim($ip); // just to be safe |
|
| 215 | - |
|
| 216 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
| 217 | - return $ip; |
|
| 218 | - } |
|
| 219 | - } |
|
| 220 | - } |
|
| 205 | + foreach ( array( |
|
| 206 | + 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
|
| 207 | + 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
|
| 208 | + ) as $key ) { |
|
| 209 | + if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 210 | + continue; |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 214 | + $ip = trim($ip); // just to be safe |
|
| 215 | + |
|
| 216 | + if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
| 217 | + return $ip; |
|
| 218 | + } |
|
| 219 | + } |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | 222 | return sanitize_text_field( $ip ); |
| 223 | - } |
|
| 223 | + } |
|
| 224 | 224 | |
| 225 | - public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 226 | - if ( strpos($param, '[') ) { |
|
| 227 | - $params = explode('[', $param); |
|
| 228 | - $param = $params[0]; |
|
| 229 | - } |
|
| 225 | + public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 226 | + if ( strpos($param, '[') ) { |
|
| 227 | + $params = explode('[', $param); |
|
| 228 | + $param = $params[0]; |
|
| 229 | + } |
|
| 230 | 230 | |
| 231 | 231 | if ( $src == 'get' ) { |
| 232 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 233 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 234 | - $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 235 | - } |
|
| 232 | + $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 233 | + if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 234 | + $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 235 | + } |
|
| 236 | 236 | self::sanitize_value( $sanitize, $value ); |
| 237 | 237 | } else { |
| 238 | - $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
|
| 239 | - } |
|
| 238 | + $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | 241 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
| 242 | - foreach ( $params as $k => $p ) { |
|
| 243 | - if ( ! $k || ! is_array($value) ) { |
|
| 244 | - continue; |
|
| 245 | - } |
|
| 242 | + foreach ( $params as $k => $p ) { |
|
| 243 | + if ( ! $k || ! is_array($value) ) { |
|
| 244 | + continue; |
|
| 245 | + } |
|
| 246 | 246 | |
| 247 | - $p = trim($p, ']'); |
|
| 248 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
| 249 | - } |
|
| 250 | - } |
|
| 247 | + $p = trim($p, ']'); |
|
| 248 | + $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
| 249 | + } |
|
| 250 | + } |
|
| 251 | 251 | |
| 252 | - return $value; |
|
| 253 | - } |
|
| 252 | + return $value; |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | 255 | public static function get_post_param( $param, $default = '', $sanitize = '' ) { |
| 256 | 256 | return self::get_simple_request( array( 'type' => 'post', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | */ |
| 267 | 267 | public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) { |
| 268 | 268 | return self::get_simple_request( array( 'type' => 'get', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
| 269 | - } |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | 271 | /** |
| 272 | 272 | * Get a GET/POST/REQUEST value and sanitize it |
@@ -302,12 +302,12 @@ discard block |
||
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /** |
| 305 | - * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 306 | - * |
|
| 307 | - * @since 2.0.8 |
|
| 308 | - * @param string $value |
|
| 309 | - * @return string $value |
|
| 310 | - */ |
|
| 305 | + * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 306 | + * |
|
| 307 | + * @since 2.0.8 |
|
| 308 | + * @param string $value |
|
| 309 | + * @return string $value |
|
| 310 | + */ |
|
| 311 | 311 | public static function preserve_backslashes( $value ) { |
| 312 | 312 | // If backslashes have already been added, don't add them again |
| 313 | 313 | if ( strpos( $value, '\\\\' ) === false ) { |
@@ -329,14 +329,14 @@ discard block |
||
| 329 | 329 | } |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 333 | - $temp_values = $values; |
|
| 334 | - foreach ( $temp_values as $k => $val ) { |
|
| 335 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 332 | + public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 333 | + $temp_values = $values; |
|
| 334 | + foreach ( $temp_values as $k => $val ) { |
|
| 335 | + if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 336 | 336 | $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
| 337 | - } |
|
| 338 | - } |
|
| 339 | - } |
|
| 337 | + } |
|
| 338 | + } |
|
| 339 | + } |
|
| 340 | 340 | |
| 341 | 341 | public static function sanitize_array( &$values ) { |
| 342 | 342 | $temp_values = $values; |
@@ -354,12 +354,12 @@ discard block |
||
| 354 | 354 | */ |
| 355 | 355 | public static function kses( $value, $allowed = array() ) { |
| 356 | 356 | $html = array( |
| 357 | - 'a' => array( |
|
| 357 | + 'a' => array( |
|
| 358 | 358 | 'href' => array(), |
| 359 | 359 | 'title' => array(), |
| 360 | 360 | 'id' => array(), |
| 361 | 361 | 'class' => array(), |
| 362 | - ), |
|
| 362 | + ), |
|
| 363 | 363 | ); |
| 364 | 364 | |
| 365 | 365 | $allowed_html = array(); |
@@ -370,50 +370,50 @@ discard block |
||
| 370 | 370 | return wp_kses( $value, $allowed_html ); |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - /** |
|
| 374 | - * Used when switching the action for a bulk action |
|
| 375 | - * @since 2.0 |
|
| 376 | - */ |
|
| 377 | - public static function remove_get_action() { |
|
| 378 | - if ( ! isset($_GET) ) { |
|
| 379 | - return; |
|
| 380 | - } |
|
| 373 | + /** |
|
| 374 | + * Used when switching the action for a bulk action |
|
| 375 | + * @since 2.0 |
|
| 376 | + */ |
|
| 377 | + public static function remove_get_action() { |
|
| 378 | + if ( ! isset($_GET) ) { |
|
| 379 | + return; |
|
| 380 | + } |
|
| 381 | 381 | |
| 382 | - $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 383 | - if ( ! empty( $new_action ) ) { |
|
| 382 | + $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 383 | + if ( ! empty( $new_action ) ) { |
|
| 384 | 384 | $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); |
| 385 | - } |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - /** |
|
| 389 | - * Check the WP query for a parameter |
|
| 390 | - * |
|
| 391 | - * @since 2.0 |
|
| 392 | - * @return string|array |
|
| 393 | - */ |
|
| 394 | - public static function get_query_var( $value, $param ) { |
|
| 395 | - if ( $value != '' ) { |
|
| 396 | - return $value; |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - global $wp_query; |
|
| 400 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 401 | - $value = $wp_query->query_vars[ $param ]; |
|
| 402 | - } |
|
| 403 | - |
|
| 404 | - return $value; |
|
| 405 | - } |
|
| 406 | - |
|
| 407 | - /** |
|
| 408 | - * @param string $type |
|
| 409 | - */ |
|
| 410 | - public static function trigger_hook_load( $type, $object = null ) { |
|
| 411 | - // only load the form hooks once |
|
| 385 | + } |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + /** |
|
| 389 | + * Check the WP query for a parameter |
|
| 390 | + * |
|
| 391 | + * @since 2.0 |
|
| 392 | + * @return string|array |
|
| 393 | + */ |
|
| 394 | + public static function get_query_var( $value, $param ) { |
|
| 395 | + if ( $value != '' ) { |
|
| 396 | + return $value; |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + global $wp_query; |
|
| 400 | + if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 401 | + $value = $wp_query->query_vars[ $param ]; |
|
| 402 | + } |
|
| 403 | + |
|
| 404 | + return $value; |
|
| 405 | + } |
|
| 406 | + |
|
| 407 | + /** |
|
| 408 | + * @param string $type |
|
| 409 | + */ |
|
| 410 | + public static function trigger_hook_load( $type, $object = null ) { |
|
| 411 | + // only load the form hooks once |
|
| 412 | 412 | $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object ); |
| 413 | - if ( ! $hooks_loaded ) { |
|
| 413 | + if ( ! $hooks_loaded ) { |
|
| 414 | 414 | do_action( 'frm_load_' . $type . '_hooks' ); |
| 415 | - } |
|
| 416 | - } |
|
| 415 | + } |
|
| 416 | + } |
|
| 417 | 417 | |
| 418 | 418 | /** |
| 419 | 419 | * Save all front-end js scripts into a single file |
@@ -435,32 +435,32 @@ discard block |
||
| 435 | 435 | $new_file->combine_files( $files ); |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | - /** |
|
| 439 | - * Check cache before fetching values and saving to cache |
|
| 440 | - * |
|
| 441 | - * @since 2.0 |
|
| 442 | - * |
|
| 443 | - * @param string $cache_key The unique name for this cache |
|
| 444 | - * @param string $group The name of the cache group |
|
| 445 | - * @param string $query If blank, don't run a db call |
|
| 446 | - * @param string $type The wpdb function to use with this query |
|
| 447 | - * @return mixed $results The cache or query results |
|
| 448 | - */ |
|
| 449 | - public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
|
| 450 | - $results = wp_cache_get($cache_key, $group); |
|
| 451 | - if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
| 452 | - return $results; |
|
| 453 | - } |
|
| 454 | - |
|
| 455 | - if ( 'get_posts' == $type ) { |
|
| 456 | - $results = get_posts($query); |
|
| 438 | + /** |
|
| 439 | + * Check cache before fetching values and saving to cache |
|
| 440 | + * |
|
| 441 | + * @since 2.0 |
|
| 442 | + * |
|
| 443 | + * @param string $cache_key The unique name for this cache |
|
| 444 | + * @param string $group The name of the cache group |
|
| 445 | + * @param string $query If blank, don't run a db call |
|
| 446 | + * @param string $type The wpdb function to use with this query |
|
| 447 | + * @return mixed $results The cache or query results |
|
| 448 | + */ |
|
| 449 | + public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
|
| 450 | + $results = wp_cache_get($cache_key, $group); |
|
| 451 | + if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
| 452 | + return $results; |
|
| 453 | + } |
|
| 454 | + |
|
| 455 | + if ( 'get_posts' == $type ) { |
|
| 456 | + $results = get_posts($query); |
|
| 457 | 457 | } else if ( 'get_associative_results' == $type ) { |
| 458 | 458 | global $wpdb; |
| 459 | 459 | $results = $wpdb->get_results( $query, OBJECT_K ); |
| 460 | - } else { |
|
| 461 | - global $wpdb; |
|
| 462 | - $results = $wpdb->{$type}($query); |
|
| 463 | - } |
|
| 460 | + } else { |
|
| 461 | + global $wpdb; |
|
| 462 | + $results = $wpdb->{$type}($query); |
|
| 463 | + } |
|
| 464 | 464 | |
| 465 | 465 | self::set_cache( $cache_key, $results, $group, $time ); |
| 466 | 466 | |
@@ -493,44 +493,44 @@ discard block |
||
| 493 | 493 | return $cached; |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | - /** |
|
| 497 | - * Data that should be stored for a long time can be stored in a transient. |
|
| 498 | - * First check the cache, then check the transient |
|
| 499 | - * @since 2.0 |
|
| 500 | - * @return mixed The cached value or false |
|
| 501 | - */ |
|
| 496 | + /** |
|
| 497 | + * Data that should be stored for a long time can be stored in a transient. |
|
| 498 | + * First check the cache, then check the transient |
|
| 499 | + * @since 2.0 |
|
| 500 | + * @return mixed The cached value or false |
|
| 501 | + */ |
|
| 502 | 502 | public static function check_cache_and_transient( $cache_key ) { |
| 503 | - // check caching layer first |
|
| 504 | - $results = self::check_cache( $cache_key ); |
|
| 505 | - if ( $results ) { |
|
| 506 | - return $results; |
|
| 507 | - } |
|
| 508 | - |
|
| 509 | - // then check the transient |
|
| 510 | - $results = get_transient($cache_key); |
|
| 511 | - if ( $results ) { |
|
| 512 | - wp_cache_set($cache_key, $results); |
|
| 513 | - } |
|
| 514 | - |
|
| 515 | - return $results; |
|
| 516 | - } |
|
| 517 | - |
|
| 518 | - /** |
|
| 519 | - * @since 2.0 |
|
| 520 | - * @param string $cache_key |
|
| 521 | - */ |
|
| 503 | + // check caching layer first |
|
| 504 | + $results = self::check_cache( $cache_key ); |
|
| 505 | + if ( $results ) { |
|
| 506 | + return $results; |
|
| 507 | + } |
|
| 508 | + |
|
| 509 | + // then check the transient |
|
| 510 | + $results = get_transient($cache_key); |
|
| 511 | + if ( $results ) { |
|
| 512 | + wp_cache_set($cache_key, $results); |
|
| 513 | + } |
|
| 514 | + |
|
| 515 | + return $results; |
|
| 516 | + } |
|
| 517 | + |
|
| 518 | + /** |
|
| 519 | + * @since 2.0 |
|
| 520 | + * @param string $cache_key |
|
| 521 | + */ |
|
| 522 | 522 | public static function delete_cache_and_transient( $cache_key, $group = 'default' ) { |
| 523 | 523 | delete_transient($cache_key); |
| 524 | 524 | wp_cache_delete( $cache_key, $group ); |
| 525 | 525 | } |
| 526 | 526 | |
| 527 | - /** |
|
| 528 | - * Delete all caching in a single group |
|
| 529 | - * |
|
| 530 | - * @since 2.0 |
|
| 531 | - * |
|
| 532 | - * @param string $group The name of the cache group |
|
| 533 | - */ |
|
| 527 | + /** |
|
| 528 | + * Delete all caching in a single group |
|
| 529 | + * |
|
| 530 | + * @since 2.0 |
|
| 531 | + * |
|
| 532 | + * @param string $group The name of the cache group |
|
| 533 | + */ |
|
| 534 | 534 | public static function cache_delete_group( $group ) { |
| 535 | 535 | $cached_keys = self::get_group_cached_keys( $group ); |
| 536 | 536 | |
@@ -543,34 +543,34 @@ discard block |
||
| 543 | 543 | } |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | - /** |
|
| 547 | - * Check a value from a shortcode to see if true or false. |
|
| 548 | - * True when value is 1, true, 'true', 'yes' |
|
| 549 | - * |
|
| 550 | - * @since 1.07.10 |
|
| 551 | - * |
|
| 552 | - * @param string $value The value to compare |
|
| 553 | - * @return boolean True or False |
|
| 554 | - */ |
|
| 546 | + /** |
|
| 547 | + * Check a value from a shortcode to see if true or false. |
|
| 548 | + * True when value is 1, true, 'true', 'yes' |
|
| 549 | + * |
|
| 550 | + * @since 1.07.10 |
|
| 551 | + * |
|
| 552 | + * @param string $value The value to compare |
|
| 553 | + * @return boolean True or False |
|
| 554 | + */ |
|
| 555 | 555 | public static function is_true( $value ) { |
| 556 | - return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 557 | - } |
|
| 556 | + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 557 | + } |
|
| 558 | 558 | |
| 559 | - /** |
|
| 560 | - * Used to filter shortcode in text widgets |
|
| 561 | - */ |
|
| 562 | - public static function widget_text_filter_callback( $matches ) { |
|
| 563 | - return do_shortcode( $matches[0] ); |
|
| 564 | - } |
|
| 559 | + /** |
|
| 560 | + * Used to filter shortcode in text widgets |
|
| 561 | + */ |
|
| 562 | + public static function widget_text_filter_callback( $matches ) { |
|
| 563 | + return do_shortcode( $matches[0] ); |
|
| 564 | + } |
|
| 565 | 565 | |
| 566 | - public static function get_pages() { |
|
| 566 | + public static function get_pages() { |
|
| 567 | 567 | return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
| 568 | - } |
|
| 568 | + } |
|
| 569 | 569 | |
| 570 | - public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 571 | - $pages = self::get_pages(); |
|
| 570 | + public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 571 | + $pages = self::get_pages(); |
|
| 572 | 572 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
| 573 | - ?> |
|
| 573 | + ?> |
|
| 574 | 574 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
| 575 | 575 | <option value=""> </option> |
| 576 | 576 | <?php foreach ( $pages as $page ) { ?> |
@@ -580,108 +580,108 @@ discard block |
||
| 580 | 580 | <?php } ?> |
| 581 | 581 | </select> |
| 582 | 582 | <?php |
| 583 | - } |
|
| 583 | + } |
|
| 584 | 584 | |
| 585 | 585 | public static function post_edit_link( $post_id ) { |
| 586 | - $post = get_post($post_id); |
|
| 587 | - if ( $post ) { |
|
| 586 | + $post = get_post($post_id); |
|
| 587 | + if ( $post ) { |
|
| 588 | 588 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
| 589 | 589 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
| 590 | - } |
|
| 591 | - return ''; |
|
| 592 | - } |
|
| 590 | + } |
|
| 591 | + return ''; |
|
| 592 | + } |
|
| 593 | 593 | |
| 594 | 594 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
| 595 | - ?> |
|
| 595 | + ?> |
|
| 596 | 596 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php |
| 597 | - echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
|
| 598 | - ?> class="frm_multiselect"> |
|
| 597 | + echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
|
| 598 | + ?> class="frm_multiselect"> |
|
| 599 | 599 | <?php self::roles_options($capability); ?> |
| 600 | 600 | </select> |
| 601 | 601 | <?php |
| 602 | - } |
|
| 602 | + } |
|
| 603 | 603 | |
| 604 | 604 | public static function roles_options( $capability ) { |
| 605 | - global $frm_vars; |
|
| 606 | - if ( isset($frm_vars['editable_roles']) ) { |
|
| 607 | - $editable_roles = $frm_vars['editable_roles']; |
|
| 608 | - } else { |
|
| 609 | - $editable_roles = get_editable_roles(); |
|
| 610 | - $frm_vars['editable_roles'] = $editable_roles; |
|
| 611 | - } |
|
| 612 | - |
|
| 613 | - foreach ( $editable_roles as $role => $details ) { |
|
| 614 | - $name = translate_user_role($details['name'] ); ?> |
|
| 605 | + global $frm_vars; |
|
| 606 | + if ( isset($frm_vars['editable_roles']) ) { |
|
| 607 | + $editable_roles = $frm_vars['editable_roles']; |
|
| 608 | + } else { |
|
| 609 | + $editable_roles = get_editable_roles(); |
|
| 610 | + $frm_vars['editable_roles'] = $editable_roles; |
|
| 611 | + } |
|
| 612 | + |
|
| 613 | + foreach ( $editable_roles as $role => $details ) { |
|
| 614 | + $name = translate_user_role($details['name'] ); ?> |
|
| 615 | 615 | <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
| 616 | 616 | <?php |
| 617 | - unset($role, $details); |
|
| 618 | - } |
|
| 619 | - } |
|
| 617 | + unset($role, $details); |
|
| 618 | + } |
|
| 619 | + } |
|
| 620 | 620 | |
| 621 | 621 | public static function frm_capabilities( $type = 'auto' ) { |
| 622 | - $cap = array( |
|
| 623 | - 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 624 | - 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 625 | - 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 626 | - 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 627 | - 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 628 | - 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 629 | - ); |
|
| 622 | + $cap = array( |
|
| 623 | + 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 624 | + 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 625 | + 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 626 | + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 627 | + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 628 | + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 629 | + ); |
|
| 630 | 630 | |
| 631 | 631 | if ( ! self::pro_is_installed() && 'pro' != $type ) { |
| 632 | - return $cap; |
|
| 633 | - } |
|
| 632 | + return $cap; |
|
| 633 | + } |
|
| 634 | 634 | |
| 635 | - $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 636 | - $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 637 | - $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 638 | - $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 635 | + $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 636 | + $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 637 | + $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 638 | + $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 639 | 639 | |
| 640 | - return $cap; |
|
| 641 | - } |
|
| 640 | + return $cap; |
|
| 641 | + } |
|
| 642 | 642 | |
| 643 | 643 | public static function user_has_permission( $needed_role ) { |
| 644 | - if ( $needed_role == '-1' ) { |
|
| 645 | - return false; |
|
| 644 | + if ( $needed_role == '-1' ) { |
|
| 645 | + return false; |
|
| 646 | 646 | } |
| 647 | 647 | |
| 648 | - // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 649 | - if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 650 | - return true; |
|
| 651 | - } |
|
| 648 | + // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 649 | + if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 650 | + return true; |
|
| 651 | + } |
|
| 652 | 652 | |
| 653 | - $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 654 | - foreach ( $roles as $role ) { |
|
| 653 | + $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 654 | + foreach ( $roles as $role ) { |
|
| 655 | 655 | if ( current_user_can( $role ) ) { |
| 656 | - return true; |
|
| 656 | + return true; |
|
| 657 | 657 | } |
| 658 | - if ( $role == $needed_role ) { |
|
| 659 | - break; |
|
| 658 | + if ( $role == $needed_role ) { |
|
| 659 | + break; |
|
| 660 | 660 | } |
| 661 | - } |
|
| 662 | - return false; |
|
| 663 | - } |
|
| 664 | - |
|
| 665 | - /** |
|
| 666 | - * Make sure administrators can see Formidable menu |
|
| 667 | - * |
|
| 668 | - * @since 2.0 |
|
| 669 | - */ |
|
| 670 | - public static function maybe_add_permissions() { |
|
| 661 | + } |
|
| 662 | + return false; |
|
| 663 | + } |
|
| 664 | + |
|
| 665 | + /** |
|
| 666 | + * Make sure administrators can see Formidable menu |
|
| 667 | + * |
|
| 668 | + * @since 2.0 |
|
| 669 | + */ |
|
| 670 | + public static function maybe_add_permissions() { |
|
| 671 | 671 | self::force_capability( 'frm_view_entries' ); |
| 672 | 672 | |
| 673 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
| 674 | - return; |
|
| 675 | - } |
|
| 673 | + if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
| 674 | + return; |
|
| 675 | + } |
|
| 676 | 676 | |
| 677 | 677 | $user_id = get_current_user_id(); |
| 678 | 678 | $user = new WP_User( $user_id ); |
| 679 | - $frm_roles = self::frm_capabilities(); |
|
| 680 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 679 | + $frm_roles = self::frm_capabilities(); |
|
| 680 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 681 | 681 | $user->add_cap( $frm_role ); |
| 682 | - unset($frm_role, $frm_role_description); |
|
| 683 | - } |
|
| 684 | - } |
|
| 682 | + unset($frm_role, $frm_role_description); |
|
| 683 | + } |
|
| 684 | + } |
|
| 685 | 685 | |
| 686 | 686 | /** |
| 687 | 687 | * Make sure admins have permission to see the menu items |
@@ -697,28 +697,28 @@ discard block |
||
| 697 | 697 | } |
| 698 | 698 | } |
| 699 | 699 | |
| 700 | - /** |
|
| 701 | - * Check if the user has permision for action. |
|
| 702 | - * Return permission message and stop the action if no permission |
|
| 703 | - * @since 2.0 |
|
| 704 | - * @param string $permission |
|
| 705 | - */ |
|
| 700 | + /** |
|
| 701 | + * Check if the user has permision for action. |
|
| 702 | + * Return permission message and stop the action if no permission |
|
| 703 | + * @since 2.0 |
|
| 704 | + * @param string $permission |
|
| 705 | + */ |
|
| 706 | 706 | public static function permission_check( $permission, $show_message = 'show' ) { |
| 707 | - $permission_error = self::permission_nonce_error($permission); |
|
| 708 | - if ( $permission_error !== false ) { |
|
| 709 | - if ( 'hide' == $show_message ) { |
|
| 710 | - $permission_error = ''; |
|
| 711 | - } |
|
| 712 | - wp_die($permission_error); |
|
| 713 | - } |
|
| 714 | - } |
|
| 715 | - |
|
| 716 | - /** |
|
| 717 | - * Check user permission and nonce |
|
| 718 | - * @since 2.0 |
|
| 719 | - * @param string $permission |
|
| 720 | - * @return false|string The permission message or false if allowed |
|
| 721 | - */ |
|
| 707 | + $permission_error = self::permission_nonce_error($permission); |
|
| 708 | + if ( $permission_error !== false ) { |
|
| 709 | + if ( 'hide' == $show_message ) { |
|
| 710 | + $permission_error = ''; |
|
| 711 | + } |
|
| 712 | + wp_die($permission_error); |
|
| 713 | + } |
|
| 714 | + } |
|
| 715 | + |
|
| 716 | + /** |
|
| 717 | + * Check user permission and nonce |
|
| 718 | + * @since 2.0 |
|
| 719 | + * @param string $permission |
|
| 720 | + * @return false|string The permission message or false if allowed |
|
| 721 | + */ |
|
| 722 | 722 | public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) { |
| 723 | 723 | if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) { |
| 724 | 724 | $frm_settings = self::get_settings(); |
@@ -726,23 +726,23 @@ discard block |
||
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | $error = false; |
| 729 | - if ( empty($nonce_name) ) { |
|
| 730 | - return $error; |
|
| 731 | - } |
|
| 729 | + if ( empty($nonce_name) ) { |
|
| 730 | + return $error; |
|
| 731 | + } |
|
| 732 | 732 | |
| 733 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 734 | - $frm_settings = self::get_settings(); |
|
| 735 | - $error = $frm_settings->admin_permission; |
|
| 736 | - } |
|
| 733 | + if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 734 | + $frm_settings = self::get_settings(); |
|
| 735 | + $error = $frm_settings->admin_permission; |
|
| 736 | + } |
|
| 737 | 737 | |
| 738 | - return $error; |
|
| 739 | - } |
|
| 738 | + return $error; |
|
| 739 | + } |
|
| 740 | 740 | |
| 741 | - public static function checked( $values, $current ) { |
|
| 741 | + public static function checked( $values, $current ) { |
|
| 742 | 742 | if ( self::check_selected( $values, $current ) ) { |
| 743 | - echo ' checked="checked"'; |
|
| 743 | + echo ' checked="checked"'; |
|
| 744 | 744 | } |
| 745 | - } |
|
| 745 | + } |
|
| 746 | 746 | |
| 747 | 747 | public static function check_selected( $values, $current ) { |
| 748 | 748 | $values = self::recursive_function_map( $values, 'trim' ); |
@@ -780,24 +780,24 @@ discard block |
||
| 780 | 780 | return (bool) count( array_filter( array_keys( $array ), 'is_string' ) ); |
| 781 | 781 | } |
| 782 | 782 | |
| 783 | - /** |
|
| 784 | - * Flatten a multi-dimensional array |
|
| 785 | - */ |
|
| 783 | + /** |
|
| 784 | + * Flatten a multi-dimensional array |
|
| 785 | + */ |
|
| 786 | 786 | public static function array_flatten( $array, $keys = 'keep' ) { |
| 787 | - $return = array(); |
|
| 788 | - foreach ( $array as $key => $value ) { |
|
| 789 | - if ( is_array($value) ) { |
|
| 787 | + $return = array(); |
|
| 788 | + foreach ( $array as $key => $value ) { |
|
| 789 | + if ( is_array($value) ) { |
|
| 790 | 790 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
| 791 | - } else { |
|
| 791 | + } else { |
|
| 792 | 792 | if ( $keys == 'keep' ) { |
| 793 | 793 | $return[ $key ] = $value; |
| 794 | 794 | } else { |
| 795 | 795 | $return[] = $value; |
| 796 | 796 | } |
| 797 | - } |
|
| 798 | - } |
|
| 799 | - return $return; |
|
| 800 | - } |
|
| 797 | + } |
|
| 798 | + } |
|
| 799 | + return $return; |
|
| 800 | + } |
|
| 801 | 801 | |
| 802 | 802 | public static function esc_textarea( $text, $is_rich_text = false ) { |
| 803 | 803 | $safe_text = str_replace( '"', '"', $text ); |
@@ -808,38 +808,38 @@ discard block |
||
| 808 | 808 | return apply_filters( 'esc_textarea', $safe_text, $text ); |
| 809 | 809 | } |
| 810 | 810 | |
| 811 | - /** |
|
| 812 | - * Add auto paragraphs to text areas |
|
| 813 | - * @since 2.0 |
|
| 814 | - */ |
|
| 811 | + /** |
|
| 812 | + * Add auto paragraphs to text areas |
|
| 813 | + * @since 2.0 |
|
| 814 | + */ |
|
| 815 | 815 | public static function use_wpautop( $content ) { |
| 816 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
| 817 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
| 818 | - } |
|
| 819 | - return $content; |
|
| 820 | - } |
|
| 816 | + if ( apply_filters('frm_use_wpautop', true) ) { |
|
| 817 | + $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
| 818 | + } |
|
| 819 | + return $content; |
|
| 820 | + } |
|
| 821 | 821 | |
| 822 | 822 | public static function replace_quotes( $val ) { |
| 823 | - //Replace double quotes |
|
| 823 | + //Replace double quotes |
|
| 824 | 824 | $val = str_replace( array( '“', '”', '″' ), '"', $val ); |
| 825 | - //Replace single quotes |
|
| 826 | - $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 827 | - return $val; |
|
| 828 | - } |
|
| 829 | - |
|
| 830 | - /** |
|
| 831 | - * @since 2.0 |
|
| 832 | - * @return string The base Google APIS url for the current version of jQuery UI |
|
| 833 | - */ |
|
| 834 | - public static function jquery_ui_base_url() { |
|
| 825 | + //Replace single quotes |
|
| 826 | + $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 827 | + return $val; |
|
| 828 | + } |
|
| 829 | + |
|
| 830 | + /** |
|
| 831 | + * @since 2.0 |
|
| 832 | + * @return string The base Google APIS url for the current version of jQuery UI |
|
| 833 | + */ |
|
| 834 | + public static function jquery_ui_base_url() { |
|
| 835 | 835 | $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' ); |
| 836 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
| 837 | - return $url; |
|
| 838 | - } |
|
| 836 | + $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
| 837 | + return $url; |
|
| 838 | + } |
|
| 839 | 839 | |
| 840 | - /** |
|
| 841 | - * @param string $handle |
|
| 842 | - */ |
|
| 840 | + /** |
|
| 841 | + * @param string $handle |
|
| 842 | + */ |
|
| 843 | 843 | public static function script_version( $handle, $default = 0 ) { |
| 844 | 844 | global $wp_scripts; |
| 845 | 845 | if ( ! $wp_scripts ) { |
@@ -861,117 +861,117 @@ discard block |
||
| 861 | 861 | |
| 862 | 862 | public static function js_redirect( $url ) { |
| 863 | 863 | return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>'; |
| 864 | - } |
|
| 864 | + } |
|
| 865 | 865 | |
| 866 | 866 | public static function get_user_id_param( $user_id ) { |
| 867 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
| 868 | - return $user_id; |
|
| 869 | - } |
|
| 867 | + if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
| 868 | + return $user_id; |
|
| 869 | + } |
|
| 870 | 870 | |
| 871 | 871 | if ( $user_id == 'current' ) { |
| 872 | 872 | $user_id = get_current_user_id(); |
| 873 | 873 | } else { |
| 874 | - if ( is_email($user_id) ) { |
|
| 875 | - $user = get_user_by('email', $user_id); |
|
| 876 | - } else { |
|
| 877 | - $user = get_user_by('login', $user_id); |
|
| 878 | - } |
|
| 874 | + if ( is_email($user_id) ) { |
|
| 875 | + $user = get_user_by('email', $user_id); |
|
| 876 | + } else { |
|
| 877 | + $user = get_user_by('login', $user_id); |
|
| 878 | + } |
|
| 879 | 879 | |
| 880 | - if ( $user ) { |
|
| 881 | - $user_id = $user->ID; |
|
| 882 | - } |
|
| 883 | - unset($user); |
|
| 884 | - } |
|
| 880 | + if ( $user ) { |
|
| 881 | + $user_id = $user->ID; |
|
| 882 | + } |
|
| 883 | + unset($user); |
|
| 884 | + } |
|
| 885 | 885 | |
| 886 | - return $user_id; |
|
| 887 | - } |
|
| 886 | + return $user_id; |
|
| 887 | + } |
|
| 888 | 888 | |
| 889 | 889 | public static function get_file_contents( $filename, $atts = array() ) { |
| 890 | - if ( ! is_file($filename) ) { |
|
| 891 | - return false; |
|
| 892 | - } |
|
| 893 | - |
|
| 894 | - extract($atts); |
|
| 895 | - ob_start(); |
|
| 896 | - include($filename); |
|
| 897 | - $contents = ob_get_contents(); |
|
| 898 | - ob_end_clean(); |
|
| 899 | - return $contents; |
|
| 900 | - } |
|
| 901 | - |
|
| 902 | - /** |
|
| 903 | - * @param string $table_name |
|
| 904 | - * @param string $column |
|
| 890 | + if ( ! is_file($filename) ) { |
|
| 891 | + return false; |
|
| 892 | + } |
|
| 893 | + |
|
| 894 | + extract($atts); |
|
| 895 | + ob_start(); |
|
| 896 | + include($filename); |
|
| 897 | + $contents = ob_get_contents(); |
|
| 898 | + ob_end_clean(); |
|
| 899 | + return $contents; |
|
| 900 | + } |
|
| 901 | + |
|
| 902 | + /** |
|
| 903 | + * @param string $table_name |
|
| 904 | + * @param string $column |
|
| 905 | 905 | * @param int $id |
| 906 | 906 | * @param int $num_chars |
| 907 | - */ |
|
| 908 | - public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 909 | - $key = ''; |
|
| 907 | + */ |
|
| 908 | + public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 909 | + $key = ''; |
|
| 910 | 910 | |
| 911 | - if ( ! empty( $name ) ) { |
|
| 912 | - $key = sanitize_key($name); |
|
| 913 | - } |
|
| 911 | + if ( ! empty( $name ) ) { |
|
| 912 | + $key = sanitize_key($name); |
|
| 913 | + } |
|
| 914 | 914 | |
| 915 | 915 | if ( empty( $key ) ) { |
| 916 | - $max_slug_value = pow(36, $num_chars); |
|
| 917 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 918 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 919 | - } |
|
| 916 | + $max_slug_value = pow(36, $num_chars); |
|
| 917 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 918 | + $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 919 | + } |
|
| 920 | 920 | |
| 921 | 921 | if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
| 922 | 922 | $key = $key . 'a'; |
| 923 | - } |
|
| 923 | + } |
|
| 924 | 924 | |
| 925 | 925 | $key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column ); |
| 926 | 926 | |
| 927 | - if ( $key_check || is_numeric($key_check) ) { |
|
| 928 | - $suffix = 2; |
|
| 927 | + if ( $key_check || is_numeric($key_check) ) { |
|
| 928 | + $suffix = 2; |
|
| 929 | 929 | do { |
| 930 | 930 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
| 931 | 931 | $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column ); |
| 932 | 932 | $suffix++; |
| 933 | 933 | } while ( $key_check || is_numeric( $key_check ) ); |
| 934 | 934 | $key = $alt_post_name; |
| 935 | - } |
|
| 936 | - return $key; |
|
| 937 | - } |
|
| 938 | - |
|
| 939 | - /** |
|
| 940 | - * Editing a Form or Entry |
|
| 941 | - * @param string $table |
|
| 942 | - * @return bool|array |
|
| 943 | - */ |
|
| 944 | - public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 945 | - if ( ! $record ) { |
|
| 946 | - return false; |
|
| 947 | - } |
|
| 948 | - |
|
| 949 | - if ( empty($post_values) ) { |
|
| 950 | - $post_values = stripslashes_deep($_POST); |
|
| 951 | - } |
|
| 935 | + } |
|
| 936 | + return $key; |
|
| 937 | + } |
|
| 938 | + |
|
| 939 | + /** |
|
| 940 | + * Editing a Form or Entry |
|
| 941 | + * @param string $table |
|
| 942 | + * @return bool|array |
|
| 943 | + */ |
|
| 944 | + public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 945 | + if ( ! $record ) { |
|
| 946 | + return false; |
|
| 947 | + } |
|
| 948 | + |
|
| 949 | + if ( empty($post_values) ) { |
|
| 950 | + $post_values = stripslashes_deep($_POST); |
|
| 951 | + } |
|
| 952 | 952 | |
| 953 | 953 | $values = array( 'id' => $record->id, 'fields' => array() ); |
| 954 | 954 | |
| 955 | 955 | foreach ( array( 'name', 'description' ) as $var ) { |
| 956 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
| 956 | + $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
| 957 | 957 | $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
| 958 | - unset($var, $default_val); |
|
| 959 | - } |
|
| 958 | + unset($var, $default_val); |
|
| 959 | + } |
|
| 960 | 960 | |
| 961 | - $values['description'] = self::use_wpautop($values['description']); |
|
| 961 | + $values['description'] = self::use_wpautop($values['description']); |
|
| 962 | 962 | |
| 963 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
| 963 | + self::fill_form_opts($record, $table, $post_values, $values); |
|
| 964 | 964 | |
| 965 | 965 | self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) ); |
| 966 | 966 | |
| 967 | - if ( $table == 'entries' ) { |
|
| 968 | - $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 969 | - } else if ( $table == 'forms' ) { |
|
| 970 | - $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 971 | - } |
|
| 967 | + if ( $table == 'entries' ) { |
|
| 968 | + $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 969 | + } else if ( $table == 'forms' ) { |
|
| 970 | + $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 971 | + } |
|
| 972 | 972 | |
| 973 | - return $values; |
|
| 974 | - } |
|
| 973 | + return $values; |
|
| 974 | + } |
|
| 975 | 975 | |
| 976 | 976 | private static function prepare_field_arrays( $fields, $record, array &$values, $args ) { |
| 977 | 977 | if ( ! empty( $fields ) ) { |
@@ -984,121 +984,121 @@ discard block |
||
| 984 | 984 | } |
| 985 | 985 | |
| 986 | 986 | private static function fill_field_defaults( $field, $record, array &$values, $args ) { |
| 987 | - $post_values = $args['post_values']; |
|
| 988 | - |
|
| 989 | - if ( $args['default'] ) { |
|
| 990 | - $meta_value = $field->default_value; |
|
| 991 | - } else { |
|
| 992 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
| 993 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
| 994 | - $field->field_options['custom_field'] = ''; |
|
| 995 | - } |
|
| 987 | + $post_values = $args['post_values']; |
|
| 988 | + |
|
| 989 | + if ( $args['default'] ) { |
|
| 990 | + $meta_value = $field->default_value; |
|
| 991 | + } else { |
|
| 992 | + if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
| 993 | + if ( ! isset($field->field_options['custom_field']) ) { |
|
| 994 | + $field->field_options['custom_field'] = ''; |
|
| 995 | + } |
|
| 996 | 996 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) ); |
| 997 | - } else { |
|
| 997 | + } else { |
|
| 998 | 998 | $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); |
| 999 | - } |
|
| 1000 | - } |
|
| 999 | + } |
|
| 1000 | + } |
|
| 1001 | 1001 | |
| 1002 | 1002 | $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
| 1003 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1004 | - |
|
| 1005 | - $field_array = array( |
|
| 1006 | - 'id' => $field->id, |
|
| 1007 | - 'value' => $new_value, |
|
| 1008 | - 'default_value' => $field->default_value, |
|
| 1009 | - 'name' => $field->name, |
|
| 1010 | - 'description' => $field->description, |
|
| 1011 | - 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
| 1012 | - 'options' => $field->options, |
|
| 1013 | - 'required' => $field->required, |
|
| 1014 | - 'field_key' => $field->field_key, |
|
| 1015 | - 'field_order' => $field->field_order, |
|
| 1016 | - 'form_id' => $field->form_id, |
|
| 1003 | + $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1004 | + |
|
| 1005 | + $field_array = array( |
|
| 1006 | + 'id' => $field->id, |
|
| 1007 | + 'value' => $new_value, |
|
| 1008 | + 'default_value' => $field->default_value, |
|
| 1009 | + 'name' => $field->name, |
|
| 1010 | + 'description' => $field->description, |
|
| 1011 | + 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
| 1012 | + 'options' => $field->options, |
|
| 1013 | + 'required' => $field->required, |
|
| 1014 | + 'field_key' => $field->field_key, |
|
| 1015 | + 'field_order' => $field->field_order, |
|
| 1016 | + 'form_id' => $field->form_id, |
|
| 1017 | 1017 | 'parent_form_id' => $args['parent_form_id'], |
| 1018 | - ); |
|
| 1018 | + ); |
|
| 1019 | 1019 | |
| 1020 | - $args['field_type'] = $field_type; |
|
| 1021 | - self::fill_field_opts($field, $field_array, $args); |
|
| 1020 | + $args['field_type'] = $field_type; |
|
| 1021 | + self::fill_field_opts($field, $field_array, $args); |
|
| 1022 | 1022 | // Track the original field's type |
| 1023 | 1023 | $field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type; |
| 1024 | 1024 | |
| 1025 | - $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() ); |
|
| 1025 | + $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() ); |
|
| 1026 | 1026 | |
| 1027 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
| 1028 | - $field_array['unique_msg'] = ''; |
|
| 1029 | - } |
|
| 1027 | + if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
| 1028 | + $field_array['unique_msg'] = ''; |
|
| 1029 | + } |
|
| 1030 | 1030 | |
| 1031 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1031 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1032 | 1032 | |
| 1033 | - $values['fields'][ $field->id ] = $field_array; |
|
| 1034 | - } |
|
| 1033 | + $values['fields'][ $field->id ] = $field_array; |
|
| 1034 | + } |
|
| 1035 | 1035 | |
| 1036 | 1036 | private static function fill_field_opts( $field, array &$field_array, $args ) { |
| 1037 | 1037 | //TODO: _deprecated_function( __METHOD__, '3.0', 'FmFieldsHelper::fill_default_field_opts' ); |
| 1038 | - $post_values = $args['post_values']; |
|
| 1039 | - $opt_defaults = FrmFieldsHelper::get_default_field_options_from_field( $field ); |
|
| 1038 | + $post_values = $args['post_values']; |
|
| 1039 | + $opt_defaults = FrmFieldsHelper::get_default_field_options_from_field( $field ); |
|
| 1040 | 1040 | $frm_settings = self::get_settings(); |
| 1041 | 1041 | |
| 1042 | - foreach ( $opt_defaults as $opt => $default_opt ) { |
|
| 1042 | + foreach ( $opt_defaults as $opt => $default_opt ) { |
|
| 1043 | 1043 | $field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt . '_' . $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt . '_' . $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt ); |
| 1044 | - if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
| 1045 | - $field_array[ $opt ] = $frm_settings->blank_msg; |
|
| 1046 | - } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
| 1047 | - if ( $args['field_type'] == 'captcha' ) { |
|
| 1048 | - $field_array[ $opt ] = $frm_settings->re_msg; |
|
| 1049 | - } else { |
|
| 1050 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
| 1051 | - } |
|
| 1052 | - } |
|
| 1053 | - } |
|
| 1054 | - |
|
| 1055 | - if ( $field_array['custom_html'] == '' ) { |
|
| 1056 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
| 1057 | - } |
|
| 1058 | - } |
|
| 1059 | - |
|
| 1060 | - /** |
|
| 1061 | - * @param string $table |
|
| 1062 | - */ |
|
| 1044 | + if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
| 1045 | + $field_array[ $opt ] = $frm_settings->blank_msg; |
|
| 1046 | + } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
| 1047 | + if ( $args['field_type'] == 'captcha' ) { |
|
| 1048 | + $field_array[ $opt ] = $frm_settings->re_msg; |
|
| 1049 | + } else { |
|
| 1050 | + $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
| 1051 | + } |
|
| 1052 | + } |
|
| 1053 | + } |
|
| 1054 | + |
|
| 1055 | + if ( $field_array['custom_html'] == '' ) { |
|
| 1056 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
| 1057 | + } |
|
| 1058 | + } |
|
| 1059 | + |
|
| 1060 | + /** |
|
| 1061 | + * @param string $table |
|
| 1062 | + */ |
|
| 1063 | 1063 | private static function fill_form_opts( $record, $table, $post_values, array &$values ) { |
| 1064 | - if ( $table == 'entries' ) { |
|
| 1065 | - $form = $record->form_id; |
|
| 1064 | + if ( $table == 'entries' ) { |
|
| 1065 | + $form = $record->form_id; |
|
| 1066 | 1066 | FrmForm::maybe_get_form( $form ); |
| 1067 | - } else { |
|
| 1068 | - $form = $record; |
|
| 1069 | - } |
|
| 1067 | + } else { |
|
| 1068 | + $form = $record; |
|
| 1069 | + } |
|
| 1070 | 1070 | |
| 1071 | - if ( ! $form ) { |
|
| 1072 | - return; |
|
| 1073 | - } |
|
| 1071 | + if ( ! $form ) { |
|
| 1072 | + return; |
|
| 1073 | + } |
|
| 1074 | 1074 | |
| 1075 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
| 1075 | + $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
| 1076 | 1076 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
| 1077 | 1077 | |
| 1078 | - if ( ! is_array($form->options) ) { |
|
| 1079 | - return; |
|
| 1080 | - } |
|
| 1078 | + if ( ! is_array($form->options) ) { |
|
| 1079 | + return; |
|
| 1080 | + } |
|
| 1081 | 1081 | |
| 1082 | - foreach ( $form->options as $opt => $value ) { |
|
| 1083 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1084 | - } |
|
| 1082 | + foreach ( $form->options as $opt => $value ) { |
|
| 1083 | + $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1084 | + } |
|
| 1085 | 1085 | |
| 1086 | - self::fill_form_defaults($post_values, $values); |
|
| 1087 | - } |
|
| 1086 | + self::fill_form_defaults($post_values, $values); |
|
| 1087 | + } |
|
| 1088 | 1088 | |
| 1089 | - /** |
|
| 1090 | - * Set to POST value or default |
|
| 1091 | - */ |
|
| 1089 | + /** |
|
| 1090 | + * Set to POST value or default |
|
| 1091 | + */ |
|
| 1092 | 1092 | private static function fill_form_defaults( $post_values, array &$values ) { |
| 1093 | - $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1093 | + $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1094 | 1094 | |
| 1095 | - foreach ( $form_defaults as $opt => $default ) { |
|
| 1096 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1095 | + foreach ( $form_defaults as $opt => $default ) { |
|
| 1096 | + if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1097 | 1097 | $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
| 1098 | - } |
|
| 1098 | + } |
|
| 1099 | 1099 | |
| 1100 | - unset($opt, $defaut); |
|
| 1101 | - } |
|
| 1100 | + unset($opt, $defaut); |
|
| 1101 | + } |
|
| 1102 | 1102 | |
| 1103 | 1103 | if ( ! isset( $values['custom_style'] ) ) { |
| 1104 | 1104 | $values['custom_style'] = self::custom_style_value( $post_values ); |
@@ -1107,10 +1107,10 @@ discard block |
||
| 1107 | 1107 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
| 1108 | 1108 | if ( ! isset( $values[ $h . '_html' ] ) ) { |
| 1109 | 1109 | $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
| 1110 | - } |
|
| 1111 | - unset($h); |
|
| 1112 | - } |
|
| 1113 | - } |
|
| 1110 | + } |
|
| 1111 | + unset($h); |
|
| 1112 | + } |
|
| 1113 | + } |
|
| 1114 | 1114 | |
| 1115 | 1115 | /** |
| 1116 | 1116 | * @since 2.2.10 |
@@ -1133,55 +1133,55 @@ discard block |
||
| 1133 | 1133 | if ( $possible_email_field ) { |
| 1134 | 1134 | $class .= 'show_frm_not_email_to'; |
| 1135 | 1135 | } |
| 1136 | - ?> |
|
| 1136 | + ?> |
|
| 1137 | 1137 | <li> |
| 1138 | 1138 | <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> |
| 1139 | 1139 | <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> |
| 1140 | 1140 | <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> |
| 1141 | 1141 | </li> |
| 1142 | 1142 | <?php |
| 1143 | - } |
|
| 1143 | + } |
|
| 1144 | 1144 | |
| 1145 | 1145 | public static function truncate( $str, $length, $minword = 3, $continue = '...' ) { |
| 1146 | - if ( is_array( $str ) ) { |
|
| 1147 | - return ''; |
|
| 1146 | + if ( is_array( $str ) ) { |
|
| 1147 | + return ''; |
|
| 1148 | 1148 | } |
| 1149 | 1149 | |
| 1150 | - $length = (int) $length; |
|
| 1150 | + $length = (int) $length; |
|
| 1151 | 1151 | $str = wp_strip_all_tags( $str ); |
| 1152 | 1152 | $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) ); |
| 1153 | 1153 | |
| 1154 | 1154 | if ( $length == 0 ) { |
| 1155 | - return ''; |
|
| 1156 | - } else if ( $length <= 10 ) { |
|
| 1155 | + return ''; |
|
| 1156 | + } else if ( $length <= 10 ) { |
|
| 1157 | 1157 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
| 1158 | - return $sub . (($length < $original_len) ? $continue : ''); |
|
| 1159 | - } |
|
| 1158 | + return $sub . (($length < $original_len) ? $continue : ''); |
|
| 1159 | + } |
|
| 1160 | 1160 | |
| 1161 | - $sub = ''; |
|
| 1162 | - $len = 0; |
|
| 1161 | + $sub = ''; |
|
| 1162 | + $len = 0; |
|
| 1163 | 1163 | |
| 1164 | 1164 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
| 1165 | 1165 | |
| 1166 | 1166 | foreach ( $words as $word ) { |
| 1167 | - $part = (($sub != '') ? ' ' : '') . $word; |
|
| 1167 | + $part = (($sub != '') ? ' ' : '') . $word; |
|
| 1168 | 1168 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
| 1169 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
| 1170 | - break; |
|
| 1171 | - } |
|
| 1169 | + if ( $total_len > $length && str_word_count($sub) ) { |
|
| 1170 | + break; |
|
| 1171 | + } |
|
| 1172 | 1172 | |
| 1173 | - $sub .= $part; |
|
| 1173 | + $sub .= $part; |
|
| 1174 | 1174 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
| 1175 | 1175 | |
| 1176 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
| 1177 | - break; |
|
| 1178 | - } |
|
| 1176 | + if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
| 1177 | + break; |
|
| 1178 | + } |
|
| 1179 | 1179 | |
| 1180 | - unset($total_len, $word); |
|
| 1181 | - } |
|
| 1180 | + unset($total_len, $word); |
|
| 1181 | + } |
|
| 1182 | 1182 | |
| 1183 | - return $sub . (($len < $original_len) ? $continue : ''); |
|
| 1184 | - } |
|
| 1183 | + return $sub . (($len < $original_len) ? $continue : ''); |
|
| 1184 | + } |
|
| 1185 | 1185 | |
| 1186 | 1186 | public static function mb_function( $function_names, $args ) { |
| 1187 | 1187 | $mb_function_name = $function_names[0]; |
@@ -1193,18 +1193,18 @@ discard block |
||
| 1193 | 1193 | } |
| 1194 | 1194 | |
| 1195 | 1195 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
| 1196 | - if ( empty($date) ) { |
|
| 1197 | - return $date; |
|
| 1198 | - } |
|
| 1196 | + if ( empty($date) ) { |
|
| 1197 | + return $date; |
|
| 1198 | + } |
|
| 1199 | 1199 | |
| 1200 | - if ( empty($date_format) ) { |
|
| 1201 | - $date_format = get_option('date_format'); |
|
| 1202 | - } |
|
| 1200 | + if ( empty($date_format) ) { |
|
| 1201 | + $date_format = get_option('date_format'); |
|
| 1202 | + } |
|
| 1203 | 1203 | |
| 1204 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
| 1205 | - $frmpro_settings = new FrmProSettings(); |
|
| 1206 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
| 1207 | - } |
|
| 1204 | + if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
| 1205 | + $frmpro_settings = new FrmProSettings(); |
|
| 1206 | + $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
| 1207 | + } |
|
| 1208 | 1208 | |
| 1209 | 1209 | $formatted = self::get_localized_date( $date_format, $date ); |
| 1210 | 1210 | |
@@ -1213,8 +1213,8 @@ discard block |
||
| 1213 | 1213 | $formatted .= self::add_time_to_date( $time_format, $date ); |
| 1214 | 1214 | } |
| 1215 | 1215 | |
| 1216 | - return $formatted; |
|
| 1217 | - } |
|
| 1216 | + return $formatted; |
|
| 1217 | + } |
|
| 1218 | 1218 | |
| 1219 | 1219 | private static function add_time_to_date( $time_format, $date ) { |
| 1220 | 1220 | if ( empty( $time_format ) ) { |
@@ -1296,61 +1296,61 @@ discard block |
||
| 1296 | 1296 | ); |
| 1297 | 1297 | } |
| 1298 | 1298 | |
| 1299 | - /** |
|
| 1300 | - * Added for < WP 4.0 compatability |
|
| 1301 | - * |
|
| 1302 | - * @since 1.07.10 |
|
| 1303 | - * |
|
| 1304 | - * @param string $term The value to escape |
|
| 1305 | - * @return string The escaped value |
|
| 1306 | - */ |
|
| 1299 | + /** |
|
| 1300 | + * Added for < WP 4.0 compatability |
|
| 1301 | + * |
|
| 1302 | + * @since 1.07.10 |
|
| 1303 | + * |
|
| 1304 | + * @param string $term The value to escape |
|
| 1305 | + * @return string The escaped value |
|
| 1306 | + */ |
|
| 1307 | 1307 | public static function esc_like( $term ) { |
| 1308 | - global $wpdb; |
|
| 1309 | - if ( method_exists($wpdb, 'esc_like') ) { |
|
| 1308 | + global $wpdb; |
|
| 1309 | + if ( method_exists($wpdb, 'esc_like') ) { |
|
| 1310 | 1310 | // WP 4.0 |
| 1311 | - $term = $wpdb->esc_like( $term ); |
|
| 1312 | - } else { |
|
| 1313 | - $term = like_escape( $term ); |
|
| 1314 | - } |
|
| 1311 | + $term = $wpdb->esc_like( $term ); |
|
| 1312 | + } else { |
|
| 1313 | + $term = like_escape( $term ); |
|
| 1314 | + } |
|
| 1315 | 1315 | |
| 1316 | - return $term; |
|
| 1317 | - } |
|
| 1316 | + return $term; |
|
| 1317 | + } |
|
| 1318 | 1318 | |
| 1319 | - /** |
|
| 1320 | - * @param string $order_query |
|
| 1321 | - */ |
|
| 1319 | + /** |
|
| 1320 | + * @param string $order_query |
|
| 1321 | + */ |
|
| 1322 | 1322 | public static function esc_order( $order_query ) { |
| 1323 | - if ( empty($order_query) ) { |
|
| 1324 | - return ''; |
|
| 1325 | - } |
|
| 1326 | - |
|
| 1327 | - // remove ORDER BY before santizing |
|
| 1328 | - $order_query = strtolower($order_query); |
|
| 1329 | - if ( strpos($order_query, 'order by') !== false ) { |
|
| 1330 | - $order_query = str_replace('order by', '', $order_query); |
|
| 1331 | - } |
|
| 1332 | - |
|
| 1333 | - $order_query = explode(' ', trim($order_query)); |
|
| 1334 | - |
|
| 1335 | - $order_fields = array( |
|
| 1336 | - 'id', 'form_key', 'name', 'description', |
|
| 1337 | - 'parent_form_id', 'logged_in', 'is_template', |
|
| 1338 | - 'default_template', 'status', 'created_at', |
|
| 1339 | - ); |
|
| 1340 | - |
|
| 1341 | - $order = trim(trim(reset($order_query), ',')); |
|
| 1342 | - if ( ! in_array($order, $order_fields) ) { |
|
| 1343 | - return ''; |
|
| 1344 | - } |
|
| 1345 | - |
|
| 1346 | - $order_by = ''; |
|
| 1347 | - if ( count($order_query) > 1 ) { |
|
| 1323 | + if ( empty($order_query) ) { |
|
| 1324 | + return ''; |
|
| 1325 | + } |
|
| 1326 | + |
|
| 1327 | + // remove ORDER BY before santizing |
|
| 1328 | + $order_query = strtolower($order_query); |
|
| 1329 | + if ( strpos($order_query, 'order by') !== false ) { |
|
| 1330 | + $order_query = str_replace('order by', '', $order_query); |
|
| 1331 | + } |
|
| 1332 | + |
|
| 1333 | + $order_query = explode(' ', trim($order_query)); |
|
| 1334 | + |
|
| 1335 | + $order_fields = array( |
|
| 1336 | + 'id', 'form_key', 'name', 'description', |
|
| 1337 | + 'parent_form_id', 'logged_in', 'is_template', |
|
| 1338 | + 'default_template', 'status', 'created_at', |
|
| 1339 | + ); |
|
| 1340 | + |
|
| 1341 | + $order = trim(trim(reset($order_query), ',')); |
|
| 1342 | + if ( ! in_array($order, $order_fields) ) { |
|
| 1343 | + return ''; |
|
| 1344 | + } |
|
| 1345 | + |
|
| 1346 | + $order_by = ''; |
|
| 1347 | + if ( count($order_query) > 1 ) { |
|
| 1348 | 1348 | $order_by = end( $order_query ); |
| 1349 | 1349 | self::esc_order_by( $order_by ); |
| 1350 | - } |
|
| 1350 | + } |
|
| 1351 | 1351 | |
| 1352 | 1352 | return ' ORDER BY ' . $order . ' ' . $order_by; |
| 1353 | - } |
|
| 1353 | + } |
|
| 1354 | 1354 | |
| 1355 | 1355 | /** |
| 1356 | 1356 | * Make sure this is ordering by either ASC or DESC |
@@ -1362,169 +1362,169 @@ discard block |
||
| 1362 | 1362 | } |
| 1363 | 1363 | } |
| 1364 | 1364 | |
| 1365 | - /** |
|
| 1366 | - * @param string $limit |
|
| 1367 | - */ |
|
| 1365 | + /** |
|
| 1366 | + * @param string $limit |
|
| 1367 | + */ |
|
| 1368 | 1368 | public static function esc_limit( $limit ) { |
| 1369 | - if ( empty($limit) ) { |
|
| 1370 | - return ''; |
|
| 1371 | - } |
|
| 1369 | + if ( empty($limit) ) { |
|
| 1370 | + return ''; |
|
| 1371 | + } |
|
| 1372 | 1372 | |
| 1373 | - $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
| 1374 | - if ( is_numeric($limit) ) { |
|
| 1373 | + $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
| 1374 | + if ( is_numeric($limit) ) { |
|
| 1375 | 1375 | return ' LIMIT ' . $limit; |
| 1376 | - } |
|
| 1376 | + } |
|
| 1377 | 1377 | |
| 1378 | - $limit = explode(',', trim($limit)); |
|
| 1379 | - foreach ( $limit as $k => $l ) { |
|
| 1380 | - if ( is_numeric( $l ) ) { |
|
| 1381 | - $limit[ $k ] = $l; |
|
| 1382 | - } |
|
| 1383 | - } |
|
| 1378 | + $limit = explode(',', trim($limit)); |
|
| 1379 | + foreach ( $limit as $k => $l ) { |
|
| 1380 | + if ( is_numeric( $l ) ) { |
|
| 1381 | + $limit[ $k ] = $l; |
|
| 1382 | + } |
|
| 1383 | + } |
|
| 1384 | 1384 | |
| 1385 | - $limit = implode(',', $limit); |
|
| 1385 | + $limit = implode(',', $limit); |
|
| 1386 | 1386 | return ' LIMIT ' . $limit; |
| 1387 | - } |
|
| 1388 | - |
|
| 1389 | - /** |
|
| 1390 | - * Get an array of values ready to go through $wpdb->prepare |
|
| 1391 | - * @since 2.0 |
|
| 1392 | - */ |
|
| 1393 | - public static function prepare_array_values( $array, $type = '%s' ) { |
|
| 1394 | - $placeholders = array_fill(0, count($array), $type); |
|
| 1395 | - return implode(', ', $placeholders); |
|
| 1396 | - } |
|
| 1397 | - |
|
| 1398 | - public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
|
| 1399 | - if ( empty($where) ) { |
|
| 1400 | - return ''; |
|
| 1401 | - } |
|
| 1387 | + } |
|
| 1388 | + |
|
| 1389 | + /** |
|
| 1390 | + * Get an array of values ready to go through $wpdb->prepare |
|
| 1391 | + * @since 2.0 |
|
| 1392 | + */ |
|
| 1393 | + public static function prepare_array_values( $array, $type = '%s' ) { |
|
| 1394 | + $placeholders = array_fill(0, count($array), $type); |
|
| 1395 | + return implode(', ', $placeholders); |
|
| 1396 | + } |
|
| 1397 | + |
|
| 1398 | + public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
|
| 1399 | + if ( empty($where) ) { |
|
| 1400 | + return ''; |
|
| 1401 | + } |
|
| 1402 | 1402 | |
| 1403 | 1403 | if ( is_array( $where ) ) { |
| 1404 | - global $wpdb; |
|
| 1405 | - FrmDb::get_where_clause_and_values( $where, $starts_with ); |
|
| 1404 | + global $wpdb; |
|
| 1405 | + FrmDb::get_where_clause_and_values( $where, $starts_with ); |
|
| 1406 | 1406 | $where = $wpdb->prepare( $where['where'], $where['values'] ); |
| 1407 | 1407 | } else { |
| 1408 | - $where = $starts_with . $where; |
|
| 1409 | - } |
|
| 1408 | + $where = $starts_with . $where; |
|
| 1409 | + } |
|
| 1410 | 1410 | |
| 1411 | - return $where; |
|
| 1412 | - } |
|
| 1411 | + return $where; |
|
| 1412 | + } |
|
| 1413 | 1413 | |
| 1414 | - // Pagination Methods |
|
| 1414 | + // Pagination Methods |
|
| 1415 | 1415 | |
| 1416 | - /** |
|
| 1417 | - * @param integer $current_p |
|
| 1418 | - */ |
|
| 1416 | + /** |
|
| 1417 | + * @param integer $current_p |
|
| 1418 | + */ |
|
| 1419 | 1419 | public static function get_last_record_num( $r_count, $current_p, $p_size ) { |
| 1420 | 1420 | return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); |
| 1421 | 1421 | } |
| 1422 | 1422 | |
| 1423 | - /** |
|
| 1424 | - * @param integer $current_p |
|
| 1425 | - */ |
|
| 1426 | - public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1427 | - if ( $current_p == 1 ) { |
|
| 1428 | - return 1; |
|
| 1429 | - } else { |
|
| 1430 | - return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1431 | - } |
|
| 1432 | - } |
|
| 1423 | + /** |
|
| 1424 | + * @param integer $current_p |
|
| 1425 | + */ |
|
| 1426 | + public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1427 | + if ( $current_p == 1 ) { |
|
| 1428 | + return 1; |
|
| 1429 | + } else { |
|
| 1430 | + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1431 | + } |
|
| 1432 | + } |
|
| 1433 | 1433 | |
| 1434 | 1434 | /** |
| 1435 | 1435 | * @return array |
| 1436 | 1436 | */ |
| 1437 | 1437 | public static function json_to_array( $json_vars ) { |
| 1438 | - $vars = array(); |
|
| 1439 | - foreach ( $json_vars as $jv ) { |
|
| 1440 | - $jv_name = explode('[', $jv['name']); |
|
| 1441 | - $last = count($jv_name) - 1; |
|
| 1442 | - foreach ( $jv_name as $p => $n ) { |
|
| 1443 | - $name = trim($n, ']'); |
|
| 1444 | - if ( ! isset($l1) ) { |
|
| 1445 | - $l1 = $name; |
|
| 1446 | - } |
|
| 1447 | - |
|
| 1448 | - if ( ! isset($l2) ) { |
|
| 1449 | - $l2 = $name; |
|
| 1450 | - } |
|
| 1451 | - |
|
| 1452 | - if ( ! isset($l3) ) { |
|
| 1453 | - $l3 = $name; |
|
| 1454 | - } |
|
| 1455 | - |
|
| 1456 | - $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1457 | - |
|
| 1458 | - switch ( $p ) { |
|
| 1459 | - case 0: |
|
| 1460 | - $l1 = $name; |
|
| 1461 | - self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1462 | - break; |
|
| 1463 | - |
|
| 1464 | - case 1: |
|
| 1465 | - $l2 = $name; |
|
| 1466 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1467 | - break; |
|
| 1468 | - |
|
| 1469 | - case 2: |
|
| 1470 | - $l3 = $name; |
|
| 1471 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1472 | - break; |
|
| 1473 | - |
|
| 1474 | - case 3: |
|
| 1475 | - $l4 = $name; |
|
| 1476 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1477 | - break; |
|
| 1478 | - } |
|
| 1479 | - |
|
| 1480 | - unset($this_val, $n); |
|
| 1481 | - } |
|
| 1482 | - |
|
| 1483 | - unset($last, $jv); |
|
| 1484 | - } |
|
| 1485 | - |
|
| 1486 | - return $vars; |
|
| 1487 | - } |
|
| 1488 | - |
|
| 1489 | - /** |
|
| 1490 | - * @param string $name |
|
| 1491 | - * @param string $l1 |
|
| 1492 | - */ |
|
| 1493 | - public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1494 | - if ( $name == '' ) { |
|
| 1495 | - $vars[] = $val; |
|
| 1496 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1497 | - $vars[ $l1 ] = $val; |
|
| 1498 | - } |
|
| 1499 | - } |
|
| 1438 | + $vars = array(); |
|
| 1439 | + foreach ( $json_vars as $jv ) { |
|
| 1440 | + $jv_name = explode('[', $jv['name']); |
|
| 1441 | + $last = count($jv_name) - 1; |
|
| 1442 | + foreach ( $jv_name as $p => $n ) { |
|
| 1443 | + $name = trim($n, ']'); |
|
| 1444 | + if ( ! isset($l1) ) { |
|
| 1445 | + $l1 = $name; |
|
| 1446 | + } |
|
| 1447 | + |
|
| 1448 | + if ( ! isset($l2) ) { |
|
| 1449 | + $l2 = $name; |
|
| 1450 | + } |
|
| 1451 | + |
|
| 1452 | + if ( ! isset($l3) ) { |
|
| 1453 | + $l3 = $name; |
|
| 1454 | + } |
|
| 1455 | + |
|
| 1456 | + $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1457 | + |
|
| 1458 | + switch ( $p ) { |
|
| 1459 | + case 0: |
|
| 1460 | + $l1 = $name; |
|
| 1461 | + self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1462 | + break; |
|
| 1463 | + |
|
| 1464 | + case 1: |
|
| 1465 | + $l2 = $name; |
|
| 1466 | + self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1467 | + break; |
|
| 1468 | + |
|
| 1469 | + case 2: |
|
| 1470 | + $l3 = $name; |
|
| 1471 | + self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1472 | + break; |
|
| 1473 | + |
|
| 1474 | + case 3: |
|
| 1475 | + $l4 = $name; |
|
| 1476 | + self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1477 | + break; |
|
| 1478 | + } |
|
| 1479 | + |
|
| 1480 | + unset($this_val, $n); |
|
| 1481 | + } |
|
| 1482 | + |
|
| 1483 | + unset($last, $jv); |
|
| 1484 | + } |
|
| 1485 | + |
|
| 1486 | + return $vars; |
|
| 1487 | + } |
|
| 1488 | + |
|
| 1489 | + /** |
|
| 1490 | + * @param string $name |
|
| 1491 | + * @param string $l1 |
|
| 1492 | + */ |
|
| 1493 | + public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1494 | + if ( $name == '' ) { |
|
| 1495 | + $vars[] = $val; |
|
| 1496 | + } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1497 | + $vars[ $l1 ] = $val; |
|
| 1498 | + } |
|
| 1499 | + } |
|
| 1500 | 1500 | |
| 1501 | 1501 | public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) { |
| 1502 | - $tooltips = array( |
|
| 1503 | - 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1504 | - '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' ), |
|
| 1505 | - 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1506 | - 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1507 | - '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' ), |
|
| 1508 | - 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1509 | - '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() ) ), |
|
| 1510 | - ); |
|
| 1511 | - |
|
| 1512 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1513 | - return; |
|
| 1514 | - } |
|
| 1515 | - |
|
| 1516 | - if ( 'open' == $class ) { |
|
| 1517 | - echo ' frm_help"'; |
|
| 1518 | - } else { |
|
| 1519 | - echo ' class="frm_help"'; |
|
| 1520 | - } |
|
| 1502 | + $tooltips = array( |
|
| 1503 | + 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1504 | + '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' ), |
|
| 1505 | + 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1506 | + 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1507 | + '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' ), |
|
| 1508 | + 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1509 | + '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() ) ), |
|
| 1510 | + ); |
|
| 1511 | + |
|
| 1512 | + if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1513 | + return; |
|
| 1514 | + } |
|
| 1515 | + |
|
| 1516 | + if ( 'open' == $class ) { |
|
| 1517 | + echo ' frm_help"'; |
|
| 1518 | + } else { |
|
| 1519 | + echo ' class="frm_help"'; |
|
| 1520 | + } |
|
| 1521 | 1521 | |
| 1522 | 1522 | echo ' title="' . esc_attr( $tooltips[ $name ] ); |
| 1523 | 1523 | |
| 1524 | - if ( 'open' != $class ) { |
|
| 1525 | - echo '"'; |
|
| 1526 | - } |
|
| 1527 | - } |
|
| 1524 | + if ( 'open' != $class ) { |
|
| 1525 | + echo '"'; |
|
| 1526 | + } |
|
| 1527 | + } |
|
| 1528 | 1528 | |
| 1529 | 1529 | /** |
| 1530 | 1530 | * Add the current_page class to that page in the form nav |
@@ -1540,35 +1540,35 @@ discard block |
||
| 1540 | 1540 | } |
| 1541 | 1541 | } |
| 1542 | 1542 | |
| 1543 | - /** |
|
| 1544 | - * Prepare and json_encode post content |
|
| 1545 | - * |
|
| 1546 | - * @since 2.0 |
|
| 1547 | - * |
|
| 1548 | - * @param array $post_content |
|
| 1549 | - * @return string $post_content ( json encoded array ) |
|
| 1550 | - */ |
|
| 1551 | - public static function prepare_and_encode( $post_content ) { |
|
| 1552 | - //Loop through array to strip slashes and add only the needed ones |
|
| 1543 | + /** |
|
| 1544 | + * Prepare and json_encode post content |
|
| 1545 | + * |
|
| 1546 | + * @since 2.0 |
|
| 1547 | + * |
|
| 1548 | + * @param array $post_content |
|
| 1549 | + * @return string $post_content ( json encoded array ) |
|
| 1550 | + */ |
|
| 1551 | + public static function prepare_and_encode( $post_content ) { |
|
| 1552 | + //Loop through array to strip slashes and add only the needed ones |
|
| 1553 | 1553 | foreach ( $post_content as $key => $val ) { |
| 1554 | 1554 | // Replace problematic characters (like ") |
| 1555 | 1555 | $val = str_replace( '"', '"', $val ); |
| 1556 | 1556 | |
| 1557 | 1557 | self::prepare_action_slashes( $val, $key, $post_content ); |
| 1558 | - unset( $key, $val ); |
|
| 1559 | - } |
|
| 1558 | + unset( $key, $val ); |
|
| 1559 | + } |
|
| 1560 | 1560 | |
| 1561 | - // json_encode the array |
|
| 1562 | - $post_content = json_encode( $post_content ); |
|
| 1561 | + // json_encode the array |
|
| 1562 | + $post_content = json_encode( $post_content ); |
|
| 1563 | 1563 | |
| 1564 | - // add extra slashes for \r\n since WP strips them |
|
| 1564 | + // add extra slashes for \r\n since WP strips them |
|
| 1565 | 1565 | $post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content ); |
| 1566 | 1566 | |
| 1567 | - // allow for " |
|
| 1568 | - $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1567 | + // allow for " |
|
| 1568 | + $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1569 | 1569 | |
| 1570 | - return $post_content; |
|
| 1571 | - } |
|
| 1570 | + return $post_content; |
|
| 1571 | + } |
|
| 1572 | 1572 | |
| 1573 | 1573 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
| 1574 | 1574 | if ( ! isset( $post_content[ $key ] ) ) { |
@@ -1636,64 +1636,64 @@ discard block |
||
| 1636 | 1636 | } |
| 1637 | 1637 | |
| 1638 | 1638 | public static function maybe_json_decode( $string ) { |
| 1639 | - if ( is_array($string) ) { |
|
| 1640 | - return $string; |
|
| 1641 | - } |
|
| 1639 | + if ( is_array($string) ) { |
|
| 1640 | + return $string; |
|
| 1641 | + } |
|
| 1642 | 1642 | |
| 1643 | - $new_string = json_decode($string, true); |
|
| 1644 | - if ( function_exists('json_last_error') ) { |
|
| 1643 | + $new_string = json_decode($string, true); |
|
| 1644 | + if ( function_exists('json_last_error') ) { |
|
| 1645 | 1645 | // php 5.3+ |
| 1646 | - if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1647 | - $string = $new_string; |
|
| 1648 | - } |
|
| 1649 | - } else if ( isset($new_string) ) { |
|
| 1646 | + if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1647 | + $string = $new_string; |
|
| 1648 | + } |
|
| 1649 | + } else if ( isset($new_string) ) { |
|
| 1650 | 1650 | // php < 5.3 fallback |
| 1651 | - $string = $new_string; |
|
| 1652 | - } |
|
| 1653 | - return $string; |
|
| 1654 | - } |
|
| 1655 | - |
|
| 1656 | - /** |
|
| 1657 | - * @since 1.07.10 |
|
| 1658 | - * |
|
| 1659 | - * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1660 | - * echo The javascript to open and highlight the Formidable menu |
|
| 1661 | - */ |
|
| 1651 | + $string = $new_string; |
|
| 1652 | + } |
|
| 1653 | + return $string; |
|
| 1654 | + } |
|
| 1655 | + |
|
| 1656 | + /** |
|
| 1657 | + * @since 1.07.10 |
|
| 1658 | + * |
|
| 1659 | + * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1660 | + * echo The javascript to open and highlight the Formidable menu |
|
| 1661 | + */ |
|
| 1662 | 1662 | public static function maybe_highlight_menu( $post_type ) { |
| 1663 | - global $post; |
|
| 1663 | + global $post; |
|
| 1664 | 1664 | |
| 1665 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1666 | - return; |
|
| 1667 | - } |
|
| 1665 | + if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1666 | + return; |
|
| 1667 | + } |
|
| 1668 | 1668 | |
| 1669 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
| 1670 | - return; |
|
| 1671 | - } |
|
| 1669 | + if ( is_object($post) && $post->post_type != $post_type ) { |
|
| 1670 | + return; |
|
| 1671 | + } |
|
| 1672 | 1672 | |
| 1673 | - self::load_admin_wide_js(); |
|
| 1674 | - echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1675 | - } |
|
| 1673 | + self::load_admin_wide_js(); |
|
| 1674 | + echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1675 | + } |
|
| 1676 | 1676 | |
| 1677 | - /** |
|
| 1678 | - * Load the JS file on non-Formidable pages in the admin area |
|
| 1679 | - * @since 2.0 |
|
| 1680 | - */ |
|
| 1677 | + /** |
|
| 1678 | + * Load the JS file on non-Formidable pages in the admin area |
|
| 1679 | + * @since 2.0 |
|
| 1680 | + */ |
|
| 1681 | 1681 | public static function load_admin_wide_js( $load = true ) { |
| 1682 | - $version = FrmAppHelper::plugin_version(); |
|
| 1682 | + $version = FrmAppHelper::plugin_version(); |
|
| 1683 | 1683 | wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version ); |
| 1684 | 1684 | |
| 1685 | - wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
| 1685 | + wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
| 1686 | 1686 | 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ), |
| 1687 | - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1687 | + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1688 | 1688 | 'url' => FrmAppHelper::plugin_url(), |
| 1689 | 1689 | 'loading' => __( 'Loading…' ), |
| 1690 | 1690 | 'nonce' => wp_create_nonce( 'frm_ajax' ), |
| 1691 | - ) ); |
|
| 1691 | + ) ); |
|
| 1692 | 1692 | |
| 1693 | 1693 | if ( $load ) { |
| 1694 | 1694 | wp_enqueue_script( 'formidable_admin_global' ); |
| 1695 | 1695 | } |
| 1696 | - } |
|
| 1696 | + } |
|
| 1697 | 1697 | |
| 1698 | 1698 | /** |
| 1699 | 1699 | * @since 2.0.9 |
@@ -1702,9 +1702,9 @@ discard block |
||
| 1702 | 1702 | wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() ); |
| 1703 | 1703 | } |
| 1704 | 1704 | |
| 1705 | - /** |
|
| 1706 | - * @param string $location |
|
| 1707 | - */ |
|
| 1705 | + /** |
|
| 1706 | + * @param string $location |
|
| 1707 | + */ |
|
| 1708 | 1708 | public static function localize_script( $location ) { |
| 1709 | 1709 | $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); |
| 1710 | 1710 | $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url ); |
@@ -1760,81 +1760,81 @@ discard block |
||
| 1760 | 1760 | } |
| 1761 | 1761 | } |
| 1762 | 1762 | |
| 1763 | - /** |
|
| 1763 | + /** |
|
| 1764 | 1764 | * echo the message on the plugins listing page |
| 1765 | - * @since 1.07.10 |
|
| 1766 | - * |
|
| 1767 | - * @param float $min_version The version the add-on requires |
|
| 1768 | - */ |
|
| 1765 | + * @since 1.07.10 |
|
| 1766 | + * |
|
| 1767 | + * @param float $min_version The version the add-on requires |
|
| 1768 | + */ |
|
| 1769 | 1769 | public static function min_version_notice( $min_version ) { |
| 1770 | - $frm_version = self::plugin_version(); |
|
| 1770 | + $frm_version = self::plugin_version(); |
|
| 1771 | 1771 | |
| 1772 | - // check if Formidable meets minimum requirements |
|
| 1773 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
| 1774 | - return; |
|
| 1775 | - } |
|
| 1772 | + // check if Formidable meets minimum requirements |
|
| 1773 | + if ( version_compare($frm_version, $min_version, '>=') ) { |
|
| 1774 | + return; |
|
| 1775 | + } |
|
| 1776 | 1776 | |
| 1777 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 1777 | + $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 1778 | 1778 | 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">' . |
| 1779 | - __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1780 | - '</div></td></tr>'; |
|
| 1781 | - } |
|
| 1782 | - |
|
| 1783 | - public static function locales( $type = 'date' ) { |
|
| 1784 | - $locales = array( |
|
| 1785 | - 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
| 1786 | - 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
| 1787 | - 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
| 1788 | - 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
|
| 1789 | - 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
| 1790 | - 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
| 1791 | - 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
|
| 1792 | - 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
| 1793 | - 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
| 1794 | - 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
|
| 1795 | - 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
| 1796 | - 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
|
| 1797 | - 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
| 1798 | - 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
|
| 1799 | - 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
| 1800 | - 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
|
| 1801 | - 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
| 1802 | - 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
| 1803 | - 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
| 1804 | - 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
| 1805 | - 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
| 1806 | - 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
|
| 1807 | - 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
| 1808 | - 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
|
| 1809 | - 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
|
| 1810 | - 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
| 1811 | - 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
|
| 1812 | - 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
| 1813 | - 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
|
| 1814 | - 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
| 1815 | - 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
| 1816 | - 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
| 1817 | - ); |
|
| 1818 | - |
|
| 1819 | - if ( $type == 'captcha' ) { |
|
| 1820 | - // remove the languages unavailable for the captcha |
|
| 1821 | - $unset = array( |
|
| 1822 | - '', 'af', 'sq', 'hy', 'az', 'eu', 'bs', |
|
| 1823 | - 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', |
|
| 1824 | - 'he', 'is', 'ms', 'sr-SR', 'ta', 'tu', |
|
| 1825 | - ); |
|
| 1826 | - } else { |
|
| 1827 | - // remove the languages unavailable for the datepicker |
|
| 1828 | - $unset = array( |
|
| 1829 | - 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', |
|
| 1830 | - 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', |
|
| 1831 | - 'es-419', 'tr', |
|
| 1832 | - ); |
|
| 1833 | - } |
|
| 1834 | - |
|
| 1835 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
| 1836 | - $locales = apply_filters('frm_locales', $locales); |
|
| 1837 | - |
|
| 1838 | - return $locales; |
|
| 1839 | - } |
|
| 1779 | + __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1780 | + '</div></td></tr>'; |
|
| 1781 | + } |
|
| 1782 | + |
|
| 1783 | + public static function locales( $type = 'date' ) { |
|
| 1784 | + $locales = array( |
|
| 1785 | + 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
| 1786 | + 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
| 1787 | + 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
| 1788 | + 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
|
| 1789 | + 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
| 1790 | + 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
| 1791 | + 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
|
| 1792 | + 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
| 1793 | + 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
| 1794 | + 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
|
| 1795 | + 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
| 1796 | + 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
|
| 1797 | + 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
| 1798 | + 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
|
| 1799 | + 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
| 1800 | + 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
|
| 1801 | + 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
| 1802 | + 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
| 1803 | + 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
| 1804 | + 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
| 1805 | + 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
| 1806 | + 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
|
| 1807 | + 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
| 1808 | + 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
|
| 1809 | + 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
|
| 1810 | + 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
| 1811 | + 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
|
| 1812 | + 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
| 1813 | + 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
|
| 1814 | + 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
| 1815 | + 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
| 1816 | + 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
| 1817 | + ); |
|
| 1818 | + |
|
| 1819 | + if ( $type == 'captcha' ) { |
|
| 1820 | + // remove the languages unavailable for the captcha |
|
| 1821 | + $unset = array( |
|
| 1822 | + '', 'af', 'sq', 'hy', 'az', 'eu', 'bs', |
|
| 1823 | + 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', |
|
| 1824 | + 'he', 'is', 'ms', 'sr-SR', 'ta', 'tu', |
|
| 1825 | + ); |
|
| 1826 | + } else { |
|
| 1827 | + // remove the languages unavailable for the datepicker |
|
| 1828 | + $unset = array( |
|
| 1829 | + 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', |
|
| 1830 | + 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', |
|
| 1831 | + 'es-419', 'tr', |
|
| 1832 | + ); |
|
| 1833 | + } |
|
| 1834 | + |
|
| 1835 | + $locales = array_diff_key($locales, array_flip($unset)); |
|
| 1836 | + $locales = apply_filters('frm_locales', $locales); |
|
| 1837 | + |
|
| 1838 | + return $locales; |
|
| 1839 | + } |
|
| 1840 | 1840 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined('ABSPATH') ) { |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 4 | } |
| 5 | 5 | |
@@ -23,11 +23,11 @@ discard block |
||
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public static function plugin_folder() { |
| 26 | - return basename(self::plugin_path()); |
|
| 26 | + return basename( self::plugin_path() ); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | public static function plugin_path() { |
| 30 | - return dirname(dirname(dirname(__FILE__))); |
|
| 30 | + return dirname( dirname( dirname( __FILE__ ) ) ); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | public static function plugin_url() { |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @return string |
| 55 | 55 | */ |
| 56 | 56 | public static function site_name() { |
| 57 | - return get_option('blogname'); |
|
| 57 | + return get_option( 'blogname' ); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | public static function make_affiliate_url( $url ) { |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | public static function get_settings() { |
| 81 | 81 | global $frm_settings; |
| 82 | - if ( empty($frm_settings) ) { |
|
| 82 | + if ( empty( $frm_settings ) ) { |
|
| 83 | 83 | $frm_settings = new FrmSettings(); |
| 84 | 84 | } |
| 85 | 85 | return $frm_settings; |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | public static function pro_is_installed() { |
| 102 | - return apply_filters('frm_pro_installed', false); |
|
| 102 | + return apply_filters( 'frm_pro_installed', false ); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * @return boolean |
| 145 | 145 | */ |
| 146 | 146 | public static function doing_ajax() { |
| 147 | - return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
| 147 | + return defined( 'DOING_AJAX' ) && DOING_AJAX && ! self::is_preview_page(); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | * @return boolean |
| 165 | 165 | */ |
| 166 | 166 | public static function is_admin() { |
| 167 | - return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
| 167 | + return is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | * @return string |
| 192 | 192 | */ |
| 193 | 193 | public static function get_server_value( $value ) { |
| 194 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 194 | + return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : ''; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -206,14 +206,14 @@ discard block |
||
| 206 | 206 | 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
| 207 | 207 | 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
| 208 | 208 | ) as $key ) { |
| 209 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 209 | + if ( ! isset( $_SERVER[$key] ) ) { |
|
| 210 | 210 | continue; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 214 | - $ip = trim($ip); // just to be safe |
|
| 213 | + foreach ( explode( ',', $_SERVER[$key] ) as $ip ) { |
|
| 214 | + $ip = trim( $ip ); // just to be safe |
|
| 215 | 215 | |
| 216 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
| 216 | + if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) { |
|
| 217 | 217 | return $ip; |
| 218 | 218 | } |
| 219 | 219 | } |
@@ -223,15 +223,15 @@ discard block |
||
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
| 226 | - if ( strpos($param, '[') ) { |
|
| 227 | - $params = explode('[', $param); |
|
| 226 | + if ( strpos( $param, '[' ) ) { |
|
| 227 | + $params = explode( '[', $param ); |
|
| 228 | 228 | $param = $params[0]; |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | if ( $src == 'get' ) { |
| 232 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 233 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 234 | - $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 232 | + $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default ); |
|
| 233 | + if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) { |
|
| 234 | + $value = stripslashes_deep( htmlspecialchars_decode( $_GET[$param] ) ); |
|
| 235 | 235 | } |
| 236 | 236 | self::sanitize_value( $sanitize, $value ); |
| 237 | 237 | } else { |
@@ -240,12 +240,12 @@ discard block |
||
| 240 | 240 | |
| 241 | 241 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
| 242 | 242 | foreach ( $params as $k => $p ) { |
| 243 | - if ( ! $k || ! is_array($value) ) { |
|
| 243 | + if ( ! $k || ! is_array( $value ) ) { |
|
| 244 | 244 | continue; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - $p = trim($p, ']'); |
|
| 248 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
| 247 | + $p = trim( $p, ']' ); |
|
| 248 | + $value = isset( $value[$p] ) ? $value[$p] : $default; |
|
| 249 | 249 | } |
| 250 | 250 | } |
| 251 | 251 | |
@@ -284,16 +284,16 @@ discard block |
||
| 284 | 284 | |
| 285 | 285 | $value = $args['default']; |
| 286 | 286 | if ( $args['type'] == 'get' ) { |
| 287 | - if ( $_GET && isset( $_GET[ $args['param'] ] ) ) { |
|
| 288 | - $value = $_GET[ $args['param'] ]; |
|
| 287 | + if ( $_GET && isset( $_GET[$args['param']] ) ) { |
|
| 288 | + $value = $_GET[$args['param']]; |
|
| 289 | 289 | } |
| 290 | 290 | } else if ( $args['type'] == 'post' ) { |
| 291 | - if ( isset( $_POST[ $args['param'] ] ) ) { |
|
| 292 | - $value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) ); |
|
| 291 | + if ( isset( $_POST[$args['param']] ) ) { |
|
| 292 | + $value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) ); |
|
| 293 | 293 | } |
| 294 | 294 | } else { |
| 295 | - if ( isset( $_REQUEST[ $args['param'] ] ) ) { |
|
| 296 | - $value = $_REQUEST[ $args['param'] ]; |
|
| 295 | + if ( isset( $_REQUEST[$args['param']] ) ) { |
|
| 296 | + $value = $_REQUEST[$args['param']]; |
|
| 297 | 297 | } |
| 298 | 298 | } |
| 299 | 299 | |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | if ( is_array( $value ) ) { |
| 322 | 322 | $temp_values = $value; |
| 323 | 323 | foreach ( $temp_values as $k => $v ) { |
| 324 | - FrmAppHelper::sanitize_value( $sanitize, $value[ $k ] ); |
|
| 324 | + FrmAppHelper::sanitize_value( $sanitize, $value[$k] ); |
|
| 325 | 325 | } |
| 326 | 326 | } else { |
| 327 | 327 | $value = call_user_func( $sanitize, $value ); |
@@ -332,8 +332,8 @@ discard block |
||
| 332 | 332 | public static function sanitize_request( $sanitize_method, &$values ) { |
| 333 | 333 | $temp_values = $values; |
| 334 | 334 | foreach ( $temp_values as $k => $val ) { |
| 335 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 336 | - $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
|
| 335 | + if ( isset( $sanitize_method[$k] ) ) { |
|
| 336 | + $values[$k] = call_user_func( $sanitize_method[$k], $val ); |
|
| 337 | 337 | } |
| 338 | 338 | } |
| 339 | 339 | } |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | public static function sanitize_array( &$values ) { |
| 342 | 342 | $temp_values = $values; |
| 343 | 343 | foreach ( $temp_values as $k => $val ) { |
| 344 | - $values[ $k ] = wp_kses_post( $val ); |
|
| 344 | + $values[$k] = wp_kses_post( $val ); |
|
| 345 | 345 | } |
| 346 | 346 | } |
| 347 | 347 | |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | |
| 365 | 365 | $allowed_html = array(); |
| 366 | 366 | foreach ( $allowed as $a ) { |
| 367 | - $allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array(); |
|
| 367 | + $allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array(); |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | return wp_kses( $value, $allowed_html ); |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | * @since 2.0 |
| 376 | 376 | */ |
| 377 | 377 | public static function remove_get_action() { |
| 378 | - if ( ! isset($_GET) ) { |
|
| 378 | + if ( ! isset( $_GET ) ) { |
|
| 379 | 379 | return; |
| 380 | 380 | } |
| 381 | 381 | |
@@ -397,8 +397,8 @@ discard block |
||
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | global $wp_query; |
| 400 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 401 | - $value = $wp_query->query_vars[ $param ]; |
|
| 400 | + if ( isset( $wp_query->query_vars[$param] ) ) { |
|
| 401 | + $value = $wp_query->query_vars[$param]; |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | return $value; |
@@ -447,19 +447,19 @@ discard block |
||
| 447 | 447 | * @return mixed $results The cache or query results |
| 448 | 448 | */ |
| 449 | 449 | public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
| 450 | - $results = wp_cache_get($cache_key, $group); |
|
| 451 | - if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
| 450 | + $results = wp_cache_get( $cache_key, $group ); |
|
| 451 | + if ( ! self::is_empty_value( $results, false ) || empty( $query ) ) { |
|
| 452 | 452 | return $results; |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | if ( 'get_posts' == $type ) { |
| 456 | - $results = get_posts($query); |
|
| 456 | + $results = get_posts( $query ); |
|
| 457 | 457 | } else if ( 'get_associative_results' == $type ) { |
| 458 | 458 | global $wpdb; |
| 459 | 459 | $results = $wpdb->get_results( $query, OBJECT_K ); |
| 460 | 460 | } else { |
| 461 | 461 | global $wpdb; |
| 462 | - $results = $wpdb->{$type}($query); |
|
| 462 | + $results = $wpdb->{$type}( $query ); |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | self::set_cache( $cache_key, $results, $group, $time ); |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | */ |
| 481 | 481 | public static function add_key_to_group_cache( $key, $group ) { |
| 482 | 482 | $cached = self::get_group_cached_keys( $group ); |
| 483 | - $cached[ $key ] = $key; |
|
| 483 | + $cached[$key] = $key; |
|
| 484 | 484 | wp_cache_set( 'cached_keys', $cached, $group, 300 ); |
| 485 | 485 | } |
| 486 | 486 | |
@@ -507,9 +507,9 @@ discard block |
||
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | // then check the transient |
| 510 | - $results = get_transient($cache_key); |
|
| 510 | + $results = get_transient( $cache_key ); |
|
| 511 | 511 | if ( $results ) { |
| 512 | - wp_cache_set($cache_key, $results); |
|
| 512 | + wp_cache_set( $cache_key, $results ); |
|
| 513 | 513 | } |
| 514 | 514 | |
| 515 | 515 | return $results; |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | * @param string $cache_key |
| 521 | 521 | */ |
| 522 | 522 | public static function delete_cache_and_transient( $cache_key, $group = 'default' ) { |
| 523 | - delete_transient($cache_key); |
|
| 523 | + delete_transient( $cache_key ); |
|
| 524 | 524 | wp_cache_delete( $cache_key, $group ); |
| 525 | 525 | } |
| 526 | 526 | |
@@ -564,17 +564,17 @@ discard block |
||
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | public static function get_pages() { |
| 567 | - return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
|
| 567 | + return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => - 1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
|
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
| 571 | 571 | $pages = self::get_pages(); |
| 572 | 572 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
| 573 | 573 | ?> |
| 574 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
|
| 574 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown"> |
|
| 575 | 575 | <option value=""> </option> |
| 576 | 576 | <?php foreach ( $pages as $page ) { ?> |
| 577 | - <option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
| 577 | + <option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
| 578 | 578 | <?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?> |
| 579 | 579 | </option> |
| 580 | 580 | <?php } ?> |
@@ -583,7 +583,7 @@ discard block |
||
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | public static function post_edit_link( $post_id ) { |
| 586 | - $post = get_post($post_id); |
|
| 586 | + $post = get_post( $post_id ); |
|
| 587 | 587 | if ( $post ) { |
| 588 | 588 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
| 589 | 589 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
@@ -593,17 +593,17 @@ discard block |
||
| 593 | 593 | |
| 594 | 594 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
| 595 | 595 | ?> |
| 596 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php |
|
| 596 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php |
|
| 597 | 597 | echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
| 598 | 598 | ?> class="frm_multiselect"> |
| 599 | - <?php self::roles_options($capability); ?> |
|
| 599 | + <?php self::roles_options( $capability ); ?> |
|
| 600 | 600 | </select> |
| 601 | 601 | <?php |
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | public static function roles_options( $capability ) { |
| 605 | 605 | global $frm_vars; |
| 606 | - if ( isset($frm_vars['editable_roles']) ) { |
|
| 606 | + if ( isset( $frm_vars['editable_roles'] ) ) { |
|
| 607 | 607 | $editable_roles = $frm_vars['editable_roles']; |
| 608 | 608 | } else { |
| 609 | 609 | $editable_roles = get_editable_roles(); |
@@ -611,10 +611,10 @@ discard block |
||
| 611 | 611 | } |
| 612 | 612 | |
| 613 | 613 | foreach ( $editable_roles as $role => $details ) { |
| 614 | - $name = translate_user_role($details['name'] ); ?> |
|
| 615 | - <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
|
| 614 | + $name = translate_user_role( $details['name'] ); ?> |
|
| 615 | + <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option> |
|
| 616 | 616 | <?php |
| 617 | - unset($role, $details); |
|
| 617 | + unset( $role, $details ); |
|
| 618 | 618 | } |
| 619 | 619 | } |
| 620 | 620 | |
@@ -670,7 +670,7 @@ discard block |
||
| 670 | 670 | public static function maybe_add_permissions() { |
| 671 | 671 | self::force_capability( 'frm_view_entries' ); |
| 672 | 672 | |
| 673 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
| 673 | + if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) { |
|
| 674 | 674 | return; |
| 675 | 675 | } |
| 676 | 676 | |
@@ -679,7 +679,7 @@ discard block |
||
| 679 | 679 | $frm_roles = self::frm_capabilities(); |
| 680 | 680 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
| 681 | 681 | $user->add_cap( $frm_role ); |
| 682 | - unset($frm_role, $frm_role_description); |
|
| 682 | + unset( $frm_role, $frm_role_description ); |
|
| 683 | 683 | } |
| 684 | 684 | } |
| 685 | 685 | |
@@ -704,12 +704,12 @@ discard block |
||
| 704 | 704 | * @param string $permission |
| 705 | 705 | */ |
| 706 | 706 | public static function permission_check( $permission, $show_message = 'show' ) { |
| 707 | - $permission_error = self::permission_nonce_error($permission); |
|
| 707 | + $permission_error = self::permission_nonce_error( $permission ); |
|
| 708 | 708 | if ( $permission_error !== false ) { |
| 709 | 709 | if ( 'hide' == $show_message ) { |
| 710 | 710 | $permission_error = ''; |
| 711 | 711 | } |
| 712 | - wp_die($permission_error); |
|
| 712 | + wp_die( $permission_error ); |
|
| 713 | 713 | } |
| 714 | 714 | } |
| 715 | 715 | |
@@ -726,11 +726,11 @@ discard block |
||
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | $error = false; |
| 729 | - if ( empty($nonce_name) ) { |
|
| 729 | + if ( empty( $nonce_name ) ) { |
|
| 730 | 730 | return $error; |
| 731 | 731 | } |
| 732 | 732 | |
| 733 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 733 | + if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) { |
|
| 734 | 734 | $frm_settings = self::get_settings(); |
| 735 | 735 | $error = $frm_settings->admin_permission; |
| 736 | 736 | } |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | } else { |
| 766 | 766 | foreach ( $value as $k => $v ) { |
| 767 | 767 | if ( ! is_array( $v ) ) { |
| 768 | - $value[ $k ] = call_user_func( $original_function, $v ); |
|
| 768 | + $value[$k] = call_user_func( $original_function, $v ); |
|
| 769 | 769 | } |
| 770 | 770 | } |
| 771 | 771 | } |
@@ -786,11 +786,11 @@ discard block |
||
| 786 | 786 | public static function array_flatten( $array, $keys = 'keep' ) { |
| 787 | 787 | $return = array(); |
| 788 | 788 | foreach ( $array as $key => $value ) { |
| 789 | - if ( is_array($value) ) { |
|
| 789 | + if ( is_array( $value ) ) { |
|
| 790 | 790 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
| 791 | 791 | } else { |
| 792 | 792 | if ( $keys == 'keep' ) { |
| 793 | - $return[ $key ] = $value; |
|
| 793 | + $return[$key] = $value; |
|
| 794 | 794 | } else { |
| 795 | 795 | $return[] = $value; |
| 796 | 796 | } |
@@ -813,8 +813,8 @@ discard block |
||
| 813 | 813 | * @since 2.0 |
| 814 | 814 | */ |
| 815 | 815 | public static function use_wpautop( $content ) { |
| 816 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
| 817 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
| 816 | + if ( apply_filters( 'frm_use_wpautop', true ) ) { |
|
| 817 | + $content = wpautop( str_replace( '<br>', '<br />', $content ) ); |
|
| 818 | 818 | } |
| 819 | 819 | return $content; |
| 820 | 820 | } |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | */ |
| 834 | 834 | public static function jquery_ui_base_url() { |
| 835 | 835 | $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' ); |
| 836 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
| 836 | + $url = apply_filters( 'frm_jquery_ui_base_url', $url ); |
|
| 837 | 837 | return $url; |
| 838 | 838 | } |
| 839 | 839 | |
@@ -847,11 +847,11 @@ discard block |
||
| 847 | 847 | } |
| 848 | 848 | |
| 849 | 849 | $ver = $default; |
| 850 | - if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
|
| 850 | + if ( ! isset( $wp_scripts->registered[$handle] ) ) { |
|
| 851 | 851 | return $ver; |
| 852 | 852 | } |
| 853 | 853 | |
| 854 | - $query = $wp_scripts->registered[ $handle ]; |
|
| 854 | + $query = $wp_scripts->registered[$handle]; |
|
| 855 | 855 | if ( is_object( $query ) && ! empty( $query->ver ) ) { |
| 856 | 856 | $ver = $query->ver; |
| 857 | 857 | } |
@@ -864,36 +864,36 @@ discard block |
||
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | public static function get_user_id_param( $user_id ) { |
| 867 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
| 867 | + if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) { |
|
| 868 | 868 | return $user_id; |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | 871 | if ( $user_id == 'current' ) { |
| 872 | 872 | $user_id = get_current_user_id(); |
| 873 | 873 | } else { |
| 874 | - if ( is_email($user_id) ) { |
|
| 875 | - $user = get_user_by('email', $user_id); |
|
| 874 | + if ( is_email( $user_id ) ) { |
|
| 875 | + $user = get_user_by( 'email', $user_id ); |
|
| 876 | 876 | } else { |
| 877 | - $user = get_user_by('login', $user_id); |
|
| 877 | + $user = get_user_by( 'login', $user_id ); |
|
| 878 | 878 | } |
| 879 | 879 | |
| 880 | 880 | if ( $user ) { |
| 881 | 881 | $user_id = $user->ID; |
| 882 | 882 | } |
| 883 | - unset($user); |
|
| 883 | + unset( $user ); |
|
| 884 | 884 | } |
| 885 | 885 | |
| 886 | 886 | return $user_id; |
| 887 | 887 | } |
| 888 | 888 | |
| 889 | 889 | public static function get_file_contents( $filename, $atts = array() ) { |
| 890 | - if ( ! is_file($filename) ) { |
|
| 890 | + if ( ! is_file( $filename ) ) { |
|
| 891 | 891 | return false; |
| 892 | 892 | } |
| 893 | 893 | |
| 894 | - extract($atts); |
|
| 894 | + extract( $atts ); |
|
| 895 | 895 | ob_start(); |
| 896 | - include($filename); |
|
| 896 | + include( $filename ); |
|
| 897 | 897 | $contents = ob_get_contents(); |
| 898 | 898 | ob_end_clean(); |
| 899 | 899 | return $contents; |
@@ -909,27 +909,27 @@ discard block |
||
| 909 | 909 | $key = ''; |
| 910 | 910 | |
| 911 | 911 | if ( ! empty( $name ) ) { |
| 912 | - $key = sanitize_key($name); |
|
| 912 | + $key = sanitize_key( $name ); |
|
| 913 | 913 | } |
| 914 | 914 | |
| 915 | 915 | if ( empty( $key ) ) { |
| 916 | - $max_slug_value = pow(36, $num_chars); |
|
| 916 | + $max_slug_value = pow( 36, $num_chars ); |
|
| 917 | 917 | $min_slug_value = 37; // we want to have at least 2 characters in the slug |
| 918 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 918 | + $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); |
|
| 919 | 919 | } |
| 920 | 920 | |
| 921 | - if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
|
| 921 | + if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
|
| 922 | 922 | $key = $key . 'a'; |
| 923 | 923 | } |
| 924 | 924 | |
| 925 | 925 | $key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column ); |
| 926 | 926 | |
| 927 | - if ( $key_check || is_numeric($key_check) ) { |
|
| 927 | + if ( $key_check || is_numeric( $key_check ) ) { |
|
| 928 | 928 | $suffix = 2; |
| 929 | 929 | do { |
| 930 | 930 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
| 931 | 931 | $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column ); |
| 932 | - $suffix++; |
|
| 932 | + $suffix ++; |
|
| 933 | 933 | } while ( $key_check || is_numeric( $key_check ) ); |
| 934 | 934 | $key = $alt_post_name; |
| 935 | 935 | } |
@@ -946,21 +946,21 @@ discard block |
||
| 946 | 946 | return false; |
| 947 | 947 | } |
| 948 | 948 | |
| 949 | - if ( empty($post_values) ) { |
|
| 950 | - $post_values = stripslashes_deep($_POST); |
|
| 949 | + if ( empty( $post_values ) ) { |
|
| 950 | + $post_values = stripslashes_deep( $_POST ); |
|
| 951 | 951 | } |
| 952 | 952 | |
| 953 | 953 | $values = array( 'id' => $record->id, 'fields' => array() ); |
| 954 | 954 | |
| 955 | 955 | foreach ( array( 'name', 'description' ) as $var ) { |
| 956 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
| 957 | - $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
|
| 958 | - unset($var, $default_val); |
|
| 956 | + $default_val = isset( $record->{$var}) ? $record->{$var} : ''; |
|
| 957 | + $values[$var] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
|
| 958 | + unset( $var, $default_val ); |
|
| 959 | 959 | } |
| 960 | 960 | |
| 961 | - $values['description'] = self::use_wpautop($values['description']); |
|
| 961 | + $values['description'] = self::use_wpautop( $values['description'] ); |
|
| 962 | 962 | |
| 963 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
| 963 | + self::fill_form_opts( $record, $table, $post_values, $values ); |
|
| 964 | 964 | |
| 965 | 965 | self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) ); |
| 966 | 966 | |
@@ -976,7 +976,7 @@ discard block |
||
| 976 | 976 | private static function prepare_field_arrays( $fields, $record, array &$values, $args ) { |
| 977 | 977 | if ( ! empty( $fields ) ) { |
| 978 | 978 | foreach ( (array) $fields as $field ) { |
| 979 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
| 979 | + $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true ); |
|
| 980 | 980 | $args['parent_form_id'] = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; |
| 981 | 981 | self::fill_field_defaults( $field, $record, $values, $args ); |
| 982 | 982 | } |
@@ -989,8 +989,8 @@ discard block |
||
| 989 | 989 | if ( $args['default'] ) { |
| 990 | 990 | $meta_value = $field->default_value; |
| 991 | 991 | } else { |
| 992 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
| 993 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
| 992 | + if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) { |
|
| 993 | + if ( ! isset( $field->field_options['custom_field'] ) ) { |
|
| 994 | 994 | $field->field_options['custom_field'] = ''; |
| 995 | 995 | } |
| 996 | 996 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) ); |
@@ -999,8 +999,8 @@ discard block |
||
| 999 | 999 | } |
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | - $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
|
| 1003 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1002 | + $field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type; |
|
| 1003 | + $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value; |
|
| 1004 | 1004 | |
| 1005 | 1005 | $field_array = array( |
| 1006 | 1006 | 'id' => $field->id, |
@@ -1008,7 +1008,7 @@ discard block |
||
| 1008 | 1008 | 'default_value' => $field->default_value, |
| 1009 | 1009 | 'name' => $field->name, |
| 1010 | 1010 | 'description' => $field->description, |
| 1011 | - 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
| 1011 | + 'type' => apply_filters( 'frm_field_type', $field_type, $field, $new_value ), |
|
| 1012 | 1012 | 'options' => $field->options, |
| 1013 | 1013 | 'required' => $field->required, |
| 1014 | 1014 | 'field_key' => $field->field_key, |
@@ -1018,19 +1018,19 @@ discard block |
||
| 1018 | 1018 | ); |
| 1019 | 1019 | |
| 1020 | 1020 | $args['field_type'] = $field_type; |
| 1021 | - self::fill_field_opts($field, $field_array, $args); |
|
| 1021 | + self::fill_field_opts( $field, $field_array, $args ); |
|
| 1022 | 1022 | // Track the original field's type |
| 1023 | 1023 | $field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type; |
| 1024 | 1024 | |
| 1025 | 1025 | $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() ); |
| 1026 | 1026 | |
| 1027 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
| 1027 | + if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) { |
|
| 1028 | 1028 | $field_array['unique_msg'] = ''; |
| 1029 | 1029 | } |
| 1030 | 1030 | |
| 1031 | 1031 | $field_array = array_merge( $field->field_options, $field_array ); |
| 1032 | 1032 | |
| 1033 | - $values['fields'][ $field->id ] = $field_array; |
|
| 1033 | + $values['fields'][$field->id] = $field_array; |
|
| 1034 | 1034 | } |
| 1035 | 1035 | |
| 1036 | 1036 | private static function fill_field_opts( $field, array &$field_array, $args ) { |
@@ -1040,20 +1040,20 @@ discard block |
||
| 1040 | 1040 | $frm_settings = self::get_settings(); |
| 1041 | 1041 | |
| 1042 | 1042 | foreach ( $opt_defaults as $opt => $default_opt ) { |
| 1043 | - $field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt . '_' . $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt . '_' . $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt ); |
|
| 1044 | - if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
| 1045 | - $field_array[ $opt ] = $frm_settings->blank_msg; |
|
| 1046 | - } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
| 1043 | + $field_array[$opt] = ( $post_values && isset( $post_values['field_options'][$opt . '_' . $field->id] ) ) ? maybe_unserialize( $post_values['field_options'][$opt . '_' . $field->id] ) : ( isset( $field->field_options[$opt] ) ? $field->field_options[$opt] : $default_opt ); |
|
| 1044 | + if ( $opt == 'blank' && $field_array[$opt] == '' ) { |
|
| 1045 | + $field_array[$opt] = $frm_settings->blank_msg; |
|
| 1046 | + } else if ( $opt == 'invalid' && $field_array[$opt] == '' ) { |
|
| 1047 | 1047 | if ( $args['field_type'] == 'captcha' ) { |
| 1048 | - $field_array[ $opt ] = $frm_settings->re_msg; |
|
| 1048 | + $field_array[$opt] = $frm_settings->re_msg; |
|
| 1049 | 1049 | } else { |
| 1050 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
| 1050 | + $field_array[$opt] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
| 1051 | 1051 | } |
| 1052 | 1052 | } |
| 1053 | 1053 | } |
| 1054 | 1054 | |
| 1055 | 1055 | if ( $field_array['custom_html'] == '' ) { |
| 1056 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
| 1056 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $args['field_type'] ); |
|
| 1057 | 1057 | } |
| 1058 | 1058 | } |
| 1059 | 1059 | |
@@ -1072,18 +1072,18 @@ discard block |
||
| 1072 | 1072 | return; |
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
| 1075 | + $values['form_name'] = isset( $record->form_id ) ? $form->name : ''; |
|
| 1076 | 1076 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
| 1077 | 1077 | |
| 1078 | - if ( ! is_array($form->options) ) { |
|
| 1078 | + if ( ! is_array( $form->options ) ) { |
|
| 1079 | 1079 | return; |
| 1080 | 1080 | } |
| 1081 | 1081 | |
| 1082 | 1082 | foreach ( $form->options as $opt => $value ) { |
| 1083 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1083 | + $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value; |
|
| 1084 | 1084 | } |
| 1085 | 1085 | |
| 1086 | - self::fill_form_defaults($post_values, $values); |
|
| 1086 | + self::fill_form_defaults( $post_values, $values ); |
|
| 1087 | 1087 | } |
| 1088 | 1088 | |
| 1089 | 1089 | /** |
@@ -1093,11 +1093,11 @@ discard block |
||
| 1093 | 1093 | $form_defaults = FrmFormsHelper::get_default_opts(); |
| 1094 | 1094 | |
| 1095 | 1095 | foreach ( $form_defaults as $opt => $default ) { |
| 1096 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1097 | - $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
|
| 1096 | + if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) { |
|
| 1097 | + $values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default; |
|
| 1098 | 1098 | } |
| 1099 | 1099 | |
| 1100 | - unset($opt, $defaut); |
|
| 1100 | + unset( $opt, $defaut ); |
|
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | 1103 | if ( ! isset( $values['custom_style'] ) ) { |
@@ -1105,10 +1105,10 @@ discard block |
||
| 1105 | 1105 | } |
| 1106 | 1106 | |
| 1107 | 1107 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
| 1108 | - if ( ! isset( $values[ $h . '_html' ] ) ) { |
|
| 1109 | - $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
|
| 1108 | + if ( ! isset( $values[$h . '_html'] ) ) { |
|
| 1109 | + $values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) ); |
|
| 1110 | 1110 | } |
| 1111 | - unset($h); |
|
| 1111 | + unset( $h ); |
|
| 1112 | 1112 | } |
| 1113 | 1113 | } |
| 1114 | 1114 | |
@@ -1135,9 +1135,9 @@ discard block |
||
| 1135 | 1135 | } |
| 1136 | 1136 | ?> |
| 1137 | 1137 | <li> |
| 1138 | - <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> |
|
| 1139 | - <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> |
|
| 1140 | - <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> |
|
| 1138 | + <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> |
|
| 1139 | + <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> |
|
| 1140 | + <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> |
|
| 1141 | 1141 | </li> |
| 1142 | 1142 | <?php |
| 1143 | 1143 | } |
@@ -1155,7 +1155,7 @@ discard block |
||
| 1155 | 1155 | return ''; |
| 1156 | 1156 | } else if ( $length <= 10 ) { |
| 1157 | 1157 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
| 1158 | - return $sub . (($length < $original_len) ? $continue : ''); |
|
| 1158 | + return $sub . ( ( $length < $original_len ) ? $continue : '' ); |
|
| 1159 | 1159 | } |
| 1160 | 1160 | |
| 1161 | 1161 | $sub = ''; |
@@ -1164,23 +1164,23 @@ discard block |
||
| 1164 | 1164 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
| 1165 | 1165 | |
| 1166 | 1166 | foreach ( $words as $word ) { |
| 1167 | - $part = (($sub != '') ? ' ' : '') . $word; |
|
| 1167 | + $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; |
|
| 1168 | 1168 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
| 1169 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
| 1169 | + if ( $total_len > $length && str_word_count( $sub ) ) { |
|
| 1170 | 1170 | break; |
| 1171 | 1171 | } |
| 1172 | 1172 | |
| 1173 | 1173 | $sub .= $part; |
| 1174 | 1174 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
| 1175 | 1175 | |
| 1176 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
| 1176 | + if ( str_word_count( $sub ) > $minword && $total_len >= $length ) { |
|
| 1177 | 1177 | break; |
| 1178 | 1178 | } |
| 1179 | 1179 | |
| 1180 | - unset($total_len, $word); |
|
| 1180 | + unset( $total_len, $word ); |
|
| 1181 | 1181 | } |
| 1182 | 1182 | |
| 1183 | - return $sub . (($len < $original_len) ? $continue : ''); |
|
| 1183 | + return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
|
| 1184 | 1184 | } |
| 1185 | 1185 | |
| 1186 | 1186 | public static function mb_function( $function_names, $args ) { |
@@ -1193,17 +1193,17 @@ discard block |
||
| 1193 | 1193 | } |
| 1194 | 1194 | |
| 1195 | 1195 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
| 1196 | - if ( empty($date) ) { |
|
| 1196 | + if ( empty( $date ) ) { |
|
| 1197 | 1197 | return $date; |
| 1198 | 1198 | } |
| 1199 | 1199 | |
| 1200 | - if ( empty($date_format) ) { |
|
| 1201 | - $date_format = get_option('date_format'); |
|
| 1200 | + if ( empty( $date_format ) ) { |
|
| 1201 | + $date_format = get_option( 'date_format' ); |
|
| 1202 | 1202 | } |
| 1203 | 1203 | |
| 1204 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
| 1204 | + if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) { |
|
| 1205 | 1205 | $frmpro_settings = new FrmProSettings(); |
| 1206 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
| 1206 | + $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' ); |
|
| 1207 | 1207 | } |
| 1208 | 1208 | |
| 1209 | 1209 | $formatted = self::get_localized_date( $date_format, $date ); |
@@ -1218,7 +1218,7 @@ discard block |
||
| 1218 | 1218 | |
| 1219 | 1219 | private static function add_time_to_date( $time_format, $date ) { |
| 1220 | 1220 | if ( empty( $time_format ) ) { |
| 1221 | - $time_format = get_option('time_format'); |
|
| 1221 | + $time_format = get_option( 'time_format' ); |
|
| 1222 | 1222 | } |
| 1223 | 1223 | |
| 1224 | 1224 | $trimmed_format = trim( $time_format ); |
@@ -1264,10 +1264,10 @@ discard block |
||
| 1264 | 1264 | $time_strings = self::get_time_strings(); |
| 1265 | 1265 | |
| 1266 | 1266 | foreach ( $time_strings as $k => $v ) { |
| 1267 | - if ( $diff[ $k ] ) { |
|
| 1268 | - $time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] ); |
|
| 1267 | + if ( $diff[$k] ) { |
|
| 1268 | + $time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] ); |
|
| 1269 | 1269 | } else { |
| 1270 | - unset( $time_strings[ $k ] ); |
|
| 1270 | + unset( $time_strings[$k] ); |
|
| 1271 | 1271 | } |
| 1272 | 1272 | } |
| 1273 | 1273 | |
@@ -1306,7 +1306,7 @@ discard block |
||
| 1306 | 1306 | */ |
| 1307 | 1307 | public static function esc_like( $term ) { |
| 1308 | 1308 | global $wpdb; |
| 1309 | - if ( method_exists($wpdb, 'esc_like') ) { |
|
| 1309 | + if ( method_exists( $wpdb, 'esc_like' ) ) { |
|
| 1310 | 1310 | // WP 4.0 |
| 1311 | 1311 | $term = $wpdb->esc_like( $term ); |
| 1312 | 1312 | } else { |
@@ -1320,17 +1320,17 @@ discard block |
||
| 1320 | 1320 | * @param string $order_query |
| 1321 | 1321 | */ |
| 1322 | 1322 | public static function esc_order( $order_query ) { |
| 1323 | - if ( empty($order_query) ) { |
|
| 1323 | + if ( empty( $order_query ) ) { |
|
| 1324 | 1324 | return ''; |
| 1325 | 1325 | } |
| 1326 | 1326 | |
| 1327 | 1327 | // remove ORDER BY before santizing |
| 1328 | - $order_query = strtolower($order_query); |
|
| 1329 | - if ( strpos($order_query, 'order by') !== false ) { |
|
| 1330 | - $order_query = str_replace('order by', '', $order_query); |
|
| 1328 | + $order_query = strtolower( $order_query ); |
|
| 1329 | + if ( strpos( $order_query, 'order by' ) !== false ) { |
|
| 1330 | + $order_query = str_replace( 'order by', '', $order_query ); |
|
| 1331 | 1331 | } |
| 1332 | 1332 | |
| 1333 | - $order_query = explode(' ', trim($order_query)); |
|
| 1333 | + $order_query = explode( ' ', trim( $order_query ) ); |
|
| 1334 | 1334 | |
| 1335 | 1335 | $order_fields = array( |
| 1336 | 1336 | 'id', 'form_key', 'name', 'description', |
@@ -1338,13 +1338,13 @@ discard block |
||
| 1338 | 1338 | 'default_template', 'status', 'created_at', |
| 1339 | 1339 | ); |
| 1340 | 1340 | |
| 1341 | - $order = trim(trim(reset($order_query), ',')); |
|
| 1342 | - if ( ! in_array($order, $order_fields) ) { |
|
| 1341 | + $order = trim( trim( reset( $order_query ), ',' ) ); |
|
| 1342 | + if ( ! in_array( $order, $order_fields ) ) { |
|
| 1343 | 1343 | return ''; |
| 1344 | 1344 | } |
| 1345 | 1345 | |
| 1346 | 1346 | $order_by = ''; |
| 1347 | - if ( count($order_query) > 1 ) { |
|
| 1347 | + if ( count( $order_query ) > 1 ) { |
|
| 1348 | 1348 | $order_by = end( $order_query ); |
| 1349 | 1349 | self::esc_order_by( $order_by ); |
| 1350 | 1350 | } |
@@ -1366,23 +1366,23 @@ discard block |
||
| 1366 | 1366 | * @param string $limit |
| 1367 | 1367 | */ |
| 1368 | 1368 | public static function esc_limit( $limit ) { |
| 1369 | - if ( empty($limit) ) { |
|
| 1369 | + if ( empty( $limit ) ) { |
|
| 1370 | 1370 | return ''; |
| 1371 | 1371 | } |
| 1372 | 1372 | |
| 1373 | - $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
| 1374 | - if ( is_numeric($limit) ) { |
|
| 1373 | + $limit = trim( str_replace( ' limit', '', strtolower( $limit ) ) ); |
|
| 1374 | + if ( is_numeric( $limit ) ) { |
|
| 1375 | 1375 | return ' LIMIT ' . $limit; |
| 1376 | 1376 | } |
| 1377 | 1377 | |
| 1378 | - $limit = explode(',', trim($limit)); |
|
| 1378 | + $limit = explode( ',', trim( $limit ) ); |
|
| 1379 | 1379 | foreach ( $limit as $k => $l ) { |
| 1380 | 1380 | if ( is_numeric( $l ) ) { |
| 1381 | - $limit[ $k ] = $l; |
|
| 1381 | + $limit[$k] = $l; |
|
| 1382 | 1382 | } |
| 1383 | 1383 | } |
| 1384 | 1384 | |
| 1385 | - $limit = implode(',', $limit); |
|
| 1385 | + $limit = implode( ',', $limit ); |
|
| 1386 | 1386 | return ' LIMIT ' . $limit; |
| 1387 | 1387 | } |
| 1388 | 1388 | |
@@ -1391,12 +1391,12 @@ discard block |
||
| 1391 | 1391 | * @since 2.0 |
| 1392 | 1392 | */ |
| 1393 | 1393 | public static function prepare_array_values( $array, $type = '%s' ) { |
| 1394 | - $placeholders = array_fill(0, count($array), $type); |
|
| 1395 | - return implode(', ', $placeholders); |
|
| 1394 | + $placeholders = array_fill( 0, count( $array ), $type ); |
|
| 1395 | + return implode( ', ', $placeholders ); |
|
| 1396 | 1396 | } |
| 1397 | 1397 | |
| 1398 | 1398 | public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
| 1399 | - if ( empty($where) ) { |
|
| 1399 | + if ( empty( $where ) ) { |
|
| 1400 | 1400 | return ''; |
| 1401 | 1401 | } |
| 1402 | 1402 | |
@@ -1437,19 +1437,19 @@ discard block |
||
| 1437 | 1437 | public static function json_to_array( $json_vars ) { |
| 1438 | 1438 | $vars = array(); |
| 1439 | 1439 | foreach ( $json_vars as $jv ) { |
| 1440 | - $jv_name = explode('[', $jv['name']); |
|
| 1441 | - $last = count($jv_name) - 1; |
|
| 1440 | + $jv_name = explode( '[', $jv['name'] ); |
|
| 1441 | + $last = count( $jv_name ) - 1; |
|
| 1442 | 1442 | foreach ( $jv_name as $p => $n ) { |
| 1443 | - $name = trim($n, ']'); |
|
| 1444 | - if ( ! isset($l1) ) { |
|
| 1443 | + $name = trim( $n, ']' ); |
|
| 1444 | + if ( ! isset( $l1 ) ) { |
|
| 1445 | 1445 | $l1 = $name; |
| 1446 | 1446 | } |
| 1447 | 1447 | |
| 1448 | - if ( ! isset($l2) ) { |
|
| 1448 | + if ( ! isset( $l2 ) ) { |
|
| 1449 | 1449 | $l2 = $name; |
| 1450 | 1450 | } |
| 1451 | 1451 | |
| 1452 | - if ( ! isset($l3) ) { |
|
| 1452 | + if ( ! isset( $l3 ) ) { |
|
| 1453 | 1453 | $l3 = $name; |
| 1454 | 1454 | } |
| 1455 | 1455 | |
@@ -1463,24 +1463,24 @@ discard block |
||
| 1463 | 1463 | |
| 1464 | 1464 | case 1: |
| 1465 | 1465 | $l2 = $name; |
| 1466 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1466 | + self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] ); |
|
| 1467 | 1467 | break; |
| 1468 | 1468 | |
| 1469 | 1469 | case 2: |
| 1470 | 1470 | $l3 = $name; |
| 1471 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1471 | + self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] ); |
|
| 1472 | 1472 | break; |
| 1473 | 1473 | |
| 1474 | 1474 | case 3: |
| 1475 | 1475 | $l4 = $name; |
| 1476 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1476 | + self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] ); |
|
| 1477 | 1477 | break; |
| 1478 | 1478 | } |
| 1479 | 1479 | |
| 1480 | - unset($this_val, $n); |
|
| 1480 | + unset( $this_val, $n ); |
|
| 1481 | 1481 | } |
| 1482 | 1482 | |
| 1483 | - unset($last, $jv); |
|
| 1483 | + unset( $last, $jv ); |
|
| 1484 | 1484 | } |
| 1485 | 1485 | |
| 1486 | 1486 | return $vars; |
@@ -1493,8 +1493,8 @@ discard block |
||
| 1493 | 1493 | public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
| 1494 | 1494 | if ( $name == '' ) { |
| 1495 | 1495 | $vars[] = $val; |
| 1496 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1497 | - $vars[ $l1 ] = $val; |
|
| 1496 | + } else if ( ! isset( $vars[$l1] ) ) { |
|
| 1497 | + $vars[$l1] = $val; |
|
| 1498 | 1498 | } |
| 1499 | 1499 | } |
| 1500 | 1500 | |
@@ -1509,7 +1509,7 @@ discard block |
||
| 1509 | 1509 | '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() ) ), |
| 1510 | 1510 | ); |
| 1511 | 1511 | |
| 1512 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1512 | + if ( ! isset( $tooltips[$name] ) ) { |
|
| 1513 | 1513 | return; |
| 1514 | 1514 | } |
| 1515 | 1515 | |
@@ -1519,7 +1519,7 @@ discard block |
||
| 1519 | 1519 | echo ' class="frm_help"'; |
| 1520 | 1520 | } |
| 1521 | 1521 | |
| 1522 | - echo ' title="' . esc_attr( $tooltips[ $name ] ); |
|
| 1522 | + echo ' title="' . esc_attr( $tooltips[$name] ); |
|
| 1523 | 1523 | |
| 1524 | 1524 | if ( 'open' != $class ) { |
| 1525 | 1525 | echo '"'; |
@@ -1571,13 +1571,13 @@ discard block |
||
| 1571 | 1571 | } |
| 1572 | 1572 | |
| 1573 | 1573 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
| 1574 | - if ( ! isset( $post_content[ $key ] ) ) { |
|
| 1574 | + if ( ! isset( $post_content[$key] ) ) { |
|
| 1575 | 1575 | return; |
| 1576 | 1576 | } |
| 1577 | 1577 | |
| 1578 | 1578 | if ( is_array( $val ) ) { |
| 1579 | 1579 | foreach ( $val as $k1 => $v1 ) { |
| 1580 | - self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] ); |
|
| 1580 | + self::prepare_action_slashes( $v1, $k1, $post_content[$key] ); |
|
| 1581 | 1581 | unset( $k1, $v1 ); |
| 1582 | 1582 | } |
| 1583 | 1583 | } else { |
@@ -1585,7 +1585,7 @@ discard block |
||
| 1585 | 1585 | $val = stripslashes( $val ); |
| 1586 | 1586 | |
| 1587 | 1587 | // Add backslashes before double quotes and forward slashes only |
| 1588 | - $post_content[ $key ] = addcslashes( $val, '"\\/' ); |
|
| 1588 | + $post_content[$key] = addcslashes( $val, '"\\/' ); |
|
| 1589 | 1589 | } |
| 1590 | 1590 | } |
| 1591 | 1591 | |
@@ -1602,7 +1602,7 @@ discard block |
||
| 1602 | 1602 | $settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] ); |
| 1603 | 1603 | |
| 1604 | 1604 | if ( empty( $settings['ID'] ) ) { |
| 1605 | - unset( $settings['ID']); |
|
| 1605 | + unset( $settings['ID'] ); |
|
| 1606 | 1606 | } |
| 1607 | 1607 | |
| 1608 | 1608 | // delete all caches for this group |
@@ -1636,17 +1636,17 @@ discard block |
||
| 1636 | 1636 | } |
| 1637 | 1637 | |
| 1638 | 1638 | public static function maybe_json_decode( $string ) { |
| 1639 | - if ( is_array($string) ) { |
|
| 1639 | + if ( is_array( $string ) ) { |
|
| 1640 | 1640 | return $string; |
| 1641 | 1641 | } |
| 1642 | 1642 | |
| 1643 | - $new_string = json_decode($string, true); |
|
| 1644 | - if ( function_exists('json_last_error') ) { |
|
| 1643 | + $new_string = json_decode( $string, true ); |
|
| 1644 | + if ( function_exists( 'json_last_error' ) ) { |
|
| 1645 | 1645 | // php 5.3+ |
| 1646 | 1646 | if ( json_last_error() == JSON_ERROR_NONE ) { |
| 1647 | 1647 | $string = $new_string; |
| 1648 | 1648 | } |
| 1649 | - } else if ( isset($new_string) ) { |
|
| 1649 | + } else if ( isset( $new_string ) ) { |
|
| 1650 | 1650 | // php < 5.3 fallback |
| 1651 | 1651 | $string = $new_string; |
| 1652 | 1652 | } |
@@ -1662,11 +1662,11 @@ discard block |
||
| 1662 | 1662 | public static function maybe_highlight_menu( $post_type ) { |
| 1663 | 1663 | global $post; |
| 1664 | 1664 | |
| 1665 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1665 | + if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1666 | 1666 | return; |
| 1667 | 1667 | } |
| 1668 | 1668 | |
| 1669 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
| 1669 | + if ( is_object( $post ) && $post->post_type != $post_type ) { |
|
| 1670 | 1670 | return; |
| 1671 | 1671 | } |
| 1672 | 1672 | |
@@ -1770,11 +1770,11 @@ discard block |
||
| 1770 | 1770 | $frm_version = self::plugin_version(); |
| 1771 | 1771 | |
| 1772 | 1772 | // check if Formidable meets minimum requirements |
| 1773 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
| 1773 | + if ( version_compare( $frm_version, $min_version, '>=' ) ) { |
|
| 1774 | 1774 | return; |
| 1775 | 1775 | } |
| 1776 | 1776 | |
| 1777 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 1777 | + $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
| 1778 | 1778 | 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">' . |
| 1779 | 1779 | __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
| 1780 | 1780 | '</div></td></tr>'; |
@@ -1782,38 +1782,38 @@ discard block |
||
| 1782 | 1782 | |
| 1783 | 1783 | public static function locales( $type = 'date' ) { |
| 1784 | 1784 | $locales = array( |
| 1785 | - 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
| 1786 | - 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
| 1787 | - 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
| 1785 | + 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
| 1786 | + 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
| 1787 | + 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
| 1788 | 1788 | 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
| 1789 | - 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
| 1790 | - 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
| 1789 | + 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
| 1790 | + 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
| 1791 | 1791 | 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
| 1792 | - 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
| 1793 | - 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
| 1792 | + 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
| 1793 | + 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
| 1794 | 1794 | 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
| 1795 | - 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
| 1795 | + 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
| 1796 | 1796 | 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
| 1797 | - 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
| 1797 | + 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
| 1798 | 1798 | 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
| 1799 | - 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
| 1799 | + 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
| 1800 | 1800 | 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
| 1801 | - 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
| 1802 | - 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
| 1803 | - 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
| 1804 | - 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
| 1805 | - 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
| 1801 | + 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
| 1802 | + 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
| 1803 | + 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
| 1804 | + 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
| 1805 | + 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
| 1806 | 1806 | 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
| 1807 | - 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
| 1807 | + 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
| 1808 | 1808 | 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
| 1809 | 1809 | 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
| 1810 | - 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
| 1810 | + 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
| 1811 | 1811 | 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
| 1812 | - 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
| 1812 | + 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
| 1813 | 1813 | 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
| 1814 | - 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
| 1815 | - 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
| 1816 | - 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
| 1814 | + 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
| 1815 | + 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
| 1816 | + 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
| 1817 | 1817 | ); |
| 1818 | 1818 | |
| 1819 | 1819 | if ( $type == 'captcha' ) { |
@@ -1832,8 +1832,8 @@ discard block |
||
| 1832 | 1832 | ); |
| 1833 | 1833 | } |
| 1834 | 1834 | |
| 1835 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
| 1836 | - $locales = apply_filters('frm_locales', $locales); |
|
| 1835 | + $locales = array_diff_key( $locales, array_flip( $unset ) ); |
|
| 1836 | + $locales = apply_filters( 'frm_locales', $locales ); |
|
| 1837 | 1837 | |
| 1838 | 1838 | return $locales; |
| 1839 | 1839 | } |