{"id":29651295,"url":"https://github.com/arraypress/wp-post-type-utils","last_synced_at":"2025-07-22T05:06:33.836Z","repository":{"id":302497249,"uuid":"1012503952","full_name":"arraypress/wp-post-type-utils","owner":"arraypress","description":"A lean WordPress library for working with post types and post type operations.","archived":false,"fork":false,"pushed_at":"2025-07-02T17:14:18.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-02T18:28:00.655Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arraypress.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-02T12:38:06.000Z","updated_at":"2025-07-02T17:14:21.000Z","dependencies_parsed_at":"2025-07-02T18:29:04.028Z","dependency_job_id":"f6909e3f-60ca-4a6a-a397-2834492a25b8","html_url":"https://github.com/arraypress/wp-post-type-utils","commit_stats":null,"previous_names":["arraypress/wp-post-type-utils"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/arraypress/wp-post-type-utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fwp-post-type-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fwp-post-type-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fwp-post-type-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fwp-post-type-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arraypress","download_url":"https://codeload.github.com/arraypress/wp-post-type-utils/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fwp-post-type-utils/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266430667,"owners_count":23927169,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-22T05:06:33.278Z","updated_at":"2025-07-22T05:06:33.811Z","avatar_url":"https://github.com/arraypress.png","language":"PHP","readme":"# WordPress Post Type Utilities\n\nA lightweight WordPress library for working with post types and post type operations. Provides clean APIs for post type information retrieval, capability checking, and search functionality with value/label formatting perfect for forms and admin interfaces.\n\n## Features\n\n* 🎯 **Clean API**: WordPress-style snake_case methods with consistent interfaces\n* 🔍 **Built-in Search**: Post type search with value/label formatting\n* 📋 **Form-Ready Options**: Perfect value/label arrays for selects and forms\n* 🛠️ **Feature Detection**: Check post type capabilities and feature support\n* 📊 **Information Retrieval**: Access labels, capabilities, and properties\n* 🎨 **Flexible Filtering**: Filter by features, hierarchical status, etc.\n* 🔗 **Taxonomy Relationships**: Easy taxonomy-post type relationship checking\n* ⚡ **Status Checking**: Built-in, public, hierarchical, and REST API status checks\n\n## Requirements\n\n* PHP 7.4 or later\n* WordPress 5.0 or later\n\n## Installation\n\n```bash\ncomposer require arraypress/wp-post-type-utils\n```\n\n## Basic Usage\n\n### Working with Single Post Types\n\n```php\nuse ArrayPress\\PostTypeUtils\\PostType;\n\n// Check if post type exists\nif ( PostType::exists( 'product' ) ) {\n\t// Post type exists\n}\n\n// Get post type object\n$post_type_obj = PostType::get( 'product' );\n\n// Get labels\n$singular     = PostType::get_singular_label( 'product' );\n$plural       = PostType::get_plural_label( 'product' );\n$custom_label = PostType::get_label( 'product', 'add_new_item' );\n$description  = PostType::get_description( 'product' );\n\n// Check properties and status\nif ( PostType::is_hierarchical( 'product' ) ) {\n\t// Post type is hierarchical\n}\n\nif ( PostType::is_public( 'product' ) ) {\n\t// Post type is public\n}\n\nif ( PostType::is_built_in( 'product' ) ) {\n\t// Post type is built-in (core)\n}\n\nif ( PostType::has_archive( 'product' ) ) {\n\t// Post type has archive pages\n}\n\nif ( PostType::show_in_rest( 'product' ) ) {\n\t// Post type appears in REST API\n}\n\n// Check feature support\nif ( PostType::supports_feature( 'product', 'thumbnail' ) ) {\n\t// Supports featured images\n}\n\n// Quick feature checks\nif ( PostType::supports_thumbnails( 'product' ) ) {\n\t// Supports thumbnails\n}\n\nif ( PostType::supports_comments( 'product' ) ) {\n\t// Supports comments\n}\n\nif ( PostType::supports_revisions( 'product' ) ) {\n\t// Supports revisions\n}\n\n// Get taxonomies\n$taxonomies       = PostType::get_taxonomies( 'product' );\n$taxonomy_objects = PostType::get_taxonomies( 'product', 'objects' );\n\n// Check taxonomy registration\nif ( PostType::is_registered_for_taxonomy( 'product', 'product_category' ) ) {\n\t// Product post type uses product_category taxonomy\n}\n\n// Get capabilities\n$capabilities = PostType::get_capabilities( 'product' );\n\n// Get admin info\n$menu_position = PostType::get_menu_position( 'product' );\n\n// Get archive info\n$archive_url  = PostType::get_archive_url( 'product' );\n$archive_slug = PostType::get_archive_slug( 'product' );\n\n// REST API\n$rest_base = PostType::get_rest_base( 'product' );\n\n// Count posts\n$published_count = PostType::count_posts( 'product', 'publish' );\n$draft_count     = PostType::count_posts( 'product', 'draft' );\n```\n\n### Working with Multiple Post Types\n\n```php\n// Check existence\n$existing = PostTypes::exists( [ 'post', 'page', 'invalid' ] );\n// Returns: ['post', 'page']\n\n// Get multiple post type objects\n$post_type_objects = PostTypes::get( [ 'post', 'page', 'product' ] );\n\n// Get all registered post types\n$all_types          = PostTypes::get_all();\n$public_types       = PostTypes::get_public();\n$hierarchical_types = PostTypes::get_hierarchical();\n\n// Get custom post types only (exclude built-in)\n$custom_types = PostTypes::get_custom();\n\n// Get post types by taxonomy\n$types_with_categories = PostTypes::get_by_taxonomy( 'category' );\n\n// Search post types\n$search_results = PostTypes::search( 'product' );\n\n// Search post types and get options\n$options = PostTypes::search_options( 'product' );\n// Returns: [['value' =\u003e 'product', 'label' =\u003e 'Products'], ...]\n\n// Get all post types as options\n$all_options = PostTypes::get_options();\n// Returns: ['post' =\u003e 'Posts', 'page' =\u003e 'Pages', ...]\n\n// Exclude default post types from options\n$custom_options = PostTypes::get_options( [], true );\n\n// Use different label field\n$options_with_plural = PostTypes::get_options( [], false, 'name' );\n```\n\n### Feature Detection and Analysis\n\n```php\n// Get post types by specific features\n$editor_types    = PostTypes::get_by_feature( 'editor' );\n$thumbnail_types = PostTypes::get_by_feature( 'thumbnail' );\n\n// Check which types support a feature\n$thumbnail_supported = PostTypes::supports_feature( [ 'post', 'page', 'product' ], 'thumbnail' );\n\n// Get Gutenberg-supported types\n$gutenberg_types = PostTypes::get_gutenberg_supported();\n\n// Single post type feature checks\n$supports_editor        = PostType::supports_feature( 'product', 'editor' );\n$supports_thumbnail     = PostType::supports_feature( 'product', 'thumbnail' );\n$supports_custom_fields = PostType::supports_feature( 'product', 'custom-fields' );\n```\n\n### Labels and Capabilities\n\n```php\n// Get specific labels for single post type\n$add_new   = PostType::get_label( 'product', 'add_new' );\n$edit_item = PostType::get_label( 'product', 'edit_item' );\n$view_item = PostType::get_label( 'product', 'view_item' );\n\n// Get capabilities for single post type\n$caps = PostType::get_capabilities( 'product' );\n// Access like: $caps-\u003eedit_posts, $caps-\u003edelete_posts\n\n// Get labels for multiple post types\n$labels     = PostTypes::get_labels( [ 'post', 'page' ], 'singular_name' );\n$all_labels = PostTypes::get_labels( [ 'post', 'page' ] ); // All labels\n\n// Get capabilities for multiple post types\n$capabilities = PostTypes::get_capabilities( [ 'post', 'page', 'product' ] );\n```\n\n### Advanced Usage Examples\n\n```php\n// Build admin interface options\nfunction get_content_type_options() {\n\treturn PostTypes::get_options( [\n\t\t'public'  =\u003e true,\n\t\t'show_ui' =\u003e true\n\t], true, 'singular_name' ); // Exclude defaults, use singular names\n}\n\n// Check if post type is suitable for content management\nfunction is_manageable_post_type( $post_type ) {\n\treturn PostType::exists( $post_type ) \u0026\u0026\n\t       PostType::is_public( $post_type ) \u0026\u0026\n\t       PostType::supports_feature( $post_type, 'editor' );\n}\n\n// Get post types that can have featured images\n$thumbnail_types = PostTypes::get_by_feature( 'thumbnail' );\n\n// Get all custom post types with archives\n$custom_with_archives = array_filter(\n\tPostTypes::get_custom(),\n\tfn( $type ) =\u003e PostType::has_archive( $type )\n);\n\n// Find post types that support both comments and revisions\n$advanced_types = array_intersect(\n\tPostTypes::get_by_feature( 'comments' ),\n\tPostTypes::get_by_feature( 'revisions' )\n);\n```\n\n## API Reference\n\n### PostType Class (Single Post Types)\n\n**Core Retrieval:**\n- `exists( string $post_type ): bool`\n- `get( string $post_type ): ?WP_Post_Type`\n\n**Labels \u0026 Information:**\n- `get_labels( string $post_type ): ?object`\n- `get_label( string $post_type, string $label ): ?string`\n- `get_singular_label( string $post_type ): ?string`\n- `get_plural_label( string $post_type ): ?string`\n- `get_description( string $post_type ): ?string`\n- `get_menu_position( string $post_type ): ?int`\n\n**Properties \u0026 Status:**\n- `is_hierarchical( string $post_type ): bool`\n- `is_public( string $post_type ): bool`\n- `is_built_in( string $post_type ): bool`\n- `has_archive( string $post_type ): bool`\n- `show_in_rest( string $post_type ): bool`\n\n**Features \u0026 Support:**\n- `supports_feature( string $post_type, string $feature ): bool`\n- `supports_thumbnails( string $post_type ): bool`\n- `supports_comments( string $post_type ): bool`\n- `supports_revisions( string $post_type ): bool`\n\n**Capabilities:**\n- `get_capabilities( string $post_type ): ?object`\n\n**Taxonomies \u0026 Relationships:**\n- `get_taxonomies( string $post_type, string $output = 'names' ): array`\n- `is_registered_for_taxonomy( string $post_type, string $taxonomy ): bool`\n\n**URLs \u0026 Archives:**\n- `get_archive_url( string $post_type )`\n- `get_archive_slug( string $post_type ): ?string`\n\n**REST API:**\n- `get_rest_base( string $post_type ): ?string`\n\n**Post Counts \u0026 Stats:**\n- `count_posts( string $post_type, string $status = 'publish' ): int`\n\n### PostTypes Class (Multiple Post Types)\n\n**Core Retrieval:**\n- `exists( array $post_types ): array`\n- `get( array $post_types, bool $include_nonexistent = false ): array`\n- `get_all( array $args = [], string $output = 'names', bool $exclude_defaults = false ): array`\n- `get_public( string $output = 'names' ): array`\n- `get_hierarchical( string $output = 'names' ): array`\n- `get_custom( string $output = 'names' ): array`\n- `get_by_taxonomy( string $taxonomy ): array`\n\n**Search \u0026 Options:**\n- `search( string $search, array $args = [] ): array`\n- `search_options( string $search, array $args = [] ): array`\n- `get_options( array $args = [], bool $exclude_defaults = false, string $label_field = 'singular_name' ): array`\n\n**Feature Analysis:**\n- `get_by_feature( string $feature ): array`\n- `supports_feature( array $post_types, string $feature ): array`\n- `get_gutenberg_supported(): array`\n\n**Labels \u0026 Capabilities:**\n- `get_labels( array $post_types, string $label = '' ): array`\n- `get_capabilities( array $post_types ): array`\n\n## Key Features\n\n- **Value/Label Format**: Perfect for forms and selects\n- **Feature Detection**: Comprehensive capability checking\n- **Search Functionality**: Built-in post type search with formatting\n- **Flexible Filtering**: Multiple filtering options by features, status, etc.\n- **Information Access**: Easy access to all post type properties\n- **Status Checking**: Built-in, public, hierarchical, and REST API status\n- **Taxonomy Relationships**: Easy taxonomy-post type relationship management\n- **Custom vs Built-in**: Clear separation between custom and core post types\n\n## Requirements\n\n- PHP 7.4+\n- WordPress 5.0+\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the GPL-2.0-or-later License.\n\n## Support\n\n- [Documentation](https://github.com/arraypress/wp-post-type-utils)\n- [Issue Tracker](https://github.com/arraypress/wp-post-type-utils/issues)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farraypress%2Fwp-post-type-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farraypress%2Fwp-post-type-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farraypress%2Fwp-post-type-utils/lists"}