I'm new to WP plugin development and found out that my shortcode is showing at the top of the page, but I want to include it anywhere in the post (not at the TOP).
My code:
function getLotoSecond() {
$html = file_get_contents_curl('URL__ADDRESS');
// List
$start = stripos($html, '<ul id="results-2" class="results-items">');
$end = stripos($html, '</ul>', $offset = $start);
$length = $end - $start;
$list = substr($html, $start, $length);
//--
// Regex
preg_match_all('(<label for="LotoPart_C2_([1-6]|Additional)">([0-9]|[1-9][0-9])<\/label>)', $list, $matches);
$items = $matches[2];
//--
// Output
echo '<ul>';
for($i = 0; $i < 7; $i++) {
if($i == 6) {
echo '<li style="width:30px;height:30px;border-radius:5px;background-color:#F4A024;color:white;font-size:20px;text-align:center;line-height:30px;display:inline-block;margin:0px 5px 5px 0px;">' . $items[$i] . '</li>';
} else {
echo '<li style="width:30px;height:30px;border-radius:5px;background-color:#294A70;color:white;font-size:20px;text-align:center;line-height:30px;display:inline-block;margin:0px 5px 5px 0px;">' . $items[$i] . '</li>';
}
}
echo '</ul>';
//--
}
And then:
function main($atts) {
if($atts["type"] == "loto-prvy") {
getLotoFirst();
} else if($atts["type"] == "loto-druhy") {
getLotoSecond();
}
}
add_shortcode('tipo', 'main');
What should be the problem here?
My Answer:
Rate this post
4 of 5 based on 1780 votesComments