Skip to content

Instantly share code, notes, and snippets.

View desrosj's full-sized avatar

Jonathan Desrosiers desrosj

View GitHub Profile
New Ways to Collaborate
Notes
Updates to Field API, DataViews and DataForms
Improved Editing Tools
Ability to Hide Blocks
Direct Drag and Drop
Iframe Integration in Post Editor
Streaming Block Parser
@desrosj
desrosj / esc_url-example.php
Last active November 17, 2025 18:15
Possible `esc_url()` code examples.
<?php
/*
* Recommended approach for defaulting to 'http' while maintaining backwards compatibility.
*
* Example: no protocol with $protocols and 'https' first.
*
* Output:
* - WordPress >= 6.9: 'https://profiles.wordpress.org'
* - WordPress < 6.9: 'http://profiles.wordpress.org'

Keybase proof

I hereby claim:

  • I am desrosj on github.
  • I am desrosj (https://keybase.io/desrosj) on keybase.
  • I have a public key ASCcyoOlEpHmjbVjg1hfC23m8cEwRIhJH8PrK9r0LJJR_wo

To claim this, I am signing this object:

@desrosj
desrosj / sync-wp-develop-fork.sh
Created October 21, 2024 18:20
Sync a wordpress-develop fork by pulling in upstream changes.
#!/bin/zsh
cd ~/Sites/wordpress-develop
nvm install
git reset --hard
git fetch --all
npm run grunt clean -- --dev
rm -rf node_modules
@desrosj
desrosj / update-svn-branches.sh
Last active October 21, 2024 18:15
Manages SVN checkouts for branches of wordpress-develop locally.
#!/bin/zsh
clean_update_local_branch() {
svn info
svn revert -R .
svn up
svn info
}
clean_up_npm() {
@desrosj
desrosj / perform-migration-from-svn-to-git.md
Created August 16, 2022 14:35
Migrate from Subersion (SVN) to Git

This is a fork of a file within ALM-Rangers/Guidance


title: Perform the migration from SVN to Git description: Explore how to migrate from SVN to Git ms.assetid: 0DBA5AC3-3065-45D7-974D-AF6E5D218BBF ms.prod: vs-devops-perform-migration-from-svn-to-git ms.technology: vs-devops-articles ms.manager: willys ms.date: 11/10/2017

@desrosj
desrosj / discord-icon-twenty-twenty-one.php
Created June 2, 2021 23:46
Adding a Discord icon to the Twenty Twenty-One theme
<?php
/**
* Add discord.com to the list of domains mapped to social icons.
*
* @param array $social_icons_map Array of default social icons.
* @return array Updated array of social icons.
*/
function mycode_social_icons_map( $social_icons_map ) {
$social_icons_map['discord'] = array(
@desrosj
desrosj / change-auto-update-state.php
Created February 2, 2021 14:30
A function for toggling auto-update state for WordPress plugins and themes.
<?php
/**
* Changes the auto-update status for plugins and themes.
*
* @param string $name The name of the plugin or theme to change the auto-update status of. For themes, this should be
* the theme slug (`twentytwentyone`). For plugins, this should be the path to the plugin file
* relative to the plugins directory (`gutenberg/gutenberg.php`).
* @param string $type The type of item to update. Accepted values are `plugin` or `theme`. Default is `plugin`.
* @param bool $enable Whether to enable (true) or disable (false). Default is true, or enable.
* @return bool True if the value was updated, false otherwise.
<?php
function demo_notice_add() {
?>
<div class="notice"><p>This is a notice without a type.</p></div>
<div class="notice is-dismissible"><p>This is a dismissible notice without a type.</p></div>
<div class="updated"><p>Your action succeeded!</p><p><a href="" class="button">Test Button</a></p></div>
<div class="error"><p>My error notice text1</p></div>
<div class="notice notice-success is-dismissible"><p>My dismissible success notice text</p></div>
<?php
/**
* Get a list of default source sets.
*
* @since 1.0.0
*
* @return array Default source sets.
*/
function bu_banners_get_default_source_sets() {
$source_sets = array(