Skip to content

Instantly share code, notes, and snippets.

View ajvillegas's full-sized avatar

Alexis J. Villegas ajvillegas

View GitHub Profile
@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 <alexis@ajvillegas.com>
* @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.
*
@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 / remove-taxonomy-meta-box.php
Last active February 16, 2022 19:44
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 November 17, 2022 14:33 — 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 / 01-custom-block.js
Last active October 19, 2023 11:52
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 / 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 {