Skip to content

Instantly share code, notes, and snippets.

@JMWebDevelopment
Created August 22, 2020 22:20
Show Gist options
  • Save JMWebDevelopment/f2f1a5a5ac25135e3b6e1b517744926f to your computer and use it in GitHub Desktop.
Save JMWebDevelopment/f2f1a5a5ac25135e3b6e1b517744926f to your computer and use it in GitHub Desktop.
/inc/Categories/Component.php
<?php
/**
* WP_Rig\WP_Rig\Categories\Component class
*
* @package wp_rig
*
* This file should be inside your /inc/Categories directory.
*/
namespace WP_Rig\WP_Rig\Categories;
use WP_Rig\WP_Rig\Component_Interface;
use function WP_Rig\WP_Rig\wp_rig;
use function add_action;
use function add_filter;
/**
* Class for managing comments UI.
*/
class Component implements Component_Interface {
/**
* Gets the unique identifier for the theme component.
*
* @return string Component slug.
*/
public function get_slug() : string {
return 'categories';
}
/**
* Adds the action and filter hooks to integrate with WordPress.
*/
public function initialize() {
add_action( 'get_the_archive_title', [ $this, 'prefix_category_title' ] );
}
public function prefix_category_title( $title ) {
if ( is_category() ) {
$title = single_cat_title( '', false );
}
return $title;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment