Skip to content

Instantly share code, notes, and snippets.

@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 );
@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-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_get_events_with_ongoing_events.php
Last active August 2, 2019 14:22
The Events Calendar – Show events with ongoing events. More date arguments in /src/Tribe/Query.php, around line 1285.
<?php // Retrieve all events (with ongoing events) in October 2019
$events = tribe_get_events( [
'eventDisplay' => 'custom',
'ends_after' => '2019-10-01 00:01',
'starts_before' => '2019-10-31 23:59',
] );
@Christian-Roth
Christian-Roth / WP-cookies-not-accepted-shortcode.php
Last active July 8, 2018 13:28
A shortcode to show content if cookies are not accepted
<?php /* Shortcode Cookie Not Accepted */
function custom_cn_cookies_not_accepted( $atts, $content = null ) {
if (function_exists('cn_cookies_accepted') && !cn_cookies_accepted()) {
return '<div class="box cookie-box">' . do_shortcode($content) . '</div>';
} else {
return '';
}
}
add_shortcode('cookies_not_accepted', 'custom_cn_cookies_not_accepted');
?>
@Christian-Roth
Christian-Roth / WP-cookie-status-shortcode.php
Last active July 8, 2018 09:32
A shortcode to show the cookie status
@Christian-Roth
Christian-Roth / stars-block.js
Created January 30, 2018 14:53 — forked from pento/stars-block.js
Gutenberg Stars Block
( function( blocks, element ) {
var el = element.createElement;
function Stars( { stars } ) {
return el( 'div', { key: 'stars' },
'★'.repeat( stars ),
( ( stars * 2 ) % 2 ) ? '½' : '' );
}
blocks.registerBlockType( 'stars/stars-block', {
@Christian-Roth
Christian-Roth / tribe_remove_archive_ical_links.php
Last active October 13, 2017 15:39
The Events Calendar – Remove the iCal and Google cal links from the archive views
@Christian-Roth
Christian-Roth / tribe_remove_single_calendar_links.php
Created October 13, 2017 15:30 — forked from elimn/tribe_remove_single_calendar_links.php
MT | TEC | Remove the iCal and Google cal links from the single event page