count_many_users_posts

Definition:
function count_many_users_posts($users, $post_type = 'post' ) {}

Number of posts written by a list of users.

Parameters

  • array $user_ids: Array of user IDs.
  • string|array $post_type: Optional. Post type to check. Defaults to post.
  • $users

Return values

returns:Amount of posts each user has written.

Source code

function count_many_users_posts($users, $post_type = 'post' ) {

	global $wpdb;



	$count = array();

	if ( empty( $users ) || ! is_array( $users ) )

		return $count;



	$userlist = implode( ',', array_map( 'absint', $users ) );

	$where = get_posts_by_author_sql( $post_type );



	$result = $wpdb->get_results( "SELECT post_author, COUNT(*) FROM $wpdb->posts $where AND post_author IN ($userlist) GROUP BY post_author", ARRAY_N );

	foreach ( $result as $row ) {

		$count[ $row[0] ] = $row[1];

	}



	foreach ( $users as $id ) {

		if ( ! isset( $count[ $id ] ) )

			$count[ $id ] = 0;

	}



	return $count;

}

734

core_upgrade_preamble

Definition:
function core_upgrade_preamble() {}

Display upgrade WordPress for downloading latest or upgrading automatically form.

Defined actions

  • core_upgrade_preamble
    do_action('core_upgrade_preamble');

Source code

function core_upgrade_preamble() {

	global $upgrade_error;



	$updates = get_core_updates();

?>

	<div class="wrap">

	<?php screen_icon('tools'); ?>

	<h2><?php _e('WordPress Updates'); ?></h2>

<?php

	if ( $upgrade_error ) {

		echo '<div class="error"><p>';

		if ( $upgrade_error == 'themes' )

			_e('Please select one or more themes to update.');

		else

			_e('Please select one or more plugins to update.');

		echo '</p></div>';

	}



	echo '<p>';

	/* translators: %1 date, %2 time. */

	printf( __('Last checked on %1$s at %2$s.'), date_i18n( get_option( 'date_format' ) ), date_i18n( get_option( 'time_format' ) ) );

	echo ' &nbsp; <a class="button" href="' . esc_url( self_admin_url('update-core.php') ) . '">' . __( 'Check Again' ) . '</a>';

	echo '</p>';



	if ( !isset($updates[0]->response) || 'latest' == $updates[0]->response ) {

		echo '<h3>';

		_e('You have the latest version of WordPress.');

		echo '</h3>';

	} else {

		echo '<div class="updated inline"><p>';

		_e('<strong>Important:</strong> before updating, please <a href="http://codex.wordpress.org/WordPress_Backups">back up your database and files</a>. For help with updates, visit the <a href="http://codex.wordpress.org/Updating_WordPress">Updating WordPress</a> Codex page.');

		echo '</p></div>';



		echo '<h3 class="response">';

		_e( 'An updated version of WordPress is available.' );

		echo '</h3>';

	}



	echo '<ul class="core-updates">';

	$alternate = true;

	foreach( (array) $updates as $update ) {

		echo '<li>';

		list_core_update( $update );

		echo '</li>';

	}

	echo '</ul>';

	echo '<p>' . __( 'While your site is being updated, it will be in maintenance mode. As soon as your updates are complete, your site will return to normal.' ) . '</p>';

	dismissed_updates();



	if ( current_user_can( 'update_plugins' ) )

		list_plugin_updates();

	if ( current_user_can( 'update_themes' ) )

		list_theme_updates();

	do_action('core_upgrade_preamble');

	echo '</div>';

}

732

core_update_footer

Definition:
function core_update_footer( $msg = '' ) {}

Parameters

  • $msg

Source code

function core_update_footer( $msg = '' ) {

	if ( is_multisite() && !current_user_can('update_core') )

		return false;



	if ( !current_user_can('update_core') )

		return sprintf( __( 'Version %s' ), $GLOBALS['wp_version'] );



	$cur = get_preferred_from_update_core();

	if ( ! isset( $cur->current ) )

		$cur->current = '';



	if ( ! isset( $cur->url ) )

		$cur->url = '';



	if ( ! isset( $cur->response ) )

		$cur->response = '';



	switch ( $cur->response ) {

	case 'development' :

		return sprintf( __( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ), $GLOBALS['wp_version'], network_admin_url( 'update-core.php' ) );

	break;



	case 'upgrade' :

		return sprintf( '<strong>'.__( '<a href="%1$s">Get Version %2$s</a>' ).'</strong>', network_admin_url( 'update-core.php' ), $cur->current);

	break;



	case 'latest' :

	default :

		return sprintf( __( 'Version %s' ), $GLOBALS['wp_version'] );

	break;

	}

}

729

copy_dir

Definition:
function copy_dir($from, $to, $skip_list = array() {}

Copies a directory from one location to another via the WordPress Filesystem Abstraction.
Assumes that WP_Filesystem() has already been called and setup.

Parameters

  • string $from: source directory
  • string $to: destination directory
  • array $skip_list: a list of files/folders to skip copying

Return values

returns:WP_Error on failure, True on success.

Source code

function copy_dir($from, $to, $skip_list = array() ) {

	global $wp_filesystem;



	$dirlist = $wp_filesystem->dirlist($from);



	$from = trailingslashit($from);

	$to = trailingslashit($to);



	$skip_regex = '';

	foreach ( (array)$skip_list as $key => $skip_file )

		$skip_regex .= preg_quote($skip_file, '!') . '|';



	if ( !empty($skip_regex) )

		$skip_regex = '!(' . rtrim($skip_regex, '|') . ')$!i';



	foreach ( (array) $dirlist as $filename => $fileinfo ) {

		if ( !empty($skip_regex) )

			if ( preg_match($skip_regex, $from . $filename) )

				continue;



		if ( 'f' == $fileinfo['type'] ) {

			if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) {

				// If copy failed, chmod file to 0644 and try again.

				$wp_filesystem->chmod($to . $filename, 0644);

				if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) )

					return new WP_Error('copy_failed', __('Could not copy file.'), $to . $filename);

			}

		} elseif ( 'd' == $fileinfo['type'] ) {

			if ( !$wp_filesystem->is_dir($to . $filename) ) {

				if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) )

					return new WP_Error('mkdir_failed', __('Could not create directory.'), $to . $filename);

			}

			$result = copy_dir($from . $filename, $to . $filename, $skip_list);

			if ( is_wp_error($result) )

				return $result;

		}

	}

	return true;

}

727

convert_to_screen

Definition:
function convert_to_screen( $screen ) {}

Convert a screen string to a screen object

Parameters

  • string $hook_name: The hook name (also known as the hook suffix) used to determine the screen.

Return values

returns:Screen object.

Defined filters

  • screen_meta_screen
    apply_filters( 'screen_meta_screen', $screen )

Source code

function convert_to_screen( $screen ) {

	$screen = str_replace( array('.php', '-new', '-add', '-network', '-user' ), '', $screen);



	if ( is_network_admin() )

		$screen .= '-network';

	elseif ( is_user_admin() )

		$screen .= '-user';



	$screen = (string) apply_filters( 'screen_meta_screen', $screen );

	$screen = (object) array('id' => $screen, 'base' => $screen);

	return $screen;

}

725