| 1 |
(function ($) { |
| 2 |
"use strict"; |
| 3 |
$(document).ready(function () { |
| 4 |
var cfg = window.betterdocsSwitcher; |
| 5 |
if (!cfg || !cfg.page) { |
| 6 |
return; |
| 7 |
} |
| 8 |
// Inject the "Switch to BetterDocs UI" button next to the page heading. |
| 9 |
// The script is only enqueued on the relevant classic screens (Docs, |
| 10 |
// FAQ, FAQ groups, Product FAQ groups, Doc Categories, Doc Tags), so |
| 11 |
// targeting the first .wp-heading-inline is safe. `cfg.url` is the |
| 12 |
// full React admin page URL (it can carry extra args like the FAQ |
| 13 |
// Builder tab); `cfg.page` is the older slug-only fallback. |
| 14 |
var href = cfg.url || "admin.php?page=" + cfg.page; |
| 15 |
$(".wp-heading-inline") |
| 16 |
.first() |
| 17 |
.after( |
| 18 |
'<a href="' + |
| 19 |
href + |
| 20 |
'" class="page-title-action betterdocs-ui-switch">' + |
| 21 |
(cfg.menu_title || "Switch to BetterDocs UI") + |
| 22 |
"</a>" |
| 23 |
); |
| 24 |
}); |
| 25 |
})(jQuery); |
| 26 |
|