本文整理汇总了PHP中amt_get_site_description函数的典型用法代码示例。如果您正苦于以下问题:PHP amt_get_site_description函数的具体用法?PHP amt_get_site_description怎么用?PHP amt_get_site_description使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了amt_get_site_description函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: amt_add_basic_metadata_head
/**
* Generates basic metadata for the head area.
*
*/
function amt_add_basic_metadata_head($post, $attachments, $embedded_media, $options)
{
$do_description = $options["auto_description"] == "1" ? true : false;
$do_keywords = $options["auto_keywords"] == "1" ? true : false;
$do_noodp_description = $options["noodp_description"] == "1" ? true : false;
// Array to store metadata
$metadata_arr = array();
// Robots Meta Tag.
$robots_content = '';
if ($do_noodp_description && (is_front_page() || is_singular())) {
// Add NOODP on posts and pages
$robots_content = 'NOODP,NOYDIR';
// Allow filtering of the robots meta tag content.
$robots_content = apply_filters('amt_robots_data', $robots_content);
}
// Add a robots meta tag if its content is not empty.
if (!empty($robots_content)) {
$metadata_arr[] = '<meta name="robots" content="' . $robots_content . '" />';
}
// hreflang link element
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) . '" />';
}
// Allow filtering of the hreflang array
$hreflang_arr = apply_filters('amt_hreflang_links', $hreflang_arr, $hreflang, $hreflang_url);
// Add to to metadata array
foreach ($hreflang_arr as $hreflang_link) {
$metadata_arr[] = $hreflang_link;
}
}
// Basic Meta Tags
// 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 = 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[] = '<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)) {
//.........这里部分代码省略.........
示例2: amt_options_page
//.........这里部分代码省略.........
*/
print '
<tr valign="top">
<th scope="row">' . __('Front Page Metadata', 'add-meta-tags') . '</th>
<td>
<fieldset>
<legend class="screen-reader-text"><span>' . __('Front Page Metadata', 'add-meta-tags') . '</span></legend>
' . __('It appears that you use static pages on the <em>front page</em> and the <em>latest posts page</em> of this web site. Please visit the editing panel of these pages and set the <code>description</code> and the <code>keywords</code> meta tags in the relevant Metadata box.', 'add-meta-tags') . '
';
print '<ul>';
$front_page_id = get_option('page_on_front');
if (intval($front_page_id) > 0) {
printf('<li>» ' . __('Edit the <a href="%s">front page</a>', 'add-meta-tags') . '</li>', get_edit_post_link(intval($front_page_id)));
}
$posts_page_id = get_option('page_for_posts');
if (intval($posts_page_id) > 0) {
printf('<li>» ' . __('Edit the <a href="%s">posts page</a>', 'add-meta-tags') . '</li>', get_edit_post_link(intval($posts_page_id)));
}
print '</ul>';
print '
</fieldset>
</td>
</tr>
';
} else {
print '
<tr valign="top">
<th scope="row">' . __('Front Page Description', 'add-meta-tags') . '</th>
<td>
<fieldset>
<legend class="screen-reader-text"><span>' . __('Front Page Description', 'add-meta-tags') . '</span></legend>
<textarea name="site_description" id="site_description" cols="100" rows="2" class="code">' . esc_attr(stripslashes(amt_get_site_description($options))) . '</textarea>
<br />
<label for="site_description">
' . __('Enter a short description of your web site.', 'add-meta-tags') . '
</label>
<br />
</fieldset>
</td>
</tr>
<tr valign="top">
<th scope="row">' . __('Front Page Keywords', 'add-meta-tags') . '</th>
<td>
<fieldset>
<legend class="screen-reader-text"><span>' . __('Front Page Keywords', 'add-meta-tags') . '</span></legend>
<textarea name="site_keywords" id="site_keywords" cols="100" rows="2" class="code">' . esc_attr(stripslashes(amt_get_site_keywords($options))) . '</textarea>
<br />
<label for="site_keywords">' . __('Enter a comma-delimited list of keywords for your web site.', 'add-meta-tags') . '</label>
<br />
</fieldset>
</td>
</tr>
';
}
print '
<tr valign="top">
<th scope="row">' . __('Global Keywords', 'add-meta-tags') . '</th>
<td>
<fieldset>
<legend class="screen-reader-text"><span>' . __('Global Keywords', 'add-meta-tags') . '</span></legend>
<textarea name="global_keywords" id="global_keywords" cols="100" rows="2" class="code">' . esc_attr(stripslashes(amt_get_site_global_keywords($options))) . '</textarea>
示例3: amt_options_page
//.........这里部分代码省略.........
*/
print '
<tr valign="top">
<th scope="row">' . __('Front Page Metadata', 'add-meta-tags') . '</th>
<td>
<fieldset>
<legend class="screen-reader-text"><span>' . __('Front Page Metadata', 'add-meta-tags') . '</span></legend>
' . __('It appears that you use static pages on the <em>front page</em> and the <em>latest posts page</em> of this web site. Please visit the editing panel of these pages and set the <code>description</code> and the <code>keywords</code> meta tags in the relevant Metadata box.', 'add-meta-tags') . '
';
print '<ul>';
$front_page_id = get_option('page_on_front');
if (intval($front_page_id) > 0) {
printf('<li>» ' . __('Edit the <a href="%s">front page</a>', 'add-meta-tags') . '</li>', get_edit_post_link(intval($front_page_id)));
}
$posts_page_id = get_option('page_for_posts');
if (intval($posts_page_id) > 0) {
printf('<li>» ' . __('Edit the <a href="%s">posts page</a>', 'add-meta-tags') . '</li>', get_edit_post_link(intval($posts_page_id)));
}
print '</ul>';
print '
</fieldset>
</td>
</tr>
';
} else {
print '
<tr valign="top">
<th scope="row">' . __('Front Page Description', 'add-meta-tags') . '</th>
<td>
<fieldset>
<legend class="screen-reader-text"><span>' . __('Front Page Description', 'add-meta-tags') . '</span></legend>
<textarea name="site_description" id="site_description" cols="100" rows="2" class="code">' . esc_attr(stripslashes(amt_get_site_description($options))) . '</textarea>
<br />
<label for="site_description">
' . __('Enter a short description of your blog (150-250 characters).', 'add-meta-tags') . '
</label>
<br />
</fieldset>
</td>
</tr>
<tr valign="top">
<th scope="row">' . __('Front Page Keywords', 'add-meta-tags') . '</th>
<td>
<fieldset>
<legend class="screen-reader-text"><span>' . __('Front Page Keywords', 'add-meta-tags') . '</span></legend>
<textarea name="site_keywords" id="site_keywords" cols="100" rows="2" class="code">' . esc_attr(stripslashes(amt_get_site_keywords($options))) . '</textarea>
<br />
<label for="site_keywords">' . __('Enter a comma-delimited list of keywords for your blog.', 'add-meta-tags') . '</label>
<br />
</fieldset>
</td>
</tr>
';
}
print '
<tr valign="top">
<th scope="row">' . __('Global Keywords', 'add-meta-tags') . '</th>
<td>
<fieldset>
<legend class="screen-reader-text"><span>' . __('Global Keywords', 'add-meta-tags') . '</span></legend>
<textarea name="global_keywords" id="global_keywords" cols="100" rows="2" class="code">' . esc_attr(stripslashes(amt_get_site_global_keywords($options))) . '</textarea>
示例4: amt_get_jsonld_schemaorg_publisher_array
/**
* Return an array of Schema.org metatags suitable for the publisher object of
* the content. Accepts the $post object as argument.
*/
function amt_get_jsonld_schemaorg_publisher_array($options, $author_id = null)
{
$metadata_arr = array();
// Schema.org type
$metadata_arr['@type'] = 'Organization';
// name
$metadata_arr['name'] = esc_attr(get_bloginfo('name'));
// description
// First use the site description from the Add-Meta-Tags settings
$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 (!empty($site_description)) {
$metadata_arr['description'] = esc_attr($site_description);
}
// logo
$image_data = amt_get_default_image_data();
if (!empty($image_data)) {
$image_size = apply_filters('amt_image_size_content', 'full');
$image_meta_array = amt_get_jsonld_schemaorg_image_array($options, $image_data, $size = $image_size);
if (!empty($image_meta_array)) {
$metadata_arr['logo'] = array();
$logo_obj = array();
// Type
$logo_obj['@type'] = 'ImageObject';
// name (title)
$logo_obj['name'] = esc_attr(get_bloginfo('name')) . ' ' . __('logo', 'add-meta-tags');
// caption
//$logo_obj['caption'] = esc_attr( rtrim(get_bloginfo('description'), '.') ) . '.';
// alt
$logo_obj['text'] = esc_attr(get_bloginfo('name')) . ' ' . __('logo', 'add-meta-tags');
// Image URL & attributes
$logo_obj = array_merge($logo_obj, $image_meta_array);
// URL (links to web page containing the image)
//$logo_obj['url'] = esc_url( $options["default_image_url"] );
// thumbnail url
//$logo_obj['thumbnailUrl'] = esc_url( ... );
// main image
//$logo_obj['contentUrl'] = esc_url( $options["default_image_url"] );
//if ( apply_filters( 'amt_extended_image_tags', true ) ) {
// $metadata_arr[] = '<meta itemprop="width" content="' . esc_attr( $embedded_item['width'] ) . '" />';
// $metadata_arr[] = '<meta itemprop="height" content="' . esc_attr( $embedded_item['height'] ) . '" />';
// $metadata_arr[] = '<meta itemprop="encodingFormat" content="image/jpeg" />';
//}
// Add logo entity to metadata
$metadata_arr['logo'][] = $logo_obj;
}
}
////if ( ! empty($options["default_image_url"]) ) {
////$metadata_arr['logo'] = array();
////$logo_obj = array();
// Type
////$logo_obj['@type'] = 'ImageObject';
// name (title)
////$logo_obj['name'] = esc_attr( get_bloginfo('name') ) . ' ' . __('logo', 'add-meta-tags');
// caption
//$logo_obj['caption'] = esc_attr( rtrim(get_bloginfo('description'), '.') ) . '.';
// alt
////$logo_obj['text'] = esc_attr( get_bloginfo('name') ) . ' ' . __('logo', 'add-meta-tags');
// URL (links to web page containing the image)
////$logo_obj['url'] = esc_url( $options["default_image_url"] );
// thumbnail url
//$logo_obj['thumbnailUrl'] = esc_url( ... );
// main image
////$logo_obj['contentUrl'] = esc_url( $options["default_image_url"] );
//if ( apply_filters( 'amt_extended_image_tags', true ) ) {
// $metadata_arr[] = '<meta itemprop="width" content="' . esc_attr( $embedded_item['width'] ) . '" />';
// $metadata_arr[] = '<meta itemprop="height" content="' . esc_attr( $embedded_item['height'] ) . '" />';
// $metadata_arr[] = '<meta itemprop="encodingFormat" content="image/jpeg" />';
//}
// Add logo entity to metadata
////$metadata_arr['logo'][] = $logo_obj;
////}
// url
// The blog url is used by default. Google+, Facebook and Twitter profile URLs are added as sameAs.
$metadata_arr['url'] = esc_url_raw(trailingslashit(get_bloginfo('url')));
// sameAs
$metadata_arr['sameAs'] = array();
// Social Profile Links are added as sameAs properties
// By default, those of the Publisher Settings are used.
// WARNING: Publisher profile URLs from the user profile page are now deprecated.
// Google+ Publisher
if (!empty($options['social_main_googleplus_publisher_profile_url'])) {
$metadata_arr['sameAs'][] = esc_url_raw($options['social_main_googleplus_publisher_profile_url'], array('http', 'https'));
}
// Facebook
if (!empty($options['social_main_facebook_publisher_profile_url'])) {
$metadata_arr['sameAs'][] = esc_url_raw($options['social_main_facebook_publisher_profile_url'], array('http', 'https'));
}
// Twitter
if (!empty($options['social_main_twitter_publisher_username'])) {
$metadata_arr['sameAs'][] = 'https://twitter.com/' . esc_attr($options['social_main_twitter_publisher_username']);
}
//.........这里部分代码省略.........
示例5: amt_options_page
//.........这里部分代码省略.........
*/
print '
<tr valign="top">
<th scope="row">' . __('Front Page Metadata', 'add-meta-tags') . '</th>
<td>
<fieldset>
<legend class="screen-reader-text"><span>' . __('Front Page Metadata', 'add-meta-tags') . '</span></legend>
' . __('It appears that you use static pages on the <em>front page</em> and the <em>latest posts page</em> of this web site. Please visit the editing panel of these pages and set the <code>description</code> and the <code>keywords</code> meta tags in the relevant Metadata box.', 'add-meta-tags') . '
';
print '<ul>';
$front_page_id = get_option('page_on_front');
if (intval($front_page_id) > 0) {
printf('<li>» ' . __('Edit the <a href="%s">front page</a>', 'add-meta-tags') . '</li>', get_edit_post_link(intval($front_page_id)));
}
$posts_page_id = get_option('page_for_posts');
if (intval($posts_page_id) > 0) {
printf('<li>» ' . __('Edit the <a href="%s">posts page</a>', 'add-meta-tags') . '</li>', get_edit_post_link(intval($posts_page_id)));
}
print '</ul>';
print '
</fieldset>
</td>
</tr>
';
} else {
print '
<tr valign="top">
<th scope="row">' . __('Front Page Description', 'add-meta-tags') . '</th>
<td>
<fieldset>
<legend class="screen-reader-text"><span>' . __('Front Page Description', 'add-meta-tags') . '</span></legend>
<textarea name="site_description" id="site_description" cols="100" rows="2" class="code">' . esc_attr(stripslashes(amt_get_site_description($options))) . '</textarea>
<br />
<label for="site_description">
' . __('Enter a short (150-250 characters long) description of your blog. This text will be used in the <em>description</em> and other similar metatags on the <strong>front page</strong>. If this is left empty, then the blog\'s <em>Tagline</em> from the <a href="options-general.php">General Options</a> will be used.', 'add-meta-tags') . '
</label>
<br />
</fieldset>
</td>
</tr>
<tr valign="top">
<th scope="row">' . __('Front Page Keywords', 'add-meta-tags') . '</th>
<td>
<fieldset>
<legend class="screen-reader-text"><span>' . __('Front Page Keywords', 'add-meta-tags') . '</span></legend>
<textarea name="site_keywords" id="site_keywords" cols="100" rows="2" class="code">' . esc_attr(stripslashes(amt_get_site_keywords($options))) . '</textarea>
<br />
<label for="site_keywords">' . __('Enter a comma-delimited list of keywords for your blog. These keywords will be used in the <em>keywords</em> meta tag on the <strong>front page</strong>. If this field is left empty, then all of your blog\'s <a href="edit-tags.php?taxonomy=category">categories</a> will be used as keywords for the <em>keywords</em> meta tag.', 'add-meta-tags') . '</label>
<p><strong>' . __('Example', 'add-meta-tags') . '</strong>: <code>' . __('keyword1, keyword2, keyword3', 'add-meta-tags') . '</code></p>
<br />
</fieldset>
</td>
</tr>
';
}
print '
<tr valign="top">
<th scope="row">' . __('Global Keywords', 'add-meta-tags') . '</th>
<td>
<fieldset>
<legend class="screen-reader-text"><span>' . __('Global Keywords', 'add-meta-tags') . '</span></legend>
示例6: 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'))) . '" />';
//.........这里部分代码省略.........
示例7: amt_add_basic_metadata_head
//.........这里部分代码省略.........
$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) . '" />';
}
// Add extra hreflang links that have been collected from the full meta tags boxes
if (!empty($hreflang_links_arr)) {
$hreflang_arr = array_merge($hreflang_arr, $hreflang_links_arr);
}
// 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);
示例8: 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'));
//.........这里部分代码省略.........
示例9: amt_get_jsonld_schemaorg_publisher_array
/**
* Return an array of Schema.org metatags suitable for the publisher object of
* the content. Accepts the $post object as argument.
*/
function amt_get_jsonld_schemaorg_publisher_array($options, $author_id = null)
{
$metadata_arr = array();
// Schema.org type
$metadata_arr['@type'] = 'Organization';
// name
$metadata_arr['name'] = esc_attr(get_bloginfo('name'));
// description
// First use the site description from the Add-Meta-Tags settings
$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 (!empty($site_description)) {
$metadata_arr['description'] = esc_attr($site_description);
}
// logo
if (!empty($options["default_image_url"])) {
$metadata_arr['logo'] = esc_url_raw($options["default_image_url"]);
}
// url
// The blog url is used by default. Google+, Facebook and Twitter profile URLs are added as sameAs.
$metadata_arr['url'] = esc_url_raw(trailingslashit(get_bloginfo('url')));
// sameAs
$metadata_arr['sameAs'] = array();
// Social Profile Links are added as sameAs properties
// By default, those of the Publisher Settings are used.
// WARNING: Publisher profile URLs from the user profile page are now deprecated.
// Google+ Publisher
if (!empty($options['social_main_googleplus_publisher_profile_url'])) {
$metadata_arr['sameAs'][] = esc_url_raw($options['social_main_googleplus_publisher_profile_url'], array('http', 'https'));
}
// Facebook
if (!empty($options['social_main_facebook_publisher_profile_url'])) {
$metadata_arr['sameAs'][] = esc_url_raw($options['social_main_facebook_publisher_profile_url'], array('http', 'https'));
}
// Twitter
if (!empty($options['social_main_twitter_publisher_username'])) {
$metadata_arr['sameAs'][] = 'https://twitter.com/' . esc_attr($options['social_main_twitter_publisher_username']);
}
// Allow filtering of the Publisher meta tags
$metadata_arr = apply_filters('amt_jsonld_schemaorg_publisher_extra', $metadata_arr);
return $metadata_arr;
}