the_attachment_links

Definition:
function the_attachment_links( $id = false ) {}

Parameters

  • unknown_type $id

Source code

function the_attachment_links( $id = false ) {

	$id = (int) $id;

	$post = & get_post( $id );



	if ( $post->post_type != 'attachment' )

		return false;



	$icon = wp_get_attachment_image( $post->ID, 'thumbnail', true );

	$attachment_data = wp_get_attachment_metadata( $id );

	$thumb = isset( $attachment_data['thumb'] );

?>

<form id="the-attachment-links">

<table>

	<col />

	<col class="widefat" />

	<tr>

		<th scope="row"><?php _e( 'URL' ) ?></th>

		<td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><?php echo esc_textarea( wp_get_attachment_url() ); ?></textarea></td>

	</tr>

<?php if ( $icon ) : ?>

	<tr>

		<th scope="row"><?php $thumb ? _e( 'Thumbnail linked to file' ) : _e( 'Image linked to file' ); ?></th>

		<td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo wp_get_attachment_url(); ?>"><?php echo $icon ?></a></textarea></td>

	</tr>

	<tr>

		<th scope="row"><?php $thumb ? _e( 'Thumbnail linked to page' ) : _e( 'Image linked to page' ); ?></th>

		<td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link( $post->ID ) ?>" rel="attachment wp-att-<?php echo $post->ID; ?>"><?php echo $icon ?></a></textarea></td>

	</tr>

<?php else : ?>

	<tr>

		<th scope="row"><?php _e( 'Link to file' ) ?></th>

		<td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo wp_get_attachment_url(); ?>" class="attachmentlink"><?php echo basename( wp_get_attachment_url() ); ?></a></textarea></td>

	</tr>

	<tr>

		<th scope="row"><?php _e( 'Link to page' ) ?></th>

		<td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link( $post->ID ) ?>" rel="attachment wp-att-<?php echo $post->ID ?>"><?php the_title(); ?></a></textarea></td>

	</tr>

<?php endif; ?>

</table>

</form>

<?php

}

2949

the_attachment_link

Definition:
function the_attachment_link( $id = 0, $fullsize = false, $deprecated = false, $permalink = false ) {}

Display an attachment page link using an image or icon.

Parameters

  • int $id: Optional. Post ID.
  • bool $fullsize: Optional, default is false. Whether to use full size.
  • bool $deprecated: Deprecated. Not used.
  • bool $permalink: Optional, default is false. Whether to include permalink.

Source code

function the_attachment_link( $id = 0, $fullsize = false, $deprecated = false, $permalink = false ) {

	if ( !empty( $deprecated ) )

		_deprecated_argument( __FUNCTION__, '2.5' );



	if ( $fullsize )

		echo wp_get_attachment_link($id, 'full', $permalink);

	else

		echo wp_get_attachment_link($id, 'thumbnail', $permalink);

}

2947

theme_update_available

Definition:
function theme_update_available( $theme ) {}

Check if there is an update for a theme available.
Will display link, if there is an update available.

Parameters

  • object $theme: Theme data object.

Return values

returns:False if no valid info was passed.

Source code

function theme_update_available( $theme ) {

	static $themes_update;



	if ( !current_user_can('update_themes' ) )

		return;



	if ( !isset($themes_update) )

		$themes_update = get_site_transient('update_themes');



	if ( is_object($theme) && isset($theme->stylesheet) )

		$stylesheet = $theme->stylesheet;

	elseif ( is_array($theme) && isset($theme['Stylesheet']) )

		$stylesheet = $theme['Stylesheet'];

	else

		return false; //No valid info passed.



	if ( isset($themes_update->response[ $stylesheet ]) ) {

		$update = $themes_update->response[ $stylesheet ];

		$theme_name = is_object($theme) ? $theme->name : (is_array($theme) ? $theme['Name'] : '');

		$details_url = add_query_arg(array('TB_iframe' => 'true', 'width' => 1024, 'height' => 800), $update['url']); //Theme browser inside WP? replace this, Also, theme preview JS will override this on the available list.

		$update_url = wp_nonce_url('update.php?action=upgrade-theme&amp;theme=' . urlencode($stylesheet), 'upgrade-theme_' . $stylesheet);

		$update_onclick = 'onclick="if ( confirm(\'' . esc_js( __("Updating this theme will lose any customizations you have made.  'Cancel' to stop, 'OK' to update.") ) . '\') ) {return true;}return false;"';



		if ( !is_multisite() ) {

			if ( ! current_user_can('update_themes') )

				printf( '<p><strong>' . __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s details</a>.') . '</strong></p>', $theme_name, $details_url, $update['new_version']);

			else if ( empty($update['package']) )

				printf( '<p><strong>' . __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s details</a>. <em>Automatic update is unavailable for this theme.</em>') . '</strong></p>', $theme_name, $details_url, $update['new_version']);

			else

				printf( '<p><strong>' . __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s details</a> or <a href="%4$s" %5$s>update automatically</a>.') . '</strong></p>', $theme_name, $details_url, $update['new_version'], $update_url, $update_onclick );

		}

	}

}

2945

themes_api

Definition:
function themes_api($action, $args = null) {}

Retrieve theme installer pages from WordPress Themes API.
It is possible for a theme to override the Themes API result with three filters. Assume this is for themes, which can extend on the Theme Info to offer more choices. This is very powerful and must be used with care, when overridding the filters.

Parameters

  • string $action
  • array|object $args: Optional. Arguments to serialize for the Theme Info API.

Defined filters

  • themes_api_args
    apply_filters('themes_api_args', $args, $action)
  • themes_api
    apply_filters('themes_api', false, $action, $args)
  • themes_api_result
    apply_filters('themes_api_result', $res, $action, $args)

Source code

function themes_api($action, $args = null) {



	if ( is_array($args) )

		$args = (object)$args;



	if ( !isset($args->per_page) )

		$args->per_page = 24;



	$args = apply_filters('themes_api_args', $args, $action); //NOTE: Ensure that an object is returned via this filter.

	$res = apply_filters('themes_api', false, $action, $args); //NOTE: Allows a theme to completely override the builtin WordPress.org API.



	if ( ! $res ) {

		$request = wp_remote_post('http://api.wordpress.org/themes/info/1.0/', array( 'body' => array('action' => $action, 'request' => serialize($args))) );

		if ( is_wp_error($request) ) {

			$res = new WP_Error('themes_api_failed', __('An Unexpected HTTP Error occured during the API request.</p> <p><a href="?" onclick="document.location.reload(); return false;">Try again</a>'), $request->get_error_message() );

		} else {

			$res = unserialize($request['body']);

			if ( ! $res )

			$res = new WP_Error('themes_api_failed', __('An unknown error occured'), $request['body']);

		}

	}

	//var_dump(array($args, $res));

	return apply_filters('themes_api_result', $res, $action, $args);

}

2943

term_exists

Definition:
function term_exists($term, $taxonomy = '', $parent = 0) {}

Check if Term exists.
Returns the index of a defined term, or 0 (false) if the term doesn’t exist.

Parameters

  • int|string $term: The term to check
  • string $taxonomy: The taxonomy name to use
  • int $parent: ID of parent term under which to confine the exists search.

Return values

returns:Get the term id or Term Object, if exists.

Source code

function term_exists($term, $taxonomy = '', $parent = 0) {

	global $wpdb;



	$select = "SELECT term_id FROM $wpdb->terms as t WHERE ";

	$tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE ";



	if ( is_int($term) ) {

		if ( 0 == $term )

			return 0;

		$where = 't.term_id = %d';

		if ( !empty($taxonomy) )

			return $wpdb->get_row( $wpdb->prepare( $tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy ), ARRAY_A );

		else

			return $wpdb->get_var( $wpdb->prepare( $select . $where, $term ) );

	}



	$term = trim( stripslashes( $term ) );



	if ( '' === $slug = sanitize_title($term) )

		return 0;



	$where = 't.slug = %s';

	$else_where = 't.name = %s';

	$where_fields = array($slug);

	$else_where_fields = array($term);

	if ( !empty($taxonomy) ) {

		$parent = (int) $parent;

		if ( $parent > 0 ) {

			$where_fields[] = $parent;

			$else_where_fields[] = $parent;

			$where .= ' AND tt.parent = %d';

			$else_where .= ' AND tt.parent = %d';

		}



		$where_fields[] = $taxonomy;

		$else_where_fields[] = $taxonomy;



		if ( $result = $wpdb->get_row( $wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A) )

			return $result;



		return $wpdb->get_row( $wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $else_where AND tt.taxonomy = %s", $else_where_fields), ARRAY_A);

	}



	if ( $result = $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields) ) )

		return $result;



	return $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $else_where", $else_where_fields) );

}

2941