[insert_php]
require_once(ABSPATH . “wp-admin” . ‘/includes/image.php’);
require_once(ABSPATH . “wp-admin” . ‘/includes/file.php’);
require_once(ABSPATH . “wp-admin” . ‘/includes/media.php’);
$uploaddir = wp_upload_dir();
function resize_crop_image($max_width, $max_height, $source_file, $dst_dir, $quality = 80){
$imgsize = getimagesize($source_file);
$width = $imgsize[0];
$height = $imgsize[1];
$mime = $imgsize[‘mime’];

switch($mime){
case ‘image/gif’:
$image_create = “imagecreatefromgif”;
$image = “imagegif”;
break;

case ‘image/png’:
$image_create = “imagecreatefrompng”;
$image = “imagepng”;
$quality = 7;
break;

case ‘image/jpeg’:
$image_create = “imagecreatefromjpeg”;
$image = “imagejpeg”;
$quality = 80;
break;

default:
return false;
break;
}

$dst_img = imagecreatetruecolor($max_width, $max_height);
$src_img = $image_create($source_file);

$width_new = $height * $max_width / $max_height;
$height_new = $width * $max_height / $max_width;
//if the new width is greater than the actual width of the image, then the height is too large and the rest cut off, or vice versa
if($width_new > $width){
//cut point by height
$h_point = (($height – $height_new) / 2);
//copy image
imagecopyresampled($dst_img, $src_img, 0, 0, 0, $h_point, $max_width, $max_height, $width, $height_new);
}else{
//cut point by width
$w_point = (($width – $width_new) / 2);
imagecopyresampled($dst_img, $src_img, 0, 0, $w_point, 0, $max_width, $max_height, $width_new, $height);
}

$image($dst_img, $dst_dir, $quality);

if($dst_img)imagedestroy($dst_img);
if($src_img)imagedestroy($src_img);
}
//————————————-
function reArrayFiles(&$file_post) {

$file_ary = array();
$file_count = count($file_post[‘name’]);
$file_keys = array_keys($file_post);

for ($i=0; $i<$file_count; $i++) { foreach ($file_keys as $key) { $file_ary[$i][$key] = $file_post[$key][$i]; } } return $file_ary; } if($_POST['side']=='3487' ){ $files = reArrayFiles($_FILES['featured' ]); //$postcontent=$_POST['postcontent']; $posttitle='واحة الأطفال – ألبوم صور الطفل :'.$_POST['kid_name']; $postcontent='

الطفل : ‘.$_POST[‘kid_name’].’ – مواليد : ‘.$_POST[‘b_date’].’ – من : ‘.$_POST[‘country’].’

‘.$_POST[‘postcontent’];
$post_info = array(
‘post_title’ => wp_strip_all_tags( $posttitle ),
‘post_content’ => $postcontent,
‘post_category’ =>[47],
‘post_type’ => ‘post’,
‘post_status’=>’pending’
);

$pid = wp_insert_post( $post_info );
$tag = ‘post-format-gallery’;
$taxonomy = ‘post_format’;
wp_set_post_terms( $pid, $tag, $taxonomy );
if($pid){

echo’

تم ارسال المحتوى سنقوم بمراجعته ونشره في أقرب وقت .شكراً لك !!

سيتم تحوبلك إلى صفحة إضافة المحتوى.

‘;
//wp_destroy_current_session();

}

$j=0;
$total=count($files);
$gal_meta_value=’a:’.$total.’:{‘;
foreach($files as $file ){
$uploadfile = $uploaddir[‘path’] . ‘/’ . basename( $file[‘name’] );
//—resize image———————————
$imgsize = getimagesize( $file[‘tmp_name’]);
$width = $imgsize[0];
$height = $imgsize[1];
//if($height >700){
resize_crop_image(700,700, $file[‘tmp_name’],$file[‘tmp_name’]);//}
//—————————————————
move_uploaded_file( $file[‘tmp_name’] , $uploadfile );
$filename = basename( $uploadfile );
$wp_filetype = wp_check_filetype(basename($filename), null );
$attachment = array(
‘post_mime_type’ => $wp_filetype[‘type’],
‘post_title’ => preg_replace(‘/\.[^.]+$/’, ”, $filename),
‘post_content’ => ”,
‘post_status’ => ‘inherit’,
‘menu_order’ => $_i + 1000
);
$attach_id = wp_insert_attachment( $attachment, $uploadfile );
if($j==0){
update_post_meta($pid,’_thumbnail_id’,$attach_id);
set_post_thumbnail( $pid, $thumbnail_id );}
$gal_meta_value.=’i:’.$j.’;s:4:”‘.$attach_id .'”;’;

$j++;
}
$gal_meta_value.=’}’;
add_post_meta( $pid, ‘ocean_gallery_link_images’, ‘on’, true );
add_post_meta( $pid, ‘ocean_gallery_id’, $gal_meta_value );
update_post_meta( $pid, ‘ocean_gallery_id’, $gal_meta_value );
$host=”localhost”;
$dbus=”khatibco_adabd”;//”adbasel”;
$dbpss=”roula@#basel”;//”7ebYQhxLFcd,.pqP”;
$dbnm =”khatibco_drkhatib”;
$connect=mysql_connect($host,$dbus,$dbpss);
mysql_select_db(“khatibco_newkhatib”);
mysql_query(“update kh_postmeta set meta_value=’$gal_meta_value’ where post_id=’$pid’ and meta_key=’ocean_gallery_id’ “);
}else{
echo’

دخول خاطئ !!

سيتم تحوبلك إلى صفحة إضافة المحتوى.

‘;
}
[/insert_php]

Close Menu