@@ -26,38 +26,38 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | class Wordlift_i18n { |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * The domain specified for this plugin. |
|
| 31 | - * |
|
| 32 | - * @since 1.0.0 |
|
| 33 | - * @access private |
|
| 34 | - * @var string $domain The domain identifier for this plugin. |
|
| 35 | - */ |
|
| 36 | - private $domain; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * Load the plugin text domain for translation. |
|
| 40 | - * |
|
| 41 | - * @since 1.0.0 |
|
| 42 | - */ |
|
| 43 | - public function load_plugin_textdomain() { |
|
| 44 | - |
|
| 45 | - load_plugin_textdomain( |
|
| 46 | - $this->domain, |
|
| 47 | - false, |
|
| 48 | - dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' |
|
| 49 | - ); |
|
| 50 | - |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * Set the domain equal to that of the specified domain. |
|
| 55 | - * |
|
| 56 | - * @since 1.0.0 |
|
| 57 | - * @param string $domain The domain that represents the locale of this plugin. |
|
| 58 | - */ |
|
| 59 | - public function set_domain( $domain ) { |
|
| 60 | - $this->domain = $domain; |
|
| 61 | - } |
|
| 29 | + /** |
|
| 30 | + * The domain specified for this plugin. |
|
| 31 | + * |
|
| 32 | + * @since 1.0.0 |
|
| 33 | + * @access private |
|
| 34 | + * @var string $domain The domain identifier for this plugin. |
|
| 35 | + */ |
|
| 36 | + private $domain; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Load the plugin text domain for translation. |
|
| 40 | + * |
|
| 41 | + * @since 1.0.0 |
|
| 42 | + */ |
|
| 43 | + public function load_plugin_textdomain() { |
|
| 44 | + |
|
| 45 | + load_plugin_textdomain( |
|
| 46 | + $this->domain, |
|
| 47 | + false, |
|
| 48 | + dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' |
|
| 49 | + ); |
|
| 50 | + |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * Set the domain equal to that of the specified domain. |
|
| 55 | + * |
|
| 56 | + * @since 1.0.0 |
|
| 57 | + * @param string $domain The domain that represents the locale of this plugin. |
|
| 58 | + */ |
|
| 59 | + public function set_domain( $domain ) { |
|
| 60 | + $this->domain = $domain; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | 63 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | load_plugin_textdomain( |
| 46 | 46 | $this->domain, |
| 47 | 47 | false, |
| 48 | - dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' |
|
| 48 | + dirname(dirname(plugin_basename(__FILE__))).'/languages/' |
|
| 49 | 49 | ); |
| 50 | 50 | |
| 51 | 51 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @since 1.0.0 |
| 57 | 57 | * @param string $domain The domain that represents the locale of this plugin. |
| 58 | 58 | */ |
| 59 | - public function set_domain( $domain ) { |
|
| 59 | + public function set_domain($domain) { |
|
| 60 | 60 | $this->domain = $domain; |
| 61 | 61 | } |
| 62 | 62 | |
@@ -23,107 +23,107 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | class Wordlift_Loader { |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * The array of actions registered with WordPress. |
|
| 28 | - * |
|
| 29 | - * @since 1.0.0 |
|
| 30 | - * @access protected |
|
| 31 | - * @var array $actions The actions registered with WordPress to fire when the plugin loads. |
|
| 32 | - */ |
|
| 33 | - protected $actions; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * The array of filters registered with WordPress. |
|
| 37 | - * |
|
| 38 | - * @since 1.0.0 |
|
| 39 | - * @access protected |
|
| 40 | - * @var array $filters The filters registered with WordPress to fire when the plugin loads. |
|
| 41 | - */ |
|
| 42 | - protected $filters; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * Initialize the collections used to maintain the actions and filters. |
|
| 46 | - * |
|
| 47 | - * @since 1.0.0 |
|
| 48 | - */ |
|
| 49 | - public function __construct() { |
|
| 50 | - |
|
| 51 | - $this->actions = array(); |
|
| 52 | - $this->filters = array(); |
|
| 53 | - |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * Add a new action to the collection to be registered with WordPress. |
|
| 58 | - * |
|
| 59 | - * @since 1.0.0 |
|
| 60 | - * @param string $hook The name of the WordPress action that is being registered. |
|
| 61 | - * @param object $component A reference to the instance of the object on which the action is defined. |
|
| 62 | - * @param string $callback The name of the function definition on the $component. |
|
| 63 | - * @param int $priority Optional. he priority at which the function should be fired. Default is 10. |
|
| 64 | - * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. |
|
| 65 | - */ |
|
| 66 | - public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { |
|
| 67 | - $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args ); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * Add a new filter to the collection to be registered with WordPress. |
|
| 72 | - * |
|
| 73 | - * @since 1.0.0 |
|
| 74 | - * @param string $hook The name of the WordPress filter that is being registered. |
|
| 75 | - * @param object $component A reference to the instance of the object on which the filter is defined. |
|
| 76 | - * @param string $callback The name of the function definition on the $component. |
|
| 77 | - * @param int $priority Optional. he priority at which the function should be fired. Default is 10. |
|
| 78 | - * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1 |
|
| 79 | - */ |
|
| 80 | - public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { |
|
| 81 | - $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * A utility function that is used to register the actions and hooks into a single |
|
| 86 | - * collection. |
|
| 87 | - * |
|
| 88 | - * @since 1.0.0 |
|
| 89 | - * @access private |
|
| 90 | - * @param array $hooks The collection of hooks that is being registered (that is, actions or filters). |
|
| 91 | - * @param string $hook The name of the WordPress filter that is being registered. |
|
| 92 | - * @param object $component A reference to the instance of the object on which the filter is defined. |
|
| 93 | - * @param string $callback The name of the function definition on the $component. |
|
| 94 | - * @param int $priority The priority at which the function should be fired. |
|
| 95 | - * @param int $accepted_args The number of arguments that should be passed to the $callback. |
|
| 96 | - * @return array The collection of actions and filters registered with WordPress. |
|
| 97 | - */ |
|
| 98 | - private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) { |
|
| 99 | - |
|
| 100 | - $hooks[] = array( |
|
| 101 | - 'hook' => $hook, |
|
| 102 | - 'component' => $component, |
|
| 103 | - 'callback' => $callback, |
|
| 104 | - 'priority' => $priority, |
|
| 105 | - 'accepted_args' => $accepted_args |
|
| 106 | - ); |
|
| 107 | - |
|
| 108 | - return $hooks; |
|
| 109 | - |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * Register the filters and actions with WordPress. |
|
| 114 | - * |
|
| 115 | - * @since 1.0.0 |
|
| 116 | - */ |
|
| 117 | - public function run() { |
|
| 118 | - |
|
| 119 | - foreach ( $this->filters as $hook ) { |
|
| 120 | - add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - foreach ( $this->actions as $hook ) { |
|
| 124 | - add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - } |
|
| 26 | + /** |
|
| 27 | + * The array of actions registered with WordPress. |
|
| 28 | + * |
|
| 29 | + * @since 1.0.0 |
|
| 30 | + * @access protected |
|
| 31 | + * @var array $actions The actions registered with WordPress to fire when the plugin loads. |
|
| 32 | + */ |
|
| 33 | + protected $actions; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * The array of filters registered with WordPress. |
|
| 37 | + * |
|
| 38 | + * @since 1.0.0 |
|
| 39 | + * @access protected |
|
| 40 | + * @var array $filters The filters registered with WordPress to fire when the plugin loads. |
|
| 41 | + */ |
|
| 42 | + protected $filters; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * Initialize the collections used to maintain the actions and filters. |
|
| 46 | + * |
|
| 47 | + * @since 1.0.0 |
|
| 48 | + */ |
|
| 49 | + public function __construct() { |
|
| 50 | + |
|
| 51 | + $this->actions = array(); |
|
| 52 | + $this->filters = array(); |
|
| 53 | + |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * Add a new action to the collection to be registered with WordPress. |
|
| 58 | + * |
|
| 59 | + * @since 1.0.0 |
|
| 60 | + * @param string $hook The name of the WordPress action that is being registered. |
|
| 61 | + * @param object $component A reference to the instance of the object on which the action is defined. |
|
| 62 | + * @param string $callback The name of the function definition on the $component. |
|
| 63 | + * @param int $priority Optional. he priority at which the function should be fired. Default is 10. |
|
| 64 | + * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. |
|
| 65 | + */ |
|
| 66 | + public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { |
|
| 67 | + $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args ); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * Add a new filter to the collection to be registered with WordPress. |
|
| 72 | + * |
|
| 73 | + * @since 1.0.0 |
|
| 74 | + * @param string $hook The name of the WordPress filter that is being registered. |
|
| 75 | + * @param object $component A reference to the instance of the object on which the filter is defined. |
|
| 76 | + * @param string $callback The name of the function definition on the $component. |
|
| 77 | + * @param int $priority Optional. he priority at which the function should be fired. Default is 10. |
|
| 78 | + * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1 |
|
| 79 | + */ |
|
| 80 | + public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { |
|
| 81 | + $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * A utility function that is used to register the actions and hooks into a single |
|
| 86 | + * collection. |
|
| 87 | + * |
|
| 88 | + * @since 1.0.0 |
|
| 89 | + * @access private |
|
| 90 | + * @param array $hooks The collection of hooks that is being registered (that is, actions or filters). |
|
| 91 | + * @param string $hook The name of the WordPress filter that is being registered. |
|
| 92 | + * @param object $component A reference to the instance of the object on which the filter is defined. |
|
| 93 | + * @param string $callback The name of the function definition on the $component. |
|
| 94 | + * @param int $priority The priority at which the function should be fired. |
|
| 95 | + * @param int $accepted_args The number of arguments that should be passed to the $callback. |
|
| 96 | + * @return array The collection of actions and filters registered with WordPress. |
|
| 97 | + */ |
|
| 98 | + private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) { |
|
| 99 | + |
|
| 100 | + $hooks[] = array( |
|
| 101 | + 'hook' => $hook, |
|
| 102 | + 'component' => $component, |
|
| 103 | + 'callback' => $callback, |
|
| 104 | + 'priority' => $priority, |
|
| 105 | + 'accepted_args' => $accepted_args |
|
| 106 | + ); |
|
| 107 | + |
|
| 108 | + return $hooks; |
|
| 109 | + |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * Register the filters and actions with WordPress. |
|
| 114 | + * |
|
| 115 | + * @since 1.0.0 |
|
| 116 | + */ |
|
| 117 | + public function run() { |
|
| 118 | + |
|
| 119 | + foreach ( $this->filters as $hook ) { |
|
| 120 | + add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + foreach ( $this->actions as $hook ) { |
|
| 124 | + add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | 129 | } |
@@ -63,8 +63,8 @@ discard block |
||
| 63 | 63 | * @param int $priority Optional. he priority at which the function should be fired. Default is 10. |
| 64 | 64 | * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. |
| 65 | 65 | */ |
| 66 | - public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { |
|
| 67 | - $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args ); |
|
| 66 | + public function add_action($hook, $component, $callback, $priority = 10, $accepted_args = 1) { |
|
| 67 | + $this->actions = $this->add($this->actions, $hook, $component, $callback, $priority, $accepted_args); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | * @param int $priority Optional. he priority at which the function should be fired. Default is 10. |
| 78 | 78 | * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1 |
| 79 | 79 | */ |
| 80 | - public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { |
|
| 81 | - $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); |
|
| 80 | + public function add_filter($hook, $component, $callback, $priority = 10, $accepted_args = 1) { |
|
| 81 | + $this->filters = $this->add($this->filters, $hook, $component, $callback, $priority, $accepted_args); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @param int $accepted_args The number of arguments that should be passed to the $callback. |
| 96 | 96 | * @return array The collection of actions and filters registered with WordPress. |
| 97 | 97 | */ |
| 98 | - private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) { |
|
| 98 | + private function add($hooks, $hook, $component, $callback, $priority, $accepted_args) { |
|
| 99 | 99 | |
| 100 | 100 | $hooks[] = array( |
| 101 | 101 | 'hook' => $hook, |
@@ -116,12 +116,12 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | public function run() { |
| 118 | 118 | |
| 119 | - foreach ( $this->filters as $hook ) { |
|
| 120 | - add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); |
|
| 119 | + foreach ($this->filters as $hook) { |
|
| 120 | + add_filter($hook['hook'], array($hook['component'], $hook['callback']), $hook['priority'], $hook['accepted_args']); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - foreach ( $this->actions as $hook ) { |
|
| 124 | - add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); |
|
| 123 | + foreach ($this->actions as $hook) { |
|
| 124 | + add_action($hook['hook'], array($hook['component'], $hook['callback']), $hook['priority'], $hook['accepted_args']); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | } |
@@ -9,28 +9,28 @@ discard block |
||
| 9 | 9 | * @param array $atts An array of shortcode attributes. |
| 10 | 10 | * @return string A dom element with requested property value(s). |
| 11 | 11 | */ |
| 12 | -function wl_shortcode_field( $atts ) { |
|
| 12 | +function wl_shortcode_field($atts) { |
|
| 13 | 13 | |
| 14 | 14 | // Extract attributes and set default values. |
| 15 | - $field_atts = shortcode_atts( array( |
|
| 15 | + $field_atts = shortcode_atts(array( |
|
| 16 | 16 | 'id' => null, |
| 17 | 17 | 'name' => null |
| 18 | - ), $atts ); |
|
| 18 | + ), $atts); |
|
| 19 | 19 | |
| 20 | 20 | // Get id of the post |
| 21 | 21 | $entity_id = $field_atts['id']; |
| 22 | - if( is_null( $field_atts['id'] ) || !is_numeric( $field_atts['id'] ) ) { |
|
| 22 | + if (is_null($field_atts['id']) || ! is_numeric($field_atts['id'])) { |
|
| 23 | 23 | $entity_id = get_the_ID(); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | $property_name = $field_atts['name']; |
| 27 | - if( !is_null( $property_name ) ) { |
|
| 28 | - $values = wl_schema_get_value( $entity_id, $property_name ); |
|
| 27 | + if ( ! is_null($property_name)) { |
|
| 28 | + $values = wl_schema_get_value($entity_id, $property_name); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | // Return |
| 32 | - if( is_array( $values ) ) { |
|
| 33 | - return implode( ', ', $values ); |
|
| 32 | + if (is_array($values)) { |
|
| 33 | + return implode(', ', $values); |
|
| 34 | 34 | } else { |
| 35 | 35 | return null; |
| 36 | 36 | } |
@@ -40,5 +40,5 @@ discard block |
||
| 40 | 40 | add_shortcode('wl_field', 'wl_shortcode_field'); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | -add_action( 'init', 'wl_register_shortcode_field'); |
|
| 43 | +add_action('init', 'wl_register_shortcode_field'); |
|
| 44 | 44 | |
@@ -7,80 +7,80 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class Wordlift_UI_Service { |
| 9 | 9 | |
| 10 | - /** |
|
| 11 | - * The button element HTML code. |
|
| 12 | - * |
|
| 13 | - * @since 3.2.0 |
|
| 14 | - */ |
|
| 15 | - const BUTTON_HTML = '<a id="%s" class="button wl-button">%s</a>'; |
|
| 10 | + /** |
|
| 11 | + * The button element HTML code. |
|
| 12 | + * |
|
| 13 | + * @since 3.2.0 |
|
| 14 | + */ |
|
| 15 | + const BUTTON_HTML = '<a id="%s" class="button wl-button">%s</a>'; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * The template HTML code. |
|
| 19 | - * |
|
| 20 | - * @since 3.2.0 |
|
| 21 | - */ |
|
| 22 | - const TEMPLATE_HTML = '<script id="%s" type="text/template">%s</script>'; |
|
| 17 | + /** |
|
| 18 | + * The template HTML code. |
|
| 19 | + * |
|
| 20 | + * @since 3.2.0 |
|
| 21 | + */ |
|
| 22 | + const TEMPLATE_HTML = '<script id="%s" type="text/template">%s</script>'; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Get the button HTML. |
|
| 26 | - * |
|
| 27 | - * @since 3.2.0 |
|
| 28 | - * |
|
| 29 | - * @param string $element_id The button element id. |
|
| 30 | - * @param string $label The button (translated) label. |
|
| 31 | - * |
|
| 32 | - * @return string The button HTML code. |
|
| 33 | - */ |
|
| 34 | - public function get_button_html( $element_id, $label ) { |
|
| 24 | + /** |
|
| 25 | + * Get the button HTML. |
|
| 26 | + * |
|
| 27 | + * @since 3.2.0 |
|
| 28 | + * |
|
| 29 | + * @param string $element_id The button element id. |
|
| 30 | + * @param string $label The button (translated) label. |
|
| 31 | + * |
|
| 32 | + * @return string The button HTML code. |
|
| 33 | + */ |
|
| 34 | + public function get_button_html( $element_id, $label ) { |
|
| 35 | 35 | |
| 36 | - return sprintf( self::BUTTON_HTML, $element_id, esc_html( $label ) ); |
|
| 37 | - } |
|
| 36 | + return sprintf( self::BUTTON_HTML, $element_id, esc_html( $label ) ); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Echo the button HTML. |
|
| 41 | - * |
|
| 42 | - * @since 3.2.0 |
|
| 43 | - * |
|
| 44 | - * @param string $element_id The button element id. |
|
| 45 | - * @param string $label The button (translated) label. |
|
| 46 | - * |
|
| 47 | - * @return string The button HTML code. |
|
| 48 | - */ |
|
| 49 | - public function print_button( $element_id, $label ) { |
|
| 39 | + /** |
|
| 40 | + * Echo the button HTML. |
|
| 41 | + * |
|
| 42 | + * @since 3.2.0 |
|
| 43 | + * |
|
| 44 | + * @param string $element_id The button element id. |
|
| 45 | + * @param string $label The button (translated) label. |
|
| 46 | + * |
|
| 47 | + * @return string The button HTML code. |
|
| 48 | + */ |
|
| 49 | + public function print_button( $element_id, $label ) { |
|
| 50 | 50 | |
| 51 | - echo( $this->get_button_html( $element_id, $label ) ); |
|
| 51 | + echo( $this->get_button_html( $element_id, $label ) ); |
|
| 52 | 52 | |
| 53 | - } |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Get the HTML code for a template tag. |
|
| 57 | - * |
|
| 58 | - * @since 3.2.0 |
|
| 59 | - * |
|
| 60 | - * @param string $element_id The element id. |
|
| 61 | - * @param string $body The element content. |
|
| 62 | - * |
|
| 63 | - * @return string The HTML code. |
|
| 64 | - */ |
|
| 65 | - public function get_template_html( $element_id, $body ) { |
|
| 55 | + /** |
|
| 56 | + * Get the HTML code for a template tag. |
|
| 57 | + * |
|
| 58 | + * @since 3.2.0 |
|
| 59 | + * |
|
| 60 | + * @param string $element_id The element id. |
|
| 61 | + * @param string $body The element content. |
|
| 62 | + * |
|
| 63 | + * @return string The HTML code. |
|
| 64 | + */ |
|
| 65 | + public function get_template_html( $element_id, $body ) { |
|
| 66 | 66 | |
| 67 | - return sprintf( self::TEMPLATE_HTML, $element_id, $body ); |
|
| 68 | - } |
|
| 67 | + return sprintf( self::TEMPLATE_HTML, $element_id, $body ); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * Echo the HTML code for a template tag. |
|
| 72 | - * |
|
| 73 | - * @since 3.2.0 |
|
| 74 | - * |
|
| 75 | - * @param string $element_id The element id. |
|
| 76 | - * @param string $body The element content. |
|
| 77 | - * |
|
| 78 | - * @return string The HTML code. |
|
| 79 | - */ |
|
| 80 | - public function print_template( $element_id, $body ) { |
|
| 70 | + /** |
|
| 71 | + * Echo the HTML code for a template tag. |
|
| 72 | + * |
|
| 73 | + * @since 3.2.0 |
|
| 74 | + * |
|
| 75 | + * @param string $element_id The element id. |
|
| 76 | + * @param string $body The element content. |
|
| 77 | + * |
|
| 78 | + * @return string The HTML code. |
|
| 79 | + */ |
|
| 80 | + public function print_template( $element_id, $body ) { |
|
| 81 | 81 | |
| 82 | - echo( $this->get_template_html( $element_id, $body ) ); |
|
| 82 | + echo( $this->get_template_html( $element_id, $body ) ); |
|
| 83 | 83 | |
| 84 | - } |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | 86 | } |
@@ -31,9 +31,9 @@ discard block |
||
| 31 | 31 | * |
| 32 | 32 | * @return string The button HTML code. |
| 33 | 33 | */ |
| 34 | - public function get_button_html( $element_id, $label ) { |
|
| 34 | + public function get_button_html($element_id, $label) { |
|
| 35 | 35 | |
| 36 | - return sprintf( self::BUTTON_HTML, $element_id, esc_html( $label ) ); |
|
| 36 | + return sprintf(self::BUTTON_HTML, $element_id, esc_html($label)); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -46,9 +46,9 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | * @return string The button HTML code. |
| 48 | 48 | */ |
| 49 | - public function print_button( $element_id, $label ) { |
|
| 49 | + public function print_button($element_id, $label) { |
|
| 50 | 50 | |
| 51 | - echo( $this->get_button_html( $element_id, $label ) ); |
|
| 51 | + echo($this->get_button_html($element_id, $label)); |
|
| 52 | 52 | |
| 53 | 53 | } |
| 54 | 54 | |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | * |
| 63 | 63 | * @return string The HTML code. |
| 64 | 64 | */ |
| 65 | - public function get_template_html( $element_id, $body ) { |
|
| 65 | + public function get_template_html($element_id, $body) { |
|
| 66 | 66 | |
| 67 | - return sprintf( self::TEMPLATE_HTML, $element_id, $body ); |
|
| 67 | + return sprintf(self::TEMPLATE_HTML, $element_id, $body); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -77,9 +77,9 @@ discard block |
||
| 77 | 77 | * |
| 78 | 78 | * @return string The HTML code. |
| 79 | 79 | */ |
| 80 | - public function print_template( $element_id, $body ) { |
|
| 80 | + public function print_template($element_id, $body) { |
|
| 81 | 81 | |
| 82 | - echo( $this->get_template_html( $element_id, $body ) ); |
|
| 82 | + echo($this->get_template_html($element_id, $body)); |
|
| 83 | 83 | |
| 84 | 84 | } |
| 85 | 85 | |
@@ -7,33 +7,33 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class Wordlift_PrimaShop_Adapter { |
| 9 | 9 | |
| 10 | - /** |
|
| 11 | - * Create a Wordlift_PrimaShop_Adapter instance. |
|
| 12 | - * |
|
| 13 | - * @since 3.2.3 |
|
| 14 | - */ |
|
| 15 | - public function __construct() { |
|
| 10 | + /** |
|
| 11 | + * Create a Wordlift_PrimaShop_Adapter instance. |
|
| 12 | + * |
|
| 13 | + * @since 3.2.3 |
|
| 14 | + */ |
|
| 15 | + public function __construct() { |
|
| 16 | 16 | |
| 17 | - // Tell WP (and PrimaShop) that we support the *prima-layout-settings*. This will display the Content Settings |
|
| 18 | - // in the entity edit page. |
|
| 19 | - add_post_type_support( Wordlift_Entity_Service::TYPE_NAME, 'prima-layout-settings' ); |
|
| 17 | + // Tell WP (and PrimaShop) that we support the *prima-layout-settings*. This will display the Content Settings |
|
| 18 | + // in the entity edit page. |
|
| 19 | + add_post_type_support( Wordlift_Entity_Service::TYPE_NAME, 'prima-layout-settings' ); |
|
| 20 | 20 | |
| 21 | - } |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Intercept the <em>prima_metabox_entity_header_args</em> filter and return what a call to the related <em>post</em> |
|
| 25 | - * would have returned. |
|
| 26 | - * |
|
| 27 | - * @since 3.2.3 |
|
| 28 | - * |
|
| 29 | - * @param array $meta The meta array. |
|
| 30 | - * @param string $ype The post type. |
|
| 31 | - * |
|
| 32 | - * @return array A meta array. |
|
| 33 | - */ |
|
| 34 | - function prima_metabox_entity_header_args( $meta, $ype ) { |
|
| 23 | + /** |
|
| 24 | + * Intercept the <em>prima_metabox_entity_header_args</em> filter and return what a call to the related <em>post</em> |
|
| 25 | + * would have returned. |
|
| 26 | + * |
|
| 27 | + * @since 3.2.3 |
|
| 28 | + * |
|
| 29 | + * @param array $meta The meta array. |
|
| 30 | + * @param string $ype The post type. |
|
| 31 | + * |
|
| 32 | + * @return array A meta array. |
|
| 33 | + */ |
|
| 34 | + function prima_metabox_entity_header_args( $meta, $ype ) { |
|
| 35 | 35 | |
| 36 | - return apply_filters( "prima_metabox_post_header_args", $meta, 'post' ); |
|
| 37 | - } |
|
| 36 | + return apply_filters( "prima_metabox_post_header_args", $meta, 'post' ); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | 39 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | // Tell WP (and PrimaShop) that we support the *prima-layout-settings*. This will display the Content Settings |
| 18 | 18 | // in the entity edit page. |
| 19 | - add_post_type_support( Wordlift_Entity_Service::TYPE_NAME, 'prima-layout-settings' ); |
|
| 19 | + add_post_type_support(Wordlift_Entity_Service::TYPE_NAME, 'prima-layout-settings'); |
|
| 20 | 20 | |
| 21 | 21 | } |
| 22 | 22 | |
@@ -31,9 +31,9 @@ discard block |
||
| 31 | 31 | * |
| 32 | 32 | * @return array A meta array. |
| 33 | 33 | */ |
| 34 | - function prima_metabox_entity_header_args( $meta, $ype ) { |
|
| 34 | + function prima_metabox_entity_header_args($meta, $ype) { |
|
| 35 | 35 | |
| 36 | - return apply_filters( "prima_metabox_post_header_args", $meta, 'post' ); |
|
| 36 | + return apply_filters("prima_metabox_post_header_args", $meta, 'post'); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | } |
@@ -3,11 +3,11 @@ |
||
| 3 | 3 | // File created to manage some dynamic translation used in the code |
| 4 | 4 | // See http://keithdevon.com/using-variables-wordpress-translation-functions/ |
| 5 | 5 | |
| 6 | -__( 'There are no related posts for the current entity.', 'wordlift' ); |
|
| 7 | -__( 'This entity has not description.', 'wordlift' ); |
|
| 8 | -__( 'There are no related entities for the current entity.', 'wordlift' ); |
|
| 9 | -__( 'This entity is not published. It will not appear within analysis results.', 'wordlift' ); |
|
| 10 | -__( 'This entity has no featured image yet.', 'wordlift' ); |
|
| 11 | -__( 'There are no sameAs configured for this entity.', 'wordlift' ); |
|
| 12 | -__( 'Schema.org metadata for this entity are not completed.', 'wordlift' ); |
|
| 6 | +__('There are no related posts for the current entity.', 'wordlift'); |
|
| 7 | +__('This entity has not description.', 'wordlift'); |
|
| 8 | +__('There are no related entities for the current entity.', 'wordlift'); |
|
| 9 | +__('This entity is not published. It will not appear within analysis results.', 'wordlift'); |
|
| 10 | +__('This entity has no featured image yet.', 'wordlift'); |
|
| 11 | +__('There are no sameAs configured for this entity.', 'wordlift'); |
|
| 12 | +__('Schema.org metadata for this entity are not completed.', 'wordlift'); |
|
| 13 | 13 | |
@@ -282,7 +282,7 @@ |
||
| 282 | 282 | * |
| 283 | 283 | * @param string $key The field's key. |
| 284 | 284 | * |
| 285 | - * @return null|array An array of field's properties or null if the field is not found. |
|
| 285 | + * @return string An array of field's properties or null if the field is not found. |
|
| 286 | 286 | */ |
| 287 | 287 | public function get_field( $key ) { |
| 288 | 288 | |
@@ -18,1687 +18,1687 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class Wordlift_Schema_Service { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * The 'location created' field name. |
|
| 23 | - * |
|
| 24 | - * @since 3.5.0 |
|
| 25 | - */ |
|
| 26 | - const FIELD_LOCATION_CREATED = 'wl_location_created'; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * The 'topic' field name. |
|
| 30 | - * |
|
| 31 | - * @since 3.5.0 |
|
| 32 | - */ |
|
| 33 | - const FIELD_TOPIC = 'wl_topic'; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * The 'author' field name. |
|
| 37 | - * |
|
| 38 | - * @since 3.1.0 |
|
| 39 | - */ |
|
| 40 | - const FIELD_AUTHOR = 'wl_author'; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * The 'same as' field name. |
|
| 44 | - * |
|
| 45 | - * @since 3.1.0 |
|
| 46 | - */ |
|
| 47 | - const FIELD_SAME_AS = 'entity_same_as'; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * The 'date start' field name. |
|
| 51 | - * |
|
| 52 | - * @since 3.1.0 |
|
| 53 | - */ |
|
| 54 | - const FIELD_DATE_START = 'wl_cal_date_start'; |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * The 'date end' field name. |
|
| 58 | - * |
|
| 59 | - * @since 3.1.0 |
|
| 60 | - */ |
|
| 61 | - const FIELD_DATE_END = 'wl_cal_date_end'; |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * The 'location' field name. |
|
| 65 | - * |
|
| 66 | - * @since 3.1.0 |
|
| 67 | - */ |
|
| 68 | - const FIELD_LOCATION = 'wl_location'; |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * The 'founder' field name. |
|
| 72 | - * |
|
| 73 | - * @since 3.1.0 |
|
| 74 | - */ |
|
| 75 | - const FIELD_FOUNDER = 'wl_founder'; |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * The 'knows' field name. |
|
| 79 | - * |
|
| 80 | - * @since 3.1.0 |
|
| 81 | - */ |
|
| 82 | - const FIELD_KNOWS = 'wl_knows'; |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * The 'birth date' field name. |
|
| 86 | - * |
|
| 87 | - * @since 3.1.0 |
|
| 88 | - */ |
|
| 89 | - const FIELD_BIRTH_DATE = 'wl_birth_date'; |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * The 'birth place' field name. |
|
| 93 | - * |
|
| 94 | - * @since 3.1.0 |
|
| 95 | - */ |
|
| 96 | - const FIELD_BIRTH_PLACE = 'wl_birth_place'; |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * The 'latitude' field name. |
|
| 100 | - * |
|
| 101 | - * @since 3.1.0 |
|
| 102 | - */ |
|
| 103 | - const FIELD_GEO_LATITUDE = 'wl_geo_latitude'; |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * The 'longitude' field name. |
|
| 107 | - * |
|
| 108 | - * @since 3.1.0 |
|
| 109 | - */ |
|
| 110 | - const FIELD_GEO_LONGITUDE = 'wl_geo_longitude'; |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * The 'streetAddress' field name. |
|
| 114 | - * |
|
| 115 | - * @since 3.1.0 |
|
| 116 | - */ |
|
| 117 | - const FIELD_ADDRESS = 'wl_address'; |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * The 'postOfficeBoxNumber' field name. |
|
| 121 | - * |
|
| 122 | - * @since 3.3.0 |
|
| 123 | - */ |
|
| 124 | - const FIELD_ADDRESS_PO_BOX = 'wl_address_post_office_box'; |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * The 'postalCode' field name. |
|
| 128 | - * |
|
| 129 | - * @since 3.3.0 |
|
| 130 | - */ |
|
| 131 | - const FIELD_ADDRESS_POSTAL_CODE = 'wl_address_postal_code'; |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * The 'addressLocality' field name. |
|
| 135 | - * |
|
| 136 | - * @since 3.3.0 |
|
| 137 | - */ |
|
| 138 | - const FIELD_ADDRESS_LOCALITY = 'wl_address_locality'; |
|
| 139 | - /** |
|
| 140 | - * The 'addressRegion' field name. |
|
| 141 | - * |
|
| 142 | - * @since 3.3.0 |
|
| 143 | - */ |
|
| 144 | - const FIELD_ADDRESS_REGION = 'wl_address_region'; |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * The 'addressCountry' field name. |
|
| 148 | - * |
|
| 149 | - * @since 3.3.0 |
|
| 150 | - */ |
|
| 151 | - const FIELD_ADDRESS_COUNTRY = 'wl_address_country'; |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * The 'entity type' field name. |
|
| 155 | - * |
|
| 156 | - * @since 3.1.0 |
|
| 157 | - */ |
|
| 158 | - const FIELD_ENTITY_TYPE = 'wl_entity_type_uri'; |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * The 'email' field name. |
|
| 162 | - * |
|
| 163 | - * @since 3.2.0 |
|
| 164 | - */ |
|
| 165 | - const FIELD_EMAIL = 'wl_email'; |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * The 'affiliation' field name. |
|
| 169 | - * |
|
| 170 | - * @since 3.2.0 |
|
| 171 | - */ |
|
| 172 | - const FIELD_AFFILIATION = 'wl_affiliation'; |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * The 'telephone' field name. |
|
| 176 | - * |
|
| 177 | - * @since 3.8.0 |
|
| 178 | - */ |
|
| 179 | - const FIELD_TELEPHONE = 'wl_schema_telephone'; |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * The 'legalName' field name. |
|
| 183 | - * |
|
| 184 | - * @since 3.12.0 |
|
| 185 | - */ |
|
| 186 | - const FIELD_LEGAL_NAME = 'wl_schema_legal_name'; |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * The 'recipeCuisine' field name. |
|
| 190 | - * |
|
| 191 | - * @since 3.14.0 |
|
| 192 | - */ |
|
| 193 | - const FIELD_RECIPE_CUISINE = 'wl_schema_recipe_cuisine'; |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * The 'recipeIngredient' field name. |
|
| 197 | - * |
|
| 198 | - * @since 3.14.0 |
|
| 199 | - */ |
|
| 200 | - const FIELD_RECIPE_INGREDIENT = 'wl_schema_recipe_ingredient'; |
|
| 201 | - |
|
| 202 | - /** |
|
| 203 | - * The 'calories' field name. |
|
| 204 | - * |
|
| 205 | - * @since 3.14.0 |
|
| 206 | - */ |
|
| 207 | - const FIELD_NUTRITION_INFO_CALORIES = 'wl_schema_nutrition_information_calories'; |
|
| 208 | - |
|
| 209 | - /** |
|
| 210 | - * The 'recipeInstructions' field name. |
|
| 211 | - * |
|
| 212 | - * @since 3.14.0 |
|
| 213 | - */ |
|
| 214 | - const FIELD_RECIPE_INSTRUCTIONS = 'wl_schema_recipe_instructions'; |
|
| 215 | - |
|
| 216 | - /** |
|
| 217 | - * The 'recipeYield' field name. |
|
| 218 | - * |
|
| 219 | - * @since 3.14.0 |
|
| 220 | - */ |
|
| 221 | - const FIELD_RECIPE_YIELD = 'wl_schema_recipe_yield'; |
|
| 222 | - |
|
| 223 | - /** |
|
| 224 | - * The 'prepTime' field name. |
|
| 225 | - * |
|
| 226 | - * @since 3.14.0 |
|
| 227 | - */ |
|
| 228 | - const FIELD_PREP_TIME = 'wl_schema_prep_time'; |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * The 'cookTime' field name. |
|
| 232 | - * |
|
| 233 | - * @since 3.14.0 |
|
| 234 | - */ |
|
| 235 | - const FIELD_COOK_TIME = 'wl_schema_cook_time'; |
|
| 236 | - |
|
| 237 | - /** |
|
| 238 | - * The 'totalTime' field name. |
|
| 239 | - * |
|
| 240 | - * @since 3.14.0 |
|
| 241 | - */ |
|
| 242 | - const FIELD_TOTAL_TIME = 'wl_schema_total_time'; |
|
| 243 | - |
|
| 244 | - /** |
|
| 245 | - * The 'performer' field name. |
|
| 246 | - * |
|
| 247 | - * @since 3.18.0 |
|
| 248 | - */ |
|
| 249 | - const FIELD_PERFORMER = 'wl_schema_performer'; |
|
| 250 | - |
|
| 251 | - /** |
|
| 252 | - * The 'offers' field name. |
|
| 253 | - * |
|
| 254 | - * @since 3.18.0 |
|
| 255 | - */ |
|
| 256 | - const FIELD_OFFERS = 'wl_schema_offers'; |
|
| 257 | - |
|
| 258 | - /** |
|
| 259 | - * The 'availablity' field name. |
|
| 260 | - * |
|
| 261 | - * @since 3.18.0 |
|
| 262 | - */ |
|
| 263 | - const FIELD_AVAILABILITY = 'wl_schema_availability'; |
|
| 264 | - |
|
| 265 | - /** |
|
| 266 | - * The 'inventoryLevel' field name. |
|
| 267 | - * |
|
| 268 | - * @since 3.18.0 |
|
| 269 | - */ |
|
| 270 | - const FIELD_INVENTORY_LEVEL = 'wl_schema_inventory_level'; |
|
| 271 | - |
|
| 272 | - /** |
|
| 273 | - * The 'price' field name. |
|
| 274 | - * |
|
| 275 | - * @since 3.18.0 |
|
| 276 | - */ |
|
| 277 | - const FIELD_PRICE = 'wl_schema_price'; |
|
| 278 | - |
|
| 279 | - /** |
|
| 280 | - * The 'priceCurrency' field name. |
|
| 281 | - * |
|
| 282 | - * @since 3.18.0 |
|
| 283 | - */ |
|
| 284 | - const FIELD_PRICE_CURRENCY = 'wl_schema_price_currency'; |
|
| 285 | - |
|
| 286 | - /** |
|
| 287 | - * The 'availabilityStarts' field name. |
|
| 288 | - * |
|
| 289 | - * @since 3.18.0 |
|
| 290 | - */ |
|
| 291 | - const FIELD_AVAILABILITY_STARTS = 'wl_schema_availability_starts'; |
|
| 292 | - |
|
| 293 | - /** |
|
| 294 | - * The 'availabilityEnds' field name. |
|
| 295 | - * |
|
| 296 | - * @since 3.18.0 |
|
| 297 | - */ |
|
| 298 | - const FIELD_AVAILABILITY_ENDS = 'wl_schema_availability_ends'; |
|
| 299 | - |
|
| 300 | - /** |
|
| 301 | - * The 'validFrom' field name. |
|
| 302 | - * |
|
| 303 | - * @since 3.18.0 |
|
| 304 | - */ |
|
| 305 | - const FIELD_VALID_FROM = 'wl_schema_valid_from'; |
|
| 306 | - |
|
| 307 | - /** |
|
| 308 | - * The 'priceValidUntil' field name. |
|
| 309 | - * |
|
| 310 | - * @since 3.18.0 |
|
| 311 | - */ |
|
| 312 | - const FIELD_PRICE_VALID_UNTIL = 'wl_schema_valid_until'; |
|
| 313 | - |
|
| 314 | - /** |
|
| 315 | - * The 'itemOffered' field name. |
|
| 316 | - * |
|
| 317 | - * @since 3.18.0 |
|
| 318 | - */ |
|
| 319 | - const FIELD_ITEM_OFFERED = 'wl_schema_item_offered'; |
|
| 320 | - |
|
| 321 | - /** |
|
| 322 | - * The 'URI' data type name. |
|
| 323 | - * |
|
| 324 | - * @since 3.1.0 |
|
| 325 | - */ |
|
| 326 | - const DATA_TYPE_URI = 'uri'; |
|
| 327 | - |
|
| 328 | - /** |
|
| 329 | - * The 'date' data type name. |
|
| 330 | - * |
|
| 331 | - * @since 3.1.0 |
|
| 332 | - */ |
|
| 333 | - const DATA_TYPE_DATE = 'date'; |
|
| 334 | - |
|
| 335 | - /** |
|
| 336 | - * The 'dateTime' data type name. |
|
| 337 | - * |
|
| 338 | - * @since 3.15.0 |
|
| 339 | - */ |
|
| 340 | - const DATA_TYPE_DATE_TIME = 'dateTime'; |
|
| 341 | - |
|
| 342 | - /** |
|
| 343 | - * The 'time' data type name. |
|
| 344 | - * |
|
| 345 | - * @since 3.14.0 |
|
| 346 | - */ |
|
| 347 | - const DATA_TYPE_DURATION = 'duration'; |
|
| 348 | - |
|
| 349 | - /** |
|
| 350 | - * The 'double' data type name. |
|
| 351 | - * |
|
| 352 | - * @since 3.1.0 |
|
| 353 | - */ |
|
| 354 | - const DATA_TYPE_DOUBLE = 'double'; |
|
| 355 | - |
|
| 356 | - /** |
|
| 357 | - * The 'string' data type name. |
|
| 358 | - * |
|
| 359 | - * @since 3.1.0 |
|
| 360 | - */ |
|
| 361 | - const DATA_TYPE_STRING = 'string'; |
|
| 362 | - |
|
| 363 | - /** |
|
| 364 | - * The multiline text data type name. |
|
| 365 | - * |
|
| 366 | - * @since 3.14.0 |
|
| 367 | - */ |
|
| 368 | - const DATA_TYPE_MULTILINE = 'multiline'; |
|
| 369 | - |
|
| 370 | - /** |
|
| 371 | - * The 'integer' data type name. |
|
| 372 | - * |
|
| 373 | - * @since 3.1.0 |
|
| 374 | - */ |
|
| 375 | - const DATA_TYPE_INTEGER = 'int'; |
|
| 376 | - |
|
| 377 | - /** |
|
| 378 | - * The 'boolean' data type name. |
|
| 379 | - * |
|
| 380 | - * @since 3.1.0 |
|
| 381 | - */ |
|
| 382 | - const DATA_TYPE_BOOLEAN = 'bool'; |
|
| 383 | - |
|
| 384 | - /** |
|
| 385 | - * The schema.org Event type URI. |
|
| 386 | - * |
|
| 387 | - * @since 3.1.0 |
|
| 388 | - */ |
|
| 389 | - const SCHEMA_EVENT_TYPE = 'http://schema.org/Event'; |
|
| 390 | - |
|
| 391 | - /** |
|
| 392 | - * The schema.org Offer type URI. |
|
| 393 | - * |
|
| 394 | - * @since 3.18.0 |
|
| 395 | - */ |
|
| 396 | - const SCHEMA_OFFER_TYPE = 'http://schema.org/Offer'; |
|
| 397 | - |
|
| 398 | - /** |
|
| 399 | - * The Schema service singleton instance. |
|
| 400 | - * |
|
| 401 | - * @since 3.1.0 |
|
| 402 | - * @access private |
|
| 403 | - * @var \Wordlift_Schema_Service $instance The Schema service singleton instance. |
|
| 404 | - */ |
|
| 405 | - private static $instance; |
|
| 406 | - |
|
| 407 | - /** |
|
| 408 | - * WordLift's schema. |
|
| 409 | - * |
|
| 410 | - * @since 3.1.0 |
|
| 411 | - * @access private |
|
| 412 | - * @var array $schema WordLift's schema. |
|
| 413 | - */ |
|
| 414 | - private $schema; |
|
| 415 | - |
|
| 416 | - /** |
|
| 417 | - * The Log service. |
|
| 418 | - * |
|
| 419 | - * @since 3.1.0 |
|
| 420 | - * @access private |
|
| 421 | - * @var \Wordlift_Log_Service $log The Log service. |
|
| 422 | - */ |
|
| 423 | - private $log; |
|
| 424 | - |
|
| 425 | - /** |
|
| 426 | - * The {@link Wordlift_Post_Property_Storage_Factory} instance. |
|
| 427 | - * |
|
| 428 | - * @since 3.15.0 |
|
| 429 | - * @access private |
|
| 430 | - * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Post_Property_Storage_Factory} instance. |
|
| 431 | - */ |
|
| 432 | - private $storage_factory; |
|
| 433 | - |
|
| 434 | - /** |
|
| 435 | - * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 436 | - * |
|
| 437 | - * @since 3.15.0 |
|
| 438 | - * @access private |
|
| 439 | - * @var \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 440 | - */ |
|
| 441 | - private $rendition_factory; |
|
| 442 | - |
|
| 443 | - /** |
|
| 444 | - * The {@link Wordlift_Configuration_Service} instance. |
|
| 445 | - * |
|
| 446 | - * @since 3.15.0 |
|
| 447 | - * @access private |
|
| 448 | - * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance. |
|
| 449 | - */ |
|
| 450 | - private $configuration_service; |
|
| 451 | - |
|
| 452 | - /** |
|
| 453 | - * The web site configured language code. |
|
| 454 | - * |
|
| 455 | - * @since 3.15.0 |
|
| 456 | - * @access private |
|
| 457 | - * @var string $language_code The web site configured language code. |
|
| 458 | - */ |
|
| 459 | - private $language_code; |
|
| 460 | - |
|
| 461 | - /** |
|
| 462 | - * Wordlift_Schema_Service constructor. |
|
| 463 | - * |
|
| 464 | - * @since 3.1.0 |
|
| 465 | - * |
|
| 466 | - * @param \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Post_Property_Storage_Factory} instance. |
|
| 467 | - * @param \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 468 | - * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance. |
|
| 469 | - */ |
|
| 470 | - public function __construct( $storage_factory, $rendition_factory, $configuration_service ) { |
|
| 471 | - |
|
| 472 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Schema_Service' ); |
|
| 473 | - |
|
| 474 | - $this->storage_factory = $storage_factory; |
|
| 475 | - $this->rendition_factory = $rendition_factory; |
|
| 476 | - $this->configuration_service = $configuration_service; |
|
| 477 | - $this->language_code = $this->configuration_service->get_language_code(); |
|
| 478 | - |
|
| 479 | - $schemas = array( |
|
| 480 | - 'article' => $this->get_article_schema(), |
|
| 481 | - 'thing' => $this->get_thing_schema(), |
|
| 482 | - 'creative-work' => $this->get_creative_work_schema(), |
|
| 483 | - 'event' => $this->get_event_schema(), |
|
| 484 | - 'organization' => $this->get_organization_schema(), |
|
| 485 | - 'person' => $this->get_person_schema(), |
|
| 486 | - 'place' => $this->get_place_schema(), |
|
| 487 | - 'local-business' => $this->get_local_business_schema(), |
|
| 488 | - 'recipe' => $this->get_recipe_schema(), |
|
| 489 | - 'web-page' => $this->get_web_page_schema(), |
|
| 490 | - 'offer' => $this->get_offer_schema(), |
|
| 491 | - ); |
|
| 492 | - |
|
| 493 | - // Set the taxonomy data. |
|
| 494 | - // Note: parent types must be defined before child types. |
|
| 495 | - /** |
|
| 496 | - * Alter the configured schemas. |
|
| 497 | - * |
|
| 498 | - * Enable 3rd parties to alter WordLift's schemas array. |
|
| 499 | - * |
|
| 500 | - * @since 3.19.1 |
|
| 501 | - * |
|
| 502 | - * @param array $schemas The array of schemas. |
|
| 503 | - */ |
|
| 504 | - $this->schema = apply_filters( 'wl_schemas', $schemas ); |
|
| 505 | - |
|
| 506 | - // Create a singleton instance of the Schema service, useful to provide static functions to global functions. |
|
| 507 | - self::$instance = $this; |
|
| 508 | - |
|
| 509 | - // Hook the `init` to allow plugins to add their schemas. |
|
| 510 | - add_action( 'init', array( $this, 'init' ) ); |
|
| 511 | - |
|
| 512 | - } |
|
| 513 | - |
|
| 514 | - /** |
|
| 515 | - * Hook to the `init`, allow late binding plugins to add their schema. |
|
| 516 | - * |
|
| 517 | - * @since 3.19.2 |
|
| 518 | - */ |
|
| 519 | - public function init() { |
|
| 520 | - |
|
| 521 | - $this->schema = apply_filters( 'wl_schemas_init', $this->schema ); |
|
| 522 | - |
|
| 523 | - } |
|
| 524 | - |
|
| 525 | - /** |
|
| 526 | - * Get a reference to the Schema service. |
|
| 527 | - * |
|
| 528 | - * @since 3.1.0 |
|
| 529 | - * |
|
| 530 | - * @return Wordlift_Schema_Service A reference to the Schema service. |
|
| 531 | - */ |
|
| 532 | - public static function get_instance() { |
|
| 533 | - |
|
| 534 | - return self::$instance; |
|
| 535 | - } |
|
| 536 | - |
|
| 537 | - /** |
|
| 538 | - * Get the properties for a field with the specified key. The key is used as |
|
| 539 | - * meta key when the field's value is stored in WordPress meta data table. |
|
| 540 | - * |
|
| 541 | - * @since 3.6.0 |
|
| 542 | - * |
|
| 543 | - * @param string $key The field's key. |
|
| 544 | - * |
|
| 545 | - * @return null|array An array of field's properties or null if the field is not found. |
|
| 546 | - */ |
|
| 547 | - public function get_field( $key ) { |
|
| 548 | - |
|
| 549 | - // Parse each schema's fields until we find the one we're looking for, then |
|
| 550 | - // return its properties. |
|
| 551 | - foreach ( $this->schema as $_ => $schema ) { |
|
| 552 | - |
|
| 553 | - if ( ! isset( $schema['custom_fields'] ) ) { |
|
| 554 | - break; |
|
| 555 | - } |
|
| 556 | - |
|
| 557 | - foreach ( $schema['custom_fields'] as $field => $props ) { |
|
| 558 | - if ( $key === $field ) { |
|
| 559 | - return $props; |
|
| 560 | - } |
|
| 561 | - } |
|
| 562 | - } |
|
| 563 | - |
|
| 564 | - return null; |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - /** |
|
| 568 | - * Get all renditions for each WordLift's schema. |
|
| 569 | - * |
|
| 570 | - * @since 3.18.0 |
|
| 571 | - * |
|
| 572 | - * @return array An array with the schema renditions. |
|
| 573 | - */ |
|
| 574 | - public function get_renditions() { |
|
| 575 | - // Get the custom fields. |
|
| 576 | - $renditions = array_reduce( |
|
| 577 | - $this->schema, |
|
| 578 | - function ( $carry, $item ) { |
|
| 579 | - return array_merge( $carry, $item['linked_data'] ); |
|
| 580 | - }, |
|
| 581 | - array() |
|
| 582 | - ); |
|
| 583 | - |
|
| 584 | - // Return the schemas. |
|
| 585 | - return $renditions; |
|
| 586 | - } |
|
| 587 | - |
|
| 588 | - /** |
|
| 589 | - * Get the WordLift's schema. |
|
| 590 | - * |
|
| 591 | - * @param string $name The schema name. |
|
| 592 | - * |
|
| 593 | - * @return array|null An array with the schema configuration or NULL if the schema is not found. |
|
| 594 | - * |
|
| 595 | - * @since 3.1.0 |
|
| 596 | - */ |
|
| 597 | - public function get_schema( $name ) { |
|
| 598 | - // Check if the schema exists and, if not, return NULL. |
|
| 599 | - if ( ! isset( $this->schema[ $name ] ) ) { |
|
| 600 | - return null; |
|
| 601 | - } |
|
| 602 | - |
|
| 603 | - // Return the requested schema. |
|
| 604 | - return $this->schema[ $name ]; |
|
| 605 | - } |
|
| 606 | - |
|
| 607 | - /** |
|
| 608 | - * Get the WordLift's schema trough schema type uri. |
|
| 609 | - * |
|
| 610 | - * @param string $uri The schema uri. |
|
| 611 | - * |
|
| 612 | - * @return array|null An array with the schema configuration or NULL if the schema is not found. |
|
| 613 | - * |
|
| 614 | - * @since 3.3.0 |
|
| 615 | - */ |
|
| 616 | - public function get_schema_by_uri( $uri ) { |
|
| 617 | - |
|
| 618 | - foreach ( $this->schema as $name => $schema ) { |
|
| 619 | - if ( $schema['uri'] === $uri ) { |
|
| 620 | - return $schema; |
|
| 621 | - } |
|
| 622 | - } |
|
| 623 | - |
|
| 624 | - return null; |
|
| 625 | - } |
|
| 626 | - |
|
| 627 | - /** |
|
| 628 | - * Get the 'thing' schema. |
|
| 629 | - * |
|
| 630 | - * @return array An array with the schema configuration. |
|
| 631 | - * |
|
| 632 | - * @since 3.1.0 |
|
| 633 | - */ |
|
| 634 | - private function get_thing_schema() { |
|
| 635 | - |
|
| 636 | - return array( |
|
| 637 | - 'css_class' => 'wl-thing', |
|
| 638 | - 'uri' => 'http://schema.org/Thing', |
|
| 639 | - 'same_as' => array( '*' ), |
|
| 640 | - // set as default. |
|
| 641 | - 'custom_fields' => array( |
|
| 642 | - self::FIELD_SAME_AS => array( |
|
| 643 | - 'predicate' => 'http://schema.org/sameAs', |
|
| 644 | - 'type' => self::DATA_TYPE_URI, |
|
| 645 | - 'export_type' => 'http://schema.org/Thing', |
|
| 646 | - 'constraints' => array( |
|
| 647 | - 'cardinality' => INF, |
|
| 648 | - ), |
|
| 649 | - // We need a custom metabox. |
|
| 650 | - 'input_field' => 'sameas', |
|
| 651 | - ), |
|
| 652 | - // Add the schema:url property. |
|
| 653 | - Wordlift_Schema_Url_Property_Service::META_KEY => Wordlift_Schema_Url_Property_Service::get_instance() |
|
| 654 | - ->get_compat_definition(), |
|
| 655 | - ), |
|
| 656 | - // {{sameAs}} not present in the microdata template, |
|
| 657 | - // because it is treated separately in *wl_content_embed_item_microdata* |
|
| 658 | - 'templates' => array( |
|
| 659 | - 'subtitle' => '{{id}}', |
|
| 660 | - ), |
|
| 661 | - 'linked_data' => array( |
|
| 662 | - // ### Title to rdfs:label. |
|
| 663 | - $this->rendition_factory->create( |
|
| 664 | - $this->storage_factory->post_title(), |
|
| 665 | - Wordlift_Query_Builder::RDFS_LABEL_URI, |
|
| 666 | - null, |
|
| 667 | - $this->language_code |
|
| 668 | - ), |
|
| 669 | - // ### Title to dct:title. |
|
| 670 | - $this->rendition_factory->create( |
|
| 671 | - $this->storage_factory->post_title(), |
|
| 672 | - 'http://purl.org/dc/terms/title', |
|
| 673 | - null, |
|
| 674 | - $this->language_code |
|
| 675 | - ), |
|
| 676 | - // ### Alternative title to rdfs:label. |
|
| 677 | - $this->rendition_factory->create( |
|
| 678 | - $this->storage_factory->post_meta( Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY ), |
|
| 679 | - Wordlift_Query_Builder::RDFS_LABEL_URI, |
|
| 680 | - null, |
|
| 681 | - $this->language_code |
|
| 682 | - ), |
|
| 683 | - // ### Alternative title to dct:title. |
|
| 684 | - $this->rendition_factory->create( |
|
| 685 | - $this->storage_factory->post_meta( Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY ), |
|
| 686 | - 'http://purl.org/dc/terms/title', |
|
| 687 | - null, |
|
| 688 | - $this->language_code |
|
| 689 | - ), |
|
| 690 | - // ### Title to schema:name. |
|
| 691 | - $this->rendition_factory->create( |
|
| 692 | - $this->storage_factory->post_title(), |
|
| 693 | - 'http://schema.org/name', |
|
| 694 | - null, |
|
| 695 | - $this->language_code |
|
| 696 | - ), |
|
| 697 | - // ### Alternative title to schema:alterName. |
|
| 698 | - $this->rendition_factory->create( |
|
| 699 | - $this->storage_factory->post_meta( Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY ), |
|
| 700 | - 'http://schema.org/alternateName', |
|
| 701 | - null, |
|
| 702 | - $this->language_code |
|
| 703 | - ), |
|
| 704 | - // ### schema:url. |
|
| 705 | - $this->rendition_factory->create( |
|
| 706 | - $this->storage_factory->url_property(), |
|
| 707 | - Wordlift_Query_Builder::SCHEMA_URL_URI, |
|
| 708 | - self::DATA_TYPE_URI |
|
| 709 | - ), |
|
| 710 | - // ### schema:description. |
|
| 711 | - $this->rendition_factory->create( |
|
| 712 | - $this->storage_factory->post_description_no_tags_no_shortcodes(), |
|
| 713 | - 'http://schema.org/description', |
|
| 714 | - null, |
|
| 715 | - $this->language_code |
|
| 716 | - ), |
|
| 717 | - // ### owl:sameAs. |
|
| 718 | - $this->rendition_factory->create( |
|
| 719 | - $this->storage_factory->post_meta( self::FIELD_SAME_AS ), |
|
| 720 | - 'http://www.w3.org/2002/07/owl#sameAs', |
|
| 721 | - self::DATA_TYPE_URI |
|
| 722 | - ), |
|
| 723 | - // ### schema:sameAs. |
|
| 724 | - $this->rendition_factory->create( |
|
| 725 | - $this->storage_factory->post_meta( self::FIELD_SAME_AS ), |
|
| 726 | - 'http://schema.org/sameAs', |
|
| 727 | - self::DATA_TYPE_URI |
|
| 728 | - ), |
|
| 729 | - // ### rdf:type. |
|
| 730 | - $this->rendition_factory->create( |
|
| 731 | - $this->storage_factory->schema_class(), |
|
| 732 | - Wordlift_Query_Builder::RDFS_TYPE_URI, |
|
| 733 | - self::DATA_TYPE_URI |
|
| 734 | - ), |
|
| 735 | - // ### schema:image. |
|
| 736 | - $this->rendition_factory->create( |
|
| 737 | - $this->storage_factory->post_images(), |
|
| 738 | - Wordlift_Query_Builder::SCHEMA_IMAGE_URI, |
|
| 739 | - self::DATA_TYPE_URI |
|
| 740 | - ), |
|
| 741 | - // ### dct:relation. |
|
| 742 | - $this->rendition_factory->create( |
|
| 743 | - $this->storage_factory->relations(), |
|
| 744 | - Wordlift_Query_Builder::DCTERMS_RELATION_URI, |
|
| 745 | - self::DATA_TYPE_URI |
|
| 746 | - ), |
|
| 747 | - ), |
|
| 748 | - ); |
|
| 749 | - |
|
| 750 | - } |
|
| 751 | - |
|
| 752 | - /** |
|
| 753 | - * Get the 'web-page' schema. |
|
| 754 | - * |
|
| 755 | - * @return array An array with the schema configuration. |
|
| 756 | - * |
|
| 757 | - * @since 3.18.0 |
|
| 758 | - */ |
|
| 759 | - private function get_web_page_schema() { |
|
| 760 | - |
|
| 761 | - return array( |
|
| 762 | - 'css_class' => 'wl-webpage', |
|
| 763 | - 'uri' => 'http://schema.org/WebPage', |
|
| 764 | - 'linked_data' => array( |
|
| 765 | - // ### schema:headline. |
|
| 766 | - $this->rendition_factory->create( |
|
| 767 | - $this->storage_factory->post_title(), |
|
| 768 | - 'http://schema.org/headline', |
|
| 769 | - null, |
|
| 770 | - $this->language_code |
|
| 771 | - ), |
|
| 772 | - // ### schema:url. |
|
| 773 | - $this->rendition_factory->create( |
|
| 774 | - $this->storage_factory->url_property(), |
|
| 775 | - Wordlift_Query_Builder::SCHEMA_URL_URI, |
|
| 776 | - self::DATA_TYPE_URI |
|
| 777 | - ), |
|
| 778 | - // ### rdf:type. |
|
| 779 | - $this->rendition_factory->create( |
|
| 780 | - $this->storage_factory->schema_class(), |
|
| 781 | - Wordlift_Query_Builder::RDFS_TYPE_URI, |
|
| 782 | - self::DATA_TYPE_URI |
|
| 783 | - ), |
|
| 784 | - // ### dcterms:references. |
|
| 785 | - $this->rendition_factory->create( |
|
| 786 | - $this->storage_factory->relations(), |
|
| 787 | - Wordlift_Query_Builder::DCTERMS_REFERENCES_URI, |
|
| 788 | - self::DATA_TYPE_URI, |
|
| 789 | - $this->language_code |
|
| 790 | - ), |
|
| 791 | - ), |
|
| 792 | - ); |
|
| 793 | - |
|
| 794 | - } |
|
| 795 | - |
|
| 796 | - /** |
|
| 797 | - * Get the 'creative work' schema. |
|
| 798 | - * |
|
| 799 | - * @return array An array with the schema configuration. |
|
| 800 | - * |
|
| 801 | - * @since 3.1.0 |
|
| 802 | - */ |
|
| 803 | - private function get_creative_work_schema() { |
|
| 804 | - |
|
| 805 | - $schema = array( |
|
| 806 | - 'label' => 'CreativeWork', |
|
| 807 | - 'description' => 'A creative work (or a Music Album).', |
|
| 808 | - 'parents' => array( 'thing' ), |
|
| 809 | - // Give term slug as parent. |
|
| 810 | - 'css_class' => 'wl-creative-work', |
|
| 811 | - 'uri' => 'http://schema.org/CreativeWork', |
|
| 812 | - 'same_as' => array( |
|
| 813 | - 'http://schema.org/MusicAlbum', |
|
| 814 | - 'http://schema.org/Product', |
|
| 815 | - ), |
|
| 816 | - 'custom_fields' => array( |
|
| 817 | - self::FIELD_AUTHOR => array( |
|
| 818 | - 'predicate' => 'http://schema.org/author', |
|
| 819 | - 'type' => self::DATA_TYPE_URI, |
|
| 820 | - 'export_type' => 'http://schema.org/Person', |
|
| 821 | - 'constraints' => array( |
|
| 822 | - 'uri_type' => array( 'Person', 'Organization' ), |
|
| 823 | - 'cardinality' => INF, |
|
| 824 | - ), |
|
| 825 | - ), |
|
| 826 | - ), |
|
| 827 | - 'linked_data' => array( |
|
| 828 | - // ### schema:author. |
|
| 829 | - $this->rendition_factory->create( |
|
| 830 | - $this->storage_factory->author_uri(), |
|
| 831 | - Wordlift_Query_Builder::SCHEMA_AUTHOR_URI, |
|
| 832 | - self::DATA_TYPE_URI |
|
| 833 | - ), |
|
| 834 | - ), |
|
| 835 | - 'templates' => array( |
|
| 836 | - 'subtitle' => '{{id}}', |
|
| 837 | - ), |
|
| 838 | - ); |
|
| 839 | - |
|
| 840 | - // Merge the custom fields with those provided by the thing schema. |
|
| 841 | - $parent_schema = $this->get_thing_schema(); |
|
| 842 | - $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] ); |
|
| 843 | - $schema['linked_data'] = array_merge( $schema['linked_data'], $parent_schema['linked_data'] ); |
|
| 844 | - |
|
| 845 | - return $schema; |
|
| 846 | - } |
|
| 847 | - |
|
| 848 | - /** |
|
| 849 | - * Get the 'event' schema. |
|
| 850 | - * |
|
| 851 | - * @return array An array with the schema configuration. |
|
| 852 | - * |
|
| 853 | - * @since 3.1.0 |
|
| 854 | - */ |
|
| 855 | - private function get_event_schema() { |
|
| 856 | - |
|
| 857 | - $schema = array( |
|
| 858 | - 'label' => 'Event', |
|
| 859 | - 'description' => 'An event . ', |
|
| 860 | - 'parents' => array( 'thing' ), |
|
| 861 | - 'css_class' => 'wl-event', |
|
| 862 | - 'uri' => self::SCHEMA_EVENT_TYPE, |
|
| 863 | - 'same_as' => array( 'http://dbpedia.org/ontology/Event' ), |
|
| 864 | - 'custom_fields' => array( |
|
| 865 | - self::FIELD_DATE_START => array( |
|
| 866 | - 'predicate' => 'http://schema.org/startDate', |
|
| 867 | - 'type' => self::DATA_TYPE_DATE, |
|
| 868 | - 'export_type' => 'xsd:dateTime', |
|
| 869 | - 'constraints' => '', |
|
| 870 | - ), |
|
| 871 | - self::FIELD_DATE_END => array( |
|
| 872 | - 'predicate' => 'http://schema.org/endDate', |
|
| 873 | - 'type' => self::DATA_TYPE_DATE, |
|
| 874 | - 'export_type' => 'xsd:dateTime', |
|
| 875 | - 'constraints' => '', |
|
| 876 | - ), |
|
| 877 | - self::FIELD_LOCATION => array( |
|
| 878 | - 'predicate' => 'http://schema.org/location', |
|
| 879 | - 'type' => self::DATA_TYPE_URI, |
|
| 880 | - 'export_type' => 'http://schema.org/PostalAddress', |
|
| 881 | - 'constraints' => array( |
|
| 882 | - 'uri_type' => array( 'Place', 'LocalBusiness' ), |
|
| 883 | - 'cardinality' => INF, |
|
| 884 | - ), |
|
| 885 | - ), |
|
| 886 | - self::FIELD_PERFORMER => array( |
|
| 887 | - 'predicate' => 'http://schema.org/performer', |
|
| 888 | - 'type' => self::DATA_TYPE_URI, |
|
| 889 | - 'export_type' => 'http://schema.org/Person', |
|
| 890 | - 'constraints' => array( |
|
| 891 | - 'uri_type' => array( 'Person', 'Organization' ), |
|
| 892 | - 'cardinality' => INF, |
|
| 893 | - ), |
|
| 894 | - ), |
|
| 895 | - self::FIELD_OFFERS => array( |
|
| 896 | - 'predicate' => 'http://schema.org/offers', |
|
| 897 | - 'type' => self::DATA_TYPE_URI, |
|
| 898 | - 'export_type' => 'http://schema.org/Offer', |
|
| 899 | - 'constraints' => array( |
|
| 900 | - 'uri_type' => array( 'Offer' ), |
|
| 901 | - 'cardinality' => INF, |
|
| 902 | - ), |
|
| 903 | - ), |
|
| 904 | - ), |
|
| 905 | - 'linked_data' => array( |
|
| 906 | - // ### schema:startDate. |
|
| 907 | - $this->rendition_factory->create( |
|
| 908 | - $this->storage_factory->post_meta( self::FIELD_DATE_START ), |
|
| 909 | - 'http://schema.org/startDate', |
|
| 910 | - self::DATA_TYPE_DATE_TIME |
|
| 911 | - ), |
|
| 912 | - // ### schema:endDate. |
|
| 913 | - $this->rendition_factory->create( |
|
| 914 | - $this->storage_factory->post_meta( self::FIELD_DATE_END ), |
|
| 915 | - 'http://schema.org/endDate', |
|
| 916 | - self::DATA_TYPE_DATE_TIME |
|
| 917 | - ), |
|
| 918 | - // ### schema:location. |
|
| 919 | - $this->rendition_factory->create( |
|
| 920 | - $this->storage_factory->post_meta_to_uri( self::FIELD_LOCATION ), |
|
| 921 | - 'http://schema.org/location', |
|
| 922 | - self::DATA_TYPE_URI |
|
| 923 | - ), |
|
| 924 | - // ### schema:performer. |
|
| 925 | - $this->rendition_factory->create( |
|
| 926 | - $this->storage_factory->post_meta_to_uri( self::FIELD_PERFORMER ), |
|
| 927 | - 'http://schema.org/performer', |
|
| 928 | - self::DATA_TYPE_URI |
|
| 929 | - ), |
|
| 930 | - // ### schema:offers. |
|
| 931 | - $this->rendition_factory->create( |
|
| 932 | - $this->storage_factory->post_meta_to_uri( self::FIELD_OFFERS ), |
|
| 933 | - 'http://schema.org/offers', |
|
| 934 | - self::DATA_TYPE_URI |
|
| 935 | - ), |
|
| 936 | - ), |
|
| 937 | - 'templates' => array( |
|
| 938 | - 'subtitle' => '{{id}}', |
|
| 939 | - ), |
|
| 940 | - ); |
|
| 941 | - |
|
| 942 | - // Merge the custom fields with those provided by the thing schema. |
|
| 943 | - $parent_schema = $this->get_thing_schema(); |
|
| 944 | - $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] ); |
|
| 945 | - $schema['linked_data'] = array_merge( $schema['linked_data'], $parent_schema['linked_data'] ); |
|
| 946 | - |
|
| 947 | - return $schema; |
|
| 948 | - } |
|
| 949 | - |
|
| 950 | - /** |
|
| 951 | - * Get the 'organization' schema. |
|
| 952 | - * |
|
| 953 | - * @return array An array with the schema configuration. |
|
| 954 | - * |
|
| 955 | - * @since 3.1.0 |
|
| 956 | - */ |
|
| 957 | - private function get_organization_schema() { |
|
| 958 | - |
|
| 959 | - $schema = array( |
|
| 960 | - 'label' => 'Organization', |
|
| 961 | - 'description' => 'An organization, including a government or a newspaper.', |
|
| 962 | - 'parents' => array( 'thing' ), |
|
| 963 | - 'css_class' => 'wl-organization', |
|
| 964 | - 'uri' => 'http://schema.org/Organization', |
|
| 965 | - 'same_as' => array( |
|
| 966 | - 'http://rdf.freebase.com/ns/organization.organization', |
|
| 967 | - 'http://rdf.freebase.com/ns/government.government', |
|
| 968 | - 'http://schema.org/Newspaper', |
|
| 969 | - ), |
|
| 970 | - 'custom_fields' => array( |
|
| 971 | - self::FIELD_LEGAL_NAME => array( |
|
| 972 | - 'predicate' => 'http://schema.org/legalName', |
|
| 973 | - 'type' => self::DATA_TYPE_STRING, |
|
| 974 | - 'export_type' => 'xsd:string', |
|
| 975 | - 'constraints' => '', |
|
| 976 | - ), |
|
| 977 | - self::FIELD_FOUNDER => array( |
|
| 978 | - 'predicate' => 'http://schema.org/founder', |
|
| 979 | - 'type' => self::DATA_TYPE_URI, |
|
| 980 | - 'export_type' => 'http://schema.org/Person', |
|
| 981 | - 'constraints' => array( |
|
| 982 | - 'uri_type' => 'Person', |
|
| 983 | - 'cardinality' => INF, |
|
| 984 | - ), |
|
| 985 | - ), |
|
| 986 | - self::FIELD_ADDRESS => array( |
|
| 987 | - 'predicate' => 'http://schema.org/streetAddress', |
|
| 988 | - 'type' => self::DATA_TYPE_STRING, |
|
| 989 | - 'export_type' => 'xsd:string', |
|
| 990 | - 'constraints' => '', |
|
| 991 | - // To build custom metabox. |
|
| 992 | - 'input_field' => 'address', |
|
| 993 | - ), |
|
| 994 | - self::FIELD_ADDRESS_PO_BOX => array( |
|
| 995 | - 'predicate' => 'http://schema.org/postOfficeBoxNumber', |
|
| 996 | - 'type' => self::DATA_TYPE_STRING, |
|
| 997 | - 'export_type' => 'xsd:string', |
|
| 998 | - 'constraints' => '', |
|
| 999 | - // To build custom metabox. |
|
| 1000 | - 'input_field' => 'address', |
|
| 1001 | - ), |
|
| 1002 | - self::FIELD_ADDRESS_POSTAL_CODE => array( |
|
| 1003 | - 'predicate' => 'http://schema.org/postalCode', |
|
| 1004 | - 'type' => self::DATA_TYPE_STRING, |
|
| 1005 | - 'export_type' => 'xsd:string', |
|
| 1006 | - 'constraints' => '', |
|
| 1007 | - // To build custom metabox. |
|
| 1008 | - 'input_field' => 'address', |
|
| 1009 | - ), |
|
| 1010 | - self::FIELD_ADDRESS_LOCALITY => array( |
|
| 1011 | - 'predicate' => 'http://schema.org/addressLocality', |
|
| 1012 | - 'type' => self::DATA_TYPE_STRING, |
|
| 1013 | - 'export_type' => 'xsd:string', |
|
| 1014 | - 'constraints' => '', |
|
| 1015 | - // To build custom metabox. |
|
| 1016 | - 'input_field' => 'address', |
|
| 1017 | - ), |
|
| 1018 | - self::FIELD_ADDRESS_REGION => array( |
|
| 1019 | - 'predicate' => 'http://schema.org/addressRegion', |
|
| 1020 | - 'type' => self::DATA_TYPE_STRING, |
|
| 1021 | - 'export_type' => 'xsd:string', |
|
| 1022 | - 'constraints' => '', |
|
| 1023 | - // To build custom metabox. |
|
| 1024 | - 'input_field' => 'address', |
|
| 1025 | - ), |
|
| 1026 | - self::FIELD_ADDRESS_COUNTRY => array( |
|
| 1027 | - 'predicate' => 'http://schema.org/addressCountry', |
|
| 1028 | - 'type' => self::DATA_TYPE_STRING, |
|
| 1029 | - 'export_type' => 'xsd:string', |
|
| 1030 | - 'constraints' => '', |
|
| 1031 | - // To build custom metabox. |
|
| 1032 | - 'input_field' => 'address', |
|
| 1033 | - ), |
|
| 1034 | - self::FIELD_EMAIL => array( |
|
| 1035 | - 'predicate' => 'http://schema.org/email', |
|
| 1036 | - 'type' => self::DATA_TYPE_STRING, |
|
| 1037 | - 'export_type' => 'xsd:string', |
|
| 1038 | - 'constraints' => '', |
|
| 1039 | - ), |
|
| 1040 | - self::FIELD_TELEPHONE => array( |
|
| 1041 | - 'predicate' => 'http://schema.org/telephone', |
|
| 1042 | - 'type' => self::DATA_TYPE_STRING, |
|
| 1043 | - 'export_type' => 'xsd:string', |
|
| 1044 | - 'constraints' => '', |
|
| 1045 | - ), |
|
| 1046 | - ), |
|
| 1047 | - 'linked_data' => array( |
|
| 1048 | - // ### schema:legalName. |
|
| 1049 | - $this->rendition_factory->create( |
|
| 1050 | - $this->storage_factory->post_meta( self::FIELD_LEGAL_NAME ), |
|
| 1051 | - 'http://schema.org/legalName' |
|
| 1052 | - ), |
|
| 1053 | - // ### schema:founder. |
|
| 1054 | - $this->rendition_factory->create( |
|
| 1055 | - $this->storage_factory->post_meta_to_uri( self::FIELD_FOUNDER ), |
|
| 1056 | - 'http://schema.org/founder', |
|
| 1057 | - self::DATA_TYPE_URI |
|
| 1058 | - ), |
|
| 1059 | - // ### schema:email. |
|
| 1060 | - $this->rendition_factory->create( |
|
| 1061 | - $this->storage_factory->post_meta( self::FIELD_EMAIL ), |
|
| 1062 | - 'http://schema.org/email' |
|
| 1063 | - ), |
|
| 1064 | - // ### schema:telephone. |
|
| 1065 | - $this->rendition_factory->create( |
|
| 1066 | - $this->storage_factory->post_meta( self::FIELD_TELEPHONE ), |
|
| 1067 | - 'http://schema.org/telephone' |
|
| 1068 | - ), |
|
| 1069 | - ), |
|
| 1070 | - 'templates' => array( |
|
| 1071 | - 'subtitle' => '{{id}}', |
|
| 1072 | - ), |
|
| 1073 | - ); |
|
| 1074 | - |
|
| 1075 | - // Merge the custom fields with those provided by the thing schema. |
|
| 1076 | - $parent_schema = $this->get_thing_schema(); |
|
| 1077 | - $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] ); |
|
| 1078 | - $schema['linked_data'] = array_merge( $schema['linked_data'], $parent_schema['linked_data'] ); |
|
| 1079 | - |
|
| 1080 | - return $schema; |
|
| 1081 | - } |
|
| 1082 | - |
|
| 1083 | - /** |
|
| 1084 | - * Get the 'person' schema. |
|
| 1085 | - * |
|
| 1086 | - * @return array An array with the schema configuration. |
|
| 1087 | - * |
|
| 1088 | - * @since 3.1.0 |
|
| 1089 | - */ |
|
| 1090 | - private function get_person_schema() { |
|
| 1091 | - |
|
| 1092 | - $schema = array( |
|
| 1093 | - 'label' => 'Person', |
|
| 1094 | - 'description' => 'A person (or a music artist).', |
|
| 1095 | - 'parents' => array( 'thing' ), |
|
| 1096 | - 'css_class' => 'wl-person', |
|
| 1097 | - 'uri' => 'http://schema.org/Person', |
|
| 1098 | - 'same_as' => array( |
|
| 1099 | - 'http://rdf.freebase.com/ns/people.person', |
|
| 1100 | - 'http://rdf.freebase.com/ns/music.artist', |
|
| 1101 | - 'http://dbpedia.org/class/yago/LivingPeople', |
|
| 1102 | - ), |
|
| 1103 | - 'custom_fields' => array( |
|
| 1104 | - self::FIELD_KNOWS => array( |
|
| 1105 | - 'predicate' => 'http://schema.org/knows', |
|
| 1106 | - 'type' => self::DATA_TYPE_URI, |
|
| 1107 | - 'export_type' => 'http://schema.org/Person', |
|
| 1108 | - 'constraints' => array( |
|
| 1109 | - 'uri_type' => 'Person', |
|
| 1110 | - 'cardinality' => INF, |
|
| 1111 | - ), |
|
| 1112 | - ), |
|
| 1113 | - self::FIELD_BIRTH_DATE => array( |
|
| 1114 | - 'predicate' => 'http://schema.org/birthDate', |
|
| 1115 | - 'type' => self::DATA_TYPE_DATE, |
|
| 1116 | - 'export_type' => 'xsd:date', |
|
| 1117 | - 'constraints' => '', |
|
| 1118 | - ), |
|
| 1119 | - self::FIELD_BIRTH_PLACE => array( |
|
| 1120 | - 'predicate' => 'http://schema.org/birthPlace', |
|
| 1121 | - 'type' => self::DATA_TYPE_URI, |
|
| 1122 | - 'export_type' => 'http://schema.org/Place', |
|
| 1123 | - 'constraints' => array( |
|
| 1124 | - 'uri_type' => 'Place', |
|
| 1125 | - ), |
|
| 1126 | - ), |
|
| 1127 | - self::FIELD_AFFILIATION => array( |
|
| 1128 | - 'predicate' => 'http://schema.org/affiliation', |
|
| 1129 | - 'type' => self::DATA_TYPE_URI, |
|
| 1130 | - 'export_type' => 'http://schema.org/Organization', |
|
| 1131 | - 'constraints' => array( |
|
| 1132 | - 'uri_type' => array( |
|
| 1133 | - 'Organization', |
|
| 1134 | - 'LocalBusiness', |
|
| 1135 | - ), |
|
| 1136 | - 'cardinality' => INF, |
|
| 1137 | - ), |
|
| 1138 | - ), |
|
| 1139 | - self::FIELD_EMAIL => array( |
|
| 1140 | - 'predicate' => 'http://schema.org/email', |
|
| 1141 | - 'type' => self::DATA_TYPE_STRING, |
|
| 1142 | - 'export_type' => 'xsd:string', |
|
| 1143 | - 'constraints' => array( |
|
| 1144 | - 'cardinality' => INF, |
|
| 1145 | - ), |
|
| 1146 | - ), |
|
| 1147 | - ), |
|
| 1148 | - 'linked_data' => array( |
|
| 1149 | - // ### schema:knows. |
|
| 1150 | - $this->rendition_factory->create( |
|
| 1151 | - $this->storage_factory->post_meta_to_uri( self::FIELD_KNOWS ), |
|
| 1152 | - 'http://schema.org/knows', |
|
| 1153 | - self::DATA_TYPE_URI |
|
| 1154 | - ), |
|
| 1155 | - // ### schema:birthDate. |
|
| 1156 | - $this->rendition_factory->create( |
|
| 1157 | - $this->storage_factory->post_meta( self::FIELD_BIRTH_DATE ), |
|
| 1158 | - 'http://schema.org/birthDate', |
|
| 1159 | - self::DATA_TYPE_DATE |
|
| 1160 | - ), |
|
| 1161 | - // ### schema:birthPlace. |
|
| 1162 | - $this->rendition_factory->create( |
|
| 1163 | - $this->storage_factory->post_meta_to_uri( self::FIELD_BIRTH_PLACE ), |
|
| 1164 | - 'http://schema.org/birthPlace', |
|
| 1165 | - self::DATA_TYPE_URI |
|
| 1166 | - ), |
|
| 1167 | - // ### schema:affiliation. |
|
| 1168 | - $this->rendition_factory->create( |
|
| 1169 | - $this->storage_factory->post_meta_to_uri( self::FIELD_AFFILIATION ), |
|
| 1170 | - 'http://schema.org/affiliation', |
|
| 1171 | - self::DATA_TYPE_URI |
|
| 1172 | - ), |
|
| 1173 | - // ### schema:email. |
|
| 1174 | - $this->rendition_factory->create( |
|
| 1175 | - $this->storage_factory->post_meta( self::FIELD_EMAIL ), |
|
| 1176 | - 'http://schema.org/email' |
|
| 1177 | - ), |
|
| 1178 | - ), |
|
| 1179 | - 'templates' => array( |
|
| 1180 | - 'subtitle' => '{{id}}', |
|
| 1181 | - ), |
|
| 1182 | - ); |
|
| 1183 | - |
|
| 1184 | - // Merge the custom fields with those provided by the thing schema. |
|
| 1185 | - $parent_schema = $this->get_thing_schema(); |
|
| 1186 | - $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] ); |
|
| 1187 | - $schema['linked_data'] = array_merge( $schema['linked_data'], $parent_schema['linked_data'] ); |
|
| 1188 | - |
|
| 1189 | - return $schema; |
|
| 1190 | - |
|
| 1191 | - } |
|
| 1192 | - |
|
| 1193 | - /** |
|
| 1194 | - * Get the 'place' schema. |
|
| 1195 | - * |
|
| 1196 | - * @return array An array with the schema configuration. |
|
| 1197 | - * |
|
| 1198 | - * @since 3.1.0 |
|
| 1199 | - */ |
|
| 1200 | - private function get_place_schema() { |
|
| 1201 | - |
|
| 1202 | - $schema = array( |
|
| 1203 | - 'label' => 'Place', |
|
| 1204 | - 'description' => 'A place.', |
|
| 1205 | - 'parents' => array( 'thing' ), |
|
| 1206 | - 'css_class' => 'wl-place', |
|
| 1207 | - 'uri' => 'http://schema.org/Place', |
|
| 1208 | - 'same_as' => array( |
|
| 1209 | - 'http://rdf.freebase.com/ns/location.location', |
|
| 1210 | - 'http://www.opengis.net/gml/_Feature', |
|
| 1211 | - ), |
|
| 1212 | - 'custom_fields' => array( |
|
| 1213 | - self::FIELD_GEO_LATITUDE => array( |
|
| 1214 | - 'predicate' => 'http://schema.org/latitude', |
|
| 1215 | - 'type' => self::DATA_TYPE_DOUBLE, |
|
| 1216 | - 'export_type' => 'xsd:double', |
|
| 1217 | - 'constraints' => '', |
|
| 1218 | - // To build custom metabox. |
|
| 1219 | - 'input_field' => 'coordinates', |
|
| 1220 | - ), |
|
| 1221 | - self::FIELD_GEO_LONGITUDE => array( |
|
| 1222 | - 'predicate' => 'http://schema.org/longitude', |
|
| 1223 | - 'type' => self::DATA_TYPE_DOUBLE, |
|
| 1224 | - 'export_type' => 'xsd:double', |
|
| 1225 | - 'constraints' => '', |
|
| 1226 | - // To build custom metabox. |
|
| 1227 | - 'input_field' => 'coordinates', |
|
| 1228 | - ), |
|
| 1229 | - self::FIELD_ADDRESS => array( |
|
| 1230 | - 'predicate' => 'http://schema.org/streetAddress', |
|
| 1231 | - 'type' => self::DATA_TYPE_STRING, |
|
| 1232 | - 'export_type' => 'xsd:string', |
|
| 1233 | - 'constraints' => '', |
|
| 1234 | - // To build custom metabox. |
|
| 1235 | - 'input_field' => 'address', |
|
| 1236 | - ), |
|
| 1237 | - self::FIELD_ADDRESS_PO_BOX => array( |
|
| 1238 | - 'predicate' => 'http://schema.org/postOfficeBoxNumber', |
|
| 1239 | - 'type' => self::DATA_TYPE_STRING, |
|
| 1240 | - 'export_type' => 'xsd:string', |
|
| 1241 | - 'constraints' => '', |
|
| 1242 | - // To build custom metabox. |
|
| 1243 | - 'input_field' => 'address', |
|
| 1244 | - ), |
|
| 1245 | - self::FIELD_ADDRESS_POSTAL_CODE => array( |
|
| 1246 | - 'predicate' => 'http://schema.org/postalCode', |
|
| 1247 | - 'type' => self::DATA_TYPE_STRING, |
|
| 1248 | - 'export_type' => 'xsd:string', |
|
| 1249 | - 'constraints' => '', |
|
| 1250 | - // To build custom metabox. |
|
| 1251 | - 'input_field' => 'address', |
|
| 1252 | - ), |
|
| 1253 | - self::FIELD_ADDRESS_LOCALITY => array( |
|
| 1254 | - 'predicate' => 'http://schema.org/addressLocality', |
|
| 1255 | - 'type' => self::DATA_TYPE_STRING, |
|
| 1256 | - 'export_type' => 'xsd:string', |
|
| 1257 | - 'constraints' => '', |
|
| 1258 | - // To build custom metabox. |
|
| 1259 | - 'input_field' => 'address', |
|
| 1260 | - ), |
|
| 1261 | - self::FIELD_ADDRESS_REGION => array( |
|
| 1262 | - 'predicate' => 'http://schema.org/addressRegion', |
|
| 1263 | - 'type' => self::DATA_TYPE_STRING, |
|
| 1264 | - 'export_type' => 'xsd:string', |
|
| 1265 | - 'constraints' => '', |
|
| 1266 | - // To build custom metabox. |
|
| 1267 | - 'input_field' => 'address', |
|
| 1268 | - ), |
|
| 1269 | - self::FIELD_ADDRESS_COUNTRY => array( |
|
| 1270 | - 'predicate' => 'http://schema.org/addressCountry', |
|
| 1271 | - 'type' => self::DATA_TYPE_STRING, |
|
| 1272 | - 'export_type' => 'xsd:string', |
|
| 1273 | - 'constraints' => '', |
|
| 1274 | - // To build custom metabox. |
|
| 1275 | - 'input_field' => 'address', |
|
| 1276 | - ), |
|
| 1277 | - ), |
|
| 1278 | - 'linked_data' => array( |
|
| 1279 | - $this->rendition_factory->create_address( |
|
| 1280 | - $this->storage_factory, |
|
| 1281 | - $this->language_code |
|
| 1282 | - ), |
|
| 1283 | - ), |
|
| 1284 | - 'templates' => array( |
|
| 1285 | - 'subtitle' => '{{id}}', |
|
| 1286 | - ), |
|
| 1287 | - ); |
|
| 1288 | - |
|
| 1289 | - // Merge the custom fields with those provided by the thing schema. |
|
| 1290 | - $parent_schema = $this->get_thing_schema(); |
|
| 1291 | - $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] ); |
|
| 1292 | - $schema['linked_data'] = array_merge( $schema['linked_data'], $parent_schema['linked_data'] ); |
|
| 1293 | - |
|
| 1294 | - return $schema; |
|
| 1295 | - } |
|
| 1296 | - |
|
| 1297 | - /** |
|
| 1298 | - * Get the 'local business' schema. |
|
| 1299 | - * |
|
| 1300 | - * @return array An array with the schema configuration. |
|
| 1301 | - * |
|
| 1302 | - * @since 3.1.0 |
|
| 1303 | - */ |
|
| 1304 | - private function get_local_business_schema() { |
|
| 1305 | - |
|
| 1306 | - $schema = array( |
|
| 1307 | - 'label' => 'LocalBusiness', |
|
| 1308 | - 'description' => 'A local business.', |
|
| 1309 | - 'parents' => array( 'place', 'organization' ), |
|
| 1310 | - 'css_class' => 'wl-local-business', |
|
| 1311 | - 'uri' => 'http://schema.org/LocalBusiness', |
|
| 1312 | - 'same_as' => array( |
|
| 1313 | - 'http://rdf.freebase.com/ns/business/business_location', |
|
| 1314 | - 'https://schema.org/Store', |
|
| 1315 | - ), |
|
| 1316 | - 'custom_fields' => array(), |
|
| 1317 | - 'linked_data' => array(), |
|
| 1318 | - 'templates' => array( |
|
| 1319 | - 'subtitle' => '{{id}}', |
|
| 1320 | - ), |
|
| 1321 | - ); |
|
| 1322 | - |
|
| 1323 | - // Merge the custom fields with those provided by the place and organization schema. |
|
| 1324 | - $place_schema = $this->get_place_schema(); |
|
| 1325 | - $organization_schema = $this->get_organization_schema(); |
|
| 1326 | - $schema['custom_fields'] = array_merge( $schema['custom_fields'], $place_schema['custom_fields'], $organization_schema['custom_fields'] ); |
|
| 1327 | - $schema['linked_data'] = array_merge( $schema['linked_data'], $place_schema['linked_data'], $organization_schema['linked_data'] ); |
|
| 1328 | - |
|
| 1329 | - return $schema; |
|
| 1330 | - } |
|
| 1331 | - |
|
| 1332 | - /** |
|
| 1333 | - * Get the 'recipe' schema. |
|
| 1334 | - * |
|
| 1335 | - * @return array An array with the schema configuration. |
|
| 1336 | - * |
|
| 1337 | - * @since 3.14.0 |
|
| 1338 | - */ |
|
| 1339 | - private function get_recipe_schema() { |
|
| 1340 | - |
|
| 1341 | - $schema = array( |
|
| 1342 | - 'label' => 'Recipe', |
|
| 1343 | - 'description' => 'A Recipe.', |
|
| 1344 | - 'parents' => array( 'CreativeWork' ), |
|
| 1345 | - 'css_class' => 'wl-recipe', |
|
| 1346 | - 'uri' => 'http://schema.org/Recipe', |
|
| 1347 | - 'same_as' => array(), |
|
| 1348 | - 'templates' => array( |
|
| 1349 | - 'subtitle' => '{{id}}', |
|
| 1350 | - ), |
|
| 1351 | - 'custom_fields' => array( |
|
| 1352 | - self::FIELD_RECIPE_CUISINE => array( |
|
| 1353 | - 'predicate' => 'http://schema.org/recipeCuisine', |
|
| 1354 | - 'type' => self::DATA_TYPE_STRING, |
|
| 1355 | - 'export_type' => 'xsd:string', |
|
| 1356 | - 'constraints' => '', |
|
| 1357 | - 'metabox' => array( |
|
| 1358 | - 'label' => __( 'Recipe cuisine', 'wordlift' ), |
|
| 1359 | - ), |
|
| 1360 | - ), |
|
| 1361 | - self::FIELD_RECIPE_INGREDIENT => array( |
|
| 1362 | - 'predicate' => 'http://schema.org/recipeIngredient', |
|
| 1363 | - 'type' => self::DATA_TYPE_STRING, |
|
| 1364 | - 'export_type' => 'xsd:string', |
|
| 1365 | - 'constraints' => array( |
|
| 1366 | - 'cardinality' => INF, |
|
| 1367 | - ), |
|
| 1368 | - 'metabox' => array( |
|
| 1369 | - 'label' => __( 'Recipe ingredient', 'wordlift' ), |
|
| 1370 | - ), |
|
| 1371 | - ), |
|
| 1372 | - self::FIELD_RECIPE_INSTRUCTIONS => array( |
|
| 1373 | - 'predicate' => 'http://schema.org/recipeInstructions', |
|
| 1374 | - 'type' => self::DATA_TYPE_MULTILINE, |
|
| 1375 | - 'export_type' => 'xsd:string', |
|
| 1376 | - 'constraints' => '', |
|
| 1377 | - 'metabox' => array( |
|
| 1378 | - 'class' => 'Wordlift_Metabox_Field_Multiline', |
|
| 1379 | - 'label' => __( 'Recipe instructions', 'wordlift' ), |
|
| 1380 | - ), |
|
| 1381 | - ), |
|
| 1382 | - self::FIELD_RECIPE_YIELD => array( |
|
| 1383 | - 'predicate' => 'http://schema.org/recipeYield', |
|
| 1384 | - 'type' => self::DATA_TYPE_STRING, |
|
| 1385 | - 'export_type' => 'xsd:string', |
|
| 1386 | - 'constraints' => '', |
|
| 1387 | - 'metabox' => array( |
|
| 1388 | - 'label' => __( 'Recipe number of servings', 'wordlift' ), |
|
| 1389 | - ), |
|
| 1390 | - ), |
|
| 1391 | - self::FIELD_RECIPE_INGREDIENT => array( |
|
| 1392 | - 'predicate' => 'http://schema.org/recipeIngredient', |
|
| 1393 | - 'type' => self::DATA_TYPE_STRING, |
|
| 1394 | - 'export_type' => 'xsd:string', |
|
| 1395 | - 'constraints' => array( |
|
| 1396 | - 'cardinality' => INF, |
|
| 1397 | - ), |
|
| 1398 | - 'metabox' => array( |
|
| 1399 | - 'label' => __( 'Recipe ingredient', 'wordlift' ), |
|
| 1400 | - ), |
|
| 1401 | - ), |
|
| 1402 | - self::FIELD_NUTRITION_INFO_CALORIES => array( |
|
| 1403 | - 'predicate' => 'http://schema.org/calories', |
|
| 1404 | - 'type' => self::DATA_TYPE_STRING, |
|
| 1405 | - 'export_type' => 'xsd:string', |
|
| 1406 | - 'constraints' => '', |
|
| 1407 | - 'metabox' => array( |
|
| 1408 | - 'label' => __( 'Calories (e.g. 240 calories)', 'wordlift' ), |
|
| 1409 | - ), |
|
| 1410 | - ), |
|
| 1411 | - self::FIELD_PREP_TIME => array( |
|
| 1412 | - 'predicate' => 'http://schema.org/prepTime', |
|
| 1413 | - 'type' => self::DATA_TYPE_DURATION, |
|
| 1414 | - 'export_type' => 'xsd:time', |
|
| 1415 | - 'constraints' => '', |
|
| 1416 | - 'metabox' => array( |
|
| 1417 | - 'class' => 'Wordlift_Metabox_Field_Duration', |
|
| 1418 | - 'label' => __( 'Recipe preparation time (e.g. 1:30)', 'wordlift' ), |
|
| 1419 | - ), |
|
| 1420 | - ), |
|
| 1421 | - self::FIELD_COOK_TIME => array( |
|
| 1422 | - 'predicate' => 'http://schema.org/cookTime', |
|
| 1423 | - 'type' => self::DATA_TYPE_DURATION, |
|
| 1424 | - 'export_type' => 'xsd:time', |
|
| 1425 | - 'constraints' => '', |
|
| 1426 | - 'metabox' => array( |
|
| 1427 | - 'class' => 'Wordlift_Metabox_Field_Duration', |
|
| 1428 | - 'label' => __( 'Recipe cook time (e.g. 1:30)', 'wordlift' ), |
|
| 1429 | - ), |
|
| 1430 | - ), |
|
| 1431 | - self::FIELD_TOTAL_TIME => array( |
|
| 1432 | - 'predicate' => 'http://schema.org/totalTime', |
|
| 1433 | - 'type' => self::DATA_TYPE_DURATION, |
|
| 1434 | - 'export_type' => 'xsd:time', |
|
| 1435 | - 'constraints' => '', |
|
| 1436 | - 'metabox' => array( |
|
| 1437 | - 'class' => 'Wordlift_Metabox_Field_Duration', |
|
| 1438 | - 'label' => __( 'Recipe total time (e.g. 1:30)', 'wordlift' ), |
|
| 1439 | - ), |
|
| 1440 | - ), |
|
| 1441 | - ), |
|
| 1442 | - 'linked_data' => array( |
|
| 1443 | - // ### schema:recipeCuisine. |
|
| 1444 | - $this->rendition_factory->create( |
|
| 1445 | - $this->storage_factory->post_meta( self::FIELD_RECIPE_CUISINE ), |
|
| 1446 | - 'http://schema.org/recipeCuisine' |
|
| 1447 | - ), |
|
| 1448 | - // ### schema:recipeIngredient. |
|
| 1449 | - $this->rendition_factory->create( |
|
| 1450 | - $this->storage_factory->post_meta( self::FIELD_RECIPE_INGREDIENT ), |
|
| 1451 | - 'http://schema.org/recipeIngredient' |
|
| 1452 | - ), |
|
| 1453 | - // ### schema:recipeInstructions. |
|
| 1454 | - $this->rendition_factory->create( |
|
| 1455 | - $this->storage_factory->post_meta( self::FIELD_RECIPE_INSTRUCTIONS ), |
|
| 1456 | - 'http://schema.org/recipeInstructions' |
|
| 1457 | - ), |
|
| 1458 | - // ### schema:recipeYield. |
|
| 1459 | - $this->rendition_factory->create( |
|
| 1460 | - $this->storage_factory->post_meta( self::FIELD_RECIPE_YIELD ), |
|
| 1461 | - 'http://schema.org/recipeYield' |
|
| 1462 | - ), |
|
| 1463 | - // ### schema:prepTime. |
|
| 1464 | - $this->rendition_factory->create( |
|
| 1465 | - $this->storage_factory->post_meta( self::FIELD_PREP_TIME ), |
|
| 1466 | - 'http://schema.org/prepTime', |
|
| 1467 | - self::DATA_TYPE_DURATION |
|
| 1468 | - ), |
|
| 1469 | - // ### schema:cookTime. |
|
| 1470 | - $this->rendition_factory->create( |
|
| 1471 | - $this->storage_factory->post_meta( self::FIELD_COOK_TIME ), |
|
| 1472 | - 'http://schema.org/cookTime', |
|
| 1473 | - self::DATA_TYPE_DURATION |
|
| 1474 | - ), |
|
| 1475 | - // ### schema:totalTime. |
|
| 1476 | - $this->rendition_factory->create( |
|
| 1477 | - $this->storage_factory->post_meta( self::FIELD_TOTAL_TIME ), |
|
| 1478 | - 'http://schema.org/totalTime', |
|
| 1479 | - self::DATA_TYPE_DURATION |
|
| 1480 | - ), |
|
| 1481 | - ), |
|
| 1482 | - ); |
|
| 1483 | - |
|
| 1484 | - // Merge the custom fields with those provided by the parent schema. |
|
| 1485 | - $parent_schema = $this->get_creative_work_schema(); |
|
| 1486 | - $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] ); |
|
| 1487 | - $schema['linked_data'] = array_merge( $schema['linked_data'], $parent_schema['linked_data'] ); |
|
| 1488 | - |
|
| 1489 | - return $schema; |
|
| 1490 | - } |
|
| 1491 | - |
|
| 1492 | - /** |
|
| 1493 | - * Get the 'offer' schema. |
|
| 1494 | - * |
|
| 1495 | - * @return array An array with the schema configuration. |
|
| 1496 | - * |
|
| 1497 | - * @since 3.18.0 |
|
| 1498 | - */ |
|
| 1499 | - private function get_offer_schema() { |
|
| 1500 | - |
|
| 1501 | - $schema = array( |
|
| 1502 | - 'label' => 'Offer', |
|
| 1503 | - 'description' => 'An offer. ', |
|
| 1504 | - 'parents' => array( 'thing' ), |
|
| 1505 | - 'css_class' => 'wl-offer', |
|
| 1506 | - 'uri' => self::SCHEMA_OFFER_TYPE, |
|
| 1507 | - 'same_as' => array(), |
|
| 1508 | - 'templates' => array( |
|
| 1509 | - 'subtitle' => '{{id}}', |
|
| 1510 | - ), |
|
| 1511 | - 'custom_fields' => array( |
|
| 1512 | - self::FIELD_AVAILABILITY => array( |
|
| 1513 | - 'predicate' => 'http://schema.org/availability', |
|
| 1514 | - 'type' => self::DATA_TYPE_STRING, |
|
| 1515 | - 'export_type' => 'xsd:string', |
|
| 1516 | - 'metabox' => array( |
|
| 1517 | - 'class' => 'Wordlift_Metabox_Field_Select', |
|
| 1518 | - ), |
|
| 1519 | - 'options' => array( |
|
| 1520 | - 'Discontinued' => esc_html__( 'Discontinued', 'wordlift' ), |
|
| 1521 | - 'InStock' => esc_html__( 'In Stock', 'wordlift' ), |
|
| 1522 | - 'InStoreOnly' => esc_html__( 'In Store Only', 'wordlift' ), |
|
| 1523 | - 'LimitedAvailability' => esc_html__( 'Limited Availability', 'wordlift' ), |
|
| 1524 | - 'OnlineOnly' => esc_html__( 'Online Only', 'wordlift' ), |
|
| 1525 | - 'OutOfStock' => esc_html__( 'Out of Stock', 'wordlift' ), |
|
| 1526 | - 'PreOrder' => esc_html__( 'Pre Order', 'wordlift' ), |
|
| 1527 | - 'PreSale' => esc_html__( 'Pre Sale', 'wordlift' ), |
|
| 1528 | - 'SoldOut' => esc_html__( 'Sold Out', 'wordlift' ), |
|
| 1529 | - ), |
|
| 1530 | - ), |
|
| 1531 | - self::FIELD_PRICE => array( |
|
| 1532 | - 'predicate' => 'http://schema.org/price', |
|
| 1533 | - 'type' => self::DATA_TYPE_STRING, |
|
| 1534 | - 'export_type' => 'xsd:integer', |
|
| 1535 | - 'metabox' => array( |
|
| 1536 | - 'class' => 'Wordlift_Metabox_Field_Integer', |
|
| 1537 | - ), |
|
| 1538 | - ), |
|
| 1539 | - self::FIELD_PRICE_CURRENCY => array( |
|
| 1540 | - 'predicate' => 'http://schema.org/priceCurrency', |
|
| 1541 | - 'type' => self::DATA_TYPE_STRING, |
|
| 1542 | - 'export_type' => 'xsd:string', |
|
| 1543 | - ), |
|
| 1544 | - self::FIELD_AVAILABILITY_STARTS => array( |
|
| 1545 | - 'predicate' => 'http://schema.org/availabilityStarts', |
|
| 1546 | - 'type' => self::DATA_TYPE_DATE, |
|
| 1547 | - 'export_type' => 'xsd:dateTime', |
|
| 1548 | - ), |
|
| 1549 | - self::FIELD_AVAILABILITY_ENDS => array( |
|
| 1550 | - 'predicate' => 'http://schema.org/availabilityEnds', |
|
| 1551 | - 'type' => self::DATA_TYPE_DATE, |
|
| 1552 | - 'export_type' => 'xsd:dateTime', |
|
| 1553 | - ), |
|
| 1554 | - self::FIELD_INVENTORY_LEVEL => array( |
|
| 1555 | - 'predicate' => 'http://schema.org/inventoryLevel', |
|
| 1556 | - 'type' => self::DATA_TYPE_STRING, |
|
| 1557 | - 'export_type' => 'xsd:integer', |
|
| 1558 | - 'metabox' => array( |
|
| 1559 | - 'class' => 'Wordlift_Metabox_Field_Integer', |
|
| 1560 | - ), |
|
| 1561 | - ), |
|
| 1562 | - self::FIELD_VALID_FROM => array( |
|
| 1563 | - 'predicate' => 'http://schema.org/validFrom', |
|
| 1564 | - 'type' => self::DATA_TYPE_DATE, |
|
| 1565 | - 'export_type' => 'xsd:dateTime', |
|
| 1566 | - ), |
|
| 1567 | - self::FIELD_PRICE_VALID_UNTIL => array( |
|
| 1568 | - 'predicate' => 'http://schema.org/priceValidUntil', |
|
| 1569 | - 'type' => self::DATA_TYPE_DATE, |
|
| 1570 | - 'export_type' => 'xsd:dateTime', |
|
| 1571 | - ), |
|
| 1572 | - self::FIELD_ITEM_OFFERED => array( |
|
| 1573 | - 'predicate' => 'http://schema.org/itemOffered', |
|
| 1574 | - 'type' => self::DATA_TYPE_URI, |
|
| 1575 | - 'export_type' => 'http://schema.org/Thing', |
|
| 1576 | - 'constraints' => array( |
|
| 1577 | - 'uri_type' => array( |
|
| 1578 | - 'Event', |
|
| 1579 | - 'Thing', |
|
| 1580 | - ), |
|
| 1581 | - 'cardinality' => INF, |
|
| 1582 | - ), |
|
| 1583 | - ), |
|
| 1584 | - ), |
|
| 1585 | - 'linked_data' => array( |
|
| 1586 | - // ### schema:availability. |
|
| 1587 | - $this->rendition_factory->create( |
|
| 1588 | - $this->storage_factory->post_meta( self::FIELD_AVAILABILITY ), |
|
| 1589 | - 'http://schema.org/availability', |
|
| 1590 | - null |
|
| 1591 | - ), |
|
| 1592 | - // ### schema:availabilityStarts. |
|
| 1593 | - $this->rendition_factory->create( |
|
| 1594 | - $this->storage_factory->post_meta( self::FIELD_AVAILABILITY_STARTS ), |
|
| 1595 | - 'http://schema.org/availabilityStarts', |
|
| 1596 | - self::DATA_TYPE_DATE_TIME |
|
| 1597 | - ), |
|
| 1598 | - // ### schema:availabilityEnds. |
|
| 1599 | - $this->rendition_factory->create( |
|
| 1600 | - $this->storage_factory->post_meta( self::FIELD_AVAILABILITY_ENDS ), |
|
| 1601 | - 'http://schema.org/availabilityEnds', |
|
| 1602 | - self::DATA_TYPE_DATE_TIME |
|
| 1603 | - ), |
|
| 1604 | - // ### schema:inventoryLevel. |
|
| 1605 | - $this->rendition_factory->create( |
|
| 1606 | - $this->storage_factory->post_meta( self::FIELD_INVENTORY_LEVEL ), |
|
| 1607 | - 'http://schema.org/inventoryLevel', |
|
| 1608 | - self::DATA_TYPE_INTEGER |
|
| 1609 | - ), |
|
| 1610 | - // ### schema:price. |
|
| 1611 | - $this->rendition_factory->create( |
|
| 1612 | - $this->storage_factory->post_meta( self::FIELD_PRICE ), |
|
| 1613 | - 'http://schema.org/price', |
|
| 1614 | - self::DATA_TYPE_INTEGER |
|
| 1615 | - ), |
|
| 1616 | - // ### schema:priceCurrency. |
|
| 1617 | - $this->rendition_factory->create( |
|
| 1618 | - $this->storage_factory->post_meta( self::FIELD_PRICE_CURRENCY ), |
|
| 1619 | - 'http://schema.org/priceCurrency', |
|
| 1620 | - null |
|
| 1621 | - ), |
|
| 1622 | - // ### schema:validFrom. |
|
| 1623 | - $this->rendition_factory->create( |
|
| 1624 | - $this->storage_factory->post_meta( self::FIELD_VALID_FROM ), |
|
| 1625 | - 'http://schema.org/validFrom', |
|
| 1626 | - null |
|
| 1627 | - ), |
|
| 1628 | - // ### schema:priceValidUntil. |
|
| 1629 | - $this->rendition_factory->create( |
|
| 1630 | - $this->storage_factory->post_meta( self::FIELD_PRICE_VALID_UNTIL ), |
|
| 1631 | - 'http://schema.org/priceValidUntil', |
|
| 1632 | - null |
|
| 1633 | - ), |
|
| 1634 | - // ### schema:itemOffered. |
|
| 1635 | - $this->rendition_factory->create( |
|
| 1636 | - $this->storage_factory->post_meta_to_uri( self::FIELD_ITEM_OFFERED ), |
|
| 1637 | - 'http://schema.org/itemOffered', |
|
| 1638 | - self::DATA_TYPE_URI |
|
| 1639 | - ), |
|
| 1640 | - ), |
|
| 1641 | - ); |
|
| 1642 | - |
|
| 1643 | - // Merge the custom fields with those provided by the thing schema. |
|
| 1644 | - $parent_schema = $this->get_thing_schema(); |
|
| 1645 | - $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] ); |
|
| 1646 | - $schema['linked_data'] = array_merge( $schema['linked_data'], $parent_schema['linked_data'] ); |
|
| 1647 | - |
|
| 1648 | - return $schema; |
|
| 1649 | - } |
|
| 1650 | - |
|
| 1651 | - /** |
|
| 1652 | - * Get the 'article' schema. |
|
| 1653 | - * |
|
| 1654 | - * @return array An array with the schema configuration. |
|
| 1655 | - * |
|
| 1656 | - * @since 3.15.0 |
|
| 1657 | - */ |
|
| 1658 | - private function get_article_schema() { |
|
| 1659 | - |
|
| 1660 | - $schema = array( |
|
| 1661 | - 'label' => 'Article', |
|
| 1662 | - 'description' => 'An Article.', |
|
| 1663 | - 'parents' => array(), |
|
| 1664 | - 'css_class' => 'wl-article', |
|
| 1665 | - 'uri' => 'http://schema.org/Article', |
|
| 1666 | - 'same_as' => array(), |
|
| 1667 | - 'templates' => array( |
|
| 1668 | - 'subtitle' => '{{id}}', |
|
| 1669 | - ), |
|
| 1670 | - 'custom_fields' => array(), |
|
| 1671 | - 'linked_data' => array( |
|
| 1672 | - // ### schema:headline. |
|
| 1673 | - $this->rendition_factory->create( |
|
| 1674 | - $this->storage_factory->post_title(), |
|
| 1675 | - 'http://schema.org/headline', |
|
| 1676 | - null, |
|
| 1677 | - $this->language_code |
|
| 1678 | - ), |
|
| 1679 | - // ### schema:url. |
|
| 1680 | - $this->rendition_factory->create( |
|
| 1681 | - $this->storage_factory->url_property(), |
|
| 1682 | - Wordlift_Query_Builder::SCHEMA_URL_URI, |
|
| 1683 | - self::DATA_TYPE_URI |
|
| 1684 | - ), |
|
| 1685 | - // ### rdf:type. |
|
| 1686 | - $this->rendition_factory->create( |
|
| 1687 | - $this->storage_factory->schema_class(), |
|
| 1688 | - Wordlift_Query_Builder::RDFS_TYPE_URI, |
|
| 1689 | - self::DATA_TYPE_URI |
|
| 1690 | - ), |
|
| 1691 | - // ### dcterms:references. |
|
| 1692 | - $this->rendition_factory->create( |
|
| 1693 | - $this->storage_factory->relations(), |
|
| 1694 | - Wordlift_Query_Builder::DCTERMS_REFERENCES_URI, |
|
| 1695 | - self::DATA_TYPE_URI, |
|
| 1696 | - $this->language_code |
|
| 1697 | - ), |
|
| 1698 | - ), |
|
| 1699 | - ); |
|
| 1700 | - |
|
| 1701 | - return $schema; |
|
| 1702 | - } |
|
| 21 | + /** |
|
| 22 | + * The 'location created' field name. |
|
| 23 | + * |
|
| 24 | + * @since 3.5.0 |
|
| 25 | + */ |
|
| 26 | + const FIELD_LOCATION_CREATED = 'wl_location_created'; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * The 'topic' field name. |
|
| 30 | + * |
|
| 31 | + * @since 3.5.0 |
|
| 32 | + */ |
|
| 33 | + const FIELD_TOPIC = 'wl_topic'; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * The 'author' field name. |
|
| 37 | + * |
|
| 38 | + * @since 3.1.0 |
|
| 39 | + */ |
|
| 40 | + const FIELD_AUTHOR = 'wl_author'; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * The 'same as' field name. |
|
| 44 | + * |
|
| 45 | + * @since 3.1.0 |
|
| 46 | + */ |
|
| 47 | + const FIELD_SAME_AS = 'entity_same_as'; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * The 'date start' field name. |
|
| 51 | + * |
|
| 52 | + * @since 3.1.0 |
|
| 53 | + */ |
|
| 54 | + const FIELD_DATE_START = 'wl_cal_date_start'; |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * The 'date end' field name. |
|
| 58 | + * |
|
| 59 | + * @since 3.1.0 |
|
| 60 | + */ |
|
| 61 | + const FIELD_DATE_END = 'wl_cal_date_end'; |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * The 'location' field name. |
|
| 65 | + * |
|
| 66 | + * @since 3.1.0 |
|
| 67 | + */ |
|
| 68 | + const FIELD_LOCATION = 'wl_location'; |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * The 'founder' field name. |
|
| 72 | + * |
|
| 73 | + * @since 3.1.0 |
|
| 74 | + */ |
|
| 75 | + const FIELD_FOUNDER = 'wl_founder'; |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * The 'knows' field name. |
|
| 79 | + * |
|
| 80 | + * @since 3.1.0 |
|
| 81 | + */ |
|
| 82 | + const FIELD_KNOWS = 'wl_knows'; |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * The 'birth date' field name. |
|
| 86 | + * |
|
| 87 | + * @since 3.1.0 |
|
| 88 | + */ |
|
| 89 | + const FIELD_BIRTH_DATE = 'wl_birth_date'; |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * The 'birth place' field name. |
|
| 93 | + * |
|
| 94 | + * @since 3.1.0 |
|
| 95 | + */ |
|
| 96 | + const FIELD_BIRTH_PLACE = 'wl_birth_place'; |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * The 'latitude' field name. |
|
| 100 | + * |
|
| 101 | + * @since 3.1.0 |
|
| 102 | + */ |
|
| 103 | + const FIELD_GEO_LATITUDE = 'wl_geo_latitude'; |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * The 'longitude' field name. |
|
| 107 | + * |
|
| 108 | + * @since 3.1.0 |
|
| 109 | + */ |
|
| 110 | + const FIELD_GEO_LONGITUDE = 'wl_geo_longitude'; |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * The 'streetAddress' field name. |
|
| 114 | + * |
|
| 115 | + * @since 3.1.0 |
|
| 116 | + */ |
|
| 117 | + const FIELD_ADDRESS = 'wl_address'; |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * The 'postOfficeBoxNumber' field name. |
|
| 121 | + * |
|
| 122 | + * @since 3.3.0 |
|
| 123 | + */ |
|
| 124 | + const FIELD_ADDRESS_PO_BOX = 'wl_address_post_office_box'; |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * The 'postalCode' field name. |
|
| 128 | + * |
|
| 129 | + * @since 3.3.0 |
|
| 130 | + */ |
|
| 131 | + const FIELD_ADDRESS_POSTAL_CODE = 'wl_address_postal_code'; |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * The 'addressLocality' field name. |
|
| 135 | + * |
|
| 136 | + * @since 3.3.0 |
|
| 137 | + */ |
|
| 138 | + const FIELD_ADDRESS_LOCALITY = 'wl_address_locality'; |
|
| 139 | + /** |
|
| 140 | + * The 'addressRegion' field name. |
|
| 141 | + * |
|
| 142 | + * @since 3.3.0 |
|
| 143 | + */ |
|
| 144 | + const FIELD_ADDRESS_REGION = 'wl_address_region'; |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * The 'addressCountry' field name. |
|
| 148 | + * |
|
| 149 | + * @since 3.3.0 |
|
| 150 | + */ |
|
| 151 | + const FIELD_ADDRESS_COUNTRY = 'wl_address_country'; |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * The 'entity type' field name. |
|
| 155 | + * |
|
| 156 | + * @since 3.1.0 |
|
| 157 | + */ |
|
| 158 | + const FIELD_ENTITY_TYPE = 'wl_entity_type_uri'; |
|
| 159 | + |
|
| 160 | + /** |
|
| 161 | + * The 'email' field name. |
|
| 162 | + * |
|
| 163 | + * @since 3.2.0 |
|
| 164 | + */ |
|
| 165 | + const FIELD_EMAIL = 'wl_email'; |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * The 'affiliation' field name. |
|
| 169 | + * |
|
| 170 | + * @since 3.2.0 |
|
| 171 | + */ |
|
| 172 | + const FIELD_AFFILIATION = 'wl_affiliation'; |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * The 'telephone' field name. |
|
| 176 | + * |
|
| 177 | + * @since 3.8.0 |
|
| 178 | + */ |
|
| 179 | + const FIELD_TELEPHONE = 'wl_schema_telephone'; |
|
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * The 'legalName' field name. |
|
| 183 | + * |
|
| 184 | + * @since 3.12.0 |
|
| 185 | + */ |
|
| 186 | + const FIELD_LEGAL_NAME = 'wl_schema_legal_name'; |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * The 'recipeCuisine' field name. |
|
| 190 | + * |
|
| 191 | + * @since 3.14.0 |
|
| 192 | + */ |
|
| 193 | + const FIELD_RECIPE_CUISINE = 'wl_schema_recipe_cuisine'; |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * The 'recipeIngredient' field name. |
|
| 197 | + * |
|
| 198 | + * @since 3.14.0 |
|
| 199 | + */ |
|
| 200 | + const FIELD_RECIPE_INGREDIENT = 'wl_schema_recipe_ingredient'; |
|
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * The 'calories' field name. |
|
| 204 | + * |
|
| 205 | + * @since 3.14.0 |
|
| 206 | + */ |
|
| 207 | + const FIELD_NUTRITION_INFO_CALORIES = 'wl_schema_nutrition_information_calories'; |
|
| 208 | + |
|
| 209 | + /** |
|
| 210 | + * The 'recipeInstructions' field name. |
|
| 211 | + * |
|
| 212 | + * @since 3.14.0 |
|
| 213 | + */ |
|
| 214 | + const FIELD_RECIPE_INSTRUCTIONS = 'wl_schema_recipe_instructions'; |
|
| 215 | + |
|
| 216 | + /** |
|
| 217 | + * The 'recipeYield' field name. |
|
| 218 | + * |
|
| 219 | + * @since 3.14.0 |
|
| 220 | + */ |
|
| 221 | + const FIELD_RECIPE_YIELD = 'wl_schema_recipe_yield'; |
|
| 222 | + |
|
| 223 | + /** |
|
| 224 | + * The 'prepTime' field name. |
|
| 225 | + * |
|
| 226 | + * @since 3.14.0 |
|
| 227 | + */ |
|
| 228 | + const FIELD_PREP_TIME = 'wl_schema_prep_time'; |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * The 'cookTime' field name. |
|
| 232 | + * |
|
| 233 | + * @since 3.14.0 |
|
| 234 | + */ |
|
| 235 | + const FIELD_COOK_TIME = 'wl_schema_cook_time'; |
|
| 236 | + |
|
| 237 | + /** |
|
| 238 | + * The 'totalTime' field name. |
|
| 239 | + * |
|
| 240 | + * @since 3.14.0 |
|
| 241 | + */ |
|
| 242 | + const FIELD_TOTAL_TIME = 'wl_schema_total_time'; |
|
| 243 | + |
|
| 244 | + /** |
|
| 245 | + * The 'performer' field name. |
|
| 246 | + * |
|
| 247 | + * @since 3.18.0 |
|
| 248 | + */ |
|
| 249 | + const FIELD_PERFORMER = 'wl_schema_performer'; |
|
| 250 | + |
|
| 251 | + /** |
|
| 252 | + * The 'offers' field name. |
|
| 253 | + * |
|
| 254 | + * @since 3.18.0 |
|
| 255 | + */ |
|
| 256 | + const FIELD_OFFERS = 'wl_schema_offers'; |
|
| 257 | + |
|
| 258 | + /** |
|
| 259 | + * The 'availablity' field name. |
|
| 260 | + * |
|
| 261 | + * @since 3.18.0 |
|
| 262 | + */ |
|
| 263 | + const FIELD_AVAILABILITY = 'wl_schema_availability'; |
|
| 264 | + |
|
| 265 | + /** |
|
| 266 | + * The 'inventoryLevel' field name. |
|
| 267 | + * |
|
| 268 | + * @since 3.18.0 |
|
| 269 | + */ |
|
| 270 | + const FIELD_INVENTORY_LEVEL = 'wl_schema_inventory_level'; |
|
| 271 | + |
|
| 272 | + /** |
|
| 273 | + * The 'price' field name. |
|
| 274 | + * |
|
| 275 | + * @since 3.18.0 |
|
| 276 | + */ |
|
| 277 | + const FIELD_PRICE = 'wl_schema_price'; |
|
| 278 | + |
|
| 279 | + /** |
|
| 280 | + * The 'priceCurrency' field name. |
|
| 281 | + * |
|
| 282 | + * @since 3.18.0 |
|
| 283 | + */ |
|
| 284 | + const FIELD_PRICE_CURRENCY = 'wl_schema_price_currency'; |
|
| 285 | + |
|
| 286 | + /** |
|
| 287 | + * The 'availabilityStarts' field name. |
|
| 288 | + * |
|
| 289 | + * @since 3.18.0 |
|
| 290 | + */ |
|
| 291 | + const FIELD_AVAILABILITY_STARTS = 'wl_schema_availability_starts'; |
|
| 292 | + |
|
| 293 | + /** |
|
| 294 | + * The 'availabilityEnds' field name. |
|
| 295 | + * |
|
| 296 | + * @since 3.18.0 |
|
| 297 | + */ |
|
| 298 | + const FIELD_AVAILABILITY_ENDS = 'wl_schema_availability_ends'; |
|
| 299 | + |
|
| 300 | + /** |
|
| 301 | + * The 'validFrom' field name. |
|
| 302 | + * |
|
| 303 | + * @since 3.18.0 |
|
| 304 | + */ |
|
| 305 | + const FIELD_VALID_FROM = 'wl_schema_valid_from'; |
|
| 306 | + |
|
| 307 | + /** |
|
| 308 | + * The 'priceValidUntil' field name. |
|
| 309 | + * |
|
| 310 | + * @since 3.18.0 |
|
| 311 | + */ |
|
| 312 | + const FIELD_PRICE_VALID_UNTIL = 'wl_schema_valid_until'; |
|
| 313 | + |
|
| 314 | + /** |
|
| 315 | + * The 'itemOffered' field name. |
|
| 316 | + * |
|
| 317 | + * @since 3.18.0 |
|
| 318 | + */ |
|
| 319 | + const FIELD_ITEM_OFFERED = 'wl_schema_item_offered'; |
|
| 320 | + |
|
| 321 | + /** |
|
| 322 | + * The 'URI' data type name. |
|
| 323 | + * |
|
| 324 | + * @since 3.1.0 |
|
| 325 | + */ |
|
| 326 | + const DATA_TYPE_URI = 'uri'; |
|
| 327 | + |
|
| 328 | + /** |
|
| 329 | + * The 'date' data type name. |
|
| 330 | + * |
|
| 331 | + * @since 3.1.0 |
|
| 332 | + */ |
|
| 333 | + const DATA_TYPE_DATE = 'date'; |
|
| 334 | + |
|
| 335 | + /** |
|
| 336 | + * The 'dateTime' data type name. |
|
| 337 | + * |
|
| 338 | + * @since 3.15.0 |
|
| 339 | + */ |
|
| 340 | + const DATA_TYPE_DATE_TIME = 'dateTime'; |
|
| 341 | + |
|
| 342 | + /** |
|
| 343 | + * The 'time' data type name. |
|
| 344 | + * |
|
| 345 | + * @since 3.14.0 |
|
| 346 | + */ |
|
| 347 | + const DATA_TYPE_DURATION = 'duration'; |
|
| 348 | + |
|
| 349 | + /** |
|
| 350 | + * The 'double' data type name. |
|
| 351 | + * |
|
| 352 | + * @since 3.1.0 |
|
| 353 | + */ |
|
| 354 | + const DATA_TYPE_DOUBLE = 'double'; |
|
| 355 | + |
|
| 356 | + /** |
|
| 357 | + * The 'string' data type name. |
|
| 358 | + * |
|
| 359 | + * @since 3.1.0 |
|
| 360 | + */ |
|
| 361 | + const DATA_TYPE_STRING = 'string'; |
|
| 362 | + |
|
| 363 | + /** |
|
| 364 | + * The multiline text data type name. |
|
| 365 | + * |
|
| 366 | + * @since 3.14.0 |
|
| 367 | + */ |
|
| 368 | + const DATA_TYPE_MULTILINE = 'multiline'; |
|
| 369 | + |
|
| 370 | + /** |
|
| 371 | + * The 'integer' data type name. |
|
| 372 | + * |
|
| 373 | + * @since 3.1.0 |
|
| 374 | + */ |
|
| 375 | + const DATA_TYPE_INTEGER = 'int'; |
|
| 376 | + |
|
| 377 | + /** |
|
| 378 | + * The 'boolean' data type name. |
|
| 379 | + * |
|
| 380 | + * @since 3.1.0 |
|
| 381 | + */ |
|
| 382 | + const DATA_TYPE_BOOLEAN = 'bool'; |
|
| 383 | + |
|
| 384 | + /** |
|
| 385 | + * The schema.org Event type URI. |
|
| 386 | + * |
|
| 387 | + * @since 3.1.0 |
|
| 388 | + */ |
|
| 389 | + const SCHEMA_EVENT_TYPE = 'http://schema.org/Event'; |
|
| 390 | + |
|
| 391 | + /** |
|
| 392 | + * The schema.org Offer type URI. |
|
| 393 | + * |
|
| 394 | + * @since 3.18.0 |
|
| 395 | + */ |
|
| 396 | + const SCHEMA_OFFER_TYPE = 'http://schema.org/Offer'; |
|
| 397 | + |
|
| 398 | + /** |
|
| 399 | + * The Schema service singleton instance. |
|
| 400 | + * |
|
| 401 | + * @since 3.1.0 |
|
| 402 | + * @access private |
|
| 403 | + * @var \Wordlift_Schema_Service $instance The Schema service singleton instance. |
|
| 404 | + */ |
|
| 405 | + private static $instance; |
|
| 406 | + |
|
| 407 | + /** |
|
| 408 | + * WordLift's schema. |
|
| 409 | + * |
|
| 410 | + * @since 3.1.0 |
|
| 411 | + * @access private |
|
| 412 | + * @var array $schema WordLift's schema. |
|
| 413 | + */ |
|
| 414 | + private $schema; |
|
| 415 | + |
|
| 416 | + /** |
|
| 417 | + * The Log service. |
|
| 418 | + * |
|
| 419 | + * @since 3.1.0 |
|
| 420 | + * @access private |
|
| 421 | + * @var \Wordlift_Log_Service $log The Log service. |
|
| 422 | + */ |
|
| 423 | + private $log; |
|
| 424 | + |
|
| 425 | + /** |
|
| 426 | + * The {@link Wordlift_Post_Property_Storage_Factory} instance. |
|
| 427 | + * |
|
| 428 | + * @since 3.15.0 |
|
| 429 | + * @access private |
|
| 430 | + * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Post_Property_Storage_Factory} instance. |
|
| 431 | + */ |
|
| 432 | + private $storage_factory; |
|
| 433 | + |
|
| 434 | + /** |
|
| 435 | + * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 436 | + * |
|
| 437 | + * @since 3.15.0 |
|
| 438 | + * @access private |
|
| 439 | + * @var \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 440 | + */ |
|
| 441 | + private $rendition_factory; |
|
| 442 | + |
|
| 443 | + /** |
|
| 444 | + * The {@link Wordlift_Configuration_Service} instance. |
|
| 445 | + * |
|
| 446 | + * @since 3.15.0 |
|
| 447 | + * @access private |
|
| 448 | + * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance. |
|
| 449 | + */ |
|
| 450 | + private $configuration_service; |
|
| 451 | + |
|
| 452 | + /** |
|
| 453 | + * The web site configured language code. |
|
| 454 | + * |
|
| 455 | + * @since 3.15.0 |
|
| 456 | + * @access private |
|
| 457 | + * @var string $language_code The web site configured language code. |
|
| 458 | + */ |
|
| 459 | + private $language_code; |
|
| 460 | + |
|
| 461 | + /** |
|
| 462 | + * Wordlift_Schema_Service constructor. |
|
| 463 | + * |
|
| 464 | + * @since 3.1.0 |
|
| 465 | + * |
|
| 466 | + * @param \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Post_Property_Storage_Factory} instance. |
|
| 467 | + * @param \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 468 | + * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance. |
|
| 469 | + */ |
|
| 470 | + public function __construct( $storage_factory, $rendition_factory, $configuration_service ) { |
|
| 471 | + |
|
| 472 | + $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Schema_Service' ); |
|
| 473 | + |
|
| 474 | + $this->storage_factory = $storage_factory; |
|
| 475 | + $this->rendition_factory = $rendition_factory; |
|
| 476 | + $this->configuration_service = $configuration_service; |
|
| 477 | + $this->language_code = $this->configuration_service->get_language_code(); |
|
| 478 | + |
|
| 479 | + $schemas = array( |
|
| 480 | + 'article' => $this->get_article_schema(), |
|
| 481 | + 'thing' => $this->get_thing_schema(), |
|
| 482 | + 'creative-work' => $this->get_creative_work_schema(), |
|
| 483 | + 'event' => $this->get_event_schema(), |
|
| 484 | + 'organization' => $this->get_organization_schema(), |
|
| 485 | + 'person' => $this->get_person_schema(), |
|
| 486 | + 'place' => $this->get_place_schema(), |
|
| 487 | + 'local-business' => $this->get_local_business_schema(), |
|
| 488 | + 'recipe' => $this->get_recipe_schema(), |
|
| 489 | + 'web-page' => $this->get_web_page_schema(), |
|
| 490 | + 'offer' => $this->get_offer_schema(), |
|
| 491 | + ); |
|
| 492 | + |
|
| 493 | + // Set the taxonomy data. |
|
| 494 | + // Note: parent types must be defined before child types. |
|
| 495 | + /** |
|
| 496 | + * Alter the configured schemas. |
|
| 497 | + * |
|
| 498 | + * Enable 3rd parties to alter WordLift's schemas array. |
|
| 499 | + * |
|
| 500 | + * @since 3.19.1 |
|
| 501 | + * |
|
| 502 | + * @param array $schemas The array of schemas. |
|
| 503 | + */ |
|
| 504 | + $this->schema = apply_filters( 'wl_schemas', $schemas ); |
|
| 505 | + |
|
| 506 | + // Create a singleton instance of the Schema service, useful to provide static functions to global functions. |
|
| 507 | + self::$instance = $this; |
|
| 508 | + |
|
| 509 | + // Hook the `init` to allow plugins to add their schemas. |
|
| 510 | + add_action( 'init', array( $this, 'init' ) ); |
|
| 511 | + |
|
| 512 | + } |
|
| 513 | + |
|
| 514 | + /** |
|
| 515 | + * Hook to the `init`, allow late binding plugins to add their schema. |
|
| 516 | + * |
|
| 517 | + * @since 3.19.2 |
|
| 518 | + */ |
|
| 519 | + public function init() { |
|
| 520 | + |
|
| 521 | + $this->schema = apply_filters( 'wl_schemas_init', $this->schema ); |
|
| 522 | + |
|
| 523 | + } |
|
| 524 | + |
|
| 525 | + /** |
|
| 526 | + * Get a reference to the Schema service. |
|
| 527 | + * |
|
| 528 | + * @since 3.1.0 |
|
| 529 | + * |
|
| 530 | + * @return Wordlift_Schema_Service A reference to the Schema service. |
|
| 531 | + */ |
|
| 532 | + public static function get_instance() { |
|
| 533 | + |
|
| 534 | + return self::$instance; |
|
| 535 | + } |
|
| 536 | + |
|
| 537 | + /** |
|
| 538 | + * Get the properties for a field with the specified key. The key is used as |
|
| 539 | + * meta key when the field's value is stored in WordPress meta data table. |
|
| 540 | + * |
|
| 541 | + * @since 3.6.0 |
|
| 542 | + * |
|
| 543 | + * @param string $key The field's key. |
|
| 544 | + * |
|
| 545 | + * @return null|array An array of field's properties or null if the field is not found. |
|
| 546 | + */ |
|
| 547 | + public function get_field( $key ) { |
|
| 548 | + |
|
| 549 | + // Parse each schema's fields until we find the one we're looking for, then |
|
| 550 | + // return its properties. |
|
| 551 | + foreach ( $this->schema as $_ => $schema ) { |
|
| 552 | + |
|
| 553 | + if ( ! isset( $schema['custom_fields'] ) ) { |
|
| 554 | + break; |
|
| 555 | + } |
|
| 556 | + |
|
| 557 | + foreach ( $schema['custom_fields'] as $field => $props ) { |
|
| 558 | + if ( $key === $field ) { |
|
| 559 | + return $props; |
|
| 560 | + } |
|
| 561 | + } |
|
| 562 | + } |
|
| 563 | + |
|
| 564 | + return null; |
|
| 565 | + } |
|
| 566 | + |
|
| 567 | + /** |
|
| 568 | + * Get all renditions for each WordLift's schema. |
|
| 569 | + * |
|
| 570 | + * @since 3.18.0 |
|
| 571 | + * |
|
| 572 | + * @return array An array with the schema renditions. |
|
| 573 | + */ |
|
| 574 | + public function get_renditions() { |
|
| 575 | + // Get the custom fields. |
|
| 576 | + $renditions = array_reduce( |
|
| 577 | + $this->schema, |
|
| 578 | + function ( $carry, $item ) { |
|
| 579 | + return array_merge( $carry, $item['linked_data'] ); |
|
| 580 | + }, |
|
| 581 | + array() |
|
| 582 | + ); |
|
| 583 | + |
|
| 584 | + // Return the schemas. |
|
| 585 | + return $renditions; |
|
| 586 | + } |
|
| 587 | + |
|
| 588 | + /** |
|
| 589 | + * Get the WordLift's schema. |
|
| 590 | + * |
|
| 591 | + * @param string $name The schema name. |
|
| 592 | + * |
|
| 593 | + * @return array|null An array with the schema configuration or NULL if the schema is not found. |
|
| 594 | + * |
|
| 595 | + * @since 3.1.0 |
|
| 596 | + */ |
|
| 597 | + public function get_schema( $name ) { |
|
| 598 | + // Check if the schema exists and, if not, return NULL. |
|
| 599 | + if ( ! isset( $this->schema[ $name ] ) ) { |
|
| 600 | + return null; |
|
| 601 | + } |
|
| 602 | + |
|
| 603 | + // Return the requested schema. |
|
| 604 | + return $this->schema[ $name ]; |
|
| 605 | + } |
|
| 606 | + |
|
| 607 | + /** |
|
| 608 | + * Get the WordLift's schema trough schema type uri. |
|
| 609 | + * |
|
| 610 | + * @param string $uri The schema uri. |
|
| 611 | + * |
|
| 612 | + * @return array|null An array with the schema configuration or NULL if the schema is not found. |
|
| 613 | + * |
|
| 614 | + * @since 3.3.0 |
|
| 615 | + */ |
|
| 616 | + public function get_schema_by_uri( $uri ) { |
|
| 617 | + |
|
| 618 | + foreach ( $this->schema as $name => $schema ) { |
|
| 619 | + if ( $schema['uri'] === $uri ) { |
|
| 620 | + return $schema; |
|
| 621 | + } |
|
| 622 | + } |
|
| 623 | + |
|
| 624 | + return null; |
|
| 625 | + } |
|
| 626 | + |
|
| 627 | + /** |
|
| 628 | + * Get the 'thing' schema. |
|
| 629 | + * |
|
| 630 | + * @return array An array with the schema configuration. |
|
| 631 | + * |
|
| 632 | + * @since 3.1.0 |
|
| 633 | + */ |
|
| 634 | + private function get_thing_schema() { |
|
| 635 | + |
|
| 636 | + return array( |
|
| 637 | + 'css_class' => 'wl-thing', |
|
| 638 | + 'uri' => 'http://schema.org/Thing', |
|
| 639 | + 'same_as' => array( '*' ), |
|
| 640 | + // set as default. |
|
| 641 | + 'custom_fields' => array( |
|
| 642 | + self::FIELD_SAME_AS => array( |
|
| 643 | + 'predicate' => 'http://schema.org/sameAs', |
|
| 644 | + 'type' => self::DATA_TYPE_URI, |
|
| 645 | + 'export_type' => 'http://schema.org/Thing', |
|
| 646 | + 'constraints' => array( |
|
| 647 | + 'cardinality' => INF, |
|
| 648 | + ), |
|
| 649 | + // We need a custom metabox. |
|
| 650 | + 'input_field' => 'sameas', |
|
| 651 | + ), |
|
| 652 | + // Add the schema:url property. |
|
| 653 | + Wordlift_Schema_Url_Property_Service::META_KEY => Wordlift_Schema_Url_Property_Service::get_instance() |
|
| 654 | + ->get_compat_definition(), |
|
| 655 | + ), |
|
| 656 | + // {{sameAs}} not present in the microdata template, |
|
| 657 | + // because it is treated separately in *wl_content_embed_item_microdata* |
|
| 658 | + 'templates' => array( |
|
| 659 | + 'subtitle' => '{{id}}', |
|
| 660 | + ), |
|
| 661 | + 'linked_data' => array( |
|
| 662 | + // ### Title to rdfs:label. |
|
| 663 | + $this->rendition_factory->create( |
|
| 664 | + $this->storage_factory->post_title(), |
|
| 665 | + Wordlift_Query_Builder::RDFS_LABEL_URI, |
|
| 666 | + null, |
|
| 667 | + $this->language_code |
|
| 668 | + ), |
|
| 669 | + // ### Title to dct:title. |
|
| 670 | + $this->rendition_factory->create( |
|
| 671 | + $this->storage_factory->post_title(), |
|
| 672 | + 'http://purl.org/dc/terms/title', |
|
| 673 | + null, |
|
| 674 | + $this->language_code |
|
| 675 | + ), |
|
| 676 | + // ### Alternative title to rdfs:label. |
|
| 677 | + $this->rendition_factory->create( |
|
| 678 | + $this->storage_factory->post_meta( Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY ), |
|
| 679 | + Wordlift_Query_Builder::RDFS_LABEL_URI, |
|
| 680 | + null, |
|
| 681 | + $this->language_code |
|
| 682 | + ), |
|
| 683 | + // ### Alternative title to dct:title. |
|
| 684 | + $this->rendition_factory->create( |
|
| 685 | + $this->storage_factory->post_meta( Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY ), |
|
| 686 | + 'http://purl.org/dc/terms/title', |
|
| 687 | + null, |
|
| 688 | + $this->language_code |
|
| 689 | + ), |
|
| 690 | + // ### Title to schema:name. |
|
| 691 | + $this->rendition_factory->create( |
|
| 692 | + $this->storage_factory->post_title(), |
|
| 693 | + 'http://schema.org/name', |
|
| 694 | + null, |
|
| 695 | + $this->language_code |
|
| 696 | + ), |
|
| 697 | + // ### Alternative title to schema:alterName. |
|
| 698 | + $this->rendition_factory->create( |
|
| 699 | + $this->storage_factory->post_meta( Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY ), |
|
| 700 | + 'http://schema.org/alternateName', |
|
| 701 | + null, |
|
| 702 | + $this->language_code |
|
| 703 | + ), |
|
| 704 | + // ### schema:url. |
|
| 705 | + $this->rendition_factory->create( |
|
| 706 | + $this->storage_factory->url_property(), |
|
| 707 | + Wordlift_Query_Builder::SCHEMA_URL_URI, |
|
| 708 | + self::DATA_TYPE_URI |
|
| 709 | + ), |
|
| 710 | + // ### schema:description. |
|
| 711 | + $this->rendition_factory->create( |
|
| 712 | + $this->storage_factory->post_description_no_tags_no_shortcodes(), |
|
| 713 | + 'http://schema.org/description', |
|
| 714 | + null, |
|
| 715 | + $this->language_code |
|
| 716 | + ), |
|
| 717 | + // ### owl:sameAs. |
|
| 718 | + $this->rendition_factory->create( |
|
| 719 | + $this->storage_factory->post_meta( self::FIELD_SAME_AS ), |
|
| 720 | + 'http://www.w3.org/2002/07/owl#sameAs', |
|
| 721 | + self::DATA_TYPE_URI |
|
| 722 | + ), |
|
| 723 | + // ### schema:sameAs. |
|
| 724 | + $this->rendition_factory->create( |
|
| 725 | + $this->storage_factory->post_meta( self::FIELD_SAME_AS ), |
|
| 726 | + 'http://schema.org/sameAs', |
|
| 727 | + self::DATA_TYPE_URI |
|
| 728 | + ), |
|
| 729 | + // ### rdf:type. |
|
| 730 | + $this->rendition_factory->create( |
|
| 731 | + $this->storage_factory->schema_class(), |
|
| 732 | + Wordlift_Query_Builder::RDFS_TYPE_URI, |
|
| 733 | + self::DATA_TYPE_URI |
|
| 734 | + ), |
|
| 735 | + // ### schema:image. |
|
| 736 | + $this->rendition_factory->create( |
|
| 737 | + $this->storage_factory->post_images(), |
|
| 738 | + Wordlift_Query_Builder::SCHEMA_IMAGE_URI, |
|
| 739 | + self::DATA_TYPE_URI |
|
| 740 | + ), |
|
| 741 | + // ### dct:relation. |
|
| 742 | + $this->rendition_factory->create( |
|
| 743 | + $this->storage_factory->relations(), |
|
| 744 | + Wordlift_Query_Builder::DCTERMS_RELATION_URI, |
|
| 745 | + self::DATA_TYPE_URI |
|
| 746 | + ), |
|
| 747 | + ), |
|
| 748 | + ); |
|
| 749 | + |
|
| 750 | + } |
|
| 751 | + |
|
| 752 | + /** |
|
| 753 | + * Get the 'web-page' schema. |
|
| 754 | + * |
|
| 755 | + * @return array An array with the schema configuration. |
|
| 756 | + * |
|
| 757 | + * @since 3.18.0 |
|
| 758 | + */ |
|
| 759 | + private function get_web_page_schema() { |
|
| 760 | + |
|
| 761 | + return array( |
|
| 762 | + 'css_class' => 'wl-webpage', |
|
| 763 | + 'uri' => 'http://schema.org/WebPage', |
|
| 764 | + 'linked_data' => array( |
|
| 765 | + // ### schema:headline. |
|
| 766 | + $this->rendition_factory->create( |
|
| 767 | + $this->storage_factory->post_title(), |
|
| 768 | + 'http://schema.org/headline', |
|
| 769 | + null, |
|
| 770 | + $this->language_code |
|
| 771 | + ), |
|
| 772 | + // ### schema:url. |
|
| 773 | + $this->rendition_factory->create( |
|
| 774 | + $this->storage_factory->url_property(), |
|
| 775 | + Wordlift_Query_Builder::SCHEMA_URL_URI, |
|
| 776 | + self::DATA_TYPE_URI |
|
| 777 | + ), |
|
| 778 | + // ### rdf:type. |
|
| 779 | + $this->rendition_factory->create( |
|
| 780 | + $this->storage_factory->schema_class(), |
|
| 781 | + Wordlift_Query_Builder::RDFS_TYPE_URI, |
|
| 782 | + self::DATA_TYPE_URI |
|
| 783 | + ), |
|
| 784 | + // ### dcterms:references. |
|
| 785 | + $this->rendition_factory->create( |
|
| 786 | + $this->storage_factory->relations(), |
|
| 787 | + Wordlift_Query_Builder::DCTERMS_REFERENCES_URI, |
|
| 788 | + self::DATA_TYPE_URI, |
|
| 789 | + $this->language_code |
|
| 790 | + ), |
|
| 791 | + ), |
|
| 792 | + ); |
|
| 793 | + |
|
| 794 | + } |
|
| 795 | + |
|
| 796 | + /** |
|
| 797 | + * Get the 'creative work' schema. |
|
| 798 | + * |
|
| 799 | + * @return array An array with the schema configuration. |
|
| 800 | + * |
|
| 801 | + * @since 3.1.0 |
|
| 802 | + */ |
|
| 803 | + private function get_creative_work_schema() { |
|
| 804 | + |
|
| 805 | + $schema = array( |
|
| 806 | + 'label' => 'CreativeWork', |
|
| 807 | + 'description' => 'A creative work (or a Music Album).', |
|
| 808 | + 'parents' => array( 'thing' ), |
|
| 809 | + // Give term slug as parent. |
|
| 810 | + 'css_class' => 'wl-creative-work', |
|
| 811 | + 'uri' => 'http://schema.org/CreativeWork', |
|
| 812 | + 'same_as' => array( |
|
| 813 | + 'http://schema.org/MusicAlbum', |
|
| 814 | + 'http://schema.org/Product', |
|
| 815 | + ), |
|
| 816 | + 'custom_fields' => array( |
|
| 817 | + self::FIELD_AUTHOR => array( |
|
| 818 | + 'predicate' => 'http://schema.org/author', |
|
| 819 | + 'type' => self::DATA_TYPE_URI, |
|
| 820 | + 'export_type' => 'http://schema.org/Person', |
|
| 821 | + 'constraints' => array( |
|
| 822 | + 'uri_type' => array( 'Person', 'Organization' ), |
|
| 823 | + 'cardinality' => INF, |
|
| 824 | + ), |
|
| 825 | + ), |
|
| 826 | + ), |
|
| 827 | + 'linked_data' => array( |
|
| 828 | + // ### schema:author. |
|
| 829 | + $this->rendition_factory->create( |
|
| 830 | + $this->storage_factory->author_uri(), |
|
| 831 | + Wordlift_Query_Builder::SCHEMA_AUTHOR_URI, |
|
| 832 | + self::DATA_TYPE_URI |
|
| 833 | + ), |
|
| 834 | + ), |
|
| 835 | + 'templates' => array( |
|
| 836 | + 'subtitle' => '{{id}}', |
|
| 837 | + ), |
|
| 838 | + ); |
|
| 839 | + |
|
| 840 | + // Merge the custom fields with those provided by the thing schema. |
|
| 841 | + $parent_schema = $this->get_thing_schema(); |
|
| 842 | + $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] ); |
|
| 843 | + $schema['linked_data'] = array_merge( $schema['linked_data'], $parent_schema['linked_data'] ); |
|
| 844 | + |
|
| 845 | + return $schema; |
|
| 846 | + } |
|
| 847 | + |
|
| 848 | + /** |
|
| 849 | + * Get the 'event' schema. |
|
| 850 | + * |
|
| 851 | + * @return array An array with the schema configuration. |
|
| 852 | + * |
|
| 853 | + * @since 3.1.0 |
|
| 854 | + */ |
|
| 855 | + private function get_event_schema() { |
|
| 856 | + |
|
| 857 | + $schema = array( |
|
| 858 | + 'label' => 'Event', |
|
| 859 | + 'description' => 'An event . ', |
|
| 860 | + 'parents' => array( 'thing' ), |
|
| 861 | + 'css_class' => 'wl-event', |
|
| 862 | + 'uri' => self::SCHEMA_EVENT_TYPE, |
|
| 863 | + 'same_as' => array( 'http://dbpedia.org/ontology/Event' ), |
|
| 864 | + 'custom_fields' => array( |
|
| 865 | + self::FIELD_DATE_START => array( |
|
| 866 | + 'predicate' => 'http://schema.org/startDate', |
|
| 867 | + 'type' => self::DATA_TYPE_DATE, |
|
| 868 | + 'export_type' => 'xsd:dateTime', |
|
| 869 | + 'constraints' => '', |
|
| 870 | + ), |
|
| 871 | + self::FIELD_DATE_END => array( |
|
| 872 | + 'predicate' => 'http://schema.org/endDate', |
|
| 873 | + 'type' => self::DATA_TYPE_DATE, |
|
| 874 | + 'export_type' => 'xsd:dateTime', |
|
| 875 | + 'constraints' => '', |
|
| 876 | + ), |
|
| 877 | + self::FIELD_LOCATION => array( |
|
| 878 | + 'predicate' => 'http://schema.org/location', |
|
| 879 | + 'type' => self::DATA_TYPE_URI, |
|
| 880 | + 'export_type' => 'http://schema.org/PostalAddress', |
|
| 881 | + 'constraints' => array( |
|
| 882 | + 'uri_type' => array( 'Place', 'LocalBusiness' ), |
|
| 883 | + 'cardinality' => INF, |
|
| 884 | + ), |
|
| 885 | + ), |
|
| 886 | + self::FIELD_PERFORMER => array( |
|
| 887 | + 'predicate' => 'http://schema.org/performer', |
|
| 888 | + 'type' => self::DATA_TYPE_URI, |
|
| 889 | + 'export_type' => 'http://schema.org/Person', |
|
| 890 | + 'constraints' => array( |
|
| 891 | + 'uri_type' => array( 'Person', 'Organization' ), |
|
| 892 | + 'cardinality' => INF, |
|
| 893 | + ), |
|
| 894 | + ), |
|
| 895 | + self::FIELD_OFFERS => array( |
|
| 896 | + 'predicate' => 'http://schema.org/offers', |
|
| 897 | + 'type' => self::DATA_TYPE_URI, |
|
| 898 | + 'export_type' => 'http://schema.org/Offer', |
|
| 899 | + 'constraints' => array( |
|
| 900 | + 'uri_type' => array( 'Offer' ), |
|
| 901 | + 'cardinality' => INF, |
|
| 902 | + ), |
|
| 903 | + ), |
|
| 904 | + ), |
|
| 905 | + 'linked_data' => array( |
|
| 906 | + // ### schema:startDate. |
|
| 907 | + $this->rendition_factory->create( |
|
| 908 | + $this->storage_factory->post_meta( self::FIELD_DATE_START ), |
|
| 909 | + 'http://schema.org/startDate', |
|
| 910 | + self::DATA_TYPE_DATE_TIME |
|
| 911 | + ), |
|
| 912 | + // ### schema:endDate. |
|
| 913 | + $this->rendition_factory->create( |
|
| 914 | + $this->storage_factory->post_meta( self::FIELD_DATE_END ), |
|
| 915 | + 'http://schema.org/endDate', |
|
| 916 | + self::DATA_TYPE_DATE_TIME |
|
| 917 | + ), |
|
| 918 | + // ### schema:location. |
|
| 919 | + $this->rendition_factory->create( |
|
| 920 | + $this->storage_factory->post_meta_to_uri( self::FIELD_LOCATION ), |
|
| 921 | + 'http://schema.org/location', |
|
| 922 | + self::DATA_TYPE_URI |
|
| 923 | + ), |
|
| 924 | + // ### schema:performer. |
|
| 925 | + $this->rendition_factory->create( |
|
| 926 | + $this->storage_factory->post_meta_to_uri( self::FIELD_PERFORMER ), |
|
| 927 | + 'http://schema.org/performer', |
|
| 928 | + self::DATA_TYPE_URI |
|
| 929 | + ), |
|
| 930 | + // ### schema:offers. |
|
| 931 | + $this->rendition_factory->create( |
|
| 932 | + $this->storage_factory->post_meta_to_uri( self::FIELD_OFFERS ), |
|
| 933 | + 'http://schema.org/offers', |
|
| 934 | + self::DATA_TYPE_URI |
|
| 935 | + ), |
|
| 936 | + ), |
|
| 937 | + 'templates' => array( |
|
| 938 | + 'subtitle' => '{{id}}', |
|
| 939 | + ), |
|
| 940 | + ); |
|
| 941 | + |
|
| 942 | + // Merge the custom fields with those provided by the thing schema. |
|
| 943 | + $parent_schema = $this->get_thing_schema(); |
|
| 944 | + $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] ); |
|
| 945 | + $schema['linked_data'] = array_merge( $schema['linked_data'], $parent_schema['linked_data'] ); |
|
| 946 | + |
|
| 947 | + return $schema; |
|
| 948 | + } |
|
| 949 | + |
|
| 950 | + /** |
|
| 951 | + * Get the 'organization' schema. |
|
| 952 | + * |
|
| 953 | + * @return array An array with the schema configuration. |
|
| 954 | + * |
|
| 955 | + * @since 3.1.0 |
|
| 956 | + */ |
|
| 957 | + private function get_organization_schema() { |
|
| 958 | + |
|
| 959 | + $schema = array( |
|
| 960 | + 'label' => 'Organization', |
|
| 961 | + 'description' => 'An organization, including a government or a newspaper.', |
|
| 962 | + 'parents' => array( 'thing' ), |
|
| 963 | + 'css_class' => 'wl-organization', |
|
| 964 | + 'uri' => 'http://schema.org/Organization', |
|
| 965 | + 'same_as' => array( |
|
| 966 | + 'http://rdf.freebase.com/ns/organization.organization', |
|
| 967 | + 'http://rdf.freebase.com/ns/government.government', |
|
| 968 | + 'http://schema.org/Newspaper', |
|
| 969 | + ), |
|
| 970 | + 'custom_fields' => array( |
|
| 971 | + self::FIELD_LEGAL_NAME => array( |
|
| 972 | + 'predicate' => 'http://schema.org/legalName', |
|
| 973 | + 'type' => self::DATA_TYPE_STRING, |
|
| 974 | + 'export_type' => 'xsd:string', |
|
| 975 | + 'constraints' => '', |
|
| 976 | + ), |
|
| 977 | + self::FIELD_FOUNDER => array( |
|
| 978 | + 'predicate' => 'http://schema.org/founder', |
|
| 979 | + 'type' => self::DATA_TYPE_URI, |
|
| 980 | + 'export_type' => 'http://schema.org/Person', |
|
| 981 | + 'constraints' => array( |
|
| 982 | + 'uri_type' => 'Person', |
|
| 983 | + 'cardinality' => INF, |
|
| 984 | + ), |
|
| 985 | + ), |
|
| 986 | + self::FIELD_ADDRESS => array( |
|
| 987 | + 'predicate' => 'http://schema.org/streetAddress', |
|
| 988 | + 'type' => self::DATA_TYPE_STRING, |
|
| 989 | + 'export_type' => 'xsd:string', |
|
| 990 | + 'constraints' => '', |
|
| 991 | + // To build custom metabox. |
|
| 992 | + 'input_field' => 'address', |
|
| 993 | + ), |
|
| 994 | + self::FIELD_ADDRESS_PO_BOX => array( |
|
| 995 | + 'predicate' => 'http://schema.org/postOfficeBoxNumber', |
|
| 996 | + 'type' => self::DATA_TYPE_STRING, |
|
| 997 | + 'export_type' => 'xsd:string', |
|
| 998 | + 'constraints' => '', |
|
| 999 | + // To build custom metabox. |
|
| 1000 | + 'input_field' => 'address', |
|
| 1001 | + ), |
|
| 1002 | + self::FIELD_ADDRESS_POSTAL_CODE => array( |
|
| 1003 | + 'predicate' => 'http://schema.org/postalCode', |
|
| 1004 | + 'type' => self::DATA_TYPE_STRING, |
|
| 1005 | + 'export_type' => 'xsd:string', |
|
| 1006 | + 'constraints' => '', |
|
| 1007 | + // To build custom metabox. |
|
| 1008 | + 'input_field' => 'address', |
|
| 1009 | + ), |
|
| 1010 | + self::FIELD_ADDRESS_LOCALITY => array( |
|
| 1011 | + 'predicate' => 'http://schema.org/addressLocality', |
|
| 1012 | + 'type' => self::DATA_TYPE_STRING, |
|
| 1013 | + 'export_type' => 'xsd:string', |
|
| 1014 | + 'constraints' => '', |
|
| 1015 | + // To build custom metabox. |
|
| 1016 | + 'input_field' => 'address', |
|
| 1017 | + ), |
|
| 1018 | + self::FIELD_ADDRESS_REGION => array( |
|
| 1019 | + 'predicate' => 'http://schema.org/addressRegion', |
|
| 1020 | + 'type' => self::DATA_TYPE_STRING, |
|
| 1021 | + 'export_type' => 'xsd:string', |
|
| 1022 | + 'constraints' => '', |
|
| 1023 | + // To build custom metabox. |
|
| 1024 | + 'input_field' => 'address', |
|
| 1025 | + ), |
|
| 1026 | + self::FIELD_ADDRESS_COUNTRY => array( |
|
| 1027 | + 'predicate' => 'http://schema.org/addressCountry', |
|
| 1028 | + 'type' => self::DATA_TYPE_STRING, |
|
| 1029 | + 'export_type' => 'xsd:string', |
|
| 1030 | + 'constraints' => '', |
|
| 1031 | + // To build custom metabox. |
|
| 1032 | + 'input_field' => 'address', |
|
| 1033 | + ), |
|
| 1034 | + self::FIELD_EMAIL => array( |
|
| 1035 | + 'predicate' => 'http://schema.org/email', |
|
| 1036 | + 'type' => self::DATA_TYPE_STRING, |
|
| 1037 | + 'export_type' => 'xsd:string', |
|
| 1038 | + 'constraints' => '', |
|
| 1039 | + ), |
|
| 1040 | + self::FIELD_TELEPHONE => array( |
|
| 1041 | + 'predicate' => 'http://schema.org/telephone', |
|
| 1042 | + 'type' => self::DATA_TYPE_STRING, |
|
| 1043 | + 'export_type' => 'xsd:string', |
|
| 1044 | + 'constraints' => '', |
|
| 1045 | + ), |
|
| 1046 | + ), |
|
| 1047 | + 'linked_data' => array( |
|
| 1048 | + // ### schema:legalName. |
|
| 1049 | + $this->rendition_factory->create( |
|
| 1050 | + $this->storage_factory->post_meta( self::FIELD_LEGAL_NAME ), |
|
| 1051 | + 'http://schema.org/legalName' |
|
| 1052 | + ), |
|
| 1053 | + // ### schema:founder. |
|
| 1054 | + $this->rendition_factory->create( |
|
| 1055 | + $this->storage_factory->post_meta_to_uri( self::FIELD_FOUNDER ), |
|
| 1056 | + 'http://schema.org/founder', |
|
| 1057 | + self::DATA_TYPE_URI |
|
| 1058 | + ), |
|
| 1059 | + // ### schema:email. |
|
| 1060 | + $this->rendition_factory->create( |
|
| 1061 | + $this->storage_factory->post_meta( self::FIELD_EMAIL ), |
|
| 1062 | + 'http://schema.org/email' |
|
| 1063 | + ), |
|
| 1064 | + // ### schema:telephone. |
|
| 1065 | + $this->rendition_factory->create( |
|
| 1066 | + $this->storage_factory->post_meta( self::FIELD_TELEPHONE ), |
|
| 1067 | + 'http://schema.org/telephone' |
|
| 1068 | + ), |
|
| 1069 | + ), |
|
| 1070 | + 'templates' => array( |
|
| 1071 | + 'subtitle' => '{{id}}', |
|
| 1072 | + ), |
|
| 1073 | + ); |
|
| 1074 | + |
|
| 1075 | + // Merge the custom fields with those provided by the thing schema. |
|
| 1076 | + $parent_schema = $this->get_thing_schema(); |
|
| 1077 | + $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] ); |
|
| 1078 | + $schema['linked_data'] = array_merge( $schema['linked_data'], $parent_schema['linked_data'] ); |
|
| 1079 | + |
|
| 1080 | + return $schema; |
|
| 1081 | + } |
|
| 1082 | + |
|
| 1083 | + /** |
|
| 1084 | + * Get the 'person' schema. |
|
| 1085 | + * |
|
| 1086 | + * @return array An array with the schema configuration. |
|
| 1087 | + * |
|
| 1088 | + * @since 3.1.0 |
|
| 1089 | + */ |
|
| 1090 | + private function get_person_schema() { |
|
| 1091 | + |
|
| 1092 | + $schema = array( |
|
| 1093 | + 'label' => 'Person', |
|
| 1094 | + 'description' => 'A person (or a music artist).', |
|
| 1095 | + 'parents' => array( 'thing' ), |
|
| 1096 | + 'css_class' => 'wl-person', |
|
| 1097 | + 'uri' => 'http://schema.org/Person', |
|
| 1098 | + 'same_as' => array( |
|
| 1099 | + 'http://rdf.freebase.com/ns/people.person', |
|
| 1100 | + 'http://rdf.freebase.com/ns/music.artist', |
|
| 1101 | + 'http://dbpedia.org/class/yago/LivingPeople', |
|
| 1102 | + ), |
|
| 1103 | + 'custom_fields' => array( |
|
| 1104 | + self::FIELD_KNOWS => array( |
|
| 1105 | + 'predicate' => 'http://schema.org/knows', |
|
| 1106 | + 'type' => self::DATA_TYPE_URI, |
|
| 1107 | + 'export_type' => 'http://schema.org/Person', |
|
| 1108 | + 'constraints' => array( |
|
| 1109 | + 'uri_type' => 'Person', |
|
| 1110 | + 'cardinality' => INF, |
|
| 1111 | + ), |
|
| 1112 | + ), |
|
| 1113 | + self::FIELD_BIRTH_DATE => array( |
|
| 1114 | + 'predicate' => 'http://schema.org/birthDate', |
|
| 1115 | + 'type' => self::DATA_TYPE_DATE, |
|
| 1116 | + 'export_type' => 'xsd:date', |
|
| 1117 | + 'constraints' => '', |
|
| 1118 | + ), |
|
| 1119 | + self::FIELD_BIRTH_PLACE => array( |
|
| 1120 | + 'predicate' => 'http://schema.org/birthPlace', |
|
| 1121 | + 'type' => self::DATA_TYPE_URI, |
|
| 1122 | + 'export_type' => 'http://schema.org/Place', |
|
| 1123 | + 'constraints' => array( |
|
| 1124 | + 'uri_type' => 'Place', |
|
| 1125 | + ), |
|
| 1126 | + ), |
|
| 1127 | + self::FIELD_AFFILIATION => array( |
|
| 1128 | + 'predicate' => 'http://schema.org/affiliation', |
|
| 1129 | + 'type' => self::DATA_TYPE_URI, |
|
| 1130 | + 'export_type' => 'http://schema.org/Organization', |
|
| 1131 | + 'constraints' => array( |
|
| 1132 | + 'uri_type' => array( |
|
| 1133 | + 'Organization', |
|
| 1134 | + 'LocalBusiness', |
|
| 1135 | + ), |
|
| 1136 | + 'cardinality' => INF, |
|
| 1137 | + ), |
|
| 1138 | + ), |
|
| 1139 | + self::FIELD_EMAIL => array( |
|
| 1140 | + 'predicate' => 'http://schema.org/email', |
|
| 1141 | + 'type' => self::DATA_TYPE_STRING, |
|
| 1142 | + 'export_type' => 'xsd:string', |
|
| 1143 | + 'constraints' => array( |
|
| 1144 | + 'cardinality' => INF, |
|
| 1145 | + ), |
|
| 1146 | + ), |
|
| 1147 | + ), |
|
| 1148 | + 'linked_data' => array( |
|
| 1149 | + // ### schema:knows. |
|
| 1150 | + $this->rendition_factory->create( |
|
| 1151 | + $this->storage_factory->post_meta_to_uri( self::FIELD_KNOWS ), |
|
| 1152 | + 'http://schema.org/knows', |
|
| 1153 | + self::DATA_TYPE_URI |
|
| 1154 | + ), |
|
| 1155 | + // ### schema:birthDate. |
|
| 1156 | + $this->rendition_factory->create( |
|
| 1157 | + $this->storage_factory->post_meta( self::FIELD_BIRTH_DATE ), |
|
| 1158 | + 'http://schema.org/birthDate', |
|
| 1159 | + self::DATA_TYPE_DATE |
|
| 1160 | + ), |
|
| 1161 | + // ### schema:birthPlace. |
|
| 1162 | + $this->rendition_factory->create( |
|
| 1163 | + $this->storage_factory->post_meta_to_uri( self::FIELD_BIRTH_PLACE ), |
|
| 1164 | + 'http://schema.org/birthPlace', |
|
| 1165 | + self::DATA_TYPE_URI |
|
| 1166 | + ), |
|
| 1167 | + // ### schema:affiliation. |
|
| 1168 | + $this->rendition_factory->create( |
|
| 1169 | + $this->storage_factory->post_meta_to_uri( self::FIELD_AFFILIATION ), |
|
| 1170 | + 'http://schema.org/affiliation', |
|
| 1171 | + self::DATA_TYPE_URI |
|
| 1172 | + ), |
|
| 1173 | + // ### schema:email. |
|
| 1174 | + $this->rendition_factory->create( |
|
| 1175 | + $this->storage_factory->post_meta( self::FIELD_EMAIL ), |
|
| 1176 | + 'http://schema.org/email' |
|
| 1177 | + ), |
|
| 1178 | + ), |
|
| 1179 | + 'templates' => array( |
|
| 1180 | + 'subtitle' => '{{id}}', |
|
| 1181 | + ), |
|
| 1182 | + ); |
|
| 1183 | + |
|
| 1184 | + // Merge the custom fields with those provided by the thing schema. |
|
| 1185 | + $parent_schema = $this->get_thing_schema(); |
|
| 1186 | + $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] ); |
|
| 1187 | + $schema['linked_data'] = array_merge( $schema['linked_data'], $parent_schema['linked_data'] ); |
|
| 1188 | + |
|
| 1189 | + return $schema; |
|
| 1190 | + |
|
| 1191 | + } |
|
| 1192 | + |
|
| 1193 | + /** |
|
| 1194 | + * Get the 'place' schema. |
|
| 1195 | + * |
|
| 1196 | + * @return array An array with the schema configuration. |
|
| 1197 | + * |
|
| 1198 | + * @since 3.1.0 |
|
| 1199 | + */ |
|
| 1200 | + private function get_place_schema() { |
|
| 1201 | + |
|
| 1202 | + $schema = array( |
|
| 1203 | + 'label' => 'Place', |
|
| 1204 | + 'description' => 'A place.', |
|
| 1205 | + 'parents' => array( 'thing' ), |
|
| 1206 | + 'css_class' => 'wl-place', |
|
| 1207 | + 'uri' => 'http://schema.org/Place', |
|
| 1208 | + 'same_as' => array( |
|
| 1209 | + 'http://rdf.freebase.com/ns/location.location', |
|
| 1210 | + 'http://www.opengis.net/gml/_Feature', |
|
| 1211 | + ), |
|
| 1212 | + 'custom_fields' => array( |
|
| 1213 | + self::FIELD_GEO_LATITUDE => array( |
|
| 1214 | + 'predicate' => 'http://schema.org/latitude', |
|
| 1215 | + 'type' => self::DATA_TYPE_DOUBLE, |
|
| 1216 | + 'export_type' => 'xsd:double', |
|
| 1217 | + 'constraints' => '', |
|
| 1218 | + // To build custom metabox. |
|
| 1219 | + 'input_field' => 'coordinates', |
|
| 1220 | + ), |
|
| 1221 | + self::FIELD_GEO_LONGITUDE => array( |
|
| 1222 | + 'predicate' => 'http://schema.org/longitude', |
|
| 1223 | + 'type' => self::DATA_TYPE_DOUBLE, |
|
| 1224 | + 'export_type' => 'xsd:double', |
|
| 1225 | + 'constraints' => '', |
|
| 1226 | + // To build custom metabox. |
|
| 1227 | + 'input_field' => 'coordinates', |
|
| 1228 | + ), |
|
| 1229 | + self::FIELD_ADDRESS => array( |
|
| 1230 | + 'predicate' => 'http://schema.org/streetAddress', |
|
| 1231 | + 'type' => self::DATA_TYPE_STRING, |
|
| 1232 | + 'export_type' => 'xsd:string', |
|
| 1233 | + 'constraints' => '', |
|
| 1234 | + // To build custom metabox. |
|
| 1235 | + 'input_field' => 'address', |
|
| 1236 | + ), |
|
| 1237 | + self::FIELD_ADDRESS_PO_BOX => array( |
|
| 1238 | + 'predicate' => 'http://schema.org/postOfficeBoxNumber', |
|
| 1239 | + 'type' => self::DATA_TYPE_STRING, |
|
| 1240 | + 'export_type' => 'xsd:string', |
|
| 1241 | + 'constraints' => '', |
|
| 1242 | + // To build custom metabox. |
|
| 1243 | + 'input_field' => 'address', |
|
| 1244 | + ), |
|
| 1245 | + self::FIELD_ADDRESS_POSTAL_CODE => array( |
|
| 1246 | + 'predicate' => 'http://schema.org/postalCode', |
|
| 1247 | + 'type' => self::DATA_TYPE_STRING, |
|
| 1248 | + 'export_type' => 'xsd:string', |
|
| 1249 | + 'constraints' => '', |
|
| 1250 | + // To build custom metabox. |
|
| 1251 | + 'input_field' => 'address', |
|
| 1252 | + ), |
|
| 1253 | + self::FIELD_ADDRESS_LOCALITY => array( |
|
| 1254 | + 'predicate' => 'http://schema.org/addressLocality', |
|
| 1255 | + 'type' => self::DATA_TYPE_STRING, |
|
| 1256 | + 'export_type' => 'xsd:string', |
|
| 1257 | + 'constraints' => '', |
|
| 1258 | + // To build custom metabox. |
|
| 1259 | + 'input_field' => 'address', |
|
| 1260 | + ), |
|
| 1261 | + self::FIELD_ADDRESS_REGION => array( |
|
| 1262 | + 'predicate' => 'http://schema.org/addressRegion', |
|
| 1263 | + 'type' => self::DATA_TYPE_STRING, |
|
| 1264 | + 'export_type' => 'xsd:string', |
|
| 1265 | + 'constraints' => '', |
|
| 1266 | + // To build custom metabox. |
|
| 1267 | + 'input_field' => 'address', |
|
| 1268 | + ), |
|
| 1269 | + self::FIELD_ADDRESS_COUNTRY => array( |
|
| 1270 | + 'predicate' => 'http://schema.org/addressCountry', |
|
| 1271 | + 'type' => self::DATA_TYPE_STRING, |
|
| 1272 | + 'export_type' => 'xsd:string', |
|
| 1273 | + 'constraints' => '', |
|
| 1274 | + // To build custom metabox. |
|
| 1275 | + 'input_field' => 'address', |
|
| 1276 | + ), |
|
| 1277 | + ), |
|
| 1278 | + 'linked_data' => array( |
|
| 1279 | + $this->rendition_factory->create_address( |
|
| 1280 | + $this->storage_factory, |
|
| 1281 | + $this->language_code |
|
| 1282 | + ), |
|
| 1283 | + ), |
|
| 1284 | + 'templates' => array( |
|
| 1285 | + 'subtitle' => '{{id}}', |
|
| 1286 | + ), |
|
| 1287 | + ); |
|
| 1288 | + |
|
| 1289 | + // Merge the custom fields with those provided by the thing schema. |
|
| 1290 | + $parent_schema = $this->get_thing_schema(); |
|
| 1291 | + $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] ); |
|
| 1292 | + $schema['linked_data'] = array_merge( $schema['linked_data'], $parent_schema['linked_data'] ); |
|
| 1293 | + |
|
| 1294 | + return $schema; |
|
| 1295 | + } |
|
| 1296 | + |
|
| 1297 | + /** |
|
| 1298 | + * Get the 'local business' schema. |
|
| 1299 | + * |
|
| 1300 | + * @return array An array with the schema configuration. |
|
| 1301 | + * |
|
| 1302 | + * @since 3.1.0 |
|
| 1303 | + */ |
|
| 1304 | + private function get_local_business_schema() { |
|
| 1305 | + |
|
| 1306 | + $schema = array( |
|
| 1307 | + 'label' => 'LocalBusiness', |
|
| 1308 | + 'description' => 'A local business.', |
|
| 1309 | + 'parents' => array( 'place', 'organization' ), |
|
| 1310 | + 'css_class' => 'wl-local-business', |
|
| 1311 | + 'uri' => 'http://schema.org/LocalBusiness', |
|
| 1312 | + 'same_as' => array( |
|
| 1313 | + 'http://rdf.freebase.com/ns/business/business_location', |
|
| 1314 | + 'https://schema.org/Store', |
|
| 1315 | + ), |
|
| 1316 | + 'custom_fields' => array(), |
|
| 1317 | + 'linked_data' => array(), |
|
| 1318 | + 'templates' => array( |
|
| 1319 | + 'subtitle' => '{{id}}', |
|
| 1320 | + ), |
|
| 1321 | + ); |
|
| 1322 | + |
|
| 1323 | + // Merge the custom fields with those provided by the place and organization schema. |
|
| 1324 | + $place_schema = $this->get_place_schema(); |
|
| 1325 | + $organization_schema = $this->get_organization_schema(); |
|
| 1326 | + $schema['custom_fields'] = array_merge( $schema['custom_fields'], $place_schema['custom_fields'], $organization_schema['custom_fields'] ); |
|
| 1327 | + $schema['linked_data'] = array_merge( $schema['linked_data'], $place_schema['linked_data'], $organization_schema['linked_data'] ); |
|
| 1328 | + |
|
| 1329 | + return $schema; |
|
| 1330 | + } |
|
| 1331 | + |
|
| 1332 | + /** |
|
| 1333 | + * Get the 'recipe' schema. |
|
| 1334 | + * |
|
| 1335 | + * @return array An array with the schema configuration. |
|
| 1336 | + * |
|
| 1337 | + * @since 3.14.0 |
|
| 1338 | + */ |
|
| 1339 | + private function get_recipe_schema() { |
|
| 1340 | + |
|
| 1341 | + $schema = array( |
|
| 1342 | + 'label' => 'Recipe', |
|
| 1343 | + 'description' => 'A Recipe.', |
|
| 1344 | + 'parents' => array( 'CreativeWork' ), |
|
| 1345 | + 'css_class' => 'wl-recipe', |
|
| 1346 | + 'uri' => 'http://schema.org/Recipe', |
|
| 1347 | + 'same_as' => array(), |
|
| 1348 | + 'templates' => array( |
|
| 1349 | + 'subtitle' => '{{id}}', |
|
| 1350 | + ), |
|
| 1351 | + 'custom_fields' => array( |
|
| 1352 | + self::FIELD_RECIPE_CUISINE => array( |
|
| 1353 | + 'predicate' => 'http://schema.org/recipeCuisine', |
|
| 1354 | + 'type' => self::DATA_TYPE_STRING, |
|
| 1355 | + 'export_type' => 'xsd:string', |
|
| 1356 | + 'constraints' => '', |
|
| 1357 | + 'metabox' => array( |
|
| 1358 | + 'label' => __( 'Recipe cuisine', 'wordlift' ), |
|
| 1359 | + ), |
|
| 1360 | + ), |
|
| 1361 | + self::FIELD_RECIPE_INGREDIENT => array( |
|
| 1362 | + 'predicate' => 'http://schema.org/recipeIngredient', |
|
| 1363 | + 'type' => self::DATA_TYPE_STRING, |
|
| 1364 | + 'export_type' => 'xsd:string', |
|
| 1365 | + 'constraints' => array( |
|
| 1366 | + 'cardinality' => INF, |
|
| 1367 | + ), |
|
| 1368 | + 'metabox' => array( |
|
| 1369 | + 'label' => __( 'Recipe ingredient', 'wordlift' ), |
|
| 1370 | + ), |
|
| 1371 | + ), |
|
| 1372 | + self::FIELD_RECIPE_INSTRUCTIONS => array( |
|
| 1373 | + 'predicate' => 'http://schema.org/recipeInstructions', |
|
| 1374 | + 'type' => self::DATA_TYPE_MULTILINE, |
|
| 1375 | + 'export_type' => 'xsd:string', |
|
| 1376 | + 'constraints' => '', |
|
| 1377 | + 'metabox' => array( |
|
| 1378 | + 'class' => 'Wordlift_Metabox_Field_Multiline', |
|
| 1379 | + 'label' => __( 'Recipe instructions', 'wordlift' ), |
|
| 1380 | + ), |
|
| 1381 | + ), |
|
| 1382 | + self::FIELD_RECIPE_YIELD => array( |
|
| 1383 | + 'predicate' => 'http://schema.org/recipeYield', |
|
| 1384 | + 'type' => self::DATA_TYPE_STRING, |
|
| 1385 | + 'export_type' => 'xsd:string', |
|
| 1386 | + 'constraints' => '', |
|
| 1387 | + 'metabox' => array( |
|
| 1388 | + 'label' => __( 'Recipe number of servings', 'wordlift' ), |
|
| 1389 | + ), |
|
| 1390 | + ), |
|
| 1391 | + self::FIELD_RECIPE_INGREDIENT => array( |
|
| 1392 | + 'predicate' => 'http://schema.org/recipeIngredient', |
|
| 1393 | + 'type' => self::DATA_TYPE_STRING, |
|
| 1394 | + 'export_type' => 'xsd:string', |
|
| 1395 | + 'constraints' => array( |
|
| 1396 | + 'cardinality' => INF, |
|
| 1397 | + ), |
|
| 1398 | + 'metabox' => array( |
|
| 1399 | + 'label' => __( 'Recipe ingredient', 'wordlift' ), |
|
| 1400 | + ), |
|
| 1401 | + ), |
|
| 1402 | + self::FIELD_NUTRITION_INFO_CALORIES => array( |
|
| 1403 | + 'predicate' => 'http://schema.org/calories', |
|
| 1404 | + 'type' => self::DATA_TYPE_STRING, |
|
| 1405 | + 'export_type' => 'xsd:string', |
|
| 1406 | + 'constraints' => '', |
|
| 1407 | + 'metabox' => array( |
|
| 1408 | + 'label' => __( 'Calories (e.g. 240 calories)', 'wordlift' ), |
|
| 1409 | + ), |
|
| 1410 | + ), |
|
| 1411 | + self::FIELD_PREP_TIME => array( |
|
| 1412 | + 'predicate' => 'http://schema.org/prepTime', |
|
| 1413 | + 'type' => self::DATA_TYPE_DURATION, |
|
| 1414 | + 'export_type' => 'xsd:time', |
|
| 1415 | + 'constraints' => '', |
|
| 1416 | + 'metabox' => array( |
|
| 1417 | + 'class' => 'Wordlift_Metabox_Field_Duration', |
|
| 1418 | + 'label' => __( 'Recipe preparation time (e.g. 1:30)', 'wordlift' ), |
|
| 1419 | + ), |
|
| 1420 | + ), |
|
| 1421 | + self::FIELD_COOK_TIME => array( |
|
| 1422 | + 'predicate' => 'http://schema.org/cookTime', |
|
| 1423 | + 'type' => self::DATA_TYPE_DURATION, |
|
| 1424 | + 'export_type' => 'xsd:time', |
|
| 1425 | + 'constraints' => '', |
|
| 1426 | + 'metabox' => array( |
|
| 1427 | + 'class' => 'Wordlift_Metabox_Field_Duration', |
|
| 1428 | + 'label' => __( 'Recipe cook time (e.g. 1:30)', 'wordlift' ), |
|
| 1429 | + ), |
|
| 1430 | + ), |
|
| 1431 | + self::FIELD_TOTAL_TIME => array( |
|
| 1432 | + 'predicate' => 'http://schema.org/totalTime', |
|
| 1433 | + 'type' => self::DATA_TYPE_DURATION, |
|
| 1434 | + 'export_type' => 'xsd:time', |
|
| 1435 | + 'constraints' => '', |
|
| 1436 | + 'metabox' => array( |
|
| 1437 | + 'class' => 'Wordlift_Metabox_Field_Duration', |
|
| 1438 | + 'label' => __( 'Recipe total time (e.g. 1:30)', 'wordlift' ), |
|
| 1439 | + ), |
|
| 1440 | + ), |
|
| 1441 | + ), |
|
| 1442 | + 'linked_data' => array( |
|
| 1443 | + // ### schema:recipeCuisine. |
|
| 1444 | + $this->rendition_factory->create( |
|
| 1445 | + $this->storage_factory->post_meta( self::FIELD_RECIPE_CUISINE ), |
|
| 1446 | + 'http://schema.org/recipeCuisine' |
|
| 1447 | + ), |
|
| 1448 | + // ### schema:recipeIngredient. |
|
| 1449 | + $this->rendition_factory->create( |
|
| 1450 | + $this->storage_factory->post_meta( self::FIELD_RECIPE_INGREDIENT ), |
|
| 1451 | + 'http://schema.org/recipeIngredient' |
|
| 1452 | + ), |
|
| 1453 | + // ### schema:recipeInstructions. |
|
| 1454 | + $this->rendition_factory->create( |
|
| 1455 | + $this->storage_factory->post_meta( self::FIELD_RECIPE_INSTRUCTIONS ), |
|
| 1456 | + 'http://schema.org/recipeInstructions' |
|
| 1457 | + ), |
|
| 1458 | + // ### schema:recipeYield. |
|
| 1459 | + $this->rendition_factory->create( |
|
| 1460 | + $this->storage_factory->post_meta( self::FIELD_RECIPE_YIELD ), |
|
| 1461 | + 'http://schema.org/recipeYield' |
|
| 1462 | + ), |
|
| 1463 | + // ### schema:prepTime. |
|
| 1464 | + $this->rendition_factory->create( |
|
| 1465 | + $this->storage_factory->post_meta( self::FIELD_PREP_TIME ), |
|
| 1466 | + 'http://schema.org/prepTime', |
|
| 1467 | + self::DATA_TYPE_DURATION |
|
| 1468 | + ), |
|
| 1469 | + // ### schema:cookTime. |
|
| 1470 | + $this->rendition_factory->create( |
|
| 1471 | + $this->storage_factory->post_meta( self::FIELD_COOK_TIME ), |
|
| 1472 | + 'http://schema.org/cookTime', |
|
| 1473 | + self::DATA_TYPE_DURATION |
|
| 1474 | + ), |
|
| 1475 | + // ### schema:totalTime. |
|
| 1476 | + $this->rendition_factory->create( |
|
| 1477 | + $this->storage_factory->post_meta( self::FIELD_TOTAL_TIME ), |
|
| 1478 | + 'http://schema.org/totalTime', |
|
| 1479 | + self::DATA_TYPE_DURATION |
|
| 1480 | + ), |
|
| 1481 | + ), |
|
| 1482 | + ); |
|
| 1483 | + |
|
| 1484 | + // Merge the custom fields with those provided by the parent schema. |
|
| 1485 | + $parent_schema = $this->get_creative_work_schema(); |
|
| 1486 | + $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] ); |
|
| 1487 | + $schema['linked_data'] = array_merge( $schema['linked_data'], $parent_schema['linked_data'] ); |
|
| 1488 | + |
|
| 1489 | + return $schema; |
|
| 1490 | + } |
|
| 1491 | + |
|
| 1492 | + /** |
|
| 1493 | + * Get the 'offer' schema. |
|
| 1494 | + * |
|
| 1495 | + * @return array An array with the schema configuration. |
|
| 1496 | + * |
|
| 1497 | + * @since 3.18.0 |
|
| 1498 | + */ |
|
| 1499 | + private function get_offer_schema() { |
|
| 1500 | + |
|
| 1501 | + $schema = array( |
|
| 1502 | + 'label' => 'Offer', |
|
| 1503 | + 'description' => 'An offer. ', |
|
| 1504 | + 'parents' => array( 'thing' ), |
|
| 1505 | + 'css_class' => 'wl-offer', |
|
| 1506 | + 'uri' => self::SCHEMA_OFFER_TYPE, |
|
| 1507 | + 'same_as' => array(), |
|
| 1508 | + 'templates' => array( |
|
| 1509 | + 'subtitle' => '{{id}}', |
|
| 1510 | + ), |
|
| 1511 | + 'custom_fields' => array( |
|
| 1512 | + self::FIELD_AVAILABILITY => array( |
|
| 1513 | + 'predicate' => 'http://schema.org/availability', |
|
| 1514 | + 'type' => self::DATA_TYPE_STRING, |
|
| 1515 | + 'export_type' => 'xsd:string', |
|
| 1516 | + 'metabox' => array( |
|
| 1517 | + 'class' => 'Wordlift_Metabox_Field_Select', |
|
| 1518 | + ), |
|
| 1519 | + 'options' => array( |
|
| 1520 | + 'Discontinued' => esc_html__( 'Discontinued', 'wordlift' ), |
|
| 1521 | + 'InStock' => esc_html__( 'In Stock', 'wordlift' ), |
|
| 1522 | + 'InStoreOnly' => esc_html__( 'In Store Only', 'wordlift' ), |
|
| 1523 | + 'LimitedAvailability' => esc_html__( 'Limited Availability', 'wordlift' ), |
|
| 1524 | + 'OnlineOnly' => esc_html__( 'Online Only', 'wordlift' ), |
|
| 1525 | + 'OutOfStock' => esc_html__( 'Out of Stock', 'wordlift' ), |
|
| 1526 | + 'PreOrder' => esc_html__( 'Pre Order', 'wordlift' ), |
|
| 1527 | + 'PreSale' => esc_html__( 'Pre Sale', 'wordlift' ), |
|
| 1528 | + 'SoldOut' => esc_html__( 'Sold Out', 'wordlift' ), |
|
| 1529 | + ), |
|
| 1530 | + ), |
|
| 1531 | + self::FIELD_PRICE => array( |
|
| 1532 | + 'predicate' => 'http://schema.org/price', |
|
| 1533 | + 'type' => self::DATA_TYPE_STRING, |
|
| 1534 | + 'export_type' => 'xsd:integer', |
|
| 1535 | + 'metabox' => array( |
|
| 1536 | + 'class' => 'Wordlift_Metabox_Field_Integer', |
|
| 1537 | + ), |
|
| 1538 | + ), |
|
| 1539 | + self::FIELD_PRICE_CURRENCY => array( |
|
| 1540 | + 'predicate' => 'http://schema.org/priceCurrency', |
|
| 1541 | + 'type' => self::DATA_TYPE_STRING, |
|
| 1542 | + 'export_type' => 'xsd:string', |
|
| 1543 | + ), |
|
| 1544 | + self::FIELD_AVAILABILITY_STARTS => array( |
|
| 1545 | + 'predicate' => 'http://schema.org/availabilityStarts', |
|
| 1546 | + 'type' => self::DATA_TYPE_DATE, |
|
| 1547 | + 'export_type' => 'xsd:dateTime', |
|
| 1548 | + ), |
|
| 1549 | + self::FIELD_AVAILABILITY_ENDS => array( |
|
| 1550 | + 'predicate' => 'http://schema.org/availabilityEnds', |
|
| 1551 | + 'type' => self::DATA_TYPE_DATE, |
|
| 1552 | + 'export_type' => 'xsd:dateTime', |
|
| 1553 | + ), |
|
| 1554 | + self::FIELD_INVENTORY_LEVEL => array( |
|
| 1555 | + 'predicate' => 'http://schema.org/inventoryLevel', |
|
| 1556 | + 'type' => self::DATA_TYPE_STRING, |
|
| 1557 | + 'export_type' => 'xsd:integer', |
|
| 1558 | + 'metabox' => array( |
|
| 1559 | + 'class' => 'Wordlift_Metabox_Field_Integer', |
|
| 1560 | + ), |
|
| 1561 | + ), |
|
| 1562 | + self::FIELD_VALID_FROM => array( |
|
| 1563 | + 'predicate' => 'http://schema.org/validFrom', |
|
| 1564 | + 'type' => self::DATA_TYPE_DATE, |
|
| 1565 | + 'export_type' => 'xsd:dateTime', |
|
| 1566 | + ), |
|
| 1567 | + self::FIELD_PRICE_VALID_UNTIL => array( |
|
| 1568 | + 'predicate' => 'http://schema.org/priceValidUntil', |
|
| 1569 | + 'type' => self::DATA_TYPE_DATE, |
|
| 1570 | + 'export_type' => 'xsd:dateTime', |
|
| 1571 | + ), |
|
| 1572 | + self::FIELD_ITEM_OFFERED => array( |
|
| 1573 | + 'predicate' => 'http://schema.org/itemOffered', |
|
| 1574 | + 'type' => self::DATA_TYPE_URI, |
|
| 1575 | + 'export_type' => 'http://schema.org/Thing', |
|
| 1576 | + 'constraints' => array( |
|
| 1577 | + 'uri_type' => array( |
|
| 1578 | + 'Event', |
|
| 1579 | + 'Thing', |
|
| 1580 | + ), |
|
| 1581 | + 'cardinality' => INF, |
|
| 1582 | + ), |
|
| 1583 | + ), |
|
| 1584 | + ), |
|
| 1585 | + 'linked_data' => array( |
|
| 1586 | + // ### schema:availability. |
|
| 1587 | + $this->rendition_factory->create( |
|
| 1588 | + $this->storage_factory->post_meta( self::FIELD_AVAILABILITY ), |
|
| 1589 | + 'http://schema.org/availability', |
|
| 1590 | + null |
|
| 1591 | + ), |
|
| 1592 | + // ### schema:availabilityStarts. |
|
| 1593 | + $this->rendition_factory->create( |
|
| 1594 | + $this->storage_factory->post_meta( self::FIELD_AVAILABILITY_STARTS ), |
|
| 1595 | + 'http://schema.org/availabilityStarts', |
|
| 1596 | + self::DATA_TYPE_DATE_TIME |
|
| 1597 | + ), |
|
| 1598 | + // ### schema:availabilityEnds. |
|
| 1599 | + $this->rendition_factory->create( |
|
| 1600 | + $this->storage_factory->post_meta( self::FIELD_AVAILABILITY_ENDS ), |
|
| 1601 | + 'http://schema.org/availabilityEnds', |
|
| 1602 | + self::DATA_TYPE_DATE_TIME |
|
| 1603 | + ), |
|
| 1604 | + // ### schema:inventoryLevel. |
|
| 1605 | + $this->rendition_factory->create( |
|
| 1606 | + $this->storage_factory->post_meta( self::FIELD_INVENTORY_LEVEL ), |
|
| 1607 | + 'http://schema.org/inventoryLevel', |
|
| 1608 | + self::DATA_TYPE_INTEGER |
|
| 1609 | + ), |
|
| 1610 | + // ### schema:price. |
|
| 1611 | + $this->rendition_factory->create( |
|
| 1612 | + $this->storage_factory->post_meta( self::FIELD_PRICE ), |
|
| 1613 | + 'http://schema.org/price', |
|
| 1614 | + self::DATA_TYPE_INTEGER |
|
| 1615 | + ), |
|
| 1616 | + // ### schema:priceCurrency. |
|
| 1617 | + $this->rendition_factory->create( |
|
| 1618 | + $this->storage_factory->post_meta( self::FIELD_PRICE_CURRENCY ), |
|
| 1619 | + 'http://schema.org/priceCurrency', |
|
| 1620 | + null |
|
| 1621 | + ), |
|
| 1622 | + // ### schema:validFrom. |
|
| 1623 | + $this->rendition_factory->create( |
|
| 1624 | + $this->storage_factory->post_meta( self::FIELD_VALID_FROM ), |
|
| 1625 | + 'http://schema.org/validFrom', |
|
| 1626 | + null |
|
| 1627 | + ), |
|
| 1628 | + // ### schema:priceValidUntil. |
|
| 1629 | + $this->rendition_factory->create( |
|
| 1630 | + $this->storage_factory->post_meta( self::FIELD_PRICE_VALID_UNTIL ), |
|
| 1631 | + 'http://schema.org/priceValidUntil', |
|
| 1632 | + null |
|
| 1633 | + ), |
|
| 1634 | + // ### schema:itemOffered. |
|
| 1635 | + $this->rendition_factory->create( |
|
| 1636 | + $this->storage_factory->post_meta_to_uri( self::FIELD_ITEM_OFFERED ), |
|
| 1637 | + 'http://schema.org/itemOffered', |
|
| 1638 | + self::DATA_TYPE_URI |
|
| 1639 | + ), |
|
| 1640 | + ), |
|
| 1641 | + ); |
|
| 1642 | + |
|
| 1643 | + // Merge the custom fields with those provided by the thing schema. |
|
| 1644 | + $parent_schema = $this->get_thing_schema(); |
|
| 1645 | + $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] ); |
|
| 1646 | + $schema['linked_data'] = array_merge( $schema['linked_data'], $parent_schema['linked_data'] ); |
|
| 1647 | + |
|
| 1648 | + return $schema; |
|
| 1649 | + } |
|
| 1650 | + |
|
| 1651 | + /** |
|
| 1652 | + * Get the 'article' schema. |
|
| 1653 | + * |
|
| 1654 | + * @return array An array with the schema configuration. |
|
| 1655 | + * |
|
| 1656 | + * @since 3.15.0 |
|
| 1657 | + */ |
|
| 1658 | + private function get_article_schema() { |
|
| 1659 | + |
|
| 1660 | + $schema = array( |
|
| 1661 | + 'label' => 'Article', |
|
| 1662 | + 'description' => 'An Article.', |
|
| 1663 | + 'parents' => array(), |
|
| 1664 | + 'css_class' => 'wl-article', |
|
| 1665 | + 'uri' => 'http://schema.org/Article', |
|
| 1666 | + 'same_as' => array(), |
|
| 1667 | + 'templates' => array( |
|
| 1668 | + 'subtitle' => '{{id}}', |
|
| 1669 | + ), |
|
| 1670 | + 'custom_fields' => array(), |
|
| 1671 | + 'linked_data' => array( |
|
| 1672 | + // ### schema:headline. |
|
| 1673 | + $this->rendition_factory->create( |
|
| 1674 | + $this->storage_factory->post_title(), |
|
| 1675 | + 'http://schema.org/headline', |
|
| 1676 | + null, |
|
| 1677 | + $this->language_code |
|
| 1678 | + ), |
|
| 1679 | + // ### schema:url. |
|
| 1680 | + $this->rendition_factory->create( |
|
| 1681 | + $this->storage_factory->url_property(), |
|
| 1682 | + Wordlift_Query_Builder::SCHEMA_URL_URI, |
|
| 1683 | + self::DATA_TYPE_URI |
|
| 1684 | + ), |
|
| 1685 | + // ### rdf:type. |
|
| 1686 | + $this->rendition_factory->create( |
|
| 1687 | + $this->storage_factory->schema_class(), |
|
| 1688 | + Wordlift_Query_Builder::RDFS_TYPE_URI, |
|
| 1689 | + self::DATA_TYPE_URI |
|
| 1690 | + ), |
|
| 1691 | + // ### dcterms:references. |
|
| 1692 | + $this->rendition_factory->create( |
|
| 1693 | + $this->storage_factory->relations(), |
|
| 1694 | + Wordlift_Query_Builder::DCTERMS_REFERENCES_URI, |
|
| 1695 | + self::DATA_TYPE_URI, |
|
| 1696 | + $this->language_code |
|
| 1697 | + ), |
|
| 1698 | + ), |
|
| 1699 | + ); |
|
| 1700 | + |
|
| 1701 | + return $schema; |
|
| 1702 | + } |
|
| 1703 | 1703 | |
| 1704 | 1704 | } |
@@ -467,9 +467,9 @@ discard block |
||
| 467 | 467 | * @param \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
| 468 | 468 | * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance. |
| 469 | 469 | */ |
| 470 | - public function __construct( $storage_factory, $rendition_factory, $configuration_service ) { |
|
| 470 | + public function __construct($storage_factory, $rendition_factory, $configuration_service) { |
|
| 471 | 471 | |
| 472 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Schema_Service' ); |
|
| 472 | + $this->log = Wordlift_Log_Service::get_logger('Wordlift_Schema_Service'); |
|
| 473 | 473 | |
| 474 | 474 | $this->storage_factory = $storage_factory; |
| 475 | 475 | $this->rendition_factory = $rendition_factory; |
@@ -501,13 +501,13 @@ discard block |
||
| 501 | 501 | * |
| 502 | 502 | * @param array $schemas The array of schemas. |
| 503 | 503 | */ |
| 504 | - $this->schema = apply_filters( 'wl_schemas', $schemas ); |
|
| 504 | + $this->schema = apply_filters('wl_schemas', $schemas); |
|
| 505 | 505 | |
| 506 | 506 | // Create a singleton instance of the Schema service, useful to provide static functions to global functions. |
| 507 | 507 | self::$instance = $this; |
| 508 | 508 | |
| 509 | 509 | // Hook the `init` to allow plugins to add their schemas. |
| 510 | - add_action( 'init', array( $this, 'init' ) ); |
|
| 510 | + add_action('init', array($this, 'init')); |
|
| 511 | 511 | |
| 512 | 512 | } |
| 513 | 513 | |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | */ |
| 519 | 519 | public function init() { |
| 520 | 520 | |
| 521 | - $this->schema = apply_filters( 'wl_schemas_init', $this->schema ); |
|
| 521 | + $this->schema = apply_filters('wl_schemas_init', $this->schema); |
|
| 522 | 522 | |
| 523 | 523 | } |
| 524 | 524 | |
@@ -544,18 +544,18 @@ discard block |
||
| 544 | 544 | * |
| 545 | 545 | * @return null|array An array of field's properties or null if the field is not found. |
| 546 | 546 | */ |
| 547 | - public function get_field( $key ) { |
|
| 547 | + public function get_field($key) { |
|
| 548 | 548 | |
| 549 | 549 | // Parse each schema's fields until we find the one we're looking for, then |
| 550 | 550 | // return its properties. |
| 551 | - foreach ( $this->schema as $_ => $schema ) { |
|
| 551 | + foreach ($this->schema as $_ => $schema) { |
|
| 552 | 552 | |
| 553 | - if ( ! isset( $schema['custom_fields'] ) ) { |
|
| 553 | + if ( ! isset($schema['custom_fields'])) { |
|
| 554 | 554 | break; |
| 555 | 555 | } |
| 556 | 556 | |
| 557 | - foreach ( $schema['custom_fields'] as $field => $props ) { |
|
| 558 | - if ( $key === $field ) { |
|
| 557 | + foreach ($schema['custom_fields'] as $field => $props) { |
|
| 558 | + if ($key === $field) { |
|
| 559 | 559 | return $props; |
| 560 | 560 | } |
| 561 | 561 | } |
@@ -575,8 +575,8 @@ discard block |
||
| 575 | 575 | // Get the custom fields. |
| 576 | 576 | $renditions = array_reduce( |
| 577 | 577 | $this->schema, |
| 578 | - function ( $carry, $item ) { |
|
| 579 | - return array_merge( $carry, $item['linked_data'] ); |
|
| 578 | + function($carry, $item) { |
|
| 579 | + return array_merge($carry, $item['linked_data']); |
|
| 580 | 580 | }, |
| 581 | 581 | array() |
| 582 | 582 | ); |
@@ -594,14 +594,14 @@ discard block |
||
| 594 | 594 | * |
| 595 | 595 | * @since 3.1.0 |
| 596 | 596 | */ |
| 597 | - public function get_schema( $name ) { |
|
| 597 | + public function get_schema($name) { |
|
| 598 | 598 | // Check if the schema exists and, if not, return NULL. |
| 599 | - if ( ! isset( $this->schema[ $name ] ) ) { |
|
| 599 | + if ( ! isset($this->schema[$name])) { |
|
| 600 | 600 | return null; |
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | // Return the requested schema. |
| 604 | - return $this->schema[ $name ]; |
|
| 604 | + return $this->schema[$name]; |
|
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | /** |
@@ -613,10 +613,10 @@ discard block |
||
| 613 | 613 | * |
| 614 | 614 | * @since 3.3.0 |
| 615 | 615 | */ |
| 616 | - public function get_schema_by_uri( $uri ) { |
|
| 616 | + public function get_schema_by_uri($uri) { |
|
| 617 | 617 | |
| 618 | - foreach ( $this->schema as $name => $schema ) { |
|
| 619 | - if ( $schema['uri'] === $uri ) { |
|
| 618 | + foreach ($this->schema as $name => $schema) { |
|
| 619 | + if ($schema['uri'] === $uri) { |
|
| 620 | 620 | return $schema; |
| 621 | 621 | } |
| 622 | 622 | } |
@@ -636,7 +636,7 @@ discard block |
||
| 636 | 636 | return array( |
| 637 | 637 | 'css_class' => 'wl-thing', |
| 638 | 638 | 'uri' => 'http://schema.org/Thing', |
| 639 | - 'same_as' => array( '*' ), |
|
| 639 | + 'same_as' => array('*'), |
|
| 640 | 640 | // set as default. |
| 641 | 641 | 'custom_fields' => array( |
| 642 | 642 | self::FIELD_SAME_AS => array( |
@@ -675,14 +675,14 @@ discard block |
||
| 675 | 675 | ), |
| 676 | 676 | // ### Alternative title to rdfs:label. |
| 677 | 677 | $this->rendition_factory->create( |
| 678 | - $this->storage_factory->post_meta( Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY ), |
|
| 678 | + $this->storage_factory->post_meta(Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY), |
|
| 679 | 679 | Wordlift_Query_Builder::RDFS_LABEL_URI, |
| 680 | 680 | null, |
| 681 | 681 | $this->language_code |
| 682 | 682 | ), |
| 683 | 683 | // ### Alternative title to dct:title. |
| 684 | 684 | $this->rendition_factory->create( |
| 685 | - $this->storage_factory->post_meta( Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY ), |
|
| 685 | + $this->storage_factory->post_meta(Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY), |
|
| 686 | 686 | 'http://purl.org/dc/terms/title', |
| 687 | 687 | null, |
| 688 | 688 | $this->language_code |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | ), |
| 697 | 697 | // ### Alternative title to schema:alterName. |
| 698 | 698 | $this->rendition_factory->create( |
| 699 | - $this->storage_factory->post_meta( Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY ), |
|
| 699 | + $this->storage_factory->post_meta(Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY), |
|
| 700 | 700 | 'http://schema.org/alternateName', |
| 701 | 701 | null, |
| 702 | 702 | $this->language_code |
@@ -716,13 +716,13 @@ discard block |
||
| 716 | 716 | ), |
| 717 | 717 | // ### owl:sameAs. |
| 718 | 718 | $this->rendition_factory->create( |
| 719 | - $this->storage_factory->post_meta( self::FIELD_SAME_AS ), |
|
| 719 | + $this->storage_factory->post_meta(self::FIELD_SAME_AS), |
|
| 720 | 720 | 'http://www.w3.org/2002/07/owl#sameAs', |
| 721 | 721 | self::DATA_TYPE_URI |
| 722 | 722 | ), |
| 723 | 723 | // ### schema:sameAs. |
| 724 | 724 | $this->rendition_factory->create( |
| 725 | - $this->storage_factory->post_meta( self::FIELD_SAME_AS ), |
|
| 725 | + $this->storage_factory->post_meta(self::FIELD_SAME_AS), |
|
| 726 | 726 | 'http://schema.org/sameAs', |
| 727 | 727 | self::DATA_TYPE_URI |
| 728 | 728 | ), |
@@ -805,7 +805,7 @@ discard block |
||
| 805 | 805 | $schema = array( |
| 806 | 806 | 'label' => 'CreativeWork', |
| 807 | 807 | 'description' => 'A creative work (or a Music Album).', |
| 808 | - 'parents' => array( 'thing' ), |
|
| 808 | + 'parents' => array('thing'), |
|
| 809 | 809 | // Give term slug as parent. |
| 810 | 810 | 'css_class' => 'wl-creative-work', |
| 811 | 811 | 'uri' => 'http://schema.org/CreativeWork', |
@@ -819,7 +819,7 @@ discard block |
||
| 819 | 819 | 'type' => self::DATA_TYPE_URI, |
| 820 | 820 | 'export_type' => 'http://schema.org/Person', |
| 821 | 821 | 'constraints' => array( |
| 822 | - 'uri_type' => array( 'Person', 'Organization' ), |
|
| 822 | + 'uri_type' => array('Person', 'Organization'), |
|
| 823 | 823 | 'cardinality' => INF, |
| 824 | 824 | ), |
| 825 | 825 | ), |
@@ -839,8 +839,8 @@ discard block |
||
| 839 | 839 | |
| 840 | 840 | // Merge the custom fields with those provided by the thing schema. |
| 841 | 841 | $parent_schema = $this->get_thing_schema(); |
| 842 | - $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] ); |
|
| 843 | - $schema['linked_data'] = array_merge( $schema['linked_data'], $parent_schema['linked_data'] ); |
|
| 842 | + $schema['custom_fields'] = array_merge($schema['custom_fields'], $parent_schema['custom_fields']); |
|
| 843 | + $schema['linked_data'] = array_merge($schema['linked_data'], $parent_schema['linked_data']); |
|
| 844 | 844 | |
| 845 | 845 | return $schema; |
| 846 | 846 | } |
@@ -857,10 +857,10 @@ discard block |
||
| 857 | 857 | $schema = array( |
| 858 | 858 | 'label' => 'Event', |
| 859 | 859 | 'description' => 'An event . ', |
| 860 | - 'parents' => array( 'thing' ), |
|
| 860 | + 'parents' => array('thing'), |
|
| 861 | 861 | 'css_class' => 'wl-event', |
| 862 | 862 | 'uri' => self::SCHEMA_EVENT_TYPE, |
| 863 | - 'same_as' => array( 'http://dbpedia.org/ontology/Event' ), |
|
| 863 | + 'same_as' => array('http://dbpedia.org/ontology/Event'), |
|
| 864 | 864 | 'custom_fields' => array( |
| 865 | 865 | self::FIELD_DATE_START => array( |
| 866 | 866 | 'predicate' => 'http://schema.org/startDate', |
@@ -879,7 +879,7 @@ discard block |
||
| 879 | 879 | 'type' => self::DATA_TYPE_URI, |
| 880 | 880 | 'export_type' => 'http://schema.org/PostalAddress', |
| 881 | 881 | 'constraints' => array( |
| 882 | - 'uri_type' => array( 'Place', 'LocalBusiness' ), |
|
| 882 | + 'uri_type' => array('Place', 'LocalBusiness'), |
|
| 883 | 883 | 'cardinality' => INF, |
| 884 | 884 | ), |
| 885 | 885 | ), |
@@ -888,7 +888,7 @@ discard block |
||
| 888 | 888 | 'type' => self::DATA_TYPE_URI, |
| 889 | 889 | 'export_type' => 'http://schema.org/Person', |
| 890 | 890 | 'constraints' => array( |
| 891 | - 'uri_type' => array( 'Person', 'Organization' ), |
|
| 891 | + 'uri_type' => array('Person', 'Organization'), |
|
| 892 | 892 | 'cardinality' => INF, |
| 893 | 893 | ), |
| 894 | 894 | ), |
@@ -897,7 +897,7 @@ discard block |
||
| 897 | 897 | 'type' => self::DATA_TYPE_URI, |
| 898 | 898 | 'export_type' => 'http://schema.org/Offer', |
| 899 | 899 | 'constraints' => array( |
| 900 | - 'uri_type' => array( 'Offer' ), |
|
| 900 | + 'uri_type' => array('Offer'), |
|
| 901 | 901 | 'cardinality' => INF, |
| 902 | 902 | ), |
| 903 | 903 | ), |
@@ -905,31 +905,31 @@ discard block |
||
| 905 | 905 | 'linked_data' => array( |
| 906 | 906 | // ### schema:startDate. |
| 907 | 907 | $this->rendition_factory->create( |
| 908 | - $this->storage_factory->post_meta( self::FIELD_DATE_START ), |
|
| 908 | + $this->storage_factory->post_meta(self::FIELD_DATE_START), |
|
| 909 | 909 | 'http://schema.org/startDate', |
| 910 | 910 | self::DATA_TYPE_DATE_TIME |
| 911 | 911 | ), |
| 912 | 912 | // ### schema:endDate. |
| 913 | 913 | $this->rendition_factory->create( |
| 914 | - $this->storage_factory->post_meta( self::FIELD_DATE_END ), |
|
| 914 | + $this->storage_factory->post_meta(self::FIELD_DATE_END), |
|
| 915 | 915 | 'http://schema.org/endDate', |
| 916 | 916 | self::DATA_TYPE_DATE_TIME |
| 917 | 917 | ), |
| 918 | 918 | // ### schema:location. |
| 919 | 919 | $this->rendition_factory->create( |
| 920 | - $this->storage_factory->post_meta_to_uri( self::FIELD_LOCATION ), |
|
| 920 | + $this->storage_factory->post_meta_to_uri(self::FIELD_LOCATION), |
|
| 921 | 921 | 'http://schema.org/location', |
| 922 | 922 | self::DATA_TYPE_URI |
| 923 | 923 | ), |
| 924 | 924 | // ### schema:performer. |
| 925 | 925 | $this->rendition_factory->create( |
| 926 | - $this->storage_factory->post_meta_to_uri( self::FIELD_PERFORMER ), |
|
| 926 | + $this->storage_factory->post_meta_to_uri(self::FIELD_PERFORMER), |
|
| 927 | 927 | 'http://schema.org/performer', |
| 928 | 928 | self::DATA_TYPE_URI |
| 929 | 929 | ), |
| 930 | 930 | // ### schema:offers. |
| 931 | 931 | $this->rendition_factory->create( |
| 932 | - $this->storage_factory->post_meta_to_uri( self::FIELD_OFFERS ), |
|
| 932 | + $this->storage_factory->post_meta_to_uri(self::FIELD_OFFERS), |
|
| 933 | 933 | 'http://schema.org/offers', |
| 934 | 934 | self::DATA_TYPE_URI |
| 935 | 935 | ), |
@@ -941,8 +941,8 @@ discard block |
||
| 941 | 941 | |
| 942 | 942 | // Merge the custom fields with those provided by the thing schema. |
| 943 | 943 | $parent_schema = $this->get_thing_schema(); |
| 944 | - $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] ); |
|
| 945 | - $schema['linked_data'] = array_merge( $schema['linked_data'], $parent_schema['linked_data'] ); |
|
| 944 | + $schema['custom_fields'] = array_merge($schema['custom_fields'], $parent_schema['custom_fields']); |
|
| 945 | + $schema['linked_data'] = array_merge($schema['linked_data'], $parent_schema['linked_data']); |
|
| 946 | 946 | |
| 947 | 947 | return $schema; |
| 948 | 948 | } |
@@ -959,7 +959,7 @@ discard block |
||
| 959 | 959 | $schema = array( |
| 960 | 960 | 'label' => 'Organization', |
| 961 | 961 | 'description' => 'An organization, including a government or a newspaper.', |
| 962 | - 'parents' => array( 'thing' ), |
|
| 962 | + 'parents' => array('thing'), |
|
| 963 | 963 | 'css_class' => 'wl-organization', |
| 964 | 964 | 'uri' => 'http://schema.org/Organization', |
| 965 | 965 | 'same_as' => array( |
@@ -1047,23 +1047,23 @@ discard block |
||
| 1047 | 1047 | 'linked_data' => array( |
| 1048 | 1048 | // ### schema:legalName. |
| 1049 | 1049 | $this->rendition_factory->create( |
| 1050 | - $this->storage_factory->post_meta( self::FIELD_LEGAL_NAME ), |
|
| 1050 | + $this->storage_factory->post_meta(self::FIELD_LEGAL_NAME), |
|
| 1051 | 1051 | 'http://schema.org/legalName' |
| 1052 | 1052 | ), |
| 1053 | 1053 | // ### schema:founder. |
| 1054 | 1054 | $this->rendition_factory->create( |
| 1055 | - $this->storage_factory->post_meta_to_uri( self::FIELD_FOUNDER ), |
|
| 1055 | + $this->storage_factory->post_meta_to_uri(self::FIELD_FOUNDER), |
|
| 1056 | 1056 | 'http://schema.org/founder', |
| 1057 | 1057 | self::DATA_TYPE_URI |
| 1058 | 1058 | ), |
| 1059 | 1059 | // ### schema:email. |
| 1060 | 1060 | $this->rendition_factory->create( |
| 1061 | - $this->storage_factory->post_meta( self::FIELD_EMAIL ), |
|
| 1061 | + $this->storage_factory->post_meta(self::FIELD_EMAIL), |
|
| 1062 | 1062 | 'http://schema.org/email' |
| 1063 | 1063 | ), |
| 1064 | 1064 | // ### schema:telephone. |
| 1065 | 1065 | $this->rendition_factory->create( |
| 1066 | - $this->storage_factory->post_meta( self::FIELD_TELEPHONE ), |
|
| 1066 | + $this->storage_factory->post_meta(self::FIELD_TELEPHONE), |
|
| 1067 | 1067 | 'http://schema.org/telephone' |
| 1068 | 1068 | ), |
| 1069 | 1069 | ), |
@@ -1074,8 +1074,8 @@ discard block |
||
| 1074 | 1074 | |
| 1075 | 1075 | // Merge the custom fields with those provided by the thing schema. |
| 1076 | 1076 | $parent_schema = $this->get_thing_schema(); |
| 1077 | - $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] ); |
|
| 1078 | - $schema['linked_data'] = array_merge( $schema['linked_data'], $parent_schema['linked_data'] ); |
|
| 1077 | + $schema['custom_fields'] = array_merge($schema['custom_fields'], $parent_schema['custom_fields']); |
|
| 1078 | + $schema['linked_data'] = array_merge($schema['linked_data'], $parent_schema['linked_data']); |
|
| 1079 | 1079 | |
| 1080 | 1080 | return $schema; |
| 1081 | 1081 | } |
@@ -1092,7 +1092,7 @@ discard block |
||
| 1092 | 1092 | $schema = array( |
| 1093 | 1093 | 'label' => 'Person', |
| 1094 | 1094 | 'description' => 'A person (or a music artist).', |
| 1095 | - 'parents' => array( 'thing' ), |
|
| 1095 | + 'parents' => array('thing'), |
|
| 1096 | 1096 | 'css_class' => 'wl-person', |
| 1097 | 1097 | 'uri' => 'http://schema.org/Person', |
| 1098 | 1098 | 'same_as' => array( |
@@ -1148,31 +1148,31 @@ discard block |
||
| 1148 | 1148 | 'linked_data' => array( |
| 1149 | 1149 | // ### schema:knows. |
| 1150 | 1150 | $this->rendition_factory->create( |
| 1151 | - $this->storage_factory->post_meta_to_uri( self::FIELD_KNOWS ), |
|
| 1151 | + $this->storage_factory->post_meta_to_uri(self::FIELD_KNOWS), |
|
| 1152 | 1152 | 'http://schema.org/knows', |
| 1153 | 1153 | self::DATA_TYPE_URI |
| 1154 | 1154 | ), |
| 1155 | 1155 | // ### schema:birthDate. |
| 1156 | 1156 | $this->rendition_factory->create( |
| 1157 | - $this->storage_factory->post_meta( self::FIELD_BIRTH_DATE ), |
|
| 1157 | + $this->storage_factory->post_meta(self::FIELD_BIRTH_DATE), |
|
| 1158 | 1158 | 'http://schema.org/birthDate', |
| 1159 | 1159 | self::DATA_TYPE_DATE |
| 1160 | 1160 | ), |
| 1161 | 1161 | // ### schema:birthPlace. |
| 1162 | 1162 | $this->rendition_factory->create( |
| 1163 | - $this->storage_factory->post_meta_to_uri( self::FIELD_BIRTH_PLACE ), |
|
| 1163 | + $this->storage_factory->post_meta_to_uri(self::FIELD_BIRTH_PLACE), |
|
| 1164 | 1164 | 'http://schema.org/birthPlace', |
| 1165 | 1165 | self::DATA_TYPE_URI |
| 1166 | 1166 | ), |
| 1167 | 1167 | // ### schema:affiliation. |
| 1168 | 1168 | $this->rendition_factory->create( |
| 1169 | - $this->storage_factory->post_meta_to_uri( self::FIELD_AFFILIATION ), |
|
| 1169 | + $this->storage_factory->post_meta_to_uri(self::FIELD_AFFILIATION), |
|
| 1170 | 1170 | 'http://schema.org/affiliation', |
| 1171 | 1171 | self::DATA_TYPE_URI |
| 1172 | 1172 | ), |
| 1173 | 1173 | // ### schema:email. |
| 1174 | 1174 | $this->rendition_factory->create( |
| 1175 | - $this->storage_factory->post_meta( self::FIELD_EMAIL ), |
|
| 1175 | + $this->storage_factory->post_meta(self::FIELD_EMAIL), |
|
| 1176 | 1176 | 'http://schema.org/email' |
| 1177 | 1177 | ), |
| 1178 | 1178 | ), |
@@ -1183,8 +1183,8 @@ discard block |
||
| 1183 | 1183 | |
| 1184 | 1184 | // Merge the custom fields with those provided by the thing schema. |
| 1185 | 1185 | $parent_schema = $this->get_thing_schema(); |
| 1186 | - $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] ); |
|
| 1187 | - $schema['linked_data'] = array_merge( $schema['linked_data'], $parent_schema['linked_data'] ); |
|
| 1186 | + $schema['custom_fields'] = array_merge($schema['custom_fields'], $parent_schema['custom_fields']); |
|
| 1187 | + $schema['linked_data'] = array_merge($schema['linked_data'], $parent_schema['linked_data']); |
|
| 1188 | 1188 | |
| 1189 | 1189 | return $schema; |
| 1190 | 1190 | |
@@ -1202,7 +1202,7 @@ discard block |
||
| 1202 | 1202 | $schema = array( |
| 1203 | 1203 | 'label' => 'Place', |
| 1204 | 1204 | 'description' => 'A place.', |
| 1205 | - 'parents' => array( 'thing' ), |
|
| 1205 | + 'parents' => array('thing'), |
|
| 1206 | 1206 | 'css_class' => 'wl-place', |
| 1207 | 1207 | 'uri' => 'http://schema.org/Place', |
| 1208 | 1208 | 'same_as' => array( |
@@ -1288,8 +1288,8 @@ discard block |
||
| 1288 | 1288 | |
| 1289 | 1289 | // Merge the custom fields with those provided by the thing schema. |
| 1290 | 1290 | $parent_schema = $this->get_thing_schema(); |
| 1291 | - $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] ); |
|
| 1292 | - $schema['linked_data'] = array_merge( $schema['linked_data'], $parent_schema['linked_data'] ); |
|
| 1291 | + $schema['custom_fields'] = array_merge($schema['custom_fields'], $parent_schema['custom_fields']); |
|
| 1292 | + $schema['linked_data'] = array_merge($schema['linked_data'], $parent_schema['linked_data']); |
|
| 1293 | 1293 | |
| 1294 | 1294 | return $schema; |
| 1295 | 1295 | } |
@@ -1306,7 +1306,7 @@ discard block |
||
| 1306 | 1306 | $schema = array( |
| 1307 | 1307 | 'label' => 'LocalBusiness', |
| 1308 | 1308 | 'description' => 'A local business.', |
| 1309 | - 'parents' => array( 'place', 'organization' ), |
|
| 1309 | + 'parents' => array('place', 'organization'), |
|
| 1310 | 1310 | 'css_class' => 'wl-local-business', |
| 1311 | 1311 | 'uri' => 'http://schema.org/LocalBusiness', |
| 1312 | 1312 | 'same_as' => array( |
@@ -1323,8 +1323,8 @@ discard block |
||
| 1323 | 1323 | // Merge the custom fields with those provided by the place and organization schema. |
| 1324 | 1324 | $place_schema = $this->get_place_schema(); |
| 1325 | 1325 | $organization_schema = $this->get_organization_schema(); |
| 1326 | - $schema['custom_fields'] = array_merge( $schema['custom_fields'], $place_schema['custom_fields'], $organization_schema['custom_fields'] ); |
|
| 1327 | - $schema['linked_data'] = array_merge( $schema['linked_data'], $place_schema['linked_data'], $organization_schema['linked_data'] ); |
|
| 1326 | + $schema['custom_fields'] = array_merge($schema['custom_fields'], $place_schema['custom_fields'], $organization_schema['custom_fields']); |
|
| 1327 | + $schema['linked_data'] = array_merge($schema['linked_data'], $place_schema['linked_data'], $organization_schema['linked_data']); |
|
| 1328 | 1328 | |
| 1329 | 1329 | return $schema; |
| 1330 | 1330 | } |
@@ -1341,7 +1341,7 @@ discard block |
||
| 1341 | 1341 | $schema = array( |
| 1342 | 1342 | 'label' => 'Recipe', |
| 1343 | 1343 | 'description' => 'A Recipe.', |
| 1344 | - 'parents' => array( 'CreativeWork' ), |
|
| 1344 | + 'parents' => array('CreativeWork'), |
|
| 1345 | 1345 | 'css_class' => 'wl-recipe', |
| 1346 | 1346 | 'uri' => 'http://schema.org/Recipe', |
| 1347 | 1347 | 'same_as' => array(), |
@@ -1355,7 +1355,7 @@ discard block |
||
| 1355 | 1355 | 'export_type' => 'xsd:string', |
| 1356 | 1356 | 'constraints' => '', |
| 1357 | 1357 | 'metabox' => array( |
| 1358 | - 'label' => __( 'Recipe cuisine', 'wordlift' ), |
|
| 1358 | + 'label' => __('Recipe cuisine', 'wordlift'), |
|
| 1359 | 1359 | ), |
| 1360 | 1360 | ), |
| 1361 | 1361 | self::FIELD_RECIPE_INGREDIENT => array( |
@@ -1366,7 +1366,7 @@ discard block |
||
| 1366 | 1366 | 'cardinality' => INF, |
| 1367 | 1367 | ), |
| 1368 | 1368 | 'metabox' => array( |
| 1369 | - 'label' => __( 'Recipe ingredient', 'wordlift' ), |
|
| 1369 | + 'label' => __('Recipe ingredient', 'wordlift'), |
|
| 1370 | 1370 | ), |
| 1371 | 1371 | ), |
| 1372 | 1372 | self::FIELD_RECIPE_INSTRUCTIONS => array( |
@@ -1376,7 +1376,7 @@ discard block |
||
| 1376 | 1376 | 'constraints' => '', |
| 1377 | 1377 | 'metabox' => array( |
| 1378 | 1378 | 'class' => 'Wordlift_Metabox_Field_Multiline', |
| 1379 | - 'label' => __( 'Recipe instructions', 'wordlift' ), |
|
| 1379 | + 'label' => __('Recipe instructions', 'wordlift'), |
|
| 1380 | 1380 | ), |
| 1381 | 1381 | ), |
| 1382 | 1382 | self::FIELD_RECIPE_YIELD => array( |
@@ -1385,7 +1385,7 @@ discard block |
||
| 1385 | 1385 | 'export_type' => 'xsd:string', |
| 1386 | 1386 | 'constraints' => '', |
| 1387 | 1387 | 'metabox' => array( |
| 1388 | - 'label' => __( 'Recipe number of servings', 'wordlift' ), |
|
| 1388 | + 'label' => __('Recipe number of servings', 'wordlift'), |
|
| 1389 | 1389 | ), |
| 1390 | 1390 | ), |
| 1391 | 1391 | self::FIELD_RECIPE_INGREDIENT => array( |
@@ -1396,7 +1396,7 @@ discard block |
||
| 1396 | 1396 | 'cardinality' => INF, |
| 1397 | 1397 | ), |
| 1398 | 1398 | 'metabox' => array( |
| 1399 | - 'label' => __( 'Recipe ingredient', 'wordlift' ), |
|
| 1399 | + 'label' => __('Recipe ingredient', 'wordlift'), |
|
| 1400 | 1400 | ), |
| 1401 | 1401 | ), |
| 1402 | 1402 | self::FIELD_NUTRITION_INFO_CALORIES => array( |
@@ -1405,7 +1405,7 @@ discard block |
||
| 1405 | 1405 | 'export_type' => 'xsd:string', |
| 1406 | 1406 | 'constraints' => '', |
| 1407 | 1407 | 'metabox' => array( |
| 1408 | - 'label' => __( 'Calories (e.g. 240 calories)', 'wordlift' ), |
|
| 1408 | + 'label' => __('Calories (e.g. 240 calories)', 'wordlift'), |
|
| 1409 | 1409 | ), |
| 1410 | 1410 | ), |
| 1411 | 1411 | self::FIELD_PREP_TIME => array( |
@@ -1415,7 +1415,7 @@ discard block |
||
| 1415 | 1415 | 'constraints' => '', |
| 1416 | 1416 | 'metabox' => array( |
| 1417 | 1417 | 'class' => 'Wordlift_Metabox_Field_Duration', |
| 1418 | - 'label' => __( 'Recipe preparation time (e.g. 1:30)', 'wordlift' ), |
|
| 1418 | + 'label' => __('Recipe preparation time (e.g. 1:30)', 'wordlift'), |
|
| 1419 | 1419 | ), |
| 1420 | 1420 | ), |
| 1421 | 1421 | self::FIELD_COOK_TIME => array( |
@@ -1425,7 +1425,7 @@ discard block |
||
| 1425 | 1425 | 'constraints' => '', |
| 1426 | 1426 | 'metabox' => array( |
| 1427 | 1427 | 'class' => 'Wordlift_Metabox_Field_Duration', |
| 1428 | - 'label' => __( 'Recipe cook time (e.g. 1:30)', 'wordlift' ), |
|
| 1428 | + 'label' => __('Recipe cook time (e.g. 1:30)', 'wordlift'), |
|
| 1429 | 1429 | ), |
| 1430 | 1430 | ), |
| 1431 | 1431 | self::FIELD_TOTAL_TIME => array( |
@@ -1435,46 +1435,46 @@ discard block |
||
| 1435 | 1435 | 'constraints' => '', |
| 1436 | 1436 | 'metabox' => array( |
| 1437 | 1437 | 'class' => 'Wordlift_Metabox_Field_Duration', |
| 1438 | - 'label' => __( 'Recipe total time (e.g. 1:30)', 'wordlift' ), |
|
| 1438 | + 'label' => __('Recipe total time (e.g. 1:30)', 'wordlift'), |
|
| 1439 | 1439 | ), |
| 1440 | 1440 | ), |
| 1441 | 1441 | ), |
| 1442 | 1442 | 'linked_data' => array( |
| 1443 | 1443 | // ### schema:recipeCuisine. |
| 1444 | 1444 | $this->rendition_factory->create( |
| 1445 | - $this->storage_factory->post_meta( self::FIELD_RECIPE_CUISINE ), |
|
| 1445 | + $this->storage_factory->post_meta(self::FIELD_RECIPE_CUISINE), |
|
| 1446 | 1446 | 'http://schema.org/recipeCuisine' |
| 1447 | 1447 | ), |
| 1448 | 1448 | // ### schema:recipeIngredient. |
| 1449 | 1449 | $this->rendition_factory->create( |
| 1450 | - $this->storage_factory->post_meta( self::FIELD_RECIPE_INGREDIENT ), |
|
| 1450 | + $this->storage_factory->post_meta(self::FIELD_RECIPE_INGREDIENT), |
|
| 1451 | 1451 | 'http://schema.org/recipeIngredient' |
| 1452 | 1452 | ), |
| 1453 | 1453 | // ### schema:recipeInstructions. |
| 1454 | 1454 | $this->rendition_factory->create( |
| 1455 | - $this->storage_factory->post_meta( self::FIELD_RECIPE_INSTRUCTIONS ), |
|
| 1455 | + $this->storage_factory->post_meta(self::FIELD_RECIPE_INSTRUCTIONS), |
|
| 1456 | 1456 | 'http://schema.org/recipeInstructions' |
| 1457 | 1457 | ), |
| 1458 | 1458 | // ### schema:recipeYield. |
| 1459 | 1459 | $this->rendition_factory->create( |
| 1460 | - $this->storage_factory->post_meta( self::FIELD_RECIPE_YIELD ), |
|
| 1460 | + $this->storage_factory->post_meta(self::FIELD_RECIPE_YIELD), |
|
| 1461 | 1461 | 'http://schema.org/recipeYield' |
| 1462 | 1462 | ), |
| 1463 | 1463 | // ### schema:prepTime. |
| 1464 | 1464 | $this->rendition_factory->create( |
| 1465 | - $this->storage_factory->post_meta( self::FIELD_PREP_TIME ), |
|
| 1465 | + $this->storage_factory->post_meta(self::FIELD_PREP_TIME), |
|
| 1466 | 1466 | 'http://schema.org/prepTime', |
| 1467 | 1467 | self::DATA_TYPE_DURATION |
| 1468 | 1468 | ), |
| 1469 | 1469 | // ### schema:cookTime. |
| 1470 | 1470 | $this->rendition_factory->create( |
| 1471 | - $this->storage_factory->post_meta( self::FIELD_COOK_TIME ), |
|
| 1471 | + $this->storage_factory->post_meta(self::FIELD_COOK_TIME), |
|
| 1472 | 1472 | 'http://schema.org/cookTime', |
| 1473 | 1473 | self::DATA_TYPE_DURATION |
| 1474 | 1474 | ), |
| 1475 | 1475 | // ### schema:totalTime. |
| 1476 | 1476 | $this->rendition_factory->create( |
| 1477 | - $this->storage_factory->post_meta( self::FIELD_TOTAL_TIME ), |
|
| 1477 | + $this->storage_factory->post_meta(self::FIELD_TOTAL_TIME), |
|
| 1478 | 1478 | 'http://schema.org/totalTime', |
| 1479 | 1479 | self::DATA_TYPE_DURATION |
| 1480 | 1480 | ), |
@@ -1483,8 +1483,8 @@ discard block |
||
| 1483 | 1483 | |
| 1484 | 1484 | // Merge the custom fields with those provided by the parent schema. |
| 1485 | 1485 | $parent_schema = $this->get_creative_work_schema(); |
| 1486 | - $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] ); |
|
| 1487 | - $schema['linked_data'] = array_merge( $schema['linked_data'], $parent_schema['linked_data'] ); |
|
| 1486 | + $schema['custom_fields'] = array_merge($schema['custom_fields'], $parent_schema['custom_fields']); |
|
| 1487 | + $schema['linked_data'] = array_merge($schema['linked_data'], $parent_schema['linked_data']); |
|
| 1488 | 1488 | |
| 1489 | 1489 | return $schema; |
| 1490 | 1490 | } |
@@ -1501,7 +1501,7 @@ discard block |
||
| 1501 | 1501 | $schema = array( |
| 1502 | 1502 | 'label' => 'Offer', |
| 1503 | 1503 | 'description' => 'An offer. ', |
| 1504 | - 'parents' => array( 'thing' ), |
|
| 1504 | + 'parents' => array('thing'), |
|
| 1505 | 1505 | 'css_class' => 'wl-offer', |
| 1506 | 1506 | 'uri' => self::SCHEMA_OFFER_TYPE, |
| 1507 | 1507 | 'same_as' => array(), |
@@ -1517,15 +1517,15 @@ discard block |
||
| 1517 | 1517 | 'class' => 'Wordlift_Metabox_Field_Select', |
| 1518 | 1518 | ), |
| 1519 | 1519 | 'options' => array( |
| 1520 | - 'Discontinued' => esc_html__( 'Discontinued', 'wordlift' ), |
|
| 1521 | - 'InStock' => esc_html__( 'In Stock', 'wordlift' ), |
|
| 1522 | - 'InStoreOnly' => esc_html__( 'In Store Only', 'wordlift' ), |
|
| 1523 | - 'LimitedAvailability' => esc_html__( 'Limited Availability', 'wordlift' ), |
|
| 1524 | - 'OnlineOnly' => esc_html__( 'Online Only', 'wordlift' ), |
|
| 1525 | - 'OutOfStock' => esc_html__( 'Out of Stock', 'wordlift' ), |
|
| 1526 | - 'PreOrder' => esc_html__( 'Pre Order', 'wordlift' ), |
|
| 1527 | - 'PreSale' => esc_html__( 'Pre Sale', 'wordlift' ), |
|
| 1528 | - 'SoldOut' => esc_html__( 'Sold Out', 'wordlift' ), |
|
| 1520 | + 'Discontinued' => esc_html__('Discontinued', 'wordlift'), |
|
| 1521 | + 'InStock' => esc_html__('In Stock', 'wordlift'), |
|
| 1522 | + 'InStoreOnly' => esc_html__('In Store Only', 'wordlift'), |
|
| 1523 | + 'LimitedAvailability' => esc_html__('Limited Availability', 'wordlift'), |
|
| 1524 | + 'OnlineOnly' => esc_html__('Online Only', 'wordlift'), |
|
| 1525 | + 'OutOfStock' => esc_html__('Out of Stock', 'wordlift'), |
|
| 1526 | + 'PreOrder' => esc_html__('Pre Order', 'wordlift'), |
|
| 1527 | + 'PreSale' => esc_html__('Pre Sale', 'wordlift'), |
|
| 1528 | + 'SoldOut' => esc_html__('Sold Out', 'wordlift'), |
|
| 1529 | 1529 | ), |
| 1530 | 1530 | ), |
| 1531 | 1531 | self::FIELD_PRICE => array( |
@@ -1585,55 +1585,55 @@ discard block |
||
| 1585 | 1585 | 'linked_data' => array( |
| 1586 | 1586 | // ### schema:availability. |
| 1587 | 1587 | $this->rendition_factory->create( |
| 1588 | - $this->storage_factory->post_meta( self::FIELD_AVAILABILITY ), |
|
| 1588 | + $this->storage_factory->post_meta(self::FIELD_AVAILABILITY), |
|
| 1589 | 1589 | 'http://schema.org/availability', |
| 1590 | 1590 | null |
| 1591 | 1591 | ), |
| 1592 | 1592 | // ### schema:availabilityStarts. |
| 1593 | 1593 | $this->rendition_factory->create( |
| 1594 | - $this->storage_factory->post_meta( self::FIELD_AVAILABILITY_STARTS ), |
|
| 1594 | + $this->storage_factory->post_meta(self::FIELD_AVAILABILITY_STARTS), |
|
| 1595 | 1595 | 'http://schema.org/availabilityStarts', |
| 1596 | 1596 | self::DATA_TYPE_DATE_TIME |
| 1597 | 1597 | ), |
| 1598 | 1598 | // ### schema:availabilityEnds. |
| 1599 | 1599 | $this->rendition_factory->create( |
| 1600 | - $this->storage_factory->post_meta( self::FIELD_AVAILABILITY_ENDS ), |
|
| 1600 | + $this->storage_factory->post_meta(self::FIELD_AVAILABILITY_ENDS), |
|
| 1601 | 1601 | 'http://schema.org/availabilityEnds', |
| 1602 | 1602 | self::DATA_TYPE_DATE_TIME |
| 1603 | 1603 | ), |
| 1604 | 1604 | // ### schema:inventoryLevel. |
| 1605 | 1605 | $this->rendition_factory->create( |
| 1606 | - $this->storage_factory->post_meta( self::FIELD_INVENTORY_LEVEL ), |
|
| 1606 | + $this->storage_factory->post_meta(self::FIELD_INVENTORY_LEVEL), |
|
| 1607 | 1607 | 'http://schema.org/inventoryLevel', |
| 1608 | 1608 | self::DATA_TYPE_INTEGER |
| 1609 | 1609 | ), |
| 1610 | 1610 | // ### schema:price. |
| 1611 | 1611 | $this->rendition_factory->create( |
| 1612 | - $this->storage_factory->post_meta( self::FIELD_PRICE ), |
|
| 1612 | + $this->storage_factory->post_meta(self::FIELD_PRICE), |
|
| 1613 | 1613 | 'http://schema.org/price', |
| 1614 | 1614 | self::DATA_TYPE_INTEGER |
| 1615 | 1615 | ), |
| 1616 | 1616 | // ### schema:priceCurrency. |
| 1617 | 1617 | $this->rendition_factory->create( |
| 1618 | - $this->storage_factory->post_meta( self::FIELD_PRICE_CURRENCY ), |
|
| 1618 | + $this->storage_factory->post_meta(self::FIELD_PRICE_CURRENCY), |
|
| 1619 | 1619 | 'http://schema.org/priceCurrency', |
| 1620 | 1620 | null |
| 1621 | 1621 | ), |
| 1622 | 1622 | // ### schema:validFrom. |
| 1623 | 1623 | $this->rendition_factory->create( |
| 1624 | - $this->storage_factory->post_meta( self::FIELD_VALID_FROM ), |
|
| 1624 | + $this->storage_factory->post_meta(self::FIELD_VALID_FROM), |
|
| 1625 | 1625 | 'http://schema.org/validFrom', |
| 1626 | 1626 | null |
| 1627 | 1627 | ), |
| 1628 | 1628 | // ### schema:priceValidUntil. |
| 1629 | 1629 | $this->rendition_factory->create( |
| 1630 | - $this->storage_factory->post_meta( self::FIELD_PRICE_VALID_UNTIL ), |
|
| 1630 | + $this->storage_factory->post_meta(self::FIELD_PRICE_VALID_UNTIL), |
|
| 1631 | 1631 | 'http://schema.org/priceValidUntil', |
| 1632 | 1632 | null |
| 1633 | 1633 | ), |
| 1634 | 1634 | // ### schema:itemOffered. |
| 1635 | 1635 | $this->rendition_factory->create( |
| 1636 | - $this->storage_factory->post_meta_to_uri( self::FIELD_ITEM_OFFERED ), |
|
| 1636 | + $this->storage_factory->post_meta_to_uri(self::FIELD_ITEM_OFFERED), |
|
| 1637 | 1637 | 'http://schema.org/itemOffered', |
| 1638 | 1638 | self::DATA_TYPE_URI |
| 1639 | 1639 | ), |
@@ -1642,8 +1642,8 @@ discard block |
||
| 1642 | 1642 | |
| 1643 | 1643 | // Merge the custom fields with those provided by the thing schema. |
| 1644 | 1644 | $parent_schema = $this->get_thing_schema(); |
| 1645 | - $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] ); |
|
| 1646 | - $schema['linked_data'] = array_merge( $schema['linked_data'], $parent_schema['linked_data'] ); |
|
| 1645 | + $schema['custom_fields'] = array_merge($schema['custom_fields'], $parent_schema['custom_fields']); |
|
| 1646 | + $schema['linked_data'] = array_merge($schema['linked_data'], $parent_schema['linked_data']); |
|
| 1647 | 1647 | |
| 1648 | 1648 | return $schema; |
| 1649 | 1649 | } |
@@ -8,50 +8,50 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | abstract class Wordlift_Shortcode { |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * The shortcode, set by extending classes. |
|
| 13 | - */ |
|
| 14 | - const SHORTCODE = NULL; |
|
| 15 | - |
|
| 16 | - /** |
|
| 17 | - * Create a shortcode instance by registering the shortcode with the render |
|
| 18 | - * function. |
|
| 19 | - * |
|
| 20 | - * @since 3.5.4 |
|
| 21 | - */ |
|
| 22 | - public function __construct() { |
|
| 23 | - |
|
| 24 | - add_shortcode( static::SHORTCODE, array( $this, 'render' ) ); |
|
| 25 | - |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Render the shortcode. |
|
| 30 | - * |
|
| 31 | - * @since 3.5.4 |
|
| 32 | - * |
|
| 33 | - * @param array $atts An array of shortcode attributes as set by the editor. |
|
| 34 | - * |
|
| 35 | - * @return string The output html code. |
|
| 36 | - */ |
|
| 37 | - public abstract function render( $atts ); |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * Enqueue scripts. Called by the shortcode implementations in their render |
|
| 41 | - * method. |
|
| 42 | - * |
|
| 43 | - * @since 3.5.4 |
|
| 44 | - */ |
|
| 45 | - protected function enqueue_scripts() { |
|
| 46 | - |
|
| 47 | - wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' ); |
|
| 48 | - wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js', array( 'angularjs' ) ); |
|
| 49 | - wp_enqueue_script( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/js/wordlift-ui' . ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ? '.min' : '' ) . '.js', array( |
|
| 50 | - 'jquery', |
|
| 51 | - 'angularjs', |
|
| 52 | - 'angularjs-touch' |
|
| 53 | - ) ); |
|
| 54 | - |
|
| 55 | - } |
|
| 11 | + /** |
|
| 12 | + * The shortcode, set by extending classes. |
|
| 13 | + */ |
|
| 14 | + const SHORTCODE = NULL; |
|
| 15 | + |
|
| 16 | + /** |
|
| 17 | + * Create a shortcode instance by registering the shortcode with the render |
|
| 18 | + * function. |
|
| 19 | + * |
|
| 20 | + * @since 3.5.4 |
|
| 21 | + */ |
|
| 22 | + public function __construct() { |
|
| 23 | + |
|
| 24 | + add_shortcode( static::SHORTCODE, array( $this, 'render' ) ); |
|
| 25 | + |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Render the shortcode. |
|
| 30 | + * |
|
| 31 | + * @since 3.5.4 |
|
| 32 | + * |
|
| 33 | + * @param array $atts An array of shortcode attributes as set by the editor. |
|
| 34 | + * |
|
| 35 | + * @return string The output html code. |
|
| 36 | + */ |
|
| 37 | + public abstract function render( $atts ); |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * Enqueue scripts. Called by the shortcode implementations in their render |
|
| 41 | + * method. |
|
| 42 | + * |
|
| 43 | + * @since 3.5.4 |
|
| 44 | + */ |
|
| 45 | + protected function enqueue_scripts() { |
|
| 46 | + |
|
| 47 | + wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' ); |
|
| 48 | + wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js', array( 'angularjs' ) ); |
|
| 49 | + wp_enqueue_script( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/js/wordlift-ui' . ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ? '.min' : '' ) . '.js', array( |
|
| 50 | + 'jquery', |
|
| 51 | + 'angularjs', |
|
| 52 | + 'angularjs-touch' |
|
| 53 | + ) ); |
|
| 54 | + |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | 57 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function __construct() { |
| 23 | 23 | |
| 24 | - add_shortcode( static::SHORTCODE, array( $this, 'render' ) ); |
|
| 24 | + add_shortcode(static::SHORTCODE, array($this, 'render')); |
|
| 25 | 25 | |
| 26 | 26 | } |
| 27 | 27 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * |
| 35 | 35 | * @return string The output html code. |
| 36 | 36 | */ |
| 37 | - public abstract function render( $atts ); |
|
| 37 | + public abstract function render($atts); |
|
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * Enqueue scripts. Called by the shortcode implementations in their render |
@@ -44,13 +44,13 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | protected function enqueue_scripts() { |
| 46 | 46 | |
| 47 | - wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' ); |
|
| 48 | - wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js', array( 'angularjs' ) ); |
|
| 49 | - wp_enqueue_script( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/js/wordlift-ui' . ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ? '.min' : '' ) . '.js', array( |
|
| 47 | + wp_enqueue_script('angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js'); |
|
| 48 | + wp_enqueue_script('angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js', array('angularjs')); |
|
| 49 | + wp_enqueue_script('wordlift-ui', dirname(plugin_dir_url(__FILE__)).'/js/wordlift-ui'.( ! defined('SCRIPT_DEBUG') || ! SCRIPT_DEBUG ? '.min' : '').'.js', array( |
|
| 50 | 50 | 'jquery', |
| 51 | 51 | 'angularjs', |
| 52 | 52 | 'angularjs-touch' |
| 53 | - ) ); |
|
| 53 | + )); |
|
| 54 | 54 | |
| 55 | 55 | } |
| 56 | 56 | |
@@ -9,72 +9,72 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | class Wordlift_Property_Getter { |
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * An array of {@link Wordlift_Simple_Property_Service}s which can access a |
|
| 14 | - * property. |
|
| 15 | - * |
|
| 16 | - * @since 3.8.0 |
|
| 17 | - * @access private |
|
| 18 | - * @var Wordlift_Simple_Property_Service[] $services An array of {@link Wordlift_Simple_Property_Service}s. |
|
| 19 | - */ |
|
| 20 | - private $services = array(); |
|
| 12 | + /** |
|
| 13 | + * An array of {@link Wordlift_Simple_Property_Service}s which can access a |
|
| 14 | + * property. |
|
| 15 | + * |
|
| 16 | + * @since 3.8.0 |
|
| 17 | + * @access private |
|
| 18 | + * @var Wordlift_Simple_Property_Service[] $services An array of {@link Wordlift_Simple_Property_Service}s. |
|
| 19 | + */ |
|
| 20 | + private $services = array(); |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * The default {@link Wordlift_Simple_Property_Service} which is used to access |
|
| 24 | - * a property when no specific {@link Wordlift_Simple_Property_Service} is found |
|
| 25 | - * in the {@see $services} array. |
|
| 26 | - * @var Wordlift_Simple_Property_Service |
|
| 27 | - */ |
|
| 28 | - private $default; |
|
| 22 | + /** |
|
| 23 | + * The default {@link Wordlift_Simple_Property_Service} which is used to access |
|
| 24 | + * a property when no specific {@link Wordlift_Simple_Property_Service} is found |
|
| 25 | + * in the {@see $services} array. |
|
| 26 | + * @var Wordlift_Simple_Property_Service |
|
| 27 | + */ |
|
| 28 | + private $default; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Create a property service with the provided {@link Wordlift_Simple_Property_Service} |
|
| 32 | - * as default. |
|
| 33 | - * |
|
| 34 | - * @since 3.8.0 |
|
| 35 | - * |
|
| 36 | - * @param $default |
|
| 37 | - */ |
|
| 38 | - public function __construct( $default ) { |
|
| 30 | + /** |
|
| 31 | + * Create a property service with the provided {@link Wordlift_Simple_Property_Service} |
|
| 32 | + * as default. |
|
| 33 | + * |
|
| 34 | + * @since 3.8.0 |
|
| 35 | + * |
|
| 36 | + * @param $default |
|
| 37 | + */ |
|
| 38 | + public function __construct( $default ) { |
|
| 39 | 39 | |
| 40 | - $this->default = $default; |
|
| 40 | + $this->default = $default; |
|
| 41 | 41 | |
| 42 | - } |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Register a {@link Wordlift_Simple_Property_Service} for the specified meta keys. |
|
| 46 | - * |
|
| 47 | - * @since 3.8.0 |
|
| 48 | - * |
|
| 49 | - * @param \Wordlift_Simple_Property_Service $property_service A {@link Wordlift_Simple_Property_Service} instance. |
|
| 50 | - * @param array $meta_keys An array of meta keys that the provided {@link Wordlift_Simple_Property_Service} will handle. |
|
| 51 | - */ |
|
| 52 | - public function register( $property_service, $meta_keys ) { |
|
| 44 | + /** |
|
| 45 | + * Register a {@link Wordlift_Simple_Property_Service} for the specified meta keys. |
|
| 46 | + * |
|
| 47 | + * @since 3.8.0 |
|
| 48 | + * |
|
| 49 | + * @param \Wordlift_Simple_Property_Service $property_service A {@link Wordlift_Simple_Property_Service} instance. |
|
| 50 | + * @param array $meta_keys An array of meta keys that the provided {@link Wordlift_Simple_Property_Service} will handle. |
|
| 51 | + */ |
|
| 52 | + public function register( $property_service, $meta_keys ) { |
|
| 53 | 53 | |
| 54 | - // Register the specified property service for each meta key. |
|
| 55 | - foreach ( $meta_keys as $meta_key ) { |
|
| 56 | - $this->services[ $meta_key ] = $property_service; |
|
| 57 | - } |
|
| 54 | + // Register the specified property service for each meta key. |
|
| 55 | + foreach ( $meta_keys as $meta_key ) { |
|
| 56 | + $this->services[ $meta_key ] = $property_service; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - } |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Get the value for the specified entity post id and WP's meta key. |
|
| 63 | - * |
|
| 64 | - * @since 3.8.0 |
|
| 65 | - * |
|
| 66 | - * @param int $post_id The post id. |
|
| 67 | - * @param string $meta_key The meta key. |
|
| 68 | - * |
|
| 69 | - * @return mixed|null The property value or null. |
|
| 70 | - */ |
|
| 71 | - public function get( $post_id, $meta_key ) { |
|
| 61 | + /** |
|
| 62 | + * Get the value for the specified entity post id and WP's meta key. |
|
| 63 | + * |
|
| 64 | + * @since 3.8.0 |
|
| 65 | + * |
|
| 66 | + * @param int $post_id The post id. |
|
| 67 | + * @param string $meta_key The meta key. |
|
| 68 | + * |
|
| 69 | + * @return mixed|null The property value or null. |
|
| 70 | + */ |
|
| 71 | + public function get( $post_id, $meta_key ) { |
|
| 72 | 72 | |
| 73 | - return isset( $this->services[ $meta_key ] ) |
|
| 74 | - // Use a specific property service. |
|
| 75 | - ? $this->services[ $meta_key ]->get( $post_id, $meta_key ) |
|
| 76 | - // Use the default property service. |
|
| 77 | - : $this->default->get( $post_id, $meta_key ); |
|
| 78 | - } |
|
| 73 | + return isset( $this->services[ $meta_key ] ) |
|
| 74 | + // Use a specific property service. |
|
| 75 | + ? $this->services[ $meta_key ]->get( $post_id, $meta_key ) |
|
| 76 | + // Use the default property service. |
|
| 77 | + : $this->default->get( $post_id, $meta_key ); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | 80 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @param $default |
| 37 | 37 | */ |
| 38 | - public function __construct( $default ) { |
|
| 38 | + public function __construct($default) { |
|
| 39 | 39 | |
| 40 | 40 | $this->default = $default; |
| 41 | 41 | |
@@ -49,11 +49,11 @@ discard block |
||
| 49 | 49 | * @param \Wordlift_Simple_Property_Service $property_service A {@link Wordlift_Simple_Property_Service} instance. |
| 50 | 50 | * @param array $meta_keys An array of meta keys that the provided {@link Wordlift_Simple_Property_Service} will handle. |
| 51 | 51 | */ |
| 52 | - public function register( $property_service, $meta_keys ) { |
|
| 52 | + public function register($property_service, $meta_keys) { |
|
| 53 | 53 | |
| 54 | 54 | // Register the specified property service for each meta key. |
| 55 | - foreach ( $meta_keys as $meta_key ) { |
|
| 56 | - $this->services[ $meta_key ] = $property_service; |
|
| 55 | + foreach ($meta_keys as $meta_key) { |
|
| 56 | + $this->services[$meta_key] = $property_service; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | } |
@@ -68,13 +68,13 @@ discard block |
||
| 68 | 68 | * |
| 69 | 69 | * @return mixed|null The property value or null. |
| 70 | 70 | */ |
| 71 | - public function get( $post_id, $meta_key ) { |
|
| 71 | + public function get($post_id, $meta_key) { |
|
| 72 | 72 | |
| 73 | - return isset( $this->services[ $meta_key ] ) |
|
| 73 | + return isset($this->services[$meta_key]) |
|
| 74 | 74 | // Use a specific property service. |
| 75 | - ? $this->services[ $meta_key ]->get( $post_id, $meta_key ) |
|
| 75 | + ? $this->services[$meta_key]->get($post_id, $meta_key) |
|
| 76 | 76 | // Use the default property service. |
| 77 | - : $this->default->get( $post_id, $meta_key ); |
|
| 77 | + : $this->default->get($post_id, $meta_key); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | } |