Increase website speed

Ideally you should have one (or even embed CSS for high-traffic pages) on your pages.
CSS files in the HEAD
CSS Sprites
Inline small CSS
Minify CSS
Ideally you should have one (or even embed scripts for high-traffic pages) on your pages.
JavaScript files at the end of the BODY
Minify JavaScript
specify the HEIGHT and WIDTH of your images
Consider switch graphic formats to achieve smaller file sizes
CSS Sprites
HTTP compression
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
<IfModule mod_expires.c>
ExpiresActive on
# Your document html
ExpiresByType text/html “access plus 0 seconds”
# Media: images, video, audio
ExpiresByType audio/ogg “access plus 1 month”
ExpiresByType image/gif “access plus 1 month”
ExpiresByType image/jpeg “access plus 1 month”
ExpiresByType image/png “access plus 1 month”
ExpiresByType video/mp4 “access plus 1 month”
ExpiresByType video/ogg “access plus 1 month”
ExpiresByType video/webm “access plus 1 month”
# CSS and JavaScript
ExpiresByType application/javascript “access plus 1 year”
ExpiresByType text/css “access plus 1 year”

Send Mail php Function with complete header details with attachment support

function sendMail($to,$subject,$htmlbody){

//$htmlbody = ” Your Mail Contant Here…. You can use html tags here…”;
//$to = “”;
//$subject = “Test email with attachment”;
$random_hash = md5(date(‘r’, time()));

$headers = “From:\r\n”;
$headers .= “Reply-To:”;
$headers .= “Cc: \r\n”;
$headers .= “Bcc: \r\n”;

$headers .= “\r\nContent-Type: multipart/mixed;boundary=\”PHP-mixed-“.$random_hash.”\””;

// Set your file path here
$attachment = chunk_split(base64_encode(file_get_contents(‘logo.png’)));
//define the body of the message.
$message = “–PHP-mixed-$random_hash\r\n”.”Content-Type: multipart/alternative; boundary=\”PHP-alt-$random_hash\”\r\n\r\n”;

$message .= “–PHP-alt-$random_hash\r\n”.”Content-Type: text/plain;
charset=\”iso-8859-1\”\r\n”.”Content-Transfer-Encoding: 7bit\r\n\r\n”;
//Insert the html message.
$message .= $htmlbody;
$message .=”\r\n\r\n–PHP-alt-$random_hash–\r\n\r\n”;
//include attachment
$message .= “–PHP-mixed-$random_hash\r\n”.”Content-Type: application/zip;
base64\r\n”.”Content-Disposition: attachment\r\n\r\n”;

$message .= $attachment;
$message .= “/r/n–PHP-mixed-$random_hash–“;
//send the email
$mail = mail( $to, $subject , $message, $headers );

echo $mail ? “Mail sent” : “Mail failed”;

Post type Contextual Help

function my_contextual_help( $contextual_help, $screen_id, $screen ) {
if ( ‘amslider’ == $screen->id ) { //post type name here

$contextual_help = ‘<h2>Products</h2>
<p>Products show the details of the items that we sell on the website. You can see a list of them on this page in reverse chronological order – the latest one we added is first.</p>
<p>You can view/edit the details of each product by clicking on its name, or you can perform bulk actions using the dropdown menu and selecting multiple items.</p>';

} elseif ( ‘edit-amslider’ == $screen->id ) {

$contextual_help = ‘<h2>Editing products</h2>
<p>This page allows you to view/modify product details. Please make sure to fill out the available boxes with the appropriate details (product image, price, brand) and <strong>not</strong> add these details to the product description.</p>';

return $contextual_help;
add_action( ‘contextual_help’, ‘my_contextual_help’, 10, 3 );

Basic Form Filtering used in PHP

// Strip HTML Tags
$clear = strip_tags($des);

// Clean up things like &amp;
$clear = html_entity_decode($clear);

// Strip out any url-encoded stuff
$clear = urldecode($clear);

// Replace non-AlNum characters with space
$clear = preg_replace(‘/[^A-Za-z0-9]/’, ‘ ‘, $clear);

// Replace Multiple spaces with single space
$clear = preg_replace(‘/ +/’, ‘ ‘, $clear);

// Trim the string of leading/trailing space
$clear = trim($clear);

//All in one above

$name = trim(preg_replace(‘/ +/’, ‘ ‘, preg_replace(‘/[^A-Za-z0-9 ]/’, ‘ ‘, urldecode(html_entity_decode(strip_tags($_POST['inputName']))))));