bb_get_option( 'bb_polldaddy_first_only' ), 'permission' => bb_get_option( 'bb_polldaddy_permission' ) ); // Load the gettext textdomain load_plugin_textdomain( 'polldaddy-for-bbpress', dirname( __FILE__ ) . '/languages' ); // Backwards compatibility if ( class_exists( 'BB_User' ) ) { $bb_polldaddy_user_class = 'BB_User'; } else { $bb_polldaddy_user_class = 'WP_User'; } function bb_polldaddy_get_poll_script( $poll ) { // Remove quote entities $poll = preg_replace( array( '/"/i', '/*39;/', '/*27;/i', '/*34;/', '/*22;/i' ), '', $poll ); $poll = trim( $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'; } global $bb_polldaddy_user_class; if ( !$user = new $bb_polldaddy_user_class( $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( '@\[\s*polldaddy\s*poll=([^\]]+)\]@', $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; } global $bb_polldaddy_user_class; if ( !$user = new $bb_polldaddy_user_class( $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' ); // Backwards compatibility if ( !function_exists( 'checked' ) ) { function checked( $checked, $current ) { if ( $checked == $current ) { echo ' checked="checked"'; } return; } } // Backwards compatibility if ( !function_exists( 'selected' ) ) { function selected( $selected, $current ) { if ( $selected === $current ) { echo ' selected="selected"'; } return; } } 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 ); } }