finnsk3
Forum Replies Created
-
Forum: Plugins
In reply to: [The Events Calendar] Calendar 6.5.1 problem with styling after updateSo I have been able to fix all the 404s to non minified js/css files.
There is an issue with maybe_get_min_file function in \the-events-calendar\common\vendor\vendor-prefixed\stellarwp\assets\src\Assets\Asset.php
it clearly expects $url being passed in to be a relative url not absolute. In my case they are all absolute so to fix this you need to change:if ( 0 === strpos( $url, $wpmu_plugin_url ) ) {
// URL inside WPMU plugin dir.
$base_dir = $base_dirs[ WPMU_PLUGIN_DIR ];
$base_url = $wpmu_plugin_url;
} elseif ( 0 === strpos( $url, $wp_plugin_url ) ) {
// URL inside WP plugin dir.
$base_dir = $base_dirs[ WP_PLUGIN_DIR ];
$base_url = $wp_plugin_url;
} elseif ( 0 === strpos( $url, $wp_content_url ) ) {
// URL inside WP content dir.
$base_dir = $base_dirs[ WP_CONTENT_DIR ];
$base_url = $wp_content_url;
} elseif ( 0 === strpos( $url, $plugins_url ) ) {
$base_dir = $base_dirs[ WP_PLUGIN_DIR ];
$base_url = $plugins_url;
} else {
// Resource needs to be inside wp-content or a plugins dir.
return false;
}to
if ( false !== strpos( $url, $wpmu_plugin_url ) ) {
// URL inside WPMU plugin dir.
$base_dir = $base_dirs[ WPMU_PLUGIN_DIR ];
$base_url = $wpmu_plugin_url;
} elseif ( false !== strpos( $url, $wp_plugin_url ) ) {
// URL inside WP plugin dir.
$base_dir = $base_dirs[ WP_PLUGIN_DIR ];
$base_url = $wp_plugin_url;
} elseif ( false !== strpos( $url, $wp_content_url ) ) {
// URL inside WP content dir.
$base_dir = $base_dirs[ WP_CONTENT_DIR ];
$base_url = $wp_content_url;
} elseif ( false !== strpos( $url, $plugins_url ) ) {
$base_dir = $base_dirs[ WP_PLUGIN_DIR ];
$base_url = $plugins_url;
} elseif ( false !== strpos( $url, $stylesheet_url ) ) {
$base_dir = $base_dirs[ $stylesheet_dir ];
$base_url = $stylesheet_url;
} else {
// Resource needs to be inside wp-content or a plugins dir.
return false;
}then this:
$relative_location = str_replace( $base_url . ‘/’, ”, $url );
needs to be change to
$relative_location = substr($url, strpos($url,$base_url) + strlen($base_url) + 1);
That has fixed all of the 404s we were getting. I don’t understand why you would use the non minified paths to declare your assets then rely on this function to use the minified path if it exists when the non minified path doesn’t exist in the first place. It seems crazy to do this. If you wanted a dev environment wouldn’t you just remove .min and check if that exists instead of the other way around.
This still hasn’t fixed all of my issues.When logged in the response is fine but when not logged in I get a completely blank response.
There is nothing in php logs. I will continue trying to debug the plugin, if I can fix it I will post my bugfix here.
- This reply was modified 9 months ago by finnsk3.
I don’t think it’s an issue with your plugin which is why I didn’t log a ticket. I just have a wierd filter applied to the editable_roles hook and I have no idea what is adding it. Just asking if anyone else has seen this kind of filter attached to the editable_roles hook.
Forum: Plugins
In reply to: [The Events Calendar] Fatal error: Uncaught TEC\Common\Exceptions\Same issue here.
This error is only thrown in wp-admin, currently reading through the PHP to see if I can find the bug.It doesn’t work wether it is enabled or disabeld.
With out merging enabled:<link rel='stylesheet' id='wpo_min-header-0-css' href='https://wp-content/cache/wpo-minify/1673751005/assets/wpo-minify-header-c830677b.min.css' type='text/css' media='all' />
I had a look through the PHP in the plugin and worked it out though. WP-Optimize is using WP_CONTENT_URL (line 39 – class-wp-optimize-minify.php).
WP_CONTENT_URL =define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' );
I am using an azure hosted wordpress instance and it has some weird settings in wp_config by default including siteurl:
define('WP_SITEURL', 'https://'. filter_input(INPUT_SERVER, 'HTTP_HOST', FILTER_SANITIZE_STRING));
INPUT_SERVER isn’t defined at all by default and I am not sure if this is something that can be done in the azure portal as I don’t work in infastructure I don’t have visilibity of it. That being said hardcoded ‘https://’ in the definition of WP_SITEURL sounds very wrong and after doing a google search it looks like people have ran in to this issue https://arlanblogs.alvarnet.com/change-http-to-https-in-azure-hosted-wordpress-website-when-option-grayed-out/
I just removed the definition for WP_HOME and WP_SITEURL so that I could edit these settings within the WP dashboard which fixed the issue. Luckily I have write access to wp_admin.php.
It’s an issue that only happens to people using azure app services but it could be fixed by not including WP_CONTENT_URL when defining WPO_CACHE_MIN_FILES_URL if WP_CONTENT_URL is incorrect.Thanks.
- This reply was modified 2 years, 1 month ago by finnsk3.
Forum: Plugins
In reply to: [Autoptimize] CSS/JS not being minifiedNo worries, I had a read through the plugin and fixed it.
autoptimizeStyles.php line 312:
$path = $this->getpath( $url );This always returns false for me so I just chucked in a simple fix:
if (substr($url,-4) == ‘.css’) $path = ABSPATH . substr($url,1);
else $path = $this->getpath( $url );I should have a look at why getpath is returning false here but it’s working for now so I will leave it at that.
Forum: Plugins
In reply to: [Autoptimize] CSS/JS not being minifiedYes, which is rather odd.
I tried this at the start of functions.php:
add_action('wp_head', function() { wp_enqueue_style('global', 'https://tasedu-ltwww-aso-prod-app-staging.azurewebsites.net/wp-content/themes/Libraries-Tasmania-Wordpress-Theme/static/css/global.css'); });
It appeared in the footer, I then disabled autoptimize and it appeared in the head so autoptimize seems to be moving it in and attempt to stop render block.
Forum: Plugins
In reply to: [Autoptimize] CSS/JS not being minifiedUnfortunately not, I made the following changes:
define('THEME_URL', get_template_directory_uri()); define('THEME_DIR', get_template_directory()); define('THEME_STATIC', THEME_URL . '/static'); define('THEME_BLOCKS', THEME_URL . '/blocks'); define('THEME_INC', THEME_DIR . '/includes'); define('THEME_ALERT_TOKEN_OPTION', 'theme_alert_token'); add_action('acf/init', 'my_acf_init_block_types'); add_action('edit_form_after_editor', 'setup_css_js'); add_action('wp_head', 'setup_css_js'); function setup_css_js() { wp_deregister_script('jquery'); wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js', array(), '3.5.1', false); wp_enqueue_script('jquery'); wp_enqueue_script('MobileMenu', THEME_STATIC . '/js/mobile-menu.js'); wp_enqueue_script('dropdownContainer', THEME_STATIC . '/js/dropdown-container.js'); wp_enqueue_script('searchTabs', THEME_STATIC . '/js/search-tabs.js'); wp_enqueue_script('tileSlider', THEME_STATIC . '/js/tile-slider.js'); wp_enqueue_script('artSlider', THEME_STATIC . '/js/art-slider.js'); wp_enqueue_script('artGallery', THEME_STATIC . '/js/art-gallery.js'); wp_enqueue_script('scrollToTop', THEME_STATIC . '/js/scroll-to-top.js'); wp_enqueue_script('JS', THEME_STATIC . '/js/index.js'); wp_enqueue_style('typography', 'https://tasedu-ltwww-aso-prod-app-staging.azurewebsites.net/wp-content/themes/Libraries-Tasmania-Wordpress-Theme/static/css/typography.css'); wp_enqueue_style('bootstrap', THEME_STATIC . '/css/bootstrap.css'); wp_enqueue_style('global', THEME_STATIC . '/css/global.css'); wp_enqueue_style('custom_buttons', THEME_STATIC . '/css/buttons.css'); wp_enqueue_style('container', THEME_STATIC . '/css/container.css'); wp_enqueue_style('grid', THEME_STATIC . '/css/grid.css'); wp_enqueue_style('art-slider', THEME_STATIC . '/css/art-slider.css'); wp_enqueue_style('sidebar', THEME_STATIC . '/css/sidebar.css'); wp_enqueue_style('header', THEME_STATIC . '/css/header.css'); wp_enqueue_style('footer', THEME_STATIC . '/css/footer.css'); }
note typography.css is using fqdn, resulting html:
<link rel=”stylesheet” id=”typography-css” href=”https://tasedu-ltwww-aso-prod-app-staging.azurewebsites.net/wp-content/themes/Libraries-Tasmania-Wordpress-Theme/static/css/typography.css?ver=6.0.1″ type=”text/css” media=”all”>