/** * URI to the parent-theme framework customizations directory * @param string $rel_path * @return string */ function fw_get_template_customizations_directory_uri($rel_path = '') { static $cache = null; if ($cache === null) { $cache = get_template_directory_uri() . fw_get_framework_customizations_dir_rel_path(); } return $cache . $rel_path; }
/** * URI to the parent-theme framework customizations directory * @param string $rel_path * @return string */ function fw_get_template_customizations_directory_uri($rel_path = '') { try { $dir = FW_Cache::get($cache_key = 'fw_template_customizations_dir_uri'); } catch (FW_Cache_Not_Found_Exception $e) { FW_Cache::set($cache_key, $dir = get_template_directory_uri() . fw_get_framework_customizations_dir_rel_path()); } return $dir . $rel_path; }
/** * Copy Theme Available Extensions from tmp directory to theme * Used after theme update * @since 2.6.0 * @return null|WP_Error */ public function theme_available_extensions_restore() { /** @var WP_Filesystem_Base $wp_filesystem */ global $wp_filesystem; if (!$wp_filesystem || is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) { return new WP_Error('fs_not_initialized', __('WP Filesystem is not initialized', 'fw')); } if (!$wp_filesystem->exists($wpfs_tmp_dir = FW_WP_Filesystem::real_path_to_filesystem_path($this->get_tmp_dir('/theme-ext')))) { return new WP_Error('no_tmp_dir', sprintf(__('Temporary directory does not exist: %s', 'fw'), $wpfs_tmp_dir)); } /** * Fixes the case when the theme path before update was * wp-content/themes/theme-name/theme-name-parent * but after update it became * wp-content/themes/theme-name-parent * * and at this point get_template_directory() returns old theme directory * so fw_get_template_customizations_directory() also returns old path */ $theme_dir = wp_get_theme()->get_theme_root() . '/' . wp_get_theme()->get_template(); if (!($wpfs_base_dir = FW_WP_Filesystem::real_path_to_filesystem_path($base_dir = $theme_dir . fw_get_framework_customizations_dir_rel_path('/extensions')))) { return new WP_Error('base_dir_to_wpfs_fail', sprintf(__('Cannot obtain WP Filesystem dir for %s', 'fw'), $base_dir)); } if (!($dirlist = $wp_filesystem->dirlist($wpfs_tmp_dir))) { return; } foreach ($dirlist as $filename => $fileinfo) { if ('d' !== $fileinfo['type']) { continue; } if (is_wp_error($merge_result = $this->merge_extension($wpfs_tmp_dir . '/' . $filename, $wpfs_base_dir . '/' . $filename))) { return $merge_result; } } $wp_filesystem->rmdir($wpfs_tmp_dir, true); }