2017 © Pedro Peláez
 

olympus-field olympus-code-field

[READ-ONLY] Code field, this component is a part of the Olympus Zeus Core framework.

image

getolympus/olympus-code-field

[READ-ONLY] Code field, this component is a part of the Olympus Zeus Core framework.

  • Saturday, March 17, 2018
  • by crewstyle
  • Repository
  • 1 Watchers
  • 0 Stars
  • 176 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

, (*1)

Dionysos Code Field

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

This component is a part of the Olympus Dionysos fields for WordPress.
It uses the default WordPress code field made with a complete integration with codemirror JS component., (*3)

composer require getolympus/olympus-dionysos-field-code

Table of contents

Field initializationVariables definitionAccepted modeRetrive dataRelease HistoryContributing, (*4)


Field initialization

Use the following lines to add a code field in your WordPress admin pages or custom post type meta fields:, (*5)

return \GetOlympus\Dionysos\Field\Code::build('my_code_field_id', [
    'title'       => 'How do Penguins code their icebergs?',
    'default'     => 'With a frozen bug.',
    'description' => 'A simple question to let you know how to seduce a penguin.',
    'mode'        => 'json',
    'rows'        => 4,

    /**
     * Code mirror settings
     * @see https://developer.wordpress.org/reference/functions/wp_get_code_editor_settings/
     */
    'settings' => [
        'indentUnit'     => 2,
        'indentWithTabs' => false,
        'tabSize'        => 2,
    ],
]);

Variables definition

Variable Type Default value if not set Accepted values
title String 'Code' empty
default String empty empty
description String empty empty
mode String text/html see Accepted mode
rows Integer 4 > 1
settings Array see Field initialization see WordPress reference

Accepted mode

  • text/css or css
  • text/x-diff or x-diff or diff
  • text/html or html
  • text/javascript or javascript or js
  • application/json or json
  • text/x-markdown or markdown or md
  • application/x-httpd-php or x-httpd-php or php
  • text/x-python or x-python or python
  • text/x-ruby or x-ruby or ruby
  • text/x-sh or x-sh or sh
  • text/x-mysql or x-mysql or mysql
  • text/x-mariadb or x-mariadb or mariadb
  • application/xml or xml
  • text/x-yaml or x-yaml or yaml

Usage example

Fill the form properly (with JSON in this example):, (*6)

{
    "response": "With a frozen bug."
}

Retrive data

Retrieve your value from Database with a simple get_option('my_code_field_id', '') (see WordPress reference):, (*7)

// Get code from Database
$code = get_option('my_code_field_id', '');

// Display code in HTML tag
echo '

'.htmlspecialchars($code).'
';

Release history

Version Note
0.0.14 Fix jQuery integration on domReady
0.0.13 Add new CodeMirror css for widget integration
0.0.12 New Olympus components compatibilitybr/Change repository to be a part of Dionysos fields

Contributing

  1. Fork it (https://github.com/GetOlympus/olympus-dionysos-field-code/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., (*8)

The Versions

17/03 2018

dev-master

9999999-dev https://github.com/GetOlympus/olympus-code-field

[READ-ONLY] Code field, this component is a part of the Olympus Zeus Core framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php code field olympus zeus hera

17/03 2018

v0.0.6

0.0.6.0 https://github.com/GetOlympus/olympus-code-field

[READ-ONLY] Code field, this component is a part of the Olympus Zeus Core framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php code field olympus zeus

08/10 2016

v0.0.5

0.0.5.0 https://github.com/GetOlympus/olympus-code-field

[READ-ONLY] Code field, this component is a part of the Olympus Hera WordPress library.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php code field olympus hera

26/06 2016

v0.0.4

0.0.4.0 https://github.com/GetOlympus/olympus-code-field

[READ-ONLY] Code field, this component is a part of the Olympus Hera WordPress library.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php code field olympus hera

10/05 2016

v0.0.3

0.0.3.0 https://github.com/GetOlympus/olympus-code-field

[READ-ONLY] Code field, this component is a part of the Olympus Hera WordPress library.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php code field olympus hera

05/05 2016

v0.0.2

0.0.2.0 https://github.com/GetOlympus/olympus-code-field

[READ-ONLY] Code field, this component is a part of the Olympus Hera WordPress library.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php code field olympus hera

29/04 2016

v0.0.1

0.0.1.0 https://github.com/GetOlympus/olympus-code-field

[READ-ONLY] Code field, this component is a part of the Olympus Hera WordPress library.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php code field olympus hera