Thank you for assistance.
Now I have tried with the .htaccess sample given in
http://codex.wordpress.org/htaccess#WordPress_3.4_and_below
But still
http://blog1.com/wp-includes/ms-files.php?file=rsz_1insectone.jpg [ Not Working ]
and issue exists.
Following are the details how duplicate post functionality is working on my blogs :
I am calling my ” auto_duplicate ” function using wordpress hack in blog1 function.php
add_action('auto-draft_to_publish', 'auto_duplicate ');
add_action('new_to_publish', 'auto_duplicate ');
add_action('draft_to_publish', 'auto_duplicate ');
add_action('pending_to_publish', 'auto_duplicate ');
add_action('future_to_publish', 'auto_duplicate ');
I have created a custom plugin where I have ” auto_duplicate ” function.
Please find the ” auto_duplicate ” code as follow:
public function auto_duplicate($from_blog_ID, $from_post_ID, $to_blog_ID) {
global $blog_id, $obj;
switch_to_blog($from_blog_ID);
$data = $obj->db->get_row("SELECT * FROM <code>wp_".$from_blog_ID."_posts</code> WHERE ID='".$from_post_ID."'");
$media = $obj->db->get_results("SELECT * FROM <code>wp_".$from_blog_ID."_posts</code> WHERE post_parent='".$from_post_ID."' AND post_type='attachment'");
$meta = $obj->db->get_results("SELECT * FROM <code>wp_".$from_blog_ID."_postmeta</code> WHERE post_id='".$from_post_ID."'");
$cats = $obj->db->get_results("SELECT t1.term_taxonomy_id, t2.name, t2.slug FROM <code>wp_".$from_blog_ID."_term_relationships</code> AS t1 INNER JOIN <code>wp_".$from_blog_ID."_terms</code> AS t2 ON t1.term_taxonomy_id=t2.term_id WHERE t1.object_id ='".$from_post_ID."'");
$read_more_link = get_post_meta($from_post_ID, 'custom_readmorelink', TRUE);
switch_to_blog($to_blog_ID);
// create new post
$post = array(
'post_title' => $data->post_title,
'post_content' => $data->post_content,
'post_status' => 'publish',
'post_date' => $data->post_date,
'post_author' => 1);
$post_ID = wp_insert_post( $post );
// insert categories
// these are special media categories
$special_media_cats = array();
$blog_id2 = 4;
$blog_id1 = 2;
if ($from_blog_ID == $blog_id1 && $to_blog_ID == $blog_id2) {
update_post_meta($post_ID, 'custom_readmorelink', $read_more_link);
}
$in_special_media_category = FALSE;
$final_cats = array();
foreach($cats as $cat) {
$cat_ID = $obj->db->get_var("SELECT <code>term_id</code> FROM <code>{prefix}terms</code> WHERE <code>slug</code> LIKE '".$cat->slug."' LIMIT 1");
// if this is a special media category, flag that the post is assigned to one of those categories
if (in_array($cat_ID, $special_media_cats)) $in_special_media_category = TRUE;
If(!empty($cat_ID)) {
$final_cats[] = $cat_ID;
}
}
// if this post is not in a special media cat and is being duped to Blog2, assign it to Blog2 "Special: Articles"
if (!$in_special_media_category && $to_blog_ID == $blog_id2) {
$final_cats[] = 3;
}
$final_cats = array_unique($final_cats);
wp_set_post_terms($post_ID, $final_cats, 'category');
// import media
foreach($media as $item) {
$post = array(
'post_title' => $item->post_title,
'post_status' => 'inherit',
'post_name' => $item->post_name,
'post_parent' => $post_ID,
'guid' => $item->guid,
'post_type' => 'attachment',
'post_mime_type' => $item->post_mime_type,
'post_author' => 1);
$file_ID = wp_insert_post( $post );
}
// import meta
foreach($meta as $item) {
$array = array( 'post_id'=>$post_ID,
'meta_key'=>$item->meta_key,
'meta_value'=>$item->meta_value);
$bnet->db->insert('{prefix}postmeta', $array);
}
switch_to_blog($from_blog_ID);
return $post_ID;
}
Auto duplicate functionality is working fine, and also media images were showing in previous version of wordpress that is wordpress 3.9.2 and 4.0
But as I have updated the wordpress version to 4.1 media library images issue exists.
When I click on broken image thumbnail in media library, they are showing correct image path but as I insert those images in post then image source left blank.
I have tried all the .htaccess examples given at the
http://codex.wordpress.org/htaccess#WordPress_3.4_and_below
But still not get any success.
Looking for your valuable comments of this issue.