PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 2.0.2
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v2.0.2
3.4.2 3.4.1 3.4.0 3.3.9 3.3.8 3.3.7 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 All 195 releases
← All changes | includes/class-convertkit-post.php +5 -102 3.4.22.0.2 View file →
@@ -49,11 +49,9 @@
49 49 $this->post_id = $post_id;
50 50
51 51 // Get Post Meta.
52 52 $meta = get_post_meta( $post_id, self::POST_META_KEY, true );
53 -
54 - // If no settings exist, or the settings are a string, fallback to the default settings.
55 - if ( ! $meta || is_string( $meta ) ) {
53 + if ( ! $meta ) {
56 54 // Fallback to default settings.
57 55 $meta = $this->get_default_settings();
58 56
59 57 // Backward compat check for older Plugin version settings.
@@ -72,20 +70,8 @@
72 70 $meta[ $key ] = $value;
73 71 }
74 72 }
75 73
76 - /**
77 - * Programmatically define ConvertKit settings for an individual Post, overriding those defined in the
78 - * meta box.
79 - *
80 - * @since 2.4.4
81 - *
82 - * @param array $meta Post Settings.
83 - * @param int $post_id Post ID.
84 - * @return array Post Settings.
85 - */
86 - $meta = apply_filters( 'convertkit_post_settings', $meta, $this->post_id );
87 -
88 74 // Assign Post's Settings to the object.
89 75 $this->settings = $meta;
90 76
91 77 }
@@ -142,76 +128,8 @@
142 128
143 129 }
144 130
145 131 /**
146 - * Returns the restrict content setting for the Post, which might be a
147 - * Form, Tag or Product.
148 - *
149 - * @since 2.1.0
150 - *
151 - * @return string
152 - */
153 - public function get_restrict_content() {
154 -
155 - return $this->settings['restrict_content'];
156 -
157 - }
158 -
159 - /**
160 - * Returns the restrict content setting's resource type.
161 - *
162 - * @since 2.1.0
163 - *
164 - * @return string
165 - */
166 - public function get_restrict_content_type() {
167 -
168 - // No type if restrict content isn't enabled on this Post.
169 - if ( ! $this->restrict_content_enabled() ) {
170 - return '';
171 - }
172 -
173 - // No type if the setting isn't of the expected format resource_ID.
174 - if ( strpos( $this->settings['restrict_content'], '_' ) === false ) {
175 - return '';
176 - }
177 -
178 - // Extract resource type from the setting.
179 - list( $resource_type, $resource_id ) = explode( '_', $this->settings['restrict_content'] );
180 -
181 - // Return resource type.
182 - return $resource_type;
183 -
184 - }
185 -
186 - /**
187 - * Returns the restrict content setting's resource ID.
188 - *
189 - * @since 2.1.0
190 - *
191 - * @return bool|int
192 - */
193 - public function get_restrict_content_id() {
194 -
195 - // No ID if restrict content isn't enabled on this Post.
196 - if ( ! $this->restrict_content_enabled() ) {
197 - return false;
198 - }
199 -
200 - // No ID if the setting isn't of the expected format resource_ID.
201 - if ( strpos( $this->settings['restrict_content'], '_' ) === false ) {
202 - return false;
203 - }
204 -
205 - // Extract resource ID from the setting.
206 - list( $resource_type, $resource_id ) = explode( '_', $this->settings['restrict_content'] );
207 -
208 - // Return resource ID.
209 - return (int) $resource_id;
210 -
211 - }
212 -
213 - /**
214 132 * Whether the Post has a ConvertKit Form defined.
215 133 *
216 134 * @since 1.9.6
217 135 *
@@ -275,21 +193,8 @@
275 193
276 194 }
277 195
278 196 /**
279 - * Whether the Post has a ConvertKit Form, Tag or Product defined for restricted content.
280 - *
281 - * @since 2.0.0
282 - *
283 - * @return bool
284 - */
285 - public function restrict_content_enabled() {
286 -
287 - return ! empty( $this->settings['restrict_content'] );
288 -
289 - }
290 -
291 - /**
292 197 * Saves Post settings to the Post.
293 198 *
294 199 * @since 1.9.6
295 200 *
@@ -312,12 +217,11 @@
312 217 */
313 218 public function get_default_settings() {
314 219
315 220 $defaults = array(
316 - 'form' => '-1', // -1: Plugin Default Form, 0: No Form, 1+: Specific Form ID on ConvertKit.
317 - 'landing_page' => '0', // 0: None, 1+: Specific Landing Page ID.
318 - 'tag' => '0', // 0: None, 1+: Specific Tag ID.
319 - 'restrict_content' => '0', // 0: None, form_<id> / tag_<id> / product_<id>: restrict to that resource.
221 + 'form' => '-1', // -1: Plugin Default Form, 0: No Form, 1+: Specific Form ID on ConvertKit.
222 + 'landing_page' => '',
223 + 'tag' => '',
320 224 );
321 225
322 226 /**
323 227 * The default settings, used to populate the Post's Settings when a Post has no Settings.
@@ -324,11 +228,10 @@
324 228 *
325 229 * @since 1.9.6
326 230 *
327 231 * @param array $defaults Default Settings.
328 - * @param int $post_id Post ID.
329 232 */
330 - $defaults = apply_filters( 'convertkit_post_get_default_settings', $defaults, $this->post_id );
233 + $defaults = apply_filters( 'convertkit_post_get_default_settings', $defaults );
331 234
332 235 return $defaults;
333 236
334 237 }