{"id":18273451,"url":"https://github.com/arraypress/register-post-states","last_synced_at":"2025-04-09T03:40:35.522Z","repository":{"id":245028277,"uuid":"816987718","full_name":"arraypress/register-post-states","owner":"arraypress","description":"A WordPress library for defining and managing custom post states within the admin area.","archived":false,"fork":false,"pushed_at":"2024-12-07T21:21:27.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-22T17:42:11.470Z","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}},"created_at":"2024-06-18T19:35:35.000Z","updated_at":"2024-06-18T19:50:08.000Z","dependencies_parsed_at":"2024-06-19T06:15:56.576Z","dependency_job_id":"6cfe91fa-8fed-4776-9f35-c755baf2c5d1","html_url":"https://github.com/arraypress/register-post-states","commit_stats":null,"previous_names":["arraypress/register-post-states"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fregister-post-states","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fregister-post-states/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fregister-post-states/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fregister-post-states/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arraypress","download_url":"https://codeload.github.com/arraypress/register-post-states/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238915887,"owners_count":19551794,"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","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":"2024-11-05T12:06:30.712Z","updated_at":"2025-02-14T22:13:15.210Z","avatar_url":"https://github.com/arraypress.png","language":"PHP","readme":"# WordPress Register Custom Post States Library\n\nEffortlessly manage and display custom indicators next to your posts in WordPress. Define your own post states like \"\nLanding Page\" or \"Featured Article\" with ease. This library streamlines content management, aiding quick post\nidentification and categorization.\n\n## Features ##\n\n* **Custom Post States:** Define your own indicators for posts.\n* **Flexible Integration:** Seamlessly add this library to your WordPress project.\n* **Callable Function:** Use a callable function to retrieve option values.\n* **Quick Reference:** Instantly recognize the state of each post.\n\n## Minimum Requirements ##\n\n* **PHP:** 7.4\n* **WordPress:** 6.5.4\n\n## Installation\n\nThis library is a developer tool, not a WordPress plugin, so it needs to be included in your WordPress project or plugin.\n\nYou can install it using Composer:\n\n```bash\ncomposer require arraypress/register-custom-columns\n```\n\n## Basic Usage\n\n```php\n// Require the Composer autoloader.\nrequire_once __DIR__ . '/vendor/autoload.php';\n\nuse function ArrayPress\\RegisterPostStates\\register_post_states;\n```\n\n### Registering Post States\n\nTo utilize this functionality, you first define an associative array that maps option keys to labels for the post\nstates. You can optionally specify a callable function responsible for retrieving option values, such as WordPress'\nbuilt-in `get_option` function. Here's how you can set it up:\n\n```php\n// Configure post states with an associative array, mapping option keys to labels.\n// Optionally, specify a callable function like `get_option` to retrieve option values.\n// It's important to ensure `get_option` returns a valid WordPress post ID to match with the admin posts list.\nregister_post_states( [\n    'landing_page'  =\u003e __( 'Landing Page', 'text-domain' ),\n    'featured_post' =\u003e __( 'Featured Post', 'text-domain' )\n] );\n```\n\nWhen the `RegisterPostStates` is initialized with the provided options, it hooks into\nWordPress `'display_post_states'` filter. This integration allows it to append the custom state labels to the\nappropriate posts in the admin list view, based on the configuration provided.\n\nEnsure that this function returns a valid post ID to correctly associate custom state labels with the appropriate posts.\n\n### Advanced Usage\n\nFor more advanced customization, you can set a specific callable function to fetch option values instead of the\ndefault `get_option`. This is particularly useful if your WordPress setup utilizes a custom options management system,\nsuch as `edd_get_option` from Easy Digital Downloads or any other custom-built mechanism.\n\nHere's how to define a custom getter function for the `RegisterPostStates`:\n\n```php\n$options_map = [\n    'landing_page'  =\u003e __( 'Landing Page', 'text-domain' ),\n    'featured_post' =\u003e __( 'Featured Post', 'text-domain' ),\n    // Additional custom states as necessary\n];\n\n// Define your custom getter function, such as 'edd_get_option' or another custom function.\n$custom_option_getter = 'edd_get_option';\n\n// Initialize the Post_States_Manager with your custom getter.\nregister_post_states( $options_map, $custom_option_getter );\n```\n\nWhen you provide your custom getter, `RegisterPostStates` will use this function for all option value retrievals. This\nseamless integration allows for a consistent data handling process that aligns with your website's specific\nconfiguration.\n\nRemember to ensure that the custom getter function you provide meets the expected signature and functionality\nas `get_option`, to prevent any incompatibilities or errors in the post states management.\n\n### Error Handling\n\nThe `register_post_states` function also accepts a third parameter: an error callback function. This callback is invoked\nif an exception occurs during the initialization of the `RegisterPostStates`. This allows for graceful handling of\ninitialization errors and ensures a smooth user experience.\n\n```php\nregister_post_states( $options_map, 'get_option', function( $exception ) {\n    edd_debug_log_exception( $exception );\n});\n```\n\n## Contributions\n\nContributions to this library are highly appreciated. Raise issues on GitHub or submit pull requests for bug\nfixes or new features. Share feedback and suggestions for improvements.\n\n## License: GPLv2 or later\n\nThis program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public\nLicense as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later\nversion.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied\nwarranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farraypress%2Fregister-post-states","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farraypress%2Fregister-post-states","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farraypress%2Fregister-post-states/lists"}