Created
August 22, 2020 22:20
-
-
Save JMWebDevelopment/f2f1a5a5ac25135e3b6e1b517744926f to your computer and use it in GitHub Desktop.
/inc/Categories/Component.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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