Skip to content

Instantly share code, notes, and snippets.

Avatar

Andreas Ek ekandreas

View GitHub Profile
@ekandreas
ekandreas / .dockerignore
Last active Jun 21, 2019
Dockerize Roots Bedrock WP w ES
View .dockerignore
vendor
dist
web/app/mu-plugins/*/
!web/app/mu-plugins/bedrock-autoloader.php
!web/app/mu-plugins/disallow-indexing.php
!web/app/mu-plugins/register-theme-directory.php
web/app/plugins/*/
web/wp
web/app/db.php
@ekandreas
ekandreas / fix-fugly-filenames-frozzare.php
Created Mar 21, 2019
fixa fula filnamn wordpress frozzare style
View fix-fugly-filenames-frozzare.php
<?php
add_filter( 'wp_handle_upload_prefilter', function ( $file ) {
if ( ! is_array( $file ) && ! is_string( $file ) ) {
return $file;
}
if ( ! is_array( $file ) ) {
$file = [
'name' => $file,
];
@ekandreas
ekandreas / Vagrantfile
Last active Dec 16, 2018 — forked from lizrice/Vagrantfile
Vagrant file for setting up a single-node Kubernetes cluster that I can access from my desktop. Read more: https://medium.com/@lizrice/kubernetes-in-vagrant-with-kubeadm-21979ded6c63
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# This script to install Kubernetes will get executed after we have provisioned the box
$script = <<-SCRIPT
# Install kubernetes
apt-get update && apt-get install -y apt-transport-https
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
@ekandreas
ekandreas / autoload.php
Last active Oct 17, 2018
Legacy autoload example
View autoload.php
<?php
/*
* Legacy autoload example
*/
spl_autoload_register(function ($requestedClass) {
$baseClass='ElseifAB\\Regnradar';
if (0!=strpos($requestedClass, $baseClass.'\\', 0)) {
return false;
}
@ekandreas
ekandreas / deploy.php
Last active Aug 16, 2018
Ultimate WordPress PHP deployer file for Swedish site
View deploy.php
<?php
namespace Deployer;
require 'recipe/composer.php';
set('repository', 'path-to-repo');
set('git_tty', true);
set('shared_files', ['.env','web/.htaccess']);
set('shared_dirs', ['web/app/uploads']);
@ekandreas
ekandreas / nginx
Last active Apr 21, 2018
nginx-laravel-forge
View nginx
# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/mwb.digital/before/*;
#ADDED
fastcgi_cache_path /etc/nginx/cache levels=1:2 keys_zone=MWBROOT:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
#/ADDED
server {
listen 443 ssl http2;
@ekandreas
ekandreas / deploy-languages.php
Created Feb 12, 2018
PHP Deployer script to add language support for WordPress installations
View deploy-languages.php
<?php
/**
* Install WordPress languages after php deployer deploy.
* Please, set wp_languages as array with language codes!
* Support added for local development environment
*/
namespace Deployer;
use Deployer\Task\Context;
View model_post_latest.php
function model_post_latest($post_type = 'post', $max = 5)
{
return get_posts([
'post_type' => $post_type,
'posts_per_page' => $max,
]);
}
@ekandreas
ekandreas / functions.php
Created Aug 27, 2017
Add blade controllers and views to a mother theme
View functions.php
add_filter('bladerunner/controller/paths', function ($paths) {
$paths = get_template_directory() . '/controllers';
return $paths;
});
add_filter('bladerunner/template/bladepath', function($paths) {
$paths = get_template_directory() . '/views';
return $paths;
});
View controller-debug-example.blade.php
<!-- file: views/index.blade.php -->
@controller
You can’t perform that action at this time.