WordPress MochiAds plugin beta released

Finally I found some time to fix the WordPress MochiAds plugin and make a working beta.

Please notice it’s just a working beta, install it on your own risk on an empty blog.

There are some interesting features already developed, and a million more features to do.

Also, I am releasing the plugin, not the theme, because I am not satisfied with it. The plugin will only create the posts from MochiAds feed, then it’s up to you to display them properly.

All in all, on triqui.com is working fine and is compatible with WordPress 2.7.

As said, there is an enormous list of features to add to the plugin. If you want to contribute it, your name and site will get credited in the plugin.

System requirements

You need a server able to host WordPress with PHP 5.2.0 and a decent amount of memory. I am running my plugin on HostGator and it’s working fine.

How to install

Download the plugin, unzip it and copy the content into your wp-content/plugins directory… line all other plugins. Then activate it, like all other plugins…

You will find a new item in the Dashboard called MochiAds.

Click it and you will open a menu. Let’s see how does it work.

MochiAds page

This is the main page… only saying it’s a beta and inviting to visit the blog for more information or contributions.

To do: turn this page into a small dashboard with options and statistics. Also, a little help about how to use the plugin should be written, eventually in more than one language. An installation wizard would be appreciated.

Mochi Table page

(a picture would be useless…)

This page creates the table that will store all your games data. Without such table, the plugin won’t be able to create the posts, so this is the next page you need to visit.

It creates a table called with your WP prefix (usually wp_) followed by mochi, so usually this table is called wp_mochi. I will refer to this table with its default name from now on.

You can call this page everytime you want without getting mysql erros if the table already exists.

To do: displaying more information about the table, such as size, number of lines (games) and an option to reset it.

Categories page

Now you should click on this page to create the categories. I included all MochiAds categories plus the “High Scores” one, where to list all games with high scores. Again, you can access to this page anytime you want without getting any error for duplicate categories.

To do: giving the ability to create only some categories by selecting them. At the moment, the script creates all categories. Creation of a “featured” category to show the so-called “frontpage games”

Feed Games page

This page will look for the last 100 games added in the Mochi feed and add them to the wp_mochi table if the aren’t already there. Then displays the games just added.

To do: First, the user has to be able to select how many games he wants to look for. I set the limit to 100 to avoid any memory issue, anyway during my tests I was able to feed 4,500 games with no errors. Also, having a limit will make you lose the first released games. It would be nice to parse the feed in different ways other than simply retrieving the last n games. The feed should be automatic at a specific hour of the day.

Add games to blog page

This page will look for games in the wp_mochi table that aren’t published on the blog and publish them. To give the most freedom to custom results in the preferred theme, all game attributes such as width, height, description and so on are saved in a custom field.

To do: The user should be able to select what game he wants to post on the blog. At the moment the plugin posts all games.

And that’s all. I hope some WP gurus can help me to improve the plugin.

If you have any question about the plugin or how does it work, post it as a comment and I’ll reply at once.

And don’t forget to visit triqui.com to see it in action!

  • Hurrah! Well done, you got there in the end!

    May all your geese be swans.

  • Nice, thanks for your great work. I look forward to seeing this grow.

  • Great, I’ve downloaded it and am having a fiddle.

    Now, I’ve never actually used WordPress before, so this may sound a bit dense. This plugin makes the posts and retrieves the game data from Mochi, then the template needs altering to actually display the game? Having a bit of trouble working out what needs altering currently, because I’m unfamiliar with the root software.

  • Emanuele Feronato

    Yes, the template needs some alterings to display custom fields.

    You can find a brief explaination at this link:
    http://www.emanueleferonato.com/2008/07/27/creation-of-a-flash-arcade-site-using-wordpress-step-2/

  • Thanks, I’ve now got games displaying on their own pages. Looks dreadful currently, need to tweak the template a lot more, but it’s working. Nice.

  • mas

    Hi,

    I just want to have 1 category only, lets say I want category RACING CAR

    How to edit to make 1 category RACING CAR only?

  • Plugin is working great but I noticed that the it embeds the game from mochi ads rather than downloading the game. It is my understanding that you do not receive any ad revenue from mochi ads unless the game is hosted on you own server. Are there any plans to modify the script so that it will transfer the game.

  • Emanuele Feronato

    @ Jeremy: nice idea, have to insert it in the TO-DO list.

  • pq

    hi there,

    nice plugin, thanks :) Will you still gonna release the wordpress theme?

  • Emanuele Feronato

    @pq: sure, as soon as I’ll have a decent theme

  • mas

    Hi,

    How do you limit the categories? I don’t want display all the categories

  • del

    Hi Emanuel, i try your plugins on my site, its says “Table wp_mochi successfully created”…then made categories as you mention and it successfully created, and next i click on feed games its says “No new games at the moment…” then i click add games to blog its says “No new games to add”, did i missed something ?, please i need your help

  • MO

    Hi Emanuele, thanks for the great tutorial.

    Hi del, probably the table is not created, because you are using MySQL < 5. Try creating the table manually:

    CREATE TABLE wp_mochi (
    id int(11) NOT NULL auto_increment,
    rating text NOT NULL,
    updated text NOT NULL,
    popularity text NOT NULL,
    description text NOT NULL,
    key_mappings text NOT NULL,
    height text NOT NULL,
    controls text NOT NULL,
    game_url text NOT NULL,
    tags text NOT NULL,
    slug text NOT NULL,
    categories text NOT NULL,
    instructions text NOT NULL,
    uuid text NOT NULL,
    author text NOT NULL,
    control_scheme text NOT NULL,
    author_link text NOT NULL,
    feed_approval_created text NOT NULL,
    name text NOT NULL,
    swf_url text NOT NULL,
    recommended text NOT NULL,
    thumbnail_url text NOT NULL,
    created text NOT NULL,
    game_tag text NOT NULL,
    leaderboard_enabled text NOT NULL,
    zip_url text NOT NULL,
    width text NOT NULL,
    status text NOT NULL,
    PRIMARY KEY (id)
    ) ENGINE=MyISAM;

  • I had the same problem as del.
    Tried Mo’s solution, but that didn’t work for me…

    Anyone who can help me out in this?

  • dan

    It doesnt work for me either. the plugin feeds the games and it says it adds the games to the blog. I even get the following:

    Add Games to blog

    Woodbox Marble Lines
    Categories: Board Game,Puzzles
    Leaderboard enabled
    BotCatch
    Categories: Action,Other
    Mini-parachutes
    Categories: Other,Shooting
    Football GATE
    Categories: Action,Sports

    However, I do not see them as individual posts. For now ill add everything manually

  • It doesnt work for me either. I have this message:
    Add Games to blog

    1. No new games to add

  • Just wanted to say thanks a million for this plugin! I’m using it now and I love it a lot!

  • Help!!

    i could not add games now.. not sure why.. can the script be edited in such a way that when u press feed games, it automatically adds? rather than click add games again…

    if i could i would made it myself but i dun understand this line:

    $row = $wpdb->get_row(“SELECT * FROM “.$wpdb->prefix.”mochi where status = ‘new’ order by id asc”);

    i tried to echo it but its blank…

  • Phil

    I came cross the site at http://www.wordpressgames.com

    It looks decent. How can it work like that?

  • Awesome. I was following your other tutorial on using the JSON feed with the extra meta tags, but I think I will give this plugin a try out.

    Time to put my WP arcade back into development! :D

  • Looks promising, although I can’t get it to work at this time. The same “No new games to add” message…

  • Carter

    I had the same problem… says “Table wp_mochi successfully created”… “100 new games found”…. but “No new games to add” message…

  • mel

    I have the problem “No new games to add” also.

  • I have the problem “No new games to add” also.

  • I am getting the same problem too.

    I follow up all the steps. It seems work fine until the last one when it try to add the games.

    “No new Games to add”

  • Jacko

    I am also getting the error with no new games to add. I tried modding the code a bit to no avail, though i did notice that when i execute the add games function it gets all the into the loop that is executed 100 times, but it seems that it doesnt execute the “if($row)” so I can only assume the problem is with my database prefix? Do I need to set the prefix somewhere?

    Thanks.

  • I like the idea of this plugin, but i can´t get i to work. It states “No new games to add…”

    If you get it too work i might donate some bucks to u :)

  • Hi guys,

    i think i have solved the problem..

    Please go to http://www.junxron.com/2009/03/mochi-script-edited/ for more info..

    Thanks..

  • didn’t work for me

  • Hi, great plugin but I can’t use it because when I click on ‘feed games’ it says 100 new games found, then I press add games to the blog and it says no new games added. I have clicked on categories and table link and they have been made successfully.
    Please help me!!!

  • Pingback: WordPress MochiAds plugin beta FIXED : Emanuele Feronato()

  • great guide and plugin..
    very detailed..
    thank you very much..

  • Pingback: WordPress MochiAds plugin beta FIXED - UPGRADE : Emanuele Feronato()

  • Great plugin!

  • thank you but its not working anymore…

  • Change your json limit to http://www.mochiads.com/feeds/games/XXXX/all/all?format=json&limit=1000 on line 291, upload and try again if you received “No new Games to add” error.
    P.S: XXXX Refers to your publisher id

  • Hello,

    I’ve made the update with the new php, the “feed games” option updates me with the last 100 games but when I hit “add games to my blog”, I get the message “No new games to add” even if I didn’t added new games for several weeks.

    the wp_mochi table is empty..

    Best wishes,
    Cosmin

  • change json limit on line 291 where? I can’t find it and I don’t understand cos I’ve already set up 2 sites using your theme and plugin and they are working fine, but when I tried to do a 3rd I can’t find the same info on this site – I’m sure I had to change something in the theme before but the info on that seems to have dissapeared.

  • I get same error as “CosminP”.

    Any clue how to resolve this?

    Thanks,

  • Paul

    Just reading through this site and thought I would chip in my 2cents as to why it works for some and not others. Check to see if your host allows the url_fopen wrapp, if not, then it is failing due to the line $feed = file_get_contents($mochi_url); as file_get_contents() needs the wrapper.You could add a switch into the script to use curl http://php.net/manual/en/book.curl.php curl is widely accepted on most hosts more than the fopen wrapper. Enjoy

  • I am having the Add Games to blog ‘No new games to add’ issue..
    i have tried changing json limit on line 291 but no luck..
    also checked and url_fopen is enable on my host.

    has someone find any solution to this?
    I would really appreciate a little help here :)

    sK.

  • Your Feed URL: http://freecom24.com/feeds/wp/05c9fd1b30fb6a7e?format=json&limit=200

    Downloading feed: Feed not found. Please check Mochi Feed URL and your Publisher ID!

    i don’t know what can i do

  • where can i download triqui theme for wordpress? and it ask to download into plugins directory.

  • and not sure how to upload into plugins directory. can anyone help?