Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Php - brak klamry?
Forum PHP.pl > Forum > PHP
Owneds
Witam.

Mam kolejny problem, a mianowicie wyskakuje mi błąd:
Parse error: syntax error, unexpected '}' in /virtual/xxxx.pl/wp-content/themes/Nautilus/inc/template-tags.php on line 41
Ale w linii 41 niczego nie mogę się doszukać.
oto kod:

  1. <?php
  2. /**
  3.  * Custom template tags for this theme.
  4.  *
  5.  * Eventually, some of the functionality here could be replaced by core features
  6.  *
  7.  * @package web2feel
  8.  * @since web2feel 1.0
  9.  */
  10.  
  11. if ( ! function_exists( 'web2feel_content_nav' ) ):
  12. /**
  13.  * Display navigation to next/previous pages when applicable
  14.  *
  15.  * @since web2feel 1.0
  16.  */
  17. function web2feel_content_nav( $nav_id ) {
  18. global $wp_query;
  19.  
  20. $nav_class = 'site-navigation paging-navigation';
  21. if ( is_single() )
  22. $nav_class = 'site-navigation post-navigation';
  23.  
  24. ?>
  25. <nav role="navigation" id="<?php echo $nav_id; ?>" class="<?php echo $nav_class; ?>">
  26. <h1 class="assistive-text"><?php _e( 'Post navigation', 'web2feel' ); ?></h1>
  27.  
  28. <?php if ( is_single() ) : // navigation links for single posts ?>
  29.  
  30. <?php previous_post_link( '<div class="nav-previous">%link</div>', '<span class="meta-nav">' . _x( '&larr;', 'Previous post link', 'web2feel' ) . '</span> %title' ); ?>
  31. <?php next_post_link( '<div class="nav-next">%link</div>', '%title <span class="meta-nav">' . _x( '&rarr;', 'Next post link', 'web2feel' ) . '</span>' ); ?>
  32.  
  33. <?php elseif ( $wp_query->max_num_pages > 1 && ( is_home() || is_archive() || is_search() ) ) : // navigation links for home, archive, and search pages ?>
  34.  
  35. <?php if ( get_next_posts_link() ) : ?>
  36. <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'web2feel' ) ); ?></div>
  37. <?php endif; ?>
  38.  
  39. <?php if ( get_previous_posts_link() ) : ?>
  40. <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'web2feel' ) ); ?></div>
  41. <?php endif; ?>
  42.  
  43. <?php endif; ?>
  44.  
  45. </nav><!-- #<?php echo $nav_id; ?> -->
  46. <?php
  47.  
  48. endif; // web2feel_content_nav
  49. }
  50. if ( ! function_exists( 'web2feel_comment' ) ) :
  51. /**
  52.  * Template for comments and pingbacks.
  53.  *
  54.  * Used as a callback by wp_list_comments() for displaying the comments.
  55.  *
  56.  * @since web2feel 1.0
  57.  */
  58. function web2feel_comment( $comment, $args, $depth ) {
  59. $GLOBALS['comment'] = $comment;
  60. switch ( $comment->comment_type ) :
  61. case 'pingback' :
  62. case 'trackback' :
  63. ?>
gorny
#48

endif; // web2feel_content_nav
}

#58 funnkcja nie zamknięta klamrą
Owneds
Poprawiłem, to mój cały kod
Nie działa, dalej coś źle w linii 41.

  1. <?php
  2. /**
  3.  * Custom template tags for this theme.
  4.  *
  5.  * Eventually, some of the functionality here could be replaced by core features
  6.  *
  7.  * @package web2feel
  8.  * @since web2feel 1.0
  9.  */
  10.  
  11. if ( ! function_exists( 'web2feel_content_nav' ) ):
  12. /**
  13.  * Display navigation to next/previous pages when applicable
  14.  *
  15.  * @since web2feel 1.0
  16.  */
  17. function web2feel_content_nav( $nav_id ) {
  18. global $wp_query;
  19.  
  20. $nav_class = 'site-navigation paging-navigation';
  21. if ( is_single() )
  22. $nav_class = 'site-navigation post-navigation';
  23.  
  24. }
  25. ?>
  26. <nav role="navigation" id="<?php echo $nav_id; ?>" class="<?php echo $nav_class; ?>">
  27. <h1 class="assistive-text"><?php _e( 'Post navigation', 'web2feel' ); ?></h1>
  28.  
  29. <?php if ( is_single() ) : // navigation links for single posts ?>
  30.  
  31. <?php previous_post_link( '<div class="nav-previous">%link</div>', '<span class="meta-nav">' . _x( '&larr;', 'Previous post link', 'web2feel' ) . '</span> %title' ); ?>
  32. <?php next_post_link( '<div class="nav-next">%link</div>', '%title <span class="meta-nav">' . _x( '&rarr;', 'Next post link', 'web2feel' ) . '</span>' ); ?>
  33.  
  34. <?php elseif ( $wp_query->max_num_pages > 1 && ( is_home() || is_archive() || is_search() ) ) : // navigation links for home, archive, and search pages ?>
  35.  
  36. <?php if ( get_next_posts_link() ) : ?>
  37. <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'web2feel' ) ); ?></div>
  38. <?php endif; ?>
  39.  
  40. <?php if ( get_previous_posts_link() ) : ?>
  41. <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'web2feel' ) ); ?></div>
  42. <?php endif; ?>
  43.  
  44.  
  45.  
  46. </nav><!-- #<?php echo $nav_id; ?> -->
  47. <?php
  48.  
  49. endif; // web2feel_content_nav
  50.  
  51. if ( ! function_exists( 'web2feel_comment' ) ) :
  52. /**
  53.  * Template for comments and pingbacks.
  54.  *
  55.  * Used as a callback by wp_list_comments() for displaying the comments.
  56.  *
  57.  * @since web2feel 1.0
  58.  */
  59. function web2feel_comment( $comment, $args, $depth ) {
  60. $GLOBALS['comment'] = $comment;
  61. switch ( $comment->comment_type ) :
  62. case 'pingback' :
  63. case 'trackback' :
  64. }
  65. ?>
  66. <li class="post pingback">
  67. <p><?php _e( 'Pingback:', 'web2feel' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( '(Edit)', 'web2feel' ), ' ' ); ?></p>
  68. <?php
  69. break;
  70. default :
  71. ?>
  72. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
  73. <article id="comment-<?php comment_ID(); ?>" class="comment">
  74. <footer class="comment-top cf">
  75. <div class="comment-author vcard">
  76. <?php echo get_avatar( $comment, 40 ); ?>
  77. </div><!-- .comment-author .vcard -->
  78.  
  79.  
  80. <div class="comment-meta commentmetadata">
  81. <?php printf( __( '%s', 'web2feel' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
  82. <?php if ( $comment->comment_approved == '0' ) : ?>
  83. <em><?php _e( 'Your comment is awaiting moderation.', 'web2feel' ); ?></em>
  84. <br />
  85. <?php endif; ?>
  86. <a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>"><time pubdate datetime="<?php comment_time( 'c' ); ?>">
  87. <?php
  88. /* translators: 1: date, 2: time */
  89. printf( __( '%1$s at %2$s', 'web2feel' ), get_comment_date(), get_comment_time() ); ?>
  90. </time></a>
  91. <?php edit_comment_link( __( '(Edit)', 'web2feel' ), ' ' );
  92. ?>
  93. </div><!-- .comment-meta .commentmetadata -->
  94. </footer>
  95.  
  96. <div class="comment-content">
  97. <?php comment_text(); ?>
  98. <div class="reply">
  99. <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  100. </div><!-- .reply -->
  101. </div>
  102.  
  103.  
  104. <div class="space"></div>
  105. </article><!-- #comment-## -->
  106.  
  107. <?php
  108. break;
  109. endswitch;
  110. }
  111. endif; // ends check for web2feel_comment()
  112.  
  113. if ( ! function_exists( 'web2feel_posted_on' ) ) :
  114. /**
  115.  * Prints HTML with meta information for the current post-date/time and author.
  116.  *
  117.  * @since web2feel 1.0
  118.  */
  119. function web2feel_posted_on() {
  120. printf( __( 'Posted on <a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s" pubdate>%4$s</time></a><span class="byline"> by <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'web2feel' ),
  121. esc_url( get_permalink() ),
  122. esc_attr( get_the_time() ),
  123. esc_attr( get_the_date( 'c' ) ),
  124. esc_html( get_the_date() ),
  125. esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
  126. esc_attr( sprintf( __( 'View all posts by %s', 'web2feel' ), get_the_author() ) ),
  127. esc_html( get_the_author() )
  128. );
  129. }
  130. endif;
  131.  
  132. /**
  133.  * Returns true if a blog has more than 1 category
  134.  *
  135.  * @since web2feel 1.0
  136.  */
  137. function web2feel_categorized_blog() {
  138. if ( false === ( $all_the_cool_cats = get_transient( 'all_the_cool_cats' ) ) ) {
  139. // Create an array of all the categories that are attached to posts
  140. $all_the_cool_cats = get_categories( array(
  141. 'hide_empty' => 1,
  142. ) );
  143.  
  144. // Count the number of categories that are attached to the posts
  145. $all_the_cool_cats = count( $all_the_cool_cats );
  146.  
  147. set_transient( 'all_the_cool_cats', $all_the_cool_cats );
  148. }
  149.  
  150. if ( '1' != $all_the_cool_cats ) {
  151. // This blog has more than 1 category so web2feel_categorized_blog should return true
  152. return true;
  153. } else {
  154. // This blog has only 1 category so web2feel_categorized_blog should return false
  155. return false;
  156. }
  157. }
  158.  
  159. /**
  160.  * Flush out the transients used in web2feel_categorized_blog
  161.  *
  162.  * @since web2feel 1.0
  163.  */
  164. function web2feel_category_transient_flusher() {
  165. // Like, beat it. Dig?
  166. delete_transient( 'all_the_cool_cats' );
  167. }
  168. add_action( 'edit_category', 'web2feel_category_transient_flusher' );
  169. add_action( 'save_post', 'web2feel_category_transient_flusher' );

Kshyhoo
Masz:
  1. function web2feel_content_nav( $nav_id ) {
  2. global $wp_query;
  3.  
  4. $nav_class = 'site-navigation paging-navigation';
  5. if ( is_single() )
  6. $nav_class = 'site-navigation post-navigation';
  7.  
  8. }
  9. ?>

Powinno być:
  1. function web2feel_content_nav( $nav_id ) {
  2. global $wp_query;
  3.  
  4. $nav_class = 'site-navigation paging-navigation';
  5. if ( is_single() )
  6. $nav_class = 'site-navigation post-navigation';
  7.  
  8. ?>


Proszę w tytułach wątków używać tagów zgodnych z regułą, tj. w nawiasach kwadratowych, np.: [PHP].

Następnie:
  1. <?php if ( get_previous_posts_link() ) : ?>
  2. <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'web2feel' ) ); ?></div>
  3. <?php endif; ?>
  4.  
  5.  
  6.  
  7. </nav><!-- #<?php echo $nav_id; ?> -->
  8. <?php
  9.  
  10. endif; // web2feel_content_nav
  11.  
  12. if ( ! function_exists( 'web2feel_comment' ) ) :
  13. /**
  14.  * Template for comments and pingbacks.
  15.  *
  16.  * Used as a callback by wp_list_comments() for displaying the comments.
  17.  *
  18.  * @since web2feel 1.0
  19.  */
  20. function web2feel_comment( $comment, $args, $depth ) {
  21. $GLOBALS['comment'] = $comment;
  22. switch ( $comment->comment_type ) :
  23. case 'pingback' :
  24. case 'trackback' :
  25. }
  26. ?>

Powinno być:
  1. <?php if ( get_previous_posts_link() ) : ?>
  2. <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'web2feel' ) ); ?></div>
  3. <?php endif; ?>
  4.  
  5. <?php endif; ?>
  6.  
  7. </nav><!-- #<?php echo $nav_id; ?> -->
  8. <?php
  9. }
  10. endif; // web2feel_content_nav
  11.  
  12. if ( ! function_exists( 'web2feel_comment' ) ) :
  13. /**
  14.  * Template for comments and pingbacks.
  15.  *
  16.  * Used as a callback by wp_list_comments() for displaying the comments.
  17.  *
  18.  * @since web2feel 1.0
  19.  */
  20. function web2feel_comment( $comment, $args, $depth ) {
  21. $GLOBALS['comment'] = $comment;
  22. switch ( $comment->comment_type ) :
  23. case 'pingback' :
  24. case 'trackback' :
  25. ?>

Czyli bierzesz się za rzeczy, których nie rozumiesz. Zamykasz tagi funkcji, które kończą się wiele linii dalej...
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.