wp_publish_post

Definition:
function wp_publish_post($post_id) {}

Publish a post by transitioning the post status.

Parameters

  • int $post_id: Post ID.

Defined actions

  • edit_post
    do_action('edit_post', $post_id, $post);
  • save_post
    do_action('save_post', $post_id, $post);
  • wp_insert_post
    do_action('wp_insert_post', $post_id, $post);

Source code

function wp_publish_post($post_id) {

	global $wpdb;



	$post = get_post($post_id);



	if ( empty($post) )

		return;



	if ( 'publish' == $post->post_status )

		return;



	$wpdb->update( $wpdb->posts, array( 'post_status' => 'publish' ), array( 'ID' => $post_id ) );



	$old_status = $post->post_status;

	$post->post_status = 'publish';

	wp_transition_post_status('publish', $old_status, $post);



	do_action('edit_post', $post_id, $post);

	do_action('save_post', $post_id, $post);

	do_action('wp_insert_post', $post_id, $post);

}

4009

wp_prototype_before_jquery

Definition:
function wp_prototype_before_jquery( $js_array ) {}

Reorder JavaScript scripts array to place prototype before jQuery.

Parameters

  • array $js_array: JavaScript scripts array

Return values

returns:Reordered array, if needed.

Source code

function wp_prototype_before_jquery( $js_array ) {

	if ( false === $jquery = array_search( 'jquery', $js_array, true ) )

		return $js_array;



	if ( false === $prototype = array_search( 'prototype', $js_array, true ) )

		return $js_array;



	if ( $prototype < $jquery )

		return $js_array;



	unset($js_array[$prototype]);



	array_splice( $js_array, $jquery, 0, 'prototype' );



	return $js_array;

}

4007

wp_protect_special_option

Definition:
function wp_protect_special_option( $option ) {}

Protect WordPress special option from being modified.
Will die if $option is in protected list. Protected options are ‘alloptions’ and ‘notoptions’ options.

Parameters

  • string $option: Option name.

Source code

function wp_protect_special_option( $option ) {

	$protected = array( 'alloptions', 'notoptions' );

	if ( in_array( $option, $protected ) )

		wp_die( sprintf( __( '%s is a protected WP option and may not be modified' ), esc_html( $option ) ) );

}

4005

wp_print_styles

Definition:
function wp_print_styles( $handles = false ) {}

Display styles that are in the queue or part of $handles.

Parameters

  • array|bool $handles: Styles to be printed. An empty array prints the queue, an array with one string prints that style, and an array of strings prints those styles.

Return values

returns:True on success, false on failure.

Defined actions

  • wp_print_styles
    do_action( 'wp_print_styles' );

Source code

function wp_print_styles( $handles = false ) {

	do_action( 'wp_print_styles' );

	if ( '' === $handles ) // for wp_head

		$handles = false;



	global $wp_styles;

	if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {

		if ( ! did_action( 'init' ) )

			_doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),

				'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>' ), '3.3' );



		if ( !$handles )

			return array(); // No need to instantiate if nothing is there.

		else

			$wp_styles = new WP_Styles();

	}



	return $wp_styles->do_items( $handles );

}

4003

wp_print_scripts

Definition:
function wp_print_scripts( $handles = false ) {}

Prints script tags in document head.
Called by admin-header.php and by wp_head hook. Since it is called by wp_head on every page load, the function does not instantiate the WP_Scripts object unless script names are explicitly passed. Does make use of already instantiated $wp_scripts if present. Use provided wp_print_scripts hook to register/enqueue new scripts.

Parameters

  • $handles

Defined actions

  • wp_print_scripts
    do_action( 'wp_print_scripts' );

Source code

function wp_print_scripts( $handles = false ) {

	do_action( 'wp_print_scripts' );

	if ( '' === $handles ) // for wp_head

		$handles = false;



	global $wp_scripts;

	if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {

		if ( ! did_action( 'init' ) )

			_doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),

				'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>' ), '3.3' );



		if ( !$handles )

			return array(); // No need to instantiate if nothing is there.

		else

			$wp_scripts = new WP_Scripts();

	}



	return $wp_scripts->do_items( $handles );

}

4001