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

Version Description

(2016-02-06) =

  • Added : Schema.org type "Person".
  • Updated : Schema.org type "LocalBusiness" OpenHours : shift time setting.
  • Check : WordPress version 4.4.2 operation check.
Download this release

Release Info

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

Code changes from version 2.3.3 to 2.4.0

css/style.css CHANGED
@@ -42,7 +42,6 @@
42
  width: 150px;
43
  }
44
  .schema-admin-table td {
45
- padding: 1px 0 0 0;
46
  vertical-align: middle;
47
  }
48
  .schema-admin-table td label {
@@ -53,4 +52,36 @@
53
  }
54
  .schema-admin-table input[type="checkbox"] {
55
  margin: 0 5px 0 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  }
42
  width: 150px;
43
  }
44
  .schema-admin-table td {
 
45
  vertical-align: middle;
46
  }
47
  .schema-admin-table td label {
52
  }
53
  .schema-admin-table input[type="checkbox"] {
54
  margin: 0 5px 0 0;
55
+ }
56
+
57
+ /** LocalBusiness */
58
+ .markup-time {
59
+ color: #999;
60
+ cursor: pointer;
61
+ width: 18px;
62
+ height: 18px;
63
+ line-height: 20px;
64
+ font-size: 14px;
65
+ border: transparent solid 1px;
66
+ border-color: #BBB;
67
+ background-color: #fff;
68
+ border-radius: 100%;
69
+ margin-top: 5px;
70
+ }
71
+
72
+ .markup-time:hover {
73
+ color: #fff;
74
+ border-color: transparent;
75
+ }
76
+
77
+ .markup-time.plus:hover {
78
+ background-color: #00a0d2;
79
+ }
80
+
81
+ .markup-time.minus {
82
+ line-height: 18px;
83
+ }
84
+
85
+ .markup-time.minus:hover {
86
+ background-color: #F55E4F;
87
  }
includes/wp-structuring-admin-db.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author Kazuya Takami
6
  * @since 1.0.0
7
- * @version 2.3.0
8
  */
9
  class Structuring_Markup_Admin_Db {
10
 
@@ -12,7 +12,7 @@ class Structuring_Markup_Admin_Db {
12
  * Variable definition.
13
  *
14
  * @since 1.0.0
15
- * @version 2.3.0
16
  */
17
  private $table_name;
18
 
@@ -25,6 +25,7 @@ class Structuring_Markup_Admin_Db {
25
  "local_business" => "Local Business",
26
  "news_article" => "News Article",
27
  "organization" => "Organization",
 
28
  "website" => "Web Site"
29
  );
30
 
@@ -106,6 +107,11 @@ class Structuring_Markup_Admin_Db {
106
  'register_date' => date( "Y-m-d H:i:s" ),
107
  'update_date' => date( "Y-m-d H:i:s" )
108
  );
 
 
 
 
 
109
  }
110
  }
111
  $this->insert_options( $args );
@@ -114,6 +120,43 @@ class Structuring_Markup_Admin_Db {
114
  }
115
  }
116
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  /**
118
  * Create table execute
119
  *
4
  *
5
  * @author Kazuya Takami
6
  * @since 1.0.0
7
+ * @version 2.4.0
8
  */
9
  class Structuring_Markup_Admin_Db {
10
 
12
  * Variable definition.
13
  *
14
  * @since 1.0.0
15
+ * @version 2.4.0
16
  */
17
  private $table_name;
18
 
25
  "local_business" => "Local Business",
26
  "news_article" => "News Article",
27
  "organization" => "Organization",
28
+ "person" => "Person",
29
  "website" => "Web Site"
30
  );
31
 
107
  'register_date' => date( "Y-m-d H:i:s" ),
108
  'update_date' => date( "Y-m-d H:i:s" )
109
  );
110
+
111
+ // LocalBusiness Convert data
112
+ if ( $key === 'local_business' && $activate === 'on' ) {
113
+ $args['options'] = $this->convert_local_business( $list->options );
114
+ }
115
  }
116
  }
117
  $this->insert_options( $args );
120
  }
121
  }
122
 
123
+ /**
124
+ * To convert the data for the new version of the "LocalBusiness".
125
+ * version 2.3.3 -> 2.4.0
126
+ *
127
+ * @since 2.4.0
128
+ * @param string $options
129
+ * @return string $convert
130
+ */
131
+ private function convert_local_business( $options ) {
132
+ $options = unserialize( $options );
133
+ $convert = $options;
134
+
135
+ $convert['Mo'] = isset( $options['mon'] ) ? $options['mon'] : "";
136
+ $convert['week']['Mo'][0]['open'] = isset( $options['mon-open'] ) ? $options['mon-open'] : "";
137
+ $convert['week']['Mo'][0]['close'] = isset( $options['mon-close'] ) ? $options['mon-close'] : "";
138
+ $convert['Tu'] = isset( $options['tue'] ) ? $options['tue'] : "";
139
+ $convert['week']['Tu'][0]['open'] = isset( $options['tue-open'] ) ? $options['tue-open'] : "";
140
+ $convert['week']['Tu'][0]['close'] = isset( $options['tue-close'] ) ? $options['tue-close'] : "";
141
+ $convert['We'] = isset( $options['wed'] ) ? $options['wed'] : "";
142
+ $convert['week']['We'][0]['open'] = isset( $options['wed-open'] ) ? $options['wed-open'] : "";
143
+ $convert['week']['We'][0]['close'] = isset( $options['wed-close'] ) ? $options['wed-close'] : "";
144
+ $convert['Th'] = isset( $options['thu'] ) ? $options['mon'] : "";
145
+ $convert['week']['Th'][0]['open'] = isset( $options['thu-open'] ) ? $options['thu-open'] : "";
146
+ $convert['week']['Th'][0]['close'] = isset( $options['thu-close'] ) ? $options['thu-close'] : "";
147
+ $convert['Fr'] = isset( $options['fri'] ) ? $options['fri'] : "";
148
+ $convert['week']['Fr'][0]['open'] = isset( $options['fri-open'] ) ? $options['fri-open'] : "";
149
+ $convert['week']['Fr'][0]['close'] = isset( $options['fri-close'] ) ? $options['fri-close'] : "";
150
+ $convert['Sa'] = isset( $options['sat'] ) ? $options['sat'] : "";
151
+ $convert['week']['Sa'][0]['open'] = isset( $options['sat-open'] ) ? $options['sat-open'] : "";
152
+ $convert['week']['Sa'][0]['close'] = isset( $options['sat-close'] ) ? $options['sat-close'] : "";
153
+ $convert['Su'] = isset( $options['sun'] ) ? $options['sun'] : "";
154
+ $convert['week']['Su'][0]['open'] = isset( $options['sun-open'] ) ? $options['sun-open'] : "";
155
+ $convert['week']['Su'][0]['close'] = isset( $options['sun-close'] ) ? $options['sun-close'] : "";
156
+
157
+ return (string) serialize( $convert );
158
+ }
159
+
160
  /**
161
  * Create table execute
162
  *
includes/wp-structuring-admin-list.php CHANGED
@@ -104,4 +104,4 @@ class Structuring_Markup_Admin_List {
104
  $output = implode( ",", unserialize( $obj ) );
105
  return (string) $output;
106
  }
107
- }
104
  $output = implode( ",", unserialize( $obj ) );
105
  return (string) $output;
106
  }
107
+ }
includes/wp-structuring-admin-post.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author Kazuya Takami
6
  * @since 1.0.0
7
- * @version 2.3.3
8
  */
9
  class Structuring_Markup_Admin_Post {
10
 
@@ -80,7 +80,7 @@ class Structuring_Markup_Admin_Post {
80
  * Setting Page of the Admin Screen.
81
  *
82
  * @since 1.0.0
83
- * @version 2.3.3
84
  * @param array $options
85
  * @param string $status
86
  */
@@ -178,6 +178,17 @@ class Structuring_Markup_Admin_Post {
178
  require_once ( plugin_dir_path( __FILE__ ) . 'wp-structuring-admin-type-organization.php' );
179
  new Structuring_Markup_Type_Organization( $options['option'] );
180
  break;
 
 
 
 
 
 
 
 
 
 
 
181
  case 'website':
182
  $html = $this->output_checkbox_render( $options['output'], "all", "All", esc_html__( 'All Page', $this->text_domain ) );
183
  $html .= $this->output_checkbox_render( $options['output'], "home", "Top", esc_html__( 'Top Page', $this->text_domain ) );
4
  *
5
  * @author Kazuya Takami
6
  * @since 1.0.0
7
+ * @version 2.4.0
8
  */
9
  class Structuring_Markup_Admin_Post {
10
 
80
  * Setting Page of the Admin Screen.
81
  *
82
  * @since 1.0.0
83
+ * @version 2.4.0
84
  * @param array $options
85
  * @param string $status
86
  */
178
  require_once ( plugin_dir_path( __FILE__ ) . 'wp-structuring-admin-type-organization.php' );
179
  new Structuring_Markup_Type_Organization( $options['option'] );
180
  break;
181
+ case 'person':
182
+ $html = $this->output_checkbox_render( $options['output'], "all", "All", esc_html__( 'All Page', $this->text_domain ) );
183
+ $html .= $this->output_checkbox_render( $options['output'], "home", "Top", esc_html__( 'Top Page', $this->text_domain ) );
184
+ $html .= $this->output_checkbox_render( $options['output'], "post", "Post", esc_html__( 'Post Page', $this->text_domain ) );
185
+ $html .= $this->output_checkbox_render( $options['output'], "page", "Fixed", esc_html__( 'Fixed Page', $this->text_domain ) );
186
+ $html .= '</td></tr></table><hr>';
187
+ echo $html;
188
+
189
+ require_once ( plugin_dir_path( __FILE__ ) . 'wp-structuring-admin-type-person.php' );
190
+ new Structuring_Markup_Type_Person( $options['option'] );
191
+ break;
192
  case 'website':
193
  $html = $this->output_checkbox_render( $options['output'], "all", "All", esc_html__( 'All Page', $this->text_domain ) );
194
  $html .= $this->output_checkbox_render( $options['output'], "home", "Top", esc_html__( 'Top Page', $this->text_domain ) );
includes/wp-structuring-admin-type-local-business.php CHANGED
@@ -177,13 +177,13 @@ class Structuring_Markup_Type_LocalBusiness {
177
 
178
  /** weekType defined. */
179
  private $week_array = array(
180
- array("type" => "mon", "display" => "Monday"),
181
- array("type" => "tue", "display" => "Tuesday"),
182
- array("type" => "wed", "display" => "Wednesday"),
183
- array("type" => "thu", "display" => "Thursday"),
184
- array("type" => "fri", "display" => "Friday"),
185
- array("type" => "sat", "display" => "Saturday"),
186
- array("type" => "sun", "display" => "Sunday")
187
  );
188
 
189
  /**
@@ -204,6 +204,7 @@ class Structuring_Markup_Type_LocalBusiness {
204
  * Form Layout Render
205
  *
206
  * @since 2.3.3
 
207
  * @param array $option
208
  */
209
  private function page_render ( array $option ) {
@@ -259,12 +260,30 @@ class Structuring_Markup_Type_LocalBusiness {
259
  $html = '<table class="schema-admin-table">';
260
  $html .= '<caption>Opening Hours Specification ( recommended )</caption>';
261
 
 
 
262
  foreach ( $this->week_array as $value ) {
263
  if ( !isset( $option[$value['type']] ) ) {
264
  $option[$value['type']] = "";
265
  }
 
266
  $html .= $this->set_form_checkbox( $value['type'], $value['display'], $option[$value['type']], 'Enabled' );
267
- $html .= $this->set_form_time( $value['type'], '', $option[$value['type'] . '-open'], $option[$value['type'] . '-close'], '' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
268
  }
269
 
270
  $html .= '</table>';
@@ -278,6 +297,7 @@ class Structuring_Markup_Type_LocalBusiness {
278
  * Return the default options array
279
  *
280
  * @since 2.3.0
 
281
  * @param array $args
282
  * @return array $args
283
  */
@@ -300,9 +320,9 @@ class Structuring_Markup_Type_LocalBusiness {
300
  $args['opening_active'] = '';
301
 
302
  foreach ( $this->week_array as $value ) {
303
- $args[$value['type']] = '';
304
- $args[$value['type'] . '-open'] = '';
305
- $args[$value['type'] . '-close'] = '';
306
  }
307
 
308
  return (array) $args;
@@ -387,22 +407,28 @@ class Structuring_Markup_Type_LocalBusiness {
387
  * Return the form time
388
  *
389
  * @since 2.3.0
 
390
  * @param string $id
391
  * @param string $display
392
  * @param string $value1
393
  * @param string $value2
394
  * @param string $note
 
395
  * @return string $html
396
  */
397
- private function set_form_time ( $id, $display, $value1 = "", $value2 = "", $note = "" ) {
398
  $value1 = esc_attr( $value1 );
399
  $value2 = esc_attr( $value2 );
400
 
401
- $format = '<tr><th><label for=%s>%s :</label></th><td>';
402
- $format .= 'Open Time : <input type="time" name="option[%s-open]" id="%s-open" value="%s">';
403
- $format .= ' Close Time : <input type="time" name="option[%s-close]" id="%s-close" value="%s">';
404
- $format .= '<small>%s</small></td></tr>';
 
 
 
 
405
 
406
- return (string) sprintf( $format, $id, $display, $id, $id, $value1, $id, $id, $value2, $note );
407
  }
408
- }
177
 
178
  /** weekType defined. */
179
  private $week_array = array(
180
+ array("type" => "Mo", "display" => "Monday"),
181
+ array("type" => "Tu", "display" => "Tuesday"),
182
+ array("type" => "We", "display" => "Wednesday"),
183
+ array("type" => "Th", "display" => "Thursday"),
184
+ array("type" => "Fr", "display" => "Friday"),
185
+ array("type" => "Sa", "display" => "Saturday"),
186
+ array("type" => "Su", "display" => "Sunday")
187
  );
188
 
189
  /**
204
  * Form Layout Render
205
  *
206
  * @since 2.3.3
207
+ * @version 2.4.0
208
  * @param array $option
209
  */
210
  private function page_render ( array $option ) {
260
  $html = '<table class="schema-admin-table">';
261
  $html .= '<caption>Opening Hours Specification ( recommended )</caption>';
262
 
263
+ $i = 0;
264
+
265
  foreach ( $this->week_array as $value ) {
266
  if ( !isset( $option[$value['type']] ) ) {
267
  $option[$value['type']] = "";
268
  }
269
+
270
  $html .= $this->set_form_checkbox( $value['type'], $value['display'], $option[$value['type']], 'Enabled' );
271
+
272
+ if ( isset( $option['week'][$value['type']] ) ) {
273
+ foreach ( $option['week'][$value['type']] as $type ) {
274
+ if ( !empty( $type['open'] ) ) {
275
+ $html .= $this->set_form_time( $value['type'], '', $type['open'], $type['close'], '', $i );
276
+ $i++;
277
+ } else {
278
+ $html .= $this->set_form_time( $value['type'], '', '', '', '', 0 );
279
+ break;
280
+ }
281
+ }
282
+ } else {
283
+ $html .= $this->set_form_time( $value['type'], '', '', '', '', 0 );
284
+ }
285
+
286
+ $i = 0;
287
  }
288
 
289
  $html .= '</table>';
297
  * Return the default options array
298
  *
299
  * @since 2.3.0
300
+ * @version 2.4.0
301
  * @param array $args
302
  * @return array $args
303
  */
320
  $args['opening_active'] = '';
321
 
322
  foreach ( $this->week_array as $value ) {
323
+ $args[$value['type']] = '';
324
+ $args['week'][$value['type']]['open'] = '';
325
+ $args['week'][$value['type']]['close'] = '';
326
  }
327
 
328
  return (array) $args;
407
  * Return the form time
408
  *
409
  * @since 2.3.0
410
+ * @version 2.4.0
411
  * @param string $id
412
  * @param string $display
413
  * @param string $value1
414
  * @param string $value2
415
  * @param string $note
416
+ * @param int $count
417
  * @return string $html
418
  */
419
+ private function set_form_time ( $id, $display, $value1 = "", $value2 = "", $note = "", $count = 0 ) {
420
  $value1 = esc_attr( $value1 );
421
  $value2 = esc_attr( $value2 );
422
 
423
+ $format = '<tr class="opening-hours %s"><th><label for=%s>%s :</label></th><td>';
424
+ $format .= 'Open Time : <input type="time" name="option[week][%s][%d][open]" id="%s-open" value="%s">';
425
+ $format .= ' Close Time : <input type="time" name="option[week][%s][%d][close]" id="%s-close" value="%s">';
426
+ $format .= '<small>%s</small><a class="dashicons dashicons-plus markup-time plus"></a>';
427
+ if( $count !== 0 ) {
428
+ $format .= '<a class="dashicons dashicons-minus markup-time minus"></a>';
429
+ }
430
+ $format .= '</td></tr>';
431
 
432
+ return (string) sprintf( $format, $id, $id, $display, $id, $count, $id, $value1, $id, $count, $id, $value2, $note );
433
  }
434
+ }
includes/wp-structuring-admin-type-person.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Schema.org Type Person
4
+ *
5
+ * @author Kazuya Takami
6
+ * @version 2.4.0
7
+ * @since 2.4.0
8
+ * @see wp-structuring-admin-db.php
9
+ * @link https://schema.org/Person
10
+ * @link https://developers.google.com/structured-data/customize/social-profiles
11
+ */
12
+ class Structuring_Markup_Type_Person {
13
+
14
+ /**
15
+ * Variable definition.
16
+ *
17
+ * @since 2.4.0
18
+ * @version 2.4.0
19
+ */
20
+ /** Social Profile */
21
+ private $social_array = array(
22
+ array("type" => "facebook", "display" => "Facebook"),
23
+ array("type" => "twitter", "display" => "Twitter"),
24
+ array("type" => "google", "display" => "Google+"),
25
+ array("type" => "instagram", "display" => "Instagram"),
26
+ array("type" => "youtube", "display" => "Youtube"),
27
+ array("type" => "linkedin", "display" => "LinkedIn"),
28
+ array("type" => "myspace", "display" => "Myspace"),
29
+ array("type" => "pinterest", "display" => "Pinterest"),
30
+ array("type" => "soundcloud", "display" => "SoundCloud"),
31
+ array("type" => "tumblr", "display" => "Tumblr")
32
+ );
33
+
34
+ /**
35
+ * Constructor Define.
36
+ *
37
+ * @since 2.4.0
38
+ * @version 2.4.0
39
+ * @param array $option
40
+ */
41
+ public function __construct ( array $option ) {
42
+ /** Default Value Set */
43
+ if ( empty( $option ) ) {
44
+ $option = $this->get_default_options( $option );
45
+ }
46
+ $this->page_render( $option );
47
+ }
48
+
49
+ /**
50
+ * Form Layout Render
51
+ *
52
+ * @since 2.4.0
53
+ * @version 2.4.0
54
+ * @param array $option
55
+ */
56
+ private function page_render ( array $option ) {
57
+ /** Basic Settings */
58
+ $html = '<table class="schema-admin-table">';
59
+ $html .= '<caption>Basic Settings</caption>';
60
+ $html .= '<tr><th><label for="name">Name :</label></th><td>';
61
+ $html .= '<input type="text" name="option[' . "name" . ']" id="name" class="regular-text" required value="' . esc_attr( $option['name'] ) . '">';
62
+ $html .= '<small>Default : bloginfo("name")</small>';
63
+ $html .= '</td></tr>';
64
+ $html .= '<tr><th><label for="url">url :</label></th><td>';
65
+ $html .= '<input type="text" name="option[' . "url" . ']" id="url" class="regular-text" required value="' . esc_attr( $option['url'] ) . '">';
66
+ $html .= '<small>Default : bloginfo("url")</small>';
67
+ $html .= '</td></tr>';
68
+ $html .= '</table>';
69
+ echo $html;
70
+
71
+ /** Social Profiles */
72
+ $html = '<table class="schema-admin-table">';
73
+ $html .= '<caption>Social Profiles</caption>';
74
+ foreach ( $this->social_array as $value ) {
75
+ $html .= '<tr><th><label for="' . $value['type'] . '">' . $value['display'] . ' :</label></th><td>';
76
+ $html .= '<input type="text" name="option[' . "social" . '][' . $value['type'] . ']" id="' . $value['type'] . '" class="regular-text" value="' . esc_attr( $option['social'][$value['type']] ) . '">';
77
+ $html .= '</td></tr>';
78
+ }
79
+ $html .= '</table>';
80
+ echo $html;
81
+
82
+ echo '<p>Setting Knowledge : <a href="https://developers.google.com/structured-data/customize/social-profiles" target="_blank">https://developers.google.com/structured-data/customize/social-profiles</a></p>';
83
+ submit_button();
84
+ }
85
+
86
+ /**
87
+ * Return the default options array
88
+ *
89
+ * @since 2.4.0
90
+ * @version 2.4.0
91
+ * @param array $args
92
+ * @return array $args
93
+ */
94
+ private function get_default_options ( array $args ) {
95
+ $args['name'] = get_bloginfo('name');
96
+ $args['url'] = get_bloginfo('url');
97
+
98
+ foreach ( $this->social_array as $value ) {
99
+ $args['social'][$value['type']] = '';
100
+ }
101
+
102
+ return (array) $args;
103
+ }
104
+ }
includes/wp-structuring-display.php CHANGED
@@ -48,7 +48,7 @@ class Structuring_Markup_Display {
48
  * Setting JSON-LD Template
49
  *
50
  * @since 1.0.0
51
- * @version 2.3.0
52
  * @param Structuring_Markup_Admin_Db $db
53
  * @param string $output
54
  */
@@ -92,6 +92,11 @@ class Structuring_Markup_Display {
92
  $this->set_schema_organization( unserialize( $row->options ) );
93
  }
94
  break;
 
 
 
 
 
95
  case 'website':
96
  if ( isset( $row->options ) && $row->options ) {
97
  $this->set_schema_website( unserialize( $row->options ) );
@@ -365,20 +370,20 @@ class Structuring_Markup_Display {
365
  * Setting schema.org LocalBusiness
366
  *
367
  * @since 2.3.0
368
- * @version 2.3.0
369
  * @param array $options
370
  */
371
  private function set_schema_local_business ( array $options ) {
372
 
373
  /** weekType defined. */
374
  $week_array = array(
375
- array("type" => "mon", "display" => "Monday"),
376
- array("type" => "tue", "display" => "Tuesday"),
377
- array("type" => "wed", "display" => "Wednesday"),
378
- array("type" => "thu", "display" => "Thursday"),
379
- array("type" => "fri", "display" => "Friday"),
380
- array("type" => "sat", "display" => "Saturday"),
381
- array("type" => "sun", "display" => "Sunday")
382
  );
383
 
384
  $args = array(
@@ -419,16 +424,27 @@ class Structuring_Markup_Display {
419
  $args = array_merge( $args, $geo_array );
420
  }
421
 
 
 
422
  foreach ( $week_array as $value ) {
423
  if ( isset( $options[$value['type']] ) && $options[$value['type']] === 'on' ) {
424
- $opening_array["openingHoursSpecification"][] = array(
425
- "@type" => "OpeningHoursSpecification",
426
- "dayOfWeek" => $value['display'],
427
- "opens" => isset( $options['name'] ) ? esc_html( $options[$value['type'] . '-open'] ) : "",
428
- "closes" => isset( $options['name'] ) ? esc_html( $options[$value['type'] . '-close'] ) : ""
429
- );
430
- $args = array_merge( $args, $opening_array );
 
 
 
 
 
 
431
  }
 
 
 
432
  }
433
 
434
  $this->set_schema_json( $args );
@@ -530,6 +546,36 @@ class Structuring_Markup_Display {
530
  $this->set_schema_json( $args );
531
  }
532
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
533
  /**
534
  * Setting schema.org WebSite
535
  *
48
  * Setting JSON-LD Template
49
  *
50
  * @since 1.0.0
51
+ * @version 2.4.0
52
  * @param Structuring_Markup_Admin_Db $db
53
  * @param string $output
54
  */
92
  $this->set_schema_organization( unserialize( $row->options ) );
93
  }
94
  break;
95
+ case 'person':
96
+ if ( isset( $row->options ) && $row->options ) {
97
+ $this->set_schema_person( unserialize( $row->options ) );
98
+ }
99
+ break;
100
  case 'website':
101
  if ( isset( $row->options ) && $row->options ) {
102
  $this->set_schema_website( unserialize( $row->options ) );
370
  * Setting schema.org LocalBusiness
371
  *
372
  * @since 2.3.0
373
+ * @version 2.4.0
374
  * @param array $options
375
  */
376
  private function set_schema_local_business ( array $options ) {
377
 
378
  /** weekType defined. */
379
  $week_array = array(
380
+ array("type" => "Mo", "display" => "Monday"),
381
+ array("type" => "Tu", "display" => "Tuesday"),
382
+ array("type" => "We", "display" => "Wednesday"),
383
+ array("type" => "Th", "display" => "Thursday"),
384
+ array("type" => "Fr", "display" => "Friday"),
385
+ array("type" => "Sa", "display" => "Saturday"),
386
+ array("type" => "Su", "display" => "Sunday")
387
  );
388
 
389
  $args = array(
424
  $args = array_merge( $args, $geo_array );
425
  }
426
 
427
+ /* openingHours */
428
+ $active_days = array();
429
  foreach ( $week_array as $value ) {
430
  if ( isset( $options[$value['type']] ) && $options[$value['type']] === 'on' ) {
431
+ $active_days[$value['type']] = $options['week'][$value['type']];
432
+ }
433
+ }
434
+
435
+ if( !empty( $active_days ) ) {
436
+
437
+ $obj = new Structuring_Markup_Opening_Hours( $active_days );
438
+ $opening_hours = $obj->display();
439
+
440
+ $opening_array["openingHours"] = array();
441
+
442
+ foreach( $opening_hours as $value ) {
443
+ $opening_array["openingHours"][] = $value;
444
  }
445
+
446
+ $args = array_merge( $args, $opening_array );
447
+
448
  }
449
 
450
  $this->set_schema_json( $args );
546
  $this->set_schema_json( $args );
547
  }
548
 
549
+ /**
550
+ * Setting schema.org Person
551
+ *
552
+ * @since 2.4.0
553
+ * @version 2.4.0
554
+ * @param array $options
555
+ */
556
+ private function set_schema_person ( array $options ) {
557
+ /** Logos */
558
+ $args = array(
559
+ "@context" => "http://schema.org",
560
+ "@type" => "Person",
561
+ "name" => isset( $options['name'] ) ? esc_html( $options['name'] ) : "",
562
+ "url" => isset( $options['url'] ) ? esc_url( $options['url'] ) : ""
563
+ );
564
+
565
+ /** Social Profiles */
566
+ if ( isset( $options['social'] ) ) {
567
+ $socials["sameAs"] = array();
568
+
569
+ foreach ( $options['social'] as $value ) {
570
+ if ( !empty( $value ) ) {
571
+ $socials["sameAs"][] = esc_html( $value );
572
+ }
573
+ }
574
+ $args = array_merge( $args, $socials );
575
+ }
576
+ $this->set_schema_json( $args );
577
+ }
578
+
579
  /**
580
  * Setting schema.org WebSite
581
  *
includes/wp-structuring-opening-hours.php ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Schema.org openingHours
4
+ *
5
+ * @author Justin Frydman
6
+ * @version 2.4.0
7
+ * @since 2.4.0
8
+ * @see wp-structuring-display.php
9
+ * @link https://schema.org/openingHours
10
+ * @link https://schema.org/LocalBusiness
11
+ */
12
+ class Structuring_Markup_Opening_Hours {
13
+
14
+ /**
15
+ * Multidimensional array of days and opening hours
16
+ *
17
+ * @since 2.4.0
18
+ * @var array
19
+ */
20
+ protected $opening_hours;
21
+
22
+ /**
23
+ * List of days
24
+ *
25
+ * @since 2.4.0
26
+ * @var array
27
+ */
28
+ protected $days;
29
+
30
+ /**
31
+ * Grouped, unique hour periods
32
+ *
33
+ * @since 2.4.0
34
+ * @var array
35
+ */
36
+ protected $periods;
37
+
38
+ /**
39
+ * Days grouped with open-close hours
40
+ *
41
+ * @since 2.4.0
42
+ * @var array
43
+ */
44
+ protected $grouped_days;
45
+
46
+ /**
47
+ * Open/close hours grouped by Mo-Su
48
+ *
49
+ * @since 2.4.0
50
+ * @var array
51
+ */
52
+ protected $weekly_hours;
53
+
54
+ /**
55
+ * Constructor
56
+ *
57
+ * @since 2.4.0
58
+ * @param array $opening_hours
59
+ */
60
+ public function __construct ( array $opening_hours ) {
61
+ /** Default Value Set */
62
+ if ( !empty( $opening_hours ) ) {
63
+ $this->opening_hours = $opening_hours;
64
+ $this->init();
65
+ }
66
+ }
67
+
68
+ /**
69
+ * Initialize the class
70
+ *
71
+ * @since 2.4.0
72
+ */
73
+ public function init () {
74
+ $this->days = array_keys( $this->opening_hours );
75
+ $this->periods = $this->group_periods();
76
+ $this->grouped_days = $this->group_periods_with_days();
77
+ $this->weekly_hours = $this->group_weekly_hours();
78
+ }
79
+
80
+ /**
81
+ * Groups unique open and closed hour periods
82
+ *
83
+ * @since 2.4.0
84
+ * @return array
85
+ */
86
+ public function group_periods () {
87
+ $periods = array();
88
+ foreach( $this->opening_hours as $day ) {
89
+ foreach( $day as $group ) {
90
+ if( !in_array( $group, $periods ) ) {
91
+ if( !empty( $group['open'] ) && !empty( $group['close'] ) ) {
92
+ $periods[] = $group;
93
+ }
94
+ }
95
+ }
96
+ }
97
+
98
+ return (array) $periods;
99
+ }
100
+
101
+ /**
102
+ * Groups day ranges with their opening hours
103
+ *
104
+ * @since 2.4.0
105
+ * @return array
106
+ */
107
+ public function group_periods_with_days () {
108
+ $periods = $this->periods;
109
+
110
+ foreach( $periods as $key => $group ) {
111
+ $days = array();
112
+
113
+ foreach( $this->opening_hours as $day => $grouped_days ) {
114
+ if( in_array( $group, $grouped_days) ) {
115
+ $days[] = $day;
116
+ }
117
+ }
118
+
119
+ $periods[$key]['days'] = $days;
120
+ }
121
+
122
+ return (array) $periods;
123
+ }
124
+
125
+ /**
126
+ * Group weekly group ranges with their opening hours
127
+ *
128
+ * @since 2.4.0
129
+ * @return array
130
+ */
131
+ public function group_weekly_hours () {
132
+ $grouped_days = $this->grouped_days;
133
+ $days = $this->days;
134
+ $object = $this;
135
+
136
+ return (array) array_reduce( $grouped_days, function($result, $group) use ( $days, $object ) {
137
+ return array_merge( $result, $object->group_periods_to_day_range( $group ) );
138
+ }, array() );
139
+ }
140
+
141
+ /**
142
+ * Groups days of the week with their opening hours
143
+ *
144
+ * @since 2.4.0
145
+ * @param array $group
146
+ * @return array
147
+ */
148
+ public function group_periods_to_day_range ( array $group ) {
149
+ $starting_day = null;
150
+ $ending_day = null;
151
+
152
+ $consecutive_days = array();
153
+
154
+ foreach( $this->days as $i => $day ) {
155
+ $has_day = in_array( $day, $group['days'] );
156
+
157
+ if( $has_day ) {
158
+ $starting_day = $starting_day ? $starting_day : $day;
159
+ $ending_day = $day;
160
+ }
161
+
162
+ if( $starting_day && (!$has_day || $i == count($this->days) - 1) ) {
163
+ $consecutive_days[] = array(
164
+ 'start' => $starting_day,
165
+ 'end' => $ending_day,
166
+ 'open' => $group['open'],
167
+ 'close' => $group['close']
168
+ );
169
+
170
+ $starting_day = null;
171
+ }
172
+ }
173
+
174
+ return (array) $this->sort_by_day_of_the_week( $consecutive_days );
175
+ }
176
+
177
+ /**
178
+ * Sorts our days in the proper weekly hour
179
+ *
180
+ * @since 2.4.0
181
+ * @param array $consecutive_days
182
+ * @return array
183
+ */
184
+ public function sort_by_day_of_the_week ( array $consecutive_days ) {
185
+ $days = $this->days;
186
+
187
+ arsort($consecutive_days);
188
+
189
+ $sort_by_day_func = function( $a, $b ) use ( $days ) {
190
+ $aKey = array_search( $a['start'], $days );
191
+ $bKey = array_search( $b['start'], $days );
192
+ return $aKey === $bKey ? 1 : $aKey < $bKey ? -1 : 1;
193
+ };
194
+
195
+ usort($consecutive_days, $sort_by_day_func);
196
+
197
+ return (array) $consecutive_days;
198
+ }
199
+
200
+ /**
201
+ * Displays formatted opening hours
202
+ *
203
+ * @since 2.4.0
204
+ * @return array
205
+ */
206
+ public function display () {
207
+ $opening_hours = array();
208
+
209
+ foreach( $this->weekly_hours as $key => $group ) {
210
+ if( $group['start'] != $group['end'] ) {
211
+ $hours = $group['start'].'-'.$group['end'];
212
+ } else {
213
+ $hours = $group['start'];
214
+ }
215
+
216
+ $hours .= ' ' . $group['open'] . '-' . $group['close'];
217
+
218
+ $opening_hours[] = $hours;
219
+ }
220
+
221
+ return (array) $opening_hours;
222
+ }
223
+
224
+ }
js/main.js ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Markup (JSON-LD) structured in schema.org */
2
+ jQuery(document).ready(function ($) {
3
+ 'use strict';
4
+
5
+ // add row
6
+ $('.schema-admin-table').on('click', '.markup-time.plus', function () {
7
+ var newRow = $(this).closest('tr.opening-hours').clone();
8
+ $(this).closest('tr.opening-hours').after(newRow);
9
+ newRow.find('input').val('');
10
+ newRow.find('.minus').show();
11
+ newRow.find('input').each(function () {
12
+ var
13
+ name = $(this).prop('name'),
14
+ currentIndex = parseInt(name.split('][')[2], 10),
15
+ nextIndex = currentIndex + 1;
16
+
17
+ if (currentIndex === 0) {
18
+ $(this).parent().find('.plus:last-child').after('<a class="dashicons dashicons-minus markup-time minus"></a>');
19
+ }
20
+ $(this).prop('name', name.replace(currentIndex, nextIndex));
21
+ });
22
+ });
23
+
24
+ // remove row
25
+ $('.schema-admin-table').on('click', '.markup-time.minus', function () {
26
+ $(this).closest('tr.opening-hours').fadeOut('normal', function () {
27
+ $(this).remove();
28
+ });
29
+ });
30
+ });
js/main.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function(n){"use strict";n(".schema-admin-table").on("click",".markup-time.plus",function(){var i=n(this).closest("tr.opening-hours").clone();n(this).closest("tr.opening-hours").after(i),i.find("input").val(""),i.find(".minus").show(),i.find("input").each(function(){var i=n(this).prop("name"),s=parseInt(i.split("][")[2],10),t=s+1;0===s&&n(this).parent().find(".plus:last-child").after('<a class="dashicons dashicons-minus markup-time minus"></a>'),n(this).prop("name",i.replace(s,t))})}),n(".schema-admin-table").on("click",".markup-time.minus",function(){n(this).closest("tr.opening-hours").fadeOut("normal",function(){n(this).remove()})})});
readme.txt CHANGED
@@ -3,13 +3,13 @@ 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.1
6
- Stable tag: 2.3.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
 
10
  == Description ==
11
 
12
- It is plug in to implement structured markup (JSON-LD syntax) by schema.org definition on an post page, fixed page and etc.
13
  Base knowledge is "https://schema.org/" and "https://developers.google.com/structured-data/"
14
 
15
  = Schema.org Type =
@@ -21,6 +21,7 @@ Base knowledge is "https://schema.org/" and "https://developers.google.com/struc
21
  * LocalBusiness : http://schema.org/LocalBusiness
22
  * NewsArticle: http://schema.org/NewsArticle
23
  * Organization: https://schema.org/Organization
 
24
  * Website: https://schema.org/WebSite
25
 
26
  = Breadcrumb =
@@ -51,7 +52,13 @@ if ( shortcode_exists( 'wp-structuring-markup-breadcrumb' ) ) {
51
 
52
  == Changelog ==
53
 
54
- = 2.3.3 (2016-01-19)
 
 
 
 
 
 
55
 
56
  * Fixed : Improved wording on admin pages
57
  * Fixed : Added alternate methods to get image dimensions for systems running legacy SSL
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.1
6
+ Stable tag: 2.4.0
7
 
8
+ Allows you to include schema.org JSON-LD syntax markup on your website
9
 
10
  == Description ==
11
 
12
+ Allows you to include schema.org JSON-LD syntax markup on your website
13
  Base knowledge is "https://schema.org/" and "https://developers.google.com/structured-data/"
14
 
15
  = Schema.org Type =
21
  * LocalBusiness : http://schema.org/LocalBusiness
22
  * NewsArticle: http://schema.org/NewsArticle
23
  * Organization: https://schema.org/Organization
24
+ * Person: https://schema.org/Person
25
  * Website: https://schema.org/WebSite
26
 
27
  = Breadcrumb =
52
 
53
  == Changelog ==
54
 
55
+ = 2.4.0 (2016-02-06) =
56
+
57
+ * Added : Schema.org type "Person".
58
+ * Updated : Schema.org type "LocalBusiness" OpenHours : shift time setting.
59
+ * Check : WordPress version 4.4.2 operation check.
60
+
61
+ = 2.3.3 (2016-01-19) =
62
 
63
  * Fixed : Improved wording on admin pages
64
  * Fixed : Added alternate methods to get image dimensions for systems running legacy SSL
wp-structuring-markup.php CHANGED
@@ -2,8 +2,8 @@
2
  /*
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.3.3
7
  Author: Kazuya Takami
8
  Author URI: http://programp.com/
9
  License: GPLv2 or later
@@ -19,7 +19,7 @@ new Structuring_Markup();
19
  *
20
  * @author Kazuya Takami
21
  * @since 1.0.0
22
- * @version 2.3.3
23
  */
24
  class Structuring_Markup {
25
 
@@ -27,16 +27,16 @@ class Structuring_Markup {
27
  * Variable definition.
28
  *
29
  * @since 1.3.0
30
- * @version 2.3.3
31
  */
32
  private $text_domain = 'wp-structuring-markup';
33
- private $version = '2.3.3';
34
 
35
  /**
36
  * Constructor Define.
37
  *
38
  * @since 1.0.0
39
- * @version 2.1.0
40
  */
41
  public function __construct() {
42
  register_activation_hook( __FILE__, array( $this, 'create_table' ) );
@@ -49,6 +49,7 @@ class Structuring_Markup {
49
  if ( is_admin() ) {
50
  add_action( 'admin_init', array( $this, 'admin_init' ) );
51
  add_action( 'admin_menu', array( $this, 'admin_menu' ) );
 
52
  } else {
53
  add_action( 'wp_head', array( $this, 'wp_head' ) );
54
  }
@@ -123,6 +124,17 @@ class Structuring_Markup {
123
  wp_register_style( 'wp-structuring-markup-admin-style', plugins_url( 'css/style.css', __FILE__ ) );
124
  }
125
 
 
 
 
 
 
 
 
 
 
 
 
126
  /**
127
  * Add Menu to the Admin Screen.
128
  *
@@ -208,6 +220,7 @@ class Structuring_Markup {
208
  * @version 1.3.0
209
  */
210
  public function wp_head () {
 
211
  require_once( plugin_dir_path( __FILE__ ) . 'includes/wp-structuring-display.php' );
212
  new Structuring_Markup_Display();
213
  }
2
  /*
3
  Plugin Name: Markup (JSON-LD) structured in schema.org
4
  Plugin URI: https://wordpress.org/plugins/wp-structuring-markup/
5
+ Description: Allows you to include schema.org JSON-LD syntax markup on your website
6
+ Version: 2.4.0
7
  Author: Kazuya Takami
8
  Author URI: http://programp.com/
9
  License: GPLv2 or later
19
  *
20
  * @author Kazuya Takami
21
  * @since 1.0.0
22
+ * @version 2.4.0
23
  */
24
  class Structuring_Markup {
25
 
27
  * Variable definition.
28
  *
29
  * @since 1.3.0
30
+ * @version 2.4.0
31
  */
32
  private $text_domain = 'wp-structuring-markup';
33
+ private $version = '2.4.0';
34
 
35
  /**
36
  * Constructor Define.
37
  *
38
  * @since 1.0.0
39
+ * @version 2.4.0
40
  */
41
  public function __construct() {
42
  register_activation_hook( __FILE__, array( $this, 'create_table' ) );
49
  if ( is_admin() ) {
50
  add_action( 'admin_init', array( $this, 'admin_init' ) );
51
  add_action( 'admin_menu', array( $this, 'admin_menu' ) );
52
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts') );
53
  } else {
54
  add_action( 'wp_head', array( $this, 'wp_head' ) );
55
  }
124
  wp_register_style( 'wp-structuring-markup-admin-style', plugins_url( 'css/style.css', __FILE__ ) );
125
  }
126
 
127
+ /**
128
+ * admin_scripts
129
+ *
130
+ * @since 2.4.0
131
+ * @version 2.4.0
132
+ * @author Justin Frydman
133
+ */
134
+ public function admin_scripts () {
135
+ wp_enqueue_script( 'wp-structuring-markup-admin-main-js', plugins_url( 'js/main.min.js', __FILE__ ), array('jquery'), '1.0' );
136
+ }
137
+
138
  /**
139
  * Add Menu to the Admin Screen.
140
  *
220
  * @version 1.3.0
221
  */
222
  public function wp_head () {
223
+ require_once( plugin_dir_path( __FILE__ ) . 'includes/wp-structuring-opening-hours.php' );
224
  require_once( plugin_dir_path( __FILE__ ) . 'includes/wp-structuring-display.php' );
225
  new Structuring_Markup_Display();
226
  }