Some times need to add custom classes in wordpress tinymce editor. This is simple solution to do this:

add_filter('tiny_mce_before_init', 'oi_tinymce');
function oi_tinymce($settings) {
	$new_styles = array(
		array(
			'title' => 'None',
			'value'	=> ''
		),
		array(
			'title'	=> 'Table',
			'value'	=> 'table',
		),
	);
	$settings['table_class_list'] = json_encode( $new_styles );
	return $settings;
}

Below I’ll give you some examples on how you can extend the functionality of the TinyMCE.

Adding Font Size & Font Family Selects

By default the Custom Fonts and font sizes are not added into the TinyMCE editor. The function below will add both of these dropdowns to the far left of the editor in the second row. Simply change where it says ‘mce_buttons_2′ if you want it in a different row (ex: use ‘mce_buttons_3′ for the 3rd row).

if ( ! function_exists( 'wp_mce_buttons' ) ) {
	function wp_mce_buttons( $buttons ) {
		array_unshift( $buttons, 'fontselect' ); // Add Font Select
		array_unshift( $buttons, 'fontsizeselect' ); // Add Font Size Select
		return $buttons;
	}
}
add_filter( 'mce_buttons_2', 'wp_mce_buttons' );

Continue reading

WordPress comes with built-in default RSS feeds. You can tweak the default feeds by adding custom content to your RSS Feeds, or even adding post thumbnail to your RSS Feeds. The default RSS and Atom feeds are enough for most users, but you may wish to create a custom RSS feed for delivering specific type of content. In this article, we will show you how to create custom RSS feeds in WordPress.

Continue reading

Today I will show simple, but simetimes very usefull example, how to remove empty paragrapth from your text.

My code:

<?php
$html = "abc<p></p><p>dd</p><b>non-empty</b>";
$pattern = "/<p[^>]*><\\/p[^>]*>/";
//$pattern = "/<[^\/>]*>([\s]?)*<\/[^>]*>/";  use this pattern to remove any empty tag

echo preg_replace($pattern, '', $html);
// output
//abc<p>dd</p><b>non-empty</b>
?>

Very simple 🙂

Today I found very usefull function, witch let to remove (disable) menu in wordpress admin. Its remove_menu_page( $menu_slug ) and remove_submenu_page( $menu_slug, $submenu_slug ).

It’s easy to remove menu entries and it is not necessary anymore to edit wordpress core. This is a small example, where I removed the entries to the comments and the submenu-page discussion.

Copy this example to function.php, and you will see, that it work.

function remove_admin_menu () {
	
		remove_menu_page( 'edit-comments.php' );
		remove_menu_page( 'link-manager.php' );
		remove_menu_page( 'tools.php' );
		remove_submenu_page( 'options-general.php', 'options-discussion.php' );
	
}
add_action( 'admin_menu', 'remove_admin_menu' );

This function will disable comments, links, ant tools menu.

With WordPress, you have the ability to create a network of sites (Multisite). This article is instructions for creating a network (multiple sites).

  1. First of all if you are running not fresh wordpress system, make back up off all you data.
  2. Open your config.php file and paste this above where it says /* That's all, stop editing! Happy blogging. */:
    <define('WP_ALLOW_MULTISITE', true);

    This allow to use multiple sites in your wordpress.

  3. Now install a network. Go to Administration > Tools > Network. Enter all required data ant press install.
    • Back up your old wp-config.php and .htaccess files.
    • Create blogs.dir directory in folder wp-content/
    • Add extra lines to your wp-config.php and replace your .htaccess file rules with new once. These rules are dinamically generated on your network configuration page.
    • Now log in again to system.

More information about this you can find in http://codex.wordpress.org/Create_A_Network.