Plugin Directory

Changeset 2453124


Ignore:
Timestamp:
01/09/2021 02:19:42 PM (5 years ago)
Author:
deano1987
Message:

1.8

  • Fixed issue with categories schema
Location:
schema-breadcrumbs
Files:
6 added
2 edited

Legend:

Unmodified
Added
Removed
  • schema-breadcrumbs/trunk/readme.txt

    r2451981 r2453124  
    55Requires at least: 2.2
    66Tested up to: 5.6
    7 stable tag: 1.7
     7stable tag: 1.8
    88
    99Very easily add breadcrumbs to your site with valid Schema Breadcrumb Markup, this plugin is also a drop-in replacement for RDFa Breadcrumb, just install this and deactivate RDFa Breadcrumb.
     
    3131
    3232== Changelog ==
     33
     34= 1.8 =
     35* Fixed issue with categories schema
    3336
    3437= 1.6 =
  • schema-breadcrumbs/trunk/schema-breadcrumbs.php

    r2451981 r2453124  
    33Plugin URI:   http://webdesires.co.uk
    44Description:  Outputs a fully Schema valid breadcrumb
    5 Version:      1.7
     5Version:      1.8
    66Author:       Dean Williams
    77Author URI:   http://deano.me
     
    280280           
    281281            $parent = &get_category($id);
     282            $parent_id = $id;
    282283            if ( is_wp_error( $parent ) )
    283284               return $parent;
     
    292293
    293294            $chain[] = ($name);
     295
     296            //print_r($parent);
     297
     298            do {
     299                $parent = &get_category($parent_id);
     300
     301                $actual_link = explode('?', "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]");
     302                    $schema[] = '{
     303                        "@type": "ListItem",
     304                        "position": '.(count($schema)+1).',
     305                        "item":
     306                        {
     307                            "@id": "'.get_category_link($parent->cat_ID).'",
     308                                "url": "'.get_category_link($parent->cat_ID).'",
     309                            "name": "'.$parent->name.'"
     310                            }
     311                        }';
     312
     313                $parent_id = $parent->parent;
     314            } while($parent_id > 0);
     315
    294316            return $chain;
    295317        }
     
    597619                    $schema[] = $homelinkschema;
    598620                    $output[] = $homelink;
    599                     $output[] = schema_get_category_parents($cat, false);
     621                    $output = array_merge($output, schema_get_category_parents($cat, false));
     622                   
    600623                } elseif ( get_post_type() == 'product' ) {
    601624                    $actual_link = explode('?', "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]");
     
    704727
    705728        $html = '';
     729       
    706730        foreach ($output as $key => $out) {
    707731            /* if (count($output) == $key+1) {
     
    723747            if (count($output) == $key+1) {
    724748
    725                 $actual_link = explode('?', "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]");
    726                 $actual_link = $actual_link[0];
    727                 $schema[] = '{
     749                if (count($output) > count($schema)) {
     750                    $actual_link = explode('?', "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]");
     751                    $actual_link = $actual_link[0];
     752                    $schema[] = '{
    728753                            "@type": "ListItem",
    729754                            "position": '.(count($schema)+1).',
     
    732757                                "@id": "'.$actual_link.'",
    733758                                    "url": "'.$actual_link.'",
    734                                 "name": "'.get_the_title().'"
     759                                "name": "1'.get_the_title().'"
    735760                                }
    736761                            }';
     762                }
    737763
    738764                if ($opt['boldlast']) {
Note: See TracChangeset for help on using the changeset viewer.