public static function create_find_cache_dir() { // if we already have a cache path reutrn it if (!empty(self::$cache_path)) { return self::$cache_path; } // determine the cache dir name $u = wp_upload_dir(); $base_dir_name = 'qsot-cache-' . substr(sha1(site_url()), 10, 10); $final_path = $u['basedir'] . DIRECTORY_SEPARATOR . $base_dir_name . DIRECTORY_SEPARATOR; return self::$cache_path = trailingslashit(self::create_find_path($final_path)); }
public function page_head() { $current = $this->_current_tab(); $args = array(); // if we are on the tools page, and the current user can manage wp options if ('tools' == $current && current_user_can('manage_options')) { $processed = false; // if the tool requested is on our list, then handle it appropriately if (isset($_GET['qsot-tool'])) { switch ($_GET['qsot-tool']) { // when not in this list, call an specialized functions for this default: if (has_action('qsot-ss-tool-' . $_GET['qsot-tool'])) { list($processed, $args) = apply_filters('qsot-ss-tool-' . $_GET['qsot-tool'], false, $args); } break; // force a resync of all the purchased tickets // force a resync of all the purchased tickets case 'RsOi2Tt': if ($this->_verify_action_nonce('RsOi2Tt')) { $state = $_GET['state'] == 'bg' ? '-bg' : ''; if ($this->_perform_resync_order_items_to_ticket_table()) { $args['performed'] = 'resync' . $state; } else { $args['performed'] = 'failed-resync' . $state; } $processed = true; } break; // force a repair of the db tables // force a repair of the db tables case 'FdbUg': if ($this->_verify_action_nonce('FdbUg')) { delete_option('_qsot_upgrader_db_table_versions'); $args['performed'] = 'removed-db-table-versions'; $processed = true; } break; // remove all the assets that have been cached for ticket pdf creation // remove all the assets that have been cached for ticket pdf creation case 'RmTFC': if ($this->_verify_action_nonce('RmTFC')) { $path = QSOT_cache_helper::create_find_cache_dir(); try { self::_empty_dir($path); $args['performed'] = 'removed-ticket-asset-cache'; $processed = true; } catch (Exception $e) { $args['performed'] = 'failed-ticket-asset-cache'; $processed = true; } } break; } } // if one of the actions was actually processed, then redirect, which protects the 'refresh-resubmit' situtation if ($processed) { wp_safe_redirect(add_query_arg($args, remove_query_arg(array('updated', 'performed', 'qsot-tool', 'qsotn')))); exit; } } }