Skip to content

Instantly share code, notes, and snippets.

@nicmare
nicmare / blc-layout-themejson-filter.php
Last active September 28, 2022 09:43
use theme.json along with Blocksy Customizer Content Width settings
<?php
function blocksy_layout_update($editor_settings, $block_editor_context){
// default values:
$editor_settings["__experimentalFeatures"]["layout"]["contentSize"] = "var(--has-wide, var(--block-max-width))";
$editor_settings["__experimentalFeatures"]["layout"]["wideSize"] = "calc(var(--block-max-width) + 260px)";
// maybe add offset values:
if($mods = get_theme_mods())
if(isset($mods["wideOffset"]))
$editor_settings["__experimentalFeatures"]["layout"]["wideSize"] = "calc(var(--block-max-width) + ".($mods["wideOffset"]*2)."px)";
return $editor_settings;
<?php
echo do_shortcode("[borlabs-cookie id='youtube' type='content-blocker'][youtubeplayer id=".$inhalt["ytid"]."][/borlabs-cookie]");
?>
<?php
// conditionally load sal.js assets
function lmdm_animation_scripts(){
if(is_singular()) {
$blocks = parse_blocks(do_shortcode(get_post(get_the_ID())->post_content));
if(is_array($blocks)){
foreach($blocks as $block){
if(isset($block["attrs"]["effect"]) && !empty($block["attrs"]["effect"])){
wp_enqueue_style('saljs-style', get_stylesheet_directory() . '_js/saljs/sal.css');
wp_enqueue_script('lmdm-saljs', get_stylesheet_directory() . '_js/saljs/sal.js', null, "1.0");
@nicmare
nicmare / add-blocksy-bodyclasses.php
Last active December 13, 2022 14:22
checks if header and/or footer is disabled on page and adds a body class
<?php
function add_blocksy_bodyclasses($classes){
if($blocksy = get_post_meta(get_the_ID(),"blocksy_post_meta_options",true)){
if(isset($blocksy["disable_header"]) && $blocksy["disable_header"] == "yes")
$classes[] = "blocksy-header-disabled";
if(isset($blocksy["disable_footer"]) && $blocksy["disable_footer"] == "yes")
$classes[] = "blocksy-footer-disabled";
}
return $classes;
<?php
function editor_font_sizes($unitOnly = false, $lineHeightOnly = false){
if($rootFont = get_theme_mod("rootTypography")){
$rootFontSize = "16px";
$rootLineHeight = 1.3;
if(isset($rootFont["size"]["desktop"]))
$rootFontSize = $rootFont["size"]["desktop"];
@nicmare
nicmare / acf-getfield-shortcode.php
Last active January 30, 2023 06:31
simple function to place acf field values where ever needed in content
<?php
function acf_get_field_shortcode($args = array()){
if(!function_exists("get_field")) return "";
$field = (isset($args["field"]) && !empty($args["field"]))?get_field($args["field"]):false;
if($field) return $field;
return "";
}
add_shortcode("acf_get_field","acf_get_field_shortcode");
@nicmare
nicmare / blocksy-ajax-search.php
Last active February 1, 2024 10:19
This Code Snippet modifies the Wordpress Search Terms
<?php
function search_replacement($term){
return ltrim(str_replace( array('0x'), array('0 x '), urldecode(strtolower($term)) ));
}
// ajax search:
function replace_search( $query_object )
{
if( $query_object->is_search() ) {
$raw_search = $query_object->query['s'];