12 Months To Beta – MapMoto

It’s been about a year, a little over actually, since I started work on my main side project. The app is a motocross track directory,  which isn’t something that doesn’t exist already, but I felt existing track directories were lacking a lot of features. This lead to me creating MapMoto.

An Idea

I ride motocross a lot, not as much as a few years ago, but a lot. I’m always looking up weather before I ride, looking for hot-line numbers to call to confirm days to ride, and looking for new tracks all together, especially when traveling. I wrote down everything I wished a motocross track directory would have, and came up with the follow list.

  • A really good map, one where I could  just drag it around and see every track easily, without typing in a zip code and having some limited radius displayed, or seeing a list of tracks for a given area and having to click on each one to see it’s location on a map.
  • The ability to see how far away from me (drive time wise) a track is without opening up a Google Maps Tab on my own.
  • To quickly check what day’s a track is open
  • To see the weather forecast for the week, to cross reference with the days a track is open.
  • A track’s website, facebook, twitter, instagram, and whatever other contact info they’ve got peruse around through.

MapMoto Alpha

I began the project last year in CodeIgniter 3. That’s right, in 2015 I STARTED a project in CI. Those who’ve been around the php community are probably wondering what I was thinking as it’s widely criticized for being dated. I was simply taking a shortcut. I’d developed two applications for clients using CI and the Google Maps API, so I had felt I could get started more quickly. I jumped right into coding, and said to hell with planning ahead.

After 3 or 4 weeks of work I had a working app to add motocross tracks into a simple MySQL database I’d designed. It was unstyled except for Bootstrap’s default look, but worked well enough for me to spend a lot of weeks adding hundreds of tracks across the country.

I constantly improved things to make my work easier, such as dropping a map pin based on a track’s address, then allowing that pin to be dragged and sync the new location with the database (lots of tracks are only kinda near their list address). I developed user and administrative  roles, and built user profile pages with user settings pages to match. Users could upload avatars, link to their social media, be granted permission to manage tracks, the scope of this project crept larger and larger. Eventually I’d styled the site to a look I was fairly happy with too. After implementing the weather forecast system I’d told myself enough was enough. This was my side project, I wanted to learn something new, and I should learn modern practices. During the entirety of development I’d felt stressed out that I was stuck working in CodeIgniter. I knew it well enough already that this project seemed like work, which didn’t seem fun. I just wanted my project finished.

MapMoto Beta

I returned from a trip to Peru a few weeks before my girlfriend who was there for work. I told myself  during those few weeks of an empty house, to stay up all hours coding in, I’d finally convert this damn thing into a framework I was excited to work with. There was a strong temptation to switch the project over to Django, as I’m comfortable writing Python, but haven’t used a Python web framework. I’d also been reading an Express.js book I’d purchased myself impulsively one day on Amazon, and thought maybe I’d go full JS.

Ultimately I decided to stick with php so as not to have to rewrite everything outside of the HTML/CSS/JS. Laravel 5 seemed like a solid choice for a modern framework, with good documentation and an active community. The conversion from CodeIgniter 3 to Laravel 5 took me roughly 3 weeks, which was surprisingly fast. Laravel’s Eloquent ORM, and Blade Templates, allowed me to clean up the code base dramatically. Since the conversion, implementations of new features have gone much more quickly than CI would have allowed, and working on my side project has become fun again.

 

Beta Launch

After deciding it was time to quietly launch the site, I opened it up to unregistered users, and allowed new users to register. I posted on /r/motocross for some feedback on what other riders thought of the initial version. I know of larger motocross communities on line, but decided to go with a low test volume at first. The initial reaction from everyone was very positive. I plan to continue to work on this project slowly, and have a larger official launch at some point in the future. It’s been a great learning experience.

Removing 100 product limit on Woocommerce Google Feed Manager

Update April 10th, 2017: The plugin developer contacted me about this post. Out of respect for the way they handled it (extremely classy),  I wanted to put a link to the paid version of their plugin. So, if you actually want support on the unlimited feed, and don’t want to do any hacky tricks, go support their hard work via the link below.

Purchase Woocommerce product feed manager

Original Article

I came across this info somewhat by accident today while working on an XML Feed generator for a WooCommerce installation. I’ll often review the code of a couple plugins with similar functions to what I’m developing. While looking through Woocommerce Google Feed Manager I guess I found a gremlin.

NY-Gremlin

tl;dr

I’ll put this right at the top in case this is all you came for. To remove the 100 product limit from the free installation of Woocommerce Google Feed Manager , download and unzip the plugin.

Navigate to /wp-product-feed-manager/includes/application/class-feed-processor.php

As of writing this the plugin is in version 1.1.0, and for this version the line your looking for is line:114

if ( get_option( 'wppfm_lic_status' ) !== 'valid' && $this->_product_counter > $grmln ) { break; }

You’ll want to change this if statement to not break the loop, so just remove the break; (pirate comment’s are optional)

if ( get_option( 'wppfm_lic_status' ) !== 'valid' && $this->_product_counter > $grmln ){/*Avast, mateys!*/ }

Save the file, re-zip your plugin, and upload it to your WordPress installation.

If you have over 100 products in your WooCommerce Store then go ahead and generate your Product Feed once more,

Screenshot from 2016-08-11 13:55:36

 

The Long Winded Explanation…

If you want to know what the above steps actually do, then this will go into a little more detail. I say a little because I really didn’t go through the plugin very much, I made this discovery, took a couple of screen shots and then moved on … I was busy doing real work stuff 🙁

Initially, I just wanted to see how the application structure looked, and how the feed was being generated. I looked at the file structure and opened /includes/application/class-feed-processor.php without looking at anything else first. I noticed the $grmln  variable declaration which lead immediately to the discovery of the if statement mentioned above.

But lets walk through this like we’re trying to hack the plugin, rather than miraculously discovering a variable.

First, take a look at the main plugin file wp-product-feed-manager.php
and scroll to line: 115 where there’s a method define_constants()

It’s not uncommon that constants are all that’s holding back paid features in free versions of plugins. Definitely far from always, but not uncommonly the case.

Anyway, in the define_constants() method we see starting at line:160
// Store the end file lmtr
if ( !defined( 'WPPFM_FEED_P_LMTR' ) )
{
define( 'WPPFM_FEED_P_LMTR', 18 );
}

This sparks interest in those who’d be seeking to perhaps….change the limit of the feed.  So let’s see where this WPPFM_FEED_P_LMTR is called.

Screenshot from 2016-08-11 15:19:47
PhpStorm output for ‘Find Usages of WPPFM_FEED_P_LMTR’

 

The usage of this variable seems to be limited one occurrence here,
includes/application/class-feed-processor.php

It defines a variable on line:69,  and  there’s is a little cryptic arithmetic involved,
$grmln = 9 + ( 5 * WPPFM_FEED_P_LMTR );

Remember when the WPPFM_FEED_P_LMTR constant was set it was 18, so $grmln = 99.

Where is $grmln used?

Screenshot from 2016-08-11 15:24:17
PhpStorm output for ‘Find Usages of $grmln’

On line:114 you’ll see the conditional statement that implements the $grmln variable, which contains a break to the loop when the statement is true.

if ( get_option( 'wppfm_lic_status' ) !== 'valid' && $this->_product_counter > $grmln ) { break; }

Well that’s a problem, because the conditions to make this statement true are such, “if the user doesn’t have a license status that’s valid”, and “if the post count is over 99”.

All you really need to do is remove the break;, and then as one would expect, the loop no longer breaks when the unlicensed user product limitation is reached. You could likely also remove this limit by bumping WPPFM_FEED_P_LMTR to be equal to an absurdly high number or setting $grmln equal to count($data)….maybe we could even define wppfm_lic_status ourselves to be valid and just cruise on past this block as licensed users. Whatever…I didn’t explore these options or play around much in that regard, so other’s will have more information for me I’m sure. For those of you that wanted to know more behind how the tl;dr version of this post accomplished removing the limitation, now you do.

Disclaimer

Developers work long and hard on these plugins, and if you’re going to use features which extend beyond the free versions of plugins, it’s best you just buy them. Sometimes I’ll publish interesting ways of extending functionality to the free version, but this is NO WHERE CLOSE to the benefits of actually obtaining the paid version. Updates will break these little hacks, and they may change functionality here and there in unexpected ways. Not to mention it’s always nice to get product support from the developer, which a license will get you, and hacking will not 🙂