Daniele Scasciafratte @Mte90Net - WordCamp Bologna
#wcbol

WordPress as a Framework 2.0

no longer only blog cms

By Daniele Scasciafratte

Daniele Scasciafratte

  • Co Founder Codeat - Full Stack Developer
  • Mozilla Reps & Mozilla TechSpeaker
  • WordPress Contributor/Developer/Translator
  • Open Source Addicted
  • Industria Italiana Software Libero President

forget what you know about wordpress

Web Application Framework

A software framework is designed to support the development of dynamic websites, web applications, web services and web resources. The framework aims to alleviate the overhead associated with common activities performed in web development. For example, many frameworks provide libraries for database access, templating frameworks and session management, and they often promote code reuse.

Cit: http://en.wikipedia.org/wiki/Web_application_framework

Really a Framework?

  • Web Application: CRUD
  • Web Services: XML-RPC , JSON REST API
  • Database: MySQL & derivated , PosteGreSQL (partially)
  • Template System: Template Hierarchy , Your Favorite
  • User Management: Multiple User Roles , Capabilities
  • Expandable: Free Plugins , Premium Plugins
  • Meta: Custom Meta , Custom Tables
  • Update: Auto Update
  • Backend UI: Standard Theme , Custom Theme
  • URL Rewrite: Native system
  • AJAX: Native system
  • Multisite: Native system
  • Cache: Native system ,Expandable

Examples of reimplementation

Filter Hook


function custom_excerpt_length( $length ) {
    return 30;
}

add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
                    

Action Hook


function modify_post_type_supports() {
    remove_post_type_support( 'pages', 'comments' );
}
                    
add_action( 'init', 'modify_post_type_supports', 11 ); 
                    

we just started!

Custom Post type

Custom post type


function show() {
    $labels = array(
        'name'                => _x( 'Shows', 'Post Type General Name', 'file_language' ),
        'singular_name'       => _x( 'Show', 'Post Type Singular Name', 'file_language' ),
        'menu_name'           => __( 'Show', 'file_language' ),
        'name_admin_bar'      => __( 'Show', 'file_language' ),
        'parent_item_colon'   => __( 'Parent Item:', 'file_language' ),
        'all_items'           => __( 'All Items', 'file_language' ),
        'add_new_item'        => __( 'Add New Item', 'file_language' ),
        'add_new'             => __( 'Add New', 'file_language' ),
        'new_item'            => __( 'New Item', 'file_language' ),
        'edit_item'           => __( 'Edit Item', 'file_language' ),
        'update_item'         => __( 'Update Item', 'file_language' ),
        'view_item'           => __( 'View Item', 'file_language' ),
        'search_items'        => __( 'Search Item', 'file_language' ),
        'not_found'           => __( 'Not found', 'file_language' ),
        'not_found_in_trash'  => __( 'Not found in Trash', 'file_language' ),
        );
    $args = array(
        'label'               => __( 'show', 'file_language' ),
        'description'         => __( 'Show Description', 'file_language' ),
        'labels'              => $labels,
        'supports'            => array( 'title', 'editor', 'thumbnail', 'comments', ),
        'taxonomies'          => array( 'portfolio_category' ),
        'hierarchical'        => false,
        'public'              => true,
		'show_in_rest'        => true, // Support for rest
        'show_ui'             => true,
        'show_in_menu'        => true,
        'menu_position'       => 5,
        'show_in_admin_bar'   => true,
        'show_in_nav_menus'   => true,
        'has_archive'         => true,
        'exclude_from_search' => false,
        'publicly_queryable'  => true,
        'capability_type'     => 'page',
        );
    register_post_type( 'show', $args );
}
// Hook into the 'init' action
add_action( 'init', 'show', 0 );
                    

Media manager

External Libraries Integrated

  • jQuery
  • jQuery UI
  • Backbone.JS
  • Underscore.JS
  • TinyMCE
  • MediaElement.JS
  • Thickbox
  • SimplePIE
  • PHP Mailer
  • Requests

Native API Integrated

  • Widgets
  • Options/Settings
  • Shortcode
  • Transients
  • Metadata
  • oEmbed
  • Cron
  • Rewrite
  • Pointer
  • Heartbeat
  • Multisite
  • REST
  • .po, .mo support
  • Over 8000+ tests

PHP support

  • Minimum Requirement: PHP 5.2, MariaDB 10, MySQL 5.6
  • Recommend Requirement: PHP 7.2, MariaDB 10, MySQL 5.6
  • Requires PHP for plugin: Maybe 4.9.7

WP CLI

  • Easy to install
  • Easy to expand by plugins or packages
  • Command for profiling
  • No login required
  • Same features of WordPress
  • More features of WordPress
  • No webserver limits

Percona DB, MariaDB, MemCache, Varnish, Nginx, CDN, PageSpeed

Composer

  • A lot of plugins or libraries easy to integrate in your project/plugin
  • https://github.com/CMB2/CMB2
  • https://github.com/wpbp/cronplus
  • https://github.com/lucatume/wp-browser
  • https://github.com/wpackagist-plugin/posts-to-posts
  • https://github.com/corcel/corcel

Other resources

  • https://github.com/Mte90/awesome-wordpress-developer-tips
  • https://make.wordpress.org/core/2018/05/16/preparing-wordpress-for-a-javascript-future-part-1-build-step-and-folder-reorganization/
  • https://make.wordpress.org/core/2018/05/01/javascript-internationalization-the-missing-pieces/

The end