Skip to content

Instantly share code, notes, and snippets.

View mortenebak's full-sized avatar
🎯
Striving to improve coding everyday :)

Morten Bak mortenebak

🎯
Striving to improve coding everyday :)
View GitHub Profile
@mortenebak
mortenebak / Contract Killer 3.md
Created June 23, 2023 08:52 — forked from tony-caffe/Contract Killer 3.md
The latest version of Bytes Unlimited ‘Contract Killer’ for web professionals

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Revised by Bytes Unlimited : Feb 3rd 2020

@mortenebak
mortenebak / .editorconfig
Created June 23, 2023 08:39
My default editorconfig
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
@mortenebak
mortenebak / pint.json
Created June 23, 2023 08:38
My default Pint configuration
{
"preset": "psr12",
"rules": {
"align_multiline_comment": true,
"array_indentation": true,
"array_syntax": true,
"blank_line_after_namespace": true,
"blank_line_after_opening_tag": true,
"combine_consecutive_issets": true,
"combine_consecutive_unsets": true,

Install dependencies

Run npm install -D prettier prettier-plugin-antlers prettier-plugin-blade prettier-plugin-tailwindcss in your terminal

Configure prettier

Create a .prettierrc file with the following content

{
    "singleQuote": true,
    "trailingComma": "all",
 "printWidth": 140,
<?php
/**
* Validate our custom text input field value
*/
function plugin_republic_add_to_cart_validation( $passed, $product_id, $quantity, $variation_id=null ) {
if( empty( $_POST['pr-field'] ) ) {
$passed = false;
wc_add_notice( __( 'Your name is a required field.', 'plugin-republic' ), 'error' );
}
return $passed;
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
@mortenebak
mortenebak / da.json
Created January 11, 2022 12:21
Laravel 8.x - Danish Jetstream, Fortify and Livewire translation file
{
"Name": "Navn",
"Email": "E-mail adresse",
"Password": "Kodeord",
"Confirm Password": "Bekræft Kodeord",
"Already registered?": "Allerede registreret?",
"Register": "Opret",
"Remember me": "Husk mig",
"Forgot your password?": "Glemt dit kodeord?",
"Log in": "Log ind",
@mortenebak
mortenebak / webhook.header.txt
Created December 28, 2021 09:05 — forked from matiaslopezd/webhook.header.txt
Woocommerce webhook payload and header example
expect 100-continue
content-length 1998
connection close
x-wc-webhook-delivery-id 36e520ebabc2fa725092ff4a47acedf2
x-wc-webhook-id 3
x-wc-webhook-signature 5poyFy4qB6fdvvT5pGbefZmfkpL48uD47F0WYwfmpo4=
x-wc-webhook-event created
x-wc-webhook-resource order
x-wc-webhook-topic order.created
x-wc-webhook-source https://www.website.com/
@mortenebak
mortenebak / upload-a-file.MD
Created October 11, 2021 11:02 — forked from ahmadawais/upload-a-file.MD
Upload a file using the WordPress REST API

Upload files

Using the REST API to upload a file to WordPress is quite simple. All you need is to send the file in a POST-Request to the wp/v2/media route.

There are two ways of sending a file. The first method simply sends the file in the body of the request. The following PHP script shows the basic principle:

@mortenebak
mortenebak / functions.php
Created June 23, 2021 19:41
Dynamic Fee @ WooCommerce Checkout
<?php
// Part 1
// Display Radio Buttons
add_action( 'woocommerce_review_order_before_payment', 'bbloomer_checkout_radio_choice' );
function bbloomer_checkout_radio_choice() {
$chosen = WC()->session->get( 'radio_chosen' );