Contact Form 7 Phone Number Validation

========================= contact-form-7/modules/text.php

insert this code:

wpcf7_add_shortcode( 'digit', 'wpcf7_text_shortcode_handler', true );
wpcf7_add_shortcode( 'digit*', 'wpcf7_text_shortcode_handler', true );

after this:

wpcf7_add_shortcode( 'email*', 'wpcf7_text_shortcode_handler', true );

insert this code:

if ( 'digit' == $type || 'digit*' == $type )
$class_att .= ' wpcf7-validates-as-digit';

after this:

if ( 'text*' == $type || 'email*' == $type )
$class_att .= ' wpcf7-validates-as-required';

insert this code:

add_filter( 'wpcf7_validate_email*', 'wpcf7_text_validation_filter', 10, 2 );
add_filter( 'wpcf7_validate_digit*', 'wpcf7_text_validation_filter', 10, 2 );

after this:

add_filter( 'wpcf7_validate_email', 'wpcf7_text_validation_filter', 10, 2 );

insert this code:


if ( 'digit' == $type || 'digit*' == $type ) {
if ( '' == $_POST[$name] ) {
$result['valid'] = false;
//$result['reason'][$name] = $wpcf7_contact_form->message( 'invalid_required' );
$result['reason'][$name] = wpcf7_get_message( 'invalid_required' );
} elseif ( '' != $_POST[$name] && ! is_telnum( $_POST[$name] ) ) {
$result['valid'] = false;
//$result['reason'][$name] = $wpcf7_contact_form->message( 'invalid_digit' );
$result['reason'][$name] = wpcf7_get_message( 'invalid_digit' );
}
}

after this if code:

if ( 'email' == $type || 'email*' == $type ) {
if ( 'email*' == $type && '' == $_POST[$name] ) {
$result['valid'] = false;
$result['reason'][$name] = $wpcf7_contact_form->message( 'invalid_required' );
} elseif ( '' != $_POST[$name] && ! is_email( $_POST[$name] ) ) {
$result['valid'] = false;
$result['reason'][$name] = $wpcf7_contact_form->message( 'invalid_email' );
}
}

================== contact-form-7/includes/functions.php to add the error message for the telephone number validation.

insert this code:

'invalid_digit' => array(
'description' => __( "There is a field that sender is needed to fill in with numbers", 'wpcf7' ),
'default' => __( 'Please fill the required field with numbers.', 'wpcf7' )
)

after this code:

'invalid_required' => array(
'description' => __( "There is a field that sender is needed to fill in", 'wpcf7' ),
'default' => __( 'Please fill the required field.', 'wpcf7' )
),

===========================wp-includes/formatting.php and create a new function

function is_telnum($telnum)
{
//$regexp = '/^[0-9\+\-]{7,}$/';
//$regexp = '/^[0-9]{1,}/';//numeric
$regexp = '/^[0-9\+\-\)\(\d\s]{7,}$/';

if(preg_match($regexp, $telnum))
return true;
else
return false;
}

=========

Your Phone [digit* text-123]

Free WordPress Plugins List

Below Plugins are some of the free plugins i used in my projects

Contact Form Contact Form7

Sitemap Plugin wp-sitemap,simple sitemap(good)

Support buddypress in any themes BuddyPress Template Pack

Creating/editing,renaming User roles role manger(Best)

Lightbox image Lightbox 2

Best Customizing content Slider Featured articles Lite

Twitter Messages Twitter for WordPress extended

Weather Plugin WPwunderground

Ad manager wp insert

Subscription Subscribe2

youtube Video slider(carousel) CDOKAY TV

Category List In Hierarchical Order inWordpress edit post page(backend) Category Checklist Tree

Video slider with flash Ultimate carousel free Video Gallery, pluginswp.com
To use the slider inside template insert the following code

<?php
$tag= array('[ultimate_carouselfree 1 /]','1');
$output=ultimate_carouselfree_video_render($tag);
echo $output;
?>

Getting All Post In Page With Pagination

functions.php===>

 <?php

function pagination($pages = '', $range = 4)
 {
 $showitems = ($range * 2)+1;

global $paged;
 if(empty($paged)) $paged = 1;

if($pages == '')
 {
 global $wp_query;
 $pages = $wp_query->max_num_pages;
 if(!$pages)
 {
 $pages = 1;
 }
 }

if(1 != $pages)
 {
 echo "<div class=\"pagination\"><span>Page ".$paged." of ".$pages."</span>";
 if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>First</a>";
 if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'> << Previous</a>";

for ($i=1; $i <= $pages; $i++)
 {
 if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
 {
 echo ($paged == $i)? "<span class=\"current\">".$i."</span>":"<a href='".get_pagenum_link($i)."' class=\"inactive\">".$i."</a>";
 }
 }

if ($paged < $pages && $showitems < $pages) echo "<a href=\"".get_pagenum_link($paged + 1)."\">Next >></a>";
 if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>Last</a>";
 echo "</div>\n";
 }
 }

?>

style.css===>


.pagination {
 clear:both;
 padding:20px 0;
 position:relative;
 font-size:11px;
 line-height:13px;
 }

.pagination span, .pagination a {
 display:block;
 float:left;
 margin: 2px 2px 2px 0;
 padding:6px 9px 5px 9px;
 text-decoration:none;
 width:auto;
 color:#fff;
 background: #555;
 }

.pagination a:hover{
 color:#fff;
 background: #3279BB;
 }

.pagination .current{
 padding:6px 9px 5px 9px;
 background: #3279BB;
 color:#fff;
 }

&nbsp;

Template Code(use in index.php)===>


<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
 $args = array( 'post_type' => 'post', 'posts_per_page' => 10, 'paged' => $paged ,'cat' => '4' );
 $wp_query = new WP_Query($args);
 while ( have_posts() ) : the_post(); ?>
 <!-- <h2><?php the_title() ?></h2>--><?php get_template_part('post-type/main'); ?>
 <?php endwhile; ?>

<!-- then the pagination links -->
 <?php next_posts_link( 'Older posts' ); ?>
 <?php previous_posts_link( 'Newer posts' ); ?>

<?php if (function_exists("pagination")) {
 pagination();
 } ?>

Excerpt & Content Limit In WordPress

Add this to functions.php in ur theme directory

 function excerpt($limit) {
 $excerpt = explode(' ', get_the_excerpt(), $limit);
 if (count($excerpt)>=$limit) {
 array_pop($excerpt);
 $excerpt = implode(" ",$excerpt).'...';
 } else {
 $excerpt = implode(" ",$excerpt);
 }
 $excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt);
 return $excerpt;
 }

function content($limit) {
 $content = explode(' ', get_the_content(), $limit);
 if (count($content)>=$limit) {
 array_pop($content);
 $content = implode(" ",$content).'...';
 } else {
 $content = implode(" ",$content);
 }
 $content = preg_replace('/\[.+\]/','', $content);
 $content = apply_filters('the_content', $content);
 $content = str_replace(']]>', ']]&gt;', $content);
 return $content;
 }

use the below code in template wherever u needed


<?php echo excerpt(25); ?>
<?php echo content(300); ?>

Getting All Images From WordPress Post

Function


<?php

function postimage($size=thumbnail, $qty=-1)
{
  if ($images = get_children(array(
         'post_parent' => get_the_ID(),
         'post_type' => 'attachment',
         'numberposts' => $qty,
         'post_mime_type' => 'image')))
       {
        foreach( $images as $image ) 
          {
           $attachmenturl=wp_get_attachment_url($image->ID);
           $attachmentimage=wp_get_attachment_image( $image->ID, $size );
           echo $attachmentimage;
          }
        }
 else {
       echo "No Image";
       }
 } 
?>

Using Function


<?php postimage(array(32,32)); ?>

where 32,32=>image height width