Skip to content

Instantly share code, notes, and snippets.

<?php
add_action( 'wp_dashboard_setup', 'bt_remove_dashboard_widgets' );
/**
*
* Remove WordPress Dashboard Widgets
*
*/
function bt_remove_dashboard_widgets() {
@kevinkub
kevinkub / incidence.js
Last active June 27, 2023 12:53
COVID-19 Inzidenz-Widget für iOS innerhalb Deutschlands 🇩🇪
// Licence: Robert Koch-Institut (RKI), dl-de/by-2-0
class IncidenceWidget {
constructor() {
this.previousDaysToShow = 31;
this.apiUrlDistricts = (location) => `https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?where=1%3D1&outFields=RS,GEN,cases7_bl_per_100k,cases7_per_100k,BL&geometry=${location.longitude.toFixed(3)}%2C${location.latitude.toFixed(3)}&geometryType=esriGeometryPoint&inSR=4326&spatialRel=esriSpatialRelWithin&returnGeometry=false&outSR=4326&f=json`
this.apiUrlDistrictsHistory = (districtId) => `https://services7.arcgis.com/mOBPykOjAyBO2ZKk/ArcGIS/rest/services/Covid19_hubv/FeatureServer/0/query?where=IdLandkreis%20%3D%20%27${districtId}%27%20AND%20Meldedatum%20%3E%3D%20TIMESTAMP%20%27${this.getDateString(-this.previousDaysToShow)}%2000%3A00%3A00%27%20AND%20Meldedatum%20%3C%3D%20TIMESTAMP%20%27${this.getDateString(1)}%2000%3A00%3A00%27&outFields=Landkreis,Meldedatum,AnzahlFall&outSR=4326&f=json`
this.stateToAbbr = {
/**
* A bookmarklet for viewing the largest contentful paint in a page.
* Will show each LCP after the bookmarklet is clicked.
*
* To install:
* 1. Copy the code starting from the line beginning `javascript:`
* 2. Add a new bookmark in Chrome, and paste the code in as the URL.
**/
javascript:(function(){
try {
@fraser-0
fraser-0 / Shopify Script - Tiered discounts on eligible products
Created October 24, 2018 01:28
Shopify script for tiered discounts that includes all products counting toward tier amount but only applies discount to eligible products
# Tiered discount campaign that allows for all products to count toward the tier amount but only eligible products be discounted.
# Can't do this in Shopify discounts because the eligible products restriction also restricts the products that can count toward the minimum spend requirement.
# Requires eligible products to have a consistent tag.
# Can do this with just one discount code but we a seperate discount code for each tier for reporting purposes.
# Amounts for the tiers
tier1_amount = Money.new(cents:100) * 160
tier2_amount = Money.new(cents:100) * 120
tier3_amount = Money.new(cents:100) * 80
(function(key, maxWidth, padding, bg, color, url) {
var load = function (load) {
if (localStorage.getItem(key)) return;
var cookieBar = document.createElement('aside');
var size = window.innerWidth > 600 ? '15' : '12';
cookieBar.innerHTML = '<div style="max-width: ' + maxWidth + 'px; margin: 0 auto; position: relative;"><p style="width: calc(100% - 40px); max-width: 1025px; margin: 0; font-size: ' + size + 'px; line-height: 1.375;">By browsing this site, you are agreeing to our use of cookies. <a href="' + url + '" style="color: inherit; text-decoration: underline; margin-right: 10px;">Our Privacy Policy.</a></p><button style="background: none; border: none; box-shadow: none; padding: 0; cursor: pointer; position: absolute; right: 0; top: 0;" aria-label="Close cookie message" type="button"><svg width="16" height="15" viewBox="0 0 16 15" xmlns="http://www.w3.org/2000/svg"><g stroke="' + color + '" fill="none" fill-rule="evenodd" stroke-linecap="square"><path d="M.5.5l14.04 14.04M.5 14.5L14.5
@GeekPress
GeekPress / ajax-cache.php
Created May 3, 2018 14:17
admin-ajax.php Request Cache
<?php
$cached_ajax_requests = array(
'your-action-here',
);
$cached_ajax_expiration_time = 7 * DAY_IN_SECONDS;
if ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_REQUEST['action'] ) && in_array( $_REQUEST['action'], $cached_ajax_requests ) ) {
$request_id = get_rocket_request_uniqid_171286();
$data = get_transient( 'rocket_get_ajax_cache_' . $request_id );
add_action( 'wp_enqueue_scripts', 'dequeue_woocommerce_styles_scripts', 99 );
function dequeue_woocommerce_styles_scripts() {
if ( function_exists( 'is_woocommerce' ) ) {
if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) {
# Styles
wp_dequeue_style( 'woocommerce-general' );
wp_dequeue_style( 'woocommerce-layout' );
wp_dequeue_style( 'woocommerce-smallscreen' );
wp_dequeue_style( 'woocommerce_frontend_styles' );
@kartick14
kartick14 / cart.liquid
Last active July 27, 2023 13:19
Apply discount code from cart page in shopify
<div class="discountcodefield">
<label for="discount">Discount Code:</label>
<input autocomplete="off" type="hidden" name="discount" class="discount_code" />
<input autocomplete="off" type="text" name="discount_code" class="discount_code_field" />
<input type="button" name="apply_discount_code" class="btn discount_code_btn" value="Apply"/>
</div>
<div class="cart__savings discount_apply_code">
</div>
@GeekPress
GeekPress / cache-woo-get-refreshed-fragment-request.php
Last active July 25, 2019 09:58
Cache WooCommerce Get Refreshed Fragment Request
<?php
if ( isset( $_GET['wc-ajax'] ) && 'get_refreshed_fragments' === $_GET['wc-ajax'] && ( !isset( $_COOKIE['woocommerce_cart_hash'] ) || empty( $_COOKIE['woocommerce_cart_hash'] ) ) && ( !isset( $_COOKIE['woocommerce_items_in_cart'] ) || empty( $_COOKIE['woocommerce_items_in_cart'] ) ) ) {
$data = get_transient( 'rocket_get_refreshed_fragments_cache' );
if ( ! empty( $data ) ) {
$data = json_decode( $data );
wp_send_json( $data );
}
ob_start();
@hdodov
hdodov / iframechange.js
Last active September 15, 2023 15:35
HTML iframe URL change listener for tracking when a new iframe page starts to load
function iframeURLChange(iframe, callback) {
var lastDispatched = null;
var dispatchChange = function () {
var newHref = iframe.contentWindow.location.href;
if (newHref !== lastDispatched) {
callback(newHref);
lastDispatched = newHref;
}