├── README.md
├── assets
├── banner-1554x500.jpg
├── banner-772x250.jpg
├── icon-128x128.png
└── icon-256x256.png
├── css
├── schema-custom-post.css
└── style.css
├── includes
├── admin
│ ├── wp-structuring-admin-config.php
│ ├── wp-structuring-admin-db.php
│ ├── wp-structuring-admin-list.php
│ ├── wp-structuring-admin-post.php
│ ├── wp-structuring-admin-type-article.php
│ ├── wp-structuring-admin-type-blog-posting.php
│ ├── wp-structuring-admin-type-breadcrumb.php
│ ├── wp-structuring-admin-type-event.php
│ ├── wp-structuring-admin-type-local-business.php
│ ├── wp-structuring-admin-type-news-article.php
│ ├── wp-structuring-admin-type-organization.php
│ ├── wp-structuring-admin-type-person.php
│ ├── wp-structuring-admin-type-site-navigation.php
│ ├── wp-structuring-admin-type-video.php
│ └── wp-structuring-admin-type-website.php
├── custom
│ ├── wp-structuring-custom-post-event.php
│ └── wp-structuring-custom-post-video.php
├── meta
│ ├── wp-structuring-meta-article.php
│ ├── wp-structuring-meta-blog-posting.php
│ ├── wp-structuring-meta-breadcrumb.php
│ ├── wp-structuring-meta-event.php
│ ├── wp-structuring-meta-local-business.php
│ ├── wp-structuring-meta-news-article.php
│ ├── wp-structuring-meta-organization.php
│ ├── wp-structuring-meta-person.php
│ ├── wp-structuring-meta-site-navigation.php
│ ├── wp-structuring-meta-video.php
│ └── wp-structuring-meta-website.php
├── wp-structuring-display-amp.php
├── wp-structuring-display.php
├── wp-structuring-opening-hours.php
├── wp-structuring-short-code-breadcrumb.php
└── wp-structuring-utility.php
├── js
├── main.js
├── main.min.js
└── media-uploader-main.js
├── languages
├── wp-structuring-markup-ja.mo
├── wp-structuring-markup-ja.po
├── wp-structuring-markup-tr_TR.mo
├── wp-structuring-markup-tr_TR.po
└── wp-structuring-markup.pot
├── materials
└── ImageDesign.psd
├── readme.txt
├── uninstall.php
└── wp-structuring-markup.php
/assets/banner-1554x500.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miiitaka/wp-structuring-markup/bc651600de3d81a749805ad5bc0450a6bbbad0c2/assets/banner-1554x500.jpg
--------------------------------------------------------------------------------
/assets/banner-772x250.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miiitaka/wp-structuring-markup/bc651600de3d81a749805ad5bc0450a6bbbad0c2/assets/banner-772x250.jpg
--------------------------------------------------------------------------------
/assets/icon-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miiitaka/wp-structuring-markup/bc651600de3d81a749805ad5bc0450a6bbbad0c2/assets/icon-128x128.png
--------------------------------------------------------------------------------
/assets/icon-256x256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miiitaka/wp-structuring-markup/bc651600de3d81a749805ad5bc0450a6bbbad0c2/assets/icon-256x256.png
--------------------------------------------------------------------------------
/css/schema-custom-post.css:
--------------------------------------------------------------------------------
1 | /** Event & Video Style */
2 | .schema-admin-custom-post label:before {
3 | border-radius: 2px;
4 | box-shadow: inset 0 -1px 0 rgba(27,31,35,0.12);
5 | line-height: 1;
6 | margin: 0 5px 0 0;
7 | }
8 |
9 | .schema-admin-required:before {
10 | background: #efefef;
11 | color: #a00;
12 | content: 'required';
13 | padding: 3px 41px 3px 5px;
14 | }
15 |
16 | .schema-admin-recommended:before {
17 | background: #efefef;
18 | color: #0073aa;
19 | content: 'recommended';
20 | padding: 3px 5px;
21 | }
--------------------------------------------------------------------------------
/css/style.css:
--------------------------------------------------------------------------------
1 | /** List Setting */
2 | .schema-admin-table-list {
3 | border-collapse: collapse;
4 | }
5 | .schema-admin-table-list .schema-admin-table-list-type {
6 | width: 15%;
7 | }
8 |
9 | .schema-admin-table-list .schema-admin-table-list-output {
10 | width: 30%;
11 | }
12 |
13 | .schema-admin-table-list tr {
14 | border-bottom: solid 1px #ddd;
15 | }
16 |
17 | .schema-admin-table-list tr:last-child {
18 | border-bottom: none;
19 | }
20 |
21 | .schema-admin-table-list td {
22 | vertical-align: middle;
23 | }
24 |
25 | .schema-admin-table-list td:nth-child(1) > span {
26 | float: left;
27 | height: 2em;
28 | }
29 |
30 | .schema-admin-table-list td:nth-child(1) > span span {
31 | display: inline-block;
32 | margin: 0 10px 0 0;
33 | padding: 0 1em 0 1em;
34 | text-align: center;
35 | width: 8em;
36 | }
37 |
38 | .schema-admin-table-list td:nth-child(1) > span span.active {
39 | background: #00a0d2;
40 | color: #fff;
41 | }
42 |
43 | .schema-admin-table-list tr.active {
44 | background: #ffffff;
45 | }
46 |
47 | .schema-admin-table-list tr.stop {
48 | background: #efefef;
49 | }
50 |
51 | .schema-admin-table-list td:nth-child(1) > span span.stop {
52 | background: #ddd;
53 | }
54 |
55 | /** Posts page */
56 | .schema-admin-h1-span {
57 | display: inline-block;
58 | font-size: 80%;
59 | margin: 0 0 0 10px;
60 | }
61 |
62 | .schema-admin-require::before {
63 | color: #a00;
64 | content: "*";
65 | margin: 0 3px 0 0;
66 | }
67 |
68 | .schema-admin-table {
69 | margin: 15px 0 15px 0;
70 | }
71 |
72 | .schema-admin-table caption {
73 | border-left: solid 4px #00a0d2;
74 | margin: 0 0 5px 0;
75 | padding: 3px 0 3px 7px;
76 | text-align: left;
77 | }
78 |
79 | .schema-admin-table th {
80 | height: 2em;
81 | padding: 0 5px 0 0;
82 | text-align: right;
83 | vertical-align: middle;
84 | width: 200px;
85 | }
86 |
87 | .schema-admin-table th.require::before {
88 | color: #a00;
89 | content: "*";
90 | margin: 0 3px 0 0;
91 | }
92 |
93 | .schema-admin-table td {
94 | vertical-align: middle;
95 | }
96 |
97 | .schema-admin-table td label {
98 | margin: 0 10px 0 0;
99 | }
100 |
101 | .schema-admin-table small {
102 | display: block;
103 | margin: 2px 0 2px 1px;
104 | background: #ddd;
105 | padding: 0 5px;
106 | }
107 |
108 | .schema-admin-table input[type="checkbox"] {
109 | margin: 0 5px 0 0;
110 | }
111 |
112 | .schema-admin-table input:invalid {
113 | border: solid 1px #d8000c;
114 | background: #ffbaba;
115 | }
116 |
117 | /** LocalBusiness */
118 | .markup-time {
119 | color: #999;
120 | cursor: pointer;
121 | width: 18px;
122 | height: 18px;
123 | line-height: 20px;
124 | font-size: 14px;
125 | border: solid 1px #bbb;
126 | background-color: #fff;
127 | border-radius: 100%;
128 | margin-top: 5px;
129 | }
130 |
131 | .markup-time:hover {
132 | color: #fff;
133 | border-color: transparent;
134 | }
135 |
136 | .markup-time .plus:hover {
137 | background-color: #00a0d2;
138 | }
139 |
140 | .markup-time .minus {
141 | line-height: 18px;
142 | }
143 |
144 | .markup-time .minus:hover {
145 | background-color: #f55e4f;
146 | }
147 |
148 | /** Media Uploader */
149 | .schema-admin-media-button {
150 | border: 0;
151 | font-size: 12px;
152 | padding: 6px 8px 2px 8px;
153 | }
154 |
155 | .schema-admin-media-button:before {
156 | font-size: 16px;
157 | height: 16px;
158 | width: 16px;
159 | }
160 |
161 | .schema-admin-media-button:hover {
162 | cursor: pointer;
163 | }
--------------------------------------------------------------------------------
/includes/admin/wp-structuring-admin-config.php:
--------------------------------------------------------------------------------
1 | text_domain = $text_domain;
37 | $this->nonce_name = "_wpnonce_" . $text_domain;
38 | $this->nonce_action = "config-" . $text_domain;
39 |
40 | /**
41 | * Update Status
42 | *
43 | * "ok" : Successful update
44 | * "output" : Output No Check
45 | */
46 | $status = "";
47 |
48 | /** DataBase Update & Insert Mode */
49 | if ( ! empty( $_POST ) && check_admin_referer( $this->nonce_action, $this->nonce_name ) ) {
50 | $db = new Structuring_Markup_Admin_Db();
51 | if ( $db->update_config( $_POST, $this->text_domain ) ) {
52 | $status = "ok";
53 | } else {
54 | $status = "error";
55 | }
56 | }
57 | $options = get_option( $text_domain );
58 | if ( !$options ) {
59 | $options = array();
60 | }
61 |
62 | $this->page_render( $options, $status );
63 | }
64 |
65 | /**
66 | * Setting Page of the Admin Screen.
67 | *
68 | * @version 4.5.0
69 | * @since 4.5.0
70 | * @param array $options
71 | * @param string $status
72 | */
73 | private function page_render ( array $options, $status ) {
74 | $html = '';
75 | $html .= '
';
179 | $html .= '';
180 | $html .= esc_html__( 'Event Type', $this->text_domain );
181 | $html .= ' ';
182 | $html .= '';
183 | foreach( $this->event_type as $value) {
184 | $html .= '' . $value . ' ';
189 | }
190 | $html .= ' ';
191 | $html .= ' ';
192 | $html .= '';
193 | $html .= esc_html__( 'Event Name', $this->text_domain );
194 | $html .= ' ';
195 | $html .= ' ';
196 | $html .= ' ';
197 | $html .= '';
198 | $html .= esc_html__( 'Event Description', $this->text_domain );
199 | $html .= ' ';
200 | $html .= '';
201 | $html .= ' ';
202 | $html .= '';
203 | $html .= esc_html__( 'Event Image', $this->text_domain );
204 | $html .= ' ';
205 | $html .= ' ';
206 | $html .= ' ';
207 | $html .= '';
208 | $html .= esc_html__( 'Start Date', $this->text_domain );
209 | $html .= ' ';
210 | $html .= ' ';
211 | $html .= ' ';
212 | $html .= ' ';
213 | $html .= '';
214 | $html .= esc_html__( 'End Date', $this->text_domain );
215 | $html .= ' ';
216 | $html .= ' ';
217 | $html .= ' ';
218 | $html .= ' ';
219 | $html .= '';
220 | $html .= esc_html__( 'Event URL', $this->text_domain );
221 | $html .= ' ';
222 | $html .= ' ';
223 | $html .= ' ';
224 | $html .= '';
225 | $html .= esc_html__( 'Place Name', $this->text_domain );
226 | $html .= ' ';
227 | $html .= ' ';
228 | $html .= ' ';
229 | $html .= '';
230 | $html .= esc_html__( 'Place URL', $this->text_domain );
231 | $html .= ' ';
232 | $html .= ' ';
233 | $html .= ' ';
234 | $html .= '';
235 | $html .= esc_html__( 'Place Address', $this->text_domain );
236 | $html .= ' ';
237 | $html .= ' ';
238 | $html .= ' ';
239 | $html .= '';
240 | $html .= esc_html__( 'Availability', $this->text_domain );
241 | $html .= ' ';
242 | $html .= '';
243 | foreach( $this->offers_availability as $value) {
244 | $html .= '' . $value . ' ';
249 | }
250 | $html .= ' ';
251 | $html .= ' ';
252 | $html .= '';
253 | $html .= esc_html__( 'Price', $this->text_domain );
254 | $html .= ' ';
255 | $html .= ' ';
256 | $html .= ' ';
257 | $html .= '';
258 | $html .= esc_html__( 'Currency', $this->text_domain );
259 | $html .= ' ';
260 | $html .= ' ';
261 | $html .= ' ( with ISO 4217 codes e.g. "USD" ) ';
262 | $html .= ' ';
263 | $html .= '';
264 | $html .= esc_html__( 'validFrom', $this->text_domain );
265 | $html .= ' ';
266 | $html .= ' ';
267 | $html .= ' ';
268 | $html .= ' ';
269 | $html .= '';
270 | $html .= esc_html__( 'Event Performer', $this->text_domain );
271 | $html .= ' ';
272 | $html .= ' ';
273 | $html .= ' ';
274 | $html .= '
';
275 |
276 | echo $html;
277 | }
278 |
279 | /**
280 | * Save custom post.
281 | *
282 | * @version 2.1.0
283 | * @since 2.1.0
284 | * @param integer $post_id The post ID.
285 | */
286 | public function save_post ( $post_id ) {
287 | if ( isset( $_POST['option'] ) ) {
288 | update_post_meta( $post_id, $this->custom_type, serialize( $_POST['option'] ) );
289 | }
290 | }
291 |
292 | /**
293 | * Return the default options array
294 | *
295 | * @version 4.0.2
296 | * @since 3.2.3
297 | * @return array $args
298 | */
299 | private function get_default_options () {
300 | $args = array(
301 | 'schema_event_type' => 'Event',
302 | 'schema_event_name' => '',
303 | 'schema_event_description' => '',
304 | 'schema_event_image' => '',
305 | 'schema_event_date' => date( 'Y-m-d' ),
306 | 'schema_event_time' => date( 'h:i' ),
307 | 'schema_event_date_end' => '',
308 | 'schema_event_time_end' => '',
309 | 'schema_event_url' => '',
310 | 'schema_event_place_name' => '',
311 | 'schema_event_place_url' => '',
312 | 'schema_event_place_address' => '',
313 | 'schema_event_offers_availability' => 'InStock',
314 | 'schema_event_offers_price' => 0,
315 | 'schema_event_offers_currency' => esc_html__( 'USD', $this->text_domain ),
316 | 'schema_event_offers_date' => '',
317 | 'schema_event_offers_time' => '',
318 | 'schema_event_performer_name' => ''
319 | );
320 |
321 | return (array) $args;
322 | }
323 | }
--------------------------------------------------------------------------------
/includes/custom/wp-structuring-custom-post-video.php:
--------------------------------------------------------------------------------
1 | text_domain = $text_domain;
31 |
32 | /** Custom post menu controls */
33 | $show_flag = __return_false();
34 | if ( isset( $_POST['type'] ) && $_POST['type'] === 'video' ) {
35 | if ( isset( $_POST['activate'] ) && $_POST['activate'] === 'on' ) {
36 | $show_flag = __return_true();
37 | }
38 | } else {
39 | /** DB Connect */
40 | $db = new Structuring_Markup_Admin_Db();
41 | $results = $db->get_type_options('video');
42 |
43 | if ( isset( $results['activate'] ) && $results['activate'] == 'on' ) {
44 | $show_flag = __return_true();
45 | }
46 | }
47 |
48 | register_post_type(
49 | $this->custom_type,
50 | array(
51 | 'labels' => array(
52 | 'name' => esc_html__( 'Video Posts', $this->text_domain ),
53 | 'singular_name' => esc_html__( 'Video Posts', $this->text_domain ),
54 | 'all_items' => esc_html__( 'All Video Posts', $this->text_domain )
55 | ),
56 | 'capability_type' => 'post',
57 | 'has_archive' => true,
58 | 'hierarchical' => false,
59 | 'menu_position' => 5,
60 | 'public' => $show_flag,
61 | 'query_var' => false,
62 | 'rewrite' => array( 'with_front' => true, 'slug' => 'videos' ),
63 | 'show_in_menu' => $show_flag,
64 | 'show_ui' => $show_flag,
65 | 'supports' => array( 'title', 'editor', 'author', 'thumbnail' )
66 | )
67 | );
68 |
69 | register_taxonomy(
70 | $this->custom_type . '_cat',
71 | $this->custom_type,
72 | array(
73 | 'hierarchical' => true,
74 | 'label' => esc_html__( 'Categories' ),
75 | 'public' => true,
76 | 'show_ui' => true,
77 | 'update_count_callback' => '_update_post_term_count'
78 | )
79 | );
80 |
81 | register_taxonomy(
82 | $this->custom_type . '_tag',
83 | $this->custom_type,
84 | array(
85 | 'hierarchical' => false,
86 | 'label' => esc_html__( 'Tags' ),
87 | 'public' => true,
88 | 'show_ui' => true,
89 | 'update_count_callback' => '_update_post_term_count'
90 | )
91 | );
92 |
93 | if ( is_admin() ) {
94 | add_action( 'admin_init', array( $this, 'admin_init' ) );
95 | add_action( 'admin_menu', array( $this, 'admin_menu' ) );
96 | }
97 | }
98 |
99 | /**
100 | * admin init.
101 | *
102 | * @version 3.0.0
103 | * @since 3.0.0
104 | */
105 | public function admin_init () {
106 | add_action( 'save_post_' . $this->custom_type, array( $this, 'save_post' ) );
107 | }
108 |
109 | /**
110 | * admin meta boxes.
111 | *
112 | * @version 3.0.0
113 | * @since 3.0.0
114 | */
115 | public function admin_menu () {
116 | $custom_field_title = esc_html__( 'Schema.org Type Video', $this->text_domain );
117 | add_meta_box( $this->custom_type, $custom_field_title, array( $this, 'set_custom_fields' ), $this->custom_type, 'normal' );
118 | }
119 |
120 | /**
121 | * Set custom fields.
122 | *
123 | * @version 4.1.1
124 | * @since 3.0.0
125 | */
126 | public function set_custom_fields () {
127 | $custom_array = get_post_meta( get_the_ID(), $this->custom_type, false );
128 | $custom_array = isset( $custom_array[0] ) ? unserialize( $custom_array[0] ) : array();
129 |
130 | /** Default Value Set */
131 | $args = $this->get_default_options();
132 |
133 | if ( !empty( $args ) ) {
134 | $args = array_merge( $args, $custom_array );
135 | }
136 |
137 | $html = '';
138 | $html .= '';
187 |
188 | echo $html;
189 | }
190 |
191 | /**
192 | * Save custom post.
193 | *
194 | * @version 3.0.0
195 | * @since 3.0.0
196 | * @param integer $post_id The post ID.
197 | */
198 | public function save_post ( $post_id ) {
199 | if ( isset( $_POST['option'] ) ) {
200 | update_post_meta( $post_id, $this->custom_type, serialize( $_POST['option'] ) );
201 | }
202 | }
203 |
204 | /**
205 | * Return the default options array
206 | *
207 | * @version 3.2.3
208 | * @since 3.2.3
209 | * @return array $args
210 | */
211 | private function get_default_options () {
212 | $args = array(
213 | 'schema_video_name' => '',
214 | 'schema_video_description' => '',
215 | 'schema_video_thumbnail_url' => '',
216 | 'schema_video_upload_date' => '',
217 | 'schema_video_upload_time' => '',
218 | 'schema_video_duration' => '',
219 | 'schema_video_content_url' => '',
220 | 'schema_video_embed_url' => '',
221 | 'schema_video_interaction_count' => '',
222 | 'schema_video_expires_date' => '',
223 | 'schema_video_expires_time' => '',
224 | );
225 |
226 | return (array) $args;
227 | }
228 | }
--------------------------------------------------------------------------------
/includes/meta/wp-structuring-meta-article.php:
--------------------------------------------------------------------------------
1 | utility = $utility;
31 | }
32 |
33 | /**
34 | * Setting schema.org Article
35 | *
36 | * @version 4.8.1
37 | * @since 4.0.0
38 | * @param array $options
39 | * @return array $args
40 | */
41 | public function set_meta ( array $options ) {
42 | global $post;
43 |
44 | $excerpt = $this->utility->escape_text( $post->post_excerpt );
45 | $content = $excerpt === "" ? mb_substr( $this->utility->escape_text( $post->post_content ), 0, 110 ) : $excerpt;
46 |
47 | $args = array(
48 | "@context" => "https://schema.org",
49 | "@type" => "Article",
50 | "mainEntityOfPage" => array(
51 | "@type" => "WebPage",
52 | "@id" => get_permalink( $post->ID )
53 | ),
54 | "headline" => mb_substr( $this->utility->escape_text( $post->post_title ), 0, 110 ),
55 | "datePublished" => get_the_time( DATE_ISO8601, $post->ID ),
56 | "dateModified" => get_the_modified_time( DATE_ISO8601, $post->ID ),
57 | "author" => array(
58 | "@type" => "Person",
59 | "name" => esc_html( get_the_author_meta( 'display_name', $post->post_author ) )
60 | ),
61 | "description" => $content
62 | );
63 |
64 | if ( has_post_thumbnail( $post->ID ) ) {
65 | $images = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
66 | $images_args = array(
67 | "image" => $this->set_image_object( $images[0], $images[1], $images[2] )
68 | );
69 | $args = array_merge( $args, $images_args );
70 | } elseif ( isset( $options['content_image'] ) && $options['content_image'] === 'on' ) {
71 | if ( $images = $this->utility->get_content_image( $post->post_content ) ) {
72 | if ( $size = $this->utility->get_image_dimensions( $images ) ) {
73 | $images_args = array(
74 | "image" => $this->set_image_object( $images, $size['width'], $size['height'] )
75 | );
76 | $args = array_merge( $args, $images_args );
77 | }
78 | } elseif ( isset( $options['default_image'] ) ) {
79 | if ($size = $this->utility->get_image_dimensions( $options['default_image'] ) ) {
80 | $images_args = array(
81 | "image" => $this->set_image_object( esc_html( $options['default_image'] ), $size['width'], $size['height'] )
82 | );
83 | $args = array_merge( $args, $images_args );
84 | }
85 | }
86 | } elseif ( isset( $options['default_image'] ) ) {
87 | if ( $size = $this->utility->get_image_dimensions( $options['default_image'] ) ) {
88 | $images_args = array(
89 | "image" => $this->set_image_object( esc_html( $options['default_image'] ), $size['width'], $size['height'] )
90 | );
91 | $args = array_merge( $args, $images_args );
92 | }
93 | }
94 |
95 | if ( isset( $options['name'] ) && !empty( $options['name'] ) ) {
96 | $publisher_args = array(
97 | "publisher" => array(
98 | "@type" => "Organization",
99 | "name" => esc_html( $options['name'] ),
100 | )
101 | );
102 |
103 | $options['logo'] = isset( $options['logo'] ) ? esc_html( $options['logo'] ) : "";
104 |
105 | if ( $logo = $this->utility->get_image_dimensions( $options['logo'] ) ) {
106 | $publisher_args['publisher']['logo'] = $this->set_image_object( $options['logo'], $logo['width'], $logo['height'] );
107 | } else if ( !empty( $options['logo'] ) ) {
108 | $publisher_args['publisher']['logo'] = $this->set_image_object(
109 | $options['logo'],
110 | isset( $options['logo-width'] ) ? ( int ) $options['logo-width'] : 0,
111 | isset( $options['logo-height'] ) ? ( int ) $options['logo-height'] : 0
112 | );
113 | }
114 | $args = array_merge( $args, $publisher_args );
115 | }
116 |
117 | if ( isset( $options['speakable_action'] ) && $options['speakable_action'] === 'on' ) {
118 | $speakable_type = isset( $options['speakable_type'] ) ? $options['speakable_type'] : '';
119 |
120 | if ( !empty( $speakable_type ) ) {
121 | $action_array = array(
122 | "@type" => "SpeakableSpecification"
123 | );
124 | $action_array[$speakable_type] = array(
125 | isset( $options['speakable_headline'] ) ? stripslashes( $options['speakable_headline'] ) : '',
126 | isset( $options['speakable_summary'] ) ? stripslashes( $options['speakable_summary'] ) : ''
127 | );
128 | $args['speakable'] = $action_array;
129 | }
130 | }
131 |
132 | return ( array ) $args;
133 | }
134 |
135 | /**
136 | * Setting ImageObject
137 | *
138 | * @version 4.7.0
139 | * @since 4.7.0
140 | * @param string $url
141 | * @param integer $width
142 | * @param integer $height
143 | * @return array $args
144 | */
145 | public function set_image_object ( $url, $width, $height ) {
146 | $args = array(
147 | "@type" => "ImageObject",
148 | "url" => $url,
149 | "width" => $width,
150 | "height" => $height
151 | );
152 |
153 | return ( array ) $args;
154 | }
155 | }
--------------------------------------------------------------------------------
/includes/meta/wp-structuring-meta-blog-posting.php:
--------------------------------------------------------------------------------
1 | utility = $utility;
31 | }
32 |
33 | /**
34 | * Setting schema.org BlogPosting
35 | *
36 | * @version 4.8.1
37 | * @since 4.0.0
38 | * @param array $options
39 | * @return array $args
40 | */
41 | public function set_meta ( array $options ) {
42 | global $post;
43 |
44 | $excerpt = $this->utility->escape_text( $post->post_excerpt );
45 | $content = $excerpt === "" ? mb_substr( $this->utility->escape_text( $post->post_content ), 0, 110 ) : $excerpt;
46 |
47 | $args = array(
48 | "@context" => "https://schema.org",
49 | "@type" => "BlogPosting",
50 | "mainEntityOfPage" => array(
51 | "@type" => "WebPage",
52 | "@id" => get_permalink( $post->ID )
53 | ),
54 | "headline" => mb_substr( $this->utility->escape_text( $post->post_title ), 0, 110 ),
55 | "datePublished" => get_the_time( DATE_ISO8601, $post->ID ), "dateModified" => get_the_modified_time( DATE_ISO8601, $post->ID ),
56 | "author" => array(
57 | "@type" => "Person",
58 | "name" => esc_html( get_the_author_meta( 'display_name', $post->post_author ) )
59 | ),
60 | "description" => $content
61 | );
62 |
63 | if ( has_post_thumbnail( $post->ID ) ) {
64 | $images = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
65 | $images_args = array(
66 | "image" => $this->set_image_object( $images[0], $images[1], $images[2] )
67 | );
68 | $args = array_merge( $args, $images_args );
69 | } elseif ( isset( $options['content_image'] ) && $options['content_image'] === 'on' ) {
70 | if ( $images = $this->utility->get_content_image( $post->post_content ) ) {
71 | if ( $size = $this->utility->get_image_dimensions( $images ) ) {
72 | $images_args = array(
73 | "image" => $this->set_image_object( $images, $size['width'], $size['height'] )
74 | );
75 | $args = array_merge( $args, $images_args );
76 | }
77 | } elseif ( isset( $options['default_image'] ) ) {
78 | if ($size = $this->utility->get_image_dimensions( $options['default_image'] ) ) {
79 | $images_args = array(
80 | "image" => $this->set_image_object( esc_html( $options['default_image'] ), $size['width'], $size['height'] )
81 | );
82 | $args = array_merge( $args, $images_args );
83 | }
84 | }
85 | } elseif ( isset( $options['default_image'] ) ) {
86 | if ( $size = $this->utility->get_image_dimensions( $options['default_image'] ) ) {
87 | $images_args = array(
88 | "image" => $this->set_image_object( esc_html( $options['default_image'] ), $size['width'], $size['height'] )
89 | );
90 | $args = array_merge( $args, $images_args );
91 | }
92 | }
93 |
94 | if ( isset( $options['name'] ) && !empty( $options['name'] ) ) {
95 | $publisher_args = array(
96 | "publisher" => array(
97 | "@type" => "Organization",
98 | "name" => esc_html( $options['name'] ),
99 | )
100 | );
101 |
102 | $options['logo'] = isset( $options['logo'] ) ? esc_html( $options['logo'] ) : "";
103 |
104 | if ( $logo = $this->utility->get_image_dimensions( $options['logo'] ) ) {
105 | $publisher_args['publisher']['logo'] = $this->set_image_object( $options['logo'], $logo['width'], $logo['height'] );
106 | } else if ( !empty( $options['logo'] ) ) {
107 | $publisher_args['publisher']['logo'] = $this->set_image_object(
108 | $options['logo'],
109 | isset( $options['logo-width'] ) ? ( int ) $options['logo-width'] : 0,
110 | isset( $options['logo-height'] ) ? ( int ) $options['logo-height'] : 0
111 | );
112 | }
113 | $args = array_merge( $args, $publisher_args );
114 | }
115 |
116 | if ( isset( $options['speakable_action'] ) && $options['speakable_action'] === 'on' ) {
117 | $speakable_type = isset( $options['speakable_type'] ) ? $options['speakable_type'] : '';
118 |
119 | if ( !empty( $speakable_type ) ) {
120 | $action_array = array(
121 | "@type" => "SpeakableSpecification"
122 | );
123 | $action_array[$speakable_type] = array(
124 | isset( $options['speakable_headline'] ) ? stripslashes( $options['speakable_headline'] ) : '',
125 | isset( $options['speakable_summary'] ) ? stripslashes( $options['speakable_summary'] ) : ''
126 | );
127 | $args['speakable'] = $action_array;
128 | }
129 | }
130 |
131 | return ( array ) $args;
132 | }
133 |
134 | /**
135 | * Setting ImageObject
136 | *
137 | * @version 4.7.0
138 | * @since 4.7.0
139 | * @param string $url
140 | * @param integer $width
141 | * @param integer $height
142 | * @return array $args
143 | */
144 | public function set_image_object ( $url, $width, $height ) {
145 | $args = array(
146 | "@type" => "ImageObject",
147 | "url" => $url,
148 | "width" => $width,
149 | "height" => $height
150 | );
151 |
152 | return ( array ) $args;
153 | }
154 | }
--------------------------------------------------------------------------------
/includes/meta/wp-structuring-meta-breadcrumb.php:
--------------------------------------------------------------------------------
1 | breadcrumb_array_setting( $options );
25 |
26 | if ( $item_array ) {
27 | /** itemListElement build */
28 | $item_list_element = array();
29 | $position = 1;
30 | foreach ($item_array as $item) {
31 | $item_list_element[] = array(
32 | "@type" => "ListItem",
33 | "position" => $position,
34 | "item" => $item
35 | );
36 | $position++;
37 | }
38 |
39 | /** Breadcrumb Schema build */
40 | $args = array(
41 | "@context" => "https://schema.org",
42 | "@type" => "BreadcrumbList",
43 | "itemListElement" => $item_list_element
44 | );
45 |
46 | return (array) $args;
47 | }
48 | }
49 |
50 | }
--------------------------------------------------------------------------------
/includes/meta/wp-structuring-meta-event.php:
--------------------------------------------------------------------------------
1 | ID, 'schema_event_post', false );
25 |
26 | if ( isset( $meta[0] ) ) {
27 | $meta = unserialize( $meta[0] );
28 |
29 | // @type: Event
30 | if ( !isset( $meta['schema_event_type']) ) $meta['schema_event_type'] = 'Event';
31 | if ( !isset( $meta['schema_event_name']) ) $meta['schema_event_name'] = '';
32 | if ( !isset( $meta['schema_event_date']) ) $meta['schema_event_date'] = date('Y-m-d');
33 | if ( !isset( $meta['schema_event_time']) ) $meta['schema_event_time'] = date('h:i');
34 | if ( !isset( $meta['schema_event_url']) ) $meta['schema_event_url'] = '';
35 | if ( !isset( $meta['schema_event_place_name'] ) ) $meta['schema_event_place_name'] = '';
36 | if ( !isset( $meta['schema_event_place_url'] ) ) $meta['schema_event_place_url'] = '';
37 | if ( !isset( $meta['schema_event_place_address'] ) ) $meta['schema_event_place_address'] = '';
38 | if ( !isset( $meta['schema_event_offers_price'] ) ) $meta['schema_event_offers_price'] = 0;
39 | if ( !isset( $meta['schema_event_offers_currency'] ) ) $meta['schema_event_offers_currency'] = '';
40 |
41 | $args = array(
42 | "@context" => "https://schema.org",
43 | "@type" => esc_html( $meta['schema_event_type'] ),
44 | "name" => esc_html( $meta['schema_event_name'] ),
45 | "startDate" => esc_html( $meta['schema_event_date'] ) . 'T' . esc_html( $meta['schema_event_time'] ),
46 | "url" => esc_url( $meta['schema_event_url'] ),
47 | "location" => array(
48 | "@type" => "Place",
49 | "sameAs" => esc_url( $meta['schema_event_place_url'] ),
50 | "name" => esc_html( $meta['schema_event_place_name'] ),
51 | "address" => esc_html( $meta['schema_event_place_address'] )
52 | )
53 | );
54 |
55 | // @type: Event recommended items
56 | if ( isset( $meta['schema_event_description'] ) && $meta['schema_event_description'] !== '' ) {
57 | $args['description'] = esc_html( $meta['schema_event_description'] );
58 | }
59 | if ( isset( $meta['schema_event_image'] ) && $meta['schema_event_image'] !== '' ) {
60 | $args['image'] = esc_html( $meta['schema_event_image'] );
61 | }
62 | if ( isset( $meta['schema_event_date_end'] ) && $meta['schema_event_date_end'] !== '' && isset( $meta['schema_event_time_end'] ) && $meta['schema_event_time_end'] !== '' ) {
63 | $args['endDate'] = esc_html( $meta['schema_event_date_end'] ) . 'T' . esc_html( $meta['schema_event_time_end'] );
64 | }
65 |
66 | // @type: Offer
67 | $offer = array(
68 | "@type" => "Offer",
69 | "price" => esc_html( $meta['schema_event_offers_price'] ),
70 | "priceCurrency" => esc_html( $meta['schema_event_offers_currency'] ),
71 | "url" => esc_url( $meta['schema_event_url'] )
72 | );
73 |
74 | // @type: Offer recommended items
75 | if ( isset( $meta['schema_event_offers_availability'] ) && $meta['schema_event_offers_availability'] !== '' ) {
76 | $offer['availability'] = "https://schema.org/" . esc_html( $meta['schema_event_offers_availability'] );
77 | }
78 | if ( isset( $meta['schema_event_offers_date'] ) && $meta['schema_event_offers_date'] !== '' && isset( $meta['schema_event_offers_time'] ) && $meta['schema_event_offers_time'] !== '' ) {
79 | $offer['validFrom'] = esc_html( $meta['schema_event_offers_date'] ) . 'T' . esc_html( $meta['schema_event_offers_time'] );
80 | }
81 |
82 | $args['offers'] = $offer;
83 |
84 | // @type: PerformingGroup recommended items
85 | if ( isset( $meta['schema_event_performer_name'] ) && $meta['schema_event_performer_name'] !== '' ) {
86 | $args['performer'] = array(
87 | "@type" => "PerformingGroup",
88 | "name" => esc_html( $meta['schema_event_performer_name'] )
89 | );
90 | }
91 |
92 | return (array) $args;
93 | }
94 | }
95 | }
--------------------------------------------------------------------------------
/includes/meta/wp-structuring-meta-local-business.php:
--------------------------------------------------------------------------------
1 | 'Mo', 'display' => 'Monday' ),
28 | array( 'type' => 'Tu', 'display' => 'Tuesday' ),
29 | array( 'type' => 'We', 'display' => 'Wednesday' ),
30 | array( 'type' => 'Th', 'display' => 'Thursday' ),
31 | array( 'type' => 'Fr', 'display' => 'Friday' ),
32 | array( 'type' => 'Sa', 'display' => 'Saturday' ),
33 | array( 'type' => 'Su', 'display' => 'Sunday' )
34 | );
35 |
36 | $args = array(
37 | '@context' => 'https://schema.org',
38 | '@type' => isset( $options['business_type'] ) ? esc_html( $options['business_type'] ) : 'LocalBusiness',
39 | 'name' => isset( $options['name'] ) ? esc_html( $options['name'] ) : '',
40 | 'image' => isset( $options['image'] ) ? esc_html( $options['image'] ) : '',
41 | 'url' => isset( $options['url'] ) ? esc_url( $options['url'] ) : ''
42 | );
43 |
44 | if ( isset( $options['telephone'] ) && !empty( $options['telephone'] ) ) {
45 | $args['telephone'] = esc_html( $options['telephone'] );
46 | }
47 |
48 | if ( isset( $options['food_active'] ) && $options['food_active'] === 'on' ) {
49 | if ( isset( $options['menu'] ) && $options['menu'] !== '' ) {
50 | $args['menu'] = esc_url( $options['menu'] );
51 | }
52 | if ( isset( $options['accepts_reservations'] ) && $options['accepts_reservations'] === 'on' ) {
53 | $args['acceptsReservations'] = 'True';
54 | } else {
55 | $args['acceptsReservations'] = 'False';
56 | }
57 | if ( isset( $options['serves_cuisine'] ) && $options['serves_cuisine'] !== '' ) {
58 | $args['servesCuisine'] = esc_html( $options['serves_cuisine'] );
59 | }
60 | }
61 |
62 | $address_array['address'] = array(
63 | '@type' => 'PostalAddress',
64 | 'streetAddress' => isset( $options['street_address'] ) ? esc_html( $options['street_address'] ) : '',
65 | 'addressLocality' => isset( $options['address_locality'] ) ? esc_html( $options['address_locality'] ) : '',
66 | 'postalCode' => isset( $options['postal_code'] ) ? esc_html( $options['postal_code'] ) : '',
67 | 'addressCountry' => isset( $options['address_country'] ) ? esc_html( $options['address_country'] ) : ''
68 | );
69 |
70 | if ( isset( $options['address_region'] ) && !empty( $options['address_region'] ) ) {
71 | $address_array['address']['addressRegion'] = esc_html( $options['address_region'] );
72 | }
73 |
74 | $args = array_merge( $args, $address_array );
75 | $geo_array = array();
76 |
77 | if ( isset( $options['geo_active'] ) && $options['geo_active'] === 'on' ) {
78 | $geo_array['geo'] = array(
79 | '@type' => 'GeoCoordinates',
80 | 'latitude' => isset( $options['latitude'] ) ? esc_html(floatval($options['latitude'])) : '',
81 | 'longitude' => isset( $options['longitude'] ) ? esc_html(floatval($options['longitude'])) : ''
82 | );
83 | }
84 |
85 | if ( isset( $options['geo_circle_active'] ) && $options['geo_circle_active'] === 'on' ) {
86 | $place_array['location'] = array( '@type' => 'Place' );
87 | $place_array['location']['geo'] = array(
88 | '@type' => 'GeoCircle',
89 | 'geoRadius' => isset( $options['geo_circle_radius'] ) ? esc_html( floatval( $options['geo_circle_radius'] ) ) : ''
90 | );
91 | if ( isset( $options['geo_active'] ) && $options['geo_active'] === 'on' ) {
92 | $place_array['location']['geo']['geoMidpoint'] = $geo_array['geo'];
93 | }
94 | $args = array_merge( $args, $place_array );
95 | } else {
96 | if ( isset( $options['geo_active'] ) && $options['geo_active'] === 'on' ) {
97 | $args = array_merge( $args, $geo_array );
98 | }
99 | }
100 |
101 | /* openingHours */
102 | $active_days = array();
103 | foreach ( $week_array as $value ) {
104 | if ( isset( $options[$value['type']] ) && $options[$value['type']] === 'on' ) {
105 | $active_days[$value['type']] = $options['week'][$value['type']];
106 | }
107 | }
108 |
109 | if( !empty( $active_days ) ) {
110 |
111 | $obj = new Structuring_Markup_Opening_Hours( $active_days );
112 | $opening_hours = $obj->display();
113 |
114 | $opening_array['openingHours'] = array();
115 |
116 | foreach( $opening_hours as $value ) {
117 | $opening_array['openingHours'][] = $value;
118 | }
119 |
120 | $args = array_merge( $args, $opening_array );
121 |
122 | }
123 |
124 | if ( isset( $options['holiday_active'] ) && $options['holiday_active'] === 'on' ) {
125 | $holiday_array['openingHoursSpecification'] = array(
126 | '@type' => 'OpeningHoursSpecification',
127 | 'opens' => isset( $options['holiday_open'] ) ? esc_html( $options['holiday_open'] ) : '',
128 | 'closes' => isset( $options['holiday_close'] ) ? esc_html( $options['holiday_close'] ) : '',
129 | 'validFrom' => isset( $options['holiday_valid_from'] ) ? esc_html( $options['holiday_valid_from'] ) : '',
130 | 'validThrough' => isset( $options['holiday_valid_through'] ) ? esc_html( $options['holiday_valid_through'] ) : ''
131 | );
132 | $args = array_merge( $args, $holiday_array );
133 | }
134 |
135 | if ( isset( $options['price_range'] ) && !empty( $options['price_range'] ) ) {
136 | $price_array['priceRange'] = $options['price_range'];
137 | $args = array_merge( $args, $price_array );
138 | }
139 |
140 | return (array) $args;
141 | }
142 |
143 | }
--------------------------------------------------------------------------------
/includes/meta/wp-structuring-meta-news-article.php:
--------------------------------------------------------------------------------
1 | utility = $utility;
31 | }
32 |
33 | /**
34 | * Setting schema.org NewsArticle
35 | *
36 | * @version 4.7.0
37 | * @since 4.0.0
38 | * @param array $options
39 | * @return array $args
40 | */
41 | public function set_meta ( array $options ) {
42 | global $post;
43 |
44 | $excerpt = $this->utility->escape_text( $post->post_excerpt );
45 | $content = $excerpt === "" ? mb_substr( $this->utility->escape_text( $post->post_content ), 0, 110 ) : $excerpt;
46 |
47 | $args = array(
48 | "@context" => "https://schema.org",
49 | "@type" => "NewsArticle",
50 | "mainEntityOfPage" => array(
51 | "@type" => "WebPage",
52 | "@id" => get_permalink( $post->ID )
53 | ),
54 | "headline" => mb_substr( $this->utility->escape_text( $post->post_title ), 0, 110 ),
55 | "datePublished" => get_the_time( DATE_ISO8601, $post->ID ),
56 | "dateModified" => get_the_modified_time( DATE_ISO8601, $post->ID ),
57 | "author" => array(
58 | "@type" => "Person",
59 | "name" => esc_html( get_the_author_meta( 'display_name', $post->post_author ) )
60 | ),
61 | "description" => $content
62 | );
63 |
64 | if ( has_post_thumbnail( $post->ID ) ) {
65 | $images = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
66 | $images_args = array(
67 | "image" => $this->set_image_object( $images[0], $images[1], $images[2] )
68 | );
69 | $args = array_merge( $args, $images_args );
70 | } elseif ( isset( $options['content_image'] ) && $options['content_image'] === 'on' ) {
71 | if ( $images = $this->utility->get_content_image( $post->post_content ) ) {
72 | if ( $size = $this->utility->get_image_dimensions( $images ) ) {
73 | $images_args = array(
74 | "image" => $this->set_image_object( $images, $size['width'], $size['height'] )
75 | );
76 | $args = array_merge( $args, $images_args );
77 | }
78 | } elseif ( isset( $options['default_image'] ) ) {
79 | if ($size = $this->utility->get_image_dimensions( $options['default_image'] ) ) {
80 | $images_args = array(
81 | "image" => $this->set_image_object( esc_html( $options['default_image'] ), $size['width'], $size['height'] )
82 | );
83 | $args = array_merge( $args, $images_args );
84 | }
85 | }
86 | } elseif ( isset( $options['default_image'] ) ) {
87 | if ( $size = $this->utility->get_image_dimensions( $options['default_image'] ) ) {
88 | $images_args = array(
89 | "image" => $this->set_image_object( esc_html( $options['default_image'] ), $size['width'], $size['height'] )
90 | );
91 | $args = array_merge( $args, $images_args );
92 | }
93 | }
94 |
95 | if ( isset( $options['name'] ) && !empty( $options['name'] ) ) {
96 | $publisher_args = array(
97 | "publisher" => array(
98 | "@type" => "Organization",
99 | "name" => esc_html( $options['name'] ),
100 | )
101 | );
102 |
103 | $options['logo'] = isset( $options['logo'] ) ? esc_html( $options['logo'] ) : "";
104 |
105 | if ( $logo = $this->utility->get_image_dimensions( $options['logo'] ) ) {
106 | $publisher_args['publisher']['logo'] = $this->set_image_object( $options['logo'], $logo['width'], $logo['height'] );
107 | } else if ( !empty( $options['logo'] ) ) {
108 | $publisher_args['publisher']['logo'] = $this->set_image_object(
109 | $options['logo'],
110 | isset( $options['logo-width'] ) ? ( int ) $options['logo-width'] : 0,
111 | isset( $options['logo-height'] ) ? ( int ) $options['logo-height'] : 0
112 | );
113 | }
114 | $args = array_merge( $args, $publisher_args );
115 | }
116 |
117 | if ( isset( $options['speakable_action'] ) && $options['speakable_action'] === 'on' ) {
118 | $speakable_type = isset( $options['speakable_type'] ) ? $options['speakable_type'] : '';
119 |
120 | if ( !empty( $speakable_type ) ) {
121 | $action_array = array(
122 | "@type" => "SpeakableSpecification"
123 | );
124 | $action_array[$speakable_type] = array(
125 | isset( $options['speakable_headline'] ) ? stripslashes( $options['speakable_headline'] ) : '',
126 | isset( $options['speakable_summary'] ) ? stripslashes( $options['speakable_summary'] ) : ''
127 | );
128 | $args['speakable'] = $action_array;
129 | }
130 | }
131 |
132 | return ( array ) $args;
133 | }
134 |
135 | /**
136 | * Setting ImageObject
137 | *
138 | * @version 4.7.0
139 | * @since 4.7.0
140 | * @param string $url
141 | * @param integer $width
142 | * @param integer $height
143 | * @return array $args
144 | */
145 | public function set_image_object ( $url, $width, $height ) {
146 | $args = array(
147 | "@type" => "ImageObject",
148 | "url" => $url,
149 | "width" => $width,
150 | "height" => $height
151 | );
152 |
153 | return ( array ) $args;
154 | }
155 | }
--------------------------------------------------------------------------------
/includes/meta/wp-structuring-meta-organization.php:
--------------------------------------------------------------------------------
1 | 'https://schema.org',
25 | '@type' => isset( $options['organization_type'] ) ? esc_html( $options['organization_type'] ) : 'Organization',
26 | 'name' => isset( $options['name'] ) ? esc_html( $options['name'] ) : '',
27 | 'url' => isset( $options['url'] ) ? esc_url( $options['url'] ) : '',
28 | 'logo' => isset( $options['logo'] ) ? esc_url( $options['logo'] ) : ''
29 | );
30 |
31 | /** Corporate Contact */
32 | if ( isset( $options['contact_point'] ) && $options['contact_point'] === 'on' ) {
33 | $contact_point_data = array(
34 | '@type' => 'ContactPoint',
35 | 'telephone' => isset( $options['telephone'] ) ? esc_html( $options['telephone'] ) : '',
36 | 'contactType' => isset( $options['contact_type'] ) ? esc_html( $options['contact_type'] ) : ''
37 | );
38 |
39 | if ( !empty( $options['email'] ) ) {
40 | $contact_point_data['email'] = isset( $options['email'] ) ? esc_html( $options['email'] ) : '';
41 | }
42 | if ( !empty( $options['area_served'] ) ) {
43 | $array = explode( ',', esc_html( $options['area_served'] ) );
44 | for ( $i = 0; $i < count( $array ); $i++ ) {
45 | $contact_point_data['areaServed'][] = isset( $options['area_served'] ) ? $array[$i] : '';
46 | }
47 | }
48 | if ( isset( $options['contact_point_1'] ) && $options['contact_point_1'] === 'on' ) {
49 | $contact_point_data['contactOption'][] = 'HearingImpairedSupported';
50 | }
51 | if ( isset( $options['contact_point_2'] ) && $options['contact_point_2'] === 'on' ) {
52 | $contact_point_data['contactOption'][] = 'TollFree';
53 | }
54 | if ( !empty( $options['available_language'] ) ) {
55 | $array = explode( ',', esc_html( $options['available_language'] ) );
56 | for ( $i = 0; $i < count( $array ); $i++ ) {
57 | $contact_point_data['availableLanguage'][] = isset( $options['available_language'] ) ? $array[$i] : '';
58 | }
59 | }
60 |
61 | $contact_point['contactPoint'] = array( $contact_point_data );
62 | $args = array_merge( $args, $contact_point );
63 | }
64 |
65 | /** Social Profiles */
66 | if ( isset( $options['social'] ) ) {
67 | $socials['sameAs'] = array();
68 |
69 | foreach ( $options['social'] as $value ) {
70 | if ( $value ) {
71 | $socials['sameAs'][] = esc_url( $value );
72 | }
73 | }
74 | if ( count( $socials['sameAs'] ) > 0 ) {
75 | $args = array_merge( $args, $socials );
76 | }
77 | }
78 | return (array) $args;
79 | }
80 | }
--------------------------------------------------------------------------------
/includes/meta/wp-structuring-meta-person.php:
--------------------------------------------------------------------------------
1 | "https://schema.org",
25 | "@type" => "Person",
26 | "name" => isset( $options['name'] ) ? esc_html( $options['name'] ) : "",
27 | "url" => isset( $options['url'] ) ? esc_url( $options['url'] ) : ""
28 | );
29 |
30 | /** Place */
31 | if ( isset( $options['addressCountry'] ) ) {
32 | $place["homeLocation"] = array(
33 | "@type" => "Place",
34 | "address" => array(
35 | "@type" => "PostalAddress",
36 | "addressCountry" => $options['addressCountry']
37 | )
38 | );
39 | $args = array_merge( $args, $place );
40 | }
41 |
42 | /** Social Profiles */
43 | if ( isset( $options['social'] ) ) {
44 | $socials["sameAs"] = array();
45 |
46 | foreach ( $options['social'] as $value ) {
47 | if ( !empty( $value ) ) {
48 | $socials["sameAs"][] = esc_html( $value );
49 | }
50 | }
51 | if ( count( $socials["sameAs"] ) > 0 ) {
52 | $args = array_merge( $args, $socials );
53 | }
54 | }
55 | return (array) $args;
56 | }
57 | }
--------------------------------------------------------------------------------
/includes/meta/wp-structuring-meta-site-navigation.php:
--------------------------------------------------------------------------------
1 | $menu_item ) {
27 | $url_array[] = $menu_item->url;
28 | $name_array[] = $menu_item->title;
29 | }
30 |
31 | if ( count( $items_array ) > 0 ) {
32 | $args = array(
33 | "@context" => "https://schema.org",
34 | "@type" => "SiteNavigationElement",
35 | "name" => $name_array,
36 | "url" => $url_array
37 | );
38 | return (array) $args;
39 | }
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/includes/meta/wp-structuring-meta-video.php:
--------------------------------------------------------------------------------
1 | utility = $utility;
30 | }
31 |
32 | /**
33 | * Setting schema.org Video
34 | *
35 | * @version 4.8.1
36 | * @since 4.0.0
37 | * @return array $args
38 | */
39 | public function set_meta () {
40 | global $post;
41 | $meta = get_post_meta( $post->ID, 'schema_video_post', false );
42 |
43 | if ( isset( $meta[0] ) ) {
44 | $meta = unserialize( $meta[0] );
45 |
46 | if ( has_post_thumbnail( $post->ID ) ) {
47 | $images = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
48 | $excerpt = $this->utility->escape_text( $post->post_excerpt );
49 | $content = $excerpt === "" ? mb_substr( $this->utility->escape_text( $post->post_content ), 0, 110 ) : $excerpt;
50 | } else {
51 | $images[0] = '';
52 | $content = '';
53 | }
54 |
55 | /* required items */
56 | if ( !isset( $meta['schema_video_name']) ) $meta['schema_video_name'] = esc_html( $post->post_title );
57 | if ( !isset( $meta['schema_video_description'] ) ) $meta['schema_video_description'] = esc_html( $content );
58 | if ( !isset( $meta['schema_video_thumbnail_url'] ) ) $meta['schema_video_description'] = esc_html( $images[0] );
59 | if ( !isset( $meta['schema_video_upload_date'] ) ) $meta['schema_video_upload_date'] = get_post_modified_time( 'Y-m-d', __return_false(), $post->ID );
60 | if ( !isset( $meta['schema_video_upload_time'] ) ) $meta['schema_video_upload_time'] = get_post_modified_time( 'H:i:s', __return_false(), $post->ID );
61 |
62 | $args = array(
63 | "@context" => "https://schema.org",
64 | "@type" => "VideoObject",
65 | "name" => esc_html( $meta['schema_video_name'] ),
66 | "description" => esc_html( $meta['schema_video_description'] ),
67 | "thumbnailUrl" => esc_html( $meta['schema_video_thumbnail_url'] ),
68 | "uploadDate" => esc_html( $meta['schema_video_upload_date'] ) . 'T' . esc_html( $meta['schema_video_upload_time'] )
69 | );
70 |
71 | /* recommended items */
72 | if ( isset( $meta['schema_video_duration'] ) && $meta['schema_video_duration'] !== '' ) {
73 | $args["duration"] = esc_html( $meta['schema_video_duration'] );
74 | }
75 | if ( isset( $meta['schema_video_content_url'] ) && $meta['schema_video_content_url'] !== '' ) {
76 | $args["contentUrl"] = esc_url( $meta['schema_video_content_url'] );
77 | }
78 | if ( isset( $meta['schema_video_embed_url'] ) && $meta['schema_video_embed_url'] !== '' ) {
79 | $args["embedUrl"] = esc_url( $meta['schema_video_embed_url'] );
80 | }
81 | if ( isset( $meta['schema_video_interaction_count'] ) && $meta['schema_video_interaction_count'] !== '' ) {
82 | $args["interactionCount"] = esc_html( $meta['schema_video_interaction_count'] );
83 | }
84 | if ( isset( $meta['schema_video_expires_date'] ) && $meta['schema_video_expires_date'] !== '' && isset( $meta['schema_video_expires_time'] ) && $meta['schema_video_expires_time'] !== '' ) {
85 | $args["expires"] = esc_html( $meta['schema_video_expires_date'] ) . 'T' . esc_html( $meta['schema_video_expires_time'] );
86 | }
87 | return (array) $args;
88 | }
89 | }
90 | }
--------------------------------------------------------------------------------
/includes/meta/wp-structuring-meta-website.php:
--------------------------------------------------------------------------------
1 | "https://schema.org",
25 | "@type" => "WebSite",
26 | "name" => isset( $options['name'] ) ? esc_html( $options['name'] ) : '',
27 | "alternateName" => isset( $options['alternateName'] ) ? esc_html( $options['alternateName'] ) : '',
28 | "url" => isset( $options['url'] ) ? esc_url( $options['url'] ) : ''
29 | );
30 |
31 | $search_array = array();
32 |
33 | if ( isset( $options['potential_action'] ) && $options['potential_action'] === 'on' ) {
34 | $action_array = array(
35 | "@type" => "SearchAction",
36 | "target" => isset( $options['target'] ) ? esc_url( $options['target'] ) . "{search_term_string}" : '',
37 | "query-input" => isset( $options['target'] ) ? "required name=search_term_string" : ''
38 | );
39 | $search_array[] = $action_array;
40 | }
41 |
42 | if ( count( $search_array ) > 0 ) {
43 | if ( isset( $options['potential_action_app'] ) && $options['potential_action_app'] === 'on' ) {
44 | $action_array = array(
45 | "@type" => "SearchAction",
46 | "target" => isset( $options['target_app'] ) ? $options['target_app'] . "{search_term_string}" : '',
47 | "query-input" => isset( $options['target_app'] ) ? "required name=search_term_string" : ''
48 | );
49 | $search_array[] = $action_array;
50 | }
51 |
52 | $potential_action["potentialAction"] = $search_array;
53 | $args = array_merge( $args, $potential_action );
54 | }
55 |
56 | return (array) $args;
57 | }
58 | }
--------------------------------------------------------------------------------
/includes/wp-structuring-display-amp.php:
--------------------------------------------------------------------------------
1 | utility = new Structuring_Markup_Utility();
36 |
37 | $db = new Structuring_Markup_Admin_Db();
38 | $this->set_schema( $db );
39 | }
40 |
41 | /**
42 | * Setting schema.org
43 | *
44 | * @version 4.0.0
45 | * @since 4.0.0
46 | * @param Structuring_Markup_Admin_Db $db
47 | */
48 | private function set_schema ( Structuring_Markup_Admin_Db $db ) {
49 | $structuring_markup_args = $db->get_list_options();
50 |
51 | if ( is_single() && get_post_type() === 'post' ) {
52 | $this->get_schema_data( 'amp', $structuring_markup_args );
53 | }
54 | }
55 |
56 | /**
57 | * Setting JSON-LD Template
58 | *
59 | * @version 4.0.0
60 | * @since 4.0.0
61 | * @param string $output
62 | * @param array $structuring_markup_args
63 | */
64 | private function get_schema_data ( $output, array $structuring_markup_args ) {
65 |
66 | foreach ( $structuring_markup_args as $row ) {
67 | /** Output page check. */
68 | $output_args = unserialize( $row->output );
69 | if ( array_key_exists( $output, $output_args ) ) {
70 |
71 | /** Activate check. */
72 | if ( isset( $row->type ) && isset( $row->activate ) && $row->activate === 'on' ) {
73 | switch ( $row->type ) {
74 | case 'article':
75 | if ( isset( $row->options ) && $row->options ) {
76 | require_once( plugin_dir_path( __FILE__ ) . 'meta/wp-structuring-meta-article.php' );
77 | $obj = new Structuring_Markup_Meta_Article( $this->utility );
78 | $this->json_ld = $obj->set_meta( unserialize( $row->options ) );
79 | }
80 | break;
81 | case 'blog_posting':
82 | if ( isset( $row->options ) && $row->options ) {
83 | require_once( plugin_dir_path( __FILE__ ) . 'meta/wp-structuring-meta-blog-posting.php' );
84 | $obj = new Structuring_Markup_Meta_Blog_Posting( $this->utility );
85 | $this->json_ld = $obj->set_meta( unserialize( $row->options ) );
86 | }
87 | break;
88 | case 'news_article':
89 | if ( isset( $row->options ) && $row->options ) {
90 | require_once( plugin_dir_path( __FILE__ ) . 'meta/wp-structuring-meta-news-article.php' );
91 | $obj = new Structuring_Markup_Meta_NewsArticle( $this->utility );
92 | $this->json_ld = $obj->set_meta( unserialize( $row->options ) );
93 | }
94 | break;
95 | }
96 | }
97 | }
98 | }
99 | }
100 | }
--------------------------------------------------------------------------------
/includes/wp-structuring-display.php:
--------------------------------------------------------------------------------
1 | utility = new Structuring_Markup_Utility();
39 |
40 | $this->options = get_option( $text_domain );
41 |
42 | $db = new Structuring_Markup_Admin_Db();
43 | $this->set_schema( $db, $version );
44 | }
45 |
46 | /**
47 | * Setting schema.org
48 | *
49 | * @version 4.5.0
50 | * @since 1.0.0
51 | * @param Structuring_Markup_Admin_Db $db
52 | * @param string $version
53 | */
54 | private function set_schema ( Structuring_Markup_Admin_Db $db, $version ) {
55 | $structuring_markup_args = $db->get_list_options();
56 |
57 | if ( !isset( $this->options['compress'] ) || $this->options['compress'] !== 'on' ) {
58 | echo '' . PHP_EOL;
59 | }
60 |
61 | $this->get_schema_data( 'all', $structuring_markup_args );
62 | if ( is_home() || is_front_page() ) {
63 | $this->get_schema_data( 'home', $structuring_markup_args );
64 | }
65 | if ( is_single() && get_post_type() === 'post' ) {
66 | $this->get_schema_data( 'post', $structuring_markup_args );
67 | }
68 | if ( is_singular( 'schema_event_post' ) ) {
69 | $this->get_schema_data( 'event', $structuring_markup_args );
70 | }
71 | if ( is_singular( 'schema_video_post' ) ) {
72 | $this->get_schema_data( 'video', $structuring_markup_args );
73 | }
74 | if ( is_page() ) {
75 | $this->get_schema_data( 'page', $structuring_markup_args );
76 | }
77 | $args = array(
78 | 'public' => true,
79 | '_builtin' => false
80 | );
81 | $post_types = get_post_types( $args, 'objects' );
82 |
83 | unset( $post_types['schema_event_post'] );
84 | unset( $post_types['schema_video_post'] );
85 |
86 | foreach ( $post_types as $post_type ) {
87 | if ( is_singular( $post_type->name ) ) {
88 | $this->get_schema_data( $post_type->name, $structuring_markup_args );
89 | }
90 | }
91 |
92 | if ( !isset( $this->options['compress'] ) || $this->options['compress'] !== 'on' ) {
93 | echo '' . PHP_EOL;
94 | }
95 | }
96 |
97 | /**
98 | * Setting JSON-LD Template
99 | *
100 | * @version 4.6.3
101 | * @since 1.0.0
102 | * @param string $output
103 | * @param array $structuring_markup_args
104 | */
105 | private function get_schema_data ( $output, array $structuring_markup_args ) {
106 |
107 | foreach ( $structuring_markup_args as $row ) {
108 | /** Output page check. */
109 | $output_args = unserialize( $row->output );
110 | if ( array_key_exists( $output, $output_args ) ) {
111 |
112 | /** Activate check. */
113 | if ( isset( $row->type ) && isset( $row->activate ) && $row->activate === 'on' ) {
114 | switch ( $row->type ) {
115 | case 'article':
116 | if ( isset( $row->options ) && $row->options ) {
117 | require_once( plugin_dir_path( __FILE__ ) . 'meta/wp-structuring-meta-article.php' );
118 | $obj = new Structuring_Markup_Meta_Article( $this->utility );
119 | $out = $obj->set_meta( unserialize( $row->options ) );
120 | $out = apply_filters( 'structuring_markup_meta_article', $out );
121 | $this->set_schema_json( $out );
122 | }
123 | break;
124 | case 'blog_posting':
125 | if ( isset( $row->options ) && $row->options ) {
126 | require_once( plugin_dir_path( __FILE__ ) . 'meta/wp-structuring-meta-blog-posting.php' );
127 | $obj = new Structuring_Markup_Meta_Blog_Posting( $this->utility );
128 | $out = $obj->set_meta( unserialize( $row->options ) );
129 | $out = apply_filters( 'structuring_markup_meta_blog_posting', $out );
130 | $this->set_schema_json( $out );
131 | }
132 | break;
133 | case 'breadcrumb':
134 | if ( isset( $row->options ) && $row->options ) {
135 | require_once( plugin_dir_path( __FILE__ ) . 'meta/wp-structuring-meta-breadcrumb.php' );
136 | require_once( plugin_dir_path( __FILE__ ) . 'wp-structuring-short-code-breadcrumb.php' );
137 | $obj = new Structuring_Markup_Meta_Breadcrumb();
138 | $out = $obj->set_meta( unserialize( $row->options ) );
139 | $out = apply_filters( 'structuring_markup_meta_breadcrumb', $out );
140 | $this->set_schema_json( $out );
141 | }
142 | break;
143 | case 'event':
144 | require_once( plugin_dir_path( __FILE__ ) . 'meta/wp-structuring-meta-event.php' );
145 | $obj = new Structuring_Markup_Meta_Event();
146 | $out = $obj->set_meta();
147 | $out = apply_filters( 'structuring_markup_meta_event', $out );
148 | $this->set_schema_json( $out );
149 | break;
150 | case 'local_business':
151 | if ( isset( $row->options ) && $row->options ) {
152 | require_once( plugin_dir_path( __FILE__ ) . 'meta/wp-structuring-meta-local-business.php' );
153 | require_once( plugin_dir_path( __FILE__ ) . 'wp-structuring-opening-hours.php' );
154 | $obj = new Structuring_Markup_Meta_LocalBusiness();
155 | $out = $obj->set_meta( unserialize( $row->options ) );
156 | $out = apply_filters( 'structuring_markup_meta_local_business', $out );
157 | $this->set_schema_json( $out );
158 | }
159 | break;
160 | case 'news_article':
161 | if ( isset( $row->options ) && $row->options ) {
162 | require_once( plugin_dir_path( __FILE__ ) . 'meta/wp-structuring-meta-news-article.php' );
163 | $obj = new Structuring_Markup_Meta_NewsArticle( $this->utility );
164 | $out = $obj->set_meta( unserialize( $row->options ) );
165 | $out = apply_filters( 'structuring_markup_meta_news_article', $out );
166 | $this->set_schema_json( $out );
167 | }
168 | break;
169 | case 'organization':
170 | if ( isset( $row->options ) && $row->options ) {
171 | require_once( plugin_dir_path( __FILE__ ) . 'meta/wp-structuring-meta-organization.php' );
172 | $obj = new Structuring_Markup_Meta_Organization();
173 | $out = $obj->set_meta( unserialize( $row->options ) );
174 | $out = apply_filters( 'structuring_markup_meta_organization', $out );
175 | $this->set_schema_json( $out );
176 | }
177 | break;
178 | case 'person':
179 | if ( isset( $row->options ) && $row->options ) {
180 | require_once( plugin_dir_path( __FILE__ ) . 'meta/wp-structuring-meta-person.php' );
181 | $obj = new Structuring_Markup_Meta_Person();
182 | $out = $obj->set_meta( unserialize( $row->options ) );
183 | $out = apply_filters( 'structuring_markup_meta_person', $out );
184 | $this->set_schema_json( $out );
185 | }
186 | break;
187 | case 'site_navigation':
188 | if ( isset( $row->options ) && $row->options ) {
189 | require_once( plugin_dir_path( __FILE__ ) . 'meta/wp-structuring-meta-site-navigation.php' );
190 | $obj = new Structuring_Markup_Meta_Site_Navigation();
191 | $out = $obj->set_meta( unserialize( $row->options ) );
192 | $out = apply_filters( 'structuring_markup_meta_site_navigation', $out );
193 | $this->set_schema_json( $out );
194 | }
195 | break;
196 | case 'video':
197 | require_once( plugin_dir_path( __FILE__ ) . 'meta/wp-structuring-meta-video.php' );
198 | $obj = new Structuring_Markup_Meta_Video( $this->utility );
199 | $out = $obj->set_meta();
200 | $out = apply_filters( 'structuring_markup_meta_video', $out );
201 | $this->set_schema_json( $out );
202 | break;
203 | case 'website':
204 | if ( isset( $row->options ) && $row->options ) {
205 | require_once( plugin_dir_path( __FILE__ ) . 'meta/wp-structuring-meta-website.php' );
206 | $obj = new Structuring_Markup_Meta_WebSite();
207 | $out = $obj->set_meta( unserialize( $row->options ) );
208 | $out = apply_filters( 'structuring_markup_meta_website', $out );
209 | $this->set_schema_json( $out );
210 | }
211 | break;
212 | }
213 | }
214 | }
215 | }
216 | }
217 |
218 | /**
219 | * Setting JSON-LD Template
220 | *
221 | * @since 4.6.4
222 | * @since 1.0.0
223 | * @param array $args
224 | * @param boolean $error
225 | */
226 | private function set_schema_json ( $args, $error = false ) {
227 | if ( $error ) {
228 | /** Error Display */
229 | if ( isset( $args["@type"] ) ) {
230 | foreach ( $args["message"] as $message ) {
231 | echo "", PHP_EOL;
232 | }
233 | }
234 | } else {
235 | $output = '';
236 | if ( is_array( $args ) ) {
237 | if ( isset( $this->options['compress'] ) && $this->options['compress'] === 'on' ) {
238 | $output .= '';
241 | } else {
242 | $output .= '' . PHP_EOL;
245 | }
246 | }
247 | echo apply_filters( 'structuring_markup_output', $output );
248 | }
249 | }
250 | }
251 |
--------------------------------------------------------------------------------
/includes/wp-structuring-opening-hours.php:
--------------------------------------------------------------------------------
1 | opening_hours = $opening_hours;
64 | $this->init();
65 | }
66 | }
67 |
68 | /**
69 | * Initialize the class
70 | *
71 | * @since 2.4.0
72 | */
73 | public function init () {
74 | $this->days = array_keys( $this->opening_hours );
75 | $this->periods = $this->group_periods();
76 | $this->grouped_days = $this->group_periods_with_days();
77 | $this->weekly_hours = $this->group_weekly_hours();
78 | }
79 |
80 | /**
81 | * Groups unique open and closed hour periods
82 | *
83 | * @since 2.4.0
84 | * @return array
85 | */
86 | public function group_periods () {
87 | $periods = array();
88 | foreach( $this->opening_hours as $day ) {
89 | foreach( $day as $group ) {
90 | if( !in_array( $group, $periods ) ) {
91 | if( !empty( $group['open'] ) && !empty( $group['close'] ) ) {
92 | $periods[] = $group;
93 | }
94 | }
95 | }
96 | }
97 |
98 | return (array) $periods;
99 | }
100 |
101 | /**
102 | * Groups day ranges with their opening hours
103 | *
104 | * @since 2.4.0
105 | * @return array
106 | */
107 | public function group_periods_with_days () {
108 | $periods = $this->periods;
109 |
110 | foreach( $periods as $key => $group ) {
111 | $days = array();
112 |
113 | foreach( $this->opening_hours as $day => $grouped_days ) {
114 | if( in_array( $group, $grouped_days) ) {
115 | $days[] = $day;
116 | }
117 | }
118 |
119 | $periods[$key]['days'] = $days;
120 | }
121 |
122 | return (array) $periods;
123 | }
124 |
125 | /**
126 | * Group weekly group ranges with their opening hours
127 | *
128 | * @since 2.4.0
129 | * @return array
130 | */
131 | public function group_weekly_hours () {
132 | $grouped_days = $this->grouped_days;
133 | $days = $this->days;
134 | $object = $this;
135 |
136 | return (array) array_reduce( $grouped_days, function($result, $group) use ( $days, $object ) {
137 | return array_merge( $result, $object->group_periods_to_day_range( $group ) );
138 | }, array() );
139 | }
140 |
141 | /**
142 | * Groups days of the week with their opening hours
143 | *
144 | * @since 2.4.0
145 | * @param array $group
146 | * @return array
147 | */
148 | public function group_periods_to_day_range ( array $group ) {
149 | $starting_day = null;
150 | $ending_day = null;
151 |
152 | $consecutive_days = array();
153 |
154 | foreach( $this->days as $i => $day ) {
155 | $has_day = in_array( $day, $group['days'] );
156 |
157 | if( $has_day ) {
158 | $starting_day = $starting_day ? $starting_day : $day;
159 | $ending_day = $day;
160 | }
161 |
162 | if( $starting_day && (!$has_day || $i == count($this->days) - 1) ) {
163 | $consecutive_days[] = array(
164 | 'start' => $starting_day,
165 | 'end' => $ending_day,
166 | 'open' => $group['open'],
167 | 'close' => $group['close']
168 | );
169 |
170 | $starting_day = null;
171 | }
172 | }
173 |
174 | return (array) $this->sort_by_day_of_the_week( $consecutive_days );
175 | }
176 |
177 | /**
178 | * Sorts our days in the proper weekly hour
179 | *
180 | * @version 4.8.0
181 | * @since 2.4.0
182 | * @param array $consecutive_days
183 | * @return array
184 | */
185 | public function sort_by_day_of_the_week ( array $consecutive_days ) {
186 | $days = $this->days;
187 |
188 | arsort( $consecutive_days );
189 |
190 | $sort_by_day_func = function( $a, $b ) use ( $days ) {
191 | $aKey = array_search( $a['start'], $days );
192 | $bKey = array_search( $b['start'], $days );
193 |
194 | if ( $aKey < $bKey ) {
195 | return -1;
196 | } else {
197 | return 1;
198 | }
199 | };
200 |
201 | usort( $consecutive_days, $sort_by_day_func );
202 |
203 | return (array) $consecutive_days;
204 | }
205 |
206 | /**
207 | * Displays formatted opening hours
208 | *
209 | * @since 2.4.0
210 | * @return array
211 | */
212 | public function display () {
213 | $opening_hours = array();
214 |
215 | foreach( $this->weekly_hours as $key => $group ) {
216 | if( $group['start'] != $group['end'] ) {
217 | $hours = $group['start'].'-'.$group['end'];
218 | } else {
219 | $hours = $group['start'];
220 | }
221 |
222 | $hours .= ' ' . $group['open'] . '-' . $group['close'];
223 |
224 | $opening_hours[] = $hours;
225 | }
226 |
227 | return (array) $opening_hours;
228 | }
229 |
230 | }
--------------------------------------------------------------------------------
/includes/wp-structuring-short-code-breadcrumb.php:
--------------------------------------------------------------------------------
1 | "",
24 | 'class' => ""
25 | ), $args ) );
26 |
27 | $instance = array(
28 | 'id' => esc_attr( $id ),
29 | 'class' => esc_attr( $class )
30 | );
31 |
32 | $item_array = $this->breadcrumb_array_setting( $options );
33 | $html = '';
34 |
35 | if ( isset( $item_array ) && count( $item_array ) > 0 ) {
36 | $html .= '' . PHP_EOL;
37 |
38 | if ( $id !== '' && $class !== '' ) {
39 | $html .= '