' . __('Configuration updated!') . '
';
}
include('includes/overview.php');
}
public 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']) || ( 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');
$this->options = $this->update_options($new_options, (empty($message) ? false : true));
}
include('includes/basic.php');
}
public 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']) || ( 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);
}
$new_options['ckfinder']['thumbnails_direct_access'] = (isset($new_options['ckfinder']['thumbnails_direct_access']) ? 't' : 'f');
$new_options['ckfinder']['thumbnails_enabled'] = (isset($new_options['ckfinder']['thumbnails_enabled']) ? 't' : 'f');
/* validation */
$message = array();
if ($new_options['upload']['browser'] != 'disabled') {
$new_options['upload']['files_allowed_ext'] = str_replace(' ', '', $new_options['upload']['files_allowed_ext']);
$new_options['upload']['images_allowed_ext'] = str_replace(' ', '', $new_options['upload']['images_allowed_ext']);
$new_options['upload']['flash_allowed_ext'] = str_replace(' ', '', $new_options['upload']['flash_allowed_ext']);
$inputs = array('files_allowed_ext', 'images_allowed_ext', 'flash_allowed_ext');
foreach ($inputs as $input) {
if (empty($new_options['upload'][$input])) {
$message['upload_' . $input] = __('This field shouldn\'t be empty', 'ckeditor_wordpress');
} elseif (!preg_match('#^([a-z0-9]+){1}(,[a-z0-9]+)*,?$#Uis', trim($new_options['upload'][$input]))) {
$message['upload_' . $input] = __('Files extensions has wrong chars.', 'ckeditor_wordpress');
}
}
if ($new_options['upload']['browser'] == 'ckfinder') {
$checkCKFinder = $this->ckfinder_status();
if (!strpos($checkCKFinder, "ckeditor_ok")) {
$message['upload_browser'] = $checkCKFinder;
}
if (empty($new_options['ckfinder']['file_max_size'])) {
$message['ckfinder_file_max_size'] = __('This field is required.', 'ckeditor_wordpress');
} elseif (!preg_match('/^\d+[MKG]?$/i', trim($new_options['ckfinder']['file_max_size']))) {
$message['ckfinder_file_max_size'] = __('Enter valid value. Example: 400 or 10M', 'ckeditor_wordpress');
}
$inputs = array('images_width', 'images_height', 'thumbnails_width', 'thumbnails_height');
foreach ($inputs as $input) {
if (empty($new_options['ckfinder'][$input])) {
$message['ckfinder_' . $input] = __('This field is required.', 'ckeditor_wordpress');
} elseif (!preg_match('#^\d+$#', trim($new_options['ckfinder'][$input]))) {
$message['ckfinder_' . $input] = __('Enter valid value. Example: 400', 'ckeditor_wordpress');
}
}
if (empty($new_options['ckfinder']['thumbnails_quality'])) {
$message['ckfinder_thumbnails_quality'] = __('This field is required.', 'ckeditor_wordpress');
} elseif (!(preg_match('#^[0-9]{1,2}$#', trim($new_options['ckfinder']['thumbnails_quality'])) || trim($new_options['ckfinder']['thumbnails_quality']) == '100')) {
$message['ckfinder_thumbnails_quality'] = __('Value should be betwen 1 and 100.', 'ckeditor_wordpress');
}
if (empty($new_options['ckfinder']['images_quality'])) {
$message['ckfinder_images_quality'] = __('This field is required.', 'ckeditor_wordpress');
} elseif (!(preg_match('#^[0-9]{1,2}$#', trim($new_options['ckfinder']['images_quality'])) || trim($new_options['ckfinder']['images_quality']) == '100')) {
$message['ckfinder_images_quality'] = __('Value should be betwen 1 and 100.', 'ckeditor_wordpress');
}
}
}
unset($new_options['ckfinder']['permissions']);
$this->options = $this->update_options($new_options, (empty($message) ? false : true));
}
include('includes/upload.php');
}
public 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']) || ( 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');
$new_options['advanced']['p_indent'] = (isset($_POST['options']['advanced']['p_indent']) ? 't' : 'f');
$new_options['advanced']['p_break_before_open'] = (isset($_POST['options']['advanced']['p_break_before_open']) ? 't' : 'f');
$new_options['advanced']['p_break_after_open'] = (isset($_POST['options']['advanced']['p_break_after_open']) ? 't' : 'f');
$new_options['advanced']['p_break_before_close'] = (isset($_POST['options']['advanced']['p_break_before_close']) ? 't' : 'f');
$new_options['advanced']['p_break_after_close'] = (isset($_POST['options']['advanced']['p_break_after_close']) ? 't' : 'f');
$new_options['advanced']['entities'] = (isset($_POST['options']['advanced']['entities']) ? 't' : 'f');
foreach ($this->options['plugins'] as $key => $val) {
if (isset($_POST['options']['plugins'][$key])) {
$new_options['plugins'][$key] = 't';
unset($_POST['options']['plugins'][$key]);
} else {
$new_options['plugins'][$key] = 'f';
}
}
foreach ((array) $_POST['options']['plugins'] as $key => $val) {
$new_options['plugins'][$key] = 't';
}
$new_options['plugins']['wpgallery'] = 't';
/* validation */
$massage = array();
/** css mode and path validation * */
if (!empty($new_options['css']['path'])) {
if ($new_options['css']['mode'] != 'self') {
$message['css_path'] = __('CSS path is not empty. Please set the "Editor CSS" option to "define css" mode.', 'ckeditor_wordpress');
} elseif (FALSE !== strpos($new_options['css']['path'], '"')) {
$massage['css_path'] = __('Double quotes are not allowed in CSS path.', 'ckeditor_wordpress');
} elseif (substr($new_options['css']['path'], 0, 1) == "'" && substr($new_options['css']['path'], -1) == "'") {
$massage['css_path'] = __('Enter valid path, do not surround it with quotes.', 'ckeditor_wordpress');
}
}
/** styles * */
if (!empty($new_options['css']['style_path'])) {
if ($new_options['css']['styles'] != 'self') {
$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');
} elseif (FALSE !== strpos($new_options['css']['styles_path'], '"')) {
$message['css_style_path'] = __('Double quotes are not allowed in path.', 'ckeditor_wordpress');
} elseif (substr($new_options['css']['style_path'], 0, 1) == "'" && substr($new_options['css']['style_path'], -1) == "'") {
$message['css_style_path'] = __('Enter valid path, do not surround it with quotes.', 'ckeditor_wordpress');
}
}
/** load timeout * */
if (!preg_match('#^\d+$#', trim($new_options['advanced']['load_timeout']))) {
$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');
}
public function basic_settings_js() {
wp_enqueue_script('ckeditor', $this->ckeditor_path . 'ckeditor.js');
wp_enqueue_script('ckeditor_admin', $this->plugin_path . 'includes/basic.js');
}
public function file_editor_js() {
/* codepress */
//add_action('admin_print_footer_scripts', 'codepress_footer_js');
//wp_enqueue_script('codepress');
}
private function is_plugin_active($plugin_name) {
$options = get_option('active_plugins');
foreach ($options AS $option) {
if (strpos($option, $plugin_name) !== FALSE) {
return true;
}
}
return false;
}
public function remove_tinymce() {
if (has_action('admin_print_footer_scripts', 'wp_tiny_mce')) {
remove_action('admin_print_footer_scripts', 'wp_tiny_mce', 25);
}
}
public function add_post_js() {
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')) {
remove_filter('admin_print_footer_scripts', 'wp_tiny_mce', 25);
remove_filter('before_wp_tiny_mce', 'wp_print_editor_js');
remove_filter('after_wp_tiny_mce', 'wp_preload_dialogs');
$this->editor_js();
}
}
public function editor_js() {
if (!user_can_richedit()) {
wp_enqueue_script('quicktags');
return;
}
wp_enqueue_script('editor');
wp_enqueue_script('ckeditor', $this->ckeditor_path . "ckeditor.js?t=".$this->timestamp);
wp_enqueue_script('ckeditor.utils', $this->plugin_path . 'includes/ckeditor.utils.js', array('ckeditor', 'jquery'));
$this->generate_js_options(false);
}
public function add_comment_js() {
if (!(is_page() || is_single())) {
return;
}
if ($this->options['appearance']['comment_editor'] != 't') {
return;
}
// if W3 Total Cache is enabled, turn off minify for page with CKEditor in comments
if ( is_plugin_active('w3-total-cache/w3-total-cache.php') ) {
define('DONOTMINIFY', true);
}
wp_enqueue_script('ckeditor', $this->ckeditor_path . "ckeditor.js?t=".$this->timestamp);
wp_enqueue_script('ckeditor.utils', $this->plugin_path . 'includes/ckeditor.utils.js', array('ckeditor', 'jquery'));
wp_deregister_script('comment-reply');
wp_register_script('comment-reply', $this->plugin_path . 'includes/ckeditor.comment-reply.js', array('ckeditor', 'ckeditor.utils'), "20100901");
$this->generate_js_options(true);
$this->add_wpcompat_styles();
}
public function add_wpcompat_styles() {
?>
options;
foreach ($new_options as $k => $v) {
if (isset($this->options[$k])) {
$options[$k] = array_merge($this->options[$k], $v);
} else {
$options[$k] = $v;
}
}
if (!$error) {
update_option("ckeditor_wordpress", $options);
echo '