Skip to content

Instantly share code, notes, and snippets.

@Christian-Roth
Christian-Roth / WP-custom_allowed_blocks.php
Last active February 11, 2022 09:05
Remove all blocks from the theme category. Useful if you use the WP Block Editor but not a Full Site Editing Theme.
<?php /* Remove all blocks from the theme category */
function custom_allowed_block_types ( $allowed_block_types, $block_editor_context ) {
$block_types = WP_Block_Type_Registry::get_instance()->get_all_registered();
if (!empty($block_types)) {
$allowed_block_types = array();
foreach ($block_types as $key => $value) {
if ($value->category != 'theme') {
$allowed_block_types[] = $key;
@Christian-Roth
Christian-Roth / tribe_activate_ics_export_on_single_events.php
Last active October 24, 2023 11:45
The Events Calendar – Show ics export link on single events
<?php
/* Classic Editor: Activate ics links */
add_filter( 'tec_views_v2_subscribe_link_ics_visibility', '__return_true', 20 );
/* Classic Editor: Make ics link first item in dropdown */
add_filter( 'tec_views_v2_subscribe_links', function ($links) {
if (isset($links['ics']) && is_singular( 'tribe_events' )) {
$links = array_merge(['ics' => $links['ics']], $links);
}
@Christian-Roth
Christian-Roth / ACF_disable_cpts_taxonomies_options.php
Last active January 26, 2024 09:12
Removes the admin menu for CPTs, Taxonomies or Options Pages in ACF
<?php
/* Disable CPTs und Taxomies in ACF and ACF PRO */
add_filter( 'acf/settings/enable_post_types', '__return_false' );
/* Disable Options Pages in ACF PRO */
add_filter( 'acf/settings/enable_options_pages_ui', '__return_false' );
/* Disable Options Pages in ACF */
add_action( 'admin_init', function () {
remove_submenu_page( 'edit.php?post_type=acf-field-group', 'acf_options_preview' );
@Christian-Roth
Christian-Roth / WP-disable-block-pattern-submenu.php
Created April 3, 2024 10:42
Removes the block pattern submenu item if you are using the classic editor
/* Remove Block Pattern Submenu */
add_action( 'admin_init', function () {
remove_submenu_page( 'themes.php', 'edit.php?post_type=wp_block' );
}, 99 );