intuitart
Forum Replies Created
-
Yes, ‘Allow users to be assigned more than a single role.’ is checked. I am assigning multiple roles.
Further to my original message, when I hack line 1184 in the code and make $hook_name a string, everything works fine.
From WordPress developer resources, the apply_filters function is a string, not a string or array:
apply_filters( string $hook_name, mixed $value )Your code is defining it as a array:
return apply_filters( array( $this, 'bnfw_members_sanitize_role' ), str_replace( ' ', '_', $_role ), $role );To make things work I changed that to:
return apply_filters( 'bnfw_members_sanitize_role', str_replace( ' ', '_', $_role ), $role );Hope this helps,
Andrew P.
You’re right. Sorry for cluttering your support forum. AP
Forum: Reviews
In reply to: [Absolute Relative URLs] UselessOK, the plugin will only save URLs as relative after it is installed. It doesn’t change those that have already been saved as absolute.
If you only have a few posts or pages, you can edit each one and save it again. Do this when it is running from the internal IP address if that’s the URL used when the post was created.
Alternatively, you can add a filter to functions.php that tells the plugin to look for a specific URL and replace it with your new URL. For example:
add_filter( 'of_absolute_relative_urls_related_sites', function( $related_sites ) { $related_sites[] = "http://192.159.0.100"; return $related_sites; } );If you want to run from both URLs as the same time, you can define the wordpress and site URLs in wp-config.php. This tells WP to use the URL from the browser instead of the URLs in Settings. Here is the code for this:
define( 'WP_SITEURL', $_SERVER['REQUEST_SCHEME'] . '://'. $_SERVER['HTTP_HOST'] ); define( 'WP_HOME', $_SERVER['REQUEST_SCHEME'] . '://'. $_SERVER['HTTP_HOST'] );Let me know how you make out.
Andrew P.
Forum: Reviews
In reply to: [Absolute Relative URLs] UselessTell me more…
Were you using this prior to WP 5.8?
Which editor are you using, Classic or the new editor?
What are you seeing that suggests it doesn’t work?Andrew P.
Sounds reasonable. Thanks for reporting the issue. The intent is that the plugin just work with minimal configuration, and most of the time it does that, but there are always edge cases…
OK, what you are seeing is a result of one of the fundamental assumptions in how the plugin works. Both urls get removed when saving a post. The ~/wordpress url is re-inserted only for files in the uploads folder.
So my next question is, what is your use case for linking to files outside the uploads folder? A custom application? Uploading images or documents manually outside of the media upload process?
A possible workaround is to add a filter in functions.php to always use the ~/wordpress url when generating an absolute url for display. This can be done with the following:
add_filter( 'of_absolute_relative_urls_url', function( $url, $wpurl ) {return $wpurl;}, 10, 2 );Hope this helps, and I am curious about your use case.
Andrew P.
- This reply was modified 4 years, 6 months ago by intuitart.
Thanks for reporting this. One question before I set this up to test, are you using the classic editor or the newer block editor?
Andrew P.
Forum: Reviews
In reply to: [Absolute Relative URLs] UselessTo accomplish this you have two things to deal with.
First, I assume those accessing the site from outside have a different URL than the ones accessing the site from inside. You can deal with this by adding two lines to wp-config.php. This tells WP, and this plugin, to use the URL accessing the site as the site and wordpress URLs.
define( 'WP_SITEURL', $_SERVER['REQUEST_SCHEME'] . '://'. $_SERVER['HTTP_HOST'] ); define( 'WP_HOME', $_SERVER['REQUEST_SCHEME'] . '://'. $_SERVER['HTTP_HOST'] );Second, you want existing posts to have relative URLs so they display properly both inside and outside the organization. There are a couple of ways of handling this. If there are only a few posts at the moment, just enable this plugin, edit and re-save each post. This will convert the URLs to relative. The second option is to use the related_sites filter in functions.php so that the plugin treats specific URLs as though they are relative.
add_filter( 'of_absolute_relative_urls_related_sites', function( $related_sites ) { $related_sites[] = "http://originalsite.org"; return $related_sites; } );Replace originalsite.org with your own domain.
Hope this helps,
Andrew P.
Forum: Reviews
In reply to: [Absolute Relative URLs] UselessAre you trying to display a different url than what was saved? You can do that.
Or are you wanting it to go through the database and remove absolute urls? The absolute part of a url is removed when it is saved, and at this time there is no batch process to do that retroactively. You would have to edit and re-save a post to remove urls.
Forum: Plugins
In reply to: [Absolute Relative URLs] Real Time Conversion from Relative to Absolute linksHi Amir,
Yes the plugin works in real time to convert relative to absolute links. It’s hard to answer about other plugins with knowing the specifics. I’ve seen this plugin work well with other plugins and I’ve seen it miss URLs, particularly when they are stored in custom tables or when a plugin author bypasses WP update and retrieve functions to access the database directly. So it depends. My understanding is that WP looks after it’s menu links, saving as relative and displaying as absolute.
The best thing is to test a specific situation. If you find something that doesn’t work, let me know.
Andrew P.
Forum: Plugins
In reply to: [Absolute Relative URLs] Get it to work in a hosted wordpressAaaah, ok, now I understand. This is a novel requirement, one I hadn’t considered when developing the plugin. I also understand now why it doesn’t work for you. The plugin relies on the WordPress and Site URLs to work. And unfortunately, there isn’t currently a filter to override those. But that is what you need to do.
If you are willing to hack the code, you could override those.
In the
set_vars()function, add the following lines immediately after the code where those variable are currently set:self::$wpurl = "https://www.mydomain.com/blog"; self::$url = "https://www.mydomain.com/blog";Now your domain will get used when building the absolute URL for display in the browser. However, changing this also means the wordpress.com domain will not be removed when saving relative URLs in the databases. That’s where the relates_sites filter can help. In functions php, add the following filter:
add_filter( 'of_absolute_relative_urls_related_sites', function( $related_sites ) { $related_sites[]['url'] = "https://mydomain.wordpress.com"; return $related_sites; } );Now the wordpress.com domain will get removed even though it is no longer the WordPress or Site URL.
Hope this helps. Let me know how you make out.
Andrew P.
Forum: Plugins
In reply to: [Absolute Relative URLs] Get it to work in a hosted wordpressOK I’m not convinced I understand the requirement, especially if your hook into ‘post_link’ resolves it for you.
Can we back up a step, and would you tell me why you want relative links? i.e. what problem, or situation, are you trying to solve?
By the way, a relative link for me is a URL without the scheme and domain. For example, an absolute URL of
https://www.mydomain.com/wp-content/2019/12/image.jpgwould become/wp-content/2019/12/image.jpgwhen converted to relative. That’s what would be saved in the database using this plugin.A special case for WordPress sites where the site itself is in a folder would drop the folder, along with the scheme and domain, when converting to relative. For exampe, an absolute URL of
https://www.mydomain.com/blog/wp-content/2019/12/image.jpgwould become/wp-content/2019/12/image.jpgwhen converted to relative, the same as above.As long as the WordPress and Site URLs are set properly in the Settings, the relative URL would be converted back to it’s original form when displayed. In the first example
https://www.mydomain.comwould be prefixed to the relative URL, and in the second examplehttps://www.mydomain.com/blogwould be prefixed to the relative URL.Forum: Plugins
In reply to: [Absolute Relative URLs] Get it to work in a hosted wordpressYou can accomplish what you are trying to do with this plugin, that is save and display URLs as relative. This is a scenario where you want to override the plugin’s default behaviour.
By default, URLs are saved as relative and displayed as absolute. To have them displayed as relative you can disable the conversion back to absolute when they are displayed. But leave the conversion to relative when they are saved in place.
Add this to functions.php:
add_filter( 'of_absolute_relative_urls_enable_absolute', function() { return false; } );If I understand your requirement, that should do it.
Andrew P.
Forum: Plugins
In reply to: [Absolute Relative URLs] Get it to work in a hosted wordpressOK first things first. Make sure the plugin is working before trying to modify the default behaviour. In most cases you shouldn’t need to customize it (i.e. no filters required in functions.php in order for the plugin to work).
If wordpress.com is allowing you to install plugins, it is unlikely they are blocking filters.
To test your own filters, just echo some text to the browser or save some text to a debug file. Dig in to php to learn those things. When you see the text you display or save, you know the filter is firing.
Forum: Plugins
In reply to: [Absolute Relative URLs] Get it to work in a hosted wordpressIs it possible that wordpress.com does something to block filters? I’m not aware of it. And I’m unable to test at wordpress.com.
Otherwise, there isn’t enough information for me to help troubleshoot.
Have you had it working on a hosted site elsewhere?
Was the plugin activated?
Does the plugin work, but not the filters, or is nothing working?
Have you put something in your code to determine whether or not the filters fire?
Let me know what you find.
Andrew P.