define('WS_CURRENT_VERSION', '4.5.1'); define('WS_DIR_PATH', plugin_dir_path(__FILE__)); define('WS_FOLDER', basename(WS_DIR_PATH)); # Load translation strings load_plugin_textdomain('word-stats', false, WS_FOLDER . '/languages/'); # Generic functions to do string stuff require_once 'basic-string-tools.php'; # This variable is meant to be used globally where needed. # Among other things, we usually won't want options changing during execution. $word_stats_options = Word_Stats_Core::load_options(); /* Check version. Perform upgrades. */ # Force recache to update stats. if (version_compare($word_stats_options['version'], '4.5.1') < 0) { Word_Stats_Core::recount_all(); } # Update version if ($word_stats_options['version'] != WS_CURRENT_VERSION) { $word_stats_options['version'] = WS_CURRENT_VERSION; update_option('word_stats_options', $word_stats_options); } /* # Hooks -------------------------------------------------------------- */ # Hook live stats. Load only when editing a post. if (isset($_GET['action'])) { if ($_GET['action'] == 'edit' || !strpos($_SERVER['SCRIPT_FILENAME'], 'post-new.php') === false) { add_action('admin_footer', array('Word_Stats_Core', 'live_stats')); } } # Hook stats caching when a post is saved