Skip to content

Instantly share code, notes, and snippets.

View jonathanbossenger's full-sized avatar
🏠
Working from home

Jonathan Bossenger jonathanbossenger

🏠
Working from home
View GitHub Profile
View wp-learn-php-compatibility.php
<?php
/**
* Plugin Name: WP Learn Compatibility
* Description: Learn to test a plugin for PHP Version Compatibility
* Version: 1.0.1
*/
/**
* Posts fetcher class
*/
View slack-old-ui-macos.md
  • Quick Slack completely
  • In a terminal, run the following commands
export SLACK_DEVELOPER_MENU=true 
open /Applications/Slack.app
  • This will open a new Slack instance but you're now able to access the developer tools.
  • Use the cmd + opt + I keyboard combination to open dev tools
  • Switch to the console tab and run the following command
View wp-learn-http-api.php
<?php
/**
* Plugin Name: WP Learn HTTP API
* Description: Learning about the WP HTTP API
* Version: 0.0.1
*/
/**
* Create an admin page to show the API data
*/
@jonathanbossenger
jonathanbossenger / switch_php.sh
Last active August 14, 2023 07:36
Script to switch PHP versions installed with homebrew on a Mac
View switch_php.sh
NEW_PHP_VERSION=$1
if [ -z "$NEW_PHP_VERSION" ]; then
echo "Please provide a PHP version to switch to."
exit 1
fi
CURRENT_PHP_VERSION=$(php -v | tail -r | tail -n 1 | cut -d " " -f 2 | cut -c 1-3)
brew unlink php@"$CURRENT_PHP_VERSION" && brew link php@"$NEW_PHP_VERSION" --force --overwrite
View wp-learn-dashboard-widgets.php
<?php
/**
* Plugin Name: WP Learn Dashboard Widgets
* Description: A plugin to add a widget to the dashboard
*/
add_action('wp_dashboard_setup', 'wp_learn_dashboard_widget_callback');
function wp_learn_dashboard_widget_callback(){
if (!current_user_can('manage_options')) {
@jonathanbossenger
jonathanbossenger / wp-test.php
Last active August 31, 2023 14:54
A simple PHP "test bed" script to learn about WordPress functionality
View wp-test.php
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Learn WordPress</title>
</head>
<body style="margin: 2em;">
<h1>Learn WordPress</h1>
<div>
<?php
View gist:96213f25ed85e662ddf92ad818ed582d
( function ( blocks, element, blockEditor ) {
var el = element.createElement;
var RichText = blockEditor.RichText;
var useBlockProps = blockEditor.useBlockProps;
var BlockControls = blockEditor.BlockControls;
var AlignmentControl = blockEditor.AlignmentControl;
blocks.registerBlockType( 'wp-learn-javascript/javascript-block', {
edit: function ( { attributes, setAttributes } ) {
@jonathanbossenger
jonathanbossenger / wp-presets.css
Created September 26, 2022 15:42
WordPress CSS Presets
View wp-presets.css
{
--wp--preset--color--black: #000000;
--wp--preset--color--cyan-bluish-gray: #abb8c3;
--wp--preset--color--white: #ffffff;
--wp--preset--color--pale-pink: #f78da7;
--wp--preset--color--vivid-red: #cf2e2e;
--wp--preset--color--luminous-vivid-orange: #ff6900;
--wp--preset--color--luminous-vivid-amber: #fcb900;
--wp--preset--color--light-green-cyan: #7bdcb5;
--wp--preset--color--vivid-green-cyan: #00d084;
View cloud-init-for-wp-multipass
# cloud-config
# See https://jonathanbossenger.com/2022/05/25/configuring-ubuntu-in-multipass-for-local-web-development-on-a-macbook/
packages:
- software-properties-common
- unzip
- zip
runcmd:
# Setting the hostname
- echo "Setting the hostname"
- echo "wp-local-env" > /etc/hostname
View times_table_tester.php
<?php
$limit = $_GET['limit'] ?? 10;
for ($i = 1; $i <= $limit; $i++) {
$numbers[] = $i;
}
$shuffled = $numbers;
shuffle($shuffled);
$lines = '';
$line_number = 0;
foreach ($numbers as $key => $number) {