summaryrefslogtreecommitdiff
path: root/inc/schema/class-astra-site-navigation-schema.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/schema/class-astra-site-navigation-schema.php')
-rw-r--r--inc/schema/class-astra-site-navigation-schema.php62
1 files changed, 62 insertions, 0 deletions
diff --git a/inc/schema/class-astra-site-navigation-schema.php b/inc/schema/class-astra-site-navigation-schema.php
new file mode 100644
index 0000000..356cad5
--- /dev/null
+++ b/inc/schema/class-astra-site-navigation-schema.php
@@ -0,0 +1,62 @@
+<?php
+/**
+ * Schema markup.
+ *
+ * @package Astra
+ * @author Astra
+ * @copyright Copyright (c) 2020, Astra
+ * @link https://wpastra.com/
+ * @since Astra 2.1.3
+ */
+
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly.
+}
+
+/**
+ * Astra CreativeWork Schema Markup.
+ *
+ * @since 2.1.3
+ */
+class Astra_Site_Navigation_Schema extends Astra_Schema {
+
+ /**
+ * Setup schema
+ *
+ * @since 2.1.3
+ */
+ public function setup_schema() {
+
+ if ( true !== $this->schema_enabled() ) {
+ return false;
+ }
+
+ add_filter( 'astra_attr_site-navigation', array( $this, 'site_navigation_schema' ) );
+ }
+
+ /**
+ * Update Schema markup attribute.
+ *
+ * @param array $attr An array of attributes.
+ *
+ * @return array Updated embed markup.
+ */
+ public function site_navigation_schema( $attr ) {
+ $attr['itemtype'] = 'https://schema.org/SiteNavigationElement';
+ $attr['itemscope'] = 'itemscope';
+
+ return $attr;
+ }
+
+ /**
+ * Enabled schema
+ *
+ * @since 2.1.3
+ */
+ protected function schema_enabled() {
+ return apply_filters( 'astra_site_navigation_schema_enabled', parent::schema_enabled() );
+ }
+
+}
+
+new Astra_Site_Navigation_Schema();