Skip to content

Instantly share code, notes, and snippets.

@nicmare
nicmare / functions.php
Created October 8, 2025 13:25
Make wordpress synced blocks public in rest api
<?php
// fetch block by name like this:
// https://…/wp-json/public/v1/reusable?slug=brunch-termine
add_action('rest_api_init', function () {
register_rest_route('public/v1','/reusable',[
'methods' => 'GET',
'args' => ['slug'=>['required'=>true]],
'permission_callback' => '__return_true',
'callback' => function(WP_REST_Request $r){
$slug = sanitize_title($r['slug']);
@nicmare
nicmare / functions.php
Last active October 7, 2025 13:19
Autoplay YT Video in Blocksy Popup
<?php
// attention! place your yt-video in html-block inside a blocksy popup like this:
// <iframe src="https://www.youtube.com/embed/LW0OVY9e5r0?enablejsapi=1&autoplay=1" class="yt-video" style="aspect-ratio:16/9" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
// this approach is also compatible with script blocker plugin "embed privacy" AND "complianz cookie consent". last one is mandatory!
function autoplay_yt_video_in_blocksy_popup(){
?>
<script>
document.addEventListener('DOMContentLoaded', function() {
ctEvents.on('blocksy:micro-popups:open', (popupId) => {
let video = document.querySelector("#post-"+popupId+" .yt-video");
@nicmare
nicmare / functions.php
Created October 1, 2025 11:58
Blocksy: Remove Links from custom post cards
<?php
function change_layer_from_card($layer,$prefix,$image_args){
if($prefix != "unterstuetzer_archive") return $layer;
$layer["featured_image"] = sprintf('<div class="ct-media-container">%s</div>',strip_tags($layer["featured_image"],"<img>"));
$layer["title"] = strip_tags($layer["title"],"<h2>");
return $layer;
}
add_filter('blocksy:archive:render-card-layers',"change_layer_from_card",10,3);
@nicmare
nicmare / functions.php
Last active September 26, 2025 13:19
blocksy: disable content block tools in wp admin bar
<?php
function disable_blocksy_hook_panel(){
$user = wp_get_current_user();
if(in_array("editor",$user->roles)) return false;
return true;
}
add_filter('blocksy:content-blocks:has-actions-debugger','disable_blocksy_hook_panel');
@nicmare
nicmare / style.css
Created September 19, 2025 12:23
Blocksy Theme: making default archive cards fully clickable
[data-archive="default"].entries article.entry-card {
position:relative;
}
[data-archive="default"].entries article.entry-card .entry-title > a::before {
position:absolute;
inset: 0;
content:"";
display:block;
z-index:10;
@nicmare
nicmare / style.css
Created September 19, 2025 12:02
Blocksy: disable theme button hover effect transform
// add the class to your button:
.no-btn-transform:hover {
--theme-button-transform: none;
}
@nicmare
nicmare / functions.php
Created September 4, 2025 09:25
Hide WP Armour Admin Menu
<?php
// hide wp armour menu from editor role
function remove_wpa_menu(){
if(!is_admin()) return;
if(current_user_can('editor'))
remove_action('admin_menu', 'wpa_plugin_menu');
}
add_action("wp_loaded",'remove_wpa_menu');
@nicmare
nicmare / functions.php
Created September 4, 2025 09:11
Remove WP Armour Scripts from Homepage
<?php
// unload wp armour honeypot assets due to jquery dependency
function remove_plugin_stuff_in_wp_loaded(){
if(is_front_page())
remove_action('wp_enqueue_scripts','wpa_load_scripts');
}
add_action('wp', 'remove_plugin_stuff_in_wp_loaded');
@nicmare
nicmare / functions.php
Last active August 1, 2025 09:16
Disable Blocksy Hero Section with Title and Vertical Top Space based upon a term assignment
<?php
// disable page title and top spacing when assigned to "schwebende navigation" term of taxonomy "page_props":
function disable_blocksy_hero_section($value){
global $post;
if(!$post->ID) return $value;
$post_options = blocksy_get_post_options($post->ID);
// turns out (for some reason) $post->ID is more reliable than $post_id in certain cases!
if($p_terms = get_the_terms( $post->ID, 'page_props' )){
@nicmare
nicmare / functions.php
Created July 30, 2025 08:30
Change Blocksy Vertical Spacing based on taxonomy term
<?php
function change_blocksy_vertical_spacing($v_spacing_components){
global $post;
if($p_terms = get_the_terms( $post->ID, 'page_props' )){ // change "page_props" to your custom taxonomy name
if ( ! is_wp_error( $p_terms ) ) {
if(in_array("schwebende-navigation",array_column($p_terms,"slug"))){ // change "schwebende-navigation" to your term name
if (($key = array_search("top", $v_spacing_components)) !== false) {
unset($v_spacing_components[$key]);
}
}