| 1 |
<?php |
| 2 |
/** |
| 3 |
* Kit MCP Prompt: Add Form. |
| 4 |
* |
| 5 |
* @package ConvertKit |
| 6 |
* @author ConvertKit |
| 7 |
*/ |
| 8 |
|
| 9 |
/** |
| 10 |
* Guided workflow to show a Kit Form as a default, on a post or category, or |
| 11 |
* inline in content. Produces a prompt named `kit/add-form`. |
| 12 |
* |
| 13 |
* @package ConvertKit |
| 14 |
* @author ConvertKit |
| 15 |
*/ |
| 16 |
class ConvertKit_MCP_Prompt_Add_Form extends ConvertKit_MCP_Prompt { |
| 17 |
|
| 18 |
/** |
| 19 |
* Returns the prompt's short name. |
| 20 |
* |
| 21 |
* @since 3.5.0 |
| 22 |
* |
| 23 |
* @return string |
| 24 |
*/ |
| 25 |
protected function get_prompt_name() { |
| 26 |
|
| 27 |
return 'add-form'; |
| 28 |
|
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* Returns the prompt's label. |
| 33 |
* |
| 34 |
* @since 3.5.0 |
| 35 |
* |
| 36 |
* @return string |
| 37 |
*/ |
| 38 |
public function get_label() { |
| 39 |
|
| 40 |
return __( 'Add a Kit Form', 'convertkit' ); |
| 41 |
|
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Returns the prompt's description. |
| 46 |
* |
| 47 |
* @since 3.5.0 |
| 48 |
* |
| 49 |
* @return string |
| 50 |
*/ |
| 51 |
public function get_description() { |
| 52 |
|
| 53 |
return __( 'Show a Kit Form as a site default, on a single post or page, on a category, or inline in content.', 'convertkit' ); |
| 54 |
|
| 55 |
} |
| 56 |
|
| 57 |
/** |
| 58 |
* Returns the prompt's arguments. |
| 59 |
* |
| 60 |
* @since 3.5.0 |
| 61 |
* |
| 62 |
* @return array |
| 63 |
*/ |
| 64 |
protected function get_arguments() { |
| 65 |
|
| 66 |
return array( |
| 67 |
'form' => array( |
| 68 |
'description' => __( 'The Kit Form to add, by name or numeric ID.', 'convertkit' ), |
| 69 |
), |
| 70 |
'scope' => array( |
| 71 |
'description' => __( 'Where to add it: default, post, category or inline.', 'convertkit' ), |
| 72 |
), |
| 73 |
); |
| 74 |
|
| 75 |
} |
| 76 |
|
| 77 |
/** |
| 78 |
* Returns the prompt text. |
| 79 |
* |
| 80 |
* @since 3.5.0 |
| 81 |
* |
| 82 |
* @param array $input Prompt arguments. |
| 83 |
* @return array|WP_Error |
| 84 |
*/ |
| 85 |
public function execute_callback( $input ) { |
| 86 |
|
| 87 |
$form = isset( $input['form'] ) ? trim( (string) $input['form'] ) : ''; |
| 88 |
$scope = isset( $input['scope'] ) ? trim( (string) $input['scope'] ) : ''; |
| 89 |
|
| 90 |
$provided = array(); |
| 91 |
if ( '' !== $form ) { |
| 92 |
/* translators: %s: Form name or ID. */ |
| 93 |
$provided[] = sprintf( __( '- Requested Form: %s', 'convertkit' ), $form ); |
| 94 |
} |
| 95 |
if ( '' !== $scope ) { |
| 96 |
/* translators: %s: scope. */ |
| 97 |
$provided[] = sprintf( __( '- Requested scope: %s', 'convertkit' ), $scope ); |
| 98 |
} |
| 99 |
|
| 100 |
return $this->render( |
| 101 |
array( |
| 102 |
'# ' . __( 'Add a Kit Form', 'convertkit' ), |
| 103 |
__( 'Goal: show a Kit Form as a site default, on a single post or page, on a category, or inline in content.', 'convertkit' ), |
| 104 |
count( $provided ) ? implode( "\n", $provided ) : '', |
| 105 |
'## ' . __( 'Preflight', 'convertkit' ), |
| 106 |
__( '- Read `kit://forms` and map the requested Form to its numeric ID. If nothing matches, list the available Forms and ask the user.', 'convertkit' ), |
| 107 |
__( '- See `kit://reference/forms` for how the Form shown on a post is resolved (post overrides category overrides the default).', 'convertkit' ), |
| 108 |
'## ' . __( 'Choose the scope', 'convertkit' ), |
| 109 |
__( '- **Default for a post type** — `kit/settings-general-update`.', 'convertkit' ), |
| 110 |
__( '- **A single Page or Post** — `kit/post-settings-update`, setting `form` (needs `post_id`).', 'convertkit' ), |
| 111 |
__( '- **A category** — `kit/category-settings-update`.', 'convertkit' ), |
| 112 |
__( '- **Inline at a chosen position in the content** — `kit/form-insert`.', 'convertkit' ), |
| 113 |
'## ' . __( 'Steps', 'convertkit' ), |
| 114 |
__( '1. Confirm the Form and the scope with the user.', 'convertkit' ), |
| 115 |
__( '2. Apply it with the matching tool above. Confirm before writing.', 'convertkit' ), |
| 116 |
__( '3. Verify with the matching read tool (e.g. `kit/post-settings-get`).', 'convertkit' ), |
| 117 |
) |
| 118 |
); |
| 119 |
|
| 120 |
} |
| 121 |
|
| 122 |
} |
| 123 |
|