Example #1
0
function shorty_ajax_get_shortcodes()
{
    // Prepare
    $array = array();
    $posts = shorty_get_shortcodes();
    // Build required structure
    foreach ($posts as $post) {
        $array[] = array('value' => $post['slug'], 'text' => $post['title']);
    }
    // Return json
    echo json_encode($array);
    exit;
}
Example #2
0
function shorty_register_shortcodes()
{
    $shortcodes = shorty_get_shortcodes();
    if ($shortcodes && sizeof($shortcodes) != 0) {
        foreach ($shortcodes as $shortcode) {
            if (empty($shortcode['slug']) || empty($shortcode['content'])) {
                continue;
            }
            $slug = $shortcode['slug'];
            $content = $shortcode['content'];
            // Return final shortcode content
            $function = function () use($content) {
                return do_shortcode($content);
            };
            // Finish
            add_shortcode($slug, $function);
        }
    }
}