Markup (JSON-LD) structured in schema.org - Version 2.2.0

Version Description

(2015-12-16) =

  • Updated : Updated on December 14, 2015 was structured data (Article) AMP correspondence. https://developers.google.com/structured-data/rich-snippets/articles?hl=ja
Download this release

Release Info

Developer miiitaka
Plugin Icon 128x128 Markup (JSON-LD) structured in schema.org
Version 2.2.0
Comparing to
See all releases

Code changes from version 2.1.3 to 2.2.0

includes/wp-structuring-admin-post.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author Kazuya Takami
6
  * @since 1.0.0
7
- * @version 2.1.0
8
  */
9
  class Structuring_Markup_Admin_Post {
10
 
@@ -21,7 +21,7 @@ class Structuring_Markup_Admin_Post {
21
  * Constructor Define.
22
  *
23
  * @since 1.0.0
24
- * @version 2.0.0
25
  * @param String $text_domain
26
  */
27
  public function __construct ( $text_domain ) {
@@ -69,6 +69,9 @@ class Structuring_Markup_Admin_Post {
69
  }
70
 
71
  $options = $db->get_options( $options['id'] );
 
 
 
72
 
73
  $this->page_render( $options, $status );
74
  }
@@ -77,7 +80,7 @@ class Structuring_Markup_Admin_Post {
77
  * Setting Page of the Admin Screen.
78
  *
79
  * @since 1.0.0
80
- * @version 2.1.0
81
  * @param array $options
82
  * @param string $status
83
  */
@@ -119,7 +122,7 @@ class Structuring_Markup_Admin_Post {
119
  echo $html;
120
 
121
  require_once ( plugin_dir_path( __FILE__ ) . 'wp-structuring-admin-type-article.php' );
122
- new Structuring_Markup_Type_Article();
123
  break;
124
  case 'blog_posting':
125
  $html = $this->output_checkbox_render( $options['output'], "post", "Post", esc_html__( 'Post Page', $this->text_domain ) );
@@ -127,7 +130,7 @@ class Structuring_Markup_Admin_Post {
127
  echo $html;
128
 
129
  require_once ( plugin_dir_path( __FILE__ ) . 'wp-structuring-admin-type-blog-posting.php' );
130
- new Structuring_Markup_Type_Blog_Posting();
131
  break;
132
  case 'breadcrumb':
133
  $html = $this->output_checkbox_render( $options['output'], "all", "All", esc_html__( 'All Page', $this->text_domain ) );
@@ -151,7 +154,7 @@ class Structuring_Markup_Admin_Post {
151
  echo $html;
152
 
153
  require_once ( plugin_dir_path( __FILE__ ) . 'wp-structuring-admin-type-news-article.php' );
154
- new Structuring_Markup_Type_NewsArticle();
155
  break;
156
  case 'organization':
157
  $html = $this->output_checkbox_render( $options['output'], "all", "All", esc_html__( 'All Page', $this->text_domain ) );
4
  *
5
  * @author Kazuya Takami
6
  * @since 1.0.0
7
+ * @version 2.2.0
8
  */
9
  class Structuring_Markup_Admin_Post {
10
 
21
  * Constructor Define.
22
  *
23
  * @since 1.0.0
24
+ * @version 2.2.0
25
  * @param String $text_domain
26
  */
27
  public function __construct ( $text_domain ) {
69
  }
70
 
71
  $options = $db->get_options( $options['id'] );
72
+ if ( $options['option'] === false ) {
73
+ $options['option'] = array();
74
+ }
75
 
76
  $this->page_render( $options, $status );
77
  }
80
  * Setting Page of the Admin Screen.
81
  *
82
  * @since 1.0.0
83
+ * @version 2.2.0
84
  * @param array $options
85
  * @param string $status
86
  */
122
  echo $html;
123
 
124
  require_once ( plugin_dir_path( __FILE__ ) . 'wp-structuring-admin-type-article.php' );
125
+ new Structuring_Markup_Type_Article( $options['option'] );
126
  break;
127
  case 'blog_posting':
128
  $html = $this->output_checkbox_render( $options['output'], "post", "Post", esc_html__( 'Post Page', $this->text_domain ) );
130
  echo $html;
131
 
132
  require_once ( plugin_dir_path( __FILE__ ) . 'wp-structuring-admin-type-blog-posting.php' );
133
+ new Structuring_Markup_Type_Blog_Posting( $options['option'] );
134
  break;
135
  case 'breadcrumb':
136
  $html = $this->output_checkbox_render( $options['output'], "all", "All", esc_html__( 'All Page', $this->text_domain ) );
154
  echo $html;
155
 
156
  require_once ( plugin_dir_path( __FILE__ ) . 'wp-structuring-admin-type-news-article.php' );
157
+ new Structuring_Markup_Type_NewsArticle( $options['option'] );
158
  break;
159
  case 'organization':
160
  $html = $this->output_checkbox_render( $options['output'], "all", "All", esc_html__( 'All Page', $this->text_domain ) );
includes/wp-structuring-admin-type-article.php CHANGED
@@ -3,7 +3,7 @@
3
  * Schema.org Type Article
4
  *
5
  * @author Kazuya Takami
6
- * @version 1.1.0
7
  * @since 1.1.0
8
  * @see wp-structuring-admin-db.php
9
  * @link http://schema.org/Article
@@ -14,30 +14,89 @@ class Structuring_Markup_Type_Article {
14
  /**
15
  * Constructor Define.
16
  *
17
- * @since 1.1.0
 
 
18
  */
19
- public function __construct () {
20
- $this->page_render();
 
 
 
 
21
  }
22
 
23
  /**
24
  * Form Layout Render
25
  *
26
- * @since 1.1.0
 
 
27
  */
28
- private function page_render () {
29
  $html = '<table class="schema-admin-table">';
30
- $html .= '<caption>Basic Setting( Post Page Only )</caption>';
31
  $html .= '<tr><th>headline :</th><td><small>Default : post_title</small></td></tr>';
32
  $html .= '<tr><th>datePublished :</th><td><small>Default : get_the_time( DATE_ISO8601, ID )</small></td></tr>';
33
- $html .= '<tr><th>author :</th><td><small>Default : get_the_author_meta( "display_name", author_ID )</small></td></tr>';
34
- $html .= '<tr><th>image :</th><td><small>Default : thumbnail</small></td></tr>';
35
  $html .= '<tr><th>description :</th><td><small>Default : post_excerpt</small></td></tr>';
36
- $html .= '<tr><th>articleBody :</th><td><small>Default : post_content</small></td></tr>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  $html .= '</table>';
38
  echo $html;
39
 
40
  echo '<p>Setting Knowledge : <a href="https://developers.google.com/structured-data/rich-snippets/articles" target="_blank">https://developers.google.com/structured-data/rich-snippets/articles</a></p>';
41
  submit_button();
42
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  }
3
  * Schema.org Type Article
4
  *
5
  * @author Kazuya Takami
6
+ * @version 2.2.0
7
  * @since 1.1.0
8
  * @see wp-structuring-admin-db.php
9
  * @link http://schema.org/Article
14
  /**
15
  * Constructor Define.
16
  *
17
+ * @since 1.0.0
18
+ * @version 2.2.0
19
+ * @param array $option
20
  */
21
+ public function __construct ( array $option ) {
22
+ /** Default Value Set */
23
+ if ( empty( $option ) ) {
24
+ $option = $this->get_default_options( $option );
25
+ }
26
+ $this->page_render( $option );
27
  }
28
 
29
  /**
30
  * Form Layout Render
31
  *
32
+ * @since 1.1.0
33
+ * @version 2.2.0
34
+ * @param array $option
35
  */
36
+ private function page_render ( array $option ) {
37
  $html = '<table class="schema-admin-table">';
38
+ $html .= '<caption>Basic Setting</caption>';
39
  $html .= '<tr><th>headline :</th><td><small>Default : post_title</small></td></tr>';
40
  $html .= '<tr><th>datePublished :</th><td><small>Default : get_the_time( DATE_ISO8601, ID )</small></td></tr>';
41
+ $html .= '<tr><th>dateModified :</th><td><small>Default : get_the_modified_time( DATE_ISO8601, false, ID )</small></td></tr>';
 
42
  $html .= '<tr><th>description :</th><td><small>Default : post_excerpt</small></td></tr>';
43
+ $html .= '</table>';
44
+ echo $html;
45
+
46
+ $html = '<table class="schema-admin-table">';
47
+ $html .= '<caption>mainEntityOfPage( recommended )</caption>';
48
+ $html .= '<tr><th>@type :</th><td><small>"WebPage"</small></td></tr>';
49
+ $html .= '<tr><th>@id :</th><td><small>Default : get_permalink( ID )</small></td></tr>';
50
+ $html .= '</table>';
51
+ echo $html;
52
+
53
+ $html = '<table class="schema-admin-table">';
54
+ $html .= '<caption>image( required )</caption>';
55
+ $html .= '<tr><th>@type :</th><td><small>"ImageObject"</small></td></tr>';
56
+ $html .= '<tr><th>url :</th><td><small>Default : thumbnail</small></td></tr>';
57
+ $html .= '<tr><th>height :</th><td><small>Auto : The height of the image, in pixels.</small></td></tr>';
58
+ $html .= '<tr><th>width :</th><td><small>Auto : The width of the image, in pixels. Images should be at least 696 pixels wide.</small></td></tr>';
59
+ $html .= '</table>';
60
+ echo $html;
61
+
62
+ $html = '<table class="schema-admin-table">';
63
+ $html .= '<caption>publisher( required )</caption>';
64
+ $html .= '<tr><th>@type :</th><td><small>"Organization"</small></td></tr>';
65
+ $html .= '<tr><th><label for="name">Organization Name :</label></th><td>';
66
+ $html .= '<input type="text" name="option[' . "name" . ']" id="name" class="regular-text" required value="' . esc_attr( $option['name'] ) . '">';
67
+ $html .= '<small>Default : bloginfo("name")</small>';
68
+ $html .= '</td></tr>';
69
+ $html .= '</table>';
70
+ echo $html;
71
+
72
+ $html = '<table class="schema-admin-table">';
73
+ $html .= '<caption>logo( required )</caption>';
74
+ $html .= '<tr><th>@type :</th><td><small>"ImageObject"</small></td></tr>';
75
+ $html .= '<tr><th><label for="logo">url :</label></th><td>';
76
+ $html .= '<input type="text" name="option[' . "logo" . ']" id="logo" class="regular-text" required value="' . esc_attr( $option['logo'] ) . '">';
77
+ $html .= '<small>Default : bloginfo("logo") + "/images/logo.png"</small>';
78
+ $html .= '</td></tr>';
79
+ $html .= '<tr><th>height :</th><td><small>Auto : height >= 60px.</small></td></tr>';
80
+ $html .= '<tr><th>width :</th><td><small>Auto : width <= 600px.</small></td></tr>';
81
  $html .= '</table>';
82
  echo $html;
83
 
84
  echo '<p>Setting Knowledge : <a href="https://developers.google.com/structured-data/rich-snippets/articles" target="_blank">https://developers.google.com/structured-data/rich-snippets/articles</a></p>';
85
  submit_button();
86
  }
87
+
88
+ /**
89
+ * Return the default options array
90
+ *
91
+ * @since 2.2.0
92
+ * @version 2.2.0
93
+ * @param array $args
94
+ * @return array $args
95
+ */
96
+ private function get_default_options ( array $args ) {
97
+ $args['name'] = get_bloginfo('name');
98
+ $args['logo'] = get_bloginfo('url') . '/images/logo.png';
99
+
100
+ return (array) $args;
101
+ }
102
  }
includes/wp-structuring-admin-type-blog-posting.php CHANGED
@@ -3,7 +3,7 @@
3
  * Schema.org Type BlogPosting
4
  *
5
  * @author Kazuya Takami
6
- * @version 1.2.0
7
  * @since 1.2.0
8
  * @see wp-structuring-admin-db.php
9
  * @link http://schema.org/BlogPosting
@@ -14,31 +14,89 @@ class Structuring_Markup_Type_Blog_Posting {
14
  /**
15
  * Constructor Define.
16
  *
17
- * @since 1.2.0
 
 
18
  */
19
- public function __construct () {
20
- $this->page_render();
 
 
 
 
21
  }
22
 
23
  /**
24
  * Form Layout Render
25
  *
26
- * @since 1.2.0
 
 
27
  */
28
- private function page_render () {
29
  $html = '<table class="schema-admin-table">';
30
- $html .= '<caption>Basic Setting( Post Page Only )</caption>';
31
  $html .= '<tr><th>headline :</th><td><small>Default : post_title</small></td></tr>';
32
  $html .= '<tr><th>datePublished :</th><td><small>Default : get_the_time( DATE_ISO8601, ID )</small></td></tr>';
33
- $html .= '<tr><th>dateModified :</th><td><small>Default : get_the_modified_time( DATE_ISO8601, ID )</small></td></tr>';
34
- $html .= '<tr><th>author :</th><td><small>Default : get_the_author_meta( "display_name", author_ID )</small></td></tr>';
35
- $html .= '<tr><th>image :</th><td><small>Default : thumbnail</small></td></tr>';
36
  $html .= '<tr><th>description :</th><td><small>Default : post_excerpt</small></td></tr>';
37
- $html .= '<tr><th>articleBody :</th><td><small>Default : post_content</small></td></tr>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  $html .= '</table>';
39
  echo $html;
40
 
41
  echo '<p>Setting Knowledge : <a href="https://developers.google.com/structured-data/rich-snippets/articles" target="_blank">https://developers.google.com/structured-data/rich-snippets/articles</a></p>';
42
  submit_button();
43
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  }
3
  * Schema.org Type BlogPosting
4
  *
5
  * @author Kazuya Takami
6
+ * @version 2.2.0
7
  * @since 1.2.0
8
  * @see wp-structuring-admin-db.php
9
  * @link http://schema.org/BlogPosting
14
  /**
15
  * Constructor Define.
16
  *
17
+ * @since 1.0.0
18
+ * @version 2.2.0
19
+ * @param array $option
20
  */
21
+ public function __construct ( array $option ) {
22
+ /** Default Value Set */
23
+ if ( empty( $option ) ) {
24
+ $option = $this->get_default_options( $option );
25
+ }
26
+ $this->page_render( $option );
27
  }
28
 
29
  /**
30
  * Form Layout Render
31
  *
32
+ * @since 1.2.0
33
+ * @version 2.2.0
34
+ * @param array $option
35
  */
36
+ private function page_render ( array $option ) {
37
  $html = '<table class="schema-admin-table">';
38
+ $html .= '<caption>Basic Setting</caption>';
39
  $html .= '<tr><th>headline :</th><td><small>Default : post_title</small></td></tr>';
40
  $html .= '<tr><th>datePublished :</th><td><small>Default : get_the_time( DATE_ISO8601, ID )</small></td></tr>';
41
+ $html .= '<tr><th>dateModified :</th><td><small>Default : get_the_modified_time( DATE_ISO8601, false, ID )</small></td></tr>';
 
 
42
  $html .= '<tr><th>description :</th><td><small>Default : post_excerpt</small></td></tr>';
43
+ $html .= '</table>';
44
+ echo $html;
45
+
46
+ $html = '<table class="schema-admin-table">';
47
+ $html .= '<caption>mainEntityOfPage( recommended )</caption>';
48
+ $html .= '<tr><th>@type :</th><td><small>"WebPage"</small></td></tr>';
49
+ $html .= '<tr><th>@id :</th><td><small>Default : get_permalink( ID )</small></td></tr>';
50
+ $html .= '</table>';
51
+ echo $html;
52
+
53
+ $html = '<table class="schema-admin-table">';
54
+ $html .= '<caption>image( required )</caption>';
55
+ $html .= '<tr><th>@type :</th><td><small>"ImageObject"</small></td></tr>';
56
+ $html .= '<tr><th>url :</th><td><small>Default : thumbnail</small></td></tr>';
57
+ $html .= '<tr><th>height :</th><td><small>Auto : The height of the image, in pixels.</small></td></tr>';
58
+ $html .= '<tr><th>width :</th><td><small>Auto : The width of the image, in pixels. Images should be at least 696 pixels wide.</small></td></tr>';
59
+ $html .= '</table>';
60
+ echo $html;
61
+
62
+ $html = '<table class="schema-admin-table">';
63
+ $html .= '<caption>publisher( required )</caption>';
64
+ $html .= '<tr><th>@type :</th><td><small>"Organization"</small></td></tr>';
65
+ $html .= '<tr><th><label for="name">Organization Name :</label></th><td>';
66
+ $html .= '<input type="text" name="option[' . "name" . ']" id="name" class="regular-text" required value="' . esc_attr( $option['name'] ) . '">';
67
+ $html .= '<small>Default : bloginfo("name")</small>';
68
+ $html .= '</td></tr>';
69
+ $html .= '</table>';
70
+ echo $html;
71
+
72
+ $html = '<table class="schema-admin-table">';
73
+ $html .= '<caption>logo( required )</caption>';
74
+ $html .= '<tr><th>@type :</th><td><small>"ImageObject"</small></td></tr>';
75
+ $html .= '<tr><th><label for="logo">url :</label></th><td>';
76
+ $html .= '<input type="text" name="option[' . "logo" . ']" id="logo" class="regular-text" required value="' . esc_attr( $option['logo'] ) . '">';
77
+ $html .= '<small>Default : bloginfo("logo") + "/images/logo.png"</small>';
78
+ $html .= '</td></tr>';
79
+ $html .= '<tr><th>height :</th><td><small>Auto : height >= 60px.</small></td></tr>';
80
+ $html .= '<tr><th>width :</th><td><small>Auto : width <= 600px.</small></td></tr>';
81
  $html .= '</table>';
82
  echo $html;
83
 
84
  echo '<p>Setting Knowledge : <a href="https://developers.google.com/structured-data/rich-snippets/articles" target="_blank">https://developers.google.com/structured-data/rich-snippets/articles</a></p>';
85
  submit_button();
86
  }
87
+
88
+ /**
89
+ * Return the default options array
90
+ *
91
+ * @since 2.2.0
92
+ * @version 2.2.0
93
+ * @param array $args
94
+ * @return array $args
95
+ */
96
+ private function get_default_options ( array $args ) {
97
+ $args['name'] = get_bloginfo('name');
98
+ $args['logo'] = get_bloginfo('url') . '/images/logo.png';
99
+
100
+ return (array) $args;
101
+ }
102
  }
includes/wp-structuring-admin-type-news-article.php CHANGED
@@ -3,7 +3,7 @@
3
  * Schema.org Type News Article
4
  *
5
  * @author Kazuya Takami
6
- * @version 1.0.0
7
  * @since 1.0.0
8
  * @see wp-structuring-admin-db.php
9
  * @link http://schema.org/NewsArticle
@@ -14,29 +14,89 @@ class Structuring_Markup_Type_NewsArticle {
14
  /**
15
  * Constructor Define.
16
  *
17
- * @since 1.0.0
 
 
18
  */
19
- public function __construct () {
20
- $this->page_render();
 
 
 
 
21
  }
22
 
23
  /**
24
  * Form Layout Render
25
  *
26
- * @since 1.0.0
 
 
27
  */
28
- private function page_render () {
29
  $html = '<table class="schema-admin-table">';
30
- $html .= '<caption>Basic Setting( Post Page Only )</caption>';
31
  $html .= '<tr><th>headline :</th><td><small>Default : post_title</small></td></tr>';
32
  $html .= '<tr><th>datePublished :</th><td><small>Default : get_the_time( DATE_ISO8601, ID )</small></td></tr>';
33
- $html .= '<tr><th>image :</th><td><small>Default : thumbnail</small></td></tr>';
34
  $html .= '<tr><th>description :</th><td><small>Default : post_excerpt</small></td></tr>';
35
- $html .= '<tr><th>articleBody :</th><td><small>Default : post_content</small></td></tr>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  $html .= '</table>';
37
  echo $html;
38
 
39
  echo '<p>Setting Knowledge : <a href="https://developers.google.com/structured-data/rich-snippets/articles" target="_blank">https://developers.google.com/structured-data/rich-snippets/articles</a></p>';
40
  submit_button();
41
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  }
3
  * Schema.org Type News Article
4
  *
5
  * @author Kazuya Takami
6
+ * @version 2.2.0
7
  * @since 1.0.0
8
  * @see wp-structuring-admin-db.php
9
  * @link http://schema.org/NewsArticle
14
  /**
15
  * Constructor Define.
16
  *
17
+ * @since 1.0.0
18
+ * @version 2.2.0
19
+ * @param array $option
20
  */
21
+ public function __construct ( array $option ) {
22
+ /** Default Value Set */
23
+ if ( empty( $option ) ) {
24
+ $option = $this->get_default_options( $option );
25
+ }
26
+ $this->page_render( $option );
27
  }
28
 
29
  /**
30
  * Form Layout Render
31
  *
32
+ * @since 1.0.0
33
+ * @version 2.2.0
34
+ * @param array $option
35
  */
36
+ private function page_render ( array $option ) {
37
  $html = '<table class="schema-admin-table">';
38
+ $html .= '<caption>Basic Setting</caption>';
39
  $html .= '<tr><th>headline :</th><td><small>Default : post_title</small></td></tr>';
40
  $html .= '<tr><th>datePublished :</th><td><small>Default : get_the_time( DATE_ISO8601, ID )</small></td></tr>';
41
+ $html .= '<tr><th>dateModified :</th><td><small>Default : get_the_modified_time( DATE_ISO8601, false, ID )</small></td></tr>';
42
  $html .= '<tr><th>description :</th><td><small>Default : post_excerpt</small></td></tr>';
43
+ $html .= '</table>';
44
+ echo $html;
45
+
46
+ $html = '<table class="schema-admin-table">';
47
+ $html .= '<caption>mainEntityOfPage( recommended )</caption>';
48
+ $html .= '<tr><th>@type :</th><td><small>"WebPage"</small></td></tr>';
49
+ $html .= '<tr><th>@id :</th><td><small>Default : get_permalink( ID )</small></td></tr>';
50
+ $html .= '</table>';
51
+ echo $html;
52
+
53
+ $html = '<table class="schema-admin-table">';
54
+ $html .= '<caption>image( required )</caption>';
55
+ $html .= '<tr><th>@type :</th><td><small>"ImageObject"</small></td></tr>';
56
+ $html .= '<tr><th>url :</th><td><small>Default : thumbnail</small></td></tr>';
57
+ $html .= '<tr><th>height :</th><td><small>Auto : The height of the image, in pixels.</small></td></tr>';
58
+ $html .= '<tr><th>width :</th><td><small>Auto : The width of the image, in pixels. Images should be at least 696 pixels wide.</small></td></tr>';
59
+ $html .= '</table>';
60
+ echo $html;
61
+
62
+ $html = '<table class="schema-admin-table">';
63
+ $html .= '<caption>publisher( required )</caption>';
64
+ $html .= '<tr><th>@type :</th><td><small>"Organization"</small></td></tr>';
65
+ $html .= '<tr><th><label for="name">Organization Name :</label></th><td>';
66
+ $html .= '<input type="text" name="option[' . "name" . ']" id="name" class="regular-text" required value="' . esc_attr( $option['name'] ) . '">';
67
+ $html .= '<small>Default : bloginfo("name")</small>';
68
+ $html .= '</td></tr>';
69
+ $html .= '</table>';
70
+ echo $html;
71
+
72
+ $html = '<table class="schema-admin-table">';
73
+ $html .= '<caption>logo( required )</caption>';
74
+ $html .= '<tr><th>@type :</th><td><small>"ImageObject"</small></td></tr>';
75
+ $html .= '<tr><th><label for="logo">url :</label></th><td>';
76
+ $html .= '<input type="text" name="option[' . "logo" . ']" id="logo" class="regular-text" required value="' . esc_attr( $option['logo'] ) . '">';
77
+ $html .= '<small>Default : bloginfo("logo") + "/images/logo.png"</small>';
78
+ $html .= '</td></tr>';
79
+ $html .= '<tr><th>height :</th><td><small>Auto : height >= 60px.</small></td></tr>';
80
+ $html .= '<tr><th>width :</th><td><small>Auto : width <= 600px.</small></td></tr>';
81
  $html .= '</table>';
82
  echo $html;
83
 
84
  echo '<p>Setting Knowledge : <a href="https://developers.google.com/structured-data/rich-snippets/articles" target="_blank">https://developers.google.com/structured-data/rich-snippets/articles</a></p>';
85
  submit_button();
86
  }
87
+
88
+ /**
89
+ * Return the default options array
90
+ *
91
+ * @since 2.2.0
92
+ * @version 2.2.0
93
+ * @param array $args
94
+ * @return array $args
95
+ */
96
+ private function get_default_options ( array $args ) {
97
+ $args['name'] = get_bloginfo('name');
98
+ $args['logo'] = get_bloginfo('url') . '/images/logo.png';
99
+
100
+ return (array) $args;
101
+ }
102
  }
includes/wp-structuring-admin-type-organization.php CHANGED
@@ -3,7 +3,7 @@
3
  * Schema.org Type Organization
4
  *
5
  * @author Kazuya Takami
6
- * @version 1.0.0
7
  * @since 1.0.0
8
  * @see wp-structuring-admin-db.php
9
  * @link https://schema.org/Organization
@@ -14,9 +14,16 @@
14
  */
15
  class Structuring_Markup_Type_Organization {
16
 
 
 
 
 
 
 
 
17
  /** contactType defined. */
18
  private $contact_type_array = array(
19
- array("type" => "customer_support", "display" => "customer support"),
20
  array("type" => "technical_support", "display" => "technical support"),
21
  array("type" => "billing_support", "display" => "billing support"),
22
  array("type" => "bill_payment", "display" => "bill payment"),
@@ -59,8 +66,9 @@ class Structuring_Markup_Type_Organization {
59
  /**
60
  * Form Layout Render
61
  *
62
- * @since 1.0.0
63
- * @param array $option
 
64
  */
65
  private function page_render ( array $option ) {
66
  /** Logos */
@@ -105,7 +113,7 @@ class Structuring_Markup_Type_Organization {
105
  $html .= '>' . $value['display'] . '</option>';
106
  }
107
  $html .= '</select>';
108
- $html .= '<small>Default : "customer support"</small>';
109
  $html .= '</td></tr>';
110
  $html .= '<tr><th><label for="area_served">areaServed :</label></th><td>';
111
  $html .= '<input type="text" name="option[' . "area_served" . ']" id="area_served" class="regular-text" value="' . esc_attr( $option['area_served'] ) . '">';
3
  * Schema.org Type Organization
4
  *
5
  * @author Kazuya Takami
6
+ * @version 2.2.0
7
  * @since 1.0.0
8
  * @see wp-structuring-admin-db.php
9
  * @link https://schema.org/Organization
14
  */
15
  class Structuring_Markup_Type_Organization {
16
 
17
+
18
+ /**
19
+ * Variable definition.
20
+ *
21
+ * @since 1.0.0
22
+ * @version 2.2.0
23
+ */
24
  /** contactType defined. */
25
  private $contact_type_array = array(
26
+ array("type" => "customer service", "display" => "customer service"),
27
  array("type" => "technical_support", "display" => "technical support"),
28
  array("type" => "billing_support", "display" => "billing support"),
29
  array("type" => "bill_payment", "display" => "bill payment"),
66
  /**
67
  * Form Layout Render
68
  *
69
+ * @since 1.0.0
70
+ * @version 2.2.0
71
+ * @param array $option
72
  */
73
  private function page_render ( array $option ) {
74
  /** Logos */
113
  $html .= '>' . $value['display'] . '</option>';
114
  }
115
  $html .= '</select>';
116
+ $html .= '<small>Default : "customer service"</small>';
117
  $html .= '</td></tr>';
118
  $html .= '<tr><th><label for="area_served">areaServed :</label></th><td>';
119
  $html .= '<input type="text" name="option[' . "area_served" . ']" id="area_served" class="regular-text" value="' . esc_attr( $option['area_served'] ) . '">';
includes/wp-structuring-display.php CHANGED
@@ -47,7 +47,7 @@ class Structuring_Markup_Display {
47
  * Setting JSON-LD Template
48
  *
49
  * @since 1.0.0
50
- * @version 2.1.0
51
  * @param Structuring_Markup_Admin_Db $db
52
  * @param string $output
53
  */
@@ -59,29 +59,35 @@ class Structuring_Markup_Display {
59
  if ( isset( $row->type ) && isset( $row->activate ) && $row->activate === 'on' ) {
60
  switch ( $row->type ) {
61
  case 'article':
62
- $this->set_schema_article();
 
 
63
  break;
64
  case 'blog_posting':
65
- $this->set_schema_blog_posting();
 
 
66
  break;
67
  case 'breadcrumb':
68
- if ( isset( $row->options ) ) {
69
- $this->set_schema_breadcrumb(unserialize($row->options));
70
  }
71
  break;
72
  case 'event':
73
  $this->set_schema_event();
74
  break;
75
  case 'news_article':
76
- $this->set_schema_news_article();
 
 
77
  break;
78
  case 'organization':
79
- if ( isset( $row->options ) ) {
80
  $this->set_schema_organization( unserialize( $row->options ) );
81
  }
82
  break;
83
  case 'website':
84
- if ( isset( $row->options ) ) {
85
  $this->set_schema_website( unserialize( $row->options ) );
86
  }
87
  break;
@@ -119,21 +125,51 @@ class Structuring_Markup_Display {
119
  * Setting schema.org Article
120
  *
121
  * @since 1.1.0
122
- * @version 1.1.3
 
123
  */
124
- private function set_schema_article () {
125
  global $post;
126
- if ( has_post_thumbnail( $post->ID ) ) {
 
 
 
127
  $images = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
 
 
 
 
128
  $args = array(
129
- "@context" => "http://schema.org",
130
- "@type" => "Article",
131
- "headline" => $this->escape_text_tags( $post->post_title ),
 
 
 
 
 
 
 
 
 
 
132
  "datePublished" => get_the_time( DATE_ISO8601, $post->ID ),
133
- "author" => $this->escape_text_tags( get_the_author_meta( 'display_name', $post->post_author ) ),
134
- "image" => array( $images[0] ),
135
- "description" => $this->escape_text_tags( $post->post_excerpt ),
136
- "articleBody" => $this->escape_text_tags( $post->post_content )
 
 
 
 
 
 
 
 
 
 
 
 
137
  );
138
  $this->set_schema_json( $args );
139
  }
@@ -143,22 +179,51 @@ class Structuring_Markup_Display {
143
  * Setting schema.org BlogPosting
144
  *
145
  * @since 1.2.0
146
- * @version 1.2.0
 
147
  */
148
- private function set_schema_blog_posting () {
149
  global $post;
150
- if ( has_post_thumbnail( $post->ID ) ) {
 
 
 
151
  $images = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
 
 
 
 
152
  $args = array(
153
- "@context" => "http://schema.org",
154
- "@type" => "BlogPosting",
155
- "headline" => $this->escape_text_tags( $post->post_title ),
 
 
 
 
 
 
 
 
 
 
156
  "datePublished" => get_the_time( DATE_ISO8601, $post->ID ),
157
- "dateModified" => get_the_modified_time( DATE_ISO8601, $post->ID ),
158
- "author" => $this->escape_text_tags( get_the_author_meta( 'display_name', $post->post_author ) ),
159
- "image" => array( $images[0] ),
160
- "description" => $this->escape_text_tags( $post->post_excerpt ),
161
- "articleBody" => $this->escape_text_tags( $post->post_content )
 
 
 
 
 
 
 
 
 
 
 
162
  );
163
  $this->set_schema_json( $args );
164
  }
@@ -182,9 +247,9 @@ class Structuring_Markup_Display {
182
  $position = 1;
183
  foreach ($item_array as $item) {
184
  $item_list_element[] = array(
185
- "@type" => "ListItem",
186
  "position" => $position,
187
- "item" => $item
188
  );
189
  $position++;
190
  }
@@ -192,7 +257,7 @@ class Structuring_Markup_Display {
192
  /** Breadcrumb Schema build */
193
  $args = array(
194
  "@context" => "http://schema.org",
195
- "@type" => "BreadcrumbList",
196
  "itemListElement" => $item_list_element
197
  );
198
 
@@ -250,20 +315,51 @@ class Structuring_Markup_Display {
250
  * Setting schema.org NewsArticle
251
  *
252
  * @since 1.0.0
253
- * @version 1.1.3
 
254
  */
255
- private function set_schema_news_article () {
256
  global $post;
257
- if ( has_post_thumbnail( $post->ID ) ) {
258
- $images = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
 
 
 
 
 
 
 
259
  $args = array(
260
- "@context" => "http://schema.org",
261
- "@type" => "NewsArticle",
262
- "headline" => $this->escape_text_tags( $post->post_title ),
 
 
 
 
 
 
 
 
 
 
263
  "datePublished" => get_the_time( DATE_ISO8601, $post->ID ),
264
- "image" => array( $images[0] ),
265
- "description" => $this->escape_text_tags( $post->post_excerpt ),
266
- "articleBody" => $this->escape_text_tags( $post->post_content )
 
 
 
 
 
 
 
 
 
 
 
 
 
267
  );
268
  $this->set_schema_json( $args );
269
  }
@@ -273,7 +369,7 @@ class Structuring_Markup_Display {
273
  * Setting schema.org Organization
274
  *
275
  * @since 1.0.0
276
- * @version 1.2.1
277
  * @param array $options
278
  */
279
  private function set_schema_organization ( array $options ) {
@@ -282,8 +378,8 @@ class Structuring_Markup_Display {
282
  "@context" => "http://schema.org",
283
  "@type" => "Organization",
284
  "name" => isset( $options['name'] ) ? esc_html( $options['name'] ) : "",
285
- "url" => isset( $options['url'] ) ? esc_html( $options['url'] ) : "",
286
- "logo" => isset( $options['logo'] ) ? esc_html( $options['logo'] ) : ""
287
  );
288
 
289
  /** Corporate Contact */
@@ -315,8 +411,9 @@ class Structuring_Markup_Display {
315
  /**
316
  * Setting schema.org WebSite
317
  *
318
- * @since 1.0.0
319
- * @param array $options
 
320
  */
321
  private function set_schema_website ( array $options ) {
322
  $args = array(
@@ -324,13 +421,13 @@ class Structuring_Markup_Display {
324
  "@type" => "WebSite",
325
  "name" => isset( $options['name'] ) ? esc_html( $options['name'] ) : "",
326
  "alternateName" => isset( $options['alternateName'] ) ? esc_html( $options['alternateName'] ) : "",
327
- "url" => isset( $options['url'] ) ? esc_html( $options['url'] ) : ""
328
  );
329
 
330
  if ( isset( $options['potential_action'] ) && $options['potential_action'] === 'on' ) {
331
  $potential_action["potentialAction"] = array(
332
  "@type" => "SearchAction",
333
- "target" => isset( $options['target'] ) ? esc_html( $options['target'] ) . "{search_term_string}" : "",
334
  "query-input" => isset( $options['target'] ) ? "required name=search_term_string" : ""
335
  );
336
  $args = array_merge( $args, $potential_action );
47
  * Setting JSON-LD Template
48
  *
49
  * @since 1.0.0
50
+ * @version 2.2.0
51
  * @param Structuring_Markup_Admin_Db $db
52
  * @param string $output
53
  */
59
  if ( isset( $row->type ) && isset( $row->activate ) && $row->activate === 'on' ) {
60
  switch ( $row->type ) {
61
  case 'article':
62
+ if ( isset( $row->options ) && $row->options ) {
63
+ $this->set_schema_article( unserialize( $row->options ) );
64
+ }
65
  break;
66
  case 'blog_posting':
67
+ if ( isset( $row->options ) && $row->options ) {
68
+ $this->set_schema_blog_posting( unserialize( $row->options ) );
69
+ }
70
  break;
71
  case 'breadcrumb':
72
+ if ( isset( $row->options ) && $row->options ) {
73
+ $this->set_schema_breadcrumb( unserialize( $row->options ) );
74
  }
75
  break;
76
  case 'event':
77
  $this->set_schema_event();
78
  break;
79
  case 'news_article':
80
+ if ( isset( $row->options ) && $row->options ) {
81
+ $this->set_schema_news_article( unserialize( $row->options ) );
82
+ }
83
  break;
84
  case 'organization':
85
+ if ( isset( $row->options ) && $row->options ) {
86
  $this->set_schema_organization( unserialize( $row->options ) );
87
  }
88
  break;
89
  case 'website':
90
+ if ( isset( $row->options ) && $row->options ) {
91
  $this->set_schema_website( unserialize( $row->options ) );
92
  }
93
  break;
125
  * Setting schema.org Article
126
  *
127
  * @since 1.1.0
128
+ * @version 2.2.0
129
+ * @param array $options
130
  */
131
+ private function set_schema_article ( array $options ) {
132
  global $post;
133
+
134
+ $options['logo'] = isset( $options['logo'] ) ? esc_url( $options['logo'] ) : "";
135
+
136
+ if ( has_post_thumbnail( $post->ID ) && @getimagesize( $options['logo'] ) ) {
137
  $images = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
138
+ $logo = getimagesize( $options['logo'] );
139
+ $excerpt = $this->escape_text_tags( $post->post_excerpt );
140
+ $content = $excerpt === "" ? mb_substr( $this->escape_text_tags( $post->post_content ), 0, 110 ) : $excerpt;
141
+
142
  $args = array(
143
+ "@context" => "http://schema.org",
144
+ "@type" => "Article",
145
+ "mainEntityOfPage" => array(
146
+ "@type" => "WebPage",
147
+ "@id" => get_permalink( $post->ID )
148
+ ),
149
+ "headline" => $this->escape_text_tags( $post->post_title ),
150
+ "image" => array(
151
+ "@type" => "ImageObject",
152
+ "url" => $images[0],
153
+ "width" => $images[1],
154
+ "height" => $images[2]
155
+ ),
156
  "datePublished" => get_the_time( DATE_ISO8601, $post->ID ),
157
+ "dateModified" => get_post_modified_time( DATE_ISO8601, __return_false(), $post->ID ),
158
+ "author" => array(
159
+ "@type" => "Person",
160
+ "name" => $this->escape_text_tags( get_the_author_meta( 'display_name', $post->post_author ) )
161
+ ),
162
+ "publisher" => array(
163
+ "@type" => "Organization",
164
+ "name" => isset( $options['name'] ) ? esc_html( $options['name'] ) : "",
165
+ "logo" => array(
166
+ "@type" => "ImageObject",
167
+ "url" => isset( $options['logo'] ) ? esc_url( $options['logo'] ) : "",
168
+ "width" => $logo[0],
169
+ "height" => $logo[1]
170
+ )
171
+ ),
172
+ "description" => $content
173
  );
174
  $this->set_schema_json( $args );
175
  }
179
  * Setting schema.org BlogPosting
180
  *
181
  * @since 1.2.0
182
+ * @version 2.2.0
183
+ * @param array $options
184
  */
185
+ private function set_schema_blog_posting ( array $options ) {
186
  global $post;
187
+
188
+ $options['logo'] = isset( $options['logo'] ) ? esc_url( $options['logo'] ) : "";
189
+
190
+ if ( has_post_thumbnail( $post->ID ) && @getimagesize( $options['logo'] ) ) {
191
  $images = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
192
+ $logo = getimagesize( $options['logo'] );
193
+ $excerpt = $this->escape_text_tags( $post->post_excerpt );
194
+ $content = $excerpt === "" ? mb_substr( $this->escape_text_tags( $post->post_content ), 0, 110 ) : $excerpt;
195
+
196
  $args = array(
197
+ "@context" => "http://schema.org",
198
+ "@type" => "BlogPosting",
199
+ "mainEntityOfPage" => array(
200
+ "@type" => "WebPage",
201
+ "@id" => get_permalink( $post->ID )
202
+ ),
203
+ "headline" => $this->escape_text_tags( $post->post_title ),
204
+ "image" => array(
205
+ "@type" => "ImageObject",
206
+ "url" => $images[0],
207
+ "width" => $images[1],
208
+ "height" => $images[2]
209
+ ),
210
  "datePublished" => get_the_time( DATE_ISO8601, $post->ID ),
211
+ "dateModified" => get_post_modified_time( DATE_ISO8601, __return_false(), $post->ID ),
212
+ "author" => array(
213
+ "@type" => "Person",
214
+ "name" => $this->escape_text_tags( get_the_author_meta( 'display_name', $post->post_author ) )
215
+ ),
216
+ "publisher" => array(
217
+ "@type" => "Organization",
218
+ "name" => isset( $options['name'] ) ? esc_html( $options['name'] ) : "",
219
+ "logo" => array(
220
+ "@type" => "ImageObject",
221
+ "url" => isset( $options['logo'] ) ? esc_url( $options['logo'] ) : "",
222
+ "width" => $logo[0],
223
+ "height" => $logo[1]
224
+ )
225
+ ),
226
+ "description" => $content
227
  );
228
  $this->set_schema_json( $args );
229
  }
247
  $position = 1;
248
  foreach ($item_array as $item) {
249
  $item_list_element[] = array(
250
+ "@type" => "ListItem",
251
  "position" => $position,
252
+ "item" => $item
253
  );
254
  $position++;
255
  }
257
  /** Breadcrumb Schema build */
258
  $args = array(
259
  "@context" => "http://schema.org",
260
+ "@type" => "BreadcrumbList",
261
  "itemListElement" => $item_list_element
262
  );
263
 
315
  * Setting schema.org NewsArticle
316
  *
317
  * @since 1.0.0
318
+ * @version 2.2.0
319
+ * @param array $options
320
  */
321
+ private function set_schema_news_article ( array $options ) {
322
  global $post;
323
+
324
+ $options['logo'] = isset( $options['logo'] ) ? esc_url( $options['logo'] ) : "";
325
+
326
+ if ( has_post_thumbnail( $post->ID ) && @getimagesize( $options['logo'] ) ) {
327
+ $images = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
328
+ $logo = getimagesize( $options['logo'] );
329
+ $excerpt = $this->escape_text_tags( $post->post_excerpt );
330
+ $content = $excerpt === "" ? mb_substr( $this->escape_text_tags( $post->post_content ), 0, 110 ) : $excerpt;
331
+
332
  $args = array(
333
+ "@context" => "http://schema.org",
334
+ "@type" => "NewsArticle",
335
+ "mainEntityOfPage" => array(
336
+ "@type" => "WebPage",
337
+ "@id" => get_permalink( $post->ID )
338
+ ),
339
+ "headline" => $this->escape_text_tags( $post->post_title ),
340
+ "image" => array(
341
+ "@type" => "ImageObject",
342
+ "url" => $images[0],
343
+ "width" => $images[1],
344
+ "height" => $images[2]
345
+ ),
346
  "datePublished" => get_the_time( DATE_ISO8601, $post->ID ),
347
+ "dateModified" => get_post_modified_time( DATE_ISO8601, __return_false(), $post->ID ),
348
+ "author" => array(
349
+ "@type" => "Person",
350
+ "name" => $this->escape_text_tags( get_the_author_meta( 'display_name', $post->post_author ) )
351
+ ),
352
+ "publisher" => array(
353
+ "@type" => "Organization",
354
+ "name" => isset( $options['name'] ) ? esc_html( $options['name'] ) : "",
355
+ "logo" => array(
356
+ "@type" => "ImageObject",
357
+ "url" => isset( $options['logo'] ) ? esc_url( $options['logo'] ) : "",
358
+ "width" => $logo[0],
359
+ "height" => $logo[1]
360
+ )
361
+ ),
362
+ "description" => $content
363
  );
364
  $this->set_schema_json( $args );
365
  }
369
  * Setting schema.org Organization
370
  *
371
  * @since 1.0.0
372
+ * @version 2.2.0
373
  * @param array $options
374
  */
375
  private function set_schema_organization ( array $options ) {
378
  "@context" => "http://schema.org",
379
  "@type" => "Organization",
380
  "name" => isset( $options['name'] ) ? esc_html( $options['name'] ) : "",
381
+ "url" => isset( $options['url'] ) ? esc_url( $options['url'] ) : "",
382
+ "logo" => isset( $options['logo'] ) ? esc_url( $options['logo'] ) : ""
383
  );
384
 
385
  /** Corporate Contact */
411
  /**
412
  * Setting schema.org WebSite
413
  *
414
+ * @since 1.0.0
415
+ * @version 2.2.0
416
+ * @param array $options
417
  */
418
  private function set_schema_website ( array $options ) {
419
  $args = array(
421
  "@type" => "WebSite",
422
  "name" => isset( $options['name'] ) ? esc_html( $options['name'] ) : "",
423
  "alternateName" => isset( $options['alternateName'] ) ? esc_html( $options['alternateName'] ) : "",
424
+ "url" => isset( $options['url'] ) ? esc_url( $options['url'] ) : ""
425
  );
426
 
427
  if ( isset( $options['potential_action'] ) && $options['potential_action'] === 'on' ) {
428
  $potential_action["potentialAction"] = array(
429
  "@type" => "SearchAction",
430
+ "target" => isset( $options['target'] ) ? esc_url( $options['target'] ) . "{search_term_string}" : "",
431
  "query-input" => isset( $options['target'] ) ? "required name=search_term_string" : ""
432
  );
433
  $args = array_merge( $args, $potential_action );
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: miiitaka
3
  Tags: schema, schema.org, json, json-ld, seo, post, posts, google, shortcode, breadcrumb
4
  Requires at least: 4.3.1
5
  Tested up to: 4.4
6
- Stable tag: 2.1.3
7
 
8
  It is plug in to implement structured markup (JSON-LD syntax) by schema.org definition on an post page, fixed page and etc.
9
 
@@ -27,7 +27,6 @@ Base knowledge is "https://schema.org/" and "https://developers.google.com/struc
27
  You can display the breadcrumbs in the short code. Breadcrumb definition is available even if not active.
28
 
29
  [ Example ]
30
-
31
  `
32
  <?php
33
  if (shortcode_exists('wp-structuring-markup-breadcrumb')) {
@@ -45,6 +44,10 @@ if (shortcode_exists('wp-structuring-markup-breadcrumb')) {
45
 
46
  == Changelog ==
47
 
 
 
 
 
48
  = 2.1.3 (2015-12-11) =
49
 
50
  * Fixed : Minor bug fixed.
3
  Tags: schema, schema.org, json, json-ld, seo, post, posts, google, shortcode, breadcrumb
4
  Requires at least: 4.3.1
5
  Tested up to: 4.4
6
+ Stable tag: 2.2.0
7
 
8
  It is plug in to implement structured markup (JSON-LD syntax) by schema.org definition on an post page, fixed page and etc.
9
 
27
  You can display the breadcrumbs in the short code. Breadcrumb definition is available even if not active.
28
 
29
  [ Example ]
 
30
  `
31
  <?php
32
  if (shortcode_exists('wp-structuring-markup-breadcrumb')) {
44
 
45
  == Changelog ==
46
 
47
+ = 2.2.0 (2015-12-16) =
48
+
49
+ * Updated : Updated on December 14, 2015 was structured data (Article) AMP correspondence. https://developers.google.com/structured-data/rich-snippets/articles?hl=ja
50
+
51
  = 2.1.3 (2015-12-11) =
52
 
53
  * Fixed : Minor bug fixed.
wp-structuring-markup.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Markup (JSON-LD) structured in schema.org
4
  Plugin URI: https://wordpress.org/plugins/wp-structuring-markup/
5
  Description: It is plug in to implement structured markup (JSON-LD syntax) by schema.org definition on an article or the fixed page.
6
- Version: 2.1.3
7
  Author: Kazuya Takami
8
  Author URI: http://programp.com/
9
  License: GPLv2 or later
3
  Plugin Name: Markup (JSON-LD) structured in schema.org
4
  Plugin URI: https://wordpress.org/plugins/wp-structuring-markup/
5
  Description: It is plug in to implement structured markup (JSON-LD syntax) by schema.org definition on an article or the fixed page.
6
+ Version: 2.2.0
7
  Author: Kazuya Takami
8
  Author URI: http://programp.com/
9
  License: GPLv2 or later