-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Peter J. Herrel
committed
Feb 27, 2017
0 parents
commit 5af5d7d
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
// aureum est silentium |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/* | ||
Plugin Name: Polylang Body Class | ||
Plugin URI: https://github.com/diggy/polylang-body-class | ||
Version: 1.0.0 | ||
Author: Peter J. Herrel | ||
Author uri: https://github.com/diggy | ||
Description: Adds prefixed and sanitized locale to body classes. Background: https://git.io/vyIh7 | ||
License: GPL-2.0+ | ||
License URI: https://www.gnu.org/licenses/gpl-2.0.txt | ||
*/ | ||
|
||
# prevent direct access | ||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; | ||
} | ||
|
||
/** | ||
* Adds prefixed and sanitized locale to body classes | ||
* | ||
* @param array $classes An array of body classes. | ||
* @return array | ||
*/ | ||
add_filter( 'body_class', 'pll_plugin_body_class' ); | ||
function pll_plugin_body_class( $classes ) | ||
{ | ||
if ( function_exists( 'PLL' ) && $language = PLL()->model->get_language( get_locale() ) ) | ||
{ | ||
$classes[] = 'pll-' . str_replace( '_', '-', sanitize_title_with_dashes( $language->get_locale( 'raw' ) ) ); | ||
} | ||
|
||
return $classes; | ||
} |