{"id":19252948,"url":"https://github.com/frc/frc-wp-framework","last_synced_at":"2025-07-02T14:36:07.534Z","repository":{"id":140523107,"uuid":"118434566","full_name":"frc/frc-wp-framework","owner":"frc","description":"Frantic WP Framework. Experimental features and other helpers to aid development.","archived":false,"fork":false,"pushed_at":"2021-07-06T10:25:02.000Z","size":152,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-27T15:02:41.281Z","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":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/frc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2018-01-22T09:22:40.000Z","updated_at":"2023-11-07T22:39:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"2822de7a-45c1-42f4-ba3e-c6d90b503598","html_url":"https://github.com/frc/frc-wp-framework","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/frc/frc-wp-framework","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frc%2Ffrc-wp-framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frc%2Ffrc-wp-framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frc%2Ffrc-wp-framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frc%2Ffrc-wp-framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/frc","download_url":"https://codeload.github.com/frc/frc-wp-framework/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frc%2Ffrc-wp-framework/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263157303,"owners_count":23422592,"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-09T18:29:00.388Z","updated_at":"2025-07-02T14:36:07.505Z","avatar_url":"https://github.com/frc.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# frc-wp-framework\nFrantic WP Framework. Experimental features and other helpers to aid development.\n\nUnder heavy development.\n**DO NOT USE YET.**\n\n# Table of contents\n\n* [Custom post type system](#custom-post-type-system)\n* [Component system](#component-system)\n* [Helper functions](#helper-functions)\n\n\n\n# Instructions\n\n## Requirements\n\n* PHP 7.1\n* Advanced custom fields (and pro to use the component system as it is based on the flexible field type)\n\n## Introduction\n\nThe FRC WP Framework consists of multiple different systems. They are:\n\n* Custom post type definition system\n* Component system for the custom post type\n* Normal wp_post and wp_query wrappers for caching and easy of use purposes.\n* Random helpers:\n    * Caching helpers\n    * Rendering helpers\n    * Other stuff...\n\n## Custom post type system\n\nThe custom post type system is made for the ease of just describing your custom post type in php class form. It includes the posts acf_fields and categories etc.\n\nA custom post type can be created by creating a directory for the custom post types and creating a file there and class in the file with the same name (in this example `My_Custom_Post_Type.php`) and then then registering the custom post types directory. \n\nFor example under the themes -directory:\n\n```\n- your-theme/\n    |- inc/\n    |   |- custom-post-types/\n    |       |- My_Custom_Post_Type.php\n    |- style.css\n    |- functions.php\n    |- index.php\n\n```\n\nAnd in the `My_Custom_Post_type.php` you add:\n```\nclass My_Custom_Post_Type inherits FRC\\Post_Base_Class {\n\n}\n```\nAfter that you add in in the `functions.php` -file:\n```\nFRC\\register_custom_post_types_folder(get_stylesheet_directory() . '/inc/custom-post-types');\n```\n\nThat's it. You've got a custom post types folder registered and one custom post type. It doesn't contain anything that interesting, but it is a basic run of the mill post -like post type.\n\nYou can add more post types by just creating a `.php` -file under the `custom-post-types` -folder and creating the appropriate class inside it.\n\nYou can use these objects just like regular WP_Post objects. These objects are fetched with the `FRC\\get_post()` -helper function. Like so:\n\n```\n$post = FRC\\get_post($post_id);\n\necho $post-\u003eID;\n```\n\nNow that post type has been created. You can define some schemas to it. You can assign taxonomies for the custom post type.\n\nLike so:\n```\nclass My_Custom_Post_Type inherits FRC\\Post_Base_Class {\n    public $taxonomies = [\n        'my_custom_taxonomy',\n        'another_my_custom_taxonomy'\n    ];\n}\n```\n\nIf you want to define more specifically the taxonomys arguments you can just:\n```\n... \n\npublic $taxonomies = [\n    'my_custom_taxonomy',\n    'another_my_custom_taxonomy' =\u003e [\n        'hierarchical' =\u003e true,\n\n        ...\n\n        additional arguments here\n    ]\n];\n\n...\n```\nThese arguments follow the basic wordpress [register_taxonomy](https://codex.wordpress.org/Function_Reference/register_taxonomy) functions arguments. There are default values preset all the time and these arguments just overwrite those in the defaut arguments.\n\nYou can also define similiarly the [register_post_type](https://codex.wordpress.org/Function_Reference/register_post_type) arguments with the `$args` -member:\n```\nclass My_Custom_Post_Type inherits FRC\\Post_Base_Class {\n    public $args = [\n        'description' =\u003e 'Description here',\n        'has_archive' =\u003e true,\n\n        ...\n\n        additional arguments here\n    ];\n}\n```\n\nSimiliarly these arguments also just overwrite the default ones.\n\nCustom post types also has the ability to define ACF fields to be defined in the schema. Those can be defined by defining the `$acf_schema` -member in the class The schema follows the `acf_add_local_field_group`'s field -arguments.\n\nLike so:\n```\nclass My_Custom_Post_Type inherits FRC\\Post_Base_Class {\n    public $acf_schema = [\n        [\n            'name' =\u003e 'a_field',\n            'lable' =\u003e 'This is the label',\n            'type' =\u003e 'text'\n        ],\n        [\n            'name' =\u003e 'another_name_field',\n            'lable' =\u003e 'This is the label of the second field',\n            'type' =\u003e 'text'\n        ],\n\n        ...\n\n        additional arguments here\n    ];\n}\n```\n\nThese fields appear in the custom post types add/edit page instantly. If you want some more fine tuned control, you can just define the `$acf_schema_groups` -member. This will go to the `acf_add_local_field_group` -function as is and it will overwrite the usage of `$acf_schema`.\n\nYou can also call `save()` -member functions to save the post data and the changed ACF field values.\n\nThe Custom post types also have some member functions that are called in different phases. For instance:\n`saved()` -function is called when ever `save()` -method has been called.\n\nThe custom post type event member functions are:\n* `init()` (Called after the custom post type object has been initialized)\n* `prepared()` (Called after the custom post type objects preparing phase is done)\n* `saved()` (Called whenever `save()` has been called)\n\nThese event member functions can be used to add additional functionality to the post type class.\n\nMisc:\n* Optionally you can define the `$included_acf_fields` -member to hold all the `acf_schema` field names that the post object loads up in when the object is loaded.\n* `$served_from_cache` -member is defined true or false when the object is retrieved from cache. You can use this for debugging.\n\nThere is also a `$cache_options` -member in the base class. You can overwrite these to suit your caching needs:\n```\npublic $cache_options = [\n    'cache_whole_object'    =\u003e true,\n    'cache_acf_fields'      =\u003e true,\n    'cache_categories'      =\u003e true,\n    'cache_component_list'  =\u003e true,\n    'cache_components'      =\u003e false\n];\n```\n\n## Component system\n\n...\n\n## Helper functions\n\n...","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrc%2Ffrc-wp-framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrc%2Ffrc-wp-framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrc%2Ffrc-wp-framework/lists"}