PageRenderTime 50ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 1ms

/blog/wp-content/plugins/polldaddy/polldaddy.php

https://bitbucket.org/sergiohzlz/reportaprod
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
  1. <?php
  2. /*
  3. Plugin Name: PollDaddy Polls
  4. Description: Create and manage PollDaddy polls and ratings in WordPress
  5. Author: Automattic, Inc.
  6. Author URL: http://automattic.com/
  7. Version: 1.8.9
  8. */
  9. // You can hardcode your PollDaddy PartnerGUID (API Key) here
  10. //define( 'WP_POLLDADDY__PARTNERGUID', '12345...' );
  11. class WP_PollDaddy {
  12. var $errors;
  13. var $base_url;
  14. var $is_admin;
  15. var $is_author;
  16. var $scheme;
  17. var $version;
  18. var $polldaddy_client_class;
  19. var $polldaddy_clients;
  20. var $id;
  21. var $multiple_accounts;
  22. var $user_code;
  23. var $rating_user_code;
  24. function WP_PollDaddy(){
  25. $this ->__construct();
  26. }
  27. function __construct() {
  28. global $current_user;
  29. $this->errors = new WP_Error;
  30. $this->scheme = 'https';
  31. $this->version = '1.8.8';
  32. $this->multiple_accounts = true;
  33. $this->polldaddy_client_class = 'api_client';
  34. $this->polldaddy_clients = array();
  35. $this->is_admin = (bool) current_user_can('manage_options');
  36. $this->is_author = true;
  37. $this->id = (int) $current_user->ID;
  38. $this->user_code = null;
  39. $this->rating_user_code = null;
  40. }
  41. function &get_client( $api_key, $userCode = null ) {
  42. if ( isset( $this->polldaddy_clients[$api_key] ) ) {
  43. if ( !is_null( $userCode ) )
  44. $this->polldaddy_clients[$api_key]->userCode = $userCode;
  45. return $this->polldaddy_clients[$api_key];
  46. }
  47. require_once WP_POLLDADDY__POLLDADDY_CLIENT_PATH;
  48. $this->polldaddy_clients[$api_key] = $this->config_client( new $this->polldaddy_client_class( $api_key, $userCode ) );
  49. return $this->polldaddy_clients[$api_key];
  50. }
  51. function config_client( $client ){
  52. return $client;
  53. }
  54. function admin_menu() {
  55. if ( !defined( 'WP_POLLDADDY__PARTNERGUID' ) ) {
  56. $guid = get_option( 'polldaddy_api_key' );
  57. if ( !$guid || !is_string( $guid ) )
  58. $guid = false;
  59. define( 'WP_POLLDADDY__PARTNERGUID', $guid );
  60. }
  61. if ( !WP_POLLDADDY__PARTNERGUID ) {
  62. if ( function_exists( 'add_object_page' ) ) // WP 2.7+
  63. $hook = add_object_page( __( 'Ratings', 'polldaddy' ), __( 'Ratings', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'api_key_page' ), "{$this->base_url}polldaddy.png" );
  64. else
  65. $hook = add_management_page( __( 'Ratings', 'polldaddy' ), __( 'Ratings', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'api_key_page' ) );
  66. add_action( "load-$hook", array( &$this, 'api_key_page_load' ) );
  67. if ( function_exists( 'add_object_page' ) ) // WP 2.7+
  68. $hook = add_object_page( __( 'Polls', 'polldaddy' ), __( 'Polls', 'polldaddy' ), 'edit_posts', 'polls', array( &$this, 'api_key_page' ), "{$this->base_url}polldaddy.png" );
  69. else
  70. $hook = add_management_page( __( 'Polls', 'polldaddy' ), __( 'Polls', 'polldaddy' ), 'edit_posts', 'polls', array( &$this, 'api_key_page' ) );
  71. add_action( "load-$hook", array( &$this, 'api_key_page_load' ) );
  72. if ( ( empty( $_GET['page'] ) || 'polls' != $_GET['page'] ) && ( empty( $_GET['page'] ) || 'ratings' != $_GET['page'] ) )
  73. 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>";' ) );
  74. return false;
  75. }
  76. if ( function_exists( 'add_object_page' ) ) // WP 2.7+
  77. $hook = add_object_page( __( 'Ratings', 'polldaddy' ), __( 'Ratings', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'management_page' ), "{$this->base_url}polldaddy.png" );
  78. else
  79. $hook = add_management_page( __( 'Ratings', 'polldaddy' ), __( 'Ratings', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'management_page' ) );
  80. add_action( "load-$hook", array( &$this, 'management_page_load' ) );
  81. if ( function_exists( 'add_object_page' ) ) // WP 2.7+
  82. $hook = add_object_page( __( 'Polls', 'polldaddy' ), __( 'Polls', 'polldaddy' ), 'edit_posts', 'polls', array( &$this, 'management_page' ), "{$this->base_url}polldaddy.png" );
  83. else
  84. $hook = add_management_page( __( 'Polls', 'polldaddy' ), __( 'Polls', 'polldaddy' ), 'edit_posts', 'polls', array( &$this, 'management_page' ) );
  85. add_action( "load-$hook", array( &$this, 'management_page_load' ) );
  86. if ( $this->is_admin ) {
  87. add_submenu_page( 'ratings', __( 'Ratings &ndash; Settings', 'polldaddy' ), __( 'Settings', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'management_page' ) );
  88. add_submenu_page( 'ratings', __( 'Ratings &ndash; Reports', 'polldaddy' ), __( 'Reports', 'polldaddy' ), 'edit_posts', 'ratings&amp;action=reports', array( &$this, 'management_page' ) );
  89. }
  90. else{
  91. add_submenu_page( 'ratings', __( 'Ratings &ndash; Reports', 'polldaddy' ), __( 'Reports', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'management_page' ) );
  92. }
  93. add_submenu_page( 'polls', __( 'Polls', 'polldaddy' ), __( 'Edit', 'polldaddy' ), 'edit_posts', 'polls', array( &$this, 'management_page' ) );
  94. if ( $this->is_author ) {
  95. add_submenu_page( 'polls', __( 'Add New Poll', 'polldaddy' ), __( 'Add New', 'polldaddy' ), 'edit_posts', 'polls&amp;action=create-poll', array( &$this, 'management_page' ) );
  96. add_submenu_page( 'polls', __( 'Custom Styles', 'polldaddy' ), __( 'Custom Styles', 'polldaddy' ), 'edit_posts', 'polls&amp;action=list-styles', array( &$this, 'management_page' ) );
  97. add_submenu_page( 'polls', __( 'Options', 'polldaddy' ), __( 'Options', 'polldaddy' ), 'edit_posts', 'polls&amp;action=options', array( &$this, 'management_page' ) );
  98. }
  99. add_action( 'media_buttons', array( &$this, 'media_buttons' ) );
  100. }
  101. function api_key_page_load() {
  102. if ( 'post' != strtolower( $_SERVER['REQUEST_METHOD'] ) || empty( $_POST['action'] ) || 'account' != $_POST['action'] )
  103. return false;
  104. check_admin_referer( 'polldaddy-account' );
  105. $polldaddy_email = stripslashes( $_POST['polldaddy_email'] );
  106. $polldaddy_password = stripslashes( $_POST['polldaddy_password'] );
  107. if ( !$polldaddy_email )
  108. $this->errors->add( 'polldaddy_email', __( 'Email address required', 'polldaddy' ) );
  109. if ( !$polldaddy_password )
  110. $this->errors->add( 'polldaddy_password', __( 'Password required', 'polldaddy' ) );
  111. if ( $this->errors->get_error_codes() )
  112. return false;
  113. $details = array(
  114. 'uName' => get_bloginfo( 'name' ),
  115. 'uEmail' => $polldaddy_email,
  116. 'uPass' => $polldaddy_password,
  117. 'partner_userid' => $this->id
  118. );
  119. if ( function_exists( 'wp_remote_post' ) ) { // WP 2.7+
  120. $polldaddy_api_key = wp_remote_post( $this->scheme . '://api.polldaddy.com/key.php', array(
  121. 'body' => $details
  122. ) );
  123. if ( is_wp_error( $polldaddy_api_key ) ) {
  124. $this->errors = $polldaddy_api_key;
  125. return false;
  126. }
  127. $polldaddy_api_key = wp_remote_retrieve_body( $polldaddy_api_key );
  128. } else {
  129. $fp = fsockopen(
  130. 'api.polldaddy.com',
  131. 80,
  132. $err_num,
  133. $err_str,
  134. 3
  135. );
  136. if ( !$fp ) {
  137. $this->errors->add( 'connect', __( "Can't connect to PollDaddy.com", 'polldaddy' ) );
  138. return false;
  139. }
  140. if ( function_exists( 'stream_set_timeout' ) )
  141. stream_set_timeout( $fp, 3 );
  142. global $wp_version;
  143. $request_body = http_build_query( $details, null, '&' );
  144. $request = "POST /key.php HTTP/1.0\r\n";
  145. $request .= "Host: api.polldaddy.com\r\n";
  146. $request .= "User-agent: WordPress/$wp_version\r\n";
  147. $request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option('blog_charset') . "\r\n";
  148. $request .= 'Content-Length: ' . strlen( $request_body ) . "\r\n";
  149. fwrite( $fp, "$request\r\n$request_body" );
  150. $response = '';
  151. while ( !feof( $fp ) )
  152. $response .= fread( $fp, 4096 );
  153. fclose( $fp );
  154. list($headers, $polldaddy_api_key) = explode( "\r\n\r\n", $response, 2 );
  155. }
  156. if ( !$polldaddy_api_key ) {
  157. $this->errors->add( 'polldaddy_password', __( 'Invalid Account', 'polldaddy' ) );
  158. return false;
  159. }
  160. update_option( 'polldaddy_api_key', $polldaddy_api_key );
  161. $polldaddy = $this->get_client( $polldaddy_api_key );
  162. $polldaddy->reset();
  163. if ( !$polldaddy->get_usercode( $this->id ) ) {
  164. $this->parse_errors( $polldaddy );
  165. $this->errors->add( 'GetUserCode', __( 'Account could not be accessed. Are your email address and password correct?', 'polldaddy' ) );
  166. return false;
  167. }
  168. return true;
  169. }
  170. function parse_errors( &$polldaddy ) {
  171. if ( $polldaddy->errors )
  172. foreach ( $polldaddy->errors as $code => $error )
  173. $this->errors->add( $code, $error );
  174. if ( isset( $this->errors->errors[4] ) ) {
  175. $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'] ) ) ) );
  176. $this->errors->add_data( true, 4 );
  177. }
  178. }
  179. function print_errors() {
  180. if ( !$error_codes = $this->errors->get_error_codes() )
  181. return;
  182. ?>
  183. <div class="error">
  184. <?php
  185. foreach ( $error_codes as $error_code ) :
  186. foreach ( $this->errors->get_error_messages( $error_code ) as $error_message ) :
  187. ?>
  188. <p><?php echo $this->errors->get_error_data( $error_code ) ? $error_message : wp_specialchars( $error_message ); ?></p>
  189. <?php
  190. endforeach;
  191. endforeach;
  192. $this->errors = new WP_Error;
  193. ?>
  194. </div>
  195. <br class="clear" />
  196. <?php
  197. }
  198. function api_key_page() {
  199. $this->print_errors();
  200. ?>
  201. <div class="wrap">
  202. <h2><?php _e( 'PollDaddy Account', 'polldaddy' ); ?></h2>
  203. <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>
  204. <form action="" method="post">
  205. <table class="form-table">
  206. <tbody>
  207. <tr class="form-field form-required">
  208. <th valign="top" scope="row">
  209. <label for="polldaddy-email"><?php _e( 'PollDaddy Email Address', 'polldaddy' ); ?></label>
  210. </th>
  211. <td>
  212. <input type="text" name="polldaddy_email" id="polldaddy-email" aria-required="true" size="40" />
  213. </td>
  214. </tr>
  215. <tr class="form-field form-required">
  216. <th valign="top" scope="row">
  217. <label for="polldaddy-password"><?php _e( 'PollDaddy Password', 'polldaddy' ); ?></label>
  218. </th>
  219. <td>
  220. <input type="password" name="polldaddy_password" id="polldaddy-password" aria-required="true" size="40" />
  221. </td>
  222. </tr>
  223. </tbody>
  224. </table>
  225. <p class="submit">
  226. <?php wp_nonce_field( 'polldaddy-account' ); ?>
  227. <input type="hidden" name="action" value="account" />
  228. <input type="hidden" name="account" value="import" />
  229. <input type="submit" value="<?php echo attribute_escape( __( 'Submit', 'polldaddy' ) ); ?>" />
  230. </p>
  231. </form>
  232. </div>
  233. <?php
  234. }
  235. function media_buttons() {
  236. $title = __( 'Add Poll', 'polldaddy' );
  237. 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>";
  238. }
  239. function set_api_user_code(){
  240. $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID );
  241. $polldaddy->reset();
  242. if ( empty( $this->user_code ) ){
  243. $this->user_code = $polldaddy->get_usercode( $this->id );
  244. }
  245. }
  246. function management_page_load() {
  247. wp_reset_vars( array( 'page', 'action', 'poll', 'style', 'rating', 'id' ) );
  248. global $plugin_page, $page, $action, $poll, $style, $rating, $id, $wp_locale;
  249. $this->set_api_user_code();
  250. if ( empty( $this->user_code ) && $page == 'polls' ){
  251. $action = 'signup';
  252. }
  253. require_once WP_POLLDADDY__POLLDADDY_CLIENT_PATH;
  254. wp_enqueue_script( 'polls', "{$this->base_url}polldaddy.js", array( 'jquery', 'jquery-ui-sortable' ), $this->version );
  255. wp_enqueue_script( 'polls-common', "{$this->base_url}common.js", array(), $this->version );
  256. if( $page == 'polls' ) {
  257. 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
  258. $action = '';
  259. }
  260. switch ( $action ) :
  261. case 'edit' :
  262. case 'edit-poll' :
  263. case 'create-poll' :
  264. wp_enqueue_script( 'polls-style', "http://i.polldaddy.com/js/poll-style-picker.js", array(), $this->version );
  265. if ( $action == 'create-poll' )
  266. $plugin_page = 'polls&amp;action=create-poll';
  267. break;
  268. case 'edit-style' :
  269. case 'create-style' :
  270. wp_enqueue_script( 'polls-style', "http://i.polldaddy.com/js/style-editor.js", array(), $this->version );
  271. wp_enqueue_script( 'polls-style-color', "http://i.polldaddy.com/js/jquery/jscolor.js", array(), $this->version );
  272. wp_enqueue_style( 'polls', "{$this->base_url}style-editor.css", array(), $this->version );
  273. $plugin_page = 'polls&amp;action=list-styles';
  274. break;
  275. case 'list-styles' :
  276. $plugin_page = 'polls&amp;action=list-styles';
  277. break;
  278. case 'options' :
  279. case 'update-options' :
  280. case 'import-account' :
  281. $plugin_page = 'polls&amp;action=options';
  282. break;
  283. endswitch;
  284. } elseif( $page == 'ratings' ) {
  285. if ( !$this->is_admin && !in_array( $action, array( 'reports', 'delete' ) ) ) {//check user privileges has access to action
  286. $action = 'reports';
  287. }
  288. switch ( $action ) :
  289. case 'delete' :
  290. case 'reports' :
  291. $plugin_page = 'ratings&amp;action=reports';
  292. break;
  293. default :
  294. wp_enqueue_script( 'rating-text-color', "http://i.polldaddy.com/js/jquery/jscolor.js", array(), $this->version );
  295. wp_enqueue_script( 'ratings', 'http://i.polldaddy.com/ratings/rating.js', array(), $this->version );
  296. wp_localize_script( 'polls-common', 'adminRatingsL10n', array(
  297. 'star_colors' => __( 'Star Colors', 'polldaddy' ), 'star_size' => __( 'Star Size', 'polldaddy' ),
  298. 'nero_type' => __( 'Nero Type', 'polldaddy' ), 'nero_size' => __( 'Nero Size', 'polldaddy' ), ) );
  299. endswitch;
  300. }
  301. wp_enqueue_script( 'admin-forms' );
  302. add_thickbox();
  303. wp_enqueue_style( 'polls', "{$this->base_url}polldaddy.css", array( 'global', 'wp-admin' ), $this->version );
  304. if ( isset($wp_locale->text_direction) && 'rtl' == $wp_locale->text_direction )
  305. wp_enqueue_style( 'polls-rtl', "{$this->base_url}polldaddy-rtl.css", array( 'global', 'wp-admin' ), $this->version );
  306. add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) );
  307. add_action( 'admin_notices', array( &$this, 'management_page_notices' ) );
  308. $query_args = array();
  309. $args = array();
  310. $allowedtags = array(
  311. 'a' => array(
  312. 'href' => array (),
  313. 'title' => array (),
  314. 'target' => array ()),
  315. 'img' => array(
  316. 'alt' => array (),
  317. 'align' => array (),
  318. 'border' => array (),
  319. 'class' => array (),
  320. 'height' => array (),
  321. 'hspace' => array (),
  322. 'longdesc' => array (),
  323. 'vspace' => array (),
  324. 'src' => array (),
  325. 'width' => array ()),
  326. 'abbr' => array(
  327. 'title' => array ()),
  328. 'acronym' => array(
  329. 'title' => array ()),
  330. 'b' => array(),
  331. 'blockquote' => array(
  332. 'cite' => array ()),
  333. 'cite' => array (),
  334. 'em' => array (),
  335. 'i' => array (),
  336. 'q' => array(
  337. 'cite' => array ()),
  338. 'strike' => array(),
  339. 'strong' => array()
  340. );
  341. $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
  342. if( $page == 'polls' ) {
  343. switch ( $action ) :
  344. case 'signup' : // sign up for first time
  345. case 'account' : // reauthenticate
  346. case 'import-account' : // reauthenticate
  347. if ( !$is_POST )
  348. return;
  349. check_admin_referer( 'polldaddy-account' );
  350. if ( $new_args = $this->management_page_load_signup() )
  351. $query_args = array_merge( $query_args, $new_args );
  352. if ( $this->errors->get_error_codes() )
  353. return false;
  354. $query_args['message'] = 'imported-account';
  355. wp_reset_vars( array( 'action' ) );
  356. if ( !empty( $_GET['reaction'] ) )
  357. $query_args['action'] = $_GET['reaction'];
  358. elseif ( !empty( $_GET['action'] ) && 'account' == $_GET['action'] )
  359. $query_args['action'] = $_GET['action'];
  360. else
  361. $query_args['action'] = false;
  362. break;
  363. case 'delete' :
  364. if ( empty( $poll ) )
  365. return;
  366. if ( is_array( $poll ) )
  367. check_admin_referer( 'action-poll_bulk' );
  368. else
  369. check_admin_referer( "delete-poll_$poll" );
  370. $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
  371. foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
  372. $polldaddy->reset();
  373. $poll_object = $polldaddy->get_poll( $poll );
  374. if ( !$this->can_edit( $poll_object ) ) {
  375. $this->errors->add( 'permission', __( 'You are not allowed to delete this poll.', 'polldaddy' ) );
  376. return false;
  377. }
  378. // Send Poll Author credentials
  379. if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
  380. $polldaddy->reset();
  381. if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
  382. $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
  383. }
  384. $polldaddy->userCode = $userCode;
  385. }
  386. $polldaddy->reset();
  387. $polldaddy->delete_poll( $poll_id );
  388. }
  389. $query_args['message'] = 'deleted';
  390. $query_args['deleted'] = count( (array) $poll );
  391. break;
  392. case 'open' :
  393. if ( empty( $poll ) )
  394. return;
  395. if ( is_array( $poll ) )
  396. check_admin_referer( 'action-poll_bulk' );
  397. else
  398. check_admin_referer( "open-poll_$poll" );
  399. $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
  400. foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
  401. $polldaddy->reset();
  402. $poll_object = $polldaddy->get_poll( $poll );
  403. if ( !$this->can_edit( $poll_object ) ) {
  404. $this->errors->add( 'permission', __( 'You are not allowed to open this poll.', 'polldaddy' ) );
  405. return false;
  406. }
  407. // Send Poll Author credentials
  408. if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
  409. $polldaddy->reset();
  410. if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
  411. $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
  412. }
  413. $polldaddy->userCode = $userCode;
  414. }
  415. $polldaddy->reset();
  416. $polldaddy->open_poll( $poll_id );
  417. }
  418. $query_args['message'] = 'opened';
  419. $query_args['opened'] = count( (array) $poll );
  420. break;
  421. case 'close' :
  422. if ( empty( $poll ) )
  423. return;
  424. if ( is_array( $poll ) )
  425. check_admin_referer( 'action-poll_bulk' );
  426. else
  427. check_admin_referer( "close-poll_$poll" );
  428. $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
  429. foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
  430. $polldaddy->reset();
  431. $poll_object = $polldaddy->get_poll( $poll );
  432. if ( !$this->can_edit( $poll_object ) ) {
  433. $this->errors->add( 'permission', __( 'You are not allowed to close this poll.', 'polldaddy' ) );
  434. return false;
  435. }
  436. // Send Poll Author credentials
  437. if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
  438. $polldaddy->reset();
  439. if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
  440. $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
  441. }
  442. $polldaddy->userCode = $userCode;
  443. }
  444. $polldaddy->reset();
  445. $polldaddy->close_poll( $poll_id );
  446. }
  447. $query_args['message'] = 'closed';
  448. $query_args['closed'] = count( (array) $poll );
  449. break;
  450. case 'edit-poll' : // TODO: use polldaddy_poll
  451. if ( !$is_POST || !$poll = (int) $poll )
  452. return;
  453. check_admin_referer( "edit-poll_$poll" );
  454. $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
  455. $polldaddy->reset();
  456. $poll_object = $polldaddy->get_poll( $poll );
  457. $this->parse_errors( $polldaddy );
  458. if ( !$this->can_edit( $poll_object ) ) {
  459. $this->errors->add( 'permission', __( 'You are not allowed to edit this poll.', 'polldaddy' ) );
  460. return false;
  461. }
  462. // Send Poll Author credentials
  463. if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
  464. $polldaddy->reset();
  465. if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
  466. $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
  467. }
  468. $this->parse_errors( $polldaddy );
  469. $polldaddy->userCode = $userCode;
  470. }
  471. if ( !$poll_object )
  472. $this->errors->add( 'GetPoll', __( 'Poll not found', 'polldaddy' ) );
  473. if ( $this->errors->get_error_codes() )
  474. return false;
  475. $poll_data = get_object_vars( $poll_object );
  476. foreach ( $poll_data as $key => $value )
  477. if ( '_' === $key[0] )
  478. unset( $poll_data[$key] );
  479. foreach ( array( 'multipleChoice', 'randomiseAnswers', 'otherAnswer', 'sharing' ) as $option ) {
  480. if ( isset( $_POST[$option] ) && $_POST[$option] )
  481. $poll_data[$option] = 'yes';
  482. else
  483. $poll_data[$option] = 'no';
  484. }
  485. $blocks = array( 'off', 'cookie', 'cookieip' );
  486. if ( isset( $_POST['blockRepeatVotersType'] ) && in_array( $_POST['blockRepeatVotersType'], $blocks ) )
  487. $poll_data['blockRepeatVotersType'] = $_POST['blockRepeatVotersType'];
  488. $results = array( 'show', 'percent', 'hide' );
  489. if ( isset( $_POST['resultsType'] ) && in_array( $_POST['resultsType'], $results ) )
  490. $poll_data['resultsType'] = $_POST['resultsType'];
  491. $poll_data['question'] = stripslashes( $_POST['question'] );
  492. if ( empty( $_POST['answer'] ) || !is_array( $_POST['answer'] ) )
  493. $this->errors->add( 'answer', __( 'Invalid answers', 'polldaddy' ) );
  494. $answers = array();
  495. foreach ( $_POST['answer'] as $answer_id => $answer ) {
  496. if ( !$answer = trim( stripslashes( $answer ) ) )
  497. continue;
  498. $args['text'] = wp_kses( $answer, $allowedtags );
  499. if ( is_numeric( $answer_id ) )
  500. $answers[] = polldaddy_poll_answer( $args, $answer_id );
  501. else
  502. $answers[] = polldaddy_poll_answer( $args );
  503. }
  504. if ( 2 > count( $answers ) )
  505. $this->errors->add( 'answer', __( 'You must include at least 2 answers', 'polldaddy' ) );
  506. if ( $this->errors->get_error_codes() )
  507. return false;
  508. $poll_data['answers'] = $answers;
  509. $poll_data['question'] = wp_kses( $poll_data['question'], $allowedtags );
  510. if ( isset ( $_POST['styleID'] ) ){
  511. if ( $_POST['styleID'] == 'x' ){
  512. $this->errors->add( 'UpdatePoll', __( 'Please choose a poll style', 'polldaddy' ) );
  513. return false;
  514. }
  515. }
  516. $poll_data['styleID'] = (int) $_POST['styleID'];
  517. $poll_data['choices'] = (int) $_POST['choices'];
  518. if ( $poll_data['blockRepeatVotersType'] == 'cookie' ){
  519. if( isset( $_POST['cookieip_expiration'] ) )
  520. $poll_data['blockExpiration'] = (int) $_POST['cookieip_expiration'];
  521. } elseif ( $poll_data['blockRepeatVotersType'] == 'cookieip' ){
  522. if( isset( $_POST['cookieip_expiration'] ) )
  523. $poll_data['blockExpiration'] = (int) $_POST['cookieip_expiration'];
  524. }
  525. $polldaddy->reset();
  526. $update_response = $polldaddy->update_poll( $poll, $poll_data );
  527. $this->parse_errors( $polldaddy );
  528. if ( !$update_response )
  529. $this->errors->add( 'UpdatePoll', __( 'Poll could not be updated', 'polldaddy' ) );
  530. if ( $this->errors->get_error_codes() )
  531. return false;
  532. $query_args['message'] = 'updated';
  533. if ( isset($_POST['iframe']) )
  534. $query_args['iframe'] = '';
  535. break;
  536. case 'create-poll' :
  537. if ( !$is_POST )
  538. return;
  539. check_admin_referer( 'create-poll' );
  540. $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
  541. $polldaddy->reset();
  542. $answers = array();
  543. foreach ( $_POST['answer'] as $answer ){
  544. if ( !$answer = trim( stripslashes( $answer ) ) )
  545. continue;
  546. $args['text'] = wp_kses( $answer, $allowedtags );
  547. $answers[] = polldaddy_poll_answer( $args );
  548. }
  549. if ( !$answers )
  550. return false;
  551. $poll_data = _polldaddy_poll_defaults();
  552. foreach ( array( 'multipleChoice', 'randomiseAnswers', 'otherAnswer', 'sharing' ) as $option ) {
  553. if ( isset( $_POST[$option] ) && $_POST[$option] )
  554. $poll_data[$option] = 'yes';
  555. else
  556. $poll_data[$option] = 'no';
  557. }
  558. $blocks = array( 'off', 'cookie', 'cookieip' );
  559. if ( isset( $_POST['blockRepeatVotersType'] ) && in_array( $_POST['blockRepeatVotersType'], $blocks ) )
  560. $poll_data['blockRepeatVotersType'] = $_POST['blockRepeatVotersType'];
  561. $results = array( 'show', 'percent', 'hide' );
  562. if ( isset( $_POST['resultsType'] ) && in_array( $_POST['resultsType'], $results ) )
  563. $poll_data['resultsType'] = $_POST['resultsType'];
  564. $poll_data['answers'] = $answers;
  565. $poll_data['question'] = stripslashes( $_POST['question'] );
  566. $poll_data['question'] = wp_kses( $poll_data['question'], $allowedtags );
  567. if ( isset ( $_POST['styleID'] ) ){
  568. if ( $_POST['styleID'] == 'x' ){
  569. $this->errors->add( 'UpdatePoll', __( 'Please choose a poll style', 'polldaddy' ) );
  570. return false;
  571. }
  572. }
  573. $poll_data['styleID'] = (int) $_POST['styleID'];
  574. $poll_data['choices'] = (int) $_POST['choices'];
  575. if ( $poll_data['blockRepeatVotersType'] == 'cookie' ){
  576. if( isset( $_POST['cookieip_expiration'] ) )
  577. $poll_data['blockExpiration'] = (int) $_POST['cookieip_expiration'];
  578. } elseif ( $poll_data['blockRepeatVotersType'] == 'cookieip' ){
  579. if( isset( $_POST['cookieip_expiration'] ) )
  580. $poll_data['blockExpiration'] = (int) $_POST['cookieip_expiration'];
  581. }
  582. $poll = $polldaddy->create_poll( $poll_data );
  583. $this->parse_errors( $polldaddy );
  584. if ( !$poll || empty( $poll->_id ) )
  585. $this->errors->add( 'CreatePoll', __( 'Poll could not be created', 'polldaddy' ) );
  586. if ( $this->errors->get_error_codes() )
  587. return false;
  588. $query_args['message'] = 'created';
  589. $query_args['action'] = 'edit-poll';
  590. $query_args['poll'] = $poll->_id;
  591. if ( isset($_POST['iframe']) )
  592. $query_args['iframe'] = '';
  593. break;
  594. case 'delete-style' :
  595. if ( empty( $style ) )
  596. return;
  597. if ( is_array( $style ) )
  598. check_admin_referer( 'action-style_bulk' );
  599. else
  600. check_admin_referer( "delete-style_$style" );
  601. $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
  602. foreach ( (array) $_REQUEST['style'] as $style_id ) {
  603. $polldaddy->reset();
  604. $polldaddy->delete_style( $style_id );
  605. }
  606. $query_args['message'] = 'deleted-style';
  607. $query_args['deleted'] = count( (array) $style );
  608. break;
  609. case 'edit-style' :
  610. if ( !$is_POST || !$style = (int) $style )
  611. return;
  612. check_admin_referer( "edit-style$style" );
  613. $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
  614. $polldaddy->reset();
  615. $style_data = _polldaddy_style_defaults();
  616. if ( isset($_POST['style-title'] ) )
  617. $style_data['title'] = stripslashes( trim ( (string) $_POST['style-title'] ) );
  618. if ( isset($_POST['CSSXML'] ) )
  619. $style_data['css'] = urlencode( stripslashes( trim ( (string) $_POST['CSSXML'] ) ) );
  620. if ( isset($_REQUEST['updatePollCheck'] ) && $_REQUEST['updatePollCheck'] == 'on' )
  621. $style_data['retro'] = 1;
  622. $update_response = $polldaddy->update_style( $style, $style_data );
  623. $this->parse_errors( $polldaddy );
  624. if ( !$update_response )
  625. $this->errors->add( 'UpdateStyle', __( 'Style could not be updated', 'polldaddy' ) );
  626. if ( $this->errors->get_error_codes() )
  627. return false;
  628. $query_args['message'] = 'updated-style';
  629. if ( isset($_POST['iframe']) )
  630. $query_args['iframe'] = '';
  631. break;
  632. case 'create-style' :
  633. if ( !$is_POST )
  634. return;
  635. check_admin_referer( 'create-style' );
  636. $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
  637. $polldaddy->reset();
  638. $style_data = _polldaddy_style_defaults();
  639. if ( isset($_POST['style-title'] ) )
  640. $style_data['title'] = stripslashes( strip_tags( trim ( (string) $_POST['style-title'] ) ) );
  641. if ( isset($_POST['CSSXML'] ) )
  642. $style_data['css'] = urlencode( stripslashes( trim ( (string) $_POST['CSSXML'] ) ) );
  643. $style = $polldaddy->create_style( $style_data );
  644. $this->parse_errors( $polldaddy );
  645. if ( !$style || empty( $style->_id ) )
  646. $this->errors->add( 'CreateStyle', __( 'Style could not be created', 'polldaddy' ) );
  647. if ( $this->errors->get_error_codes() )
  648. return false;
  649. $query_args['message'] = 'created-style';
  650. $query_args['action'] = 'edit-style';
  651. $query_args['style'] = $style->_id;
  652. if ( isset($_POST['iframe']) )
  653. $query_args['iframe'] = '';
  654. break;
  655. case 'update-options' :
  656. if ( !$is_POST )
  657. return;
  658. check_admin_referer( 'polldaddy-account' );
  659. $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
  660. $polldaddy->reset();
  661. $poll_defaults = _polldaddy_poll_defaults();
  662. $user_defaults = array();
  663. foreach( array( "multipleChoice", "randomiseAnswers", "otherAnswer", "sharing", "resultsType", "styleID", "blockRepeatVotersType", "blockExpiration" ) as $option ){
  664. if ( isset( $poll_defaults[$option] ) && $poll_defaults[$option] )
  665. $user_defaults[$option] = $poll_defaults[$option];
  666. }
  667. foreach ( array( 'multipleChoice', 'randomiseAnswers', 'otherAnswer', 'sharing' ) as $option ) {
  668. if ( isset( $_POST[$option] ) && $_POST[$option] )
  669. $user_defaults[$option] = 'yes';
  670. else
  671. $user_defaults[$option] = 'no';
  672. }
  673. $results = array( 'show', 'percent', 'hide' );
  674. if ( isset( $_POST['resultsType'] ) && in_array( $_POST['resultsType'], $results ) )
  675. $user_defaults['resultsType'] = $_POST['resultsType'];
  676. if ( isset ( $_POST['styleID'] ) ){
  677. $user_defaults['styleID'] = (int) $_POST['styleID'];
  678. }
  679. $blocks = array( 'off', 'cookie', 'cookieip' );
  680. if ( isset( $_POST['blockRepeatVotersType'] ) && in_array( $_POST['blockRepeatVotersType'], $blocks ) )
  681. $user_defaults['blockRepeatVotersType'] = $_POST['blockRepeatVotersType'];
  682. if( isset( $_POST['blockExpiration'] ) )
  683. $user_defaults['blockExpiration'] = (int) $_POST['blockExpiration'];
  684. $polldaddy->update_poll_defaults( 0, $user_defaults );
  685. $this->parse_errors( $polldaddy );
  686. if ( $this->errors->get_error_codes() )
  687. return false;
  688. $query_args['message'] = 'updated-options';
  689. break;
  690. default :
  691. return;
  692. endswitch;
  693. } elseif( $page == 'ratings' ) {
  694. switch ( $action ) :
  695. case 'delete' :
  696. if ( empty( $id ) )
  697. return;
  698. if ( empty( $rating ) )
  699. return;
  700. $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
  701. if ( is_array( $rating ) ) {
  702. check_admin_referer( 'action-rating_bulk' );
  703. foreach( $rating as $key => $value ){
  704. $polldaddy->reset();
  705. $polldaddy->delete_rating_result( $id, $value );
  706. }
  707. } else {
  708. check_admin_referer( "delete-rating_$rating" );
  709. $polldaddy->delete_rating_result( $id, $rating );
  710. }
  711. if ( isset( $_REQUEST['filter'] ) )
  712. $query_args['filter'] = $_REQUEST['filter'];
  713. if ( isset( $_REQUEST['change-report-to'] ) )
  714. $query_args['change-report-to'] = $_REQUEST['change-report-to'];
  715. $query_args['message'] = 'deleted-rating';
  716. $query_args['deleted'] = count( (array) $rating );
  717. break;
  718. default :
  719. return;
  720. endswitch;
  721. }
  722. wp_redirect( add_query_arg( $query_args, wp_get_referer() ) );
  723. exit;
  724. }
  725. function management_page_load_signup() {
  726. switch ( $_POST['account'] ) :
  727. case 'import' :
  728. return $this->import_account();
  729. break;
  730. default :
  731. return;
  732. endswitch;
  733. }
  734. function import_account(){
  735. $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID );
  736. $polldaddy->reset();
  737. $email = trim( stripslashes( $_POST['polldaddy_email'] ) );
  738. $password = trim( stripslashes( $_POST['polldaddy_password'] ) );
  739. if ( !is_email( $email ) )
  740. $this->errors->add( 'polldaddy_email', __( 'Email address required', 'polldaddy' ) );
  741. if ( !$password )
  742. $this->errors->add( 'polldaddy_password', __( 'Password required', 'polldaddy' ) );
  743. if ( $this->errors->get_error_codes() )
  744. return false;
  745. if ( $usercode = $polldaddy->initiate( $email, $password, $this->id ) ) {
  746. $this->user_code = $usercode;
  747. } else {
  748. $this->parse_errors( $polldaddy );
  749. $this->errors->add( 'import-account', __( 'Account could not be imported. Are your email address and password correct?', 'polldaddy' ) );
  750. return false;
  751. }
  752. }
  753. function admin_body_class( $class ) {
  754. if ( isset( $_GET['iframe'] ) )
  755. $class .= 'poll-preview-iframe ';
  756. if ( isset( $_GET['TB_iframe'] ) )
  757. $class .= 'poll-preview-iframe-editor ';
  758. return $class;
  759. }
  760. function management_page_notices( $message = false ) {
  761. switch ( (string) @$_GET['message'] ) :
  762. case 'deleted' :
  763. $deleted = (int) $_GET['deleted'];
  764. if ( 1 == $deleted )
  765. $message = __( 'Poll deleted.', 'polldaddy' );
  766. else
  767. $message = sprintf( __ngettext( '%s Poll Deleted.', '%s Polls Deleted.', $deleted ), number_format_i18n( $deleted ) );
  768. break;
  769. case 'opened' :
  770. $opened = (int) $_GET['opened'];
  771. if ( 1 == $opened )
  772. $message = __( 'Poll opened.', 'polldaddy' );
  773. else
  774. $message = sprintf( __ngettext( '%s Poll Opened.', '%s Polls Opened.', $opened ), number_format_i18n( $opened ) );
  775. break;
  776. case 'closed' :
  777. $closed = (int) $_GET['closed'];
  778. if ( 1 == $closed )
  779. $message = __( 'Poll closed.', 'polldaddy' );
  780. else
  781. $message = sprintf( __ngettext( '%s Poll Closed.', '%s Polls Closed.', $closed ), number_format_i18n( $closed ) );
  782. break;
  783. case 'updated' :
  784. $message = __( 'Poll updated.', 'polldaddy' );
  785. break;
  786. case 'created' :
  787. $message = __( 'Poll created.', 'polldaddy' );
  788. if ( isset( $_GET['iframe'] ) )
  789. $message .= ' <input type="button" class="button polldaddy-send-to-editor" value="' . attribute_escape( __( 'Send to Editor', 'polldaddy' ) ) . '" />';
  790. break;
  791. case 'updated-style' :
  792. $message = __( 'Custom Style updated.', 'polldaddy' );
  793. break;
  794. case 'created-style' :
  795. $message = __( 'Custom Style created.', 'polldaddy' );
  796. break;
  797. case 'deleted-style' :
  798. $deleted = (int) $_GET['deleted'];
  799. if ( 1 == $deleted )
  800. $message = __( 'Custom Style deleted.', 'polldaddy' );
  801. else
  802. $message = sprintf( __ngettext( '%s Style Deleted.', '%s Custom Styles Deleted.', $deleted ), number_format_i18n( $deleted ) );
  803. break;
  804. case 'imported-account' :
  805. $message = __( 'Account Imported.', 'polldaddy' );
  806. break;
  807. case 'updated-options' :
  808. $message = __( 'Options Updated.', 'polldaddy' );
  809. break;
  810. case 'deleted-rating' :
  811. $deleted = (int) $_GET['deleted'];
  812. if ( 1 == $deleted )
  813. $message = __( 'Rating deleted.', 'polldaddy' );
  814. else
  815. $message = sprintf( __ngettext( '%s Rating Deleted.', '%s Ratings Deleted.', $deleted ), number_format_i18n( $deleted ) );
  816. break;
  817. endswitch;
  818. $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
  819. if ( $is_POST ) {
  820. switch ( $GLOBALS['action'] ) :
  821. case 'create-poll' :
  822. $message = __( 'Error: An error has occurred; Poll not created.', 'polldaddy' );
  823. break;
  824. case 'edit-poll' :
  825. $message = __( 'Error: An error has occurred; Poll not updated.', 'polldaddy' );
  826. break;
  827. case 'account' :
  828. if ( 'import' == $_POST['account'] )
  829. $message = __( 'Error: An error has occurred; Account could not be imported. Perhaps your email address or password is incorrect?', 'polldaddy' );
  830. else
  831. $message = __( 'Error: An error has occurred; Account could not be created.', 'polldaddy' );
  832. break;
  833. endswitch;
  834. }
  835. if ( !$message )
  836. return;
  837. ?>
  838. <div class='updated'><p><?php echo $message; ?></p></div>
  839. <?php
  840. $this->print_errors();
  841. }
  842. function management_page() {
  843. global $page, $action, $poll, $style, $rating;
  844. $poll = (int) $poll;
  845. $style = (int) $style;
  846. $rating = wp_specialchars( $rating );
  847. ?>
  848. <div class="wrap" id="manage-polls">
  849. <?php
  850. if( $page == 'polls' ) {
  851. 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
  852. $action = '';
  853. }
  854. switch ( $action ) :
  855. case 'signup' :
  856. case 'account' :
  857. $this->signup();
  858. break;
  859. case 'preview' :
  860. ?>
  861. <h2 id="preview-header"><?php
  862. if( $this->is_author )
  863. printf( __( 'Poll Preview (<a href="%s">Edit Poll</a>, <a href="%s">List Polls</a>)', 'polldaddy' ),
  864. clean_url( add_query_arg( array( 'action' => 'edit', 'poll' => $poll, 'message' => false ) ) ),
  865. clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ));
  866. else
  867. printf( __( 'Poll Preview (<a href="%s">List Polls</a>)', 'polldaddy'), clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ) ); ?></h2>
  868. <?php
  869. echo do_shortcode( "[polldaddy poll=$poll cb=1]" );
  870. break;
  871. case 'results' :
  872. ?>
  873. <h2><?php
  874. if( $this->is_author )
  875. printf( __( 'Poll Results (<a href="%s">Edit Poll</a>)', 'polldaddy' ), clean_url( add_query_arg( array( 'action' => 'edit', 'poll' => $poll, 'message' => false ) ) ) );
  876. else
  877. printf( __( 'Poll Results (<a href="%s">List Polls</a>)', 'polldaddy'), clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ) ); ?></h2>
  878. <?php
  879. $this->poll_results_page( $poll );
  880. break;
  881. case 'edit' :
  882. case 'edit-poll' :
  883. ?>
  884. <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>
  885. <?php
  886. $this->poll_edit_form( $poll );
  887. break;
  888. case 'create-poll' :
  889. ?>
  890. <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>
  891. <?php
  892. $this->poll_edit_form();
  893. break;
  894. case 'list-styles' :
  895. ?>
  896. <h2><?php
  897. if( $this->is_author )
  898. printf( __('Custom Styles (<a href="%s">Add New</a>)', 'polldaddy'), clean_url( add_query_arg( array( 'action' => 'create-style', 'poll' => false, 'message' => false ) ) ) );
  899. else
  900. _e('Custom Styles', 'polldaddy'); ?></h2>
  901. <?php
  902. $this->styles_table();
  903. break;
  904. case 'edit-style' :
  905. ?>
  906. <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>
  907. <?php
  908. $this->style_edit_form( $style );
  909. break;
  910. case 'create-style' :
  911. ?>
  912. <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>
  913. <?php
  914. $this->style_edit_form();
  915. break;
  916. case 'options' :
  917. case 'import-account' :
  918. case 'update-options' :
  919. $this->plugin_options();
  920. break;
  921. default :
  922. ?>
  923. <h2 id="poll-list-header"><?php
  924. if( $this->is_author )
  925. printf( __( 'Polls (<a href="%s">Add New</a>)', 'polldaddy' ), clean_url( add_query_arg( array('action' => 'create-poll','poll' => false,'message' => false) ) ) );
  926. else
  927. _e( 'Polls', 'polldaddy'); ?></h2>
  928. <?php
  929. $this->polls_table( isset( $_GET['view'] ) && 'user' == $_GET['view'] ? 'user' : 'blog' );
  930. endswitch;
  931. } elseif( $page == 'ratings' ) {
  932. if ( !$this->is_admin && !in_array( $action, array( 'delete', 'reports' ) ) ) {//check user privileges has access to action
  933. $action = 'reports';
  934. }
  935. switch ( $action ) :
  936. case 'delete' :
  937. case 'reports' :
  938. $this->rating_reports();
  939. break;
  940. case 'update-rating' :
  941. $this->update_rating();
  942. $this->rating_settings( $action );
  943. break;
  944. default :
  945. $this->rating_settings();
  946. endswitch;
  947. }
  948. ?>
  949. </div>
  950. <?php
  951. }
  952. function polls_table( $view = 'blog' ) {
  953. $page = 1;
  954. if ( isset( $_GET['paged'] ) )
  955. $page = absint($_GET['paged']);
  956. $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
  957. $polldaddy->reset();
  958. if( !$this->is_author )
  959. $view = '';
  960. if ( 'user' == $view )
  961. $polls_object = $polldaddy->get_polls( ( $page - 1 ) * 10 + 1, $page * 10 );
  962. else
  963. $polls_object = $polldaddy->get_polls_by_parent_id( ( $page - 1 ) * 10 + 1, $page * 10 );
  964. $this->parse_errors( $polldaddy );
  965. $this->print_errors();
  966. $polls = & $polls_object->poll;
  967. if( isset( $polls_object->_total ) )
  968. $total_polls = $polls_object->_total;
  969. else
  970. $total_polls = count( $polls );
  971. $class = '';
  972. $page_links = paginate_links( array(
  973. 'base' => add_query_arg( 'paged', '%#%' ),
  974. 'format' => '',
  975. 'total' => ceil( $total_polls / 10 ),
  976. 'current' => $page
  977. ) );
  978. if( $this->is_author ){ ?>
  979. <ul class="subsubsub">
  980. <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>
  981. <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>
  982. </ul>
  983. <?php } ?>
  984. <form method="post" action="">
  985. <?php if( $this->is_author ){ ?>
  986. <div class="tablenav">
  987. <div class="alignleft">
  988. <select name="action">
  989. <option selected="selected" value=""><?php _e( 'Actions', 'polldaddy' ); ?></option>
  990. <option value="delete"><?php _e( 'Delete', 'polldaddy' ); ?></option>
  991. <option value="close"><?php _e( 'Close', 'polldaddy' ); ?></option>
  992. <option value="open"><?php _e( 'Open', 'polldaddy' ); ?></option>
  993. </select>
  994. <input class="button-secondary action" type="submit" name="doaction" value="<?php _e( 'Apply', 'polldaddy' ); ?>" />
  995. <?php wp_nonce_field( 'action-poll_bulk' ); ?>
  996. </div>
  997. <div class="tablenav-pages"><?php echo $page_links; ?></div>
  998. </div>
  999. <br class="clear" />
  1000. <?php } ?>
  1001. <table class="widefat">
  1002. <thead>
  1003. <tr>
  1004. <th id="cb" class="manage-column column-cb check-column" scope="col" /><?php if( $this->is_author ){ ?><input type="checkbox" /><?php } ?></th>
  1005. <th id="title" class="manage-column column-title" scope="col"><?php _e( 'Poll', 'polldaddy' ); ?></th>
  1006. <th id="votes" class="manage-column column-vote num" scope="col"><?php _e( 'Votes', 'polldaddy' ); ?></th>
  1007. <th id="date" class="manage-column column-date" scope="col"><?php _e( 'Created', 'polldaddy' ); ?></th>
  1008. </tr>
  1009. </thead>
  1010. <tbody>
  1011. <?php
  1012. if ( $polls ) :
  1013. foreach ( $polls as $poll ) :
  1014. $poll_id = (int) $poll->_id;
  1015. $poll->___content = trim( strip_tags( $poll->___content ) );
  1016. if( strlen( $poll->___content ) == 0 ){
  1017. $poll->___content = '-- empty HTML tag --';
  1018. }
  1019. $poll_closed = (int) $poll->_closed;
  1020. if ( $this->is_author and $this->can_edit( $poll ) ) {
  1021. $edit_link = clean_url( add_query_arg( array( 'action' => 'edit', 'poll' => $poll_id, 'message' => false ) ) );
  1022. $delete_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete', 'poll' => $poll_id, 'message' => false ) ), "delete-poll_$poll_id" ) );
  1023. $open_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'open', 'poll' => $poll_id, 'message' => false ) ), "open-poll_$poll_id" ) );
  1024. $close_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'close', 'poll' => $poll_id, 'message' => false ) ), "close-poll_$poll_id" ) );
  1025. }
  1026. else {
  1027. $edit_link = false;
  1028. $delete_link = false;
  1029. $open_link = false;
  1030. $close_link = false;
  1031. }
  1032. $class = $class ? '' : ' class="alternate"';
  1033. $results_link = clean_url( add_query_arg( array( 'action' => 'results', 'poll' => $poll_id, 'message' => false ) ) );
  1034. $preview_link = clean_url( add_query_arg( array( 'action' => 'preview', 'poll' => $poll_id, 'message' => false ) ) ); //, 'iframe' => '', 'TB_iframe' => 'true' ) ) );
  1035. list($poll_time) = explode( '.', $poll->_created );
  1036. $poll_time = strtotime( $poll_time );
  1037. ?>
  1038. <tr<?php echo $class; ?>>
  1039. <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>
  1040. <td class="post-title column-title">
  1041. <?php if ( $edit_link ) { ?>
  1042. <strong><a class="row-title" href="<?php echo $edit_link; ?>"><?php echo wp_specialchars( $poll->___content ); ?></a></strong>
  1043. <div class="row-actions">
  1044. <span class="edit"><a href="<?php echo $edit_link; ?>"><?php _e( 'Edit', 'polldaddy' ); ?></a> | </span>
  1045. <?php } else { ?>
  1046. <strong><?php echo wp_specialchars( $poll->___content ); ?></strong>
  1047. <div class="row-actions">
  1048. <?php } ?>
  1049. <span class="results"><a href="<?php echo $results_link; ?>"><?php _e( 'Results', 'polldaddy' ); ?></a> | </span>
  1050. <?php if ( $delete_link ) { ?>
  1051. <span class="delete"><a class="delete-poll delete" href="<?php echo $delete_link; ?>"><?php _e( 'Delete', 'polldaddy' ); ?></a> | </span>
  1052. <?php }
  1053. if ( $poll_closed == 2 ) {
  1054. if ( $open_link ) { ?>
  1055. <span class="open"><a class="open-poll" href="<?php echo $open_link; ?>"><?php _e( 'Open', 'polldaddy' ); ?></a> | </span>
  1056. <?php } } else {
  1057. if ( $close_link ) { ?>
  1058. <span class="close"><a class="close-poll" href="<?php echo $close_link; ?>"><?php _e( 'Close', 'polldaddy' ); ?></a> | </span>
  1059. <?php } } ?>
  1060. <?php if ( isset( $_GET['iframe'] ) ) { ?>
  1061. <span class="view"><a href="<?php echo $preview_link; ?>"><?php _e( 'Preview', 'polldaddy' ); ?></a> | </span>
  1062. <span class="editor">
  1063. <a href="#" class="polldaddy-send-to-editor"><?php _e( 'Send to editor', 'polldaddy' ); ?></a>
  1064. <input type="hidden" class="polldaddy-poll-id hack" value="<?php echo (int) $poll_id; ?>" /> |
  1065. </span>
  1066. <?php } else { ?>
  1067. <span class="view"><a class="thickbox" href="<?php echo $preview_link; ?>"><?php _e( 'Preview', 'polldaddy' ); ?></a> | </span>
  1068. <?php } ?>
  1069. <span class="shortcode"><a href="#" class="polldaddy-show-shortcode"><?php _e( 'Share-Embed', 'polldaddy' ); ?></a></span>
  1070. <?php $this->poll_table_add_option( $poll_id ); ?>
  1071. </div>
  1072. </td>
  1073. <td class="poll-votes column-vote num"><?php echo number_format_i18n( $poll->_responses ); ?></td>
  1074. <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>
  1075. </tr>
  1076. <tr class="polldaddy-shortcode-row" style="display: none;">
  1077. <td colspan="4">
  1078. <h4><?php _e( 'WordPress Shortcode', 'polldaddy' ); ?></h4>
  1079. <input type="text" readonly="readonly" style="width: 175px;" onclick="this.select();" value="[polldaddy poll=<?php echo (int) $poll_id; ?>]"/>
  1080. <h4><?php _e( 'JavaScript', 'polldaddy' ); ?></h4>
  1081. <pre>&lt;script type="text/javascript" language="javascript"
  1082. src="http://static.polldaddy.com/p/<?php echo (int) $poll_id; ?>.js"&gt;&lt;/script&gt;
  1083. &lt;noscript&gt;
  1084. &lt;a href="http://polldaddy.com/poll/<?php echo (int) $poll_id; ?>/"&gt;<?php echo trim( strip_tags( $poll->___content ) ); ?>&lt;/a&gt;&lt;br/&gt;
  1085. &lt;span style="font:9px;"&gt;(&lt;a href="http://www.polldaddy.com"&gt;polls&lt;/a&gt;)&lt;/span&gt;
  1086. &lt;/noscript&gt;</pre>
  1087. <h4><?php _e( 'Short URL (Good for Twitter etc.)', 'polldaddy' ); ?></h4>
  1088. <input type="text" readonly="readonly" style="width: 175px;" onclick="this.select();" value="http://poll.fm/<?php echo base_convert( $poll_id, 10, 36 ); ?>"/>
  1089. <h4><?php _e( 'Facebook URL', 'polldaddy' ); ?></h4>
  1090. <input type="text" readonly="readonly" style="width: 175px;" onclick="this.select();" value="http://poll.fm/f/<?php echo base_convert( $poll_id, 10, 36 ); ?>"/>
  1091. </td>
  1092. </tr>
  1093. <?php
  1094. endforeach;
  1095. elseif ( $total_polls ) : // $polls
  1096. ?>
  1097. <tr>
  1098. <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>
  1099. </tr>
  1100. <?php
  1101. else : // $polls
  1102. ?>
  1103. <tr>
  1104. <td colspan="4"><?php
  1105. if( $this->is_author )
  1106. printf( __( 'No polls yet. <a href="%s">Create one</a>', 'polldaddy' ), clean_url( add_query_arg( array( 'action' => 'create-poll' ) ) ) );
  1107. else
  1108. _e( 'No polls yet.', 'polldaddy' ); ?></td>
  1109. </tr>
  1110. <?php endif; // $polls ?>
  1111. </tbody>
  1112. </table>
  1113. <?php $this->poll_table_extra(); ?>
  1114. </form>
  1115. <div class="tablenav">
  1116. <div class="tablenav-pages"><?php echo $page_links; ?></div>
  1117. </div>
  1118. <br class="clear" />
  1119. <script language="javascript">
  1120. jQuery( document ).ready(function(){
  1121. plugin = new Plugin( {
  1122. delete_rating: '<?php _e( 'Are you sure you want to delete the rating for "%s"?','polldaddy'); ?>',
  1123. delete_poll: '<?php _e( 'Are you sure you want to delete "%s"?','polldaddy'); ?>',
  1124. delete_answer: '<?php _e( 'Are you sure you want to delete this answer?','polldaddy'); ?>',
  1125. delete_answer_title: '<?php _e( 'delete this answer','polldaddy'); ?>',
  1126. standard_styles: '<?php _e( 'Standard Styles','polldaddy'); ?>',
  1127. custom_styles: '<?php _e( 'Custom Styles','polldaddy'); ?>'
  1128. } );
  1129. });
  1130. </script>
  1131. <?php
  1132. }
  1133. function poll_table_add_option(){}
  1134. function poll_table_extra(){}
  1135. function poll_edit_form( $poll_id = 1 ) {
  1136. $poll_id = (int) $poll_id;
  1137. $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
  1138. $polldaddy->reset();
  1139. $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
  1140. if ( $poll_id ) {
  1141. $poll = $polldaddy->get_poll( $poll_id );
  1142. $this->parse_errors( $polldaddy );
  1143. if ( !$this->can_edit( $poll ) ) {
  1144. $this->errors->add( 'permission', __( 'You are not allowed to edit this poll.', 'polldaddy' ) );
  1145. }
  1146. if( $poll_id == 1 ){
  1147. $poll->answers = array();
  1148. $poll_id = 0;
  1149. }
  1150. } else {
  1151. $poll = polldaddy_poll( array(), null, false );
  1152. }
  1153. $question = $is_POST ? attribute_escape( stripslashes( $_POST['question'] ) ) : attribute_escape( $poll->question );
  1154. $this->print_errors();
  1155. ?>
  1156. <form action="" method="post">
  1157. <div id="poststuff"><div id="post-body" class="has-sidebar has-right-sidebar">
  1158. <div class="inner-sidebar" id="side-info-column">
  1159. <div id="submitdiv" class="postbox">
  1160. <h3><?php _e( 'Publish', 'polldaddy' ); ?></h3>
  1161. <div class="inside">
  1162. <div id="major-publishing-actions">
  1163. <p id="publishing-action">
  1164. <?php wp_nonce_field( $poll_id ? "edit-poll_$poll_id" : 'create-poll' ); ?>
  1165. <input type="hidden" name="action" value="<?php echo $poll_id ? 'edit-poll' : 'create-poll'; ?>" />
  1166. <input type="hidden" class="polldaddy-poll-id" name="poll" value="<?php echo $poll_id; ?>" />
  1167. <input type="submit" class="button-primary" value="<?php echo attribute_escape( __( 'Save Poll', 'polldaddy' ) ); ?>" />
  1168. <?php if ( isset( $_GET['iframe'] ) && $poll_id ) : ?>
  1169. <input type="button" class="button polldaddy-send-to-editor" value="<?php echo attribute_escape( __( 'Send to Editor', 'polldaddy' ) ); ?>" />
  1170. <?php endif; ?>
  1171. </p>
  1172. <br class="clear" />
  1173. </div>
  1174. </div>
  1175. </div>
  1176. <div class="postbox">
  1177. <h3><?php _e( 'Poll results', 'polldaddy' ); ?></h3>
  1178. <div class="inside">
  1179. <ul class="poll-options">
  1180. <?php
  1181. foreach ( array( 'show' => __( 'Show results to voters', 'polldaddy' ), 'percent' => __( 'Only show percentages', 'polldaddy' ), 'hide' => __( 'Hide all results', 'polldaddy' ) ) as $value => $label ) :
  1182. if ( $is_POST )
  1183. $checked = $value === $_POST['resultsType'] ? ' checked="checked"' : '';
  1184. else
  1185. $checked = $value === $poll->resultsType ? ' checked="checked"' : '';
  1186. ?>
  1187. <li>
  1188. <label for="resultsType-<?php echo $value; ?>"><input type="radio"<?php echo $checked; ?> value="<?php echo $value; ?>" name="resultsType" id="resultsType-<?php echo $value; ?>" /> <?php echo wp_specialchars( $label ); ?></label>
  1189. </li>
  1190. <?php endforeach; ?>
  1191. </ul>
  1192. </div>
  1193. </div>
  1194. <div class="postbox">
  1195. <h3><?php _e( 'Block repeat voters', 'polldaddy' ); ?></h3>
  1196. <div class="inside">
  1197. <ul class="poll-options">
  1198. <?php
  1199. 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 ) :
  1200. if ( $is_POST )
  1201. $checked = $value === $_POST['blockRepeatVotersType'] ? ' checked="checked"' : '';
  1202. else
  1203. $checked = $value === $poll->blockRepeatVotersType ? ' checked="checked"' : '';
  1204. ?>
  1205. <li>
  1206. <label for="blockRepeatVotersType-<?php echo $value; ?>"><input class="block-repeat" type="radio"<?php echo $checked; ?> value="<?php echo $value; ?>" name="blockRepeatVotersType" id="blockRepeatVotersType-<?php echo $value; ?>" /> <?php echo wp_specialchars( $label ); ?></label>
  1207. </li>
  1208. <?php endforeach; ?>
  1209. </ul>
  1210. <span style="margin:6px 6px 8px;" id="cookieip_expiration_label"><label><?php _e( 'Expires: ', 'polldaddy' ); ?></label></span>
  1211. <select id="cookieip_expiration" name="cookieip_expiration" style="width: auto;<?php echo $poll->blockRepeatVotersType == 'off' ? 'display:none;' : ''; ?>">
  1212. <option value="0" <?php echo (int) $poll->blockExpiration == 0 ? 'selected' : ''; ?>><?php _e( 'Never', 'polldaddy' ); ?></option>
  1213. <option value="3600" <?php echo (int) $poll->blockExpiration == 3600 ? 'selected' : ''; ?>><?php printf( __('%d hour', 'polldaddy'), 1 ); ?></option>
  1214. <option value="10800" <?php echo (int) $poll->blockExpiration == 10800 ? 'selected' : ''; ?>><?php printf( __('%d hours', 'polldaddy'), 3 ); ?></option>
  1215. <option value="21600" <?php echo (int) $poll->blockExpiration == 21600 ? 'selected' : ''; ?>><?php printf( __('%d hours', 'polldaddy'), 6 ); ?></option>
  1216. <option value="43200" <?php echo (int) $poll->blockExpiration == 43200 ? 'selected' : ''; ?>><?php printf( __('%d hours', 'polldaddy'), 12 ); ?></option>
  1217. <option value="86400" <?php echo (int) $poll->blockExpiration == 86400 ? 'selected' : ''; ?>><?php printf( __('%d day', 'polldaddy'), 1 ); ?></option>
  1218. <option value="604800" <?php echo (int) $poll->blockExpiration == 604800 ? 'selected' : ''; ?>><?php printf( __('%d week', 'polldaddy'), 1 ); ?></option>
  1219. <option value="2419200" <?php echo (int) $poll->blockExpiration == 2419200 ? 'selected' : ''; ?>><?php printf( __('%d month', 'polldaddy'), 1 ); ?></option>
  1220. </select>
  1221. <p><?php _e( 'Note: Blocking by cookie and IP address can be problematic for some voters.', 'polldaddy'); ?></p>
  1222. </div>
  1223. </div>
  1224. </div>
  1225. <div id="post-body-content" class="has-sidebar-content">
  1226. <div id="titlediv">
  1227. <div id="titlewrap">
  1228. <input type="text" autocomplete="off" id="title" value="<?php echo $question; ?>" tabindex="1" size="30" name="question" />
  1229. </div>
  1230. </div>
  1231. <div id="answersdiv" class="postbox">
  1232. <h3><?php _e( 'Answers', 'polldaddy' ); ?></h3>
  1233. <div id="answerswrap" class="inside">
  1234. <ul id="answers">
  1235. <?php
  1236. $a = 0;
  1237. $answers = array();
  1238. if ( $is_POST && $_POST['answer'] ) {
  1239. foreach( $_POST['answer'] as $answer_id => $answer )
  1240. $answers[attribute_escape($answer_id)] = attribute_escape( stripslashes($answer) );
  1241. } elseif ( isset( $poll->answers->answer ) ) {
  1242. foreach ( $poll->answers->answer as $answer )
  1243. $answers[(int) $answer->_id] = attribute_escape( $answer->text );
  1244. }
  1245. foreach ( $answers as $answer_id => $answer ) :
  1246. $a++;
  1247. $delete_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete-answer', 'poll' => $poll_id, 'answer' => $answer_id, 'message' => false ) ), "delete-answer_$answer_id" ) );
  1248. ?>
  1249. <li>
  1250. <span class="handle" title="<?php echo attribute_escape( 'click and drag to move' ); ?>">&#x2195;</span>
  1251. <div><input type="text" autocomplete="off" id="answer-<?php echo $answer_id; ?>" value="<?php echo $answer; ?>" tabindex="2" size="30" name="answer[<?php echo $answer_id; ?>]" /></div>
  1252. <a href="<?php echo $delete_link; ?>" class="delete-answer delete" title="<?php echo attribute_escape( 'delete this answer' ); ?>">&times;</a>
  1253. </li>
  1254. <?php
  1255. endforeach;
  1256. while ( 3 - $a > 0 ) :
  1257. $a++;
  1258. ?>
  1259. <li>
  1260. <span class="handle" title="<?php echo attribute_escape( 'click and drag to move' ); ?>">&#x2195;</span>
  1261. <div><input type="text" autocomplete="off" value="" tabindex="2" size="30" name="answer[new<?php echo $a; ?>]" /></div>
  1262. <a href="#" class="delete-answer delete" title="<?php echo attribute_escape( 'delete this answer' ); ?>">&times;</a>
  1263. </li>
  1264. <?php
  1265. endwhile;
  1266. ?>
  1267. </ul>
  1268. <p id="add-answer-holder">
  1269. <button class="button"><?php echo wp_specialchars( __( 'Add another', 'polldaddy' ) ); ?></button>
  1270. </p>
  1271. <ul id="answer-options">
  1272. <?php
  1273. foreach ( array( 'multipleChoice' => __( 'Multiple choice', 'polldaddy' ), 'randomiseAnswers' => __( 'Randomize answer order', 'polldaddy' ), 'otherAnswer' => __( 'Allow other answers', 'polldaddy' ), 'sharing' => __( "'Share This' link", 'polldaddy' ) ) as $option => $label ) :
  1274. if ( $is_POST )
  1275. $checked = 'yes' === $_POST[$option] ? ' checked="checked"' : '';
  1276. else
  1277. $checked = 'yes' === $poll->$option ? ' checked="checked"' : '';
  1278. ?>
  1279. <li>
  1280. <label for="<?php echo $option; ?>"><input type="checkbox"<?php echo $checked; ?> value="yes" id="<?php echo $option; ?>" name="<?php echo $option; ?>" /> <?php echo wp_specialchars( $label ); ?></label>
  1281. </li>
  1282. <?php endforeach; ?>
  1283. </ul>
  1284. <?php
  1285. if ( $is_POST )
  1286. $style = 'yes' === $_POST['multipleChoice'] ? 'display:block;' : 'display:none;';
  1287. else
  1288. $style = 'yes' === $poll->multipleChoice ? 'display:block;' : 'display:none;';
  1289. ?>
  1290. <div id="numberChoices" name="numberChoices" style="padding-left:15px;<?php echo $style; ?>">
  1291. <p>Number of choices: <select name="choices" id="choices"><option value="0">No Limit</option>
  1292. <?php
  1293. if ( $is_POST )
  1294. $choices = (int) $_POST['choices'];
  1295. else
  1296. $choices = (int) $poll->choices;
  1297. if( $a > 1 ) :
  1298. for( $i=2; $i<=$a; $i++ ) :
  1299. $selected = $i == $choices ? 'selected="true"' : '';
  1300. echo "<option value='$i' $selected>$i</option>";
  1301. endfor;
  1302. endif; ?>
  1303. </select>
  1304. </p>
  1305. </div>
  1306. </div>
  1307. </div>
  1308. <div id="design" class="postbox">
  1309. <?php $style_ID = (int) ( $is_POST ? $_POST['styleID'] : $poll->styleID );
  1310. $iframe_view = false;
  1311. if ( isset($_GET['iframe']) )
  1312. $iframe_view = true;
  1313. $options = array(
  1314. 101 => __( 'Aluminum Narrow','polldaddy'),
  1315. 102 => __( 'Aluminum Medium','polldaddy'),
  1316. 103 => __( 'Aluminum Wide','polldaddy'),
  1317. 104 => __( 'Plain White Narrow','polldaddy'),
  1318. 105 => __( 'Plain White Medium','polldaddy'),
  1319. 106 => __( 'Plain White Wide','polldaddy'),
  1320. 107 => __( 'Plain Black Narrow','polldaddy'),
  1321. 108 => __( 'Plain Black Medium','polldaddy'),
  1322. 109 => __( 'Plain Black Wide','polldaddy'),
  1323. 110 => __( 'Paper Narrow','polldaddy'),
  1324. 111 => __( 'Paper Medium','polldaddy'),
  1325. 112 => __( 'Paper Wide','polldaddy'),
  1326. 113 => __( 'Skull Dark Narrow','polldaddy'),
  1327. 114 => __( 'Skull Dark Medium','polldaddy'),
  1328. 115 => __( 'Skull Dark Wide','polldaddy'),
  1329. 116 => __( 'Skull Light Narrow','polldaddy'),
  1330. 117 => __( 'Skull Light Medium','polldaddy'),
  1331. 118 => __( 'Skull Light Wide','polldaddy'),
  1332. 157 => __( 'Micro','polldaddy'),
  1333. 119 => __( 'Plastic White Narrow','polldaddy'),
  1334. 120 => __( 'Plastic White Medium','polldaddy'),
  1335. 121 => __( 'Plastic White Wide','polldaddy'),
  1336. 122 => __( 'Plastic Grey Narrow','polldaddy'),
  1337. 123 => __( 'Plastic Grey Medium','polldaddy'),
  1338. 124 => __( 'Plastic Grey Wide','polldaddy'),
  1339. 125 => __( 'Plastic Black Narrow','polldaddy'),
  1340. 126 => __( 'Plastic Black Medium','polldaddy'),
  1341. 127 => __( 'Plastic Black Wide','polldaddy'),
  1342. 128 => __( 'Manga Narrow','polldaddy'),
  1343. 129 => __( 'Manga Medium','polldaddy'),
  1344. 130 => __( 'Manga Wide','polldaddy'),
  1345. 131 => __( 'Tech Dark Narrow','polldaddy'),
  1346. 132 => __( 'Tech Dark Medium','polldaddy'),
  1347. 133 => __( 'Tech Dark Wide','polldaddy'),
  1348. 134 => __( 'Tech Grey Narrow','polldaddy'),
  1349. 135 => __( 'Tech Grey Medium','polldaddy'),
  1350. 136 => __( 'Tech Grey Wide','polldaddy'),
  1351. 137 => __( 'Tech Light Narrow','polldaddy'),
  1352. 138 => __( 'Tech Light Medium','polldaddy'),
  1353. 139 => __( 'Tech Light Wide','polldaddy'),
  1354. 140 => __( 'Working Male Narrow','polldaddy'),
  1355. 141 => __( 'Working Male Medium','polldaddy'),
  1356. 142 => __( 'Working Male Wide','polldaddy'),
  1357. 143 => __( 'Working Female Narrow','polldaddy'),
  1358. 144 => __( 'Working Female Medium','polldaddy'),
  1359. 145 => __( 'Working Female Wide','polldaddy'),
  1360. 146 => __( 'Thinking Male Narrow','polldaddy'),
  1361. 147 => __( 'Thinking Male Medium','polldaddy'),
  1362. 148 => __( 'Thinking Male Wide','polldaddy'),
  1363. 149 => __( 'Thinking Female Narrow','polldaddy'),
  1364. 150 => __( 'Thinking Female Medium','polldaddy'),
  1365. 151 => __( 'Thinking Female Wide','polldaddy'),
  1366. 152 => __( 'Sunset Narrow','polldaddy'),
  1367. 153 => __( 'Sunset Medium','polldaddy'),
  1368. 154 => __( 'Sunset Wide','polldaddy'),
  1369. 155 => __( 'Music Medium','polldaddy'),
  1370. 156 => __( 'Music Wide','polldaddy')
  1371. );
  1372. $polldaddy->reset();
  1373. $styles = $polldaddy->get_styles();
  1374. $show_custom = false;
  1375. if( !empty( $styles ) && !empty( $styles->style ) && count( $styles->style ) > 0 ){
  1376. foreach( (array) $styles->style as $style ){
  1377. $options[ (int) $style->_id ] = $style->title;
  1378. }
  1379. $show_custom = true;
  1380. }
  1381. if ( $style_ID > 18 ){
  1382. $standard_style_ID = 0;
  1383. $custom_style_ID = $style_ID;
  1384. }
  1385. else{
  1386. $standard_style_ID = $style_ID;
  1387. $custom_style_ID = 0;
  1388. }
  1389. ?>
  1390. <h3><?php _e( 'Design', 'polldaddy' ); ?></h3>
  1391. <input type="hidden" name="styleID" id="styleID" value="<?php echo $style_ID ?>">
  1392. <div class="inside">
  1393. <?php if ( $iframe_view ){ ?>
  1394. <div id="design_standard" style="padding:0px;">
  1395. <div class="hide-if-no-js">
  1396. <table class="pollStyle">
  1397. <thead>
  1398. <tr>
  1399. <th>
  1400. <div style="display:none;">
  1401. <input type="radio" name="styleTypeCB" id="regular" onclick="javascript:pd_build_styles( 0 );"/>
  1402. </div>
  1403. </th>
  1404. </tr>
  1405. </thead>
  1406. <tr>
  1407. <td class="selector">
  1408. <table class="st_selector">
  1409. <tr>
  1410. <td class="dir_left">
  1411. <a href="javascript:pd_move('prev');" style="width: 1em;display: block;font-size: 4em;text-decoration: none;">&#171;</a>
  1412. </td>
  1413. <td class="img"><div class="st_image_loader"><div id="st_image" onmouseover="st_results(this, 'show');" onmouseout="st_results(this, 'hide');"></div></div></td>
  1414. <td class="dir_right">
  1415. <a href="javascript:pd_move('next');" style="width: 1em;display: block;font-size: 4em;text-decoration: none;">&#187;</a>
  1416. </td>
  1417. </tr>
  1418. <tr>
  1419. <td></td>
  1420. <td class="counter">
  1421. <div id="st_number"></div>
  1422. </td>
  1423. <td></td>
  1424. </tr>
  1425. <tr>
  1426. <td></td>
  1427. <td class="title">
  1428. <div id="st_name"></div>
  1429. </td>
  1430. <td></td>
  1431. </tr>
  1432. <tr>
  1433. <td></td>
  1434. <td>
  1435. <div id="st_sizes"></div>
  1436. </td>
  1437. <td></td>
  1438. </tr>
  1439. <tr>
  1440. <td colspan="3">
  1441. <div id="st_description"></div>
  1442. </td>
  1443. </tr>
  1444. </table>
  1445. </td>
  1446. </tr>
  1447. </table>
  1448. </div>
  1449. <p class="empty-if-js" id="no-js-styleID">
  1450. <select id="styleID" name="styleID">
  1451. <?php foreach ( $options as $styleID => $label ) :
  1452. $selected = $styleID == $style_ID ? ' selected="selected"' : ''; ?>
  1453. <option value="<?php echo (int) $styleID; ?>"<?php echo $selected; ?>><?php echo wp_specialchars( $label ); ?></option>
  1454. <?php endforeach; ?>
  1455. </select>
  1456. </p>
  1457. </div>
  1458. <?php if ( $show_custom ){ ?>
  1459. <div id="design_custom">
  1460. <p class="hide-if-no-js">
  1461. <table class="pollStyle">
  1462. <thead>
  1463. <tr>
  1464. <th>
  1465. <div style="display:none;">
  1466. <?php $disabled = $show_custom == false ? ' disabled="true"' : ''; ?>
  1467. <input type="radio" name="styleTypeCB" id="custom" onclick="javascript:pd_change_style(_$('customSelect').value);" <?php echo $disabled; ?>></input>
  1468. <label onclick="javascript:pd_change_style(_$('customSelect').value);"><?php _e( 'Custom Style', 'polldaddy' ); ?></label>
  1469. </div>
  1470. </th>
  1471. </tr>
  1472. </thead>
  1473. <tbody>
  1474. <tr>
  1475. <td class="customSelect">
  1476. <table>
  1477. <tr>
  1478. <td><?php $hide = $show_custom == true ? ' style="display:block;"' : ' style="display:none;"'; ?>
  1479. <select id="customSelect" name="customSelect" onclick="pd_change_style(this.value);" <?php echo $hide ?>>
  1480. <?php $selected = $custom_style_ID == 0 ? ' selected="selected"' : ''; ?>
  1481. <option value="x"<?php echo $selected; ?>><?php _e( 'Please choose a custom style...', 'polldaddy' ); ?></option>
  1482. <?php if( $show_custom) : foreach ( (array)$styles->style as $style ) :
  1483. $selected = $style->_id == $custom_style_ID ? ' selected="selected"' : ''; ?>
  1484. <option value="<?php echo (int) $style->_id; ?>"<?php echo $selected; ?>><?php echo wp_specialchars( $style->title ); ?></option>
  1485. <?php endforeach; endif; ?>
  1486. </select>
  1487. <div id="styleIDErr" class="formErr" style="display:none;"><?php _e( 'Please choose a style.', 'polldaddy' ); ?></div></td>
  1488. </tr>
  1489. <tr>
  1490. <td><?php $extra = $show_custom == false ? __( 'You currently have no custom styles created.', 'polldaddy') : ''; ?>
  1491. <p><?php echo $extra ?></p>
  1492. <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>
  1493. </td>
  1494. </tr>
  1495. </table>
  1496. </td>
  1497. </tr>
  1498. </tbody>
  1499. </table>
  1500. </p>
  1501. </div>
  1502. <div id="design_options">
  1503. <a href="#" class="polldaddy-show-design-options"><?php _e( 'Custom Styles', 'polldaddy' ); ?></a>
  1504. </div>
  1505. <?php }}else{?>
  1506. <div class="design_standard">
  1507. <div class="hide-if-no-js">
  1508. <table class="pollStyle">
  1509. <thead>
  1510. <tr>
  1511. <th class="cb">
  1512. <input type="radio" name="styleTypeCB" id="regular" onclick="javascript:pd_build_styles( 0 );"/>
  1513. </th>
  1514. <th>
  1515. <label for="skin" onclick="javascript:pd_build_styles( 0 );"><?php _e( 'PollDaddy Style', 'polldaddy' ); ?></label>
  1516. </th>
  1517. <th/>
  1518. <th class="cb">
  1519. <?php $disabled = $show_custom == false ? ' disabled="true"' : ''; ?>
  1520. <input type="radio" name="styleTypeCB" id="custom" onclick="javascript:pd_change_style(_$('customSelect').value);" <?php echo $disabled; ?>></input>
  1521. </th>
  1522. <th>
  1523. <label onclick="javascript:pd_change_style(_$('customSelect').value);"><?php _e( 'Custom Style', 'polldaddy' ); ?></label>
  1524. </th>
  1525. </tr>
  1526. </thead>
  1527. <tbody>
  1528. <tr>
  1529. <td/>
  1530. <td class="selector">
  1531. <table class="st_selector">
  1532. <tr>
  1533. <td class="dir_left">
  1534. <a href="javascript:pd_move('prev');" style="width: 1em;display: block;font-size: 4em;text-decoration: none;">&#171;</a>
  1535. </td>
  1536. <td class="img"><div class="st_image_loader"><div id="st_image" onmouseover="st_results(this, 'show');" onmouseout="st_results(this, 'hide');"></div></div></td>
  1537. <td class="dir_right">
  1538. <a href="javascript:pd_move('next');" style="width: 1em;display: block;font-size: 4em;text-decoration: none;">&#187;</a>
  1539. </td>
  1540. </tr>
  1541. <tr>
  1542. <td></td>
  1543. <td class="counter">
  1544. <div id="st_number"></div>
  1545. </td>
  1546. <td></td>
  1547. </tr>
  1548. <tr>
  1549. <td></td>
  1550. <td class="title">
  1551. <div id="st_name"></div>
  1552. </td>
  1553. <td></td>
  1554. </tr>
  1555. <tr>
  1556. <td></td>
  1557. <td>
  1558. <div id="st_sizes"></div>
  1559. </td>
  1560. <td></td>
  1561. </tr>
  1562. <tr>
  1563. <td colspan="3">
  1564. <div id="st_description"></div>
  1565. </td>
  1566. </tr>
  1567. </table>
  1568. </td>
  1569. <td width="100"></td>
  1570. <td/>
  1571. <td class="customSelect">
  1572. <table>
  1573. <tr>
  1574. <td><?php $hide = $show_custom == true ? ' style="display:block;"' : ' style="display:none;"'; ?>
  1575. <select id="customSelect" name="customSelect" onclick="pd_change_style(this.value);" <?php echo $hide ?>>
  1576. <?php $selected = $custom_style_ID == 0 ? ' selected="selected"' : ''; ?>
  1577. <option value="x"<?php echo $selected; ?>><?php _e( 'Please choose a custom style...', 'polldaddy'); ?></option>
  1578. <?php if( $show_custom) : foreach ( (array)$styles->style as $style ) :
  1579. $selected = $style->_id == $custom_style_ID ? ' selected="selected"' : ''; ?>
  1580. <option value="<?php echo (int) $style->_id; ?>"<?php echo $selected; ?>><?php echo wp_specialchars( $style->title ); ?></option>
  1581. <?php endforeach; endif;?>
  1582. </select>
  1583. <div id="styleIDErr" class="formErr" style="display:none;"><?php _e( 'Please choose a style.', 'polldaddy'); ?></div></td>
  1584. </tr>
  1585. <tr>
  1586. <td><?php $extra = $show_custom == false ? __( 'You currently have no custom styles created.', 'polldaddy' ) : ''; ?>
  1587. <p><?php echo $extra ?></p>
  1588. <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>
  1589. </td>
  1590. </tr>
  1591. </table>
  1592. </td>
  1593. </tr>
  1594. </tbody>
  1595. </table>
  1596. </div>
  1597. <p class="empty-if-js" id="no-js-styleID">
  1598. <select id="styleID" name="styleID">
  1599. <?php foreach ( $options as $styleID => $label ) :
  1600. $selected = $styleID == $style_ID ? ' selected="selected"' : ''; ?>
  1601. <option value="<?php echo (int) $styleID; ?>"<?php echo $selected; ?>><?php echo wp_specialchars( $label ); ?></option>
  1602. <?php endforeach; ?>
  1603. </select>
  1604. </p>
  1605. </div>
  1606. <?php } ?>
  1607. <script language="javascript">
  1608. jQuery( document ).ready(function(){
  1609. plugin = new Plugin( {
  1610. delete_rating: '<?php _e( 'Are you sure you want to delete the rating for "%s"?','polldaddy'); ?>',
  1611. delete_poll: '<?php _e( 'Are you sure you want to delete "%s"?','polldaddy'); ?>',
  1612. delete_answer: '<?php _e( 'Are you sure you want to delete this answer?','polldaddy'); ?>',
  1613. delete_answer_title: '<?php _e( 'delete this answer','polldaddy'); ?>',
  1614. standard_styles: '<?php _e( 'Standard Styles','polldaddy'); ?>',
  1615. custom_styles: '<?php _e( 'Custom Styles','polldaddy'); ?>'
  1616. } );
  1617. });
  1618. </script>
  1619. <script language="javascript">
  1620. current_pos = 0;
  1621. for( var key in styles_array ) {
  1622. var name = styles_array[key].name;
  1623. switch( name ){
  1624. case 'Aluminum':
  1625. styles_array[key].name = '<?php _e( 'Aluminum', 'polldaddy' ); ?>';
  1626. break;
  1627. case 'Plain White':
  1628. styles_array[key].name = '<?php _e( 'Plain White', 'polldaddy' ); ?>';
  1629. break;
  1630. case 'Plain Black':
  1631. styles_array[key].name = '<?php _e( 'Plain Black', 'polldaddy' ); ?>';
  1632. break;
  1633. case 'Paper':
  1634. styles_array[key].name = '<?php _e( 'Paper', 'polldaddy' ); ?>';
  1635. break;
  1636. case 'Skull Dark':
  1637. styles_array[key].name = '<?php _e( 'Skull Dark', 'polldaddy' ); ?>';
  1638. break;
  1639. case 'Skull Light':
  1640. styles_array[key].name = '<?php _e( 'Skull Light', 'polldaddy' ); ?>';
  1641. break;
  1642. case 'Micro':
  1643. styles_array[key].name = '<?php _e( 'Micro', 'polldaddy' ); ?>';
  1644. styles_array[key].n_desc = '<?php _e( 'Width 150px, the micro style is useful when space is tight.', 'polldaddy' ); ?>';
  1645. break;
  1646. case 'Plastic White':
  1647. styles_array[key].name = '<?php _e( 'Plastic White', 'polldaddy' ); ?>';
  1648. break;
  1649. case 'Plastic Grey':
  1650. styles_array[key].name = '<?php _e( 'Plastic Grey', 'polldaddy' ); ?>';
  1651. break;
  1652. case 'Plastic Black':
  1653. styles_array[key].name = '<?php _e( 'Plastic Black', 'polldaddy' ); ?>';
  1654. break;
  1655. case 'Manga':
  1656. styles_array[key].name = '<?php _e( 'Manga', 'polldaddy' ); ?>';
  1657. break;
  1658. case 'Tech Dark':
  1659. styles_array[key].name = '<?php _e( 'Tech Dark', 'polldaddy' ); ?>';
  1660. break;
  1661. case 'Tech Grey':
  1662. styles_array[key].name = '<?php _e( 'Tech Grey', 'polldaddy' ); ?>';
  1663. break;
  1664. case 'Tech Light':
  1665. styles_array[key].name = '<?php _e( 'Tech Light', 'polldaddy' ); ?>';
  1666. break;
  1667. case 'Working Male':
  1668. styles_array[key].name = '<?php _e( 'Working Male', 'polldaddy' ); ?>';
  1669. break;
  1670. case 'Working Female':
  1671. styles_array[key].name = '<?php _e( 'Working Female', 'polldaddy' ); ?>';
  1672. break;
  1673. case 'Thinking Male':
  1674. styles_array[key].name = '<?php _e( 'Thinking Male', 'polldaddy' ); ?>';
  1675. break;
  1676. case 'Thinking Female':
  1677. styles_array[key].name = '<?php _e( 'Thinking Female', 'polldaddy' ); ?>';
  1678. break;
  1679. case 'Sunset':
  1680. styles_array[key].name = '<?php _e( 'Sunset', 'polldaddy' ); ?>';
  1681. break;
  1682. case 'Music':
  1683. styles_array[key].name = '<?php _e( 'Music', 'polldaddy' ); ?>';
  1684. break;
  1685. }
  1686. }
  1687. pd_map = {
  1688. wide : '<?php _e( 'Wide', 'polldaddy' ); ?>',
  1689. medium : '<?php _e( 'Medium', 'polldaddy' ); ?>',
  1690. narrow : '<?php _e( 'Narrow', 'polldaddy' ); ?>',
  1691. style_desc_wide : '<?php _e( 'Width: 630px, the wide style is good for blog posts.', 'polldaddy' ); ?>',
  1692. style_desc_medium : '<?php _e( 'Width: 300px, the medium style is good for general use.', 'polldaddy' ); ?>',
  1693. style_desc_narrow : '<?php _e( 'Width 150px, the narrow style is good for sidebars etc.', 'polldaddy' ); ?>',
  1694. style_desc_micro : '<?php _e( 'Width 150px, the micro style is useful when space is tight.', 'polldaddy' ); ?>'
  1695. }
  1696. pd_build_styles( current_pos );
  1697. <?php if( $style_ID > 0 && $style_ID <= 1000 ){ ?>
  1698. pd_pick_style( <?php echo $style_ID ?> );
  1699. <?php }else{ ?>
  1700. pd_change_style( <?php echo $style_ID ?> );
  1701. <?php } ?>
  1702. </script>
  1703. </div>
  1704. </div>
  1705. </div>
  1706. </div></div>
  1707. </form>
  1708. <br class="clear" />
  1709. <?php
  1710. }
  1711. function poll_results_page( $poll_id ) {
  1712. $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
  1713. $polldaddy->reset();
  1714. $results = $polldaddy->get_poll_results( $poll_id );
  1715. ?>
  1716. <table class="poll-results widefat">
  1717. <thead>
  1718. <tr>
  1719. <th scope="col" class="column-title"><?php _e( 'Answer', 'polldaddy' ); ?></th>
  1720. <th scope="col" class="column-vote"><?php _e( 'Votes', 'polldaddy' ); ?></th>
  1721. </tr>
  1722. </thead>
  1723. <tbody>
  1724. <?php
  1725. $class = '';
  1726. foreach ( $results->answers as $answer ) :
  1727. $answer->text = trim( strip_tags( $answer->text ) );
  1728. if( strlen( $answer->text ) == 0 ){
  1729. $answer->text = '-- empty HTML tag --';
  1730. }
  1731. $class = $class ? '' : ' class="alternate"';
  1732. $content = $results->others && 'Other answer...' === $answer->text ? sprintf( __( 'Other (<a href="%s">see below</a>)', 'polldaddy' ), '#other-answers-results' ) : wp_specialchars( $answer->text );
  1733. ?>
  1734. <tr<?php echo $class; ?>>
  1735. <th scope="row" class="column-title"><?php echo $content; ?></th>
  1736. <td class="column-vote">
  1737. <div class="result-holder">
  1738. <span class="result-bar" style="width: <?php echo number_format( $answer->_percent, 2 ); ?>%;">&nbsp;</span>
  1739. <span class="result-total alignleft"><?php echo number_format_i18n( $answer->_total ); ?></span>
  1740. <span class="result-percent alignright"><?php echo number_format_i18n( $answer->_percent ); ?>%</span>
  1741. </div>
  1742. </td>
  1743. </tr>
  1744. <?php
  1745. endforeach;
  1746. ?>
  1747. </tbody>
  1748. </table>
  1749. <?php
  1750. if ( !$results->others )
  1751. return;
  1752. ?>
  1753. <table id="other-answers-results" class="poll-others widefat">
  1754. <thead>
  1755. <tr>
  1756. <th scope="col" class="column-title"><?php _e( 'Other Answer', 'polldaddy' ); ?></th>
  1757. <th scope="col" class="column-vote"><?php _e( 'Votes', 'polldaddy' ); ?></th>
  1758. </tr>
  1759. </thead>
  1760. <tbody>
  1761. <?php
  1762. $class = '';
  1763. $others = array_count_values( $results->others );
  1764. arsort( $others );
  1765. foreach ( $others as $other => $freq ) :
  1766. $class = $class ? '' : ' class="alternate"';
  1767. ?>
  1768. <tr<?php echo $class; ?>>
  1769. <th scope="row" class="column-title"><?php echo wp_specialchars( $other ); ?></th>
  1770. <td class="column-vote"><?php echo number_format_i18n( $freq ); ?></td>
  1771. </tr>
  1772. <?php
  1773. endforeach;
  1774. ?>
  1775. </tbody>
  1776. </table>
  1777. <?php
  1778. }
  1779. function styles_table() {
  1780. $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
  1781. $polldaddy->reset();
  1782. $styles_object = $polldaddy->get_styles();
  1783. $this->parse_errors( $polldaddy );
  1784. $this->print_errors();
  1785. $styles = & $styles_object->style;
  1786. $class = '';
  1787. $styles_exist = false;
  1788. foreach ( (array)$styles as $style ) :
  1789. if( (int) $style->_type == 1 ):
  1790. $styles_exist = true;
  1791. break;
  1792. endif;
  1793. endforeach;
  1794. ?>
  1795. <form method="post" action="">
  1796. <div class="tablenav">
  1797. <div class="alignleft">
  1798. <select name="action">
  1799. <option selected="selected" value=""><?php _e( 'Actions', 'polldaddy' ); ?></option>
  1800. <option value="delete-style"><?php _e( 'Delete', 'polldaddy' ); ?></option>
  1801. </select>
  1802. <input class="button-secondary action" type="submit" name="doaction" value="<?php _e( 'Apply', 'polldaddy' ); ?>" />
  1803. <?php wp_nonce_field( 'action-style_bulk' ); ?>
  1804. </div>
  1805. <div class="tablenav-pages"></div>
  1806. </div>
  1807. <br class="clear" />
  1808. <table class="widefat">
  1809. <thead>
  1810. <tr>
  1811. <th id="cb" class="manage-column column-cb check-column" scope="col" /><input type="checkbox" /></th>
  1812. <th id="title" class="manage-column column-title" scope="col"><?php _e( 'Style', 'polldaddy' ); ?></th>
  1813. <th id="date" class="manage-column column-date" scope="col"><?php _e( 'Last Modified', 'polldaddy' ); ?></th>
  1814. </tr>
  1815. </thead>
  1816. <tbody>
  1817. <?php
  1818. if ( $styles_exist ) :
  1819. foreach ( $styles as $style ) :
  1820. if( (int) $style->_type == 1 ):
  1821. $style_id = (int) $style->_id;
  1822. $class = $class ? '' : ' class="alternate"';
  1823. $edit_link = clean_url( add_query_arg( array( 'action' => 'edit-style', 'style' => $style_id, 'message' => false ) ) );
  1824. $delete_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete-style', 'style' => $style_id, 'message' => false ) ), "delete-style_$style_id" ) );
  1825. list($style_time) = explode( '.', $style->date );
  1826. $style_time = strtotime( $style_time );
  1827. ?>
  1828. <tr<?php echo $class; ?>>
  1829. <th class="check-column" scope="row"><input type="checkbox" value="<?php echo (int) $style_id; ?>" name="style[]" /></th>
  1830. <td class="post-title column-title">
  1831. <?php if ( $edit_link ) : ?>
  1832. <strong><a class="row-title" href="<?php echo $edit_link; ?>"><?php echo wp_specialchars( $style->title ); ?></a></strong>
  1833. <span class="edit"><a href="<?php echo $edit_link; ?>"><?php _e( 'Edit', 'polldaddy' ); ?></a> | </span>
  1834. <?php else : ?>
  1835. <strong><?php echo wp_specialchars( $style->title ); ?></strong>
  1836. <?php endif; ?>
  1837. <span class="delete"><a class="delete-poll delete" href="<?php echo $delete_link; ?>"><?php _e( 'Delete', 'polldaddy' ); ?></a></span>
  1838. </td>
  1839. <td class="date column-date"><abbr title="<?php echo date( __('Y/m/d g:i:s A', 'polldaddy'), $style_time ); ?>"><?php echo date( __('Y/m/d', 'polldaddy'), $style_time ); ?></abbr></td>
  1840. </tr>
  1841. <?php
  1842. endif;
  1843. endforeach;
  1844. else : // $styles
  1845. ?>
  1846. <tr>
  1847. <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>
  1848. </tr>
  1849. <?php endif; // $styles ?>
  1850. </tbody>
  1851. </table>
  1852. </form>
  1853. <div class="tablenav">
  1854. <div class="tablenav-pages"></div>
  1855. </div>
  1856. <br class="clear" />
  1857. <?php
  1858. }
  1859. function style_edit_form( $style_id = 105 ) {
  1860. $style_id = (int) $style_id;
  1861. $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
  1862. $polldaddy->reset();
  1863. $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
  1864. if ( $style_id ) {
  1865. $style = $polldaddy->get_style( $style_id );
  1866. $this->parse_errors( $polldaddy );
  1867. } else {
  1868. $style = polldaddy_style( array(), null, false );
  1869. }
  1870. $style->css = trim( urldecode( $style->css ) );
  1871. if ( $start = stripos( $style->css, '<data>' ) )
  1872. $style->css = substr( $style->css, $start );
  1873. $style->css = addslashes( $style->css );
  1874. $preload_style_id = 0;
  1875. $preload_style = null;
  1876. if ( isset ( $_REQUEST['preload'] ) )
  1877. {
  1878. $preload_style_id = (int) $_REQUEST['preload'];
  1879. if ( $preload_style_id > 1000 || $preload_style_id < 100 )
  1880. $preload_style_id = 0;
  1881. if ( $preload_style_id > 0 ) {
  1882. $polldaddy->reset();
  1883. $preload_style = $polldaddy->get_style( $preload_style_id );
  1884. $this->parse_errors( $polldaddy );
  1885. }
  1886. $preload_style->css = trim( urldecode( $preload_style->css ) );
  1887. if ( $start = stripos( $preload_style->css, '<data>' ) )
  1888. $preload_style->css = substr( $preload_style->css, $start );
  1889. $style->css = addslashes( $preload_style->css );
  1890. }
  1891. $this->print_errors();
  1892. echo '<script language="javascript">var CSSXMLString = "' . $style->css .'";</script>';
  1893. ?>
  1894. <form action="" method="post">
  1895. <div id="poststuff">
  1896. <div id="post-body">
  1897. <br/>
  1898. <table width="100%">
  1899. <tr>
  1900. <td colspan="2">
  1901. <table width="100%">
  1902. <tr>
  1903. <td valign="middle" width="8%">
  1904. <label class="CSSE_title_label"><?php _e( 'Style Name', 'polldaddy' ); ?></label>
  1905. </td>
  1906. <td>
  1907. <div id="titlediv" style="margin:0px;">
  1908. <div id="titlewrap">
  1909. <input type="text" autocomplete="off" id="title" value="<?php echo $style_id > 1000 ? $style->title : ''; ?>" tabindex="1" size="30" name="style-title"></input>
  1910. </div>
  1911. </div>
  1912. </td>
  1913. </tr>
  1914. </table>
  1915. </td>
  1916. </tr>
  1917. <tr>
  1918. <td width="13%">
  1919. <label class="CSSE_title_label"><?php _e( 'Preload Basic Style', 'polldaddy' ); ?></label>
  1920. </td>
  1921. <td>
  1922. <div class="CSSE_preload">
  1923. <select id="preload_value">
  1924. <option value="0"></option>
  1925. <option value="102"><?php _e( 'Aluminum', 'polldaddy' ); ?></option>
  1926. <option value="105"><?php _e( 'Plain White', 'polldaddy' ); ?></option>
  1927. <option value="108"><?php _e( 'Plain Black', 'polldaddy' ); ?></option>
  1928. <option value="111"><?php _e( 'Paper', 'polldaddy' ); ?></option>
  1929. <option value="114"><?php _e( 'Skull Dark', 'polldaddy' ); ?></option>
  1930. <option value="117"><?php _e( 'Skull Light', 'polldaddy' ); ?></option>
  1931. <option value="157"><?php _e( 'Micro', 'polldaddy' ); ?></option>
  1932. </select>
  1933. <a tabindex="4" id="style-preload" href="javascript:preload_pd_style();" class="button"><?php echo attribute_escape( __( 'Load Style', 'polldaddy' ) ); ?></a>
  1934. </div>
  1935. </td>
  1936. </tr>
  1937. <tr>
  1938. <td width="13%">
  1939. <p><?php _e( 'Choose a part to edit...', 'polldaddy' ); ?></p>
  1940. </td>
  1941. <td>
  1942. <select id="styleName" onchange="renderStyleEdit(this.value);">
  1943. <option value="pds-box" selected="selected"><?php _e( 'Poll Box', 'polldaddy' ); ?></option>
  1944. <option value="pds-question-top"><?php _e( 'Question', 'polldaddy' ); ?></option>
  1945. <option value="pds-answer-group"><?php _e( 'Answer Group', 'polldaddy' ); ?></option>
  1946. <option value="pds-answer-input"><?php _e( 'Answer Check', 'polldaddy' ); ?></option>
  1947. <option value="pds-answer"><?php _e( 'Answers', 'polldaddy' ); ?></option>
  1948. <option value="pds-textfield"><?php _e( 'Other Input', 'polldaddy' ); ?></option>
  1949. <option value="pds-vote-button"><?php _e( 'Vote Button', 'polldaddy' ); ?></option>
  1950. <option value="pds-link"><?php _e( 'Links', 'polldaddy' ); ?></option>
  1951. <option value="pds-answer-feedback"><?php _e( 'Result Background', 'polldaddy' ); ?></option>
  1952. <option value="pds-answer-feedback-bar"><?php _e( 'Result Bar', 'polldaddy' ); ?></option>
  1953. <option value="pds-totalvotes-inner"><?php _e( 'Total Votes', 'polldaddy' ); ?></option>
  1954. </select>
  1955. </td>
  1956. </tr>
  1957. </table>
  1958. <table width="100%">
  1959. <tr>
  1960. <td valign="top">
  1961. <table class="CSSE_main">
  1962. <tr>
  1963. <td class="CSSE_main_l" valign="top">
  1964. <div class="off" id="D_Font">
  1965. <a href="javascript:CSSE_changeView('Font');" id="A_Font" class="Aoff"><?php _e( 'Font', 'polldaddy' ); ?></a>
  1966. </div>
  1967. <div class="on" id="D_Background">
  1968. <a href="javascript:CSSE_changeView('Background');" id="A_Background" class="Aon"><?php _e( 'Background', 'polldaddy' ); ?></a>
  1969. </div>
  1970. <div class="off" id="D_Border">
  1971. <a href="javascript:CSSE_changeView('Border');" id="A_Border" class="Aoff"><?php _e( 'Border', 'polldaddy' ); ?></a>
  1972. </div>
  1973. <div class="off" id="D_Margin">
  1974. <a href="javascript:CSSE_changeView('Margin');" id="A_Margin" class="Aoff"><?php _e( 'Margin', 'polldaddy' ); ?></a>
  1975. </div>
  1976. <div class="off" id="D_Padding">
  1977. <a href="javascript:CSSE_changeView('Padding');" id="A_Padding" class="Aoff"><?php _e( 'Padding', 'polldaddy' ); ?></a>
  1978. </div>
  1979. <div class="off" id="D_Scale">
  1980. <a href="javascript:CSSE_changeView('Scale');" id="A_Scale" class="Aoff"><?php _e( 'Width', 'polldaddy' ); ?></a>
  1981. </div>
  1982. <div class="off" id="D_Height">
  1983. <a href="javascript:CSSE_changeView('Height');" id="A_Height" class="Aoff"><?php _e( 'Height', 'polldaddy' ); ?></a>
  1984. </div>
  1985. </td>
  1986. <td class="CSSE_main_r" valign="top">
  1987. <table class="CSSE_sub">
  1988. <tr>
  1989. <td class="top"/>
  1990. </tr>
  1991. <tr>
  1992. <td class="mid">
  1993. <!-- Font Table -->
  1994. <table class="CSSE_edit" id="editFont" style="display:none;">
  1995. <tr>
  1996. <td width="85"><?php _e( 'Font Size', 'polldaddy' ); ?>:</td>
  1997. <td>
  1998. <select id="font-size" onchange="bind(this);">
  1999. <option value="6px">6px</option>
  2000. <option value="8px">8px</option>
  2001. <option value="9px">9px</option>
  2002. <option value="10px">10px</option>
  2003. <option value="11px">11px</option>
  2004. <option value="12px">12px</option>
  2005. <option value="13px">13px</option>
  2006. <option value="14px">14px</option>
  2007. <option value="15px">15px</option>
  2008. <option value="16px">16px</option>
  2009. <option value="18px">18px</option>
  2010. <option value="20px">20px</option>
  2011. <option value="24px">24px</option>
  2012. <option value="30px">30px</option>
  2013. <option value="36px">36px</option>
  2014. </select>
  2015. </td>
  2016. </tr>
  2017. <tr>
  2018. <td><?php _e( 'Font Size', 'polldaddy' ); ?></td>
  2019. <td>
  2020. <select id="font-family" onchange="bind(this);">
  2021. <option value="Arial">Arial</option>
  2022. <option value="Comic Sans MS">Comic Sans MS</option>
  2023. <option value="Courier">Courier</option>
  2024. <option value="Georgia">Georgia</option>
  2025. <option value="Lucida Grande">Lucida Grande</option>
  2026. <option value="Trebuchet MS">Trebuchet MS</option>
  2027. <option value="Times">Times</option>
  2028. <option value="Verdana">Verdana</option>
  2029. </select>
  2030. </td>
  2031. </tr>
  2032. <tr>
  2033. <td><?php _e( 'Color', 'polldaddy' ); ?> (#hex):</td>
  2034. <td>
  2035. <input type="text" maxlength="11" id="color" class="elmColor jscolor-picker" onblur="bind(this);" style="float:left;"/>
  2036. </td>
  2037. </tr>
  2038. <tr>
  2039. <td><?php _e( 'Bold', 'polldaddy' ); ?>:</td>
  2040. <td>
  2041. <input type="checkbox" id="font-weight" value="bold" onclick="bind(this);"/>
  2042. </td>
  2043. </tr>
  2044. <tr>
  2045. <td><?php _e( 'Italic', 'polldaddy' ); ?>:</td>
  2046. <td>
  2047. <input type="checkbox" id="font-style" value="italic" onclick="bind(this);"/>
  2048. </td>
  2049. </tr>
  2050. <tr>
  2051. <td><?php _e( 'Underline', 'polldaddy' ); ?>:</td>
  2052. <td>
  2053. <input type="checkbox" id="text-decoration" value="underline" onclick="bind(this);"/>
  2054. </td>
  2055. </tr>
  2056. <tr>
  2057. <td><?php _e( 'Line Height', 'polldaddy' ); ?>:</td>
  2058. <td>
  2059. <select id="line-height" onchange="bind(this);">
  2060. <option value="6px">6px</option>
  2061. <option value="8px">8px</option>
  2062. <option value="9px">9px</option>
  2063. <option value="10px">10px</option>
  2064. <option value="11px">11px</option>
  2065. <option value="12px">12px</option>
  2066. <option value="13px">13px</option>
  2067. <option value="14px">14px</option>
  2068. <option value="15px">15px</option>
  2069. <option value="16px">16px</option>
  2070. <option value="18px">18px</option>
  2071. <option value="20px">20px</option>
  2072. <option value="24px">24px</option>
  2073. <option value="30px">30px</option>
  2074. <option value="36px">36px</option>
  2075. </select>
  2076. </td>
  2077. </tr>
  2078. <tr>
  2079. <td><?php _e( 'Align', 'polldaddy' ); ?>:</td>
  2080. <td>
  2081. <select id="text-align" onchange="bind(this);">
  2082. <option value="left"><?php _e( 'Left', 'polldaddy' ); ?></option>
  2083. <option value="center"><?php _e( 'Center', 'polldaddy' ); ?></option>
  2084. <option value="right"><?php _e( 'Right', 'polldaddy' ); ?></option>
  2085. </select>
  2086. </td>
  2087. </tr>
  2088. </table>
  2089. <!-- Background Table -->
  2090. <table class="CSSE_edit" id="editBackground" style="display:none;">
  2091. <tr>
  2092. <td width="85"><?php _e( 'Color', 'polldaddy' ); ?> (#hex):</td>
  2093. <td>
  2094. <input type="text" maxlength="11" id="background-color" class="elmColor jscolor-picker" onblur="bind(this);"/>
  2095. </td>
  2096. </tr>
  2097. <tr>
  2098. <td><?php _e( 'Image URL', 'polldaddy' ); ?>: <a href="http://support.polldaddy.com/custom-poll-styles/" class="noteLink" title="<?php _e( 'Click here for more information', 'polldaddy' ); ?>">(?)</a></td>
  2099. <td>
  2100. <input type="text" id="background-image" onblur="bind(this);"/>
  2101. </td>
  2102. </tr>
  2103. <tr>
  2104. <td><?php _e( 'Image Repeat', 'polldaddy' ); ?>:</td>
  2105. <td>
  2106. <select id="background-repeat" onchange="bind(this);">
  2107. <option value="repeat"><?php _e( 'repeat', 'polldaddy' ); ?></option>
  2108. <option value="no-repeat"><?php _e( 'no-repeat', 'polldaddy' ); ?></option>
  2109. <option value="repeat-x"><?php _e( 'repeat-x', 'polldaddy' ); ?></option>
  2110. <option value="repeat-y"><?php _e( 'repeat-y', 'polldaddy' ); ?></option>
  2111. </select>
  2112. </td>
  2113. </tr>
  2114. <tr>
  2115. <td><?php _e( 'Image Position', 'polldaddy' ); ?>:</td>
  2116. <td>
  2117. <select id="background-position" onchange="bind(this);">
  2118. <option value="left top"><?php _e( 'left top', 'polldaddy' ); ?></option>
  2119. <option value="left center"><?php _e( 'left center', 'polldaddy' ); ?></option>
  2120. <option value="left bottom"><?php _e( 'left bottom', 'polldaddy' ); ?></option>
  2121. <option value="center top"><?php _e( 'center top', 'polldaddy' ); ?></option>
  2122. <option value="center center"><?php _e( 'center center', 'polldaddy' ); ?></option>
  2123. <option value="center bottom"><?php _e( 'center bottom', 'polldaddy' ); ?></option>
  2124. <option value="right top"><?php _e( 'right top', 'polldaddy' ); ?></option>
  2125. <option value="right center"><?php _e( 'right center', 'polldaddy' ); ?></option>
  2126. <option value="right bottom"><?php _e( 'right bottom', 'polldaddy' ); ?></option>
  2127. </select>
  2128. </td>
  2129. </tr>
  2130. </table>
  2131. <!-- Border Table -->
  2132. <table class="CSSE_edit" id="editBorder" style="display:none;">
  2133. <tr>
  2134. <td width="85"><?php _e( 'Width', 'polldaddy' ); ?>:</td>
  2135. <td>
  2136. <select id="border-width" onchange="bind(this);">
  2137. <option value="0px">0px</option>
  2138. <option value="1px">1px</option>
  2139. <option value="2px">2px</option>
  2140. <option value="3px">3px</option>
  2141. <option value="4px">4px</option>
  2142. <option value="5px">5px</option>
  2143. <option value="6px">6px</option>
  2144. <option value="7px">7px</option>
  2145. <option value="8px">8px</option>
  2146. <option value="9px">9px</option>
  2147. <option value="10px">10px</option>
  2148. <option value="11px">11px</option>
  2149. <option value="12px">12px</option>
  2150. <option value="13px">13px</option>
  2151. <option value="14px">14px</option>
  2152. <option value="15px">15px</option>
  2153. <option value="16px">16px</option>
  2154. <option value="17px">17px</option>
  2155. <option value="18px">18px</option>
  2156. <option value="19px">19px</option>
  2157. <option value="20px">20px</option>
  2158. <option value="21px">21px</option>
  2159. <option value="22px">22px</option>
  2160. <option value="23px">23px</option>
  2161. <option value="24px">24px</option>
  2162. <option value="25px">25px</option>
  2163. <option value="26px">26px</option>
  2164. <option value="27px">27px</option>
  2165. <option value="28px">28px</option>
  2166. <option value="29px">29px</option>
  2167. <option value="30px">30px</option>
  2168. </select>
  2169. </td>
  2170. </tr>
  2171. <tr>
  2172. <td><?php _e( 'Style', 'polldaddy' ); ?>:</td>
  2173. <td>
  2174. <select id="border-style" onchange="bind(this);">
  2175. <option value="none"><?php _e( 'none', 'polldaddy' ); ?></option>
  2176. <option value="solid"><?php _e( 'solid', 'polldaddy' ); ?></option>
  2177. <option value="dotted"><?php _e( 'dotted', 'polldaddy' ); ?></option>
  2178. <option value="dashed"><?php _e( 'dashed', 'polldaddy' ); ?></option>
  2179. <option value="double"><?php _e( 'double', 'polldaddy' ); ?></option>
  2180. <option value="groove"><?php _e( 'groove', 'polldaddy' ); ?></option>
  2181. <option value="inset"><?php _e( 'inset', 'polldaddy' ); ?></option>
  2182. <option value="outset"><?php _e( 'outset', 'polldaddy' ); ?></option>
  2183. <option value="ridge"><?php _e( 'ridge', 'polldaddy' ); ?></option>
  2184. <option value="hidden"><?php _e( 'hidden', 'polldaddy' ); ?></option>
  2185. </select>
  2186. </td>
  2187. </tr>
  2188. <tr>
  2189. <td><?php _e( 'Color', 'polldaddy' ); ?> (#hex):</td>
  2190. <td>
  2191. <input type="text" maxlength="11" class="elmColor jscolor-picker" id="border-color" onblur="bind(this);"/>
  2192. </td>
  2193. </tr>
  2194. <tr>
  2195. <td width="85"><?php _e( 'Rounded Corners', 'polldaddy' ); ?>:</td>
  2196. <td>
  2197. <select id="border-radius" onchange="bind(this);">
  2198. <option value="0px">0px</option>
  2199. <option value="1px">1px</option>
  2200. <option value="2px">2px</option>
  2201. <option value="3px">3px</option>
  2202. <option value="4px">4px</option>
  2203. <option value="5px">5px</option>
  2204. <option value="6px">6px</option>
  2205. <option value="7px">7px</option>
  2206. <option value="8px">8px</option>
  2207. <option value="9px">9px</option>
  2208. <option value="10px">10px</option>
  2209. <option value="11px">11px</option>
  2210. <option value="12px">12px</option>
  2211. <option value="13px">13px</option>
  2212. <option value="14px">14px</option>
  2213. <option value="15px">15px</option>
  2214. <option value="16px">16px</option>
  2215. <option value="17px">17px</option>
  2216. <option value="18px">18px</option>
  2217. <option value="19px">19px</option>
  2218. <option value="20px">20px</option>
  2219. <option value="21px">21px</option>
  2220. <option value="22px">22px</option>
  2221. <option value="23px">23px</option>
  2222. <option value="24px">24px</option>
  2223. <option value="25px">25px</option>
  2224. <option value="26px">26px</option>
  2225. <option value="27px">27px</option>
  2226. <option value="28px">28px</option>
  2227. <option value="29px">29px</option>
  2228. <option value="30px">30px</option>
  2229. </select>
  2230. <br/>
  2231. <?php _e( 'Not supported in Internet Explorer.', 'polldaddy' ); ?>
  2232. </td>
  2233. </tr>
  2234. </table>
  2235. <!-- Margin Table -->
  2236. <table class="CSSE_edit" id="editMargin" style="display:none;">
  2237. <tr>
  2238. <td width="85"><?php _e( 'Top', 'polldaddy' ); ?>: </td>
  2239. <td>
  2240. <select id="margin-top" onchange="bind(this);">
  2241. <option value="0px">0px</option>
  2242. <option value="1px">1px</option>
  2243. <option value="2px">2px</option>
  2244. <option value="3px">3px</option>
  2245. <option value="4px">4px</option>
  2246. <option value="5px">5px</option>
  2247. <option value="6px">6px</option>
  2248. <option value="7px">7px</option>
  2249. <option value="8px">8px</option>
  2250. <option value="9px">9px</option>
  2251. <option value="10px">10px</option>
  2252. <option value="11px">11px</option>
  2253. <option value="12px">12px</option>
  2254. <option value="13px">13px</option>
  2255. <option value="14px">14px</option>
  2256. <option value="15px">15px</option>
  2257. <option value="16px">16px</option>
  2258. <option value="17px">17px</option>
  2259. <option value="18px">18px</option>
  2260. <option value="19px">19px</option>
  2261. <option value="20px">20px</option>
  2262. <option value="21px">21px</option>
  2263. <option value="22px">22px</option>
  2264. <option value="23px">23px</option>
  2265. <option value="24px">24px</option>
  2266. <option value="25px">25px</option>
  2267. <option value="26px">26px</option>
  2268. <option value="27px">27px</option>
  2269. <option value="28px">28px</option>
  2270. <option value="29px">29px</option>
  2271. <option value="30px">30px</option>
  2272. </select>
  2273. </td>
  2274. </tr>
  2275. <tr>
  2276. <td><?php _e( 'Right', 'polldaddy' ); ?>:</td>
  2277. <td>
  2278. <select id="margin-right" onchange="bind(this);">
  2279. <option value="0px">0px</option>
  2280. <option value="1px">1px</option>
  2281. <option value="2px">2px</option>
  2282. <option value="3px">3px</option>
  2283. <option value="4px">4px</option>
  2284. <option value="5px">5px</option>
  2285. <option value="6px">6px</option>
  2286. <option value="7px">7px</option>
  2287. <option value="8px">8px</option>
  2288. <option value="9px">9px</option>
  2289. <option value="10px">10px</option>
  2290. <option value="11px">11px</option>
  2291. <option value="12px">12px</option>
  2292. <option value="13px">13px</option>
  2293. <option value="14px">14px</option>
  2294. <option value="15px">15px</option>
  2295. <option value="16px">16px</option>
  2296. <option value="17px">17px</option>
  2297. <option value="18px">18px</option>
  2298. <option value="19px">19px</option>
  2299. <option value="20px">20px</option>
  2300. <option value="21px">21px</option>
  2301. <option value="22px">22px</option>
  2302. <option value="23px">23px</option>
  2303. <option value="24px">24px</option>
  2304. <option value="25px">25px</option>
  2305. <option value="26px">26px</option>
  2306. <option value="27px">27px</option>
  2307. <option value="28px">28px</option>
  2308. <option value="29px">29px</option>
  2309. <option value="30px">30px</option>
  2310. </select>
  2311. </td>
  2312. </tr>
  2313. <tr>
  2314. <td><?php _e( 'Bottom', 'polldaddy' ); ?>:</td>
  2315. <td>
  2316. <select id="margin-bottom" onchange="bind(this);">
  2317. <option value="0px">0px</option>
  2318. <option value="1px">1px</option>
  2319. <option value="2px">2px</option>
  2320. <option value="3px">3px</option>
  2321. <option value="4px">4px</option>
  2322. <option value="5px">5px</option>
  2323. <option value="6px">6px</option>
  2324. <option value="7px">7px</option>
  2325. <option value="8px">8px</option>
  2326. <option value="9px">9px</option>
  2327. <option value="10px">10px</option>
  2328. <option value="11px">11px</option>
  2329. <option value="12px">12px</option>
  2330. <option value="13px">13px</option>
  2331. <option value="14px">14px</option>
  2332. <option value="15px">15px</option>
  2333. <option value="16px">16px</option>
  2334. <option value="17px">17px</option>
  2335. <option value="18px">18px</option>
  2336. <option value="19px">19px</option>
  2337. <option value="20px">20px</option>
  2338. <option value="21px">21px</option>
  2339. <option value="22px">22px</option>
  2340. <option value="23px">23px</option>
  2341. <option value="24px">24px</option>
  2342. <option value="25px">25px</option>
  2343. <option value="26px">26px</option>
  2344. <option value="27px">27px</option>
  2345. <option value="28px">28px</option>
  2346. <option value="29px">29px</option>
  2347. <option value="30px">30px</option>
  2348. </select>
  2349. </td>
  2350. </tr>
  2351. <tr>
  2352. <td><?php _e( 'Left', 'polldaddy' ); ?>:</td>
  2353. <td>
  2354. <select id="margin-left" onchange="bind(this);">
  2355. <option value="0px">0px</option>
  2356. <option value="1px">1px</option>
  2357. <option value="2px">2px</option>
  2358. <option value="3px">3px</option>
  2359. <option value="4px">4px</option>
  2360. <option value="5px">5px</option>
  2361. <option value="6px">6px</option>
  2362. <option value="7px">7px</option>
  2363. <option value="8px">8px</option>
  2364. <option value="9px">9px</option>
  2365. <option value="10px">10px</option>
  2366. <option value="11px">11px</option>
  2367. <option value="12px">12px</option>
  2368. <option value="13px">13px</option>
  2369. <option value="14px">14px</option>
  2370. <option value="15px">15px</option>
  2371. <option value="16px">16px</option>
  2372. <option value="17px">17px</option>
  2373. <option value="18px">18px</option>
  2374. <option value="19px">19px</option>
  2375. <option value="20px">20px</option>
  2376. <option value="21px">21px</option>
  2377. <option value="22px">22px</option>
  2378. <option value="23px">23px</option>
  2379. <option value="24px">24px</option>
  2380. <option value="25px">25px</option>
  2381. <option value="26px">26px</option>
  2382. <option value="27px">27px</option>
  2383. <option value="28px">28px</option>
  2384. <option value="29px">29px</option>
  2385. <option value="30px">30px</option>
  2386. </select>
  2387. </td>
  2388. </tr>
  2389. </table>
  2390. <!-- Padding Table -->
  2391. <table class="CSSE_edit" id="editPadding" style="display:none;">
  2392. <tr>
  2393. <td width="85"><?php _e( 'Top', 'polldaddy' ); ?>:</td>
  2394. <td>
  2395. <select id="padding-top" onchange="bind(this);">
  2396. <option value="0px">0px</option>
  2397. <option value="1px">1px</option>
  2398. <option value="2px">2px</option>
  2399. <option value="3px">3px</option>
  2400. <option value="4px">4px</option>
  2401. <option value="5px">5px</option>
  2402. <option value="6px">6px</option>
  2403. <option value="7px">7px</option>
  2404. <option value="8px">8px</option>
  2405. <option value="9px">9px</option>
  2406. <option value="10px">10px</option>
  2407. <option value="11px">11px</option>
  2408. <option value="12px">12px</option>
  2409. <option value="13px">13px</option>
  2410. <option value="14px">14px</option>
  2411. <option value="15px">15px</option>
  2412. <option value="16px">16px</option>
  2413. <option value="17px">17px</option>
  2414. <option value="18px">18px</option>
  2415. <option value="19px">19px</option>
  2416. <option value="20px">20px</option>
  2417. <option value="21px">21px</option>
  2418. <option value="22px">22px</option>
  2419. <option value="23px">23px</option>
  2420. <option value="24px">24px</option>
  2421. <option value="25px">25px</option>
  2422. <option value="26px">26px</option>
  2423. <option value="27px">27px</option>
  2424. <option value="28px">28px</option>
  2425. <option value="29px">29px</option>
  2426. <option value="30px">30px</option>
  2427. </select>
  2428. </td>
  2429. </tr>
  2430. <tr>
  2431. <td><?php _e( 'Right', 'polldaddy' ); ?>:</td>
  2432. <td>
  2433. <select id="padding-right" onchange="bind(this);">
  2434. <option value="0px">0px</option>
  2435. <option value="1px">1px</option>
  2436. <option value="2px">2px</option>
  2437. <option value="3px">3px</option>
  2438. <option value="4px">4px</option>
  2439. <option value="5px">5px</option>
  2440. <option value="6px">6px</option>
  2441. <option value="7px">7px</option>
  2442. <option value="8px">8px</option>
  2443. <option value="9px">9px</option>
  2444. <option value="10px">10px</option>
  2445. <option value="11px">11px</option>
  2446. <option value="12px">12px</option>
  2447. <option value="13px">13px</option>
  2448. <option value="14px">14px</option>
  2449. <option value="15px">15px</option>
  2450. <option value="16px">16px</option>
  2451. <option value="17px">17px</option>
  2452. <option value="18px">18px</option>
  2453. <option value="19px">19px</option>
  2454. <option value="20px">20px</option>
  2455. <option value="21px">21px</option>
  2456. <option value="22px">22px</option>
  2457. <option value="23px">23px</option>
  2458. <option value="24px">24px</option>
  2459. <option value="25px">25px</option>
  2460. <option value="26px">26px</option>
  2461. <option value="27px">27px</option>
  2462. <option value="28px">28px</option>
  2463. <option value="29px">29px</option>
  2464. <option value="30px">30px</option>
  2465. </select>
  2466. </td>
  2467. </tr>
  2468. <tr>
  2469. <td><?php _e( 'Bottom', 'polldaddy' ); ?>:</td>
  2470. <td>
  2471. <select id="padding-bottom" onchange="bind(this);">
  2472. <option value="0px">0px</option>
  2473. <option value="1px">1px</option>
  2474. <option value="2px">2px</option>
  2475. <option value="3px">3px</option>
  2476. <option value="4px">4px</option>
  2477. <option value="5px">5px</option>
  2478. <option value="6px">6px</option>
  2479. <option value="7px">7px</option>
  2480. <option value="8px">8px</option>
  2481. <option value="9px">9px</option>
  2482. <option value="10px">10px</option>
  2483. <option value="11px">11px</option>
  2484. <option value="12px">12px</option>
  2485. <option value="13px">13px</option>
  2486. <option value="14px">14px</option>
  2487. <option value="15px">15px</option>
  2488. <option value="16px">16px</option>
  2489. <option value="17px">17px</option>
  2490. <option value="18px">18px</option>
  2491. <option value="19px">19px</option>
  2492. <option value="20px">20px</option>
  2493. <option value="21px">21px</option>
  2494. <option value="22px">22px</option>
  2495. <option value="23px">23px</option>
  2496. <option value="24px">24px</option>
  2497. <option value="25px">25px</option>
  2498. <option value="26px">26px</option>
  2499. <option value="27px">27px</option>
  2500. <option value="28px">28px</option>
  2501. <option value="29px">29px</option>
  2502. <option value="30px">30px</option>
  2503. </select>
  2504. </td>
  2505. </tr>
  2506. <tr>
  2507. <td><?php _e( 'Left', 'polldaddy' ); ?>:</td>
  2508. <td>
  2509. <select id="padding-left" onchange="bind(this);">
  2510. <option value="0px">0px</option>
  2511. <option value="1px">1px</option>
  2512. <option value="2px">2px</option>
  2513. <option value="3px">3px</option>
  2514. <option value="4px">4px</option>
  2515. <option value="5px">5px</option>
  2516. <option value="6px">6px</option>
  2517. <option value="7px">7px</option>
  2518. <option value="8px">8px</option>
  2519. <option value="9px">9px</option>
  2520. <option value="10px">10px</option>
  2521. <option value="11px">11px</option>
  2522. <option value="12px">12px</option>
  2523. <option value="13px">13px</option>
  2524. <option value="14px">14px</option>
  2525. <option value="15px">15px</option>
  2526. <option value="16px">16px</option>
  2527. <option value="17px">17px</option>
  2528. <option value="18px">18px</option>
  2529. <option value="19px">19px</option>
  2530. <option value="20px">20px</option>
  2531. <option value="21px">21px</option>
  2532. <option value="22px">22px</option>
  2533. <option value="23px">23px</option>
  2534. <option value="24px">24px</option>
  2535. <option value="25px">25px</option>
  2536. <option value="26px">26px</option>
  2537. <option value="27px">27px</option>
  2538. <option value="28px">28px</option>
  2539. <option value="29px">29px</option>
  2540. <option value="30px">30px</option>
  2541. </select>
  2542. </td>
  2543. </tr>
  2544. </table>
  2545. <!-- Scale Table -->
  2546. <table class="CSSE_edit" id="editScale" style="display:none;">
  2547. <tr>
  2548. <td width="85"><?php _e( 'Width', 'polldaddy' ); ?> (px): <a href="http://support.polldaddy.com/custom-poll-styles/" class="noteLink" title="<?php _e( 'Click here for more information', 'polldaddy' ); ?>">(?)</a></td>
  2549. <td>
  2550. <input type="text" maxlength="4" class="elmColor" id="width" onblur="bind(this);"/>
  2551. </td>
  2552. </tr>
  2553. <tr>
  2554. <td width="85"></td>
  2555. <td>
  2556. <?php _e( 'If you change the width of the<br/> poll you may also need to change<br/> the width of your answers.', 'polldaddy' ); ?>
  2557. </td>
  2558. </tr>
  2559. </table>
  2560. <!-- Height Table -->
  2561. <table class="CSSE_edit" id="editHeight" style="display:none;">
  2562. <tr>
  2563. <td width="85"><?php _e( 'Height', 'polldaddy' ); ?> (px):</td>
  2564. <td>
  2565. <input type="text" maxlength="4" class="elmColor" id="height" onblur="bind(this);"/>
  2566. </td>
  2567. </tr>
  2568. </table>
  2569. </td>
  2570. </tr>
  2571. <tr>
  2572. <td class="btm"/>
  2573. </tr>
  2574. </table>
  2575. </td>
  2576. </tr>
  2577. </table>
  2578. </td>
  2579. <td width="10"> </td>
  2580. <td valign="top">
  2581. <div style="overflow-x:auto;width:633px;">
  2582. <!-- POLL XHTML START -->
  2583. <div class="pds-box" id="pds-box">
  2584. <div class="pds-box-outer">
  2585. <div class="pds-box-inner">
  2586. <div class="pds-box-top">
  2587. <div class="pds-question">
  2588. <div class="pds-question-outer">
  2589. <div class="pds-question-inner">
  2590. <div class="pds-question-top" id="pds-question-top"><?php _e( 'Do you mostly use the internet at work, in school or at home?', 'polldaddy' ); ?></div>
  2591. </div>
  2592. </div>
  2593. </div>
  2594. <div>
  2595. <!-- divAnswers -->
  2596. <div id="divAnswers">
  2597. <span id="pds-answer143974">
  2598. <span class="pds-answer-group" id="pds-answer-group">
  2599. <span class="pds-answer-input" id="pds-answer-input">
  2600. <input type="radio" name="PDI_answer" value="1" id="p1" class="pds-checkbox"/>
  2601. </span>
  2602. <label for="p1" class="pds-answer" id="pds-answer"><span class="pds-answer-span"><?php _e( 'I use it in school.', 'polldaddy' ); ?></span></label>
  2603. <span class="pds-clear"></span>
  2604. </span>
  2605. <span class="pds-answer-group" id="pds-answer-group1">
  2606. <span class="pds-answer-input" id="pds-answer-input1">
  2607. <input type="radio" name="PDI_answer" value="2" id="p2" class="pds-checkbox"/>
  2608. </span>
  2609. <label for="p2" class="pds-answer" id="pds-answer1"><span class="pds-answer-span"><?php _e( 'I use it at home.', 'polldaddy' ); ?></span></label>
  2610. <span class="pds-clear"></span>
  2611. </span>
  2612. <span class="pds-answer-group" id="pds-answer-group2">
  2613. <span class="pds-answer-input" id="pds-answer-input2">
  2614. <input type="radio" name="PDI_answer" value="3" id="p3" class="pds-checkbox"/>
  2615. </span>
  2616. <label for="p3" class="pds-answer" id="pds-answer2"><span class="pds-answer-span"><?php _e( 'I use it every where I go, at work and home and anywhere else that I can!', 'polldaddy' ); ?></span></label>
  2617. <span class="pds-clear"></span>
  2618. </span>
  2619. <span class="pds-answer-group" id="pds-answer-group3">
  2620. <span class="pds-answer-input" id="pds-answer-input3">
  2621. <input type="radio" name="PDI_answer" value="4" id="p4" class="pds-checkbox"/>
  2622. </span>
  2623. <label for="p4" class="pds-answer" id="pds-answer3"><span class="pds-answer-span"><?php _e( 'Other', 'polldaddy' ); ?>:</span></label>
  2624. <span class="pds-clear"></span>
  2625. <span class="pds-answer-other">
  2626. <input type="text" name="PDI_OtherText1761982" id="pds-textfield" maxlength="80" class="pds-textfield"/>
  2627. </span>
  2628. <span class="pds-clear"></span>
  2629. </span>
  2630. </span>
  2631. <br/>
  2632. <div class="pds-vote" id="pds-links">
  2633. <div class="pds-votebutton-outer">
  2634. <a href="javascript:renderStyleEdit('pds-answer-feedback');" id="pds-vote-button" style="display:block;float:left;" class="pds-vote-button"><span><?php _e( 'Vote', 'polldaddy' ); ?></span></a>
  2635. <span class="pds-links">
  2636. <div style="padding: 0px 0px 0px 15px; float:left;"><a href="javascript:renderStyleEdit('pds-answer-feedback');" class="pds-link" id="pds-link"><?php _e( 'View Results', 'polldaddy' ); ?></a></div>
  2637. <span class="pds-clear"></span>
  2638. </span>
  2639. <span class="pds-clear"></span>
  2640. </div>
  2641. </div>
  2642. </div>
  2643. <!-- End divAnswers -->
  2644. <!-- divResults -->
  2645. <div id="divResults">
  2646. <div class="pds-answer-group" id="pds-answer-group4">
  2647. <label for="PDI_feedback1" class="pds-answer" id="pds-answer4"><span class="pds-answer-text"><?php _e( 'I use it in school!', 'polldaddy' ); ?></span><xsl:text> </xsl:text><span class="pds-feedback-per"><strong>46%</strong></span><xsl:text> </xsl:text><span class="pds-feedback-votes"><?php printf( __( '(%d votes)', 'polldaddy' ), 620 ); ?></span></label>
  2648. <span class="pds-clear"></span>
  2649. <div id="pds-answer-feedback">
  2650. <div style="width:46%;" id="pds-answer-feedback-bar" class="pds-answer-feedback-bar"></div>
  2651. </div>
  2652. <span class="pds-clear"></span>
  2653. </div>
  2654. <div class="pds-answer-group" id="pds-answer-group5">
  2655. <label for="PDI_feedback2" class="pds-answer" id="pds-answer5"><span class="pds-answer-text"><?php _e( 'I use it at home.', 'polldaddy' ); ?></span><xsl:text> </xsl:text><span class="pds-feedback-per"><strong>30%</strong></span><xsl:text> </xsl:text><span class="pds-feedback-votes"><?php printf( __( '(%d votes)', 'polldaddy' ), 400 ); ?></span></label>
  2656. <span class="pds-clear"></span>
  2657. <div id="pds-answer-feedback2">
  2658. <div style="width:46%;" id="pds-answer-feedback-bar2" class="pds-answer-feedback-bar"></div>
  2659. </div>
  2660. <span class="pds-clear"></span>
  2661. </div>
  2662. <div class="pds-answer-group" id="pds-answer-group6">
  2663. <label for="PDI_feedback3" class="pds-answer" id="pds-answer6"><span class="pds-answer-text"><?php _e( 'I use it every where I go, at work and home and anywhere else that I can!', 'polldaddy' ); ?></span><xsl:text> </xsl:text><span class="pds-feedback-per"><strong>16%</strong></span><xsl:text> </xsl:text><span class="pds-feedback-votes"><?php printf( __( '(%d votes)', 'polldaddy' ), 220 ); ?></span></label>
  2664. <span class="pds-clear"></span>
  2665. <div id="pds-answer-feedback3">
  2666. <div style="width:16%;" id="pds-answer-feedback-bar3" class="pds-answer-feedback-bar"></div>
  2667. </div>
  2668. <span class="pds-clear"></span>
  2669. </div>
  2670. <div class="pds-answer-group" id="pds-answer-group7">
  2671. <label for="PDI_feedback4" class="pds-answer" id="pds-answer7"><span class="pds-answer-text"><?php _e( 'Other', 'polldaddy' ); ?></span><xsl:text> </xsl:text><span class="pds-feedback-per"><strong>8%</strong></span><xsl:text> </xsl:text><span class="pds-feedback-votes"><?php printf( __( '(%d votes)', 'polldaddy' ), 110 ); ?></span></label>
  2672. <span class="pds-clear"></span>
  2673. <div id="pds-answer-feedback4">
  2674. <div style="width:8%;" id="pds-answer-feedback-bar4" class="pds-answer-feedback-bar"></div>
  2675. </div>
  2676. <span class="pds-clear"></span>
  2677. </div>
  2678. </div>
  2679. <!-- End divResults -->
  2680. <span class="pds-clear"></span>
  2681. <div style="height: 10px;"></div>
  2682. <div id="pds-totalvotes-inner"><?php _e( 'Total Votes', 'polldaddy' ); ?>: <strong>1,350</strong></div>
  2683. </div>
  2684. <div class="pds-vote" id="pds-links-back">
  2685. <div class="pds-totalvotes-outer">
  2686. <span class="pds-links-back">
  2687. <br/>
  2688. <a href="javascript:" class="pds-link" id="pds-link1"><?php _e( 'Comments', 'polldaddy' ); ?> <strong>(19)</strong></a>
  2689. <xsl:text> </xsl:text>
  2690. <a href="javascript:renderStyleEdit('pds-box');" class="pds-link" id="pds-link2"><?php _e( 'Return To Poll', 'polldaddy' ); ?></a>
  2691. <span class="pds-clear"></span>
  2692. </span>
  2693. <span class="pds-clear"></span>
  2694. </div>
  2695. </div>
  2696. </div>
  2697. </div>
  2698. </div>
  2699. </div>
  2700. <!-- POLL XHTML END -->
  2701. </div>
  2702. </td>
  2703. </tr>
  2704. </table>
  2705. <div id="editBox"></div>
  2706. <p class="pds-clear"></p>
  2707. <p>
  2708. <?php wp_nonce_field( $style_id > 1000 ? "edit-style$style_id" : 'create-style' ); ?>
  2709. <input type="hidden" name="action" value="<?php echo $style_id > 1000 ? 'edit-style' : 'create-style'; ?>" />
  2710. <input type="hidden" class="polldaddy-style-id" name="style" value="<?php echo $style_id; ?>" />
  2711. <input type="submit" class="button-primary" value="<?php echo attribute_escape( __( 'Save Style', 'polldaddy' ) ); ?>" />
  2712. <?php if ( $style_id > 1000 ) { ?>
  2713. <input name="updatePollCheck" id="updatePollCheck" type="checkbox"> <label for="updatePollCheck"><?php _e( 'Check this box if you wish to update the polls that use this style.' ); ?></label>
  2714. <?php } ?>
  2715. </p>
  2716. </div>
  2717. </div>
  2718. <textarea id="S_www" name="CSSXML" style="display:none;width: 1000px; height: 500px;" rows="10" cols="10"> </textarea>
  2719. </form>
  2720. <script language="javascript">
  2721. jQuery( document ).ready(function(){
  2722. plugin = new Plugin( {
  2723. delete_rating: '<?php _e( 'Are you sure you want to delete the rating for "%s"?','polldaddy'); ?>',
  2724. delete_poll: '<?php _e( 'Are you sure you want to delete "%s"?','polldaddy'); ?>',
  2725. delete_answer: '<?php _e( 'Are you sure you want to delete this answer?','polldaddy'); ?>',
  2726. delete_answer_title: '<?php _e( 'delete this answer','polldaddy'); ?>',
  2727. standard_styles: '<?php _e( 'Standard Styles','polldaddy'); ?>',
  2728. custom_styles: '<?php _e( 'Custom Styles','polldaddy'); ?>'
  2729. } );
  2730. });
  2731. pd_map = {
  2732. thankyou : '<?php _e( 'Thank you for voting!', 'polldaddy' ); ?>',
  2733. question : '<?php _e( 'Do you mostly use the internet at work, in school or at home?', 'polldaddy' ); ?>'
  2734. }
  2735. </script>
  2736. <script type="text/javascript" language="javascript">window.onload = function() {
  2737. var CSSXML;
  2738. loadStyle();
  2739. showResults( false );
  2740. renderStyleEdit( _$('styleName').value );
  2741. }</script>
  2742. <br class="clear" />
  2743. <?php
  2744. }
  2745. function rating_settings(){
  2746. global $action, $rating;
  2747. $show_posts = $show_posts_index = $show_pages = $show_comments = $pos_posts = $pos_posts_index = $pos_pages = $pos_comments = 0;
  2748. $show_settings = $rating_updated = ( $action == 'update-rating' ? true : false );
  2749. $error = false;
  2750. $settings_style = 'display: none;';
  2751. if( $show_settings )
  2752. $settings_style = 'display: block;';
  2753. $rating_id = get_option( 'pd-rating-posts-id' );
  2754. $report_type = 'posts';
  2755. $updated = false;
  2756. if ( isset( $rating ) ) {
  2757. switch ( $rating ) :
  2758. case 'pages':
  2759. $report_type = 'pages';
  2760. $rating_id = (int) get_option( 'pd-rating-pages-id' );
  2761. break;
  2762. case 'comments':
  2763. $report_type = 'comments';
  2764. $rating_id = (int) get_option( 'pd-rating-comments-id' );
  2765. break;
  2766. case 'posts':
  2767. $report_type = 'posts';
  2768. $rating_id = (int) get_option( 'pd-rating-posts-id' );
  2769. break;
  2770. endswitch;
  2771. }
  2772. $new_type = 0;
  2773. if ( $report_type == 'comments' )
  2774. $new_type = 1;
  2775. $blog_name = get_option( 'blogname' );
  2776. if ( empty( $blog_name ) )
  2777. $blog_name = 'WordPress Blog';
  2778. $blog_name .= ' - ' . $report_type;
  2779. $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
  2780. $polldaddy->reset();
  2781. if ( empty( $rating_id ) ) {
  2782. $pd_rating = $polldaddy->create_rating( $blog_name , $new_type );
  2783. if ( !empty( $pd_rating ) ) {
  2784. $rating_id = (int) $pd_rating->_id;
  2785. update_option ( 'pd-rating-' . $report_type . '-id', $rating_id );
  2786. update_option ( 'pd-rating-' . $report_type, 0 );
  2787. }
  2788. } else
  2789. $pd_rating = $polldaddy->get_rating( $rating_id );
  2790. if ( empty( $pd_rating ) || (int) $pd_rating->_id == 0 ) {
  2791. if ( $polldaddy->errors ) {
  2792. if( array_key_exists( 4, $polldaddy->errors ) ) { //Obsolete key
  2793. $this->rating_user_code = '';
  2794. update_option( 'pd-rating-usercode', '' );
  2795. $this->set_api_user_code(); // get latest key
  2796. $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
  2797. $polldaddy->reset();
  2798. $pd_rating = $polldaddy->get_rating( $rating_id ); //see it exists
  2799. if ( empty( $pd_rating ) || (int) $pd_rating->_id == 0 ) { //if not then create a rating for blog
  2800. $polldaddy->reset();
  2801. $pd_rating = $polldaddy->create_rating( $blog_name , $new_type );
  2802. }
  2803. }
  2804. }
  2805. if( empty( $pd_rating ) ) { //something's up!
  2806. echo '<div class="error"><p>'.sprintf(__('Sorry! There was an error creating your rating widget. Please contact <a href="%1$s" %2$s>PollDaddy support</a> to fix this.', 'polldaddy'), 'http://polldaddy.com/feedback/', 'target="_blank"') . '</p></div>';
  2807. $error = true;
  2808. } else {
  2809. $rating_id = (int) $pd_rating->_id;
  2810. update_option ( 'pd-rating-' . $report_type . '-id', $rating_id );
  2811. update_option ( 'pd-rating-' . $report_type, 0 );
  2812. switch ( $report_type ) :
  2813. case 'posts':
  2814. $show_posts = 0;
  2815. break;
  2816. case 'pages':
  2817. $show_pages = 0;
  2818. break;
  2819. case 'comments':
  2820. $show_comments = 0;
  2821. break;
  2822. endswitch;
  2823. }
  2824. }
  2825. if ( isset( $_POST[ 'pd_rating_action_type' ] ) ) {
  2826. switch ( $_POST[ 'pd_rating_action_type' ] ) :
  2827. case 'posts' :
  2828. if ( isset( $_POST[ 'pd_show_posts' ] ) && (int) $_POST[ 'pd_show_posts' ] == 1 )
  2829. $show_posts = get_option( 'pd-rating-posts-id' );
  2830. update_option( 'pd-rating-posts', $show_posts );
  2831. if ( isset( $_POST[ 'pd_show_posts_index' ] ) && (int) $_POST[ 'pd_show_posts_index' ] == 1 )
  2832. $show_posts_index = get_option( 'pd-rating-posts-id' );
  2833. update_option( 'pd-rating-posts-index', $show_posts_index );
  2834. if ( isset( $_POST[ 'posts_pos' ] ) && (int) $_POST[ 'posts_pos' ] == 1 )
  2835. $pos_posts = 1;
  2836. update_option( 'pd-rating-posts-pos', $pos_posts );
  2837. if ( isset( $_POST[ 'posts_index_pos' ] ) && (int) $_POST[ 'posts_index_pos' ] == 1 )
  2838. $pos_posts_index = 1;
  2839. update_option( 'pd-rating-posts-index-pos', $pos_posts_index );
  2840. $rating_updated = true;
  2841. break;
  2842. case 'pages';
  2843. if ( isset( $_POST[ 'pd_show_pages' ] ) && (int) $_POST[ 'pd_show_pages' ] == 1 )
  2844. $show_pages = get_option( 'pd-rating-pages-id' );
  2845. update_option( 'pd-rating-pages', $show_pages );
  2846. if ( isset( $_POST[ 'pages_pos' ] ) && (int) $_POST[ 'pages_pos' ] == 1 )
  2847. $pos_pages = 1;
  2848. update_option( 'pd-rating-pages-pos', $pos_pages );
  2849. $rating_updated = true;
  2850. break;
  2851. case 'comments':
  2852. if ( isset( $_POST[ 'pd_show_comments' ] ) && (int) $_POST[ 'pd_show_comments' ] == 1 )
  2853. $show_comments = get_option( 'pd-rating-comments-id' );
  2854. update_option( 'pd-rating-comments', $show_comments );
  2855. if ( isset( $_POST[ 'comments_pos' ] ) && (int) $_POST[ 'comments_pos' ] == 1 )
  2856. $pos_comments = 1;
  2857. update_option( 'pd-rating-comments-pos', $pos_comments );
  2858. $rating_updated = true;
  2859. break;
  2860. endswitch;
  2861. }
  2862. $show_posts = (int) get_option( 'pd-rating-posts' );
  2863. $show_pages = (int) get_option( 'pd-rating-pages' );
  2864. $show_comments = (int) get_option( 'pd-rating-comments' );
  2865. $show_posts_index = (int) get_option( 'pd-rating-posts-index' );
  2866. $pos_posts = (int) get_option( 'pd-rating-posts-pos' );
  2867. $pos_pages = (int) get_option( 'pd-rating-pages-pos' );
  2868. $pos_comments = (int) get_option( 'pd-rating-comments-pos' );
  2869. $pos_posts_index = (int) get_option( 'pd-rating-posts-index-pos' );
  2870. if ( !empty( $pd_rating ) ) {
  2871. $settings_text = $pd_rating->settings;
  2872. $settings = json_decode( $settings_text );
  2873. $popup_disabled = ( isset( $settings->popup ) && $settings->popup == 'off' );
  2874. $rating_type = 0;
  2875. if( $settings->type == 'stars' )
  2876. $rating_type = 0;
  2877. else
  2878. $rating_type = 1;
  2879. if( empty( $settings->font_color ) )
  2880. $settings->font_color = '#000000';
  2881. }?>
  2882. <div class="wrap">
  2883. <h2><?php _e('Rating Settings', 'polldaddy'); ?></h2><?php
  2884. if ( $rating_updated )
  2885. echo( '<div class="updated"><p>'.__('Rating updated', 'polldaddy').'</p></div>' );
  2886. if ( !$error ) { ?>
  2887. <div id="side-sortables">
  2888. <div id="categorydiv" class="categorydiv">
  2889. <ul id="category-tabs" class="category-tabs"><?php
  2890. $this_class = '';
  2891. $posts_link = clean_url( add_query_arg( array( 'rating' => 'posts', 'message' => false ) ) );
  2892. $pages_link = clean_url( add_query_arg( array( 'rating' => 'pages', 'message' => false ) ) );
  2893. $comments_link = clean_url( add_query_arg( array( 'rating' => 'comments', 'message' => false ) ) );
  2894. if ( $report_type == 'posts' )
  2895. $this_class = ' class="tabs"';?>
  2896. <li <?php echo( $this_class ); ?>><a tabindex="3" href="<?php echo $posts_link; ?>"><?php _e('Posts', 'polldaddy');?></a></li><?php
  2897. $this_class = '';
  2898. if ( $report_type == 'pages' )
  2899. $this_class = ' class="tabs"'; ?>
  2900. <li <?php echo( $this_class ); ?>><a tabindex="3" href="<?php echo $pages_link; ?>"><?php _e('Pages', 'polldaddy');?></a></li><?php
  2901. $this_class = '';
  2902. if ( $report_type == 'comments' )
  2903. $this_class = ' class="tabs"'; ?>
  2904. <li <?php echo( $this_class ); ?>><a href="<?php echo $comments_link; ?>"><?php _e('Comments', 'polldaddy');?></a></li>
  2905. </ul>
  2906. <div class="tabs-panel" id="categories-all" style="background: #FFFFFF;height: auto; overflow: visible;">
  2907. <form action="" method="post">
  2908. <input type="hidden" name="pd_rating_action_type" value="<?php echo ( $report_type ); ?>" />
  2909. <table class="form-table" style="width: normal;">
  2910. <tbody><?php
  2911. if ( $report_type == 'posts' ) { ?>
  2912. <tr valign="top">
  2913. <td style="padding-left: 0px; padding-right: 0px; padding-top: 7px;">
  2914. <label for="pd_show_posts">
  2915. <input type="checkbox" name="pd_show_posts" id="pd_show_posts" <?php if( $show_posts > 0 ) echo( ' checked="checked" ' ); ?> value="1" /> <?php _e('Enable for blog posts', 'polldaddy');?>
  2916. </label>
  2917. <span id="span_posts">
  2918. <select name="posts_pos"><?php
  2919. $select = array( __('Above each blog post', 'polldaddy') => '0', __('Below each blog post', 'polldaddy') => '1' );
  2920. foreach( $select as $option => $value ) :
  2921. $selected = '';
  2922. if ( $value == $pos_posts )
  2923. $selected = ' selected="selected"';
  2924. echo ( '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' );
  2925. endforeach;?>
  2926. </select>
  2927. </span>
  2928. </td>
  2929. </tr>
  2930. <tr valign="top">
  2931. <td style="padding-left: 0px; padding-right: 0px; padding-top: 7px;">
  2932. <label for="pd_show_posts_index">
  2933. <input type="checkbox" name="pd_show_posts_index" id="pd_show_posts_index" <?php if( $show_posts_index > 0 ) echo( ' checked="checked" ' ); ?> value="1" /> <?php _e('Enable for front page', 'polldaddy');?>
  2934. </label>
  2935. <span id="span_posts">
  2936. <select name="posts_index_pos"><?php
  2937. $select = array( __('Above each blog post', 'polldaddy') => '0', __('Below each blog post', 'polldaddy') => '1' );
  2938. foreach( $select as $option => $value ) :
  2939. $selected = '';
  2940. if ( $value == $pos_posts_index )
  2941. $selected = ' selected="selected"';
  2942. echo ( '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' );
  2943. endforeach;?>
  2944. </select>
  2945. </span>
  2946. </td>
  2947. </tr><?php
  2948. }
  2949. if ( $report_type == 'pages' ) {?>
  2950. <tr valign="top">
  2951. <td style="padding-left: 0px; padding-right: 0px; padding-top: 7px;">
  2952. <label for="pd_show_pages">
  2953. <input type="checkbox" name="pd_show_pages" id="pd_show_pages" <?php if( $show_pages > 0 ) echo( ' checked="checked" ' ); ?> value="1" /> <?php _e('Enable for pages', 'polldaddy');?>
  2954. </label>
  2955. <span id="span_pages">
  2956. <select name="pages_pos"><?php
  2957. $select = array( __('Above each page', 'polldaddy') => '0', __('Below each page', 'polldaddy') => '1' );
  2958. foreach( $select as $option => $value ) :
  2959. $selected = '';
  2960. if ( $value == $pos_pages )
  2961. $selected = ' selected="selected"';
  2962. echo ( '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' );
  2963. endforeach; ?>
  2964. </select>
  2965. </span>
  2966. </td>
  2967. </tr><?php
  2968. }
  2969. if ( $report_type == 'comments' ) {?>
  2970. <tr valign="top">
  2971. <td style="padding-left: 0px; padding-right: 0px; padding-top: 7px;">
  2972. <label for="pd_show_comments">
  2973. <input type="checkbox" name="pd_show_comments" id="pd_show_comments" <?php if( $show_comments > 0 ) echo( ' checked="checked" ' ); ?> value="1" /> <?php _e('Enable for comments', 'polldaddy');?>
  2974. </label>
  2975. <span id="span_comments">
  2976. <select name="comments_pos"><?php
  2977. $select = array( __('Above each comment', 'polldaddy') => '0', __('Below each comment', 'polldaddy') => '1' );
  2978. foreach( $select as $option => $value ) :
  2979. $selected = '';
  2980. if ( $value == $pos_comments )
  2981. $selected = ' selected="selected"';
  2982. echo ( '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' );
  2983. endforeach; ?>
  2984. </select>
  2985. </span>
  2986. </td>
  2987. </tr><?php
  2988. } ?>
  2989. </tbody>
  2990. </table>
  2991. <p class="submit">
  2992. <input class="button-primary" type="submit" value="<?php esc_attr_e('Save Changes', 'polldaddy');?>" name="Submit" />
  2993. </p><?php
  2994. if ( $report_type == 'posts' ) {
  2995. if( $show_posts > 0 || $show_posts_index > 0 )
  2996. $show_settings = true;
  2997. }
  2998. if ( $report_type == 'pages' && $show_pages > 0 )
  2999. $show_settings = true;
  3000. if ( $report_type == 'comments' && $show_comments > 0 )
  3001. $show_settings = true;
  3002. if ( $show_settings == true )
  3003. echo ( '<a href="javascript:" onclick="show_settings();">'.__('Advanced Settings', 'polldaddy').'</a>' );?>
  3004. </form>
  3005. </div>
  3006. </div>
  3007. </div>
  3008. <?php if ( $show_settings == true ){ ?>
  3009. <br />
  3010. <form method="post" action="">
  3011. <div id="poststuff" style="<?php echo( $settings_style ); ?>">
  3012. <div class="has-sidebar has-right-sidebar">
  3013. <div class="inner-sidebar-ratings">
  3014. <div class="postbox" id="submitdiv">
  3015. <h3><?php _e('Save', 'polldaddy');?></h3>
  3016. <div class="inside">
  3017. <div id="major-publishing-actions">
  3018. <input type="hidden" name="type" value="<?php echo( $report_type ); ?>" />
  3019. <input type="hidden" name="rating_id" value="<?php echo( $rating_id ); ?>" />
  3020. <input type="hidden" name="action" value="update-rating" />
  3021. <p id="publishing-action">
  3022. <input type="submit" value="<?php _e('Save Changes', 'polldaddy');?>" class="button-primary"/>
  3023. </p>
  3024. <br class="clear"/>
  3025. </div>
  3026. </div>
  3027. </div>
  3028. <div class="postbox">
  3029. <h3><?php _e('Preview', 'polldaddy');?></h3>
  3030. <div class="inside">
  3031. <p><?php _e('This is a demo of what your rating widget will look like', 'polldaddy'); ?>.</p>
  3032. <p>
  3033. <div id="pd_rating_holder_1"></div>
  3034. </p>
  3035. </div>
  3036. </div>
  3037. <div class="postbox">
  3038. <h3><?php _e('Customize Labels', 'polldaddy');?></h3>
  3039. <div class="inside">
  3040. <table width="99.5%">
  3041. <tr>
  3042. <td><p style="margin-bottom: 0px;"><?php _e('Vote', 'polldaddy');?></p></td>
  3043. </tr>
  3044. <tr>
  3045. <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_vote" id="text_vote" value="<?php echo empty( $settings->text_vote ) ? 'Vote' : wp_specialchars( $settings->text_vote ); ?>" maxlength="20" />
  3046. </tr>
  3047. <tr>
  3048. <td><p style="margin-bottom: 0px;"><?php _e('Votes', 'polldaddy');?></p></td>
  3049. </tr>
  3050. <tr>
  3051. <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_votes" id="text_votes" value="<?php echo empty( $settings->text_votes ) ? 'Votes' : wp_specialchars( $settings->text_votes ); ?>" maxlength="20" />
  3052. </tr>
  3053. <tr>
  3054. <td><p style="margin-bottom: 0px;"><?php _e('Rate This', 'polldaddy');?></p></td>
  3055. </tr>
  3056. <tr>
  3057. <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_rate_this" id="text_rate_this" value="<?php echo empty( $settings->text_rate_this ) ? 'Rate This' : wp_specialchars( $settings->text_rate_this ); ?>" maxlength="20" />
  3058. </tr>
  3059. <tr>
  3060. <td><p style="margin-bottom: 0px;"><?php printf(__( '%d star', 'polldaddy' ), 1);?></p></td>
  3061. </tr>
  3062. <tr>
  3063. <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_1_star" id="text_1_star" value="<?php echo empty( $settings->text_1_star ) ? '1 star' : wp_specialchars( $settings->text_1_star ); ?>" maxlength="20" />
  3064. </tr>
  3065. <tr>
  3066. <td><p style="margin-bottom: 0px;"><?php printf(__( '%d stars', 'polldaddy' ), 2);?></p></td>
  3067. </tr>
  3068. <tr>
  3069. <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_2_star" id="text_2_star" value="<?php echo empty( $settings->text_2_star ) ? '2 stars' : wp_specialchars( $settings->text_2_star ); ?>" maxlength="20" />
  3070. </tr>
  3071. <tr>
  3072. <td><p style="margin-bottom: 0px;"><?php printf(__( '%d stars', 'polldaddy' ), 3);?></p></td>
  3073. </tr>
  3074. <tr>
  3075. <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_3_star" id="text_3_star" value="<?php echo empty( $settings->text_3_star ) ? '3 stars' : wp_specialchars( $settings->text_3_star ); ?>" maxlength="20" />
  3076. </tr>
  3077. <tr>
  3078. <td><p style="margin-bottom: 0px;"><?php printf(__( '%d stars', 'polldaddy' ), 4);?></p></td>
  3079. </tr>
  3080. <tr>
  3081. <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_4_star" id="text_4_star" value="<?php echo empty( $settings->text_4_star ) ? '4 stars' : wp_specialchars( $settings->text_4_star ); ?>" maxlength="20" />
  3082. </tr>
  3083. <tr>
  3084. <td><p style="margin-bottom: 0px;"><?php printf(__( '%d stars', 'polldaddy' ), 5);?></p></td>
  3085. </tr>
  3086. <tr>
  3087. <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_5_star" id="text_5_star" value="<?php echo empty( $settings->text_5_star ) ? '5 stars' : wp_specialchars( $settings->text_5_star ); ?>" maxlength="20" />
  3088. </tr>
  3089. <tr>
  3090. <td><p style="margin-bottom: 0px;"><?php _e('Thank You', 'polldaddy');?></p></td>
  3091. </tr>
  3092. <tr>
  3093. <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_thank_you" id="text_thank_you" value="<?php echo empty( $settings->text_thank_you ) ? 'Thank You' : wp_specialchars( $settings->text_thank_you ); ?>" maxlength="20" />
  3094. </tr>
  3095. <tr>
  3096. <td><p style="margin-bottom: 0px;"><?php _e('Rate Up', 'polldaddy');?></p></td>
  3097. </tr>
  3098. <tr>
  3099. <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_rate_up" id="text_rate_up" value="<?php echo empty( $settings->text_rate_up ) ? 'Rate Up' : wp_specialchars( $settings->text_rate_up ); ?>" maxlength="20" />
  3100. </tr>
  3101. <tr>
  3102. <td><p style="margin-bottom: 0px;"><?php _e('Rate Down', 'polldaddy');?></p></td>
  3103. </tr>
  3104. <tr>
  3105. <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_rate_down" id="text_rate_down" value="<?php echo empty( $settings->text_rate_down ) ? 'Rate Down' : wp_specialchars( $settings->text_rate_down ); ?>" maxlength="20" />
  3106. </tr>
  3107. <tr>
  3108. <td><p style="margin-bottom: 0px;"><?php _e('Most Popular Content', 'polldaddy');?></p></td>
  3109. </tr>
  3110. <tr>
  3111. <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_popcontent" id="text_popcontent" value="<?php echo empty( $settings->text_popcontent ) ? 'Most Popular Content' : wp_specialchars( $settings->text_popcontent ); ?>" maxlength="20" />
  3112. </tr>
  3113. <tr>
  3114. <td><p style="margin-bottom: 0px;"><?php _e('Close', 'polldaddy');?></p></td>
  3115. </tr>
  3116. <tr>
  3117. <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_close" id="text_close" value="<?php echo empty( $settings->text_close ) ? 'Close' : wp_specialchars( $settings->text_close ); ?>" maxlength="20" />
  3118. </tr>
  3119. <tr>
  3120. <td><p style="margin-bottom: 0px;"><?php _e('All', 'polldaddy');?></p></td>
  3121. </tr>
  3122. <tr>
  3123. <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_all" id="text_all" value="<?php echo empty( $settings->text_all ) ? 'All' : wp_specialchars( $settings->text_all ); ?>" maxlength="20" />
  3124. </tr>
  3125. <tr>
  3126. <td><p style="margin-bottom: 0px;"><?php _e('Today', 'polldaddy');?></p></td>
  3127. </tr>
  3128. <tr>
  3129. <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_today" id="text_today" value="<?php echo empty( $settings->text_today ) ? 'Today' : wp_specialchars( $settings->text_today ); ?>" maxlength="20" />
  3130. </tr>
  3131. <tr>
  3132. <td><p style="margin-bottom: 0px;"><?php _e('This Week', 'polldaddy');?></p></td>
  3133. </tr>
  3134. <tr>
  3135. <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_thisweek" id="text_thisweek" value="<?php echo empty( $settings->text_thisweek ) ? 'This Week' : wp_specialchars( $settings->text_thisweek ); ?>" maxlength="20" />
  3136. </tr>
  3137. <tr>
  3138. <td><p style="margin-bottom: 0px;"><?php _e('This Month', 'polldaddy');?></p></td>
  3139. </tr>
  3140. <tr>
  3141. <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_thismonth" id="text_thismonth" value="<?php echo empty( $settings->text_thismonth ) ? 'This Month' : wp_specialchars( $settings->text_thismonth ); ?>" maxlength="20" />
  3142. </tr>
  3143. <tr>
  3144. <td><p style="margin-bottom: 0px;"><?php _e('Rated', 'polldaddy');?></p></td>
  3145. </tr>
  3146. <tr>
  3147. <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_rated" id="text_rated" value="<?php echo empty( $settings->text_rated ) ? 'Rated' : wp_specialchars( $settings->text_rated ); ?>" maxlength="20" />
  3148. </tr>
  3149. <tr>
  3150. <td><p style="margin-bottom: 0px;"><?php _e('There are no rated items for this period', 'polldaddy');?></p></td>
  3151. </tr>
  3152. <tr>
  3153. <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_noratings" id="text_noratings" value="<?php echo empty( $settings->text_noratings ) ? 'There are no rated items for this period' : wp_specialchars( $settings->text_noratings ); ?>" maxlength="50" />
  3154. </tr>
  3155. </table>
  3156. </div>
  3157. </div>
  3158. </div>
  3159. <div id="post-body-content" class="has-sidebar-content">
  3160. <div class="postbox">
  3161. <h3><?php _e('Rating Type', 'polldaddy');?></h3>
  3162. <div class="inside">
  3163. <p><?php _e('Here you can choose how you want your rating to display. The 5 star rating is the most commonly used. The Nero rating is useful for keeping it simple.', 'polldaddy'); ?></p>
  3164. <ul>
  3165. <li style="display: inline;margin-right: 10px;">
  3166. <label for="stars"><?php
  3167. $checked = '';
  3168. if ( $settings->type == 'stars' )
  3169. $checked = ' checked="checked"';?>
  3170. <input type="radio" onchange="pd_change_type( 0 );" <?php echo ( $checked ); ?> value="stars" id="stars" name="rating_type" />
  3171. <?php printf(__( '%d Star Rating', 'polldaddy' ), 5);?>
  3172. </label>
  3173. </li>
  3174. <li style="display: inline;">
  3175. <label><?php
  3176. $checked = '';
  3177. if ( $settings->type == 'nero' )
  3178. $checked = ' checked="checked"';?>
  3179. <input type="radio" onchange="pd_change_type( 1 );" <?php echo( $checked ); ?> value="nero" id="nero" name="rating_type" />
  3180. <?php _e('Nero Rating', 'polldaddy' );?>
  3181. </label>
  3182. </li>
  3183. </ul>
  3184. </div>
  3185. </div>
  3186. <div class="postbox">
  3187. <h3><?php _e('Rating Style', 'polldaddy');?></h3>
  3188. <div class="inside">
  3189. <table>
  3190. <tr>
  3191. <td height="30" width="100" id="editor_star_size_text"><?php _e('Star Size', 'polldaddy');?></td>
  3192. <td>
  3193. <select name="size" id="size" onchange="pd_bind(this);"><?php
  3194. $select = array( __('Small', 'polldaddy')." (16px)" => "sml", __('Medium', 'polldaddy')." (20px)" => "med", __('Large', 'polldaddy')." (24px)" => "lrg" );
  3195. foreach ( $select as $option => $value ) :
  3196. $selected = '';
  3197. if ( $settings->size == $value )
  3198. $selected = ' selected="selected"';
  3199. echo ( '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' . "\n" );
  3200. endforeach;?>
  3201. </select>
  3202. </td>
  3203. </tr>
  3204. <tr>
  3205. <td height="30" id="editor_star_color_text"><?php echo 'bubu'; _e('Star Color', 'polldaddy');?></td>
  3206. <td>
  3207. <select name="star_color" id="star_color" onchange="pd_bind(this);" style="display: none;"><?php
  3208. $select = array( __('Yellow', 'polldaddy') => "yellow", __('Red', 'polldaddy') => "red", __('Blue', 'polldaddy') => "blue", __('Green', 'polldaddy') => "green", __('Grey', 'polldaddy') => "grey" );
  3209. foreach ( $select as $option => $value ) :
  3210. $selected = '';
  3211. if ( $settings->star_color == $value )
  3212. $selected = ' selected="selected"';
  3213. echo ( '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' . "\n" );
  3214. endforeach;?>
  3215. </select>
  3216. <select name="nero_style" id="nero_style" onchange="pd_bind(this);" style="display: none;"><?php
  3217. $select = array( __('Hand', 'polldaddy') => "hand" );
  3218. foreach ( $select as $option => $value ) :
  3219. $selected = '';
  3220. if ( $settings->star_color == $value )
  3221. $selected = ' selected="selected"';
  3222. echo ( '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' . "\n" );
  3223. endforeach;?>
  3224. </select>
  3225. </td>
  3226. </tr>
  3227. <tr>
  3228. <td height="30"><?php _e('Custom Image', 'polldaddy');?></td>
  3229. <td><input type="text" onblur="pd_bind(this);" name="custom_star" id="custom_star" value="<?php echo( clean_url( $settings->custom_star ) ); ?>" maxlength="200" />
  3230. </tr>
  3231. </table>
  3232. </div>
  3233. </div>
  3234. <div class="postbox">
  3235. <h3><?php _e('Text Layout & Font', 'polldaddy');?></h3>
  3236. <div class="inside">
  3237. <table>
  3238. <tr>
  3239. <td width="100" height="30"><?php _e('Align', 'polldaddy');?></td>
  3240. <td>
  3241. <select id="font_align" onchange="pd_bind(this);" name="font_align"><?php
  3242. $select = array( __('Left', 'polldaddy') => "left", __('Center', 'polldaddy') => "center", __('Right', 'polldaddy') => "right" );
  3243. foreach( $select as $option => $value ):
  3244. $selected = '';
  3245. if ( $settings->font_align == $value )
  3246. $selected = ' selected="selected"';
  3247. echo ( '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>');
  3248. endforeach;?>
  3249. </select>
  3250. </td>
  3251. </tr>
  3252. <tr>
  3253. <td height="30"><?php _e('Position', 'polldaddy');?></td>
  3254. <td>
  3255. <select name="font_position" onchange="pd_bind(this);" id="font_position"><?php
  3256. $select = array( __('Top', 'polldaddy') => "top", __('Right', 'polldaddy') => "right", __('Bottom', 'polldaddy') => "bottom" );
  3257. foreach( $select as $option => $value ) :
  3258. $selected = '';
  3259. if ( $settings->font_position == $value )
  3260. $selected = ' selected="selected"';
  3261. echo ( '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>');
  3262. endforeach;?>
  3263. </select>
  3264. </td>
  3265. </tr>
  3266. <tr>
  3267. <td height="30"><?php _e('Font', 'polldaddy');?></td>
  3268. <td>
  3269. <select name="font_family" id="font_family" onchange="pd_bind(this);"><?php
  3270. $select = array( __('Inherit', 'polldaddy') => "", "Arial" => "arial", "Comic Sans MS" => "comic sans ms", "Courier" => "courier", "Georgia" => "georgia", "Lucida Grande" => "lucida grande", "Tahoma" => "tahoma", "Times" => "times", "Trebuchet MS" => "trebuchet ms", "Verdana" => "verdana" );
  3271. foreach( $select as $option => $value ) :
  3272. $selected = '';
  3273. if ( $settings->font_family == $value )
  3274. $selected = ' selected="selected"';
  3275. echo ( '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' );
  3276. endforeach;?>
  3277. </select>
  3278. </td>
  3279. </tr>
  3280. <tr>
  3281. <td height="30"><?php _e('Color', 'polldaddy');?></td>
  3282. <td><input type="text" onblur="pd_bind(this);" class="elmColor jscolor-picker" name="font_color" id="font_color" value="<?php echo( wp_specialchars( $settings->font_color ) ); ?>" maxlength="11" autocomplete="off"/>
  3283. </td>
  3284. </tr>
  3285. <tr>
  3286. <td><?php _e('Size', 'polldaddy');?></td>
  3287. <td>
  3288. <select name="font_size" id="font_size" onchange="pd_bind(this);"><?php
  3289. $select = array( __('Inherit', 'polldaddy') => "", "6px" => "6px", "8px" => "8px", "9px" => "9px", "10px" => "10px", "11px" => "11px", "12px" => "12px", "14px" => "14px", "16px" => "16px", "18px" => "18px", "20px" => "20px", "24px" => "24px", "30px" => "30px", "36px" => "36px", );
  3290. foreach ( $select as $option => $value ) :
  3291. $selected = '';
  3292. if ( $settings->font_size == $value )
  3293. $selected = ' selected="selected"';
  3294. echo ( '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' . "\n" );
  3295. endforeach;?>
  3296. </select>
  3297. </td>
  3298. </tr>
  3299. <tr>
  3300. <td height="30"><?php _e('Line Height', 'polldaddy');?></td>
  3301. <td>
  3302. <select name="font_line_height" id="font_line_height" onchange="pd_bind(this);"><?php
  3303. $select = array( __('Inherit', 'polldaddy') => "", "6px" => "6px", "8px" => "8px", "9px" => "9px", "10px" => "10px", "11px" => "11px", "12px" => "12px", "14px" => "14px", "16px" => "16px", "18px" => "18px", "20px" => "20px", "24px" => "24px", "30px" => "30px", "36px" => "36px", );
  3304. foreach ( $select as $option => $value ) :
  3305. $selected = '';
  3306. if ( $settings->font_line_height == $value )
  3307. $selected = ' selected="selected"';
  3308. echo ( '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' . "\n" );
  3309. endforeach; ?>
  3310. </select>
  3311. </td>
  3312. </tr>
  3313. <tr>
  3314. <td height="30"><?php _e('Bold', 'polldaddy');?></td>
  3315. <td><?php
  3316. $checked = '';
  3317. if ( $settings->font_bold == 'bold' )
  3318. $checked = ' checked="checked"';?>
  3319. <input type="checkbox" name="font_bold" onclick="pd_bind(this);" id="font_bold" value="bold" <?php echo( $checked ); ?> />
  3320. </td>
  3321. </tr>
  3322. <tr>
  3323. <td height="30"><?php _e('Italic', 'polldaddy');?></td><?php
  3324. $checked = '';
  3325. if( $settings->font_italic == 'italic' )
  3326. $checked = ' checked="checked"';?>
  3327. <td><input type="checkbox" name="font_italic" onclick="pd_bind(this);" id="font_italic" value="italic" <?php echo( $checked ); ?>/></td>
  3328. </tr>
  3329. </table>
  3330. </div>
  3331. </div>
  3332. <?php
  3333. if ( $this->is_admin ) { ?>
  3334. <div class="postbox">
  3335. <h3><?php _e('Extra Settings', 'polldaddy');?></h3>
  3336. <div class="inside">
  3337. <table>
  3338. <tr>
  3339. <td width="100" height="30"><?php _e('Results Popup', 'polldaddy');?></td>
  3340. <td>
  3341. <input type="checkbox" onchange="pd_bind(this);" value="on" name="polldaddy-rating-popup" id="polldaddy-rating-popup" <?php echo !$popup_disabled ? 'checked="checked"' : ''; ?> />
  3342. </td>
  3343. <td>
  3344. <span class="description">
  3345. <label for="polldaddy-rating-popup"><?php _e( 'Uncheck this box to disable the results popup', 'polldaddy' ); ?></label>
  3346. </span>
  3347. </td>
  3348. </tr><?php
  3349. if ( $report_type == 'posts' ) {
  3350. $exclude_post_ids = wp_specialchars( get_option( 'pd-rating-exclude-post-ids' ) ); ?>
  3351. <tr>
  3352. <td width="100" height="30"><?php _e('Rating ID', 'polldaddy');?></td>
  3353. <td>
  3354. <input type="text" name="polldaddy-post-rating-id" id="polldaddy-post-rating-id" value="<?php echo $rating_id; ?>" />
  3355. </td>
  3356. <td>
  3357. <span class="description">
  3358. <label for="polldaddy-post-rating-id"><?php _e( 'This is the rating ID used in posts', 'polldaddy' ); ?></label>
  3359. </span>
  3360. </td>
  3361. </tr>
  3362. <tr>
  3363. <td width="100" height="30"><?php _e('Exclude Posts', 'polldaddy');?></td>
  3364. <td>
  3365. <input type="text" name="exclude-post-ids" id="exclude-post-ids" value="<?php echo $exclude_post_ids; ?>" />
  3366. </td>
  3367. <td>
  3368. <span class="description">
  3369. <label for="exclude-post-ids"><?php _e( 'Enter the Post IDs where you want to exclude ratings from. Please use a comma-delimited list, eg. 1,2,3', 'polldaddy' ); ?></label>
  3370. </span>
  3371. </td>
  3372. </tr><?php
  3373. } else if ( $report_type == 'pages' ) {
  3374. $exclude_page_ids = wp_specialchars( get_option( 'pd-rating-exclude-page-ids' ) ); ?>
  3375. <tr>
  3376. <td width="100" height="30"><?php _e('Rating ID', 'polldaddy');?></td>
  3377. <td>
  3378. <input type="text" name="polldaddy-page-rating-id" id="polldaddy-page-rating-id" value="<?php echo $rating_id; ?>" />
  3379. </td>
  3380. <td>
  3381. <span class="description">
  3382. <label for="polldaddy-page-rating-id"><?php _e( 'This is the rating ID used in pages', 'polldaddy' ); ?></label>
  3383. </span>
  3384. </td>
  3385. </tr>
  3386. <tr>
  3387. <td width="100" height="30"><?php _e('Exclude Pages', 'polldaddy');?></td>
  3388. <td>
  3389. <input type="text" name="exclude-page-ids" id="exclude-page-ids" value="<?php echo $exclude_page_ids; ?>" />
  3390. </td>
  3391. <td>
  3392. <span class="description">
  3393. <label for="exclude-page-ids"><?php _e( 'Enter the Page IDs where you want to exclude ratings from. Please use a comma-delimited list, eg. 1,2,3', 'polldaddy' ); ?></label>
  3394. </span>
  3395. </td>
  3396. </tr><?php
  3397. } else if ( $report_type == 'comments' ) { ?>
  3398. <tr>
  3399. <td width="100" height="30"><?php _e('Rating ID', 'polldaddy');?></td>
  3400. <td>
  3401. <input type="text" name="polldaddy-comment-rating-id" id="polldaddy-comment-rating-id" value="<?php echo $rating_id; ?>" />
  3402. </td>
  3403. <td>
  3404. <span class="description">
  3405. <label for="polldaddy-comment-rating-id"><?php _e( 'This is the rating ID used in comments', 'polldaddy' ); ?></label>
  3406. </span>
  3407. </td>
  3408. </tr><?php
  3409. } ?>
  3410. </table>
  3411. </div>
  3412. </div>
  3413. <?php } ?>
  3414. </div>
  3415. </div>
  3416. </form>
  3417. <script language="javascript">
  3418. jQuery( document ).ready(function(){
  3419. plugin = new Plugin( {
  3420. delete_rating: '<?php _e( 'Are you sure you want to delete the rating for "%s"?','polldaddy'); ?>',
  3421. delete_poll: '<?php _e( 'Are you sure you want to delete "%s"?','polldaddy'); ?>',
  3422. delete_answer: '<?php _e( 'Are you sure you want to delete this answer?','polldaddy'); ?>',
  3423. delete_answer_title: '<?php _e( 'delete this answer','polldaddy'); ?>',
  3424. standard_styles: '<?php _e( 'Standard Styles','polldaddy'); ?>',
  3425. custom_styles: '<?php _e( 'Custom Styles','polldaddy'); ?>'
  3426. } );
  3427. });
  3428. </script>
  3429. <script type="text/javascript">
  3430. PDRTJS_settings = <?php echo ( $settings_text ); ?>;
  3431. PDRTJS_settings.id = "1";
  3432. PDRTJS_settings.unique_id = "xxx";
  3433. PDRTJS_settings.title = "";
  3434. PDRTJS_settings.override = "<?php echo( $rating_id ); ?>";
  3435. PDRTJS_settings.permalink = "";
  3436. PDRTJS_1 = new PDRTJS_RATING( PDRTJS_settings );
  3437. pd_change_type( <?php echo ( $rating_type ) ?> );
  3438. </script><?php
  3439. } ?>
  3440. </div><?php
  3441. } // from if !error ?>
  3442. </div><?php
  3443. }
  3444. function update_rating(){
  3445. $rating_type = 0;
  3446. $rating_id = 0;
  3447. $new_rating_id = 0;
  3448. $type = 'post';
  3449. $set = null;
  3450. if( isset( $_REQUEST['rating_id'] ) )
  3451. $rating_id = (int) $_REQUEST['rating_id'];
  3452. if( isset( $_REQUEST['polldaddy-post-rating-id'] ) ) {
  3453. $new_rating_id = (int) $_REQUEST['polldaddy-post-rating-id'];
  3454. $type = 'posts';
  3455. }
  3456. else if( isset( $_REQUEST['polldaddy-page-rating-id'] ) ) {
  3457. $new_rating_id = (int) $_REQUEST['polldaddy-page-rating-id'];
  3458. $type = 'pages';
  3459. }
  3460. else if( isset( $_REQUEST['polldaddy-comment-rating-id'] ) ) {
  3461. $new_rating_id = (int) $_REQUEST['polldaddy-comment-rating-id'];
  3462. $type = 'comments';
  3463. } else{
  3464. $new_rating_id = $rating_id;
  3465. }
  3466. if( $rating_id > 0 && $rating_id == $new_rating_id ) {
  3467. if( isset( $_REQUEST['rating_type'] ) && $_REQUEST['rating_type'] == 'stars' ) {
  3468. $set->type = 'stars';
  3469. $rating_type = 0;
  3470. if( isset( $_REQUEST['star_color'] ) )
  3471. $set->star_color = attribute_escape( $_REQUEST['star_color'] );
  3472. } else {
  3473. $set->type = 'nero';
  3474. $rating_type = 1;
  3475. if( isset( $_REQUEST['nero_style'] ) )
  3476. $set->star_color = attribute_escape( $_REQUEST['nero_style'] );
  3477. }
  3478. $set->size = wp_specialchars( $_REQUEST['size'], 1 );
  3479. $set->custom_star = wp_specialchars( clean_url( $_REQUEST['custom_star'] ) , 1 );
  3480. $set->font_align = wp_specialchars( $_REQUEST['font_align'], 1 );
  3481. $set->font_position = wp_specialchars( $_REQUEST['font_position'], 1 );
  3482. $set->font_family = wp_specialchars( $_REQUEST['font_family'], 1);
  3483. $set->font_size = wp_specialchars( $_REQUEST['font_size'], 1 );
  3484. $set->font_line_height = wp_specialchars( $_REQUEST['font_line_height'], 1 );
  3485. if ( isset( $_REQUEST['font_bold'] ) && $_REQUEST['font_bold'] == 'bold' )
  3486. $set->font_bold = 'bold';
  3487. else
  3488. $set->font_bold = 'normal';
  3489. if ( isset( $_REQUEST['font_italic'] ) && $_REQUEST['font_italic'] == 'italic' )
  3490. $set->font_italic = 'italic';
  3491. else
  3492. $set->font_italic = 'normal';
  3493. $set->text_vote = wp_specialchars( $_REQUEST['text_vote'], 1 );
  3494. $set->text_votes = wp_specialchars( $_REQUEST['text_votes'], 1 );
  3495. $set->text_rate_this = wp_specialchars( $_REQUEST['text_rate_this'], 1 );
  3496. $set->text_1_star = wp_specialchars( $_REQUEST['text_1_star'], 1 );
  3497. $set->text_2_star = wp_specialchars( $_REQUEST['text_2_star'], 1 );
  3498. $set->text_3_star = wp_specialchars( $_REQUEST['text_3_star'], 1 );
  3499. $set->text_4_star = wp_specialchars( $_REQUEST['text_4_star'], 1 );
  3500. $set->text_5_star = wp_specialchars( $_REQUEST['text_5_star'], 1 );
  3501. $set->text_thank_you = wp_specialchars( $_REQUEST['text_thank_you'], 1 );
  3502. $set->text_rate_up = wp_specialchars( $_REQUEST['text_rate_up'], 1 );
  3503. $set->text_rate_down = wp_specialchars( $_REQUEST['text_rate_down'], 1 );
  3504. $set->font_color = wp_specialchars( $_REQUEST['font_color'], 1 );
  3505. $set->text_popcontent= wp_specialchars( $_REQUEST['text_popcontent'], 1 );
  3506. $set->text_close = wp_specialchars( $_REQUEST['text_close'], 1 );
  3507. $set->text_all = wp_specialchars( $_REQUEST['text_all'], 1 );
  3508. $set->text_today = wp_specialchars( $_REQUEST['text_today'], 1 );
  3509. $set->text_thisweek = wp_specialchars( $_REQUEST['text_thisweek'], 1 );
  3510. $set->text_thismonth = wp_specialchars( $_REQUEST['text_thismonth'], 1 );
  3511. $set->text_rated = wp_specialchars( $_REQUEST['text_rated'], 1 );
  3512. $set->text_noratings = wp_specialchars( $_REQUEST['text_noratings'], 1 );
  3513. $set->popup = 'off';
  3514. if( isset( $_REQUEST['polldaddy-rating-popup'] ) )
  3515. $set->popup = ( $_REQUEST['polldaddy-rating-popup'] == 'on' ? 'on' : 'off' );
  3516. $settings_text = json_encode( $set );
  3517. $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
  3518. $polldaddy->reset();
  3519. $rating = $polldaddy->update_rating( $rating_id, $settings_text, $rating_type );
  3520. }
  3521. else if( $this->is_admin && $new_rating_id > 0 ){
  3522. switch( $type ){
  3523. case 'pages':
  3524. update_option( 'pd-rating-pages-id', $new_rating_id );
  3525. if( (int) get_option( 'pd-rating-pages' ) > 0 )
  3526. update_option( 'pd-rating-pages', $new_rating_id );
  3527. break;
  3528. case 'comments':
  3529. update_option( 'pd-rating-comments-id', $new_rating_id );
  3530. if( (int) get_option( 'pd-rating-comments' ) > 0 )
  3531. update_option( 'pd-rating-comments', $new_rating_id );
  3532. break;
  3533. case 'posts':
  3534. update_option( 'pd-rating-posts-id', $new_rating_id );
  3535. if( (int) get_option( 'pd-rating-posts' ) > 0 )
  3536. update_option( 'pd-rating-posts', $new_rating_id );
  3537. }
  3538. }
  3539. if( $this->is_admin ) {
  3540. if( $type=='posts' && isset( $_REQUEST['exclude-post-ids'] ) ) {
  3541. $exclude_post_ids = $_REQUEST['exclude-post-ids'];
  3542. if( empty( $exclude_post_ids ) ){
  3543. update_option( 'pd-rating-exclude-post-ids', '' );
  3544. } else{
  3545. $post_ids = array();
  3546. $ids = explode( ',', $exclude_post_ids );
  3547. if( !empty( $ids ) ){
  3548. foreach( (array) $ids as $id ){
  3549. if( (int) $id > 0 )
  3550. $post_ids[] = (int) $id;
  3551. }
  3552. }
  3553. if( !empty( $post_ids ) ){
  3554. $exclude_post_ids = implode( ',', $post_ids );
  3555. update_option( 'pd-rating-exclude-post-ids', $exclude_post_ids );
  3556. }
  3557. }
  3558. }
  3559. if( $type=='pages' && isset( $_REQUEST['exclude-page-ids'] ) ) {
  3560. $exclude_page_ids = $_REQUEST['exclude-page-ids'];
  3561. if( empty( $exclude_page_ids ) ){
  3562. update_option( 'pd-rating-exclude-page-ids', '' );
  3563. } else{
  3564. $page_ids = array();
  3565. $ids = explode( ',', $exclude_page_ids );
  3566. if( !empty( $ids ) ){
  3567. foreach( (array) $ids as $id ){
  3568. if( (int) $id > 0 )
  3569. $page_ids[] = (int) $id;
  3570. }
  3571. }
  3572. if( !empty( $page_ids ) ){
  3573. $exclude_page_ids = implode( ',', $page_ids );
  3574. update_option( 'pd-rating-exclude-page-ids', $exclude_page_ids );
  3575. }
  3576. }
  3577. }
  3578. }
  3579. }
  3580. function rating_reports() {
  3581. $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
  3582. $rating_id = get_option( 'pd-rating-posts-id' );
  3583. $report_type = 'posts';
  3584. $period = '7';
  3585. $show_rating = 0;
  3586. if ( isset( $_REQUEST['change-report-to'] ) ){
  3587. switch ( $_REQUEST['change-report-to'] ) :
  3588. case 'pages':
  3589. $report_type = 'pages';
  3590. $rating_id = (int) get_option( 'pd-rating-pages-id' );
  3591. break;
  3592. case 'comments':
  3593. $report_type = 'comments';
  3594. $rating_id = get_option( 'pd-rating-comments-id' );
  3595. break;
  3596. case 'posts':
  3597. $report_type = 'posts';
  3598. $rating_id = get_option( 'pd-rating-posts-id' );
  3599. break;
  3600. endswitch;
  3601. }
  3602. if ( isset( $_REQUEST['filter'] ) && $_REQUEST['filter'] ){
  3603. switch ( $_REQUEST['filter'] ) :
  3604. case '1':
  3605. $period = '1';
  3606. break;
  3607. case '7':
  3608. $period = '7';
  3609. break;
  3610. case '31':
  3611. $period = '31';
  3612. break;
  3613. case '90':
  3614. $period = '90';
  3615. break;
  3616. case '365':
  3617. $period = '365';
  3618. break;
  3619. case 'all':
  3620. $period = 'all';
  3621. break;
  3622. endswitch;
  3623. }
  3624. $page_size = 15;
  3625. $current_page = 1;
  3626. if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'change-report' ){
  3627. $current_page = 1;
  3628. } else {
  3629. if ( isset( $_REQUEST['paged'] ) ) {
  3630. $current_page = (int) $_REQUEST['paged'];
  3631. if ( $current_page == 0 )
  3632. $current_page = 1;
  3633. }
  3634. }
  3635. $start = ( $current_page * $page_size ) - $page_size;
  3636. $end = $page_size;
  3637. $response = $polldaddy->get_rating_results( $rating_id, $period, $start, $end );
  3638. $total = $total_pages = 0;
  3639. $ratings = null;
  3640. if( !empty($response) ){
  3641. $ratings = $response->rating;
  3642. $total = (int) $response->_total;
  3643. $total_pages = ceil( $total / $page_size );
  3644. }
  3645. $page_links = paginate_links( array(
  3646. 'base' => add_query_arg( array ('paged' => '%#%', 'change-report-to' => $report_type, 'filter' => $period ) ),
  3647. 'format' => '',
  3648. 'prev_text' => __('&laquo;', 'polldaddy'),
  3649. 'next_text' => __('&raquo;', 'polldaddy'),
  3650. 'total' => $total_pages,
  3651. 'current' => $current_page
  3652. ));
  3653. ?>
  3654. <div class="wrap">
  3655. <h2><?php _e('Rating Reports', 'polldaddy');?> <span style="font-size: 16px;">(<?php echo ( $report_type ); ?>)</span></h2>
  3656. <div class="clear"></div>
  3657. <form method="post" action="admin.php?page=ratings&action=reports">
  3658. <div class="tablenav">
  3659. <div class="alignleft actions">
  3660. <select name="action">
  3661. <option selected="selected" value=""><?php _e( 'Actions', 'polldaddy' ); ?></option>
  3662. <option value="delete"><?php _e( 'Delete', 'polldaddy' ); ?></option>
  3663. </select>
  3664. <input type="hidden" name="id" id="id" value="<?php echo (int) $rating_id; ?>" />
  3665. <input class="button-secondary action" type="submit" name="doaction" value="<?php _e( 'Apply', 'polldaddy' ); ?>" />
  3666. <?php wp_nonce_field( 'action-rating_bulk' ); ?>
  3667. <select name="change-report-to"><?php
  3668. $select = array( __('Posts', 'polldaddy') => "posts", __('Pages', 'polldaddy') => "pages", __('Comments', 'polldaddy') => "comments" );
  3669. foreach ( $select as $option => $value ) :
  3670. $selected = '';
  3671. if ( $value == $report_type )
  3672. $selected = ' selected="selected"';?>
  3673. <option value="<?php echo $value; ?>" <?php echo $selected; ?>><?php echo $option; ?></option>
  3674. <?php endforeach; ?>
  3675. </select>
  3676. <select name="filter"><?php
  3677. $select = array( __('Last 24 hours', 'polldaddy') => "1", __('Last 7 days', 'polldaddy') => "7", __('Last 31 days', 'polldaddy') => "31", __('Last 3 months', 'polldaddy') => "90", __('Last 12 months', 'polldaddy') => "365", __('All time', 'polldaddy') => "all" );
  3678. foreach ( $select as $option => $value ) :
  3679. $selected = '';
  3680. if ( $value == $period )
  3681. $selected = ' selected="selected"';?>
  3682. <option value="<?php echo $value; ?>" <?php echo $selected; ?>><?php echo $option; ?></option>
  3683. <?php endforeach; ?>
  3684. </select>
  3685. <input class="button-secondary action" type="submit" value="<?php _e('Filter', 'polldaddy');?>" />
  3686. </div>
  3687. <div class="alignright">
  3688. <div class="tablenav-pages">
  3689. <?php echo( $page_links ); ?>
  3690. </div>
  3691. </div>
  3692. </div>
  3693. <table class="widefat"><?php
  3694. if ( empty( $ratings ) ) { ?>
  3695. <tbody>
  3696. <tr>
  3697. <td colspan="4"><?php printf(__('No ratings have been collected for your %s yet.', 'polldaddy'), $report_type); ?></td>
  3698. </tr>
  3699. </tbody><?php
  3700. } else { ?>
  3701. <thead>
  3702. <tr>
  3703. <th scope="col" class="manage-column column-cb check-column" id="cb"><input type="checkbox"></th>
  3704. <th scope="col" class="manage-column column-title" id="title"><?php _e('Title', 'polldaddy');?></th>
  3705. <th scope="col" class="manage-column column-id" id="id"><?php _e('Unique ID', 'polldaddy');?></th>
  3706. <th scope="col" class="manage-column column-date" id="date"><?php _e('Start Date', 'polldaddy');?></th>
  3707. <th scope="col" class="manage-column column-vote num" id="votes"><?php _e('Votes', 'polldaddy');?></th>
  3708. <th scope="col" class="manage-column column-rating num" id="rating"><?php _e('Average Rating', 'polldaddy');?></th>
  3709. </tr>
  3710. </thead>
  3711. <tbody><?php
  3712. $alt_counter = 0;
  3713. $alt = '';
  3714. foreach ( $ratings as $rating ) :
  3715. $delete_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete', 'id' => $rating_id, 'rating' => $rating->uid, 'change-report-to' => $report_type, 'message' => false ) ), "delete-rating_$rating->uid" ) );
  3716. $alt_counter++;?>
  3717. <tr <?php echo ( $alt_counter & 1 ) ? ' class="alternate"' : ''; ?>>
  3718. <th class="check-column" scope="row"><input type="checkbox" value="<?php echo wp_specialchars( $rating->uid ); ?>" name="rating[]" /></th>
  3719. <td class="post-title column-title">
  3720. <strong><a href="<?php echo clean_url( $rating->permalink ); ?>"><?php echo strlen( wp_specialchars( $rating->title ) ) > 75 ? substr( wp_specialchars( $rating->title ), 0, 72 ) . '&hellip' : wp_specialchars( $rating->title ); ?></a></strong>
  3721. <div class="row-actions">
  3722. <?php if ( $delete_link ) { ?>
  3723. <span class="delete"><a class="delete-rating delete" href="<?php echo $delete_link; ?>"><?php _e( 'Delete', 'polldaddy' ); ?></a></span>
  3724. <?php } ?>
  3725. </div>
  3726. </td>
  3727. <td class="column-id">
  3728. <?php echo wp_specialchars( $rating->uid ); ?>
  3729. </td>
  3730. <td class="date column-date">
  3731. <abbr title="<?php echo date( __('Y/m/d g:i:s A', 'polldaddy'), $rating->date ); ?>"><?php echo str_replace( '-', '/', substr( wp_specialchars( $rating->date ), 0, 10 ) ); ?></abbr>
  3732. </td>
  3733. <td class="column-vote num"><?php echo number_format( $rating->_votes ); ?></td>
  3734. <td class="column-rating num"><table width="100%"><tr align="center"><td style="border:none;"><?php
  3735. if ( $rating->_type == 0 ) {
  3736. $avg_rating = $this->round( $rating->average_rating, 0.5 );?>
  3737. <div style="width:100px"><?php
  3738. $image_pos = '';
  3739. for ( $c = 1; $c <= 5; $c++ ) :
  3740. if ( $avg_rating > 0 ) {
  3741. if ( $avg_rating < $c )
  3742. $image_pos = 'bottom left';
  3743. if ( $avg_rating == ( $c - 1 + 0.5 ) )
  3744. $image_pos = 'center left';
  3745. } ?>
  3746. <div style="width: 20px; height: 20px; background: url(http://i.polldaddy.com/ratings/images/star-yellow-med.png) <?php echo $image_pos; ?>; float: left;"></div><?php
  3747. endfor; ?>
  3748. <br class="clear" />
  3749. </div><?php
  3750. } else { ?>
  3751. <div>
  3752. <div style="margin: 0px 0px 0px 20px; background: transparent url(http://i.polldaddy.com/images/rate-graph-up.png); width: 20px; height: 20px; float: left;"></div>
  3753. <div style="float:left; line-height: 20px; padding: 0px 10px 0px 5px;"><?php echo number_format ( $rating->total1 );?></div>
  3754. <div style="margin: 0px; background: transparent url(http://i.polldaddy.com/images/rate-graph-dn.png); width: 20px; height: 20px; float: left;"></div>
  3755. <div style="float:left; line-height: 20px; padding: 0px 10px 0px 5px;"><?php echo number_format( $rating->total2 );?></div>
  3756. <br class="clear" />
  3757. </div><?php
  3758. } ?>
  3759. </td></tr></table>
  3760. </td>
  3761. </tr><?php
  3762. endforeach;
  3763. ?>
  3764. </tbody><?php
  3765. } ?>
  3766. </table>
  3767. <div class="tablenav">
  3768. <div class="alignright">
  3769. <div class="tablenav-pages">
  3770. <?php echo $page_links; ?>
  3771. </div>
  3772. </div>
  3773. </div>
  3774. </form>
  3775. </div>
  3776. <p></p>
  3777. <script language="javascript">
  3778. jQuery( document ).ready(function(){
  3779. plugin = new Plugin( {
  3780. delete_rating: '<?php _e( 'Are you sure you want to delete the rating for "%s"?','polldaddy'); ?>',
  3781. delete_poll: '<?php _e( 'Are you sure you want to delete "%s"?','polldaddy'); ?>',
  3782. delete_answer: '<?php _e( 'Are you sure you want to delete this answer?','polldaddy'); ?>',
  3783. delete_answer_title: '<?php _e( 'delete this answer','polldaddy'); ?>',
  3784. standard_styles: '<?php _e( 'Standard Styles','polldaddy'); ?>',
  3785. custom_styles: '<?php _e( 'Custom Styles','polldaddy'); ?>'
  3786. } );
  3787. });
  3788. </script><?php
  3789. }
  3790. function plugin_options() {
  3791. if ( isset( $_POST['polldaddy_email'] ) ){
  3792. $account_email = attribute_escape( $_POST['polldaddy_email'] );
  3793. }
  3794. else{
  3795. $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
  3796. $account = $polldaddy->get_account();
  3797. if( !empty($account) )
  3798. $account_email = attribute_escape( $account->email );
  3799. $polldaddy->reset();
  3800. $poll = $polldaddy->get_poll( 1 );
  3801. $options = array(
  3802. 101 => __( 'Aluminum Narrow','polldaddy'),
  3803. 102 => __( 'Aluminum Medium','polldaddy'),
  3804. 103 => __( 'Aluminum Wide','polldaddy'),
  3805. 104 => __( 'Plain White Narrow','polldaddy'),
  3806. 105 => __( 'Plain White Medium','polldaddy'),
  3807. 106 => __( 'Plain White Wide','polldaddy'),
  3808. 107 => __( 'Plain Black Narrow','polldaddy'),
  3809. 108 => __( 'Plain Black Medium','polldaddy'),
  3810. 109 => __( 'Plain Black Wide','polldaddy'),
  3811. 110 => __( 'Paper Narrow','polldaddy'),
  3812. 111 => __( 'Paper Medium','polldaddy'),
  3813. 112 => __( 'Paper Wide','polldaddy'),
  3814. 113 => __( 'Skull Dark Narrow','polldaddy'),
  3815. 114 => __( 'Skull Dark Medium','polldaddy'),
  3816. 115 => __( 'Skull Dark Wide','polldaddy'),
  3817. 116 => __( 'Skull Light Narrow','polldaddy'),
  3818. 117 => __( 'Skull Light Medium','polldaddy'),
  3819. 118 => __( 'Skull Light Wide','polldaddy'),
  3820. 157 => __( 'Micro','polldaddy'),
  3821. 119 => __( 'Plastic White Narrow','polldaddy'),
  3822. 120 => __( 'Plastic White Medium','polldaddy'),
  3823. 121 => __( 'Plastic White Wide','polldaddy'),
  3824. 122 => __( 'Plastic Grey Narrow','polldaddy'),
  3825. 123 => __( 'Plastic Grey Medium','polldaddy'),
  3826. 124 => __( 'Plastic Grey Wide','polldaddy'),
  3827. 125 => __( 'Plastic Black Narrow','polldaddy'),
  3828. 126 => __( 'Plastic Black Medium','polldaddy'),
  3829. 127 => __( 'Plastic Black Wide','polldaddy'),
  3830. 128 => __( 'Manga Narrow','polldaddy'),
  3831. 129 => __( 'Manga Medium','polldaddy'),
  3832. 130 => __( 'Manga Wide','polldaddy'),
  3833. 131 => __( 'Tech Dark Narrow','polldaddy'),
  3834. 132 => __( 'Tech Dark Medium','polldaddy'),
  3835. 133 => __( 'Tech Dark Wide','polldaddy'),
  3836. 134 => __( 'Tech Grey Narrow','polldaddy'),
  3837. 135 => __( 'Tech Grey Medium','polldaddy'),
  3838. 136 => __( 'Tech Grey Wide','polldaddy'),
  3839. 137 => __( 'Tech Light Narrow','polldaddy'),
  3840. 138 => __( 'Tech Light Medium','polldaddy'),
  3841. 139 => __( 'Tech Light Wide','polldaddy'),
  3842. 140 => __( 'Working Male Narrow','polldaddy'),
  3843. 141 => __( 'Working Male Medium','polldaddy'),
  3844. 142 => __( 'Working Male Wide','polldaddy'),
  3845. 143 => __( 'Working Female Narrow','polldaddy'),
  3846. 144 => __( 'Working Female Medium','polldaddy'),
  3847. 145 => __( 'Working Female Wide','polldaddy'),
  3848. 146 => __( 'Thinking Male Narrow','polldaddy'),
  3849. 147 => __( 'Thinking Male Medium','polldaddy'),
  3850. 148 => __( 'Thinking Male Wide','polldaddy'),
  3851. 149 => __( 'Thinking Female Narrow','polldaddy'),
  3852. 150 => __( 'Thinking Female Medium','polldaddy'),
  3853. 151 => __( 'Thinking Female Wide','polldaddy'),
  3854. 152 => __( 'Sunset Narrow','polldaddy'),
  3855. 153 => __( 'Sunset Medium','polldaddy'),
  3856. 154 => __( 'Sunset Wide','polldaddy'),
  3857. 155 => __( 'Music Medium','polldaddy'),
  3858. 156 => __( 'Music Wide','polldaddy')
  3859. );
  3860. $polldaddy->reset();
  3861. $styles = $polldaddy->get_styles();
  3862. if( !empty( $styles ) && !empty( $styles->style ) && count( $styles->style ) > 0 ){
  3863. foreach( (array) $styles->style as $style ){
  3864. $options[ (int) $style->_id ] = $style->title;
  3865. }
  3866. }
  3867. }
  3868. $this->print_errors();
  3869. ?>
  3870. <div id="options-page" class="wrap">
  3871. <div class="icon32" id="icon-options-general"><br/></div>
  3872. <h2>
  3873. <?php _e( 'Options', 'polldaddy' ); ?>
  3874. </h2>
  3875. <?php if( $this->is_admin || $this->multiple_accounts ) {?>
  3876. <h3>
  3877. <?php _e( 'PollDaddy Account Info', 'polldaddy' ); ?>
  3878. </h3>
  3879. <p>
  3880. <?php _e( 'This is the PollDadddy account you currently have imported into your WordPress account', 'polldaddy' ); ?>.
  3881. </p>
  3882. <form action="" method="post">
  3883. <table class="form-table">
  3884. <tbody>
  3885. <tr class="form-field form-required">
  3886. <th valign="top" scope="row">
  3887. <label for="polldaddy-email">
  3888. <?php _e( 'PollDaddy Email Address', 'polldaddy' ); ?>
  3889. </label>
  3890. </th>
  3891. <td>
  3892. <input type="text" name="polldaddy_email" id="polldaddy-email" aria-required="true" size="40" value="<?php echo $account_email; ?>" />
  3893. </td>
  3894. </tr>
  3895. <tr class="form-field form-required">
  3896. <th valign="top" scope="row">
  3897. <label for="polldaddy-password">
  3898. <?php _e( 'PollDaddy Password', 'polldaddy' ); ?>
  3899. </label>
  3900. </th>
  3901. <td>
  3902. <input type="password" name="polldaddy_password" id="polldaddy-password" aria-required="true" size="40" />
  3903. </td>
  3904. </tr>
  3905. </tbody>
  3906. </table>
  3907. <p class="submit">
  3908. <?php wp_nonce_field( 'polldaddy-account' ); ?>
  3909. <input type="hidden" name="action" value="import-account" />
  3910. <input type="hidden" name="account" value="import" />
  3911. <input type="submit" value="<?php echo attribute_escape( __( 'Import Account', 'polldaddy' ) ); ?>" />
  3912. </p>
  3913. </form>
  3914. <br />
  3915. <?php } ?>
  3916. <h3>
  3917. <?php _e( 'General Settings', 'polldaddy' ); ?>
  3918. </h3>
  3919. <form action="" method="post">
  3920. <table class="form-table">
  3921. <tbody>
  3922. <tr valign="top">
  3923. <th valign="top" scope="row">
  3924. <label>
  3925. <?php _e( 'Default poll settings', 'polldaddy' ); ?>
  3926. </label>
  3927. </th>
  3928. <td>
  3929. <fieldset>
  3930. <legend class="screen-reader-text"><span>poll-defaults</span></legend><?php
  3931. $selected = '';
  3932. if ( $poll->multipleChoice == 'yes' )
  3933. $selected = 'checked="checked"';?>
  3934. <label for="multipleChoice"><input type="checkbox" <?php echo $selected; ?> value="1" id="multipleChoice" name="multipleChoice"> <?php _e( 'Multiple Choice', 'polldaddy' ); ?></label>
  3935. <br /><?php
  3936. $selected = '';
  3937. if ( $poll->randomiseAnswers == 'yes' )
  3938. $selected = 'checked="checked"';?>
  3939. <label for="randomiseAnswers"><input type="checkbox" <?php echo $selected; ?> value="1" id="randomiseAnswers" name="randomiseAnswers"> <?php _e( 'Randomise Answers', 'polldaddy' ); ?></label>
  3940. <br /><?php
  3941. $selected = '';
  3942. if ( $poll->otherAnswer == 'yes' )
  3943. $selected = 'checked="checked"';?>
  3944. <label for="otherAnswer"><input type="checkbox" <?php echo $selected; ?> value="1" id="otherAnswer" name="otherAnswer"> <?php _e( 'Other Answer', 'polldaddy' ); ?></label>
  3945. <br /><?php
  3946. $selected = '';
  3947. if ( $poll->sharing == 'yes' )
  3948. $selected = 'checked="checked"';?>
  3949. <label for="sharing"><input type="checkbox" <?php echo $selected; ?> value="1" id="sharing" name="sharing"> <?php _e( 'Sharing', 'polldaddy' ); ?></label>
  3950. <br />
  3951. <label for="resultsType">
  3952. <select id="resultsType" name="resultsType">
  3953. <option <?php echo $poll->resultsType == 'show' ? 'selected="selected"':''; ?> value="show"><?php _e('Show', 'polldaddy'); ?></option>
  3954. <option <?php echo $poll->resultsType == 'hide' ? 'selected="selected"':''; ?> value="hide"><?php _e('Hide', 'polldaddy'); ?></option>
  3955. <option <?php echo $poll->resultsType == 'percent' ? 'selected="selected"':''; ?> value="percent"><?php _e('Percentages', 'polldaddy'); ?></option>
  3956. </select> <?php _e( 'Poll results', 'polldaddy' ); ?>
  3957. </label>
  3958. <br />
  3959. <label for="styleID">
  3960. <select id="styleID" name="styleID"><?php
  3961. foreach ( (array) $options as $styleID => $label ) :
  3962. $selected = $styleID == $poll->styleID ? ' selected="selected"' : ''; ?>
  3963. <option value="<?php echo (int) $styleID; ?>"<?php echo $selected; ?>><?php echo wp_specialchars( $label ); ?></option><?php
  3964. endforeach;?>
  3965. </select> <?php _e( 'Poll style', 'polldaddy' ); ?>
  3966. </label>
  3967. <br />
  3968. <label for="blockRepeatVotersType">
  3969. <select id="poll-block-repeat" name="blockRepeatVotersType">
  3970. <option <?php echo $poll->blockRepeatVotersType == 'off' ? 'selected="selected"':''; ?> value="off"><?php _e('Off', 'polldaddy'); ?></option>
  3971. <option <?php echo $poll->blockRepeatVotersType == 'cookie' ? 'selected="selected"':''; ?> value="cookie"><?php _e('Cookie', 'polldaddy'); ?></option>
  3972. <option <?php echo $poll->blockRepeatVotersType == 'cookieip' ? 'selected="selected"':''; ?> value="cookieip"><?php _e('Cookie & IP address', 'polldaddy'); ?></option>
  3973. </select> <?php _e( 'Block repeat voters', 'polldaddy' ); ?>
  3974. </label>
  3975. <br />
  3976. <label for="blockExpiration">
  3977. <select id="blockExpiration" name="blockExpiration">
  3978. <option value="0" <?php echo $poll->blockExpiration == 0 ? 'selected="selected"':''; ?>><?php _e('Never', 'polldaddy'); ?></option>
  3979. <option value="3600" <?php echo $poll->blockExpiration == 3600 ? 'selected="selected"':''; ?>><?php printf( __('%d hour', 'polldaddy'), 1 ); ?></option>
  3980. <option value="10800" <?php echo (int) $poll->blockExpiration == 10800 ? 'selected="selected"' : ''; ?>><?php printf( __('%d hours', 'polldaddy'), 3 ); ?></option>
  3981. <option value="21600" <?php echo (int) $poll->blockExpiration == 21600 ? 'selected="selected"' : ''; ?>><?php printf( __('%d hours', 'polldaddy'), 6 ); ?></option>
  3982. <option value="43200" <?php echo (int) $poll->blockExpiration == 43200 ? 'selected="selected"' : ''; ?>><?php printf( __('%d hours', 'polldaddy'), 12 ); ?></option>
  3983. <option value="86400" <?php echo (int) $poll->blockExpiration == 86400 ? 'selected="selected"' : ''; ?>><?php printf( __('%d day', 'polldaddy'), 1 ); ?></option>
  3984. <option value="604800" <?php echo (int) $poll->blockExpiration == 604800 ? 'selected="selected"' : ''; ?>><?php printf( __('%d week', 'polldaddy'), 1 ); ?></option>
  3985. <option value="2419200" <?php echo (int) $poll->blockExpiration == 2419200 ? 'selected="selected"' : ''; ?>><?php printf( __('%d month', 'polldaddy'), 1 ); ?></option>
  3986. </select> <?php _e( 'Block expiration limit', 'polldaddy' ); ?>
  3987. </label>
  3988. <br />
  3989. </fieldset>
  3990. </td>
  3991. </tr>
  3992. <?php $this->plugin_options_add(); ?>
  3993. </tbody>
  3994. </table>
  3995. <p class="submit">
  3996. <?php wp_nonce_field( 'polldaddy-account' ); ?>
  3997. <input type="hidden" name="action" value="update-options" />
  3998. <input type="submit" value="<?php echo attribute_escape( __( 'Save Options', 'polldaddy' ) ); ?>" />
  3999. </p>
  4000. </form>
  4001. </div>
  4002. <?php
  4003. }
  4004. function plugin_options_add(){}
  4005. function round($number, $increments) {
  4006. $increments = 1 / $increments;
  4007. return ( round ( $number * $increments ) / $increments );
  4008. }
  4009. function signup() {
  4010. return $this->api_key_page();
  4011. }
  4012. function can_edit( &$poll ) {
  4013. if ( empty( $poll->_owner ) )
  4014. return true;
  4015. if ( $this->id == $poll->_owner )
  4016. return true;
  4017. return (bool) current_user_can( 'edit_others_posts' );
  4018. }
  4019. }
  4020. require 'rating.php';
  4021. require 'polldaddy-org.php';