h3 { margin: 0px; margin-top: 12px; margin-bottom: 6px; } caption { font-weight: bold; text-align: center; } label { font-weight: bold; } small { font-size: 0.9em; font-style: italic; color: #666; } code { color: #333366; font-style: italic; } code.opt { font-weight: bold; font-style: normal; } .error { color: #993333; } .warning { color: #cc33cc; } .field_warning { border: solid 1px #993333; } .lp_paragraph { line-height: 1.5em; text-align: justify; } div.theme { } div.theme img { float: left; border: solid 1px #ccc; padding: 3px; margin-right: 9px; } '; } add_action('admin_head', 'lpadmin_extra_css'); /***** Add actions for the options controlled by WP ****/ // the WP filters/actions system is totally braindead, why is it impossible // to retrieve the name of the 'tag' from the called filter/action? Why // is the update_option action different for each option, and does not // receive the option name as its first argument? if ($basedir = get_option('lp_opt_basedir')) { require_once implode(DIRECTORY_SEPARATOR, array($basedir, 'wp-plugin', 'LightPressOptions.php')); $lp_opts = new LightPressOptions(); $lp_opts_names = array_values($lp_opts->_wpoption); $lp_opts_names = array_merge($lp_opts_names, array('blog_charset', 'permalink_structure', 'category_base', 'rss_use_excerpt')); foreach ($lp_opts_names as $opt) { $action_name = create_function('$old, $new', "lp_sync_option('$opt', \$old, \$new);"); add_action("update_option_$opt", $action_name, 10, 2); } } function lp_sync_option($opt, $old, $new) { global $lp_opts; $map = array_flip($lp_opts->_wpoption); switch ($opt) { case 'permalink_structure': foreach (array('post_prefix', 'archives_prefix') as $opt) $lp_opts->updateOption("lp_opt_$opt", $lp_opts->getDefault($opt)); break; case 'rss_use_excerpt': if ($new != $old) $lp_opts->updateOption("lp_opt_rss_use_excerpt", $new); break; case 'category_base': $new = $lp_opts->removeWPslashes($new); default: if (isset($map[$opt])) $lp_opts->updateOption("lp_opt_{$map[$opt]}", $new); else $lp_opts->updateOption("lp_opt_$opt", $new); } } /***** Add LP Rewrite rule filters *****/ function lpadmin_rewrite_rules($rules) { require_once 'wp-plugin/LightPressModRewrite.php'; if (!isset($lightpress_rewrite_helper)) $lightpress_rewrite_helper =& new LightPressModRewrite(); if ($lightpress_rewrite_helper->basedir) { // check to see if we can override the .htaccess file in the WP root if (get_option('lp_opt_install_type') == 'root') { return $lightpress_rewrite_helper->buildHtaccess(); } else { return $rules . "\n# Lightpress is in 'testing' mode, please check the Lightpress admin console\n# for LP .htaccess rules\n"; } } else { return $rules; } } add_filter('mod_rewrite_rules', 'lpadmin_rewrite_rules'); /***** LP Tagging *****/ require_once 'wp-plugin/LightPressTagging.php'; $lightpress_tag_helper =& new LightPressTagging(); /***** LP Cache Refresh *****/ if (get_option('lp_opt_cache_actions_enabled') == '1') { $ret = include_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'FileCache.php'); if ($ret) { $lp_cache_args = get_option('lp_opt_cache_args'); if (!is_array($lp_cache_args)) { if (is_string($lp_cache_args) && !empty($lp_cache_args)) $lp_cache_args = @unserialize($lp_cache_args); if (!is_array($lp_cache_args)) { trigger_error('non-array cache arguments in lightpress.php ' . __LINE__ . ' ' . var_export($lp_cache_args, true), E_USER_WARNING); $lp_cache_args = array(); } } else { $lp_cache_args['dir'] = stripslashes($lp_cache_args['dir']); } $lp_cache =& new LightPressCache($lp_cache_args); if (get_option('lp_opt_cache_actions_all_pages') == '1') { add_action('publish_post', array(&$lp_cache, 'clearCache'), 99); add_action('edit_post', array(&$lp_cache, 'clearCache'), 99); add_action('comment_post', array(&$lp_cache, 'clearCache'), 99); add_action('edit_comment', array(&$lp_cache, 'clearCache'), 99); add_action('delete_comment', array(&$lp_cache, 'clearCache'), 99); } else { add_action('publish_post', array(&$lp_cache, 'clearCachePost'), 99); //add_action('edit_post', array(&$lp_cache, 'clearCachePost'), 99); add_action('delete_post', array(&$lp_cache, 'clearCachePost'), 99); add_action('comment_post', array(&$lp_cache, 'clearCacheComment'), 99); add_action('edit_comment', array(&$lp_cache, 'clearCacheComment'), 99); add_action('delete_comment', array(&$lp_cache, 'clearCacheComment'), 99); add_action('pingback_post', array(&$lp_cache, 'clearCacheComment'), 99); } } } if (get_option('lp_opt_use_preformatter') == '1') { $ret = include_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'LightpressPreformatter.php'); if ($ret) { $lp_preformatter_method = get_option('lp_opt_preformatter_method'); $lp_preformatter =& new LightpressPreformatter($lp_preformatter_method); $lp_preformatter->register_filters(); } } ?>