Skip to content

Instantly share code, notes, and snippets.

View MonteLogic's full-sized avatar
♂️

Monte Logic MonteLogic

♂️
View GitHub Profile
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"name": "create-block/mol-custom-blocks",
"version": "0.1.0",
"title": "Monte Logic's Custom Blocks",
"category": "text",
"icon": "flag",
"description": "A Gutenberg block to show your pride! This block enables you to type text and style it with the color font Gilbert from Type with Pride.",
"attributes": {
@MonteLogic
MonteLogic / block.json
Last active September 16, 2022 15:52 — forked from ryanwelcher/block.json
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"name": "create-block/mol-custom-blocks",
"version": "0.1.0",
"title": "Monte Logic's Custom Blocks",
"category": "text",
"icon": "flag",
"description": "A Gutenberg block to show your pride! This block enables you to type text and style it with the color font Gilbert from Type with Pride.",
"attributes": {
@MonteLogic
MonteLogic / frontend.js
Created October 3, 2022 02:22
documenting a function attachToggleActionToButtons(menus) -getwid-megamenu - src/frontend.js
function attachToggleActionToButtons(menus) {
menus.each((index, menu) => {
// I think(?) this is for the larger menu on mobile and not
// the submenu. Have to test that out.
$(menu).on('click', '.gw-mm__toggle', function (event) {
toggleMobileMenu($(this), $(menu));
});
// I could write an if statement here but I still don't know
// the full jurisdictions of the this operator below.
(function ($) {
$(document).ready(function () {
const menus = $('.gw-mm');
const plainMenus = $('.gw-pm');
function setDropdownsPosition(menus) {
menus.each((index, menu) => {
if ($(menu).hasClass('is-mobile')) {
$(menu).find('.gw-mm-item__dropdown-wrapper').css({
'left': '',
@MonteLogic
MonteLogic / App.js
Created October 16, 2022 15:51
Fetch feature with useEffect.
import "./styles.css";
import React, { useEffect, useState } from "react";
export default function App() {
const [resourceType, setResourceType] = useState("posts");
console.log("render");
useEffect(() => {
fetch(`https://jsonplaceholder.typicode.com/${resourceType}`)
@MonteLogic
MonteLogic / woo-blocks-check-house-number-in-shipping-address.php
Created November 2, 2022 17:42 — forked from woogists/woo-blocks-check-house-number-in-shipping-address.php
[WooCommerce Blocks] Check if the shipping address contains a house number
<?php
add_action( 'woocommerce_store_api_checkout_update_order_from_request', 'woo_blocks_address_field_validation', 10, 2);
function woo_blocks_address_field_validation( WC_Order $order, $request ) {
$shipping_address = $order->get_address('shipping')['address_1'];
if ( $shipping_address && ! preg_match( '/[0-9]+/', $shipping_address ) ) {
throw new Exception( 'Your shipping address must contain a house number!' );
}
}
<?php
/**
* What I am trying to do is access the IntegrationInterface from
* WooCommerce-Blocks
* Documentation on IntegrationInterface:
* https://github.com/woocommerce/woocommerce-blocks/blob/50f9b3e8d012f425d318908cc13d9c601d97bd68/docs/extensibility/integration-interface.md
*
*
* It is an interface which allows for certain files to be loaded in a
<?php
/**
* Plugin Name: The WordPress SlotFill System
* Description: Plugin of Slot Fill Examples.
* Version: 0.1.0
* Author: Monte Logic
* Author URI: www.ryanwelcher.com
* Plugin URI: https://github.com/montelogic
* Textdomain: gutenberg-slot-fill-system
*
@MonteLogic
MonteLogic / option.tsx
Last active January 5, 2023 19:06
WC Blocks option which contains some state logic related to the props. In studying to make the editor view changable on the shipping options.
/**
* External dependencies
*/
import classnames from 'classnames';
/**
* Internal dependencies
*/
import OptionLayout from './option-layout';
import type { RadioControlOptionProps } from './types';
function getThisToWork() {
fetch('/wp-json/wp/v2/users/3', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'X-WP-Nonce': wpApiSettings.nonce, // replace with your nonce value
},
})
.then(response => response.json())
.then(data => {