Mads Phikamphon
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Rewrite rules dropped at random intervalsHere’s one that disappears once in a while, i.e. the German version /de/p/.. stops working, while the English version /p/.. keeps working.
add_rewrite_rule( '^de/p/([^/]*)/?', 'index.php?products=$matches[1]', 'top' );
German version (/de/p/..) isn’t a post, so that’s why the rewrite rule is needed. English version (/p/..) is a post (of a custom post type).
Forum: Developing with WordPress
In reply to: wp_remote_get arguments not receivedThanks a lot for the answer.
$request
is the parameter of the API function like this:public function mtp_api_get_product($request) {...}
Not sure if you can pass arbitrary args, but that thinking lead me to the solution.
Just do like this:
$url = "https://www.modeltrainprices.com/wp-json/public/get-product?brand=" . $atts['brand'] . "&model=" . $atts['model'] . "¤cy=" . $atts['currency'] . "&key=" . $atts['api-key']; $response = wp_remote_get($url);
Then everything works just like it did with curl.
- This reply was modified 2 years, 2 months ago by Mads Phikamphon.
Forum: Fixing WordPress
In reply to: Offloading cron jobsGood point. It’s not WP specific. Let me close this one and ask in StackExchange instead.
Forum: Plugins
In reply to: [Advanced Cron Manager - debug & control] Cron job vs. reading/writing filesFound the solution:
When a job is started from the dashboard, the directory is
DOMAIN/wp-admin/
.When a job is started through the cron scheduling, the directory is only
DOMAIN
.Adding a quick
chdir('wp-admin');
fixes the issue, so everything is good now.Forum: Fixing WordPress
In reply to: JS not running on phonesIt was defer thing that messed things up.
Defer was added by an option in WP Rocket caching. Disabling the defer JS option fixed the problem, so now the page (https://www.bulkhackers.com/deals/) seems to work everywhere.
Thanks a lot for the hint @bcworkz
Forum: Fixing WordPress
In reply to: JS not running on phonesThanks a lot for your reply. I think it’s actually part of the problem.
In some browsers, my JS file with get_supported_countries() is included like this when I do view source:
<script type=’text/javascript’ src=’https://localhost/wp-content/plugins/bulk-hackers-stuff/js/deals.js?ver=5.1.4′></script>
In other browsers, it looks like this:
<script type=’text/javascript’ src=’https://localhost/wp-content/plugins/bulk-hackers-stuff/js/deals.js’ defer></script>
As far as I can understand, the defer means the JS file isn’t loaded right away and get_supported_countries() is therefore undefined.
Now the big question is why it’s not the same source output in all browsers. I can get both versions in browsers where I’m not logged in, so whether I’m logged in or not is not the problem.
- This reply was modified 4 years, 7 months ago by Mads Phikamphon.
Forum: Developing with WordPress
In reply to: Check user session by HeartBeatI would add a an action and control it through cron. The cron settings can be controlled easily through a WP cron plugin (I like Advanced Cron Manager).
Like this:
add_action('my_action', 'my_function'); function my_function() { ... }
Forum: Plugins
In reply to: [Subscribe To Comments Reloaded] Function for adding subscribersThe link above doesn’t seem to work anymore. We need to add www in front of it, i.e. https://subscribe-reloaded.com/function-to-add-subscribers-manually/
- This reply was modified 4 years, 7 months ago by Mads Phikamphon.
Forum: Fixing WordPress
In reply to: Shortcode with Instagram embeddingThanks! wp_oembed_get() works.
Only issue is that it slows things down vs. having the Instagram url directly in the post content.
Luckily I found this cache trick by Stanislav Khromov that fixes the performance issue: https://snippets.khromov.se/how-to-cache-the-wp_oembed_get-function/
Forum: Plugins
In reply to: [Subscribe To Comments Reloaded] Function for adding subscribersThat’s super awesome! Thanks – and thanks for provide an easy to follow guide too.
Forum: Plugins
In reply to: [Subscribe To Comments Reloaded] Function for adding subscribersThanks a lot for the update! – and for the awesome plugin.
Forum: Plugins
In reply to: [Subscribe To Comments Reloaded] Function for adding subscribersHow is it going with the function? Can you share the name of it?
Thanks,
MadsForum: Plugins
In reply to: [Subscribe To Comments Reloaded] Function for adding subscribersThat’s super awesome! Looking forward to the update.
Forum: Fixing WordPress
In reply to: Url changes to ?post_type=Solution found, just add this to the code:
https://biostall.com/prevent-wordpress-redirecting-to-nearest-matching-url/
Thanks for the hint to
Forum: Fixing WordPress
In reply to: Url changes to ?post_type=I have tried to do add_action() for
init
andwp_loaded
– in both cases, the url is still/b/lima/
, i.e. the url/redirect to?post_type=
happens after those two actions.Here’s exactly how it goes:
init - url is /b/lima wp_loaded - url is /b/lima init - url is now ?post_type :( wp_loaded - url is ?post_type template_redirect - url is ?post_type
Note that template_redirect is never reached when the url is
/b/lima
.- This reply was modified 5 years, 3 months ago by Mads Phikamphon.
- This reply was modified 5 years, 3 months ago by Mads Phikamphon.