Skip to content

Instantly share code, notes, and snippets.

@kloon
kloon / gist:4228021
Created December 6, 2012 20:25
WooCommerce variations custom field
//Display Fields
add_action( 'woocommerce_product_after_variable_attributes', 'variable_fields', 10, 2 );
//JS to add fields for new variations
add_action( 'woocommerce_product_after_variable_attributes_js', 'variable_fields_js' );
//Save variation fields
add_action( 'woocommerce_process_product_meta_variable', 'variable_fields_process', 10, 1 );
function variable_fields( $loop, $variation_data ) {
?>
<tr>
@thefuxia
thefuxia / t5-custom-logout-url.php
Created December 14, 2012 20:49
T5 Custom Log-out URL Create a custom log-out URL in WordPress.
<?php
/**
* Plugin Name: T5 Custom Log-out URL
* Description: Create a custom log-out URL.
* Plugin URI: http://wordpress.stackexchange.com/questions/76161/masking-logout-url
* Version: 2012.12.14
* Author: Thomas Scholz
* Author URI: http://toscho.de
* Licence: MIT
* License URI: http://opensource.org/licenses/MIT
@franz-josef-kaiser
franz-josef-kaiser / dashboard_widget_recently_edited_files.php
Last active December 10, 2015 01:48
Show the last X recently edited files in a dashboard widget
<?php
defined( 'ABSPATH' ) OR exit;
/**
* Plugin Name: (#64910) (Dashboard Widget) Last edited files
* Description: Lists the last edited files in a dashboard widget
* Author: Franz Josef Kaiser <wecodemore@gmail.com>
* Author URL: https://plus.google.com/107110219316412982437
* License: MIT
*/
@thefuxia
thefuxia / t5-table-size-dashboard-widget.php
Last active December 10, 2015 17:58
T5 Table size dashboard widget Print a list of table sizes into your dashboard.
<?php
/**
* Plugin Name: T5 Table size dashboard widget
* Description: Print a list of table sizes into your dashboard.
* Plugin URI:
* Version: 2013.01.07
* Author: Thomas Scholz
* Author URI: http://toscho.de
* Licence: MIT
* License URI: http://opensource.org/licenses/MIT
@franz-josef-kaiser
franz-josef-kaiser / curl_dump.php
Last active May 22, 2022 14:57
Debug and dump a WordPress cURL Request and it's response during a WP HTTP API call.
<?php
/**
* Plugin Name: Dump WP HTTP API cURL Request & Response
* Author: Franz Josef Kaiser
*/
add_action( 'plugins_loaded', array( 'WPSE81791_cURL', 'init' ) );
class WPSE81791_cURL
{
protected static $instance;
@franz-josef-kaiser
franz-josef-kaiser / sys_bot.php
Last active August 4, 2020 06:29
Creates and maintains the SysBot User (which has the role of "editor"). Purpose of this bot user: You're importing data into a WordPress CustomPostType (for e.g.: via a HTTP request). During import/fetch you need a user who is the author of those CPTs posts. You could go with a fake ID, but this will successfully prevent you to use taxonomies, a…
<?php
defined( 'ABSPATH' ) OR exit;
/**
* Plugin Name: SysBot
* Description: Creates and maintains the SysBot User (which has the role of "editor")
* Author: Franz Josef Kaiser
*/
# PUBLIC API #
function get_bot()
@mbijon
mbijon / posts_search_demo.php
Created February 18, 2013 18:48
WordPress posts_search filter example, for Tom Barrett on WP-Hackers list 2013-02-18
function tcb_filter_search( $term ) {
if ( is_search() )
$search = "(($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%'))";
return $search;
}
add_filter( 'posts_search', 'tcb_filter_search', null, 2 );
@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 / 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
@thefuxia
thefuxia / functions.php
Created March 18, 2013 09:49
Count posts in post-format "status".
add_action( 'wp_footer', 'count_statuses' );
function count_statuses()
{
$status = 'status';
$num = get_term_post_count_by_type( "post-format-$status", 'post_format' );
print "<pre>{$status}es: $num</pre>";
}
/**
* Count all post in a term.