/** * Template tag for breadcrumbs. * * @todo [JRF => Yoast/whomever] We could probably get rid of the 'breadcrumbs-enable' option key * as the file is now only loaded when the template tag is encountered anyway. * Only issue with that would be the removal of the bbPress crumb from within wpseo_frontend_init() * in wpseo.php which is also based on this setting. * Whether or not to show the bctitle field within meta boxes is also based on this setting, but * showing these when someone hasn't implemented the template tag shouldn't really give cause for concern. * Other than that, leaving the setting is an easy way to enable/disable the bc without having to * edit the template files again, but having to manually enable when you've added the template tag * in your theme is kind of double, so I'm undecided about what to do. * I guess I'm leaning towards removing the option key. * * @param string $before What to show before the breadcrumb. * @param string $after What to show after the breadcrumb. * @param bool $display Whether to display the breadcrumb (true) or return it (false). * * @return string */ function yoast_breadcrumb($before = '', $after = '', $display = true) { $options = get_option('wpseo_internallinks'); if ($options['breadcrumbs-enable'] === true) { return WPSEO_Breadcrumbs::breadcrumb($before, $after, $display); } }
/** * Placeholder test to prevent PHPUnit from throwing errors */ public function test_breadcrumb_after() { // test after argument $output = WPSEO_Breadcrumbs::breadcrumb('', 'after', false); $expected = 'after'; $this->assertStringEndsWith($expected, $output); // todo test actual breadcrumb output.. }
/** * Template tag for breadcrumbs. * * @param string $before What to show before the breadcrumb. * @param string $after What to show after the breadcrumb. * @param bool $display Whether to display the breadcrumb (true) or return it (false). * * @return string */ function yoast_breadcrumb($before = '', $after = '', $display = true) { $breadcrumbs_enabled = current_theme_supports('yoast-seo-breadcrumbs'); if (!$breadcrumbs_enabled) { $options = get_option('wpseo_internallinks'); $breadcrumbs_enabled = $options['breadcrumbs-enable'] === true; } if ($breadcrumbs_enabled) { return WPSEO_Breadcrumbs::breadcrumb($before, $after, $display); } }
/** * Get breadcrumb string using the singleton instance of this class * * @return object */ public static function breadcrumb($before = '', $after = '', $display = true) { if (!self::$instance instanceof self) { self::$instance = new self(); } // Remember the last used before/after for use in case the object goes __toString() self::$before = $before; self::$after = $after; $output = $before . self::$instance->output . $after; if ($display === true) { echo $output; return true; } else { return $output; } }
function yoast_breadcrumb($prefix = '', $suffix = '', $display = true) { $wpseo_bc = new WPSEO_Breadcrumbs(); return $wpseo_bc->breadcrumb($prefix, $suffix, $display); }