Talking about Flash, Php and WordPress.
Some time ago I blogged about Showing MochiAds leaderboards in any Flash movie or web page with a script made by myself that displayed MochiAds leaderboards on your site.
Yesterday MochiAds guys released a widget that accepts a game slug and partner ID and will display all the available leaderboards for the given game. The partner ID will constrain the widget to showing only scores from your site if you choose to do so. The widget is a Flash .SWF that can be embedded on any HTML page on your site.
In the official docs page there is an example using swfobject library but there is a much simpler way to embed scores… here it is:
Just replace ballbalance with the game slug you want to display highscores.
Width and height have minimum values of 230 and 200 pixels, and the score table will adjust according to size.
Here it is an example of a leaderboard with 400×400
And this is the tiniest one…
… that looks perfect to be embedded in a blog
Let’s create the WP widget!
Before continuing, I suggest you to read How to create a WordPress Widget if you don’t have experience with WP widgets.
The new widget is made this way (don’t worry, I’ll explain how to do it during one of next tutorials)
$game_name Leaderboard";
}
function mochi_setup(){
add_option("mochiads_slug","ballbalance");
add_option("mochiads_name","BallBalance");
if($_POST[game_slug]){
update_option("mochiads_slug", strip_tags(stripslashes($_POST[game_slug])));
}
if($_POST[game_name]){
update_option("mochiads_name", strip_tags(stripslashes($_POST[game_name])));
}
$game_slug = get_option("mochiads_slug");
$game_name = get_option("mochiads_name");
echo "\n";
echo "Game name:\n";
echo "Game slug:\n";
echo "\n";
}
function init_mochi(){
register_sidebar_widget("MochiAds Scores", "mochi_scores");
register_widget_control("MochiAds Scores", "mochi_setup");
}
add_action("plugins_loaded", "init_mochi");
?>
and creates customizable widget allowing you to specify name and slug of your game this way:
Download the widget and give me feedback
Never miss an update! Subscribe, and I will bother you by email only when a new game or full source code comes out.