ArcadePress is an open source arcade plugin for Wordpress that allows you to turn any Wordpress site into a full arcade site, including flash game uploads, categories, highscores, game feeds & more. Version: 0.65 Author: skybox3d.com Author URI: http://www.skybox3d.com/ License: GPL2 */ /* Copyright 2010 Skybox3d.com (email : admin@skybox3d.com) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ //Global variables: $arcadepress_version = 0.65; $arcadepress_db_version = 0.65; $APjavascriptQueue = NULL; // Pre-2.6 compatibility, which is actually frivilous since we use the 2.8+ widget technique if ( ! defined( 'WP_CONTENT_URL' ) ) define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' ); if ( ! defined( 'WP_CONTENT_DIR' ) ) define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); if ( ! defined( 'WP_PLUGIN_URL' ) ) define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' ); if ( ! defined( 'WP_PLUGIN_DIR' ) ) define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // Create the proper directory structure if it is not already created if(!is_dir(WP_CONTENT_DIR . '/uploads/')) { mkdir(WP_CONTENT_DIR . '/uploads/', 0777, true); } if(!is_dir(WP_CONTENT_DIR . '/uploads/arcadepress/')) { mkdir(WP_CONTENT_DIR . '/uploads/arcadepress/', 0777, true); } if(!is_dir(WP_CONTENT_DIR . '/uploads/arcadepress/games/')) { mkdir(WP_CONTENT_DIR . '/uploads/arcadepress/games/', 0777, true); } if(!is_dir(WP_CONTENT_DIR . '/uploads/arcadepress/images/')) { mkdir(WP_CONTENT_DIR . '/uploads/arcadepress/images/', 0777, true); } /** * =============================================================================================================== * Main ArcadePress Class */ if (!class_exists("ArcadePress")) { class ArcadePress { var $adminOptionsName = "ArcadePressAdminOptions"; function ArcadePress() { //constructor } function init() { $this->getAdminOptions(); } //Returns an array of admin options function getAdminOptions() { $apAdminOptions = array('mainpage' => '', 'turnon_arcadepress' => 'true', 'height' => '300', 'width' => '400', 'alt' => '

'.__('The Flash plugin is required to view this object.', 'arcadepress').'

', 'required_player_version' => '8.0.0', 'express_install_swf' => WP_PLUGIN_URL.'/arcadepress/swf/expressInstall.swf', 'allowfullscreen' => 'true', 'wmode' => 'window', 'showgamethumbnail' => 'true', 'showgamedescription' => 'true', 'creategameundercategory' => 'false' ); $devOptions = get_option($this->adminOptionsName); if (!empty($devOptions)) { foreach ($devOptions as $key => $option) $apAdminOptions[$key] = $option; } update_option($this->adminOptionsName, $apAdminOptions); return $apAdminOptions; } //Prints out the admin page ================================================================================ function printAdminPage() { global $wpdb; $devOptions = $this->getAdminOptions(); if ( function_exists('current_user_can') && !current_user_can('manage_options') ) { die(__('Cheatin’ uh?')); } if (isset($_POST['update_arcadePressSettings'])) { if (isset($_POST['arcadePressmainpage'])) { $devOptions['mainpage'] = $wpdb->escape($_POST['arcadePressmainpage']); } if (isset($_POST['turnArcadePressOn'])) { $devOptions['turnon_arcadepress'] = $wpdb->escape($_POST['turnArcadePressOn']); } if (isset($_POST['allowfullscreen'])) { $devOptions['allowfullscreen'] = $wpdb->escape($_POST['allowfullscreen']); } if (isset($_POST['arcadePressalt'])) { $devOptions['alt'] = apply_filters('content_save_pre', $_POST['arcadePressalt']); } if (isset($_POST['arcadePresswidth'])) { $devOptions['width'] = $wpdb->escape($_POST['arcadePresswidth']); } if (isset($_POST['arcadePressheight'])) { $devOptions['height'] = $wpdb->escape($_POST['arcadePressheight']); } if (isset($_POST['arcadePresswmode'])) { $devOptions['wmode'] = $wpdb->escape($_POST['arcadePresswmode']); } if (isset($_POST['arcadePressrequired_player_version'])) { $devOptions['required_player_version'] = $wpdb->escape($_POST['arcadePressrequired_player_version']); } if (isset($_POST['arcadePressexpress_install_swf'])) { $devOptions['express_install_swf'] = $wpdb->escape($_POST['arcadePressexpress_install_swf']); } if (isset($_POST['showgamethumbnail'])) { $devOptions['showgamethumbnail'] = $wpdb->escape($_POST['showgamethumbnail']); } if (isset($_POST['showgamedescription'])) { $devOptions['showgamedescription'] = $wpdb->escape($_POST['showgamedescription']); } if (isset($_POST['creategameundercategory'])) { $devOptions['creategameundercategory'] = $wpdb->escape($_POST['creategameundercategory']); } update_option($this->adminOptionsName, $devOptions); echo '

'; _e("Settings Updated.", "ArcadePress"); echo '

'; } echo '
arcadepress
Please support ArcadePress by donating: PayPal - The safer, easier way to pay online!


ArcadePress General Options

'; echo ' '; echo '
OptionDescriptionValue

ArcadePress Main Page:

You need to use a Page as the base for ArcadePress. Insert the POST ID of that page here:

Use categories?

Selecting "No" means all games will be child pages of the Main Page, and no category functions will be available. Selecting "Yes" means that all games will be children pages of the main category you select for a game (example, if a game\'s main category is Action, then your game would listed as a child of the page Action, which itself would be a child of Main Page, i.e. MainPage > Action > YourGame)

    

Turn ArcadePress on?

Selecting "No" will turn off ArcadePress, but will not deactivate it.

    

Required Flash Player version

The minimum version of Flash required to play any game. Example: 8.0.0

Allow fullscreen?

    

Flash WMODE

The wmode value when embedding Flash.

URL to Express Install

This Flash file allows easy upgrading of Flash.

Alternative Text

Alternative text when Flash is not activated or installed, or if the game is missing.



Game Display Options

'; echo '
OptionDescriptionValue

Default Width & Height

All this value does is determine what is in the width and height field by default when you visit the Add New Game admin page.

Width:
Height:

Display thumbnail under game?

If set to Yes, the thumbnail for the game will be displayed underneath the game itself

    

Display description under game?

If set to Yes, the description for the game is written underneath the game, after the thumbnail.

    



'; } //END Prints out the admin page ================================================================================ //Prints out the Add Games admin page ======================================================================= function printAdminPageAddGames() { global $wpdb, $user_level; //Apparently this code doesn't work: //get_currentuserinfo(); //if ($user_level < 8) {die('This page is not for you, but thanks for being sneaky and trying');}; if ( function_exists('current_user_can') && !current_user_can('manage_options') ) { die(__('Cheatin’ uh?')); } $devOptions = $this->getAdminOptions(); $table_name = $wpdb->prefix . "arcadepress_games"; if(!isset($devOptions['mainpage']) || !is_numeric($devOptions['mainpage'])) { echo '

ERROR: ArcadePress is configured incorrectly. Visit the ArcadePress options page and set the main page to the numeric POST ID of a dedicated PAGE that you have created for your arcade.

'; return false; } // For new games if(!isset($_GET['keytoedit'])) { // Default form values $arcadePressgame_name = ''; $arcadePressgame_description = ''; $arcadePressgame_type = ''; $arcadePressgame_file = ''; $arcadePressgame_width = $devOptions['width']; $arcadePressgame_height = $devOptions['height']; $arcadePressgame_thumbnail = ''; $arcadePressgame_tags = ''; $keytoedit=0; } // To edit a previous game $isanedit = false; if ($_GET['keytoedit']!=0 && is_numeric($_GET['keytoedit'])) { $isanedit = true; if (isset($_POST['arcadePressgame_name']) && isset($_POST['arcadePressgame_description']) && isset($_POST['arcadePressgame_type']) && isset($_POST['arcadePressgame_file']) && $_POST['arcadePressgame_width'] && $_POST['arcadePressgame_height'] && is_numeric($_POST['arcadePressgame_width']) && is_numeric($_POST['arcadePressgame_height']) && isset($_POST['arcadePressgame_thumbnail']) && isset($_POST['arcadePressgame_tags']) ) { $arcadePressgame_name = $wpdb->escape($_POST['arcadePressgame_name']); $arcadePressgame_description = $wpdb->escape($_POST['arcadePressgame_description']); $arcadePressgame_type = $wpdb->escape($_POST['arcadePressgame_type']); $arcadePressgame_file = $wpdb->escape($_POST['arcadePressgame_file']); $arcadePressgame_width = $wpdb->escape($_POST['arcadePressgame_width']); $arcadePressgame_height = $wpdb->escape($_POST['arcadePressgame_height']); $timestamp = date('Ymd'); $arcadePressgame_thumbnail = $wpdb->escape($_POST['arcadePressgame_thumbnail']); $arcadePressgame_tags = $wpdb->escape($_POST['arcadePressgame_tags']); $cleanKey = $wpdb->escape($_GET['keytoedit']); $updateSQL = " UPDATE `{$table_name}` SET `name` = '{$arcadePressgame_name}', `description` = '{$arcadePressgame_description}', `type` = '{$arcadePressgame_type}', `file` = '{$arcadePressgame_file}', `tags` = '{$arcadePressgame_tags}', `dateadded` = '{$timestamp}', `width` = '{$arcadePressgame_width}', `height` = '{$arcadePressgame_height}', `thumbnail` = '{$arcadePressgame_thumbnail}' WHERE `primkey` ={$cleanKey} LIMIT 1 ; "; $results = $wpdb->query($updateSQL); if($results===false) { echo '

'; _e("ERROR 2: There was a problem with your form! The database query was invalid. ", "ArcadePress"); echo $wpdb->print_error(); echo '

'; } else { // If we get this far, we are still successful echo '

'; _e("Edit successful! Your game details have been saved.", "ArcadePress"); echo '

'; } } $keytoedit=$_GET['keytoedit']; $grabrecord = "SELECT * FROM {$table_name} WHERE `primkey`={$keytoedit};"; $results = $wpdb->get_results( $grabrecord , ARRAY_A ); if(isset($results)) { foreach ($results as $result) { $arcadePressgame_name = stripslashes($result['name']); $arcadePressgame_description = stripslashes($result['description']); $arcadePressgame_type = stripslashes($result['type']); $arcadePressgame_file = stripslashes($result['file']); $arcadePressgame_width = stripslashes($result['width']); $arcadePressgame_height = stripslashes($result['height']); $arcadePressgame_thumbnail = stripslashes($result['thumbnail']); $arcadePressgame_tags = stripslashes($result['tags']); } } else { echo '

'; echo "There was a problem loading the game you wish to edit. The query was: {$grabrecord} "; echo '

'; } } if (isset($_POST['addNewArcadePress_Game']) && $isanedit == false) { if (isset($_POST['arcadePressgame_name']) && isset($_POST['arcadePressgame_description']) && isset($_POST['arcadePressgame_type']) && isset($_POST['arcadePressgame_file']) && $_POST['arcadePressgame_width'] && $_POST['arcadePressgame_height'] && is_numeric($_POST['arcadePressgame_width']) && is_numeric($_POST['arcadePressgame_height']) && isset($_POST['arcadePressgame_thumbnail']) && isset($_POST['arcadePressgame_tags']) ) { $arcadePressgame_name = $wpdb->escape($_POST['arcadePressgame_name']); $arcadePressgame_description = $wpdb->escape($_POST['arcadePressgame_description']); $arcadePressgame_type = $wpdb->escape($_POST['arcadePressgame_type']); $arcadePressgame_file = $wpdb->escape($_POST['arcadePressgame_file']); $arcadePressgame_width = $wpdb->escape($_POST['arcadePressgame_width']); $arcadePressgame_height = $wpdb->escape($_POST['arcadePressgame_height']); $timestamp = date('Ymd'); $arcadePressgame_thumbnail = $wpdb->escape($_POST['arcadePressgame_thumbnail']); $arcadePressgame_tags = $wpdb->escape($_POST['arcadePressgame_tags']); $devOptions = $this->getAdminOptions(); // Create our PAGE in draft mode in order to get the POST ID $my_post = array(); $my_post['post_title'] = stripslashes($arcadePressgame_name); $my_post['post_type'] = 'page'; $my_post['post_content'] = ''; $my_post['post_status'] = 'draft'; $my_post['post_author'] = 1; // Create the page as either directly under the main page or underneath a category page if($devOptions['creategameundercategory']==false) { $my_post['post_parent'] = $devOptions['mainpage']; } else { $theCategories = explode(',',$arcadePressgame_tags); if(isset($theCategories[0])) { $catSQL = "SELECT `ID` FROM `{$wpdb->prefix}posts` WHERE `post_title` LIKE '%{$theCategories[0]}%' AND `post_parent`={$devOptions['mainpage']} AND `post_status`='publish';"; $catResults = $wpdb->get_results( $catSQL , ARRAY_A ); if(!isset($catResults[0]['ID'])) { $my_cat_post = array(); $my_cat_post['post_title'] = stripslashes($theCategories[0]); $my_cat_post['post_type'] = 'page'; $my_cat_post['post_content'] = '[arcadepress category="'.stripslashes($theCategories[0]).'"]'; $my_cat_post['post_status'] = 'publish'; $my_cat_post['post_author'] = 1; $my_cat_post['post_parent'] = $devOptions['mainpage']; $theCatPostID = wp_insert_post( $my_cat_post ); } else { $theCatPostID = $catResults[0]['ID']; } $my_post['post_parent'] = $theCatPostID; } else { $my_post['post_parent'] = $devOptions['mainpage']; } } // Insert the PAGE into the WP database $thePostID = wp_insert_post( $my_post ); if($thePostID==0) { echo '

'; _e("ERROR 4: Wordpress didn't like your data and failed to create a page for it!", "ArcadePress"); echo $wpdb->print_error(); echo '

'; return false; } // Now insert the game into the ArcadePress database $insert = "INSERT INTO {$table_name} (`primkey`, `name`, `description`, `type`, `file`, `tags`, `gameplays`, `dateadded`, `width`, `height`, `thumbnail`, `url`, `postid`) VALUES (NULL, '{$arcadePressgame_name}', '{$arcadePressgame_description}', '{$arcadePressgame_type}', '{$arcadePressgame_file}', '{$arcadePressgame_tags}', '0', '{$timestamp}', '{$arcadePressgame_width}', '{$arcadePressgame_height}', '{$arcadePressgame_thumbnail}', '', '{$thePostID}');"; $results = $wpdb->query( $insert ); $lastID = $wpdb->insert_id; // Now that we've inserted both the PAGE and the GAME, let's update and publish our post with the correct content $my_post = array(); $my_post['ID'] = $thePostID; $my_post['post_content'] = '[arcadepress display="game" primkey="'.$lastID.'"]'; $my_post['post_status'] = 'publish'; wp_update_post( $my_post ); if($results===false) { echo '

'; _e("ERROR 2: There was a problem with your form! The database query was invalid. ", "ArcadePress"); echo $wpdb->print_error(); echo '

'; } else { // If we get this far, we are still successful echo '

'; _e("Your game details have been saved.", "ArcadePress"); echo '

'; } } else { echo '

'; _e("There was a problem with your form! Did not save data.", "ArcadePress"); echo '

'; } } echo '
'; if($isanedit==true) { // An edit's REQUEST_URL will already have the key appended, while a new game won't $codeForKeyToEdit = NULL; } else { $codeForKeyToEdit = '&keytoedit='.$keytoedit; } if(isset($lastID)) { $codeForKeyToEdit = '&keytoedit='.$lastID; } echo '
arcadepress
Please support ArcadePress by donating: PayPal - The safer, easier way to pay online!


Add or Edit a Game

'; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo '
Game AttributeValueDescription

Game Name:

The title of the game.

Description:

You should be very detailed and include not only the backstory of the game, but also helpful information like instructions, controls, and objectives.

Tags

Comma seperated list of tags. In ArcadePress, tags serve as categories.

File:

URL: or
Upload a file:
Either a full URL to a file, or use the upload form to select a Flash file from your computer. Max filesize is either: '.ini_get('post_max_size').' or '.ini_get('upload_max_filesize').', whichever is lower.

File type:

Select if you are using a SWF, DCR, or FLV file (only SWF is supported at the moment.)

Game Thumbnail:

URL: or
Upload a file:
Either a full URL to an image file, or use the upload form to select an image file from your computer.

Width & Height:

Width:         Height:
The width and height of the embedded Flash element. Make sure your theme supports this size of content!

'; } // END Prints out the Add Games admin page ======================================================================= //Prints out the Edit Games admin page ======================================================================= function printAdminPageEditGames() { global $wpdb, $user_level; // Apparently this code doesn't work //get_currentuserinfo(); //if ($user_level < 8) {die('This page is not for you, but thanks for being sneaky and trying');}; if ( function_exists('current_user_can') && !current_user_can('manage_options') ) { die(__('Cheatin’ uh?')); } $table_name = $wpdb->prefix . "arcadepress_games"; if(isset($_GET['keytodelete']) && is_numeric($_GET['keytodelete'])) { $sqlbeforedelete = "SELECT `postid` FROM {$table_name} WHERE `primkey`={$_GET['keytodelete']};"; $theDeleteResults = $wpdb->get_results( $sqlbeforedelete , ARRAY_A ); if(isset($theDeleteResults)) { // Delete the post wp_delete_post($theDeleteResults[0]['postid']); } $wpdb->query("DELETE FROM `{$table_name}` WHERE `primkey`={$_GET['keytodelete']};"); echo '

'; _e("Game was removed from the database.", "ArcadePress"); echo '

'; } echo '
arcadepress
Please support ArcadePress by donating: PayPal - The safer, easier way to pay online!


Edit Games

'; $startrecord = 0; if(isset($_GET['startrecord']) && is_numeric($_GET['startrecord'])) { $startrecord = $_GET['startrecord']; } $numberofrecords = 10; $totalrecordssql = "SELECT COUNT(`primkey`) AS num FROM `{$table_name}`"; $totalrecordsres = $wpdb->get_results( $totalrecordssql , ARRAY_A ); $totalrecords = $totalrecordsres[0]['num']; $numberofpages = ceil($totalrecords / $numberofrecords); echo '
Pages: '; $icounter = 0; while ($icounter < $numberofpages) { $pagenum = $icounter + 1; $offeset = $icounter * $numberofrecords; echo ''.$pagenum.' '; $icounter++; } echo '

'; $grabrecord = "SELECT * FROM `{$table_name}` LIMIT {$startrecord}, {$numberofrecords};"; $results = $wpdb->get_results( $grabrecord , ARRAY_A ); if(isset($results)) { foreach ($results as $result) { $arcadePressgame_name = $result['name']; $arcadePressgame_description = $result['description']; $arcadePressgame_type = $result['type']; $arcadePressgame_file = $result['file']; $arcadePressgame_width = $result['width']; $arcadePressgame_height = $result['height']; $arcadePressgame_thumbnail = $result['thumbnail']; $arcadePressgame_tags = $result['tags']; echo ""; } } echo '
ActionNameDescriptionTypeFileWidthHeightThumbnailTags
Edit | Delete".stripslashes($arcadePressgame_name)."".stripslashes($arcadePressgame_description)."{$arcadePressgame_type}{$arcadePressgame_file}{$arcadePressgame_width}{$arcadePressgame_height}\"\"".stripslashes($arcadePressgame_tags)."
'; } //END Prints out the Edit Games admin page ======================================================================= // Dashboard widget code======================================================================= function arcadepress_main_dashboard_widget_function() { global $wpdb; $devOptions = $this->getAdminOptions(); $table_name = $wpdb->prefix . "arcadepress_games"; $totalrecordssql = "SELECT COUNT(`primkey`) AS num FROM `{$table_name}`"; $totalrecordsres = $wpdb->get_results( $totalrecordssql , ARRAY_A ); if(isset($totalrecordsres)) { $totalrecords = $totalrecordsres[0]['num']; } else { $totalrecords = 0; } $totalgameplayssql = "SELECT SUM(`gameplays`) AS num FROM `{$table_name}`;"; $totalgameplaysres = $wpdb->get_results( $totalgameplayssql , ARRAY_A ); if(isset($totalgameplaysres)) { $totalgameplays = $totalgameplaysres[0]['num']; } else { $totalgameplays = 0; } $permalink = get_permalink( $devOptions['mainpage'] ); echo '

ArcadePress main page: here

'; echo "

Games installed: {$totalrecords}

"; echo "

Number of times games played: {$totalgameplays}

"; } // Create the function use in the action hook function arcadepress_main_add_dashboard_widgets() { wp_add_dashboard_widget('arcadepress_main_dashboard_widgets', 'ArcadePress Overview', array(&$this, 'arcadepress_main_dashboard_widget_function')); } function addHeaderCode() { echo ''; } function addContent($content = '') { $content .= "

ArcadePress

"; return $content; } // Installation ============================================================================================== function arcadepress_install() { global $wpdb; global $arcadepress_db_version; $table_name = $wpdb->prefix . "arcadepress_games"; if($wpdb->get_var("show tables like '$table_name'") != $table_name) { $sql = " CREATE TABLE {$table_name} ( `primkey` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `name` VARCHAR(255) NOT NULL, `description` TEXT NOT NULL, `type` VARCHAR(32) NOT NULL, `file` VARCHAR(512) NOT NULL, `tags` VARCHAR(512) NOT NULL, `gameplays` INT(11) NOT NULL, `dateadded` INT(8) NOT NULL, `width` INT(4) NOT NULL, `height` INT(4) NOT NULL, `thumbnail` VARCHAR(255) NOT NULL, `url` VARCHAR(255) NOT NULL, `postid` int(11) NOT NULL); "; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); add_option("arcadepress_db_version", $arcadepress_db_version); } } // END Installation ============================================================================================== // Shortcode ========================================= function arcadepress_mainshortcode($atts) { global $wpdb; $table_name = $wpdb->prefix . "arcadepress_games"; $devOptions = $this->getAdminOptions(); extract(shortcode_atts(array( 'display' => 'categories', 'primkey' => '0', 'quantity' => '10', 'usetext' => 'true', 'usepictures' => 'false', 'category' => '' ), $atts)); $output = ''; if($category!='') { if(is_numeric($quantity)){ $sql = "SELECT * FROM `{$table_name}` WHERE `tags` LIKE '%{$category}%' ORDER BY `dateadded` DESC LIMIT 0, {$quantity};"; $results = $wpdb->get_results( $sql , ARRAY_A ); if(isset($results)) { foreach ($results as $result) { $permalink = get_permalink( $result['postid'] ); // Grab the permalink based on the post id associated with the game if($usepictures=='true') { $output .= ''.$result['name'].''; } if($usetext=='true') { $output .= '

'.$result['name'].'

'; } } } } else { $output .= 'ArcadePress did not like your category shortcode! The quantity field contained non-numeric data. Please fix your page or consult the ArcadePress documentation for help.'; } } switch ($display) { case 'recentgames': // Recent game shortcode ========================================================= if(is_numeric($quantity)){ $sql = "SELECT * FROM `{$table_name}` ORDER BY `dateadded` DESC LIMIT 0, {$quantity};"; $results = $wpdb->get_results( $sql , ARRAY_A ); if(isset($results)) { foreach ($results as $result) { $permalink = get_permalink( $result['postid'] ); // Grab the permalink based on the post id associated with the game if($usepictures=='true') { $output .= ''.$result['name'].''; } if($usetext=='true') { $output .= '

'.$result['name'].'

'; } } } } else { $output .= 'ArcadePress did not like your recentgames shortcode! The quantity field contained non-numeric data. Please fix your page or consult the ArcadePress documentation for help.'; } break; case 'topgames': // Top game shortcode ========================================================= if(is_numeric($quantity)){ $sql = "SELECT * FROM `{$table_name}` ORDER BY `gameplays` DESC LIMIT 0, {$quantity};"; $results = $wpdb->get_results( $sql , ARRAY_A ); if(isset($results)) { foreach ($results as $result) { $permalink = get_permalink( $result['postid'] ); // Grab the permalink based on the post id associated with the game if($usepictures=='true') { $output .= ''.$result['name'].''; } if($usetext=='true') { $output .= '

'.$result['name'].'

'; } } } } else { $output .= 'ArcadePress did not like your topgames shortcode! The quantity field contained non-numeric data. Please fix your page or consult the ArcadePress documentation for help.'; } break; case 'categories': // Categories shortcode ========================================================= if($devOptions['creategameundercategory']==true) { $sql = "SELECT `ID`, `post_title` FROM `{$wpdb->prefix}posts` WHERE `post_parent`={$devOptions['mainpage']} AND `post_status`='publish' ORDER BY `post_title` ASC"; $results = $wpdb->get_results( $sql , ARRAY_A ); if(isset($results)) { $output .= ''; } } else { $output .= 'ArcadePress is configured to not use categories.'; } break; case 'game': // Individual game shortcode ========================================================= if(isset($primkey) && is_numeric($primkey)) { $sql = "SELECT * FROM `{$table_name}` WHERE `primkey`={$primkey};"; $results = $wpdb->get_results( $sql , ARRAY_A ); if(isset($results)) { $newGamePlayValue = $results[0]['gameplays'] + 1; // Increment the play counter $updatedSQL = "UPDATE `{$table_name}` SET `gameplays` = '{$newGamePlayValue}' WHERE `primkey` ={$primkey} LIMIT 1 ;"; $wpdb->query($updatedSQL); $output .= '

'.$devOptions['alt'].'


'; if($devOptions['showgamethumbnail']=='true') { $output .= ''.$results[0]['name'].'
'; } if($devOptions['showgamedescription']=='true') { $output .= $results[0]['description']; } } else { $output .= 'This game has been removed, but the shortcode associated with it was not.'; } } else { $output .= 'ArcadePress did not like the primkey in your shortcode! The primkey field contained non-numeric data. Please fix your page or consult the ArcadePress documentation for help.'; } break; } return $output; } // END SHORTCODE ================================================ function add_script_swfobject($posts){ if (empty($posts)) return $posts; wp_enqueue_script('swfobject'); return $posts; } function my_admin_scripts(){ global $APjavascriptQueue; wp_enqueue_script('swfupload'); if (session_id() == "") {@session_start();}; $APjavascriptQueue .= ' '; } function placeAdminHeaderCode() { global $APjavascriptQueue; echo $APjavascriptQueue; } } /** * =============================================================================================================== * End Main ArcadePress Class */ } // The end of the IF statement /** * =============================================================================================================== * ArcadePressTopGamesWidget SIDEBAR WIDGET */ if (class_exists("WP_Widget")) { class ArcadePressTopGamesWidget extends WP_Widget { /** constructor */ function ArcadePressTopGamesWidget() { parent::WP_Widget(false, $name = 'ArcadePress Top Games'); } /** @see WP_Widget::widget */ function widget($args, $instance) { global $wpdb; $table_name = $wpdb->prefix . "arcadepress_games"; extract( $args ); $title = apply_filters('widget_title', $instance['title']); $numberOfGamesToDisplay = empty($instance['numberOfGamesToDisplay']) ? '10' : $instance['numberOfGamesToDisplay']; $widgetShowGameImages = empty($instance['widgetShowGameImages']) ? 'false' : $instance['widgetShowGameImages']; echo $before_widget; if ( $title ) { echo $before_title . $title . $after_title; } if(is_numeric($numberOfGamesToDisplay)){ $sql = "SELECT * FROM `{$table_name}` ORDER BY `gameplays` DESC LIMIT 0, {$numberOfGamesToDisplay};"; $results = $wpdb->get_results( $sql , ARRAY_A ); if(isset($results)) { foreach ($results as $result) { $permalink = get_permalink( $result['postid'] ); // Grab the permalink based on the post id associated with the game if($widgetShowGameImages=='true') { $output .= ''.$result['name'].''; } $output .= '

'.$result['name'].'

'; } } } else { $output .= 'ArcadePress did not like your widget! The number of games to display contained non-numeric data. Please fix your widget or consult the ArcadePress documentation for help.'; } echo $output; echo $after_widget; } /** @see WP_Widget::update */ function update($new_instance, $old_instance) { $instance['title']= strip_tags(stripslashes($new_instance['title'])); $instance['numberOfGamesToDisplay'] = strip_tags(stripslashes($new_instance['numberOfGamesToDisplay'])); $instance['widgetShowGameImages'] = strip_tags(stripslashes($new_instance['widgetShowGameImages'])); return $instance; } /** @see WP_Widget::form */ function form($instance) { $title = esc_attr($instance['title']); $numberOfGamesToDisplay = htmlspecialchars($instance['numberOfGamesToDisplay']); $widgetShowGameImages = htmlspecialchars($instance['widgetShowGameImages']); echo '

'; echo '

'; //echo '

'; echo '

'; } } class ArcadePressRecentGamesWidget extends WP_Widget { /** constructor */ function ArcadePressRecentGamesWidget() { parent::WP_Widget(false, $name = 'ArcadePress Recent Games'); } /** @see WP_Widget::widget */ function widget($args, $instance) { global $wpdb; $table_name = $wpdb->prefix . "arcadepress_games"; extract( $args ); $title = apply_filters('widget_title', $instance['title']); $numberOfGamesToDisplay = empty($instance['numberOfGamesToDisplay']) ? '10' : $instance['numberOfGamesToDisplay']; $widgetShowGameImages = empty($instance['widgetShowGameImages']) ? 'false' : $instance['widgetShowGameImages']; echo $before_widget; if ( $title ) { echo $before_title . $title . $after_title; } if(is_numeric($numberOfGamesToDisplay)){ $sql = "SELECT * FROM `{$table_name}` ORDER BY `dateadded` DESC LIMIT 0, {$numberOfGamesToDisplay};"; $results = $wpdb->get_results( $sql , ARRAY_A ); if(isset($results)) { foreach ($results as $result) { $permalink = get_permalink( $result['postid'] ); // Grab the permalink based on the post id associated with the game if($widgetShowGameImages=='true') { $output .= ''.$result['name'].''; } $output .= '

'.$result['name'].'

'; } } } else { $output .= 'ArcadePress did not like your widget! The number of games to display contained non-numeric data. Please fix your widget or consult the ArcadePress documentation for help.'; } echo $output; echo $after_widget; } /** @see WP_Widget::update */ function update($new_instance, $old_instance) { $instance['title']= strip_tags(stripslashes($new_instance['title'])); $instance['numberOfGamesToDisplay'] = strip_tags(stripslashes($new_instance['numberOfGamesToDisplay'])); $instance['widgetShowGameImages'] = strip_tags(stripslashes($new_instance['widgetShowGameImages'])); return $instance; } /** @see WP_Widget::form */ function form($instance) { $title = esc_attr($instance['title']); $numberOfGamesToDisplay = htmlspecialchars($instance['numberOfGamesToDisplay']); $widgetShowGameImages = htmlspecialchars($instance['widgetShowGameImages']); echo '

'; echo '

'; //echo '

'; echo '

'; } } } /** * =============================================================================================================== * END ArcadePressTopGamesWidget SIDEBAR WIDGET */ /** * =============================================================================================================== * ArcadePressCategoryGamesWidget SIDEBAR WIDGET */ if (class_exists("WP_Widget")) { class ArcadePressCategoryGamesWidget extends WP_Widget { /** constructor */ function ArcadePressCategoryGamesWidget() { parent::WP_Widget(false, $name = 'ArcadePress Category List'); } /** @see WP_Widget::widget */ function widget($args, $instance) { global $wpdb, $arcadePress; $devOptions = $arcadePress->getAdminOptions(); extract( $args ); $title = apply_filters('widget_title', $instance['title']); echo $before_widget; if ( $title ) { echo $before_title . $title . $after_title; } if($devOptions['creategameundercategory']==true) { $sql = "SELECT `ID`, `post_title` FROM `{$wpdb->prefix}posts` WHERE `post_parent`={$devOptions['mainpage']} AND `post_status`='publish' ORDER BY `post_title` ASC"; $results = $wpdb->get_results( $sql , ARRAY_A ); if(isset($results)) { $output .= ''; } } else { $output .= 'ArcadePress is configured to not use categories.'; } echo $output; echo $after_widget; } /** @see WP_Widget::update */ function update($new_instance, $old_instance) { $instance['title']= strip_tags(stripslashes($new_instance['title'])); return $instance; } /** @see WP_Widget::form */ function form($instance) { $title = esc_attr($instance['title']); echo '

'; } } } /** * =============================================================================================================== * Initialize the admin panel */ if (!function_exists("arcadePressAdminPanel")) { function arcadePressAdminPanel() { global $arcadePress; if (!isset($arcadePress)) { return; } if (function_exists('add_menu_page')) { add_menu_page('ArcadePress - Open Source Arcade CMS Plugin', 'ArcadePress', 9, 'arcadepress-admin', array(&$arcadePress, 'printAdminPage'), WP_PLUGIN_URL.'/arcadepress/images/controller.png'); $page = add_submenu_page('arcadepress-admin','Add Game - ArcadePress ', 'Add Game', 9, 'arcadepress-add-games', array(&$arcadePress, 'printAdminPageAddGames')); add_submenu_page('arcadepress-admin','Edit Games - ArcadePress ', 'Edit Games', 9, 'arcadepress-edit-games', array(&$arcadePress, 'printAdminPageEditGames')); add_action( "admin_print_scripts-$page", array(&$arcadePress, 'my_admin_scripts') ); } } } /** * =============================================================================================================== * END Initialize the admin panel */ /** * =============================================================================================================== * Call everything */ if (class_exists("ArcadePress")) { $arcadePress = new ArcadePress(); } //Actions and Filters if (isset($arcadePress)) { //Actions register_activation_hook(__FILE__, array(&$arcadePress, 'arcadepress_install')); // Install DB schema add_action('arcadepress/arcadepress.php', array(&$arcadePress, 'init')); // Create options on activation add_action('admin_menu', 'arcadePressAdminPanel'); // Create admin panel add_action('wp_dashboard_setup', array(&$arcadePress, 'arcadepress_main_add_dashboard_widgets') ); // Dashboard widget add_action('wp_head', array(&$arcadePress, 'addHeaderCode'), 1); // Place ArcadePress comment into header add_action('widgets_init', create_function('', 'return register_widget("ArcadePressTopGamesWidget");')); // Register the widget: ArcadePressTopGamesWidget add_action('widgets_init', create_function('', 'return register_widget("ArcadePressRecentGamesWidget");')); // Register the widget: ArcadePressRecentGamesWidget add_action('widgets_init', create_function('', 'return register_widget("ArcadePressCategoryGamesWidget");')); add_shortcode('arcadepress', array(&$arcadePress, 'arcadepress_mainshortcode')); add_action('admin_head', array(&$arcadePress, 'placeAdminHeaderCode'), 1); // Place ArcadePress comment into header //Filters add_filter('the_posts', array(&$arcadePress, 'add_script_swfobject')); //add_filter('the_posts', array(&$arcadePress, 'add_script_swfupload')); } /** * =============================================================================================================== * Call everything */ ?>