@@ -1,17 +1,17 @@ |
||
| 1 | 1 | <div class="field-group clearfix frm-half frm-first-row"> |
| 2 | 2 | <label><?php _e( 'Size', 'formidable' ) ?></label> |
| 3 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('title_size') ) ?>" id="frm_title_size" value="<?php echo esc_attr( $style->post_content['title_size'] ) ?>" /> |
|
| 3 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'title_size' ) ) ?>" id="frm_title_size" value="<?php echo esc_attr( $style->post_content['title_size'] ) ?>" /> |
|
| 4 | 4 | </div> |
| 5 | 5 | |
| 6 | 6 | <div class="field-group clearfix frm-half frm-first-row"> |
| 7 | 7 | <label><?php _e( 'Color', 'formidable' ) ?></label> |
| 8 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('title_color') ) ?>" id="frm_title_color" class="hex" value="<?php echo esc_attr( $style->post_content['title_color'] ) ?>" /> |
|
| 8 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'title_color' ) ) ?>" id="frm_title_color" class="hex" value="<?php echo esc_attr( $style->post_content['title_color'] ) ?>" /> |
|
| 9 | 9 | </div> |
| 10 | 10 | <div class="field-group clearfix frm-half"> |
| 11 | 11 | <label><?php _e( 'Margin Top', 'formidable' ) ?></label> |
| 12 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('title_margin_top') ) ?>" id="frm_title_margin_top" value="<?php echo esc_attr( $style->post_content['title_margin_top'] ) ?>" size="4" /> |
|
| 12 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'title_margin_top' ) ) ?>" id="frm_title_margin_top" value="<?php echo esc_attr( $style->post_content['title_margin_top'] ) ?>" size="4" /> |
|
| 13 | 13 | </div> |
| 14 | 14 | <div class="field-group clearfix frm-half"> |
| 15 | 15 | <label><?php _e( 'Margin Bottom', 'formidable' ) ?></label> |
| 16 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('title_margin_bottom') ) ?>" id="frm_title_margin_bottom" value="<?php echo esc_attr( $style->post_content['title_margin_bottom'] ) ?>" size="4" /> |
|
| 16 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'title_margin_bottom' ) ) ?>" id="frm_title_margin_bottom" value="<?php echo esc_attr( $style->post_content['title_margin_bottom'] ) ?>" size="4" /> |
|
| 17 | 17 | </div> |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | class FrmFormsListHelper extends FrmListHelper { |
| 7 | - var $status = ''; |
|
| 7 | + var $status = ''; |
|
| 8 | 8 | |
| 9 | 9 | public function __construct( $args ) { |
| 10 | 10 | $this->status = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
@@ -13,14 +13,14 @@ discard block |
||
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | public function prepare_items() { |
| 16 | - global $wpdb, $per_page, $mode; |
|
| 16 | + global $wpdb, $per_page, $mode; |
|
| 17 | 17 | |
| 18 | - $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; |
|
| 18 | + $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; |
|
| 19 | 19 | |
| 20 | 20 | $default_orderby = 'name'; |
| 21 | 21 | $default_order = 'ASC'; |
| 22 | 22 | |
| 23 | - $orderby = ( isset( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : $default_orderby; |
|
| 23 | + $orderby = ( isset( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : $default_orderby; |
|
| 24 | 24 | $order = ( isset( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : $default_order; |
| 25 | 25 | |
| 26 | 26 | $page = $this->get_pagenum(); |
@@ -28,40 +28,40 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | $start = ( isset( $_REQUEST['start'] ) ) ? $_REQUEST['start'] : (( $page - 1 ) * $per_page); |
| 30 | 30 | |
| 31 | - $s_query = array(); |
|
| 32 | - $s_query[] = array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 1 ); |
|
| 31 | + $s_query = array(); |
|
| 32 | + $s_query[] = array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 1 ); |
|
| 33 | 33 | switch ( $this->status ) { |
| 34 | - case 'template': |
|
| 35 | - $s_query['is_template'] = 1; |
|
| 36 | - $s_query['status !'] = 'trash'; |
|
| 37 | - break; |
|
| 38 | - case 'draft': |
|
| 39 | - $s_query['is_template'] = 0; |
|
| 40 | - $s_query['status'] = 'draft'; |
|
| 41 | - break; |
|
| 42 | - case 'trash': |
|
| 43 | - $s_query['status'] = 'trash'; |
|
| 44 | - break; |
|
| 45 | - default: |
|
| 46 | - $s_query['is_template'] = 0; |
|
| 47 | - $s_query['status !'] = 'trash'; |
|
| 48 | - break; |
|
| 34 | + case 'template': |
|
| 35 | + $s_query['is_template'] = 1; |
|
| 36 | + $s_query['status !'] = 'trash'; |
|
| 37 | + break; |
|
| 38 | + case 'draft': |
|
| 39 | + $s_query['is_template'] = 0; |
|
| 40 | + $s_query['status'] = 'draft'; |
|
| 41 | + break; |
|
| 42 | + case 'trash': |
|
| 43 | + $s_query['status'] = 'trash'; |
|
| 44 | + break; |
|
| 45 | + default: |
|
| 46 | + $s_query['is_template'] = 0; |
|
| 47 | + $s_query['status !'] = 'trash'; |
|
| 48 | + break; |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : ''; |
|
| 52 | - if ( $s != '' ) { |
|
| 53 | - preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches); |
|
| 54 | - $search_terms = array_map('trim', $matches[0]); |
|
| 55 | - foreach ( (array) $search_terms as $term ) { |
|
| 56 | - $s_query[] = array( |
|
| 57 | - 'or' => true, 'name LIKE' => $term, 'description LIKE' => $term, 'created_at LIKE' => $term, |
|
| 58 | - ); |
|
| 59 | - unset($term); |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - $this->items = FrmForm::getAll($s_query, $orderby .' '. $order, $start .','. $per_page); |
|
| 64 | - $total_items = FrmDb::get_count( 'frm_forms', $s_query ); |
|
| 51 | + $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : ''; |
|
| 52 | + if ( $s != '' ) { |
|
| 53 | + preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches); |
|
| 54 | + $search_terms = array_map('trim', $matches[0]); |
|
| 55 | + foreach ( (array) $search_terms as $term ) { |
|
| 56 | + $s_query[] = array( |
|
| 57 | + 'or' => true, 'name LIKE' => $term, 'description LIKE' => $term, 'created_at LIKE' => $term, |
|
| 58 | + ); |
|
| 59 | + unset($term); |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + $this->items = FrmForm::getAll($s_query, $orderby .' '. $order, $start .','. $per_page); |
|
| 64 | + $total_items = FrmDb::get_count( 'frm_forms', $s_query ); |
|
| 65 | 65 | |
| 66 | 66 | $this->set_pagination_args( array( |
| 67 | 67 | 'total_items' => $total_items, |
@@ -70,69 +70,69 @@ discard block |
||
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | public function no_items() { |
| 73 | - if ( 'template' == $this->status ) { |
|
| 74 | - _e( 'No Templates Found.', 'formidable' ) ?> |
|
| 73 | + if ( 'template' == $this->status ) { |
|
| 74 | + _e( 'No Templates Found.', 'formidable' ) ?> |
|
| 75 | 75 | <br/><br/><?php _e( 'To add a new template:', 'formidable' ) ?> |
| 76 | 76 | <ol><li><?php printf( __( 'Create a new %1$sform%2$s.', 'formidable' ), '<a href="'. esc_url( admin_url( 'admin?page=formidable&frm_action=new' ) ) . '"', '</a>' ) ?></li> |
| 77 | 77 | <li><?php printf(__( 'After your form is created, go to Formidable -> %1$sForms%2$s.', 'formidable' ), '<a href="?page=formidable">', '</a>') ?></li> |
| 78 | 78 | <li><?php _e( 'Place your mouse over the name of the form you just created, and click the "Create Template" link.', 'formidable' ) ?></li> |
| 79 | 79 | </ol> |
| 80 | 80 | <?php } else { |
| 81 | - _e( 'No Forms Found.', 'formidable' ) ?> |
|
| 81 | + _e( 'No Forms Found.', 'formidable' ) ?> |
|
| 82 | 82 | <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable&frm_action=new' ) ) ?>"><?php _e( 'Add New', 'formidable' ); ?></a> |
| 83 | 83 | <?php } |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | public function get_bulk_actions() { |
| 87 | - $actions = array(); |
|
| 87 | + $actions = array(); |
|
| 88 | 88 | |
| 89 | 89 | if ( in_array( $this->status, array( '', 'published' ) ) ) { |
| 90 | - $actions['bulk_create_template'] = __( 'Create Template', 'formidable' ); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - if ( 'trash' == $this->status ) { |
|
| 94 | - if ( current_user_can('frm_edit_forms') ) { |
|
| 95 | - $actions['bulk_untrash'] = __( 'Restore', 'formidable' ); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - if ( current_user_can('frm_delete_forms') ) { |
|
| 99 | - $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' ); |
|
| 100 | - } |
|
| 101 | - } else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) { |
|
| 102 | - $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' ); |
|
| 103 | - } else if ( current_user_can('frm_delete_forms') ) { |
|
| 104 | - $actions['bulk_delete'] = __( 'Delete'); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - return $actions; |
|
| 108 | - } |
|
| 90 | + $actions['bulk_create_template'] = __( 'Create Template', 'formidable' ); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + if ( 'trash' == $this->status ) { |
|
| 94 | + if ( current_user_can('frm_edit_forms') ) { |
|
| 95 | + $actions['bulk_untrash'] = __( 'Restore', 'formidable' ); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + if ( current_user_can('frm_delete_forms') ) { |
|
| 99 | + $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' ); |
|
| 100 | + } |
|
| 101 | + } else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) { |
|
| 102 | + $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' ); |
|
| 103 | + } else if ( current_user_can('frm_delete_forms') ) { |
|
| 104 | + $actions['bulk_delete'] = __( 'Delete'); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + return $actions; |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | 110 | public function extra_tablenav( $which ) { |
| 111 | - if ( 'top' != $which ) { |
|
| 112 | - return; |
|
| 113 | - } |
|
| 111 | + if ( 'top' != $which ) { |
|
| 112 | + return; |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) { |
|
| 115 | + if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) { |
|
| 116 | 116 | ?> |
| 117 | 117 | <div class="alignleft actions frm_visible_overflow"> |
| 118 | 118 | <?php submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); ?> |
| 119 | 119 | </div> |
| 120 | 120 | <?php |
| 121 | - return; |
|
| 122 | - } |
|
| 121 | + return; |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - if ( 'template' != $this->status ) { |
|
| 125 | - return; |
|
| 126 | - } |
|
| 124 | + if ( 'template' != $this->status ) { |
|
| 125 | + return; |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | 128 | $where = apply_filters( 'frm_forms_dropdown', array(), '' ); |
| 129 | 129 | $forms = FrmForm::get_published_forms( $where ); |
| 130 | 130 | |
| 131 | - $base = admin_url('admin.php?page=formidable&form_type=template'); |
|
| 132 | - $args = array( |
|
| 133 | - 'frm_action' => 'duplicate', |
|
| 134 | - 'template' => true, |
|
| 135 | - ); |
|
| 131 | + $base = admin_url('admin.php?page=formidable&form_type=template'); |
|
| 132 | + $args = array( |
|
| 133 | + 'frm_action' => 'duplicate', |
|
| 134 | + 'template' => true, |
|
| 135 | + ); |
|
| 136 | 136 | |
| 137 | 137 | ?> |
| 138 | 138 | <div class="alignleft actions frm_visible_overflow"> |
@@ -140,18 +140,18 @@ discard block |
||
| 140 | 140 | <a href="#" id="frm-templateDrop" class="frm-dropdown-toggle button" data-toggle="dropdown"><?php _e( 'Create New Template', 'formidable' ) ?> <b class="caret"></b></a> |
| 141 | 141 | <ul class="frm-dropdown-menu" role="menu" aria-labelledby="frm-templateDrop"> |
| 142 | 142 | <?php |
| 143 | - if ( empty( $forms ) ) { ?> |
|
| 143 | + if ( empty( $forms ) ) { ?> |
|
| 144 | 144 | <li class="frm_dropdown_li"><?php _e( 'You have not created any forms yet. <br/>You must create a form before you can make a template.', 'formidable' ) ?></li> |
| 145 | 145 | <?php |
| 146 | - } else { |
|
| 147 | - foreach ( $forms as $form ) { |
|
| 148 | - $args['id'] = $form->id; ?> |
|
| 146 | + } else { |
|
| 147 | + foreach ( $forms as $form ) { |
|
| 148 | + $args['id'] = $form->id; ?> |
|
| 149 | 149 | <li><a href="<?php echo esc_url( add_query_arg( $args, $base ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li> |
| 150 | 150 | <?php |
| 151 | - unset($form); |
|
| 151 | + unset($form); |
|
| 152 | 152 | } |
| 153 | - } |
|
| 154 | - ?> |
|
| 153 | + } |
|
| 154 | + ?> |
|
| 155 | 155 | </ul> |
| 156 | 156 | </div> |
| 157 | 157 | </div> |
@@ -161,30 +161,30 @@ discard block |
||
| 161 | 161 | public function get_views() { |
| 162 | 162 | |
| 163 | 163 | $statuses = array( |
| 164 | - 'published' => __( 'My Forms', 'formidable' ), |
|
| 165 | - 'template' => __( 'Templates', 'formidable' ), |
|
| 166 | - 'draft' => __( 'Drafts', 'formidable' ), |
|
| 167 | - 'trash' => __( 'Trash', 'formidable' ), |
|
| 164 | + 'published' => __( 'My Forms', 'formidable' ), |
|
| 165 | + 'template' => __( 'Templates', 'formidable' ), |
|
| 166 | + 'draft' => __( 'Drafts', 'formidable' ), |
|
| 167 | + 'trash' => __( 'Trash', 'formidable' ), |
|
| 168 | 168 | ); |
| 169 | 169 | |
| 170 | - $links = array(); |
|
| 171 | - $counts = FrmForm::get_count(); |
|
| 172 | - $form_type = isset( $_REQUEST['form_type'] ) ? sanitize_text_field( $_REQUEST['form_type'] ) : 'published'; |
|
| 170 | + $links = array(); |
|
| 171 | + $counts = FrmForm::get_count(); |
|
| 172 | + $form_type = isset( $_REQUEST['form_type'] ) ? sanitize_text_field( $_REQUEST['form_type'] ) : 'published'; |
|
| 173 | 173 | |
| 174 | - foreach ( $statuses as $status => $name ) { |
|
| 174 | + foreach ( $statuses as $status => $name ) { |
|
| 175 | 175 | |
| 176 | - if ( $status == $form_type ) { |
|
| 177 | - $class = ' class="current"'; |
|
| 178 | - } else { |
|
| 179 | - $class = ''; |
|
| 180 | - } |
|
| 176 | + if ( $status == $form_type ) { |
|
| 177 | + $class = ' class="current"'; |
|
| 178 | + } else { |
|
| 179 | + $class = ''; |
|
| 180 | + } |
|
| 181 | 181 | |
| 182 | - if ( $counts->{$status} || 'published' == $status ) { |
|
| 182 | + if ( $counts->{$status} || 'published' == $status ) { |
|
| 183 | 183 | $links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>'; |
| 184 | - } |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | - unset($status, $name); |
|
| 187 | - } |
|
| 186 | + unset($status, $name); |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | 189 | return $links; |
| 190 | 190 | } |
@@ -200,16 +200,16 @@ discard block |
||
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | public function single_row( $item, $style = '' ) { |
| 203 | - global $frm_vars, $mode; |
|
| 203 | + global $frm_vars, $mode; |
|
| 204 | 204 | |
| 205 | 205 | // Set up the hover actions for this user |
| 206 | 206 | $actions = array(); |
| 207 | - $edit_link = '?page=formidable&frm_action=edit&id='. $item->id; |
|
| 208 | - $duplicate_link = '?page=formidable&frm_action=duplicate&id='. $item->id; |
|
| 207 | + $edit_link = '?page=formidable&frm_action=edit&id='. $item->id; |
|
| 208 | + $duplicate_link = '?page=formidable&frm_action=duplicate&id='. $item->id; |
|
| 209 | 209 | |
| 210 | - $this->get_actions($actions, $item, $edit_link, $duplicate_link); |
|
| 210 | + $this->get_actions($actions, $item, $edit_link, $duplicate_link); |
|
| 211 | 211 | |
| 212 | - $action_links = $this->row_actions( $actions ); |
|
| 212 | + $action_links = $this->row_actions( $actions ); |
|
| 213 | 213 | |
| 214 | 214 | // Set up the checkbox ( because the user is editable, otherwise its empty ) |
| 215 | 215 | $checkbox = '<input type="checkbox" name="item-action[]" id="cb-item-action-' . absint( $item->id ) . '" value="' . esc_attr( $item->id ) . '" />'; |
@@ -218,17 +218,17 @@ discard block |
||
| 218 | 218 | |
| 219 | 219 | list( $columns, $hidden ) = $this->get_column_info(); |
| 220 | 220 | |
| 221 | - $format = 'Y/m/d'; |
|
| 222 | - if ( 'list' != $mode ) { |
|
| 223 | - $format .= ' \<\b\r \/\> g:i:s a'; |
|
| 221 | + $format = 'Y/m/d'; |
|
| 222 | + if ( 'list' != $mode ) { |
|
| 223 | + $format .= ' \<\b\r \/\> g:i:s a'; |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | foreach ( $columns as $column_name => $column_display_name ) { |
| 227 | - $class = $column_name .' column-'. $column_name . ( ('name' == $column_name) ? ' post-title page-title column-title' : '' ); |
|
| 227 | + $class = $column_name .' column-'. $column_name . ( ('name' == $column_name) ? ' post-title page-title column-title' : '' ); |
|
| 228 | 228 | |
| 229 | 229 | $style = ''; |
| 230 | 230 | if ( in_array( $column_name, $hidden ) ) { |
| 231 | - $class .= ' frm_hidden'; |
|
| 231 | + $class .= ' frm_hidden'; |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | $class = 'class="' . esc_attr( $class ) . '"'; |
@@ -241,41 +241,41 @@ discard block |
||
| 241 | 241 | break; |
| 242 | 242 | case 'id': |
| 243 | 243 | case 'form_key': |
| 244 | - $val = $item->{$column_name}; |
|
| 245 | - break; |
|
| 244 | + $val = $item->{$column_name}; |
|
| 245 | + break; |
|
| 246 | 246 | case 'name': |
| 247 | - $val = $this->get_form_name( $item, $actions, $edit_link, $mode ); |
|
| 248 | - $val .= $action_links; |
|
| 247 | + $val = $this->get_form_name( $item, $actions, $edit_link, $mode ); |
|
| 248 | + $val .= $action_links; |
|
| 249 | 249 | |
| 250 | - break; |
|
| 250 | + break; |
|
| 251 | 251 | case 'created_at': |
| 252 | - $date = date($format, strtotime($item->created_at)); |
|
| 252 | + $date = date($format, strtotime($item->created_at)); |
|
| 253 | 253 | $val = '<abbr title="' . esc_attr( date( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>'; |
| 254 | 254 | break; |
| 255 | 255 | case 'shortcode': |
| 256 | 256 | $val = '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable id=' . $item->id .']' ) . '" /><br/>'; |
| 257 | - if ( 'excerpt' == $mode ) { |
|
| 257 | + if ( 'excerpt' == $mode ) { |
|
| 258 | 258 | $val .= '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable key=' . $item->form_key . ']' ) . '" />'; |
| 259 | - } |
|
| 260 | - break; |
|
| 261 | - case 'entries': |
|
| 259 | + } |
|
| 260 | + break; |
|
| 261 | + case 'entries': |
|
| 262 | 262 | if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) { |
| 263 | - $val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="'. esc_attr('Entries are not being saved', 'formidable' ) .'"></i>'; |
|
| 264 | - } else { |
|
| 265 | - $text = FrmEntry::getRecordCount($item->id); |
|
| 263 | + $val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="'. esc_attr('Entries are not being saved', 'formidable' ) .'"></i>'; |
|
| 264 | + } else { |
|
| 265 | + $text = FrmEntry::getRecordCount($item->id); |
|
| 266 | 266 | $val = current_user_can('frm_view_entries') ? '<a href="'. esc_url( admin_url( 'admin.php?page=formidable-entries&form='. $item->id ) ) . '">' . $text . '</a>' : $text; |
| 267 | - unset($text); |
|
| 268 | - } |
|
| 269 | - break; |
|
| 270 | - case 'type': |
|
| 271 | - $val = ( $item->is_template && $item->default_template ) ? __( 'Default', 'formidable' ) : __( 'Custom', 'formidable' ); |
|
| 272 | - break; |
|
| 267 | + unset($text); |
|
| 268 | + } |
|
| 269 | + break; |
|
| 270 | + case 'type': |
|
| 271 | + $val = ( $item->is_template && $item->default_template ) ? __( 'Default', 'formidable' ) : __( 'Custom', 'formidable' ); |
|
| 272 | + break; |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | if ( isset($val) ) { |
| 276 | - $r .= "<td $attributes>"; |
|
| 277 | - $r .= $val; |
|
| 278 | - $r .= '</td>'; |
|
| 276 | + $r .= "<td $attributes>"; |
|
| 277 | + $r .= $val; |
|
| 278 | + $r .= '</td>'; |
|
| 279 | 279 | } |
| 280 | 280 | unset($val); |
| 281 | 281 | } |
@@ -284,37 +284,37 @@ discard block |
||
| 284 | 284 | return $r; |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - /** |
|
| 288 | - * @param string $edit_link |
|
| 289 | - * @param string $duplicate_link |
|
| 290 | - */ |
|
| 291 | - private function get_actions( &$actions, $item, $edit_link, $duplicate_link ) { |
|
| 287 | + /** |
|
| 288 | + * @param string $edit_link |
|
| 289 | + * @param string $duplicate_link |
|
| 290 | + */ |
|
| 291 | + private function get_actions( &$actions, $item, $edit_link, $duplicate_link ) { |
|
| 292 | 292 | if ( 'trash' == $this->status ) { |
| 293 | 293 | if ( current_user_can('frm_edit_forms') ) { |
| 294 | 294 | $actions['restore'] = FrmFormsHelper::delete_trash_link( $item->id, $item->status, 'short' ); |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | - if ( current_user_can('frm_delete_forms') ) { |
|
| 298 | - $actions['trash'] = '<a href="' . esc_url(wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id='. $item->id, 'destroy_form_'. $item->id )) .'" class="submitdelete" onclick="return confirm(\''. __( 'Are you sure you want to permanently delete that?', 'formidable' ) .'\')">' . __( 'Delete Permanently' ) . '</a>'; |
|
| 299 | - } |
|
| 300 | - return; |
|
| 297 | + if ( current_user_can('frm_delete_forms') ) { |
|
| 298 | + $actions['trash'] = '<a href="' . esc_url(wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id='. $item->id, 'destroy_form_'. $item->id )) .'" class="submitdelete" onclick="return confirm(\''. __( 'Are you sure you want to permanently delete that?', 'formidable' ) .'\')">' . __( 'Delete Permanently' ) . '</a>'; |
|
| 299 | + } |
|
| 300 | + return; |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | if ( current_user_can('frm_edit_forms') ) { |
| 304 | - if ( ! $item->is_template || ! $item->default_template ) { |
|
| 305 | - $actions['frm_edit'] = '<a href="'. esc_url( $edit_link ) . '">'. __( 'Edit') .'</a>'; |
|
| 306 | - } |
|
| 304 | + if ( ! $item->is_template || ! $item->default_template ) { |
|
| 305 | + $actions['frm_edit'] = '<a href="'. esc_url( $edit_link ) . '">'. __( 'Edit') .'</a>'; |
|
| 306 | + } |
|
| 307 | 307 | |
| 308 | - if ( $item->is_template ) { |
|
| 308 | + if ( $item->is_template ) { |
|
| 309 | 309 | $actions['frm_duplicate'] = '<a href="'. esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Create Form from Template', 'formidable' ) . '</a>'; |
| 310 | - } else { |
|
| 311 | - $actions['frm_settings'] = '<a href="'. esc_url('?page=formidable&frm_action=settings&id='. $item->id ) . '">'. __( 'Settings', 'formidable' ) .'</a>'; |
|
| 310 | + } else { |
|
| 311 | + $actions['frm_settings'] = '<a href="'. esc_url('?page=formidable&frm_action=settings&id='. $item->id ) . '">'. __( 'Settings', 'formidable' ) .'</a>'; |
|
| 312 | 312 | |
| 313 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 313 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 314 | 314 | $actions['duplicate'] = '<a href="' . esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Duplicate', 'formidable' ) . '</a>'; |
| 315 | - } |
|
| 316 | - } |
|
| 317 | - } |
|
| 315 | + } |
|
| 316 | + } |
|
| 317 | + } |
|
| 318 | 318 | |
| 319 | 319 | $actions['trash'] = FrmFormsHelper::delete_trash_link( $item->id, $item->status, 'short' ); |
| 320 | 320 | if ( empty( $actions['trash'] ) ) { |
@@ -323,52 +323,52 @@ discard block |
||
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | $actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview') . '</a>'; |
| 326 | - } |
|
| 326 | + } |
|
| 327 | 327 | |
| 328 | - /** |
|
| 329 | - * @param string $edit_link |
|
| 330 | - */ |
|
| 328 | + /** |
|
| 329 | + * @param string $edit_link |
|
| 330 | + */ |
|
| 331 | 331 | private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) { |
| 332 | - $form_name = $item->name; |
|
| 333 | - if ( trim($form_name) == '' ) { |
|
| 334 | - $form_name = __( '(no title)'); |
|
| 335 | - } |
|
| 332 | + $form_name = $item->name; |
|
| 333 | + if ( trim($form_name) == '' ) { |
|
| 334 | + $form_name = __( '(no title)'); |
|
| 335 | + } |
|
| 336 | 336 | $form_name = FrmAppHelper::kses( $form_name ); |
| 337 | 337 | if ( 'excerpt' != $mode ) { |
| 338 | 338 | $form_name = FrmAppHelper::truncate( $form_name, 50 ); |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | - $val = '<strong>'; |
|
| 342 | - if ( 'trash' == $this->status ) { |
|
| 343 | - $val .= $form_name; |
|
| 344 | - } else { |
|
| 341 | + $val = '<strong>'; |
|
| 342 | + if ( 'trash' == $this->status ) { |
|
| 343 | + $val .= $form_name; |
|
| 344 | + } else { |
|
| 345 | 345 | $val .= '<a href="' . esc_url( isset( $actions['frm_edit'] ) ? $edit_link : FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" class="row-title">' . FrmAppHelper::kses( $form_name ) . '</a> '; |
| 346 | - } |
|
| 347 | - |
|
| 348 | - $this->add_draft_label( $item, $val ); |
|
| 349 | - $val .= '</strong>'; |
|
| 350 | - |
|
| 351 | - $this->add_form_description( $item, $val ); |
|
| 352 | - |
|
| 353 | - return $val; |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - /** |
|
| 357 | - * @param string $val |
|
| 358 | - */ |
|
| 359 | - private function add_draft_label( $item, &$val ) { |
|
| 360 | - if ( 'draft' == $item->status && 'draft' != $this->status ) { |
|
| 361 | - $val .= ' - <span class="post-state">'. __( 'Draft', 'formidable' ) .'</span>'; |
|
| 362 | - } |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - /** |
|
| 366 | - * @param string $val |
|
| 367 | - */ |
|
| 368 | - private function add_form_description( $item, &$val ) { |
|
| 369 | - global $mode; |
|
| 370 | - if ( 'excerpt' == $mode ) { |
|
| 371 | - $val .= FrmAppHelper::truncate(strip_tags($item->description), 50); |
|
| 372 | - } |
|
| 373 | - } |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + $this->add_draft_label( $item, $val ); |
|
| 349 | + $val .= '</strong>'; |
|
| 350 | + |
|
| 351 | + $this->add_form_description( $item, $val ); |
|
| 352 | + |
|
| 353 | + return $val; |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + /** |
|
| 357 | + * @param string $val |
|
| 358 | + */ |
|
| 359 | + private function add_draft_label( $item, &$val ) { |
|
| 360 | + if ( 'draft' == $item->status && 'draft' != $this->status ) { |
|
| 361 | + $val .= ' - <span class="post-state">'. __( 'Draft', 'formidable' ) .'</span>'; |
|
| 362 | + } |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + /** |
|
| 366 | + * @param string $val |
|
| 367 | + */ |
|
| 368 | + private function add_form_description( $item, &$val ) { |
|
| 369 | + global $mode; |
|
| 370 | + if ( 'excerpt' == $mode ) { |
|
| 371 | + $val .= FrmAppHelper::truncate(strip_tags($item->description), 50); |
|
| 372 | + } |
|
| 373 | + } |
|
| 374 | 374 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | $page = $this->get_pagenum(); |
| 27 | 27 | $per_page = $this->get_items_per_page( 'formidable_page_formidable_per_page' ); |
| 28 | 28 | |
| 29 | - $start = ( isset( $_REQUEST['start'] ) ) ? $_REQUEST['start'] : (( $page - 1 ) * $per_page); |
|
| 29 | + $start = ( isset( $_REQUEST['start'] ) ) ? $_REQUEST['start'] : ( ( $page - 1 ) * $per_page ); |
|
| 30 | 30 | |
| 31 | 31 | $s_query = array(); |
| 32 | 32 | $s_query[] = array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 1 ); |
@@ -48,19 +48,19 @@ discard block |
||
| 48 | 48 | break; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : ''; |
|
| 51 | + $s = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : ''; |
|
| 52 | 52 | if ( $s != '' ) { |
| 53 | - preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches); |
|
| 54 | - $search_terms = array_map('trim', $matches[0]); |
|
| 53 | + preg_match_all( '/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches ); |
|
| 54 | + $search_terms = array_map( 'trim', $matches[0] ); |
|
| 55 | 55 | foreach ( (array) $search_terms as $term ) { |
| 56 | 56 | $s_query[] = array( |
| 57 | 57 | 'or' => true, 'name LIKE' => $term, 'description LIKE' => $term, 'created_at LIKE' => $term, |
| 58 | 58 | ); |
| 59 | - unset($term); |
|
| 59 | + unset( $term ); |
|
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - $this->items = FrmForm::getAll($s_query, $orderby .' '. $order, $start .','. $per_page); |
|
| 63 | + $this->items = FrmForm::getAll( $s_query, $orderby . ' ' . $order, $start . ',' . $per_page ); |
|
| 64 | 64 | $total_items = FrmDb::get_count( 'frm_forms', $s_query ); |
| 65 | 65 | |
| 66 | 66 | $this->set_pagination_args( array( |
@@ -73,8 +73,8 @@ discard block |
||
| 73 | 73 | if ( 'template' == $this->status ) { |
| 74 | 74 | _e( 'No Templates Found.', 'formidable' ) ?> |
| 75 | 75 | <br/><br/><?php _e( 'To add a new template:', 'formidable' ) ?> |
| 76 | - <ol><li><?php printf( __( 'Create a new %1$sform%2$s.', 'formidable' ), '<a href="'. esc_url( admin_url( 'admin?page=formidable&frm_action=new' ) ) . '"', '</a>' ) ?></li> |
|
| 77 | - <li><?php printf(__( 'After your form is created, go to Formidable -> %1$sForms%2$s.', 'formidable' ), '<a href="?page=formidable">', '</a>') ?></li> |
|
| 76 | + <ol><li><?php printf( __( 'Create a new %1$sform%2$s.', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin?page=formidable&frm_action=new' ) ) . '"', '</a>' ) ?></li> |
|
| 77 | + <li><?php printf( __( 'After your form is created, go to Formidable -> %1$sForms%2$s.', 'formidable' ), '<a href="?page=formidable">', '</a>' ) ?></li> |
|
| 78 | 78 | <li><?php _e( 'Place your mouse over the name of the form you just created, and click the "Create Template" link.', 'formidable' ) ?></li> |
| 79 | 79 | </ol> |
| 80 | 80 | <?php } else { |
@@ -91,17 +91,17 @@ discard block |
||
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | if ( 'trash' == $this->status ) { |
| 94 | - if ( current_user_can('frm_edit_forms') ) { |
|
| 94 | + if ( current_user_can( 'frm_edit_forms' ) ) { |
|
| 95 | 95 | $actions['bulk_untrash'] = __( 'Restore', 'formidable' ); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if ( current_user_can('frm_delete_forms') ) { |
|
| 98 | + if ( current_user_can( 'frm_delete_forms' ) ) { |
|
| 99 | 99 | $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' ); |
| 100 | 100 | } |
| 101 | - } else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) { |
|
| 101 | + } else if ( EMPTY_TRASH_DAYS && current_user_can( 'frm_delete_forms' ) ) { |
|
| 102 | 102 | $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' ); |
| 103 | - } else if ( current_user_can('frm_delete_forms') ) { |
|
| 104 | - $actions['bulk_delete'] = __( 'Delete'); |
|
| 103 | + } else if ( current_user_can( 'frm_delete_forms' ) ) { |
|
| 104 | + $actions['bulk_delete'] = __( 'Delete' ); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | return $actions; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | return; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) { |
|
| 115 | + if ( 'trash' == $this->status && current_user_can( 'frm_delete_forms' ) ) { |
|
| 116 | 116 | ?> |
| 117 | 117 | <div class="alignleft actions frm_visible_overflow"> |
| 118 | 118 | <?php submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); ?> |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | $where = apply_filters( 'frm_forms_dropdown', array(), '' ); |
| 129 | 129 | $forms = FrmForm::get_published_forms( $where ); |
| 130 | 130 | |
| 131 | - $base = admin_url('admin.php?page=formidable&form_type=template'); |
|
| 131 | + $base = admin_url( 'admin.php?page=formidable&form_type=template' ); |
|
| 132 | 132 | $args = array( |
| 133 | 133 | 'frm_action' => 'duplicate', |
| 134 | 134 | 'template' => true, |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | $args['id'] = $form->id; ?> |
| 149 | 149 | <li><a href="<?php echo esc_url( add_query_arg( $args, $base ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li> |
| 150 | 150 | <?php |
| 151 | - unset($form); |
|
| 151 | + unset( $form ); |
|
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | 154 | ?> |
@@ -180,10 +180,10 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | if ( $counts->{$status} || 'published' == $status ) { |
| 183 | - $links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>'; |
|
| 183 | + $links[$status] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>'; |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - unset($status, $name); |
|
| 186 | + unset( $status, $name ); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | return $links; |
@@ -204,10 +204,10 @@ discard block |
||
| 204 | 204 | |
| 205 | 205 | // Set up the hover actions for this user |
| 206 | 206 | $actions = array(); |
| 207 | - $edit_link = '?page=formidable&frm_action=edit&id='. $item->id; |
|
| 208 | - $duplicate_link = '?page=formidable&frm_action=duplicate&id='. $item->id; |
|
| 207 | + $edit_link = '?page=formidable&frm_action=edit&id=' . $item->id; |
|
| 208 | + $duplicate_link = '?page=formidable&frm_action=duplicate&id=' . $item->id; |
|
| 209 | 209 | |
| 210 | - $this->get_actions($actions, $item, $edit_link, $duplicate_link); |
|
| 210 | + $this->get_actions( $actions, $item, $edit_link, $duplicate_link ); |
|
| 211 | 211 | |
| 212 | 212 | $action_links = $this->row_actions( $actions ); |
| 213 | 213 | |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | foreach ( $columns as $column_name => $column_display_name ) { |
| 227 | - $class = $column_name .' column-'. $column_name . ( ('name' == $column_name) ? ' post-title page-title column-title' : '' ); |
|
| 227 | + $class = $column_name . ' column-' . $column_name . ( ( 'name' == $column_name ) ? ' post-title page-title column-title' : '' ); |
|
| 228 | 228 | |
| 229 | 229 | $style = ''; |
| 230 | 230 | if ( in_array( $column_name, $hidden ) ) { |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | |
| 238 | 238 | switch ( $column_name ) { |
| 239 | 239 | case 'cb': |
| 240 | - $r .= '<th scope="row" class="check-column">'. $checkbox .'</th>'; |
|
| 240 | + $r .= '<th scope="row" class="check-column">' . $checkbox . '</th>'; |
|
| 241 | 241 | break; |
| 242 | 242 | case 'id': |
| 243 | 243 | case 'form_key': |
@@ -249,22 +249,22 @@ discard block |
||
| 249 | 249 | |
| 250 | 250 | break; |
| 251 | 251 | case 'created_at': |
| 252 | - $date = date($format, strtotime($item->created_at)); |
|
| 252 | + $date = date( $format, strtotime( $item->created_at ) ); |
|
| 253 | 253 | $val = '<abbr title="' . esc_attr( date( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>'; |
| 254 | 254 | break; |
| 255 | 255 | case 'shortcode': |
| 256 | - $val = '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable id=' . $item->id .']' ) . '" /><br/>'; |
|
| 256 | + $val = '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable id=' . $item->id . ']' ) . '" /><br/>'; |
|
| 257 | 257 | if ( 'excerpt' == $mode ) { |
| 258 | 258 | $val .= '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable key=' . $item->form_key . ']' ) . '" />'; |
| 259 | 259 | } |
| 260 | 260 | break; |
| 261 | 261 | case 'entries': |
| 262 | 262 | if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) { |
| 263 | - $val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="'. esc_attr('Entries are not being saved', 'formidable' ) .'"></i>'; |
|
| 263 | + $val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr( 'Entries are not being saved', 'formidable' ) . '"></i>'; |
|
| 264 | 264 | } else { |
| 265 | - $text = FrmEntry::getRecordCount($item->id); |
|
| 266 | - $val = current_user_can('frm_view_entries') ? '<a href="'. esc_url( admin_url( 'admin.php?page=formidable-entries&form='. $item->id ) ) . '">' . $text . '</a>' : $text; |
|
| 267 | - unset($text); |
|
| 265 | + $text = FrmEntry::getRecordCount( $item->id ); |
|
| 266 | + $val = current_user_can( 'frm_view_entries' ) ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text; |
|
| 267 | + unset( $text ); |
|
| 268 | 268 | } |
| 269 | 269 | break; |
| 270 | 270 | case 'type': |
@@ -272,12 +272,12 @@ discard block |
||
| 272 | 272 | break; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - if ( isset($val) ) { |
|
| 275 | + if ( isset( $val ) ) { |
|
| 276 | 276 | $r .= "<td $attributes>"; |
| 277 | 277 | $r .= $val; |
| 278 | 278 | $r .= '</td>'; |
| 279 | 279 | } |
| 280 | - unset($val); |
|
| 280 | + unset( $val ); |
|
| 281 | 281 | } |
| 282 | 282 | $r .= '</tr>'; |
| 283 | 283 | |
@@ -290,25 +290,25 @@ discard block |
||
| 290 | 290 | */ |
| 291 | 291 | private function get_actions( &$actions, $item, $edit_link, $duplicate_link ) { |
| 292 | 292 | if ( 'trash' == $this->status ) { |
| 293 | - if ( current_user_can('frm_edit_forms') ) { |
|
| 293 | + if ( current_user_can( 'frm_edit_forms' ) ) { |
|
| 294 | 294 | $actions['restore'] = FrmFormsHelper::delete_trash_link( $item->id, $item->status, 'short' ); |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | - if ( current_user_can('frm_delete_forms') ) { |
|
| 298 | - $actions['trash'] = '<a href="' . esc_url(wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id='. $item->id, 'destroy_form_'. $item->id )) .'" class="submitdelete" onclick="return confirm(\''. __( 'Are you sure you want to permanently delete that?', 'formidable' ) .'\')">' . __( 'Delete Permanently' ) . '</a>'; |
|
| 297 | + if ( current_user_can( 'frm_delete_forms' ) ) { |
|
| 298 | + $actions['trash'] = '<a href="' . esc_url( wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id=' . $item->id, 'destroy_form_' . $item->id ) ) . '" class="submitdelete" onclick="return confirm(\'' . __( 'Are you sure you want to permanently delete that?', 'formidable' ) . '\')">' . __( 'Delete Permanently' ) . '</a>'; |
|
| 299 | 299 | } |
| 300 | 300 | return; |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | - if ( current_user_can('frm_edit_forms') ) { |
|
| 303 | + if ( current_user_can( 'frm_edit_forms' ) ) { |
|
| 304 | 304 | if ( ! $item->is_template || ! $item->default_template ) { |
| 305 | - $actions['frm_edit'] = '<a href="'. esc_url( $edit_link ) . '">'. __( 'Edit') .'</a>'; |
|
| 305 | + $actions['frm_edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit' ) . '</a>'; |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | if ( $item->is_template ) { |
| 309 | - $actions['frm_duplicate'] = '<a href="'. esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Create Form from Template', 'formidable' ) . '</a>'; |
|
| 309 | + $actions['frm_duplicate'] = '<a href="' . esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Create Form from Template', 'formidable' ) . '</a>'; |
|
| 310 | 310 | } else { |
| 311 | - $actions['frm_settings'] = '<a href="'. esc_url('?page=formidable&frm_action=settings&id='. $item->id ) . '">'. __( 'Settings', 'formidable' ) .'</a>'; |
|
| 311 | + $actions['frm_settings'] = '<a href="' . esc_url( '?page=formidable&frm_action=settings&id=' . $item->id ) . '">' . __( 'Settings', 'formidable' ) . '</a>'; |
|
| 312 | 312 | |
| 313 | 313 | if ( FrmAppHelper::pro_is_installed() ) { |
| 314 | 314 | $actions['duplicate'] = '<a href="' . esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Duplicate', 'formidable' ) . '</a>'; |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | unset( $actions['trash'] ); |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - $actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview') . '</a>'; |
|
| 325 | + $actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview' ) . '</a>'; |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | /** |
@@ -330,8 +330,8 @@ discard block |
||
| 330 | 330 | */ |
| 331 | 331 | private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) { |
| 332 | 332 | $form_name = $item->name; |
| 333 | - if ( trim($form_name) == '' ) { |
|
| 334 | - $form_name = __( '(no title)'); |
|
| 333 | + if ( trim( $form_name ) == '' ) { |
|
| 334 | + $form_name = __( '(no title)' ); |
|
| 335 | 335 | } |
| 336 | 336 | $form_name = FrmAppHelper::kses( $form_name ); |
| 337 | 337 | if ( 'excerpt' != $mode ) { |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | */ |
| 359 | 359 | private function add_draft_label( $item, &$val ) { |
| 360 | 360 | if ( 'draft' == $item->status && 'draft' != $this->status ) { |
| 361 | - $val .= ' - <span class="post-state">'. __( 'Draft', 'formidable' ) .'</span>'; |
|
| 361 | + $val .= ' - <span class="post-state">' . __( 'Draft', 'formidable' ) . '</span>'; |
|
| 362 | 362 | } |
| 363 | 363 | } |
| 364 | 364 | |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | private function add_form_description( $item, &$val ) { |
| 369 | 369 | global $mode; |
| 370 | 370 | if ( 'excerpt' == $mode ) { |
| 371 | - $val .= FrmAppHelper::truncate(strip_tags($item->description), 50); |
|
| 371 | + $val .= FrmAppHelper::truncate( strip_tags( $item->description ), 50 ); |
|
| 372 | 372 | } |
| 373 | 373 | } |
| 374 | 374 | } |
@@ -3,11 +3,11 @@ discard block |
||
| 3 | 3 | class FrmAddonsController { |
| 4 | 4 | |
| 5 | 5 | public static function menu() { |
| 6 | - add_submenu_page( 'formidable', 'Formidable | '. __( 'AddOns', 'formidable' ), __( 'AddOns', 'formidable' ), 'frm_view_forms', 'formidable-addons', 'FrmAddonsController::list_addons' ); |
|
| 6 | + add_submenu_page( 'formidable', 'Formidable | ' . __( 'AddOns', 'formidable' ), __( 'AddOns', 'formidable' ), 'frm_view_forms', 'formidable-addons', 'FrmAddonsController::list_addons' ); |
|
| 7 | 7 | |
| 8 | 8 | $affiliate = FrmAppHelper::get_affiliate(); |
| 9 | 9 | if ( ! empty( $affiliate ) && ! FrmAppHelper::pro_is_installed() ) { |
| 10 | - add_submenu_page( 'formidable', 'Formidable | '. __( 'Upgrade to Pro', 'formidable' ), __( 'Upgrade to Pro', 'formidable' ), 'frm_view_forms', 'formidable-pro-upgrade', 'FrmAddonsController::upgrade_to_pro' ); |
|
| 10 | + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Upgrade to Pro', 'formidable' ), __( 'Upgrade to Pro', 'formidable' ), 'frm_view_forms', 'formidable-pro-upgrade', 'FrmAddonsController::upgrade_to_pro' ); |
|
| 11 | 11 | } |
| 12 | 12 | } |
| 13 | 13 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | $keyed_addons = array(); |
| 41 | 41 | foreach ( $addons as $addon ) { |
| 42 | - $keyed_addons[ $addon['info']['slug'] ] = $addon; |
|
| 42 | + $keyed_addons[$addon['info']['slug']] = $addon; |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | $plugin_order = array( |
@@ -48,9 +48,9 @@ discard block |
||
| 48 | 48 | ); |
| 49 | 49 | $ordered_addons = array(); |
| 50 | 50 | foreach ( $plugin_order as $plugin ) { |
| 51 | - if ( isset( $keyed_addons[ $plugin ] ) ) { |
|
| 52 | - $ordered_addons[] = $keyed_addons[ $plugin ]; |
|
| 53 | - unset( $keyed_addons[ $plugin ] ); |
|
| 51 | + if ( isset( $keyed_addons[$plugin] ) ) { |
|
| 52 | + $ordered_addons[] = $keyed_addons[$plugin]; |
|
| 53 | + unset( $keyed_addons[$plugin] ); |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | $addons = $ordered_addons + $keyed_addons; |
@@ -85,12 +85,12 @@ discard block |
||
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | public static function get_licenses() { |
| 88 | - FrmAppHelper::permission_check('frm_change_settings'); |
|
| 88 | + FrmAppHelper::permission_check( 'frm_change_settings' ); |
|
| 89 | 89 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 90 | 90 | |
| 91 | - $license = get_option('frmpro-credentials'); |
|
| 91 | + $license = get_option( 'frmpro-credentials' ); |
|
| 92 | 92 | if ( $license && is_array( $license ) && isset( $license['license'] ) ) { |
| 93 | - $url = 'http://formidablepro.com/frm-edd-api/licenses?l='. urlencode( base64_encode( $license['license'] ) ); |
|
| 93 | + $url = 'http://formidablepro.com/frm-edd-api/licenses?l=' . urlencode( base64_encode( $license['license'] ) ); |
|
| 94 | 94 | $licenses = self::send_api_request( $url, array( 'name' => 'frm_api_licence', 'expires' => 60 * 60 * 5 ) ); |
| 95 | 95 | echo json_encode( $licenses ); |
| 96 | 96 | } |
@@ -2,137 +2,137 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmFieldsController { |
| 4 | 4 | |
| 5 | - public static function load_field() { |
|
| 5 | + public static function load_field() { |
|
| 6 | 6 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 7 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 7 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 8 | 8 | |
| 9 | - $fields = $_POST['field']; |
|
| 10 | - if ( empty( $fields ) ) { |
|
| 11 | - wp_die(); |
|
| 12 | - } |
|
| 9 | + $fields = $_POST['field']; |
|
| 10 | + if ( empty( $fields ) ) { |
|
| 11 | + wp_die(); |
|
| 12 | + } |
|
| 13 | 13 | |
| 14 | - $_GET['page'] = 'formidable'; |
|
| 15 | - $fields = stripslashes_deep( $fields ); |
|
| 14 | + $_GET['page'] = 'formidable'; |
|
| 15 | + $fields = stripslashes_deep( $fields ); |
|
| 16 | 16 | |
| 17 | - $ajax = true; |
|
| 17 | + $ajax = true; |
|
| 18 | 18 | $values = array( 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ) ); |
| 19 | - $path = FrmAppHelper::plugin_path(); |
|
| 20 | - $field_html = array(); |
|
| 21 | - |
|
| 22 | - foreach ( $fields as $field ) { |
|
| 23 | - $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
| 24 | - $field = json_decode( $field, true ); |
|
| 25 | - if ( ! isset( $field['id'] ) ) { |
|
| 26 | - // this field may have already been loaded |
|
| 27 | - continue; |
|
| 28 | - } |
|
| 19 | + $path = FrmAppHelper::plugin_path(); |
|
| 20 | + $field_html = array(); |
|
| 21 | + |
|
| 22 | + foreach ( $fields as $field ) { |
|
| 23 | + $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
| 24 | + $field = json_decode( $field, true ); |
|
| 25 | + if ( ! isset( $field['id'] ) ) { |
|
| 26 | + // this field may have already been loaded |
|
| 27 | + continue; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - $field_id = absint( $field['id'] ); |
|
| 30 | + $field_id = absint( $field['id'] ); |
|
| 31 | 31 | |
| 32 | - if ( ! isset( $field['value'] ) ) { |
|
| 33 | - $field['value'] = ''; |
|
| 34 | - } |
|
| 32 | + if ( ! isset( $field['value'] ) ) { |
|
| 33 | + $field['value'] = ''; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - $field_name = 'item_meta['. $field_id .']'; |
|
| 37 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 36 | + $field_name = 'item_meta['. $field_id .']'; |
|
| 37 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 38 | 38 | |
| 39 | - ob_start(); |
|
| 40 | - include($path .'/classes/views/frm-forms/add_field.php'); |
|
| 41 | - $field_html[ $field_id ] = ob_get_contents(); |
|
| 42 | - ob_end_clean(); |
|
| 43 | - } |
|
| 39 | + ob_start(); |
|
| 40 | + include($path .'/classes/views/frm-forms/add_field.php'); |
|
| 41 | + $field_html[ $field_id ] = ob_get_contents(); |
|
| 42 | + ob_end_clean(); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - unset($path); |
|
| 45 | + unset($path); |
|
| 46 | 46 | |
| 47 | - echo json_encode($field_html); |
|
| 47 | + echo json_encode($field_html); |
|
| 48 | 48 | |
| 49 | - wp_die(); |
|
| 50 | - } |
|
| 49 | + wp_die(); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - public static function create() { |
|
| 52 | + public static function create() { |
|
| 53 | 53 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 54 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 54 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 55 | 55 | |
| 56 | 56 | $field_type = FrmAppHelper::get_post_param( 'field', '', 'sanitize_text_field' ); |
| 57 | 57 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 58 | 58 | |
| 59 | - $field = self::include_new_field($field_type, $form_id); |
|
| 59 | + $field = self::include_new_field($field_type, $form_id); |
|
| 60 | 60 | |
| 61 | - // this hook will allow for multiple fields to be added at once |
|
| 62 | - do_action('frm_after_field_created', $field, $form_id); |
|
| 61 | + // this hook will allow for multiple fields to be added at once |
|
| 62 | + do_action('frm_after_field_created', $field, $form_id); |
|
| 63 | 63 | |
| 64 | - wp_die(); |
|
| 65 | - } |
|
| 64 | + wp_die(); |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * @param integer $form_id |
|
| 69 | - */ |
|
| 67 | + /** |
|
| 68 | + * @param integer $form_id |
|
| 69 | + */ |
|
| 70 | 70 | public static function include_new_field( $field_type, $form_id ) { |
| 71 | - $values = array(); |
|
| 72 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 73 | - $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 74 | - } |
|
| 71 | + $values = array(); |
|
| 72 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 73 | + $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id)); |
|
| 77 | - $field_id = FrmField::create( $field_values ); |
|
| 76 | + $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id)); |
|
| 77 | + $field_id = FrmField::create( $field_values ); |
|
| 78 | 78 | |
| 79 | - if ( ! $field_id ) { |
|
| 80 | - return false; |
|
| 81 | - } |
|
| 79 | + if ( ! $field_id ) { |
|
| 80 | + return false; |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - $field = self::include_single_field($field_id, $values, $form_id); |
|
| 83 | + $field = self::include_single_field($field_id, $values, $form_id); |
|
| 84 | 84 | |
| 85 | - return $field; |
|
| 86 | - } |
|
| 85 | + return $field; |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - public static function update_form_id() { |
|
| 88 | + public static function update_form_id() { |
|
| 89 | 89 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 90 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 90 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 91 | 91 | |
| 92 | 92 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
| 93 | 93 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 94 | 94 | |
| 95 | - if ( ! $field_id || ! $form_id ) { |
|
| 96 | - wp_die(); |
|
| 97 | - } |
|
| 95 | + if ( ! $field_id || ! $form_id ) { |
|
| 96 | + wp_die(); |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | 99 | $updated = FrmField::update( $field_id, compact( 'form_id' ) ); |
| 100 | 100 | echo absint( $updated ); |
| 101 | 101 | |
| 102 | - wp_die(); |
|
| 103 | - } |
|
| 102 | + wp_die(); |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | 105 | public static function edit_name( $field = 'name', $id = '' ) { |
| 106 | 106 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 107 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 107 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 108 | 108 | |
| 109 | - if ( empty($field) ) { |
|
| 110 | - $field = 'name'; |
|
| 111 | - } |
|
| 109 | + if ( empty($field) ) { |
|
| 110 | + $field = 'name'; |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - if ( empty($id) ) { |
|
| 113 | + if ( empty($id) ) { |
|
| 114 | 114 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 115 | 115 | $id = str_replace( 'field_label_', '', $id ); |
| 116 | - } |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | 118 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
| 119 | 119 | $value = trim( $value ); |
| 120 | - if ( trim(strip_tags($value)) == '' ) { |
|
| 121 | - // set blank value if there is no content |
|
| 122 | - $value = ''; |
|
| 123 | - } |
|
| 120 | + if ( trim(strip_tags($value)) == '' ) { |
|
| 121 | + // set blank value if there is no content |
|
| 122 | + $value = ''; |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | 125 | FrmField::update( $id, array( $field => $value ) ); |
| 126 | 126 | |
| 127 | 127 | do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) ); |
| 128 | 128 | |
| 129 | 129 | echo stripslashes( wp_kses_post( $value ) ); |
| 130 | - wp_die(); |
|
| 131 | - } |
|
| 130 | + wp_die(); |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - public static function update_ajax_option() { |
|
| 133 | + public static function update_ajax_option() { |
|
| 134 | 134 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 135 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 135 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 136 | 136 | |
| 137 | 137 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
| 138 | 138 | if ( ! $field_id ) { |
@@ -142,155 +142,155 @@ discard block |
||
| 142 | 142 | $field = FrmField::getOne( $field_id ); |
| 143 | 143 | |
| 144 | 144 | foreach ( array( 'clear_on_focus', 'separate_value', 'default_blank' ) as $val ) { |
| 145 | - if ( isset($_POST[ $val ]) ) { |
|
| 145 | + if ( isset($_POST[ $val ]) ) { |
|
| 146 | 146 | // all three of these options are boolean |
| 147 | 147 | $new_val = FrmAppHelper::get_post_param( $val, 0, 'absint' ); |
| 148 | 148 | |
| 149 | - if ( $val == 'separate_value' ) { |
|
| 149 | + if ( $val == 'separate_value' ) { |
|
| 150 | 150 | $new_val = FrmField::is_option_true( $field, $val ) ? 0 : 1; |
| 151 | - } |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - $field->field_options[ $val ] = $new_val; |
|
| 154 | - unset($new_val); |
|
| 155 | - } |
|
| 156 | - unset($val); |
|
| 157 | - } |
|
| 153 | + $field->field_options[ $val ] = $new_val; |
|
| 154 | + unset($new_val); |
|
| 155 | + } |
|
| 156 | + unset($val); |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - FrmField::update( $field_id, array( |
|
| 160 | - 'field_options' => $field->field_options, |
|
| 159 | + FrmField::update( $field_id, array( |
|
| 160 | + 'field_options' => $field->field_options, |
|
| 161 | 161 | 'form_id' => $field->form_id, |
| 162 | - ) ); |
|
| 163 | - wp_die(); |
|
| 164 | - } |
|
| 162 | + ) ); |
|
| 163 | + wp_die(); |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | - public static function duplicate() { |
|
| 166 | + public static function duplicate() { |
|
| 167 | 167 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 168 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 168 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 169 | 169 | |
| 170 | - global $wpdb; |
|
| 170 | + global $wpdb; |
|
| 171 | 171 | |
| 172 | 172 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 173 | 173 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 174 | 174 | |
| 175 | 175 | $copy_field = FrmField::getOne( $field_id ); |
| 176 | - if ( ! $copy_field ) { |
|
| 177 | - wp_die(); |
|
| 178 | - } |
|
| 176 | + if ( ! $copy_field ) { |
|
| 177 | + wp_die(); |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - do_action('frm_duplicate_field', $copy_field, $form_id); |
|
| 181 | - do_action('frm_duplicate_field_'. $copy_field->type, $copy_field, $form_id); |
|
| 180 | + do_action('frm_duplicate_field', $copy_field, $form_id); |
|
| 181 | + do_action('frm_duplicate_field_'. $copy_field->type, $copy_field, $form_id); |
|
| 182 | 182 | |
| 183 | - $values = array( 'id' => $form_id ); |
|
| 184 | - FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
|
| 183 | + $values = array( 'id' => $form_id ); |
|
| 184 | + FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
|
| 185 | 185 | |
| 186 | 186 | $field_count = FrmDb::get_count( $wpdb->prefix .'frm_fields fi LEFT JOIN '. $wpdb->prefix .'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) ); |
| 187 | 187 | |
| 188 | - $values['field_order'] = $field_count + 1; |
|
| 188 | + $values['field_order'] = $field_count + 1; |
|
| 189 | 189 | |
| 190 | - if ( ! $field_id = FrmField::create($values) ) { |
|
| 191 | - wp_die(); |
|
| 192 | - } |
|
| 190 | + if ( ! $field_id = FrmField::create($values) ) { |
|
| 191 | + wp_die(); |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | - self::include_single_field($field_id, $values); |
|
| 194 | + self::include_single_field($field_id, $values); |
|
| 195 | 195 | |
| 196 | - wp_die(); |
|
| 197 | - } |
|
| 196 | + wp_die(); |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - /** |
|
| 200 | - * Load a single field in the form builder along with all needed variables |
|
| 201 | - */ |
|
| 202 | - public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
| 203 | - $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 204 | - $field_name = 'item_meta['. $field_id .']'; |
|
| 205 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 206 | - $id = $form_id ? $form_id : $field['form_id']; |
|
| 207 | - if ( $field['type'] == 'html' ) { |
|
| 208 | - $field['stop_filter'] = true; |
|
| 209 | - } |
|
| 199 | + /** |
|
| 200 | + * Load a single field in the form builder along with all needed variables |
|
| 201 | + */ |
|
| 202 | + public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
| 203 | + $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 204 | + $field_name = 'item_meta['. $field_id .']'; |
|
| 205 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 206 | + $id = $form_id ? $form_id : $field['form_id']; |
|
| 207 | + if ( $field['type'] == 'html' ) { |
|
| 208 | + $field['stop_filter'] = true; |
|
| 209 | + } |
|
| 210 | 210 | |
| 211 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php'); |
|
| 211 | + require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php'); |
|
| 212 | 212 | |
| 213 | - return $field; |
|
| 214 | - } |
|
| 213 | + return $field; |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | - public static function destroy() { |
|
| 216 | + public static function destroy() { |
|
| 217 | 217 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 218 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 218 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 219 | 219 | |
| 220 | 220 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 221 | 221 | FrmField::destroy( $field_id ); |
| 222 | - wp_die(); |
|
| 223 | - } |
|
| 222 | + wp_die(); |
|
| 223 | + } |
|
| 224 | 224 | |
| 225 | - /* Field Options */ |
|
| 225 | + /* Field Options */ |
|
| 226 | 226 | |
| 227 | - //Add Single Option or Other Option |
|
| 228 | - public static function add_option() { |
|
| 227 | + //Add Single Option or Other Option |
|
| 228 | + public static function add_option() { |
|
| 229 | 229 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 230 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 230 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 231 | 231 | |
| 232 | 232 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 233 | 233 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
| 234 | 234 | |
| 235 | - //Get the field |
|
| 236 | - $field = FrmField::getOne($id); |
|
| 235 | + //Get the field |
|
| 236 | + $field = FrmField::getOne($id); |
|
| 237 | 237 | |
| 238 | 238 | if ( ! empty( $field->options ) ) { |
| 239 | 239 | $keys = array_keys( $field->options ); |
| 240 | - $last = str_replace( 'other_', '', end( $keys ) ); |
|
| 241 | - } else { |
|
| 242 | - $last = 0; |
|
| 243 | - } |
|
| 244 | - $opt_key = $last + 1; |
|
| 240 | + $last = str_replace( 'other_', '', end( $keys ) ); |
|
| 241 | + } else { |
|
| 242 | + $last = 0; |
|
| 243 | + } |
|
| 244 | + $opt_key = $last + 1; |
|
| 245 | 245 | |
| 246 | - if ( 'other' == $opt_type ) { |
|
| 246 | + if ( 'other' == $opt_type ) { |
|
| 247 | 247 | $opt = esc_html__( 'Other', 'formidable' ); |
| 248 | - $other_val = ''; |
|
| 249 | - $opt_key = 'other_' . $opt_key; |
|
| 250 | - |
|
| 251 | - //Update value of "other" in DB |
|
| 252 | - $field_options = maybe_unserialize( $field->field_options ); |
|
| 253 | - $field_options['other'] = 1; |
|
| 254 | - FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
|
| 255 | - } else { |
|
| 248 | + $other_val = ''; |
|
| 249 | + $opt_key = 'other_' . $opt_key; |
|
| 250 | + |
|
| 251 | + //Update value of "other" in DB |
|
| 252 | + $field_options = maybe_unserialize( $field->field_options ); |
|
| 253 | + $field_options['other'] = 1; |
|
| 254 | + FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
|
| 255 | + } else { |
|
| 256 | 256 | $first_opt = reset( $field->options ); |
| 257 | 257 | $next_opt = count( $field->options ); |
| 258 | - if ( $first_opt != '' ) { |
|
| 259 | - $next_opt++; |
|
| 260 | - } |
|
| 261 | - $opt = esc_html__( 'Option', 'formidable' ) .' '. $next_opt; |
|
| 262 | - unset($next_opt); |
|
| 263 | - } |
|
| 264 | - $field_val = $opt; |
|
| 258 | + if ( $first_opt != '' ) { |
|
| 259 | + $next_opt++; |
|
| 260 | + } |
|
| 261 | + $opt = esc_html__( 'Option', 'formidable' ) .' '. $next_opt; |
|
| 262 | + unset($next_opt); |
|
| 263 | + } |
|
| 264 | + $field_val = $opt; |
|
| 265 | 265 | $field->options[ $opt_key ] = $opt; |
| 266 | 266 | |
| 267 | - //Update options in DB |
|
| 267 | + //Update options in DB |
|
| 268 | 268 | FrmField::update( $id, array( 'options' => $field->options ) ); |
| 269 | 269 | |
| 270 | - $field_data = $field; |
|
| 271 | - $field = array( |
|
| 272 | - 'type' => $field_data->type, |
|
| 273 | - 'id' => $id, |
|
| 274 | - 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
| 275 | - 'form_id' => $field_data->form_id, |
|
| 276 | - 'field_key' => $field_data->field_key, |
|
| 277 | - ); |
|
| 278 | - |
|
| 279 | - $field_name = 'item_meta['. $id .']'; |
|
| 280 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 281 | - $checked = ''; |
|
| 282 | - |
|
| 283 | - if ( 'other' == $opt_type ) { |
|
| 284 | - require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php'); |
|
| 285 | - } else { |
|
| 286 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php'); |
|
| 287 | - } |
|
| 288 | - wp_die(); |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - public static function edit_option() { |
|
| 270 | + $field_data = $field; |
|
| 271 | + $field = array( |
|
| 272 | + 'type' => $field_data->type, |
|
| 273 | + 'id' => $id, |
|
| 274 | + 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
| 275 | + 'form_id' => $field_data->form_id, |
|
| 276 | + 'field_key' => $field_data->field_key, |
|
| 277 | + ); |
|
| 278 | + |
|
| 279 | + $field_name = 'item_meta['. $id .']'; |
|
| 280 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 281 | + $checked = ''; |
|
| 282 | + |
|
| 283 | + if ( 'other' == $opt_type ) { |
|
| 284 | + require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php'); |
|
| 285 | + } else { |
|
| 286 | + require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php'); |
|
| 287 | + } |
|
| 288 | + wp_die(); |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + public static function edit_option() { |
|
| 292 | 292 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 293 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 293 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 294 | 294 | |
| 295 | 295 | $element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 296 | 296 | $ids = explode( '-', $element_id ); |
@@ -298,43 +298,43 @@ discard block |
||
| 298 | 298 | |
| 299 | 299 | $orig_update_value = $update_value = trim( FrmAppHelper::get_post_param( 'update_value' ) ); |
| 300 | 300 | if ( strpos( $element_id, 'key_' ) ) { |
| 301 | - $new_value = $update_value; |
|
| 302 | - } else { |
|
| 303 | - $new_label = $update_value; |
|
| 304 | - } |
|
| 301 | + $new_value = $update_value; |
|
| 302 | + } else { |
|
| 303 | + $new_label = $update_value; |
|
| 304 | + } |
|
| 305 | 305 | |
| 306 | - $field = FrmField::getOne($id); |
|
| 307 | - $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
|
| 306 | + $field = FrmField::getOne($id); |
|
| 307 | + $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
|
| 308 | 308 | |
| 309 | - $this_opt_id = end($ids); |
|
| 309 | + $this_opt_id = end($ids); |
|
| 310 | 310 | $this_opt = (array) $field->options[ $this_opt_id ]; |
| 311 | 311 | $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false ); |
| 312 | 312 | |
| 313 | - $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
| 314 | - $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
| 313 | + $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
| 314 | + $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
| 315 | 315 | |
| 316 | - if ( ! isset( $new_label ) ) { |
|
| 317 | - $new_label = $label; |
|
| 318 | - } |
|
| 316 | + if ( ! isset( $new_label ) ) { |
|
| 317 | + $new_label = $label; |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | - if ( isset($new_value) || isset($value) ) { |
|
| 321 | - $update_value = isset($new_value) ? $new_value : $value; |
|
| 322 | - } |
|
| 320 | + if ( isset($new_value) || isset($value) ) { |
|
| 321 | + $update_value = isset($new_value) ? $new_value : $value; |
|
| 322 | + } |
|
| 323 | 323 | |
| 324 | 324 | if ( $update_value != $new_label && $other_opt === false && $separate_values ) { |
| 325 | 325 | $field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label ); |
| 326 | - } else { |
|
| 326 | + } else { |
|
| 327 | 327 | $field->options[ $this_opt_id ] = $orig_update_value; |
| 328 | - } |
|
| 328 | + } |
|
| 329 | 329 | |
| 330 | 330 | FrmField::update( $field->id, array( 'options' => $field->options ) ); |
| 331 | 331 | echo ( $orig_update_value == '' ) ? esc_html__( '(Blank)', 'formidable' ) : stripslashes( $orig_update_value ); |
| 332 | - wp_die(); |
|
| 333 | - } |
|
| 332 | + wp_die(); |
|
| 333 | + } |
|
| 334 | 334 | |
| 335 | - public static function delete_option() { |
|
| 335 | + public static function delete_option() { |
|
| 336 | 336 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 337 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 337 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 338 | 338 | |
| 339 | 339 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 340 | 340 | $field = FrmField::getOne( $field_id ); |
@@ -342,340 +342,340 @@ discard block |
||
| 342 | 342 | $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' ); |
| 343 | 343 | |
| 344 | 344 | $options = $field->options; |
| 345 | - unset( $options[ $opt_key ] ); |
|
| 346 | - $response = array( 'other' => true ); |
|
| 345 | + unset( $options[ $opt_key ] ); |
|
| 346 | + $response = array( 'other' => true ); |
|
| 347 | 347 | |
| 348 | - //If the deleted option is an "other" option |
|
| 348 | + //If the deleted option is an "other" option |
|
| 349 | 349 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
| 350 | - //Assume all other options are gone, unless proven otherwise |
|
| 351 | - $other = false; |
|
| 350 | + //Assume all other options are gone, unless proven otherwise |
|
| 351 | + $other = false; |
|
| 352 | 352 | |
| 353 | - //Check if all other options are really gone |
|
| 354 | - foreach ( $options as $o_key => $o_val ) { |
|
| 355 | - //If there is still an other option in the field, set other to true |
|
| 353 | + //Check if all other options are really gone |
|
| 354 | + foreach ( $options as $o_key => $o_val ) { |
|
| 355 | + //If there is still an other option in the field, set other to true |
|
| 356 | 356 | if ( FrmFieldsHelper::is_other_opt( $o_key ) ) { |
| 357 | - $other = true; |
|
| 358 | - break; |
|
| 359 | - } |
|
| 360 | - unset( $o_key, $o_val ); |
|
| 361 | - } |
|
| 362 | - |
|
| 363 | - //If all other options are gone |
|
| 364 | - if ( false === $other ) { |
|
| 365 | - $field_options = maybe_unserialize( $field->field_options ); |
|
| 366 | - $field_options['other'] = 0; |
|
| 357 | + $other = true; |
|
| 358 | + break; |
|
| 359 | + } |
|
| 360 | + unset( $o_key, $o_val ); |
|
| 361 | + } |
|
| 362 | + |
|
| 363 | + //If all other options are gone |
|
| 364 | + if ( false === $other ) { |
|
| 365 | + $field_options = maybe_unserialize( $field->field_options ); |
|
| 366 | + $field_options['other'] = 0; |
|
| 367 | 367 | FrmField::update( $field_id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
| 368 | - $response = array( 'other' => false ); |
|
| 369 | - } |
|
| 370 | - } |
|
| 371 | - echo json_encode( $response ); |
|
| 368 | + $response = array( 'other' => false ); |
|
| 369 | + } |
|
| 370 | + } |
|
| 371 | + echo json_encode( $response ); |
|
| 372 | 372 | |
| 373 | 373 | FrmField::update( $field_id, array( 'options' => maybe_serialize( $options ) ) ); |
| 374 | 374 | |
| 375 | - wp_die(); |
|
| 376 | - } |
|
| 375 | + wp_die(); |
|
| 376 | + } |
|
| 377 | 377 | |
| 378 | - public static function import_choices() { |
|
| 379 | - FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
| 378 | + public static function import_choices() { |
|
| 379 | + FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
| 380 | 380 | |
| 381 | 381 | $field_id = absint( $_REQUEST['field_id'] ); |
| 382 | 382 | |
| 383 | - global $current_screen, $hook_suffix; |
|
| 383 | + global $current_screen, $hook_suffix; |
|
| 384 | 384 | |
| 385 | - // Catch plugins that include admin-header.php before admin.php completes. |
|
| 386 | - if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
| 387 | - $hook_suffix = ''; |
|
| 388 | - set_current_screen(); |
|
| 389 | - } |
|
| 385 | + // Catch plugins that include admin-header.php before admin.php completes. |
|
| 386 | + if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
| 387 | + $hook_suffix = ''; |
|
| 388 | + set_current_screen(); |
|
| 389 | + } |
|
| 390 | 390 | |
| 391 | - if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
| 392 | - register_admin_color_schemes(); |
|
| 393 | - } |
|
| 391 | + if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
| 392 | + register_admin_color_schemes(); |
|
| 393 | + } |
|
| 394 | 394 | |
| 395 | - $hook_suffix = $admin_body_class = ''; |
|
| 395 | + $hook_suffix = $admin_body_class = ''; |
|
| 396 | 396 | |
| 397 | - if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
| 398 | - $admin_body_class .= ' folded'; |
|
| 399 | - } |
|
| 397 | + if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
| 398 | + $admin_body_class .= ' folded'; |
|
| 399 | + } |
|
| 400 | 400 | |
| 401 | - if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
| 402 | - $admin_body_class .= ' admin-bar'; |
|
| 403 | - } |
|
| 401 | + if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
| 402 | + $admin_body_class .= ' admin-bar'; |
|
| 403 | + } |
|
| 404 | 404 | |
| 405 | - if ( is_rtl() ) { |
|
| 406 | - $admin_body_class .= ' rtl'; |
|
| 407 | - } |
|
| 405 | + if ( is_rtl() ) { |
|
| 406 | + $admin_body_class .= ' rtl'; |
|
| 407 | + } |
|
| 408 | 408 | |
| 409 | - $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
| 410 | - $prepop = array(); |
|
| 411 | - FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 409 | + $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
| 410 | + $prepop = array(); |
|
| 411 | + FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 412 | 412 | |
| 413 | - $field = FrmField::getOne($field_id); |
|
| 413 | + $field = FrmField::getOne($field_id); |
|
| 414 | 414 | |
| 415 | - wp_enqueue_script( 'utils' ); |
|
| 416 | - wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css' ); |
|
| 417 | - FrmAppHelper::load_admin_wide_js(); |
|
| 415 | + wp_enqueue_script( 'utils' ); |
|
| 416 | + wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css' ); |
|
| 417 | + FrmAppHelper::load_admin_wide_js(); |
|
| 418 | 418 | |
| 419 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/import_choices.php'); |
|
| 420 | - wp_die(); |
|
| 421 | - } |
|
| 419 | + include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/import_choices.php'); |
|
| 420 | + wp_die(); |
|
| 421 | + } |
|
| 422 | 422 | |
| 423 | - public static function import_options() { |
|
| 423 | + public static function import_options() { |
|
| 424 | 424 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 425 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 425 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 426 | 426 | |
| 427 | - if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 428 | - return; |
|
| 429 | - } |
|
| 427 | + if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 428 | + return; |
|
| 429 | + } |
|
| 430 | 430 | |
| 431 | 431 | $field_id = absint( $_POST['field_id'] ); |
| 432 | - $field = FrmField::getOne($field_id); |
|
| 432 | + $field = FrmField::getOne($field_id); |
|
| 433 | 433 | |
| 434 | 434 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
| 435 | - return; |
|
| 436 | - } |
|
| 437 | - |
|
| 438 | - $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 439 | - $opts = stripslashes_deep($_POST['opts']); |
|
| 440 | - $opts = explode("\n", rtrim($opts, "\n")); |
|
| 441 | - if ( $field['separate_value'] ) { |
|
| 442 | - foreach ( $opts as $opt_key => $opt ) { |
|
| 443 | - if ( strpos($opt, '|') !== false ) { |
|
| 444 | - $vals = explode('|', $opt); |
|
| 445 | - if ( $vals[0] != $vals[1] ) { |
|
| 446 | - $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 447 | - } |
|
| 448 | - unset($vals); |
|
| 449 | - } |
|
| 450 | - unset($opt_key, $opt); |
|
| 451 | - } |
|
| 452 | - } |
|
| 453 | - |
|
| 454 | - //Keep other options after bulk update |
|
| 455 | - if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
| 456 | - $other_array = array(); |
|
| 457 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 458 | - if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
|
| 459 | - $other_array[ $opt_key ] = $opt; |
|
| 460 | - } |
|
| 461 | - unset($opt_key, $opt); |
|
| 462 | - } |
|
| 463 | - if ( ! empty($other_array) ) { |
|
| 464 | - $opts = array_merge( $opts, $other_array); |
|
| 465 | - } |
|
| 466 | - } |
|
| 467 | - |
|
| 468 | - FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) ); |
|
| 469 | - |
|
| 470 | - $field['options'] = $opts; |
|
| 471 | - $field_name = $field['name']; |
|
| 472 | - |
|
| 473 | - // Get html_id which will be used in single-option.php |
|
| 474 | - $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 475 | - |
|
| 476 | - if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
| 477 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/radio.php'); |
|
| 478 | - } else { |
|
| 479 | - FrmFieldsHelper::show_single_option($field); |
|
| 480 | - } |
|
| 481 | - |
|
| 482 | - wp_die(); |
|
| 483 | - } |
|
| 484 | - |
|
| 485 | - public static function update_order() { |
|
| 435 | + return; |
|
| 436 | + } |
|
| 437 | + |
|
| 438 | + $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 439 | + $opts = stripslashes_deep($_POST['opts']); |
|
| 440 | + $opts = explode("\n", rtrim($opts, "\n")); |
|
| 441 | + if ( $field['separate_value'] ) { |
|
| 442 | + foreach ( $opts as $opt_key => $opt ) { |
|
| 443 | + if ( strpos($opt, '|') !== false ) { |
|
| 444 | + $vals = explode('|', $opt); |
|
| 445 | + if ( $vals[0] != $vals[1] ) { |
|
| 446 | + $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 447 | + } |
|
| 448 | + unset($vals); |
|
| 449 | + } |
|
| 450 | + unset($opt_key, $opt); |
|
| 451 | + } |
|
| 452 | + } |
|
| 453 | + |
|
| 454 | + //Keep other options after bulk update |
|
| 455 | + if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
| 456 | + $other_array = array(); |
|
| 457 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 458 | + if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
|
| 459 | + $other_array[ $opt_key ] = $opt; |
|
| 460 | + } |
|
| 461 | + unset($opt_key, $opt); |
|
| 462 | + } |
|
| 463 | + if ( ! empty($other_array) ) { |
|
| 464 | + $opts = array_merge( $opts, $other_array); |
|
| 465 | + } |
|
| 466 | + } |
|
| 467 | + |
|
| 468 | + FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) ); |
|
| 469 | + |
|
| 470 | + $field['options'] = $opts; |
|
| 471 | + $field_name = $field['name']; |
|
| 472 | + |
|
| 473 | + // Get html_id which will be used in single-option.php |
|
| 474 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 475 | + |
|
| 476 | + if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
| 477 | + require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/radio.php'); |
|
| 478 | + } else { |
|
| 479 | + FrmFieldsHelper::show_single_option($field); |
|
| 480 | + } |
|
| 481 | + |
|
| 482 | + wp_die(); |
|
| 483 | + } |
|
| 484 | + |
|
| 485 | + public static function update_order() { |
|
| 486 | 486 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 487 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 487 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 488 | 488 | |
| 489 | 489 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
| 490 | 490 | foreach ( (array) $fields as $position => $item ) { |
| 491 | 491 | FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) ); |
| 492 | 492 | } |
| 493 | - wp_die(); |
|
| 494 | - } |
|
| 493 | + wp_die(); |
|
| 494 | + } |
|
| 495 | 495 | |
| 496 | 496 | public static function change_type( $type ) { |
| 497 | - $type_switch = array( |
|
| 498 | - 'scale' => 'radio', |
|
| 499 | - '10radio' => 'radio', |
|
| 500 | - 'rte' => 'textarea', |
|
| 501 | - 'website' => 'url', |
|
| 502 | - ); |
|
| 503 | - if ( isset( $type_switch[ $type ] ) ) { |
|
| 504 | - $type = $type_switch[ $type ]; |
|
| 505 | - } |
|
| 497 | + $type_switch = array( |
|
| 498 | + 'scale' => 'radio', |
|
| 499 | + '10radio' => 'radio', |
|
| 500 | + 'rte' => 'textarea', |
|
| 501 | + 'website' => 'url', |
|
| 502 | + ); |
|
| 503 | + if ( isset( $type_switch[ $type ] ) ) { |
|
| 504 | + $type = $type_switch[ $type ]; |
|
| 505 | + } |
|
| 506 | 506 | |
| 507 | 507 | $frm_field_selection = FrmField::field_selection(); |
| 508 | - $types = array_keys($frm_field_selection); |
|
| 509 | - if ( ! in_array($type, $types) && $type != 'captcha' ) { |
|
| 510 | - $type = 'text'; |
|
| 511 | - } |
|
| 508 | + $types = array_keys($frm_field_selection); |
|
| 509 | + if ( ! in_array($type, $types) && $type != 'captcha' ) { |
|
| 510 | + $type = 'text'; |
|
| 511 | + } |
|
| 512 | 512 | |
| 513 | - return $type; |
|
| 514 | - } |
|
| 513 | + return $type; |
|
| 514 | + } |
|
| 515 | 515 | |
| 516 | 516 | public static function display_field_options( $display ) { |
| 517 | 517 | switch ( $display['type'] ) { |
| 518 | - case 'captcha': |
|
| 519 | - $display['required'] = false; |
|
| 520 | - $display['invalid'] = true; |
|
| 521 | - $display['default_blank'] = false; |
|
| 518 | + case 'captcha': |
|
| 519 | + $display['required'] = false; |
|
| 520 | + $display['invalid'] = true; |
|
| 521 | + $display['default_blank'] = false; |
|
| 522 | 522 | $display['captcha_size'] = true; |
| 523 | - break; |
|
| 524 | - case 'radio': |
|
| 525 | - $display['default_blank'] = false; |
|
| 526 | - break; |
|
| 527 | - case 'text': |
|
| 528 | - case 'textarea': |
|
| 529 | - $display['size'] = true; |
|
| 530 | - $display['clear_on_focus'] = true; |
|
| 531 | - break; |
|
| 532 | - case 'select': |
|
| 533 | - $display['size'] = true; |
|
| 534 | - break; |
|
| 535 | - case 'url': |
|
| 536 | - case 'website': |
|
| 537 | - case 'email': |
|
| 538 | - $display['size'] = true; |
|
| 539 | - $display['clear_on_focus'] = true; |
|
| 540 | - $display['invalid'] = true; |
|
| 541 | - } |
|
| 542 | - |
|
| 543 | - return $display; |
|
| 544 | - } |
|
| 545 | - |
|
| 546 | - public static function input_html( $field, $echo = true ) { |
|
| 547 | - $class = array(); //$field['type']; |
|
| 548 | - self::add_input_classes($field, $class); |
|
| 549 | - |
|
| 550 | - $add_html = array(); |
|
| 551 | - self::add_html_size($field, $add_html); |
|
| 552 | - self::add_html_length($field, $add_html); |
|
| 553 | - self::add_html_placeholder($field, $add_html, $class); |
|
| 523 | + break; |
|
| 524 | + case 'radio': |
|
| 525 | + $display['default_blank'] = false; |
|
| 526 | + break; |
|
| 527 | + case 'text': |
|
| 528 | + case 'textarea': |
|
| 529 | + $display['size'] = true; |
|
| 530 | + $display['clear_on_focus'] = true; |
|
| 531 | + break; |
|
| 532 | + case 'select': |
|
| 533 | + $display['size'] = true; |
|
| 534 | + break; |
|
| 535 | + case 'url': |
|
| 536 | + case 'website': |
|
| 537 | + case 'email': |
|
| 538 | + $display['size'] = true; |
|
| 539 | + $display['clear_on_focus'] = true; |
|
| 540 | + $display['invalid'] = true; |
|
| 541 | + } |
|
| 542 | + |
|
| 543 | + return $display; |
|
| 544 | + } |
|
| 545 | + |
|
| 546 | + public static function input_html( $field, $echo = true ) { |
|
| 547 | + $class = array(); //$field['type']; |
|
| 548 | + self::add_input_classes($field, $class); |
|
| 549 | + |
|
| 550 | + $add_html = array(); |
|
| 551 | + self::add_html_size($field, $add_html); |
|
| 552 | + self::add_html_length($field, $add_html); |
|
| 553 | + self::add_html_placeholder($field, $add_html, $class); |
|
| 554 | 554 | //self::add_validation_messages( $field, $add_html ); uncomment this when the js validation is complete |
| 555 | 555 | |
| 556 | - $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 556 | + $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 557 | 557 | |
| 558 | 558 | FrmFormsHelper::add_html_attr( $class, 'class', $add_html ); |
| 559 | 559 | |
| 560 | - self::add_shortcodes_to_html($field, $add_html); |
|
| 560 | + self::add_shortcodes_to_html($field, $add_html); |
|
| 561 | 561 | |
| 562 | 562 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
| 563 | 563 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
| 564 | 564 | |
| 565 | - if ( $echo ) { |
|
| 566 | - echo $add_html; |
|
| 567 | - } |
|
| 565 | + if ( $echo ) { |
|
| 566 | + echo $add_html; |
|
| 567 | + } |
|
| 568 | 568 | |
| 569 | - return $add_html; |
|
| 570 | - } |
|
| 569 | + return $add_html; |
|
| 570 | + } |
|
| 571 | 571 | |
| 572 | 572 | private static function add_input_classes( $field, array &$class ) { |
| 573 | - if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 574 | - $class[] = $field['input_class']; |
|
| 575 | - } |
|
| 573 | + if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 574 | + $class[] = $field['input_class']; |
|
| 575 | + } |
|
| 576 | 576 | |
| 577 | - if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
| 578 | - return; |
|
| 579 | - } |
|
| 577 | + if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
| 578 | + return; |
|
| 579 | + } |
|
| 580 | 580 | |
| 581 | - global $frm_vars; |
|
| 581 | + global $frm_vars; |
|
| 582 | 582 | if ( is_admin() && ! FrmAppHelper::is_preview_page() && ! in_array( $field['type'], array( 'scale', 'radio', 'checkbox', 'data' ) ) ) { |
| 583 | - $class[] = 'dyn_default_value'; |
|
| 584 | - } |
|
| 583 | + $class[] = 'dyn_default_value'; |
|
| 584 | + } |
|
| 585 | 585 | |
| 586 | - if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 587 | - $class[] = 'auto_width'; |
|
| 588 | - } |
|
| 589 | - } |
|
| 586 | + if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 587 | + $class[] = 'auto_width'; |
|
| 588 | + } |
|
| 589 | + } |
|
| 590 | 590 | |
| 591 | 591 | private static function add_html_size( $field, array &$add_html ) { |
| 592 | 592 | if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden' ) ) ) { |
| 593 | - return; |
|
| 594 | - } |
|
| 593 | + return; |
|
| 594 | + } |
|
| 595 | 595 | |
| 596 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 597 | - return; |
|
| 598 | - } |
|
| 596 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 597 | + return; |
|
| 598 | + } |
|
| 599 | 599 | |
| 600 | - if ( is_numeric($field['size']) ) { |
|
| 601 | - $field['size'] .= 'px'; |
|
| 602 | - } |
|
| 600 | + if ( is_numeric($field['size']) ) { |
|
| 601 | + $field['size'] .= 'px'; |
|
| 602 | + } |
|
| 603 | 603 | |
| 604 | - $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 605 | - // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
| 606 | - $add_html['style'] = 'style="width:'. esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) .'"'; |
|
| 604 | + $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 605 | + // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
| 606 | + $add_html['style'] = 'style="width:'. esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) .'"'; |
|
| 607 | 607 | |
| 608 | - self::add_html_cols($field, $add_html); |
|
| 609 | - } |
|
| 608 | + self::add_html_cols($field, $add_html); |
|
| 609 | + } |
|
| 610 | 610 | |
| 611 | 611 | private static function add_html_cols( $field, array &$add_html ) { |
| 612 | 612 | if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) { |
| 613 | - return; |
|
| 614 | - } |
|
| 613 | + return; |
|
| 614 | + } |
|
| 615 | 615 | |
| 616 | - // convert to cols for textareas |
|
| 617 | - $calc = array( |
|
| 618 | - '' => 9, |
|
| 619 | - 'px' => 9, |
|
| 620 | - 'rem' => 0.444, |
|
| 621 | - 'em' => 0.544, |
|
| 622 | - ); |
|
| 616 | + // convert to cols for textareas |
|
| 617 | + $calc = array( |
|
| 618 | + '' => 9, |
|
| 619 | + 'px' => 9, |
|
| 620 | + 'rem' => 0.444, |
|
| 621 | + 'em' => 0.544, |
|
| 622 | + ); |
|
| 623 | 623 | |
| 624 | - // include "col" for valid html |
|
| 625 | - $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 624 | + // include "col" for valid html |
|
| 625 | + $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 626 | 626 | |
| 627 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
| 628 | - return; |
|
| 629 | - } |
|
| 627 | + if ( ! isset( $calc[ $unit ] ) ) { |
|
| 628 | + return; |
|
| 629 | + } |
|
| 630 | 630 | |
| 631 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 631 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 632 | 632 | |
| 633 | 633 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
| 634 | - } |
|
| 634 | + } |
|
| 635 | 635 | |
| 636 | 636 | private static function add_html_length( $field, array &$add_html ) { |
| 637 | - // check for max setting and if this field accepts maxlength |
|
| 637 | + // check for max setting and if this field accepts maxlength |
|
| 638 | 638 | if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden' ) ) ) { |
| 639 | - return; |
|
| 640 | - } |
|
| 639 | + return; |
|
| 640 | + } |
|
| 641 | 641 | |
| 642 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 643 | - // don't load on form builder page |
|
| 644 | - return; |
|
| 645 | - } |
|
| 642 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 643 | + // don't load on form builder page |
|
| 644 | + return; |
|
| 645 | + } |
|
| 646 | 646 | |
| 647 | 647 | $add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"'; |
| 648 | - } |
|
| 648 | + } |
|
| 649 | 649 | |
| 650 | 650 | private static function add_html_placeholder( $field, array &$add_html, array &$class ) { |
| 651 | 651 | if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) { |
| 652 | 652 | return; |
| 653 | 653 | } |
| 654 | 654 | |
| 655 | - if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
|
| 655 | + if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
|
| 656 | 656 | if ( is_array( $field['default_value'] ) ) { |
| 657 | 657 | $field['default_value'] = json_encode( $field['default_value'] ); |
| 658 | 658 | } |
| 659 | 659 | $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"'; |
| 660 | - return; |
|
| 661 | - } |
|
| 660 | + return; |
|
| 661 | + } |
|
| 662 | 662 | |
| 663 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 663 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 664 | 664 | |
| 665 | 665 | if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) { |
| 666 | - // use HMTL5 placeholder with js fallback |
|
| 667 | - $add_html['placeholder'] = 'placeholder="'. esc_attr($field['default_value']) .'"'; |
|
| 668 | - wp_enqueue_script('jquery-placeholder'); |
|
| 669 | - } else if ( ! $frm_settings->use_html ) { |
|
| 666 | + // use HMTL5 placeholder with js fallback |
|
| 667 | + $add_html['placeholder'] = 'placeholder="'. esc_attr($field['default_value']) .'"'; |
|
| 668 | + wp_enqueue_script('jquery-placeholder'); |
|
| 669 | + } else if ( ! $frm_settings->use_html ) { |
|
| 670 | 670 | $val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( ''', "'", esc_attr( $field['default_value'] ) ) ) ); |
| 671 | - $add_html['data-frmval'] = 'data-frmval="'. esc_attr($val) .'"'; |
|
| 672 | - $class[] = 'frm_toggle_default'; |
|
| 671 | + $add_html['data-frmval'] = 'data-frmval="'. esc_attr($val) .'"'; |
|
| 672 | + $class[] = 'frm_toggle_default'; |
|
| 673 | 673 | |
| 674 | - if ( $field['value'] == $field['default_value'] ) { |
|
| 675 | - $class[] = 'frm_default'; |
|
| 676 | - } |
|
| 677 | - } |
|
| 678 | - } |
|
| 674 | + if ( $field['value'] == $field['default_value'] ) { |
|
| 675 | + $class[] = 'frm_default'; |
|
| 676 | + } |
|
| 677 | + } |
|
| 678 | + } |
|
| 679 | 679 | |
| 680 | 680 | private static function add_validation_messages( $field, array &$add_html ) { |
| 681 | 681 | if ( FrmField::is_required( $field ) ) { |
@@ -696,44 +696,44 @@ discard block |
||
| 696 | 696 | } |
| 697 | 697 | } |
| 698 | 698 | |
| 699 | - private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
| 700 | - if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
| 701 | - return; |
|
| 702 | - } |
|
| 703 | - |
|
| 704 | - foreach ( $field['shortcodes'] as $k => $v ) { |
|
| 705 | - if ( 'opt' === $k ) { |
|
| 706 | - continue; |
|
| 707 | - } |
|
| 708 | - |
|
| 709 | - if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 710 | - $add_html[] = $v; |
|
| 711 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 712 | - $add_html[ $k ] = str_replace( $k .'="', $k .'="'. $v, $add_html[ $k ] ); |
|
| 713 | - } else { |
|
| 699 | + private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
| 700 | + if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
| 701 | + return; |
|
| 702 | + } |
|
| 703 | + |
|
| 704 | + foreach ( $field['shortcodes'] as $k => $v ) { |
|
| 705 | + if ( 'opt' === $k ) { |
|
| 706 | + continue; |
|
| 707 | + } |
|
| 708 | + |
|
| 709 | + if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 710 | + $add_html[] = $v; |
|
| 711 | + } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 712 | + $add_html[ $k ] = str_replace( $k .'="', $k .'="'. $v, $add_html[ $k ] ); |
|
| 713 | + } else { |
|
| 714 | 714 | $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
| 715 | - } |
|
| 716 | - |
|
| 717 | - unset($k, $v); |
|
| 718 | - } |
|
| 719 | - } |
|
| 720 | - |
|
| 721 | - public static function check_value( $opt, $opt_key, $field ) { |
|
| 722 | - if ( is_array( $opt ) ) { |
|
| 723 | - if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
| 724 | - $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 725 | - } else { |
|
| 726 | - $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
| 727 | - } |
|
| 728 | - } |
|
| 729 | - return $opt; |
|
| 730 | - } |
|
| 715 | + } |
|
| 716 | + |
|
| 717 | + unset($k, $v); |
|
| 718 | + } |
|
| 719 | + } |
|
| 720 | + |
|
| 721 | + public static function check_value( $opt, $opt_key, $field ) { |
|
| 722 | + if ( is_array( $opt ) ) { |
|
| 723 | + if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
| 724 | + $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 725 | + } else { |
|
| 726 | + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
| 727 | + } |
|
| 728 | + } |
|
| 729 | + return $opt; |
|
| 730 | + } |
|
| 731 | 731 | |
| 732 | 732 | public static function check_label( $opt ) { |
| 733 | - if ( is_array($opt) ) { |
|
| 734 | - $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 735 | - } |
|
| 733 | + if ( is_array($opt) ) { |
|
| 734 | + $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 735 | + } |
|
| 736 | 736 | |
| 737 | - return $opt; |
|
| 738 | - } |
|
| 737 | + return $opt; |
|
| 738 | + } |
|
| 739 | 739 | } |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | class FrmFieldsController { |
| 4 | 4 | |
| 5 | 5 | public static function load_field() { |
| 6 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 6 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 7 | 7 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 8 | 8 | |
| 9 | 9 | $fields = $_POST['field']; |
@@ -33,33 +33,33 @@ discard block |
||
| 33 | 33 | $field['value'] = ''; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - $field_name = 'item_meta['. $field_id .']'; |
|
| 37 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 36 | + $field_name = 'item_meta[' . $field_id . ']'; |
|
| 37 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 38 | 38 | |
| 39 | 39 | ob_start(); |
| 40 | - include($path .'/classes/views/frm-forms/add_field.php'); |
|
| 41 | - $field_html[ $field_id ] = ob_get_contents(); |
|
| 40 | + include( $path . '/classes/views/frm-forms/add_field.php' ); |
|
| 41 | + $field_html[$field_id] = ob_get_contents(); |
|
| 42 | 42 | ob_end_clean(); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - unset($path); |
|
| 45 | + unset( $path ); |
|
| 46 | 46 | |
| 47 | - echo json_encode($field_html); |
|
| 47 | + echo json_encode( $field_html ); |
|
| 48 | 48 | |
| 49 | 49 | wp_die(); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | public static function create() { |
| 53 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 53 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 54 | 54 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 55 | 55 | |
| 56 | 56 | $field_type = FrmAppHelper::get_post_param( 'field', '', 'sanitize_text_field' ); |
| 57 | 57 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 58 | 58 | |
| 59 | - $field = self::include_new_field($field_type, $form_id); |
|
| 59 | + $field = self::include_new_field( $field_type, $form_id ); |
|
| 60 | 60 | |
| 61 | 61 | // this hook will allow for multiple fields to be added at once |
| 62 | - do_action('frm_after_field_created', $field, $form_id); |
|
| 62 | + do_action( 'frm_after_field_created', $field, $form_id ); |
|
| 63 | 63 | |
| 64 | 64 | wp_die(); |
| 65 | 65 | } |
@@ -70,23 +70,23 @@ discard block |
||
| 70 | 70 | public static function include_new_field( $field_type, $form_id ) { |
| 71 | 71 | $values = array(); |
| 72 | 72 | if ( FrmAppHelper::pro_is_installed() ) { |
| 73 | - $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 73 | + $values['post_type'] = FrmProFormsHelper::post_type( $form_id ); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id)); |
|
| 76 | + $field_values = apply_filters( 'frm_before_field_created', FrmFieldsHelper::setup_new_vars( $field_type, $form_id ) ); |
|
| 77 | 77 | $field_id = FrmField::create( $field_values ); |
| 78 | 78 | |
| 79 | 79 | if ( ! $field_id ) { |
| 80 | 80 | return false; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - $field = self::include_single_field($field_id, $values, $form_id); |
|
| 83 | + $field = self::include_single_field( $field_id, $values, $form_id ); |
|
| 84 | 84 | |
| 85 | 85 | return $field; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | public static function update_form_id() { |
| 89 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 89 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 90 | 90 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 91 | 91 | |
| 92 | 92 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
@@ -103,21 +103,21 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | public static function edit_name( $field = 'name', $id = '' ) { |
| 106 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 106 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 107 | 107 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 108 | 108 | |
| 109 | - if ( empty($field) ) { |
|
| 109 | + if ( empty( $field ) ) { |
|
| 110 | 110 | $field = 'name'; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - if ( empty($id) ) { |
|
| 113 | + if ( empty( $id ) ) { |
|
| 114 | 114 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 115 | 115 | $id = str_replace( 'field_label_', '', $id ); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
| 119 | 119 | $value = trim( $value ); |
| 120 | - if ( trim(strip_tags($value)) == '' ) { |
|
| 120 | + if ( trim( strip_tags( $value ) ) == '' ) { |
|
| 121 | 121 | // set blank value if there is no content |
| 122 | 122 | $value = ''; |
| 123 | 123 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | public static function update_ajax_option() { |
| 134 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 134 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 135 | 135 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 136 | 136 | |
| 137 | 137 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | $field = FrmField::getOne( $field_id ); |
| 143 | 143 | |
| 144 | 144 | foreach ( array( 'clear_on_focus', 'separate_value', 'default_blank' ) as $val ) { |
| 145 | - if ( isset($_POST[ $val ]) ) { |
|
| 145 | + if ( isset( $_POST[$val] ) ) { |
|
| 146 | 146 | // all three of these options are boolean |
| 147 | 147 | $new_val = FrmAppHelper::get_post_param( $val, 0, 'absint' ); |
| 148 | 148 | |
@@ -150,10 +150,10 @@ discard block |
||
| 150 | 150 | $new_val = FrmField::is_option_true( $field, $val ) ? 0 : 1; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - $field->field_options[ $val ] = $new_val; |
|
| 154 | - unset($new_val); |
|
| 153 | + $field->field_options[$val] = $new_val; |
|
| 154 | + unset( $new_val ); |
|
| 155 | 155 | } |
| 156 | - unset($val); |
|
| 156 | + unset( $val ); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | FrmField::update( $field_id, array( |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | public static function duplicate() { |
| 167 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 167 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 168 | 168 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 169 | 169 | |
| 170 | 170 | global $wpdb; |
@@ -177,21 +177,21 @@ discard block |
||
| 177 | 177 | wp_die(); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - do_action('frm_duplicate_field', $copy_field, $form_id); |
|
| 181 | - do_action('frm_duplicate_field_'. $copy_field->type, $copy_field, $form_id); |
|
| 180 | + do_action( 'frm_duplicate_field', $copy_field, $form_id ); |
|
| 181 | + do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id ); |
|
| 182 | 182 | |
| 183 | 183 | $values = array( 'id' => $form_id ); |
| 184 | 184 | FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
| 185 | 185 | |
| 186 | - $field_count = FrmDb::get_count( $wpdb->prefix .'frm_fields fi LEFT JOIN '. $wpdb->prefix .'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) ); |
|
| 186 | + $field_count = FrmDb::get_count( $wpdb->prefix . 'frm_fields fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) ); |
|
| 187 | 187 | |
| 188 | 188 | $values['field_order'] = $field_count + 1; |
| 189 | 189 | |
| 190 | - if ( ! $field_id = FrmField::create($values) ) { |
|
| 190 | + if ( ! $field_id = FrmField::create( $values ) ) { |
|
| 191 | 191 | wp_die(); |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - self::include_single_field($field_id, $values); |
|
| 194 | + self::include_single_field( $field_id, $values ); |
|
| 195 | 195 | |
| 196 | 196 | wp_die(); |
| 197 | 197 | } |
@@ -200,21 +200,21 @@ discard block |
||
| 200 | 200 | * Load a single field in the form builder along with all needed variables |
| 201 | 201 | */ |
| 202 | 202 | public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
| 203 | - $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 204 | - $field_name = 'item_meta['. $field_id .']'; |
|
| 205 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 203 | + $field = FrmFieldsHelper::setup_edit_vars( FrmField::getOne( $field_id ) ); |
|
| 204 | + $field_name = 'item_meta[' . $field_id . ']'; |
|
| 205 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 206 | 206 | $id = $form_id ? $form_id : $field['form_id']; |
| 207 | 207 | if ( $field['type'] == 'html' ) { |
| 208 | 208 | $field['stop_filter'] = true; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php'); |
|
| 211 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' ); |
|
| 212 | 212 | |
| 213 | 213 | return $field; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | public static function destroy() { |
| 217 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 217 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 218 | 218 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 219 | 219 | |
| 220 | 220 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
@@ -226,14 +226,14 @@ discard block |
||
| 226 | 226 | |
| 227 | 227 | //Add Single Option or Other Option |
| 228 | 228 | public static function add_option() { |
| 229 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 229 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 230 | 230 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 231 | 231 | |
| 232 | 232 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 233 | 233 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
| 234 | 234 | |
| 235 | 235 | //Get the field |
| 236 | - $field = FrmField::getOne($id); |
|
| 236 | + $field = FrmField::getOne( $id ); |
|
| 237 | 237 | |
| 238 | 238 | if ( ! empty( $field->options ) ) { |
| 239 | 239 | $keys = array_keys( $field->options ); |
@@ -256,13 +256,13 @@ discard block |
||
| 256 | 256 | $first_opt = reset( $field->options ); |
| 257 | 257 | $next_opt = count( $field->options ); |
| 258 | 258 | if ( $first_opt != '' ) { |
| 259 | - $next_opt++; |
|
| 259 | + $next_opt ++; |
|
| 260 | 260 | } |
| 261 | - $opt = esc_html__( 'Option', 'formidable' ) .' '. $next_opt; |
|
| 262 | - unset($next_opt); |
|
| 261 | + $opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt; |
|
| 262 | + unset( $next_opt ); |
|
| 263 | 263 | } |
| 264 | 264 | $field_val = $opt; |
| 265 | - $field->options[ $opt_key ] = $opt; |
|
| 265 | + $field->options[$opt_key] = $opt; |
|
| 266 | 266 | |
| 267 | 267 | //Update options in DB |
| 268 | 268 | FrmField::update( $id, array( 'options' => $field->options ) ); |
@@ -271,25 +271,25 @@ discard block |
||
| 271 | 271 | $field = array( |
| 272 | 272 | 'type' => $field_data->type, |
| 273 | 273 | 'id' => $id, |
| 274 | - 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
| 274 | + 'separate_value' => isset( $field_data->field_options['separate_value'] ) ? $field_data->field_options['separate_value'] : 0, |
|
| 275 | 275 | 'form_id' => $field_data->form_id, |
| 276 | 276 | 'field_key' => $field_data->field_key, |
| 277 | 277 | ); |
| 278 | 278 | |
| 279 | - $field_name = 'item_meta['. $id .']'; |
|
| 280 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 279 | + $field_name = 'item_meta[' . $id . ']'; |
|
| 280 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 281 | 281 | $checked = ''; |
| 282 | 282 | |
| 283 | 283 | if ( 'other' == $opt_type ) { |
| 284 | - require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php'); |
|
| 284 | + require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
|
| 285 | 285 | } else { |
| 286 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php'); |
|
| 286 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
|
| 287 | 287 | } |
| 288 | 288 | wp_die(); |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | public static function edit_option() { |
| 292 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 292 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 293 | 293 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 294 | 294 | |
| 295 | 295 | $element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
@@ -303,28 +303,28 @@ discard block |
||
| 303 | 303 | $new_label = $update_value; |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - $field = FrmField::getOne($id); |
|
| 306 | + $field = FrmField::getOne( $id ); |
|
| 307 | 307 | $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
| 308 | 308 | |
| 309 | - $this_opt_id = end($ids); |
|
| 310 | - $this_opt = (array) $field->options[ $this_opt_id ]; |
|
| 311 | - $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false ); |
|
| 309 | + $this_opt_id = end( $ids ); |
|
| 310 | + $this_opt = (array) $field->options[$this_opt_id]; |
|
| 311 | + $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other' ) !== false ); |
|
| 312 | 312 | |
| 313 | - $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
| 314 | - $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
| 313 | + $label = isset( $this_opt['label'] ) ? $this_opt['label'] : reset( $this_opt ); |
|
| 314 | + $value = isset( $this_opt['value'] ) ? $this_opt['value'] : ''; |
|
| 315 | 315 | |
| 316 | 316 | if ( ! isset( $new_label ) ) { |
| 317 | 317 | $new_label = $label; |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - if ( isset($new_value) || isset($value) ) { |
|
| 321 | - $update_value = isset($new_value) ? $new_value : $value; |
|
| 320 | + if ( isset( $new_value ) || isset( $value ) ) { |
|
| 321 | + $update_value = isset( $new_value ) ? $new_value : $value; |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | if ( $update_value != $new_label && $other_opt === false && $separate_values ) { |
| 325 | - $field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label ); |
|
| 325 | + $field->options[$this_opt_id] = array( 'value' => $update_value, 'label' => $new_label ); |
|
| 326 | 326 | } else { |
| 327 | - $field->options[ $this_opt_id ] = $orig_update_value; |
|
| 327 | + $field->options[$this_opt_id] = $orig_update_value; |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | FrmField::update( $field->id, array( 'options' => $field->options ) ); |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | public static function delete_option() { |
| 336 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 336 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 337 | 337 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 338 | 338 | |
| 339 | 339 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' ); |
| 343 | 343 | |
| 344 | 344 | $options = $field->options; |
| 345 | - unset( $options[ $opt_key ] ); |
|
| 345 | + unset( $options[$opt_key] ); |
|
| 346 | 346 | $response = array( 'other' => true ); |
| 347 | 347 | |
| 348 | 348 | //If the deleted option is an "other" option |
@@ -408,46 +408,46 @@ discard block |
||
| 408 | 408 | |
| 409 | 409 | $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
| 410 | 410 | $prepop = array(); |
| 411 | - FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 411 | + FrmFieldsHelper::get_bulk_prefilled_opts( $prepop ); |
|
| 412 | 412 | |
| 413 | - $field = FrmField::getOne($field_id); |
|
| 413 | + $field = FrmField::getOne( $field_id ); |
|
| 414 | 414 | |
| 415 | 415 | wp_enqueue_script( 'utils' ); |
| 416 | - wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css' ); |
|
| 416 | + wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' ); |
|
| 417 | 417 | FrmAppHelper::load_admin_wide_js(); |
| 418 | 418 | |
| 419 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/import_choices.php'); |
|
| 419 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' ); |
|
| 420 | 420 | wp_die(); |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | public static function import_options() { |
| 424 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 424 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 425 | 425 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 426 | 426 | |
| 427 | - if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 427 | + if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) { |
|
| 428 | 428 | return; |
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | $field_id = absint( $_POST['field_id'] ); |
| 432 | - $field = FrmField::getOne($field_id); |
|
| 432 | + $field = FrmField::getOne( $field_id ); |
|
| 433 | 433 | |
| 434 | 434 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
| 435 | 435 | return; |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | - $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 439 | - $opts = stripslashes_deep($_POST['opts']); |
|
| 440 | - $opts = explode("\n", rtrim($opts, "\n")); |
|
| 438 | + $field = FrmFieldsHelper::setup_edit_vars( $field ); |
|
| 439 | + $opts = stripslashes_deep( $_POST['opts'] ); |
|
| 440 | + $opts = explode( "\n", rtrim( $opts, "\n" ) ); |
|
| 441 | 441 | if ( $field['separate_value'] ) { |
| 442 | 442 | foreach ( $opts as $opt_key => $opt ) { |
| 443 | - if ( strpos($opt, '|') !== false ) { |
|
| 444 | - $vals = explode('|', $opt); |
|
| 443 | + if ( strpos( $opt, '|' ) !== false ) { |
|
| 444 | + $vals = explode( '|', $opt ); |
|
| 445 | 445 | if ( $vals[0] != $vals[1] ) { |
| 446 | - $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 446 | + $opts[$opt_key] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 447 | 447 | } |
| 448 | - unset($vals); |
|
| 448 | + unset( $vals ); |
|
| 449 | 449 | } |
| 450 | - unset($opt_key, $opt); |
|
| 450 | + unset( $opt_key, $opt ); |
|
| 451 | 451 | } |
| 452 | 452 | } |
| 453 | 453 | |
@@ -456,12 +456,12 @@ discard block |
||
| 456 | 456 | $other_array = array(); |
| 457 | 457 | foreach ( $field['options'] as $opt_key => $opt ) { |
| 458 | 458 | if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
| 459 | - $other_array[ $opt_key ] = $opt; |
|
| 459 | + $other_array[$opt_key] = $opt; |
|
| 460 | 460 | } |
| 461 | - unset($opt_key, $opt); |
|
| 461 | + unset( $opt_key, $opt ); |
|
| 462 | 462 | } |
| 463 | - if ( ! empty($other_array) ) { |
|
| 464 | - $opts = array_merge( $opts, $other_array); |
|
| 463 | + if ( ! empty( $other_array ) ) { |
|
| 464 | + $opts = array_merge( $opts, $other_array ); |
|
| 465 | 465 | } |
| 466 | 466 | } |
| 467 | 467 | |
@@ -474,16 +474,16 @@ discard block |
||
| 474 | 474 | $html_id = FrmFieldsHelper::get_html_id( $field ); |
| 475 | 475 | |
| 476 | 476 | if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
| 477 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/radio.php'); |
|
| 477 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); |
|
| 478 | 478 | } else { |
| 479 | - FrmFieldsHelper::show_single_option($field); |
|
| 479 | + FrmFieldsHelper::show_single_option( $field ); |
|
| 480 | 480 | } |
| 481 | 481 | |
| 482 | 482 | wp_die(); |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | public static function update_order() { |
| 486 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 486 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 487 | 487 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 488 | 488 | |
| 489 | 489 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
@@ -500,13 +500,13 @@ discard block |
||
| 500 | 500 | 'rte' => 'textarea', |
| 501 | 501 | 'website' => 'url', |
| 502 | 502 | ); |
| 503 | - if ( isset( $type_switch[ $type ] ) ) { |
|
| 504 | - $type = $type_switch[ $type ]; |
|
| 503 | + if ( isset( $type_switch[$type] ) ) { |
|
| 504 | + $type = $type_switch[$type]; |
|
| 505 | 505 | } |
| 506 | 506 | |
| 507 | 507 | $frm_field_selection = FrmField::field_selection(); |
| 508 | - $types = array_keys($frm_field_selection); |
|
| 509 | - if ( ! in_array($type, $types) && $type != 'captcha' ) { |
|
| 508 | + $types = array_keys( $frm_field_selection ); |
|
| 509 | + if ( ! in_array( $type, $types ) && $type != 'captcha' ) { |
|
| 510 | 510 | $type = 'text'; |
| 511 | 511 | } |
| 512 | 512 | |
@@ -545,19 +545,19 @@ discard block |
||
| 545 | 545 | |
| 546 | 546 | public static function input_html( $field, $echo = true ) { |
| 547 | 547 | $class = array(); //$field['type']; |
| 548 | - self::add_input_classes($field, $class); |
|
| 548 | + self::add_input_classes( $field, $class ); |
|
| 549 | 549 | |
| 550 | 550 | $add_html = array(); |
| 551 | - self::add_html_size($field, $add_html); |
|
| 552 | - self::add_html_length($field, $add_html); |
|
| 553 | - self::add_html_placeholder($field, $add_html, $class); |
|
| 551 | + self::add_html_size( $field, $add_html ); |
|
| 552 | + self::add_html_length( $field, $add_html ); |
|
| 553 | + self::add_html_placeholder( $field, $add_html, $class ); |
|
| 554 | 554 | //self::add_validation_messages( $field, $add_html ); uncomment this when the js validation is complete |
| 555 | 555 | |
| 556 | - $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 556 | + $class = apply_filters( 'frm_field_classes', implode( ' ', $class ), $field ); |
|
| 557 | 557 | |
| 558 | 558 | FrmFormsHelper::add_html_attr( $class, 'class', $add_html ); |
| 559 | 559 | |
| 560 | - self::add_shortcodes_to_html($field, $add_html); |
|
| 560 | + self::add_shortcodes_to_html( $field, $add_html ); |
|
| 561 | 561 | |
| 562 | 562 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
| 563 | 563 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | private static function add_input_classes( $field, array &$class ) { |
| 573 | - if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 573 | + if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) { |
|
| 574 | 574 | $class[] = $field['input_class']; |
| 575 | 575 | } |
| 576 | 576 | |
@@ -583,7 +583,7 @@ discard block |
||
| 583 | 583 | $class[] = 'dyn_default_value'; |
| 584 | 584 | } |
| 585 | 585 | |
| 586 | - if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 586 | + if ( isset( $field['size'] ) && $field['size'] > 0 ) { |
|
| 587 | 587 | $class[] = 'auto_width'; |
| 588 | 588 | } |
| 589 | 589 | } |
@@ -593,19 +593,19 @@ discard block |
||
| 593 | 593 | return; |
| 594 | 594 | } |
| 595 | 595 | |
| 596 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 596 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 597 | 597 | return; |
| 598 | 598 | } |
| 599 | 599 | |
| 600 | - if ( is_numeric($field['size']) ) { |
|
| 600 | + if ( is_numeric( $field['size'] ) ) { |
|
| 601 | 601 | $field['size'] .= 'px'; |
| 602 | 602 | } |
| 603 | 603 | |
| 604 | - $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 604 | + $important = apply_filters( 'frm_use_important_width', 1, $field ); |
|
| 605 | 605 | // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
| 606 | - $add_html['style'] = 'style="width:'. esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) .'"'; |
|
| 606 | + $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"'; |
|
| 607 | 607 | |
| 608 | - self::add_html_cols($field, $add_html); |
|
| 608 | + self::add_html_cols( $field, $add_html ); |
|
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | private static function add_html_cols( $field, array &$add_html ) { |
@@ -622,13 +622,13 @@ discard block |
||
| 622 | 622 | ); |
| 623 | 623 | |
| 624 | 624 | // include "col" for valid html |
| 625 | - $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 625 | + $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) ); |
|
| 626 | 626 | |
| 627 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
| 627 | + if ( ! isset( $calc[$unit] ) ) { |
|
| 628 | 628 | return; |
| 629 | 629 | } |
| 630 | 630 | |
| 631 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 631 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[$unit]; |
|
| 632 | 632 | |
| 633 | 633 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
| 634 | 634 | } |
@@ -639,7 +639,7 @@ discard block |
||
| 639 | 639 | return; |
| 640 | 640 | } |
| 641 | 641 | |
| 642 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 642 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 643 | 643 | // don't load on form builder page |
| 644 | 644 | return; |
| 645 | 645 | } |
@@ -664,11 +664,11 @@ discard block |
||
| 664 | 664 | |
| 665 | 665 | if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) { |
| 666 | 666 | // use HMTL5 placeholder with js fallback |
| 667 | - $add_html['placeholder'] = 'placeholder="'. esc_attr($field['default_value']) .'"'; |
|
| 668 | - wp_enqueue_script('jquery-placeholder'); |
|
| 667 | + $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"'; |
|
| 668 | + wp_enqueue_script( 'jquery-placeholder' ); |
|
| 669 | 669 | } else if ( ! $frm_settings->use_html ) { |
| 670 | 670 | $val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( ''', "'", esc_attr( $field['default_value'] ) ) ) ); |
| 671 | - $add_html['data-frmval'] = 'data-frmval="'. esc_attr($val) .'"'; |
|
| 671 | + $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"'; |
|
| 672 | 672 | $class[] = 'frm_toggle_default'; |
| 673 | 673 | |
| 674 | 674 | if ( $field['value'] == $field['default_value'] ) { |
@@ -692,7 +692,7 @@ discard block |
||
| 692 | 692 | $format = FrmEntryValidate::phone_format( $field ); |
| 693 | 693 | $format = substr( $format, 2, -2 ); |
| 694 | 694 | $key = 'pattern'; |
| 695 | - $add_html[ $key ] = $key . '="' . esc_attr( $format ) . '"'; |
|
| 695 | + $add_html[$key] = $key . '="' . esc_attr( $format ) . '"'; |
|
| 696 | 696 | } |
| 697 | 697 | } |
| 698 | 698 | |
@@ -706,15 +706,15 @@ discard block |
||
| 706 | 706 | continue; |
| 707 | 707 | } |
| 708 | 708 | |
| 709 | - if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 709 | + if ( is_numeric( $k ) && strpos( $v, '=' ) ) { |
|
| 710 | 710 | $add_html[] = $v; |
| 711 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 712 | - $add_html[ $k ] = str_replace( $k .'="', $k .'="'. $v, $add_html[ $k ] ); |
|
| 711 | + } else if ( ! empty( $k ) && isset( $add_html[$k] ) ) { |
|
| 712 | + $add_html[$k] = str_replace( $k . '="', $k . '="' . $v, $add_html[$k] ); |
|
| 713 | 713 | } else { |
| 714 | - $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
|
| 714 | + $add_html[$k] = $k . '="' . esc_attr( $v ) . '"'; |
|
| 715 | 715 | } |
| 716 | 716 | |
| 717 | - unset($k, $v); |
|
| 717 | + unset( $k, $v ); |
|
| 718 | 718 | } |
| 719 | 719 | } |
| 720 | 720 | |
@@ -730,8 +730,8 @@ discard block |
||
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | public static function check_label( $opt ) { |
| 733 | - if ( is_array($opt) ) { |
|
| 734 | - $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 733 | + if ( is_array( $opt ) ) { |
|
| 734 | + $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 735 | 735 | } |
| 736 | 736 | |
| 737 | 737 | return $opt; |
@@ -1,109 +1,109 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmFormActionsController { |
| 4 | - public static $action_post_type = 'frm_form_actions'; |
|
| 5 | - public static $registered_actions; |
|
| 6 | - |
|
| 7 | - public static function register_post_types() { |
|
| 8 | - register_post_type( self::$action_post_type, array( |
|
| 9 | - 'label' => __( 'Form Actions', 'formidable' ), |
|
| 10 | - 'description' => '', |
|
| 11 | - 'public' => false, |
|
| 12 | - 'show_ui' => false, |
|
| 13 | - 'exclude_from_search' => true, |
|
| 14 | - 'show_in_nav_menus' => false, |
|
| 15 | - 'show_in_menu' => true, |
|
| 16 | - 'capability_type' => 'page', |
|
| 17 | - 'supports' => array( |
|
| 4 | + public static $action_post_type = 'frm_form_actions'; |
|
| 5 | + public static $registered_actions; |
|
| 6 | + |
|
| 7 | + public static function register_post_types() { |
|
| 8 | + register_post_type( self::$action_post_type, array( |
|
| 9 | + 'label' => __( 'Form Actions', 'formidable' ), |
|
| 10 | + 'description' => '', |
|
| 11 | + 'public' => false, |
|
| 12 | + 'show_ui' => false, |
|
| 13 | + 'exclude_from_search' => true, |
|
| 14 | + 'show_in_nav_menus' => false, |
|
| 15 | + 'show_in_menu' => true, |
|
| 16 | + 'capability_type' => 'page', |
|
| 17 | + 'supports' => array( |
|
| 18 | 18 | 'title', 'editor', 'excerpt', 'custom-fields', |
| 19 | 19 | 'page-attributes', |
| 20 | - ), |
|
| 21 | - 'has_archive' => false, |
|
| 22 | - ) ); |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * post_content: json settings |
|
| 26 | - * menu_order: form id |
|
| 27 | - * post_excerpt: action type |
|
| 28 | - */ |
|
| 29 | - |
|
| 30 | - self::actions_init(); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - public static function actions_init() { |
|
| 34 | - self::$registered_actions = new Frm_Form_Action_Factory(); |
|
| 35 | - self::register_actions(); |
|
| 36 | - do_action( 'frm_form_actions_init' ); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - public static function register_actions() { |
|
| 40 | - $action_classes = apply_filters( 'frm_registered_form_actions', array( |
|
| 41 | - 'email' => 'FrmEmailAction', |
|
| 42 | - 'wppost' => 'FrmDefPostAction', |
|
| 43 | - 'register' => 'FrmDefRegAction', |
|
| 44 | - 'paypal' => 'FrmDefPayPalAction', |
|
| 45 | - //'aweber' => 'FrmDefAweberAction', |
|
| 46 | - 'mailchimp' => 'FrmDefMlcmpAction', |
|
| 47 | - 'twilio' => 'FrmDefTwilioAction', |
|
| 48 | - 'highrise' => 'FrmDefHrsAction', |
|
| 49 | - ) ); |
|
| 50 | - |
|
| 51 | - include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php'); |
|
| 52 | - include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php'); |
|
| 53 | - |
|
| 54 | - foreach ( $action_classes as $action_class ) { |
|
| 55 | - self::$registered_actions->register($action_class); |
|
| 56 | - } |
|
| 57 | - } |
|
| 20 | + ), |
|
| 21 | + 'has_archive' => false, |
|
| 22 | + ) ); |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * post_content: json settings |
|
| 26 | + * menu_order: form id |
|
| 27 | + * post_excerpt: action type |
|
| 28 | + */ |
|
| 29 | + |
|
| 30 | + self::actions_init(); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + public static function actions_init() { |
|
| 34 | + self::$registered_actions = new Frm_Form_Action_Factory(); |
|
| 35 | + self::register_actions(); |
|
| 36 | + do_action( 'frm_form_actions_init' ); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + public static function register_actions() { |
|
| 40 | + $action_classes = apply_filters( 'frm_registered_form_actions', array( |
|
| 41 | + 'email' => 'FrmEmailAction', |
|
| 42 | + 'wppost' => 'FrmDefPostAction', |
|
| 43 | + 'register' => 'FrmDefRegAction', |
|
| 44 | + 'paypal' => 'FrmDefPayPalAction', |
|
| 45 | + //'aweber' => 'FrmDefAweberAction', |
|
| 46 | + 'mailchimp' => 'FrmDefMlcmpAction', |
|
| 47 | + 'twilio' => 'FrmDefTwilioAction', |
|
| 48 | + 'highrise' => 'FrmDefHrsAction', |
|
| 49 | + ) ); |
|
| 50 | + |
|
| 51 | + include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php'); |
|
| 52 | + include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php'); |
|
| 53 | + |
|
| 54 | + foreach ( $action_classes as $action_class ) { |
|
| 55 | + self::$registered_actions->register($action_class); |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | 59 | public static function get_form_actions( $action = 'all' ) { |
| 60 | - $temp_actions = self::$registered_actions; |
|
| 61 | - if ( empty($temp_actions) ) { |
|
| 62 | - self::actions_init(); |
|
| 63 | - $temp_actions = self::$registered_actions->actions; |
|
| 64 | - } else { |
|
| 65 | - $temp_actions = $temp_actions->actions; |
|
| 66 | - } |
|
| 60 | + $temp_actions = self::$registered_actions; |
|
| 61 | + if ( empty($temp_actions) ) { |
|
| 62 | + self::actions_init(); |
|
| 63 | + $temp_actions = self::$registered_actions->actions; |
|
| 64 | + } else { |
|
| 65 | + $temp_actions = $temp_actions->actions; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - $actions = array(); |
|
| 68 | + $actions = array(); |
|
| 69 | 69 | |
| 70 | - foreach ( $temp_actions as $a ) { |
|
| 71 | - if ( 'all' != $action && $a->id_base == $action ) { |
|
| 72 | - return $a; |
|
| 73 | - } |
|
| 70 | + foreach ( $temp_actions as $a ) { |
|
| 71 | + if ( 'all' != $action && $a->id_base == $action ) { |
|
| 72 | + return $a; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | 75 | $actions[ $a->id_base ] = $a; |
| 76 | - } |
|
| 77 | - unset( $temp_actions, $a ); |
|
| 78 | - |
|
| 79 | - $action_limit = 10; |
|
| 80 | - if ( count( $actions ) <= $action_limit ) { |
|
| 81 | - return $actions; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - // remove the last few inactive icons if there are too many |
|
| 85 | - $temp_actions = $actions; |
|
| 86 | - arsort( $temp_actions ); |
|
| 87 | - foreach ( $temp_actions as $type => $a ) { |
|
| 88 | - if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) { |
|
| 76 | + } |
|
| 77 | + unset( $temp_actions, $a ); |
|
| 78 | + |
|
| 79 | + $action_limit = 10; |
|
| 80 | + if ( count( $actions ) <= $action_limit ) { |
|
| 81 | + return $actions; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + // remove the last few inactive icons if there are too many |
|
| 85 | + $temp_actions = $actions; |
|
| 86 | + arsort( $temp_actions ); |
|
| 87 | + foreach ( $temp_actions as $type => $a ) { |
|
| 88 | + if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) { |
|
| 89 | 89 | unset( $actions[ $type ] ); |
| 90 | - if ( count( $actions ) <= $action_limit ) { |
|
| 91 | - break; |
|
| 92 | - } |
|
| 93 | - } |
|
| 94 | - unset( $type, $a ); |
|
| 95 | - } |
|
| 90 | + if ( count( $actions ) <= $action_limit ) { |
|
| 91 | + break; |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | + unset( $type, $a ); |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - return $actions; |
|
| 98 | - } |
|
| 97 | + return $actions; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | 101 | * @since 2.0 |
| 102 | 102 | */ |
| 103 | - public static function list_actions( $form, $values ) { |
|
| 104 | - if ( empty( $form ) ) { |
|
| 105 | - return; |
|
| 106 | - } |
|
| 103 | + public static function list_actions( $form, $values ) { |
|
| 104 | + if ( empty( $form ) ) { |
|
| 105 | + return; |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | 108 | /** |
| 109 | 109 | * use this hook to migrate old settings into a new action |
@@ -113,116 +113,116 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | $form_actions = FrmFormAction::get_action_for_form( $form->id ); |
| 115 | 115 | |
| 116 | - $action_controls = self::get_form_actions(); |
|
| 116 | + $action_controls = self::get_form_actions(); |
|
| 117 | 117 | |
| 118 | - $action_map = array(); |
|
| 118 | + $action_map = array(); |
|
| 119 | 119 | |
| 120 | 120 | foreach ( $action_controls as $key => $control ) { |
| 121 | - $action_map[ $control->id_base ] = $key; |
|
| 122 | - } |
|
| 121 | + $action_map[ $control->id_base ] = $key; |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - foreach ( $form_actions as $action ) { |
|
| 125 | - if ( ! isset( $action_map[ $action->post_excerpt ] ) ) { |
|
| 126 | - // don't try and show settings if action no longer exists |
|
| 127 | - continue; |
|
| 128 | - } |
|
| 124 | + foreach ( $form_actions as $action ) { |
|
| 125 | + if ( ! isset( $action_map[ $action->post_excerpt ] ) ) { |
|
| 126 | + // don't try and show settings if action no longer exists |
|
| 127 | + continue; |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values ); |
|
| 131 | - } |
|
| 132 | - } |
|
| 130 | + self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values ); |
|
| 131 | + } |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | 134 | public static function action_control( $form_action, $form, $action_key, $action_control, $values ) { |
| 135 | - $action_control->_set($action_key); |
|
| 136 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php'); |
|
| 137 | - } |
|
| 135 | + $action_control->_set($action_key); |
|
| 136 | + include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php'); |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | - public static function add_form_action() { |
|
| 139 | + public static function add_form_action() { |
|
| 140 | 140 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 141 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 141 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 142 | 142 | |
| 143 | - global $frm_vars; |
|
| 143 | + global $frm_vars; |
|
| 144 | 144 | |
| 145 | 145 | $action_key = absint( $_POST['list_id'] ); |
| 146 | - $action_type = sanitize_text_field( $_POST['type'] ); |
|
| 146 | + $action_type = sanitize_text_field( $_POST['type'] ); |
|
| 147 | 147 | |
| 148 | - $action_control = self::get_form_actions( $action_type ); |
|
| 149 | - $action_control->_set($action_key); |
|
| 148 | + $action_control = self::get_form_actions( $action_type ); |
|
| 149 | + $action_control->_set($action_key); |
|
| 150 | 150 | |
| 151 | - $form_id = absint( $_POST['form_id'] ); |
|
| 151 | + $form_id = absint( $_POST['form_id'] ); |
|
| 152 | 152 | |
| 153 | - $form_action = $action_control->prepare_new($form_id); |
|
| 153 | + $form_action = $action_control->prepare_new($form_id); |
|
| 154 | 154 | |
| 155 | - $values = array(); |
|
| 156 | - $form = self::fields_to_values($form_id, $values); |
|
| 155 | + $values = array(); |
|
| 156 | + $form = self::fields_to_values($form_id, $values); |
|
| 157 | 157 | |
| 158 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php'); |
|
| 159 | - wp_die(); |
|
| 160 | - } |
|
| 158 | + include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php'); |
|
| 159 | + wp_die(); |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - public static function fill_action() { |
|
| 162 | + public static function fill_action() { |
|
| 163 | 163 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 164 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 164 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 165 | 165 | |
| 166 | - $action_key = absint( $_POST['action_id'] ); |
|
| 167 | - $action_type = sanitize_text_field( $_POST['action_type'] ); |
|
| 166 | + $action_key = absint( $_POST['action_id'] ); |
|
| 167 | + $action_type = sanitize_text_field( $_POST['action_type'] ); |
|
| 168 | 168 | |
| 169 | - $action_control = self::get_form_actions( $action_type ); |
|
| 170 | - if ( empty($action_control) ) { |
|
| 171 | - wp_die(); |
|
| 172 | - } |
|
| 169 | + $action_control = self::get_form_actions( $action_type ); |
|
| 170 | + if ( empty($action_control) ) { |
|
| 171 | + wp_die(); |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | - $form_action = $action_control->get_single_action( $action_key ); |
|
| 174 | + $form_action = $action_control->get_single_action( $action_key ); |
|
| 175 | 175 | |
| 176 | - $values = array(); |
|
| 177 | - $form = self::fields_to_values($form_action->menu_order, $values); |
|
| 176 | + $values = array(); |
|
| 177 | + $form = self::fields_to_values($form_action->menu_order, $values); |
|
| 178 | 178 | |
| 179 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/_action_inside.php'); |
|
| 180 | - wp_die(); |
|
| 181 | - } |
|
| 179 | + include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/_action_inside.php'); |
|
| 180 | + wp_die(); |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | 183 | private static function fields_to_values( $form_id, array &$values ) { |
| 184 | - $form = FrmForm::getOne($form_id); |
|
| 184 | + $form = FrmForm::getOne($form_id); |
|
| 185 | 185 | |
| 186 | 186 | $values = array( 'fields' => array(), 'id' => $form->id ); |
| 187 | 187 | |
| 188 | - $fields = FrmField::get_all_for_form($form->id); |
|
| 189 | - foreach ( $fields as $k => $f ) { |
|
| 190 | - $f = (array) $f; |
|
| 191 | - $opts = (array) $f['field_options']; |
|
| 192 | - $f = array_merge($opts, $f); |
|
| 193 | - if ( ! isset( $f['post_field'] ) ) { |
|
| 194 | - $f['post_field'] = ''; |
|
| 195 | - } |
|
| 196 | - $values['fields'][] = $f; |
|
| 197 | - unset($k, $f); |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - return $form; |
|
| 201 | - } |
|
| 188 | + $fields = FrmField::get_all_for_form($form->id); |
|
| 189 | + foreach ( $fields as $k => $f ) { |
|
| 190 | + $f = (array) $f; |
|
| 191 | + $opts = (array) $f['field_options']; |
|
| 192 | + $f = array_merge($opts, $f); |
|
| 193 | + if ( ! isset( $f['post_field'] ) ) { |
|
| 194 | + $f['post_field'] = ''; |
|
| 195 | + } |
|
| 196 | + $values['fields'][] = $f; |
|
| 197 | + unset($k, $f); |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + return $form; |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | 203 | public static function update_settings( $form_id ) { |
| 204 | - global $wpdb; |
|
| 204 | + global $wpdb; |
|
| 205 | 205 | |
| 206 | - $registered_actions = self::$registered_actions->actions; |
|
| 206 | + $registered_actions = self::$registered_actions->actions; |
|
| 207 | 207 | |
| 208 | 208 | $old_actions = FrmDb::get_col( $wpdb->posts, array( 'post_type' => self::$action_post_type, 'menu_order' => $form_id ), 'ID' ); |
| 209 | - $new_actions = array(); |
|
| 209 | + $new_actions = array(); |
|
| 210 | 210 | |
| 211 | - foreach ( $registered_actions as $registered_action ) { |
|
| 212 | - $action_ids = $registered_action->update_callback($form_id); |
|
| 213 | - if ( ! empty( $action_ids ) ) { |
|
| 214 | - $new_actions[] = $action_ids; |
|
| 215 | - } |
|
| 216 | - } |
|
| 211 | + foreach ( $registered_actions as $registered_action ) { |
|
| 212 | + $action_ids = $registered_action->update_callback($form_id); |
|
| 213 | + if ( ! empty( $action_ids ) ) { |
|
| 214 | + $new_actions[] = $action_ids; |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - //Only use array_merge if there are new actions |
|
| 219 | - if ( ! empty( $new_actions ) ) { |
|
| 220 | - $new_actions = call_user_func_array( 'array_merge', $new_actions ); |
|
| 221 | - } |
|
| 222 | - $old_actions = array_diff( $old_actions, $new_actions ); |
|
| 218 | + //Only use array_merge if there are new actions |
|
| 219 | + if ( ! empty( $new_actions ) ) { |
|
| 220 | + $new_actions = call_user_func_array( 'array_merge', $new_actions ); |
|
| 221 | + } |
|
| 222 | + $old_actions = array_diff( $old_actions, $new_actions ); |
|
| 223 | 223 | |
| 224 | 224 | self::delete_missing_actions( $old_actions ); |
| 225 | - } |
|
| 225 | + } |
|
| 226 | 226 | |
| 227 | 227 | public static function delete_missing_actions( $old_actions ) { |
| 228 | 228 | if ( ! empty( $old_actions ) ) { |
@@ -237,36 +237,36 @@ discard block |
||
| 237 | 237 | self::trigger_actions( 'create', $form_id, $entry_id, 'all', $args ); |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - /** |
|
| 241 | - * @param string $event |
|
| 242 | - */ |
|
| 240 | + /** |
|
| 241 | + * @param string $event |
|
| 242 | + */ |
|
| 243 | 243 | public static function trigger_actions( $event, $form, $entry, $type = 'all', $args = array() ) { |
| 244 | 244 | $form_actions = FrmFormAction::get_action_for_form( ( is_object( $form ) ? $form->id : $form ), $type ); |
| 245 | 245 | |
| 246 | 246 | if ( empty( $form_actions ) ) { |
| 247 | - return; |
|
| 248 | - } |
|
| 247 | + return; |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | 250 | FrmForm::maybe_get_form( $form ); |
| 251 | 251 | |
| 252 | - $link_settings = self::get_form_actions( $type ); |
|
| 253 | - if ( 'all' != $type ) { |
|
| 254 | - $link_settings = array( $type => $link_settings ); |
|
| 255 | - } |
|
| 252 | + $link_settings = self::get_form_actions( $type ); |
|
| 253 | + if ( 'all' != $type ) { |
|
| 254 | + $link_settings = array( $type => $link_settings ); |
|
| 255 | + } |
|
| 256 | 256 | |
| 257 | - $stored_actions = $action_priority = array(); |
|
| 257 | + $stored_actions = $action_priority = array(); |
|
| 258 | 258 | |
| 259 | 259 | $importing = in_array( $event, array( 'create', 'update' ) ) && defined( 'WP_IMPORTING' ) && WP_IMPORTING; |
| 260 | 260 | |
| 261 | - foreach ( $form_actions as $action ) { |
|
| 261 | + foreach ( $form_actions as $action ) { |
|
| 262 | 262 | $trigger_on_import = $importing && in_array( 'import', $action->post_content['event'] ); |
| 263 | 263 | if ( ! in_array( $event, $action->post_content['event'] ) && ! $trigger_on_import ) { |
| 264 | - continue; |
|
| 265 | - } |
|
| 264 | + continue; |
|
| 265 | + } |
|
| 266 | 266 | |
| 267 | - if ( ! is_object( $entry ) ) { |
|
| 268 | - $entry = FrmEntry::getOne( $entry, true ); |
|
| 269 | - } |
|
| 267 | + if ( ! is_object( $entry ) ) { |
|
| 268 | + $entry = FrmEntry::getOne( $entry, true ); |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | 271 | if ( empty( $entry ) || $entry->is_draft ) { |
| 272 | 272 | continue; |
@@ -275,66 +275,66 @@ discard block |
||
| 275 | 275 | $child_entry = ( ( $form && is_numeric( $form->parent_form_id ) && $form->parent_form_id ) || ( $entry && ( $entry->form_id != $form->id || $entry->parent_item_id ) ) || ( isset( $args['is_child'] ) && $args['is_child'] ) ); |
| 276 | 276 | |
| 277 | 277 | if ( $child_entry ) { |
| 278 | - //don't trigger actions for sub forms |
|
| 279 | - continue; |
|
| 280 | - } |
|
| 278 | + //don't trigger actions for sub forms |
|
| 279 | + continue; |
|
| 280 | + } |
|
| 281 | 281 | |
| 282 | - // check conditional logic |
|
| 282 | + // check conditional logic |
|
| 283 | 283 | $stop = FrmFormAction::action_conditions_met( $action, $entry ); |
| 284 | - if ( $stop ) { |
|
| 285 | - continue; |
|
| 286 | - } |
|
| 284 | + if ( $stop ) { |
|
| 285 | + continue; |
|
| 286 | + } |
|
| 287 | 287 | |
| 288 | - // store actions so they can be triggered with the correct priority |
|
| 289 | - $stored_actions[ $action->ID ] = $action; |
|
| 290 | - $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority']; |
|
| 288 | + // store actions so they can be triggered with the correct priority |
|
| 289 | + $stored_actions[ $action->ID ] = $action; |
|
| 290 | + $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority']; |
|
| 291 | 291 | |
| 292 | - unset($action); |
|
| 293 | - } |
|
| 292 | + unset($action); |
|
| 293 | + } |
|
| 294 | 294 | |
| 295 | - if ( ! empty( $stored_actions ) ) { |
|
| 296 | - asort($action_priority); |
|
| 295 | + if ( ! empty( $stored_actions ) ) { |
|
| 296 | + asort($action_priority); |
|
| 297 | 297 | |
| 298 | - // make sure hooks are loaded |
|
| 299 | - new FrmNotification(); |
|
| 298 | + // make sure hooks are loaded |
|
| 299 | + new FrmNotification(); |
|
| 300 | 300 | |
| 301 | - foreach ( $action_priority as $action_id => $priority ) { |
|
| 302 | - $action = $stored_actions[ $action_id ]; |
|
| 303 | - do_action('frm_trigger_'. $action->post_excerpt .'_action', $action, $entry, $form, $event); |
|
| 304 | - do_action('frm_trigger_'. $action->post_excerpt .'_'. $event .'_action', $action, $entry, $form); |
|
| 301 | + foreach ( $action_priority as $action_id => $priority ) { |
|
| 302 | + $action = $stored_actions[ $action_id ]; |
|
| 303 | + do_action('frm_trigger_'. $action->post_excerpt .'_action', $action, $entry, $form, $event); |
|
| 304 | + do_action('frm_trigger_'. $action->post_excerpt .'_'. $event .'_action', $action, $entry, $form); |
|
| 305 | 305 | |
| 306 | - // If post is created, get updated $entry object |
|
| 307 | - if ( $action->post_excerpt == 'wppost' && $event == 'create' ) { |
|
| 308 | - $entry = FrmEntry::getOne($entry->id, true); |
|
| 309 | - } |
|
| 310 | - } |
|
| 311 | - } |
|
| 312 | - } |
|
| 306 | + // If post is created, get updated $entry object |
|
| 307 | + if ( $action->post_excerpt == 'wppost' && $event == 'create' ) { |
|
| 308 | + $entry = FrmEntry::getOne($entry->id, true); |
|
| 309 | + } |
|
| 310 | + } |
|
| 311 | + } |
|
| 312 | + } |
|
| 313 | 313 | |
| 314 | 314 | public static function duplicate_form_actions( $form_id, $values, $args = array() ) { |
| 315 | - if ( ! isset($args['old_id']) || empty($args['old_id']) ) { |
|
| 316 | - // continue if we know which actions to copy |
|
| 317 | - return; |
|
| 318 | - } |
|
| 315 | + if ( ! isset($args['old_id']) || empty($args['old_id']) ) { |
|
| 316 | + // continue if we know which actions to copy |
|
| 317 | + return; |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | - $action_controls = self::get_form_actions( ); |
|
| 320 | + $action_controls = self::get_form_actions( ); |
|
| 321 | 321 | |
| 322 | - foreach ( $action_controls as $action_control ) { |
|
| 323 | - $action_control->duplicate_form_actions( $form_id, $args['old_id'] ); |
|
| 324 | - unset( $action_control ); |
|
| 325 | - } |
|
| 326 | - } |
|
| 322 | + foreach ( $action_controls as $action_control ) { |
|
| 323 | + $action_control->duplicate_form_actions( $form_id, $args['old_id'] ); |
|
| 324 | + unset( $action_control ); |
|
| 325 | + } |
|
| 326 | + } |
|
| 327 | 327 | |
| 328 | - public static function limit_by_type( $where ) { |
|
| 329 | - global $frm_vars, $wpdb; |
|
| 328 | + public static function limit_by_type( $where ) { |
|
| 329 | + global $frm_vars, $wpdb; |
|
| 330 | 330 | |
| 331 | - if ( ! isset( $frm_vars['action_type'] ) ) { |
|
| 332 | - return $where; |
|
| 333 | - } |
|
| 331 | + if ( ! isset( $frm_vars['action_type'] ) ) { |
|
| 332 | + return $where; |
|
| 333 | + } |
|
| 334 | 334 | |
| 335 | - $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] ); |
|
| 336 | - return $where; |
|
| 337 | - } |
|
| 335 | + $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] ); |
|
| 336 | + return $where; |
|
| 337 | + } |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | foreach ( $keys as $key ) { |
| 362 | 362 | // don't register new action if old action with the same id is already registered |
| 363 | 363 | if ( ! isset( $this->actions[ $key ] ) ) { |
| 364 | - $this->actions[ $key ]->_register(); |
|
| 364 | + $this->actions[ $key ]->_register(); |
|
| 365 | 365 | } |
| 366 | 366 | } |
| 367 | 367 | } |
@@ -48,17 +48,17 @@ discard block |
||
| 48 | 48 | 'highrise' => 'FrmDefHrsAction', |
| 49 | 49 | ) ); |
| 50 | 50 | |
| 51 | - include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php'); |
|
| 52 | - include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php'); |
|
| 51 | + include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php' ); |
|
| 52 | + include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php' ); |
|
| 53 | 53 | |
| 54 | 54 | foreach ( $action_classes as $action_class ) { |
| 55 | - self::$registered_actions->register($action_class); |
|
| 55 | + self::$registered_actions->register( $action_class ); |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | public static function get_form_actions( $action = 'all' ) { |
| 60 | 60 | $temp_actions = self::$registered_actions; |
| 61 | - if ( empty($temp_actions) ) { |
|
| 61 | + if ( empty( $temp_actions ) ) { |
|
| 62 | 62 | self::actions_init(); |
| 63 | 63 | $temp_actions = self::$registered_actions->actions; |
| 64 | 64 | } else { |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | return $a; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - $actions[ $a->id_base ] = $a; |
|
| 75 | + $actions[$a->id_base] = $a; |
|
| 76 | 76 | } |
| 77 | 77 | unset( $temp_actions, $a ); |
| 78 | 78 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | arsort( $temp_actions ); |
| 87 | 87 | foreach ( $temp_actions as $type => $a ) { |
| 88 | 88 | if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) { |
| 89 | - unset( $actions[ $type ] ); |
|
| 89 | + unset( $actions[$type] ); |
|
| 90 | 90 | if ( count( $actions ) <= $action_limit ) { |
| 91 | 91 | break; |
| 92 | 92 | } |
@@ -118,26 +118,26 @@ discard block |
||
| 118 | 118 | $action_map = array(); |
| 119 | 119 | |
| 120 | 120 | foreach ( $action_controls as $key => $control ) { |
| 121 | - $action_map[ $control->id_base ] = $key; |
|
| 121 | + $action_map[$control->id_base] = $key; |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | foreach ( $form_actions as $action ) { |
| 125 | - if ( ! isset( $action_map[ $action->post_excerpt ] ) ) { |
|
| 125 | + if ( ! isset( $action_map[$action->post_excerpt] ) ) { |
|
| 126 | 126 | // don't try and show settings if action no longer exists |
| 127 | 127 | continue; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values ); |
|
| 130 | + self::action_control( $action, $form, $action->ID, $action_controls[$action_map[$action->post_excerpt]], $values ); |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | public static function action_control( $form_action, $form, $action_key, $action_control, $values ) { |
| 135 | - $action_control->_set($action_key); |
|
| 136 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php'); |
|
| 135 | + $action_control->_set( $action_key ); |
|
| 136 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | public static function add_form_action() { |
| 140 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 140 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 141 | 141 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 142 | 142 | |
| 143 | 143 | global $frm_vars; |
@@ -146,55 +146,55 @@ discard block |
||
| 146 | 146 | $action_type = sanitize_text_field( $_POST['type'] ); |
| 147 | 147 | |
| 148 | 148 | $action_control = self::get_form_actions( $action_type ); |
| 149 | - $action_control->_set($action_key); |
|
| 149 | + $action_control->_set( $action_key ); |
|
| 150 | 150 | |
| 151 | 151 | $form_id = absint( $_POST['form_id'] ); |
| 152 | 152 | |
| 153 | - $form_action = $action_control->prepare_new($form_id); |
|
| 153 | + $form_action = $action_control->prepare_new( $form_id ); |
|
| 154 | 154 | |
| 155 | 155 | $values = array(); |
| 156 | - $form = self::fields_to_values($form_id, $values); |
|
| 156 | + $form = self::fields_to_values( $form_id, $values ); |
|
| 157 | 157 | |
| 158 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php'); |
|
| 158 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); |
|
| 159 | 159 | wp_die(); |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | public static function fill_action() { |
| 163 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 163 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 164 | 164 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 165 | 165 | |
| 166 | 166 | $action_key = absint( $_POST['action_id'] ); |
| 167 | 167 | $action_type = sanitize_text_field( $_POST['action_type'] ); |
| 168 | 168 | |
| 169 | 169 | $action_control = self::get_form_actions( $action_type ); |
| 170 | - if ( empty($action_control) ) { |
|
| 170 | + if ( empty( $action_control ) ) { |
|
| 171 | 171 | wp_die(); |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | $form_action = $action_control->get_single_action( $action_key ); |
| 175 | 175 | |
| 176 | 176 | $values = array(); |
| 177 | - $form = self::fields_to_values($form_action->menu_order, $values); |
|
| 177 | + $form = self::fields_to_values( $form_action->menu_order, $values ); |
|
| 178 | 178 | |
| 179 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/_action_inside.php'); |
|
| 179 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php' ); |
|
| 180 | 180 | wp_die(); |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | private static function fields_to_values( $form_id, array &$values ) { |
| 184 | - $form = FrmForm::getOne($form_id); |
|
| 184 | + $form = FrmForm::getOne( $form_id ); |
|
| 185 | 185 | |
| 186 | 186 | $values = array( 'fields' => array(), 'id' => $form->id ); |
| 187 | 187 | |
| 188 | - $fields = FrmField::get_all_for_form($form->id); |
|
| 188 | + $fields = FrmField::get_all_for_form( $form->id ); |
|
| 189 | 189 | foreach ( $fields as $k => $f ) { |
| 190 | 190 | $f = (array) $f; |
| 191 | 191 | $opts = (array) $f['field_options']; |
| 192 | - $f = array_merge($opts, $f); |
|
| 192 | + $f = array_merge( $opts, $f ); |
|
| 193 | 193 | if ( ! isset( $f['post_field'] ) ) { |
| 194 | 194 | $f['post_field'] = ''; |
| 195 | 195 | } |
| 196 | 196 | $values['fields'][] = $f; |
| 197 | - unset($k, $f); |
|
| 197 | + unset( $k, $f ); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | return $form; |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | $new_actions = array(); |
| 210 | 210 | |
| 211 | 211 | foreach ( $registered_actions as $registered_action ) { |
| 212 | - $action_ids = $registered_action->update_callback($form_id); |
|
| 212 | + $action_ids = $registered_action->update_callback( $form_id ); |
|
| 213 | 213 | if ( ! empty( $action_ids ) ) { |
| 214 | 214 | $new_actions[] = $action_ids; |
| 215 | 215 | } |
@@ -286,33 +286,33 @@ discard block |
||
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | // store actions so they can be triggered with the correct priority |
| 289 | - $stored_actions[ $action->ID ] = $action; |
|
| 290 | - $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority']; |
|
| 289 | + $stored_actions[$action->ID] = $action; |
|
| 290 | + $action_priority[$action->ID] = $link_settings[$action->post_excerpt]->action_options['priority']; |
|
| 291 | 291 | |
| 292 | - unset($action); |
|
| 292 | + unset( $action ); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | if ( ! empty( $stored_actions ) ) { |
| 296 | - asort($action_priority); |
|
| 296 | + asort( $action_priority ); |
|
| 297 | 297 | |
| 298 | 298 | // make sure hooks are loaded |
| 299 | 299 | new FrmNotification(); |
| 300 | 300 | |
| 301 | 301 | foreach ( $action_priority as $action_id => $priority ) { |
| 302 | - $action = $stored_actions[ $action_id ]; |
|
| 303 | - do_action('frm_trigger_'. $action->post_excerpt .'_action', $action, $entry, $form, $event); |
|
| 304 | - do_action('frm_trigger_'. $action->post_excerpt .'_'. $event .'_action', $action, $entry, $form); |
|
| 302 | + $action = $stored_actions[$action_id]; |
|
| 303 | + do_action( 'frm_trigger_' . $action->post_excerpt . '_action', $action, $entry, $form, $event ); |
|
| 304 | + do_action( 'frm_trigger_' . $action->post_excerpt . '_' . $event . '_action', $action, $entry, $form ); |
|
| 305 | 305 | |
| 306 | 306 | // If post is created, get updated $entry object |
| 307 | 307 | if ( $action->post_excerpt == 'wppost' && $event == 'create' ) { |
| 308 | - $entry = FrmEntry::getOne($entry->id, true); |
|
| 308 | + $entry = FrmEntry::getOne( $entry->id, true ); |
|
| 309 | 309 | } |
| 310 | 310 | } |
| 311 | 311 | } |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | public static function duplicate_form_actions( $form_id, $values, $args = array() ) { |
| 315 | - if ( ! isset($args['old_id']) || empty($args['old_id']) ) { |
|
| 315 | + if ( ! isset( $args['old_id'] ) || empty( $args['old_id'] ) ) { |
|
| 316 | 316 | // continue if we know which actions to copy |
| 317 | 317 | return; |
| 318 | 318 | } |
@@ -346,22 +346,22 @@ discard block |
||
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | public function register( $action_class ) { |
| 349 | - $this->actions[ $action_class ] = new $action_class(); |
|
| 349 | + $this->actions[$action_class] = new $action_class(); |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | public function unregister( $action_class ) { |
| 353 | - if ( isset( $this->actions[ $action_class ] ) ) { |
|
| 354 | - unset($this->actions[ $action_class ]); |
|
| 353 | + if ( isset( $this->actions[$action_class] ) ) { |
|
| 354 | + unset( $this->actions[$action_class] ); |
|
| 355 | 355 | } |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | public function _register_actions() { |
| 359 | - $keys = array_keys($this->actions); |
|
| 359 | + $keys = array_keys( $this->actions ); |
|
| 360 | 360 | |
| 361 | 361 | foreach ( $keys as $key ) { |
| 362 | 362 | // don't register new action if old action with the same id is already registered |
| 363 | - if ( ! isset( $this->actions[ $key ] ) ) { |
|
| 364 | - $this->actions[ $key ]->_register(); |
|
| 363 | + if ( ! isset( $this->actions[$key] ) ) { |
|
| 364 | + $this->actions[$key]->_register(); |
|
| 365 | 365 | } |
| 366 | 366 | } |
| 367 | 367 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | $tip = FrmTipsHelper::get_banner_tip(); |
| 134 | 134 | ?> |
| 135 | 135 | <div class="update-nag frm-update-to-pro"> |
| 136 | - <?php echo FrmAppHelper::kses( $tip['tip'] ) ?> <span><?php echo FrmAppHelper::kses( $tip['call'] ) ?></span> <a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidablepro.com?banner=1&tip='. absint( $tip['num'] ) ) ) ?>" class="button">Upgrade to Pro</a> |
|
| 136 | + <?php echo FrmAppHelper::kses( $tip['tip'] ) ?> <span><?php echo FrmAppHelper::kses( $tip['call'] ) ?></span> <a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidablepro.com?banner=1&tip=' . absint( $tip['num'] ) ) ) ?>" class="button">Upgrade to Pro</a> |
|
| 137 | 137 | </div> |
| 138 | 138 | <?php |
| 139 | 139 | } |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | public static function uninstall() { |
| 384 | - FrmAppHelper::permission_check('administrator'); |
|
| 384 | + FrmAppHelper::permission_check( 'administrator' ); |
|
| 385 | 385 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 386 | 386 | |
| 387 | 387 | $frmdb = new FrmDb(); |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | public static function deauthorize() { |
| 419 | - FrmAppHelper::permission_check('frm_change_settings'); |
|
| 419 | + FrmAppHelper::permission_check( 'frm_change_settings' ); |
|
| 420 | 420 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 421 | 421 | |
| 422 | 422 | delete_option( 'frmpro-credentials' ); |
@@ -3,14 +3,14 @@ discard block |
||
| 3 | 3 | class FrmAppController { |
| 4 | 4 | |
| 5 | 5 | public static function menu() { |
| 6 | - FrmAppHelper::maybe_add_permissions(); |
|
| 7 | - if ( ! current_user_can( 'frm_view_forms' ) ) { |
|
| 8 | - return; |
|
| 9 | - } |
|
| 6 | + FrmAppHelper::maybe_add_permissions(); |
|
| 7 | + if ( ! current_user_can( 'frm_view_forms' ) ) { |
|
| 8 | + return; |
|
| 9 | + } |
|
| 10 | 10 | |
| 11 | 11 | $menu_name = FrmAppHelper::get_menu_name(); |
| 12 | 12 | add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', FrmAppHelper::plugin_url() . '/images/form_16.png', self::get_menu_position() ); |
| 13 | - } |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | 15 | private static function get_menu_position() { |
| 16 | 16 | $count = count( get_post_types( array( 'show_ui' => true, '_builtin' => false, 'show_in_menu' => true ) ) ); |
@@ -19,39 +19,39 @@ discard block |
||
| 19 | 19 | return $pos; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - public static function load_wp_admin_style() { |
|
| 23 | - FrmAppHelper::load_font_style(); |
|
| 24 | - } |
|
| 22 | + public static function load_wp_admin_style() { |
|
| 23 | + FrmAppHelper::load_font_style(); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | 26 | public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) { |
| 27 | - global $pagenow, $frm_vars; |
|
| 27 | + global $pagenow, $frm_vars; |
|
| 28 | 28 | |
| 29 | 29 | $show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' ); |
| 30 | - if ( empty( $show_nav ) ) { |
|
| 31 | - return; |
|
| 32 | - } |
|
| 30 | + if ( empty( $show_nav ) ) { |
|
| 31 | + return; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | 34 | $current_page = isset( $_GET['page'] ) ? FrmAppHelper::simple_get( 'page', 'sanitize_title' ) : FrmAppHelper::simple_get( 'post_type', 'sanitize_title', 'None' ); |
| 35 | 35 | if ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) { |
| 36 | 36 | $current_page = 'frm_display'; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - if ( $form ) { |
|
| 39 | + if ( $form ) { |
|
| 40 | 40 | FrmForm::maybe_get_form( $form ); |
| 41 | 41 | |
| 42 | - if ( is_object( $form ) ) { |
|
| 43 | - $id = $form->id; |
|
| 44 | - } |
|
| 45 | - } |
|
| 42 | + if ( is_object( $form ) ) { |
|
| 43 | + $id = $form->id; |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - if ( ! isset( $id ) ) { |
|
| 48 | - $form = $id = false; |
|
| 49 | - } |
|
| 47 | + if ( ! isset( $id ) ) { |
|
| 48 | + $form = $id = false; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | 51 | $nav_items = self::get_form_nav_items( $id ); |
| 52 | 52 | |
| 53 | - include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' ); |
|
| 54 | - } |
|
| 53 | + include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' ); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | 56 | private static function get_form_nav_items( $id ) { |
| 57 | 57 | $nav_items = array( |
@@ -82,28 +82,28 @@ discard block |
||
| 82 | 82 | return $nav_items; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - // Adds a settings link to the plugins page |
|
| 86 | - public static function settings_link( $links ) { |
|
| 85 | + // Adds a settings link to the plugins page |
|
| 86 | + public static function settings_link( $links ) { |
|
| 87 | 87 | $settings = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings' ) ) . '">' . __( 'Settings', 'formidable' ) . '</a>'; |
| 88 | - array_unshift( $links, $settings ); |
|
| 88 | + array_unshift( $links, $settings ); |
|
| 89 | 89 | |
| 90 | - return $links; |
|
| 91 | - } |
|
| 90 | + return $links; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - public static function pro_get_started_headline() { |
|
| 93 | + public static function pro_get_started_headline() { |
|
| 94 | 94 | self::maybe_show_upgrade_bar(); |
| 95 | 95 | |
| 96 | - // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message |
|
| 97 | - if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) { |
|
| 98 | - return; |
|
| 99 | - } |
|
| 96 | + // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message |
|
| 97 | + if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) { |
|
| 98 | + return; |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | 101 | if ( get_site_option( 'frmpro-authorized' ) && ! file_exists( FrmAppHelper::plugin_path() . '/pro/formidable-pro.php' ) ) { |
| 102 | - FrmAppHelper::load_admin_wide_js(); |
|
| 102 | + FrmAppHelper::load_admin_wide_js(); |
|
| 103 | 103 | |
| 104 | - // user is authorized, but running free version |
|
| 105 | - $inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/'; |
|
| 106 | - ?> |
|
| 104 | + // user is authorized, but running free version |
|
| 105 | + $inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/'; |
|
| 106 | + ?> |
|
| 107 | 107 | <div class="error" class="frm_previous_install"> |
| 108 | 108 | <?php |
| 109 | 109 | echo wp_kses_post( apply_filters( 'frm_pro_update_msg', |
@@ -115,8 +115,8 @@ discard block |
||
| 115 | 115 | ) ); ?> |
| 116 | 116 | </div> |
| 117 | 117 | <?php |
| 118 | - } |
|
| 119 | - } |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | 121 | private static function maybe_show_upgrade_bar() { |
| 122 | 122 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | } |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - public static function admin_js() { |
|
| 219 | + public static function admin_js() { |
|
| 220 | 220 | $version = FrmAppHelper::plugin_version(); |
| 221 | 221 | FrmAppHelper::load_admin_wide_js( false ); |
| 222 | 222 | |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | 'bootstrap_tooltip', 'bootstrap-multiselect', |
| 228 | 228 | ), $version, true ); |
| 229 | 229 | wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version ); |
| 230 | - wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' ); |
|
| 230 | + wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' ); |
|
| 231 | 231 | |
| 232 | 232 | // load multselect js |
| 233 | 233 | wp_register_script( 'bootstrap-multiselect', FrmAppHelper::plugin_url() . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip' ), '0.9.8', true ); |
@@ -238,78 +238,78 @@ discard block |
||
| 238 | 238 | global $pagenow; |
| 239 | 239 | if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow == 'edit.php' && $post_type == 'frm_display' ) ) { |
| 240 | 240 | |
| 241 | - wp_enqueue_script( 'admin-widgets' ); |
|
| 242 | - wp_enqueue_style( 'widgets' ); |
|
| 243 | - wp_enqueue_script( 'formidable' ); |
|
| 244 | - wp_enqueue_script( 'formidable_admin' ); |
|
| 241 | + wp_enqueue_script( 'admin-widgets' ); |
|
| 242 | + wp_enqueue_style( 'widgets' ); |
|
| 243 | + wp_enqueue_script( 'formidable' ); |
|
| 244 | + wp_enqueue_script( 'formidable_admin' ); |
|
| 245 | 245 | FrmAppHelper::localize_script( 'admin' ); |
| 246 | 246 | |
| 247 | - wp_enqueue_style( 'formidable-admin' ); |
|
| 248 | - add_thickbox(); |
|
| 247 | + wp_enqueue_style( 'formidable-admin' ); |
|
| 248 | + add_thickbox(); |
|
| 249 | 249 | |
| 250 | - wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' ); |
|
| 250 | + wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' ); |
|
| 251 | 251 | |
| 252 | - } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) { |
|
| 253 | - if ( isset( $_REQUEST['post_type'] ) ) { |
|
| 254 | - $post_type = sanitize_title( $_REQUEST['post_type'] ); |
|
| 252 | + } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) { |
|
| 253 | + if ( isset( $_REQUEST['post_type'] ) ) { |
|
| 254 | + $post_type = sanitize_title( $_REQUEST['post_type'] ); |
|
| 255 | 255 | } else if ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) { |
| 256 | 256 | $post = get_post( absint( $_REQUEST['post'] ) ); |
| 257 | - if ( ! $post ) { |
|
| 258 | - return; |
|
| 259 | - } |
|
| 260 | - $post_type = $post->post_type; |
|
| 261 | - } else { |
|
| 262 | - return; |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - if ( $post_type == 'frm_display' ) { |
|
| 266 | - wp_enqueue_script( 'jquery-ui-draggable' ); |
|
| 267 | - wp_enqueue_script( 'formidable_admin' ); |
|
| 268 | - wp_enqueue_style( 'formidable-admin' ); |
|
| 257 | + if ( ! $post ) { |
|
| 258 | + return; |
|
| 259 | + } |
|
| 260 | + $post_type = $post->post_type; |
|
| 261 | + } else { |
|
| 262 | + return; |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + if ( $post_type == 'frm_display' ) { |
|
| 266 | + wp_enqueue_script( 'jquery-ui-draggable' ); |
|
| 267 | + wp_enqueue_script( 'formidable_admin' ); |
|
| 268 | + wp_enqueue_style( 'formidable-admin' ); |
|
| 269 | 269 | FrmAppHelper::localize_script( 'admin' ); |
| 270 | - } |
|
| 271 | - } else if ( $pagenow == 'widgets.php' ) { |
|
| 272 | - FrmAppHelper::load_admin_wide_js(); |
|
| 273 | - } |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - public static function wp_admin_body_class( $classes ) { |
|
| 277 | - global $wp_version; |
|
| 278 | - //we need this class everywhere in the admin for the menu |
|
| 279 | - if ( version_compare( $wp_version, '3.7.2', '>' ) ) { |
|
| 280 | - $classes .= ' frm_38_trigger'; |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - return $classes; |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - public static function load_lang() { |
|
| 287 | - load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' ); |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - /** |
|
| 291 | - * Filter shortcodes in text widgets |
|
| 292 | - */ |
|
| 293 | - public static function widget_text_filter( $content ) { |
|
| 294 | - $regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/'; |
|
| 295 | - return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content ); |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - public static function widget_text_filter_callback( $matches ) { |
|
| 299 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::widget_text_filter_callback' ); |
|
| 300 | - return FrmAppHelper::widget_text_filter_callback( $matches ); |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - public static function front_head() { |
|
| 304 | - if ( is_multisite() ) { |
|
| 305 | - $old_db_version = get_option( 'frm_db_version' ); |
|
| 306 | - $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false; |
|
| 307 | - if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) || |
|
| 308 | - ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) { |
|
| 309 | - self::install( $old_db_version ); |
|
| 310 | - } |
|
| 311 | - } |
|
| 312 | - } |
|
| 270 | + } |
|
| 271 | + } else if ( $pagenow == 'widgets.php' ) { |
|
| 272 | + FrmAppHelper::load_admin_wide_js(); |
|
| 273 | + } |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + public static function wp_admin_body_class( $classes ) { |
|
| 277 | + global $wp_version; |
|
| 278 | + //we need this class everywhere in the admin for the menu |
|
| 279 | + if ( version_compare( $wp_version, '3.7.2', '>' ) ) { |
|
| 280 | + $classes .= ' frm_38_trigger'; |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + return $classes; |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + public static function load_lang() { |
|
| 287 | + load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' ); |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + /** |
|
| 291 | + * Filter shortcodes in text widgets |
|
| 292 | + */ |
|
| 293 | + public static function widget_text_filter( $content ) { |
|
| 294 | + $regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/'; |
|
| 295 | + return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content ); |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + public static function widget_text_filter_callback( $matches ) { |
|
| 299 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::widget_text_filter_callback' ); |
|
| 300 | + return FrmAppHelper::widget_text_filter_callback( $matches ); |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + public static function front_head() { |
|
| 304 | + if ( is_multisite() ) { |
|
| 305 | + $old_db_version = get_option( 'frm_db_version' ); |
|
| 306 | + $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false; |
|
| 307 | + if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) || |
|
| 308 | + ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) { |
|
| 309 | + self::install( $old_db_version ); |
|
| 310 | + } |
|
| 311 | + } |
|
| 312 | + } |
|
| 313 | 313 | |
| 314 | 314 | public static function localize_script( $location ) { |
| 315 | 315 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmAppHelper::localize_script' ); |
@@ -369,20 +369,20 @@ discard block |
||
| 369 | 369 | wp_die(); |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - public static function activation_install() { |
|
| 373 | - FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' ); |
|
| 374 | - FrmFormActionsController::actions_init(); |
|
| 375 | - self::install(); |
|
| 376 | - } |
|
| 372 | + public static function activation_install() { |
|
| 373 | + FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' ); |
|
| 374 | + FrmFormActionsController::actions_init(); |
|
| 375 | + self::install(); |
|
| 376 | + } |
|
| 377 | 377 | |
| 378 | - public static function install( $old_db_version = false ) { |
|
| 379 | - $frmdb = new FrmDb(); |
|
| 380 | - $frmdb->upgrade( $old_db_version ); |
|
| 381 | - } |
|
| 378 | + public static function install( $old_db_version = false ) { |
|
| 379 | + $frmdb = new FrmDb(); |
|
| 380 | + $frmdb->upgrade( $old_db_version ); |
|
| 381 | + } |
|
| 382 | 382 | |
| 383 | - public static function uninstall() { |
|
| 383 | + public static function uninstall() { |
|
| 384 | 384 | FrmAppHelper::permission_check('administrator'); |
| 385 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 385 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 386 | 386 | |
| 387 | 387 | $frmdb = new FrmDb(); |
| 388 | 388 | $frmdb->uninstall(); |
@@ -391,48 +391,48 @@ discard block |
||
| 391 | 391 | deactivate_plugins( FrmAppHelper::plugin_folder() . '/formidable.php', false, false ); |
| 392 | 392 | echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) ); |
| 393 | 393 | |
| 394 | - wp_die(); |
|
| 395 | - } |
|
| 394 | + wp_die(); |
|
| 395 | + } |
|
| 396 | 396 | |
| 397 | - public static function drop_tables( $tables ) { |
|
| 398 | - global $wpdb; |
|
| 399 | - $tables[] = $wpdb->prefix . 'frm_fields'; |
|
| 400 | - $tables[] = $wpdb->prefix . 'frm_forms'; |
|
| 401 | - $tables[] = $wpdb->prefix . 'frm_items'; |
|
| 402 | - $tables[] = $wpdb->prefix . 'frm_item_metas'; |
|
| 403 | - return $tables; |
|
| 404 | - } |
|
| 397 | + public static function drop_tables( $tables ) { |
|
| 398 | + global $wpdb; |
|
| 399 | + $tables[] = $wpdb->prefix . 'frm_fields'; |
|
| 400 | + $tables[] = $wpdb->prefix . 'frm_forms'; |
|
| 401 | + $tables[] = $wpdb->prefix . 'frm_items'; |
|
| 402 | + $tables[] = $wpdb->prefix . 'frm_item_metas'; |
|
| 403 | + return $tables; |
|
| 404 | + } |
|
| 405 | 405 | |
| 406 | - // Routes for wordpress pages -- we're just replacing content here folks. |
|
| 407 | - public static function page_route( $content ) { |
|
| 408 | - global $post; |
|
| 406 | + // Routes for wordpress pages -- we're just replacing content here folks. |
|
| 407 | + public static function page_route( $content ) { |
|
| 408 | + global $post; |
|
| 409 | 409 | |
| 410 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 411 | - if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) { |
|
| 412 | - $content = FrmFormsController::page_preview(); |
|
| 413 | - } |
|
| 410 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 411 | + if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) { |
|
| 412 | + $content = FrmFormsController::page_preview(); |
|
| 413 | + } |
|
| 414 | 414 | |
| 415 | - return $content; |
|
| 416 | - } |
|
| 415 | + return $content; |
|
| 416 | + } |
|
| 417 | 417 | |
| 418 | - public static function deauthorize() { |
|
| 418 | + public static function deauthorize() { |
|
| 419 | 419 | FrmAppHelper::permission_check('frm_change_settings'); |
| 420 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 421 | - |
|
| 422 | - delete_option( 'frmpro-credentials' ); |
|
| 423 | - delete_option( 'frmpro-authorized' ); |
|
| 424 | - delete_site_option( 'frmpro-credentials' ); |
|
| 425 | - delete_site_option( 'frmpro-authorized' ); |
|
| 426 | - wp_die(); |
|
| 427 | - } |
|
| 428 | - |
|
| 429 | - public static function get_form_shortcode( $atts ) { |
|
| 430 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
|
| 431 | - return FrmFormsController::get_form_shortcode( $atts ); |
|
| 432 | - } |
|
| 433 | - |
|
| 434 | - public static function get_postbox_class() { |
|
| 435 | - _deprecated_function( __FUNCTION__, '2.0' ); |
|
| 436 | - return 'postbox-container'; |
|
| 437 | - } |
|
| 420 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 421 | + |
|
| 422 | + delete_option( 'frmpro-credentials' ); |
|
| 423 | + delete_option( 'frmpro-authorized' ); |
|
| 424 | + delete_site_option( 'frmpro-credentials' ); |
|
| 425 | + delete_site_option( 'frmpro-authorized' ); |
|
| 426 | + wp_die(); |
|
| 427 | + } |
|
| 428 | + |
|
| 429 | + public static function get_form_shortcode( $atts ) { |
|
| 430 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
|
| 431 | + return FrmFormsController::get_form_shortcode( $atts ); |
|
| 432 | + } |
|
| 433 | + |
|
| 434 | + public static function get_postbox_class() { |
|
| 435 | + _deprecated_function( __FUNCTION__, '2.0' ); |
|
| 436 | + return 'postbox-container'; |
|
| 437 | + } |
|
| 438 | 438 | } |
@@ -181,13 +181,13 @@ |
||
| 181 | 181 | ), |
| 182 | 182 | ); |
| 183 | 183 | $random = rand( 0, count( $tips ) - 1 ); |
| 184 | - $tip = $tips[ $random ]; |
|
| 184 | + $tip = $tips[$random]; |
|
| 185 | 185 | $tip['num'] = $random; |
| 186 | 186 | return $tip; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | public static function get_random_tip( $tips ) { |
| 190 | 190 | $random = rand( 0, count( $tips ) - 1 ); |
| 191 | - return $tips[ $random ]; |
|
| 191 | + return $tips[$random]; |
|
| 192 | 192 | } |
| 193 | 193 | } |
@@ -2,201 +2,201 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmEntriesController { |
| 4 | 4 | |
| 5 | - public static function menu() { |
|
| 5 | + public static function menu() { |
|
| 6 | 6 | FrmAppHelper::force_capability( 'frm_view_entries' ); |
| 7 | 7 | |
| 8 | - add_submenu_page('formidable', 'Formidable | '. __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
| 8 | + add_submenu_page('formidable', 'Formidable | '. __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
| 9 | 9 | |
| 10 | 10 | if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) { |
| 11 | 11 | $menu_name = FrmAppHelper::get_menu_name(); |
| 12 | 12 | add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_columns', 'FrmEntriesController::manage_columns' ); |
| 13 | 13 | add_filter( 'get_user_option_manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden', 'FrmEntriesController::hidden_columns' ); |
| 14 | 14 | add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_sortable_columns', 'FrmEntriesController::sortable_columns' ); |
| 15 | - } |
|
| 16 | - } |
|
| 15 | + } |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - /* Display in Back End */ |
|
| 19 | - public static function route() { |
|
| 18 | + /* Display in Back End */ |
|
| 19 | + public static function route() { |
|
| 20 | 20 | $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
| 21 | 21 | |
| 22 | - switch ( $action ) { |
|
| 23 | - case 'show': |
|
| 24 | - case 'destroy': |
|
| 25 | - case 'destroy_all': |
|
| 26 | - return self::$action(); |
|
| 22 | + switch ( $action ) { |
|
| 23 | + case 'show': |
|
| 24 | + case 'destroy': |
|
| 25 | + case 'destroy_all': |
|
| 26 | + return self::$action(); |
|
| 27 | 27 | |
| 28 | - default: |
|
| 29 | - do_action( 'frm_entry_action_route', $action ); |
|
| 30 | - if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) { |
|
| 31 | - return; |
|
| 32 | - } |
|
| 28 | + default: |
|
| 29 | + do_action( 'frm_entry_action_route', $action ); |
|
| 30 | + if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) { |
|
| 31 | + return; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - return self::display_list(); |
|
| 35 | - } |
|
| 36 | - } |
|
| 34 | + return self::display_list(); |
|
| 35 | + } |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | 38 | public static function contextual_help( $help, $screen_id, $screen ) { |
| 39 | - // Only add to certain screens. add_help_tab was introduced in WordPress 3.3 |
|
| 40 | - if ( ! method_exists( $screen, 'add_help_tab' ) ) { |
|
| 41 | - return $help; |
|
| 42 | - } |
|
| 39 | + // Only add to certain screens. add_help_tab was introduced in WordPress 3.3 |
|
| 40 | + if ( ! method_exists( $screen, 'add_help_tab' ) ) { |
|
| 41 | + return $help; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | 44 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
| 45 | 45 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
| 46 | 46 | if ( $page != 'formidable-entries' || ( ! empty( $action ) && $action != 'list' ) ) { |
| 47 | - return $help; |
|
| 48 | - } |
|
| 47 | + return $help; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | unset( $action, $page ); |
| 51 | 51 | |
| 52 | - $screen->add_help_tab( array( |
|
| 53 | - 'id' => 'formidable-entries-tab', |
|
| 54 | - 'title' => __( 'Overview', 'formidable' ), |
|
| 52 | + $screen->add_help_tab( array( |
|
| 53 | + 'id' => 'formidable-entries-tab', |
|
| 54 | + 'title' => __( 'Overview', 'formidable' ), |
|
| 55 | 55 | 'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) .'</p> <p>'. esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>', |
| 56 | - )); |
|
| 56 | + )); |
|
| 57 | 57 | |
| 58 | - $screen->set_help_sidebar( |
|
| 58 | + $screen->set_help_sidebar( |
|
| 59 | 59 | '<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' . |
| 60 | 60 | '<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'http://formidablepro.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( 'http://formidablepro.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>' |
| 62 | - ); |
|
| 62 | + ); |
|
| 63 | 63 | |
| 64 | - return $help; |
|
| 65 | - } |
|
| 64 | + return $help; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | 67 | public static function manage_columns( $columns ) { |
| 68 | - global $frm_vars, $wpdb; |
|
| 68 | + global $frm_vars, $wpdb; |
|
| 69 | 69 | $form_id = FrmForm::get_current_form_id(); |
| 70 | 70 | |
| 71 | - $columns[ $form_id .'_id' ] = 'ID'; |
|
| 71 | + $columns[ $form_id .'_id' ] = 'ID'; |
|
| 72 | 72 | $columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' ); |
| 73 | 73 | |
| 74 | - if ( ! $form_id ) { |
|
| 75 | - return $columns; |
|
| 76 | - } |
|
| 74 | + if ( ! $form_id ) { |
|
| 75 | + return $columns; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - $form_cols = FrmField::get_all_for_form($form_id, '', 'include'); |
|
| 78 | + $form_cols = FrmField::get_all_for_form($form_id, '', 'include'); |
|
| 79 | 79 | |
| 80 | - foreach ( $form_cols as $form_col ) { |
|
| 80 | + foreach ( $form_cols as $form_col ) { |
|
| 81 | 81 | if ( FrmField::is_no_save_field( $form_col->type ) ) { |
| 82 | - continue; |
|
| 83 | - } |
|
| 82 | + continue; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) { |
|
| 85 | + if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) { |
|
| 86 | 86 | $sub_form_cols = FrmField::get_all_for_form( $form_col->field_options['form_select'] ); |
| 87 | 87 | |
| 88 | - if ( $sub_form_cols ) { |
|
| 89 | - foreach ( $sub_form_cols as $k => $sub_form_col ) { |
|
| 88 | + if ( $sub_form_cols ) { |
|
| 89 | + foreach ( $sub_form_cols as $k => $sub_form_col ) { |
|
| 90 | 90 | if ( FrmField::is_no_save_field( $sub_form_col->type ) ) { |
| 91 | - unset( $sub_form_cols[ $k ] ); |
|
| 92 | - continue; |
|
| 93 | - } |
|
| 91 | + unset( $sub_form_cols[ $k ] ); |
|
| 92 | + continue; |
|
| 93 | + } |
|
| 94 | 94 | $columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 ); |
| 95 | - unset($sub_form_col); |
|
| 96 | - } |
|
| 97 | - } |
|
| 98 | - unset($sub_form_cols); |
|
| 99 | - } else { |
|
| 100 | - $col_id = $form_col->field_key; |
|
| 101 | - if ( $form_col->form_id != $form_id ) { |
|
| 102 | - $col_id .= '-_-form'. $form_col->form_id; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) { |
|
| 106 | - $columns[ $form_id .'_frmsep_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
| 107 | - } |
|
| 108 | - $columns[ $form_id .'_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
| 109 | - } |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - $columns[ $form_id .'_created_at' ] = __( 'Entry creation date', 'formidable' ); |
|
| 113 | - $columns[ $form_id .'_updated_at' ] = __( 'Entry update date', 'formidable' ); |
|
| 114 | - $columns[ $form_id .'_ip' ] = 'IP'; |
|
| 115 | - |
|
| 116 | - $frm_vars['cols'] = $columns; |
|
| 95 | + unset($sub_form_col); |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | + unset($sub_form_cols); |
|
| 99 | + } else { |
|
| 100 | + $col_id = $form_col->field_key; |
|
| 101 | + if ( $form_col->form_id != $form_id ) { |
|
| 102 | + $col_id .= '-_-form'. $form_col->form_id; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) { |
|
| 106 | + $columns[ $form_id .'_frmsep_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
| 107 | + } |
|
| 108 | + $columns[ $form_id .'_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + $columns[ $form_id .'_created_at' ] = __( 'Entry creation date', 'formidable' ); |
|
| 113 | + $columns[ $form_id .'_updated_at' ] = __( 'Entry update date', 'formidable' ); |
|
| 114 | + $columns[ $form_id .'_ip' ] = 'IP'; |
|
| 115 | + |
|
| 116 | + $frm_vars['cols'] = $columns; |
|
| 117 | 117 | |
| 118 | 118 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
| 119 | 119 | if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) { |
| 120 | 120 | add_screen_option( 'per_page', array( 'label' => __( 'Entries', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page' ) ); |
| 121 | - } |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - return $columns; |
|
| 124 | - } |
|
| 123 | + return $columns; |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | 126 | public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) { |
| 127 | 127 | $menu_name = FrmAppHelper::get_menu_name(); |
| 128 | 128 | $this_page_name = 'manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden'; |
| 129 | 129 | if ( $meta_key != $this_page_name || $meta_value == $prev_value ) { |
| 130 | - return $check; |
|
| 131 | - } |
|
| 130 | + return $check; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | 133 | if ( empty( $prev_value ) ) { |
| 134 | 134 | $prev_value = get_metadata( 'user', $object_id, $meta_key, true ); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - global $frm_vars; |
|
| 138 | - //add a check so we don't create a loop |
|
| 139 | - $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
| 137 | + global $frm_vars; |
|
| 138 | + //add a check so we don't create a loop |
|
| 139 | + $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
| 140 | 140 | |
| 141 | - return $check; |
|
| 142 | - } |
|
| 141 | + return $check; |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - //add hidden columns back from other forms |
|
| 144 | + //add hidden columns back from other forms |
|
| 145 | 145 | public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) { |
| 146 | 146 | $menu_name = FrmAppHelper::get_menu_name(); |
| 147 | 147 | $sanitized = sanitize_title( $menu_name ); |
| 148 | 148 | $this_page_name = 'manage'. $sanitized .'_page_formidable-entriescolumnshidden'; |
| 149 | 149 | if ( $meta_key != $this_page_name ) { |
| 150 | - return; |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - global $frm_vars; |
|
| 154 | - if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) { |
|
| 155 | - return; //don't continue if there's no previous value |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - foreach ( $meta_value as $mk => $mv ) { |
|
| 159 | - //remove blank values |
|
| 160 | - if ( empty( $mv ) ) { |
|
| 161 | - unset( $meta_value[ $mk ] ); |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - $cur_form_prefix = reset($meta_value); |
|
| 166 | - $cur_form_prefix = explode('_', $cur_form_prefix); |
|
| 167 | - $cur_form_prefix = $cur_form_prefix[0]; |
|
| 168 | - $save = false; |
|
| 169 | - |
|
| 170 | - foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) { |
|
| 150 | + return; |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + global $frm_vars; |
|
| 154 | + if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) { |
|
| 155 | + return; //don't continue if there's no previous value |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + foreach ( $meta_value as $mk => $mv ) { |
|
| 159 | + //remove blank values |
|
| 160 | + if ( empty( $mv ) ) { |
|
| 161 | + unset( $meta_value[ $mk ] ); |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + $cur_form_prefix = reset($meta_value); |
|
| 166 | + $cur_form_prefix = explode('_', $cur_form_prefix); |
|
| 167 | + $cur_form_prefix = $cur_form_prefix[0]; |
|
| 168 | + $save = false; |
|
| 169 | + |
|
| 170 | + foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) { |
|
| 171 | 171 | if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) { |
| 172 | - //don't add blank cols or process included cols |
|
| 173 | - continue; |
|
| 174 | - } |
|
| 172 | + //don't add blank cols or process included cols |
|
| 173 | + continue; |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | 176 | $form_prefix = explode( '_', $prev_hidden ); |
| 177 | - $form_prefix = $form_prefix[0]; |
|
| 178 | - if ( $form_prefix == $cur_form_prefix ) { |
|
| 179 | - //don't add back columns that are meant to be hidden |
|
| 180 | - continue; |
|
| 181 | - } |
|
| 177 | + $form_prefix = $form_prefix[0]; |
|
| 178 | + if ( $form_prefix == $cur_form_prefix ) { |
|
| 179 | + //don't add back columns that are meant to be hidden |
|
| 180 | + continue; |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | - $meta_value[] = $prev_hidden; |
|
| 184 | - $save = true; |
|
| 185 | - unset($form_prefix); |
|
| 186 | - } |
|
| 183 | + $meta_value[] = $prev_hidden; |
|
| 184 | + $save = true; |
|
| 185 | + unset($form_prefix); |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | 188 | if ( $save ) { |
| 189 | - $user = wp_get_current_user(); |
|
| 189 | + $user = wp_get_current_user(); |
|
| 190 | 190 | update_user_option( $user->ID, $this_page_name, $meta_value, true ); |
| 191 | - } |
|
| 192 | - } |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | 194 | public static function save_per_page( $save, $option, $value ) { |
| 195 | - if ( $option == 'formidable_page_formidable_entries_per_page' ) { |
|
| 196 | - $save = (int) $value; |
|
| 197 | - } |
|
| 198 | - return $save; |
|
| 199 | - } |
|
| 195 | + if ( $option == 'formidable_page_formidable_entries_per_page' ) { |
|
| 196 | + $save = (int) $value; |
|
| 197 | + } |
|
| 198 | + return $save; |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | 201 | public static function sortable_columns() { |
| 202 | 202 | $form_id = FrmForm::get_current_form_id(); |
@@ -222,226 +222,226 @@ discard block |
||
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | public static function hidden_columns( $result ) { |
| 225 | - global $frm_vars; |
|
| 225 | + global $frm_vars; |
|
| 226 | 226 | |
| 227 | 227 | $form_id = FrmForm::get_current_form_id(); |
| 228 | 228 | |
| 229 | - $return = false; |
|
| 230 | - foreach ( (array) $result as $r ) { |
|
| 231 | - if ( ! empty( $r ) ) { |
|
| 232 | - $form_prefix = explode( '_', $r ); |
|
| 233 | - $form_prefix = $form_prefix[0]; |
|
| 229 | + $return = false; |
|
| 230 | + foreach ( (array) $result as $r ) { |
|
| 231 | + if ( ! empty( $r ) ) { |
|
| 232 | + $form_prefix = explode( '_', $r ); |
|
| 233 | + $form_prefix = $form_prefix[0]; |
|
| 234 | 234 | |
| 235 | - if ( (int) $form_prefix == (int) $form_id ) { |
|
| 236 | - $return = true; |
|
| 237 | - break; |
|
| 238 | - } |
|
| 235 | + if ( (int) $form_prefix == (int) $form_id ) { |
|
| 236 | + $return = true; |
|
| 237 | + break; |
|
| 238 | + } |
|
| 239 | 239 | |
| 240 | - unset($form_prefix); |
|
| 241 | - } |
|
| 242 | - } |
|
| 240 | + unset($form_prefix); |
|
| 241 | + } |
|
| 242 | + } |
|
| 243 | 243 | |
| 244 | - if ( $return ) { |
|
| 244 | + if ( $return ) { |
|
| 245 | 245 | return $result; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0; |
|
| 249 | - $max_columns = 8; |
|
| 250 | - if ( $i <= $max_columns ) { |
|
| 248 | + $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0; |
|
| 249 | + $max_columns = 8; |
|
| 250 | + if ( $i <= $max_columns ) { |
|
| 251 | 251 | return $result; |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - global $frm_vars; |
|
| 255 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) { |
|
| 256 | - $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options); |
|
| 257 | - } |
|
| 254 | + global $frm_vars; |
|
| 255 | + if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) { |
|
| 256 | + $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options); |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) { |
|
| 260 | - $result = $frm_vars['current_form']->options['hidden_cols']; |
|
| 261 | - } else { |
|
| 262 | - $cols = $frm_vars['cols']; |
|
| 263 | - $cols = array_reverse($cols, true); |
|
| 259 | + if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) { |
|
| 260 | + $result = $frm_vars['current_form']->options['hidden_cols']; |
|
| 261 | + } else { |
|
| 262 | + $cols = $frm_vars['cols']; |
|
| 263 | + $cols = array_reverse($cols, true); |
|
| 264 | 264 | |
| 265 | - $result[] = $form_id .'_id'; |
|
| 266 | - $i--; |
|
| 265 | + $result[] = $form_id .'_id'; |
|
| 266 | + $i--; |
|
| 267 | 267 | |
| 268 | - $result[] = $form_id .'_item_key'; |
|
| 269 | - $i--; |
|
| 268 | + $result[] = $form_id .'_item_key'; |
|
| 269 | + $i--; |
|
| 270 | 270 | |
| 271 | 271 | foreach ( $cols as $col_key => $col ) { |
| 272 | - if ( $i > $max_columns ) { |
|
| 272 | + if ( $i > $max_columns ) { |
|
| 273 | 273 | $result[] = $col_key; |
| 274 | 274 | } |
| 275 | - //remove some columns by default |
|
| 276 | - $i--; |
|
| 277 | - unset($col_key, $col); |
|
| 278 | - } |
|
| 279 | - } |
|
| 275 | + //remove some columns by default |
|
| 276 | + $i--; |
|
| 277 | + unset($col_key, $col); |
|
| 278 | + } |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | - return $result; |
|
| 282 | - } |
|
| 281 | + return $result; |
|
| 282 | + } |
|
| 283 | 283 | |
| 284 | 284 | public static function display_list( $message = '', $errors = array() ) { |
| 285 | - global $wpdb, $frm_vars; |
|
| 285 | + global $wpdb, $frm_vars; |
|
| 286 | 286 | |
| 287 | 287 | $form = FrmForm::get_current_form(); |
| 288 | 288 | $params = FrmForm::get_admin_params( $form ); |
| 289 | 289 | |
| 290 | - if ( $form ) { |
|
| 291 | - $params['form'] = $form->id; |
|
| 292 | - $frm_vars['current_form'] = $form; |
|
| 290 | + if ( $form ) { |
|
| 291 | + $params['form'] = $form->id; |
|
| 292 | + $frm_vars['current_form'] = $form; |
|
| 293 | 293 | |
| 294 | - if ( 'trash' == $form->status ) { |
|
| 295 | - $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); |
|
| 296 | - $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) ); |
|
| 297 | - $errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete ); |
|
| 298 | - unset( $time_to_delete, $delete_timestamp ); |
|
| 299 | - } |
|
| 294 | + if ( 'trash' == $form->status ) { |
|
| 295 | + $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); |
|
| 296 | + $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) ); |
|
| 297 | + $errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete ); |
|
| 298 | + unset( $time_to_delete, $delete_timestamp ); |
|
| 299 | + } |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | - $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' ); |
|
| 302 | + $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' ); |
|
| 303 | 303 | |
| 304 | - $wp_list_table = new $table_class( array( 'params' => $params ) ); |
|
| 304 | + $wp_list_table = new $table_class( array( 'params' => $params ) ); |
|
| 305 | 305 | |
| 306 | - $pagenum = $wp_list_table->get_pagenum(); |
|
| 306 | + $pagenum = $wp_list_table->get_pagenum(); |
|
| 307 | 307 | |
| 308 | - $wp_list_table->prepare_items(); |
|
| 308 | + $wp_list_table->prepare_items(); |
|
| 309 | 309 | |
| 310 | - $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 311 | - if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 310 | + $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 311 | + if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 312 | 312 | $url = add_query_arg( 'paged', $total_pages ); |
| 313 | - if ( headers_sent() ) { |
|
| 314 | - echo FrmAppHelper::js_redirect($url); |
|
| 315 | - } else { |
|
| 316 | - wp_redirect( esc_url_raw( $url ) ); |
|
| 317 | - } |
|
| 318 | - die(); |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - if ( empty($message) && isset($_GET['import-message']) ) { |
|
| 322 | - $message = __( 'Your import is complete', 'formidable' ); |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/list.php'); |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - /* Back End CRUD */ |
|
| 313 | + if ( headers_sent() ) { |
|
| 314 | + echo FrmAppHelper::js_redirect($url); |
|
| 315 | + } else { |
|
| 316 | + wp_redirect( esc_url_raw( $url ) ); |
|
| 317 | + } |
|
| 318 | + die(); |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + if ( empty($message) && isset($_GET['import-message']) ) { |
|
| 322 | + $message = __( 'Your import is complete', 'formidable' ); |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/list.php'); |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + /* Back End CRUD */ |
|
| 329 | 329 | public static function show( $id = 0 ) { |
| 330 | - FrmAppHelper::permission_check('frm_view_entries'); |
|
| 330 | + FrmAppHelper::permission_check('frm_view_entries'); |
|
| 331 | 331 | |
| 332 | - if ( ! $id ) { |
|
| 332 | + if ( ! $id ) { |
|
| 333 | 333 | $id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' ); |
| 334 | 334 | |
| 335 | - if ( ! $id ) { |
|
| 335 | + if ( ! $id ) { |
|
| 336 | 336 | $id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' ); |
| 337 | - } |
|
| 338 | - } |
|
| 337 | + } |
|
| 338 | + } |
|
| 339 | 339 | |
| 340 | - $entry = FrmEntry::getOne($id, true); |
|
| 340 | + $entry = FrmEntry::getOne($id, true); |
|
| 341 | 341 | |
| 342 | - $data = maybe_unserialize($entry->description); |
|
| 342 | + $data = maybe_unserialize($entry->description); |
|
| 343 | 343 | if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) { |
| 344 | 344 | $data = array( 'referrer' => $data ); |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | $fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' ); |
| 348 | - $to_emails = array(); |
|
| 348 | + $to_emails = array(); |
|
| 349 | 349 | |
| 350 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/show.php'); |
|
| 351 | - } |
|
| 350 | + include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/show.php'); |
|
| 351 | + } |
|
| 352 | 352 | |
| 353 | - public static function destroy() { |
|
| 354 | - FrmAppHelper::permission_check('frm_delete_entries'); |
|
| 353 | + public static function destroy() { |
|
| 354 | + FrmAppHelper::permission_check('frm_delete_entries'); |
|
| 355 | 355 | |
| 356 | 356 | $params = FrmForm::get_admin_params(); |
| 357 | 357 | |
| 358 | - if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
| 359 | - //unlink entry from post |
|
| 360 | - global $wpdb; |
|
| 358 | + if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
| 359 | + //unlink entry from post |
|
| 360 | + global $wpdb; |
|
| 361 | 361 | $wpdb->update( $wpdb->prefix .'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) ); |
| 362 | - } |
|
| 362 | + } |
|
| 363 | 363 | |
| 364 | - $message = ''; |
|
| 365 | - if ( FrmEntry::destroy( $params['id'] ) ) { |
|
| 366 | - $message = __( 'Entry was Successfully Destroyed', 'formidable' ); |
|
| 367 | - } |
|
| 364 | + $message = ''; |
|
| 365 | + if ( FrmEntry::destroy( $params['id'] ) ) { |
|
| 366 | + $message = __( 'Entry was Successfully Destroyed', 'formidable' ); |
|
| 367 | + } |
|
| 368 | 368 | |
| 369 | - self::display_list( $message ); |
|
| 370 | - } |
|
| 369 | + self::display_list( $message ); |
|
| 370 | + } |
|
| 371 | 371 | |
| 372 | - public static function destroy_all() { |
|
| 373 | - if ( ! current_user_can( 'frm_delete_entries' ) ) { |
|
| 374 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 375 | - wp_die( $frm_settings->admin_permission ); |
|
| 376 | - } |
|
| 372 | + public static function destroy_all() { |
|
| 373 | + if ( ! current_user_can( 'frm_delete_entries' ) ) { |
|
| 374 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 375 | + wp_die( $frm_settings->admin_permission ); |
|
| 376 | + } |
|
| 377 | 377 | |
| 378 | - global $wpdb; |
|
| 378 | + global $wpdb; |
|
| 379 | 379 | $params = FrmForm::get_admin_params(); |
| 380 | - $message = ''; |
|
| 381 | - $errors = array(); |
|
| 382 | - $form_id = (int) $params['form']; |
|
| 380 | + $message = ''; |
|
| 381 | + $errors = array(); |
|
| 382 | + $form_id = (int) $params['form']; |
|
| 383 | 383 | |
| 384 | - if ( $form_id ) { |
|
| 385 | - $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) ); |
|
| 384 | + if ( $form_id ) { |
|
| 385 | + $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) ); |
|
| 386 | 386 | $action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 ); |
| 387 | 387 | |
| 388 | - if ( $action ) { |
|
| 389 | - // this action takes a while, so only trigger it if there are posts to delete |
|
| 390 | - foreach ( $entry_ids as $entry_id ) { |
|
| 391 | - do_action( 'frm_before_destroy_entry', $entry_id ); |
|
| 392 | - unset( $entry_id ); |
|
| 393 | - } |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - $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 ) ); |
|
| 397 | - $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) ); |
|
| 398 | - if ( $results ) { |
|
| 399 | - $message = __( 'Entries were Successfully Destroyed', 'formidable' ); |
|
| 400 | - } |
|
| 401 | - } else { |
|
| 402 | - $errors = __( 'No entries were specified', 'formidable' ); |
|
| 403 | - } |
|
| 404 | - |
|
| 405 | - self::display_list( $message, $errors ); |
|
| 406 | - } |
|
| 407 | - |
|
| 408 | - public static function show_form( $id = '', $key = '', $title = false, $description = false ) { |
|
| 409 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' ); |
|
| 410 | - return FrmFormsController::show_form( $id, $key, $title, $description ); |
|
| 411 | - } |
|
| 412 | - |
|
| 413 | - public static function get_form( $filename, $form, $title, $description ) { |
|
| 414 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' ); |
|
| 415 | - return FrmFormsController::get_form( $form, $title, $description ); |
|
| 416 | - } |
|
| 417 | - |
|
| 418 | - public static function process_entry( $errors = '', $ajax = false ) { |
|
| 388 | + if ( $action ) { |
|
| 389 | + // this action takes a while, so only trigger it if there are posts to delete |
|
| 390 | + foreach ( $entry_ids as $entry_id ) { |
|
| 391 | + do_action( 'frm_before_destroy_entry', $entry_id ); |
|
| 392 | + unset( $entry_id ); |
|
| 393 | + } |
|
| 394 | + } |
|
| 395 | + |
|
| 396 | + $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 ) ); |
|
| 397 | + $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) ); |
|
| 398 | + if ( $results ) { |
|
| 399 | + $message = __( 'Entries were Successfully Destroyed', 'formidable' ); |
|
| 400 | + } |
|
| 401 | + } else { |
|
| 402 | + $errors = __( 'No entries were specified', 'formidable' ); |
|
| 403 | + } |
|
| 404 | + |
|
| 405 | + self::display_list( $message, $errors ); |
|
| 406 | + } |
|
| 407 | + |
|
| 408 | + public static function show_form( $id = '', $key = '', $title = false, $description = false ) { |
|
| 409 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' ); |
|
| 410 | + return FrmFormsController::show_form( $id, $key, $title, $description ); |
|
| 411 | + } |
|
| 412 | + |
|
| 413 | + public static function get_form( $filename, $form, $title, $description ) { |
|
| 414 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' ); |
|
| 415 | + return FrmFormsController::get_form( $form, $title, $description ); |
|
| 416 | + } |
|
| 417 | + |
|
| 418 | + public static function process_entry( $errors = '', $ajax = false ) { |
|
| 419 | 419 | $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' ); |
| 420 | 420 | if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) { |
| 421 | - return; |
|
| 422 | - } |
|
| 421 | + return; |
|
| 422 | + } |
|
| 423 | 423 | |
| 424 | - global $frm_vars; |
|
| 424 | + global $frm_vars; |
|
| 425 | 425 | |
| 426 | 426 | $form = FrmForm::getOne( $form_id ); |
| 427 | - if ( ! $form ) { |
|
| 428 | - return; |
|
| 429 | - } |
|
| 427 | + if ( ! $form ) { |
|
| 428 | + return; |
|
| 429 | + } |
|
| 430 | 430 | |
| 431 | 431 | $params = FrmForm::get_params( $form ); |
| 432 | 432 | |
| 433 | - if ( ! isset( $frm_vars['form_params'] ) ) { |
|
| 434 | - $frm_vars['form_params'] = array(); |
|
| 435 | - } |
|
| 433 | + if ( ! isset( $frm_vars['form_params'] ) ) { |
|
| 434 | + $frm_vars['form_params'] = array(); |
|
| 435 | + } |
|
| 436 | 436 | $frm_vars['form_params'][ $form->id ] = $params; |
| 437 | 437 | |
| 438 | 438 | if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) { |
| 439 | - return; |
|
| 440 | - } |
|
| 439 | + return; |
|
| 440 | + } |
|
| 441 | 441 | |
| 442 | - if ( $errors == '' ) { |
|
| 442 | + if ( $errors == '' ) { |
|
| 443 | 443 | $errors = FrmEntryValidate::validate( $_POST ); |
| 444 | - } |
|
| 444 | + } |
|
| 445 | 445 | |
| 446 | 446 | /** |
| 447 | 447 | * Use this filter to add trigger actions and add errors after |
@@ -452,102 +452,102 @@ discard block |
||
| 452 | 452 | |
| 453 | 453 | $frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors ); |
| 454 | 454 | |
| 455 | - if ( empty( $errors ) ) { |
|
| 455 | + if ( empty( $errors ) ) { |
|
| 456 | 456 | $_POST['frm_skip_cookie'] = 1; |
| 457 | - if ( $params['action'] == 'create' ) { |
|
| 457 | + if ( $params['action'] == 'create' ) { |
|
| 458 | 458 | if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) { |
| 459 | 459 | $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); |
| 460 | - } |
|
| 461 | - } |
|
| 460 | + } |
|
| 461 | + } |
|
| 462 | 462 | |
| 463 | - do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); |
|
| 463 | + do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); |
|
| 464 | 464 | unset( $_POST['frm_skip_cookie'] ); |
| 465 | - } |
|
| 466 | - } |
|
| 467 | - |
|
| 468 | - public static function delete_entry_before_redirect( $url, $form, $atts ) { |
|
| 469 | - self::_delete_entry( $atts['id'], $form ); |
|
| 470 | - return $url; |
|
| 471 | - } |
|
| 472 | - |
|
| 473 | - //Delete entry if not redirected |
|
| 474 | - public static function delete_entry_after_save( $atts ) { |
|
| 475 | - self::_delete_entry( $atts['entry_id'], $atts['form'] ); |
|
| 476 | - } |
|
| 477 | - |
|
| 478 | - private static function _delete_entry( $entry_id, $form ) { |
|
| 479 | - if ( ! $form ) { |
|
| 480 | - return; |
|
| 481 | - } |
|
| 482 | - |
|
| 483 | - $form->options = maybe_unserialize( $form->options ); |
|
| 484 | - if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) { |
|
| 485 | - FrmEntry::destroy( $entry_id ); |
|
| 486 | - } |
|
| 487 | - } |
|
| 465 | + } |
|
| 466 | + } |
|
| 467 | + |
|
| 468 | + public static function delete_entry_before_redirect( $url, $form, $atts ) { |
|
| 469 | + self::_delete_entry( $atts['id'], $form ); |
|
| 470 | + return $url; |
|
| 471 | + } |
|
| 472 | + |
|
| 473 | + //Delete entry if not redirected |
|
| 474 | + public static function delete_entry_after_save( $atts ) { |
|
| 475 | + self::_delete_entry( $atts['entry_id'], $atts['form'] ); |
|
| 476 | + } |
|
| 477 | + |
|
| 478 | + private static function _delete_entry( $entry_id, $form ) { |
|
| 479 | + if ( ! $form ) { |
|
| 480 | + return; |
|
| 481 | + } |
|
| 482 | + |
|
| 483 | + $form->options = maybe_unserialize( $form->options ); |
|
| 484 | + if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) { |
|
| 485 | + FrmEntry::destroy( $entry_id ); |
|
| 486 | + } |
|
| 487 | + } |
|
| 488 | 488 | |
| 489 | 489 | public static function show_entry_shortcode( $atts ) { |
| 490 | 490 | return FrmEntryFormat::show_entry( $atts ); |
| 491 | 491 | } |
| 492 | 492 | |
| 493 | - public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) { |
|
| 494 | - $field = FrmField::getOne($meta->field_id); |
|
| 495 | - if ( ! $field ) { |
|
| 496 | - return $value; |
|
| 497 | - } |
|
| 493 | + public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) { |
|
| 494 | + $field = FrmField::getOne($meta->field_id); |
|
| 495 | + if ( ! $field ) { |
|
| 496 | + return $value; |
|
| 497 | + } |
|
| 498 | 498 | |
| 499 | - $value = self::filter_display_value($value, $field, $atts); |
|
| 500 | - return $value; |
|
| 501 | - } |
|
| 499 | + $value = self::filter_display_value($value, $field, $atts); |
|
| 500 | + return $value; |
|
| 501 | + } |
|
| 502 | 502 | |
| 503 | 503 | public static function &filter_shortcode_value( $value, $tag, $atts, $field ) { |
| 504 | - $plain_text = add_filter('frm_plain_text_email', true); |
|
| 504 | + $plain_text = add_filter('frm_plain_text_email', true); |
|
| 505 | 505 | FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value ); |
| 506 | 506 | |
| 507 | - if ( isset($atts['show']) && $atts['show'] == 'value' ) { |
|
| 508 | - return $value; |
|
| 509 | - } |
|
| 507 | + if ( isset($atts['show']) && $atts['show'] == 'value' ) { |
|
| 508 | + return $value; |
|
| 509 | + } |
|
| 510 | 510 | |
| 511 | - return self::filter_display_value($value, $field, $atts); |
|
| 512 | - } |
|
| 511 | + return self::filter_display_value($value, $field, $atts); |
|
| 512 | + } |
|
| 513 | 513 | |
| 514 | - public static function &filter_display_value( $value, $field, $atts = array() ) { |
|
| 515 | - $saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false; |
|
| 514 | + public static function &filter_display_value( $value, $field, $atts = array() ) { |
|
| 515 | + $saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false; |
|
| 516 | 516 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'radio', 'select' ) ) || ! FrmField::is_option_true( $field, 'separate_value' ) || $saved_value ) { |
| 517 | - return $value; |
|
| 518 | - } |
|
| 519 | - |
|
| 520 | - $f_values = $f_labels = array(); |
|
| 521 | - |
|
| 522 | - foreach ( $field->options as $opt_key => $opt ) { |
|
| 523 | - if ( ! is_array($opt) ) { |
|
| 524 | - continue; |
|
| 525 | - } |
|
| 526 | - |
|
| 527 | - $f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt); |
|
| 528 | - $f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ]; |
|
| 529 | - if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) { |
|
| 530 | - unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] ); |
|
| 531 | - } |
|
| 532 | - unset($opt_key, $opt); |
|
| 533 | - } |
|
| 534 | - |
|
| 535 | - if ( ! empty($f_values) ) { |
|
| 536 | - foreach ( (array) $value as $v_key => $val ) { |
|
| 537 | - if ( in_array($val, $f_values) ) { |
|
| 538 | - $opt = array_search($val, $f_values); |
|
| 539 | - if ( is_array($value) ) { |
|
| 540 | - $value[ $v_key ] = $f_labels[ $opt ]; |
|
| 541 | - } else { |
|
| 542 | - $value = $f_labels[ $opt ]; |
|
| 543 | - } |
|
| 544 | - } |
|
| 545 | - unset($v_key, $val); |
|
| 546 | - } |
|
| 547 | - } |
|
| 548 | - |
|
| 549 | - return $value; |
|
| 550 | - } |
|
| 517 | + return $value; |
|
| 518 | + } |
|
| 519 | + |
|
| 520 | + $f_values = $f_labels = array(); |
|
| 521 | + |
|
| 522 | + foreach ( $field->options as $opt_key => $opt ) { |
|
| 523 | + if ( ! is_array($opt) ) { |
|
| 524 | + continue; |
|
| 525 | + } |
|
| 526 | + |
|
| 527 | + $f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt); |
|
| 528 | + $f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ]; |
|
| 529 | + if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) { |
|
| 530 | + unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] ); |
|
| 531 | + } |
|
| 532 | + unset($opt_key, $opt); |
|
| 533 | + } |
|
| 534 | + |
|
| 535 | + if ( ! empty($f_values) ) { |
|
| 536 | + foreach ( (array) $value as $v_key => $val ) { |
|
| 537 | + if ( in_array($val, $f_values) ) { |
|
| 538 | + $opt = array_search($val, $f_values); |
|
| 539 | + if ( is_array($value) ) { |
|
| 540 | + $value[ $v_key ] = $f_labels[ $opt ]; |
|
| 541 | + } else { |
|
| 542 | + $value = $f_labels[ $opt ]; |
|
| 543 | + } |
|
| 544 | + } |
|
| 545 | + unset($v_key, $val); |
|
| 546 | + } |
|
| 547 | + } |
|
| 548 | + |
|
| 549 | + return $value; |
|
| 550 | + } |
|
| 551 | 551 | |
| 552 | 552 | public static function get_params( $form = null ) { |
| 553 | 553 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_params' ); |
@@ -555,13 +555,13 @@ discard block |
||
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | public static function entry_sidebar( $entry ) { |
| 558 | - $data = maybe_unserialize($entry->description); |
|
| 559 | - $date_format = get_option('date_format'); |
|
| 560 | - $time_format = get_option('time_format'); |
|
| 558 | + $data = maybe_unserialize($entry->description); |
|
| 559 | + $date_format = get_option('date_format'); |
|
| 560 | + $time_format = get_option('time_format'); |
|
| 561 | 561 | if ( isset( $data['browser'] ) ) { |
| 562 | 562 | $browser = FrmEntryFormat::get_browser( $data['browser'] ); |
| 563 | 563 | } |
| 564 | 564 | |
| 565 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/sidebar-shared.php'); |
|
| 566 | - } |
|
| 565 | + include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/sidebar-shared.php'); |
|
| 566 | + } |
|
| 567 | 567 | } |
@@ -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(); |
@@ -52,13 +52,13 @@ discard block |
||
| 52 | 52 | $screen->add_help_tab( array( |
| 53 | 53 | 'id' => 'formidable-entries-tab', |
| 54 | 54 | 'title' => __( 'Overview', 'formidable' ), |
| 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 | - )); |
|
| 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 | + ) ); |
|
| 57 | 57 | |
| 58 | 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( 'http://formidablepro.com/knowledgebase/manage-entries-from-the-back-end/' ) ) . '" target="_blank">' . esc_html__( 'Documentation on Entries', 'formidable' ) . '</a></p>' . |
| 61 | - '<p><a href="'. esc_url( FrmAppHelper::make_affiliate_url( 'http://formidablepro.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>' |
|
| 61 | + '<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'http://formidablepro.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>' |
|
| 62 | 62 | ); |
| 63 | 63 | |
| 64 | 64 | return $help; |
@@ -68,14 +68,14 @@ discard block |
||
| 68 | 68 | global $frm_vars, $wpdb; |
| 69 | 69 | $form_id = FrmForm::get_current_form_id(); |
| 70 | 70 | |
| 71 | - $columns[ $form_id .'_id' ] = 'ID'; |
|
| 72 | - $columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' ); |
|
| 71 | + $columns[$form_id . '_id'] = 'ID'; |
|
| 72 | + $columns[$form_id . '_item_key'] = esc_html__( 'Entry Key', 'formidable' ); |
|
| 73 | 73 | |
| 74 | 74 | if ( ! $form_id ) { |
| 75 | 75 | return $columns; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - $form_cols = FrmField::get_all_for_form($form_id, '', 'include'); |
|
| 78 | + $form_cols = FrmField::get_all_for_form( $form_id, '', 'include' ); |
|
| 79 | 79 | |
| 80 | 80 | foreach ( $form_cols as $form_col ) { |
| 81 | 81 | if ( FrmField::is_no_save_field( $form_col->type ) ) { |
@@ -88,30 +88,30 @@ discard block |
||
| 88 | 88 | if ( $sub_form_cols ) { |
| 89 | 89 | foreach ( $sub_form_cols as $k => $sub_form_col ) { |
| 90 | 90 | if ( FrmField::is_no_save_field( $sub_form_col->type ) ) { |
| 91 | - unset( $sub_form_cols[ $k ] ); |
|
| 91 | + unset( $sub_form_cols[$k] ); |
|
| 92 | 92 | continue; |
| 93 | 93 | } |
| 94 | - $columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 ); |
|
| 95 | - unset($sub_form_col); |
|
| 94 | + $columns[$form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id] = FrmAppHelper::truncate( $sub_form_col->name, 35 ); |
|
| 95 | + unset( $sub_form_col ); |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | - unset($sub_form_cols); |
|
| 98 | + unset( $sub_form_cols ); |
|
| 99 | 99 | } else { |
| 100 | 100 | $col_id = $form_col->field_key; |
| 101 | 101 | if ( $form_col->form_id != $form_id ) { |
| 102 | - $col_id .= '-_-form'. $form_col->form_id; |
|
| 102 | + $col_id .= '-_-form' . $form_col->form_id; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) { |
|
| 106 | - $columns[ $form_id .'_frmsep_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
| 105 | + if ( isset( $form_col->field_options['separate_value'] ) && $form_col->field_options['separate_value'] ) { |
|
| 106 | + $columns[$form_id . '_frmsep_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
| 107 | 107 | } |
| 108 | - $columns[ $form_id .'_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
| 108 | + $columns[$form_id . '_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - $columns[ $form_id .'_created_at' ] = __( 'Entry creation date', 'formidable' ); |
|
| 113 | - $columns[ $form_id .'_updated_at' ] = __( 'Entry update date', 'formidable' ); |
|
| 114 | - $columns[ $form_id .'_ip' ] = 'IP'; |
|
| 112 | + $columns[$form_id . '_created_at'] = __( 'Entry creation date', 'formidable' ); |
|
| 113 | + $columns[$form_id . '_updated_at'] = __( 'Entry update date', 'formidable' ); |
|
| 114 | + $columns[$form_id . '_ip'] = 'IP'; |
|
| 115 | 115 | |
| 116 | 116 | $frm_vars['cols'] = $columns; |
| 117 | 117 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) { |
| 127 | 127 | $menu_name = FrmAppHelper::get_menu_name(); |
| 128 | - $this_page_name = 'manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden'; |
|
| 128 | + $this_page_name = 'manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden'; |
|
| 129 | 129 | if ( $meta_key != $this_page_name || $meta_value == $prev_value ) { |
| 130 | 130 | return $check; |
| 131 | 131 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | global $frm_vars; |
| 138 | 138 | //add a check so we don't create a loop |
| 139 | - $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
| 139 | + $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
| 140 | 140 | |
| 141 | 141 | return $check; |
| 142 | 142 | } |
@@ -145,25 +145,25 @@ discard block |
||
| 145 | 145 | public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) { |
| 146 | 146 | $menu_name = FrmAppHelper::get_menu_name(); |
| 147 | 147 | $sanitized = sanitize_title( $menu_name ); |
| 148 | - $this_page_name = 'manage'. $sanitized .'_page_formidable-entriescolumnshidden'; |
|
| 148 | + $this_page_name = 'manage' . $sanitized . '_page_formidable-entriescolumnshidden'; |
|
| 149 | 149 | if ( $meta_key != $this_page_name ) { |
| 150 | 150 | return; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | global $frm_vars; |
| 154 | - if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) { |
|
| 154 | + if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) { |
|
| 155 | 155 | return; //don't continue if there's no previous value |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | foreach ( $meta_value as $mk => $mv ) { |
| 159 | 159 | //remove blank values |
| 160 | - if ( empty( $mv ) ) { |
|
| 161 | - unset( $meta_value[ $mk ] ); |
|
| 160 | + if ( empty( $mv ) ) { |
|
| 161 | + unset( $meta_value[$mk] ); |
|
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - $cur_form_prefix = reset($meta_value); |
|
| 166 | - $cur_form_prefix = explode('_', $cur_form_prefix); |
|
| 165 | + $cur_form_prefix = reset( $meta_value ); |
|
| 166 | + $cur_form_prefix = explode( '_', $cur_form_prefix ); |
|
| 167 | 167 | $cur_form_prefix = $cur_form_prefix[0]; |
| 168 | 168 | $save = false; |
| 169 | 169 | |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | |
| 183 | 183 | $meta_value[] = $prev_hidden; |
| 184 | 184 | $save = true; |
| 185 | - unset($form_prefix); |
|
| 185 | + unset( $form_prefix ); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | if ( $save ) { |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | foreach ( $fields as $field ) { |
| 215 | 215 | if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) { |
| 216 | 216 | // Can't sort on checkboxes because they are stored serialized, or post fields |
| 217 | - $columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id; |
|
| 217 | + $columns[$form_id . '_' . $field->field_key] = 'meta_' . $field->id; |
|
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | break; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - unset($form_prefix); |
|
| 240 | + unset( $form_prefix ); |
|
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | 243 | |
@@ -245,36 +245,36 @@ discard block |
||
| 245 | 245 | return $result; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0; |
|
| 248 | + $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0; |
|
| 249 | 249 | $max_columns = 8; |
| 250 | 250 | if ( $i <= $max_columns ) { |
| 251 | 251 | return $result; |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | global $frm_vars; |
| 255 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) { |
|
| 256 | - $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options); |
|
| 255 | + if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] ) { |
|
| 256 | + $frm_vars['current_form']->options = maybe_unserialize( $frm_vars['current_form']->options ); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) { |
|
| 259 | + if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && isset( $frm_vars['current_form']->options['hidden_cols'] ) && ! empty( $frm_vars['current_form']->options['hidden_cols'] ) ) { |
|
| 260 | 260 | $result = $frm_vars['current_form']->options['hidden_cols']; |
| 261 | 261 | } else { |
| 262 | 262 | $cols = $frm_vars['cols']; |
| 263 | - $cols = array_reverse($cols, true); |
|
| 263 | + $cols = array_reverse( $cols, true ); |
|
| 264 | 264 | |
| 265 | - $result[] = $form_id .'_id'; |
|
| 266 | - $i--; |
|
| 265 | + $result[] = $form_id . '_id'; |
|
| 266 | + $i --; |
|
| 267 | 267 | |
| 268 | - $result[] = $form_id .'_item_key'; |
|
| 269 | - $i--; |
|
| 268 | + $result[] = $form_id . '_item_key'; |
|
| 269 | + $i --; |
|
| 270 | 270 | |
| 271 | 271 | foreach ( $cols as $col_key => $col ) { |
| 272 | 272 | if ( $i > $max_columns ) { |
| 273 | 273 | $result[] = $col_key; |
| 274 | 274 | } |
| 275 | 275 | //remove some columns by default |
| 276 | - $i--; |
|
| 277 | - unset($col_key, $col); |
|
| 276 | + $i --; |
|
| 277 | + unset( $col_key, $col ); |
|
| 278 | 278 | } |
| 279 | 279 | } |
| 280 | 280 | |
@@ -311,23 +311,23 @@ discard block |
||
| 311 | 311 | if ( $pagenum > $total_pages && $total_pages > 0 ) { |
| 312 | 312 | $url = add_query_arg( 'paged', $total_pages ); |
| 313 | 313 | if ( headers_sent() ) { |
| 314 | - echo FrmAppHelper::js_redirect($url); |
|
| 314 | + echo FrmAppHelper::js_redirect( $url ); |
|
| 315 | 315 | } else { |
| 316 | 316 | wp_redirect( esc_url_raw( $url ) ); |
| 317 | 317 | } |
| 318 | 318 | die(); |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - if ( empty($message) && isset($_GET['import-message']) ) { |
|
| 321 | + if ( empty( $message ) && isset( $_GET['import-message'] ) ) { |
|
| 322 | 322 | $message = __( 'Your import is complete', 'formidable' ); |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/list.php'); |
|
| 325 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' ); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | /* Back End CRUD */ |
| 329 | 329 | public static function show( $id = 0 ) { |
| 330 | - FrmAppHelper::permission_check('frm_view_entries'); |
|
| 330 | + FrmAppHelper::permission_check( 'frm_view_entries' ); |
|
| 331 | 331 | |
| 332 | 332 | if ( ! $id ) { |
| 333 | 333 | $id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' ); |
@@ -337,9 +337,9 @@ discard block |
||
| 337 | 337 | } |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - $entry = FrmEntry::getOne($id, true); |
|
| 340 | + $entry = FrmEntry::getOne( $id, true ); |
|
| 341 | 341 | |
| 342 | - $data = maybe_unserialize($entry->description); |
|
| 342 | + $data = maybe_unserialize( $entry->description ); |
|
| 343 | 343 | if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) { |
| 344 | 344 | $data = array( 'referrer' => $data ); |
| 345 | 345 | } |
@@ -347,18 +347,18 @@ discard block |
||
| 347 | 347 | $fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' ); |
| 348 | 348 | $to_emails = array(); |
| 349 | 349 | |
| 350 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/show.php'); |
|
| 350 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' ); |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | public static function destroy() { |
| 354 | - FrmAppHelper::permission_check('frm_delete_entries'); |
|
| 354 | + FrmAppHelper::permission_check( 'frm_delete_entries' ); |
|
| 355 | 355 | |
| 356 | 356 | $params = FrmForm::get_admin_params(); |
| 357 | 357 | |
| 358 | - if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
| 358 | + if ( isset( $params['keep_post'] ) && $params['keep_post'] ) { |
|
| 359 | 359 | //unlink entry from post |
| 360 | 360 | global $wpdb; |
| 361 | - $wpdb->update( $wpdb->prefix .'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) ); |
|
| 361 | + $wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) ); |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | $message = ''; |
@@ -433,9 +433,9 @@ discard block |
||
| 433 | 433 | if ( ! isset( $frm_vars['form_params'] ) ) { |
| 434 | 434 | $frm_vars['form_params'] = array(); |
| 435 | 435 | } |
| 436 | - $frm_vars['form_params'][ $form->id ] = $params; |
|
| 436 | + $frm_vars['form_params'][$form->id] = $params; |
|
| 437 | 437 | |
| 438 | - if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) { |
|
| 438 | + if ( isset( $frm_vars['created_entries'][$form_id] ) ) { |
|
| 439 | 439 | return; |
| 440 | 440 | } |
| 441 | 441 | |
@@ -450,13 +450,13 @@ discard block |
||
| 450 | 450 | */ |
| 451 | 451 | $errors = apply_filters( 'frm_entries_before_create', $errors, $form ); |
| 452 | 452 | |
| 453 | - $frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors ); |
|
| 453 | + $frm_vars['created_entries'][$form_id] = array( 'errors' => $errors ); |
|
| 454 | 454 | |
| 455 | 455 | if ( empty( $errors ) ) { |
| 456 | 456 | $_POST['frm_skip_cookie'] = 1; |
| 457 | 457 | if ( $params['action'] == 'create' ) { |
| 458 | - if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) { |
|
| 459 | - $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); |
|
| 458 | + if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) { |
|
| 459 | + $frm_vars['created_entries'][$form_id]['entry_id'] = FrmEntry::create( $_POST ); |
|
| 460 | 460 | } |
| 461 | 461 | } |
| 462 | 462 | |
@@ -491,28 +491,28 @@ discard block |
||
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) { |
| 494 | - $field = FrmField::getOne($meta->field_id); |
|
| 494 | + $field = FrmField::getOne( $meta->field_id ); |
|
| 495 | 495 | if ( ! $field ) { |
| 496 | 496 | return $value; |
| 497 | 497 | } |
| 498 | 498 | |
| 499 | - $value = self::filter_display_value($value, $field, $atts); |
|
| 499 | + $value = self::filter_display_value( $value, $field, $atts ); |
|
| 500 | 500 | return $value; |
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | public static function &filter_shortcode_value( $value, $tag, $atts, $field ) { |
| 504 | - $plain_text = add_filter('frm_plain_text_email', true); |
|
| 504 | + $plain_text = add_filter( 'frm_plain_text_email', true ); |
|
| 505 | 505 | FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value ); |
| 506 | 506 | |
| 507 | - if ( isset($atts['show']) && $atts['show'] == 'value' ) { |
|
| 507 | + if ( isset( $atts['show'] ) && $atts['show'] == 'value' ) { |
|
| 508 | 508 | return $value; |
| 509 | 509 | } |
| 510 | 510 | |
| 511 | - return self::filter_display_value($value, $field, $atts); |
|
| 511 | + return self::filter_display_value( $value, $field, $atts ); |
|
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | public static function &filter_display_value( $value, $field, $atts = array() ) { |
| 515 | - $saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false; |
|
| 515 | + $saved_value = ( isset( $atts['saved_value'] ) && $atts['saved_value'] ) ? true : false; |
|
| 516 | 516 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'radio', 'select' ) ) || ! FrmField::is_option_true( $field, 'separate_value' ) || $saved_value ) { |
| 517 | 517 | return $value; |
| 518 | 518 | } |
@@ -520,29 +520,29 @@ discard block |
||
| 520 | 520 | $f_values = $f_labels = array(); |
| 521 | 521 | |
| 522 | 522 | foreach ( $field->options as $opt_key => $opt ) { |
| 523 | - if ( ! is_array($opt) ) { |
|
| 523 | + if ( ! is_array( $opt ) ) { |
|
| 524 | 524 | continue; |
| 525 | 525 | } |
| 526 | 526 | |
| 527 | - $f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt); |
|
| 528 | - $f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ]; |
|
| 529 | - if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) { |
|
| 530 | - unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] ); |
|
| 527 | + $f_labels[$opt_key] = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
| 528 | + $f_values[$opt_key] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[$opt_key]; |
|
| 529 | + if ( $f_labels[$opt_key] == $f_values[$opt_key] ) { |
|
| 530 | + unset( $f_values[$opt_key], $f_labels[$opt_key] ); |
|
| 531 | 531 | } |
| 532 | - unset($opt_key, $opt); |
|
| 532 | + unset( $opt_key, $opt ); |
|
| 533 | 533 | } |
| 534 | 534 | |
| 535 | - if ( ! empty($f_values) ) { |
|
| 535 | + if ( ! empty( $f_values ) ) { |
|
| 536 | 536 | foreach ( (array) $value as $v_key => $val ) { |
| 537 | - if ( in_array($val, $f_values) ) { |
|
| 538 | - $opt = array_search($val, $f_values); |
|
| 539 | - if ( is_array($value) ) { |
|
| 540 | - $value[ $v_key ] = $f_labels[ $opt ]; |
|
| 537 | + if ( in_array( $val, $f_values ) ) { |
|
| 538 | + $opt = array_search( $val, $f_values ); |
|
| 539 | + if ( is_array( $value ) ) { |
|
| 540 | + $value[$v_key] = $f_labels[$opt]; |
|
| 541 | 541 | } else { |
| 542 | - $value = $f_labels[ $opt ]; |
|
| 542 | + $value = $f_labels[$opt]; |
|
| 543 | 543 | } |
| 544 | 544 | } |
| 545 | - unset($v_key, $val); |
|
| 545 | + unset( $v_key, $val ); |
|
| 546 | 546 | } |
| 547 | 547 | } |
| 548 | 548 | |
@@ -555,13 +555,13 @@ discard block |
||
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | public static function entry_sidebar( $entry ) { |
| 558 | - $data = maybe_unserialize($entry->description); |
|
| 559 | - $date_format = get_option('date_format'); |
|
| 560 | - $time_format = get_option('time_format'); |
|
| 558 | + $data = maybe_unserialize( $entry->description ); |
|
| 559 | + $date_format = get_option( 'date_format' ); |
|
| 560 | + $time_format = get_option( 'time_format' ); |
|
| 561 | 561 | if ( isset( $data['browser'] ) ) { |
| 562 | 562 | $browser = FrmEntryFormat::get_browser( $data['browser'] ); |
| 563 | 563 | } |
| 564 | 564 | |
| 565 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/sidebar-shared.php'); |
|
| 565 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' ); |
|
| 566 | 566 | } |
| 567 | 567 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 8 | 8 | $menu_label .= ' (Lite)'; |
| 9 | 9 | } |
| 10 | - add_submenu_page('formidable', 'Formidable | '. $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' ); |
|
| 10 | + add_submenu_page( 'formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' ); |
|
| 11 | 11 | |
| 12 | 12 | self::maybe_load_listing_hooks(); |
| 13 | 13 | } |
@@ -18,14 +18,14 @@ discard block |
||
| 18 | 18 | return; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - add_filter('get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' ); |
|
| 21 | + add_filter( 'get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' ); |
|
| 22 | 22 | |
| 23 | - add_filter('manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 ); |
|
| 24 | - add_filter('manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' ); |
|
| 23 | + add_filter( 'manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 ); |
|
| 24 | + add_filter( 'manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' ); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | public static function head() { |
| 28 | - wp_enqueue_script('formidable-editinplace'); |
|
| 28 | + wp_enqueue_script( 'formidable-editinplace' ); |
|
| 29 | 29 | |
| 30 | 30 | if ( wp_is_mobile() ) { |
| 31 | 31 | wp_enqueue_script( 'jquery-touch-punch' ); |
@@ -33,49 +33,49 @@ discard block |
||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public static function register_widgets() { |
| 36 | - require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php'); |
|
| 37 | - register_widget('FrmShowForm'); |
|
| 36 | + require_once( FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php' ); |
|
| 37 | + register_widget( 'FrmShowForm' ); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | public static function list_form() { |
| 41 | - FrmAppHelper::permission_check('frm_view_forms'); |
|
| 41 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 42 | 42 | |
| 43 | 43 | $params = FrmForm::list_page_params(); |
| 44 | - $errors = self::process_bulk_form_actions( array()); |
|
| 45 | - $errors = apply_filters('frm_admin_list_form_action', $errors); |
|
| 44 | + $errors = self::process_bulk_form_actions( array() ); |
|
| 45 | + $errors = apply_filters( 'frm_admin_list_form_action', $errors ); |
|
| 46 | 46 | |
| 47 | 47 | return self::display_forms_list( $params, '', $errors ); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | public static function new_form( $values = array() ) { |
| 51 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 51 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 52 | 52 | |
| 53 | 53 | global $frm_vars; |
| 54 | 54 | |
| 55 | - $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 56 | - $action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ]; |
|
| 55 | + $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
| 56 | + $action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[$action]; |
|
| 57 | 57 | |
| 58 | 58 | if ( $action == 'create' ) { |
| 59 | - return self::create($values); |
|
| 59 | + return self::create( $values ); |
|
| 60 | 60 | } else if ( $action == 'new' ) { |
| 61 | 61 | $frm_field_selection = FrmField::field_selection(); |
| 62 | - $values = FrmFormsHelper::setup_new_vars($values); |
|
| 62 | + $values = FrmFormsHelper::setup_new_vars( $values ); |
|
| 63 | 63 | $id = FrmForm::create( $values ); |
| 64 | - $form = FrmForm::getOne($id); |
|
| 64 | + $form = FrmForm::getOne( $id ); |
|
| 65 | 65 | |
| 66 | 66 | // add default email notification |
| 67 | 67 | $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
| 68 | - $action_control->create($form->id); |
|
| 68 | + $action_control->create( $form->id ); |
|
| 69 | 69 | |
| 70 | 70 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 71 | 71 | |
| 72 | 72 | $values['id'] = $id; |
| 73 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php'); |
|
| 73 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
|
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | public static function create( $values = array() ) { |
| 78 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 78 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 79 | 79 | |
| 80 | 80 | global $frm_vars; |
| 81 | 81 | if ( empty( $values ) ) { |
@@ -87,58 +87,58 @@ discard block |
||
| 87 | 87 | $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - $id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
|
| 90 | + $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
|
| 91 | 91 | |
| 92 | 92 | if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) { |
| 93 | 93 | $frm_settings = FrmAppHelper::get_settings(); |
| 94 | 94 | $errors = array( 'form' => $frm_settings->admin_permission ); |
| 95 | 95 | } else { |
| 96 | - $errors = FrmForm::validate($values); |
|
| 96 | + $errors = FrmForm::validate( $values ); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - if ( count($errors) > 0 ) { |
|
| 99 | + if ( count( $errors ) > 0 ) { |
|
| 100 | 100 | $hide_preview = true; |
| 101 | 101 | $frm_field_selection = FrmField::field_selection(); |
| 102 | 102 | $form = FrmForm::getOne( $id ); |
| 103 | - $fields = FrmField::get_all_for_form($id); |
|
| 103 | + $fields = FrmField::get_all_for_form( $id ); |
|
| 104 | 104 | |
| 105 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 105 | + $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true ); |
|
| 106 | 106 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 107 | 107 | |
| 108 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php'); |
|
| 108 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
|
| 109 | 109 | } else { |
| 110 | 110 | FrmForm::update( $id, $values, true ); |
| 111 | - die(FrmAppHelper::js_redirect(admin_url('admin.php?page=formidable&frm_action=settings&id='. $id))); |
|
| 111 | + die( FrmAppHelper::js_redirect( admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . $id ) ) ); |
|
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | public static function edit( $values = false ) { |
| 116 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 116 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 117 | 117 | |
| 118 | 118 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 119 | - return self::get_edit_vars($id); |
|
| 119 | + return self::get_edit_vars( $id ); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | public static function settings( $id = false, $message = '' ) { |
| 123 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 123 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 124 | 124 | |
| 125 | - if ( ! $id || ! is_numeric($id) ) { |
|
| 125 | + if ( ! $id || ! is_numeric( $id ) ) { |
|
| 126 | 126 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 127 | 127 | } |
| 128 | 128 | return self::get_settings_vars( $id, array(), $message ); |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | public static function update_settings() { |
| 132 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 132 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 133 | 133 | |
| 134 | 134 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 135 | 135 | |
| 136 | - $errors = FrmForm::validate($_POST); |
|
| 137 | - if ( count($errors) > 0 ) { |
|
| 138 | - return self::get_settings_vars($id, $errors); |
|
| 136 | + $errors = FrmForm::validate( $_POST ); |
|
| 137 | + if ( count( $errors ) > 0 ) { |
|
| 138 | + return self::get_settings_vars( $id, $errors ); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - do_action('frm_before_update_form_settings', $id); |
|
| 141 | + do_action( 'frm_before_update_form_settings', $id ); |
|
| 142 | 142 | |
| 143 | 143 | FrmForm::update( $id, $_POST ); |
| 144 | 144 | |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | private static function edit_in_place_value( $field ) { |
| 162 | 162 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 163 | - FrmAppHelper::permission_check('frm_edit_forms', 'hide'); |
|
| 163 | + FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
| 164 | 164 | |
| 165 | 165 | $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' ); |
| 166 | 166 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_filter_post_kses' ); |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | * @since 2.0 |
| 219 | 219 | */ |
| 220 | 220 | public static function _create_from_template() { |
| 221 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 221 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 222 | 222 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 223 | 223 | |
| 224 | 224 | $current_form = FrmAppHelper::get_param( 'this_form', '', 'get', 'absint' ); |
@@ -233,15 +233,15 @@ discard block |
||
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | public static function duplicate() { |
| 236 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 236 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 237 | 237 | |
| 238 | 238 | $params = FrmForm::list_page_params(); |
| 239 | 239 | $form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
| 240 | - $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
| 240 | + $message = ( $params['template'] ) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
| 241 | 241 | if ( $form ) { |
| 242 | 242 | return self::get_edit_vars( $form, array(), $message, true ); |
| 243 | 243 | } else { |
| 244 | - return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' )); |
|
| 244 | + return self::display_forms_list( $params, __( 'There was a problem creating the new template.', 'formidable' ) ); |
|
| 245 | 245 | } |
| 246 | 246 | } |
| 247 | 247 | |
@@ -267,14 +267,14 @@ discard block |
||
| 267 | 267 | if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) { |
| 268 | 268 | global $wp; |
| 269 | 269 | $root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ); |
| 270 | - include_once( $root.'/wp-config.php' ); |
|
| 270 | + include_once( $root . '/wp-config.php' ); |
|
| 271 | 271 | $wp->init(); |
| 272 | 272 | $wp->register_globals(); |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | self::register_pro_scripts(); |
| 276 | 276 | |
| 277 | - header( 'Content-Type: text/html; charset='. get_option( 'blog_charset' ) ); |
|
| 277 | + header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
| 278 | 278 | |
| 279 | 279 | $key = FrmAppHelper::simple_get( 'form', 'sanitize_title' ); |
| 280 | 280 | if ( $key == '' ) { |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | $form = FrmForm::getAll( array(), '', 1 ); |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/direct.php'); |
|
| 289 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' ); |
|
| 290 | 290 | wp_die(); |
| 291 | 291 | } |
| 292 | 292 | |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | if ( FrmAppHelper::pro_is_installed() ) { |
| 295 | 295 | wp_register_script( 'jquery-frm-rating', FrmAppHelper::plugin_url() . '/pro/js/jquery.rating.min.js', array( 'jquery' ), '4.11', true ); |
| 296 | 296 | wp_register_script( 'jquery-maskedinput', FrmAppHelper::plugin_url() . '/pro/js/jquery.maskedinput.min.js', array( 'jquery' ), '1.4', true ); |
| 297 | - wp_register_script( 'jquery-chosen', FrmAppHelper::plugin_url() .'/pro/js/chosen.jquery.min.js', array( 'jquery' ), '1.2.0', true ); |
|
| 297 | + wp_register_script( 'jquery-chosen', FrmAppHelper::plugin_url() . '/pro/js/chosen.jquery.min.js', array( 'jquery' ), '1.2.0', true ); |
|
| 298 | 298 | } |
| 299 | 299 | } |
| 300 | 300 | |
@@ -303,11 +303,11 @@ discard block |
||
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | public static function bulk_untrash( $ids ) { |
| 306 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 306 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 307 | 307 | |
| 308 | 308 | $count = FrmForm::set_status( $ids, 'published' ); |
| 309 | 309 | |
| 310 | - $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
| 310 | + $message = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
| 311 | 311 | return $message; |
| 312 | 312 | } |
| 313 | 313 | |
@@ -326,90 +326,90 @@ discard block |
||
| 326 | 326 | 'trash' => array( 'permission' => 'frm_delete_forms', 'new_status' => 'trash' ), |
| 327 | 327 | ); |
| 328 | 328 | |
| 329 | - if ( ! isset( $available_status[ $status ] ) ) { |
|
| 329 | + if ( ! isset( $available_status[$status] ) ) { |
|
| 330 | 330 | return; |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - FrmAppHelper::permission_check( $available_status[ $status ]['permission'] ); |
|
| 333 | + FrmAppHelper::permission_check( $available_status[$status]['permission'] ); |
|
| 334 | 334 | |
| 335 | 335 | $params = FrmForm::list_page_params(); |
| 336 | 336 | |
| 337 | 337 | //check nonce url |
| 338 | - check_admin_referer($status .'_form_' . $params['id']); |
|
| 338 | + check_admin_referer( $status . '_form_' . $params['id'] ); |
|
| 339 | 339 | |
| 340 | 340 | $count = 0; |
| 341 | - if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) { |
|
| 342 | - $count++; |
|
| 341 | + if ( FrmForm::set_status( $params['id'], $available_status[$status]['new_status'] ) ) { |
|
| 342 | + $count ++; |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | - $available_status['untrash']['message'] = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count ); |
|
| 346 | - $available_status['trash']['message'] = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=untrash&form_type='. ( isset( $_REQUEST['form_type'] ) ? sanitize_title( $_REQUEST['form_type'] ) : '' ) . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' ); |
|
| 345 | + $available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count ); |
|
| 346 | + $available_status['trash']['message'] = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=untrash&form_type=' . ( isset( $_REQUEST['form_type'] ) ? sanitize_title( $_REQUEST['form_type'] ) : '' ) . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' ); |
|
| 347 | 347 | |
| 348 | - $message = $available_status[ $status ]['message']; |
|
| 348 | + $message = $available_status[$status]['message']; |
|
| 349 | 349 | |
| 350 | 350 | self::display_forms_list( $params, $message ); |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | public static function bulk_trash( $ids ) { |
| 354 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 354 | + FrmAppHelper::permission_check( 'frm_delete_forms' ); |
|
| 355 | 355 | |
| 356 | 356 | $count = 0; |
| 357 | 357 | foreach ( $ids as $id ) { |
| 358 | 358 | if ( FrmForm::trash( $id ) ) { |
| 359 | - $count++; |
|
| 359 | + $count ++; |
|
| 360 | 360 | } |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
| 364 | - $message = sprintf(_n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="'. esc_url(wp_nonce_url( '?page=formidable&frm_action=list&action=bulk_untrash&form_type='. $current_page .'&item-action[]='. implode('item-action[]=', $ids), 'bulk-toplevel_page_formidable' )) .'">', '</a>' ); |
|
| 364 | + $message = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=list&action=bulk_untrash&form_type=' . $current_page . '&item-action[]=' . implode( 'item-action[]=', $ids ), 'bulk-toplevel_page_formidable' ) ) . '">', '</a>' ); |
|
| 365 | 365 | |
| 366 | 366 | return $message; |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | public static function destroy() { |
| 370 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 370 | + FrmAppHelper::permission_check( 'frm_delete_forms' ); |
|
| 371 | 371 | |
| 372 | 372 | $params = FrmForm::list_page_params(); |
| 373 | 373 | |
| 374 | 374 | //check nonce url |
| 375 | - check_admin_referer('destroy_form_' . $params['id']); |
|
| 375 | + check_admin_referer( 'destroy_form_' . $params['id'] ); |
|
| 376 | 376 | |
| 377 | 377 | $count = 0; |
| 378 | 378 | if ( FrmForm::destroy( $params['id'] ) ) { |
| 379 | - $count++; |
|
| 379 | + $count ++; |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 382 | + $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
|
| 383 | 383 | |
| 384 | 384 | self::display_forms_list( $params, $message ); |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | public static function bulk_destroy( $ids ) { |
| 388 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 388 | + FrmAppHelper::permission_check( 'frm_delete_forms' ); |
|
| 389 | 389 | |
| 390 | 390 | $count = 0; |
| 391 | 391 | foreach ( $ids as $id ) { |
| 392 | 392 | $d = FrmForm::destroy( $id ); |
| 393 | 393 | if ( $d ) { |
| 394 | - $count++; |
|
| 394 | + $count ++; |
|
| 395 | 395 | } |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 398 | + $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
|
| 399 | 399 | |
| 400 | 400 | return $message; |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | private static function delete_all() { |
| 404 | 404 | //check nonce url |
| 405 | - $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable'); |
|
| 405 | + $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
| 406 | 406 | if ( $permission_error !== false ) { |
| 407 | 407 | self::display_forms_list( array(), '', array( $permission_error ) ); |
| 408 | 408 | return; |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | $count = FrmForm::scheduled_delete( time() ); |
| 412 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 412 | + $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
|
| 413 | 413 | |
| 414 | 414 | self::display_forms_list( array(), $message ); |
| 415 | 415 | } |
@@ -426,11 +426,11 @@ discard block |
||
| 426 | 426 | * @since 2.0.15 |
| 427 | 427 | */ |
| 428 | 428 | public static function insert_form_button() { |
| 429 | - if ( current_user_can('frm_view_forms') ) { |
|
| 429 | + if ( current_user_can( 'frm_view_forms' ) ) { |
|
| 430 | 430 | $menu_name = FrmAppHelper::get_menu_name(); |
| 431 | 431 | $content = '<a href="#TB_inline?width=50&height=50&inlineId=frm_insert_form" class="thickbox button add_media frm_insert_form" title="' . esc_attr__( 'Add forms and content', 'formidable' ) . '"> |
| 432 | 432 | <span class="frm-buttons-icon wp-media-buttons-icon"></span> '. |
| 433 | - $menu_name .'</a>'; |
|
| 433 | + $menu_name . '</a>'; |
|
| 434 | 434 | echo wp_kses_post( $content ); |
| 435 | 435 | } |
| 436 | 436 | } |
@@ -447,22 +447,22 @@ discard block |
||
| 447 | 447 | 'formidable' => array( 'name' => __( 'Form', 'formidable' ), 'label' => __( 'Insert a Form', 'formidable' ) ), |
| 448 | 448 | ); |
| 449 | 449 | |
| 450 | - $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes); |
|
| 450 | + $shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes ); |
|
| 451 | 451 | |
| 452 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/insert_form_popup.php'); |
|
| 452 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' ); |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | public static function get_shortcode_opts() { |
| 456 | - FrmAppHelper::permission_check('frm_view_forms'); |
|
| 456 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 457 | 457 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 458 | 458 | |
| 459 | 459 | $shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' ); |
| 460 | - if ( empty($shortcode) ) { |
|
| 460 | + if ( empty( $shortcode ) ) { |
|
| 461 | 461 | wp_die(); |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | - echo '<div id="sc-opts-'. esc_attr( $shortcode ) .'" class="frm_shortcode_option">'; |
|
| 465 | - echo '<input type="radio" name="frmsc" value="'. esc_attr($shortcode) .'" id="sc-'. esc_attr($shortcode) .'" class="frm_hidden" />'; |
|
| 464 | + echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">'; |
|
| 465 | + echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />'; |
|
| 466 | 466 | |
| 467 | 467 | $form_id = ''; |
| 468 | 468 | $opts = array(); |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | ); |
| 478 | 478 | break; |
| 479 | 479 | } |
| 480 | - $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode); |
|
| 480 | + $opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode ); |
|
| 481 | 481 | |
| 482 | 482 | if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) { |
| 483 | 483 | // allow other shortcodes to use the required form id option |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | unset( $opts['form_id'] ); |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/shortcode_opts.php'); |
|
| 488 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' ); |
|
| 489 | 489 | |
| 490 | 490 | echo '</div>'; |
| 491 | 491 | |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | die(); |
| 518 | 518 | } |
| 519 | 519 | |
| 520 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/list.php'); |
|
| 520 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' ); |
|
| 521 | 521 | } |
| 522 | 522 | |
| 523 | 523 | public static function get_columns( $columns ) { |
@@ -594,11 +594,11 @@ discard block |
||
| 594 | 594 | } |
| 595 | 595 | |
| 596 | 596 | if ( $form->parent_form_id ) { |
| 597 | - wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="'. esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id='. $form->parent_form_id ) ) . '">', '</a>' )); |
|
| 597 | + wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' ) ); |
|
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | $frm_field_selection = FrmField::field_selection(); |
| 601 | - $fields = FrmField::get_all_for_form($form->id); |
|
| 601 | + $fields = FrmField::get_all_for_form( $form->id ); |
|
| 602 | 602 | |
| 603 | 603 | // Automatically add end section fields if they don't exist (2.0 migration) |
| 604 | 604 | $reset_fields = false; |
@@ -608,9 +608,9 @@ discard block |
||
| 608 | 608 | $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | - unset($end_section_values, $last_order, $open, $reset_fields); |
|
| 611 | + unset( $end_section_values, $last_order, $open, $reset_fields ); |
|
| 612 | 612 | |
| 613 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 613 | + $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true ); |
|
| 614 | 614 | |
| 615 | 615 | $edit_message = __( 'Form was Successfully Updated', 'formidable' ); |
| 616 | 616 | if ( $form->is_template && $message == $edit_message ) { |
@@ -620,13 +620,13 @@ discard block |
||
| 620 | 620 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 621 | 621 | |
| 622 | 622 | if ( $form->default_template ) { |
| 623 | - wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 624 | - } else if ( defined('DOING_AJAX') ) { |
|
| 623 | + wp_die( __( 'That template cannot be edited', 'formidable' ) ); |
|
| 624 | + } else if ( defined( 'DOING_AJAX' ) ) { |
|
| 625 | 625 | wp_die(); |
| 626 | 626 | } else if ( $create_link ) { |
| 627 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php'); |
|
| 627 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
|
| 628 | 628 | } else { |
| 629 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/edit.php'); |
|
| 629 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' ); |
|
| 630 | 630 | } |
| 631 | 631 | } |
| 632 | 632 | |
@@ -637,28 +637,28 @@ discard block |
||
| 637 | 637 | |
| 638 | 638 | $form = FrmForm::getOne( $id ); |
| 639 | 639 | |
| 640 | - $fields = FrmField::get_all_for_form($id); |
|
| 641 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 640 | + $fields = FrmField::get_all_for_form( $id ); |
|
| 641 | + $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true ); |
|
| 642 | 642 | |
| 643 | - if ( isset($values['default_template']) && $values['default_template'] ) { |
|
| 644 | - wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 643 | + if ( isset( $values['default_template'] ) && $values['default_template'] ) { |
|
| 644 | + wp_die( __( 'That template cannot be edited', 'formidable' ) ); |
|
| 645 | 645 | } |
| 646 | 646 | |
| 647 | 647 | $action_controls = FrmFormActionsController::get_form_actions(); |
| 648 | 648 | |
| 649 | - $sections = apply_filters('frm_add_form_settings_section', array(), $values); |
|
| 649 | + $sections = apply_filters( 'frm_add_form_settings_section', array(), $values ); |
|
| 650 | 650 | $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
| 651 | 651 | |
| 652 | - $styles = apply_filters('frm_get_style_opts', array()); |
|
| 652 | + $styles = apply_filters( 'frm_get_style_opts', array() ); |
|
| 653 | 653 | |
| 654 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/settings.php'); |
|
| 654 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' ); |
|
| 655 | 655 | } |
| 656 | 656 | |
| 657 | 657 | public static function mb_tags_box( $form_id, $class = '' ) { |
| 658 | - $fields = FrmField::get_all_for_form($form_id, '', 'include'); |
|
| 658 | + $fields = FrmField::get_all_for_form( $form_id, '', 'include' ); |
|
| 659 | 659 | $linked_forms = array(); |
| 660 | 660 | $col = 'one'; |
| 661 | - $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false; |
|
| 661 | + $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false; |
|
| 662 | 662 | |
| 663 | 663 | $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() ); |
| 664 | 664 | $adv_shortcodes = self::get_advanced_shortcodes(); |
@@ -736,13 +736,13 @@ discard block |
||
| 736 | 736 | |
| 737 | 737 | // Insert the form class setting into the form |
| 738 | 738 | public static function form_classes( $form ) { |
| 739 | - if ( isset($form->options['form_class']) ) { |
|
| 739 | + if ( isset( $form->options['form_class'] ) ) { |
|
| 740 | 740 | echo esc_attr( sanitize_text_field( $form->options['form_class'] ) ); |
| 741 | 741 | } |
| 742 | 742 | } |
| 743 | 743 | |
| 744 | 744 | public static function get_email_html() { |
| 745 | - FrmAppHelper::permission_check('frm_view_forms'); |
|
| 745 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 746 | 746 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 747 | 747 | echo FrmEntryFormat::show_entry( array( |
| 748 | 748 | 'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ), |
@@ -839,11 +839,11 @@ discard block |
||
| 839 | 839 | public static function add_default_templates( $path, $default = true, $template = true ) { |
| 840 | 840 | _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' ); |
| 841 | 841 | |
| 842 | - $path = untrailingslashit(trim($path)); |
|
| 843 | - $templates = glob( $path .'/*.php' ); |
|
| 842 | + $path = untrailingslashit( trim( $path ) ); |
|
| 843 | + $templates = glob( $path . '/*.php' ); |
|
| 844 | 844 | |
| 845 | - for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) { |
|
| 846 | - $filename = str_replace( '.php', '', str_replace( $path.'/', '', $templates[ $i ] ) ); |
|
| 845 | + for ( $i = count( $templates ) - 1; $i >= 0; $i -- ) { |
|
| 846 | + $filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[$i] ) ); |
|
| 847 | 847 | $template_query = array( 'form_key' => $filename ); |
| 848 | 848 | if ( $template ) { |
| 849 | 849 | $template_query['is_template'] = 1; |
@@ -861,12 +861,12 @@ discard block |
||
| 861 | 861 | $values['default_template'] = 1; |
| 862 | 862 | } |
| 863 | 863 | |
| 864 | - include( $templates[ $i ] ); |
|
| 864 | + include( $templates[$i] ); |
|
| 865 | 865 | |
| 866 | 866 | //get updated form |
| 867 | - if ( isset($form) && ! empty($form) ) { |
|
| 867 | + if ( isset( $form ) && ! empty( $form ) ) { |
|
| 868 | 868 | $old_id = $form->id; |
| 869 | - $form = FrmForm::getOne($form->id); |
|
| 869 | + $form = FrmForm::getOne( $form->id ); |
|
| 870 | 870 | } else { |
| 871 | 871 | $old_id = false; |
| 872 | 872 | $form = FrmForm::getAll( $template_query, '', 1 ); |
@@ -879,24 +879,24 @@ discard block |
||
| 879 | 879 | } |
| 880 | 880 | |
| 881 | 881 | public static function route() { |
| 882 | - $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 882 | + $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
| 883 | 883 | $vars = array(); |
| 884 | 884 | if ( isset( $_POST['frm_compact_fields'] ) ) { |
| 885 | 885 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 886 | 886 | |
| 887 | - $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('"', '\\\"', $_POST['frm_compact_fields'] )))); |
|
| 888 | - $json_vars = json_decode($json_vars, true); |
|
| 889 | - if ( empty($json_vars) ) { |
|
| 887 | + $json_vars = htmlspecialchars_decode( nl2br( stripslashes( str_replace( '"', '\\\"', $_POST['frm_compact_fields'] ) ) ) ); |
|
| 888 | + $json_vars = json_decode( $json_vars, true ); |
|
| 889 | + if ( empty( $json_vars ) ) { |
|
| 890 | 890 | // json decoding failed so we should return an error message |
| 891 | 891 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 892 | 892 | if ( 'edit' == $action ) { |
| 893 | 893 | $action = 'update'; |
| 894 | 894 | } |
| 895 | 895 | |
| 896 | - add_filter('frm_validate_form', 'FrmFormsController::json_error'); |
|
| 896 | + add_filter( 'frm_validate_form', 'FrmFormsController::json_error' ); |
|
| 897 | 897 | } else { |
| 898 | - $vars = FrmAppHelper::json_to_array($json_vars); |
|
| 899 | - $action = $vars[ $action ]; |
|
| 898 | + $vars = FrmAppHelper::json_to_array( $json_vars ); |
|
| 899 | + $action = $vars[$action]; |
|
| 900 | 900 | unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] ); |
| 901 | 901 | $_REQUEST = array_merge( $_REQUEST, $vars ); |
| 902 | 902 | $_POST = array_merge( $_POST, $_REQUEST ); |
@@ -914,7 +914,7 @@ discard block |
||
| 914 | 914 | |
| 915 | 915 | switch ( $action ) { |
| 916 | 916 | case 'new': |
| 917 | - return self::new_form($vars); |
|
| 917 | + return self::new_form( $vars ); |
|
| 918 | 918 | case 'create': |
| 919 | 919 | case 'edit': |
| 920 | 920 | case 'update': |
@@ -927,8 +927,8 @@ discard block |
||
| 927 | 927 | case 'update_settings': |
| 928 | 928 | return self::$action( $vars ); |
| 929 | 929 | default: |
| 930 | - do_action('frm_form_action_'. $action); |
|
| 931 | - if ( apply_filters('frm_form_stop_action_'. $action, false) ) { |
|
| 930 | + do_action( 'frm_form_action_' . $action ); |
|
| 931 | + if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) { |
|
| 932 | 932 | return; |
| 933 | 933 | } |
| 934 | 934 | |
@@ -937,7 +937,7 @@ discard block |
||
| 937 | 937 | $action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
| 938 | 938 | } |
| 939 | 939 | |
| 940 | - if ( strpos($action, 'bulk_') === 0 ) { |
|
| 940 | + if ( strpos( $action, 'bulk_' ) === 0 ) { |
|
| 941 | 941 | FrmAppHelper::remove_get_action(); |
| 942 | 942 | return self::list_form(); |
| 943 | 943 | } |
@@ -964,37 +964,37 @@ discard block |
||
| 964 | 964 | |
| 965 | 965 | public static function admin_bar_configure() { |
| 966 | 966 | global $frm_vars; |
| 967 | - if ( empty($frm_vars['forms_loaded']) ) { |
|
| 967 | + if ( empty( $frm_vars['forms_loaded'] ) ) { |
|
| 968 | 968 | return; |
| 969 | 969 | } |
| 970 | 970 | |
| 971 | 971 | $actions = array(); |
| 972 | 972 | foreach ( $frm_vars['forms_loaded'] as $form ) { |
| 973 | - if ( is_object($form) ) { |
|
| 974 | - $actions[ $form->id ] = $form->name; |
|
| 973 | + if ( is_object( $form ) ) { |
|
| 974 | + $actions[$form->id] = $form->name; |
|
| 975 | 975 | } |
| 976 | - unset($form); |
|
| 976 | + unset( $form ); |
|
| 977 | 977 | } |
| 978 | 978 | |
| 979 | - if ( empty($actions) ) { |
|
| 979 | + if ( empty( $actions ) ) { |
|
| 980 | 980 | return; |
| 981 | 981 | } |
| 982 | 982 | |
| 983 | - asort($actions); |
|
| 983 | + asort( $actions ); |
|
| 984 | 984 | |
| 985 | 985 | global $wp_admin_bar; |
| 986 | 986 | |
| 987 | - if ( count($actions) == 1 ) { |
|
| 987 | + if ( count( $actions ) == 1 ) { |
|
| 988 | 988 | $wp_admin_bar->add_menu( array( |
| 989 | 989 | 'title' => 'Edit Form', |
| 990 | - 'href' => admin_url('admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) )), |
|
| 990 | + 'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ), |
|
| 991 | 991 | 'id' => 'frm-forms', |
| 992 | 992 | ) ); |
| 993 | 993 | } else { |
| 994 | 994 | $wp_admin_bar->add_menu( array( |
| 995 | 995 | 'id' => 'frm-forms', |
| 996 | 996 | 'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>', |
| 997 | - 'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) ) ), |
|
| 997 | + 'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ), |
|
| 998 | 998 | 'meta' => array( |
| 999 | 999 | 'title' => __( 'Edit Forms', 'formidable' ), |
| 1000 | 1000 | ), |
@@ -1004,8 +1004,8 @@ discard block |
||
| 1004 | 1004 | |
| 1005 | 1005 | $wp_admin_bar->add_menu( array( |
| 1006 | 1006 | 'parent' => 'frm-forms', |
| 1007 | - 'id' => 'edit_form_'. $form_id, |
|
| 1008 | - 'title' => empty($name) ? __( '(no title)') : $name, |
|
| 1007 | + 'id' => 'edit_form_' . $form_id, |
|
| 1008 | + 'title' => empty( $name ) ? __( '(no title)' ) : $name, |
|
| 1009 | 1009 | 'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ), |
| 1010 | 1010 | ) ); |
| 1011 | 1011 | } |
@@ -1015,22 +1015,22 @@ discard block |
||
| 1015 | 1015 | //formidable shortcode |
| 1016 | 1016 | public static function get_form_shortcode( $atts ) { |
| 1017 | 1017 | global $frm_vars; |
| 1018 | - if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) { |
|
| 1018 | + if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) { |
|
| 1019 | 1019 | $sc = '[formidable'; |
| 1020 | 1020 | if ( ! empty( $atts ) ) { |
| 1021 | 1021 | foreach ( $atts as $k => $v ) { |
| 1022 | 1022 | $sc .= ' ' . $k . '="' . esc_attr( $v ) . '"'; |
| 1023 | 1023 | } |
| 1024 | 1024 | } |
| 1025 | - return $sc .']'; |
|
| 1025 | + return $sc . ']'; |
|
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | 1028 | $shortcode_atts = shortcode_atts( array( |
| 1029 | 1029 | 'id' => '', 'key' => '', 'title' => false, 'description' => false, |
| 1030 | 1030 | 'readonly' => false, 'entry_id' => false, 'fields' => array(), |
| 1031 | 1031 | 'exclude_fields' => array(), 'minimize' => false, |
| 1032 | - ), $atts); |
|
| 1033 | - do_action('formidable_shortcode_atts', $shortcode_atts, $atts); |
|
| 1032 | + ), $atts ); |
|
| 1033 | + do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts ); |
|
| 1034 | 1034 | |
| 1035 | 1035 | return self::show_form( |
| 1036 | 1036 | $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], |
@@ -1118,51 +1118,51 @@ discard block |
||
| 1118 | 1118 | |
| 1119 | 1119 | $frm_settings = FrmAppHelper::get_settings(); |
| 1120 | 1120 | |
| 1121 | - $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value; |
|
| 1121 | + $submit = isset( $form->options['submit_value'] ) ? $form->options['submit_value'] : $frm_settings->submit_value; |
|
| 1122 | 1122 | |
| 1123 | 1123 | $user_ID = get_current_user_id(); |
| 1124 | 1124 | $params = FrmForm::get_params( $form ); |
| 1125 | 1125 | $message = $errors = ''; |
| 1126 | 1126 | |
| 1127 | 1127 | if ( $params['posted_form_id'] == $form->id && $_POST ) { |
| 1128 | - $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array(); |
|
| 1128 | + $errors = isset( $frm_vars['created_entries'][$form->id] ) ? $frm_vars['created_entries'][$form->id]['errors'] : array(); |
|
| 1129 | 1129 | } |
| 1130 | 1130 | |
| 1131 | 1131 | $include_form_tag = apply_filters( 'frm_include_form_tag', true, $form ); |
| 1132 | 1132 | $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) ); |
| 1133 | 1133 | |
| 1134 | 1134 | if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) { |
| 1135 | - do_action('frm_display_form_action', $params, $fields, $form, $title, $description); |
|
| 1136 | - if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) { |
|
| 1137 | - $values = FrmEntriesHelper::setup_new_vars($fields, $form); |
|
| 1138 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php'); |
|
| 1135 | + do_action( 'frm_display_form_action', $params, $fields, $form, $title, $description ); |
|
| 1136 | + if ( apply_filters( 'frm_continue_to_new', true, $form->id, $params['action'] ) ) { |
|
| 1137 | + $values = FrmEntriesHelper::setup_new_vars( $fields, $form ); |
|
| 1138 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
|
| 1139 | 1139 | } |
| 1140 | 1140 | return; |
| 1141 | 1141 | } |
| 1142 | 1142 | |
| 1143 | - if ( ! empty($errors) ) { |
|
| 1144 | - $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array(); |
|
| 1145 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php'); |
|
| 1143 | + if ( ! empty( $errors ) ) { |
|
| 1144 | + $values = $fields ? FrmEntriesHelper::setup_new_vars( $fields, $form ) : array(); |
|
| 1145 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
|
| 1146 | 1146 | return; |
| 1147 | 1147 | } |
| 1148 | 1148 | |
| 1149 | - do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description); |
|
| 1150 | - if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) { |
|
| 1149 | + do_action( 'frm_validate_form_creation', $params, $fields, $form, $title, $description ); |
|
| 1150 | + if ( ! apply_filters( 'frm_continue_to_create', true, $form->id ) ) { |
|
| 1151 | 1151 | return; |
| 1152 | 1152 | } |
| 1153 | 1153 | |
| 1154 | - $values = FrmEntriesHelper::setup_new_vars($fields, $form, true); |
|
| 1155 | - $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form->id ] ) ) ? $frm_vars['created_entries'][ $form->id ]['entry_id'] : 0; |
|
| 1156 | - $conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create'); |
|
| 1154 | + $values = FrmEntriesHelper::setup_new_vars( $fields, $form, true ); |
|
| 1155 | + $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][$form->id] ) ) ? $frm_vars['created_entries'][$form->id]['entry_id'] : 0; |
|
| 1156 | + $conf_method = apply_filters( 'frm_success_filter', 'message', $form, $form->options, 'create' ); |
|
| 1157 | 1157 | |
| 1158 | - if ( $created && is_numeric($created) && $conf_method != 'message' ) { |
|
| 1159 | - do_action('frm_success_action', $conf_method, $form, $form->options, $created); |
|
| 1158 | + if ( $created && is_numeric( $created ) && $conf_method != 'message' ) { |
|
| 1159 | + do_action( 'frm_success_action', $conf_method, $form, $form->options, $created ); |
|
| 1160 | 1160 | do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) ); |
| 1161 | 1161 | return; |
| 1162 | 1162 | } |
| 1163 | 1163 | |
| 1164 | - if ( $created && is_numeric($created) ) { |
|
| 1165 | - $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg; |
|
| 1164 | + if ( $created && is_numeric( $created ) ) { |
|
| 1165 | + $message = isset( $form->options['success_msg'] ) ? $form->options['success_msg'] : $frm_settings->success_msg; |
|
| 1166 | 1166 | $class = 'frm_message'; |
| 1167 | 1167 | } else { |
| 1168 | 1168 | $message = $frm_settings->failed_msg; |
@@ -1173,16 +1173,16 @@ discard block |
||
| 1173 | 1173 | 'message' => $message, 'form' => $form, |
| 1174 | 1174 | 'entry_id' => $created, 'class' => $class, |
| 1175 | 1175 | ) ); |
| 1176 | - $message = apply_filters('frm_main_feedback', $message, $form, $created); |
|
| 1176 | + $message = apply_filters( 'frm_main_feedback', $message, $form, $created ); |
|
| 1177 | 1177 | |
| 1178 | - if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) { |
|
| 1179 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php'); |
|
| 1178 | + if ( ! isset( $form->options['show_form'] ) || $form->options['show_form'] ) { |
|
| 1179 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
|
| 1180 | 1180 | } else { |
| 1181 | 1181 | global $frm_vars; |
| 1182 | 1182 | self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] ); |
| 1183 | 1183 | |
| 1184 | - $include_extra_container = 'frm_forms'. FrmFormsHelper::get_form_style_class($values); |
|
| 1185 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/errors.php'); |
|
| 1184 | + $include_extra_container = 'frm_forms' . FrmFormsHelper::get_form_style_class( $values ); |
|
| 1185 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php' ); |
|
| 1186 | 1186 | } |
| 1187 | 1187 | |
| 1188 | 1188 | do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) ); |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmFormsController { |
| 4 | 4 | |
| 5 | - public static function menu() { |
|
| 5 | + public static function menu() { |
|
| 6 | 6 | $menu_label = __( 'Forms', 'formidable' ); |
| 7 | 7 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 8 | 8 | $menu_label .= ' (Lite)'; |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | add_submenu_page('formidable', 'Formidable | '. $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' ); |
| 11 | 11 | |
| 12 | 12 | self::maybe_load_listing_hooks(); |
| 13 | - } |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | 15 | public static function maybe_load_listing_hooks() { |
| 16 | 16 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
@@ -24,127 +24,127 @@ discard block |
||
| 24 | 24 | add_filter('manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' ); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public static function head() { |
|
| 28 | - wp_enqueue_script('formidable-editinplace'); |
|
| 27 | + public static function head() { |
|
| 28 | + wp_enqueue_script('formidable-editinplace'); |
|
| 29 | 29 | |
| 30 | - if ( wp_is_mobile() ) { |
|
| 31 | - wp_enqueue_script( 'jquery-touch-punch' ); |
|
| 32 | - } |
|
| 33 | - } |
|
| 30 | + if ( wp_is_mobile() ) { |
|
| 31 | + wp_enqueue_script( 'jquery-touch-punch' ); |
|
| 32 | + } |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - public static function register_widgets() { |
|
| 36 | - require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php'); |
|
| 37 | - register_widget('FrmShowForm'); |
|
| 38 | - } |
|
| 35 | + public static function register_widgets() { |
|
| 36 | + require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php'); |
|
| 37 | + register_widget('FrmShowForm'); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - public static function list_form() { |
|
| 41 | - FrmAppHelper::permission_check('frm_view_forms'); |
|
| 40 | + public static function list_form() { |
|
| 41 | + FrmAppHelper::permission_check('frm_view_forms'); |
|
| 42 | 42 | |
| 43 | 43 | $params = FrmForm::list_page_params(); |
| 44 | - $errors = self::process_bulk_form_actions( array()); |
|
| 45 | - $errors = apply_filters('frm_admin_list_form_action', $errors); |
|
| 44 | + $errors = self::process_bulk_form_actions( array()); |
|
| 45 | + $errors = apply_filters('frm_admin_list_form_action', $errors); |
|
| 46 | 46 | |
| 47 | 47 | return self::display_forms_list( $params, '', $errors ); |
| 48 | - } |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | public static function new_form( $values = array() ) { |
| 51 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 51 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 52 | 52 | |
| 53 | - global $frm_vars; |
|
| 53 | + global $frm_vars; |
|
| 54 | 54 | |
| 55 | - $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 55 | + $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 56 | 56 | $action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ]; |
| 57 | 57 | |
| 58 | 58 | if ( $action == 'create' ) { |
| 59 | - return self::create($values); |
|
| 59 | + return self::create($values); |
|
| 60 | 60 | } else if ( $action == 'new' ) { |
| 61 | 61 | $frm_field_selection = FrmField::field_selection(); |
| 62 | - $values = FrmFormsHelper::setup_new_vars($values); |
|
| 63 | - $id = FrmForm::create( $values ); |
|
| 64 | - $form = FrmForm::getOne($id); |
|
| 62 | + $values = FrmFormsHelper::setup_new_vars($values); |
|
| 63 | + $id = FrmForm::create( $values ); |
|
| 64 | + $form = FrmForm::getOne($id); |
|
| 65 | 65 | |
| 66 | - // add default email notification |
|
| 67 | - $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
| 68 | - $action_control->create($form->id); |
|
| 66 | + // add default email notification |
|
| 67 | + $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
| 68 | + $action_control->create($form->id); |
|
| 69 | 69 | |
| 70 | 70 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 71 | 71 | |
| 72 | - $values['id'] = $id; |
|
| 73 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php'); |
|
| 74 | - } |
|
| 75 | - } |
|
| 72 | + $values['id'] = $id; |
|
| 73 | + require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php'); |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | 77 | public static function create( $values = array() ) { |
| 78 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 78 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 79 | 79 | |
| 80 | - global $frm_vars; |
|
| 81 | - if ( empty( $values ) ) { |
|
| 82 | - $values = $_POST; |
|
| 83 | - } |
|
| 80 | + global $frm_vars; |
|
| 81 | + if ( empty( $values ) ) { |
|
| 82 | + $values = $_POST; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - //Set radio button and checkbox meta equal to "other" value |
|
| 86 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 87 | - $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 88 | - } |
|
| 85 | + //Set radio button and checkbox meta equal to "other" value |
|
| 86 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 87 | + $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | 90 | $id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 91 | 91 | |
| 92 | - if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) { |
|
| 93 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 94 | - $errors = array( 'form' => $frm_settings->admin_permission ); |
|
| 95 | - } else { |
|
| 96 | - $errors = FrmForm::validate($values); |
|
| 97 | - } |
|
| 92 | + if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) { |
|
| 93 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 94 | + $errors = array( 'form' => $frm_settings->admin_permission ); |
|
| 95 | + } else { |
|
| 96 | + $errors = FrmForm::validate($values); |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - if ( count($errors) > 0 ) { |
|
| 100 | - $hide_preview = true; |
|
| 99 | + if ( count($errors) > 0 ) { |
|
| 100 | + $hide_preview = true; |
|
| 101 | 101 | $frm_field_selection = FrmField::field_selection(); |
| 102 | - $form = FrmForm::getOne( $id ); |
|
| 103 | - $fields = FrmField::get_all_for_form($id); |
|
| 102 | + $form = FrmForm::getOne( $id ); |
|
| 103 | + $fields = FrmField::get_all_for_form($id); |
|
| 104 | 104 | |
| 105 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 105 | + $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 106 | 106 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 107 | 107 | |
| 108 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php'); |
|
| 109 | - } else { |
|
| 110 | - FrmForm::update( $id, $values, true ); |
|
| 111 | - die(FrmAppHelper::js_redirect(admin_url('admin.php?page=formidable&frm_action=settings&id='. $id))); |
|
| 112 | - } |
|
| 113 | - } |
|
| 108 | + require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php'); |
|
| 109 | + } else { |
|
| 110 | + FrmForm::update( $id, $values, true ); |
|
| 111 | + die(FrmAppHelper::js_redirect(admin_url('admin.php?page=formidable&frm_action=settings&id='. $id))); |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - public static function edit( $values = false ) { |
|
| 116 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 115 | + public static function edit( $values = false ) { |
|
| 116 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 117 | 117 | |
| 118 | 118 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 119 | - return self::get_edit_vars($id); |
|
| 120 | - } |
|
| 119 | + return self::get_edit_vars($id); |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - public static function settings( $id = false, $message = '' ) { |
|
| 123 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 122 | + public static function settings( $id = false, $message = '' ) { |
|
| 123 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 124 | 124 | |
| 125 | - if ( ! $id || ! is_numeric($id) ) { |
|
| 125 | + if ( ! $id || ! is_numeric($id) ) { |
|
| 126 | 126 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 127 | - } |
|
| 127 | + } |
|
| 128 | 128 | return self::get_settings_vars( $id, array(), $message ); |
| 129 | - } |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | - public static function update_settings() { |
|
| 132 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 131 | + public static function update_settings() { |
|
| 132 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 133 | 133 | |
| 134 | 134 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 135 | 135 | |
| 136 | - $errors = FrmForm::validate($_POST); |
|
| 137 | - if ( count($errors) > 0 ) { |
|
| 138 | - return self::get_settings_vars($id, $errors); |
|
| 139 | - } |
|
| 136 | + $errors = FrmForm::validate($_POST); |
|
| 137 | + if ( count($errors) > 0 ) { |
|
| 138 | + return self::get_settings_vars($id, $errors); |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | - do_action('frm_before_update_form_settings', $id); |
|
| 141 | + do_action('frm_before_update_form_settings', $id); |
|
| 142 | 142 | |
| 143 | 143 | FrmForm::update( $id, $_POST ); |
| 144 | 144 | |
| 145 | - $message = __( 'Settings Successfully Updated', 'formidable' ); |
|
| 145 | + $message = __( 'Settings Successfully Updated', 'formidable' ); |
|
| 146 | 146 | return self::get_settings_vars( $id, array(), $message ); |
| 147 | - } |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | 149 | public static function edit_key() { |
| 150 | 150 | $values = self::edit_in_place_value( 'form_key' ); |
@@ -174,43 +174,43 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | public static function update( $values = array() ) { |
| 176 | 176 | if ( empty( $values ) ) { |
| 177 | - $values = $_POST; |
|
| 178 | - } |
|
| 177 | + $values = $_POST; |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - //Set radio button and checkbox meta equal to "other" value |
|
| 181 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 182 | - $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 183 | - } |
|
| 180 | + //Set radio button and checkbox meta equal to "other" value |
|
| 181 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 182 | + $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - $errors = FrmForm::validate( $values ); |
|
| 186 | - $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' ); |
|
| 187 | - if ( $permission_error !== false ) { |
|
| 188 | - $errors['form'] = $permission_error; |
|
| 189 | - } |
|
| 185 | + $errors = FrmForm::validate( $values ); |
|
| 186 | + $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' ); |
|
| 187 | + if ( $permission_error !== false ) { |
|
| 188 | + $errors['form'] = $permission_error; |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | 191 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 192 | 192 | |
| 193 | 193 | if ( count( $errors ) > 0 ) { |
| 194 | - return self::get_edit_vars( $id, $errors ); |
|
| 194 | + return self::get_edit_vars( $id, $errors ); |
|
| 195 | 195 | } else { |
| 196 | - FrmForm::update( $id, $values ); |
|
| 197 | - $message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 198 | - if ( defined( 'DOING_AJAX' ) ) { |
|
| 196 | + FrmForm::update( $id, $values ); |
|
| 197 | + $message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 198 | + if ( defined( 'DOING_AJAX' ) ) { |
|
| 199 | 199 | wp_die( $message ); |
| 200 | - } |
|
| 200 | + } |
|
| 201 | 201 | return self::get_edit_vars( $id, array(), $message ); |
| 202 | - } |
|
| 203 | - } |
|
| 202 | + } |
|
| 203 | + } |
|
| 204 | 204 | |
| 205 | - public static function bulk_create_template( $ids ) { |
|
| 206 | - FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 205 | + public static function bulk_create_template( $ids ) { |
|
| 206 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 207 | 207 | |
| 208 | - foreach ( $ids as $id ) { |
|
| 209 | - FrmForm::duplicate( $id, true, true ); |
|
| 210 | - } |
|
| 208 | + foreach ( $ids as $id ) { |
|
| 209 | + FrmForm::duplicate( $id, true, true ); |
|
| 210 | + } |
|
| 211 | 211 | |
| 212 | - return __( 'Form template was Successfully Created', 'formidable' ); |
|
| 213 | - } |
|
| 212 | + return __( 'Form template was Successfully Created', 'formidable' ); |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | 215 | /** |
| 216 | 216 | * Redirect to the url for creating from a template |
@@ -232,45 +232,45 @@ discard block |
||
| 232 | 232 | wp_die(); |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - public static function duplicate() { |
|
| 236 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 235 | + public static function duplicate() { |
|
| 236 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 237 | 237 | |
| 238 | 238 | $params = FrmForm::list_page_params(); |
| 239 | - $form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
|
| 240 | - $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
| 241 | - if ( $form ) { |
|
| 239 | + $form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
|
| 240 | + $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
| 241 | + if ( $form ) { |
|
| 242 | 242 | return self::get_edit_vars( $form, array(), $message, true ); |
| 243 | - } else { |
|
| 244 | - return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' )); |
|
| 245 | - } |
|
| 246 | - } |
|
| 243 | + } else { |
|
| 244 | + return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' )); |
|
| 245 | + } |
|
| 246 | + } |
|
| 247 | 247 | |
| 248 | - public static function page_preview() { |
|
| 248 | + public static function page_preview() { |
|
| 249 | 249 | $params = FrmForm::list_page_params(); |
| 250 | - if ( ! $params['form'] ) { |
|
| 251 | - return; |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - $form = FrmForm::getOne( $params['form'] ); |
|
| 255 | - if ( ! $form ) { |
|
| 256 | - return; |
|
| 257 | - } |
|
| 258 | - return self::show_form( $form->id, '', true, true ); |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - public static function preview() { |
|
| 262 | - do_action( 'frm_wp' ); |
|
| 263 | - |
|
| 264 | - global $frm_vars; |
|
| 265 | - $frm_vars['preview'] = true; |
|
| 266 | - |
|
| 267 | - if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) { |
|
| 268 | - global $wp; |
|
| 269 | - $root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ); |
|
| 270 | - include_once( $root.'/wp-config.php' ); |
|
| 271 | - $wp->init(); |
|
| 272 | - $wp->register_globals(); |
|
| 273 | - } |
|
| 250 | + if ( ! $params['form'] ) { |
|
| 251 | + return; |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + $form = FrmForm::getOne( $params['form'] ); |
|
| 255 | + if ( ! $form ) { |
|
| 256 | + return; |
|
| 257 | + } |
|
| 258 | + return self::show_form( $form->id, '', true, true ); |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + public static function preview() { |
|
| 262 | + do_action( 'frm_wp' ); |
|
| 263 | + |
|
| 264 | + global $frm_vars; |
|
| 265 | + $frm_vars['preview'] = true; |
|
| 266 | + |
|
| 267 | + if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) { |
|
| 268 | + global $wp; |
|
| 269 | + $root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ); |
|
| 270 | + include_once( $root.'/wp-config.php' ); |
|
| 271 | + $wp->init(); |
|
| 272 | + $wp->register_globals(); |
|
| 273 | + } |
|
| 274 | 274 | |
| 275 | 275 | self::register_pro_scripts(); |
| 276 | 276 | |
@@ -284,11 +284,11 @@ discard block |
||
| 284 | 284 | $form = FrmForm::getAll( array( 'form_key' => $key ), '', 1 ); |
| 285 | 285 | if ( empty( $form ) ) { |
| 286 | 286 | $form = FrmForm::getAll( array(), '', 1 ); |
| 287 | - } |
|
| 287 | + } |
|
| 288 | 288 | |
| 289 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/direct.php'); |
|
| 290 | - wp_die(); |
|
| 291 | - } |
|
| 289 | + require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/direct.php'); |
|
| 290 | + wp_die(); |
|
| 291 | + } |
|
| 292 | 292 | |
| 293 | 293 | public static function register_pro_scripts() { |
| 294 | 294 | if ( FrmAppHelper::pro_is_installed() ) { |
@@ -298,22 +298,22 @@ discard block |
||
| 298 | 298 | } |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - public static function untrash() { |
|
| 301 | + public static function untrash() { |
|
| 302 | 302 | self::change_form_status( 'untrash' ); |
| 303 | - } |
|
| 303 | + } |
|
| 304 | 304 | |
| 305 | 305 | public static function bulk_untrash( $ids ) { |
| 306 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 306 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 307 | 307 | |
| 308 | - $count = FrmForm::set_status( $ids, 'published' ); |
|
| 308 | + $count = FrmForm::set_status( $ids, 'published' ); |
|
| 309 | 309 | |
| 310 | - $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
| 311 | - return $message; |
|
| 312 | - } |
|
| 310 | + $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
| 311 | + return $message; |
|
| 312 | + } |
|
| 313 | 313 | |
| 314 | - public static function trash() { |
|
| 314 | + public static function trash() { |
|
| 315 | 315 | self::change_form_status( 'trash' ); |
| 316 | - } |
|
| 316 | + } |
|
| 317 | 317 | |
| 318 | 318 | /** |
| 319 | 319 | * @param string $status |
@@ -351,68 +351,68 @@ discard block |
||
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | public static function bulk_trash( $ids ) { |
| 354 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 354 | + FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 355 | 355 | |
| 356 | - $count = 0; |
|
| 357 | - foreach ( $ids as $id ) { |
|
| 358 | - if ( FrmForm::trash( $id ) ) { |
|
| 359 | - $count++; |
|
| 360 | - } |
|
| 361 | - } |
|
| 356 | + $count = 0; |
|
| 357 | + foreach ( $ids as $id ) { |
|
| 358 | + if ( FrmForm::trash( $id ) ) { |
|
| 359 | + $count++; |
|
| 360 | + } |
|
| 361 | + } |
|
| 362 | 362 | |
| 363 | - $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
|
| 364 | - $message = sprintf(_n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="'. esc_url(wp_nonce_url( '?page=formidable&frm_action=list&action=bulk_untrash&form_type='. $current_page .'&item-action[]='. implode('item-action[]=', $ids), 'bulk-toplevel_page_formidable' )) .'">', '</a>' ); |
|
| 363 | + $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
|
| 364 | + $message = sprintf(_n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="'. esc_url(wp_nonce_url( '?page=formidable&frm_action=list&action=bulk_untrash&form_type='. $current_page .'&item-action[]='. implode('item-action[]=', $ids), 'bulk-toplevel_page_formidable' )) .'">', '</a>' ); |
|
| 365 | 365 | |
| 366 | - return $message; |
|
| 367 | - } |
|
| 366 | + return $message; |
|
| 367 | + } |
|
| 368 | 368 | |
| 369 | - public static function destroy() { |
|
| 370 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 369 | + public static function destroy() { |
|
| 370 | + FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 371 | 371 | |
| 372 | 372 | $params = FrmForm::list_page_params(); |
| 373 | 373 | |
| 374 | - //check nonce url |
|
| 375 | - check_admin_referer('destroy_form_' . $params['id']); |
|
| 374 | + //check nonce url |
|
| 375 | + check_admin_referer('destroy_form_' . $params['id']); |
|
| 376 | 376 | |
| 377 | - $count = 0; |
|
| 378 | - if ( FrmForm::destroy( $params['id'] ) ) { |
|
| 379 | - $count++; |
|
| 380 | - } |
|
| 377 | + $count = 0; |
|
| 378 | + if ( FrmForm::destroy( $params['id'] ) ) { |
|
| 379 | + $count++; |
|
| 380 | + } |
|
| 381 | 381 | |
| 382 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 382 | + $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 383 | 383 | |
| 384 | 384 | self::display_forms_list( $params, $message ); |
| 385 | - } |
|
| 385 | + } |
|
| 386 | 386 | |
| 387 | 387 | public static function bulk_destroy( $ids ) { |
| 388 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 388 | + FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 389 | 389 | |
| 390 | - $count = 0; |
|
| 391 | - foreach ( $ids as $id ) { |
|
| 392 | - $d = FrmForm::destroy( $id ); |
|
| 393 | - if ( $d ) { |
|
| 394 | - $count++; |
|
| 395 | - } |
|
| 396 | - } |
|
| 390 | + $count = 0; |
|
| 391 | + foreach ( $ids as $id ) { |
|
| 392 | + $d = FrmForm::destroy( $id ); |
|
| 393 | + if ( $d ) { |
|
| 394 | + $count++; |
|
| 395 | + } |
|
| 396 | + } |
|
| 397 | 397 | |
| 398 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 398 | + $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 399 | 399 | |
| 400 | - return $message; |
|
| 401 | - } |
|
| 400 | + return $message; |
|
| 401 | + } |
|
| 402 | 402 | |
| 403 | - private static function delete_all() { |
|
| 404 | - //check nonce url |
|
| 405 | - $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable'); |
|
| 406 | - if ( $permission_error !== false ) { |
|
| 403 | + private static function delete_all() { |
|
| 404 | + //check nonce url |
|
| 405 | + $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable'); |
|
| 406 | + if ( $permission_error !== false ) { |
|
| 407 | 407 | self::display_forms_list( array(), '', array( $permission_error ) ); |
| 408 | - return; |
|
| 409 | - } |
|
| 408 | + return; |
|
| 409 | + } |
|
| 410 | 410 | |
| 411 | 411 | $count = FrmForm::scheduled_delete( time() ); |
| 412 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 412 | + $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 413 | 413 | |
| 414 | 414 | self::display_forms_list( array(), $message ); |
| 415 | - } |
|
| 415 | + } |
|
| 416 | 416 | |
| 417 | 417 | public static function scheduled_delete( $delete_timestamp = '' ) { |
| 418 | 418 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::scheduled_delete' ); |
@@ -420,11 +420,11 @@ discard block |
||
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | /** |
| 423 | - * Inserts Formidable button |
|
| 424 | - * Hook exists since 2.5.0 |
|
| 425 | - * |
|
| 426 | - * @since 2.0.15 |
|
| 427 | - */ |
|
| 423 | + * Inserts Formidable button |
|
| 424 | + * Hook exists since 2.5.0 |
|
| 425 | + * |
|
| 426 | + * @since 2.0.15 |
|
| 427 | + */ |
|
| 428 | 428 | public static function insert_form_button() { |
| 429 | 429 | if ( current_user_can('frm_view_forms') ) { |
| 430 | 430 | $menu_name = FrmAppHelper::get_menu_name(); |
@@ -435,49 +435,49 @@ discard block |
||
| 435 | 435 | } |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | - public static function insert_form_popup() { |
|
| 438 | + public static function insert_form_popup() { |
|
| 439 | 439 | $page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) ); |
| 440 | 440 | if ( ! in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) { |
| 441 | - return; |
|
| 442 | - } |
|
| 441 | + return; |
|
| 442 | + } |
|
| 443 | 443 | |
| 444 | - FrmAppHelper::load_admin_wide_js(); |
|
| 444 | + FrmAppHelper::load_admin_wide_js(); |
|
| 445 | 445 | |
| 446 | - $shortcodes = array( |
|
| 446 | + $shortcodes = array( |
|
| 447 | 447 | 'formidable' => array( 'name' => __( 'Form', 'formidable' ), 'label' => __( 'Insert a Form', 'formidable' ) ), |
| 448 | - ); |
|
| 448 | + ); |
|
| 449 | 449 | |
| 450 | - $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes); |
|
| 450 | + $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes); |
|
| 451 | 451 | |
| 452 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/insert_form_popup.php'); |
|
| 453 | - } |
|
| 452 | + include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/insert_form_popup.php'); |
|
| 453 | + } |
|
| 454 | 454 | |
| 455 | - public static function get_shortcode_opts() { |
|
| 455 | + public static function get_shortcode_opts() { |
|
| 456 | 456 | FrmAppHelper::permission_check('frm_view_forms'); |
| 457 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 457 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 458 | 458 | |
| 459 | 459 | $shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' ); |
| 460 | - if ( empty($shortcode) ) { |
|
| 461 | - wp_die(); |
|
| 462 | - } |
|
| 460 | + if ( empty($shortcode) ) { |
|
| 461 | + wp_die(); |
|
| 462 | + } |
|
| 463 | 463 | |
| 464 | - echo '<div id="sc-opts-'. esc_attr( $shortcode ) .'" class="frm_shortcode_option">'; |
|
| 465 | - echo '<input type="radio" name="frmsc" value="'. esc_attr($shortcode) .'" id="sc-'. esc_attr($shortcode) .'" class="frm_hidden" />'; |
|
| 464 | + echo '<div id="sc-opts-'. esc_attr( $shortcode ) .'" class="frm_shortcode_option">'; |
|
| 465 | + echo '<input type="radio" name="frmsc" value="'. esc_attr($shortcode) .'" id="sc-'. esc_attr($shortcode) .'" class="frm_hidden" />'; |
|
| 466 | 466 | |
| 467 | - $form_id = ''; |
|
| 468 | - $opts = array(); |
|
| 467 | + $form_id = ''; |
|
| 468 | + $opts = array(); |
|
| 469 | 469 | switch ( $shortcode ) { |
| 470 | - case 'formidable': |
|
| 471 | - $opts = array( |
|
| 470 | + case 'formidable': |
|
| 471 | + $opts = array( |
|
| 472 | 472 | 'form_id' => 'id', |
| 473 | - //'key' => ', |
|
| 473 | + //'key' => ', |
|
| 474 | 474 | 'title' => array( 'val' => 1, 'label' => __( 'Display form title', 'formidable' ) ), |
| 475 | 475 | 'description' => array( 'val' => 1, 'label' => __( 'Display form description', 'formidable' ) ), |
| 476 | 476 | 'minimize' => array( 'val' => 1, 'label' => __( 'Minimize form HTML', 'formidable' ) ), |
| 477 | - ); |
|
| 478 | - break; |
|
| 479 | - } |
|
| 480 | - $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode); |
|
| 477 | + ); |
|
| 478 | + break; |
|
| 479 | + } |
|
| 480 | + $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode); |
|
| 481 | 481 | |
| 482 | 482 | if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) { |
| 483 | 483 | // allow other shortcodes to use the required form id option |
@@ -485,63 +485,63 @@ discard block |
||
| 485 | 485 | unset( $opts['form_id'] ); |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/shortcode_opts.php'); |
|
| 488 | + include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/shortcode_opts.php'); |
|
| 489 | 489 | |
| 490 | - echo '</div>'; |
|
| 490 | + echo '</div>'; |
|
| 491 | 491 | |
| 492 | - wp_die(); |
|
| 493 | - } |
|
| 492 | + wp_die(); |
|
| 493 | + } |
|
| 494 | 494 | |
| 495 | 495 | public static function display_forms_list( $params = array(), $message = '', $errors = array(), $deprecated_errors = array() ) { |
| 496 | - FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 496 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 497 | 497 | if ( ! empty( $deprecated_errors ) ) { |
| 498 | 498 | $errors = $deprecated_errors; |
| 499 | 499 | _deprecated_argument( 'errors', '2.0.8' ); |
| 500 | 500 | } |
| 501 | 501 | |
| 502 | - global $wpdb, $frm_vars; |
|
| 502 | + global $wpdb, $frm_vars; |
|
| 503 | 503 | |
| 504 | 504 | if ( empty( $params ) ) { |
| 505 | 505 | $params = FrmForm::list_page_params(); |
| 506 | - } |
|
| 506 | + } |
|
| 507 | 507 | |
| 508 | - $wp_list_table = new FrmFormsListHelper( compact( 'params' ) ); |
|
| 508 | + $wp_list_table = new FrmFormsListHelper( compact( 'params' ) ); |
|
| 509 | 509 | |
| 510 | - $pagenum = $wp_list_table->get_pagenum(); |
|
| 510 | + $pagenum = $wp_list_table->get_pagenum(); |
|
| 511 | 511 | |
| 512 | - $wp_list_table->prepare_items(); |
|
| 512 | + $wp_list_table->prepare_items(); |
|
| 513 | 513 | |
| 514 | - $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 515 | - if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 514 | + $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 515 | + if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 516 | 516 | wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) ); |
| 517 | - die(); |
|
| 518 | - } |
|
| 517 | + die(); |
|
| 518 | + } |
|
| 519 | 519 | |
| 520 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/list.php'); |
|
| 521 | - } |
|
| 520 | + require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/list.php'); |
|
| 521 | + } |
|
| 522 | 522 | |
| 523 | 523 | public static function get_columns( $columns ) { |
| 524 | - $columns['cb'] = '<input type="checkbox" />'; |
|
| 525 | - $columns['id'] = 'ID'; |
|
| 524 | + $columns['cb'] = '<input type="checkbox" />'; |
|
| 525 | + $columns['id'] = 'ID'; |
|
| 526 | 526 | |
| 527 | - $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : 'published'; |
|
| 527 | + $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : 'published'; |
|
| 528 | 528 | |
| 529 | - if ( 'template' == $type ) { |
|
| 530 | - $columns['name'] = __( 'Template Name', 'formidable' ); |
|
| 531 | - $columns['type'] = __( 'Type', 'formidable' ); |
|
| 532 | - $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 533 | - } else { |
|
| 534 | - $columns['name'] = __( 'Form Title', 'formidable' ); |
|
| 535 | - $columns['entries'] = __( 'Entries', 'formidable' ); |
|
| 536 | - $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 537 | - $columns['shortcode'] = __( 'Shortcodes', 'formidable' ); |
|
| 538 | - } |
|
| 529 | + if ( 'template' == $type ) { |
|
| 530 | + $columns['name'] = __( 'Template Name', 'formidable' ); |
|
| 531 | + $columns['type'] = __( 'Type', 'formidable' ); |
|
| 532 | + $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 533 | + } else { |
|
| 534 | + $columns['name'] = __( 'Form Title', 'formidable' ); |
|
| 535 | + $columns['entries'] = __( 'Entries', 'formidable' ); |
|
| 536 | + $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 537 | + $columns['shortcode'] = __( 'Shortcodes', 'formidable' ); |
|
| 538 | + } |
|
| 539 | 539 | |
| 540 | - $columns['created_at'] = __( 'Date', 'formidable' ); |
|
| 540 | + $columns['created_at'] = __( 'Date', 'formidable' ); |
|
| 541 | 541 | |
| 542 | 542 | add_screen_option( 'per_page', array( 'label' => __( 'Forms', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_per_page' ) ); |
| 543 | 543 | |
| 544 | - return $columns; |
|
| 544 | + return $columns; |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | public static function get_sortable_columns() { |
@@ -555,110 +555,110 @@ discard block |
||
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | public static function hidden_columns( $result ) { |
| 558 | - $return = false; |
|
| 559 | - foreach ( (array) $result as $r ) { |
|
| 560 | - if ( ! empty( $r ) ) { |
|
| 561 | - $return = true; |
|
| 562 | - break; |
|
| 563 | - } |
|
| 564 | - } |
|
| 558 | + $return = false; |
|
| 559 | + foreach ( (array) $result as $r ) { |
|
| 560 | + if ( ! empty( $r ) ) { |
|
| 561 | + $return = true; |
|
| 562 | + break; |
|
| 563 | + } |
|
| 564 | + } |
|
| 565 | 565 | |
| 566 | - if ( $return ) { |
|
| 567 | - return $result; |
|
| 566 | + if ( $return ) { |
|
| 567 | + return $result; |
|
| 568 | 568 | } |
| 569 | 569 | |
| 570 | - $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
|
| 570 | + $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
|
| 571 | 571 | |
| 572 | - $result[] = 'created_at'; |
|
| 573 | - if ( $type == 'template' ) { |
|
| 574 | - $result[] = 'id'; |
|
| 575 | - $result[] = 'form_key'; |
|
| 576 | - } |
|
| 572 | + $result[] = 'created_at'; |
|
| 573 | + if ( $type == 'template' ) { |
|
| 574 | + $result[] = 'id'; |
|
| 575 | + $result[] = 'form_key'; |
|
| 576 | + } |
|
| 577 | 577 | |
| 578 | - return $result; |
|
| 579 | - } |
|
| 578 | + return $result; |
|
| 579 | + } |
|
| 580 | 580 | |
| 581 | 581 | public static function save_per_page( $save, $option, $value ) { |
| 582 | - if ( $option == 'formidable_page_formidable_per_page' ) { |
|
| 583 | - $save = (int) $value; |
|
| 584 | - } |
|
| 585 | - return $save; |
|
| 586 | - } |
|
| 582 | + if ( $option == 'formidable_page_formidable_per_page' ) { |
|
| 583 | + $save = (int) $value; |
|
| 584 | + } |
|
| 585 | + return $save; |
|
| 586 | + } |
|
| 587 | 587 | |
| 588 | 588 | private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) { |
| 589 | - global $frm_vars; |
|
| 589 | + global $frm_vars; |
|
| 590 | 590 | |
| 591 | - $form = FrmForm::getOne( $id ); |
|
| 592 | - if ( ! $form ) { |
|
| 593 | - wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) ); |
|
| 594 | - } |
|
| 591 | + $form = FrmForm::getOne( $id ); |
|
| 592 | + if ( ! $form ) { |
|
| 593 | + wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) ); |
|
| 594 | + } |
|
| 595 | 595 | |
| 596 | - if ( $form->parent_form_id ) { |
|
| 596 | + if ( $form->parent_form_id ) { |
|
| 597 | 597 | wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="'. esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id='. $form->parent_form_id ) ) . '">', '</a>' )); |
| 598 | - } |
|
| 598 | + } |
|
| 599 | 599 | |
| 600 | 600 | $frm_field_selection = FrmField::field_selection(); |
| 601 | - $fields = FrmField::get_all_for_form($form->id); |
|
| 601 | + $fields = FrmField::get_all_for_form($form->id); |
|
| 602 | 602 | |
| 603 | - // Automatically add end section fields if they don't exist (2.0 migration) |
|
| 604 | - $reset_fields = false; |
|
| 605 | - FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields ); |
|
| 603 | + // Automatically add end section fields if they don't exist (2.0 migration) |
|
| 604 | + $reset_fields = false; |
|
| 605 | + FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields ); |
|
| 606 | 606 | |
| 607 | - if ( $reset_fields ) { |
|
| 608 | - $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
|
| 609 | - } |
|
| 607 | + if ( $reset_fields ) { |
|
| 608 | + $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
|
| 609 | + } |
|
| 610 | 610 | |
| 611 | - unset($end_section_values, $last_order, $open, $reset_fields); |
|
| 611 | + unset($end_section_values, $last_order, $open, $reset_fields); |
|
| 612 | 612 | |
| 613 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 613 | + $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 614 | 614 | |
| 615 | - $edit_message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 616 | - if ( $form->is_template && $message == $edit_message ) { |
|
| 617 | - $message = __( 'Template was Successfully Updated', 'formidable' ); |
|
| 618 | - } |
|
| 615 | + $edit_message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 616 | + if ( $form->is_template && $message == $edit_message ) { |
|
| 617 | + $message = __( 'Template was Successfully Updated', 'formidable' ); |
|
| 618 | + } |
|
| 619 | 619 | |
| 620 | 620 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 621 | 621 | |
| 622 | - if ( $form->default_template ) { |
|
| 623 | - wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 624 | - } else if ( defined('DOING_AJAX') ) { |
|
| 625 | - wp_die(); |
|
| 626 | - } else if ( $create_link ) { |
|
| 627 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php'); |
|
| 628 | - } else { |
|
| 629 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/edit.php'); |
|
| 630 | - } |
|
| 631 | - } |
|
| 622 | + if ( $form->default_template ) { |
|
| 623 | + wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 624 | + } else if ( defined('DOING_AJAX') ) { |
|
| 625 | + wp_die(); |
|
| 626 | + } else if ( $create_link ) { |
|
| 627 | + require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php'); |
|
| 628 | + } else { |
|
| 629 | + require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/edit.php'); |
|
| 630 | + } |
|
| 631 | + } |
|
| 632 | 632 | |
| 633 | 633 | public static function get_settings_vars( $id, $errors = array(), $message = '' ) { |
| 634 | 634 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 635 | 635 | |
| 636 | - global $frm_vars; |
|
| 636 | + global $frm_vars; |
|
| 637 | 637 | |
| 638 | - $form = FrmForm::getOne( $id ); |
|
| 638 | + $form = FrmForm::getOne( $id ); |
|
| 639 | 639 | |
| 640 | - $fields = FrmField::get_all_for_form($id); |
|
| 641 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 640 | + $fields = FrmField::get_all_for_form($id); |
|
| 641 | + $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 642 | 642 | |
| 643 | - if ( isset($values['default_template']) && $values['default_template'] ) { |
|
| 644 | - wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 645 | - } |
|
| 643 | + if ( isset($values['default_template']) && $values['default_template'] ) { |
|
| 644 | + wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 645 | + } |
|
| 646 | 646 | |
| 647 | - $action_controls = FrmFormActionsController::get_form_actions(); |
|
| 647 | + $action_controls = FrmFormActionsController::get_form_actions(); |
|
| 648 | 648 | |
| 649 | - $sections = apply_filters('frm_add_form_settings_section', array(), $values); |
|
| 650 | - $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
|
| 649 | + $sections = apply_filters('frm_add_form_settings_section', array(), $values); |
|
| 650 | + $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
|
| 651 | 651 | |
| 652 | - $styles = apply_filters('frm_get_style_opts', array()); |
|
| 652 | + $styles = apply_filters('frm_get_style_opts', array()); |
|
| 653 | 653 | |
| 654 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/settings.php'); |
|
| 655 | - } |
|
| 654 | + require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/settings.php'); |
|
| 655 | + } |
|
| 656 | 656 | |
| 657 | - public static function mb_tags_box( $form_id, $class = '' ) { |
|
| 658 | - $fields = FrmField::get_all_for_form($form_id, '', 'include'); |
|
| 659 | - $linked_forms = array(); |
|
| 660 | - $col = 'one'; |
|
| 661 | - $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false; |
|
| 657 | + public static function mb_tags_box( $form_id, $class = '' ) { |
|
| 658 | + $fields = FrmField::get_all_for_form($form_id, '', 'include'); |
|
| 659 | + $linked_forms = array(); |
|
| 660 | + $col = 'one'; |
|
| 661 | + $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false; |
|
| 662 | 662 | |
| 663 | 663 | $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() ); |
| 664 | 664 | $adv_shortcodes = self::get_advanced_shortcodes(); |
@@ -666,7 +666,7 @@ discard block |
||
| 666 | 666 | $entry_shortcodes = self::get_shortcode_helpers( $settings_tab ); |
| 667 | 667 | |
| 668 | 668 | include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' ); |
| 669 | - } |
|
| 669 | + } |
|
| 670 | 670 | |
| 671 | 671 | /** |
| 672 | 672 | * Get an array of the options to display in the advanced tab |
@@ -707,7 +707,7 @@ discard block |
||
| 707 | 707 | '' => '', |
| 708 | 708 | 'siteurl' => __( 'Site URL', 'formidable' ), |
| 709 | 709 | 'sitename' => __( 'Site Name', 'formidable' ), |
| 710 | - ); |
|
| 710 | + ); |
|
| 711 | 711 | |
| 712 | 712 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 713 | 713 | unset( $entry_shortcodes['post_id'] ); |
@@ -734,39 +734,39 @@ discard block |
||
| 734 | 734 | return $entry_shortcodes; |
| 735 | 735 | } |
| 736 | 736 | |
| 737 | - // Insert the form class setting into the form |
|
| 737 | + // Insert the form class setting into the form |
|
| 738 | 738 | public static function form_classes( $form ) { |
| 739 | - if ( isset($form->options['form_class']) ) { |
|
| 739 | + if ( isset($form->options['form_class']) ) { |
|
| 740 | 740 | echo esc_attr( sanitize_text_field( $form->options['form_class'] ) ); |
| 741 | - } |
|
| 742 | - } |
|
| 741 | + } |
|
| 742 | + } |
|
| 743 | 743 | |
| 744 | - public static function get_email_html() { |
|
| 744 | + public static function get_email_html() { |
|
| 745 | 745 | FrmAppHelper::permission_check('frm_view_forms'); |
| 746 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 746 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 747 | 747 | echo FrmEntryFormat::show_entry( array( |
| 748 | 748 | 'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ), |
| 749 | - 'default_email' => true, |
|
| 749 | + 'default_email' => true, |
|
| 750 | 750 | 'plain_text' => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ), |
| 751 | - ) ); |
|
| 752 | - wp_die(); |
|
| 751 | + ) ); |
|
| 752 | + wp_die(); |
|
| 753 | 753 | } |
| 754 | 754 | |
| 755 | - public static function filter_content( $content, $form, $entry = false ) { |
|
| 755 | + public static function filter_content( $content, $form, $entry = false ) { |
|
| 756 | 756 | self::get_entry_by_param( $entry ); |
| 757 | - if ( ! $entry ) { |
|
| 758 | - return $content; |
|
| 759 | - } |
|
| 757 | + if ( ! $entry ) { |
|
| 758 | + return $content; |
|
| 759 | + } |
|
| 760 | 760 | |
| 761 | - if ( is_object( $form ) ) { |
|
| 762 | - $form = $form->id; |
|
| 763 | - } |
|
| 761 | + if ( is_object( $form ) ) { |
|
| 762 | + $form = $form->id; |
|
| 763 | + } |
|
| 764 | 764 | |
| 765 | - $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form ); |
|
| 766 | - $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes ); |
|
| 765 | + $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form ); |
|
| 766 | + $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes ); |
|
| 767 | 767 | |
| 768 | - return $content; |
|
| 769 | - } |
|
| 768 | + return $content; |
|
| 769 | + } |
|
| 770 | 770 | |
| 771 | 771 | private static function get_entry_by_param( &$entry ) { |
| 772 | 772 | if ( ! $entry || ! is_object( $entry ) ) { |
@@ -778,287 +778,287 @@ discard block |
||
| 778 | 778 | } |
| 779 | 779 | } |
| 780 | 780 | |
| 781 | - public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
|
| 782 | - return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes ); |
|
| 783 | - } |
|
| 781 | + public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
|
| 782 | + return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes ); |
|
| 783 | + } |
|
| 784 | 784 | |
| 785 | - public static function process_bulk_form_actions( $errors ) { |
|
| 786 | - if ( ! $_REQUEST ) { |
|
| 787 | - return $errors; |
|
| 788 | - } |
|
| 785 | + public static function process_bulk_form_actions( $errors ) { |
|
| 786 | + if ( ! $_REQUEST ) { |
|
| 787 | + return $errors; |
|
| 788 | + } |
|
| 789 | 789 | |
| 790 | 790 | $bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); |
| 791 | - if ( $bulkaction == -1 ) { |
|
| 791 | + if ( $bulkaction == -1 ) { |
|
| 792 | 792 | $bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
| 793 | - } |
|
| 794 | - |
|
| 795 | - if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) { |
|
| 796 | - FrmAppHelper::remove_get_action(); |
|
| 797 | - |
|
| 798 | - $bulkaction = str_replace( 'bulk_', '', $bulkaction ); |
|
| 799 | - } |
|
| 800 | - |
|
| 801 | - $ids = FrmAppHelper::get_param( 'item-action', '' ); |
|
| 802 | - if ( empty( $ids ) ) { |
|
| 803 | - $errors[] = __( 'No forms were specified', 'formidable' ); |
|
| 804 | - return $errors; |
|
| 805 | - } |
|
| 806 | - |
|
| 807 | - $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
| 808 | - if ( $permission_error !== false ) { |
|
| 809 | - $errors[] = $permission_error; |
|
| 810 | - return $errors; |
|
| 811 | - } |
|
| 812 | - |
|
| 813 | - if ( ! is_array( $ids ) ) { |
|
| 814 | - $ids = explode( ',', $ids ); |
|
| 815 | - } |
|
| 816 | - |
|
| 817 | - switch ( $bulkaction ) { |
|
| 818 | - case 'delete': |
|
| 819 | - $message = self::bulk_destroy( $ids ); |
|
| 820 | - break; |
|
| 821 | - case 'trash': |
|
| 822 | - $message = self::bulk_trash( $ids ); |
|
| 823 | - break; |
|
| 824 | - case 'untrash': |
|
| 825 | - $message = self::bulk_untrash( $ids ); |
|
| 826 | - break; |
|
| 827 | - case 'create_template': |
|
| 828 | - $message = self::bulk_create_template( $ids ); |
|
| 829 | - break; |
|
| 830 | - } |
|
| 831 | - |
|
| 832 | - if ( isset( $message ) && ! empty( $message ) ) { |
|
| 793 | + } |
|
| 794 | + |
|
| 795 | + if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) { |
|
| 796 | + FrmAppHelper::remove_get_action(); |
|
| 797 | + |
|
| 798 | + $bulkaction = str_replace( 'bulk_', '', $bulkaction ); |
|
| 799 | + } |
|
| 800 | + |
|
| 801 | + $ids = FrmAppHelper::get_param( 'item-action', '' ); |
|
| 802 | + if ( empty( $ids ) ) { |
|
| 803 | + $errors[] = __( 'No forms were specified', 'formidable' ); |
|
| 804 | + return $errors; |
|
| 805 | + } |
|
| 806 | + |
|
| 807 | + $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
| 808 | + if ( $permission_error !== false ) { |
|
| 809 | + $errors[] = $permission_error; |
|
| 810 | + return $errors; |
|
| 811 | + } |
|
| 812 | + |
|
| 813 | + if ( ! is_array( $ids ) ) { |
|
| 814 | + $ids = explode( ',', $ids ); |
|
| 815 | + } |
|
| 816 | + |
|
| 817 | + switch ( $bulkaction ) { |
|
| 818 | + case 'delete': |
|
| 819 | + $message = self::bulk_destroy( $ids ); |
|
| 820 | + break; |
|
| 821 | + case 'trash': |
|
| 822 | + $message = self::bulk_trash( $ids ); |
|
| 823 | + break; |
|
| 824 | + case 'untrash': |
|
| 825 | + $message = self::bulk_untrash( $ids ); |
|
| 826 | + break; |
|
| 827 | + case 'create_template': |
|
| 828 | + $message = self::bulk_create_template( $ids ); |
|
| 829 | + break; |
|
| 830 | + } |
|
| 831 | + |
|
| 832 | + if ( isset( $message ) && ! empty( $message ) ) { |
|
| 833 | 833 | echo '<div id="message" class="updated frm_msg_padding">' . FrmAppHelper::kses( $message ) . '</div>'; |
| 834 | - } |
|
| 834 | + } |
|
| 835 | 835 | |
| 836 | - return $errors; |
|
| 837 | - } |
|
| 836 | + return $errors; |
|
| 837 | + } |
|
| 838 | 838 | |
| 839 | - public static function add_default_templates( $path, $default = true, $template = true ) { |
|
| 840 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' ); |
|
| 839 | + public static function add_default_templates( $path, $default = true, $template = true ) { |
|
| 840 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' ); |
|
| 841 | 841 | |
| 842 | - $path = untrailingslashit(trim($path)); |
|
| 843 | - $templates = glob( $path .'/*.php' ); |
|
| 842 | + $path = untrailingslashit(trim($path)); |
|
| 843 | + $templates = glob( $path .'/*.php' ); |
|
| 844 | 844 | |
| 845 | 845 | for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) { |
| 846 | - $filename = str_replace( '.php', '', str_replace( $path.'/', '', $templates[ $i ] ) ); |
|
| 846 | + $filename = str_replace( '.php', '', str_replace( $path.'/', '', $templates[ $i ] ) ); |
|
| 847 | 847 | $template_query = array( 'form_key' => $filename ); |
| 848 | - if ( $template ) { |
|
| 849 | - $template_query['is_template'] = 1; |
|
| 850 | - } |
|
| 851 | - if ( $default ) { |
|
| 852 | - $template_query['default_template'] = 1; |
|
| 853 | - } |
|
| 848 | + if ( $template ) { |
|
| 849 | + $template_query['is_template'] = 1; |
|
| 850 | + } |
|
| 851 | + if ( $default ) { |
|
| 852 | + $template_query['default_template'] = 1; |
|
| 853 | + } |
|
| 854 | 854 | $form = FrmForm::getAll( $template_query, '', 1 ); |
| 855 | 855 | |
| 856 | - $values = FrmFormsHelper::setup_new_vars(); |
|
| 857 | - $values['form_key'] = $filename; |
|
| 858 | - $values['is_template'] = $template; |
|
| 859 | - $values['status'] = 'published'; |
|
| 860 | - if ( $default ) { |
|
| 861 | - $values['default_template'] = 1; |
|
| 862 | - } |
|
| 863 | - |
|
| 864 | - include( $templates[ $i ] ); |
|
| 865 | - |
|
| 866 | - //get updated form |
|
| 867 | - if ( isset($form) && ! empty($form) ) { |
|
| 868 | - $old_id = $form->id; |
|
| 869 | - $form = FrmForm::getOne($form->id); |
|
| 870 | - } else { |
|
| 871 | - $old_id = false; |
|
| 856 | + $values = FrmFormsHelper::setup_new_vars(); |
|
| 857 | + $values['form_key'] = $filename; |
|
| 858 | + $values['is_template'] = $template; |
|
| 859 | + $values['status'] = 'published'; |
|
| 860 | + if ( $default ) { |
|
| 861 | + $values['default_template'] = 1; |
|
| 862 | + } |
|
| 863 | + |
|
| 864 | + include( $templates[ $i ] ); |
|
| 865 | + |
|
| 866 | + //get updated form |
|
| 867 | + if ( isset($form) && ! empty($form) ) { |
|
| 868 | + $old_id = $form->id; |
|
| 869 | + $form = FrmForm::getOne($form->id); |
|
| 870 | + } else { |
|
| 871 | + $old_id = false; |
|
| 872 | 872 | $form = FrmForm::getAll( $template_query, '', 1 ); |
| 873 | - } |
|
| 873 | + } |
|
| 874 | 874 | |
| 875 | - if ( $form ) { |
|
| 875 | + if ( $form ) { |
|
| 876 | 876 | do_action( 'frm_after_duplicate_form', $form->id, (array) $form, array( 'old_id' => $old_id ) ); |
| 877 | - } |
|
| 878 | - } |
|
| 879 | - } |
|
| 877 | + } |
|
| 878 | + } |
|
| 879 | + } |
|
| 880 | 880 | |
| 881 | - public static function route() { |
|
| 882 | - $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 883 | - $vars = array(); |
|
| 881 | + public static function route() { |
|
| 882 | + $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 883 | + $vars = array(); |
|
| 884 | 884 | if ( isset( $_POST['frm_compact_fields'] ) ) { |
| 885 | 885 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 886 | 886 | |
| 887 | - $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('"', '\\\"', $_POST['frm_compact_fields'] )))); |
|
| 888 | - $json_vars = json_decode($json_vars, true); |
|
| 889 | - if ( empty($json_vars) ) { |
|
| 890 | - // json decoding failed so we should return an error message |
|
| 887 | + $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('"', '\\\"', $_POST['frm_compact_fields'] )))); |
|
| 888 | + $json_vars = json_decode($json_vars, true); |
|
| 889 | + if ( empty($json_vars) ) { |
|
| 890 | + // json decoding failed so we should return an error message |
|
| 891 | 891 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 892 | - if ( 'edit' == $action ) { |
|
| 893 | - $action = 'update'; |
|
| 894 | - } |
|
| 895 | - |
|
| 896 | - add_filter('frm_validate_form', 'FrmFormsController::json_error'); |
|
| 897 | - } else { |
|
| 898 | - $vars = FrmAppHelper::json_to_array($json_vars); |
|
| 899 | - $action = $vars[ $action ]; |
|
| 892 | + if ( 'edit' == $action ) { |
|
| 893 | + $action = 'update'; |
|
| 894 | + } |
|
| 895 | + |
|
| 896 | + add_filter('frm_validate_form', 'FrmFormsController::json_error'); |
|
| 897 | + } else { |
|
| 898 | + $vars = FrmAppHelper::json_to_array($json_vars); |
|
| 899 | + $action = $vars[ $action ]; |
|
| 900 | 900 | unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] ); |
| 901 | 901 | $_REQUEST = array_merge( $_REQUEST, $vars ); |
| 902 | 902 | $_POST = array_merge( $_POST, $_REQUEST ); |
| 903 | - } |
|
| 904 | - } else { |
|
| 903 | + } |
|
| 904 | + } else { |
|
| 905 | 905 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 906 | - if ( isset( $_REQUEST['delete_all'] ) ) { |
|
| 907 | - // override the action for this page |
|
| 908 | - $action = 'delete_all'; |
|
| 909 | - } |
|
| 910 | - } |
|
| 906 | + if ( isset( $_REQUEST['delete_all'] ) ) { |
|
| 907 | + // override the action for this page |
|
| 908 | + $action = 'delete_all'; |
|
| 909 | + } |
|
| 910 | + } |
|
| 911 | 911 | |
| 912 | 912 | add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
| 913 | - FrmAppHelper::trigger_hook_load( 'form' ); |
|
| 914 | - |
|
| 915 | - switch ( $action ) { |
|
| 916 | - case 'new': |
|
| 917 | - return self::new_form($vars); |
|
| 918 | - case 'create': |
|
| 919 | - case 'edit': |
|
| 920 | - case 'update': |
|
| 921 | - case 'duplicate': |
|
| 922 | - case 'trash': |
|
| 923 | - case 'untrash': |
|
| 924 | - case 'destroy': |
|
| 925 | - case 'delete_all': |
|
| 926 | - case 'settings': |
|
| 927 | - case 'update_settings': |
|
| 913 | + FrmAppHelper::trigger_hook_load( 'form' ); |
|
| 914 | + |
|
| 915 | + switch ( $action ) { |
|
| 916 | + case 'new': |
|
| 917 | + return self::new_form($vars); |
|
| 918 | + case 'create': |
|
| 919 | + case 'edit': |
|
| 920 | + case 'update': |
|
| 921 | + case 'duplicate': |
|
| 922 | + case 'trash': |
|
| 923 | + case 'untrash': |
|
| 924 | + case 'destroy': |
|
| 925 | + case 'delete_all': |
|
| 926 | + case 'settings': |
|
| 927 | + case 'update_settings': |
|
| 928 | 928 | return self::$action( $vars ); |
| 929 | - default: |
|
| 930 | - do_action('frm_form_action_'. $action); |
|
| 931 | - if ( apply_filters('frm_form_stop_action_'. $action, false) ) { |
|
| 932 | - return; |
|
| 933 | - } |
|
| 929 | + default: |
|
| 930 | + do_action('frm_form_action_'. $action); |
|
| 931 | + if ( apply_filters('frm_form_stop_action_'. $action, false) ) { |
|
| 932 | + return; |
|
| 933 | + } |
|
| 934 | 934 | |
| 935 | 935 | $action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); |
| 936 | - if ( $action == -1 ) { |
|
| 936 | + if ( $action == -1 ) { |
|
| 937 | 937 | $action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
| 938 | - } |
|
| 938 | + } |
|
| 939 | 939 | |
| 940 | - if ( strpos($action, 'bulk_') === 0 ) { |
|
| 941 | - FrmAppHelper::remove_get_action(); |
|
| 942 | - return self::list_form(); |
|
| 943 | - } |
|
| 940 | + if ( strpos($action, 'bulk_') === 0 ) { |
|
| 941 | + FrmAppHelper::remove_get_action(); |
|
| 942 | + return self::list_form(); |
|
| 943 | + } |
|
| 944 | 944 | |
| 945 | - return self::display_forms_list(); |
|
| 946 | - } |
|
| 947 | - } |
|
| 945 | + return self::display_forms_list(); |
|
| 946 | + } |
|
| 947 | + } |
|
| 948 | 948 | |
| 949 | - public static function json_error( $errors ) { |
|
| 950 | - $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' ); |
|
| 951 | - return $errors; |
|
| 952 | - } |
|
| 949 | + public static function json_error( $errors ) { |
|
| 950 | + $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' ); |
|
| 951 | + return $errors; |
|
| 952 | + } |
|
| 953 | 953 | |
| 954 | 954 | |
| 955 | - /* FRONT-END FORMS */ |
|
| 956 | - public static function admin_bar_css() { |
|
| 955 | + /* FRONT-END FORMS */ |
|
| 956 | + public static function admin_bar_css() { |
|
| 957 | 957 | if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) { |
| 958 | - return; |
|
| 959 | - } |
|
| 958 | + return; |
|
| 959 | + } |
|
| 960 | 960 | |
| 961 | 961 | add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' ); |
| 962 | 962 | FrmAppHelper::load_font_style(); |
| 963 | 963 | } |
| 964 | 964 | |
| 965 | 965 | public static function admin_bar_configure() { |
| 966 | - global $frm_vars; |
|
| 967 | - if ( empty($frm_vars['forms_loaded']) ) { |
|
| 968 | - return; |
|
| 969 | - } |
|
| 970 | - |
|
| 971 | - $actions = array(); |
|
| 972 | - foreach ( $frm_vars['forms_loaded'] as $form ) { |
|
| 973 | - if ( is_object($form) ) { |
|
| 974 | - $actions[ $form->id ] = $form->name; |
|
| 975 | - } |
|
| 976 | - unset($form); |
|
| 977 | - } |
|
| 978 | - |
|
| 979 | - if ( empty($actions) ) { |
|
| 980 | - return; |
|
| 981 | - } |
|
| 982 | - |
|
| 983 | - asort($actions); |
|
| 984 | - |
|
| 985 | - global $wp_admin_bar; |
|
| 986 | - |
|
| 987 | - if ( count($actions) == 1 ) { |
|
| 988 | - $wp_admin_bar->add_menu( array( |
|
| 989 | - 'title' => 'Edit Form', |
|
| 990 | - 'href' => admin_url('admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) )), |
|
| 991 | - 'id' => 'frm-forms', |
|
| 992 | - ) ); |
|
| 993 | - } else { |
|
| 994 | - $wp_admin_bar->add_menu( array( |
|
| 995 | - 'id' => 'frm-forms', |
|
| 996 | - 'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>', |
|
| 997 | - 'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) ) ), |
|
| 998 | - 'meta' => array( |
|
| 966 | + global $frm_vars; |
|
| 967 | + if ( empty($frm_vars['forms_loaded']) ) { |
|
| 968 | + return; |
|
| 969 | + } |
|
| 970 | + |
|
| 971 | + $actions = array(); |
|
| 972 | + foreach ( $frm_vars['forms_loaded'] as $form ) { |
|
| 973 | + if ( is_object($form) ) { |
|
| 974 | + $actions[ $form->id ] = $form->name; |
|
| 975 | + } |
|
| 976 | + unset($form); |
|
| 977 | + } |
|
| 978 | + |
|
| 979 | + if ( empty($actions) ) { |
|
| 980 | + return; |
|
| 981 | + } |
|
| 982 | + |
|
| 983 | + asort($actions); |
|
| 984 | + |
|
| 985 | + global $wp_admin_bar; |
|
| 986 | + |
|
| 987 | + if ( count($actions) == 1 ) { |
|
| 988 | + $wp_admin_bar->add_menu( array( |
|
| 989 | + 'title' => 'Edit Form', |
|
| 990 | + 'href' => admin_url('admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) )), |
|
| 991 | + 'id' => 'frm-forms', |
|
| 992 | + ) ); |
|
| 993 | + } else { |
|
| 994 | + $wp_admin_bar->add_menu( array( |
|
| 995 | + 'id' => 'frm-forms', |
|
| 996 | + 'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>', |
|
| 997 | + 'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) ) ), |
|
| 998 | + 'meta' => array( |
|
| 999 | 999 | 'title' => __( 'Edit Forms', 'formidable' ), |
| 1000 | - ), |
|
| 1001 | - ) ); |
|
| 1000 | + ), |
|
| 1001 | + ) ); |
|
| 1002 | 1002 | |
| 1003 | - foreach ( $actions as $form_id => $name ) { |
|
| 1003 | + foreach ( $actions as $form_id => $name ) { |
|
| 1004 | 1004 | |
| 1005 | - $wp_admin_bar->add_menu( array( |
|
| 1006 | - 'parent' => 'frm-forms', |
|
| 1007 | - 'id' => 'edit_form_'. $form_id, |
|
| 1008 | - 'title' => empty($name) ? __( '(no title)') : $name, |
|
| 1005 | + $wp_admin_bar->add_menu( array( |
|
| 1006 | + 'parent' => 'frm-forms', |
|
| 1007 | + 'id' => 'edit_form_'. $form_id, |
|
| 1008 | + 'title' => empty($name) ? __( '(no title)') : $name, |
|
| 1009 | 1009 | 'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ), |
| 1010 | - ) ); |
|
| 1011 | - } |
|
| 1012 | - } |
|
| 1013 | - } |
|
| 1010 | + ) ); |
|
| 1011 | + } |
|
| 1012 | + } |
|
| 1013 | + } |
|
| 1014 | 1014 | |
| 1015 | - //formidable shortcode |
|
| 1015 | + //formidable shortcode |
|
| 1016 | 1016 | public static function get_form_shortcode( $atts ) { |
| 1017 | - global $frm_vars; |
|
| 1018 | - if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) { |
|
| 1019 | - $sc = '[formidable'; |
|
| 1017 | + global $frm_vars; |
|
| 1018 | + if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) { |
|
| 1019 | + $sc = '[formidable'; |
|
| 1020 | 1020 | if ( ! empty( $atts ) ) { |
| 1021 | 1021 | foreach ( $atts as $k => $v ) { |
| 1022 | 1022 | $sc .= ' ' . $k . '="' . esc_attr( $v ) . '"'; |
| 1023 | 1023 | } |
| 1024 | 1024 | } |
| 1025 | - return $sc .']'; |
|
| 1026 | - } |
|
| 1027 | - |
|
| 1028 | - $shortcode_atts = shortcode_atts( array( |
|
| 1029 | - 'id' => '', 'key' => '', 'title' => false, 'description' => false, |
|
| 1030 | - 'readonly' => false, 'entry_id' => false, 'fields' => array(), |
|
| 1031 | - 'exclude_fields' => array(), 'minimize' => false, |
|
| 1032 | - ), $atts); |
|
| 1033 | - do_action('formidable_shortcode_atts', $shortcode_atts, $atts); |
|
| 1034 | - |
|
| 1035 | - return self::show_form( |
|
| 1036 | - $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], |
|
| 1037 | - $shortcode_atts['description'], $atts |
|
| 1038 | - ); |
|
| 1039 | - } |
|
| 1040 | - |
|
| 1041 | - public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) { |
|
| 1042 | - if ( empty( $id ) ) { |
|
| 1043 | - $id = $key; |
|
| 1044 | - } |
|
| 1045 | - |
|
| 1046 | - // no form id or key set |
|
| 1047 | - if ( empty( $id ) ) { |
|
| 1048 | - return __( 'Please select a valid form', 'formidable' ); |
|
| 1049 | - } |
|
| 1050 | - |
|
| 1051 | - $form = FrmForm::getOne( $id ); |
|
| 1052 | - if ( ! $form || $form->parent_form_id ) { |
|
| 1053 | - return __( 'Please select a valid form', 'formidable' ); |
|
| 1054 | - } |
|
| 1025 | + return $sc .']'; |
|
| 1026 | + } |
|
| 1027 | + |
|
| 1028 | + $shortcode_atts = shortcode_atts( array( |
|
| 1029 | + 'id' => '', 'key' => '', 'title' => false, 'description' => false, |
|
| 1030 | + 'readonly' => false, 'entry_id' => false, 'fields' => array(), |
|
| 1031 | + 'exclude_fields' => array(), 'minimize' => false, |
|
| 1032 | + ), $atts); |
|
| 1033 | + do_action('formidable_shortcode_atts', $shortcode_atts, $atts); |
|
| 1034 | + |
|
| 1035 | + return self::show_form( |
|
| 1036 | + $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], |
|
| 1037 | + $shortcode_atts['description'], $atts |
|
| 1038 | + ); |
|
| 1039 | + } |
|
| 1040 | + |
|
| 1041 | + public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) { |
|
| 1042 | + if ( empty( $id ) ) { |
|
| 1043 | + $id = $key; |
|
| 1044 | + } |
|
| 1045 | + |
|
| 1046 | + // no form id or key set |
|
| 1047 | + if ( empty( $id ) ) { |
|
| 1048 | + return __( 'Please select a valid form', 'formidable' ); |
|
| 1049 | + } |
|
| 1050 | + |
|
| 1051 | + $form = FrmForm::getOne( $id ); |
|
| 1052 | + if ( ! $form || $form->parent_form_id ) { |
|
| 1053 | + return __( 'Please select a valid form', 'formidable' ); |
|
| 1054 | + } |
|
| 1055 | 1055 | |
| 1056 | 1056 | add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
| 1057 | - FrmAppHelper::trigger_hook_load( 'form', $form ); |
|
| 1057 | + FrmAppHelper::trigger_hook_load( 'form', $form ); |
|
| 1058 | 1058 | |
| 1059 | - $form = apply_filters( 'frm_pre_display_form', $form ); |
|
| 1059 | + $form = apply_filters( 'frm_pre_display_form', $form ); |
|
| 1060 | 1060 | |
| 1061 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 1061 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 1062 | 1062 | |
| 1063 | 1063 | if ( self::is_viewable_draft_form( $form ) ) { |
| 1064 | 1064 | // don't show a draft form on a page |
@@ -1079,7 +1079,7 @@ discard block |
||
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | 1081 | return $form; |
| 1082 | - } |
|
| 1082 | + } |
|
| 1083 | 1083 | |
| 1084 | 1084 | private static function is_viewable_draft_form( $form ) { |
| 1085 | 1085 | global $post; |
@@ -1095,98 +1095,98 @@ discard block |
||
| 1095 | 1095 | return $form->logged_in && get_current_user_id() && isset( $form->options['logged_in_role'] ) && $form->options['logged_in_role'] != '' && ! FrmAppHelper::user_has_permission( $form->options['logged_in_role'] ); |
| 1096 | 1096 | } |
| 1097 | 1097 | |
| 1098 | - public static function get_form( $form, $title, $description, $atts = array() ) { |
|
| 1099 | - ob_start(); |
|
| 1098 | + public static function get_form( $form, $title, $description, $atts = array() ) { |
|
| 1099 | + ob_start(); |
|
| 1100 | 1100 | |
| 1101 | - self::get_form_contents( $form, $title, $description, $atts ); |
|
| 1101 | + self::get_form_contents( $form, $title, $description, $atts ); |
|
| 1102 | 1102 | self::enqueue_scripts( FrmForm::get_params( $form ) ); |
| 1103 | 1103 | |
| 1104 | - $contents = ob_get_contents(); |
|
| 1105 | - ob_end_clean(); |
|
| 1104 | + $contents = ob_get_contents(); |
|
| 1105 | + ob_end_clean(); |
|
| 1106 | 1106 | |
| 1107 | 1107 | self::maybe_minimize_form( $atts, $contents ); |
| 1108 | 1108 | |
| 1109 | - return $contents; |
|
| 1110 | - } |
|
| 1109 | + return $contents; |
|
| 1110 | + } |
|
| 1111 | 1111 | |
| 1112 | 1112 | public static function enqueue_scripts( $params ) { |
| 1113 | 1113 | do_action( 'frm_enqueue_form_scripts', $params ); |
| 1114 | 1114 | } |
| 1115 | 1115 | |
| 1116 | 1116 | public static function get_form_contents( $form, $title, $description, $atts ) { |
| 1117 | - global $frm_vars; |
|
| 1117 | + global $frm_vars; |
|
| 1118 | 1118 | |
| 1119 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 1119 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 1120 | 1120 | |
| 1121 | - $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value; |
|
| 1121 | + $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value; |
|
| 1122 | 1122 | |
| 1123 | - $user_ID = get_current_user_id(); |
|
| 1123 | + $user_ID = get_current_user_id(); |
|
| 1124 | 1124 | $params = FrmForm::get_params( $form ); |
| 1125 | - $message = $errors = ''; |
|
| 1125 | + $message = $errors = ''; |
|
| 1126 | 1126 | |
| 1127 | - if ( $params['posted_form_id'] == $form->id && $_POST ) { |
|
| 1128 | - $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array(); |
|
| 1129 | - } |
|
| 1127 | + if ( $params['posted_form_id'] == $form->id && $_POST ) { |
|
| 1128 | + $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array(); |
|
| 1129 | + } |
|
| 1130 | 1130 | |
| 1131 | 1131 | $include_form_tag = apply_filters( 'frm_include_form_tag', true, $form ); |
| 1132 | - $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) ); |
|
| 1133 | - |
|
| 1134 | - if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) { |
|
| 1135 | - do_action('frm_display_form_action', $params, $fields, $form, $title, $description); |
|
| 1136 | - if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) { |
|
| 1137 | - $values = FrmEntriesHelper::setup_new_vars($fields, $form); |
|
| 1138 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php'); |
|
| 1139 | - } |
|
| 1140 | - return; |
|
| 1141 | - } |
|
| 1142 | - |
|
| 1143 | - if ( ! empty($errors) ) { |
|
| 1144 | - $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array(); |
|
| 1145 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php'); |
|
| 1146 | - return; |
|
| 1147 | - } |
|
| 1148 | - |
|
| 1149 | - do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description); |
|
| 1150 | - if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) { |
|
| 1151 | - return; |
|
| 1152 | - } |
|
| 1153 | - |
|
| 1154 | - $values = FrmEntriesHelper::setup_new_vars($fields, $form, true); |
|
| 1155 | - $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form->id ] ) ) ? $frm_vars['created_entries'][ $form->id ]['entry_id'] : 0; |
|
| 1156 | - $conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create'); |
|
| 1157 | - |
|
| 1158 | - if ( $created && is_numeric($created) && $conf_method != 'message' ) { |
|
| 1159 | - do_action('frm_success_action', $conf_method, $form, $form->options, $created); |
|
| 1132 | + $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) ); |
|
| 1133 | + |
|
| 1134 | + if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) { |
|
| 1135 | + do_action('frm_display_form_action', $params, $fields, $form, $title, $description); |
|
| 1136 | + if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) { |
|
| 1137 | + $values = FrmEntriesHelper::setup_new_vars($fields, $form); |
|
| 1138 | + include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php'); |
|
| 1139 | + } |
|
| 1140 | + return; |
|
| 1141 | + } |
|
| 1142 | + |
|
| 1143 | + if ( ! empty($errors) ) { |
|
| 1144 | + $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array(); |
|
| 1145 | + include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php'); |
|
| 1146 | + return; |
|
| 1147 | + } |
|
| 1148 | + |
|
| 1149 | + do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description); |
|
| 1150 | + if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) { |
|
| 1151 | + return; |
|
| 1152 | + } |
|
| 1153 | + |
|
| 1154 | + $values = FrmEntriesHelper::setup_new_vars($fields, $form, true); |
|
| 1155 | + $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form->id ] ) ) ? $frm_vars['created_entries'][ $form->id ]['entry_id'] : 0; |
|
| 1156 | + $conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create'); |
|
| 1157 | + |
|
| 1158 | + if ( $created && is_numeric($created) && $conf_method != 'message' ) { |
|
| 1159 | + do_action('frm_success_action', $conf_method, $form, $form->options, $created); |
|
| 1160 | 1160 | do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) ); |
| 1161 | - return; |
|
| 1162 | - } |
|
| 1161 | + return; |
|
| 1162 | + } |
|
| 1163 | 1163 | |
| 1164 | - if ( $created && is_numeric($created) ) { |
|
| 1165 | - $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg; |
|
| 1166 | - $class = 'frm_message'; |
|
| 1167 | - } else { |
|
| 1168 | - $message = $frm_settings->failed_msg; |
|
| 1169 | - $class = 'frm_error_style'; |
|
| 1170 | - } |
|
| 1164 | + if ( $created && is_numeric($created) ) { |
|
| 1165 | + $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg; |
|
| 1166 | + $class = 'frm_message'; |
|
| 1167 | + } else { |
|
| 1168 | + $message = $frm_settings->failed_msg; |
|
| 1169 | + $class = 'frm_error_style'; |
|
| 1170 | + } |
|
| 1171 | 1171 | |
| 1172 | 1172 | $message = FrmFormsHelper::get_success_message( array( |
| 1173 | 1173 | 'message' => $message, 'form' => $form, |
| 1174 | 1174 | 'entry_id' => $created, 'class' => $class, |
| 1175 | 1175 | ) ); |
| 1176 | - $message = apply_filters('frm_main_feedback', $message, $form, $created); |
|
| 1176 | + $message = apply_filters('frm_main_feedback', $message, $form, $created); |
|
| 1177 | 1177 | |
| 1178 | - if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) { |
|
| 1179 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php'); |
|
| 1180 | - } else { |
|
| 1181 | - global $frm_vars; |
|
| 1178 | + if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) { |
|
| 1179 | + require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php'); |
|
| 1180 | + } else { |
|
| 1181 | + global $frm_vars; |
|
| 1182 | 1182 | self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] ); |
| 1183 | 1183 | |
| 1184 | - $include_extra_container = 'frm_forms'. FrmFormsHelper::get_form_style_class($values); |
|
| 1185 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/errors.php'); |
|
| 1186 | - } |
|
| 1184 | + $include_extra_container = 'frm_forms'. FrmFormsHelper::get_form_style_class($values); |
|
| 1185 | + include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/errors.php'); |
|
| 1186 | + } |
|
| 1187 | 1187 | |
| 1188 | 1188 | do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) ); |
| 1189 | - } |
|
| 1189 | + } |
|
| 1190 | 1190 | |
| 1191 | 1191 | public static function front_head() { |
| 1192 | 1192 | $version = FrmAppHelper::plugin_version(); |
@@ -1215,10 +1215,10 @@ discard block |
||
| 1215 | 1215 | } |
| 1216 | 1216 | |
| 1217 | 1217 | public static function defer_script_loading( $tag, $handle ) { |
| 1218 | - if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) { |
|
| 1219 | - $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag ); |
|
| 1218 | + if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) { |
|
| 1219 | + $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag ); |
|
| 1220 | 1220 | } |
| 1221 | - return $tag; |
|
| 1221 | + return $tag; |
|
| 1222 | 1222 | } |
| 1223 | 1223 | |
| 1224 | 1224 | public static function footer_js( $location = 'footer' ) { |