2017 © Pedro Peláez
 

olympus-field olympus-link-field

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

image

getolympus/olympus-link-field

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

  • Saturday, March 17, 2018
  • by crewstyle
  • Repository
  • 1 Watchers
  • 0 Stars
  • 179 Installations
  • HTML
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

, (*1)

Dionysos Link 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 wpLink WordPress javascript bundle to manage field., (*3)

composer require getolympus/olympus-dionysos-field-link

Table of contents

Field initializationVariables definitionTexts definitionRetrive dataRelease HistoryContributing, (*4)


Field initialization

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

return \GetOlympus\Dionysos\Field\Link::build('my_link_field_id', [
    'title'       => 'Never gonna give you up!',
    'default'     => [
        [
            'url'    => 'https://www.youtube.com/watch?v=oVTPg9iicy4',
            'label'  => 'Never gonna get you down!',
            'target' => '_blank',
        ],
    ],
    'description' => 'You\'ve been Rick rolled!',
    'multiple'    => false,

    /**
     * Texts definition
     * @see the `Texts definition` section below
     */
    't_addblock_title'        => 'Click on the edit button',
    't_addblock_description'  => 'Click on the "+" button to add your link.',
    't_addblocks_description' => 'Click on the "+" button to add a link item.',
    't_addblock_label'        => 'Add',
    't_editblock_label'       => 'Edit',
    't_removeblock_label'     => 'Remove',
]);

Variables definition

Variable Type Default value if not set Accepted values
title String 'Hypertext link' empty
default Array empty empty
description String empty empty
multiple Boolean false true or false

Notes: * Set multiple to true to enable the "Add link" button, (*6)

Texts definition

Code Default value Definition
t_addblock_title Click on the edit button Message displayed on an item without link
t_addblock_description Click on the "+" button to add your link. Main helper to add a single item box
t_addblocks_description Click on the "+" button to add a link item. Main helper to add multiple items boxes
t_addblock_label Add Used as an Add button area title
t_editblock_label Edit Used as an Edit button area title
t_removeblock_label Remove Used as a Remove button area title

Retrive data

Retrieve your value from Database with a simple get_option('my_link_field_id', []) (see WordPress reference).
Below, a json_encode() example to understand how data are stored in Database:, (*7)

{
  "1": {
    "url": "https://www.google.com",
    "label": "Google.com",
    "target": "_self"
  },
  "2": {
    "url": "https://www.yahoo.com",
    "label": "Yahoo.com",
    "target": "_blank"
  }
}

And below, a simple example to show how to iterate on the data array in PHP:, (*8)

// Get links from Database
$links = get_option('my_link_field_id', []);

// Check if links are empty
if (!empty($links)) {
    // Build HTML list
    echo '

'; }

Release history

Version Note
0.0.22 Add editor's button stylesheet and wp-util javascriptbr/Update README
0.0.21 JS compatibility
0.0.20 Fix display with new remove icon

Contributing

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

The Versions

17/03 2018

dev-master

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

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

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php link field olympus zeus hera

17/03 2018

v0.0.8

0.0.8.0 https://github.com/GetOlympus/olympus-link-field

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

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php link field olympus zeus

02/04 2017

v0.0.7

0.0.7.0 https://github.com/GetOlympus/olympus-link-field

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

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php link field olympus hera

21/03 2017

v0.0.6

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

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

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php link field olympus hera

08/10 2016

v0.0.5

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

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

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php link field olympus hera

26/06 2016

v0.0.4

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

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

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php link field olympus hera

10/05 2016

v0.0.3

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

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

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php link field olympus hera

05/05 2016

v0.0.2

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

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

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php link field olympus hera

29/04 2016

v0.0.1

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

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

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php link field olympus hera