← All changes
|
includes/plugin-sidebars/class-convertkit-plugin-sidebar-post-settings.php
+39
-10
3.3.4
→
3.4.3
View file →
| @@ -118,31 +118,49 @@ | ||
| 118 | 118 | $convertkit_landing_pages = new ConvertKit_Resource_Landing_Pages( 'post_settings' ); |
| 119 | 119 | $convertkit_tags = new ConvertKit_Resource_Tags( 'post_settings' ); |
| 120 | 120 | $convertkit_products = new ConvertKit_Resource_Products( 'post_settings' ); |
| 121 | 121 | |
| 122 | - // Get Forms. | |
| 123 | - $forms = array( | |
| 122 | + // Get Forms. Non-legacy forms populate the dropdown; legacy forms are | |
| 123 | + // exposed separately as a fallback so a previously-saved legacy form | |
| 124 | + // remains visible as the current selection without offering other | |
| 125 | + // legacy forms as new choices. | |
| 126 | + $forms = array( | |
| 124 | 127 | '-1' => esc_html__( 'Default', 'convertkit' ), |
| 125 | 128 | '0' => esc_html__( 'None', 'convertkit' ), |
| 126 | 129 | ); |
| 130 | + $legacy_forms = array(); | |
| 127 | 131 | if ( $convertkit_forms->exist() ) { |
| 128 | 132 | foreach ( $convertkit_forms->get() as $form ) { |
| 129 | - // Legacy forms don't include a `format` key, so define them as inline. | |
| 130 | - $forms[ absint( $form['id'] ) ] = sprintf( | |
| 133 | + $label = sprintf( | |
| 131 | 134 | '%s [%s]', |
| 132 | 135 | sanitize_text_field( $form['name'] ), |
| 136 | + // Legacy forms don't include a `format` key, so define them as inline. | |
| 133 | 137 | ( ! empty( $form['format'] ) ? sanitize_text_field( $form['format'] ) : 'inline' ) |
| 134 | 138 | ); |
| 139 | + | |
| 140 | + if ( ! empty( $form['format'] ) ) { | |
| 141 | + $forms[ absint( $form['id'] ) ] = $label; | |
| 142 | + } else { | |
| 143 | + $legacy_forms[ absint( $form['id'] ) ] = $label; | |
| 144 | + } | |
| 135 | 145 | } |
| 136 | 146 | } |
| 137 | 147 | |
| 138 | - // Get Landing Pages. | |
| 139 | - $landing_pages = array( | |
| 148 | + // Get Landing Pages. Non-legacy pages populate the dropdown; legacy | |
| 149 | + // pages are exposed separately as a fallback so a previously-saved | |
| 150 | + // legacy landing page remains visible as the current selection | |
| 151 | + // without offering other legacy pages as new choices. | |
| 152 | + $landing_pages = array( | |
| 140 | 153 | '0' => esc_html__( 'None', 'convertkit' ), |
| 141 | 154 | ); |
| 155 | + $legacy_landing_pages = array(); | |
| 142 | 156 | if ( $convertkit_landing_pages->exist() ) { |
| 143 | 157 | foreach ( $convertkit_landing_pages->get() as $landing_page ) { |
| 144 | - $landing_pages[ absint( $landing_page['id'] ) ] = sanitize_text_field( $landing_page['name'] ); | |
| 158 | + if ( isset( $landing_page['url'] ) ) { | |
| 159 | + $legacy_landing_pages[ absint( $landing_page['id'] ) ] = sanitize_text_field( $landing_page['name'] ); | |
| 160 | + } else { | |
| 161 | + $landing_pages[ absint( $landing_page['id'] ) ] = sanitize_text_field( $landing_page['name'] ); | |
| 162 | + } | |
| 145 | 163 | } |
| 146 | 164 | } |
| 147 | 165 | |
| 148 | 166 | // Get Tags. |
| @@ -155,11 +173,12 @@ | ||
| 155 | 173 | } |
| 156 | 174 | } |
| 157 | 175 | |
| 158 | 176 | // Get Products. |
| 159 | - $restrict_content = array( | |
| 177 | + $restrict_content = array( | |
| 160 | 178 | '0' => esc_html__( 'Do not restrict content to member-only', 'convertkit' ), |
| 161 | 179 | ); |
| 180 | + $restrict_content_legacy_forms = array(); | |
| 162 | 181 | if ( $convertkit_forms->exist() ) { |
| 163 | 182 | $restrict_content['forms'] = array( |
| 164 | 183 | 'label' => esc_html__( 'Forms', 'convertkit' ), |
| 165 | 184 | 'values' => array(), |
| @@ -164,14 +183,21 @@ | ||
| 164 | 183 | 'label' => esc_html__( 'Forms', 'convertkit' ), |
| 165 | 184 | 'values' => array(), |
| 166 | 185 | ); |
| 167 | 186 | foreach ( $convertkit_forms->get() as $form ) { |
| 168 | - // Legacy forms don't include a `format` key, so define them as inline. | |
| 169 | - $restrict_content['forms']['values'][ 'form_' . absint( $form['id'] ) ] = sprintf( | |
| 187 | + $key = 'form_' . absint( $form['id'] ); | |
| 188 | + $label = sprintf( | |
| 170 | 189 | '%s [%s]', |
| 171 | 190 | sanitize_text_field( $form['name'] ), |
| 191 | + // Legacy forms don't include a `format` key, so define them as inline. | |
| 172 | 192 | ( ! empty( $form['format'] ) ? sanitize_text_field( $form['format'] ) : 'inline' ) |
| 173 | 193 | ); |
| 194 | + | |
| 195 | + if ( ! empty( $form['format'] ) ) { | |
| 196 | + $restrict_content['forms']['values'][ $key ] = $label; | |
| 197 | + } else { | |
| 198 | + $restrict_content_legacy_forms[ $key ] = $label; | |
| 199 | + } | |
| 174 | 200 | } |
| 175 | 201 | } |
| 176 | 202 | if ( $convertkit_tags->exist() ) { |
| 177 | 203 | $restrict_content['tags'] = array( |
| @@ -217,8 +243,9 @@ | ||
| 217 | 243 | esc_html__( 'sign in to Kit', 'convertkit' ) |
| 218 | 244 | ), |
| 219 | 245 | ), |
| 220 | 246 | 'values' => $forms, |
| 247 | + 'legacy_values' => $legacy_forms, | |
| 221 | 248 | 'resource_type' => 'forms', |
| 222 | 249 | ), |
| 223 | 250 | 'landing_page' => array( |
| 224 | 251 | 'label' => __( 'Landing Page', 'convertkit' ), |
| @@ -231,8 +258,9 @@ | ||
| 231 | 258 | '<a href="' . esc_url( convertkit_get_sign_in_url() ) . '" target="_blank">' . esc_html__( 'sign in to Kit', 'convertkit' ) . '</a>' |
| 232 | 259 | ), |
| 233 | 260 | ), |
| 234 | 261 | 'values' => $landing_pages, |
| 262 | + 'legacy_values' => $legacy_landing_pages, | |
| 235 | 263 | 'post_type' => 'page', |
| 236 | 264 | 'resource_type' => 'landing_pages', |
| 237 | 265 | ), |
| 238 | 266 | 'tag' => array( |
| @@ -266,8 +294,9 @@ | ||
| 266 | 294 | esc_html__( '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' ) |
| 267 | 295 | ), |
| 268 | 296 | ), |
| 269 | 297 | 'values' => $restrict_content, |
| 298 | + 'legacy_values' => $restrict_content_legacy_forms, | |
| 270 | 299 | 'resource_type' => 'restrict_content', |
| 271 | 300 | ), |
| 272 | 301 | ); |
| 273 | 302 | |