/** * Ajax Clear all builder caches. * * @since 2.4.2 * @access public * @return json */ public function clear_all_builder_caches() { check_ajax_referer('ajax-nonce', 'nonce'); // Clear the cache TFCache::removeDirectory(TFCache::get_cache_dir()); wp_send_json_success('success'); }
function run($options) { $defaults = array('package' => '', 'destination' => '', 'clear_destination' => false, 'clear_working' => true, 'is_multi' => false, 'hook_extra' => array()); $options = wp_parse_args($options, $defaults); extract($options); //Connect to the Filesystem first. $res = $this->fs_connect(array(WP_CONTENT_DIR, $destination)); if (!$res) { //Mainly for non-connected filesystem. return false; } if (is_wp_error($res)) { $this->skin->error($res); return $res; } if (!$is_multi) { // call $this->header separately if running multiple times $this->skin->header(); } $this->skin->before(); //Download the package (Note, This just returns the filename of the file if the package is a local file) $download = $this->download_package($package); if (is_wp_error($download)) { $this->skin->error($download); $this->skin->after(); return $download; } $delete_package = $download != $package; // Do not delete a "local" file //Unzip's the file into a temporary directory $working_dir = $this->unpack_package($download, $delete_package); if (is_wp_error($working_dir)) { $this->skin->error($working_dir); $this->skin->after(); return $working_dir; } //With the given options, this installs it to the destination directory. $result = $this->install_package(array('source' => $working_dir, 'destination' => $destination, 'clear_destination' => $clear_destination, 'clear_working' => $clear_working, 'hook_extra' => $hook_extra)); $this->skin->set_result($result); if (is_wp_error($result)) { $this->skin->error($result); $this->skin->feedback('process_failed'); } else { //Install Suceeded $this->skin->feedback('process_success'); printf(esc_html__('Deleting transient for %s', 'themify'), $hook_extra['type']); if ($hook_extra['type'] == 'framework') { delete_transient('themify_new_framework'); themify_set_update_cookie('framework'); } else { $theme = wp_get_theme(); $theme_name = $theme->get_template(); $theme_hash = md5($theme_name); delete_transient('themify_new_theme' . $theme_hash); themify_set_update_cookie('theme'); } TFCache::removeDirectory(TFCache::get_cache_dir()); } $this->skin->after(); if (!$is_multi) { $this->skin->footer(); } return $result; }