esc_like( $search ) . '%'; } if ( ! empty( $args ) ) { $sql = "SELECT * FROM {$table} WHERE {$where} ORDER BY created_at DESC"; $rows = $wpdb->get_results( $wpdb->prepare( $sql, ...$args ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared } else { $rows = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$table} WHERE 1=1 ORDER BY created_at DESC" ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared } $forms = Form::all(); ?>
fields, true ); $preview = is_array( $data ) && $data ? ( $data[0]['label'] . ': ' . $data[0]['value'] ) : ''; $form = new Form( $row->form_id ); $view_url = add_query_arg( [ 'page' => Admin::SLUG . '-entries', 'entry' => $row->id, ], admin_url( 'admin.php' ) ); $del_url = wp_nonce_url( add_query_arg( [ 'page' => Admin::SLUG . '-entries', 'action' => 'delete', 'entry' => $row->id, ], admin_url( 'admin.php' ) ), 'phemightforms_delete_entry_' . $row->id ); ?>
#id ); ?> exists() ? $form->title : __( '(deleted form)', 'phemightforms' ) ); ?> status ) : ?> created_at ) ); ?>
get_row( $wpdb->prepare( "SELECT * FROM {$table} WHERE id = %d", $entry_id ) ); // phpcs:ignore WordPress.DB if ( ! $row ) { echo '
'; Admin::header( 'entries' ); echo '

' . esc_html__( 'Entry not found.', 'phemightforms' ) . '

'; return; } // Mark as read. if ( 'read' !== $row->status ) { $wpdb->update( $table, [ 'status' => 'read' ], [ 'id' => $entry_id ], [ '%s' ], [ '%d' ] ); // phpcs:ignore WordPress.DB } $data = json_decode( $row->fields, true ); $back_url = add_query_arg( [ 'page' => Admin::SLUG . '-entries' ], admin_url( 'admin.php' ) ); $form = new Form( $row->form_id ); ?>

exists() ? $form->title : __( '(deleted form)', 'phemightforms' ) ); ?>

exists() ? $form->title : __( '(deleted form)', 'phemightforms' ) ); ?>
<?php esc_attr_e( 'Signature', 'phemightforms' ); ?>
created_at ) ); ?>
ip_address ); ?>

delete( Install::entries_table(), [ 'id' => $entry_id ], [ '%d' ] ); // phpcs:ignore WordPress.DB wp_safe_redirect( add_query_arg( [ 'page' => Admin::SLUG . '-entries' ], admin_url( 'admin.php' ) ) ); exit; } /** * Bulk update or delete entries. */ private static function handle_bulk() { check_admin_referer( 'phemightforms_bulk_entries' ); if ( ! current_user_can( Admin::CAPABILITY ) ) { wp_die( esc_html__( 'Permission denied.', 'phemightforms' ) ); } global $wpdb; $table = Install::entries_table(); $action = isset( $_POST['bulk_action'] ) ? sanitize_key( wp_unslash( $_POST['bulk_action'] ) ) : ''; $ids = isset( $_POST['entry_ids'] ) ? array_map( 'absint', (array) wp_unslash( $_POST['entry_ids'] ) ) : []; foreach ( $ids as $id ) { if ( 'delete' === $action ) { $wpdb->delete( $table, [ 'id' => $id ], [ '%d' ] ); // phpcs:ignore WordPress.DB } elseif ( 'read' === $action ) { $wpdb->update( $table, [ 'status' => 'read' ], [ 'id' => $id ], [ '%s' ], [ '%d' ] ); // phpcs:ignore WordPress.DB } elseif ( 'unread' === $action ) { $wpdb->update( $table, [ 'status' => 'unread' ], [ 'id' => $id ], [ '%s' ], [ '%d' ] ); // phpcs:ignore WordPress.DB } } wp_safe_redirect( add_query_arg( [ 'page' => Admin::SLUG . '-entries' ], admin_url( 'admin.php' ) ) ); exit; } /** * Save entry notes and tags. */ private static function handle_save_meta() { $entry_id = isset( $_GET['entry'] ) ? absint( wp_unslash( $_GET['entry'] ) ) : 0; check_admin_referer( 'phemightforms_entry_meta_' . $entry_id ); if ( ! current_user_can( Admin::CAPABILITY ) ) { wp_die( esc_html__( 'Permission denied.', 'phemightforms' ) ); } global $wpdb; $wpdb->update( // phpcs:ignore WordPress.DB Install::entries_table(), [ 'notes' => isset( $_POST['notes'] ) ? sanitize_textarea_field( wp_unslash( $_POST['notes'] ) ) : '', 'tags' => isset( $_POST['tags'] ) ? sanitize_text_field( wp_unslash( $_POST['tags'] ) ) : '', ], [ 'id' => $entry_id ], [ '%s', '%s' ], [ '%d' ] ); wp_safe_redirect( add_query_arg( [ 'page' => Admin::SLUG . '-entries', 'entry' => $entry_id, 'saved' => 1, ], admin_url( 'admin.php' ) ) ); exit; } }