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, { useState } from "react"; | |
import "./App.css"; | |
import Form from "./Form"; | |
const App = () => { | |
const [todos, setTodos] = useState([]); | |
const toggleComplete = i => | |
setTodos(todos.map( | |
(todo, k) => |
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 | |
function mytheme_setup_theme_supported_features() { | |
add_theme_support( 'editor-color-palette', | |
'#556270', | |
'#4ECDC4', | |
'#C7F464', | |
'#FF6B6B', | |
'#C44D58' | |
); |
I came across this solution when I had about a ton of posts (200+) with values in various PDFs. I didn't want to have to spend time filling out the same values over and over again.
This case is pretty straight forward; I have one repeater field field_123a56b7cb890 that has a text fields inside it (field_588a24c3cb782). I haven't tried any other types like post objects or radio buttons, but I'm sure it can be done.
Step 1. Hook into acf/load_value on your repeater field. You can use type/key/name as desired here.
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
//Add listener for when the user scrolls more than 64px | |
function init() { | |
window.addEventListener('scroll', function(e){ | |
var distanceY = window.pageYOffset || document.documentElement.scrollTop, //get offset from top | |
distanceX = window.innerWidth, //get window width | |
shrinkOn = 64, | |
header = document.querySelector(".header"); | |
if( distanceX > 992 ){ // Optional: Unfixes the menu at a certain break | |
if (distanceY > shrinkOn) { |
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
add_filter('wp_title', 'normal_tribe_events_title'); | |
function normal_tribe_events_title($title) { | |
if( get_post_type() == 'tribe_events' ){ | |
$title = get_bloginfo('name'); | |
return $title; | |
} | |
} |
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
var decodeEntities = (function() { | |
// this prevents any overhead from creating the object each time | |
var element = document.createElement('div'); | |
function decodeHTMLEntities (str) { | |
if(str && typeof str === 'string') { | |
// strip script/html tags | |
str = str.replace(/<script[^>]*>([\S\s]*?)<\/script>/gmi, ''); | |
str = str.replace(/<\/?\w(?:[^"'>]|"[^"]*"|'[^']*')*>/gmi, ''); | |
element.innerHTML = str; |
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
<div> | |
<div id="map-canvas"></div> | |
</div> | |
<script> | |
function initMap() { | |
var directionsService = new google.maps.DirectionsService; | |
var directionsDisplay = new google.maps.DirectionsRenderer({suppressMarkers: true}); | |
var map = new google.maps.Map(document.getElementById('map-canvas'), { | |
zoom: 10, |
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
//Enqueue JS like we normally do. | |
function add_test_js_files(){ | |
wp_enqueue_script('script1', '//script1.js?cid=6asdfsdf'); | |
wp_enqueue_script('script2', '//script2.js?cid=a213423423'); | |
} | |
add_action('wp_enqueue_scripts','add_test_js_files'); | |
function add_async_attribute($tag, $handle) { |
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
add_action('save_post', 'pk_require_post_thumbnail'); | |
add_action('admin_notices', 'pk_post_thumbnail_error'); | |
function pk_require_post_thumbnail($post_id) { | |
// change to any custom post type | |
if(get_post_type($post_id) != 'post') | |
return; | |
if ( !has_post_thumbnail( $post_id ) ) { |
NewerOlder