check_for_network(); /* register options */ $this->get_options(); /* check is backend is available */ $alive = wp_ffpc_init( $this->options ); /* don't register hooks if backend is dead */ if ($alive) { /* init inactivation hooks */ add_action('switch_theme', array( $this , 'invalidate'), 0); add_action('edit_post', array( $this , 'invalidate'), 0); add_action('publish_post', array( $this , 'invalidate'), 0); add_action('delete_post', array( $this , 'invalidate'), 0); /* Capture and register if a redirect is sent back from WP, so the cache can cache (or ignore) it. Redirects were source of problems for blogs with more than one host name (eg. domain.com and www.domain.com) comined with the use of Hyper Cache.*/ add_filter('redirect_canonical', array( $this , 'redirect_canonical') , 10, 2); } /* add admin styling */ if( is_admin() ) { wp_enqueue_style( WP_FFPC_PARAM . '.admin.css' , WP_FFPC_URL . '/css/'. WP_FFPC_PARAM .'.admin.css', false, '0.1'); //wp_enqueue_script("jquery-ui-g","https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.8/jquery-ui.min.js"); //wp_enqueue_script ( "jquery"); //wp_enqueue_script ( "jquery-ui-core"); wp_enqueue_script ( "jquery-ui-tabs" ); } /* on activation */ register_activation_hook(__FILE__ , array( $this , 'activate') ); /* on deactivation */ register_deactivation_hook(__FILE__ , array( $this , 'deactivate') ); /* on uninstall */ register_uninstall_hook(__FILE__ , array( $this , 'uninstall') ); /* init plugin in the admin section */ /* if multisite, admin page will be on network admin section */ if ( $this->network ) add_action('network_admin_menu', array( $this , 'admin_init') ); /* not network, will be in simple admin menu */ else add_action('admin_menu', array( $this , 'admin_init') ); } /** * activation hook: save default settings in order to eliminate bugs. * */ function activate ( ) { $this->save_settings( true ); } /** * init function for admin section * */ function admin_init () { /* register options */ add_site_option( WP_FFPC_PARAM, $this->options , '' , 'no'); /* save parameter updates, if there are any */ if ( isset($_POST[WP_FFPC_PARAM . '-save']) ) { $this->save_settings (); $this->status = 1; header("Location: admin.php?page=" . WP_FFPC_OPTIONS_PAGE . "&saved=true"); } add_submenu_page('settings.php', 'Edit WP-FFPC options', __('WP-FFPC', WP_FFPC_PARAM ), 10, WP_FFPC_OPTIONS_PAGE , array ( $this , 'admin_panel' ) ); //add_menu_page('Edit WP-FFPC options', __('WP-FFPC', WP_FFPC_PARAM ), 10, WP_FFPC_OPTIONS_PAGE , array ( $this , 'admin_panel' ) ); } /** * settings panel at admin section * */ function admin_panel ( ) { /** * security */ if( ! function_exists( 'current_user_can' ) || ! current_user_can( 'manage_options' ) ){ die( ); } /** * if options were saved */ if ($_GET['saved']=='true' || $this->status == 1) : ?>

Settings saved.

options['cache_type'] == 'memcached' && $memcached_protocol == 'binary' ) : ?>

options['cache_type'] == 'memcached' || $this->options['cache_type'] == 'memcache' ) : ?>

options['host'] . ', port ' . $this->options['port'] .' with driver "' . $this->options['cache_type'] . '": ', WP_FFPC_PARAM ); $server_status = wp_ffpc_init( $this->options); $server_status = ( empty($server_status) || $server_status == 0 ) ? 'down' : 'up & running' ; echo $server_status; ?>

: cache_type( $this->defaults['cache_type'] , true ) ; ?>
: defaults['expire']; ?>
: defaults['charset']; ?>
WARNING! When selection "all", the cache will be fully flushed, including elements that were set by other applications.

', WP_FFPC_PARAM); ?>
: invalidation_method( $this->defaults['invalidation_method'] , true ) ; ?>
: defaults['prefix_data']; ?>
: defaults['prefix_meta']; ?>
options['debug'],true); ?> /> : print_bool( $this->defaults['debug']); ?>
options['syslog'],true); ?> /> : print_bool( $this->defaults['syslog']); ?>
options['pingback_status'],true); ?> /> : print_bool( $this->defaults['pingback_status']); ?>
options['sync_protocols'],true); ?> /> : print_bool( $this->defaults['sync_protocols']); ?>
options['cache_loggedin'],true); ?> /> : print_bool( $this->defaults['cache_loggedin']); ?>
options['nocache_home'],true); ?> /> : print_bool( $this->defaults['nocache_home']); ?>
options['nocache_feed'],true); ?> /> : print_bool( $this->defaults['nocache_feed']); ?>
options['nocache_archive'],true); ?> /> : print_bool( $this->defaults['nocache_archive']); ?>
options['nocache_single'],true); ?> /> : print_bool( $this->defaults['nocache_single']); ?>
options['nocache_page'],true); ?> /> : print_bool( $this->defaults['nocache_page']); ?>
options['apc_compress'],true); ?> /> : print_bool( $this->defaults['apc_compress']); ?>
: defaults['host']; ?>
: defaults['port']; ?>
options['prefix_data'], $this->options['host'], $this->options['port'] ); $nginx = file_get_contents ( WP_FFPC_DIR .'/nginx-sample.conf' ); $nginx = str_replace ( $search , $replace , $nginx ); ?>

input field with $current set as active * */ function cache_type ( $current , $returntext = false ) { $e = array ( 'apc' => 'use APC as store', 'memcache' => 'use memcached server with Memcache extension', 'memcached' => 'use memcached server with Memcached extension', ); $this->print_select_options ( $e , $current , $returntext ); } /** * see if we are using network-wide setup or not * */ function check_for_network( ) { if ( is_multisite() ) { $plugins = get_site_option( 'active_sitewide_plugins'); if ( isset($plugins['wp-ffpc/wp-ffpc.php']) ) { $this->network = true; } } } /** * deactivation hook: clear advanced-cache config file * */ function deactivate ( ) { if (@file_exists (WP_FFPC_ACACHE_MAIN_FILE)) @unlink (WP_FFPC_ACACHE_MAIN_FILE); } /** * invalidate cache */ function invalidate ( $post_id ) { wp_ffpc_clear ( $post_id ); } /** * generates invalidation method select box * * @param $current * the active or required size's identifier * * @param $returntext * boolean: is true, the description will be returned of $current size * * @return * prints either description of $current * or option list for a input field with $current set as active * */ function print_select_options ( $sizes, $current, $returntext=false ) { if ( $returntext ) { _e( $sizes[ $current ] , WP_FFPC_PARAM); return; } foreach ($sizes as $ext=>$name) { ?> options as $name=>$optionvalue) { if (!empty($_POST[$name])) { $update = $_POST[$name]; if (strlen($update)!=0 && !is_numeric($update)) $update = stripslashes($update); } elseif ( ( empty($_POST[$name]) && is_bool ($this->defaults[$name]) ) || is_int( $this->defaults[$name] ) ) { $update = 0; } else { $update = $this->defaults[$name]; } $this->options[$name] = $update; } update_site_option( WP_FFPC_PARAM , $this->options ); $this->invalidate('system_flush'); if ( ! $firstrun ) $this->generate_config(); } /** * clean up at uninstall * */ function uninstall ( ) { delete_site_option( WP_FFPC_PARAM ); } } } /** * instantiate the class */ $wp_nmc = new WPFFPC(); ?>