Skip to content

Commit

Permalink
Fix loading of development JavaScript and CSS files when ARSKI_DEBUG …
Browse files Browse the repository at this point in the history
…is set to true.
  • Loading branch information
beastaugh committed Jul 3, 2011
1 parent 1e90f70 commit f5415db
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 37 deletions.
36 changes: 36 additions & 0 deletions app/api/deprecated.php
Expand Up @@ -11,6 +11,42 @@
* @link http://tarskitheme.com/forum/
*/

/**
* If debug mode is enabled, use uncompressed (development mode) JavaScript.
*
* @since 2.7
* @deprecated 3.1.0
*
* @see TARSKI_DEBUG
* @uses _tarski_compressible_asset_path
*
* @param string $path
* @return string
*/
function tarski_js($path) {
_deprecated_function(__FUNCTION__, '3.1.0');

return tarski_asset_path($path);
}

/**
* If debug mode is enabled, use uncompressed (development mode) CSS.
*
* @since 2.7
* @deprecated 3.1.0
*
* @see TARSKI_DEBUG
* @uses _tarski_compressible_asset_path
*
* @param string $path
* @return string
*/
function tarski_css($path) {
_deprecated_function(__FUNCTION__, '3.1.0');

return tarski_asset_path($path);
}

/**
* Adds JavaScript to the Tarski Options page.
*
Expand Down
6 changes: 6 additions & 0 deletions changelog.txt
Expand Up @@ -18,10 +18,16 @@
function `tarski_should_show_authors`
* Deprecated `tarski_count_authors` and `tarski_resave_show_authors`
functions
* Deprecated `tarski_css` and `tarski_js` functions
* Removed all functions deprecated before version 3.0
* Deprecated `tarski_inject_scripts` function
* Removed defunct admin page JavaScript

#### Bug fixes

* Make development JavaScript and CSS files load when `TARSKI_DEBUG` is set
to `true`


### Version 3.0.5 [§](http://tarskitheme.com/2011/03/18/3-0-release/)

Expand Down
2 changes: 1 addition & 1 deletion functions.php
Expand Up @@ -175,7 +175,7 @@
} else {
// JavaScript
wp_enqueue_script('tarski',
get_template_directory_uri() . '/app/js/tarski.js',
tarski_asset_path('app/js/tarski.js'),
array('jquery'), theme_version());
wp_localize_script('tarski', 'objectL10n', array(
'expand' => __('Expand', 'tarski'),
Expand Down
42 changes: 8 additions & 34 deletions library/core.php
Expand Up @@ -34,36 +34,6 @@ function is_valid_tarski_style($name) {
!preg_match('/^(janus|centre|rtl|js).css$/', $file);
}

/**
* If debug mode is enabled, use uncompressed (development mode) JavaScript.
*
* @since 2.7
*
* @see TARSKI_DEBUG
* @uses _tarski_compressible_asset_path
*
* @param string $path
* @return string
*/
function tarski_js($path) {
return _tarski_compressible_asset_path('js', $path);
}

/**
* If debug mode is enabled, use uncompressed (development mode) CSS.
*
* @since 2.7
*
* @see TARSKI_DEBUG
* @uses _tarski_compressible_asset_path
*
* @param string $path
* @return string
*/
function tarski_css($path) {
return _tarski_compressible_asset_path('css', $path);
}

/**
* If debug mode is enabled, use an uncompressed version of the file.
*
Expand All @@ -76,11 +46,15 @@ function tarski_css($path) {
* @param string $path
* @return string
*/
function _tarski_compressible_asset_path($type, $path) {
$dev = defined('TARSKI_DEBUG') && TARSKI_DEBUG === true ? '.dev' : '';
$path = preg_replace("/\.${type}$/", '', $path);
function tarski_asset_path($path) {
$matches = array();
preg_match("/\\.[A-Za-z\d]+\$/", $path, &$matches);
$ext = count($matches) > 0 ? $matches[0] : '';
$suffix = defined('TARSKI_DEBUG') && TARSKI_DEBUG === true ? '.dev' : '';
$root = get_template_directory_uri();
$path = preg_replace("/${ext}\$/", '', $path);

return $path . $dev . ".${type}";
return $root . '/' . $path . $suffix . $ext;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions library/helpers/template_helper.php
Expand Up @@ -182,9 +182,9 @@ function tarski_meta() {
function tarski_stylesheets() {
$style_array = array(
'main' => array(
'url' => get_bloginfo('stylesheet_url')),
'url' => tarski_asset_path('style.css')),
'print' => array(
'url' => get_template_directory_uri() . '/library/css/print.css',
'url' => tarski_asset_path('library/css/print.css'),
'media' => 'print'));

if (get_tarski_option('style')) {
Expand Down

0 comments on commit f5415db

Please sign in to comment.