- https://speakerdeck.com/willroth/50-laravel-tricks-in-50-minutes
- https://www.reddit.com/r/laravel/comments/3to60i/50_laravel_tricks/
- 1. Automatic Model Validation
| server { | |
| listen 80; | |
| #listen [::]:80 default_server ipv6only=on; | |
| ## Make site accessible from world web. | |
| server_name mailwizz.dev www.mailwizz.dev; | |
| ## Log Settings. | |
| access_log /var/log/nginx/mailwizz.dev_access.log; | |
| error_log /var/log/nginx/mailwizz.dev_error.log error; |
| // Place this in wp-config | |
| define( 'ACF_5_KEY', 'yourkeyhere' ); | |
| // Set ACF 5 license key on theme activation. Stick in your functions.php or equivalent. | |
| function auto_set_license_keys() { | |
| if ( ! get_option( 'acf_pro_license' ) && defined( 'ACF_5_KEY' ) ) { | |
| $save = array( | |
| 'key' => ACF_5_KEY, |
| #!/bin/bash -e | |
| ## | |
| # WordPress Installation and VirtualHost Creation | |
| # | |
| # Description: Installs a WordPress website in the ~/Sites folder, creates a homepage, | |
| # cleans up the WP install a bit, deletes the akismet and hello dolly plugins, creates the permalinks, | |
| # clones the roots/sage theme framework to the theme folder, deletes all the other WP default themes, | |
| # installs/runs npm and bower and runs gulp to create the initial assets, adds a custom gitignore file | |
| # to /wp-content, installs the roots/soil plugin, creates a git repo in wp-content, saves the WordPress |
| # Remove existing containers | |
| cd {{release}} | |
| [[ ! -f .env ]] && cp ~/.env.marketplace ./.env | |
| sudo docker ps -a | grep marketplace && sudo docker rm -f marketplace | |
| sudo docker build -t marketplace . | |
| sudo docker run -id -v /$(pwd):/usr/share/nginx/html -p 7000:80 --name marketplace marketplace |
| // assets/scripts/customizer.js | |
| (function($) { | |
| // Primary colour | |
| wp.customize('primary_colour', function(value) { | |
| value.bind(function(to) { | |
| $('head').append('<style>.Primary-bg-c{background-color:'+ to +' !important;}</style>'); | |
| $('head').append('<style>.Primary-c{color:'+ to +' !important;}</style>'); | |
| $('head').append('<style>.Primary-c--hover:hover{color:'+ to +' !important;}</style>'); |
| // Get defaultView from LocalStorage, fallback on basicWeek if it is not set yet. | |
| var defaultView = (localStorage.getItem("fcDefaultView") !== null ? localStorage.getItem("fcDefaultView") : "basicWeek"); | |
| $('#calendar').fullCalendar({ | |
| header: { | |
| left: 'prev,next today', | |
| center: 'title', | |
| right: 'month,basicWeek,basicDay' | |
| }, | |
| defaultView: defaultView, | |
| viewRender: function (view, element) { |
| // REMOVE WP EMOJI | |
| remove_action('wp_head', 'print_emoji_detection_script', 7); | |
| remove_action('wp_print_styles', 'print_emoji_styles'); | |
| remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); | |
| remove_action( 'admin_print_styles', 'print_emoji_styles' ); | |
| // First, we remove all the RSS feed links from wp_head using remove_action | |
| remove_action( 'wp_head','feed_links', 2 ); |
| <?php | |
| if ( ! function_exists( 'squarecandy_add_to_gcal' ) && ! function_exists( 'squarecandy_add_to_gcal_url' ) ) : | |
| /** | |
| * Create a Google Calendar "add to calendar" link. | |
| * | |
| * This function is convienient because it does not require an API connection. | |
| * Note that this only allows for adding a single event. | |
| * The data does not have to exist already on any Google Calendar anywhere. | |
| * This just adds your event data to the end-users GCal one item at a time. |
| <?php | |
| /** | |
| * Adds a Base64 encoded version of the Featured Image thumbnail | |
| * to post meta | |
| * | |
| * @param int $post_id ID of the post that's being updated. | |
| */ | |
| function dp_add_base64_featured_image_thumb($post_id) { | |
| // If this is just a revision, don't do anything. | |
| if (wp_is_post_revision($post_id)) { |