اذهب إلى المحتوى
  • 0

عرض صفحة php من نفس ملفات الموقع في الورد بريس

محمد رشيد2

السؤال

السلام عليكم اخواني واخواتي الكرام 

استفساري بسيط 

ما هو الكود الذي يمكن عرض صفحةphp من نفس ملفات الموقع في الورد بريس

Capture1.thumb.PNG.6aa62fb5561bd6d87c06f28ab4a5e05b.PNG

علما اني اضفت خيارات للوحة التحكم 

Capture2.PNG.3484eec782cefc440327e28f1e2dc10d.PNG

مع ان الملف موجود في نفس مسار الموقع ولاكن لا يتم عرضه عند الضغط على زر

اضافة اعلان

اريد كود لتضمين كود لملفات php لعرضه للازائر وهي عبارة عن فورم لاضافة الاعلانات الفورم متوفر 

علما ان هذا الخيار مربوط في زر اضف اعلان في الصفحة الرئيسية

Capture2.PNG.3484eec782cefc440327e28f1e2dc10d.PNG

وهناك ايضا خيار اخر قمت بانشائه في لوحة التحكم

Capture5.PNG.57607b5f87130e73b888c23c85345733.PNG

علما اني اريد اضافة هذا الكود الي الصفحة

<?php
/*
*#################################################
*first the shortcode to hold custom form
*#################################################
*/
session_start();

$getmetaoption = get_option( "dani_activeeditor" );
if($getmetaoption =="true"){
function addnewads_sc()
{
ob_start();


$getmetaoptionvistor = get_option( "dani_active_editor_vistor" );
if ( !is_user_logged_in() and $getmetaoptionvistor !="true" )
{
?>

<center>نأسف, يجب ان تقوم بال <a href="<?php if (!empty(get_option( "dani_login" ))){ echo get_page_link(get_option( "dani_login" )); }else{  echo wp_login_url();}?>">الدخول</a> اذا كانت لديك عضوية او <a href="<?php if (!empty(get_option( "dani_register" ))){ echo get_page_link(get_option( "dani_register" )); }else{ echo wp_registration_url();}?>">تسجيل</a> كعضو جديد لتستطيع المشاركة</center>
<?php
}else{
global $current_user;
get_currentuserinfo();
$user_ID = get_current_user_id();
$author_name = get_userdata($user_ID)->display_name;
$author_url = $author_name;
?>

<?php /*call javascript files  for uploader and subcategory*/ ?>
<script src="<?php echo get_template_directory_uri(); ?>/submenu/jquery.min.js"></script>
<script src="<?php echo get_template_directory_uri(); ?>/assets/uploadtools/script.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri(); ?>/assets/uploadtools/style.css">
<script type="text/javascript">
$(document).ready(function() {
	$("#genrecat").change(function() {
		$(this).after('<div id="loader"><img src="<?php echo get_template_directory_uri(); ?>/submenu/images/upload_wating.gif" alt="loading subcategory" /></div>');
		$.get('<?php echo get_template_directory_uri(); ?>/submenu/subordinarycategory.php?genrecat=' + $(this).val(), function(data) {
			$("#sub_cat").html(data);
			$('#loader').slideUp(200, function() {
				$(this).remove();
			});
		});
    });

});

/*catcar*/
$(document).ready(function() {
	$("#genrecatcar").change(function() {
		$(this).after('<div id="loader"><img src="<?php echo get_template_directory_uri(); ?>/submenu/images/upload_wating.gif" alt="loading subcategory" /></div>');
		$.get('<?php echo get_template_directory_uri(); ?>/submenu/subordinarycategory.php?genrecat=' + $(this).val(), function(data) {
			$("#sub_catcar").html(data);
			$('#loader').slideUp(200, function() {
				$(this).remove();
			});
		});
    });

});
/*counrty*/
$(document).ready(function() {
	$("#city").change(function() {
		$(this).after('<div id="loader"><img src="<?php echo get_template_directory_uri(); ?>/submenu/images/upload_wating.gif" alt="loading subcategory" /></div>');
		$.get('<?php echo get_template_directory_uri(); ?>/submenu/city.php?city=' + $(this).val(), function(data) {
			$("#subcity").html(data);
			$('#loader').slideUp(200, function() {
				$(this).remove();
			});
		});
    });

});
</script>



<?php
$deactivefulleditor = get_option( "dani_full_editor_disactive" );
if($deactivefulleditor !="true"){
?>
<script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/assets/tinymce/tinymce.min.js"></script>
<script type="text/javascript">
tinymce.init({
    language : 'ar',
    selector: "textarea",
    theme: "modern",
    plugins: [
        "advlist autolink lists link image charmap print preview hr anchor pagebreak",
        "searchreplace wordcount visualblocks visualchars code fullscreen",
        "insertdatetime media nonbreaking save table contextmenu directionality",
        "emoticons template paste textcolor colorpicker textpattern"
    ],
    toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
    toolbar2: "print preview media | forecolor backcolor emoticons",
    image_advtab: true,
    templates: [
        {title: 'Test template 1', content: 'Test 1'},
        {title: 'Test template 2', content: 'Test 2'}
    ]
});
</script>
<?php } ?>
<?php /* End call javascript files  for uploader and subcategory*/ ?>


<?php

/*if submit*/

if(isset($_POST['submit'])){
/*call and clean varibles*/
$vistorname=clean_text($_POST['vistorname']);
$mobile=clean_text($_POST['metamobile']);
$email=clean_text($_POST['metaemail']);
$period=clean_text($_POST['period']);
$city=clean_text($_POST['getcity']);
$year=clean_text($_POST['getyear']);
$kindadd=clean_text($_POST['kindadd']);
$subcity=clean_text($_POST['subcity']);
if($kindadd =='yes'){
	$genrecat=clean_text($_POST['genrecatcar']);
	$subcat=clean_text($_POST['sub_catcar']);
}else{
	$genrecat=clean_text($_POST['genrecat']);
	$subcat=clean_text($_POST['sub_cat']);
}
$metaprice=clean_text($_POST['metaprice']);
$metatitle=clean_text($_POST['metatitle']);
$deactivefulleditor = get_option( "dani_full_editor_disactive" );
if($deactivefulleditor =="true"){
$content=clean_text($_POST['content']);
}else{
$content=$_POST['content'];
}
$captcha = clean_text($_POST['check']);

// $googlesecret= get_option('dani_googlesecret');
// $curl = curl_init();
// curl_setopt_array($curl, array(
//     CURLOPT_RETURNTRANSFER => 1,
//     CURLOPT_URL => 'https://www.google.com/recaptcha/api/siteverify',
//     CURLOPT_POST => 1,
//     CURLOPT_POSTFIELDS => array(
//         'secret' => $googlesecret,
//         'response' => $captcha
//     )
// ));
// $response = curl_exec($curl);
// curl_close($curl);

/*call and clean varibles*/

/*this part is for image*/
	$target_path = "wp-content/uploads/"; //Declaring Path for uploaded images
	$imgsname=array_values(array_filter($_FILES['file']['name']));
	$imgstmpname=array_values(array_filter($_FILES['file']['tmp_name']));
	$imgsizes=array_values(array_filter($_FILES['file']['size']));
	$imgerror=array_values(array_filter($_FILES['file']['error']));
	$format_file = array("jpg", "png", "gif", "bmp","jpeg",);
	$max_file_size = 1024*5000000; //maksimal 100 kb
	$path = $target_path; // Lokasi folder untuk menampung file
	$count = 0;
	// Loop $_FILES to exeicute all files
	foreach ($imgsname as $f => $name) {

	    if ($imgerror[$f] == 10) {
	        continue; // Skip file if any error found
	    }
	    if ($imgerror[$f] == 0) {
	        if ($imgsizes[$f] > $max_file_size) {
	            //$message[] = "$name is too large!.";
	            continue; // Skip large files
	        }
			elseif( ! in_array(pathinfo($name, PATHINFO_EXTENSION), $format_file) ){
			//	$message[] = "$name is not a valid format";
				continue; // Skip invalid file formats
			}
	        else{ // No error found! Move uploaded files
						$temp = explode(".", $name);
						$newfilename = md5(uniqid()) . '.' . end($temp);
	            if(move_uploaded_file($imgstmpname[$f], $path.$newfilename))
	            $count++; // Number of successfully uploaded file
							$myimglink[]=get_site_url()."/".$path.$newfilename;
							$mmaray=$myimglink;
	        }
	    }
	}



if( ! $current_user->exists() && empty($metatitle)||empty($content)||empty($email) ){
	echo '<div class="warn">من فضلك ادخل جميع الحقول المطلوبة</div>';
}elseif($captcha != $_SESSION['captcha']|| empty($captcha) ){
	echo '<div class="warn">الكود الامني غير صحيح</div>';
}elseif(!filter_var($email, FILTER_VALIDATE_EMAIL)){
	echo '<div class="warn">البريد الاليكتروني خاطئ يرجي التحقق منه</div>';
}elseif(get_option( "dani_disable_uploading" ) != "true" and empty($imgsname)){
	echo '<div class="warn">يجب رفع صورة حتي يتم نشر اعلانك</div>';
}else{
$userid= $current_user->ID;
// $tax_arr = array(
// 'category' => array($genrecat ),
// 'category' => array($subcat ),
// 'city' => array($city),
// 'city' => array($subcity ),
// );
// if($kindadd =='yes'){
// $tax_arr[]['year']=	$year;
// }
global $wpdb;

// If we get here then the user is logged in and we have their id...

/*if mazad open*/


$activeorpending = get_option( "dani_accept_ads_wihtout_review" );
if($activeorpending =="true" || current_user_can('administrator') ){
  $poststatus="publish";
}else{
  $poststatus="pending";
}

$new_post_arr = array(
'comment_status' => $status,
'ping_status' => $status,
'post_author' => $userid,
'post_content' =>$content,
'post_name' => $metatitle,
'post_status' => $poststatus,
'post_title' => $metatitle,
'post_type' => 'post',
/**'tax_input' => $tax_arr,**/

);

$lastid = wp_insert_post($new_post_arr);

$wpdb->insert( 'wp_term_relationships', array('object_id' => $lastid, 'term_taxonomy_id' =>$genrecat, 'term_order' =>0));
$wpdb->insert( 'wp_term_relationships', array('object_id' => $lastid, 'term_taxonomy_id' =>$subcat, 'term_order' =>0));
$wpdb->insert( 'wp_term_relationships', array('object_id' => $lastid, 'term_taxonomy_id' =>$city, 'term_order' =>0));
$wpdb->insert( 'wp_term_relationships', array('object_id' => $lastid, 'term_taxonomy_id' =>$subcity, 'term_order' =>0));
if($kindadd =='yes'){
$wpdb->insert( 'wp_term_relationships', array('object_id' => $lastid, 'term_taxonomy_id' =>$year, 'term_order' =>0));
}
$wpdb->insert( 'wp_postmeta', array('post_id' => $lastid , 'meta_key' =>'vistorname', 'meta_value' => $vistorname));
$wpdb->insert( 'wp_postmeta', array('post_id' => $lastid , 'meta_key' =>'meta-price', 'meta_value' => $metaprice));
$wpdb->insert( 'wp_postmeta', array('post_id' => $lastid , 'meta_key' =>'meta-email', 'meta_value' => $email));
$wpdb->insert( 'wp_postmeta', array('post_id' => $lastid , 'meta_key' =>'meta-mobile', 'meta_value' => $mobile));
$wpdb->insert( 'wp_postmeta', array('post_id' => $lastid , 'meta_key' =>'period', 'meta_value' => $period));
$wpdb->insert( 'wp_postmeta', array('post_id' => $lastid , 'meta_key' =>'kindadd', 'meta_value' => $kindadd));

#tags System
$posttags= get_option( "dani_posttags" );
if($posttags== "true"){
$pretitle	= explode( ' ', $metatitle );
foreach ($pretitle as $tagsme) {
wp_set_object_terms( $lastid, $tagsme, 'post_tag', true );
}
}else{
}
#End of tags System


if($RESULT === FALSE){

}else{

/*back to here*/
// $a1 = array();
// foreach ($myArray as $vara) {
// @$mnew_strin .= $vara . ' ';
// }

$first_value = reset($mmaray);
$str = substr(strrchr($first_value, '/'), 1);
$mnb=$str;
$idi=$lastid +1;
$data = date("o-m-d H:i:s");

foreach ($mmaray as $vara) {
@$piclink = $vara;
$str = substr(strrchr($piclink, '/'), 1);
$lmnp=$str;

/**$wpdb->insert( 'wp_postmeta', array('post_id' => $lastid  , 'meta_key' =>'meta-myimg', 'meta_value' => $mnew_strin));**/

// Prepare an array of post data for the attachment.
$attachment = array(
	'guid'           => $piclink,
	'post_mime_type' => 'image/jpeg',
	'post_title'     => $metatitle,
	'post_type'     => 'attachment',
	'post_content'   => '',
	'post_status'    => 'inherit'
);

// Insert the attachment.
$attach_id = wp_insert_attachment( $attachment, $lmnp, $lastid );


}

require_once(ABSPATH . 'wp-admin/includes/image.php');
wp_generate_attachment_metadata( $attach_id,'.$first_value.');
wp_update_attachment_metadata( $attach_id,$fullsizepath);
set_post_thumbnail( $lastid, $attach_id );
update_post_meta($lastid, '_wp_attachment_metadata', $attach_id);
update_post_meta($lastid, '_thumbnail_id', $attach_id);


/*end the part of image*/

}

echo '<div class="success">شكرا لك لقد تم استقبال اعلانكم بنجاح</div>';

$getmetaoption = get_option( "dani_sendemailtoadmin" );
if($getmetaoption =="1"){

/**Sending Email To Admin**/

$receiveremails = get_option( "dani_edit_emails" );
if(!empty($receiveremails)){

$adminemail =$receiveremails;

}else{

	$adminemail = get_option( 'admin_email' );

}
$sender= get_option( 'admin_email' );
$name=$vistorname;
$contento=clean_text($content);
$subject="اعلان جديد بعنوان ".$metatitle." بانتظار المراجعة ";
$cont=$contento."\n email:{$sender}";
$cont="\n{$metatitle}\n".$contento;
$header = "From: ". $name . " <" . $sender . ">\r\n";
wp_mail($adminemail, $subject, $cont,$header);

/**End Of Sending Email To Admin**/
}
}
}else{
 /*create form*/
?>
<form enctype="multipart/form-data" method="POST" action="" class="mobawaba-form">
	<div class="form-group">
		<?php
		if(! $current_user->exists()){
		?>
		<input type="text" class="vistorname form-control" id="vistorname" name="vistorname" size="40" placeholder="الاسم"/>
		<?php
		}else{
		echo $author_url ;
		}
		?>
</div>
<div class="form-group">
	<input type="text"class="metamobile form-control" id="metamobile" name="metamobile"   size="40" placeholder="رقم الجوال"/>
</div>
<div class="form-group">
	<input type="text"  id="metaemail" class="form-control" name="metaemail" size="40" placeholder="البريد الاليكتروني"/>
</div>

<div class="form-group">
	<div class="radio">
	<label for="[object Object]">نوع الاعلان</label>
	<div id="kindadd">
		<input type="radio" name="kindadd" id="kindadd" value="yes"> <span class="radiosp">اعلان سيارة </span>
		<input type="radio" checked="checked" name="kindadd" id="kindadd" value="no">  <span class="radiosp">اعلان اخر</span>
	</div>
	</div>
</div>
<div class="hidemaincatforshowcars" style="display:block;">
	<div class="form-group">
		<select name="genrecat" id="genrecat" class="genrecat required form-control" >
		<option selected value="0"><?php echo __('اختر القسم', 'mobawaba');?></option>
		<?php
		$args = array(
			'type'                     => 'post',
			'child_of'                 => 0,
			'orderby'                  => 'name',
			'order'                    => 'ASC',
			'hide_empty'               => 0,
			'parent'                   => 0,
			'taxonomy'                 => 'category',
			'pad_counts'               => false,
			'exclude'               =>  array(get_option('dani_car_category'),'1')

		);
		$categories = get_categories($args); ?>
		<?php foreach( $categories as $category ) { ?>
		<option value="<?php echo $category->term_id; ?>">
		<?php echo $category->name; ?></option>
		<?php } ?>
		</select>
	</div>
	<div class="form-group">
	 <select name="sub_cat" id="sub_cat" class="form-control" >
	   <option value="0">اختر القسم الفرعي</option>
	 </select>
	</div>
</div>


<div class="form-group">
	<div class="yearx" style="display:none;">
		<div class="form-group">
			<select name="genrecatcar" id="genrecatcar" class="genrecat required form-control" >
			<option selected value="0"><?php echo __('اختر القسم', 'mobawaba');?></option>
			<?php
			$args = array(
				'type'                     => 'post',
				'child_of'                 => 0,
				'orderby'                  => 'name',
				'order'                    => 'ASC',
				'hide_empty'               => 0,
				'exclude'                  =>0,
				'parent'                   => get_option('dani_car_category'),
				'taxonomy'                 => 'category',
				'pad_counts'               => false
			);
			$categories = get_categories($args); ?>
			<?php foreach( $categories as $category ) { ?>
			<option value="<?php echo $category->term_id; ?>">
			<?php echo $category->name; ?></option>
			<?php } ?>
			</select>
		</div>
		<div class="form-group">
		 <select name="sub_catcar" id="sub_catcar"  class="form-control" >
		   <option value="0">اختر القسم الفرعي</option>
		 </select>
		</div>
		<select name="getyear" id="year" class="form-control">
		<option selected ><?php echo __('اختر سنه الاصدار', 'mobawaba');?></option>
		<?php
		$args = array(
			'type'                     => 'post',
			'child_of'                 => 0,
			'orderby'                  => 'name',
			'order'                    => 'ASC',
			'hide_empty'               => 0,
			'exclude'                  =>'',
			'parent'                   => 0,
			'taxonomy'                 => 'year',
			'pad_counts'               => false

		);
		$categories = get_categories($args); ?>
		<?php foreach( $categories as $category ) { ?>
		<option value="<?php echo $category->term_id; ?>">
		<?php echo $category->name; ?></option>
		<?php } ?>
		</select>
	</div>
	<script type="text/javascript">
	$('.radio :radio').on("click", function(){
		  var radioval = $(this).val();
			if(radioval =='yes'){
				$('.yearx').show();
				$('.hidemaincatforshowcars').hide();
			}else{
				$('.yearx').hide();
				$('.hidemaincatforshowcars').show();
			}
	});
	</script>
</div>

<div class="form-group">
	<select name="getcity" id="city" class="form-control">
	<option selected ><?php echo __('اختر البلد', 'mobawaba');?></option>
	<?php
	$args = array(
		'type'                     => 'post',
		'child_of'                 => 0,
		'orderby'                  => 'name',
		'order'                    => 'ASC',
		'hide_empty'               => 0,
		'exclude'                  =>'',
		'parent'                   => 0,
		'taxonomy'                 => 'city',
		'pad_counts'               => false

	);
	$categories = get_categories($args); ?>
	<?php foreach( $categories as $category ) { ?>
	<option value="<?php echo $category->term_id; ?>">
	<?php echo $category->name; ?></option>
	<?php } ?>
	</select>
</div>
<div class="form-group">
 <select name="subcity" id="subcity" class="form-control">
   <option value="0">اختر المدينة</option>
 </select>
</div>
<div class="form-group">
	<input type="text" name="metaprice" class="metaprice form-control" id="metaprice" size="40" placeholder="السعر"/>
</div>
<div class="form-group">
<select  name="period" class="form-control">
	<option value="">اختر مدة الاعلان</option>
	<option value="0">دائم</option>
	<option value="1">يوم</option>
	<option value="3">ثلاث ايام</option>
	<option value="7">سبع ايام</option>
</select>
</div>
<div class="form-group">
	<input type="text" name="metatitle" class="metatitle form-control" id="metatitle" size="40" placeholder="عنوان الاعلان"/>
</div>
<div class="form-group">
	<textarea rows="4" cols="50" name="content" id="content" class="content form-control" placeholder="محتوي الاعلان"></textarea>
</div>
<?php
$disableuploading= get_option( "dani_disable_uploading" );
		if($disableuploading != "true"){
?>
<div class="form-group">
<label for="meta-title">صورة الاعلان</label>
     <div id="filediv"><input name="file[]" type="file" id="file" class"mfile"/></div>
    <?php
    /*if multi upload active*/
    $getmetaoption = get_option( "dani_active_multi_upload" );
    if($getmetaoption == "true"){
    ?>
     <input type="button" id="add_more" class="upload" value="المزيد من الصور"/>
    <?php }?>

<?php
}//end of disable system
?>
</div>

<div class="form-group">
	<label for="meta-adcontent">التحقق الامني</label>
	<div class="captcha">
		<img alt="captcha" src="<?php echo get_template_directory_uri(); ?>/assets/captcha/captcha.php" />
	</div>
</div>

<div class="form-group">
	<label for="meta-adcontent">ادخل الكود الامني</label>
	<div class="captcha">
		<input type="number" name="check" class=" form-control">
	</div>
</div>
<div class="form-group">
	<input name="submit" type="submit" id="submit" value="اضف اعلانك"/>
</div>

</form>

<?php /* end of create form*/ ?>

<?php
}
/*end of else submit*/

}
return ob_get_clean();

}
add_shortcode('addnewads', 'addnewads_sc');

}else{


function addnewads_sc()
{
ob_start();
	echo '<div class="warn" align="center">اضافه الاعلانات موقوفه بشكل مؤقت</div>';
return ob_get_clean();
}
add_shortcode('addnewads', 'addnewads_sc');
}


?>

 

رابط هذا التعليق
شارك على الشبكات الإجتماعية

Recommended Posts

  • 1

ستحتاج إنشاء قالب صفحة جديد (Custom Page Template) ووضع الكود الذي تحتاجه بداخله, لتنفيذ العملية عليك إنشاء ملف php داخل مجلد القالب أي في المسار التالي :

wp-content/themes/ThemeName/FileName.php
// ThemeName = إسم القالب الذي تعتمده & FileName = تغيره بإسم الملف الذي قمت بإنشاءه

بداية هذا الملف ضروري ان تكون بهذا الشكل :

<?php /* Template Name: TemplateName */ ?>

ضع بدل TemplateName إسم قالب الصفحة الذي تريد إنشاءه, مثلاً Contact-us وضروري ان يكون بالإنجليزي ولا يضم فراغات, بعد ان تضيف هذا السطر ضع المحتوى الذي تريد 

ملاحظة أخيرة : سيكون عليك تضمين رأسية الموقع وكذا الـfooter للصفحة التي تنشئهاً طبعاً هذا في حال كنت ستحتاج رأسية وذيل الموقع ... لإضافة الرئسية والذيل إعتمد الكود التالي :

<?php get_header(); // يستحسن وضعها مباشرة بعد الكود الذي الذي سبق وطرحته ?> 
....
<?php get_footer(); // يستحسن وضعها كأخر عنصر في الملف ?>

 

رابط هذا التعليق
شارك على الشبكات الإجتماعية

  • 0

اخي حاولت لاكن لم تنجح الطريقة 

لاكن لدي استفسار اخر هل يمكنني وضع هذه الاكواد

<?php
/*
*#################################################
*first the shortcode to hold custom form
*#################################################
*/
session_start();

$getmetaoption = get_option( "dani_activeeditor" );
if($getmetaoption =="true"){
function addnewads_sc()
{
ob_start();


$getmetaoptionvistor = get_option( "dani_active_editor_vistor" );
if ( !is_user_logged_in() and $getmetaoptionvistor !="true" )
{
?>

<center>نأسف, يجب ان تقوم بال <a href="<?php if (!empty(get_option( "dani_login" ))){ echo get_page_link(get_option( "dani_login" )); }else{  echo wp_login_url();}?>">الدخول</a> اذا كانت لديك عضوية او <a href="<?php if (!empty(get_option( "dani_register" ))){ echo get_page_link(get_option( "dani_register" )); }else{ echo wp_registration_url();}?>">تسجيل</a> كعضو جديد لتستطيع المشاركة</center>
<?php
}else{
global $current_user;
get_currentuserinfo();
$user_ID = get_current_user_id();
$author_name = get_userdata($user_ID)->display_name;
$author_url = $author_name;
?>

<?php /*call javascript files  for uploader and subcategory*/ ?>
<script src="<?php echo get_template_directory_uri(); ?>/submenu/jquery.min.js"></script>
<script src="<?php echo get_template_directory_uri(); ?>/assets/uploadtools/script.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri(); ?>/assets/uploadtools/style.css">
<script type="text/javascript">
$(document).ready(function() {
	$("#genrecat").change(function() {
		$(this).after('<div id="loader"><img src="<?php echo get_template_directory_uri(); ?>/submenu/images/upload_wating.gif" alt="loading subcategory" /></div>');
		$.get('<?php echo get_template_directory_uri(); ?>/submenu/subordinarycategory.php?genrecat=' + $(this).val(), function(data) {
			$("#sub_cat").html(data);
			$('#loader').slideUp(200, function() {
				$(this).remove();
			});
		});
    });

});

/*catcar*/
$(document).ready(function() {
	$("#genrecatcar").change(function() {
		$(this).after('<div id="loader"><img src="<?php echo get_template_directory_uri(); ?>/submenu/images/upload_wating.gif" alt="loading subcategory" /></div>');
		$.get('<?php echo get_template_directory_uri(); ?>/submenu/subordinarycategory.php?genrecat=' + $(this).val(), function(data) {
			$("#sub_catcar").html(data);
			$('#loader').slideUp(200, function() {
				$(this).remove();
			});
		});
    });

});
/*counrty*/
$(document).ready(function() {
	$("#city").change(function() {
		$(this).after('<div id="loader"><img src="<?php echo get_template_directory_uri(); ?>/submenu/images/upload_wating.gif" alt="loading subcategory" /></div>');
		$.get('<?php echo get_template_directory_uri(); ?>/submenu/city.php?city=' + $(this).val(), function(data) {
			$("#subcity").html(data);
			$('#loader').slideUp(200, function() {
				$(this).remove();
			});
		});
    });

});
</script>



<?php
$deactivefulleditor = get_option( "dani_full_editor_disactive" );
if($deactivefulleditor !="true"){
?>
<script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/assets/tinymce/tinymce.min.js"></script>
<script type="text/javascript">
tinymce.init({
    language : 'ar',
    selector: "textarea",
    theme: "modern",
    plugins: [
        "advlist autolink lists link image charmap print preview hr anchor pagebreak",
        "searchreplace wordcount visualblocks visualchars code fullscreen",
        "insertdatetime media nonbreaking save table contextmenu directionality",
        "emoticons template paste textcolor colorpicker textpattern"
    ],
    toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
    toolbar2: "print preview media | forecolor backcolor emoticons",
    image_advtab: true,
    templates: [
        {title: 'Test template 1', content: 'Test 1'},
        {title: 'Test template 2', content: 'Test 2'}
    ]
});
</script>
<?php } ?>
<?php /* End call javascript files  for uploader and subcategory*/ ?>


<?php

/*if submit*/

if(isset($_POST['submit'])){
/*call and clean varibles*/
$vistorname=clean_text($_POST['vistorname']);
$mobile=clean_text($_POST['metamobile']);
$email=clean_text($_POST['metaemail']);
$period=clean_text($_POST['period']);
$city=clean_text($_POST['getcity']);
$year=clean_text($_POST['getyear']);
$kindadd=clean_text($_POST['kindadd']);
$subcity=clean_text($_POST['subcity']);
if($kindadd =='yes'){
	$genrecat=clean_text($_POST['genrecatcar']);
	$subcat=clean_text($_POST['sub_catcar']);
}else{
	$genrecat=clean_text($_POST['genrecat']);
	$subcat=clean_text($_POST['sub_cat']);
}
$metaprice=clean_text($_POST['metaprice']);
$metatitle=clean_text($_POST['metatitle']);
$deactivefulleditor = get_option( "dani_full_editor_disactive" );
if($deactivefulleditor =="true"){
$content=clean_text($_POST['content']);
}else{
$content=$_POST['content'];
}
$captcha = clean_text($_POST['check']);

// $googlesecret= get_option('dani_googlesecret');
// $curl = curl_init();
// curl_setopt_array($curl, array(
//     CURLOPT_RETURNTRANSFER => 1,
//     CURLOPT_URL => 'https://www.google.com/recaptcha/api/siteverify',
//     CURLOPT_POST => 1,
//     CURLOPT_POSTFIELDS => array(
//         'secret' => $googlesecret,
//         'response' => $captcha
//     )
// ));
// $response = curl_exec($curl);
// curl_close($curl);

/*call and clean varibles*/

/*this part is for image*/
	$target_path = "wp-content/uploads/"; //Declaring Path for uploaded images
	$imgsname=array_values(array_filter($_FILES['file']['name']));
	$imgstmpname=array_values(array_filter($_FILES['file']['tmp_name']));
	$imgsizes=array_values(array_filter($_FILES['file']['size']));
	$imgerror=array_values(array_filter($_FILES['file']['error']));
	$format_file = array("jpg", "png", "gif", "bmp","jpeg",);
	$max_file_size = 1024*5000000; //maksimal 100 kb
	$path = $target_path; // Lokasi folder untuk menampung file
	$count = 0;
	// Loop $_FILES to exeicute all files
	foreach ($imgsname as $f => $name) {

	    if ($imgerror[$f] == 10) {
	        continue; // Skip file if any error found
	    }
	    if ($imgerror[$f] == 0) {
	        if ($imgsizes[$f] > $max_file_size) {
	            //$message[] = "$name is too large!.";
	            continue; // Skip large files
	        }
			elseif( ! in_array(pathinfo($name, PATHINFO_EXTENSION), $format_file) ){
			//	$message[] = "$name is not a valid format";
				continue; // Skip invalid file formats
			}
	        else{ // No error found! Move uploaded files
						$temp = explode(".", $name);
						$newfilename = md5(uniqid()) . '.' . end($temp);
	            if(move_uploaded_file($imgstmpname[$f], $path.$newfilename))
	            $count++; // Number of successfully uploaded file
							$myimglink[]=get_site_url()."/".$path.$newfilename;
							$mmaray=$myimglink;
	        }
	    }
	}



if( ! $current_user->exists() && empty($metatitle)||empty($content)||empty($email) ){
	echo '<div class="warn">من فضلك ادخل جميع الحقول المطلوبة</div>';
}elseif($captcha != $_SESSION['captcha']|| empty($captcha) ){
	echo '<div class="warn">الكود الامني غير صحيح</div>';
}elseif(!filter_var($email, FILTER_VALIDATE_EMAIL)){
	echo '<div class="warn">البريد الاليكتروني خاطئ يرجي التحقق منه</div>';
}elseif(get_option( "dani_disable_uploading" ) != "true" and empty($imgsname)){
	echo '<div class="warn">يجب رفع صورة حتي يتم نشر اعلانك</div>';
}else{
$userid= $current_user->ID;
// $tax_arr = array(
// 'category' => array($genrecat ),
// 'category' => array($subcat ),
// 'city' => array($city),
// 'city' => array($subcity ),
// );
// if($kindadd =='yes'){
// $tax_arr[]['year']=	$year;
// }
global $wpdb;

// If we get here then the user is logged in and we have their id...

/*if mazad open*/


$activeorpending = get_option( "dani_accept_ads_wihtout_review" );
if($activeorpending =="true" || current_user_can('administrator') ){
  $poststatus="publish";
}else{
  $poststatus="pending";
}

$new_post_arr = array(
'comment_status' => $status,
'ping_status' => $status,
'post_author' => $userid,
'post_content' =>$content,
'post_name' => $metatitle,
'post_status' => $poststatus,
'post_title' => $metatitle,
'post_type' => 'post',
/**'tax_input' => $tax_arr,**/

);

$lastid = wp_insert_post($new_post_arr);

$wpdb->insert( 'wp_term_relationships', array('object_id' => $lastid, 'term_taxonomy_id' =>$genrecat, 'term_order' =>0));
$wpdb->insert( 'wp_term_relationships', array('object_id' => $lastid, 'term_taxonomy_id' =>$subcat, 'term_order' =>0));
$wpdb->insert( 'wp_term_relationships', array('object_id' => $lastid, 'term_taxonomy_id' =>$city, 'term_order' =>0));
$wpdb->insert( 'wp_term_relationships', array('object_id' => $lastid, 'term_taxonomy_id' =>$subcity, 'term_order' =>0));
if($kindadd =='yes'){
$wpdb->insert( 'wp_term_relationships', array('object_id' => $lastid, 'term_taxonomy_id' =>$year, 'term_order' =>0));
}
$wpdb->insert( 'wp_postmeta', array('post_id' => $lastid , 'meta_key' =>'vistorname', 'meta_value' => $vistorname));
$wpdb->insert( 'wp_postmeta', array('post_id' => $lastid , 'meta_key' =>'meta-price', 'meta_value' => $metaprice));
$wpdb->insert( 'wp_postmeta', array('post_id' => $lastid , 'meta_key' =>'meta-email', 'meta_value' => $email));
$wpdb->insert( 'wp_postmeta', array('post_id' => $lastid , 'meta_key' =>'meta-mobile', 'meta_value' => $mobile));
$wpdb->insert( 'wp_postmeta', array('post_id' => $lastid , 'meta_key' =>'period', 'meta_value' => $period));
$wpdb->insert( 'wp_postmeta', array('post_id' => $lastid , 'meta_key' =>'kindadd', 'meta_value' => $kindadd));

#tags System
$posttags= get_option( "dani_posttags" );
if($posttags== "true"){
$pretitle	= explode( ' ', $metatitle );
foreach ($pretitle as $tagsme) {
wp_set_object_terms( $lastid, $tagsme, 'post_tag', true );
}
}else{
}
#End of tags System


if($RESULT === FALSE){

}else{

/*back to here*/
// $a1 = array();
// foreach ($myArray as $vara) {
// @$mnew_strin .= $vara . ' ';
// }

$first_value = reset($mmaray);
$str = substr(strrchr($first_value, '/'), 1);
$mnb=$str;
$idi=$lastid +1;
$data = date("o-m-d H:i:s");

foreach ($mmaray as $vara) {
@$piclink = $vara;
$str = substr(strrchr($piclink, '/'), 1);
$lmnp=$str;

/**$wpdb->insert( 'wp_postmeta', array('post_id' => $lastid  , 'meta_key' =>'meta-myimg', 'meta_value' => $mnew_strin));**/

// Prepare an array of post data for the attachment.
$attachment = array(
	'guid'           => $piclink,
	'post_mime_type' => 'image/jpeg',
	'post_title'     => $metatitle,
	'post_type'     => 'attachment',
	'post_content'   => '',
	'post_status'    => 'inherit'
);

// Insert the attachment.
$attach_id = wp_insert_attachment( $attachment, $lmnp, $lastid );


}

require_once(ABSPATH . 'wp-admin/includes/image.php');
wp_generate_attachment_metadata( $attach_id,'.$first_value.');
wp_update_attachment_metadata( $attach_id,$fullsizepath);
set_post_thumbnail( $lastid, $attach_id );
update_post_meta($lastid, '_wp_attachment_metadata', $attach_id);
update_post_meta($lastid, '_thumbnail_id', $attach_id);


/*end the part of image*/

}

echo '<div class="success">شكرا لك لقد تم استقبال اعلانكم بنجاح</div>';

$getmetaoption = get_option( "dani_sendemailtoadmin" );
if($getmetaoption =="1"){

/**Sending Email To Admin**/

$receiveremails = get_option( "dani_edit_emails" );
if(!empty($receiveremails)){

$adminemail =$receiveremails;

}else{

	$adminemail = get_option( 'admin_email' );

}
$sender= get_option( 'admin_email' );
$name=$vistorname;
$contento=clean_text($content);
$subject="اعلان جديد بعنوان ".$metatitle." بانتظار المراجعة ";
$cont=$contento."\n email:{$sender}";
$cont="\n{$metatitle}\n".$contento;
$header = "From: ". $name . " <" . $sender . ">\r\n";
wp_mail($adminemail, $subject, $cont,$header);

/**End Of Sending Email To Admin**/
}
}
}else{
 /*create form*/
?>
<form enctype="multipart/form-data" method="POST" action="" class="mobawaba-form">
	<div class="form-group">
		<?php
		if(! $current_user->exists()){
		?>
		<input type="text" class="vistorname form-control" id="vistorname" name="vistorname" size="40" placeholder="الاسم"/>
		<?php
		}else{
		echo $author_url ;
		}
		?>
</div>
<div class="form-group">
	<input type="text"class="metamobile form-control" id="metamobile" name="metamobile"   size="40" placeholder="رقم الجوال"/>
</div>
<div class="form-group">
	<input type="text"  id="metaemail" class="form-control" name="metaemail" size="40" placeholder="البريد الاليكتروني"/>
</div>

<div class="form-group">
	<div class="radio">
	<label for="[object Object]">نوع الاعلان</label>
	<div id="kindadd">
		<input type="radio" name="kindadd" id="kindadd" value="yes"> <span class="radiosp">اعلان سيارة </span>
		<input type="radio" checked="checked" name="kindadd" id="kindadd" value="no">  <span class="radiosp">اعلان اخر</span>
	</div>
	</div>
</div>
<div class="hidemaincatforshowcars" style="display:block;">
	<div class="form-group">
		<select name="genrecat" id="genrecat" class="genrecat required form-control" >
		<option selected value="0"><?php echo __('اختر القسم', 'mobawaba');?></option>
		<?php
		$args = array(
			'type'                     => 'post',
			'child_of'                 => 0,
			'orderby'                  => 'name',
			'order'                    => 'ASC',
			'hide_empty'               => 0,
			'parent'                   => 0,
			'taxonomy'                 => 'category',
			'pad_counts'               => false,
			'exclude'               =>  array(get_option('dani_car_category'),'1')

		);
		$categories = get_categories($args); ?>
		<?php foreach( $categories as $category ) { ?>
		<option value="<?php echo $category->term_id; ?>">
		<?php echo $category->name; ?></option>
		<?php } ?>
		</select>
	</div>
	<div class="form-group">
	 <select name="sub_cat" id="sub_cat" class="form-control" >
	   <option value="0">اختر القسم الفرعي</option>
	 </select>
	</div>
</div>


<div class="form-group">
	<div class="yearx" style="display:none;">
		<div class="form-group">
			<select name="genrecatcar" id="genrecatcar" class="genrecat required form-control" >
			<option selected value="0"><?php echo __('اختر القسم', 'mobawaba');?></option>
			<?php
			$args = array(
				'type'                     => 'post',
				'child_of'                 => 0,
				'orderby'                  => 'name',
				'order'                    => 'ASC',
				'hide_empty'               => 0,
				'exclude'                  =>0,
				'parent'                   => get_option('dani_car_category'),
				'taxonomy'                 => 'category',
				'pad_counts'               => false
			);
			$categories = get_categories($args); ?>
			<?php foreach( $categories as $category ) { ?>
			<option value="<?php echo $category->term_id; ?>">
			<?php echo $category->name; ?></option>
			<?php } ?>
			</select>
		</div>
		<div class="form-group">
		 <select name="sub_catcar" id="sub_catcar"  class="form-control" >
		   <option value="0">اختر القسم الفرعي</option>
		 </select>
		</div>
		<select name="getyear" id="year" class="form-control">
		<option selected ><?php echo __('اختر سنه الاصدار', 'mobawaba');?></option>
		<?php
		$args = array(
			'type'                     => 'post',
			'child_of'                 => 0,
			'orderby'                  => 'name',
			'order'                    => 'ASC',
			'hide_empty'               => 0,
			'exclude'                  =>'',
			'parent'                   => 0,
			'taxonomy'                 => 'year',
			'pad_counts'               => false

		);
		$categories = get_categories($args); ?>
		<?php foreach( $categories as $category ) { ?>
		<option value="<?php echo $category->term_id; ?>">
		<?php echo $category->name; ?></option>
		<?php } ?>
		</select>
	</div>
	<script type="text/javascript">
	$('.radio :radio').on("click", function(){
		  var radioval = $(this).val();
			if(radioval =='yes'){
				$('.yearx').show();
				$('.hidemaincatforshowcars').hide();
			}else{
				$('.yearx').hide();
				$('.hidemaincatforshowcars').show();
			}
	});
	</script>
</div>

<div class="form-group">
	<select name="getcity" id="city" class="form-control">
	<option selected ><?php echo __('اختر البلد', 'mobawaba');?></option>
	<?php
	$args = array(
		'type'                     => 'post',
		'child_of'                 => 0,
		'orderby'                  => 'name',
		'order'                    => 'ASC',
		'hide_empty'               => 0,
		'exclude'                  =>'',
		'parent'                   => 0,
		'taxonomy'                 => 'city',
		'pad_counts'               => false

	);
	$categories = get_categories($args); ?>
	<?php foreach( $categories as $category ) { ?>
	<option value="<?php echo $category->term_id; ?>">
	<?php echo $category->name; ?></option>
	<?php } ?>
	</select>
</div>
<div class="form-group">
 <select name="subcity" id="subcity" class="form-control">
   <option value="0">اختر المدينة</option>
 </select>
</div>
<div class="form-group">
	<input type="text" name="metaprice" class="metaprice form-control" id="metaprice" size="40" placeholder="السعر"/>
</div>
<div class="form-group">
<select  name="period" class="form-control">
	<option value="">اختر مدة الاعلان</option>
	<option value="0">دائم</option>
	<option value="1">يوم</option>
	<option value="3">ثلاث ايام</option>
	<option value="7">سبع ايام</option>
</select>
</div>
<div class="form-group">
	<input type="text" name="metatitle" class="metatitle form-control" id="metatitle" size="40" placeholder="عنوان الاعلان"/>
</div>
<div class="form-group">
	<textarea rows="4" cols="50" name="content" id="content" class="content form-control" placeholder="محتوي الاعلان"></textarea>
</div>
<?php
$disableuploading= get_option( "dani_disable_uploading" );
		if($disableuploading != "true"){
?>
<div class="form-group">
<label for="meta-title">صورة الاعلان</label>
     <div id="filediv"><input name="file[]" type="file" id="file" class"mfile"/></div>
    <?php
    /*if multi upload active*/
    $getmetaoption = get_option( "dani_active_multi_upload" );
    if($getmetaoption == "true"){
    ?>
     <input type="button" id="add_more" class="upload" value="المزيد من الصور"/>
    <?php }?>

<?php
}//end of disable system
?>
</div>

<div class="form-group">
	<label for="meta-adcontent">التحقق الامني</label>
	<div class="captcha">
		<img alt="captcha" src="<?php echo get_template_directory_uri(); ?>/assets/captcha/captcha.php" />
	</div>
</div>

<div class="form-group">
	<label for="meta-adcontent">ادخل الكود الامني</label>
	<div class="captcha">
		<input type="number" name="check" class=" form-control">
	</div>
</div>
<div class="form-group">
	<input name="submit" type="submit" id="submit" value="اضف اعلانك"/>
</div>

</form>

<?php /* end of create form*/ ?>

<?php
}
/*end of else submit*/

}
return ob_get_clean();

}
add_shortcode('addnewads', 'addnewads_sc');

}else{


function addnewads_sc()
{
ob_start();
	echo '<div class="warn" align="center">اضافه الاعلانات موقوفه بشكل مؤقت</div>';
return ob_get_clean();
}
add_shortcode('addnewads', 'addnewads_sc');
}


?>

في هذه الصفحة داخل صندوق اضافة صفحة ليتم عرضها للزوار او هل هناك اي كود يمكن ربط الملف الموجود في ملفات موقعي في هذا الصندوق

Capture1.thumb.PNG.ecd2276b160b206b7c7a16b469c50678.PNG

تم حل المشكلة

رابط هذا التعليق
شارك على الشبكات الإجتماعية

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...