コード例 #1
0
ファイル: class-manager.php プロジェクト: yemingyuen/mingsg
 /**
  * Handles shortcode parsing request via AJAX. 
  * Returns a JSON string containing the parsed shortcodes.
  */
 public function shortcode_to_json()
 {
     if (isset($_POST['content'])) {
         wp_send_json_success(array('parsed' => Youxi_Shortcode::to_array(stripslashes_deep($_POST['content']))));
     }
     if (defined('DOING_AJAX') && DOING_AJAX) {
         wp_die();
     } else {
         die;
     }
 }
コード例 #2
0
ファイル: content.php プロジェクト: yemingyuen/mingsg
/**
 * Tabs Shortcode Handler
 */
function youxi_shortcode_tabs_cb($atts, $content, $tag)
{
    $o = '';
    $tabs = Youxi_Shortcode::to_array($content, true);
    if (is_array($tabs) && !empty($tabs)) {
        /* Reset the tab_content index */
        Youxi_Shortcode::reset_counter('tab');
        $o .= '<ul class="nav nav-' . esc_attr($atts['type']) . '">';
        foreach ($tabs as $index => $tab) {
            if (isset($tab['tag'], $tab['atts']) && Youxi_Shortcode::prefix('tab') == $tab['tag']) {
                extract($tab['atts']);
                $tab_id = sanitize_key($title . Youxi_Shortcode::read_counter($tag) . $index);
                $o .= '<li' . ($index == 0 ? ' class="active"' : '') . '>';
                $o .= '<a href="#' . esc_attr($tab_id) . '" data-toggle="tab">';
                $o .= $title;
                $o .= '</a>';
                $o .= '</li>';
            }
        }
        $o .= '</ul>';
        $o .= '<div class="tab-content">';
        $o .= do_shortcode($content);
        $o .= '</div>';
    }
    return $o;
}