Skip to content

Instantly share code, notes, and snippets.

Per Søderlind soderlind

Block or report user

Report or block soderlind

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
soderlind / README.txt
Last active Nov 30, 2019
Install Ninja Forms Add-Ons using Composer
View README.txt
soderlind / block-script.js
Last active Oct 19, 2019
add_theme_support( 'disable_block_style') .. hide gutenberg block style.
View block-script.js
* Hide block styles
wp.domReady(() => {
if (_.isObject(oDelBlockStyles)) {, (styleVariationName, blockName) => {
styleVariationName.forEach((style) => {
wp.blocks.unregisterBlockStyle(blockName, style);
soderlind / insert-link-to-pdf.php
Last active Sep 10, 2019
WordPress: In the editor, using "Insert Link", insert link to a PDF file in the media library
View insert-link-to-pdf.php
soderlind / add-nf-submissions-cap-capabilities.php
Created Jun 24, 2019
Ninja Forms, give Editor access to submissions
View add-nf-submissions-cap-capabilities.php
namespace Soderlind\NinjaForm\Capabilities;
add_filter( 'ninja_forms_admin_parent_menu_capabilities', __NAMESPACE__ . '\add_nf_submissions_cap_capabilities' );
add_filter( 'ninja_forms_admin_submissions_capabilities', __NAMESPACE__ . '\add_nf_submissions_cap_capabilities' );
add_filter( 'ninja_forms_admin_menu_capabilities', __NAMESPACE__ . '\add_nf_submissions_cap_capabilities' );
function add_nf_submissions_cap_capabilities( $cap ) {
return 'edit_posts'; // EDIT: User Capability
soderlind / get-ip.php
Last active May 7, 2019
PHP, Get IP behind trusted proxy
View get-ip.php
* Inspired by
//PHP 5.6
function get_ip( $trusted_proxies = [] ) {
if ( ! empty( $trusted_proxies ) && isset( $_SERVER['REMOTE_ADDR'] ) && ! in_array( $_SERVER['REMOTE_ADDR'], $trusted_proxies ) ) {
if ( isset( $_SERVER['HTTP_CF_CONNECTING_IP'] ) ) {
} elseif ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) {
soderlind /
Last active Apr 1, 2019 — forked from bjornjohansen/
Run all due cron events for WordPress with WP-CLI. Works with both single sites and multisite networks.
# Copyright © 2015 Bjørn Johansen
# This work is free. You can redistribute it and/or modify it under the
# terms of the Do What The Fuck You Want To Public License, Version 2,
# as published by Sam Hocevar. See for more details.
# Modified by Per Søderlind
MAIN_SITE="http://www.domain.tld" # --url="$MAIN_SITE" below, prevents the Undefined index: HTTP_HOST error.
soderlind / activate-searchwp.php
Last active Apr 22, 2019
Activate SearchWP using code. Also available as a plugin for WordPress Multisite:
View activate-searchwp.php
// Define the license key e.g. in wp-config.php
define( 'SEARCHWP_LICENSE_KEY', 'my-license-key-goes-here' );
// Programmatically activate the license and enable SearchWP.
add_action( 'admin_init', 'searchwp_activate' );
function searchwp_activate() {
if ( defined( 'SEARCHWP_LICENSE_KEY' ) && class_exists( '\SearchWP_License' ) && false === get_option( 'soderlind_searchwp_license_activated', false ) ) {
soderlind /
Created Sep 5, 2018 — forked from morganestes/
Create multiple sites with wp-cli in WordPress multisite for testing.

These commands will install multiple dummy sites in a WordPress Multisite environment.

I wrote this to easily create an environment to work on



In the terminal, inside your WordPress directory: simply copy, paste, and run the one-line command.

You can also add it to a location available in your $PATH and invoke the script from the shell.

soderlind / searchwp-custom-settings.php
Created Jul 11, 2018
On SearchWP activation, set the defaults for my custom post types.
View searchwp-custom-settings.php
namespace Soderlind\Demo\SearchWP;
add_filter( 'searchwp_custom_field_keys', __NAMESPACE__ . '\\on_searchwp_custom_field_keys' );
add_filter( 'searchwp_initial_engine_settings', __NAMESPACE__ . '\\on_searchwp_initial_engine_settings' );
* Add custom fields to the search index
* @param array $keys
soderlind / Install.txt
Last active Jan 10, 2020
macOS DoH! (DNS over HTTPS) using cloudflared
View Install.txt
1) Install cloudflared using homebrew:
brew install cloudflare/cloudflare/cloudflared
2) Create /usr/local/etc/cloudflared/config.yaml, with the following content
proxy-dns: true
You can’t perform that action at this time.