mupic/wp-api-yoast-meta 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mupic/wp-api-yoast-meta

Composer 安装命令:

composer require mupic/wp-api-yoast-meta

包简介

README 文档

README

Supports Yoast SEO >= 11.0

Install

composer require mupic/wp-api-yoast-meta

For use with the new WP REST API

Returns Yoast post or page metadata in a normal post or page request. Stores the metadata in the yoast_meta field of the returned data.

Default constants

//GET params will take precedence over constants
define('YOAST_REST_META', false); //false - Disable automatic meta seo input. (Equivalent in get request: meta=false)
define('YOAST_REST_OG', false); //false - Disable automatic open graph input. (Equivalent in get request: opengraph=false)
define('YOAST_REST_TW', false); //false - Disable automatic meta twitter input. (Equivalent in get request: twitter=false)
define('YOAST_REST_BC', false); //true - Return json breadcrumbs. "html" - Return html generated breadcrumbs. (Equivalent in get request: breadcrumbs=false)
define('YOAST_REST_SCHEMA', false); //false - Disable automatic microdata input. (Equivalent in get request: schema=false)

define('YOAST_REST_ENABLE_EMBED', false); //false - Disable yoast in fields called from _embed=true. (Equivalent in get request: yoast_embed=false)

Examples

//wp-json/wp/v2/posts/123?yoast_meta=true&opengraph=true&twitter=true&breadcrumbs=true&schema=true
{
	id: 123,
	...
	yoast:{
		breadcrumbs: {
			links: [
				0: {
					allow_html: true
					text: "Home"
					url: "http://example.com/"
				},
				1: {
					text: "News"
					url: "http://example.com/category/news/"
				},
				2: {
					text: "Title"
					url: "http://example.com/news/title/"
				}
			],
			separator: "»"
		},
		meta: {
			canonical: "http://example.com/news/title/"
			description: "Description"
			article:modified_time: "2019-04-01T16:22:10+00:00"
			article:published_time: "2019-01-10T13:05:30+00:00"
			article:section: "News"
			article:tag: ["Tag1", "Tag2"]
			og:description: "Description"
			og:image: "http://example.com/wp-content/uploads/2019/01/6JHYYbvoSuQ95ceGx8Oeg8zzAjg-550x309.jpg"
			og:image:height: "309"
			og:image:width: "550"
			og:locale: "en_US"
			og:site_name: "Site"
			og:title: "Title - site"
			og:type: "article"
			og:updated_time: "2019-04-01T16:22:10+00:00"
			og:url: "http://example.com/news/title/"
			title: "Title - site"
			twitter:card: "summary"
			twitter:description: "Description"
			twitter:image: "http://example.com/wp-content/uploads/2019/01/6JHYYbvoSuQ95ceGx8Oeg8zzAjg.jpg"
			twitter:title: "Title - site"
		},
		schema: "{"@context":"https://schema.org","@graph":[...]}" //all schemes
	}
}
//yoast_api/v1/home?yoast_meta=true&opengraph=true&twitter=true&breadcrumbs=true&schema=true
{
	breadcrumbs: {
		links: [
			0: {
				allow_html: true
				text: "Home"
				url: "http://example.com/"
			}
		],
		separator: "»"
	},
	meta: {
		canonical: "http://example.com/"
		description: "Description"
		og:description: "Description"
		og:locale: "en_US"
		og:site_name: "Site"
		og:title: "Title - site"
		og:type: "website"
		og:url: "http://example.com/"
		title: "Title - site"
		twitter:card: "summary"
		twitter:description: "Description"
		twitter:title: "Title - site"
	},
	schema: {
		organization: "{"@context":"https://schema.org","@type":"Organization","url":"http://example.com/","sameAs":[],"@id":"http://example.com/#organization","name":"My super company","logo":"http://example.com/wp-content/uploads/2019/02/7e55b905c43b67479065761d49f0dcb8-2.png"}",
		website: "{"@context":"https://schema.org","@type":"WebSite","@id":"http://example.com/#website","url":"http://example.com/","name":"SiteName","potentialAction":{"@type":"SearchAction","target":"http://example.com/?s={search_term_string}","query-input":"required name=search_term_string"}}"
	}
}
//wp-json/wp/v2/posts/123?yoast_meta=true&breadcrumbs=html
{
	id: 123,
	...
	yoast:{
		breadcrumbs: {
			html: "<span><span><a href="http://example.com/" >Home</a> » <span><a href="http://example.com/category/news/" >News</a> » <span class="breadcrumb_last" aria-current="page">Title</span></span></span></span>"
		},
		meta: {...}
	}
}

Supports pages, posts, any public custom post types, categories, tags, any show_in_rest custom taxonomies

Currently fetching:

  • canonical
  • description
  • yoast_wpseo_title
  • yoast_wpseo_metadesc
  • yoast_wpseo_canonical
  • article:modified_time
  • article:published_time
  • article:section
  • article:tag
  • og:description
  • og:image
  • og:image:height
  • og:image:width
  • og:locale
  • og:site_name
  • og:title
  • og:type
  • og:updated_time
  • og:url
  • title
  • twitter:card
  • twitter:description
  • twitter:image
  • twitter:title

Currently updating:

  • yoast_wpseo_focuskw
  • yoast_wpseo_title
  • yoast_wpseo_metadesc
  • yoast_wpseo_linkdex
  • yoast_wpseo_metakeywords
  • yoast_wpseo_meta-robots-noindex
  • yoast_wpseo_meta-robots-nofollow
  • yoast_wpseo_meta-robots-adv
  • yoast_wpseo_canonical
  • yoast_wpseo_redirect
  • yoast_wpseo_opengraph-title
  • yoast_wpseo_opengraph-description
  • yoast_wpseo_opengraph-image
  • yoast_wpseo_twitter-title
  • yoast_wpseo_twitter-description
  • yoast_wpseo_twitter-image

Fork from https://github.com/ChazUK/wp-api-yoast-meta

mupic/wp-api-yoast-meta 适用场景与选型建议

mupic/wp-api-yoast-meta 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 29 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 03 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 mupic/wp-api-yoast-meta 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mupic/wp-api-yoast-meta 我们能提供哪些服务?
定制开发 / 二次开发

基于 mupic/wp-api-yoast-meta 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 29
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 10
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 65
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2019-03-30