carawebs/wp-helpers

此软件包提供Wordpress维护和辅助函数。

1.0.0 2017-03-21 20:52 UTC

This package is auto-updated.

Last update: 2024-09-21 23:50:48 UTC


README

大多数项目中都很有用的奇偶项。

此库正在开发中,我可能会引入破坏性更改。

// 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 );
    }

});

自定义帖子类型视图的菜单调整

定义CPTs、菜单和菜单项,以便从活动主题内部进行定位。使用格式$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;
});

使用“carawebs/amend-menu-cpts-target-locations”钩子定义应适用修正的菜单位置数组

add_filter( 'carawebs/amend-menu-cpts-target-locations', function() {
    return ['primary_navigation'];
});