Skip to content

Instantly share code, notes, and snippets.

View ajvillegas's full-sized avatar

Alexis J. Villegas ajvillegas

View GitHub Profile
@ajvillegas
ajvillegas / 1. Building PHP-MAMP on Apple Silicon M1.md
Created February 25, 2025 15:28 — forked from lennardv2/1. Building PHP-MAMP on Apple Silicon M1.md
Native PHP development / MAMP stack on Apple silicon M1

Building the MAMP stack (php, apache & mysql) on Apple Silicon ARM (native)

Update! This tutorial is outdated. Nowadays brew installes m1 binaries just fine. Also use valet: https://laravel.com/docs/9.x/valet. It's 10x easier.

In this tutorial, we'll build the the nescessary packages for ARM via homebrew. After that we'll configure apache2 for using virtual hosts. The native php is ofcourse way faster, see the results of this benchmark below.

TEST NAME SECONDS OP/SEC
@ajvillegas
ajvillegas / style.css
Created November 14, 2023 18:44
Wide and Full-Width Alignment in WP
/* Break out of a container in a WP site. */
/* Exclude blocks in the editor. */
.alignfull:not(.wp-block) {
margin-left: calc( 50% - 50vw );
margin-right: calc( 50% - 50vw );
max-width: 100vw;
}
.alignwide {
@ajvillegas
ajvillegas / remove-taxonomy-meta-box.php
Last active December 14, 2024 03:37
Remove Taxonomy Meta Box from Edit Screen
<?php
function register_custom_taxonomy() {
$taxonomy_labels = [
'name' => esc_html__( 'Custom Terms', 'text-domain' ),
'singular_name' => esc_html__( 'Custom Term', 'text-domain' ),
'menu_name' => esc_html__( 'Terms', 'text-domain' ),
];
$taxonomy_args = [
@ajvillegas
ajvillegas / how-i-work.md
Last active April 25, 2024 11:56 — forked from jazzsequence/how-i-work-template.md
How I Like to Work

How I work

¡Hola! I'm Alexis, a Web Engineer at Human Made working from San Sebastián, Puerto Rico 🇵🇷 in the Caribbean.

This document goes over how I like to work and how I manage my energy to be most productive. Feedback is always welcome, specially if we work together or collaborate on projects.

When I work

I live in the Caribbean, within the Atlantic Standard Timezone (GMT-4) throughout the year, with no Daylight Saving Time.

Setting Up WordPress Coding Standards with VSCode

Install WordPress Coding Standards (WPCS)

First, make sure you have Composer installed in your system.

In order to use the WPCS you'll need the PHP_CodeSniffer (PHPCS) and the WPCS rules (sniffs) installed.

You can install PHP_CodeSniffer globally using Composer by running this command:

@ajvillegas
ajvillegas / password-protect-posts.php
Last active February 9, 2021 15:45
Password protect posts in WordPress programmatically.
<?php
add_action( 'the_post', 'myprefix_password_protect_post_type' );
/**
* Add master password to post type.
*
* This function password protects all posts in
* a post type with the same master password.
*
* @since 1.0.0
@ajvillegas
ajvillegas / 01-custom-block.js
Last active December 14, 2024 02:17
Sample custom WordPress editor block and sidebar controls using using ES5 JavaScript syntax.
/**
* Custom WordPress block boilerplate.
*
* @package My_Block_Package
* @author Alexis J. Villegas
* @link http://www.alexisvillegas.com
* @license GPL-2.0+
*/
( function( blocks, editor, element ) {
@ajvillegas
ajvillegas / display-attachment-details.php
Created May 10, 2017 23:25
Illustrates how to display attachments using data extracted from wp_prepare_attachment_for_js().
<?php
/**
* Illustrates how to display a basic list of attachments when using data extracted
* from the wp_prepare_attachment_for_js() array.
*
* @author Alexis J. Villegas <[email protected]>
* @link https://developer.wordpress.org/reference/functions/wp_prepare_attachment_for_js/
*/
@ajvillegas
ajvillegas / get-attachment-details.php
Last active August 12, 2018 04:12
Illustrates how to extract attachment details returned by wp_prepare_attachment_for_js().
<?php
/**
* Illustrates how to extract attachment details returned by wp_prepare_attachment_for_js().
*
* The wp_prepare_attachment_for_js() function returns an array with the attachment post object
* that can be used to extract specific information for the attachment.
*
* Following is a list of all the details that the function returns extrated into individual variables.
*