function post_updated($post_id) { if ('post' != get_post_type($post_id)) { return; } if (isset($_POST['tm_video_url'])) { $url = $_POST['tm_video_url']; } //print_r($url);exit; if ($url == '') { $url = get_post_meta($post_id, 'tm_video_url', true); } $data = Video_Fetcher::fetchData($url, $fields = array(), $post_id); $post['ID'] = $post_id; //print_r($data);exit; $auto_get_info = get_post_meta($post_id, 'fetch_info', true); //var_dump($auto_get_info); if ($url != '' && strpos($url, 'youtube.com') !== false || $url != '' && strpos($url, 'vimeo.com') !== false || $url != '' && strpos($url, 'dailymotion.com') !== false) { if (empty($auto_get_info) || $auto_get_info['0'] != '1') { if (function_exists('ot_get_option')) { $get_info = ot_get_option('auto_get_info'); } if ($get_info['0'] == '1') { //$post['post_title'] = get_post_meta($post_id,'title_video',true); $post['post_title'] = $data['title']; $post['post_name'] = $data['title']; } if ($get_info['1'] == '2') { //$post['post_content'] = get_post_meta($post_id,'ct_video',true); $post['post_content'] = $data['description']; } if ($get_info['2'] == '3') { //$post['tags'] = get_post_meta($post_id,'tags',true); //echo $data['tags'] ;exit; wp_set_post_tags($post_id, $data['tags'], true); //$post['tags'] = $data['tags'] ; } if ($get_info['3'] == '4') { update_post_meta($post_id, '_count-views_all', $data['viewCount']); } // update the post, removing the action to prevent an infinite loop remove_action('save_post', 'post_updated'); wp_update_post($post); add_action('save_post', 'post_updated'); } } }