Tag: CMS

  • The difference "" vs null vs 0

    The difference "" vs null vs 0

    Recently as I was conversing with my young friend, he looked at some of my code and wondered why I was using a zero or null or empty string (“” or ‘ ‘ ) instead of using one wherever I wanted.
    Programming is an interesting though weird or confusing discipline, especially to the novice things don’t mean a lot because most novices concentrate on the output than the efficiency and effectiveness of the output. For the mature programmers optimization is key, after all at the end of the day a user wants something working but requires less attention than something erroneous and slow.
    So let’s get to it. How does null, empty string and zero differ?
    Similarities
    First of all the similarity is of the three is that they are all values to variables and mostly used as the initial value of a variable.
    Second the empty string and null will usually output nothing if printed on the screen.
    Differences
    Differences might be defined differently per programming language.
    For example in Python there is no null but there is None which means the same as null in other programming languages.
    To find out the datatype of None and other values in python use the type( ) function e.g type( None ), will return NoneType data type in python. While in JavaScript we use typeof value to find out the Data type of a value stored in a variable. i.e. console.log( typeof null ) will return object as the data type of null.
    PHP 4+ we use gettype( ) function to find out the datatype of the value stored in the variable. For example gettype( null ) will return for NULL.
    If you are a JavaScript novice it’s good to pay much attention to null values since they are of data type object. For example find out how object data types are treated in JavaScript before you hit a nail in your foot.
     
    Almost all programming languages “” or ” is treated as a string and it occupies the space in memory of the size that is occupied by a string or char datatype. In fact in JavaScript if a value starts with ” even if it’s proceeded by a number or decimal it will be type cast to a string so that the resulting value will of data type string.
    So be careful initializing variables with ” especially if they will be used in mathematical expressions.
    In Java, Python and PHP 0 is treated as an integer whereas it’s treated as a number in JavaScript because in JavaScript integers and floats are number data types. I know most people might be wondering why not a Boolean?
    Though 0 or 1 might represent false/true they are not treated boolean data types.

    Why care?

    It’s always good to code what a programmer and fellow programmers understand to avoid spending time in refactoring than improving functionality and optimization.
    It’s also important to ship a software which will give more predictable results than not to avoid the users plucking hair out of their heads, assuming they’re wrong yet it’s the programmer is the calprit.
    DataTypes determine how big your program will be and how it nay handle memory, avoid confusing by planing to code rightfully from the beginning.
    Note: 
    This tutorial assumes you have some programming knowledge and some level of practice with the one or more of the programming languages cited in the tutorial.
    The tutorial is dedicated to Were Calvin a Ugandan African motion graphics designer and emerging front-end developer practicing at Gagawala Graphics limited.

  • Simplest WordPress plugins creation, Part 1.

    Simplest WordPress plugins creation, Part 1.

    There is no question WordPress is the most popular Content Management System, in the world of CMS possibly because of it’s simplistic and the free blog platform wordpress.com and support for several features; theming, plugins, widgets, media management and more being the most notable. I personally love SEO support that it comes with out of box.

    Plugins-available-in-Wordpress-dot-org
    WordPress.org has over 45k plugins!

    Actually wordpress.org has ove 40,000 plugins and more are coming in. So why do I teach someone who to make a plugin? Simply because you may have an idea that is not yet executed though it could be useful to you and other WordPress users. So if you read this short tutorial and other parts, you will be able to do that whenever you want.
    Tip: WordPress plugins can be monetized hence make some income for you.

    Prerequisite knowledge you should have/know.

    It’s important to check yourself for the technologies below.

    • HTML, CSS & PHP knowledge (Must)
    • Javascript/Jquery/Angular knowledge is a plus
    • A text editor such as Notepad++, Brackets & Sublime, etc.
    • A fully working WordPress installation, running on a local/private server. Testing on local(development) set up, is recommended in order not harm the website the visitors are viewing.

    Step 1. In a folder of your choice, create a main PHP file of your plugin and name it. e.g my_plugin.php
    For preview purposes, I suggest to create a folder, residing in the WordPress plugin folder.
    Which is located at /wordpress_install_folder/wp-content/plugins
    If you have xampp installed on your development machine, you have this folder in the path; c:/xampp/htdocs/wordpress_install_folder/wp-content/plugins
    Step 2: Add plugin code to the file

    a.Tell WordPress about your Plugin

    A WordPress plugin begins with code that describes the plugin, they code is so helpful for installation, uninstall and management of the plugin. It also makes extending the plugin or updating it’s code easier. Such details include:- Plugin Name, Description, Tags, Author, Version, Author URI and etc. As a general rule of thumb this code goes at the start of the file, enclosed in comments.
    Example:
    /*
    Plugin Name: My Plugin
    Author: awebdesigner
    Author URI: http://fictiontoactual.wordpress.com
    Description: My Plugin is a cool plugin and it will print the date at the footer of website. For illustration purposes.
    Version: 0.0.1
    */
    b. Add code to do the real thing
    add_action(‘wp_footer’,’print_date’);
    function print_date(){
    echo date(‘Y’);
    }
    Step 3: Compress and upload to server.
    Let see it in action. Compress the plugin and upload it to your site.
    Notice: Since WordPress is coded using PHP, it’s plugins supports everything PHP supports, includes, services, MYSQL etc. Don’t limit yourself.
    What’s next? Improving the functionality of our WordPress Plugin by adding to the Admin Menu, integrating a form which saves something and display to the users.
     

Verified by MonsterInsights