prefix . "curlc_show_comment_url"; if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) { $sql = "CREATE TABLE " . $table_name . " ( comment_id bigint(20) NOT NULL, show_url bool NOT NULL, UNIQUE KEY (comment_id) );"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); } } /** * Register with options-page */ function curlc_register_with_options() { if (function_exists('add_options_page')) { add_options_page('Comment-URL Control', 'Comment-URL Control', 8, basename(__FILE__), 'curlc_options_subpanel'); } } /** * Display the plugin's option-page */ function curlc_options_subpanel() { global $_POST; /* This array contains all settings for this plugin. */ $data = array ( 'curlc-use-nofollow' => '', 'curlc-default-url' => '' ); /* Get settings from database via WordPress framework */ $comment_url_control_settings = get_option('comment_url_control_settings'); $comment_url_keywords_flash = ""; if (curlc_user_is_authorized()) { if (isset ($_POST['curlc-use-nofollow']) or isset ($_POST['curlc-default-url'])) { $comment_url_control_settings['curlc-use-nofollow'] = $_POST['curlc-use-nofollow']; $comment_url_control_settings['curlc-default-url'] = $_POST['curlc-default-url']; update_option('comment_url_control_settings', $comment_url_control_settings); $comment_url_keywords_flash = "Your settings have been saved."; } } else { $comment_url_keywords_flash = "You don't have enough access rights."; } if ($comment_url_keywords_flash != '') { ?>

Comment URL Control

Here you can enter the URI that will be used instead of the commenter's own URI. You can also specify, if the nofollow-attribute should be used for the URI.



Documentation and Support for this Plugin

Can be found at the Plugin-Homepage.

5; } } /** * Returns whether the comment is switched or not */ function curlc_switch_url(){ global $wpdb; global $comment; $commentID = $comment->comment_ID; $table_name = $wpdb->prefix . "curlc_show_comment_url"; $query = "SELECT show_url FROM " . $table_name . " WHERE comment_id=$commentID LIMIT 1"; $result = mysql_query($query); $num_rows = mysql_num_rows($result); if ($num_rows==0){ return false; } else { return true; } } /** * Substitute for WordPress's comment_author_link() * Displays the switched Link for switched comments or the author's Link for * non-switched comments. */ function curlc_comment_author_link(){ global $comment; $settings = get_option('comment_url_control_settings'); $default_url = $settings['curlc-default-url']; $use_nofollow = $settings['curlc-use-nofollow']; if (curlc_switch_url() && $default_url != ""){ ?> rel="nofollow" > comment_author;?>comment_author; } else { comment_author_link(); } } /** * Substitute for WordPress's comment_author_url() * Displays the switched URL for switched comments or the author's URL for * non-switched comments. */ function curlc_comment_author_url(){ global $comment; $settings = get_option('comment_url_control_settings'); $default_url = $settings['curlc-default-url']; if (curlc_switch_url()){ echo $default_url; } else { comment_author_url(); } } /** * Displays the Swwitch-button inside the comment. Renders a complete HTML-form. * Only visible to a logged-in admin-user with user-level==10 */ function curlc_switch_button(){ get_currentuserinfo() ; global $user_level; if (is_user_logged_in() and $user_level==10) { global $post; global $comment; ?>