1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
<?php
namespace hji\geofarms\controllers;
use \hji\geofarms\GeoFarms;
class Shortcodes
{
function __construct()
{
add_shortcode(GeoFarms::$slug, array($this, 'hjigf_display'));
add_shortcode(GeoFarms::$slug . '-map', array($this, 'hjigf_map_display'));
}
function hjigf_display($atts)
{
ob_start();
$a = shortcode_atts(array(
'ids' => false,
'tags' => false,
'sort' => 'none',
'display_type' => 'list',
'grid_size' => '1',
'width' => 150,
'height' => 150,
'classes' => 'img_responsive',
), $atts);
$id_array = $a['ids'] ? explode(",",$a['ids']) : array();
hjigf_display($id_array, $a['tags'], $a['sort'], array('w' => $a['width'], 'h' => $a['height'], 'classes' => $a['classes']), $a['display_type'], $a['grid_size']);
$output = ob_get_contents();
ob_end_clean();
return $output;
}
function hjigf_map_display($atts)
{
ob_start();
$a = shortcode_atts(array(
'parent_only' => false,
'id' => null,
), $atts);
echo hjigf_display_map($a['parent_only'], $a['id']);
$output = ob_get_contents();
ob_end_clean();
return $output;
}
}