Version Description
- New PollDaddy API
- Do not store UserCode, retrieve from API
- Bug Fix: Fix API key retrieval. Improper use of wp_remote_post()
Download this release
Release Info
| Developer | mdawaffe |
| Plugin | |
| Version | 1.0 |
| Comparing to | |
| See all releases | |
Code changes from version 0.9 to 1.0
- polldaddy-client.php +1 -1
- polldaddy.php +60 -41
- readme.txt +6 -1
polldaddy-client.php
CHANGED
|
@@ -4,7 +4,7 @@ require_once dirname( __FILE__ ) . '/polldaddy-xml.php';
|
|
| 4 |
|
| 5 |
// TODO: polls->poll should always be an array and similar bad typing
|
| 6 |
class PollDaddy_Client {
|
| 7 |
-
var $polldaddy_url = 'http://api.polldaddy.com/
|
| 8 |
var $partnerGUID;
|
| 9 |
var $userCode;
|
| 10 |
|
| 4 |
|
| 5 |
// TODO: polls->poll should always be an array and similar bad typing
|
| 6 |
class PollDaddy_Client {
|
| 7 |
+
var $polldaddy_url = 'http://api.polldaddy.com/';
|
| 8 |
var $partnerGUID;
|
| 9 |
var $userCode;
|
| 10 |
|
polldaddy.php
CHANGED
|
@@ -5,7 +5,7 @@ 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: 0
|
| 9 |
*/
|
| 10 |
|
| 11 |
// You can hardcode your PollDaddy PartnerGUID (API Key) here
|
|
@@ -24,6 +24,19 @@ class WP_PollDaddy {
|
|
| 24 |
var $base_url = false;
|
| 25 |
var $version = '0.8';
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
function admin_menu() {
|
| 28 |
global $current_user;
|
| 29 |
|
|
@@ -41,7 +54,7 @@ class WP_PollDaddy {
|
|
| 41 |
|
| 42 |
if ( !WP_POLLDADDY__PARTNERGUID ) {
|
| 43 |
if ( function_exists( 'add_object_page' ) ) // WP 2.7+
|
| 44 |
-
$hook = add_object_page( __( 'Polls' ), __( 'Polls' ), 'edit_posts', 'polls', array( &$this, 'api_key_page' ),
|
| 45 |
else
|
| 46 |
$hook = add_management_page( __( 'Polls' ), __( 'Polls' ), 'edit_posts', 'polls', array( &$this, 'api_key_page' ) );
|
| 47 |
add_action( "load-$hook", array( &$this, 'api_key_page_load' ) );
|
|
@@ -50,16 +63,14 @@ class WP_PollDaddy {
|
|
| 50 |
return false;
|
| 51 |
}
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
);
|
| 59 |
-
}
|
| 60 |
|
| 61 |
if ( function_exists( 'add_object_page' ) ) // WP 2.7+
|
| 62 |
-
$hook = add_object_page( __( 'Polls' ), __( 'Polls' ), 'edit_posts', 'polls', array( &$this, 'management_page' ),
|
| 63 |
else
|
| 64 |
$hook = add_management_page( __( 'Polls' ), __( 'Polls' ), 'edit_posts', 'polls', array( &$this, 'management_page' ) );
|
| 65 |
add_action( "load-$hook", array( &$this, 'management_page_load' ) );
|
|
@@ -92,12 +103,18 @@ class WP_PollDaddy {
|
|
| 92 |
$details = array(
|
| 93 |
'uName' => get_bloginfo( 'name' ),
|
| 94 |
'uEmail' => $polldaddy_email,
|
| 95 |
-
'uPass' => $polldaddy_password
|
|
|
|
| 96 |
);
|
| 97 |
if ( function_exists( 'wp_remote_post' ) ) { // WP 2.7+
|
| 98 |
-
$polldaddy_api_key = wp_remote_post( '
|
| 99 |
'body' => $details
|
| 100 |
) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
} else {
|
| 102 |
$fp = fsockopen(
|
| 103 |
'api.polldaddy.com',
|
|
@@ -119,7 +136,7 @@ class WP_PollDaddy {
|
|
| 119 |
|
| 120 |
$request_body = http_build_query( $details, null, '&' );
|
| 121 |
|
| 122 |
-
$request = "POST /key
|
| 123 |
$request .= "Host: api.polldaddy.com\r\n";
|
| 124 |
$request .= "User-agent: WordPress/$wp_version\r\n";
|
| 125 |
$request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option('blog_charset') . "\r\n";
|
|
@@ -141,13 +158,9 @@ class WP_PollDaddy {
|
|
| 141 |
|
| 142 |
update_option( 'polldaddy_api_key', $polldaddy_api_key );
|
| 143 |
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
if ( $polldaddy_account = $polldaddy->GetUserCode( 0 ) ) {
|
| 149 |
-
update_usermeta( $GLOBALS['user_ID'], 'polldaddy_account', $polldaddy_account );
|
| 150 |
-
} else {
|
| 151 |
$this->parse_errors( $polldaddy );
|
| 152 |
$this->errors->add( 'GetUserCode', __( 'Account could not be accessed. Are your email address and password correct?' ) );
|
| 153 |
return false;
|
|
@@ -294,9 +307,10 @@ class WP_PollDaddy {
|
|
| 294 |
else
|
| 295 |
check_admin_referer( "delete-poll_$poll" );
|
| 296 |
|
| 297 |
-
$polldaddy =
|
| 298 |
|
| 299 |
foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
|
|
|
|
| 300 |
$poll_object = $polldaddy->GetPoll( $poll );
|
| 301 |
|
| 302 |
if ( !$this->can_edit( $poll_object ) ) {
|
|
@@ -304,18 +318,17 @@ class WP_PollDaddy {
|
|
| 304 |
return false;
|
| 305 |
}
|
| 306 |
|
| 307 |
-
$polldaddy->reset();
|
| 308 |
-
|
| 309 |
// Send Poll Author credentials
|
| 310 |
if ( !empty( $poll_object->_owner ) && $current_user->ID != $poll_object->_owner ) {
|
| 311 |
-
|
|
|
|
| 312 |
$this->errors->add( 'no_usercode', __( 'Invalid Poll Author' ) );
|
| 313 |
}
|
| 314 |
$polldaddy->userCode = $userCode;
|
| 315 |
}
|
| 316 |
|
| 317 |
-
$polldaddy->DeletePoll( $poll_id );
|
| 318 |
$polldaddy->reset();
|
|
|
|
| 319 |
}
|
| 320 |
|
| 321 |
$query_args['message'] = 'deleted';
|
|
@@ -327,9 +340,11 @@ class WP_PollDaddy {
|
|
| 327 |
|
| 328 |
check_admin_referer( "edit-poll_$poll" );
|
| 329 |
|
| 330 |
-
$polldaddy =
|
|
|
|
| 331 |
|
| 332 |
$poll_object = $polldaddy->GetPoll( $poll );
|
|
|
|
| 333 |
|
| 334 |
if ( !$this->can_edit( $poll_object ) ) {
|
| 335 |
$this->errors->add( 'permission', __( 'You are not allowed to edit this poll.' ) );
|
|
@@ -337,15 +352,16 @@ class WP_PollDaddy {
|
|
| 337 |
}
|
| 338 |
|
| 339 |
// Send Poll Author credentials
|
|
|
|
| 340 |
if ( !empty( $poll_object->_owner ) && $current_user->ID != $poll_object->_owner ) {
|
| 341 |
-
|
|
|
|
| 342 |
$this->errors->add( 'no_usercode', __( 'Invalid Poll Author' ) );
|
| 343 |
}
|
|
|
|
| 344 |
$polldaddy->userCode = $userCode;
|
| 345 |
}
|
| 346 |
|
| 347 |
-
$this->parse_errors( $polldaddy );
|
| 348 |
-
|
| 349 |
if ( !$poll_object )
|
| 350 |
$this->errors->add( 'GetPoll', __( 'Poll not found' ) );
|
| 351 |
|
|
@@ -418,7 +434,8 @@ class WP_PollDaddy {
|
|
| 418 |
|
| 419 |
check_admin_referer( 'create-poll' );
|
| 420 |
|
| 421 |
-
$polldaddy =
|
|
|
|
| 422 |
|
| 423 |
$answers = array();
|
| 424 |
foreach ( $_POST['answer'] as $answer )
|
|
@@ -460,7 +477,8 @@ class WP_PollDaddy {
|
|
| 460 |
function management_page_load_signup() {
|
| 461 |
switch ( $_POST['account'] ) :
|
| 462 |
case 'import' :
|
| 463 |
-
$polldaddy =
|
|
|
|
| 464 |
$email = trim( stripslashes( $_POST['polldaddy_email'] ) );
|
| 465 |
$password = trim( stripslashes( $_POST['polldaddy_password'] ) );
|
| 466 |
|
|
@@ -473,9 +491,7 @@ class WP_PollDaddy {
|
|
| 473 |
if ( $this->errors->get_error_codes() )
|
| 474 |
return false;
|
| 475 |
|
| 476 |
-
if (
|
| 477 |
-
update_usermeta( $GLOBALS['user_ID'], 'polldaddy_account', $polldaddy_account );
|
| 478 |
-
} else {
|
| 479 |
$this->parse_errors( $polldaddy );
|
| 480 |
$this->errors->add( 'import-account', __( 'Account could not be imported. Are your email address and password correct?' ) );
|
| 481 |
return false;
|
|
@@ -560,7 +576,7 @@ class WP_PollDaddy {
|
|
| 560 |
|
| 561 |
<h2 id="preview-header"><?php printf( __( 'Poll Preview (<a href="%s">Edit Poll</a>, <a href="%s">List Polls</a>)' ),
|
| 562 |
clean_url( add_query_arg( array( 'action' => 'edit', 'poll' => $poll, 'message' => false ) ) ),
|
| 563 |
-
clean_url( add_query_arg( array( 'action' => false, 'poll' =>
|
| 564 |
); ?></h2>
|
| 565 |
|
| 566 |
<?php
|
|
@@ -578,7 +594,7 @@ class WP_PollDaddy {
|
|
| 578 |
case 'edit-poll' :
|
| 579 |
?>
|
| 580 |
|
| 581 |
-
<h2><?php printf( __('Edit Poll (<a href="%s">List Polls</a>)'), clean_url( add_query_arg( array( 'action' => false, 'poll' =>
|
| 582 |
|
| 583 |
<?php
|
| 584 |
|
|
@@ -587,7 +603,7 @@ class WP_PollDaddy {
|
|
| 587 |
case 'create-poll' :
|
| 588 |
?>
|
| 589 |
|
| 590 |
-
<h2><?php printf( __('Create Poll (<a href="%s">List Polls</a>)'), clean_url( add_query_arg( array( 'action' => false, 'poll' =>
|
| 591 |
|
| 592 |
<?php
|
| 593 |
$this->poll_edit_form();
|
|
@@ -617,7 +633,8 @@ class WP_PollDaddy {
|
|
| 617 |
$page = absint($_GET['paged']);
|
| 618 |
if ( !$page )
|
| 619 |
$page = 1;
|
| 620 |
-
$polldaddy =
|
|
|
|
| 621 |
if ( 'user' == $view )
|
| 622 |
$polls_object = $polldaddy->listPolls( ( $page - 1 ) * 10 + 1, $page * 10 );
|
| 623 |
else
|
|
@@ -634,7 +651,6 @@ class WP_PollDaddy {
|
|
| 634 |
'total' => ceil( $total_polls / 10 ),
|
| 635 |
'current' => $page
|
| 636 |
) );
|
| 637 |
-
|
| 638 |
?>
|
| 639 |
|
| 640 |
<ul class="subsubsub">
|
|
@@ -756,13 +772,15 @@ class WP_PollDaddy {
|
|
| 756 |
function poll_edit_form( $poll_id = 0 ) {
|
| 757 |
$poll_id = (int) $poll_id;
|
| 758 |
|
| 759 |
-
$polldaddy =
|
|
|
|
| 760 |
|
| 761 |
$is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
|
| 762 |
|
| 763 |
if ( $poll_id ) {
|
| 764 |
$poll = $polldaddy->GetPoll( $poll_id );
|
| 765 |
$this->parse_errors( $polldaddy );
|
|
|
|
| 766 |
if ( !$this->can_edit( $poll ) ) {
|
| 767 |
$this->errors->add( 'permission', __( 'You are not allowed to edit this poll.' ) );
|
| 768 |
}
|
|
@@ -987,7 +1005,8 @@ class WP_PollDaddy {
|
|
| 987 |
}
|
| 988 |
|
| 989 |
function poll_results_page( $poll_id ) {
|
| 990 |
-
$polldaddy =
|
|
|
|
| 991 |
|
| 992 |
$results = $polldaddy->GetPollResults( $poll_id );
|
| 993 |
?>
|
| 5 |
Description: Create and manage PollDaddy polls in WordPress
|
| 6 |
Author: Automattic, Inc.
|
| 7 |
Author URL: http://automattic.com/
|
| 8 |
+
Version: 1.0
|
| 9 |
*/
|
| 10 |
|
| 11 |
// You can hardcode your PollDaddy PartnerGUID (API Key) here
|
| 24 |
var $base_url = false;
|
| 25 |
var $version = '0.8';
|
| 26 |
|
| 27 |
+
var $polldaddy_clients = array();
|
| 28 |
+
|
| 29 |
+
function &get_client( $api_key, $userCode = null ) {
|
| 30 |
+
if ( isset( $this->polldaddy_clients[$api_key] ) ) {
|
| 31 |
+
if ( !is_null( $userCode ) )
|
| 32 |
+
$this->polldaddy_clients[$api_key]->userCode = $userCode;
|
| 33 |
+
return $this->polldaddy_clients[$api_key];
|
| 34 |
+
}
|
| 35 |
+
require_once WP_POLLDADDY__POLLDADDY_CLIENT_PATH;
|
| 36 |
+
$this->polldaddy_clients[$api_key] = new $this->polldaddy_client_class( $api_key, $userCode );
|
| 37 |
+
return $this->polldaddy_clients[$api_key];
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
function admin_menu() {
|
| 41 |
global $current_user;
|
| 42 |
|
| 54 |
|
| 55 |
if ( !WP_POLLDADDY__PARTNERGUID ) {
|
| 56 |
if ( function_exists( 'add_object_page' ) ) // WP 2.7+
|
| 57 |
+
$hook = add_object_page( __( 'Polls' ), __( 'Polls' ), 'edit_posts', 'polls', array( &$this, 'api_key_page' ), "{$this->base_url}polldaddy.png" );
|
| 58 |
else
|
| 59 |
$hook = add_management_page( __( 'Polls' ), __( 'Polls' ), 'edit_posts', 'polls', array( &$this, 'api_key_page' ) );
|
| 60 |
add_action( "load-$hook", array( &$this, 'api_key_page_load' ) );
|
| 63 |
return false;
|
| 64 |
}
|
| 65 |
|
| 66 |
+
$polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID );
|
| 67 |
+
$polldaddy->reset();
|
| 68 |
+
|
| 69 |
+
if ( !defined( 'WP_POLLDADDY__USERCODE' ) )
|
| 70 |
+
define( 'WP_POLLDADDY__USERCODE', $polldaddy->GetUserCode( $current_user->ID ) );
|
|
|
|
|
|
|
| 71 |
|
| 72 |
if ( function_exists( 'add_object_page' ) ) // WP 2.7+
|
| 73 |
+
$hook = add_object_page( __( 'Polls' ), __( 'Polls' ), 'edit_posts', 'polls', array( &$this, 'management_page' ), "{$this->base_url}polldaddy.png" );
|
| 74 |
else
|
| 75 |
$hook = add_management_page( __( 'Polls' ), __( 'Polls' ), 'edit_posts', 'polls', array( &$this, 'management_page' ) );
|
| 76 |
add_action( "load-$hook", array( &$this, 'management_page_load' ) );
|
| 103 |
$details = array(
|
| 104 |
'uName' => get_bloginfo( 'name' ),
|
| 105 |
'uEmail' => $polldaddy_email,
|
| 106 |
+
'uPass' => $polldaddy_password,
|
| 107 |
+
'partner_userid' => $GLOBALS['current_user']->ID
|
| 108 |
);
|
| 109 |
if ( function_exists( 'wp_remote_post' ) ) { // WP 2.7+
|
| 110 |
+
$polldaddy_api_key = wp_remote_post( 'https://api.polldaddy.com/key.php', array(
|
| 111 |
'body' => $details
|
| 112 |
) );
|
| 113 |
+
if ( is_wp_error( $polldaddy_api_key ) ) {
|
| 114 |
+
$this->errors = $polldaddy_api_key;
|
| 115 |
+
return false;
|
| 116 |
+
}
|
| 117 |
+
$polldaddy_api_key = wp_remote_retrieve_body( $polldaddy_api_key );
|
| 118 |
} else {
|
| 119 |
$fp = fsockopen(
|
| 120 |
'api.polldaddy.com',
|
| 136 |
|
| 137 |
$request_body = http_build_query( $details, null, '&' );
|
| 138 |
|
| 139 |
+
$request = "POST /key.php HTTP/1.0\r\n";
|
| 140 |
$request .= "Host: api.polldaddy.com\r\n";
|
| 141 |
$request .= "User-agent: WordPress/$wp_version\r\n";
|
| 142 |
$request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option('blog_charset') . "\r\n";
|
| 158 |
|
| 159 |
update_option( 'polldaddy_api_key', $polldaddy_api_key );
|
| 160 |
|
| 161 |
+
$polldaddy = $this->get_client( $polldaddy_api_key );
|
| 162 |
+
$polldaddy->reset();
|
| 163 |
+
if ( !$polldaddy->GetUserCode( $GLOBALS['current_user']->ID ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
$this->parse_errors( $polldaddy );
|
| 165 |
$this->errors->add( 'GetUserCode', __( 'Account could not be accessed. Are your email address and password correct?' ) );
|
| 166 |
return false;
|
| 307 |
else
|
| 308 |
check_admin_referer( "delete-poll_$poll" );
|
| 309 |
|
| 310 |
+
$polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
|
| 311 |
|
| 312 |
foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
|
| 313 |
+
$polldaddy->reset();
|
| 314 |
$poll_object = $polldaddy->GetPoll( $poll );
|
| 315 |
|
| 316 |
if ( !$this->can_edit( $poll_object ) ) {
|
| 318 |
return false;
|
| 319 |
}
|
| 320 |
|
|
|
|
|
|
|
| 321 |
// Send Poll Author credentials
|
| 322 |
if ( !empty( $poll_object->_owner ) && $current_user->ID != $poll_object->_owner ) {
|
| 323 |
+
$polldaddy->reset();
|
| 324 |
+
if ( !$userCode = $polldaddy->GetUserCode( $poll_object->_owner ) ) {
|
| 325 |
$this->errors->add( 'no_usercode', __( 'Invalid Poll Author' ) );
|
| 326 |
}
|
| 327 |
$polldaddy->userCode = $userCode;
|
| 328 |
}
|
| 329 |
|
|
|
|
| 330 |
$polldaddy->reset();
|
| 331 |
+
$polldaddy->DeletePoll( $poll_id );
|
| 332 |
}
|
| 333 |
|
| 334 |
$query_args['message'] = 'deleted';
|
| 340 |
|
| 341 |
check_admin_referer( "edit-poll_$poll" );
|
| 342 |
|
| 343 |
+
$polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
|
| 344 |
+
$polldaddy->reset();
|
| 345 |
|
| 346 |
$poll_object = $polldaddy->GetPoll( $poll );
|
| 347 |
+
$this->parse_errors( $polldaddy );
|
| 348 |
|
| 349 |
if ( !$this->can_edit( $poll_object ) ) {
|
| 350 |
$this->errors->add( 'permission', __( 'You are not allowed to edit this poll.' ) );
|
| 352 |
}
|
| 353 |
|
| 354 |
// Send Poll Author credentials
|
| 355 |
+
|
| 356 |
if ( !empty( $poll_object->_owner ) && $current_user->ID != $poll_object->_owner ) {
|
| 357 |
+
$polldaddy->reset();
|
| 358 |
+
if ( !$userCode = $polldaddy->GetUserCode( $poll_object->_owner ) ) {
|
| 359 |
$this->errors->add( 'no_usercode', __( 'Invalid Poll Author' ) );
|
| 360 |
}
|
| 361 |
+
$this->parse_errors( $polldaddy );
|
| 362 |
$polldaddy->userCode = $userCode;
|
| 363 |
}
|
| 364 |
|
|
|
|
|
|
|
| 365 |
if ( !$poll_object )
|
| 366 |
$this->errors->add( 'GetPoll', __( 'Poll not found' ) );
|
| 367 |
|
| 434 |
|
| 435 |
check_admin_referer( 'create-poll' );
|
| 436 |
|
| 437 |
+
$polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
|
| 438 |
+
$polldaddy->reset();
|
| 439 |
|
| 440 |
$answers = array();
|
| 441 |
foreach ( $_POST['answer'] as $answer )
|
| 477 |
function management_page_load_signup() {
|
| 478 |
switch ( $_POST['account'] ) :
|
| 479 |
case 'import' :
|
| 480 |
+
$polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID );
|
| 481 |
+
$polldaddy->reset();
|
| 482 |
$email = trim( stripslashes( $_POST['polldaddy_email'] ) );
|
| 483 |
$password = trim( stripslashes( $_POST['polldaddy_password'] ) );
|
| 484 |
|
| 491 |
if ( $this->errors->get_error_codes() )
|
| 492 |
return false;
|
| 493 |
|
| 494 |
+
if ( !$polldaddy->Initiate( $email, $password, $GLOBALS['user_ID'] ) ) {
|
|
|
|
|
|
|
| 495 |
$this->parse_errors( $polldaddy );
|
| 496 |
$this->errors->add( 'import-account', __( 'Account could not be imported. Are your email address and password correct?' ) );
|
| 497 |
return false;
|
| 576 |
|
| 577 |
<h2 id="preview-header"><?php printf( __( 'Poll Preview (<a href="%s">Edit Poll</a>, <a href="%s">List Polls</a>)' ),
|
| 578 |
clean_url( add_query_arg( array( 'action' => 'edit', 'poll' => $poll, 'message' => false ) ) ),
|
| 579 |
+
clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) )
|
| 580 |
); ?></h2>
|
| 581 |
|
| 582 |
<?php
|
| 594 |
case 'edit-poll' :
|
| 595 |
?>
|
| 596 |
|
| 597 |
+
<h2><?php printf( __('Edit Poll (<a href="%s">List Polls</a>)'), clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ) ); ?></h2>
|
| 598 |
|
| 599 |
<?php
|
| 600 |
|
| 603 |
case 'create-poll' :
|
| 604 |
?>
|
| 605 |
|
| 606 |
+
<h2><?php printf( __('Create Poll (<a href="%s">List Polls</a>)'), clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ) ); ?></h2>
|
| 607 |
|
| 608 |
<?php
|
| 609 |
$this->poll_edit_form();
|
| 633 |
$page = absint($_GET['paged']);
|
| 634 |
if ( !$page )
|
| 635 |
$page = 1;
|
| 636 |
+
$polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
|
| 637 |
+
$polldaddy->reset();
|
| 638 |
if ( 'user' == $view )
|
| 639 |
$polls_object = $polldaddy->listPolls( ( $page - 1 ) * 10 + 1, $page * 10 );
|
| 640 |
else
|
| 651 |
'total' => ceil( $total_polls / 10 ),
|
| 652 |
'current' => $page
|
| 653 |
) );
|
|
|
|
| 654 |
?>
|
| 655 |
|
| 656 |
<ul class="subsubsub">
|
| 772 |
function poll_edit_form( $poll_id = 0 ) {
|
| 773 |
$poll_id = (int) $poll_id;
|
| 774 |
|
| 775 |
+
$polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
|
| 776 |
+
$polldaddy->reset();
|
| 777 |
|
| 778 |
$is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
|
| 779 |
|
| 780 |
if ( $poll_id ) {
|
| 781 |
$poll = $polldaddy->GetPoll( $poll_id );
|
| 782 |
$this->parse_errors( $polldaddy );
|
| 783 |
+
|
| 784 |
if ( !$this->can_edit( $poll ) ) {
|
| 785 |
$this->errors->add( 'permission', __( 'You are not allowed to edit this poll.' ) );
|
| 786 |
}
|
| 1005 |
}
|
| 1006 |
|
| 1007 |
function poll_results_page( $poll_id ) {
|
| 1008 |
+
$polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
|
| 1009 |
+
$polldaddy->reset();
|
| 1010 |
|
| 1011 |
$results = $polldaddy->GetPollResults( $poll_id );
|
| 1012 |
?>
|
readme.txt
CHANGED
|
@@ -3,7 +3,7 @@ Contributors: mdawaffe
|
|
| 3 |
Tags: poll, polls, polldaddy, WordPress.com
|
| 4 |
Requires at least: 2.6
|
| 5 |
Tested up to: 2.7.1
|
| 6 |
-
Stable tag: 0
|
| 7 |
|
| 8 |
Create and manage PollDaddy polls from within WordPress.
|
| 9 |
|
|
@@ -31,6 +31,11 @@ Nope. The permissions are the same as for posts. So Editors and Administrators
|
|
| 31 |
|
| 32 |
== Change Log ==
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
= 0.9 =
|
| 35 |
* Compatiblity with WordPress 2.7
|
| 36 |
* Bug Fix: Potential charset issues
|
| 3 |
Tags: poll, polls, polldaddy, WordPress.com
|
| 4 |
Requires at least: 2.6
|
| 5 |
Tested up to: 2.7.1
|
| 6 |
+
Stable tag: 1.0
|
| 7 |
|
| 8 |
Create and manage PollDaddy polls from within WordPress.
|
| 9 |
|
| 31 |
|
| 32 |
== Change Log ==
|
| 33 |
|
| 34 |
+
= 1.0 =
|
| 35 |
+
* New PollDaddy API
|
| 36 |
+
* Do not store UserCode, retrieve from API
|
| 37 |
+
* Bug Fix: Fix API key retrieval. Improper use of wp_remote_post()
|
| 38 |
+
|
| 39 |
= 0.9 =
|
| 40 |
* Compatiblity with WordPress 2.7
|
| 41 |
* Bug Fix: Potential charset issues
|
