رفتن به مطلب

شرطی کردن برخی عناصر


goldenfont

پست های پیشنهاد شده

سلام ، چگونه میشه بعضی المانهارو شرطی کرد ؟

مثلا بیایم یک قسمت برای گذاشتن یک متن در تنظیمات پوسته ایجاد کنیم

و بعد بگیم ک اگر این قسمت از توی تنظیمات پوسته اگر پر شد نمایش داده بشه ، اگر پر نشد نمایش داده نشه

لینک به ارسال

آموزش ایجاد تنظیمات در بخش آموزش هست

برای بررسی هم:


if($mysetting){
// more code
}

لینک به ارسال

خدا رو شکر اینقدر پیچیده فرمودید که من اصلاً نفهمیدم!

اما آیا منظورتون اینه که مثلاً باکس در صورتی که تعداد کاراکتر ها به 600 کاراکتر رسید نمایش داده بشه و اگر کمتر بود پنهان بمونه؟

لینک به ارسال

کجاش پیچیده بود ؟

میگم اگ داخل باکس آدرسی وارد شد نمایش داده بشه و اگ آدرسی نوشته نشد نمایش نده

لینک به ارسال

بعد میخوام اگر مثلا آدرس یه عکس نوشته شد در تنظیمات یک کلاس پایینش قرار بگیره ک مثلا خط نارنجی باشه ، استایل این خط رو نوشتم و فراخوانی کردم

حالا چیکار کنم ک اگر در تنظیمات نوشته شد اون خط نارنجی هم بالاش بیاد ؟

لینک به ارسال

در پست 2 دقیقاً گفته شد که چه کار باید بکنید

اما اگر این باکس از نوع زمینه های دلخواه است در بخشی از آموزش زیر راهکار گفته شده

http://forum.wp-parsi.com/tutorials/article/221-%D8%B2%D9%85%DB%8C%D9%86%D9%87-%D8%AF%D9%84%D8%AE%D9%88%D8%A7%D9%87-%D9%BE%DB%8C%D8%B4%D8%B1%D9%81%D8%AA%D9%87/

این باکس از چه جنسیه؟ یعنی در ادیتور متن ایجاد میشه؟ یا مثلاً در تگ ها یا زمینه های دلخواه یا ....؟

لینک به ارسال


<tr valign="top">
<th scope="row">ساید بار15:</th>
<td>
<input id="showcaser_theme_settings[s15_img]" class="regular-text" type="text" size="36" name="showcaser_theme_settings[s15_img]" value="<?php esc_attr_e( $options['s15_img'] ); ?>" />
</td>
</tr>

مثلا کد بالا رو در تنظیمات گذاشتم

میخوام وقتی داخل این باکس از توی تنظیمان آدرسی قرار نگرفته چیزی نشون داده نشه ، الان تونستم کاری کنم ک عکس نشون داده نشه

ولی صفه اسکرول میخوره ، جای عکس هست ، با فایر باگ ک میری روش هستش

ولی چیزی نمایش نمیده چون آدرسی وارد نشده

میخوام کاری کنم تا آدرسی نذاشتم جاش هم نباشه

ویرایش شده توسط goldenfont
لینک به ارسال

<?php if($options['s15_img'] != "") { ?>
<tr valign="top">
<th scope="row">ساید بار15:</th>
<td>
<input id="showcaser_theme_settings[s15_img]" class="regular-text" type="text" size="36" name="showcaser_theme_settings[s15_img]" value="<?php esc_attr_e( $options['s15_img'] ); ?>" />
</td>
</tr>
<?php } ?>

لینک به ارسال

با این کد سایت دگ بالا نمیاد !!!!

Parse error: syntax error, unexpected $end in /home2/domains/public_html/wp-content/themes/admin/theme-admin.php on line 421

چیکار کنم حالا ؟

به هاست هم دسترسی ندارم ! وای

ویرایش شده توسط goldenfont
لینک به ارسال

کد که سالمه - تست هم شد - احتمالا شرط های دیگه ی جدول رو شکونده

به هر حال فعلاً باید به هاست دسترسی داشته باشید - چطور ممکنه که دسترسی ندارید؟ با مدیر سرورتون تماس بگیرید

لینک به ارسال

خب سایت بالا آمد - حالا فایل رو پیوست کنید اینجا - اگر امکان داره براتون لینک قالب رو از سایت سازنده بدید تا ویرایش کنم

لینک به ارسال

اینهم کدهای پنل تنظیمات :


<?php
/**
* @package WordPress
* @subpackage Showcaser Theme
*/
//register settings
function showcaser_theme_settings_init(){
register_setting( 'showcaser_theme_settings', 'showcaser_theme_settings' );
}
//menu
function showcaser_add_settings_page() {
add_menu_page( __( 'Showcaser' ), __( 'تنظيمات پوسته' ), 'manage_options', 'showcaser-settings', 'showcaser_theme_settings_page');
}
add_action( 'admin_init', 'showcaser_theme_settings_init' );
add_action( 'admin_menu', 'showcaser_add_settings_page' );
//start settings page
function showcaser_theme_settings_page() {
global $slider_effects;
if ( ! isset( $_REQUEST['updated'] ) )
$_REQUEST['updated'] = false;
?>
<div class="wrap">
<div id="icon-options-general" class="icon32"></div>
<h2><?php _e( 'تنظيمات پوسته' ) ?></h2>

<?php if ( false !== $_REQUEST['updated'] ) : ?>
<div class="updated fade"><p><strong><?php _e( 'Options saved' ); ?></strong></p></div>
<?php endif; ?>
<form method="post" action="options.php">
<?php settings_fields( 'showcaser_theme_settings' ); ?>
<?php $options = get_option( 'showcaser_theme_settings' ); ?>
<table class="form-table">
<tr valign="top">
<th scope="row">همکاران ساخت پوسته</th>
<td><p>پوسته <a href="http://www.wpexplorer.com/showcaser-wordpress-theme.html">Showcaser</a> ساخته شده توسط AJ Clarke <a href="http://www.wpexplorer.com"><strong>WPExplorer.com</strong></a></p>
ويرايش و ترجمه پوسته توسط گروه <a href="http://rooeen.com/" style="color: rgb(0, 204, 204);"><strong>رويين</strong></a>
</td>
</tr>
<tr valign="top">
<th scope="row">لایک زدن صفحه سازنده پوسته</th>
<td><div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#appId=215260205165212&xfbml=1"></script><fb:like href="http://www.wpexplorer.com/" send="true" layout="button_count" width="450" height="40" show_faces="false" font=""></fb:like></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'ایکون کنار نوار آدرس (favicon)' ); ?></th>
<td>
<input id="showcaser_theme_settings[favicon]" class="regular-text" type="text" size="36" name="showcaser_theme_settings[favicon]" value="<?php esc_attr_e( $options['favicon'] ); ?>" />
<br />
<label class="description abouttxtdescription" for="showcaser_theme_settings[favicon]"><?php _e( 'آپلود کنید یا آدرس ایکون را وارد کنید.' ); ?></label>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'لوگو' ); ?></th>
<td>
<input id="showcaser_theme_settings[logo]" class="regular-text" type="text" size="36" name="showcaser_theme_settings[logo]" value="<?php esc_attr_e( $options['logo'] ); ?>" />
<br />
<label class="description abouttxtdescription" for="showcaser_theme_settings[logo]"><?php _e( 'آپلود کنید یا آدرس تصویر لوگو را وارد کنید.' ); ?></label>
</td>
</tr>
<tr valign="top">
<th scope="row">هدر پوسته:</th>
<td>
<input id="showcaser_theme_settings[header_img]" class="regular-text" type="text" size="36" name="showcaser_theme_settings[header_img]" value="<?php esc_attr_e( $options['header_img'] ); ?>" />
</td>
</tr>
<tr valign="top">
<th scope="row">فوتر پوسته:</th>
<td>
<input id="showcaser_theme_settings[footer_img]" class="regular-text" type="text" size="36" name="showcaser_theme_settings[footer_img]" value="<?php esc_attr_e( $options['footer_img'] ); ?>" />
</td>
</tr>
<tr valign="top">
<th scope="row">ساید بار1:</th>
<td>
<input id="showcaser_theme_settings[s1_img]" class="regular-text" type="text" size="36" name="showcaser_theme_settings[s1_img]" value="<?php esc_attr_e( $options['s1_img'] ); ?>" />
</td>
</tr>
<tr valign="top">
<th scope="row">ساید بار2:</th>
<td>
<input id="showcaser_theme_settings[s2_img]" class="regular-text" type="text" size="36" name="showcaser_theme_settings[s2_img]" value="<?php esc_attr_e( $options['s2_img'] ); ?>" />
</td>
</tr>
<tr valign="top">
<th scope="row">ساید بار3:</th>
<td>
<input id="showcaser_theme_settings[s3_img]" class="regular-text" type="text" size="36" name="showcaser_theme_settings[s3_img]" value="<?php esc_attr_e( $options['s3_img'] ); ?>" />
</td>
</tr>
<tr valign="top">
<th scope="row">ساید بار4:</th>
<td>
<input id="showcaser_theme_settings[s4_img]" class="regular-text" type="text" size="36" name="showcaser_theme_settings[s4_img]" value="<?php esc_attr_e( $options['s4_img'] ); ?>" />
</td>
</tr>
<tr valign="top">
<th scope="row">ساید بار5:</th>
<td>
<input id="showcaser_theme_settings[s5_img]" class="regular-text" type="text" size="36" name="showcaser_theme_settings[s5_img]" value="<?php esc_attr_e( $options['s5_img'] ); ?>" />
</td>
</tr>
<tr valign="top">
<th scope="row">فعال کردن ساید بار5:</th>
<td>
<input id="showcaser_theme_settings[s5_on]" class="regular-text" type="text" size="36" name="showcaser_theme_settings[s5_on]" value="<?php esc_attr_e( $options['s5_on'] ); ?>" />
</td>
</tr>

<tr valign="top">
<th scope="row">ساید بار6:</th>
<td>
<input id="showcaser_theme_settings[s6_img]" class="regular-text" type="text" size="36" name="showcaser_theme_settings[s6_img]" value="<?php esc_attr_e( $options['s6_img'] ); ?>" />
</td>
</tr>

<tr valign="top">
<th scope="row">فعال کردن ساید بار6:</th>
<td>
<input id="showcaser_theme_settings[s6_on]" class="regular-text" type="text" size="36" name="showcaser_theme_settings[s6_on]" value="<?php esc_attr_e( $options['s6_on'] ); ?>" />
</td>
</tr>


<tr valign="top">
<th scope="row"><?php _e( 'کد آمارگیر آنالیزگر' ); ?></th>
<td>
<textarea id="showcaser_theme_settings[analytics]" class="regular-text" name="showcaser_theme_settings[analytics]" rows="5" cols="45"><?php esc_attr_e( $options['analytics'] ); ?></textarea>
<br />
<label class="description" for="showcaser_theme_settings[analytics]"><?php _e( 'کد آنالیزگر را وارد کنید' ); ?></label>
</td>
</tr>
<tr valign="top">
<th scope="row">دانلود پوسته های بیشتر</th>
<td>
<a href="http://rooeen.com/category/wordpress/wp-themes" style="text-decoration:none;">پوسته های وردپرس رایگان</a>
</td>
</tr>
</table>
<p class="submit-changes">
<input type="submit" class="button-primary" value="<?php _e( 'ذخیره تغییرات' ); ?>" />
</p>
</form>
</div><!-- END wrap -->
<?php
}
//sanitize and validate
function showcaser_options_validate( $input ) {
global $select_options, $radio_options;
if ( ! isset( $input['option1'] ) )
$input['option1'] = null;
$input['option1'] = ( $input['option1'] == 1 ? 1 : 0 );
$input['sometext'] = wp_filter_nohtml_kses( $input['sometext'] );
if ( ! isset( $input['radioinput'] ) )
$input['radioinput'] = null;
if ( ! array_key_exists( $input['radioinput'], $radio_options ) )
$input['radioinput'] = null;
$input['sometextarea'] = wp_filter_post_kses( $input['sometextarea'] );
return $input;
}
?>

لینک به ارسال

اینجا که نه ساید 15 هست و نه s15_img - بفرمایید کدوم رو می خواهید در صورت خالی بودن مخفی کنید؟

لینک به ارسال

کد:


<tr valign="top">
<th scope="row">فعال کردن ساید بار5:</th>
<td>
<input id="showcaser_theme_settings[s5_on]" class="regular-text" type="text" size="36" name="showcaser_theme_settings[s5_on]" value="<?php esc_attr_e( $options['s5_on'] ); ?>" />
</td>
</tr>

به


<?php if($options['s5_on'] != "") { ?>
<tr valign="top">
<th scope="row">فعال کردن ساید بار5:</th>
<td>
<input id="showcaser_theme_settings[s5_on]" class="regular-text" type="text" size="36" name="showcaser_theme_settings[s5_on]" value="<?php esc_attr_e( $options['s5_on'] ); ?>" />
</td>
</tr>
<?php } ?>

و


<tr valign="top">
<th scope="row">ساید بار5:</th>
<td>
<input id="showcaser_theme_settings[s5_img]" class="regular-text" type="text" size="36" name="showcaser_theme_settings[s5_img]" value="<?php esc_attr_e( $options['s5_img'] ); ?>" />
</td>
</tr>

به


<?php if($options['s5_img'] != "") { ?>
<tr valign="top">
<th scope="row">ساید بار5:</th>
<td>
<input id="showcaser_theme_settings[s5_img]" class="regular-text" type="text" size="36" name="showcaser_theme_settings[s5_img]" value="<?php esc_attr_e( $options['s5_img'] ); ?>" />
</td>
</tr>
<?php } ?>

تبدیل شود

لینک به ارسال

فک کنم شما منظور منو اشتباه متوجه شدید

نگاه کنید با اینکار فک کنم از توی پنل تنظیمات پاک میشه

من میخوام این در پنل تنظیمات باشه ( بخش ساید بار 5 رو میگم )

و تا وقتی ک در اون آدرسی قرار داده نشده ، در صفه اصلی سایت چیزی نمایش داده نشه

الان وقتی توش چیزی ننویسی تو صفه اصلی نمایش داده نمیشه چون لینک نداره

ولی خب جاش هستش

ینی اسکرول میخوره میره پایین

امیدوارم منظورمو فهمیده باشید

لینک به ارسال

خب شما به جای اون فایل باید کد فراخوانی فایل ساید 5 رو بدید - یعنی باید فایلی که در داخل اون ساید 5 فراخوانی میشه رو بدید

و البته اگر قالب سایتتون با قوانین منطبق باشه!

لینک به ارسال

بله مطابقه


<a href="/"><img width="95" height="90" class="posts-widget-featured-image alignleft wp-post-image" src="<?php
$options = get_option( 'showcaser_theme_settings' );
echo $options['s5_img'];
?>"></a>

لینک به ارسال

باز اگر ناقص نداده باشید و شرط empty‌ شرط های دیگه رو نمیشکنه تست کنید:


<?php if($options['s5_img'] != "") { ?>
<a href="/"><img width="95" height="90" class="posts-widget-featured-image alignleft wp-post-image" src="<?php
$options = get_option( 'showcaser_theme_settings' );
echo $options['s5_img'];
?>"></a>
<?php } ?>

لینک به ارسال

به گفتگو بپیوندید

هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .

مهمان
ارسال پاسخ به این موضوع ...

×   شما در حال چسباندن محتوایی با قالب بندی هستید.   حذف قالب بندی

  تنها استفاده از 75 اموجی مجاز می باشد.

×   لینک شما به صورت اتوماتیک جای گذاری شد.   نمایش به صورت لینک

×   محتوای قبلی شما بازگردانی شد.   پاک کردن محتوای ویرایشگر

×   شما مستقیما نمی توانید تصویر خود را قرار دهید. یا آن را اینجا بارگذاری کنید یا از یک URL قرار دهید.

×
×
  • اضافه کردن...