Files
Portfolio-2026/lib/class-resources.php
T
Keith SolomonandClaude Opus 4.7 e2f6270717 Release as SoloFrame Evo (#2)
* docs: Add onboarding documentation for new developers

Add four comprehensive guides to help new developers get started
with the VDI-Starter-v5 WordPress theme:

- docs/getting-started.md: Setup from zero, local WordPress options,
  env config, theme activation warnings, troubleshooting
- docs/architecture.md: Bootstrap flow, 7 architectural layers,
  namespace conventions, WP hooks cleanup, enqueue system, theme.json
- docs/creating-blocks.md: Step-by-step ACF block creation tutorial,
  helper functions, parent-child patterns, Tailwind integration
- docs/reference.md: Hooks/filters tables, design tokens, CSS import
  tree, JS module graph, class reference, CLI commands, deployment

Update README.md: trim deep-dive API docs (moved to reference),
add documentation links section, fix CSS paths (views/styles/ →
styles/), add missing contact-info block, fix deployment filename
typo (wpengine,yml → wpengine.yml), add backToTop.js and
enqEditorAssets(), add namespace conventions table.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* docs: language graph

* docs: Update readme

* 🔵 other: Rename project and publish

* 🔵 other: Update .gitignore
2026-07-29 15:52:21 -05:00

130 lines
3.7 KiB
PHP

<?php
/**
* Resources custom post type & taxonomies
*
* @package SoloFrameEvo
* @since 1.0.0
*/
namespace SoloFrameEvo;
/**
* Class Resources
*
* This class is responsible for setting up the Resources post type and taxonomies.
*
* @package Basic-WP
*/
class Resources {
/**
* Constructor for the class.
*
* Initializes the class and sets up any necessary properties or methods.
*/
public function __construct() {
add_action( 'init', array( $this, 'registerPostType' ) );
add_action( 'init', array( $this, 'registerTaxonomy' ) );
add_filter( 'post_type_link', array( $this, 'postTypeLink' ), 10, 2 );
}
/**
* Registers a custom post type.
*
* This method is responsible for defining and registering a custom post type
* with WordPress. It should include all necessary arguments and labels
* required for the post type to function correctly.
*
* @return void
*/
public function registerPostType() {
register_post_type(
'resources',
array(
'labels' => array(
'name' => 'Resources',
'singular_name' => 'Resource',
'menu_name' => 'Resources',
'name_admin_bar' => 'Resource',
'add_new' => 'Add New Resource',
'add_new_item' => 'Add New Resource',
'edit_item' => 'Edit Resource',
'new_item' => 'New Resource',
'view_item' => 'View Resource',
'search_items' => 'Search Resources',
'not_found' => 'No resources found',
'not_found_in_trash' => 'No resources found in Trash',
),
'public' => true,
'has_archive' => true,
'rewrite' => array( 'slug' => 'resources' ),
'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'revisions', 'custom-fields' ),
'menu_position' => 20,
'menu_icon' => 'dashicons-hammer',
'show_in_rest' => true,
)
);
}
/**
* Registers a custom taxonomy.
*
* This method is responsible for defining and registering a custom taxonomy
* within the WordPress environment. It should include the necessary arguments
* and settings for the taxonomy to function as intended.
*
* @return void
*/
public function registerTaxonomy() {
register_taxonomy(
'resource_type',
array( 'resources' ),
array(
'labels' => array(
'name' => 'Resource Types',
'singular_name' => 'Resource Type',
'search_items' => 'Search Resource Types',
'all_items' => 'All Resource Types',
'parent_item' => 'Parent Resource Type',
'parent_item_colon' => 'Parent Resource Type:',
'edit_item' => 'Edit Resource Type',
'update_item' => 'Update Resource Type',
'add_new_item' => 'Add New Resource Type',
'new_item_name' => 'New Resource Type Name',
'menu_name' => 'Resource Types',
),
'public' => true,
'hierarchical' => true,
'show_admin_column' => true,
'rewrite' => array(
'slug' => 'resources',
'with_front' => false,
'hierarchical' => true,
),
'show_in_rest' => true,
)
);
}
/**
* Filters the permalink for a post of a specific post type.
*
* @param string $post_link The post's permalink.
* @param WP_Post $post The post object.
* @return string The filtered post permalink.
*/
public function postTypeLink( $post_link, $post ) {
if ( 'resources' === $post->post_type ) {
$terms = get_the_terms( $post->ID, 'resource_type' );
if ( $terms && ! is_wp_error( $terms ) ) {
$term_slug = $terms[0]->slug;
return home_url( "resources/{$term_slug}/{$post->post_name}" );
}
}
return $post_link;
}
}
new Resources();