Skip to content

Instantly share code, notes, and snippets.

View engelen's full-sized avatar

Jesper van Engelen engelen

  • Leiden, The Netherlands
View GitHub Profile
<?php
add_filter( 'cac/column/value', 'myplugin_column_value', 10, 4 ); // All columns for all content types
function myplugin_column_value( $value, $object_id, $column, $storage_type ) {
// Possibly modify $value
return $value;
}
?>
<?php
add_filter( 'cac/column/value/user', 'myplugin_users_column_value', 10, 4 ); // Columns on the user overview page
add_filter( 'cac/column/value/page', 'myplugin_posttype_page_column_value', 10, 4 ); // Columns on the page overview
?>
<?php
add_filter( 'cac/column/value', 'myplugin_cac_column_featured_image_value', 10, 4 );
function myplugin_cac_column_featured_image_value( $value, $postid, $column, $post_type ) {
if ( $column->properties->type == 'column-featured_image' ) {
if ( ! $value ) {
$value = '<em>' . __( 'No featured image', 'myplugin' ) . '</em>';
}
}
<?php
add_filter( 'cac/column/meta/value', 'myplugin_cac_column_format_numbers', 10, 3 );
function myplugin_cac_column_format_numbers( $value, $postid, $column, $post_type ) {
$numval = floatval( $value );
if ( $value == $numval ) {
$value = number_format_i18n( $numval, 2 );
}
<?php
add_filter( 'cac/column/meta/value', 'myplugin_column_meta_value', 10, 4 ); // Meta (custom field) columns for all content types
function myplugin_column_meta_value( $value, $object_id, $column, $storage_type ) {
// Possibly modify $value
return $value;
}
?>
<?php
add_filter( 'cac/settings/tabs', 'myplugin_cac_settings_tabs' );
function myplugin_cac_settings_tabs( $tabs ) {
// Possibly modify $tabs
return $tabs;
}
?>
<?php
add_filter( 'cac/settings/tabs', 'myplugin_cac_settings_tabs' );
/**
* Add the tab
*/
function myplugin_cac_settings_tabs( $tabs ) {
// Add a tab to the list of Admin Columns settings tabs
$tabs['myplugin-information'] = __( 'Am I a wizard?', 'myplugin_textdomain' );
<?php
add_filter( 'cac/settings/tab_contents/tab=[tabid]', 'myplugin_cac_tab_contents_mytab' ); // Only the [tabid] tab
?>
<?php
add_filter( 'cac/settings/tab_contents', 'myplugin_cac_tab_contents', 10, 2 ); // All tabs
?>
@engelen
engelen / myplugin.php
Last active August 29, 2015 14:03
Code is poetry. An implementation of a plugin class structure that allows you to access a plugin class instance without using singletons and without storing a reference to the instance in the global namespace.
<?php
/*
Plugin Name: My Plugin
*/
/**
* Main plugin class
*/
class MyPlugin {