WYMeditor 0.4
Version: 0.4.2
Author: Amaury BALMER
Author URI: http://www.herewithme.fr
### Instructions ###
1. Send plugin into "wp-content/plugins"
2. Active it
3. New editor visual is Ok.
4. To customize predefined style, edit styles.css
### License ###
Copyright (C) 2007 Amaury Balmer (email : balmer.amaury@gmail.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
Class SimpleWYMeditor {
var $version = '0.4.2';
var $wymeditor_url = '';
var $plugin_url = '';
var $plugin_path = '';
var $locale = '';
function SimpleWYMeditor() {
// Set URL & Path
$this->plugin_url = trailingslashit(get_option('siteurl')) . 'wp-content/plugins/' . basename(dirname(__FILE__)) .'/';
$this->plugin_path = ABSPATH . 'wp-content/plugins/' . basename(dirname(__FILE__)) .'/';
$this->wymeditor_url = $this->plugin_url . 'wymeditor/';
// Add JS in admin header
add_action('admin_print_scripts', array(&$this, 'addAdminHead'));
// Desactive visual editor
add_action('personal_options_update', array(&$this, 'userPersonaloptsUpdate'));
// Add editor in admin
add_action('edit_form_advanced', array(&$this, 'loadWYMeditor'));
add_action('edit_page_form', array(&$this, 'loadWYMeditor'));
add_action('simple_edit_form', array(&$this, 'loadWYMeditor'));
// remove old WP preview
add_action('admin_footer', array(&$this, 'disablePreview'));
// remove WP upload
// add_filter('uploading_iframe_src', array(&$this, 'disableWPupload'));
// Put right autosave script
add_filter('script_loader_src', array(&$this, 'autoSave'));
// Active/deactive visual editor for current user
register_activation_hook(basename(dirname(__FILE__)). '/' . basename(__FILE__), array(&$this, 'activate'));
register_deactivation_hook(basename(dirname(__FILE__)). '/' . basename(__FILE__), array(&$this, 'deactivate'));
return true;
}
function addAdminHead() {
global $pagenow;
$pages = apply_filters( 'pages_with_wymeditor_editor', array('post-new.php', 'page-new.php', 'post.php', 'page.php') );
if ( in_array($pagenow, (array) $pages) ) {
wp_enqueue_script( 'jquery' );
add_action('admin_head', array(&$this, 'addFilesWYMeditor'));
}
return true;
}
function addFilesWYMeditor() {
if ( get_locale() ) {
$short_locale = substr( strtolower(get_locale()), 0, 2 );
if ( is_file( $this->plugin_path . 'wymeditor/lang/' . $short_locale . '.js' ) ) {
$this->locale = $short_locale;
echo '';
}
}
$rows = 10 * get_option('default_post_edit_rows');
if (($rows < 100) || ($rows > 1000)) {
$rows = 300;
}
?>
id, 'rich_editing', 'true', true);
return true;
}
function activate() {
global $current_user;
update_user_option($current_user->id, 'rich_editing', 'false', true);
return true;
}
function userPersonaloptsUpdate() {
global $current_user;
update_user_option($current_user->id, 'rich_editing', 'false', true);
return true;
}
function disablePreview() {
?>