AnsPress_Tag::terms_clauses( array $query, array $taxonomies, array $args )

Description #

Modify terms mysql quries.

Parameters #

  • $query
    array (Required) Query parameters.
  • $taxonomies
    array (Required) Available taxonomies.
  • $args
    array (Required) Arguments.

Source #

File: addons/free/tag.php

	public static function terms_clauses( $query, $taxonomies, $args ) {
		if ( isset( $args['ap_tags_query'] ) && 'num_rows' === $args['ap_tags_query'] ) {
			$query['fields'] = 'SQL_CALC_FOUND_ROWS ' . $query['fields'];
		}

		if ( in_array( 'question_tag', $taxonomies, true ) && isset( $args['ap_query'] ) && 'tags_subscription' === $args['ap_query'] ) {
			global $wpdb;

			$query['join']     = $query['join'].' INNER JOIN ' . $wpdb->prefix . 'ap_meta apmeta ON t.term_id = apmeta.apmeta_actionid';
			$query['where']    = $query['where'] . " AND apmeta.apmeta_type='subscriber' AND apmeta.apmeta_param='tag' AND apmeta.apmeta_userid='" . $args['user_id'] . "'";
		}

		return $query;
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment