diff --git a/tinymce-email-button.php b/tinymce-email-button.php index c8a29c0..95d0eb9 100644 --- a/tinymce-email-button.php +++ b/tinymce-email-button.php @@ -1,7 +1,7 @@ plugin_dir_url(__FILE__), - 'title' => __('Insert e-mail link', 'tinymce-email-button'), - 'prompt' => __('Enter the email address to link to:', 'tinymce-email-button'), - )); + wp_localize_script( 'editor', 'tinymce_email_button', array( + 'url' => plugin_dir_url( __FILE__ ), + 'title' => __( 'Insert e-mail link', 'tinymce-email-button' ), + 'prompt' => __( 'Enter the email address to link to:', 'tinymce-email-button' ), + ) ); } /** @@ -71,20 +68,17 @@ public function i18n() * @param array $buttons ordered button list * @return array $buttons */ - public function mce_buttons($buttons) - { + public function mce_buttons( $buttons ) { // Look for the regular link button - if (FALSE === ($key = array_search('link', $buttons))) - { + $key = array_search( 'link', $buttons ); + if ( false === $key ) { // Append the button to the end of the row if no link button was found $buttons[] = 'email'; - } - else - { + } else { // Insert the email button before the link button - $before = array_slice($buttons, 0, $key); - $after = array_slice($buttons, $key); - $buttons = array_merge($before, array('email'), $after); + $before = array_slice( $buttons, 0, $key ); + $after = array_slice( $buttons, $key ); + $buttons = array_merge( $before, array( 'email' ), $after ); } return $buttons; @@ -96,10 +90,9 @@ public function mce_buttons($buttons) * @param array $plugins TinyMCE plugin files * @return array $plugins */ - public function mce_external_plugins($plugins) - { - $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; - $plugins['email'] = plugin_dir_url(__FILE__).'javascript/tinymce-email-button'.$suffix.'.js'; + public function mce_external_plugins( $plugins ) { + $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; + $plugins['email'] = plugin_dir_url( __FILE__ ) . "javascript/tinymce-email-button$suffix.js"; return $plugins; }