Title: Mads Phikamphon's Replies | WordPress.org

---

# Mads Phikamphon

  [  ](https://wordpress.org/support/users/madsphi/)

 *   [Profile](https://wordpress.org/support/users/madsphi/)
 *   [Topics Started](https://wordpress.org/support/users/madsphi/topics/)
 *   [Replies Created](https://wordpress.org/support/users/madsphi/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/madsphi/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/madsphi/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/madsphi/engagements/)
 *   [Favorites](https://wordpress.org/support/users/madsphi/favorites/)

 Search replies:

## Forum Replies Created

Viewing 15 replies - 1 through 15 (of 87 total)

1 [2](https://wordpress.org/support/users/madsphi/replies/page/2/?output_format=md)
[3](https://wordpress.org/support/users/madsphi/replies/page/3/?output_format=md)
[4](https://wordpress.org/support/users/madsphi/replies/page/4/?output_format=md)
[5](https://wordpress.org/support/users/madsphi/replies/page/5/?output_format=md)
[6](https://wordpress.org/support/users/madsphi/replies/page/6/?output_format=md)
[→](https://wordpress.org/support/users/madsphi/replies/page/2/?output_format=md)

 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Rewrite rules dropped at random intervals](https://wordpress.org/support/topic/rewrite-rules-dropped/)
 *  Thread Starter [Mads Phikamphon](https://wordpress.org/support/users/madsphi/)
 * (@madsphi)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/rewrite-rules-dropped/#post-16109349)
 * Here’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](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [wp_remote_get arguments not received](https://wordpress.org/support/topic/wp_remote_get-arguments-not-received/)
 *  Thread Starter [Mads Phikamphon](https://wordpress.org/support/users/madsphi/)
 * (@madsphi)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/wp_remote_get-arguments-not-received/#post-15965004)
 * Thanks 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'] . "&currency=" . $atts['currency'] . "&key=" . $atts['api-key'];
   
       $response = wp_remote_get($url);
       ```
   
 * Then everything works just like it did with curl.
    -  This reply was modified 3 years, 10 months ago by [Mads Phikamphon](https://wordpress.org/support/users/madsphi/).
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Offloading cron jobs](https://wordpress.org/support/topic/offloading-cron-jobs/)
 *  Thread Starter [Mads Phikamphon](https://wordpress.org/support/users/madsphi/)
 * (@madsphi)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/offloading-cron-jobs/#post-15959164)
 * Good point. It’s not WP specific. Let me close this one and ask in StackExchange
   instead.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Advanced Cron Manager - debug & control] Cron job vs. reading/writing files](https://wordpress.org/support/topic/cron-job-vs-reading-writing-files/)
 *  Thread Starter [Mads Phikamphon](https://wordpress.org/support/users/madsphi/)
 * (@madsphi)
 * [5 years, 12 months ago](https://wordpress.org/support/topic/cron-job-vs-reading-writing-files/#post-13110384)
 * Found 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](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [JS not running on phones](https://wordpress.org/support/topic/js-not-running-on-phones/)
 *  Thread Starter [Mads Phikamphon](https://wordpress.org/support/users/madsphi/)
 * (@madsphi)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/js-not-running-on-phones/#post-12739090)
 * It 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/](https://www.bulkhackers.com/deals/))
   seems to work everywhere.
 * Thanks a lot for the hint [@bcworkz](https://wordpress.org/support/users/bcworkz/)
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [JS not running on phones](https://wordpress.org/support/topic/js-not-running-on-phones/)
 *  Thread Starter [Mads Phikamphon](https://wordpress.org/support/users/madsphi/)
 * (@madsphi)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/js-not-running-on-phones/#post-12736749)
 * Thanks 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=’[http://localhost/wp-content/plugins/bulk-hackers-stuff/js/deals.js?ver=5.1.4′></script&gt](http://localhost/wp-content/plugins/bulk-hackers-stuff/js/deals.js?ver=5.1.4′></script&gt);
 * In other browsers, it looks like this:
 * <script type=’text/javascript’ src=’[http://localhost/wp-content/plugins/bulk-hackers-stuff/js/deals.js&#8217](http://localhost/wp-content/plugins/bulk-hackers-stuff/js/deals.js&#8217);
   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 6 years, 2 months ago by [Mads Phikamphon](https://wordpress.org/support/users/madsphi/).
 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [Check user session by HeartBeat](https://wordpress.org/support/topic/check-user-session-by-heartbeat/)
 *  [Mads Phikamphon](https://wordpress.org/support/users/madsphi/)
 * (@madsphi)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/check-user-session-by-heartbeat/#post-12724984)
 * I 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](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Subscribe To Comments Reloaded] Function for adding subscribers](https://wordpress.org/support/topic/function-for-adding-subscribers/)
 *  Thread Starter [Mads Phikamphon](https://wordpress.org/support/users/madsphi/)
 * (@madsphi)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/function-for-adding-subscribers/#post-12650913)
 * The link above doesn’t seem to work anymore. We need to add www in front of it,
   i.e. [http://subscribe-reloaded.com/function-to-add-subscribers-manually/](http://subscribe-reloaded.com/function-to-add-subscribers-manually/)
    -  This reply was modified 6 years, 3 months ago by [Mads Phikamphon](https://wordpress.org/support/users/madsphi/).
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Shortcode with Instagram embedding](https://wordpress.org/support/topic/shortcode-with-instagram-embedding/)
 *  Thread Starter [Mads Phikamphon](https://wordpress.org/support/users/madsphi/)
 * (@madsphi)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/shortcode-with-instagram-embedding/#post-12604680)
 * Thanks! 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/](https://snippets.khromov.se/how-to-cache-the-wp_oembed_get-function/)
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Subscribe To Comments Reloaded] Function for adding subscribers](https://wordpress.org/support/topic/function-for-adding-subscribers/)
 *  Thread Starter [Mads Phikamphon](https://wordpress.org/support/users/madsphi/)
 * (@madsphi)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/function-for-adding-subscribers/#post-12399948)
 * That’s super awesome! Thanks – and thanks for provide an easy to follow guide
   too.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Subscribe To Comments Reloaded] Function for adding subscribers](https://wordpress.org/support/topic/function-for-adding-subscribers/)
 *  Thread Starter [Mads Phikamphon](https://wordpress.org/support/users/madsphi/)
 * (@madsphi)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/function-for-adding-subscribers/#post-12370025)
 * Thanks a lot for the update! – and for the awesome plugin.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Subscribe To Comments Reloaded] Function for adding subscribers](https://wordpress.org/support/topic/function-for-adding-subscribers/)
 *  Thread Starter [Mads Phikamphon](https://wordpress.org/support/users/madsphi/)
 * (@madsphi)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/function-for-adding-subscribers/#post-12364514)
 * How is it going with the function? Can you share the name of it?
 * Thanks,
    Mads
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Subscribe To Comments Reloaded] Function for adding subscribers](https://wordpress.org/support/topic/function-for-adding-subscribers/)
 *  Thread Starter [Mads Phikamphon](https://wordpress.org/support/users/madsphi/)
 * (@madsphi)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/function-for-adding-subscribers/#post-12281498)
 * That’s super awesome! Looking forward to the update.
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Url changes to ?post_type=](https://wordpress.org/support/topic/url-changes-to-post_type/)
 *  Thread Starter [Mads Phikamphon](https://wordpress.org/support/users/madsphi/)
 * (@madsphi)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/url-changes-to-post_type/#post-11819610)
 * Solution found, just add this to the code:
    `http://biostall.com/prevent-wordpress-
   redirecting-to-nearest-matching-url/`
 * Thanks for the hint to
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Url changes to ?post_type=](https://wordpress.org/support/topic/url-changes-to-post_type/)
 *  Thread Starter [Mads Phikamphon](https://wordpress.org/support/users/madsphi/)
 * (@madsphi)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/url-changes-to-post_type/#post-11819593)
 * I have tried to do add_action() for `init` and `wp_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 6 years, 11 months ago by [Mads Phikamphon](https://wordpress.org/support/users/madsphi/).
    -  This reply was modified 6 years, 11 months ago by [Mads Phikamphon](https://wordpress.org/support/users/madsphi/).

Viewing 15 replies - 1 through 15 (of 87 total)

1 [2](https://wordpress.org/support/users/madsphi/replies/page/2/?output_format=md)
[3](https://wordpress.org/support/users/madsphi/replies/page/3/?output_format=md)
[4](https://wordpress.org/support/users/madsphi/replies/page/4/?output_format=md)
[5](https://wordpress.org/support/users/madsphi/replies/page/5/?output_format=md)
[6](https://wordpress.org/support/users/madsphi/replies/page/6/?output_format=md)
[→](https://wordpress.org/support/users/madsphi/replies/page/2/?output_format=md)