Append code into wp-config.php

This commands prepends a line at the beggining of yourfile sed -i 1i”define(‘WP_CACHE’, true);” yourfile To look for many files named wp-config.php and prepend the same text, type this in the shell: for i in $(find . -name wp-config.php) do sed -i 1i”define(‘<?php WP_CACHE’, true); ?>” $i done Run this from the main folder where … Read more

Real time Duplicate title check

You can hook ‘save_post’ or ‘wp_insert_post’ (both executed the same in wp_insert_post()) to check for autosaves and notify the author(s) accordingly. The checks that I would do would be to check that the author of the autosave (aka, revision) and the new autosave are not the same, check that the post title is the same … Read more

WordPress admin never finishes saving page on site with large page count

Have you tried optimizing and repairing the table in your MySQL database you are running WordPress on? Your can manually do this with phpmyadmin: http://support.hostgator.com/articles/specialized-help/technical/how-to-optimize-a-mysql-database-using-phpmyadmin Or you can install a WordPress plugin such as WP Database Optimizer and set a regular optimization schedule: http://wordpress.org/extend/plugins/wp-database-optimizer/

Debugging upload problem: What part of WP does actual image-resizing?

You can add a filter to wp_image_editors and see what editor is in use (GD or Imagick). In a past project I’ve extended the resize routines on both GD, and Imagick, and the methods responsible for resize are WP_Image_Editor_Imagick->crop() and WP_Image_Editor_GD->_resize(). Note that WP_Image_Editor_GD->resize() is just a wrapper. The process it’s run on ajax, but … Read more

Listing all capabilities in dropdown is returning boolean

Solved with this Answer at Stack Overflow. Each Array Key was the actual name of the capability […] You were searching for the capabilities by name, and since you were only seeing 1s in the output, I figured what you were looking for was in the keys. foreach($capslist as $cap=>$caps){ $dropdown .= ‘<option value=”‘.$cap.'”>’.$cap.'</option>’; }

Add Incrementing ID to each paragraph in the_content

If I understand your question correctly, you can try the following: add_filter( ‘the_content’, ‘incrementparagraphs’, 10, 1 ); function incrementparagraphs( $content ) { return preg_replace_callback( ‘|<p>|’, function ( $matches ) { static $i = 0; return sprintf( ‘<p data-section-id=”%d”>’, $i++ ); }, $content ); } to replace every <p> tags with <p data-section-id=”1″>, where the data-section-id … Read more

Custom HTML structure in wp_list_categories

In case someone finds this someday I was able to solve this and I used tis walker: class Navigation_Catwalker extends Walker_Category { // Configure the start of each level function start_lvl(&$output, $depth = 0, $args = array()) { $output .= “”; } // Configure the end of each level function end_lvl(&$output, $depth = 0, $args … Read more