Skip to content

Instantly share code, notes, and snippets.

View elpuas's full-sized avatar
💻
coding

Alfredo Navas-Fernandini elpuas

💻
coding
View GitHub Profile

General Cursor Rules

You are an expert software engineer with extensive experience across multiple domains, programming languages, and frameworks.

When assisting with code:

  • Prioritize clean, efficient, and maintainable code.
  • Follow best practices and design patterns appropriate for the language and project.
  • Provide clear, concise explanations for your code suggestions.
  • Consider performance, scalability, and security in your implementations.

Modern WordPress Full-Site Development Best Practices

Dependencies & Build Tools

  • Use modern PHP & Node: Develop with PHP 8.2+ and Node (for build scripts), to leverage latest features and performance . Add declare(strict_types=1); at the top of PHP files to enforce strict typing (catching type errors early).
  • Composer for autoloading: Manage PHP libraries with Composer and use PSR-4 autoloading to load classes automatically (avoids manual require_once calls)
  • Keep your plugin/theme’s custom classes under a namespace and let Composer handle loading them.
  • Leverage WP-CLI scaffolding: Use official tools like wp create-block (or npx @wordpress/create-block) to scaffold block plugins. It generates all necessary PHP, JS, and CSS files plus a no-config build setup .
  • Use @wordpress/scripts: Rely on the wp-scripts build tool (part of @wordpress/scripts) for bundling and transpiling modern JS. It comes pre-configured with webpack and Babel for ES6+ and JSX, so you can write modern JS/React withou
@elpuas
elpuas / gist:fcc52a668b440682c38fb6fc1a7c0bda
Created March 3, 2025 13:48
Need a specific WordPress or PHP version?
npx @wp-now/wp-now start --wp=6.4 --php=8.0
@elpuas
elpuas / gist:715af927956bd042fb5940af9124cf5a
Created March 3, 2025 13:47
Start WordPress on Your Browser
npx @wp-now/wp-now start
@elpuas
elpuas / set-get-cookies.js
Created January 9, 2023 16:41
Set and Get Cookies
/**
* Set a cookie
*
* @param {string} name - The name of the cookie.
* @param {string} value - The value of the cookie.
* @param {number} [days] - The number of days until the cookie expires.
*/
const setCookie = ( name, value, days ) => {
let expires = '';
if ( days ) {
@elpuas
elpuas / flip-cards.css
Last active December 29, 2022 14:53
Flip Cards CSS
.lp-flip-cards {
max-width: var(--wp--style--global--content-size);
margin: 0 auto;
}
.lp-flip-cards .wp-block-post-template .wp-block-post .lp-flip-card {
perspective: 1000px;
height: 320px;
}
@elpuas
elpuas / flip-cards-html.html
Created December 29, 2022 14:50
Flip Cards HTML
<!-- wp:query {"queryId":0,"query":{"perPage":3,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false},"tagName":"section","namespace":"loop-patterns/flip-cards","className":"lp-flip-cards"} -->
@elpuas
elpuas / @flip-cards-innerblocks.js
Created December 29, 2022 14:47
Inner Blocks Flip Cards
innerBlocks: [
[
'core/post-template',
{
lock: 'all',
className: 'lp-flip-card__card is-flex-container columns-3',
},
[
['core/group', {
className: 'lp-flip-card'
@elpuas
elpuas / @query-flip-cards.js
Created December 29, 2022 14:43
Flip Cards Variations
const FLIP_CARDS = 'loop-patterns/flip-cards';
wp.domReady( function() {
wp.blocks.registerBlockVariation( 'core/query', {
name: FLIP_CARDS,
title: 'Flip Cards',
description: 'Flip Cards Query',
isActive: ( { namespace, query } ) => {
return (
namespace === FLIP_CARDS
@elpuas
elpuas / @query-loop-register.js
Created December 29, 2022 14:41
register the block variation
import './simple-query';