bb_get_option('bb_polldaddy_first_only'), 'permission' => bb_get_option('bb_polldaddy_permission') ); function bb_polldaddy_get_poll_script($poll) { return ''; } function bb_polldaddy_get_poll_script_callback($matches) { return bb_polldaddy_get_poll_script($matches[1]); } function bb_polldaddy_first_only_error_handler($atts, $content = null) { return __('Sorry, polls can only be added to the first post in a thread.', 'polldaddy-for-bbpress'); } function bb_polldaddy_permission_error_handler($atts, $content = null) { return __('Sorry, you do not have permission to add polls.', 'polldaddy-for-bbpress'); } // For bbPress less than 1.0-alpha-2 function bb_polldaddy_preg($post_text, $post_id) { global $bb_polldaddy_options; $callback = 'bb_polldaddy_get_poll_script_callback'; if ($bb_polldaddy_options['first_only'] && !bb_is_first($post_id)) { $callback = 'bb_polldaddy_first_only_error_handler'; } if (!$user_id = get_post_author_id($post_id)) { $callback = 'bb_polldaddy_permission_error_handler'; } if (!$user = new WP_User($user_id)) { $callback = 'bb_polldaddy_permission_error_handler'; } if ($bb_polldaddy_options['permission'] && !$user->has_cap($bb_polldaddy_options['permission'])) { $callback = 'bb_polldaddy_permission_error_handler'; } $post_text = preg_replace_callback('@\[polldaddy poll=(?:"|\')?([0-9]+)(?:"|\')?\]@', $callback, $post_text); return $post_text; } // For bbPress greater than 1.0-alpha-1 function bb_polldaddy_shortcode_handler($atts, $content = null) { extract( shortcode_atts( array('poll' => 'empty'), $atts ) ); return bb_polldaddy_get_poll_script($poll); } function bb_polldaddy_shortcode($post_text, $post_id) { global $bb_polldaddy_options; if ($bb_polldaddy_options['first_only'] && !bb_is_first($post_id)) { remove_shortcode('polldaddy'); add_shortcode('polldaddy', 'bb_polldaddy_first_only_error_handler'); return $post_text; } if (!$user_id = get_post_author_id($post_id)) { remove_shortcode('polldaddy'); add_shortcode('polldaddy', 'bb_polldaddy_permission_error_handler'); return $post_text; } if (!$user = new WP_User($user_id)) { remove_shortcode('polldaddy'); add_shortcode('polldaddy', 'bb_polldaddy_permission_error_handler'); return $post_text; } if ($bb_polldaddy_options['permission'] && !$user->has_cap($bb_polldaddy_options['permission'])) { remove_shortcode('polldaddy'); add_shortcode('polldaddy', 'bb_polldaddy_permission_error_handler'); return $post_text; } add_shortcode('polldaddy', 'bb_polldaddy_shortcode_handler'); return $post_text; } if (version_compare(bb_get_option('version'), '1.0-alpha-2', 'lt')) { add_filter( 'post_text', 'bb_polldaddy_preg', 5, 2); } else { add_filter( 'post_text', 'bb_polldaddy_shortcode', 5, 2 ); } if (!BB_IS_ADMIN) { return; } // Add filters for the admin area add_action('bb_admin_menu_generator', 'bb_polldaddy_admin_page_add'); add_action('bb_admin-header.php', 'bb_polldaddy_admin_page_process'); function bb_polldaddy_admin_page_add() { bb_admin_add_submenu(__('PollDaddy', 'polldaddy-for-bbpress'), 'use_keys', 'bb_polldaddy_admin_page'); } function bb_polldaddy_admin_page() { ?>
PollDaddy is a free hosted polls service where you can create polls to include in your bbPress topics.', 'polldaddy-for-bbpress'), 'http://polldaddy.com/'); ?>
$value ) { if ( !in_array( $option, array('_wpnonce', '_wp_http_referer', 'submit') ) ) { $option = trim( $option ); $value = is_array( $value ) ? $value : trim( $value ); $value = stripslashes_deep( $value ); if ( $value ) { bb_update_option( $option, $value ); } else { bb_delete_option( $option ); } } } $goback = add_query_arg('updated', 'true', wp_get_referer()); bb_safe_redirect($goback); } } ?>