Sunday, March 29, 2015

Create post programatically and assigned category to posts (If category & Posts not exists it will create and assign to that posts).


$new_post = array(
'post_name' => sanitize_title($data['Handle']), // Slug
'post_title' => convert_chars($data['Title']),
'post_content' => wpautop(convert_chars($data['Body (HTML)'])),
'post_status' => 'publish',
'post_type' => 'post',
//'post_category' => array($new_cat_ID)
);

if($id = post_exists($new_post['post_title'], $new_post['post_content']))
{
$new_post['ID'] = (int)$id;
$id = wp_update_post($new_post);
if ( is_wp_error( $id ) )
{
return $id;
}
if (!$id)
{
$output .= "Couldn't get post ID";
return;
}

foreach($data as $key => $value)
{
update_post_meta($id, sanitize_user('Shopify '.$key), esc_attr($value));
}
$output .= 'Updated !'. ' <a href="'.get_permalink($id).'">View '.$data['Title'].'</a>';
}
else
{
$id = wp_insert_post($new_post);
}

$arrCategories = explode(',', $data['Categories']);
if(count($arrCategories) > 0)
{
global $wpdb;
foreach($arrCategories as $key => $category_name)
{
$slug = strtolower( str_ireplace( ' ', '-', $category_name ) );
$sqlTermQuery = "SELECT * FROM wp_terms WHERE slug = '".$slug."'";
$arrTermsArray = $wpdb->get_results($sqlTermQuery);
if(count($arrTermsArray) <= 0)
{
$sqlInsertTerm = "INSERT INTO wp_terms SET name = '".ucfirst($category_name)."',slug = '".$slug."'";
$wpdb->query($sqlInsertTerm);
$lastid = $wpdb->insert_id;
$sqlInsertTermTexonomy = "INSERT INTO wp_term_taxonomy SET term_id = '".$lastid."',taxonomy = 'category'";
$arrTexonomy[] = $wpdb->get_results($sqlInsertTermTexonomy);
$lasttexonomyid = $wpdb->insert_id;
$arrCategories_ids[] = $lastid;
}
else
{
$sqlTermQuery = "SELECT * FROM wp_terms WHERE slug = '".$slug."'";
$arrTermsArray = $wpdb->get_results($sqlTermQuery);
$intTermid = $arrTermsArray[0]->term_id;

$sqlTexonomy = "SELECT term_taxonomy_id FROM wp_term_taxonomy WHERE term_id = '".$intTermid."' AND taxonomy = 'download_category'";
$arrTaxonomy = $wpdb->get_results($sqlTexonomy);
if(count($arrTaxonomy) > 0)
{
$lasttexonomyid = $arrTaxonomy[0]->term_taxonomy_id;
}
else
{
$sqlInsertTermTexonomy = "INSERT INTO wp_term_taxonomy SET term_id = '".$intTermid."',taxonomy = 'download_category'";
$arrTexonomy[] = $wpdb->get_results($sqlInsertTermTexonomy);
$lasttexonomyid = $wpdb->insert_id;
}
}

if($lasttexonomyid >0 && $id > 0)
{
$sqlInsertTerm = "INSERT INTO wp_term_relationships SET object_id = '".$id."',term_taxonomy_id = '".$lasttexonomyid."'";
$wpdb->query($sqlInsertTerm);
}
}
}

Sunday, February 2, 2014

JQuery image preview on hover and onclick

Sorry, no attachments exist.
JQuery image preview on hover and onclick

Image-preview


JQuery image preview on hover and onclick

Disabling local modules in Magento.

if you ever wanted to temporarily disable all local modules, here is how to.

Open file app/etc/local.xml

Locate the tag

Change it’s value to true.

i.e

<disable_local_modules>false</disable_local_modules>


Disabling local modules in Magento.

Thursday, January 30, 2014

Sunday, January 26, 2014

Wordpress Banner Slider By Mayank Patel

Sorry, no attachments exist.
WordPress banner Slider by mayank patel


Wordpress Banner Slider By Mayank Patel

PHP Script

<?php

function getBrowser()

a-zA-Z.]*)#’;

if (!preg_match_all($pattern, $u_agent, $matches))


// we have no matching number just continue

// See how many we have.

$i = count($matches['browser']);

if ($i != 1)


//we will have two since we are not using ‘other’ argument yet

//see if version is before or after the name

if (strripos($u_agent,”Version”) < strripos($u_agent,$ub))


$version= $matches['version'][0];


else


$version= $matches['version'][1];



else


$version= $matches['version'][0];

// Check if we have a number.

if($version==null

// Now try it.

$ua=getBrowser();

$yourbrowser= “Your browser = ” . $ua['name'] . “<br />Version = ” . $ua['version'] . ” <br />” .”O.S. = “. $ua['platform'] . ” <br />reports = ” . $ua['userAgent'];

print_r($yourbrowser);

?>


PHP Script

Sunday, December 29, 2013

Wordpress Banner Slider (Backend Side)

Sorry, no attachments exist.
WordPress banner Slider by mayank patel


Wordpress Banner Slider (Backend Side)

Saturday, December 14, 2013

Sunday, December 8, 2013

Wordpress change email from wordpress@domain.com to custom email address

function change_from_email_name()


$message = get_option(‘blogname’);

return $message;


add_filter(‘wp_mail_from_name’, ‘change_from_email_name’); // // changes email from default “wordpress@yourdomain.com”//

function change_from_email()


$message = get_option(‘admin_email’);

return $message;


add_filter(‘wp_mail_from’, ‘change_from_email’); /// Changed by mayank patel over ////


Wordpress change email from wordpress@domain.com to custom email address

Wordpress change registration email from wordpress@domainname.com to custom email.

On function.php file of current theme place follownig code at last

function change_from_email_name()

$message = get_option(‘blogname’);

return $message;


add_filter(‘wp_mail_from_name’, ‘change_from_email_name’);

//

// changes email from default “wordpress@yourdomain.com”

//

function change_from_email()

$message = get_option(‘admin_email’);

return $message;


add_filter(‘wp_mail_from’, ‘change_from_email’);


Wordpress change registration email from wordpress@domainname.com to custom email.

Sunday, December 1, 2013

Magento print query for throughout site.

Lib/zend/Db/Adapter/Abstract.php

find :

public function query($sql, $bind = array())


after :

$sql = $sql->assemble();

//echo $sql . “\n<br />\n”;

// var_dump($bind);


Magento print query for throughout site.

Magento extension for facebook comments from product detail page.

Sorry, no attachments exist.

Magento extension for facebook comments from product detail page.


Magento extension for facebook comments from product detail page.

Magento customer credit extension.

Sorry, no attachments exist.

Magento customer credit extension.


Magento customer credit extension.

Thursday, November 28, 2013

Magento blacklist email address extension

Sorry, no attachments exist.

Magento blacklist email address extension



Magento blacklist email address extension

Magento extension for one page easy checkout

Sorry, no attachments exist.

Magento extension for one page easy checkout



Magento extension for one page easy checkout

Magento improve one page checkout with designing (css only)

Sorry, no attachments exist.

Magento improve one page checkout with designing (css only)



Magento improve one page checkout with designing (css only)

Magento Google analytics extension

Sorry, no attachments exist.

Magento Google analytics extension



Magento Google analytics extension

Magento comments on checkout extension

Sorry, no attachments exist.

Magento comments on checkout extension



Magento comments on checkout extension

Magento developer toolbar extension

Sorry, no attachments exist.

Magento developer toolbar extension



Magento developer toolbar extension

Magento facebook likebox and connect extension.

Sorry, no attachments exist.

Magento facebook likebox and connect extension.



Magento facebook likebox and connect extension.