Skip to content

Commit

Permalink
Merge branch 'main' into feedback-and-services-catalogue-cms-able
Browse files Browse the repository at this point in the history
  • Loading branch information
SourabhChakraborty committed Feb 23, 2024
2 parents 79f6638 + 3cc650d commit 2da7227
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 8 deletions.
21 changes: 21 additions & 0 deletions wp-content/mu-plugins/add-link-locale.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

// Add locale to a link if it currently doesn't exist
// Examples, if the locale is 'es':
// https://jobs.nyc.gov/employers -> https://jobs.nyc.gov/es/employers
// https://jobs.nyc.gov/es/employers -> https://jobs.nyc.gov/es/employers
// If locale is 'en':
// https://jobs.nyc.gov/employers -> https://jobs.nyc.gov/employers
if (! function_exists('convert_link_locale')) {
function convert_link_locale($original_url, $site_url, $site_url_localized) {
if (! strpos($original_url, $site_url_localized)) {
$site_url_localized_to_use = $site_url_localized;
if (substr($site_url_localized_to_use, -1) === "/") {
$site_url_localized_to_use = substr_replace($site_url_localized_to_use, "", -1);
}
return str_replace($site_url, $site_url_localized_to_use, $original_url);
}
// if original url is already localized, return it
return $original_url;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{% set container_button_class = 'btn-styled' %}
{% endif %}

<a class="mt-2 btn btn-small tablet:btn {{ container_button_class }} pointer-events-auto" href="{{ this.fields.container_button_link }}">{{ this.fields.container_button_text }}</a>
<a class="mt-2 btn btn-small tablet:btn {{ container_button_class }} pointer-events-auto" href="{{ function('convert_link_locale', this.fields.container_button_link, site.site_url, site.url) }}">{{ this.fields.container_button_text }}</a>
</div>
{% if this.fields.container_image_side == 'right' %}
<div class="desktop-w-500 desktop-h-400 hidden desktop:block">
Expand Down
6 changes: 3 additions & 3 deletions wp-content/themes/workingnyc/views/employer-home-page.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
<div class="pb-3 tablet:pb-0 desktop:pb-0 tablet:pr-3 desktop:pr-3">
<h3 class="mb-3">{{ post.meta('subtitle_1') }}</h3>
<p class="mb-3">{{ post.meta('description_1') }}</p>
<a class="btn bg-white border-[#30374F] text-[#30374F] hover:bg-[#30374F] hover:text-white pointer-events-auto" href="{{ post.meta('button_link_1') }}">{{ post.meta('button_label_1') }}</a>
<a class="btn bg-white border-[#30374F] text-[#30374F] hover:bg-[#30374F] hover:text-white pointer-events-auto" href="{{ function('convert_link_locale', post.meta('button_link_1'), site.site_url, site.url) }}">{{ post.meta('button_label_1') }}</a>
</div>
<div class="pt-3 tablet:pt-0 desktop:pt-0 border-t-3 tablet:border-t-0 desktop:border-t-0 tablet:border-l-3 desktop:border-l-3 border-slate-300 tablet:pl-3 desktop:pl-3">
<h3 class="mb-3">{{ post.meta('subtitle_2') }}</h3>
<p class="mb-3">{{ post.meta('description_2') }}</p>
<a class="btn bg-white border-[#30374F] text-[#30374F] hover:bg-[#30374F] hover:text-white pointer-events-auto" href="{{ post.meta('button_link_2') }}">{{ post.meta('button_label_2') }}</a>
<a class="btn bg-white border-[#30374F] text-[#30374F] hover:bg-[#30374F] hover:text-white pointer-events-auto" href="{{ function('convert_link_locale', post.meta('button_link_2'), site.site_url, site.url) }}">{{ post.meta('button_label_2') }}</a>
</div>
</div>
</div>
Expand All @@ -36,7 +36,7 @@
{# Collections #}
{% if collections %}
{% for collection in collections %}
{% include collection.template with {this: collection} only %}
{% include collection.template with {this: collection, site: site} only %}
{% endfor %}
{% endif %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</div>
<div>
{% for menu_item in employer_header_menu.get_items %}
<a class="o-navigation__item mr-2 desktop:py-2 desktop-px-12" width="84" height="70" href="{{ menu_item.link }}">{{ menu_item.title }}</a>
<a class="o-navigation__item mr-2 desktop:py-2 desktop-px-12" width="84" height="70" href="{{ function('convert_link_locale', menu_item.link, site.site_url, site.url) }}">{{ menu_item.title }}</a>
{% endfor %}
</div>
<button class="desktop:hidden mie-0" aria-controls="aria-c-menu" aria-expanded="false" data-js="menu" data-js-menu="open">
Expand Down
2 changes: 1 addition & 1 deletion wp-content/themes/workingnyc/views/objects/footer.twig
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
{% set footer_menu_to_use = job_seeker_footer_menu %}
{% endif %}
{% for m in footer_menu_to_use.get_items %}
<a class="inline mr-2 desktop:mr-3 tablet:mr-3" href="{{ m.link }}"
<a class="inline mr-2 desktop:mr-3 tablet:mr-3" href="{{ function('convert_link_locale', m.link, site.site_url, site.url) }}"
{% if m.attr_title %}title="{{ m.attr_title }}"{% endif %}
{% if m.target %}target="{{ m.target }}"{% endif %}
{% if m.xfn %}rel="{{ m.xfn }}"{% endif %}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
<div class="mx-3 tablet:mx-auto desktop:ml-auto desktop:mr-0 tablet:w-4/5 grid bg-white p-4">
<h3 class="mx-auto mb-4 text-center">{{ post.meta('subtitle_1') }}</h3>
<p class="mx-auto mb-4 text-center">{{ post.meta('description_1') }}</p>
<a class="mx-auto btn tablet:btn btn-secondary pointer-events-auto" href="{{ post.meta('button_link_1') }}">{{ post.meta('button_label_1') }}</a>
<a class="mx-auto btn tablet:btn btn-secondary pointer-events-auto" href="{{ function('convert_link_locale', post.meta('button_link_1'), site.site_url, site.url) }}">{{ post.meta('button_label_1') }}</a>
</div>
<div class="mx-3 tablet:mx-auto desktop:mr-auto desktop:ml-0 tablet:w-4/5 grid bg-white p-4">
<h3 class="mx-auto mb-4 text-center">{{ post.meta('subtitle_2') }}</h3>
<p class="mx-auto mb-4 text-center">{{ post.meta('description_2') }}</p>
<a class="mx-auto btn tablet:btn btn-secondary pointer-events-auto" href="{{ post.meta('button_link_2') }}">{{ post.meta('button_label_2') }}</a>
<a class="mx-auto btn tablet:btn btn-secondary pointer-events-auto" href="{{ function('convert_link_locale', post.meta('button_link_2'), site.site_url, site.url) }}">{{ post.meta('button_label_2') }}</a>
</div>
</div>
</div>
Expand Down

0 comments on commit 2da7227

Please sign in to comment.