2017 © Pedro Peláez
 

framework olympus-hera

Olympus Zeus framework core system used to make all your WordPress plugins and themes developments easier and efficient.

image

getolympus/olympus-hera

Olympus Zeus framework core system used to make all your WordPress plugins and themes developments easier and efficient.

  • Tuesday, May 1, 2018
  • by crewstyle
  • Repository
  • 1 Watchers
  • 1 Stars
  • 147 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 50 Versions
  • 0 % Grown

The README.md

Olympus Zeus Core ![PHP Version][php-image]

Olympus Zeus Core is a framework which allows you to make all your WordPress plugins and themes developments easier and efficient., (*1)

composer require getolympus/olympus-zeus-core

Olympus Component ![CodeFactor Grade][codefactor-image] Packagist Version Travis Status ![MIT][license-image], (*2)


Features

With Composer, (*3)

Initialization

To initialize Zeus Core from your functions.php WordPress theme file or main plugin php file:, (*4)

// file: functions.php
namespace MyThemeName;

/**
 * Everything starts here.
 *
 * @package MyThemeName
 * @author  Your Name <yourmail@domain-name.ext>
 * @since   x.y.z
 *
 */

// Directory separator and Vendor path.
defined('S')          or define('S', DIRECTORY_SEPARATOR); // Provided by Olympus container
defined('VENDORPATH') or define('VENDORPATH', realpath(dirname(__DIR__)).S.'vendor'.S); // Provided by Olympus container

/**
 * MyThemeName class definition
 */

if (!class_exists('MyThemeName')) {
    /**
     * Use of Zeus abstract PHP class to initialize everything.
     */
    class MyThemeName extends \GetOlympus\Zeus\Zeus
    {
        /**
         * Define all useful folders
         */
        // Load option admin pages
        protected $adminpages = __DIR__.S.'controllers'.S.'adminpages';
        // Load scheduled actions
        protected $crons      = __DIR__.S.'controllers'.S.'crons';
        // Load custom post types
        protected $posttypes  = __DIR__.S.'controllers'.S.'posttypes';
        // Load custom terms
        protected $terms      = __DIR__.S.'controllers'.S.'terms';
        // Load options for users
        protected $users      = __DIR__.S.'controllers'.S.'users';
        // Load custom widgets
        protected $widgets    = __DIR__.S.'controllers'.S.'widgets';

        /**
         * Define WordPress optimizations and configurations in a single var.
         */
        protected $configurations = [
            'AccessManagement' => [/*...*/],
            'Assets'           => [/*...*/],
            'Clean'            => [/*...*/],
            'Menus'            => [/*...*/],
            'Settings'         => [/*...*/],
            'Shortcodes'       => [/*...*/],
            'Sidebars'         => [/*...*/],
            'Sizes'            => [/*...*/],
            'Supports'         => [/*...*/],
        ];

        /**
         * Main function which defines vendors path
         * and some useful actions needed by your application
         */
        protected function setVars()
        {
            // Load Zeus framework vendors.
            if (file_exists($autoload = VENDORPATH.'autoload.php')) {
                include $autoload;
            }

            // Add custom actions.
        }
    }
}

// Instanciate MyThemeName
return new MyThemeName();

A custom post type example

Assuming you need a new Movie custom post type, here is the controllers/posttypes/MoviePosttype.php content file:, (*5)

// file: controllers/posttypes/MoviePosttype.php
namespace MyThemeName\Controllers\Posttypes;

/**
 * Extends main \GetOlympus\Zeus\Posttype\Posttype class to use all functionalities
 */
class MoviePosttype extends \GetOlympus\Zeus\Posttype\Posttype
{
    /**
     * @var array
     */
    protected $args = [
        'menu_icon'     => 'dashicons-video-alt3',
        'supports'      => ['title', 'excerpt', 'thumbnail'],
        'taxonomies'    => ['post_tag'],
        'rewrite'       => [
            'slug'          => 'movie',
            'with_front'    => true,
        ],
    ];

    /**
     * @var string
     */
    protected $slug = 'movie';

    /**
     * Prepare variables.
     */
    public function setVars()
    {
        // Update labels
        $this->setLabels([
            'name'          => __('Movies', 'mythemename'),
            'singular_name' => __('Movie', 'mythemename'),
        ]);

        // Add metabox
        $this->addMetabox(__('Details', 'mythemename'), [
            \GetOlympus\Dionysos\Field\Text::build('link', [
                'title' => __('Movie source URL', 'mythemename'),
            ]),
            \GetOlympus\Dionysos\Field\Text::build('length', [
                'title' => __('Length in seconds', 'mythemename'),
            ]),
            \GetOlympus\Dionysos\Field\Text::build('author', [
                'title' => __('Author name', 'mythemename'),
            ]),
            // (...)
        ]);
    }
}

Release History

See CHANGELOG.md for all details., (*6)

Contributing

  1. Fork it (https://github.com/GetOlympus/Zeus-Core/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

Built with ♥ by Achraf Chouk ~ (c) since a long time., (*7)

The Versions