Skip to content

Instantly share code, notes, and snippets.

@tanthammar
tanthammar / custom_user_woo_sub.php
Last active January 26, 2017 19:47
Proposed `custom_user_roles()` function to change `'woocommerce_subscriptions_update_users_role'` default behavior
<?php
function custom_user_roles( $user_id, $role_name ) {
$user = new WP_User( $user_id );
//I need help here how to get a meta value from the subscription
$subscription_role = ??
$wooSubRole = get_post_meta( $subscription_role, 'wpcf-woo-sub-user-role', true );
// End help needed
[{"name":"Bears","color":"Blue","position":{"x":177,"y":85},"modelclass":"Bear","increment":false,"timestamp":false,"softdelete":false,"column":[{"colid":"c217","name":"id","type":"increments","length":"0","order":0,"defaultvalue":"","enumvalue":""},{"colid":"c218","name":"name","type":"string","length":"200","order":1,"defaultvalue":"","enumvalue":""},{"colid":"c219","name":"danger_level","type":"string","length":"200","order":2,"defaultvalue":"","enumvalue":""}],"relation":[{"extramethods":"","foreignkeys":"","name":"fish","relatedmodel":"Fish","relationtype":"hasOne","usenamespace":""},{"extramethods":"","foreignkeys":"","name":"trees","relatedmodel":"Trees","relationtype":"hasMany","usenamespace":""},{"extramethods":"->withPivot('bears_picnics')","foreignkeys":"bear_id, picnic_id","name":"picnics","relatedmodel":"Picnics","relationtype":"belongsToMany","usenamespace":""}],"seeding":[]},{"name":"Fish","color":"Yellow","position":{"x":1063,"y":14},"modelclass":"Fish","increment":false,"timestamp":false,"sof
@tanthammar
tanthammar / igen.skema
Created September 23, 2018 19:59
test
[{"name":"Bears","color":"Blue","position":{"x":177,"y":85},"modelclass":"Bear","increment":false,"timestamp":false,"softdelete":false,"column":[{"colid":"c217","name":"id","type":"increments","length":"0","order":0,"defaultvalue":"","enumvalue":""},{"colid":"c218","name":"name","type":"string","length":"200","order":1,"defaultvalue":"","enumvalue":""},{"colid":"c219","name":"danger_level","type":"string","length":"200","order":2,"defaultvalue":"","enumvalue":""}],"relation":[{"extramethods":"","foreignkeys":"","name":"fish","relatedmodel":"Fish","relationtype":"hasOne","usenamespace":""},{"extramethods":"","foreignkeys":"","name":"trees","relatedmodel":"Trees","relationtype":"hasMany","usenamespace":""},{"extramethods":"->withPivot('bears_picnics')","foreignkeys":"bear_id, picnic_id","name":"picnics","relatedmodel":"Picnics","relationtype":"belongsToMany","usenamespace":""}],"seeding":[]},{"name":"Fish","color":"Yellow","position":{"x":1063,"y":14},"modelclass":"Fish","increment":false,"timestamp":false,"sof
@tanthammar
tanthammar / Import Locations and Markers, Formula.md
Last active May 18, 2019 12:03
Underlag Joakim, import formel

Existerande värden

Bild

Alla bilder har bredd och höjd som går att definera i följande måttenheter

  • Punkter
  • Pica
  • Tum
  • Millimeter
  • Centimeter
  • Pixlar
@tanthammar
tanthammar / ocr.php
Created September 27, 2019 10:38 — forked from AdamGerthel/ocr.php
Generate BankGiro/PlusGiro OCR numbers via PHP
<?php
/**
* OCR Number generation function
*
* @param string $base_number
* The base number that you wish to use for the OCR nr. Can be any number,
* but usually consists of client ID combined with invoice ID or similar.
* @param boolean $length
* Use length if you want the OCR number to add a length
@tanthammar
tanthammar / Response.php
Created February 13, 2020 10:48 — forked from jeffochoa/Response.php
Laravel HTTP status code
<?php
// This can be found in the Symfony\Component\HttpFoundation\Response class
const HTTP_CONTINUE = 100;
const HTTP_SWITCHING_PROTOCOLS = 101;
const HTTP_PROCESSING = 102; // RFC2518
const HTTP_OK = 200;
const HTTP_CREATED = 201;
const HTTP_ACCEPTED = 202;
@tanthammar
tanthammar / HasUuidTrait.php
Last active January 28, 2021 16:47
Laravel Model Uuid trait
<?php
namespace App\Traits;
use Hidehalo\Nanoid\Client;
/**
* Source: https://github.com/jamesmills/eloquent-uuid
* added prefix
* last updated 28 jan 2021.
@tanthammar
tanthammar / HasLinks.php
Last active July 10, 2020 11:14
Laravel Append Model Links
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddIndexToTranslatedNamesTable extends Migration
{
protected $tables = ['organizers', 'events', 'bookers',
'categories', 'terms', 'tabs', 'helps',
@tanthammar
tanthammar / capturePlainTextOnPaste.js
Created May 2, 2020 16:58
Capture plain-text on paste JS
/**
* Capture the <CTL-V> paste event, only allow plain-text, no images.
*
* see: https://stackoverflow.com/a/28213320
*
* @param {object} evt - array of files
* @author Daniel Thompson-Yvetot
* @license MIT
*/
pasteCapture(evt, ref) {