CreateFormRoute.php
2 years ago
EditFormRoute.php
2 years ago
RegisterFormBuilderPageRoute.php
2 years ago
RegisterFormBuilderRestRoutes.php
2 years ago
EditFormRoute.php
34 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\FormBuilder\Routes; |
| 4 | |
| 5 | use Give\FormBuilder\FormBuilderRouteBuilder; |
| 6 | use Give\Helpers\Form\Utils; |
| 7 | |
| 8 | /** |
| 9 | * Route to edit an existing form |
| 10 | */ |
| 11 | class EditFormRoute |
| 12 | { |
| 13 | /** |
| 14 | * @since 3.0.3 Use isV3Form() method instead of 'post_content' to check if the form is built with Visual Builder |
| 15 | * @since 3.0.0 |
| 16 | * |
| 17 | * @return void |
| 18 | */ |
| 19 | public function __invoke() |
| 20 | { |
| 21 | if (isset($_GET['post'], $_GET['action']) && 'edit' === $_GET['action']) { |
| 22 | // This conditional will be also triggered by WP edit bulk action |
| 23 | // WP sends an array of IDs so if that is the case here, we can skip this |
| 24 | if ( ! is_array($_GET['post'])) { |
| 25 | $post = get_post(abs($_GET['post'])); |
| 26 | if ('give_forms' === $post->post_type && Utils::isV3Form($post->ID)) { |
| 27 | wp_redirect(FormBuilderRouteBuilder::makeEditFormRoute($post->ID)); |
| 28 | exit(); |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 |