This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import apiFetch from '@wordpress/api-fetch'; | |
// Define your WooCommerce consumer key and secret | |
const consumerKey = 'your_consumer_key'; | |
const consumerSecret = 'your_consumer_secret'; | |
const storeUrl = 'https://your-domain.com/wp-json/store-vacation/v1'; | |
// Function to fetch WooCommerce vacation schedules. | |
const fetchVacationSchedules = async () => { | |
try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Displaying first name and last name fields on | |
* WooCommerce's registration page. | |
*/ | |
function woocommerce_register_form() { | |
$fields = array( | |
'first_name' => __('First name', 'woocommerce'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add the code below to your theme's functions.php file | |
* to add a confirm password field on the register form under My Accounts. | |
*/ | |
function woocommerce_registration_errors_validation($reg_errors, $sanitized_user_login, $user_email) { | |
global $woocommerce; | |
extract( $_POST ); | |
if ( strcmp( $password, $password2 ) !== 0 ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
function useWindowDimensions() { | |
const [width, setWidth] = React.useState(window.innerWidth); | |
const [height, setHeight] = React.useState(window.innerHeight); | |
React.useEffect(() => { | |
const handleResize = () => { | |
setWidth(window.innerWidth); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
function useWait(delay) { | |
const [status, setStatus] = React.useState(false); | |
React.useEffect(() => { | |
const id = window.setTimeout(() => { | |
setStatus((c) => !c); | |
}, delay); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const menu = { | |
_courses: { | |
appetizers: [], | |
mains: [], | |
desserts: [] | |
}, | |
addDishToCourse( courseName, dishName, dishPrice ) { | |
dish = { | |
name: dishName, | |
price: dishPrice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.wsvpro + .product form.cart { | |
display: none; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Destructure the `subreddit` from props: | |
function Reddit({ subreddit }) { | |
const [posts, setPosts] = useState([]); | |
useEffect(() => { | |
async function fetchData() { | |
// 2. Use a template string to set the URL: | |
const res = await fetch( | |
`https://www.reddit.com/r/${subreddit}.json` | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect, useState, useRef } from "react"; | |
import ReactDOM from "react-dom"; | |
function App() { | |
// Store a reference to the input's DOM node | |
const inputRef = useRef(); | |
const [value, setValue] = useState(""); | |
useEffect( | |
() => { |
NewerOlder