PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/models/FrmGatedContentAction.php +18 -41 6.33 → trunk View file →
@@ -176,26 +176,15 @@
176 176 return (array) apply_filters( 'frm_gated_content_shortcodes', $shortcodes, $action_id );
177 177 }
178 178
179 179 /**
180 - * Get posts for the "post" item type selector.
181 - *
182 - * Applies the `frm_gated_content_posts_query` filter so callers can extend
183 - * the post types or change any other WP_Query argument, then narrows the
184 - * result to posts that actually require a token: private posts and
185 - * password-protected posts. Plain published posts are publicly accessible
186 - * and should not appear as selectable gated content items.
187 - *
188 - * @return WP_Post[]
189 - */
190 - /**
191 180 * Get posts for all post-type-backed gated content item type selectors.
192 181 *
193 - * Runs one query covering all enabled post types derived from get_types(), then
194 - * groups the results by type key. Only private and password-protected posts are
195 - * included — plain published posts are publicly accessible and not selectable.
182 + * Runs one query covering all enabled post types, then groups results by type key.
183 + * Only private and password-protected posts are included — plain published posts
184 + * are publicly accessible and should not appear as selectable gated content items.
196 185 *
197 - * @return array<string, WP_Post[]> Posts keyed by item type slug (e.g. 'page', 'post').
186 + * @return array<string, list<object>> Posts keyed by item type slug (e.g. 'page', 'post').
198 187 */
199 188 public static function get_posts() {
200 189 $post_types = array();
201 190
@@ -208,34 +197,21 @@
208 197 if ( ! $post_types ) {
209 198 return array();
210 199 }
211 200
212 - /**
213 - * Filter the get_posts() arguments used to build the gated content item selectors.
214 - *
215 - * The filtered list is then narrowed to private and password-protected posts only.
216 - *
217 - * @since 6.33
218 - *
219 - * @param array $query_args get_posts() argument array.
220 - */
221 - $query_args = (array) apply_filters(
222 - 'frm_gated_content_posts_query',
201 + /** @var object[] $raw_posts */
202 + $raw_posts = FrmDb::get_results(
203 + 'posts',
223 204 array(
224 - 'post_type' => $post_types,
225 - 'post_status' => array( 'publish', 'private' ),
226 - 'orderby' => 'title',
227 - 'order' => 'ASC',
228 - 'numberposts' => -1,
229 - 'update_post_meta_cache' => false,
230 - 'update_post_term_cache' => false,
231 - )
205 + 'post_type' => $post_types,
206 + 'post_status' => array( 'publish', 'private' ),
207 + ),
208 + 'ID, post_title, post_password, post_status, post_type',
209 + array( 'order_by' => 'post_title ASC' )
232 210 );
233 211
234 - $raw_posts = get_posts( $query_args );
235 - $raw_posts = is_array( $raw_posts ) ? $raw_posts : array();
236 -
237 212 // Initialise empty buckets in get_types() order.
213 + /** @var array<string, list<object>> $grouped */
238 214 $grouped = array_fill_keys( $post_types, array() );
239 215
240 216 foreach ( $raw_posts as $post ) {
241 217 if ( 'private' !== $post->post_status && '' === $post->post_password ) {
@@ -242,14 +218,15 @@
242 218 // Skip publicly accessible posts.
243 219 continue;
244 220 }
245 221
246 - if ( isset( $grouped[ $post->post_type ] ) ) {
247 - $grouped[ $post->post_type ][] = $post;
222 + $post_type = (string) $post->post_type;
223 +
224 + if ( isset( $grouped[ $post_type ] ) ) {
225 + $grouped[ $post_type ][] = $post;
248 226 }
249 227 }
250 228
251 - /** @var array<string, WP_Post[]> */
252 229 return $grouped;
253 230 }
254 231
255 232 /**
@@ -258,9 +235,9 @@
258 235 * Returns a JSON string suitable for passing as a `data-source` attribute to a
259 236 * jQuery UI autocomplete widget. Each entry has a `value` (post ID string) and
260 237 * a `label` (post title).
261 238 *
262 - * @param WP_Post[] $posts Posts returned by get_posts().
239 + * @param object[] $posts Posts returned by get_posts().
263 240 *
264 241 * @return string JSON-encoded array, or an empty string on encoding failure.
265 242 */
266 243 public static function get_posts_autocomplete_source( $posts ) {