PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 3.4.5
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v3.4.5
3.4.5 3.4.4 3.4.3 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 All 198 releases
← All changes | includes/class-convertkit-post.php +41 -4 2.2.5 → 3.4.5 View file →
@@ -72,8 +72,20 @@
72 72 $meta[ $key ] = $value;
73 73 }
74 74 }
75 75
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 +
76 88 // Assign Post's Settings to the object.
77 89 $this->settings = $meta;
78 90
79 91 }
@@ -276,8 +288,32 @@
276 288
277 289 }
278 290
279 291 /**
292 + * Returns all Post Meta rows stored against this Post for the Plugin's Post Meta key.
293 + *
294 + * Queries the database directly, as each row's meta ID is required to delete individual
295 + * duplicate rows, which get_post_meta() doesn't return.
296 + *
297 + * @since 3.4.5
298 + *
299 + * @return array Post Meta rows, oldest first.
300 + */
301 + public function get_meta_rows() {
302 +
303 + global $wpdb;
304 +
305 + return $wpdb->get_results(
306 + $wpdb->prepare(
307 + "SELECT meta_id, meta_value FROM {$wpdb->postmeta} WHERE post_id = %d AND meta_key = %s ORDER BY meta_id ASC",
308 + $this->post_id,
309 + self::POST_META_KEY
310 + )
311 + );
312 +
313 + }
314 +
315 + /**
280 316 * Saves Post settings to the Post.
281 317 *
282 318 * @since 1.9.6
283 319 *
@@ -301,11 +337,11 @@
301 337 public function get_default_settings() {
302 338
303 339 $defaults = array(
304 340 'form' => '-1', // -1: Plugin Default Form, 0: No Form, 1+: Specific Form ID on ConvertKit.
305 - 'landing_page' => '',
306 - 'tag' => '',
307 - 'restrict_content' => '',
341 + 'landing_page' => '0', // 0: None, 1+: Specific Landing Page ID.
342 + 'tag' => '0', // 0: None, 1+: Specific Tag ID.
343 + 'restrict_content' => '0', // 0: None, form_<id> / tag_<id> / product_<id>: restrict to that resource.
308 344 );
309 345
310 346 /**
311 347 * The default settings, used to populate the Post's Settings when a Post has no Settings.
@@ -312,10 +348,11 @@
312 348 *
313 349 * @since 1.9.6
314 350 *
315 351 * @param array $defaults Default Settings.
352 + * @param int $post_id Post ID.
316 353 */
317 - $defaults = apply_filters( 'convertkit_post_get_default_settings', $defaults );
354 + $defaults = apply_filters( 'convertkit_post_get_default_settings', $defaults, $this->post_id );
318 355
319 356 return $defaults;
320 357
321 358 }