PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.2.3
JetFormBuilder — Dynamic Blocks Form Builder v3.2.3
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / modules / cli / commands / seed-records.php
jetformbuilder / modules / cli / commands Last commit date
base-command-it.php 2 years ago downgrade-database.php 2 years ago seed-jet-apb.php 2 years ago seed-payments.php 2 years ago seed-records.php 2 years ago upgrade-database.php 2 years ago
seed-records.php
102 lines
1 <?php
2
3
4 namespace JFB_Modules\Cli\Commands;
5
6 // If this file is called directly, abort.
7 if ( ! defined( 'WPINC' ) ) {
8 die;
9 }
10
11 use Jet_Form_Builder\Blocks\Block_Helper;
12 use JFB_Modules\Form_Record\Models\Record_Action_Result_Model;
13 use JFB_Modules\Form_Record\Models\Record_Field_Model;
14 use JFB_Modules\Form_Record\Models\Record_Model;
15 use JFB_Modules\Security\Csrf\Csrf_Tools;
16 use JFB_Modules\Cli\Cli_Tools;
17
18 class Seed_Records implements Base_Command_It {
19
20 public function rep_item_id() {
21 return 'seed-records';
22 }
23
24 public function condition(): bool {
25 return true;
26 }
27
28 public function do_command( $args, $assoc_args ) {
29 $form = Cli_Tools::resolve_form( $assoc_args );
30 $limit = absint( $assoc_args['limit'] ?? 1000000 );
31
32 if ( 0 >= $limit ) {
33 $limit = 1;
34 }
35
36 $field_names = array_keys(
37 Block_Helper::get_form_field_names(
38 Block_Helper::get_blocks_by_post( $form )
39 )
40 );
41
42 /** @var \WP_User $user */
43 list( $user ) = get_users(
44 array(
45 'number' => 1,
46 )
47 );
48
49 /** @var \WP_Post $post */
50 list( $post ) = get_posts(
51 array(
52 'numberposts' => 1,
53 )
54 );
55
56 $current = 0;
57
58 foreach ( range( 0, $limit ) as $current ) {
59 $record_id = ( new Record_Model() )->insert_soft(
60 array(
61 'user_id' => $user->ID,
62 'form_id' => $form->ID,
63 'from_content_id' => $post->ID,
64 'from_content_type' => 'cli',
65 'status' => 'failed',
66 )
67 );
68
69 foreach ( range( 0, 2 ) as $next ) {
70 ( new Record_Action_Result_Model() )->insert_soft(
71 array(
72 'record_id' => $record_id,
73 'action_slug' => 'insert_post',
74 'action_id' => 9999,
75 'status' => 'failed',
76 'on_event' => 'GENERATED.CLI',
77 )
78 );
79 }
80
81 foreach ( $field_names as $field_name ) {
82 ( new Record_Field_Model() )->insert_soft(
83 array(
84 'record_id' => $record_id,
85 'field_name' => $field_name,
86 'field_value' => Csrf_Tools::generate(),
87 'field_type' => 'text-field',
88 'field_attrs' => '{}',
89 )
90 );
91 }
92
93 if ( 0 === $current % 5000 ) {
94 \WP_CLI::line( 'Reached: ' . $current );
95 }
96 }
97
98 \WP_CLI::success( "Executed successfully ($current)" );
99 }
100
101 }
102