Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@thefuxia
thefuxia / wp-breadcrumb.php
Last active August 29, 2015 13:59
Basic concept for a flexible OOP breadcrumb setup
<?php
interface Wp_Breadcrumb_Strings_Interface {
public function get_text( $item );
}
class Wp_Breadcrumb_Strings implements Wp_Breadcrumb_Strings_Interface {
public function get_text( $item ) {}
}
@thefuxia
thefuxia / Mlp_Redirect.php
Created April 28, 2014 00:17
Class Mlp_Redirect
<?php
/**
* Class Mlp_Redirect
*
* @version 2014.04.28
* @author Inpsyde GmbH, toscho
* @license GPL
*/
class Mlp_Redirect {
@thefuxia
thefuxia / mlp_duplicated_blog.php
Created July 2, 2014 05:27
Multilingual Press: mlp_duplicated_blog
<?php
// In inc/pro/controllers/Mlp_Duplicate_Blogs.php,
// at the end of Mlp_Duplicate_Blogs::wpmu_new_blog()
$context = array (
'source_blog_id' => $source_blog_id,
'new_blog_id' => $blog_id
);
/**
<?php
/**
* Remove callbacks for problematic hooks.
*
* Many plugins and themes do not check for a switched site context, they will
* save $_POST data to the wrong site. This class tries to remove all those
* callbacks.
*
* @version 2014.07.23
* @author Inpsyde GmbH, toscho
@thefuxia
thefuxia / woocommerce-insanity.md
Last active August 29, 2015 14:05
WooCommerce insanity

WooCommerce has a strange way to register its tables.

$sql = "
SELECT DISTINCT TABLE_NAME
FROM information_schema.columns
WHERE TABLE_NAME LIKE '{$wpdb->prefix}woocommerce_%'";

$tables = $wpdb->get_col( $sql );
@thefuxia
thefuxia / post-meta-test.php
Created September 12, 2014 04:58
Test post meta fields in WordPress
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: Post Meta Test
* Description: Adds a simple post meta field below the title to the post editor screen.
* Plugin URI: http://marketpress.com/
* Version: 2014.09.12
* Author: MarketPress, Thomas Scholz
* Author URI: http://marketpress.com/
* Licence: GPL 2
* License URI: http://opensource.org/licenses/GPL-2.0
@thefuxia
thefuxia / url-decorator.php
Created September 21, 2014 22:02
Simple decorator pattern example
<?php # -*- coding: utf-8 -*-
interface Url {
public function get_url();
}
class Basic_Url implements Url {
private $url;
@thefuxia
thefuxia / MultilingualPress-translations-example.php
Created December 18, 2014 13:54
Get translation from MultilingualPress
<?php
add_action( 'wp_footer', function() {
$mlp_language_api = apply_filters( 'mlp_language_api', NULL );
if ( is_a( $mlp_language_api, 'Mlp_Language_Api_Interface' ) ) {
$args = [
'site_id' => get_current_blog_id(),
'content_id' => get_queried_object_id(),
@thefuxia
thefuxia / category-feed-links.php
Created December 27, 2014 14:01
Always add category feed links
@thefuxia
thefuxia / t5-refresh-rss-widget.php
Last active August 29, 2015 14:12
Refresh the feed for the built-in RSS widget every two hours
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: T5 Refresh RSS Widget
* Plugin URI: https://gist.github.com/toscho/47fc50f875473ee537e6
* Description: Refresh the feed for the built-in RSS widget every two hours.
* Version: 03.01.15
* Required: 4.0
* Author: Thomas Scholz <info@toscho.de>
* Author URI: http://toscho.de
* License: MIT