* @copyright Copyright © 2006 Sabin Iacob
* @version 0.7
* @license http://creativecommons.org/licenses/GPL/2.0/ GNU General Public License
*/
//{{{ initialization
/**
* initialize database stored parameters and add link to the options page in the
* options submenu
*/
function as_add_options_page(){
$as_options = array(
"as_personal" => "wp-content/plugins/ajax_spellchecker/service/dict/custom.en.pws",
"as_repl" => "wp-content/plugins/ajax_spellchecker/service/dict/custom.en.prepl",
"as_custompath" => "wp-content/plugins/ajax_spellchecker/service/dict",
"as_custom" => false,
"as_lang" => "en",
"as_maxsug" => 5,
"as_backend" => "Pspell",
"as_runtogether"=> true
);
//make sure options exist
foreach($as_options as $k => $v){
if(get_option($k) === false){
add_option($k, $v);
}
}
add_options_page("Ajax Spell Checker Options","Spell Checker",5,"ajax_spellchecker/options.php");
}
//}}}
//{{{ TinyMCE plugin
/**
* add plugin to TinyMCE plugin list
*
* tinymce_gzip.php must be able to read our plugin in order to include it, hence
* the long path
*/
function as_tinymce_plugin(&$plugins){
$plugins[] = "../../../../wp-content/plugins/ajax_spellchecker/tinymce/mcespell";
return $plugins;
}
/**
* add button to TinyMCE button list
*/
function as_tinymce_button(&$buttons){
$buttons[] = "mcespell";
return $buttons;
}
/**
* fix the plugin address
*
* Since TinyMCE will only look in its plugins directory, we keep the basename (also plugin name)
* and discard the rest of the path
*/
function as_fix_tinymce_plugin(){
global $plugins;
$tmp = explode(",", $plugins);
for($i = 0; $i < count($tmp); $i++){
$tmp[$i] = basename($tmp[$i]);
}
$plugins = implode(",", $tmp);
}
/**
* fool TinyMCE into believing it has the plugin under its plugin path
*/
function as_rewrite_rules($rules){
$tmp = explode("\n",$rules);
$ret = array();
$ig_rules = "RewriteRule wp-includes/js/tinymce/plugins/mcespell/spell-check-service wp-content/plugins/ajax_spellchecker/service/spell-check-service.php [QSA,L]\n";
$ig_rules .= 'RewriteRule wp-includes/js/tinymce/plugins/mcespell/(.*) wp-content/plugins/ajax_spellchecker/tinymce/mcespell/$1 [L]';
foreach($tmp as $rule){
array_push($ret, $rule);
if(strstr($rule,"RewriteBase") !== false)
array_push($ret, $ig_rules);
}
$rules = join("\n", $ret);
return $rules;
}
//}}}
//{{{ QuickTags
/**
* add spell checking button to QuickTags
*/
function as_quicktags() {
?>