Development Blog launched – and how it is integrated

Finally the ready2order development blog has been launched today. The purpose of this blog is to post and share some development achievements, tutorials and great code snippets which are created while developing our systems. Within this first post I will demonstrate part of how the development blog itself is integrated on this website.

Besides some casual WordPress theming and settings creation we have written a WordPress Plugin to active on a site which offers a development blog. Writing a WordPress Plugin is pretty straightforward: Define a header to be read by the WordPress backend and start off with functionality. Usually this means to hook into WordPress Actions and Filters.

Defining the header:

/**
 * Plugin Name: ready2order Developer Blog
 * Version: 1.0
 * Plugin URI: https://ready2order.com/en
 * Description: Track the origin of a visitor by an encrypted URL GET parameter.
 * Author: Ready2Order ([email protected])
 * Author URI: https://ready2order.com/en
 * Text Domain: ready2order-devblog
 * Domain Path: /languages/
 * License: Commercial
 */

Registering the development post types and taxonomies:

// Register post types and taxonomies (only for pages where dev blog is activated)
function r2odb_register_typetax() {
    register_post_type('devpost',
        array(
            'labels' => [
                'name' => __('Developer Posts','ready2order-devblog'),
                'singular_name' => __('Developer Post','ready2order-devblog')
            ],
            'description' => '',
            'public' => true,
            'show_ui' => true,
            'hierarchical' => false, // parents and sub pages?
            'capability_type' => 'post', // will act like a normal post
            'rewrite' => array('slug' => 'development'), //this is used for rewriting the permalinks
            'query_var' => false,
            'supports' => ['title', 'editor', 'thumbnail', 'revisions', 'custom-fields', 'comments'], //the editing regions that will support
            'menu_position' => 5,
            'has_archive' => true
        )
    );

    register_taxonomy('devcat', // the slug for the new taxonomy
        ['devpost'], // the post type(s) you want to register a custom taxonomy for
        [
            'public' => true,
            'labels' => [
                'name' => __('Development Category','ready2order-devblog'),
                'singular_name' => __('Development Category','ready2order-devblog')
            ],
            'hierarchical' => true, // this will decide if it is like "tags" or like "categories
            'rewrite' => ['slug' => 'development-category', 'with_front' => false],
            'query_var' => true
        ]
    );

    register_taxonomy('devtag', // the slug for the new taxonomy
        ['devpost'], // the post type(s) you want to register a custom taxonomy for
        [
            'public' => true,
            'labels' => [
                'name' => __('Development Tag','ready2order-devblog'),
                'singular_name' => __('Development Tag','ready2order-devblog')
            ],
            'hierarchical' => false, // this will decide if it is like "tags" or like "categories
            'rewrite' => ['slug' => 'development-tag', 'with_front' => false],
            'query_var' => true
        ]
    );
}

By using custom post types and taxonomies we will make sure that the development blog is entirely seperated from the rest of the system.

We also register a custom sidebar for the development blog exclusively – this is where our search widget and category listings will reside:

// register the sidebar
add_action('init','r2odb_register_typetax');


function r2odb_register_sidebar() {
    register_sidebar(array(
        'name' => esc_html__('Development Blog: Sidebar Single', 'ready2order'),
        'id' => 'sidebar-devblog',
        'description' => esc_html__('Add widgets here.', 'ready2order'),
        'before_widget' => '<section id="%1$s" class="widget %2$s">',
        'after_widget' => '</section>',
        'before_title' => '<h2 class="widget-title">',
        'after_title' => '</h2>',
    ));
}

add_action('init','r2odb_register_sidebar');

 

Categories

Tags