wp_dashboard_cached_rss_widget

Definition:
function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() {}

Checks to see if all of the feed url in $check_urls are cached.
If $check_urls is empty, look for the rss feed url found in the dashboard widget options of $widget_id. If cached, call $callback, a function that echoes out output for this widget. If not cache, echo a "Loading…" stub which is later replaced by AJAX call (see top of /wp-admin/index.php)

Parameters

  • string $widget_id
  • callback $callback
  • array $check_urls: RSS feeds

Return values

returns:False on failure. True on success.

Source code

function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) {

	$loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><p class="hide-if-js">' . __( 'This widget requires JavaScript.' ) . '</p>';

	$doing_ajax = ( defined('DOING_AJAX') && DOING_AJAX );



	if ( empty($check_urls) ) {

		$widgets = get_option( 'dashboard_widget_options' );

		if ( empty($widgets[$widget_id]['url']) && ! $doing_ajax ) {

			echo $loading;

			return false;

		}

		$check_urls = array( $widgets[$widget_id]['url'] );

	}



	$cache_key = 'dash_' . md5( $widget_id );

	if ( false !== ( $output = get_transient( $cache_key ) ) ) {

		echo $output;

		return true;

	}



	if ( ! $doing_ajax ) {

		echo $loading;

		return false;

	}



	if ( $callback && is_callable( $callback ) ) {

		$args = array_slice( func_get_args(), 2 );

		array_unshift( $args, $widget_id );

		ob_start();

		call_user_func_array( $callback, $args );

		set_transient( $cache_key, ob_get_flush(), 43200); // Default lifetime in cache of 12 hours (same as the feeds)

	}



	return true;

}

3529

wp_dashboard

Definition:
function wp_dashboard() {}

Displays the dashboard.

Source code

function wp_dashboard() {

	global $screen_layout_columns;



	$screen = get_current_screen();



	$hide2 = $hide3 = $hide4 = '';

	switch ( $screen_layout_columns ) {

		case 4:

			$width = 'width:24.5%;';

			break;

		case 3:

			$width = 'width:32.67%;';

			$hide4 = 'display:none;';

			break;

		case 2:

			$width = 'width:49%;';

			$hide3 = $hide4 = 'display:none;';

			break;

		default:

			$width = 'width:98%;';

			$hide2 = $hide3 = $hide4 = 'display:none;';

	}

?>

<div id="dashboard-widgets" class="metabox-holder">

<?php

	echo "\t<div class='postbox-container' style='$width'>\n";

	do_meta_boxes( $screen->id, 'normal', '' );



	echo "\t</div><div class='postbox-container' style='{$hide2}$width'>\n";

3527

wp_crop_image

Definition:
function wp_crop_image( $src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) {}

Crop an Image to a given size.

Parameters

  • string|int $src_file: The source file or Attachment ID.
  • int $src_x: The start x position to crop from.
  • int $src_y: The start y position to crop from.
  • int $src_w: The width to crop.
  • int $src_h: The height to crop.
  • int $dst_w: The destination width.
  • int $dst_h: The destination height.
  • int $src_abs: Optional. If the source crop points are absolute.
  • string $dst_file: Optional. The destination file to write to.

Return values

returns:New filepath on success, WP_Error or false on failure.

Defined filters

  • jpeg_quality
    apply_filters( 'jpeg_quality', 90, 'wp_crop_image' )

Source code

function wp_crop_image( $src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) {

	if ( is_numeric( $src_file ) ) // Handle int as attachment ID

		$src_file = get_attached_file( $src_file );



	$src = wp_load_image( $src_file );



	if ( !is_resource( $src ) )

		return new WP_Error( 'error_loading_image', $src, $src_file );



	$dst = wp_imagecreatetruecolor( $dst_w, $dst_h );



	if ( $src_abs ) {

		$src_w -= $src_x;

		$src_h -= $src_y;

	}



	if (function_exists('imageantialias'))

		imageantialias( $dst, true );



	imagecopyresampled( $dst, $src, 0, 0, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h );



	imagedestroy( $src ); // Free up memory



	if ( ! $dst_file )

		$dst_file = str_replace( basename( $src_file ), 'cropped-' . basename( $src_file ), $src_file );



	$dst_file = preg_replace( '/\\.[^\\.]+$/', '.jpg', $dst_file );



	if ( imagejpeg( $dst, $dst_file, apply_filters( 'jpeg_quality', 90, 'wp_crop_image' ) ) )

		return $dst_file;

	else

		return false;

}

3525

wp_cron

Definition:
function wp_cron() {}

Run scheduled callbacks or spawn cron for all scheduled events.

Return values

returns:When doesn’t need to run Cron.

Source code

function wp_cron() {



	// Prevent infinite loops caused by lack of wp-cron.php

	if ( strpos($_SERVER['REQUEST_URI'], '/wp-cron.php') !== false || ( defined('DISABLE_WP_CRON') && DISABLE_WP_CRON ) )

		return;



	if ( false === $crons = _get_cron_array() )

		return;



	$local_time = time();

	$keys = array_keys( $crons );

	if ( isset($keys[0]) && $keys[0] > $local_time )

		return;



	$schedules = wp_get_schedules();

	foreach ( $crons as $timestamp => $cronhooks ) {

		if ( $timestamp > $local_time ) break;

		foreach ( (array) $cronhooks as $hook => $args ) {

			if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) )

				continue;

			spawn_cron( $local_time );

			break 2;

		}

	}

}

3523

wp_create_user

Definition:
function wp_create_user($username, $password, $email = '') {}

A simpler way of inserting an user into the database.
Creates a new user with just the username, password, and email. For a more detail creation of a user, use wp_insert_user() to specify more infomation.

Parameters

  • string $username: The user’s username.
  • string $password: The user’s password.
  • string $email: The user’s email (optional).

Return values

returns:The new user’s ID.

Source code

function wp_create_user($username, $password, $email = '') {

	$user_login = esc_sql( $username );

	$user_email = esc_sql( $email    );

	$user_pass = $password;



	$userdata = compact('user_login', 'user_email', 'user_pass');

	return wp_insert_user($userdata);

}

3521