.
*
* @package WordPress MU
* @since version 1.3
*/
function ajax_comments_getcount() {
global $ajax_comments_count;
echo '' . "\n";
}
/**
* ajax_comments_return() - returns ajax-specific stuff instead of a whole page
*
* This function is hooked in when wordpress saved a comment ('comment_post')
*
* Note that there's no detection whether the comment is an even or odd one,
* due this is handled by the javascript. That is because in this case the
* server knows less about how many comments there are than the client.
*
* @package WordPress MU
* @since version 1.3
*
* @param integer $passed hopefully an integer (id of the inserted comment)
* @return string $matches[1] the new comment as
* @return string $passed whatever error message is available
*/
function ajax_comments_send () {
$passed = func_get_arg(0);
$comment = @get_comment($passed);
// if we get anything else than a valid comment id something was wrong
if (!is_object($comment)) {
header('HTTP/1.0 406 Not Acceptable');
die('An error occured. Please make sure you filled in the form and try again.');
die($passed);
} else {
// scrape templated comment HTML from /themes directory
header('Content-type: text/html; charset=utf-8');
ob_start(); // start buffering output
$comments = array($comment); // make it look like there is one comment to be displayed
global $comment;
include(TEMPLATEPATH.'/comments.php'); // now ask comments.php from the themes directory to display it
$commentout = ob_get_clean(); // grab buffered output
preg_match('|()|ims', $commentout, $matches); // Regular Expression cuts out the LI element
die($matches[1]);
}
}
/**
* ajax_comments_js() - handles most javascript-specific issues
*
* This function is hooked in to 'wp_head' and outputs most javascript-parts.
* It handles theme-specific settings and the general script locations.
*
* There's one additional function that outputs js: ajax_comments_get_count()
*
* @package WordPress MU
* @since version 1.3
*/
function ajax_comments_js() {
require_once('themes.php');
// this block of code tries to find the correct theme-settings.
// it works like this:
//
// 1.st) is the 'hardcode' - variable set in themes.php, then
// use this and don't do anything else
//
// 2.nd) are there theme-parameters for a theme that matches
// the current template path, then try using those
//
// 3.rd) if neither succeeds, use settings for the default theme
if (!$ajax_comments_themes['hardcode']) {
$curTempDir = (substr(TEMPLATEPATH, strlen(dirname(TEMPLATEPATH))));
$allThemes = array_keys($ajax_comments_themes);
// try to auto-detect theme
for ($i=0; !is_array($theme), $i' . "\n";
echo '' . "\n";
echo '' . "\n";
echo '\n";
}