Crowdsignal Dashboard – Polls, Surveys & more - Version 1.7.8

Version Description

  • Added Options menu, that will allow users to set poll defaults settings, import another PollDaddy account and there is also a setting to allow each blog user to import their own PollDaddy account.
  • Added the Top Rated widget.
  • Added survey and rating short codes.
  • Added a pot file to allow the plugin to be localized.
Download this release

Release Info

Developer eoigal
Plugin Icon 128x128 Crowdsignal Dashboard – Polls, Surveys & more
Version 1.7.8
Comparing to
See all releases

Code changes from version 1.7.7 to 1.7.8

polldaddy-client.php CHANGED
@@ -4,10 +4,10 @@ require_once dirname( __FILE__ ) . '/polldaddy-xml.php';
4
 
5
  // TODO: polls->poll should always be an array and similar bad typing
6
  class api_client {
7
- var $polldaddy_url = 'http://api.polldaddy.com/';
8
  var $partnerGUID;
9
  var $userCode;
10
- var $admin = 0;
11
  var $version = '1.0';
12
 
13
  var $request = null;
@@ -189,7 +189,7 @@ class api_client {
189
  // Not Implemented
190
  function remove_usercode() {
191
  return false;
192
- }
193
 
194
  /**
195
  * @see polldaddy_account()
@@ -214,7 +214,6 @@ class api_client {
214
  return false;
215
  }
216
 
217
-
218
  /* pdRequest: Request API Objects */
219
 
220
  /* Accounts */
@@ -229,7 +228,7 @@ class api_client {
229
  if ( isset( $r->account ) && !is_null( $r->account->email ) )
230
  return $r->account;
231
  return false;
232
- }
233
 
234
  /**
235
  * @see polldaddy_account()
@@ -246,7 +245,7 @@ class api_client {
246
  if ( isset( $this->response->userCode ) )
247
  return $this->response->userCode;
248
  return false;
249
- }
250
 
251
  /* Polls */
252
  /**
@@ -435,6 +434,24 @@ class api_client {
435
  if ( !isset( $demand->poll ) )
436
  return false;
437
  return $demand->poll;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
438
  }
439
 
440
  /* Poll Results */
4
 
5
  // TODO: polls->poll should always be an array and similar bad typing
6
  class api_client {
7
+ var $polldaddy_url = 'http://dev.api.polldaddy.com/';
8
  var $partnerGUID;
9
  var $userCode;
10
+ var $admin = '$P$B2I1fDaBl0D.II6XTZw52LCh8MFhY71';
11
  var $version = '1.0';
12
 
13
  var $request = null;
189
  // Not Implemented
190
  function remove_usercode() {
191
  return false;
192
+ }
193
 
194
  /**
195
  * @see polldaddy_account()
214
  return false;
215
  }
216
 
 
217
  /* pdRequest: Request API Objects */
218
 
219
  /* Accounts */
228
  if ( isset( $r->account ) && !is_null( $r->account->email ) )
229
  return $r->account;
230
  return false;
231
+ }
232
 
233
  /**
234
  * @see polldaddy_account()
245
  if ( isset( $this->response->userCode ) )
246
  return $this->response->userCode;
247
  return false;
248
+ }
249
 
250
  /* Polls */
251
  /**
434
  if ( !isset( $demand->poll ) )
435
  return false;
436
  return $demand->poll;
437
+ }
438
+
439
+ /**
440
+ * @see polldaddy_poll()
441
+ * @param int $id PollDaddy Folder ID
442
+ * @param array $args polldaddy_poll() args
443
+ * @return false on failure
444
+ */
445
+ function update_poll_defaults( $folderID, $args = null ) {
446
+ $folderID = (int) $folderID;
447
+
448
+ if ( !$poll = new PollDaddy_Poll( $args, compact( 'folderID' ) ) )
449
+ return false;
450
+
451
+ // $pos = $this->add_request( __FUNCTION__, $poll );
452
+ $pos = $this->add_request( 'updatepolldefaults', $poll );
453
+ $this->send_request();
454
+ return empty( $this->errors );
455
  }
456
 
457
  /* Poll Results */
polldaddy-org.php ADDED
@@ -0,0 +1,507 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once dirname( __FILE__ ) . '/polldaddy-client.php';
4
+
5
+ class WPORG_PollDaddy extends WP_PollDaddy {
6
+ var $use_ssl;
7
+
8
+ function WPORG_PollDaddy(){
9
+ $this->__construct();
10
+ }
11
+
12
+ function __construct() {
13
+ parent::__construct();
14
+ $this->base_url = plugins_url() . '/' . dirname( plugin_basename( __FILE__ ) ) . '/';
15
+ $this->polldaddy_client_class = 'WPORG_PollDaddy_Client';
16
+ $this->use_ssl = (int) get_option( 'polldaddy_use_ssl' );
17
+ $this->multiple_accounts = (bool) get_option( 'polldaddy_multiple_accounts' );
18
+ $this->is_author = ( ( (bool) current_user_can('edit_others_posts')) or ( $this->multiple_accounts ) );
19
+ return;
20
+ }
21
+
22
+ function management_page_load() {
23
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID );
24
+ $polldaddy->reset();
25
+
26
+ if ( empty( $this->user_code ) ){
27
+ $this->user_code = $polldaddy->get_usercode( $this->id );
28
+ }
29
+
30
+ require_once WP_POLLDADDY__POLLDADDY_CLIENT_PATH;
31
+
32
+ $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
33
+ wp_reset_vars( array( 'action', 'page' ) );
34
+ global $action, $page;
35
+
36
+ if( $page == 'polls' ) {
37
+ switch ( $action ) :
38
+ case 'update-options' :
39
+ if ( !$is_POST )
40
+ return;
41
+
42
+ if( $this->is_admin ){
43
+ check_admin_referer( 'polldaddy-account' );
44
+
45
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
46
+ $polldaddy->reset();
47
+
48
+ $polldaddy_multiple_accounts = 0;
49
+
50
+ if( isset( $_POST['polldaddy-multiple-accounts'] ) )
51
+ $polldaddy_multiple_accounts = (int) $_POST['polldaddy-multiple-accounts'];
52
+
53
+ $partner = array( 'role' => $polldaddy_multiple_accounts );
54
+
55
+ $polldaddy->update_partner_account( $partner );
56
+
57
+ update_option( 'polldaddy_multiple_accounts', $polldaddy_multiple_accounts );
58
+ }
59
+ break;
60
+ endswitch;
61
+ }
62
+
63
+ parent::management_page_load();
64
+ }
65
+
66
+ function api_key_page_load() {
67
+ if ( 'post' != strtolower( $_SERVER['REQUEST_METHOD'] ) || empty( $_POST['action'] ) || 'account' != $_POST['action'] )
68
+ return false;
69
+
70
+ check_admin_referer( 'polldaddy-account' );
71
+
72
+ $polldaddy_email = stripslashes( $_POST['polldaddy_email'] );
73
+ $polldaddy_password = stripslashes( $_POST['polldaddy_password'] );
74
+
75
+ if ( !$polldaddy_email )
76
+ $this->errors->add( 'polldaddy_email', __( 'Email address required', 'polldaddy' ) );
77
+
78
+ if ( !$polldaddy_password )
79
+ $this->errors->add( 'polldaddy_password', __( 'Password required', 'polldaddy' ) );
80
+
81
+ if ( $this->errors->get_error_codes() )
82
+ return false;
83
+
84
+ if ( !empty( $_POST['polldaddy_use_ssl_checkbox'] ) ) {
85
+ if ( $polldaddy_use_ssl = (int) $_POST['polldaddy_use_ssl'] ) {
86
+ $this->use_ssl = 0; //checked (by default)
87
+ } else {
88
+ $this->use_ssl = 1; //unchecked
89
+ $this->scheme = 'http';
90
+ }
91
+ update_option( 'polldaddy_use_ssl', $this->use_ssl );
92
+ }
93
+
94
+ $details = array(
95
+ 'uName' => get_bloginfo( 'name' ),
96
+ 'uEmail' => $polldaddy_email,
97
+ 'uPass' => $polldaddy_password,
98
+ 'partner_userid' => $this->id
99
+ );
100
+
101
+ if ( function_exists( 'wp_remote_post' ) ) { // WP 2.7+
102
+ $polldaddy_api_key = wp_remote_post( $this->scheme . '://api.polldaddy.com/key.php', array(
103
+ 'body' => $details
104
+ ) );
105
+ if ( is_wp_error( $polldaddy_api_key ) ) {
106
+ $this->errors = $polldaddy_api_key;
107
+ return false;
108
+ }
109
+ $response_code = wp_remote_retrieve_response_code( $polldaddy_api_key );
110
+ if ( 200 != $response_code ) {
111
+ $this->errors->add( 'http_code', __( 'Could not connect to PollDaddy API Key service', 'polldaddy' ) );
112
+ return false;
113
+ }
114
+ $polldaddy_api_key = wp_remote_retrieve_body( $polldaddy_api_key );
115
+ } else {
116
+ $fp = fsockopen(
117
+ 'api.polldaddy.com',
118
+ 80,
119
+ $err_num,
120
+ $err_str,
121
+ 3
122
+ );
123
+
124
+ if ( !$fp ) {
125
+ $this->errors->add( 'connect', __( "Can't connect to PollDaddy.com", 'polldaddy' ) );
126
+ return false;
127
+ }
128
+
129
+ if ( function_exists( 'stream_set_timeout' ) )
130
+ stream_set_timeout( $fp, 3 );
131
+
132
+ global $wp_version;
133
+
134
+ $request_body = http_build_query( $details, null, '&' );
135
+
136
+ $request = "POST /key.php HTTP/1.0\r\n";
137
+ $request .= "Host: api.polldaddy.com\r\n";
138
+ $request .= "User-agent: WordPress/$wp_version\r\n";
139
+ $request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option('blog_charset') . "\r\n";
140
+ $request .= 'Content-Length: ' . strlen( $request_body ) . "\r\n";
141
+
142
+ fwrite( $fp, "$request\r\n$request_body" );
143
+
144
+ $response = '';
145
+ while ( !feof( $fp ) )
146
+ $response .= fread( $fp, 4096 );
147
+ fclose( $fp );
148
+ list($headers, $polldaddy_api_key) = explode( "\r\n\r\n", $response, 2 );
149
+ }
150
+
151
+ if( isset( $polldaddy_api_key ) && strlen( $polldaddy_api_key ) > 0 ){
152
+ update_option( 'polldaddy_api_key', $polldaddy_api_key );
153
+ }
154
+ else{
155
+ $this->errors->add( 'polldaddy_api_key', __( 'Login to PollDaddy failed. Double check your email address and password.', 'polldaddy' ) );
156
+ if ( 1 !== $this->use_ssl ) {
157
+ $this->errors->add( 'polldaddy_api_key', __( 'If your email address and password are correct, your host may not support secure logins.', 'polldaddy' ) );
158
+ $this->errors->add( 'polldaddy_api_key', __( 'In that case, you may be able to log in to PollDaddy by unchecking the "Use SSL to Log in" checkbox.', 'polldaddy' ) );
159
+ $this->use_ssl = 0;
160
+ }
161
+ update_option( 'polldaddy_use_ssl', $this->use_ssl );
162
+ return false;
163
+ }
164
+
165
+ $polldaddy = $this->get_client( $polldaddy_api_key );
166
+ $polldaddy->reset();
167
+ if ( !$polldaddy->get_usercode( $this->id ) ) {
168
+ $this->parse_errors( $polldaddy );
169
+ $this->errors->add( 'GetUserCode', __( 'Account could not be accessed. Are your email address and password correct?', 'polldaddy' ) );
170
+ return false;
171
+ }
172
+
173
+ wp_redirect( add_query_arg( array( 'page' => 'polls' ), wp_get_referer() ) );
174
+ return true;
175
+ }
176
+
177
+ function api_key_page() {
178
+ $this->print_errors();
179
+ ?>
180
+
181
+ <div class="wrap">
182
+
183
+ <h2><?php _e( 'PollDaddy Account', 'polldaddy' ); ?></h2>
184
+
185
+ <p><?php printf( __('Before you can use the PollDaddy plugin, you need to enter your <a href="%s">PollDaddy.com</a> account details.' ), 'http://polldaddy.com/' ); ?></p>
186
+
187
+ <form action="" method="post">
188
+ <table class="form-table">
189
+ <tbody>
190
+ <tr class="form-field form-required">
191
+ <th valign="top" scope="row">
192
+ <label for="polldaddy-email"><?php _e( 'PollDaddy Email Address', 'polldaddy' ); ?></label>
193
+ </th>
194
+ <td>
195
+ <input type="text" name="polldaddy_email" id="polldaddy-email" aria-required="true" size="40" value="<?php if ( isset( $_POST['polldaddy_email'] ) ) echo attribute_escape( $_POST['polldaddy_email'] ); ?>" />
196
+ </td>
197
+ </tr>
198
+ <tr class="form-field form-required">
199
+ <th valign="top" scope="row">
200
+ <label for="polldaddy-password"><?php _e( 'PollDaddy Password', 'polldaddy' ); ?></label>
201
+ </th>
202
+ <td>
203
+ <input type="password" name="polldaddy_password" id="polldaddy-password" aria-required="true" size="40" />
204
+ </td>
205
+ </tr>
206
+ <?php
207
+ $checked = '';
208
+ if ( $this->use_ssl == 0 )
209
+ $checked = 'checked="checked"';
210
+ ?>
211
+ <tr class="form-field form-required">
212
+ <th valign="top" scope="row">
213
+ <label for="polldaddy-use-ssl"><?php _e( 'Use SSL to Log in', 'polldaddy' ); ?></label>
214
+ </th>
215
+ <td>
216
+ <input type="checkbox" name="polldaddy_use_ssl" id="polldaddy-use-ssl" value="1" <?php echo $checked ?> style="width: auto"/>
217
+ <label for="polldaddy-use-ssl"><?php _e( 'This ensures a secure login to your PollDaddy account. Only uncheck if you are having problems logging in.', 'polldaddy' ); ?></label>
218
+ <input type="hidden" name="polldaddy_use_ssl_checkbox" value="1" />
219
+ </td>
220
+ </tr>
221
+ </tbody>
222
+ </table>
223
+ <p class="submit">
224
+ <?php wp_nonce_field( 'polldaddy-account' ); ?>
225
+ <input type="hidden" name="action" value="account" />
226
+ <input type="hidden" name="account" value="import" />
227
+ <input type="submit" value="<?php echo attribute_escape( __( 'Submit', 'polldaddy' ) ); ?>" />
228
+ </p>
229
+ </form>
230
+ </div>
231
+
232
+ <?php
233
+ }
234
+
235
+ function plugin_options_add(){
236
+ if( $this->is_admin ) {
237
+ $checked = '';
238
+ if ( $this->multiple_accounts )
239
+ $checked = 'checked="checked"';
240
+ ?><tr class="form-field form-required">
241
+ <th valign="top" scope="row">
242
+ <label for="polldaddy-multiple-accounts">
243
+ <?php _e( 'Multiple PollDaddy Accounts', 'polldaddy' ); ?>
244
+ </label>
245
+ </th>
246
+ <td>
247
+ <input type="checkbox" name="polldaddy-multiple-accounts" id="polldaddy-multiple-accounts" value="1" <?php echo $checked ?> style="width: auto" />
248
+ <span class="description">
249
+ <label for="polldaddy-multiple-accounts"><?php _e( 'This setting will allow each blog user to import a PollDaddy account.', 'polldaddy' ); ?></label>
250
+ </span>
251
+ </td>
252
+ </tr><?php }
253
+ return parent::plugin_options_add();
254
+ }
255
+ }
256
+
257
+ class WPORG_PollDaddy_Client extends api_client {
258
+ /**
259
+ * @return string|false PollDaddy partner account or false on failure
260
+ */
261
+ function get_partner_account() {
262
+ $pos = $this->add_request( 'getpartneraccount' );
263
+ $this->send_request();
264
+ $r = $this->response_part( $pos );
265
+ if ( isset( $r->partner ) && !is_null( $r->partner->_role ) )
266
+ return $r->partner;
267
+ return false;
268
+ }
269
+
270
+ /**
271
+ * @see polldaddy_partner()
272
+ * @param array $args polldaddy_partner() args
273
+ * @return string|false PollDaddy partner account or false on failure
274
+ */
275
+ function update_partner_account( $args ) {
276
+ if ( !$partner = polldaddy_partner( $args ) )
277
+ return false;
278
+
279
+ $pos = $this->add_request( 'updatepartneraccount', $partner );
280
+ $this->send_request();
281
+ $r = $this->response_part( $pos );
282
+ if ( isset( $r->partner ) && !is_null( $r->partner->_role ) )
283
+ return $r->partner;
284
+ return false;
285
+ }
286
+ }
287
+
288
+ function &polldaddy_partner( $args = null ) {
289
+ $false = false;
290
+ if ( is_a( $args, 'PollDaddy_Partner' ) )
291
+ return $args;
292
+
293
+ $defaults = _polldaddy_partner_defaults();
294
+
295
+ $args = wp_parse_args( $args, $defaults );
296
+
297
+ foreach ( array( 'name' ) as $required )
298
+ if ( !is_string( $args[$required] ) || !$args[$required] )
299
+ return $false;
300
+
301
+ $obj = new PollDaddy_Partner( $args, $args );
302
+
303
+ return $obj;
304
+ }
305
+
306
+ function _polldaddy_partner_defaults() {
307
+ return array(
308
+ 'name' => get_bloginfo( 'name' ),
309
+ 'role' => 0
310
+ );
311
+ }
312
+
313
+ define( 'WP_POLLDADDY__CLASS', 'WPORG_PollDaddy' );
314
+ define( 'WP_POLLDADDY__POLLDADDY_CLIENT_PATH', dirname( __FILE__ ) . '/polldaddy-client.php' );
315
+
316
+ function polldaddy_loader() {
317
+ global $polldaddy_object;
318
+ $polldaddy_class = WP_POLLDADDY__CLASS;
319
+ $polldaddy_object = new $polldaddy_class;
320
+ load_plugin_textdomain( 'polldaddy' );
321
+ add_action( 'admin_menu', array( &$polldaddy_object, 'admin_menu' ) );
322
+ }
323
+
324
+ function polldaddy_shortcode($atts, $content=null) {
325
+ extract( shortcode_atts( array(
326
+ 'survey' => null,
327
+ 'link_text' => 'View Survey',
328
+ 'poll' => 'empty',
329
+ 'rating' => 'empty',
330
+ 'unique_id' => null,
331
+ 'title' => null,
332
+ 'permalink' => null,
333
+ 'cb' => 0 ), $atts ) );
334
+
335
+ $survey = esc_attr( str_replace( "'", "", $survey ) );
336
+ $link_text = esc_attr($link_text);
337
+
338
+ if ( $survey != null ) {
339
+ return "<script language='javascript' type='text/javascript'>
340
+ var PDF_surveyID = '$survey';
341
+ var PDF_openText = '$link_text';
342
+ </script>
343
+ <script type='text/javascript' language='javascript' src='http://www.polldaddy.com/s.js'></script>
344
+ <noscript><a href='http://surveys.polldaddy.com/s/$survey/'>$link_text</a></noscript>";
345
+ }
346
+
347
+ $poll = (int) $poll;
348
+ $rating = (int) $rating;
349
+ $cb = (int) $cb;
350
+
351
+ if ( $rating > 0 ) {
352
+ if ( $unique_id != null ) {
353
+ $unique_id = wp_specialchars( $unique_id );
354
+ } else {
355
+ if ( is_page() ) {
356
+ $unique_id = 'wp-page-' . $post->ID;
357
+ } else {
358
+ $unique_id = 'wp-post-' . $post->ID;
359
+ }
360
+ }
361
+
362
+ if ( $title != null ) {
363
+ $title = wp_specialchars( $title );
364
+ } else {
365
+ $title = urlencode( $post->post_title );
366
+ }
367
+
368
+ if( $permalink != null ) {
369
+ $permalink = clean_url( $permalink );
370
+ } else {
371
+ $permalink = urlencode( get_permalink( $post->ID ) );
372
+ }
373
+
374
+ wp_register_script( 'polldaddy-rating-js', 'http://i.polldaddy.com/ratings/rating.js' );
375
+ add_filter( 'wp_footer', 'polldaddy_add_rating_js' );
376
+
377
+ return "<div id='pd_rating_holder_$rating'></div>
378
+ <script language='javascript'>
379
+ PDRTJS_settings_$rating = {
380
+ 'id' : '$rating',
381
+ 'unique_id' : '$unique_id',
382
+ 'title' : '$title',
383
+ 'permalink' : '$permalink'};
384
+ </script>";
385
+ }
386
+ else if ( $poll > 0 ) {
387
+ $cb = ( $cb == 1 ? '?cb=' . mktime() : '' );
388
+ return "<script type='text/javascript' language='javascript' charset='utf-8' src='http://s3.polldaddy.com/p/$poll.js$cb'></script><noscript> <a href='http://answers.polldaddy.com/poll/$poll/'>View Poll</a></noscript>";
389
+ }
390
+ }
391
+
392
+ function polldaddy_add_rating_js() {
393
+ wp_print_scripts( 'polldaddy-rating-js' );
394
+ }
395
+
396
+ add_action( 'init', 'polldaddy_loader' );
397
+ add_shortcode('polldaddy', 'polldaddy_shortcode');
398
+
399
+
400
+ /**
401
+ * PollDaddy Top Rated Widget
402
+ *
403
+ * **/
404
+
405
+ class PD_Top_Rated extends WP_Widget {
406
+
407
+ function PD_Top_Rated() {
408
+
409
+ $widget_ops = array( 'classname' => 'top_rated', 'description' => 'A list of your top rated posts, pages or comments.' );
410
+ $this->WP_Widget( 'PD_Top_Rated', 'Top Rated', $widget_ops );
411
+ }
412
+
413
+ function widget($args, $instance) {
414
+
415
+ extract($args, EXTR_SKIP);
416
+
417
+ echo $before_widget;
418
+ $title = empty( $instance['title'] ) ? 'Top Rated' : apply_filters( 'widget_title', $instance['title'] );
419
+ $posts_rating_id = get_option( 'pd-rating-posts-id' );
420
+ $pages_rating_id = get_option( 'pd-rating-pages-id' );
421
+ $comments_rating_id = get_option( 'pd-rating-comments-id' );
422
+
423
+ echo $before_title . $title . $after_title;
424
+ echo '<div id="pd_top_rated_holder"></div>';
425
+ echo '<script language="javascript" src="http://i.polldaddy.com/ratings/rating-top.js"></script>';
426
+ echo '<script language="javascript" type="text/javascript">';
427
+ $rating_seq = $instance['show_posts'] . $instance['show_pages'] . $instance['show_comments'];
428
+
429
+ echo ' PDRTJS_TOP = new PDRTJS_RATING_TOP( ' . $posts_rating_id . ', ' . $pages_rating_id . ', ' . $comments_rating_id . ", '" . $rating_seq . "', " . $instance['item_count'] . ' );';
430
+ echo '</script>';
431
+ echo $after_widget;
432
+ }
433
+
434
+ function update( $new_instance, $old_instance ) {
435
+
436
+ $instance = $old_instance;
437
+ $instance['title'] = strip_tags($new_instance['title']);
438
+ $instance['show_posts'] = (int) $new_instance['show_posts'];
439
+ $instance['show_pages'] = (int) $new_instance['show_pages'];
440
+ $instance['show_comments'] = (int) $new_instance['show_comments'];
441
+ $instance['item_count'] = (int) $new_instance['item_count'];
442
+ return $instance;
443
+ }
444
+
445
+ function form( $instance ) {
446
+
447
+ $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'show_posts' => '1', 'show_pages' => '1', 'show_comments' => '1', 'item_count' => '5' ) );
448
+ $title = strip_tags( $instance['title'] );
449
+ $show_posts = (int) $instance['show_posts'];
450
+ $show_pages = (int) $instance['show_pages'];
451
+ $show_comments = (int) $instance['show_comments'];
452
+ $item_count = (int) $instance['item_count'];
453
+ ?>
454
+ <p><label for="<?php echo $this->get_field_id('title'); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape( $title ); ?>" /></label></p>
455
+ <p>
456
+ <label for="<?php echo $this->get_field_id( 'show_posts' ); ?>">
457
+ <?php
458
+ $checked = '';
459
+ if ( $show_posts == 1 ){
460
+ $checked = 'checked="checked"';
461
+ }
462
+ ?>
463
+ <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id( 'show_posts' ); ?>" name="<?php echo $this->get_field_name( 'show_posts' ); ?>" value="1" <?php echo ( $checked ); ?> />
464
+ Show for posts
465
+ </label>
466
+ </p>
467
+ <p>
468
+ <label for="<?php echo $this->get_field_id( 'show_pages' ); ?>">
469
+ <?php
470
+ $checked = '';
471
+ if ( $show_pages == 1 ){
472
+ $checked = 'checked="checked"';
473
+ }
474
+ ?>
475
+ <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id( 'show_pages' ); ?>" name="<?php echo $this->get_field_name( 'show_pages' ); ?>" value="1" <?php echo ( $checked ); ?> />
476
+ Show for pages
477
+ </label>
478
+ </p>
479
+ <p>
480
+ <label for="<?php echo $this->get_field_id( 'show_comments' ); ?>">
481
+ <?php
482
+ $checked = '';
483
+ if ( $show_comments == 1 ){
484
+ $checked = 'checked="checked"';
485
+ }
486
+ ?>
487
+ <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id( 'show_comments' ); ?>" name="<?php echo $this->get_field_name( 'show_comments' ); ?>" value="1" <?php echo ( $checked ); ?>/>
488
+ Show for comments
489
+ </label>
490
+ </p>
491
+ <p>
492
+ <label for="rss-items-<?php echo $number; ?>"><?php _e('How many items would you like to display?'); ?>
493
+ <select id="<?php echo $this->get_field_id( 'item_count' ); ?>" name="<?php echo $this->get_field_name( 'item_count' ); ?>">
494
+ <?php
495
+ for ( $i = 1; $i <= 20; ++$i )
496
+ echo "<option value='$i' " . ( $item_count == $i ? "selected='selected'" : '' ) . ">$i</option>";
497
+ ?>
498
+ </select>
499
+ </label>
500
+ </p>
501
+ <?php
502
+ }
503
+
504
+ }
505
+
506
+ add_action('widgets_init', create_function('', 'return register_widget("PD_Top_Rated");'));
507
+ ?>
polldaddy-xml.php CHANGED
@@ -236,6 +236,17 @@ class PollDaddy_Demand extends PollDaddy_XML_Object {
236
  var $rating_result;
237
  var $rating;
238
  var $nonce;
 
 
 
 
 
 
 
 
 
 
 
239
  }
240
 
241
  class PollDaddy_Account extends PollDaddy_XML_Object {
@@ -619,7 +630,8 @@ class PollDaddy_XML_Parser {
619
  'http://api.polldaddy.com/pdapi.xsd:rating_result' => 'PollDaddy_Rating_Result',
620
  'http://api.polldaddy.com/pdapi.xsd:ratings' => 'PollDaddy_Ratings',
621
  'http://api.polldaddy.com/pdapi.xsd:rating' => 'PollDaddy_Rating',
622
- 'http://api.polldaddy.com/pdapi.xsd:nonce' => 'PollDaddy_Nonce'
 
623
  );// the parser matches the tag names to the class name and creates an object defined by that class
624
 
625
  var $object_stack = array();
236
  var $rating_result;
237
  var $rating;
238
  var $nonce;
239
+ var $partner;
240
+ }
241
+
242
+ class PollDaddy_Partner extends PollDaddy_XML_Object {
243
+ var $___cdata = array( 'name' );
244
+ var $___name = 'partner';
245
+
246
+ var $_role;
247
+ var $_users;
248
+
249
+ var $name;
250
  }
251
 
252
  class PollDaddy_Account extends PollDaddy_XML_Object {
630
  'http://api.polldaddy.com/pdapi.xsd:rating_result' => 'PollDaddy_Rating_Result',
631
  'http://api.polldaddy.com/pdapi.xsd:ratings' => 'PollDaddy_Ratings',
632
  'http://api.polldaddy.com/pdapi.xsd:rating' => 'PollDaddy_Rating',
633
+ 'http://api.polldaddy.com/pdapi.xsd:nonce' => 'PollDaddy_Nonce',
634
+ 'http://api.polldaddy.com/pdapi.xsd:partner' => 'PollDaddy_Partner'
635
  );// the parser matches the tag names to the class name and creates an object defined by that class
636
 
637
  var $object_stack = array();
polldaddy.php CHANGED
@@ -2,35 +2,49 @@
2
 
3
  /*
4
  Plugin Name: PollDaddy Polls
5
- Description: Create and manage PollDaddy polls in WordPress
6
  Author: Automattic, Inc.
7
  Author URL: http://automattic.com/
8
- Version: 1.7.7
9
  */
10
 
11
  // You can hardcode your PollDaddy PartnerGUID (API Key) here
12
  //define( 'WP_POLLDADDY__PARTNERGUID', '12345...' );
13
 
14
- if ( !defined( 'WP_POLLDADDY__CLASS' ) )
15
- define( 'WP_POLLDADDY__CLASS', 'WP_PollDaddy' );
16
-
17
- if ( !defined( 'WP_POLLDADDY__POLLDADDY_CLIENT_PATH' ) )
18
- define( 'WP_POLLDADDY__POLLDADDY_CLIENT_PATH', dirname( __FILE__ ) . '/polldaddy-client.php' );
19
-
20
- // TODO: when user changes PollDaddy password, userCode changes
21
  class WP_PollDaddy {
22
  var $errors;
23
- var $polldaddy_client_class = 'api_client';
24
- var $base_url = false;
25
- var $use_ssl = 0;
26
- var $scheme = 'https';
27
- var $version = '1.7.7';
28
-
29
- var $polldaddy_clients = array();
30
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  function &get_client( $api_key, $userCode = null ) {
32
  if ( isset( $this->polldaddy_clients[$api_key] ) ) {
33
- if ( !is_null( $userCode ) )
34
  $this->polldaddy_clients[$api_key]->userCode = $userCode;
35
  return $this->polldaddy_clients[$api_key];
36
  }
@@ -39,58 +53,67 @@ class WP_PollDaddy {
39
  return $this->polldaddy_clients[$api_key];
40
  }
41
 
42
- function admin_menu() {
43
- $this->errors = new WP_Error;
44
-
45
- if ( !$this->base_url )
46
- $this->base_url = plugins_url() . '/' . dirname( plugin_basename( __FILE__ ) ) . '/';
47
-
48
  if ( !defined( 'WP_POLLDADDY__PARTNERGUID' ) ) {
49
  $guid = get_option( 'polldaddy_api_key' );
50
  if ( !$guid || !is_string( $guid ) )
51
  $guid = false;
52
  define( 'WP_POLLDADDY__PARTNERGUID', $guid );
53
  }
54
-
55
- if ( !WP_POLLDADDY__PARTNERGUID ) {
56
- $this->use_ssl = (int) get_option( 'polldaddy_use_ssl' );
57
-
58
  if ( function_exists( 'add_object_page' ) ) // WP 2.7+
59
- $hook = add_object_page( __( 'Polls' ), __( 'Polls' ), 'edit_posts', 'polls', array( &$this, 'api_key_page' ), "{$this->base_url}polldaddy.png" );
60
- else
61
- $hook = add_management_page( __( 'Polls' ), __( 'Polls' ), 'edit_posts', 'polls', array( &$this, 'api_key_page' ) );
62
-
63
- add_action( "load-$hook", array( &$this, 'api_key_page_load' ) );
64
- if ( empty( $_GET['page'] ) || 'polls' != $_GET['page'] )
 
 
 
 
 
 
 
65
  add_action( 'admin_notices', create_function( '', 'echo "<div class=\"error\"><p>" . sprintf( "You need to <a href=\"%s\">input your PollDaddy.com account details</a>.", "edit.php?page=polls" ) . "</p></div>";' ) );
66
  return false;
67
- }
68
 
69
  if ( function_exists( 'add_object_page' ) ) // WP 2.7+
70
- $hook = add_object_page( __( 'Ratings' ), __( 'Ratings' ), 'edit_posts', 'ratings', array( &$this, 'management_page' ), "{$this->base_url}polldaddy.png" );
71
  else
72
- $hook = add_management_page( __( 'Ratings' ), __( 'Ratings' ), 'edit_posts', 'ratings', array( &$this, 'management_page' ) );
73
 
74
  add_action( "load-$hook", array( &$this, 'management_page_load' ) );
75
 
76
  if ( function_exists( 'add_object_page' ) ) // WP 2.7+
77
- $hook = add_object_page( __( 'Polls' ), __( 'Polls' ), 'edit_posts', 'polls', array( &$this, 'management_page' ), "{$this->base_url}polldaddy.png" );
78
  else
79
- $hook = add_management_page( __( 'Polls' ), __( 'Polls' ), 'edit_posts', 'polls', array( &$this, 'management_page' ) );
80
 
81
  add_action( "load-$hook", array( &$this, 'management_page_load' ) );
82
 
83
- add_submenu_page( 'ratings', __( 'Ratings &ndash; Settings' ), __( 'Settings' ), 'edit_posts', 'ratings', array( &$this, 'management_page' ) );
84
- add_submenu_page( 'ratings', __( 'Ratings &ndash; Reports' ), __( 'Reports' ), 'edit_posts', 'ratings&amp;action=reports', array( &$this, 'management_page' ) );
 
 
 
 
 
85
 
86
- add_submenu_page( 'polls', __( 'Polls' ), __( 'Edit' ), 'edit_posts', 'polls', array( &$this, 'management_page' ) );
87
- add_submenu_page( 'polls', __( 'Add New Poll' ), __( 'Add New' ), 'edit_posts', 'polls&amp;action=create-poll', array( &$this, 'management_page' ) );
88
- add_submenu_page( 'polls', __( 'Custom Styles' ), __( 'Custom Styles' ), 'edit_posts', 'polls&amp;action=list-styles', array( &$this, 'management_page' ) );
 
 
 
 
89
 
90
  add_action( 'media_buttons', array( &$this, 'media_buttons' ) );
91
  }
92
 
93
- function api_key_page_load() {
94
  if ( 'post' != strtolower( $_SERVER['REQUEST_METHOD'] ) || empty( $_POST['action'] ) || 'account' != $_POST['action'] )
95
  return false;
96
 
@@ -98,33 +121,22 @@ class WP_PollDaddy {
98
 
99
  $polldaddy_email = stripslashes( $_POST['polldaddy_email'] );
100
  $polldaddy_password = stripslashes( $_POST['polldaddy_password'] );
101
-
102
  if ( !$polldaddy_email )
103
- $this->errors->add( 'polldaddy_email', __( 'Email address required' ) );
104
 
105
  if ( !$polldaddy_password )
106
- $this->errors->add( 'polldaddy_password', __( 'Password required' ) );
107
 
108
  if ( $this->errors->get_error_codes() )
109
  return false;
110
 
111
- if ( !empty( $_POST['polldaddy_use_ssl_checkbox'] ) ) {
112
- if ( $polldaddy_use_ssl = (int) $_POST['polldaddy_use_ssl'] ) {
113
- $this->use_ssl = 0; //checked (by default)
114
- } else {
115
- $this->use_ssl = 1; //unchecked
116
- $this->scheme = 'http';
117
- }
118
- update_option( 'polldaddy_use_ssl', $this->use_ssl );
119
- }
120
-
121
  $details = array(
122
  'uName' => get_bloginfo( 'name' ),
123
  'uEmail' => $polldaddy_email,
124
  'uPass' => $polldaddy_password,
125
- 'partner_userid' => $GLOBALS['current_user']->ID
126
  );
127
-
128
  if ( function_exists( 'wp_remote_post' ) ) { // WP 2.7+
129
  $polldaddy_api_key = wp_remote_post( $this->scheme . '://api.polldaddy.com/key.php', array(
130
  'body' => $details
@@ -133,11 +145,6 @@ class WP_PollDaddy {
133
  $this->errors = $polldaddy_api_key;
134
  return false;
135
  }
136
- $response_code = wp_remote_retrieve_response_code( $polldaddy_api_key );
137
- if ( 200 != $response_code ) {
138
- $this->errors->add( 'http_code', __( 'Could not connect to PollDaddy API Key service' ) );
139
- return false;
140
- }
141
  $polldaddy_api_key = wp_remote_retrieve_body( $polldaddy_api_key );
142
  } else {
143
  $fp = fsockopen(
@@ -149,7 +156,7 @@ class WP_PollDaddy {
149
  );
150
 
151
  if ( !$fp ) {
152
- $this->errors->add( 'connect', __( "Can't connect to PollDaddy.com" ) );
153
  return false;
154
  }
155
 
@@ -175,30 +182,22 @@ class WP_PollDaddy {
175
  list($headers, $polldaddy_api_key) = explode( "\r\n\r\n", $response, 2 );
176
  }
177
 
178
- if( isset( $polldaddy_api_key ) && strlen( $polldaddy_api_key ) > 0 ){
179
- update_option( 'polldaddy_api_key', $polldaddy_api_key );
180
- }
181
- else{
182
- $this->errors->add( 'polldaddy_api_key', __( 'Login to PollDaddy failed. Double check your email address and password.' ) );
183
- if ( 1 !== $this->use_ssl ) {
184
- $this->errors->add( 'polldaddy_api_key', __( 'If your email address and password are correct, your host may not support secure logins.' ) );
185
- $this->errors->add( 'polldaddy_api_key', __( 'In that case, you may be able to log in to PollDaddy by unchecking the "Use SSL to Log in" checkbox.' ) );
186
- $this->use_ssl = 0;
187
- }
188
- update_option( 'polldaddy_use_ssl', $this->use_ssl );
189
  return false;
190
  }
191
 
 
 
192
  $polldaddy = $this->get_client( $polldaddy_api_key );
193
  $polldaddy->reset();
194
- if ( !$polldaddy->get_usercode( $GLOBALS['current_user']->ID ) ) {
195
  $this->parse_errors( $polldaddy );
196
- $this->errors->add( 'GetUserCode', __( 'Account could not be accessed. Are your email address and password correct?' ) );
197
  return false;
198
  }
199
-
200
- wp_redirect( add_query_arg( array( 'page' => 'polls' ), wp_get_referer() ) );
201
- exit;
202
  }
203
 
204
  function parse_errors( &$polldaddy ) {
@@ -206,7 +205,7 @@ class WP_PollDaddy {
206
  foreach ( $polldaddy->errors as $code => $error )
207
  $this->errors->add( $code, $error );
208
  if ( isset( $this->errors->errors[4] ) ) {
209
- $this->errors->errors[4] = array( sprintf( __( 'Obsolete PollDaddy User API Key: <a href="%s">Sign in again to re-authenticate</a>' ), add_query_arg( array( 'action' => 'signup', 'reaction' => empty( $_GET['action'] ) ? false : $_GET['action'] ) ) ) );
210
  $this->errors->add_data( true, 4 );
211
  }
212
  }
@@ -240,56 +239,41 @@ class WP_PollDaddy {
240
  }
241
 
242
  function api_key_page() {
243
- $this->print_errors();
244
  ?>
245
 
246
  <div class="wrap">
247
 
248
- <h2><?php _e( 'PollDaddy Account' ); ?></h2>
249
 
250
- <p><?php printf( __('Before you can use the PollDaddy plugin, you need to enter your <a href="%s">PollDaddy.com</a> account details.' ), 'http://polldaddy.com/' ); ?></p>
251
 
252
  <form action="" method="post">
253
  <table class="form-table">
254
  <tbody>
255
  <tr class="form-field form-required">
256
  <th valign="top" scope="row">
257
- <label for="polldaddy-email"><?php _e( 'PollDaddy Email Address' ); ?></label>
258
  </th>
259
  <td>
260
- <input type="text" name="polldaddy_email" id="polldaddy-email" aria-required="true" size="40" value="<?php if ( isset( $_POST['polldaddy_email'] ) ) echo attribute_escape( $_POST['polldaddy_email'] ); ?>" />
261
  </td>
262
  </tr>
263
  <tr class="form-field form-required">
264
  <th valign="top" scope="row">
265
- <label for="polldaddy-password"><?php _e( 'PollDaddy Password' ); ?></label>
266
  </th>
267
  <td>
268
  <input type="password" name="polldaddy_password" id="polldaddy-password" aria-required="true" size="40" />
269
  </td>
270
  </tr>
271
- <?php
272
- $checked = '';
273
- if ( $this->use_ssl == 0 )
274
- $checked = 'checked="checked"';
275
- ?>
276
- <tr class="form-field form-required">
277
- <th valign="top" scope="row">
278
- <label for="polldaddy-use-ssl"><?php _e( 'Use SSL to Log in' ); ?></label>
279
- </th>
280
- <td>
281
- <input type="checkbox" name="polldaddy_use_ssl" id="polldaddy-use-ssl" value="1" <?php echo $checked ?> style="width: auto"/>
282
- <label for="polldaddy-use-ssl"><?php _e( 'This ensures a secure login to your PollDaddy account. Only uncheck if you are having problems logging in.' ); ?></label>
283
- <input type="hidden" name="polldaddy_use_ssl_checkbox" value="1" />
284
- </td>
285
- </tr>
286
  </tbody>
287
  </table>
288
  <p class="submit">
289
  <?php wp_nonce_field( 'polldaddy-account' ); ?>
290
  <input type="hidden" name="action" value="account" />
291
  <input type="hidden" name="account" value="import" />
292
- <input type="submit" value="<?php echo attribute_escape( __( 'Submit' ) ); ?>" />
293
  </p>
294
  </form>
295
  </div>
@@ -298,31 +282,38 @@ class WP_PollDaddy {
298
  }
299
 
300
  function media_buttons() {
301
- $title = __( 'Add Poll' );
302
- echo "<a href='admin.php?page=polls&amp;iframe&amp;TB_iframe=true' id='add_poll' class='thickbox' title='$title'><img src='{$this->base_url}polldaddy.png' alt='$title' /></a>";
303
  }
304
 
305
  function management_page_load() {
306
- global $current_user, $plugin_page;
307
-
308
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID );
309
  $polldaddy->reset();
310
 
311
- if ( !defined( 'WP_POLLDADDY__USERCODE' ) )
312
- define( 'WP_POLLDADDY__USERCODE', $polldaddy->get_usercode( $current_user->ID ) );
313
-
 
314
  wp_reset_vars( array( 'page', 'action', 'poll', 'style', 'rating' ) );
315
  global $page, $action, $poll, $style, $rating;
316
 
317
- if ( !WP_POLLDADDY__USERCODE )
318
- $action = 'signup';
 
 
319
 
320
  require_once WP_POLLDADDY__POLLDADDY_CLIENT_PATH;
321
 
322
  wp_enqueue_script( 'polls', "{$this->base_url}polldaddy.js", array( 'jquery', 'jquery-ui-sortable' ), $this->version );
323
  wp_enqueue_script( 'polls-common', "{$this->base_url}common.js", array(), $this->version );
324
 
325
- if( $page == 'polls' ) {
 
 
 
 
326
  switch ( $action ) :
327
  case 'edit' :
328
  case 'edit-poll' :
@@ -341,9 +332,17 @@ class WP_PollDaddy {
341
  break;
342
  case 'list-styles' :
343
  $plugin_page = 'polls&amp;action=list-styles';
 
 
 
 
 
344
  break;
345
  endswitch;
346
  } elseif( $page == 'ratings' ) {
 
 
 
347
  switch ( $action ) :
348
  case 'change-report' :
349
  case 'reports' :
@@ -353,8 +352,8 @@ class WP_PollDaddy {
353
  wp_enqueue_script( 'rating-text-color', "http://i.polldaddy.com/js/jscolor.js", array(), $this->version );
354
  wp_enqueue_script( 'ratings', 'http://i.polldaddy.com/ratings/rating.js', array(), $this->version );
355
  wp_localize_script( 'polls-common', 'adminRatingsL10n', array(
356
- 'star_colors' => __( 'Star Colors' ), 'star_size' => __( 'Star Size' ),
357
- 'nero_type' => __( 'Nero Type' ), 'nero_size' => __( 'Nero Size' ), ) );
358
  endswitch;
359
  }
360
 
@@ -407,8 +406,9 @@ class WP_PollDaddy {
407
  switch ( $action ) :
408
  case 'signup' : // sign up for first time
409
  case 'account' : // reauthenticate
 
410
  if ( !$is_POST )
411
- return;
412
 
413
  check_admin_referer( 'polldaddy-account' );
414
 
@@ -416,40 +416,43 @@ class WP_PollDaddy {
416
  $query_args = array_merge( $query_args, $new_args );
417
  if ( $this->errors->get_error_codes() )
418
  return false;
 
 
419
 
420
  wp_reset_vars( array( 'action' ) );
421
  if ( !empty( $_GET['reaction'] ) )
422
  $query_args['action'] = $_GET['reaction'];
423
- elseif ( !empty( $_GET['action'] ) && 'signup' != $_GET['action'] )
424
  $query_args['action'] = $_GET['action'];
425
  else
426
  $query_args['action'] = false;
427
  break;
 
428
  case 'delete' :
429
  if ( empty( $poll ) )
430
  return;
431
 
432
  if ( is_array( $poll ) )
433
- check_admin_referer( 'delete-poll_bulk' );
434
  else
435
  check_admin_referer( "delete-poll_$poll" );
436
 
437
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
438
 
439
  foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
440
  $polldaddy->reset();
441
  $poll_object = $polldaddy->get_poll( $poll );
442
 
443
  if ( !$this->can_edit( $poll_object ) ) {
444
- $this->errors->add( 'permission', __( 'You are not allowed to delete this poll.' ) );
445
  return false;
446
  }
447
 
448
  // Send Poll Author credentials
449
- if ( !empty( $poll_object->_owner ) && $current_user->ID != $poll_object->_owner ) {
450
  $polldaddy->reset();
451
  if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
452
- $this->errors->add( 'no_usercode', __( 'Invalid Poll Author' ) );
453
  }
454
  $polldaddy->userCode = $userCode;
455
  }
@@ -470,22 +473,22 @@ class WP_PollDaddy {
470
  else
471
  check_admin_referer( "open-poll_$poll" );
472
 
473
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
474
 
475
  foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
476
  $polldaddy->reset();
477
  $poll_object = $polldaddy->get_poll( $poll );
478
 
479
  if ( !$this->can_edit( $poll_object ) ) {
480
- $this->errors->add( 'permission', __( 'You are not allowed to delete this poll.' ) );
481
  return false;
482
  }
483
 
484
  // Send Poll Author credentials
485
- if ( !empty( $poll_object->_owner ) && $current_user->ID != $poll_object->_owner ) {
486
  $polldaddy->reset();
487
  if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
488
- $this->errors->add( 'no_usercode', __( 'Invalid Poll Author' ) );
489
  }
490
  $polldaddy->userCode = $userCode;
491
  }
@@ -506,22 +509,22 @@ class WP_PollDaddy {
506
  else
507
  check_admin_referer( "close-poll_$poll" );
508
 
509
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
510
 
511
  foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
512
  $polldaddy->reset();
513
  $poll_object = $polldaddy->get_poll( $poll );
514
 
515
  if ( !$this->can_edit( $poll_object ) ) {
516
- $this->errors->add( 'permission', __( 'You are not allowed to delete this poll.' ) );
517
  return false;
518
  }
519
 
520
  // Send Poll Author credentials
521
- if ( !empty( $poll_object->_owner ) && $current_user->ID != $poll_object->_owner ) {
522
  $polldaddy->reset();
523
  if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
524
- $this->errors->add( 'no_usercode', __( 'Invalid Poll Author' ) );
525
  }
526
  $polldaddy->userCode = $userCode;
527
  }
@@ -539,30 +542,30 @@ class WP_PollDaddy {
539
 
540
  check_admin_referer( "edit-poll_$poll" );
541
 
542
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
543
  $polldaddy->reset();
544
 
545
  $poll_object = $polldaddy->get_poll( $poll );
546
  $this->parse_errors( $polldaddy );
547
 
548
  if ( !$this->can_edit( $poll_object ) ) {
549
- $this->errors->add( 'permission', __( 'You are not allowed to edit this poll.' ) );
550
  return false;
551
  }
552
 
553
  // Send Poll Author credentials
554
 
555
- if ( !empty( $poll_object->_owner ) && $current_user->ID != $poll_object->_owner ) {
556
  $polldaddy->reset();
557
  if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
558
- $this->errors->add( 'no_usercode', __( 'Invalid Poll Author' ) );
559
  }
560
  $this->parse_errors( $polldaddy );
561
  $polldaddy->userCode = $userCode;
562
  }
563
 
564
  if ( !$poll_object )
565
- $this->errors->add( 'GetPoll', __( 'Poll not found' ) );
566
 
567
  if ( $this->errors->get_error_codes() )
568
  return false;
@@ -589,7 +592,7 @@ class WP_PollDaddy {
589
  $poll_data['question'] = stripslashes( $_POST['question'] );
590
 
591
  if ( empty( $_POST['answer'] ) || !is_array( $_POST['answer'] ) )
592
- $this->errors->add( 'answer', __( 'Invalid answers' ) );
593
 
594
  $answers = array();
595
  foreach ( $_POST['answer'] as $answer_id => $answer ) {
@@ -605,7 +608,7 @@ class WP_PollDaddy {
605
  }
606
 
607
  if ( 2 > count( $answers ) )
608
- $this->errors->add( 'answer', __( 'You must include at least 2 answers' ) );
609
 
610
  if ( $this->errors->get_error_codes() )
611
  return false;
@@ -616,7 +619,7 @@ class WP_PollDaddy {
616
 
617
  if ( isset ( $_POST['styleID'] ) ){
618
  if ( $_POST['styleID'] == 'x' ){
619
- $this->errors->add( 'UpdatePoll', __( 'Please choose a poll style' ) );
620
  return false;
621
  }
622
  }
@@ -638,7 +641,7 @@ class WP_PollDaddy {
638
  $this->parse_errors( $polldaddy );
639
 
640
  if ( !$update_response )
641
- $this->errors->add( 'UpdatePoll', __( 'Poll could not be updated' ) );
642
 
643
  if ( $this->errors->get_error_codes() )
644
  return false;
@@ -653,7 +656,7 @@ class WP_PollDaddy {
653
 
654
  check_admin_referer( 'create-poll' );
655
 
656
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
657
  $polldaddy->reset();
658
 
659
  $answers = array();
@@ -670,17 +673,30 @@ class WP_PollDaddy {
670
  return false;
671
 
672
  $poll_data = _polldaddy_poll_defaults();
673
- foreach ( $poll_data as $key => $value )
674
- if ( isset($_POST[$key]) )
675
- $poll_data[$key] = stripslashes( $_POST[$key] );
 
 
 
 
 
 
 
 
 
 
 
 
676
 
677
  $poll_data['answers'] = $answers;
678
 
 
679
  $poll_data['question'] = wp_kses( $poll_data['question'], $allowedtags );
680
 
681
  if ( isset ( $_POST['styleID'] ) ){
682
  if ( $_POST['styleID'] == 'x' ){
683
- $this->errors->add( 'UpdatePoll', __( 'Please choose a poll style' ) );
684
  return false;
685
  }
686
  }
@@ -699,7 +715,7 @@ class WP_PollDaddy {
699
  $this->parse_errors( $polldaddy );
700
 
701
  if ( !$poll || empty( $poll->_id ) )
702
- $this->errors->add( 'CreatePoll', __( 'Poll could not be created' ) );
703
 
704
  if ( $this->errors->get_error_codes() )
705
  return false;
@@ -719,7 +735,7 @@ class WP_PollDaddy {
719
  else
720
  check_admin_referer( "delete-style_$style" );
721
 
722
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
723
 
724
  foreach ( (array) $_REQUEST['style'] as $style_id ) {
725
  $polldaddy->reset();
@@ -735,7 +751,7 @@ class WP_PollDaddy {
735
 
736
  check_admin_referer( "edit-style$style" );
737
 
738
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
739
  $polldaddy->reset();
740
 
741
  $style_data = _polldaddy_style_defaults();
@@ -751,7 +767,7 @@ class WP_PollDaddy {
751
  $this->parse_errors( $polldaddy );
752
 
753
  if ( !$update_response )
754
- $this->errors->add( 'UpdateStyle', __( 'Style could not be updated' ) );
755
 
756
  if ( $this->errors->get_error_codes() )
757
  return false;
@@ -766,7 +782,7 @@ class WP_PollDaddy {
766
 
767
  check_admin_referer( 'create-style' );
768
 
769
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
770
  $polldaddy->reset();
771
 
772
  $style_data = _polldaddy_style_defaults();
@@ -781,7 +797,7 @@ class WP_PollDaddy {
781
  $this->parse_errors( $polldaddy );
782
 
783
  if ( !$style || empty( $style->_id ) )
784
- $this->errors->add( 'CreateStyle', __( 'Style could not be created' ) );
785
 
786
  if ( $this->errors->get_error_codes() )
787
  return false;
@@ -792,6 +808,54 @@ class WP_PollDaddy {
792
  if ( isset($_POST['iframe']) )
793
  $query_args['iframe'] = '';
794
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
795
  default :
796
  return;
797
  endswitch;
@@ -806,30 +870,36 @@ class WP_PollDaddy {
806
  function management_page_load_signup() {
807
  switch ( $_POST['account'] ) :
808
  case 'import' :
809
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID );
810
- $polldaddy->reset();
811
- $email = trim( stripslashes( $_POST['polldaddy_email'] ) );
812
- $password = trim( stripslashes( $_POST['polldaddy_password'] ) );
813
-
814
- if ( !is_email( $email ) )
815
- $this->errors->add( 'polldaddy_email', __( 'Email address required' ) );
816
-
817
- if ( !$password )
818
- $this->errors->add( 'polldaddy_password', __( 'Password required' ) );
819
-
820
- if ( $this->errors->get_error_codes() )
821
- return false;
822
-
823
- if ( !$polldaddy->initiate( $email, $password, $GLOBALS['user_ID'] ) ) {
824
- $this->parse_errors( $polldaddy );
825
- $this->errors->add( 'import-account', __( 'Account could not be imported. Are your email address and password correct?' ) );
826
- return false;
827
- }
828
  break;
829
  default :
830
  return;
831
  endswitch;
832
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
833
 
834
  function admin_body_class( $class ) {
835
  if ( isset( $_GET['iframe'] ) )
@@ -839,51 +909,56 @@ class WP_PollDaddy {
839
  return $class;
840
  }
841
 
842
- function management_page_notices() {
843
- $message = false;
844
  switch ( (string) @$_GET['message'] ) :
845
  case 'deleted' :
846
  $deleted = (int) $_GET['deleted'];
847
  if ( 1 == $deleted )
848
- $message = __( 'Poll deleted.' );
849
  else
850
  $message = sprintf( __ngettext( '%s Poll Deleted.', '%s Polls Deleted.', $deleted ), number_format_i18n( $deleted ) );
851
  break;
852
  case 'opened' :
853
  $opened = (int) $_GET['opened'];
854
  if ( 1 == $opened )
855
- $message = __( 'Poll opened.' );
856
  else
857
  $message = sprintf( __ngettext( '%s Poll Opened.', '%s Polls Opened.', $opened ), number_format_i18n( $opened ) );
858
  break;
859
  case 'closed' :
860
  $closed = (int) $_GET['closed'];
861
  if ( 1 == $closed )
862
- $message = __( 'Poll closed.' );
863
  else
864
  $message = sprintf( __ngettext( '%s Poll Closed.', '%s Polls Closed.', $closed ), number_format_i18n( $closed ) );
865
  break;
866
  case 'updated' :
867
- $message = __( 'Poll updated.' );
868
  break;
869
  case 'created' :
870
- $message = __( 'Poll created.' );
871
  if ( isset( $_GET['iframe'] ) )
872
- $message .= ' <input type="button" class="button polldaddy-send-to-editor" value="' . attribute_escape( __( 'Send to Editor' ) ) . '" />';
873
  break;
874
  case 'updated-style' :
875
- $message = __( 'Custom Style updated.' );
876
  break;
877
  case 'created-style' :
878
- $message = __( 'Custom Style created.' );
879
  break;
880
  case 'deleted-style' :
881
  $deleted = (int) $_GET['deleted'];
882
  if ( 1 == $deleted )
883
- $message = __( 'Custom Style deleted.' );
884
  else
885
  $message = sprintf( __ngettext( '%s Style Deleted.', '%s Custom Styles Deleted.', $deleted ), number_format_i18n( $deleted ) );
886
  break;
 
 
 
 
 
 
887
  endswitch;
888
 
889
  $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
@@ -891,16 +966,16 @@ class WP_PollDaddy {
891
  if ( $is_POST ) {
892
  switch ( $GLOBALS['action'] ) :
893
  case 'create-poll' :
894
- $message = __( 'Error: An error has occurred; Poll not created.' );
895
  break;
896
  case 'edit-poll' :
897
- $message = __( 'Error: An error has occurred; Poll not updated.' );
898
  break;
899
  case 'account' :
900
  if ( 'import' == $_POST['account'] )
901
- $message = __( 'Error: An error has occurred; Account could not be imported. Perhaps your email address or password is incorrect?' );
902
  else
903
- $message = __( 'Error: An error has occurred; Account could not be created.' );
904
  break;
905
  endswitch;
906
  }
@@ -914,17 +989,19 @@ class WP_PollDaddy {
914
  }
915
 
916
  function management_page() {
917
- global $page, $action, $poll, $style, $rating;
918
  $poll = (int) $poll;
919
  $style = (int) $style;
920
- $rating = wp_specialchars( $rating );
921
-
922
  ?>
923
 
924
  <div class="wrap" id="manage-polls">
925
 
926
  <?php
927
- if( $page == 'polls' ) {
 
 
 
928
  switch ( $action ) :
929
  case 'signup' :
930
  case 'account' :
@@ -933,10 +1010,13 @@ class WP_PollDaddy {
933
  case 'preview' :
934
  ?>
935
 
936
- <h2 id="preview-header"><?php printf( __( 'Poll Preview (<a href="%s">Edit Poll</a>, <a href="%s">List Polls</a>)' ),
937
- clean_url( add_query_arg( array( 'action' => 'edit', 'poll' => $poll, 'message' => false ) ) ),
938
- clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) )
939
- ); ?></h2>
 
 
 
940
 
941
  <?php
942
  echo do_shortcode( "[polldaddy poll=$poll cb=1]" );
@@ -944,7 +1024,11 @@ class WP_PollDaddy {
944
  case 'results' :
945
  ?>
946
 
947
- <h2><?php printf( __( 'Poll Results (<a href="%s">Edit</a>)' ), clean_url( add_query_arg( array( 'action' => 'edit', 'poll' => $poll, 'message' => false ) ) ) ); ?></h2>
 
 
 
 
948
 
949
  <?php
950
  $this->poll_results_page( $poll );
@@ -953,7 +1037,7 @@ class WP_PollDaddy {
953
  case 'edit-poll' :
954
  ?>
955
 
956
- <h2><?php printf( __('Edit Poll (<a href="%s">List Polls</a>)'), clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ) ); ?></h2>
957
 
958
  <?php
959
 
@@ -962,7 +1046,7 @@ class WP_PollDaddy {
962
  case 'create-poll' :
963
  ?>
964
 
965
- <h2><?php printf( __('Create Poll (<a href="%s">List Polls</a>)'), clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ) ); ?></h2>
966
 
967
  <?php
968
  $this->poll_edit_form();
@@ -970,8 +1054,11 @@ class WP_PollDaddy {
970
  case 'list-styles' :
971
  ?>
972
 
973
- <h2><?php printf( __('Custom Styles (<a href="%s">Add New</a>)'), clean_url( add_query_arg( array(
974
- 'action' => 'create-style', 'poll' => false, 'message' => false ) ) ) ); ?></h2>
 
 
 
975
 
976
  <?php
977
  $this->styles_table();
@@ -993,20 +1080,29 @@ class WP_PollDaddy {
993
  <?php
994
  $this->style_edit_form();
995
  break;
 
 
 
 
 
996
  default :
997
 
998
  ?>
999
 
1000
- <h2 id="poll-list-header"><?php printf( __( 'Polls (<a href="%s">Add New</a>)' ), clean_url( add_query_arg( array(
1001
- 'action' => 'create-poll',
1002
- 'poll' => false,
1003
- 'message' => false
1004
- ) ) ) ); ?></h2>
1005
 
1006
  <?php
1007
  $this->polls_table( isset( $_GET['view'] ) && 'user' == $_GET['view'] ? 'user' : 'blog' );
1008
  endswitch;
1009
  } elseif( $page == 'ratings' ) {
 
 
 
 
1010
  switch ( $action ) :
1011
  case 'change-report' :
1012
  case 'reports' :
@@ -1014,7 +1110,7 @@ class WP_PollDaddy {
1014
  break;
1015
  case 'update-rating' :
1016
  $this->update_rating();
1017
- $this->rating_settings( true );
1018
  break;
1019
  default :
1020
  $this->rating_settings();
@@ -1032,8 +1128,12 @@ class WP_PollDaddy {
1032
  $page = 1;
1033
  if ( isset( $_GET['paged'] ) )
1034
  $page = absint($_GET['paged']);
1035
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
1036
  $polldaddy->reset();
 
 
 
 
1037
  if ( 'user' == $view )
1038
  $polls_object = $polldaddy->get_polls( ( $page - 1 ) * 10 + 1, $page * 10 );
1039
  else
@@ -1053,31 +1153,34 @@ class WP_PollDaddy {
1053
  'total' => ceil( $total_polls / 10 ),
1054
  'current' => $page
1055
  ) );
1056
- ?>
1057
 
 
1058
  <ul class="subsubsub">
1059
- <li><a href="<?php echo clean_url( add_query_arg( array( 'view' => false, 'paged' => false ) ) ); ?>"<?php if ( 'blog' == $view ) echo ' class="current"'; ?>><?php _e( "All Blog's Polls" ); ?></a> | </li>
1060
- <li><a href="<?php echo clean_url( add_query_arg( array( 'view' => 'user', 'paged' => false ) ) ); ?>"<?php if ( 'user' == $view ) echo ' class="current"'; ?>><?php _e( "All My Polls" ); ?></a></li>
1061
  </ul>
 
1062
  <form method="post" action="">
 
1063
  <div class="tablenav">
1064
  <div class="alignleft">
1065
  <select name="action">
1066
- <option selected="selected" value=""><?php _e( 'Actions' ); ?></option>
1067
- <option value="delete"><?php _e( 'Delete' ); ?></option>
1068
- <option value="close"><?php _e( 'Close' ); ?></option>
1069
- <option value="open"><?php _e( 'Open' ); ?></option>
1070
  </select>
1071
- <input class="button-secondary action" type="submit" name="doaction" value="<?php _e( 'Apply' ); ?>" />
1072
  <?php wp_nonce_field( 'action-poll_bulk' ); ?>
1073
  </div>
1074
  <div class="tablenav-pages"><?php echo $page_links; ?></div>
1075
  </div>
1076
  <br class="clear" />
 
1077
  <table class="widefat">
1078
  <thead>
1079
  <tr>
1080
- <th id="cb" class="manage-column column-cb check-column" scope="col" /><input type="checkbox" /></th>
1081
  <th id="title" class="manage-column column-title" scope="col">Poll</th>
1082
  <th id="votes" class="manage-column column-vote" scope="col">Votes</th>
1083
  <th id="date" class="manage-column column-date" scope="col">Created</th>
@@ -1086,69 +1189,78 @@ class WP_PollDaddy {
1086
  <tbody>
1087
 
1088
  <?php
1089
- if ( $polls ) :
1090
  foreach ( $polls as $poll ) :
1091
  $poll_id = (int) $poll->_id;
1092
 
1093
  $poll->___content = trim( strip_tags( $poll->___content ) );
1094
- if( strlen( $poll->___content ) == 0 ){
1095
- $poll->___content = '-- empty HTML tag --';
1096
- }
1097
 
1098
  $poll_closed = (int) $poll->_closed;
1099
 
1100
- if ( $this->can_edit( $poll ) )
1101
- $edit_link = clean_url( add_query_arg( array( 'action' => 'edit', 'poll' => $poll_id, 'message' => false ) ) );
1102
- else
1103
- $edit_link = false;
 
 
 
 
 
 
 
 
1104
 
1105
  $class = $class ? '' : ' class="alternate"';
1106
  $results_link = clean_url( add_query_arg( array( 'action' => 'results', 'poll' => $poll_id, 'message' => false ) ) );
1107
- $delete_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete', 'poll' => $poll_id, 'message' => false ) ), "delete-poll_$poll_id" ) );
1108
- $open_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'open', 'poll' => $poll_id, 'message' => false ) ), "open-poll_$poll_id" ) );
1109
- $close_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'close', 'poll' => $poll_id, 'message' => false ) ), "close-poll_$poll_id" ) );
1110
  $preview_link = clean_url( add_query_arg( array( 'action' => 'preview', 'poll' => $poll_id, 'message' => false ) ) ); //, 'iframe' => '', 'TB_iframe' => 'true' ) ) );
1111
  list($poll_time) = explode( '.', $poll->_created );
1112
  $poll_time = strtotime( $poll_time );
1113
  ?>
1114
 
1115
  <tr<?php echo $class; ?>>
1116
- <th class="check-column" scope="row"><input type="checkbox" value="<?php echo (int) $poll_id; ?>" name="poll[]" /></th>
1117
  <td class="post-title column-title">
1118
- <?php if ( $edit_link ) : ?>
1119
  <strong><a class="row-title" href="<?php echo $edit_link; ?>"><?php echo wp_specialchars( $poll->___content ); ?></a></strong>
1120
- <span class="edit"><a href="<?php echo $edit_link; ?>"><?php _e( 'Edit' ); ?></a> | </span>
1121
- <?php else : ?>
1122
  <strong><?php echo wp_specialchars( $poll->___content ); ?></strong>
1123
- <?php endif; ?>
1124
-
1125
- <span class="results"><a href="<?php echo $results_link; ?>"><?php _e( 'Results' ); ?></a> | </span>
1126
- <span class="delete"><a class="delete-poll delete" href="<?php echo $delete_link; ?>"><?php _e( 'Delete' ); ?></a> | </span>
1127
- <?php if ( $poll_closed == 2 ) : ?>
1128
- <span class="open"><a class="open-poll" href="<?php echo $open_link; ?>"><?php _e( 'Open' ); ?></a> | </span>
1129
- <?php else : ?>
1130
- <span class="close"><a class="close-poll" href="<?php echo $close_link; ?>"><?php _e( 'Close' ); ?></a> | </span>
1131
- <?php endif; ?>
1132
- <?php if ( isset( $_GET['iframe'] ) ) : ?>
1133
- <span class="view"><a href="<?php echo $preview_link; ?>"><?php _e( 'Preview' ); ?></a> | </span>
 
 
 
1134
  <span class="editor">
1135
- <a href="#" class="polldaddy-send-to-editor"><?php _e( 'Send to editor' ); ?></a>
1136
  <input type="hidden" class="polldaddy-poll-id hack" value="<?php echo (int) $poll_id; ?>" /> |
1137
  </span>
1138
- <?php else : ?>
1139
- <span class="view"><a class="thickbox" href="<?php echo $preview_link; ?>"><?php _e( 'Preview' ); ?></a> | </span>
1140
- <?php endif; ?>
1141
- <span class="shortcode"><a href="#" class="polldaddy-show-shortcode"><?php _e( 'HTML code' ); ?></a></span>
1142
- </td>
 
1143
  <td class="poll-votes column-vote"><?php echo number_format_i18n( $poll->_responses ); ?></td>
1144
  <td class="date column-date"><abbr title="<?php echo date( __('Y/m/d g:i:s A'), $poll_time ); ?>"><?php echo date( __('Y/m/d'), $poll_time ); ?></abbr></td>
1145
  </tr>
1146
  <tr class="polldaddy-shortcode-row" style="display: none;">
1147
  <td colspan="4">
1148
- <h4><?php _e( 'Shortcode' ); ?></h4>
1149
  <pre>[polldaddy poll=<?php echo (int) $poll_id; ?>]</pre>
1150
 
1151
- <h4><?php _e( 'JavaScript' ); ?></h4>
1152
  <pre>&lt;script type="text/javascript" language="javascript"
1153
  src="http://static.polldaddy.com/p/<?php echo (int) $poll_id; ?>.js"&gt;&lt;/script&gt;
1154
  &lt;noscript&gt;
@@ -1164,7 +1276,7 @@ class WP_PollDaddy {
1164
  ?>
1165
 
1166
  <tr>
1167
- <td colspan="4"><?php printf( __( 'What are you doing here? <a href="%s">Go back</a>.' ), clean_url( add_query_arg( 'paged', false ) ) ); ?></td>
1168
  </tr>
1169
 
1170
  <?php
@@ -1172,12 +1284,17 @@ class WP_PollDaddy {
1172
  ?>
1173
 
1174
  <tr>
1175
- <td colspan="4"><?php printf( __( 'No polls yet. <a href="%s">Create one</a>' ), clean_url( add_query_arg( array( 'action' => 'create-poll' ) ) ) ); ?></td>
 
 
 
 
1176
  </tr>
1177
  <?php endif; // $polls ?>
1178
 
1179
  </tbody>
1180
  </table>
 
1181
  </form>
1182
  <div class="tablenav">
1183
  <div class="tablenav-pages"><?php echo $page_links; ?></div>
@@ -1186,11 +1303,15 @@ class WP_PollDaddy {
1186
 
1187
  <?php
1188
  }
 
 
 
 
1189
 
1190
- function poll_edit_form( $poll_id = 0 ) {
1191
  $poll_id = (int) $poll_id;
1192
 
1193
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
1194
  $polldaddy->reset();
1195
 
1196
  $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
@@ -1200,10 +1321,16 @@ class WP_PollDaddy {
1200
  $this->parse_errors( $polldaddy );
1201
 
1202
  if ( !$this->can_edit( $poll ) ) {
1203
- $this->errors->add( 'permission', __( 'You are not allowed to edit this poll.' ) );
1204
  }
1205
- } else {
1206
- $poll = polldaddy_poll( array(), null, false );
 
 
 
 
 
 
1207
  }
1208
 
1209
  $question = $is_POST ? attribute_escape( stripslashes( $_POST['question'] ) ) : attribute_escape( $poll->question );
@@ -1216,18 +1343,18 @@ class WP_PollDaddy {
1216
 
1217
  <div class="inner-sidebar" id="side-info-column">
1218
  <div id="submitdiv" class="postbox">
1219
- <h3><?php _e( 'Publish' ); ?></h3>
1220
  <div class="inside">
1221
  <div id="major-publishing-actions">
1222
  <p id="publishing-action">
1223
  <?php wp_nonce_field( $poll_id ? "edit-poll_$poll_id" : 'create-poll' ); ?>
1224
  <input type="hidden" name="action" value="<?php echo $poll_id ? 'edit-poll' : 'create-poll'; ?>" />
1225
  <input type="hidden" class="polldaddy-poll-id" name="poll" value="<?php echo $poll_id; ?>" />
1226
- <input type="submit" class="button-primary" value="<?php echo attribute_escape( __( 'Save Poll' ) ); ?>" />
1227
 
1228
  <?php if ( isset( $_GET['iframe'] ) && $poll_id ) : ?>
1229
 
1230
- <input type="button" class="button polldaddy-send-to-editor" value="<?php echo attribute_escape( __( 'Send to Editor' ) ); ?>" />
1231
 
1232
  <?php endif; ?>
1233
 
@@ -1238,12 +1365,12 @@ class WP_PollDaddy {
1238
  </div>
1239
 
1240
  <div class="postbox">
1241
- <h3><?php _e( 'Poll results' ); ?></h3>
1242
  <div class="inside">
1243
  <ul class="poll-options">
1244
 
1245
  <?php
1246
- foreach ( array( 'show' => __( 'Show results to voters' ), 'percent' => __( 'Only show percentages' ), 'hide' => __( 'Hide all results' ) ) as $value => $label ) :
1247
  if ( $is_POST )
1248
  $checked = $value === $_POST['resultsType'] ? ' checked="checked"' : '';
1249
  else
@@ -1261,12 +1388,12 @@ class WP_PollDaddy {
1261
  </div>
1262
 
1263
  <div class="postbox">
1264
- <h3><?php _e( 'Block repeat voters' ); ?></h3>
1265
  <div class="inside">
1266
  <ul class="poll-options">
1267
 
1268
  <?php
1269
- foreach ( array( 'off' => __( "Don't block repeat voters" ), 'cookie' => __( 'Block by cookie (recommended)' ), 'cookieip' => __( 'Block by cookie and by IP address' ) ) as $value => $label ) :
1270
  if ( $is_POST )
1271
  $checked = $value === $_POST['blockRepeatVotersType'] ? ' checked="checked"' : '';
1272
  else
@@ -1281,9 +1408,9 @@ class WP_PollDaddy {
1281
 
1282
  </ul>
1283
 
1284
- <span style="margin:6px 6px 8px;" id="cookieip_expiration_label"><label><?php _e( 'Expires: ' ); ?></label></span>
1285
  <select id="cookieip_expiration" name="cookieip_expiration" style="width: auto;<?php echo $poll->blockRepeatVotersType == 'off' ? 'display:none;' : ''; ?>">
1286
- <option value="0" <?php echo (int) $poll->blockExpiration == 0 ? 'selected' : ''; ?>><?php _e( 'Never' ); ?></option>
1287
  <option value="3600" <?php echo (int) $poll->blockExpiration == 3600 ? 'selected' : ''; ?>><?php printf( __('%d hour'), 1 ); ?></option>
1288
  <option value="10800" <?php echo (int) $poll->blockExpiration == 10800 ? 'selected' : ''; ?>><?php printf( __('%d hours'), 3 ); ?></option>
1289
  <option value="21600" <?php echo (int) $poll->blockExpiration == 21600 ? 'selected' : ''; ?>><?php printf( __('%d hours'), 6 ); ?></option>
@@ -1307,7 +1434,7 @@ class WP_PollDaddy {
1307
  </div>
1308
 
1309
  <div id="answersdiv" class="postbox">
1310
- <h3><?php _e( 'Answers' ); ?></h3>
1311
 
1312
  <div id="answerswrap" class="inside">
1313
  <ul id="answers">
@@ -1353,13 +1480,13 @@ class WP_PollDaddy {
1353
  </ul>
1354
 
1355
  <p id="add-answer-holder">
1356
- <button class="button"><?php echo wp_specialchars( __( 'Add another' ) ); ?></button>
1357
  </p>
1358
 
1359
  <ul id="answer-options">
1360
 
1361
  <?php
1362
- foreach ( array( 'multipleChoice' => __( 'Multiple choice' ), 'randomiseAnswers' => __( 'Randomize answer order' ), 'otherAnswer' => __( 'Allow other answers' ), 'sharing' => __( "'Share This' link" ) ) as $option => $label ) :
1363
  if ( $is_POST )
1364
  $checked = 'yes' === $_POST[$option] ? ' checked="checked"' : '';
1365
  else
@@ -1471,7 +1598,7 @@ class WP_PollDaddy {
1471
  $styles = $polldaddy->get_styles();
1472
 
1473
  $show_custom = false;
1474
- if( isset( $styles ) && count( $styles ) > 0 ){
1475
  foreach( (array) $styles->style as $style ){
1476
  $options[ (int) $style->_id ] = $style->title;
1477
  }
@@ -1488,7 +1615,7 @@ class WP_PollDaddy {
1488
  }
1489
  ?>
1490
 
1491
- <h3><?php _e( 'Design' ); ?></h3>
1492
  <input type="hidden" name="styleID" id="styleID" value="<?php echo $style_ID ?>">
1493
  <div class="inside">
1494
  <?php if ( $iframe_view ){ ?>
@@ -1569,7 +1696,7 @@ class WP_PollDaddy {
1569
  <div style="display:none;">
1570
  <?php $disabled = $show_custom == false ? ' disabled="true"' : ''; ?>
1571
  <input type="radio" name="styleTypeCB" id="custom" onclick="javascript:pd_change_style($('customSelect').value);" <?php echo $disabled; ?>></input>
1572
- <label onclick="javascript:pd_change_style($('customSelect').value);"><?php _e( 'Custom Style' ); ?></label>
1573
  </div>
1574
  </th>
1575
  </tr>
@@ -1582,18 +1709,18 @@ class WP_PollDaddy {
1582
  <td><?php $hide = $show_custom == true ? ' style="display:block;"' : ' style="display:none;"'; ?>
1583
  <select id="customSelect" name="customSelect" onclick="pd_change_style(this.value);" <?php echo $hide ?>>
1584
  <?php $selected = $custom_style_ID == 0 ? ' selected="selected"' : ''; ?>
1585
- <option value="x"<?php echo $selected; ?>><?php _e( 'Please choose a custom style...' ); ?></option>
1586
- <?php foreach ( $styles->style as $style ) :
1587
  $selected = $style->_id == $custom_style_ID ? ' selected="selected"' : ''; ?>
1588
  <option value="<?php echo (int) $style->_id; ?>"<?php echo $selected; ?>><?php echo wp_specialchars( $style->title ); ?></option>
1589
- <?php endforeach;?>
1590
  </select>
1591
- <div id="styleIDErr" class="formErr" style="display:none;"><?php _e( 'Please choose a style.' ); ?></div></td>
1592
  </tr>
1593
  <tr>
1594
  <td><?php $extra = $show_custom == false ? 'You currently have no custom styles created.' : ''; ?>
1595
  <p><?php echo $extra ?></p>
1596
- <p><?php printf( __( 'Did you know we have a new editor for building your own custom poll styles? Find out more <a href="%s" target="_blank">here</a>.' ), 'http://support.polldaddy.com/custom-poll-styles/' ); ?></p>
1597
  </td>
1598
  </tr>
1599
  </table>
@@ -1604,7 +1731,7 @@ class WP_PollDaddy {
1604
  </p>
1605
  </div>
1606
  <div id="design_options">
1607
- <a href="#" class="polldaddy-show-design-options"><?php _e( 'Custom Styles' ); ?></a>
1608
  </div>
1609
  <?php }}else{?>
1610
  <div class="design_standard">
@@ -1616,7 +1743,7 @@ class WP_PollDaddy {
1616
  <input type="radio" name="styleTypeCB" id="regular" onclick="javascript:pd_build_styles( 0 );"/>
1617
  </th>
1618
  <th>
1619
- <label for="skin" onclick="javascript:pd_build_styles( 0 );"><?php _e( 'PollDaddy Style' ); ?></label>
1620
  </th>
1621
  <th/>
1622
  <th class="cb">
@@ -1624,7 +1751,7 @@ class WP_PollDaddy {
1624
  <input type="radio" name="styleTypeCB" id="custom" onclick="javascript:pd_change_style($('customSelect').value);" <?php echo $disabled; ?>></input>
1625
  </th>
1626
  <th>
1627
- <label onclick="javascript:pd_change_style($('customSelect').value);"><?php _e( 'Custom Style' ); ?></label>
1628
  </th>
1629
  </tr>
1630
  </thead>
@@ -1689,7 +1816,7 @@ class WP_PollDaddy {
1689
  <tr>
1690
  <td><?php $extra = $show_custom == false ? 'You currently have no custom styles created.' : ''; ?>
1691
  <p><?php echo $extra ?></p>
1692
- <p><?php printf( __( 'Did you know we have a new editor for building your own custom poll styles? Find out more <a href="%s" target="_blank">here</a>.' ), 'http://support.polldaddy.com/custom-poll-styles/' ); ?></p>
1693
  </td>
1694
  </tr>
1695
  </table>
@@ -1732,7 +1859,7 @@ class WP_PollDaddy {
1732
  }
1733
 
1734
  function poll_results_page( $poll_id ) {
1735
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
1736
  $polldaddy->reset();
1737
 
1738
  $results = $polldaddy->get_poll_results( $poll_id );
@@ -1741,8 +1868,8 @@ class WP_PollDaddy {
1741
  <table class="poll-results widefat">
1742
  <thead>
1743
  <tr>
1744
- <th scope="col" class="column-title"><?php _e( 'Answer' ); ?></th>
1745
- <th scope="col" class="column-vote"><?php _e( 'Votes' ); ?></th>
1746
  </tr>
1747
  </thead>
1748
  <tbody>
@@ -1756,7 +1883,7 @@ class WP_PollDaddy {
1756
  }
1757
 
1758
  $class = $class ? '' : ' class="alternate"';
1759
- $content = $results->others && 'Other answer...' === $answer->text ? sprintf( __( 'Other (<a href="%s">see below</a>)' ), '#other-answers-results' ) : wp_specialchars( $answer->text );
1760
 
1761
  ?>
1762
 
@@ -1786,8 +1913,8 @@ class WP_PollDaddy {
1786
  <table id="other-answers-results" class="poll-others widefat">
1787
  <thead>
1788
  <tr>
1789
- <th scope="col" class="column-title"><?php _e( 'Other Answer' ); ?></th>
1790
- <th scope="col" class="column-vote"><?php _e( 'Votes' ); ?></th>
1791
  </tr>
1792
  </thead>
1793
  <tbody>
@@ -1815,7 +1942,7 @@ class WP_PollDaddy {
1815
  }
1816
 
1817
  function styles_table() {
1818
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
1819
  $polldaddy->reset();
1820
 
1821
  $styles_object = $polldaddy->get_styles();
@@ -1838,10 +1965,10 @@ class WP_PollDaddy {
1838
  <div class="tablenav">
1839
  <div class="alignleft">
1840
  <select name="action">
1841
- <option selected="selected" value=""><?php _e( 'Actions' ); ?></option>
1842
- <option value="delete-style"><?php _e( 'Delete' ); ?></option>
1843
  </select>
1844
- <input class="button-secondary action" type="submit" name="doaction" value="<?php _e( 'Apply' ); ?>" />
1845
  <?php wp_nonce_field( 'action-style_bulk' ); ?>
1846
  </div>
1847
  <div class="tablenav-pages"></div>
@@ -1851,8 +1978,8 @@ class WP_PollDaddy {
1851
  <thead>
1852
  <tr>
1853
  <th id="cb" class="manage-column column-cb check-column" scope="col" /><input type="checkbox" /></th>
1854
- <th id="title" class="manage-column column-title" scope="col"><?php _e( 'Style' ); ?></th>
1855
- <th id="date" class="manage-column column-date" scope="col"><?php _e( 'Last Modified' ); ?></th>
1856
  </tr>
1857
  </thead>
1858
  <tbody>
@@ -1875,12 +2002,12 @@ class WP_PollDaddy {
1875
  <td class="post-title column-title">
1876
  <?php if ( $edit_link ) : ?>
1877
  <strong><a class="row-title" href="<?php echo $edit_link; ?>"><?php echo wp_specialchars( $style->title ); ?></a></strong>
1878
- <span class="edit"><a href="<?php echo $edit_link; ?>"><?php _e( 'Edit' ); ?></a> | </span>
1879
  <?php else : ?>
1880
  <strong><?php echo wp_specialchars( $style->title ); ?></strong>
1881
  <?php endif; ?>
1882
 
1883
- <span class="delete"><a class="delete-poll delete" href="<?php echo $delete_link; ?>"><?php _e( 'Delete' ); ?></a></span>
1884
  </td>
1885
  <td class="date column-date"><abbr title="<?php echo date( __('Y/m/d g:i:s A'), $style_time ); ?>"><?php echo date( __('Y/m/d'), $style_time ); ?></abbr></td>
1886
  </tr>
@@ -1892,7 +2019,7 @@ class WP_PollDaddy {
1892
  ?>
1893
 
1894
  <tr>
1895
- <td colspan="4"><?php printf( __( 'No custom styles yet. <a href="%s">Create one</a>' ), clean_url( add_query_arg( array( 'action' => 'create-style' ) ) ) ); ?></td>
1896
  </tr>
1897
  <?php endif; // $styles ?>
1898
 
@@ -1910,7 +2037,7 @@ class WP_PollDaddy {
1910
  function style_edit_form( $style_id = 105 ) {
1911
  $style_id = (int) $style_id;
1912
 
1913
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
1914
  $polldaddy->reset();
1915
 
1916
  $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
@@ -1968,7 +2095,7 @@ class WP_PollDaddy {
1968
  <table width="100%">
1969
  <tr>
1970
  <td valign="middle" width="8%">
1971
- <label class="CSSE_title_label"><?php _e( 'Style Name' ); ?></label>
1972
  </td>
1973
  <td>
1974
  <div id="titlediv" style="margin:0px;">
@@ -1983,7 +2110,7 @@ class WP_PollDaddy {
1983
  </tr>
1984
  <tr>
1985
  <td width="13%">
1986
- <label class="CSSE_title_label"><?php _e( 'Preload Basic Style' ); ?></label>
1987
  </td>
1988
  <td>
1989
  <div class="CSSE_preload">
@@ -1997,7 +2124,7 @@ class WP_PollDaddy {
1997
  <option value="117">Skull Light</option>
1998
  <option value="157">Micro</option>
1999
  </select>
2000
- <a tabindex="4" id="style-preload" href="javascript:preload_pd_style();" class="button"><?php echo attribute_escape( __( 'Load Style' ) ); ?></a>
2001
  </div>
2002
  </td>
2003
  </tr>
@@ -2788,7 +2915,7 @@ class WP_PollDaddy {
2788
  <?php wp_nonce_field( $style_id > 1000 ? "edit-style$style_id" : 'create-style' ); ?>
2789
  <input type="hidden" name="action" value="<?php echo $style_id > 1000 ? 'edit-style' : 'create-style'; ?>" />
2790
  <input type="hidden" class="polldaddy-style-id" name="style" value="<?php echo $style_id; ?>" />
2791
- <input type="submit" class="button-primary" value="<?php echo attribute_escape( __( 'Save Style' ) ); ?>" />
2792
 
2793
  </div>
2794
  </div>
@@ -2817,14 +2944,10 @@ enter a numeric value in pixels.
2817
  <?php
2818
  }
2819
 
2820
- function rating_settings( $rating_updated = false ){
2821
- global $rating;
2822
- $show_pages = 0;
2823
- $show_comments = 0;
2824
- $pos_posts = 0;
2825
- $pos_pages = 0;
2826
- $pos_comments = 0;
2827
- $show_settings = $rating_updated;
2828
  $error = false;
2829
 
2830
  $settings_style = 'display: none;';
@@ -2907,7 +3030,7 @@ enter a numeric value in pixels.
2907
  endswitch;
2908
  }
2909
 
2910
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
2911
  $polldaddy->reset();
2912
  $response = $polldaddy->get_rating( $rating_id );
2913
 
@@ -2960,6 +3083,9 @@ enter a numeric value in pixels.
2960
  $rating_type = 0;
2961
  else
2962
  $rating_type = 1;
 
 
 
2963
  }
2964
 
2965
  ?>
@@ -3138,23 +3264,23 @@ enter a numeric value in pixels.
3138
  <td><input onblur="pd_bind(this);" type="text" name="text_rate_this" id="text_rate_this" value="<?php echo( wp_specialchars( $settings->text_rate_this ) ); ?>" maxlength="20" />
3139
  </tr>
3140
  <tr>
3141
- <td height="30"><?php printf(__( '%d star' ), 1);?></td>
3142
  <td><input onblur="pd_bind(this);" type="text" name="text_1_star" id="text_1_star" value="<?php echo( wp_specialchars( $settings->text_1_star ) ); ?>" maxlength="20" />
3143
  </tr>
3144
  <tr>
3145
- <td height="30"><?php printf(__( '%d stars' ), 2);?></td>
3146
  <td><input onblur="pd_bind(this);" type="text" name="text_2_star" id="text_2_star" value="<?php echo( wp_specialchars( $settings->text_2_star ) ); ?>" maxlength="20" />
3147
  </tr>
3148
  <tr>
3149
- <td height="30"><?php printf(__( '%d stars' ), 3);?></td>
3150
  <td><input onblur="pd_bind(this);" type="text" name="text_3_star" id="text_3_star" value="<?php echo( wp_specialchars( $settings->text_3_star ) ); ?>" maxlength="20" />
3151
  </tr>
3152
  <tr>
3153
- <td height="30"><?php printf(__( '%d stars' ), 4);?></td>
3154
  <td><input onblur="pd_bind(this);" type="text" name="text_4_star" id="text_4_star" value="<?php echo( wp_specialchars( $settings->text_4_star ) ); ?>" maxlength="20" />
3155
  </tr>
3156
  <tr>
3157
- <td height="30"><?php printf(__( '%d stars' ), 5);?></td>
3158
  <td><input onblur="pd_bind(this);" type="text" name="text_5_star" id="text_5_star" value="<?php echo( wp_specialchars( $settings->text_5_star ) ); ?>" maxlength="20" />
3159
  </tr>
3160
  <tr>
@@ -3189,7 +3315,7 @@ enter a numeric value in pixels.
3189
  $checked = ' checked="checked"';
3190
  ?>
3191
  <input type="radio" onchange="pd_change_type( 0 );" <?php echo ( $checked ); ?> value="stars" id="stars" name="rating_type" />
3192
- <?php printf(__( '%d Star Rating' ), 5);?>
3193
  </label>
3194
  </li>
3195
  <li style="display: inline;">
@@ -3448,12 +3574,12 @@ enter a numeric value in pixels.
3448
 
3449
  $settings_text = json_encode( $set );
3450
 
3451
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
3452
  $polldaddy->reset();
3453
  $response = $polldaddy->update_rating( $rating_id, $settings_text, $rating_type );
3454
  }
3455
  function rating_reports() {
3456
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
3457
  $rating_id = get_option( 'pd-rating-posts-id' );
3458
 
3459
  $report_type = 'posts';
@@ -3682,6 +3808,226 @@ enter a numeric value in pixels.
3682
  <p></p>
3683
  <?php
3684
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3685
 
3686
  function round($number, $increments) {
3687
  $increments = 1 / $increments;
@@ -3692,144 +4038,16 @@ enter a numeric value in pixels.
3692
  return $this->api_key_page();
3693
  }
3694
 
3695
- function can_edit( &$poll ) {
3696
- global $current_user;
3697
- if ( empty( $poll->_owner ) )
3698
  return true;
3699
-
3700
- if ( $current_user->ID == $poll->_owner )
3701
- return true;
3702
-
3703
- return current_user_can( 'edit_others_posts' );
3704
- }
3705
- }
3706
-
3707
- function polldaddy_loader() {
3708
- global $polldaddy_object;
3709
- $polldaddy_class = WP_POLLDADDY__CLASS;
3710
- $polldaddy_object = new $polldaddy_class;
3711
- add_action( 'admin_menu', array( &$polldaddy_object, 'admin_menu' ) );
3712
- }
3713
-
3714
- add_action( 'init', 'polldaddy_loader' );
3715
- add_filter( 'the_content', 'polldaddy_show_rating', 1 );
3716
- add_filter( 'comment_text', 'polldaddy_show_rating_comments', 50 );
3717
-
3718
- function polldaddy_shortcode($atts, $content=null) {
3719
- extract(shortcode_atts(array(
3720
- 'poll' => 'empty',
3721
- 'cb' => '',
3722
- ), $atts));
3723
-
3724
- $poll = (int) $poll;
3725
- $cb = ( $cb == 1 ? '?cb=' . mktime() : '' );
3726
-
3727
- return "<script type='text/javascript' language='javascript' charset='utf-8' src='http://s3.polldaddy.com/p/$poll.js$cb'></script><noscript> <a href='http://answers.polldaddy.com/poll/$poll/'>View Poll</a></noscript>";
3728
- }
3729
-
3730
- function polldaddy_show_rating_comments( $content ){
3731
- if ( !is_feed() ) {
3732
- global $comment;
3733
- global $post;
3734
-
3735
- if ( $comment->comment_ID > 0 ) {
3736
- $unique_id = '';
3737
- $title = '';
3738
- $permalink = '';
3739
- $html = '';
3740
- $rating_pos = 0;
3741
 
3742
- if ( (int) get_option( 'pd-rating-comments' ) > 0 ) {
3743
- $rating_id = (int) get_option( 'pd-rating-comments' );
3744
- $unique_id = 'wp-comment-' . $comment->comment_ID;
3745
- $rating_pos = (int) get_option( 'pd-rating-comments-pos' );
3746
- $title = mb_substr( $comment->comment_content, 0, 195 ) . '...';
3747
- $permalink = get_permalink( $post->ID ) . '#comment-' . $comment->comment_ID;
3748
- $html = polldaddy_get_rating_code( $rating_id, $unique_id, $title, $permalink, '_comm_' . $comment->comment_ID );
3749
-
3750
- wp_register_script( 'polldaddy-rating-js', 'http://i.polldaddy.com/ratings/rating.js' );
3751
- add_filter( 'wp_footer', 'polldaddy_add_rating_js' );
3752
- }
3753
-
3754
- if ( $rating_pos == 0 )
3755
- $content = $html . $content;
3756
- else
3757
- $content .= $html;
3758
- }
3759
- }
3760
- return $content;
3761
- }
3762
-
3763
- function polldaddy_show_rating( $content ) {
3764
- if ( !is_feed() && !is_attachment() ) {
3765
- if ( is_single() || is_page() ) {
3766
- global $post;
3767
-
3768
- if ( $post->ID > 0 ) {
3769
- $unique_id = '';
3770
- $title = '';
3771
- $permalink = '';
3772
- $html = '';
3773
- $rating_id = 0;
3774
- $rating_pos = 0;
3775
- $item_id = '';
3776
-
3777
- if ( is_page() ) {
3778
- if ( (int) get_option( 'pd-rating-pages' ) > 0 ) {
3779
- $rating_id = (int) get_option( 'pd-rating-pages' );
3780
- $unique_id = 'wp-page-' . $post->ID;
3781
- $rating_pos = (int) get_option( 'pd-rating-pages-pos' );
3782
- $item_id = '_page_' . $post->ID;
3783
- }
3784
- } else {
3785
- if ( (int) get_option( 'pd-rating-posts' ) > 0 ) {
3786
- $rating_id = (int) get_option( 'pd-rating-posts' );
3787
- $unique_id = 'wp-post-' . $post->ID;
3788
- $rating_pos = (int) get_option( 'pd-rating-posts-pos' );
3789
- $item_id = '_post_' . $post->ID;
3790
- }
3791
- }
3792
-
3793
- if ( $rating_id > 0 ) {
3794
- $title = $post->post_title;
3795
- $permalink = get_permalink( $post->ID );
3796
- $html = polldaddy_get_rating_code( $rating_id, $unique_id, $title, $permalink, $item_id );
3797
-
3798
- wp_register_script( 'polldaddy-rating-js', 'http://i.polldaddy.com/ratings/rating.js' );
3799
- add_filter( 'wp_footer', 'polldaddy_add_rating_js' );
3800
- }
3801
 
3802
- if ( $rating_pos == 0 )
3803
- $content = $html . $content;
3804
- else
3805
- $content .= $html;
3806
- }
3807
- }
3808
  }
3809
- return $content;
3810
- }
3811
-
3812
- function polldaddy_get_rating_code( $rating_id, $unique_id, $title, $permalink, $item_id = '' ) {
3813
-
3814
- $html = '<p><div class="pd-rating" id="pd_rating_holder_' . $rating_id . $item_id . '"></div></p>
3815
- <script type="text/javascript">
3816
- PDRTJS_settings_' . (int)$rating_id . $item_id . ' = {
3817
- "id" : "' . (int)$rating_id . '",
3818
- "unique_id" : "' . urlencode( $unique_id ) . '",
3819
- "title" : "' . urlencode( $title ) . '",' . "\n";
3820
-
3821
- if ( $item_id != '' )
3822
- $html .= ( ' "item_id" : "' . $item_id . '",' . "\n" );
3823
-
3824
- $html .= ' "permalink" : "' . urlencode( clean_url( $permalink ) ) . '"';
3825
- $html .= "\n }\n";
3826
- $html .= '</script>';
3827
-
3828
- return $html;
3829
- }
3830
-
3831
- function polldaddy_add_rating_js() {
3832
- wp_print_scripts( 'polldaddy-rating-js' );
3833
  }
3834
 
3835
- add_shortcode('polldaddy', 'polldaddy_shortcode');
 
2
 
3
  /*
4
  Plugin Name: PollDaddy Polls
5
+ Description: Create and manage PollDaddy polls and ratings in WordPress
6
  Author: Automattic, Inc.
7
  Author URL: http://automattic.com/
8
+ Version: 1.7.8
9
  */
10
 
11
  // You can hardcode your PollDaddy PartnerGUID (API Key) here
12
  //define( 'WP_POLLDADDY__PARTNERGUID', '12345...' );
13
 
 
 
 
 
 
 
 
14
  class WP_PollDaddy {
15
  var $errors;
16
+ var $base_url;
17
+ var $is_admin;
18
+ var $is_author;
19
+ var $scheme;
20
+ var $version;
21
+ var $polldaddy_client_class;
22
+ var $polldaddy_clients;
23
+ var $id;
24
+ var $multiple_accounts;
25
+ var $user_code;
26
+
27
+ function WP_PollDaddy(){
28
+ $this ->__construct();
29
+ }
30
+
31
+ function __construct() {
32
+ global $current_user;
33
+ $this->errors = new WP_Error;
34
+ $this->scheme = 'https';
35
+ $this->version = '1.7.8';
36
+ $this->multiple_accounts = true;
37
+ $this->polldaddy_client_class = 'api_client';
38
+ $this->polldaddy_clients = array();
39
+ $this->is_admin = (bool) current_user_can('manage_options');
40
+ $this->is_author = true;
41
+ $this->id = (int) $current_user->ID;
42
+ $this->user_code = null;
43
+ }
44
+
45
  function &get_client( $api_key, $userCode = null ) {
46
  if ( isset( $this->polldaddy_clients[$api_key] ) ) {
47
+ if ( !is_null( $userCode ) )
48
  $this->polldaddy_clients[$api_key]->userCode = $userCode;
49
  return $this->polldaddy_clients[$api_key];
50
  }
53
  return $this->polldaddy_clients[$api_key];
54
  }
55
 
56
+ function admin_menu() {
 
 
 
 
 
57
  if ( !defined( 'WP_POLLDADDY__PARTNERGUID' ) ) {
58
  $guid = get_option( 'polldaddy_api_key' );
59
  if ( !$guid || !is_string( $guid ) )
60
  $guid = false;
61
  define( 'WP_POLLDADDY__PARTNERGUID', $guid );
62
  }
63
+
64
+ if ( !WP_POLLDADDY__PARTNERGUID ) {
 
 
65
  if ( function_exists( 'add_object_page' ) ) // WP 2.7+
66
+ $hook = add_object_page( __( 'Ratings', 'polldaddy' ), __( 'Ratings', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'api_key_page' ), "{$this->base_url}polldaddy.png" );
67
+ else
68
+ $hook = add_management_page( __( 'Ratings', 'polldaddy' ), __( 'Ratings', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'api_key_page' ) );
69
+
70
+ add_action( "load-$hook", array( &$this, 'api_key_page_load' ) );
71
+
72
+ if ( function_exists( 'add_object_page' ) ) // WP 2.7+
73
+ $hook = add_object_page( __( 'Polls', 'polldaddy' ), __( 'Polls', 'polldaddy' ), 'edit_posts', 'polls', array( &$this, 'api_key_page' ), "{$this->base_url}polldaddy.png" );
74
+ else
75
+ $hook = add_management_page( __( 'Polls', 'polldaddy' ), __( 'Polls', 'polldaddy' ), 'edit_posts', 'polls', array( &$this, 'api_key_page' ) );
76
+
77
+ add_action( "load-$hook", array( &$this, 'api_key_page_load' ) );
78
+ if ( ( empty( $_GET['page'] ) || 'polls' != $_GET['page'] ) && ( empty( $_GET['page'] ) || 'ratings' != $_GET['page'] ) )
79
  add_action( 'admin_notices', create_function( '', 'echo "<div class=\"error\"><p>" . sprintf( "You need to <a href=\"%s\">input your PollDaddy.com account details</a>.", "edit.php?page=polls" ) . "</p></div>";' ) );
80
  return false;
81
+ }
82
 
83
  if ( function_exists( 'add_object_page' ) ) // WP 2.7+
84
+ $hook = add_object_page( __( 'Ratings', 'polldaddy' ), __( 'Ratings', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'management_page' ), "{$this->base_url}polldaddy.png" );
85
  else
86
+ $hook = add_management_page( __( 'Ratings', 'polldaddy' ), __( 'Ratings', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'management_page' ) );
87
 
88
  add_action( "load-$hook", array( &$this, 'management_page_load' ) );
89
 
90
  if ( function_exists( 'add_object_page' ) ) // WP 2.7+
91
+ $hook = add_object_page( __( 'Polls', 'polldaddy' ), __( 'Polls', 'polldaddy' ), 'edit_posts', 'polls', array( &$this, 'management_page' ), "{$this->base_url}polldaddy.png" );
92
  else
93
+ $hook = add_management_page( __( 'Polls', 'polldaddy' ), __( 'Polls', 'polldaddy' ), 'edit_posts', 'polls', array( &$this, 'management_page' ) );
94
 
95
  add_action( "load-$hook", array( &$this, 'management_page_load' ) );
96
 
97
+ if ( $this->is_admin ) {
98
+ add_submenu_page( 'ratings', __( 'Ratings &ndash; Settings', 'polldaddy' ), __( 'Settings', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'management_page' ) );
99
+ add_submenu_page( 'ratings', __( 'Ratings &ndash; Reports', 'polldaddy' ), __( 'Reports', 'polldaddy' ), 'edit_posts', 'ratings&amp;action=reports', array( &$this, 'management_page' ) );
100
+ }
101
+ else{
102
+ add_submenu_page( 'ratings', __( 'Ratings &ndash; Reports', 'polldaddy' ), __( 'Reports', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'management_page' ) );
103
+ }
104
 
105
+ add_submenu_page( 'polls', __( 'Polls', 'polldaddy' ), __( 'Edit', 'polldaddy' ), 'edit_posts', 'polls', array( &$this, 'management_page' ) );
106
+
107
+ if ( $this->is_author ) {
108
+ add_submenu_page( 'polls', __( 'Add New Poll', 'polldaddy' ), __( 'Add New', 'polldaddy' ), 'edit_posts', 'polls&amp;action=create-poll', array( &$this, 'management_page' ) );
109
+ add_submenu_page( 'polls', __( 'Custom Styles', 'polldaddy' ), __( 'Custom Styles', 'polldaddy' ), 'edit_posts', 'polls&amp;action=list-styles', array( &$this, 'management_page' ) );
110
+ add_submenu_page( 'polls', __( 'Options', 'polldaddy' ), __( 'Options', 'polldaddy' ), 'edit_posts', 'polls&amp;action=options', array( &$this, 'management_page' ) );
111
+ }
112
 
113
  add_action( 'media_buttons', array( &$this, 'media_buttons' ) );
114
  }
115
 
116
+ function api_key_page_load() {
117
  if ( 'post' != strtolower( $_SERVER['REQUEST_METHOD'] ) || empty( $_POST['action'] ) || 'account' != $_POST['action'] )
118
  return false;
119
 
121
 
122
  $polldaddy_email = stripslashes( $_POST['polldaddy_email'] );
123
  $polldaddy_password = stripslashes( $_POST['polldaddy_password'] );
124
+
125
  if ( !$polldaddy_email )
126
+ $this->errors->add( 'polldaddy_email', __( 'Email address required', 'polldaddy' ) );
127
 
128
  if ( !$polldaddy_password )
129
+ $this->errors->add( 'polldaddy_password', __( 'Password required', 'polldaddy' ) );
130
 
131
  if ( $this->errors->get_error_codes() )
132
  return false;
133
 
 
 
 
 
 
 
 
 
 
 
134
  $details = array(
135
  'uName' => get_bloginfo( 'name' ),
136
  'uEmail' => $polldaddy_email,
137
  'uPass' => $polldaddy_password,
138
+ 'partner_userid' => $this->id
139
  );
 
140
  if ( function_exists( 'wp_remote_post' ) ) { // WP 2.7+
141
  $polldaddy_api_key = wp_remote_post( $this->scheme . '://api.polldaddy.com/key.php', array(
142
  'body' => $details
145
  $this->errors = $polldaddy_api_key;
146
  return false;
147
  }
 
 
 
 
 
148
  $polldaddy_api_key = wp_remote_retrieve_body( $polldaddy_api_key );
149
  } else {
150
  $fp = fsockopen(
156
  );
157
 
158
  if ( !$fp ) {
159
+ $this->errors->add( 'connect', __( "Can't connect to PollDaddy.com", 'polldaddy' ) );
160
  return false;
161
  }
162
 
182
  list($headers, $polldaddy_api_key) = explode( "\r\n\r\n", $response, 2 );
183
  }
184
 
185
+ if ( !$polldaddy_api_key ) {
186
+ $this->errors->add( 'polldaddy_password', __( 'Invalid Account', 'polldaddy' ) );
 
 
 
 
 
 
 
 
 
187
  return false;
188
  }
189
 
190
+ update_option( 'polldaddy_api_key', $polldaddy_api_key );
191
+
192
  $polldaddy = $this->get_client( $polldaddy_api_key );
193
  $polldaddy->reset();
194
+ if ( !$polldaddy->get_usercode( $this->id ) ) {
195
  $this->parse_errors( $polldaddy );
196
+ $this->errors->add( 'GetUserCode', __( 'Account could not be accessed. Are your email address and password correct?', 'polldaddy' ) );
197
  return false;
198
  }
199
+
200
+ return true;
 
201
  }
202
 
203
  function parse_errors( &$polldaddy ) {
205
  foreach ( $polldaddy->errors as $code => $error )
206
  $this->errors->add( $code, $error );
207
  if ( isset( $this->errors->errors[4] ) ) {
208
+ $this->errors->errors[4] = array( sprintf( __( 'Obsolete PollDaddy User API Key: <a href="%s">Sign in again to re-authenticate</a>', 'polldaddy' ), add_query_arg( array( 'action' => 'signup', 'reaction' => empty( $_GET['action'] ) ? false : $_GET['action'] ) ) ) );
209
  $this->errors->add_data( true, 4 );
210
  }
211
  }
239
  }
240
 
241
  function api_key_page() {
242
+ $this->print_errors();
243
  ?>
244
 
245
  <div class="wrap">
246
 
247
+ <h2><?php _e( 'PollDaddy Account', 'polldaddy' ); ?></h2>
248
 
249
+ <p><?php printf( __( 'Before you can use the PollDaddy plugin, you need to enter your <a href="%s">PollDaddy.com</a> account details.', 'polldaddy' ), 'http://polldaddy.com/' ); ?></p>
250
 
251
  <form action="" method="post">
252
  <table class="form-table">
253
  <tbody>
254
  <tr class="form-field form-required">
255
  <th valign="top" scope="row">
256
+ <label for="polldaddy-email"><?php _e( 'PollDaddy Email Address', 'polldaddy' ); ?></label>
257
  </th>
258
  <td>
259
+ <input type="text" name="polldaddy_email" id="polldaddy-email" aria-required="true" size="40" />
260
  </td>
261
  </tr>
262
  <tr class="form-field form-required">
263
  <th valign="top" scope="row">
264
+ <label for="polldaddy-password"><?php _e( 'PollDaddy Password', 'polldaddy' ); ?></label>
265
  </th>
266
  <td>
267
  <input type="password" name="polldaddy_password" id="polldaddy-password" aria-required="true" size="40" />
268
  </td>
269
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270
  </tbody>
271
  </table>
272
  <p class="submit">
273
  <?php wp_nonce_field( 'polldaddy-account' ); ?>
274
  <input type="hidden" name="action" value="account" />
275
  <input type="hidden" name="account" value="import" />
276
+ <input type="submit" value="<?php echo attribute_escape( __( 'Submit', 'polldaddy' ) ); ?>" />
277
  </p>
278
  </form>
279
  </div>
282
  }
283
 
284
  function media_buttons() {
285
+ $title = __( 'Add Poll', 'polldaddy' );
286
+ echo "<a href='admin.php?page=polls&amp;iframe&amp;TB_iframe=true' onclick='return false;' id='add_poll' class='thickbox' title='$title'><img src='{$this->base_url}polldaddy.png' alt='$title' /></a>";
287
  }
288
 
289
  function management_page_load() {
290
+ global $plugin_page;
291
+
292
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID );
293
  $polldaddy->reset();
294
 
295
+ if ( empty( $this->user_code ) ){
296
+ $this->user_code = $polldaddy->get_usercode( $this->id );
297
+ }
298
+
299
  wp_reset_vars( array( 'page', 'action', 'poll', 'style', 'rating' ) );
300
  global $page, $action, $poll, $style, $rating;
301
 
302
+ if ( empty( $this->user_code ) ){
303
+ $action = 'signup';
304
+ $page = 'polls';
305
+ }
306
 
307
  require_once WP_POLLDADDY__POLLDADDY_CLIENT_PATH;
308
 
309
  wp_enqueue_script( 'polls', "{$this->base_url}polldaddy.js", array( 'jquery', 'jquery-ui-sortable' ), $this->version );
310
  wp_enqueue_script( 'polls-common', "{$this->base_url}common.js", array(), $this->version );
311
 
312
+ if( $page == 'polls' ) {
313
+ if ( !$this->is_author && in_array( $action, array( 'edit', 'edit-poll', 'create-poll', 'edit-style', 'create-style', 'list-styles', 'options', 'update-options', 'import-account' ) ) ) {//check user privileges has access to action
314
+ $action = '';
315
+ }
316
+
317
  switch ( $action ) :
318
  case 'edit' :
319
  case 'edit-poll' :
332
  break;
333
  case 'list-styles' :
334
  $plugin_page = 'polls&amp;action=list-styles';
335
+ break;
336
+ case 'options' :
337
+ case 'update-options' :
338
+ case 'import-account' :
339
+ $plugin_page = 'polls&amp;action=options';
340
  break;
341
  endswitch;
342
  } elseif( $page == 'ratings' ) {
343
+ if ( !$this->is_admin && !in_array( $action, array( 'change-report', 'reports' ) ) ) {//check user privileges has access to action
344
+ $action = 'reports';
345
+ }
346
  switch ( $action ) :
347
  case 'change-report' :
348
  case 'reports' :
352
  wp_enqueue_script( 'rating-text-color', "http://i.polldaddy.com/js/jscolor.js", array(), $this->version );
353
  wp_enqueue_script( 'ratings', 'http://i.polldaddy.com/ratings/rating.js', array(), $this->version );
354
  wp_localize_script( 'polls-common', 'adminRatingsL10n', array(
355
+ 'star_colors' => __( 'Star Colors', 'polldaddy' ), 'star_size' => __( 'Star Size', 'polldaddy' ),
356
+ 'nero_type' => __( 'Nero Type', 'polldaddy' ), 'nero_size' => __( 'Nero Size', 'polldaddy' ), ) );
357
  endswitch;
358
  }
359
 
406
  switch ( $action ) :
407
  case 'signup' : // sign up for first time
408
  case 'account' : // reauthenticate
409
+ case 'import-account' : // reauthenticate
410
  if ( !$is_POST )
411
+ return;
412
 
413
  check_admin_referer( 'polldaddy-account' );
414
 
416
  $query_args = array_merge( $query_args, $new_args );
417
  if ( $this->errors->get_error_codes() )
418
  return false;
419
+
420
+ $query_args['message'] = 'imported-account';
421
 
422
  wp_reset_vars( array( 'action' ) );
423
  if ( !empty( $_GET['reaction'] ) )
424
  $query_args['action'] = $_GET['reaction'];
425
+ elseif ( !empty( $_GET['action'] ) && 'account' == $_GET['action'] )
426
  $query_args['action'] = $_GET['action'];
427
  else
428
  $query_args['action'] = false;
429
  break;
430
+
431
  case 'delete' :
432
  if ( empty( $poll ) )
433
  return;
434
 
435
  if ( is_array( $poll ) )
436
+ check_admin_referer( 'action-poll_bulk' );
437
  else
438
  check_admin_referer( "delete-poll_$poll" );
439
 
440
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
441
 
442
  foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
443
  $polldaddy->reset();
444
  $poll_object = $polldaddy->get_poll( $poll );
445
 
446
  if ( !$this->can_edit( $poll_object ) ) {
447
+ $this->errors->add( 'permission', __( 'You are not allowed to delete this poll.', 'polldaddy' ) );
448
  return false;
449
  }
450
 
451
  // Send Poll Author credentials
452
+ if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
453
  $polldaddy->reset();
454
  if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
455
+ $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
456
  }
457
  $polldaddy->userCode = $userCode;
458
  }
473
  else
474
  check_admin_referer( "open-poll_$poll" );
475
 
476
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
477
 
478
  foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
479
  $polldaddy->reset();
480
  $poll_object = $polldaddy->get_poll( $poll );
481
 
482
  if ( !$this->can_edit( $poll_object ) ) {
483
+ $this->errors->add( 'permission', __( 'You are not allowed to open this poll.', 'polldaddy' ) );
484
  return false;
485
  }
486
 
487
  // Send Poll Author credentials
488
+ if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
489
  $polldaddy->reset();
490
  if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
491
+ $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
492
  }
493
  $polldaddy->userCode = $userCode;
494
  }
509
  else
510
  check_admin_referer( "close-poll_$poll" );
511
 
512
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
513
 
514
  foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
515
  $polldaddy->reset();
516
  $poll_object = $polldaddy->get_poll( $poll );
517
 
518
  if ( !$this->can_edit( $poll_object ) ) {
519
+ $this->errors->add( 'permission', __( 'You are not allowed to close this poll.', 'polldaddy' ) );
520
  return false;
521
  }
522
 
523
  // Send Poll Author credentials
524
+ if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
525
  $polldaddy->reset();
526
  if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
527
+ $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
528
  }
529
  $polldaddy->userCode = $userCode;
530
  }
542
 
543
  check_admin_referer( "edit-poll_$poll" );
544
 
545
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
546
  $polldaddy->reset();
547
 
548
  $poll_object = $polldaddy->get_poll( $poll );
549
  $this->parse_errors( $polldaddy );
550
 
551
  if ( !$this->can_edit( $poll_object ) ) {
552
+ $this->errors->add( 'permission', __( 'You are not allowed to edit this poll.', 'polldaddy' ) );
553
  return false;
554
  }
555
 
556
  // Send Poll Author credentials
557
 
558
+ if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
559
  $polldaddy->reset();
560
  if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
561
+ $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
562
  }
563
  $this->parse_errors( $polldaddy );
564
  $polldaddy->userCode = $userCode;
565
  }
566
 
567
  if ( !$poll_object )
568
+ $this->errors->add( 'GetPoll', __( 'Poll not found', 'polldaddy' ) );
569
 
570
  if ( $this->errors->get_error_codes() )
571
  return false;
592
  $poll_data['question'] = stripslashes( $_POST['question'] );
593
 
594
  if ( empty( $_POST['answer'] ) || !is_array( $_POST['answer'] ) )
595
+ $this->errors->add( 'answer', __( 'Invalid answers', 'polldaddy' ) );
596
 
597
  $answers = array();
598
  foreach ( $_POST['answer'] as $answer_id => $answer ) {
608
  }
609
 
610
  if ( 2 > count( $answers ) )
611
+ $this->errors->add( 'answer', __( 'You must include at least 2 answers', 'polldaddy' ) );
612
 
613
  if ( $this->errors->get_error_codes() )
614
  return false;
619
 
620
  if ( isset ( $_POST['styleID'] ) ){
621
  if ( $_POST['styleID'] == 'x' ){
622
+ $this->errors->add( 'UpdatePoll', __( 'Please choose a poll style', 'polldaddy' ) );
623
  return false;
624
  }
625
  }
641
  $this->parse_errors( $polldaddy );
642
 
643
  if ( !$update_response )
644
+ $this->errors->add( 'UpdatePoll', __( 'Poll could not be updated', 'polldaddy' ) );
645
 
646
  if ( $this->errors->get_error_codes() )
647
  return false;
656
 
657
  check_admin_referer( 'create-poll' );
658
 
659
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
660
  $polldaddy->reset();
661
 
662
  $answers = array();
673
  return false;
674
 
675
  $poll_data = _polldaddy_poll_defaults();
676
+
677
+ foreach ( array( 'multipleChoice', 'randomiseAnswers', 'otherAnswer', 'sharing' ) as $option ) {
678
+ if ( isset( $_POST[$option] ) && $_POST[$option] )
679
+ $poll_data[$option] = 'yes';
680
+ else
681
+ $poll_data[$option] = 'no';
682
+ }
683
+
684
+ $blocks = array( 'off', 'cookie', 'cookieip' );
685
+ if ( isset( $_POST['blockRepeatVotersType'] ) && in_array( $_POST['blockRepeatVotersType'], $blocks ) )
686
+ $poll_data['blockRepeatVotersType'] = $_POST['blockRepeatVotersType'];
687
+
688
+ $results = array( 'show', 'percent', 'hide' );
689
+ if ( isset( $_POST['resultsType'] ) && in_array( $_POST['resultsType'], $results ) )
690
+ $poll_data['resultsType'] = $_POST['resultsType'];
691
 
692
  $poll_data['answers'] = $answers;
693
 
694
+ $poll_data['question'] = stripslashes( $_POST['question'] );
695
  $poll_data['question'] = wp_kses( $poll_data['question'], $allowedtags );
696
 
697
  if ( isset ( $_POST['styleID'] ) ){
698
  if ( $_POST['styleID'] == 'x' ){
699
+ $this->errors->add( 'UpdatePoll', __( 'Please choose a poll style', 'polldaddy' ) );
700
  return false;
701
  }
702
  }
715
  $this->parse_errors( $polldaddy );
716
 
717
  if ( !$poll || empty( $poll->_id ) )
718
+ $this->errors->add( 'CreatePoll', __( 'Poll could not be created', 'polldaddy' ) );
719
 
720
  if ( $this->errors->get_error_codes() )
721
  return false;
735
  else
736
  check_admin_referer( "delete-style_$style" );
737
 
738
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
739
 
740
  foreach ( (array) $_REQUEST['style'] as $style_id ) {
741
  $polldaddy->reset();
751
 
752
  check_admin_referer( "edit-style$style" );
753
 
754
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
755
  $polldaddy->reset();
756
 
757
  $style_data = _polldaddy_style_defaults();
767
  $this->parse_errors( $polldaddy );
768
 
769
  if ( !$update_response )
770
+ $this->errors->add( 'UpdateStyle', __( 'Style could not be updated', 'polldaddy' ) );
771
 
772
  if ( $this->errors->get_error_codes() )
773
  return false;
782
 
783
  check_admin_referer( 'create-style' );
784
 
785
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
786
  $polldaddy->reset();
787
 
788
  $style_data = _polldaddy_style_defaults();
797
  $this->parse_errors( $polldaddy );
798
 
799
  if ( !$style || empty( $style->_id ) )
800
+ $this->errors->add( 'CreateStyle', __( 'Style could not be created', 'polldaddy' ) );
801
 
802
  if ( $this->errors->get_error_codes() )
803
  return false;
808
  if ( isset($_POST['iframe']) )
809
  $query_args['iframe'] = '';
810
  break;
811
+ case 'update-options' :
812
+ if ( !$is_POST )
813
+ return;
814
+
815
+ check_admin_referer( 'polldaddy-account' );
816
+
817
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
818
+ $polldaddy->reset();
819
+
820
+ $poll_defaults = _polldaddy_poll_defaults();
821
+
822
+ $user_defaults = array();
823
+
824
+ foreach( array( "multipleChoice", "randomiseAnswers", "otherAnswer", "sharing", "resultsType", "styleID", "blockRepeatVotersType", "blockExpiration" ) as $option ){
825
+ if ( isset( $poll_defaults[$option] ) && $poll_defaults[$option] )
826
+ $user_defaults[$option] = $poll_defaults[$option];
827
+ }
828
+
829
+ foreach ( array( 'multipleChoice', 'randomiseAnswers', 'otherAnswer', 'sharing' ) as $option ) {
830
+ if ( isset( $_POST[$option] ) && $_POST[$option] )
831
+ $user_defaults[$option] = 'yes';
832
+ else
833
+ $user_defaults[$option] = 'no';
834
+ }
835
+
836
+ $results = array( 'show', 'percent', 'hide' );
837
+ if ( isset( $_POST['resultsType'] ) && in_array( $_POST['resultsType'], $results ) )
838
+ $user_defaults['resultsType'] = $_POST['resultsType'];
839
+
840
+ if ( isset ( $_POST['styleID'] ) ){
841
+ $user_defaults['styleID'] = (int) $_POST['styleID'];
842
+ }
843
+
844
+ $blocks = array( 'off', 'cookie', 'cookieip' );
845
+ if ( isset( $_POST['blockRepeatVotersType'] ) && in_array( $_POST['blockRepeatVotersType'], $blocks ) )
846
+ $user_defaults['blockRepeatVotersType'] = $_POST['blockRepeatVotersType'];
847
+
848
+ if( isset( $_POST['blockExpiration'] ) )
849
+ $user_defaults['blockExpiration'] = (int) $_POST['blockExpiration'];
850
+
851
+ $polldaddy->update_poll_defaults( 0, $user_defaults );
852
+
853
+ $this->parse_errors( $polldaddy );
854
+ if ( $this->errors->get_error_codes() )
855
+ return false;
856
+
857
+ $query_args['message'] = 'updated-options';
858
+ break;
859
  default :
860
  return;
861
  endswitch;
870
  function management_page_load_signup() {
871
  switch ( $_POST['account'] ) :
872
  case 'import' :
873
+ return $this->import_account();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
874
  break;
875
  default :
876
  return;
877
  endswitch;
878
  }
879
+
880
+ function import_account(){
881
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID );
882
+ $polldaddy->reset();
883
+ $email = trim( stripslashes( $_POST['polldaddy_email'] ) );
884
+ $password = trim( stripslashes( $_POST['polldaddy_password'] ) );
885
+
886
+ if ( !is_email( $email ) )
887
+ $this->errors->add( 'polldaddy_email', __( 'Email address required', 'polldaddy' ) );
888
+
889
+ if ( !$password )
890
+ $this->errors->add( 'polldaddy_password', __( 'Password required', 'polldaddy' ) );
891
+
892
+ if ( $this->errors->get_error_codes() )
893
+ return false;
894
+
895
+ if ( $usercode = $polldaddy->initiate( $email, $password, $this->id ) ) {
896
+ $this->user_code = $usercode;
897
+ } else {
898
+ $this->parse_errors( $polldaddy );
899
+ $this->errors->add( 'import-account', __( 'Account could not be imported. Are your email address and password correct?', 'polldaddy' ) );
900
+ return false;
901
+ }
902
+ }
903
 
904
  function admin_body_class( $class ) {
905
  if ( isset( $_GET['iframe'] ) )
909
  return $class;
910
  }
911
 
912
+ function management_page_notices( $message = false ) {
 
913
  switch ( (string) @$_GET['message'] ) :
914
  case 'deleted' :
915
  $deleted = (int) $_GET['deleted'];
916
  if ( 1 == $deleted )
917
+ $message = __( 'Poll deleted.', 'polldaddy' );
918
  else
919
  $message = sprintf( __ngettext( '%s Poll Deleted.', '%s Polls Deleted.', $deleted ), number_format_i18n( $deleted ) );
920
  break;
921
  case 'opened' :
922
  $opened = (int) $_GET['opened'];
923
  if ( 1 == $opened )
924
+ $message = __( 'Poll opened.', 'polldaddy' );
925
  else
926
  $message = sprintf( __ngettext( '%s Poll Opened.', '%s Polls Opened.', $opened ), number_format_i18n( $opened ) );
927
  break;
928
  case 'closed' :
929
  $closed = (int) $_GET['closed'];
930
  if ( 1 == $closed )
931
+ $message = __( 'Poll closed.', 'polldaddy' );
932
  else
933
  $message = sprintf( __ngettext( '%s Poll Closed.', '%s Polls Closed.', $closed ), number_format_i18n( $closed ) );
934
  break;
935
  case 'updated' :
936
+ $message = __( 'Poll updated.', 'polldaddy' );
937
  break;
938
  case 'created' :
939
+ $message = __( 'Poll created.', 'polldaddy' );
940
  if ( isset( $_GET['iframe'] ) )
941
+ $message .= ' <input type="button" class="button polldaddy-send-to-editor" value="' . attribute_escape( __( 'Send to Editor', 'polldaddy' ) ) . '" />';
942
  break;
943
  case 'updated-style' :
944
+ $message = __( 'Custom Style updated.', 'polldaddy' );
945
  break;
946
  case 'created-style' :
947
+ $message = __( 'Custom Style created.', 'polldaddy' );
948
  break;
949
  case 'deleted-style' :
950
  $deleted = (int) $_GET['deleted'];
951
  if ( 1 == $deleted )
952
+ $message = __( 'Custom Style deleted.', 'polldaddy' );
953
  else
954
  $message = sprintf( __ngettext( '%s Style Deleted.', '%s Custom Styles Deleted.', $deleted ), number_format_i18n( $deleted ) );
955
  break;
956
+ case 'imported-account' :
957
+ $message = __( 'Account Imported.', 'polldaddy' );
958
+ break;
959
+ case 'updated-options' :
960
+ $message = __( 'Options Updated.', 'polldaddy' );
961
+ break;
962
  endswitch;
963
 
964
  $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
966
  if ( $is_POST ) {
967
  switch ( $GLOBALS['action'] ) :
968
  case 'create-poll' :
969
+ $message = __( 'Error: An error has occurred; Poll not created.', 'polldaddy' );
970
  break;
971
  case 'edit-poll' :
972
+ $message = __( 'Error: An error has occurred; Poll not updated.', 'polldaddy' );
973
  break;
974
  case 'account' :
975
  if ( 'import' == $_POST['account'] )
976
+ $message = __( 'Error: An error has occurred; Account could not be imported. Perhaps your email address or password is incorrect?', 'polldaddy' );
977
  else
978
+ $message = __( 'Error: An error has occurred; Account could not be created.', 'polldaddy' );
979
  break;
980
  endswitch;
981
  }
989
  }
990
 
991
  function management_page() {
992
+ global $page, $action, $poll, $style, $rating;
993
  $poll = (int) $poll;
994
  $style = (int) $style;
995
+ $rating = wp_specialchars( $rating );
 
996
  ?>
997
 
998
  <div class="wrap" id="manage-polls">
999
 
1000
  <?php
1001
+ if( $page == 'polls' ) {
1002
+ if ( !$this->is_author && in_array( $action, array( 'edit', 'edit-poll', 'create-poll', 'edit-style', 'create-style', 'list-styles', 'options', 'update-options', 'import-account' ) ) ) {//check user privileges has access to action
1003
+ $action = '';
1004
+ }
1005
  switch ( $action ) :
1006
  case 'signup' :
1007
  case 'account' :
1010
  case 'preview' :
1011
  ?>
1012
 
1013
+ <h2 id="preview-header"><?php
1014
+ if( $this->is_author )
1015
+ printf( __( 'Poll Preview (<a href="%s">Edit Poll</a>, <a href="%s">List Polls</a>)', 'polldaddy' ),
1016
+ clean_url( add_query_arg( array( 'action' => 'edit', 'poll' => $poll, 'message' => false ) ) ),
1017
+ clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ));
1018
+ else
1019
+ printf( __( 'Poll Preview (<a href="%s">List Polls</a>)', 'polldaddy'), clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ) ); ?></h2>
1020
 
1021
  <?php
1022
  echo do_shortcode( "[polldaddy poll=$poll cb=1]" );
1024
  case 'results' :
1025
  ?>
1026
 
1027
+ <h2><?php
1028
+ if( $this->is_author )
1029
+ printf( __( 'Poll Results (<a href="%s">Edit Poll</a>)', 'polldaddy' ), clean_url( add_query_arg( array( 'action' => 'edit', 'poll' => $poll, 'message' => false ) ) ) );
1030
+ else
1031
+ printf( __( 'Poll Results (<a href="%s">List Polls</a>)', 'polldaddy'), clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ) ); ?></h2>
1032
 
1033
  <?php
1034
  $this->poll_results_page( $poll );
1037
  case 'edit-poll' :
1038
  ?>
1039
 
1040
+ <h2><?php printf( __('Edit Poll (<a href="%s">List Polls</a>)', 'polldaddy'), clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ) ); ?></h2>
1041
 
1042
  <?php
1043
 
1046
  case 'create-poll' :
1047
  ?>
1048
 
1049
+ <h2><?php printf( __('Create Poll (<a href="%s">List Polls</a>)', 'polldaddy'), clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ) ); ?></h2>
1050
 
1051
  <?php
1052
  $this->poll_edit_form();
1054
  case 'list-styles' :
1055
  ?>
1056
 
1057
+ <h2><?php
1058
+ if( $this->is_author )
1059
+ printf( __('Custom Styles (<a href="%s">Add New</a>)', 'polldaddy'), clean_url( add_query_arg( array( 'action' => 'create-style', 'poll' => false, 'message' => false ) ) ) );
1060
+ else
1061
+ _e('Custom Styles', 'polldaddy'); ?></h2>
1062
 
1063
  <?php
1064
  $this->styles_table();
1080
  <?php
1081
  $this->style_edit_form();
1082
  break;
1083
+ case 'options' :
1084
+ case 'import-account' :
1085
+ case 'update-options' :
1086
+ $this->plugin_options();
1087
+ break;
1088
  default :
1089
 
1090
  ?>
1091
 
1092
+ <h2 id="poll-list-header"><?php
1093
+ if( $this->is_author )
1094
+ printf( __( 'Polls (<a href="%s">Add New</a>)', 'polldaddy' ), clean_url( add_query_arg( array('action' => 'create-poll','poll' => false,'message' => false) ) ) );
1095
+ else
1096
+ _e( 'Polls', 'polldaddy'); ?></h2>
1097
 
1098
  <?php
1099
  $this->polls_table( isset( $_GET['view'] ) && 'user' == $_GET['view'] ? 'user' : 'blog' );
1100
  endswitch;
1101
  } elseif( $page == 'ratings' ) {
1102
+ if ( !$this->is_admin && !in_array( $action, array( 'change-report', 'reports' ) ) ) {//check user privileges has access to action
1103
+ $action = 'reports';
1104
+ }
1105
+
1106
  switch ( $action ) :
1107
  case 'change-report' :
1108
  case 'reports' :
1110
  break;
1111
  case 'update-rating' :
1112
  $this->update_rating();
1113
+ $this->rating_settings( $action );
1114
  break;
1115
  default :
1116
  $this->rating_settings();
1128
  $page = 1;
1129
  if ( isset( $_GET['paged'] ) )
1130
  $page = absint($_GET['paged']);
1131
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
1132
  $polldaddy->reset();
1133
+
1134
+ if( !$this->is_author )
1135
+ $view = '';
1136
+
1137
  if ( 'user' == $view )
1138
  $polls_object = $polldaddy->get_polls( ( $page - 1 ) * 10 + 1, $page * 10 );
1139
  else
1153
  'total' => ceil( $total_polls / 10 ),
1154
  'current' => $page
1155
  ) );
 
1156
 
1157
+ if( $this->is_author ){ ?>
1158
  <ul class="subsubsub">
1159
+ <li><a href="<?php echo clean_url( add_query_arg( array( 'view' => false, 'paged' => false ) ) ); ?>"<?php if ( 'blog' == $view ) echo ' class="current"'; ?>><?php _e( "All Blog's Polls", 'polldaddy' ); ?></a> | </li>
1160
+ <li><a href="<?php echo clean_url( add_query_arg( array( 'view' => 'user', 'paged' => false ) ) ); ?>"<?php if ( 'user' == $view ) echo ' class="current"'; ?>><?php _e( "All My Polls", 'polldaddy' ); ?></a></li>
1161
  </ul>
1162
+ <?php } ?>
1163
  <form method="post" action="">
1164
+ <?php if( $this->is_author ){ ?>
1165
  <div class="tablenav">
1166
  <div class="alignleft">
1167
  <select name="action">
1168
+ <option selected="selected" value=""><?php _e( 'Actions', 'polldaddy' ); ?></option>
1169
+ <option value="delete"><?php _e( 'Delete', 'polldaddy' ); ?></option>
1170
+ <option value="close"><?php _e( 'Close', 'polldaddy' ); ?></option>
1171
+ <option value="open"><?php _e( 'Open', 'polldaddy' ); ?></option>
1172
  </select>
1173
+ <input class="button-secondary action" type="submit" name="doaction" value="<?php _e( 'Apply', 'polldaddy' ); ?>" />
1174
  <?php wp_nonce_field( 'action-poll_bulk' ); ?>
1175
  </div>
1176
  <div class="tablenav-pages"><?php echo $page_links; ?></div>
1177
  </div>
1178
  <br class="clear" />
1179
+ <?php } ?>
1180
  <table class="widefat">
1181
  <thead>
1182
  <tr>
1183
+ <th id="cb" class="manage-column column-cb check-column" scope="col" /><?php if( $this->is_author ){ ?><input type="checkbox" /><?php } ?></th>
1184
  <th id="title" class="manage-column column-title" scope="col">Poll</th>
1185
  <th id="votes" class="manage-column column-vote" scope="col">Votes</th>
1186
  <th id="date" class="manage-column column-date" scope="col">Created</th>
1189
  <tbody>
1190
 
1191
  <?php
1192
+ if ( $polls ) :
1193
  foreach ( $polls as $poll ) :
1194
  $poll_id = (int) $poll->_id;
1195
 
1196
  $poll->___content = trim( strip_tags( $poll->___content ) );
1197
+ if( strlen( $poll->___content ) == 0 ){
1198
+ $poll->___content = '-- empty HTML tag --';
1199
+ }
1200
 
1201
  $poll_closed = (int) $poll->_closed;
1202
 
1203
+ if ( $this->is_author and $this->can_edit( $poll ) ) {
1204
+ $edit_link = clean_url( add_query_arg( array( 'action' => 'edit', 'poll' => $poll_id, 'message' => false ) ) );
1205
+ $delete_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete', 'poll' => $poll_id, 'message' => false ) ), "delete-poll_$poll_id" ) );
1206
+ $open_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'open', 'poll' => $poll_id, 'message' => false ) ), "open-poll_$poll_id" ) );
1207
+ $close_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'close', 'poll' => $poll_id, 'message' => false ) ), "close-poll_$poll_id" ) );
1208
+ }
1209
+ else {
1210
+ $edit_link = false;
1211
+ $delete_link = false;
1212
+ $open_link = false;
1213
+ $close_link = false;
1214
+ }
1215
 
1216
  $class = $class ? '' : ' class="alternate"';
1217
  $results_link = clean_url( add_query_arg( array( 'action' => 'results', 'poll' => $poll_id, 'message' => false ) ) );
 
 
 
1218
  $preview_link = clean_url( add_query_arg( array( 'action' => 'preview', 'poll' => $poll_id, 'message' => false ) ) ); //, 'iframe' => '', 'TB_iframe' => 'true' ) ) );
1219
  list($poll_time) = explode( '.', $poll->_created );
1220
  $poll_time = strtotime( $poll_time );
1221
  ?>
1222
 
1223
  <tr<?php echo $class; ?>>
1224
+ <th class="check-column" scope="row"><?php if( $this->is_author and $this->can_edit( $poll ) ){ ?><input type="checkbox" value="<?php echo (int) $poll_id; ?>" name="poll[]" /><?php } ?></th>
1225
  <td class="post-title column-title">
1226
+ <?php if ( $edit_link ) { ?>
1227
  <strong><a class="row-title" href="<?php echo $edit_link; ?>"><?php echo wp_specialchars( $poll->___content ); ?></a></strong>
1228
+ <span class="edit"><a href="<?php echo $edit_link; ?>"><?php _e( 'Edit', 'polldaddy' ); ?></a> | </span>
1229
+ <?php } else { ?>
1230
  <strong><?php echo wp_specialchars( $poll->___content ); ?></strong>
1231
+ <?php } ?>
1232
+ <span class="results"><a href="<?php echo $results_link; ?>"><?php _e( 'Results', 'polldaddy' ); ?></a> | </span>
1233
+ <?php if ( $delete_link ) { ?>
1234
+ <span class="delete"><a class="delete-poll delete" href="<?php echo $delete_link; ?>"><?php _e( 'Delete', 'polldaddy' ); ?></a> | </span>
1235
+ <?php }
1236
+ if ( $poll_closed == 2 ) {
1237
+ if ( $open_link ) { ?>
1238
+ <span class="open"><a class="open-poll" href="<?php echo $open_link; ?>"><?php _e( 'Open', 'polldaddy' ); ?></a> | </span>
1239
+ <?php } } else {
1240
+ if ( $close_link ) { ?>
1241
+ <span class="close"><a class="close-poll" href="<?php echo $close_link; ?>"><?php _e( 'Close', 'polldaddy' ); ?></a> | </span>
1242
+ <?php } } ?>
1243
+ <?php if ( isset( $_GET['iframe'] ) ) { ?>
1244
+ <span class="view"><a href="<?php echo $preview_link; ?>"><?php _e( 'Preview', 'polldaddy' ); ?></a> | </span>
1245
  <span class="editor">
1246
+ <a href="#" class="polldaddy-send-to-editor"><?php _e( 'Send to editor', 'polldaddy' ); ?></a>
1247
  <input type="hidden" class="polldaddy-poll-id hack" value="<?php echo (int) $poll_id; ?>" /> |
1248
  </span>
1249
+ <?php } else { ?>
1250
+ <span class="view"><a class="thickbox" href="<?php echo $preview_link; ?>"><?php _e( 'Preview', 'polldaddy' ); ?></a> | </span>
1251
+ <?php } ?>
1252
+ <span class="shortcode"><a href="#" class="polldaddy-show-shortcode"><?php _e( 'HTML code', 'polldaddy' ); ?></a></span>
1253
+ <?php $this->poll_table_add_option( $poll_id ); ?>
1254
+ </td>
1255
  <td class="poll-votes column-vote"><?php echo number_format_i18n( $poll->_responses ); ?></td>
1256
  <td class="date column-date"><abbr title="<?php echo date( __('Y/m/d g:i:s A'), $poll_time ); ?>"><?php echo date( __('Y/m/d'), $poll_time ); ?></abbr></td>
1257
  </tr>
1258
  <tr class="polldaddy-shortcode-row" style="display: none;">
1259
  <td colspan="4">
1260
+ <h4><?php _e( 'Shortcode', 'polldaddy' ); ?></h4>
1261
  <pre>[polldaddy poll=<?php echo (int) $poll_id; ?>]</pre>
1262
 
1263
+ <h4><?php _e( 'JavaScript', 'polldaddy' ); ?></h4>
1264
  <pre>&lt;script type="text/javascript" language="javascript"
1265
  src="http://static.polldaddy.com/p/<?php echo (int) $poll_id; ?>.js"&gt;&lt;/script&gt;
1266
  &lt;noscript&gt;
1276
  ?>
1277
 
1278
  <tr>
1279
+ <td colspan="4"><?php printf( __( 'What are you doing here? <a href="%s">Go back</a>.', 'polldaddy' ), clean_url( add_query_arg( 'paged', false ) ) ); ?></td>
1280
  </tr>
1281
 
1282
  <?php
1284
  ?>
1285
 
1286
  <tr>
1287
+ <td colspan="4"><?php
1288
+ if( $this->is_author )
1289
+ printf( __( 'No polls yet. <a href="%s">Create one</a>', 'polldaddy' ), clean_url( add_query_arg( array( 'action' => 'create-poll' ) ) ) );
1290
+ else
1291
+ _e( 'No polls yet.', 'polldaddy' ); ?></td>
1292
  </tr>
1293
  <?php endif; // $polls ?>
1294
 
1295
  </tbody>
1296
  </table>
1297
+ <?php $this->poll_table_extra(); ?>
1298
  </form>
1299
  <div class="tablenav">
1300
  <div class="tablenav-pages"><?php echo $page_links; ?></div>
1303
 
1304
  <?php
1305
  }
1306
+
1307
+ function poll_table_add_option(){}
1308
+
1309
+ function poll_table_extra(){}
1310
 
1311
+ function poll_edit_form( $poll_id = 1 ) {
1312
  $poll_id = (int) $poll_id;
1313
 
1314
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
1315
  $polldaddy->reset();
1316
 
1317
  $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
1321
  $this->parse_errors( $polldaddy );
1322
 
1323
  if ( !$this->can_edit( $poll ) ) {
1324
+ $this->errors->add( 'permission', __( 'You are not allowed to edit this poll.', 'polldaddy' ) );
1325
  }
1326
+
1327
+ if( $poll_id == 1 ){
1328
+ $poll->answers = array();
1329
+ $poll_id = 0;
1330
+ }
1331
+
1332
+ } else {
1333
+ $poll = polldaddy_poll( array(), null, false );
1334
  }
1335
 
1336
  $question = $is_POST ? attribute_escape( stripslashes( $_POST['question'] ) ) : attribute_escape( $poll->question );
1343
 
1344
  <div class="inner-sidebar" id="side-info-column">
1345
  <div id="submitdiv" class="postbox">
1346
+ <h3><?php _e( 'Publish', 'polldaddy' ); ?></h3>
1347
  <div class="inside">
1348
  <div id="major-publishing-actions">
1349
  <p id="publishing-action">
1350
  <?php wp_nonce_field( $poll_id ? "edit-poll_$poll_id" : 'create-poll' ); ?>
1351
  <input type="hidden" name="action" value="<?php echo $poll_id ? 'edit-poll' : 'create-poll'; ?>" />
1352
  <input type="hidden" class="polldaddy-poll-id" name="poll" value="<?php echo $poll_id; ?>" />
1353
+ <input type="submit" class="button-primary" value="<?php echo attribute_escape( __( 'Save Poll', 'polldaddy' ) ); ?>" />
1354
 
1355
  <?php if ( isset( $_GET['iframe'] ) && $poll_id ) : ?>
1356
 
1357
+ <input type="button" class="button polldaddy-send-to-editor" value="<?php echo attribute_escape( __( 'Send to Editor', 'polldaddy' ) ); ?>" />
1358
 
1359
  <?php endif; ?>
1360
 
1365
  </div>
1366
 
1367
  <div class="postbox">
1368
+ <h3><?php _e( 'Poll results', 'polldaddy' ); ?></h3>
1369
  <div class="inside">
1370
  <ul class="poll-options">
1371
 
1372
  <?php
1373
+ foreach ( array( 'show' => __( 'Show results to voters', 'polldaddy' ), 'percent' => __( 'Only show percentages', 'polldaddy' ), 'hide' => __( 'Hide all results', 'polldaddy' ) ) as $value => $label ) :
1374
  if ( $is_POST )
1375
  $checked = $value === $_POST['resultsType'] ? ' checked="checked"' : '';
1376
  else
1388
  </div>
1389
 
1390
  <div class="postbox">
1391
+ <h3><?php _e( 'Block repeat voters', 'polldaddy' ); ?></h3>
1392
  <div class="inside">
1393
  <ul class="poll-options">
1394
 
1395
  <?php
1396
+ foreach ( array( 'off' => __( "Don't block repeat voters", 'polldaddy' ), 'cookie' => __( 'Block by cookie (recommended)', 'polldaddy' ), 'cookieip' => __( 'Block by cookie and by IP address', 'polldaddy' ) ) as $value => $label ) :
1397
  if ( $is_POST )
1398
  $checked = $value === $_POST['blockRepeatVotersType'] ? ' checked="checked"' : '';
1399
  else
1408
 
1409
  </ul>
1410
 
1411
+ <span style="margin:6px 6px 8px;" id="cookieip_expiration_label"><label><?php _e( 'Expires: ', 'polldaddy' ); ?></label></span>
1412
  <select id="cookieip_expiration" name="cookieip_expiration" style="width: auto;<?php echo $poll->blockRepeatVotersType == 'off' ? 'display:none;' : ''; ?>">
1413
+ <option value="0" <?php echo (int) $poll->blockExpiration == 0 ? 'selected' : ''; ?>><?php _e( 'Never', 'polldaddy' ); ?></option>
1414
  <option value="3600" <?php echo (int) $poll->blockExpiration == 3600 ? 'selected' : ''; ?>><?php printf( __('%d hour'), 1 ); ?></option>
1415
  <option value="10800" <?php echo (int) $poll->blockExpiration == 10800 ? 'selected' : ''; ?>><?php printf( __('%d hours'), 3 ); ?></option>
1416
  <option value="21600" <?php echo (int) $poll->blockExpiration == 21600 ? 'selected' : ''; ?>><?php printf( __('%d hours'), 6 ); ?></option>
1434
  </div>
1435
 
1436
  <div id="answersdiv" class="postbox">
1437
+ <h3><?php _e( 'Answers', 'polldaddy' ); ?></h3>
1438
 
1439
  <div id="answerswrap" class="inside">
1440
  <ul id="answers">
1480
  </ul>
1481
 
1482
  <p id="add-answer-holder">
1483
+ <button class="button"><?php echo wp_specialchars( __( 'Add another', 'polldaddy' ) ); ?></button>
1484
  </p>
1485
 
1486
  <ul id="answer-options">
1487
 
1488
  <?php
1489
+ foreach ( array( 'multipleChoice' => __( 'Multiple choice', 'polldaddy' ), 'randomiseAnswers' => __( 'Randomize answer order', 'polldaddy' ), 'otherAnswer' => __( 'Allow other answers', 'polldaddy' ), 'sharing' => __( "'Share This' link", 'polldaddy' ) ) as $option => $label ) :
1490
  if ( $is_POST )
1491
  $checked = 'yes' === $_POST[$option] ? ' checked="checked"' : '';
1492
  else
1598
  $styles = $polldaddy->get_styles();
1599
 
1600
  $show_custom = false;
1601
+ if( !empty( $styles ) && !empty( $styles->style ) && count( $styles->style ) > 0 ){
1602
  foreach( (array) $styles->style as $style ){
1603
  $options[ (int) $style->_id ] = $style->title;
1604
  }
1615
  }
1616
  ?>
1617
 
1618
+ <h3><?php _e( 'Design', 'polldaddy' ); ?></h3>
1619
  <input type="hidden" name="styleID" id="styleID" value="<?php echo $style_ID ?>">
1620
  <div class="inside">
1621
  <?php if ( $iframe_view ){ ?>
1696
  <div style="display:none;">
1697
  <?php $disabled = $show_custom == false ? ' disabled="true"' : ''; ?>
1698
  <input type="radio" name="styleTypeCB" id="custom" onclick="javascript:pd_change_style($('customSelect').value);" <?php echo $disabled; ?>></input>
1699
+ <label onclick="javascript:pd_change_style($('customSelect').value);"><?php _e( 'Custom Style', 'polldaddy' ); ?></label>
1700
  </div>
1701
  </th>
1702
  </tr>
1709
  <td><?php $hide = $show_custom == true ? ' style="display:block;"' : ' style="display:none;"'; ?>
1710
  <select id="customSelect" name="customSelect" onclick="pd_change_style(this.value);" <?php echo $hide ?>>
1711
  <?php $selected = $custom_style_ID == 0 ? ' selected="selected"' : ''; ?>
1712
+ <option value="x"<?php echo $selected; ?>><?php _e( 'Please choose a custom style...', 'polldaddy' ); ?></option>
1713
+ <?php if( $show_custom) : foreach ( (array)$styles->style as $style ) :
1714
  $selected = $style->_id == $custom_style_ID ? ' selected="selected"' : ''; ?>
1715
  <option value="<?php echo (int) $style->_id; ?>"<?php echo $selected; ?>><?php echo wp_specialchars( $style->title ); ?></option>
1716
+ <?php endforeach; endif; ?>
1717
  </select>
1718
+ <div id="styleIDErr" class="formErr" style="display:none;"><?php _e( 'Please choose a style.', 'polldaddy' ); ?></div></td>
1719
  </tr>
1720
  <tr>
1721
  <td><?php $extra = $show_custom == false ? 'You currently have no custom styles created.' : ''; ?>
1722
  <p><?php echo $extra ?></p>
1723
+ <p><?php printf( __( 'Did you know we have a new editor for building your own custom poll styles? Find out more <a href="%s" target="_blank">here</a>.', 'polldaddy' ), 'http://support.polldaddy.com/custom-poll-styles/' ); ?></p>
1724
  </td>
1725
  </tr>
1726
  </table>
1731
  </p>
1732
  </div>
1733
  <div id="design_options">
1734
+ <a href="#" class="polldaddy-show-design-options"><?php _e( 'Custom Styles', 'polldaddy' ); ?></a>
1735
  </div>
1736
  <?php }}else{?>
1737
  <div class="design_standard">
1743
  <input type="radio" name="styleTypeCB" id="regular" onclick="javascript:pd_build_styles( 0 );"/>
1744
  </th>
1745
  <th>
1746
+ <label for="skin" onclick="javascript:pd_build_styles( 0 );"><?php _e( 'PollDaddy Style', 'polldaddy' ); ?></label>
1747
  </th>
1748
  <th/>
1749
  <th class="cb">
1751
  <input type="radio" name="styleTypeCB" id="custom" onclick="javascript:pd_change_style($('customSelect').value);" <?php echo $disabled; ?>></input>
1752
  </th>
1753
  <th>
1754
+ <label onclick="javascript:pd_change_style($('customSelect').value);"><?php _e( 'Custom Style', 'polldaddy' ); ?></label>
1755
  </th>
1756
  </tr>
1757
  </thead>
1816
  <tr>
1817
  <td><?php $extra = $show_custom == false ? 'You currently have no custom styles created.' : ''; ?>
1818
  <p><?php echo $extra ?></p>
1819
+ <p><?php printf( __( 'Did you know we have a new editor for building your own custom poll styles? Find out more <a href="%s" target="_blank">here</a>.', 'polldaddy' ), 'http://support.polldaddy.com/custom-poll-styles/' ); ?></p>
1820
  </td>
1821
  </tr>
1822
  </table>
1859
  }
1860
 
1861
  function poll_results_page( $poll_id ) {
1862
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
1863
  $polldaddy->reset();
1864
 
1865
  $results = $polldaddy->get_poll_results( $poll_id );
1868
  <table class="poll-results widefat">
1869
  <thead>
1870
  <tr>
1871
+ <th scope="col" class="column-title"><?php _e( 'Answer', 'polldaddy' ); ?></th>
1872
+ <th scope="col" class="column-vote"><?php _e( 'Votes', 'polldaddy' ); ?></th>
1873
  </tr>
1874
  </thead>
1875
  <tbody>
1883
  }
1884
 
1885
  $class = $class ? '' : ' class="alternate"';
1886
+ $content = $results->others && 'Other answer...' === $answer->text ? sprintf( __( 'Other (<a href="%s">see below</a>)', 'polldaddy' ), '#other-answers-results' ) : wp_specialchars( $answer->text );
1887
 
1888
  ?>
1889
 
1913
  <table id="other-answers-results" class="poll-others widefat">
1914
  <thead>
1915
  <tr>
1916
+ <th scope="col" class="column-title"><?php _e( 'Other Answer', 'polldaddy' ); ?></th>
1917
+ <th scope="col" class="column-vote"><?php _e( 'Votes', 'polldaddy' ); ?></th>
1918
  </tr>
1919
  </thead>
1920
  <tbody>
1942
  }
1943
 
1944
  function styles_table() {
1945
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
1946
  $polldaddy->reset();
1947
 
1948
  $styles_object = $polldaddy->get_styles();
1965
  <div class="tablenav">
1966
  <div class="alignleft">
1967
  <select name="action">
1968
+ <option selected="selected" value=""><?php _e( 'Actions', 'polldaddy' ); ?></option>
1969
+ <option value="delete-style"><?php _e( 'Delete', 'polldaddy' ); ?></option>
1970
  </select>
1971
+ <input class="button-secondary action" type="submit" name="doaction" value="<?php _e( 'Apply', 'polldaddy' ); ?>" />
1972
  <?php wp_nonce_field( 'action-style_bulk' ); ?>
1973
  </div>
1974
  <div class="tablenav-pages"></div>
1978
  <thead>
1979
  <tr>
1980
  <th id="cb" class="manage-column column-cb check-column" scope="col" /><input type="checkbox" /></th>
1981
+ <th id="title" class="manage-column column-title" scope="col"><?php _e( 'Style', 'polldaddy' ); ?></th>
1982
+ <th id="date" class="manage-column column-date" scope="col"><?php _e( 'Last Modified', 'polldaddy' ); ?></th>
1983
  </tr>
1984
  </thead>
1985
  <tbody>
2002
  <td class="post-title column-title">
2003
  <?php if ( $edit_link ) : ?>
2004
  <strong><a class="row-title" href="<?php echo $edit_link; ?>"><?php echo wp_specialchars( $style->title ); ?></a></strong>
2005
+ <span class="edit"><a href="<?php echo $edit_link; ?>"><?php _e( 'Edit', 'polldaddy' ); ?></a> | </span>
2006
  <?php else : ?>
2007
  <strong><?php echo wp_specialchars( $style->title ); ?></strong>
2008
  <?php endif; ?>
2009
 
2010
+ <span class="delete"><a class="delete-poll delete" href="<?php echo $delete_link; ?>"><?php _e( 'Delete', 'polldaddy' ); ?></a></span>
2011
  </td>
2012
  <td class="date column-date"><abbr title="<?php echo date( __('Y/m/d g:i:s A'), $style_time ); ?>"><?php echo date( __('Y/m/d'), $style_time ); ?></abbr></td>
2013
  </tr>
2019
  ?>
2020
 
2021
  <tr>
2022
+ <td colspan="4"><?php printf( __( 'No custom styles yet. <a href="%s">Create one</a>', 'polldaddy' ), clean_url( add_query_arg( array( 'action' => 'create-style' ) ) ) ); ?></td>
2023
  </tr>
2024
  <?php endif; // $styles ?>
2025
 
2037
  function style_edit_form( $style_id = 105 ) {
2038
  $style_id = (int) $style_id;
2039
 
2040
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
2041
  $polldaddy->reset();
2042
 
2043
  $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
2095
  <table width="100%">
2096
  <tr>
2097
  <td valign="middle" width="8%">
2098
+ <label class="CSSE_title_label"><?php _e( 'Style Name', 'polldaddy' ); ?></label>
2099
  </td>
2100
  <td>
2101
  <div id="titlediv" style="margin:0px;">
2110
  </tr>
2111
  <tr>
2112
  <td width="13%">
2113
+ <label class="CSSE_title_label"><?php _e( 'Preload Basic Style', 'polldaddy' ); ?></label>
2114
  </td>
2115
  <td>
2116
  <div class="CSSE_preload">
2124
  <option value="117">Skull Light</option>
2125
  <option value="157">Micro</option>
2126
  </select>
2127
+ <a tabindex="4" id="style-preload" href="javascript:preload_pd_style();" class="button"><?php echo attribute_escape( __( 'Load Style', 'polldaddy' ) ); ?></a>
2128
  </div>
2129
  </td>
2130
  </tr>
2915
  <?php wp_nonce_field( $style_id > 1000 ? "edit-style$style_id" : 'create-style' ); ?>
2916
  <input type="hidden" name="action" value="<?php echo $style_id > 1000 ? 'edit-style' : 'create-style'; ?>" />
2917
  <input type="hidden" class="polldaddy-style-id" name="style" value="<?php echo $style_id; ?>" />
2918
+ <input type="submit" class="button-primary" value="<?php echo attribute_escape( __( 'Save Style', 'polldaddy' ) ); ?>" />
2919
 
2920
  </div>
2921
  </div>
2944
  <?php
2945
  }
2946
 
2947
+ function rating_settings(){
2948
+ global $action, $rating;
2949
+ $show_pages = $show_comments = $pos_posts = $pos_pages = $pos_comments = 0;
2950
+ $show_settings = $rating_updated = ( $action == 'update-rating' ? true : false );
 
 
 
 
2951
  $error = false;
2952
 
2953
  $settings_style = 'display: none;';
3030
  endswitch;
3031
  }
3032
 
3033
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
3034
  $polldaddy->reset();
3035
  $response = $polldaddy->get_rating( $rating_id );
3036
 
3083
  $rating_type = 0;
3084
  else
3085
  $rating_type = 1;
3086
+
3087
+ if( empty( $settings->font_color ) )
3088
+ $settings->font_color = '#000000';
3089
  }
3090
 
3091
  ?>
3264
  <td><input onblur="pd_bind(this);" type="text" name="text_rate_this" id="text_rate_this" value="<?php echo( wp_specialchars( $settings->text_rate_this ) ); ?>" maxlength="20" />
3265
  </tr>
3266
  <tr>
3267
+ <td height="30"><?php printf(__( '%d star', 'polldaddy' ), 1);?></td>
3268
  <td><input onblur="pd_bind(this);" type="text" name="text_1_star" id="text_1_star" value="<?php echo( wp_specialchars( $settings->text_1_star ) ); ?>" maxlength="20" />
3269
  </tr>
3270
  <tr>
3271
+ <td height="30"><?php printf(__( '%d stars', 'polldaddy' ), 2);?></td>
3272
  <td><input onblur="pd_bind(this);" type="text" name="text_2_star" id="text_2_star" value="<?php echo( wp_specialchars( $settings->text_2_star ) ); ?>" maxlength="20" />
3273
  </tr>
3274
  <tr>
3275
+ <td height="30"><?php printf(__( '%d stars', 'polldaddy' ), 3);?></td>
3276
  <td><input onblur="pd_bind(this);" type="text" name="text_3_star" id="text_3_star" value="<?php echo( wp_specialchars( $settings->text_3_star ) ); ?>" maxlength="20" />
3277
  </tr>
3278
  <tr>
3279
+ <td height="30"><?php printf(__( '%d stars', 'polldaddy' ), 4);?></td>
3280
  <td><input onblur="pd_bind(this);" type="text" name="text_4_star" id="text_4_star" value="<?php echo( wp_specialchars( $settings->text_4_star ) ); ?>" maxlength="20" />
3281
  </tr>
3282
  <tr>
3283
+ <td height="30"><?php printf(__( '%d stars', 'polldaddy' ), 5);?></td>
3284
  <td><input onblur="pd_bind(this);" type="text" name="text_5_star" id="text_5_star" value="<?php echo( wp_specialchars( $settings->text_5_star ) ); ?>" maxlength="20" />
3285
  </tr>
3286
  <tr>
3315
  $checked = ' checked="checked"';
3316
  ?>
3317
  <input type="radio" onchange="pd_change_type( 0 );" <?php echo ( $checked ); ?> value="stars" id="stars" name="rating_type" />
3318
+ <?php printf(__( '%d Star Rating', 'polldaddy' ), 5);?>
3319
  </label>
3320
  </li>
3321
  <li style="display: inline;">
3574
 
3575
  $settings_text = json_encode( $set );
3576
 
3577
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
3578
  $polldaddy->reset();
3579
  $response = $polldaddy->update_rating( $rating_id, $settings_text, $rating_type );
3580
  }
3581
  function rating_reports() {
3582
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
3583
  $rating_id = get_option( 'pd-rating-posts-id' );
3584
 
3585
  $report_type = 'posts';
3808
  <p></p>
3809
  <?php
3810
  }
3811
+
3812
+ function plugin_options() {
3813
+ if ( isset( $_POST['polldaddy_email'] ) ){
3814
+ $account_email = attribute_escape( $_POST['polldaddy_email'] );
3815
+ }
3816
+ else{
3817
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
3818
+ $account = $polldaddy->get_account();
3819
+
3820
+ if( !empty($account) )
3821
+ $account_email = attribute_escape( $account->email );
3822
+
3823
+ $polldaddy->reset();
3824
+ $poll = $polldaddy->get_poll( 1 );
3825
+
3826
+ $options = array(
3827
+ 101 => 'Aluminum Narrow',
3828
+ 102 => 'Aluminum Medium',
3829
+ 103 => 'Aluminum Wide',
3830
+ 104 => 'Plain White Narrow',
3831
+ 105 => 'Plain White Medium',
3832
+ 106 => 'Plain White Wide',
3833
+ 107 => 'Plain Black Narrow',
3834
+ 108 => 'Plain Black Medium',
3835
+ 109 => 'Plain Black Wide',
3836
+ 110 => 'Paper Narrow',
3837
+ 111 => 'Paper Medium',
3838
+ 112 => 'Paper Wide',
3839
+ 113 => 'Skull Dark Narrow',
3840
+ 114 => 'Skull Dark Medium',
3841
+ 115 => 'Skull Dark Wide',
3842
+ 116 => 'Skull Light Narrow',
3843
+ 117 => 'Skull Light Medium',
3844
+ 118 => 'Skull Light Wide',
3845
+ 157 => 'Micro',
3846
+ 119 => 'Plastic White Narrow',
3847
+ 120 => 'Plastic White Medium',
3848
+ 121 => 'Plastic White Wide',
3849
+ 122 => 'Plastic Grey Narrow',
3850
+ 123 => 'Plastic Grey Medium',
3851
+ 124 => 'Plastic Grey Wide',
3852
+ 125 => 'Plastic Black Narrow',
3853
+ 126 => 'Plastic Black Medium',
3854
+ 127 => 'Plastic Black Wide',
3855
+ 128 => 'Manga Narrow',
3856
+ 129 => 'Manga Medium',
3857
+ 130 => 'Manga Wide',
3858
+ 131 => 'Tech Dark Narrow',
3859
+ 132 => 'Tech Dark Medium',
3860
+ 133 => 'Tech Dark Wide',
3861
+ 134 => 'Tech Grey Narrow',
3862
+ 135 => 'Tech Grey Medium',
3863
+ 136 => 'Tech Grey Wide',
3864
+ 137 => 'Tech Light Narrow',
3865
+ 138 => 'Tech Light Medium',
3866
+ 139 => 'Tech Light Wide',
3867
+ 140 => 'Working Male Narrow',
3868
+ 141 => 'Working Male Medium',
3869
+ 142 => 'Working Male Wide',
3870
+ 143 => 'Working Female Narrow',
3871
+ 144 => 'Working Female Medium',
3872
+ 145 => 'Working Female Wide',
3873
+ 146 => 'Thinking Male Narrow',
3874
+ 147 => 'Thinking Male Medium',
3875
+ 148 => 'Thinking Male Wide',
3876
+ 149 => 'Thinking Female Narrow',
3877
+ 150 => 'Thinking Female Medium',
3878
+ 151 => 'Thinking Female Wide',
3879
+ 152 => 'Sunset Narrow',
3880
+ 153 => 'Sunset Medium',
3881
+ 154 => 'Sunset Wide',
3882
+ 155 => 'Music Medium',
3883
+ 156 => 'Music Wide'
3884
+ );
3885
+
3886
+ $polldaddy->reset();
3887
+ $styles = $polldaddy->get_styles();
3888
+
3889
+ if( !empty( $styles ) && !empty( $styles->style ) && count( $styles->style ) > 0 ){
3890
+ foreach( (array) $styles->style as $style ){
3891
+ $options[ (int) $style->_id ] = $style->title;
3892
+ }
3893
+ }
3894
+ }
3895
+ $this->print_errors();
3896
+ ?>
3897
+ <div id="options-page" class="wrap">
3898
+ <div class="icon32" id="icon-options-general"><br/></div>
3899
+ <h2>
3900
+ <?php _e( 'Options', 'polldaddy' ); ?>
3901
+ </h2>
3902
+ <h3>
3903
+ <?php _e( 'PollDaddy Account Info', 'polldaddy' ); ?>
3904
+ </h3>
3905
+ <p>
3906
+ <?php _e( 'This is the PollDadddy account you currently have imported into your WordPress account', 'polldaddy' ); ?>.
3907
+ </p>
3908
+ <form action="" method="post">
3909
+ <table class="form-table">
3910
+ <tbody>
3911
+ <tr class="form-field form-required">
3912
+ <th valign="top" scope="row">
3913
+ <label for="polldaddy-email">
3914
+ <?php _e( 'PollDaddy Email Address', 'polldaddy' ); ?>
3915
+ </label>
3916
+ </th>
3917
+ <td>
3918
+ <input type="text" name="polldaddy_email" id="polldaddy-email" aria-required="true" size="40" value="<?php echo $account_email; ?>" />
3919
+ </td>
3920
+ </tr>
3921
+ <tr class="form-field form-required">
3922
+ <th valign="top" scope="row">
3923
+ <label for="polldaddy-password">
3924
+ <?php _e( 'PollDaddy Password', 'polldaddy' ); ?>
3925
+ </label>
3926
+ </th>
3927
+ <td>
3928
+ <input type="password" name="polldaddy_password" id="polldaddy-password" aria-required="true" size="40" />
3929
+ </td>
3930
+ </tr>
3931
+ </tbody>
3932
+ </table>
3933
+ <p class="submit">
3934
+ <?php wp_nonce_field( 'polldaddy-account' ); ?>
3935
+ <input type="hidden" name="action" value="import-account" />
3936
+ <input type="hidden" name="account" value="import" />
3937
+ <input type="submit" value="<?php echo attribute_escape( __( 'Import Account', 'polldaddy' ) ); ?>" />
3938
+ </p>
3939
+ </form>
3940
+ <br />
3941
+ <h3>
3942
+ <?php _e( 'General Settings', 'polldaddy' ); ?>
3943
+ </h3>
3944
+ <form action="" method="post">
3945
+ <table class="form-table">
3946
+ <tbody>
3947
+ <tr valign="top">
3948
+ <th valign="top" scope="row">
3949
+ <label>
3950
+ <?php _e( 'Default poll settings', 'polldaddy' ); ?>
3951
+ </label>
3952
+ </th>
3953
+ <td>
3954
+ <fieldset>
3955
+ <legend class="screen-reader-text"><span>poll-defaults</span></legend><?php
3956
+ $selected = '';
3957
+ if ( $poll->multipleChoice == 'yes' )
3958
+ $selected = 'checked="checked"';?>
3959
+ <label for="multipleChoice"><input type="checkbox" <?php echo $selected; ?> value="1" id="multipleChoice" name="multipleChoice"> <?php _e( 'Multiple Choice', 'polldaddy' ); ?></label>
3960
+ <br /><?php
3961
+ $selected = '';
3962
+ if ( $poll->randomiseAnswers == 'yes' )
3963
+ $selected = 'checked="checked"';?>
3964
+ <label for="randomiseAnswers"><input type="checkbox" <?php echo $selected; ?> value="1" id="randomiseAnswers" name="randomiseAnswers"> <?php _e( 'Randomise Answers', 'polldaddy' ); ?></label>
3965
+ <br /><?php
3966
+ $selected = '';
3967
+ if ( $poll->otherAnswer == 'yes' )
3968
+ $selected = 'checked="checked"';?>
3969
+ <label for="otherAnswer"><input type="checkbox" <?php echo $selected; ?> value="1" id="otherAnswer" name="otherAnswer"> <?php _e( 'Other Answer', 'polldaddy' ); ?></label>
3970
+ <br /><?php
3971
+ $selected = '';
3972
+ if ( $poll->sharing == 'yes' )
3973
+ $selected = 'checked="checked"';?>
3974
+ <label for="sharing"><input type="checkbox" <?php echo $selected; ?> value="1" id="sharing" name="sharing"> <?php _e( 'Sharing', 'polldaddy' ); ?></label>
3975
+ <br />
3976
+ <label for="resultsType">
3977
+ <select id="resultsType" name="resultsType">
3978
+ <option <?php echo $poll->resultsType == 'show' ? 'selected="selected"':''; ?> value="show"><?php _e('Show', 'polldaddy'); ?></option>
3979
+ <option <?php echo $poll->resultsType == 'hide' ? 'selected="selected"':''; ?> value="hide"><?php _e('Hide', 'polldaddy'); ?></option>
3980
+ <option <?php echo $poll->resultsType == 'percent' ? 'selected="selected"':''; ?> value="percent"><?php _e('Percentages', 'polldaddy'); ?></option>
3981
+ </select> <?php _e( 'Poll results', 'polldaddy' ); ?>
3982
+ </label>
3983
+ <br />
3984
+ <label for="styleID">
3985
+ <select id="styleID" name="styleID"><?php
3986
+ foreach ( (array) $options as $styleID => $label ) :
3987
+ $selected = $styleID == $poll->styleID ? ' selected="selected"' : ''; ?>
3988
+ <option value="<?php echo (int) $styleID; ?>"<?php echo $selected; ?>><?php echo wp_specialchars( $label ); ?></option><?php
3989
+ endforeach;?>
3990
+ </select> <?php _e( 'Poll style', 'polldaddy' ); ?>
3991
+ </label>
3992
+ <br />
3993
+ <label for="blockRepeatVotersType">
3994
+ <select id="poll-block-repeat" name="blockRepeatVotersType">
3995
+ <option <?php echo $poll->blockRepeatVotersType == 'off' ? 'selected="selected"':''; ?> value="off"><?php _e('Off', 'polldaddy'); ?></option>
3996
+ <option <?php echo $poll->blockRepeatVotersType == 'cookie' ? 'selected="selected"':''; ?> value="cookie"><?php _e('Cookie', 'polldaddy'); ?></option>
3997
+ <option <?php echo $poll->blockRepeatVotersType == 'cookieip' ? 'selected="selected"':''; ?> value="cookieip"><?php _e('Cookie & IP address', 'polldaddy'); ?></option>
3998
+ </select> <?php _e( 'Block repeat voters', 'polldaddy' ); ?>
3999
+ </label>
4000
+ <br />
4001
+ <label for="blockExpiration">
4002
+ <select id="blockExpiration" name="blockExpiration">
4003
+ <option value="0" <?php echo $poll->blockExpiration == 0 ? 'selected="selected"':''; ?>><?php _e('Never', 'polldaddy'); ?></option>
4004
+ <option value="3600" <?php echo $poll->blockExpiration == 3600 ? 'selected="selected"':''; ?>><?php printf( __('%d hour', 'polldaddy'), 1 ); ?></option>
4005
+ <option value="10800" <?php echo (int) $poll->blockExpiration == 10800 ? 'selected="selected"' : ''; ?>><?php printf( __('%d hours', 'polldaddy'), 3 ); ?></option>
4006
+ <option value="21600" <?php echo (int) $poll->blockExpiration == 21600 ? 'selected="selected"' : ''; ?>><?php printf( __('%d hours', 'polldaddy'), 6 ); ?></option>
4007
+ <option value="43200" <?php echo (int) $poll->blockExpiration == 43200 ? 'selected="selected"' : ''; ?>><?php printf( __('%d hours', 'polldaddy'), 12 ); ?></option>
4008
+ <option value="86400" <?php echo (int) $poll->blockExpiration == 86400 ? 'selected="selected"' : ''; ?>><?php printf( __('%d day', 'polldaddy'), 1 ); ?></option>
4009
+ <option value="604800" <?php echo (int) $poll->blockExpiration == 604800 ? 'selected="selected"' : ''; ?>><?php printf( __('%d week', 'polldaddy'), 1 ); ?></option>
4010
+ <option value="2419200" <?php echo (int) $poll->blockExpiration == 2419200 ? 'selected="selected"' : ''; ?>><?php printf( __('%d month', 'polldaddy'), 1 ); ?></option>
4011
+ </select> <?php _e( 'Block expiration limit', 'polldaddy' ); ?>
4012
+ </label>
4013
+ <br />
4014
+ </fieldset>
4015
+ </td>
4016
+ </tr>
4017
+ <?php $this->plugin_options_add(); ?>
4018
+ </tbody>
4019
+ </table>
4020
+ <p class="submit">
4021
+ <?php wp_nonce_field( 'polldaddy-account' ); ?>
4022
+ <input type="hidden" name="action" value="update-options" />
4023
+ <input type="submit" value="<?php echo attribute_escape( __( 'Save Options', 'polldaddy' ) ); ?>" />
4024
+ </p>
4025
+ </form>
4026
+ </div>
4027
+ <?php
4028
+ }
4029
+
4030
+ function plugin_options_add(){}
4031
 
4032
  function round($number, $increments) {
4033
  $increments = 1 / $increments;
4038
  return $this->api_key_page();
4039
  }
4040
 
4041
+ function can_edit( &$poll ) {
4042
+ if ( empty( $poll->_owner ) )
 
4043
  return true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4044
 
4045
+ if ( $this->id == $poll->_owner )
4046
+ return true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4047
 
4048
+ return (bool) current_user_can( 'edit_others_posts' );
 
 
 
 
 
4049
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4050
  }
4051
 
4052
+ require 'rating.php';
4053
+ require 'polldaddy-org.php';
polldaddy.pot ADDED
@@ -0,0 +1,965 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Translation of the WordPress plugin PollDaddy Polls 1.7.8 by Automattic, Inc..
2
+ # Copyright (C) 2010 Automattic, Inc.
3
+ # This file is distributed under the same license as the PollDaddy Polls package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, 2010.
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: PollDaddy Polls 1.7.8\n"
10
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/polldaddy\n"
11
+ "POT-Creation-Date: 2010-01-26 15:25+0000\n"
12
+ "PO-Revision-Date: 2010-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "MIME-Version: 1.0\n"
16
+ "Content-Type: text/plain; charset=utf-8\n"
17
+ "Content-Transfer-Encoding: 8bit\n"
18
+ "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
19
+
20
+ #: polldaddy.php:66 polldaddy.php:68 polldaddy.php:84 polldaddy.php:86
21
+ msgid "Ratings"
22
+ msgstr ""
23
+
24
+ #: polldaddy.php:73 polldaddy.php:75 polldaddy.php:91 polldaddy.php:93
25
+ #: polldaddy.php:105 polldaddy.php:1096
26
+ msgid "Polls"
27
+ msgstr ""
28
+
29
+ #: polldaddy.php:98
30
+ msgid "Ratings &ndash; Settings"
31
+ msgstr ""
32
+
33
+ #: polldaddy.php:98
34
+ msgid "Settings"
35
+ msgstr ""
36
+
37
+ #: polldaddy.php:99 polldaddy.php:102
38
+ msgid "Ratings &ndash; Reports"
39
+ msgstr ""
40
+
41
+ #: polldaddy.php:99 polldaddy.php:102
42
+ msgid "Reports"
43
+ msgstr ""
44
+
45
+ #: polldaddy.php:105 polldaddy.php:1228 polldaddy.php:2005
46
+ msgid "Edit"
47
+ msgstr ""
48
+
49
+ #: polldaddy.php:108
50
+ msgid "Add New Poll"
51
+ msgstr ""
52
+
53
+ #: polldaddy.php:108
54
+ msgid "Add New"
55
+ msgstr ""
56
+
57
+ #: polldaddy.php:109 polldaddy.php:1061 polldaddy.php:1734
58
+ msgid "Custom Styles"
59
+ msgstr ""
60
+
61
+ #: polldaddy.php:110 polldaddy.php:3900
62
+ msgid "Options"
63
+ msgstr ""
64
+
65
+ #: polldaddy.php:126 polldaddy.php:887
66
+ msgid "Email address required"
67
+ msgstr ""
68
+
69
+ #: polldaddy.php:129 polldaddy.php:890
70
+ msgid "Password required"
71
+ msgstr ""
72
+
73
+ #: polldaddy.php:159
74
+ msgid "Can't connect to PollDaddy.com"
75
+ msgstr ""
76
+
77
+ #: polldaddy.php:186
78
+ msgid "Invalid Account"
79
+ msgstr ""
80
+
81
+ #: polldaddy.php:196
82
+ msgid ""
83
+ "Account could not be accessed. Are your email address and password correct?"
84
+ msgstr ""
85
+
86
+ #: polldaddy.php:208
87
+ #, php-format
88
+ msgid ""
89
+ "Obsolete PollDaddy User API Key: <a href=\"%s\">Sign in again to re-"
90
+ "authenticate</a>"
91
+ msgstr ""
92
+
93
+ #: polldaddy.php:247
94
+ msgid "PollDaddy Account"
95
+ msgstr ""
96
+
97
+ #: polldaddy.php:249
98
+ #, php-format
99
+ msgid ""
100
+ "Before you can use the PollDaddy plugin, you need to enter your <a href=\"%s"
101
+ "\">PollDaddy.com</a> account details."
102
+ msgstr ""
103
+
104
+ #: polldaddy.php:256 polldaddy.php:3914
105
+ msgid "PollDaddy Email Address"
106
+ msgstr ""
107
+
108
+ #: polldaddy.php:264 polldaddy.php:3924
109
+ msgid "PollDaddy Password"
110
+ msgstr ""
111
+
112
+ #: polldaddy.php:276
113
+ msgid "Submit"
114
+ msgstr ""
115
+
116
+ #: polldaddy.php:285
117
+ msgid "Add Poll"
118
+ msgstr ""
119
+
120
+ #: polldaddy.php:355
121
+ msgid "Star Colors"
122
+ msgstr ""
123
+
124
+ #: polldaddy.php:355 polldaddy.php:3340
125
+ msgid "Star Size"
126
+ msgstr ""
127
+
128
+ #: polldaddy.php:356
129
+ msgid "Nero Type"
130
+ msgstr ""
131
+
132
+ #: polldaddy.php:356
133
+ msgid "Nero Size"
134
+ msgstr ""
135
+
136
+ #: polldaddy.php:447
137
+ msgid "You are not allowed to delete this poll."
138
+ msgstr ""
139
+
140
+ #: polldaddy.php:455 polldaddy.php:491 polldaddy.php:527 polldaddy.php:561
141
+ msgid "Invalid Poll Author"
142
+ msgstr ""
143
+
144
+ #: polldaddy.php:483
145
+ msgid "You are not allowed to open this poll."
146
+ msgstr ""
147
+
148
+ #: polldaddy.php:519
149
+ msgid "You are not allowed to close this poll."
150
+ msgstr ""
151
+
152
+ #: polldaddy.php:552 polldaddy.php:1324
153
+ msgid "You are not allowed to edit this poll."
154
+ msgstr ""
155
+
156
+ #: polldaddy.php:568
157
+ msgid "Poll not found"
158
+ msgstr ""
159
+
160
+ #: polldaddy.php:595
161
+ msgid "Invalid answers"
162
+ msgstr ""
163
+
164
+ #: polldaddy.php:611
165
+ msgid "You must include at least 2 answers"
166
+ msgstr ""
167
+
168
+ #: polldaddy.php:622 polldaddy.php:699
169
+ msgid "Please choose a poll style"
170
+ msgstr ""
171
+
172
+ #: polldaddy.php:644
173
+ msgid "Poll could not be updated"
174
+ msgstr ""
175
+
176
+ #: polldaddy.php:718
177
+ msgid "Poll could not be created"
178
+ msgstr ""
179
+
180
+ #: polldaddy.php:770
181
+ msgid "Style could not be updated"
182
+ msgstr ""
183
+
184
+ #: polldaddy.php:800
185
+ msgid "Style could not be created"
186
+ msgstr ""
187
+
188
+ #: polldaddy.php:899
189
+ msgid ""
190
+ "Account could not be imported. Are your email address and password correct?"
191
+ msgstr ""
192
+
193
+ #: polldaddy.php:917
194
+ msgid "Poll deleted."
195
+ msgstr ""
196
+
197
+ #: polldaddy.php:919
198
+ #, php-format
199
+ msgid "%s Poll Deleted."
200
+ msgid_plural "%s Polls Deleted."
201
+ msgstr[0] ""
202
+ msgstr[1] ""
203
+
204
+ #: polldaddy.php:924
205
+ msgid "Poll opened."
206
+ msgstr ""
207
+
208
+ #: polldaddy.php:926
209
+ #, php-format
210
+ msgid "%s Poll Opened."
211
+ msgid_plural "%s Polls Opened."
212
+ msgstr[0] ""
213
+ msgstr[1] ""
214
+
215
+ #: polldaddy.php:931
216
+ msgid "Poll closed."
217
+ msgstr ""
218
+
219
+ #: polldaddy.php:933
220
+ #, php-format
221
+ msgid "%s Poll Closed."
222
+ msgid_plural "%s Polls Closed."
223
+ msgstr[0] ""
224
+ msgstr[1] ""
225
+
226
+ #: polldaddy.php:936
227
+ msgid "Poll updated."
228
+ msgstr ""
229
+
230
+ #: polldaddy.php:939
231
+ msgid "Poll created."
232
+ msgstr ""
233
+
234
+ #: polldaddy.php:941 polldaddy.php:1357
235
+ msgid "Send to Editor"
236
+ msgstr ""
237
+
238
+ #: polldaddy.php:944
239
+ msgid "Custom Style updated."
240
+ msgstr ""
241
+
242
+ #: polldaddy.php:947
243
+ msgid "Custom Style created."
244
+ msgstr ""
245
+
246
+ #: polldaddy.php:952
247
+ msgid "Custom Style deleted."
248
+ msgstr ""
249
+
250
+ #: polldaddy.php:954
251
+ #, php-format
252
+ msgid "%s Style Deleted."
253
+ msgid_plural "%s Custom Styles Deleted."
254
+ msgstr[0] ""
255
+ msgstr[1] ""
256
+
257
+ #: polldaddy.php:957
258
+ msgid "Account Imported."
259
+ msgstr ""
260
+
261
+ #: polldaddy.php:960
262
+ msgid "Options Updated."
263
+ msgstr ""
264
+
265
+ #: polldaddy.php:969
266
+ msgid "Error: An error has occurred; Poll not created."
267
+ msgstr ""
268
+
269
+ #: polldaddy.php:972
270
+ msgid "Error: An error has occurred; Poll not updated."
271
+ msgstr ""
272
+
273
+ #: polldaddy.php:976
274
+ msgid ""
275
+ "Error: An error has occurred; Account could not be imported. Perhaps your "
276
+ "email address or password is incorrect?"
277
+ msgstr ""
278
+
279
+ #: polldaddy.php:978
280
+ msgid "Error: An error has occurred; Account could not be created."
281
+ msgstr ""
282
+
283
+ #: polldaddy.php:1015
284
+ #, php-format
285
+ msgid ""
286
+ "Poll Preview (<a href=\"%s\">Edit Poll</a>, <a href=\"%s\">List Polls</a>)"
287
+ msgstr ""
288
+
289
+ #: polldaddy.php:1019
290
+ #, php-format
291
+ msgid "Poll Preview (<a href=\"%s\">List Polls</a>)"
292
+ msgstr ""
293
+
294
+ #: polldaddy.php:1029
295
+ #, php-format
296
+ msgid "Poll Results (<a href=\"%s\">Edit Poll</a>)"
297
+ msgstr ""
298
+
299
+ #: polldaddy.php:1031
300
+ #, php-format
301
+ msgid "Poll Results (<a href=\"%s\">List Polls</a>)"
302
+ msgstr ""
303
+
304
+ #: polldaddy.php:1040
305
+ #, php-format
306
+ msgid "Edit Poll (<a href=\"%s\">List Polls</a>)"
307
+ msgstr ""
308
+
309
+ #: polldaddy.php:1049
310
+ #, php-format
311
+ msgid "Create Poll (<a href=\"%s\">List Polls</a>)"
312
+ msgstr ""
313
+
314
+ #: polldaddy.php:1059
315
+ #, php-format
316
+ msgid "Custom Styles (<a href=\"%s\">Add New</a>)"
317
+ msgstr ""
318
+
319
+ #: polldaddy.php:1069
320
+ #, php-format
321
+ msgid "Edit Style (<a href=\"%s\">List Styles</a>)"
322
+ msgstr ""
323
+
324
+ #: polldaddy.php:1078
325
+ #, php-format
326
+ msgid "Create Style (<a href=\"%s\">List Styles</a>)"
327
+ msgstr ""
328
+
329
+ #: polldaddy.php:1094
330
+ #, php-format
331
+ msgid "Polls (<a href=\"%s\">Add New</a>)"
332
+ msgstr ""
333
+
334
+ #: polldaddy.php:1159
335
+ msgid "All Blog's Polls"
336
+ msgstr ""
337
+
338
+ #: polldaddy.php:1160
339
+ msgid "All My Polls"
340
+ msgstr ""
341
+
342
+ #: polldaddy.php:1168 polldaddy.php:1968
343
+ msgid "Actions"
344
+ msgstr ""
345
+
346
+ #: polldaddy.php:1169 polldaddy.php:1234 polldaddy.php:1969 polldaddy.php:2010
347
+ msgid "Delete"
348
+ msgstr ""
349
+
350
+ #: polldaddy.php:1170 polldaddy.php:1241
351
+ msgid "Close"
352
+ msgstr ""
353
+
354
+ #: polldaddy.php:1171 polldaddy.php:1238
355
+ msgid "Open"
356
+ msgstr ""
357
+
358
+ #: polldaddy.php:1173 polldaddy.php:1971
359
+ msgid "Apply"
360
+ msgstr ""
361
+
362
+ #: polldaddy.php:1232
363
+ msgid "Results"
364
+ msgstr ""
365
+
366
+ #: polldaddy.php:1244 polldaddy.php:1250 polldaddy.php:3246
367
+ msgid "Preview"
368
+ msgstr ""
369
+
370
+ #: polldaddy.php:1246
371
+ msgid "Send to editor"
372
+ msgstr ""
373
+
374
+ #: polldaddy.php:1252
375
+ msgid "HTML code"
376
+ msgstr ""
377
+
378
+ #: polldaddy.php:1256 polldaddy.php:2012
379
+ msgid "Y/m/d g:i:s A"
380
+ msgstr ""
381
+
382
+ #: polldaddy.php:1256 polldaddy.php:2012
383
+ msgid "Y/m/d"
384
+ msgstr ""
385
+
386
+ #: polldaddy.php:1260
387
+ msgid "Shortcode"
388
+ msgstr ""
389
+
390
+ #: polldaddy.php:1263
391
+ msgid "JavaScript"
392
+ msgstr ""
393
+
394
+ #: polldaddy.php:1279
395
+ #, php-format
396
+ msgid "What are you doing here? <a href=\"%s\">Go back</a>."
397
+ msgstr ""
398
+
399
+ #: polldaddy.php:1289
400
+ #, php-format
401
+ msgid "No polls yet. <a href=\"%s\">Create one</a>"
402
+ msgstr ""
403
+
404
+ #: polldaddy.php:1291
405
+ msgid "No polls yet."
406
+ msgstr ""
407
+
408
+ #: polldaddy.php:1346
409
+ msgid "Publish"
410
+ msgstr ""
411
+
412
+ #: polldaddy.php:1353
413
+ msgid "Save Poll"
414
+ msgstr ""
415
+
416
+ #: polldaddy.php:1368 polldaddy.php:3981
417
+ msgid "Poll results"
418
+ msgstr ""
419
+
420
+ #: polldaddy.php:1373
421
+ msgid "Show results to voters"
422
+ msgstr ""
423
+
424
+ #: polldaddy.php:1373
425
+ msgid "Only show percentages"
426
+ msgstr ""
427
+
428
+ #: polldaddy.php:1373
429
+ msgid "Hide all results"
430
+ msgstr ""
431
+
432
+ #: polldaddy.php:1391 polldaddy.php:3998
433
+ msgid "Block repeat voters"
434
+ msgstr ""
435
+
436
+ #: polldaddy.php:1396
437
+ msgid "Don't block repeat voters"
438
+ msgstr ""
439
+
440
+ #: polldaddy.php:1396
441
+ msgid "Block by cookie (recommended)"
442
+ msgstr ""
443
+
444
+ #: polldaddy.php:1396
445
+ msgid "Block by cookie and by IP address"
446
+ msgstr ""
447
+
448
+ #: polldaddy.php:1411
449
+ msgid "Expires: "
450
+ msgstr ""
451
+
452
+ #: polldaddy.php:1413 polldaddy.php:4003
453
+ msgid "Never"
454
+ msgstr ""
455
+
456
+ #: polldaddy.php:1414 polldaddy.php:4004
457
+ #, php-format
458
+ msgid "%d hour"
459
+ msgstr ""
460
+
461
+ #: polldaddy.php:1415 polldaddy.php:1416 polldaddy.php:1417 polldaddy.php:4005
462
+ #: polldaddy.php:4006 polldaddy.php:4007
463
+ #, php-format
464
+ msgid "%d hours"
465
+ msgstr ""
466
+
467
+ #: polldaddy.php:1418 polldaddy.php:4008
468
+ #, php-format
469
+ msgid "%d day"
470
+ msgstr ""
471
+
472
+ #: polldaddy.php:1419 polldaddy.php:4009
473
+ #, php-format
474
+ msgid "%d week"
475
+ msgstr ""
476
+
477
+ #: polldaddy.php:1420 polldaddy.php:4010
478
+ #, php-format
479
+ msgid "%d month"
480
+ msgstr ""
481
+
482
+ #: polldaddy.php:1422
483
+ msgid ""
484
+ "Note: Blocking by cookie and IP address can be problematic for some voters."
485
+ msgstr ""
486
+
487
+ #: polldaddy.php:1437
488
+ msgid "Answers"
489
+ msgstr ""
490
+
491
+ #: polldaddy.php:1483
492
+ msgid "Add another"
493
+ msgstr ""
494
+
495
+ #: polldaddy.php:1489
496
+ msgid "Multiple choice"
497
+ msgstr ""
498
+
499
+ #: polldaddy.php:1489
500
+ msgid "Randomize answer order"
501
+ msgstr ""
502
+
503
+ #: polldaddy.php:1489
504
+ msgid "Allow other answers"
505
+ msgstr ""
506
+
507
+ #: polldaddy.php:1489
508
+ msgid "'Share This' link"
509
+ msgstr ""
510
+
511
+ #: polldaddy.php:1618
512
+ msgid "Design"
513
+ msgstr ""
514
+
515
+ #: polldaddy.php:1699 polldaddy.php:1754
516
+ msgid "Custom Style"
517
+ msgstr ""
518
+
519
+ #: polldaddy.php:1712 polldaddy.php:1808
520
+ msgid "Please choose a custom style..."
521
+ msgstr ""
522
+
523
+ #: polldaddy.php:1718 polldaddy.php:1814
524
+ msgid "Please choose a style."
525
+ msgstr ""
526
+
527
+ #: polldaddy.php:1723 polldaddy.php:1819
528
+ #, php-format
529
+ msgid ""
530
+ "Did you know we have a new editor for building your own custom poll styles? "
531
+ "Find out more <a href=\"%s\" target=\"_blank\">here</a>."
532
+ msgstr ""
533
+
534
+ #: polldaddy.php:1746
535
+ msgid "PollDaddy Style"
536
+ msgstr ""
537
+
538
+ #: polldaddy.php:1871
539
+ msgid "Answer"
540
+ msgstr ""
541
+
542
+ #: polldaddy.php:1872 polldaddy.php:1917 polldaddy.php:3731
543
+ msgid "Votes"
544
+ msgstr ""
545
+
546
+ #: polldaddy.php:1886
547
+ #, php-format
548
+ msgid "Other (<a href=\"%s\">see below</a>)"
549
+ msgstr ""
550
+
551
+ #: polldaddy.php:1916 polldaddy.php:3969
552
+ msgid "Other Answer"
553
+ msgstr ""
554
+
555
+ #: polldaddy.php:1981
556
+ msgid "Style"
557
+ msgstr ""
558
+
559
+ #: polldaddy.php:1982
560
+ msgid "Last Modified"
561
+ msgstr ""
562
+
563
+ #: polldaddy.php:2022
564
+ #, php-format
565
+ msgid "No custom styles yet. <a href=\"%s\">Create one</a>"
566
+ msgstr ""
567
+
568
+ #: polldaddy.php:2098
569
+ msgid "Style Name"
570
+ msgstr ""
571
+
572
+ #: polldaddy.php:2113
573
+ msgid "Preload Basic Style"
574
+ msgstr ""
575
+
576
+ #: polldaddy.php:2127
577
+ msgid "Load Style"
578
+ msgstr ""
579
+
580
+ #: polldaddy.php:2918
581
+ msgid "Save Style"
582
+ msgstr ""
583
+
584
+ #: polldaddy.php:3053
585
+ #, php-format
586
+ msgid ""
587
+ "Sorry! There was an error creating your rating widget. Please contact <a "
588
+ "href=\"%1$s\" %2$s>PollDaddy support</a> to fix this."
589
+ msgstr ""
590
+
591
+ #: polldaddy.php:3093
592
+ msgid "Rating Settings"
593
+ msgstr ""
594
+
595
+ #: polldaddy.php:3096
596
+ msgid "Rating updated"
597
+ msgstr ""
598
+
599
+ #: polldaddy.php:3111 polldaddy.php:3680
600
+ msgid "Posts"
601
+ msgstr ""
602
+
603
+ #: polldaddy.php:3117 polldaddy.php:3680
604
+ msgid "Pages"
605
+ msgstr ""
606
+
607
+ #: polldaddy.php:3123 polldaddy.php:3680
608
+ msgid "Comments"
609
+ msgstr ""
610
+
611
+ #: polldaddy.php:3136
612
+ msgid "Enable for blog posts"
613
+ msgstr ""
614
+
615
+ #: polldaddy.php:3142
616
+ msgid "Above each blog post"
617
+ msgstr ""
618
+
619
+ #: polldaddy.php:3142
620
+ msgid "Below each blog post"
621
+ msgstr ""
622
+
623
+ #: polldaddy.php:3161
624
+ msgid "Enable for pages"
625
+ msgstr ""
626
+
627
+ #: polldaddy.php:3167
628
+ msgid "Above each page"
629
+ msgstr ""
630
+
631
+ #: polldaddy.php:3167
632
+ msgid "Below each page"
633
+ msgstr ""
634
+
635
+ #: polldaddy.php:3186
636
+ msgid "Enable for comments"
637
+ msgstr ""
638
+
639
+ #: polldaddy.php:3192
640
+ msgid "Above each comment"
641
+ msgstr ""
642
+
643
+ #: polldaddy.php:3192
644
+ msgid "Below each comment"
645
+ msgstr ""
646
+
647
+ #: polldaddy.php:3208 polldaddy.php:3239
648
+ msgid "Save Changes"
649
+ msgstr ""
650
+
651
+ #: polldaddy.php:3218
652
+ msgid "Advanced Settings"
653
+ msgstr ""
654
+
655
+ #: polldaddy.php:3232
656
+ msgid "Save"
657
+ msgstr ""
658
+
659
+ #: polldaddy.php:3248
660
+ msgid "This is a demo of what your rating widget will look like"
661
+ msgstr ""
662
+
663
+ #: polldaddy.php:3255
664
+ msgid "Customize Labels"
665
+ msgstr ""
666
+
667
+ #: polldaddy.php:3259
668
+ msgid "votes"
669
+ msgstr ""
670
+
671
+ #: polldaddy.php:3263
672
+ msgid "rate this"
673
+ msgstr ""
674
+
675
+ #: polldaddy.php:3267
676
+ #, php-format
677
+ msgid "%d star"
678
+ msgstr ""
679
+
680
+ #: polldaddy.php:3271 polldaddy.php:3275 polldaddy.php:3279 polldaddy.php:3283
681
+ #, php-format
682
+ msgid "%d stars"
683
+ msgstr ""
684
+
685
+ #: polldaddy.php:3287
686
+ msgid "Thank You"
687
+ msgstr ""
688
+
689
+ #: polldaddy.php:3291
690
+ msgid "Rate Up"
691
+ msgstr ""
692
+
693
+ #: polldaddy.php:3295
694
+ msgid "Rate Down"
695
+ msgstr ""
696
+
697
+ #: polldaddy.php:3306
698
+ msgid "Rating Type"
699
+ msgstr ""
700
+
701
+ #: polldaddy.php:3308
702
+ msgid ""
703
+ "Here you can choose how you want your rating to display. The 5 star rating "
704
+ "is the most commonly used. The Nero rating is useful for keeping it simple."
705
+ msgstr ""
706
+
707
+ #: polldaddy.php:3318
708
+ #, php-format
709
+ msgid "%d Star Rating"
710
+ msgstr ""
711
+
712
+ #: polldaddy.php:3329
713
+ msgid "Nero Rating"
714
+ msgstr ""
715
+
716
+ #: polldaddy.php:3336
717
+ msgid "Rating Style"
718
+ msgstr ""
719
+
720
+ #: polldaddy.php:3344
721
+ msgid "Small"
722
+ msgstr ""
723
+
724
+ #: polldaddy.php:3344
725
+ msgid "Medium"
726
+ msgstr ""
727
+
728
+ #: polldaddy.php:3344
729
+ msgid "Large"
730
+ msgstr ""
731
+
732
+ #: polldaddy.php:3358
733
+ msgid "Star Color"
734
+ msgstr ""
735
+
736
+ #: polldaddy.php:3362
737
+ msgid "Yellow"
738
+ msgstr ""
739
+
740
+ #: polldaddy.php:3362
741
+ msgid "Red"
742
+ msgstr ""
743
+
744
+ #: polldaddy.php:3362
745
+ msgid "Blue"
746
+ msgstr ""
747
+
748
+ #: polldaddy.php:3362
749
+ msgid "Green"
750
+ msgstr ""
751
+
752
+ #: polldaddy.php:3362
753
+ msgid "Grey"
754
+ msgstr ""
755
+
756
+ #: polldaddy.php:3373
757
+ msgid "Hand"
758
+ msgstr ""
759
+
760
+ #: polldaddy.php:3386
761
+ msgid "Custom Image"
762
+ msgstr ""
763
+
764
+ #: polldaddy.php:3393
765
+ msgid "Text Layout & Font"
766
+ msgstr ""
767
+
768
+ #: polldaddy.php:3397
769
+ msgid "Align"
770
+ msgstr ""
771
+
772
+ #: polldaddy.php:3401
773
+ msgid "Left"
774
+ msgstr ""
775
+
776
+ #: polldaddy.php:3401
777
+ msgid "Center"
778
+ msgstr ""
779
+
780
+ #: polldaddy.php:3401 polldaddy.php:3417
781
+ msgid "Right"
782
+ msgstr ""
783
+
784
+ #: polldaddy.php:3413
785
+ msgid "Position"
786
+ msgstr ""
787
+
788
+ #: polldaddy.php:3417
789
+ msgid "Top"
790
+ msgstr ""
791
+
792
+ #: polldaddy.php:3417
793
+ msgid "Bottom"
794
+ msgstr ""
795
+
796
+ #: polldaddy.php:3429
797
+ msgid "Font"
798
+ msgstr ""
799
+
800
+ #: polldaddy.php:3446
801
+ msgid "Color"
802
+ msgstr ""
803
+
804
+ #: polldaddy.php:3451
805
+ msgid "Size"
806
+ msgstr ""
807
+
808
+ #: polldaddy.php:3455 polldaddy.php:3472
809
+ msgid "Inherit"
810
+ msgstr ""
811
+
812
+ #: polldaddy.php:3468
813
+ msgid "Line Height"
814
+ msgstr ""
815
+
816
+ #: polldaddy.php:3485
817
+ msgid "Bold"
818
+ msgstr ""
819
+
820
+ #: polldaddy.php:3493
821
+ msgid "Italic"
822
+ msgstr ""
823
+
824
+ #: polldaddy.php:3666
825
+ msgid "&laquo;"
826
+ msgstr ""
827
+
828
+ #: polldaddy.php:3667
829
+ msgid "&raquo;"
830
+ msgstr ""
831
+
832
+ #: polldaddy.php:3673
833
+ msgid "Rating Reports"
834
+ msgstr ""
835
+
836
+ #: polldaddy.php:3691
837
+ msgid "View Report"
838
+ msgstr ""
839
+
840
+ #: polldaddy.php:3695
841
+ msgid "Last 24 hours"
842
+ msgstr ""
843
+
844
+ #: polldaddy.php:3695
845
+ msgid "Last 7 days"
846
+ msgstr ""
847
+
848
+ #: polldaddy.php:3695
849
+ msgid "Last 31 days"
850
+ msgstr ""
851
+
852
+ #: polldaddy.php:3695
853
+ msgid "Last 3 months"
854
+ msgstr ""
855
+
856
+ #: polldaddy.php:3695
857
+ msgid "Last 12 months"
858
+ msgstr ""
859
+
860
+ #: polldaddy.php:3695
861
+ msgid "All time"
862
+ msgstr ""
863
+
864
+ #: polldaddy.php:3704
865
+ msgid "Filter Report"
866
+ msgstr ""
867
+
868
+ #: polldaddy.php:3720
869
+ #, php-format
870
+ msgid "No ratings have been collected for your %s yet."
871
+ msgstr ""
872
+
873
+ #: polldaddy.php:3729
874
+ msgid "Start Date"
875
+ msgstr ""
876
+
877
+ #: polldaddy.php:3730
878
+ msgid "Title"
879
+ msgstr ""
880
+
881
+ #: polldaddy.php:3732
882
+ msgid "Average Rating"
883
+ msgstr ""
884
+
885
+ #: polldaddy.php:3903
886
+ msgid "PollDaddy Account Info"
887
+ msgstr ""
888
+
889
+ #: polldaddy.php:3906
890
+ msgid ""
891
+ "This is the PollDadddy account you currently have imported into your "
892
+ "WordPress account"
893
+ msgstr ""
894
+
895
+ #: polldaddy.php:3937
896
+ msgid "Import Account"
897
+ msgstr ""
898
+
899
+ #: polldaddy.php:3942
900
+ msgid "General Settings"
901
+ msgstr ""
902
+
903
+ #: polldaddy.php:3950
904
+ msgid "Default poll settings"
905
+ msgstr ""
906
+
907
+ #: polldaddy.php:3959
908
+ msgid "Multiple Choice"
909
+ msgstr ""
910
+
911
+ #: polldaddy.php:3964
912
+ msgid "Randomise Answers"
913
+ msgstr ""
914
+
915
+ #: polldaddy.php:3974
916
+ msgid "Sharing"
917
+ msgstr ""
918
+
919
+ #: polldaddy.php:3978
920
+ msgid "Show"
921
+ msgstr ""
922
+
923
+ #: polldaddy.php:3979
924
+ msgid "Hide"
925
+ msgstr ""
926
+
927
+ #: polldaddy.php:3980
928
+ msgid "Percentages"
929
+ msgstr ""
930
+
931
+ #: polldaddy.php:3990
932
+ msgid "Poll style"
933
+ msgstr ""
934
+
935
+ #: polldaddy.php:3995
936
+ msgid "Off"
937
+ msgstr ""
938
+
939
+ #: polldaddy.php:3996
940
+ msgid "Cookie"
941
+ msgstr ""
942
+
943
+ #: polldaddy.php:3997
944
+ msgid "Cookie & IP address"
945
+ msgstr ""
946
+
947
+ #: polldaddy.php:4011
948
+ msgid "Block expiration limit"
949
+ msgstr ""
950
+
951
+ #: polldaddy.php:4023
952
+ msgid "Save Options"
953
+ msgstr ""
954
+
955
+ #. Plugin Name of an extension
956
+ msgid "PollDaddy Polls"
957
+ msgstr ""
958
+
959
+ #. Description of an extension
960
+ msgid "Create and manage PollDaddy polls and ratings in WordPress"
961
+ msgstr ""
962
+
963
+ #. Author of an extension
964
+ msgid "Automattic, Inc."
965
+ msgstr ""
rating.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function polldaddy_show_rating_comments( $content ){
3
+ if ( !is_feed() ) {
4
+ global $comment;
5
+ global $post;
6
+
7
+ if ( $comment->comment_ID > 0 ) {
8
+ $unique_id = '';
9
+ $title = '';
10
+ $permalink = '';
11
+ $html = '';
12
+ $rating_pos = 0;
13
+
14
+ if ( (int) get_option( 'pd-rating-comments' ) > 0 ) {
15
+ $rating_id = (int) get_option( 'pd-rating-comments' );
16
+ $unique_id = 'wp-comment-' . $comment->comment_ID;
17
+ $rating_pos = (int) get_option( 'pd-rating-comments-pos' );
18
+ $title = mb_substr( $comment->comment_content, 0, 195 ) . '...';
19
+ $permalink = get_permalink( $post->ID ) . '#comment-' . $comment->comment_ID;
20
+ $html = polldaddy_get_rating_code( $rating_id, $unique_id, $title, $permalink, '_comm_' . $comment->comment_ID );
21
+
22
+ wp_register_script( 'polldaddy-rating-js', 'http://i.polldaddy.com/ratings/rating.js' );
23
+ add_filter( 'wp_footer', 'polldaddy_add_rating_js' );
24
+ }
25
+
26
+ if ( $rating_pos == 0 )
27
+ $content = $html . $content;
28
+ else
29
+ $content .= $html;
30
+ }
31
+ }
32
+ return $content;
33
+ }
34
+
35
+ function polldaddy_show_rating( $content ) {
36
+ if ( !is_feed() && !is_attachment() ) {
37
+ if ( is_single() || is_page() ) {
38
+ global $post;
39
+
40
+ if ( $post->ID > 0 ) {
41
+ $unique_id = '';
42
+ $title = '';
43
+ $permalink = '';
44
+ $html = '';
45
+ $rating_id = 0;
46
+ $rating_pos = 0;
47
+ $item_id = '';
48
+
49
+ if ( is_page() ) {
50
+ if ( (int) get_option( 'pd-rating-pages' ) > 0 ) {
51
+ $rating_id = (int) get_option( 'pd-rating-pages' );
52
+ $unique_id = 'wp-page-' . $post->ID;
53
+ $rating_pos = (int) get_option( 'pd-rating-pages-pos' );
54
+ $item_id = '_page_' . $post->ID;
55
+ }
56
+ } else {
57
+ if ( (int) get_option( 'pd-rating-posts' ) > 0 ) {
58
+ $rating_id = (int) get_option( 'pd-rating-posts' );
59
+ $unique_id = 'wp-post-' . $post->ID;
60
+ $rating_pos = (int) get_option( 'pd-rating-posts-pos' );
61
+ $item_id = '_post_' . $post->ID;
62
+ }
63
+ }
64
+
65
+ if ( $rating_id > 0 ) {
66
+ $title = $post->post_title;
67
+ $permalink = get_permalink( $post->ID );
68
+ $html = polldaddy_get_rating_code( $rating_id, $unique_id, $title, $permalink, $item_id );
69
+
70
+ wp_register_script( 'polldaddy-rating-js', 'http://i.polldaddy.com/ratings/rating.js' );
71
+ add_filter( 'wp_footer', 'polldaddy_add_rating_js' );
72
+ }
73
+
74
+ if ( $rating_pos == 0 )
75
+ $content = $html . $content;
76
+ else
77
+ $content .= $html;
78
+ }
79
+ }
80
+ }
81
+ return $content;
82
+ }
83
+
84
+ function polldaddy_get_rating_code( $rating_id, $unique_id, $title, $permalink, $item_id = '' ) {
85
+
86
+ $html = '<p><div class="pd-rating" id="pd_rating_holder_' . $rating_id . $item_id . '"></div></p>
87
+ <script type="text/javascript">
88
+ PDRTJS_settings_' . (int)$rating_id . $item_id . ' = {
89
+ "id" : "' . (int)$rating_id . '",
90
+ "unique_id" : "' . urlencode( $unique_id ) . '",
91
+ "title" : "' . urlencode( $title ) . '",' . "\n";
92
+
93
+ if ( $item_id != '' )
94
+ $html .= ( ' "item_id" : "' . $item_id . '",' . "\n" );
95
+
96
+ $html .= ' "permalink" : "' . urlencode( clean_url( $permalink ) ) . '"';
97
+ $html .= "\n }\n";
98
+ $html .= '</script>';
99
+
100
+ return $html;
101
+ }
102
+
103
+ add_filter( 'the_content', 'polldaddy_show_rating', 1 );
104
+ add_filter( 'comment_text', 'polldaddy_show_rating_comments', 50 );
105
+ ?>
readme.txt CHANGED
@@ -3,13 +3,19 @@ Contributors: mdawaffe, eoigal
3
  Tags: polls, poll, polldaddy, wppolls, vote, polling, surveys, rate, rating, ratings
4
  Requires at least: 2.6
5
  Tested up to: 2.9.1
6
- Stable tag: 1.7.7
7
 
8
  Create and manage PollDaddy polls and ratings from within WordPress.
9
 
10
  == Description ==
11
 
12
- The PollDaddy Polls plugin allows you to create and manage polls and ratings from within your WordPress dashboard. You can create polls, choose from 20 different styles for your polls, and view all results for your polls as they come in. All PollDaddy polls are fully customizable, you can set a close date for your poll, create multiple choice polls, choose whether to display the results or keep them private. You can also create your own custom style for your poll. You can even embed the polls you create on other websites. You can collect unlimited votes and create unlimited polls. The new ratings menu allows you to embed ratings into your posts, pages or comments.
 
 
 
 
 
 
13
 
14
  == Installation ==
15
 
@@ -17,6 +23,15 @@ Upload the plugin to your blog, Activate it, then enter your PollDaddy.com email
17
 
18
  More info here - http://support.polldaddy.com/installing-wordpress-org-plugin/
19
 
 
 
 
 
 
 
 
 
 
20
  == Frequently Asked Questions ==
21
 
22
  = I have multiple authors on my blog? What happens? =
@@ -32,6 +47,12 @@ Yes. You'll be able to edit the polls they create from your blog. (You won't be
32
  Nope. The permissions are the same as for posts. So Editors and Administrators can edit anyone's polls for that blog. Authors can only edit their own.
33
 
34
  == Change Log ==
 
 
 
 
 
 
35
  = 1.7.7 =
36
  * Added a block repeat vote expiration setting to allow users to set how long to block out repeat voters from repeat voting
37
  * Bug Fix: Fixed notices thrown by ratings when first loaded, empty response from API.
3
  Tags: polls, poll, polldaddy, wppolls, vote, polling, surveys, rate, rating, ratings
4
  Requires at least: 2.6
5
  Tested up to: 2.9.1
6
+ Stable tag: 1.7.8
7
 
8
  Create and manage PollDaddy polls and ratings from within WordPress.
9
 
10
  == Description ==
11
 
12
+ The PollDaddy Polls and Ratings plugin allows you to create and manage polls and ratings from within your WordPress dashboard. You can create polls, choose from 20 different styles for your polls, and view all results for your polls as they come in. All PollDaddy polls are fully customizable, you can set a close date for your poll, create multiple choice polls, choose whether to display the results or keep them private. You can also create your own custom style for your poll. You can even embed the polls you create on other websites. You can collect unlimited votes and create unlimited polls. The new ratings menu allows you to embed ratings into your posts, pages or comments. The rating editor allows you to fully customize you rating. You can also avail of the the 'Top Rated' widget that will allow you to place the widget in your sidebar. This widget will show you the top rated posts, pages and comments today, this week and this month.
13
+
14
+ PollDaddy Polls is localizable and currently available in:
15
+
16
+ * English
17
+
18
+ A messages.pot file is included in the plugin - please do send us any language files!
19
 
20
  == Installation ==
21
 
23
 
24
  More info here - http://support.polldaddy.com/installing-wordpress-org-plugin/
25
 
26
+ == Screenshots ==
27
+
28
+ 1. Manage polls
29
+ 2. Edit poll
30
+ 3. View poll on page or in a widget
31
+ 4. Add ratings
32
+ 5. Ratings on a post
33
+ 6. Ratings on comments
34
+
35
  == Frequently Asked Questions ==
36
 
37
  = I have multiple authors on my blog? What happens? =
47
  Nope. The permissions are the same as for posts. So Editors and Administrators can edit anyone's polls for that blog. Authors can only edit their own.
48
 
49
  == Change Log ==
50
+ = 1.7.8 =
51
+ * Added Options menu, that will allow users to set poll defaults settings, import another PollDaddy account and there is also a setting to allow each blog user to import their own PollDaddy account.
52
+ * Added the Top Rated widget.
53
+ * Added survey and rating short codes.
54
+ * Added a pot file to allow the plugin to be localized.
55
+
56
  = 1.7.7 =
57
  * Added a block repeat vote expiration setting to allow users to set how long to block out repeat voters from repeat voting
58
  * Bug Fix: Fixed notices thrown by ratings when first loaded, empty response from API.
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
screenshot-3.png ADDED
Binary file
screenshot-4.png ADDED
Binary file
screenshot-5.png ADDED
Binary file
screenshot-6.png ADDED
Binary file