PluginProbe ʕ •ᴥ•ʔ
Search Regex / 3.4.3
Search Regex v3.4.3
3.4.3 trunk 1.4.12 1.4.13 1.4.14 1.4.15 1.4.16 2.0 2.0.1 2.1 2.2 2.2.1 2.3 2.3.1 2.3.2 2.3.3 2.4 2.4.1 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.1 3.1.1 3.1.2 3.2 3.3 3.3.0 3.3.1 3.4 3.4.1 3.4.2
search-regex / includes / action / type / class-delete.php
search-regex / includes / action / type Last commit date
class-delete.php 6 months ago class-export.php 1 week ago class-global-replace.php 6 months ago class-modify.php 6 months ago class-nothing.php 6 months ago class-run.php 1 week ago
class-delete.php
48 lines
1 <?php
2
3 namespace SearchRegex\Action\Type;
4
5 use SearchRegex\Action\Action;
6 use SearchRegex\Source;
7 use SearchRegex\Plugin;
8
9 /**
10 * Action to delete rows
11 */
12 class Delete extends Action {
13 /**
14 * Track how many rows have been deleted
15 */
16 private int $deleted = 0;
17
18 /**
19 * @return array<string, mixed>
20 */
21 public function to_json() {
22 return [
23 'action' => 'delete',
24 ];
25 }
26
27 /**
28 * @param int $row_id
29 * @param array<string, mixed> $row
30 * @param Source\Source $source
31 * @param array<\SearchRegex\Search\Column> $columns
32 * @return array<\SearchRegex\Search\Column>
33 */
34 public function perform( $row_id, array $row, Source\Source $source, array $columns ) {
35 if ( $this->should_save() ) {
36 $this->deleted++;
37
38 $this->log_action( 'Delete: ' . $source->get_table_name() . ' row ' . (string) $row_id );
39
40 if ( Plugin\Settings::init()->can_save() ) {
41 $source->delete_row( $row_id );
42 }
43 }
44
45 return $columns;
46 }
47 }
48