Skip to content

Instantly share code, notes, and snippets.

View tobiasschutter's full-sized avatar

Tobias Schutter tobiasschutter

View GitHub Profile
@tobiasschutter
tobiasschutter / acp_get_layouts_by_post_type.php
Last active July 26, 2019 14:57
Admin Columns Pro API method for fetching layouts by post type
<?php
/**
* @param string $post_type
*
* @return \ACP\Layout[]
*/
function acp_get_layouts_by_post_type( string $post_type ) : array {
$list_screen = new \ACP\ListScreen\Post( $post_type );
$layouts = new \ACP\Layouts( $list_screen );
@tobiasschutter
tobiasschutter / acp_get_columns_by_post_type.php
Last active July 26, 2019 14:56
Admin Colums Pro API method for fetching columns by post type
<?php
/**
* @param string $post_type
* @param string|null $layout
*
* @return \AC\Column[]
*/
function acp_get_columns_by_post_type( string $post_type, string $layout = null ): array {
$list_screen = new \ACP\ListScreen\Post( $post_type );
@tobiasschutter
tobiasschutter / class-mla-admin-columns-support.php
Last active January 25, 2018 13:45
class-mla-admin-columns-support.php for ACP 4.2
<?php
/**
* Media Library Assistant Admin Columns (plugin) Support
*
* @package Media Library Assistant
* @since 2.50
*/
defined( 'ABSPATH' ) or die();
if ( class_exists( 'ACP_Editing_Strategy' ) ) {
@tobiasschutter
tobiasschutter / search_user_custom_fields.php
Last active February 2, 2016 18:23
Add custom fields for users to the search in the wp-admin
<?php
/**
* Add custom fields for users to the search in the wp-admin
*/
function codepress_search_user_custom_fields( $user_query ) {
// Fill in the custom fields you want to add to the search
$custom_fields = array(
'my_custom_field_1',
'my_custom_field_2'
@tobiasschutter
tobiasschutter / search_post_custom_fields.php
Last active February 3, 2016 08:00
Add custom fields for posts to the search in the wp-admin
<?php
/**
* Add custom fields for users to the search in the wp-admin
*/
function codepress_search_post_custom_fields( $wp ) {
global $pagenow, $wpdb;
// Fill in the post types that should be used
$post_types = array(
'post',
@tobiasschutter
tobiasschutter / send-mail-with-mandrill-template.php
Last active October 8, 2021 16:50
send-mail-with-mandrill-template
<?php
/**
* Send Mail through Mandrill with Template
*
* See https://mandrillapp.com/api/docs/index.php.html
*
* @param string $to_email Email Reciever
* @param string $to_name Name Receiver
* @param string $subject Mail subject
* @param string $message HTML message ( allowed ul, p, h1 )
@tobiasschutter
tobiasschutter / maintenance.html
Last active May 8, 2017 14:32
Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
<?php
// source: http://www.wprecipes.com/list-all-hooked-wordpress-functions
function list_hooked_functions($tag=false){
global $wp_filter;
if ($tag) {
$hook[$tag]=$wp_filter[$tag];
if (!is_array($hook[$tag])) {
trigger_error("Nothing found for '$tag' hook", E_USER_WARNING);
return;
}