| @@ -9,14 +9,11 @@ | ||
| 9 | 9 | FrmAppHelper::force_capability( 'frm_view_entries' ); |
| 10 | 10 | |
| 11 | 11 | add_submenu_page( 'formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
| 12 | 12 | |
| 13 | - $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) && FrmProAppHelper::views_is_installed(); | |
| 13 | + $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) ? FrmProAppHelper::views_is_installed() : FrmAppHelper::pro_is_installed(); | |
| 14 | 14 | if ( ! $views_installed ) { |
| 15 | 15 | add_submenu_page( 'formidable', 'Formidable | ' . __( 'Views', 'formidable' ), __( 'Views', 'formidable' ), 'frm_view_entries', 'formidable-views', 'FrmFormsController::no_views' ); |
| 16 | - self::maybe_redirect_to_views_upsell(); | |
| 17 | - } else { | |
| 18 | - self::maybe_redirect_to_views_index(); | |
| 19 | 16 | } |
| 20 | 17 | |
| 21 | 18 | if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) ) { |
| 22 | 19 | self::load_manage_entries_hooks(); |
| @@ -23,77 +20,12 @@ | ||
| 23 | 20 | } |
| 24 | 21 | } |
| 25 | 22 | |
| 26 | 23 | /** |
| 27 | - * This function is called when views is installed. | |
| 28 | - * The Views add-on uses a different URL for the Views tab than the upsell page. | |
| 29 | - * If the user is on the upsell page, instead of showing a permission error on reload, | |
| 30 | - * redirect to the views index page. | |
| 31 | - * | |
| 32 | - * @since 6.14.1 | |
| 33 | - * | |
| 34 | - * @return void | |
| 35 | - */ | |
| 36 | - private static function maybe_redirect_to_views_index() { | |
| 37 | - if ( ! FrmAppHelper::is_admin_page( 'formidable-views' ) ) { | |
| 38 | - return; | |
| 39 | - } | |
| 40 | - | |
| 41 | - $query_args = array( | |
| 42 | - 'post_type' => 'frm_display', | |
| 43 | - ); | |
| 44 | - $query_args = self::add_url_params_to_views_redirect_query_args( $query_args ); | |
| 45 | - | |
| 46 | - wp_safe_redirect( add_query_arg( $query_args, admin_url( 'edit.php' ) ) ); | |
| 47 | - die(); | |
| 48 | - } | |
| 49 | - | |
| 50 | - /** | |
| 51 | - * This function is called when views is inactive. | |
| 52 | - * A user may deactivate views but then try to reload the views index. | |
| 53 | - * Instead of showing a permission error, redirect to the views upsell page. | |
| 54 | - * | |
| 55 | - * @since 6.14.1 | |
| 56 | - * | |
| 57 | - * @return void | |
| 58 | - */ | |
| 59 | - private static function maybe_redirect_to_views_upsell() { | |
| 60 | - global $pagenow; | |
| 61 | - if ( 'edit.php' !== $pagenow || 'frm_display' !== FrmAppHelper::simple_get( 'post_type' ) ) { | |
| 62 | - return; | |
| 63 | - } | |
| 64 | - | |
| 65 | - $query_args = array( | |
| 66 | - 'page' => 'formidable-views', | |
| 67 | - ); | |
| 68 | - $query_args = self::add_url_params_to_views_redirect_query_args( $query_args ); | |
| 69 | - | |
| 70 | - wp_safe_redirect( add_query_arg( $query_args, admin_url( 'admin.php' ) ) ); | |
| 71 | - die(); | |
| 72 | - } | |
| 73 | - | |
| 74 | - /** | |
| 75 | - * @since 6.14.1 | |
| 76 | - * | |
| 77 | - * @param array $query_args | |
| 78 | - * @return array | |
| 79 | - */ | |
| 80 | - private static function add_url_params_to_views_redirect_query_args( $query_args ) { | |
| 81 | - $query_args['show_nav'] = FrmAppHelper::simple_get( 'show_nav', 'absint', 0 ); | |
| 82 | - | |
| 83 | - $form_id = FrmAppHelper::simple_get( 'form', 'absint', 0 ); | |
| 84 | - if ( $form_id ) { | |
| 85 | - $query_args['form'] = $form_id; | |
| 86 | - } | |
| 87 | - | |
| 88 | - return $query_args; | |
| 89 | - } | |
| 90 | - | |
| 91 | - /** | |
| 92 | 24 | * @since 2.05.07 |
| 93 | 25 | */ |
| 94 | 26 | private static function load_manage_entries_hooks() { |
| 95 | - if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show', 'new', 'duplicate' ), true ) ) { | |
| 27 | + if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show', 'new' ) ) ) { | |
| 96 | 28 | $menu_name = FrmAppHelper::get_menu_name(); |
| 97 | 29 | $base = self::base_column_key( $menu_name ); |
| 98 | 30 | |
| 99 | 31 | add_filter( 'manage_' . $base . '_columns', 'FrmEntriesController::manage_columns' ); |
| @@ -99,15 +31,13 @@ | ||
| 99 | 31 | add_filter( 'manage_' . $base . '_columns', 'FrmEntriesController::manage_columns' ); |
| 100 | 32 | add_filter( 'get_user_option_' . self::hidden_column_key( $menu_name ), 'FrmEntriesController::hidden_columns' ); |
| 101 | 33 | add_filter( 'manage_' . $base . '_sortable_columns', 'FrmEntriesController::sortable_columns' ); |
| 102 | 34 | } else { |
| 103 | - add_filter( 'screen_options_show_screen', self::class . '::remove_screen_options', 10, 2 ); | |
| 35 | + add_filter( 'screen_options_show_screen', __CLASS__ . '::remove_screen_options', 10, 2 ); | |
| 104 | 36 | } |
| 105 | 37 | } |
| 106 | 38 | |
| 107 | - /** | |
| 108 | - * Display in Back End. | |
| 109 | - */ | |
| 39 | + /* Display in Back End */ | |
| 110 | 40 | public static function route() { |
| 111 | 41 | $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
| 112 | 42 | FrmAppHelper::include_svg(); |
| 113 | 43 | |
| @@ -132,12 +62,10 @@ | ||
| 132 | 62 | * |
| 133 | 63 | * @since 3.0 |
| 134 | 64 | */ |
| 135 | 65 | public static function remove_screen_options( $show_screen, $screen ) { |
| 136 | - $menu_name = sanitize_title( FrmAppHelper::get_menu_name() ); | |
| 137 | - $unread_count = FrmEntriesHelper::get_visible_unread_inbox_count(); | |
| 138 | - | |
| 139 | - if ( $screen->id === $menu_name . ( $unread_count ? '-' . $unread_count : '' ) . '_page_formidable-entries' ) { | |
| 66 | + $menu_name = sanitize_title( FrmAppHelper::get_menu_name() ); | |
| 67 | + if ( $screen->id == $menu_name . '_page_formidable-entries' ) { | |
| 140 | 68 | $show_screen = false; |
| 141 | 69 | } |
| 142 | 70 | |
| 143 | 71 | return $show_screen; |
| @@ -152,14 +80,13 @@ | ||
| 152 | 80 | |
| 153 | 81 | if ( $form_id ) { |
| 154 | 82 | self::get_columns_for_form( $form_id, $columns ); |
| 155 | 83 | } else { |
| 156 | - $columns[ $form_id . '_form_id' ] = esc_html__( 'Form', 'formidable' ); | |
| 157 | - $columns[ $form_id . '_name' ] = esc_html__( 'Entry Name', 'formidable' ); | |
| 158 | - $columns[ $form_id . '_user_id' ] = esc_html__( 'Created By', 'formidable' ); | |
| 84 | + $columns[ $form_id . '_form_id' ] = __( 'Form', 'formidable' ); | |
| 85 | + $columns[ $form_id . '_name' ] = __( 'Entry Name', 'formidable' ); | |
| 86 | + $columns[ $form_id . '_user_id' ] = __( 'Created By', 'formidable' ); | |
| 159 | 87 | } |
| 160 | 88 | |
| 161 | - $columns[ $form_id . '_is_draft' ] = esc_html__( 'Entry Status', 'formidable' ); | |
| 162 | 89 | $columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' ); |
| 163 | 90 | $columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' ); |
| 164 | 91 | self::maybe_add_ip_col( $form_id, $columns ); |
| 165 | 92 | |
| @@ -169,9 +96,9 @@ | ||
| 169 | 96 | if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) { |
| 170 | 97 | add_screen_option( |
| 171 | 98 | 'per_page', |
| 172 | 99 | array( |
| 173 | - 'label' => esc_html__( 'Entries', 'formidable' ), | |
| 100 | + 'label' => __( 'Entries', 'formidable' ), | |
| 174 | 101 | 'default' => 20, |
| 175 | 102 | 'option' => 'formidable_page_formidable_entries_per_page', |
| 176 | 103 | ) |
| 177 | 104 | ); |
| @@ -182,24 +109,14 @@ | ||
| 182 | 109 | |
| 183 | 110 | private static function get_columns_for_form( $form_id, &$columns ) { |
| 184 | 111 | $form_cols = FrmField::get_all_for_form( $form_id, '', 'include' ); |
| 185 | 112 | |
| 186 | - /** | |
| 187 | - * Allows changing fields in the Entries list table heading. | |
| 188 | - * | |
| 189 | - * @since 5.0.04 | |
| 190 | - * | |
| 191 | - * @param array $fields Array of fields. | |
| 192 | - * @param array $args The arguments. Contains `form_id`. | |
| 193 | - */ | |
| 194 | - $form_cols = apply_filters( 'frm_fields_in_entries_list_table', $form_cols, compact( 'form_id' ) ); | |
| 195 | - | |
| 196 | 113 | foreach ( $form_cols as $form_col ) { |
| 197 | 114 | if ( FrmField::is_no_save_field( $form_col->type ) ) { |
| 198 | 115 | continue; |
| 199 | 116 | } |
| 200 | 117 | |
| 201 | - $has_child_fields = $form_col->type === 'form' && ! empty( $form_col->field_options['form_select'] ); | |
| 118 | + $has_child_fields = $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ); | |
| 202 | 119 | if ( $has_child_fields ) { |
| 203 | 120 | self::add_subform_cols( $form_col, $form_id, $columns ); |
| 204 | 121 | } else { |
| 205 | 122 | self::add_field_cols( $form_col, $form_id, $columns ); |
| @@ -235,9 +152,9 @@ | ||
| 235 | 152 | $col_id .= '-_-form' . $field->form_id; |
| 236 | 153 | } |
| 237 | 154 | |
| 238 | 155 | $has_separate_value = ! FrmField::is_option_empty( $field, 'separate_value' ); |
| 239 | - $is_post_status = FrmField::is_option_true( $field, 'post_field' ) && $field->field_options['post_field'] === 'post_status'; | |
| 156 | + $is_post_status = FrmField::is_option_true( $field, 'post_field' ) && $field->field_options['post_field'] == 'post_status'; | |
| 240 | 157 | if ( $has_separate_value && ! $is_post_status ) { |
| 241 | 158 | $columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $field->name, 35 ); |
| 242 | 159 | } |
| 243 | 160 | |
| @@ -260,10 +177,10 @@ | ||
| 260 | 177 | $prev_value = get_metadata( 'user', $object_id, $meta_key, true ); |
| 261 | 178 | } |
| 262 | 179 | |
| 263 | 180 | global $frm_vars; |
| 264 | - // Add a check so we don't create a loop. | |
| 265 | - $frm_vars['prev_hidden_cols'] = ! empty( $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; | |
| 181 | + //add a check so we don't create a loop | |
| 182 | + $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; | |
| 266 | 183 | |
| 267 | 184 | return $check; |
| 268 | 185 | } |
| 269 | 186 | |
| @@ -277,10 +194,9 @@ | ||
| 277 | 194 | } |
| 278 | 195 | |
| 279 | 196 | global $frm_vars; |
| 280 | 197 | if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) { |
| 281 | - // Don't continue if there's no previous value. | |
| 282 | - return; | |
| 198 | + return; // Don't continue if there's no previous value. | |
| 283 | 199 | } |
| 284 | 200 | |
| 285 | 201 | foreach ( $meta_value as $mk => $mv ) { |
| 286 | 202 | // Remove blank values. |
| @@ -334,15 +250,13 @@ | ||
| 334 | 250 | if ( empty( $menu_name ) ) { |
| 335 | 251 | $menu_name = FrmAppHelper::get_menu_name(); |
| 336 | 252 | } |
| 337 | 253 | |
| 338 | - $unread_count = FrmEntriesHelper::get_visible_unread_inbox_count(); | |
| 339 | - | |
| 340 | - return sanitize_title( $menu_name ) . ( $unread_count ? '-' . $unread_count : '' ) . '_page_formidable-entries'; | |
| 254 | + return sanitize_title( $menu_name ) . '_page_formidable-entries'; | |
| 341 | 255 | } |
| 342 | 256 | |
| 343 | 257 | public static function save_per_page( $save, $option, $value ) { |
| 344 | - if ( $option === 'formidable_page_formidable_entries_per_page' ) { | |
| 258 | + if ( $option == 'formidable_page_formidable_entries_per_page' ) { | |
| 345 | 259 | $save = (int) $value; |
| 346 | 260 | } |
| 347 | 261 | |
| 348 | 262 | return $save; |
| @@ -360,16 +274,11 @@ | ||
| 360 | 274 | $form_id . '_item_key' => 'item_key', |
| 361 | 275 | $form_id . '_is_draft' => 'is_draft', |
| 362 | 276 | ); |
| 363 | 277 | |
| 364 | - if ( ! $form_id ) { | |
| 365 | - $columns[ $form_id . '_user_id' ] = 'user_id'; | |
| 366 | - $columns[ $form_id . '_name' ] = 'name'; | |
| 367 | - $columns[ $form_id . '_form_id' ] = 'form_id'; | |
| 368 | - } | |
| 369 | - | |
| 370 | 278 | foreach ( $fields as $field ) { |
| 371 | - if ( self::field_supports_sorting( $field ) ) { | |
| 279 | + if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) { | |
| 280 | + // Can't sort on checkboxes because they are stored serialized, or post fields | |
| 372 | 281 | $columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id; |
| 373 | 282 | } |
| 374 | 283 | } |
| 375 | 284 | |
| @@ -375,42 +284,22 @@ | ||
| 375 | 284 | |
| 376 | 285 | return $columns; |
| 377 | 286 | } |
| 378 | 287 | |
| 379 | - /** | |
| 380 | - * Can't sort on checkboxes because they are sorted serialized. | |
| 381 | - * Some post content can be sorted but not everything. | |
| 382 | - * | |
| 383 | - * @param stdClass $field | |
| 384 | - * @return bool | |
| 385 | - */ | |
| 386 | - private static function field_supports_sorting( $field ) { | |
| 387 | - $is_sortable = 'checkbox' !== $field->type && empty( $field->field_options['post_field'] ); | |
| 388 | - return apply_filters( 'frm_field_column_is_sortable', $is_sortable, $field ); | |
| 389 | - } | |
| 390 | - | |
| 391 | - /** | |
| 392 | - * @param mixed $result Option value from database for hidden columns in entries table. | |
| 393 | - * @return array | |
| 394 | - */ | |
| 395 | 288 | public static function hidden_columns( $result ) { |
| 396 | - global $frm_vars; | |
| 289 | + $form_id = FrmForm::get_current_form_id(); | |
| 397 | 290 | |
| 398 | - if ( ! is_array( $result ) ) { | |
| 399 | - // Force an unexpected value to be an array. | |
| 400 | - // Since $result is a filtered option and gets saved to the database, it's possible it could be a string. | |
| 401 | - // Since this code expects an array it would break with a "Uncaught Error: [] operator not supported for strings" error. | |
| 402 | - $result = array(); | |
| 403 | - } | |
| 291 | + $hidden = self::user_hidden_columns_for_form( $form_id, $result ); | |
| 404 | 292 | |
| 405 | - $form_id = FrmForm::get_current_form_id(); | |
| 406 | - $hidden = self::user_hidden_columns_for_form( $form_id, $result ); | |
| 407 | - $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0; | |
| 408 | - $max_columns = 11; | |
| 293 | + global $frm_vars; | |
| 294 | + $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0; | |
| 409 | 295 | |
| 410 | 296 | if ( ! empty( $hidden ) ) { |
| 411 | - $result = $hidden; | |
| 412 | - $i = $i - count( $result ); | |
| 297 | + $result = $hidden; | |
| 298 | + $i = $i - count( $result ); | |
| 299 | + $max_columns = 11; | |
| 300 | + } else { | |
| 301 | + $max_columns = 8; | |
| 413 | 302 | } |
| 414 | 303 | |
| 415 | 304 | if ( $i <= $max_columns ) { |
| 416 | 305 | return $result; |
| @@ -429,9 +318,9 @@ | ||
| 429 | 318 | foreach ( (array) $result as $r ) { |
| 430 | 319 | if ( ! empty( $r ) ) { |
| 431 | 320 | list( $form_prefix, $field_key ) = explode( '_', $r ); |
| 432 | 321 | |
| 433 | - if ( (int) $form_prefix === (int) $form_id ) { | |
| 322 | + if ( (int) $form_prefix == (int) $form_id ) { | |
| 434 | 323 | $hidden[] = $r; |
| 435 | 324 | } |
| 436 | 325 | |
| 437 | 326 | unset( $form_prefix ); |
| @@ -444,12 +333,8 @@ | ||
| 444 | 333 | /** |
| 445 | 334 | * Remove some columns by default when there are too many |
| 446 | 335 | * |
| 447 | 336 | * @since 2.05.07 |
| 448 | - * | |
| 449 | - * @param array $atts | |
| 450 | - * @param array $result | |
| 451 | - * @return void | |
| 452 | 337 | */ |
| 453 | 338 | private static function remove_excess_cols( $atts, &$result ) { |
| 454 | 339 | global $frm_vars; |
| 455 | 340 | |
| @@ -467,9 +352,9 @@ | ||
| 467 | 352 | } |
| 468 | 353 | |
| 469 | 354 | if ( empty( $result ) || ! in_array( $col_key, $result, true ) ) { |
| 470 | 355 | $result[] = $col_key; |
| 471 | - --$i; | |
| 356 | + $i--; | |
| 472 | 357 | } |
| 473 | 358 | |
| 474 | 359 | unset( $col_key, $col ); |
| 475 | 360 | } |
| @@ -499,9 +384,9 @@ | ||
| 499 | 384 | $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
| 500 | 385 | if ( $pagenum > $total_pages && $total_pages > 0 ) { |
| 501 | 386 | $url = add_query_arg( 'paged', $total_pages ); |
| 502 | 387 | if ( headers_sent() ) { |
| 503 | - FrmAppHelper::js_redirect( $url, true ); | |
| 388 | + echo FrmAppHelper::js_redirect( $url ); // WPCS: XSS ok. | |
| 504 | 389 | } else { |
| 505 | 390 | wp_redirect( esc_url_raw( $url ) ); |
| 506 | 391 | } |
| 507 | 392 | die(); |
| @@ -510,24 +395,22 @@ | ||
| 510 | 395 | if ( empty( $message ) && isset( $_GET['import-message'] ) ) { |
| 511 | 396 | $message = __( 'Your import is complete', 'formidable' ); |
| 512 | 397 | } |
| 513 | 398 | |
| 514 | - require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php'; | |
| 399 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' ); | |
| 515 | 400 | } |
| 516 | 401 | |
| 517 | 402 | private static function get_delete_form_time( $form, &$errors ) { |
| 518 | - if ( 'trash' === $form->status ) { | |
| 403 | + if ( 'trash' == $form->status ) { | |
| 519 | 404 | $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); |
| 520 | - $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( $form->options['trash_time'] ?? time() ) ); | |
| 405 | + $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) ); | |
| 521 | 406 | |
| 522 | 407 | /* translators: %1$s: Time string */ |
| 523 | - $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 ); | |
| 408 | + $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 ); | |
| 524 | 409 | } |
| 525 | 410 | } |
| 526 | 411 | |
| 527 | - /** | |
| 528 | - * Back End CRUD. | |
| 529 | - */ | |
| 412 | + /* Back End CRUD */ | |
| 530 | 413 | public static function show( $id = 0 ) { |
| 531 | 414 | FrmAppHelper::permission_check( 'frm_view_entries' ); |
| 532 | 415 | |
| 533 | 416 | if ( ! $id ) { |
| @@ -539,15 +422,12 @@ | ||
| 539 | 422 | } |
| 540 | 423 | |
| 541 | 424 | $entry = FrmEntry::getOne( $id, true ); |
| 542 | 425 | if ( ! $entry ) { |
| 543 | - FrmAppController::show_error_modal( | |
| 544 | - array( | |
| 545 | - 'title' => __( 'You can\'t view the entry', 'formidable' ), | |
| 546 | - 'body' => __( 'You are trying to view an entry that does not exist', 'formidable' ), | |
| 547 | - 'cancel_url' => admin_url( 'admin.php?page=formidable' ), | |
| 548 | - ) | |
| 549 | - ); | |
| 426 | + echo '<div id="form_show_entry_page" class="wrap">' . | |
| 427 | + esc_html__( 'You are trying to view an entry that does not exist.', 'formidable' ) . | |
| 428 | + '</div>'; | |
| 429 | + | |
| 550 | 430 | return; |
| 551 | 431 | } |
| 552 | 432 | |
| 553 | 433 | $data = $entry->description; |
| @@ -557,28 +437,13 @@ | ||
| 557 | 437 | |
| 558 | 438 | $fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' ); |
| 559 | 439 | $form = FrmForm::getOne( $entry->form_id ); |
| 560 | 440 | |
| 561 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php'; | |
| 441 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' ); | |
| 562 | 442 | } |
| 563 | 443 | |
| 564 | - /** | |
| 565 | - * Destroy an entry from the admin page. | |
| 566 | - * This is triggered from the entries list from the "Delete" row action, and also from the "Delete Entry" trigger in the view/edit entry sidebar. | |
| 567 | - * | |
| 568 | - * @return void | |
| 569 | - */ | |
| 570 | 444 | public static function destroy() { |
| 571 | - $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_entries', '_wpnonce', -1 ); | |
| 572 | - if ( false !== $permission_error ) { | |
| 573 | - $error_args = array( | |
| 574 | - 'title' => __( 'Verification failed', 'formidable' ), | |
| 575 | - 'body' => $permission_error, | |
| 576 | - 'cancel_url' => admin_url( 'admin.php?page=formidable-entries' ), | |
| 577 | - ); | |
| 578 | - FrmAppController::show_error_modal( $error_args ); | |
| 579 | - return; | |
| 580 | - } | |
| 445 | + FrmAppHelper::permission_check( 'frm_delete_entries' ); | |
| 581 | 446 | |
| 582 | 447 | $params = FrmForm::get_admin_params(); |
| 583 | 448 | |
| 584 | 449 | if ( isset( $params['keep_post'] ) && $params['keep_post'] ) { |
| @@ -586,17 +451,27 @@ | ||
| 586 | 451 | } |
| 587 | 452 | |
| 588 | 453 | $message = ''; |
| 589 | 454 | if ( FrmEntry::destroy( $params['id'] ) ) { |
| 590 | - $message = __( 'Entry was successfully deleted', 'formidable' ); | |
| 455 | + $message = __( 'Entry was Successfully Deleted', 'formidable' ); | |
| 591 | 456 | } |
| 592 | 457 | |
| 593 | 458 | self::display_list( $message ); |
| 594 | 459 | } |
| 595 | 460 | |
| 461 | + /** | |
| 462 | + * @deprecated 4.02.04 - Moved to Pro since it was unused in Lite. | |
| 463 | + */ | |
| 464 | + public static function destroy_all() { | |
| 465 | + _deprecated_function( __METHOD__, '4.02.04', 'FrmProEntriesController::destroy_all' ); | |
| 466 | + if ( is_callable( 'FrmProEntriesController::destroy_all' ) ) { | |
| 467 | + FrmProEntriesController::destroy_all(); | |
| 468 | + } | |
| 469 | + } | |
| 470 | + | |
| 596 | 471 | public static function process_entry( $errors = '', $ajax = false ) { |
| 597 | 472 | $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' ); |
| 598 | - if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 473 | + if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) { | |
| 599 | 474 | return; |
| 600 | 475 | } |
| 601 | 476 | |
| 602 | 477 | global $frm_vars; |
| @@ -605,13 +480,8 @@ | ||
| 605 | 480 | if ( ! $form ) { |
| 606 | 481 | return; |
| 607 | 482 | } |
| 608 | 483 | |
| 609 | - $is_preview = 'frm_forms_preview' === FrmAppHelper::simple_get( 'action' ); | |
| 610 | - if ( $is_preview && FrmFormsHelper::should_block_preview( $form->form_key ) ) { | |
| 611 | - return; | |
| 612 | - } | |
| 613 | - | |
| 614 | 484 | $params = FrmForm::get_params( $form ); |
| 615 | 485 | |
| 616 | 486 | if ( ! isset( $frm_vars['form_params'] ) ) { |
| 617 | 487 | $frm_vars['form_params'] = array(); |
| @@ -622,9 +492,9 @@ | ||
| 622 | 492 | return; |
| 623 | 493 | } |
| 624 | 494 | |
| 625 | 495 | if ( $errors == '' && ! $ajax ) { |
| 626 | - $errors = FrmEntryValidate::validate( wp_unslash( $_POST ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 496 | + $errors = FrmEntryValidate::validate( wp_unslash( $_POST ) ); | |
| 627 | 497 | } |
| 628 | 498 | |
| 629 | 499 | /** |
| 630 | 500 | * Use this filter to add trigger actions and add errors after |
| @@ -638,11 +508,11 @@ | ||
| 638 | 508 | |
| 639 | 509 | if ( empty( $errors ) ) { |
| 640 | 510 | $_POST['frm_skip_cookie'] = 1; |
| 641 | 511 | $do_success = false; |
| 642 | - if ( $params['action'] === 'create' ) { | |
| 512 | + if ( $params['action'] == 'create' ) { | |
| 643 | 513 | if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) { |
| 644 | - $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 514 | + $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); | |
| 645 | 515 | |
| 646 | 516 | $params['id'] = $frm_vars['created_entries'][ $form_id ]['entry_id']; |
| 647 | 517 | $do_success = true; |
| 648 | 518 | } |
| @@ -651,9 +521,9 @@ | ||
| 651 | 521 | do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); |
| 652 | 522 | if ( $do_success ) { |
| 653 | 523 | FrmFormsController::maybe_trigger_redirect( $form, $params, array( 'ajax' => $ajax ) ); |
| 654 | 524 | } |
| 655 | - unset( $_POST['frm_skip_cookie'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 525 | + unset( $_POST['frm_skip_cookie'] ); | |
| 656 | 526 | } |
| 657 | 527 | } |
| 658 | 528 | |
| 659 | 529 | /** |
| @@ -705,42 +575,39 @@ | ||
| 705 | 575 | FrmEntry::clear_cache(); |
| 706 | 576 | } |
| 707 | 577 | |
| 708 | 578 | /** |
| 709 | - * @param array $atts | |
| 579 | + * @param $atts | |
| 710 | 580 | * |
| 711 | 581 | * @return array|string |
| 712 | 582 | */ |
| 713 | 583 | public static function show_entry_shortcode( $atts ) { |
| 714 | 584 | $defaults = array( |
| 715 | - 'id' => false, | |
| 716 | - 'entry' => false, | |
| 717 | - 'fields' => false, | |
| 718 | - 'plain_text' => false, | |
| 719 | - 'user_info' => false, | |
| 720 | - 'include_blank' => false, | |
| 721 | - 'default_email' => false, | |
| 722 | - 'form_id' => false, | |
| 723 | - 'format' => 'text', | |
| 724 | - 'array_key' => 'key', | |
| 725 | - 'direction' => 'ltr', | |
| 726 | - 'font_size' => '', | |
| 727 | - 'text_color' => '', | |
| 728 | - 'border_width' => '', | |
| 729 | - 'border_color' => '', | |
| 730 | - 'bg_color' => '', | |
| 731 | - 'alt_bg_color' => '', | |
| 732 | - 'class' => '', | |
| 733 | - 'clickable' => false, | |
| 734 | - 'exclude_fields' => '', | |
| 735 | - 'include_fields' => '', | |
| 736 | - 'include_extras' => '', | |
| 737 | - 'inline_style' => 1, | |
| 738 | - 'table_style' => '', | |
| 739 | - // Return embedded fields as nested array. | |
| 740 | - 'child_array' => false, | |
| 741 | - 'line_breaks' => true, | |
| 742 | - 'array_separator' => ', ', | |
| 585 | + 'id' => false, | |
| 586 | + 'entry' => false, | |
| 587 | + 'fields' => false, | |
| 588 | + 'plain_text' => false, | |
| 589 | + 'user_info' => false, | |
| 590 | + 'include_blank' => false, | |
| 591 | + 'default_email' => false, | |
| 592 | + 'form_id' => false, | |
| 593 | + 'format' => 'text', | |
| 594 | + 'array_key' => 'key', | |
| 595 | + 'direction' => 'ltr', | |
| 596 | + 'font_size' => '', | |
| 597 | + 'text_color' => '', | |
| 598 | + 'border_width' => '', | |
| 599 | + 'border_color' => '', | |
| 600 | + 'bg_color' => '', | |
| 601 | + 'alt_bg_color' => '', | |
| 602 | + 'class' => '', | |
| 603 | + 'clickable' => false, | |
| 604 | + 'exclude_fields' => '', | |
| 605 | + 'include_fields' => '', | |
| 606 | + 'include_extras' => '', | |
| 607 | + 'inline_style' => 1, | |
| 608 | + 'child_array' => false, // return embedded fields as nested array | |
| 609 | + 'line_breaks' => true, | |
| 743 | 610 | ); |
| 744 | 611 | $defaults = apply_filters( 'frm_show_entry_defaults', $defaults ); |
| 745 | 612 | |
| 746 | 613 | $atts = shortcode_atts( $defaults, $atts ); |
| @@ -776,18 +643,33 @@ | ||
| 776 | 643 | $data = $entry->description; |
| 777 | 644 | if ( isset( $data['browser'] ) ) { |
| 778 | 645 | $browser = FrmEntriesHelper::get_browser( $data['browser'] ); |
| 779 | 646 | } |
| 780 | - /** | |
| 781 | - * Add or remove information in the entry sidebar. | |
| 782 | - * | |
| 783 | - * @since 5.5.2 | |
| 784 | - * | |
| 785 | - * @param array $data | |
| 786 | - * @param array{entry:\stdClass} $entry | |
| 787 | - */ | |
| 788 | - $data = apply_filters( 'frm_sidebar_data', $data, compact( 'entry' ) ); | |
| 789 | 647 | } |
| 790 | 648 | |
| 791 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php'; | |
| 649 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' ); | |
| 650 | + } | |
| 651 | + | |
| 652 | + /** | |
| 653 | + * @deprecated 4.0 | |
| 654 | + */ | |
| 655 | + public static function contextual_help( $help, $screen_id, $screen ) { | |
| 656 | + _deprecated_function( __METHOD__, '4.0' ); | |
| 657 | + return $help; | |
| 658 | + } | |
| 659 | + | |
| 660 | + /** | |
| 661 | + * @deprecated 1.07.05 | |
| 662 | + * @codeCoverageIgnore | |
| 663 | + */ | |
| 664 | + public static function show_form( $id = '', $key = '', $title = false, $description = false ) { | |
| 665 | + return FrmDeprecated::show_form( $id, $key, $title, $description ); | |
| 666 | + } | |
| 667 | + | |
| 668 | + /** | |
| 669 | + * @deprecated 1.07.05 | |
| 670 | + * @codeCoverageIgnore | |
| 671 | + */ | |
| 672 | + public static function get_form( $filename, $form, $title, $description ) { | |
| 673 | + return FrmDeprecated::get_form( $filename, $form, $title, $description ); | |
| 792 | 674 | } |
| 793 | 675 | } |