رفتن به مطلب

مشکل با فایل function.php قالب


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

سلام دوستان یه قالب وردپرس دارم وقتی فعالش میکنم نمیتونم هیچ فایلی مثل عکس تو داخل وردپرس  اپلود کنم بعد از بررسی های زیاد فهمیدم مشکل اپلود عکس و فایل مشکلش از این فایلfunctions قالب هست . وقتی این فایلو حذف میکنم بدون مشکل با همین قالب میتونم فایل عکس اینا اپ کنم

نمیدونم چه مشکلی تو کد نویسیش هست.کدش اینه ..ممنون میشم راهنمایی کنید.

 

<?php 
include(TEMPLATEPATH .'/admin/advertising.php');
include(TEMPLATEPATH .'/admin/setting.php');
if (function_exists('add_theme_support')) {
add_theme_support( 'post-thumbnails' );
}
function get_image_url(){
$image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id,'full');
$image_url = $image_url[0];
echo $image_url;
}
function catch_that_image() {
 global $post, $posts;
 $first_img = '';
 ob_start();
 ob_end_clean();
 $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
 $first_img = $matches [1] [0];
if(empty($first_img)){ //Defines a default image
 $first_img = "/images/no-thumbnail3.png";
 }
 return $first_img;
}
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'improved_trim_excerpt');
function improved_trim_excerpt($text) {
 global $post;
 if ( '' == $text ) {
 $text = get_the_content('');
 $text = apply_filters('the_content', $text);
 $text = str_replace(']]>', ']]&gt;', $text);
 $text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
 $text = strip_tags($text, '');
 $excerpt_length = 75;
 $words = explode(' ', $text, $excerpt_length + 1);
 if (count($words)> $excerpt_length) {
 array_pop($words);
 array_push($words, '[...]');
 $text = implode(' ', $words);
 }
 }
 return $text;
}

if ( function_exists('register_sidebar') )
register_sidebar(array(
'name'          => 'ابزارک چپ',
'description'   => '',
'before_widget' => '<div class="box"><div class="title"><div class="icon red"><span class="icon-paper-clip" style="margin: 5px 5.5px 0px 0px;"></span></div>',
'after_widget'  => '</div></div>',
'before_title'  => '<h4>',
'after_title'   => '</h4></div><div class="content">',
));
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name'          => 'ابزارک راست',
'description'   => '',
'before_widget' => '<div class="box"><div class="title"><div class="icon red"><span class="icon-paper-clip" style="margin: 5px 5.5px 0px 0px;"></span></div>',
'after_widget'  => '</div></div>',
'before_title'  => '<h4>',
'after_title'   => '</h4></div><div class="content">',
));
?>
<?php
function add_custom_meta_box() {  
    add_meta_box(  
        'custom_meta_box',   
        '!اطلاعات مطلب را وارد کنید',   
        'show_custom_meta_box',   
        'post',   
        'normal',   
        'high');   
}  
add_action('add_meta_boxes', 'add_custom_meta_box');  
// Field Array  
    $prefix = '';  
    $custom_meta_fields = array(   
		array(  
            'label'=> '<b style="color:#A31C2B">نام خواننده</b>',  
            'desc'  => '',  
            'id'    => $prefix.'name1',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> '<b style="color:#A31C2B">نام اثر</b>',  
            'desc'  => '',  
            'id'    => $prefix.'name2',  
            'type'  => 'text'  
        ),
		array(  
            'label'=> 'نام خواننده دوم',  
            'desc'  => '',  
            'id'    => $prefix.'name3',  
            'type'  => 'text'  
        ),
	
        array(
        'label'=> 'موضوع مطلب',
        'desc'  => '',
        'id'    => $prefix.'select',
        'type'  => 'select',
        'options' => array (
            'music' => array (
                'label' => 'موزیک',
                'value' => 'music'
            ),
            'album' => array (
                'label' => 'آلبوم',
                'value' => 'album'
            ),
            'musicvideo' => array (
                'label' => 'موزیک ویدیو',
                'value' => 'musicvideo'
            ),
            'news' => array (
                'label' => 'اخبار',
                'value' => 'news'
            )
            )
            ),
	
        array(
        'label'=> 'عنوان مطلب',
        'desc'  => '',
        'id'    => $prefix.'select2',
        'type'  => 'select',
        'options' => array (
            'public' => array (
                'label' => 'پخش شده',
                'value' => 'public'
            ),
            'soon' => array (
                'label' => 'به زودی',
                'value' => 'soon'
            ),
            'hot' => array (
                'label' => 'ویژه',
                'value' => 'hot'
            )
            )
            ),
        array(  
            'label'=> 'لینک عکس پست ویژه',  
            'desc'  => '',  
            'id'    => $prefix.'special',  
            'type'  => 'text'  
        ),
        array('label'=> '<p style="color: #1c6ba3; border-bottom: 1px solid #F2F2F2; font-weight: bold; padding: 5px 0px;">اطلاعات مربوط به دانلود آهنگ</p>',),
		array('label'=> '',),
		array('label'=> '',),
        array(  
            'label'=> 'لینک آهنگ کیفیت 320',  
            'desc'  => '',  
            'id'    => $prefix.'music320',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ کیفیت 128',  
            'desc'  => '',  
            'id'    => $prefix.'music128',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ برای پخش آنلاین و کد وبلاگ',  
            'desc'  => '',  
            'id'    => $prefix.'online',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> '<b style="color: #1c6ba3; border-bottom: 1px solid #F2F2F2; font-weight: bold; padding: 5px 0px;">اطلاعات مربوط به دانلود آلبوم</b>',  
        ),
		array('label'=> '',),
		array('label'=> '',),
        array(  
            'label'=> 'لینک دانلود آلبوم 320',  
            'desc'  => '',  
            'id'    => $prefix.'albume320',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک دانلود آلبوم 320 تکی',  
            'desc'  => '',  
            'id'    => $prefix.'talbume320',  
            'type'  => 'text'  
        ),
		array('label'=> '',),
        array(  
            'label'=> 'لینک دانلود آلبوم 128',  
            'desc'  => '',  
            'id'    => $prefix.'albume128',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک دانلود آلبوم 128 تکی',  
            'desc'  => '',  
            'id'    => $prefix.'talbume128',  
            'type'  => 'text'  
        ),
		array('label'=> '',),
        array(  
            'label'=> '<b style="color: #1c6ba3; border-bottom: 1px solid #F2F2F2; font-weight: bold; padding: 5px 0px;">اطلاعات مربوط به دانلود موزیک ویدیو</b>',  
        ),
		array('label'=> '',),
		array('label'=> '',),
        array(  
            'label'=> 'موزیک ویدیو با کیفیت 1080p عالی',  
            'desc'  => '',  
            'id'    => $prefix.'video1080p',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'موزیک ویدیو با کیفیت 720p متوسط',  
            'desc'  => '',  
            'id'    => $prefix.'video720p',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'موزیک ویدیو با کیفیت 480p پایین',  
            'desc'  => '',  
            'id'    => $prefix.'video480p',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'موزیک ویدیو با کیفیت موبایل',  
            'desc'  => '',  
            'id'    => $prefix.'videomob',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک موزیک ویدیو پخش آنلاین',  
            'desc'  => '',  
            'id'    => $prefix.'vonline',  
            'type'  => 'text'  
        ),
        array('label'=> '',),
        array(  
            'label'=> '<b style="color:#1c6ba3">اطلاعات مربوط به آلبوم پخش آنلاین</b>',  
        ),
        array(  
            'label'=> '<b style="color:#a31c2c">جهت نمایش آلبوم پخش آنلاین</b>',  
            'desc'  => 'حتما این تیک زده شود',  
            'id'    => $prefix.'albume-online',  
            'type'  => 'checkbox'  
        ),
        array('label'=> '',),
        array(  
            'label'=> 'عنوان آهنگ 1',  
            'desc'  => '',  
            'id'    => $prefix.'txtmusic1',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 128',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic1281',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 320',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic3201',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'عنوان آهنگ 2',  
            'desc'  => '',  
            'id'    => $prefix.'txtmusic2',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 128',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic1282',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 320',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic3202',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'عنوان آهنگ 3',  
            'desc'  => '',  
            'id'    => $prefix.'txtmusic3',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 128',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic1283',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 320',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic3203',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'عنوان آهنگ 4',  
            'desc'  => '',  
            'id'    => $prefix.'txtmusic4',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 128',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic1284',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 320',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic3204',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'عنوان آهنگ 5',  
            'desc'  => '',  
            'id'    => $prefix.'txtmusic5',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 128',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic1285',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 320',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic3205',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'عنوان آهنگ 6',  
            'desc'  => '',  
            'id'    => $prefix.'txtmusic6',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 128',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic1286',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 320',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic3206',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'عنوان آهنگ 7',  
            'desc'  => '',  
            'id'    => $prefix.'txtmusic7',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 128',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic1287',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 320',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic3207',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'عنوان آهنگ 8',  
            'desc'  => '',  
            'id'    => $prefix.'txtmusic8',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 128',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic1288',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 320',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic3208',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'عنوان آهنگ 9',  
            'desc'  => '',  
            'id'    => $prefix.'txtmusic9',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 128',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic1289',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 320',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic3209',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'عنوان آهنگ 10',  
            'desc'  => '',  
            'id'    => $prefix.'txtmusic10',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 128',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic12810',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 320',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic32010',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'عنوان آهنگ 11',  
            'desc'  => '',  
            'id'    => $prefix.'txtmusic11',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 128',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic12811',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 320',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic32011',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'عنوان آهنگ 12',  
            'desc'  => '',  
            'id'    => $prefix.'txtmusic12',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 128',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic12812',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 320',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic32012',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'عنوان آهنگ 13',  
            'desc'  => '',  
            'id'    => $prefix.'txtmusic13',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 128',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic12813',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 320',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic32013',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'عنوان آهنگ 14',  
            'desc'  => '',  
            'id'    => $prefix.'txtmusic14',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 128',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic12814',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 320',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic32014',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'عنوان آهنگ 15',  
            'desc'  => '',  
            'id'    => $prefix.'txtmusic15',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 128',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic12815',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 320',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic32015',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'عنوان آهنگ 16',  
            'desc'  => '',  
            'id'    => $prefix.'txtmusic16',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 128',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic12816',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 320',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic32016',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'عنوان آهنگ 17',  
            'desc'  => '',  
            'id'    => $prefix.'txtmusic17',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 128',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic12817',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 320',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic32017',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'عنوان آهنگ 18',  
            'desc'  => '',  
            'id'    => $prefix.'txtmusic18',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 128',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic12818',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 320',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic32018',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'عنوان آهنگ 19',  
            'desc'  => '',  
            'id'    => $prefix.'txtmusic19',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 128',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic12819',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 320',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic32019',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'عنوان آهنگ 20',  
            'desc'  => '',  
            'id'    => $prefix.'txtmusic20',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 128',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic12820',  
            'type'  => 'text'  
        ),
        array(  
            'label'=> 'لینک آهنگ 320',  
            'desc'  => '',  
            'id'    => $prefix.'linkmusic32020',  
            'type'  => 'text'  
        ),
    );
    function show_custom_meta_box() {  
    global $custom_meta_fields, $post;   
    echo '<input type="hidden" name="custom_meta_box_nonce" value="'.wp_create_nonce(basename(__FILE__)).'" />';  
        echo '<div style="width:100%;display: inline-block;">';  
        foreach ($custom_meta_fields as $field) {   
            $meta = get_post_meta($post->ID, $field['id'], true);  
            echo '<div style="width:33%;display: inline-block;padding:5px 0px"> 
                    <label for="'.$field['id'].'" style="width: 90%; display: inline-block;padding:5px 0px">'.$field['label'].'</label> 
                    ';  
                    switch($field['type']) {  
    case 'text':  
        echo '<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$meta.'" style="width: 90%; display: inline-block;"> 
            <span class="description">'.$field['desc'].'</span>';  
    break;
	// checkbox
case 'checkbox':
	echo '<input type="checkbox" name="'.$field['id'].'" id="'.$field['id'].'" ',$meta ? ' checked="checked"' : '','/>
		<label for="'.$field['id'].'">'.$field['desc'].'</label>';
break;	

		// textarea
case 'textarea':
    echo '<textarea name="'.$field['id'].'" id="'.$field['id'].'" style="width:90%">'.$meta.'</textarea>
        <br /><span class="description">'.$field['desc'].'</span>';
break;

// select
case 'select':
    echo '<select name="'.$field['id'].'" id="'.$field['id'].'">';
    foreach ($field['options'] as $option) {
        echo '<option', $meta == $option['value'] ? ' selected="selected"' : '', ' value="'.$option['value'].'">'.$option['label'].'</option>';
    }
    echo '</select><br /><span class="description">'.$field['desc'].'</span>';
break;
                    } 
            echo '</div>';  
        }  
        echo '</div>'; 
    }  
function save_custom_meta($post_id) {  
    global $custom_meta_fields;   
    if (!wp_verify_nonce($_POST['custom_meta_box_nonce'], basename(__FILE__)))  
        return $post_id;    
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)  
        return $post_id;  
    if ('page' == $_POST['post_type']) {  
        if (!current_user_can('edit_page', $post_id))  
            return $post_id;  
        } elseif (!current_user_can('edit_post', $post_id)) {  
            return $post_id;  
    }  
    foreach ($custom_meta_fields as $field) {  
        $old = get_post_meta($post_id, $field['id'], true);  
        $new = $_POST[$field['id']];  
        if ($new && $new != $old) {  
            update_post_meta($post_id, $field['id'], $new);  
        } elseif ('' == $new && $old) {  
            delete_post_meta($post_id, $field['id'], $old);  
        }  
    }  
}  
add_action('save_post', 'save_custom_meta');    	
?>

 

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

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

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

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

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

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

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

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

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

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