YOP Poll - Version 1.6

Version Description

  • Added ability to change the text for Vote button
  • Added ability to display the answers for Others field
Download this release

Release Info

Developer yourownprogrammer
Plugin Icon 128x128 YOP Poll
Version 1.6
Comparing to
See all releases

Code changes from version 1.5 to 1.6

inc/admin.php CHANGED
@@ -7,7 +7,42 @@
7
  register_activation_hook( $this->_config->plugin_file, array( $this, 'activate' ) );
8
  register_deactivation_hook( $this->_config->plugin_file, array( $this, 'deactivate' ) );
9
  register_uninstall_hook( $this->_config->plugin_file, 'yop_poll_uninstall' );
10
- $this->add_action('admin_enqueue_scripts', 'load_editor_functions');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  }
12
 
13
  public function admin_loader() {
@@ -51,7 +86,7 @@
51
  }
52
  else {
53
  if ( ! extension_loaded('json') ) {
54
- $error = new WP_Error( 'Wordpress_json_error', sprintf( __( 'You need the json php extension for this plugin', 'yop_poll' ), YOP_POLL_WP_VERSION ), __( 'Error: Wordpress Extension Problem', 'yop_poll' ) );
55
 
56
  // die & print error message & code - for admins only!
57
  if ( isset( $error ) && is_wp_error( $error ) && current_user_can( 'manage_options' ) )
@@ -237,7 +272,7 @@
237
  wp_enqueue_style( 'yop-poll-admin-add-new', "{$this->_config->plugin_url}/css/yop-poll-admin-add-new.css", array(), $this->_config->version );
238
  wp_enqueue_style( 'yop-poll-timepicker', "{$this->_config->plugin_url}/css/timepicker.css", array(), $this->_config->version );
239
  wp_enqueue_style( 'yop-poll-jquery-ui', "{$this->_config->plugin_url}/css/jquery-ui.css", array(), $this->_config->version );
240
-
241
  wp_enqueue_script( 'yop-poll-admin-add-new', "{$this->_config->plugin_url}/js/yop-poll-admin-add-new.js", array( 'jquery', 'yop-poll-jquery-ui-timepicker' ), $this->_config->version );
242
  wp_enqueue_script( 'yop-poll-jquery-ui-timepicker', "{$this->_config->plugin_url}/js/jquery-ui-timepicker-addon.js",array( 'jquery-ui-datepicker', 'jquery-ui-slider' ), $this->_config->version);
243
  wp_localize_script( 'yop-poll-admin-add-new', 'yop_poll_add_new_config', $yop_poll_add_new_config );
@@ -2109,6 +2144,21 @@
2109
  $newinput['other_answers_label'] = $default_options['other_answers_label'] ;
2110
  $errors .= __( 'Option "Allow Other Answer Label" Not Updated! The field must not be empty!', 'yop_poll' ).$message_delimiter;
2111
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2112
  }
2113
  }
2114
  else {
@@ -2514,6 +2564,55 @@
2514
  $newinput['answer_result_label'] = $default_options['answer_result_label'];
2515
  $errors .= __( 'Option "Poll Answer Result Label" Not Updated!', 'yop_poll' ).$message_delimiter;
2516
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2517
 
2518
  //view_results_link
2519
  if ( isset( $input['view_results_link'] ) ) {
@@ -2716,6 +2815,22 @@
2716
  $newinput['blocking_voters'] = $default_options['blocking_voters'];
2717
  $errors .= __( 'Option "Blocking Voters" Not Updated!', 'yop_poll' ).$message_delimiter;
2718
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2719
 
2720
  //view_poll_archive_link
2721
  if ( isset( $input['view_poll_archive_link'] ) ) {
@@ -2861,10 +2976,19 @@
2861
  <?php _e( 'Other Answer Label', 'yop_poll' ); ?>:
2862
  </th>
2863
  <td>
2864
- <input id="yop-poll-other-answers-label" type="text" name="yop_poll_options[other_answers_label]" value="<?php echo isset( $other_answer[0]['answer'] ) ? $other_answer[0]['answer'] : $default_options['other_answers_label'] ?>" />
2865
  <input type="hidden" name="yop_poll_options[other_answers_id]" value="<?php echo isset( $other_answer[0]['id'] ) ? $other_answer[0]['id'] : '' ?>" />
2866
  </td>
2867
  </tr>
 
 
 
 
 
 
 
 
 
2868
  <tr>
2869
  <th>
2870
  <?php _e( 'Allow Multiple Answers ', 'yop_poll' ); ?>:
@@ -3029,7 +3153,7 @@
3029
  </td>
3030
  </tr>
3031
  <tr>
3032
- <th><?php _e( 'Sorting Results in', 'yop_poll' ); ?>:</th>
3033
  <td valign="top">
3034
  <label for="yop_poll_sorting_results_exact"><input id="yop_poll_sorting_results_exact" <?php echo $default_options['sorting_results'] == 'exact' ? 'checked="checked"' : ''; ?> type="radio" name="yop_poll_options[sorting_results]" value="exact" > <?php _e( 'Exact Order', 'yop_poll' ); ?></label>
3035
  <label for="yop_poll_sorting_results_alphabetical"><input id="yop_poll_sorting_results_alphabetical" <?php echo $default_options['sorting_results'] == 'alphabetical' ? 'checked="checked"' : ''; ?> type="radio" name="yop_poll_options[sorting_results]" value="alphabetical" > <?php _e( 'Alphabetical Order', 'yop_poll' ); ?></label>
@@ -3113,9 +3237,29 @@
3113
  <?php _e( 'Poll Answer Result Label', 'yop_poll'); ?>:
3114
  </th>
3115
  <td>
3116
- <input id="yop-poll-answer-result-label" type="text" name="yop_poll_options[answer_result_label]" value="<?php echo $default_options['answer_result_label']; ?>" /> <small><i>Use %POLL-ANSWER-RESULT-PERCENTAGES% for showing answer percentages and %POLL-ANSWER-RESULT-VOTES% for showing answer number of votes</i></small>
3117
  </td>
3118
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3119
  <tr>
3120
  <th>
3121
  <?php _e( 'View Results Link', 'yop_poll' ); ?>:
@@ -3130,7 +3274,7 @@
3130
  <?php _e( 'View Results Link Label', 'yop_poll' ); ?>:
3131
  </th>
3132
  <td>
3133
- <input id="yop-poll-view-results-link-label" type="text" name="yop_poll_options[view_results_link_label]" value="<?php echo $default_options['view_results_link_label']; ?>" />
3134
  </td>
3135
  </tr>
3136
  <tr>
@@ -3147,7 +3291,7 @@
3147
  <?php _e( 'View Back To Vote Link Label', 'yop_poll' ); ?>:
3148
  </th>
3149
  <td>
3150
- <input id="yop-poll-view-back-to-vote-link-label" type="text" name="yop_poll_options[view_back_to_vote_link_label]" value="<?php echo $default_options['view_back_to_vote_link_label']; ?>" />
3151
  </td>
3152
  </tr>
3153
  <tr>
@@ -3164,7 +3308,7 @@
3164
  <?php _e( 'View Total Votes Label', 'yop_poll' ); ?>:
3165
  </th>
3166
  <td>
3167
- <input id="yop-poll-view-total-votes-label" type="text" name="yop_poll_options[view_total_votes_label]" value="<?php echo $default_options['view_total_votes_label']; ?>" />
3168
  </td>
3169
  </tr>
3170
  <tr>
@@ -3181,7 +3325,7 @@
3181
  <?php _e( 'View Total Voters Label', 'yop_poll' ); ?>:
3182
  </th>
3183
  <td>
3184
- <input id="yop-poll-view-total-voters-label" type="text" name="yop_poll_options[view_total_voters_label]" value="<?php echo $default_options['view_total_voters_label']; ?>" />
3185
  </td>
3186
  </tr>
3187
  <tr>
@@ -3189,7 +3333,7 @@
3189
  <label for="yop-poll-page-url"><?php _e( 'Poll Page Url ', 'yop_poll' ); ?>:</label>
3190
  </th>
3191
  <td>
3192
- <input id="yop-poll-page-url" type="text" name="yop_poll_options[poll_page_url]" value="<?php echo $default_options['poll_page_url']; ?>" />
3193
  </td>
3194
  </tr>
3195
  </tbody>
@@ -3238,6 +3382,14 @@
3238
  </select>
3239
  </td>
3240
  </tr>
 
 
 
 
 
 
 
 
3241
  </tbody>
3242
  </table>
3243
  </div>
@@ -3262,7 +3414,7 @@
3262
  <?php _e( 'View Poll Archive Link Label', 'yop_poll' ); ?>:
3263
  </th>
3264
  <td>
3265
- <input id="yop-poll-view-poll-archive-link-label" type="text" name="yop_poll_options[view_poll_archive_link_label]" value="<?php echo $default_options['view_poll_archive_link_label']; ?>" />
3266
  </td>
3267
  </tr>
3268
  <tr id="yop-poll-view-poll-archive-link-div" style="<?php echo 'yes' != $default_options['view_poll_archive_link'] ? 'display: none;' : ''; ?>">
@@ -3270,7 +3422,7 @@
3270
  <?php _e( 'Poll Archive Url', 'yop_poll' ); ?>:
3271
  </th>
3272
  <td>
3273
- <input id="yop-poll-poll-archive-url" type="text" name="yop_poll_options[poll_archive_url]" value="<?php echo $default_options['poll_archive_url']; ?>" />
3274
  </td>
3275
  </tr>
3276
  <tr>
@@ -3290,6 +3442,14 @@
3290
  <input id="yop-poll-show-in-archive-order" type="text" name="yop_poll_options[archive_order]" value="<?php echo $default_options['archive_order']; ?>" />
3291
  </td>
3292
  </tr>
 
 
 
 
 
 
 
 
3293
  </table>
3294
  </div>
3295
  </div>
@@ -3395,7 +3555,7 @@
3395
  <th scope="row"><label class="yop_poll_answer_label" for="yop-poll-answer<?php echo $answer_id ?>"><?php echo $yop_poll_add_new_config['text_answer']; ?> <?php echo $answer_id ?></label></th>
3396
  <td>
3397
  <input type="hidden" value="<?php echo isset( $answers[ $answer_id - 1 ]['id'] )? $answers[ $answer_id - 1 ]['id'] : ''; ?>" name="yop_poll_answer_ids[answer<?php echo $answer_id ?>]" />
3398
- <input type="text" value="<?php echo isset( $answers[ $answer_id - 1 ]['answer'] )? $answers[ $answer_id - 1 ]['answer'] : ''; ?>" id="yop-poll-answer<?php echo $answer_id ?>" name="yop_poll_answer[answer<?php echo $answer_id ?>]" /></td>
3399
  <td align="right"><input type="button" value="<?php echo $yop_poll_add_new_config['text_customize_answer']; ?>" onclick="yop_poll_toogle_customize_answer('#yop-poll-answer-table', <?php echo $answer_id ?>); return false;" class="button" /> <input onclick="yop_poll_remove_answer('#yop-poll-answer-table', <?php echo $answer_id ?>); return false;" type="button" value="<?php echo $yop_poll_add_new_config['text_remove_answer'];?>" class="button" /></td>
3400
  </tr>
3401
  <tr class="yop_poll_tr_customize_answer" id="yop_poll_tr_customize_answer<?php echo $answer_id ?>" style="display:none;">
@@ -3503,10 +3663,19 @@
3503
  <?php _e( 'Other Answer Label', 'yop_poll' ); ?>:
3504
  </th>
3505
  <td>
3506
- <input id="yop-poll-other-answers-label" type="text" name="yop_poll_options[other_answers_label]" value="<?php echo isset( $other_answer[0]['answer'] ) ? $other_answer[0]['answer'] : $default_options['other_answers_label'] ?>" />
3507
  <input type="hidden" name="yop_poll_options[other_answers_id]" value="<?php echo isset( $other_answer[0]['id'] ) ? $other_answer[0]['id'] : '' ?>" />
3508
  </td>
3509
  </tr>
 
 
 
 
 
 
 
 
 
3510
  <tr>
3511
  <th>
3512
  <?php _e( 'Allow Multiple Answers ', 'yop_poll' ); ?>:
@@ -3757,9 +3926,29 @@
3757
  <?php _e( 'Poll Answer Result Label', 'yop_poll'); ?>:
3758
  </th>
3759
  <td>
3760
- <input id="yop-poll-answer-result-label" type="text" name="yop_poll_options[answer_result_label]" value="<?php echo $default_options['answer_result_label']; ?>" /> <small><i>Use %POLL-ANSWER-RESULT-PERCENTAGES% for showing answer percentages and %POLL-ANSWER-RESULT-VOTES% for showing answer number of votes</i></small>
3761
  </td>
3762
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3763
  <tr>
3764
  <th>
3765
  <?php _e( 'View Results Link', 'yop_poll' ); ?>:
@@ -3774,7 +3963,7 @@
3774
  <?php _e( 'View Results Link Label', 'yop_poll' ); ?>:
3775
  </th>
3776
  <td>
3777
- <input id="yop-poll-view-results-link-label" type="text" name="yop_poll_options[view_results_link_label]" value="<?php echo $default_options['view_results_link_label']; ?>" />
3778
  </td>
3779
  </tr>
3780
  <tr>
@@ -3791,7 +3980,7 @@
3791
  <?php _e( 'View Back To Vote Link Label', 'yop_poll' ); ?>:
3792
  </th>
3793
  <td>
3794
- <input id="yop-poll-view-back-to-vote-link-label" type="text" name="yop_poll_options[view_back_to_vote_link_label]" value="<?php echo $default_options['view_back_to_vote_link_label']; ?>" />
3795
  </td>
3796
  </tr>
3797
  <tr>
@@ -3808,7 +3997,7 @@
3808
  <?php _e( 'View Total Votes Label', 'yop_poll' ); ?>:
3809
  </th>
3810
  <td>
3811
- <input id="yop-poll-view-total-votes-label" type="text" name="yop_poll_options[view_total_votes_label]" value="<?php echo $default_options['view_total_votes_label']; ?>" />
3812
  </td>
3813
  </tr>
3814
  <tr>
@@ -3825,7 +4014,7 @@
3825
  <?php _e( 'View Total Voters Label', 'yop_poll' ); ?>:
3826
  </th>
3827
  <td>
3828
- <input id="yop-poll-view-total-voters-label" type="text" name="yop_poll_options[view_total_voters_label]" value="<?php echo $default_options['view_total_voters_label']; ?>" />
3829
  </td>
3830
  </tr>
3831
  <tr>
@@ -3833,7 +4022,7 @@
3833
  <label for="yop-poll-page-url"><?php _e( 'Poll Page Url ', 'yop_poll' ); ?>:</label>
3834
  </th>
3835
  <td>
3836
- <input id="yop-poll-page-url" type="text" name="yop_poll_options[poll_page_url]" value="<?php echo $default_options['poll_page_url']; ?>" />
3837
  </td>
3838
  </tr>
3839
  </tbody>
@@ -3902,6 +4091,14 @@
3902
  </select>
3903
  </td>
3904
  </tr>
 
 
 
 
 
 
 
 
3905
  </tbody>
3906
  </table>
3907
  </div>
@@ -3926,7 +4123,7 @@
3926
  <?php _e( 'View Poll Archive Link Label', 'yop_poll' ); ?>:
3927
  </th>
3928
  <td>
3929
- <input id="yop-poll-view-poll-archive-link-label" type="text" name="yop_poll_options[view_poll_archive_link_label]" value="<?php echo $default_options['view_poll_archive_link_label']; ?>" />
3930
  </td>
3931
  </tr>
3932
  <tr id="yop-poll-view-poll-archive-link-div" style="<?php echo 'yes' != $default_options['view_poll_archive_link'] ? 'display: none;' : ''; ?>">
@@ -3934,7 +4131,7 @@
3934
  <?php _e( 'Poll Archive Url', 'yop_poll' ); ?>:
3935
  </th>
3936
  <td>
3937
- <input id="yop-poll-poll-archive-url" type="text" name="yop_poll_options[poll_archive_url]" value="<?php echo $default_options['poll_archive_url']; ?>" />
3938
  </td>
3939
  </tr>
3940
  <tr>
@@ -3951,7 +4148,7 @@
3951
  <?php _e( 'Archive Order', 'yop_poll' ); ?>:
3952
  </th>
3953
  <td>
3954
- <input id="yop-poll-show-in-archive-order" type="text" name="yop_poll_options[archive_order]" value="<?php echo $default_options['archive_order']; ?>" />
3955
  </td>
3956
  </tr>
3957
  </table>
7
  register_activation_hook( $this->_config->plugin_file, array( $this, 'activate' ) );
8
  register_deactivation_hook( $this->_config->plugin_file, array( $this, 'deactivate' ) );
9
  register_uninstall_hook( $this->_config->plugin_file, 'yop_poll_uninstall' );
10
+ $this->add_action('admin_enqueue_scripts', 'load_editor_functions');
11
+ $this->add_action('plugins_loaded', 'db_update');
12
+ }
13
+
14
+ public function db_update() {
15
+ global $wpdb;
16
+ $installed_version = get_option( "yop_poll_version" );
17
+
18
+ //update for version 1.5
19
+ if( version_compare ( $installed_version, '1.5', '<=' ) ) {
20
+ $default_options = get_option( 'yop_poll_options' );
21
+ if ( ! isset( $default_options['vote_button_label'] ) ) {
22
+ $default_options['vote_button_label'] = 'Vote';
23
+ }
24
+ update_option( "yop_poll_version", $wpdb->yop_poll_version );
25
+ update_option( 'yop_poll_options', $default_options );
26
+ }
27
+
28
+ //update for version 1.6
29
+ if( version_compare ( $installed_version, '1.6', '<=' ) ) {
30
+ $default_options = get_option( 'yop_poll_options' );
31
+ if ( ! isset( $default_options['display_other_answers_values'] ) ) {
32
+ $default_options['display_other_answers_values'] = 'no';
33
+ }
34
+ if ( ! isset( $default_options['percentages_decimals'] ) ) {
35
+ $default_options['percentages_decimals'] = '0';
36
+ }
37
+ if ( ! isset( $default_options['plural_answer_result_votes_number_label'] ) ) {
38
+ $default_options['singular_answer_result_votes_number_label'] = 'vote';
39
+ }
40
+ if ( ! isset( $default_options['plural_answer_result_votes_number_label'] ) ) {
41
+ $default_options['plural_answer_result_votes_number_label'] = 'votes';
42
+ }
43
+ update_option( "yop_poll_version", $wpdb->yop_poll_version );
44
+ update_option( 'yop_poll_options', $default_options );
45
+ }
46
  }
47
 
48
  public function admin_loader() {
86
  }
87
  else {
88
  if ( ! extension_loaded('json') ) {
89
+ $error = new WP_Error( 'Wordpress_json_error', __( 'You need the json php extension for this plugin', 'yop_poll' ), __( 'Error: Wordpress Extension Problem', 'yop_poll' ) );
90
 
91
  // die & print error message & code - for admins only!
92
  if ( isset( $error ) && is_wp_error( $error ) && current_user_can( 'manage_options' ) )
272
  wp_enqueue_style( 'yop-poll-admin-add-new', "{$this->_config->plugin_url}/css/yop-poll-admin-add-new.css", array(), $this->_config->version );
273
  wp_enqueue_style( 'yop-poll-timepicker', "{$this->_config->plugin_url}/css/timepicker.css", array(), $this->_config->version );
274
  wp_enqueue_style( 'yop-poll-jquery-ui', "{$this->_config->plugin_url}/css/jquery-ui.css", array(), $this->_config->version );
275
+
276
  wp_enqueue_script( 'yop-poll-admin-add-new', "{$this->_config->plugin_url}/js/yop-poll-admin-add-new.js", array( 'jquery', 'yop-poll-jquery-ui-timepicker' ), $this->_config->version );
277
  wp_enqueue_script( 'yop-poll-jquery-ui-timepicker', "{$this->_config->plugin_url}/js/jquery-ui-timepicker-addon.js",array( 'jquery-ui-datepicker', 'jquery-ui-slider' ), $this->_config->version);
278
  wp_localize_script( 'yop-poll-admin-add-new', 'yop_poll_add_new_config', $yop_poll_add_new_config );
2144
  $newinput['other_answers_label'] = $default_options['other_answers_label'] ;
2145
  $errors .= __( 'Option "Allow Other Answer Label" Not Updated! The field must not be empty!', 'yop_poll' ).$message_delimiter;
2146
  }
2147
+
2148
+ if( isset( $input['display_other_answers_values'] ) ) {
2149
+ if( in_array( $input['display_other_answers_values'], array('yes', 'no') ) ) {
2150
+ $newinput['display_other_answers_values'] = trim( $input['display_other_answers_values'] ) ;
2151
+ $updated .= __( 'Option "Display Other Answers Values" Updated!', 'yop_poll' ).$message_delimiter;
2152
+ }
2153
+ else {
2154
+ $newinput['display_other_answers_values'] = $default_options['display_other_answers_values'] ;
2155
+ $errors .= __( 'Option "Display Other Answers Values" Not Updated! Choose "yes" or "no"!', 'yop_poll' ).$message_delimiter;
2156
+ }
2157
+ }
2158
+ else {
2159
+ $newinput['display_other_answers_values'] = $default_options['display_other_answers_values'] ;
2160
+ $errors .= __( 'Option "Display Other Answers Values" Not Updated! Choose "yes" or "no"!', 'yop_poll' ).$message_delimiter;
2161
+ }
2162
  }
2163
  }
2164
  else {
2564
  $newinput['answer_result_label'] = $default_options['answer_result_label'];
2565
  $errors .= __( 'Option "Poll Answer Result Label" Not Updated!', 'yop_poll' ).$message_delimiter;
2566
  }
2567
+
2568
+ //singular_answer_result_votes_number_label
2569
+ if ( isset( $input['singular_answer_result_votes_number_label'] ) ) {
2570
+ if ( '' != $input['singular_answer_result_votes_number_label'] ) {
2571
+ $newinput['singular_answer_result_votes_number_label'] = trim( $input['singular_answer_result_votes_number_label'] );
2572
+ $updated .= __( 'Option "Poll Answer Result Votes Number Singular Label" Updated!', 'yop_poll' ).$message_delimiter;
2573
+ }
2574
+ else {
2575
+ $newinput['singular_answer_result_votes_number_label'] = $default_options['singular_answer_result_votes_number_label'];
2576
+ $errors .= __( 'Option "Poll Answer Result Votes Number Singular Label" Not Updated! The field is empty!', 'yop_poll' ).$message_delimiter;
2577
+ }
2578
+ }
2579
+ else {
2580
+ $newinput['singular_answer_result_votes_number_label'] = $default_options['singular_answer_result_votes_number_label'];
2581
+ $errors .= __( 'Option "Poll Answer Result Votes Number Singular Label" Not Updated!', 'yop_poll' ).$message_delimiter;
2582
+ }
2583
+
2584
+ //plural_answer_result_votes_number_label
2585
+ if ( isset( $input['plural_answer_result_votes_number_label'] ) ) {
2586
+ if ( '' != $input['singular_answer_result_votes_number_label'] ) {
2587
+ $newinput['plural_answer_result_votes_number_label'] = trim( $input['plural_answer_result_votes_number_label'] );
2588
+ $updated .= __( 'Option "Poll Answer Result Votes Number Plural Label" Updated!', 'yop_poll' ).$message_delimiter;
2589
+ }
2590
+ else {
2591
+ $newinput['plural_answer_result_votes_number_label'] = $default_options['plural_answer_result_votes_number_label'];
2592
+ $errors .= __( 'Option "Poll Answer Result Votes Number Plural Label" Not Updated! The field is empty!', 'yop_poll' ).$message_delimiter;
2593
+ }
2594
+ }
2595
+ else {
2596
+ $newinput['plural_answer_result_votes_number_label'] = $default_options['plural_answer_result_votes_number_label'];
2597
+ $errors .= __( 'Option "Poll Answer Result Votes Number Plural Label" Not Updated!', 'yop_poll' ).$message_delimiter;
2598
+ }
2599
+
2600
+ //vote_button_label
2601
+ if ( isset( $input['vote_button_label'] ) ) {
2602
+ if ( '' != $input['vote_button_label'] ) {
2603
+ $newinput['vote_button_label'] = trim( $input['vote_button_label'] );
2604
+ $updated .= __( 'Option "Vote Button Label" Updated!', 'yop_poll' ).$message_delimiter;
2605
+ }
2606
+ else {
2607
+ $newinput['vote_button_label'] = $default_options['vote_button_label'];
2608
+ $errors .= __( 'Option "Vote Button Label" Not Updated! The field is empty!', 'yop_poll' ).$message_delimiter;
2609
+ }
2610
+ }
2611
+ else {
2612
+ $newinput['vote_button_label'] = $default_options['vote_button_label'];
2613
+ $errors .= __( 'Option "Vote Button Label" Not Updated!', 'yop_poll' ).$message_delimiter;
2614
+ }
2615
+
2616
 
2617
  //view_results_link
2618
  if ( isset( $input['view_results_link'] ) ) {
2815
  $newinput['blocking_voters'] = $default_options['blocking_voters'];
2816
  $errors .= __( 'Option "Blocking Voters" Not Updated!', 'yop_poll' ).$message_delimiter;
2817
  }
2818
+
2819
+ //percentages_decimals
2820
+ if ( isset( $input['percentages_decimals'] ) ) {
2821
+ if ( ctype_digit( $input['percentages_decimals'] ) ) {
2822
+ $newinput['percentages_decimals'] = trim( $input['percentages_decimals'] );
2823
+ $updated .= __( 'Option "Percentages Decimals" Updated!', 'yop_poll' ).$message_delimiter;
2824
+ }
2825
+ else {
2826
+ $newinput['percentages_decimals'] = $default_options['percentages_decimals'];
2827
+ $errors .= __( 'Option "Percentages Decimals" Not Updated! Please fill in a number!', 'yop_poll' ).$message_delimiter;
2828
+ }
2829
+ }
2830
+ else {
2831
+ $newinput['percentages_decimals'] = $default_options['percentages_decimals'];
2832
+ $errors .= __( 'Option "Percentages Decimals" Not Updated!', 'yop_poll' ).$message_delimiter;
2833
+ }
2834
 
2835
  //view_poll_archive_link
2836
  if ( isset( $input['view_poll_archive_link'] ) ) {
2976
  <?php _e( 'Other Answer Label', 'yop_poll' ); ?>:
2977
  </th>
2978
  <td>
2979
+ <input id="yop-poll-other-answers-label" type="text" name="yop_poll_options[other_answers_label]" value="<?php echo isset( $other_answer[0]['answer'] ) ? esc_html( stripslashes( $other_answer[0]['answer'] ) ) : $default_options['other_answers_label'] ?>" />
2980
  <input type="hidden" name="yop_poll_options[other_answers_id]" value="<?php echo isset( $other_answer[0]['id'] ) ? $other_answer[0]['id'] : '' ?>" />
2981
  </td>
2982
  </tr>
2983
+ <tr id="yop-poll-display-other-answers-values-div" style="<?php echo 'no' == $default_options['allow_other_answers'] ? 'display: none;' : ''; ?>">
2984
+ <th>
2985
+ <?php _e( 'Display Other Answers Values', 'yop_poll' ); ?>:
2986
+ </th>
2987
+ <td>
2988
+ <label for="yop-poll-display-other-answers-values-no"><input id="yop-poll-display-other-answers-values-no" <?php echo 'no' == $default_options['display_other_answers_values'] ? 'checked="checked"' : ''; ?> type="radio" name="yop_poll_options[display_other_answers_values]" value="no" /> <?php _e( 'No', 'yop_poll' ); ?></label>
2989
+ <label for="yop-poll-display-other-answers-values-yes"><input id="yop-poll-display-other-answers-values-yes" <?php echo 'yes' == $default_options['display_other_answers_values'] ? 'checked="checked"' : ''; ?> type="radio" name="yop_poll_options[display_other_answers_values]" value="yes" /> <?php _e( 'Yes', 'yop_poll' ); ?></label>
2990
+ </td>
2991
+ </tr>
2992
  <tr>
2993
  <th>
2994
  <?php _e( 'Allow Multiple Answers ', 'yop_poll' ); ?>:
3153
  </td>
3154
  </tr>
3155
  <tr>
3156
+ <th><?php _e( 'Sorting Results', 'yop_poll' ); ?>:</th>
3157
  <td valign="top">
3158
  <label for="yop_poll_sorting_results_exact"><input id="yop_poll_sorting_results_exact" <?php echo $default_options['sorting_results'] == 'exact' ? 'checked="checked"' : ''; ?> type="radio" name="yop_poll_options[sorting_results]" value="exact" > <?php _e( 'Exact Order', 'yop_poll' ); ?></label>
3159
  <label for="yop_poll_sorting_results_alphabetical"><input id="yop_poll_sorting_results_alphabetical" <?php echo $default_options['sorting_results'] == 'alphabetical' ? 'checked="checked"' : ''; ?> type="radio" name="yop_poll_options[sorting_results]" value="alphabetical" > <?php _e( 'Alphabetical Order', 'yop_poll' ); ?></label>
3237
  <?php _e( 'Poll Answer Result Label', 'yop_poll'); ?>:
3238
  </th>
3239
  <td>
3240
+ <input id="yop-poll-answer-result-label" type="text" name="yop_poll_options[answer_result_label]" value="<?php echo esc_html( stripslashes( $default_options['answer_result_label'] ) ); ?>" /> <small><i>Use %POLL-ANSWER-RESULT-PERCENTAGES% for showing answer percentages and %POLL-ANSWER-RESULT-VOTES% for showing answer number of votes</i></small>
3241
  </td>
3242
  </tr>
3243
+ <tr>
3244
+ <th>
3245
+ <?php _e( 'Poll Answer Result Votes Number Label', 'yop_poll' ); ?>:
3246
+ </th>
3247
+ <td>
3248
+ <?php _e( 'Singular', 'yop_poll' ); ?>
3249
+ <input id="yop-poll-singular-answer-result-votes-number-label" type="text" name="yop_poll_options[singular_answer_result_votes_number_label]" value="<?php echo esc_html( stripslashes( $default_options['singular_answer_result_votes_number_label'] ) ); ?>" />
3250
+ <?php _e( 'Plural', 'yop_poll' ); ?>
3251
+ <input id="yop-poll-plural-answer-result-votes-number-label" type="text" name="yop_poll_options[plural_answer_result_votes_number_label]" value="<?php echo esc_html( stripslashes( $default_options['plural_answer_result_votes_number_label'] ) ); ?>" />
3252
+
3253
+ </td>
3254
+ </tr>
3255
+ <tr>
3256
+ <th>
3257
+ <?php _e( 'Vote Button Label', 'yop_poll' ); ?>:
3258
+ </th>
3259
+ <td>
3260
+ <input id="yop-poll-vote-button-label" type="text" name="yop_poll_options[vote_button_label]" value="<?php echo esc_html( stripslashes( $default_options['vote_button_label'] ) ); ?>" />
3261
+ </td>
3262
+ </tr>
3263
  <tr>
3264
  <th>
3265
  <?php _e( 'View Results Link', 'yop_poll' ); ?>:
3274
  <?php _e( 'View Results Link Label', 'yop_poll' ); ?>:
3275
  </th>
3276
  <td>
3277
+ <input id="yop-poll-view-results-link-label" type="text" name="yop_poll_options[view_results_link_label]" value="<?php echo esc_html( stripslashes( $default_options['view_results_link_label'] ) ); ?>" />
3278
  </td>
3279
  </tr>
3280
  <tr>
3291
  <?php _e( 'View Back To Vote Link Label', 'yop_poll' ); ?>:
3292
  </th>
3293
  <td>
3294
+ <input id="yop-poll-view-back-to-vote-link-label" type="text" name="yop_poll_options[view_back_to_vote_link_label]" value="<?php echo esc_html( stripslashes( $default_options['view_back_to_vote_link_label'] ) ); ?>" />
3295
  </td>
3296
  </tr>
3297
  <tr>
3308
  <?php _e( 'View Total Votes Label', 'yop_poll' ); ?>:
3309
  </th>
3310
  <td>
3311
+ <input id="yop-poll-view-total-votes-label" type="text" name="yop_poll_options[view_total_votes_label]" value="<?php echo esc_html( stripslashes( $default_options['view_total_votes_label'] ) ); ?>" />
3312
  </td>
3313
  </tr>
3314
  <tr>
3325
  <?php _e( 'View Total Voters Label', 'yop_poll' ); ?>:
3326
  </th>
3327
  <td>
3328
+ <input id="yop-poll-view-total-voters-label" type="text" name="yop_poll_options[view_total_voters_label]" value="<?php echo esc_html( stripslashes( $default_options['view_total_voters_label'] ) ); ?>" />
3329
  </td>
3330
  </tr>
3331
  <tr>
3333
  <label for="yop-poll-page-url"><?php _e( 'Poll Page Url ', 'yop_poll' ); ?>:</label>
3334
  </th>
3335
  <td>
3336
+ <input id="yop-poll-page-url" type="text" name="yop_poll_options[poll_page_url]" value="<?php echo esc_html( stripslashes( $default_options['poll_page_url'] ) ); ?>" />
3337
  </td>
3338
  </tr>
3339
  </tbody>
3382
  </select>
3383
  </td>
3384
  </tr>
3385
+ <tr>
3386
+ <th>
3387
+ <?php _e( 'Percentages Decimals', 'yop_poll' ); ?>:
3388
+ </th>
3389
+ <td>
3390
+ <input id="yop-poll-percentages-decimals" type="text" name="yop_poll_options[percentages_decimals]" value="<?php echo esc_html( stripslashes( $default_options['percentages_decimals'] ) ); ?>" />
3391
+ </td>
3392
+ </tr>
3393
  </tbody>
3394
  </table>
3395
  </div>
3414
  <?php _e( 'View Poll Archive Link Label', 'yop_poll' ); ?>:
3415
  </th>
3416
  <td>
3417
+ <input id="yop-poll-view-poll-archive-link-label" type="text" name="yop_poll_options[view_poll_archive_link_label]" value="<?php echo esc_html( stripslashes( $default_options['view_poll_archive_link_label'] ) ); ?>" />
3418
  </td>
3419
  </tr>
3420
  <tr id="yop-poll-view-poll-archive-link-div" style="<?php echo 'yes' != $default_options['view_poll_archive_link'] ? 'display: none;' : ''; ?>">
3422
  <?php _e( 'Poll Archive Url', 'yop_poll' ); ?>:
3423
  </th>
3424
  <td>
3425
+ <input id="yop-poll-poll-archive-url" type="text" name="yop_poll_options[poll_archive_url]" value="<?php echo esc_html( stripslashes( $default_options['poll_archive_url'] ) ); ?>" />
3426
  </td>
3427
  </tr>
3428
  <tr>
3442
  <input id="yop-poll-show-in-archive-order" type="text" name="yop_poll_options[archive_order]" value="<?php echo $default_options['archive_order']; ?>" />
3443
  </td>
3444
  </tr>
3445
+ <tr>
3446
+ <th>
3447
+ <?php _e( 'Archive Polls Per Page', 'yop_poll' ); ?>:
3448
+ </th>
3449
+ <td>
3450
+ <input id="yop-poll-archive-polls-per-page" type="text" name="yop_poll_options[archive_polls_per_page]" value="<?php echo $default_options['archive_polls_per_page']; ?>" />
3451
+ </td>
3452
+ </tr>
3453
  </table>
3454
  </div>
3455
  </div>
3555
  <th scope="row"><label class="yop_poll_answer_label" for="yop-poll-answer<?php echo $answer_id ?>"><?php echo $yop_poll_add_new_config['text_answer']; ?> <?php echo $answer_id ?></label></th>
3556
  <td>
3557
  <input type="hidden" value="<?php echo isset( $answers[ $answer_id - 1 ]['id'] )? $answers[ $answer_id - 1 ]['id'] : ''; ?>" name="yop_poll_answer_ids[answer<?php echo $answer_id ?>]" />
3558
+ <input type="text" value="<?php echo isset( $answers[ $answer_id - 1 ]['answer'] )? esc_html( stripslashes( $answers[ $answer_id - 1 ]['answer'] ) ) : ''; ?>" id="yop-poll-answer<?php echo $answer_id ?>" name="yop_poll_answer[answer<?php echo $answer_id ?>]" /></td>
3559
  <td align="right"><input type="button" value="<?php echo $yop_poll_add_new_config['text_customize_answer']; ?>" onclick="yop_poll_toogle_customize_answer('#yop-poll-answer-table', <?php echo $answer_id ?>); return false;" class="button" /> <input onclick="yop_poll_remove_answer('#yop-poll-answer-table', <?php echo $answer_id ?>); return false;" type="button" value="<?php echo $yop_poll_add_new_config['text_remove_answer'];?>" class="button" /></td>
3560
  </tr>
3561
  <tr class="yop_poll_tr_customize_answer" id="yop_poll_tr_customize_answer<?php echo $answer_id ?>" style="display:none;">
3663
  <?php _e( 'Other Answer Label', 'yop_poll' ); ?>:
3664
  </th>
3665
  <td>
3666
+ <input id="yop-poll-other-answers-label" type="text" name="yop_poll_options[other_answers_label]" value="<?php echo isset( $other_answer[0]['answer'] ) ? esc_html( stripslashes( $other_answer[0]['answer'] ) ) : $default_options['other_answers_label'] ?>" />
3667
  <input type="hidden" name="yop_poll_options[other_answers_id]" value="<?php echo isset( $other_answer[0]['id'] ) ? $other_answer[0]['id'] : '' ?>" />
3668
  </td>
3669
  </tr>
3670
+ <tr id="yop-poll-display-other-answers-values-div" style="<?php echo 'no' == $default_options['allow_other_answers'] ? 'display: none;' : ''; ?>">
3671
+ <th>
3672
+ <?php _e( 'Display Other Answers Values', 'yop_poll' ); ?>:
3673
+ </th>
3674
+ <td>
3675
+ <label for="yop-poll-display-other-answers-values-no"><input id="yop-poll-display-other-answers-values-no" <?php echo 'no' == $default_options['display_other_answers_values'] ? 'checked="checked"' : ''; ?> type="radio" name="yop_poll_options[display_other_answers_values]" value="no" /> <?php _e( 'No', 'yop_poll' ); ?></label>
3676
+ <label for="yop-poll-display-other-answers-values-yes"><input id="yop-poll-display-other-answers-values-yes" <?php echo 'yes' == $default_options['display_other_answers_values'] ? 'checked="checked"' : ''; ?> type="radio" name="yop_poll_options[display_other_answers_values]" value="yes" /> <?php _e( 'Yes', 'yop_poll' ); ?></label>
3677
+ </td>
3678
+ </tr>
3679
  <tr>
3680
  <th>
3681
  <?php _e( 'Allow Multiple Answers ', 'yop_poll' ); ?>:
3926
  <?php _e( 'Poll Answer Result Label', 'yop_poll'); ?>:
3927
  </th>
3928
  <td>
3929
+ <input id="yop-poll-answer-result-label" type="text" name="yop_poll_options[answer_result_label]" value="<?php echo esc_html( stripslashes( $default_options['answer_result_label'] ) ); ?>" /> <small><i>Use %POLL-ANSWER-RESULT-PERCENTAGES% for showing answer percentages and %POLL-ANSWER-RESULT-VOTES% for showing answer number of votes</i></small>
3930
  </td>
3931
  </tr>
3932
+ <tr>
3933
+ <th>
3934
+ <?php _e( 'Poll Answer Result Votes Number Label', 'yop_poll' ); ?>:
3935
+ </th>
3936
+ <td>
3937
+ <?php _e( 'Singular', 'yop_poll' ); ?>
3938
+ <input id="yop-poll-singular-answer-result-votes-number-label" type="text" name="yop_poll_options[singular_answer_result_votes_number_label]" value="<?php echo esc_html( stripslashes( $default_options['singular_answer_result_votes_number_label'] ) ); ?>" />
3939
+ <?php _e( 'Plural', 'yop_poll' ); ?>
3940
+ <input id="yop-poll-plural-answer-result-votes-number-label" type="text" name="yop_poll_options[plural_answer_result_votes_number_label]" value="<?php echo esc_html( stripslashes( $default_options['plural_answer_result_votes_number_label'] ) ); ?>" />
3941
+
3942
+ </td>
3943
+ </tr>
3944
+ <tr>
3945
+ <th>
3946
+ <?php _e( 'Vote Button Label', 'yop_poll' ); ?>:
3947
+ </th>
3948
+ <td>
3949
+ <input id="yop-poll-vote-button-label" type="text" name="yop_poll_options[vote_button_label]" value="<?php echo esc_html( stripslashes( $default_options['vote_button_label'] ) ); ?>" />
3950
+ </td>
3951
+ </tr>
3952
  <tr>
3953
  <th>
3954
  <?php _e( 'View Results Link', 'yop_poll' ); ?>:
3963
  <?php _e( 'View Results Link Label', 'yop_poll' ); ?>:
3964
  </th>
3965
  <td>
3966
+ <input id="yop-poll-view-results-link-label" type="text" name="yop_poll_options[view_results_link_label]" value="<?php echo esc_html( stripslashes( $default_options['view_results_link_label'] ) ); ?>" />
3967
  </td>
3968
  </tr>
3969
  <tr>
3980
  <?php _e( 'View Back To Vote Link Label', 'yop_poll' ); ?>:
3981
  </th>
3982
  <td>
3983
+ <input id="yop-poll-view-back-to-vote-link-label" type="text" name="yop_poll_options[view_back_to_vote_link_label]" value="<?php echo esc_html( stripslashes( $default_options['view_back_to_vote_link_label'] ) ); ?>" />
3984
  </td>
3985
  </tr>
3986
  <tr>
3997
  <?php _e( 'View Total Votes Label', 'yop_poll' ); ?>:
3998
  </th>
3999
  <td>
4000
+ <input id="yop-poll-view-total-votes-label" type="text" name="yop_poll_options[view_total_votes_label]" value="<?php echo esc_html( stripslashes( $default_options['view_total_votes_label'] ) ); ?>" />
4001
  </td>
4002
  </tr>
4003
  <tr>
4014
  <?php _e( 'View Total Voters Label', 'yop_poll' ); ?>:
4015
  </th>
4016
  <td>
4017
+ <input id="yop-poll-view-total-voters-label" type="text" name="yop_poll_options[view_total_voters_label]" value="<?php echo esc_html( stripslashes( $default_options['view_total_voters_label'] ) ); ?>" />
4018
  </td>
4019
  </tr>
4020
  <tr>
4022
  <label for="yop-poll-page-url"><?php _e( 'Poll Page Url ', 'yop_poll' ); ?>:</label>
4023
  </th>
4024
  <td>
4025
+ <input id="yop-poll-page-url" type="text" name="yop_poll_options[poll_page_url]" value="<?php echo esc_html( stripslashes( $default_options['poll_page_url'] ) ); ?>" />
4026
  </td>
4027
  </tr>
4028
  </tbody>
4091
  </select>
4092
  </td>
4093
  </tr>
4094
+ <tr>
4095
+ <th>
4096
+ <?php _e( 'Percentages Decimals', 'yop_poll' ); ?>:
4097
+ </th>
4098
+ <td>
4099
+ <input id="yop-poll-percentages-decimals" type="text" name="yop_poll_options[percentages_decimals]" value="<?php echo esc_html( stripslashes( $default_options['percentages_decimals'] ) ); ?>" />
4100
+ </td>
4101
+ </tr>
4102
  </tbody>
4103
  </table>
4104
  </div>
4123
  <?php _e( 'View Poll Archive Link Label', 'yop_poll' ); ?>:
4124
  </th>
4125
  <td>
4126
+ <input id="yop-poll-view-poll-archive-link-label" type="text" name="yop_poll_options[view_poll_archive_link_label]" value="<?php echo esc_html( stripslashes( $default_options['view_poll_archive_link_label'] ) ); ?>" />
4127
  </td>
4128
  </tr>
4129
  <tr id="yop-poll-view-poll-archive-link-div" style="<?php echo 'yes' != $default_options['view_poll_archive_link'] ? 'display: none;' : ''; ?>">
4131
  <?php _e( 'Poll Archive Url', 'yop_poll' ); ?>:
4132
  </th>
4133
  <td>
4134
+ <input id="yop-poll-poll-archive-url" type="text" name="yop_poll_options[poll_archive_url]" value="<?php echo esc_html( stripslashes( $default_options['poll_archive_url'] ) ); ?>" />
4135
  </td>
4136
  </tr>
4137
  <tr>
4148
  <?php _e( 'Archive Order', 'yop_poll' ); ?>:
4149
  </th>
4150
  <td>
4151
+ <input id="yop-poll-show-in-archive-order" type="text" name="yop_poll_options[archive_order]" value="<?php echo esc_html( stripslashes( $default_options['archive_order'] ) ); ?>" />
4152
  </td>
4153
  </tr>
4154
  </table>
inc/db_schema.php CHANGED
@@ -21,52 +21,57 @@
21
 
22
  update_option( "yop_poll_version", $wpdb->yop_poll_version );
23
  $default_options = array(
24
- 'create_poll_page' => 'yes',
25
- 'poll_page_url' => '',
26
- 'allow_other_answers' => 'yes',
27
- 'other_answers_label' => 'Other',
28
- 'allow_multiple_answers' => 'no',
29
- 'allow_multiple_answers_number' => 1,
30
- 'display_answers' => 'vertical',
31
- 'display_answers_tabulated_cols' => 1,
32
- 'display_results' => 'vertical',
33
- 'display_results_tabulated_cols' => 1,
34
- 'use_template_bar' => 'yes',
35
- 'bar_background' => 'FBD55E',
36
- 'bar_height' => 10,
37
- 'bar_border_color' => 'EDB918',
38
- 'bar_border_width' => 1,
39
- 'bar_border_style' => 'solid',
40
- 'sorting_answers' => 'exact',
41
- 'sorting_answers_direction' => 'asc',
42
- 'sorting_results' => 'exact',
43
- 'sorting_results_direction' => 'asc',
44
- 'start_date' => date('Y-m-d H:i:s'),
45
- 'end_date' => '9999-12-31 23:59:59',
46
- 'never_expire' => 'yes',
47
- 'view_results' => 'after',
48
- 'answer_result_label' => '- %POLL-ANSWER-RESULT-PERCENTAGES% ( %POLL-ANSWER-RESULT-VOTES% )',
49
- 'view_results_type' => 'votes-number',
50
- 'view_results_start_date' => '',
51
- 'view_results_link' => 'yes',
52
- 'view_back_to_vote_link' => 'yes',
53
- 'view_results_link_label' => 'View Results',
54
- 'view_back_to_vote_link_label' => 'Back To Vote',
55
- 'view_total_votes_label' => 'Total Votes %POLL-TOTAL-VOTES%',
56
- 'view_total_voters_label' => 'Total Voters %POLL-TOTAL-VOTERS%',
57
- 'view_total_voters' => 'yes',
58
- 'view_total_votes' => 'yes',
59
- 'view_poll_archive_link' => 'yes',
60
- 'view_poll_archive_link_label' => 'View Poll Archive',
61
- 'poll_archive_url' => home_url().'/yop-poll-archive',
62
- 'vote_permisions' => 'guest-registered',
63
- 'blocking_voters' => 'dont-block',
64
- 'blocking_voters_interval_value' => 30,
65
- 'blocking_voters_interval_unit' => 'days',
66
- 'template' => '1',
67
- 'show_in_archive' => 'yes',
68
- 'archive_order' => '1',
69
- 'archive_polls_per_page' => '5'
 
 
 
 
 
70
  );
71
 
72
  //prepopulate database
21
 
22
  update_option( "yop_poll_version", $wpdb->yop_poll_version );
23
  $default_options = array(
24
+ 'create_poll_page' => 'yes',
25
+ 'poll_page_url' => '',
26
+ 'allow_other_answers' => 'yes',
27
+ 'other_answers_label' => 'Other',
28
+ 'display_other_answers_values' => 'no',
29
+ 'allow_multiple_answers' => 'no',
30
+ 'allow_multiple_answers_number' => 1,
31
+ 'display_answers' => 'vertical',
32
+ 'display_answers_tabulated_cols' => 1,
33
+ 'display_results' => 'vertical',
34
+ 'display_results_tabulated_cols' => 1,
35
+ 'use_template_bar' => 'yes',
36
+ 'bar_background' => 'FBD55E',
37
+ 'bar_height' => 10,
38
+ 'bar_border_color' => 'EDB918',
39
+ 'bar_border_width' => 1,
40
+ 'bar_border_style' => 'solid',
41
+ 'sorting_answers' => 'exact',
42
+ 'sorting_answers_direction' => 'asc',
43
+ 'sorting_results' => 'exact',
44
+ 'sorting_results_direction' => 'asc',
45
+ 'start_date' => date('Y-m-d H:i:s'),
46
+ 'end_date' => '9999-12-31 23:59:59',
47
+ 'never_expire' => 'yes',
48
+ 'view_results' => 'after',
49
+ 'answer_result_label' => '- %POLL-ANSWER-RESULT-PERCENTAGES% ( %POLL-ANSWER-RESULT-VOTES% )',
50
+ 'view_results_type' => 'votes-number',
51
+ 'view_results_start_date' => '',
52
+ 'view_results_link' => 'yes',
53
+ 'view_back_to_vote_link' => 'yes',
54
+ 'singular_answer_result_votes_number_label' => 'vote',
55
+ 'plural_answer_result_votes_number_label' => 'votes',
56
+ 'vote_button_label' => 'Vote',
57
+ 'view_results_link_label' => 'View Results',
58
+ 'view_back_to_vote_link_label' => 'Back To Vote',
59
+ 'view_total_votes_label' => 'Total Votes %POLL-TOTAL-VOTES%',
60
+ 'view_total_voters_label' => 'Total Voters %POLL-TOTAL-VOTERS%',
61
+ 'view_total_voters' => 'yes',
62
+ 'view_total_votes' => 'yes',
63
+ 'view_poll_archive_link' => 'yes',
64
+ 'view_poll_archive_link_label' => 'View Poll Archive',
65
+ 'poll_archive_url' => home_url().'/yop-poll-archive',
66
+ 'vote_permisions' => 'guest-registered',
67
+ 'blocking_voters' => 'dont-block',
68
+ 'blocking_voters_interval_value' => 30,
69
+ 'blocking_voters_interval_unit' => 'days',
70
+ 'template' => '1',
71
+ 'show_in_archive' => 'yes',
72
+ 'archive_order' => '1',
73
+ 'archive_polls_per_page' => '5',
74
+ 'percentages_decimals' => '0'
75
  );
76
 
77
  //prepopulate database
inc/public-admin.php CHANGED
@@ -7,7 +7,7 @@
7
  $this->add_filter( 'widget_text', 'do_shortcode');
8
  }
9
 
10
- public function do_shortcode( $content ) {
11
  return do_shortcode( $content );
12
  }
13
 
7
  $this->add_filter( 'widget_text', 'do_shortcode');
8
  }
9
 
10
+ public function do_shortcode( $content ) {
11
  return do_shortcode( $content );
12
  }
13
 
inc/yop_poll_model.php CHANGED
@@ -750,8 +750,13 @@
750
  return $this->poll;
751
  }
752
 
753
- public static function get_poll_answers( $poll_id, $types = array( 'default' ), $order = 'id', $order_dir = '' ) {
754
  global $wpdb;
 
 
 
 
 
755
  $type_sql = '';
756
  if ( count( $types ) > 0 ) {
757
  $type_sql .= ' AND type in (';
@@ -777,22 +782,125 @@
777
  ),
778
  ARRAY_A
779
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
780
  $total_votes = self::get_sum_poll_votes( $poll_id );
781
  if( count( $answers ) > 0 ) {
782
  for( $i = 0; $i < count ( $answers ); $i++ ) {
783
  if( 0 == intval( $total_votes ) )
784
  $answers[$i]['procentes'] = 0;
785
- else
786
- $answers[$i]['procentes'] = intval( ( intval( $answers[$i]['votes']) / intval( $total_votes ) * 100 ) ) ;
 
 
 
787
  }
788
  }
 
789
  if ( $is_votes_sort ) {
790
  $order_dir = ( '' == $order_dir ) ? 'asc' : $order_dir;
791
  usort($answers, array( 'Yop_Poll_Model', "sort_answers_by_votes_".$order_dir."_callback" ) );
792
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
793
  return $answers;
794
  }
795
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
796
  public static function get_poll_answer_by_id( $answer_id ) {
797
  global $wpdb;
798
  $answer = $wpdb->get_row(
@@ -1258,8 +1366,7 @@
1258
  ";
1259
  $sql .= $sql_search;
1260
  return $wpdb->get_var( $sql );
1261
- }
1262
-
1263
 
1264
  public static function get_bans_filter_search ( $orderby = 'id', $order = 'desc' , $search = array( 'fields' => array(), 'value' => NULL ), $type = NULL, $poll_id = NULL, $offset = 0, $per_page = 99999999 ) {
1265
  global $wpdb;
@@ -1965,9 +2072,16 @@
1965
  $poll_id = $this->poll['id'];
1966
  if( ! $poll_id )
1967
  return '';
1968
- $poll_details = $this->poll;
1969
- $poll_options = $this->poll_options;
1970
- $template_id = $poll_options['template'];
 
 
 
 
 
 
 
1971
  if ( '' == $template_id ) {
1972
  $default_template = self::get_default_template();
1973
  $template_id = $default_template['id'] ? $default_template['id'] : 0;
@@ -1975,12 +2089,12 @@
1975
  $answers_tabulated_cols = 1;
1976
  $results_tabulated_cols = 1;
1977
  if ( 'orizontal' == $poll_options['display_answers'] ) {
1978
- $ans_no = count( self::get_poll_answers( $poll_id, array( 'default', 'other' ) ) );
1979
  if( $ans_no > 0 )
1980
  $answers_tabulated_cols = $ans_no;
1981
  }
1982
  if ( 'orizontal' == $poll_options['display_results'] ) {
1983
- $ans_no = count( self::get_poll_answers( $poll_id, array( 'default', 'other' ) ) );
1984
  if( $ans_no > 0 )
1985
  $results_tabulated_cols = $ans_no;
1986
  }
@@ -2017,7 +2131,7 @@
2017
  $template = $template_details['before_vote_template'];
2018
  if ( 'before' == $poll_options['view_results'] )
2019
  $template = str_ireplace( '%POLL-ANSWER-RESULT-LABEL%', $poll_options['answer_result_label'], $template );
2020
- $template = str_ireplace( '%POLL-VOTE-BUTTON%', '<button class="yop_poll_vote_button" id="yop_poll_vote-button-'.$poll_id.'" onclick="yop_poll_do_vote(\''.$poll_id.'\'); return false;">Vote</button>', $template );
2021
  }
2022
  else {
2023
  $template = $template_details['after_vote_template'];
@@ -2103,31 +2217,50 @@
2103
  ( 'after-poll-end-date' == $poll_options['view_results'] && self::get_mysql_curent_date() >= $this -> poll['end_date'] )
2104
  ) && 'never' != $poll_options['view_results']
2105
  ) {
 
 
 
 
 
 
 
 
 
2106
  if( isset( $poll_options['sorting_results'] ) ) {
2107
  if( 'exact' == $poll_options['sorting_results'] ) {
2108
- $answers = self::get_poll_answers( $poll_id, array('default', 'other') );
 
 
 
2109
  }
2110
  elseif( 'alphabetical' == $poll_options['sorting_results'] ) {
2111
  $order_dir = 'asc';
2112
  if( isset( $poll_options['sorting_results_direction'] ) )
2113
  $order_dir = ('asc' == $poll_options['sorting_results_direction']) ? 'asc' : 'desc';
2114
- $answers = self::get_poll_answers( $poll_id, array('default', 'other'), 'answer', $order_dir );
2115
  }
2116
  elseif( 'random' == $poll_options['sorting_results'] ) {
2117
- $answers = self::get_poll_answers( $poll_id, array('default', 'other'), 'rand()' );
2118
  }
2119
  elseif( 'votes' == $poll_options['sorting_results'] ) {
2120
  $order_dir = 'asc';
2121
  if( isset( $poll_options['sorting_results_direction'] ) )
2122
  $order_dir = ('asc' == $poll_options['sorting_results_direction']) ? 'asc' : 'desc';
2123
- $answers = self::get_poll_answers( $poll_id, array('default', 'other'), 'votes', $order_dir );
2124
  }
2125
  else {
2126
- $answers = self::get_poll_answers( $poll_id );
 
 
 
2127
  }
2128
  }
2129
- else
2130
- $answers = self::get_poll_answers( $poll_id );
 
 
 
 
2131
  if( count( $answers ) > 0 ) {
2132
  foreach( $answers as $answer ) {
2133
  $poll_options = $this->poll_options;
@@ -2178,6 +2311,9 @@
2178
  $poll_options = $this->poll_options;
2179
  $return_string = '';
2180
  $is_voted = $this->is_voted();
 
 
 
2181
  if( ! $is_voted ) {
2182
  $multiple_answers = false;
2183
  if( isset( $poll_options['allow_multiple_answers'] ) )
@@ -2198,7 +2334,7 @@
2198
  );
2199
  $other_answer_id = self::insert_answer_to_database( $answer );
2200
  }
2201
- $other_answer = self::get_poll_answers( $poll_id, array( 'other') );
2202
  if( $multiple_answers )
2203
  $temp_string = str_ireplace( '%POLL-OTHER-ANSWER-CHECK-INPUT%', '<input type="checkbox" value="'.$other_answer[0]['id'].'" name="yop_poll_answer['.$other_answer[0]['id'].']" id="yop-poll-answer-'.$other_answer[0]['id'].'" />', $m[5] );
2204
  else
@@ -2230,32 +2366,45 @@
2230
  $poll_options = $this->poll_options;
2231
  $return_string = '';
2232
  $is_voted = $this->is_voted();
 
 
 
2233
  if( ! $is_voted ) {
2234
  if( isset( $poll_options['sorting_answers'] ) ) {
2235
  if( 'exact' == $poll_options['sorting_answers'] ) {
2236
- $answers = self::get_poll_answers( $poll_id );
 
 
 
2237
  }
2238
  elseif( 'alphabetical' == $poll_options['sorting_answers'] ) {
2239
  $order_dir = 'asc';
2240
  if( isset( $poll_options['sorting_answers_direction'] ) )
2241
  $order_dir = ('asc' == $poll_options['sorting_answers_direction']) ? 'asc' : 'desc';
2242
- $answers = self::get_poll_answers( $poll_id, array('default'), 'answer', $order_dir );
2243
  }
2244
  elseif( 'random' == $poll_options['sorting_answers'] ) {
2245
- $answers = self::get_poll_answers( $poll_id, array('default'), 'rand()' );
2246
  }
2247
  elseif( 'votes' == $poll_options['sorting_answers'] ) {
2248
  $order_dir = 'asc';
2249
  if( isset( $poll_options['sorting_answers_direction'] ) )
2250
  $order_dir = ('asc' == $poll_options['sorting_answers_direction']) ? 'asc' : 'desc';
2251
- $answers = self::get_poll_answers( $poll_id, array('default'), 'votes', $order_dir );
2252
  }
2253
  else {
2254
- $answers = self::get_poll_answers( $poll_id );
 
 
 
2255
  }
2256
  }
2257
- else
2258
- $answers = self::get_poll_answers( $poll_id );
 
 
 
 
2259
  $multiple_answers = false;
2260
  if( isset( $poll_options['allow_multiple_answers'] ) )
2261
  if ( 'yes' == $poll_options['allow_multiple_answers'] )
@@ -2318,6 +2467,7 @@
2318
  FROM ".$wpdb->yop_poll_logs."
2319
  WHERE answer_id = %d
2320
  GROUP BY other_answer_value
 
2321
  LIMIT %d, %d
2322
  ",
2323
  $answer_id,
@@ -2382,6 +2532,20 @@
2382
  return $wpdb->get_var( $sql );
2383
  }
2384
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2385
  public static function sort_answers_by_votes_asc_callback( $a, $b ) {
2386
  if ( intval( $a['votes'] ) == intval( $b['votes'] ) )
2387
  return 0;
@@ -2416,9 +2580,9 @@
2416
  private static function display_poll_result_votes ( $answer = array(), $poll_options = array() ) {
2417
  if ( 'votes-number' == $poll_options['view_results_type'] || 'votes-number-and-percentages' == $poll_options['view_results_type'] )
2418
  if ( '1' == $answer['votes'] )
2419
- return $answer['votes'].' '.__( 'vote', 'yop_poll' );
2420
  else
2421
- return $answer['votes'].' '.__( 'votes', 'yop_poll' );
2422
  }
2423
 
2424
  private static function display_poll_result_percentages ( $answer = array(), $poll_options = array() ) {
750
  return $this->poll;
751
  }
752
 
753
+ public static function get_poll_answers( $poll_id, $types = array( 'default' ), $order = 'id', $order_dir = '', $include_others = false, $percentages_decimals = 0 ) {
754
  global $wpdb;
755
+
756
+ if( $include_others ) {
757
+ $types = array_diff( $types, array( 'other' ) );
758
+ }
759
+
760
  $type_sql = '';
761
  if ( count( $types ) > 0 ) {
762
  $type_sql .= ' AND type in (';
782
  ),
783
  ARRAY_A
784
  );
785
+
786
+ if ( $include_others ) {
787
+ $other_answer_details = $wpdb->get_row(
788
+ $wpdb -> prepare(
789
+ "
790
+ SELECT *
791
+ FROM ".$wpdb->yop_poll_answers."
792
+ WHERE poll_id = %d AND type = 'other' ",
793
+ $poll_id
794
+ ),
795
+ ARRAY_A
796
+ );
797
+
798
+ $other_answers_values = self::get_other_answers_votes( $other_answer_details['id'] );
799
+ if ( count( $other_answers_values ) > 0 ) {
800
+ if ( 'id' == $order && 'desc' == $order_dir )
801
+ $interval = range( count( $other_answers_values ) - 1, 0, -1 );
802
+ else
803
+ $interval = range( 0, count( $other_answers_values ) - 1, 1 );
804
+ for( $i = 0; $i < count( $other_answers_values ); $i++ ) {
805
+ $answers[] =
806
+ array(
807
+ 'id' => $other_answer_details['id'],
808
+ 'poll_id' => $poll_id,
809
+ 'answer' => $other_answers_values[ $interval[ $i ] ]['other_answer_value'],
810
+ 'votes' => $other_answers_values[ $interval[ $i ] ]['votes'],
811
+ 'status' => 'active',
812
+ 'type' => 'other'
813
+ );
814
+ }
815
+ }
816
+ else {
817
+ $answers[] = $other_answer_details;
818
+ }
819
+ }
820
  $total_votes = self::get_sum_poll_votes( $poll_id );
821
  if( count( $answers ) > 0 ) {
822
  for( $i = 0; $i < count ( $answers ); $i++ ) {
823
  if( 0 == intval( $total_votes ) )
824
  $answers[$i]['procentes'] = 0;
825
+ else {
826
+ $answers[$i]['procentes'] = round( ( intval( $answers[$i]['votes']) / intval( $total_votes ) * 100 ), $percentages_decimals ) ;
827
+ if ( 0 < $answers[$i]['procentes'] )
828
+ $answers[$i]['procentes'] = number_format( $answers[$i]['procentes'], $percentages_decimals );
829
+ }
830
  }
831
  }
832
+
833
  if ( $is_votes_sort ) {
834
  $order_dir = ( '' == $order_dir ) ? 'asc' : $order_dir;
835
  usort($answers, array( 'Yop_Poll_Model', "sort_answers_by_votes_".$order_dir."_callback" ) );
836
  }
837
+ if ( $include_others ) {
838
+ if ( 'answer' == $order ) {
839
+ $order_dir = ( '' == $order_dir ) ? 'asc' : $order_dir;
840
+ usort($answers, array( 'Yop_Poll_Model', "sort_answers_alphabetical_".$order_dir."_callback" ) );
841
+ }
842
+
843
+ if ( 'rand()' == $order ) {
844
+ $interval = range( 0, count( $answers ) - 1, 1 );
845
+ shuffle( $interval );
846
+ $new_answers = array();
847
+ foreach ( $interval as $number ) {
848
+ $new_answers[] = $answers[ $number ];
849
+ }
850
+ $answers = $new_answers;
851
+ }
852
+ }
853
  return $answers;
854
  }
855
 
856
+ public static function get_count_poll_answers( $poll_id, $types = array( 'default' ), $include_others = false ) {
857
+ global $wpdb;
858
+
859
+ $answers_no = 0;
860
+ $other_answers_no = 0;
861
+
862
+ if( $include_others ) {
863
+ $types = array_diff( $types, array( 'other' ) );
864
+ }
865
+
866
+ $type_sql = '';
867
+ if ( count( $types ) > 0 ) {
868
+ $type_sql .= ' AND type in (';
869
+ foreach ( $types as $type ) {
870
+ $type_sql .= "'".$type."',";
871
+ }
872
+ $type_sql = trim ( $type_sql, ',' );
873
+ $type_sql .= ' ) ';
874
+ }
875
+
876
+ $answers_no = $wpdb->get_var(
877
+ $wpdb -> prepare(
878
+ "
879
+ SELECT count(*)
880
+ FROM ".$wpdb->yop_poll_answers."
881
+ WHERE poll_id = %d ".$type_sql,
882
+ $poll_id
883
+ )
884
+ );
885
+
886
+ if ( $include_others ) {
887
+ $other_answer_details = $wpdb->get_row(
888
+ $wpdb -> prepare(
889
+ "
890
+ SELECT *
891
+ FROM ".$wpdb->yop_poll_answers."
892
+ WHERE poll_id = %d AND type = 'other' ",
893
+ $poll_id
894
+ ),
895
+ ARRAY_A
896
+ );
897
+
898
+ $other_answers_no = count( self::get_other_answers_votes( $other_answer_details['id'] ) );
899
+ }
900
+
901
+ return $answers_no + $other_answers_no;
902
+ }
903
+
904
  public static function get_poll_answer_by_id( $answer_id ) {
905
  global $wpdb;
906
  $answer = $wpdb->get_row(
1366
  ";
1367
  $sql .= $sql_search;
1368
  return $wpdb->get_var( $sql );
1369
+ }
 
1370
 
1371
  public static function get_bans_filter_search ( $orderby = 'id', $order = 'desc' , $search = array( 'fields' => array(), 'value' => NULL ), $type = NULL, $poll_id = NULL, $offset = 0, $per_page = 99999999 ) {
1372
  global $wpdb;
2072
  $poll_id = $this->poll['id'];
2073
  if( ! $poll_id )
2074
  return '';
2075
+ $poll_details = $this->poll;
2076
+ $poll_options = $this->poll_options;
2077
+ $template_id = $poll_options['template'];
2078
+ $display_other_answers_values = false;
2079
+ if ( isset( $poll_options['display_other_answers_values'] ) ) {
2080
+ if ( 'yes' == $poll_options['display_other_answers_values'] )
2081
+ $display_other_answers_values = true;
2082
+ else
2083
+ $display_other_answers_values = false;
2084
+ }
2085
  if ( '' == $template_id ) {
2086
  $default_template = self::get_default_template();
2087
  $template_id = $default_template['id'] ? $default_template['id'] : 0;
2089
  $answers_tabulated_cols = 1;
2090
  $results_tabulated_cols = 1;
2091
  if ( 'orizontal' == $poll_options['display_answers'] ) {
2092
+ $ans_no = self::get_count_poll_answers( $poll_id, array( 'default', 'other' ) ) ;
2093
  if( $ans_no > 0 )
2094
  $answers_tabulated_cols = $ans_no;
2095
  }
2096
  if ( 'orizontal' == $poll_options['display_results'] ) {
2097
+ $ans_no = self::get_count_poll_answers( $poll_id, array( 'default', 'other' ), $display_other_answers_values ) ;
2098
  if( $ans_no > 0 )
2099
  $results_tabulated_cols = $ans_no;
2100
  }
2131
  $template = $template_details['before_vote_template'];
2132
  if ( 'before' == $poll_options['view_results'] )
2133
  $template = str_ireplace( '%POLL-ANSWER-RESULT-LABEL%', $poll_options['answer_result_label'], $template );
2134
+ $template = str_ireplace( '%POLL-VOTE-BUTTON%', '<button class="yop_poll_vote_button" id="yop_poll_vote-button-'.$poll_id.'" onclick="yop_poll_do_vote(\''.$poll_id.'\'); return false;">'.$poll_options['vote_button_label'].'</button>', $template );
2135
  }
2136
  else {
2137
  $template = $template_details['after_vote_template'];
2217
  ( 'after-poll-end-date' == $poll_options['view_results'] && self::get_mysql_curent_date() >= $this -> poll['end_date'] )
2218
  ) && 'never' != $poll_options['view_results']
2219
  ) {
2220
+ $display_other_answers_values = false;
2221
+ if ( 'yes' == $poll_options['display_other_answers_values'] )
2222
+ $display_other_answers_values = true;
2223
+ else
2224
+ $display_other_answers_values = false;
2225
+
2226
+ $percentages_decimals = 0;
2227
+ if ( isset( $poll_options['percentages_decimals'] ) )
2228
+ $percentages_decimals = $poll_options['percentages_decimals'];
2229
  if( isset( $poll_options['sorting_results'] ) ) {
2230
  if( 'exact' == $poll_options['sorting_results'] ) {
2231
+ $order_dir = 'asc';
2232
+ if( isset( $poll_options['sorting_results_direction'] ) )
2233
+ $order_dir = ('asc' == $poll_options['sorting_results_direction']) ? 'asc' : 'desc';
2234
+ $answers = self::get_poll_answers( $poll_id, array('default', 'other'), 'id', $order_dir, $display_other_answers_values, $percentages_decimals );
2235
  }
2236
  elseif( 'alphabetical' == $poll_options['sorting_results'] ) {
2237
  $order_dir = 'asc';
2238
  if( isset( $poll_options['sorting_results_direction'] ) )
2239
  $order_dir = ('asc' == $poll_options['sorting_results_direction']) ? 'asc' : 'desc';
2240
+ $answers = self::get_poll_answers( $poll_id, array('default', 'other'), 'answer', $order_dir, $display_other_answers_values, $percentages_decimals );
2241
  }
2242
  elseif( 'random' == $poll_options['sorting_results'] ) {
2243
+ $answers = self::get_poll_answers( $poll_id, array('default', 'other'), 'rand()', '', $display_other_answers_values, $percentages_decimals );
2244
  }
2245
  elseif( 'votes' == $poll_options['sorting_results'] ) {
2246
  $order_dir = 'asc';
2247
  if( isset( $poll_options['sorting_results_direction'] ) )
2248
  $order_dir = ('asc' == $poll_options['sorting_results_direction']) ? 'asc' : 'desc';
2249
+ $answers = self::get_poll_answers( $poll_id, array('default', 'other'), 'votes', $order_dir, $display_other_answers_values, $percentages_decimals );
2250
  }
2251
  else {
2252
+ $order_dir = 'asc';
2253
+ if( isset( $poll_options['sorting_results_direction'] ) )
2254
+ $order_dir = ('asc' == $poll_options['sorting_results_direction']) ? 'asc' : 'desc';
2255
+ $answers = self::get_poll_answers( $poll_id, array('default', 'other'), 'id', $order_dir, $display_other_answers_values, $percentages_decimals );
2256
  }
2257
  }
2258
+ else {
2259
+ $order_dir = 'asc';
2260
+ if( isset( $poll_options['sorting_results_direction'] ) )
2261
+ $order_dir = ('asc' == $poll_options['sorting_results_direction']) ? 'asc' : 'desc';
2262
+ $answers = self::get_poll_answers( $poll_id, array('default', 'other'), 'id', $order_dir, $display_other_answers_values, $percentages_decimals );
2263
+ }
2264
  if( count( $answers ) > 0 ) {
2265
  foreach( $answers as $answer ) {
2266
  $poll_options = $this->poll_options;
2311
  $poll_options = $this->poll_options;
2312
  $return_string = '';
2313
  $is_voted = $this->is_voted();
2314
+ $percentages_decimals = 0;
2315
+ if ( isset( $poll_options['percentages_decimals'] ) )
2316
+ $percentages_decimals = $poll_options['percentages_decimals'];
2317
  if( ! $is_voted ) {
2318
  $multiple_answers = false;
2319
  if( isset( $poll_options['allow_multiple_answers'] ) )
2334
  );
2335
  $other_answer_id = self::insert_answer_to_database( $answer );
2336
  }
2337
+ $other_answer = self::get_poll_answers( $poll_id, array( 'other'), 'id', '', false, $percentages_decimals );
2338
  if( $multiple_answers )
2339
  $temp_string = str_ireplace( '%POLL-OTHER-ANSWER-CHECK-INPUT%', '<input type="checkbox" value="'.$other_answer[0]['id'].'" name="yop_poll_answer['.$other_answer[0]['id'].']" id="yop-poll-answer-'.$other_answer[0]['id'].'" />', $m[5] );
2340
  else
2366
  $poll_options = $this->poll_options;
2367
  $return_string = '';
2368
  $is_voted = $this->is_voted();
2369
+ $percentages_decimals = 0;
2370
+ if ( isset( $poll_options['percentages_decimals'] ) )
2371
+ $percentages_decimals = $poll_options['percentages_decimals'];
2372
  if( ! $is_voted ) {
2373
  if( isset( $poll_options['sorting_answers'] ) ) {
2374
  if( 'exact' == $poll_options['sorting_answers'] ) {
2375
+ $order_dir = 'asc';
2376
+ if( isset( $poll_options['sorting_answers_direction'] ) )
2377
+ $order_dir = ('asc' == $poll_options['sorting_answers_direction']) ? 'asc' : 'desc';
2378
+ $answers = self::get_poll_answers( $poll_id, array( 'default'), 'id', $order_dir, false, $percentages_decimals );
2379
  }
2380
  elseif( 'alphabetical' == $poll_options['sorting_answers'] ) {
2381
  $order_dir = 'asc';
2382
  if( isset( $poll_options['sorting_answers_direction'] ) )
2383
  $order_dir = ('asc' == $poll_options['sorting_answers_direction']) ? 'asc' : 'desc';
2384
+ $answers = self::get_poll_answers( $poll_id, array('default'), 'answer', $order_dir, false, $percentages_decimals );
2385
  }
2386
  elseif( 'random' == $poll_options['sorting_answers'] ) {
2387
+ $answers = self::get_poll_answers( $poll_id, array('default'), 'rand()', '', false, $percentages_decimals );
2388
  }
2389
  elseif( 'votes' == $poll_options['sorting_answers'] ) {
2390
  $order_dir = 'asc';
2391
  if( isset( $poll_options['sorting_answers_direction'] ) )
2392
  $order_dir = ('asc' == $poll_options['sorting_answers_direction']) ? 'asc' : 'desc';
2393
+ $answers = self::get_poll_answers( $poll_id, array('default'), 'votes', $order_dir, '', $percentages_decimals );
2394
  }
2395
  else {
2396
+ $order_dir = 'asc';
2397
+ if( isset( $poll_options['sorting_answers_direction'] ) )
2398
+ $order_dir = ('asc' == $poll_options['sorting_answers_direction']) ? 'asc' : 'desc';
2399
+ $answers = self::get_poll_answers( $poll_id, array( 'default'), 'id', $order_dir, false, $percentages_decimals );
2400
  }
2401
  }
2402
+ else {
2403
+ $order_dir = 'asc';
2404
+ if( isset( $poll_options['sorting_answers_direction'] ) )
2405
+ $order_dir = ('asc' == $poll_options['sorting_answers_direction']) ? 'asc' : 'desc';
2406
+ $answers = self::get_poll_answers( $poll_id, array( 'default'), 'id', $order_dir, false, $percentages_decimals );
2407
+ }
2408
  $multiple_answers = false;
2409
  if( isset( $poll_options['allow_multiple_answers'] ) )
2410
  if ( 'yes' == $poll_options['allow_multiple_answers'] )
2467
  FROM ".$wpdb->yop_poll_logs."
2468
  WHERE answer_id = %d
2469
  GROUP BY other_answer_value
2470
+ ORDER BY id
2471
  LIMIT %d, %d
2472
  ",
2473
  $answer_id,
2532
  return $wpdb->get_var( $sql );
2533
  }
2534
 
2535
+ public static function sort_answers_alphabetical_asc_callback( $a, $b ) {
2536
+ $cmp = strcmp( $a['answer'], $b['answer'] );
2537
+ if ( $cmp == 0 )
2538
+ return 0;
2539
+ return ( $cmp < 0 ) ? -1 : 1;
2540
+ }
2541
+
2542
+ public static function sort_answers_alphabetical_desc_callback( $a, $b ) {
2543
+ $cmp = strcmp( $a['answer'], $b['answer'] );
2544
+ if ( $cmp == 0 )
2545
+ return 0;
2546
+ return ( $cmp < 0 ) ? 1 : -1;
2547
+ }
2548
+
2549
  public static function sort_answers_by_votes_asc_callback( $a, $b ) {
2550
  if ( intval( $a['votes'] ) == intval( $b['votes'] ) )
2551
  return 0;
2580
  private static function display_poll_result_votes ( $answer = array(), $poll_options = array() ) {
2581
  if ( 'votes-number' == $poll_options['view_results_type'] || 'votes-number-and-percentages' == $poll_options['view_results_type'] )
2582
  if ( '1' == $answer['votes'] )
2583
+ return $answer['votes'].' '.$poll_options['singular_answer_result_votes_number_label'];
2584
  else
2585
+ return $answer['votes'].' '.$poll_options['plural_answer_result_votes_number_label'];
2586
  }
2587
 
2588
  private static function display_poll_result_percentages ( $answer = array(), $poll_options = array() ) {
js/yop-poll-admin-add-new.js CHANGED
@@ -9,9 +9,11 @@ jQuery(document).ready(function(jQuery) {
9
  });
10
  jQuery( "#yop-poll-allow-other-answers-yes" ).click( function () {
11
  jQuery( '#yop-poll-other-answers-label-div' ).show();
 
12
  });
13
  jQuery( "#yop-poll-allow-other-answers-no" ).click( function () {
14
  jQuery( '#yop-poll-other-answers-label-div' ).hide();
 
15
  });
16
  jQuery( "#yop-poll-display-answers-vertical" ).click( function () {
17
  jQuery( '#yop-poll-display-answers-tabulated-div' ).hide();
9
  });
10
  jQuery( "#yop-poll-allow-other-answers-yes" ).click( function () {
11
  jQuery( '#yop-poll-other-answers-label-div' ).show();
12
+ jQuery( '#yop-poll-display-other-answers-values-div' ).show();
13
  });
14
  jQuery( "#yop-poll-allow-other-answers-no" ).click( function () {
15
  jQuery( '#yop-poll-other-answers-label-div' ).hide();
16
+ jQuery( '#yop-poll-display-other-answers-values-div' ).hide();
17
  });
18
  jQuery( "#yop-poll-display-answers-vertical" ).click( function () {
19
  jQuery( '#yop-poll-display-answers-tabulated-div' ).hide();
js/yop-poll-admin-options.js CHANGED
@@ -1,9 +1,11 @@
1
  jQuery(document).ready(function(jQuery) {
2
  jQuery( "#yop-poll-allow-other-answers-yes" ).click( function () {
3
  jQuery( '#yop-poll-other-answers-label-div' ).show();
 
4
  });
5
  jQuery( "#yop-poll-allow-other-answers-no" ).click( function () {
6
  jQuery( '#yop-poll-other-answers-label-div' ).hide();
 
7
  });
8
  jQuery( "#yop-poll-display-answers-vertical" ).click( function () {
9
  jQuery( '#yop-poll-display-answers-tabulated-div' ).hide();
1
  jQuery(document).ready(function(jQuery) {
2
  jQuery( "#yop-poll-allow-other-answers-yes" ).click( function () {
3
  jQuery( '#yop-poll-other-answers-label-div' ).show();
4
+ jQuery( '#yop-poll-display-other-answers-values-div' ).show();
5
  });
6
  jQuery( "#yop-poll-allow-other-answers-no" ).click( function () {
7
  jQuery( '#yop-poll-other-answers-label-div' ).hide();
8
+ jQuery( '#yop-poll-display-other-answers-values-div' ).hide();
9
  });
10
  jQuery( "#yop-poll-display-answers-vertical" ).click( function () {
11
  jQuery( '#yop-poll-display-answers-tabulated-div' ).hide();
readme.txt CHANGED
@@ -136,6 +136,10 @@ This plugin was especially designed for flexibility and it is very easy to use.
136
 
137
  == Changelog ==
138
 
 
 
 
 
139
  = 1.5 =
140
  * Fixed sort_answers_by_votes_asc_callback() bug
141
 
136
 
137
  == Changelog ==
138
 
139
+ = 1.6 =
140
+ * Added ability to change the text for Vote button
141
+ * Added ability to display the answers for Others field
142
+
143
  = 1.5 =
144
  * Fixed sort_answers_by_votes_asc_callback() bug
145
 
yop_poll.php CHANGED
@@ -5,10 +5,10 @@
5
  Description: Use a full option polling functionality to get the answers you need. YOP Poll is the perfect, easy to use plugin for your WordPress website.
6
  Author: yourownprogrammer
7
  Author URL: http://www.yourownprogrammer.com
8
- Version: 1.5
9
  */
10
- define( 'YOP_POLL_WP_VERSION', '3.4.2' );
11
- define( 'YOP_POLL_VERSION', '1.5' );
12
  define( 'YOP_POLL_PATH', plugin_dir_path( __FILE__ ) );
13
  define( 'YOP_POLL_URL', plugins_url( '', __FILE__ ) );
14
  define( 'YOP_POLL_PLUGIN_FILE', plugin_basename( __FILE__ ) );
@@ -23,11 +23,11 @@
23
  require_once( ABSPATH . WPINC . '/pluggable.php' );
24
  require_once( YOP_POLL_INC . '/public-admin.php' );
25
  require_once( YOP_POLL_INC . '/widget.php' );
26
- require_once( YOP_POLL_INC . '/theme-functions.php' );
27
 
28
  #Yop Poll Tables Name
29
  global $wpdb;
30
- $wpdb->yop_poll_version = "1.5";
31
  $wpdb->yop_polls = $wpdb->prefix . 'yop_polls';
32
  $wpdb->yop_poll_answers = $wpdb->prefix . 'yop_poll_answers';
33
  $wpdb->yop_poll_templates = $wpdb->prefix . 'yop_poll_templates';
@@ -59,7 +59,7 @@
59
  );
60
 
61
  $yop_poll_public_admin = new Yop_Poll_Public_Admin( new Yop_Poll_Config( $yop_poll_config_data ) );
62
- $yop_poll = new $yop_poll_current_class( new Yop_Poll_Config( $yop_poll_config_data ) );
63
 
64
 
65
  function yop_poll_uninstall() {
5
  Description: Use a full option polling functionality to get the answers you need. YOP Poll is the perfect, easy to use plugin for your WordPress website.
6
  Author: yourownprogrammer
7
  Author URL: http://www.yourownprogrammer.com
8
+ Version: 1.6
9
  */
10
+ define( 'YOP_POLL_WP_VERSION', '3.3.0' );
11
+ define( 'YOP_POLL_VERSION', '1.6' );
12
  define( 'YOP_POLL_PATH', plugin_dir_path( __FILE__ ) );
13
  define( 'YOP_POLL_URL', plugins_url( '', __FILE__ ) );
14
  define( 'YOP_POLL_PLUGIN_FILE', plugin_basename( __FILE__ ) );
23
  require_once( ABSPATH . WPINC . '/pluggable.php' );
24
  require_once( YOP_POLL_INC . '/public-admin.php' );
25
  require_once( YOP_POLL_INC . '/widget.php' );
26
+ require_once( YOP_POLL_INC . '/theme-functions.php' );
27
 
28
  #Yop Poll Tables Name
29
  global $wpdb;
30
+ $wpdb->yop_poll_version = YOP_POLL_VERSION;
31
  $wpdb->yop_polls = $wpdb->prefix . 'yop_polls';
32
  $wpdb->yop_poll_answers = $wpdb->prefix . 'yop_poll_answers';
33
  $wpdb->yop_poll_templates = $wpdb->prefix . 'yop_poll_templates';
59
  );
60
 
61
  $yop_poll_public_admin = new Yop_Poll_Public_Admin( new Yop_Poll_Config( $yop_poll_config_data ) );
62
+ $yop_poll = new $yop_poll_current_class( new Yop_Poll_Config( $yop_poll_config_data ) );
63
 
64
 
65
  function yop_poll_uninstall() {