wp_convert_bytes_to_hr

Definition:
function wp_convert_bytes_to_hr( $bytes ) {}

Parameters

  • unknown_type $bytes

Source code

function wp_convert_bytes_to_hr( $bytes ) {

	$units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' );

	$log = log( $bytes, 1024 );

	$power = (int) $log;

	$size = pow(1024, $log - $power);

	return $size . $units[$power];

}

3489

wp_constrain_dimensions

Definition:
function wp_constrain_dimensions( $current_width, $current_height, $max_width=0, $max_height=0 ) {}

Calculates the new dimensions for a downsampled image.
If either width or height are empty, no constraint is applied on that dimension.

Parameters

  • int $current_width: Current width of the image.
  • int $current_height: Current height of the image.
  • int $max_width: Optional. Maximum wanted width.
  • int $max_height: Optional. Maximum wanted height.

Return values

returns:First item is the width, the second item is the height.

Source code

function wp_constrain_dimensions( $current_width, $current_height, $max_width=0, $max_height=0 ) {

	if ( !$max_width and !$max_height )

		return array( $current_width, $current_height );



	$width_ratio = $height_ratio = 1.0;

	$did_width = $did_height = false;



	if ( $max_width > 0 && $current_width > 0 && $current_width > $max_width ) {

		$width_ratio = $max_width / $current_width;

		$did_width = true;

	}



	if ( $max_height > 0 && $current_height > 0 && $current_height > $max_height ) {

		$height_ratio = $max_height / $current_height;

		$did_height = true;

	}



	// Calculate the larger/smaller ratios

	$smaller_ratio = min( $width_ratio, $height_ratio );

	$larger_ratio  = max( $width_ratio, $height_ratio );



	if ( intval( $current_width * $larger_ratio ) > $max_width || intval( $current_height * $larger_ratio ) > $max_height )

 		// The larger ratio is too big. It would result in an overflow.

		$ratio = $smaller_ratio;

	else

		// The larger ratio fits, and is likely to be a more "snug" fit.

		$ratio = $larger_ratio;



	$w = intval( $current_width  * $ratio );

	$h = intval( $current_height * $ratio );



	// Sometimes, due to rounding, we'll end up with a result like this: 465x700 in a 177x177 box is 117x176... a pixel short

	// We also have issues with recursive calls resulting in an ever-changing result. Constraining to the result of a constraint should yield the original result.

	// Thus we look for dimensions that are one pixel shy of the max value and bump them up

	if ( $did_width && $w == $max_width - 1 )

		$w = $max_width; // Round it up

	if ( $did_height && $h == $max_height - 1 )

		$h = $max_height; // Round it up



	return array( $w, $h );

}

3487

wp_comment_trashnotice

Definition:
function wp_comment_trashnotice() {}

Output ‘undo move to trash’ text for comments

Source code

function wp_comment_trashnotice() {

?>

<div class="hidden" id="trash-undo-holder">

	<div class="trash-undo-inside"><?php printf(__('Comment by %s moved to the trash.'), '<strong></strong>'); ?> <span class="undo untrash"><a href="#"><?php _e('Undo'); ?></a></span></div>

</div>

<div class="hidden" id="spam-undo-holder">

	<div class="spam-undo-inside"><?php printf(__('Comment by %s marked as spam.'), '<strong></strong>'); ?> <span class="undo unspam"><a href="#"><?php _e('Undo'); ?></a></span></div>

</div>

<?php

}

3485

wp_comment_reply

Definition:
function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) {}

Parameters

  • unknown_type $position
  • unknown_type $checkbox
  • unknown_type $mode
  • $table_row

Defined filters

  • wp_comment_reply
    apply_filters( 'wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode)

Source code

function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) {

	// allow plugin to replace the popup content

	$content = apply_filters( 'wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode) );



	if ( ! empty($content) ) {

		echo $content;

		return;

	}



	if ( $mode == 'single' ) {

		$wp_list_table = _get_list_table('WP_Post_Comments_List_Table');

	} else {

		$wp_list_table = _get_list_table('WP_Comments_List_Table');

	}



?>

<form method="get" action="">

<?php if ( $table_row ) : ?>

<table style="display:none;"><tbody id="com-reply"><tr id="replyrow" style="display:none;"><td colspan="<?php echo $wp_list_table->get_column_count(); ?>" class="colspanchange">

<?php else : ?>

<div id="com-reply" style="display:none;"><div id="replyrow" style="display:none;">

<?php endif; ?>

	<div id="replyhead" style="display:none;"><?php _e('Reply to Comment'); ?></div>



	<div id="edithead" style="display:none;">

		<div class="inside">

		<label for="author"><?php _e('Name') ?></label>

		<input type="text" name="newcomment_author" size="50" value="" tabindex="101" id="author" />

		</div>



		<div class="inside">

		<label for="author-email"><?php _e('E-mail') ?></label>

		<input type="text" name="newcomment_author_email" size="50" value="" tabindex="102" id="author-email" />

		</div>



		<div class="inside">

		<label for="author-url"><?php _e('URL') ?></label>

		<input type="text" id="author-url" name="newcomment_author_url" size="103" value="" tabindex="103" />

		</div>

		<div style="clear:both;"></div>

	</div>



	<div id="replycontainer"><textarea rows="8" cols="40" name="replycontent" tabindex="104" id="replycontent"></textarea></div>



	<p id="replysubmit" class="submit">

	<a href="#comments-form" class="cancel button-secondary alignleft" tabindex="106"><?php _e('Cancel'); ?></a>

	<a href="#comments-form" class="save button-primary alignright" tabindex="104">

	<span id="savebtn" style="display:none;"><?php _e('Update Comment'); ?></span>

	<span id="replybtn" style="display:none;"><?php _e('Submit Reply'); ?></span></a>

	<img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />

	<span class="error" style="display:none;"></span>

	<br class="clear" />

	</p>



	<input type="hidden" name="user_ID" id="user_ID" value="<?php echo get_current_user_id(); ?>" />

	<input type="hidden" name="action" id="action" value="" />

	<input type="hidden" name="comment_ID" id="comment_ID" value="" />

	<input type="hidden" name="comment_post_ID" id="comment_post_ID" value="" />

	<input type="hidden" name="status" id="status" value="" />

	<input type="hidden" name="position" id="position" value="<?php echo $position; ?>" />

	<input type="hidden" name="checkbox" id="checkbox" value="<?php echo $checkbox ? 1 : 0; ?>" />

	<input type="hidden" name="mode" id="mode" value="<?php echo esc_attr($mode); ?>" />

	<?php wp_nonce_field( 'replyto-comment', '_ajax_nonce-replyto-comment', false ); ?>

	<?php wp_comment_form_unfiltered_html_nonce(); ?>

<?php if ( $table_row ) : ?>

</td></tr></tbody></table>

<?php else : ?>

</div></div>

<?php endif; ?>

</form>

<?php

}

3483

wp_comment_form_unfiltered_html_nonce

Definition:
function wp_comment_form_unfiltered_html_nonce() {}

Displays form token for unfiltered comments.
Will only display nonce token if the current user has permissions for unfiltered html. Won’t display the token for other users.

Source code

function wp_comment_form_unfiltered_html_nonce() {

	global $post;



	$post_id = 0;

	if ( !empty($post) )

		$post_id = $post->ID;



	if ( current_user_can('unfiltered_html') )

		wp_nonce_field('unfiltered-html-comment_' . $post_id, '_wp_unfiltered_html_comment', false);

}

3481