-
Üyelik
01.07.2014
-
Yaş/Cinsiyet
32 / E
-
Meslek
Yazılım
-
Konum
İzmir
-
Ad Soyad
M** P**
-
Mesajlar
1104
-
Beğeniler
180 / 265
-
Ticaret
26, (%100)
function html($url, $tur=false) {
$ct = curl_init();
curl_setopt($ct, CURLOPT_URL, $url);
curl_setopt($ct, CURLOPT_RETURNTRANSFER, true);
$cikti = curl_exec($ct);
curl_close($ct);
if(empty($tur)){
return $this->tmz($cikti);
} else {
return $cikti;
}
}
function slugOlustur($url) {
$trharf = array("İ","Ş"," ","Ü","Ç","Ğ","Ö","ı","ş","ü","ç","ğ","ö");
$trharfdegis = array("I","S","-","U","C","G","O","i","s","u","c","g","o");
$url = str_replace($trharf,$trharfdegis,$url);
$url = preg_replace("@[^A-Za-z0-9\-_]+@i","",$url);
$url = trim($url);
$url = strtolower($url);
$find = array('', '');
$url = str_replace ($find, '', $url);
$url = preg_replace('/<(\/{0,1})img(.*?)(\/{0,1})\>/', 'image', $url);
$find = array(' ', '"', '&', '&', '\r\n', '\n', '/', '\\', '+', '<', '>');
$url = str_replace ($find, '-', $url);
$find = array('é', 'è', 'ë', 'ê', 'É', 'È', 'Ë', 'Ê');
$url = str_replace ($find, 'e', $url);
$find = array('í', 'ì', 'î', 'ï', 'I', 'Í', 'Ì', 'Î', 'Ï');
$url = str_replace ($find, 'i', $url);
$find = array('ó', 'ö', 'Ö', 'ò', 'ô', 'Ó', 'Ò', 'Ô');
$url = str_replace ($find, 'o', $url);
$find = array('á', 'ä', 'â', 'à', 'â', 'Ä', 'Â', 'Á', 'À', 'Â');
$url = str_replace ($find, 'a', $url);
$find = array('ú', 'ü', 'Ü', 'ù', 'û', 'Ú', 'Ù', 'Û');
$url = str_replace ($find, 'u', $url);
$find = array('ç', 'Ç');
$url = str_replace ($find, 'c', $url);
$find = array('?', '!', '$', '#', '+');
$url = str_replace ($find, '-', $url);
$find = array('ğ', 'Ğ');
$url = str_replace ($find, 'g', $url);
$find = array('/[^a-z0-9\-<>]/', '/[\-]+/', '/<[^>]*>/');
$repl = array('', '-', '');
$url = preg_replace ($find, $repl, $url);
$url = str_replace('--', '-', $url);
return $url;
}
function oneCikan($imageTitle, $imageUrl, $insertId) {
$fileName = remove_accents($imageTitle);
$fileName = slugOlustur($fileName);
$path = pathinfo($imageUrl);
$ex = $path['extension'];
$fileName = $fileName.'.'.$ex;
if(function_exists('mb_strtolower'))
$fileName = mb_strtolower($fileName, 'utf-8');
$fileName = utf8_uri_encode($fileName);
$fileType = wp_check_filetype($imageUrl);
extract($fileType);
if(!$type)
$type = '';
$uploadImage = wp_upload_bits($fileName, $fileType, html($imageUrl, "1"));
if(!empty($uploadImage['error'])) {
return $uploadImage['error'];
} else {
$ufile = $uploadImage['file'];
$attachment = array( 'guid' => $uploadImage['url'], 'post_mime_type' => $type, 'post_title' => $imageTitle, 'post_content' => '' );
$attach_id = wp_insert_attachment( $attachment, $ufile, $insertId );
$attach_data = wp_generate_attachment_metadata( $attach_id, $ufile );
wp_update_attachment_metadata( $attach_id, $attach_data );
add_post_meta( $insertId, '_thumbnail_id', $attach_id, true );
}
}
bütün fonksiyonlar burda bunları komple ekleyin dosyanıza ondan sonra çalışacaktır.
Wordpress Hizmetleri | Skype: mert50356