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

Version Description

  • The first release.

=

Download this release

Release Info

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

Version 1.0.0

css/style.css ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ text-align: right;
12
+ width: 100px;
13
+ }
14
+ .schema-admin-table td label{
15
+ margin: 0 10px 0 0;
16
+ }
17
+ .schema-admin-table small {
18
+ margin: 0 0 0 10px;
19
+ }
20
+ .schema-admin-table input[type="checkbox"] {
21
+ margin: 0 5px 0 0;
22
+ }
readme.txt ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Markup (JSON-LD) structured in schema.org ===
2
+ Contributors: miiitaka
3
+ Tags: schema, json, seo
4
+ Requires at least: 4.3.1
5
+ Tested up to: 4.3.1
6
+ Stable tag: 1.0.0
7
+
8
+ It is plug in to implement structured markup (JSON-LD syntax) by schema.org definition on an article or the fixed page.
9
+
10
+ == Description ==
11
+
12
+ It is plug in to implement structured markup (JSON-LD syntax) by schema.org definition on an article or the fixed page.
13
+ Base knowledge is "https://developers.google.com/structured-data/"
14
+
15
+ == Installation ==
16
+
17
+ * A plug-in installation screen is displayed in the WordPress admin panel.
18
+ * It installs in `wp-content/plugins`.
19
+ * The plug-in is activated.
20
+ * Open 'Schema.org Setting' menu.
21
+
22
+ == Changelog ==
23
+
24
+ = 1.0.0 =
25
+ * The first release.
26
+
27
+ == Contact ==
28
+
29
+ email to foundationmeister[at]outlook.com
30
+ twitter @miiitaka
uninstall.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
3
+ exit;
4
+ }
5
+ new Structuring_Markup_Uninstall();
6
+
7
+ /**
8
+ * Schema.org Plugin Uninstall
9
+ *
10
+ * @author Kazuya Takami
11
+ * @version 1.0.0
12
+ * @since 1.0.0
13
+ */
14
+ class Structuring_Markup_Uninstall {
15
+
16
+ /**
17
+ * Constructor Define.
18
+ *
19
+ * @since 1.0.0
20
+ */
21
+ function __construct() {
22
+ $this->drop_table();
23
+ }
24
+
25
+ /**
26
+ * Drop Table.
27
+ *
28
+ * @since 1.0.0
29
+ */
30
+ private function drop_table() {
31
+ global $wpdb;
32
+ $table_name = $wpdb->prefix . "structuring_markup";
33
+ $wpdb->query( "DROP TABLE IF EXISTS " . $table_name );
34
+ }
35
+ }
wp-structuring-admin-db.php ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ define( 'WP_STRUCTURING_MARKUP_DB', 'structuring_markup' );
3
+
4
+ /**
5
+ * Schema.org Admin DB Connection
6
+ *
7
+ * @author Kazuya Takami
8
+ * @version 1.0.0
9
+ * @since 1.0.0
10
+ */
11
+ class Structuring_Markup_Admin_Db {
12
+ private $table_name;
13
+
14
+ /**
15
+ * Constructor Define.
16
+ *
17
+ * @since 1.0.0
18
+ */
19
+ public function __construct() {
20
+ global $wpdb;
21
+ $this->table_name = $wpdb->prefix . WP_STRUCTURING_MARKUP_DB;
22
+ }
23
+
24
+ /**
25
+ * Create Table.
26
+ *
27
+ * @since 1.0.0
28
+ */
29
+ public function create_table() {
30
+ global $wpdb;
31
+
32
+ $prepared = $wpdb->prepare( "SHOW TABLES LIKE %s", $this->table_name );
33
+ $is_db_exists = $wpdb->get_var( $prepared );
34
+
35
+ if ( is_null( $is_db_exists ) ) {
36
+ $charset_collate = $wpdb->get_charset_collate();
37
+
38
+ $query = " CREATE TABLE " . $this->table_name;
39
+ $query .= " (id mediumint(9) NOT NULL AUTO_INCREMENT PRIMARY KEY";
40
+ $query .= ",type tinytext NOT NULL";
41
+ $query .= ",output text NOT NULL";
42
+ $query .= ",options text NOT NULL";
43
+ $query .= ",register_date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL";
44
+ $query .= ",update_date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL";
45
+ $query .= ",UNIQUE KEY id (id)) " . $charset_collate;
46
+
47
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
48
+ dbDelta( $query );
49
+ }
50
+ }
51
+
52
+ /**
53
+ * Get Data.
54
+ *
55
+ * @since 1.0.0
56
+ * @param integer $id
57
+ * @return array $results
58
+ */
59
+ public function get_options( $id ) {
60
+ global $wpdb;
61
+
62
+ $query = "SELECT * FROM " . $this->table_name . " WHERE id = %d";
63
+ $data = array( $id );
64
+ $prepared = $wpdb->prepare( $query, $data );
65
+ $args = $wpdb->get_row( $prepared );
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
+ }
76
+
77
+ /**
78
+ * Get All Data.
79
+ *
80
+ * @since 1.0.0
81
+ * @return array $results
82
+ */
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
+ }
90
+
91
+ /**
92
+ * Get Select Data.
93
+ *
94
+ * @since 1.0.0
95
+ * @param array $output
96
+ * @return array $results
97
+ */
98
+ public function get_select_options( $output ) {
99
+ global $wpdb;
100
+
101
+ $query = "SELECT * FROM " . $this->table_name . " WHERE output LIKE '%%%s%%'";
102
+ $data = array( $output );
103
+ $prepared = $wpdb->prepare( $query, $data );
104
+ $results = $wpdb->get_results( $prepared );
105
+
106
+ return (array) $results;
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
+ * @param array $post($_POST)
138
+ */
139
+ public function update_options( array $post ) {
140
+ global $wpdb;
141
+
142
+ $data = array(
143
+ 'type' => $post['type'],
144
+ 'output' => serialize( $post['output'] ),
145
+ 'options' => isset( $post['option'] ) ? serialize( $post['option'] ) : "",
146
+ 'update_date' => date( "Y-m-d H:i:s" )
147
+ );
148
+ $key = array( 'id' => $post['id'] );
149
+ $prepared = array( '%s', '%s', '%s' );
150
+ $key_prepared = array( '%d' );
151
+
152
+ $wpdb->update( $this->table_name, $data, $key, $prepared, $key_prepared );
153
+ }
154
+
155
+ /**
156
+ * Delete Data.
157
+ *
158
+ * @since 1.0.0
159
+ * @param integer $id
160
+ */
161
+ public function delete_options( $id ) {
162
+ global $wpdb;
163
+
164
+ $key = array( 'id' => $id );
165
+ $key_prepared = array( '%d' );
166
+
167
+ $wpdb->delete( $this->table_name, $key, $key_prepared );
168
+ }
169
+ }
wp-structuring-admin-list.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Schema.org Admin List
4
+ *
5
+ * @author Kazuya Takami
6
+ * @version 1.0.0
7
+ * @since 1.0.0
8
+ * @see wp-structuring-admin-db.php
9
+ */
10
+ class Structuring_Markup_Admin_List {
11
+ /** Schema.org Type defined. */
12
+ private $type_array = array(
13
+ "website" => "Web Site",
14
+ "organization" => "Organization",
15
+ "news_article" => "News Article"
16
+ );
17
+
18
+ /**
19
+ * Constructor Define.
20
+ *
21
+ * @since 1.0.0
22
+ */
23
+ function __construct() {
24
+ $db = new Structuring_Markup_Admin_Db();
25
+ $mode = "";
26
+
27
+ if ( isset( $_GET['mode'] ) && $_GET['mode'] === 'delete' ) {
28
+ if ( isset( $_GET['schema_post_id'] ) && is_numeric( $_GET['schema_post_id'] ) ) {
29
+ $db->delete_options( $_GET['schema_post_id'] );
30
+ $mode = "delete";
31
+ }
32
+ }
33
+
34
+ $this->page_render( $db, $mode );
35
+ }
36
+
37
+ /**
38
+ * LIST Page HTML Render.
39
+ *
40
+ * @since 1.0.0
41
+ * @param Structuring_Markup_Admin_Db $db
42
+ * @param String $mode
43
+ */
44
+ private function page_render( Structuring_Markup_Admin_Db $db, $mode = "" ) {
45
+ $post_url = "admin.php?page=wp-structuring-admin-post.php";
46
+ $self_url = $_SERVER['PHP_SELF'] . '?' . esc_html( $_SERVER['QUERY_STRING'] );
47
+
48
+ $html = '';
49
+ $html .= '<div class="wrap">';
50
+ $html .= '<h1>Schema.org Setting List';
51
+ $html .= '<a href="' . $post_url . '" class="page-title-action">新規追加</a>';
52
+ $html .= '</h1>';
53
+ echo $html;
54
+
55
+ if ( $mode === "delete" ) {
56
+ $this->information_render();
57
+ }
58
+
59
+ $html = '<hr>';
60
+ $html .= '<table class="wp-list-table widefat fixed striped posts">';
61
+ $html .= '<tr>';
62
+ $html .= '<th scope="row">Schema&nbsp;Type</th>';
63
+ $html .= '<th scope="row">Output&nbsp;Page</th>';
64
+ $html .= '<th scope="row">Register&nbsp;Date</th>';
65
+ $html .= '<th scope="row">Update&nbsp;Date</th>';
66
+ $html .= '<th scope="row">&nbsp;</th>';
67
+ $html .= '</tr>';
68
+ echo $html;
69
+
70
+ $results = $db->get_list_options();
71
+
72
+ if ( $results ) {
73
+ foreach ( $results as $row ) {
74
+ $html = '';
75
+ $html .= '<tr>';
76
+ $html .= '<td>';
77
+ $html .= '<a href="' . $post_url . '&mode=edit&schema_post_id=' . esc_html( $row->id ) . '">' . $this->type_array[esc_html( $row->type )] . '</a>';
78
+ $html .= '</td>';
79
+ $html .= '<td>' . $this->unserialize_output( $row->output ) . '</td>';
80
+ $html .= '<td>' . esc_html( $row->register_date ) . '</td>';
81
+ $html .= '<td>' . esc_html( $row->update_date ) . '</td>';
82
+ $html .= '<td>';
83
+ $html .= '<a href="' . $post_url . '&mode=edit&schema_post_id=' . esc_html( $row->id ) . '">Edit</a>&nbsp;&nbsp;';
84
+ $html .= '<a href="' . $self_url . '&mode=delete&schema_post_id=' . esc_html( $row->id ) . '">Delete</a>';
85
+ $html .= '</td>';
86
+ $html .= '</tr>';
87
+ echo $html;
88
+ }
89
+ } else {
90
+ echo '<td colspan="3">NOT FOUND</td>';
91
+ }
92
+
93
+ $html = '</table>';
94
+ $html .= '</div>';
95
+ echo $html;
96
+ }
97
+
98
+ /**
99
+ * LIST Page HTML Render.
100
+ *
101
+ * @since 1.0.0
102
+ * @param object $obj
103
+ * @return string
104
+ */
105
+ private function unserialize_output( $obj ) {
106
+ $args = unserialize( $obj );
107
+ return (string) implode( ",", $args );
108
+ }
109
+
110
+
111
+ /**
112
+ * Information Message Render
113
+ *
114
+ * @since 1.0.0
115
+ */
116
+ private function information_render() {
117
+ $html = '<div id="message" class="updated notice notice-success is-dismissible below-h2">';
118
+ $html .= '<p>Deletion succeeds.</p>';
119
+ $html .= '<button type="button" class="notice-dismiss">';
120
+ $html .= '<span class="screen-reader-text">Dismiss this notice.</span>';
121
+ $html .= '</button>';
122
+ $html .= '</div>';
123
+
124
+ echo $html;
125
+ }
126
+ }
wp-structuring-admin-post.php ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Schema.org Admin Post
4
+ *
5
+ * @author Kazuya Takami
6
+ * @version 1.0.0
7
+ * @since 1.0.0
8
+ */
9
+ class Structuring_Markup_Admin_Post {
10
+
11
+ /** Schema.org Type defined. */
12
+ private $type_array = array(
13
+ array("type" => "website", "display" => "Web Site"),
14
+ array("type" => "organization", "display" => "Organization"),
15
+ array("type" => "news_article", "display" => "News Article")
16
+ );
17
+
18
+ /**
19
+ * Constructor Define.
20
+ *
21
+ * @since 1.0.0
22
+ */
23
+ public function __construct() {
24
+ /**
25
+ * Input Mode
26
+ *
27
+ * "" : Input Start
28
+ * "edit" : Edit Mode
29
+ */
30
+ $mode = isset( $_GET['mode'] ) ? esc_html( $_GET['mode'] ) : "";
31
+
32
+ /**
33
+ * Update Status
34
+ *
35
+ * "ok" : Successful update
36
+ * "output" : Output No Check
37
+ */
38
+ $status = "";
39
+
40
+ /** DB Connect */
41
+ $db = new Structuring_Markup_Admin_Db();
42
+
43
+ /** Set Default Parameter for Array */
44
+ $options = array(
45
+ "id" => "",
46
+ "type" => "website",
47
+ "output" => array(),
48
+ "option" => array()
49
+ );
50
+
51
+ /** Key Set */
52
+ if ( isset( $_GET['schema_post_id'] ) && is_numeric( $_GET['schema_post_id'] ) ) {
53
+ $options['id'] = esc_html( $_GET['schema_post_id'] );
54
+ }
55
+
56
+ /** Type Set */
57
+ if ( isset( $_GET['type'] ) ) {
58
+ foreach ( $this->type_array as $value ) {
59
+ if ( $_GET['type'] === $value['type'] ) {
60
+ $options['type'] = esc_html( $_GET['type'] );
61
+ break;
62
+ }
63
+ }
64
+ }
65
+
66
+ /** DataBase Update & Insert Mode */
67
+ if ( isset( $_POST['id'] ) && is_numeric( $_POST['id'] ) ) {
68
+ if ( isset( $_POST['output'] ) ) {
69
+ $db->update_options( $_POST );
70
+ $options['id'] = $_POST['id'];
71
+ $status = "ok";
72
+ } else {
73
+ $status = "output";
74
+ }
75
+ } else {
76
+ if ( isset( $_POST['id'] ) && $_POST['id'] === '' ) {
77
+ if ( isset( $_POST['output'] ) ) {
78
+ $options['id'] = $db->insert_options( $_POST );
79
+ $status = "ok";
80
+ $mode = "edit";
81
+ } else {
82
+ $status = "output";
83
+ }
84
+ }
85
+ }
86
+
87
+ /** Mode Judgment */
88
+ if ( isset( $options['id'] ) && is_numeric( $options['id'] ) ) {
89
+ $options = $db->get_options( $options['id'] );
90
+ }
91
+
92
+ $this->page_render( $options, $mode, $status );
93
+ }
94
+
95
+ /**
96
+ * Setting Page of the Admin Screen.
97
+ *
98
+ * @since 1.0.0
99
+ * @param array $options
100
+ * @param string $mode
101
+ * @param string $status
102
+ */
103
+ private function page_render( array $options, $mode, $status ) {
104
+ $html = '';
105
+ $html .= '<link rel="stylesheet" href="' . plugin_dir_url( __FILE__ ) . 'css/style.css">';
106
+ $html .= '<div class="wrap">';
107
+ $html .= '<h1>Schema.org Post</h1>';
108
+ echo $html;
109
+
110
+ switch ( $status ) {
111
+ case "ok":
112
+ $this->information_render();
113
+ break;
114
+ case "output":
115
+ $this->output_error_render();
116
+ break;
117
+ default:
118
+ break;
119
+ }
120
+
121
+ $html = '<hr>';
122
+ $html .= '<form method="get" action="">';
123
+ $html .= '<input type="hidden" name="page" value="wp-structuring-admin-post.php">';
124
+ $html .= '<table class="schema-admin-table">';
125
+ $html .= '<tr><th><label for="type">Schema Type :</label></th><td>';
126
+ $html .= '<select id="type" name="type" onchange="this.form.submit();">';
127
+ foreach ( $this->type_array as $value ) {
128
+ $html .= '<option value="' . $value['type'] . '"';
129
+ if ( $value['type'] === $options['type'] ) {
130
+ $html .= ' selected';
131
+ } else {
132
+ if ( $mode === "edit" ) {
133
+ $html .= ' disabled';
134
+ }
135
+ }
136
+ $html .= '>' . $value['display'] . '</option>';
137
+ }
138
+ $html .= '</select>';
139
+ $html .= '</td></tr></table>';
140
+ $html .= '</form>';
141
+ echo $html;
142
+
143
+ /** Output Page Select */
144
+ $html = '<form method="post" action="">';
145
+ $html .= '<input type="hidden" name="id" value="' . esc_attr( $options['id'] ) . '">';
146
+ $html .= '<input type="hidden" name="type" value="' . esc_attr( $options['type'] ) . '">';
147
+ $html .= '<table class="schema-admin-table">';
148
+ $html .= '<tr><th>Output :</th><td>';
149
+ echo $html;
150
+
151
+ switch ( $options['type'] ) {
152
+ case 'website':
153
+ $this->output_checkbox_render( $options['output'], "all", "All", "All Page" );
154
+ $this->output_checkbox_render( $options['output'], "home", "Top", "Top Page" );
155
+ $this->output_checkbox_render( $options['output'], "post", "Post", "Post Page" );
156
+ $this->output_checkbox_render( $options['output'], "page", "Fixed", "Fixed Page" );
157
+ $html = '</td></tr></table><hr>';
158
+ echo $html;
159
+
160
+ require_once( 'wp-structuring-admin-type-website.php' );
161
+ new Structuring_Markup_Type_Website( $options['option'] );
162
+ break;
163
+ case 'organization':
164
+ $this->output_checkbox_render( $options['output'], "all", "All", "All Page" );
165
+ $this->output_checkbox_render( $options['output'], "home", "Top", "Top Page" );
166
+ $this->output_checkbox_render( $options['output'], "post", "Post", "Post Page" );
167
+ $this->output_checkbox_render( $options['output'], "page", "Fixed", "Fixed Page" );
168
+ $html = '</td></tr></table><hr>';
169
+ echo $html;
170
+
171
+ require_once ( 'wp-structuring-admin-type-organization.php' );
172
+ new Structuring_Markup_Type_Organization( $options['option'] );
173
+ break;
174
+ case 'news_article':
175
+ $this->output_checkbox_render( $options['output'], "post", "Post", "Post Page" );
176
+ $html = '</td></tr></table><hr>';
177
+ echo $html;
178
+
179
+ require_once ( 'wp-structuring-admin-type-news-article.php' );
180
+ new Structuring_Markup_Type_NewsArticle();
181
+ break;
182
+ }
183
+
184
+ $html = '</form>';
185
+ $html .= '</div>';
186
+ echo $html;
187
+ }
188
+
189
+ /**
190
+ * CheckBox Build Render
191
+ *
192
+ * @since 1.0.0
193
+ * @param array $option['output']
194
+ * @param string $output
195
+ * @param string $value
196
+ * @param string $display
197
+ * @return string $html
198
+ */
199
+ private function output_checkbox_render( array $option, $output, $value, $display ) {
200
+ $html = '<label>';
201
+ $html .= '<input type="checkbox" name="output[' . $output . ']" value="' . $value . '""';
202
+
203
+ if ( isset( $option[$output] ) ) {
204
+ $html .= ' checked';
205
+ }
206
+ $html .= '>' . $display . '</label>';
207
+
208
+ echo $html;
209
+ }
210
+
211
+ /**
212
+ * Information Message Render
213
+ *
214
+ * @since 1.0.0
215
+ */
216
+ private function information_render() {
217
+ $html = '<div id="message" class="updated notice notice-success is-dismissible below-h2">';
218
+ $html .= '<p>Schema.org Information Update.</p>';
219
+ $html .= '<button type="button" class="notice-dismiss">';
220
+ $html .= '<span class="screen-reader-text">Dismiss this notice.</span>';
221
+ $html .= '</button>';
222
+ $html .= '</div>';
223
+
224
+ echo $html;
225
+ }
226
+
227
+ /**
228
+ * Error Message Render
229
+ *
230
+ * @since 1.0.0
231
+ */
232
+ private function output_error_render() {
233
+ $html = '<div id="notice" class="notice notice-error is-dismissible below-h2">';
234
+ $html .= '<p>Output No Select.</p>';
235
+ $html .= '<button type="button" class="notice-dismiss">';
236
+ $html .= '<span class="screen-reader-text">Dismiss this notice.</span>';
237
+ $html .= '</button>';
238
+ $html .= '</div>';
239
+
240
+ echo $html;
241
+ }
242
+ }
wp-structuring-admin-type-news-article.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Schema.org Type News Article
4
+ *
5
+ * @author Kazuya Takami
6
+ * @version 1.0.0
7
+ * @since 1.0.0
8
+ * @see wp-structuring-admin-db.php
9
+ * @link http://schema.org/NewsArticle
10
+ * @link https://developers.google.com/structured-data/rich-snippets/articles
11
+ */
12
+ class Structuring_Markup_Type_NewsArticle {
13
+
14
+ /**
15
+ * Constructor Define.
16
+ *
17
+ * @since 1.0.0
18
+ */
19
+ public function __construct()
20
+ {
21
+ $this->page_render();
22
+ }
23
+
24
+ /**
25
+ * Form Layout Render
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>';
34
+ $html .= '<tr><th>datePublished :</th><td><small>Default : get_the_time( DATE_ISO8601, ID )</small></td></tr>';
35
+ $html .= '<tr><th>image :</th><td><small>Default : thumbnail</small></td></tr>';
36
+ $html .= '<tr><th>description :</th><td><small>Default : post_excerpt</small></td></tr>';
37
+ $html .= '<tr><th>articleBody :</th><td><small>Default : post_content</small></td></tr>';
38
+ $html .= '</table>';
39
+ echo $html;
40
+
41
+ echo '<p>Setting Knowledge : <a href="https://developers.google.com/structured-data/rich-snippets/articles" target="_blank">https://developers.google.com/structured-data/rich-snippets/articles</a></p>';
42
+ submit_button();
43
+ }
44
+ }
wp-structuring-admin-type-organization.php ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Schema.org Type Organization
4
+ *
5
+ * @author Kazuya Takami
6
+ * @version 1.0.0
7
+ * @since 1.0.0
8
+ * @see wp-structuring-admin-db.php
9
+ * @link https://schema.org/Organization
10
+ * @link https://developers.google.com/structured-data/customize/overview
11
+ * @link https://developers.google.com/structured-data/customize/logos
12
+ * @link https://developers.google.com/structured-data/customize/contact-points
13
+ * @link https://developers.google.com/structured-data/customize/social-profiles
14
+ */
15
+ class Structuring_Markup_Type_Organization {
16
+
17
+ /** contactType defined. */
18
+ private $contact_type_array = array(
19
+ array("type" => "customer_support", "display" => "customer support"),
20
+ array("type" => "technical_support", "display" => "technical support"),
21
+ array("type" => "billing_support", "display" => "billing support"),
22
+ array("type" => "bill_payment", "display" => "bill payment"),
23
+ array("type" => "sales", "display" => "sales"),
24
+ array("type" => "reservations", "display" => "reservations"),
25
+ array("type" => "credit_card_support", "display" => "credit card support"),
26
+ array("type" => "emergency", "display" => "emergency"),
27
+ array("type" => "baggage_tracking", "display" => "baggage tracking"),
28
+ array("type" => "roadside_assistance", "display" => "roadside assistance"),
29
+ array("type" => "package_tracking", "display" => "package tracking")
30
+ );
31
+ /** Social Profile */
32
+ private $social_array = array(
33
+ array("type" => "facebook", "display" => "Facebook"),
34
+ array("type" => "twitter", "display" => "Twitter"),
35
+ array("type" => "google", "display" => "Google+"),
36
+ array("type" => "instagram", "display" => "Instagram"),
37
+ array("type" => "youtube", "display" => "Youtube"),
38
+ array("type" => "linkedin", "display" => "LinkedIn"),
39
+ array("type" => "myspace", "display" => "Myspace"),
40
+ array("type" => "pinterest", "display" => "Pinterest"),
41
+ array("type" => "soundcloud", "display" => "SoundCloud"),
42
+ array("type" => "tumblr", "display" => "Tumblr")
43
+ );
44
+
45
+ /**
46
+ * Constructor Define.
47
+ *
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 );
56
+ }
57
+ $this->page_render( $option );
58
+ }
59
+
60
+ /**
61
+ * Form Layout Render
62
+ *
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>';
71
+ $html .= '<tr><th><label for="name">Organization Name :</label></th><td>';
72
+ $html .= '<input type="text" name="option[' . "name" . ']" id="name" class="regular-text" required value="' . esc_attr( $option['name'] ) . '">';
73
+ $html .= '<small>Default : bloginfo("name")</small>';
74
+ $html .= '</td></tr>';
75
+ $html .= '<tr><th><label for="url">url :</label></th><td>';
76
+ $html .= '<input type="text" name="option[' . "url" . ']" id="url" class="regular-text" required value="' . esc_attr( $option['url'] ) . '">';
77
+ $html .= '<small>Default : bloginfo("url")</small>';
78
+ $html .= '</td></tr>';
79
+ $html .= '<tr><th><label for="logo">logo :</label></th><td>';
80
+ $html .= '<input type="text" name="option[' . "logo" . ']" id="logo" class="regular-text" required value="' . esc_attr( $option['logo'] ) . '">';
81
+ $html .= '<small>Default : bloginfo("logo") + "/images/logo.png"</small>';
82
+ $html .= '</td></tr>';
83
+ $html .= '</table>';
84
+ echo $html;
85
+
86
+ /** Corporate Contact */
87
+ $html = '<table class="schema-admin-table">';
88
+ $html .= '<caption>Corporate Contact</caption>';
89
+ $html .= '<tr><th><label for="contact_point">contactPoint :</label></th><td>';
90
+ $html .= '<input type="checkbox" name="option[' . "contact_point" . ']" id="contact_point" value="on"';
91
+ if ( isset( $option['contact_point'] ) && $option['contact_point'] === 'on' ) {
92
+ $html .= ' checked="checked"';
93
+ }
94
+ $html .= '>Active';
95
+ $html .= '</td></tr>';
96
+ $html .= '<tr><th><label for="telephone">telephone :</label></th><td>';
97
+ $html .= '<input type="text" name="option[' . "telephone" . ']" id="telephone" class="regular-text" value="' . esc_attr( $option['telephone'] ) . '">';
98
+ $html .= '<small>Default : +1-880-555-1212</small>';
99
+ $html .= '</td></tr>';
100
+ $html .= '<tr><th><label for="contact_type">contactType :</label></th><td>';
101
+ $html .= '<select id="contact_type" name="option[' . "contact_type" . ']">';
102
+ foreach ( $this->contact_type_array as $value ) {
103
+ $html .= '<option value="' . $value['type'] . '"';
104
+ if ( $value['type'] === $option['contact_type'] ) {
105
+ $html .= ' selected';
106
+ }
107
+ $html .= '>' . $value['display'] . '</option>';
108
+ }
109
+ $html .= '</select>';
110
+ $html .= '<small>Default : "customer support"</small>';
111
+ $html .= '</td></tr>';
112
+ $html .= '<tr><th><label for="area_served">areaServed :</label></th><td>';
113
+ $html .= '<input type="text" name="option[' . "area_served" . ']" id="area_served" class="regular-text" value="' . esc_attr( $option['area_served'] ) . '">';
114
+ $html .= '<small>Default : "US"&nbsp;&nbsp;Multiple : "US,CA"</small>';
115
+ $html .= '</td></tr>';
116
+ $html .= '<tr><th>contactOption :</th><td>';
117
+ $html .= '<label><input type="checkbox" name="option[' . "contact_point_1" . ']" id="contact_point_1" value="on"';
118
+ if ( isset( $option['contact_point_1'] ) && $option['contact_point_1'] === 'on' ) {
119
+ $html .= ' checked="checked"';
120
+ }
121
+ $html .= '>HearingImpairedSupported</label><br>';
122
+ $html .= '<label><input type="checkbox" name="option[' . "contact_point_2" . ']" id="contact_point_2" value="on"';
123
+ if ( isset( $option['contact_point_2'] ) && $option['contact_point_2'] === 'on' ) {
124
+ $html .= ' checked="checked"';
125
+ }
126
+ $html .= '>TollFree</label><br>';
127
+ $html .= '</td></tr>';
128
+ $html .= '<tr><th><label for="available_language">available<br>Language :</label></th><td>';
129
+ $html .= '<input type="text" name="option[' . "available_language" . ']" id="available_language" class="regular-text" value="' . esc_attr( $option['available_language'] ) . '">';
130
+ $html .= '<small>Default : "English"&nbsp;&nbsp;Multiple : "French,English"</small>';
131
+ $html .= '</td></tr>';
132
+ $html .= '</table>';
133
+ echo $html;
134
+
135
+ /** Social Profiles */
136
+ $html = '<table class="schema-admin-table">';
137
+ $html .= '<caption>Social Profiles</caption>';
138
+ foreach ( $this->social_array as $value ) {
139
+ $html .= '<tr><th><label for="' . $value['type'] . '">' . $value['display'] . ' :</label></th><td>';
140
+ $html .= '<input type="text" name="option[' . "social" . '][' . $value['type'] . ']" id="' . $value['type'] . '" class="regular-text" value="' . esc_attr( $option['social'][$value['type']] ) . '">';
141
+ $html .= '</td></tr>';
142
+ }
143
+ $html .= '</table>';
144
+ echo $html;
145
+
146
+ echo '<p>Setting Knowledge : <a href="https://developers.google.com/structured-data/customize/overview" target="_blank">https://developers.google.com/structured-data/customize/overview</a></p>';
147
+ submit_button();
148
+ }
149
+
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';
162
+ $args['contact_point'] = '';
163
+ $args['telephone'] = '+1-880-555-1212';
164
+ $args['contact_type'] = 'customer_support';
165
+ $args['area_served'] = 'US';
166
+ $args['contact_option_1'] = '';
167
+ $args['contact_option_2'] = '';
168
+ $args['available_language'] = 'English';
169
+
170
+ foreach ( $this->social_array as $value ) {
171
+ $args['social'][$value['type']] = '';
172
+ }
173
+
174
+ return (array) $args;
175
+ }
176
+ }
wp-structuring-admin-type-website.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Schema.org Type WebSite
4
+ *
5
+ * @author Kazuya Takami
6
+ * @version 1.0.0
7
+ * @since 1.0.0
8
+ * @see wp-structuring-admin-db.php
9
+ * @link https://schema.org/WebSite
10
+ * @link https://developers.google.com/structured-data/slsb-overview
11
+ * @link https://developers.google.com/structured-data/site-name
12
+ */
13
+ class Structuring_Markup_Type_Website {
14
+
15
+ /**
16
+ * Constructor Define.
17
+ *
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 );
26
+ }
27
+ $this->page_render( $option );
28
+ }
29
+
30
+ /**
31
+ * Form Layout Render
32
+ *
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>';
41
+ $html .= '<input type="text" name="option[' . "name" . ']" id="name" class="regular-text" required value="' . esc_attr( $option['name'] ) . '">';
42
+ $html .= '<small>Default : bloginfo("name")</small>';
43
+ $html .= '</td></tr>';
44
+ $html .= '<tr><th><label for="alternateName">alternateName :</label></th><td>';
45
+ $html .= '<input type="text" name="option[' . "alternateName" . ']" id="alternateName" class="regular-text" value="' . esc_attr( $option['alternateName'] ) . '">';
46
+ $html .= '<small>Default : bloginfo("name")</small>';
47
+ $html .= '</td></tr>';
48
+ $html .= '<tr><th><label for="url">url :</label></th><td>';
49
+ $html .= '<input type="text" name="option[' . "url" . ']" id="url" class="regular-text" required value="' . esc_attr( $option['url'] ) . '">';
50
+ $html .= '<small>Default : bloginfo("url")</small>';
51
+ $html .= '</td></tr>';
52
+ $html .= '</table>';
53
+ echo $html;
54
+
55
+ $html = '<table class="schema-admin-table">';
56
+ $html .= '<caption>Sitelink Search Box</caption>';
57
+ $html .= '<tr><th><label for="potential_action">potentialAction Active :</label></th><td>';
58
+ $html .= '<input type="checkbox" name="option[' . "potential_action" . ']" id="potential_action" value="on"';
59
+ if ( isset( $option['potential_action'] ) && $option['potential_action'] === 'on' ) {
60
+ $html .= ' checked="checked"';
61
+ }
62
+ $html .= '>Active';
63
+ $html .= '</td></tr>';
64
+ $html .= '<tr><th><label for="target">target :</label></th><td>';
65
+ $html .= '<input type="text" name="option[' . "target" . ']" id="target" class="regular-text" value="' . esc_attr( $option['target'] ) . '">';
66
+ $html .= '<small>Default : bloginfo("url") + /?s=</small>';
67
+ $html .= '</td></tr>';
68
+ $html .= '</table>';
69
+ echo $html;
70
+
71
+ 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>';
72
+ submit_button();
73
+ }
74
+
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');
87
+ $args['potential_action'] = '';
88
+ $args['target'] = $args['url'] . '/?s=';
89
+
90
+ return (array) $args;
91
+ }
92
+ }
wp-structuring-display.php ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Schema.org Display
4
+ *
5
+ * @author Kazuya Takami
6
+ * @version 1.0.0
7
+ * @since 1.0.0
8
+ */
9
+ class Structuring_Markup_Display {
10
+
11
+ /**
12
+ * Constructor Define.
13
+ *
14
+ * @since 1.0.0
15
+ */
16
+ public function __construct() {
17
+ $db = new Structuring_Markup_Admin_Db();
18
+ $this->set_schema( $db );
19
+ }
20
+
21
+ /**
22
+ * Setting schema.org
23
+ *
24
+ * @since 1.0.0
25
+ * @param Structuring_Markup_Admin_Db $db
26
+ */
27
+ private function set_schema( Structuring_Markup_Admin_Db $db ) {
28
+ $this->get_schema_data( $db, 'all' );
29
+ if ( is_home() ) {
30
+ $this->get_schema_data( $db, 'home' );
31
+ }
32
+ if ( is_single() ) {
33
+ $this->get_schema_data( $db, 'post' );
34
+ }
35
+ if ( is_page() ) {
36
+ $this->get_schema_data( $db, 'page' );
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Setting JSON-LD Template
42
+ *
43
+ * @since 1.0.0
44
+ * @param string $output
45
+ * @param Structuring_Markup_Admin_Db $db
46
+ */
47
+ private function get_schema_data( Structuring_Markup_Admin_Db $db, $output ) {
48
+ $results = $db->get_select_options( $output );
49
+
50
+ if ( isset( $results ) ) {
51
+ foreach ( $results as $row ) {
52
+ if ( isset( $row->type ) ) {
53
+ switch ( $row->type ) {
54
+ case 'website':
55
+ if ( isset( $row->options ) ) {
56
+ $this->set_schema_website( unserialize( $row->options ) );
57
+ }
58
+ break;
59
+ case 'organization':
60
+ if ( isset( $row->options ) ) {
61
+ $this->set_schema_organization( unserialize( $row->options ) );
62
+ }
63
+ break;
64
+ case 'news_article':
65
+ if ( isset( $row->options ) ) {
66
+ $this->set_schema_news_article( unserialize( $row->options ) );
67
+ }
68
+ break;
69
+ }
70
+ }
71
+ }
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Setting JSON-LD Template
77
+ *
78
+ * @since 1.0.0
79
+ * @param array $args
80
+ */
81
+ private function set_schema_json( array $args ) {
82
+ echo '<script type="application/ld+json">' , PHP_EOL;
83
+ echo json_encode( $args, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT ) , PHP_EOL;
84
+ echo '</script>' , PHP_EOL;
85
+ }
86
+
87
+ /**
88
+ * Setting schema.org WebSite
89
+ *
90
+ * @since 1.0.0
91
+ * @param array $options
92
+ */
93
+ private function set_schema_website( array $options ) {
94
+ $args = array(
95
+ "@context" => "http://schema.org",
96
+ "@type" => "WebSite",
97
+ "name" => isset( $options['name'] ) ? esc_html( $options['name'] ) : "",
98
+ "alternateName" => isset( $options['alternateName'] ) ? esc_html( $options['alternateName'] ) : "",
99
+ "url" => isset( $options['url'] ) ? esc_html( $options['url'] ) : ""
100
+ );
101
+
102
+ if ( isset( $options['potential_action'] ) && $options['potential_action'] === 'on' ) {
103
+ $potential_action["potentialAction"] = array(
104
+ "@type" => "SearchAction",
105
+ "target" => isset( $options['target'] ) ? esc_html( $options['target'] ) . "{search_term_string}" : "",
106
+ "query-input" => isset( $options['target'] ) ? "required name=search_term_string" : ""
107
+ );
108
+ $args = array_merge( $args, $potential_action );
109
+ }
110
+
111
+ $this->set_schema_json( $args );
112
+ }
113
+
114
+ /**
115
+ * Setting schema.org Organization
116
+ *
117
+ * @since 1.0.0
118
+ * @param array $options
119
+ */
120
+ private function set_schema_organization( array $options ) {
121
+ /** Logos */
122
+ $args = array(
123
+ "@context" => "http://schema.org",
124
+ "@type" => "Organization",
125
+ "name" => isset( $options['name'] ) ? esc_html( $options['name'] ) : "",
126
+ "url" => isset( $options['url'] ) ? esc_html( $options['url'] ) : "",
127
+ "logo" => isset( $options['logo'] ) ? esc_html( $options['logo'] ) : ""
128
+ );
129
+
130
+ /** Corporate Contact */
131
+ if ( isset( $options['contact_point'] ) && $options['contact_point'] === 'on' ) {
132
+ $contact_point["contactPoint"] = array(
133
+ array(
134
+ "@type" => "ContactPoint",
135
+ "telephone" => isset( $options['telephone'] ) ? esc_html( $options['telephone'] ) : "",
136
+ "contactType" => isset( $options['contact_type'] ) ? esc_html( $options['contact_type'] ) : ""
137
+ )
138
+ );
139
+ $args = array_merge( $args, $contact_point );
140
+ }
141
+
142
+ /** Social Profiles */
143
+ if ( isset( $options['social'] ) ) {
144
+ $socials["sameAs"] = array();
145
+
146
+ foreach ( $options['social'] as $value ) {
147
+ if ( !empty( $value ) ) {
148
+ $socials["sameAs"][] = ( esc_html( $value ) );
149
+ }
150
+ }
151
+ $args = array_merge( $args, $socials );
152
+ }
153
+ $this->set_schema_json( $args );
154
+ }
155
+
156
+ /**
157
+ * Setting schema.org NewsArticle
158
+ *
159
+ * @since 1.0.0
160
+ */
161
+ private function set_schema_news_article() {
162
+ global $post;
163
+ if ( has_post_thumbnail( $post->ID ) ) {
164
+ $args = array(
165
+ "@context" => "http://schema.org",
166
+ "@type" => "NewsArticle",
167
+ "headline" => esc_html( $post->post_title ),
168
+ "datePublished" => get_the_time( DATE_ISO8601, $post->ID ),
169
+ "image" => array( esc_html( wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "full" )[0] ) ),
170
+ "description" => esc_html( $post->post_excerpt ),
171
+ "articleBody" => esc_html( $post->post_content )
172
+ );
173
+ $this->set_schema_json( $args );
174
+ }
175
+ }
176
+ }
wp-structuring-markup.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Markup (JSON-LD) structured in schema.org
4
+ Plugin URI: https://github.com/miiitaka/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.0.0
7
+ Author: Kazuya Takami
8
+ Author URI: http://programp.com/
9
+ License: GPLv2 or later
10
+ Text Domain: wp-structuring-markup
11
+ */
12
+ require_once( 'wp-structuring-admin-db.php' );
13
+
14
+ new Structuring_Markup();
15
+
16
+ /**
17
+ * Schema.org Basic Class
18
+ *
19
+ * @author Kazuya Takami
20
+ * @version 1.0.0
21
+ * @since 1.0.0
22
+ */
23
+ class Structuring_Markup {
24
+
25
+ /**
26
+ * Constructor Define.
27
+ *
28
+ * @since 1.0.0
29
+ */
30
+ function __construct() {
31
+ $db = new Structuring_Markup_Admin_Db();
32
+ $db->create_table();
33
+
34
+ if ( is_admin() ) {
35
+ add_action( 'admin_menu', array( $this, 'set_menu' ) );
36
+ } else {
37
+ add_action( 'wp_head', array( $this, 'display_page_render' ) );
38
+ }
39
+ }
40
+
41
+ /**
42
+ * Add Menu to the Admin Screen.
43
+ *
44
+ * @since 1.0.0
45
+ */
46
+ public function set_menu() {
47
+ add_menu_page(
48
+ 'Scheme.org Setting',
49
+ 'Scheme.org Setting',
50
+ 'manage_options',
51
+ plugin_basename( __FILE__ ),
52
+ array($this, 'list_page_render')
53
+ );
54
+ add_submenu_page(
55
+ __FILE__,
56
+ 'Setting All',
57
+ 'Setting All',
58
+ 'manage_options',
59
+ plugin_basename( __FILE__ ),
60
+ array($this, 'list_page_render')
61
+ );
62
+ add_submenu_page(
63
+ __FILE__,
64
+ 'Scheme.org Setting Post',
65
+ 'Add New',
66
+ 'manage_options',
67
+ 'wp-structuring-admin-post.php',
68
+ array($this, 'post_page_render')
69
+ );
70
+ }
71
+
72
+ /**
73
+ * LIST Page Template Require.
74
+ *
75
+ * @since 1.0.0
76
+ */
77
+ public function list_page_render() {
78
+ require_once( 'wp-structuring-admin-list.php' );
79
+ new Structuring_Markup_Admin_List();
80
+ }
81
+
82
+ /**
83
+ * POST Page Template Require.
84
+ *
85
+ * @since 1.0.0
86
+ */
87
+ public function post_page_render() {
88
+ require_once( 'wp-structuring-admin-post.php' );
89
+ new Structuring_Markup_Admin_Post();
90
+ }
91
+
92
+ /**
93
+ * Display Page Template Require.
94
+ *
95
+ * @since 1.0.0
96
+ */
97
+ public function display_page_render() {
98
+ require_once( 'wp-structuring-display.php' );
99
+ new Structuring_Markup_Display();
100
+ }
101
+ }