Skip to content

Instantly share code, notes, and snippets.

@apkoponen
apkoponen / Simple JS
Created March 8, 2016 13:53
Don't calculate distances with Pythagoras and simple magic constant.
var Helsinki = {
lat: 60.1639305,
lng: 24.9001888
};
var Oulu = {
lat: 64.4984149,
lng: 26.1482539
};
var Lappeenranta = {
lat: 60.9673061,
@apkoponen
apkoponen / What I now get
Created February 12, 2016 20:07
Custom errors
{
"code": "rest_missing_callback_param",
"message": "Missing parameter(s): client_id, response_type, redirect_uri",
"data": {
"status": 400,
"params": [
"client_id",
"response_type",
"redirect_uri"
]
@apkoponen
apkoponen / Interceptor
Created February 4, 2016 19:46
Example interceptor
function oauth2_handle_access_token() {
if(isset($_GET['access_token'])) {
// Check if access token is valid. Give capabilities accordingly.
}
}
add_action('init', 'oauth2_handle_access_token')
@apkoponen
apkoponen / wordpress-export.xml
Created December 28, 2015 12:18
A simple WordPress export that has an XSS attack in it.
<?xml version="1.0" encoding="UTF-8" ?>
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
<!-- You may use this file to transfer that content from one site to another. -->
<!-- This file is not intended to serve as a complete backup of your site. -->
<!-- To import this information into a WordPress site follow these steps: -->
<!-- 1. Log in to that site as an administrator. -->
<!-- 2. Go to Tools: Import in the WordPress admin panel. -->
<!-- 3. Install the "WordPress" importer from the list. -->
@apkoponen
apkoponen / the_attachment_image_responsive_bg_style
Last active November 1, 2017 08:32
Output a style tag with responsive background image sizes (for WordPress 4.4 and up).
/**
* Output a style tag with responsive background image sizes.
*
* Example:
*
* the_attachment_image_responsive_bg_style(132, "#section-top", 40)
*
* For attachment ID 132, for an element with id="section-top" and a page
* with 20px padding on both sides of the element.
*
diff --git a/includes/admin/class-wc-bookings-admin.php b/includes/admin/class-wc-bookings-admin.php
index ca679ca..7c5fd38 100644
--- a/includes/admin/class-wc-bookings-admin.php
+++ b/includes/admin/class-wc-bookings-admin.php
@@ -28,6 +28,8 @@ class WC_Bookings_Admin {
add_action( 'woocommerce_product_options_general_product_data', array( $this, 'booking_data' ) );
add_filter( 'product_type_options', array( $this, 'booking_product_type_options' ) );
add_action( 'load-options-general.php', array( $this, 'reset_ics_exporter_timezone_cache' ) );
+ add_action( 'update_option', array($this, 'update_global_booking_availability'), 10, 3 ); // wc_global_booking_availability do_action( 'updated_option', $option, $old_value, $value );
+ add_action( 'update_postmeta', array($this, 'update_booking_availablity'), 10, 4 ); // do_action( 'updated_postmeta', $meta_id, $object_id, $meta_key, $meta_value ); _wc_booking_availability
@apkoponen
apkoponen / woocommerce-gateway-paytrail.php
Created June 4, 2015 11:57
Fixed WooCommerce gateway main file
<?php
/**
* Plugin Name: WooCommerce Paytrail Gateway
* Plugin URI: http://www.woothemes.com/products/suomen-verkkomaksut-gateway/
* Description: Accept payment in WooCommerce with the Paytrail gateway. Fixed by Valu.
* Author: SkyVerge
* Author URI: http://www.skyverge.com
* Version: 100.3.1
* Text Domain: woocommerce-gateway-paytrail
* Domain Path: /i18n/languages/