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


PHP amt_is_default_front_page函数代码示例

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


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

示例1: amt_add_jsonld_schemaorg_metadata_head

/**
 * Add Schema.org Microdata in the footer.
 *
 * Mainly used to embed microdata to front page, posts index page and archives.
 */
function amt_add_jsonld_schemaorg_metadata_head($post, $attachments, $embedded_media, $options)
{
    if (apply_filters('amt_exclude_schemaorg_metadata', false)) {
        return array();
    }
    $do_auto_schemaorg = $options["auto_schemaorg"] == "1" ? true : false;
    if (!$do_auto_schemaorg) {
        return array();
    }
    // Check if the microdata or the JSON-LD schema.org generator should be used.
    if ($options["schemaorg_force_jsonld"] == "0") {
        // Here we check for AMP page https://www.ampproject.org/
        // For AMP pages, if the Schema.org microdata generator has been enabled,
        // we enforce the JSON+LD form instead of microdata.
        if ($do_auto_schemaorg && function_exists('is_amp_endpoint') && is_amp_endpoint()) {
            // Do nothing and let it proceed with forced generation of JSON+LD Schema.org metadata.
        } else {
            return array();
        }
    }
    $metadata_arr = array();
    // Context
    $metadata_arr['@context'] = 'http://schema.org';
    // TODO: Check if this is_paged() check is needed. If removed, make sure that titles and descriptions are passed through multipage function.
    if (is_paged()) {
        //
        // Currently we do not support adding Schema.org metadata on
        // paged archives, if page number is >=2
        //
        // NOTE: This refers to an archive or the main page being split up over
        // several pages, this does not refer to a Post or Page whose content
        // has been divided into pages using the <!--nextpage--> QuickTag.
        //
        // Multipage content IS processed below.
        //
        return array();
    }
    // Custom content override
    if (amt_is_custom($post, $options)) {
        // Return metadata with:
        // add_filter( 'amt_custom_metadata_jsonld_schemaorg', '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_jsonld_schemaorg', $metadata_arr, $post, $options, $attachments, $embedded_media);
        // Default fron tpage displaying the latest posts.
    } elseif (amt_is_default_front_page()) {
        // On the front page we are adding two top level entities, so we remove
        // the existing context, as the entities need to be in an array and each
        // array item needs its own context.
        unset($metadata_arr['@context']);
        // Organization
        //
        // NOTICE:
        // Even if the front page has been set as the source of profile, this
        // this does not work with the default front page with the latest posts.
        // This is becuase this page does not have an author, which is essential
        // for the generated metadata on a page that is supposed to be a profile.
        // Therefore, an Organization object is always generated on the default
        // front page and it is never treated as a profile page by Add-Meta-Tags.
        //
        $organization_arr = array();
        // Context
        $organization_arr['@context'] = 'http://schema.org';
        // ID
        $organization_arr['@id'] = amt_get_schemaorg_entity_id('organization');
        $organization_arr = array_merge($organization_arr, amt_get_jsonld_schemaorg_publisher_array($options));
        // mainEntityOfPage
        $organization_arr['mainEntityOfPage'] = esc_url(trailingslashit(get_bloginfo('url')));
        // Get publisher/mainEntity metatags
        //        $metadata_arr = array_merge( $metadata_arr, amt_get_schemaorg_publisher_metatags( $options ) );
        // WebSite
        $website_arr = array();
        // Context
        $website_arr['@context'] = 'http://schema.org';
        // ID
        $website_arr['@id'] = amt_get_schemaorg_entity_id('website');
        // Type
        $website_arr['@type'] = 'WebSite';
        // name
        $website_arr['name'] = esc_attr(get_bloginfo('name'));
        // headline - contains title information
        $website_arr['headline'] = esc_attr(amt_get_title_for_metadata($options, $post));
        // alternateName (The WordPress tag line is used.)
        // TODO: use tag line. Needs feedback!
        // url
        $website_arr['url'] = esc_url_raw(trailingslashit(get_bloginfo('url')));
        // publisher
        //        $website_arr['publisher'] = array( '@id' => esc_attr(amt_get_schemaorg_entity_id('organization') ) );
        // SearchAction
        // Scope BEGIN: SearchAction: http://schema.org/SearchAction
        //        $metadata_arr[] = '<!-- Scope BEGIN: SearchAction -->';
        //        $metadata_arr[] = '<span itemprop="potentialAction" itemscope itemtype="http://schema.org/SearchAction">';
        $website_arr['potentialAction'] = array();
        $website_arr['potentialAction']['@type'] = 'SearchAction';
        // target
        // Scope BEGIN: EntryPoint: http://schema.org/EntryPoint
//.........这里部分代码省略.........
开发者ID:ashenkar,项目名称:sanga,代码行数:101,代码来源:amt_schemaorg.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_opengraph_metadata_head

/**
 * Generates Opengraph metadata.
 *
 * Currently for:
 * - home page
 * - author archive
 * - content
 */
function amt_add_opengraph_metadata_head($post, $attachments, $embedded_media, $options)
{
    if (apply_filters('amt_exclude_opengraph_metadata', false)) {
        return array();
    }
    $do_auto_opengraph = $options["auto_opengraph"] == "1" ? true : false;
    if (!$do_auto_opengraph) {
        return array();
    }
    $metadata_arr = array();
    // fb:app_id & fb:admins
    // We currently let users add the full meta tags for fb:app_id and fb:admins in the site wide meta tags box.
    // fb:app_id appears everywhere
    //if ( ! empty($options['social_main_facebook_app_id']) ) {
    //    $metadata_arr[] = '<meta property="fb:app_id" content="' . esc_attr( $options['social_main_facebook_app_id'] ) . '" />';
    //}
    // fb:admins appear everywhere
    //if ( ! empty($options['social_main_facebook_admins']) ) {
    //    $fb_admins_arr = explode(',', $options['social_main_facebook_admins']);
    //    foreach ( $fb_admins_arr as $fb_admin ) {
    //        $metadata_arr[] = '<meta property="fb:admins" content="' . esc_attr( trim($fb_admin) ) . '" />';
    //    }
    //}
    // no publisher meta tag for facebook, unless it is content
    // Custom content override
    if (amt_is_custom($post, $options)) {
        // Return metadata with:
        // add_filter( 'amt_custom_metadata_opengraph', '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_opengraph', $metadata_arr, $post, $options, $attachments, $embedded_media);
        // Default front page displaying the latest posts
    } elseif (amt_is_default_front_page()) {
        // 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(trailingslashit(get_bloginfo('url'))) . '" />';
        }
        // 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 property="og:description" content="' . esc_attr(amt_process_paged($site_description)) . '" />';
        }
        // Locale
        $metadata_arr[] = '<meta property="og:locale" content="' . esc_attr(str_replace('-', '_', amt_get_language_site($options))) . '" />';
        // Site Image
        // 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);
            }
        }
        // Front page using a static page
        // Note: might also contain a listing of posts which may be paged, so use amt_process_paged()
    } elseif (amt_is_static_front_page()) {
        // Type
        if ($options['author_profile_source'] == 'frontpage') {
            // The front page is treated as the profile page.
            $metadata_arr[] = '<meta property="og:type" content="profile" />';
        } else {
            $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(trailingslashit(get_bloginfo('url'))) . '" />';
        }
        // 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 the blog's description
            $metadata_arr[] = '<meta property="og:description" content="' . esc_attr(amt_process_paged(get_bloginfo('description'))) . '" />';
//.........这里部分代码省略.........
开发者ID:pytong,项目名称:research-group,代码行数:101,代码来源:amt_opengraph.php

示例4: amt_add_basic_metadata_head


//.........这里部分代码省略.........
    } else {
        $robots_options = array_unique($robots_options, SORT_STRING);
    }
    if (!empty($robots_options)) {
        $metadata_arr['basic:robots'] = '<meta name="robots" content="' . esc_attr(implode(',', $robots_options)) . '" />';
    }
    // Add full meta tags
    // Merge meta tags
    $processed_full_meta_tags = apply_filters('amt_full_metatags_processed', $processed_full_meta_tags);
    if (!empty($processed_full_meta_tags)) {
        $metadata_arr = array_merge($metadata_arr, $processed_full_meta_tags);
    }
    // Add copyright link
    // On every page print the copyright head link
    $copyright_url = amt_get_site_copyright_url($options);
    //if ( empty($copyright_url)) {
    //    $copyright_url = trailingslashit( get_bloginfo('url') );
    //}
    if (!empty($copyright_url)) {
        $metadata_arr['basic:copyright'] = '<link rel="copyright" type="text/html" title="' . esc_attr(get_bloginfo('name')) . ' ' . __('copyright information', 'add-meta-tags') . '" href="' . esc_url($copyright_url) . '" />';
    }
    // hreflang link element
    // This section also expects an array of extra hreflang links that may have
    // been collected from the full meta tags boxes.
    if ($options['generate_hreflang_links'] == '1') {
        if (is_singular()) {
            $locale = amt_get_language_content($options, $post);
            $hreflang = amt_get_the_hreflang($locale, $options);
            $hreflang_url = amt_get_permalink_for_multipage($post);
        } else {
            $locale = amt_get_language_site($options);
            $hreflang = amt_get_the_hreflang($locale, $options);
            $hreflang_url = '';
            if (amt_is_default_front_page()) {
                $hreflang_url = trailingslashit(get_bloginfo('url'));
            } elseif (is_category() || is_tag() || is_tax()) {
                // $post is a term object
                $hreflang_url = get_term_link($post);
            } elseif (is_author()) {
                // $post is an author object
                $hreflang_url = get_author_posts_url($post->ID);
            } elseif (is_year()) {
                $archive_year = get_the_time('Y');
                $hreflang_url = get_year_link($archive_year);
            } elseif (is_month()) {
                $archive_year = get_the_time('Y');
                $archive_month = get_the_time('m');
                $hreflang_url = get_month_link($archive_year, $archive_month);
            } elseif (is_day()) {
                $archive_year = get_the_time('Y');
                $archive_month = get_the_time('m');
                $archive_day = get_the_time('d');
                $hreflang_url = get_day_link($archive_year, $archive_month, $archive_day);
            }
            // If paged information is available
            if (is_paged()) {
                //$hreflang_url = trailingslashit( $hreflang_url ) . get_query_var('paged') . '/';
                $hreflang_url = get_pagenum_link(get_query_var('paged'));
            }
        }
        // hreflang links array
        $hreflang_arr = array();
        // Add link element
        if (!empty($hreflang) && !empty($hreflang_url)) {
            $hreflang_arr[] = '<link rel="alternate" hreflang="' . esc_attr($hreflang) . '" href="' . esc_url_raw($hreflang_url) . '" />';
        }
开发者ID:ashenkar,项目名称:sanga,代码行数:67,代码来源:amt_basic.php

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

示例6: amt_get_metadata_footer

/**
 * Returns an array of all the generated metadata for the footer area.
 */
function amt_get_metadata_footer()
{
    // Get the options the DB
    $options = get_option("add_meta_tags_opts");
    $do_add_metadata = true;
    $metadata_arr = array();
    // Get current post object
    $post = get_queried_object();
    if (is_null($post)) {
        // Allow metadata on the default front page (latest posts).
        // A post object is not available on that page, but we still need to
        // generate metadata for it. A $post object exists for the "front page"
        // and the "posts page" when static pages are used. No allow rule needed.
        if (!amt_is_default_front_page()) {
            $do_add_metadata = false;
        }
    } elseif (is_singular()) {
        // The post type check should only take place on content pages.
        // Check if metadata should be added to this content type.
        $post_type = get_post_type($post);
        if (!in_array($post_type, amt_get_supported_post_types())) {
            $do_add_metadata = false;
        }
    }
    // Add Metadata
    if ($do_add_metadata) {
        // Attachments and embedded media are collected only on content pages.
        if (is_singular()) {
            // Get an array containing the attachments
            $attachments = amt_get_ordered_attachments($post);
            //var_dump($attachments);
            // Get an array containing the URLs of the embedded media
            $embedded_media = amt_get_embedded_media($post);
            //var_dump($embedded_media);
        } else {
            $attachments = array();
            $embedded_media = array();
        }
        // Add Schema.org Microdata
        $metadata_arr = array_merge($metadata_arr, amt_add_schemaorg_metadata_footer($post, $attachments, $embedded_media, $options));
    }
    // Allow filtering of all the generated metatags
    $metadata_arr = apply_filters('amt_metadata_footer', $metadata_arr);
    // Add our comment
    if (count($metadata_arr) > 0) {
        array_unshift($metadata_arr, "<!-- BEGIN Metadata added by Add-Meta-Tags WordPress plugin -->");
        array_push($metadata_arr, "<!-- END Metadata added by Add-Meta-Tags WordPress plugin -->");
    }
    return $metadata_arr;
}
开发者ID:rpi-virtuell,项目名称:wordpress-add-meta-tags,代码行数:53,代码来源:add-meta-tags.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_default_front_page函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。