CKEditor for WordPress - Version 3.6.2.4

Version Description

  • 13.12.2011 =

    • Fix problems with upgrade and working correctly in new Wordpress 3.3 Sonny.
    • Fix problem with loading CKEditor inside element with id 'content' which is not textarea.
Download this release

Release Info

Developer michal_cksource
Plugin Icon 128x128 CKEditor for WordPress
Version 3.6.2.4
Comparing to
See all releases

Code changes from version 3.6.2.3 to 3.6.2.4

Files changed (5) hide show
  1. ckeditor_class.php +1019 -968
  2. ckeditor_wordpress.php +34 -34
  3. includes/advanced.php +185 -186
  4. includes/ckeditor.utils.js +353 -325
  5. readme.txt +8 -3
ckeditor_class.php CHANGED
@@ -1,981 +1,1032 @@
1
  <?php
 
2
  class ckeditor_wordpress {
3
- var $version = '3.6.2.3';
4
- var $default_options = array();
5
- var $options = array();
6
- var $ckeditor_path = "";
7
- var $plugin_path ="";
8
- var $editable_files = array(); //array with files which can be edited
9
-
10
- function ckeditor_wordpress()
11
- {
12
- $this->__construct();
13
- }
14
-
15
- function __construct()
16
- {
17
- $siteurl = trailingslashit(get_option('siteurl'));
18
- if (DEFINED('WP_PLUGIN_URL'))
19
- {
20
- $this->plugin_path = WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)) .'/';
21
- }
22
- else if (DEFINED('WP_PLUGIN_DIR')){
23
- $this->plugin_path = $siteurl .'/'. WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__)) .'/';
24
- }
25
- else{
26
- $this->plugin_path = $siteurl .'wp-content/plugins/' . basename(dirname(__FILE__)) .'/';
27
- }
28
-
29
- define('CKEDITOR_PLUGIN_URL', $this->plugin_path);
30
- $this->ckeditor_path = $this->plugin_path .'ckeditor/';
31
- $this->editable_files = array(
32
- 'ckeditor.config.js' => dirname(__FILE__).'/ckeditor.config.js',
33
- 'ckeditor.styles.js' => dirname(__FILE__).'/ckeditor.styles.js',
34
- 'ckeditor.templates.js' => dirname(__FILE__).'/ckeditor.templates.js',
35
- );
36
- $this->default_options=array(
37
- 'appearance' => array(
38
- 'skin' => 'kama',
39
- 'uicolor' => 'default',
40
- 'uicolor_user' => '',
41
- /* basic post settings */
42
- 'default_state' => 't',
43
- 'post_toolbar' => 'WordpressFull',
44
- 'post_editor_height' => 300,
45
- /* basic comment settings */
46
- 'comment_editor' => 't',
47
- 'comment_toolbar' => 'WordpressBasic',
48
- 'comment_editor_height' => 120,
49
- ),
50
- 'upload' => array(
51
- 'browser' => 'disabled',
52
- 'type' => 'native',
53
- 'user_file_path' => 'wp-content/uploads/',
54
- 'files_allowed_ext' => '7z,aiff,asf,avi,bmp,csv,doc,fla,flv,gif,gz,gzip,jpeg,jpg,mid,mov,mp3,mp4,mpc,mpeg,mpg,ods,odt,pdf,png,ppt,pxd,qt,ram,rar,rm,rmi,rmvb,rtf,sdc,sitd,swf,sxc,sxw,tar,tgz,tif,tiff,txt,vsd,wav,wma,wmv,xls,zip',
55
- 'images_allowed_ext' => 'bmp,gif,jpeg,jpg,png',
56
- 'flash_allowed_ext' => 'swf,flv',
57
- ),
58
- 'ckfinder' => array(
59
- 'file_max_size' => '8M',
60
- 'images_width' => '1200',
61
- 'images_height' => '1600',
62
- 'images_quality' => '80',
63
- 'thumbnails_width' => '100',
64
- 'thumbnails_height' => '100',
65
- 'thumbnails_quality' => '80',
66
- 'thumbnails_enabled' => 't',
67
- 'thumbnails_direct_access' => 'f',
68
- 'license_name' => '',
69
- 'license_key' => '',
70
- ),
71
- 'css' => array(
72
- 'mode' => 'default',
73
- 'path' => '',
74
- 'styles' => 'default',
75
- 'style_path' => '',
76
- ),
77
- 'advanced' => array(
78
- 'load_method' => 'ckeditor.js',
79
- 'load_timeout' => 0,
80
- 'native_spell_checker' => 't',
81
- 'scayt_autoStartup' => 'f',
82
- 'entities' => 't',
83
- 'p_indent' => 't',
84
- 'p_break_before_open' => 't',
85
- 'p_break_after_open' => 'f',
86
- 'p_break_before_close' => 'f',
87
- 'p_break_after_close' => 't',
88
- ),
89
- 'plugins' => array(
90
- 'autogrow' => 'f',
91
- 'tableresize' => 'f',
92
- 'wpgallery' => 't'
93
- ),
94
- );
95
- $options = get_option('ckeditor_wordpress');
96
- if (!$options) {
97
- add_option('ckeditor_wordpress', $this->default_options);
98
- $options = $this->default_options;
99
- }
100
- $this->options = $options;
101
- if (!isset($this->options['advanced']['entities'])){
102
- $this->options['advanced']['entities'] = 't';
103
- }
104
- $path = str_replace(ABSPATH, '', trim($this->options['upload']['user_file_path']));
105
- $dir = ABSPATH . $path;
106
- if ( $dir == ABSPATH ) { //the option was empty
107
- $dir = ABSPATH . 'wp-content/uploads';
108
- }
109
- $dir = rtrim($dir, "/\\")."/";
110
- $this->user_files_absolute_path = $dir;
111
- $this->user_files_url = $siteurl . $path;
112
- $this->file_browser = $this->options['upload']['browser'];
113
- }
114
-
115
- function get_sorted_roles()
116
- {
117
- // This function returns all roles, sorted by user level (lowest to highest)
118
- global $wp_roles;
119
- $roles = $wp_roles->role_objects;
120
- $sorted = array();
121
-
122
- if (class_exists('RoleManager')) {
123
- foreach ($roles as $role_key => $role_name) {
124
- $role = get_role($role_key);
125
- if (empty($role))
126
- continue;
127
- $role_user_level = array_reduce(array_keys($role->capabilities), array('WP_User', 'level_reduction'), 0);
128
- $sorted[$role_user_level] = $role;
129
- }
130
- $sorted = array_values($sorted);
131
- }
132
- else {
133
- $role_order = array("subscriber", "contributor", "author", "editor", "administrator");
134
- foreach ($role_order as $role_key) {
135
- $sorted[$role_key] = get_role($role_key);
136
- }
137
- }
138
- return $sorted;
139
- }
140
-
141
- function get_role($capability)
142
- {
143
- // This function return the lowest roles which has the capabilities
144
- $check_order = $this->get_sorted_roles();
145
-
146
- $args = array_slice(func_get_args(), 1);
147
- $args = array_merge(array($capability), $args);
148
-
149
- foreach ($check_order as $check_role) {
150
- if (empty($check_role))
151
- return false;
152
-
153
- if (call_user_func_array(array(&$check_role, 'has_cap'), $args))
154
- return $check_role->name;
155
- }
156
- return false;
157
- }
158
-
159
- function set_capability($lowest_role, $capability)
160
- {
161
- // This function set or remove the $capability
162
- $check_order = $this->get_sorted_roles();
163
- $add_capability = false;
164
-
165
- foreach ($check_order as $the_role) {
166
- $role = $the_role->name;
167
-
168
- if ($lowest_role == $role)
169
- $add_capability = true;
170
-
171
- // If you rename the roles, then please use the role manager plugin
172
- if (empty($the_role))
173
- continue;
174
-
175
- $add_capability ? $the_role->add_cap($capability) : $the_role->remove_cap($capability) ;
176
- }
177
- }
178
-
179
- function can_upload()
180
- {
181
- global $userdata;
182
- $user_level = intval($userdata->user_level);
183
- if ((function_exists('current_user_can') && current_user_can('upload_files')) || (isset($user_level) && $user_level >= 3))
184
- {
185
- return true;
186
- }
187
- return false;
188
- }
189
-
190
- function checkbox($section, $var, $text, $onClick = '') {
191
- return '<label id="lbl_' . $var . '"><input type="checkbox" id="' . $var . '" name="options[' . $section . '][' . $var . ']"' .
192
- ($onClick != '' ? ' onClick="' . $onClick .'" ' : '') .
193
- ($this->options[$section][$var]=='t' ? "checked" : '') . '>&nbsp;' . __($text, 'ckeditor_wordpress') . "</label>\n";
194
- }
195
-
196
- function add_admin_head()
197
- {
198
- ?>
199
- <style type="text/css">
200
- .form-table td .cke_editor td { padding:0; }
201
- #icon-wp-ckeditor {background: transparent url(<?php echo $this->plugin_path;?>images/ckeditor_ico32.png) no-repeat;}
202
- </style>
203
- <?php
204
- }
205
-
206
- function user_personalopts_update()
207
- {
208
- global $current_user;
209
- update_user_option($current_user->id, 'rich_editing', 'false', true);
210
- }
211
-
212
- function print_admin_styles()
213
- {
214
- wp_enqueue_style( 'ckeditor_admin', $this->plugin_path.'includes/overview.css', false, $this->version, 'screen' );
215
- }
216
-
217
- function print_admin_upload_styles()
218
- {
219
- wp_enqueue_style( 'ckeditor_admin', $this->plugin_path.'includes/upload.css', false, $this->version, 'screen' );
220
- }
221
- function add_option_page()
222
- {
223
- add_menu_page(__('CKEditor Settings'), 'CKEditor', 'administrator', 'ckeditor_settings', array (&$this, 'plugin_overview'), $this->plugin_path.'images/menuicon.gif');
224
- //line below replace url title from CKEditor to Overview
225
- $overview_page = add_submenu_page('ckeditor_settings', __('CKEditor Overview'), __('Overview'), 'administrator', 'ckeditor_settings', array (&$this, 'plugin_overview'));
226
- add_action('admin_print_styles-'.$overview_page, array(&$this, 'print_admin_styles') );
227
-
228
- // TODO: include postbox/dashboard only on overview page
229
- if (isset($_GET['page']) && $_GET['page'] == 'ckeditor_settings') {
230
- wp_enqueue_script( 'postbox' );
231
- wp_admin_css( 'css/dashboard' );
232
- }
233
-
234
- $basic_page = add_submenu_page('ckeditor_settings', __('CKEditor Basic Settings'), __('Basic Settings'), 'administrator', 'ckeditor_basic_options', array (&$this, 'option_page'));
235
- add_action('admin_print_scripts-'.$basic_page, array(&$this, 'basic_settings_js'));
236
-
237
- add_submenu_page('ckeditor_settings', __('CKEditor Advanced Settings'), __('Advanced Settings'), 'administrator', 'ckeditor_advanced_options', array(&$this, 'advanced_options'));
238
- $upload_page = add_submenu_page('ckeditor_settings', __('CKEditor Upload Settings'), __('Upload Options'), 'administrator', 'ckeditor_upload_options', array(&$this, 'upload_options'));
239
- add_action('admin_print_styles-'.$upload_page, array(&$this, 'print_admin_upload_styles') );
240
-
241
- if (count($this->get_writable_files())>0){
242
- $file_editor_page = add_submenu_page('ckeditor_settings', __('CKEditor File Editor'), __('File Editor'), 'administrator', 'ckeditor_file_editor', array(&$this, 'file_editor'));
243
- add_action('admin_print_scripts-'.$file_editor_page, array(&$this, 'file_editor_js'));
244
- }
245
- }
246
-
247
- function ckeditor_get_version()
248
- {
249
- $jspath = dirname(__FILE__).'/ckeditor/ckeditor_basic.js';
250
- $contents = @file_get_contents($jspath);
251
- if ($contents) {
252
- $matches = array();
253
- if (preg_match('#,version:\'(.*?)\',#', $contents, $matches)) {
254
- return $matches[1];
255
- }
256
- }
257
- return __('N/A', 'ckeditor_wordpress');
258
- }
259
-
260
- function ckfinder_status()
261
- {
262
- $ckfinder_php = dirname(__FILE__).'/ckfinder/ckfinder.php';
263
- $nested_ckfinder_php = dirname(__FILE__).'/ckfinder/ckfinder/ckfinder.php';
264
- $config_path = dirname(__FILE__).'/ckfinder/config.php';
265
-
266
- if (!file_exists($ckfinder_php)) {
267
- if (file_exists($nested_ckfinder_php)) {
268
- return '<span class="ckeditor_error">'.__('CKFinder installed in wrong (nested) directory. Move files from ckeditor/ckfinder/ckfinder to ckeditor/ckfinder directory.', 'ckeditor_wordpress').'</span>';
269
- }
270
- else {
271
- return __('Not installed', 'ckeditor_wordpress');
272
- }
273
- }
274
- else {
275
- $contents = @file_get_contents($config_path);
276
- if (!$contents) {
277
- return '<span class="ckeditor_error">'.__('CKFinder is installed, configuration file not readable or empty.', 'ckeditor_wordpress').'</span>';
278
- }
279
- if (strpos($contents, 'wp-config.php') === false) {
280
- return '<span class="ckeditor_error">'.__('CKFinder is installed, but invalid config.php was detected. Rename ckfinder_config.php to config.php (overwriting the default config.php file distributed with CKFinder).', 'ckeditor_wordpress').'</span>';
281
- }
282
- if ($this->options['upload']['browser'] != 'ckfinder') {
283
- return '<span class="ckeditor_ok">'.__('CKFinder is installed, not enabled.', 'ckeditor_wordpress').'</span>';
284
- }
285
- return '<span class="ckeditor_ok">'.__('CKFinder is installed', 'ckeditor_wordpress').'</span>';
286
- }
287
- }
288
-
289
- function plugin_overview()
290
- {
291
- global $ckeditor_version, $ckeditor_plugin_version, $ckfinder_status;
292
- $ckeditor_version = $this->ckeditor_get_version();
293
- $ckeditor_plugin_version = $this->version;
294
- $ckfinder_status = $this->ckfinder_status();
295
- if(isset($_POST['reset']) && $_POST['reset']==1){
296
- if (! wp_verify_nonce($_POST['csrf_ckeditor-for-wordpress'], 'ckeditor_create_nonce_overview') || empty($_POST['_wp_http_referer']) || ( isset($_SERVER['HTTP_REFERER']) && !strstr( $_SERVER['HTTP_REFERER'], $_POST['_wp_http_referer']) ) ) wp_die("You do not have sufficient permissions to access this page.");
297
- update_option('ckeditor_wordpress', $this->default_options);
298
- $this->options = $this->default_options;
299
- echo '<div class="updated"><p>' . __('Configuration updated!') . '</p></div>';
300
- }
301
- include('includes/overview.php');
302
- }
303
-
304
- function option_page()
305
- {
306
-
307
- if (!empty($_POST['submit_update'])) {
308
- $message=array();
309
- /* validation */
310
- if (! wp_verify_nonce($_POST['csrf_ckeditor-for-wordpress'], 'ckeditor_create_nonce_basic') || empty($_POST['_wp_http_referer']) || ( isset($_SERVER['HTTP_REFERER']) && !strstr( $_SERVER['HTTP_REFERER'], $_POST['_wp_http_referer']) ) ) wp_die("You do not have sufficient permissions to access this page.");
311
- $new_options=$_POST['options'];
312
- $new_options['appearance']['comment_editor']=(isset($_POST['options']['appearance']['comment_editor'])?'t':'f');
313
-
314
- $this->options = $this->update_options($new_options, (empty($message)?false:true));
315
- }
316
- include('includes/basic.php');
317
- }
318
-
319
- function upload_options()
320
- {
321
- if (!empty($_POST['submit_update'])) {
322
- if (! wp_verify_nonce($_POST['csrf_ckeditor-for-wordpress'], 'ckeditor_create_nonce_upload') || empty($_POST['_wp_http_referer']) || ( isset($_SERVER['HTTP_REFERER']) && !strstr( $_SERVER['HTTP_REFERER'], $_POST['_wp_http_referer']) ) ) wp_die("You do not have sufficient permissions to access this page.");
323
- $new_options=$_POST['options'];
324
- foreach (array('access', 'fileView', 'fileDelete', 'fileRename', 'fileUpload', 'folderView', 'folderDelete', 'folderCreate', 'folderRename') as $command) {
325
- $this->set_capability($new_options['ckfinder']['permissions'][$command], "ckeditor_ckfinder_".$command);
326
- }
327
- $new_options['ckfinder']['thumbnails_direct_access'] = (isset($new_options['ckfinder']['thumbnails_direct_access'])?'t':'f');
328
- $new_options['ckfinder']['thumbnails_enabled'] = (isset($new_options['ckfinder']['thumbnails_enabled'])?'t':'f');
329
-
330
- /* validation */
331
- $message=array();
332
-
333
- if($new_options['upload']['browser'] != 'disabled'){
334
- $new_options['upload']['files_allowed_ext'] = str_replace(' ','',$new_options['upload']['files_allowed_ext']);
335
- $new_options['upload']['images_allowed_ext'] = str_replace(' ','',$new_options['upload']['images_allowed_ext']);
336
- $new_options['upload']['flash_allowed_ext'] = str_replace(' ','',$new_options['upload']['flash_allowed_ext']);
337
-
338
- $inputs=array('files_allowed_ext', 'images_allowed_ext', 'flash_allowed_ext');
339
- foreach ($inputs as $input) {
340
- if(empty($new_options['upload'][$input])){
341
- $message['upload_' . $input] = __('This field shouldn\'t be empty', 'ckeditor_wordpress');
342
- } elseif (!preg_match('#^([a-z0-9]+){1}(,[a-z0-9]+)*,?$#Uis', trim($new_options['upload'][$input]))) {
343
- $message['upload_' . $input] = __('Files extensions has wrong chars.','ckeditor_wordpress');
344
- }
345
- }
346
-
347
- if ($new_options['upload']['browser'] == 'ckfinder') {
348
- $checkCKFinder = $this->ckfinder_status();
349
- if (!strpos($checkCKFinder, "ckeditor_ok")){
350
- $message['upload_browser'] = $checkCKFinder;
351
- }
352
- if(empty($new_options['ckfinder']['file_max_size'])){
353
- $message['ckfinder_file_max_size'] = __('This field is required.', 'ckeditor_wordpress');
354
- }elseif (!preg_match('/^\d+[MKG]?$/i', trim($new_options['ckfinder']['file_max_size']))) {
355
- $message['ckfinder_file_max_size'] = __('Enter valid value. Example: 400 or 10M', 'ckeditor_wordpress');
356
- }
357
- $inputs=array('images_width', 'images_height', 'thumbnails_width', 'thumbnails_height');
358
- foreach ($inputs as $input) {
359
- if(empty($new_options['ckfinder'][$input])){
360
- $message['ckfinder_' . $input] = __('This field is required.', 'ckeditor_wordpress');
361
- } elseif(!preg_match('#^\d+$#',trim($new_options['ckfinder'][$input]))) {
362
- $message['ckfinder_' . $input] = __('Enter valid value. Example: 400', 'ckeditor_wordpress');
363
- }
364
- }
365
- if(empty($new_options['ckfinder']['thumbnails_quality'])) {
366
- $message['ckfinder_thumbnails_quality'] = __('This field is required.', 'ckeditor_wordpress');
367
- }elseif(!(preg_match('#^[0-9]{1,2}$#', trim($new_options['ckfinder']['thumbnails_quality'])) || trim($new_options['ckfinder']['thumbnails_quality']) == '100')){
368
- $message['ckfinder_thumbnails_quality'] = __('Value should be betwen 1 and 100.', 'ckeditor_wordpress');
369
- }
370
- if(empty($new_options['ckfinder']['images_quality'])) {
371
- $message['ckfinder_images_quality'] = __('This field is required.', 'ckeditor_wordpress');
372
- }elseif(!(preg_match('#^[0-9]{1,2}$#', trim($new_options['ckfinder']['images_quality'])) || trim($new_options['ckfinder']['images_quality']) == '100')){
373
- $message['ckfinder_images_quality'] = __('Value should be betwen 1 and 100.', 'ckeditor_wordpress');
374
- }
375
- }
376
- }
377
-
378
- unset($new_options['ckfinder']['permissions']);
379
-
380
- $this->options = $this->update_options($new_options, (empty($message)?false:true));
381
- }
382
- include('includes/upload.php');
383
- }
384
-
385
- function advanced_options() {
386
- if (!empty($_POST['submit_update'])) {
387
- if (! wp_verify_nonce($_POST['csrf_ckeditor-for-wordpress'], 'ckeditor_create_nonce_advanced') || empty($_POST['_wp_http_referer']) || ( isset($_SERVER['HTTP_REFERER']) && !strstr( $_SERVER['HTTP_REFERER'], $_POST['_wp_http_referer']) ) ) wp_die("You do not have sufficient permissions to access this page.");
388
- $new_options=$_POST['options'];
389
- $new_options['advanced']['native_spell_checker'] = (isset($_POST['options']['advanced']['native_spell_checker'])?'t':'f');
390
- $new_options['advanced']['scayt_autoStartup'] = (isset($_POST['options']['advanced']['scayt_autoStartup'])?'t':'f');
391
- $new_options['advanced']['p_indent'] = (isset($_POST['options']['advanced']['p_indent'])?'t':'f');
392
- $new_options['advanced']['p_break_before_open'] = (isset($_POST['options']['advanced']['p_break_before_open'])?'t':'f');
393
- $new_options['advanced']['p_break_after_open'] = (isset($_POST['options']['advanced']['p_break_after_open'])?'t':'f');
394
- $new_options['advanced']['p_break_before_close'] = (isset($_POST['options']['advanced']['p_break_before_close'])?'t':'f');
395
- $new_options['advanced']['p_break_after_close'] = (isset($_POST['options']['advanced']['p_break_after_close'])?'t':'f');
396
- $new_options['advanced']['entities'] = (isset($_POST['options']['advanced']['entities'])?'t':'f');
397
- foreach ($this->options['plugins'] as $key => $val){
398
- if (isset($_POST['options']['plugins'][$key])){
399
- $new_options['plugins'][$key] = 't';
400
- unset($_POST['options']['plugins'][$key]);
401
- }
402
- else {
403
- $new_options['plugins'][$key] = 'f';
404
- }
405
- }
406
- foreach ((array) $_POST['options']['plugins'] as $key => $val){
407
- $new_options['plugins'][$key] = 't';
408
- }
409
- $new_options['plugins']['wpgallery'] = 't';
410
-
411
- /* validation */
412
- $massage = array();
413
-
414
- /** css mode and path validation **/
415
- if (!empty($new_options['css']['path'])) {
416
- if ($new_options['css']['mode'] != 'self') {
417
- $message['css_path'] = __('CSS path is not empty. Please set the "Editor CSS" option to "define css" mode.', 'ckeditor_wordpress');
418
- }
419
- elseif (FALSE !== strpos($new_options['css']['path'], '"')) {
420
- $massage['css_path'] = __('Double quotes are not allowed in CSS path.', 'ckeditor_wordpress');
421
- }
422
- elseif (substr($new_options['css']['path'], 0, 1) == "'" && substr($new_options['css']['path'], -1) == "'") {
423
- $massage['css_path'] = __('Enter valid path, do not surround it with quotes.', 'ckeditor_wordpress');
424
- }
425
- }
426
- /** styles **/
427
- if (!empty($new_options['css']['style_path'])) {
428
- if ($new_options['css']['styles'] != 'self') {
429
- $message['css_style_path'] = __('Path to predefined styles is not empty. Please set the "Predefined styles" option to "define path to ckeditor.styles.js" mode.', 'ckeditor_wordpress');
430
- }
431
- elseif (FALSE !== strpos($new_options['css']['styles_path'], '"')) {
432
- $message['css_style_path'] = __('Double quotes are not allowed in path.', 'ckeditor_wordpress');
433
- }
434
- elseif (substr($new_options['css']['style_path'], 0, 1) == "'" && substr($new_options['css']['style_path'], -1) == "'") {
435
- $message['css_style_path'] = __('Enter valid path, do not surround it with quotes.', 'ckeditor_wordpress');
436
- }
437
- }
438
- /** load timeout **/
439
- if (!preg_match('#^\d+$#', trim($new_options['advanced']['load_timeout']))) {
440
- $massage['advanced_load_timeout'] = __('Enter valid load timeout in seconds.', 'ckeditor_wordpress');
441
- }
442
-
443
- /* language settings */
444
- if (!preg_match('#^\d\d$#', trim($new_options['advanced']['language'])) && !preg_match('#^\d\d-\d\d$#', trim($new_options['advanced']['language']))) {
445
- $massage['advanced_language'] = __('Enter a valid language.', 'ckeditor_wordpress');
446
- }
447
-
448
- if ( trim($new_options['advanced']['detect_language_auto']) != 't' && trim($new_options['advanced']['detect_language_auto'] != 'f') ) {
449
- $massage['advanced_detect_language_auto'] = __('Enter a valid auto detect language value.', 'ckeditor_wordpress');
450
- }
451
-
452
- if ( trim($new_options['advanced']['language_direction']) != 'default' && trim($new_options['advanced']['language_direction']) != 'ltr' && trim($new_options['advanced']['language_direction']) != 'rtl') {
453
- $massage['advanced_language_direction'] = __('Enter a valid language direction value.', 'ckeditor_wordpress');
454
- }
455
-
456
- $this->options = $this->update_options($new_options, (empty($message)?false:true));
457
- }
458
- include('includes/advanced.php');
459
- }
460
-
461
- function basic_settings_js()
462
- {
463
- wp_enqueue_script('ckeditor', $this->ckeditor_path . 'ckeditor.js');
464
- wp_enqueue_script('ckeditor_admin', $this->plugin_path . 'includes/basic.js');
465
- }
466
-
467
- function file_editor_js()
468
- {
469
- /* codepress */
470
- //add_action('admin_print_footer_scripts', 'codepress_footer_js');
471
- //wp_enqueue_script('codepress');
472
- }
473
-
474
- function is_plugin_active( $plugin_name )
475
- {
476
- $options = get_option('active_plugins');
477
- foreach ( $options AS $option ){
478
- if ( strpos( $option, $plugin_name ) !== FALSE ){
479
- return true;
480
- }
481
- }
482
-
483
- return false;
484
-
485
- }
486
-
487
- function remove_tinymce(){
488
- if (has_action('admin_print_footer_scripts','wp_tiny_mce')){
489
- remove_action('admin_print_footer_scripts','wp_tiny_mce', 25);
490
- }
491
- }
492
-
493
- function add_post_js()
494
- {
495
- if (has_filter('admin_print_footer_scripts','wp_tiny_mce') || has_filter('before_wp_tiny_mce', 'wp_print_editor_js') || has_filter('after_wp_tiny_mce', 'wp_preload_dialogs')) {
496
- if (!user_can_richedit()){
497
- wp_enqueue_script('quicktags');
498
- //echo '<script type="text/javascript">jQuery(document).ready(function () { jQuery(\'#quicktags\').show(); });</script>';
499
- return;
500
- }
501
- wp_enqueue_script('editor');
502
- wp_enqueue_script('ckeditor', $this->ckeditor_path . $this->options['advanced']['load_method']);
503
- wp_enqueue_script('ckeditor.utils', $this->plugin_path . 'includes/ckeditor.utils.js', array('ckeditor', 'jquery'));
504
-
505
- remove_filter('admin_print_footer_scripts','wp_tiny_mce',25);
506
- remove_filter('before_wp_tiny_mce', 'wp_print_editor_js');
507
- remove_filter('after_wp_tiny_mce', 'wp_preload_dialogs');
508
- $this->generate_js_options(false);
509
- }
510
- }
511
 
512
- function add_comment_js()
513
- {
514
- if (!(is_page() || is_single())) { return; }
515
-
516
- if ($this->options['appearance']['comment_editor'] != 't') { return; }
517
-
518
- wp_enqueue_script('ckeditor', $this->ckeditor_path . $this->options['advanced']['load_method']);
519
- wp_enqueue_script('ckeditor.utils', $this->plugin_path . 'includes/ckeditor.utils.js', array('ckeditor', 'jquery'));
520
- wp_deregister_script('comment-reply');
521
- wp_register_script('comment-reply', $this->plugin_path . 'includes/ckeditor.comment-reply.js', array('ckeditor','ckeditor.utils'), "20100901");
522
- $this->generate_js_options(true);
523
- $this->add_wpcompat_styles();
524
- }
525
-
526
- function add_wpcompat_styles()
527
- {
528
- ?>
529
- <style type="text/css">
530
- #content table.cke_editor { margin:0; }
531
- #content table.cke_editor tr td { padding:0;border:0; }
532
- </style>
533
- <?php
534
- }
535
-
536
- function update_options($new_options, $error){
537
- $options=$this->options;
538
- foreach($new_options as $k => $v){
539
- if (isset($this->options[$k])) {
540
- $options[$k] = array_merge($this->options[$k], $v);
541
- }
542
- else {
543
- $options[$k] = $v;
544
- }
545
- }
546
- if (!$error) {
547
- update_option("ckeditor_wordpress", $options);
548
- echo '<div class="updated"><p>' . __('Configuration updated!') . '</p></div>';
549
- }
550
- return $options;
551
- }
552
-
553
- function get_writable_files(){
554
- $out=array();
555
- foreach($this->editable_files as $file => $path){
556
- if(file_exists($path) && is_writable($path)){
557
- $out[$file]=$path;
558
- }
559
- }
560
- return $out;
561
- }
562
-
563
- function file_editor(){
564
- $files=$this->get_writable_files();
565
- if(isset($_POST['file']) && !isset($files[$_POST['file']])) {
566
- echo '<div class="error"><p>' . __('Invalid file!') . '</p></div>';
567
- return;
568
- }
569
- if(isset($_POST['file'])) {
570
- $file=$_POST['file'];
571
- }
572
- else {
573
- $keys=array_keys($files);
574
- $file=$keys[0];
575
- unset($keys);
576
- }
577
- if(isset($_POST['newcontent'])){
578
- if (! wp_verify_nonce($_POST['csrf_ckeditor-for-wordpress'], 'ckeditor_create_nonce_file_editor') || empty($_POST['_wp_http_referer']) || ( isset($_SERVER['HTTP_REFERER']) && !strstr( $_SERVER['HTTP_REFERER'], $_POST['_wp_http_referer']) ) ) wp_die("You do not have sufficient permissions to access this page.");
579
- $fp=fopen($files[$file], 'w');
580
- $content = stripslashes($_POST['newcontent']);
581
- fwrite($fp, stripslashes($_POST['newcontent']));
582
- echo '<div class="updated"><p>' . __('Configuration updated!') . '</p></div>';
583
- } else {
584
- $fp=fopen($files[$file], 'r');
585
- $content = fread($fp, filesize($files[$file]));
586
- }
587
- fclose($fp);
588
- include('includes/file_editor.php');
589
- }
590
-
591
- function generate_js_options($is_comment){
592
-
593
- $options=$this->options;
594
- $settings=array();
595
- if ($options['upload']['browser'] == 'builtin') {
596
- $ck_browser_url = $this->plugin_path .'filemanager/browser/default/browser.html?Connector=../../connectors/php/connector.php';
597
- $ck_upload_url = $this->plugin_path .'filemanager/connectors/php/upload.php';
598
- $settings['filebrowserBrowseUrl'] = $ck_browser_url;
599
- $settings['filebrowserImageBrowseUrl'] = $ck_browser_url . '&type=Images';
600
- $settings['filebrowserFlashBrowseUrl'] = $ck_browser_url . '&type=Flash';
601
- $settings['filebrowserUploadUrl'] = $ck_upload_url;
602
- $settings['filebrowserImageUploadUrl'] = $ck_upload_url . '?type=Images';
603
- $settings['filebrowserFlashUploadUrl'] = $ck_upload_url . '?type=Flash';
604
- }
605
- else if ($options['upload']['browser'] == 'ckfinder') {
606
- $ck_browser_url = $this->plugin_path .'ckfinder/ckfinder.html';
607
- $ck_upload_url = $this->plugin_path .'ckfinder/core/connector/php/connector.php?command=QuickUpload';
608
- $settings['filebrowserBrowseUrl'] = $ck_browser_url;
609
- $settings['filebrowserImageBrowseUrl'] = $ck_browser_url . '?type=Images';
610
- $settings['filebrowserFlashBrowseUrl'] = $ck_browser_url . '?type=Flash';
611
- $settings['filebrowserUploadUrl'] = $ck_upload_url . '&type=Files';
612
- $settings['filebrowserImageUploadUrl'] = $ck_upload_url . '&type=Images';
613
- $settings['filebrowserFlashUploadUrl'] = $ck_upload_url . '&type=Flash';
614
- }
615
-
616
- if ($options['appearance']['uicolor'] == 'custom' && !empty($options['appearance']['uicolor_user'])) {
617
- $settings['uiColor'] = $options['appearance']['uicolor_user'];
618
- }
619
- $settings['height']=($is_comment ? $options['appearance']['comment_editor_height'] : $options['appearance']['post_editor_height']).'px';
620
- $settings['skin']=$options['appearance']['skin'];
621
- $settings['scayt_autoStartup']=$options['advanced']['scayt_autoStartup'] == 't' ? true : false;
622
- $settings['entities']=$options['advanced']['entities'] == 't' ? true : false;
623
- $settings['entities_greek']=$settings['entities'];
624
- $settings['entities_latin']=$settings['entities'];
625
- $settings['toolbar']=($is_comment ? $options['appearance']['comment_toolbar'] : $options['appearance']['post_toolbar']);
626
- $settings['templates_files'][] = $this->plugin_path.'ckeditor.templates.js';
627
- $output=array(
628
- 'textarea_id' => ($is_comment ? 'comment' : 'content'),
629
- 'pluginPath' => $this->plugin_path,
630
- 'autostart' => ($options['appearance']['default_state']=='t' || $is_comment ?true:false),
631
- 'qtransEnabled' => ($this->is_plugin_active( "qtrans" ) ? true : false),
632
- 'outputFormat' => array(
633
- 'indent' => ($options['advanced']['p_indent']=='t' ? true : false),
634
- 'breakBeforeOpen' => ($options['advanced']['p_break_before_open']=='t' ? true : false),
635
- 'breakAfterOpen' => ($options['advanced']['p_break_after_open']=='t' ? true : false),
636
- 'breakBeforeClose' => ($options['advanced']['p_break_before_close']=='t' ? true : false),
637
- 'breakAfterClose' => ($options['advanced']['p_break_after_close']=='t' ? true : false),
638
- ),
639
- 'configuration' => array(),
640
- );
641
- /** css mode **/
642
- switch($options['css']['mode']){
643
- case 'theme':
644
- $settings['contentsCss'][] = get_stylesheet_uri();
645
- //fix for default Wordpress theme
646
- if (preg_match('/twenty[\S]+/', get_stylesheet_uri()))
647
- {
648
- $settings['extraCss'] = 'body {background:#FFF; padding: 0 0.5em; }';
649
- }
650
- break;
651
- case 'self':
652
- foreach(explode(',',$options['css']['path']) as $css_path){
653
- $css_path = trim(str_replace("%h%t", "%t", $css_path));
654
- $settings['contentsCss'][] = str_replace(array('%h', '%t'), array($_SERVER['HTTP_HOST'], get_template_directory_uri()), $css_path);
655
- }
656
- break;
657
- }
658
- /** predefined style $options['css']['styles'] != 'default' || **/
659
- switch($options['css']['styles']){
660
- case 'theme':
661
- $settings['stylesCombo_stylesSet'] = 'wordpress:'.get_template_directory_uri().'/ckeditor.styles.js';
662
- break;
663
- case 'self':
664
- $options['css']['style_path'] = trim(str_replace("%h%t", "%t", $options['css']['style_path']));
665
- $settings['stylesCombo_stylesSet'] = 'wordpress:'.str_replace(array('%h', '%t'), array($_SERVER['HTTP_HOST'], get_template_directory_uri()), $options['css']['style_path']);
666
- break;
667
- default:
668
- $settings['stylesCombo_stylesSet'] = 'wordpress:'.$this->plugin_path.'ckeditor.styles.js';
669
- break;
670
- }
671
-
672
- if ($options['advanced']['detect_language_auto'] == 'f')
673
- {
674
- $settings['language'] = $options['advanced']['language'];
675
- }
676
-
677
- if (isset($options['advanced']['language_direction'])) {
678
- switch ($options['advanced']['language_direction']) {
679
- case 'default':
680
- if (is_rtl()) {
681
- $settings['contentsLangDirection'] = 'rtl';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
682
  }
683
  break;
684
- case 'ltr':
685
- $settings['contentsLangDirection'] = 'ltr';
 
 
 
686
  break;
687
- case 'rtl':
688
- $settings['contentsLangDirection'] = 'rtl';
 
 
 
689
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
690
  }
691
  }
692
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
693
 
694
- $output['configuration']=$settings;
695
- $output['configuration']['customConfig'] = $this->plugin_path . 'ckeditor.config.js';
696
- if(!$is_comment){
697
- $output['externalPlugins'] = apply_filters('ckeditor_external_plugins', array());
698
- $output['additionalButtons'] = apply_filters('ckeditor_buttons', array());
699
- foreach ((array) $options['plugins'] as $name => $val ){
700
- if ($val == 't' && !isset($output['externalPlugins'][$name])){
701
- $output['externalPlugins'][$name] = $this->plugin_path.'ckeditor/plugins/'.$name.'/';
702
- }
703
- else if ($val == 'f' && isset($output['externalPlugins'][$name])){
704
- unset($output['externalPlugins'][$name]);
705
- }
706
- }
707
- } else {
708
- $output['externalPlugins'] = array();
709
- $output['additionalButtons'] = array();
710
- }
711
- echo "<script type='text/javascript'>\n/* <![CDATA[ */\nwindow.CKEDITOR_BASEPATH = \"". $this->ckeditor_path ."\";\nvar ckeditorSettings = " . $this->jsEncode($output) . "\n/* ]]> */\n</script>";
712
- }
713
-
714
- /**
715
- * This little function provides a basic JSON support.
716
- * http://php.net/manual/en/function.json-encode.php
717
- * \private
718
- *
719
- * @param mixed $val
720
- * @return string
721
- */
722
- function jsEncode($val)
723
- {
724
- if (is_null($val)) {
725
- return 'null';
726
- }
727
- if ($val === false) {
728
- return 'false';
729
- }
730
- if ($val === true) {
731
- return 'true';
732
- }
733
- if (is_scalar($val))
734
- {
735
- if (is_float($val))
736
- {
737
- // Always use "." for floats.
738
- $val = str_replace(",", ".", strval($val));
739
- }
740
-
741
- // Use @@ to not use quotes when outputting string value
742
- if (strpos($val, '@@') === 0) {
743
- return substr($val, 2);
744
- }
745
- else {
746
- // All scalars are converted to strings to avoid indeterminism.
747
- // PHP's "1" and 1 are equal for all PHP operators, but
748
- // JS's "1" and 1 are not. So if we pass "1" or 1 from the PHP backend,
749
- // we should get the same result in the JS frontend (string).
750
- // Character replacements for JSON.
751
- static $jsonReplaces = array(array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"'),
752
- array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'));
753
-
754
- $val = str_replace($jsonReplaces[0], $jsonReplaces[1], $val);
755
-
756
- return '"' . $val . '"';
757
- }
758
- }
759
- $isList = true;
760
- for ($i = 0, reset($val); $i < count($val); $i++, next($val))
761
- {
762
- if (key($val) !== $i)
763
- {
764
- $isList = false;
765
- break;
766
- }
767
- }
768
- $result = array();
769
- if ($isList)
770
- {
771
- foreach ($val as $v) $result[] = $this->jsEncode($v);
772
- return '[ ' . join(', ', $result) . ' ]';
773
- }
774
- else
775
- {
776
- foreach ($val as $k => $v) $result[] = $this->jsEncode($k).': '.$this->jsEncode($v);
777
- return '{ ' . join(', ', $result) . ' }';
778
- }
779
- }
780
-
781
- function ckeditor_wpmore_plugin($plugins) {
782
- $plugins['wpmore']=$this->plugin_path.'plugins/wpmore/';
783
- return $plugins;
784
- }
785
-
786
- function ckeditor_wpmore_button($buttons) {
787
- $buttons[]=array('WPMore');
788
- return $buttons;
789
- }
790
-
791
- function ckeditor_wpgallery_plugin($plugins) {
792
- $plugins['wpgallery']=$this->plugin_path.'plugins/wpgallery/';
793
- return $plugins;
794
- }
795
-
796
- //filter to change data for wpeditimage plugin before insert/update in database
797
- function ckeditor_insert_post_data_filter( $data , $postarr = null )
798
- {
799
- $content = $data['post_content'];
800
- //change amp; to empty character . This is to create & character before entities like gt; and lt;
801
- //$content = str_replace('amp;' , '', $content);
802
- $content = stripslashes($content);
803
- //change " character in caption string for &quot;
804
- //change amp; to empty character . This is to create & character before entities like gt; and lt; in caption string
805
- $pattern = '/caption="(.+)"\]/';
806
- preg_match_all($pattern, $content,$matches);
807
- if (isset($matches[1]))
808
- {
809
-
810
- $content = str_replace($matches[1], str_replace('amp;', '', $matches[1]), $content);
811
- $content = str_replace($matches[1], str_replace('"', '&quot;', $matches[1]), $content);
812
-
813
- }
814
- //save data
815
- $content = addslashes($content);
816
- $data['post_content'] = $content;
817
- return $data;
818
- }
819
-
820
- function ckeditor_externalvvq_plugin($plugins) {
821
- if (class_exists('VipersVideoQuicktags')) {
822
- $plugins['vvq']=$this->plugin_path.'plugins/vvq/';
823
- }
824
- return $plugins;
825
- }
826
-
827
- function ckeditor_vvqbuttons($buttons) {
828
- if (class_exists('VipersVideoQuicktags')) {
829
- $vvqsettings = (array) get_option('vvq_options');
830
- $vvqbuttons = array(
831
- 'youtube' => 'VVQYoutube',
832
- 'googlevideo' => 'VVQGoogleVideo',
833
- 'dailymotion' => 'VVQDailyMotion',
834
- 'vimeo' => 'VVQVimeo',
835
- 'veoh' => 'VVQVeoh',
836
- 'viddler' => 'VVQViddler',
837
- 'metacafe' => 'VVQMetacafe',
838
- 'bliptv' => 'VVQBlipTV',
839
- 'flickrvideo' => 'VVQFlickrVideo',
840
- 'spike' => 'VVQSpike',
841
- 'myspace' => 'VVQMySpace',
842
- 'flv' => 'VVQFLV',
843
- 'quicktime' => 'VVQQuicktime',
844
- 'videofile' => 'VVQVideoFile'
845
- );
846
- $vvqtoolbar = array();
847
- foreach ($vvqsettings as $name => $val){
848
- if (isset($val["button"]) && $val["button"] == 1 && isset($vvqbuttons[$name])){
849
- $vvqtoolbar[] = $vvqbuttons[$name];
850
- }
851
- }
852
- $buttons[]=$vvqtoolbar;
853
- }
854
- return $buttons;
855
- }
856
-
857
- function wppoll_external($plugins) {
858
- if (function_exists('poll_menu')) {
859
- $plugins['wppolls']=$this->plugin_path.'plugins/wppolls/';
860
- }
861
- return $plugins;
862
- }
863
-
864
- function wppoll_buttons($buttons) {
865
- if (function_exists('poll_menu')) {
866
- $buttons[]=array('WPPolls');
867
- }
868
- return $buttons;
869
- }
870
-
871
- function starrating_external_plugin($plugins) {
872
- if (defined('STARRATING_PATH')) {
873
- $plugins['starrating'] = $this->plugin_path . 'plugins/gd-star-rating/';
874
- }
875
- return $plugins;
876
- }
877
-
878
- function starrating_buttons($buttons) {
879
- if (defined('STARRATING_PATH')) {
880
- $buttons[]=array('StarRating');
881
- }
882
- return $buttons;
883
- }
884
- /**
885
- * List of installed CKEditor languages
886
- *
887
- * @return array
888
- */
889
- function ckeditor_load_lang_options() {
890
- $arr = array();
891
-
892
- if (DEFINED('WP_PLUGIN_DIR'))
893
- {
894
- $lang_file = WP_PLUGIN_DIR .'/'. basename(dirname(__FILE__)) .'/ckeditor/lang/_languages.js';
895
- }
896
- else{
897
- $lang_file = '../wp-content/plugins/ckeditor-for-wordpress/ckeditor/lang/_languages.js';
898
- }
899
- if (file_exists($lang_file))
900
- {
901
- $f = fopen($lang_file, 'r');
902
- $file = fread($f, filesize($lang_file));
903
- $tmp = explode('{', $file);
904
- if (isset($tmp[2]))
905
- {
906
- $tmp = explode('}', $tmp[2]);
907
- }
908
- $langs = explode(',', $tmp[0]);
909
- foreach ($langs AS $key => $lang)
910
- {
911
- preg_match("/(\w+-?\w+):'(\w+)'/i",$lang, $matches);
912
- if (isset($matches[1]) && isset($matches[2]))
913
- $arr[$matches[1]] = $matches[2];
914
- }
915
- }
916
-
917
- //oops, we have no information about languages, let's use those available in CKEditor 2.4.3
918
- if (empty($arr)) {
919
- $arr = array(
920
- 'af' => 'Afrikaans',
921
- 'ar' => 'Arabic',
922
- 'bg' => 'Bulgarian',
923
- 'bn' => 'Bengali/Bangla',
924
- 'bs' => 'Bosnian',
925
- 'ca' => 'Catalan',
926
- 'cs' => 'Czech',
927
- 'da' => 'Danish',
928
- 'de' => 'German',
929
- 'el' => 'Greek',
930
- 'en' => 'English',
931
- 'en-au' => 'English (Australia)',
932
- 'en-ca' => 'English (Canadian)',
933
- 'en-uk' => 'English (United Kingdom)',
934
- 'eo' => 'Esperanto',
935
- 'es' => 'Spanish',
936
- 'et' => 'Estonian',
937
- 'eu' => 'Basque',
938
- 'fa' => 'Persian',
939
- 'fi' => 'Finnish',
940
- 'fo' => 'Faroese',
941
- 'fr' => 'French',
942
- 'gl' => 'Galician',
943
- 'he' => 'Hebrew',
944
- 'hi' => 'Hindi',
945
- 'hr' => 'Croatian',
946
- 'hu' => 'Hungarian',
947
- 'it' => 'Italian',
948
- 'ja' => 'Japanese',
949
- 'km' => 'Khmer',
950
- 'ko' => 'Korean',
951
- 'lt' => 'Lithuanian',
952
- 'lv' => 'Latvian',
953
- 'mn' => 'Mongolian',
954
- 'ms' => 'Malay',
955
- 'nb' => 'Norwegian Bokmal',
956
- 'nl' => 'Dutch',
957
- 'no' => 'Norwegian',
958
- 'pl' => 'Polish',
959
- 'pt' => 'Portuguese (Portugal)',
960
- 'pt-br' => 'Portuguese (Brazil)',
961
- 'ro' => 'Romanian',
962
- 'ru' => 'Russian',
963
- 'sk' => 'Slovak',
964
- 'sl' => 'Slovenian',
965
- 'sr' => 'Serbian (Cyrillic)',
966
- 'sr-latn' => 'Serbian (Latin)',
967
- 'sv' => 'Swedish',
968
- 'th' => 'Thai',
969
- 'tr' => 'Turkish',
970
- 'uk' => 'Ukrainian',
971
- 'vi' => 'Vietnamese',
972
- 'zh' => 'Chinese Traditional',
973
- 'zh-cn' => 'Chinese Simplified',
974
- );
975
- }
976
- asort($arr);
977
- return $arr;
978
- }
979
  }
980
- $ckeditor_wordpress = new ckeditor_wordpress();
 
981
  ?>
1
  <?php
2
+
3
  class ckeditor_wordpress {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
+ private static $instance;
6
+ public static $version = '3.6.2.4';
7
+ public static $default_options = array();
8
+ public $options = array();
9
+ public static $ckeditor_path = "";
10
+ public static $plugin_path = "";
11
+ public $editable_files = array(); //array with files which can be edited
12
+
13
+ public static function getInstance() {
14
+ if (!isset(self::$instance)) {
15
+ $class = __CLASS__;
16
+ self::$instance = new $class();
17
+ }
18
+ return self::$instance;
19
+ }
20
+
21
+ public function __construct() {
22
+ $siteurl = trailingslashit(get_option('siteurl'));
23
+ if (DEFINED('WP_PLUGIN_URL')) {
24
+ $this->plugin_path = WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)) . '/';
25
+ } else if (DEFINED('WP_PLUGIN_DIR')) {
26
+ $this->plugin_path = $siteurl . '/' . WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__)) . '/';
27
+ } else {
28
+ $this->plugin_path = $siteurl . 'wp-content/plugins/' . basename(dirname(__FILE__)) . '/';
29
+ }
30
+
31
+ define('CKEDITOR_PLUGIN_URL', $this->plugin_path);
32
+ $this->ckeditor_path = $this->plugin_path . 'ckeditor/';
33
+ $this->editable_files = array(
34
+ 'ckeditor.config.js' => dirname(__FILE__) . '/ckeditor.config.js',
35
+ 'ckeditor.styles.js' => dirname(__FILE__) . '/ckeditor.styles.js',
36
+ 'ckeditor.templates.js' => dirname(__FILE__) . '/ckeditor.templates.js',
37
+ );
38
+ $this->default_options = array(
39
+ 'appearance' => array(
40
+ 'skin' => 'kama',
41
+ 'uicolor' => 'default',
42
+ 'uicolor_user' => '',
43
+ /* basic post settings */
44
+ 'default_state' => 't',
45
+ 'post_toolbar' => 'WordpressFull',
46
+ 'post_editor_height' => 300,
47
+ /* basic comment settings */
48
+ 'comment_editor' => 't',
49
+ 'comment_toolbar' => 'WordpressBasic',
50
+ 'comment_editor_height' => 120,
51
+ ),
52
+ 'upload' => array(
53
+ 'browser' => 'disabled',
54
+ 'type' => 'native',
55
+ 'user_file_path' => 'wp-content/uploads/',
56
+ 'files_allowed_ext' => '7z,aiff,asf,avi,bmp,csv,doc,fla,flv,gif,gz,gzip,jpeg,jpg,mid,mov,mp3,mp4,mpc,mpeg,mpg,ods,odt,pdf,png,ppt,pxd,qt,ram,rar,rm,rmi,rmvb,rtf,sdc,sitd,swf,sxc,sxw,tar,tgz,tif,tiff,txt,vsd,wav,wma,wmv,xls,zip',
57
+ 'images_allowed_ext' => 'bmp,gif,jpeg,jpg,png',
58
+ 'flash_allowed_ext' => 'swf,flv',
59
+ ),
60
+ 'ckfinder' => array(
61
+ 'file_max_size' => '8M',
62
+ 'images_width' => '1200',
63
+ 'images_height' => '1600',
64
+ 'images_quality' => '80',
65
+ 'thumbnails_width' => '100',
66
+ 'thumbnails_height' => '100',
67
+ 'thumbnails_quality' => '80',
68
+ 'thumbnails_enabled' => 't',
69
+ 'thumbnails_direct_access' => 'f',
70
+ 'license_name' => '',
71
+ 'license_key' => '',
72
+ ),
73
+ 'css' => array(
74
+ 'mode' => 'default',
75
+ 'path' => '',
76
+ 'styles' => 'default',
77
+ 'style_path' => '',
78
+ ),
79
+ 'advanced' => array(
80
+ 'load_method' => 'ckeditor.js',
81
+ 'load_timeout' => 0,
82
+ 'native_spell_checker' => 't',
83
+ 'scayt_autoStartup' => 'f',
84
+ 'entities' => 't',
85
+ 'p_indent' => 't',
86
+ 'p_break_before_open' => 't',
87
+ 'p_break_after_open' => 'f',
88
+ 'p_break_before_close' => 'f',
89
+ 'p_break_after_close' => 't',
90
+ ),
91
+ 'plugins' => array(
92
+ 'autogrow' => 'f',
93
+ 'tableresize' => 'f',
94
+ 'wpgallery' => 't'
95
+ ),
96
+ );
97
+ $options = get_option('ckeditor_wordpress');
98
+ if (!$options) {
99
+ add_option('ckeditor_wordpress', $this->default_options);
100
+ $options = $this->default_options;
101
+ }
102
+ $this->options = $options;
103
+ if (!isset($this->options['advanced']['entities'])) {
104
+ $this->options['advanced']['entities'] = 't';
105
+ }
106
+ $path = str_replace(ABSPATH, '', trim($this->options['upload']['user_file_path']));
107
+ $dir = ABSPATH . $path;
108
+ if ($dir == ABSPATH) { //the option was empty
109
+ $dir = ABSPATH . 'wp-content/uploads';
110
+ }
111
+ $dir = rtrim($dir, "/\\") . "/";
112
+ $this->user_files_absolute_path = $dir;
113
+ $this->user_files_url = $siteurl . $path;
114
+ $this->file_browser = $this->options['upload']['browser'];
115
+ }
116
+
117
+ private function get_sorted_roles() {
118
+ // This function returns all roles, sorted by user level (lowest to highest)
119
+ global $wp_roles;
120
+ $roles = $wp_roles->role_objects;
121
+ $sorted = array();
122
+
123
+ if (class_exists('RoleManager')) {
124
+ foreach ($roles as $role_key => $role_name) {
125
+ $role = get_role($role_key);
126
+ if (empty($role))
127
+ continue;
128
+ $role_user_level = array_reduce(array_keys($role->capabilities), array('WP_User', 'level_reduction'), 0);
129
+ $sorted[$role_user_level] = $role;
130
+ }
131
+ $sorted = array_values($sorted);
132
+ }
133
+ else {
134
+ $role_order = array("subscriber", "contributor", "author", "editor", "administrator");
135
+ foreach ($role_order as $role_key) {
136
+ $sorted[$role_key] = get_role($role_key);
137
+ }
138
+ }
139
+ return $sorted;
140
+ }
141
+
142
+ private function get_role($capability) {
143
+ // This function return the lowest roles which has the capabilities
144
+ $check_order = $this->get_sorted_roles();
145
+
146
+ $args = array_slice(func_get_args(), 1);
147
+ $args = array_merge(array($capability), $args);
148
+
149
+ foreach ($check_order as $check_role) {
150
+ if (empty($check_role))
151
+ return false;
152
+
153
+ if (call_user_func_array(array(&$check_role, 'has_cap'), $args))
154
+ return $check_role->name;
155
+ }
156
+ return false;
157
+ }
158
+
159
+ private function set_capability($lowest_role, $capability) {
160
+ // This function set or remove the $capability
161
+ $check_order = $this->get_sorted_roles();
162
+ $add_capability = false;
163
+
164
+ foreach ($check_order as $the_role) {
165
+ $role = $the_role->name;
166
+
167
+ if ($lowest_role == $role)
168
+ $add_capability = true;
169
+
170
+ // If you rename the roles, then please use the role manager plugin
171
+ if (empty($the_role))
172
+ continue;
173
+
174
+ $add_capability ? $the_role->add_cap($capability) : $the_role->remove_cap($capability);
175
+ }
176
+ }
177
+
178
+ private function can_upload() {
179
+ global $userdata;
180
+ $user_level = intval($userdata->user_level);
181
+ if ((function_exists('current_user_can') && current_user_can('upload_files')) || (isset($user_level) && $user_level >= 3)) {
182
+ return true;
183
+ }
184
+ return false;
185
+ }
186
+
187
+ private function checkbox($section, $var, $text, $onClick = '') {
188
+ return '<label id="lbl_' . $var . '"><input type="checkbox" id="' . $var . '" name="options[' . $section . '][' . $var . ']"' .
189
+ ($onClick != '' ? ' onClick="' . $onClick . '" ' : '') .
190
+ ($this->options[$section][$var] == 't' ? "checked" : '') . '>&nbsp;' . __($text, 'ckeditor_wordpress') . "</label>\n";
191
+ }
192
+
193
+ public function add_admin_head() {
194
+ ?>
195
+ <style type="text/css">
196
+ .form-table td .cke_editor td { padding:0; }
197
+ #icon-wp-ckeditor {background: transparent url(<?php echo $this->plugin_path; ?>images/ckeditor_ico32.png) no-repeat;}
198
+ </style>
199
+ <?php
200
+ }
201
+
202
+ public function user_personalopts_update() {
203
+ global $current_user;
204
+ update_user_option($current_user->id, 'rich_editing', 'false', true);
205
+ }
206
+
207
+ public function print_admin_styles() {
208
+ wp_enqueue_style('ckeditor_admin', $this->plugin_path . 'includes/overview.css', false, $this->version, 'screen');
209
+ }
210
+
211
+ public function print_admin_upload_styles() {
212
+ wp_enqueue_style('ckeditor_admin', $this->plugin_path . 'includes/upload.css', false, $this->version, 'screen');
213
+ }
214
+
215
+ public function add_option_page() {
216
+ add_menu_page(__('CKEditor Settings'), 'CKEditor', 'administrator', 'ckeditor_settings', array(&$this, 'plugin_overview'), $this->plugin_path . 'images/menuicon.gif');
217
+ //line below replace url title from CKEditor to Overview
218
+ $overview_page = add_submenu_page('ckeditor_settings', __('CKEditor Overview'), __('Overview'), 'administrator', 'ckeditor_settings', array(&$this, 'plugin_overview'));
219
+ add_action('admin_print_styles-' . $overview_page, array(&$this, 'print_admin_styles'));
220
+
221
+ // TODO: include postbox/dashboard only on overview page
222
+ if (isset($_GET['page']) && $_GET['page'] == 'ckeditor_settings') {
223
+ wp_enqueue_script('postbox');
224
+ wp_admin_css('css/dashboard');
225
+ }
226
+
227
+ $basic_page = add_submenu_page('ckeditor_settings', __('CKEditor Basic Settings'), __('Basic Settings'), 'administrator', 'ckeditor_basic_options', array(&$this, 'option_page'));
228
+ add_action('admin_print_scripts-' . $basic_page, array(&$this, 'basic_settings_js'));
229
+
230
+ add_submenu_page('ckeditor_settings', __('CKEditor Advanced Settings'), __('Advanced Settings'), 'administrator', 'ckeditor_advanced_options', array(&$this, 'advanced_options'));
231
+ $upload_page = add_submenu_page('ckeditor_settings', __('CKEditor Upload Settings'), __('Upload Options'), 'administrator', 'ckeditor_upload_options', array(&$this, 'upload_options'));
232
+ add_action('admin_print_styles-' . $upload_page, array(&$this, 'print_admin_upload_styles'));
233
+
234
+ if (count($this->get_writable_files()) > 0) {
235
+ $file_editor_page = add_submenu_page('ckeditor_settings', __('CKEditor File Editor'), __('File Editor'), 'administrator', 'ckeditor_file_editor', array(&$this, 'file_editor'));
236
+ add_action('admin_print_scripts-' . $file_editor_page, array(&$this, 'file_editor_js'));
237
+ }
238
+ }
239
+
240
+ private function ckeditor_get_version() {
241
+ $jspath = dirname(__FILE__) . '/ckeditor/ckeditor_basic.js';
242
+ $contents = @file_get_contents($jspath);
243
+ if ($contents) {
244
+ $matches = array();
245
+ if (preg_match('#,version:\'(.*?)\',#', $contents, $matches)) {
246
+ return $matches[1];
247
+ }
248
+ }
249
+ return __('N/A', 'ckeditor_wordpress');
250
+ }
251
+
252
+ private function ckfinder_status() {
253
+ $ckfinder_php = dirname(__FILE__) . '/ckfinder/ckfinder.php';
254
+ $nested_ckfinder_php = dirname(__FILE__) . '/ckfinder/ckfinder/ckfinder.php';
255
+ $config_path = dirname(__FILE__) . '/ckfinder/config.php';
256
+
257
+ if (!file_exists($ckfinder_php)) {
258
+ if (file_exists($nested_ckfinder_php)) {
259
+ return '<span class="ckeditor_error">' . __('CKFinder installed in wrong (nested) directory. Move files from ckeditor/ckfinder/ckfinder to ckeditor/ckfinder directory.', 'ckeditor_wordpress') . '</span>';
260
+ } else {
261
+ return __('Not installed', 'ckeditor_wordpress');
262
+ }
263
+ } else {
264
+ $contents = @file_get_contents($config_path);
265
+ if (!$contents) {
266
+ return '<span class="ckeditor_error">' . __('CKFinder is installed, configuration file not readable or empty.', 'ckeditor_wordpress') . '</span>';
267
+ }
268
+ if (strpos($contents, 'wp-config.php') === false) {
269
+ return '<span class="ckeditor_error">' . __('CKFinder is installed, but invalid config.php was detected. Rename ckfinder_config.php to config.php (overwriting the default config.php file distributed with CKFinder).', 'ckeditor_wordpress') . '</span>';
270
+ }
271
+ if ($this->options['upload']['browser'] != 'ckfinder') {
272
+ return '<span class="ckeditor_ok">' . __('CKFinder is installed, not enabled.', 'ckeditor_wordpress') . '</span>';
273
+ }
274
+ return '<span class="ckeditor_ok">' . __('CKFinder is installed', 'ckeditor_wordpress') . '</span>';
275
+ }
276
+ }
277
+
278
+ public function plugin_overview() {
279
+ global $ckeditor_version, $ckeditor_plugin_version, $ckfinder_status;
280
+ $ckeditor_version = $this->ckeditor_get_version();
281
+ $ckeditor_plugin_version = $this->version;
282
+ $ckfinder_status = $this->ckfinder_status();
283
+ if (isset($_POST['reset']) && $_POST['reset'] == 1) {
284
+ if (!wp_verify_nonce($_POST['csrf_ckeditor-for-wordpress'], 'ckeditor_create_nonce_overview') || empty($_POST['_wp_http_referer']) || ( isset($_SERVER['HTTP_REFERER']) && !strstr($_SERVER['HTTP_REFERER'], $_POST['_wp_http_referer']) ))
285
+ wp_die("You do not have sufficient permissions to access this page.");
286
+ update_option('ckeditor_wordpress', $this->default_options);
287
+ $this->options = $this->default_options;
288
+ echo '<div class="updated"><p>' . __('Configuration updated!') . '</p></div>';
289
+ }
290
+ include('includes/overview.php');
291
+ }
292
+
293
+ public function option_page() {
294
+
295
+ if (!empty($_POST['submit_update'])) {
296
+ $message = array();
297
+ /* validation */
298
+ if (!wp_verify_nonce($_POST['csrf_ckeditor-for-wordpress'], 'ckeditor_create_nonce_basic') || empty($_POST['_wp_http_referer']) || ( isset($_SERVER['HTTP_REFERER']) && !strstr($_SERVER['HTTP_REFERER'], $_POST['_wp_http_referer']) ))
299
+ wp_die("You do not have sufficient permissions to access this page.");
300
+ $new_options = $_POST['options'];
301
+ $new_options['appearance']['comment_editor'] = (isset($_POST['options']['appearance']['comment_editor']) ? 't' : 'f');
302
+
303
+ $this->options = $this->update_options($new_options, (empty($message) ? false : true));
304
+ }
305
+ include('includes/basic.php');
306
+ }
307
+
308
+ public function upload_options() {
309
+ if (!empty($_POST['submit_update'])) {
310
+ if (!wp_verify_nonce($_POST['csrf_ckeditor-for-wordpress'], 'ckeditor_create_nonce_upload') || empty($_POST['_wp_http_referer']) || ( isset($_SERVER['HTTP_REFERER']) && !strstr($_SERVER['HTTP_REFERER'], $_POST['_wp_http_referer']) ))
311
+ wp_die("You do not have sufficient permissions to access this page.");
312
+ $new_options = $_POST['options'];
313
+ foreach (array('access', 'fileView', 'fileDelete', 'fileRename', 'fileUpload', 'folderView', 'folderDelete', 'folderCreate', 'folderRename') as $command) {
314
+ $this->set_capability($new_options['ckfinder']['permissions'][$command], "ckeditor_ckfinder_" . $command);
315
+ }
316
+ $new_options['ckfinder']['thumbnails_direct_access'] = (isset($new_options['ckfinder']['thumbnails_direct_access']) ? 't' : 'f');
317
+ $new_options['ckfinder']['thumbnails_enabled'] = (isset($new_options['ckfinder']['thumbnails_enabled']) ? 't' : 'f');
318
+
319
+ /* validation */
320
+ $message = array();
321
+
322
+ if ($new_options['upload']['browser'] != 'disabled') {
323
+ $new_options['upload']['files_allowed_ext'] = str_replace(' ', '', $new_options['upload']['files_allowed_ext']);
324
+ $new_options['upload']['images_allowed_ext'] = str_replace(' ', '', $new_options['upload']['images_allowed_ext']);
325
+ $new_options['upload']['flash_allowed_ext'] = str_replace(' ', '', $new_options['upload']['flash_allowed_ext']);
326
+
327
+ $inputs = array('files_allowed_ext', 'images_allowed_ext', 'flash_allowed_ext');
328
+ foreach ($inputs as $input) {
329
+ if (empty($new_options['upload'][$input])) {
330
+ $message['upload_' . $input] = __('This field shouldn\'t be empty', 'ckeditor_wordpress');
331
+ } elseif (!preg_match('#^([a-z0-9]+){1}(,[a-z0-9]+)*,?$#Uis', trim($new_options['upload'][$input]))) {
332
+ $message['upload_' . $input] = __('Files extensions has wrong chars.', 'ckeditor_wordpress');
333
+ }
334
+ }
335
+
336
+ if ($new_options['upload']['browser'] == 'ckfinder') {
337
+ $checkCKFinder = $this->ckfinder_status();
338
+ if (!strpos($checkCKFinder, "ckeditor_ok")) {
339
+ $message['upload_browser'] = $checkCKFinder;
340
+ }
341
+ if (empty($new_options['ckfinder']['file_max_size'])) {
342
+ $message['ckfinder_file_max_size'] = __('This field is required.', 'ckeditor_wordpress');
343
+ } elseif (!preg_match('/^\d+[MKG]?$/i', trim($new_options['ckfinder']['file_max_size']))) {
344
+ $message['ckfinder_file_max_size'] = __('Enter valid value. Example: 400 or 10M', 'ckeditor_wordpress');
345
+ }
346
+ $inputs = array('images_width', 'images_height', 'thumbnails_width', 'thumbnails_height');
347
+ foreach ($inputs as $input) {
348
+ if (empty($new_options['ckfinder'][$input])) {
349
+ $message['ckfinder_' . $input] = __('This field is required.', 'ckeditor_wordpress');
350
+ } elseif (!preg_match('#^\d+$#', trim($new_options['ckfinder'][$input]))) {
351
+ $message['ckfinder_' . $input] = __('Enter valid value. Example: 400', 'ckeditor_wordpress');
352
+ }
353
+ }
354
+ if (empty($new_options['ckfinder']['thumbnails_quality'])) {
355
+ $message['ckfinder_thumbnails_quality'] = __('This field is required.', 'ckeditor_wordpress');
356
+ } elseif (!(preg_match('#^[0-9]{1,2}$#', trim($new_options['ckfinder']['thumbnails_quality'])) || trim($new_options['ckfinder']['thumbnails_quality']) == '100')) {
357
+ $message['ckfinder_thumbnails_quality'] = __('Value should be betwen 1 and 100.', 'ckeditor_wordpress');
358
+ }
359
+ if (empty($new_options['ckfinder']['images_quality'])) {
360
+ $message['ckfinder_images_quality'] = __('This field is required.', 'ckeditor_wordpress');
361
+ } elseif (!(preg_match('#^[0-9]{1,2}$#', trim($new_options['ckfinder']['images_quality'])) || trim($new_options['ckfinder']['images_quality']) == '100')) {
362
+ $message['ckfinder_images_quality'] = __('Value should be betwen 1 and 100.', 'ckeditor_wordpress');
363
+ }
364
+ }
365
+ }
366
+
367
+ unset($new_options['ckfinder']['permissions']);
368
+
369
+ $this->options = $this->update_options($new_options, (empty($message) ? false : true));
370
+ }
371
+ include('includes/upload.php');
372
+ }
373
+
374
+ public function advanced_options() {
375
+ if (!empty($_POST['submit_update'])) {
376
+ if (!wp_verify_nonce($_POST['csrf_ckeditor-for-wordpress'], 'ckeditor_create_nonce_advanced') || empty($_POST['_wp_http_referer']) || ( isset($_SERVER['HTTP_REFERER']) && !strstr($_SERVER['HTTP_REFERER'], $_POST['_wp_http_referer']) ))
377
+ wp_die("You do not have sufficient permissions to access this page.");
378
+ $new_options = $_POST['options'];
379
+ $new_options['advanced']['native_spell_checker'] = (isset($_POST['options']['advanced']['native_spell_checker']) ? 't' : 'f');
380
+ $new_options['advanced']['scayt_autoStartup'] = (isset($_POST['options']['advanced']['scayt_autoStartup']) ? 't' : 'f');
381
+ $new_options['advanced']['p_indent'] = (isset($_POST['options']['advanced']['p_indent']) ? 't' : 'f');
382
+ $new_options['advanced']['p_break_before_open'] = (isset($_POST['options']['advanced']['p_break_before_open']) ? 't' : 'f');
383
+ $new_options['advanced']['p_break_after_open'] = (isset($_POST['options']['advanced']['p_break_after_open']) ? 't' : 'f');
384
+ $new_options['advanced']['p_break_before_close'] = (isset($_POST['options']['advanced']['p_break_before_close']) ? 't' : 'f');
385
+ $new_options['advanced']['p_break_after_close'] = (isset($_POST['options']['advanced']['p_break_after_close']) ? 't' : 'f');
386
+ $new_options['advanced']['entities'] = (isset($_POST['options']['advanced']['entities']) ? 't' : 'f');
387
+ foreach ($this->options['plugins'] as $key => $val) {
388
+ if (isset($_POST['options']['plugins'][$key])) {
389
+ $new_options['plugins'][$key] = 't';
390
+ unset($_POST['options']['plugins'][$key]);
391
+ } else {
392
+ $new_options['plugins'][$key] = 'f';
393
+ }
394
+ }
395
+ foreach ((array) $_POST['options']['plugins'] as $key => $val) {
396
+ $new_options['plugins'][$key] = 't';
397
+ }
398
+ $new_options['plugins']['wpgallery'] = 't';
399
+
400
+ /* validation */
401
+ $massage = array();
402
+
403
+ /** css mode and path validation * */
404
+ if (!empty($new_options['css']['path'])) {
405
+ if ($new_options['css']['mode'] != 'self') {
406
+ $message['css_path'] = __('CSS path is not empty. Please set the "Editor CSS" option to "define css" mode.', 'ckeditor_wordpress');
407
+ } elseif (FALSE !== strpos($new_options['css']['path'], '"')) {
408
+ $massage['css_path'] = __('Double quotes are not allowed in CSS path.', 'ckeditor_wordpress');
409
+ } elseif (substr($new_options['css']['path'], 0, 1) == "'" && substr($new_options['css']['path'], -1) == "'") {
410
+ $massage['css_path'] = __('Enter valid path, do not surround it with quotes.', 'ckeditor_wordpress');
411
+ }
412
+ }
413
+ /** styles * */
414
+ if (!empty($new_options['css']['style_path'])) {
415
+ if ($new_options['css']['styles'] != 'self') {
416
+ $message['css_style_path'] = __('Path to predefined styles is not empty. Please set the "Predefined styles" option to "define path to ckeditor.styles.js" mode.', 'ckeditor_wordpress');
417
+ } elseif (FALSE !== strpos($new_options['css']['styles_path'], '"')) {
418
+ $message['css_style_path'] = __('Double quotes are not allowed in path.', 'ckeditor_wordpress');
419
+ } elseif (substr($new_options['css']['style_path'], 0, 1) == "'" && substr($new_options['css']['style_path'], -1) == "'") {
420
+ $message['css_style_path'] = __('Enter valid path, do not surround it with quotes.', 'ckeditor_wordpress');
421
+ }
422
+ }
423
+ /** load timeout * */
424
+ if (!preg_match('#^\d+$#', trim($new_options['advanced']['load_timeout']))) {
425
+ $massage['advanced_load_timeout'] = __('Enter valid load timeout in seconds.', 'ckeditor_wordpress');
426
+ }
427
+
428
+ /* language settings */
429
+ if (!preg_match('#^\d\d$#', trim($new_options['advanced']['language'])) && !preg_match('#^\d\d-\d\d$#', trim($new_options['advanced']['language']))) {
430
+ $massage['advanced_language'] = __('Enter a valid language.', 'ckeditor_wordpress');
431
+ }
432
+
433
+ if (trim($new_options['advanced']['detect_language_auto']) != 't' && trim($new_options['advanced']['detect_language_auto'] != 'f')) {
434
+ $massage['advanced_detect_language_auto'] = __('Enter a valid auto detect language value.', 'ckeditor_wordpress');
435
+ }
436
+
437
+ if (trim($new_options['advanced']['language_direction']) != 'default' && trim($new_options['advanced']['language_direction']) != 'ltr' && trim($new_options['advanced']['language_direction']) != 'rtl') {
438
+ $massage['advanced_language_direction'] = __('Enter a valid language direction value.', 'ckeditor_wordpress');
439
+ }
440
+
441
+ $this->options = $this->update_options($new_options, (empty($message) ? false : true));
442
+ }
443
+ include('includes/advanced.php');
444
+ }
445
+
446
+ public function basic_settings_js() {
447
+ wp_enqueue_script('ckeditor', $this->ckeditor_path . 'ckeditor.js');
448
+ wp_enqueue_script('ckeditor_admin', $this->plugin_path . 'includes/basic.js');
449
+ }
450
+
451
+ public function file_editor_js() {
452
+ /* codepress */
453
+ //add_action('admin_print_footer_scripts', 'codepress_footer_js');
454
+ //wp_enqueue_script('codepress');
455
+ }
456
+
457
+ private function is_plugin_active($plugin_name) {
458
+ $options = get_option('active_plugins');
459
+ foreach ($options AS $option) {
460
+ if (strpos($option, $plugin_name) !== FALSE) {
461
+ return true;
462
+ }
463
+ }
464
+
465
+ return false;
466
+ }
467
+
468
+ public function remove_tinymce() {
469
+ if (has_action('admin_print_footer_scripts', 'wp_tiny_mce')) {
470
+ remove_action('admin_print_footer_scripts', 'wp_tiny_mce', 25);
471
+ }
472
+ }
473
+
474
+ public function add_post_js() {
475
+ if (has_filter('admin_print_footer_scripts', 'wp_tiny_mce') || has_filter('before_wp_tiny_mce', 'wp_print_editor_js') || has_filter('after_wp_tiny_mce', 'wp_preload_dialogs')) {
476
+
477
+ remove_filter('admin_print_footer_scripts', 'wp_tiny_mce', 25);
478
+ remove_filter('before_wp_tiny_mce', 'wp_print_editor_js');
479
+ remove_filter('after_wp_tiny_mce', 'wp_preload_dialogs');
480
+ $this->editor_js();
481
+ }
482
+ }
483
+
484
+ public function editor_js() {
485
+ if (!user_can_richedit()) {
486
+ wp_enqueue_script('quicktags');
487
+ return;
488
+ }
489
+ wp_enqueue_script('editor');
490
+ wp_enqueue_script('ckeditor', $this->ckeditor_path . $this->options['advanced']['load_method']);
491
+ wp_enqueue_script('ckeditor.utils', $this->plugin_path . 'includes/ckeditor.utils.js', array('ckeditor', 'jquery'));
492
+
493
+ $this->generate_js_options(false);
494
+ }
495
+
496
+ public function add_comment_js() {
497
+ if (!(is_page() || is_single())) {
498
+ return;
499
+ }
500
+
501
+ if ($this->options['appearance']['comment_editor'] != 't') {
502
+ return;
503
+ }
504
+
505
+ wp_enqueue_script('ckeditor', $this->ckeditor_path . $this->options['advanced']['load_method']);
506
+ wp_enqueue_script('ckeditor.utils', $this->plugin_path . 'includes/ckeditor.utils.js', array('ckeditor', 'jquery'));
507
+ wp_deregister_script('comment-reply');
508
+ wp_register_script('comment-reply', $this->plugin_path . 'includes/ckeditor.comment-reply.js', array('ckeditor', 'ckeditor.utils'), "20100901");
509
+ $this->generate_js_options(true);
510
+ $this->add_wpcompat_styles();
511
+ }
512
+
513
+ public function add_wpcompat_styles() {
514
+ ?>
515
+ <style type="text/css">
516
+ #content table.cke_editor { margin:0; }
517
+ #content table.cke_editor tr td { padding:0;border:0; }
518
+ </style>
519
+ <?php
520
+ }
521
+
522
+ private function update_options($new_options, $error) {
523
+ $options = $this->options;
524
+ foreach ($new_options as $k => $v) {
525
+ if (isset($this->options[$k])) {
526
+ $options[$k] = array_merge($this->options[$k], $v);
527
+ } else {
528
+ $options[$k] = $v;
529
+ }
530
+ }
531
+ if (!$error) {
532
+ update_option("ckeditor_wordpress", $options);
533
+ echo '<div class="updated"><p>' . __('Configuration updated!') . '</p></div>';
534
+ }
535
+ return $options;
536
+ }
537
+
538
+ private function get_writable_files() {
539
+ $out = array();
540
+ foreach ($this->editable_files as $file => $path) {
541
+ if (file_exists($path) && is_writable($path)) {
542
+ $out[$file] = $path;
543
+ }
544
+ }
545
+ return $out;
546
+ }
547
+
548
+ public function file_editor() {
549
+ $files = $this->get_writable_files();
550
+ if (isset($_POST['file']) && !isset($files[$_POST['file']])) {
551
+ echo '<div class="error"><p>' . __('Invalid file!') . '</p></div>';
552
+ return;
553
+ }
554
+ if (isset($_POST['file'])) {
555
+ $file = $_POST['file'];
556
+ } else {
557
+ $keys = array_keys($files);
558
+ $file = $keys[0];
559
+ unset($keys);
560
+ }
561
+ if (isset($_POST['newcontent'])) {
562
+ if (!wp_verify_nonce($_POST['csrf_ckeditor-for-wordpress'], 'ckeditor_create_nonce_file_editor') || empty($_POST['_wp_http_referer']) || ( isset($_SERVER['HTTP_REFERER']) && !strstr($_SERVER['HTTP_REFERER'], $_POST['_wp_http_referer']) ))
563
+ wp_die("You do not have sufficient permissions to access this page.");
564
+ $fp = fopen($files[$file], 'w');
565
+ $content = stripslashes($_POST['newcontent']);
566
+ fwrite($fp, stripslashes($_POST['newcontent']));
567
+ echo '<div class="updated"><p>' . __('Configuration updated!') . '</p></div>';
568
+ } else {
569
+ $fp = fopen($files[$file], 'r');
570
+ $content = fread($fp, filesize($files[$file]));
571
+ }
572
+ fclose($fp);
573
+ include('includes/file_editor.php');
574
+ }
575
+
576
+ private function generate_js_options($is_comment) {
577
+ $options = $this->options;
578
+ $settings = array();
579
+ if ($options['upload']['browser'] == 'builtin') {
580
+ $ck_browser_url = $this->plugin_path . 'filemanager/browser/default/browser.html?Connector=../../connectors/php/connector.php';
581
+ $ck_upload_url = $this->plugin_path . 'filemanager/connectors/php/upload.php';
582
+ $settings['filebrowserBrowseUrl'] = $ck_browser_url;
583
+ $settings['filebrowserImageBrowseUrl'] = $ck_browser_url . '&type=Images';
584
+ $settings['filebrowserFlashBrowseUrl'] = $ck_browser_url . '&type=Flash';
585
+ $settings['filebrowserUploadUrl'] = $ck_upload_url;
586
+ $settings['filebrowserImageUploadUrl'] = $ck_upload_url . '?type=Images';
587
+ $settings['filebrowserFlashUploadUrl'] = $ck_upload_url . '?type=Flash';
588
+ } else if ($options['upload']['browser'] == 'ckfinder') {
589
+ $ck_browser_url = $this->plugin_path . 'ckfinder/ckfinder.html';
590
+ $ck_upload_url = $this->plugin_path . 'ckfinder/core/connector/php/connector.php?command=QuickUpload';
591
+ $settings['filebrowserBrowseUrl'] = $ck_browser_url;
592
+ $settings['filebrowserImageBrowseUrl'] = $ck_browser_url . '?type=Images';
593
+ $settings['filebrowserFlashBrowseUrl'] = $ck_browser_url . '?type=Flash';
594
+ $settings['filebrowserUploadUrl'] = $ck_upload_url . '&type=Files';
595
+ $settings['filebrowserImageUploadUrl'] = $ck_upload_url . '&type=Images';
596
+ $settings['filebrowserFlashUploadUrl'] = $ck_upload_url . '&type=Flash';
597
+ }
598
+
599
+ if ($options['appearance']['uicolor'] == 'custom' && !empty($options['appearance']['uicolor_user'])) {
600
+ $settings['uiColor'] = $options['appearance']['uicolor_user'];
601
+ }
602
+ $settings['height'] = ($is_comment ? $options['appearance']['comment_editor_height'] : $options['appearance']['post_editor_height']) . 'px';
603
+ $settings['skin'] = $options['appearance']['skin'];
604
+ $settings['scayt_autoStartup'] = $options['advanced']['scayt_autoStartup'] == 't' ? true : false;
605
+ $settings['entities'] = $options['advanced']['entities'] == 't' ? true : false;
606
+ $settings['entities_greek'] = $settings['entities'];
607
+ $settings['entities_latin'] = $settings['entities'];
608
+ $settings['toolbar'] = ($is_comment ? $options['appearance']['comment_toolbar'] : $options['appearance']['post_toolbar']);
609
+ $settings['templates_files'][] = $this->plugin_path . 'ckeditor.templates.js';
610
+ $output = array(
611
+ 'textarea_id' => ($is_comment ? 'comment' : 'content'),
612
+ 'pluginPath' => $this->plugin_path,
613
+ 'autostart' => ($options['appearance']['default_state'] == 't' || $is_comment ? true : false),
614
+ 'qtransEnabled' => ($this->is_plugin_active("qtrans") ? true : false),
615
+ 'outputFormat' => array(
616
+ 'indent' => ($options['advanced']['p_indent'] == 't' ? true : false),
617
+ 'breakBeforeOpen' => ($options['advanced']['p_break_before_open'] == 't' ? true : false),
618
+ 'breakAfterOpen' => ($options['advanced']['p_break_after_open'] == 't' ? true : false),
619
+ 'breakBeforeClose' => ($options['advanced']['p_break_before_close'] == 't' ? true : false),
620
+ 'breakAfterClose' => ($options['advanced']['p_break_after_close'] == 't' ? true : false),
621
+ ),
622
+ 'configuration' => array(),
623
+ );
624
+ /** css mode * */
625
+ switch ($options['css']['mode']) {
626
+ case 'theme':
627
+ $settings['contentsCss'][] = get_stylesheet_uri();
628
+ //fix for default Wordpress theme
629
+ if (preg_match('/twenty[\S]+/', get_stylesheet_uri())) {
630
+ $settings['extraCss'] = 'body {background:#FFF; padding: 0 0.5em; }';
631
  }
632
  break;
633
+ case 'self':
634
+ foreach (explode(',', $options['css']['path']) as $css_path) {
635
+ $css_path = trim(str_replace("%h%t", "%t", $css_path));
636
+ $settings['contentsCss'][] = str_replace(array('%h', '%t'), array($_SERVER['HTTP_HOST'], get_template_directory_uri()), $css_path);
637
+ }
638
  break;
639
+ }
640
+ /** predefined style $options['css']['styles'] != 'default' || * */
641
+ switch ($options['css']['styles']) {
642
+ case 'theme':
643
+ $settings['stylesCombo_stylesSet'] = 'wordpress:' . get_template_directory_uri() . '/ckeditor.styles.js';
644
  break;
645
+ case 'self':
646
+ $options['css']['style_path'] = trim(str_replace("%h%t", "%t", $options['css']['style_path']));
647
+ $settings['stylesCombo_stylesSet'] = 'wordpress:' . str_replace(array('%h', '%t'), array($_SERVER['HTTP_HOST'], get_template_directory_uri()), $options['css']['style_path']);
648
+ break;
649
+ default:
650
+ $settings['stylesCombo_stylesSet'] = 'wordpress:' . $this->plugin_path . 'ckeditor.styles.js';
651
+ break;
652
+ }
653
+
654
+ if ($options['advanced']['detect_language_auto'] == 'f') {
655
+ $settings['language'] = $options['advanced']['language'];
656
+ }
657
+
658
+ if (isset($options['advanced']['language_direction'])) {
659
+ switch ($options['advanced']['language_direction']) {
660
+ case 'default':
661
+ if (is_rtl()) {
662
+ $settings['contentsLangDirection'] = 'rtl';
663
+ }
664
+ break;
665
+ case 'ltr':
666
+ $settings['contentsLangDirection'] = 'ltr';
667
+ break;
668
+ case 'rtl':
669
+ $settings['contentsLangDirection'] = 'rtl';
670
+ break;
671
+ }
672
+ }
673
+
674
+
675
+ $output['configuration'] = $settings;
676
+ $output['configuration']['customConfig'] = $this->plugin_path . 'ckeditor.config.js';
677
+ if (!$is_comment) {
678
+ $output['externalPlugins'] = apply_filters('ckeditor_external_plugins', array());
679
+ $output['additionalButtons'] = apply_filters('ckeditor_buttons', array());
680
+ foreach ((array) $options['plugins'] as $name => $val) {
681
+ if ($val == 't' && !isset($output['externalPlugins'][$name])) {
682
+ $output['externalPlugins'][$name] = $this->plugin_path . 'ckeditor/plugins/' . $name . '/';
683
+ } else if ($val == 'f' && isset($output['externalPlugins'][$name])) {
684
+ unset($output['externalPlugins'][$name]);
685
+ }
686
+ }
687
+ } else {
688
+ $output['externalPlugins'] = array();
689
+ $output['additionalButtons'] = array();
690
+ }
691
+ echo "<script type='text/javascript'>\n/* <![CDATA[ */\nwindow.CKEDITOR_BASEPATH = \"" . $this->ckeditor_path . "\";\nvar ckeditorSettings = " . $this->jsEncode($output) . "\n/* ]]> */\n</script>";
692
+ }
693
+
694
+ /**
695
+ * This little function provides a basic JSON support.
696
+ * http://php.net/manual/en/function.json-encode.php
697
+ * \private
698
+ *
699
+ * @param mixed $val
700
+ * @return string
701
+ */
702
+ private function jsEncode($val) {
703
+ if (is_null($val)) {
704
+ return 'null';
705
+ }
706
+ if ($val === false) {
707
+ return 'false';
708
+ }
709
+ if ($val === true) {
710
+ return 'true';
711
+ }
712
+ if (is_scalar($val)) {
713
+ if (is_float($val)) {
714
+ // Always use "." for floats.
715
+ $val = str_replace(",", ".", strval($val));
716
+ }
717
+
718
+ // Use @@ to not use quotes when outputting string value
719
+ if (strpos($val, '@@') === 0) {
720
+ return substr($val, 2);
721
+ } else {
722
+ // All scalars are converted to strings to avoid indeterminism.
723
+ // PHP's "1" and 1 are equal for all PHP operators, but
724
+ // JS's "1" and 1 are not. So if we pass "1" or 1 from the PHP backend,
725
+ // we should get the same result in the JS frontend (string).
726
+ // Character replacements for JSON.
727
+ static $jsonReplaces = array(array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"'),
728
+ array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'));
729
+
730
+ $val = str_replace($jsonReplaces[0], $jsonReplaces[1], $val);
731
+
732
+ return '"' . $val . '"';
733
+ }
734
+ }
735
+ $isList = true;
736
+ for ($i = 0, reset($val); $i < count($val); $i++, next($val)) {
737
+ if (key($val) !== $i) {
738
+ $isList = false;
739
+ break;
740
+ }
741
+ }
742
+ $result = array();
743
+ if ($isList) {
744
+ foreach ($val as $v)
745
+ $result[] = $this->jsEncode($v);
746
+ return '[ ' . join(', ', $result) . ' ]';
747
+ } else {
748
+ foreach ($val as $k => $v)
749
+ $result[] = $this->jsEncode($k) . ': ' . $this->jsEncode($v);
750
+ return '{ ' . join(', ', $result) . ' }';
751
  }
752
  }
753
 
754
+ public function ckeditor_wpmore_plugin($plugins) {
755
+ $plugins['wpmore'] = $this->plugin_path . 'plugins/wpmore/';
756
+ return $plugins;
757
+ }
758
+
759
+ public function ckeditor_wpmore_button($buttons) {
760
+ $buttons[] = array('WPMore');
761
+ return $buttons;
762
+ }
763
+
764
+ public function ckeditor_wpgallery_plugin($plugins) {
765
+ $plugins['wpgallery'] = $this->plugin_path . 'plugins/wpgallery/';
766
+ return $plugins;
767
+ }
768
+
769
+ //filter to change data for wpeditimage plugin before insert/update in database
770
+ public function ckeditor_insert_post_data_filter($data, $postarr = null) {
771
+ $content = $data['post_content'];
772
+ //change amp; to empty character . This is to create & character before entities like gt; and lt;
773
+ //$content = str_replace('amp;' , '', $content);
774
+ $content = stripslashes($content);
775
+ //change " character in caption string for &quot;
776
+ //change amp; to empty character . This is to create & character before entities like gt; and lt; in caption string
777
+ $pattern = '/caption="(.+)"\]/';
778
+ preg_match_all($pattern, $content, $matches);
779
+ if (isset($matches[1])) {
780
+
781
+ $content = str_replace($matches[1], str_replace('amp;', '', $matches[1]), $content);
782
+ $content = str_replace($matches[1], str_replace('"', '&quot;', $matches[1]), $content);
783
+ }
784
+ //save data
785
+ $content = addslashes($content);
786
+ $data['post_content'] = $content;
787
+ return $data;
788
+ }
789
+
790
+ public function ckeditor_externalvvq_plugin($plugins) {
791
+ if (class_exists('VipersVideoQuicktags')) {
792
+ $plugins['vvq'] = $this->plugin_path . 'plugins/vvq/';
793
+ }
794
+ return $plugins;
795
+ }
796
+
797
+ public function ckeditor_vvqbuttons($buttons) {
798
+ if (class_exists('VipersVideoQuicktags')) {
799
+ $vvqsettings = (array) get_option('vvq_options');
800
+ $vvqbuttons = array(
801
+ 'youtube' => 'VVQYoutube',
802
+ 'googlevideo' => 'VVQGoogleVideo',
803
+ 'dailymotion' => 'VVQDailyMotion',
804
+ 'vimeo' => 'VVQVimeo',
805
+ 'veoh' => 'VVQVeoh',
806
+ 'viddler' => 'VVQViddler',
807
+ 'metacafe' => 'VVQMetacafe',
808
+ 'bliptv' => 'VVQBlipTV',
809
+ 'flickrvideo' => 'VVQFlickrVideo',
810
+ 'spike' => 'VVQSpike',
811
+ 'myspace' => 'VVQMySpace',
812
+ 'flv' => 'VVQFLV',
813
+ 'quicktime' => 'VVQQuicktime',
814
+ 'videofile' => 'VVQVideoFile'
815
+ );
816
+ $vvqtoolbar = array();
817
+ foreach ($vvqsettings as $name => $val) {
818
+ if (isset($val["button"]) && $val["button"] == 1 && isset($vvqbuttons[$name])) {
819
+ $vvqtoolbar[] = $vvqbuttons[$name];
820
+ }
821
+ }
822
+ $buttons[] = $vvqtoolbar;
823
+ }
824
+ return $buttons;
825
+ }
826
+
827
+ public function wppoll_external($plugins) {
828
+ if (function_exists('poll_menu')) {
829
+ $plugins['wppolls'] = $this->plugin_path . 'plugins/wppolls/';
830
+ }
831
+ return $plugins;
832
+ }
833
+
834
+ public function wppoll_buttons($buttons) {
835
+ if (function_exists('poll_menu')) {
836
+ $buttons[] = array('WPPolls');
837
+ }
838
+ return $buttons;
839
+ }
840
+
841
+ public function starrating_external_plugin($plugins) {
842
+ if (defined('STARRATING_PATH')) {
843
+ $plugins['starrating'] = $this->plugin_path . 'plugins/gd-star-rating/';
844
+ }
845
+ return $plugins;
846
+ }
847
+
848
+ public function starrating_buttons($buttons) {
849
+ if (defined('STARRATING_PATH')) {
850
+ $buttons[] = array('StarRating');
851
+ }
852
+ return $buttons;
853
+ }
854
+
855
+ /**
856
+ * List of installed CKEditor languages
857
+ *
858
+ * @return array
859
+ */
860
+ public function ckeditor_load_lang_options() {
861
+ $arr = array();
862
+
863
+ if (DEFINED('WP_PLUGIN_DIR')) {
864
+ $lang_file = WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__)) . '/ckeditor/lang/_languages.js';
865
+ } else {
866
+ $lang_file = '../wp-content/plugins/ckeditor-for-wordpress/ckeditor/lang/_languages.js';
867
+ }
868
+ if (file_exists($lang_file)) {
869
+ $f = fopen($lang_file, 'r');
870
+ $file = fread($f, filesize($lang_file));
871
+ $tmp = explode('{', $file);
872
+ if (isset($tmp[2])) {
873
+ $tmp = explode('}', $tmp[2]);
874
+ }
875
+ $langs = explode(',', $tmp[0]);
876
+ foreach ($langs AS $key => $lang) {
877
+ preg_match("/(\w+-?\w+):'(\w+)'/i", $lang, $matches);
878
+ if (isset($matches[1]) && isset($matches[2]))
879
+ $arr[$matches[1]] = $matches[2];
880
+ }
881
+ }
882
+
883
+ //oops, we have no information about languages, let's use those available in CKEditor 2.4.3
884
+ if (empty($arr)) {
885
+ $arr = array(
886
+ 'af' => 'Afrikaans',
887
+ 'ar' => 'Arabic',
888
+ 'bg' => 'Bulgarian',
889
+ 'bn' => 'Bengali/Bangla',
890
+ 'bs' => 'Bosnian',
891
+ 'ca' => 'Catalan',
892
+ 'cs' => 'Czech',
893
+ 'da' => 'Danish',
894
+ 'de' => 'German',
895
+ 'el' => 'Greek',
896
+ 'en' => 'English',
897
+ 'en-au' => 'English (Australia)',
898
+ 'en-ca' => 'English (Canadian)',
899
+ 'en-uk' => 'English (United Kingdom)',
900
+ 'eo' => 'Esperanto',
901
+ 'es' => 'Spanish',
902
+ 'et' => 'Estonian',
903
+ 'eu' => 'Basque',
904
+ 'fa' => 'Persian',
905
+ 'fi' => 'Finnish',
906
+ 'fo' => 'Faroese',
907
+ 'fr' => 'French',
908
+ 'gl' => 'Galician',
909
+ 'he' => 'Hebrew',
910
+ 'hi' => 'Hindi',
911
+ 'hr' => 'Croatian',
912
+ 'hu' => 'Hungarian',
913
+ 'it' => 'Italian',
914
+ 'ja' => 'Japanese',
915
+ 'km' => 'Khmer',
916
+ 'ko' => 'Korean',
917
+ 'lt' => 'Lithuanian',
918
+ 'lv' => 'Latvian',
919
+ 'mn' => 'Mongolian',
920
+ 'ms' => 'Malay',
921
+ 'nb' => 'Norwegian Bokmal',
922
+ 'nl' => 'Dutch',
923
+ 'no' => 'Norwegian',
924
+ 'pl' => 'Polish',
925
+ 'pt' => 'Portuguese (Portugal)',
926
+ 'pt-br' => 'Portuguese (Brazil)',
927
+ 'ro' => 'Romanian',
928
+ 'ru' => 'Russian',
929
+ 'sk' => 'Slovak',
930
+ 'sl' => 'Slovenian',
931
+ 'sr' => 'Serbian (Cyrillic)',
932
+ 'sr-latn' => 'Serbian (Latin)',
933
+ 'sv' => 'Swedish',
934
+ 'th' => 'Thai',
935
+ 'tr' => 'Turkish',
936
+ 'uk' => 'Ukrainian',
937
+ 'vi' => 'Vietnamese',
938
+ 'zh' => 'Chinese Traditional',
939
+ 'zh-cn' => 'Chinese Simplified',
940
+ );
941
+ }
942
+ asort($arr);
943
+ return $arr;
944
+ }
945
+
946
+ }
947
+
948
+ final class _WP_Editors {
949
+
950
+ public static function parse_settings($editor_id, $settings) {
951
+ $set = wp_parse_args($settings, array(
952
+ 'wpautop' => true, // use wpautop?
953
+ 'media_buttons' => true, // show insert/upload button(s)
954
+ 'textarea_name' => $editor_id, // set the textarea name to something different, square brackets [] can be used here
955
+ 'textarea_rows' => get_option('default_post_edit_rows', 10), // rows="..."
956
+ 'tabindex' => '',
957
+ 'editor_css' => '', // intended for extra styles for both visual and HTML editors buttons, needs to include the <style> tags, can use "scoped".
958
+ 'editor_class' => '', // add extra class(es) to the editor textarea
959
+ 'teeny' => false, // output the minimal editor config used in Press This
960
+ 'dfw' => false, // replace the default fullscreen with DFW (needs specific DOM elements and css)
961
+ 'tinymce' => true, // load TinyMCE, can be used to pass settings directly to TinyMCE using an array()
962
+ 'quicktags' => true // load Quicktags, can be used to pass settings directly to Quicktags using an array()
963
+ ));
964
+
965
+ $set['tinymce'] = ( $set['tinymce'] && user_can_richedit() );
966
+ $set['quicktags'] = (bool) $set['quicktags'];
967
+
968
+ return $set;
969
+ }
970
+
971
+ public static function editor($content, $editor_id, $settings = array()) {
972
+ $set = self::parse_settings($editor_id, $settings);
973
+ $editor_class = ' class="' . trim($set['editor_class'] . ' wp-editor-area theEditor') . '"';
974
+ $tabindex = $set['tabindex'] ? ' tabindex="' . (int) $set['tabindex'] . '"' : '';
975
+ $rows = ' rows="' . (int) $set['textarea_rows'] . '"';
976
+ $switch_class = 'html-active';
977
+ $toolbar = $buttons = '';
978
+
979
+ if (!current_user_can('upload_files'))
980
+ $set['media_buttons'] = false;
981
+
982
+ if ($set['quicktags'] && $set['tinymce']) {
983
+ $switch_class = 'html-active';
984
+
985
+ if ('html' == wp_default_editor()) {
986
+ add_filter('the_editor_content', 'wp_htmledit_pre');
987
+ } else {
988
+ add_filter('the_editor_content', 'wp_richedit_pre');
989
+ $switch_class = 'tmce-active';
990
+ }
991
+
992
+ $buttons .= '<a id="' . $editor_id . '-html" class="hide-if-no-js wp-switch-editor switch-html" onclick="switchEditors.switchto(this);">' . __('HTML') . "</a>\n";
993
+ $buttons .= '<a id="' . $editor_id . '-tmce" class="hide-if-no-js wp-switch-editor switch-tmce" onclick="switchEditors.switchto(this);">' . __('Visual') . "</a>\n";
994
+ }
995
+
996
+ echo '<div id="wp-' . $editor_id . '-wrap" class="wp-editor-wrap ' . $switch_class . '">';
997
+
998
+ wp_print_styles('editor-buttons');
999
+
1000
+ if (!empty($set['editor_css']))
1001
+ echo $set['editor_css'] . "\n";
1002
+
1003
+ if (!empty($buttons) || $set['media_buttons']) {
1004
+ echo '<div id="wp-' . $editor_id . '-editor-tools" class="wp-editor-tools">';
1005
+ echo $buttons;
1006
+
1007
+ if ($set['media_buttons']) {
1008
+ //self::$has_medialib = true;
1009
+
1010
+ if (!function_exists('media_buttons'))
1011
+ include(ABSPATH . 'wp-admin/includes/media.php');
1012
+
1013
+ echo '<div id="wp-' . $editor_id . '-media-buttons" class="hide-if-no-js wp-media-buttons">';
1014
+ do_action('media_buttons', $editor_id);
1015
+ echo "</div>\n";
1016
+ }
1017
+ echo "</div>\n";
1018
+ }
1019
+
1020
+ $the_editor = apply_filters('the_editor', '<div id="wp-' . $editor_id . '-editor-container" class="wp-editor-container"><textarea' . $editor_class . $rows . $tabindex . ' cols="40" name="' . $set['textarea_name'] . '" id="' . $editor_id . '">%s</textarea></div>');
1021
+ $content = apply_filters('the_editor_content', $content);
1022
+
1023
+ printf($the_editor, $content);
1024
+ echo "\n</div>\n\n";
1025
+
1026
+ ckeditor_wordpress::getInstance()->editor_js();
1027
+ }
1028
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1029
  }
1030
+
1031
+ $ckeditor_wordpress = ckeditor_wordpress::getInstance();
1032
  ?>
ckeditor_wordpress.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: CKEditor for WordPress
5
  Plugin URI: http://wordpress.ckeditor.com/
6
  Description: Replaces the default WordPress editor with <a href="http://ckeditor.com/"> CKEditor</a>
7
- Version: 3.6.2.3
8
  Author: CKSource
9
  Author URI: http://cksource.com/
10
  */
@@ -12,39 +12,39 @@ Author URI: http://cksource.com/
12
  add_action('init', 'ckeditor_init');
13
 
14
  function ckeditor_init(){
15
- global $ckeditor_wordpress;
16
- require_once 'ckeditor_class.php';
17
-
18
- if(is_admin()){
19
- add_action('admin_menu', array(&$ckeditor_wordpress, 'add_option_page'));
20
- add_action('admin_head', array(&$ckeditor_wordpress, 'add_admin_head'));
21
- add_action('personal_options_update', array(&$ckeditor_wordpress, 'user_personalopts_update'));
22
- add_action('admin_print_scripts', array(&$ckeditor_wordpress, 'add_post_js'));
23
- add_action('admin_print_footer_scripts', array(&$ckeditor_wordpress, 'remove_tinymce'));
24
- }
25
-
26
- add_action('wp_print_scripts', array(&$ckeditor_wordpress, 'add_comment_js'));
27
- add_filter( 'ckeditor_external_plugins', array(&$ckeditor_wordpress, 'ckeditor_wpmore_plugin') );
28
- add_filter( 'ckeditor_buttons', array(&$ckeditor_wordpress, 'ckeditor_wpmore_button') );
29
- add_filter( 'ckeditor_external_plugins', array(&$ckeditor_wordpress, 'ckeditor_wpgallery_plugin') );
30
- add_filter( 'ckeditor_load_lang_options', array(&$ckeditor_wordpress, 'ckeditor_load_lang_options') );
31
-
32
- //add filter to change content before insert/update to database - needed for wpeditimage plugin
33
- add_filter( 'wp_insert_post_data' , array(&$ckeditor_wordpress, 'ckeditor_insert_post_data_filter'));
34
-
35
- /** temporary for vvq **/
36
- add_filter( 'ckeditor_external_plugins', array(&$ckeditor_wordpress, 'ckeditor_externalvvq_plugin') );
37
- add_filter( 'ckeditor_buttons', array(&$ckeditor_wordpress, 'ckeditor_vvqbuttons') );
38
- /** temporary for wppoll **/
39
- add_filter( 'ckeditor_external_plugins', array(&$ckeditor_wordpress, 'wppoll_external') );
40
- add_filter( 'ckeditor_buttons', array(&$ckeditor_wordpress, 'wppoll_buttons') );
41
-
42
- /** temporary for ngggallery **/
43
- include_once(dirname(__FILE__) . '/plugins/nggallery/ckeditor.php');
44
-
45
- /** temporary for gd-star-rating **/
46
- add_filter( 'ckeditor_external_plugins', array(&$ckeditor_wordpress, 'starrating_external_plugin') );
47
- add_filter( 'ckeditor_buttons', array(&$ckeditor_wordpress, 'starrating_buttons') );
48
 
49
  }
50
  ?>
4
  Plugin Name: CKEditor for WordPress
5
  Plugin URI: http://wordpress.ckeditor.com/
6
  Description: Replaces the default WordPress editor with <a href="http://ckeditor.com/"> CKEditor</a>
7
+ Version: 3.6.2.4
8
  Author: CKSource
9
  Author URI: http://cksource.com/
10
  */
12
  add_action('init', 'ckeditor_init');
13
 
14
  function ckeditor_init(){
15
+ global $ckeditor_wordpress;
16
+ require_once 'ckeditor_class.php';
17
+
18
+ if(is_admin()){
19
+ add_action('admin_menu', array(&$ckeditor_wordpress, 'add_option_page'));
20
+ add_action('admin_head', array(&$ckeditor_wordpress, 'add_admin_head'));
21
+ add_action('personal_options_update', array(&$ckeditor_wordpress, 'user_personalopts_update'));
22
+ add_action('admin_print_scripts', array(&$ckeditor_wordpress, 'add_post_js'));
23
+ add_action('admin_print_footer_scripts', array(&$ckeditor_wordpress, 'remove_tinymce'));
24
+ }
25
+
26
+ add_action( 'wp_print_scripts', array(&$ckeditor_wordpress, 'add_comment_js'));
27
+ add_filter( 'ckeditor_external_plugins', array(&$ckeditor_wordpress, 'ckeditor_wpmore_plugin') );
28
+ add_filter( 'ckeditor_buttons', array(&$ckeditor_wordpress, 'ckeditor_wpmore_button') );
29
+ add_filter( 'ckeditor_external_plugins', array(&$ckeditor_wordpress, 'ckeditor_wpgallery_plugin') );
30
+ add_filter( 'ckeditor_load_lang_options', array(&$ckeditor_wordpress, 'ckeditor_load_lang_options') );
31
+
32
+ //add filter to change content before insert/update to database - needed for wpeditimage plugin
33
+ add_filter( 'wp_insert_post_data' , array(&$ckeditor_wordpress, 'ckeditor_insert_post_data_filter'));
34
+
35
+ /** temporary for vvq **/
36
+ add_filter( 'ckeditor_external_plugins', array(&$ckeditor_wordpress, 'ckeditor_externalvvq_plugin') );
37
+ add_filter( 'ckeditor_buttons', array(&$ckeditor_wordpress, 'ckeditor_vvqbuttons') );
38
+ /** temporary for wppoll **/
39
+ add_filter( 'ckeditor_external_plugins', array(&$ckeditor_wordpress, 'wppoll_external') );
40
+ add_filter( 'ckeditor_buttons', array(&$ckeditor_wordpress, 'wppoll_buttons') );
41
+
42
+ /** temporary for ngggallery **/
43
+ include_once(dirname(__FILE__) . '/plugins/nggallery/ckeditor.php');
44
+
45
+ /** temporary for gd-star-rating **/
46
+ add_filter( 'ckeditor_external_plugins', array(&$ckeditor_wordpress, 'starrating_external_plugin') );
47
+ add_filter( 'ckeditor_buttons', array(&$ckeditor_wordpress, 'starrating_buttons') );
48
 
49
  }
50
  ?>
includes/advanced.php CHANGED
@@ -1,190 +1,189 @@
1
  <div class="wrap">
2
- <div id="icon-wp-ckeditor" class="icon32"><br /></div>
3
- <h2><?php _e('CKEditor - Advanced Settings', 'ckeditor_wordpress') ?></h2>
4
- <form method="post" id="ca_form">
5
- <?php wp_nonce_field('ckeditor_create_nonce_advanced','csrf_ckeditor-for-wordpress'); ?>
6
- <h3><?php _e('CSS Options', 'ckeditor_wordpress') ?></h3>
7
- <table class="form-table">
8
- <tr valign="top">
9
- <th scope="row"><?php _e('Editor CSS', 'ckeditor_wordpress') ?></th>
10
- <td>
11
- <select name="options[css][mode]">
12
- <option value="default"<?php echo ($this->options['css']['mode']=='default'?' selected="selected"':'') ?>><?php _e('CKEditor default (recommended)', 'ckeditor_wordpress');?></option>
13
- <option value="theme"<?php echo ($this->options['css']['mode']=='theme'?' selected="selected"':'') ?>><?php _e('Use theme css', 'ckeditor_wordpress');?></option>
14
- <option value="self"<?php echo ($this->options['css']['mode']=='self'?' selected="selected"':'') ?>><?php _e('Define css', 'ckeditor_wordpress');?></option>
15
- </select>
16
- <div class="description"><?php _e("Defines the CSS to be used in the editor area.<br />Use theme css - load style.css from current site theme.<br />Define css - enter path for css file below.<br />CKEditor default - uses default CSS from editor.", 'ckeditor_wordpress') ?></div>
17
- </td>
18
- </tr>
19
- <tr valign="top">
20
- <th scope="row"><?php _e('CSS path', 'ckeditor_wordpress') ?></th>
21
- <td>
22
- <input type="text" name="options[css][path]" value="<?php echo htmlspecialchars($this->options['css']['path']) ?>" />
23
- <?php if (isset($message['css_path'])): ?><span class="error"><?php echo $message['css_path'] ?></span><?php endif; ?>
24
- <div class="description"><?php _e('Enter path to CSS file (Example: "css/editor.css") or a list of css files separated by a comma (Example: "/wp-content/themes/default/style.css,http://example.com/style.css"). Make sure to select "Define css" above.<br />Available placeholders:<br />%h - host name (/).<br />%t - path to theme.', 'ckeditor_wordpress') ?></div>
25
- </td>
26
- </tr>
27
- <tr valign="top">
28
- <th scope="row"><?php _e('Predefined styles', 'ckeditor_wordpress') ?></th>
29
- <td>
30
- <select name="options[css][styles]">
31
- <option value="theme"<?php echo ($this->options['css']['styles']=='theme'?' selected="selected"':'') ?>><?php _e('Use theme ckeditor.styles.js', 'ckeditor_wordpress');?></option>
32
- <option value="self"<?php echo ($this->options['css']['styles']=='self'?' selected="selected"':'') ?>><?php _e('Define path to ckeditor.styles.js', 'ckeditor_wordpress');?></option>
33
- <option value="default"<?php echo ($this->options['css']['styles']=='default'?' selected="selected"':'') ?>><?php _e('CKEditor default', 'ckeditor_wordpress');?></option>
34
- </select>
35
- <div class="description"><?php _e('Define the location of "ckeditor.styles.js" file. It is used by the "Style" dropdown list available in the default toolbar.', 'ckeditor_wordpress') ?></div>
36
- </td>
37
- </tr>
38
- <tr valign="top">
39
- <th scope="row"><?php _e('Predefined styles path', 'ckeditor_wordpress') ?></th>
40
- <td>
41
- <input type="text" name="options[css][style_path]" value="<?php echo htmlspecialchars($this->options['css']['style_path']) ?>" />
42
- <?php if (isset($message['css_style_path'])): ?><span class="error"><?php echo $message['css_style_path'] ?></span><?php endif; ?>
43
- <div class="description"><?php _e('Enter path to file with predefined styles (Example: "/ckeditor.styles.js"). Be sure to select "define path to ckeditor.styles.js" above.<br />Available placeholders:<br />%h - host name (/).<br />%t - path to theme .', 'ckeditor_wordpress') ?></div>
44
- </td>
45
- </tr>
46
- </table>
47
- <h3><?php _e('Output Formatting', 'ckeditor_wordpress') ?></h3>
48
- <table class="form-table">
49
- <tr valign="top">
50
- <th scope="row"><?php _e('Output formatting', 'ckeditor_wordpress')?><br /><span class="description">(<?php _e('Writer rules', 'ckeditor_wordpress'); ?>)</span></th>
51
- <td>
52
- <?php echo $this->checkbox('advanced', 'p_indent', 'indent the element contents.');?><br />
53
- <?php echo $this->checkbox('advanced', 'p_break_before_open', 'break line before the opener tag.');?><br />
54
- <?php echo $this->checkbox('advanced', 'p_break_after_open', 'break line after the opener tag.');?><br />
55
- <?php echo $this->checkbox('advanced', 'p_break_before_close', 'break line before the closer tag.');?><br />
56
- <?php echo $this->checkbox('advanced', 'p_break_after_close', 'break line after the closer tag.');?><br />
57
- </td>
58
- </tr>
59
- </table>
60
- <h3><?php _e('Advanced Options', 'ckeditor_wordpress') ?></h3>
61
- <table class="form-table">
62
- <tr valign="top">
63
- <th scope="row"><?php _e('Spell checker', 'ckeditor_wordpress')?><br /></th>
64
- <td>
65
- <?php echo $this->checkbox('advanced', 'scayt_autoStartup', 'SCAYT auto startup.');?><br />
66
- <div class="description"><?php _e('If enabled, turns on SCAYT (Spell Check As You Type) automatically after loading the editor.', 'ckeditor_wordpress'); ?></div>
67
- </td>
68
- </tr>
69
- <tr valign="top">
70
- <th scope="row"><?php _e('Built-in spell checker', 'ckeditor_wordpress')?></th>
71
- <td><?php echo $this->checkbox('advanced', 'native_spell_checker', 'Enable the built-in spell checker while typing natively available in the browser.');?>
72
- <div class="description">(<?php _e('currently Firefox and Safari only', 'ckeditor_wordpress');?>)</div></td></tr>
73
- </tr>
74
- <tr valign="top">
75
- <th scope="row"><?php _e('HTML entities', 'ckeditor_wordpress')?></th>
76
- <td><?php echo $this->checkbox('advanced', 'entities', 'Using HTML entities in the output.');?>
77
- <div class="description">(<?php _e('Convert all applicable characters to HTML entities', 'ckeditor_wordpress');?>)</div></td></tr>
78
- </tr>
79
- <tr valign="top">
80
- <th scope="row"><?php _e('Plugins', 'ckeditor_wordpress')?></th>
81
- <td>
82
- <?php
83
- $plugins = apply_filters('ckeditor_external_plugins', array());
84
- $plugins = array_keys($plugins);
85
- $plugins[] = "autogrow";
86
- $plugins[] = "tableresize";
87
- sort($plugins);
88
 
89
- foreach ($plugins as $plugin){
90
- if ($plugin == "wpgallery" || $plugin == "wpeditimage") continue;
91
- if (!isset($this->options['plugins'][$plugin])){
92
- $this->options['plugins'][$plugin] = 't';
93
- }
94
- echo $this->checkbox('plugins', $plugin, ucfirst($plugin) . ' plugin') . '<br />';
95
- }
96
- ?>
97
 
98
- <div class="description">(<?php _e('Choose the plugins which u want to load into CKEditor', 'ckeditor_wordpress');?>)</div>
99
- </td>
100
- </tr>
101
- <tr valign="top">
102
- <th scope="row"><?php _e('Load method', 'ckeditor_wordpress') ?></th>
103
- <td>
104
- <select name="options[advanced][load_method]">
105
- <option value="ckeditor.js"<?php echo ($this->options['advanced']['load_method']=='ckeditor.js'?' selected="selected"':'') ?>>ckeditor.js</option>
106
- <option value="ckeditor_basic.js"<?php echo ($this->options['advanced']['load_method']=='ckeditor_basic.js'?' selected="selected"':'') ?>>ckeditor_basic.js</option>
107
- <?php if (file_exists(dirname(dirname(__FILE__))."/ckeditor/_source")):?>
108
- <option value="ckeditor_source.js"<?php echo ($this->options['advanced']['load_method']=='ckeditor_source.js'?' selected="selected"':'') ?>>ckeditor_source.js (for developers only)</option>
109
- <?php endif; ?>
110
- </select>
111
- <div class="description"><?php _e('Select the load method of CKEditor. If ckeditor_base.js is used, only a small file is initially loaded and the rest part of the editor is loaded later (see "Load timeout"). This might be handy if CKEditor is disabled by default.', 'ckeditor_wordpress');?><br/>
112
- <?php _e('You can also choose loading ckeditor_source.js (for developers), but only if you download the full CKEditor package from <a href="http://ckeditor.com/download">CKEditor web site</a> and unpack it in the "ckeditor" folder. CKEditor distributed with this plugin does not contain _source files as well as the _samples folder to reduce the size of a plugin, that\'s why this option is not available by default.', 'ckeditor_wordpress') ?></div>
113
- </td>
114
- </tr>
115
- <tr valign="top">
116
- <th scope="row"><?php _e('Load timeout', 'ckeditor_wordpress')?></th>
117
- <td>
118
- <input type="text" name="options[advanced][load_timeout]" value="<?php echo $this->options['advanced']['load_timeout']; ?>"/>s
119
- <?php if (isset($message['advanced_load_timeout'])): ?><span class="error"><?php echo $message['advanced_load_timeout'] ?></span><?php endif; ?>
120
- <div class="description"><?php _e('The time to wait (in seconds) to load the full editor code after the page load, if the "ckeditor_basic.js" file is used. If set to zero, the editor is loaded on demand.', 'ckeditor_wordpress') ?></div>
121
- </td>
122
- </tr>
123
- <?php
124
- $langs = apply_filters('ckeditor_load_lang_options', array());
125
- ?>
126
- <tr valign="top">
127
- <th scope="row"><?php _e('Language', 'ckeditor_wordpress')?></th>
128
- <td>
129
- <?php
130
- //var_dump( get_locale());
131
- if (isset($this->options['advanced']['language']))
132
- {
133
- $selected = $this->options['advanced']['language'];
134
- }else{
135
- $selected = (get_locale())? get_locale() : 'en';
136
- }
137
- ?>
138
- <select name="options[advanced][language]">
139
- <?php foreach ($langs AS $key => $lang): ?>
140
- <option value="<?php echo $key?>" <?php if($key == $selected):?>selected="selected"<?php endif;?>><?php echo $lang ?></option>
141
- <?php endforeach; ?>
142
- </select>
143
- <br /><span class="description"><?php _e('The language for the CKEditor user interface.', 'ckeditor_wordpress'); ?></span>
144
- <?php if (isset($message['advanced_language'])): ?><span class="error"><?php echo $message['advanced_language'] ?></span><?php endif; ?>
145
- </td>
146
- </tr>
147
- <?php
148
- if (isset($this->options['advanced']['detect_language_auto']))
149
- {
150
- $auto = $this->options['advanced']['detect_language_auto'];
151
- } else {
152
- $auto = 't';
153
- }
154
- ?>
155
- <tr valign="top">
156
- <th scope="row"><?php _e('Auto-detect language', 'ckeditor_wordpress')?></th>
157
- <td>
158
- <input id="autodetect_enabled" name="options[advanced][detect_language_auto]" type="radio" value="t" <?php if($auto == 't'):?>checked="checked"<?php endif; ?>><label for="autodetect_enabled">Enabled</label> <br/>
159
- <input id="autodetect_disabled" name="options[advanced][detect_language_auto]" type="radio" value="f" <?php if($auto == 'f'):?>checked="checked"<?php endif; ?>><label for="autodetect_disabled"> Disabled</label>
160
- <br /><span class="description"><?php _e('Automatically detect the user language.', 'ckeditor_wordpress'); ?></span>
161
- <?php if (isset($message['advanced_detect_language_auto'])): ?><br/><span class="error"><?php echo $message['advanced_detect_language_auto'] ?></span><?php endif; ?>
162
- </td>
163
- </tr>
164
- <tr valign="top">
165
- <th scope="row"><?php _e('Language direction ', 'ckeditor_wordpress')?></th>
166
- <td>
167
- <?php
168
- if (isset($this->options['advanced']['language_direction']))
169
- {
170
- $selected = $this->options['advanced']['language_direction'];
171
- }else{
172
- $selected = 'default';
173
- }
174
- ?>
175
- <select name="options[advanced][language_direction]">
176
- <option value="default" <?php if($selected == 'default'):?>selected="selected"<?php endif;?>>Get from current locale (default)</option>
177
- <option value="ltr" <?php if($selected == 'ltr'):?>selected="selected"<?php endif;?>>Left-To-Right</option>
178
- <option value="rtl" <?php if($selected == 'rtl'):?>selected="selected"<?php endif;?>>Right-To-Left</option>
179
- </select>
180
- <br /><span class="description"><?php _e('Choose the language direction used in the editing area. Even when CKEditor automatically detects the user language and adjusts its user interface, the editing area is not automatically changed into the LTR or RTL mode. To be able to type LTR (like English) and RTL (like Arabic, Hebrew, Persian) content at the same time, please make sure that the BidiLtr and BidiRtl buttons are enabled in the toolbar.', 'ckeditor_wordpress'); ?></span>
181
- <?php if (isset($message['advanced_language_direction'])): ?><span class="error"><?php echo $message['advanced_language_dierction'] ?></span><?php endif; ?>
182
- </td>
183
- </tr>
184
- </table>
185
- <p class="submit">
186
- <input type="hidden" name="df_submit" value="1" />
187
- <input type="submit" class="button-primary" value="Update Options" name="submit_update" />
188
- </p>
189
- </form>
190
  </div>
1
  <div class="wrap">
2
+ <div id="icon-wp-ckeditor" class="icon32"><br /></div>
3
+ <h2><?php _e('CKEditor - Advanced Settings', 'ckeditor_wordpress') ?></h2>
4
+ <form method="post" id="ca_form">
5
+ <?php wp_nonce_field('ckeditor_create_nonce_advanced','csrf_ckeditor-for-wordpress'); ?>
6
+ <h3><?php _e('CSS Options', 'ckeditor_wordpress') ?></h3>
7
+ <table class="form-table">
8
+ <tr valign="top">
9
+ <th scope="row"><?php _e('Editor CSS', 'ckeditor_wordpress') ?></th>
10
+ <td>
11
+ <select name="options[css][mode]">
12
+ <option value="default"<?php echo ($this->options['css']['mode']=='default'?' selected="selected"':'') ?>><?php _e('CKEditor default (recommended)', 'ckeditor_wordpress');?></option>
13
+ <option value="theme"<?php echo ($this->options['css']['mode']=='theme'?' selected="selected"':'') ?>><?php _e('Use theme css', 'ckeditor_wordpress');?></option>
14
+ <option value="self"<?php echo ($this->options['css']['mode']=='self'?' selected="selected"':'') ?>><?php _e('Define css', 'ckeditor_wordpress');?></option>
15
+ </select>
16
+ <div class="description"><?php _e("Defines the CSS to be used in the editor area.<br />Use theme css - load style.css from current site theme.<br />Define css - enter path for css file below.<br />CKEditor default - uses default CSS from editor.", 'ckeditor_wordpress') ?></div>
17
+ </td>
18
+ </tr>
19
+ <tr valign="top">
20
+ <th scope="row"><?php _e('CSS path', 'ckeditor_wordpress') ?></th>
21
+ <td>
22
+ <input type="text" name="options[css][path]" value="<?php echo htmlspecialchars($this->options['css']['path']) ?>" />
23
+ <?php if (isset($message['css_path'])): ?><span class="error"><?php echo $message['css_path'] ?></span><?php endif; ?>
24
+ <div class="description"><?php _e('Enter path to CSS file (Example: "css/editor.css") or a list of css files separated by a comma (Example: "/wp-content/themes/default/style.css,http://example.com/style.css"). Make sure to select "Define css" above.<br />Available placeholders:<br />%h - host name (/).<br />%t - path to theme.', 'ckeditor_wordpress') ?></div>
25
+ </td>
26
+ </tr>
27
+ <tr valign="top">
28
+ <th scope="row"><?php _e('Predefined styles', 'ckeditor_wordpress') ?></th>
29
+ <td>
30
+ <select name="options[css][styles]">
31
+ <option value="theme"<?php echo ($this->options['css']['styles']=='theme'?' selected="selected"':'') ?>><?php _e('Use theme ckeditor.styles.js', 'ckeditor_wordpress');?></option>
32
+ <option value="self"<?php echo ($this->options['css']['styles']=='self'?' selected="selected"':'') ?>><?php _e('Define path to ckeditor.styles.js', 'ckeditor_wordpress');?></option>
33
+ <option value="default"<?php echo ($this->options['css']['styles']=='default'?' selected="selected"':'') ?>><?php _e('CKEditor default', 'ckeditor_wordpress');?></option>
34
+ </select>
35
+ <div class="description"><?php _e('Define the location of "ckeditor.styles.js" file. It is used by the "Style" dropdown list available in the default toolbar.', 'ckeditor_wordpress') ?></div>
36
+ </td>
37
+ </tr>
38
+ <tr valign="top">
39
+ <th scope="row"><?php _e('Predefined styles path', 'ckeditor_wordpress') ?></th>
40
+ <td>
41
+ <input type="text" name="options[css][style_path]" value="<?php echo htmlspecialchars($this->options['css']['style_path']) ?>" />
42
+ <?php if (isset($message['css_style_path'])): ?><span class="error"><?php echo $message['css_style_path'] ?></span><?php endif; ?>
43
+ <div class="description"><?php _e('Enter path to file with predefined styles (Example: "/ckeditor.styles.js"). Be sure to select "define path to ckeditor.styles.js" above.<br />Available placeholders:<br />%h - host name (/).<br />%t - path to theme .', 'ckeditor_wordpress') ?></div>
44
+ </td>
45
+ </tr>
46
+ </table>
47
+ <h3><?php _e('Output Formatting', 'ckeditor_wordpress') ?></h3>
48
+ <table class="form-table">
49
+ <tr valign="top">
50
+ <th scope="row"><?php _e('Output formatting', 'ckeditor_wordpress')?><br /><span class="description">(<?php _e('Writer rules', 'ckeditor_wordpress'); ?>)</span></th>
51
+ <td>
52
+ <?php echo $this->checkbox('advanced', 'p_indent', 'indent the element contents.');?><br />
53
+ <?php echo $this->checkbox('advanced', 'p_break_before_open', 'break line before the opener tag.');?><br />
54
+ <?php echo $this->checkbox('advanced', 'p_break_after_open', 'break line after the opener tag.');?><br />
55
+ <?php echo $this->checkbox('advanced', 'p_break_before_close', 'break line before the closer tag.');?><br />
56
+ <?php echo $this->checkbox('advanced', 'p_break_after_close', 'break line after the closer tag.');?><br />
57
+ </td>
58
+ </tr>
59
+ </table>
60
+ <h3><?php _e('Advanced Options', 'ckeditor_wordpress') ?></h3>
61
+ <table class="form-table">
62
+ <tr valign="top">
63
+ <th scope="row"><?php _e('Spell checker', 'ckeditor_wordpress')?><br /></th>
64
+ <td>
65
+ <?php echo $this->checkbox('advanced', 'scayt_autoStartup', 'SCAYT auto startup.');?><br />
66
+ <div class="description"><?php _e('If enabled, turns on SCAYT (Spell Check As You Type) automatically after loading the editor.', 'ckeditor_wordpress'); ?></div>
67
+ </td>
68
+ </tr>
69
+ <tr valign="top">
70
+ <th scope="row"><?php _e('Built-in spell checker', 'ckeditor_wordpress')?></th>
71
+ <td><?php echo $this->checkbox('advanced', 'native_spell_checker', 'Enable the built-in spell checker while typing natively available in the browser.');?>
72
+ <div class="description">(<?php _e('currently Firefox and Safari only', 'ckeditor_wordpress');?>)</div></td></tr>
73
+ </tr>
74
+ <tr valign="top">
75
+ <th scope="row"><?php _e('HTML entities', 'ckeditor_wordpress')?></th>
76
+ <td><?php echo $this->checkbox('advanced', 'entities', 'Using HTML entities in the output.');?>
77
+ <div class="description">(<?php _e('Convert all applicable characters to HTML entities', 'ckeditor_wordpress');?>)</div></td></tr>
78
+ </tr>
79
+ <tr valign="top">
80
+ <th scope="row"><?php _e('Plugins', 'ckeditor_wordpress')?></th>
81
+ <td>
82
+ <?php
83
+ $plugins = apply_filters('ckeditor_external_plugins', array());
84
+ $plugins = array_keys($plugins);
85
+ $plugins[] = "autogrow";
86
+ $plugins[] = "tableresize";
87
+ sort($plugins);
88
 
89
+ foreach ($plugins as $plugin){
90
+ if ($plugin == "wpgallery" || $plugin == "wpeditimage") continue;
91
+ if (!isset($this->options['plugins'][$plugin])){
92
+ $this->options['plugins'][$plugin] = 't';
93
+ }
94
+ echo $this->checkbox('plugins', $plugin, ucfirst($plugin) . ' plugin') . '<br />';
95
+ }
96
+ ?>
97
 
98
+ <div class="description">(<?php _e('Choose the plugins which u want to load into CKEditor', 'ckeditor_wordpress');?>)</div>
99
+ </td>
100
+ </tr>
101
+ <tr valign="top">
102
+ <th scope="row"><?php _e('Load method', 'ckeditor_wordpress') ?></th>
103
+ <td>
104
+ <select name="options[advanced][load_method]">
105
+ <option value="ckeditor.js"<?php echo ($this->options['advanced']['load_method']=='ckeditor.js'?' selected="selected"':'') ?>>ckeditor.js</option>
106
+ <option value="ckeditor_basic.js"<?php echo ($this->options['advanced']['load_method']=='ckeditor_basic.js'?' selected="selected"':'') ?>>ckeditor_basic.js</option>
107
+ <?php if (file_exists(dirname(dirname(__FILE__))."/ckeditor/_source")):?>
108
+ <option value="ckeditor_source.js"<?php echo ($this->options['advanced']['load_method']=='ckeditor_source.js'?' selected="selected"':'') ?>>ckeditor_source.js (for developers only)</option>
109
+ <?php endif; ?>
110
+ </select>
111
+ <div class="description"><?php _e('Select the load method of CKEditor. If ckeditor_base.js is used, only a small file is initially loaded and the rest part of the editor is loaded later (see "Load timeout"). This might be handy if CKEditor is disabled by default.', 'ckeditor_wordpress');?><br/>
112
+ <?php _e('You can also choose loading ckeditor_source.js (for developers), but only if you download the full CKEditor package from <a href="http://ckeditor.com/download">CKEditor web site</a> and unpack it in the "ckeditor" folder. CKEditor distributed with this plugin does not contain _source files as well as the _samples folder to reduce the size of a plugin, that\'s why this option is not available by default.', 'ckeditor_wordpress') ?></div>
113
+ </td>
114
+ </tr>
115
+ <tr valign="top">
116
+ <th scope="row"><?php _e('Load timeout', 'ckeditor_wordpress')?></th>
117
+ <td>
118
+ <input type="text" name="options[advanced][load_timeout]" value="<?php echo $this->options['advanced']['load_timeout']; ?>"/>s
119
+ <?php if (isset($message['advanced_load_timeout'])): ?><span class="error"><?php echo $message['advanced_load_timeout'] ?></span><?php endif; ?>
120
+ <div class="description"><?php _e('The time to wait (in seconds) to load the full editor code after the page load, if the "ckeditor_basic.js" file is used. If set to zero, the editor is loaded on demand.', 'ckeditor_wordpress') ?></div>
121
+ </td>
122
+ </tr>
123
+ <?php
124
+ $langs = apply_filters('ckeditor_load_lang_options', array());
125
+ ?>
126
+ <tr valign="top">
127
+ <th scope="row"><?php _e('Language', 'ckeditor_wordpress')?></th>
128
+ <td>
129
+ <?php
130
+ if (isset($this->options['advanced']['language']))
131
+ {
132
+ $selected = $this->options['advanced']['language'];
133
+ }else{
134
+ $selected = (get_locale())? get_locale() : 'en';
135
+ }
136
+ ?>
137
+ <select name="options[advanced][language]">
138
+ <?php foreach ($langs AS $key => $lang): ?>
139
+ <option value="<?php echo $key?>" <?php if($key == $selected):?>selected="selected"<?php endif;?>><?php echo $lang ?></option>
140
+ <?php endforeach; ?>
141
+ </select>
142
+ <br /><span class="description"><?php _e('The language for the CKEditor user interface.', 'ckeditor_wordpress'); ?></span>
143
+ <?php if (isset($message['advanced_language'])): ?><span class="error"><?php echo $message['advanced_language'] ?></span><?php endif; ?>
144
+ </td>
145
+ </tr>
146
+ <?php
147
+ if (isset($this->options['advanced']['detect_language_auto']))
148
+ {
149
+ $auto = $this->options['advanced']['detect_language_auto'];
150
+ } else {
151
+ $auto = 't';
152
+ }
153
+ ?>
154
+ <tr valign="top">
155
+ <th scope="row"><?php _e('Auto-detect language', 'ckeditor_wordpress')?></th>
156
+ <td>
157
+ <input id="autodetect_enabled" name="options[advanced][detect_language_auto]" type="radio" value="t" <?php if($auto == 't'):?>checked="checked"<?php endif; ?>><label for="autodetect_enabled">Enabled</label> <br/>
158
+ <input id="autodetect_disabled" name="options[advanced][detect_language_auto]" type="radio" value="f" <?php if($auto == 'f'):?>checked="checked"<?php endif; ?>><label for="autodetect_disabled"> Disabled</label>
159
+ <br /><span class="description"><?php _e('Automatically detect the user language.', 'ckeditor_wordpress'); ?></span>
160
+ <?php if (isset($message['advanced_detect_language_auto'])): ?><br/><span class="error"><?php echo $message['advanced_detect_language_auto'] ?></span><?php endif; ?>
161
+ </td>
162
+ </tr>
163
+ <tr valign="top">
164
+ <th scope="row"><?php _e('Language direction ', 'ckeditor_wordpress')?></th>
165
+ <td>
166
+ <?php
167
+ if (isset($this->options['advanced']['language_direction']))
168
+ {
169
+ $selected = $this->options['advanced']['language_direction'];
170
+ }else{
171
+ $selected = 'default';
172
+ }
173
+ ?>
174
+ <select name="options[advanced][language_direction]">
175
+ <option value="default" <?php if($selected == 'default'):?>selected="selected"<?php endif;?>>Get from current locale (default)</option>
176
+ <option value="ltr" <?php if($selected == 'ltr'):?>selected="selected"<?php endif;?>>Left-To-Right</option>
177
+ <option value="rtl" <?php if($selected == 'rtl'):?>selected="selected"<?php endif;?>>Right-To-Left</option>
178
+ </select>
179
+ <br /><span class="description"><?php _e('Choose the language direction used in the editing area. Even when CKEditor automatically detects the user language and adjusts its user interface, the editing area is not automatically changed into the LTR or RTL mode. To be able to type LTR (like English) and RTL (like Arabic, Hebrew, Persian) content at the same time, please make sure that the BidiLtr and BidiRtl buttons are enabled in the toolbar.', 'ckeditor_wordpress'); ?></span>
180
+ <?php if (isset($message['advanced_language_direction'])): ?><span class="error"><?php echo $message['advanced_language_dierction'] ?></span><?php endif; ?>
181
+ </td>
182
+ </tr>
183
+ </table>
184
+ <p class="submit">
185
+ <input type="hidden" name="df_submit" value="1" />
186
+ <input type="submit" class="button-primary" value="Update Options" name="submit_update" />
187
+ </p>
188
+ </form>
 
189
  </div>
includes/ckeditor.utils.js CHANGED
@@ -1,361 +1,389 @@
1
- /*
2
  Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
3
  For licensing, see LICENSE.html or http://ckeditor.com/license
4
  */
5
  var editorCKE;
6
  jQuery(document).ready(function () {
7
- ckeditorSettings.configuration['on'] = {
8
- configLoaded : function ( evt ) {
9
- if (typeof(ckeditorSettings.externalPlugins) != 'undefined') {
10
- var externals=new Array();
11
- for(var x in ckeditorSettings.externalPlugins) {
12
- CKEDITOR.plugins.addExternal(x, ckeditorSettings.externalPlugins[x]);
13
- externals.push(x);
14
- }
15
- }
16
- evt.editor.config.extraPlugins += (evt.editor.config.extraPlugins ? ','+externals.join(',') : externals.join(','));
17
- if (typeof(ckeditorSettings.additionalButtons) != 'undefined') {
18
- for (var x in ckeditorSettings.additionalButtons) {
19
- evt.editor.config['toolbar_' + evt.editor.config.toolbar].push(ckeditorSettings.additionalButtons[x]);
20
- }
21
- }
22
- }
23
- };
24
- CKEDITOR.on( 'instanceReady', function( ev )
25
- {
26
- var dtd = CKEDITOR.dtd;
27
- for ( var e in CKEDITOR.tools.extend( {}, dtd.$nonBodyContent, dtd.$block, dtd.$listItem, dtd.$tableContent ) )
28
- {
29
- ev.editor.dataProcessor.writer.setRules( e, ckeditorSettings.outputFormat);
30
- }
31
- ev.editor.dataProcessor.writer.setRules( 'br',
32
- {
33
- breakAfterOpen : true
34
- });
35
- ev.editor.dataProcessor.writer.setRules( 'pre',
36
- {
37
- indent: false
38
- });
39
- editorCKE = CKEDITOR.instances['content'];
40
- });
41
 
42
- if(ckeditorSettings.textarea_id != 'comment'){
43
- edInsertContentOld = function () { return ; };
44
- if(typeof(window.edInsertContent) != 'undefined'){
45
- edInsertContentOld = window.edInsertContent;
46
- }
47
- window.edInsertContent = function (myField, myValue) {
48
- if(typeof(CKEDITOR) != 'undefined' && typeof(editorCKE) != 'undefined'){
49
- editorCKE.insertHtml(myValue);
50
- } else {
51
- edInsertContentOld(myField, myValue);
52
- }
53
- };
54
- var autosaveOld = function () { return ; };
55
- if(typeof(window.autosave) != 'undefined'){
56
- autosaveOld = window.autosave;
57
- }
 
 
 
 
58
 
59
- if(typeof(window.switchEditors) != 'undefined') {
60
- window.switchEditors.go = function(id, mode) {
61
- if ('tinymce' == mode) {
62
- ckeditorOn(id);
63
- } else {
64
- ckeditorOff(id);
65
- jQuery('.js .theEditor').attr('style', 'color: black;');
66
- }
67
- };
68
- }
69
- }
70
- if ( ckeditorSettings.qtransEnabled ){
 
 
71
 
72
- jQuery('#edButtonHTML').addClass('active');
73
- jQuery('#edButtonPreview').removeClass('active');
74
- if(ckeditorSettings.textarea_id != 'comment'){
75
 
76
- ckeditorSettings.textarea_id = 'qtrans_textarea_content';
77
- ckeditorSettings.configuration['on'].getData = function (evt) {
78
- evt.data.dataValue = evt.data.dataValue.replace(/(^<\/p>)|(<p>$)/g, '');
79
- evt.data.dataValue = evt.data.dataValue.replace(/^<p>(\s|\n|\r)*<p>/g, '<p>');
80
- evt.data.dataValue = evt.data.dataValue.replace(/<\/p>(\s|\n|\r)*<\/p>(\s|\n|\r)*$/g, '<\/p>');
81
- qtrans_save(evt.data.dataValue);
82
- };
83
- if ( jQuery('#'+ckeditorSettings.textarea_id).length && typeof CKEDITOR.instances[ckeditorSettings.textarea_id] == 'undefined' ) {
84
- CKEDITOR.replace(ckeditorSettings.textarea_id, ckeditorSettings.configuration);
85
- editorCKE = CKEDITOR.instances[ckeditorSettings.textarea_id];
86
- }
87
 
88
- window.tinyMCE = tinymce = getTinyMCEObject();
89
- }
90
- }
91
- else {
92
- if(ckeditorSettings.autostart && (typeof getUserSetting == 'undefined' || getUserSetting('editor') === '' || getUserSetting('editor') == 'tinymce')){
93
- ckeditorOn();
94
- }
95
- }
96
 
97
- jQuery("#update-gallery").click(function(){
98
- updateCkeGallery();
99
- });
100
 
101
  });
102
  function ckeditorOn(id) {
103
- if (typeof(id) != 'undefined' && typeof(CKEDITOR.instances[id]) == 'undefined' )
104
- {
105
- setUserSetting( 'editor', 'tinymce' );
106
- jQuery('#quicktags').hide();
107
- jQuery('#edButtonPreview').addClass('active');
108
- jQuery('#edButtonHTML').removeClass('active');
109
- CKEDITOR.replace(id, ckeditorSettings.configuration);
110
- if (typeof ckeditorSettings.configuration['extraCss'] != 'undefined')
111
- {
112
- CKEDITOR.instances[id].addCss(ckeditorSettings.configuration['extraCss']);
113
- }
114
- }
115
- if ( jQuery('#'+ckeditorSettings.textarea_id).length && (typeof(CKEDITOR.instances) == 'undefined' || typeof(CKEDITOR.instances[ckeditorSettings.textarea_id]) == 'undefined' ) && jQuery("#"+ckeditorSettings.textarea_id).parent().parent().attr('id') != 'quick-press') {
116
- CKEDITOR.replace(ckeditorSettings.textarea_id, ckeditorSettings.configuration);
117
- if (typeof ckeditorSettings.configuration['extraCss'] != 'undefined')
118
- {
119
- CKEDITOR.instances[ckeditorSettings.textarea_id].addCss(ckeditorSettings.configuration['extraCss']);
120
- }
121
- if(ckeditorSettings.textarea_id == 'content') {
122
- setUserSetting( 'editor', 'tinymce' );
123
- jQuery('#quicktags').hide();
124
- jQuery('#edButtonPreview').addClass('active');
125
- jQuery('#edButtonHTML').removeClass('active');
126
- }
127
- else if(ckeditorSettings.textarea_id == 'comment') {
128
- var labelObj = jQuery('#'+ckeditorSettings.textarea_id).prev('label');
129
- if (labelObj){
130
- labelObj.hide();
131
- }
132
- }
133
- }
134
  }
135
 
136
  function ckeditorOff(id) {
137
- if (typeof(id) != 'undefined')
138
- {
139
- editorCKE = CKEDITOR.instances[id];
140
- }else
141
- {
142
- editorCKE = CKEDITOR.instances[ckeditorSettings.textarea_id];
143
- }
144
- if(typeof(editorCKE) != 'undefined'){
145
- editorCKE.destroy();
146
- if(ckeditorSettings.textarea_id == 'content') {
147
- setUserSetting( 'editor', 'html' );
148
- jQuery('#quicktags').show();
149
- jQuery('#edButtonHTML').addClass('active');
150
- jQuery('#edButtonPreview').removeClass('active');
151
- }
152
- }
153
  }
154
 
155
  if ( !ckeditorSettings.qtransEnabled ){
156
- var tinymce = window.tinyMCE = getTinyMCEObject();
157
  }
158
  function getTinyMCEObject()
159
  {
160
- var tinymce = window.tinyMCE = (function () {
161
- var tinyMCE = {
162
- get : function (id) {
163
- var instant = {
164
- isHidden : function (){
165
- editor = CKEDITOR.instances[id];
166
- if (typeof editorCKE == 'undefined') editorCKE = editor;
167
- if(typeof(editor) != 'undefined')
168
- {
169
- return false;
170
- }else{
171
- return true;
172
- }
173
- },
174
- isDirty : function (){return false;},
175
- execCommand : function (command, integer, val) {
176
- if(command == 'mceSetContent') {
177
- editorCKE.setData(val);
178
- }
179
- if (command == 'mceInsertContent')
180
- {
181
- editorCKE.insertHtml(val);
182
- }
183
- },
184
- onSaveContent : {
185
- add : function (func) {
186
- window.tinymceosc = func;
187
- }
188
- },
189
- getContentAreaContainer : function () {
190
- return {
191
- offsetHeight : editorCKE.config.height
192
- };
193
- },
194
- hide : function () {
195
- ckeditorOff(id);
196
- },
197
- show : function () {
198
- ckeditorOn(id);
199
- },
200
- save : function(){return;},
201
- focus : function(){return;},
202
- plugins: {}
203
- };
 
 
 
 
 
 
204
 
205
- return instant;
206
- },
207
- execCommand : function (command, integer, val) {
208
- if(command == 'mceAddControl'){
209
- ckeditorSettings.textarea_id = val;
210
- if(ckeditorSettings.autostart) {
211
- ckeditorOn();
212
- } else {
213
- document.getElementById('qtrans_textarea_content').removeAttribute('style');
214
- }
215
- }
216
- },
217
- triggerSave : function(param) {
218
- if(typeof(CKEDITOR) != 'undefined' && typeof(editorCKE) != 'undefined')
219
- editorCKE.updateElement();
220
- },
221
- activeEditor : {
222
- isHidden : function (){return false;},
223
- isDirty : function (){return false;},
224
- focus : function (){return;},
225
- plugins : {},
226
- execCommand : function(command, state, text)
227
- {
228
- if (command == "mceInsertContent")
229
- {
230
- pattern = /(\[caption.+\])/ig;
231
- if (pattern.test(text))
232
- {
233
- text = text.replace(/&gt;/g, '>');
234
- text = text.replace(/&lt;/g, '<');
235
- pattern = /(<[\w'"=\s]+>([\S\s]+)<\/\S+>)/ig;
236
- text= text.replace(pattern, function(match, cont)
237
- {
238
- cont = cont.replace(/<[\w'"=\s]+>([\S\s]+)<\/\S+>/ig, function(match, cont){
239
- return cont;
240
- });
241
- return cont;
242
- });
243
- text = text.replace(/<br\/>|<br>|<br \>|<br \/ >|<br\/ >/i,'');
244
- text = text.replace(/"/i,'&quot;');
245
- }
 
 
 
 
 
 
246
 
247
- //setTimeout is required in IE8 when inserting Image gallery from an external modal dialog
248
- if (typeof editorCKE == 'undefined') editorCKE = CKEDITOR.instances[ckeditorSettings.textarea_id];
249
- setTimeout(function(){editorCKE.insertHtml(text);}, 0);
250
- }
251
- },
252
- selection : {
253
- getBookmark : function(name) {return '';}
254
- },
255
- windowManager : {
256
- bookmark: {}
257
- }
258
- },
259
- EditorManager :{
260
- activeEditor: {
261
- selection : {
262
- getNode : function(){
263
- var obj = jQuery(editorCKE.document.getBody().getHtml());
264
- var index = 0;
265
- jQuery.each(obj,function(i, val){
266
- var images = jQuery("img",jQuery(val));
267
- jQuery.each(images, function(key, value){
268
- if (jQuery(value).hasClass('wpGallery, cke_wpgallery'))
269
- {
270
- index = i;
271
- return;
272
- }
273
- });
274
- });
275
- if (obj.length === 0)
276
- {
277
- obj = document.createElement("p");
278
- return obj;
279
- }
280
- return obj[index];
281
- },
282
- getBookmark : function(name) {return ;}
283
- },
284
- dom :{
285
- select : function(selector) {
 
 
 
 
 
 
286
 
287
- //get CKEditor content
288
- var obj = editorCKE.document.getBody().getHtml();
289
- images = editorCKE.document.getElementsByTag('img');
290
- if ( typeof images.$ == 'undefined' || images.$.length == 0) return [];
291
- for (var i in images.$)
292
- {
293
- if ( typeof images.$[i] != 'undefined' && ((CKEDITOR.env.ie && images.$[i].className == 'wpGallery, cke_wpgallery') || images.$[i].classList == 'wpGallery, cke_wpgallery'))
294
- {
295
- var element = new CKEDITOR.dom.element(images.$[i]);
296
- index = i;
297
- break;
298
- }
299
- }
300
- var results =[];
301
 
302
- if (typeof element != 'undefined')
303
- {
304
- results[0] = images.$[index];
305
- return results;
306
 
307
- }else
308
- {
309
- return [];
310
- }
311
- },
312
- getAttrib : function(el, selector)
313
- {
314
- return jQuery(el).attr(selector);
315
- },
316
- //function to set new gallery attributes
317
- setAttrib : function(el, selector, value)
318
- {
319
- //get CKEditor content
320
- var obj = editorCKE.document.getBody().getHtml();
321
- images = editorCKE.document.getElementsByTag('img');
322
- for (var i in images.$)
323
- {
324
- if ( typeof images.$[i] != 'undefined' && ((CKEDITOR.env.ie && images.$[i].className == 'wpGallery, cke_wpgallery') || images.$[i].classList == 'wpGallery, cke_wpgallery'))
325
- {
326
- var element = new CKEDITOR.dom.element(images.$[i]);
327
- element.setAttribute('title', value);
328
- element.setAttribute('data-gallery', '['+value+']');
329
- }
330
- }
331
- },
332
- decode : function(text) {return text;},
333
- hasClass : function(element, name)
334
- {
335
- var hasClass = jQuery(element).attr('class');
336
- var pattern = /wpGallery/;
337
- return pattern.test(hasClass);
338
- }
339
- }
340
- }
341
- },
342
- addI18n : function(language, param){
343
- return ;
344
- }
345
- };
346
- return tinyMCE;
347
- })();
348
- return tinymce;
 
 
349
  }
350
  var tinyMCEPreInit = {
351
- mceInit : function(){
352
- language : 'en';
353
- }
354
 
355
  };
356
  //function to move cursor after fake gallery image. Turn on frame show
357
  function updateCkeGallery()
358
  {
359
- jQuery("#add_image").unbind('click');
360
- jQuery("#add_image").bind('click',function(){return true;});
 
 
361
  }
1
+ /*
2
  Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
3
  For licensing, see LICENSE.html or http://ckeditor.com/license
4
  */
5
  var editorCKE;
6
  jQuery(document).ready(function () {
7
+ ckeditorSettings.configuration['on'] = {
8
+ configLoaded : function ( evt ) {
9
+ if (typeof(ckeditorSettings.externalPlugins) != 'undefined') {
10
+ var externals=new Array();
11
+ for(var x in ckeditorSettings.externalPlugins) {
12
+ CKEDITOR.plugins.addExternal(x, ckeditorSettings.externalPlugins[x]);
13
+ externals.push(x);
14
+ }
15
+ }
16
+ evt.editor.config.extraPlugins += (evt.editor.config.extraPlugins ? ','+externals.join(',') : externals.join(','));
17
+ if (typeof(ckeditorSettings.additionalButtons) != 'undefined') {
18
+ for (var x in ckeditorSettings.additionalButtons) {
19
+ evt.editor.config['toolbar_' + evt.editor.config.toolbar].push(ckeditorSettings.additionalButtons[x]);
20
+ }
21
+ }
22
+ }
23
+ };
24
+ CKEDITOR.on( 'instanceReady', function( ev )
25
+ {
26
+ var dtd = CKEDITOR.dtd;
27
+ for ( var e in CKEDITOR.tools.extend( {}, dtd.$nonBodyContent, dtd.$block, dtd.$listItem, dtd.$tableContent ) )
28
+ {
29
+ ev.editor.dataProcessor.writer.setRules( e, ckeditorSettings.outputFormat);
30
+ }
31
+ ev.editor.dataProcessor.writer.setRules( 'br',
32
+ {
33
+ breakAfterOpen : true
34
+ });
35
+ ev.editor.dataProcessor.writer.setRules( 'pre',
36
+ {
37
+ indent: false
38
+ });
39
+ editorCKE = CKEDITOR.instances['content'];
40
+ });
41
 
42
+ if(ckeditorSettings.textarea_id != 'comment'){
43
+ edInsertContentOld = function () {
44
+ return ;
45
+ };
46
+ if(typeof(window.edInsertContent) != 'undefined'){
47
+ edInsertContentOld = window.edInsertContent;
48
+ }
49
+ window.edInsertContent = function (myField, myValue) {
50
+ if(typeof(CKEDITOR) != 'undefined' && typeof(editorCKE) != 'undefined'){
51
+ editorCKE.insertHtml(myValue);
52
+ } else {
53
+ edInsertContentOld(myField, myValue);
54
+ }
55
+ };
56
+ var autosaveOld = function () {
57
+ return ;
58
+ };
59
+ if(typeof(window.autosave) != 'undefined'){
60
+ autosaveOld = window.autosave;
61
+ }
62
 
63
+ if(typeof(window.switchEditors) != 'undefined') {
64
+ window.switchEditors.go = function(id, mode) {
65
+ if ('tinymce' == mode || 'tmce' == mode) {
66
+ jQuery('#'+id).closest('.html-active').removeClass('html-active').addClass('tmce-active');
67
+ ckeditorOn(id);
68
+ } else {
69
+ jQuery('#'+id).closest('.tmce-active').removeClass('tmce-active').addClass('html-active');
70
+ ckeditorOff(id);
71
+ jQuery('.js .theEditor').attr('style', 'color: black;');
72
+ }
73
+ };
74
+ }
75
+ }
76
+ if ( ckeditorSettings.qtransEnabled ){
77
 
78
+ jQuery('#edButtonHTML').addClass('active');
79
+ jQuery('#edButtonPreview').removeClass('active');
80
+ if(ckeditorSettings.textarea_id != 'comment'){
81
 
82
+ ckeditorSettings.textarea_id = 'qtrans_textarea_content';
83
+ ckeditorSettings.configuration['on'].getData = function (evt) {
84
+ evt.data.dataValue = evt.data.dataValue.replace(/(^<\/p>)|(<p>$)/g, '');
85
+ evt.data.dataValue = evt.data.dataValue.replace(/^<p>(\s|\n|\r)*<p>/g, '<p>');
86
+ evt.data.dataValue = evt.data.dataValue.replace(/<\/p>(\s|\n|\r)*<\/p>(\s|\n|\r)*$/g, '<\/p>');
87
+ qtrans_save(evt.data.dataValue);
88
+ };
89
+ if ( jQuery('#'+ckeditorSettings.textarea_id).length && typeof CKEDITOR.instances[ckeditorSettings.textarea_id] == 'undefined' ) {
90
+ CKEDITOR.replace(ckeditorSettings.textarea_id, ckeditorSettings.configuration);
91
+ editorCKE = CKEDITOR.instances[ckeditorSettings.textarea_id];
92
+ }
93
 
94
+ window.tinyMCE = tinymce = getTinyMCEObject();
95
+ }
96
+ }
97
+ else {
98
+ if(ckeditorSettings.autostart && (typeof getUserSetting == 'undefined' || getUserSetting('editor') === '' || getUserSetting('editor') == 'tinymce')){
99
+ ckeditorOn();
100
+ }
101
+ }
102
 
103
+ jQuery("#update-gallery").click(function(){
104
+ updateCkeGallery();
105
+ });
106
 
107
  });
108
  function ckeditorOn(id) {
109
+ if (typeof(id) != 'undefined' && typeof(CKEDITOR.instances[id]) == 'undefined' )
110
+ {
111
+ setUserSetting( 'editor', 'tinymce' );
112
+ jQuery('#quicktags').hide();
113
+ jQuery('#edButtonPreview').addClass('active');
114
+ jQuery('#edButtonHTML').removeClass('active');
115
+ CKEDITOR.replace(id, ckeditorSettings.configuration);
116
+ if (typeof ckeditorSettings.configuration['extraCss'] != 'undefined')
117
+ {
118
+ CKEDITOR.instances[id].addCss(ckeditorSettings.configuration['extraCss']);
119
+ }
120
+ }
121
+ if ( jQuery('textarea#'+ckeditorSettings.textarea_id).length && (typeof(CKEDITOR.instances) == 'undefined' || typeof(CKEDITOR.instances[ckeditorSettings.textarea_id]) == 'undefined' ) && jQuery("#"+ckeditorSettings.textarea_id).parent().parent().attr('id') != 'quick-press') {
122
+ CKEDITOR.replace(ckeditorSettings.textarea_id, ckeditorSettings.configuration);
123
+ if (typeof ckeditorSettings.configuration['extraCss'] != 'undefined')
124
+ {
125
+ CKEDITOR.instances[ckeditorSettings.textarea_id].addCss(ckeditorSettings.configuration['extraCss']);
126
+ }
127
+ if(ckeditorSettings.textarea_id == 'content') {
128
+ setUserSetting( 'editor', 'tinymce' );
129
+ jQuery('#quicktags').hide();
130
+ jQuery('#edButtonPreview').addClass('active');
131
+ jQuery('#edButtonHTML').removeClass('active');
132
+ }
133
+ else if(ckeditorSettings.textarea_id == 'comment') {
134
+ var labelObj = jQuery('#'+ckeditorSettings.textarea_id).prev('label');
135
+ if (labelObj){
136
+ labelObj.hide();
137
+ }
138
+ }
139
+ }
140
  }
141
 
142
  function ckeditorOff(id) {
143
+ if (typeof(id) != 'undefined')
144
+ {
145
+ editorCKE = CKEDITOR.instances[id];
146
+ }else
147
+ {
148
+ editorCKE = CKEDITOR.instances[ckeditorSettings.textarea_id];
149
+ }
150
+ if(typeof(editorCKE) != 'undefined'){
151
+ editorCKE.destroy();
152
+ if(ckeditorSettings.textarea_id == 'content') {
153
+ setUserSetting( 'editor', 'html' );
154
+ jQuery('#quicktags').show();
155
+ jQuery('#edButtonHTML').addClass('active');
156
+ jQuery('#edButtonPreview').removeClass('active');
157
+ }
158
+ }
159
  }
160
 
161
  if ( !ckeditorSettings.qtransEnabled ){
162
+ var tinymce = window.tinyMCE = getTinyMCEObject();
163
  }
164
  function getTinyMCEObject()
165
  {
166
+ var tinymce = window.tinyMCE = (function () {
167
+ var tinyMCE = {
168
+ get : function (id) {
169
+ var instant = {
170
+ isHidden : function (){
171
+ editor = CKEDITOR.instances[id];
172
+ if (typeof editorCKE == 'undefined') editorCKE = editor;
173
+ if(typeof(editor) != 'undefined')
174
+ {
175
+ return false;
176
+ }else{
177
+ return true;
178
+ }
179
+ },
180
+ isDirty : function (){
181
+ return false;
182
+ },
183
+ execCommand : function (command, integer, val) {
184
+ if(command == 'mceSetContent') {
185
+ editorCKE.setData(val);
186
+ }
187
+ if (command == 'mceInsertContent')
188
+ {
189
+ editorCKE.insertHtml(val);
190
+ }
191
+ },
192
+ onSaveContent : {
193
+ add : function (func) {
194
+ window.tinymceosc = func;
195
+ }
196
+ },
197
+ getContentAreaContainer : function () {
198
+ return {
199
+ offsetHeight : editorCKE.config.height
200
+ };
201
+ },
202
+ hide : function () {
203
+ ckeditorOff(id);
204
+ },
205
+ show : function () {
206
+ ckeditorOn(id);
207
+ },
208
+ save : function(){
209
+ return;
210
+ },
211
+ focus : function(){
212
+ return;
213
+ },
214
+ plugins: {}
215
+ };
216
 
217
+ return instant;
218
+ },
219
+ execCommand : function (command, integer, val) {
220
+ if(command == 'mceAddControl'){
221
+ ckeditorSettings.textarea_id = val;
222
+ if(ckeditorSettings.autostart) {
223
+ ckeditorOn();
224
+ } else {
225
+ document.getElementById('qtrans_textarea_content').removeAttribute('style');
226
+ }
227
+ }
228
+ },
229
+ triggerSave : function(param) {
230
+ if(typeof(CKEDITOR) != 'undefined' && typeof(editorCKE) != 'undefined')
231
+ editorCKE.updateElement();
232
+ },
233
+ activeEditor : {
234
+ isHidden : function (){
235
+ return false;
236
+ },
237
+ isDirty : function (){
238
+ return false;
239
+ },
240
+ focus : function (){
241
+ return;
242
+ },
243
+ plugins : {},
244
+ execCommand : function(command, state, text)
245
+ {
246
+ if (command == "mceInsertContent")
247
+ {
248
+ pattern = /(\[caption.+\])/ig;
249
+ if (pattern.test(text))
250
+ {
251
+ text = text.replace(/&gt;/g, '>');
252
+ text = text.replace(/&lt;/g, '<');
253
+ pattern = /(<[\w'"=\s]+>([\S\s]+)<\/\S+>)/ig;
254
+ text= text.replace(pattern, function(match, cont)
255
+ {
256
+ cont = cont.replace(/<[\w'"=\s]+>([\S\s]+)<\/\S+>/ig, function(match, cont){
257
+ return cont;
258
+ });
259
+ return cont;
260
+ });
261
+ text = text.replace(/<br\/>|<br>|<br \>|<br \/ >|<br\/ >/i,'');
262
+ text = text.replace(/"/i,'&quot;');
263
+ }
264
 
265
+ //setTimeout is required in IE8 when inserting Image gallery from an external modal dialog
266
+ if (typeof editorCKE == 'undefined') editorCKE = CKEDITOR.instances[ckeditorSettings.textarea_id];
267
+ setTimeout(function(){
268
+ editorCKE.insertHtml(text);
269
+ }, 0);
270
+ }
271
+ },
272
+ selection : {
273
+ getBookmark : function(name) {
274
+ return '';
275
+ }
276
+ },
277
+ windowManager : {
278
+ bookmark: {}
279
+ }
280
+ },
281
+ EditorManager :{
282
+ activeEditor: {
283
+ selection : {
284
+ getNode : function(){
285
+ var obj = jQuery(editorCKE.document.getBody().getHtml());
286
+ var index = 0;
287
+ jQuery.each(obj,function(i, val){
288
+ var images = jQuery("img",jQuery(val));
289
+ jQuery.each(images, function(key, value){
290
+ if (jQuery(value).hasClass('wpGallery, cke_wpgallery'))
291
+ {
292
+ index = i;
293
+ return;
294
+ }
295
+ });
296
+ });
297
+ if (obj.length === 0)
298
+ {
299
+ obj = document.createElement("p");
300
+ return obj;
301
+ }
302
+ return obj[index];
303
+ },
304
+ getBookmark : function(name) {
305
+ return ;
306
+ }
307
+ },
308
+ dom :{
309
+ select : function(selector) {
310
 
311
+ //get CKEditor content
312
+ var obj = editorCKE.document.getBody().getHtml();
313
+ images = editorCKE.document.getElementsByTag('img');
314
+ if ( typeof images.$ == 'undefined' || images.$.length == 0) return [];
315
+ for (var i in images.$)
316
+ {
317
+ if ( typeof images.$[i] != 'undefined' && ((CKEDITOR.env.ie && images.$[i].className == 'wpGallery, cke_wpgallery') || images.$[i].classList == 'wpGallery, cke_wpgallery'))
318
+ {
319
+ var element = new CKEDITOR.dom.element(images.$[i]);
320
+ index = i;
321
+ break;
322
+ }
323
+ }
324
+ var results =[];
325
 
326
+ if (typeof element != 'undefined')
327
+ {
328
+ results[0] = images.$[index];
329
+ return results;
330
 
331
+ }else
332
+ {
333
+ return [];
334
+ }
335
+ },
336
+ getAttrib : function(el, selector)
337
+ {
338
+ return jQuery(el).attr(selector);
339
+ },
340
+ //function to set new gallery attributes
341
+ setAttrib : function(el, selector, value)
342
+ {
343
+ //get CKEditor content
344
+ var obj = editorCKE.document.getBody().getHtml();
345
+ images = editorCKE.document.getElementsByTag('img');
346
+ for (var i in images.$)
347
+ {
348
+ if ( typeof images.$[i] != 'undefined' && ((CKEDITOR.env.ie && images.$[i].className == 'wpGallery, cke_wpgallery') || images.$[i].classList == 'wpGallery, cke_wpgallery'))
349
+ {
350
+ var element = new CKEDITOR.dom.element(images.$[i]);
351
+ element.setAttribute('title', value);
352
+ element.setAttribute('data-gallery', '['+value+']');
353
+ }
354
+ }
355
+ },
356
+ decode : function(text) {
357
+ return text;
358
+ },
359
+ hasClass : function(element, name)
360
+ {
361
+ var hasClass = jQuery(element).attr('class');
362
+ var pattern = /wpGallery/;
363
+ return pattern.test(hasClass);
364
+ }
365
+ }
366
+ }
367
+ },
368
+ addI18n : function(language, param){
369
+ return ;
370
+ }
371
+ };
372
+ return tinyMCE;
373
+ })();
374
+ return tinymce;
375
  }
376
  var tinyMCEPreInit = {
377
+ mceInit : function(){
378
+ language : 'en';
379
+ }
380
 
381
  };
382
  //function to move cursor after fake gallery image. Turn on frame show
383
  function updateCkeGallery()
384
  {
385
+ jQuery("#add_image").unbind('click');
386
+ jQuery("#add_image").bind('click',function(){
387
+ return true;
388
+ });
389
  }
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === CKEditor For WordPress ===
2
  Contributors: wiktor, michal_cksource, dczepierga, Dean Lee
3
  Tags: post, wysiwyg, CKEditor, FCKeditor, editor, rich text, rte, rich text editor
4
- Requires at least: 2.0
5
- Tested up to: 3.2
6
- Stable tag: 3.6.2.3
7
  This plugin replaces the default WordPress editor with <a href="http://ckeditor.com/">CKEditor</a>.
8
 
9
  == Description ==
@@ -57,6 +57,11 @@ Features:
57
 
58
  == Changelog ==
59
 
 
 
 
 
 
60
  = V3.6.2.3 - 01.12.2011 =
61
 
62
  * This version of CKEditor for WordPress was released due to some issues with upgrading the plugin to version 3.6.2.2. The problem is now fixed.
1
  === CKEditor For WordPress ===
2
  Contributors: wiktor, michal_cksource, dczepierga, Dean Lee
3
  Tags: post, wysiwyg, CKEditor, FCKeditor, editor, rich text, rte, rich text editor
4
+ Requires at least: 3.2
5
+ Tested up to: 3.3
6
+ Stable tag: 3.6.2.4
7
  This plugin replaces the default WordPress editor with <a href="http://ckeditor.com/">CKEditor</a>.
8
 
9
  == Description ==
57
 
58
  == Changelog ==
59
 
60
+ = V3.6.2.4 - 13.12.2011 =
61
+
62
+ * Fix problems with upgrade and working correctly in new Wordpress 3.3 “Sonny”.
63
+ * Fix problem with loading CKEditor inside element with id 'content' which is not textarea.
64
+
65
  = V3.6.2.3 - 01.12.2011 =
66
 
67
  * This version of CKEditor for WordPress was released due to some issues with upgrading the plugin to version 3.6.2.2. The problem is now fixed.