Пример #1
0
 function widget($args, $instance)
 {
     extract($args, EXTR_SKIP);
     $title = $instance['title'] ? esc_attr($instance['title']) : __yop_poll('Yop Poll Widget');
     $poll_id = $instance['poll_id'] ? intval($instance['poll_id']) : -1;
     $tr_id = $instance['tr_id'] ? $instance['tr_id'] : '';
     $poll_unique_id = uniqid('_yp');
     wp_enqueue_script('yop-poll-supercookie-js', YOP_POLL_URL . "js/yop-poll-supercookie.js", array('jquery'), YOP_POLL_VERSION, true);
     wp_enqueue_script('superCookie-min-js', YOP_POLL_URL . "js/super-cookie/superCookie-min.js", array('jquery'), YOP_POLL_VERSION, true);
     wp_enqueue_script('swfobject-js', YOP_POLL_URL . "js/super-cookie/swfobject/swfobject.js", array('jquery'), YOP_POLL_VERSION, true);
     if (-99 == $poll_id) {
         return '';
     }
     $pro_options = get_option('yop_poll_pro_options');
     require_once YOP_POLL_MODELS . 'poll_model.php';
     $yop_poll_model = new YOP_POLL_Poll_Model($poll_id);
     $yop_poll_model->unique_id = $poll_unique_id;
     $poll_id = $yop_poll_model->ID;
     $template = $yop_poll_model->return_poll_html(array('tr_id' => $tr_id, 'location' => 'widget', 'load_css' => true, 'load_js' => true));
     if ('yes' == $yop_poll_model->use_default_loading_image) {
         $loading_image_src = YOP_POLL_URL . 'images/loading36x36.gif';
     } else {
         $loading_image_src = $yop_poll_model->loading_image_url;
     }
     wp_enqueue_script('jquery');
     wp_enqueue_script('yop-poll-jquery-popup-windows', YOP_POLL_URL . "js/jquery.popupWindow.js", array('jquery'), YOP_POLL_VERSION, true);
     wp_enqueue_style('yop-poll-public', YOP_POLL_URL . "css/yop-poll-public.css", array(), YOP_POLL_VERSION);
     wp_enqueue_script('yop-poll-widget-user-defined_' . $poll_id . $poll_unique_id, add_query_arg(array('id' => $poll_id, 'location' => 'widget', 'unique_id' => $poll_unique_id), admin_url('admin-ajax.php', is_ssl() ? 'https' : 'http') . '?action=yop_poll_load_js'), array('jquery'), YOP_POLL_VERSION, true);
     wp_enqueue_script('yop-poll-public-js', YOP_POLL_URL . 'js/yop-poll-public.js', array(), YOP_POLL_VERSION, true);
     wp_enqueue_script('yop-poll-json-2', YOP_POLL_URL . "js/yop-poll-json2.js", array(), YOP_POLL_VERSION, true);
     wp_enqueue_script('yop-poll-jquery-base64', YOP_POLL_URL . "js/yop-poll-jquery.base64.min.js", array(), YOP_POLL_VERSION, true);
     $yop_poll_public_config_general = array('ajax' => array('url' => admin_url('admin-ajax.php', is_ssl() ? 'https' : 'http'), 'vote_action' => 'yop_poll_do_vote', 'yop_poll_show_vote_options' => 'yop_poll_show_vote_options', 'captcha_action' => 'yop_poll_show_captcha', 'view_results_action' => 'yop_poll_view_results', 'back_to_vote_action' => 'yop_poll_back_to_vote', 'is_wordpress_user_action' => 'yop_poll_is_wordpress_user', 'is_facebook_user_action' => 'yop_poll_is_facebook_user'), 'pro' => array(), 'yop_poll_version' => YOP_POLL_VERSION, 'vote_with_wordpress_login_url' => wp_login_url(admin_url('admin-ajax.php?action=yop_poll_set_wordpress_vote', is_ssl() ? 'https' : 'http')), 'vote_with_facebook_ajax_url' => admin_url('admin-ajax.php?action=yop_poll_set_facebook_vote', is_ssl() ? 'https' : 'http'));
     $vote_permisions_types = 0;
     if ('guest-only' != $yop_poll_model->vote_permisions) {
         if ('yes' == $yop_poll_model->vote_permisions_wordpress) {
             $vote_permisions_types += 1;
         }
         if ('yes' == $yop_poll_model->vote_permisions_anonymous) {
             $vote_permisions_types += 2;
         }
         if ('yes' == $yop_poll_model->vote_permisions_facebook) {
             $vote_permisions_types += 4;
         }
     }
     $yop_poll_public_config = array('poll_options' => array('vote_permisions' => $yop_poll_model->vote_permisions, 'vote_permisions_facebook_label' => $yop_poll_model->vote_permisions_facebook_label, 'vote_permisions_wordpress_label' => $yop_poll_model->vote_permisions_wordpress_label, 'vote_permisions_anonymous_label' => $yop_poll_model->vote_permisions_anonymous_label, 'vote_permisions_types' => $vote_permisions_types, 'share_after_vote' => $yop_poll_model->share_after_vote, 'share_name' => $yop_poll_model->share_name, 'share_caption' => $yop_poll_model->share_caption, 'share_description' => $yop_poll_model->share_description, 'share_picture' => $yop_poll_model->share_picture, 'share_link' => $yop_poll_model->poll_page_url == '' ? site_url() : $yop_poll_model->poll_options['poll_page_url'], 'redirect_after_vote' => $yop_poll_model->redirect_after_vote, 'redirect_after_vote_url' => $yop_poll_model->redirect_after_vote_url), 'loading_image_src' => $loading_image_src, 'loading_image_alt' => __('Loading', 'yop_poll'));
     wp_localize_script('yop-poll-public-js', 'yop_poll_public_config_general', $yop_poll_public_config_general);
     wp_localize_script('yop-poll-public-js', 'yop_poll_public_config_' . $poll_id . $poll_unique_id, $yop_poll_public_config);
     echo $before_widget;
     echo $before_title . $title . $after_title;
     echo do_shortcode($template);
     echo $after_widget;
 }
Пример #2
0
 public function activate($networkwide)
 {
     if (!current_user_can('activate_plugins')) {
         $error = new WP_Error('Wordpress_version_error', __yop_poll('You need permissions to activate this plugin'), __yop_poll('Error: Wordpress Activation Permissions Problem'));
     }
     if (!version_compare($GLOBALS['wp_version'], YOP_POLL_WP_VERSION, '>=')) {
         $error = new WP_Error('Wordpress_version_error', sprintf(__yop_poll('You need at least Wordpress version %s to use this plugin'), YOP_POLL_WP_VERSION), __yop_poll('Error: Wordpress Version Problem'));
     }
     if (isset($error) && is_wp_error($error)) {
         wp_die($error->get_error_message(), $error->get_error_data());
     }
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     require_once YOP_POLL_INC . 'db_schema.php';
     $this->install_default_options();
     $capObj = YOP_POLL_Capabilities::get_instance();
     $capObj->install_capabilities();
     Yop_Poll_DbSchema::install_database();
 }
Пример #3
0
 public function after_buy()
 {
     sleep(8);
     $data['title'] = __yop_poll("Finish Upgrade");
     $domain = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
     $domain = str_replace("www.", "", $domain);
     $pro_options = get_option("yop_poll_pro");
     $rand = $pro_options['rand_number'];
     $ch = curl_init("http://yop-poll.com/yop-poll-pro/upgrade.php?action=getPackageLink&domain=" . urlencode($domain) . "&rand=" . urlencode($rand));
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $result = curl_exec($ch);
     curl_close($ch);
     $result = json_decode($result, true);
     if (isset($result['error']) && "Error" == $result['error']) {
         $data['error'] = $result['message'];
         $this->display('after_upgrade.html', $data);
     } else {
         $pro_options = get_option("yop_poll_pro");
         $pro_options['pro_key'] = $result['licence'];
         $data['success'] = $result['message'];
         $download_link = $result['download_link'] . "&domain={$domain}&rand={$rand}";
         update_option("yop_poll_pro", $pro_options);
         require_once YOP_POLL_PATH . "upgrade.php";
         $this->display('after_upgrade.html', $data);
     }
 }
Пример #4
0
 public static function save_poll($preview = false)
 {
     $new_poll = new YOP_POLL_Poll_Model($_POST['poll_id']);
     $new_poll->poll_title = stripslashes(trim($_POST['poll_title']));
     $new_poll->poll_name = sanitize_title($new_poll->poll_title);
     $new_poll->poll_author = $GLOBALS['current_user']->ID;
     $new_poll->poll_date = current_time('mysql');
     $new_poll->poll_status = 'active';
     $new_poll->poll_modified = current_time('mysql');
     $new_poll->poll_start_date = $_POST['poll_start_date'];
     $new_poll->poll_end_date = isset($_POST['poll_never_expire']) && 'yes' == $_POST['poll_never_expire'] ? '01-01-2038 23:59:59' : $_POST['poll_end_date'];
     $new_poll->poll_total_votes = 0;
     //poll options area
     if (isset($_POST['yop_poll_options']) && is_array($_POST['yop_poll_options']) && count($_POST['yop_poll_options']) > 0) {
         foreach ($_POST['yop_poll_options'] as $poll_option_field => $poll_option_value) {
             $new_poll->{$poll_option_field} = $poll_option_value;
         }
     }
     if (isset($_POST['yop_poll_options']['use_the_same_template_for_widget'])) {
         $new_poll->use_the_same_template_for_widget = 'yes';
         $new_poll->widget_template_width = $new_poll->template_width;
         $new_poll->widget_template = $new_poll->template;
     } else {
         $new_poll->use_the_same_template_for_widget = 'no';
     }
     $questions = array();
     if (isset($_POST['yop_poll_question']) && is_array($_POST['yop_poll_question']) && count($_POST['yop_poll_question']) > 0) {
         foreach ($_POST['yop_poll_question'] as $question_args) {
             $new_question = new YOP_POLL_Question_Model($question_args['question_id']);
             $new_question->question = trim($question_args['question']);
             $new_question->type = trim($question_args['type']);
             $new_question->question_modified = current_time('mysql');
             $new_question->poll_order = intval($question_args['poll_order']);
             if (!$new_question->exists()) {
                 //for insert
                 $new_question->question_author = $GLOBALS['current_user']->ID;
                 $new_question->question_date = current_time('mysql');
                 $new_question->question_status = 'active';
             }
             //question options area
             if (isset($question_args['options']) && is_array($question_args['options']) && count($question_args['options']) > 0) {
                 foreach ($question_args['options'] as $question_option_field => $question_option_value) {
                     $new_question->{$question_option_field} = $question_option_value;
                 }
             }
             $custom_fields = array();
             //question custom fields area
             if (isset($question_args['custom_fields']) && is_array($question_args['custom_fields']) && count($question_args['custom_fields']) > 0) {
                 foreach ($question_args['custom_fields'] as $question_custom_field) {
                     $cf_id = isset($question_custom_field['id']) ? trim($question_custom_field['id']) : 0;
                     $new_custom_field = new YOP_POLL_Custom_Field_Model($cf_id);
                     $new_custom_field->custom_field = trim($question_custom_field['custom_field']);
                     $new_custom_field->required = isset($question_custom_field['required']) ? trim($question_custom_field['required']) : 'no';
                     $new_custom_field->status = "active";
                     if ($new_custom_field->custom_field == "") {
                         $response['success'] = 0;
                         $response['id'] = -1;
                         $response['error'] = 1;
                         $response['message'] = __yop_poll('Custom Field') . ' ' . $question_custom_field['order'] . ' ' . __yop_poll('from Question') . ' ' . $new_question->poll_order . ' ' . __yop_poll('is empty!');
                         wp_die(json_encode($response));
                     }
                     $custom_fields[] = $new_custom_field;
                 }
             }
             $new_question->custom_fields = $custom_fields;
             $answers = array();
             if (isset($_POST['yop_poll_answer'][$question_args['question_id']]) && is_array($_POST['yop_poll_answer'][$question_args['question_id']]) && count($_POST['yop_poll_answer'][$question_args['question_id']]) > 0) {
                 foreach ($_POST['yop_poll_answer'][$question_args['question_id']] as $answer_args) {
                     $new_answer = new YOP_POLL_Answer_Model($answer_args['answer_id']);
                     $new_answer->answer = trim($answer_args['answer']);
                     $new_answer->type = trim($answer_args['type']);
                     if (isset($answer_args['is_default_answer'])) {
                         $new_answer->is_default_answer = 'yes';
                     } else {
                         $new_answer->is_default_answer = 'no';
                     }
                     $new_answer->description = "";
                     if ($new_answer->type == 'video') {
                         $new_answer->description = trim($answer_args['description_video']);
                     } else {
                         if ($new_answer->type == 'image') {
                             $new_answer->description = trim($answer_args['description_image']);
                         }
                     }
                     $new_answer->question_order = trim($answer_args['question_order']);
                     $new_answer->answer_modified = current_time('mysql');
                     if (!$new_answer->exists()) {
                         //for insert
                         $new_answer->answer_author = $GLOBALS['current_user']->ID;
                         $new_answer->answer_date = current_time('mysql');
                         $new_answer->answer_status = 'active';
                     }
                     if ($new_answer->answer == '') {
                         $response['success'] = 0;
                         $response['id'] = -1;
                         $response['error'] = 1;
                         $response['message'] = __yop_poll('Answer') . ' ' . $new_answer->question_order . ' ' . __yop_poll('from Question') . ' ' . $new_question->poll_order . ' ' . __yop_poll('is empty!');
                         wp_die(json_encode($response));
                     }
                     $answers[] = $new_answer;
                 }
             }
             $new_question->answers = $answers;
             if ($new_question->question == '') {
                 $response['success'] = 0;
                 $response['id'] = -1;
                 $response['error'] = 1;
                 $response['message'] = __yop_poll('Question') . ' ' . $new_question->poll_order . ' ' . __yop_poll('is empty!');
                 wp_die(json_encode($response));
             }
             $questions[] = $new_question;
         }
     }
     $new_poll->questions = $questions;
     if ($preview) {
         $new_poll->ID = 'preview';
         return $new_poll->return_poll_html(array('tr_id' => '', 'location' => 'page', 'load_css' => true, 'load_js' => false));
     } else {
         if (!$new_poll->exists() && YOP_POLL_Poll_Model::get_data_by('name', $new_poll->poll_name)) {
             $response['success'] = 0;
             $response['id'] = -1;
             $response['error'] = 1;
             $response['message'] = __yop_poll('This poll already exists! Please choose another name!');
             wp_die(json_encode($response));
         }
         if ($new_poll->exists() && YOP_POLL_Poll_Model::get_other_model_data_by('name', $new_poll->poll_name, $new_poll->id)) {
             $response['success'] = 0;
             $response['id'] = -1;
             $response['error'] = 1;
             $response['message'] = __yop_poll('This poll already exists! Please choose another name!');
             wp_die(json_encode($response));
         }
         if ($new_poll->save()) {
             self::save_poll_order($new_poll->get('ID'), $_POST['poll_archive_order']);
             $response['success'] = 1;
             $response['id'] = $new_poll->ID;
             $response['error'] = 0;
             $response['message'] = __yop_poll('Poll successfully saved!');
             wp_die(json_encode($response));
         } else {
             $response['success'] = 0;
             $response['id'] = -1;
             $response['error'] = 1;
             $response['message'] = __yop_poll('Poll couldn`t be saved!');
             wp_die(json_encode($response));
         }
     }
 }
Пример #5
0
 public function return_yop_poll($id, $results, $tr_id = '', $show_results = "", $offset = 0)
 {
     //$pro_options = get_option( 'yop_poll_pro_options' );
     $options = get_option('yop_poll_options');
     require_once YOP_POLL_MODELS . "poll_model.php";
     $poll_unique_id = uniqid('_yp');
     $yop_poll_model = new YOP_POLL_Poll_Model($id);
     $yop_poll_model->unique_id = $poll_unique_id;
     if (!$yop_poll_model->ID) {
         return '';
     }
     $yop_poll_public_config_general = array('ajax' => array('url' => admin_url('admin-ajax.php', is_ssl() ? 'https' : 'http'), 'vote_action' => 'yop_poll_do_vote', 'yop_poll_show_vote_options' => 'yop_poll_show_vote_options', 'captcha_action' => 'yop_poll_show_captcha', 'view_results_action' => 'yop_poll_view_results', 'back_to_vote_action' => 'yop_poll_back_to_vote', 'is_wordpress_user_action' => 'yop_poll_is_wordpress_user', 'is_facebook_user_action' => 'yop_poll_is_facebook_user'), 'pro' => array(), 'yop_poll_version' => YOP_POLL_VERSION, 'vote_with_wordpress_login_url' => wp_login_url(admin_url('admin-ajax.php?action=yop_poll_set_wordpress_vote', is_ssl() ? 'https' : 'http')), 'vote_with_facebook_ajax_url' => admin_url('admin-ajax.php?action=yop_poll_set_facebook_vote', is_ssl() ? 'https' : 'http'));
     $vote_permisions_types = 0;
     if (in_array('registered', $yop_poll_model->vote_permisions)) {
         if ('yes' == $yop_poll_model->vote_permisions_wordpress) {
             $vote_permisions_types += 1;
         }
         if ('yes' == $yop_poll_model->vote_permisions_anonymous && in_array('guest', $yop_poll_model->vote_permisions) || 'yes' == $yop_poll_model->vote_permisions_anonymous && in_array('registered', $yop_poll_model->vote_permisions)) {
             $vote_permisions_types += 2;
         }
     } else {
         if (in_array('guest', $yop_poll_model->vote_permisions)) {
             if ('yes' == $yop_poll_model->vote_permisions_anonymous && in_array('guest', $yop_poll_model->vote_permisions)) {
                 $vote_permisions_types += 2;
             }
         }
     }
     if ('yes' == $options["use_default_loading_image"]) {
         $loading_image_src = YOP_POLL_URL . 'images/loading36x36.gif';
     } else {
         $loading_image_src = $options["loading_image_url"];
     }
     if ($results) {
         $yop_poll_model->vote = true;
     }
     $template = $yop_poll_model->return_poll_html(array('tr_id' => $tr_id, 'location' => 'page', 'load_css' => true, 'load_js' => true, 'show_results' => $show_results));
     $yop_poll_public_config = array('poll_options' => array('vote_permisions' => $yop_poll_model->vote_permisions, 'vote_permisions_facebook_label' => $yop_poll_model->vote_permisions_facebook_label, 'vote_permisions_wordpress_label' => $yop_poll_model->vote_permisions_wordpress_label, 'vote_permisions_anonymous_label' => $yop_poll_model->vote_permisions_anonymous_label, 'vote_permisions_google_label' => $yop_poll_model->vote_permisions_google_label, 'vote_permisions_types' => $vote_permisions_types, 'share_after_vote' => $yop_poll_model->share_after_vote, 'share_name' => $yop_poll_model->share_name, 'share_caption' => $yop_poll_model->share_caption, 'share_description' => $yop_poll_model->share_description, 'share_picture' => $yop_poll_model->share_picture, 'share_poll_name' => $yop_poll_model->poll['name'], 'share_link' => $yop_poll_model->poll_page_url == '' ? site_url() : $yop_poll_model->poll_page_url, 'redirect_after_vote' => $yop_poll_model->redirect_after_vote, 'redirect_after_vote_url' => $yop_poll_model->redirect_after_vote_url, 'facebook_share_after_vote' => $yop_poll_model->facebook_share_after_vote), 'loading_image_src' => $loading_image_src, 'loading_image_alt' => __yop_poll('Loading'));
     $tabulate['results'] = false;
     $tabulate['answers'] = false;
     $tabulate['orizontal_answers'] = 0;
     $tabulate['orizontal_results'] = 0;
     wp_enqueue_script('yop-poll-public-js', YOP_POLL_URL . "js/yop-poll-public.js", array('jquery'), YOP_POLL_VERSION, true);
     foreach ($yop_poll_model->questions as $question) {
         $answers_tabulated_cols = 1;
         //vertical display
         $results_tabulated_cols = 1;
         $include_others = false;
         $display_answers = array('text', 'image', 'video');
         if (isset($question->allow_other_answers) && 'yes' == $question->allow_other_answers) {
             if (isset($question->display_other_answers_values) && 'yes' == $question->display_other_answers_values) {
                 $include_others = true;
                 $display_answers = array('text', 'image', 'video', 'other');
             }
         }
         if ('orizontal' == $question->display_answers) {
             $ans_no = $question->countanswers($display_answers, $include_others);
             if ($ans_no > 0) {
                 $tabulate['orizontal_answers'] = $ans_no;
             }
             if (isset($question->allow_other_answers) && 'yes' == $question->allow_other_answers) {
                 $tabulate['orizontal_answers']++;
             }
         }
         if ('orizontal' == $question->display_results) {
             $ans_no = $question->countanswers($display_answers, $include_others);
             if ($ans_no > 0) {
                 $tabulate['orizontal_results'] = $ans_no;
             }
         }
         if ('tabulated' == $question->display_answers) {
             $tabulate['answers'] = true;
         }
         if ('tabulated' == $question->display_results) {
             $tabulate['results'] = true;
         }
     }
     wp_enqueue_script('yop-poll-public-js', YOP_POLL_URL . "js/yop-poll-public.js", array('jquery'), YOP_POLL_VERSION, true);
     wp_localize_script('yop-poll-public-js', 'tabulate', $tabulate);
     wp_enqueue_script('yop-poll-supercookie-js', YOP_POLL_URL . "js/yop-poll-supercookie.js", array('jquery'), YOP_POLL_VERSION, true);
     wp_enqueue_script('superCookie-min-js', YOP_POLL_URL . "js/super-cookie/superCookie-min.js", array('jquery'), YOP_POLL_VERSION, true);
     wp_enqueue_script('swfobject-js', YOP_POLL_URL . "js/super-cookie/swfobject/swfobject.js", array('jquery'), YOP_POLL_VERSION, true);
     wp_enqueue_script('yop-poll-jquery-popup-windows', YOP_POLL_URL . "js/jquery.popupWindow.js", array(), YOP_POLL_VERSION, true);
     wp_enqueue_script('yop-poll-jquery-base64', YOP_POLL_URL . "js/yop-poll-jquery.base64.min.js", array(), YOP_POLL_VERSION, true);
     wp_enqueue_script('yop-poll-json-2', YOP_POLL_URL . "js/yop-poll-json2.js", array(), YOP_POLL_VERSION, true);
     wp_enqueue_script('yop-poll-user-defined_' . $yop_poll_model->ID . $poll_unique_id, add_query_arg(array('id' => $id, 'location' => 'page', 'unique_id' => $poll_unique_id), admin_url('admin-ajax.php', is_ssl() ? 'https' : 'http') . '?action=yop_poll_load_js'), array('jquery'), YOP_POLL_VERSION, true);
     wp_localize_script('yop-poll-public-js', 'yop_poll_public_config_general', $yop_poll_public_config_general);
     wp_localize_script('yop-poll-public-js', 'yop_poll_public_config_' . $yop_poll_model->ID . $poll_unique_id, $yop_poll_public_config);
     // wp_enqueue_style( 'yop-poll-public-css', "{$this->_config->plugin_url}css/yop-poll-admin.css", array(), YOP_POLL_VERSION );
     /*wp_enqueue_style( 'yop-poll-public-css', "{$this->_config->plugin_url}/css/yop-poll-public.css", array(), $this->_config->version );
       wp_enqueue_script( 'jquery' );
       wp_enqueue_script( 'yop-poll-jquery-popup-windows', "{$this->_config->plugin_url}/js/jquery.popupWindow.js", array(), $this->_config->version, true );
       wp_enqueue_script( 'yop-poll-user-defined_' . $id . $poll_unique_id, add_query_arg( array( 'id' => $id, 'location' => 'page', 'unique_id' => $poll_unique_id ), admin_url( 'admin-ajax.php', ( is_ssl() ? 'https' : 'http' ) ) . '?action=yop_poll_load_js' ), array( 'jquery' ), $this->_config->version, true );
       wp_enqueue_script( 'yop-poll-public-js', "{$this->_config->plugin_url}js/yop-poll-public.js", array(), $this->_config->version, true );
       wp_enqueue_script( 'yop-poll-json2', "{$this->_config->plugin_url}/js/yop-poll-json2.js", array(), $this->_config->version, true );
       wp_enqueue_script( 'yop-poll-jquery-base64', "{$this->_config->plugin_url}/js/yop-poll-jquery.base64.min.js", array(), $this->_config->version, true );
       */
     return $template;
 }
Пример #6
0
 public function add_votes()
 {
     if (is_admin()) {
         if (!check_ajax_referer('yop-poll-results_vote_add_vote', 'yop-poll-results_votes_add_votes', false)) {
             wp_die(__yop_poll('You are not allowed to access this request.'));
         }
         $pollAdminObj = YOP_POLL_Poll_Admin::get_instance();
         $pollAdminObj->add_votes();
     }
     die;
 }
Пример #7
0
    public function activation_hook($default)
    {
        ini_set('max_execution_time', 700);
        $current_options = get_option('yop_poll_options');
        $polls = self::yop_poll_get_polls_from_db();
        $answers = self::yop_poll_get_answers_from_db();
        $logs = self::yop_poll_get_logs_from_db();
        $bans = self::yop_poll_get_bans_from_db();
        $custom_fields = self::yop_poll_get_custom_fields_from_db();
        $custom_votes = self::yop_poll_get_custom_fields_votes_from_db();
        $metas = self::yop_poll_get_polls_meta_from_db();
        $answers_meta = self::yop_poll_get_answers_meta_from_db();
        $templates = self::yop_poll_get_templates_from_db();
        foreach ($templates as $template) {
            $template['before_vote_template'] = "[QUESTION_CONTAINER]" . $template['before_vote_template'];
            $template['before_vote_template'] = str_replace('%POLL-ANSWER-LABEL%', '%POLL-ANSWER-LABEL% [ANSWER_RESULT_CONTAINER]', $template['before_vote_template']);
            $template['before_vote_template'] = str_replace('%POLL-TOTAL-ANSWERS%', '%POLL-TOTAL-ANSWERS-LABEL%', $template['before_vote_template']);
            $template['before_vote_template'] = str_replace('%POLL-TOTAL-VOTES%', '%POLL-TOTAL-VOTES-LABEL%', $template['before_vote_template']);
            $template['after_vote_template'] = str_replace('%POLL-TOTAL-VOTES%', '%POLL-TOTAL-VOTES-LABEL%', $template['after_vote_template']);
            $template['after_vote_template'] = str_replace('%POLL-TOTAL-ANSWERS%', '%POLL-TOTAL-ANSWERS-LABEL%', $template['after_vote_template']);
            $template['after_end_date_template'] = str_replace('%POLL-TOTAL-ANSWERS%', '%POLL-TOTAL-ANSWERS-LABEL%', $template['after_end_date_template']);
            $template['after_end_date_template'] = str_replace('%POLL-TOTAL-VOTES%', '%POLL-TOTAL-VOTES-LABEL%', $template['after_end_date_template']);
            $template['before_vote_template'] = preg_replace('/%POLL-ANSWER-RESULT-BAR%/', '%POLL-ANSWER-RESULT-BAR%  [/ANSWER_RESULT_CONTAINER]', $template['before_vote_template'], 1);
            $find = '[/ANSWER_RESULT_CONTAINER]';
            $replace = '';
            //   $template['before_vote_template']= preg_replace(strrev("/$find/"),strrev($replace),strrev( $template['before_vote_template']),1);
            $template['after_vote_template'] = "[QUESTION_CONTAINER]" . $template['after_vote_template'];
            $template['after_end_date_template'] = "[QUESTION_CONTAINER]" . $template['after_end_date_template'];
            /*  if(strpos($template['before_vote_template'],"[CAPTCHA_CONTAINER]"))
                    $template['before_vote_template']=str_replace('[CAPTCHA_CONTAINER]','[/QUESTION_CONTAINER][CAPTCHA_CONTAINER]',$template['before_vote_template']);
                else{
                    $template['before_vote_template']=str_replace('<div id="yop-poll-vote-%POLL-ID%" class="yop-poll-footer">','[/QUESTION_CONTAINER]<div id="yop-poll-vote-%POLL-ID%" class="yop-poll-footer">',$template['before_vote_template']);
                } */
            $template['before_vote_template'] = $template['before_vote_template'] . '[/QUESTION_CONTAINER]';
            if (strpos($template['before_vote_template'], "%POLL-QUESTION%") && strpos($template['before_vote_template'], '%POLL-NAME%')) {
                $template['before_vote_template'] = str_replace('%POLL-QUESTION%', '', $template['before_vote_template']);
                $template['before_vote_template'] = str_replace('%POLL-NAME%', '%POLL-QUESTION%', $template['before_vote_template']);
            }
            if (strpos($template['after_vote_template'], "%POLL-QUESTION%") && strpos($template['after_vote_template'], '%POLL-NAME%')) {
                $template['after_vote_template'] = str_replace('%POLL-QUESTION%', '', $template['after_vote_template']);
                $template['after_vote_template'] = str_replace('%POLL-NAME%', '%POLL-QUESTION%', $template['after_vote_template']);
            }
            $template['after_vote_template'] = $template['after_vote_template'] . '[/QUESTION_CONTAINER]';
            $template['after_end_date_template'] = $template['after_end_date_template'] . '[/QUESTION_CONTAINER]';
            $template['js'] = <<<NOWDOC
function stripBorder_%POLL-ID%(object) {
\tobject.each(function() {
\t\tif( parseInt(jQuery(this).width() ) > 0) {
\t\t\tjQuery(this).width(
\t\t\t\tparseInt(
\t\t\t\t\tjQuery(this).width() ) -
\t\t\t\t\tparseInt(jQuery(this).css("border-left-width")) -
\t\t\t\t\tparseInt(jQuery(this).css("border-right-width"))
\t\t\t);
\t\t\t}
\t\telse {
\t\tjQuery(this).css("border-left-width", "0px");
\t\tjQuery(this).css("border-right-width", "0px");
\t\t}
\t});
}
function stripPadding_%POLL-ID%(object) {
\tobject.each(function() {
\t\tjQuery(this).width(
\t\tparseInt( jQuery(this).width() ) -
\t\tparseInt(jQuery(this).css("padding-left")) -
\t\tparseInt(jQuery(this).css("padding-left"))
\t\t);
\t});
}

function strip_results_%POLL-ID%() {
\tstripPadding_%POLL-ID%( jQuery("#yop-poll-container-%POLL-ID% .yop_poll_li_result-%POLL-ID%") );
\tstripBorder_%POLL-ID%(  jQuery("#yop-poll-container-%POLL-ID% .yop-poll-result-bar-%POLL-ID%") );
}

jQuery(document).ready(function(e) {
   jQuery('.yop-poll-forms').removeClass('yop-poll-forms-display');
\tif(typeof window.strip_results_%POLL-ID% == "function")
\t\tstrip_results_%POLL-ID%();
\tif(typeof window.tabulate_answers_%POLL-ID% == "function")
\t\ttabulate_answers_%POLL-ID%();
\tif(typeof window.tabulate_results_%POLL-ID% == "function")
\t\ttabulate_results_%POLL-ID%();



});

function equalWidth_%POLL-ID%(obj, cols, findWidest ) {

    findWidest  = typeof findWidest  !== "undefined" ? findWidest  : false;
    var quest=0;
    if ( findWidest ) {
        obj.each(function() {
            var thisWidth = jQuery(this).width();
            width = parseInt(thisWidth / cols);
            jQuery(this).width(width);
            jQuery(this).css("float", "left");
        });
    }
    else {
        var widest = 0;
        var count  = 0;
        var poz_each_question=0;

        obj.each(function() {

            count++;
            cols[quest][2]=(jQuery('#yop-poll-answers-%POLL-ID%-'+ cols[quest][3] +' li').length);
            var thisWidth = jQuery(this).width();
            if(thisWidth > widest) {
                widest = thisWidth;
            }
            if(count<cols[quest][2])
            { width = parseInt( %POLL-WIDTH% / cols[quest][0]);
             if(cols[quest][0]==1)
                        jQuery(".yop-poll-li-answer-%POLL-ID%-"+cols[quest][3]).css("width","100%");
             else
                         jQuery(".yop-poll-li-answer-%POLL-ID%-"+cols[quest][3]).width(width-20);
             jQuery(".yop-poll-li-answer-%POLL-ID%-"+cols[quest][3]).css("float", "left");
            }
            else
            {
                count=0;


                width = parseInt( %POLL-WIDTH% / cols[quest][0]);
                jQuery(".yop-poll-li-answer-%POLL-ID%-"+cols[quest][3]).width(width-20);
                jQuery(".yop-poll-li-answer-%POLL-ID%-"+cols[quest][3]).css("float", "left");
                quest++;
            }

        });
}
}

function equalWidth2_%POLL-ID%(obj, cols, findWidest ) {
    findWidest  = typeof findWidest  !== "undefined" ? findWidest  : false;
    var quest=0;

    if ( findWidest ) {
        obj.each(function() {
            var thisWidth = jQuery(this).width();
            width = parseInt(thisWidth / cols);
            jQuery(this).width(width);
            jQuery(this).css("float", "left");
        });
    }
    else {
        var widest = 0;
        var count  = 0;
        var poz_each_question=0;

        obj.each(function() {
            count++;
            cols[quest][2]=(jQuery('#yop-poll-answers-%POLL-ID%-'+ cols[quest][3] +' li').length);
            var thisWidth = jQuery(this).width();
            if(thisWidth > widest) {
                widest = thisWidth;
            }
            if(count<cols[quest][2])
            { width = parseInt( %POLL-WIDTH% / cols[quest][1]);
             jQuery(".yop-poll-li-result-%POLL-ID%-"+cols[quest][3]).width(width-20);
             jQuery(".yop-poll-li-result-%POLL-ID%-"+cols[quest][3]).css("float", "left");
            }
            else
            {
                count=0;


                width = parseInt( %POLL-WIDTH% / cols[quest][1]);
                jQuery(".yop-poll-li-result-%POLL-ID%-"+cols[quest][3]).width(width-20);
                jQuery(".yop-poll-li-result-%POLL-ID%-"+cols[quest][3]).css("float", "left");
                quest++;
            }

        });
}
}
function tabulate_answers_%POLL-ID%() {

\tequalWidth_%POLL-ID%( jQuery("#yop-poll-container-%POLL-ID% .yop-poll-li-answer-%POLL-ID%"), %ANSWERS-TABULATED-COLS% );
\t//equalWidth_%POLL-ID%( jQuery("#yop-poll-container-%POLL-ID% .yop-poll-li-answer-%POLL-ID% .yop-poll-results-bar-%POLL-ID% div "), %ANSWERS-TABULATED-COLS%, true );
}

function tabulate_results_%POLL-ID%() {
\tequalWidth2_%POLL-ID%( jQuery("#yop-poll-container-%POLL-ID% .yop-poll-li-result-%POLL-ID%"), %RESULTS-TABULATED-COLS% );
\t//equalWidth_%POLL-ID%( jQuery("#yop-poll-container-%POLL-ID% .yop-poll-li-result-%POLL-ID% .yop-poll-results-bar-%POLL-ID% div "), %RESULTS-TABULATED-COLS%, true );
\t}

jQuery(document).ready(function(){
\trunOnPollStateChange_%POLL-ID%();
});

function runOnPollStateChange_%POLL-ID%() {

};

NOWDOC;
            $template['js'] = addslashes($template['js']);
            $templates_ids[$template['id']] = self::insert_template_in_databease($template);
        }
        foreach ($polls as $poll) {
            foreach ($answers as $answer) {
                if ($answer['poll_id'] == $poll['id']) {
                    $answers_ordonate[$poll['id']][] = (array) $answer;
                }
                if ($answer['poll_id'] > $poll['id']) {
                    break;
                }
                foreach ($logs as $log) {
                    if ($log['poll_id'] == $poll['id'] && $log['answer_id'] == $answer['id']) {
                        $logs_ordonate[$poll['id']][] = (array) $log;
                        $logs_ordonate_details[$log['id']][] = $answer['answer'];
                    }
                }
                foreach ($answers_meta as $answer_meta) {
                    if ($answer_meta['yop_poll_answer_id'] == $answer['id']) {
                        $answer_meta_ordonate[$answer['id']][] = (array) $answer_meta;
                    }
                }
            }
            foreach ($bans as $ban) {
                if ($ban['poll_id'] == $poll['id']) {
                    $bans_ordonate[$poll['id']][] = (array) $ban;
                }
                if ($ban['poll_id'] > $poll['id']) {
                    break;
                }
            }
            foreach ($metas as $meta) {
                if ($meta['yop_poll_id'] == $poll['id']) {
                    $metas_ordonate[$poll['id']][] = (array) $meta;
                }
                if ($meta['yop_poll_id'] > $poll['id']) {
                    break;
                }
            }
            foreach ($custom_fields as $custom_field) {
                if ($custom_field['poll_id'] == $poll['id']) {
                    $custom_fields_ordonate[$poll['id']][] = (array) $custom_field;
                    if ($custom_field['poll_id'] > $poll['id']) {
                        break;
                    }
                    foreach ($custom_votes as $custom_vote) {
                        if ($custom_field['id'] == $custom_vote['custom_field_id']) {
                            $custom_votes_fields_ordonate[$custom_field['id']][] = (array) $custom_vote;
                        }
                    }
                }
            }
        }
        foreach ($polls as $poll) {
            $current_poll = new YOP_POLL_Poll_Model();
            $current_poll->poll_author = $poll['poll_author'];
            $current_poll->ID = $poll['id'];
            $current_poll->poll_title = $poll['name'];
            $current_poll->poll_name = $poll['name'];
            $current_poll->poll_date = $poll['date_added'];
            $current_poll->poll_modified = $poll['last_modified'];
            $current_poll->poll_status = $poll['status'];
            $current_poll->poll_type = "poll";
            $current_poll->poll_status = $poll['status'];
            $current_poll->email_notifications_body = '<p>A new vote was registered on %VOTE_DATE% for %POLL_NAME%</p>

                                                            <p>Vote Details:</p>

                [QUESTION]

                                                            <p><b>Question:</b> %QUESTION_TEXT%</p>

                                                            <p><b>Answers:</b> <br />

                                                            [ANSWERS]

                                                            %ANSWER_VALUE%

                                                            [/ANSWERS]

                                                            </p>

                                                            <p><b>Custom Fields:</b> <br />

                                                            [CUSTOM_FIELDS]

                                                            %CUSTOM_FIELD_NAME% - %CUSTOM_FIELD_VALUE%

                                                            [/CUSTOM_FIELDS]

                                                            </p>

                [/QUESTION]

                                                            <p><b>Vote ID:</b> <br />%VOTE_ID%</p>';
            if ($poll['end_date'] <= "2038-01-18 23:59:59") {
                $current_poll->poll_end_date = convert_date($poll['end_date'], 'd-m-Y H:i:s', 1);
            } else {
                $current_poll->poll_end_date = "01-01-2038 23:59:59";
            }
            if ($poll['start_date'] <= "2038-01-18 23:59:59") {
                $current_poll->poll_start_date = convert_date($poll['start_date'], 'd-m-Y H:i:s', 1);
            } else {
                $current_poll->poll_start_date = "01-01-2038 23:59:59";
            }
            $current_poll->poll_total_votes = $poll['total_votes'];
            $question = new YOP_POLL_Question_Model();
            $question->type = "text";
            $question->question = $poll['question'];
            $question->question_date = $current_poll->poll_date;
            $question->question_author = $current_poll->poll_author;
            $question->question_modified = $current_poll->poll_modified;
            $question->question_status = $current_poll->poll_status;
            $question->poll_order = 1;
            $i = 0;
            foreach ($answers_ordonate[$poll['id']] as $answer_ordonate) {
                if ($answer_ordonate['type'] == "other") {
                    $current_poll->allow_other_answers = 'yes';
                    $question->allow_other_answers = 'yes';
                }
            }
            $q[] = $question;
            // yop_poll_dump($current_poll);
            $current_poll->questions = $q;
            $current_poll->auto_generate_poll_page = "no";
            $current_poll_id = $current_poll->insert();
            $current_poll_id = $current_poll->ID;
            // yop_poll_dump($current_poll->save())
            $no_modif = 0;
            $no_modif2 = 0;
            $current_poll_meta = $current_options;
            if (isset($metas_ordonate[$poll['id']])) {
                $poll_option = maybe_unserialize($metas_ordonate[$poll['id']][0]['meta_value']);
                foreach ($current_options as $key => $value) {
                    if (isset($poll_option[$key])) {
                        if ($key == 'view_results_permissions') {
                            list($g1, $d) = explode('-', $poll_option[$key]);
                            if ($g1 == "quest") {
                                $g1 = "guest";
                            }
                            $current_poll_meta[$key] = array($g1, $d);
                            $no_modif = 1;
                        } else {
                            if ($key == 'vote_permisions') {
                                list($g1, $d) = explode('-', $poll_option['vote_permisions']);
                                if ($g1 == "quest") {
                                    $g1 = "guest";
                                }
                                $no_modif2 = 1;
                                $current_poll_meta[$key] = array($g1, $d);
                            } else {
                                $current_poll_meta[$key] = $poll_option[$key];
                            }
                        }
                    } else {
                        $current_poll_meta[$key] = $default[$key];
                    }
                }
            }
            $current_poll_meta['view_results'] = array($poll_option['view_results']);
            $current_poll_meta['sorting_results'] = $default['sorting_answers'];
            if (!isset($poll_option['view_results_link'])) {
                $current_poll_meta['view_results_link'] = "yes";
            } else {
                $current_poll_meta['view_results_link'] = $poll_option['view_results_link'];
            }
            if ($poll_option['view_results'] == 'custom-date') {
                $current_poll_meta['view_results_start_date'] = $poll_option['view_results_start_date'];
            }
            if (empty($current_poll_meta['view_results'][0])) {
                $current_poll_meta['view_results'] = array('after');
            }
            if ($no_modif == 0 || empty($current_poll_meta['view_results'])) {
                $current_poll_meta['view_results_permissions'] = array('guest', 'registered');
            }
            if ($no_modif2 == 0 || empty($current_poll_meta['vote_permisions'])) {
                $current_poll_meta['vote_permisions'] = array('guest', 'registered');
            }
            if ($poll_option['blocking_voters'] == 'cookie-ip') {
                $current_poll_meta['blocking_voters'] = array("cookie", 'ip');
            } else {
                if ($poll_option['blocking_voters'] == 'username') {
                    $current_poll_meta['blocking_voters'] = array("user_id");
                } else {
                    $current_poll_meta['blocking_voters'] = array('dont-block');
                }
            }
            $current_poll_meta['facebook_share_after_vote'] = "no";
            $current_poll_meta['show_google_share_button'] = "no";
            $current_poll_meta['facebook_show_comments_widget'] = "no";
            $current_poll_meta['facebook_share_description'] = __yop_poll('Just casted an YOP Poll vote on ') . get_bloginfo('name');
            if (isset($poll_option['show_in_archive'])) {
                $current_poll_meta['show_poll_in_archive'] = $poll_option['show_in_archive'];
            }
            if (isset($poll_option['schedule_reset_poll_date'])) {
                $current_poll_meta['schedule_reset_poll_date'] = $poll_option['schedule_reset_poll_date'];
            }
            if (isset($poll_option['template'])) {
                $current_poll_meta['template'] = $templates_ids[$poll_option['template']];
            } else {
                $current_poll_meta['template'] = 1;
            }
            if (isset($poll_option['widget_template'])) {
                $current_poll_meta['widget_template'] = $templates_ids[$poll_option['widget_template']];
            } else {
                $current_poll_meta['widget_template'] = 1;
            }
            if (isset($poll_option['widget_template']) && isset($poll_option['template']) && $poll_option['template'] != $poll_option['widget_template']) {
                $current_poll_meta['use_the_same_template_for_widget'] = "no";
            }
            if (isset($poll_option['view_total_answers_label'])) {
                $current_poll_meta['view_total_answers_label'] = $default['view_total_answers_label'];
            }
            if (isset($poll_option['answer_result_label'])) {
                $current_poll_meta['answer_result_label'] = $default['answer_result_label'];
            }
            if ($current_poll_meta['vote_permisions_anonymous'] == "no" && $current_poll_meta['vote_permisions_wordpress'] == "no") {
                $current_poll_meta['vote_permisions_anonymous'] = "yes";
            }
            update_yop_poll_question_meta($current_poll_id, 'options', $current_poll_meta);
            update_yop_poll_meta($current_poll_id, 'options', $current_poll_meta);
            if ($poll['show_in_archive'] == "yes") {
                self::save_poll_order($current_poll_id, $poll['archive_order']);
            }
            if ($default['sorting_answers'] == "votes") {
                $answers_ordonate[$poll['id']] = self::get_answers_order_by_votes($poll['id'], $default['sorting_answers_direction']);
            }
            if ($default['sorting_answers'] == "alphabetical") {
                $answers_ordonate[$poll['id']] = self::get_answers_order_by_alph($poll['id'], $default['sorting_answers_direction']);
            }
            foreach ($answers_ordonate[$poll['id']] as $answer_ordonate) {
                $ans = new YOP_POLL_Answer_Model();
                $ans->answer = $answer_ordonate['answer'];
                $ans->answer_author = $current_poll->poll_author;
                $ans->answer_date = $current_poll->poll_date;
                $ans->answer_modified = $poll['last_modified'];
                if ($answer_ordonate['type'] != "other") {
                    $ans->type = "text";
                } else {
                    $current_poll->allow_other_answers = 'yes';
                    $question->allow_other_answers = 'yes';
                    $ans->type = "other";
                }
                $ans->answer_status = $answer['status'];
                $ans->votes = $answer_ordonate['votes'];
                $ans->question_order = $i++;
                if ($answer_ordonate['type'] != "other") {
                    $answersa[] = $ans;
                    if (isset($answer_meta_ordonate[$answer_ordonate['id']])) {
                        $answer_option = maybe_unserialize($answer_meta_ordonate[$answer_ordonate['id']][0]['meta_value']);
                        $answer_options = $ans->options;
                        foreach ($ans->options as $key => &$value) {
                            if (isset($answer_option[$key])) {
                                $ans->{$key} = $answer_option[$key];
                            }
                        }
                        $ans->options = $answer_options;
                    }
                    $question->addAnswer($ans);
                    $question->save_answers();
                    $answersids[$answer_ordonate['id']] = $ans->ID;
                }
            }
            if (!empty($custom_fields_ordonate[$poll['id']])) {
                foreach ($custom_fields_ordonate[$poll['id']] as $custom_ordonate) {
                    $oldid = $custom_ordonate['id'];
                    //   $question                       = $current_poll->questions;
                    $custom_ordonate['question_id'] = $current_poll_id;
                    $custom_ordonate['poll_id'] = $current_poll_id;
                    $newid = insert_custom_field_in_db($custom_ordonate);
                    foreach ($custom_votes_fields_ordonate[$oldid] as $votes) {
                        $votes['custom_field_id'] = $newid;
                        $votes['question_id'] = $current_poll_id;
                        $votes['poll_id'] = $current_poll_id;
                        $votes['id'] = insert_votes_custom_in_db($votes);
                        $custom_field_vote[$poll['id']][] = $votes;
                    }
                }
            }
            if (!empty($logs_ordonate[$poll['id']])) {
                foreach ($logs_ordonate[$poll['id']] as $log_ordonate) {
                    $log['poll_id'] = $current_poll_id;
                    $log['vote_id'] = $log_ordonate['vote_id'];
                    $log['ip'] = $log_ordonate['ip'];
                    $log['user_id'] = $log_ordonate['user_id'];
                    $log['user_type'] = $log_ordonate['user_type'];
                    $log['vote_date'] = $log_ordonate['vote_date'];
                    $log['tr_id'] = $log_ordonate['tr_id'];
                    $vote_details[1]["q-" . $current_poll_id]['question'] = $poll['question'];
                    $vote_details[1]["q-" . $current_poll_id]['id'] = $current_poll_id;
                    $vote_details[1]["q-" . $current_poll_id]['a'][] = $answersids[$log_ordonate['answer_id']];
                    if ($log_ordonate['other_answer_value'] != "" && isset($log_ordonate['other_answer_value'])) {
                        $ans = new YOP_POLL_Answer_Model();
                        $ans->answer = $answer_ordonate['answer'];
                        $ans->answer_author = $current_poll->poll_author;
                        $ans->answer_date = $current_poll->poll_date;
                        $ans->answer_modified = $poll['last_modified'];
                        $ans->answer = $log_ordonate['other_answer_value'];
                        $ans->answer_status = 'active';
                        $ans->votes = 1;
                        $ans->type = 'other';
                        $ans->question_order = $i++;
                        $question->addAnswer($ans);
                        $question->save_answers();
                    }
                    if (!empty($custom_field_vote[$poll['id']])) {
                        foreach ($custom_field_vote[$poll['id']] as $vote) {
                            if ($vote['vote_id'] == $log_ordonate['vote_id']) {
                                $vote_details[1]["q-" . $current_poll_id]['cf'][] = $vote['id'];
                            }
                        }
                    }
                    foreach ($logs_ordonate_details[$log_ordonate['id']] as $a) {
                        $vote_details[1]["q-" . $current_poll_id]['answers'][] = $a;
                        $log['vote_details'] = json_encode($vote_details[1]);
                        $log['message'] = "Succes";
                        insert_result_in_db($log);
                        insert_log_in_db($log);
                        unset($vote_details[1]["q-" . $current_poll_id]['answers']);
                    }
                    unset($vote_details);
                }
            }
            if (!empty($bans_ordonate[$poll['id']])) {
                foreach ($bans_ordonate[$poll['id']] as $ban_ordonate) {
                    $ban = $ban_ordonate;
                    $ban['poll_id'] = $current_poll_id;
                    self::insert_ban_in_db($ban);
                }
            }
        }
    }
Пример #8
0
 private static function save_template()
 {
     $template['name'] = $_POST['yop_poll_template_name'];
     $template['before_vote_template'] = $_POST['yop-poll-before-vote-template-input'];
     $template['after_vote_template'] = $_POST['yop-poll-after-vote-template-input'];
     $template['before_start_date_template'] = $_POST['yop-poll-template-before-start-date-input'];
     $template['after_end_date_template'] = $_POST['yop-poll-template-after-end-date-input'];
     $template['css'] = $_POST['yop-poll-template-css-input'];
     $template['js'] = $_POST['yop-poll-template-js-input'];
     $template['status'] = "other";
     $template['id'] = $_POST['template_id'];
     if ($_POST['action_type'] == "add-new-template") {
         if ($template['name'] != "") {
             $result = self::get_poll_template_from_database_by_name($template['name']);
             if ($result) {
                 wp_die(__yop_poll('This template already exists! Please choose another name!'));
             }
         } else {
             wp_die(__yop_poll('Please enter a template name!'));
         }
         $result = self::insert_poll_template_to_database($template);
         if ($result) {
             wp_die(__yop_poll('Template added!'));
         } else {
             wp_die(__yop_poll('Could not add template in database! Please try again!'));
         }
     } else {
         if ($_POST['action_type'] == "edit") {
             if ($template['name'] == "") {
                 wp_die(__yop_poll('Please enter a template name!'));
             } else {
                 $result = self::update_poll_template_in_database($template);
                 if ($result) {
                     wp_die(__yop_poll('Template edited!'));
                 } else {
                     wp_die(__yop_poll('Could not edit template in database! Please try again!'));
                 }
             }
         }
     }
 }
Пример #9
0
 public function edit_ban_from_database($ban)
 {
     global $wpdb;
     $response['success'] = "";
     $response['error'] = "";
     if (check_admin_referer('yop-poll-add-edit-ban', 'yop-poll-add-edit-ban')) {
         if (current_user_can('manage_yop_polls_bans')) {
             $sql = $wpdb->query($wpdb->prepare("UPDATE  {$wpdb->yop_poll_bans} SET type = %s ,value = %s ,period= %d  ,unit=%s,poll_id = %d WHERE id = %d", $ban['type'], $ban['value'], intval($ban['period']), $ban['unit'], $ban['poll_id'], $ban['id']));
             if ($sql == "" | $sql) {
                 $response['success'] = __yop_poll('Ban edited');
                 $response['insert_id'] = __yop_poll('Ban edited');
             } else {
                 $response['error'] = __yop_poll('Could not edit ban from database! Please try again!');
             }
         } else {
             $response['error'] = __yop_poll('You do not have enough permission to edit a ban');
         }
         return $response;
     } else {
         wp_die(__yop_poll('You do not have enough permission to edit a ban'));
     }
 }
Пример #10
0
 private function view_results()
 {
     wp_enqueue_script('yop-poll-results-votes-js', YOP_POLL_URL . '/js/polls/yop-poll-results-votes.js', array('jquery', 'jquery-ui-resizable'), YOP_POLL_VERSION, true);
     //self::yop_poll_get_percentages_for_age_gender_charts();
     $index = 1;
     $data['title'] = __yop_poll("Results");
     $data['poll_id'] = isset($_GET['id']) ? intval($_GET['id']) : 0;
     $data['results_order_by'] = isset($_GET['results_order_by']) ? $_GET['results_order_by'] : 'id';
     $data['results_order'] = isset($_GET['results_order']) ? $_GET['results_order'] : 'ASC';
     $data['soav'] = isset($_GET['soav']) ? $_GET['soav'] : 'no';
     $data['a'] = isset($_GET['a']) ? $_GET['a'] : 'no';
     $current_poll = new YOP_POLL_Poll_Model($data['poll_id'], $is_view_results = "no", $question_sort = "poll_order", $question_sort_rule = "ASC", $answer_sort = $data['results_order_by'], $answer_sort_rule = $data['results_order']);
     $data['poll_details'] = array('name' => $current_poll->poll_title, 'question' => $current_poll->questions);
     if ('yes' == $data['soav']) {
         $data['display_other_answers_values'] = true;
     } else {
         $data['display_other_answers_values'] = false;
     }
     $percentages = array();
     $total_votes = array();
     $i = 0;
     foreach ($current_poll->questions as $question) {
         $total_votes[$i] = 0;
         foreach ($question->answers as $answer) {
             $total_votes[$i] += floatval($answer->votes);
         }
         $i++;
     }
     $i = 0;
     foreach ($current_poll->questions as $question) {
         foreach ($question->answers as $answer) {
             if ($answer->votes > 0) {
                 $answer->status = round($answer->votes * 100 / $total_votes[$i], 1);
             } else {
                 $percentages[$i][] = 0;
                 $answer->status = 0;
             }
         }
         $i++;
     }
     $data['cf_sdate'] = isset($_GET['cf_sdate']) ? $_GET['cf_sdate'] : '';
     $data['cf_edate'] = isset($_GET['cf_edate']) ? $_GET['cf_edate'] : '';
     $data['title'] = "Results";
     $data['custom_fields'] = array();
     foreach ($current_poll->questions as $question) {
         $data['cf_per_page'] = isset($_REQUEST['cf_per_page']) ? intval($_REQUEST['cf_per_page']) : 100;
         $data['cf_page_no'] = isset($_REQUEST['cf_page_no']) ? (int) $_REQUEST['cf_page_no'] : 1;
         $poll_custom_fields = self::get_poll_customfields($data['poll_id'], $question->ID);
         $custom_fields_logs = self::get_poll_customfields_logs($data['poll_id'], $question->ID, 'vote_id', 'asc', ($data['cf_page_no'] - 1) * $data['cf_per_page'], $data['cf_per_page'], $data['cf_sdate'], $data['cf_edate']);
         unset($column_custom_fields_ids);
         foreach ($poll_custom_fields as $custom_field) {
             $column_custom_fields_ids[] = $custom_field['ID'];
         }
         if (count($custom_fields_logs) > 0) {
             foreach ($custom_fields_logs as &$logs) {
                 foreach ($column_custom_fields_ids as $custom_field_id) {
                     $vote_log_values = array();
                     $vote_logs = explode('<#!,>', $logs['vote_log']);
                     if (count($vote_logs) > 0) {
                         foreach ($vote_logs as $vote_log) {
                             $temp = explode('<#!->', $vote_log);
                             $vote_log_values[$temp[1]] = stripslashes($temp[0]);
                         }
                     }
                 }
                 $custom_fields_logs_details[] = array('vote_id' => $logs['vote_id'], "tr_id" => $logs['tr_id'], "vote_date" => $logs['vote_date'], "custom_fields_value" => $vote_log_values, 'column_custom_fields_ids' => $column_custom_fields_ids);
             }
         }
         $data['total_custom_fields_logs'] = self::get_poll_total_customfields_logs($data['poll_id'], $question->ID, $data['cf_sdate'], $data['cf_edate']);
         $data['total_custom_fields_logs_pages'] = ceil($data['total_custom_fields_logs'] / $data['cf_per_page']);
         $data['column_custom_fields_ids'] = array();
         if (intval($data['cf_page_no']) > intval($data['total_custom_fields_logs_pages'])) {
             $data['cf_page_no'] = 1;
         }
         $data['cf_args'] = array('base' => remove_query_arg('cf_page_no', $_SERVER['REQUEST_URI']) . '%_%', 'format' => '&cf_page_no=%#%', 'total' => $data['total_custom_fields_logs_pages'], 'current' => max(1, $data['cf_page_no']), 'prev_next' => true, 'prev_text' => __yop_poll('&laquo; Previous'), 'next_text' => __yop_poll('Next &raquo;'));
         $data['cf_pagination'] = paginate_links($data['cf_args']);
         $chart_answer[$index][0][] = "Answer";
         $i = 1;
         $chart_answer[$index][0][] = "Votes";
         foreach ($question->answers as $answer) {
             if ($answer->type == "other" && $data['display_other_answers_values'] == 1 || $answer->type != "other") {
                 if ($answer->description == "") {
                     $chart_answer[$index][$i][0] = $answer->answer;
                 } else {
                     $chart_answer[$index][$i][0] = $answer->description;
                 }
                 $chart_answer[$index][$i][1] = (int) $answer->votes;
                 $i++;
             }
         }
         $question_detail[] = array('other_answer' => $question->other_answers_label, 'name' => $question->question, 'answers' => $question->answers, 'custom_fields' => self::get_poll_customfields($data['poll_id'], $question->ID), 'custom_fields_logs_details' => $custom_fields_logs_details, 'q_id' => $question->ID, 'total_custom_fields_logs' => $data['total_custom_fields_logs'], 'cf_pagination' => $data['cf_pagination']);
         //yop_poll_dump($question_detail);
         $data['questions_details'] = $question_detail;
         unset($custom_fields_logs_details);
         unset($column_custom_fields_ids);
         $index++;
     }
     wp_localize_script('yop-poll-results-votes-js', 'charts_answer', $chart_answer);
     $data['total_logs_other_answers'] = 0;
     foreach ($current_poll->questions as $question) {
         foreach ($question->answers as $other_answer) {
             if ($other_answer->type == 'other') {
                 $data['total_logs_other_answers']++;
             }
         }
     }
     $countries = self::yop_poll_get_country_date_by_ip($data['poll_id']);
     $vote_dates = self::yop_poll_get_results_vote_date_by_poll_id($data['poll_id']);
     $chart_country[0][0] = "Country";
     $i = 1;
     $chart_country[0][1] = "Voters";
     foreach ($countries as $country) {
         $chart_country[$i][0] = $country['country'];
         $chart_country[$i][1] = (int) $country['no_country'];
         $i++;
     }
     $chart_evolution[0][0] = "Date";
     $i = 1;
     $chart_evolution[0][1] = "Voters";
     foreach ($vote_dates as $vote_date) {
         $chart_evolution[$i][0] = convert_date($vote_date['v_data'], 'm-d-Y');
         $chart_evolution[$i][1] = (int) $vote_date['no_votes'];
         $i++;
     }
     if (!isset($chart_evolution[$i][0])) {
         $chart_evolution[1][0] = convert_date(yop_poll_get_mysql_curent_date(), 'm-d-Y');
     }
     if (!isset($chart_evolution[1][1])) {
         $chart_evolution[$i][1] = 0;
     }
     wp_localize_script('yop-poll-results-votes-js', 'charts_evolution', $chart_evolution);
     wp_localize_script('yop-poll-results-votes-js', 'charts_country', $chart_country);
     $this->display('results.html', $data);
 }
Пример #11
0
 private function delete_log_from_db($log_id)
 {
     global $wpdb;
     $response['success'] = "";
     $response['error'] = "";
     if (current_user_can('delete_yop_polls_logs')) {
         $sql = $wpdb->query($wpdb->prepare("\r\n\t\t\t\t\t\tDELETE FROM  {$wpdb->yop_poll_logs}\r\n\t\t\t\t\t\tWHERE id = %d", $log_id));
         if ($sql) {
             $response['success'] = __yop_poll('Log deleted');
         } else {
             $response['error'] = __yop_poll('Could not delete log from database! Please try again!');
         }
     } else {
         $response['error'] = __yop_poll('You do not have enough permission to delete a log!');
     }
     return $response;
 }
Пример #12
0
    public function captcha_replace_callback($m)
    {
        $unique_id = $this->unique_id;
        $return_string = '';
        $temp_string = '';
        if ('yes' == $this->use_captcha) {
            $sid = md5(uniqid());
            $temp_string = str_ireplace('%CAPTCHA-IMAGE%', '<img class="yop_poll_captcha_image" id="yop_poll_captcha_image_' . $this->ID . $unique_id . '" src="' . admin_url('admin-ajax.php', is_ssl() ? 'https' : 'http') . '?action=yop_poll_show_captcha&poll_id=' . $this->ID . '&sid=' . $sid . '&unique_id=' . $this->unique_id . '" />', $m[5]);
            $temp_string = str_ireplace('%CAPTCHA-INPUT%', '<input type="text" value="" name="yop_poll_captcha_input[' . $this->ID . ']" id="yop-poll-captcha-input-' . $this->ID . $unique_id . '" />', $temp_string);
            $temp_string = str_ireplace('%RELOAD-CAPTCHA-IMAGE%', '<a href="javascript:void(0)"><img src="' . YOP_POLL_URL . 'images/captcha_reload.png' . '" alt="' . __('Reload', 'yop_poll') . '" onClick="yop_poll_reloadCaptcha(' . "'" . $this->ID . "', '" . $this->unique_id . "'" . ')" /></a>', $temp_string);
            $temp_string = str_ireplace('%CAPTCHA-LABEL%', "<br>" . __yop_poll('Enter the code'), $temp_string);
            $temp_string = str_ireplace('%CAPTCHA-PLAY%', '<object type="application/x-shockwave-flash" data="' . YOP_POLL_URL . 'captcha/securimage_play.swf?bgcol=#ffffff&amp;icon_file=' . YOP_POLL_URL . 'images/captcha-audio.gif&amp;audio_file=' . urlencode(admin_url('admin-ajax.php', is_ssl() ? 'https' : 'http') . '?action=yop_poll_play_captcha&poll_id=' . $this->ID . '&unique_id=' . $this->unique_id) . '" height="30" width="30">
					<param name="movie" value="' . YOP_POLL_URL . 'captcha/securimage_play.swf?bgcol=#ffffff&amp;icon_file=' . YOP_POLL_URL . 'images/captcha-audio.gif&amp;audio_file=' . urlencode(admin_url('admin-ajax.php', is_ssl() ? 'https' : 'http') . '?action=yop_poll_play_captcha&poll_id=' . $this->ID . '&unique_id=' . $this->unique_id) . '" />
					</object>', $temp_string);
        }
        $return_string .= $temp_string;
        return $return_string;
    }
Пример #13
0
 private function view_wp_polls()
 {
     global $wpdb;
     if ($wpdb->get_var("SHOW TABLES LIKE '" . $wpdb->prefix . "pollsq'") === $wpdb->prefix . 'pollsq') {
         $data['REQUEST'] = $_REQUEST;
         $voter['poll_id'] = 7;
         $voter['user_id'] = 1;
         $voter['user_type'] = "wordpress";
         global $wpdb, $message;
         global $page, $action, $orderby, $order, $current_user;
         $orderby = empty($GLOBALS['orderby']) ? 'pollq_question' : $GLOBALS['orderby'];
         $order = empty($GLOBALS['order']) ? 'desc' : $GLOBALS['order'];
         $data['per_page'] = isset($_GET['per_page']) ? intval($_GET['per_page']) : 100;
         $data['page_no'] = isset($_REQUEST['page_no']) ? (int) $_REQUEST['page_no'] : 1;
         $order_fields = array('pollq_question', 'pollq_totalvoters');
         $data['orderby'] = empty($data['REQUEST']['orderby']) ? 'pollq_question' : $data['REQUEST']['orderby'];
         $data['order'] = empty($data['REQUEST']['order']) ? 'desc' : $data['REQUEST']['order'];
         $data['order_direction'] = $this->make_order_array($order_fields, 'asc', $orderby, 'desc' == $order ? 'asc' : 'desc');
         $data['order_sortable'] = $this->make_order_array($order_fields, 'sortable', $orderby, 'sorted');
         $data['order_direction_reverse'] = $this->make_order_array($order_fields, 'desc', $orderby, 'desc' == $order ? 'desc' : 'asc');
         $data['search'] = array('fields' => array('pollq_question'), 'value' => isset($_REQUEST['s']) ? trim($_REQUEST['s']) : '');
         $data['wp_polls'] = self::get_wp_poll_search($data['orderby'], $data['order'], $data['search'], $data['page_no'], $data['per_page']);
         foreach ($data['wp_polls'] as &$wp_poll) {
             $wp_poll['pollq_timestamp'] = date("Y-m-d H:i:s", $wp_poll['pollq_timestamp']);
             $wp_poll['pollq_expiry'] = date("Y-m-d H:i:s", $wp_poll['pollq_expiry']);
         }
         $data['total_wp_polls'] = self::count_wp_search($data['orderby'], $data['order'], $data['search']);
         $data['total_polls'] = $data['total_wp_polls'][0]['poll_no'];
         $data['message'] = array('error' => $message['error'], 'success' => $message['success']);
         if (intval($data['page_no']) > intval($data['total_polls'])) {
             $data['page_no'] = 1;
         }
         $args = array('base' => remove_query_arg('page_no', $_SERVER['REQUEST_URI']) . '%_%', 'format' => '&page_no=%#%', 'current' => max(1, $data['page_no']), 'total' => ceil($data['total_wp_polls'][0]['poll_no'] / $data['per_page']), 'prev_next' => true, 'prev_text' => __('&laquo;'), 'next_text' => __('&raquo;'));
         $data['pagination'] = paginate_links($args);
         $_SERVER['REQUEST_URI'] = remove_query_arg(array('action'), $_SERVER['REQUEST_URI']);
         $data['request']['uri'] = $_SERVER["REQUEST_URI"];
     }
     $data['title'] = __yop_poll("Import Polls from Wp-Poll");
     $this->display('imports.html', $data);
 }
Пример #14
0
<?php

include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
include_once ABSPATH . 'wp-admin/includes/plugin.php';
$plugin_slug = basename(dirname(__FILE__));
$plugin = $plugin_slug . "/" . 'yop_poll' . ".php";
$upgrader = new Plugin_Upgrader(new Plugin_Upgrader_Skin(array('title' => 'Yop Poll 2.0 Plugin', 'plugin' => $plugin_slug . '/yop_poll.php')));
$options = get_option('yop_poll_options');
$options['vote_permisions_facebook'] = "no";
$options['vote_permisions_google'] = "no";
$options['vote_permisions_facebook_label'] = __yop_poll('Vote as Facebook User');
$options['vote_permisions_google_label'] = __yop_poll('Vote as G+ User');
$options['facebook_share_description'] = __yop_poll('Just casted an YOP Poll vote on ') . get_bloginfo('name');
$options['show_google_share_button'] = "no";
$options['facebook_share_after_vote'] = "no";
$options['google_integration'] = "no";
$options['facebook_integration'] = "no";
$options['user_interface_type'] = "beginner";
$options['is_default_other_answer'] = "no";
$options['facebook_show_comments_widget'] = "no";
update_option('yop_poll_options', $options);
$upgrader->init();
if (is_plugin_active($plugin)) {
    deactivate_plugins($plugin);
}
$result = @$upgrader->run(array('package' => $download_link, 'destination' => WP_PLUGIN_DIR . "/" . $plugin_slug . "/", 'clear_destination' => false, 'abort_if_destination_exists' => false, 'clear_working' => true, 'is_multi' => true, 'hook_extra' => array()));
if (!is_wp_error($result)) {
    if (!is_plugin_active($plugin)) {
        $pro_options = get_option("yop_poll_pro");
        unset($pro_options['rand_number']);
        update_option("yop_poll_pro", $pro_options);
function insert_result_in_db($result)
{
    global $wpdb;
    $response['success'] = "";
    $response['error'] = "";
    $sql = $wpdb->query($wpdb->prepare("\r\r\n\t\t\t\tINSERT INTO {$wpdb->yop_poll_results} (\r\r\n\t\t\t\tpoll_id,\r\r\n\t\t\t\tvote_id,\r\r\n\t\t\t\tip ,\r\r\n\t\t\t\tuser_id,\r\r\n\t\t\t\tuser_type,\r\r\n\t\t\t\ttr_id,\r\r\n\t\t\t\tresult_details,\r\r\n\t\t\t\tuser_details,\r\r\n\t\t\t\tcountry,\r\r\n\t\t\t\tvote_date\r\r\n\t\t\t\t) VALUES ( %d, %s, %s, %s, %s, %s, %s, %s,%s, %s)", $result['poll_id'], $result['vote_id'], $result['ip'], $result['user_id'], $result['user_type'], $result['tr_id'], $result['vote_details'], $result['user_details'], $result['country'], isset($result['vote_date']) ? $result['vote_date'] : YOP_POLL_Poll_Model::get_mysql_curent_date()));
    if ($sql) {
        $response['success'] = __yop_poll('Votes added');
        $response['insert_id'] = $wpdb->insert_id;
    } else {
        $response['error'] = __yop_poll('Could not insert log into database!');
    }
    return $response;
}
Пример #16
0
 private static function delete_result_from_db_by_poll_id($poll_id)
 {
     global $wpdb;
     $response['success'] = "";
     $response['error'] = "";
     $sql = $wpdb->query($wpdb->prepare("\r\n\r\n\t\t\t\t\tDELETE FROM  {$wpdb->yop_poll_results}\r\n\r\n\t\t\t\t\tWHERE poll_id = %d\r\n\r\n\t\t\t\t\t", $poll_id));
     if ($sql) {
         $response['success'] = __yop_poll('Result deleted');
     } else {
         $response['error'] = __yop_poll('Could not delete result from database! Please try again!');
     }
     return $response;
 }
Пример #17
0
 public function general_options_validate($input)
 {
     $default_options = get_option('yop_poll_options', array());
     $newinput = $default_options;
     $errors = '';
     $updated = '';
     $message_delimiter = '<br>';
     if (current_user_can('manage_yop_polls_options')) {
         //<editor-fold desc="User Interface Options">
         //</editor-fold>
         //<editor-fold desc="Poll Options">
         //<editor-fold desc="Poll Start/End Date">
         if (isset($input['date_format'])) {
             if ($default_options['date_format'] != trim($input['date_format'])) {
                 $newinput['date_format'] = $input['date_format'];
                 $updated .= __yop_poll('Option "Poll  Date Format" Updated!') . $message_delimiter;
             }
         }
         if (isset($input['poll_start_date'])) {
             if ('' != $input['poll_start_date']) {
                 if ($default_options['poll_start_date'] != trim($input['poll_start_date'])) {
                     $options = get_option('yop_poll_options');
                     if ($options['date_format'] == "US") {
                         $original1 = explode(' ', $input['poll_start_date']);
                         $original = explode('-', $original1[0]);
                         $input['poll_start_date'] = $original[1] . '-' . $original[0] . '-' . $original[2] . ' ' . $original1[1];
                     }
                     $newinput['poll_start_date'] = $input['poll_start_date'];
                     $updated .= __yop_poll('Option "Poll Start Date" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['poll_start_date'] = $default_options['poll_start_date'];
             }
         } else {
             $newinput['poll_start_date'] = $default_options['poll_start_date'];
         }
         if (isset($input['poll_never_expire']) && 'yes' == $input['poll_never_expire']) {
             if ($default_options['poll_end_date'] != $input['poll_end_date']) {
                 $newinput['poll_end_date'] = "01-01-2038 23:59:59";
                 $updated .= __yop_poll('Option "Poll End Date" Updated!') . $message_delimiter;
             }
         } else {
             if (isset($input['poll_end_date'])) {
                 if ('' != $input['poll_end_date']) {
                     if ($default_options['poll_end_date'] != $input['poll_end_date']) {
                         $options = get_option('yop_poll_options');
                         if ($options['date_format'] == "US") {
                             $original1 = explode(' ', $input['poll_end_date']);
                             $original = explode('-', $original1[0]);
                             $input['poll_end_date'] = $original[1] . '-' . $original[0] . '-' . $original[2] . ' ' . $original1[1];
                         }
                         $newinput['poll_end_date'] = $input['poll_end_date'];
                         $updated .= __yop_poll('Option "Poll End Date" Updated!') . $message_delimiter;
                     }
                 } else {
                     $newinput['poll_end_date'] = $default_options['poll_end_date'];
                 }
             } else {
                 $newinput['poll_end_date'] = $default_options['poll_end_date'];
             }
         }
         //</editor-fold>
         //<editor-fold desc="View Results">
         if (isset($input['view_results'])) {
             if (count(array_intersect(array('before', 'after', 'after-poll-end-date', 'never', 'custom-date'), $input['view_results'])) > 0) {
                 if ($default_options['view_results'] != $input['view_results']) {
                     $newinput['view_results'] = $input['view_results'];
                     $updated .= __yop_poll('Option "View Results" Updated!') . $message_delimiter;
                 }
                 if (in_array('custom-date', $newinput['view_results'])) {
                     if (isset($input['view_results_start_date'])) {
                         if ($default_options['view_results_start_date'] != trim($input['view_results_start_date'])) {
                             $options = get_option('yop_poll_options');
                             if ($options['date_format'] == "US") {
                                 $original1 = explode(' ', $input['view_results_start_date']);
                                 $original = explode('-', $original1[0]);
                                 $input['view_results_start_date'] = $original[1] . '-' . $original[0] . '-' . $original[2] . ' ' . $original1[1];
                             }
                             $newinput['view_results_start_date'] = $input['view_results_start_date'];
                             $options = get_option('yop_poll_options');
                             $updated .= __yop_poll('Option "View Results Custom Date" Updated!') . $message_delimiter;
                         }
                     }
                 }
             } else {
                 $newinput['view_results'] = $default_options['view_results'];
             }
         } else {
             $newinput['view_results'] = $default_options['view_results'];
         }
         //</editor-fold>
         //<editor-fold desc="View Results Permissions">
         if (isset($input['view_results_permissions'])) {
             if (count(array_intersect(array('guest', 'registered'), $input['view_results_permissions'])) > 0) {
                 if ($default_options['view_results_permissions'] != $input['view_results_permissions']) {
                     $newinput['view_results_permissions'] = $input['view_results_permissions'];
                     $updated .= __yop_poll('Option "View Results Permissions" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['view_results_permissions'] = $default_options['view_results_permissions'];
             }
         } else {
             $newinput['view_results_permissions'] = $default_options['view_results_permissions'];
         }
         //</editor-fold>
         if (isset($input['view_results_type'])) {
             if (in_array($input['view_results_type'], array('votes-number', 'percentages', 'votes-number-and-percentages'))) {
                 if ($default_options['view_results_type'] != trim($input['view_results_type'])) {
                     $newinput['view_results_type'] = trim($input['view_results_type']);
                     $updated .= __yop_poll('Option "View Results Type" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['view_results_type'] = $default_options['view_results_type'];
             }
         } else {
             $newinput['view_results_type'] = $default_options['view_results_type'];
         }
         if (isset($input['answer_result_label'])) {
             if ('votes-number' == $input['view_results_type']) {
                 if (stripos($input['answer_result_label'], '%POLL-ANSWER-RESULT-VOTES%') === false) {
                     $newinput['answer_result_label'] = $default_options['answer_result_label'];
                 } else {
                     if ($default_options['answer_result_label'] != trim($input['answer_result_label'])) {
                         $newinput['answer_result_label'] = trim($input['answer_result_label']);
                         $updated .= __yop_poll('Option "Poll Answer Result Label" Updated!') . $message_delimiter;
                     }
                 }
             }
             if ('percentages' == $input['view_results_type']) {
                 if (stripos($input['answer_result_label'], '%POLL-ANSWER-RESULT-PERCENTAGES%') === false) {
                     $newinput['answer_result_label'] = $default_options['answer_result_label'];
                 } else {
                     if ($default_options['answer_result_label'] != trim($input['answer_result_label'])) {
                         $newinput['answer_result_label'] = trim($input['answer_result_label']);
                         $updated .= __yop_poll('Option "Poll Answer Result Label" Updated!') . $message_delimiter;
                     }
                 }
             }
             if ('votes-number-and-percentages' == $input['view_results_type']) {
                 if (stripos($input['answer_result_label'], '%POLL-ANSWER-RESULT-PERCENTAGES%') === false) {
                     $newinput['answer_result_label'] = $default_options['answer_result_label'];
                 } elseif (stripos($input['answer_result_label'], '%POLL-ANSWER-RESULT-VOTES%') === false) {
                     $newinput['answer_result_label'] = $default_options['answer_result_label'];
                 } else {
                     if ($default_options['answer_result_label'] != trim($input['answer_result_label'])) {
                         $newinput['answer_result_label'] = trim($input['answer_result_label']);
                         $updated .= __yop_poll('Option "Poll Answer Result Label" Updated!') . $message_delimiter;
                     }
                 }
             }
         } else {
             $newinput['answer_result_label'] = $default_options['answer_result_label'];
         }
         if (isset($input['vote_button_label'])) {
             if ('' != $input['vote_button_label']) {
                 if ($default_options['vote_button_label'] != trim($input['vote_button_label'])) {
                     $newinput['vote_button_label'] = trim($input['vote_button_label']);
                     $updated .= __yop_poll('Option "Vote Button Label" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['vote_button_label'] = $default_options['vote_button_label'];
             }
         } else {
             $newinput['vote_button_label'] = $default_options['vote_button_label'];
         }
         if (isset($input['view_results_link'])) {
             if (in_array($input['view_results_link'], array('yes', 'no'))) {
                 if ($default_options['view_results_link'] != trim($input['view_results_link'])) {
                     $newinput['view_results_link'] = trim($input['view_results_link']);
                     $updated .= __yop_poll('Option "View Results Link" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['view_results_link'] = $default_options['view_results_link'];
             }
         } else {
             $newinput['view_results_link'] = $default_options['view_results_link'];
         }
         if (isset($input['view_results_link_label'])) {
             if ('' != $input['view_results_link_label']) {
                 if ($default_options['view_results_link_label'] != trim($input['view_results_link_label'])) {
                     $newinput['view_results_link_label'] = trim($input['view_results_link_label']);
                     $updated .= __yop_poll('Option "View Results Link Label" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['view_results_link_label'] = $default_options['view_results_link_label'];
             }
         } else {
             $newinput['view_results_link_label'] = $default_options['view_results_link_label'];
         }
         if (isset($input['view_back_to_vote_link'])) {
             if (in_array($input['view_back_to_vote_link'], array('yes', 'no'))) {
                 if ($default_options['view_back_to_vote_link'] != trim($input['view_back_to_vote_link'])) {
                     $newinput['view_back_to_vote_link'] = trim($input['view_back_to_vote_link']);
                     $updated .= __yop_poll('Option "View Back To Vote Link" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['view_back_to_vote_link'] = $default_options['view_back_to_vote_link'];
             }
         } else {
             $newinput['view_back_to_vote_link'] = $default_options['view_back_to_vote_link'];
         }
         if (isset($input['view_back_to_vote_link_label'])) {
             if ('' != $input['view_back_to_vote_link_label']) {
                 if ($default_options['view_back_to_vote_link_label'] != trim($input['view_back_to_vote_link_label'])) {
                     $newinput['view_back_to_vote_link_label'] = trim($input['view_back_to_vote_link_label']);
                     $updated .= __yop_poll('Option "View Back to Vote Link Label" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['view_back_to_vote_link_label'] = $default_options['view_back_to_vote_link_label'];
             }
         } else {
             $newinput['view_back_to_vote_link_label'] = $default_options['view_back_to_vote_link_label'];
         }
         if (isset($input['view_total_votes'])) {
             if (in_array($input['view_total_votes'], array('yes', 'no'))) {
                 if ($default_options['view_total_votes'] != trim($input['view_total_votes'])) {
                     $newinput['view_total_votes'] = trim($input['view_total_votes']);
                     $updated .= __yop_poll('Option "View Total Votes" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['view_total_votes'] = $default_options['view_total_votes'];
             }
         } else {
             $newinput['view_total_votes'] = $default_options['view_total_votes'];
         }
         if (isset($input['view_total_votes_label'])) {
             if (stripos($input['view_total_votes_label'], '%POLL-TOTAL-VOTES%') === false) {
                 $newinput['view_total_votes_label'] = $default_options['view_total_votes_label'];
             } else {
                 if ($default_options['view_total_votes_label'] != trim($input['view_total_votes_label'])) {
                     $newinput['view_total_votes_label'] = trim($input['view_total_votes_label']);
                     $updated .= __yop_poll('Option "View Total Votes Label" Updated!') . $message_delimiter;
                 }
             }
         } else {
             $newinput['view_total_votes_label'] = $default_options['view_total_votes_label'];
         }
         if (isset($input['view_total_answers'])) {
             if (in_array($input['view_total_answers'], array('yes', 'no'))) {
                 if ($default_options['view_total_answers'] != trim($input['view_total_answers'])) {
                     $newinput['view_total_answers'] = trim($input['view_total_answers']);
                     $updated .= __yop_poll('Option "View Total Answers" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['view_total_answers'] = $default_options['view_total_answers'];
             }
         } else {
             $newinput['view_total_answers'] = $default_options['view_total_answers'];
         }
         if (isset($input['view_total_answers_label'])) {
             if (stripos($input['view_total_answers_label'], '%POLL-TOTAL-ANSWERS%') === false) {
                 $newinput['view_total_answers_label'] = $default_options['view_total_answers_label'];
             } else {
                 if ($default_options['view_total_answers_label'] != trim($input['view_total_answers_label'])) {
                     $newinput['view_total_answers_label'] = trim($input['view_total_answers_label']);
                     $updated .= __yop_poll('Option "View Total Answers Label" Updated!') . $message_delimiter;
                 }
             }
         } else {
             $newinput['view_total_answers_label'] = $default_options['view_total_answers_label'];
         }
         if (isset($input['message_after_vote'])) {
             if ($default_options['message_after_vote'] != trim($input['message_after_vote'])) {
                 $newinput['message_after_vote'] = trim($input['message_after_vote']);
                 $updated .= __yop_poll('Option "Message After Vote" Updated!') . $message_delimiter;
             }
         }
         if (isset($input['vote_permisions'])) {
             if (count(array_intersect(array('guest', 'registered'), $input['vote_permisions'])) > 0) {
                 if ($default_options['vote_permisions'] != $input['vote_permisions']) {
                     $newinput['vote_permisions'] = $input['vote_permisions'];
                     $updated .= __yop_poll('Option "Vote Permissions" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['vote_permisions'] = $default_options['vote_permisions'];
             }
         } else {
             $newinput['vote_permisions'] = $default_options['vote_permisions'];
         }
         //<editor-fold desc="Vote As Facebook">
         //</editor-fold>
         //<editor-fold desc="Vote as Wordpress">
         if (isset($input['vote_permisions_wordpress']) && in_array($input['vote_permisions_wordpress'], array('yes', 'no'))) {
             if ($default_options['vote_permisions_wordpress'] != trim($input['vote_permisions_wordpress'])) {
                 $newinput['vote_permisions_wordpress'] = trim($input['vote_permisions_wordpress']);
                 $updated .= __yop_poll('Option "Vote as Wordpress User" Updated!') . $message_delimiter;
             }
         } else {
             $newinput['vote_permisions_wordpress'] = $default_options['vote_permisions_wordpress'];
         }
         if (isset($input['vote_permisions_wordpress_label']) && '' != trim($input['vote_permisions_wordpress_label'])) {
             if ($default_options['vote_permisions_wordpress_label'] != trim($input['vote_permisions_wordpress_label'])) {
                 $newinput['vote_permisions_wordpress_label'] = trim($input['vote_permisions_wordpress_label']);
                 $updated .= __yop_poll('Option "Vote as Wordpress User Buton Label" Updated!') . $message_delimiter;
             }
         } else {
             $newinput['vote_permisions_wordpress_label'] = $default_options['vote_permisions_wordpress_label'];
         }
         //</editor-fold>
         //<editor-fold desc="Vote as Anonymous">
         if (isset($input['vote_permisions_anonymous']) && in_array($input['vote_permisions_anonymous'], array('yes', 'no'))) {
             if ($default_options['vote_permisions_anonymous'] != trim($input['vote_permisions_anonymous'])) {
                 $newinput['vote_permisions_anonymous'] = trim($input['vote_permisions_anonymous']);
                 $updated .= __yop_poll('Option "Vote as Anonymous User" Updated!') . $message_delimiter;
             }
         } else {
             $newinput['vote_permisions_anonymous'] = $default_options['vote_permisions_anonymous'];
         }
         if (isset($input['vote_permisions_anonymous_label']) && '' != trim($input['vote_permisions_anonymous_label'])) {
             if ($default_options['vote_permisions_anonymous_label'] != trim($input['vote_permisions_anonymous_label'])) {
                 $newinput['vote_permisions_anonymous_label'] = trim($input['vote_permisions_anonymous_label']);
                 $updated .= __yop_poll('Option "Vote as Anonymous User Buton Label" Updated!') . $message_delimiter;
             }
         } else {
             $newinput['vote_permisions_anonymous_label'] = $default_options['vote_permisions_anonymous_label'];
         }
         //</editor-fold>
         if (isset($input['blocking_voters'])) {
             if (count(array_intersect(array('dont-block', 'cookie', 'ip', 'user_id', 'supercookie'), $input['blocking_voters'])) > 0) {
                 if ($default_options['blocking_voters'] != $input['blocking_voters']) {
                     $newinput['blocking_voters'] = $input['blocking_voters'];
                     $updated .= __('Option "Blocking Voters" Updated!', 'yop_poll') . $message_delimiter;
                 }
                 if (!in_array('dont-block', $newinput['blocking_voters'])) {
                     // blocking_voters_interval_value
                     if (isset($input['blocking_voters_interval_value'])) {
                         if (ctype_digit($input['blocking_voters_interval_value'])) {
                             if ($default_options['blocking_voters_interval_value'] != trim($input['blocking_voters_interval_value'])) {
                                 $newinput['blocking_voters_interval_value'] = trim($input['blocking_voters_interval_value']);
                                 $updated .= __yop_poll('Option "Blocking Voters Interval Value" Updated!') . $message_delimiter;
                             }
                         } else {
                             $newinput['blocking_voters_interval_value'] = $default_options['blocking_voters_interval_value'];
                         }
                     }
                     // blocking_voters_interval_unit
                     if (isset($input['blocking_voters_interval_unit'])) {
                         if (in_array($input['blocking_voters_interval_unit'], array('seconds', 'minutes', 'hours', 'days'))) {
                             if ($default_options['blocking_voters_interval_unit'] != trim($input['blocking_voters_interval_unit'])) {
                                 $newinput['blocking_voters_interval_unit'] = trim($input['blocking_voters_interval_unit']);
                                 $updated .= __yop_poll('Option "Blocking Voters Interval Unit" Updated!') . $message_delimiter;
                             }
                         } else {
                             $newinput['blocking_voters_interval_unit'] = $default_options['blocking_voters_interval_unit'];
                         }
                     }
                 }
             } else {
                 $newinput['blocking_voters'] = $default_options['blocking_voters'];
             }
         } else {
             $newinput['blocking_voters'] = $default_options['blocking_voters'];
         }
         if (isset($input['limit_number_of_votes_per_user'])) {
             if (in_array($input['limit_number_of_votes_per_user'], array('yes', 'no'))) {
                 if ($default_options['limit_number_of_votes_per_user'] != trim($input['limit_number_of_votes_per_user'])) {
                     $newinput['limit_number_of_votes_per_user'] = trim($input['limit_number_of_votes_per_user']);
                     $updated .= __yop_poll('Option "Limit Number of Votes per User" Updated!') . $message_delimiter;
                 }
                 if ('yes' == $input['limit_number_of_votes_per_user']) {
                     if (isset($input['number_of_votes_per_user'])) {
                         if (intval($input['number_of_votes_per_user']) <= 0) {
                             $newinput['number_of_votes_per_user'] = $default_options['number_of_votes_per_user'];
                         } else {
                             if ($default_options['number_of_votes_per_user'] != $input['number_of_votes_per_user']) {
                                 $newinput['number_of_votes_per_user'] = trim($input['number_of_votes_per_user']);
                                 $updated .= __yop_poll('Option "Number of Votes per User" Updated!') . $message_delimiter;
                             }
                         }
                     } else {
                         $newinput['number_of_votes_per_user'] = $default_options['number_of_votes_per_user'];
                     }
                 }
             } else {
                 $newinput['limit_number_of_votes_per_user'] = $default_options['limit_number_of_votes_per_user'];
             }
         } else {
             $newinput['limit_number_of_votes_per_user'] = $default_options['limit_number_of_votes_per_user'];
         }
         if (isset($input['percentages_decimals']) && '' != trim($input['percentages_decimals'])) {
             if (ctype_digit($input['percentages_decimals'])) {
                 if ($default_options['percentages_decimals'] != trim($input['percentages_decimals'])) {
                     $newinput['percentages_decimals'] = trim($input['percentages_decimals']);
                     $updated .= __yop_poll('Option "Percentages Decimals" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['percentages_decimals'] = $default_options['percentages_decimals'];
             }
         } else {
             $newinput['percentages_decimals'] = $default_options['percentages_decimals'];
         }
         if (isset($input['use_default_loading_image']) && in_array($input['use_default_loading_image'], array('yes', 'no'))) {
             if ($default_options['use_default_loading_image'] != trim($input['use_default_loading_image'])) {
                 $newinput['use_default_loading_image'] = trim($input['use_default_loading_image']);
                 $updated .= __yop_poll('Option "Use Default Loading Image" Updated!') . $message_delimiter;
             }
             if ('no' == $input['use_default_loading_image']) {
                 if (isset($input['loading_image_url'])) {
                     if (stripos($input['loading_image_url'], 'http') === false) {
                         $newinput['loading_image_url'] = $default_options['loading_image_url'];
                     } else {
                         if ($default_options['loading_image_url'] != trim($input['loading_image_url'])) {
                             $newinput['loading_image_url'] = trim($input['loading_image_url']);
                             $updated .= __yop_poll('Option "Loading Image Url" Updated!') . $message_delimiter;
                         }
                     }
                 }
             }
         } else {
             $newinput['use_default_loading_image'] = $default_options['use_default_loading_image'];
         }
         if (isset($input['redirect_after_vote'])) {
             if (in_array($input['redirect_after_vote'], array('yes', 'no'))) {
                 if ($default_options['redirect_after_vote'] != trim($input['redirect_after_vote'])) {
                     $newinput['redirect_after_vote'] = trim($input['redirect_after_vote']);
                     $updated .= __yop_poll('Option "Redirect After Vote" Updated!') . $message_delimiter;
                 }
                 if ('yes' == $input['redirect_after_vote']) {
                     // archive_order
                     if (isset($input['redirect_after_vote_url']) && '' != trim($input['redirect_after_vote_url'])) {
                         if ($default_options['redirect_after_vote_url'] != trim($input['redirect_after_vote_url'])) {
                             $newinput['redirect_after_vote_url'] = trim($input['redirect_after_vote_url']);
                             $updated .= __yop_poll('Option "Redirect After Vote Url" Updated!') . $message_delimiter;
                         }
                     } else {
                         $newinput['redirect_after_vote_url'] = $default_options['redirect_after_vote_url'];
                     }
                 }
             } else {
                 $newinput['redirect_after_vote'] = $default_options['redirect_after_vote'];
             }
         } else {
             $newinput['redirect_after_vote'] = $default_options['redirect_after_vote'];
         }
         if (isset($input['date_format']) && '' != trim($input['date_format'])) {
             if ($default_options['date_format'] != trim($input['date_format'])) {
                 $newinput['date_format'] = trim($input['date_format']);
                 $updated .= __yop_poll('Option "Poll Date Format" Updated!') . $message_delimiter;
             }
         }
         if (isset($input['view_poll_archive_link'])) {
             if (in_array($input['view_poll_archive_link'], array('yes', 'no'))) {
                 if ($default_options['view_poll_archive_link'] != trim($input['view_poll_archive_link'])) {
                     $newinput['view_poll_archive_link'] = trim($input['view_poll_archive_link']);
                     $updated .= __yop_poll('Option "View Poll Archive Link" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['view_poll_archive_link'] = $default_options['view_poll_archive_link'];
             }
         } else {
             $newinput['view_poll_archive_link'] = $default_options['view_poll_archive_link'];
         }
         if (isset($input['auto_generate_poll_page'])) {
             if (in_array($input['auto_generate_poll_page'], array('yes', 'no'))) {
                 if ($default_options['auto_generate_poll_page'] != trim($input['auto_generate_poll_page'])) {
                     $newinput['auto_generate_poll_page'] = trim($input['auto_generate_poll_page']);
                     $updated .= __yop_poll('Option "Auto Generate Poll Page" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['auto_generate_poll_page'] = $default_options['auto_generate_poll_page'];
             }
         } else {
             $newinput['auto_generate_poll_page'] = $default_options['auto_generate_poll_page'];
         }
         if (isset($input['use_captcha'])) {
             if (in_array($input['use_captcha'], array('yes', 'no'))) {
                 if ($default_options['use_captcha'] != trim($input['use_captcha'])) {
                     $newinput['use_captcha'] = trim($input['use_captcha']);
                     $updated .= __yop_poll('Option "Use CAPTCHA" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['use_captcha'] = $default_options['use_captcha'];
             }
         } else {
             $newinput['use_captcha'] = $default_options['use_captcha'];
         }
         if (isset($input['send_email_notifications'])) {
             if (in_array($input['send_email_notifications'], array('yes', 'no'))) {
                 if ($default_options['send_email_notifications'] != trim($input['send_email_notifications'])) {
                     $newinput['send_email_notifications'] = trim($input['send_email_notifications']);
                     $updated .= __('Option "Send Email Notifications" Updated!', 'yop_poll') . $message_delimiter;
                 }
             } else {
                 $newinput['send_email_notifications'] = $default_options['send_email_notifications'];
             }
         } else {
             $newinput['send_email_notifications'] = $default_options['send_email_notifications'];
         }
         //</editor-fold>
         /* Start Questions Options */
         if (isset($input['allow_other_answers'])) {
             if (in_array($input['allow_other_answers'], array('yes', 'no'))) {
                 if ($default_options['allow_other_answers'] != trim($input['allow_other_answers'])) {
                     $newinput['allow_other_answers'] = trim($input['allow_other_answers']);
                     $updated .= __yop_poll('Option "Allow Other Answer" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['allow_other_answers'] = $default_options['allow_other_answers'];
             }
             if ('yes' == $input['allow_other_answers']) {
                 // other_answers_label
                 if (isset($input['other_answers_label'])) {
                     if ($default_options['other_answers_label'] != trim($input['other_answers_label'])) {
                         $newinput['other_answers_label'] = trim($input['other_answers_label']);
                         $updated .= __yop_poll('Option "Other Answer Label" Updated!') . $message_delimiter;
                     }
                 }
                 if (isset($input['is_default_other_answer'])) {
                     if (in_array($input['is_default_other_answer'], array('yes', 'no'))) {
                         if ($default_options['is_default_other_answer'] != trim($input['is_default_other_answer'])) {
                             $newinput['is_default_other_answer'] = trim($input['is_default_other_answer']);
                             $updated .= __yop_poll('Option "Make \'Other answer\' default answer" Updated!') . $message_delimiter;
                         }
                     } else {
                         $newinput['is_default_other_answer'] = $default_options['is_default_other_answer'];
                     }
                 }
                 if (isset($input['add_other_answers_to_default_answers'])) {
                     if (in_array($input['add_other_answers_to_default_answers'], array('yes', 'no'))) {
                         if ($default_options['add_other_answers_to_default_answers'] != trim($input['add_other_answers_to_default_answers'])) {
                             $newinput['add_other_answers_to_default_answers'] = trim($input['add_other_answers_to_default_answers']);
                             $updated .= __yop_poll('Option "Add the values submitted in \'Other\' as answers" Updated!') . $message_delimiter;
                         }
                     } else {
                         $newinput['add_other_answers_to_default_answers'] = $default_options['add_other_answers_to_default_answers'];
                     }
                 }
                 if (isset($input['display_other_answers_values'])) {
                     if (in_array($input['display_other_answers_values'], array('yes', 'no'))) {
                         if ($default_options['display_other_answers_values'] != trim($input['display_other_answers_values'])) {
                             $newinput['display_other_answers_values'] = trim($input['display_other_answers_values']);
                             $updated .= __yop_poll('Option "Display Other Answers Values" Updated!') . $message_delimiter;
                         }
                     } else {
                         $newinput['display_other_answers_values'] = $default_options['display_other_answers_values'];
                     }
                 }
             }
         }
         if (isset($input['allow_multiple_answers'])) {
             if (in_array($input['allow_multiple_answers'], array('yes', 'no'))) {
                 if ($default_options['allow_multiple_answers'] != trim($input['allow_multiple_answers'])) {
                     $newinput['allow_multiple_answers'] = trim($input['allow_multiple_answers']);
                     $updated .= __yop_poll('Option "Allow Multiple Answers" Updated!') . $message_delimiter;
                 }
                 // allow_multiple_answers_number
                 if ('yes' == $input['allow_multiple_answers']) {
                     if (isset($input['allow_multiple_answers_number'])) {
                         if (ctype_digit($input['allow_multiple_answers_number'])) {
                             if ($default_options['allow_multiple_answers_number'] != trim($input['allow_multiple_answers_number'])) {
                                 $newinput['allow_multiple_answers_number'] = trim($input['allow_multiple_answers_number']);
                                 $updated .= __yop_poll('Option "Max Number of allowed answers" Updated!') . $message_delimiter;
                             }
                         } else {
                             $newinput['allow_multiple_answers_number'] = $default_options['allow_multiple_answers_number'];
                         }
                     }
                     if (isset($input['allow_multiple_answers_min_number'])) {
                         if (ctype_digit($input['allow_multiple_answers_min_number'])) {
                             if ($default_options['allow_multiple_answers_min_number'] != trim($input['allow_multiple_answers_min_number'])) {
                                 $newinput['allow_multiple_answers_min_number'] = trim($input['allow_multiple_answers_min_number']);
                                 $updated .= __yop_poll('Option "Min Number of allowed answers" Updated!') . $message_delimiter;
                             }
                         } else {
                             $newinput['allow_multiple_answers_min_number'] = $default_options['allow_multiple_answers_min_number'];
                         }
                     }
                 }
             } else {
                 $newinput['allow_multiple_answers'] = $default_options['allow_multiple_answers'];
             }
         }
         if (isset($input['display_answers'])) {
             if (in_array($input['display_answers'], array('vertical', 'orizontal', 'tabulated'))) {
                 if ($default_options['display_answers'] != trim($input['display_answers'])) {
                     $newinput['display_answers'] = trim($input['display_answers']);
                     $updated .= __yop_poll('Option "Display Answers" Updated!') . $message_delimiter;
                 }
                 if ('tabulated' == $input['display_answers']) {
                     // display_answers_tabulated_cols
                     if (isset($input['display_answers_tabulated_cols'])) {
                         if (ctype_digit($input['display_answers_tabulated_cols'])) {
                             if ($default_options['display_answers_tabulated_cols'] != trim($input['display_answers_tabulated_cols'])) {
                                 $newinput['display_answers_tabulated_cols'] = trim($input['display_answers_tabulated_cols']);
                                 $updated .= __yop_poll('Option "Columns for Tabulated Display Answers" Updated!') . $message_delimiter;
                             }
                         } else {
                             $newinput['display_answers_tabulated_cols'] = $default_options['display_answers_tabulated_cols'];
                         }
                     }
                 }
             } else {
                 $newinput['display_answers'] = $default_options['display_answers'];
             }
         }
         /* End Questions Options */
         /* Start Results Options */
         if (isset($input['sorting_results'])) {
             if (in_array($input['sorting_results'], array('as_defined', 'alphabetical', 'votes'))) {
                 if ($default_options['sorting_results'] != trim($input['sorting_results'])) {
                     $newinput['sorting_results'] = trim($input['sorting_results']);
                     $updated .= __yop_poll('Option "Sort Results" Updated!') . $message_delimiter;
                 }
                 // sorting_results_direction
                 if (isset($input['sorting_results_direction'])) {
                     if (in_array($input['sorting_results_direction'], array('asc', 'desc'))) {
                         if ($default_options['sorting_results_direction'] != trim($input['sorting_results_direction'])) {
                             $newinput['sorting_results_direction'] = trim($input['sorting_results_direction']);
                             $updated .= __yop_poll('Option "Sort Results Direction" Updated!') . $message_delimiter;
                         }
                     } else {
                         $newinput['sorting_results_direction'] = $default_options['sorting_results_direction'];
                     }
                 }
             } else {
                 $newinput['sorting_results'] = $default_options['sorting_results'];
             }
         }
         if (isset($input['singular_answer_result_votes_number_label'])) {
             if ('' != $input['singular_answer_result_votes_number_label']) {
                 if ($default_options['singular_answer_result_votes_number_label'] != trim($input['singular_answer_result_votes_number_label'])) {
                     $newinput['singular_answer_result_votes_number_label'] = trim($input['singular_answer_result_votes_number_label']);
                     $updated .= __yop_poll('Option "Poll Answer Result Votes Number Singular Label" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['singular_answer_result_votes_number_label'] = $default_options['singular_answer_result_votes_number_label'];
             }
         }
         if (isset($input['plural_answer_result_votes_number_label'])) {
             if ('' != $input['plural_answer_result_votes_number_label']) {
                 if ($default_options['plural_answer_result_votes_number_label'] != trim($input['plural_answer_result_votes_number_label'])) {
                     $newinput['plural_answer_result_votes_number_label'] = trim($input['plural_answer_result_votes_number_label']);
                     $updated .= __yop_poll('Option "Poll Answer Result Votes Number Plural Label" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['plural_answer_result_votes_number_label'] = $default_options['plural_answer_result_votes_number_label'];
             }
         }
         if (isset($input['display_results'])) {
             if (in_array($input['display_results'], array('vertical', 'orizontal', 'tabulated'))) {
                 if ($default_options['display_results'] != trim($input['display_results'])) {
                     $newinput['display_results'] = trim($input['display_results']);
                     $updated .= __yop_poll('Option "Display Results" Updated!') . $message_delimiter;
                 }
                 if ('tabulated' == $input['display_results']) {
                     // display_results_tabulated_cols
                     if (isset($input['display_results_tabulated_cols'])) {
                         if (ctype_digit($input['display_results_tabulated_cols'])) {
                             if ($default_options['display_results_tabulated_cols'] != trim($input['display_results_tabulated_cols'])) {
                                 $newinput['display_results_tabulated_cols'] = trim($input['display_results_tabulated_cols']);
                                 $updated .= __yop_poll('Option "Columns for Tabulated Display Results" Updated!') . $message_delimiter;
                             }
                         } else {
                             $newinput['display_results_tabulated_cols'] = $default_options['display_results_tabulated_cols'];
                         }
                     }
                 }
             } else {
                 $newinput['display_results'] = $default_options['display_results'];
             }
         }
         /* Start Poll bar style*/
         if (isset($input['bar_background'])) {
             if (ctype_alnum($input['bar_background'])) {
                 if ($default_options['bar_background'] != trim($input['bar_background'])) {
                     $newinput['bar_background'] = trim($input['bar_background']);
                     $updated .= __yop_poll('Option "Result Bar Background Color" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['bar_background'] = $default_options['bar_background'];
             }
         }
         if (isset($input['bar_height'])) {
             if (ctype_digit($input['bar_height'])) {
                 if ($default_options['bar_height'] != trim($input['bar_height'])) {
                     $newinput['bar_height'] = trim($input['bar_height']);
                     $updated .= __yop_poll('Option "Result Bar Height" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['bar_height'] = $default_options['bar_height'];
             }
         }
         if (isset($input['bar_border_color'])) {
             if (ctype_alnum($input['bar_border_color'])) {
                 if ($default_options['bar_border_color'] != trim($input['bar_border_color'])) {
                     $newinput['bar_border_color'] = trim($input['bar_border_color']);
                     $updated .= __yop_poll('Option "Result Bar Border Color" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['bar_border_color'] = $default_options['bar_border_color'];
             }
         }
         if (isset($input['bar_border_width'])) {
             if (ctype_digit($input['bar_border_width'])) {
                 if ($default_options['bar_border_width'] != trim($input['bar_border_width'])) {
                     $newinput['bar_border_width'] = trim($input['bar_border_width']);
                     $updated .= __yop_poll('Option "Result Bar Border Width" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['bar_border_width'] = $default_options['bar_border_width'];
             }
         }
         if (isset($input['bar_border_style'])) {
             if (ctype_alpha($input['bar_border_style'])) {
                 if ($default_options['bar_border_style'] != trim($input['bar_border_style'])) {
                     $newinput['bar_border_style'] = trim($input['bar_border_style']);
                     $updated .= __yop_poll('Option "Result Bar Border Style" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['bar_border_style'] = $default_options['bar_border_style'];
             }
         }
         /* End Poll bar style*/
         /* End Results Options */
         /* Start Archive Options */
         if (isset($input['sorting_archive_polls'])) {
             if (in_array($input['sorting_archive_polls'], array('as_defined', 'database', 'votes'))) {
                 if ($default_options['sorting_archive_polls'] != trim($input['sorting_archive_polls'])) {
                     $newinput['sorting_archive_polls'] = trim($input['sorting_archive_polls']);
                     $updated .= __yop_poll('Option "Sort Archive Polls!" Updated') . $message_delimiter;
                 }
                 if ('as_defined' != trim($input['sorting_archive_polls'])) {
                     if (isset($input['sorting_archive_polls_rule'])) {
                         if ($default_options['sorting_archive_polls_rule'] != trim($input['sorting_archive_polls_rule'])) {
                             $newinput['sorting_archive_polls_rule'] = trim($input['sorting_archive_polls_rule']);
                             $updated .= __yop_poll('Option "Sort Archive Polls Rule!" Updated') . $message_delimiter;
                         }
                     } else {
                         $newinput = $default_options['sorting_archive_polls_rule'];
                     }
                 }
             } else {
                 $newinput['sorting_archive_polls'] = $default_options['sorting_archive_polls'];
             }
         }
         if (isset($input['yop_poll_archive_page_id'])) {
             if ('' != $input['yop_poll_archive_page_id']) {
                 if ($default_options['yop_poll_archive_page_id'] != trim($input['yop_poll_archive_page_id'])) {
                     $newinput['yop_poll_archive_page_id'] = trim($input['yop_poll_archive_page_id']);
                     $updated .= __yop_poll('Option "Archive Page" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['yop_poll_archive_page_id'] = $default_options['yop_poll_archive_page_id'];
             }
         }
         if (isset($input['archive_link_label'])) {
             if ('' != $input['archive_link_label']) {
                 if ($default_options['archive_link_label'] != trim($input['archive_link_label'])) {
                     $newinput['archive_link_label'] = trim($input['archive_link_label']);
                     $updated .= __yop_poll('Option "Poll Archive Link Label" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['archive_link_label'] = $default_options['archive_link_label'];
             }
         }
         if (isset($input['archive_polls_per_page'])) {
             if (false != intval(trim($input['archive_polls_per_page']))) {
                 if ($default_options['archive_polls_per_page'] != intval(trim($input['archive_polls_per_page']))) {
                     $newinput['archive_polls_per_page'] = intval(trim($input['archive_polls_per_page']));
                     $updated .= __yop_poll('Option "Polls Per Page" Updated') . $message_delimiter;
                 }
             } else {
                 $newinput['archive_polls_per_page'] = $default_options['archive_polls_per_page'];
             }
         }
         /* End Archive Options */
         /* Start Email Options */
         if (isset($input['email_notifications_from_name'])) {
             if ('' != $input['email_notifications_from_name']) {
                 if ($default_options['email_notifications_from_name'] != trim($input['email_notifications_from_name'])) {
                     $newinput['email_notifications_from_name'] = trim($input['email_notifications_from_name']);
                     $updated .= __yop_poll('Option "Notifications From Name" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['email_notifications_from_name'] = $default_options['email_notifications_from_name'];
             }
         }
         if (isset($input['email_notifications_from_email'])) {
             if ('' != $input['email_notifications_from_email']) {
                 if ($default_options['email_notifications_from_email'] != trim($input['email_notifications_from_email'])) {
                     $newinput['email_notifications_from_email'] = trim($input['email_notifications_from_email']);
                     $updated .= __yop_poll('Option "Notifications From Email" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['email_notifications_from_email'] = $default_options['email_notifications_from_email'];
             }
         }
         if (isset($input['email_notifications_recipients'])) {
             if ('' != $input['email_notifications_recipients']) {
                 if ($default_options['email_notifications_recipients'] != trim($input['email_notifications_recipients'])) {
                     $newinput['email_notifications_recipients'] = trim($input['email_notifications_recipients']);
                     $updated .= __yop_poll('Option "Email Notifications Recipients" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['email_notifications_recipients'] = $default_options['email_notifications_recipients'];
             }
         }
         if (isset($input['email_notifications_subject'])) {
             if ('' != $input['email_notifications_subject']) {
                 if ($default_options['email_notifications_subject'] != trim($input['email_notifications_subject'])) {
                     $newinput['email_notifications_subject'] = trim($input['email_notifications_subject']);
                     $updated .= __yop_poll('Option "Email Notifications Subject" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['email_notifications_subject'] = $default_options['email_notifications_subject'];
             }
         }
         if (isset($input['email_notifications_body'])) {
             if ('' != $input['email_notifications_body']) {
                 if ($default_options['email_notifications_body'] != trim($input['email_notifications_body'])) {
                     $newinput['email_notifications_body'] = trim($input['email_notifications_body']);
                     $updated .= __yop_poll('Option "Email Notifications Body" Updated!') . $message_delimiter;
                 }
             } else {
                 $newinput['email_notifications_body'] = $default_options['email_notifications_body'];
             }
         }
         /* End Email Options */
     } else {
         $errors .= __yop_poll('Bad Request!') . $message_delimiter;
     }
     if ('' != $errors) {
         add_settings_error('general', 'yop-poll-errors', $errors, 'error');
     }
     if ('' != $updated) {
         add_settings_error('general', 'yop-poll-updates', "Changes saved!", 'updated');
     }
     return $newinput;
 }