/** * Filter the sidebar status on AudioTheme archives and singular posts. * * @since 1.0.0 * * @param bool $is_active_sidebar Whether the sidebar is active. * @param string $index The sidebar id. * @return bool */ function huesos_audiotheme_sidebar_status($is_active_sidebar, $index) { if ('sidebar-1' !== $index || !$is_active_sidebar) { return $is_active_sidebar; } $post_type = get_post_type(); if (is_audiotheme_post_type_archive()) { $archive_post_type = get_audiotheme_post_type_archive(); } elseif (is_singular() && 0 === strpos($post_type, 'audiotheme_')) { $archive_post_type = 'audiotheme_track' === $post_type ? 'audiotheme_record' : $post_type; } elseif (is_tax('audiotheme_record_type')) { $archive_post_type = 'audiotheme_record'; } elseif (is_tax('audiotheme_video_category')) { $archive_post_type = 'audiotheme_video'; } if (!empty($archive_post_type)) { $is_active_sidebar = 'enabled' === get_audiotheme_archive_meta('huesos_sidebar', true, 'enabled', $archive_post_type); } return $is_active_sidebar; }
/** * Provide an edit link for archives in the admin bar. * * @since 1.2.1 * * @param WP_Admin_Bar $wp_admin_bar Admin bar object instance. */ function audiotheme_archives_admin_bar_edit_menu($wp_admin_bar) { if (!is_admin() && is_audiotheme_post_type_archive()) { $id = get_audiotheme_post_type_archive(); $post_type_object = get_post_type_object(get_post_type($id)); if (empty($post_type_object)) { return; } $wp_admin_bar->add_menu(array('id' => 'edit', 'title' => $post_type_object->labels->edit_item, 'href' => get_edit_post_link($id))); } }