| @@ -15,48 +15,41 @@ | ||
| 15 | 15 | <label for="wp-convertkit-form"><?php esc_html_e( 'Form', 'convertkit' ); ?></label> |
| 16 | 16 | </th> |
| 17 | 17 | <td> |
| 18 | 18 | <div class="convertkit-select2-container convertkit-select2-container-grid"> |
| 19 | - <select name="wp-convertkit[form]" id="wp-convertkit-form" class="convertkit-select2 widefat"> | |
| 20 | - <option value="-1"<?php selected( - 1, $convertkit_post->get_form() ); ?> data-preserve-on-refresh="1"> | |
| 21 | - <?php esc_html_e( 'Default', 'convertkit' ); ?> | |
| 22 | - </option> | |
| 23 | - <option value="0"<?php selected( 0, $convertkit_post->get_form() ); ?> data-preserve-on-refresh="1"> | |
| 24 | - <?php esc_html_e( 'None', 'convertkit' ); ?> | |
| 25 | - </option> | |
| 26 | - <?php | |
| 27 | - if ( $convertkit_forms->exist() ) { | |
| 28 | - foreach ( $convertkit_forms->get() as $form ) { | |
| 29 | - ?> | |
| 30 | - <option value="<?php echo esc_attr( $form['id'] ); ?>"<?php selected( $form['id'], $convertkit_post->get_form() ); ?>> | |
| 31 | - <?php echo esc_attr( $form['name'] ); ?> | |
| 32 | - </option> | |
| 33 | - <?php | |
| 34 | - } | |
| 35 | - } | |
| 36 | - ?> | |
| 37 | - </select> | |
| 38 | - <button class="wp-convertkit-refresh-resources" class="button button-secondary hide-if-no-js" title="<?php esc_attr_e( 'Refresh Forms from ConvertKit account', 'convertkit' ); ?>" data-resource="forms" data-field="#wp-convertkit-form"> | |
| 19 | + <?php | |
| 20 | + $convertkit_forms->output_select_field_all( | |
| 21 | + 'wp-convertkit[form]', | |
| 22 | + 'wp-convertkit-form', | |
| 23 | + array( | |
| 24 | + 'convertkit-select2', | |
| 25 | + 'widefat', | |
| 26 | + ), | |
| 27 | + esc_attr( $convertkit_post->get_form() ), | |
| 28 | + array( | |
| 29 | + '-1' => esc_html__( 'Default', 'convertkit' ), | |
| 30 | + '0' => esc_html__( 'None', 'convertkit' ), | |
| 31 | + ) | |
| 32 | + ); | |
| 33 | + ?> | |
| 34 | + <button class="wp-convertkit-refresh-resources" class="button button-secondary hide-if-no-js" title="<?php esc_attr_e( 'Refresh Forms from Kit account', 'convertkit' ); ?>" data-resource="forms" data-field="#wp-convertkit-form"> | |
| 39 | 35 | <span class="dashicons dashicons-update"></span> |
| 40 | 36 | </button> |
| 41 | 37 | <p class="description"> |
| 42 | - <?php | |
| 43 | - printf( | |
| 44 | - /* translators: settings url */ | |
| 45 | - __( '<code>Default</code>: Uses the form specified on the <a href="%s" target="_blank">settings page</a>.', 'convertkit' ), /* phpcs:ignore */ | |
| 46 | - esc_attr( esc_url( $settings_link ) ) | |
| 47 | - ); | |
| 48 | - ?> | |
| 38 | + <code><?php esc_html_e( 'Default', 'convertkit' ); ?></code> | |
| 39 | + <?php esc_html_e( ': Uses the form specified on the', 'convertkit' ); ?> | |
| 40 | + <a href="<?php echo esc_url( $settings_link ); ?>"><?php esc_html_e( 'settings page', 'convertkit' ); ?></a> | |
| 49 | 41 | <br /> |
| 50 | - <?php _e( '<code>None</code>: do not display a form.', 'convertkit' ); /* phpcs:ignore */ ?> | |
| 42 | + <code><?php esc_html_e( 'None', 'convertkit' ); ?></code> | |
| 43 | + <?php esc_html_e( ': do not display a form.', 'convertkit' ); ?> | |
| 51 | 44 | <br /> |
| 52 | 45 | <?php esc_html_e( 'Any other option will display that form after the main content.', 'convertkit' ); ?> |
| 53 | 46 | <br /> |
| 54 | 47 | <?php |
| 55 | - echo sprintf( | |
| 48 | + printf( | |
| 56 | 49 | /* translators: Link to sign in to ConvertKit */ |
| 57 | 50 | esc_html__( 'To make changes to your forms, %s', 'convertkit' ), |
| 58 | - '<a href="' . esc_url( convertkit_get_sign_in_url() ) . '" target="_blank">' . esc_html__( 'sign in to ConvertKit', 'convertkit' ) . '</a>' | |
| 51 | + '<a href="' . esc_url( convertkit_get_sign_in_url() ) . '" target="_blank">' . esc_html__( 'sign in to Kit', 'convertkit' ) . '</a>' | |
| 59 | 52 | ); |
| 60 | 53 | ?> |
| 61 | 54 | </p> |
| 62 | 55 | </div> |
| @@ -73,32 +66,44 @@ | ||
| 73 | 66 | </th> |
| 74 | 67 | <td> |
| 75 | 68 | <div class="convertkit-select2-container convertkit-select2-container-grid"> |
| 76 | 69 | <select name="wp-convertkit[landing_page]" id="wp-convertkit-landing_page" class="convertkit-select2"> |
| 77 | - <option <?php selected( '', $convertkit_post->get_landing_page() ); ?> value="0" data-preserve-on-refresh="1"> | |
| 78 | - <?php esc_html_e( 'None', 'convertkit' ); ?> | |
| 79 | - </option> | |
| 70 | + <option <?php selected( '', $convertkit_post->get_landing_page() ); ?> value="0" data-preserve-on-refresh="1"><?php esc_html_e( 'None', 'convertkit' ); ?></option> | |
| 80 | 71 | <?php |
| 81 | - if ( $convertkit_landing_pages->exist() ) { | |
| 82 | - foreach ( $convertkit_landing_pages->get() as $landing_page ) { | |
| 83 | - if ( isset( $convertkit_landing_page['url'] ) ) { | |
| 72 | + $non_legacy_landing_pages = $convertkit_landing_pages->get_non_legacy(); | |
| 73 | + if ( is_array( $non_legacy_landing_pages ) ) { | |
| 74 | + foreach ( $non_legacy_landing_pages as $landing_page ) { | |
| 75 | + ?> | |
| 76 | + <option value="<?php echo esc_attr( $landing_page['id'] ); ?>"<?php selected( $landing_page['id'], $convertkit_post->get_landing_page() ); ?>><?php echo esc_attr( $landing_page['name'] ); ?></option> | |
| 77 | + <?php | |
| 78 | + } | |
| 79 | + } | |
| 80 | + | |
| 81 | + // If the currently-saved landing page is a legacy resource, append | |
| 82 | + // it here so the dropdown truthfully reflects the saved value | |
| 83 | + // without offering other legacy pages as new selection choices. | |
| 84 | + $current_landing_page = $convertkit_post->get_landing_page(); | |
| 85 | + if ( $current_landing_page && $convertkit_landing_pages->is_legacy( $current_landing_page ) ) { | |
| 86 | + // data-preserve-on-refresh keeps this option in place when | |
| 87 | + // the Refresh Resources button repopulates the dropdown, | |
| 88 | + // so the saved legacy selection isn't silently lost. | |
| 89 | + // Pre-1.9.6 storage: the saved value is the legacy URL itself. | |
| 90 | + if ( is_string( $current_landing_page ) && strstr( $current_landing_page, 'http' ) ) { | |
| 91 | + ?> | |
| 92 | + <option value="<?php echo esc_attr( $current_landing_page ); ?>" data-preserve-on-refresh="1" selected><?php echo esc_attr( $current_landing_page ); ?></option> | |
| 93 | + <?php | |
| 94 | + } else { | |
| 95 | + $legacy_landing_page = $convertkit_landing_pages->get_by_id( (int) $current_landing_page ); | |
| 96 | + if ( $legacy_landing_page ) { | |
| 84 | 97 | ?> |
| 85 | - <option value="<?php echo esc_attr( $landing_page['url'] ); ?>"<?php selected( $landing_page['url'], $convertkit_post->get_landing_page() ); ?>> | |
| 86 | - <?php echo esc_attr( $landing_page['name'] ); ?> | |
| 87 | - </option> | |
| 98 | + <option value="<?php echo esc_attr( $legacy_landing_page['id'] ); ?>" data-preserve-on-refresh="1" selected><?php echo esc_attr( $legacy_landing_page['name'] ); ?></option> | |
| 88 | 99 | <?php |
| 89 | - } else { | |
| 90 | - ?> | |
| 91 | - <option value="<?php echo esc_attr( $landing_page['id'] ); ?>"<?php selected( $landing_page['id'], $convertkit_post->get_landing_page() ); ?>> | |
| 92 | - <?php echo esc_attr( $landing_page['name'] ); ?> | |
| 93 | - </option> | |
| 94 | - <?php | |
| 95 | 100 | } |
| 96 | 101 | } |
| 97 | 102 | } |
| 98 | 103 | ?> |
| 99 | 104 | </select> |
| 100 | - <button class="wp-convertkit-refresh-resources" class="button button-secondary hide-if-no-js" title="<?php esc_attr_e( 'Refresh Landing Pages from ConvertKit account', 'convertkit' ); ?>" data-resource="landing_pages" data-field="#wp-convertkit-landing_page"> | |
| 105 | + <button class="wp-convertkit-refresh-resources" class="button button-secondary hide-if-no-js" title="<?php esc_attr_e( 'Refresh Landing Pages from Kit account', 'convertkit' ); ?>" data-resource="landing_pages" data-field="#wp-convertkit-landing_page"> | |
| 101 | 106 | <span class="dashicons dashicons-update"></span> |
| 102 | 107 | </button> |
| 103 | 108 | <p class="description"> |
| 104 | 109 | <?php esc_html_e( 'Select a landing page to make it appear in place of this page.', 'convertkit' ); ?> |
| @@ -103,12 +108,12 @@ | ||
| 103 | 108 | <p class="description"> |
| 104 | 109 | <?php esc_html_e( 'Select a landing page to make it appear in place of this page.', 'convertkit' ); ?> |
| 105 | 110 | <br /> |
| 106 | 111 | <?php |
| 107 | - echo sprintf( | |
| 112 | + printf( | |
| 108 | 113 | /* translators: Link to sign in to ConvertKit */ |
| 109 | 114 | esc_html__( 'To make changes to your landing pages, %s', 'convertkit' ), |
| 110 | - '<a href="' . esc_url( convertkit_get_sign_in_url() ) . '" target="_blank">' . esc_html__( 'sign in to ConvertKit', 'convertkit' ) . '</a>' | |
| 115 | + '<a href="' . esc_url( convertkit_get_sign_in_url() ) . '" target="_blank">' . esc_html__( 'sign in to Kit', 'convertkit' ) . '</a>' | |
| 111 | 116 | ); |
| 112 | 117 | ?> |
| 113 | 118 | </p> |
| 114 | 119 | </div> |
| @@ -125,79 +130,101 @@ | ||
| 125 | 130 | </th> |
| 126 | 131 | <td> |
| 127 | 132 | <div class="convertkit-select2-container convertkit-select2-container-grid"> |
| 128 | 133 | <select name="wp-convertkit[tag]" id="wp-convertkit-tag" class="convertkit-select2"> |
| 129 | - <option value="0"<?php selected( '', $convertkit_post->get_tag() ); ?> data-preserve-on-refresh="1"> | |
| 130 | - <?php esc_html_e( 'None', 'convertkit' ); ?> | |
| 131 | - </option> | |
| 134 | + <option value="0"<?php selected( '', $convertkit_post->get_tag() ); ?> data-preserve-on-refresh="1"><?php esc_html_e( 'None', 'convertkit' ); ?></option> | |
| 132 | 135 | <?php |
| 133 | 136 | if ( $convertkit_tags->exist() ) { |
| 134 | 137 | foreach ( $convertkit_tags->get() as $convertkit_tag ) { |
| 135 | 138 | ?> |
| 136 | - <option value="<?php echo esc_attr( $convertkit_tag['id'] ); ?>"<?php selected( $convertkit_tag['id'], $convertkit_post->get_tag() ); ?>> | |
| 137 | - <?php echo esc_attr( $convertkit_tag['name'] ); ?> | |
| 138 | - </option> | |
| 139 | + <option value="<?php echo esc_attr( $convertkit_tag['id'] ); ?>"<?php selected( $convertkit_tag['id'], $convertkit_post->get_tag() ); ?>><?php echo esc_attr( $convertkit_tag['name'] ); ?></option> | |
| 139 | 140 | <?php |
| 140 | 141 | } |
| 141 | 142 | } |
| 142 | 143 | ?> |
| 143 | 144 | </select> |
| 144 | - <button class="wp-convertkit-refresh-resources" class="button button-secondary hide-if-no-js" title="<?php esc_attr_e( 'Refresh Tags from ConvertKit account', 'convertkit' ); ?>" data-resource="tags" data-field="#wp-convertkit-tag"> | |
| 145 | + <button class="wp-convertkit-refresh-resources" class="button button-secondary hide-if-no-js" title="<?php esc_attr_e( 'Refresh Tags from Kit account', 'convertkit' ); ?>" data-resource="tags" data-field="#wp-convertkit-tag"> | |
| 145 | 146 | <span class="dashicons dashicons-update"></span> |
| 146 | 147 | </button> |
| 147 | 148 | <p class="description"> |
| 148 | 149 | <?php esc_html_e( 'Select a tag to apply to visitors of this page who are subscribed.', 'convertkit' ); ?> |
| 149 | 150 | <br /> |
| 150 | - <?php esc_html_e( 'A visitor is deemed to be subscribed if they have clicked a link in an email to this site which includes their subscriber ID, or have entered their email address in a ConvertKit Form on this site.', 'convertkit' ); ?> | |
| 151 | + <?php esc_html_e( 'A visitor is deemed to be subscribed if they have clicked a link in an email to this site which includes their subscriber ID, or have entered their email address in a Kit Form on this site.', 'convertkit' ); ?> | |
| 151 | 152 | </p> |
| 152 | 153 | </div> |
| 153 | 154 | </td> |
| 154 | 155 | </tr> |
| 155 | 156 | |
| 156 | - <?php | |
| 157 | - if ( $restrict_content_settings->enabled() ) { | |
| 158 | - ?> | |
| 159 | - <tr valign="top"> | |
| 160 | - <th scope="row"> | |
| 161 | - <label for="wp-convertkit-restrict_content"><?php esc_html_e( 'Member Content', 'convertkit' ); ?></label> | |
| 162 | - </th> | |
| 163 | - <td> | |
| 164 | - <div class="convertkit-select2-container convertkit-select2-container-grid"> | |
| 165 | - <select name="wp-convertkit[restrict_content]" id="wp-convertkit-restrict_content" class="convertkit-select2"> | |
| 166 | - <option value="0"<?php selected( '', $convertkit_post->get_restrict_content() ); ?> data-preserve-on-refresh="1"> | |
| 167 | - <?php esc_html_e( 'Don\'t restrict content to members only.', 'convertkit' ); ?> | |
| 168 | - </option> | |
| 157 | + <tr valign="top"> | |
| 158 | + <th scope="row"> | |
| 159 | + <label for="wp-convertkit-restrict_content"><?php esc_html_e( 'Member Content', 'convertkit' ); ?></label> | |
| 160 | + </th> | |
| 161 | + <td> | |
| 162 | + <div class="convertkit-select2-container convertkit-select2-container-grid"> | |
| 163 | + <select name="wp-convertkit[restrict_content]" id="wp-convertkit-restrict_content" class="convertkit-select2"> | |
| 164 | + <option value="0"<?php selected( '', $convertkit_post->get_restrict_content() ); ?> data-preserve-on-refresh="1"><?php esc_html_e( 'Don\'t restrict content to member-only.', 'convertkit' ); ?></option> | |
| 169 | 165 | |
| 166 | + <optgroup label="<?php esc_attr_e( 'Forms', 'convertkit' ); ?>" data-resource="forms"> | |
| 170 | 167 | <?php |
| 168 | + // Forms. | |
| 169 | + if ( $convertkit_forms->inline_exist() ) { | |
| 170 | + foreach ( $convertkit_forms->get_inline() as $convertkit_form ) { | |
| 171 | + printf( | |
| 172 | + '<option value="form_%s"%s>%s [%s]</option>', | |
| 173 | + esc_attr( $convertkit_form['id'] ), | |
| 174 | + selected( $convertkit_post->get_restrict_content(), 'form_' . $convertkit_form['id'], false ), | |
| 175 | + esc_attr( $convertkit_form['name'] ), | |
| 176 | + ( ! empty( $convertkit_form['format'] ) ? esc_attr( $convertkit_form['format'] ) : 'inline' ) | |
| 177 | + ); | |
| 178 | + } | |
| 179 | + } | |
| 180 | + ?> | |
| 181 | + </optgroup> | |
| 182 | + | |
| 183 | + <optgroup label="<?php esc_attr_e( 'Tags', 'convertkit' ); ?>" data-resource="tags"> | |
| 184 | + <?php | |
| 185 | + // Tags. | |
| 186 | + if ( $convertkit_tags->exist() ) { | |
| 187 | + foreach ( $convertkit_tags->get() as $convertkit_tag ) { | |
| 188 | + ?> | |
| 189 | + <option value="tag_<?php echo esc_attr( $convertkit_tag['id'] ); ?>"<?php selected( 'tag_' . $convertkit_tag['id'], $convertkit_post->get_restrict_content() ); ?>><?php echo esc_attr( $convertkit_tag['name'] ); ?></option> | |
| 190 | + <?php | |
| 191 | + } | |
| 192 | + } | |
| 193 | + ?> | |
| 194 | + </optgroup> | |
| 195 | + | |
| 196 | + <optgroup label="<?php esc_attr_e( 'Products', 'convertkit' ); ?>" data-resource="products"> | |
| 197 | + <?php | |
| 198 | + // Products. | |
| 171 | 199 | if ( $convertkit_products->exist() ) { |
| 172 | - ?> | |
| 173 | - <optgroup label="<?php esc_attr_e( 'Products', 'convertkit' ); ?>"> | |
| 200 | + foreach ( $convertkit_products->get() as $product ) { | |
| 201 | + ?> | |
| 202 | + <option value="product_<?php echo esc_attr( $product['id'] ); ?>"<?php selected( 'product_' . $product['id'], $convertkit_post->get_restrict_content() ); ?>><?php echo esc_attr( $product['name'] ); ?></option> | |
| 174 | 203 | <?php |
| 175 | - foreach ( $convertkit_products->get() as $product ) { | |
| 176 | - ?> | |
| 177 | - <option value="product_<?php echo esc_attr( $product['id'] ); ?>"<?php selected( 'product_' . $product['id'], $convertkit_post->get_restrict_content() ); ?>> | |
| 178 | - <?php echo esc_attr( $product['name'] ); ?> | |
| 179 | - </option> | |
| 180 | - <?php | |
| 181 | - } | |
| 182 | - ?> | |
| 183 | - </optgroup> | |
| 184 | - <?php | |
| 204 | + } | |
| 185 | 205 | } |
| 186 | 206 | ?> |
| 187 | - </select> | |
| 188 | - <button class="wp-convertkit-refresh-resources" class="button button-secondary hide-if-no-js" title="<?php esc_attr_e( 'Refresh Products Pages from ConvertKit account', 'convertkit' ); ?>" data-resource="products" data-field="#wp-convertkit-restrict_content"> | |
| 189 | - <span class="dashicons dashicons-update"></span> | |
| 190 | - </button> | |
| 191 | - <p class="description"> | |
| 192 | - <?php esc_html_e( 'Select the ConvertKit product that the visitor must be subscribed to, permitting them access to view this members only content.', 'convertkit' ); ?> | |
| 193 | - </p> | |
| 194 | - </div> | |
| 195 | - </td> | |
| 196 | - </tr> | |
| 197 | - <?php | |
| 198 | - } | |
| 199 | - ?> | |
| 207 | + </optgroup> | |
| 208 | + </select> | |
| 209 | + <button class="wp-convertkit-refresh-resources" class="button button-secondary hide-if-no-js" title="<?php esc_attr_e( 'Refresh Products and Tags from Kit account', 'convertkit' ); ?>" data-resource="restrict_content" data-field="#wp-convertkit-restrict_content"> | |
| 210 | + <span class="dashicons dashicons-update"></span> | |
| 211 | + </button> | |
| 212 | + <p class="description"> | |
| 213 | + <?php esc_html_e( 'Select the Kit form, tag or product that the visitor must be subscribed to, permitting them access to view this member-only content.', 'convertkit' ); ?> | |
| 214 | + <br /> | |
| 215 | + <code><?php esc_html_e( 'Form', 'convertkit' ); ?></code> | |
| 216 | + <?php esc_html_e( ': Displays the Kit form. On submission, the email address will be subscribed to the selected form, granting access to the member-only content. Useful to gate free content in return for an email address.', 'convertkit' ); ?> | |
| 217 | + <br /> | |
| 218 | + <code><?php esc_html_e( 'Tag', 'convertkit' ); ?></code> | |
| 219 | + <?php esc_html_e( ': Displays a WordPress styled subscription form. On submission, the email address will be subscribed to the selected tag, granting access to the member-only content. Useful to gate free content in return for an email address.', 'convertkit' ); ?> | |
| 220 | + <br /> | |
| 221 | + <code><?php esc_html_e( 'Product', 'convertkit' ); ?></code> | |
| 222 | + <?php esc_html_e( ': Displays a link to the Kit product, and a login form. Useful to gate content that can only be accessed by purchasing the Kit product.', 'convertkit' ); ?> | |
| 223 | + </p> | |
| 224 | + </div> | |
| 225 | + </td> | |
| 226 | + </tr> | |
| 200 | 227 | </tbody> |
| 201 | 228 | </table> |
| 202 | 229 | |
| 203 | 230 | <?php |