Skip to content

Instantly share code, notes, and snippets.

@swooningfish
swooningfish / php8.0-fpm-nginx-ubuntu-20.04
Last active August 17, 2022 19:35
How to install PHP 8.0.x fpm with nginx on ubuntu 20.04
# source : https://linuxize.com/post/how-to-install-php-8-on-ubuntu-20-04/
# Enableging the PHP Repo
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
# Nginx cconfig to specify which php fpm sock to use.
/etc/nginx/sites-enabled/site.local
@swooningfish
swooningfish / security.conf
Created February 24, 2021 14:03 — forked from ambroisemaupate/security.conf
Nginx CSP example
# config to don't allow the browser to render the page inside an frame or iframe
# and avoid clickjacking http://en.wikipedia.org/wiki/Clickjacking
# if you need to allow [i]frames, you can use SAMEORIGIN or even set an uri with ALLOW-FROM uri
# https://developer.mozilla.org/en-US/docs/HTTP/X-Frame-Options
add_header X-Frame-Options SAMEORIGIN;
# when serving user-supplied content, include a X-Content-Type-Options: nosniff header along with the Content-Type: header,
# to disable content-type sniffing on some browsers.
# https://www.owasp.org/index.php/List_of_useful_HTTP_headers
# currently suppoorted in IE > 8 http://blogs.msdn.com/b/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx
@swooningfish
swooningfish / get-order-detail-by-order-id.php
Created September 18, 2019 19:22 — forked from web-hat/get-order-detail-by-order-id.php
Works with WooCommerce 3.x or above
<?php
if (!function_exists('getOrderDetailById')) {
//to get full order details
function getOrderDetailById($id, $fields = null, $filter = array()) {
if (is_wp_error($id))
return false;
@swooningfish
swooningfish / yoast_seo_canonical_change_home_url_slash.php
Created February 20, 2019 13:46 — forked from amboutwe/yoast_seo_canonical_change_woocom_shop.php
Code snippets for the Yoast SEO canonical output
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Add Trailing Slash to Home Canonical - Yoast SEO
* Credit: Unknown
* Last Tested: Unknown
*/
add_filter( 'wpseo_canonical', 'yoast_seo_canonical_change_home_url_slash' );
function yoast_seo_canonical_change_home_url_slash( $canonical_url ) {
@swooningfish
swooningfish / .gitignore
Created February 18, 2019 09:58 — forked from octocat/.gitignore
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@swooningfish
swooningfish / cs-repeater-download.php
Created August 16, 2018 11:26
Make an ACF repeater field downloadable as a CSV file (without titles)
<?php
/**
* Plugin Name: CS Repeater Download
* Plugin URI: https://casperschultz.dk
* Description: Plugin for downloading repeater field data.
* Author: Casper Schultz
* Author URI: https://casperschultz.dk
* Text Domain: cs-repeater-download
* Domain Path: /lang/
* Version: 1.0
@swooningfish
swooningfish / wordpress-hide-editor-on-pages.php
Created January 4, 2018 15:10 — forked from atomtigerzoo/wordpress-hide-editor-on-pages.php
Wordpress: Hide the editor on defined pages
/**
* Hide the main editor on specific pages
*/
define('EDITOR_HIDE_PAGE_TITLES', json_encode(array()));
define('EDITOR_HIDE_PAGE_TEMPLATES', json_encode(array('template-cars.php')));
/**
* Hide the main editor on defined pages
*
@swooningfish
swooningfish / get-instagram-feed.php
Created November 10, 2017 14:11 — forked from owex/get-instagram-feed.php
Simple PHP Instagram feed
<?php
// Created following https://medium.com/@bkwebster/how-to-get-instagram-api-access-token-and-fix-your-broken-feed-c8ad470e3f02
function get_instagram($user_id=XXXXXXXXX, $count=18, $width=190, $height=190){
$url = 'https://api.instagram.com/v1/users/'.$user_id.'/media/recent/?access_token=XXXXXXXXXXXXXXXXXXXXXX&count='.$count;
// Also Perhaps you should cache the results as the instagram API is slow
$cache = './instagram/'.sha1($url).'.json';
if(file_exists($cache) && filemtime($cache) > time() - 60*60){
// If a cache file exists, and it is newer than 1 hour, use it
@swooningfish
swooningfish / gist:84b9437d91b7ecfb4d0857c95be9d832
Created August 14, 2017 23:58 — forked from paulallies/gist:0052fab554b14bbfa3ef
Remove node_modules from git repo
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master