Skip to content

Instantly share code, notes, and snippets.

View jackbillstrom's full-sized avatar
👋

Jack Billström jackbillstrom

👋
View GitHub Profile
@jackbillstrom
jackbillstrom / index.html
Created April 27, 2020 16:26
Tidö Lindö Marin Filtersök FORK
<html>
<head>
<meta charset="UTF-8">
<!-- import CSS -->
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
</head>
<body>
filtered_boats: function () {
let filtered = this.boats;
// the minimums
let mins = {
"minPrice": 'price',
"minLength": 'length',
...
};
@jackbillstrom
jackbillstrom / index.html
Created May 10, 2020 12:17
tailwind-landing-page
<body
class="text-gray-700 bg-white"
style="font-family: 'Source Sans Pro', sans-serif"
>
<!--Nav-->
<nav>
<div
class="container mx-auto px-6 py-2 flex justify-between items-center"
>
<a class="font-bold text-2xl lg:text-4xl" href="#">
@jackbillstrom
jackbillstrom / [WP SSH SNIPPET] Skapa ny Wordpress på utv.miljö.md
Last active June 24, 2020 09:55
[WP SSH SNIPPET] Skapa ny Wordpress på utv.miljö

[WP / SSH SNIPPET] Skapa ny Wordpress på utv.miljö

  • cd /var/www/
  • sudo mkdir -p subdomain/public_html
  • cd subdomain/pub*
  • sudo chown $USER:$USER -R .
  • wp core download
  • sudo chown www-data:www-data -R .

Importera från fil

@jackbillstrom
jackbillstrom / code.php
Created May 25, 2020 22:35
[WooCommerce] Recently Viewed Products
/**
* goes inside your beloved functions.php
*/
add_shortcode( 'recently_viewed_products', 'code_recently_viewed_products' );
function code_recently_viewed_products() {
$viewed_products = ! empty( $_COOKIE['woocommerce_recently_viewed'] ) ? (array) explode( '|', wp_unslash( $_COOKIE['woocommerce_recently_viewed'] ) ) : array();
$viewed_products = array_reverse( array_filter( array_map( 'absint', $viewed_products ) ) );
<?
// /product-options-for-woocommerce/Model/Option.php
public function saveOptions($productId, $options) {
$productId = (int)$productId;
// Här kommer alla värden samlas upp efter loopen
// tänk på att loopen svarar RAD FÖR RAD
$lens_options = array();
@jackbillstrom
jackbillstrom / command.sh
Last active July 21, 2020 00:21
How to renew a expired Let's Encrypt certificate via certbot
# This command will be generating a TXT-string you'll need to enter into your "_acme-challenge.example.se"
# When the new DNS post is live, you'll want to press ENTER in your shell to complete setup.
# My setup is a Debian machine with Apache as Web Server with virtualhosts.
sudo certbot-auto --server https://acme-v02.api.letsencrypt.org/directory -d "*.example.se" --preferred-challenges dns-01 certonly
<?php
function my_customize_rest_cors() {
remove_filter( 'rest_pre_serve_request', 'rest_send_cors_headers' );
add_filter( 'rest_pre_serve_request', function( $value ) {
header( 'Access-Control-Allow-Origin: *' );
header( 'Access-Control-Allow-Methods: GET' );
header( 'Access-Control-Allow-Credentials: true' );
header( 'Access-Control-Expose-Headers: Link', false );
@jackbillstrom
jackbillstrom / single.php
Created October 30, 2020 12:17
WC v4.4.0
<?php
/**
* Simple product add to cart
*
* This template can be overridden by copying it to yourtheme/woocommerce/single-product/add-to-cart/simple.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
@jackbillstrom
jackbillstrom / wc_ajax_add_to_cart.php
Created November 18, 2020 23:08
Woocommerce Ajax Add To Cart Button
<?php
//AJAX ADD TO CART BUTTON
$product_id = 143;
if( !my_custom_cart_contains( $product_id ) ) {
?>
<button class="my-custom-add-to-cart-button" data-product-id="<?php echo $product_id; ?>">add to cart</button>
<?php
} else {
?>