Skip to content

Instantly share code, notes, and snippets.

View Jehu's full-sized avatar

Marco Michely Jehu

View GitHub Profile
@Jehu
Jehu / function.php
Created August 9, 2023 08:36
Load ACSS in Gutenberg
<?php
// Load ACSS Gutenberg editor styles
function mwe_acss_gutenberg_styles() {
$url = site_url( '/wp-content/uploads/automatic-css/');
wp_enqueue_style( 'mwe-acss-gutenberg', $url . 'automatic-gutenberg-editor.css', false, '1.0', 'all' );
}
add_action( 'enqueue_block_editor_assets', 'mwe_acss_gutenberg_styles' );
@Jehu
Jehu / function.php
Created August 21, 2023 13:30
filter Bricks term query for custom taxonomy tag
<?php
// Include only terms where posts do have a term from custom 'hersteller' taxonomy
add_filter(
"bricks/terms/query_vars",
function ($query_vars, $settings, $element_id) {
if ($element_id !== "qaajzi") {
return $query_vars;
}
@Jehu
Jehu / function.php
Last active September 13, 2023 14:10
WordPress: set category menu active on post single page
<?php
/**
* helper function to test if post is in subcategory
*/
if (!function_exists("mwe_is_in_subcategory")) {
function mwe_is_in_subcategory($categories, $_post = null)
{
foreach ((array) $categories as $category) {
$subcats = get_term_children((int) $category, "category");
@Jehu
Jehu / anker-active.js
Created June 4, 2024 08:49
Add CSS Class 'active' to navigation anker links
const updateActiveEl = (list) => {
if (!list) return;
var hash = window.location.hash;
if (!hash) {
let first = list.querySelector("a");
if (first) {
first.classList.add("active");
}
return;
}
@Jehu
Jehu / bicks-code-signing.php
Last active August 8, 2024 17:55
wp-cli Bricks Code Signing - save in mu-plugins folder
<?php
namespace Bricks;
class MWE_BRICKS_SIGN_CODE
{
public function __construct() {
if (defined('WP_CLI') && WP_CLI) {
// https://make.wordpress.org/cli/handbook/references/internal-api/wp-cli-add-command/
\WP_CLI::add_command('bricks', '\Bricks\MWE_BRICKS_SIGN_CODE');
}
@Jehu
Jehu / splide-with-custom-pagination.js
Last active October 8, 2024 09:00
Splide with custom pagination that only shows that many dots
/**
* Show only MAX_DOTS in Splide Pagination.
*
* This code generates a custom pagination.
* Therefore you need to disable the Splide pagination with the option `pagination: false`.
* You can configure the number of visible pagination dots via MAX_DOTS.
* The active dot is moved from left to right and starts at the left if the end of
* MAX_DOTS is reached. So the user can see that there is something happen when using the Slider.
*/