How to send pdf file attachment to user using contact form 7

Here is code to send pdf file attachment to user using contact form 7.

function send_pdf( $cf7 ) {
	$id = $cf7->id();
	if ($id==1076){
		$submission = WPCF7_Submission::get_instance();
		$posted_data = $submission->get_posted_data();
		$tdsfileurl = $posted_data['tdsfile'];
		$tdsproductname = $posted_data['productname'];
		$explode = explode("/", $tdsfileurl);
		$end = '';
		$begin = '';
		if(count($explode) > 0){
			$end = array_pop($explode); // removes the last element, and returns it
			if(count($explode) > 0){
				$begin = implode('/', $explode); // glue the remaining pieces back together
			}
		}
		$t=time();
		$hostname = $_SERVER['HTTP_HOST'];
		$newfile2 = explode($hostname, $begin);
		$newfile = $_SERVER['DOCUMENT_ROOT'] . '' .$newfile2['1'].'/' .$tdsproductname.'_TDS_'.$t.'.pdf';
		error_log('$tdsfileurl: ' . $tdsfileurl);
		error_log('$newfile: ' . $newfile);
		if ( copy($tdsfileurl, $newfile) ) {
			error_log('File copied');
			$submission->add_uploaded_file('pdf', $newfile);
		}else{
			error_log('Not able to attche file');
		}


	}
}
add_action('wpcf7_before_send_mail','send_pdf');

1076 is contact form 7 ID and tdsfile form field is having PDF url form local server (http://localhost:90/pidi/wp-content/uploads/2015/09/test.pdf) which i want to send as attachment.

How to display selected category names of custom post type in wordpress

Here is code snippet to display selected category names of custom post type in wordpress.

To get the categories of a custom post type you have call get_the_terms() and setup the registered category name like this

<?php
$terms = get_the_terms( $post->ID , 'myposttype_category' );
foreach ( $terms as $term ) {
  echo $term->name;
}
?>

WordPress website are at 25% market share

Now wordpress takend 25 % of market share as per Web technology surveys http://w3techs.com/technologies/history_overview/content_management/all/y

WordPress website are at 25 percentage market share

In 2003 Matt Mullenweg and Mike Little fork b2 and created WordPress.
As wordpress freelancer we seen tremendous growth in wordpress usage since 2011.
Three main aspect of wordpress is Its Lightweight, Simple User & SEO friendly.

Historical yearly trends in the usage of content management systems for websites

This report shows the historical trends in the usage of content management since January 2011.

2011
1 Jan
2012
1 Jan
2013
1 Jan
2014
1 Jan
2015
1 Jan
2015
9 Nov
None 76.4% 71.0% 68.2% 64.8% 61.7% 57.4%
WordPress 13.1% 15.8% 17.4% 21.0% 23.3% 25.0%
Joomla 2.6% 2.8% 2.8% 3.2% 2.9% 2.8%
Drupal 1.4% 1.9% 2.3% 1.9% 2.0% 2.1%
Magento 0.9% 1.1% 1.2%
Blogger 0.6% 0.9% 1.1% 1.2% 1.1% 1.2%
TYPO3 0.6% 0.6% 0.7% 0.6% 0.6% 0.7%
Adobe Dreamweaver 0.6%
PrestaShop 0.3% 0.4% 0.5% 0.5%
Bitrix 0.2% 0.3% 0.3% 0.3% 0.4% 0.5%
FrontPage 0.4%
OpenCart 0.3% 0.4%
Shopify  0.1% 0.3% 0.4%
vBulletin 1.4% 1.3% 1.1% 0.5% 0.4% 0.3%
Squarespace <0.1% 0.1% <0.1% 0.1% 0.2% 0.3%
DataLife Engine 0.4% 0.5% 0.5% 0.4% 0.3% 0.3%
DotNetNuke 0.2% 0.2% 0.2% 0.2% 0.2% 0.2%
ExpressionEngine 0.2% 0.3% 0.3% 0.3% 0.2% 0.2%
phpBB 0.4% 0.4% 0.4% 0.3% 0.2% 0.2%
Discuz! 0.4% 0.5% 0.4% 0.3% 0.2% 0.2%
osCommerce 0.4% 0.3% 0.3% 0.2% 0.2%
Bigcommerce 0.1% 0.2%
Wix <0.1% 0.1% 0.1% 0.2%
Weebly  <0.1% 0.1% 0.1% 0.2%
SharePoint 0.2% 0.2% 0.1% 0.1% 0.2%
uCoz 0.1% 0.2% 0.2% 0.1% 0.1%
GitHub Pages 0.1% 0.1% 0.1%
Zen Cart 0.1% 0.1%
XenForo 0.1% 0.1% 0.1%
Tumblr 0.1% 0.1% 0.1% 0.1% 0.1%
Simple Machines Forum 0.2% 0.2% 0.2% 0.1% 0.1% 0.1%
Telerik Sitefinity 0.1% 0.1% 0.1% 0.1% 0.1%
Volusion 0.1%
Concrete5 <0.1% <0.1% <0.1% 0.1% 0.1% 0.1%
Contao <0.1% 0.1% 0.1% 0.1% 0.1% 0.1%
Duda  0.1% 0.1%
SPIP 0.1% 0.1% 0.1% 0.1% 0.1% 0.1%
Kentico <0.1% 0.1% 0.1%
IP.Board 0.1% 0.1% 0.1% 0.1% 0.1% 0.1%
CMS Made Simple 0.1% 0.1% 0.1% 0.1% 0.1% 0.1%
Liferay 0.1% 0.1% 0.1% 0.1% 0.1%
PHP Link Directory 0.6% 0.5% 0.2% 0.1% 0.1%
Jimdo 0.1% 0.1%
CS-Cart 0.1% 0.1%
eZ Publish 0.1% 0.1% 0.1% 0.1% 0.1% 0.1%
Webs <0.1% <0.1% <0.1% <0.1% 0.1%
Dealer.com 0.1%
xt:Commerce 0.1% 0.1% 0.1%
Yahoo! Small Business 0.1% 0.1% 0.1% 0.1% 0.1%
Pligg 0.3% 0.3% 0.1% 0.1% 0.1%
MediaWiki 0.1% 0.1% 0.1% 0.1% 0.1% 0.1%
Movable Type 0.1% 0.1% 0.1% 0.1% 0.1% 0.1%
SilverStripe <0.1% <0.1% <0.1% <0.1% <0.1% 0.1%
MyBB 0.1% 0.1% 0.1% <0.1%
Umbraco 0.1% 0.1% 0.1% <0.1%
XOOPS 0.1% 0.1% 0.1% 0.1% <0.1% <0.1%
Plone 0.1% 0.1% 0.1% <0.1% <0.1% <0.1%
Ektron 0.1% 0.1% 0.1% <0.1% <0.1% <0.1%
GoDaddy Website Builder 0.1% <0.1%
Ning 0.1% 0.1% <0.1% <0.1%
Open Text 0.1% 0.1% 0.1% <0.1% <0.1% <0.1%
PHP-Nuke 0.1% <0.1% <0.1% <0.1% <0.1% <0.1%
TypePad 0.1% 0.1% <0.1% <0.1% <0.1% <0.1%

The diagram shows only content management systems with more than 1% usage.

Visit http://w3techs.com/technologies/history_overview/content_management/all/y to see more detail

WordPress disable all update notification

Here is code to disable WordPress all update notification

function remove_core_updates(){
global $wp_version;return(object) array('last_checked'=> time(),'version_checked'=> $wp_version,);
}
add_filter('pre_site_transient_update_core','remove_core_updates');
add_filter('pre_site_transient_update_plugins','remove_core_updates');
add_filter('pre_site_transient_update_themes','remove_core_updates');

how to edit rel attribute of the_category link in wordpress

Here is hook code for wordpress to  edit rel attribute of the_category link in wordpress

add_filter( 'the_category', 'remove_nofollow_cat' );  
function remove_nofollow_cat( $text ) { 
	$text = str_replace('rel="nofollow"', 'rel="follow"', $text); return $text; 
}

How to display only second level child menu in wordpress

Below is snippet code to display second level menu in wordpress.
Put below php code into your theme/functions.php file

add_filter( 'wp_nav_menu_objects', 'my_wp_nav_menu_objects_sub_menu', 10, 2 );

// filter_hook function to react on sub_menu flag
function my_wp_nav_menu_objects_sub_menu( $sorted_menu_items, $args ) {
if ( isset( $args->sub_menu ) ) {
$root_id = 0;
// find the current menu item
foreach ( $sorted_menu_items as $menu_item ) {
if ( $menu_item->current ) {
// set the root id based on whether the current menu item has a parent or not
$root_id = ( $menu_item->menu_item_parent ) ? $menu_item->menu_item_parent : $menu_item->ID;
break;
}
}
// find the top level parent
if ( ! isset( $args->direct_parent ) ) {
$prev_root_id = $root_id;
while ( $prev_root_id != 0 ) {
foreach ( $sorted_menu_items as $menu_item ) {
if ( $menu_item->ID == $prev_root_id ) {
$prev_root_id = $menu_item->menu_item_parent;
// don't set the root_id to 0 if we've reached the top of the menu
if ( $prev_root_id != 0 ) $root_id = $menu_item->menu_item_parent;
break;
}
}
}
}

$menu_item_parents = array();
foreach ( $sorted_menu_items as $key => $item ) {
// init menu_item_parents
if ( $item->ID == $root_id ) $menu_item_parents[] = $item->ID;

if ( in_array( $item->menu_item_parent, $menu_item_parents ) ) {
// part of sub-tree: keep!
$menu_item_parents[] = $item->ID;
} else if ( ! ( isset( $args->show_parent ) && in_array( $item->ID, $menu_item_parents ) ) ) {
// not part of sub-tree: away with it!
unset( $sorted_menu_items[$key] );
}
}
return $sorted_menu_items;
} else {
return $sorted_menu_items;
}
}

Then you can display it in your theme using wp_nav_menu (just like you normally would), but also passing in a sub_menu flag to activate the custom sub_menu function:

 'primary', /// Your primary theme location name as per theme code
'sub_menu' => true
) ); ?>

How to restrict user other than administrator to acess wp-admin in wordpress

Here is code restrict user other than administrator to acess wp-admin in wordpress.
Put below code into your theme/funtion.php file

function block_wp_admin_init() {

if (strpos(strtolower($_SERVER['REQUEST_URI']),'/wp-admin/') !== false) {
  if ( !is_site_admin() ) {
     wp_redirect( get_option('siteurl'), 302 );
  }
}
}
add_action('init','block_wp_admin_init',0);

How to reset user id in wordpress for new signup registration

Here is way to reset user id in wordpress for new signup registration.

  1. First Delete all your unwanted users from backend.
  2. Now go to phpmyadmin to acess you database.
  3. Click on SQL tab from top and Enter below SQL COMMAND and Click GO button.
  4. ALTER TABLE wp_users AUTO_INCREMENT = 15

That’s it.

How to manage wordpress comments using php mysql

Here is way to manage your wordpress comments using php mysql queries.

Some things to note

  • Don’t forget to do a backup of your database before testing any of the queries below.
  • Don’t forget to change the default table prefix wp_ by the one used by your database.

Delete all spam comments

When you have over 100,000 spam comments in your spam queue, deleting them using the built-in “delete all spam” button might result in a PHP memory error. To avoid this, just use this simple SQL request to delete all spam at once.

DELETE from wp_comments WHERE comment_approved = 'spam'

Delete all comments between two dates

Had a “spam attack” for a limited time? Here is an easy way to delete all comments between two dates.

DELETE FROM wp_comments 
WHERE comment_date > '2013-11-15 01:10:04'
AND comment_date <= '2013-11-20 00:10:04'

Delete all pending comments

If your “pending comment” queue is filled with 99% spam comments and you don’t want to manually review each of them, here is a SQL command to instantly erase all pending comments.

DELETE FROM wp_comments WHERE comment_approved = '0'

Disable comments on all posts at once

Want to disable comments on all of your posts? Instead of closing comments on all your posts the one after the other, why not using this super simple SQL query?

UPDATE wp_posts SET comment_status = 'closed', ping_status = 'closed' WHERE comment_status = 'open'

Disable comments on older posts

To limit spam, why not closing comments on older posts? Here is the SQL to automatically close comments on all posts older than January 1, 2014:

UPDATE wp_posts SET comment_status = 'closed' WHERE post_date < '2014-01-01' AND post_status = 'publish'

Source: http://perishablepress.com/wordpress-discussion-management…

delete comments with a specific url

Even if you’re careful when approving new comments, sometimes you might just forget to visit the commenter url and detect a long time after that the linked site is spammy. Here is a very easy way to bulk delete all comments with a specific url, using a simple SQL query.

DELETE from wp_comments WHERE comment_author_url LIKE "%nastyspamurl%" ;

Source: http://www.wprecipes.com/wordpress-tip-bulk-delete-comments…

Search and replace comment text

If there’s a specific word or sentence that you want to replace in all comments, here is a very handy SQL query which use the mysql REPLACE function.

UPDATE wp_comments SET `comment_content` = REPLACE (`comment_content`, 'OriginalText', 'ReplacedText')

Globally enable comments for registered users only

A very effective way to dramatically decrease the amount of received spam comment is to enable comments for registered users only. Instead of doing it on each post, here’s a SQL query to run in oder to do it on all posts at once.

UPDATE wp_posts SET comment_status = 'registered_only'

Source: http://digwp.com/2010/08/wordpress-sql-comments/

How to change/ overwrite wordpress backend footer message

Here is code for change/ overwrite wordpress backend thankyou message. Put this code into your current theme function.php file

// Custom WordPress Footer
function remove_footer_admin () {
	echo '&copy; 2012 - WordPress Channel, Aur&eacute;lien Denis';
}
add_filter('admin_footer_text', 'remove_footer_admin');

How to change wordpress backend login logo

Here is code to change wordpress backend login logo. Put this code into your current theme function.php file.

function custom_login_logo() {
	echo '<style type="text/css">
	h1 a { background-image: url(http://webdesignermumbai.net/work/shivam/wp-content/themes/akhil/images/akhil-bharatvarshiya-logo.png) !important;width:397px !important;height:75px !important;background-size:397px 75px !important; }
	#login {width:400px !important}
	</style>';
}
add_action('login_head', 'custom_login_logo');

How to disable wordpress update notification

here is code to disable wordpress backend update notification. put this into your current theme function.php file

add_action('admin_menu','wphidenag');
function wphidenag() {
remove_action( 'admin_notices', 'update_nag', 3 );
}

How to add own style css into wp-admin backend using theme function hook

Here is snippet to add own style css into wp-admin backend using theme function hook.

function my_custom_admin_head(){
echo '<style>.yourclass {display: none !important;}</style>';
}
add_action('admin_head', 'my_custom_admin_head');

How to remove empty lines using regular expression in notpad++

I hope this tips will help you as wed designer to reduce files size by removing empty lines from file using notepadd++

Just Write “^s*” in Find Text box and replace with blank.

Server side responsive with cookies

here is code which i done after searching over google with help of different website.

<script type="text/javascript">
		function setCookie(cname,cvalue,exdays)	{
			var d = new Date();
			d.setTime(d.getTime()+(exdays*24*60*60*1000));
			var expires = "expires="+d.toGMTString();
			document.cookie = cname+"="+cvalue+"; "+expires;
		}
		windowwidth = document.body.clientWidth;
		setCookie("wwidth",windowwidth,30);
		var user1=getCookie("wwidth");
		//alert('user1'+user1);
		</script>
		<?php $screenWidth = $_COOKIE['wwidth'] ?>

Condition php code

<?php if ($screenWidth <= 660) { ?>
		<div class="class1" id="content">
	<?php } else { ?>
		<div class="class2" id="content">
	<?php } ?>

How Separate First post from Other in wordpress loop

As wordpress freelancer i found way to first post from Other in wordpress loop. Below is php code for same.

$latest_post = new WP_Query("post_type=post&posts_per_page=5&orderby=date&order=DESC");
if ( $latest_post->have_posts() ) :  $i = 0; while ( $latest_post->have_posts() ) : $latest_post->the_post();
if ( $i == 0 ) { ?>
<!-- FIRST POST CODE WILL COME HERE -->
<?php }else{ ?>
<!-- Others POST CODE WILL COME HERE -->
<?php }  
$i++;  
endwhile;  
endif; 
Page 1 of 1212345...10...»

Wordpress Freelancer, Joomla Freelancer Web designer Mumbai india, Wordpress web developer India, Joomla Web developer india, Outsourcing web project india mumbai

By Santosh Kori Published: October 10, 2012 Professional Freelance Website developer 5 stars based on 65 reviews Total time: 24 hour 00 min Wordpress Joomla XHTML CSS jQuery HTML5 eCommerce CSS3 ☞ Offers low cost freelance web designing, asp php asp.net web development services from Mumbai India. Freelance web designer & developer Mumbai India.

I AM NOT AVAILABLE FOR WEB DESIGN & DEVELOPMENT PROJECTS