Skip to content

Instantly share code, notes, and snippets.

@thefuxia
thefuxia / mlp-addon-post-meta.php
Last active November 26, 2015 09:00
MLP Addon: Sync post meta fields
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: MLP Addon: Sync post meta fields
* Plugin URI: https://gist.github.com/toscho/6393c79aacba0983a96a
* Description: Create a custom field, put it into the MLP translation box, and sync it across the sites.
* Version: 2015.03.03
* Required: 4.0
* Author: Thomas Scholz <info@toscho.de>
* Author URI: http://toscho.de
* License: MIT
@thefuxia
thefuxia / t5-cpt-tester.php
Created February 26, 2015 18:32
T5 Test Types
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: T5 Test Types
* Description: Adds some custom post types and taxonomies for testing purposes.
* Plugin URI:
* Version: 2013.04.12
* Author: Thomas Scholz
* Author URI: http://toscho.de
* Licence: MIT
* License URI: http://opensource.org/licenses/MIT
@thefuxia
thefuxia / t5-excerpt-widget.php
Created February 17, 2015 18:28
Plugin T5 Excerpt Widget.
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: T5 Excerpt Widget
* Plugin URI: https://gist.github.com/toscho/b318faa2b79d9bb8ffe8
* Description: Shows the post excerpt in a widget. The widget is visible on single posts only.
* Version: 17.02.15
* Required: 4.0
* Author: Thomas Scholz <info@toscho.de>
* Author URI: http://toscho.de
* License: MIT
@thefuxia
thefuxia / t5-page-template-column.php
Last active December 14, 2017 09:04
T5 Page Template Column. Shows the page templates as separate, sortable column.
<?php
/**
* Plugin Name: T5 Page Template Column
* Plugin URI: https://gist.github.com/toscho/f657e323a60f12ad9605
* Description: Shows the page templates as separate, sortable column.
* Version: 2015.02.14
* Required: 4.0
* Author: Thomas Scholz <info@toscho.de>
* Author URI: http://toscho.de
* License: MIT
@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
@thefuxia
thefuxia / category-feed-links.php
Created December 27, 2014 14:01
Always add category feed links
@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 / 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 / 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 / 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 );