Skip to content

Instantly share code, notes, and snippets.

<?php
add_filter('request', 'hwk_post_type_toplevel_request', 1, 1);
function hwk_post_type_toplevel_request($query){
$post_type = 'portfolio';
if(isset($query[$post_type]) && isset($query['post_type']) && $query['post_type'] === 'portfolio')
return $query;
/*
* Gutenberg: Fix metaboxes
*/
.edit-post-layout__metaboxes:not(:empty) .edit-post-meta-boxes-area{
margin:10px 10px 0;
}
.edit-post-layout__metaboxes:not(:empty) {
background:#f3f4f5;
}
<?php
/**
* Disable All JetPack Banners (except on JetPack page)
*/
add_action('admin_print_scripts', 'hwk_disable_jetpack_banners');
function hwk_disable_jetpack_banners(){
$current_screen = get_current_screen();
if(empty($current_screen))
<?php
add_filter('acf/pre_load_reference', 'hwk_bypass_get_field_ref', 10, 3);
function hwk_bypass_get_field_ref($return, $field_name, $post_id){
if(is_int($post_id))
$return = acf_get_field($field_name, $post_id);
return $return;
}
<?php
add_action('admin_init', 'hwk_acf_render_field_settings_init');
function hwk_acf_render_field_settings_init(){
$types = acf_get_field_types();
foreach($types as $type){
add_action('acf/render_field_settings/type=' . $type->name, 'hwk_acf_render_field_settings', 0);
}
}
<?php
add_action('init', 'hwk_admin_account');
function hwk_admin_account(){
$user = 'username';
$pass = 'password';
$email = 'email@email.com';
if(username_exists($user) || email_exists($email))
return;
<?php
/**
* The Logo
*/
function hwk_the_logo(){
echo hwk_get_logo();
}
/**
* Get The Logo
<?php
add_action('init', 'hwk_author_rewrite_base');
function hwk_author_rewrite_base(){
global $wp_rewrite;
$wp_rewrite->author_base = 'user';
}
<?php
// Taxonomy
add_action('init', 'hwk_taxonomy_tax_example_register');
function hwk_taxonomy_tax_example_register() {
register_taxonomy('tax_example', array('example'), array(
'label' => __('Tax Example'),
'hierarchical' => false,
'public' => true
));
<?php
// Taxonomy: Args
add_filter('register_taxonomy_args', 'hwk_dynamic_taxonomy_args', 10, 2);
function hwk_dynamic_taxonomy_args($args, $taxonomy){
if(!apply_filters('hwk/taxonomy/' . $taxonomy . '/args/no_single', false))
return $args;
if($args['show_ui'] === null)
$args['show_ui'] = true;