コード例 #1
0
ファイル: class-tabs.php プロジェクト: mathewdenis/avada
 function parse_tab_parameter($content, $shortcode, $args = null)
 {
     $preg_match_tabs_single = preg_match_all(FusionCore_Plugin::get_shortcode_regex($shortcode), $content, $tabs_single);
     if (is_array($tabs_single[0])) {
         foreach ($tabs_single[0] as $key => $tab) {
             if (is_array($args)) {
                 $preg_match_titles = preg_match_all('/' . $shortcode . ' id=([0-9]+)/i', $tab, $ids);
                 if (array_key_exists('0', $ids[1])) {
                     $id = $ids[1][0];
                 } else {
                     $title = 'default';
                 }
                 foreach ($args as $key => $value) {
                     if ($key == $shortcode . $id) {
                         $title = $value;
                     }
                 }
             } else {
                 $preg_match_titles = preg_match_all('/' . $shortcode . ' title="([^\\"]+)"/i', $tab, $titles);
                 if (array_key_exists('0', $titles[1])) {
                     $title = $titles[1][0];
                 } else {
                     $title = 'default';
                 }
             }
             $preg_match_icons = preg_match_all('/' . $shortcode . '( id=[0-9]+| title="[^\\"]+")? icon="([^\\"]+)"/i', $tab, $icons);
             if (array_key_exists('0', $icons[2])) {
                 $icon = $icons[2][0];
             } else {
                 $icon = 'none';
             }
             // create unique tab id for linking
             $sanitized_title = hash("md5", $title, false);
             $sanitized_title = 'tab' . str_replace('-', '_', $sanitized_title);
             $unique_id = 'tab-' . substr(md5(get_the_ID() . '-' . $this->tabs_counter . '-' . $this->tab_counter . '-' . $sanitized_title), 13);
             // create array for every single tab shortcode
             $this->tabs[] = array('title' => $title, 'icon' => $icon, 'unique_id' => $unique_id);
             $this->tab_counter++;
         }
         $this->tab_counter = 1;
     }
 }