Parse error: syntax error, unexpected end of file

Résolu/Fermé
vanaila - 19 déc. 2012 à 20:04
 vanaila - 20 déc. 2012 à 22:17
Bonjour,

J'ai un problème d'installation de thème sur mon local host:

Que je l'installe ou le prévilsualise ça me dit ça :

Parse error: syntax error, unexpected end of file in E:\Utilitaires\wamp\www\wordpress\wp-content\themes\handmade\ocmx\interface\post-type-meta.php on line 187

Voici le code que j'ai dans ce fichier.

Quelqu'un pourrait-il m'aider s'il vous plait ?

 <?php function post_type_meta_panel($pId, $posttype = "post") { 
    $posttypedetails = get_post_type_object($posttype);
	
	$input = get_post_meta($pId,$posttype,true);
	$cat_list = get_terms("$posttype-category", "orderby=count&hide_empty=0"); ?>
    <div class="inside clearfix">
        <div id="taxonomy-<?php echo $posttype; ?>-category" class="categorydiv">
        	<p style="text-align: right;">Add, edit and delete <?php echo $posttypedetails->labels->name; ?> via the <a href="<?php bloginfo("url"); ?>wp-admin/edit.php?post_type=<?php echo $posttype; ?>"><?php echo $posttypedetails->labels->name; ?> Panel</a> </p>
            <ul id="<?php echo $posttype; ?>-category-tabs" class="category-tabs clearfix">
                <li <?php if($i == 1) : ?>class="tabs"<?php endif; ?>><a href="#<?php echo $posttype; ?>-category-all">All</a></li>
                <?php  $i=1; foreach($cat_list as $tax) :
					if($tax->parent == 0) :
				?>
                    <li <?php if($i == 1) : ?>class="tabs"<?php endif; ?>><a href="#<?php echo $posttype; ?>-category-<?php echo $tax->slug; ?>" tabindex="3"><?php echo $tax->name; ?></a></li>
                <?php  $i++;
					endif;
				endforeach; ?>
            </ul>
            <?php $i=1; $ocmx_posts = new WP_Query("post_type=".$posttype."&posts_per_page=-1"); ?>
            <div id="<?php echo $posttype; ?>-category-all" class="tabs-panel" <?php if($i != 1) : ?>style="display: none;"<?php endif; ?>>
                 <?php if ($ocmx_posts->have_posts()) :
                    while ($ocmx_posts->have_posts()) :	$ocmx_posts->the_post(); 
						if(is_array($input) && in_array(get_the_ID(), $input)) : $checked = "checked=\"checked\""; else : $checked = ""; endif; ?>
                        <p><label class="selectit">
                            <input type="checkbox" name="<?php echo $posttype; ?>[]" value="<?php echo get_the_ID(); ?>" <?php echo $checked; ?> />&nbsp;<?php the_title(); ?>
                        </label></p>
                    <?php endwhile;
					$i++;
                endif; ?>
            </div>
             <?php  foreach($cat_list as $tax) :
			 	if($tax->parent == 0) :
                    $ocmx_posts = new WP_Query("post_type=$posttype&$posttype-category=$tax->slug&posts_per_page=-1"); ?>
                <div id="<?php echo $posttype; ?>-category-<?php echo $tax->slug; ?>" class="tabs-panel" <?php if($i != 1) : ?>style="display: none;"<?php endif; ?>>
                     <?php if ($ocmx_posts->have_posts()) :
                        while ($ocmx_posts->have_posts()) :	$ocmx_posts->the_post(); 
							if(is_array($input) && in_array(get_the_ID(), $input)) : $checked = "checked=\"checked\""; else : $checked = ""; endif; ?>
                            <p><label class="selectit">
                                <input type="checkbox" name="<?php echo $posttype; ?>[]" value="<?php echo get_the_ID(); ?>" <?php echo $checked; ?> />&nbsp;<?php the_title(); ?>
                            </label></p>
                        <?php endwhile;
                    endif; ?>
                </div>
            <?php $i++; endif;
			endforeach; ?>
        </div>
    </div>
<?php }

function post_type_meta_update($postId, $posttype = "post") { 
	foreach($_POST as $key => $value) :
		if($key == $posttype) :
			delete_post_meta($postId,$posttype);
			$metalist = array();
			foreach($value as $val) :
				if(!in_array($val, $metalist))
					$metalist[] = $val;
			endforeach;
			add_post_meta($postId,$key,$metalist,true) or update_post_meta($postId,$key,$metalist);
		endif;
	endforeach;
}

function post_meta_panel($postId, $postmeta) { 
	global $obox_metabox_value; ?>
    <table class="obox_metaboxes_table">
		<?php foreach ($postmeta as $metabox) :
			$metabox_value = get_post_meta($postId, $metabox["name"],true);
			
			if ($metabox_value == "" || !isset($metabox_value)) :
				$metabox_value = $metabox['default'];
			endif; ?>
			<tr>
				<td width="20%" valign="top" class="obox_label">
					<label for="<?php echo $metabox; ?>"><?php echo $metabox["label"]; ?></label>
					<p><?php echo $metabox["desc"] ?></p>
				</td>
				<td colspan="3">
                	<?php if($metabox["input_type"] == "image") : ?>
                        <div class="clearfix"><input type="file" name="<?php echo "obox_".$metabox["name"]."_file"; ?>" /></div>
                        <div class="clearfix">
                            <label>
                                Image Path
                            </label>
							<?php if($obox_metabox_value !== "") :?>
                                <input class="obox_input_text" type="text" name="<?php echo "obox_".$metabox["name"]; ?>" id="<?php echo "obox_".$metabox["name"]; ?>" value="<?php echo $metabox_value; ?>" size="<?php echo $metabox["input_size"] ?>" />
                            <?php else : ?>
                                <input class="obox_input_text" type="text" name="<?php echo "obox_".$metabox["name"]; ?>" />
                            <?php endif; ?>
                        </div>
						<?php if($metabox["effects"]) : 
                            global $post;
                            $effect = get_post_meta($post->ID,$metabox["name"]."_effect",true); ?>
                            <div class="clearfix">
                                <label class="image-edit-item noeffect selectit" title="None">
                                    <a href="#"<?php if($effect == 0) : ?> class="active"<?php endif; ?>></a>
                                    <input type="radio" name="<?php echo "obox_".$metabox["name"]."_effect"; ?>" value="0" />
                                </label>
                                <label class="image-edit-item greyscale" title="Grey Scale">
                                    <a href="#"<?php if($effect == 2) : ?> class="active"<?php endif; ?>></a>
                                    <input type="radio" name="<?php echo "obox_".$metabox["name"]."_effect"; ?>" value="2" />
                                </label>
                                
                                <label class="image-edit-item negative" title="Negative">
                                    <a href="#"<?php if($effect == 1) : ?> class="active"<?php endif; ?>></a>
                                    <input type="radio" name="<?php echo "obox_".$metabox["name"]."_effect"; ?>" value="1" />
                                </label>
                                
                                <label class="image-edit-item brightness" title="Brighten">
                                    <a href="#"<?php if($effect == 3) : ?> class="active"<?php endif; ?>></a>
                                    <input type="radio" name="<?php echo "obox_".$metabox["name"]."_effect"; ?>" value="3" />
                                </label>
                                
                                <label class="image-edit-item contrast" title="Contrast">
                                    <a href="#"<?php if($effect == 5) : ?> class="active"<?php endif; ?>></a>
                                    <input type="radio" name="<?php echo "obox_".$metabox["name"]."_effect"; ?>" value="5" />
                                </label>
                                
                                <label class="image-edit-item blur" title="Blur">
                                    <a href="#"<?php if($effect == 8) : ?> class="active"<?php endif; ?>></a>
                                    <input type="radio" name="<?php echo "obox_".$metabox["name"]."_effect"; ?>" value="8" />
                                </label>
                                
                                <label class="image-edit-item colorize" title="Colorize">
                                    <a href="#"<?php if($effect == 4) : ?> class="active"<?php endif; ?>></a>
                                    <input type="radio" name="<?php echo "obox_".$metabox["name"]."_effect"; ?>" value="4" />
                                </label>
                            </div>
                        <?php endif; ?>
                        <div class="clearfix">
							<?php if($metabox_value != "") : ?>
                                <div class="obox_main_image">
                                    <img src="<?php bloginfo('template_directory'); ?>/functions/timthumb.php?src=<?php echo $metabox_value; ?>&h=255&w=590&zc=1&q=100&f=<?php echo $effect; ?>" />
                                </div>
                            <?php endif; ?>
                        </div>
					<?php elseif($metabox["input_type"] == "select") : ?>
                    	<select name="<?php echo "obox_".$metabox["name"]; ?>" id="<?php echo "obox_".$metabox["name"]; ?>">
                        	<?php foreach($metabox["options"] as $option => $value) : ?>
	                        	<option <?php if($metabox_value == $value) : ?>selected="selected"<?php endif; ?> value="<?php echo $value; ?>"><?php echo $option; ?></option>
                            <?php endforeach; ?>
                        </select>
					<?php elseif($metabox["input_type"] == "textarea") : ?>
						<textarea class="obox_metabox_fields" style="width: 70%;" rows="8" name="<?php echo "obox_".$metabox["name"]; ?>" id="<?php echo "obox_".$metabox["name"]; ?>"><?php echo $metabox_value; ?></textarea>
					<?php else : ?>
						<input class="obox_metabox_fields" type="text" name="<?php echo "obox_".$metabox["name"]; ?>" id="<?php echo "obox_".$metabox["name"]; ?>" value="<?php echo $metabox_value; ?>" size="<?php echo $metabox["input_size"] ?>" />
					<?php endif; ?>        
				</td>
			</tr>
		<?php endforeach; ?>
    </table>
<? }

function post_meta_update($postId, $postmeta){
    global $use_effect, $use_width, $use_height;
    foreach ($postmeta as $metabox) {
		$var = "obox_".$metabox["name"];
		if (isset($_POST[$var])) :
			if($metabox["input_type"] == "image") :
				$use_file_field = $var."_file";
				
				/* Check if we've actually selected a file */
				
				if($_FILES[$use_file_field]["name"] != "") :				
					$upload = wp_upload_bits($_FILES[$use_file_field]["name"], null, file_get_contents($_FILES[$use_file_field]["tmp_name"]));
					
					$resized_image = ocmx_custom_resize($upload["file"], $use_width, $use_height, true);
					
					ocmx_add_attachment($upload);
					
					//Update Post Meta
					add_post_meta($postId, $metabox["name"], $upload["url"],true) or update_post_meta($postId,  $metabox["name"], $upload["url"]);
				else :
					//Update Post Meta
					add_post_meta($postId,$metabox["name"],$_POST[$var],true) or update_post_meta($postId,$metabox["name"], $_POST[$var]);
				endif;
				if($metabox["effects"]) :
				if(isset($_POST[$use_effect])):	
                    add_post_meta($postId,$metabox["name"]."_effect",$_POST[$use_effect],true) or update_post_meta($postId,$metabox["name"]."_effect",$_POST[$use_effect]);
				endif;
                endif;
			else :
				add_post_meta($postId,$metabox["name"],$_POST[$var],true) or update_post_meta($postId,$metabox["name"],$_POST[$var]);				
			endif;
		endif;
	}
} ?>


3 réponses

Merci beaucoup!

Il semble que c'était bien ça.

En tout cas là il s'active et semble fonctionnel.
3
Merci pour ta réponse.

C'est un thème normalement compatible pour wordpress 3.4 et c'est dans cette version que je suis.

J'ai rien fait de perso, je m'y connais pas en codage ^^

Y a-t-il un logiciel facile d'utilisation qui me permette d'ouvrir le code avec les lignes ?
1
theshadoo Messages postés 786 Date d'inscription samedi 26 mai 2007 Statut Membre Dernière intervention 3 mai 2016 123
19 déc. 2012 à 22:37
ok je pense avoir trouvé mais je n'en suis pas certain car le copier collé depuis le site n'est pas forcément propre et fidèle dans l'éditeur, ce qu'il fait que la ligne où il est stipulé l'erreur n'est pas forcément la bonne ligne.

à cette ligne :
</tr>
<?php endforeach; ?>
</table>
<? }

le tag d'ouverture pour le php ne doit pas être <? mais <?php il manque donc php, celui qui a fait le code de ce template code comme un porc franchement voilà où cela amène par la suite.

le code est sans doute bien indenté mais sa structure est complètement stupide, couper son code php et html dans des fonctions php alors que ces fonctions devraient être dans un fichier de wordpress appelé functions.php

il mériterait un coup de règle sur les doigts (ou de souris volante en pleine poire)

ajoute php après <? où j'ai ciblé la ligne je pense que c'est ça sauf si il y a encore d'autres erreurs de syntaxes
0
theshadoo Messages postés 786 Date d'inscription samedi 26 mai 2007 Statut Membre Dernière intervention 3 mai 2016 123
Modifié par theshadoo le 19/12/2012 à 20:42
je ne comprends pas pourquoi tes fonctions sont dans ton theme, il faut séparer ton code.

ça va être difficile de t'aider car on voit pas les lignes ici donc ligne 187 ça ne me parle pas trop moi.
Sans doute un theme compatible avec un ancien wordpress sur les fonctions meta sauf si ce sont des fonctions perso c'est dans la fonction qu'il y a une erreur.

En tout cas c'est une erreur de syntaxe dans une fonction des meta, regarde ta ligne 187
0