WP SEO Structured Data Schema - Version 2.1

Version Description

  • Can delete all save data
  • Restaurant Schema (New)
  • Image url fixed for product schema
Download this release

Release Info

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

Code changes from version 2.0 to 2.1

lib/classes/KcSeoInit.php CHANGED
@@ -17,7 +17,6 @@ if ( ! class_exists( 'KcSeoInit' ) ):
17
 
18
  register_activation_hook( KCSEO_WP_SCHEMA_PLUGIN_ACTIVE_FILE_NAME, array( $this, 'activePlugin' ) );
19
  // register_deactivation_hook(KCSEO_WP_SCHEMA_PLUGIN_ACTIVE_FILE_NAME, array($this, 'uninstall'));
20
-
21
  // Uninstall hook
22
 
23
  }
@@ -101,8 +100,7 @@ if ( ! class_exists( 'KcSeoInit' ) ):
101
  $styles['kcseo-admin-css'] = $KcSeoWPSchema->assetsUrl . 'css/admin.css';
102
  }
103
  foreach ( $scripts as $script ) {
104
- wp_register_script( $script['handle'], $script['src'], $script['deps'], time(),
105
- $script['footer'] ); //$KcSeoWPSchema->options['version']
106
  }
107
  foreach ( $styles as $k => $v ) {
108
  wp_register_style( $k, $v, false, $KcSeoWPSchema->options['version'] );
@@ -165,8 +163,6 @@ if ( ! class_exists( 'KcSeoInit' ) ):
165
  load_plugin_textdomain( KCSEO_WP_SCHEMA_SLUG, false, KCSEO_WP_SCHEMA_LANGUAGE_PATH );
166
  $this->updateVariableAndFixIssue();
167
  }
168
-
169
-
170
  function activePlugin() {
171
  $this->updateVariableAndFixIssue();
172
  }
17
 
18
  register_activation_hook( KCSEO_WP_SCHEMA_PLUGIN_ACTIVE_FILE_NAME, array( $this, 'activePlugin' ) );
19
  // register_deactivation_hook(KCSEO_WP_SCHEMA_PLUGIN_ACTIVE_FILE_NAME, array($this, 'uninstall'));
 
20
  // Uninstall hook
21
 
22
  }
100
  $styles['kcseo-admin-css'] = $KcSeoWPSchema->assetsUrl . 'css/admin.css';
101
  }
102
  foreach ( $scripts as $script ) {
103
+ wp_register_script( $script['handle'], $script['src'], $script['deps'], time(), $script['footer'] ); //$KcSeoWPSchema->options['version']
 
104
  }
105
  foreach ( $styles as $k => $v ) {
106
  wp_register_style( $k, $v, false, $KcSeoWPSchema->options['version'] );
163
  load_plugin_textdomain( KCSEO_WP_SCHEMA_SLUG, false, KCSEO_WP_SCHEMA_LANGUAGE_PATH );
164
  $this->updateVariableAndFixIssue();
165
  }
 
 
166
  function activePlugin() {
167
  $this->updateVariableAndFixIssue();
168
  }
lib/init.php CHANGED
@@ -1,101 +1,128 @@
1
  <?php
2
 
3
- if(!class_exists('KcSeoWPSchema')){
4
 
5
- class KcSeoWPSchema
6
- {
7
- public $options;
8
- public $KcSeoPrefix;
9
- function __construct() {
10
- $this->KcSeoPrefix = "_schema_";
11
- $this->options = array(
12
- 'settings' => 'kcseo_wp_schema',
13
- 'installed_version' => 'kcseo_wp_installed_version',
14
- 'version' => '2.0',
15
- '1_2_fix' => "kcseo_wp_1_2_data_fix"
16
- );
17
 
18
- $this->incPath = dirname(__FILE__);
19
- $this->functionsPath = $this->incPath . '/functions/';
20
- $this->classesPath = $this->incPath . '/classes/';
21
- $this->viewsPath = $this->incPath . '/views/';
22
- $this->assetsUrl = KCSEO_WP_SCHEMA_URL . '/assets/';
23
- $this->modelPath = $this->incPath . '/models/';
 
 
24
 
25
- $this->KeSeoLoadFunctions($this->functionsPath);
26
- $this->KcSeoLoadModel($this->modelPath);
27
- $this->KcSeoLoadClass($this->classesPath);
 
 
 
28
 
29
- }
 
 
30
 
31
- function KcSeoLoadClass($dir) {
32
- if (!file_exists($dir)) return;
33
- $classes = array();
34
- foreach (scandir($dir) as $item) {
35
- if (preg_match("/.php$/i", $item)) {
36
- require_once ($dir . $item);
37
- $className = str_replace(".php", "", $item);
38
- $classes[] = new $className;
39
- }
40
- }
41
 
42
- if ($classes) {
43
- foreach ($classes as $class) $this->objects[] = $class;
44
- }
45
- }
 
 
 
 
 
 
 
 
46
 
47
- function KcSeoLoadModel($dir){
48
- if (!file_exists($dir)) return;
49
- foreach (scandir($dir) as $item) {
50
- if (preg_match("/.php$/i", $item)) {
51
- require_once ($dir . $item);
52
- }
53
- }
54
- }
55
 
56
- function KeSeoLoadFunctions($dir){
57
- if (!file_exists($dir)) return;
58
- foreach (scandir($dir) as $item) {
59
- if (preg_match("/.php$/i", $item)) {
60
- require_once ($dir . $item);
61
- }
62
- }
63
- }
 
 
64
 
65
- function render($viewName, $args = array()) {
66
- global $KcSeoWPSchema;
67
- $path = str_replace(".","/", $viewName);
68
- $viewPath = $KcSeoWPSchema->viewsPath . $path . '.php';
69
- if (!file_exists($viewPath)) return;
 
 
 
 
 
70
 
71
- if ($args) extract($args);
72
- $pageReturn = include $viewPath;
73
- if ($pageReturn AND $pageReturn <> 1) return $pageReturn;
74
- if (@$html) return $html;
75
- }
 
 
76
 
77
- /**
78
- * Dynamicaly call any method from models class
79
- * by pluginFramework instance
80
- */
81
- function __call($name, $args) {
82
- if (!is_array($this->objects)) return;
83
- foreach ($this->objects as $object) {
84
- if (method_exists($object, $name)) {
85
- $count = count($args);
86
- if ($count == 0) return $object->$name();
87
- elseif ($count == 1) return $object->$name($args[0]);
88
- elseif ($count == 2) return $object->$name($args[0], $args[1]);
89
- elseif ($count == 3) return $object->$name($args[0], $args[1], $args[2]);
90
- elseif ($count == 4) return $object->$name($args[0], $args[1], $args[2], $args[3]);
91
- elseif ($count == 5) return $object->$name($args[0], $args[1], $args[2], $args[3], $args[4]);
92
- elseif ($count == 6) return $object->$name($args[0], $args[1], $args[2], $args[3], $args[4], $args[5]);
93
- }
94
- }
95
- }
96
- }
97
 
98
- global $KcSeoWPSchema;
99
- if (!is_object($KcSeoWPSchema))
100
- $KcSeoWPSchema = new KcseoWPSchema;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  }
1
  <?php
2
 
3
+ if ( ! class_exists( 'KcSeoWPSchema' ) ) {
4
 
5
+ class KcSeoWPSchema {
6
+ public $options;
7
+ public $KcSeoPrefix;
 
 
 
 
 
 
 
 
 
8
 
9
+ function __construct() {
10
+ $this->KcSeoPrefix = "_schema_";
11
+ $this->options = array(
12
+ 'settings' => 'kcseo_wp_schema',
13
+ 'installed_version' => 'kcseo_wp_installed_version',
14
+ 'version' => '2.1',
15
+ '1_2_fix' => "kcseo_wp_1_2_data_fix"
16
+ );
17
 
18
+ $this->incPath = dirname( __FILE__ );
19
+ $this->functionsPath = $this->incPath . '/functions/';
20
+ $this->classesPath = $this->incPath . '/classes/';
21
+ $this->viewsPath = $this->incPath . '/views/';
22
+ $this->assetsUrl = KCSEO_WP_SCHEMA_URL . '/assets/';
23
+ $this->modelPath = $this->incPath . '/models/';
24
 
25
+ $this->KeSeoLoadFunctions( $this->functionsPath );
26
+ $this->KcSeoLoadModel( $this->modelPath );
27
+ $this->KcSeoLoadClass( $this->classesPath );
28
 
29
+ }
 
 
 
 
 
 
 
 
 
30
 
31
+ function KcSeoLoadClass( $dir ) {
32
+ if ( ! file_exists( $dir ) ) {
33
+ return;
34
+ }
35
+ $classes = array();
36
+ foreach ( scandir( $dir ) as $item ) {
37
+ if ( preg_match( "/.php$/i", $item ) ) {
38
+ require_once( $dir . $item );
39
+ $className = str_replace( ".php", "", $item );
40
+ $classes[] = new $className;
41
+ }
42
+ }
43
 
44
+ if ( $classes ) {
45
+ foreach ( $classes as $class ) {
46
+ $this->objects[] = $class;
47
+ }
48
+ }
49
+ }
 
 
50
 
51
+ function KcSeoLoadModel( $dir ) {
52
+ if ( ! file_exists( $dir ) ) {
53
+ return;
54
+ }
55
+ foreach ( scandir( $dir ) as $item ) {
56
+ if ( preg_match( "/.php$/i", $item ) ) {
57
+ require_once( $dir . $item );
58
+ }
59
+ }
60
+ }
61
 
62
+ function KeSeoLoadFunctions( $dir ) {
63
+ if ( ! file_exists( $dir ) ) {
64
+ return;
65
+ }
66
+ foreach ( scandir( $dir ) as $item ) {
67
+ if ( preg_match( "/.php$/i", $item ) ) {
68
+ require_once( $dir . $item );
69
+ }
70
+ }
71
+ }
72
 
73
+ function render( $viewName, $args = array() ) {
74
+ global $KcSeoWPSchema;
75
+ $path = str_replace( ".", "/", $viewName );
76
+ $viewPath = $KcSeoWPSchema->viewsPath . $path . '.php';
77
+ if ( ! file_exists( $viewPath ) ) {
78
+ return;
79
+ }
80
 
81
+ if ( $args ) {
82
+ extract( $args );
83
+ }
84
+ $pageReturn = include $viewPath;
85
+ if ( $pageReturn AND $pageReturn <> 1 ) {
86
+ return $pageReturn;
87
+ }
88
+ if ( @$html ) {
89
+ return $html;
90
+ }
91
+ }
 
 
 
 
 
 
 
 
 
92
 
93
+ /**
94
+ * Dynamicaly call any method from models class
95
+ * by pluginFramework instance
96
+ */
97
+ function __call( $name, $args ) {
98
+ if ( ! is_array( $this->objects ) ) {
99
+ return;
100
+ }
101
+ foreach ( $this->objects as $object ) {
102
+ if ( method_exists( $object, $name ) ) {
103
+ $count = count( $args );
104
+ if ( $count == 0 ) {
105
+ return $object->$name();
106
+ } elseif ( $count == 1 ) {
107
+ return $object->$name( $args[0] );
108
+ } elseif ( $count == 2 ) {
109
+ return $object->$name( $args[0], $args[1] );
110
+ } elseif ( $count == 3 ) {
111
+ return $object->$name( $args[0], $args[1], $args[2] );
112
+ } elseif ( $count == 4 ) {
113
+ return $object->$name( $args[0], $args[1], $args[2], $args[3] );
114
+ } elseif ( $count == 5 ) {
115
+ return $object->$name( $args[0], $args[1], $args[2], $args[3], $args[4] );
116
+ } elseif ( $count == 6 ) {
117
+ return $object->$name( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5] );
118
+ }
119
+ }
120
+ }
121
+ }
122
+ }
123
+
124
+ global $KcSeoWPSchema;
125
+ if ( ! is_object( $KcSeoWPSchema ) ) {
126
+ $KcSeoWPSchema = new KcseoWPSchema;
127
+ }
128
  }
lib/models/KcSeoSchemaModel.php CHANGED
@@ -207,8 +207,8 @@ if ( ! class_exists( 'KcSeoSchemaModel' ) ):
207
  }
208
  if ( ! empty( $metaData['performerName'] ) ) {
209
  $event["performer"] = array(
210
- "@type" => "Person",
211
- "name" => $KcSeoWPSchema->sanitizeOutPut( $metaData['performerName'] )
212
  );
213
  }
214
  if ( ! empty( $metaData['image'] ) ) {
@@ -243,7 +243,8 @@ if ( ! class_exists( 'KcSeoSchemaModel' ) ):
243
  $product["name"] = $KcSeoWPSchema->sanitizeOutPut( $metaData['name'] );
244
  }
245
  if ( ! empty( $metaData['image'] ) ) {
246
- $product["image"] = $KcSeoWPSchema->sanitizeOutPut( $metaData['image'] );
 
247
  }
248
  if ( ! empty( $metaData['description'] ) ) {
249
  $product["description"] = $KcSeoWPSchema->sanitizeOutPut( $metaData['description'] );
@@ -407,9 +408,9 @@ if ( ! class_exists( 'KcSeoSchemaModel' ) ):
407
  if ( ! empty( $metaData['description'] ) ) {
408
  $aRating["description"] = $KcSeoWPSchema->sanitizeOutPut( $metaData['description'], 'textarea' );
409
  }
410
- if( $aRating["@type"] != "Organization"){
411
  if ( ! empty( $metaData['image'] ) ) {
412
- $img = $KcSeoWPSchema->imageInfo( absint( $metaData['image'] ) );
413
  $aRating["image"] = array(
414
  "@type" => "ImageObject",
415
  "url" => $KcSeoWPSchema->sanitizeOutPut( $img['url'], 'url' ),
@@ -425,7 +426,7 @@ if ( ! class_exists( 'KcSeoSchemaModel' ) ):
425
  }
426
 
427
  if ( ! empty( $metaData['address'] ) ) {
428
- $aRating["address"] = $KcSeoWPSchema->sanitizeOutPut( $metaData['address'] );
429
  }
430
  }
431
 
@@ -448,6 +449,41 @@ if ( ! class_exists( 'KcSeoSchemaModel' ) ):
448
  $html .= $this->get_jsonEncode( $aRating );
449
  break;
450
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
451
  default:
452
  break;
453
  }
@@ -464,20 +500,20 @@ if ( ! class_exists( 'KcSeoSchemaModel' ) ):
464
  $name = $data['name'];
465
  $value = $data['value'];
466
 
467
- $class = isset( $data['class'] ) ? ( $data['class'] ? $data['class'] : null ) : null;
468
- $require = ( isset( $data['required'] ) ? ( $data['required'] ? "<span class='required'>*</span>" : null ) : null );
469
- $title = ( isset( $data['title'] ) ? ( $data['title'] ? $data['title'] : null ) : null );
470
- $desc = ( isset( $data['desc'] ) ? ( $data['desc'] ? $data['desc'] : null ) : null );
471
- $holderClass = ( !empty( $data['holderClass'] ) ? $data['holderClass'] : null );
472
- $html .= "<div class='field-container {$holderClass}' id='" . $id . '-container' . "'>";
473
- $html .= "<label class='field-label' for='{$id}'>{$title}{$require}</label>";
474
- $html .= "<div class='field-content' id='" . $id . '-content' . "'>";
475
  switch ( $data['type'] ) {
476
  case 'checkbox':
477
  $checked = ( $value ? "checked" : null );
478
- $html .= "<div class='kSeo-checkbox-wrapper'>";
479
- $html .= "<label for='{$id}'><input type='checkbox' id='{$id}' class='{$class}' name='{$name}' {$checked} value='1' /> Enable</label>";
480
- $html .= "</div>";
481
  break;
482
 
483
  case 'text':
@@ -496,23 +532,23 @@ if ( ! class_exists( 'KcSeoSchemaModel' ) ):
496
  break;
497
 
498
  case 'image':
499
- $html .= '<div class="kSeo-image">';
500
- $ImageId = ! empty( $value ) ? absint( $value ) : 0;
501
- $image = $ingInfo = null;
502
- if ( $ImageId ) {
503
- $image = wp_get_attachment_image( $ImageId, "thumbnail" );
504
- $imgData = $KcSeoWPSchema->imageInfo( $ImageId );
505
- $ingInfo .= "<span><strong>URL: </strong>{$imgData['url']}</span>";
506
- $ingInfo .= "<span><strong>Width: </strong>{$imgData['width']}px</span>";
507
- $ingInfo .= "<span><strong>Height: </strong>{$imgData['height']}px</span>";
508
- }
509
- $html .= "<div class='kSeo-image-wrapper'>";
510
- $html .= '<span class="kSeoImgAdd"><span class="dashicons dashicons-plus-alt"></span></span>';
511
- $html .= '<span class="kSeoImgRemove ' . ( $image ? null : "kSeo-hidden" ) . '"><span class="dashicons dashicons-trash"></span></span>';
512
- $html .= '<div class="kSeo-image-preview">' . $image . '</div>';
513
- $html .= "<input type='hidden' name='{$name}' value='" . absint( $ImageId ) . "' />";
514
- $html .= "</div>";
515
- $html .= "<div class='image-info'>{$ingInfo}</div>";
516
  $html .= '</div>';
517
  break;
518
  case 'select':
@@ -523,12 +559,12 @@ if ( ! class_exists( 'KcSeoSchemaModel' ) ):
523
  if ( ! empty( $data['options'] ) && is_array( $data['options'] ) ) {
524
  if ( $this->isAssoc( $data['options'] ) ) {
525
  foreach ( $data['options'] as $optKey => $optValue ) {
526
- $slt = ( $optKey == $value ? "selected" : null );
527
  $html .= "<option value='" . esc_attr( $optKey ) . "' {$slt}>" . esc_html( $optValue ) . "</option>";
528
  }
529
  } else {
530
  foreach ( $data['options'] as $optValue ) {
531
- $slt = ( $optValue == $value ? "selected" : null );
532
  $html .= "<option value='" . esc_attr( $optValue ) . "' {$slt}>" . esc_html( $optValue ) . "</option>";
533
  }
534
  }
@@ -789,18 +825,18 @@ if ( ! class_exists( 'KcSeoSchemaModel' ) ):
789
  'required' => true,
790
  'desc' => "Event start date"
791
  ),
792
- 'endDate' => array(
793
- 'title' => 'End date (Recommended)',
794
- 'type' => 'text',
795
- 'class' => 'kcseo-date',
796
- 'desc' => "Event end date"
797
  ),
798
- 'description' => array(
799
  'title' => 'Description (Recommended)',
800
  'type' => 'textarea',
801
  'desc' => "Event description"
802
  ),
803
- 'performerName' => array(
804
  'title' => 'Performer Name (Recommended)',
805
  'type' => 'text',
806
  'desc' => "The performer's name."
@@ -931,7 +967,7 @@ if ( ! class_exists( 'KcSeoSchemaModel' ) ):
931
  'thumbnailUrl' => array(
932
  'title' => 'Thumbnail URL',
933
  'type' => 'url',
934
- 'placeholder' => "URL",
935
  'required' => true,
936
  'desc' => "A URL pointing to the video thumbnail image file. Images must be at least 160x90 pixels and at most 1920x1080 pixels."
937
  ),
@@ -1126,26 +1162,26 @@ if ( ! class_exists( 'KcSeoSchemaModel' ) ):
1126
  'required' => true,
1127
  'desc' => "The item that is being rated."
1128
  ),
1129
- 'image' => array(
1130
- 'title' => 'Image',
1131
- 'type' => 'image',
1132
- 'required' => true,
1133
  'holderClass' => 'kSeo-hidden aggregate-except-organization-holder'
1134
  ),
1135
- 'priceRange' => array(
1136
- 'title' => 'Price Range (Recommended)',
1137
- 'type' => 'text',
1138
  'holderClass' => 'kSeo-hidden aggregate-except-organization-holder',
1139
- 'desc' => "The price range of the business, for example $$$."
1140
  ),
1141
- 'telephone' => array(
1142
- 'title' => 'Telephone (Recommended)',
1143
- 'type' => 'text',
1144
  'holderClass' => 'kSeo-hidden aggregate-except-organization-holder'
1145
  ),
1146
- 'address' => array(
1147
- 'title' => 'Address (Recommended)',
1148
- 'type' => 'text',
1149
  'holderClass' => 'kSeo-hidden aggregate-except-organization-holder',
1150
  ),
1151
  'description' => array(
@@ -1190,6 +1226,57 @@ if ( ! class_exists( 'KcSeoSchemaModel' ) ):
1190
  'desc' => "The lowest value allowed in this rating system. <span class='required'>* Required if the rating system is not a 5-point scale.</span> If worstRating is omitted, 1 is assumed."
1191
  )
1192
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1193
  )
1194
  );
1195
  }
207
  }
208
  if ( ! empty( $metaData['performerName'] ) ) {
209
  $event["performer"] = array(
210
+ "@type" => "Person",
211
+ "name" => $KcSeoWPSchema->sanitizeOutPut( $metaData['performerName'] )
212
  );
213
  }
214
  if ( ! empty( $metaData['image'] ) ) {
243
  $product["name"] = $KcSeoWPSchema->sanitizeOutPut( $metaData['name'] );
244
  }
245
  if ( ! empty( $metaData['image'] ) ) {
246
+ $img = $KcSeoWPSchema->imageInfo( absint( $metaData['image'] ) );
247
+ $product["image"] = $KcSeoWPSchema->sanitizeOutPut( $img['url'], 'url' );
248
  }
249
  if ( ! empty( $metaData['description'] ) ) {
250
  $product["description"] = $KcSeoWPSchema->sanitizeOutPut( $metaData['description'] );
408
  if ( ! empty( $metaData['description'] ) ) {
409
  $aRating["description"] = $KcSeoWPSchema->sanitizeOutPut( $metaData['description'], 'textarea' );
410
  }
411
+ if ( $aRating["@type"] != "Organization" ) {
412
  if ( ! empty( $metaData['image'] ) ) {
413
+ $img = $KcSeoWPSchema->imageInfo( absint( $metaData['image'] ) );
414
  $aRating["image"] = array(
415
  "@type" => "ImageObject",
416
  "url" => $KcSeoWPSchema->sanitizeOutPut( $img['url'], 'url' ),
426
  }
427
 
428
  if ( ! empty( $metaData['address'] ) ) {
429
+ $aRating["address"] = $KcSeoWPSchema->sanitizeOutPut( $metaData['address'] );
430
  }
431
  }
432
 
449
  $html .= $this->get_jsonEncode( $aRating );
450
  break;
451
 
452
+ case 'restaurant':
453
+ $restaurant = array();
454
+ $restaurant["@context"] = "http://schema.org";
455
+ $restaurant["@type"] = "Restaurant";
456
+ if ( ! empty( $metaData['name'] ) ) {
457
+ $restaurant["name"] = $KcSeoWPSchema->sanitizeOutPut( $metaData['name'] );
458
+ }
459
+ if ( ! empty( $metaData['description'] ) ) {
460
+ $restaurant["description"] = $KcSeoWPSchema->sanitizeOutPut( $metaData['description'], 'textarea' );
461
+ }
462
+ if ( ! empty( $metaData['openingHours'] ) ) {
463
+ $restaurant["openingHours"] = $KcSeoWPSchema->sanitizeOutPut( $metaData['openingHours'], 'textarea' );
464
+ }
465
+ if ( ! empty( $metaData['telephone'] ) ) {
466
+ $restaurant["telephone"] = $KcSeoWPSchema->sanitizeOutPut( $metaData['telephone'] );
467
+ }
468
+ if ( ! empty( $metaData['menu'] ) ) {
469
+ $restaurant["menu"] = $KcSeoWPSchema->sanitizeOutPut( $metaData['menu'], 'url' );
470
+ }
471
+ if ( ! empty( $metaData['image'] ) ) {
472
+ $img = $KcSeoWPSchema->imageInfo( absint( $metaData['image'] ) );
473
+ $restaurant["image"] = $KcSeoWPSchema->sanitizeOutPut( $img['url'], 'url' );
474
+ }
475
+ if ( ! empty( $metaData['address'] ) ) {
476
+ $restaurant["address"] = $KcSeoWPSchema->sanitizeOutPut( $metaData['address'], 'textarea' );
477
+ }
478
+ if ( ! empty( $metaData['priceRange'] ) ) {
479
+ $restaurant["priceRange"] = $KcSeoWPSchema->sanitizeOutPut( $metaData['priceRange'] );
480
+ }
481
+ if ( ! empty( $metaData['servesCuisine'] ) ) {
482
+ $restaurant["servesCuisine"] = $KcSeoWPSchema->sanitizeOutPut( $metaData['servesCuisine'] );
483
+ }
484
+ $html .= $this->get_jsonEncode( $restaurant );
485
+ break;
486
+
487
  default:
488
  break;
489
  }
500
  $name = $data['name'];
501
  $value = $data['value'];
502
 
503
+ $class = isset( $data['class'] ) ? ( $data['class'] ? $data['class'] : null ) : null;
504
+ $require = ( isset( $data['required'] ) ? ( $data['required'] ? "<span class='required'>*</span>" : null ) : null );
505
+ $title = ( isset( $data['title'] ) ? ( $data['title'] ? $data['title'] : null ) : null );
506
+ $desc = ( isset( $data['desc'] ) ? ( $data['desc'] ? $data['desc'] : null ) : null );
507
+ $holderClass = ( ! empty( $data['holderClass'] ) ? $data['holderClass'] : null );
508
+ $html .= "<div class='field-container {$holderClass}' id='" . $id . '-container' . "'>";
509
+ $html .= "<label class='field-label' for='{$id}'>{$title}{$require}</label>";
510
+ $html .= "<div class='field-content' id='" . $id . '-content' . "'>";
511
  switch ( $data['type'] ) {
512
  case 'checkbox':
513
  $checked = ( $value ? "checked" : null );
514
+ $html .= "<div class='kSeo-checkbox-wrapper'>";
515
+ $html .= "<label for='{$id}'><input type='checkbox' id='{$id}' class='{$class}' name='{$name}' {$checked} value='1' /> Enable</label>";
516
+ $html .= "</div>";
517
  break;
518
 
519
  case 'text':
532
  break;
533
 
534
  case 'image':
535
+ $html .= '<div class="kSeo-image">';
536
+ $ImageId = ! empty( $value ) ? absint( $value ) : 0;
537
+ $image = $ingInfo = null;
538
+ if ( $ImageId ) {
539
+ $image = wp_get_attachment_image( $ImageId, "thumbnail" );
540
+ $imgData = $KcSeoWPSchema->imageInfo( $ImageId );
541
+ $ingInfo .= "<span><strong>URL: </strong>{$imgData['url']}</span>";
542
+ $ingInfo .= "<span><strong>Width: </strong>{$imgData['width']}px</span>";
543
+ $ingInfo .= "<span><strong>Height: </strong>{$imgData['height']}px</span>";
544
+ }
545
+ $html .= "<div class='kSeo-image-wrapper'>";
546
+ $html .= '<span class="kSeoImgAdd"><span class="dashicons dashicons-plus-alt"></span></span>';
547
+ $html .= '<span class="kSeoImgRemove ' . ( $image ? null : "kSeo-hidden" ) . '"><span class="dashicons dashicons-trash"></span></span>';
548
+ $html .= '<div class="kSeo-image-preview">' . $image . '</div>';
549
+ $html .= "<input type='hidden' name='{$name}' value='" . absint( $ImageId ) . "' />";
550
+ $html .= "</div>";
551
+ $html .= "<div class='image-info'>{$ingInfo}</div>";
552
  $html .= '</div>';
553
  break;
554
  case 'select':
559
  if ( ! empty( $data['options'] ) && is_array( $data['options'] ) ) {
560
  if ( $this->isAssoc( $data['options'] ) ) {
561
  foreach ( $data['options'] as $optKey => $optValue ) {
562
+ $slt = ( $optKey == $value ? "selected" : null );
563
  $html .= "<option value='" . esc_attr( $optKey ) . "' {$slt}>" . esc_html( $optValue ) . "</option>";
564
  }
565
  } else {
566
  foreach ( $data['options'] as $optValue ) {
567
+ $slt = ( $optValue == $value ? "selected" : null );
568
  $html .= "<option value='" . esc_attr( $optValue ) . "' {$slt}>" . esc_html( $optValue ) . "</option>";
569
  }
570
  }
825
  'required' => true,
826
  'desc' => "Event start date"
827
  ),
828
+ 'endDate' => array(
829
+ 'title' => 'End date (Recommended)',
830
+ 'type' => 'text',
831
+ 'class' => 'kcseo-date',
832
+ 'desc' => "Event end date"
833
  ),
834
+ 'description' => array(
835
  'title' => 'Description (Recommended)',
836
  'type' => 'textarea',
837
  'desc' => "Event description"
838
  ),
839
+ 'performerName' => array(
840
  'title' => 'Performer Name (Recommended)',
841
  'type' => 'text',
842
  'desc' => "The performer's name."
967
  'thumbnailUrl' => array(
968
  'title' => 'Thumbnail URL',
969
  'type' => 'url',
970
+ 'placeholder' => "URL",
971
  'required' => true,
972
  'desc' => "A URL pointing to the video thumbnail image file. Images must be at least 160x90 pixels and at most 1920x1080 pixels."
973
  ),
1162
  'required' => true,
1163
  'desc' => "The item that is being rated."
1164
  ),
1165
+ 'image' => array(
1166
+ 'title' => 'Image',
1167
+ 'type' => 'image',
1168
+ 'required' => true,
1169
  'holderClass' => 'kSeo-hidden aggregate-except-organization-holder'
1170
  ),
1171
+ 'priceRange' => array(
1172
+ 'title' => 'Price Range (Recommended)',
1173
+ 'type' => 'text',
1174
  'holderClass' => 'kSeo-hidden aggregate-except-organization-holder',
1175
+ 'desc' => "The price range of the business, for example $$$."
1176
  ),
1177
+ 'telephone' => array(
1178
+ 'title' => 'Telephone (Recommended)',
1179
+ 'type' => 'text',
1180
  'holderClass' => 'kSeo-hidden aggregate-except-organization-holder'
1181
  ),
1182
+ 'address' => array(
1183
+ 'title' => 'Address (Recommended)',
1184
+ 'type' => 'text',
1185
  'holderClass' => 'kSeo-hidden aggregate-except-organization-holder',
1186
  ),
1187
  'description' => array(
1226
  'desc' => "The lowest value allowed in this rating system. <span class='required'>* Required if the rating system is not a 5-point scale.</span> If worstRating is omitted, 1 is assumed."
1227
  )
1228
  )
1229
+ ),
1230
+ 'restaurant' => array(
1231
+ 'title' => 'Restaurant',
1232
+ 'fields' => array(
1233
+ 'active' => array(
1234
+ 'type' => 'checkbox'
1235
+ ),
1236
+ 'name' => array(
1237
+ 'title' => 'Name of the Restaurant',
1238
+ 'type' => 'text',
1239
+ 'required' => true
1240
+ ),
1241
+ 'description' => array(
1242
+ 'title' => 'Description of the Restaurant',
1243
+ 'type' => 'textarea',
1244
+ ),
1245
+ 'openingHours' => array(
1246
+ 'title' => 'Opening Hours',
1247
+ 'type' => 'textarea',
1248
+ 'desc' => 'Mo,Tu,We,Th,Fr,Sa,Su 11:30-23:00'
1249
+ ),
1250
+ 'telephone' => array(
1251
+ 'title' => 'Opening Hours',
1252
+ 'type' => 'text',
1253
+ 'desc' => '+155501003333'
1254
+ ),
1255
+ 'menu' => array(
1256
+ 'title' => 'Menu',
1257
+ 'type' => 'text',
1258
+ 'desc' => 'http://example.com/menu'
1259
+ ),
1260
+ 'image' => array(
1261
+ 'title' => 'Image',
1262
+ 'type' => 'image',
1263
+ 'required' => true
1264
+ ),
1265
+ 'address' => array(
1266
+ 'title' => 'Address',
1267
+ 'type' => 'textarea'
1268
+ ),
1269
+ 'priceRange' => array(
1270
+ 'title' => 'Price Range',
1271
+ 'type' => 'text',
1272
+ 'desc' => 'The price range of the business, for example $$$'
1273
+ ),
1274
+ 'servesCuisine' => array(
1275
+ 'title' => 'Serves Cuisine',
1276
+ 'type' => 'text',
1277
+ 'desc' => 'The cuisine of the restaurant.'
1278
+ )
1279
+ )
1280
  )
1281
  );
1282
  }
lib/views/settings.php CHANGED
@@ -473,6 +473,20 @@ $schemaModel = new KcSeoSchemaModel;
473
  </td>
474
  </tr>
475
  </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
476
  <p class="submit"><input type="submit" name="submit" id="tlpSaveButton" class="button button-primary"
477
  value="<?php _e( 'Save Changes', KCSEO_WP_SCHEMA_SLUG ); ?>"></p>
478
 
473
  </td>
474
  </tr>
475
  </table>
476
+ <h2>Schema Settings</h2>
477
+ <table width="100%" cellpadding="10" class="form-table">
478
+ <tr class="default">
479
+ <th>Delete all data</th>
480
+ <td align="left" scope="row">
481
+ <input type="checkbox"
482
+ name="delete-data" <?php echo( ! empty( $settings['delete-data'] ) ? "checked" : null ); ?>
483
+ value="1"
484
+ id="delete-data"
485
+ /><label for="delete-data">Enable</label>
486
+ <p class="description">This will delete all schema data when plugin is deleted.</p>
487
+ </td>
488
+ </tr>
489
+ </table>
490
  <p class="submit"><input type="submit" name="submit" id="tlpSaveButton" class="button button-primary"
491
  value="<?php _e( 'Save Changes', KCSEO_WP_SCHEMA_SLUG ); ?>"></p>
492
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ 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.7
7
- Stable tag: 2.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -93,6 +93,11 @@ You'll find the [FAQ on Kcseopro.com](http://kcseopro.com/).
93
 
94
  == Changelog ==
95
 
 
 
 
 
 
96
  = 2.0 =
97
  * Major update at coding and structure
98
  * Recover data from 1.2
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.8
7
+ Stable tag: 2.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
93
 
94
  == Changelog ==
95
 
96
+ = 2.1 =
97
+ * Can delete all save data
98
+ * Restaurant Schema (New)
99
+ * Image url fixed for product schema
100
+
101
  = 2.0 =
102
  * Major update at coding and structure
103
  * Recover data from 1.2
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: 2.0
7
  * Author: kcseopro
8
  * Author URI: http://kcseopro.com/
9
  * License: A "Slug" license name e.g. GPL2
@@ -24,4 +24,31 @@ define('KCSEO_WP_SCHEMA_PLUGIN_ACTIVE_FILE_NAME', plugin_basename( __FILE__ ));
24
  define('KCSEO_WP_SCHEMA_URL', plugins_url('', __FILE__));
25
  define('KCSEO_WP_SCHEMA_LANGUAGE_PATH', dirname( plugin_basename( __FILE__ ) ) . '/languages');
26
 
27
- 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: 2.1
7
  * Author: kcseopro
8
  * Author URI: http://kcseopro.com/
9
  * License: A "Slug" license name e.g. GPL2
24
  define('KCSEO_WP_SCHEMA_URL', plugins_url('', __FILE__));
25
  define('KCSEO_WP_SCHEMA_LANGUAGE_PATH', dirname( plugin_basename( __FILE__ ) ) . '/languages');
26
 
27
+ require ('lib/init.php');
28
+ register_uninstall_hook( __FILE__, 'KCSEO_uninstall');
29
+
30
+ function KCSEO_uninstall(){
31
+ global $KcSeoWPSchema;
32
+ $settings = get_option( $KcSeoWPSchema->options['settings'] );
33
+ if(! empty( $settings['delete-data'])){
34
+ $schemas = new KcSeoSchemaModel;
35
+ $schemaFields = $schemas->schemaTypes();
36
+
37
+ $args = array(
38
+ 'post_type' => array( 'page', 'post' ),
39
+ 'posts_per_page' => '-1'
40
+ );
41
+ $pages = new WP_Query ( $args );
42
+ if ( $pages->have_posts() ) {
43
+
44
+ while ( $pages->have_posts() ) {
45
+ $pages->the_post();
46
+ foreach ( $schemaFields as $schemaID => $schema ) {
47
+ delete_post_meta( get_the_ID(), '_schema_' . $schemaID );
48
+ }
49
+ }
50
+ wp_reset_postdata();
51
+ }
52
+ }
53
+
54
+ }