Hi, I have an error in my wordpress theme: "Parse error: syntax error, unexpected T_VARIABLE in /home/xlinks/public_html/example.com/wp-content/themes/collection/includes/theme-postmeta.php on line 1 " Here is the code of theme-postmeta.php: <?php /*----------------------------------------------------------------------------------- Add Post Format meta boxes -----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/ /* Define Metabox Fields /*-----------------------------------------------------------------------------------*/ $prefix = 'tj_'; $meta_box_quote = array( 'id' => 'tj-meta-box-quote', 'title' => __('Quote Settings', 'themejunkie'), 'page' => 'post', 'context' => 'normal', 'priority' => 'high', 'fields' => array( array( "name" => __('The Quote','themejunkie'), "desc" => __('Write your quote in this field.','themejunkie'), "id" => $prefix."quote", "type" => "textarea" ), ), ); $meta_box_link = array( 'id' => 'tj-meta-box-link', 'title' => __('Link Settings', 'themejunkie'), 'page' => 'post', 'context' => 'normal', 'priority' => 'high', 'fields' => array( array( "name" => __('The URL','themejunkie'), "desc" => __('Insert the URL you wish to link to.','themejunkie'), "id" => $prefix."link_url", "type" => "text" ), ), ); $meta_box_image = array( 'id' => 'tj-meta-box-image', 'title' => __('Image Settings', 'themejunkie'), 'page' => 'post', 'context' => 'normal', 'priority' => 'high', 'fields' => array( array( "name" => __('Enable Lightbox','themejunkie'), "desc" => __('Check this to enable the lightbox.','themejunkie'), "id" => $prefix."image_lightbox", "type" => "select", 'std' => 'no', 'options' => array('yes', 'no'), ), ), ); $meta_box_audio = array( 'id' => 'tj-meta-box-audio', 'title' => __('Audio Settings', 'themejunkie'), 'page' => 'post', 'context' => 'normal', 'priority' => 'high', 'fields' => array( array( "name" => __('MP3 File URL','themejunkie'), "desc" => __('The URL to the .mp3 audio file','themejunkie'), "id" => $prefix."audio_mp3", "type" => "text" ), array( "name" => __('OGA File URL','themejunkie'), "desc" => __('The URL to the .oga, .ogg audio file','themejunkie'), "id" => $prefix."audio_ogg", "type" => "text" ) ), ); $meta_box_video = array( 'id' => 'tj-meta-box-video', 'title' => __('Video Settings', 'themejunkie'), 'page' => 'post', 'context' => 'normal', 'priority' => 'high', 'fields' => array( array( "name" => __('Video Height','themejunkie'), "desc" => __('If you set the M4V or OGV , you must set this.(no Youtube or such as that).','themejunkie'), "id" => $prefix."video_height", "type" => "text" ), array( "name" => __('Video Height Large','themejunkie'), "desc" => __('The video height (e.g. 500) for the post page.','themejunkie'), "id" => $prefix."video_height_single", "type" => "text" ), array( "name" => __('M4V File URL','themejunkie'), "desc" => __('The URL to the .m4v video file','themejunkie'), "id" => $prefix."video_m4v", "type" => "text" ), array( "name" => __('OGV File URL','themejunkie'), "desc" => __('The URL to the .ogv video file','themejunkie'), "id" => $prefix."video_ogv", "type" => "text" ), array( "name" => __('Poster Image','themejunkie'), "desc" => __('The preivew image(It is important).','themejunkie'), "id" => $prefix."video_poster", "type" => "text" ), array( "name" => "", "desc" => "", "id" => $prefix."video_poster_button", "type" => "button", "std" => "Browse" ), array( "name" => __('Embeded Code','themejunkie'), "desc" => __('If you\'re not using self hosted video then you can include embeded code here. Best viewed at 360px wide.','themejunkie'), "id" => $prefix."video_embed", "type" => "textarea" ), array( "name" => __('Lage Embeded Code','themejunkie'), "desc" => __('This should be the same as the above code but at a width of 600px. This is displayed on the post page itself.','themejunkie'), "id" => $prefix."video_embed_single", "type" => "textarea" ) ) ); add_action('admin_menu', 'tj_add_box'); /*-----------------------------------------------------------------------------------*/ /* Add metabox to edit page /*-----------------------------------------------------------------------------------*/ function tj_add_box() { global $meta_box_quote, $meta_box_link, $meta_box_image, $meta_box_audio, $meta_box_video; add_meta_box($meta_box_quote['id'], $meta_box_quote['title'], 'tj_show_box_quote', $meta_box_quote['page'], $meta_box_quote['context'], $meta_box_quote['priority']); add_meta_box($meta_box_image['id'], $meta_box_image['title'], 'tj_show_box_image', $meta_box_image['page'], $meta_box_image['context'], $meta_box_image['priority']); add_meta_box($meta_box_link['id'], $meta_box_link['title'], 'tj_show_box_link', $meta_box_link['page'], $meta_box_link['context'], $meta_box_link['priority']); add_meta_box($meta_box_audio['id'], $meta_box_audio['title'], 'tj_show_box_audio', $meta_box_audio['page'], $meta_box_audio['context'], $meta_box_audio['priority']); add_meta_box($meta_box_video['id'], $meta_box_video['title'], 'tj_show_box_video', $meta_box_video['page'], $meta_box_video['context'], $meta_box_video['priority']); } /*-----------------------------------------------------------------------------------*/ /* Callback function to show fields in meta box /*-----------------------------------------------------------------------------------*/ function tj_show_box_quote() { global $meta_box_quote, $post; // Use nonce for verification echo '<input type="hidden" name="tj_meta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />'; echo '<table class="form-table">'; foreach ($meta_box_quote['fields'] as $field) { // get current post meta data $meta = get_post_meta($post->ID, $field['id'], true); switch ($field['type']) { //If textarea case 'textarea': echo '<tr>', '<th style="width:25%"><label for="', $field['id'], '"><strong>', $field['name'], '</strong><span style="line-height:18px; display:block; color:#999; margin:5px 0 0 0;">'. $field['desc'].'</span></label></th>', '<td>'; echo '<textarea name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : stripslashes(htmlspecialchars(( $field['std']), ENT_QUOTES)), '" rows="8" cols="5" style="width:100%; margin-right: 20px; float:left;">', $meta ? $meta : stripslashes(htmlspecialchars(( $field['std']), ENT_QUOTES)), '</textarea>'; break; } } echo '</table>'; } function tj_show_box_link() { global $meta_box_link, $post; // Use nonce for verification echo '<input type="hidden" name="tj_meta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />'; echo '<table class="form-table">'; foreach ($meta_box_link['fields'] as $field) { // get current post meta data $meta = get_post_meta($post->ID, $field['id'], true); switch ($field['type']) { //If Text case 'text': echo '<tr>', '<th style="width:25%"><label for="', $field['id'], '"><strong>', $field['name'], '</strong><span style=" display:block; color:#999; margin:5px 0 0 0; line-height: 18px;">'. $field['desc'].'</span></label></th>', '<td>'; echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : stripslashes(htmlspecialchars(( $field['std']), ENT_QUOTES)), '" size="30" style="width:75%; margin-right: 20px; float:left;" />'; break; } } echo '</table>'; } function tj_show_box_audio() { global $meta_box_audio, $post; echo '<p style="padding:10px 0 0 0;">'.__('Note that for audio, you must supply both MP3 and OGG files to satisfy all browsers.', 'themejunkie').'</p>'; // Use nonce for verification echo '<input type="hidden" name="tj_meta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />'; echo '<table class="form-table">'; foreach ($meta_box_audio['fields'] as $field) { // get current post meta data $meta = get_post_meta($post->ID, $field['id'], true); switch ($field['type']) { //If Text case 'text': echo '<tr>', '<th style="width:25%"><label for="', $field['id'], '"><strong>', $field['name'], '</strong><span style=" display:block; color:#999; margin:5px 0 0 0; line-height: 18px;">'. $field['desc'].'</span></label></th>', '<td>'; echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : stripslashes(htmlspecialchars(( $field['std']), ENT_QUOTES)), '" size="30" style="width:75%; margin-right: 20px; float:left;" />'; break; //If textarea case 'textarea': echo '<tr style="border-top:1px solid #eeeeee;">', '<th style="width:25%"><label for="', $field['id'], '"><strong>', $field['name'], '</strong><span style="line-height:18px; display:block; color:#999; margin:5px 0 0 0;">'. $field['desc'].'</span></label></th>', '<td>'; echo '<textarea name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : stripslashes(htmlspecialchars(( $field['std']), ENT_QUOTES)), '" rows="8" cols="5" style="width:100%; margin-right: 20px; float:left;">', $meta ? $meta : stripslashes(htmlspecialchars(( $field['std']), ENT_QUOTES)), '</textarea>'; break; } } echo '</table>'; } function tj_show_box_video() { global $meta_box_video, $post; echo '<p style="padding:10px 0 0 0;">'.__('Note that for video, you must supply an M4V file to satisfy both HTML5 and Flash solutions. The optional OGV format is used to increase x-browser support for HTML5 browsers such as Firefox and Opera.', 'themejunkie').'</p>'; // Use nonce for verification echo '<input type="hidden" name="tj_meta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />'; echo '<table class="form-table">'; foreach ($meta_box_video['fields'] as $field) { // get current post meta data $meta = get_post_meta($post->ID, $field['id'], true); switch ($field['type']) { //If Text case 'text': echo '<tr>', '<th style="width:25%"><label for="', $field['id'], '"><strong>', $field['name'], '</strong><span style=" display:block; color:#999; margin:5px 0 0 0; line-height: 18px;">'. $field['desc'].'</span></label></th>', '<td>'; echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : stripslashes(htmlspecialchars(( $field['std']), ENT_QUOTES)), '" size="30" style="width:75%; margin-right: 20px; float:left;" />'; break; //If textarea case 'textarea': echo '<tr style="border-top:1px solid #eeeeee;">', '<th style="width:25%"><label for="', $field['id'], '"><strong>', $field['name'], '</strong><span style="line-height:18px; display:block; color:#999; margin:5px 0 0 0;">'. $field['desc'].'</span></label></th>', '<td>'; echo '<textarea name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : stripslashes(htmlspecialchars(( $field['std']), ENT_QUOTES)), '" rows="8" cols="5" style="width:100%; margin-right: 20px; float:left;">', $meta ? $meta : stripslashes(htmlspecialchars(( $field['std']), ENT_QUOTES)), '</textarea>'; break; //If Button case 'button': echo '<input style="float: left;" type="button" class="button" name="', $field['id'], '" id="', $field['id'], '"value="', $meta ? $meta : $field['std'], '" />'; echo '</td>', '</tr>'; break; } } echo '</table>'; } function tj_show_box_image() { global $meta_box_image, $post; // Use nonce for verification echo '<input type="hidden" name="tj_meta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />'; echo '<table class="form-table">'; foreach ($meta_box_image['fields'] as $field) { // get current post meta data $meta = get_post_meta($post->ID, $field['id'], true); switch ($field['type']) { //If Select case 'select': echo '<tr>', '<th style="width:25%"><label for="', $field['id'], '"><strong>', $field['name'], '</strong><span style=" display:block; color:#999; margin:5px 0 0 0;">'. $field['desc'].'</span></label></th>', '<td>'; echo'<select name="'.$field['id'].'">'; foreach ($field['options'] as $option) { echo'<option'; if ($meta == $option ) { echo ' selected="selected"'; } echo'>'. $option .'</option>'; } echo'</select>'; break; } } echo '</table>'; } add_action('save_post', 'tj_save_data'); /*-----------------------------------------------------------------------------------*/ /* Save data when post is edited /*-----------------------------------------------------------------------------------*/ function tj_save_data($post_id) { global $meta_box_quote, $meta_box_link, $meta_box_image, $meta_box_audio, $meta_box_video; // verify nonce if (!wp_verify_nonce($_POST['tj_meta_box_nonce'], basename(__FILE__))) { return $post_id; } // check autosave if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } // check permissions 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 ($meta_box_quote['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'], stripslashes(htmlspecialchars($new))); } elseif ('' == $new && $old) { delete_post_meta($post_id, $field['id'], $old); } } foreach ($meta_box_link['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'], stripslashes(htmlspecialchars($new))); } elseif ('' == $new && $old) { delete_post_meta($post_id, $field['id'], $old); } } foreach ($meta_box_audio['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'],stripslashes(htmlspecialchars($new))); } elseif ('' == $new && $old) { delete_post_meta($post_id, $field['id'], $old); } } foreach ($meta_box_video['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'], stripslashes(htmlspecialchars($new))); } elseif ('' == $new && $old) { delete_post_meta($post_id, $field['id'], $old); } } foreach ($meta_box_image['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'], stripslashes(htmlspecialchars($new))); } elseif ('' == $new && $old) { delete_post_meta($post_id, $field['id'], $old); } } } /*-----------------------------------------------------------------------------------*/ /* Queue Scripts /*-----------------------------------------------------------------------------------*/ function tj_admin_scripts() { wp_enqueue_script('media-upload'); wp_enqueue_script('thickbox'); wp_register_script('tj-upload', get_template_directory_uri() . '/includes/js/upload-button.js', array('jquery','media-upload','thickbox')); wp_enqueue_script('tj-upload'); } function tj_admin_styles() { wp_enqueue_style('thickbox'); } add_action('admin_print_scripts', 'tj_admin_scripts'); add_action('admin_print_styles', 'tj_admin_styles'); PHP:
Are you using some non standard encoding? Try saving file with utf8 and see if that resolves the issue.
like Rukbat said, you forget close coment behind text "Define Metabox Fields". try adding end comment or delete this comment block : /*----------------------------------------------------------------------------------- Add Post Format meta boxes-----------------------------------------------------------------------------------*//*-----------------------------------------------------------------------------------*//* Define Metabox Fields/*-----------------------------------------------------------------------------------*/
I would like to disagree about the comments, because /* ----- /* <-this gets treated as a part of comment ----*/ /* ---- /* this would cause problems for sure */ ----*/ PHP:
That's a nested comment and it's illegal. /* ----- /* <-this gets treated as a part of comment ----*/ /* ---- /* this would cause problems for sure */ //the multiline comment ends here ----*/ //The ---*/ on the previous line isn't legal PHP code PHP:
i agree with Rukbat. /* combination slash / wild char * and text in comment body like this also can make error */ PHP:
Have you tested that on server? I'm not saying it's the right way to write comments, but it works. I copied code from first post on my local server and it was working fine, so the main problem is not the comment here.
ok im wrong. i have tested some comment /* this comment right */ PHP: /* no problem /with* *this/ comment */ PHP: /* no problem /* with this comment */ PHP: /* this is wrong */ comment */ PHP: /* this is also /* wrong */ comment */ PHP: /* this is also /* wrong */ comment */ PHP: