Skip to content

Instantly share code, notes, and snippets.

View tfrommen's full-sized avatar
👋
Hallo! 😀

Thorsten Frommen tfrommen

👋
Hallo! 😀
View GitHub Profile
<?php
/**
* Add Gravity Forms capabilities.
*/
add_filter( 'user_has_cap',
function( $caps ) {
if ( ! empty( $caps[ 'edit_pages' ] ) )
// user has edit capabilities
foreach ( array(
'gravityforms_delete_entries',
@tfrommen
tfrommen / mlp-hide-non-public-sites.php
Last active September 15, 2015 22:38 — forked from bueltge/mlp-filter-site.php
This is a simple add-on for the MultilingualPress plugin to hide non-public sites (i.e., languages) from translation lists such as the Language Switcher widget or the Quicklinks.
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: Hide Non-public Sites
* Description: This is a simple add-on for the MultilingualPress plugin to hide non-public sites (i.e., languages) from translation lists such as the Language Switcher widget or the Quicklinks.
* Author: Inpsyde GmbH, tf
* Author URI: http://inpsyde.com
* Version: 2015-09-16
* License: GPL-3.0
* Network: true
*/
@tfrommen
tfrommen / mlp-redirect-on-front-page-only.php
Last active August 2, 2016 12:55
Configure MultilingualPress to only redirect users on the front page
<?php # -*- coding: utf-8 -*-
add_action( 'inpsyde_mlp_init', function () {
remove_action( 'inpsyde_mlp_loaded', 'mlp_feature_redirect' );
} );
add_action( 'mlp_and_wp_loaded', function ( Inpsyde_Property_List_Interface $plugin_data ) {
if (
@tfrommen
tfrommen / adapt-redirect-url-fallback.php
Created August 9, 2016 07:34
Adapt the redirect target URL fallback (which is the home page by default).
<?php # -*- coding: utf-8 -*-
add_filter( 'mlp_redirect_url', function ( $url, array $match ) {
// If this is the home page, any URL is fine.
if ( is_home() || is_front_page() ) {
return $url;
}
// Prepare the HTTP language code.
@tfrommen
tfrommen / NetworkState.php
Last active September 7, 2016 05:26
Save and restore the current WordPress network state.
<?php
/**
* Save and restore the current network state.
*
* By using this class, you can avoid unnecessary
* switch_to_blog()-restore_current_blog()-switch_to_blog()-... excesses.
*/
class NetworkState {