PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 2.5.2
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v2.5.2
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 2.3.0 2.3.1 All 196 releases
← All changes | includes/class-convertkit-term.php +40 -21 2.2.42.5.2 View file →
@@ -17,9 +17,9 @@
17 17 * Holds the Term Meta Key that stores ConvertKit settings on a per-Taxonomy Term basis
18 18 *
19 19 * @var string
20 20 */
21 - const TERM_META_KEY = 'ck_default_form';
21 + const TERM_META_KEY = '_wp_convertkit_term_meta';
22 22
23 23 /**
24 24 * Holds the Term ID
25 25 *
@@ -31,9 +31,9 @@
31 31
32 32 /**
33 33 * Holds the Term's Settings
34 34 *
35 - * @var bool|string
35 + * @var bool|array
36 36 */
37 37 private $settings = false;
38 38
39 39 /**
@@ -65,9 +65,9 @@
65 65 * Returns settings for the Term.
66 66 *
67 67 * @since 1.9.6
68 68 *
69 - * @return string
69 + * @return array
70 70 */
71 71 public function get() {
72 72
73 73 return $this->settings;
@@ -82,9 +82,9 @@
82 82 * @return string
83 83 */
84 84 public function get_form() {
85 85
86 - return $this->settings;
86 + return $this->settings['form'];
87 87
88 88 }
89 89
90 90 /**
@@ -95,31 +95,47 @@
95 95 * @return bool
96 96 */
97 97 public function has_form() {
98 98
99 - // Backward compat. for Terms created/edited prior to 1.9.6, where
100 - // 'default' was used instead of zero to denote the Post / Post Type
101 - // setting should be used for determining the Form to display.
102 - // Using a comparison operator on 'default' will return different results in:
103 - // PHP < 8.0: 'default' > 0 is false
104 - // PHP 8.0+: 'default' > 0 is true
105 - // See https://www.php.net/manual/en/language.operators.comparison.php.
106 - if ( $this->settings === 'default' ) {
107 - return false;
108 - }
99 + return ( $this->settings['form'] > 0 );
109 100
110 - // If the setting is greater than zero, it's a specific Form ID that
111 - // should be used for Posts assigned to this Category.
112 - return ( $this->settings > 0 );
101 + }
113 102
103 + /**
104 + * Returns the form position setting for the Term
105 + * on the Term archive.
106 + *
107 + * @since 2.4.9.1
108 + *
109 + * @return string
110 + */
111 + public function get_form_position() {
112 +
113 + return $this->settings['form_position'];
114 +
114 115 }
115 116
116 117 /**
118 + * Whether the Term has a ConvertKit Form Position defined
119 + * for the Term archive.
120 + *
121 + * @since 2.4.9.1
122 + *
123 + * @return bool
124 + */
125 + public function has_form_position() {
126 +
127 + return ( $this->settings['form_position'] !== '' );
128 +
129 + }
130 +
131 + /**
117 132 * Saves Term settings to the Term.
118 133 *
119 134 * @since 1.9.6
120 135 *
121 - * @param string $meta Settings.
136 + * @param array $meta Settings.
137 + * @return bool Term Meta was updated
122 138 */
123 139 public function save( $meta ) {
124 140
125 141 return update_term_meta( $this->term_id, self::TERM_META_KEY, $meta );
@@ -131,13 +147,16 @@
131 147 * has no Settings.
132 148 *
133 149 * @since 1.9.6
134 150 *
135 - * @return string
151 + * @return array
136 152 */
137 153 public function get_default_settings() {
138 154
139 - $defaults = '';
155 + $defaults = array(
156 + 'form' => '',
157 + 'form_position' => '',
158 + );
140 159
141 160 /**
142 161 * The default settings, used to populate the Term's Settings when a Term
143 162 * has no Settings.
@@ -143,9 +162,9 @@
143 162 * has no Settings.
144 163 *
145 164 * @since 1.9.6
146 165 *
147 - * @param string $defaults Default Form
166 + * @param array $defaults Default Form
148 167 */
149 168 $defaults = apply_filters( 'convertkit_term_get_default_settings', $defaults );
150 169
151 170 return $defaults;