Version Description
(19 Sept 2019) =
- Major Feature: Schema type blocks (How To & FAQ) have been added in Gutenberg editor
- Added: Schema markup to category of WooCommerce #405
- Added: Option to remove data on uninstall in Advanced tab #468
- Added: Priority support in the Services section in the first place #346
- Bug Fixed: "[POST, PAGE] Specific Schema" options don't show up in /wp-admin/post-new.php #409
- Bug Fixed: Call to undefined function get_avatar_data #480
- Bug Fixed: Need to show the modify schema list based on target location of schema type #483
- Bug Fixed: Fatal error function bcdiv () #489
Download this release
Release Info
Developer | magazine3 |
Plugin | Schema & Structured Data for WP & AMP |
Version | 1.9.7 |
Comparing to | |
See all releases |
Code changes from version 1.9.6 to 1.9.7
- admin_section/common-function.php +118 -14
- admin_section/images/support-1.png +0 -0
- admin_section/settings.php +30 -2
- admin_section/structure_admin.php +46 -41
- core/array-list/local-sub-business.php +1 -1
- modules/gutenberg/assets/blocks/faq.js +454 -0
- modules/gutenberg/assets/blocks/how-to.js +551 -0
- modules/gutenberg/assets/css/editor.css +102 -0
- modules/gutenberg/assets/css/style.css +10 -0
- modules/gutenberg/includes/class-gutenberg.php +220 -0
- output/function.php +24 -3
- output/output.php +216 -85
- output/output_post_specific.php +1 -1
- output/review-output.php +7 -2
- output/service.php +115 -20
- readme.txt +17 -2
- structured-data-for-wp.php +6 -3
- view/post_specific.php +47 -27
admin_section/common-function.php
CHANGED
@@ -2179,16 +2179,22 @@ if ( ! defined('ABSPATH') ) exit;
|
|
2179 |
//All in one Seo pack
|
2180 |
if(saswp_remove_warnings($sd_data, 'saswp-aiosp', 'saswp_string') == 1){
|
2181 |
|
2182 |
-
global $aiosp, $post;
|
2183 |
-
|
2184 |
-
if($
|
2185 |
-
|
2186 |
-
|
2187 |
-
|
|
|
|
|
|
|
|
|
|
|
2188 |
}
|
2189 |
|
2190 |
//SEOPress
|
2191 |
if(saswp_remove_warnings($sd_data, 'saswp-seo-press', 'saswp_string') == 1){
|
|
|
2192 |
require_once ( WP_PLUGIN_DIR. '/wp-seopress/inc/functions/options-titles-metas.php'); //Social
|
2193 |
$c_excerpt = seopress_titles_the_description_content($post);
|
2194 |
|
@@ -2294,15 +2300,20 @@ if ( ! defined('ABSPATH') ) exit;
|
|
2294 |
|
2295 |
//All in one Seo pack
|
2296 |
if(saswp_remove_warnings($sd_data, 'saswp-aiosp', 'saswp_string') == 1){
|
2297 |
-
|
2298 |
-
global $aiosp;
|
2299 |
|
2300 |
-
|
2301 |
|
2302 |
-
if($
|
|
|
|
|
|
|
|
|
2303 |
$title = $c_title;
|
2304 |
-
|
2305 |
-
|
|
|
|
|
2306 |
}
|
2307 |
|
2308 |
//The seo framework
|
@@ -2388,8 +2399,12 @@ if ( ! defined('ABSPATH') ) exit;
|
|
2388 |
|
2389 |
}
|
2390 |
|
2391 |
-
$author_image
|
2392 |
-
|
|
|
|
|
|
|
|
|
2393 |
$author_details['@type'] = 'Person';
|
2394 |
$author_details['name'] = esc_attr($author_name);
|
2395 |
$author_details['description'] = esc_attr($author_desc);
|
@@ -2530,6 +2545,95 @@ function saswp_check_plugin_active_status($pname){
|
|
2530 |
|
2531 |
}
|
2532 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2533 |
function saswp_on_activation(){
|
2534 |
|
2535 |
$installation_date = get_option('saswp_installation_date');
|
2179 |
//All in one Seo pack
|
2180 |
if(saswp_remove_warnings($sd_data, 'saswp-aiosp', 'saswp_string') == 1){
|
2181 |
|
2182 |
+
global $aiosp, $post;
|
2183 |
+
|
2184 |
+
if(is_object($aiosp)){
|
2185 |
+
|
2186 |
+
$c_excerpt = $aiosp->get_aioseop_description($post);
|
2187 |
+
if($c_excerpt){
|
2188 |
+
$excerpt = $c_excerpt;
|
2189 |
+
}
|
2190 |
+
|
2191 |
+
}
|
2192 |
+
|
2193 |
}
|
2194 |
|
2195 |
//SEOPress
|
2196 |
if(saswp_remove_warnings($sd_data, 'saswp-seo-press', 'saswp_string') == 1){
|
2197 |
+
|
2198 |
require_once ( WP_PLUGIN_DIR. '/wp-seopress/inc/functions/options-titles-metas.php'); //Social
|
2199 |
$c_excerpt = seopress_titles_the_description_content($post);
|
2200 |
|
2300 |
|
2301 |
//All in one Seo pack
|
2302 |
if(saswp_remove_warnings($sd_data, 'saswp-aiosp', 'saswp_string') == 1){
|
2303 |
+
|
|
|
2304 |
|
2305 |
+
global $aiosp;
|
2306 |
|
2307 |
+
if(is_object($aiosp)){
|
2308 |
+
|
2309 |
+
$c_title = $aiosp->wp_title();
|
2310 |
+
|
2311 |
+
if($c_title){
|
2312 |
$title = $c_title;
|
2313 |
+
}
|
2314 |
+
|
2315 |
+
}
|
2316 |
+
|
2317 |
}
|
2318 |
|
2319 |
//The seo framework
|
2399 |
|
2400 |
}
|
2401 |
|
2402 |
+
$author_image = array();
|
2403 |
+
|
2404 |
+
if(function_exists('get_avatar_data')){
|
2405 |
+
$author_image = get_avatar_data($author_id);
|
2406 |
+
}
|
2407 |
+
|
2408 |
$author_details['@type'] = 'Person';
|
2409 |
$author_details['name'] = esc_attr($author_name);
|
2410 |
$author_details['description'] = esc_attr($author_desc);
|
2545 |
|
2546 |
}
|
2547 |
|
2548 |
+
function saswp_uninstall_single($blog_id = null){
|
2549 |
+
|
2550 |
+
try{
|
2551 |
+
|
2552 |
+
global $wpdb;
|
2553 |
+
|
2554 |
+
//SASWP post types
|
2555 |
+
$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type = %s", 'saswp' ) );
|
2556 |
+
|
2557 |
+
if ( $post_ids ) {
|
2558 |
+
$wpdb->delete(
|
2559 |
+
$wpdb->posts,
|
2560 |
+
array( 'post_type' => 'saswp' ),
|
2561 |
+
array( '%s' )
|
2562 |
+
);
|
2563 |
+
|
2564 |
+
$wpdb->query( "DELETE FROM {$wpdb->postmeta} WHERE post_id IN( " . implode( ',', $post_ids ) . " )" );
|
2565 |
+
}
|
2566 |
+
|
2567 |
+
if($post_ids){
|
2568 |
+
|
2569 |
+
$query = "SELECT ID FROM " . $wpdb->posts;
|
2570 |
+
$all_post_id = $wpdb->get_results($query, ARRAY_A );
|
2571 |
+
$all_post_id = wp_list_pluck( $all_post_id, 'ID' );
|
2572 |
+
$post_specific = new saswp_post_specific();
|
2573 |
+
|
2574 |
+
foreach($post_ids as $post_id){
|
2575 |
+
|
2576 |
+
$meta_fields = $post_specific->saswp_get_fields_by_schema_type($post_id);
|
2577 |
+
$meta_fields = wp_list_pluck( $meta_fields, 'id' );
|
2578 |
+
|
2579 |
+
foreach ($meta_fields as $meta_key){
|
2580 |
+
$wpdb->query( "DELETE FROM {$wpdb->postmeta} WHERE post_id IN( " . implode( ',', $all_post_id ) . " ) AND meta_key = '".$meta_key."'" );
|
2581 |
+
|
2582 |
+
}
|
2583 |
+
|
2584 |
+
}
|
2585 |
+
}
|
2586 |
+
|
2587 |
+
//Post specific post meta
|
2588 |
+
|
2589 |
+
//Review Post Types
|
2590 |
+
$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type = %s", 'saswp_reviews' ) );
|
2591 |
+
|
2592 |
+
if ( $post_ids ) {
|
2593 |
+
$wpdb->delete(
|
2594 |
+
$wpdb->posts,
|
2595 |
+
array( 'post_type' => 'saswp_reviews' ),
|
2596 |
+
array( '%s' )
|
2597 |
+
);
|
2598 |
+
|
2599 |
+
$wpdb->query( "DELETE FROM {$wpdb->postmeta} WHERE post_id IN( " . implode( ',', $post_ids ) . " )" );
|
2600 |
+
}
|
2601 |
+
|
2602 |
+
//All options
|
2603 |
+
delete_option('sd_data');
|
2604 |
+
|
2605 |
+
wp_cache_flush();
|
2606 |
+
|
2607 |
+
}catch(Exception $ex){
|
2608 |
+
echo $ex->getMessage();
|
2609 |
+
}
|
2610 |
+
|
2611 |
+
}
|
2612 |
+
|
2613 |
+
function saswp_on_uninstall(){
|
2614 |
+
|
2615 |
+
global $wpdb;
|
2616 |
+
|
2617 |
+
$options = get_option('sd_data');
|
2618 |
+
|
2619 |
+
if(isset($options['saswp_rmv_data_on_uninstall'])){
|
2620 |
+
|
2621 |
+
if ( ! is_multisite() ) {
|
2622 |
+
saswp_uninstall_single();
|
2623 |
+
} else {
|
2624 |
+
$blog_ids = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->blogs}" );
|
2625 |
+
|
2626 |
+
foreach ( $blog_ids as $blog_id ) {
|
2627 |
+
|
2628 |
+
saswp_uninstall_single($blog_id);
|
2629 |
+
}
|
2630 |
+
|
2631 |
+
}
|
2632 |
+
|
2633 |
+
}
|
2634 |
+
|
2635 |
+
}
|
2636 |
+
|
2637 |
function saswp_on_activation(){
|
2638 |
|
2639 |
$installation_date = get_option('saswp_installation_date');
|
admin_section/images/support-1.png
ADDED
Binary file
|
admin_section/settings.php
CHANGED
@@ -461,7 +461,7 @@ function saswp_premium_features_callback(){ ?>
|
|
461 |
<?php echo $cooked_active_text; ?>
|
462 |
|
463 |
</div>
|
464 |
-
</li>
|
465 |
</ul>
|
466 |
</div>
|
467 |
|
@@ -471,6 +471,23 @@ function saswp_premium_features_callback(){ ?>
|
|
471 |
function saswp_services_callback(){ ?>
|
472 |
<div class="saswp-pre-ftrs-wrap">
|
473 |
<ul class="saswp-features-blocks">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
474 |
<li>
|
475 |
<div class="saswp-features-ele">
|
476 |
<div class="saswp-ele-ic saswp-ele-3">
|
@@ -504,7 +521,7 @@ function saswp_services_callback(){ ?>
|
|
504 |
</div>
|
505 |
</a>
|
506 |
|
507 |
-
</li>
|
508 |
</ul>
|
509 |
</div>
|
510 |
|
@@ -1312,6 +1329,17 @@ function saswp_import_callback(){
|
|
1312 |
</li>
|
1313 |
|
1314 |
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1315 |
<?php
|
1316 |
|
1317 |
$add_on = array();
|
461 |
<?php echo $cooked_active_text; ?>
|
462 |
|
463 |
</div>
|
464 |
+
</li>
|
465 |
</ul>
|
466 |
</div>
|
467 |
|
471 |
function saswp_services_callback(){ ?>
|
472 |
<div class="saswp-pre-ftrs-wrap">
|
473 |
<ul class="saswp-features-blocks">
|
474 |
+
<li>
|
475 |
+
<div class="saswp-features-ele">
|
476 |
+
<div class="saswp-ele-ic saswp-ele-4" style="background: #69e781;">
|
477 |
+
<img src="<?php echo SASWP_PLUGIN_URL; ?>/admin_section/images/support-1.png">
|
478 |
+
</div>
|
479 |
+
<div class="saswp-ele-tlt">
|
480 |
+
<h3><?php echo esc_html__('Priority Support','schema-and-structured-data-for-wp') ?></h3>
|
481 |
+
<p><?php echo esc_html__('We get more than 100 technical queries a day but the Priority support plan will help you skip that and get the help from a dedicated team.','schema-and-structured-data-for-wp') ?></p>
|
482 |
+
</div>
|
483 |
+
</div>
|
484 |
+
<a target="_blank" href="https://structured-data-for-wp.com/priority-support//">
|
485 |
+
<div class="saswp-sts-btn">
|
486 |
+
<span class="saswp-d-btn"><?php echo esc_html__('Try it','schema-and-structured-data-for-wp') ?></span>
|
487 |
+
</div>
|
488 |
+
</a>
|
489 |
+
|
490 |
+
</li>
|
491 |
<li>
|
492 |
<div class="saswp-features-ele">
|
493 |
<div class="saswp-ele-ic saswp-ele-3">
|
521 |
</div>
|
522 |
</a>
|
523 |
|
524 |
+
</li>
|
525 |
</ul>
|
526 |
</div>
|
527 |
|
1329 |
</li>
|
1330 |
|
1331 |
</ul>
|
1332 |
+
|
1333 |
+
<ul>
|
1334 |
+
<li>
|
1335 |
+
<div class="">
|
1336 |
+
<div class="saswp-tooltip"><strong><?php echo esc_html__('Remove Data On Uninstall','schema-and-structured-data-for-wp'); ?></strong></div><input type="checkbox" id="saswp_rmv_data_on_uninstall" name="sd_data[saswp_rmv_data_on_uninstall]" <?php echo (isset($sd_data['saswp_rmv_data_on_uninstall'])? 'checked': ''); ?>>
|
1337 |
+
<p><?php echo esc_html__('This will remove all of its data when the plugin is deleted','schema-and-structured-data-for-wp'); ?></p>
|
1338 |
+
</div>
|
1339 |
+
</li>
|
1340 |
+
|
1341 |
+
</ul>
|
1342 |
+
|
1343 |
<?php
|
1344 |
|
1345 |
$add_on = array();
|
admin_section/structure_admin.php
CHANGED
@@ -141,29 +141,10 @@ function saswp_load_plugin_textdomain() {
|
|
141 |
add_action( 'plugins_loaded', 'saswp_load_plugin_textdomain' );
|
142 |
|
143 |
|
144 |
-
function saswp_get_all_schema_posts(){
|
145 |
-
|
146 |
-
$schema_id_array = array();
|
147 |
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
if(!$schema_id_array){
|
152 |
-
|
153 |
-
$schema_id_array = saswp_get_saved_schema_ids();
|
154 |
-
|
155 |
-
}
|
156 |
-
|
157 |
-
if($schema_id_array){
|
158 |
-
|
159 |
-
if(count($schema_id_array)>0){
|
160 |
-
|
161 |
-
$returnData = array();
|
162 |
-
|
163 |
-
foreach ($schema_id_array as $post_id){
|
164 |
-
|
165 |
$unique_checker = '';
|
166 |
-
|
167 |
$resultset = saswp_generate_field_data( $post_id );
|
168 |
|
169 |
if($resultset){
|
@@ -193,7 +174,7 @@ function saswp_get_all_schema_posts(){
|
|
193 |
$condition_array[] = $checker;
|
194 |
|
195 |
}
|
196 |
-
|
197 |
|
198 |
if($array_is_true){
|
199 |
|
@@ -202,11 +183,36 @@ function saswp_get_all_schema_posts(){
|
|
202 |
}
|
203 |
|
204 |
}else{
|
205 |
-
|
206 |
-
$unique_checker = 'notset';
|
207 |
-
|
208 |
}
|
209 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
if ( $unique_checker === 1 || $unique_checker === true || $unique_checker == 'notset') {
|
211 |
|
212 |
$conditions = array();
|
@@ -273,8 +279,7 @@ function saswp_generate_field_data( $post_id ){
|
|
273 |
|
274 |
function saswp_comparison_logic_checker($input){
|
275 |
|
276 |
-
global $post;
|
277 |
-
|
278 |
$type = $input['key_1'];
|
279 |
$comparison = $input['key_2'];
|
280 |
$data = $input['key_3'];
|
@@ -285,20 +290,20 @@ function saswp_comparison_logic_checker($input){
|
|
285 |
|
286 |
switch ($type) {
|
287 |
|
288 |
-
|
289 |
|
290 |
$result = true;
|
291 |
|
292 |
break;
|
293 |
// Basic Controls ------------
|
294 |
// Posts Type
|
295 |
-
|
296 |
|
297 |
$current_post_type = '';
|
298 |
|
299 |
-
if(is_singular()){
|
300 |
|
301 |
-
$current_post_type = $post->
|
302 |
|
303 |
}
|
304 |
|
@@ -320,7 +325,7 @@ function saswp_comparison_logic_checker($input){
|
|
320 |
|
321 |
|
322 |
// Posts
|
323 |
-
|
324 |
|
325 |
$homepage ='false';
|
326 |
|
@@ -342,7 +347,7 @@ function saswp_comparison_logic_checker($input){
|
|
342 |
break;
|
343 |
|
344 |
// Logged in User Type
|
345 |
-
|
346 |
if ( $comparison == 'equal') {
|
347 |
if ( in_array( $data, (array) $user->roles ) ) {
|
348 |
$result = true;
|
@@ -373,11 +378,11 @@ function saswp_comparison_logic_checker($input){
|
|
373 |
|
374 |
// Post Controls ------------
|
375 |
// Posts
|
376 |
-
|
377 |
|
378 |
$current_post ='';
|
379 |
|
380 |
-
if(is_singular()){
|
381 |
$current_post = $post->ID;
|
382 |
}
|
383 |
|
@@ -395,7 +400,7 @@ function saswp_comparison_logic_checker($input){
|
|
395 |
break;
|
396 |
|
397 |
// Post Category
|
398 |
-
|
399 |
|
400 |
$current_category = '';
|
401 |
|
@@ -422,7 +427,7 @@ function saswp_comparison_logic_checker($input){
|
|
422 |
}
|
423 |
break;
|
424 |
// Post Format
|
425 |
-
|
426 |
|
427 |
$current_post_format = '';
|
428 |
|
@@ -449,7 +454,7 @@ function saswp_comparison_logic_checker($input){
|
|
449 |
|
450 |
// Page Controls ----------------
|
451 |
// Page
|
452 |
-
|
453 |
|
454 |
global $redux_builder_amp;
|
455 |
|
@@ -480,7 +485,7 @@ function saswp_comparison_logic_checker($input){
|
|
480 |
break;
|
481 |
|
482 |
// Page Template
|
483 |
-
|
484 |
|
485 |
$current_page_template = '';
|
486 |
|
@@ -508,7 +513,7 @@ function saswp_comparison_logic_checker($input){
|
|
508 |
|
509 |
// Other Controls ---------------
|
510 |
// Taxonomy Term
|
511 |
-
|
512 |
// Get all the post registered taxonomies
|
513 |
// Get the list of all the taxonomies associated with current post
|
514 |
$taxonomy_names = get_post_taxonomies( $post->ID );
|
141 |
add_action( 'plugins_loaded', 'saswp_load_plugin_textdomain' );
|
142 |
|
143 |
|
|
|
|
|
|
|
144 |
|
145 |
+
function saswp_check_advance_display_status($post_id){
|
146 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
$unique_checker = '';
|
|
|
148 |
$resultset = saswp_generate_field_data( $post_id );
|
149 |
|
150 |
if($resultset){
|
174 |
$condition_array[] = $checker;
|
175 |
|
176 |
}
|
177 |
+
$array_is_true = in_array(true,$condition_array);
|
178 |
|
179 |
if($array_is_true){
|
180 |
|
183 |
}
|
184 |
|
185 |
}else{
|
186 |
+
$unique_checker = 'notset';
|
|
|
|
|
187 |
}
|
188 |
+
|
189 |
+
return $unique_checker;
|
190 |
+
|
191 |
+
}
|
192 |
+
|
193 |
+
function saswp_get_all_schema_posts(){
|
194 |
+
|
195 |
+
$schema_id_array = array();
|
196 |
+
|
197 |
+
$schema_id_array = json_decode(get_transient('saswp_transient_schema_ids'), true);
|
198 |
+
|
199 |
+
|
200 |
+
if(!$schema_id_array){
|
201 |
+
|
202 |
+
$schema_id_array = saswp_get_saved_schema_ids();
|
203 |
+
|
204 |
+
}
|
205 |
+
|
206 |
+
if($schema_id_array){
|
207 |
+
|
208 |
+
if(count($schema_id_array)>0){
|
209 |
+
|
210 |
+
$returnData = array();
|
211 |
+
|
212 |
+
foreach ($schema_id_array as $post_id){
|
213 |
+
|
214 |
+
$unique_checker = saswp_check_advance_display_status($post_id);
|
215 |
+
|
216 |
if ( $unique_checker === 1 || $unique_checker === true || $unique_checker == 'notset') {
|
217 |
|
218 |
$conditions = array();
|
279 |
|
280 |
function saswp_comparison_logic_checker($input){
|
281 |
|
282 |
+
global $post;
|
|
|
283 |
$type = $input['key_1'];
|
284 |
$comparison = $input['key_2'];
|
285 |
$data = $input['key_3'];
|
290 |
|
291 |
switch ($type) {
|
292 |
|
293 |
+
case 'show_globally':
|
294 |
|
295 |
$result = true;
|
296 |
|
297 |
break;
|
298 |
// Basic Controls ------------
|
299 |
// Posts Type
|
300 |
+
case 'post_type':
|
301 |
|
302 |
$current_post_type = '';
|
303 |
|
304 |
+
if(is_singular() || is_admin()){
|
305 |
|
306 |
+
$current_post_type = get_post_type($post->ID);
|
307 |
|
308 |
}
|
309 |
|
325 |
|
326 |
|
327 |
// Posts
|
328 |
+
case 'homepage':
|
329 |
|
330 |
$homepage ='false';
|
331 |
|
347 |
break;
|
348 |
|
349 |
// Logged in User Type
|
350 |
+
case 'user_type':
|
351 |
if ( $comparison == 'equal') {
|
352 |
if ( in_array( $data, (array) $user->roles ) ) {
|
353 |
$result = true;
|
378 |
|
379 |
// Post Controls ------------
|
380 |
// Posts
|
381 |
+
case 'post':
|
382 |
|
383 |
$current_post ='';
|
384 |
|
385 |
+
if(is_singular() || is_admin()){
|
386 |
$current_post = $post->ID;
|
387 |
}
|
388 |
|
400 |
break;
|
401 |
|
402 |
// Post Category
|
403 |
+
case 'post_category':
|
404 |
|
405 |
$current_category = '';
|
406 |
|
427 |
}
|
428 |
break;
|
429 |
// Post Format
|
430 |
+
case 'post_format':
|
431 |
|
432 |
$current_post_format = '';
|
433 |
|
454 |
|
455 |
// Page Controls ----------------
|
456 |
// Page
|
457 |
+
case 'page':
|
458 |
|
459 |
global $redux_builder_amp;
|
460 |
|
485 |
break;
|
486 |
|
487 |
// Page Template
|
488 |
+
case 'page_template':
|
489 |
|
490 |
$current_page_template = '';
|
491 |
|
513 |
|
514 |
// Other Controls ---------------
|
515 |
// Taxonomy Term
|
516 |
+
case 'ef_taxonomy':
|
517 |
// Get all the post registered taxonomies
|
518 |
// Get the list of all the taxonomies associated with current post
|
519 |
$taxonomy_names = get_post_taxonomies( $post->ID );
|
core/array-list/local-sub-business.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
return array(
|
3 |
-
|
4 |
'' => 'Select Sub Business Type ( optional )',
|
5 |
'autobodyshop' => 'Auto Body Shop',
|
6 |
'autodealer' => 'Auto Dealer',
|
1 |
<?php
|
2 |
return array(
|
3 |
+
'automotivebusiness' => array(
|
4 |
'' => 'Select Sub Business Type ( optional )',
|
5 |
'autobodyshop' => 'Auto Body Shop',
|
6 |
'autodealer' => 'Auto Dealer',
|
modules/gutenberg/assets/blocks/faq.js
ADDED
@@ -0,0 +1,454 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
( function( blocks, element, editor, components ) {
|
3 |
+
var el = element.createElement;
|
4 |
+
var RichText = editor.RichText;
|
5 |
+
var MediaUpload = editor.MediaUpload;
|
6 |
+
var IconButton = components.IconButton;
|
7 |
+
var AlignmentToolbar = editor.AlignmentToolbar;
|
8 |
+
var BlockControls = editor.BlockControls;
|
9 |
+
var InspectorControls = editor.InspectorControls;
|
10 |
+
var ToggleControl = components.ToggleControl;
|
11 |
+
var PanelBody = components.PanelBody;
|
12 |
+
|
13 |
+
blocks.registerBlockType( 'saswp/faq-block', {
|
14 |
+
title: 'FAQ (SASWP)',
|
15 |
+
icon: 'text',
|
16 |
+
category: 'saswp-blocks',
|
17 |
+
keywords: ['schema', 'structured data', 'FAQ', 'faq'],
|
18 |
+
|
19 |
+
// Allow only one How To block per post.
|
20 |
+
supports: {
|
21 |
+
multiple: false
|
22 |
+
},
|
23 |
+
|
24 |
+
attributes: {
|
25 |
+
alignment: {
|
26 |
+
type: 'string',
|
27 |
+
default: 'none'
|
28 |
+
},
|
29 |
+
toggleList: {
|
30 |
+
type: 'boolean',
|
31 |
+
default: false
|
32 |
+
},
|
33 |
+
items: {
|
34 |
+
default: [{index: 0, title: "", description: "", imageUrl: "", imageId: null}],
|
35 |
+
selector: '.saswp-faq-block-data',
|
36 |
+
query: {
|
37 |
+
title: {
|
38 |
+
type: 'string',
|
39 |
+
selector: '.title'
|
40 |
+
},
|
41 |
+
description: {
|
42 |
+
type: 'string',
|
43 |
+
selector: '.description'
|
44 |
+
},
|
45 |
+
imageId: {
|
46 |
+
type: 'integer'
|
47 |
+
},
|
48 |
+
imageUrl: {
|
49 |
+
type: 'string'
|
50 |
+
},
|
51 |
+
index: {
|
52 |
+
type: 'number',
|
53 |
+
attribute: 'data-index'
|
54 |
+
},
|
55 |
+
isSelected: {
|
56 |
+
type: 'boolean',
|
57 |
+
default:false
|
58 |
+
}
|
59 |
+
}
|
60 |
+
}
|
61 |
+
},
|
62 |
+
edit: function(props) {
|
63 |
+
|
64 |
+
var attributes = props.attributes;
|
65 |
+
var alignment = props.attributes.alignment;
|
66 |
+
|
67 |
+
//List of function for the current blocks starts here
|
68 |
+
|
69 |
+
function saswpGetImageSrc( item ) {
|
70 |
+
|
71 |
+
var contents = item.description;
|
72 |
+
|
73 |
+
if ( ! contents ) {
|
74 |
+
|
75 |
+
return false;
|
76 |
+
}
|
77 |
+
|
78 |
+
const image = contents.match(/<img/);
|
79 |
+
|
80 |
+
if ( image ) {
|
81 |
+
return true;
|
82 |
+
}else {
|
83 |
+
|
84 |
+
return false;
|
85 |
+
}
|
86 |
+
|
87 |
+
}
|
88 |
+
|
89 |
+
|
90 |
+
function moveElementsByDirection(direction, item){
|
91 |
+
|
92 |
+
var newIndex = null;
|
93 |
+
var oldIndex = parseInt(item.index);
|
94 |
+
const oldAttributes = attributes;
|
95 |
+
const oldItems = attributes.items;
|
96 |
+
|
97 |
+
if(direction == 'up'){
|
98 |
+
newIndex = parseInt(item.index)-1;
|
99 |
+
}
|
100 |
+
|
101 |
+
if(direction == 'down'){
|
102 |
+
newIndex = parseInt(item.index)+1;
|
103 |
+
}
|
104 |
+
|
105 |
+
if(newIndex >= oldItems.length){
|
106 |
+
newIndex = 0;
|
107 |
+
}
|
108 |
+
|
109 |
+
const newTestimonials = move(oldItems, oldIndex, newIndex);
|
110 |
+
|
111 |
+
newTestimonials.forEach(function(value, index){
|
112 |
+
newTestimonials[index]['title'] = value['title'];
|
113 |
+
newTestimonials[index]['description'] = value['description'];
|
114 |
+
newTestimonials[index]['index'] = index;
|
115 |
+
newTestimonials[index]['isSelected'] = false;
|
116 |
+
|
117 |
+
});
|
118 |
+
|
119 |
+
oldAttributes['items'] = newTestimonials;
|
120 |
+
props.setAttributes({
|
121 |
+
attributes: oldAttributes
|
122 |
+
});
|
123 |
+
|
124 |
+
}
|
125 |
+
|
126 |
+
function move(arr, old_index, new_index) {
|
127 |
+
while (old_index < 0) {
|
128 |
+
old_index += arr.length;
|
129 |
+
}
|
130 |
+
while (new_index < 0) {
|
131 |
+
new_index += arr.length;
|
132 |
+
}
|
133 |
+
if (new_index >= arr.length) {
|
134 |
+
var k = new_index - arr.length;
|
135 |
+
while ((k--) + 1) {
|
136 |
+
arr.push(undefined);
|
137 |
+
}
|
138 |
+
}
|
139 |
+
arr.splice(new_index, 0, arr.splice(old_index, 1)[0]);
|
140 |
+
return arr;
|
141 |
+
}
|
142 |
+
|
143 |
+
function _cloneArray(arr) {
|
144 |
+
if (Array.isArray(arr)) {
|
145 |
+
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
|
146 |
+
arr2[i] = arr[i];
|
147 |
+
}
|
148 |
+
return arr2;
|
149 |
+
} else {
|
150 |
+
return Array.from(arr);
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
function saswpGetButtons(item){
|
155 |
+
|
156 |
+
if(!item.isSelected){
|
157 |
+
return null;
|
158 |
+
}
|
159 |
+
|
160 |
+
return el('div', {className:'saswp-faq-button-container'},
|
161 |
+
!saswpGetImageSrc(item) ?
|
162 |
+
el(MediaUpload, {
|
163 |
+
onSelect: function(media){
|
164 |
+
|
165 |
+
const image = '<img src="'+media.url+'" alt="'+media.alt+'" key="'+media.id+'"/>';
|
166 |
+
|
167 |
+
const oldAttributes = attributes;
|
168 |
+
const oldItems = attributes.items;
|
169 |
+
oldItems.forEach(function(value, index){
|
170 |
+
|
171 |
+
if(index == item.index){
|
172 |
+
|
173 |
+
oldItems[index]['description'] = value['description']+image;
|
174 |
+
oldItems[index]['imageUrl'] = media.url;
|
175 |
+
oldItems[index]['imageId'] = media.id;
|
176 |
+
|
177 |
+
}
|
178 |
+
|
179 |
+
});
|
180 |
+
|
181 |
+
oldAttributes['items'] = oldItems;
|
182 |
+
props.setAttributes({
|
183 |
+
attributes: oldAttributes
|
184 |
+
});
|
185 |
+
|
186 |
+
},
|
187 |
+
allowedTypes:[ "image" ],
|
188 |
+
value: item.id,
|
189 |
+
render:function(obj){
|
190 |
+
return el( IconButton, {
|
191 |
+
icon: "insert",
|
192 |
+
className: 'saswp-faq-step-button saswp-to-step-add-media',
|
193 |
+
onClick: obj.open
|
194 |
+
},
|
195 |
+
'Add Image'
|
196 |
+
)
|
197 |
+
}
|
198 |
+
}): null,
|
199 |
+
el( IconButton, {
|
200 |
+
icon: "trash",
|
201 |
+
className: 'saswp-faq-step-button',
|
202 |
+
onClick: function() {
|
203 |
+
|
204 |
+
const oldAttributes = attributes;
|
205 |
+
const oldItems = attributes.items;
|
206 |
+
const newTestimonials = oldItems
|
207 |
+
|
208 |
+
.filter(function(itemFilter){
|
209 |
+
return itemFilter.index != item.index
|
210 |
+
}).map(function(t){
|
211 |
+
if (t.index > oldItems.index) {
|
212 |
+
t.index -= 1;
|
213 |
+
}
|
214 |
+
return t;
|
215 |
+
});
|
216 |
+
|
217 |
+
newTestimonials.forEach(function(value, index){
|
218 |
+
newTestimonials[index]['title'] = value['title'];
|
219 |
+
newTestimonials[index]['description'] = value['description'];
|
220 |
+
newTestimonials[index]['index'] = index;
|
221 |
+
newTestimonials[index]['isSelected'] = false;
|
222 |
+
});
|
223 |
+
|
224 |
+
oldAttributes['items'] = newTestimonials;
|
225 |
+
props.setAttributes({
|
226 |
+
attributes: oldAttributes
|
227 |
+
});
|
228 |
+
|
229 |
+
}
|
230 |
+
}
|
231 |
+
),
|
232 |
+
el( IconButton, {
|
233 |
+
icon: "insert",
|
234 |
+
className: 'saswp-faq-step-button',
|
235 |
+
onClick: function() {
|
236 |
+
|
237 |
+
const oldAttributes = attributes;
|
238 |
+
const oldItems = attributes.items;
|
239 |
+
|
240 |
+
const insertitem = {title:"",description:"",index:item.index, isSelected:false};
|
241 |
+
oldItems.splice(parseInt(item.index)+1, 0, insertitem);
|
242 |
+
|
243 |
+
const newTestimonials = oldItems;
|
244 |
+
|
245 |
+
newTestimonials.forEach(function(value, index){
|
246 |
+
newTestimonials[index]['title'] = value['title'];
|
247 |
+
newTestimonials[index]['description'] = value['description'];
|
248 |
+
newTestimonials[index]['index'] = index;
|
249 |
+
newTestimonials[index]['isSelected'] = false;
|
250 |
+
});
|
251 |
+
|
252 |
+
oldAttributes['items'] = newTestimonials;
|
253 |
+
props.setAttributes({
|
254 |
+
attributes: oldAttributes
|
255 |
+
});
|
256 |
+
}
|
257 |
+
}
|
258 |
+
)
|
259 |
+
|
260 |
+
);
|
261 |
+
|
262 |
+
}
|
263 |
+
|
264 |
+
function saswpGetMover(item){
|
265 |
+
|
266 |
+
if(!item.isSelected){
|
267 |
+
return null;
|
268 |
+
}
|
269 |
+
|
270 |
+
return el('div',
|
271 |
+
{className:'saswp-faq-step-mover'},
|
272 |
+
el( IconButton, {
|
273 |
+
icon: "arrow-up-alt2",
|
274 |
+
className: 'editor-block-mover__control',
|
275 |
+
onClick: function() {
|
276 |
+
|
277 |
+
moveElementsByDirection('up', item);
|
278 |
+
|
279 |
+
}
|
280 |
+
},
|
281 |
+
|
282 |
+
),
|
283 |
+
el( IconButton, {
|
284 |
+
icon: "arrow-down-alt2",
|
285 |
+
className: 'editor-block-mover__control',
|
286 |
+
onClick: function() {
|
287 |
+
|
288 |
+
moveElementsByDirection('down', item);
|
289 |
+
|
290 |
+
}
|
291 |
+
},
|
292 |
+
)
|
293 |
+
);
|
294 |
+
}
|
295 |
+
//List of function for the current blocks ends here
|
296 |
+
|
297 |
+
var itemli = attributes.items.sort(function(a , b) {
|
298 |
+
|
299 |
+
return a.index - b.index;
|
300 |
+
}).map(function(item){
|
301 |
+
|
302 |
+
if(!saswpGetImageSrc(item)){
|
303 |
+
item.imageUrl = '';
|
304 |
+
item.imageId = null;
|
305 |
+
}
|
306 |
+
|
307 |
+
return el('li',
|
308 |
+
{
|
309 |
+
className: 'item',
|
310 |
+
onClick: function(){
|
311 |
+
|
312 |
+
const oldAttributes = attributes;
|
313 |
+
const oldItems = attributes.items;
|
314 |
+
oldItems.forEach(function(value, index){
|
315 |
+
|
316 |
+
if(index == item.index){
|
317 |
+
oldItems[index]['isSelected'] = true;
|
318 |
+
}else{
|
319 |
+
oldItems[index]['isSelected'] = false;
|
320 |
+
}
|
321 |
+
|
322 |
+
});
|
323 |
+
|
324 |
+
oldAttributes['items'] = oldItems;
|
325 |
+
props.setAttributes({
|
326 |
+
attributes: oldAttributes
|
327 |
+
});
|
328 |
+
}
|
329 |
+
},
|
330 |
+
el('span',{
|
331 |
+
className:'saswp-faq-step-number'
|
332 |
+
},
|
333 |
+
attributes.toggleList ? '•':
|
334 |
+
( parseInt(item.index) + 1) + "."
|
335 |
+
),
|
336 |
+
el( RichText, {
|
337 |
+
tagName: 'p',
|
338 |
+
className:'saswp-faq-step-title',
|
339 |
+
placeholder: 'Enter a question',
|
340 |
+
style: { textAlign: alignment },
|
341 |
+
value: item.title,
|
342 |
+
autoFocus: true,
|
343 |
+
onChange: function( value ) {
|
344 |
+
var newObject = Object.assign({}, item, {
|
345 |
+
title: value
|
346 |
+
});
|
347 |
+
return props.setAttributes({
|
348 |
+
items: [].concat(_cloneArray(props.attributes.items.filter(function (itemFilter) {
|
349 |
+
return itemFilter.index != item.index;
|
350 |
+
})), [newObject])
|
351 |
+
});
|
352 |
+
}
|
353 |
+
}
|
354 |
+
),
|
355 |
+
el( RichText, {
|
356 |
+
tagName: 'p',
|
357 |
+
placeholder: 'Enter answer to the question',
|
358 |
+
className:'saswp-faq-step-description',
|
359 |
+
style: { textAlign: alignment },
|
360 |
+
value: item.description,
|
361 |
+
autoFocus: true,
|
362 |
+
onChange: function( value ) {
|
363 |
+
var newObject = Object.assign({}, item, {
|
364 |
+
description: value
|
365 |
+
});
|
366 |
+
return props.setAttributes({
|
367 |
+
items: [].concat(_cloneArray(props.attributes.items.filter(function (itemFilter) {
|
368 |
+
return itemFilter.index != item.index;
|
369 |
+
})), [newObject])
|
370 |
+
});
|
371 |
+
}
|
372 |
+
}
|
373 |
+
),
|
374 |
+
el('div', {className:'saswp-faq-step-controls-container'},
|
375 |
+
saswpGetMover(item),
|
376 |
+
saswpGetButtons(item)
|
377 |
+
)
|
378 |
+
)
|
379 |
+
});
|
380 |
+
|
381 |
+
var itemlist = el('ul',{}, itemli);
|
382 |
+
|
383 |
+
return [
|
384 |
+
el(InspectorControls,
|
385 |
+
{
|
386 |
+
className:'saswp-faq-inspector',
|
387 |
+
key: 'inspector'
|
388 |
+
},
|
389 |
+
el(PanelBody,
|
390 |
+
{className:'saswp-faq-panel-body',
|
391 |
+
title:'Settings'
|
392 |
+
},
|
393 |
+
el(ToggleControl,
|
394 |
+
{
|
395 |
+
className:'saswp-faq-toggle-list',
|
396 |
+
checked:attributes.toggleList,
|
397 |
+
onChange: function(newContent){
|
398 |
+
props.setAttributes( { toggleList: newContent } );
|
399 |
+
},
|
400 |
+
help: function(value){
|
401 |
+
return (value == true ? 'Showing step item as an unordered list': 'Showing step item as an ordered list');
|
402 |
+
}
|
403 |
+
},
|
404 |
+
)
|
405 |
+
)
|
406 |
+
),
|
407 |
+
el(
|
408 |
+
BlockControls,
|
409 |
+
{ key: 'controls' },
|
410 |
+
el(
|
411 |
+
AlignmentToolbar,
|
412 |
+
{
|
413 |
+
value: alignment,
|
414 |
+
onChange: function(newAlignment){
|
415 |
+
props.setAttributes( { alignment: newAlignment === undefined ? 'none' : newAlignment } );
|
416 |
+
}
|
417 |
+
}
|
418 |
+
)
|
419 |
+
),
|
420 |
+
,el(
|
421 |
+
'div',
|
422 |
+
{ className: props.className },
|
423 |
+
el('div', { className: 'saswp-faq-setp-list' },
|
424 |
+
itemlist,
|
425 |
+
),
|
426 |
+
el( IconButton, {
|
427 |
+
icon: "insert",
|
428 |
+
className: 'saswp-faq-step-button',
|
429 |
+
onClick: function() {
|
430 |
+
return props.setAttributes({
|
431 |
+
items: [].concat(_cloneArray(props.attributes.items), [{
|
432 |
+
index: props.attributes.items.length,
|
433 |
+
title: "",
|
434 |
+
description:""
|
435 |
+
}])
|
436 |
+
});
|
437 |
+
}
|
438 |
+
},
|
439 |
+
'Add A Question'
|
440 |
+
)
|
441 |
+
)];
|
442 |
+
|
443 |
+
},
|
444 |
+
save: function( props ) {
|
445 |
+
return null
|
446 |
+
}
|
447 |
+
} );
|
448 |
+
}(
|
449 |
+
window.wp.blocks,
|
450 |
+
window.wp.element,
|
451 |
+
window.wp.editor,
|
452 |
+
window.wp.components,
|
453 |
+
) );
|
454 |
+
|
modules/gutenberg/assets/blocks/how-to.js
ADDED
@@ -0,0 +1,551 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
( function( blocks, element, editor, components ) {
|
3 |
+
var el = element.createElement;
|
4 |
+
var RichText = editor.RichText;
|
5 |
+
var MediaUpload = editor.MediaUpload;
|
6 |
+
var IconButton = components.IconButton;
|
7 |
+
var AlignmentToolbar = editor.AlignmentToolbar;
|
8 |
+
var BlockControls = editor.BlockControls;
|
9 |
+
var TextControl = components.TextControl;
|
10 |
+
var InspectorControls = editor.InspectorControls;
|
11 |
+
var ToggleControl = components.ToggleControl;
|
12 |
+
var PanelBody = components.PanelBody;
|
13 |
+
|
14 |
+
blocks.registerBlockType( 'saswp/how-to-block', {
|
15 |
+
title: 'How To (SASWP)',
|
16 |
+
icon: 'list-view',
|
17 |
+
category: 'saswp-blocks',
|
18 |
+
keywords: ['schema', 'structured data', 'how to', 'how-to'],
|
19 |
+
|
20 |
+
// Allow only one How To block per post.
|
21 |
+
supports: {
|
22 |
+
multiple: false
|
23 |
+
},
|
24 |
+
|
25 |
+
attributes: {
|
26 |
+
hasDuration:{
|
27 |
+
type:'boolean',
|
28 |
+
default:false
|
29 |
+
},
|
30 |
+
alignment: {
|
31 |
+
type: 'string',
|
32 |
+
default: 'none'
|
33 |
+
},
|
34 |
+
toggleList: {
|
35 |
+
type: 'boolean',
|
36 |
+
default: false
|
37 |
+
},
|
38 |
+
description: {
|
39 |
+
type: 'string',
|
40 |
+
selector: '.saswp-how-to-main-description'
|
41 |
+
},
|
42 |
+
days: {
|
43 |
+
type: 'string',
|
44 |
+
selector: '.saswp-how-to-days'
|
45 |
+
},
|
46 |
+
hours: {
|
47 |
+
type: 'string',
|
48 |
+
selector: '.saswp-how-to-hours'
|
49 |
+
},
|
50 |
+
minutes: {
|
51 |
+
type: 'string',
|
52 |
+
selector: '.saswp-how-to-minutes'
|
53 |
+
},
|
54 |
+
items: {
|
55 |
+
default: [{index: 0, title: "", description: "", imageUrl: "", imageId: null}],
|
56 |
+
selector: '.saswp-how-to-block-data',
|
57 |
+
query: {
|
58 |
+
title: {
|
59 |
+
type: 'string',
|
60 |
+
selector: '.title'
|
61 |
+
},
|
62 |
+
description: {
|
63 |
+
type: 'string',
|
64 |
+
selector: '.description'
|
65 |
+
},
|
66 |
+
imageId: {
|
67 |
+
type: 'integer'
|
68 |
+
},
|
69 |
+
imageUrl: {
|
70 |
+
type: 'string'
|
71 |
+
},
|
72 |
+
index: {
|
73 |
+
type: 'number',
|
74 |
+
attribute: 'data-index',
|
75 |
+
},
|
76 |
+
isSelected: {
|
77 |
+
type: 'boolean',
|
78 |
+
default:false
|
79 |
+
}
|
80 |
+
}
|
81 |
+
}
|
82 |
+
},
|
83 |
+
edit: function(props) {
|
84 |
+
|
85 |
+
var attributes = props.attributes;
|
86 |
+
var alignment = props.attributes.alignment;
|
87 |
+
|
88 |
+
//List of function for the current blocks starts here
|
89 |
+
|
90 |
+
function saswpGetImageSrc( item ) {
|
91 |
+
|
92 |
+
var contents = item.description;
|
93 |
+
|
94 |
+
if ( ! contents ) {
|
95 |
+
|
96 |
+
return false;
|
97 |
+
}
|
98 |
+
|
99 |
+
const image = contents.match(/<img/);
|
100 |
+
|
101 |
+
if ( image ) {
|
102 |
+
return true;
|
103 |
+
}else {
|
104 |
+
|
105 |
+
return false;
|
106 |
+
}
|
107 |
+
|
108 |
+
}
|
109 |
+
|
110 |
+
function saswpGetDuration(){
|
111 |
+
|
112 |
+
var duration = el('fieldset',{className:'saswp-how-to-duration'},el('legend',{className:'saswp-how-to-duration-legend'}, 'Time Needed : ',
|
113 |
+
el('span',{className:'saswp-how-to-duration-time-input'},
|
114 |
+
el(TextControl,
|
115 |
+
{
|
116 |
+
className:'saswp-how-to-duration-input',
|
117 |
+
placeholder: 'DD',
|
118 |
+
value: attributes.days,
|
119 |
+
autoFocus: true,
|
120 |
+
onChange: function( newContent ) {
|
121 |
+
|
122 |
+
props.setAttributes( { days: newContent } );
|
123 |
+
}
|
124 |
+
},),
|
125 |
+
el(TextControl,
|
126 |
+
{
|
127 |
+
className:'saswp-how-to-duration-input',
|
128 |
+
placeholder: 'HH',
|
129 |
+
value: attributes.hours,
|
130 |
+
autoFocus: true,
|
131 |
+
onChange: function( newContent ) {
|
132 |
+
props.setAttributes( { hours: newContent } );
|
133 |
+
}
|
134 |
+
},),
|
135 |
+
el(TextControl,
|
136 |
+
{
|
137 |
+
className:'saswp-how-to-duration-input',
|
138 |
+
placeholder: 'MM',
|
139 |
+
value: attributes.minutes,
|
140 |
+
autoFocus: true,
|
141 |
+
onChange: function( newContent ) {
|
142 |
+
props.setAttributes( { minutes: newContent } );
|
143 |
+
}
|
144 |
+
},),
|
145 |
+
el( IconButton, {
|
146 |
+
icon: "trash",
|
147 |
+
className: 'saswp-how-to-step-button',
|
148 |
+
onClick: function() {
|
149 |
+
props.setAttributes( { hasDuration: false } );
|
150 |
+
}
|
151 |
+
}
|
152 |
+
)
|
153 |
+
)
|
154 |
+
));
|
155 |
+
|
156 |
+
var addDuration = el( IconButton, {
|
157 |
+
icon: "insert",
|
158 |
+
className: 'saswp-how-to-step-button saswp-to-step-add-media',
|
159 |
+
onClick: function(){
|
160 |
+
props.setAttributes( { hasDuration: true } );
|
161 |
+
}
|
162 |
+
},
|
163 |
+
'Add Total Time'
|
164 |
+
);
|
165 |
+
|
166 |
+
if(attributes.hasDuration){
|
167 |
+
return duration;
|
168 |
+
}else{
|
169 |
+
return addDuration;
|
170 |
+
}
|
171 |
+
|
172 |
+
}
|
173 |
+
|
174 |
+
function moveElementsByDirection(direction, item){
|
175 |
+
|
176 |
+
var newIndex = null;
|
177 |
+
var oldIndex = parseInt(item.index);
|
178 |
+
const oldAttributes = attributes;
|
179 |
+
const oldItems = attributes.items;
|
180 |
+
|
181 |
+
if(direction == 'up'){
|
182 |
+
newIndex = parseInt(item.index)-1;
|
183 |
+
}
|
184 |
+
|
185 |
+
if(direction == 'down'){
|
186 |
+
newIndex = parseInt(item.index)+1;
|
187 |
+
}
|
188 |
+
|
189 |
+
if(newIndex >= oldItems.length){
|
190 |
+
newIndex = 0;
|
191 |
+
}
|
192 |
+
|
193 |
+
const newTestimonials = move(oldItems, oldIndex, newIndex);
|
194 |
+
|
195 |
+
newTestimonials.forEach(function(value, index){
|
196 |
+
newTestimonials[index]['title'] = value['title'];
|
197 |
+
newTestimonials[index]['description'] = value['description'];
|
198 |
+
newTestimonials[index]['index'] = index;
|
199 |
+
newTestimonials[index]['isSelected'] = false;
|
200 |
+
|
201 |
+
});
|
202 |
+
|
203 |
+
oldAttributes['items'] = newTestimonials;
|
204 |
+
props.setAttributes({
|
205 |
+
attributes: oldAttributes
|
206 |
+
});
|
207 |
+
|
208 |
+
}
|
209 |
+
|
210 |
+
function move(arr, old_index, new_index) {
|
211 |
+
while (old_index < 0) {
|
212 |
+
old_index += arr.length;
|
213 |
+
}
|
214 |
+
while (new_index < 0) {
|
215 |
+
new_index += arr.length;
|
216 |
+
}
|
217 |
+
if (new_index >= arr.length) {
|
218 |
+
var k = new_index - arr.length;
|
219 |
+
while ((k--) + 1) {
|
220 |
+
arr.push(undefined);
|
221 |
+
}
|
222 |
+
}
|
223 |
+
arr.splice(new_index, 0, arr.splice(old_index, 1)[0]);
|
224 |
+
return arr;
|
225 |
+
}
|
226 |
+
|
227 |
+
function _cloneArray(arr) {
|
228 |
+
if (Array.isArray(arr)) {
|
229 |
+
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
|
230 |
+
arr2[i] = arr[i];
|
231 |
+
}
|
232 |
+
return arr2;
|
233 |
+
} else {
|
234 |
+
return Array.from(arr);
|
235 |
+
}
|
236 |
+
}
|
237 |
+
|
238 |
+
function saswpGetButtons(item){
|
239 |
+
|
240 |
+
if(!item.isSelected){
|
241 |
+
return null;
|
242 |
+
}
|
243 |
+
|
244 |
+
return el('div', {className:'saswp-how-to-step-button-container'},
|
245 |
+
!saswpGetImageSrc(item) ?
|
246 |
+
el(MediaUpload, {
|
247 |
+
onSelect: function(media){
|
248 |
+
|
249 |
+
const image = '<img src="'+media.url+'" alt="'+media.alt+'" key="'+media.id+'"/>';
|
250 |
+
|
251 |
+
const oldAttributes = attributes;
|
252 |
+
const oldItems = attributes.items;
|
253 |
+
oldItems.forEach(function(value, index){
|
254 |
+
|
255 |
+
if(index == item.index){
|
256 |
+
|
257 |
+
oldItems[index]['description'] = value['description']+image;
|
258 |
+
oldItems[index]['imageUrl'] = media.url;
|
259 |
+
oldItems[index]['imageId'] = media.id;
|
260 |
+
|
261 |
+
}
|
262 |
+
|
263 |
+
});
|
264 |
+
|
265 |
+
oldAttributes['items'] = oldItems;
|
266 |
+
props.setAttributes({
|
267 |
+
attributes: oldAttributes
|
268 |
+
});
|
269 |
+
|
270 |
+
},
|
271 |
+
allowedTypes:[ "image" ],
|
272 |
+
value: item.id,
|
273 |
+
render:function(obj){
|
274 |
+
return el( IconButton, {
|
275 |
+
icon: "insert",
|
276 |
+
className: 'saswp-how-to-step-button saswp-to-step-add-media',
|
277 |
+
onClick: obj.open
|
278 |
+
},
|
279 |
+
'Add Image'
|
280 |
+
)
|
281 |
+
}
|
282 |
+
}): null,
|
283 |
+
el( IconButton, {
|
284 |
+
icon: "trash",
|
285 |
+
className: 'saswp-how-to-step-button',
|
286 |
+
onClick: function() {
|
287 |
+
|
288 |
+
const oldAttributes = attributes;
|
289 |
+
const oldItems = attributes.items;
|
290 |
+
const newTestimonials = oldItems
|
291 |
+
|
292 |
+
.filter(function(itemFilter){
|
293 |
+
return itemFilter.index != item.index
|
294 |
+
}).map(function(t){
|
295 |
+
if (t.index > oldItems.index) {
|
296 |
+
t.index -= 1;
|
297 |
+
}
|
298 |
+
return t;
|
299 |
+
});
|
300 |
+
|
301 |
+
newTestimonials.forEach(function(value, index){
|
302 |
+
newTestimonials[index]['title'] = value['title'];
|
303 |
+
newTestimonials[index]['description'] = value['description'];
|
304 |
+
newTestimonials[index]['index'] = index;
|
305 |
+
newTestimonials[index]['isSelected'] = false;
|
306 |
+
});
|
307 |
+
|
308 |
+
oldAttributes['items'] = newTestimonials;
|
309 |
+
props.setAttributes({
|
310 |
+
attributes: oldAttributes
|
311 |
+
});
|
312 |
+
|
313 |
+
}
|
314 |
+
}
|
315 |
+
),
|
316 |
+
el( IconButton, {
|
317 |
+
icon: "insert",
|
318 |
+
className: 'saswp-how-to-step-button',
|
319 |
+
onClick: function() {
|
320 |
+
|
321 |
+
const oldAttributes = attributes;
|
322 |
+
const oldItems = attributes.items;
|
323 |
+
|
324 |
+
const insertitem = {title:"",description:"",index:item.index, isSelected:false};
|
325 |
+
oldItems.splice(parseInt(item.index)+1, 0, insertitem);
|
326 |
+
|
327 |
+
const newTestimonials = oldItems;
|
328 |
+
|
329 |
+
newTestimonials.forEach(function(value, index){
|
330 |
+
newTestimonials[index]['title'] = value['title'];
|
331 |
+
newTestimonials[index]['description'] = value['description'];
|
332 |
+
newTestimonials[index]['index'] = index;
|
333 |
+
newTestimonials[index]['isSelected'] = false;
|
334 |
+
});
|
335 |
+
|
336 |
+
oldAttributes['items'] = newTestimonials;
|
337 |
+
props.setAttributes({
|
338 |
+
attributes: oldAttributes
|
339 |
+
});
|
340 |
+
}
|
341 |
+
}
|
342 |
+
)
|
343 |
+
|
344 |
+
);
|
345 |
+
|
346 |
+
}
|
347 |
+
|
348 |
+
function saswpGetMover(item){
|
349 |
+
|
350 |
+
if(!item.isSelected){
|
351 |
+
return null;
|
352 |
+
}
|
353 |
+
|
354 |
+
return el('div',
|
355 |
+
{className:'saswp-how-to-step-mover'},
|
356 |
+
el( IconButton, {
|
357 |
+
icon: "arrow-up-alt2",
|
358 |
+
className: 'editor-block-mover__control',
|
359 |
+
onClick: function() {
|
360 |
+
|
361 |
+
moveElementsByDirection('up', item);
|
362 |
+
|
363 |
+
}
|
364 |
+
},
|
365 |
+
|
366 |
+
),
|
367 |
+
el( IconButton, {
|
368 |
+
icon: "arrow-down-alt2",
|
369 |
+
className: 'editor-block-mover__control',
|
370 |
+
onClick: function() {
|
371 |
+
|
372 |
+
moveElementsByDirection('down', item);
|
373 |
+
|
374 |
+
}
|
375 |
+
},
|
376 |
+
)
|
377 |
+
);
|
378 |
+
}
|
379 |
+
//List of function for the current blocks ends here
|
380 |
+
|
381 |
+
var itemli = attributes.items.sort(function(a , b) {
|
382 |
+
|
383 |
+
return a.index - b.index;
|
384 |
+
}).map(function(item){
|
385 |
+
|
386 |
+
if(!saswpGetImageSrc(item)){
|
387 |
+
item.imageUrl = '';
|
388 |
+
item.imageId = null;
|
389 |
+
}
|
390 |
+
|
391 |
+
return el('li',
|
392 |
+
{
|
393 |
+
className: 'item',
|
394 |
+
onClick: function(){
|
395 |
+
|
396 |
+
const oldAttributes = attributes;
|
397 |
+
const oldItems = attributes.items;
|
398 |
+
oldItems.forEach(function(value, index){
|
399 |
+
|
400 |
+
if(index == item.index){
|
401 |
+
oldItems[index]['isSelected'] = true;
|
402 |
+
}else{
|
403 |
+
oldItems[index]['isSelected'] = false;
|
404 |
+
}
|
405 |
+
|
406 |
+
});
|
407 |
+
|
408 |
+
oldAttributes['items'] = oldItems;
|
409 |
+
props.setAttributes({
|
410 |
+
attributes: oldAttributes
|
411 |
+
});
|
412 |
+
}
|
413 |
+
},
|
414 |
+
el('span',{
|
415 |
+
className:'saswp-how-to-step-number'
|
416 |
+
},
|
417 |
+
attributes.toggleList ? '•':
|
418 |
+
( parseInt(item.index) + 1) + "."
|
419 |
+
),
|
420 |
+
el( RichText, {
|
421 |
+
tagName: 'p',
|
422 |
+
className:'saswp-how-to-step-title',
|
423 |
+
placeholder: 'Enter a step title',
|
424 |
+
style: { textAlign: alignment },
|
425 |
+
value: item.title,
|
426 |
+
autoFocus: true,
|
427 |
+
onChange: function( value ) {
|
428 |
+
var newObject = Object.assign({}, item, {
|
429 |
+
title: value
|
430 |
+
});
|
431 |
+
return props.setAttributes({
|
432 |
+
items: [].concat(_cloneArray(props.attributes.items.filter(function (itemFilter) {
|
433 |
+
return itemFilter.index != item.index;
|
434 |
+
})), [newObject])
|
435 |
+
});
|
436 |
+
}
|
437 |
+
}
|
438 |
+
),
|
439 |
+
el( RichText, {
|
440 |
+
tagName: 'p',
|
441 |
+
placeholder: 'Enter a step description',
|
442 |
+
className:'saswp-how-to-step-description',
|
443 |
+
style: { textAlign: alignment },
|
444 |
+
value: item.description,
|
445 |
+
autoFocus: true,
|
446 |
+
onChange: function( value ) {
|
447 |
+
var newObject = Object.assign({}, item, {
|
448 |
+
description: value
|
449 |
+
});
|
450 |
+
return props.setAttributes({
|
451 |
+
items: [].concat(_cloneArray(props.attributes.items.filter(function (itemFilter) {
|
452 |
+
return itemFilter.index != item.index;
|
453 |
+
})), [newObject])
|
454 |
+
});
|
455 |
+
}
|
456 |
+
}
|
457 |
+
),
|
458 |
+
el('div', {className:'saswp-how-to-step-controls-container'},
|
459 |
+
saswpGetMover(item),
|
460 |
+
saswpGetButtons(item)
|
461 |
+
)
|
462 |
+
)
|
463 |
+
});
|
464 |
+
|
465 |
+
var itemlist = el('ul',{}, itemli);
|
466 |
+
|
467 |
+
return [
|
468 |
+
el(InspectorControls,
|
469 |
+
{
|
470 |
+
className:'saswp-how-to-inspector',
|
471 |
+
key: 'inspector'
|
472 |
+
},
|
473 |
+
el(PanelBody,
|
474 |
+
{className:'saswp-how-to-panel-body',
|
475 |
+
title:'Settings'
|
476 |
+
},
|
477 |
+
el(ToggleControl,
|
478 |
+
{
|
479 |
+
className:'saswp-how-to-toggle-list',
|
480 |
+
checked:attributes.toggleList,
|
481 |
+
onChange: function(newContent){
|
482 |
+
props.setAttributes( { toggleList: newContent } );
|
483 |
+
},
|
484 |
+
help: function(value){
|
485 |
+
return (value == true ? 'Showing step item as an unordered list': 'Showing step item as an ordered list');
|
486 |
+
}
|
487 |
+
},
|
488 |
+
)
|
489 |
+
)
|
490 |
+
),
|
491 |
+
el(
|
492 |
+
BlockControls,
|
493 |
+
{ key: 'controls' },
|
494 |
+
el(
|
495 |
+
AlignmentToolbar,
|
496 |
+
{
|
497 |
+
value: alignment,
|
498 |
+
onChange: function(newAlignment){
|
499 |
+
props.setAttributes( { alignment: newAlignment === undefined ? 'none' : newAlignment } );
|
500 |
+
}
|
501 |
+
}
|
502 |
+
)
|
503 |
+
),
|
504 |
+
,el(
|
505 |
+
'div',
|
506 |
+
{ className: props.className },
|
507 |
+
saswpGetDuration(),
|
508 |
+
el( RichText, {
|
509 |
+
tagName: 'p',
|
510 |
+
className:'saswp-how-to-description',
|
511 |
+
placeholder: 'Enter how to description',
|
512 |
+
style: { textAlign: alignment },
|
513 |
+
value: attributes.description,
|
514 |
+
autoFocus: true,
|
515 |
+
onChange: function( newContent ) {
|
516 |
+
props.setAttributes( { description: newContent } );
|
517 |
+
}
|
518 |
+
}
|
519 |
+
),
|
520 |
+
el('div', { className: 'saswp-how-to-setp-list' },
|
521 |
+
itemlist,
|
522 |
+
),
|
523 |
+
el( IconButton, {
|
524 |
+
icon: "insert",
|
525 |
+
className: 'saswp-how-to-step-button',
|
526 |
+
onClick: function() {
|
527 |
+
return props.setAttributes({
|
528 |
+
items: [].concat(_cloneArray(props.attributes.items), [{
|
529 |
+
index: props.attributes.items.length,
|
530 |
+
title: "",
|
531 |
+
description: "",
|
532 |
+
}])
|
533 |
+
});
|
534 |
+
}
|
535 |
+
},
|
536 |
+
'Add A Step'
|
537 |
+
)
|
538 |
+
)];
|
539 |
+
|
540 |
+
},
|
541 |
+
save: function( props ) {
|
542 |
+
return null
|
543 |
+
}
|
544 |
+
} );
|
545 |
+
}(
|
546 |
+
window.wp.blocks,
|
547 |
+
window.wp.element,
|
548 |
+
window.wp.editor,
|
549 |
+
window.wp.components,
|
550 |
+
) );
|
551 |
+
|
modules/gutenberg/assets/css/editor.css
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
To change this license header, choose License Headers in Project Properties.
|
3 |
+
To change this template file, choose Tools | Templates
|
4 |
+
and open the template in the editor.
|
5 |
+
*/
|
6 |
+
/*
|
7 |
+
Created on : Sep 15, 2019, 1:52:02 PM
|
8 |
+
Author : acer
|
9 |
+
*/
|
10 |
+
|
11 |
+
.saswp-how-to-step-button:hover{
|
12 |
+
color: #0085ba !important;
|
13 |
+
box-shadow: none !important;
|
14 |
+
}
|
15 |
+
.saswp-how-to-setp-list li{
|
16 |
+
position: relative;
|
17 |
+
padding: 8px 4px 8px 32px;
|
18 |
+
margin: 4px 0;
|
19 |
+
border: 1px solid rgba(145,151,162,.25);
|
20 |
+
list-style-type: none;
|
21 |
+
list-style: none;
|
22 |
+
}
|
23 |
+
.saswp-how-to-step-number {
|
24 |
+
position: absolute;
|
25 |
+
left: 4px;
|
26 |
+
width: 24px;
|
27 |
+
text-align: right;
|
28 |
+
}
|
29 |
+
.saswp-how-to-step-title{
|
30 |
+
font-weight: 600;
|
31 |
+
}
|
32 |
+
.saswp-how-to-step-button-container{
|
33 |
+
display: flex;
|
34 |
+
}
|
35 |
+
.saswp-how-to-step-mover{
|
36 |
+
display: flex;
|
37 |
+
}
|
38 |
+
.saswp-how-to-step-controls-container{
|
39 |
+
display: flex;
|
40 |
+
justify-content: flex-end;
|
41 |
+
}
|
42 |
+
.saswp-how-to-duration-input{
|
43 |
+
width: 50px;
|
44 |
+
margin: 0 2px;
|
45 |
+
padding: 6px 4px;
|
46 |
+
text-align: center;
|
47 |
+
border-radius: 5px;
|
48 |
+
}
|
49 |
+
.saswp-how-to-duration-time-input{
|
50 |
+
display: inline-flex;
|
51 |
+
}
|
52 |
+
.saswp-how-to-duration-time-input button{
|
53 |
+
position: relative;
|
54 |
+
top: -12px;
|
55 |
+
}
|
56 |
+
|
57 |
+
|
58 |
+
.saswp-faq-step-button:hover{
|
59 |
+
color: #0085ba !important;
|
60 |
+
box-shadow: none !important;
|
61 |
+
}
|
62 |
+
.saswp-faq-setp-list li{
|
63 |
+
position: relative;
|
64 |
+
padding: 8px 4px 8px 32px;
|
65 |
+
margin: 4px 0;
|
66 |
+
border: 1px solid rgba(145,151,162,.25);
|
67 |
+
list-style-type: none;
|
68 |
+
list-style: none;
|
69 |
+
}
|
70 |
+
.saswp-faq-step-number {
|
71 |
+
position: absolute;
|
72 |
+
left: 4px;
|
73 |
+
width: 24px;
|
74 |
+
text-align: right;
|
75 |
+
}
|
76 |
+
.saswp-faq-step-title{
|
77 |
+
font-weight: 600;
|
78 |
+
}
|
79 |
+
.saswp-faq-button-container{
|
80 |
+
display: flex;
|
81 |
+
}
|
82 |
+
.saswp-faq-step-mover{
|
83 |
+
display: flex;
|
84 |
+
}
|
85 |
+
.saswp-faq-step-controls-container{
|
86 |
+
display: flex;
|
87 |
+
justify-content: flex-end;
|
88 |
+
}
|
89 |
+
.saswp-faq-duration-input{
|
90 |
+
width: 50px;
|
91 |
+
margin: 0 2px;
|
92 |
+
padding: 6px 4px;
|
93 |
+
text-align: center;
|
94 |
+
border-radius: 5px;
|
95 |
+
}
|
96 |
+
.saswp-faq-duration-time-input{
|
97 |
+
display: inline-flex;
|
98 |
+
}
|
99 |
+
.saswp-faq-duration-time-input button{
|
100 |
+
position: relative;
|
101 |
+
top: -12px;
|
102 |
+
}
|
modules/gutenberg/assets/css/style.css
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
To change this license header, choose License Headers in Project Properties.
|
3 |
+
To change this template file, choose Tools | Templates
|
4 |
+
and open the template in the editor.
|
5 |
+
*/
|
6 |
+
/*
|
7 |
+
Created on : Sep 15, 2019, 1:52:02 PM
|
8 |
+
Author : acer
|
9 |
+
*/
|
10 |
+
|
modules/gutenberg/includes/class-gutenberg.php
ADDED
@@ -0,0 +1,220 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SASWP_Gutenberg {
|
4 |
+
|
5 |
+
private static $instance;
|
6 |
+
|
7 |
+
private function __construct() {
|
8 |
+
add_action( 'init', array( $this, 'register_how_to' ) );
|
9 |
+
add_action( 'init', array( $this, 'register_faq' ) );
|
10 |
+
add_action( 'enqueue_block_editor_assets', array( $this, 'register_assets' ) );
|
11 |
+
add_filter( 'block_categories', array( $this, 'saswp_add_blocks_categories' ) );
|
12 |
+
}
|
13 |
+
|
14 |
+
|
15 |
+
public function register_assets() {
|
16 |
+
|
17 |
+
if ( !function_exists( 'register_block_type' ) ) {
|
18 |
+
// no Gutenberg, Abort
|
19 |
+
return;
|
20 |
+
}
|
21 |
+
wp_register_style(
|
22 |
+
'saswp-gutenberg-css-reg-editor',
|
23 |
+
SASWP_PLUGIN_URL . '/modules/gutenberg/assets/css/editor.css',
|
24 |
+
array( 'wp-edit-blocks' )
|
25 |
+
);
|
26 |
+
|
27 |
+
wp_register_style(
|
28 |
+
'saswp-gutenberg-css-reg',
|
29 |
+
SASWP_PLUGIN_URL . '/modules/gutenberg/assets/css/style.css',
|
30 |
+
array( )
|
31 |
+
);
|
32 |
+
|
33 |
+
wp_register_script(
|
34 |
+
'saswp-faq-js-reg',
|
35 |
+
SASWP_PLUGIN_URL . '/modules/gutenberg/assets/blocks/faq.js',
|
36 |
+
array( 'wp-i18n', 'wp-element', 'wp-blocks', 'wp-components', 'wp-editor' )
|
37 |
+
);
|
38 |
+
|
39 |
+
$inline_script = array(
|
40 |
+
'title' => 'Faq'
|
41 |
+
);
|
42 |
+
|
43 |
+
wp_localize_script( 'saswp-how-to-js-reg', 'saswpGutenbergFaq', $inline_script );
|
44 |
+
|
45 |
+
wp_enqueue_script( 'saswp-faq-js-reg' );
|
46 |
+
|
47 |
+
wp_register_script(
|
48 |
+
'saswp-how-to-js-reg',
|
49 |
+
SASWP_PLUGIN_URL . '/modules/gutenberg/assets/blocks/how-to.js',
|
50 |
+
array( 'wp-i18n', 'wp-element', 'wp-blocks', 'wp-components', 'wp-editor' )
|
51 |
+
);
|
52 |
+
|
53 |
+
$inline_script = array(
|
54 |
+
'title' => 'How To'
|
55 |
+
);
|
56 |
+
|
57 |
+
wp_localize_script( 'saswp-how-to-js-reg', 'saswpGutenbergHowTo', $inline_script );
|
58 |
+
|
59 |
+
wp_enqueue_script( 'saswp-how-to-js-reg' );
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Register blocks
|
64 |
+
*/
|
65 |
+
public function register_faq() {
|
66 |
+
|
67 |
+
if ( !function_exists( 'register_block_type' ) ) {
|
68 |
+
// no Gutenberg, Abort
|
69 |
+
return;
|
70 |
+
}
|
71 |
+
|
72 |
+
register_block_type( 'saswp/faq-block', array(
|
73 |
+
'style' => 'saswp-gutenberg-css-reg',
|
74 |
+
'editor_style' => 'saswp-gutenberg-css-reg-editor',
|
75 |
+
'editor_script' => 'saswp-faq-js-reg',
|
76 |
+
'render_callback' => array( $this, 'render_faq_data' ),
|
77 |
+
) );
|
78 |
+
|
79 |
+
}
|
80 |
+
|
81 |
+
public static function render_faq_data( $attributes ) {
|
82 |
+
|
83 |
+
ob_start();
|
84 |
+
|
85 |
+
if ( !isset( $attributes ) ) {
|
86 |
+
ob_end_clean();
|
87 |
+
|
88 |
+
return '';
|
89 |
+
}
|
90 |
+
|
91 |
+
echo '<div class="saswp-faq-block-section">';
|
92 |
+
if($attributes['items']){
|
93 |
+
|
94 |
+
if(!isset($attributes['toggleList'])){
|
95 |
+
echo '<ol>';
|
96 |
+
}else{
|
97 |
+
echo '<ul>';
|
98 |
+
}
|
99 |
+
|
100 |
+
foreach($attributes['items'] as $item){
|
101 |
+
|
102 |
+
if($item['title'] || $item['description']){
|
103 |
+
echo '<li>';
|
104 |
+
echo '<strong class="saswp-faq-question-title">'. html_entity_decode(esc_attr($item['title'])).'</strong>';
|
105 |
+
echo '<p class="saswp-faq-answer-text">'.html_entity_decode(esc_textarea($item['description'])).'</p>';
|
106 |
+
echo '</li>';
|
107 |
+
}
|
108 |
+
|
109 |
+
}
|
110 |
+
if(!isset($attributes['toggleList'])){
|
111 |
+
echo '</ol>';
|
112 |
+
}else{
|
113 |
+
echo '</ul>';
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
echo '</div>';
|
118 |
+
|
119 |
+
return ob_get_clean();
|
120 |
+
}
|
121 |
+
|
122 |
+
public static function render_how_to_data( $attributes ) {
|
123 |
+
|
124 |
+
ob_start();
|
125 |
+
|
126 |
+
if ( !isset( $attributes ) ) {
|
127 |
+
ob_end_clean();
|
128 |
+
|
129 |
+
return '';
|
130 |
+
}
|
131 |
+
|
132 |
+
echo '<div class="saswp-how-to-block-section">';
|
133 |
+
|
134 |
+
if(isset($attributes['hasDuration'])){
|
135 |
+
echo '<p class="saswp-how-to-total-time">';
|
136 |
+
echo '<span class="saswp-how-to-duration-time-text">Time Needed : </span>';
|
137 |
+
|
138 |
+
echo esc_attr($attributes['days']).' days '.esc_attr($attributes['hours']).' hours '.esc_attr($attributes['minutes']).' minutes';
|
139 |
+
echo '</p>';
|
140 |
+
}
|
141 |
+
if(isset($attributes['description'])){
|
142 |
+
echo '<p>'.esc_attr($attributes['description']).'</p>';
|
143 |
+
}
|
144 |
+
|
145 |
+
if(isset($attributes['items'])){
|
146 |
+
|
147 |
+
if(!isset($attributes['toggleList'])){
|
148 |
+
echo '<ol>';
|
149 |
+
}else{
|
150 |
+
echo '<ul>';
|
151 |
+
}
|
152 |
+
|
153 |
+
foreach($attributes['items'] as $item){
|
154 |
+
|
155 |
+
if($item['title'] || $item['description']){
|
156 |
+
echo '<li>';
|
157 |
+
echo '<strong class="saswp-how-to-step-name">'. html_entity_decode(esc_attr($item['title'])).'</strong>';
|
158 |
+
echo '<p class="saswp-how-to-step-text">'.html_entity_decode(esc_textarea($item['description'])).'</p>';
|
159 |
+
echo '</li>';
|
160 |
+
}
|
161 |
+
|
162 |
+
}
|
163 |
+
if(!isset($attributes['toggleList'])){
|
164 |
+
echo '</ol>';
|
165 |
+
}else{
|
166 |
+
echo '</ul>';
|
167 |
+
}
|
168 |
+
}
|
169 |
+
|
170 |
+
echo '</div>';
|
171 |
+
|
172 |
+
return ob_get_clean();
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Register blocks
|
177 |
+
*/
|
178 |
+
public function register_how_to() {
|
179 |
+
|
180 |
+
if ( !function_exists( 'register_block_type' ) ) {
|
181 |
+
// no Gutenberg, Abort
|
182 |
+
return;
|
183 |
+
}
|
184 |
+
|
185 |
+
register_block_type( 'saswp/how-to-block', array(
|
186 |
+
'style' => 'saswp-gutenberg-css-reg',
|
187 |
+
'editor_style' => 'saswp-gutenberg-css-reg-editor',
|
188 |
+
'editor_script' => 'saswp-how-to-js-reg',
|
189 |
+
'render_callback' => array( $this, 'render_how_to_data' ),
|
190 |
+
) );
|
191 |
+
|
192 |
+
|
193 |
+
}
|
194 |
+
|
195 |
+
public function saswp_add_blocks_categories($categories){
|
196 |
+
|
197 |
+
$categories[] = array(
|
198 |
+
'slug' => 'saswp-blocks',
|
199 |
+
'title' => 'Schema & Structured Data Blocks'
|
200 |
+
);
|
201 |
+
|
202 |
+
return $categories;
|
203 |
+
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Return the unique instance
|
208 |
+
*/
|
209 |
+
public static function get_instance() {
|
210 |
+
if ( null == self::$instance ) {
|
211 |
+
self::$instance = new self;
|
212 |
+
}
|
213 |
+
return self::$instance;
|
214 |
+
}
|
215 |
+
|
216 |
+
}
|
217 |
+
|
218 |
+
if ( class_exists( 'SASWP_Gutenberg') ) {
|
219 |
+
SASWP_Gutenberg::get_instance();
|
220 |
+
}
|
output/function.php
CHANGED
@@ -64,7 +64,7 @@ function saswp_schema_markup_output() {
|
|
64 |
|
65 |
global $sd_data;
|
66 |
global $post;
|
67 |
-
|
68 |
$custom_markup = '';
|
69 |
$output = '';
|
70 |
$post_specific_enable = '';
|
@@ -72,8 +72,11 @@ function saswp_schema_markup_output() {
|
|
72 |
$kb_schema_output = array();
|
73 |
$item_list = array();
|
74 |
$collection_page = array();
|
75 |
-
$blog_page = array();
|
76 |
-
|
|
|
|
|
|
|
77 |
$site_navigation = saswp_site_navigation_output();
|
78 |
$contact_page_output = saswp_contact_page_output();
|
79 |
$about_page_output = saswp_about_page_output();
|
@@ -141,6 +144,24 @@ function saswp_schema_markup_output() {
|
|
141 |
$output .= ",";
|
142 |
$output .= "\n\n";
|
143 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
if(!empty($blog_page)){
|
145 |
|
146 |
$output .= saswp_json_print_format($blog_page);
|
64 |
|
65 |
global $sd_data;
|
66 |
global $post;
|
67 |
+
|
68 |
$custom_markup = '';
|
69 |
$output = '';
|
70 |
$post_specific_enable = '';
|
72 |
$kb_schema_output = array();
|
73 |
$item_list = array();
|
74 |
$collection_page = array();
|
75 |
+
$blog_page = array();
|
76 |
+
|
77 |
+
$gutenberg_how_to = saswp_gutenberg_how_to_schema();
|
78 |
+
$gutenberg_faq = saswp_gutenberg_faq_schema();
|
79 |
+
$woo_cat_schema = saswp_woocommerce_category_schema();
|
80 |
$site_navigation = saswp_site_navigation_output();
|
81 |
$contact_page_output = saswp_contact_page_output();
|
82 |
$about_page_output = saswp_about_page_output();
|
144 |
$output .= ",";
|
145 |
$output .= "\n\n";
|
146 |
}
|
147 |
+
if(!empty($woo_cat_schema)){
|
148 |
+
|
149 |
+
$output .= saswp_json_print_format($woo_cat_schema);
|
150 |
+
$output .= ",";
|
151 |
+
$output .= "\n\n";
|
152 |
+
}
|
153 |
+
if(!empty($gutenberg_how_to)){
|
154 |
+
|
155 |
+
$output .= saswp_json_print_format($gutenberg_how_to);
|
156 |
+
$output .= ",";
|
157 |
+
$output .= "\n\n";
|
158 |
+
}
|
159 |
+
if(!empty($gutenberg_faq)){
|
160 |
+
|
161 |
+
$output .= saswp_json_print_format($gutenberg_faq);
|
162 |
+
$output .= ",";
|
163 |
+
$output .= "\n\n";
|
164 |
+
}
|
165 |
if(!empty($blog_page)){
|
166 |
|
167 |
$output .= saswp_json_print_format($blog_page);
|
output/output.php
CHANGED
@@ -932,93 +932,14 @@ function saswp_schema_output() {
|
|
932 |
if( 'Product' === $schema_type){
|
933 |
|
934 |
$service = new saswp_output_service();
|
935 |
-
$
|
936 |
-
|
937 |
-
if((isset($sd_data['saswp-woocommerce']) && $sd_data['saswp-woocommerce'] == 1) && !empty($product_details)){
|
938 |
-
|
939 |
-
$input1 = array(
|
940 |
-
'@context' => saswp_context_url(),
|
941 |
-
'@type' => 'Product',
|
942 |
-
'@id' => trailingslashit(saswp_get_permalink()).'#product',
|
943 |
-
'url' => trailingslashit(saswp_get_permalink()),
|
944 |
-
'name' => saswp_remove_warnings($product_details, 'product_name', 'saswp_string'),
|
945 |
-
'sku' => saswp_remove_warnings($product_details, 'product_sku', 'saswp_string'),
|
946 |
-
'description' => saswp_remove_warnings($product_details, 'product_description', 'saswp_string'),
|
947 |
-
'offers' => array(
|
948 |
-
'@type' => 'Offer',
|
949 |
-
'availability' => saswp_remove_warnings($product_details, 'product_availability', 'saswp_string'),
|
950 |
-
'price' => saswp_remove_warnings($product_details, 'product_price', 'saswp_string'),
|
951 |
-
'priceCurrency' => saswp_remove_warnings($product_details, 'product_currency', 'saswp_string'),
|
952 |
-
'url' => trailingslashit(saswp_get_permalink()),
|
953 |
-
'priceValidUntil' => saswp_remove_warnings($product_details, 'product_priceValidUntil', 'saswp_string'),
|
954 |
-
),
|
955 |
-
|
956 |
-
);
|
957 |
-
|
958 |
-
if(isset($product_details['product_image'])){
|
959 |
-
$input1 = array_merge($input1, $product_details['product_image']);
|
960 |
-
}
|
961 |
-
|
962 |
-
if(isset($product_details['product_gtin8']) && $product_details['product_gtin8'] !=''){
|
963 |
-
$input1['gtin8'] = esc_attr($product_details['product_gtin8']);
|
964 |
-
}
|
965 |
-
if(isset($product_details['product_mpn']) && $product_details['product_mpn'] !=''){
|
966 |
-
$input1['mpn'] = esc_attr($product_details['product_mpn']);
|
967 |
-
}
|
968 |
-
if(isset($product_details['product_isbn']) && $product_details['product_isbn'] !=''){
|
969 |
-
$input1['isbn'] = esc_attr($product_details['product_isbn']);
|
970 |
-
}
|
971 |
-
if(isset($product_details['product_brand']) && $product_details['product_brand'] !=''){
|
972 |
-
$input1['brand'] = array('@type'=>'Thing','name'=> esc_attr($product_details['product_brand']));
|
973 |
-
}
|
974 |
-
if(isset($product_details['product_review_count']) && $product_details['product_review_count'] >0 && isset($product_details['product_average_rating']) && $product_details['product_average_rating'] >0){
|
975 |
-
$input1['aggregateRating'] = array(
|
976 |
-
'@type' => 'AggregateRating',
|
977 |
-
'ratingValue' => esc_attr($product_details['product_average_rating']),
|
978 |
-
'reviewCount' => (int)esc_attr($product_details['product_review_count']),
|
979 |
-
);
|
980 |
-
}
|
981 |
-
if(!empty($product_details['product_reviews'])){
|
982 |
-
|
983 |
-
$reviews = array();
|
984 |
-
|
985 |
-
foreach ($product_details['product_reviews'] as $review){
|
986 |
-
|
987 |
-
$reviews[] = array(
|
988 |
-
'@type' => 'Review',
|
989 |
-
'author' => esc_attr($review['author']),
|
990 |
-
'datePublished' => esc_html($review['datePublished']),
|
991 |
-
'description' => $review['description'],
|
992 |
-
'reviewRating' => array(
|
993 |
-
'@type' => 'Rating',
|
994 |
-
'bestRating' => '5',
|
995 |
-
'ratingValue' => esc_attr($review['reviewRating']),
|
996 |
-
'worstRating' => '1',
|
997 |
-
)
|
998 |
-
);
|
999 |
-
|
1000 |
-
}
|
1001 |
-
$input1['review'] = $reviews;
|
1002 |
-
}
|
1003 |
-
|
1004 |
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
1005 |
|
1006 |
$service = new saswp_output_service();
|
1007 |
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
1008 |
|
1009 |
-
}
|
1010 |
-
}else{
|
1011 |
-
|
1012 |
-
$input1['@context'] = saswp_context_url();
|
1013 |
-
$input1['@type'] = 'Product';
|
1014 |
-
$input1['@id'] = trailingslashit(saswp_get_permalink()).'#Product';
|
1015 |
-
|
1016 |
-
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
1017 |
-
$service = new saswp_output_service();
|
1018 |
-
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
1019 |
-
}
|
1020 |
-
|
1021 |
-
}
|
1022 |
|
1023 |
$input1 = apply_filters('saswp_modify_product_schema_output', $input1 );
|
1024 |
}
|
@@ -1301,9 +1222,9 @@ function saswp_schema_output() {
|
|
1301 |
}
|
1302 |
|
1303 |
$input1 = array(
|
1304 |
-
'@context'
|
1305 |
'@type' => esc_attr($local_business),
|
1306 |
-
'@id'
|
1307 |
'url' => trailingslashit(saswp_get_permalink()),
|
1308 |
);
|
1309 |
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] == 1){
|
@@ -1486,6 +1407,59 @@ function saswp_kb_website_output(){
|
|
1486 |
return apply_filters('saswp_modify_website_output', $input);
|
1487 |
}
|
1488 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1489 |
/**
|
1490 |
* Function generates archive page schema markup in the form of CollectionPage schema type
|
1491 |
* @global type $query_string
|
@@ -1903,4 +1877,161 @@ function saswp_site_navigation_fallback(){
|
|
1903 |
|
1904 |
|
1905 |
return $input;
|
1906 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
932 |
if( 'Product' === $schema_type){
|
933 |
|
934 |
$service = new saswp_output_service();
|
935 |
+
$input1 = $service->saswp_schema_markup_generator($schema_type);
|
936 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
937 |
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] ==1){
|
938 |
|
939 |
$service = new saswp_output_service();
|
940 |
$input1 = $service->saswp_replace_with_custom_fields_value($input1, $schema_post_id);
|
941 |
|
942 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
943 |
|
944 |
$input1 = apply_filters('saswp_modify_product_schema_output', $input1 );
|
945 |
}
|
1222 |
}
|
1223 |
|
1224 |
$input1 = array(
|
1225 |
+
'@context' => saswp_context_url(),
|
1226 |
'@type' => esc_attr($local_business),
|
1227 |
+
'@id' => trailingslashit(saswp_get_permalink()).'#'. strtolower(esc_attr($local_business)),
|
1228 |
'url' => trailingslashit(saswp_get_permalink()),
|
1229 |
);
|
1230 |
if(isset($schema_options['enable_custom_field']) && $schema_options['enable_custom_field'] == 1){
|
1407 |
return apply_filters('saswp_modify_website_output', $input);
|
1408 |
}
|
1409 |
|
1410 |
+
/**
|
1411 |
+
* Function to get woocommerce archive schema list
|
1412 |
+
* @global type $query_string
|
1413 |
+
* @global type $sd_data
|
1414 |
+
* @return type
|
1415 |
+
* since version: 1.9.7
|
1416 |
+
*/
|
1417 |
+
function saswp_woocommerce_category_schema(){
|
1418 |
+
|
1419 |
+
global $query_string, $sd_data;
|
1420 |
+
|
1421 |
+
if ( function_exists('is_product_category') && is_product_category()) {
|
1422 |
+
|
1423 |
+
$list_item = array();
|
1424 |
+
$term = get_queried_object();
|
1425 |
+
$service = new saswp_output_service();
|
1426 |
+
$category_loop = new WP_Query( $query_string );
|
1427 |
+
|
1428 |
+
$i = 1;
|
1429 |
+
|
1430 |
+
if ( $category_loop->have_posts() ):
|
1431 |
+
while( $category_loop->have_posts() ): $category_loop->the_post();
|
1432 |
+
|
1433 |
+
$category_posts = array();
|
1434 |
+
$category_posts['@type'] = 'ListItem';
|
1435 |
+
$category_posts['position'] = $i;
|
1436 |
+
$category_posts['item'] = $service->saswp_schema_markup_generator('Product');
|
1437 |
+
$category_posts['item']['url'] = get_category_link($term->term_id).'#product_'.$i;
|
1438 |
+
unset($category_posts['item']['@id']);
|
1439 |
+
$list_item[] = $category_posts;
|
1440 |
+
|
1441 |
+
$i++;
|
1442 |
+
endwhile;
|
1443 |
+
|
1444 |
+
wp_reset_postdata();
|
1445 |
+
|
1446 |
+
$item_list_schema = array();
|
1447 |
+
|
1448 |
+
if($list_item){
|
1449 |
+
$item_list_schema['@context'] = saswp_context_url();
|
1450 |
+
$item_list_schema['@type'] = 'ItemList';
|
1451 |
+
$item_list_schema['url'] = get_category_link($term->term_id);
|
1452 |
+
$item_list_schema['itemListElement'] = $list_item;
|
1453 |
+
}
|
1454 |
+
|
1455 |
+
return $item_list_schema;
|
1456 |
+
|
1457 |
+
endif;
|
1458 |
+
|
1459 |
+
}
|
1460 |
+
|
1461 |
+
}
|
1462 |
+
|
1463 |
/**
|
1464 |
* Function generates archive page schema markup in the form of CollectionPage schema type
|
1465 |
* @global type $query_string
|
1877 |
|
1878 |
|
1879 |
return $input;
|
1880 |
+
}
|
1881 |
+
|
1882 |
+
function saswp_gutenberg_how_to_schema(){
|
1883 |
+
|
1884 |
+
global $post;
|
1885 |
+
$input1 = array();
|
1886 |
+
|
1887 |
+
if(function_exists('parse_blocks')){
|
1888 |
+
|
1889 |
+
$blocks = parse_blocks($post->post_content);
|
1890 |
+
|
1891 |
+
if($blocks){
|
1892 |
+
|
1893 |
+
foreach ($blocks as $parse_blocks){
|
1894 |
+
|
1895 |
+
if(isset($parse_blocks['blockName']) && $parse_blocks['blockName'] === 'saswp/how-to-block'){
|
1896 |
+
|
1897 |
+
$input1['@context'] = saswp_context_url();
|
1898 |
+
$input1['@type'] = 'HowTo';
|
1899 |
+
$input1['@id'] = trailingslashit(get_permalink()).'#HowTo';
|
1900 |
+
$input1['name'] = saswp_get_the_title();
|
1901 |
+
$input1['datePublished'] = get_the_date("Y-m-d\TH:i:s\Z");
|
1902 |
+
$input1['dateModified'] = get_the_modified_date("Y-m-d\TH:i:s\Z");
|
1903 |
+
|
1904 |
+
if(array_key_exists('description', $parse_blocks['attrs'])){
|
1905 |
+
$input1['description'] = $parse_blocks['attrs']['description'];
|
1906 |
+
}
|
1907 |
+
$step = array();
|
1908 |
+
|
1909 |
+
if(array_key_exists('items', $parse_blocks['attrs'])){
|
1910 |
+
$step = $parse_blocks['attrs']['items'];
|
1911 |
+
}
|
1912 |
+
|
1913 |
+
$step_arr = array();
|
1914 |
+
if(!empty($step)){
|
1915 |
+
|
1916 |
+
foreach($step as $key => $val){
|
1917 |
+
|
1918 |
+
$supply_data = array();
|
1919 |
+
$direction = array();
|
1920 |
+
$tip = array();
|
1921 |
+
|
1922 |
+
if($val['title'] || $val['description']){
|
1923 |
+
|
1924 |
+
if($val['title']){
|
1925 |
+
$direction['@type'] = 'HowToDirection';
|
1926 |
+
$direction['text'] = $val['title'];
|
1927 |
+
}
|
1928 |
+
|
1929 |
+
if($val['description']){
|
1930 |
+
|
1931 |
+
$tip['@type'] = 'HowToTip';
|
1932 |
+
$tip['text'] = $val['description'];
|
1933 |
+
|
1934 |
+
}
|
1935 |
+
|
1936 |
+
$supply_data['@type'] = 'HowToStep';
|
1937 |
+
$supply_data['url'] = trailingslashit(get_permalink()).'#step'.++$key;
|
1938 |
+
$supply_data['name'] = $val['title'];
|
1939 |
+
|
1940 |
+
if(isset($direction['text']) || isset($tip['text'])){
|
1941 |
+
$supply_data['itemListElement'] = array($direction, $tip);
|
1942 |
+
}
|
1943 |
+
|
1944 |
+
if(isset($val['imageId']) && $val['imageId'] !=''){
|
1945 |
+
|
1946 |
+
$image_details = wp_get_attachment_image_src($val['imageId']);
|
1947 |
+
$supply_data['image']['@type'] = 'ImageObject';
|
1948 |
+
$supply_data['image']['url'] = esc_url($image_details[0]);
|
1949 |
+
$supply_data['image']['width'] = esc_attr($image_details[1]);
|
1950 |
+
$supply_data['image']['height'] = esc_attr($image_details[2]);
|
1951 |
+
|
1952 |
+
}
|
1953 |
+
|
1954 |
+
$step_arr[] = $supply_data;
|
1955 |
+
|
1956 |
+
}
|
1957 |
+
|
1958 |
+
}
|
1959 |
+
|
1960 |
+
$input1['step'] = $step_arr;
|
1961 |
+
|
1962 |
+
}
|
1963 |
+
|
1964 |
+
if(isset($parse_blocks['attrs']['days']) && $parse_blocks['attrs']['hours'] && $parse_blocks['attrs']['minutes']){
|
1965 |
+
$input1['totalTime'] = 'P' . $parse_blocks['attrs']['days'] . 'DT' . $parse_blocks['attrs']['hours'] . 'H' . $parse_blocks['attrs']['minutes'] . 'M';
|
1966 |
+
}
|
1967 |
+
|
1968 |
+
}
|
1969 |
+
|
1970 |
+
}
|
1971 |
+
|
1972 |
+
}
|
1973 |
+
|
1974 |
+
}
|
1975 |
+
|
1976 |
+
return $input1;
|
1977 |
+
|
1978 |
+
}
|
1979 |
+
|
1980 |
+
|
1981 |
+
function saswp_gutenberg_faq_schema(){
|
1982 |
+
|
1983 |
+
global $post;
|
1984 |
+
$input1 = array();
|
1985 |
+
|
1986 |
+
if(function_exists('parse_blocks')){
|
1987 |
+
|
1988 |
+
$blocks = parse_blocks($post->post_content);
|
1989 |
+
|
1990 |
+
if($blocks){
|
1991 |
+
|
1992 |
+
foreach ($blocks as $parse_blocks){
|
1993 |
+
|
1994 |
+
if(isset($parse_blocks['blockName']) && $parse_blocks['blockName'] === 'saswp/faq-block'){
|
1995 |
+
|
1996 |
+
$input1['@context'] = saswp_context_url();
|
1997 |
+
$input1['@type'] = 'FAQPage';
|
1998 |
+
$input1['@id'] = trailingslashit(get_permalink()).'#FAQPage';
|
1999 |
+
|
2000 |
+
$faq_question_arr = array();
|
2001 |
+
|
2002 |
+
if(!empty($parse_blocks['attrs']['items'])){
|
2003 |
+
|
2004 |
+
foreach($parse_blocks['attrs']['items'] as $val){
|
2005 |
+
|
2006 |
+
$supply_data = array();
|
2007 |
+
$supply_data['@type'] = 'Question';
|
2008 |
+
$supply_data['name'] = $val['title'];
|
2009 |
+
$supply_data['acceptedAnswer']['@type'] = 'Answer';
|
2010 |
+
$supply_data['acceptedAnswer']['text'] = $val['description'];
|
2011 |
+
|
2012 |
+
if(isset($val['imageId']) && $val['imageId'] !=''){
|
2013 |
+
|
2014 |
+
$image_details = wp_get_attachment_image_src($val['imageId']);
|
2015 |
+
$supply_data['image']['@type'] = 'ImageObject';
|
2016 |
+
$supply_data['image']['url'] = esc_url($image_details[0]);
|
2017 |
+
$supply_data['image']['width'] = esc_attr($image_details[1]);
|
2018 |
+
$supply_data['image']['height'] = esc_attr($image_details[2]);
|
2019 |
+
|
2020 |
+
}
|
2021 |
+
|
2022 |
+
$faq_question_arr[] = $supply_data;
|
2023 |
+
}
|
2024 |
+
$input1['mainEntity'] = $faq_question_arr;
|
2025 |
+
}
|
2026 |
+
|
2027 |
+
}
|
2028 |
+
|
2029 |
+
}
|
2030 |
+
|
2031 |
+
}
|
2032 |
+
|
2033 |
+
}
|
2034 |
+
|
2035 |
+
return $input1;
|
2036 |
+
|
2037 |
+
}
|
output/output_post_specific.php
CHANGED
@@ -65,7 +65,7 @@ function saswp_post_specific_schema_output() {
|
|
65 |
$schema_post_id = $post->ID;
|
66 |
$all_post_meta = get_post_meta($schema_post_id, $key='', true);
|
67 |
|
68 |
-
if(is_singular() && (
|
69 |
|
70 |
$saswp_review_details = get_post_meta(get_the_ID(), 'saswp_review_details', true);
|
71 |
|
65 |
$schema_post_id = $post->ID;
|
66 |
$all_post_meta = get_post_meta($schema_post_id, $key='', true);
|
67 |
|
68 |
+
if(is_singular() && (isset($schema_enable[$schema_id]) && $schema_enable[$schema_id] == 1 )){
|
69 |
|
70 |
$saswp_review_details = get_post_meta(get_the_ID(), 'saswp_review_details', true);
|
71 |
|
output/review-output.php
CHANGED
@@ -54,8 +54,13 @@ Class saswp_review_output{
|
|
54 |
if(isset($saswp_review_details['saswp-review-item-enable'])){
|
55 |
|
56 |
$author_id = get_the_author_meta('ID');
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
59 |
$date = get_the_date("Y-m-d\TH:i:s\Z");
|
60 |
$modified_date = get_the_modified_date("Y-m-d\TH:i:s\Z");
|
61 |
$aurthor_name = get_the_author();
|
54 |
if(isset($saswp_review_details['saswp-review-item-enable'])){
|
55 |
|
56 |
$author_id = get_the_author_meta('ID');
|
57 |
+
$author_details = array();
|
58 |
+
|
59 |
+
if(function_exists('get_avatar_data')){
|
60 |
+
$author_details = get_avatar_data($author_id);
|
61 |
+
}
|
62 |
+
|
63 |
+
|
64 |
$date = get_the_date("Y-m-d\TH:i:s\Z");
|
65 |
$modified_date = get_the_modified_date("Y-m-d\TH:i:s\Z");
|
66 |
$aurthor_name = get_the_author();
|
output/service.php
CHANGED
@@ -209,8 +209,12 @@ Class saswp_output_service{
|
|
209 |
|
210 |
break;
|
211 |
case 'author_image':
|
|
|
212 |
$author_id = get_the_author_meta('ID');
|
213 |
-
|
|
|
|
|
|
|
214 |
$response['@type'] = 'ImageObject';
|
215 |
$response['url'] = $author_image['url'];
|
216 |
$response['width'] = $author_image['height'];
|
@@ -253,9 +257,7 @@ Class saswp_output_service{
|
|
253 |
|
254 |
}
|
255 |
public function saswp_replace_with_custom_fields_value($input1, $schema_post_id){
|
256 |
-
|
257 |
-
global $post;
|
258 |
-
|
259 |
$custom_fields = get_post_meta($schema_post_id, 'saswp_meta_list_val', true);
|
260 |
|
261 |
if(!empty($custom_fields)){
|
@@ -263,11 +265,9 @@ Class saswp_output_service{
|
|
263 |
$schema_type = get_post_meta( $schema_post_id, 'schema_type', true);
|
264 |
|
265 |
foreach ($custom_fields as $key => $field){
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
}
|
270 |
-
|
271 |
}
|
272 |
|
273 |
switch ($schema_type) {
|
@@ -373,8 +373,7 @@ Class saswp_output_service{
|
|
373 |
}
|
374 |
if(isset($custom_fields['local_street_address'])){
|
375 |
$input1['address']['streetAddress'] = $custom_fields['local_street_address'];
|
376 |
-
}
|
377 |
-
|
378 |
if(isset($custom_fields['local_city'])){
|
379 |
$input1['address']['addressLocality'] = $custom_fields['local_city'];
|
380 |
}
|
@@ -384,12 +383,14 @@ Class saswp_output_service{
|
|
384 |
if(isset($custom_fields['local_postal_code'])){
|
385 |
$input1['address']['postalCode'] = $custom_fields['local_postal_code'];
|
386 |
}
|
387 |
-
if(isset($custom_fields['local_latitude'])){
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
$input1['geo']['longitude'] = $custom_fields['local_longitude'];
|
392 |
-
|
|
|
|
|
393 |
if(isset($custom_fields['local_phone'])){
|
394 |
$input1['telephone'] = $custom_fields['local_phone'];
|
395 |
}
|
@@ -411,6 +412,14 @@ Class saswp_output_service{
|
|
411 |
if(isset($custom_fields['local_menu'])){
|
412 |
$input1['hasMenu'] = $custom_fields['local_menu'];
|
413 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
414 |
|
415 |
break;
|
416 |
|
@@ -1992,7 +2001,11 @@ Class saswp_output_service{
|
|
1992 |
$post_meta = get_post_meta($post_id, $key='', true);
|
1993 |
|
1994 |
if(isset($post_meta['_post_review_box_breakdowns_score'])){
|
1995 |
-
|
|
|
|
|
|
|
|
|
1996 |
}
|
1997 |
if(isset($post_meta['_post_review_box_title'])){
|
1998 |
$post_review_title = $post_meta['_post_review_box_title'][0];
|
@@ -2210,7 +2223,7 @@ Class saswp_output_service{
|
|
2210 |
'saswp_dayofweek' => 'Operation Days',
|
2211 |
'local_price_range' => 'Price Range',
|
2212 |
'local_hasmap' => 'HasMap',
|
2213 |
-
'local_menu' => '
|
2214 |
'local_facebook' => 'Facebook',
|
2215 |
'local_twitter' => 'Twitter',
|
2216 |
'local_instagram' => 'Instagram',
|
@@ -2218,7 +2231,10 @@ Class saswp_output_service{
|
|
2218 |
'local_linkedin' => 'LinkedIn',
|
2219 |
'local_soundcloud' => 'SoundCloud',
|
2220 |
'local_tumblr' => 'Tumblr',
|
2221 |
-
'local_youtube' => 'Youtube',
|
|
|
|
|
|
|
2222 |
);
|
2223 |
break;
|
2224 |
|
@@ -3009,6 +3025,85 @@ Class saswp_output_service{
|
|
3009 |
);
|
3010 |
|
3011 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3012 |
|
3013 |
default:
|
3014 |
break;
|
@@ -3168,7 +3263,7 @@ Class saswp_output_service{
|
|
3168 |
|
3169 |
if($key == 0){
|
3170 |
|
3171 |
-
if($image['width'] <
|
3172 |
|
3173 |
$resized_image = aq_resize( $image['url'], 1280, 720, true, false, true );
|
3174 |
$attach_images['image'][$key]['url'] = $resized_image[0];
|
209 |
|
210 |
break;
|
211 |
case 'author_image':
|
212 |
+
$author_image = array();
|
213 |
$author_id = get_the_author_meta('ID');
|
214 |
+
|
215 |
+
if(function_exists('get_avatar_data')){
|
216 |
+
$author_image = get_avatar_data($author_id);
|
217 |
+
}
|
218 |
$response['@type'] = 'ImageObject';
|
219 |
$response['url'] = $author_image['url'];
|
220 |
$response['width'] = $author_image['height'];
|
257 |
|
258 |
}
|
259 |
public function saswp_replace_with_custom_fields_value($input1, $schema_post_id){
|
260 |
+
|
|
|
|
|
261 |
$custom_fields = get_post_meta($schema_post_id, 'saswp_meta_list_val', true);
|
262 |
|
263 |
if(!empty($custom_fields)){
|
265 |
$schema_type = get_post_meta( $schema_post_id, 'schema_type', true);
|
266 |
|
267 |
foreach ($custom_fields as $key => $field){
|
268 |
+
|
269 |
+
$custom_fields[$key] = $this->saswp_get_meta_list_value($key, $field, $schema_post_id);
|
270 |
+
|
|
|
|
|
271 |
}
|
272 |
|
273 |
switch ($schema_type) {
|
373 |
}
|
374 |
if(isset($custom_fields['local_street_address'])){
|
375 |
$input1['address']['streetAddress'] = $custom_fields['local_street_address'];
|
376 |
+
}
|
|
|
377 |
if(isset($custom_fields['local_city'])){
|
378 |
$input1['address']['addressLocality'] = $custom_fields['local_city'];
|
379 |
}
|
383 |
if(isset($custom_fields['local_postal_code'])){
|
384 |
$input1['address']['postalCode'] = $custom_fields['local_postal_code'];
|
385 |
}
|
386 |
+
if(isset($custom_fields['local_latitude']) && isset($custom_fields['local_longitude'])){
|
387 |
+
|
388 |
+
$input1['geo']['@type'] = 'GeoCoordinates';
|
389 |
+
$input1['geo']['latitude'] = $custom_fields['local_latitude'];
|
390 |
$input1['geo']['longitude'] = $custom_fields['local_longitude'];
|
391 |
+
|
392 |
+
}
|
393 |
+
|
394 |
if(isset($custom_fields['local_phone'])){
|
395 |
$input1['telephone'] = $custom_fields['local_phone'];
|
396 |
}
|
412 |
if(isset($custom_fields['local_menu'])){
|
413 |
$input1['hasMenu'] = $custom_fields['local_menu'];
|
414 |
}
|
415 |
+
|
416 |
+
if(isset($custom_fields['local_rating_value']) && isset($custom_fields['local_rating_count'])){
|
417 |
+
$input1['aggregateRating']['@type'] = 'AggregateRating';
|
418 |
+
$input1['aggregateRating']['worstRating'] = 0;
|
419 |
+
$input1['aggregateRating']['bestRating'] = 5;
|
420 |
+
$input1['aggregateRating']['ratingValue'] = $custom_fields['local_rating_value'];
|
421 |
+
$input1['aggregateRating']['ratingCount'] = $custom_fields['local_rating_count'];
|
422 |
+
}
|
423 |
|
424 |
break;
|
425 |
|
2001 |
$post_meta = get_post_meta($post_id, $key='', true);
|
2002 |
|
2003 |
if(isset($post_meta['_post_review_box_breakdowns_score'])){
|
2004 |
+
|
2005 |
+
if(function_exists('bcdiv')){
|
2006 |
+
$rating_value = bcdiv($post_meta['_post_review_box_breakdowns_score'][0], 20, 2);
|
2007 |
+
}
|
2008 |
+
|
2009 |
}
|
2010 |
if(isset($post_meta['_post_review_box_title'])){
|
2011 |
$post_review_title = $post_meta['_post_review_box_title'][0];
|
2223 |
'saswp_dayofweek' => 'Operation Days',
|
2224 |
'local_price_range' => 'Price Range',
|
2225 |
'local_hasmap' => 'HasMap',
|
2226 |
+
'local_menu' => 'Menu',
|
2227 |
'local_facebook' => 'Facebook',
|
2228 |
'local_twitter' => 'Twitter',
|
2229 |
'local_instagram' => 'Instagram',
|
2231 |
'local_linkedin' => 'LinkedIn',
|
2232 |
'local_soundcloud' => 'SoundCloud',
|
2233 |
'local_tumblr' => 'Tumblr',
|
2234 |
+
'local_youtube' => 'Youtube',
|
2235 |
+
'local_rating_value' => 'Rating Value',
|
2236 |
+
'local_rating_count' => 'Rating Count',
|
2237 |
+
|
2238 |
);
|
2239 |
break;
|
2240 |
|
3025 |
);
|
3026 |
|
3027 |
break;
|
3028 |
+
|
3029 |
+
case 'Product':
|
3030 |
+
|
3031 |
+
$product_details = $this->saswp_woocommerce_product_details(get_the_ID());
|
3032 |
+
|
3033 |
+
if((isset($sd_data['saswp-woocommerce']) && $sd_data['saswp-woocommerce'] == 1) && !empty($product_details)){
|
3034 |
+
|
3035 |
+
$input1 = array(
|
3036 |
+
'@context' => saswp_context_url(),
|
3037 |
+
'@type' => 'Product',
|
3038 |
+
'@id' => trailingslashit(saswp_get_permalink()).'#product',
|
3039 |
+
'url' => trailingslashit(saswp_get_permalink()),
|
3040 |
+
'name' => saswp_remove_warnings($product_details, 'product_name', 'saswp_string'),
|
3041 |
+
'sku' => saswp_remove_warnings($product_details, 'product_sku', 'saswp_string'),
|
3042 |
+
'description' => saswp_remove_warnings($product_details, 'product_description', 'saswp_string'),
|
3043 |
+
'offers' => array(
|
3044 |
+
'@type' => 'Offer',
|
3045 |
+
'availability' => saswp_remove_warnings($product_details, 'product_availability', 'saswp_string'),
|
3046 |
+
'price' => saswp_remove_warnings($product_details, 'product_price', 'saswp_string'),
|
3047 |
+
'priceCurrency' => saswp_remove_warnings($product_details, 'product_currency', 'saswp_string'),
|
3048 |
+
'url' => trailingslashit(saswp_get_permalink()),
|
3049 |
+
'priceValidUntil' => saswp_remove_warnings($product_details, 'product_priceValidUntil', 'saswp_string'),
|
3050 |
+
),
|
3051 |
+
|
3052 |
+
);
|
3053 |
+
|
3054 |
+
if(isset($product_details['product_image'])){
|
3055 |
+
$input1 = array_merge($input1, $product_details['product_image']);
|
3056 |
+
}
|
3057 |
+
|
3058 |
+
if(isset($product_details['product_gtin8']) && $product_details['product_gtin8'] !=''){
|
3059 |
+
$input1['gtin8'] = esc_attr($product_details['product_gtin8']);
|
3060 |
+
}
|
3061 |
+
if(isset($product_details['product_mpn']) && $product_details['product_mpn'] !=''){
|
3062 |
+
$input1['mpn'] = esc_attr($product_details['product_mpn']);
|
3063 |
+
}
|
3064 |
+
if(isset($product_details['product_isbn']) && $product_details['product_isbn'] !=''){
|
3065 |
+
$input1['isbn'] = esc_attr($product_details['product_isbn']);
|
3066 |
+
}
|
3067 |
+
if(isset($product_details['product_brand']) && $product_details['product_brand'] !=''){
|
3068 |
+
$input1['brand'] = array('@type'=>'Thing','name'=> esc_attr($product_details['product_brand']));
|
3069 |
+
}
|
3070 |
+
if(isset($product_details['product_review_count']) && $product_details['product_review_count'] >0 && isset($product_details['product_average_rating']) && $product_details['product_average_rating'] >0){
|
3071 |
+
$input1['aggregateRating'] = array(
|
3072 |
+
'@type' => 'AggregateRating',
|
3073 |
+
'ratingValue' => esc_attr($product_details['product_average_rating']),
|
3074 |
+
'reviewCount' => (int)esc_attr($product_details['product_review_count']),
|
3075 |
+
);
|
3076 |
+
}
|
3077 |
+
if(!empty($product_details['product_reviews'])){
|
3078 |
+
|
3079 |
+
$reviews = array();
|
3080 |
+
|
3081 |
+
foreach ($product_details['product_reviews'] as $review){
|
3082 |
+
|
3083 |
+
$reviews[] = array(
|
3084 |
+
'@type' => 'Review',
|
3085 |
+
'author' => esc_attr($review['author']),
|
3086 |
+
'datePublished' => esc_html($review['datePublished']),
|
3087 |
+
'description' => $review['description'],
|
3088 |
+
'reviewRating' => array(
|
3089 |
+
'@type' => 'Rating',
|
3090 |
+
'bestRating' => '5',
|
3091 |
+
'ratingValue' => esc_attr($review['reviewRating']),
|
3092 |
+
'worstRating' => '1',
|
3093 |
+
)
|
3094 |
+
);
|
3095 |
+
|
3096 |
+
}
|
3097 |
+
$input1['review'] = $reviews;
|
3098 |
+
}
|
3099 |
+
}else{
|
3100 |
+
|
3101 |
+
$input1['@context'] = saswp_context_url();
|
3102 |
+
$input1['@type'] = 'Product';
|
3103 |
+
$input1['@id'] = trailingslashit(saswp_get_permalink()).'#Product';
|
3104 |
+
}
|
3105 |
+
|
3106 |
+
break;
|
3107 |
|
3108 |
default:
|
3109 |
break;
|
3263 |
|
3264 |
if($key == 0){
|
3265 |
|
3266 |
+
if($image['width'] < 1200){
|
3267 |
|
3268 |
$resized_image = aq_resize( $image['url'], 1280, 720, true, false, true );
|
3269 |
$attach_images['image'][$key]['url'] = $resized_image[0];
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: magazine3
|
|
3 |
Tags: Schema, Structured Data, Google Snippets, Rich Snippets, Schema.org, SEO, AMP
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 5.2
|
6 |
-
Stable tag: 1.9.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -23,7 +23,9 @@ Schema & Structured Data for WP & AMP adds Google Rich Snippets markup according
|
|
23 |
* <strong>Compatibility</strong>: Generate the schema markup for the plugins. We have provided schema support for them. Few of them are - kk Star Ratings, WP-PostRatings, bbPress
|
24 |
* <strong>Google Review</strong>: Display your business google reviews and its schema markup on your website.
|
25 |
* **[Premium]** Reviews ( [Fetch](https://structured-data-for-wp.com/reviews-for-schema) reviews from 75+ platforms ).
|
26 |
-
*
|
|
|
|
|
27 |
* <strong>Unlimited Custom Post Types</strong>: You can control to represent the Rich Snippets data in the google search console using unlimited custom post types.
|
28 |
* <strong>Easy to use</strong> with Minimal Settings
|
29 |
* <strong>Archive Page Listing</strong> Support
|
@@ -112,6 +114,19 @@ You can contact us from [here](http://structured-data-for-wp.com/contact-us/)
|
|
112 |
|
113 |
== Changelog ==
|
114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
= 1.9.6 (11 Sept 2019) =
|
116 |
|
117 |
* Enhancement: Remove all the global static fields and migrate its data to modify schema output #465
|
3 |
Tags: Schema, Structured Data, Google Snippets, Rich Snippets, Schema.org, SEO, AMP
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 5.2
|
6 |
+
Stable tag: 1.9.7
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
23 |
* <strong>Compatibility</strong>: Generate the schema markup for the plugins. We have provided schema support for them. Few of them are - kk Star Ratings, WP-PostRatings, bbPress
|
24 |
* <strong>Google Review</strong>: Display your business google reviews and its schema markup on your website.
|
25 |
* **[Premium]** Reviews ( [Fetch](https://structured-data-for-wp.com/reviews-for-schema) reviews from 75+ platforms ).
|
26 |
+
* **[Premium]** Priority Support. [Get it](https://structured-data-for-wp.com/priority-support/) We get more than 100 technical queries a day but the Priority support plan will help you skip that and get the help from a dedicated team.
|
27 |
+
* <strong>Review Module</strong>: Create your own review rating box with pros and cons and its schema markup
|
28 |
+
* <strong>Schema Type Blocks in Gutenberg</strong>: Create your own content with the blocks and json schema markup will be added automatically
|
29 |
* <strong>Unlimited Custom Post Types</strong>: You can control to represent the Rich Snippets data in the google search console using unlimited custom post types.
|
30 |
* <strong>Easy to use</strong> with Minimal Settings
|
31 |
* <strong>Archive Page Listing</strong> Support
|
114 |
|
115 |
== Changelog ==
|
116 |
|
117 |
+
|
118 |
+
= 1.9.7 (19 Sept 2019) =
|
119 |
+
|
120 |
+
* Major Feature: Schema type blocks (How To & FAQ) have been added in Gutenberg editor
|
121 |
+
* Added: Schema markup to category of WooCommerce #405
|
122 |
+
* Added: Option to remove data on uninstall in Advanced tab #468
|
123 |
+
* Added: Priority support in the Services section in the first place #346
|
124 |
+
* Bug Fixed: "[POST, PAGE] Specific Schema" options don't show up in /wp-admin/post-new.php #409
|
125 |
+
* Bug Fixed: Call to undefined function get_avatar_data #480
|
126 |
+
* Bug Fixed: Need to show the modify schema list based on target location of schema type #483
|
127 |
+
* Bug Fixed: Fatal error function bcdiv () #489
|
128 |
+
|
129 |
+
|
130 |
= 1.9.6 (11 Sept 2019) =
|
131 |
|
132 |
* Enhancement: Remove all the global static fields and migrate its data to modify schema output #465
|
structured-data-for-wp.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*
|
3 |
Plugin Name: Schema & Structured Data for WP
|
4 |
Description: Schema & Structured Data adds Google Rich Snippets markup according to Schema.org guidelines to structure your site for SEO. (AMP Compatible)
|
5 |
-
Version: 1.9.
|
6 |
Text Domain: schema-and-structured-data-for-wp
|
7 |
Domain Path: /languages
|
8 |
Author: Magazine3
|
@@ -13,7 +13,7 @@ License: GPL2
|
|
13 |
// Exit if accessed directly.
|
14 |
if ( ! defined( 'ABSPATH' ) ) exit;
|
15 |
|
16 |
-
define('SASWP_VERSION', '1.9.
|
17 |
define('SASWP_DIR_NAME_FILE', __FILE__ );
|
18 |
define('SASWP_DIR_NAME', dirname( __FILE__ ));
|
19 |
define('SASWP_DIR_URI', plugin_dir_url(__FILE__));
|
@@ -79,6 +79,8 @@ require_once SASWP_DIR_NAME.'/reviews/reviews_admin.php';
|
|
79 |
require_once SASWP_DIR_NAME.'/reviews/reviews_setup.php';
|
80 |
require_once SASWP_DIR_NAME.'/reviews/reviews_service.php';
|
81 |
require_once SASWP_DIR_NAME.'/reviews/reviews_widget.php';
|
|
|
|
|
82 |
|
83 |
//Loading Third party files
|
84 |
require_once SASWP_DIR_NAME.'/core/3rd-party/aqua_resizer.php';
|
@@ -86,11 +88,12 @@ require_once SASWP_DIR_NAME.'/core/3rd-party/aqua_resizer.php';
|
|
86 |
* set user defined message on plugin activate
|
87 |
*/
|
88 |
register_activation_hook( __FILE__, 'saswp_on_activation' );
|
|
|
89 |
|
90 |
add_action( 'admin_notices', 'saswp_admin_notice' );
|
91 |
|
92 |
function saswp_admin_notice(){
|
93 |
-
|
94 |
$screen_id = '';
|
95 |
$current_screen = get_current_screen();
|
96 |
|
2 |
/*
|
3 |
Plugin Name: Schema & Structured Data for WP
|
4 |
Description: Schema & Structured Data adds Google Rich Snippets markup according to Schema.org guidelines to structure your site for SEO. (AMP Compatible)
|
5 |
+
Version: 1.9.7
|
6 |
Text Domain: schema-and-structured-data-for-wp
|
7 |
Domain Path: /languages
|
8 |
Author: Magazine3
|
13 |
// Exit if accessed directly.
|
14 |
if ( ! defined( 'ABSPATH' ) ) exit;
|
15 |
|
16 |
+
define('SASWP_VERSION', '1.9.7');
|
17 |
define('SASWP_DIR_NAME_FILE', __FILE__ );
|
18 |
define('SASWP_DIR_NAME', dirname( __FILE__ ));
|
19 |
define('SASWP_DIR_URI', plugin_dir_url(__FILE__));
|
79 |
require_once SASWP_DIR_NAME.'/reviews/reviews_setup.php';
|
80 |
require_once SASWP_DIR_NAME.'/reviews/reviews_service.php';
|
81 |
require_once SASWP_DIR_NAME.'/reviews/reviews_widget.php';
|
82 |
+
//Module files load
|
83 |
+
require_once SASWP_DIR_NAME.'/modules/gutenberg/includes/class-gutenberg.php';
|
84 |
|
85 |
//Loading Third party files
|
86 |
require_once SASWP_DIR_NAME.'/core/3rd-party/aqua_resizer.php';
|
88 |
* set user defined message on plugin activate
|
89 |
*/
|
90 |
register_activation_hook( __FILE__, 'saswp_on_activation' );
|
91 |
+
register_uninstall_hook( __FILE__, 'saswp_on_uninstall' );
|
92 |
|
93 |
add_action( 'admin_notices', 'saswp_admin_notice' );
|
94 |
|
95 |
function saswp_admin_notice(){
|
96 |
+
|
97 |
$screen_id = '';
|
98 |
$current_screen = get_current_screen();
|
99 |
|
view/post_specific.php
CHANGED
@@ -326,24 +326,23 @@ class saswp_post_specific {
|
|
326 |
|
327 |
public function saswp_get_all_schema_list(){
|
328 |
|
329 |
-
|
330 |
-
|
331 |
-
if($pagenow == 'post.php' || $pagenow == 'admin-ajax.php'){
|
332 |
-
|
333 |
-
if($this->all_schema == null){
|
334 |
-
|
335 |
-
$all_schema = get_posts(
|
336 |
-
array(
|
337 |
-
'post_type' => 'saswp',
|
338 |
-
'posts_per_page' => -1,
|
339 |
-
'post_status' => 'publish',
|
340 |
-
)
|
341 |
-
);
|
342 |
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
347 |
}
|
348 |
|
349 |
public function saswp_post_specifc_add_meta_boxes() {
|
@@ -358,10 +357,9 @@ class saswp_post_specific {
|
|
358 |
}
|
359 |
if(!empty($this->all_schema)){
|
360 |
$schema_count = count($this->all_schema);
|
361 |
-
}
|
362 |
-
|
363 |
$custom_option = get_option('custom_schema_post_enable_'.esc_attr($post->ID));
|
364 |
-
if($schema_count > 0
|
365 |
|
366 |
$show_post_types = get_post_types();
|
367 |
unset($show_post_types['adsforwp'],$show_post_types['saswp'],$show_post_types['attachment'], $show_post_types['revision'], $show_post_types['nav_menu_item'], $show_post_types['user_request'], $show_post_types['custom_css']);
|
@@ -585,9 +583,15 @@ class saswp_post_specific {
|
|
585 |
|
586 |
foreach($this->all_schema as $key => $schema){
|
587 |
|
|
|
|
|
|
|
|
|
|
|
|
|
588 |
$checked = '';
|
589 |
|
590 |
-
if(
|
591 |
|
592 |
$checked = 'checked';
|
593 |
|
@@ -601,7 +605,7 @@ class saswp_post_specific {
|
|
601 |
|
602 |
if($key==0){
|
603 |
|
604 |
-
$tabs .='<li class="selected"><a saswp-schema-type="'.esc_attr($schema_type).'" data-id="saswp_specific_'.esc_attr($schema->ID).'" class="saswp-tab-links selected">'.esc_attr($
|
605 |
. '<label class="saswp-switch">'
|
606 |
. '<input type="checkbox" class="saswp-schema-type-toggle" value="1" data-schema-id="'.esc_attr($schema->ID).'" data-post-id="'.esc_attr($post->ID).'" '.$checked.'>'
|
607 |
. '<span class="saswp-slider"></span>'
|
@@ -620,7 +624,7 @@ class saswp_post_specific {
|
|
620 |
}else{
|
621 |
|
622 |
$tabs .='<li>'
|
623 |
-
. '<a saswp-schema-type="'.esc_attr($schema_type).'" data-id="saswp_specific_'.esc_attr($schema->ID).'" class="saswp-tab-links">'.esc_attr($
|
624 |
. '<label class="saswp-switch">'
|
625 |
. '<input type="checkbox" class="saswp-schema-type-toggle" value="1" data-schema-id="'.esc_attr($schema->ID).'" data-post-id="'.esc_attr($post->ID).'" '.$checked.'>'
|
626 |
. '<span class="saswp-slider"></span>'
|
@@ -683,8 +687,15 @@ class saswp_post_specific {
|
|
683 |
$response_html .= '</div>';
|
684 |
|
685 |
}else{
|
686 |
-
|
687 |
$all_schema = $this->all_schema;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
688 |
$response = $this->saswp_get_fields_by_schema_type($all_schema[0]->ID);
|
689 |
|
690 |
$schema_ids[] = $all_schema[0]->ID;
|
@@ -692,7 +703,7 @@ class saswp_post_specific {
|
|
692 |
|
693 |
$checked = '';
|
694 |
|
695 |
-
if(
|
696 |
$checked = 'checked';
|
697 |
}
|
698 |
|
@@ -899,7 +910,11 @@ class saswp_post_specific {
|
|
899 |
}
|
900 |
|
901 |
$current_user = wp_get_current_user();
|
902 |
-
$author_details
|
|
|
|
|
|
|
|
|
903 |
$schema_type = get_post_meta($schema_id, 'schema_type', true);
|
904 |
$output = '';
|
905 |
|
@@ -1402,7 +1417,12 @@ class saswp_post_specific {
|
|
1402 |
|
1403 |
$current_user = wp_get_current_user();
|
1404 |
$author_desc = get_the_author_meta( 'user_description' );
|
1405 |
-
$author_details
|
|
|
|
|
|
|
|
|
|
|
1406 |
$schema_type = get_post_meta($schema_id, 'schema_type', true);
|
1407 |
|
1408 |
$business_type = get_post_meta($schema_id, 'saswp_business_type', true);
|
326 |
|
327 |
public function saswp_get_all_schema_list(){
|
328 |
|
329 |
+
$schema_ids = array();
|
330 |
+
$schema_id_array = json_decode(get_transient('saswp_transient_schema_ids'), true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
331 |
|
332 |
+
if(!$schema_id_array){
|
333 |
+
|
334 |
+
$schema_id_array = saswp_get_saved_schema_ids();
|
335 |
+
|
336 |
+
}
|
337 |
+
if($schema_id_array && is_array($schema_id_array)){
|
338 |
+
|
339 |
+
foreach($schema_id_array as $schema_id){
|
340 |
+
|
341 |
+
$schema_ids['ID'] = $schema_id;
|
342 |
+
$this->all_schema[] = (object)$schema_ids;
|
343 |
+
}
|
344 |
+
}
|
345 |
+
|
346 |
}
|
347 |
|
348 |
public function saswp_post_specifc_add_meta_boxes() {
|
357 |
}
|
358 |
if(!empty($this->all_schema)){
|
359 |
$schema_count = count($this->all_schema);
|
360 |
+
}
|
|
|
361 |
$custom_option = get_option('custom_schema_post_enable_'.esc_attr($post->ID));
|
362 |
+
if($schema_count > 0){
|
363 |
|
364 |
$show_post_types = get_post_types();
|
365 |
unset($show_post_types['adsforwp'],$show_post_types['saswp'],$show_post_types['attachment'], $show_post_types['revision'], $show_post_types['nav_menu_item'], $show_post_types['user_request'], $show_post_types['custom_css']);
|
583 |
|
584 |
foreach($this->all_schema as $key => $schema){
|
585 |
|
586 |
+
$advnace_status = saswp_check_advance_display_status($schema->ID);
|
587 |
+
|
588 |
+
if($advnace_status !== 1){
|
589 |
+
continue;
|
590 |
+
}
|
591 |
+
|
592 |
$checked = '';
|
593 |
|
594 |
+
if(isset($schema_enable[$schema->ID]) && $schema_enable[$schema->ID] == 1){
|
595 |
|
596 |
$checked = 'checked';
|
597 |
|
605 |
|
606 |
if($key==0){
|
607 |
|
608 |
+
$tabs .='<li class="selected"><a saswp-schema-type="'.esc_attr($schema_type).'" data-id="saswp_specific_'.esc_attr($schema->ID).'" class="saswp-tab-links selected">'.esc_attr($schema_type == 'local_business'? 'LocalBusiness': $schema_type).'</a>'
|
609 |
. '<label class="saswp-switch">'
|
610 |
. '<input type="checkbox" class="saswp-schema-type-toggle" value="1" data-schema-id="'.esc_attr($schema->ID).'" data-post-id="'.esc_attr($post->ID).'" '.$checked.'>'
|
611 |
. '<span class="saswp-slider"></span>'
|
624 |
}else{
|
625 |
|
626 |
$tabs .='<li>'
|
627 |
+
. '<a saswp-schema-type="'.esc_attr($schema_type).'" data-id="saswp_specific_'.esc_attr($schema->ID).'" class="saswp-tab-links">'.esc_attr($schema_type == 'local_business'? 'LocalBusiness': $schema_type).'</a>'
|
628 |
. '<label class="saswp-switch">'
|
629 |
. '<input type="checkbox" class="saswp-schema-type-toggle" value="1" data-schema-id="'.esc_attr($schema->ID).'" data-post-id="'.esc_attr($post->ID).'" '.$checked.'>'
|
630 |
. '<span class="saswp-slider"></span>'
|
687 |
$response_html .= '</div>';
|
688 |
|
689 |
}else{
|
690 |
+
|
691 |
$all_schema = $this->all_schema;
|
692 |
+
|
693 |
+
$advnace_status = saswp_check_advance_display_status($all_schema[0]->ID);
|
694 |
+
|
695 |
+
if(!$advnace_status){
|
696 |
+
return '';
|
697 |
+
}
|
698 |
+
|
699 |
$response = $this->saswp_get_fields_by_schema_type($all_schema[0]->ID);
|
700 |
|
701 |
$schema_ids[] = $all_schema[0]->ID;
|
703 |
|
704 |
$checked = '';
|
705 |
|
706 |
+
if(isset($schema_enable[$all_schema[0]->ID]) && $schema_enable[$all_schema[0]->ID] == 1){
|
707 |
$checked = 'checked';
|
708 |
}
|
709 |
|
910 |
}
|
911 |
|
912 |
$current_user = wp_get_current_user();
|
913 |
+
$author_details = array();
|
914 |
+
|
915 |
+
if(function_exists('get_avatar_data')){
|
916 |
+
$author_details = get_avatar_data($current_user->ID);
|
917 |
+
}
|
918 |
$schema_type = get_post_meta($schema_id, 'schema_type', true);
|
919 |
$output = '';
|
920 |
|
1417 |
|
1418 |
$current_user = wp_get_current_user();
|
1419 |
$author_desc = get_the_author_meta( 'user_description' );
|
1420 |
+
$author_details = array();
|
1421 |
+
|
1422 |
+
if(function_exists('get_avatar_data')){
|
1423 |
+
$author_details = get_avatar_data($current_user->ID);
|
1424 |
+
}
|
1425 |
+
|
1426 |
$schema_type = get_post_meta($schema_id, 'schema_type', true);
|
1427 |
|
1428 |
$business_type = get_post_meta($schema_id, 'saswp_business_type', true);
|