/blog/wp-content/plugins/polldaddy/polldaddy.php
PHP | 4477 lines | 4068 code | 396 blank | 13 comment | 524 complexity | 4570197ed0b395937eb9f34b958eae9b MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, AGPL-1.0, LGPL-2.1
Large files files are truncated, but you can click here to view the full file
- <?php
-
- /*
- Plugin Name: PollDaddy Polls
- Description: Create and manage PollDaddy polls and ratings in WordPress
- Author: Automattic, Inc.
- Author URL: http://automattic.com/
- Version: 1.8.9
- */
-
- // You can hardcode your PollDaddy PartnerGUID (API Key) here
- //define( 'WP_POLLDADDY__PARTNERGUID', '12345...' );
-
- class WP_PollDaddy {
- var $errors;
- var $base_url;
- var $is_admin;
- var $is_author;
- var $scheme;
- var $version;
- var $polldaddy_client_class;
- var $polldaddy_clients;
- var $id;
- var $multiple_accounts;
- var $user_code;
- var $rating_user_code;
-
- function WP_PollDaddy(){
- $this ->__construct();
- }
-
- function __construct() {
- global $current_user;
- $this->errors = new WP_Error;
- $this->scheme = 'https';
- $this->version = '1.8.8';
- $this->multiple_accounts = true;
- $this->polldaddy_client_class = 'api_client';
- $this->polldaddy_clients = array();
- $this->is_admin = (bool) current_user_can('manage_options');
- $this->is_author = true;
- $this->id = (int) $current_user->ID;
- $this->user_code = null;
- $this->rating_user_code = null;
- }
-
- function &get_client( $api_key, $userCode = null ) {
- if ( isset( $this->polldaddy_clients[$api_key] ) ) {
- if ( !is_null( $userCode ) )
- $this->polldaddy_clients[$api_key]->userCode = $userCode;
- return $this->polldaddy_clients[$api_key];
- }
- require_once WP_POLLDADDY__POLLDADDY_CLIENT_PATH;
- $this->polldaddy_clients[$api_key] = $this->config_client( new $this->polldaddy_client_class( $api_key, $userCode ) );
- return $this->polldaddy_clients[$api_key];
- }
-
- function config_client( $client ){
- return $client;
- }
-
- function admin_menu() {
- if ( !defined( 'WP_POLLDADDY__PARTNERGUID' ) ) {
- $guid = get_option( 'polldaddy_api_key' );
- if ( !$guid || !is_string( $guid ) )
- $guid = false;
- define( 'WP_POLLDADDY__PARTNERGUID', $guid );
- }
-
- if ( !WP_POLLDADDY__PARTNERGUID ) {
- if ( function_exists( 'add_object_page' ) ) // WP 2.7+
- $hook = add_object_page( __( 'Ratings', 'polldaddy' ), __( 'Ratings', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'api_key_page' ), "{$this->base_url}polldaddy.png" );
- else
- $hook = add_management_page( __( 'Ratings', 'polldaddy' ), __( 'Ratings', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'api_key_page' ) );
-
- add_action( "load-$hook", array( &$this, 'api_key_page_load' ) );
-
- if ( function_exists( 'add_object_page' ) ) // WP 2.7+
- $hook = add_object_page( __( 'Polls', 'polldaddy' ), __( 'Polls', 'polldaddy' ), 'edit_posts', 'polls', array( &$this, 'api_key_page' ), "{$this->base_url}polldaddy.png" );
- else
- $hook = add_management_page( __( 'Polls', 'polldaddy' ), __( 'Polls', 'polldaddy' ), 'edit_posts', 'polls', array( &$this, 'api_key_page' ) );
-
- add_action( "load-$hook", array( &$this, 'api_key_page_load' ) );
- if ( ( empty( $_GET['page'] ) || 'polls' != $_GET['page'] ) && ( empty( $_GET['page'] ) || 'ratings' != $_GET['page'] ) )
- 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>";' ) );
- return false;
- }
-
- if ( function_exists( 'add_object_page' ) ) // WP 2.7+
- $hook = add_object_page( __( 'Ratings', 'polldaddy' ), __( 'Ratings', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'management_page' ), "{$this->base_url}polldaddy.png" );
- else
- $hook = add_management_page( __( 'Ratings', 'polldaddy' ), __( 'Ratings', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'management_page' ) );
-
- add_action( "load-$hook", array( &$this, 'management_page_load' ) );
-
- if ( function_exists( 'add_object_page' ) ) // WP 2.7+
- $hook = add_object_page( __( 'Polls', 'polldaddy' ), __( 'Polls', 'polldaddy' ), 'edit_posts', 'polls', array( &$this, 'management_page' ), "{$this->base_url}polldaddy.png" );
- else
- $hook = add_management_page( __( 'Polls', 'polldaddy' ), __( 'Polls', 'polldaddy' ), 'edit_posts', 'polls', array( &$this, 'management_page' ) );
-
- add_action( "load-$hook", array( &$this, 'management_page_load' ) );
-
- if ( $this->is_admin ) {
- add_submenu_page( 'ratings', __( 'Ratings – Settings', 'polldaddy' ), __( 'Settings', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'management_page' ) );
- add_submenu_page( 'ratings', __( 'Ratings – Reports', 'polldaddy' ), __( 'Reports', 'polldaddy' ), 'edit_posts', 'ratings&action=reports', array( &$this, 'management_page' ) );
- }
- else{
- add_submenu_page( 'ratings', __( 'Ratings – Reports', 'polldaddy' ), __( 'Reports', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'management_page' ) );
- }
-
- add_submenu_page( 'polls', __( 'Polls', 'polldaddy' ), __( 'Edit', 'polldaddy' ), 'edit_posts', 'polls', array( &$this, 'management_page' ) );
-
- if ( $this->is_author ) {
- add_submenu_page( 'polls', __( 'Add New Poll', 'polldaddy' ), __( 'Add New', 'polldaddy' ), 'edit_posts', 'polls&action=create-poll', array( &$this, 'management_page' ) );
- add_submenu_page( 'polls', __( 'Custom Styles', 'polldaddy' ), __( 'Custom Styles', 'polldaddy' ), 'edit_posts', 'polls&action=list-styles', array( &$this, 'management_page' ) );
- add_submenu_page( 'polls', __( 'Options', 'polldaddy' ), __( 'Options', 'polldaddy' ), 'edit_posts', 'polls&action=options', array( &$this, 'management_page' ) );
- }
-
- add_action( 'media_buttons', array( &$this, 'media_buttons' ) );
- }
-
- function api_key_page_load() {
- if ( 'post' != strtolower( $_SERVER['REQUEST_METHOD'] ) || empty( $_POST['action'] ) || 'account' != $_POST['action'] )
- return false;
-
- check_admin_referer( 'polldaddy-account' );
-
- $polldaddy_email = stripslashes( $_POST['polldaddy_email'] );
- $polldaddy_password = stripslashes( $_POST['polldaddy_password'] );
-
- if ( !$polldaddy_email )
- $this->errors->add( 'polldaddy_email', __( 'Email address required', 'polldaddy' ) );
-
- if ( !$polldaddy_password )
- $this->errors->add( 'polldaddy_password', __( 'Password required', 'polldaddy' ) );
-
- if ( $this->errors->get_error_codes() )
- return false;
-
- $details = array(
- 'uName' => get_bloginfo( 'name' ),
- 'uEmail' => $polldaddy_email,
- 'uPass' => $polldaddy_password,
- 'partner_userid' => $this->id
- );
- if ( function_exists( 'wp_remote_post' ) ) { // WP 2.7+
- $polldaddy_api_key = wp_remote_post( $this->scheme . '://api.polldaddy.com/key.php', array(
- 'body' => $details
- ) );
- if ( is_wp_error( $polldaddy_api_key ) ) {
- $this->errors = $polldaddy_api_key;
- return false;
- }
- $polldaddy_api_key = wp_remote_retrieve_body( $polldaddy_api_key );
- } else {
- $fp = fsockopen(
- 'api.polldaddy.com',
- 80,
- $err_num,
- $err_str,
- 3
- );
-
- if ( !$fp ) {
- $this->errors->add( 'connect', __( "Can't connect to PollDaddy.com", 'polldaddy' ) );
- return false;
- }
-
- if ( function_exists( 'stream_set_timeout' ) )
- stream_set_timeout( $fp, 3 );
-
- global $wp_version;
-
- $request_body = http_build_query( $details, null, '&' );
-
- $request = "POST /key.php HTTP/1.0\r\n";
- $request .= "Host: api.polldaddy.com\r\n";
- $request .= "User-agent: WordPress/$wp_version\r\n";
- $request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option('blog_charset') . "\r\n";
- $request .= 'Content-Length: ' . strlen( $request_body ) . "\r\n";
-
- fwrite( $fp, "$request\r\n$request_body" );
-
- $response = '';
- while ( !feof( $fp ) )
- $response .= fread( $fp, 4096 );
- fclose( $fp );
- list($headers, $polldaddy_api_key) = explode( "\r\n\r\n", $response, 2 );
- }
-
- if ( !$polldaddy_api_key ) {
- $this->errors->add( 'polldaddy_password', __( 'Invalid Account', 'polldaddy' ) );
- return false;
- }
-
- update_option( 'polldaddy_api_key', $polldaddy_api_key );
-
- $polldaddy = $this->get_client( $polldaddy_api_key );
- $polldaddy->reset();
- if ( !$polldaddy->get_usercode( $this->id ) ) {
- $this->parse_errors( $polldaddy );
- $this->errors->add( 'GetUserCode', __( 'Account could not be accessed. Are your email address and password correct?', 'polldaddy' ) );
- return false;
- }
-
- return true;
- }
-
- function parse_errors( &$polldaddy ) {
- if ( $polldaddy->errors )
- foreach ( $polldaddy->errors as $code => $error )
- $this->errors->add( $code, $error );
- if ( isset( $this->errors->errors[4] ) ) {
- $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'] ) ) ) );
- $this->errors->add_data( true, 4 );
- }
- }
-
- function print_errors() {
- if ( !$error_codes = $this->errors->get_error_codes() )
- return;
- ?>
-
- <div class="error">
-
- <?php
-
- foreach ( $error_codes as $error_code ) :
- foreach ( $this->errors->get_error_messages( $error_code ) as $error_message ) :
- ?>
-
- <p><?php echo $this->errors->get_error_data( $error_code ) ? $error_message : wp_specialchars( $error_message ); ?></p>
-
- <?php
- endforeach;
- endforeach;
-
- $this->errors = new WP_Error;
- ?>
-
- </div>
- <br class="clear" />
-
- <?php
- }
-
- function api_key_page() {
- $this->print_errors();
- ?>
-
- <div class="wrap">
-
- <h2><?php _e( 'PollDaddy Account', 'polldaddy' ); ?></h2>
-
- <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>
-
- <form action="" method="post">
- <table class="form-table">
- <tbody>
- <tr class="form-field form-required">
- <th valign="top" scope="row">
- <label for="polldaddy-email"><?php _e( 'PollDaddy Email Address', 'polldaddy' ); ?></label>
- </th>
- <td>
- <input type="text" name="polldaddy_email" id="polldaddy-email" aria-required="true" size="40" />
- </td>
- </tr>
- <tr class="form-field form-required">
- <th valign="top" scope="row">
- <label for="polldaddy-password"><?php _e( 'PollDaddy Password', 'polldaddy' ); ?></label>
- </th>
- <td>
- <input type="password" name="polldaddy_password" id="polldaddy-password" aria-required="true" size="40" />
- </td>
- </tr>
- </tbody>
- </table>
- <p class="submit">
- <?php wp_nonce_field( 'polldaddy-account' ); ?>
- <input type="hidden" name="action" value="account" />
- <input type="hidden" name="account" value="import" />
- <input type="submit" value="<?php echo attribute_escape( __( 'Submit', 'polldaddy' ) ); ?>" />
- </p>
- </form>
- </div>
-
- <?php
- }
-
- function media_buttons() {
- $title = __( 'Add Poll', 'polldaddy' );
- echo "<a href='admin.php?page=polls&iframe&TB_iframe=true' onclick='return false;' id='add_poll' class='thickbox' title='$title'><img src='{$this->base_url}polldaddy.png' alt='$title' /></a>";
- }
-
- function set_api_user_code(){
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID );
- $polldaddy->reset();
-
- if ( empty( $this->user_code ) ){
- $this->user_code = $polldaddy->get_usercode( $this->id );
- }
- }
-
- function management_page_load() {
- wp_reset_vars( array( 'page', 'action', 'poll', 'style', 'rating', 'id' ) );
- global $plugin_page, $page, $action, $poll, $style, $rating, $id, $wp_locale;
-
- $this->set_api_user_code();
-
- if ( empty( $this->user_code ) && $page == 'polls' ){
- $action = 'signup';
- }
-
- require_once WP_POLLDADDY__POLLDADDY_CLIENT_PATH;
-
- wp_enqueue_script( 'polls', "{$this->base_url}polldaddy.js", array( 'jquery', 'jquery-ui-sortable' ), $this->version );
- wp_enqueue_script( 'polls-common', "{$this->base_url}common.js", array(), $this->version );
-
- if( $page == 'polls' ) {
- 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
- $action = '';
- }
-
- switch ( $action ) :
- case 'edit' :
- case 'edit-poll' :
- case 'create-poll' :
- wp_enqueue_script( 'polls-style', "http://i.polldaddy.com/js/poll-style-picker.js", array(), $this->version );
-
- if ( $action == 'create-poll' )
- $plugin_page = 'polls&action=create-poll';
-
- break;
- case 'edit-style' :
- case 'create-style' :
- wp_enqueue_script( 'polls-style', "http://i.polldaddy.com/js/style-editor.js", array(), $this->version );
- wp_enqueue_script( 'polls-style-color', "http://i.polldaddy.com/js/jquery/jscolor.js", array(), $this->version );
- wp_enqueue_style( 'polls', "{$this->base_url}style-editor.css", array(), $this->version );
- $plugin_page = 'polls&action=list-styles';
- break;
- case 'list-styles' :
- $plugin_page = 'polls&action=list-styles';
- break;
- case 'options' :
- case 'update-options' :
- case 'import-account' :
- $plugin_page = 'polls&action=options';
- break;
- endswitch;
- } elseif( $page == 'ratings' ) {
- if ( !$this->is_admin && !in_array( $action, array( 'reports', 'delete' ) ) ) {//check user privileges has access to action
- $action = 'reports';
- }
- switch ( $action ) :
- case 'delete' :
- case 'reports' :
- $plugin_page = 'ratings&action=reports';
- break;
- default :
- wp_enqueue_script( 'rating-text-color', "http://i.polldaddy.com/js/jquery/jscolor.js", array(), $this->version );
- wp_enqueue_script( 'ratings', 'http://i.polldaddy.com/ratings/rating.js', array(), $this->version );
- wp_localize_script( 'polls-common', 'adminRatingsL10n', array(
- 'star_colors' => __( 'Star Colors', 'polldaddy' ), 'star_size' => __( 'Star Size', 'polldaddy' ),
- 'nero_type' => __( 'Nero Type', 'polldaddy' ), 'nero_size' => __( 'Nero Size', 'polldaddy' ), ) );
- endswitch;
- }
-
- wp_enqueue_script( 'admin-forms' );
- add_thickbox();
-
- wp_enqueue_style( 'polls', "{$this->base_url}polldaddy.css", array( 'global', 'wp-admin' ), $this->version );
- if ( isset($wp_locale->text_direction) && 'rtl' == $wp_locale->text_direction )
- wp_enqueue_style( 'polls-rtl', "{$this->base_url}polldaddy-rtl.css", array( 'global', 'wp-admin' ), $this->version );
- add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) );
-
- add_action( 'admin_notices', array( &$this, 'management_page_notices' ) );
-
- $query_args = array();
- $args = array();
-
- $allowedtags = array(
- 'a' => array(
- 'href' => array (),
- 'title' => array (),
- 'target' => array ()),
- 'img' => array(
- 'alt' => array (),
- 'align' => array (),
- 'border' => array (),
- 'class' => array (),
- 'height' => array (),
- 'hspace' => array (),
- 'longdesc' => array (),
- 'vspace' => array (),
- 'src' => array (),
- 'width' => array ()),
- 'abbr' => array(
- 'title' => array ()),
- 'acronym' => array(
- 'title' => array ()),
- 'b' => array(),
- 'blockquote' => array(
- 'cite' => array ()),
- 'cite' => array (),
- 'em' => array (),
- 'i' => array (),
- 'q' => array(
- 'cite' => array ()),
- 'strike' => array(),
- 'strong' => array()
- );
-
- $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
-
- if( $page == 'polls' ) {
- switch ( $action ) :
- case 'signup' : // sign up for first time
- case 'account' : // reauthenticate
- case 'import-account' : // reauthenticate
- if ( !$is_POST )
- return;
-
- check_admin_referer( 'polldaddy-account' );
-
- if ( $new_args = $this->management_page_load_signup() )
- $query_args = array_merge( $query_args, $new_args );
- if ( $this->errors->get_error_codes() )
- return false;
-
- $query_args['message'] = 'imported-account';
-
- wp_reset_vars( array( 'action' ) );
- if ( !empty( $_GET['reaction'] ) )
- $query_args['action'] = $_GET['reaction'];
- elseif ( !empty( $_GET['action'] ) && 'account' == $_GET['action'] )
- $query_args['action'] = $_GET['action'];
- else
- $query_args['action'] = false;
- break;
-
- case 'delete' :
- if ( empty( $poll ) )
- return;
-
- if ( is_array( $poll ) )
- check_admin_referer( 'action-poll_bulk' );
- else
- check_admin_referer( "delete-poll_$poll" );
-
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
-
- foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
- $polldaddy->reset();
- $poll_object = $polldaddy->get_poll( $poll );
-
- if ( !$this->can_edit( $poll_object ) ) {
- $this->errors->add( 'permission', __( 'You are not allowed to delete this poll.', 'polldaddy' ) );
- return false;
- }
-
- // Send Poll Author credentials
- if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
- $polldaddy->reset();
- if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
- $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
- }
- $polldaddy->userCode = $userCode;
- }
-
- $polldaddy->reset();
- $polldaddy->delete_poll( $poll_id );
- }
-
- $query_args['message'] = 'deleted';
- $query_args['deleted'] = count( (array) $poll );
- break;
- case 'open' :
- if ( empty( $poll ) )
- return;
-
- if ( is_array( $poll ) )
- check_admin_referer( 'action-poll_bulk' );
- else
- check_admin_referer( "open-poll_$poll" );
-
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
-
- foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
- $polldaddy->reset();
- $poll_object = $polldaddy->get_poll( $poll );
-
- if ( !$this->can_edit( $poll_object ) ) {
- $this->errors->add( 'permission', __( 'You are not allowed to open this poll.', 'polldaddy' ) );
- return false;
- }
-
- // Send Poll Author credentials
- if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
- $polldaddy->reset();
- if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
- $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
- }
- $polldaddy->userCode = $userCode;
- }
-
- $polldaddy->reset();
- $polldaddy->open_poll( $poll_id );
- }
-
- $query_args['message'] = 'opened';
- $query_args['opened'] = count( (array) $poll );
- break;
- case 'close' :
- if ( empty( $poll ) )
- return;
-
- if ( is_array( $poll ) )
- check_admin_referer( 'action-poll_bulk' );
- else
- check_admin_referer( "close-poll_$poll" );
-
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
-
- foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
- $polldaddy->reset();
- $poll_object = $polldaddy->get_poll( $poll );
-
- if ( !$this->can_edit( $poll_object ) ) {
- $this->errors->add( 'permission', __( 'You are not allowed to close this poll.', 'polldaddy' ) );
- return false;
- }
-
- // Send Poll Author credentials
- if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
- $polldaddy->reset();
- if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
- $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
- }
- $polldaddy->userCode = $userCode;
- }
-
- $polldaddy->reset();
- $polldaddy->close_poll( $poll_id );
- }
-
- $query_args['message'] = 'closed';
- $query_args['closed'] = count( (array) $poll );
- break;
- case 'edit-poll' : // TODO: use polldaddy_poll
- if ( !$is_POST || !$poll = (int) $poll )
- return;
-
- check_admin_referer( "edit-poll_$poll" );
-
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
- $polldaddy->reset();
-
- $poll_object = $polldaddy->get_poll( $poll );
- $this->parse_errors( $polldaddy );
-
- if ( !$this->can_edit( $poll_object ) ) {
- $this->errors->add( 'permission', __( 'You are not allowed to edit this poll.', 'polldaddy' ) );
- return false;
- }
-
- // Send Poll Author credentials
-
- if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
- $polldaddy->reset();
- if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
- $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
- }
- $this->parse_errors( $polldaddy );
- $polldaddy->userCode = $userCode;
- }
-
- if ( !$poll_object )
- $this->errors->add( 'GetPoll', __( 'Poll not found', 'polldaddy' ) );
-
- if ( $this->errors->get_error_codes() )
- return false;
-
- $poll_data = get_object_vars( $poll_object );
- foreach ( $poll_data as $key => $value )
- if ( '_' === $key[0] )
- unset( $poll_data[$key] );
-
- foreach ( array( 'multipleChoice', 'randomiseAnswers', 'otherAnswer', 'sharing' ) as $option ) {
- if ( isset( $_POST[$option] ) && $_POST[$option] )
- $poll_data[$option] = 'yes';
- else
- $poll_data[$option] = 'no';
- }
-
- $blocks = array( 'off', 'cookie', 'cookieip' );
- if ( isset( $_POST['blockRepeatVotersType'] ) && in_array( $_POST['blockRepeatVotersType'], $blocks ) )
- $poll_data['blockRepeatVotersType'] = $_POST['blockRepeatVotersType'];
-
- $results = array( 'show', 'percent', 'hide' );
- if ( isset( $_POST['resultsType'] ) && in_array( $_POST['resultsType'], $results ) )
- $poll_data['resultsType'] = $_POST['resultsType'];
- $poll_data['question'] = stripslashes( $_POST['question'] );
-
- if ( empty( $_POST['answer'] ) || !is_array( $_POST['answer'] ) )
- $this->errors->add( 'answer', __( 'Invalid answers', 'polldaddy' ) );
-
- $answers = array();
- foreach ( $_POST['answer'] as $answer_id => $answer ) {
- if ( !$answer = trim( stripslashes( $answer ) ) )
- continue;
-
- $args['text'] = wp_kses( $answer, $allowedtags );
-
- if ( is_numeric( $answer_id ) )
- $answers[] = polldaddy_poll_answer( $args, $answer_id );
- else
- $answers[] = polldaddy_poll_answer( $args );
- }
-
- if ( 2 > count( $answers ) )
- $this->errors->add( 'answer', __( 'You must include at least 2 answers', 'polldaddy' ) );
-
- if ( $this->errors->get_error_codes() )
- return false;
-
- $poll_data['answers'] = $answers;
-
- $poll_data['question'] = wp_kses( $poll_data['question'], $allowedtags );
-
- if ( isset ( $_POST['styleID'] ) ){
- if ( $_POST['styleID'] == 'x' ){
- $this->errors->add( 'UpdatePoll', __( 'Please choose a poll style', 'polldaddy' ) );
- return false;
- }
- }
- $poll_data['styleID'] = (int) $_POST['styleID'];
- $poll_data['choices'] = (int) $_POST['choices'];
-
- if ( $poll_data['blockRepeatVotersType'] == 'cookie' ){
- if( isset( $_POST['cookieip_expiration'] ) )
- $poll_data['blockExpiration'] = (int) $_POST['cookieip_expiration'];
- } elseif ( $poll_data['blockRepeatVotersType'] == 'cookieip' ){
- if( isset( $_POST['cookieip_expiration'] ) )
- $poll_data['blockExpiration'] = (int) $_POST['cookieip_expiration'];
- }
-
- $polldaddy->reset();
-
- $update_response = $polldaddy->update_poll( $poll, $poll_data );
-
- $this->parse_errors( $polldaddy );
-
- if ( !$update_response )
- $this->errors->add( 'UpdatePoll', __( 'Poll could not be updated', 'polldaddy' ) );
-
- if ( $this->errors->get_error_codes() )
- return false;
-
- $query_args['message'] = 'updated';
- if ( isset($_POST['iframe']) )
- $query_args['iframe'] = '';
- break;
- case 'create-poll' :
- if ( !$is_POST )
- return;
-
- check_admin_referer( 'create-poll' );
-
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
- $polldaddy->reset();
-
- $answers = array();
- foreach ( $_POST['answer'] as $answer ){
- if ( !$answer = trim( stripslashes( $answer ) ) )
- continue;
-
- $args['text'] = wp_kses( $answer, $allowedtags );
-
- $answers[] = polldaddy_poll_answer( $args );
- }
-
- if ( !$answers )
- return false;
-
- $poll_data = _polldaddy_poll_defaults();
-
- foreach ( array( 'multipleChoice', 'randomiseAnswers', 'otherAnswer', 'sharing' ) as $option ) {
- if ( isset( $_POST[$option] ) && $_POST[$option] )
- $poll_data[$option] = 'yes';
- else
- $poll_data[$option] = 'no';
- }
-
- $blocks = array( 'off', 'cookie', 'cookieip' );
- if ( isset( $_POST['blockRepeatVotersType'] ) && in_array( $_POST['blockRepeatVotersType'], $blocks ) )
- $poll_data['blockRepeatVotersType'] = $_POST['blockRepeatVotersType'];
-
- $results = array( 'show', 'percent', 'hide' );
- if ( isset( $_POST['resultsType'] ) && in_array( $_POST['resultsType'], $results ) )
- $poll_data['resultsType'] = $_POST['resultsType'];
-
- $poll_data['answers'] = $answers;
-
- $poll_data['question'] = stripslashes( $_POST['question'] );
- $poll_data['question'] = wp_kses( $poll_data['question'], $allowedtags );
-
- if ( isset ( $_POST['styleID'] ) ){
- if ( $_POST['styleID'] == 'x' ){
- $this->errors->add( 'UpdatePoll', __( 'Please choose a poll style', 'polldaddy' ) );
- return false;
- }
- }
- $poll_data['styleID'] = (int) $_POST['styleID'];
- $poll_data['choices'] = (int) $_POST['choices'];
-
- if ( $poll_data['blockRepeatVotersType'] == 'cookie' ){
- if( isset( $_POST['cookieip_expiration'] ) )
- $poll_data['blockExpiration'] = (int) $_POST['cookieip_expiration'];
- } elseif ( $poll_data['blockRepeatVotersType'] == 'cookieip' ){
- if( isset( $_POST['cookieip_expiration'] ) )
- $poll_data['blockExpiration'] = (int) $_POST['cookieip_expiration'];
- }
-
- $poll = $polldaddy->create_poll( $poll_data );
- $this->parse_errors( $polldaddy );
-
- if ( !$poll || empty( $poll->_id ) )
- $this->errors->add( 'CreatePoll', __( 'Poll could not be created', 'polldaddy' ) );
-
- if ( $this->errors->get_error_codes() )
- return false;
-
- $query_args['message'] = 'created';
- $query_args['action'] = 'edit-poll';
- $query_args['poll'] = $poll->_id;
- if ( isset($_POST['iframe']) )
- $query_args['iframe'] = '';
- break;
- case 'delete-style' :
- if ( empty( $style ) )
- return;
-
- if ( is_array( $style ) )
- check_admin_referer( 'action-style_bulk' );
- else
- check_admin_referer( "delete-style_$style" );
-
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
-
- foreach ( (array) $_REQUEST['style'] as $style_id ) {
- $polldaddy->reset();
- $polldaddy->delete_style( $style_id );
- }
-
- $query_args['message'] = 'deleted-style';
- $query_args['deleted'] = count( (array) $style );
- break;
- case 'edit-style' :
- if ( !$is_POST || !$style = (int) $style )
- return;
-
- check_admin_referer( "edit-style$style" );
-
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
- $polldaddy->reset();
-
- $style_data = _polldaddy_style_defaults();
-
- if ( isset($_POST['style-title'] ) )
- $style_data['title'] = stripslashes( trim ( (string) $_POST['style-title'] ) );
-
- if ( isset($_POST['CSSXML'] ) )
- $style_data['css'] = urlencode( stripslashes( trim ( (string) $_POST['CSSXML'] ) ) );
-
- if ( isset($_REQUEST['updatePollCheck'] ) && $_REQUEST['updatePollCheck'] == 'on' )
- $style_data['retro'] = 1;
-
- $update_response = $polldaddy->update_style( $style, $style_data );
-
- $this->parse_errors( $polldaddy );
-
- if ( !$update_response )
- $this->errors->add( 'UpdateStyle', __( 'Style could not be updated', 'polldaddy' ) );
-
- if ( $this->errors->get_error_codes() )
- return false;
-
- $query_args['message'] = 'updated-style';
- if ( isset($_POST['iframe']) )
- $query_args['iframe'] = '';
- break;
- case 'create-style' :
- if ( !$is_POST )
- return;
-
- check_admin_referer( 'create-style' );
-
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
- $polldaddy->reset();
-
- $style_data = _polldaddy_style_defaults();
-
- if ( isset($_POST['style-title'] ) )
- $style_data['title'] = stripslashes( strip_tags( trim ( (string) $_POST['style-title'] ) ) );
-
- if ( isset($_POST['CSSXML'] ) )
- $style_data['css'] = urlencode( stripslashes( trim ( (string) $_POST['CSSXML'] ) ) );
-
- $style = $polldaddy->create_style( $style_data );
- $this->parse_errors( $polldaddy );
-
- if ( !$style || empty( $style->_id ) )
- $this->errors->add( 'CreateStyle', __( 'Style could not be created', 'polldaddy' ) );
-
- if ( $this->errors->get_error_codes() )
- return false;
-
- $query_args['message'] = 'created-style';
- $query_args['action'] = 'edit-style';
- $query_args['style'] = $style->_id;
- if ( isset($_POST['iframe']) )
- $query_args['iframe'] = '';
- break;
- case 'update-options' :
- if ( !$is_POST )
- return;
-
- check_admin_referer( 'polldaddy-account' );
-
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
- $polldaddy->reset();
-
- $poll_defaults = _polldaddy_poll_defaults();
-
- $user_defaults = array();
-
- foreach( array( "multipleChoice", "randomiseAnswers", "otherAnswer", "sharing", "resultsType", "styleID", "blockRepeatVotersType", "blockExpiration" ) as $option ){
- if ( isset( $poll_defaults[$option] ) && $poll_defaults[$option] )
- $user_defaults[$option] = $poll_defaults[$option];
- }
-
- foreach ( array( 'multipleChoice', 'randomiseAnswers', 'otherAnswer', 'sharing' ) as $option ) {
- if ( isset( $_POST[$option] ) && $_POST[$option] )
- $user_defaults[$option] = 'yes';
- else
- $user_defaults[$option] = 'no';
- }
-
- $results = array( 'show', 'percent', 'hide' );
- if ( isset( $_POST['resultsType'] ) && in_array( $_POST['resultsType'], $results ) )
- $user_defaults['resultsType'] = $_POST['resultsType'];
-
- if ( isset ( $_POST['styleID'] ) ){
- $user_defaults['styleID'] = (int) $_POST['styleID'];
- }
-
- $blocks = array( 'off', 'cookie', 'cookieip' );
- if ( isset( $_POST['blockRepeatVotersType'] ) && in_array( $_POST['blockRepeatVotersType'], $blocks ) )
- $user_defaults['blockRepeatVotersType'] = $_POST['blockRepeatVotersType'];
-
- if( isset( $_POST['blockExpiration'] ) )
- $user_defaults['blockExpiration'] = (int) $_POST['blockExpiration'];
-
- $polldaddy->update_poll_defaults( 0, $user_defaults );
-
- $this->parse_errors( $polldaddy );
- if ( $this->errors->get_error_codes() )
- return false;
-
- $query_args['message'] = 'updated-options';
- break;
- default :
- return;
- endswitch;
- } elseif( $page == 'ratings' ) {
-
- switch ( $action ) :
- case 'delete' :
- if ( empty( $id ) )
- return;
- if ( empty( $rating ) )
- return;
-
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
-
- if ( is_array( $rating ) ) {
- check_admin_referer( 'action-rating_bulk' );
-
- foreach( $rating as $key => $value ){
- $polldaddy->reset();
- $polldaddy->delete_rating_result( $id, $value );
- }
- } else {
- check_admin_referer( "delete-rating_$rating" );
-
- $polldaddy->delete_rating_result( $id, $rating );
- }
-
- if ( isset( $_REQUEST['filter'] ) )
- $query_args['filter'] = $_REQUEST['filter'];
- if ( isset( $_REQUEST['change-report-to'] ) )
- $query_args['change-report-to'] = $_REQUEST['change-report-to'];
- $query_args['message'] = 'deleted-rating';
- $query_args['deleted'] = count( (array) $rating );
- break;
- default :
- return;
- endswitch;
- }
-
- wp_redirect( add_query_arg( $query_args, wp_get_referer() ) );
- exit;
- }
-
- function management_page_load_signup() {
- switch ( $_POST['account'] ) :
- case 'import' :
- return $this->import_account();
- break;
- default :
- return;
- endswitch;
- }
-
- function import_account(){
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID );
- $polldaddy->reset();
- $email = trim( stripslashes( $_POST['polldaddy_email'] ) );
- $password = trim( stripslashes( $_POST['polldaddy_password'] ) );
-
- if ( !is_email( $email ) )
- $this->errors->add( 'polldaddy_email', __( 'Email address required', 'polldaddy' ) );
-
- if ( !$password )
- $this->errors->add( 'polldaddy_password', __( 'Password required', 'polldaddy' ) );
-
- if ( $this->errors->get_error_codes() )
- return false;
-
- if ( $usercode = $polldaddy->initiate( $email, $password, $this->id ) ) {
- $this->user_code = $usercode;
- } else {
- $this->parse_errors( $polldaddy );
- $this->errors->add( 'import-account', __( 'Account could not be imported. Are your email address and password correct?', 'polldaddy' ) );
- return false;
- }
- }
-
- function admin_body_class( $class ) {
- if ( isset( $_GET['iframe'] ) )
- $class .= 'poll-preview-iframe ';
- if ( isset( $_GET['TB_iframe'] ) )
- $class .= 'poll-preview-iframe-editor ';
- return $class;
- }
-
- function management_page_notices( $message = false ) {
- switch ( (string) @$_GET['message'] ) :
- case 'deleted' :
- $deleted = (int) $_GET['deleted'];
- if ( 1 == $deleted )
- $message = __( 'Poll deleted.', 'polldaddy' );
- else
- $message = sprintf( __ngettext( '%s Poll Deleted.', '%s Polls Deleted.', $deleted ), number_format_i18n( $deleted ) );
- break;
- case 'opened' :
- $opened = (int) $_GET['opened'];
- if ( 1 == $opened )
- $message = __( 'Poll opened.', 'polldaddy' );
- else
- $message = sprintf( __ngettext( '%s Poll Opened.', '%s Polls Opened.', $opened ), number_format_i18n( $opened ) );
- break;
- case 'closed' :
- $closed = (int) $_GET['closed'];
- if ( 1 == $closed )
- $message = __( 'Poll closed.', 'polldaddy' );
- else
- $message = sprintf( __ngettext( '%s Poll Closed.', '%s Polls Closed.', $closed ), number_format_i18n( $closed ) );
- break;
- case 'updated' :
- $message = __( 'Poll updated.', 'polldaddy' );
- break;
- case 'created' :
- $message = __( 'Poll created.', 'polldaddy' );
- if ( isset( $_GET['iframe'] ) )
- $message .= ' <input type="button" class="button polldaddy-send-to-editor" value="' . attribute_escape( __( 'Send to Editor', 'polldaddy' ) ) . '" />';
- break;
- case 'updated-style' :
- $message = __( 'Custom Style updated.', 'polldaddy' );
- break;
- case 'created-style' :
- $message = __( 'Custom Style created.', 'polldaddy' );
- break;
- case 'deleted-style' :
- $deleted = (int) $_GET['deleted'];
- if ( 1 == $deleted )
- $message = __( 'Custom Style deleted.', 'polldaddy' );
- else
- $message = sprintf( __ngettext( '%s Style Deleted.', '%s Custom Styles Deleted.', $deleted ), number_format_i18n( $deleted ) );
- break;
- case 'imported-account' :
- $message = __( 'Account Imported.', 'polldaddy' );
- break;
- case 'updated-options' :
- $message = __( 'Options Updated.', 'polldaddy' );
- break;
- case 'deleted-rating' :
- $deleted = (int) $_GET['deleted'];
- if ( 1 == $deleted )
- $message = __( 'Rating deleted.', 'polldaddy' );
- else
- $message = sprintf( __ngettext( '%s Rating Deleted.', '%s Ratings Deleted.', $deleted ), number_format_i18n( $deleted ) );
- break;
- endswitch;
-
- $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
-
- if ( $is_POST ) {
- switch ( $GLOBALS['action'] ) :
- case 'create-poll' :
- $message = __( 'Error: An error has occurred; Poll not created.', 'polldaddy' );
- break;
- case 'edit-poll' :
- $message = __( 'Error: An error has occurred; Poll not updated.', 'polldaddy' );
- break;
- case 'account' :
- if ( 'import' == $_POST['account'] )
- $message = __( 'Error: An error has occurred; Account could not be imported. Perhaps your email address or password is incorrect?', 'polldaddy' );
- else
- $message = __( 'Error: An error has occurred; Account could not be created.', 'polldaddy' );
- break;
- endswitch;
- }
-
- if ( !$message )
- return;
- ?>
- <div class='updated'><p><?php echo $message; ?></p></div>
- <?php
- $this->print_errors();
- }
-
- function management_page() {
- global $page, $action, $poll, $style, $rating;
- $poll = (int) $poll;
- $style = (int) $style;
- $rating = wp_specialchars( $rating );
- ?>
-
- <div class="wrap" id="manage-polls">
-
- <?php
- if( $page == 'polls' ) {
- 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
- $action = '';
- }
- switch ( $action ) :
- case 'signup' :
- case 'account' :
- $this->signup();
- break;
- case 'preview' :
- ?>
-
- <h2 id="preview-header"><?php
- if( $this->is_author )
- printf( __( 'Poll Preview (<a href="%s">Edit Poll</a>, <a href="%s">List Polls</a>)', 'polldaddy' ),
- clean_url( add_query_arg( array( 'action' => 'edit', 'poll' => $poll, 'message' => false ) ) ),
- clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ));
- else
- printf( __( 'Poll Preview (<a href="%s">List Polls</a>)', 'polldaddy'), clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ) ); ?></h2>
-
- <?php
- echo do_shortcode( "[polldaddy poll=$poll cb=1]" );
- break;
- case 'results' :
- ?>
-
- <h2><?php
- if( $this->is_author )
- printf( __( 'Poll Results (<a href="%s">Edit Poll</a>)', 'polldaddy' ), clean_url( add_query_arg( array( 'action' => 'edit', 'poll' => $poll, 'message' => false ) ) ) );
- else
- printf( __( 'Poll Results (<a href="%s">List Polls</a>)', 'polldaddy'), clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ) ); ?></h2>
-
- <?php
- $this->poll_results_page( $poll );
- break;
- case 'edit' :
- case 'edit-poll' :
- ?>
-
- <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>
-
- <?php
-
- $this->poll_edit_form( $poll );
- break;
- case 'create-poll' :
- ?>
-
- <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>
-
- <?php
- $this->poll_edit_form();
- break;
- case 'list-styles' :
- ?>
-
- <h2><?php
- if( $this->is_author )
- printf( __('Custom Styles (<a href="%s">Add New</a>)', 'polldaddy'), clean_url( add_query_arg( array( 'action' => 'create-style', 'poll' => false, 'message' => false ) ) ) );
- else
- _e('Custom Styles', 'polldaddy'); ?></h2>
-
- <?php
- $this->styles_table();
- break;
- case 'edit-style' :
- ?>
-
- <h2><?php printf( __('Edit Style (<a href="%s">List Styles</a>)', 'polldaddy'), clean_url( add_query_arg( array( 'action' => 'list-styles', 'style' => false, 'message' => false, 'preload' => false ) ) ) ); ?></h2>
-
- <?php
-
- $this->style_edit_form( $style );
- break;
- case 'create-style' :
- ?>
-
- <h2><?php printf( __('Create Style (<a href="%s">List Styles</a>)', 'polldaddy'), clean_url( add_query_arg( array( 'action' => 'list-styles', 'style' => false, 'message' => false, 'preload' => false ) ) ) ); ?></h2>
-
- <?php
- $this->style_edit_form();
- break;
- case 'options' :
- case 'import-account' :
- case 'update-options' :
- $this->plugin_options();
- break;
- default :
-
- ?>
-
- <h2 id="poll-list-header"><?php
- if( $this->is_author )
- printf( __( 'Polls (<a href="%s">Add New</a>)', 'polldaddy' ), clean_url( add_query_arg( array('action' => 'create-poll','poll' => false,'message' => false) ) ) );
- else
- _e( 'Polls', 'polldaddy'); ?></h2>
-
- <?php
- $this->polls_table( isset( $_GET['view'] ) && 'user' == $_GET['view'] ? 'user' : 'blog' );
- endswitch;
- } elseif( $page == 'ratings' ) {
- if ( !$this->is_admin && !in_array( $action, array( 'delete', 'reports' ) ) ) {//check user privileges has access to action
- $action = 'reports';
- }
-
- switch ( $action ) :
- case 'delete' :
- case 'reports' :
- $this->rating_reports();
- break;
- case 'update-rating' :
- $this->update_rating();
- $this->rating_settings( $action );
- break;
- default :
- $this->rating_settings();
- endswitch;
- }
- ?>
-
- </div>
-
- <?php
-
- }
-
- function polls_table( $view = 'blog' ) {
- $page = 1;
- if ( isset( $_GET['paged'] ) )
- $page = absint($_GET['paged']);
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
- $polldaddy->reset();
-
- if( !$this->is_author )
- $view = '';
-
- if ( 'user' == $view )
- $polls_object = $polldaddy->get_polls( ( $page - 1 ) * 10 + 1, $page * 10 );
- else
- $polls_object = $polldaddy->get_polls_by_parent_id( ( $page - 1 ) * 10 + 1, $page * 10 );
- $this->parse_errors( $polldaddy );
- $this->print_errors();
- $polls = & $polls_object->poll;
- if( isset( $polls_object->_total ) )
- $total_polls = $polls_object->_total;
- else
- $total_polls = count( $polls );
- $class = '';
-
- $page_links = paginate_links( array(
- 'base' => add_query_arg( 'paged', '%#%' ),
- 'format' => '',
- 'total' => ceil( $total_polls / 10 ),
- 'current' => $page
- ) );
-
- if( $this->is_author ){ ?>
- <ul class="subsubsub">
- <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>
- <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>
- </ul>
- <?php } ?>
- <form method="post" action="">
- <?php if( $this->is_author ){ ?>
- <div class="tablenav">
- <div class="alignleft">
- <select name="action">
- <option selected="selected" value=""><?php _e( 'Actions', 'polldaddy' ); ?></option>
- <option value="delete"><?php _e( 'Delete', 'polldaddy' ); ?></option>
- <option value="close"><?php _e( 'Close', 'polldaddy' ); ?></option>
- <option value="open"><?php _e( 'Open', 'polldaddy' ); ?></option>
- </select>
- <input class="button-secondary action" type="submit" name="doaction" value="<?php _e( 'Apply', 'polldaddy' ); ?>" />
- <?php wp_nonce_field( 'action-poll_bulk' ); ?>
- </div>
- <div class="tablenav-pages"><?php echo $page_links; ?></div>
- </div>
- <br class="clear" />
- <?php } ?>
- <table class="widefat">
- <thead>
- <tr>
- <th id="cb" class="manage-column column-cb check-column" scope="col" /><?php if( $this->is_author ){ ?><input type="checkbox" /><?php } ?></th>
- <th id="title" class="manage-column column-title" scope="col"><?php _e( 'Poll', 'polldaddy' ); ?></th>
- <th id="votes" class="manage-column column-vote num" scope="col"><?php _e( 'Votes', 'polldaddy' ); ?></th>
- <th id="date" class="manage-column column-date" scope="col"><?php _e( 'Created', 'polldaddy' ); ?></th>
- </tr>
- </thead>
- <tbody>
-
- <?php
- if ( $polls ) :
- foreach ( $polls as $poll ) :
- $poll_id = (int) $poll->_id;
-
- $poll->___content = trim( strip_tags( $poll->___content ) );
- if( strlen( $poll->___content ) == 0 ){
- $poll->___content = '-- empty HTML tag --';
- }
-
- $poll_closed = (int) $poll->_closed;
-
- if ( $this->is_author and $this->can_edit( $poll ) ) {
- $edit_link = clean_url( add_query_arg( array( 'action' => 'edit', 'poll' => $poll_id, 'message' => false ) ) );
- $delete_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete', 'poll' => $poll_id, 'message' => false ) ), "delete-poll_$poll_id" ) );
- $open_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'open', 'poll' => $poll_id, 'message' => false ) ), "open-poll_$poll_id" ) );
- $close_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'close', 'poll' => $poll_id, 'message' => false ) ), "close-poll_$poll_id" ) );
- }
- else {
- $edit_link = false;
- $delete_link = false;
- $open_link = false;
- $close_link = false;
- }
-
- $class = $class ? '' : ' class="alternate"';
- $results_link = clean_url( add_query_arg( array( 'action' => 'results', 'poll' => $poll_id, 'message' => false ) ) );
- $preview_link = clean_url( add_query_arg( array( 'action' => 'preview', 'poll' => $poll_id, 'message' => false ) ) ); //, 'iframe' => '', 'TB_iframe' => 'true' ) ) );
- list($poll_time) = explode( '.', $poll->_created );
- $poll_time = strtotime( $poll_time );
- ?>
- <tr<?php echo $class; ?>>
- <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>
- <td class="post-title column-title">
- <?php if ( $edit_link ) { ?>
- <strong><a class="row-title" href="<?php echo $edit_link; ?>"><?php echo wp_specialchars( $poll->___content ); ?></a></strong>
- <div class="row-actions">
- <span class="edit"><a href="<?php echo $edit_link; ?>"><?php _e( 'Edit', 'polldaddy' ); ?></a> | </span>
- <?php } else { ?>
- <strong><?php echo wp_specialchars( $poll->___content ); ?></strong>
- <div class="row-actions">
- <?php } ?>
- <span class="results"><a href="<?php echo $results_link; ?>"><?php _e( 'Results', 'polldaddy' ); ?></a> | </span>
- <?php if ( $delete_link ) { ?>
- <span class="delete"><a class="delete-poll delete" href="<?php echo $delete_link; ?>"><?php _e( 'Delete', 'polldaddy' ); ?></a> | </span>
- <?php }
- if ( $poll_closed == 2 ) {
- if ( $open_link ) { ?>
- <span class="open"><a class="open-poll" href="<?php echo $open_link; ?>"><?php _e( 'Open', 'polldaddy' ); ?></a> | </span>
- <?php } } else {
- if ( $close_link ) { ?>
- <span class="close"><a class="close-poll" href="<?php echo $close_link; ?>"><?php _e( 'Close', 'polldaddy' ); ?></a> | </span>
- <?php } } ?>
- <?php if ( isset( $_GET['iframe'] ) ) { ?>
- <span class="view"><a href="<?php echo $preview_link; ?>"><?php _e( 'Preview', 'polldaddy' ); ?></a> | </span>
- <span class="editor">
- <a href="#" class="polldaddy-send-to-editor"><?php _e( 'Send to editor', 'polldaddy' ); ?></a>
- <input type="hidden" class="polldaddy-poll-id hack" value="<?php echo (int) $poll_id; ?>" /> |
- </span>
- <?php } else { ?>
- <span class="view"><a class="thickbox" href="<?php echo $preview_link; ?>"><?php _e( 'Preview', 'polldaddy' ); ?></a> | </span>
- <?php } ?>
- <span class="shortcode"><a href="#" class="polldaddy-show-shortcode"><?php _e( 'Share-Embed', 'polldaddy' ); ?></a></span>
- <?php $this->poll_table_add_option( $poll_id ); ?>
- </div>
- </td>
- <td class="poll-votes column-vote num"><?php echo number_format_i18n( $poll->_responses ); ?></td>
- <td class="date column-date"><abbr title="<?php echo date( __('Y/m/d g:i:s A', 'polldaddy'), $poll_time ); ?>"><?php echo date( __('Y/m/d', 'polldaddy'), $poll_time ); ?></abbr></td>
- </tr>
- <tr class="polldaddy-shortcode-row" style="display: none;">
- <td colspan="4">
- <h4><?php _e( 'WordPress Shortcode', 'polldaddy' ); ?></h4>
- <input type="text" readonly="readonly" style="width: 175px;" onclick="this.select();" value="[polldaddy poll=<?php echo (int) $poll_id; ?>]"/>
-
- <h4><?php _e( 'JavaScript', 'polldaddy' ); ?></h4>
- <pre><script type="text/javascript" language="javascript"
- src="http://static.polldaddy.com/p/<?php echo (int) $poll_id; ?>.js"></script>
- <noscript>
- <a href="http://polldaddy.com/poll/<?php echo (int) $poll_id; ?>/"><?php echo trim( strip_tags( $poll->___content ) ); ?></a><br/>
- <span style="font:9px;">(<a href="http://www.polldaddy.com">polls</a>)</span>
- </noscript></pre>
- <h4><?php _e( 'Short URL (Good for Twitter etc.)', 'polldaddy' ); ?></h4>
- <input type="text" readonly="readonly" style="width: 175px;" onclick="this.select();" value="http://poll.fm/<?php echo base_convert( $poll_id, 10, 36 ); ?>"/>
- <h4><?php _e( 'Facebook URL', 'polldaddy' ); ?></h4>
- <input type="text" readonly="readonly" style="width: 175px;" onclick="this.se…
Large files files are truncated, but you can click here to view the full file