PHP code example of getolympus / olympus-link-field
1. Go to this page and download the library: Download getolympus/olympus-link-field library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
getolympus / olympus-link-field example snippets
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',
]);
// Get links from Database
$links = get_option('my_link_field_id', []);
// Check if links are empty
if (!empty($links)) {
// Build HTML list
echo '<ul>';
foreach ($links as $link) {
// Build HTML items
echo '<li>';
echo '<a href="'.$link['url'].'" target="'.$link['target'].'" title="'.esc_html($link['label']).'">';
echo $link['label'];
echo '</a>';
echo '</li>';
}
echo '</ul>';
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.