WP SEO Structured Data Schema - Version 1.2

Version Description

  • Meta field issue
  • Layout change
  • Fix some coding bug
Download this release

Release Info

Developer kcseopro
Plugin Icon 128x128 WP SEO Structured Data Schema
Version 1.2
Comparing to
See all releases

Code changes from version 1.1 to 1.2

assets/css/admin.css CHANGED
@@ -6,35 +6,47 @@
6
  display: inline-block;
7
  width: 100%;
8
  }
 
 
 
 
 
 
 
9
  .field-container label {
10
  float: left;
11
  width: 25%;
 
12
  }
13
  .field-container .field-content {
14
  width: 75%;
15
  float: right;
16
  }
17
- div#tabs-kcseo-container .field-container input{
18
- width: 300px;
 
 
 
 
19
  }
20
- div#tabs-kcseo-container .field-container textarea{
21
  width: 100%;
22
  min-height: 80px;
23
  }
24
- div#tabs-kcseo-container .field-container input[type=number]{
25
  width: 100px;
26
  }
27
- div#tabs-kcseo-container .field-container input.kcseo-date{
28
  width: auto;
29
  }
30
 
31
  /* tab */
32
- .ui-widget {
33
- font-size: inherit;
 
 
34
  }
35
-
36
-
37
- #tabs-kcseo-container ul.tabs-menu{
38
  clear: both;
39
  margin-top: 0;
40
  padding: 0;
@@ -42,20 +54,21 @@ div#tabs-kcseo-container .field-container input.kcseo-date{
42
  width: 100%;
43
  margin-bottom: -4px;
44
  }
45
- #tabs-kcseo-container ul.tabs-menu li{
46
  background: none repeat scroll 0 0 rgb(230, 230, 230);
47
  cursor: pointer;
48
  display: inline-block;
49
  float: left;
50
  margin: 0;
51
  }
52
- #tabs-kcseo-container ul.tabs-menu li:focus{
 
53
  outline: none;
54
  }
55
- #tabs-kcseo-container ul.tabs-menu li.ui-tabs-active a , #tabs-kcseo-container ul.tabs-menu li a:hover{
56
  background: #8cc63e;
57
  }
58
- #tabs-kcseo-container ul.tabs-menu li.ui-tabs-active a:after , #tabs-kcseo-container ul.tabs-menu li a:hover:after{
59
  width: 0;
60
  height: 0;
61
  border-left: 10px solid transparent;
@@ -69,7 +82,7 @@ div#tabs-kcseo-container .field-container input.kcseo-date{
69
  margin: auto;
70
  content: "";
71
  }
72
- #tabs-kcseo-container ul.tabs-menu li a{
73
  text-decoration: none;
74
  display: block;
75
  padding: 8px 10px;
@@ -77,37 +90,34 @@ div#tabs-kcseo-container .field-container input.kcseo-date{
77
  background: #0071bd;
78
  color: #fff;
79
  position: relative;
 
80
  }
81
- #tabs-kcseo-container ul.tabs-menu li:last-child a{
82
  border-right: 0;
83
  }
84
- #tabs-kcseo-container ul.tabs-menu li a:focus{
85
  -webkit-box-shadow: none;
86
  box-shadow: none;
87
  }
88
- .kcseo-tab-container{
 
89
  display: none;
90
  border: 1px solid #e7e7e7;
91
- padding: 15px;
92
- }
93
- #kcseo-settings #tabs-kcseo-container{
94
- margin-top: 25px;
95
- background: #fff;
96
  }
97
 
98
-
99
-
100
- li.ui-tabs-active a:focus{
101
- -webkit-box-shadow: none;
102
- box-shadow: none;
103
- }
104
- #tabs-container {
105
- margin-top: 20px;
106
  }
 
107
  .form-table th {
108
  padding: 5px 10px 5px 0;
109
  }
110
- .form-table tr.person, .form-table tr.field_homepage{
111
  display: none;
112
  }
113
  .sfield span.select2 {
@@ -178,4 +188,7 @@ p.description .required {
178
  height: 16px;
179
  display: inline-block;
180
  background: url("../images/help.png") no-repeat center;
 
 
 
181
  }
6
  display: inline-block;
7
  width: 100%;
8
  }
9
+ .field-container:after{
10
+ content: ".";
11
+ height: 0;
12
+ visibility: hidden;
13
+ display: block;
14
+ clear: both;
15
+ }
16
  .field-container label {
17
  float: left;
18
  width: 25%;
19
+ font-weight: bold;
20
  }
21
  .field-container .field-content {
22
  width: 75%;
23
  float: right;
24
  }
25
+ .rt-tab-container .field-container input{
26
+ width: 100%;
27
+ }
28
+ .rt-tab-container .field-container input, .rt-tab-container .field-container textarea,#kcseo-settings input.regular-text {
29
+ border-radius: 4px;
30
+ padding: 5px;
31
  }
32
+ .rt-tab-container .field-container textarea{
33
  width: 100%;
34
  min-height: 80px;
35
  }
36
+ .rt-tab-container .field-container input[type=number]{
37
  width: 100px;
38
  }
39
+ .rt-tab-container .field-container input.kcseo-date{
40
  width: auto;
41
  }
42
 
43
  /* tab */
44
+ .rt-tab-container {
45
+ background: #fff;
46
+ margin: 25px 0;
47
+ max-width: 1200px;
48
  }
49
+ ul.rt-tab-nav{
 
 
50
  clear: both;
51
  margin-top: 0;
52
  padding: 0;
54
  width: 100%;
55
  margin-bottom: -4px;
56
  }
57
+ ul.rt-tab-nav li{
58
  background: none repeat scroll 0 0 rgb(230, 230, 230);
59
  cursor: pointer;
60
  display: inline-block;
61
  float: left;
62
  margin: 0;
63
  }
64
+
65
+ ul.rt-tab-nav li:focus{
66
  outline: none;
67
  }
68
+ ul.rt-tab-nav li.active a , ul.rt-tab-nav li a:hover{
69
  background: #8cc63e;
70
  }
71
+ ul.rt-tab-nav li.active a:after , ul.rt-tab-nav li a:hover:after{
72
  width: 0;
73
  height: 0;
74
  border-left: 10px solid transparent;
82
  margin: auto;
83
  content: "";
84
  }
85
+ ul.rt-tab-nav li a{
86
  text-decoration: none;
87
  display: block;
88
  padding: 8px 10px;
90
  background: #0071bd;
91
  color: #fff;
92
  position: relative;
93
+ font-weight: bold;
94
  }
95
+ ul.rt-tab-nav li:last-child a{
96
  border-right: 0;
97
  }
98
+ ul.rt-tab-nav li a:focus{
99
  -webkit-box-shadow: none;
100
  box-shadow: none;
101
  }
102
+
103
+ .rt-tab-content{
104
  display: none;
105
  border: 1px solid #e7e7e7;
106
+ padding: 20px;
 
 
 
 
107
  }
108
 
109
+ div#meta-tab-holder:after {
110
+ clear: both;
111
+ content: ".";
112
+ height: 0;
113
+ visibility: hidden;
114
+ display: block;
 
 
115
  }
116
+ /* from */
117
  .form-table th {
118
  padding: 5px 10px 5px 0;
119
  }
120
+ .form-table tr.person{
121
  display: none;
122
  }
123
  .sfield span.select2 {
188
  height: 16px;
189
  display: inline-block;
190
  background: url("../images/help.png") no-repeat center;
191
+ }
192
+ .select2-results__option[aria-selected=true] {
193
+ background: #f3f3f3;
194
  }
assets/js/admin.js CHANGED
@@ -1,23 +1,25 @@
1
  (function($){
2
  'use strict';
3
- $("#tabs-kcseo-container").tabs();
4
- $("#tabs-container").tabs();
5
  $('.kcseo-date').datepicker({
6
  dateFormat : 'yy-mm-dd'
7
  });
8
-
9
- showHideWebUrl();
10
- $('#homeonly').click(function () {
11
- showHideWebUrl();
12
- });
13
  showHideType();
14
  $("#site_type").change(function(){
15
  showHideType();
16
  });
17
 
18
- $(".select2").select2({
19
- placeholder: "Select an item"
20
- });
 
 
 
 
 
 
 
 
 
21
 
22
  $(".social-remove").on('click', function(){
23
  $(this).parent('.sfield').slideUp('slow').remove();
@@ -46,16 +48,25 @@
46
  }
47
  });
48
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
  })(jQuery);
51
 
52
- function showHideWebUrl(){
53
- if(jQuery('#homeonly').is(':checked')){
54
- jQuery(".field_homepage").show();
55
- }else{
56
- jQuery(".field_homepage").hide();
57
- }
58
- }
59
 
60
  function showHideType(){
61
  var id = jQuery("#site_type option:selected").val();
1
  (function($){
2
  'use strict';
 
 
3
  $('.kcseo-date').datepicker({
4
  dateFormat : 'yy-mm-dd'
5
  });
 
 
 
 
 
6
  showHideType();
7
  $("#site_type").change(function(){
8
  showHideType();
9
  });
10
 
11
+ if($("#kcseo-wordpres-seo-structured-data-schema-meta-box").length){
12
+
13
+ $("select.select2").select2({
14
+ dropdownAutoWidth : true,
15
+ width : '100%'
16
+ });
17
+ }else{
18
+ $("select.select2").select2({
19
+ dropdownAutoWidth : true
20
+ });
21
+ }
22
+
23
 
24
  $(".social-remove").on('click', function(){
25
  $(this).parent('.sfield').slideUp('slow').remove();
48
  }
49
  });
50
  });
51
+ $(document).ready(function() {
52
+ $(".rt-tab-nav li:first-child a").trigger('click');
53
+ });
54
+ $(".rt-tab-nav li").on('click', 'a', function(e){
55
+ e.preventDefault();
56
+ var container = $(this).parents('.rt-tab-container');
57
+ var nav = container.children('.rt-tab-nav');
58
+ var content = container.children(".rt-tab-content");
59
+ var $this, $id;
60
+ $this = $(this);
61
+ $id = $this.attr('href');
62
+ content.hide();
63
+ nav.find('li').removeClass('active');
64
+ $this.parent().addClass('active');
65
+ container.find($id).show();
66
+ });
67
 
68
  })(jQuery);
69
 
 
 
 
 
 
 
 
70
 
71
  function showHideType(){
72
  var id = jQuery("#site_type option:selected").val();
lib/classes/KcSeoHelper.php CHANGED
@@ -1,18 +1,101 @@
1
  <?php
2
 
3
- if(!class_exists('KcSeoSettings')):
4
-
5
- class KcSeoHelper
6
- {
7
- function verifyNonce( ){
8
- $nonce = @$_REQUEST['_kcseo_nonce'];
9
- if( !wp_verify_nonce( $nonce, $this->nonceText() ) ) return false;
10
- return true;
11
- }
12
-
13
- function nonceText(){
14
- return "kcseo_nonce_secret_text";
15
- }
16
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
  endif;
1
  <?php
2
 
3
+ if ( ! class_exists( 'KcSeoSettings' ) ):
4
+
5
+ class KcSeoHelper {
6
+ function verifyNonce() {
7
+ $nonce = ! empty( $_REQUEST['_kcseo_nonce'] ) ? $_REQUEST['_kcseo_nonce'] : null;
8
+ if ( ! wp_verify_nonce( $nonce, $this->nonceText() ) ) {
9
+ return false;
10
+ }
11
+
12
+ return true;
13
+ }
14
+
15
+ function nonceText() {
16
+ return "kcseo_nonce_secret_text";
17
+ }
18
+
19
+
20
+ function isValidBase64( $string ) {
21
+ $decoded = base64_decode( $string, true );
22
+ // Check if there is no invalid character in string
23
+ if ( ! preg_match( '/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $string ) ) {
24
+ return false;
25
+ }
26
+
27
+ // Decode the string in strict mode and send the response
28
+ if ( ! base64_decode( $string, true ) ) {
29
+ return false;
30
+ }
31
+
32
+ // Encode and compare it to original one
33
+ if ( base64_encode( $decoded ) != $string ) {
34
+ return false;
35
+ }
36
+
37
+ return true;
38
+ }
39
+
40
+
41
+ function kcSeoPostTypes() {
42
+ $post_types = get_post_types(
43
+ array(
44
+ '_builtin' => true
45
+ )
46
+ );
47
+ $exclude = array( 'attachment', 'revision', 'nav_menu_item' );
48
+ foreach ( $exclude as $ex ) {
49
+ unset( $post_types[ $ex ] );
50
+ }
51
+
52
+ return $post_types;
53
+ }
54
+
55
+ /**
56
+ * Sanitize field value
57
+ *
58
+ * @param array $field
59
+ * @param null $value
60
+ *
61
+ * @return array|null
62
+ * @internal param $value
63
+ */
64
+ function sanitize( $field = array(), $value = null ) {
65
+ $newValue = null;
66
+ if ( is_array( $field ) && $value ) {
67
+ $type = ( ! empty( $field['type'] ) ? $field['type'] : 'text' );
68
+ if ( $type == 'text' || $type == 'number' || $type == 'select' || $type == 'checkbox' || $type == 'radio' ) {
69
+ $newValue = sanitize_text_field( $value );
70
+ } else if ( $type == 'url' ) {
71
+ $newValue = esc_url( $value );
72
+ } else if ( $type == 'textarea' ) {
73
+ $newValue = wp_kses_post( $value );
74
+ } else {
75
+ $newValue = sanitize_text_field( $value );
76
+ }
77
+ }
78
+
79
+ return $newValue;
80
+ }
81
+
82
+
83
+ function sanitizeOutPut( $value, $type = 'text' ) {
84
+ $newValue = null;
85
+ if ( $value ) {
86
+ if ( $type == 'text' ) {
87
+ $newValue = esc_html( stripslashes( $value ) );
88
+ } elseif ( $type == 'url' ) {
89
+ $newValue = esc_url( stripslashes( $value ) );
90
+ } elseif ( $type == 'textarea' ) {
91
+ $newValue = esc_textarea( stripslashes( $value ) );
92
+ } else {
93
+ $newValue = esc_html( stripslashes( $value ) );
94
+ }
95
+ }
96
+
97
+ return $newValue;
98
+ }
99
+ }
100
 
101
  endif;
lib/classes/{KcSeoSettings.php → KcSeoInit.php} RENAMED
@@ -1,17 +1,38 @@
1
  <?php
2
 
3
- if(!class_exists('KcSeoSettings')):
4
 
5
- class KcSeoSettings
6
  {
7
  function __construct()
8
  {
9
- add_action( 'plugins_loaded', array($this, 'kcSeo_pluginInit') );
10
  add_action( 'admin_menu' , array($this, 'kcSeo_Wp_Schema_menu'));
 
11
  add_action( 'wp_ajax_kcSeoWpSchemaSettings', array($this, 'kcSeoWpSchemaSettings'));
12
  add_action( 'wp_ajax_newSocial', array($this, 'newSocial'));
13
- add_action( 'init', array($this, 'kcSeoScript'));
14
  add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  }
16
  function admin_enqueue_scripts(){
17
  global $pagenow;
@@ -21,8 +42,7 @@ if(!class_exists('KcSeoSettings')):
21
  // scripts
22
  wp_enqueue_script(array(
23
  'jquery',
24
- 'jquery-ui-core',
25
- 'jquery-ui-tabs',
26
  'kcseo-select2-js',
27
  'kcseo-tooltip-js',
28
  'kcseo-admin-js',
@@ -30,6 +50,7 @@ if(!class_exists('KcSeoSettings')):
30
 
31
  // styles
32
  wp_enqueue_style(array(
 
33
  'kcseo-select2-css',
34
  'kcseo-tooltip-css',
35
  'kcseo-admin-css',
@@ -59,7 +80,7 @@ if(!class_exists('KcSeoSettings')):
59
  $scripts[] = array(
60
  'handle' => 'kcseo-admin-js',
61
  'src' => $KcSeoWPSchema->assetsUrl . 'js/admin.js',
62
- 'deps' => array('jquery', 'jquery-ui-core', 'jquery-ui-tabs','jquery-ui-datepicker'),
63
  'footer' => true
64
  );
65
  $styles['kcseo-ui-css'] = 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.0/themes/base/jquery-ui.css';
@@ -131,5 +152,6 @@ if(!class_exists('KcSeoSettings')):
131
  function kcSeo_pluginInit(){
132
  load_plugin_textdomain( KCSEO_WP_SCHEMA_SLUG, FALSE, KCSEO_WP_SCHEMA_LANGUAGE_PATH );
133
  }
 
134
  }
135
  endif;
1
  <?php
2
 
3
+ if(!class_exists('KcSeoInit')):
4
 
5
+ class KcSeoInit
6
  {
7
  function __construct()
8
  {
9
+ add_action( 'init', array($this, 'kcSeoScript'));
10
  add_action( 'admin_menu' , array($this, 'kcSeo_Wp_Schema_menu'));
11
+ add_action( 'plugins_loaded', array($this, 'kcSeo_pluginInit') );
12
  add_action( 'wp_ajax_kcSeoWpSchemaSettings', array($this, 'kcSeoWpSchemaSettings'));
13
  add_action( 'wp_ajax_newSocial', array($this, 'newSocial'));
 
14
  add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
15
+
16
+ // for MU Site
17
+ add_action( 'activated_plugin', array( $this, 'update_queue' ), 10, 2 );
18
+ add_action( 'deactivated_plugin', array( $this, 'update_queue' ), 10, 2 );
19
+
20
+ // register_activation_hook(KCSEO_WP_SCHEMA_PLUGIN_ACTIVE_FILE_NAME, array($this, 'uninstall'));
21
+ // register_deactivation_hook(KCSEO_WP_SCHEMA_PLUGIN_ACTIVE_FILE_NAME, array($this, 'uninstall'));
22
+
23
+ // Uninstall hook
24
+
25
+ }
26
+ function update_queue( $plugin, $network_wide = null ) {
27
+ if ( !$network_wide )
28
+ return;
29
+ list( $action ) = explode( '_', current_filter(), 2 );
30
+
31
+ $action = str_replace( 'activated', 'activate', $action );
32
+ $queue = get_site_option( "network_{$action}_queue", array() );
33
+
34
+ $queue[$plugin] = ( has_filter( $action . '_' . $plugin ) || has_filter( $action . '_plugin' ) );
35
+ update_site_option( "network_{$action}_queue", $queue );
36
  }
37
  function admin_enqueue_scripts(){
38
  global $pagenow;
42
  // scripts
43
  wp_enqueue_script(array(
44
  'jquery',
45
+ 'jquery-ui-datepicker',
 
46
  'kcseo-select2-js',
47
  'kcseo-tooltip-js',
48
  'kcseo-admin-js',
50
 
51
  // styles
52
  wp_enqueue_style(array(
53
+ 'kcseo-ui-css',
54
  'kcseo-select2-css',
55
  'kcseo-tooltip-css',
56
  'kcseo-admin-css',
80
  $scripts[] = array(
81
  'handle' => 'kcseo-admin-js',
82
  'src' => $KcSeoWPSchema->assetsUrl . 'js/admin.js',
83
+ 'deps' => array('jquery'),
84
  'footer' => true
85
  );
86
  $styles['kcseo-ui-css'] = 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.0/themes/base/jquery-ui.css';
152
  function kcSeo_pluginInit(){
153
  load_plugin_textdomain( KCSEO_WP_SCHEMA_SLUG, FALSE, KCSEO_WP_SCHEMA_LANGUAGE_PATH );
154
  }
155
+
156
  }
157
  endif;
lib/classes/KcSeoMetaData.php CHANGED
@@ -13,14 +13,14 @@ if(!class_exists('KcSeoMetaData')):
13
  function admin_enqueue_scripts(){
14
  global $pagenow, $typenow, $KcSeoWPSchema;
15
  // validate page
 
16
  if( !in_array( $pagenow, array('post.php', 'post-new.php') ) ) return;
17
- if(!in_array($typenow, $KcSeoWPSchema->kcSep_postType)) return;
18
 
19
  // scripts
20
  wp_enqueue_script(array(
21
  'jquery',
22
- 'jquery-ui-core',
23
- 'jquery-ui-tabs',
24
  'kcseo-select2-js',
25
  'kcseo-admin-js',
26
  ));
@@ -37,7 +37,8 @@ if(!class_exists('KcSeoMetaData')):
37
 
38
  function admin_head(){
39
  global $KcSeoWPSchema;
40
- foreach($KcSeoWPSchema->kcSep_postType as $postType){
 
41
  add_meta_box(
42
  'kcseo-wordpres-seo-structured-data-schema-meta-box',
43
  __('WP SEO Structured Data Schema by <a href="http://kcseopro.com/">KCSEOPro.com</a>', KCSEO_WP_SCHEMA_SLUG),
@@ -61,14 +62,14 @@ if(!class_exists('KcSeoMetaData')):
61
  $html .= "<p><span>Tip:</span> Once you save these structured data schema settings, validate this page url here: <a href='https://developers.google.com/structured-data/testing-tool/'>https://developers.google.com/structured-data/testing-tool/</a></p>";
62
  $html .="</div>";
63
  $html .= "<div class='schema-holder'>";
64
- $html .= '<div id="tabs-kcseo-container">';
65
  $htmlMenu = null;
66
  $htmlCont = null;
67
- $htmlMenu .= "<ul class='tabs-menu'>";
68
  foreach($schemas->schemaTypes() as $schemaID => $schema){
69
  $tabId = $KcSeoWPSchema->KcSeoPrefix.$schemaID;
70
  $htmlMenu .= '<li><a href="#'.$tabId.'">'.$schema['title'].'</a></li>';
71
- $htmlCont .="<div id='{$tabId}' class='kcseo-tab-container'>";
72
  foreach($schema['fields'] as $fieldId => $data){
73
  $data['schemaId'] = $schemaID;
74
  $htmlCont .= $schemas->get_field($fieldId,$data, $post->ID);
@@ -77,6 +78,7 @@ if(!class_exists('KcSeoMetaData')):
77
  }
78
  $htmlMenu .="</ul>";
79
  $html .= $htmlMenu .$htmlCont;
 
80
  $html .= "</div>";
81
  echo $html;
82
  }
@@ -87,11 +89,11 @@ if(!class_exists('KcSeoMetaData')):
87
  if (!wp_verify_nonce(@$_REQUEST['_kcseo_nonce'], $KcSeoWPSchema->nonceText())) return $post_id;
88
 
89
  // Check permissions
90
- if (@$_GET['post_type']) {
91
- if (!current_user_can('edit_' . @$_GET['post_type'], $post_id)) return $post_id;
92
  }
93
-
94
- if (!in_array($post->post_type,$KcSeoWPSchema->kcSep_postType) ) return $post_id;
95
 
96
  $meta = array();
97
  $schemaModel = new KcSeoSchemaModel;
@@ -99,14 +101,14 @@ if(!class_exists('KcSeoMetaData')):
99
  $schemaMetaId = $KcSeoWPSchema->KcSeoPrefix.$schemaID;
100
  $data = array();
101
  foreach($schema['fields'] as $fieldId => $fieldData){
102
- $value = (isset($_REQUEST[$schemaMetaId][$fieldId]) ? ($_REQUEST[$schemaMetaId][$fieldId] ? sanitize_text_field($_REQUEST[$schemaMetaId][$fieldId]) : null) : null);
 
 
103
  if($value){
104
  $data[$fieldId] = $value;
105
  }
106
  }
107
- if(!empty($data)){
108
- $meta[$schemaMetaId] = serialize($data);
109
- }
110
  }
111
 
112
  foreach($meta as $mKey => $mValue){
13
  function admin_enqueue_scripts(){
14
  global $pagenow, $typenow, $KcSeoWPSchema;
15
  // validate page
16
+ $pt = $KcSeoWPSchema->kcSeoPostTypes();
17
  if( !in_array( $pagenow, array('post.php', 'post-new.php') ) ) return;
18
+ if(!in_array($typenow, $pt)) return;
19
 
20
  // scripts
21
  wp_enqueue_script(array(
22
  'jquery',
23
+ 'jquery-ui-datepicker',
 
24
  'kcseo-select2-js',
25
  'kcseo-admin-js',
26
  ));
37
 
38
  function admin_head(){
39
  global $KcSeoWPSchema;
40
+ $pt = $KcSeoWPSchema->kcSeoPostTypes();
41
+ foreach($pt as $postType){
42
  add_meta_box(
43
  'kcseo-wordpres-seo-structured-data-schema-meta-box',
44
  __('WP SEO Structured Data Schema by <a href="http://kcseopro.com/">KCSEOPro.com</a>', KCSEO_WP_SCHEMA_SLUG),
62
  $html .= "<p><span>Tip:</span> Once you save these structured data schema settings, validate this page url here: <a href='https://developers.google.com/structured-data/testing-tool/'>https://developers.google.com/structured-data/testing-tool/</a></p>";
63
  $html .="</div>";
64
  $html .= "<div class='schema-holder'>";
65
+ $html .= '<div id="meta-tab-holder" class="rt-tab-container">';
66
  $htmlMenu = null;
67
  $htmlCont = null;
68
+ $htmlMenu .= "<ul class='rt-tab-nav'>";
69
  foreach($schemas->schemaTypes() as $schemaID => $schema){
70
  $tabId = $KcSeoWPSchema->KcSeoPrefix.$schemaID;
71
  $htmlMenu .= '<li><a href="#'.$tabId.'">'.$schema['title'].'</a></li>';
72
+ $htmlCont .="<div id='{$tabId}' class='rt-tab-content'>";
73
  foreach($schema['fields'] as $fieldId => $data){
74
  $data['schemaId'] = $schemaID;
75
  $htmlCont .= $schemas->get_field($fieldId,$data, $post->ID);
78
  }
79
  $htmlMenu .="</ul>";
80
  $html .= $htmlMenu .$htmlCont;
81
+ $html .= "</div>";
82
  $html .= "</div>";
83
  echo $html;
84
  }
89
  if (!wp_verify_nonce(@$_REQUEST['_kcseo_nonce'], $KcSeoWPSchema->nonceText())) return $post_id;
90
 
91
  // Check permissions
92
+ if (!empty($_GET['post_type'])) {
93
+ if (!current_user_can('edit_' . $_GET['post_type'], $post_id)) return $post_id;
94
  }
95
+ $pt = $KcSeoWPSchema->kcSeoPostTypes();
96
+ if (!in_array($post->post_type,$pt) ) return $post_id;
97
 
98
  $meta = array();
99
  $schemaModel = new KcSeoSchemaModel;
101
  $schemaMetaId = $KcSeoWPSchema->KcSeoPrefix.$schemaID;
102
  $data = array();
103
  foreach($schema['fields'] as $fieldId => $fieldData){
104
+
105
+ $value = (!empty($_REQUEST[$schemaMetaId][$fieldId]) ? $_REQUEST[$schemaMetaId][$fieldId] : null);
106
+ $value = $KcSeoWPSchema->sanitize($fieldData, $value);
107
  if($value){
108
  $data[$fieldId] = $value;
109
  }
110
  }
111
+ $meta[$schemaMetaId] = base64_encode(serialize($data));
 
 
112
  }
113
 
114
  foreach($meta as $mKey => $mValue){
lib/classes/KcSeoOutput.php CHANGED
@@ -1,136 +1,149 @@
1
  <?php
2
 
3
- if(!class_exists('KcSeoOutput')):
4
 
5
- class KcSeoOutput
6
- {
7
- function __construct()
8
- {
9
- add_action('wp_footer', array($this,'load_schema'), 1);
10
- }
11
 
12
- function load_schema(){
13
- global $KcSeoWPSchema, $post;
14
- $schemaModel = new KcSeoSchemaModel;
15
- $html = null;
16
- $settings = get_option($KcSeoWPSchema->options['settings']);
17
- if(is_home() || is_front_page()){
18
- $metaData = array();
19
 
20
- $metaData["@context"] = "http://schema.org/";
21
- $metaData["@type"] = "WebSite";
22
 
23
- if($settings['homeonly']){
24
- $author_url = ($settings['siteurl'] ? $settings['siteurl'] : get_home_url());
25
- $to_remove = array( 'http://', 'https://','www.' );
26
- foreach ( $to_remove as $item ) {
27
- $author_url = str_replace($item, '', $author_url); // to: www.example.com
28
- }
29
- $metaData["url"] = $author_url;
30
- $metaData["name"] = $settings['sitename'];
31
- $metaData["alternateName"] = $settings['siteaname'];
32
- $html .= $schemaModel->get_jsonEncode($metaData);
33
- }else{
34
- $metaData["url"] = get_home_url();
35
- $metaData["potentialAction"] = array(
36
- "@type" => "SearchAction",
37
- "target" => get_home_url() ."/?s={query}",
38
- "query-input" => "required name=query"
39
- );
40
- $html .= $schemaModel->get_jsonEncode($metaData);
41
- }
42
- }
 
 
 
 
43
 
44
- $webMeta = array();
45
- $webMeta["@context"] = "http://schema.org";
46
- $webMeta["@type"] = esc_attr($settings['site_type']);
 
 
 
 
 
 
 
47
 
48
- if($settings['additionalType']){
49
- $aType = explode("\r\n", $settings['additionalType']);
50
- if(!empty($aType) && is_array($aType)){
51
- if(count($aType) == 1){
52
- $webMeta["additionalType"] = $aType[0];
53
- }else if(count($aType) > 1){
54
- $webMeta["additionalType"] = $aType;
55
- }
56
- }
57
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
59
- if(esc_attr($settings['site_type']) == 'Person'){
60
- $webMeta["name"] = esc_attr( $settings['person']['name']);
61
- $webMeta["worksFor"] = esc_attr( $settings['person']['worksFor']);
62
- $webMeta["jobTitle"] = esc_attr( $settings['person']['jobTitle']);
63
- $webMeta["image"] = esc_attr( $settings['person']['image']);
64
- $webMeta["description"] = esc_attr( $settings['person']['description']);
65
- $webMeta["birthDate"] = esc_attr( $settings['person']['birthDate']);
66
- }else{
67
- $webMeta["name"] = esc_attr($settings['type_name']);
68
- $webMeta["logo"] = esc_attr( $settings['logo_url'] );
69
- }
70
- if(esc_attr($settings['site_type']) != "Organization" && esc_attr($settings['site_type']) != "Person"){
71
- $webMeta["description"] = esc_attr( $settings['business_info']['description'] );
72
- if($settings['business_info']['openingHours']){
73
- $aOhour = explode("\r\n", $settings['business_info']['openingHours']);
74
- if(!empty($aOhour) && is_array($aOhour)){
75
- if(count($aOhour) == 1){
76
- $webMeta["openingHours"] = $aOhour[0];
77
- }else if(count($aOhour) > 1){
78
- $webMeta["openingHours"] = $aOhour;
79
- }
80
- }
81
- }
82
- $webMeta["geo"] = array(
83
- "@type" => "GeoCoordinates",
84
- "longitude" => esc_attr( $settings['business_info']['longitude'] ),
85
- "latitude" => esc_attr( $settings['business_info']['latitude'] )
86
- );
87
- }
88
 
89
- $webMeta["url"] = esc_attr( $settings['web_url']);
90
- if(!empty($settings['social']) && is_array($settings['social'])){
91
- $link = array();
92
- foreach ($settings['social'] as $socialD) {
93
- if($socialD['link']){
94
- $link[] = $socialD['link'];
95
- }
96
- }
97
- if(!empty($link)){
98
- $webMeta["sameAs"] = $link;
99
- }
100
- }
 
 
 
 
 
 
 
 
 
101
 
102
- $webMeta["contactPoint"] = array(
103
- "@type" => "ContactPoint",
104
- "telephone" => esc_attr( $settings['contact']['telephone']),
105
- "contactType" => esc_attr( $settings['contact']['contactType']),
106
- "contactOption" => esc_attr( $settings['contact']['contactOption']),
107
- "areaServed" => esc_attr( @implode(',',$settings['area_served'])),
108
- "availableLanguage" => esc_attr( $settings['availableLanguage'])
109
- );
110
- $webMeta["address"] = array(
111
- "@type" => "PostalAddress",
112
- "addressCountry" => esc_attr($settings['address']['country']),
113
- "addressLocality" => esc_attr($settings['address']['locality']),
114
- "addressRegion" => esc_attr($settings['address']['region']),
115
- "postalCode" => esc_attr($settings['address']['postalcode']),
116
- "streetAddress" => esc_attr($settings['address']['street'])
117
- );
118
- if($webMeta["@type"]) {
119
- $html .= $schemaModel->get_jsonEncode($webMeta);
120
- }
121
 
122
- if(is_single() || is_page()){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
 
124
- foreach($schemaModel->schemaTypes() as $schemaID => $schema){
125
- $schemaMetaId = $KcSeoWPSchema->KcSeoPrefix.$schemaID;
126
- $metaData = unserialize(get_post_meta($post->ID, $schemaMetaId, true ));
127
- $firstItem = @current($metaData);
128
- if(!empty($metaData) && is_array($metaData) && isset($firstItem)){
129
- $html .= $schemaModel->schemaOutput($schemaID, $metaData);
130
- }
131
- }
132
- }
133
- echo $html;
134
- }
135
- }
136
  endif;
1
  <?php
2
 
3
+ if ( ! class_exists( 'KcSeoOutput' ) ):
4
 
5
+ class KcSeoOutput {
6
+ function __construct() {
7
+ add_action( 'wp_footer', array( $this, 'load_schema' ), 1 );
8
+ }
 
 
9
 
10
+ function load_schema() {
11
+ global $KcSeoWPSchema, $post;
12
+ $schemaModel = new KcSeoSchemaModel;
13
+ $html = null;
14
+ $settings = get_option( $KcSeoWPSchema->options['settings'] );
15
+ if ( is_home() || is_front_page() ) {
16
+ $metaData = array();
17
 
18
+ $metaData["@context"] = "http://schema.org/";
19
+ $metaData["@type"] = "WebSite";
20
 
21
+ if ( ! empty( $settings['homeonly'] ) ) {
22
+ $author_url = ( ! empty( $settings['siteurl'] ) ? $settings['siteurl'] : get_home_url() );
23
+ $to_remove = array( 'http://', 'https://', 'www.' );
24
+ foreach ( $to_remove as $item ) {
25
+ $author_url = str_replace( $item, '', $author_url ); // to: www.example.com
26
+ }
27
+ $metaData["url"] = $KcSeoWPSchema->sanitizeOutPut( $author_url, 'url' );
28
+ $metaData["name"] = ! empty( $settings['sitename'] ) ? $KcSeoWPSchema->sanitizeOutPut( $settings['sitename'] ) : null;
29
+ $metaData["alternateName"] = ! empty( $settings['siteaname'] ) ? $KcSeoWPSchema->sanitizeOutPut( $settings['siteaname'] ) : null;
30
+ $html .= $schemaModel->get_jsonEncode( $metaData );
31
+ } else {
32
+ $metaData["url"] = get_home_url();
33
+ $metaData["potentialAction"] = array(
34
+ "@type" => "SearchAction",
35
+ "target" => get_home_url() . "/?s={query}",
36
+ "query-input" => "required name=query"
37
+ );
38
+ $html .= $schemaModel->get_jsonEncode( $metaData );
39
+ }
40
+ }
41
+ $webMeta = array();
42
+ $webMeta["@context"] = "http://schema.org";
43
+ $siteType = ! empty( $settings['site_type'] ) ? $KcSeoWPSchema->sanitizeOutPut( $settings['site_type'] ) : null;
44
+ $webMeta["@type"] = $siteType;
45
 
46
+ if ( ! empty( $settings['additionalType'] ) ) {
47
+ $aType = explode( "\r\n", $settings['additionalType'] );
48
+ if ( ! empty( $aType ) && is_array( $aType ) ) {
49
+ if ( count( $aType ) == 1 ) {
50
+ $webMeta["additionalType"] = $aType[0];
51
+ } else if ( count( $aType ) > 1 ) {
52
+ $webMeta["additionalType"] = $aType;
53
+ }
54
+ }
55
+ }
56
 
57
+ if ( $siteType == 'Person' ) {
58
+ $webMeta["name"] = ! empty( $settings['person']['name'] ) ? $KcSeoWPSchema->sanitizeOutPut( $settings['person']['name'] ) : null;
59
+ $webMeta["worksFor"] = ! empty( $settings['person']['worksFor'] ) ? $KcSeoWPSchema->sanitizeOutPut( $settings['person']['worksFor'] ) : null;
60
+ $webMeta["jobTitle"] = ! empty( $settings['person']['jobTitle'] ) ? $KcSeoWPSchema->sanitizeOutPut( $settings['person']['jobTitle'] ) : null;
61
+ $webMeta["image"] = ! empty( $settings['person']['image'] ) ? $KcSeoWPSchema->sanitizeOutPut( $settings['person']['image'], 'url' ) : null;
62
+ $webMeta["description"] = ! empty( $settings['person']['description'] ) ? $KcSeoWPSchema->sanitizeOutPut( $settings['person']['description'], 'textarea' ) : null;
63
+ $webMeta["birthDate"] = ! empty( $settings['person']['birthDate'] ) ? $KcSeoWPSchema->sanitizeOutPut( $settings['person']['birthDate'] ) : null;
64
+ } else {
65
+ $webMeta["name"] = ! empty( $settings['type_name'] ) ? $KcSeoWPSchema->sanitizeOutPut( $settings['type_name'] ) : null;
66
+ $webMeta["logo"] = ! empty( $settings['logo_url'] ) ? $KcSeoWPSchema->sanitizeOutPut( $settings['logo_url'], 'url' ) : null;
67
+ }
68
+ if ( $siteType != "Organization" && $siteType != "Person" ) {
69
+ $webMeta["description"] = ! empty( $settings['business_info']['description'] ) ? $KcSeoWPSchema->sanitizeOutPut( $settings['business_info']['description'], 'textarea' ) : null;
70
+ if ( ! empty( $settings['business_info']['openingHours'] ) ) {
71
+ $aOhour = explode( "\r\n", $settings['business_info']['openingHours'] );
72
+ if ( ! empty( $aOhour ) && is_array( $aOhour ) ) {
73
+ if ( count( $aOhour ) == 1 ) {
74
+ $webMeta["openingHours"] = $aOhour[0];
75
+ } else if ( count( $aOhour ) > 1 ) {
76
+ $webMeta["openingHours"] = $aOhour;
77
+ }
78
+ }
79
+ }
80
+ $webMeta["geo"] = array(
81
+ "@type" => "GeoCoordinates",
82
+ "longitude" => ! empty( $settings['business_info']['longitude'] ) ? $KcSeoWPSchema->sanitizeOutPut( $settings['business_info']['longitude'] ) : null,
83
+ "latitude" => ! empty( $settings['business_info']['latitude'] ) ? $KcSeoWPSchema->sanitizeOutPut( $settings['business_info']['latitude'] ) : null
84
+ );
85
+ }
86
 
87
+ $webMeta["url"] = ! empty( $settings['web_url'] ) ? $KcSeoWPSchema->sanitizeOutPut( $settings['web_url'], 'url' ) : $KcSeoWPSchema->sanitizeOutPut( get_home_url(), 'url');
88
+ if ( ! empty( $settings['social'] ) && is_array( $settings['social'] ) ) {
89
+ $link = array();
90
+ foreach ( $settings['social'] as $socialD ) {
91
+ if ( $socialD['link'] ) {
92
+ $link[] = $socialD['link'];
93
+ }
94
+ }
95
+ if ( ! empty( $link ) ) {
96
+ $webMeta["sameAs"] = $link;
97
+ }
98
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
 
100
+ $webMeta["contactPoint"] = array(
101
+ "@type" => "ContactPoint",
102
+ "telephone" => ! empty( $settings['contact']['telephone'] ) ? $KcSeoWPSchema->sanitizeOutPut( $settings['contact']['telephone'] ) : '',
103
+ "contactType" => ! empty( $settings['contact']['contactType'] ) ? $KcSeoWPSchema->sanitizeOutPut( $settings['contact']['contactType'] ) : '',
104
+ "contactOption" => ! empty( $settings['contact']['contactOption'] ) ? $KcSeoWPSchema->sanitizeOutPut( $settings['contact']['contactOption'] ) : '',
105
+ "areaServed" => ! empty( $settings['area_served'] ) ? implode( ',',
106
+ ! empty( $settings['area_served'] ) ? $settings['area_served'] : array() ) : '',
107
+ "availableLanguage" => ! empty( $settings['availableLanguage'] ) ? @implode( ',',
108
+ ! empty( $settings['availableLanguage'] ) ? $settings['availableLanguage'] : array() ) : null
109
+ );
110
+ $webMeta["address"] = array(
111
+ "@type" => "PostalAddress",
112
+ "addressCountry" => ! empty( $settings['address']['country'] ) ? $KcSeoWPSchema->sanitizeOutPut( $settings['address']['country'] ) : null,
113
+ "addressLocality" => ! empty( $settings['address']['locality'] ) ? $KcSeoWPSchema->sanitizeOutPut( $settings['address']['locality'] ) : null,
114
+ "addressRegion" => ! empty( $settings['address']['region'] ) ? $KcSeoWPSchema->sanitizeOutPut( $settings['address']['region'] ) : null,
115
+ "postalCode" => ! empty( $settings['address']['postalcode'] ) ? $KcSeoWPSchema->sanitizeOutPut( $settings['address']['postalcode'] ) : null,
116
+ "streetAddress" => ! empty( $settings['address']['street'] ) ? $KcSeoWPSchema->sanitizeOutPut( $settings['address']['street'] ) : null
117
+ );
118
+ if ( $webMeta["@type"] ) {
119
+ $html .= $schemaModel->get_jsonEncode( $webMeta );
120
+ }
121
 
122
+ if ( is_single() || is_page() ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
 
124
+ foreach ( $schemaModel->schemaTypes() as $schemaID => $schema ) {
125
+ $schemaMetaId = $KcSeoWPSchema->KcSeoPrefix . $schemaID;
126
+ $getRawMeta = get_post_meta( $post->ID, $schemaMetaId, true );
127
+ $metaData = array();
128
+ if ( ! empty( $getRawMeta ) ) {
129
+ if ( $KcSeoWPSchema->isValidBase64( $getRawMeta ) ) {
130
+ $metaData = unserialize( base64_decode( $getRawMeta ) );
131
+ } else {
132
+ $metaData = unserialize( $getRawMeta );
133
+ }
134
+ }
135
+ $metaData = ( ! empty( $metaData ) ? $metaData : array() );
136
+ $firstItem = null;
137
+ if ( ! empty( $metaData ) && is_array( $metaData ) ) {
138
+ $firstItem = current( $metaData );
139
+ }
140
 
141
+ if ( ! empty( $metaData ) && is_array( $metaData ) && $firstItem ) {
142
+ $html .= $schemaModel->schemaOutput( $schemaID, $metaData );
143
+ }
144
+ }
145
+ }
146
+ echo $html;
147
+ }
148
+ }
 
 
 
 
149
  endif;
lib/init.php CHANGED
@@ -6,12 +6,11 @@ if(!class_exists('KcSeoWPSchema')){
6
  {
7
  public $options;
8
  public $KcSeoPrefix;
9
- public $kcSep_postType = array();
10
  function __construct() {
11
  $this->KcSeoPrefix = "_schema_";
12
  $this->options = array(
13
  'settings' => 'kcseo_wp_schema',
14
- 'version' => '1.1'
15
  );
16
 
17
  $this->incPath = dirname(__FILE__);
@@ -20,7 +19,6 @@ if(!class_exists('KcSeoWPSchema')){
20
  $this->viewsPath = $this->incPath . '/views/';
21
  $this->assetsUrl = KCSEO_WP_SCHEMA_URL . '/assets/';
22
  $this->modelPath = $this->incPath . '/models/';
23
- $this->kcSep_postType = $this->kcSeoPostTypes();
24
 
25
  $this->KeSeoLoadFunctions($this->functionsPath);
26
  $this->KcSeoLoadModel($this->modelPath);
@@ -31,25 +29,9 @@ if(!class_exists('KcSeoWPSchema')){
31
 
32
  }
33
 
34
-
35
- function kcSeoPostTypes(){
36
- $post_types = get_post_types(
37
- array(
38
- '_builtin' => true
39
- )
40
- );
41
- $exclude = array( 'attachment', 'revision', 'nav_menu_item' );
42
- foreach($exclude as $ex){
43
- unset($post_types[$ex]);
44
- }
45
- return $post_types;
46
- }
47
-
48
  function KcSeoLoadClass($dir) {
49
  if (!file_exists($dir)) return;
50
-
51
  $classes = array();
52
-
53
  foreach (scandir($dir) as $item) {
54
  if (preg_match("/.php$/i", $item)) {
55
  require_once ($dir . $item);
6
  {
7
  public $options;
8
  public $KcSeoPrefix;
 
9
  function __construct() {
10
  $this->KcSeoPrefix = "_schema_";
11
  $this->options = array(
12
  'settings' => 'kcseo_wp_schema',
13
+ 'version' => '1.2'
14
  );
15
 
16
  $this->incPath = dirname(__FILE__);
19
  $this->viewsPath = $this->incPath . '/views/';
20
  $this->assetsUrl = KCSEO_WP_SCHEMA_URL . '/assets/';
21
  $this->modelPath = $this->incPath . '/models/';
 
22
 
23
  $this->KeSeoLoadFunctions($this->functionsPath);
24
  $this->KcSeoLoadModel($this->modelPath);
29
 
30
  }
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  function KcSeoLoadClass($dir) {
33
  if (!file_exists($dir)) return;
 
34
  $classes = array();
 
35
  foreach (scandir($dir) as $item) {
36
  if (preg_match("/.php$/i", $item)) {
37
  require_once ($dir . $item);
lib/models/KcSeoSchemaModel.php CHANGED
@@ -12,26 +12,27 @@ if(!class_exists('KcSeoSchemaModel')):
12
  $html = null;
13
 
14
  if($schemaID){
 
15
  switch($schemaID){
16
  case "article":
17
  $article = array();
18
  $article["@context"] = "http://schema.org";
19
  $article["@type"] = "Article";
20
- if($metaData['headline']){
21
- $article["headline"] = esc_attr($metaData['headline']);
22
- }if($metaData['mainEntityOfPage']){
23
  $article["mainEntityOfPage"] = array(
24
  "@type" => "WebPage",
25
- "@id" => esc_attr($article["mainEntityOfPage"])
26
  );
27
- }if($metaData['author']){
28
- $article["author"] = esc_attr($metaData['author']);
29
- }if($metaData['publisher']){
30
- if($metaData['publisherImage']){
31
  $img = $this->imgInfo($metaData['publisherImage']);
32
  $plA = array(
33
  "@type" => "ImageObject",
34
- "url" => esc_attr($metaData['publisherImage']),
35
  "height" => intval($img['height']),
36
  "width" => intval($img['width']),
37
  );
@@ -40,27 +41,27 @@ if(!class_exists('KcSeoSchemaModel')):
40
  }
41
  $article["publisher"] = array(
42
  "@type" => "Organization",
43
- "name" => esc_attr($metaData['publisher']),
44
  "logo" => $plA
45
  );
46
- }if($metaData['alternativeHeadline']){
47
- $article["alternativeHeadline"] = esc_attr($metaData['alternativeHeadline']);
48
- }if($metaData['image']){
49
  $img = $this->imgInfo($metaData['image']);
50
  $article["image"] = array(
51
  "@type" => "ImageObject",
52
- "url" => esc_attr($metaData['image']),
53
  "height" => $img['height'],
54
  "width" =>$img['width']
55
  );
56
- }if($metaData['datePublished']){
57
- $article["datePublished"] = esc_attr($metaData['datePublished']);
58
- }if($metaData['dateModified']){
59
- $article["dateModified"] = esc_attr($metaData['dateModified']);
60
- }if($metaData['description']){
61
- $article["description"] = esc_attr($metaData['description']);
62
- }if($metaData['articleBody']){
63
- $article["articleBody"] = esc_attr($metaData['articleBody']);
64
  }
65
  $html .= $this->get_jsonEncode($article);
66
  break;
@@ -69,33 +70,33 @@ if(!class_exists('KcSeoSchemaModel')):
69
  $newsArticle = array();
70
  $newsArticle["@context"] = "http://schema.org";
71
  $newsArticle["@type"] = "NewsArticle";
72
- if($metaData['headline']){
73
- $newsArticle["headline"] = esc_attr($metaData['headline']);
74
- }if($metaData['mainEntityOfPage']){
75
  $newsArticle["mainEntityOfPage"] = array(
76
  "@type" => "WebPage",
77
- "@id" => esc_attr($metaData["mainEntityOfPage"])
78
  );
79
- }if($metaData['author']){
80
- $newsArticle["author"] = esc_attr($metaData['author']);
81
- }if($metaData['image']){
82
  $img = $this->imgInfo($metaData['image']);
83
  $newsArticle["image"] = array(
84
  "@type" => "ImageObject",
85
- "url" => esc_attr($metaData['image']),
86
  "height" => $img['height'],
87
  "width" =>$img['width']
88
  );
89
- }if($metaData['datePublished']){
90
- $newsArticle["datePublished"] = esc_attr($metaData['datePublished']);
91
- }if($metaData['dateModified']){
92
- $newsArticle["dateModified"] = esc_attr($metaData['dateModified']);
93
- }if($metaData['publisher']){
94
- if($metaData['publisherImage']){
95
  $img = $this->imgInfo($metaData['publisherImage']);
96
  $plA = array(
97
  "@type" => "ImageObject",
98
- "url" => esc_attr($metaData['publisherImage']),
99
  "height" => intval($img['height']),
100
  "width" => intval($img['width']),
101
  );
@@ -104,13 +105,13 @@ if(!class_exists('KcSeoSchemaModel')):
104
  }
105
  $newsArticle["publisher"] = array(
106
  "@type" => "Organization",
107
- "name" => esc_attr($metaData['publisher']),
108
  "logo" => $plA
109
  );
110
- }if($metaData['description']){
111
- $newsArticle["description"] = esc_attr($metaData['description']);
112
- }if($metaData['articleBody']){
113
- $newsArticle["articleBody"] = esc_attr($metaData['articleBody']);
114
  }
115
  $html .= $this->get_jsonEncode($newsArticle);
116
  break;
@@ -119,33 +120,33 @@ if(!class_exists('KcSeoSchemaModel')):
119
  $blogPosting = array();
120
  $blogPosting["@context"] = "http://schema.org";
121
  $blogPosting["@type"] = "BlogPosting";
122
- if($metaData['headline']){
123
- $blogPosting["headline"] = esc_attr($metaData['headline']);
124
- }if($metaData['mainEntityOfPage']){
125
  $blogPosting["mainEntityOfPage"] = array(
126
  "@type" => "WebPage",
127
- "@id" => esc_attr($metaData["mainEntityOfPage"])
128
  );
129
- }if($metaData['author']){
130
- $blogPosting["author"] = esc_attr($metaData['author']);
131
- }if($metaData['image']){
132
  $img = $this->imgInfo($metaData['image']);
133
  $blogPosting["image"] = array(
134
  "@type" => "ImageObject",
135
- "url" => esc_attr($metaData['image']),
136
  "height" => $img['height'],
137
  "width" =>$img['width']
138
  );
139
- }if($metaData['datePublished']){
140
- $blogPosting["datePublished"] = esc_attr($metaData['datePublished']);
141
- }if($metaData['dateModified']){
142
- $blogPosting["dateModified"] = esc_attr($metaData['dateModified']);
143
- }if($metaData['publisher']){
144
  if($metaData['publisherImage']){
145
  $img = $this->imgInfo($metaData['publisherImage']);
146
  $plA = array(
147
  "@type" => "ImageObject",
148
- "url" => esc_attr($metaData['publisherImage']),
149
  "height" => intval($img['height']),
150
  "width" => intval($img['width']),
151
  );
@@ -154,13 +155,13 @@ if(!class_exists('KcSeoSchemaModel')):
154
  }
155
  $blogPosting["publisher"] = array(
156
  "@type" => "Organization",
157
- "name" => esc_attr($metaData['publisher']),
158
  "logo" => $plA
159
  );
160
- }if($metaData['description']){
161
- $blogPosting["description"] = esc_attr($metaData['description']);
162
- }if($metaData['articleBody']){
163
- $blogPosting["articleBody"] = esc_attr($metaData['articleBody']);
164
  }
165
  $html .= $this->get_jsonEncode($blogPosting);
166
  break;
@@ -169,22 +170,22 @@ if(!class_exists('KcSeoSchemaModel')):
169
  $event = array();
170
  $event["@context"] = "http://schema.org";
171
  $event["@type"] = "Event";
172
- if($metaData['name']){
173
- $event["name"] = esc_attr($metaData['name']);
174
- }if($metaData['startDate']){
175
- $event["startDate"] = esc_attr($metaData['startDate']);
176
- }if($metaData['locationName']){
177
  $event["location"] = array(
178
  "@type" => "Place",
179
- "name" => esc_attr($metaData['locationName']),
180
- "address" => esc_attr($metaData['locationAddress'])
181
  );
182
- }if($metaData['price']){
183
  $event["offers"] = array(
184
  "@type" => "Offer",
185
- "price" => esc_attr($metaData['price']),
186
- "priceCurrency" => esc_attr($metaData['priceCurrency']),
187
- "url" => esc_attr($metaData['url'])
188
  );
189
  }
190
  $html .= $this->get_jsonEncode($event);
@@ -194,31 +195,36 @@ if(!class_exists('KcSeoSchemaModel')):
194
  $product = array();
195
  $product["@context"] = "http://schema.org";
196
  $product["@type"] = "Product";
197
- if($metaData['name']){
198
- $product["name"] = esc_attr($metaData['name']);
199
- }if($metaData['image']){
200
- $product["image"] = esc_attr($metaData['image']);
201
- }if($metaData['description']){
202
- $product["description"] = esc_attr($metaData['description']);
203
- }if($metaData['brand']){
 
 
 
204
  $product["brand"] = array(
205
  "@type" => "Thing",
206
- "name" => esc_attr($metaData['name'])
207
  );
208
- }if($metaData['ratingValue']){
 
209
  $product["aggregateRating"] = array(
210
  "@type" => "AggregateRating",
211
- "ratingValue" => esc_attr($metaData['ratingValue']),
212
- "reviewCount" => esc_attr($metaData['reviewCount'])
213
  );
214
- }if($metaData['price']){
 
215
  $product["offers"] = array(
216
  "@type" => "Offer",
217
- "price" => esc_attr($metaData['price']),
218
- "priceCurrency" => esc_attr($metaData['priceCurrency']),
219
- "itemCondition" => esc_attr($metaData['itemCondition']),
220
- "availability" => esc_attr($metaData['availability']),
221
- "url" => esc_attr($metaData['url'])
222
  );
223
  }
224
  $html .= $this->get_jsonEncode($product);
@@ -228,24 +234,24 @@ if(!class_exists('KcSeoSchemaModel')):
228
  $video = array();
229
  $video["@context"] = "http://schema.org";
230
  $video["@type"] = "VideoObject";
231
- if($metaData['name']){
232
- $video["name"] = esc_attr($metaData['name']);
233
- }if($metaData['description']){
234
- $video["description"] = esc_attr($metaData['description']);
235
- }if($metaData['description']){
236
- $video["description"] = esc_attr($metaData['description']);
237
- }if($metaData['thumbnailUrl']){
238
- $video["thumbnailUrl"] = esc_attr($metaData['thumbnailUrl']);
239
- }if($metaData['uploadDate']){
240
- $video["uploadDate"] = esc_attr($metaData['uploadDate']);
241
- }if($metaData['duration']){
242
- $video["duration"] = esc_attr($metaData['duration']);
243
- }if($metaData['contentUrl']){
244
- $video["contentUrl"] = esc_attr($metaData['contentUrl']);
245
- }if($metaData['interactionCount']){
246
- $video["interactionCount"] = esc_attr($metaData['interactionCount']);
247
- }if($metaData['expires']){
248
- $video["expires"] = esc_attr($metaData['expires']);
249
  }
250
  $html .= $this->get_jsonEncode($video);
251
  break;
@@ -254,34 +260,34 @@ if(!class_exists('KcSeoSchemaModel')):
254
  $service = array();
255
  $service["@context"] = "http://schema.org";
256
  $service["@type"] = "Service";
257
- if($metaData['name']){
258
- $service["name"] = esc_attr($metaData['name']);
259
- }if($metaData['serviceType']){
260
- $service["serviceType"] = esc_attr($metaData['serviceType']);
261
- }if($metaData['locationName']){
262
  $service["location"] = array(
263
  "@type" => "Place",
264
- "name" => esc_attr($metaData['locationName']),
265
- "address" => esc_attr($metaData['locationAddress'])
266
  );
267
- }if($metaData['award']){
268
- $service["award"] = esc_attr($metaData['award']);
269
- }if($metaData['category']){
270
- $service["category"] = esc_attr($metaData['category']);
271
- }if($metaData['providerMobility']){
272
- $service["providerMobility"] = esc_attr($metaData['providerMobility']);
273
- }if($metaData['additionalType']){
274
- $service["additionalType"] = esc_attr($metaData['additionalType']);
275
- }if($metaData['alternateName']){
276
- $service["alternateName"] = esc_attr($metaData['alternateName']);
277
- }if($metaData['image']){
278
- $service["image"] = esc_attr($metaData['image']);
279
- }if($metaData['mainEntityOfPage']){
280
- $service["mainEntityOfPage"] = esc_attr($metaData['mainEntityOfPage']);
281
- }if($metaData['sameAs']){
282
- $service["sameAs"] = esc_attr($metaData['sameAs']);
283
- }if($metaData['url']){
284
- $service["url"] = esc_attr($metaData['url']);
285
  }
286
  $html .= $this->get_jsonEncode($service);
287
  break;
@@ -290,33 +296,33 @@ if(!class_exists('KcSeoSchemaModel')):
290
  $review = array();
291
  $review["@context"] = "http://schema.org";
292
  $review["@type"] = "Review";
293
- if($metaData['itemName']){
294
  $review["itemReviewed"] = array(
295
  "@type" => "Thing",
296
- "name" => esc_attr($metaData['itemName'])
297
  );
298
- }if($metaData['ratingValue']){
299
  $review["reviewRating"] = array(
300
  "@type" => "Rating",
301
- "ratingValue" => esc_attr($metaData['ratingValue']),
302
- "bestRating" => esc_attr($metaData['bestRating']),
303
- "worstRating" => esc_attr($metaData['worstRating'])
304
  );
305
- }if($metaData['name']){
306
- $review["name"] = esc_attr($metaData['name']);
307
- }if($metaData['author']){
308
  $review["author"] = array(
309
  "@type" => "Person",
310
- "name" => esc_attr($metaData['author'])
311
  );
312
- }if($metaData['reviewBody']){
313
- $review["reviewBody"] = esc_attr($metaData['reviewBody']);
314
- }if($metaData['datePublished']){
315
- $review["datePublished"] = esc_attr($metaData['datePublished']);
316
- }if($metaData['publisher']){
317
  $review["publisher"] = array(
318
  "@type" => "Organization",
319
- "name" => esc_attr($metaData['publisher'])
320
  );
321
  }
322
  $html .= $this->get_jsonEncode($review);
@@ -324,21 +330,21 @@ if(!class_exists('KcSeoSchemaModel')):
324
  case 'aggregate_rating':
325
  $aRating = array();
326
  $aRating["@context"] = "http://schema.org";
327
- $aRating["@type"] = "Thing";
328
- if($metaData['name']){
329
- $aRating["name"] = esc_attr($metaData['name']);
330
- }if($metaData['description']){
331
- $aRating["description"] = esc_attr($metaData['description']);
332
- }if($metaData['ratingValue']){
333
  $rValue = array();
334
  $rValue["@type"] = "AggregateRating";
335
- $rValue["ratingValue"] = esc_attr($metaData['ratingValue']);
336
- if($metaData['bestRating']){
337
- $rValue["bestRating"] = esc_attr($metaData['bestRating']);
338
- }if($metaData['worstRating']){
339
- $rValue["worstRating"] = esc_attr($metaData['worstRating']);
340
- }if($metaData['ratingCount']){
341
- $rValue["ratingCount"] = esc_attr($metaData['ratingCount']);
342
  }
343
 
344
  $aRating["aggregateRating"] = $rValue;
@@ -361,8 +367,18 @@ if(!class_exists('KcSeoSchemaModel')):
361
  $schemaId = $KcSeoWPSchema->KcSeoPrefix.$data['schemaId'];
362
  $id = $KcSeoWPSchema->KcSeoPrefix.$data['schemaId']."_".$fieldId;
363
  $name = $schemaId."[{$fieldId}]";
364
- $metaData = ( get_post_meta($pid, $schemaId, true ) ? unserialize(get_post_meta($pid, $schemaId, true )) : array());
365
- $value = (isset($metaData[$fieldId]) ? ($metaData[$fieldId] ? esc_attr($metaData[$fieldId]) : null) : null);
 
 
 
 
 
 
 
 
 
 
366
  $class = isset($data['class']) ? ($data['class'] ? $data['class'] : null) : null;
367
  $require = (isset($data['required']) ? ($data['required'] ? "<span class='required'>*</span>" : null ) : null);
368
  $title = (isset($data['title']) ? ($data['title'] ? $data['title'] : null ) : null);
@@ -387,11 +403,22 @@ if(!class_exists('KcSeoSchemaModel')):
387
  $html .= "<textarea id='{$id}' class='{$class}' name='{$name}' >{$value}</textarea>";
388
  break;
389
  case 'select':
390
- $html .="<select name='{$name}' class='{$class}' id='{$id}'>";
391
- $html .="<option value=''>Select {$title}</option>";
392
- foreach($data['options'] as $optKey =>$optValue){
393
- $slt = ($optKey == $value ? "selected" : null);
394
- $html .="<option value='{$optKey}' {$slt}>{$optValue}</option>";
 
 
 
 
 
 
 
 
 
 
 
395
  }
396
  $html .="</select>";
397
  break;
@@ -504,7 +531,7 @@ if(!class_exists('KcSeoSchemaModel')):
504
  'image' => array(
505
  'title' => 'Image URL',
506
  'type' => 'url',
507
- 'desc' => 'Image url',
508
  'required' => true
509
  ),
510
  'datePublished' => array(
@@ -703,6 +730,7 @@ if(!class_exists('KcSeoSchemaModel')):
703
  'availability' => array(
704
  'title' => 'Availability',
705
  'type' => 'select',
 
706
  'options' => array(
707
  'http://schema.org/InStock' => 'InStock',
708
  'http://schema.org/InStoreOnly' => 'InStoreOnly',
@@ -718,6 +746,7 @@ if(!class_exists('KcSeoSchemaModel')):
718
  'itemCondition' => array(
719
  'title' => 'Product condition',
720
  'type' => 'select',
 
721
  'options' => array(
722
  'http://schema.org/NewCondition' => 'NewCondition',
723
  'http://schema.org/UsedCondition' => 'UsedCondition',
@@ -933,8 +962,16 @@ if(!class_exists('KcSeoSchemaModel')):
933
  'aggregate_rating' => array(
934
  'title' => 'Aggregate Ratings',
935
  'fields' => array(
 
 
 
 
 
 
 
 
936
  'name' => array(
937
- 'title' => 'Name (Think)',
938
  'type' => 'text',
939
  'required' => true,
940
  'desc' => "The item that is being rated."
@@ -1352,7 +1389,7 @@ if(!class_exists('KcSeoSchemaModel')):
1352
  "Billing Support",
1353
  "Bill Payment",
1354
  "Sales",
1355
- "Reservation",
1356
  "Credit Card Support",
1357
  "Emergency",
1358
  "Baggage Tracking",
@@ -1483,13 +1520,23 @@ if(!class_exists('KcSeoSchemaModel')):
1483
  function imgInfo($url = null){
1484
  $img = array();
1485
  if($url){
1486
- $imgA = getimagesize($url);
1487
-
1488
- $img['width'] = $imgA[0];
1489
- $img['height'] = $imgA[1];
 
 
 
 
1490
  }
1491
  return $img;
1492
  }
 
 
 
 
 
 
1493
 
1494
  }
1495
  endif;
12
  $html = null;
13
 
14
  if($schemaID){
15
+ global $KcSeoWPSchema;
16
  switch($schemaID){
17
  case "article":
18
  $article = array();
19
  $article["@context"] = "http://schema.org";
20
  $article["@type"] = "Article";
21
+ if(!empty($metaData['headline'])){
22
+ $article["headline"] = $KcSeoWPSchema->sanitizeOutPut($metaData['headline']);
23
+ }if(!empty($metaData['mainEntityOfPage'])){
24
  $article["mainEntityOfPage"] = array(
25
  "@type" => "WebPage",
26
+ "@id" => $KcSeoWPSchema->sanitizeOutPut($metaData["mainEntityOfPage"])
27
  );
28
+ }if(!empty($metaData['author'])){
29
+ $article["author"] = $KcSeoWPSchema->sanitizeOutPut($metaData['author']);
30
+ }if(!empty($metaData['publisher'])){
31
+ if(!empty($metaData['publisherImage'])){
32
  $img = $this->imgInfo($metaData['publisherImage']);
33
  $plA = array(
34
  "@type" => "ImageObject",
35
+ "url" => $KcSeoWPSchema->sanitizeOutPut($metaData['publisherImage'], 'url'),
36
  "height" => intval($img['height']),
37
  "width" => intval($img['width']),
38
  );
41
  }
42
  $article["publisher"] = array(
43
  "@type" => "Organization",
44
+ "name" => $KcSeoWPSchema->sanitizeOutPut($metaData['publisher']),
45
  "logo" => $plA
46
  );
47
+ }if(!empty($metaData['alternativeHeadline'])){
48
+ $article["alternativeHeadline"] = $KcSeoWPSchema->sanitizeOutPut($metaData['alternativeHeadline']);
49
+ }if(!empty($metaData['image'])){
50
  $img = $this->imgInfo($metaData['image']);
51
  $article["image"] = array(
52
  "@type" => "ImageObject",
53
+ "url" => $KcSeoWPSchema->sanitizeOutPut($metaData['image']),
54
  "height" => $img['height'],
55
  "width" =>$img['width']
56
  );
57
+ }if(!empty($metaData['datePublished'])){
58
+ $article["datePublished"] = $KcSeoWPSchema->sanitizeOutPut($metaData['datePublished']);
59
+ }if(!empty($metaData['dateModified'])){
60
+ $article["dateModified"] = $KcSeoWPSchema->sanitizeOutPut($metaData['dateModified']);
61
+ }if(!empty($metaData['description'])){
62
+ $article["description"] = $KcSeoWPSchema->sanitizeOutPut($metaData['description'], 'textarea');
63
+ }if(!empty($metaData['articleBody'])){
64
+ $article["articleBody"] = $KcSeoWPSchema->sanitizeOutPut($metaData['articleBody'], 'textarea');
65
  }
66
  $html .= $this->get_jsonEncode($article);
67
  break;
70
  $newsArticle = array();
71
  $newsArticle["@context"] = "http://schema.org";
72
  $newsArticle["@type"] = "NewsArticle";
73
+ if(!empty($metaData['headline'])){
74
+ $newsArticle["headline"] = $KcSeoWPSchema->sanitizeOutPut($metaData['headline']);
75
+ }if(!empty($metaData['mainEntityOfPage'])){
76
  $newsArticle["mainEntityOfPage"] = array(
77
  "@type" => "WebPage",
78
+ "@id" => $KcSeoWPSchema->sanitizeOutPut($metaData["mainEntityOfPage"])
79
  );
80
+ }if(!empty($metaData['author'])){
81
+ $newsArticle["author"] = $KcSeoWPSchema->sanitizeOutPut($metaData['author']);
82
+ }if(!empty($metaData['image'])){
83
  $img = $this->imgInfo($metaData['image']);
84
  $newsArticle["image"] = array(
85
  "@type" => "ImageObject",
86
+ "url" => $KcSeoWPSchema->sanitizeOutPut($metaData['image'], 'url'),
87
  "height" => $img['height'],
88
  "width" =>$img['width']
89
  );
90
+ }if(!empty($metaData['datePublished'])){
91
+ $newsArticle["datePublished"] = $KcSeoWPSchema->sanitizeOutPut($metaData['datePublished']);
92
+ }if(!empty($metaData['dateModified'])){
93
+ $newsArticle["dateModified"] = $KcSeoWPSchema->sanitizeOutPut($metaData['dateModified']);
94
+ }if(!empty($metaData['publisher'])){
95
+ if(!empty($metaData['publisherImage'])){
96
  $img = $this->imgInfo($metaData['publisherImage']);
97
  $plA = array(
98
  "@type" => "ImageObject",
99
+ "url" => $KcSeoWPSchema->sanitizeOutPut($metaData['publisherImage'], 'url'),
100
  "height" => intval($img['height']),
101
  "width" => intval($img['width']),
102
  );
105
  }
106
  $newsArticle["publisher"] = array(
107
  "@type" => "Organization",
108
+ "name" => $KcSeoWPSchema->sanitizeOutPut($metaData['publisher']),
109
  "logo" => $plA
110
  );
111
+ }if(!empty($metaData['description'])){
112
+ $newsArticle["description"] = $KcSeoWPSchema->sanitizeOutPut($metaData['description'], 'textarea');
113
+ }if(!empty($metaData['articleBody'])){
114
+ $newsArticle["articleBody"] = $KcSeoWPSchema->sanitizeOutPut($metaData['articleBody'], 'textarea');
115
  }
116
  $html .= $this->get_jsonEncode($newsArticle);
117
  break;
120
  $blogPosting = array();
121
  $blogPosting["@context"] = "http://schema.org";
122
  $blogPosting["@type"] = "BlogPosting";
123
+ if(!empty($metaData['headline'])){
124
+ $blogPosting["headline"] = $KcSeoWPSchema->sanitizeOutPut($metaData['headline']);
125
+ }if(!empty($metaData['mainEntityOfPage'])){
126
  $blogPosting["mainEntityOfPage"] = array(
127
  "@type" => "WebPage",
128
+ "@id" => $KcSeoWPSchema->sanitizeOutPut($metaData["mainEntityOfPage"])
129
  );
130
+ }if(!empty($metaData['author'])){
131
+ $blogPosting["author"] = $KcSeoWPSchema->sanitizeOutPut($metaData['author']);
132
+ }if(!empty($metaData['image'])){
133
  $img = $this->imgInfo($metaData['image']);
134
  $blogPosting["image"] = array(
135
  "@type" => "ImageObject",
136
+ "url" => $KcSeoWPSchema->sanitizeOutPut($metaData['image'], 'url'),
137
  "height" => $img['height'],
138
  "width" =>$img['width']
139
  );
140
+ }if(!empty($metaData['datePublished'])){
141
+ $blogPosting["datePublished"] = $KcSeoWPSchema->sanitizeOutPut($metaData['datePublished']);
142
+ }if(!empty($metaData['dateModified'])){
143
+ $blogPosting["dateModified"] = $KcSeoWPSchema->sanitizeOutPut($metaData['dateModified']);
144
+ }if(!empty($metaData['publisher'])){
145
  if($metaData['publisherImage']){
146
  $img = $this->imgInfo($metaData['publisherImage']);
147
  $plA = array(
148
  "@type" => "ImageObject",
149
+ "url" => $KcSeoWPSchema->sanitizeOutPut($metaData['publisherImage']),
150
  "height" => intval($img['height']),
151
  "width" => intval($img['width']),
152
  );
155
  }
156
  $blogPosting["publisher"] = array(
157
  "@type" => "Organization",
158
+ "name" => $KcSeoWPSchema->sanitizeOutPut($metaData['publisher']),
159
  "logo" => $plA
160
  );
161
+ }if(!empty($metaData['description'])){
162
+ $blogPosting["description"] = $KcSeoWPSchema->sanitizeOutPut($metaData['description'], 'textarea');
163
+ }if(!empty($metaData['articleBody'])){
164
+ $blogPosting["articleBody"] = $KcSeoWPSchema->sanitizeOutPut($metaData['articleBody'], 'textarea');
165
  }
166
  $html .= $this->get_jsonEncode($blogPosting);
167
  break;
170
  $event = array();
171
  $event["@context"] = "http://schema.org";
172
  $event["@type"] = "Event";
173
+ if(!empty($metaData['name'])){
174
+ $event["name"] = $KcSeoWPSchema->sanitizeOutPut($metaData['name']);
175
+ }if(!empty($metaData['startDate'])){
176
+ $event["startDate"] = $KcSeoWPSchema->sanitizeOutPut($metaData['startDate']);
177
+ }if(!empty($metaData['locationName'])){
178
  $event["location"] = array(
179
  "@type" => "Place",
180
+ "name" => $KcSeoWPSchema->sanitizeOutPut($metaData['locationName']),
181
+ "address" => $KcSeoWPSchema->sanitizeOutPut($metaData['locationAddress'])
182
  );
183
+ }if(!empty($metaData['price'])){
184
  $event["offers"] = array(
185
  "@type" => "Offer",
186
+ "price" => $KcSeoWPSchema->sanitizeOutPut($metaData['price']),
187
+ "priceCurrency" => !empty($metaData['priceCurrency']) ? $KcSeoWPSchema->sanitizeOutPut($metaData['priceCurrency']) : null,
188
+ "url" => !empty($metaData['url']) ? $KcSeoWPSchema->sanitizeOutPut($metaData['url'], 'url') : null
189
  );
190
  }
191
  $html .= $this->get_jsonEncode($event);
195
  $product = array();
196
  $product["@context"] = "http://schema.org";
197
  $product["@type"] = "Product";
198
+ if (!empty($metaData['name'])) {
199
+ $product["name"] = $KcSeoWPSchema->sanitizeOutPut($metaData['name']);
200
+ }
201
+ if (!empty($metaData['image'])) {
202
+ $product["image"] = $KcSeoWPSchema->sanitizeOutPut($metaData['image']);
203
+ }
204
+ if (!empty($metaData['description'])) {
205
+ $product["description"] = $KcSeoWPSchema->sanitizeOutPut($metaData['description']);
206
+ }
207
+ if (!empty($metaData['brand'])) {
208
  $product["brand"] = array(
209
  "@type" => "Thing",
210
+ "name" => $KcSeoWPSchema->sanitizeOutPut($metaData['brand'])
211
  );
212
+ }
213
+ if (!empty($metaData['ratingValue'])) {
214
  $product["aggregateRating"] = array(
215
  "@type" => "AggregateRating",
216
+ "ratingValue" => !empty($metaData['ratingValue']) ? $KcSeoWPSchema->sanitizeOutPut($metaData['ratingValue']) : null,
217
+ "reviewCount" => !empty($metaData['reviewCount']) ? $KcSeoWPSchema->sanitizeOutPut($metaData['reviewCount']) : null
218
  );
219
+ }
220
+ if (!empty($metaData['price'])) {
221
  $product["offers"] = array(
222
  "@type" => "Offer",
223
+ "price" => $KcSeoWPSchema->sanitizeOutPut($metaData['price']),
224
+ "priceCurrency" => !empty($metaData['priceCurrency']) ? $KcSeoWPSchema->sanitizeOutPut($metaData['priceCurrency']) : null,
225
+ "itemCondition" => !empty($metaData['itemCondition']) ? $KcSeoWPSchema->sanitizeOutPut($metaData['itemCondition']) : null,
226
+ "availability" => !empty($metaData['availability']) ? $KcSeoWPSchema->sanitizeOutPut($metaData['availability']) : null,
227
+ "url" => !empty($metaData['url']) ? $KcSeoWPSchema->sanitizeOutPut($metaData['url']) : null
228
  );
229
  }
230
  $html .= $this->get_jsonEncode($product);
234
  $video = array();
235
  $video["@context"] = "http://schema.org";
236
  $video["@type"] = "VideoObject";
237
+ if(!empty($metaData['name'])){
238
+ $video["name"] = $KcSeoWPSchema->sanitizeOutPut($metaData['name']);
239
+ }if(!empty($metaData['description'])){
240
+ $video["description"] = $KcSeoWPSchema->sanitizeOutPut($metaData['description'], 'textarea');
241
+ }if(!empty($metaData['description'])){
242
+ $video["description"] = $KcSeoWPSchema->sanitizeOutPut($metaData['description']);
243
+ }if(!empty($metaData['thumbnailUrl'])){
244
+ $video["thumbnailUrl"] = $KcSeoWPSchema->sanitizeOutPut($metaData['thumbnailUrl'], 'url');
245
+ }if(!empty($metaData['uploadDate'])){
246
+ $video["uploadDate"] = $KcSeoWPSchema->sanitizeOutPut($metaData['uploadDate']);
247
+ }if(!empty($metaData['duration'])){
248
+ $video["duration"] = $KcSeoWPSchema->sanitizeOutPut($metaData['duration']);
249
+ }if(!empty($metaData['contentUrl'])){
250
+ $video["contentUrl"] = $KcSeoWPSchema->sanitizeOutPut($metaData['contentUrl'], 'url');
251
+ }if(!empty($metaData['interactionCount'])){
252
+ $video["interactionCount"] = $KcSeoWPSchema->sanitizeOutPut($metaData['interactionCount']);
253
+ }if(!empty($metaData['expires'])){
254
+ $video["expires"] = $KcSeoWPSchema->sanitizeOutPut($metaData['expires']);
255
  }
256
  $html .= $this->get_jsonEncode($video);
257
  break;
260
  $service = array();
261
  $service["@context"] = "http://schema.org";
262
  $service["@type"] = "Service";
263
+ if(!empty($metaData['name'])){
264
+ $service["name"] = $KcSeoWPSchema->sanitizeOutPut($metaData['name']);
265
+ }if(!empty($metaData['serviceType'])){
266
+ $service["serviceType"] = $KcSeoWPSchema->sanitizeOutPut($metaData['serviceType']);
267
+ }if(!empty($metaData['locationName'])){
268
  $service["location"] = array(
269
  "@type" => "Place",
270
+ "name" => $KcSeoWPSchema->sanitizeOutPut($metaData['locationName']),
271
+ "address" => $KcSeoWPSchema->sanitizeOutPut($metaData['locationAddress'])
272
  );
273
+ }if(!empty($metaData['award'])){
274
+ $service["award"] = $KcSeoWPSchema->sanitizeOutPut($metaData['award']);
275
+ }if(!empty($metaData['category'])){
276
+ $service["category"] = $KcSeoWPSchema->sanitizeOutPut($metaData['category']);
277
+ }if(!empty($metaData['providerMobility'])){
278
+ $service["providerMobility"] = $KcSeoWPSchema->sanitizeOutPut($metaData['providerMobility']);
279
+ }if(!empty($metaData['additionalType'])){
280
+ $service["additionalType"] = $KcSeoWPSchema->sanitizeOutPut($metaData['additionalType']);
281
+ }if(!empty($metaData['alternateName'])){
282
+ $service["alternateName"] = $KcSeoWPSchema->sanitizeOutPut($metaData['alternateName']);
283
+ }if(!empty($metaData['image'])){
284
+ $service["image"] = $KcSeoWPSchema->sanitizeOutPut($metaData['image']);
285
+ }if(!empty($metaData['mainEntityOfPage'])){
286
+ $service["mainEntityOfPage"] = $KcSeoWPSchema->sanitizeOutPut($metaData['mainEntityOfPage']);
287
+ }if(!empty($metaData['sameAs'])){
288
+ $service["sameAs"] = $KcSeoWPSchema->sanitizeOutPut($metaData['sameAs']);
289
+ }if(!empty($metaData['url'])){
290
+ $service["url"] = $KcSeoWPSchema->sanitizeOutPut($metaData['url'], 'url');
291
  }
292
  $html .= $this->get_jsonEncode($service);
293
  break;
296
  $review = array();
297
  $review["@context"] = "http://schema.org";
298
  $review["@type"] = "Review";
299
+ if(!empty($metaData['itemName'])){
300
  $review["itemReviewed"] = array(
301
  "@type" => "Thing",
302
+ "name" => $KcSeoWPSchema->sanitizeOutPut($metaData['itemName'])
303
  );
304
+ }if(!empty($metaData['ratingValue'])){
305
  $review["reviewRating"] = array(
306
  "@type" => "Rating",
307
+ "ratingValue" => $KcSeoWPSchema->sanitizeOutPut($metaData['ratingValue']),
308
+ "bestRating" => $KcSeoWPSchema->sanitizeOutPut($metaData['bestRating']),
309
+ "worstRating" => $KcSeoWPSchema->sanitizeOutPut($metaData['worstRating'])
310
  );
311
+ }if(!empty($metaData['name'])){
312
+ $review["name"] = $KcSeoWPSchema->sanitizeOutPut($metaData['name']);
313
+ }if(!empty($metaData['author'])){
314
  $review["author"] = array(
315
  "@type" => "Person",
316
+ "name" => $KcSeoWPSchema->sanitizeOutPut($metaData['author'])
317
  );
318
+ }if(!empty($metaData['reviewBody'])){
319
+ $review["reviewBody"] = $KcSeoWPSchema->sanitizeOutPut($metaData['reviewBody']);
320
+ }if(!empty($metaData['datePublished'])){
321
+ $review["datePublished"] = $KcSeoWPSchema->sanitizeOutPut($metaData['datePublished']);
322
+ }if(!empty($metaData['publisher'])){
323
  $review["publisher"] = array(
324
  "@type" => "Organization",
325
+ "name" => $KcSeoWPSchema->sanitizeOutPut($metaData['publisher'])
326
  );
327
  }
328
  $html .= $this->get_jsonEncode($review);
330
  case 'aggregate_rating':
331
  $aRating = array();
332
  $aRating["@context"] = "http://schema.org";
333
+ $aRating["@type"] = !empty($metaData['schema_type']) ? $metaData['schema_type'] : "LocalBusiness";
334
+ if(!empty($metaData['name'])){
335
+ $aRating["name"] = $KcSeoWPSchema->sanitizeOutPut($metaData['name']);
336
+ }if(!empty($metaData['description'])){
337
+ $aRating["description"] = $KcSeoWPSchema->sanitizeOutPut($metaData['description'], 'textarea');
338
+ }if(!empty($metaData['ratingValue'])){
339
  $rValue = array();
340
  $rValue["@type"] = "AggregateRating";
341
+ $rValue["ratingValue"] = $KcSeoWPSchema->sanitizeOutPut($metaData['ratingValue']);
342
+ if(!empty($metaData['bestRating'])){
343
+ $rValue["bestRating"] = $KcSeoWPSchema->sanitizeOutPut($metaData['bestRating']);
344
+ }if(!empty($metaData['worstRating'])){
345
+ $rValue["worstRating"] = $KcSeoWPSchema->sanitizeOutPut($metaData['worstRating']);
346
+ }if(!empty($metaData['ratingCount'])){
347
+ $rValue["ratingCount"] = $KcSeoWPSchema->sanitizeOutPut($metaData['ratingCount']);
348
  }
349
 
350
  $aRating["aggregateRating"] = $rValue;
367
  $schemaId = $KcSeoWPSchema->KcSeoPrefix.$data['schemaId'];
368
  $id = $KcSeoWPSchema->KcSeoPrefix.$data['schemaId']."_".$fieldId;
369
  $name = $schemaId."[{$fieldId}]";
370
+ $getRawMeta = get_post_meta($pid, $schemaId, true );
371
+ $metaData = array();
372
+ if(!empty($getRawMeta)) {
373
+ if ($KcSeoWPSchema->isValidBase64($getRawMeta)) {
374
+ $metaData = unserialize(base64_decode($getRawMeta));
375
+ } else {
376
+ $metaData = unserialize($getRawMeta);
377
+ }
378
+ }
379
+ $value = (!empty($metaData[$fieldId]) ? esc_attr(stripslashes($metaData[$fieldId])) : null);
380
+
381
+
382
  $class = isset($data['class']) ? ($data['class'] ? $data['class'] : null) : null;
383
  $require = (isset($data['required']) ? ($data['required'] ? "<span class='required'>*</span>" : null ) : null);
384
  $title = (isset($data['title']) ? ($data['title'] ? $data['title'] : null ) : null);
403
  $html .= "<textarea id='{$id}' class='{$class}' name='{$name}' >{$value}</textarea>";
404
  break;
405
  case 'select':
406
+ $html .="<select name='{$name}' class='select2 {$class}' id='{$id}'>";
407
+ if(!empty($data['empty'])){
408
+ $html .="<option value=''>{$data['empty']}</option>";
409
+ }
410
+ if(!empty($data['options']) && is_array($data['options'])) {
411
+ if ($this->isAssoc($data['options'])) {
412
+ foreach ($data['options'] as $optKey => $optValue) {
413
+ $slt = ($optKey == $value ? "selected" : null);
414
+ $html .= "<option value='{$optKey}' {$slt}>{$optValue}</option>";
415
+ }
416
+ } else {
417
+ foreach ($data['options'] as $optValue) {
418
+ $slt = ($optValue == $value ? "selected" : null);
419
+ $html .= "<option value='{$optValue}' {$slt}>{$optValue}</option>";
420
+ }
421
+ }
422
  }
423
  $html .="</select>";
424
  break;
531
  'image' => array(
532
  'title' => 'Image URL',
533
  'type' => 'url',
534
+ 'desc' => 'Image url, The representative image of the article. Only a marked-up image that directly belongs to the article should be specified. Images should be at least 696 pixels wide. Images should be in .jpg, .png, or. gif format.',
535
  'required' => true
536
  ),
537
  'datePublished' => array(
730
  'availability' => array(
731
  'title' => 'Availability',
732
  'type' => 'select',
733
+ 'empty' => "Select one",
734
  'options' => array(
735
  'http://schema.org/InStock' => 'InStock',
736
  'http://schema.org/InStoreOnly' => 'InStoreOnly',
746
  'itemCondition' => array(
747
  'title' => 'Product condition',
748
  'type' => 'select',
749
+ 'empty' => "Select one",
750
  'options' => array(
751
  'http://schema.org/NewCondition' => 'NewCondition',
752
  'http://schema.org/UsedCondition' => 'UsedCondition',
962
  'aggregate_rating' => array(
963
  'title' => 'Aggregate Ratings',
964
  'fields' => array(
965
+ 'schema_type' => array(
966
+ 'title' => 'Schema type',
967
+ 'type' => 'select',
968
+ 'required' => true,
969
+ 'options' => $this->site_type(),
970
+ 'empty' => "Select one",
971
+ 'desc' => "Use the most appropriate schema type for what is being reviewed."
972
+ ),
973
  'name' => array(
974
+ 'title' => 'Name of the item',
975
  'type' => 'text',
976
  'required' => true,
977
  'desc' => "The item that is being rated."
1389
  "Billing Support",
1390
  "Bill Payment",
1391
  "Sales",
1392
+ "Reservations",
1393
  "Credit Card Support",
1394
  "Emergency",
1395
  "Baggage Tracking",
1520
  function imgInfo($url = null){
1521
  $img = array();
1522
  if($url){
1523
+ $imgA = @getimagesize($url);
1524
+ if(is_array($imgA) && !empty($imgA)){
1525
+ $img['width'] = $imgA[0];
1526
+ $img['height'] = $imgA[1];
1527
+ }else{
1528
+ $img['width'] = 0;
1529
+ $img['height'] = 0;
1530
+ }
1531
  }
1532
  return $img;
1533
  }
1534
+ function isAssoc($array)
1535
+ {
1536
+ $keys = array_keys($array);
1537
+ return $keys !== array_keys($keys);
1538
+ }
1539
+
1540
 
1541
  }
1542
  endif;
lib/views/settings.php CHANGED
@@ -12,11 +12,10 @@ $schemaModel = new KcSeoSchemaModel;
12
  <div class="setting-holder">
13
  <table width="40%" cellpadding="10" class="form-table">
14
  <tr class="default">
15
- <th>Enable Site link Search Box</th>
16
- <td scope="row">
17
  <div class="with-tooltip">
18
- <input type="checkbox" name="homeonly" id="homeonly" <?php echo (@$settings['homeonly'] ? "checked" : null); ?> value="1" />
19
-
20
  <div class="schema-tooltip-holder">
21
  <span class="schema-tooltip"></span>
22
  <div class="hidden">
@@ -27,20 +26,15 @@ $schemaModel = new KcSeoSchemaModel;
27
  </div>
28
  </td>
29
  </tr>
30
- <tr class="default field_homepage">
31
- <th>Website Url</th>
32
- <td align="left" scope="row">
33
- <input type="text" class="regular-text" name="web_url" value="<?php echo (@$settings['web_url'] ? @$settings['web_url'] : null); ?>" />
34
- </td>
35
- </tr>
36
  <tr class="default">
37
  <th>Type</th>
38
  <td align="left" scope="row">
39
  <select id="site_type" name="site_type" class="select2">
40
  <option value="">Select one type</option>
41
  <?php
 
42
  foreach($schemaModel->site_type() as $site){
43
- $slt = ($site == @$settings['site_type'] ? "selected" : null);
44
  echo "<option value='$site' $slt>$site</option>";
45
  }
46
  ?>
@@ -50,14 +44,14 @@ $schemaModel = new KcSeoSchemaModel;
50
  <tr class="default">
51
  <th>Organization or Business name</th>
52
  <td align="left" scope="row">
53
- <input type="text" class="regular-text" name="type_name" value="<?php echo (@$settings['type_name'] ? @$settings['type_name'] : null); ?>" />
54
  </td>
55
  </tr>
56
  <tr class="default">
57
  <th>Additional Type</th>
58
  <td align="left" scope="row">
59
  <div class="with-tooltip">
60
- <textarea name="additionalType" placeholder="http://example1.com&#10;http://example2.com&#10;http://example3.com" rows="6" cols="50" class="additional-type"><?php echo (@$settings['additionalType'] ? esc_attr(@$settings['additionalType']) : null); ?></textarea>
61
  <p class="description">Add "Additional Type" URL(s) by separate ideas</p>
62
  <div class="schema-tooltip-holder">
63
  <span class="schema-tooltip"></span>
@@ -80,14 +74,14 @@ $schemaModel = new KcSeoSchemaModel;
80
  <tr class="default business-info">
81
  <th>Description</th>
82
  <td align="left" scope="row">
83
- <textarea cols="50" rows="6" name="business_info[description]"><?php echo (@$settings['business_info']['description'] ? @$settings['business_info']['description'] : null); ?></textarea>
84
  </td>
85
  </tr>
86
  <tr class="default business-info">
87
  <th>Operation Hours</th>
88
  <td align="left" scope="row">
89
  <div class="with-tooltip">
90
- <textarea name="business_info[openingHours]" placeholder="Mo-Sa 11:00-14:30&#10;Mo-Th 17:00-21:30&#10;Fr-Sa 17:00-22:00" rows="4" cols="50" class="additional-type"><?php echo (@$settings['business_info']['openingHours'] ? esc_attr(@$settings['business_info']['openingHours']) : null); ?></textarea>
91
  <p class="description">- Days are specified using the following two-letter combinations: Mo, Tu, We, Th, Fr, Sa, Su.</br>
92
  - Times are specified using 24:00 time. For example, 3pm is specified as 15:00. <br>
93
  - Add Opening Hours by separate line</p>
@@ -108,13 +102,13 @@ $schemaModel = new KcSeoSchemaModel;
108
  <tr class="default business-info">
109
  <th style="text-align: right">Longitude</th>
110
  <td align="left" scope="row">
111
- <input type="text" class="regular-text" name="business_info[longitude]" value="<?php echo (@$settings['business_info']['longitude'] ? @$settings['business_info']['longitude'] : null); ?>" />
112
  </td>
113
  </tr>
114
  <tr class="default business-info">
115
  <th style="text-align: right">Latitude</th>
116
  <td align="left" scope="row">
117
- <input type="text" class="regular-text" name="business_info[latitude]" value="<?php echo (@$settings['business_info']['latitude'] ? @$settings['business_info']['latitude'] : null); ?>" />
118
  </td>
119
  </tr>
120
 
@@ -125,14 +119,14 @@ $schemaModel = new KcSeoSchemaModel;
125
  <tr class="default person">
126
  <th>Name</th>
127
  <td align="left" scope="row">
128
- <input type="text" class="regular-text" name="person[name]" value="<?php echo (@$settings['person']['name'] ? @$settings['person']['name'] : null); ?>" />
129
  </td>
130
  </tr>
131
  <tr class="default person">
132
  <th>Work For</th>
133
  <td align="left" scope="row">
134
  <input type="text" class="regular-text" name="person[worksFor]"
135
- value="<?php echo (@$settings['person']['worksFor'] ? @$settings['person']['worksFor'] : null); ?>" />
136
 
137
  </td>
138
  </tr>
@@ -148,7 +142,7 @@ $schemaModel = new KcSeoSchemaModel;
148
  <th>Image</th>
149
  <td align="left" scope="row">
150
  <input type="text" class="regular-text" name="person[image]"
151
- value="<?php echo (@$settings['person']['image'] ? @$settings['person']['image'] : null); ?>" />
152
  <p class="description">Add your personal photo here</p>
153
  </td>
154
  </tr>
@@ -156,14 +150,14 @@ $schemaModel = new KcSeoSchemaModel;
156
  <th>Description</th>
157
  <td align="left" scope="row">
158
  <input type="text" class="regular-text" name="person[description]"
159
- value="<?php echo (@$settings['person']['description'] ? @$settings['person']['description'] : null); ?>" />
160
  </td>
161
  </tr>
162
  <tr class="default person">
163
  <th>Birth date</th>
164
  <td align="left" scope="row">
165
  <input type="text" class="regular-text kcseo-date" name="person[birthDate]"
166
- value="<?php echo (@$settings['person']['birthDate'] ? @$settings['person']['birthDate'] : null); ?>" />
167
 
168
  </td>
169
  </tr>
@@ -176,8 +170,9 @@ $schemaModel = new KcSeoSchemaModel;
176
  <select class="select2" name="address[country]">
177
  <option value="">Select a country</option>
178
  <?php
 
179
  foreach($schemaModel->countryList() as $country){
180
- $slt = ($country == @$settings['address']['country'] ? "selected" : null);
181
  echo "<option value='$country' $slt>$country</option>";
182
  }
183
  ?>
@@ -187,49 +182,49 @@ $schemaModel = new KcSeoSchemaModel;
187
  <tr class="default">
188
  <th>Address Locality</th>
189
  <td align="left" scope="row">
190
- <input type="text" class="regular-text" name="address[locality]" value="<?php echo (@$settings['address']['locality'] ? @$settings['address']['locality'] : null); ?>" />
191
  <p class="description">City (i.e Kansas city)</p>
192
  </tr>
193
  <tr class="default">
194
  <th>Address Region</th>
195
  <td align="left" scope="row">
196
- <input type="text" class="regular-text" name="address[region]" value="<?php echo (@$settings['address']['region'] ? @$settings['address']['region'] : null); ?>" />
197
  <p class="description">State (i.e. MO)</p>
198
  </tr>
199
  <tr class="default">
200
  <th>Postal Code</th>
201
  <td align="left" scope="row">
202
- <input type="text" class="regular-text" name="address[postalcode]" value="<?php echo (@$settings['address']['postalcode'] ? @$settings['address']['postalcode'] : null); ?>" />
203
  </tr>
204
  <tr class="default">
205
  <th>Street Address</th>
206
  <td align="left" scope="row">
207
- <input type="text" class="regular-text" name="address[street]" value="<?php echo (@$settings['address']['street'] ? @$settings['address']['street'] : null); ?>" />
208
  </tr>
209
  </table>
210
  </div>
211
- <div id="tabs-kcseo-container">
212
- <ul class="tabs-menu">
213
- <li class="current"><a href="#tab-1">Organization Logo</a></li>
214
- <li><a href="#tab-2">Social Profile</a></li>
215
- <li><a href="#tab-3">Corporate Contacts</a></li>
216
  </ul>
217
- <div id="tab-1" class="tab-content kcseo-tab-container">
218
  <table width="100%" cellpadding="10" class="form-table">
219
  <tr class="field_logo">
220
  <th>Logo URL </th>
221
  <td scope="row">
222
- <input type="text" class="regular-text" name="logo_url" value="<?php echo (@$settings['logo_url'] ? @$settings['logo_url'] : null); ?>" />
223
  </td>
224
  </tr>
225
  </table>
226
  </div>
227
- <div id="tab-2" class="tab-content kcseo-tab-container">
228
  <table width="100%" cellpadding="10" class="form-table">
229
  <tr class="field_social">
230
  <th>Company Name </th>
231
  <td align="left" scope="row">
232
- <input type="text" class="regular-text" name="social_company_name" value="<?php echo (@$settings['social_company_name'] ? @$settings['social_company_name'] : null); ?>" />
233
  </td>
234
  </tr>
235
  <tr class="field_social_title">
@@ -240,7 +235,7 @@ $schemaModel = new KcSeoSchemaModel;
240
  <th>
241
  <div id="social-field-holder">
242
  <?php
243
- $socialP = (isset($settings['social']) ? ($settings['social'] ? $settings['social'] : array()) : array() );
244
  if(is_array($socialP) && !empty($socialP)) {
245
  $html = null;
246
  $i = 0;
@@ -266,7 +261,7 @@ $schemaModel = new KcSeoSchemaModel;
266
  </tr>
267
  </table>
268
  </div>
269
- <div id="tab-3" class="tab-content kcseo-tab-container">
270
  <table width="100%" cellpadding="10" class="form-table">
271
  <tr class="field_contact">
272
  <th style="font-size: 18px; padding: 10px 0;">Contacts</th>
@@ -274,11 +269,12 @@ $schemaModel = new KcSeoSchemaModel;
274
  <tr class="field_contact">
275
  <th>Contact Type </th>
276
  <td scope="row">
277
- <select name="contact[contactType]" class="select2">
278
  <?php
279
- foreach($schemaModel->contactType() as $ctype){
280
- $slt = ($ctype == $settings['contact']['contactType'] ? "selected" : null);
281
- echo "<option value='$ctype' $slt>$ctype</option>";
 
282
  }
283
 
284
  ?>
@@ -289,7 +285,7 @@ $schemaModel = new KcSeoSchemaModel;
289
  <tr class="field_contact">
290
  <th>Contact Phone </th>
291
  <td align="left" scope="row">
292
- <input type="text" class="regular-text" name="contact[telephone]" value="<?php echo (@$settings['contact']['telephone'] ? @$settings['contact']['telephone'] : null); ?>" />
293
  <p class="description kco-telephone">Please follow the format below<span style="font-size: 11px;">+1-505-998-3793</span><span style="font-size: 11px;">(425) 123-4567</span><span style="font-size: 11px;">( 33 1) 42 68 53 01</span><span style="font-size: 11px;">+44-2078225951</span><span style="font-size: 11px;">1 (855) 469-6378</span>
294
  </p>
295
  </td>
@@ -297,8 +293,11 @@ $schemaModel = new KcSeoSchemaModel;
297
  <tr class="field_contact">
298
  <th>Contact Option </th>
299
  <td align="left" scope="row">
300
- <select name="contact[contactOption]" class="select2">
301
- <option value="TollFree" <?php echo ($settings['contact']['contactOption'] == "TollFree" ? "selected" : null); ?>>TollFree</option>
 
 
 
302
  <option value="HearingImpairedSupported" <?php echo ($settings['contact']['contactOption'] == "HearingImpairedSupported" ? "selected" : null); ?>>HearingImpairedSupported</option>
303
  </select>
304
  </td>
@@ -309,8 +308,9 @@ $schemaModel = new KcSeoSchemaModel;
309
  <div class="area_served_wrapper">
310
  <select id="area_served" class="select2" name="area_served[]" multiple="multiple" style="width: 50%">
311
  <?php
 
312
  foreach($schemaModel->countryList() as $country){
313
- $slt = (in_array($country, $settings['area_served']) ? "selected" : null);
314
  echo "<option value='$country' $slt>$country</option>";
315
  }
316
  ?>
@@ -321,10 +321,11 @@ $schemaModel = new KcSeoSchemaModel;
321
  <tr class="field_contact">
322
  <th>Available language </th>
323
  <td scope="row" class="lang">
324
- <select class="select2" name="availableLanguage" style="width: 50%">
325
  <?php
 
326
  foreach($schemaModel->languageList() as $language){
327
- $slt = ($language == $settings['availableLanguage'] ? "selected" : null);
328
  echo "<option value='$language' $slt>$language</option>";
329
  }
330
  ?>
@@ -337,22 +338,28 @@ $schemaModel = new KcSeoSchemaModel;
337
 
338
  <h2>Site Name in Search Results</h2>
339
  <table width="100%" cellpadding="10" class="form-table">
 
 
 
 
 
 
340
  <tr class="default">
341
  <th>Site Name: </th>
342
  <td align="left" scope="row">
343
- <input type="text" class="regular-text" name="sitename" value="<?php echo (@$settings['sitename'] ? @$settings['sitename'] : null); ?>" />
344
  </td>
345
  </tr>
346
  <tr class="default">
347
  <th>Site Alternative Name: </th>
348
  <td align="left" scope="row">
349
- <input type="text" class="regular-text" name="siteaname" value="<?php echo (@$settings['siteaname'] ? @$settings['siteaname'] : null); ?>" />
350
  </td>
351
  </tr>
352
  <tr class="default">
353
  <th>Site Url: </th>
354
  <td align="left" scope="row">
355
- <input type="text" class="regular-text" name="siteurl" value="<?php echo (@$settings['siteurl'] ? @$settings['siteurl'] : get_home_url()); ?>" />
356
  </td>
357
  </tr>
358
  </table>
12
  <div class="setting-holder">
13
  <table width="40%" cellpadding="10" class="form-table">
14
  <tr class="default">
15
+ <th>Website Url <span class="required">*</span></th>
16
+ <td align="left" scope="row">
17
  <div class="with-tooltip">
18
+ <input type="text" class="regular-text" name="web_url" value="<?php echo (!empty($settings['web_url']) ? esc_attr($settings['web_url']) : get_home_url()); ?>" />
 
19
  <div class="schema-tooltip-holder">
20
  <span class="schema-tooltip"></span>
21
  <div class="hidden">
26
  </div>
27
  </td>
28
  </tr>
 
 
 
 
 
 
29
  <tr class="default">
30
  <th>Type</th>
31
  <td align="left" scope="row">
32
  <select id="site_type" name="site_type" class="select2">
33
  <option value="">Select one type</option>
34
  <?php
35
+ $siteType = !empty($settings['site_type']) ? $settings['site_type'] : null;
36
  foreach($schemaModel->site_type() as $site){
37
+ $slt = ($site == $siteType ? "selected" : null);
38
  echo "<option value='$site' $slt>$site</option>";
39
  }
40
  ?>
44
  <tr class="default">
45
  <th>Organization or Business name</th>
46
  <td align="left" scope="row">
47
+ <input type="text" class="regular-text" name="type_name" value="<?php echo (!empty($settings['type_name']) ? $settings['type_name'] : null); ?>" />
48
  </td>
49
  </tr>
50
  <tr class="default">
51
  <th>Additional Type</th>
52
  <td align="left" scope="row">
53
  <div class="with-tooltip">
54
+ <textarea name="additionalType" placeholder="http://example1.com&#10;http://example2.com&#10;http://example3.com" rows="6" cols="50" class="additional-type"><?php echo (!empty($settings['additionalType']) ? esc_attr(@$settings['additionalType']) : null); ?></textarea>
55
  <p class="description">Add "Additional Type" URL(s) by separate ideas</p>
56
  <div class="schema-tooltip-holder">
57
  <span class="schema-tooltip"></span>
74
  <tr class="default business-info">
75
  <th>Description</th>
76
  <td align="left" scope="row">
77
+ <textarea cols="50" rows="6" name="business_info[description]"><?php echo (!empty($settings['business_info']['description']) ? esc_attr($settings['business_info']['description']) : null); ?></textarea>
78
  </td>
79
  </tr>
80
  <tr class="default business-info">
81
  <th>Operation Hours</th>
82
  <td align="left" scope="row">
83
  <div class="with-tooltip">
84
+ <textarea name="business_info[openingHours]" placeholder="Mo-Sa 11:00-14:30&#10;Mo-Th 17:00-21:30&#10;Fr-Sa 17:00-22:00" rows="4" cols="50" class="additional-type"><?php echo (!empty($settings['business_info']['openingHours']) ? esc_attr($settings['business_info']['openingHours']) : null); ?></textarea>
85
  <p class="description">- Days are specified using the following two-letter combinations: Mo, Tu, We, Th, Fr, Sa, Su.</br>
86
  - Times are specified using 24:00 time. For example, 3pm is specified as 15:00. <br>
87
  - Add Opening Hours by separate line</p>
102
  <tr class="default business-info">
103
  <th style="text-align: right">Longitude</th>
104
  <td align="left" scope="row">
105
+ <input type="text" class="regular-text" name="business_info[longitude]" value="<?php echo (!empty($settings['business_info']['longitude']) ? esc_attr($settings['business_info']['longitude']) : null); ?>" />
106
  </td>
107
  </tr>
108
  <tr class="default business-info">
109
  <th style="text-align: right">Latitude</th>
110
  <td align="left" scope="row">
111
+ <input type="text" class="regular-text" name="business_info[latitude]" value="<?php echo (!empty($settings['business_info']['latitude']) ? esc_attr($settings['business_info']['latitude']) : null); ?>" />
112
  </td>
113
  </tr>
114
 
119
  <tr class="default person">
120
  <th>Name</th>
121
  <td align="left" scope="row">
122
+ <input type="text" class="regular-text" name="person[name]" value="<?php echo (!empty($settings['person']['name']) ? esc_attr($settings['person']['name']) : null); ?>" />
123
  </td>
124
  </tr>
125
  <tr class="default person">
126
  <th>Work For</th>
127
  <td align="left" scope="row">
128
  <input type="text" class="regular-text" name="person[worksFor]"
129
+ value="<?php echo (!empty($settings['person']['worksFor']) ? esc_attr($settings['person']['worksFor']) : null); ?>" />
130
 
131
  </td>
132
  </tr>
142
  <th>Image</th>
143
  <td align="left" scope="row">
144
  <input type="text" class="regular-text" name="person[image]"
145
+ value="<?php echo (!empty($settings['person']['image']) ? esc_attr($settings['person']['image']) : null); ?>" />
146
  <p class="description">Add your personal photo here</p>
147
  </td>
148
  </tr>
150
  <th>Description</th>
151
  <td align="left" scope="row">
152
  <input type="text" class="regular-text" name="person[description]"
153
+ value="<?php echo (!empty($settings['person']['description']) ? esc_attr($settings['person']['description']) : null); ?>" />
154
  </td>
155
  </tr>
156
  <tr class="default person">
157
  <th>Birth date</th>
158
  <td align="left" scope="row">
159
  <input type="text" class="regular-text kcseo-date" name="person[birthDate]"
160
+ value="<?php echo (!empty($settings['person']['birthDate']) ? esc_attr($settings['person']['birthDate']) : null); ?>" />
161
 
162
  </td>
163
  </tr>
170
  <select class="select2" name="address[country]">
171
  <option value="">Select a country</option>
172
  <?php
173
+ $aCountry = !empty($settings['address']['country']) ? $settings['address']['country'] : null;
174
  foreach($schemaModel->countryList() as $country){
175
+ $slt = ($country == $aCountry ? "selected" : null);
176
  echo "<option value='$country' $slt>$country</option>";
177
  }
178
  ?>
182
  <tr class="default">
183
  <th>Address Locality</th>
184
  <td align="left" scope="row">
185
+ <input type="text" class="regular-text" name="address[locality]" value="<?php echo (!empty($settings['address']['locality']) ? esc_attr($settings['address']['locality']) : null); ?>" />
186
  <p class="description">City (i.e Kansas city)</p>
187
  </tr>
188
  <tr class="default">
189
  <th>Address Region</th>
190
  <td align="left" scope="row">
191
+ <input type="text" class="regular-text" name="address[region]" value="<?php echo (!empty($settings['address']['region']) ? esc_attr($settings['address']['region']) : null); ?>" />
192
  <p class="description">State (i.e. MO)</p>
193
  </tr>
194
  <tr class="default">
195
  <th>Postal Code</th>
196
  <td align="left" scope="row">
197
+ <input type="text" class="regular-text" name="address[postalcode]" value="<?php echo (!empty($settings['address']['postalcode']) ? esc_attr($settings['address']['postalcode']) : null); ?>" />
198
  </tr>
199
  <tr class="default">
200
  <th>Street Address</th>
201
  <td align="left" scope="row">
202
+ <input type="text" class="regular-text" name="address[street]" value="<?php echo (!empty($settings['address']['street']) ? esc_attr($settings['address']['street']) : null); ?>" />
203
  </tr>
204
  </table>
205
  </div>
206
+ <div id="tabs-kcseo-container" class="rt-tab-container">
207
+ <ul class="rt-tab-nav">
208
+ <li class="current"><a href="#tab-logo-url">Organization Logo</a></li>
209
+ <li><a href="#tab-social-profile">Social Profile</a></li>
210
+ <li><a href="#tab-corporate-contract">Corporate Contacts</a></li>
211
  </ul>
212
+ <div id="tab-logo-url" class="rt-tab-content">
213
  <table width="100%" cellpadding="10" class="form-table">
214
  <tr class="field_logo">
215
  <th>Logo URL </th>
216
  <td scope="row">
217
+ <input type="text" class="regular-text" name="logo_url" value="<?php echo (!empty($settings['logo_url']) ? esc_attr($settings['logo_url']) : null); ?>" />
218
  </td>
219
  </tr>
220
  </table>
221
  </div>
222
+ <div id="tab-social-profile" class="rt-tab-content">
223
  <table width="100%" cellpadding="10" class="form-table">
224
  <tr class="field_social">
225
  <th>Company Name </th>
226
  <td align="left" scope="row">
227
+ <input type="text" class="regular-text" name="social_company_name" value="<?php echo (!empty($settings['social_company_name']) ? esc_attr($settings['social_company_name']) : null); ?>" />
228
  </td>
229
  </tr>
230
  <tr class="field_social_title">
235
  <th>
236
  <div id="social-field-holder">
237
  <?php
238
+ $socialP = (!empty($settings['social']) ? $settings['social'] : array());
239
  if(is_array($socialP) && !empty($socialP)) {
240
  $html = null;
241
  $i = 0;
261
  </tr>
262
  </table>
263
  </div>
264
+ <div id="tab-corporate-contract" class="rt-tab-content">
265
  <table width="100%" cellpadding="10" class="form-table">
266
  <tr class="field_contact">
267
  <th style="font-size: 18px; padding: 10px 0;">Contacts</th>
269
  <tr class="field_contact">
270
  <th>Contact Type </th>
271
  <td scope="row">
272
+ <select name="contact[contactType]" class="select2" style="width: 200px">
273
  <?php
274
+ $contactType = !empty($settings['contact']['contactType']) ? $settings['contact']['contactType'] : null;
275
+ foreach($schemaModel->contactType() as $cType){
276
+ $slt = ($cType == $contactType ? "selected" : null);
277
+ echo "<option value='$cType' $slt>$cType</option>";
278
  }
279
 
280
  ?>
285
  <tr class="field_contact">
286
  <th>Contact Phone </th>
287
  <td align="left" scope="row">
288
+ <input type="text" class="regular-text" name="contact[telephone]" value="<?php echo (!empty($settings['contact']['telephone']) ? esc_attr($settings['contact']['telephone']) : null); ?>" />
289
  <p class="description kco-telephone">Please follow the format below<span style="font-size: 11px;">+1-505-998-3793</span><span style="font-size: 11px;">(425) 123-4567</span><span style="font-size: 11px;">( 33 1) 42 68 53 01</span><span style="font-size: 11px;">+44-2078225951</span><span style="font-size: 11px;">1 (855) 469-6378</span>
290
  </p>
291
  </td>
293
  <tr class="field_contact">
294
  <th>Contact Option </th>
295
  <td align="left" scope="row">
296
+ <select name="contact[contactOption]" class="select2 withEmptyOption" style="width: 200px">
297
+ <option value="">Select an option</option>
298
+ <option value="TollFree" <?php
299
+ $cPtOpt = !empty($settings['contact']['contactOption']) ? $settings['contact']['contactOption'] : null;
300
+ echo ($cPtOpt == "TollFree" ? "selected" : null); ?>>TollFree</option>
301
  <option value="HearingImpairedSupported" <?php echo ($settings['contact']['contactOption'] == "HearingImpairedSupported" ? "selected" : null); ?>>HearingImpairedSupported</option>
302
  </select>
303
  </td>
308
  <div class="area_served_wrapper">
309
  <select id="area_served" class="select2" name="area_served[]" multiple="multiple" style="width: 50%">
310
  <?php
311
+ $areaServed = !empty($settings['area_served']) ? $settings['area_served'] : array();
312
  foreach($schemaModel->countryList() as $country){
313
+ $slt = (in_array($country, $areaServed) ? "selected" : null);
314
  echo "<option value='$country' $slt>$country</option>";
315
  }
316
  ?>
321
  <tr class="field_contact">
322
  <th>Available language </th>
323
  <td scope="row" class="lang">
324
+ <select class="select2" name="availableLanguage[]" style="width: 50%" multiple="multiple">
325
  <?php
326
+ $lanAvailable = !empty($settings['availableLanguage']) ? $settings['availableLanguage'] : array();
327
  foreach($schemaModel->languageList() as $language){
328
+ $slt = (in_array($language, $lanAvailable) ? "selected" : null);
329
  echo "<option value='$language' $slt>$language</option>";
330
  }
331
  ?>
338
 
339
  <h2>Site Name in Search Results</h2>
340
  <table width="100%" cellpadding="10" class="form-table">
341
+ <tr class="default">
342
+ <th>Enable Site link Search Box</th>
343
+ <td align="left" scope="row">
344
+ <input type="checkbox" name="homeonly" <?php echo (!empty($settings['homeonly']) ? "checked" : null); ?> value="1" />
345
+ </td>
346
+ </tr>
347
  <tr class="default">
348
  <th>Site Name: </th>
349
  <td align="left" scope="row">
350
+ <input type="text" class="regular-text" name="sitename" value="<?php echo (!empty($settings['sitename']) ? esc_attr($settings['sitename']) : null); ?>" />
351
  </td>
352
  </tr>
353
  <tr class="default">
354
  <th>Site Alternative Name: </th>
355
  <td align="left" scope="row">
356
+ <input type="text" class="regular-text" name="siteaname" value="<?php echo (!empty($settings['siteaname']) ? esc_attr($settings['siteaname']) : null); ?>" />
357
  </td>
358
  </tr>
359
  <tr class="default">
360
  <th>Site Url: </th>
361
  <td align="left" scope="row">
362
+ <input type="text" class="regular-text" name="siteurl" value="<?php echo (!empty($settings['siteurl']) ? esc_attr($settings['siteurl']) : get_home_url()); ?>" />
363
  </td>
364
  </tr>
365
  </table>
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: kcseopro
3
  Donate link:
4
  Tags: seo, schema, structured data, rich snippets, microdata, json-ld, search engine optimization, local seo, google, sitelinks, schema.org, microformat, serp, amp
5
- Requires at least: 4
6
- Tested up to: 4.4
7
- Stable tag: 1.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -93,6 +93,12 @@ You'll find the [FAQ on Kcseopro.com](http://kcseopro.com/).
93
 
94
  == Changelog ==
95
 
 
 
 
 
 
 
96
  = 1.1 =
97
  * Layout change
98
  * Fix some coding bug
2
  Contributors: kcseopro
3
  Donate link:
4
  Tags: seo, schema, structured data, rich snippets, microdata, json-ld, search engine optimization, local seo, google, sitelinks, schema.org, microformat, serp, amp
5
+ Requires at least: 3.5
6
+ Tested up to: 4.6
7
+ Stable tag: 1.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
93
 
94
  == Changelog ==
95
 
96
+ = 1.2 =
97
+ * Meta field issue
98
+ * Layout change
99
+ * Fix some coding bug
100
+
101
+
102
  = 1.1 =
103
  * Layout change
104
  * Fix some coding bug
wp-seo-structured-data-schema.php CHANGED
@@ -3,7 +3,7 @@
3
  *Plugin Name: WP SEO Structured Data Schema
4
  * Plugin URI: http://kcseopro.com/
5
  * Description: Comprehensive JSON-LD based Structured Data solution for WordPress for adding schema for organizations, businesses, blog posts, ratings & more.
6
- * Version: 1.1
7
  * Author: kcseopro
8
  * Author URI: http://kcseopro.com/
9
  * License: A "Slug" license name e.g. GPL2
@@ -13,7 +13,42 @@ if ( ! defined( 'ABSPATH' ) ) {
13
  }
14
  define('KCSEO_WP_SCHEMA_SLUG', 'wp-seo-structured-data-schema');
15
  define('KCSEO_WP_SCHEMA_PATH', dirname(__FILE__));
 
16
  define('KCSEO_WP_SCHEMA_URL', plugins_url('', __FILE__));
17
  define('KCSEO_WP_SCHEMA_LANGUAGE_PATH', dirname( plugin_basename( __FILE__ ) ) . '/languages');
18
 
19
  require ('lib/init.php');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  *Plugin Name: WP SEO Structured Data Schema
4
  * Plugin URI: http://kcseopro.com/
5
  * Description: Comprehensive JSON-LD based Structured Data solution for WordPress for adding schema for organizations, businesses, blog posts, ratings & more.
6
+ * Version: 1.2
7
  * Author: kcseopro
8
  * Author URI: http://kcseopro.com/
9
  * License: A "Slug" license name e.g. GPL2
13
  }
14
  define('KCSEO_WP_SCHEMA_SLUG', 'wp-seo-structured-data-schema');
15
  define('KCSEO_WP_SCHEMA_PATH', dirname(__FILE__));
16
+ define('KCSEO_WP_SCHEMA_PLUGIN_ACTIVE_FILE_NAME', __FILE__);
17
  define('KCSEO_WP_SCHEMA_URL', plugins_url('', __FILE__));
18
  define('KCSEO_WP_SCHEMA_LANGUAGE_PATH', dirname( plugin_basename( __FILE__ ) ) . '/languages');
19
 
20
  require ('lib/init.php');
21
+
22
+
23
+ register_activation_hook(__FILE__, 'kcSeo_active');
24
+
25
+ /**
26
+ *
27
+ */
28
+ function kcSeo_active(){
29
+
30
+ register_uninstall_hook( __FILE__, 'kcSeo_uninstall' );
31
+ }
32
+
33
+ /**
34
+ *
35
+ */
36
+ function kcSeo_uninstall(){
37
+
38
+ $metas = array(
39
+ '_schema_article',
40
+ '_schema_blog_posting',
41
+ '_schema_news_article',
42
+ '_schema_event',
43
+ '_schema_product',
44
+ '_schema_video',
45
+ '_schema_service',
46
+ '_schema_review',
47
+ '_schema_aggregate_rating'
48
+ );
49
+
50
+ foreach($metas as $meta){
51
+ delete_post_meta_by_key($meta);
52
+ }
53
+
54
+ }