Skip to content

Instantly share code, notes, and snippets.

Avatar

Fuxia Scholz thefuxia

View GitHub Profile
@thefuxia
thefuxia / wp-breadcrumb.php
Last active Aug 29, 2015
Basic concept for a flexible OOP breadcrumb setup
View wp-breadcrumb.php
<?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 ) {}
}
View Mlp_Redirect.php
<?php
/**
* Class Mlp_Redirect
*
* @version 2014.04.28
* @author Inpsyde GmbH, toscho
* @license GPL
*/
class Mlp_Redirect {
@thefuxia
thefuxia / mlp_duplicated_blog.php
Created Jul 2, 2014
Multilingual Press: mlp_duplicated_blog
View mlp_duplicated_blog.php
<?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
);
/**
View Mlp_Unhook.php
<?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 Aug 29, 2015
WooCommerce insanity
View woocommerce-insanity.md

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 Sep 12, 2014
Test post meta fields in WordPress
View post-meta-test.php
<?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 Sep 21, 2014
Simple decorator pattern example
View url-decorator.php
<?php # -*- coding: utf-8 -*-
interface Url {
public function get_url();
}
class Basic_Url implements Url {
private $url;
@thefuxia
thefuxia / MultilingualPress-translations-example.php
Created Dec 18, 2014
Get translation from MultilingualPress
View MultilingualPress-translations-example.php
<?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 Dec 27, 2014
Always add category feed links
View category-feed-links.php
@thefuxia
thefuxia / t5-refresh-rss-widget.php
Last active Aug 29, 2015
Refresh the feed for the built-in RSS widget every two hours
View t5-refresh-rss-widget.php
<?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
You can’t perform that action at this time.