carawebs / wp-helpers
This package provides Wordpress housekeeping & helper functions.
1.0.0
2017-03-21 20:52 UTC
This package is auto-updated.
Last update: 2024-11-22 00:12:27 UTC
README
Odds and sods that are useful on most projects.
This library is in development and I may introduce breaking changes.
// Within theme /** * Run themehelper setup */ add_action('after_setup_theme', function() { // Apply Themehelper functions - basic housekeeping if (class_exists('\Carawebs\Helpers\Functions')) { $args = []; new \Carawebs\Helpers\Functions( $args ); } });
Menu Adjustment for Custom Post Type Views
Define the CPTs, menus and menu items to target from within the active theme.
Use the format $keyvals['custom-post-type-slug'] => ['class'=>'menu-class-of-parent', 'text'=>'Text val of parent menu item'];
// Define the custom post type view and the required parent menu item: add_filter( 'carawebs/amend-menu-cpts-target-cpts', function($keyvals) { $keyvals['service'] = ['class' => 'services', 'text' => 'Services']; return $keyvals; });
Define an array of menu locations for which the amendments should apply using the 'carawebs/amend-menu-cpts-target-locations' hook:
add_filter( 'carawebs/amend-menu-cpts-target-locations', function() { return ['primary_navigation']; });