Wp bug user’s old comments email address change after user email update


Issue: When user change his profile email address thats time not change on his comments email address which user have added. so when admin and other reply on comment so reply send on old email address. More info:

In wordpress user comments with email address changes issue fixed with this code when user profile email changed.

so just add this hook code on your function.php

function user_profile_update($user_id) {
$commentarr = array();
global $wpdb;

if( !current_user_can( ‘edit_user’, $user_id ) ){
return false;
}

if(isset($_POST[’email’])):
$email = esc_attr($_POST[’email’]);
$wpdb->query(“UPDATE $wpdb->comments SET comment_author_email=’$email’ WHERE user_id=$user_id”);
endif;
}
add_action(‘personal_options_update’,’my_profile_update’, 10,2);
add_action(‘profile_update’, ‘user_profile_update’, 10,2);

Development bump issue fixed

Get Taxonomy categories of custom post type


<?php
	$customPostTaxonomies = get_object_taxonomies('news');
	
	//ex.(news) Add your custom post type name 
	
	if(count($customPostTaxonomies) > 0){
		foreach($customPostTaxonomies as $tax){
			$args = array(
				 'orderby' => 'name',
				 'show_count' => 0,
				 'pad_counts' => 0,
				 'hierarchical' => 1,
				 'taxonomy' => $tax,
				 'title_li' => ''
			);
			wp_list_categories( $args );
		}
	}
?>

NOTE: wp_list_categories() works in much the same way as the two template tags replaced in WordPress 2.1, list_cats() and wp_list_cats() (both deprecated).

Galleria Classic onclick thumbnail open in lightbox


Galleria Classic onclick thumbnail slide after open in lightbox using jquery.

Galleria Classic Slider Demo

<script type="text/javascript">
//<![CDATA[
	var flag = false;
    $j('#galleria').galleria({
        responsive: true,
            lightbox: true,
            swipe: true,
            extend: function(){
                this.bind('image', function(e) {
                       if(flag == true){
                           this.openLightbox(this.getIndex());
                       }else{
			              flag = true;
                     }
                });         
            }
    });
//]]>

</script>

More info to Go hear

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 );
	?>

Magento validation class


Magento form validation, text validation, url validation

Most important thing besides assigning class names to form in magento is that little piece of JavaScript below the form. Remember to pass form id into the new VarienForm object.

Basically that’s it. Constructing the form this way, automatically makes your form reuse already existing validation code, the one that the rest of the shop is using.

Below is a full list of validate class and its error message that I found in prototype lib.

* validate-select

Please select an option.

* required-entry

This is a required field.

* validate-number

Please enter a valid number in this field.

* validate-digits

Please use numbers only in this field. please avoid spaces or other characters such as dots or commas.

* validate-alpha

Please use letters only (a-z or A-Z) in this field.

* validate-code

Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter.

* validate-alphanum

Please use only letters (a-z or A-Z) or numbers (0-9) only in this field. No spaces or other characters are allowed.

* validate-street

Please use only letters (a-z or A-Z) or numbers (0-9) or spaces and # only in this field.

* validate-phoneStrict

Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890.

* validate-phoneLax

Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890.

* validate-fax

Please enter a valid fax number. For example (123) 456-7890 or 123-456-7890.

* validate-date

Please enter a valid date.

* validate-email

Please enter a valid email address. For example johndoe@domain.com.

* validate-emailSender

Please use only letters (a-z or A-Z), numbers (0-9) , underscore(_) or spaces in this field.

* validate-password

Please enter 6 or more characters. Leading or trailing spaces will be ignored.

* validate-admin-password

Please enter 7 or more characters. Password should contain both numeric and alphabetic characters.

* validate-cpassword

lease make sure your passwords match.

* validate-url

Please enter a valid URL. http:// is required

* validate-clean-url

Please enter a valid URL. For example  https://cmsblogheart.wordpress.com or cmsblogheart.wordpress.com

* validate-identifier

Please enter a valid Identifier. For example example-page, example-page.html or anotherlevel/example-page

* validate-xml-identifier

Please enter a valid XML-identifier. For example something_1, block5, id-4

* validate-ssn

Please enter a valid social security number. For example 123-45-6789.

* validate-zip

Please enter a valid zip code. For example 90602 or 90602-1234.

* validate-date-au

Please use this date format: dd/mm/yyyy. For example 17/03/2006 for the 17th of March, 2006.

* validate-currency-dollar

Please enter a valid $ amount. For example $100.00.

* validate-one-required

Please select one of the above options.

  * validate-one-required-by-name

Please select one of the options.

  * validate-not-negative-number

Please enter a valid number in this field.

* validate-state

Please select State/Province.

* validate-new-password

Please enter 6 or more characters. Leading or trailing spaces will be ignored.

* validate-greater-than-zero

Please enter a number greater than 0 in this field.

  * validate-zero-or-greater

Please enter a number 0 or greater in this field.

* validate-cc-number

Please enter a valid credit card number.

* validate-cc-type

Credit card number doesn\’t match credit card type

* validate-cc-type-select

Card type doesn\’t match credit card number

* validate-cc-exp

Incorrect credit card expiration date

    * validate-cc-cvn

Please enter a valid credit card verification number.

* validate-data

Please use only letters (a-z or A-Z), numbers (0-9) or underscore(_) in this field, first character should be a letter.

* validate-css-length

Please input a valid CSS-length. For example 100px or 77pt or 20em or .5ex or 50%

* validate-length

Maximum length exceeded.

Magento Custom Page Templates using Xml


In Magento it is possible to create more page templates than the traditional 1-column, 2-columns-left (etc) options that we’re given by default. These page templates are defined in XML configuration, which means to add others you’ll need to create a module with config.xml.

In the below example I’ll create a custom page template for my CMS homepage.

app/code/local/Rv/Layouts/etc/config.xml

<config>
  <global>
    <page>
      <layouts>
        <homepage_layout translate="label">
          <label>Homepage Layout</label>
          <template>page/homepage.phtml</template>
        </homepage_layout>
      </layouts>
    </page>
  </global>
</config>

After doing this, simply create homepage.phtml within your theme template’s ‘page’ directory. To declare your module’s existence, don’t forget your module activation file:

app/etc/modules/Rv_Layouts.xml


<config>
  <modules>
    <Rv_Layouts>
      <active>true</active>
      <codePool>local</codePool>
    </Rv_Layouts>
  </modules>
</config>

Following this, you will now have ‘Homepage Layout’ as an available page template for

products, CMS pages, categories and so on.

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.