Skip to content

Instantly share code, notes, and snippets.

View franz-josef-kaiser's full-sized avatar

Franz Josef Kaiser franz-josef-kaiser

View GitHub Profile
@franz-josef-kaiser
franz-josef-kaiser / wcm_list_cat_filter.class.php
Created January 29, 2013 12:12
WordPress plugin that alters the (translated) title attribute for `wp_list_categories()` list items on the fly using the `gettext` or `category_description` filter.
<?php
add_action( 'plugins_loaded', array( 'WCM_list_cat_filter', 'init' ), 5 );
/**
* @package WCM Filterama
* @subpackage Bootstrap
*/
class WCM_list_cat_filter
{
private static $instance;
@franz-josef-kaiser
franz-josef-kaiser / questions.php
Created February 1, 2013 07:49
Child Plugin Questions: I pro-actively try to find people who develop child plugins/extensions for my plugins. Now I got two plugins approved for the official repo and want to have a possibility to advertise those peoples child plugins (if there come any) along with my parent plugin. Am I allowed to do the following? * Am I allowed to place link…
<?php
/**
* Plugin Name: Child Plugin
* Description: This plugin can get downloaded from the official wp.org repo. Just click the download link. It has no other functionality so far.
*/
add_action( 'plugins_loaded', array( $this, 'child_plugin' ) );
class child_plugin
{
protected static $inst;
public static function init()
@franz-josef-kaiser
franz-josef-kaiser / admin_menu_separator.php
Last active September 7, 2020 22:05
WordPress (mu)plugin to add a separator to the admin menu with a call to the default API. Explanation can be found in the doc block. // Screenshots (main menu separator) http://i.stack.imgur.com/HUmKQ.png // (submenu separator) http://i.stack.imgur.com/6AKDY.png
<?php
defined( 'ABSPATH' ) OR exit;
/**
* Plugin Name: Admin Menu Separator
* Description: Adds a separator on whatver priority is needed.
*/
add_filter( 'parent_file', 'admin_menu_separator' );
function admin_menu_separator( $parent_file )
{
@franz-josef-kaiser
franz-josef-kaiser / dom_doc_table.php
Last active December 13, 2015 16:59
Example for DOMDocument parser used to create a HTML table.
<?php
$dom = new DOMDocument( '' );
$root = $dom->createElement( 'html' );
$root = $dom->appendChild( $root );
$body = $dom->createElement( 'body' );
$body = $root->appendChild( $body );
$table = $dom->createElement( 'table' );
$table = $body->appendChild( $table );
@franz-josef-kaiser
franz-josef-kaiser / taxonomies_for_pages.php
Created February 15, 2013 13:47
Adds the built in "Category" and "Post Tag" taxonomies to WordPress "pages" post type
<?php
defined( 'ABSPATH' ) OR exit;
/**
* Plugin Name: Taxonomies for Pages
* Description: Adds the built in "Category" and "Post Tag" taxonomies to WordPress "pages" post type
* Author: Franz Josef Kaiser <weocodemore@gmail.com>
* Author URL: http://unserkaiser.com
* License: GPL v3
*/
@franz-josef-kaiser
franz-josef-kaiser / rules.md
Created February 18, 2013 07:46
Submission rules for the *Google+ WordPress*-Community. This is the first draft and this description will change as well as the files contents. Come back on a regular basis to check for updates and leave your thoughts in the comments or make a fork (so people can follow your draft) and leave your changes there.

Submission rules for the Google+ WordPress-Community

  • Theme/Plugin promotion advertising themes and plugins are not allowed, discussion of themes and plugins is allowed.
  • Hosting questions - Not specific to WordPress, never useful, attracts affiliate links.
  • Affiliate links in comments. We used to let this slide but lately there have been to many so they won't be allowed at all.
  • What.. theme questions Posts to non WordPress sites asking if there are any themes that "look like it". Posts asking for "good" themes without actually listing features. These are really "do my work for me" posts and provide no discussion.
  • CSS/HTML question The questions usually have nothing to do with WordPress
  • Top 10 lists 90% of top ten lists are seo junk, we will remove the bad ones so please report top ten submissions for removal if they are crappy.
  • Googleable questions Sometimes a question is just so simple that Google is just a step away, though the question has to be blatantly poor. We will rely on the com
@franz-josef-kaiser
franz-josef-kaiser / wpse67107_restrict_upload.php
Created February 26, 2013 10:39
Restrict the maximum file size as well as the maximum allowed resolution for images uploaded to WordPress.
<?php
/**
* Plugin Name: (#67107) »kaiser« Restrict file upload via image dimensions
*/
function wpse67107_restrict_upload( $file )
{
$file_data = getimagesize( $file );
// Abort when we can't get any info:
if ( ! $file_data )
@franz-josef-kaiser
franz-josef-kaiser / wpm_vie_settings_field.class.php
Last active December 14, 2015 08:28
Example Plugin to show how to add a numeric/integer media settings field.
<?php
/**
* Plugin Name: (WPM Vienna) Numeric Media Settings field
* Description: Example Plugin to show how to add a numeric/integer media settings field.
* Author: Franz Josef Kaiser
* Author URl: http://unserkaiser.com
* Plugin URl: https://github.com/wecodemore/wcm_limitor
* Version: 1.0
* License: MIT
*
@franz-josef-kaiser
franz-josef-kaiser / debug_register_pt_args.class.php
Last active December 14, 2015 10:18
Shows the arguments of a newly registered post type right after it was registered. Helps inspecting which defaults have been added by core and if one of the developers arguments got overwritten. Simply add `&debug_pt_args=true` to your URL and set `WP_DEBUG` to `TRUE`.
<?php
defined( 'ABSPATH' ) OR exit;
/**
* Plugin Name: (WCM) Debug Register Post Type Args
* Description: Shows the arguments of a newly registered post type right after it was
* registered. Helps inspecting which defaults have been added by core and if
* one of the developers arguments got overwritten. Simply add
* <code>&debug_pt_args=true</code> to your URL and set
* <code>WP_DEBUG</code> to <code>TRUE</code> in your <code>wp-config.php</code>.
* Plugin URl: http://wordpress.stackexchange.com/questions/89066