Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author YOP

    (@yourownprogrammer)

    Hi John,

    Make sure that your JavaScript is enabled.
    Please try again and let us know if you need more help.

    Best wishes,

    YOP Team

    Thread Starter johnklijnen

    (@johnklijnen)

    I don’t really understand what you mean with javascript enabled? On my computer (Macbook pro) or browser (Chrome and Firefox)? I restarted my computer and tried again. The problem remains.

    Thread Starter johnklijnen

    (@johnklijnen)

    Oké, I checked with firefox, Safari and Chrome, all have Javascript enabled. The problem remains.

    Thread Starter johnklijnen

    (@johnklijnen)

    Oh yes, just to be complete. I’m using the latest version of WordPress 3.9.1–nl_NL. Could that be the problem?

    Plugin Author YOP

    (@yourownprogrammer)

    Hey John,

    Did you install any other plugin recently?
    This problem might be caused by a conflict between YOP Poll and another plugin.

    Regards,

    YOP Team

    Thread Starter johnklijnen

    (@johnklijnen)

    I deactivated all plugins except Yop-Poll and still no solution.

    Plugin Author YOP

    (@yourownprogrammer)

    Hi John,

    Edit yop_poll_model.php and replace the edit_poll_in_database function with

    public function edit_poll_in_database( $request = array(), $config = NULL ) {
       if ( $this->verify_request_data( $request, $config ) ){
        $this->make_poll_from_request_data( $request, $config );
    
        $result = self::get_poll_from_database_by_id( $this->poll['id'] );
        if ( isset( $result['id'] ) ){
         //update poll in db
    
         self::update_poll_in_database( $this->poll );
    
         $poll_old_options = get_yop_poll_meta( $this->poll['id'], 'options', true );
    
         if ( !isset( $poll_old_options['has_auto_generate_poll_page'] ) ){
          $poll_old_options['has_auto_generate_poll_page'] = 'no';
         }
         if ( !isset( $request['yop_poll_options']['auto_generate_poll_page'] ) ){
          $request['yop_poll_options']['auto_generate_poll_page'] = 'no';
         }
    
         if ( 'yes' != $poll_old_options['has_auto_generate_poll_page'] ){
          if ( 'yes' == $request['yop_poll_options']['auto_generate_poll_page'] ){
           $_p                   = array();
           $_p['post_title']     = $this->poll['name'];
           $_p['post_content']   = "[yop_poll id='" . $this->poll['id'] . "']";
           $_p['post_status']    = 'publish';
           $_p['post_type']      = 'page';
           $_p['comment_status'] = 'open';
           $_p['ping_status']    = 'open';
           $_p['post_category']  = array( 1 ); // the default 'Uncategorised'
    
           $poll_page_id = wp_insert_post( $_p );
    
           $request['yop_poll_options']['poll_page_url']               = get_permalink( $poll_page_id );
           $request['yop_poll_options']['has_auto_generate_poll_page'] = 'yes';
          }
         }
    
         //update poll options in db
         $poll_options    = array();
         $default_options = get_option( 'yop_poll_options', false );
    
         if ( isset( $request['yop_poll_options'] ) ){
          foreach ( $request['yop_poll_options'] as $option_name => $option_value ) {
           if ( $default_options ){
            if ( isset ( $default_options[$option_name] ) ){
             if ( $default_options[$option_name] != $option_value ){
              $poll_options[$option_name] = $option_value;
             }
            }
           }
           else {
            $poll_options[$option_name] = $option_value;
           }
          }
         }
         //this is for checkbox options
         if ( !isset( $request['yop_poll_options']['never_expire'] ) ){
          $poll_options['never_expire'] = 'no';
         }
    
         if ( isset( $request['yop_poll_options']['schedule_reset_poll_date'] ) ){
          $poll_options['schedule_reset_poll_date'] = strtotime( $request['yop_poll_options']['schedule_reset_poll_date'] );
         }
         else {
          $poll_options['schedule_reset_poll_date'] = current_time( 'timestamp' );
         }
    
         if ( 'yes' == $request['yop_poll_options']['schedule_reset_poll_stats'] ){
          $default_options['start_scheduler'] = 'yes';
         }
         else {
          $change_start_scheduler_to_no = true;
          $yop_polls                    = self::get_yop_polls_fields( array( 'id' ) );
          if ( count( $yop_polls ) > 0 ){
           foreach ( $yop_polls as $yop_poll_id ) {
            if ( $yop_poll_id['id'] != $this->poll['id'] ){
             $yop_poll_options = get_yop_poll_meta( $yop_poll_id['id'], 'options', true );
             if ( isset( $yop_poll_options['schedule_reset_poll_stats'] ) && 'yes' == $yop_poll_options['schedule_reset_poll_stats'] ){
              $change_start_scheduler_to_no = false;
             }
            }
           }
          }
          if ( $change_start_scheduler_to_no ){
           $default_options['start_scheduler'] = 'no';
          }
          else {
           $default_options['start_scheduler'] = 'yes';
          }
         }
         update_option( 'yop_poll_options', $default_options );
    
         //if ( count( $poll_options ) > 0 )
         update_yop_poll_meta( $this->poll['id'], 'options', $poll_options );
    
         //add update answers in db
         foreach ( $default_options as $option_name => $option_value ) {
          if ( isset( $poll_options[$option_name] ) ){
           if ( $option_name != 'use_template_bar' ){
            $default_options[$option_name] = $poll_options[$option_name];
           }
          }
         }
    
         $this->make_answers_from_request_data( $request, $config );
         if ( count( $this->answers ) > 0 ){
          $answer_ids_for_not_remove = array();
          $all_poll_answers          = self::get_poll_answers( $this->poll['id'], array( 'default', 'other' ) );
          foreach ( $this->answers as $answer ) {
           if ( $answer['id'] ){
            self::update_answer_in_database( $answer );
            $answer_id = $answer['id'];
           }
           else {
            $answer_id = self::insert_answer_to_database( $answer );
           }
           //if( 'other' != $answer['type'] )
           $answer_ids_for_not_remove[] = $answer_id;
    
           //insert poll answer options to db
           if ( 'other' != $answer['type'] ){
            if ( isset( $request['yop_poll_answer_options'][$answer['name']] ) ){
             $poll_answer_options = array();
             foreach ( $request['yop_poll_answer_options'][$answer['name']] as $option_name => $option_value ) {
              if ( isset( $poll_options[$option_name] ) && $poll_options[$option_name] != $option_value ){
               $poll_answer_options[$option_name] = $option_value;
              }
              elseif ( $default_options[$option_name] != $option_value ) {
               $poll_answer_options[$option_name] = $option_value;
              }
              if ( $option_name == 'is_default_answer' ){
               $poll_answer_options[$option_name] = $option_value;
              }
             }
             //if ( count( $poll_answer_options ) > 0 ) {
             /*if ( isset( $request['yop_poll_options']['use_template_bar'] ) ) {
             if ( $request['yop_poll_options']['use_template_bar'] == 'yes' ) {
             if ( isset( $poll_answer_options[ 'use_template_bar' ] ) )
             $poll_answer_options[ 'use_template_bar' ]    = 'yes';
             }
             }*/
             update_yop_poll_answer_meta( $answer_id, 'options', $poll_answer_options, false );
            }
           }
          }
          //deleting removed answers
          if ( count( $all_poll_answers ) > 0 ){
           foreach ( $all_poll_answers as $answer ) {
            if ( !in_array( $answer['id'], $answer_ids_for_not_remove ) ){
             self::delete_poll_answers_from_db( $answer['id'], $this->poll['id'] );
             delete_yop_poll_answer_meta( $answer['id'], 'options' );
            }
           }
          }
         }
    
         //update insert custom fields in db
         $this->make_custom_fields_from_request_data( $request, $config );
         if ( count( $this->custom_fields ) > 0 ){
          $customfield_ids_for_not_remove = array();
          $all_poll_customfields          = self::get_poll_customfields( $this->poll['id'] );
          foreach ( $this->custom_fields as $custom_field ) {
           if ( $custom_field['id'] ){
            self::update_custom_field_in_database( $custom_field );
            $custom_field_id = $custom_field['id'];
           }
           else {
            $custom_field_id = self::insert_custom_field_to_database( $custom_field );
           }
           $customfield_ids_for_not_remove[] = $custom_field_id;
          }
          //deleting removed custom_fields
          if ( count( $all_poll_customfields ) > 0 ){
           foreach ( $all_poll_customfields as $customfield ) {
            if ( !in_array( $customfield['id'], $customfield_ids_for_not_remove ) ){
             self::delete_poll_customfields_from_db( $customfield['id'], $this->poll['id'] );
            }
           }
          }
         }
         else {
          self::delete_all_poll_customfields_from_db( $this->poll['id'] );
         }
    
         return $this->poll['id'];
        }
        else {
         $this->error = __( 'This poll doesn't exist!', 'yop_poll' );
         return false;
        }
       }
       else {
        return false;
       }
      }

    Let us know if you need more help.

    Best wishes,

    YOP Team

    Thread Starter johnklijnen

    (@johnklijnen)

    Thanks for trying but this code stops the backoffice from working. Blanc screen. There is a bug in it.

    Thread Starter johnklijnen

    (@johnklijnen)

    I found the problem: This poll doesn't exist! was in the original file This poll doesn(backtick)t exist! That is the only difference between these two functions. I compared them in Textwrangler.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Changes aren't being saved’ is closed to new replies.