get_tax_sql

Definition:
function get_tax_sql( $tax_query, $primary_table, $primary_id_column ) {}

Given a taxonomy query, generates SQL to be appended to a main query.

Parameters

  • array $tax_query: A compact tax query
  • string $primary_table
  • string $primary_id_column

Source code

function get_tax_sql( $tax_query, $primary_table, $primary_id_column ) {

	$tax_query_obj = new WP_Tax_Query( $tax_query );

	return $tax_query_obj->get_sql( $primary_table, $primary_id_column );

}

9677

get_submit_button

Definition:
function get_submit_button( $text = NULL, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = NULL ) {}

Returns a submit button, with provided text and appropriate class

Parameters

  • string $text: The text of the button (defaults to ‘Save Changes’)
  • string $type: The type of button. One of: primary, secondary, delete
  • string $name: The HTML name of the submit button. Defaults to “submit”. If no id attribute is given in $other_attributes below, $name will be used as the button’s id.
  • bool $wrap: True if the output button should be wrapped in a paragraph tag, false otherwise. Defaults to true
  • array|string $other_attributes: Other attributes that should be output with the button, mapping attributes to their values, such as array( ‘tabindex’ => ‘1’ ). These attributes will be output as attribute=”value”, such as tabindex=”1″. Defaults to no other attributes. Other attributes can also be provided as a string such as ‘tabindex=”1″‘, though the array format is typically cleaner.

Source code

function get_submit_button( $text = NULL, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = NULL ) {

	switch ( $type ) :

		case 'primary' :

		case 'secondary' :

			$class = 'button-' . $type;

			break;

		case 'delete' :

			$class = 'button-secondary delete';

			break;

		default :

			$class = $type; // Custom cases can just pass in the classes they want to be used

	endswitch;

	$text = ( NULL == $text ) ? __( 'Save Changes' ) : $text;



	// Default the id attribute to $name unless an id was specifically provided in $other_attributes

	$id = $name;

	if ( is_array( $other_attributes ) && isset( $other_attributes['id'] ) ) {

		$id = $other_attributes['id'];

		unset( $other_attributes['id'] );

	}



	$attributes = '';

	if ( is_array( $other_attributes ) ) {

		foreach ( $other_attributes as $attribute => $value ) {

			$attributes .= $attribute . '="' . esc_attr( $value ) . '" '; // Trailing space is important

		}

	} else if ( !empty( $other_attributes ) ) { // Attributes provided as a string

		$attributes = $other_attributes;

	}



	$button = '<input type="submit" name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" class="' . esc_attr( $class );

	$button	.= '" value="' . esc_attr( $text ) . '" ' . $attributes . ' />';



	if ( $wrap ) {

		$button = '<p class="submit">' . $button . '</p>';

	}



	return $button;

}

9664

get_raw_theme_root

Definition:
function get_raw_theme_root( $stylesheet_or_template, $no_cache = false ) {}

Get the raw theme root relative to the content directory with no filters applied.

Parameters

  • string $stylesheet_or_template: The stylesheet or template name of the theme
  • $no_cache

Return values

returns:Theme root

Source code

function get_raw_theme_root( $stylesheet_or_template, $no_cache = false ) {

	global $wp_theme_directories;



	if ( count($wp_theme_directories) <= 1 )

		return '/themes';



	$theme_root = false;



	// If requesting the root for the current theme, consult options to avoid calling get_theme_roots()

	if ( !$no_cache ) {

		if ( get_option('stylesheet') == $stylesheet_or_template )

			$theme_root = get_option('stylesheet_root');

		elseif ( get_option('template') == $stylesheet_or_template )

			$theme_root = get_option('template_root');

	}



	if ( empty($theme_root) ) {

		$theme_roots = get_theme_roots();

		if ( !empty($theme_roots[$stylesheet_or_template]) )

			$theme_root = $theme_roots[$stylesheet_or_template];

	}



	return $theme_root;

}

9633

get_queried_object_id

Definition:
function get_queried_object_id() {}

Retrieve ID of the current queried object. Wrapper for $wp_query->get_queried_object_id()

Source code

	function get_queried_object_id() {

		$this->get_queried_object();



		if ( isset($this->queried_object_id) ) {

			return $this->queried_object_id;

		}



		return 0;

	}

9629

get_queried_object

Definition:
function get_queried_object() {}

Retrieve the currently-queried object. Wrapper for $wp_query->get_queried_object()

Source code

	function get_queried_object() {

		if ( isset($this->queried_object) )

			return $this->queried_object;



		$this->queried_object = NULL;

		$this->queried_object_id = 0;



		if ( $this->is_category || $this->is_tag || $this->is_tax ) {

			$tax_query_in_and = wp_list_filter( $this->tax_query->queries, array( 'operator' => 'NOT IN' ), 'NOT' );



			$query = reset( $tax_query_in_and );



			if ( 'term_id' == $query['field'] )

				$term = get_term( reset( $query['terms'] ), $query['taxonomy'] );

			else

				$term = get_term_by( $query['field'], reset( $query['terms'] ), $query['taxonomy'] );



			if ( $term && ! is_wp_error($term) )  {

				$this->queried_object = $term;

				$this->queried_object_id = (int) $term->term_id;



				if ( $this->is_category )

					_make_cat_compat( $this->queried_object );

			}

		} elseif ( $this->is_post_type_archive ) {

			$this->queried_object = get_post_type_object( $this->get('post_type') );

		} elseif ( $this->is_posts_page ) {

			$page_for_posts = get_option('page_for_posts');

			$this->queried_object = & get_page( $page_for_posts );

			$this->queried_object_id = (int) $this->queried_object->ID;

		} elseif ( $this->is_singular && !is_null($this->post) ) {

			$this->queried_object = $this->post;

			$this->queried_object_id = (int) $this->post->ID;

		} elseif ( $this->is_author ) {

			$this->queried_object_id = (int) $this->get('author');

			$this->queried_object = get_userdata( $this->queried_object_id );

		}



		return $this->queried_object;

	}

9627