Tag Archives: wordpress

Fix – Notice: get_currentuserinfo is deprecated since version 4.5


Just find in plugin or theme directory with text get_currentuserinfo and replace with wp_get_current_user()

Because of deprecated function get_currentuserinfo and arrived new function _wp_get_current_user() Since: WordPress 4.5.0

function get_currentuserinfo() {
_deprecated_function( __FUNCTION__, '4.5', 'wp_get_current_user()' );
return wp_get_current_user();
}

More info

Post save twice during use hook add_action(save_post)


Now I recognize on my plugin, that if I save the post_save hook on call curl function to send data it writes 2 entries on my server. so using this code to fixed.

         <?php
               global $my_save_post_flag;
                       // .. some stuff here ..
               if ($my_save_post_flag == 0) {
                      // .. do the stuff only once i have add my curl code hear ..
               }  
                     // .. continue your stuff ..
               $my_save_post_flag = 1;
        ?>

More Info to stack

WordPress 3.9 Features


WordPress users more futures Added on wordpress new version 3.9 this releases date official It’s April 16.

At that time Lattest Worrdpress 3.9 in includes more than 200 changes, including with this Futures:

changes_progress

Updated Visual Editor Options.

TinyMCE was updated to the latest version. For the uninitiated, TinyMCE is an open-source, platform-independent, web-based Javascript HTML WYSIWYG editor that powers the Visual Editor on WordPress. The update made it possible for them to remove the “Paste from Word” button. It’s said that the visual editor will handle copy paste from Microsoft Word with more grace, and will add much cleaner HTML markup.

Include Horizontal Line Options.

live widget previews And Header Image Editor on Customize option.

Widgets offer an easy way to customize you sidebars and footer on you WordPress site. When you go into Appearance >> Themes >> Customize in WordPress 3.9, you have the option to see live preview for widgets. When you click on “Add A Widget”, a new menu slides out where you can search for a widget, and you can see the widget in action before you push it live on your site.

widget customizer
header_image editor

New theme installer Visually Appealing with Filter options

New theme installer display theme list with Featured,Popular,Latest, And
Feature Filter options.

Feature Filter to use you can diplay your filter for theme list you can apply for theme with customize and you can see the Slected theme demo on your theme.

themebrowsing

Drag and Drop Media in Visual Editor.

Now ALttest futured drag and drop images From your directory to visual editor. After drag and drop images upload image on your media and post.

drag_and_Drop_media

Live Gallery Preview in Visual Editor

HTML5 caption support to match the new gallery support.

After Add Gallery on your post to diaply simple gallery in the visual editor.

live_gallery_visual_editor

Audio and Video Playlist options

You can create your audio and video playlists within WordPress. You can access this when you go to the Insert Media screen option.

audio_and_video_playlist
audio_playlist
plalist_on post_view

Improved Image Editing Options

You can edit your images from while working on your post. without leave the page and post open image editing controls.

improved_image_editing

Search box on Navigation Menu


Using This code add the default search box on main navigation menu that will save the space and flexibly fit with the menu.

// Add this code on your theme Function.php
function menu_search($items){
  $search = '<li class="search">';
  $search .= '<form method="get" id="searchform" action="'.site_url().'/">';
  $search .= '<input type="text" class="field" name="s" id="s" value="'.get_search_query().'" placeholder="Search" />';
  $search .= '</form>';
  $search .= '</li>';
  return $items . $search;
}
add_filter('wp_nav_menu_items','menu_search');

WordPress Custom Post Type


Suppose you want your blog to have a separate section so Use This code genearte your separate custom post.

My ‘post_type’=>’blogheart’ if you want to change replace with your value.

Let’s Create a Custom Post Type

Here we shall create a custom post type plugin which will display favorite movie reviews. Lets get started.

  • Step 1: Create directory in your theme ‘blogheart’.
  • Step 2: Create PHP File ‘blogheart-post-type.php’ at below define code.
  • Step 3: open function.php.

    Add This code in function.php

    			require_once (TEMPLATEPATH . '/blogheart/blogheart-post-type.php');
    		
	<?php 

	add_action( 'init', 'register_cpt_blogheart' );

	function register_cpt_blogheart() {

		$labels = array( 
			'name' => _x( 'Blog Heart', 'blogheart' ),
			'singular_name' => _x( 'blogheart', 'blogheart' ),
			'add_new' => _x( 'Add New', 'blogheart' ),
			'add_new_item' => _x( 'Add New blogheart', 'blogheart' ),
			'edit_item' => _x( 'Edit blogheart', 'blogheart' ),
			'new_item' => _x( 'New blogheart', 'blogheart' ),
			'view_item' => _x( 'View blogheart', 'blogheart' ),
			'search_items' => _x( 'Search Blog Heart', 'blogheart' ),
			'not_found' => _x( 'No blog heart found', 'blogheart' ),
			'not_found_in_trash' => _x( 'No blog heart found in Trash', 'blogheart' ),
			'parent_item_colon' => _x( 'Parent blogheart:', 'blogheart' ),
			'menu_name' => _x( 'Blog Heart', 'blogheart' ),
		);

		$args = array( 
			'labels' => $labels,
			'hierarchical' => true,
			'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes' ),
			'public' => true,
			'show_ui' => true,
			'show_in_menu' => true,
			'show_in_nav_menus' => true,
			'publicly_queryable' => true,
			'exclude_from_search' => false,
            'menu_icon' => 'http://0.gravatar.com/blavatar/ad954c75259323ec69b56683eb96ae42?s=16',
			'has_archive' => true,
			'query_var' => true,
			'can_export' => true,
			'rewrite' => true,
			'capability_type' => 'post'
		);

		register_post_type( 'blogheart', $args );
	?>

Changing Permalinks for Pages (%pagename%)


WordPress defaultPage permalink structure: /%pagename%

https://www.yourweb.com/pagenamexyz/

But you wanted to make pages structure like:

If you want to change it to be just /pagenamexyz.html, you could use something like ‘%pagename%.html’ and so on.

https://www.yourweb.com/pagenamexyz.html/ using %pagename.html%
https://www.yourweb.com/pages/pagenamexyz/ using pages/%pagename.html%
https://www.yourweb.com/mypages/pagenamexyz.html/ using mypages/%pagename.html%

So Put this code in your functions.php file.

add_action( 'init', 'custom_page_rules' );
	function custom_page_rules() {
		global $wp_rewrite;
		$wp_rewrite->page_structure = $wp_rewrite->root . 'page/%pagename%.html';
	}

If you have any feedback or questions about this code so define below comment.