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


PHP amt_is_static_home函数代码示例

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


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

示例1: amt_add_opengraph_metadata_head


//.........这里部分代码省略.........
        } elseif (function_exists('has_post_thumbnail') && has_post_thumbnail($post->ID)) {
            // Allow filtering of the image size.
            $image_size = apply_filters('amt_image_size_index', 'full');
            $metadata_arr = array_merge($metadata_arr, amt_get_opengraph_image_metatags($options, get_post_thumbnail_id($post->ID), $size = $image_size));
        } else {
            // Use the default image, if one has been set.
            $image_data = amt_get_default_image_data();
            if (!empty($image_data)) {
                $image_size = apply_filters('amt_image_size_index', 'full');
                $image_meta_tags = amt_get_opengraph_image_metatags($options, $image_data, $size = $image_size);
                if (!empty($image_meta_tags)) {
                    $metadata_arr = array_merge($metadata_arr, $image_meta_tags);
                }
            }
            // Alternatively, use default image
            //$metadata_arr[] = '<meta property="og:image" content="' . esc_url_raw( $options["default_image_url"] ) . '" />';
            //if ( is_ssl() || ( ! is_ssl() && $options["has_https_access"] == "1" ) ) {
            //    $metadata_arr[] = '<meta property="og:image:secure_url" content="' . esc_url_raw( str_replace('http:', 'https:', $options["default_image_url"] ) ) . '" />';
            //}
        }
        // Profile data (only if the front page has been set as the source of profile.)
        if ($options['author_profile_source'] == 'frontpage') {
            // Profile first and last name
            $last_name = get_the_author_meta('last_name', $post->post_author);
            if (!empty($last_name)) {
                $metadata_arr[] = '<meta property="profile:last_name" content="' . esc_attr($last_name) . '" />';
            }
            $first_name = get_the_author_meta('first_name', $post->post_author);
            if (!empty($first_name)) {
                $metadata_arr[] = '<meta property="profile:first_name" content="' . esc_attr($first_name) . '" />';
            }
        }
        // The posts index page - a static page displaying the latest posts
    } elseif (amt_is_static_home()) {
        // Type
        $metadata_arr[] = '<meta property="og:type" content="website" />';
        // Site Name
        $metadata_arr[] = '<meta property="og:site_name" content="' . esc_attr(get_bloginfo('name')) . '" />';
        // Title - Note: Contains multipage information
        $metadata_arr['og:title'] = '<meta property="og:title" content="' . esc_attr(amt_get_title_for_metadata($options, $post)) . '" />';
        // URL - Note: different method to get the permalink on paged archives
        if (is_paged()) {
            $metadata_arr[] = '<meta property="og:url" content="' . esc_url_raw(get_pagenum_link(get_query_var('paged'))) . '" />';
        } else {
            $metadata_arr[] = '<meta property="og:url" content="' . esc_url_raw(get_permalink($post->ID)) . '" />';
        }
        // Site Description - Note: Contains multipage information through amt_process_paged()
        $content_desc = amt_get_content_description($post);
        if (!empty($content_desc)) {
            // Use the pages custom description
            $metadata_arr[] = '<meta property="og:description" content="' . esc_attr(amt_process_paged($content_desc)) . '" />';
        } elseif (get_bloginfo('description')) {
            // Alternatively use a generic description
            $metadata_arr[] = '<meta property="og:description" content="' . amt_process_paged("An index of the latest content.") . '" />';
        }
        // Locale
        $metadata_arr[] = '<meta property="og:locale" content="' . esc_attr(str_replace('-', '_', amt_get_language_content($options, $post))) . '" />';
        // Site Image
        // First check if a global image override URL has been entered.
        // If yes, use this image URL and override all other images.
        $image_data = amt_get_image_attributes_array(amt_get_post_meta_image_url($post->ID));
        if (!empty($image_data)) {
            $image_size = apply_filters('amt_image_size_index', 'full');
            $image_meta_tags = amt_get_opengraph_image_metatags($options, $image_data, $size = $image_size);
            if (!empty($image_meta_tags)) {
                $metadata_arr = array_merge($metadata_arr, $image_meta_tags);
开发者ID:pytong,项目名称:research-group,代码行数:67,代码来源:amt_opengraph.php

示例2: 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

示例3: amt_add_basic_metadata_head

/**
 * Generates basic metadata for the head area.
 *
 */
function amt_add_basic_metadata_head($post, $attachments, $embedded_media, $options)
{
    if (apply_filters('amt_exclude_basic_metadata', false)) {
        return array();
    }
    $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();
    // Pre-processing
    // Store hreflang links in array
    $hreflang_links_arr = array();
    // Store base robots options
    $robots_options = array();
    if ($do_noodp_description && (is_front_page() || is_singular() || is_category() || is_tag() || is_tax() || is_author())) {
        // Add NOODP on posts and pages
        $robots_options[] = 'noodp';
        $robots_options[] = 'noydir';
    }
    // Store full meta tags (site wide and post specific)
    // Add site wide meta tags
    $full_metatags_as_string = '';
    if (!empty($options['site_wide_meta'])) {
        $full_metatags_for_site = html_entity_decode(stripslashes($options['site_wide_meta']));
        $full_metatags_as_string .= apply_filters('amt_full_metatags_site', $full_metatags_for_site);
        $full_metatags_as_string .= PHP_EOL;
    }
    // Full meta tags
    if (is_singular() || amt_is_static_front_page() || amt_is_static_home()) {
        // per post full meta tags
        $full_metatags_for_content = amt_get_post_meta_full_metatags($post->ID);
        $full_metatags_for_content = html_entity_decode(stripslashes($full_metatags_for_content));
        $full_metatags_as_string .= apply_filters('amt_full_metatags_post', $full_metatags_for_content);
    } elseif (is_category() || is_tag() || is_tax()) {
        // Term specific full meta tags ($post is a term object)
        $full_metatags_for_term = amt_get_term_meta_full_metatags($post->term_id);
        $full_metatags_for_term = html_entity_decode(stripslashes($full_metatags_for_term));
        $full_metatags_as_string .= apply_filters('amt_full_metatags_term', $full_metatags_for_term);
    } elseif (is_author()) {
        // User specific full meta tags ($post is a user object)
        $full_metatags_for_user = amt_get_user_meta_full_metatags($post->ID);
        $full_metatags_for_user = html_entity_decode(stripslashes($full_metatags_for_user));
        $full_metatags_as_string .= apply_filters('amt_full_metatags_term', $full_metatags_for_user);
    }
    // Sanitize
    //$full_metatags_as_string = esc_textarea( wp_kses( $full_metatags_as_string, amt_get_allowed_html_kses() ) );
    $full_metatags_as_string = wp_kses($full_metatags_as_string, amt_get_allowed_html_kses());
    // Make array of full meta tags
    $full_meta_tags = preg_split('#\\R#', $full_metatags_as_string, NULL, PREG_SPLIT_NO_EMPTY);
    // Process
    if (apply_filters('amt_full_metatags_processor_enable', true)) {
        // Store processed meta tags here
        $processed_full_meta_tags = array();
        // Field substitutions currently take place only on content pages.
        // TODO: See if this can be expanded to terms, authors.
        // Store the post's custom fields
        $custom_fields = null;
        // Store the post object's custom fields.
        //
        if (is_singular() || amt_is_static_front_page() || amt_is_static_home()) {
            // Get an array of all custom fields names of the post object.
            $custom_fields = get_post_custom_keys($post->ID);
        }
        // Iterate over full meta tags
        foreach ($full_meta_tags as $single_meta_tag) {
            // Note: Field value substitutions take place first, outside the elseif clauses.
            // Process substitutions of special notation with data from Custom Fields
            // Supported special notation:
            //   [field=Field Name]
            // Notes:
            // - 'Field Name' is the name of custom field.
            // - If the custom field with name 'Field Name' does not exist, the meta tag
            //   that contains it is omitted.
            // - If the value of the field is an empty string, then the substitution
            //   takes place normally.
            //
            // The regex pattern fo our special notation.
            $special_notation_pattern = '#(?:\\[field\\=)([^\\]]+)(?:\\])#';
            // The following covers content pages, as $custom_fields is only set on content pages. See above.
            if (!empty($custom_fields) && isset($post->ID)) {
                // This also assumes that we have a post object since custom fields
                // are set only on content pages, otherwise it is null.
                // Check for special notation
                if (preg_match($special_notation_pattern, $single_meta_tag, $matches)) {
                    //var_dump($matches);
                    // If the field name of the special notation does not match
                    // any custom field name, omit the meta tag as per the rules above.
                    if (!in_array($matches[1], $custom_fields)) {
                        continue;
                    }
                    // Since there is special notation and the field name from the special
                    // notation exists in the $custom_fields array, iterate over the available
                    // custom fields and perform the substitutions.
                    foreach ($custom_fields as $custom_field) {
                        // Check if it matches the field name of the special notation
//.........这里部分代码省略.........
开发者ID:ashenkar,项目名称:sanga,代码行数:101,代码来源:amt_basic.php

示例4: amt_add_twitter_cards_metadata_head

/**
 * Generate Twitter Cards metadata for the content pages.
 */
function amt_add_twitter_cards_metadata_head($post, $attachments, $embedded_media, $options)
{
    if (apply_filters('amt_exclude_twitter_cards_metadata', false)) {
        return array();
    }
    $do_auto_twitter = $options["auto_twitter"] == "1" ? true : false;
    if (!$do_auto_twitter) {
        return array();
    }
    $metadata_arr = array();
    // Custom content override
    if (amt_is_custom($post, $options)) {
        // Return metadata with:
        // add_filter( 'amt_custom_metadata_twitter_cards', '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_twitter_cards', $metadata_arr, $post, $options, $attachments, $embedded_media);
        return $metadata_arr;
    }
    // Front page and archives
    if (!is_singular() && !amt_is_static_home() && !amt_is_static_front_page() || amt_is_default_front_page() || is_category() || is_tag() || is_tax() || is_post_type_archive()) {
        // Note1: is_front_page() is used for the case in which a static page is used as the front page.
        // Note2: product groups should pass the is_tax() validation, so no need for
        // amt_is_product_group(). We do not support other product groups.
        // Default front page containing latest posts
        // Add a basic Twitter Card to the default home page that contains latest posts.
        // If static pages are used as the front page or the latest-posts page,
        // then they are treated as content and are processed below.
        if (amt_is_default_front_page()) {
            // Generate the card only if a publisher username has been set in the publisher settings
            if (!empty($options['social_main_twitter_publisher_username'])) {
                // Type
                $metadata_arr[] = '<meta name="twitter:card" content="' . amt_get_default_twitter_card_type($options) . '" />';
                // Creator
                $metadata_arr[] = '<meta name="twitter:creator" content="@' . esc_attr($options['social_main_twitter_publisher_username']) . '" />';
                // Publisher
                $metadata_arr[] = '<meta name="twitter:site" content="@' . esc_attr($options['social_main_twitter_publisher_username']) . '" />';
                // Title
                // Note: Contains multipage information
                $metadata_arr['twitter:title'] = '<meta name="twitter:title" content="' . esc_attr(amt_get_title_for_metadata($options, $post)) . '" />';
                // Site description - Note: Contains multipage information through amt_process_paged()
                $site_description = amt_get_site_description($options);
                if (empty($site_description)) {
                    $site_description = get_bloginfo('description');
                }
                if (!empty($site_description)) {
                    $metadata_arr[] = '<meta name="twitter:description" content="' . esc_attr(amt_process_paged($site_description)) . '" />';
                }
                // Image. Use the default image (if set).
                $image_data = amt_get_default_image_data();
                if (!empty($image_data)) {
                    $image_size = apply_filters('amt_image_size_index', 'full');
                    $image_meta_tags = amt_get_twitter_cards_image_metatags($options, $image_data, $size = $image_size);
                    if (!empty($image_meta_tags)) {
                        $metadata_arr = array_merge($metadata_arr, $image_meta_tags);
                    }
                }
                //$image_url = apply_filters( 'amt_twitter_cards_image_url_index', $options["default_image_url"] );
                //$metadata_arr[] = '<meta name="twitter:image" content="' . esc_url_raw( $image_url ) . '" />';
            }
            // Taxonomy archives
            // Note: product groups should pass the is_tax() validation, so no need for
            // amt_is_product_group(). We do not support other product groups.
        } elseif (is_category() || is_tag() || is_tax()) {
            // Taxonomy term object.
            // When viewing taxonomy archives, the $post object is the taxonomy term object. Check with: var_dump($post);
            $tax_term_object = $post;
            //var_dump($tax_term_object);
            // Generate the card only if a publisher username has been set in the publisher settings
            if (!empty($options['social_main_twitter_publisher_username'])) {
                // Type
                $metadata_arr[] = '<meta name="twitter:card" content="' . amt_get_default_twitter_card_type($options) . '" />';
                // Creator
                $metadata_arr[] = '<meta name="twitter:creator" content="@' . esc_attr($options['social_main_twitter_publisher_username']) . '" />';
                // Publisher
                $metadata_arr[] = '<meta name="twitter:site" content="@' . esc_attr($options['social_main_twitter_publisher_username']) . '" />';
                // Title
                // Note: Contains multipage information
                $metadata_arr['twitter:title'] = '<meta name="twitter:title" content="' . esc_attr(amt_get_title_for_metadata($options, $post)) . '" />';
                // Description
                // If set, the description of the custom taxonomy term is used in the 'description' metatag.
                // Otherwise, a generic description is used.
                // Here we sanitize the provided description for safety
                $description_content = sanitize_text_field(amt_sanitize_description(term_description($tax_term_object->term_id, $tax_term_object->taxonomy)));
                // Note: Contains multipage information through amt_process_paged()
                if (empty($description_content)) {
                    // Add a filtered generic description.
                    // Filter name
                    if (is_category()) {
                        $generic_description = apply_filters('amt_generic_description_category_archive', __('Content filed under the %s category.', 'add-meta-tags'));
                    } elseif (is_tag()) {
                        $generic_description = apply_filters('amt_generic_description_tag_archive', __('Content tagged with %s.', 'add-meta-tags'));
                    } elseif (is_tax()) {
                        // Construct the filter name. Template: ``amt_generic_description_TAXONOMYSLUG_archive``
                        $taxonomy_description_filter_name = sprintf('amt_generic_description_%s_archive', $tax_term_object->taxonomy);
                        // var_dump($taxonomy_description_filter_name);
                        // Generic description
                        $generic_description = apply_filters($taxonomy_description_filter_name, __('Content filed under the %s taxonomy.', 'add-meta-tags'));
//.........这里部分代码省略.........
开发者ID:prkirby,项目名称:AbsolutePressure,代码行数:101,代码来源:amt_twitter_cards.php

示例5: amt_custom_title_tag

/**
 * Replaces the text to be used in the title element, if a replacement text has been set.
 */
function amt_custom_title_tag($title)
{
    if (is_singular() || amt_is_static_front_page() || amt_is_static_home()) {
        // Get current post object
        $post = get_queried_object();
        if (is_null($post)) {
            return $title;
        }
        // Check if metadata is supported on this content type.
        $post_type = get_post_type($post);
        if (!in_array($post_type, amt_get_supported_post_types())) {
            return $title;
        }
        $custom_title = amt_get_post_meta_title($post->ID);
        if (!empty($custom_title)) {
            $custom_title = str_replace('%title%', $title, $custom_title);
            // Allow filtering of the custom title
            $custom_title = apply_filters('amt_custom_title', $custom_title);
            // Note: Contains multipage information through amt_process_paged()
            return esc_attr(amt_process_paged($custom_title));
        }
    }
    // WordPress adds multipage information if a custom title is not set.
    return $title;
}
开发者ID:rpi-virtuell,项目名称:wordpress-add-meta-tags,代码行数:28,代码来源:add-meta-tags.php

示例6: 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

示例7: amt_internal_get_title

function amt_internal_get_title($options, $post, $title_templates, $force_custom_title_if_set = false, $caller_is_metadata_generator = false)
{
    // EARLY PROCESSING
    // First we check for a custom title whgich may have been inserted in the
    // relevant Custom Field of the supported types.
    $custom_title = '';
    if (is_singular() || amt_is_static_front_page() || amt_is_static_home()) {
        if (!is_null($post)) {
            // Check if metadata is supported on this content type.
            $post_type = get_post_type($post);
            if (in_array($post_type, amt_get_supported_post_types())) {
                // Store the custom title. Should be empty for post types which do not support a custom title or which have an empty custom title.
                $custom_title = amt_get_post_meta_title($post->ID);
                //$custom_title = str_replace('%title%', $title, $custom_title);
                // Allow filtering of the custom title
                $custom_title = apply_filters('amt_custom_title', $custom_title);
            }
        }
    }
    // Early processing in case advanced title management is TURNED OFF
    // This early processing takes place only for calls from the 'amt_get_title_for_title_element()' function.
    // WordPress constructs its own titles for the 'title' HTML element, so we
    // do not need to do further processing and title guessing here.
    // This early processing is NOT performed for calls from the 'amt_get_title_for_metadata()' function,
    // because the metadata generators
    if (!$caller_is_metadata_generator && array_key_exists('enable_advanced_title_management', $options) && $options['enable_advanced_title_management'] == '0') {
        if (is_singular() || amt_is_static_front_page() || amt_is_static_home()) {
            if (!empty($custom_title)) {
                // Contains paging information
                return amt_process_paged($custom_title);
            }
        }
        return;
    }
    // From now on Add-Meta-Tags generates the title.
    // TEMPLATE VARIABLES
    // Set template variable values
    // #entity_title#, #Entity_title#, #Entity_Title#, #page#, #page_total#, #site_name#, #site_tagline#, #year#, #month#, #month_name#, #day#
    // Date variables
    // Credit for the following here: http://wordpress.stackexchange.com/a/109674
    // https://developer.wordpress.org/reference/classes/wp_locale/
    $var_year = 0;
    $var_month = 0;
    $var_month_name = '';
    $var_day = 0;
    if (is_date()) {
        // On date archives the following have a value. On the default front page are zero
        $var_year = get_query_var('year');
        $var_month = get_query_var('monthnum');
        $var_month_name = '';
        if ($var_month) {
            $var_month_name = $GLOBALS['wp_locale']->get_month($var_month);
        }
        $var_day = get_query_var('day');
    } elseif (is_singular() || amt_is_static_front_page() || amt_is_static_home()) {
        $var_year = mysql2date('Y', $post->post_date);
        $var_month = mysql2date('m', $post->post_date);
        $var_month_name = '';
        if ($var_month) {
            $var_month_name = $GLOBALS['wp_locale']->get_month($var_month);
        }
        $var_day = mysql2date('d', $post->post_date);
    }
    // #page_total#
    global $wp_query;
    $page_total = 1;
    if (isset($wp_query->max_num_pages)) {
        $page_total = $wp_query->max_num_pages;
    }
    // #page#
    $page = 1;
    // For paginated archives or paginated main page with latest posts.
    if (is_paged()) {
        $paged = get_query_var('paged');
        // paged
        if ($paged && $paged >= 2) {
            $page = $paged;
        }
        // For a Post or Page that has been divided into pages using the <!--nextpage--> QuickTag
    } else {
        $paged = get_query_var('page');
        // page
        if ($paged && $paged >= 2) {
            $page = $paged;
        }
    }
    // #site_name#
    $site_name = get_bloginfo('name');
    // #site_tagline#
    $site_tagline = get_bloginfo('description');
    // MAIN PROCESSING
    // 1) generate title, 2) determine title template
    // #entity_title# and $entity_title_template
    $entity_title = '';
    $entity_title_template = '';
    // Default front page displaying the latest posts
    if (amt_is_default_front_page()) {
        // Entity title
        // $post is NULL
        $entity_title = get_bloginfo('name');
//.........这里部分代码省略.........
开发者ID:ashenkar,项目名称:sanga,代码行数:101,代码来源:amt-utils.php


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