You are here

function wysiwyg_tinymce_version in Wysiwyg 7.2

Same name and namespace in other branches
  1. 5.2 editors/tinymce.inc \wysiwyg_tinymce_version()
  2. 5 editors/tinymce.inc \wysiwyg_tinymce_version()
  3. 6.2 editors/tinymce.inc \wysiwyg_tinymce_version()
  4. 6 editors/tinymce.inc \wysiwyg_tinymce_version()

Detect editor version.

Parameters

$editor: An array containing editor properties as returned from hook_editor().

Return value

The installed editor version.

1 string reference to 'wysiwyg_tinymce_version'
wysiwyg_tinymce_editor in editors/tinymce.inc
Plugin implementation of hook_editor().

File

editors/tinymce.inc, line 93
Editor integration functions for TinyMCE.

Code

function wysiwyg_tinymce_version($editor) {
  $script = $editor['library path'] . '/jscripts/tiny_mce/tiny_mce.js';
  if (!file_exists($script)) {
    $script = $editor['library path'] . '/js/tinymce/tinymce.min.js';
    if (!file_exists($script)) {
      return;
    }
  }
  $script = fopen($script, 'r');

  // Version is contained in the first 200 chars.
  $line = fgets($script, 200);
  fclose($script);

  // 2.x: this.majorVersion="2";this.minorVersion="1.3"
  // 3.x: majorVersion:'3',minorVersion:'2.0.1'
  // 4.x: 4.0b2 (2013-04-24)
  if (preg_match('@majorVersion[=:]["\'](\\d).+?minorVersion[=:]["\']([\\d\\.]+)@', $line, $version) || preg_match('@(\\d)\\.([\\d\\.\\w]+) @', $line, $version)) {
    return $version[1] . '.' . $version[2];
  }
}