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

Version Description

Download this release

Release Info

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

Code changes from version 1.0.1 to 1.0.2

readme.txt CHANGED
@@ -1,9 +1,9 @@
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
 
@@ -21,6 +21,9 @@ Base knowledge is "https://developers.google.com/structured-data/"
21
 
22
  == Changelog ==
23
 
 
 
 
24
  = 1.0.0 =
25
  * The first release.
26
 
1
  === Markup (JSON-LD) structured in schema.org ===
2
  Contributors: miiitaka
3
+ Tags: schema, json, seo, posts
4
  Requires at least: 4.3.1
5
  Tested up to: 4.3.1
6
+ Stable tag: 1.0.1
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
 
21
 
22
  == Changelog ==
23
 
24
+ = 1.0.1 =
25
+ * Bug Fix.
26
+
27
  = 1.0.0 =
28
  * The first release.
29
 
trunk/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
+ }
trunk/readme.txt ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Markup (JSON-LD) structured in schema.org ===
2
+ Contributors: miiitaka
3
+ Tags: schema, json, seo, posts
4
+ Requires at least: 4.3.1
5
+ Tested up to: 4.3.1
6
+ Stable tag: 1.0.2
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.2 =
25
+ * Bug Fix.
26
+
27
+ = 1.0.1 =
28
+ * Bug Fix.
29
+
30
+ = 1.0.0 =
31
+ * The first release.
32
+
33
+ == Contact ==
34
+
35
+ email to foundationmeister[at]outlook.com
36
+ twitter @miiitaka
trunk/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
+ }
trunk/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
+ }
trunk/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
+ }
trunk/wp-structuring-admin-post.php ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ define( 'WP_STRUCTURING_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
3
+
4
+ /**
5
+ * Schema.org Admin Post
6
+ *
7
+ * @author Kazuya Takami
8
+ * @version 1.0.0
9
+ * @since 1.0.0
10
+ */
11
+ class Structuring_Markup_Admin_Post {
12
+
13
+ /** Schema.org Type defined. */
14
+ private $type_array = array(
15
+ array("type" => "website", "display" => "Web Site"),
16
+ array("type" => "organization", "display" => "Organization"),
17
+ array("type" => "news_article", "display" => "News Article")
18
+ );
19
+
20
+ /**
21
+ * Constructor Define.
22
+ *
23
+ * @since 1.0.0
24
+ */
25
+ public function __construct() {
26
+ /**
27
+ * Input Mode
28
+ *
29
+ * "" : Input Start
30
+ * "edit" : Edit Mode
31
+ */
32
+ $mode = isset( $_GET['mode'] ) ? esc_html( $_GET['mode'] ) : "";
33
+
34
+ /**
35
+ * Update Status
36
+ *
37
+ * "ok" : Successful update
38
+ * "output" : Output No Check
39
+ */
40
+ $status = "";
41
+
42
+ /** DB Connect */
43
+ $db = new Structuring_Markup_Admin_Db();
44
+
45
+ /** Set Default Parameter for Array */
46
+ $options = array(
47
+ "id" => "",
48
+ "type" => "website",
49
+ "output" => array(),
50
+ "option" => array()
51
+ );
52
+
53
+ /** Key Set */
54
+ if ( isset( $_GET['schema_post_id'] ) && is_numeric( $_GET['schema_post_id'] ) ) {
55
+ $options['id'] = esc_html( $_GET['schema_post_id'] );
56
+ }
57
+
58
+ /** Type Set */
59
+ if ( isset( $_GET['type'] ) ) {
60
+ foreach ( $this->type_array as $value ) {
61
+ if ( $_GET['type'] === $value['type'] ) {
62
+ $options['type'] = esc_html( $_GET['type'] );
63
+ break;
64
+ }
65
+ }
66
+ }
67
+
68
+ /** DataBase Update & Insert Mode */
69
+ if ( isset( $_POST['id'] ) && is_numeric( $_POST['id'] ) ) {
70
+ if ( isset( $_POST['output'] ) ) {
71
+ $db->update_options( $_POST );
72
+ $options['id'] = $_POST['id'];
73
+ $status = "ok";
74
+ } else {
75
+ $status = "output";
76
+ }
77
+ } else {
78
+ if ( isset( $_POST['id'] ) && $_POST['id'] === '' ) {
79
+ if ( isset( $_POST['output'] ) ) {
80
+ $options['id'] = $db->insert_options( $_POST );
81
+ $status = "ok";
82
+ $mode = "edit";
83
+ } else {
84
+ $status = "output";
85
+ }
86
+ }
87
+ }
88
+
89
+ /** Mode Judgment */
90
+ if ( isset( $options['id'] ) && is_numeric( $options['id'] ) ) {
91
+ $options = $db->get_options( $options['id'] );
92
+ }
93
+
94
+ $this->page_render( $options, $mode, $status );
95
+ }
96
+
97
+ /**
98
+ * Setting Page of the Admin Screen.
99
+ *
100
+ * @since 1.0.0
101
+ * @param array $options
102
+ * @param string $mode
103
+ * @param string $status
104
+ */
105
+ private function page_render( array $options, $mode, $status ) {
106
+ $html = '';
107
+ $html .= '<link rel="stylesheet" href="' . WP_STRUCTURING_PLUGIN_DIR . 'css/style.css">';
108
+ $html .= '<div class="wrap">';
109
+ $html .= '<h1>Schema.org Post</h1>';
110
+ echo $html;
111
+
112
+ switch ( $status ) {
113
+ case "ok":
114
+ $this->information_render();
115
+ break;
116
+ case "output":
117
+ $this->output_error_render();
118
+ break;
119
+ default:
120
+ break;
121
+ }
122
+
123
+ $html = '<hr>';
124
+ $html .= '<form method="get" action="">';
125
+ $html .= '<input type="hidden" name="page" value="wp-structuring-admin-post.php">';
126
+ $html .= '<table class="schema-admin-table">';
127
+ $html .= '<tr><th><label for="type">Schema Type :</label></th><td>';
128
+ $html .= '<select id="type" name="type" onchange="this.form.submit();">';
129
+ foreach ( $this->type_array as $value ) {
130
+ $html .= '<option value="' . $value['type'] . '"';
131
+ if ( $value['type'] === $options['type'] ) {
132
+ $html .= ' selected';
133
+ } else {
134
+ if ( $mode === "edit" ) {
135
+ $html .= ' disabled';
136
+ }
137
+ }
138
+ $html .= '>' . $value['display'] . '</option>';
139
+ }
140
+ $html .= '</select>';
141
+ $html .= '</td></tr></table>';
142
+ $html .= '</form>';
143
+ echo $html;
144
+
145
+ /** Output Page Select */
146
+ $html = '<form method="post" action="">';
147
+ $html .= '<input type="hidden" name="id" value="' . esc_attr( $options['id'] ) . '">';
148
+ $html .= '<input type="hidden" name="type" value="' . esc_attr( $options['type'] ) . '">';
149
+ $html .= '<table class="schema-admin-table">';
150
+ $html .= '<tr><th>Output :</th><td>';
151
+ echo $html;
152
+
153
+ switch ( $options['type'] ) {
154
+ case 'website':
155
+ $this->output_checkbox_render( $options['output'], "all", "All", "All Page" );
156
+ $this->output_checkbox_render( $options['output'], "home", "Top", "Top Page" );
157
+ $this->output_checkbox_render( $options['output'], "post", "Post", "Post Page" );
158
+ $this->output_checkbox_render( $options['output'], "page", "Fixed", "Fixed Page" );
159
+ $html = '</td></tr></table><hr>';
160
+ echo $html;
161
+
162
+ require_once( WP_STRUCTURING_PLUGIN_DIR . 'wp-structuring-admin-type-website.php' );
163
+ new Structuring_Markup_Type_Website( $options['option'] );
164
+ break;
165
+ case 'organization':
166
+ $this->output_checkbox_render( $options['output'], "all", "All", "All Page" );
167
+ $this->output_checkbox_render( $options['output'], "home", "Top", "Top Page" );
168
+ $this->output_checkbox_render( $options['output'], "post", "Post", "Post Page" );
169
+ $this->output_checkbox_render( $options['output'], "page", "Fixed", "Fixed Page" );
170
+ $html = '</td></tr></table><hr>';
171
+ echo $html;
172
+
173
+ require_once ( WP_STRUCTURING_PLUGIN_DIR . 'wp-structuring-admin-type-organization.php' );
174
+ new Structuring_Markup_Type_Organization( $options['option'] );
175
+ break;
176
+ case 'news_article':
177
+ $this->output_checkbox_render( $options['output'], "post", "Post", "Post Page" );
178
+ $html = '</td></tr></table><hr>';
179
+ echo $html;
180
+
181
+ require_once ( WP_STRUCTURING_PLUGIN_DIR . 'wp-structuring-admin-type-news-article.php' );
182
+ new Structuring_Markup_Type_NewsArticle();
183
+ break;
184
+ }
185
+
186
+ $html = '</form>';
187
+ $html .= '</div>';
188
+ echo $html;
189
+ }
190
+
191
+ /**
192
+ * CheckBox Build Render
193
+ *
194
+ * @since 1.0.0
195
+ * @param array $option['output']
196
+ * @param string $output
197
+ * @param string $value
198
+ * @param string $display
199
+ * @return string $html
200
+ */
201
+ private function output_checkbox_render( array $option, $output, $value, $display ) {
202
+ $html = '<label>';
203
+ $html .= '<input type="checkbox" name="output[' . $output . ']" value="' . $value . '""';
204
+
205
+ if ( isset( $option[$output] ) ) {
206
+ $html .= ' checked';
207
+ }
208
+ $html .= '>' . $display . '</label>';
209
+
210
+ echo $html;
211
+ }
212
+
213
+ /**
214
+ * Information Message Render
215
+ *
216
+ * @since 1.0.0
217
+ */
218
+ private function information_render() {
219
+ $html = '<div id="message" class="updated notice notice-success is-dismissible below-h2">';
220
+ $html .= '<p>Schema.org Information Update.</p>';
221
+ $html .= '<button type="button" class="notice-dismiss">';
222
+ $html .= '<span class="screen-reader-text">Dismiss this notice.</span>';
223
+ $html .= '</button>';
224
+ $html .= '</div>';
225
+
226
+ echo $html;
227
+ }
228
+
229
+ /**
230
+ * Error Message Render
231
+ *
232
+ * @since 1.0.0
233
+ */
234
+ private function output_error_render() {
235
+ $html = '<div id="notice" class="notice notice-error is-dismissible below-h2">';
236
+ $html .= '<p>Output No Select.</p>';
237
+ $html .= '<button type="button" class="notice-dismiss">';
238
+ $html .= '<span class="screen-reader-text">Dismiss this notice.</span>';
239
+ $html .= '</button>';
240
+ $html .= '</div>';
241
+
242
+ echo $html;
243
+ }
244
+ }
trunk/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
+ }
trunk/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
+ }
trunk/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
+ }
trunk/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
+ }
trunk/wp-structuring-markup.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.2
7
+ Author: Kazuya Takami
8
+ Author URI: http://programp.com/
9
+ License: GPLv2 or later
10
+ Text Domain: wp-structuring-markup
11
+ */
12
+ define( 'WP_STRUCTURING_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
13
+ require_once( WP_STRUCTURING_PLUGIN_DIR . 'wp-structuring-admin-db.php' );
14
+
15
+ new Structuring_Markup();
16
+
17
+ /**
18
+ * Schema.org Basic Class
19
+ *
20
+ * @author Kazuya Takami
21
+ * @version 1.0.0
22
+ * @since 1.0.0
23
+ */
24
+ class Structuring_Markup {
25
+
26
+ /**
27
+ * Constructor Define.
28
+ *
29
+ * @since 1.0.0
30
+ */
31
+ function __construct() {
32
+ $db = new Structuring_Markup_Admin_Db();
33
+ $db->create_table();
34
+
35
+ if ( is_admin() ) {
36
+ add_action( 'admin_menu', array( $this, 'set_menu' ) );
37
+ } else {
38
+ add_action( 'wp_head', array( $this, 'display_page_render' ) );
39
+ }
40
+ }
41
+
42
+ /**
43
+ * Add Menu to the Admin Screen.
44
+ *
45
+ * @since 1.0.0
46
+ */
47
+ public function set_menu() {
48
+ add_menu_page(
49
+ 'Scheme.org Setting',
50
+ 'Scheme.org Setting',
51
+ 'manage_options',
52
+ plugin_basename( __FILE__ ),
53
+ array($this, 'list_page_render')
54
+ );
55
+ add_submenu_page(
56
+ __FILE__,
57
+ 'Setting All',
58
+ 'Setting All',
59
+ 'manage_options',
60
+ plugin_basename( __FILE__ ),
61
+ array($this, 'list_page_render')
62
+ );
63
+ add_submenu_page(
64
+ __FILE__,
65
+ 'Scheme.org Setting Post',
66
+ 'Add New',
67
+ 'manage_options',
68
+ WP_STRUCTURING_PLUGIN_DIR . 'wp-structuring-admin-post.php',
69
+ array($this, 'post_page_render')
70
+ );
71
+ }
72
+
73
+ /**
74
+ * LIST Page Template Require.
75
+ *
76
+ * @since 1.0.0
77
+ */
78
+ public function list_page_render() {
79
+ require_once( WP_STRUCTURING_PLUGIN_DIR . 'wp-structuring-admin-list.php' );
80
+ new Structuring_Markup_Admin_List();
81
+ }
82
+
83
+ /**
84
+ * POST Page Template Require.
85
+ *
86
+ * @since 1.0.0
87
+ */
88
+ public function post_page_render() {
89
+ require_once( WP_STRUCTURING_PLUGIN_DIR . 'wp-structuring-admin-post.php' );
90
+ new Structuring_Markup_Admin_Post();
91
+ }
92
+
93
+ /**
94
+ * Display Page Template Require.
95
+ *
96
+ * @since 1.0.0
97
+ */
98
+ public function display_page_render() {
99
+ require_once( WP_STRUCTURING_PLUGIN_DIR . 'wp-structuring-display.php' );
100
+ new Structuring_Markup_Display();
101
+ }
102
+ }
wp-structuring-markup.php CHANGED
@@ -3,7 +3,7 @@
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
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.1
7
  Author: Kazuya Takami
8
  Author URI: http://programp.com/
9
  License: GPLv2 or later