Created
May 21, 2019 13:40
-
-
Save Jimmylet/bbb0e18032fc518d91e9a9049c40b91c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| /* In functions.php, paste this code (replace YOUR_THEME_NAME by your theme name) */ | |
| /* Use this code with the plugin Theme and plugin translation for Polylang */ | |
| if (class_exists('Polylang_Theme_Translation')) { | |
| class Sage_Polylang_Theme_Translation extends Polylang_Theme_Translation | |
| { | |
| /** | |
| * Constructor. | |
| */ | |
| public function __construct() | |
| { | |
| parent::__construct(); | |
| $this->run_sage_theme_scanner(); | |
| } | |
| /** | |
| * Find strings in /theme/app folder. | |
| */ | |
| protected function run_sage_theme_scanner() | |
| { | |
| $themes = wp_get_themes(); | |
| if (!empty($themes)) { | |
| foreach ($themes as $name => $theme) { | |
| if ($name === 'YOUR_THEME_NAME/resources') { | |
| $theme_path = $theme->theme_root . DIRECTORY_SEPARATOR . $name; | |
| $app_path = str_replace('resources', 'app', $theme_path); | |
| $app_controllers_path = "{$app_path}/controllers"; | |
| $app_files = $this->get_files_from_dir($app_path); | |
| $app_controllers_files = $this->get_files_from_dir($app_controllers_path); | |
| $app_strings = $this->file_scanner($app_files); | |
| $app_controllers_strings = $this->file_scanner($app_controllers_files); | |
| $strings = array_merge($app_strings, $app_controllers_strings); | |
| $this->add_to_polylang_register($strings, $name); | |
| } | |
| } | |
| } | |
| } | |
| } | |
| new Sage_Polylang_Theme_Translation(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment