cli-tools.php
32 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace JFB_Modules\Cli; |
| 5 | |
| 6 | // If this file is called directly, abort. |
| 7 | if ( ! defined( 'WPINC' ) ) { |
| 8 | die; |
| 9 | } |
| 10 | |
| 11 | class Cli_Tools { |
| 12 | |
| 13 | public static function resolve_form( $assoc_args ): \WP_Post { |
| 14 | $form_id = absint( $assoc_args['form'] ?? 0 ); |
| 15 | $form = get_post( $form_id ); |
| 16 | |
| 17 | if ( $form instanceof \WP_Post ) { |
| 18 | return $form; |
| 19 | } |
| 20 | |
| 21 | list( $form ) = get_posts( |
| 22 | array( |
| 23 | 'numberposts' => 1, |
| 24 | 'post_type' => jet_form_builder()->post_type->slug(), |
| 25 | ) |
| 26 | ); |
| 27 | |
| 28 | return $form; |
| 29 | } |
| 30 | |
| 31 | } |
| 32 |