Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Plugin Name: Test plugin
Plugin URI:
Description: Test plugin
Version: 1.0
Author: khromov
Author URI:
License: GPL2
//Change the “Enter title here” placeholder text for new posts
function enter_title_filter($title, $post) {
return __('Your own enter title here text');
add_filter('enter_title_here', 'enter_title_filter', 10, 2);
//Change the post updated, published, trashed messages
function post_updated_messages_filter($messages) {
//Get the current post
global $post;
$post_url = get_permalink($post->ID);
//print_r($messages); <- in case you want to check content of $messages
$messages['post'][1] = __("Your own post updated message! Woo!") . " <a href='{$post_url}'>". __('View post') ."</a>";
return $messages;
add_filter('post_updated_messages', 'post_updated_messages_filter');
//Filter content of the post editor
function post_editor_filter($content) {
if($content == '')
return _('Adding my own content for new posts!') . $content;
return $content;
add_filter('the_editor_content', 'post_editor_filter');
//Rearrange admin menu order
//Move the settings menu to the top, just because we can!
function rearrange_admin_menu_filter($menu_order) {
//Unset current position of options menu
foreach($menu_order as $key => $value) {
if($value == 'options-general.php');
//Add the Options menu again at the top
array_unshift($menu_order, 'options-general.php');
return $menu_order;
add_filter('custom_menu_order', '__return_true');
add_filter('menu_order', 'rearrange_admin_menu_filter', 10, 2);
//Hide admin meta boxes by default
function change_default_hidden( $hidden, $screen ) {
//This is the <div id="X"> value in the admin HTML code.
$hidden[] = 'postimagediv';
return $hidden;
add_filter( 'default_hidden_meta_boxes', 'change_default_hidden', 10, 2 );
//Modifying post content on the frontend
function the_content_filter($content) {
return __('<strong>Prepending stuff to the_content! </strong>') . $content;
add_filter('the_content', 'the_content_filter', 10, 1);
//Adding classes to body and post wrappers
function body_class_filter($classes) {
$classes[] = 'my-class';
return $classes;
add_filter('body_class', 'body_class_filter', 10, 1);
//Changing the length of post excerpts
function post_excerpt_filter($number) {
echo "wat";
return 20;
add_filter('excerpt_length', 'post_excerpt_filter', 10, 1);
//Modifying the request
function request_filter($query_vars) {
//Warning: Will redirect every request to a page with the slug sample-page
//$query_vars['pagename'] = 'sample-page';
return $query_vars;
add_filter('request', 'request_filter', 10, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.