PluginProbe ʕ •ᴥ•ʔ
FAPI Member / trunk
FAPI Member vtrunk
2.2.33 2.2.32 trunk 1.9.47 2.1.18 2.2.24 2.2.25 2.2.26 2.2.28 2.2.29 2.2.30 2.2.31
fapi-member / src / Utils / PostTypeHelper.php
fapi-member / src / Utils Last commit date
AlertProvider.php 1 year ago ApiClient.php 1 day ago DateTimeHelper.php 1 year ago DateTimes.php 2 years ago DateTimesImmutable.php 2 years ago Debugger.php 1 year ago DisplayHelper.php 1 year ago EmailHelper.php 1 year ago PostTypeHelper.php 2 years ago Random.php 4 years ago SecurityValidator.php 2 years ago ShortcodeSubstitutor.php 2 months ago TemplateProvider.php 2 years ago functions.php 3 years ago
PostTypeHelper.php
40 lines
1 <?php
2
3 namespace FapiMember\Utils;
4
5 class PostTypeHelper
6 {
7 public static array $excludedPostTypePrefixes = ['jet-', 'elementor_', 'elemental_'];
8
9 /**
10 * @return array<string>
11 */
12 public static function getSupportedPostTypes(bool $cptOnly = false): array
13 {
14 $supportedPostTypes = [];
15 $excludedPostTypes = $cptOnly ? ['attachment', 'page', 'post'] : ['attachment'];
16 $supportedPostTypesObjects = get_post_types(['public' => true], 'objects');
17
18 foreach ($supportedPostTypesObjects as $obj) {
19 $name = $obj->name;
20
21 if (in_array($name, $excludedPostTypes, true)) {
22 continue;
23 }
24
25 foreach (self::$excludedPostTypePrefixes as $prefix) {
26 if (str_starts_with($name, $prefix)) {
27 continue 2;
28 }
29 }
30
31 $supportedPostTypes[] = $name;
32 }
33
34 sort($supportedPostTypes);
35
36 return $supportedPostTypes;
37 }
38
39 }
40