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
Last active April 28, 2025 00:17
Styles for the provided mockup
/**
*
* Styles matching the provided website mockup.
*
* NOTES:
* – We'll use WP's native custom properties wherever possible.
* – The usage of `!important`, although a bad practice, is unavoidable in the situations it was used.
*/
/* Define custom properties where there's no equivalent in WordPress. */
@pagelab
pagelab / multisite.branda.2025-04-27.1745721211.json
Created April 27, 2025 02:54
Branda site status page settings
{
"name": "Branda",
"url": "https:\/\/wpmudev.com\/plugins\/ultimate-branding",
"version": "3.4.23",
"timestamp": 1745721211,
"date": "2025-04-27T02:33:31+00:00",
"activate_module": {
"front-end\/site-status-page.php": "yes"
},
"modules": {
@pagelab
pagelab / taxonomy-registration.php
Created April 26, 2025 02:55
Custom taxonomy registration code for the “Books” Custom Post Type.
<?php // Ignore this line if your functions.php already include it.
function register_book_author_taxonomy() {
$labels = array(
'name' => 'Book Authors',
'singular_name' => 'Book Author',
'menu_name' => 'Book Authors',
'all_items' => 'All Book Authors',
'edit_item' => 'Edit Book Author',
'view_item' => 'View Book Author',
'update_item' => 'Update Book Author',
@pagelab
pagelab / shortcode-fix.php
Created April 26, 2025 02:06
New shortcode with corrections.
<?php
// Add Shortcode
function subform() {
// Get the current user
$current_user = wp_get_current_user();
// Check if user is logged in and get the nickname
if ($current_user->exists()) {
$user_display_name = $current_user->nickname;
// If nickname is empty, fall back to display_name
@pagelab
pagelab / latest-and-oldest-posts.html
Created April 25, 2025 21:31
Latest and Oldest post WordPress block pattern (for Sarah)
<!-- wp:group {"layout":{"type":"default"}} -->
<div class="wp-block-group"><!-- wp:columns -->
<div class="wp-block-columns"><!-- wp:column -->
<div class="wp-block-column"><!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Latest Posts</h3>
<!-- /wp:heading -->
<!-- wp:query {"queryId":28,"query":{"perPage":5,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false},"metadata":{"categories":["posts"],"patternName":"core/query-small-posts","name":"Small image and title"}} -->
<div class="wp-block-query"><!-- wp:post-template -->
<!-- wp:columns {"verticalAlignment":"center","style":{"color":{"background":"#f6ffeb"}}} -->
@pagelab
pagelab / Save.php
Created December 13, 2024 18:28 — forked from lucprincen/Save.php
Saves a WordPress FSE pattern on the local environment.
<?php
namespace WotW\Theme\Patterns;
use WotW\Theme\Contracts\Interfaces\Hookable;
class Save implements Hookable{
public function register_hooks(): void {
@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)) {