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


PHP amt_process_paged函数代码示例

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


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

示例1: amt_add_jsonld_schemaorg_metadata_head


//.........这里部分代码省略.........
        // Also, ``get_the_author_meta('....', $author)`` returns nothing under author archives.
        // Access user meta with:  $author->description, $author->user_email, etc
        // $author = get_queried_object();
        $author = $post;
        // Person
        // Scope BEGIN: Person: http://schema.org/Person
        //        $metadata_arr[] = '<!-- Scope BEGIN: Person -->';
        //        $metadata_arr[] = '<span itemscope itemtype="http://schema.org/Person"' . amt_get_schemaorg_itemref('person_author') . '>';
        $metadata_arr['@type'] = 'Person';
        // headline - contains title information
        // NOTE: Not supported for person
        //$metadata_arr['headline'] = esc_attr( amt_get_title_for_metadata($options, $author) );
        // Get author metatags
        //        $metadata_arr = array_merge( $metadata_arr, amt_get_schemaorg_author_metatags( $author->ID, $options ) );
        $metadata_arr = array_merge($metadata_arr, amt_get_jsonld_schemaorg_author_array($author->ID, $options));
        // mainEntityOfPage
        $metadata_arr['mainEntityOfPage'] = esc_url(get_author_posts_url($author->ID));
        // Scope END: Person
        //        $metadata_arr[] = '</span> <!-- Scope END: Person -->';
    } elseif (amt_is_product()) {
        // Scope BEGIN: Product: http://schema.org/Product
        //        $metadata_arr[] = '<!-- Scope BEGIN: Product -->';
        //        $metadata_arr[] = '<div itemscope itemtype="http://schema.org/Product"' . amt_get_schemaorg_itemref('product') . '>';
        // Schema.org type
        $metadata_arr['@type'] = 'Product';
        // ID
        $metadata_arr['@id'] = amt_get_schemaorg_entity_id('product');
        // URL - Uses amt_get_permalink_for_multipage()
        $metadata_arr['url'] = esc_url_raw(amt_get_permalink_for_multipage($post));
        // mainEntityOfPage
        $metadata_arr['mainEntityOfPage'] = esc_url(amt_get_permalink_for_multipage($post));
        // name
        // Note: Contains multipage information through amt_process_paged()
        $metadata_arr['name'] = esc_attr(amt_process_paged(strip_tags(get_the_title($post->ID))));
        // headline - contains title information
        //$metadata_arr['headline'] = esc_attr( amt_get_title_for_metadata($options, $post) );
        // Description - We use the description defined by Add-Meta-Tags
        // Note: Contains multipage information through amt_process_paged()
        $content_desc = amt_get_content_description($post);
        //if ( empty($content_desc) ) {
        //    // Use the post body as the description. Product objects do not support body text.
        //    // TODO: ERROR here $post_body var does not exist
        //    $content_desc = sanitize_text_field( amt_sanitize_description( $post_body ) );
        //}
        if (!empty($content_desc)) {
            $metadata_arr['description'] = esc_attr(amt_process_paged($content_desc));
        }
        // Dates
        $metadata_arr['releaseDate'] = esc_attr(amt_iso8601_date($post->post_date));
        // Images
        $metadata_arr['image'] = array();
        // 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_data(amt_get_post_meta_image_url($post->ID));
        if (!empty($image_data)) {
            $image_size = apply_filters('amt_image_size_product', 'full');
            $image_meta_array = amt_get_jsonld_schemaorg_image_array($options, $image_data, $size = $image_size);
            if (!empty($image_meta_array)) {
                $metadata_arr['image'] = array();
                $metadata_arr['image'][] = $image_meta_array;
            }
            //$global_image_override_url = amt_get_post_meta_image_url($post->ID);
            //if ( ! empty( $global_image_override_url ) ) {
            //            $metadata_arr[] = '<!-- Scope BEGIN: ImageObject -->';
            //            $metadata_arr[] = '<span itemprop="image" itemscope itemtype="http://schema.org/ImageObject">';
            //   $current_image_obj = array();
开发者ID:ashenkar,项目名称:sanga,代码行数:67,代码来源: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_basic_metadata_head


//.........这里部分代码省略.........
        // Allow filtering of the hreflang array
        $hreflang_arr = apply_filters('amt_hreflang_links', $hreflang_arr);
        // Add to to metadata array
        foreach ($hreflang_arr as $hreflang_link) {
            if (preg_match('# hreflang="([^"]+)" #', $hreflang_link, $matches)) {
                $metadata_arr['basic:hreflang:' . $matches[1]] = $hreflang_link;
            }
        }
    }
    // Basic Meta Tags
    // Custom content override
    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()) {
开发者ID:ashenkar,项目名称:sanga,代码行数:67,代码来源:amt_basic.php

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

示例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_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

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

示例8: amt_add_dublin_core_metadata_head

function amt_add_dublin_core_metadata_head($post, $attachments, $embedded_media, $options)
{
    if (apply_filters('amt_exclude_dublin_core_metadata', false)) {
        return array();
    }
    $metadata_arr = array();
    $do_auto_dublincore = $options["auto_dublincore"] == "1" ? true : false;
    if (!$do_auto_dublincore) {
        return $metadata_arr;
    }
    // Custom content override
    if (amt_is_custom($post, $options)) {
        // Return metadata with:
        // add_filter( 'amt_custom_metadata_dublin_core', '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_dublin_core', $metadata_arr, $post, $options, $attachments, $embedded_media);
        return $metadata_arr;
    }
    if (!is_singular() || is_front_page()) {
        // is_front_page() is used for the case in which a static page is used as the front page.
        // Dublin Core metadata has a meaning for content only.
        return array();
    }
    // The Dublin Core metadata generator does not support products or product groups.
    if (amt_is_product() || amt_is_product_group()) {
        return array();
    }
    // Title
    // Note: Contains multipage information through amt_process_paged()
    $metadata_arr['dcterms.title'] = '<meta name="dcterms.title" content="' . esc_attr(amt_get_title_for_metadata($options, $post)) . '" />';
    // Resource identifier - Uses amt_get_permalink_for_multipage()
    $metadata_arr[] = '<meta name="dcterms.identifier" content="' . esc_url_raw(amt_get_permalink_for_multipage($post)) . '" />';
    $metadata_arr[] = '<meta name="dcterms.creator" content="' . esc_attr(amt_get_dublin_core_author_notation($post)) . '" />';
    //$metadata_arr[] = '<meta name="dcterms.date" content="' . esc_attr( amt_iso8601_date($post->post_date) ) . '" />';
    $metadata_arr[] = '<meta name="dcterms.created" content="' . esc_attr(amt_iso8601_date($post->post_date)) . '" />';
    $metadata_arr[] = '<meta name="dcterms.available" content="' . esc_attr(amt_iso8601_date($post->post_date)) . '" />';
    //$metadata_arr[] = '<meta name="dcterms.issued" content="' . esc_attr( amt_iso8601_date($post->post_date) ) . '" />';
    $metadata_arr[] = '<meta name="dcterms.modified" content="' . esc_attr(amt_iso8601_date($post->post_modified)) . '" />';
    // Description
    // We use the same description as the ``description`` meta tag.
    // Note: Contains multipage information through amt_process_paged()
    $content_desc = amt_get_content_description($post);
    if (!empty($content_desc)) {
        $metadata_arr[] = '<meta name="dcterms.description" content="' . esc_attr(amt_process_paged($content_desc)) . '" />';
    }
    // Keywords
    if (!is_attachment()) {
        // Attachments do not support keywords
        // dcterms.subject - one for each keyword.
        $keywords = explode(',', amt_get_content_keywords($post));
        foreach ($keywords as $subject) {
            $subject = trim($subject);
            if (!empty($subject)) {
                $metadata_arr[] = '<meta name="dcterms.subject" content="' . esc_attr($subject) . '" />';
            }
        }
    }
    $metadata_arr[] = '<meta name="dcterms.language" content="' . esc_attr(amt_get_language_content($options, $post)) . '" />';
    $metadata_arr[] = '<meta name="dcterms.publisher" content="' . esc_url_raw(trailingslashit(get_bloginfo('url'))) . '" />';
    // Copyright page
    $copyright_url = amt_get_site_copyright_url($options);
    if (empty($copyright_url)) {
        $copyright_url = trailingslashit(get_bloginfo('url'));
    }
    if (!empty($copyright_url)) {
        $metadata_arr[] = '<meta name="dcterms.rights" content="' . esc_url_raw($copyright_url) . '" />';
    }
    // License
    $license_url = '';
    // The following requires creative commons configurator
    if (function_exists('bccl_get_license_url')) {
        $license_url = bccl_get_license_url();
    }
    // Allow filtering of the license URL
    $license_url = apply_filters('amt_dublin_core_license', $license_url, $post->ID);
    // Add metatag if $license_url is not empty.
    if (!empty($license_url)) {
        $metadata_arr[] = '<meta name="dcterms.license" content="' . esc_url_raw($license_url) . '" />';
    }
    // Coverage
    $metadata_arr[] = '<meta name="dcterms.coverage" content="World" />';
    if (is_attachment()) {
        $mime_type = get_post_mime_type($post->ID);
        //$attachment_type = strstr( $mime_type, '/', true );
        // See why we do not use strstr(): http://www.codetrax.org/issues/1091
        $attachment_type = preg_replace('#\\/[^\\/]*$#', '', $mime_type);
        $metadata_arr[] = '<meta name="dcterms.isPartOf" content="' . esc_url_raw(get_permalink($post->post_parent)) . '" />';
        if ('image' == $attachment_type) {
            $metadata_arr[] = '<meta name="dcterms.type" content="Image" />';
            $metadata_arr[] = '<meta name="dcterms.format" content="' . $mime_type . '" />';
        } elseif ('video' == $attachment_type) {
            $metadata_arr[] = '<meta name="dcterms.type" content="MovingImage" />';
            $metadata_arr[] = '<meta name="dcterms.format" content="' . $mime_type . '" />';
        } elseif ('audio' == $attachment_type) {
            $metadata_arr[] = '<meta name="dcterms.type" content="Sound" />';
            $metadata_arr[] = '<meta name="dcterms.format" content="' . $mime_type . '" />';
        }
        // Finally add the hasFormat
        $metadata_arr[] = '<meta name="dcterms.hasFormat" content="' . esc_url_raw(wp_get_attachment_url($post->ID)) . '" />';
    } else {
//.........这里部分代码省略.........
开发者ID:pytong,项目名称:research-group,代码行数:101,代码来源:amt_dublin_core.php

示例9: amt_add_schemaorg_metadata_content_filter

/**
 * Filter function that generates and embeds Schema.org metadata in the content.
 */
function amt_add_schemaorg_metadata_content_filter($post_body)
{
    if (is_feed()) {
        return $post_body;
    }
    if (!is_singular() || is_front_page()) {
        // is_front_page() is used for the case in which a static page is used as the front page.
        // In this filter function we only deal with content and attachments.
        return $post_body;
    }
    // Get the options the DB
    $options = get_option("add_meta_tags_opts");
    $do_auto_schemaorg = $options["auto_schemaorg"] == "1" ? true : false;
    if (!$do_auto_schemaorg) {
        return $post_body;
    }
    // Get current post object
    $post = get_queried_object();
    $metadata_arr = array();
    // Since this is a function that is hooked to the 'the_content' filter
    // of WordPress, the post type check has not run, so this happens here.
    // 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 $post_body;
    }
    // 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);
    // Products
    if (amt_is_product()) {
        // Scope BEGIN: Product: http://schema.org/Product
        $metadata_arr[] = '<!-- Scope BEGIN: Product -->';
        // Construct itemref attribute. Should contain a comma delimited list of IDs.
        $itemref = apply_filters('amt_schemaorg_itemref_product', '');
        if (!empty($itemref)) {
            $itemref_attrib = ' itemref="' . $itemref . '"';
        } else {
            $itemref_attrib = '';
        }
        $metadata_arr[] = '<div itemscope itemtype="http://schema.org/Product"' . $itemref_attrib . '>';
        // URL - Uses amt_get_permalink_for_multipage()
        $metadata_arr[] = '<meta itemprop="url" content="' . esc_url_raw(amt_get_permalink_for_multipage($post)) . '" />';
        // name
        // Note: Contains multipage information through amt_process_paged()
        $metadata_arr[] = '<meta itemprop="name" content="' . esc_attr(amt_process_paged(get_the_title($post->ID))) . '" />';
        // Description - We use the description defined by Add-Meta-Tags
        // Note: Contains multipage information through amt_process_paged()
        $content_desc = amt_get_content_description($post);
        if (empty($content_desc)) {
            // Use the post body as the description. Product objects do not support body text.
            $content_desc = sanitize_text_field(amt_sanitize_description($post_body));
        }
        if (!empty($content_desc)) {
            $metadata_arr[] = '<meta itemprop="description" content="' . esc_attr(amt_process_paged($content_desc)) . '" />';
        }
        // Dates
        $metadata_arr[] = '<meta itemprop="releaseDate" content="' . esc_attr(amt_iso8601_date($post->post_date)) . '" />';
        // Images
        // First check if a global image override URL has been entered.
        // If yes, use this image URL and override all other images.
        $global_image_override_url = amt_get_post_meta_image_url($post->ID);
        if (!empty($global_image_override_url)) {
            $metadata_arr[] = '<!-- Scope BEGIN: ImageObject -->';
            $metadata_arr[] = '<span itemprop="image" itemscope itemtype="http://schema.org/ImageObject">';
            $metadata_arr[] = '<meta itemprop="contentUrl" content="' . esc_url_raw($global_image_override_url) . '" />';
            $metadata_arr[] = '</span> <!-- Scope END: ImageObject -->';
            // Further image processing
        } else {
            // Set to true if any image attachments are found. Use to finally add the default image
            // if no image attachments have been found.
            $has_images = false;
            // Scope BEGIN: ImageObject: http://schema.org/ImageObject
            // Image - Featured image is checked first, so that it can be the first associated image.
            if (function_exists('has_post_thumbnail') && has_post_thumbnail($post->ID)) {
                // Get the image attachment object
                $image = get_post(get_post_thumbnail_id($post->ID));
                // metadata BEGIN
                $metadata_arr[] = '<!-- Scope BEGIN: ImageObject -->';
                $metadata_arr[] = '<span itemprop="image" itemscope itemtype="http://schema.org/ImageObject">';
                // Allow filtering of the image size.
                $image_size = apply_filters('amt_image_size_product', 'full');
                // Get image metatags.
                $metadata_arr = array_merge($metadata_arr, amt_get_schemaorg_image_metatags($image, $size = $image_size));
                // metadata END
                $metadata_arr[] = '</span> <!-- Scope END: ImageObject -->';
                // Images have been found.
                $has_images = true;
            }
            // Scope END: ImageObject
            // If no images have been found so far use the default image, if set.
            // Scope BEGIN: ImageObject: http://schema.org/ImageObject
            if ($has_images === false && !empty($options["default_image_url"])) {
                $metadata_arr[] = '<!-- Scope BEGIN: ImageObject -->';
//.........这里部分代码省略.........
开发者ID:rpi-virtuell,项目名称:wordpress-add-meta-tags,代码行数:101,代码来源:amt_schemaorg.php


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