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


PHP amt_sanitize_keywords函数代码示例

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


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

示例1: amt_add_basic_metadata_head

/**
 * Generates basic metadata for the head area.
 *
 */
function amt_add_basic_metadata_head($post, $attachments, $embedded_media, $options)
{
    $do_description = $options["auto_description"] == "1" ? true : false;
    $do_keywords = $options["auto_keywords"] == "1" ? true : false;
    $do_noodp_description = $options["noodp_description"] == "1" ? true : false;
    // Array to store metadata
    $metadata_arr = array();
    // Robots Meta Tag.
    $robots_content = '';
    if ($do_noodp_description && (is_front_page() || is_singular())) {
        // Add NOODP on posts and pages
        $robots_content = 'NOODP,NOYDIR';
        // Allow filtering of the robots meta tag content.
        $robots_content = apply_filters('amt_robots_data', $robots_content);
    }
    // Add a robots meta tag if its content is not empty.
    if (!empty($robots_content)) {
        $metadata_arr[] = '<meta name="robots" content="' . $robots_content . '" />';
    }
    // Default front page displaying latest posts
    if (amt_is_default_front_page()) {
        // Description and Keywords from the Add-Meta-Tags settings override
        // default behaviour.
        // Description
        if ($do_description) {
            // Use the site description from the Add-Meta-Tags settings.
            // Fall back to the blog description.
            $site_description = $options["site_description"];
            if (empty($site_description)) {
                // Alternatively, use the blog description
                // Here we sanitize the provided description for safety
                $site_description = sanitize_text_field(amt_sanitize_description(get_bloginfo('description')));
            }
            // If we have a description, use it in the description meta-tag of the front page
            if (!empty($site_description)) {
                // Note: Contains multipage information through amt_process_paged()
                $metadata_arr[] = '<meta name="description" content="' . esc_attr(amt_process_paged($site_description)) . '" />';
            }
        }
        // Keywords
        if ($do_keywords) {
            // Use the site keywords from the Add-Meta-Tags settings.
            // Fall back to the blog categories.
            $site_keywords = $options["site_keywords"];
            if (empty($site_keywords)) {
                // Alternatively, use the blog categories
                // Here we sanitize the provided keywords for safety
                $site_keywords = sanitize_text_field(amt_sanitize_keywords(amt_get_all_categories()));
            }
            // If we have keywords, use them in the keywords meta-tag of the front page
            if (!empty($site_keywords)) {
                $metadata_arr[] = '<meta name="keywords" content="' . esc_attr($site_keywords) . '" />';
            }
        }
        // Attachments
    } elseif (is_attachment()) {
        // has to be before is_singular() since is_singular() is true for attachments.
        // Description
        if ($do_description) {
            $description = amt_get_content_description($post, $auto = $do_description);
            if (!empty($description)) {
                // Note: Contains multipage information through amt_process_paged()
                $metadata_arr[] = '<meta name="description" content="' . esc_attr(amt_process_paged($description)) . '" />';
            }
        }
        // No keywords
        // Content pages and static pages used as "front page" and "posts page"
        // This also supports products via is_singular()
    } elseif (is_singular() || amt_is_static_front_page() || amt_is_static_home()) {
        // Description
        if ($do_description) {
            $description = amt_get_content_description($post, $auto = $do_description);
            if (!empty($description)) {
                // Note: Contains multipage information through amt_process_paged()
                $metadata_arr[] = '<meta name="description" content="' . esc_attr(amt_process_paged($description)) . '" />';
            }
        }
        // Keywords
        if ($do_keywords) {
            $keywords = amt_get_content_keywords($post, $auto = $do_keywords);
            if (!empty($keywords)) {
                $metadata_arr[] = '<meta name="keywords" content="' . esc_attr($keywords) . '" />';
                // Static Posts Index Page
                // If no keywords have been set in the metabox and this is the static page,
                // which displayes the latest posts, use the categories of the posts in the loop.
            } elseif (amt_is_static_home()) {
                // Here we sanitize the provided keywords for safety
                $cats_from_loop = sanitize_text_field(amt_sanitize_keywords(implode(', ', amt_get_categories_from_loop())));
                if (!empty($cats_from_loop)) {
                    $metadata_arr[] = '<meta name="keywords" content="' . esc_attr($cats_from_loop) . '" />';
                }
            }
        }
        // 'news_keywords'
        $newskeywords = amt_get_post_meta_newskeywords($post->ID);
        if (!empty($newskeywords)) {
//.........这里部分代码省略.........
开发者ID:rpi-virtuell,项目名称:wordpress-add-meta-tags,代码行数:101,代码来源:amt_basic.php

示例2: amt_save_postdata

function amt_save_postdata($post_id, $post)
{
    // Verify if this is an auto save routine.
    // If it is our form has not been submitted, so we dont want to do anything
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return;
    }
    /* Verify the nonce before proceeding. */
    // Verify this came from the our screen and with proper authorization,
    // because save_post can be triggered at other times
    if (!isset($_POST['amt_noncename']) || !wp_verify_nonce($_POST['amt_noncename'], plugin_basename(AMT_PLUGIN_FILE))) {
        return;
    }
    // Get the Metadata metabox permissions (filtered)
    $metabox_permissions = amt_get_metadata_metabox_permissions();
    // Global Metadata metabox permission check (can be user customized via filter).
    if (!current_user_can($metabox_permissions['global_metabox_capability'])) {
        return;
    }
    // Get the Add-Meta-Tags options.
    $options = get_option("add_meta_tags_opts");
    /* Get the post type object. */
    $post_type_obj = get_post_type_object($post->post_type);
    /* Check if the current user has permission to edit the post. */
    if (!current_user_can($post_type_obj->cap->edit_post, $post_id)) {
        return;
    }
    // OK, we're authenticated: we need to find and save the data
    //
    // Sanitize user input
    //
    //
    // Description
    if (isset($_POST['amt_custom_description'])) {
        $description_value = sanitize_text_field(amt_sanitize_description(stripslashes($_POST['amt_custom_description'])));
    }
    // Keywords - sanitize_text_field() removes '%ca' part of '%cats%', so we enclose 'sanitize_text_field()' in amt_(convert|revert)_placeholders()
    if (isset($_POST['amt_custom_keywords'])) {
        $keywords_value = amt_sanitize_keywords(amt_revert_placeholders(sanitize_text_field(amt_convert_placeholders(stripslashes($_POST['amt_custom_keywords'])))));
    }
    // Title
    if (isset($_POST['amt_custom_title'])) {
        $title_value = amt_revert_placeholders(sanitize_text_field(amt_convert_placeholders(stripslashes($_POST['amt_custom_title']))));
    }
    // News keywords
    if (isset($_POST['amt_custom_newskeywords'])) {
        $newskeywords_value = sanitize_text_field(amt_sanitize_keywords(stripslashes($_POST['amt_custom_newskeywords'])));
    }
    // Full metatags - We allow only <meta> elements.
    if (isset($_POST['amt_custom_full_metatags'])) {
        $full_metatags_value = esc_textarea(wp_kses(stripslashes($_POST['amt_custom_full_metatags']), amt_get_allowed_html_kses()));
    }
    // Image URL
    if (isset($_POST['amt_custom_image_url'])) {
        $image_url_value = amt_esc_id_or_url_notation(stripslashes($_POST['amt_custom_image_url']));
    }
    // Content locale
    if (isset($_POST['amt_custom_content_locale'])) {
        $content_locale_value = esc_attr(stripslashes($_POST['amt_custom_content_locale']));
    }
    // Express review
    if (isset($_POST['amt_custom_express_review'])) {
        $express_review_value = esc_textarea(wp_kses(stripslashes($_POST['amt_custom_express_review']), array()));
        //
        // REVIEW_AMPERSAND_NOTE: We replace &amp; to & for (see also REVIEW_AMPERSAND_NOTE in amt-utils.php)
        //
        $express_review_value = str_replace('&amp;', '&', $express_review_value);
    }
    // List of referenced items - We allow no HTML elements.
    if (isset($_POST['amt_custom_referenced_list'])) {
        $referenced_list_value = esc_textarea(wp_kses(stripslashes($_POST['amt_custom_referenced_list']), array()));
    }
    // If a value has not been entered we try to delete existing data from the database
    // If the user has entered data, store it in the database.
    // Add-Meta-Tags custom field names
    $amt_description_field_name = '_amt_description';
    $amt_keywords_field_name = '_amt_keywords';
    $amt_title_field_name = '_amt_title';
    $amt_newskeywords_field_name = '_amt_news_keywords';
    $amt_full_metatags_field_name = '_amt_full_metatags';
    $amt_image_url_field_name = '_amt_image_url';
    $amt_content_locale_field_name = '_amt_content_locale';
    $amt_express_review_field_name = '_amt_express_review';
    $amt_referenced_list_field_name = '_amt_referenced_list';
    // As an extra security measure, here we also check the user-defined per box
    // permissions before we save any data in the database.
    // Description
    if ($options['metabox_enable_description'] == '1' && current_user_can($metabox_permissions['description_box_capability'])) {
        if (empty($description_value)) {
            delete_post_meta($post_id, $amt_description_field_name);
            // Also clean up old description field
            delete_post_meta($post_id, 'description');
        } else {
            update_post_meta($post_id, $amt_description_field_name, $description_value);
            // Also clean up again old description field - no need to exist any more since the new field is used.
            delete_post_meta($post_id, 'description');
        }
    }
    // Keywords
    if ($options['metabox_enable_keywords'] == '1' && current_user_can($metabox_permissions['keywords_box_capability'])) {
//.........这里部分代码省略.........
开发者ID:prkirby,项目名称:AbsolutePressure,代码行数:101,代码来源:amt-admin-panel.php

示例3: amt_save_settings

/**
 * Saves the new settings in the database.
 * Accepts the POST request data.
 */
function amt_save_settings($post_payload)
{
    // Default Add-Meta-Tags Settings
    $default_options = amt_get_default_options();
    $add_meta_tags_opts = array();
    foreach ($default_options as $def_key => $def_value) {
        // **Always** use the ``settings_version`` from the defaults
        if ($def_key == 'settings_version') {
            $add_meta_tags_opts['settings_version'] = $def_value;
        } elseif (array_key_exists($def_key, $post_payload)) {
            // Validate and sanitize input before adding to 'add_meta_tags_opts'
            if ($def_key == 'site_description') {
                $add_meta_tags_opts[$def_key] = sanitize_text_field(amt_sanitize_description(stripslashes($post_payload[$def_key])));
            } elseif ($def_key == 'site_keywords') {
                // No placeholders here
                $add_meta_tags_opts[$def_key] = sanitize_text_field(amt_sanitize_keywords(stripslashes($post_payload[$def_key])));
            } elseif ($def_key == 'global_keywords') {
                // placeholder may exist here
                $add_meta_tags_opts[$def_key] = amt_sanitize_keywords(amt_revert_placeholders(sanitize_text_field(amt_convert_placeholders(stripslashes($post_payload[$def_key])))));
            } elseif ($def_key == 'site_wide_meta') {
                $add_meta_tags_opts[$def_key] = esc_textarea(wp_kses(stripslashes($post_payload[$def_key]), amt_get_allowed_html_kses()));
            } elseif ($def_key == 'copyright_url') {
                $add_meta_tags_opts[$def_key] = esc_url_raw(stripslashes($post_payload[$def_key]), array('http', 'https'));
            } elseif ($def_key == 'default_image_url') {
                $add_meta_tags_opts[$def_key] = esc_url_raw(stripslashes($post_payload[$def_key]), array('http', 'https'));
            } elseif ($def_key == 'social_main_facebook_publisher_profile_url') {
                $add_meta_tags_opts[$def_key] = esc_url_raw(stripslashes($post_payload[$def_key]), array('http', 'https'));
            } elseif ($def_key == 'social_main_googleplus_publisher_profile_url') {
                $add_meta_tags_opts[$def_key] = esc_url_raw(stripslashes($post_payload[$def_key]), array('http', 'https'));
            } elseif ($def_key == 'author_profile_source') {
                $author_profile_source_value = sanitize_text_field(stripslashes($post_payload[$def_key]));
                if (!in_array($author_profile_source_value, array('default', 'frontpage', 'buddypress', 'url'))) {
                    $author_profile_source_value = 'default';
                }
                $add_meta_tags_opts[$def_key] = $author_profile_source_value;
            } elseif ($def_key == 'transient_cache_expiration') {
                $transient_cache_expiration_value = sanitize_text_field(stripslashes($post_payload[$def_key]));
                if (!is_numeric($transient_cache_expiration_value) || intval($transient_cache_expiration_value) < 0) {
                    $transient_cache_expiration_value = '0';
                }
                $add_meta_tags_opts[$def_key] = $transient_cache_expiration_value;
            } else {
                $add_meta_tags_opts[$def_key] = sanitize_text_field(stripslashes($post_payload[$def_key]));
            }
        } else {
            // The following settings have a default value of 1, so they can never be
            // deactivated, unless the following check takes place.
            if ($def_key == 'auto_description' || $def_key == 'auto_keywords' || $def_key == 'noindex_search_results' || $def_key == 'metabox_enable_description' || $def_key == 'metabox_enable_keywords' || $def_key == 'metabox_enable_title') {
                if (!isset($post_payload[$def_key])) {
                    $add_meta_tags_opts[$def_key] = "0";
                }
            } else {
                // Else save the default value in the db.
                $add_meta_tags_opts[$def_key] = $def_value;
            }
        }
    }
    // Finally update the Add-Meta-Tags options.
    update_option("add_meta_tags_opts", $add_meta_tags_opts);
    //var_dump($post_payload);
    //var_dump($add_meta_tags_opts);
    amt_show_info_msg(__('Add-Meta-Tags options saved', 'add-meta-tags'));
}
开发者ID:pytong,项目名称:research-group,代码行数:67,代码来源:amt-settings.php

示例4: amt_add_basic_metadata_head


//.........这里部分代码省略.........
    if (amt_is_custom($post, $options)) {
        // Return metadata with:
        // add_filter( 'amt_custom_metadata_basic', 'my_function', 10, 5 );
        // Return an array of meta tags. Array item format: ['key_can_be_whatever'] = '<meta name="foo" content="bar" />'
        $metadata_arr = apply_filters('amt_custom_metadata_basic', $metadata_arr, $post, $options, $attachments, $embedded_media);
        // Default front page displaying latest posts
    } elseif (amt_is_default_front_page()) {
        // Description and Keywords from the Add-Meta-Tags settings override
        // default behaviour.
        // Description
        if ($do_description) {
            // Use the site description from the Add-Meta-Tags settings.
            // Fall back to the blog description.
            $site_description = amt_get_site_description($options);
            if (empty($site_description)) {
                // Alternatively, use the blog description
                // Here we sanitize the provided description for safety
                $site_description = sanitize_text_field(amt_sanitize_description(get_bloginfo('description')));
            }
            // If we have a description, use it in the description meta-tag of the front page
            if (!empty($site_description)) {
                // Note: Contains multipage information through amt_process_paged()
                $metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr(amt_process_paged($site_description)) . '" />';
            }
        }
        // Keywords
        if ($do_keywords) {
            // Use the site keywords from the Add-Meta-Tags settings.
            // Fall back to the blog categories.
            $site_keywords = amt_get_site_keywords($options);
            if (empty($site_keywords)) {
                // Alternatively, use the blog categories
                // Here we sanitize the provided keywords for safety
                $site_keywords = sanitize_text_field(amt_sanitize_keywords(amt_get_all_categories()));
            }
            // If we have keywords, use them in the keywords meta-tag of the front page
            if (!empty($site_keywords)) {
                $metadata_arr['basic:keywords'] = '<meta name="keywords" content="' . esc_attr($site_keywords) . '" />';
            }
        }
        // Attachments
    } elseif (is_attachment()) {
        // has to be before is_singular() since is_singular() is true for attachments.
        // Description
        if ($do_description) {
            $description = amt_get_content_description($post, $auto = $do_description);
            if (!empty($description)) {
                // Note: Contains multipage information through amt_process_paged()
                $metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr(amt_process_paged($description)) . '" />';
            }
        }
        // No keywords
        // Content pages and static pages used as "front page" and "posts page"
        // This also supports products via is_singular()
    } elseif (is_singular() || amt_is_static_front_page() || amt_is_static_home()) {
        // Description
        if ($do_description) {
            $description = amt_get_content_description($post, $auto = $do_description);
            if (!empty($description)) {
                // Note: Contains multipage information through amt_process_paged()
                $metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr(amt_process_paged($description)) . '" />';
            }
        }
        // Keywords
        if ($do_keywords) {
            $keywords = amt_get_content_keywords($post, $auto = $do_keywords);
开发者ID:ashenkar,项目名称:sanga,代码行数:67,代码来源:amt_basic.php

示例5: amt_get_content_keywords

/**
 * This is a helper function that returns the post's or page's keywords.
 *
 * Important: MUST return sanitized data, unless this plugin has sanitized the data before storing to db.
 *
 */
function amt_get_content_keywords($post, $auto = true, $exclude_categories = false)
{
    // By default, if custom keywords have not been entered by the user in the
    // metabox, keywords are autogenerated. To stop this automatic generation
    // of keywords and return only the keywords that have been entered manually,
    // set $auto to false via the following filter.
    $auto = apply_filters('amt_generate_keywords_if_no_manual_data', $auto);
    $content_keywords = '';
    /*
     * Custom post field "keywords" overrides post's categories, tags (tags exist in WordPress 2.3 or newer)
     * and custom taxonomy terms (custom taxonomies exist since WP version 2.8).
     * %cats% is replaced by the post's categories.
     * %tags% is replaced by the post's tags.
     * %terms% is replaced by the post's custom taxonomy terms.
     */
    if (is_singular() || amt_is_static_front_page() || amt_is_static_home()) {
        $keyw_fld_content = amt_get_post_meta_keywords($post->ID);
        // If there is a custom field, use it
        if (!empty($keyw_fld_content)) {
            // On single posts, expand the %cats%, %tags% and %terms% placeholders.
            // This should not take place in pages (no categories, no tags by default)
            // or custom post types, the support of which for categories and tags is unknown.
            if (is_single()) {
                // Here we sanitize the provided keywords for safety
                $keywords_from_post_cats = sanitize_text_field(amt_sanitize_keywords(amt_get_keywords_from_post_cats($post)));
                if (!empty($keywords_from_post_cats)) {
                    $keyw_fld_content = str_replace("%cats%", $keywords_from_post_cats, $keyw_fld_content);
                }
                // Also, the %tags% placeholder is replaced by the post's tags (WordPress 2.3 or newer)
                if (version_compare(get_bloginfo('version'), '2.3', '>=')) {
                    // Here we sanitize the provided keywords for safety
                    $keywords_from_post_tags = sanitize_text_field(amt_sanitize_keywords(amt_get_post_tags($post)));
                    if (!empty($keywords_from_post_tags)) {
                        $keyw_fld_content = str_replace("%tags%", $keywords_from_post_tags, $keyw_fld_content);
                    }
                }
                // Also, the %terms% placeholder is replaced by the post's custom taxonomy terms (WordPress 2.8 or newer)
                if (version_compare(get_bloginfo('version'), '2.8', '>=')) {
                    // Here we sanitize the provided keywords for safety
                    $keywords_from_post_terms = sanitize_text_field(amt_sanitize_keywords(amt_get_keywords_from_custom_taxonomies($post)));
                    if (!empty($keywords_from_post_terms)) {
                        $keyw_fld_content = str_replace("%terms%", $keywords_from_post_terms, $keyw_fld_content);
                    }
                }
            }
            $content_keywords .= $keyw_fld_content;
            // Otherwise, generate the keywords from categories, tags and custom taxonomy terms.
            // Note:
            // Here we use is_singular(), so that pages are also checked for categories and tags.
            // By default, pages do not support categories and tags, but enabling such
            // functionality is trivial. See #1206 for more details.
        } elseif ($auto && is_singular()) {
            /*
             * Add keywords automatically.
             * Keywords consist of the post's categories, the post's tags (tags exist in WordPress 2.3 or newer)
             * and the terms of the custom taxonomies to which the post belongs (since WordPress 2.8).
             */
            // Categories - Here we sanitize the provided keywords for safety
            if ($exclude_categories === false) {
                $keywords_from_post_cats = sanitize_text_field(amt_sanitize_keywords(amt_get_keywords_from_post_cats($post)));
                if (!empty($keywords_from_post_cats)) {
                    $content_keywords .= $keywords_from_post_cats;
                }
            }
            // Tags - Here we sanitize the provided keywords for safety
            $keywords_from_post_tags = sanitize_text_field(amt_sanitize_keywords(amt_get_post_tags($post)));
            if (!empty($keywords_from_post_tags)) {
                if (!empty($content_keywords)) {
                    $content_keywords .= ", ";
                }
                $content_keywords .= $keywords_from_post_tags;
            }
            // Custom taxonomy terms - Here we sanitize the provided keywords for safety
            $keywords_from_post_custom_taxonomies = sanitize_text_field(amt_sanitize_keywords(amt_get_keywords_from_custom_taxonomies($post)));
            if (!empty($keywords_from_post_custom_taxonomies)) {
                if (!empty($content_keywords)) {
                    $content_keywords .= ", ";
                }
                $content_keywords .= $keywords_from_post_custom_taxonomies;
            }
        }
    }
    // Add post format to the list of keywords
    if ($auto && is_singular() && get_post_format($post->ID) !== false) {
        if (empty($content_keywords)) {
            $content_keywords .= get_post_format($post->ID);
        } else {
            $content_keywords .= ', ' . get_post_format($post->ID);
        }
    }
    /**
     * Finally, add the global keywords, if they are set in the administration panel.
     */
    #if ( !empty($content_keywords) && ( is_singular() || amt_is_static_front_page() || amt_is_static_home() ) ) {
//.........这里部分代码省略.........
开发者ID:RomualdKarbido,项目名称:Zeroom,代码行数:101,代码来源:amt-utils.php

示例6: amt_buddypress_basic

function amt_buddypress_basic($metadata_arr, $post, $options, $attachments, $embedded_media)
{
    // User Profiles
    // Determines if a BuddyPress user profile has been requested
    if (bp_is_user_profile()) {
        // https://codex.buddypress.org/developer/the-bp-global/
        global $bp;
        // $user_id = $bp->displayed_user->id;
        $user_id = bp_displayed_user_id();
        // $user_domain = $bp->displayed_user->domain;
        // bp_core_get_user_domain( bp_displayed_user_id() )
        $user_domain = bp_displayed_user_domain();
        $user_profile_url = trailingslashit(bp_displayed_user_domain() . amt_bp_get_profile_slug());
        $user_fullname = $bp->displayed_user->fullname;
        // $user_fullname = bp_displayed_user_fullname();
        // $user_username = $bp->displayed_user->user_login;
        $user_username = bp_get_displayed_user_username();
        //$wp_user_obj = get_user_by( 'id', $user_id );
        $wp_user_obj = get_userdata($user_id);
        //var_dump($wp_user_obj);
        // Related resources
        // Perhaps add Facebook, Twitter, Google+ profile URLs in 'og:see_also' meta tags
        // og:see_also
        // Determines if Extended Profiles component is active.
        if (!bp_is_active('xprofile')) {
            // Description
            $author_description = sanitize_text_field(amt_sanitize_description($wp_user_obj->description));
            if (empty($author_description)) {
                $metadata_arr[] = '<meta name="description" content="' . esc_attr(__('Profile of', 'add-meta-tags') . ' ' . $wp_user_obj->display_name) . '" />';
            } else {
                $metadata_arr[] = '<meta name="description" content="' . esc_attr($author_description) . '" />';
            }
            // No automatic keywords
            // Extended Profiles
        } else {
            // https://codex.buddypress.org/themes/guides/displaying-extended-profile-fields-on-member-profiles/
            $xprofile_field_map = amt_buddypress_get_xprofile_field_map();
            // Get list of IDs of public fields
            $xprofile_public_fields = bp_xprofile_get_fields_by_visibility_levels($user_id, array('public'));
            // Description
            $field_value = amt_bp_get_profile_field_data('description', $user_id, $xprofile_field_map, $xprofile_public_fields);
            $field_value = sanitize_text_field(amt_sanitize_description($field_value));
            if (!empty($field_value)) {
                $metadata_arr[] = '<meta name="description" content="' . esc_attr($field_value) . '" />';
            } else {
                $metadata_arr[] = '<meta name="description" content="' . esc_attr(__('Profile of', 'add-meta-tags') . ' ' . $user_fullname) . '" />';
            }
            // Keywords
            $field_value = amt_bp_get_profile_field_data('keywords', $user_id, $xprofile_field_map, $xprofile_public_fields);
            $field_value = sanitize_text_field(amt_sanitize_keywords($field_value));
            if (!empty($field_value)) {
                $metadata_arr[] = '<meta name="keywords" content="' . esc_attr($field_value) . '" />';
            }
        }
    }
    // Allow filtering of the generated metadata
    // Customize with: add_filter('amt_buddypress_basic_extra', 'my_function', 10, 5);
    $metadata_arr = apply_filters('amt_buddypress_basic_extra', $metadata_arr, $post, $options, $attachments, $embedded_media);
    return $metadata_arr;
}
开发者ID:prkirby,项目名称:AbsolutePressure,代码行数:60,代码来源:amt_extended.php


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