id === 'toplevel_page_yatra';
}
/**
* Critical CSS + dark-mode init in <head> (before body) to prevent FOUC / flicker of native wp-admin chrome.
*
* Previously this lived in templates/admin.php (body), so the menu painted before hide rules applied.
*/
public function printYatraReactAdminCriticalCss(): void
{
if (!$this->isYatraMainReactAdminScreen()) {
return;
}
$app_js = YATRA_PLUGIN_PATH . 'assets/admin/dist/js/app.js';
$has_build = file_exists($app_js);
?>
isYatraMainReactAdminScreen()) {
$classes .= ' yatra-react-admin-shell';
}
return $classes;
}
/**
* Hide Setup Wizard in the Yatra submenu while keeping it registered (required for direct URL access).
*/
public function printHideYatraSetupWizardSubmenu(): void
{
if (!apply_filters('yatra_enable_setup_wizard', true)) {
return;
}
if (!apply_filters('yatra_hide_setup_wizard_submenu', true)) {
return;
}
echo '';
}
/**
* Size the custom Yatra menu icon (PNG) like core dashicons.
*/
public function printYatraAdminMenuIconStyles(): void
{
if (!function_exists('yatra_get_brand_icon_url') || yatra_get_brand_icon_url() === '') {
return;
}
echo '';
}
/**
* “Upgrade to Pro” on the Plugins list (free only).
*
* @param array $links
* @return array
*/
public function addPluginUpgradeLink(array $links): array
{
if (apply_filters('yatra_is_pro_active', false)) {
return $links;
}
$upgrade = sprintf(
'%s',
esc_url(self::UPGRADE_TO_PRO_URL),
esc_html__('Upgrade to Pro', 'yatra')
);
array_unshift($links, $upgrade);
return $links;
}
/**
* Plugins list row meta: Version, By MantraBrain, View details, Support, Plugin Homepage, Contact, Rate (5★).
*
* @param string[] $plugin_meta
* @param array $plugin_data
* @return string[]
*/
public function filterPluginRowMeta(array $plugin_meta, string $plugin_file, array $plugin_data, string $status): array
{
if ($plugin_file !== YATRA_PLUGIN_BASENAME) {
return $plugin_meta;
}
$is_white_label = function_exists('yatra_is_white_label_active') && yatra_is_white_label_active();
$brand_company = function_exists('yatra_get_brand_company') ? yatra_get_brand_company() : 'MantraBrain';
$brand_home = function_exists('yatra_get_brand_website_url') ? yatra_get_brand_website_url() : 'https://wpyatra.com/';
$brand_support = function_exists('yatra_get_brand_support_url') ? yatra_get_brand_support_url() : 'https://wordpress.org/support/plugin/yatra/reviews/?filter=5';
$home = $brand_home;
$org_plugin_page = 'https://wordpress.org/plugins/yatra/';
$support_url = $brand_support;
$contact_url = $brand_home;
$rate_url = 'https://wordpress.org/support/plugin/yatra/reviews/?filter=5';
$row = [];
if (!empty($plugin_data['Version'])) {
$row[] = sprintf(
/* translators: %s: plugin version number. */
__('Version %s', 'yatra'),
$plugin_data['Version']
);
}
$row[] = sprintf(
/* translators: %s: linked author name (HTML). */
__('By %s', 'yatra'),
'' . esc_html($brand_company) . ''
);
// White-label sites should not link clients off to wp.org / Yatra rating
// pages. Show only the agency's own support + homepage links.
if (!$is_white_label) {
$row[] = sprintf(
'%s',
esc_url($org_plugin_page),
esc_html__('View details', 'yatra')
);
}
$row[] = sprintf(
'%s',
esc_url($support_url),
esc_html__('Support', 'yatra')
);
$row[] = sprintf(
'%s',
esc_url($home),
esc_html__('Plugin Homepage', 'yatra')
);
if (!$is_white_label) {
$row[] = sprintf(
'%s',
esc_url($contact_url),
esc_html__('Contact', 'yatra')
);
$row[] = sprintf(
'%s ★★★★★',
esc_url($rate_url),
esc_html__('Rate the plugin', 'yatra')
);
}
return $row;
}
/**
* Amber styling for Upgrade to Pro (admin menu + plugins list).
*/
public function printUpgradeProAdminStyles(): void
{
if (apply_filters('yatra_is_pro_active', false)) {
return;
}
if (!is_admin()) {
return;
}
$screen = function_exists('get_current_screen') ? get_current_screen() : null;
$onPlugins = $screen && $screen->id === 'plugins';
$pricingHref = esc_attr(self::UPGRADE_TO_PRO_URL);
// Plain link emphasis only (same layout as other submenu items / plugin row links).
// Bright orange, bold — reads clearly on default admin submenu and Plugins screen (no button chrome).
echo '';
}
/**
* Open pricing link in a new tab (submenu HTML is generated by core without target="_blank").
*/
public function upgradeProSubmenuOpenInNewTab(): void
{
if (apply_filters('yatra_is_pro_active', false)) {
return;
}
if (!is_admin()) {
return;
}
$url = wp_json_encode(self::UPGRADE_TO_PRO_URL, JSON_UNESCAPED_SLASHES);
echo '";
}
/**
* Direct external submenu link (WordPress prints href from slug when it is not a registered admin page file).
*
* @global array>> $submenu
*/
public function registerUpgradeProExternalSubmenu(): void
{
if (apply_filters('yatra_is_pro_active', false)) {
return;
}
global $submenu;
if (!isset($submenu['yatra']) || !is_array($submenu['yatra'])) {
return;
}
$submenu['yatra'][] = [
esc_html__('Upgrade to Pro', 'yatra'),
'manage_options',
self::UPGRADE_TO_PRO_URL,
esc_html__('Upgrade to Pro', 'yatra'),
];
}
/**
* Add type="module" attribute to yatra-admin script
*/
public function addModuleTypeToScript(string $tag, string $handle): string
{
if ($handle === 'yatra-admin') {
// Check if type="module" is already present
if (strpos($tag, 'type="module"') === false && strpos($tag, "type='module'") === false) {
// Replace the script tag to add type="module"
$tag = str_replace('