| 1 |
<?php |
| 2 |
/** |
| 3 |
* Kit MCP Prompt: Restrict Content. |
| 4 |
* |
| 5 |
* @package ConvertKit |
| 6 |
* @author ConvertKit |
| 7 |
*/ |
| 8 |
|
| 9 |
/** |
| 10 |
* Guided workflow to gate a post or page behind a Kit Product, Tag or Form. |
| 11 |
* Produces a prompt named `kit/restrict-content`. |
| 12 |
* |
| 13 |
* @package ConvertKit |
| 14 |
* @author ConvertKit |
| 15 |
*/ |
| 16 |
class ConvertKit_MCP_Prompt_Restrict_Content 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 'restrict-content'; |
| 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 __( 'Restrict content to subscribers', '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 __( 'Gate a post or page so only subscribers or paying members can read it, using a Kit Product, Tag or Form.', '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 |
'post_id' => array( |
| 68 |
'description' => __( 'The ID of the Page or Post to restrict.', 'convertkit' ), |
| 69 |
), |
| 70 |
'gate' => array( |
| 71 |
'description' => __( 'What to gate by: a Product, Tag or Form (name or ID).', '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 |
$post_id = isset( $input['post_id'] ) ? trim( (string) $input['post_id'] ) : ''; |
| 88 |
$gate = isset( $input['gate'] ) ? trim( (string) $input['gate'] ) : ''; |
| 89 |
|
| 90 |
$provided = array(); |
| 91 |
if ( '' !== $post_id ) { |
| 92 |
/* translators: %s: Post ID. */ |
| 93 |
$provided[] = sprintf( __( '- Post to restrict: %s', 'convertkit' ), $post_id ); |
| 94 |
} |
| 95 |
if ( '' !== $gate ) { |
| 96 |
/* translators: %s: gate description. */ |
| 97 |
$provided[] = sprintf( __( '- Gate by: %s', 'convertkit' ), $gate ); |
| 98 |
} |
| 99 |
|
| 100 |
return $this->render( |
| 101 |
array( |
| 102 |
'# ' . __( 'Restrict content to subscribers', 'convertkit' ), |
| 103 |
__( 'Goal: gate a single post or page so only qualifying visitors see the full content. Read `kit://reference/restrict-content` first for how gating works and what the visitor sees.', 'convertkit' ), |
| 104 |
count( $provided ) ? implode( "\n", $provided ) : '', |
| 105 |
'## ' . __( 'Preflight', 'convertkit' ), |
| 106 |
__( '- Decide what to gate by: a **Product** (paywall) from `kit://products`, a **Tag** from `kit://tags`, or a **Form** from `kit://forms`. Map the name to its numeric ID.', 'convertkit' ), |
| 107 |
__( '- Confirm the target post ID with the user if not given.', 'convertkit' ), |
| 108 |
'## ' . __( 'Steps', 'convertkit' ), |
| 109 |
__( '1. Confirm the post and the gate with the user.', 'convertkit' ), |
| 110 |
__( '2. Set it with `kit/post-settings-update`, supplying `restrict_content` (needs `post_id`). Confirm before writing.', 'convertkit' ), |
| 111 |
__( '3. Verify with `kit/post-settings-get`.', 'convertkit' ), |
| 112 |
__( 'Site wide behaviour (teaser, wording, login) lives in the restrict-content settings group — read `kit://settings` if the user wants to review it.', 'convertkit' ), |
| 113 |
) |
| 114 |
); |
| 115 |
|
| 116 |
} |
| 117 |
|
| 118 |
} |
| 119 |
|