Title: Bug &#8211; wp_localize_script
Last modified: August 21, 2016

---

# Bug – wp_localize_script

 *  Resolved [vovasik](https://wordpress.org/support/users/vovasik/)
 * (@vovasik)
 * [12 years ago](https://wordpress.org/support/topic/bug-wp_localize_script/)
 * Does not match the data type, the second argument wp_localize_script:
 *     ```
       $sh_settings = array_merge( array(
       			'unsaved_changes_txt' => __('Some changes have not been saved.', 'syntax-highlight')
       			), $sh_settings);
       		wp_localize_script( $this->js_handle, 'shSettings', $sh_settings);
       ```
   
 * Fix:
 *     ```
       if(is_array($sh_settings)) {
                   $sh_settings = array_merge(array(
                       'unsaved_changes_txt' => __('Some changes have not been saved.', 'syntax-highlight')
                   ), $sh_settings);
               }else{
                   $sh_settings= array();
               }
       ```
   
 * [https://wordpress.org/plugins/syntax-highlight/](https://wordpress.org/plugins/syntax-highlight/)

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Author [lukasz.webmaster](https://wordpress.org/support/users/lukaszwebmaster/)
 * (@lukaszwebmaster)
 * [12 years ago](https://wordpress.org/support/topic/bug-wp_localize_script/#post-4991688)
 * Hi vovasik,
 * Thank you for noticing this and for providing the solution.
 * However, it is a bit strange that `sh_settings` variable is not an array. In 
   this case plugin might not work as intended – the settings will not work. Could
   you tell me what plugins you have activated? I think Syntax Highlight may collide
   with one of them.
 * Thank you for your message.
 * Regards,
    Lukasz
 *  Thread Starter [vovasik](https://wordpress.org/support/users/vovasik/)
 * (@vovasik)
 * [12 years ago](https://wordpress.org/support/topic/bug-wp_localize_script/#post-4991713)
 * May be a problem in a custom template of my site, I will write more tomorrow,
   need to look at the source code
 *  Plugin Author [lukasz.webmaster](https://wordpress.org/support/users/lukaszwebmaster/)
 * (@lukaszwebmaster)
 * [12 years ago](https://wordpress.org/support/topic/bug-wp_localize_script/#post-4991726)
 * Okay, so I look forward to further information. Maybe you could provide me admin
   access to your WordPress instance? I could also take a look then.
 * Best regards,
    Lukasz
 *  Thread Starter [vovasik](https://wordpress.org/support/users/vovasik/)
 * (@vovasik)
 * [12 years ago](https://wordpress.org/support/topic/bug-wp_localize_script/#post-4991751)
 * Доступа к своему сайту дать не могу , потому что он локальный.
    Я проверил плагин
   на стандартной конфигурации: wordpress 3.9; theme: Twenty Thirteen; plugins: –(
   только Syntax Highlight); дополнительная информация:
 * php: 5.4
    webserver: nginx 1.6
 * **Но это не важно.**
 * _Проблема в том что классclass SH\_Settings возвращает по умолчанию строковые
   значения, если на странице настроек внести изминения одного из параметров /options-
   general.php?page=sh\_settings то класс SH\_Settings вернет массив натроек их 
   из базы данных (get\_option). Трудность отладки в вашей установке в этом. Попробуйте
   протестировать не внося изминений в /options-general.php?page=sh\_settings._
 * P.S. архив моей установки
 * [https://dl.dropboxusercontent.com/u/87478289/public_html.zip](https://dl.dropboxusercontent.com/u/87478289/public_html.zip)
 *  Plugin Author [lukasz.webmaster](https://wordpress.org/support/users/lukaszwebmaster/)
 * (@lukaszwebmaster)
 * [12 years ago](https://wordpress.org/support/topic/bug-wp_localize_script/#post-4991778)
 * Thank you vovasik for sharing your WordPress installation.
 * I have investigated the issue and the problem was in obtaining the default settings,
   when there have been no changes in the Settings page. In the latest version (
   1.0.1) this issue has been resolved.
 * Please update to the latest version and, if it works fine now, I would be grateful,
   if you could express it on Syntax Highlight plugin page in the Compatibility 
   section at the bottom of the page.
 * Thanks again for noticing the issue.
 *  Thread Starter [vovasik](https://wordpress.org/support/users/vovasik/)
 * (@vovasik)
 * [12 years ago](https://wordpress.org/support/topic/bug-wp_localize_script/#post-4991784)
 * That’s what I tried you convey, thank you
 *  Plugin Author [lukasz.webmaster](https://wordpress.org/support/users/lukaszwebmaster/)
 * (@lukaszwebmaster)
 * [12 years ago](https://wordpress.org/support/topic/bug-wp_localize_script/#post-4991798)
 * Ok, I see. I don’t know Russian and Google Translate didn’t deal good with your
   post. But most importantly, that the bug is fixed now 🙂

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Bug – wp_localize_script’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/syntax-highlight.svg)
 * [Syntax Highlight](https://wordpress.org/plugins/syntax-highlight/)
 * [Support Threads](https://wordpress.org/support/plugin/syntax-highlight/)
 * [Active Topics](https://wordpress.org/support/plugin/syntax-highlight/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/syntax-highlight/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/syntax-highlight/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [lukasz.webmaster](https://wordpress.org/support/users/lukaszwebmaster/)
 * Last activity: [12 years ago](https://wordpress.org/support/topic/bug-wp_localize_script/#post-4991798)
 * Status: resolved