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


PHP sanitize_term_field函数代码示例

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


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

示例1: quality_manage_columns

/**
 * Create callbacks for custom columns.
 *
 * @since Quality Control 0.1
 * @uses get_the_term_list
 */
function quality_manage_columns($column)
{
    global $post;
    switch ($column) {
        case 'milestone':
            $milestones = get_the_terms($post->ID, 'ticket_milestone');
            if (!empty($milestones)) {
                $out = array();
                foreach ($milestones as $c) {
                    $out[] = "<a href='edit.php?post_type={$post->post_type}&amp;ticket_milestone={$c->slug}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'ticket_milestone', 'display')) . "</a>";
                }
                echo join(', ', $out);
            } else {
                _e('No Milestone', 'quality');
            }
            break;
        case 'status':
            $states = get_the_terms($post->ID, 'ticket_status');
            if (!empty($states)) {
                $out = array();
                foreach ($states as $c) {
                    $out[] = "<a href='edit.php?post_type={$post->post_type}&amp;ticket_status={$c->slug}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'ticket_milestone', 'display')) . "</a>";
                }
                echo join(', ', $out);
            } else {
                _e('No Status', 'quality');
            }
            break;
        case 'assigned':
            echo quality_assigned_to_list();
            break;
    }
}
开发者ID:jshwlkr,项目名称:Quality-Control,代码行数:39,代码来源:tickets.php

示例2: my_manage_project_columns

function my_manage_project_columns($column, $post_id)
{
    global $post;
    switch ($column) {
        case 'type':
            $terms = get_the_terms($post_id, 'type');
            if (!empty($terms)) {
                $out = array();
                foreach ($terms as $term) {
                    $out[] = sprintf('<a href="%s">%s</a>', esc_url(add_query_arg(array('post_type' => $post->post_type, 'type' => $term->slug), 'edit.php')), esc_html(sanitize_term_field('name', $term->name, $term->term_id, 'type', 'display')));
                }
                echo join(', ', $out);
            } else {
                _e('No Type Specified');
            }
            break;
        case 'featured':
            $featured = get_field('status', $post_id);
            if ($featured != 'no') {
                echo '<span class="yes">YES</span>';
            } else {
                echo '<span class="no">NO</span>';
            }
            break;
        default:
            break;
    }
}
开发者ID:ndimatteo,项目名称:aa-theme,代码行数:28,代码来源:post-types.php

示例3: manage_events_columns

function manage_events_columns($name)
{
    global $post, $wp_query, $default_date;
    switch ($name) {
        case 'events_cat':
            $terms = get_the_terms($post->ID, 'events_cat');
            //If the terms array contains items... (dupe of core)
            if (!empty($terms)) {
                //Loop through terms
                foreach ($terms as $term) {
                    //Add tax name & link to an array
                    $post_terms[] = esc_html(sanitize_term_field('name', $term->name, $term->term_id, '', 'edit'));
                }
                //Spit out the array as CSV
                echo implode(', ', $post_terms);
            } else {
                //Text to show if no terms attached for post & tax
                echo '<em>No terms</em>';
            }
            break;
        case 'eventdate':
            if (get_post_meta(get_the_ID(), 'event_date', true) != '') {
                echo date($default_date, get_post_meta(get_the_ID(), 'event_date', true));
            }
            //echo get_post_meta( get_the_ID(),'event_date',TRUE );
            break;
        case 'location':
            echo get_post_meta(get_the_ID(), 'event_location', TRUE);
            break;
        case 'venue':
            echo get_post_meta(get_the_ID(), 'event_venue', TRUE);
            break;
    }
}
开发者ID:pryspry,项目名称:MusicPlay,代码行数:34,代码来源:events.php

示例4: manage_portfolio_columns

function manage_portfolio_columns($column)
{
    global $post;
    if ($post->post_type == "portfolio") {
        switch ($column) {
            case "description":
                the_excerpt();
                break;
            case "portfolio_categories":
                $terms = get_the_terms($post->ID, 'portfolio_category');
                if (!empty($terms)) {
                    foreach ($terms as $t) {
                        $output[] = "<a href='edit.php?post_type=portfolio&portfolio_tag={$t->slug}'> " . esc_html(sanitize_term_field('name', $t->name, $t->term_id, 'portfolio_tag', 'display')) . "</a>";
                    }
                    $output = implode(', ', $output);
                } else {
                    $t = get_taxonomy('portfolio_category');
                    $output = "No {$t->label}";
                }
                echo $output;
                break;
            case 'thumbnail':
                echo the_post_thumbnail('thumbnail');
                break;
        }
    }
}
开发者ID:kevalbaxi,项目名称:dosomething-blog,代码行数:27,代码来源:portfolio.php

示例5: orbit_manage_excpt2_columns

function orbit_manage_excpt2_columns($column, $post_id)
{
    global $post;
    switch ($column) {
        // If displaying the 'type' column
        case 'type':
            // Get the types for the post
            $terms = get_the_terms($post_id, 'excpt2-type');
            // If terms were found
            if (!empty($terms)) {
                $out = array();
                // Loop through each term, linking to the 'edit posts' page for the specific term
                foreach ($terms as $term) {
                    $out[] = sprintf('<a href="%s">%s</a>', esc_url(add_query_arg(array('post_type' => $post->post_type, 'excpt2' => $term->slug), 'edit.php')), esc_html(sanitize_term_field('name', $term->name, $term->term_id, 'excpt2', 'display')));
                }
                // Join the terms, separating them with a comma
                echo join(', ', $out);
            } else {
                _e('No excpt2 type');
            }
            break;
            // Just break out of the switch statement for everything else
        // Just break out of the switch statement for everything else
        default:
            break;
    }
}
开发者ID:ryanurban,项目名称:Orbit,代码行数:27,代码来源:admin-columns.php

示例6: get_the_series_rss

function get_the_series_rss($type = 'rss')
{
    $series = get_the_series();
    $home = get_bloginfo_rss('home');
    $the_list = '';
    $series_names = array();
    $filter = 'rss';
    if ('atom' == $type) {
        $filter = 'raw';
    }
    if (!empty($series)) {
        foreach ((array) $series as $serial) {
            $series_names[] = sanitize_term_field('name', $serial->name, $serial->term_id, 'series', $filter);
        }
    }
    $series_names = array_unique($series_names);
    foreach ($series_names as $series_name) {
        if ('rdf' == $type) {
            $the_list .= "\n\t\t<series:name><![CDATA[{$series_name}]]></series:name>\n";
        } elseif ('atom' == $type) {
            $the_list .= sprintf('<series:name scheme="%1$s" term="%2$s" />', esc_attr(apply_filters('get_bloginfo_rss', get_bloginfo('url'))), esc_attr($series_name));
        } else {
            $the_list .= "\n\t\t<series:name><![CDATA[{$series_name}]]></series:name>\n";
        }
    }
    return apply_filters('the_series_rss', $the_list, $type);
}
开发者ID:briancfeeney,项目名称:portigal,代码行数:27,代码来源:orgSeries-rss.php

示例7: manage_artists_columns

function manage_artists_columns($name)
{
    global $wpdb, $wp_query, $post;
    switch ($name) {
        case 'genres':
            echo get_post_meta(get_the_ID(), 'artist_genres', TRUE);
            break;
        case 'artist_id':
            echo get_the_ID();
            break;
        case 'artist_cat':
            $terms = get_the_terms($post->ID, 'artist_cat');
            //If the terms array contains items... (dupe of core)
            if (!empty($terms)) {
                //Loop through terms
                foreach ($terms as $term) {
                    //Add tax name & link to an array
                    $post_terms[] = esc_html(sanitize_term_field('name', $term->name, $term->term_id, '', 'edit'));
                }
                //Spit out the array as CSV
                echo implode(', ', $post_terms);
            } else {
                //Text to show if no terms attached for post & tax
                echo '<em>No terms</em>';
            }
            break;
        case 'thumbnail':
            echo the_post_thumbnail(array(100, 100));
            break;
    }
}
开发者ID:pryspry,项目名称:MusicPlay,代码行数:31,代码来源:artist.php

示例8: vntd_portfolio_columns_content

function vntd_portfolio_columns_content($column, $post_id)
{
    global $post;
    switch ($column) {
        /* If displaying the 'duration' column. */
        case 'category':
            $taxonomy = "project-type";
            $post_type = get_post_type($post_id);
            $terms = get_the_terms($post_id, $taxonomy);
            if (!empty($terms)) {
                foreach ($terms as $term) {
                    $post_terms[] = "<a href='edit.php?post_type={$post_type}&{$taxonomy}={$term->slug}'> " . esc_html(sanitize_term_field('name', $term->name, $term->term_id, $taxonomy, 'edit')) . "</a>";
                }
                echo join(', ', $post_terms);
            } else {
                echo '<i>No categories.</i>';
            }
            break;
            /* If displaying the 'genre' column. */
        /* If displaying the 'genre' column. */
        case 'thumbnail':
            the_post_thumbnail('thumbnail', array('class' => 'column-img'));
            break;
            /* Just break out of the switch statement for everything else. */
        /* Just break out of the switch statement for everything else. */
        default:
            break;
    }
}
开发者ID:jfbelisle,项目名称:magexpress,代码行数:29,代码来源:portfolio-functions.php

示例9: convert_object_to_cpt_onomy_term

 /**
  * This function takes an object's information and creates a term object.
  *
  * As of version 1.2, you can hook into the 'term_description' or
  * '{$taxonomy}_description' filter to add a description to your terms.
  *
  * The variable type (object or array) for the returned $term will match the set type of the passed $object.
  *
  * @since 1.0
  * @uses $cpt_onomies_manager
  * @param array|object $object - the information for the object you are converting
  * @param boolean $get_count - whether to get the term count
  * @return array|object - the information for the term you have created.
  */
 private function convert_object_to_cpt_onomy_term($object, $get_count = true)
 {
     global $cpt_onomies_manager;
     // If its empty, then there's no point
     if (empty($object)) {
         return $object;
     }
     // Make sure the term is an object
     $term = (object) $object;
     // Make sure its a CPT-onomy
     if (!$cpt_onomies_manager->is_registered_cpt_onomy($term->post_type)) {
         return $object;
     }
     /**
      * sanitize_term_field() lets you apply the 'term_description'
      * or '{$taxonomy}_description' filter to tweak the description,
      * if desired. Maybe you want the description to be a custom field?
      * or the post content. Just return that info in the filter!
      */
     $term = array('term_id' => $term->ID, 'name' => apply_filters('the_title', $term->post_title, $term->ID), 'slug' => $term->post_name, 'term_group' => $term->post_parent, 'term_taxonomy_id' => 0, 'taxonomy' => $term->post_type, 'description' => sanitize_term_field('description', '', $term->ID, $term->post_type, 'display'), 'parent' => $term->post_parent);
     if ($get_count) {
         $term['count'] = $this->get_term_count($term['term_id'], $term['taxonomy']);
     }
     if (is_object($object)) {
         return (object) $term;
     }
     return $term;
 }
开发者ID:aarongillett,项目名称:B22-151217,代码行数:42,代码来源:cpt-onomy.php

示例10: portfolio_custom_columns

 /**
  * Portfolio Custom Columns
  * @since     1.0
  * @updated   1.0
  *
  */
 public function portfolio_custom_columns($column)
 {
     global $post;
     $layouts = array('half' => esc_attr__('Half Width', 'Twoot'), 'full' => esc_attr__('Full Width', 'Twoot'));
     $type = ucwords(twoot_get_frontend_func('meta', 'type'));
     $layout = twoot_get_frontend_func('meta', 'layout');
     switch ($column) {
         case 'portfolio_categories':
             $terms = get_the_terms($post->ID, 'portfolio_cat');
             if (!empty($terms)) {
                 foreach ($terms as $t) {
                     $output[] = '<a href="edit.php?post_type=portfolio&portfolio_cat=' . $t->slug . '">' . esc_html(sanitize_term_field('name', $t->name, $t->term_id, 'portfolio_cat', 'display')) . '</a>';
                 }
                 $output = implode(', ', $output);
             } else {
                 $t = get_taxonomy('portfolio_cat');
                 $output = 'No ' . $t->label;
             }
             echo $output;
             break;
         case 'portfolio_thumbnail':
             if (has_post_thumbnail()) {
                 the_post_thumbnail('thumbnail');
             } else {
                 echo esc_attr__('No featured image', 'Twoot');
             }
             break;
         case 'portfolio_type':
             echo $type;
             break;
         case 'portfolio_layout':
             echo $layouts[$layout];
             break;
     }
 }
开发者ID:sniezekjp,项目名称:prod-fs,代码行数:41,代码来源:class-post-types-backend.php

示例11: manage_rehearsal_columns

/**
 * UCFBands Rehearsal: Manage CPT Custom Columns
 *
 * @author Jordan Pakrosnis
 */
function manage_rehearsal_columns($column, $post_id)
{
    global $post;
    switch ($column) {
        /* If displaying the 'duration' column. */
        case 'rehearsal_date':
            // Edit link
            echo '<a href="' . get_edit_post_link() . '">';
            /* Get the post meta. */
            $rehearsal_date = get_post_meta($post_id, '_ucfbands_rehearsal_' . 'date', true);
            /* If no date is found, output a default message. */
            if (empty($rehearsal_date)) {
                echo __('Not Set!');
            } else {
                echo date('l, M jS', $rehearsal_date);
            }
            // End edit link
            echo '</a>';
            break;
            /* If displaying the 'cancelled' column. */
        /* If displaying the 'cancelled' column. */
        case 'cancelled':
            /* Get the post meta. */
            $rehearsal_cancelled = get_post_meta($post_id, '_ucfbands_rehearsal_' . 'is_rehearsal_cancelled', true);
            /* If no date is found, output a default message. */
            if ($rehearsal_cancelled == true) {
                echo '<b>Yes</b>';
            }
            break;
            /* If displaying the 'band' column. */
        /* If displaying the 'band' column. */
        case 'band':
            /* Get the genres for the post. */
            $terms = get_the_terms($post_id, 'band');
            /* If terms were found. */
            if (!empty($terms)) {
                $out = array();
                /* Loop through each term, linking to the 'edit posts' page for the specific term. */
                foreach ($terms as $term) {
                    $out[] = sprintf('%s', esc_html(sanitize_term_field('name', $term->name, $term->term_id, 'band', 'display')));
                }
                /* Join the terms, separating them with a comma. */
                echo join(', ', $out);
            } else {
                _e('No Band');
            }
            break;
            /* Just break out of the switch statement for everything else. */
        /* Just break out of the switch statement for everything else. */
        default:
            break;
    }
    // column switch
}
开发者ID:JordanPak,项目名称:UCFBands-Functionality,代码行数:59,代码来源:rehearsal-admin.php

示例12: han_dwa_qa_question_admin_columns_content

/**
 * Add content to the created admin columns for questions
 * @param (string) the column title
 * @param (int) the post ID
 * @return (void / output buffer)
 */
function han_dwa_qa_question_admin_columns_content($column, $postId)
{
    $question = new Question($postId);
    if ($column === 'email') {
        echo $question->getEmail();
    } elseif ($column === 'votes') {
        echo $question->getVotes();
    } elseif ($column === 'qa') {
        $qa = $question->getQa();
        echo sprintf('<a href="%s">%s</a>', esc_url(add_query_arg(array('post' => $qa->ID, 'action' => 'edit'), 'post.php')), esc_html(sanitize_term_field('name', $qa->post_title, $qa->ID, 'name', 'display')));
    }
}
开发者ID:sjorsroelofs,项目名称:han-dwa-qa,代码行数:18,代码来源:post_types_and_taxonomies.php

示例13: get_portfolio_taxs

function get_portfolio_taxs($cat_name)
{
    global $post;
    $categories = get_the_terms(null, $cat_name);
    if (!empty($categories)) {
        $out = array();
        foreach ($categories as $c) {
            $out[] = "<a href='edit.php?post_type={$post->post_type}&amp;{$cat_name}={$c->slug}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, $cat_name, 'display')) . "</a>";
        }
        return join(', ', $out);
    } else {
        return $cat_name == 'projects' ? __('Uncategorized') : __('No Tags');
    }
}
开发者ID:billyprice1,项目名称:website,代码行数:14,代码来源:portfolio.php

示例14: organizedthemes_manage_staff_columns

function organizedthemes_manage_staff_columns($column, $post_id)
{
    global $post;
    switch ($column) {
        case "slide_thumbnail":
            //Adds the slide thumnail to the columns
            $width = (int) 400;
            $height = (int) 300;
            $thumbnail_id = get_post_meta($post_id, '_thumbnail_id', true);
            // Display the featured image in the column view if possible
            if ($thumbnail_id) {
                $thumb = wp_get_attachment_image($thumbnail_id, array($width, $height), true);
            }
            break;
            /* If displaying the 'job title' column. */
        /* If displaying the 'job title' column. */
        case 'staff_title':
            /* Get the post meta. */
            $job_title = get_post_meta($post_id, 'title', true);
            /* If no duration is found, output a default message. */
            if (empty($job_title)) {
                echo __('', 'organizedthemes');
            } else {
                printf(__('%s'), $job_title);
            }
            break;
            /* If displaying the 'staff-group' column. */
        /* If displaying the 'staff-group' column. */
        case 'staff_group':
            /* Get the genres for the post. */
            $terms = get_the_terms($post_id, 'staff-group');
            /* If terms were found. */
            if (!empty($terms)) {
                $out = array();
                /* Loop through each term, linking to the 'edit posts' page for the specific term. */
                foreach ($terms as $term) {
                    $out[] = sprintf('<a href="%s">%s</a>', esc_url(add_query_arg(array('post_type' => $post->post_type, 'staff-group' => $term->slug), 'edit.php')), esc_html(sanitize_term_field('name', $term->name, $term->term_id, 'staff-group', 'display')));
                }
                /* Join the terms, separating them with a comma. */
                echo join(', ', $out);
            } else {
                _e('');
            }
            break;
            /* Just break out of the switch statement for everything else. */
        /* Just break out of the switch statement for everything else. */
        default:
            break;
    }
}
开发者ID:Ezyva2015,项目名称:money101.com.au,代码行数:50,代码来源:staff.php

示例15: docCustomColumn

 public function docCustomColumn($columnName, $postID)
 {
     $taxonomy = $columnName;
     $postType = get_post_type($postID);
     $terms = get_the_terms($postID, $taxonomy);
     if (!empty($terms)) {
         foreach ($terms as $term) {
             $postTerms[] = "<a href='edit.php?post_type={$postType}&{$taxonomy}={$term->slug}'> " . esc_html(sanitize_term_field('name', $term->name, $term->term_id, $taxonomy, 'edit')) . '</a>';
             echo join(',', $postTerms);
         }
     } else {
         echo '<i>No terms.</i>';
     }
 }
开发者ID:alex-storojenko,项目名称:eerp_plugin,代码行数:14,代码来源:articles.php


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