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 { DrupalJsonApiParams } from "drupal-jsonapi-params"; | |
| import { drupal, getResourceByParams } from "@/lib/drupal"; | |
| const RESOURCE_TYPE = "node--landing_page"; | |
| export default async function Page({ params }: { params: { slug: string[] } }) { | |
| // Fetch a resource by params | |
| const resource = await getResourceByParams(params); |
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 | |
| /* Developer Config */ | |
| // Environment | |
| define( 'DEV_MODE', true ); | |
| // Debug (based upon dev mode) | |
| define( 'WP_DEBUG', DEV_MODE ); | |
| define( 'WP_DEBUG_LOG', DEV_MODE ); |
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
| function apply_global_coupon() { | |
| global $woocommerce; | |
| $all_coupons = get_all_store_coupons(); | |
| $coupon_code = 'Global'; | |
| if ( in_array( $coupon_code, $all_coupons) ) { | |
| if ( WC()->cart->has_discount( $coupon_code ) ) return; |
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
| function imageLazyLoad() { | |
| const images = Array.from(document.querySelectorAll('img[data-src]')); | |
| if (images.length) { | |
| if ('IntersectionObserver' in window) { | |
| setupIntersectionObserver(images); | |
| } else { | |
| loadImages(images); | |
| } | |
| } |
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 events = (function () { | |
| const topics = {}; | |
| return { | |
| subscribe(topic, listener) { | |
| // Create topics object if not yet created | |
| if (!topics.hasOwnProperty.call(topics, topic)) topics[topic] = []; | |
| // Add listener to the queue | |
| const index = topics[topic].push(listener) - 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
| Array.from(document.querySelectorAll('[id]')) | |
| .map(domNode => domNode.id) | |
| .filter((id, index, self) => id.length > 0 && self.indexOf(id) !== index) | |
| .forEach(id => console.warn(`Multiple IDs #${id}`)); |
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
| <img data-src="http://placehold.it/300x300" alt="Example image"> |
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 Analytics = {}; | |
| // Pass n arguments using rest parameter | |
| Analytics.trigger = (...params) => { | |
| // console.log(typeof params); // object (Array) | |
| // Spread parameter into CoreMetrics tag | |
| cmCreateElementTag(...params); | |
| }; |