2014-02-20 5 views
-2

сервер дал мне эту ошибку, но я не понимаю, почему!Ошибка анализа: синтаксическая ошибка, неожиданный конец файла

Ошибка

"Parse error: syntax error, unexpected end of file in /homepages/43/d514350324/htdocs/wp-content/plugins/NetClass/nw_NetClass_init_CustomBoxes.php on line 227"

Line 227 является последней строкой файла.

Это код. Помоги мне, пожалуйста!

<?php 
/* Define the custom box */ 

add_action('add_meta_boxes', 'aggiungiMetaBox'); 
add_action('save_post', 'salvaMetaBox', 10, 2); 

add_action('wp_ajax_nc_savePortable_lezioni_action', 'nc_savePortable_lezioni'); 
add_action('admin_footer', 'nc_savePortable_lezioni_js'); 



function parseInt($str){ 
    return (int) $str; 
} 


function aggiungiMetaBox(){ 

    add_meta_box("nw_Netclass_Box_AggiungiaCorso", "Aggiungi la lezione al corso", "aggiungiMetaBox_AggiungiLezione", "corso"); 
    add_meta_box("nw_NetClass_Box_DatiFattura", "Dati della fattura", "aggiungiMetaBox_DatiFattura", "fattura"); 
    add_meta_box("nw_NetClass_Box_Corsi_Associati", "Corsi associati", "aggiungiMetaBox_Corsi_Associati", "lezione"); 

} 
function aggiungiMetaBox_Corsi_Associati($post){ 
    ?> 
    <p><?php echo get_post_meta($post->ID, 'corsi_associati',true); ?></p> 
    <?php 
} 

function is_in_array($array_lezioni_del_corso, $object){ 

     if(!is_array($array_lezioni_del_corso)){ 
     if($array_lezioni_del_corso == $object){ 
      return true; 
     }else{ 
      return false; 
     } 
     } 
     else{ 
     return in_array($object, $array_lezioni_del_corso); 
     } 
    } 


function aggiungiMetaBox_DatiFattura($post){ 

    $post_id = $post->ID; 

    $user_info = get_userdata(get_post_meta($post_id, "intestatarioFattura" , true)); 
    $user_meta = array(
     'tipo_utente' => get_user_meta(get_post_meta($post_id, "intestatarioFattura" , true), 'tipo_utente',true), 
     'p_iva' => get_user_meta(get_post_meta($post_id, "intestatarioFattura" , true), 'p_iva',true), 
     'indirizzo_fatturazione' => get_user_meta(get_post_meta($post_id, "intestatarioFattura" , true), 'indirizzo_fatturazione',true) 
    ); 

    ?> 
    Intestatario della fattura : <?php echo $user_info->display_name; ?> <br> 
    Tipo di utente : <?php echo $user_meta['tipo_utente']; ?> <br> 
    Indirizzo di fatturazione : <?php echo $user_meta['indirizzo_fatturazione']; ?> <br> 
    P.IVA : <?php echo $user_meta['p_iva']; ?> <br> 
    Inponibile della fattura : <?php echo get_post_meta($post_id, "inponibileFattura" , true); ?> <br> 
    Totale della fattura : <?php echo get_post_meta($post_id, "totaleFattura" , true); ?> <br> 
    Articoli acquistati: 

    <ul> 
     <?php 
     foreach(get_post_meta($post_id, "articoliFattura" , true) as $prodotto){ 
     ?> 
     <li><?php echo get_the_title($prodotto); ?></li> 

     <?php 
     } 
     ?> 
    </ul> 
    <?php 


} 


//save the meta box 
function salvaMetaBox($post_id) 
{ 

    //Salvo i dati del Box lezioni nel post corso // 
    global $wpdb; 
    $database_name = $wpdb->prefix.'Netclass_friends'; 

    if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { return $post_id; } 


    //Salvo i dati delle fatture 
} 



function aggiungiMetaBox_AggiungiLezione($post){ 

    global $wpdb; 
    $post_id = $post->ID; 
    $query = "SELECT post_title,ID FROM ".$wpdb->prefix."posts WHERE post_type='lezione' AND post_status='publish'"; 
    $array_lezioni_del_corso = get_post_meta($post_id, 'array_lezioni_del_corso'); 
    $lezioni = $wpdb->get_results($query); 


    foreach ($lezioni as $lezione) { ?> 

    <input id="<?php echo $lezione->ID; ?>" data-title="<?php echo $lezione->post_title; ?>" class="nc_lezione_pubblicata" type="checkbox" name="checkfield[]" value="<?php echo $lezione->ID; ?>" <?php if (is_in_array($array_lezioni_del_corso[0], $lezione->ID)) { ?> checked <?php } ?>/> 
    <label for="<?php echo $lezione->ID; ?>"><?php echo $lezione->post_title; ?></label> <br> 

    <?php } ?> 

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> 
    <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script> 

    <script type="text/javascript"> 

    $(document).ready(function($) 
    {  
     $('.sortable').sortable({ 
      opacity: 0.6, 
      revert: true, 
      cursor: 'move', 
      handle: '.hndle', 
      placeholder: { 
       element: function(currentItem) { 
        return $("<li style='background:#E7E8AD'>&nbsp;</li>")[0]; 
       }, 
       update: function(container, p) { 
        return; 
       } 
      }, 

      update: function(event, ui) { 

       console.log($(".sortable").sortable("toArray", {attribute: 'data-id'})); 
       saveSortable($(".sortable").sortable("toArray", {attribute: 'data-id'})); 

      } 
     }); 
     $('.sortable').disableSelection(); 

     $(".nc_lezione_pubblicata").change(function() { 
      if($(this).is(':checked')){ 
       $('<li class="nc_lezione_del_corso" data-id="'+$(this).attr('id')+'" id="lezione_del_corso_'+$(this).attr('id')+'"><code class="hndle"> -[]- </code>'+$(this).data('title')+'</p>').appendTo(".sortable"); 
      }else{ 
      $("#lezione_del_corso_"+$(this).attr('id')).remove(); 
      console.log("elimino"); 
      } 

      saveSortable($(".sortable").sortable("toArray", {attribute: 'data-id'})); 

     }); 
    }); 
    </script> 

    <ul class="sortable ui-sortable"> 

     <?php foreach ($array_lezioni_del_corso[0] as $lezione_del_corso) { ?> 

     <li class="nc_lezione_del_corso" id="lezione_del_corso_<?php echo $lezione_del_corso; ?>" 
     data-id="<?php echo $lezione_del_corso; ?>"> 

      <code class='hndle'> -[]- </code> 
      <?php echo get_the_title($lezione_del_corso); ?> 

     </li> 

     } ?> 

    </ul> 

    <p> 

    <script type="text/javascript"> 
    $(function(){ 
     console.log($(".sortable").sortable("toArray")); 
    });</script> 

    </p> 

<?php } 

function nc_savePortable_lezioni(){ 

    global $wpdb; 
    $post_id = $_POST['post_id']; 
    $array_lezioni_del_corso = $_POST['array_lezioni_del_corso']; 

    update_post_meta($post_id, 'array_lezioni_del_corso', $array_lezioni_del_corso); 

    foreach ($array_lezioni_del_corso as $lezione_del_corso) { 

     $corsi_associati = get_post_meta($lezione_del_corso, 'corsi_associati', true); 
     $corsi_associati = $corsi_associati.','.$post_id; 


     update_post_meta(parseInt($lezione_del_corso), 'corsi_associati', $corsi_associati); 


    } 

    echo 'al server arrriva '.$array_lezioni_del_corso; 

} 

function nc_savePortable_lezioni_js(){ 
    ?> 
    <script type="text/javascript"> 
     function saveSortable(sortableArraystringData){ 

      var data = { 
      action: 'nc_savePortable_lezioni_action', 
      array_lezioni_del_corso : sortableArraystringData, 
      post_id : <? echo get_the_ID(); ?> 

      }; 

      // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php 
      $.post(ajaxurl, data, function(response) { 
      alert('This was passed ' + sortableArraystringData); 
      }); 
     } 

    </script> 
    <?php 
} 
+0

Ваши скобки ошибочно согласованы - вам не хватает '}'. –

+0

Согласованное форматирование кода и не смешивание HTML и PHP так много предотвратят эти проблемы! – miken32

+0

Это всегда головная боль, «особенно», когда дело доходит до WordPress (плагины). Ваш квест мог даже продолжаться, даже после исправления недостающей фигурной скобки. –

ответ

Смежные вопросы