当前位置: 首页>>代码示例>>PHP>>正文


PHP sanitize_term函数代码示例

本文整理汇总了PHP中sanitize_term函数的典型用法代码示例。如果您正苦于以下问题:PHP sanitize_term函数的具体用法?PHP sanitize_term怎么用?PHP sanitize_term使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sanitize_term函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: powerpress_get_term_by_ttid

function powerpress_get_term_by_ttid($ttid, $output = OBJECT, $filter = 'raw')
{
    global $wpdb;
    $value = intval($ttid);
    $field = 'tt.term_taxonomy_id';
    $term = $wpdb->get_row($wpdb->prepare("SELECT t.*, tt.* FROM {$wpdb->terms} AS t INNER JOIN {$wpdb->term_taxonomy} AS tt ON t.term_id = tt.term_id WHERE {$field} = %s LIMIT 1", $value));
    if (!$term) {
        return false;
    }
    $taxonomy = $term->taxonomy;
    wp_cache_add($term->term_id, $term, $taxonomy);
    /** This filter is documented in wp-includes/taxonomy.php */
    $term = apply_filters('get_term', $term, $taxonomy);
    /** This filter is documented in wp-includes/taxonomy.php */
    $term = apply_filters("get_{$taxonomy}", $term, $taxonomy);
    $term = sanitize_term($term, $taxonomy, $filter);
    if ($output == OBJECT) {
        return $term;
    } elseif ($output == ARRAY_A) {
        return get_object_vars($term);
    } elseif ($output == ARRAY_N) {
        return array_values(get_object_vars($term));
    } else {
        return $term;
    }
}
开发者ID:ryan2407,项目名称:Vision,代码行数:26,代码来源:powerpress-playlist.php

示例2: categories_form

	function categories_form() {
?>
<script type="text/javascript">
<!--
var checkflag = "false";
function check_all_rows() {
	field = document.formlist;
	if ( 'false' == checkflag ) {
		for ( i = 0; i < field.length; i++ ) {
			if ( 'cats_to_convert[]' == field[i].name )
				field[i].checked = true;
		}
		checkflag = 'true';
		return '<?php _e('Uncheck All') ?>';
	} else {
		for ( i = 0; i < field.length; i++ ) {
			if ( 'cats_to_convert[]' == field[i].name )
				field[i].checked = false;
		}
		checkflag = 'false';
		return '<?php _e('Check All') ?>';
	}
}

//  -->
</script>
<?php
		echo '<form name="formlist" id="formlist" action="admin.php?import=wp-cat2tag&amp;step=2" method="post">
		<p><input type="button" class="button-secondary" value="' . __('Check All') . '"' . ' onClick="this.value=check_all_rows()"></p>';
		wp_nonce_field('import-cat2tag');
		echo '<ul style="list-style:none">';

		$hier = _get_term_hierarchy('category');

		foreach ($this->all_categories as $category) {
			$category = sanitize_term( $category, 'category', 'display' );

			if ((int) $category->parent == 0) {
				echo '<li><label><input type="checkbox" name="cats_to_convert[]" value="' . intval($category->term_id) . '" /> ' . $category->name . ' (' . $category->count . ')</label>';

				if (isset($hier[$category->term_id])) {
					$this->_category_children($category, $hier);
				}

				echo '</li>';
			}
		}

		echo '</ul>';

		echo '<p class="submit"><input type="submit" name="submit" class="button" value="' . __('Convert Tags') . '" /></p>';

		echo '</form>';
	}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:54,代码来源:wp-cat2tag.php

示例3: categories_form

 function categories_form()
 {
     print '<form action="admin.php?import=wp-cat2tag&amp;step=2" method="post">';
     wp_nonce_field('import-cat2tag');
     print '<ul style="list-style:none">';
     $hier = _get_term_hierarchy('category');
     foreach ($this->all_categories as $category) {
         $category = sanitize_term($category, 'category', 'display');
         if ((int) $category->parent == 0) {
             print '<li><label><input type="checkbox" name="cats_to_convert[]" value="' . intval($category->term_id) . '" /> ' . $category->name . ' (' . $category->count . ')</label>';
             if (isset($hier[$category->term_id])) {
                 $this->_category_children($category, $hier);
             }
             print '</li>';
         }
     }
     print '</ul>';
     print '<p class="submit"><input type="submit" name="submit" value="' . __('Convert &raquo;') . '" /></p>';
     print '</form>';
 }
开发者ID:helmonaut,项目名称:owb-mirror,代码行数:20,代码来源:wp-cat2tag.php

示例4: get_term

function get_term($term, $taxonomy = '', $output = OBJECT, $filter = 'raw')
{
    if (empty($term)) {
        return new WP_Error('invalid_term', __('Empty Term'));
    }
    if ($taxonomy && !taxonomy_exists($taxonomy)) {
        // pr($term);pr($taxonomy);die;
        // return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy' ) );
        $taxonomy = '';
    }
    if ($term instanceof WP_Term) {
        $_term = $term;
    } elseif (is_object($term)) {
        if (empty($term->filter) || 'raw' === $term->filter) {
            $_term = sanitize_term($term, $taxonomy, 'raw');
            $_term = new WP_Term($_term);
        } else {
            $_term = WP_Term::get_instance($term->term_id);
        }
    } else {
        $_term = WP_Term::get_instance($term, $taxonomy);
    }
    if (is_wp_error($_term)) {
        return $_term;
    } elseif (!$_term) {
        return null;
    }
    $_term = apply_filters('get_term', $_term, $taxonomy);
    $_term = apply_filters("get_{$taxonomy}", $_term, $taxonomy);
    // Sanitize term, according to the specified filter.
    $_term->filter($filter);
    if ($output == ARRAY_A) {
        return $_term->to_array();
    } elseif ($output == ARRAY_N) {
        return array_values($_term->to_array());
    }
    return $_term;
}
开发者ID:AppItNetwork,项目名称:yii2-wordpress-themes,代码行数:38,代码来源:taxonomy.php

示例5: get

 /**
  * Get term data from database by term ID.
  *
  * The usage of this method is to apply filters to a term object. It
  * is possible to get a term object from the database before applying the
  * filters.
  *
  * $term ID must be part of $taxonomy, to get from the database. Failure, might
  * be able to be captured by the hooks. Failure would be the same value as $wpdb
  * returns for the get_row method.
  *
  * There are two hooks, one is specifically for each term, named 'cn_get_term', and
  * the second is for the taxonomy name, 'cn_term_$taxonomy'. Both hooks are passed the
  * term object, and the taxonomy name as parameters. Both hooks are expected to
  * return a term object.
  *
  * Filters:
  *    cn_get_term - The method variables.
  *        Passes: (object) $term, (string) $taxonomy
  *        Return: $term
  *
  *    cn_get_{$taxonomy} - The fields for the SELECT query clause.
  *        Passes: (object) $term, (string) $taxonomy
  *        Return: $term
  *
  * NOTE: This is the Connections equivalent of @see get_term() in WordPress core ../wp-includes/taxonomy.php
  *
  * @access public
  * @since  8.1.6
  * @static
  *
  * @global $wpdb
  *
  * @uses  WP_Error
  * @uses  wp_cache_get()
  * @uses  wp_cache_add()
  * @uses  apply_filters()
  * @uses  sanitize_term() Cleanses the term based on $filter context before returning.
  *
  * @param int|object $term     If integer, will get from database. If object will apply filters and return $term.
  * @param string     $taxonomy Taxonomy name that $term is part of.
  * @param string     $output   Constant OBJECT, ARRAY_A, or ARRAY_N
  * @param string     $filter   Optional, default is raw or no WordPress defined filter will applied.
  *
  * @return mixed|null|WP_Error Term Row from database. Will return null if $term is empty. If taxonomy does not
  * exist then WP_Error will be returned.
  */
 public static function get($term, $taxonomy, $output = OBJECT, $filter = 'raw')
 {
     /** @var $wpdb wpdb */
     global $wpdb;
     if (empty($term)) {
         return new WP_Error('invalid_term', __('Empty Term', 'connections'));
     }
     // @todo Implement taxonomy check.
     //if ( ! taxonomy_exists( $taxonomy ) ) {
     //
     //	return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy' ) );
     //}
     if (is_object($term) && empty($term->filter)) {
         wp_cache_add($term->term_id, $term, 'cn_' . $taxonomy);
         $_term = $term;
     } else {
         if (is_object($term)) {
             $term = $term->term_id;
         }
         if (!($term = (int) $term)) {
             return NULL;
         }
         if (!($_term = wp_cache_get($term, 'cn_' . $taxonomy))) {
             $_term = $wpdb->get_row($wpdb->prepare("SELECT t.*, tt.* FROM " . CN_TERMS_TABLE . " AS t INNER JOIN " . CN_TERM_TAXONOMY_TABLE . " AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND t.term_id = %d LIMIT 1", $taxonomy, $term));
             if (!$_term) {
                 return NULL;
             }
             wp_cache_add($term, $_term, 'cn_' . $taxonomy);
         }
     }
     /**
      * Filter a term.
      *
      * @since 8.1.6
      *
      * @param int|object $_term    Term object or ID.
      * @param string     $taxonomy The taxonomy slug.
      */
     $_term = apply_filters('cn_get_term', $_term, $taxonomy);
     /**
      * Filter a taxonomy.
      *
      * The dynamic portion of the filter name, $taxonomy, refers
      * to the taxonomy slug.
      *
      * @since 8.1.6
      *
      * @param int|object $_term    Term object or ID.
      * @param string     $taxonomy The taxonomy slug.
      */
     $_term = apply_filters("cn_get_{$taxonomy}", $_term, $taxonomy);
     $_term = sanitize_term($_term, 'cn_' . $taxonomy, $filter);
     if ($output == OBJECT) {
//.........这里部分代码省略.........
开发者ID:VacantFuture,项目名称:Connections,代码行数:101,代码来源:class.terms.php

示例6: categories_form

    function categories_form()
    {
        ?>

<script type="text/javascript">
/* <![CDATA[ */
var checkflag = "false";
function check_all_rows() {
	field = document.catlist;
	if ( 'false' == checkflag ) {
		for ( i = 0; i < field.length; i++ ) {
			if ( 'cats_to_convert[]' == field[i].name )
				field[i].checked = true;
		}
		checkflag = 'true';
		return '<?php 
        _e('Uncheck All');
        ?>
';
	} else {
		for ( i = 0; i < field.length; i++ ) {
			if ( 'cats_to_convert[]' == field[i].name )
				field[i].checked = false;
		}
		checkflag = 'false';
		return '<?php 
        _e('Check All');
        ?>
';
	}
}
/* ]]> */
</script>

<form name="catlist" id="catlist" action="admin.php?import=wp-cat2tag&amp;step=2" method="post">
<p><input type="button" class="button-secondary" value="<?php 
        _e('Check All');
        ?>
" onclick="this.value=check_all_rows()" />
<?php 
        wp_nonce_field('import-cat2tag');
        ?>
</p>
<ul style="list-style:none">

<?php 
        $hier = _get_term_hierarchy('category');
        foreach ($this->all_categories as $category) {
            $category = sanitize_term($category, 'category', 'display');
            if ((int) $category->parent == 0) {
                ?>

	<li><label><input type="checkbox" name="cats_to_convert[]" value="<?php 
                echo intval($category->term_id);
                ?>
" /> <?php 
                echo $category->name . ' (' . $category->count . ')';
                ?>
</label><?php 
                if (in_array(intval($category->term_id), $this->hybrids_ids)) {
                    echo ' <a href="#note"> * </a>';
                }
                if (isset($hier[$category->term_id])) {
                    $this->_category_children($category, $hier);
                }
                ?>
</li>
<?php 
            }
        }
        ?>
</ul>

<?php 
        if (!empty($this->hybrids_ids)) {
            echo '<p><a name="note"></a>' . __('* This category is also a tag. Converting it will add that tag to all posts that are currently in the category.') . '</p>';
        }
        ?>

<p class="submit"><input type="submit" name="submit" class="button" value="<?php 
        _e('Convert Categories to Tags');
        ?>
" /></p>
</form>

<?php 
    }
开发者ID:BGCX262,项目名称:zxhproject-svn-to-git,代码行数:87,代码来源:wp-cat2tag.php

示例7: wp_update_term

/**
 * wp_update_term() - Update term based on arguments provided
 *
 * The $args will indiscriminately override all values with the same field name. Care
 * must be taken to not override important information need to update or update will
 * fail (or perhaps create a new term, neither would be acceptable).
 *
 * Defaults will set 'alias_of', 'description', 'parent', and 'slug' if not defined
 * in $args already.
 *
 * 'alias_of' will create a term group, if it doesn't already exist, and update it for
 * the $term.
 *
 * If the 'slug' argument in $args is missing, then the 'name' in $args will be used.
 * It should also be noted that if you set 'slug' and it isn't unique then a WP_Error
 * will be passed back. If you don't pass any slug, then a unique one will be created
 * for you.
 *
 * For what can be overrode in $args, check the term scheme can contain and stay away
 * from the term keys.
 *
 * @package WordPress
 * @subpackage Taxonomy
 * @since 2.3
 *
 * @uses $wpdb
 * @uses do_action() Will call both 'edit_term' and 'edit_$taxonomy' twice.
 * @uses apply_filters() Will call the 'term_id_filter' filter and pass the term id and
 *	taxonomy id.
 *
 * @param int $term The ID of the term
 * @param string $taxonomy The context in which to relate the term to the object.
 * @param array|string $args Overwrite term field values
 * @return array|WP_Error Returns Term ID and Taxonomy Term ID
 */
function wp_update_term( $term, $taxonomy, $args = array() ) {
	global $wpdb;

	if ( ! is_taxonomy($taxonomy) )
		return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));

	$term_id = (int) $term;

	// First, get all of the original args
	$term = get_term ($term_id, $taxonomy, ARRAY_A);

	// Escape data pulled from DB.
	$term = add_magic_quotes($term);

	// Merge old and new args with new args overwriting old ones.
	$args = array_merge($term, $args);

	$defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
	$args = wp_parse_args($args, $defaults);
	$args = sanitize_term($args, $taxonomy, 'db');
	extract($args, EXTR_SKIP);

	// expected_slashed ($name)
	$name = stripslashes($name);
	$description = stripslashes($description);

	$empty_slug = false;
	if ( empty($slug) ) {
		$empty_slug = true;
		$slug = sanitize_title($name);
	}

	if ( $alias_of ) {
		$alias = $wpdb->get_row( $wpdb->prepare( "SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $alias_of) );
		if ( $alias->term_group ) {
			// The alias we want is already in a group, so let's use that one.
			$term_group = $alias->term_group;
		} else {
			// The alias isn't in a group, so let's create a new one and firstly add the alias term to it.
			$term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1;
			$wpdb->update( $wpdb->terms, compact('term_group'), array( 'term_id' => $alias->term_id ) );
		}
	}

	// Check for duplicate slug
	$id = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms WHERE slug = %s", $slug ) );
	if ( $id && ($id != $term_id) ) {
		// If an empty slug was passed or the parent changed, reset the slug to something unique.
		// Otherwise, bail.
		if ( $empty_slug || ( $parent != $term->parent) )
			$slug = wp_unique_term_slug($slug, (object) $args);
		else
			return new WP_Error('duplicate_term_slug', sprintf(__('The slug "%s" is already in use by another term'), $slug));
	}

	$wpdb->update($wpdb->terms, compact( 'name', 'slug', 'term_group' ), compact( 'term_id' ) );

	if ( empty($slug) ) {
		$slug = sanitize_title($name, $term_id);
		$wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) );
	}

	$tt_id = $wpdb->get_var( $wpdb->prepare( "SELECT tt.term_taxonomy_id FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.term_id = %d", $taxonomy, $term_id) );

	$wpdb->update( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent' ), array( 'term_taxonomy_id' => $tt_id ) );
//.........这里部分代码省略.........
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:101,代码来源:taxonomy.php

示例8: get_term_by

 /**
  * Get all Term data from database by Term field and data.
  *
  * @param string $field Either 'slug', 'name', or 'id'
  * @param string|int $value Search for this term value
  * @param string $taxonomy Taxonomy Name
  * @param string $output Constant OBJECT, ARRAY_A, or ARRAY_N
  * @param string $filter Optional, default is raw or no WordPress defined filter will applied.
  * @return mixed Term Row from database. Will return false if $taxonomy does not exist or $term was not found.
  *
  * @since 1.0
  */
 private function get_term_by($field, $value, $taxonomy, $output = OBJECT, $filter = 'raw')
 {
     global $wpdb;
     $original_field = $field;
     if (!taxonomy_exists($taxonomy)) {
         return false;
     }
     if ('slug' == $field) {
         $field = 'm.meta_key = \'' . $this->get_meta_key() . '\' AND m.meta_value';
         $value = sanitize_title($value);
         if (empty($value)) {
             return false;
         }
     } else {
         if ('name' == $field) {
             // Assume already escaped
             $value = stripslashes($value);
             $field = 't.name';
         } else {
             $term = get_term((int) $value, $taxonomy, $output, $filter);
             if (is_wp_error($term)) {
                 $term = false;
             }
             return $term;
         }
     }
     $term = $wpdb->get_row($wpdb->prepare("SELECT t.*, tt.* FROM {$wpdb->terms} AS t, {$wpdb->term_taxonomy} AS tt, {$wpdb->termmeta} AS m WHERE t.term_id = tt.term_id AND tt.term_id = m.term_id AND tt.taxonomy = %s AND {$field} = %s LIMIT 1", $taxonomy, $value));
     if (!$term && 'slug' == $original_field) {
         $field = 't.slug';
         $term = $wpdb->get_row($wpdb->prepare("SELECT t.*, tt.* FROM {$wpdb->terms} AS t INNER JOIN {$wpdb->term_taxonomy} AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND {$field} = %s LIMIT 1", $taxonomy, $value));
     }
     if (!$term) {
         return false;
     }
     wp_cache_add($term->term_id, $term, $taxonomy);
     $term = apply_filters('get_term', $term, $taxonomy);
     $term = apply_filters("get_{$taxonomy}", $term, $taxonomy);
     $term = sanitize_term($term, $taxonomy, $filter);
     if ($output == OBJECT) {
         return $term;
     } elseif ($output == ARRAY_A) {
         return get_object_vars($term);
     } elseif ($output == ARRAY_N) {
         return array_values(get_object_vars($term));
     } else {
         return $term;
     }
 }
开发者ID:Savantos,项目名称:cow-theme,代码行数:60,代码来源:qtranslate-slug.php

示例9: get_term_by

 /**
  * This function mimics the WordPress function get_term_by()
  * because we cannot hook into the function without receiving errors.
  *
  * @since 1.0
  * @uses $wpdb, $cpt_onomies_manager
  * @param string $field Either 'slug', 'name', or 'id'
  * @param string|int $value Search for this term value
  * @param string $taxonomy Taxonomy Name
  * @param string $output Constant OBJECT, ARRAY_A, or ARRAY_N
  * @param string $filter Optional, default is raw or no WordPress defined filter will applied.
  * @param inte $parent allows to get a term by its parent's term id
  * @return mixed Term Row from database. Will return false if $taxonomy does not exist or $term was not found.
  */
 public function get_term_by($field, $value, $taxonomy, $output = OBJECT, $filter = 'raw', $parent = 0)
 {
     global $wpdb, $cpt_onomies_manager;
     if (!taxonomy_exists($taxonomy)) {
         return false;
     }
     /**
      * This function only processes registered CPT-onomies.
      * If this is a normal taxonomy, then use the WordPress function.
      */
     if (!$cpt_onomies_manager->is_registered_cpt_onomy($taxonomy)) {
         return get_term_by($field, $value, $taxonomy, $output, $filter);
     }
     if ($parent > 0) {
         $parent = " AND wpposts.post_parent = " . $parent;
     } else {
         $parent = NULL;
     }
     if ('slug' == $field) {
         $value = sanitize_title($value);
         if (empty($value)) {
             return false;
         }
         // Get eligible post types
         $eligible_post_types = ($tax = get_taxonomy($taxonomy)) && isset($tax->object_type) ? $tax->object_type : array();
         // Find term and term count
         $query = "SELECT (SELECT COUNT(*) FROM {$wpdb->postmeta} wpcountmeta INNER JOIN {$wpdb->posts} wpcountposts ON wpcountposts.ID = wpcountmeta.post_id AND wpcountposts.post_status = 'publish' AND wpcountposts.post_type IN ('" . implode("','", $eligible_post_types) . "') WHERE wpcountmeta.meta_key = '" . CPT_ONOMIES_POSTMETA_KEY . "' AND wpcountmeta.meta_value = wpposts.ID) AS count, wpposts.* FROM {$wpdb->posts} wpposts WHERE wpposts.post_type = '{$taxonomy}' AND wpposts.post_name = '{$value}' and wpposts.post_status = 'publish'" . $parent;
     } else {
         if ('name' == $field) {
             // Assume already escaped
             $value = stripslashes($value);
             // Get eligible post types
             $eligible_post_types = ($tax = get_taxonomy($taxonomy)) && isset($tax->object_type) ? $tax->object_type : array();
             // Find term and term count
             $query = "SELECT (SELECT COUNT(*) FROM {$wpdb->postmeta} wpcountmeta INNER JOIN {$wpdb->posts} wpcountposts ON wpcountposts.ID = wpcountmeta.post_id AND wpcountposts.post_status = 'publish' AND wpcountposts.post_type IN ('" . implode("','", $eligible_post_types) . "') WHERE wpcountmeta.meta_key = '" . CPT_ONOMIES_POSTMETA_KEY . "' AND wpcountmeta.meta_value = wpposts.ID) AS count, wpposts.* FROM {$wpdb->posts} wpposts WHERE wpposts.post_type = '{$taxonomy}' AND wpposts.post_title = '{$value}' and wpposts.post_status = 'publish'" . $parent;
         } else {
             $term = $this->get_term((int) $value, $taxonomy, $output, $filter);
             if (is_wp_error($term)) {
                 return false;
             }
             return $term;
         }
     }
     // Get the term
     $term = $wpdb->get_row($query);
     if (!$term) {
         return false;
     }
     // Save the term count and remove from $term before conversion
     $term_count = $term->count;
     unset($term->count);
     // Dont get the count, we'll add from before
     $term = $this->convert_object_to_cpt_onomy_term($term, false);
     if (!$term) {
         return false;
     }
     // Add count
     $term->count = $term_count;
     wp_cache_add($term->term_id, $term, $taxonomy);
     $term = apply_filters('get_term', $term, $taxonomy);
     $term = apply_filters("get_{$taxonomy}", $term, $taxonomy);
     $term = sanitize_term($term, $taxonomy, $filter);
     if ($output == OBJECT) {
         return $term;
     } elseif ($output == ARRAY_A) {
         return get_object_vars($term);
     } elseif ($output == ARRAY_N) {
         return array_values(get_object_vars($term));
     }
     return $term;
 }
开发者ID:aarongillett,项目名称:B22-151217,代码行数:85,代码来源:cpt-onomy.php

示例10: element

    function element()
    {
        global $zn_config;
        $separator_top = $this->opt('show_oblique_top') ? $this->opt('show_oblique_top') : 'yes';
        $sort_alphabetical = $this->opt('sort_alphabetical') ? $this->opt('sort_alphabetical') : '';
        $data_sort = $sort_alphabetical === 'yes' ? 'data-sort="h3 a"' : '';
        $separator_top = zn_get_top_separator(array('show' => $separator_top));
        $category = $this->opt('category') ? $this->opt('category') : '0';
        $posts_per_page = $this->opt('post_per_page') ? $this->opt('post_per_page') : '8';
        // How many posts to load
        $columns_num = $this->opt('columns_num') ? $this->opt('columns_num') : '3';
        $zn_config['columns'] = zn_get_col_size($columns_num);
        $zn_config['archive_type'] = $archive_type = false;
        $zn_config['pagination'] = $this->opt('use_pagination');
        $zn_config['use_as_gallery'] = $this->opt('use_as_gallery') === 'yes' ? true : false;
        $portfolio_icon_opt = zget_option('portfolio_archive_icon', 'portfolio_options');
        $portfolio_icon = !empty($portfolio_icon_opt['family']) ? '<div class="sectionIcon " ' . zn_generate_icon($portfolio_icon_opt) . '></div>' : '';
        ?>
			<section id="ZnPortfolio" class="obliqueCut <?php 
        echo $separator_top['class'];
        ?>
 <?php 
        echo $this->data['uid'];
        ?>
">
				<?php 
        echo $separator_top['svg'];
        //echo $portfolio_icon;
        //<div class="sectionIcon zn_icon icon_ribbon_alt"></div>
        ?>
		        <div class="container">

			<?php 
        $args = array('include' => $category, 'hide_empty' => true);
        $terms = $archive_type ? false : get_terms("portfolio_categories", $args);
        if (!empty($terms) && !is_wp_error($terms) && count($terms) > 1) {
            echo '<div class="row">';
            echo '<div class="col-sm-12">';
            echo '<div class="zn_portfolio_filter_container">';
            echo '<span class="filter_title h4 titleColor">' . __('Filter:', 'zn_framework') . '</span>';
            echo "<ul class='zn_portfolio_categories'>";
            echo '<li class="all"><a href="#" title="' . __('Alle', 'zn_framework') . '" data-filter="*" class="active">' . __('Alle', 'zn_framework') . '</a></li>';
            foreach ($terms as $term) {
                $term = sanitize_term($term, 'portfolio_categories');
                $term_link = get_term_link($term, 'portfolio_categories');
                // CHECK IF WE HAVE AN ERROR
                if (is_wp_error($term_link)) {
                    continue;
                }
                echo '/';
                echo '<li><a href="' . $term_link . '" title="' . $term->name . '" data-filter="' . $term->slug . '">' . $term->name . '</a></li>';
            }
            echo "</ul>";
            echo "</div>";
            echo "</div>";
            echo "</div>";
        }
        global $query_string, $paged;
        $tax_cat = '';
        if (!empty($category)) {
            $tax_cat = array(array('taxonomy' => 'portfolio_categories', 'field' => 'id', 'terms' => $category));
        }
        global $paged;
        $args = array('post_type' => 'portfolio', 'post_status' => 'publish', 'posts_per_page' => $posts_per_page, 'tax_query' => $tax_cat, 'paged' => $paged);
        query_posts($args);
        ?>
		            <!-- START BLOG CONTENT -->
		            <div class="row">
		            
		                <!--MAIN COLUMN-->
		                <div class="zn_portfolio_archive col-sm-12" <?php 
        echo $data_sort;
        ?>
>
		                    <?php 
        get_template_part('template_helpers/loop', 'portfolio');
        wp_reset_query();
        ?>
		                </div>

		            </div>



		        </div>
			</section>
    		<!--END Portfolio archive section-->
		<?php 
    }
开发者ID:fjbeteiligung,项目名称:development,代码行数:89,代码来源:portfolio_archive.php

示例11: get_ordered_object_terms

 /**
  * Retrieves the terms associated with the given object(s), in the
  * supplied taxonomies.
  * 
  * This is a copy of WordPress' wp_get_object_terms function with a bunch
  * of edits to use term_order as a default sorting param.
  * 
  * @since    1.0
  * 
  * @param    array           $terms The post's terms
  * @param    int|array       $object_ids The ID(s) of the object(s) to retrieve.
  * @param    string|array    $taxonomies The taxonomies to retrieve terms from.
  * @param    array|string    $args Change what is returned
  * 
  * @return   array|WP_Error  The requested term data or empty array if no
  *                           terms found. WP_Error if any of the $taxonomies
  *                           don't exist.
  */
 public static function get_ordered_object_terms($terms, $object_ids, $taxonomies, $args)
 {
     $total = count($terms);
     $original_terms = $terms;
     // Term ordering is killing quick/bulk edit, avoid it
     if (is_admin() && (function_exists('get_current_screen') && 'edit-movie' == get_current_screen()->id)) {
         return $terms;
     }
     $taxonomies = explode(', ', str_replace("'", "", $taxonomies));
     if (empty($object_ids) || $taxonomies != "'collection', 'actor', 'genre'" && (!in_array('collection', $taxonomies) && !in_array('actor', $taxonomies) && !in_array('genre', $taxonomies))) {
         return $terms;
     }
     global $wpdb;
     foreach ((array) $taxonomies as $taxonomy) {
         if (!taxonomy_exists($taxonomy)) {
             return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
         }
     }
     if (!is_array($object_ids)) {
         $object_ids = array($object_ids);
     }
     $object_ids = array_map('intval', $object_ids);
     $defaults = array('orderby' => 'term_order', 'order' => 'ASC', 'fields' => 'all');
     $args = wp_parse_args($args, $defaults);
     $terms = array();
     if (count($taxonomies) > 1) {
         foreach ($taxonomies as $index => $taxonomy) {
             $t = get_taxonomy($taxonomy);
             if (isset($t->args) && is_array($t->args) && $args != array_merge($args, $t->args)) {
                 unset($taxonomies[$index]);
                 $terms = array_merge($terms, self::get_ordered_object_terms($object_ids, $taxonomy, array_merge($args, $t->args)));
             }
         }
     } else {
         $t = get_taxonomy($taxonomies[0]);
         if (isset($t->args) && is_array($t->args)) {
             $args = array_merge($args, $t->args);
         }
     }
     extract($args, EXTR_SKIP);
     $orderby = "ORDER BY tr.term_order";
     $order = 'ASC';
     $taxonomies = "'" . implode("', '", $taxonomies) . "'";
     $object_ids = implode(', ', $object_ids);
     $select_this = '';
     if ('all' == $fields) {
         $select_this = 't.*, tt.*';
     } else {
         if ('ids' == $fields) {
             $select_this = 't.term_id';
         } else {
             if ('names' == $fields) {
                 $select_this = 't.name';
             } else {
                 if ('slugs' == $fields) {
                     $select_this = 't.slug';
                 } else {
                     if ('all_with_object_id' == $fields) {
                         $select_this = 't.*, tt.*, tr.object_id';
                     }
                 }
             }
         }
     }
     $query = "SELECT {$select_this} FROM {$wpdb->terms} AS t INNER JOIN {$wpdb->term_taxonomy} AS tt ON tt.term_id = t.term_id INNER JOIN {$wpdb->term_relationships} AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tr.object_id IN ({$object_ids}) {$orderby} {$order}";
     if ('all' == $fields || 'all_with_object_id' == $fields) {
         $_terms = $wpdb->get_results($query);
         foreach ($_terms as $key => $term) {
             $_terms[$key] = sanitize_term($term, $taxonomy, 'raw');
         }
         $terms = array_merge($terms, $_terms);
         update_term_cache($terms);
     } else {
         if ('ids' == $fields || 'names' == $fields || 'slugs' == $fields) {
             $_terms = $wpdb->get_col($query);
             $_field = 'ids' == $fields ? 'term_id' : 'name';
             foreach ($_terms as $key => $term) {
                 $_terms[$key] = sanitize_term_field($_field, $term, $term, $taxonomy, 'raw');
             }
             $terms = array_merge($terms, $_terms);
         } else {
             if ('tt_ids' == $fields) {
//.........这里部分代码省略.........
开发者ID:masterdoed,项目名称:wpmovielibrary,代码行数:101,代码来源:class-wpmoly-utils.php

示例12: get_term_children

     }
     // 親タームのURLと名称とカウントを出力
     echo '<div class="second-group">';
     echo '<h4>';
     echo '<option type=text disabled="disabled">' . $term->name . '</option>';
     echo '</h4>';
     // 子タームのIDのリストを取得
     $term_children = get_term_children($term->term_id, $taxonomy);
     if (count($term_children) != 0) {
         echo '<ul>';
         // 子タームのIDのリスト $term_children を $term_idに格納してループ
         foreach ($term_children as $term_id) {
             // 子タームのIDを元に子タームの情報を取得
             $term_child = get_term_by('id', $term_id, $taxonomy);
             // 子タームのURLを取得
             $term_child = sanitize_term($term_child, $taxonomy);
             $term_child_link = get_term_link($term_child, $taxonomy);
             $postid = url_to_postid($url);
             if (is_wp_error($term_child_link)) {
                 continue;
             }
             // 子タームのURLと名称とカウントを出力
             echo '<div id="start_radio" >';
             // echo '<a href="'. $term_child_link .'">'. $term_child->name .','. $term_id .'</a>' ;
             echo '<option <?php if (isset($categoryselect) && $categoryselect=="' . $term_id . '") echo "selected";?>' . $term_child->name . ',' . $term_id . '</option>';
             echo "</div>\n";
         }
         echo '</ul>';
         echo '</div>';
     }
 }
开发者ID:hujiyama,项目名称:wordpress,代码行数:31,代码来源:newpost.php

示例13: foreach

foreach ($categories as $category) :
$category = sanitize_category($category);
if ($category->term_id == get_option('default_category')) $selected = " selected='selected'";
else $selected = '';
echo "\n\t<option value='$category->term_id' $selected>$category->name</option>";
endforeach;
?>
</select></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Default Link Category') ?></th>
<td><select name="default_link_category" id="default_link_category">
<?php
$link_categories = get_terms('link_category', 'get=all');
foreach ($link_categories as $category) :
$category = sanitize_term($category, 'link_category');
if ($category->term_id == get_option('default_link_category')) $selected = " selected='selected'";
else $selected = '';
echo "\n\t<option value='$category->term_id' $selected>$category->name</option>";
endforeach;
?>
</select></td>
</tr>
</table>

<h3><?php _e('Post via e-mail') ?></h3>
<p><?php printf(__('To post to WordPress by e-mail you must set up a secret e-mail account with POP3 access. Any mail received at this address will be posted, so it&#8217;s a good idea to keep this address very secret. Here are three random strings you could use: <code>%s</code>, <code>%s</code>, <code>%s</code>.'), wp_generate_password(), wp_generate_password(), wp_generate_password()) ?></p>

<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e('Mail Server') ?></th>
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:31,代码来源:options-writing.php

示例14: wp_update_term

/**
 * Update term based on arguments provided.
 *
 * The $args will indiscriminately override all values with the same field name.
 * Care must be taken to not override important information need to update or
 * update will fail (or perhaps create a new term, neither would be acceptable).
 *
 * Defaults will set 'alias_of', 'description', 'parent', and 'slug' if not
 * defined in $args already.
 *
 * 'alias_of' will create a term group, if it doesn't already exist, and update
 * it for the $term.
 *
 * If the 'slug' argument in $args is missing, then the 'name' in $args will be
 * used. It should also be noted that if you set 'slug' and it isn't unique then
 * a WP_Error will be passed back. If you don't pass any slug, then a unique one
 * will be created for you.
 *
 * For what can be overrode in $args, check the term scheme can contain and stay
 * away from the term keys.
 *
 * @since 2.3.0
 *
 * @uses $wpdb
 *
 * @param int $term_id The ID of the term
 * @param string $taxonomy The context in which to relate the term to the object.
 * @param array|string $args Overwrite term field values
 * @return array|WP_Error Returns Term ID and Taxonomy Term ID
 */
function wp_update_term( $term_id, $taxonomy, $args = array() ) {
	global $wpdb;

	if ( ! taxonomy_exists($taxonomy) )
		return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));

	$term_id = (int) $term_id;

	// First, get all of the original args
	$term = get_term ($term_id, $taxonomy, ARRAY_A);

	if ( is_wp_error( $term ) )
		return $term;

	// Escape data pulled from DB.
	$term = wp_slash($term);

	// Merge old and new args with new args overwriting old ones.
	$args = array_merge($term, $args);

	$defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
	$args = wp_parse_args($args, $defaults);
	$args = sanitize_term($args, $taxonomy, 'db');
	extract($args, EXTR_SKIP);

	// expected_slashed ($name)
	$name = wp_unslash($name);
	$description = wp_unslash($description);

	if ( '' == trim($name) )
		return new WP_Error('empty_term_name', __('A name is required for this term'));

	$empty_slug = false;
	if ( empty($slug) ) {
		$empty_slug = true;
		$slug = sanitize_title($name);
	}

	if ( $alias_of ) {
		$alias = $wpdb->get_row( $wpdb->prepare( "SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $alias_of) );
		if ( $alias->term_group ) {
			// The alias we want is already in a group, so let's use that one.
			$term_group = $alias->term_group;
		} else {
			// The alias isn't in a group, so let's create a new one and firstly add the alias term to it.
			$term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1;

			/** This action is documented in wp-includes/taxonomy.php */
			do_action( 'edit_terms', $alias->term_id, $taxonomy );
			$wpdb->update( $wpdb->terms, compact('term_group'), array( 'term_id' => $alias->term_id ) );

			/** This action is documented in wp-includes/taxonomy.php */
			do_action( 'edited_terms', $alias->term_id, $taxonomy );
		}
	}

	/**
	 * Filter the term parent.
	 *
	 * Hook to this filter to see if it will cause a hierarchy loop.
	 *
	 * @since 3.1.0
	 *
	 * @param int    $parent   ID of the parent term.
	 * @param int    $term_id  Term ID.
	 * @param string $taxonomy Taxonomy slug.
	 * @param array  $args     Compacted array of update arguments for the given term.
	 * @param array  $args     An array of update arguments for the given term.
	 */
	$parent = apply_filters( 'wp_update_term_parent', $parent, $term_id, $taxonomy, compact( array_keys( $args ) ), $args );
//.........这里部分代码省略.........
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:101,代码来源:taxonomy.php

示例15: wp_update_term

/**
 * Update term based on arguments provided.
 *
 * The $args will indiscriminately override all values with the same field name.
 * Care must be taken to not override important information need to update or
 * update will fail (or perhaps create a new term, neither would be acceptable).
 *
 * Defaults will set 'alias_of', 'description', 'parent', and 'slug' if not
 * defined in $args already.
 *
 * 'alias_of' will create a term group, if it doesn't already exist, and update
 * it for the $term.
 *
 * If the 'slug' argument in $args is missing, then the 'name' in $args will be
 * used. It should also be noted that if you set 'slug' and it isn't unique then
 * a WP_Error will be passed back. If you don't pass any slug, then a unique one
 * will be created for you.
 *
 * For what can be overrode in $args, check the term scheme can contain and stay
 * away from the term keys.
 *
 * @package WordPress
 * @subpackage Taxonomy
 * @since 2.3.0
 *
 * @uses $wpdb
 * @uses do_action() Will call both 'edit_term' and 'edit_$taxonomy' twice.
 * @uses apply_filters() Will call the 'term_id_filter' filter and pass the term
 *	id and taxonomy id.
 *
 * @param int $term_id The ID of the term
 * @param string $taxonomy The context in which to relate the term to the object.
 * @param array|string $args Overwrite term field values
 * @return array|WP_Error Returns Term ID and Taxonomy Term ID
 */
function wp_update_term($term_id, $taxonomy, $args = array(), $engelTuru)
{
    global $wpdb;
    if (!taxonomy_exists($taxonomy)) {
        return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
    }
    $term_id = (int) $term_id;
    // First, get all of the original args
    $term = get_term($term_id, $taxonomy, ARRAY_A);
    if (is_wp_error($term)) {
        return $term;
    }
    // Escape data pulled from DB.
    $term = add_magic_quotes($term);
    // Merge old and new args with new args overwriting old ones.
    $args = array_merge($term, $args);
    $defaults = array('alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
    $args = wp_parse_args($args, $defaults);
    $args = sanitize_term($args, $taxonomy, 'db');
    extract($args, EXTR_SKIP);
    // expected_slashed ($name)
    $name = stripslashes($name);
    $description = stripslashes($description);
    if ('' == trim($name)) {
        return new WP_Error('empty_term_name', __('A name is required for this term'));
    }
    $empty_slug = false;
    if (empty($slug)) {
        $empty_slug = true;
        $slug = sanitize_title($name);
    }
    if ($alias_of) {
        $alias = $wpdb->get_row($wpdb->prepare("SELECT term_id, term_group FROM {$wpdb->terms} WHERE slug = %s", $alias_of));
        if ($alias->term_group) {
            // The alias we want is already in a group, so let's use that one.
            $term_group = $alias->term_group;
        } else {
            // The alias isn't in a group, so let's create a new one and firstly add the alias term to it.
            $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM {$wpdb->terms}") + 1;
            do_action('edit_terms', $alias->term_id);
            $wpdb->update($wpdb->terms, compact('term_group'), array('term_id' => $alias->term_id));
            do_action('edited_terms', $alias->term_id);
        }
    }
    // Check $parent to see if it will cause a hierarchy loop
    $parent = apply_filters('wp_update_term_parent', $parent, $term_id, $taxonomy, compact(array_keys($args)), $args);
    // Check for duplicate slug
    $id = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM {$wpdb->terms} WHERE slug = %s", $slug));
    if ($id && $id != $term_id) {
        // If an empty slug was passed or the parent changed, reset the slug to something unique.
        // Otherwise, bail.
        if ($empty_slug || $parent != $term['parent']) {
            $slug = wp_unique_term_slug($slug, (object) $args);
        } else {
            return new WP_Error('duplicate_term_slug', sprintf(__('The slug &#8220;%s&#8221; is already in use by another term'), $slug));
        }
    }
    do_action('edit_terms', $term_id);
    $wpdb->update($wpdb->terms, compact('name', 'slug', 'term_group'), compact('term_id'));
    if (empty($slug)) {
        $slug = sanitize_title($name, $term_id);
        $wpdb->update($wpdb->terms, compact('slug'), compact('term_id'));
    }
    do_action('edited_terms', $term_id);
    $tt_id = $wpdb->get_var($wpdb->prepare("SELECT tt.term_taxonomy_id FROM {$wpdb->term_taxonomy} AS tt INNER JOIN {$wpdb->terms} AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.term_id = %d", $taxonomy, $term_id));
//.........这里部分代码省略.........
开发者ID:ugurbastan,项目名称:swe-574-group4,代码行数:101,代码来源:taxonomy.php


注:本文中的sanitize_term函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。