Category Archives: WordPress

How I tried to fix “Suggested maximum image size is 2560 pixels” error in WordPress

While uploading an image I got:

(more…)

Installed Post Password Token WordPress plugin

When the user enters a page or post password WordPress sets wp_postpass_XXXX cookie:

Use chrome://settings/cookies/detail?site=developernote.com to see the cookies in Google Chrome browser.

(more…)

How to publish a WordPress post

Login to WordPress admin panel, select Posts on the left sidebar and create new post:

(more…)

Making SyntaxHighlighter plugin display “>” symbol correctly.

My SyntaxHighlighter plugin started to display “>” as “ = & g t ;” after I updated my WordPress to a version where blocks were added. To fix the plugin I added the following line to wp-content/plugins/syntaxhighlighter/syntaxhighlighter.php:

$code = preg_replace( '#<pre [^>]+>([^<]+)?</pre>#', '$1', $content );

// Undo escaping done by WordPress
$code = htmlspecialchars_decode( $code );

return $this->shortcode_callback( $attributes, $code, 'code' );
(more…)

Adding footers and meta tags to WordPress posts

Adding post footer

There are a lot of plugins for adding footers to WordPress posts and one of them is so called “Add Post URL” plugin written by some Chinese guys. From my perspective, its benefits includes macros support and ability to decide whether or not to display the footer for each post individually. It worked fine for me and I even improved it a little bit. The following code snippet shows how I added “post_id” macro:

$footer_text = $posturl_options['footer_text'];
$footer_text = trim($footer_text);
if (!empty($footer_text))
{
    //remove_filter( 'the_content', 'wpautop' );
    
    $post_id = get_the_ID();
    
    $footer_text = str_replace("%post_id%", $post_id, $footer_text);
    $footer_text = str_replace("%site_url%", site_url('/'), $footer_text);
    $footer_text = str_replace("%site_name%", get_bloginfo('sitename'), $footer_text);
    $footer_text = str_replace("%post_url%", get_permalink(), $footer_text);
    $footer_text = str_replace("%post_title%", the_title('', '', false), $footer_text);
    $footer_text = stripslashes($footer_text);
    $text .= $footer_text;
}

(more…)

Getting WordPress multisite work with Windows Live Writer

Windows Live Writer is configured for working with WordPress multi-site the same way as with normal single-site WordPress installation, but WordPress works a bit differently in multi-site and single-site configurations. The difference consists in a few lines of code in wp-includes/class-wp-xmlrpc-server.php:

function wp_getUsersBlogs( $args ) {
    global $current_site;
    // If this isn't on WPMU then just use blogger_getUsersBlogs
    if ( !is_multisite() ) {
        array_unshift( $args, 1 );
        return $this->blogger_getUsersBlogs( $args );
    }

    //single-site verion...
}

(more…)

Getting WordPress Syntax Highlighter work

WordPress has a very nice plugin called SyntaxHighlighter Evolved based on JavaScript package written by Alex Gorbatchev.

To make it work with Widows Live Writer I commented out a line of code in wp-includes/kses.php that installs some filter:

function kses_init_filters() {
	// Normal filtering.
	add_filter('pre_comment_content', 'wp_filter_kses');
	add_filter('title_save_pre', 'wp_filter_kses');

	// Post filtering
	//add_filter('content_save_pre', 'wp_filter_post_kses');
	add_filter('excerpt_save_pre', 'wp_filter_post_kses');
	add_filter('content_filtered_save_pre', 'wp_filter_post_kses');
}