Posted on Leave a comment

Let There Be LIFE In JavaScript

screenshot - javascript life simulator

screenshot - javascript life simulator

Can you create life in JavaScript?

My new project, LIFE, is a simple javascript life simulator in which each digital citizen moves randomly, socializes, ages and breeds to replace citizens that die up to a maximum of 50 live citizens at a time. There is a limit of 50 citizens to avoid crashing the browser. Each citizen starts as a newborn and grows to adulthood. Citizens turn orange while socializing. When the citizens reach breeding age, there is a chance that socializing will result in a new citizen being born and added to the top of the pile. when citizens leave breeding age, they turn grey. When citizens die they turn black, stop moving and decompose until they are removed from the stack.

check it out here

Posted on Leave a comment

Basic WordPress Widget Tutorial


( ! ) Notice: A non well formed numeric value encountered in /var/www/html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Call Stack
#TimeMemoryFunctionLocation
10.0002395912{main}( ).../index.php:0
20.0002396200require( '/var/www/html/wp-blog-header.php' ).../index.php:17
31.351712815288require_once( '/var/www/html/wp-includes/template-loader.php' ).../wp-blog-header.php:19
41.360012944664include( '/var/www/html/wp-content/themes/storefront/archive.php' ).../template-loader.php:98
51.452213364552get_template_part( ).../archive.php:25
61.452213365016locate_template( ).../general-template.php:168
71.452313365096load_template( ).../template.php:671
81.452313365384require( '/var/www/html/wp-content/themes/storefront/loop.php' ).../template.php:724
91.475013399848get_template_part( ).../loop.php:21
101.475013400264locate_template( ).../general-template.php:168
111.475213400344load_template( ).../template.php:671
121.475213400592require( '/var/www/html/wp-content/themes/storefront/content.php' ).../template.php:724
131.476913400592do_action( ).../content.php:19
141.476913400968WP_Hook->do_action( ).../plugin.php:478
151.476913400968WP_Hook->apply_filters( ).../class-wp-hook.php:312
161.480513401344storefront_post_content( ).../class-wp-hook.php:288
171.481613401640the_content( ).../storefront-template-functions.php:414
181.481613402920apply_filters( ).../post-template.php:253
191.481613403320WP_Hook->apply_filters( ).../plugin.php:206
201.486913408608CrayonWP::the_content( ).../class-wp-hook.php:288
211.491213537736CrayonHighlighter->output( ).../crayon_wp.class.php:703
221.508013613048CrayonFormatter::print_code( ).../crayon_highlighter.class.php:189

( ! ) Notice: A non well formed numeric value encountered in /var/www/html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Call Stack
#TimeMemoryFunctionLocation
10.0002395912{main}( ).../index.php:0
20.0002396200require( '/var/www/html/wp-blog-header.php' ).../index.php:17
31.351712815288require_once( '/var/www/html/wp-includes/template-loader.php' ).../wp-blog-header.php:19
41.360012944664include( '/var/www/html/wp-content/themes/storefront/archive.php' ).../template-loader.php:98
51.452213364552get_template_part( ).../archive.php:25
61.452213365016locate_template( ).../general-template.php:168
71.452313365096load_template( ).../template.php:671
81.452313365384require( '/var/www/html/wp-content/themes/storefront/loop.php' ).../template.php:724
91.475013399848get_template_part( ).../loop.php:21
101.475013400264locate_template( ).../general-template.php:168
111.475213400344load_template( ).../template.php:671
121.475213400592require( '/var/www/html/wp-content/themes/storefront/content.php' ).../template.php:724
131.476913400592do_action( ).../content.php:19
141.476913400968WP_Hook->do_action( ).../plugin.php:478
151.476913400968WP_Hook->apply_filters( ).../class-wp-hook.php:312
161.480513401344storefront_post_content( ).../class-wp-hook.php:288
171.481613401640the_content( ).../storefront-template-functions.php:414
181.481613402920apply_filters( ).../post-template.php:253
191.481613403320WP_Hook->apply_filters( ).../plugin.php:206
201.486913408608CrayonWP::the_content( ).../class-wp-hook.php:288
211.491213537736CrayonHighlighter->output( ).../crayon_wp.class.php:703
221.508013613048CrayonFormatter::print_code( ).../crayon_highlighter.class.php:189

Sometimes you just can’t find a pre-built widget that does exactly what you want, when you run into this scenario, your best bet is to build something from scratch. This tutorial will is an answer to “How do I build a custom WordPress widget?“.

WordPress widgets are objects that have several required parts:

  1. Constructor (__construct) – actions to take when the widget is first created like enqueueing javascript or stylesheet files.
  2. Front-end  (widget) – the widget’s HTML output
  3. Back-end (form) – the form for the widget’s edit interface in the Admin section
  4. Update (update) – catches the form submission from the back-end form, updating the database

The easiest way to add a custom widget type to your theme is to build a class that looks something like this:

To embed this widget type into your own custom theme, just include this php in your functions.php

To add this widget type to your custom plugin, include this code in a standard plugin file.