Skip to content

Instantly share code, notes, and snippets.

View AlphaGit's full-sized avatar

Alpha AlphaGit

View GitHub Profile
<?php
if (has_nav_menu('footer-menu')) {
?>
<nav>
<?php
wp_nav_menu(array(
'theme_location' => 'footer-menu',
'container' => false,
'menu_id' => 'dockMenu',
'depth' => 1,
<?php
class AlphasManifestoNavMenuWalker extends Walker_Nav_Menu {
/**
* @see Walker::start_el()
* @since 3.0.0
*
* @param string $output Passed by reference. Used to append additional content.
* @param object $item Menu item data object.
* @param int $depth Depth of menu item. Used for padding.
* @param int $current_page Menu item ID.
@AlphaGit
AlphaGit / customImageUrl.php
Last active December 14, 2015 21:09
Adding a custom attribute to Wordpress menu items (Themes -> Appearance -> Menus -> Item edition). Extracted from https://github.com/AlphaGit/alphasmanifesto/blob/master/custom_menu_setup.php
<?php
// retrieve menu item custom url attribute when a
add_filter( 'wp_setup_nav_menu_item', 'alphasmanifesto_setup_nav_menu_item' );
function alphasmanifesto_setup_nav_menu_item($menu_item) {
$attrName = 'image_url'; // property name
$genericProperty = "alphasmanifesto_menu_item_$attrName"; // unique property name -- avoid colliding with other plugins/themes
// get it from the database with its id, set it to the menu item
$menu_item->image_url = get_post_meta($menu_item->ID, $genericProperty, true);
@AlphaGit
AlphaGit / customNavWalkerMenuEdit.php
Created March 13, 2013 04:09
Adding a custom property, modifying the Nav_Waker_Menu_Edit for Wordpress. (Code extract from https://github.com/AlphaGit/alphasmanifesto/blob/master/custom_menu_setup.php)
<?php
// modify the displayed dom for editing menu items so that they provide the new value
add_action( 'wp_edit_nav_menu_walker', 'alphasmanifesto_edit_nav_menu_walker' );
function alphasmanifesto_edit_nav_menu_walker($walker) {
return "AlphasManifestoNavMenuEditWalker";
}
class AlphasManifestoNavMenuEditWalker extends Walker_Nav_Menu {
//...
function start_el(&$output, $item, $depth, $args) {
<!DOCTYPE html>
<html>
<head>
<title>Arkanoid with canvas</title>
<link rel="stylesheet" type="text/css" href="arkanoid.css">
<script type="text/javascript" src="arkanoid.js"></script>
</head>
<body onload="arkanoid.init();">
</body>
</html>
/* from http://stackoverflow.com/questions/4288253/html5-canvas-100-width-height-of-viewport */
* {
margin: 0;
padding: 0;
}
html, body {
width: 100%;
height: 100%;
window.arkanoid = (function(userOptions) {
// private fields
var canvas = null;
var ctx = null;
var options = null;
var defaultOptions = {
fullWidth: true,
fullHeight: true,
// ArkanoidStage
+function ArkanoidStage(drawingContext, height, width) {
+ this.blockWidth = width / 10;
+ this.blockHeight = height / 50;
+ this.ballRadius = this.blockHeight * 0.8;
+
+ var player = new ArkanoidPlayer(drawingContext, "#000", this.blockHeight, this.blockWidth, width, height);
+ player.draw();
+
+ return {
// DrawableEntityBase
function DrawableEntityBase(drawingContext, color) {
if (!drawingContext) throw "A drawing context needs to be provided.";
this.ctx = drawingContext;
this.color = color;
this.draw = function() {
throw "DrawableEntityBase is an abstract class -- needs an implementation!"
};
// DrawableBlock: DrawableEntityBase
DrawableBlock.prototype = Object.create(DrawableEntityBase.prototype);
DrawableBlock.prototype.constructor = DrawableEntityBase;
function DrawableBlock(drawingContext, color, posX, posY, height, width) {
DrawableEntityBase.call(this, drawingContext, color);
var self = this;
self.posX = posX;
self.posY = posY;
self.height = height;