Title: Code Suggestion
Last modified: July 28, 2021

---

# Code Suggestion

 *  [woutervddn](https://wordpress.org/support/users/woutervddn/)
 * (@woutervddn)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/code-suggestion-2/)
 * I wanted to suggest a code edit, but I’m not sure if the source has a public 
   repo.
 * In either case, I noticed that `event_pageview()` has no args passed to it. This
   is unfortunate because I think most people, me included, want to know which page
   has been viewed.
 * I suggest editing the code to get access to the wp_query:
 *     ```
       public function event_pageview(){
           global $wp_query;
           $this->assemble_mqtt_message( 'event_pageview', (array) $wp_query );
       }
       ```
   
 * Another suggestion is to also use `replace_placeholders` in the topic. This way
   we can have a different subtopic depending on which page is actually viewed. 
   This is easily achieved by adding: `topic = $this->replace_placeholders( $topic,
   $args );` in the `assemble_mqtt_message()` function.
    -  This topic was modified 4 years, 10 months ago by [woutervddn](https://wordpress.org/support/users/woutervddn/).
      Reason: extra suggestion

Viewing 1 replies (of 1 total)

 *  Plugin Author [Roy Tanck](https://wordpress.org/support/users/roytanck/)
 * (@roytanck)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/code-suggestion-2/#post-14722404)
 * Hi [@woutervddn](https://wordpress.org/support/users/woutervddn/). This plugin
   is not currently being actively developed. I’ve made the code available on Github(
   [https://github.com/roytanck/WP-MQTT](https://github.com/roytanck/WP-MQTT)) and
   am happy to look at PRs.
 * I’m no longer using MQTT in any projects, and have taken my broker offline a 
   while ago. This makes it harder to test against new WordPress versions. Releasing
   a new version on wordpress.org requires at least some testing to make sure it
   works with whatever is the current version of WP at that time.
 * Ideally, someone with a more active interest could take over development.

Viewing 1 replies (of 1 total)

The topic ‘Code Suggestion’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-mqtt_349bce.svg)
 * [WP-MQTT](https://wordpress.org/plugins/wp-mqtt/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-mqtt/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-mqtt/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-mqtt/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-mqtt/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-mqtt/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Roy Tanck](https://wordpress.org/support/users/roytanck/)
 * Last activity: [4 years, 10 months ago](https://wordpress.org/support/topic/code-suggestion-2/#post-14722404)
 * Status: not a support question