0

Hello I need help solving this php code. I get the error : Parse error: syntax error, unexpected '}' in /home/pkyxkrtp/public_html/wp-content/themes/fundingpress/themeOptions/rating.php on line 3

<?php
}
add_action( 'save_post', 'cd_meta_box_save' );
function cd_meta_box_save( $post_id ){
  // Bail if we're doing an auto save
  if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
  // if our nonce isn't there, or we can't verify it, bail
  if( !isset( $_POST['meta_box_nonce'] ) || !wp_verify_nonce( $_POST['meta_box_nonce'], 'my_meta_box_nonce' ) ) return;
  // if our current user can't edit this post, bail
  if( !current_user_can( 'edit_post' ) ) return;
  // now we can actually save the data
  $allowed = array(
    'a' => array(
      // on allow a tags
      'href' => array()
      // and those anchords can only have href attribute
    )
  );
  // Probably a good idea to make sure your data is set
  if( isset( $_POST['creteria_1_text'] ) )
    update_post_meta( $post_id, 'creteria_1_text', wp_kses( $_POST['creteria_1_text'], $allowed ) );
  if( isset( $_POST['overall_rating'] ) )
    update_post_meta( $post_id, 'overall_rating', esc_attr( $_POST['overall_rating'] ) );
  if( isset( $_POST['creteria_1'] ) )
    update_post_meta( $post_id, 'creteria_1', esc_attr( $_POST['creteria_1'] ) );
  if( isset( $_POST['creteria_2_text'] ) )
    update_post_meta( $post_id, 'creteria_2_text', wp_kses( $_POST['creteria_2_text'], $allowed ) );
  if( isset( $_POST['creteria_2'] ) )
    update_post_meta( $post_id, 'creteria_2', esc_attr( $_POST['creteria_2'] ) );
  if( isset( $_POST['creteria_3_text'] ) )
    update_post_meta( $post_id, 'creteria_3_text', wp_kses( $_POST['creteria_3_text'], $allowed ) );
  if( isset( $_POST['creteria_3'] ) )
    update_post_meta( $post_id, 'creteria_3', esc_attr( $_POST['creteria_3'] ) );
  if( isset( $_POST['creteria_4_text'] ) )
    update_post_meta( $post_id, 'creteria_4_text', wp_kses( $_POST['creteria_4_text'], $allowed ) );
  if( isset( $_POST['creteria_4'] ) )
    update_post_meta( $post_id, 'creteria_4', esc_attr( $_POST['creteria_4'] ) );
  if( isset( $_POST['creteria_5_text'] ) )
    update_post_meta( $post_id, 'creteria_5_text', wp_kses( $_POST['creteria_5_text'], $allowed ) );
  if( isset( $_POST['creteria_5'] ) )
    update_post_meta( $post_id, 'creteria_5', esc_attr( $_POST['creteria_5'] ) );
}
// function for show rating content
//$key_1_value = get_post_meta($post->ID, 'my_meta_box_text', true);
?>
Piyin
  • 1,823
  • 1
  • 16
  • 23
  • I would recommend reading some tutorial about basic PHP syntax. Then you should add some line breaks and indentions to make the code readable. – M. Eriksson Jul 24 '17 at 22:00

1 Answers1

0

The first } (before add_action( 'save_post', 'cd_meta_box_save' );) is probably what's causing the issue

Piyin
  • 1,823
  • 1
  • 16
  • 23