Skip to content

Instantly share code, notes, and snippets.

View pagelab's full-sized avatar
🚀

Márcio Duarte pagelab

🚀
View GitHub Profile
@pagelab
pagelab / style.css
Created October 18, 2024 17:15
Rankmath's breadcrumb style customization for the Toivo Lite theme.
/* Rankmath's breadcrumb style customization */
.layout-1c .rank-math-breadcrumb .wrap {
margin-left: auto;
margin-right: auto;
max-width: 1260px;
}
.rank-math-breadcrumb {
text-align: center;
font-size: 0.75em;
@pagelab
pagelab / auto-complete-virtual-orders.php
Created October 6, 2024 23:40
Plugin que realiza apenas uma função: conclui automaticamente pedidos de produtos virtuais quando o pagamento é confirmado.
<?php
/**
* Plugin Name: Auto Complete Virtual Orders
* Description: Conclui automaticamente pedidos de produtos virtuais quando o pagamento é confirmado.
* Version: 1.1
* Author: Seu Nome
* License: GPL2
*/
// Evita o acesso direto ao arquivo
@pagelab
pagelab / gist:476710c843324e63e694e9a6ed20628a
Created October 6, 2024 23:35 — forked from Acephalia/gist:873f1a6c13e842a8c62aa73a1b976231
Auto Complete Woocommerce Virtual Orders
// Auto-complete virtual orders if payment is completed by u/acephaliax
function auto_complete_virtual_orders($order_id) {
if (!$order_id) {
return;
}
// Get the order object
$order = wc_get_order($order_id);
// Check if the order contains virtual products
@pagelab
pagelab / bricks-mobile-dropdow-open-nav-nestable.html
Last active January 25, 2024 16:18
Bricks Builder: invert the default behaviour of the dropdown inside the Nav (nestable) element.
<script>
/**
* Nav (nestable) element.
* Invert the default behaviour of the dropdown inside the element.
* Toggles the submenu with two CSS classes (.show-sub-menu and .hide-sub-menu).
*/
// Utility function to add or remove classes from an element.
function toggleClass(element, className) {
if (element.classList.contains(className)) {
@pagelab
pagelab / bricks-mobile-dropdow-open-nav-element.html
Last active January 25, 2024 16:21
Bricks Builder: invert the default behaviour of the dropdown inside the Nav element (opened when the menu is clicked).
/* Nav element: change based on the breakpoint for the mobile menu. */
/* Note: change the `max-width` value to reflect the Nav element's breakpoint */
@media ( max-width: 768px ) {
.display-sub-menu {
display: block !important;
}
}
<script>
/**
@pagelab
pagelab / convert-css-variables-to-json.py
Last active June 22, 2024 12:34
Script to convert a list of CSS custom properties to the JSON format required by Advanced Themer to make them appear on the Bricks Builder fields (via the “V” symbol).
# Script to convert a list of CSS custom properties to the JSON format required by Advanced Themer to make them appear on the Bricks Builder fields (via the “V” symbol).
# 1. Add a file in a folder with all CSS variables from Core Framework called core-framework-css-variables.css, one per line. Group each section using CSS comments.
# 2. Run the python script to generate the JSON file for Advanced Themer: python3 convert-css-variables-to-json.py
# 3. Add the file to the “Import Framework” option of the Advanced Themer on Bricks → AT - Theme settints → Global CSS Variables → Import Framework.
import re
import json
# Read the CSS file
with open('core-framework-css-variables.css', 'r') as f:
css = f.readlines()
@pagelab
pagelab / auto-block-recovery.js
Created June 7, 2023 16:26 — forked from bfintal/auto-block-recovery.js
Encountering lots of broken blocks / block errors in WordPress Gutenberg? Paste this code in your browser developer console while editing your post to recover all the blocks at once.
var recursivelyRecoverInvalidBlockList = blocks => {
const _blocks = [ ...blocks ]
let recoveryCalled = false
const recursivelyRecoverBlocks = willRecoverBlocks => {
willRecoverBlocks.forEach( _block => {
if ( isInvalid( _block ) ) {
recoveryCalled = true
const newBlock = recoverBlock( _block )
for ( const key in newBlock ) {
_block[ key ] = newBlock[ key ]
@pagelab
pagelab / dicas.html
Created February 21, 2023 00:13
Caixa de dicas para o tema Épico utilizando o editor de blocos do WordPress
<!-- wp:group {"style":{"color":{"background":"#ffae0017"},"spacing":{"padding":{"top":"0","right":"0","bottom":"0","left":"0"}},"border":{"left":{"color":"#fcb90033","width":"8px"}}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group has-background" style="border-left-color:#fcb90033;border-left-width:8px;background-color:#ffae0017;padding-top:0;padding-right:0;padding-bottom:0;padding-left:0">
<!-- wp:columns {"isStackedOnMobile":false,"style":{"spacing":{"padding":{"top":"0px","right":"0px","bottom":"0px","left":"0px"},"blockGap":{"top":"0px","left":"0px"},"margin":{"top":"0px","bottom":"0px"}}}} -->
<div class="wp-block-columns is-not-stacked-on-mobile" style="margin-top:0px;margin-bottom:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px">
<!-- wp:column {"width":"40px","layout":{"type":"default"}} -->
<div class="wp-block-column" style="flex-basis:40px">
<!-- wp:image {"sizeSlug":"large","linkDestination":"none","className":"is-styl
@pagelab
pagelab / functions.php
Last active March 28, 2024 19:21
Add clickable anchor icons with links in all core/paragraph blocks.
<?php
namespace MyPlugin;
add_filter( 'render_block_core/heading', __NAMESPACE__ . '\\add_anchor_icon', 10, 2 );
/**
* Add clickable anchor icons to all core/paragragh blocks.
*
* @param string $block_content The block content about to be appended.
@pagelab
pagelab / functions.php
Last active August 20, 2022 04:10
Adding a class to external links in content blocks.
<?php
namespace MyPlugin;
// Adds a class to external links in content blocks.
add_filter( 'render_block', __NAMESPACE__ . '\\add_class_external_links', 10, 2 );
/**
* Adds a CSS class to external links in content blocks.
*