Skip to content

Commit

Permalink
Widget properly enqueues the right JS file based on SCRIPT_DEBUG
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterUpfold committed Sep 6, 2012
1 parent 75dd942 commit e2cdcfd
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions total-slider/total-slider.php
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,7 @@ public static function printSettingsPage()

Total_Slider::setCapabilityForRoles($rolesToAdd);
$success = true;
$message .= __('Required role level saved.', 'total_slider') . ' ';
$message = __('Settings saved.', 'total_slider');

}

Expand All @@ -1332,7 +1332,7 @@ public static function printSettingsPage()
if (array_key_exists('should_enqueue_template', $otherOptions) && $otherOptions['should_enqueue_template'] != '1')
{
$success = true;
$message .= __('Advanced settings saved.', 'total_slider') . ' ';
$message = __('Settings saved.', 'total_slider');
}

$otherOptions['should_enqueue_template'] = '1';
Expand All @@ -1343,7 +1343,7 @@ public static function printSettingsPage()
if (array_key_exists('should_enqueue_template', $otherOptions) && $otherOptions['should_enqueue_template'] != '0')
{
$success = true;
$message .= __('Advanced settings saved.', 'total_slider') . ' ';
$message = __('Settings saved.', 'total_slider');
}

$otherOptions['should_enqueue_template'] = '0';
Expand Down Expand Up @@ -1864,13 +1864,26 @@ public function widget($args, $instance) {

wp_enqueue_style( 'total-slider-' . esc_attr($group->template) );

// load .min.js if available, if SCRIPT_DEBUG is not true in wp-config.php
$isMin = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? false : true;

if ($isMin)
{
$jsURI = $tpl->jsMinURI();
$jsPath = $tpl->jsMinPath();
}
else {
$jsURI = $tpl->jsURI();
$jsPath = $tpl->jsPath();
}

wp_register_script(
'total-slider-' . esc_attr($group->template), /* handle */
$tpl->jsURI(), /* src */
$jsURI, /* src */
array(
'jquery'
), /* deps */
date("YmdHis", @filemtime( $tpl->jsPath()) ), /* ver */
date("YmdHis", @filemtime( $jsPath) ), /* ver */
true /* in_footer */
);

Expand Down

0 comments on commit e2cdcfd

Please sign in to comment.