This file contains hidden or 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 | |
| // Fixes the missing values from ACF fields when importing posts via Wordpress importer. | |
| function auto_update_cpt_fields() | |
| { | |
| $args = array( | |
| 'post_type' => <your-cpt-name>, | |
| 'posts_per_page' => -1 | |
| ); |
This file contains hidden or 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 | |
| function enqueue_styles_and_scripts() | |
| { | |
| wp_enqueue_script('leafletjs', get_template_directory_uri() . '/path/to/leaflet-example.js', array(), '1.0.0', true); | |
| } | |
| add_action('wp_enqueue_scripts', 'enqueue_styles_and_scripts'); |
This file contains hidden or 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 | |
| /** | |
| * Return a file's size in human readable form | |
| * | |
| * @param int $bytes File's size in bytes | |
| * @param int $decimals How many decimals on the returned value | |
| * | |
| * @return string The file's size in human readable form | |
| */ |
This file contains hidden or 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 { useState, useEffect } from 'react' | |
| const useFetch = (url, options = {}) => { | |
| const [loading, setLoading] = useState(true) | |
| const [data, setData] = useState() | |
| const [error, setError] = useState() | |
| useEffect(() => { | |
| const controller = new AbortController() | |
| setLoading(true) |
This file contains hidden or 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 people from "./data"; | |
| const SearchBar = () => { | |
| const [searchValue, setSearchValue] = useState(""); | |
| const searchResults = | |
| searchValue.trim().length > 0 | |
| ? people.filter((person) => { | |
| const name = person.name; |
This file contains hidden or 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 { useState, useEffect } from "react"; | |
| const useMediaQuery = (query: string) => { | |
| const [matches, setMatches] = useState(false); | |
| useEffect(() => { | |
| const media = window.matchMedia(query); | |
| if (media.matches !== matches) { | |
| setMatches(media.matches); |
This file contains hidden or 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 { RefObject, useEffect } from 'react' | |
| const useClickOutside = (ref: RefObject<any>, callback: Function) => { | |
| useEffect(() => { | |
| const listener = (e: MouseEvent | TouchEvent) => { | |
| if (!ref.current || ref.current.contains(e.target)) { | |
| return | |
| } | |
| callback(e) |
This file contains hidden or 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 BOT_TOKEN = process.env.BOT_TOKEN; | |
| const CHANNEL_ID = process.env.CHANNEL_ID; | |
| export const sendMessage = async (message) => { | |
| const options = { | |
| method: "POST", | |
| headers: { | |
| accept: "application/json", | |
| "User-Agent": | |
| "Telegram Bot SDK - (https://github.com/irazasyed/telegram-bot-sdk)", |
This file contains hidden or 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 { useEffect, useState } from "react"; | |
| export function useDebounce<T>(value: T, delay?: number): T { | |
| const [debouncedValue, setDebouncedValue] = useState<T>(value); | |
| useEffect(() => { | |
| const timer = setTimeout(() => setDebouncedValue(value), delay || 500); | |
| return () => { | |
| clearTimeout(timer); |
OlderNewer