| @@ -3,107 +3,51 @@ | ||
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | class FrmEntriesListHelper extends FrmListHelper { |
| 7 | - | |
| 8 | - /** | |
| 9 | - * @var string|null | |
| 10 | - */ | |
| 11 | 7 | protected $column_name; |
| 8 | + protected $item; | |
| 9 | + protected $field; | |
| 12 | 10 | |
| 13 | 11 | /** |
| 14 | 12 | * @since 4.07 |
| 15 | - * | |
| 16 | - * @var bool|int | |
| 17 | 13 | */ |
| 18 | 14 | public $total_items = 0; |
| 19 | 15 | |
| 20 | - /** | |
| 21 | - * @param array $args | |
| 22 | - */ | |
| 23 | - public function __construct( $args ) { | |
| 24 | - parent::__construct( $args ); | |
| 25 | - $this->screen->set_screen_reader_content( | |
| 26 | - array( | |
| 27 | - 'heading_list' => esc_html__( 'Entries list', 'formidable' ), | |
| 28 | - ) | |
| 29 | - ); | |
| 30 | - } | |
| 31 | - | |
| 32 | - /** | |
| 33 | - * @return void | |
| 34 | - */ | |
| 35 | 16 | public function prepare_items() { |
| 36 | - $this->set_per_page(); | |
| 37 | - $s_query = array(); | |
| 38 | - $join_form_in_query = false; | |
| 17 | + global $per_page; | |
| 39 | 18 | |
| 40 | - $this->items = $this->get_entry_items( $s_query, $join_form_in_query ); | |
| 41 | - $this->set_total_items( $s_query ); | |
| 42 | - $this->prepare_pagination(); | |
| 43 | - } | |
| 19 | + $per_page = $this->get_items_per_page( 'formidable_page_formidable_entries_per_page' ); | |
| 20 | + $form_id = $this->params['form']; | |
| 44 | 21 | |
| 45 | - /** | |
| 46 | - * @param array $s_query | |
| 47 | - * | |
| 48 | - * @return void | |
| 49 | - */ | |
| 50 | - protected function set_total_items( $s_query ) { | |
| 51 | - $this->total_items = FrmEntry::getRecordCount( $s_query ); | |
| 52 | - } | |
| 22 | + $s_query = array(); | |
| 53 | 23 | |
| 54 | - /** | |
| 55 | - * Prepares pagination. | |
| 56 | - * | |
| 57 | - * @since 6.5.4 | |
| 58 | - * | |
| 59 | - * @return void | |
| 60 | - */ | |
| 61 | - protected function prepare_pagination() { | |
| 62 | - global $per_page; | |
| 24 | + if ( $form_id ) { | |
| 25 | + $s_query['it.form_id'] = $form_id; | |
| 26 | + $join_form_in_query = false; | |
| 27 | + } else { | |
| 28 | + $s_query[] = array( | |
| 29 | + 'or' => 1, | |
| 30 | + 'parent_form_id' => null, | |
| 31 | + 'parent_form_id <' => 1, | |
| 32 | + ); | |
| 33 | + $join_form_in_query = true; | |
| 34 | + } | |
| 63 | 35 | |
| 64 | - $this->set_pagination_args( | |
| 36 | + $s = self::get_param( | |
| 65 | 37 | array( |
| 66 | - 'total_items' => $this->total_items, | |
| 67 | - 'per_page' => $per_page, | |
| 38 | + 'param' => 's', | |
| 39 | + 'sanitize' => 'sanitize_text_field', | |
| 68 | 40 | ) |
| 69 | 41 | ); |
| 70 | - } | |
| 71 | 42 | |
| 72 | - /** | |
| 73 | - * Sets the global $per_page variable | |
| 74 | - * | |
| 75 | - * @since 6.5.4 | |
| 76 | - * | |
| 77 | - * @return void | |
| 78 | - */ | |
| 79 | - protected function set_per_page() { | |
| 80 | - global $per_page; | |
| 81 | - $per_page = $this->get_items_per_page( 'formidable_page_formidable_entries_per_page' ); | |
| 82 | - } | |
| 43 | + if ( $s != '' && FrmAppHelper::pro_is_installed() ) { | |
| 44 | + $fid = self::get_param( array( 'param' => 'fid' ) ); | |
| 45 | + $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid ); | |
| 46 | + } | |
| 83 | 47 | |
| 84 | - /** | |
| 85 | - * @since 6.5.4 | |
| 86 | - * | |
| 87 | - * @param array $s_query | |
| 88 | - * @param bool $join_form_in_query | |
| 89 | - * | |
| 90 | - * @return array | |
| 91 | - */ | |
| 92 | - protected function get_entry_items( &$s_query, &$join_form_in_query ) { | |
| 93 | - global $per_page; | |
| 94 | - $s_query = $this->get_search_query( $join_form_in_query ); | |
| 95 | - $limit = $this->get_limit( $per_page ); | |
| 48 | + $s_query = apply_filters( 'frm_entries_list_query', $s_query, compact( 'form_id' ) ); | |
| 96 | 49 | |
| 97 | - return FrmEntry::getAll( $s_query, $this->get_order_by(), $limit, true, $join_form_in_query ); | |
| 98 | - } | |
| 99 | - | |
| 100 | - /** | |
| 101 | - * @since 6.5.4 | |
| 102 | - * | |
| 103 | - * @return string | |
| 104 | - */ | |
| 105 | - protected function get_order_by() { | |
| 106 | 50 | $orderby = self::get_param( |
| 107 | 51 | array( |
| 108 | 52 | 'param' => 'orderby', |
| 109 | 53 | 'default' => 'id', |
| @@ -108,36 +52,22 @@ | ||
| 108 | 52 | 'param' => 'orderby', |
| 109 | 53 | 'default' => 'id', |
| 110 | 54 | ) |
| 111 | 55 | ); |
| 112 | - $order = self::get_param( | |
| 56 | + | |
| 57 | + if ( strpos( $orderby, 'meta' ) !== false ) { | |
| 58 | + $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) ); | |
| 59 | + $orderby .= in_array( $order_field_type, array( 'number', 'scale', 'star' ) ) ? '+0' : ''; | |
| 60 | + } | |
| 61 | + | |
| 62 | + $order = self::get_param( | |
| 113 | 63 | array( |
| 114 | 64 | 'param' => 'order', |
| 115 | 65 | 'default' => 'DESC', |
| 116 | 66 | ) |
| 117 | 67 | ); |
| 68 | + $order = FrmDb::esc_order( $orderby . ' ' . $order ); | |
| 118 | 69 | |
| 119 | - FrmAppController::apply_saved_sort_preference( $orderby, $order ); | |
| 120 | - | |
| 121 | - if ( str_contains( $orderby, 'meta' ) ) { | |
| 122 | - $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) ); | |
| 123 | - | |
| 124 | - if ( in_array( $order_field_type, array( 'number', 'scale', 'star' ), true ) ) { | |
| 125 | - $orderby .= '+0'; | |
| 126 | - } | |
| 127 | - } | |
| 128 | - | |
| 129 | - return FrmDb::esc_order( $orderby . ' ' . $order ); | |
| 130 | - } | |
| 131 | - | |
| 132 | - /** | |
| 133 | - * @since 6.5.4 | |
| 134 | - * | |
| 135 | - * @param int $per_page | |
| 136 | - * | |
| 137 | - * @return string | |
| 138 | - */ | |
| 139 | - protected function get_limit( $per_page ) { | |
| 140 | 70 | $page = $this->get_pagenum(); |
| 141 | 71 | $start = (int) self::get_param( |
| 142 | 72 | array( |
| 143 | 73 | 'param' => 'start', |
| @@ -144,63 +74,21 @@ | ||
| 144 | 74 | 'default' => ( $page - 1 ) * $per_page, |
| 145 | 75 | ) |
| 146 | 76 | ); |
| 147 | 77 | |
| 148 | - return FrmDb::esc_limit( $start . ',' . $per_page ); | |
| 149 | - } | |
| 78 | + $limit = FrmDb::esc_limit( $start . ',' . $per_page ); | |
| 79 | + $this->items = FrmEntry::getAll( $s_query, $order, $limit, true, $join_form_in_query ); | |
| 80 | + $total_items = FrmEntry::getRecordCount( $s_query ); | |
| 81 | + $this->total_items = $total_items; | |
| 150 | 82 | |
| 151 | - /** | |
| 152 | - * @since 6.5.4 | |
| 153 | - * | |
| 154 | - * @param bool $join_form_in_query | |
| 155 | - * | |
| 156 | - * @return array | |
| 157 | - */ | |
| 158 | - protected function get_search_query( &$join_form_in_query ) { | |
| 159 | - $form_id = $this->params['form']; | |
| 160 | - $s_query = array(); | |
| 161 | - | |
| 162 | - if ( $form_id ) { | |
| 163 | - $form_ids = $this->get_form_ids( $form_id ); | |
| 164 | - $s_query['it.form_id'] = count( $form_ids ) > 1 ? $form_ids : $form_ids[0]; | |
| 165 | - } else { | |
| 166 | - $s_query[] = array( | |
| 167 | - 'or' => 1, | |
| 168 | - 'parent_form_id' => null, | |
| 169 | - 'parent_form_id <' => 1, | |
| 170 | - ); | |
| 171 | - $join_form_in_query = true; | |
| 172 | - } | |
| 173 | - | |
| 174 | - $s = self::get_param( | |
| 83 | + $this->set_pagination_args( | |
| 175 | 84 | array( |
| 176 | - 'param' => 's', | |
| 177 | - 'sanitize' => 'sanitize_text_field', | |
| 85 | + 'total_items' => $total_items, | |
| 86 | + 'per_page' => $per_page, | |
| 178 | 87 | ) |
| 179 | 88 | ); |
| 180 | - | |
| 181 | - if ( $s !== '' && FrmAppHelper::pro_is_installed() ) { | |
| 182 | - $fid = self::get_param( array( 'param' => 'fid' ) ); | |
| 183 | - $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid ); | |
| 184 | - } | |
| 185 | - | |
| 186 | - return apply_filters( 'frm_entries_list_query', $s_query, compact( 'form_id' ) ); | |
| 187 | 89 | } |
| 188 | 90 | |
| 189 | - /** | |
| 190 | - * @since 6.5.4 | |
| 191 | - * | |
| 192 | - * @param int|string $form_id | |
| 193 | - * | |
| 194 | - * @return array<int> | |
| 195 | - */ | |
| 196 | - protected function get_form_ids( $form_id ) { | |
| 197 | - return array( (int) $form_id ); | |
| 198 | - } | |
| 199 | - | |
| 200 | - /** | |
| 201 | - * @return void | |
| 202 | - */ | |
| 203 | 91 | public function no_items() { |
| 204 | 92 | $s = self::get_param( |
| 205 | 93 | array( |
| 206 | 94 | 'param' => 's', |
| @@ -206,23 +94,11 @@ | ||
| 206 | 94 | 'param' => 's', |
| 207 | 95 | 'sanitize' => 'sanitize_text_field', |
| 208 | 96 | ) |
| 209 | 97 | ); |
| 98 | + if ( ! empty( $s ) ) { | |
| 99 | + esc_html_e( 'No Entries Found', 'formidable' ); | |
| 210 | 100 | |
| 211 | - if ( $s !== '' ) { | |
| 212 | - $current_url = set_url_scheme( | |
| 213 | - 'http://' . FrmAppHelper::get_server_value( 'HTTP_HOST' ) . FrmAppHelper::get_server_value( 'REQUEST_URI' ) | |
| 214 | - ); | |
| 215 | - $clear_url = remove_query_arg( 's', $current_url ); | |
| 216 | - | |
| 217 | - echo '<p>'; | |
| 218 | - printf( | |
| 219 | - /* translators: %1$s: Start link HTML, %2$s: End link HTML */ | |
| 220 | - esc_html__( 'No entries match your search. %1$sClear search%2$s', 'formidable' ), | |
| 221 | - '<a href="' . esc_url( $clear_url ) . '">', | |
| 222 | - '</a>' | |
| 223 | - ); | |
| 224 | - echo '</p>'; | |
| 225 | 101 | return; |
| 226 | 102 | } |
| 227 | 103 | |
| 228 | 104 | $form_id = $this->params['form']; |
| @@ -230,9 +106,8 @@ | ||
| 230 | 106 | |
| 231 | 107 | if ( $form_id ) { |
| 232 | 108 | $form = FrmForm::getOne( $form_id ); |
| 233 | 109 | } |
| 234 | - | |
| 235 | 110 | $has_form = ! empty( $form ); |
| 236 | 111 | |
| 237 | 112 | if ( ! $has_form ) { |
| 238 | 113 | $has_form = FrmForm::getAll( array(), '', 1 ); |
| @@ -240,70 +115,42 @@ | ||
| 240 | 115 | } |
| 241 | 116 | |
| 242 | 117 | $colspan = $this->get_column_count(); |
| 243 | 118 | |
| 244 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php'; | |
| 119 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php' ); | |
| 245 | 120 | } |
| 246 | 121 | |
| 247 | - /** | |
| 248 | - * @param string $text Text. | |
| 249 | - * @param string $input_id Input ID. | |
| 250 | - * | |
| 251 | - * @return void | |
| 252 | - */ | |
| 253 | 122 | public function search_box( $text, $input_id ) { |
| 254 | 123 | // Searching is a pro feature |
| 255 | 124 | } |
| 256 | 125 | |
| 257 | - /** | |
| 258 | - * @param string $which | |
| 259 | - * | |
| 260 | - * @return void | |
| 261 | - */ | |
| 262 | 126 | protected function display_tablenav( $which ) { |
| 263 | - $is_footer = $which !== 'top'; | |
| 264 | - | |
| 127 | + $is_footer = ( $which !== 'top' ); | |
| 265 | 128 | if ( $is_footer && ! empty( $this->items ) ) { |
| 266 | - $utm = array( | |
| 267 | - 'campaign' => 'spam-protection', | |
| 268 | - 'content' => 'entries-list-spam-protection', | |
| 269 | - ); | |
| 270 | - // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 271 | 129 | ?> |
| 272 | 130 | <p> |
| 273 | 131 | <?php esc_html_e( 'Getting spam form submissions?', 'formidable' ); ?> |
| 274 | - <a href="<?php echo esc_url( FrmAppHelper::admin_upgrade_link( $utm, 'knowledgebase/add-spam-protection/' ) ); ?>" target="_blank"> | |
| 132 | + <a href="https://formidableforms.com/knowledgebase/add-spam-protection/" target="_blank"> | |
| 275 | 133 | <?php esc_html_e( 'Learn how to prevent them.', 'formidable' ); ?> |
| 276 | 134 | </a> |
| 277 | 135 | </p> |
| 278 | 136 | <?php |
| 279 | - // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 280 | 137 | } |
| 281 | 138 | parent::display_tablenav( $which ); |
| 282 | 139 | } |
| 283 | 140 | |
| 284 | - /** | |
| 285 | - * @param string $which | |
| 286 | - * | |
| 287 | - * @return void | |
| 288 | - */ | |
| 289 | 141 | protected function extra_tablenav( $which ) { |
| 290 | 142 | $form_id = FrmAppHelper::simple_get( 'form', 'absint' ); |
| 143 | + if ( $which === 'top' && ! $form_id ) { | |
| 144 | + echo '<div class="alignleft actions">'; | |
| 291 | 145 | |
| 292 | - if ( $which !== 'top' || $form_id ) { | |
| 293 | - return; | |
| 146 | + // Override the referrer to prevent it from being used for the screen options. | |
| 147 | + echo '<input type="hidden" name="_wp_http_referer" value="" />'; | |
| 148 | + | |
| 149 | + FrmFormsHelper::forms_dropdown( 'form', $form_id, array( 'blank' => __( 'View all forms', 'formidable' ) ) ); | |
| 150 | + submit_button( __( 'Filter', 'formidable' ), 'filter_action action', '', false, array( 'id' => 'post-query-submit' ) ); | |
| 151 | + echo '</div>'; | |
| 294 | 152 | } |
| 295 | - | |
| 296 | - echo '<div class="alignleft actions">'; | |
| 297 | - | |
| 298 | - // Override the referrer to prevent it from being used for the screen options. | |
| 299 | - echo '<input type="hidden" name="_wp_http_referer" value="" />'; | |
| 300 | - | |
| 301 | - echo '<label for="form" class="screen-reader-text">' . esc_html__( 'Filter by form', 'formidable' ) . '</label>'; | |
| 302 | - | |
| 303 | - FrmFormsHelper::forms_dropdown( 'form', $form_id, array( 'blank' => __( 'View all forms', 'formidable' ) ) ); | |
| 304 | - submit_button( __( 'Filter', 'formidable' ), 'filter_action action', '', false, array( 'id' => 'post-query-submit' ) ); | |
| 305 | - echo '</div>'; | |
| 306 | 153 | } |
| 307 | 154 | |
| 308 | 155 | /** |
| 309 | 156 | * Gets the name of the primary column in the Entries screen |
| @@ -309,17 +156,18 @@ | ||
| 309 | 156 | * Gets the name of the primary column in the Entries screen |
| 310 | 157 | * |
| 311 | 158 | * @since 2.0.14 |
| 312 | 159 | * |
| 313 | - * @return string Primary column. | |
| 160 | + * @return string $primary_column | |
| 314 | 161 | */ |
| 315 | 162 | protected function get_primary_column_name() { |
| 316 | - $columns = get_column_headers( $this->screen ); | |
| 317 | - $hidden = get_hidden_columns( $this->screen ); | |
| 163 | + $columns = get_column_headers( $this->screen ); | |
| 164 | + $hidden = get_hidden_columns( $this->screen ); | |
| 165 | + | |
| 318 | 166 | $primary_column = ''; |
| 319 | 167 | |
| 320 | 168 | foreach ( $columns as $column_key => $column_display_name ) { |
| 321 | - if ( 'cb' !== $column_key && ! in_array( $column_key, $hidden, true ) ) { | |
| 169 | + if ( 'cb' != $column_key && ! in_array( $column_key, $hidden ) ) { | |
| 322 | 170 | $primary_column = $column_key; |
| 323 | 171 | break; |
| 324 | 172 | } |
| 325 | 173 | } |
| @@ -326,29 +174,8 @@ | ||
| 326 | 174 | |
| 327 | 175 | return $primary_column; |
| 328 | 176 | } |
| 329 | 177 | |
| 330 | - /** | |
| 331 | - * @since 6.12 | |
| 332 | - * | |
| 333 | - * @param object $item | |
| 334 | - * | |
| 335 | - * @return string | |
| 336 | - */ | |
| 337 | - private static function get_entry_label( $item ) { | |
| 338 | - if ( $item->name ) { | |
| 339 | - return $item->name; | |
| 340 | - } | |
| 341 | - /* translators: %d: Entry id */ | |
| 342 | - return sprintf( __( 'Entry %d', 'formidable' ), $item->id ); | |
| 343 | - } | |
| 344 | - | |
| 345 | - /** | |
| 346 | - * @param stdClass $item | |
| 347 | - * @param string $style | |
| 348 | - * | |
| 349 | - * @return string | |
| 350 | - */ | |
| 351 | 178 | public function single_row( $item, $style = '' ) { |
| 352 | 179 | // Set up the hover actions for this user |
| 353 | 180 | $actions = array(); |
| 354 | 181 | $view_link = '?page=formidable-entries&frm_action=show&id=' . $item->id; |
| @@ -358,10 +185,8 @@ | ||
| 358 | 185 | $action_links = $this->row_actions( $actions ); |
| 359 | 186 | |
| 360 | 187 | // Set up the checkbox ( because the user is editable, otherwise its empty ) |
| 361 | 188 | $checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />"; |
| 362 | - /* translators: %s: Form name */ | |
| 363 | - $checkbox .= "<label for='cb-item-action-{$item->id}'><span class='screen-reader-text'>" . esc_html( sprintf( __( 'Select %s', 'formidable' ), self::get_entry_label( $item ) ) ) . '</span></label>'; // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 364 | 189 | |
| 365 | 190 | $r = "<tr id='item-action-{$item->id}'$style>"; |
| 366 | 191 | |
| 367 | 192 | list( $columns, $hidden, , $primary ) = $this->get_column_info(); |
| @@ -375,9 +200,9 @@ | ||
| 375 | 200 | $class .= ' column-primary'; |
| 376 | 201 | } |
| 377 | 202 | |
| 378 | 203 | if ( in_array( $column_name, $hidden, true ) ) { |
| 379 | - $class .= ' hidden'; | |
| 204 | + $class .= ' frm_hidden'; | |
| 380 | 205 | } elseif ( ! $action_col && ! in_array( $column_name, $action_columns, true ) ) { |
| 381 | 206 | $action_col = $column_name; |
| 382 | 207 | } |
| 383 | 208 | |
| @@ -382,50 +207,48 @@ | ||
| 382 | 207 | } |
| 383 | 208 | |
| 384 | 209 | $attributes = 'class="' . esc_attr( $class ) . '"'; |
| 385 | 210 | unset( $class ); |
| 386 | - $attributes .= ' data-colname="' . $column_display_name . '"'; | |
| 211 | + $attributes .= ' data-colname="' . $column_display_name . '"'; | |
| 212 | + | |
| 387 | 213 | $form_id = $this->params['form'] ? $this->params['form'] : 0; |
| 388 | 214 | $this->column_name = preg_replace( '/^(' . $form_id . '_)/', '', $column_name ); |
| 389 | 215 | |
| 390 | - if ( $this->column_name === 'cb' ) { | |
| 216 | + if ( $this->column_name == 'cb' ) { | |
| 391 | 217 | $r .= "<th scope='row' class='check-column'>$checkbox</th>"; |
| 392 | 218 | } else { |
| 393 | - $val = in_array( $column_name, $hidden, true ) ? '' : $this->column_value( $item ); | |
| 394 | - $r .= "<td $attributes>"; | |
| 219 | + if ( in_array( $column_name, $hidden, true ) ) { | |
| 220 | + $val = ''; | |
| 221 | + } else { | |
| 222 | + $val = $this->column_value( $item ); | |
| 223 | + } | |
| 395 | 224 | |
| 396 | - // phpcs:ignore Universal.Operators.StrictComparisons | |
| 225 | + $r .= "<td $attributes>"; | |
| 397 | 226 | if ( $column_name == $action_col ) { |
| 398 | - $edit_link = admin_url( 'admin.php?page=formidable-entries&frm_action=edit&id=' . $item->id ); | |
| 399 | - $r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> '; | |
| 400 | - $r .= $action_links; | |
| 227 | + $edit_link = FrmAppHelper::maybe_full_screen_link( '?page=formidable-entries&frm_action=edit&id=' . $item->id ); | |
| 228 | + $r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> '; | |
| 229 | + $r .= $action_links; | |
| 401 | 230 | } else { |
| 402 | 231 | $r .= $val; |
| 403 | 232 | } |
| 404 | - | |
| 405 | 233 | $r .= '</td>'; |
| 406 | - }//end if | |
| 234 | + } | |
| 407 | 235 | unset( $val ); |
| 408 | - }//end foreach | |
| 409 | - return $r . '</tr>'; | |
| 236 | + } | |
| 237 | + $r .= '</tr>'; | |
| 238 | + | |
| 239 | + return $r; | |
| 410 | 240 | } |
| 411 | 241 | |
| 412 | 242 | /** |
| 413 | 243 | * Get the column names that the logged in user can action on |
| 414 | - * | |
| 415 | - * @return string[] | |
| 416 | 244 | */ |
| 417 | 245 | private function get_action_columns() { |
| 418 | 246 | return array( 'cb', 'form_id', 'id', 'post_id' ); |
| 419 | 247 | } |
| 420 | 248 | |
| 421 | - /** | |
| 422 | - * @param object $item | |
| 423 | - * | |
| 424 | - * @return mixed | |
| 425 | - */ | |
| 426 | 249 | private function column_value( $item ) { |
| 427 | - $col_name = $this->maybe_fix_column_name( $this->column_name ); | |
| 250 | + $col_name = $this->column_name; | |
| 428 | 251 | |
| 429 | 252 | switch ( $col_name ) { |
| 430 | 253 | case 'ip': |
| 431 | 254 | case 'id': |
| @@ -432,8 +255,9 @@ | ||
| 432 | 255 | case 'item_key': |
| 433 | 256 | $val = $item->{$col_name}; |
| 434 | 257 | break; |
| 435 | 258 | case 'name': |
| 259 | + case 'description': | |
| 436 | 260 | $val = FrmAppHelper::truncate( strip_tags( $item->{$col_name} ), 100 ); |
| 437 | 261 | break; |
| 438 | 262 | case 'created_at': |
| 439 | 263 | case 'updated_at': |
| @@ -440,19 +264,13 @@ | ||
| 440 | 264 | $date = FrmAppHelper::get_formatted_time( $item->{$col_name} ); |
| 441 | 265 | $val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>'; |
| 442 | 266 | break; |
| 443 | 267 | case 'is_draft': |
| 444 | - $entry_status = FrmEntriesHelper::get_entry_status_label( $item->is_draft ); | |
| 445 | - $val = sprintf( | |
| 446 | - '<span class="frm-meta-tag frm-entry-status frm-entry-status-%s">%s</span>', | |
| 447 | - sanitize_html_class( $item->is_draft ), | |
| 448 | - esc_html( $entry_status ) | |
| 449 | - ); | |
| 268 | + $val = empty( $item->is_draft ) ? esc_html__( 'No', 'formidable' ) : esc_html__( 'Yes', 'formidable' ); | |
| 450 | 269 | break; |
| 451 | 270 | case 'form_id': |
| 452 | 271 | $form_id = $item->form_id; |
| 453 | 272 | $user_can_edit_forms = false === FrmAppHelper::permission_nonce_error( 'frm_edit_forms' ); |
| 454 | - | |
| 455 | 273 | if ( $user_can_edit_forms ) { |
| 456 | 274 | $val = FrmFormsHelper::edit_form_link( $form_id ); |
| 457 | 275 | } else { |
| 458 | 276 | $val = FrmFormsHelper::edit_form_link_label( $form_id ); |
| @@ -469,9 +287,8 @@ | ||
| 469 | 287 | $val = $item->parent_item_id; |
| 470 | 288 | break; |
| 471 | 289 | default: |
| 472 | 290 | $val = apply_filters( 'frm_entries_' . $col_name . '_column', false, compact( 'item' ) ); |
| 473 | - | |
| 474 | 291 | if ( $val === false ) { |
| 475 | 292 | $this->get_column_value( $item, $val ); |
| 476 | 293 | } |
| 477 | 294 | |
| @@ -483,57 +300,33 @@ | ||
| 483 | 300 | * @param mixed $val Column value. |
| 484 | 301 | * @param array $args Contains `item` and `col_name`. |
| 485 | 302 | */ |
| 486 | 303 | $val = apply_filters( 'frm_entries_column_value', $val, compact( 'item', 'col_name' ) ); |
| 487 | - }//end switch | |
| 304 | + } | |
| 488 | 305 | |
| 489 | 306 | return $val; |
| 490 | 307 | } |
| 491 | 308 | |
| 492 | 309 | /** |
| 493 | - * When a form has entries with the 0 item meta value, the values do not appear properly in the entries list. | |
| 494 | - * | |
| 495 | - * @since 6.11.2 | |
| 496 | - * | |
| 497 | - * @param string $column_name | |
| 498 | - * | |
| 499 | - * @return string | |
| 500 | - */ | |
| 501 | - private function maybe_fix_column_name( $column_name ) { | |
| 502 | - if ( str_starts_with( $column_name, '0_' ) ) { | |
| 503 | - return substr( $column_name, 2 ); | |
| 504 | - } | |
| 505 | - return $column_name; | |
| 506 | - } | |
| 507 | - | |
| 508 | - /** | |
| 509 | - * @param array $actions | |
| 510 | - * @param object $item | |
| 511 | 310 | * @param string $view_link |
| 512 | - * | |
| 513 | - * @return void | |
| 514 | 311 | */ |
| 515 | 312 | private function get_actions( &$actions, $item, $view_link ) { |
| 516 | - $actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . esc_html__( 'View', 'formidable' ) . '</a>'; | |
| 313 | + $view_link = FrmAppHelper::maybe_full_screen_link( $view_link ); | |
| 314 | + $actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>'; | |
| 517 | 315 | |
| 518 | 316 | if ( current_user_can( 'frm_delete_entries' ) ) { |
| 519 | 317 | $delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form']; |
| 520 | - $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" data-frmverify="' . esc_attr__( 'Permanently delete this entry?', 'formidable' ) . '" data-frmverify-btn="frm-button-red">' . esc_html__( 'Delete', 'formidable' ) . '</a>'; // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 318 | + $delete_link = FrmAppHelper::maybe_full_screen_link( $delete_link ); | |
| 319 | + $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" data-frmverify="' . esc_attr__( 'Permanently delete this entry?', 'formidable' ) . '">' . __( 'Delete', 'formidable' ) . '</a>'; | |
| 521 | 320 | } |
| 522 | 321 | |
| 523 | 322 | $actions = apply_filters( 'frm_row_actions', $actions, $item ); |
| 524 | 323 | } |
| 525 | 324 | |
| 526 | - /** | |
| 527 | - * @param object $item | |
| 528 | - * @param mixed $val | |
| 529 | - * | |
| 530 | - * @return void | |
| 531 | - */ | |
| 532 | 325 | private function get_column_value( $item, &$val ) { |
| 533 | 326 | $col_name = $this->column_name; |
| 534 | 327 | |
| 535 | - if ( str_starts_with( $col_name, 'frmsep_' ) ) { | |
| 328 | + if ( strpos( $col_name, 'frmsep_' ) === 0 ) { | |
| 536 | 329 | $sep_val = true; |
| 537 | 330 | $col_name = str_replace( 'frmsep_', '', $col_name ); |
| 538 | 331 | } else { |
| 539 | 332 | $sep_val = false; |
| @@ -538,14 +331,13 @@ | ||
| 538 | 331 | } else { |
| 539 | 332 | $sep_val = false; |
| 540 | 333 | } |
| 541 | 334 | |
| 542 | - if ( str_contains( $col_name, '-_-' ) ) { | |
| 335 | + if ( strpos( $col_name, '-_-' ) ) { | |
| 543 | 336 | list( $col_name, $embedded_field_id ) = explode( '-_-', $col_name ); |
| 544 | 337 | } |
| 545 | 338 | |
| 546 | 339 | $field = FrmField::getOne( $col_name ); |
| 547 | - | |
| 548 | 340 | if ( ! $field ) { |
| 549 | 341 | return; |
| 550 | 342 | } |
| 551 | 343 | |
| @@ -572,19 +364,7 @@ | ||
| 572 | 364 | /** |
| 573 | 365 | * @return string |
| 574 | 366 | */ |
| 575 | 367 | protected function confirm_bulk_delete() { |
| 576 | - return sprintf( | |
| 577 | - /* translators: %1$s: HTML break line, %2$s: HTML bold text */ | |
| 578 | - esc_html__( 'ALL entries in this form will be permanently deleted.%1$sWant to proceed? Type %2$s below.', 'formidable' ), | |
| 579 | - '<br/>', | |
| 580 | - '<b>DELETE ALL</b>' | |
| 581 | - ); | |
| 582 | - } | |
| 583 | - | |
| 584 | - /** | |
| 585 | - * @return string | |
| 586 | - */ | |
| 587 | - protected function loaded_from() { | |
| 588 | - return 'entries-list'; | |
| 368 | + return __( 'ALL selected entries in this form will be permanently deleted. Want to proceed?', 'formidable' ); | |
| 589 | 369 | } |
| 590 | 370 | } |