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

Version Description

(2015/11/23) =

  • Added : Schema.org type "BreadcrumbList" Breadcrumbs schema.org definition Add breadcrumbs short code output that works
  • Updated : Schema.org definition immobilization.
Download this release

Release Info

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

Code changes from version 1.3.2 to 2.0.0

css/style.css CHANGED
@@ -1,24 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  .schema-admin-table {
2
- margin: 15px 0 15px 0;
3
  }
4
  .schema-admin-table caption {
5
- border-left: solid 4px #00a0d2;
6
- margin: 0 0 10px 0;
7
- padding: 3px 0 3px 7px;
8
- text-align: left;
9
  }
10
  .schema-admin-table th {
11
- padding: 3px 5px 0 0;
12
- text-align: right;
13
- vertical-align: top;
14
- width: 120px;
15
  }
16
  .schema-admin-table td label{
17
- margin: 0 10px 0 0;
18
  }
19
  .schema-admin-table small {
20
- margin: 0 0 0 10px;
21
  }
22
  .schema-admin-table input[type="checkbox"] {
23
- margin: 0 5px 0 0;
24
  }
1
+ /** List Setting */
2
+ .schema-admin-table-list th:nth-child(1) {
3
+ width: 10em;
4
+ }
5
+ .schema-admin-table-list td {
6
+ vertical-align: middle;
7
+ }
8
+ .schema-admin-table-list td:nth-child(1) span {
9
+ display: inline-block;
10
+ padding: 0 1em 0 1em;
11
+ text-align: center;
12
+ width: 8em;
13
+ }
14
+ .schema-admin-table-list td:nth-child(1) span.active {
15
+ background: #00a0d2;
16
+ color: #ffffff;
17
+ }
18
+ .schema-admin-table-list td:nth-child(1) span.stop {
19
+ background: #CCCCCC;
20
+ }
21
+
22
+ /** Posts page */
23
+ .schema-admin-h1-span {
24
+ display: inline-block;
25
+ font-size: 80%;
26
+ margin: 0 0 0 10px;
27
+ }
28
  .schema-admin-table {
29
+ margin: 15px 0 15px 0;
30
  }
31
  .schema-admin-table caption {
32
+ border-left: solid 4px #00a0d2;
33
+ margin: 0 0 10px 0;
34
+ padding: 3px 0 3px 7px;
35
+ text-align: left;
36
  }
37
  .schema-admin-table th {
38
+ padding: 3px 5px 0 0;
39
+ text-align: right;
40
+ vertical-align: top;
41
+ width: 120px;
42
  }
43
  .schema-admin-table td label{
44
+ margin: 0 10px 0 0;
45
  }
46
  .schema-admin-table small {
47
+ margin: 0 0 0 10px;
48
  }
49
  .schema-admin-table input[type="checkbox"] {
50
+ margin: 0 5px 0 0;
51
  }
includes/wp-structuring-admin-db.php CHANGED
@@ -4,11 +4,28 @@
4
  *
5
  * @author Kazuya Takami
6
  * @since 1.0.0
7
- * @version 1.0.0
8
  */
9
  class Structuring_Markup_Admin_Db {
 
 
 
 
 
 
 
10
  private $table_name;
11
 
 
 
 
 
 
 
 
 
 
 
12
  /**
13
  * Constructor Define.
14
  *
@@ -23,31 +40,96 @@ class Structuring_Markup_Admin_Db {
23
  /**
24
  * Create Table.
25
  *
26
- * @since 1.0.0
 
27
  */
28
  public function create_table() {
 
 
29
  global $wpdb;
30
 
31
- $prepared = $wpdb->prepare( "SHOW TABLES LIKE %s", $this->table_name );
32
- $is_db_exists = $wpdb->get_var( $prepared );
 
33
 
34
  if ( is_null( $is_db_exists ) ) {
35
- $charset_collate = $wpdb->get_charset_collate();
36
-
37
- $query = " CREATE TABLE " . $this->table_name;
38
- $query .= " (id mediumint(9) NOT NULL AUTO_INCREMENT PRIMARY KEY";
39
- $query .= ",type tinytext NOT NULL";
40
- $query .= ",output text NOT NULL";
41
- $query .= ",options text NOT NULL";
42
- $query .= ",register_date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL";
43
- $query .= ",update_date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL";
44
- $query .= ",UNIQUE KEY id (id)) " . $charset_collate;
45
-
46
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
47
- dbDelta( $query );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  }
49
  }
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  /**
52
  * Get Data.
53
  *
@@ -66,10 +148,11 @@ class Structuring_Markup_Admin_Db {
66
  $results = array();
67
 
68
  if ( $args ) {
69
- $results['id'] = $args->id;
70
- $results['type'] = $args->type;
71
- $results['output'] = unserialize( $args->output );
72
- $results['option'] = unserialize( $args->options );
 
73
  }
74
  return (array) $results;
75
  }
@@ -83,7 +166,7 @@ class Structuring_Markup_Admin_Db {
83
  public function get_list_options() {
84
  global $wpdb;
85
 
86
- $query = "SELECT * FROM " . $this->table_name . " ORDER BY update_date DESC";
87
 
88
  return (array) $wpdb->get_results( $query );
89
  }
@@ -107,65 +190,69 @@ class Structuring_Markup_Admin_Db {
107
  }
108
 
109
  /**
110
- * Insert Data.
111
  *
112
- * @since 1.0.0
113
- * @param array $post($_POST)
114
- * @return integer $id
 
115
  */
116
- public function insert_options( array $post ) {
117
  global $wpdb;
118
 
119
- $data = array(
120
- 'type' => $post['type'],
121
- 'output' => serialize( $post['output'] ),
122
- 'options' => isset( $post['option'] ) ? serialize( $post['option'] ) : "",
123
- 'register_date' => date( "Y-m-d H:i:s" ),
124
- 'update_date' => date( "Y-m-d H:i:s" )
125
- );
126
- $prepared = array( '%s', '%s', '%s' );
127
 
128
- $wpdb->insert( $this->table_name, $data, $prepared );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
 
130
- return (int) $wpdb->insert_id;
 
131
  }
132
 
133
  /**
134
  * Update Data.
135
  *
136
  * @since 1.0.0
137
- * @version 1.3.2
138
  * @param array $post($_POST)
 
139
  */
140
  public function update_options( array $post ) {
141
  global $wpdb;
142
 
143
  $data = array(
144
  'type' => $post['type'],
 
145
  'output' => serialize( $post['output'] ),
146
  'options' => isset( $post['option'] ) ? serialize( $post['option'] ) : "",
147
  'update_date' => date( "Y-m-d H:i:s" )
148
  );
149
  $key = array( 'id' => esc_html( $post['id'] ) );
150
- $prepared = array( '%s', '%s', '%s' );
151
  $key_prepared = array( '%d' );
152
 
153
  $wpdb->update( $this->table_name, $data, $key, $prepared, $key_prepared );
154
- }
155
-
156
- /**
157
- * Delete Data.
158
- *
159
- * @since 1.0.0
160
- * @version 1.3.2
161
- * @param integer $id
162
- */
163
- public function delete_options( $id ) {
164
- global $wpdb;
165
-
166
- $key = array( 'id' => esc_html( $id ) );
167
- $key_prepared = array( '%d' );
168
-
169
- $wpdb->delete( $this->table_name, $key, $key_prepared );
170
  }
171
  }
4
  *
5
  * @author Kazuya Takami
6
  * @since 1.0.0
7
+ * @version 2.0.0
8
  */
9
  class Structuring_Markup_Admin_Db {
10
+
11
+ /**
12
+ * Variable definition.
13
+ *
14
+ * @since 1.0.0
15
+ * @version 2.0.0
16
+ */
17
  private $table_name;
18
 
19
+ /** Schema.org Type defined. */
20
+ public $type_array = array(
21
+ "article" => "Article",
22
+ "blog_posting" => "Blog Posting",
23
+ "breadcrumb" => "Breadcrumb",
24
+ "news_article" => "News Article",
25
+ "organization" => "Organization",
26
+ "website" => "Web Site"
27
+ );
28
+
29
  /**
30
  * Constructor Define.
31
  *
40
  /**
41
  * Create Table.
42
  *
43
+ * @since 1.0.0
44
+ * @version 2.0.0
45
  */
46
  public function create_table() {
47
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
48
+
49
  global $wpdb;
50
 
51
+ $prepared = $wpdb->prepare( "SHOW TABLES LIKE %s", $this->table_name );
52
+ $is_db_exists = $wpdb->get_var( $prepared );
53
+ $charset_collate = $wpdb->get_charset_collate();
54
 
55
  if ( is_null( $is_db_exists ) ) {
56
+ $this->create_table_execute( $charset_collate );
57
+
58
+ foreach ( $this->type_array as $key => $value ) {
59
+ $args = array(
60
+ 'type' => $key,
61
+ 'activate' => "",
62
+ 'output' => serialize( array() ),
63
+ 'options' => serialize( array() ),
64
+ 'register_date' => date( "Y-m-d H:i:s" ),
65
+ 'update_date' => date( "Y-m-d H:i:s" )
66
+ );
67
+ $this->insert_options( $args );
68
+ }
69
+ } else {
70
+ /**
71
+ * version 1.x.x -> 2.0.0 migration process.
72
+ *
73
+ * @since 2.0.0
74
+ * */
75
+ $options = get_option( 'wp_structuring_markup' );
76
+ if ( !isset( $options['version'] ) ) {
77
+ $lists = $this->get_list_options();
78
+
79
+ $wpdb->query( "DROP TABLE " . $this->table_name );
80
+ $this->create_table_execute( $charset_collate );
81
+
82
+ foreach ( $this->type_array as $key => $value ) {
83
+ $args = array(
84
+ 'type' => $key,
85
+ 'activate' => "",
86
+ 'output' => serialize( array() ),
87
+ 'options' => serialize( array() ),
88
+ 'register_date' => date( "Y-m-d H:i:s" ),
89
+ 'update_date' => date( "Y-m-d H:i:s" )
90
+ );
91
+ foreach ( $lists as $list ) {
92
+ if ( $list->type === $key ) {
93
+ $args = array(
94
+ 'type' => $key,
95
+ 'activate' => "on",
96
+ 'output' => $list->output,
97
+ 'options' => $list->options,
98
+ 'register_date' => date( "Y-m-d H:i:s" ),
99
+ 'update_date' => date( "Y-m-d H:i:s" )
100
+ );
101
+ }
102
+ }
103
+ $this->insert_options( $args );
104
+ }
105
+ }
106
  }
107
  }
108
 
109
+ /**
110
+ * Create table execute
111
+ *
112
+ * @since 2.0.0
113
+ * @version 2.0.0
114
+ * @param string $charset_collate
115
+ */
116
+ private function create_table_execute( $charset_collate ) {
117
+ $query = " CREATE TABLE " . $this->table_name;
118
+ $query .= " (id MEDIUMINT(9) NOT NULL AUTO_INCREMENT PRIMARY KEY";
119
+ $query .= ",type TINYTEXT NOT NULL";
120
+ $query .= ",activate TINYTEXT NOT NULL";
121
+ $query .= ",output TEXT NOT NULL";
122
+ $query .= ",options TEXT NOT NULL";
123
+ $query .= ",register_date DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL";
124
+ $query .= ",update_date DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL";
125
+ $query .= ",UNIQUE KEY id (id)) " . $charset_collate;
126
+
127
+ dbDelta( $query );
128
+
129
+ $options = array( 'version' => '2.0.0' );
130
+ add_option( 'wp_structuring_markup', $options, false, 'yes' );
131
+ }
132
+
133
  /**
134
  * Get Data.
135
  *
148
  $results = array();
149
 
150
  if ( $args ) {
151
+ $results['id'] = $args->id;
152
+ $results['activate'] = $args->activate;
153
+ $results['type'] = $args->type;
154
+ $results['output'] = unserialize( $args->output );
155
+ $results['option'] = unserialize( $args->options );
156
  }
157
  return (array) $results;
158
  }
166
  public function get_list_options() {
167
  global $wpdb;
168
 
169
+ $query = "SELECT * FROM " . $this->table_name . " ORDER BY type ASC";
170
 
171
  return (array) $wpdb->get_results( $query );
172
  }
190
  }
191
 
192
  /**
193
+ * Get Type Data.
194
  *
195
+ * @since 2.0.0
196
+ * @version 2.0.0
197
+ * @param string $type
198
+ * @return array $results
199
  */
200
+ public function get_type_options( $type ) {
201
  global $wpdb;
202
 
203
+ $query = "SELECT * FROM " . $this->table_name . " WHERE type = %s";
204
+ $data = array( esc_html( $type ) );
205
+ $prepared = $wpdb->prepare( $query, $data );
206
+ $args = $wpdb->get_row( $prepared );
207
+ $results = array();
 
 
 
208
 
209
+ if ( $args ) {
210
+ $results['id'] = $args->id;
211
+ $results['activate'] = $args->activate;
212
+ $results['type'] = $args->type;
213
+ $results['output'] = unserialize( $args->output );
214
+ $results['option'] = unserialize( $args->options );
215
+ }
216
+ return (array) $results;
217
+ }
218
+
219
+ /**
220
+ * Insert Data.
221
+ *
222
+ * @since 1.0.0
223
+ * @version 2.0.0
224
+ * @param array $args
225
+ */
226
+ private function insert_options( array $args ) {
227
+ global $wpdb;
228
 
229
+ $prepared = array( '%s', '%s', '%s', '%s', '%s', '%s' );
230
+ $wpdb->insert( $this->table_name, $args, $prepared );
231
  }
232
 
233
  /**
234
  * Update Data.
235
  *
236
  * @since 1.0.0
237
+ * @version 2.0.0
238
  * @param array $post($_POST)
239
+ * @return integer $post['id']
240
  */
241
  public function update_options( array $post ) {
242
  global $wpdb;
243
 
244
  $data = array(
245
  'type' => $post['type'],
246
+ 'activate' => isset( $post['activate'] ) ? $post['activate'] : "",
247
  'output' => serialize( $post['output'] ),
248
  'options' => isset( $post['option'] ) ? serialize( $post['option'] ) : "",
249
  'update_date' => date( "Y-m-d H:i:s" )
250
  );
251
  $key = array( 'id' => esc_html( $post['id'] ) );
252
+ $prepared = array( '%s', '%s', '%s', '%s', '%s' );
253
  $key_prepared = array( '%d' );
254
 
255
  $wpdb->update( $this->table_name, $data, $key, $prepared, $key_prepared );
256
+ return (integer) $post['id'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
  }
258
  }
includes/wp-structuring-admin-list.php CHANGED
@@ -3,8 +3,8 @@
3
  * Schema.org Admin List
4
  *
5
  * @author Kazuya Takami
6
- * @version 1.2.0
7
  * @since 1.0.0
 
8
  * @see wp-structuring-admin-db.php
9
  */
10
  class Structuring_Markup_Admin_List {
@@ -12,101 +12,79 @@ class Structuring_Markup_Admin_List {
12
  /**
13
  * Variable definition.
14
  *
15
- * @since 1.3.0
 
16
  */
17
  private $text_domain;
18
 
19
- /** Schema.org Type defined. */
20
- private $type_array = array(
21
- "website" => "Web Site",
22
- "organization" => "Organization",
23
- "article" => "Article",
24
- "blog_posting" => "Blog Posting",
25
- "news_article" => "News Article"
26
- );
27
-
28
  /**
29
  * Constructor Define.
30
  *
31
  * @since 1.0.0
32
- * @version 1.3.0
33
  * @param String $text_domain
34
  */
35
  function __construct( $text_domain ) {
36
  $this->text_domain = $text_domain;
37
-
38
- $db = new Structuring_Markup_Admin_Db();
39
- $mode = "";
40
-
41
- if ( isset( $_GET['mode'] ) && $_GET['mode'] === 'delete' ) {
42
- if ( isset( $_GET['schema_post_id'] ) && is_numeric( $_GET['schema_post_id'] ) ) {
43
- $db->delete_options( $_GET['schema_post_id'] );
44
- $mode = "delete";
45
- }
46
- }
47
-
48
- $this->page_render( $db, $mode );
49
  }
50
 
51
  /**
52
  * LIST Page HTML Render.
53
  *
54
  * @since 1.0.0
55
- * @version 1.3.2
56
- * @param Structuring_Markup_Admin_Db $db
57
- * @param String $mode
58
  */
59
- private function page_render( Structuring_Markup_Admin_Db $db, $mode = "" ) {
60
- $post_url = admin_url() . 'admin.php?page=' . $this->text_domain . '/includes/wp-structuring-admin-post.php';
61
- $self_url = $_SERVER['PHP_SELF'] . '?' . esc_html( $_SERVER['QUERY_STRING'] );
62
 
63
  $html = '';
64
  $html .= '<div class="wrap">';
65
  $html .= '<h1>' . esc_html__( 'Schema.org Settings List', $this->text_domain );
66
- $html .= '<a href="' . $post_url . '" class="page-title-action">' . esc_html__( 'Add New', $this->text_domain ) . '</a>';
67
  $html .= '</h1>';
68
  echo $html;
69
 
70
- if ( $mode === "delete" ) {
71
- $this->information_render();
72
- }
73
-
74
  $html = '<hr>';
75
- $html .= '<table class="wp-list-table widefat fixed striped posts">';
76
  $html .= '<tr>';
 
77
  $html .= '<th scope="row">' . esc_html__( 'Schema Type', $this->text_domain ) . '</th>';
78
  $html .= '<th scope="row">' . esc_html__( 'Output Page', $this->text_domain ) . '</th>';
79
- $html .= '<th scope="row">' . esc_html__( 'Register Date', $this->text_domain ) . '</th>';
80
- $html .= '<th scope="row">' . esc_html__( 'Update Date', $this->text_domain ) . '</th>';
81
  $html .= '<th scope="row">&nbsp;</th>';
82
  $html .= '</tr>';
83
  echo $html;
84
 
85
- $results = $db->get_list_options();
 
 
86
 
87
  if ( $results ) {
88
  foreach ( $results as $row ) {
89
- $html = '';
90
- $html .= '<tr>';
91
- $html .= '<td>';
92
- $html .= '<a href="' . $post_url . '&mode=edit&schema_post_id=' . esc_html( $row->id ) . '">' . $this->type_array[esc_html( $row->type )] . '</a>';
93
- $html .= '</td>';
 
94
  $html .= '<td>' . $this->unserialize_output( $row->output ) . '</td>';
95
- $html .= '<td>' . esc_html( $row->register_date ) . '</td>';
96
- $html .= '<td>' . esc_html( $row->update_date ) . '</td>';
97
  $html .= '<td>';
98
- $html .= '<a href="' . $post_url . '&mode=edit&schema_post_id=' . esc_html( $row->id ) . '">';
99
- $html .= esc_html__( 'Edit', $this->text_domain );
100
- $html .= '</a>&nbsp;&nbsp;&nbsp;&nbsp;';
101
- $html .= '<a href="' . $self_url . '&mode=delete&schema_post_id=' . esc_html( $row->id ) . '">';
102
- $html .= esc_html__( 'Delete', $this->text_domain );
103
- $html .= '</a>';
104
  $html .= '</td>';
 
 
 
 
105
  $html .= '</tr>';
106
  echo $html;
107
  }
108
  } else {
109
- echo '<td colspan="3">' . esc_html__( 'Without registration.', $this->text_domain ) . '</td>';
110
  }
111
 
112
  $html = '</table>';
@@ -117,28 +95,13 @@ class Structuring_Markup_Admin_List {
117
  /**
118
  * LIST Page HTML Render.
119
  *
120
- * @since 1.0.0
121
- * @param object $obj
122
- * @return string $args
 
123
  */
124
  private function unserialize_output( $obj ) {
125
- $args = unserialize( $obj );
126
- return (string) implode( ",", $args );
127
- }
128
-
129
- /**
130
- * Information Message Render
131
- *
132
- * @since 1.0.0
133
- */
134
- private function information_render() {
135
- $html = '<div id="message" class="updated notice notice-success is-dismissible below-h2">';
136
- $html .= '<p>Deletion succeeds.</p>';
137
- $html .= '<button type="button" class="notice-dismiss">';
138
- $html .= '<span class="screen-reader-text">Dismiss this notice.</span>';
139
- $html .= '</button>';
140
- $html .= '</div>';
141
-
142
- echo $html;
143
  }
144
  }
3
  * Schema.org Admin List
4
  *
5
  * @author Kazuya Takami
 
6
  * @since 1.0.0
7
+ * @version 2.0.0
8
  * @see wp-structuring-admin-db.php
9
  */
10
  class Structuring_Markup_Admin_List {
12
  /**
13
  * Variable definition.
14
  *
15
+ * @since 1.3.0
16
+ * @version 2.0.0
17
  */
18
  private $text_domain;
19
 
 
 
 
 
 
 
 
 
 
20
  /**
21
  * Constructor Define.
22
  *
23
  * @since 1.0.0
24
+ * @version 2.0.0
25
  * @param String $text_domain
26
  */
27
  function __construct( $text_domain ) {
28
  $this->text_domain = $text_domain;
29
+ $this->page_render( );
 
 
 
 
 
 
 
 
 
 
 
30
  }
31
 
32
  /**
33
  * LIST Page HTML Render.
34
  *
35
  * @since 1.0.0
36
+ * @version 2.0.0
 
 
37
  */
38
+ private function page_render( ) {
39
+ $post_url = 'admin.php?page=' . $this->text_domain . '-post';
 
40
 
41
  $html = '';
42
  $html .= '<div class="wrap">';
43
  $html .= '<h1>' . esc_html__( 'Schema.org Settings List', $this->text_domain );
 
44
  $html .= '</h1>';
45
  echo $html;
46
 
 
 
 
 
47
  $html = '<hr>';
48
+ $html .= '<table class="wp-list-table widefat fixed striped posts schema-admin-table-list">';
49
  $html .= '<tr>';
50
+ $html .= '<th scope="row">' . esc_html__( 'Status', $this->text_domain ) . '</th>';
51
  $html .= '<th scope="row">' . esc_html__( 'Schema Type', $this->text_domain ) . '</th>';
52
  $html .= '<th scope="row">' . esc_html__( 'Output Page', $this->text_domain ) . '</th>';
53
+ $html .= '<th scope="row">' . esc_html__( 'ShortCode', $this->text_domain ) . '</th>';
 
54
  $html .= '<th scope="row">&nbsp;</th>';
55
  $html .= '</tr>';
56
  echo $html;
57
 
58
+ $db = new Structuring_Markup_Admin_Db();
59
+ $results = $db->get_list_options();
60
+ $type_array = $db->type_array;
61
 
62
  if ( $results ) {
63
  foreach ( $results as $row ) {
64
+ $html = '<tr><td>';
65
+ $html .= ( $row->activate === 'on' ) ? '<span class="active">Activate' : '<span class="stop">Stop';
66
+ $html .= '</span></td>';
67
+ $html .= '<td><a href="';
68
+ $html .= admin_url( $post_url . '&type=' . esc_html( $row->type ) . '&schema_post_id=' . esc_html( $row->id ) ). '">' . $type_array[esc_html( $row->type )];
69
+ $html .= '</a></td>';
70
  $html .= '<td>' . $this->unserialize_output( $row->output ) . '</td>';
 
 
71
  $html .= '<td>';
72
+
73
+ if ( $row->type === 'breadcrumb' ) {
74
+ $html .= '<input type="text" onfocus="this.select();" readonly="readonly" value="[wp-structuring-markup-breadcrumb]" class="large-text code">';
75
+ } else {
76
+ $html .= '-';
77
+ }
78
  $html .= '</td>';
79
+
80
+ $html .= '<td><a href="';
81
+ $html .= $post_url . '&type=' . esc_html( $row->type ) . '&schema_post_id=' . esc_html( $row->id ) . '">' . esc_html__( 'Edit', $this->text_domain );
82
+ $html .= '</a></td>';
83
  $html .= '</tr>';
84
  echo $html;
85
  }
86
  } else {
87
+ echo '<td colspan="5">' . esc_html__( 'Without registration.', $this->text_domain ) . '</td>';
88
  }
89
 
90
  $html = '</table>';
95
  /**
96
  * LIST Page HTML Render.
97
  *
98
+ * @since 1.0.0
99
+ * @version 2.0.0
100
+ * @param string $obj
101
+ * @return string $output
102
  */
103
  private function unserialize_output( $obj ) {
104
+ $output = implode( ",", unserialize( $obj ) );
105
+ return (string) $output;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  }
107
  }
includes/wp-structuring-admin-post.php CHANGED
@@ -3,45 +3,30 @@
3
  * Schema.org Admin Post
4
  *
5
  * @author Kazuya Takami
6
- * @version 1.2.0
7
  * @since 1.0.0
 
8
  */
9
  class Structuring_Markup_Admin_Post {
10
 
11
  /**
12
  * Variable definition.
13
  *
14
- * @since 1.3.0
 
15
  */
16
  private $text_domain;
17
-
18
- /** Schema.org Type defined. */
19
- private $type_array = array(
20
- array("type" => "website", "display" => "Web Site"),
21
- array("type" => "organization", "display" => "Organization"),
22
- array("type" => "article", "display" => "Article"),
23
- array("type" => "blog_posting", "display" => "Blog Posting"),
24
- array("type" => "news_article", "display" => "News Article")
25
- );
26
 
27
  /**
28
  * Constructor Define.
29
  *
30
  * @since 1.0.0
31
- * @version 1.3.0
32
  * @param String $text_domain
33
  */
34
  public function __construct( $text_domain ) {
35
  $this->text_domain = $text_domain;
36
 
37
- /**
38
- * Input Mode
39
- *
40
- * "" : Input Start
41
- * "edit" : Edit Mode
42
- */
43
- $mode = isset( $_GET['mode'] ) ? esc_html( $_GET['mode'] ) : "";
44
-
45
  /**
46
  * Update Status
47
  *
@@ -52,162 +37,135 @@ class Structuring_Markup_Admin_Post {
52
 
53
  /** DB Connect */
54
  $db = new Structuring_Markup_Admin_Db();
 
55
 
56
  /** Set Default Parameter for Array */
57
  $options = array(
58
- "id" => "",
59
- "type" => "website",
60
- "output" => array(),
61
- "option" => array()
 
62
  );
63
 
64
- /** Key Set */
65
- if ( isset( $_GET['schema_post_id'] ) && is_numeric( $_GET['schema_post_id'] ) ) {
66
- $options['id'] = esc_html( $_GET['schema_post_id'] );
67
- }
68
-
69
- /** Type Set */
70
- if ( isset( $_GET['type'] ) ) {
71
- foreach ( $this->type_array as $value ) {
72
- if ( $_GET['type'] === $value['type'] ) {
73
- $options['type'] = esc_html( $_GET['type'] );
74
- break;
75
- }
76
- }
77
- }
78
-
79
  /** DataBase Update & Insert Mode */
80
  if ( isset( $_POST['id'] ) && is_numeric( $_POST['id'] ) ) {
81
  if ( isset( $_POST['output'] ) ) {
82
- $db->update_options( $_POST );
83
- $options['id'] = $_POST['id'];
84
  $status = "ok";
85
  } else {
86
  $status = "output";
87
  }
88
- } else {
89
- if ( isset( $_POST['id'] ) && $_POST['id'] === '' ) {
90
- if ( isset( $_POST['output'] ) ) {
91
- $options['id'] = $db->insert_options( $_POST );
92
- $status = "ok";
93
- $mode = "edit";
94
- } else {
95
- $status = "output";
96
- }
97
- }
98
  }
99
 
100
- /** Mode Judgment */
101
- if ( isset( $options['id'] ) && is_numeric( $options['id'] ) ) {
102
- $options = $db->get_options( $options['id'] );
 
 
 
 
 
103
  }
104
 
105
- $this->page_render( $options, $mode, $status );
 
106
  }
107
 
108
  /**
109
  * Setting Page of the Admin Screen.
110
  *
111
  * @since 1.0.0
112
- * @version 1.3.0
113
  * @param array $options
114
- * @param string $mode
115
  * @param string $status
116
  */
117
- private function page_render( array $options, $mode, $status ) {
118
  $html = '';
119
  $html .= '<div class="wrap">';
120
- $html .= '<h1>' . esc_html__( 'Schema.org Register', $this->text_domain ) . '</h1>';
121
- echo $html;
122
-
123
  switch ( $status ) {
124
  case "ok":
125
- $this->information_render();
126
  break;
127
  case "output":
128
- $this->output_error_render();
129
  break;
130
  default:
131
  break;
132
  }
133
-
134
- $html = '<hr>';
135
- $html .= '<form method="get" action="">';
136
- $html .= '<input type="hidden" name="page" value="wp-structuring-markup/includes/wp-structuring-admin-post.php">';
137
- $html .= '<table class="schema-admin-table">';
138
- $html .= '<tr><th><label for="type">Schema Type :</label></th><td>';
139
- $html .= '<select id="type" name="type" autofocus onchange="this.form.submit();">';
140
- foreach ( $this->type_array as $value ) {
141
- $html .= '<option value="' . $value['type'] . '"';
142
- if ( $value['type'] === $options['type'] ) {
143
- $html .= ' selected';
144
- } else {
145
- if ( $mode === "edit" ) {
146
- $html .= ' disabled';
147
- }
148
- }
149
- $html .= '>' . $value['display'] . '</option>';
150
- }
151
- $html .= '</select>';
152
- $html .= '</td></tr></table>';
153
- $html .= '</form>';
154
  echo $html;
155
 
156
  /** Output Page Select */
157
- $html = '<form method="post" action="">';
158
- $html .= '<input type="hidden" name="id" value="' . esc_attr( $options['id'] ) . '">';
 
159
  $html .= '<input type="hidden" name="type" value="' . esc_attr( $options['type'] ) . '">';
160
  $html .= '<table class="schema-admin-table">';
161
- $html .= '<tr><th>' . esc_html__( 'Output Page', $this->text_domain ) . ':</th><td>';
 
 
 
 
162
  echo $html;
163
 
164
  switch ( $options['type'] ) {
165
- case 'website':
166
- $this->output_checkbox_render( $options['output'], "all", "All", esc_html__( 'All Page', $this->text_domain ) );
167
- $this->output_checkbox_render( $options['output'], "home", "Top", esc_html__( 'Top Page', $this->text_domain ) );
168
- $this->output_checkbox_render( $options['output'], "post", "Post", esc_html__( 'Post Page', $this->text_domain ) );
169
- $this->output_checkbox_render( $options['output'], "page", "Fixed", esc_html__( 'Fixed Page', $this->text_domain ) );
170
- $html = '</td></tr></table><hr>';
171
- echo $html;
172
-
173
- require_once( plugin_dir_path( __FILE__ ) . 'wp-structuring-admin-type-website.php' );
174
- new Structuring_Markup_Type_Website( $options['option'] );
175
- break;
176
- case 'organization':
177
- $this->output_checkbox_render( $options['output'], "all", "All", esc_html__( 'All Page', $this->text_domain ) );
178
- $this->output_checkbox_render( $options['output'], "home", "Top", esc_html__( 'Top Page', $this->text_domain ) );
179
- $this->output_checkbox_render( $options['output'], "post", "Post", esc_html__( 'Post Page', $this->text_domain ) );
180
- $this->output_checkbox_render( $options['output'], "page", "Fixed", esc_html__( 'Fixed Page', $this->text_domain ) );
181
- $html = '</td></tr></table><hr>';
182
- echo $html;
183
-
184
- require_once ( plugin_dir_path( __FILE__ ) . 'wp-structuring-admin-type-organization.php' );
185
- new Structuring_Markup_Type_Organization( $options['option'] );
186
- break;
187
  case 'article':
188
- $this->output_checkbox_render( $options['output'], "post", "Post", esc_html__( 'Post Page', $this->text_domain ) );
189
- $html = '</td></tr></table><hr>';
190
  echo $html;
191
 
192
  require_once ( plugin_dir_path( __FILE__ ) . 'wp-structuring-admin-type-article.php' );
193
  new Structuring_Markup_Type_Article();
194
  break;
195
  case 'blog_posting':
196
- $this->output_checkbox_render( $options['output'], "post", "Post", esc_html__( 'Post Page', $this->text_domain ) );
197
- $html = '</td></tr></table><hr>';
198
  echo $html;
199
 
200
  require_once ( plugin_dir_path( __FILE__ ) . 'wp-structuring-admin-type-blog-posting.php' );
201
  new Structuring_Markup_Type_Blog_Posting();
202
  break;
 
 
 
 
 
 
 
 
203
  case 'news_article':
204
- $this->output_checkbox_render( $options['output'], "post", "Post", esc_html__( 'Post Page', $this->text_domain ) );
205
- $html = '</td></tr></table><hr>';
206
  echo $html;
207
 
208
  require_once ( plugin_dir_path( __FILE__ ) . 'wp-structuring-admin-type-news-article.php' );
209
  new Structuring_Markup_Type_NewsArticle();
210
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
  }
212
 
213
  $html = '</form>';
@@ -218,29 +176,29 @@ class Structuring_Markup_Admin_Post {
218
  /**
219
  * CheckBox Build Render
220
  *
221
- * @since 1.0.0
222
- * @param array $option['output']
223
- * @param string $output
224
- * @param string $value
225
- * @param string $display
226
- * @return string $html
 
227
  */
228
  private function output_checkbox_render( array $option, $output, $value, $display ) {
229
  $html = '<label>';
230
  $html .= '<input type="checkbox" name="output[' . $output . ']" value="' . $value . '""';
231
-
232
- if ( isset( $option[$output] ) ) {
233
- $html .= ' checked';
234
- }
235
  $html .= '>' . $display . '</label>';
236
 
237
- echo $html;
238
  }
239
 
240
  /**
241
  * Information Message Render
242
  *
243
- * @since 1.0.0
 
 
244
  */
245
  private function information_render() {
246
  $html = '<div id="message" class="updated notice notice-success is-dismissible below-h2">';
@@ -250,13 +208,15 @@ class Structuring_Markup_Admin_Post {
250
  $html .= '</button>';
251
  $html .= '</div>';
252
 
253
- echo $html;
254
  }
255
 
256
  /**
257
  * Error Message Render
258
  *
259
- * @since 1.0.0
 
 
260
  */
261
  private function output_error_render() {
262
  $html = '<div id="notice" class="notice notice-error is-dismissible below-h2">';
@@ -266,6 +226,6 @@ class Structuring_Markup_Admin_Post {
266
  $html .= '</button>';
267
  $html .= '</div>';
268
 
269
- echo $html;
270
  }
271
  }
3
  * Schema.org Admin Post
4
  *
5
  * @author Kazuya Takami
 
6
  * @since 1.0.0
7
+ * @version 2.0.0
8
  */
9
  class Structuring_Markup_Admin_Post {
10
 
11
  /**
12
  * Variable definition.
13
  *
14
+ * @since 1.3.0
15
+ * @version 2.0.0
16
  */
17
  private $text_domain;
18
+ private $type_array;
 
 
 
 
 
 
 
 
19
 
20
  /**
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 ) {
28
  $this->text_domain = $text_domain;
29
 
 
 
 
 
 
 
 
 
30
  /**
31
  * Update Status
32
  *
37
 
38
  /** DB Connect */
39
  $db = new Structuring_Markup_Admin_Db();
40
+ $this->type_array = $db->type_array;
41
 
42
  /** Set Default Parameter for Array */
43
  $options = array(
44
+ "id" => "",
45
+ "type" => "",
46
+ "activate" => "",
47
+ "output" => array(),
48
+ "option" => array()
49
  );
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  /** DataBase Update & Insert Mode */
52
  if ( isset( $_POST['id'] ) && is_numeric( $_POST['id'] ) ) {
53
  if ( isset( $_POST['output'] ) ) {
54
+ $options['id'] = $db->update_options( $_POST );
 
55
  $status = "ok";
56
  } else {
57
  $status = "output";
58
  }
 
 
 
 
 
 
 
 
 
 
59
  }
60
 
61
+ /** Key Set */
62
+ if ( isset( $_GET['schema_post_id'] ) && is_numeric( $_GET['schema_post_id'] ) ) {
63
+ $options['id'] = esc_html( $_GET['schema_post_id'] );
64
+ }
65
+
66
+ /** Type Set */
67
+ if ( isset( $_GET['type'] ) && array_key_exists( $_GET['type'], $this->type_array) ) {
68
+ $options['type'] = esc_html( $_GET['type'] );
69
  }
70
 
71
+ $options = $db->get_options( $options['id'] );
72
+ $this->page_render( $options, $status );
73
  }
74
 
75
  /**
76
  * Setting Page of the Admin Screen.
77
  *
78
  * @since 1.0.0
79
+ * @version 2.0.0
80
  * @param array $options
 
81
  * @param string $status
82
  */
83
+ private function page_render( array $options, $status ) {
84
  $html = '';
85
  $html .= '<div class="wrap">';
86
+ $html .= '<h1>' . esc_html__( 'Schema.org Register', $this->text_domain );
87
+ $html .= '<span class="schema-admin-h1-span">[ Schema Type : ' . esc_html( $this->type_array[$options['type']] ) . ' ]</span>';
88
+ $html .= '</h1>';
89
  switch ( $status ) {
90
  case "ok":
91
+ $html .= $this->information_render();
92
  break;
93
  case "output":
94
+ $html .= $this->output_error_render();
95
  break;
96
  default:
97
  break;
98
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  echo $html;
100
 
101
  /** Output Page Select */
102
+ $html = '<hr>';
103
+ $html .= '<form method="post" action="">';
104
+ $html .= '<input type="hidden" name="id" value="' . esc_attr( $options['id'] ) . '">';
105
  $html .= '<input type="hidden" name="type" value="' . esc_attr( $options['type'] ) . '">';
106
  $html .= '<table class="schema-admin-table">';
107
+ $html .= '<tr><th>Activate : </th><td><label>';
108
+ $html .= '<input type="checkbox" name="activate" value="on"';
109
+ $html .= ( $options['activate'] === "on" ) ? ' checked' : '';
110
+ $html .= '>Activate</label></td></tr>';
111
+ $html .= '<tr><th>' . esc_html__( 'Output Page', $this->text_domain ) . ' : </th><td>';
112
  echo $html;
113
 
114
  switch ( $options['type'] ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  case 'article':
116
+ $html = $this->output_checkbox_render( $options['output'], "post", "Post", esc_html__( 'Post Page', $this->text_domain ) );
117
+ $html .= '</td></tr></table><hr>';
118
  echo $html;
119
 
120
  require_once ( plugin_dir_path( __FILE__ ) . 'wp-structuring-admin-type-article.php' );
121
  new Structuring_Markup_Type_Article();
122
  break;
123
  case 'blog_posting':
124
+ $html = $this->output_checkbox_render( $options['output'], "post", "Post", esc_html__( 'Post Page', $this->text_domain ) );
125
+ $html .= '</td></tr></table><hr>';
126
  echo $html;
127
 
128
  require_once ( plugin_dir_path( __FILE__ ) . 'wp-structuring-admin-type-blog-posting.php' );
129
  new Structuring_Markup_Type_Blog_Posting();
130
  break;
131
+ case 'breadcrumb':
132
+ $html = $this->output_checkbox_render( $options['output'], "all", "All", esc_html__( 'All Page', $this->text_domain ) );
133
+ $html .= '</td></tr></table><hr>';
134
+ echo $html;
135
+
136
+ require_once ( plugin_dir_path( __FILE__ ) . 'wp-structuring-admin-type-breadcrumb.php' );
137
+ new Structuring_Markup_Type_Breadcrumb( $options['option'] );
138
+ break;
139
  case 'news_article':
140
+ $html = $this->output_checkbox_render( $options['output'], "post", "Post", esc_html__( 'Post Page', $this->text_domain ) );
141
+ $html .= '</td></tr></table><hr>';
142
  echo $html;
143
 
144
  require_once ( plugin_dir_path( __FILE__ ) . 'wp-structuring-admin-type-news-article.php' );
145
  new Structuring_Markup_Type_NewsArticle();
146
  break;
147
+ case 'organization':
148
+ $html = $this->output_checkbox_render( $options['output'], "all", "All", esc_html__( 'All Page', $this->text_domain ) );
149
+ $html .= $this->output_checkbox_render( $options['output'], "home", "Top", esc_html__( 'Top Page', $this->text_domain ) );
150
+ $html .= $this->output_checkbox_render( $options['output'], "post", "Post", esc_html__( 'Post Page', $this->text_domain ) );
151
+ $html .= $this->output_checkbox_render( $options['output'], "page", "Fixed", esc_html__( 'Fixed Page', $this->text_domain ) );
152
+ $html .= '</td></tr></table><hr>';
153
+ echo $html;
154
+
155
+ require_once ( plugin_dir_path( __FILE__ ) . 'wp-structuring-admin-type-organization.php' );
156
+ new Structuring_Markup_Type_Organization( $options['option'] );
157
+ break;
158
+ case 'website':
159
+ $html = $this->output_checkbox_render( $options['output'], "all", "All", esc_html__( 'All Page', $this->text_domain ) );
160
+ $html .= $this->output_checkbox_render( $options['output'], "home", "Top", esc_html__( 'Top Page', $this->text_domain ) );
161
+ $html .= $this->output_checkbox_render( $options['output'], "post", "Post", esc_html__( 'Post Page', $this->text_domain ) );
162
+ $html .= $this->output_checkbox_render( $options['output'], "page", "Fixed", esc_html__( 'Fixed Page', $this->text_domain ) );
163
+ $html .= '</td></tr></table><hr>';
164
+ echo $html;
165
+
166
+ require_once( plugin_dir_path( __FILE__ ) . 'wp-structuring-admin-type-website.php' );
167
+ new Structuring_Markup_Type_Website( $options['option'] );
168
+ break;
169
  }
170
 
171
  $html = '</form>';
176
  /**
177
  * CheckBox Build Render
178
  *
179
+ * @since 1.0.0
180
+ * @version 2.0.0
181
+ * @param array $option['output']
182
+ * @param string $output
183
+ * @param string $value
184
+ * @param string $display
185
+ * @return string $html
186
  */
187
  private function output_checkbox_render( array $option, $output, $value, $display ) {
188
  $html = '<label>';
189
  $html .= '<input type="checkbox" name="output[' . $output . ']" value="' . $value . '""';
190
+ $html .= isset( $option[$output] ) ? ' checked' : '';
 
 
 
191
  $html .= '>' . $display . '</label>';
192
 
193
+ return (string) $html;
194
  }
195
 
196
  /**
197
  * Information Message Render
198
  *
199
+ * @since 1.0.0
200
+ * @version 2.0.0
201
+ * @return string $html
202
  */
203
  private function information_render() {
204
  $html = '<div id="message" class="updated notice notice-success is-dismissible below-h2">';
208
  $html .= '</button>';
209
  $html .= '</div>';
210
 
211
+ return (string) $html;
212
  }
213
 
214
  /**
215
  * Error Message Render
216
  *
217
+ * @since 1.0.0
218
+ * @version 2.0.0
219
+ * @return string $html
220
  */
221
  private function output_error_render() {
222
  $html = '<div id="notice" class="notice notice-error is-dismissible below-h2">';
226
  $html .= '</button>';
227
  $html .= '</div>';
228
 
229
+ return (string) $html;
230
  }
231
  }
includes/wp-structuring-admin-type-article.php CHANGED
@@ -15,8 +15,7 @@ class Structuring_Markup_Type_Article {
15
  *
16
  * @since 1.1.0
17
  */
18
- public function __construct()
19
- {
20
  $this->page_render();
21
  }
22
 
@@ -25,8 +24,7 @@ class Structuring_Markup_Type_Article {
25
  *
26
  * @since 1.1.0
27
  */
28
- private function page_render()
29
- {
30
  $html = '<table class="schema-admin-table">';
31
  $html .= '<caption>Basic Setting( Post Page Only )</caption>';
32
  $html .= '<tr><th>headline :</th><td><small>Default : post_title</small></td></tr>';
@@ -38,6 +36,7 @@ class Structuring_Markup_Type_Article {
38
  $html .= '</table>';
39
  echo $html;
40
 
 
41
  submit_button();
42
  }
43
  }
15
  *
16
  * @since 1.1.0
17
  */
18
+ public function __construct() {
 
19
  $this->page_render();
20
  }
21
 
24
  *
25
  * @since 1.1.0
26
  */
27
+ private function page_render() {
 
28
  $html = '<table class="schema-admin-table">';
29
  $html .= '<caption>Basic Setting( Post Page Only )</caption>';
30
  $html .= '<tr><th>headline :</th><td><small>Default : post_title</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
  }
includes/wp-structuring-admin-type-blog-posting.php CHANGED
@@ -15,8 +15,7 @@ class Structuring_Markup_Type_Blog_Posting {
15
  *
16
  * @since 1.2.0
17
  */
18
- public function __construct()
19
- {
20
  $this->page_render();
21
  }
22
 
@@ -25,8 +24,7 @@ class Structuring_Markup_Type_Blog_Posting {
25
  *
26
  * @since 1.2.0
27
  */
28
- private function page_render()
29
- {
30
  $html = '<table class="schema-admin-table">';
31
  $html .= '<caption>Basic Setting( Post Page Only )</caption>';
32
  $html .= '<tr><th>headline :</th><td><small>Default : post_title</small></td></tr>';
@@ -39,6 +37,7 @@ class Structuring_Markup_Type_Blog_Posting {
39
  $html .= '</table>';
40
  echo $html;
41
 
 
42
  submit_button();
43
  }
44
  }
15
  *
16
  * @since 1.2.0
17
  */
18
+ public function __construct() {
 
19
  $this->page_render();
20
  }
21
 
24
  *
25
  * @since 1.2.0
26
  */
27
+ private function page_render() {
 
28
  $html = '<table class="schema-admin-table">';
29
  $html .= '<caption>Basic Setting( Post Page Only )</caption>';
30
  $html .= '<tr><th>headline :</th><td><small>Default : post_title</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
  }
includes/wp-structuring-admin-type-breadcrumb.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Schema.org Type Breadcrumb
4
+ *
5
+ * @author Kazuya Takami
6
+ * @version 2.0.0
7
+ * @since 2.0.0
8
+ * @see wp-structuring-admin-db.php
9
+ * @link https://schema.org/BreadcrumbList
10
+ * @link https://developers.google.com/structured-data/breadcrumbs
11
+ */
12
+ class Structuring_Markup_Type_Breadcrumb {
13
+
14
+ /**
15
+ * Constructor Define.
16
+ *
17
+ * @since 2.0.0
18
+ * @param array $option
19
+ */
20
+ public function __construct( array $option ) {
21
+ /** Default Value Set */
22
+ if ( empty( $option ) ) {
23
+ $option = $this->get_default_options( $option );
24
+ }
25
+ $this->page_render( $option );
26
+ }
27
+
28
+ /**
29
+ * Form Layout Render
30
+ *
31
+ * @since 2.0.0
32
+ * @param array $option
33
+ */
34
+ private function page_render( array $option ) {
35
+ $html = '<table class="schema-admin-table">';
36
+ $html .= '<caption>Basic Setting</caption>';
37
+ $html .= '<tr><th><label for="home_on">Home Display :</label></th><td>';
38
+ $html .= '<input type="checkbox" name="option[' . "home_on" . ']" id="home_on" value="on"';
39
+ if ( isset( $option['home_on'] ) && $option['home_on'] === 'on' ) {
40
+ $html .= ' checked="checked"';
41
+ }
42
+ $html .= '>Active';
43
+ $html .= '<small>( Installed the HOME to breadcrumbs )</small>';
44
+ $html .= '</td></tr>';
45
+ $html .= '<tr><th><label for="home_name">Home Name :</label></th><td>';
46
+ $html .= '<input type="text" name="option[' . "home_name" . ']" id="home_name" class="regular-text" value="' . esc_attr( $option['home_name'] ) . '">';
47
+ $html .= '<small>Default : bloginfo("name")</small>';
48
+ $html .= '</td></tr>';
49
+ $html .= '</table>';
50
+ echo $html;
51
+
52
+ echo '<p>Setting Knowledge : <a href="https://developers.google.com/structured-data/slsb-overview" target="_blank">https://developers.google.com/structured-data/slsb-overview</a></p>';
53
+ submit_button();
54
+ }
55
+
56
+ /**
57
+ * Return the default options array
58
+ *
59
+ * @since 2.0.0
60
+ * @param array $args
61
+ * @return array $args
62
+ */
63
+ private function get_default_options( array $args ) {
64
+ $args['home_on'] = 'on';
65
+ $args['home_name'] = '';
66
+
67
+ return (array) $args;
68
+ }
69
+ }
includes/wp-structuring-admin-type-news-article.php CHANGED
@@ -16,8 +16,7 @@ class Structuring_Markup_Type_NewsArticle {
16
  *
17
  * @since 1.0.0
18
  */
19
- public function __construct()
20
- {
21
  $this->page_render();
22
  }
23
 
@@ -26,8 +25,7 @@ class Structuring_Markup_Type_NewsArticle {
26
  *
27
  * @since 1.0.0
28
  */
29
- private function page_render()
30
- {
31
  $html = '<table class="schema-admin-table">';
32
  $html .= '<caption>Basic Setting( Post Page Only )</caption>';
33
  $html .= '<tr><th>headline :</th><td><small>Default : post_title</small></td></tr>';
16
  *
17
  * @since 1.0.0
18
  */
19
+ public function __construct() {
 
20
  $this->page_render();
21
  }
22
 
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>';
includes/wp-structuring-admin-type-organization.php CHANGED
@@ -48,8 +48,7 @@ class Structuring_Markup_Type_Organization {
48
  * @since 1.0.0
49
  * @param array $option
50
  */
51
- public function __construct( array $option )
52
- {
53
  /** Default Value Set */
54
  if ( empty( $option ) ) {
55
  $option = $this->get_default_options( $option );
@@ -63,8 +62,7 @@ class Structuring_Markup_Type_Organization {
63
  * @since 1.0.0
64
  * @param array $option
65
  */
66
- private function page_render( array $option )
67
- {
68
  /** Logos */
69
  $html = '<table class="schema-admin-table">';
70
  $html .= '<caption>Logos</caption>';
@@ -150,12 +148,12 @@ class Structuring_Markup_Type_Organization {
150
  /**
151
  * Return the default options array
152
  *
153
- * @since 1.0.0
154
- * @param array $args
155
- * @return array $args
 
156
  */
157
  private function get_default_options( array $args ) {
158
- $args['id'] = '';
159
  $args['name'] = get_bloginfo('name');
160
  $args['url'] = get_bloginfo('url');
161
  $args['logo'] = get_bloginfo('url') . '/images/logo.png';
48
  * @since 1.0.0
49
  * @param array $option
50
  */
51
+ public function __construct( array $option ) {
 
52
  /** Default Value Set */
53
  if ( empty( $option ) ) {
54
  $option = $this->get_default_options( $option );
62
  * @since 1.0.0
63
  * @param array $option
64
  */
65
+ private function page_render( array $option ) {
 
66
  /** Logos */
67
  $html = '<table class="schema-admin-table">';
68
  $html .= '<caption>Logos</caption>';
148
  /**
149
  * Return the default options array
150
  *
151
+ * @since 1.0.0
152
+ * @version 2.0.0
153
+ * @param array $args
154
+ * @return array $args
155
  */
156
  private function get_default_options( array $args ) {
 
157
  $args['name'] = get_bloginfo('name');
158
  $args['url'] = get_bloginfo('url');
159
  $args['logo'] = get_bloginfo('url') . '/images/logo.png';
includes/wp-structuring-admin-type-website.php CHANGED
@@ -18,8 +18,7 @@ class Structuring_Markup_Type_Website {
18
  * @since 1.0.0
19
  * @param array $option
20
  */
21
- public function __construct( array $option )
22
- {
23
  /** Default Value Set */
24
  if ( empty( $option ) ) {
25
  $option = $this->get_default_options( $option );
@@ -33,8 +32,7 @@ class Structuring_Markup_Type_Website {
33
  * @since 1.0.0
34
  * @param array $option
35
  */
36
- private function page_render( array $option )
37
- {
38
  $html = '<table class="schema-admin-table">';
39
  $html .= '<caption>Basic Setting</caption>';
40
  $html .= '<tr><th><label for="name">name :</label></th><td>';
@@ -75,12 +73,12 @@ class Structuring_Markup_Type_Website {
75
  /**
76
  * Return the default options array
77
  *
78
- * @since 1.0.0
79
- * @param array $args
80
- * @return array $args
 
81
  */
82
  private function get_default_options( array $args ) {
83
- $args['id'] = '';
84
  $args['name'] = get_bloginfo('name');
85
  $args['alternateName'] = $args['name'];
86
  $args['url'] = get_bloginfo('url');
18
  * @since 1.0.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 );
32
  * @since 1.0.0
33
  * @param array $option
34
  */
35
+ private function page_render( array $option ) {
 
36
  $html = '<table class="schema-admin-table">';
37
  $html .= '<caption>Basic Setting</caption>';
38
  $html .= '<tr><th><label for="name">name :</label></th><td>';
73
  /**
74
  * Return the default options array
75
  *
76
+ * @since 1.0.0
77
+ * @version 2.0.0
78
+ * @param array $args
79
+ * @return array $args
80
  */
81
  private function get_default_options( array $args ) {
 
82
  $args['name'] = get_bloginfo('name');
83
  $args['alternateName'] = $args['name'];
84
  $args['url'] = get_bloginfo('url');
includes/wp-structuring-display.php CHANGED
@@ -22,11 +22,11 @@ class Structuring_Markup_Display {
22
  * Setting schema.org
23
  *
24
  * @since 1.0.0
25
- * @version 1.3.2
26
  * @param Structuring_Markup_Admin_Db $db
27
  */
28
  private function set_schema( Structuring_Markup_Admin_Db $db ) {
29
- echo '<!-- WP Markup (JSON-LD) structured in schema.org START -->' , PHP_EOL;
30
  $this->get_schema_data( $db, 'all' );
31
  if ( is_home() ) {
32
  $this->get_schema_data( $db, 'home' );
@@ -37,14 +37,14 @@ class Structuring_Markup_Display {
37
  if ( is_page() ) {
38
  $this->get_schema_data( $db, 'page' );
39
  }
40
- echo '<!-- WP Markup (JSON-LD) structured in schema.org END -->' , PHP_EOL;
41
  }
42
 
43
  /**
44
  * Setting JSON-LD Template
45
  *
46
  * @since 1.0.0
47
- * @version 1.2.0
48
  * @param Structuring_Markup_Admin_Db $db
49
  * @param string $output
50
  */
@@ -53,31 +53,30 @@ class Structuring_Markup_Display {
53
 
54
  if ( isset( $results ) ) {
55
  foreach ( $results as $row ) {
56
- if ( isset( $row->type ) ) {
57
  switch ( $row->type ) {
58
- case 'website':
59
- if ( isset( $row->options ) ) {
60
- $this->set_schema_website( unserialize( $row->options ) );
61
- }
62
  break;
63
- case 'organization':
64
- if ( isset( $row->options ) ) {
65
- $this->set_schema_organization( unserialize( $row->options ) );
66
- }
67
  break;
68
- case 'article':
69
  if ( isset( $row->options ) ) {
70
- $this->set_schema_article();
71
  }
72
  break;
73
- case 'blog_posting':
 
 
 
74
  if ( isset( $row->options ) ) {
75
- $this->set_schema_blog_posting();
76
  }
77
  break;
78
- case 'news_article':
79
  if ( isset( $row->options ) ) {
80
- $this->set_schema_news_article();
81
  }
82
  break;
83
  }
@@ -101,82 +100,13 @@ class Structuring_Markup_Display {
101
  /**
102
  * Setting JSON-LD Template
103
  *
104
- * @since 1.1.3
105
- * @param string $text
106
- * @return string $text
 
107
  */
108
  private function escape_text_tags( $text ) {
109
- return str_replace( array( "\r", "\n" ), '', strip_tags( $text ) );
110
- }
111
-
112
- /**
113
- * Setting schema.org WebSite
114
- *
115
- * @since 1.0.0
116
- * @param array $options
117
- */
118
- private function set_schema_website( array $options ) {
119
- $args = array(
120
- "@context" => "http://schema.org",
121
- "@type" => "WebSite",
122
- "name" => isset( $options['name'] ) ? esc_html( $options['name'] ) : "",
123
- "alternateName" => isset( $options['alternateName'] ) ? esc_html( $options['alternateName'] ) : "",
124
- "url" => isset( $options['url'] ) ? esc_html( $options['url'] ) : ""
125
- );
126
-
127
- if ( isset( $options['potential_action'] ) && $options['potential_action'] === 'on' ) {
128
- $potential_action["potentialAction"] = array(
129
- "@type" => "SearchAction",
130
- "target" => isset( $options['target'] ) ? esc_html( $options['target'] ) . "{search_term_string}" : "",
131
- "query-input" => isset( $options['target'] ) ? "required name=search_term_string" : ""
132
- );
133
- $args = array_merge( $args, $potential_action );
134
- }
135
-
136
- $this->set_schema_json( $args );
137
- }
138
-
139
- /**
140
- * Setting schema.org Organization
141
- *
142
- * @since 1.0.0
143
- * @version 1.2.1
144
- * @param array $options
145
- */
146
- private function set_schema_organization( array $options ) {
147
- /** Logos */
148
- $args = array(
149
- "@context" => "http://schema.org",
150
- "@type" => "Organization",
151
- "name" => isset( $options['name'] ) ? esc_html( $options['name'] ) : "",
152
- "url" => isset( $options['url'] ) ? esc_html( $options['url'] ) : "",
153
- "logo" => isset( $options['logo'] ) ? esc_html( $options['logo'] ) : ""
154
- );
155
-
156
- /** Corporate Contact */
157
- if ( isset( $options['contact_point'] ) && $options['contact_point'] === 'on' ) {
158
- $contact_point["contactPoint"] = array(
159
- array(
160
- "@type" => "ContactPoint",
161
- "telephone" => isset( $options['telephone'] ) ? esc_html( $options['telephone'] ) : "",
162
- "contactType" => isset( $options['contact_type'] ) ? esc_html( $options['contact_type'] ) : ""
163
- )
164
- );
165
- $args = array_merge( $args, $contact_point );
166
- }
167
-
168
- /** Social Profiles */
169
- if ( isset( $options['social'] ) ) {
170
- $socials["sameAs"] = array();
171
-
172
- foreach ( $options['social'] as $value ) {
173
- if ( !empty( $value ) ) {
174
- $socials["sameAs"][] = esc_html( $value );
175
- }
176
- }
177
- $args = array_merge( $args, $socials );
178
- }
179
- $this->set_schema_json( $args );
180
  }
181
 
182
  /**
@@ -228,6 +158,42 @@ class Structuring_Markup_Display {
228
  }
229
  }
230
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
  /**
232
  * Setting schema.org NewsArticle
233
  *
@@ -250,4 +216,74 @@ class Structuring_Markup_Display {
250
  $this->set_schema_json( $args );
251
  }
252
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  }
22
  * Setting schema.org
23
  *
24
  * @since 1.0.0
25
+ * @version 2.0.0
26
  * @param Structuring_Markup_Admin_Db $db
27
  */
28
  private function set_schema( Structuring_Markup_Admin_Db $db ) {
29
+ echo '<!-- Markup (JSON-LD) structured in schema.org START -->' . PHP_EOL;
30
  $this->get_schema_data( $db, 'all' );
31
  if ( is_home() ) {
32
  $this->get_schema_data( $db, 'home' );
37
  if ( is_page() ) {
38
  $this->get_schema_data( $db, 'page' );
39
  }
40
+ echo '<!-- Markup (JSON-LD) structured in schema.org END -->' . PHP_EOL;
41
  }
42
 
43
  /**
44
  * Setting JSON-LD Template
45
  *
46
  * @since 1.0.0
47
+ * @version 2.0.0
48
  * @param Structuring_Markup_Admin_Db $db
49
  * @param string $output
50
  */
53
 
54
  if ( isset( $results ) ) {
55
  foreach ( $results as $row ) {
56
+ if ( isset( $row->type ) && $row->activate === 'on' ) {
57
  switch ( $row->type ) {
58
+ case 'article':
59
+ $this->set_schema_article();
 
 
60
  break;
61
+ case 'blog_posting':
62
+ $this->set_schema_blog_posting();
 
 
63
  break;
64
+ case 'breadcrumb':
65
  if ( isset( $row->options ) ) {
66
+ $this->set_schema_breadcrumb(unserialize($row->options));
67
  }
68
  break;
69
+ case 'news_article':
70
+ $this->set_schema_news_article();
71
+ break;
72
+ case 'organization':
73
  if ( isset( $row->options ) ) {
74
+ $this->set_schema_organization( unserialize( $row->options ) );
75
  }
76
  break;
77
+ case 'website':
78
  if ( isset( $row->options ) ) {
79
+ $this->set_schema_website( unserialize( $row->options ) );
80
  }
81
  break;
82
  }
100
  /**
101
  * Setting JSON-LD Template
102
  *
103
+ * @since 1.1.3
104
+ * @version 2.0.0
105
+ * @param string $text
106
+ * @return string $text
107
  */
108
  private function escape_text_tags( $text ) {
109
+ return (string) str_replace( array( "\r", "\n" ), '', strip_tags( $text ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  }
111
 
112
  /**
158
  }
159
  }
160
 
161
+ /**
162
+ * Setting schema.org Breadcrumb
163
+ *
164
+ * @since 2.0.0
165
+ * @version 2.0.0
166
+ * @param array $options
167
+ */
168
+ private function set_schema_breadcrumb( array $options ) {
169
+ require_once( plugin_dir_path( __FILE__ ) . 'wp-structuring-short-code-breadcrumb.php' );
170
+ $obj = new Structuring_Markup_ShortCode_Breadcrumb();
171
+ $item_array = $obj->breadcrumb_array_setting( $options );
172
+
173
+ if ( $item_array ) {
174
+ /** itemListElement build */
175
+ $item_list_element = array();
176
+ $position = 1;
177
+ foreach ($item_array as $item) {
178
+ $item_list_element[] = array(
179
+ "@type" => "ListItem",
180
+ "position" => $position,
181
+ "item" => $item
182
+ );
183
+ $position++;
184
+ }
185
+
186
+ /** Breadcrumb Schema build */
187
+ $args = array(
188
+ "@context" => "http://schema.org",
189
+ "@type" => "BreadcrumbList",
190
+ "itemListElement" => $item_list_element
191
+ );
192
+
193
+ $this->set_schema_json($args);
194
+ }
195
+ }
196
+
197
  /**
198
  * Setting schema.org NewsArticle
199
  *
216
  $this->set_schema_json( $args );
217
  }
218
  }
219
+
220
+ /**
221
+ * Setting schema.org Organization
222
+ *
223
+ * @since 1.0.0
224
+ * @version 1.2.1
225
+ * @param array $options
226
+ */
227
+ private function set_schema_organization( array $options ) {
228
+ /** Logos */
229
+ $args = array(
230
+ "@context" => "http://schema.org",
231
+ "@type" => "Organization",
232
+ "name" => isset( $options['name'] ) ? esc_html( $options['name'] ) : "",
233
+ "url" => isset( $options['url'] ) ? esc_html( $options['url'] ) : "",
234
+ "logo" => isset( $options['logo'] ) ? esc_html( $options['logo'] ) : ""
235
+ );
236
+
237
+ /** Corporate Contact */
238
+ if ( isset( $options['contact_point'] ) && $options['contact_point'] === 'on' ) {
239
+ $contact_point["contactPoint"] = array(
240
+ array(
241
+ "@type" => "ContactPoint",
242
+ "telephone" => isset( $options['telephone'] ) ? esc_html( $options['telephone'] ) : "",
243
+ "contactType" => isset( $options['contact_type'] ) ? esc_html( $options['contact_type'] ) : ""
244
+ )
245
+ );
246
+ $args = array_merge( $args, $contact_point );
247
+ }
248
+
249
+ /** Social Profiles */
250
+ if ( isset( $options['social'] ) ) {
251
+ $socials["sameAs"] = array();
252
+
253
+ foreach ( $options['social'] as $value ) {
254
+ if ( !empty( $value ) ) {
255
+ $socials["sameAs"][] = esc_html( $value );
256
+ }
257
+ }
258
+ $args = array_merge( $args, $socials );
259
+ }
260
+ $this->set_schema_json( $args );
261
+ }
262
+
263
+ /**
264
+ * Setting schema.org WebSite
265
+ *
266
+ * @since 1.0.0
267
+ * @param array $options
268
+ */
269
+ private function set_schema_website( array $options ) {
270
+ $args = array(
271
+ "@context" => "http://schema.org",
272
+ "@type" => "WebSite",
273
+ "name" => isset( $options['name'] ) ? esc_html( $options['name'] ) : "",
274
+ "alternateName" => isset( $options['alternateName'] ) ? esc_html( $options['alternateName'] ) : "",
275
+ "url" => isset( $options['url'] ) ? esc_html( $options['url'] ) : ""
276
+ );
277
+
278
+ if ( isset( $options['potential_action'] ) && $options['potential_action'] === 'on' ) {
279
+ $potential_action["potentialAction"] = array(
280
+ "@type" => "SearchAction",
281
+ "target" => isset( $options['target'] ) ? esc_html( $options['target'] ) . "{search_term_string}" : "",
282
+ "query-input" => isset( $options['target'] ) ? "required name=search_term_string" : ""
283
+ );
284
+ $args = array_merge( $args, $potential_action );
285
+ }
286
+
287
+ $this->set_schema_json( $args );
288
+ }
289
  }
includes/wp-structuring-short-code-breadcrumb.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Breadcrumb ShortCode Settings
4
+ *
5
+ * @author Kazuya Takami
6
+ * @version 2.0.0
7
+ * @since 2.0.0
8
+ */
9
+ class Structuring_Markup_ShortCode_Breadcrumb {
10
+
11
+ /**
12
+ * ShortCode Display.
13
+ *
14
+ * @since 2.0.0
15
+ * @access public
16
+ * @param array $options
17
+ * @return string $html
18
+ */
19
+ public function short_code_display( array $options ) {
20
+ $item_array = $this->breadcrumb_array_setting( $options );
21
+ $html = '';
22
+
23
+ if ( $item_array ) {
24
+ $html .= '<!-- Markup (JSON-LD) structured in schema.org Breadcrumb START -->' . PHP_EOL;
25
+ $html .= '<ol>' . PHP_EOL;
26
+ foreach ($item_array as $item) {
27
+ $html .= '<li>';
28
+ $html .= '<a href="' . esc_url($item['@id']) . '">';
29
+ $html .= esc_html($item['name']);
30
+ $html .= '</a>';
31
+ $html .= '</li>' . PHP_EOL;
32
+ }
33
+ $html .= '</ol>' . PHP_EOL;
34
+ $html .= '<!-- Markup (JSON-LD) structured in schema.org Breadcrumb END -->' . PHP_EOL;
35
+ }
36
+
37
+ return (string) $html;
38
+ }
39
+
40
+ /**
41
+ * Breadcrumb array setting.
42
+ *
43
+ * @since 2.0.0
44
+ * @access public
45
+ * @param array $options
46
+ * @return array $item_array
47
+ */
48
+ public function breadcrumb_array_setting( array $options ) {
49
+ global $post;
50
+
51
+ /** item build */
52
+ $item_array = array();
53
+ $current_url = esc_url( home_url() . $_SERVER['REQUEST_URI'] );
54
+
55
+ if ( isset( $options['home_on'] ) && $options['home_on'] === 'on' ) {
56
+ if ( isset( $options['home_name'] ) ) {
57
+ $item_array[] = $this->set_schema_breadcrumb_item( home_url(), $options['home_name'] );
58
+ } else {
59
+ $item_array[] = $this->set_schema_breadcrumb_item( home_url(), get_bloginfo('name') );
60
+ }
61
+ }
62
+
63
+ if ( is_search() ) {
64
+ $item_array[] = $this->set_schema_breadcrumb_item( $current_url, get_search_query() );
65
+ } elseif ( is_tag() ) {
66
+ $item_array[] = $this->set_schema_breadcrumb_item( $current_url, single_tag_title( '', false ) );
67
+ } elseif ( is_date() ) {
68
+ $item_array[] = $this->set_schema_breadcrumb_item( get_year_link( get_query_var( 'year' ) ), get_query_var( 'year' ) );
69
+ if ( get_query_var( 'day' ) !== 0 ) {
70
+ $item_array[] = $this->set_schema_breadcrumb_item( get_month_link( get_query_var( 'year' ), get_query_var( 'monthnum' ) ), get_query_var( 'monthnum' ) );
71
+ $item_array[] = $this->set_schema_breadcrumb_item( get_day_link( get_query_var( 'year' ), get_query_var( 'monthnum' ), get_query_var( 'day' ) ), get_query_var( 'day' ) );
72
+ } elseif ( get_query_var( 'monthnum' ) !== 0 ) {
73
+ $item_array[] = $this->set_schema_breadcrumb_item( get_month_link( get_query_var( 'year' ), get_query_var( 'monthnum' ) ), get_query_var( 'monthnum' ) );
74
+ }
75
+ } elseif ( is_category() ) {
76
+ $categories = get_queried_object();
77
+ if( $categories->parent !== 0 ) {
78
+ $ancestors = array_reverse( get_ancestors( $categories->cat_ID, 'category' ) );
79
+ foreach( $ancestors as $ancestor ) {
80
+ $item_array[] = $this->set_schema_breadcrumb_item( get_category_link( $ancestor ), get_cat_name( $ancestor ) );
81
+ }
82
+ }
83
+ $item_array[] = $this->set_schema_breadcrumb_item( get_category_link( $categories->term_id ), $categories->name );
84
+ } elseif ( is_author() ) {
85
+ $item_array[] = $this->set_schema_breadcrumb_item( $current_url, get_the_author_meta( 'display_name', get_query_var( 'author' ) ) );
86
+ } elseif ( is_page() ) {
87
+ if( $post->post_parent !== 0 ) {
88
+ $ancestors = array_reverse( get_post_ancestors( $post->ID ) );
89
+ foreach( $ancestors as $ancestor ){
90
+ $item_array[] = $this->set_schema_breadcrumb_item( get_permalink( $ancestor ), get_the_title( $ancestor ) );
91
+ }
92
+ }
93
+ $item_array[] = $this->set_schema_breadcrumb_item( $current_url, $post->post_title );
94
+ } elseif ( is_attachment() ) {
95
+ if ( $post->post_parent !== 0 ) {
96
+ $item_array[] = $this->set_schema_breadcrumb_item( get_permalink( $post->post_parent ), get_the_title( $post->post_parent ) );
97
+ }
98
+ $item_array[] = $this->set_schema_breadcrumb_item( $current_url, $post->post_title );
99
+ } elseif ( is_single() ) {
100
+ $categories = get_the_category($post->ID);
101
+ $cat = $categories[0];
102
+
103
+ if( $cat->parent !== 0){
104
+ $ancestors = array_reverse( get_ancestors( $cat->cat_ID, 'category' ) );
105
+ foreach( $ancestors as $ancestor ){
106
+ $item_array[] = $this->set_schema_breadcrumb_item( get_category_link( $ancestor ), get_cat_name( $ancestor ) );
107
+ }
108
+ }
109
+ $item_array[] = $this->set_schema_breadcrumb_item( get_category_link( $cat->term_id ), $cat->name );
110
+ $item_array[] = $this->set_schema_breadcrumb_item( $current_url, $post->post_title );
111
+ }
112
+
113
+ return (array) $item_array;
114
+ }
115
+
116
+ /**
117
+ * Breadcrumb item settings
118
+ *
119
+ * @since 2.0.0
120
+ * @version 2.0.0
121
+ * @param string $id
122
+ * @param string $name
123
+ * @return array $args
124
+ */
125
+ private function set_schema_breadcrumb_item( $id, $name ) {
126
+ $args = array(
127
+ "@id" => esc_html( $id ),
128
+ "name" => esc_html( $name )
129
+ );
130
+ return (array) $args;
131
+ }
132
+ }
languages/wp-structuring-markup-ja.mo CHANGED
Binary file
languages/wp-structuring-markup-ja.po CHANGED
@@ -2,107 +2,95 @@
2
  # This file is distributed under the same license as the Markup (JSON-LD) structured in schema.org package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Markup (JSON-LD) structured in schema.org 1.3.0\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-structuring-"
7
  "markup\n"
8
- "POT-Creation-Date: 2015-10-24 10:02:34+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
  "PO-Revision-Date: 2015-MO-DA HO:MI+ZONE\n"
13
- "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
15
 
16
- #: includes/wp-structuring-admin-list.php:65
17
  msgid "Schema.org Settings List"
18
  msgstr "Schema.org 設定一覧"
19
 
20
- #: includes/wp-structuring-admin-list.php:66 wp-structuring-markup.php:95
21
- msgid "Add New"
22
- msgstr "新規追加"
23
 
24
- #: includes/wp-structuring-admin-list.php:77
25
  msgid "Schema Type"
26
  msgstr ""
27
 
28
- #: includes/wp-structuring-admin-list.php:78
29
- #: includes/wp-structuring-admin-post.php:161
30
  msgid "Output Page"
31
- msgstr "出力ページ"
32
-
33
- #: includes/wp-structuring-admin-list.php:79
34
- msgid "Register Date"
35
- msgstr "登録日"
36
 
37
- #: includes/wp-structuring-admin-list.php:80
38
- msgid "Update Date"
39
- msgstr "更新日"
40
 
41
- #: includes/wp-structuring-admin-list.php:99
42
  msgid "Edit"
43
  msgstr "編集"
44
 
45
- #: includes/wp-structuring-admin-list.php:102
46
- msgid "Delete"
47
- msgstr "削除"
48
-
49
- #: includes/wp-structuring-admin-list.php:109
50
  msgid "Without registration."
51
  msgstr "登録されていません。"
52
 
53
- #: includes/wp-structuring-admin-post.php:120
54
  msgid "Schema.org Register"
55
- msgstr "Scheme.org 登録"
 
 
 
 
 
 
 
 
56
 
57
- #: includes/wp-structuring-admin-post.php:166
58
- #: includes/wp-structuring-admin-post.php:177
 
59
  msgid "All Page"
60
  msgstr "全てのページ"
61
 
62
- #: includes/wp-structuring-admin-post.php:167
63
- #: includes/wp-structuring-admin-post.php:178
64
  msgid "Top Page"
65
  msgstr "トップページ"
66
 
67
- #: includes/wp-structuring-admin-post.php:168
68
- #: includes/wp-structuring-admin-post.php:179
69
- #: includes/wp-structuring-admin-post.php:188
70
- #: includes/wp-structuring-admin-post.php:196
71
- #: includes/wp-structuring-admin-post.php:204
72
- msgid "Post Page"
73
- msgstr "投稿ページ"
74
-
75
- #: includes/wp-structuring-admin-post.php:169
76
- #: includes/wp-structuring-admin-post.php:180
77
  msgid "Fixed Page"
78
  msgstr "固定ページ"
79
 
80
- #: wp-structuring-markup.php:78 wp-structuring-markup.php:79
81
- msgid "Scheme.org Settings"
82
- msgstr "Scheme.org 設定"
83
 
84
- #: wp-structuring-markup.php:86 wp-structuring-markup.php:87
85
- msgid "All Settings"
86
- msgstr "設定一覧"
87
-
88
- #: wp-structuring-markup.php:94
89
- msgid "Scheme.org Settings Post"
90
- msgstr "新規登録"
91
 
92
  #. Plugin Name of the plugin/theme
93
  msgid "Markup (JSON-LD) structured in schema.org"
94
  msgstr ""
95
 
96
  #. Plugin URI of the plugin/theme
97
- msgid "https://github.com/miiitaka/wp-structuring-markup"
98
  msgstr ""
99
 
100
  #. Description of the plugin/theme
101
  msgid ""
102
  "It is plug in to implement structured markup (JSON-LD syntax) by schema.org "
103
  "definition on an article or the fixed page."
104
- msgstr ""
105
- "このプラグインは、投稿ページ、固定ページなどにschema.org定義の構造化マークアップ( JSON -LDの構文)を実装するプラグインです。"
106
 
107
  #. Author of the plugin/theme
108
  msgid "Kazuya Takami"
2
  # This file is distributed under the same license as the Markup (JSON-LD) structured in schema.org package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Markup (JSON-LD) structured in schema.org 2.0.0\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-structuring-"
7
  "markup\n"
8
+ "POT-Creation-Date: 2015-11-23 00:21:34+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
  "PO-Revision-Date: 2015-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: Kazuya Takami <foundationmeister@outlook.com>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
15
 
16
+ #: includes/wp-structuring-admin-list.php:43
17
  msgid "Schema.org Settings List"
18
  msgstr "Schema.org 設定一覧"
19
 
20
+ #: includes/wp-structuring-admin-list.php:50
21
+ msgid "Status"
22
+ msgstr ""
23
 
24
+ #: includes/wp-structuring-admin-list.php:51
25
  msgid "Schema Type"
26
  msgstr ""
27
 
28
+ #: includes/wp-structuring-admin-list.php:52
29
+ #: includes/wp-structuring-admin-post.php:111
30
  msgid "Output Page"
31
+ msgstr ""
 
 
 
 
32
 
33
+ #: includes/wp-structuring-admin-list.php:53
34
+ msgid "ShortCode"
35
+ msgstr ""
36
 
37
+ #: includes/wp-structuring-admin-list.php:81 wp-structuring-markup.php:116
38
  msgid "Edit"
39
  msgstr "編集"
40
 
41
+ #: includes/wp-structuring-admin-list.php:87
 
 
 
 
42
  msgid "Without registration."
43
  msgstr "登録されていません。"
44
 
45
+ #: includes/wp-structuring-admin-post.php:86
46
  msgid "Schema.org Register"
47
+ msgstr ""
48
+
49
+ #: includes/wp-structuring-admin-post.php:116
50
+ #: includes/wp-structuring-admin-post.php:124
51
+ #: includes/wp-structuring-admin-post.php:140
52
+ #: includes/wp-structuring-admin-post.php:150
53
+ #: includes/wp-structuring-admin-post.php:161
54
+ msgid "Post Page"
55
+ msgstr "投稿ページ"
56
 
57
+ #: includes/wp-structuring-admin-post.php:132
58
+ #: includes/wp-structuring-admin-post.php:148
59
+ #: includes/wp-structuring-admin-post.php:159
60
  msgid "All Page"
61
  msgstr "全てのページ"
62
 
63
+ #: includes/wp-structuring-admin-post.php:149
64
+ #: includes/wp-structuring-admin-post.php:160
65
  msgid "Top Page"
66
  msgstr "トップページ"
67
 
68
+ #: includes/wp-structuring-admin-post.php:151
69
+ #: includes/wp-structuring-admin-post.php:162
 
 
 
 
 
 
 
 
70
  msgid "Fixed Page"
71
  msgstr "固定ページ"
72
 
73
+ #: wp-structuring-markup.php:107 wp-structuring-markup.php:108
74
+ msgid "Schema.org Settings"
75
+ msgstr "Schema.org 設定"
76
 
77
+ #: wp-structuring-markup.php:115
78
+ msgid "Schema.org Setting Edit"
79
+ msgstr "Schema.org 編集"
 
 
 
 
80
 
81
  #. Plugin Name of the plugin/theme
82
  msgid "Markup (JSON-LD) structured in schema.org"
83
  msgstr ""
84
 
85
  #. Plugin URI of the plugin/theme
86
+ msgid "https://wordpress.org/plugins/wp-structuring-markup/"
87
  msgstr ""
88
 
89
  #. Description of the plugin/theme
90
  msgid ""
91
  "It is plug in to implement structured markup (JSON-LD syntax) by schema.org "
92
  "definition on an article or the fixed page."
93
+ msgstr "このプラグインは、投稿ページ、固定ページなどにschema.org定義の構造化マークアップ( JSON -LDの構文)を実装するプラグインです。"
 
94
 
95
  #. Author of the plugin/theme
96
  msgid "Kazuya Takami"
languages/wp-structuring-markup.pot CHANGED
@@ -2,10 +2,10 @@
2
  # This file is distributed under the same license as the Markup (JSON-LD) structured in schema.org package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Markup (JSON-LD) structured in schema.org 1.3.0\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-structuring-"
7
  "markup\n"
8
- "POT-Creation-Date: 2015-10-24 10:02:34+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
@@ -13,80 +13,69 @@ msgstr ""
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
15
 
16
- #: includes/wp-structuring-admin-list.php:65
17
  msgid "Schema.org Settings List"
18
  msgstr ""
19
 
20
- #: includes/wp-structuring-admin-list.php:66 wp-structuring-markup.php:95
21
- msgid "Add New"
22
  msgstr ""
23
 
24
- #: includes/wp-structuring-admin-list.php:77
25
  msgid "Schema Type"
26
  msgstr ""
27
 
28
- #: includes/wp-structuring-admin-list.php:78
29
- #: includes/wp-structuring-admin-post.php:161
30
  msgid "Output Page"
31
  msgstr ""
32
 
33
- #: includes/wp-structuring-admin-list.php:79
34
- msgid "Register Date"
35
- msgstr ""
36
-
37
- #: includes/wp-structuring-admin-list.php:80
38
- msgid "Update Date"
39
  msgstr ""
40
 
41
- #: includes/wp-structuring-admin-list.php:99
42
  msgid "Edit"
43
  msgstr ""
44
 
45
- #: includes/wp-structuring-admin-list.php:102
46
- msgid "Delete"
47
  msgstr ""
48
 
49
- #: includes/wp-structuring-admin-list.php:109
50
- msgid "Without registration."
51
  msgstr ""
52
 
53
- #: includes/wp-structuring-admin-post.php:120
54
- msgid "Schema.org Post"
 
 
 
 
55
  msgstr ""
56
 
57
- #: includes/wp-structuring-admin-post.php:166
58
- #: includes/wp-structuring-admin-post.php:177
 
59
  msgid "All Page"
60
  msgstr ""
61
 
62
- #: includes/wp-structuring-admin-post.php:167
63
- #: includes/wp-structuring-admin-post.php:178
64
  msgid "Top Page"
65
  msgstr ""
66
 
67
- #: includes/wp-structuring-admin-post.php:168
68
- #: includes/wp-structuring-admin-post.php:179
69
- #: includes/wp-structuring-admin-post.php:188
70
- #: includes/wp-structuring-admin-post.php:196
71
- #: includes/wp-structuring-admin-post.php:204
72
- msgid "Post Page"
73
- msgstr ""
74
-
75
- #: includes/wp-structuring-admin-post.php:169
76
- #: includes/wp-structuring-admin-post.php:180
77
  msgid "Fixed Page"
78
  msgstr ""
79
 
80
- #: wp-structuring-markup.php:78 wp-structuring-markup.php:79
81
- msgid "Scheme.org Settings"
82
- msgstr ""
83
-
84
- #: wp-structuring-markup.php:86 wp-structuring-markup.php:87
85
- msgid "All Settings"
86
  msgstr ""
87
 
88
- #: wp-structuring-markup.php:94
89
- msgid "Scheme.org Setting Post"
90
  msgstr ""
91
 
92
  #. Plugin Name of the plugin/theme
@@ -94,7 +83,7 @@ msgid "Markup (JSON-LD) structured in schema.org"
94
  msgstr ""
95
 
96
  #. Plugin URI of the plugin/theme
97
- msgid "https://github.com/miiitaka/wp-structuring-markup"
98
  msgstr ""
99
 
100
  #. Description of the plugin/theme
2
  # This file is distributed under the same license as the Markup (JSON-LD) structured in schema.org package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Markup (JSON-LD) structured in schema.org 2.0.0\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-structuring-"
7
  "markup\n"
8
+ "POT-Creation-Date: 2015-11-23 00:32:54+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
15
 
16
+ #: includes/wp-structuring-admin-list.php:43
17
  msgid "Schema.org Settings List"
18
  msgstr ""
19
 
20
+ #: includes/wp-structuring-admin-list.php:50
21
+ msgid "Status"
22
  msgstr ""
23
 
24
+ #: includes/wp-structuring-admin-list.php:51
25
  msgid "Schema Type"
26
  msgstr ""
27
 
28
+ #: includes/wp-structuring-admin-list.php:52
29
+ #: includes/wp-structuring-admin-post.php:111
30
  msgid "Output Page"
31
  msgstr ""
32
 
33
+ #: includes/wp-structuring-admin-list.php:53
34
+ msgid "ShortCode"
 
 
 
 
35
  msgstr ""
36
 
37
+ #: includes/wp-structuring-admin-list.php:81 wp-structuring-markup.php:116
38
  msgid "Edit"
39
  msgstr ""
40
 
41
+ #: includes/wp-structuring-admin-list.php:87
42
+ msgid "Without registration."
43
  msgstr ""
44
 
45
+ #: includes/wp-structuring-admin-post.php:86
46
+ msgid "Schema.org Register"
47
  msgstr ""
48
 
49
+ #: includes/wp-structuring-admin-post.php:116
50
+ #: includes/wp-structuring-admin-post.php:124
51
+ #: includes/wp-structuring-admin-post.php:140
52
+ #: includes/wp-structuring-admin-post.php:150
53
+ #: includes/wp-structuring-admin-post.php:161
54
+ msgid "Post Page"
55
  msgstr ""
56
 
57
+ #: includes/wp-structuring-admin-post.php:132
58
+ #: includes/wp-structuring-admin-post.php:148
59
+ #: includes/wp-structuring-admin-post.php:159
60
  msgid "All Page"
61
  msgstr ""
62
 
63
+ #: includes/wp-structuring-admin-post.php:149
64
+ #: includes/wp-structuring-admin-post.php:160
65
  msgid "Top Page"
66
  msgstr ""
67
 
68
+ #: includes/wp-structuring-admin-post.php:151
69
+ #: includes/wp-structuring-admin-post.php:162
 
 
 
 
 
 
 
 
70
  msgid "Fixed Page"
71
  msgstr ""
72
 
73
+ #: wp-structuring-markup.php:107 wp-structuring-markup.php:108
74
+ msgid "Schema.org Settings"
 
 
 
 
75
  msgstr ""
76
 
77
+ #: wp-structuring-markup.php:115
78
+ msgid "Schema.org Setting Edit"
79
  msgstr ""
80
 
81
  #. Plugin Name of the plugin/theme
83
  msgstr ""
84
 
85
  #. Plugin URI of the plugin/theme
86
+ msgid "https://wordpress.org/plugins/wp-structuring-markup/"
87
  msgstr ""
88
 
89
  #. Description of the plugin/theme
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: miiitaka
3
  Tags: schema, schema.org, json, json-ld, seo, post, posts, google
4
  Requires at least: 4.3.1
5
  Tested up to: 4.3.1
6
- Stable tag: 1.3.2
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
 
@@ -12,13 +12,14 @@ It is plug in to implement structured markup (JSON-LD syntax) by schema.org defi
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定義の構造化マークアップ( JSON -LDの構文)を実装するプラグインです。
16
  基本知識は、https://schema.org/ や https://developers.google.com/structured-data/ を参考にしてください。
17
 
18
  = Schema.org Type =
19
 
20
  * Article: http://schema.org/Article
21
  * BlogPosting: http://schema.org/BlogPosting
 
22
  * NewsArticle: http://schema.org/NewsArticle
23
  * Organization: https://schema.org/Organization
24
  * Website: https://schema.org/WebSite
@@ -30,9 +31,22 @@ Base knowledge is "https://schema.org/" and "https://developers.google.com/struc
30
  * The plug-in is activated.
31
  * Open 'Schema.org Setting' menu.
32
 
 
 
 
 
 
 
 
 
33
  == Changelog ==
34
 
35
- = 1.3.2 =
 
 
 
 
 
36
 
37
  * Fixed : Fixed translation.
38
  * Added : Additional output comment.
3
  Tags: schema, schema.org, json, json-ld, seo, post, posts, google
4
  Requires at least: 4.3.1
5
  Tested up to: 4.3.1
6
+ Stable tag: 2.0.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
 
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定義の構造化マークアップ(JSON-LDの構文)を実装するプラグインです。
16
  基本知識は、https://schema.org/ や https://developers.google.com/structured-data/ を参考にしてください。
17
 
18
  = Schema.org Type =
19
 
20
  * Article: http://schema.org/Article
21
  * BlogPosting: http://schema.org/BlogPosting
22
+ * BreadcrumbList: https://schema.org/BreadcrumbList
23
  * NewsArticle: http://schema.org/NewsArticle
24
  * Organization: https://schema.org/Organization
25
  * Website: https://schema.org/WebSite
31
  * The plug-in is activated.
32
  * Open 'Schema.org Setting' menu.
33
 
34
+ **Breadcrumb**
35
+
36
+ You can display the breadcrumbs in the short code. Breadcrumb definition is available even if not active.
37
+
38
+ ショートコードでパンくずリストを表示することができます。Breadcrumb定義がアクティブでなくても使用可能です。
39
+
40
+ `[wp-structuring-markup-breadcrumb]`
41
+
42
  == Changelog ==
43
 
44
+ = 2.0.0 (2015/11/23) =
45
+
46
+ * Added : Schema.org type "BreadcrumbList" Breadcrumbs schema.org definition Add breadcrumbs short code output that works
47
+ * Updated : Schema.org definition immobilization.
48
+
49
+ = 1.3.2 (2015/11/17) =
50
 
51
  * Fixed : Fixed translation.
52
  * Added : Additional output comment.
uninstall.php CHANGED
@@ -16,10 +16,12 @@ class Structuring_Markup_Uninstall {
16
  /**
17
  * Constructor Define.
18
  *
19
- * @since 1.0.0
 
20
  */
21
  function __construct() {
22
  $this->drop_table();
 
23
  }
24
 
25
  /**
16
  /**
17
  * Constructor Define.
18
  *
19
+ * @since 1.0.0
20
+ * @version 2.0.0
21
  */
22
  function __construct() {
23
  $this->drop_table();
24
+ delete_option( 'wp_structuring_markup' );
25
  }
26
 
27
  /**
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: 1.3.2
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 1.3.2
23
  */
24
  class Structuring_Markup {
25
 
@@ -34,14 +34,13 @@ class Structuring_Markup {
34
  * Constructor Define.
35
  *
36
  * @since 1.0.0
37
- * @version 1.3.0
38
  */
39
  public function __construct() {
 
 
40
  add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
41
 
42
- $db = new Structuring_Markup_Admin_Db();
43
- $db->create_table();
44
-
45
  if ( is_admin() ) {
46
  add_action( 'admin_init', array( $this, 'admin_init' ) );
47
  add_action( 'admin_menu', array( $this, 'admin_menu' ) );
@@ -51,13 +50,30 @@ class Structuring_Markup {
51
  }
52
 
53
  /**
54
- * admin init.
55
  *
56
- * @since 1.3.1
57
- * @version 1.3.1
58
  */
59
- public function admin_init() {
60
- wp_register_style( 'wp-structuring-markup-admin-style', plugins_url( 'css/style.css', __FILE__ ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  }
62
 
63
  /**
@@ -67,46 +83,45 @@ class Structuring_Markup {
67
  * @version 1.3.0
68
  */
69
  public function plugins_loaded() {
70
- load_plugin_textdomain(
71
- $this->text_domain,
72
- false,
73
- dirname( plugin_basename( __FILE__ ) ) . '/languages'
74
- );
 
 
 
 
 
 
75
  }
76
 
77
  /**
78
  * Add Menu to the Admin Screen.
79
  *
80
  * @since 1.0.0
81
- * @version 1.3.2
82
  */
83
  public function admin_menu() {
84
- add_menu_page(
85
- esc_html__( 'Scheme.org Settings', $this->text_domain ),
86
- esc_html__( 'Scheme.org Settings', $this->text_domain ),
87
- 'manage_options',
88
- plugin_basename( __FILE__ ),
89
- array( $this, 'list_page_render' )
90
- );
91
- add_submenu_page(
92
- __FILE__,
93
- esc_html__( 'All Settings', $this->text_domain ),
94
- esc_html__( 'All Settings', $this->text_domain ),
95
  'manage_options',
96
  plugin_basename( __FILE__ ),
97
  array( $this, 'list_page_render' )
98
  );
99
- $page = add_submenu_page(
100
- __FILE__,
101
- esc_html__( 'Scheme.org Setting Post', $this->text_domain ),
102
- esc_html__( 'Add New', $this->text_domain ),
103
  'manage_options',
104
- plugin_dir_path( __FILE__ ) . 'includes/wp-structuring-admin-post.php',
105
  array( $this, 'post_page_render' )
106
  );
107
 
108
  /** Using registered $page handle to hook stylesheet loading */
109
- add_action( 'admin_print_styles-' . $page, array( $this, 'add_style' ) );
 
110
  }
111
 
112
  /**
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.0.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.0.0
23
  */
24
  class Structuring_Markup {
25
 
34
  * Constructor Define.
35
  *
36
  * @since 1.0.0
37
+ * @version 2.0.0
38
  */
39
  public function __construct() {
40
+ register_activation_hook( __FILE__, array( $this, 'create_table' ) );
41
+ add_shortcode( $this->text_domain . '-breadcrumb', array( $this, 'short_code_init_breadcrumb' ) );
42
  add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
43
 
 
 
 
44
  if ( is_admin() ) {
45
  add_action( 'admin_init', array( $this, 'admin_init' ) );
46
  add_action( 'admin_menu', array( $this, 'admin_menu' ) );
50
  }
51
 
52
  /**
53
+ * Create table.
54
  *
55
+ * @since 2.0.0
 
56
  */
57
+ public function create_table() {
58
+ $db = new Structuring_Markup_Admin_Db();
59
+ $db->create_table();
60
+ }
61
+
62
+ /**
63
+ * Breadcrumb ShortCode Register.
64
+ *
65
+ * @since 2.0.0
66
+ * @return string $html
67
+ */
68
+ public function short_code_init_breadcrumb () {
69
+ /** DB Connect */
70
+ $db = new Structuring_Markup_Admin_Db();
71
+ $results = $db->get_type_options( 'breadcrumb' );
72
+ $options = $results['option'];
73
+
74
+ require_once( plugin_dir_path( __FILE__ ) . 'includes/wp-structuring-short-code-breadcrumb.php' );
75
+ $obj = new Structuring_Markup_ShortCode_Breadcrumb();
76
+ return $obj->short_code_display( $options );
77
  }
78
 
79
  /**
83
  * @version 1.3.0
84
  */
85
  public function plugins_loaded() {
86
+ load_plugin_textdomain( $this->text_domain, false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
87
+ }
88
+
89
+ /**
90
+ * admin init.
91
+ *
92
+ * @since 1.3.1
93
+ * @version 1.3.1
94
+ */
95
+ public function admin_init() {
96
+ wp_register_style( 'wp-structuring-markup-admin-style', plugins_url( 'css/style.css', __FILE__ ) );
97
  }
98
 
99
  /**
100
  * Add Menu to the Admin Screen.
101
  *
102
  * @since 1.0.0
103
+ * @version 2.0.0
104
  */
105
  public function admin_menu() {
106
+ $list_page = add_menu_page(
107
+ esc_html__( 'Schema.org Settings', $this->text_domain ),
108
+ esc_html__( 'Schema.org Settings', $this->text_domain ),
 
 
 
 
 
 
 
 
109
  'manage_options',
110
  plugin_basename( __FILE__ ),
111
  array( $this, 'list_page_render' )
112
  );
113
+ $post_page = add_submenu_page(
114
+ $this->text_domain . '-post',
115
+ esc_html__( 'Schema.org Setting Edit', $this->text_domain ),
116
+ esc_html__( 'Edit', $this->text_domain ),
117
  'manage_options',
118
+ $this->text_domain . '-post',
119
  array( $this, 'post_page_render' )
120
  );
121
 
122
  /** Using registered $page handle to hook stylesheet loading */
123
+ add_action( 'admin_print_styles-' . $list_page, array( $this, 'add_style' ) );
124
+ add_action( 'admin_print_styles-' . $post_page, array( $this, 'add_style' ) );
125
  }
126
 
127
  /**