Permalink
Browse files

Ckeditor for Wordpress release 3.6.2.2

  • Loading branch information...
Michal Kesicki
Michal Kesicki committed Nov 29, 2011
1 parent 1587a0d commit ca7c2f9fd5701bffc965ede5bc570a749dbc705c
View
@@ -1,6 +1,6 @@
<?php
class ckeditor_wordpress {
var $version = '3.6.2.1';
var $version = '3.6.2.2';
var $default_options = array();
var $options = array();
var $ckeditor_path = "";
@@ -15,9 +15,19 @@ function ckeditor_wordpress()
function __construct()
{
$siteurl = trailingslashit(get_option('siteurl'));
$this->plugin_path = $siteurl .'wp-content/plugins/' . basename(dirname(__FILE__)) .'/';
define('CKEDITOR_PLUGIN_URL', $this->plugin_path);
$this->ckeditor_path = $siteurl .'wp-content/plugins/' . basename(dirname(__FILE__)) .'/ckeditor/';
if (DEFINED('WP_PLUGIN_URL'))
{
$this->plugin_path = WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)) .'/';
}
else if (DEFINED('WP_PLUGIN_DIR')){
$this->plugin_path = $siteurl .'/'. WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__)) .'/';
}
else{
$this->plugin_path = $siteurl .'wp-content/plugins/' . basename(dirname(__FILE__)) .'/';
}
define('CKEDITOR_PLUGIN_URL', $this->plugin_path_url);
$this->ckeditor_path = $this->plugin_path .'ckeditor/';
$this->editable_files = array(
'ckeditor.config.js' => dirname(__FILE__).'/ckeditor.config.js',
'ckeditor.styles.js' => dirname(__FILE__).'/ckeditor.styles.js',
@@ -283,7 +293,7 @@ function plugin_overview()
$ckeditor_plugin_version = $this->version;
$ckfinder_status = $this->ckfinder_status();
if(isset($_POST['reset']) && $_POST['reset']==1){
if (! wp_verify_nonce($_POST['csrf_ckeditor-for-wordpress'], 'ckeditor_create_nonce_overview') || empty($_POST['_wp_http_referer']) || !strstr( $_SERVER['HTTP_REFERER'], $_POST['_wp_http_referer']) ) wp_die("You do not have sufficient permissions to access this page.");
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.");
update_option('ckeditor_wordpress', $this->default_options);
$this->options = $this->default_options;
echo '<div class="updated"><p>' . __('Configuration updated!') . '</p></div>';
@@ -297,7 +307,7 @@ function option_page()
if (!empty($_POST['submit_update'])) {
$message=array();
/* validation */
if (! wp_verify_nonce($_POST['csrf_ckeditor-for-wordpress'], 'ckeditor_create_nonce_basic') || empty($_POST['_wp_http_referer']) || !strstr( $_SERVER['HTTP_REFERER'], $_POST['_wp_http_referer']) ) wp_die("You do not have sufficient permissions to access this page.");
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.");
$new_options=$_POST['options'];
$new_options['appearance']['comment_editor']=(isset($_POST['options']['appearance']['comment_editor'])?'t':'f');
@@ -309,7 +319,7 @@ function option_page()
function upload_options()
{
if (!empty($_POST['submit_update'])) {
if (! wp_verify_nonce($_POST['csrf_ckeditor-for-wordpress'], 'ckeditor_create_nonce_upload') || empty($_POST['_wp_http_referer']) || !strstr( $_SERVER['HTTP_REFERER'], $_POST['_wp_http_referer']) ) wp_die("You do not have sufficient permissions to access this page.");
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.");
$new_options=$_POST['options'];
foreach (array('access', 'fileView', 'fileDelete', 'fileRename', 'fileUpload', 'folderView', 'folderDelete', 'folderCreate', 'folderRename') as $command) {
$this->set_capability($new_options['ckfinder']['permissions'][$command], "ckeditor_ckfinder_".$command);
@@ -374,7 +384,7 @@ function upload_options()
function advanced_options() {
if (!empty($_POST['submit_update'])) {
if (! wp_verify_nonce($_POST['csrf_ckeditor-for-wordpress'], 'ckeditor_create_nonce_advanced') || empty($_POST['_wp_http_referer']) || !strstr( $_SERVER['HTTP_REFERER'], $_POST['_wp_http_referer']) ) wp_die("You do not have sufficient permissions to access this page.");
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.");
$new_options=$_POST['options'];
$new_options['advanced']['native_spell_checker'] = (isset($_POST['options']['advanced']['native_spell_checker'])?'t':'f');
$new_options['advanced']['scayt_autoStartup'] = (isset($_POST['options']['advanced']['scayt_autoStartup'])?'t':'f');
@@ -430,6 +440,19 @@ function advanced_options() {
$massage['advanced_load_timeout'] = __('Enter valid load timeout in seconds.', 'ckeditor_wordpress');
}
/* language settings */
if (!preg_match('#^\d\d$#', trim($new_options['advanced']['language'])) && !preg_match('#^\d\d-\d\d$#', trim($new_options['advanced']['language']))) {
$massage['advanced_language'] = __('Enter a valid language.', 'ckeditor_wordpress');
}
if ( trim($new_options['advanced']['detect_language_auto']) != 't' && trim($new_options['advanced']['detect_language_auto'] != 'f') ) {
$massage['advanced_detect_language_auto'] = __('Enter a valid auto detect language value.', 'ckeditor_wordpress');
}
if ( trim($new_options['advanced']['language_direction']) != 'default' && trim($new_options['advanced']['language_direction']) != 'ltr' && trim($new_options['advanced']['language_direction']) != 'rtl') {
$massage['advanced_language_direction'] = __('Enter a valid language direction value.', 'ckeditor_wordpress');
}
$this->options = $this->update_options($new_options, (empty($message)?false:true));
}
include('includes/advanced.php');
@@ -552,7 +575,7 @@ function file_editor(){
unset($keys);
}
if(isset($_POST['newcontent'])){
if (! wp_verify_nonce($_POST['csrf_ckeditor-for-wordpress'], 'ckeditor_create_nonce_file_editor') || empty($_POST['_wp_http_referer']) || !strstr( $_SERVER['HTTP_REFERER'], $_POST['_wp_http_referer']) ) wp_die("You do not have sufficient permissions to access this page.");
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.");
$fp=fopen($files[$file], 'w');
$content = stripslashes($_POST['newcontent']);
fwrite($fp, stripslashes($_POST['newcontent']));
@@ -619,6 +642,11 @@ function generate_js_options($is_comment){
switch($options['css']['mode']){
case 'theme':
$settings['contentsCss'][] = get_stylesheet_uri();
//fix for default Wordpress theme
if (preg_match('/twenty[\S]+/', get_stylesheet_uri()))
{
$settings['extraCss'] = 'body {background:#FFF; padding: 0 0.5em; }';
}
break;
case 'self':
foreach(explode(',',$options['css']['path']) as $css_path){
@@ -641,6 +669,28 @@ function generate_js_options($is_comment){
break;
}
if ($options['advanced']['detect_language_auto'] == 'f')
{
$settings['language'] = $options['advanced']['language'];
}
if (isset($options['advanced']['language_direction'])) {
switch ($options['advanced']['language_direction']) {
case 'default':
if (is_rtl()) {
$settings['contentsLangDirection'] = 'rtl';
}
break;
case 'ltr':
$settings['contentsLangDirection'] = 'ltr';
break;
case 'rtl':
$settings['contentsLangDirection'] = 'rtl';
break;
}
}
$output['configuration']=$settings;
$output['configuration']['customConfig'] = $this->plugin_path . 'ckeditor.config.js';
if(!$is_comment){
@@ -746,16 +796,20 @@ function ckeditor_wpgallery_plugin($plugins) {
//filter to change data for wpeditimage plugin before insert/update in database
function ckeditor_insert_post_data_filter( $data , $postarr = null )
{
//change amp; to empty character . This is to create & character before entities like gt; and lt;
$content = $data['post_content'];
$content = str_replace('amp;' , '', $content);
//change amp; to empty character . This is to create & character before entities like gt; and lt;
//$content = str_replace('amp;' , '', $content);
$content = stripslashes($content);
//change " character in caption string for &quot;
//change amp; to empty character . This is to create & character before entities like gt; and lt; in caption string
$pattern = '/caption="(.+)"\]/';
preg_match_all($pattern, $content,$matches);
if (isset($matches[1]))
{
$content = str_replace($matches[1], str_replace('amp;', '', $matches[1]), $content);
$content = str_replace($matches[1], str_replace('"', '&quot;', $matches[1]), $content);
}
//save data
$content = addslashes($content);
@@ -827,6 +881,101 @@ function starrating_buttons($buttons) {
}
return $buttons;
}
/**
* List of installed CKEditor languages
*
* @return array
*/
function ckeditor_load_lang_options() {
$arr = array();
if (DEFINED('WP_PLUGIN_DIR'))
{
$lang_file = WP_PLUGIN_DIR .'/'. basename(dirname(__FILE__)) .'/ckeditor/lang/_languages.js';
}
else{
$lang_file = '../wp-content/plugins/ckeditor-for-wordpress/ckeditor/lang/_languages.js';
}
if (file_exists($lang_file))
{
$f = fopen($lang_file, 'r');
$file = fread($f, filesize($lang_file));
$tmp = explode('{', $file);
if (isset($tmp[2]))
{
$tmp = explode('}', $tmp[2]);
}
$langs = explode(',', $tmp[0]);
foreach ($langs AS $key => $lang)
{
preg_match("/(\w+-?\w+):'(\w+)'/i",$lang, $matches);
if (isset($matches[1]) && isset($matches[2]))
$arr[$matches[1]] = $matches[2];
}
}
//oops, we have no information about languages, let's use those available in CKEditor 2.4.3
if (empty($arr)) {
$arr = array(
'af' => 'Afrikaans',
'ar' => 'Arabic',
'bg' => 'Bulgarian',
'bn' => 'Bengali/Bangla',
'bs' => 'Bosnian',
'ca' => 'Catalan',
'cs' => 'Czech',
'da' => 'Danish',
'de' => 'German',
'el' => 'Greek',
'en' => 'English',
'en-au' => 'English (Australia)',
'en-ca' => 'English (Canadian)',
'en-uk' => 'English (United Kingdom)',
'eo' => 'Esperanto',
'es' => 'Spanish',
'et' => 'Estonian',
'eu' => 'Basque',
'fa' => 'Persian',
'fi' => 'Finnish',
'fo' => 'Faroese',
'fr' => 'French',
'gl' => 'Galician',
'he' => 'Hebrew',
'hi' => 'Hindi',
'hr' => 'Croatian',
'hu' => 'Hungarian',
'it' => 'Italian',
'ja' => 'Japanese',
'km' => 'Khmer',
'ko' => 'Korean',
'lt' => 'Lithuanian',
'lv' => 'Latvian',
'mn' => 'Mongolian',
'ms' => 'Malay',
'nb' => 'Norwegian Bokmal',
'nl' => 'Dutch',
'no' => 'Norwegian',
'pl' => 'Polish',
'pt' => 'Portuguese (Portugal)',
'pt-br' => 'Portuguese (Brazil)',
'ro' => 'Romanian',
'ru' => 'Russian',
'sk' => 'Slovak',
'sl' => 'Slovenian',
'sr' => 'Serbian (Cyrillic)',
'sr-latn' => 'Serbian (Latin)',
'sv' => 'Swedish',
'th' => 'Thai',
'tr' => 'Turkish',
'uk' => 'Ukrainian',
'vi' => 'Vietnamese',
'zh' => 'Chinese Traditional',
'zh-cn' => 'Chinese Simplified',
);
}
asort($arr);
return $arr;
}
}
$ckeditor_wordpress = new ckeditor_wordpress();
?>
View
@@ -4,7 +4,7 @@
Plugin Name: CKEditor for WordPress
Plugin URI: http://wordpress.ckeditor.com/
Description: Replaces the default WordPress editor with <a href="http://ckeditor.com/"> CKEditor</a>
Version: 3.6.2.1
Version: 3.6.2.2
Author: CKSource
Author URI: http://cksource.com/
*/
@@ -27,6 +27,8 @@ function ckeditor_init(){
add_filter( 'ckeditor_external_plugins', array(&$ckeditor_wordpress, 'ckeditor_wpmore_plugin') );
add_filter( 'ckeditor_buttons', array(&$ckeditor_wordpress, 'ckeditor_wpmore_button') );
add_filter( 'ckeditor_external_plugins', array(&$ckeditor_wordpress, 'ckeditor_wpgallery_plugin') );
add_filter( 'ckeditor_load_lang_options', array(&$ckeditor_wordpress, 'ckeditor_load_lang_options') );
//add filter to change content before insert/update to database - needed for wpeditimage plugin
add_filter( 'wp_insert_post_data' , array(&$ckeditor_wordpress, 'ckeditor_insert_post_data_filter'));
View
Binary file not shown.
View
@@ -120,6 +120,67 @@
<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>
</td>
</tr>
<?php
$langs = apply_filters('ckeditor_load_lang_options', array());
?>
<tr valign="top">
<th scope="row"><?php _e('Language', 'ckeditor_wordpress')?></th>
<td>
<?php
//var_dump( get_locale());
if (isset($this->options['advanced']['language']))
{
$selected = $this->options['advanced']['language'];
}else{
$selected = (get_locale())? get_locale() : 'en';
}
?>
<select name="options[advanced][language]">
<?php foreach ($langs AS $key => $lang): ?>
<option value="<?php echo $key?>" <?php if($key == $selected):?>selected="selected"<?php endif;?>><?php echo $lang ?></option>
<?php endforeach; ?>
</select>
<br /><span class="description"><?php _e('The language for the CKEditor user interface.', 'ckeditor_wordpress'); ?></span>
<?php if (isset($message['advanced_language'])): ?><span class="error"><?php echo $message['advanced_language'] ?></span><?php endif; ?>
</td>
</tr>
<?php
if (isset($this->options['advanced']['detect_language_auto']))
{
$auto = $this->options['advanced']['detect_language_auto'];
} else {
$auto = 't';
}
?>
<tr valign="top">
<th scope="row"><?php _e('Auto-detect language', 'ckeditor_wordpress')?></th>
<td>
<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/>
<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>
<br /><span class="description"><?php _e('Automatically detect the user language.', 'ckeditor_wordpress'); ?></span>
<?php if (isset($message['advanced_detect_language_auto'])): ?><br/><span class="error"><?php echo $message['advanced_detect_language_auto'] ?></span><?php endif; ?>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Language direction ', 'ckeditor_wordpress')?></th>
<td>
<?php
if (isset($this->options['advanced']['language_direction']))
{
$selected = $this->options['advanced']['language_direction'];
}else{
$selected = 'default';
}
?>
<select name="options[advanced][language_direction]">
<option value="default" <?php if($selected == 'default'):?>selected="selected"<?php endif;?>>Get from current locale (default)</option>
<option value="ltr" <?php if($selected == 'ltr'):?>selected="selected"<?php endif;?>>Left-To-Right</option>
<option value="rtl" <?php if($selected == 'rtl'):?>selected="selected"<?php endif;?>>Right-To-Left</option>
</select>
<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>
<?php if (isset($message['advanced_language_direction'])): ?><span class="error"><?php echo $message['advanced_language_dierction'] ?></span><?php endif; ?>
</td>
</tr>
</table>
<p class="submit">
<input type="hidden" name="df_submit" value="1" />
Oops, something went wrong.

0 comments on commit ca7c2f9

Please sign in to comment.