PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 2.4.7
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v2.4.7
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-term.php +22 -72 3.3.32.4.7 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 = '_wp_convertkit_term_meta';
21 + const TERM_META_KEY = 'ck_default_form';
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|array
35 + * @var bool|string
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 array
69 + * @return string
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['form'];
86 + return $this->settings;
87 87
88 88 }
89 89
90 90 /**
@@ -95,83 +95,36 @@
95 95 * @return bool
96 96 */
97 97 public function has_form() {
98 98
99 - return ( $this->settings['form'] > 0 );
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 + }
100 109
101 - }
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 );
102 113
103 - /**
104 - * Whether the Term is set to use the Plugin's Default Form Setting.
105 - *
106 - * @since 2.6.6
107 - *
108 - * @return bool
109 - */
110 - public function uses_default_form() {
111 -
112 - return ( $this->settings['form'] === -1 );
113 -
114 114 }
115 115
116 116 /**
117 - * Whether the Post's Form setting is set to 'None'
118 - *
119 - * @since 2.6.6
120 - *
121 - * @return bool
122 - */
123 - public function uses_no_form() {
124 -
125 - return ( $this->settings['form'] === 0 );
126 -
127 - }
128 -
129 - /**
130 - * Returns the form position setting for the Term
131 - * on the Term archive.
132 - *
133 - * @since 2.4.9.1
134 - *
135 - * @return string
136 - */
137 - public function get_form_position() {
138 -
139 - return $this->settings['form_position'];
140 -
141 - }
142 -
143 - /**
144 - * Whether the Term has a ConvertKit Form Position defined
145 - * for the Term archive.
146 - *
147 - * @since 2.4.9.1
148 - *
149 - * @return bool
150 - */
151 - public function has_form_position() {
152 -
153 - return ( $this->settings['form_position'] !== '' );
154 -
155 - }
156 -
157 - /**
158 117 * Saves Term settings to the Term.
159 118 *
160 119 * @since 1.9.6
161 120 *
162 - * @param array $meta Settings.
163 - * @return bool Term Meta was updated
121 + * @param string $meta Settings.
164 122 */
165 123 public function save( $meta ) {
166 124
167 - $result = update_term_meta( $this->term_id, self::TERM_META_KEY, array_merge( $this->get(), $meta ) );
125 + return update_term_meta( $this->term_id, self::TERM_META_KEY, $meta );
168 126
169 - // Reload meta in class, to reflect changes.
170 - $this->settings = get_term_meta( $this->term_id, self::TERM_META_KEY, true );
171 -
172 - return $result;
173 -
174 127 }
175 128
176 129 /**
177 130 * The default settings, used to populate the Term's Settings when a Term
@@ -178,16 +131,13 @@
178 131 * has no Settings.
179 132 *
180 133 * @since 1.9.6
181 134 *
182 - * @return array
135 + * @return string
183 136 */
184 137 public function get_default_settings() {
185 138
186 - $defaults = array(
187 - 'form' => '',
188 - 'form_position' => '',
189 - );
139 + $defaults = '';
190 140
191 141 /**
192 142 * The default settings, used to populate the Term's Settings when a Term
193 143 * has no Settings.
@@ -193,9 +143,9 @@
193 143 * has no Settings.
194 144 *
195 145 * @since 1.9.6
196 146 *
197 - * @param array $defaults Default Form
147 + * @param string $defaults Default Form
198 148 */
199 149 $defaults = apply_filters( 'convertkit_term_get_default_settings', $defaults );
200 150
201 151 return $defaults;