Skip to content

Commit

Permalink
ao loves asyncjs
Browse files Browse the repository at this point in the history
  • Loading branch information
futtta committed Mar 15, 2018
1 parent 442fb04 commit 806e3d6
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions classlesses/autoptimizeExtra.php
Expand Up @@ -35,7 +35,7 @@ function autoptimize_extra_init() {
}

/* async JS */
if (!empty($autoptimize_extra_options['autoptimize_extra_text_field_3'])) {
if ( !empty($autoptimize_extra_options['autoptimize_extra_text_field_3']) && !is_plugin_active('autoptimize/autoptimize.php') ) {

This comment has been minimized.

Copy link
@zytzagoo

zytzagoo Mar 16, 2018

Collaborator

This looks off at first look, I mean, if there are extra options for field_3 and AO is not active, adding an autoptimize_filter_js_exclude to execute autoptimize_extra_async_js will work how exactly?

I mean, how will autoptimize_extra_init() execute/get-called at all if AO plugin is not active? Am I missing something? If not (missing anything), this effectively became dead code now, and autoptimize_extra_async_js is never getting hooked/called anymore?

This comment has been minimized.

Copy link
@zytzagoo

zytzagoo Mar 16, 2018

Collaborator

Was that plugin_active check supposed to be checking for async-javascript/async-javascript.php and not autoptimize/autoptimize.php as is currently written above?

This comment has been minimized.

Copy link
@futtta

futtta via email Mar 16, 2018

Author Owner
add_filter('autoptimize_filter_js_exclude','autoptimize_extra_async_js',10,1);
}

Expand Down Expand Up @@ -339,9 +339,21 @@ function autoptimize_extra_options_page() {
<tr>
<th scope="row"><?php _e('Async Javascript-files <em>(advanced users)</em>','autoptimize'); ?></th>
<td>
<input type='text' style='width:80%' name='autoptimize_extra_settings[autoptimize_extra_text_field_3]' value='<?php echo $autoptimize_extra_options['autoptimize_extra_text_field_3']; ?>'>
<br />
<?php _e('Comma-separated list of local or 3rd party JS-files that should loaded with the <code>async</code> flag. JS-files from your own site will be automatically excluded if added here.','autoptimize'); ?>
<?php if ( is_plugin_active('async-javascript/async-javascript.php') ) {
_e('You have "Async JavaScript" installed, ','autoptimize');
$asj_config_url="options-general.php?page=async-javascript";
echo sprintf('<a href="'.$asj_config_url.'">%s</a>', __('configuration of async javascript is best done there.'));
} else { ?>
<input type='text' style='width:80%' name='autoptimize_extra_settings[autoptimize_extra_text_field_3]' value='<?php echo $autoptimize_extra_options['autoptimize_extra_text_field_3']; ?>'>
<br />
<?php
_e('Comma-separated list of local or 3rd party JS-files that should loaded with the <code>async</code> flag. JS-files from your own site will be automatically excluded if added here. ','autoptimize');
echo "<strong>";
_e('Configuration of async javascript is easier and more flexible using the "Async Javascript"-plugin. ','autoptimize');
echo "</strong>";
$asj_install_url= network_admin_url()."plugin-install.php?s=async+javascript&tab=search&type=term";
echo sprintf('<a href="'.$asj_install_url.'">%s</a>', __('Click here to install it.'));
} ?>
</td>
</tr>
</table>
Expand Down

0 comments on commit 806e3d6

Please sign in to comment.