2013-09-26 49 views
-4

新的在這裏和一點點noob。試圖將字段添加到自定義帖子類型,並在所有網站頁面上出現解析錯誤消息。我粘貼了錯誤信息和承包商type.php代碼誰能告訴我如何解決這個問題?我沒有運氣到託管服務提供商做完整的恢復。非常感謝任何和所有的建議。我目前沒有ftp訪問權限,所有唯一能做的就是使用主機控制面板中的文件管理器嘗試上傳備份的主題文件副本,但無濟於事。WordPress的:解析錯誤:語法錯誤,意外的'陣列'(T_ARRAY)網站破壞

解析錯誤:語法錯誤,意外的'數組'(T_ARRAY),期待')'在/home/renovant/public_html/wp-content/themes/renovantage/self-developed-plugin/contractor-type.php上212行

<?php 


function get_contractor_info($id) 
{ 
    if($id==0)return; 
    $p  = get_post($id); 
    $infos = get_post_custom($id); 
    $return = array(); 
    $return['id']  = $id; 
    $return['company'] = $p->post_title; 
    foreach($infos as $key => $vls) 
    { 
     $return[$key] = $vls[0]; 
    } 
    return $return; 
} 
add_action('init', 'tr_contractor_type'); 


function tr_contractor_type() { 
    $labels = array(
     'name' => _x('Contractors', 'post type general name'), 
     'singular_name' => _x('Contractor', 'post type singular name'), 
     'add_new' => _x('Add New Contractor', 'article'), 
     'add_new_item' => __('Add New Contractor'), 
     'edit_item' => __('Edit Contractor'), 
     'new_item' => __('New Contractor'), 
     'view_item' => __('View Contractor'), 
     'search_items' => __('Search Contractor'), 
     'not_found' => __('No Contractors found'), 
     'not_found_in_trash' => __('No Contractors found in Trash'), 
     'parent_item_colon' => '' 
     ); 

    $supports = array(
     'title', 
    // 'editor', 
     //'author', 
     'thumbnail', 
     //'excerpt', 
    // 'comments', 
    // 'custom-fields', 
    // 'trackbacks', 
     'revisions' 
     ); 


    $args = array(
     'labels' => $labels, 
     'public' => true, 
     'capability_type' => 'post', 
     'supports' => $supports, 

     'rewrite' => array('slug' => 'contractor','with_front' => false), 
     'taxonomies' => array('category') 
     ); 

    register_post_type('contractor', $args); 
} 


add_action('admin_init','tr_admin_init_add_con'); 
function tr_admin_init_add_con() 
{ 
    global $wpdb; 

    if($_GET['act'] !='cc')return; 
    $results = $wpdb->get_results(
    "SELECT * FROM ".'wpms1_contractor'." "); 

    foreach($results as $row) 
    { 
     $post_title = $row->company; 
     $post_content = ''; 
     $post_status = 'publish'; 
     $post_type = 'contractor'; 
     $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'to_ping', 'post_type', 'post_name', 'post_password', 'post_parent', 'menu_order', 'tags_input', 'page_template'); 
     //$post_id = wp_insert_post($postdata); 
     //$post = $wpdb->get_row("select ID from {$wpdb->posts} where post_title = '{$row->company}'"); 

     if($post_id>0) 
     { 
      update_post_meta($post_id,'address',$row->company_address); 
      update_post_meta($post_id,'address2',$row->company_address2); 
      update_post_meta($post_id,'city',$row->company_city); 
      update_post_meta($post_id,'province',$row->company_province); 
      update_post_meta($post_id,'country',$row->company_country); 
      update_post_meta($post_id,'postal_code',$row->company_postal); 
      update_post_meta($post_id,'owner',$row->company_owner); 
      update_post_meta($post_id,'contact_name',$row->company_contact); 
      update_post_meta($post_id,'phone1',$row->company_phone); 
      update_post_meta($post_id,'phone2',$row->company_phone2); 
      update_post_meta($post_id,'fax',$row->company_fax); 
      update_post_meta($post_id,'website',$row->company_website); 
      update_post_meta($post_id,'email',$row->company_email); 
      update_post_meta($post_id,'email2',$row->company_email2); 
      update_post_meta($post_id,'overview',$row->company_overview); 
      update_post_meta($post_id,'motto',$row->company_motto); 
      update_post_meta($post_id,'services',$row->company_services); 
      update_post_meta($post_id,'postal_prefixes',$row->postal_prefix); 
      update_post_meta($post_id,'profile_column_1_title',$row->title1); 
      update_post_meta($post_id,'profile_column_1_description',$row->description1); 
      update_post_meta($post_id,'profile_column_2_title',$row->title2); 
      update_post_meta($post_id,'profile_column_2_description',$row->description2); 
      update_post_meta($post_id,'profile_column_3_title',$row->title3); 
      update_post_meta($post_id,'profile_column_3_description',$row->description3); 
     } 
    } 
} 

//hide button media 
add_action('admin_menu','tr_admin_menu_landing_hidemedia',11); 
function tr_admin_menu_landing_hidemedia() 
{ 
    $rs = wp_get_current_user(); 
    foreach((array) $rs->roles as $role) 
    { 
     if($role == 'subscriber') 
     { 
      remove_menu_page('upload.php'); 
     } 
    } 
} 

function tr_landing_is_admin() 
{ 
    $rs = wp_get_current_user(); 
    foreach((array) $rs->roles as $role) 
    { 
     if($role == 'administrator') 
     { 
      return true; 
     } 
    } 
    return false; 
} 


$profile_metaboxs =array(); 

$Company_fields = array(
         'address' => 'Address', 
         'address2' => 'Address2', 
         'city' => 'City', 
         'province' => 'Province', 
         'country' => 'Country', 
         'postal_code' =>'Postal Code', 
         'website' => 'Website', 
         'owner' => 'Owner', 
         'contact_name' => ' Contact Name', 
         'phone1' => 'Phone 1', 
         'phone2' => 'Phone 2', 
         'fax' => 'Fax', 
         'email' => 'Email', 
         'email2' => 'Email2', 

         ); 
$Company_fieldsb= array(); 
foreach($Company_fields as $k => $f) 
{ 

    $Company_fieldsb[] = array(
         'id'=>$k, 
         'label'=>"{$f}:", 
         'name'=>$k, 
         'type'=>"text" 
        ); 
} 

$profile_metaboxs[] = array(
     'id'=>'profile-meta-box-1', 
     'title'=>'Company Information', 
     'page'=> 'contractor', 
     'context'=>'normal', 
     'priority'=>'high', 
     'fields'=>$Company_fieldsb 
    ); 

$profile_metaboxs[] = array(
     'id'=>'profile-meta-box-2', 
     'title'=>'Profile Overview', 
     'page'=> 'contractor', 
     'context'=>'normal', 
     'priority'=>'high', 
     'fields'=>array(
        array(
         'id'=>'overview', 
         'label'=>"Overview:", 
         'type'=>"textarea", 
         'height' => '100px' 
        ), 
        array(
         'id'=>'motto', 
         'label'=>"Motto:", 
         'type'=>"textarea", 
         'height' => '100px' 
        ), 
        array(
         'id'=>'services', 
         'label'=>"Services:", 
         'type'=>"textarea", 
         'height' => '100px' 
        ), 
        array(
         'id'=>'postal_prefixes', 
         'label'=>"Postal Prefixes:", 
         'type'=>"textarea", 
         'height' => '100px', 
         'readonly' => (!tr_landing_is_admin()) 
        ) 
     // LINE 212 as per comment from OP 
    ); 

$profile_metaboxs[] = array(
     'id'=>'profile-meta-box-3', 
     'title'=>'Profile Column 1', 
     'page'=> 'contractor', 
     'context'=>'normal', 
     'priority'=>'high', 
     'fields'=>array(
        array(
         'id'=>'profile_column_1_title', 
         'label'=>"Title:", 
         'type'=>"text", 
        ), 
        array(
         'id'=>'profile_column_1_image', 
         'label'=>"Image:", 
         'type'=>"img", 
        ), 
        array(
         'id'=>'profile_column_1_description', 
         'label'=>"Description:", 
         'type'=>"textarea", 
         'height' => '100px' 
        ) 
     ) 
    ); 


$profile_metaboxs[] = array(
     'id'=>'profile-meta-box-4', 
     'title'=>'Profile Column 2', 
     'page'=> 'contractor', 
     'context'=>'normal', 
     'priority'=>'high', 
     'fields'=>array(
        array(
         'id'=>'profile_column_2_title', 
         'label'=>"Title:", 
         'type'=>"text", 
        ), 
        array(
         'id'=>'profile_column_2_image', 
         'label'=>"Image:", 
         'type'=>"img", 
        ), 
        array(
         'id'=>'profile_column_2_description', 
         'label'=>"Description:", 
         'type'=>"textarea", 
         'height' => '100px' 
        ) 
     ) 
    ); 

$profile_metaboxs[] = array(
     'id'=>'profile-meta-box-5', 
     'title'=>'Profile Column 3', 
     'page'=> 'contractor', 
     'context'=>'normal', 
     'priority'=>'high', 
     'fields'=>array(
        array(
         'id'=>'profile_column_3_title', 
         'label'=>"Title:", 
         'type'=>"text", 
        ), 
        array(
         'id'=>'profile_column_3_image', 
         'label'=>"Image:", 
         'type'=>"img", 
        ), 
        array(
         'id'=>'profile_column_3_description', 
         'label'=>"Description:", 
         'type'=>"textarea", 
         'height' => '100px' 
        ) 
     ) 
    ); 
    $profile_metaboxs[]=array(
     'id'=>'page-meta-box-6', 
     'title'=>'Header Box', 
     'page'=> 'contractor', 
     'context'=>'normal', 
     'priority'=>'high', 
     'fields'=>array(    
        array(
         'id'=>"header_title", 
         'label'=>"Title:", 
         'name'=>"header_title", 
         'type'=>"text" 
        ), 
        array(
         'id'=>"header_content", 
         'label'=>"Content:", 
         'name'=>"header_content", 
         'type'=>"text" 
        ), 
        array(
         'id'=>"header_link_text", 
         'label'=>"Text Link:", 
         'name'=>"header_link_text", 
         'type'=>"text" 
        ), 
        array(
         'id'=>"header_link_url", 
         'label'=>"Link:", 
         'name'=>"header_link_url", 
         'type'=>"text" 
        ), 

      ) 
    ); 
foreach ($profile_metaboxs as $meta_box) { 
    $my_box = new Ant_Meta_Box($meta_box); 
} 

add_filter('post_row_actions', 'tr_landing_row_actions'); 
function tr_landing_row_actions($actions){ 
    global $post; 

    if($post->post_type == 'contractor') 
    { 
     $actions['referral'] = '<a href="'.get_bloginfo('url').'/referral/'.$post->post_name.'" >Referral</a>'; 
    } 

    return $actions; 
} 
+5

像聽上去那麼瘋狂,我們沒有辦法知道這是行212你的錯誤說。 –

+0

感謝您給我看看 – user2820037

+1

你應該告訴我們哪一行是212行! –

回答

0

此錯誤可能是由於沒有關閉的語句造成的,但我們現在有檢查第212行的內容。這裏有一個例子:

211 echo "Hello" 
212 $example = array("1","2") 

而這應該是:

211 echo "Hello"; 
212 $example = array("1","2"); 

希望這有助於!

+0

錯誤已被主持人非常感謝您的建議和輸入 – user2820037

+0

很高興在這裏問題是固定的:) –

1

看來你有失蹤支架...

$profile_metaboxs[] = array(
    'id'=>'profile-meta-box-2', 
    'title'=>'Profile Overview', 
    'page'=> 'contractor', 
    'context'=>'normal', 
    'priority'=>'high', 
    'fields'=>array(
       array(
        'id'=>'overview', 
        'label'=>"Overview:", 
        'type'=>"textarea", 
        'height' => '100px' 
       ), 
       array(
        'id'=>'motto', 
        'label'=>"Motto:", 
        'type'=>"textarea", 
        'height' => '100px' 
       ), 
       array(
        'id'=>'services', 
        'label'=>"Services:", 
        'type'=>"textarea", 
        'height' => '100px' 
       ), 
       array(
        'id'=>'postal_prefixes', 
        'label'=>"Postal Prefixes:", 
        'type'=>"textarea", 
        'height' => '100px', 
        'readonly' => (!tr_landing_is_admin()) 
       ) 
    ) // <------------------------------ this "(" is missing from your code... 
); 
相關問題