function tcc_flexslider() { echo '<div class="flexslider_box"><h2 class="hide">' . __('Flex Slider', 'tcc') . '</h2><div class="flexslider"><ul class="slides">'; $options = ThemeOptions::getOptions(); //載入主題設定值 $lang = get_locale(); $flexCount = count($options[$lang]['flex']['title']); if ($flexCount > 0) { for ($i = 0; $i < $flexCount; $i ++) { echo '<li><div class=' . $options[$lang]['flex']['style'][$i] . '><img src=' . $options[$lang]['flex']['image'][$i] . '><div><h3>' . $options[$lang]['flex']['title'][$i] . '</h3></div></div></li>'; } } else { // 預設圖片牆 for ($i = 1; $i <= 4; $i ++) { echo '<li><img src="'; bloginfo('template_directory'); echo '/images/image' . $i . '.jpg"/></li>'; } } echo '</ul></div></div>'; }
<footer class="footer"> <div class="copyright"> © 2014-2015 <a href="<? bloginfo("url");?>"><? bloginfo("name");?></a> </div> <div class="lastmodified"> <?_e('last Update:', 'tcc');?> <script> //取得最近更新日期 update = new Date(document.lastModified); theYear = update.getFullYear(); theMonth = update.getMonth() + 1; theDate = update.getDate(); document.write(theYear + "/" + theMonth + "/" + theDate); </script> </div> <?//自訂頁尾資訊 $options = ThemeOptions::getOptions(); foreach ($options[get_locale()]['footer']['info'] as $key => $value) { echo '<div>'.$value.'</div>'; } ?> </footer> </div> <div id="gotop"><i class="fa fa-chevron-up"></i><div></div></div> <div class="loading hide"><div><?_e('Loading...', 'tcc');?><br><img src="<?bloginfo('template_directory')?>/images/ajax-loader.gif"></div></div> </body> </html>
static public function show_page($page, $display_debug = false) { if (!current_user_can('manage_options')) { wp_die(__('You do not have sufficient permissions to access this page.' )); } $options = ThemeOptions::getOptions(); $pages = Array( 'theme_options' => Array( 'title' => __('Theme Options', 'tcc'), 'id' => 'footer', 'fileds' => Array( Array( 'title' => __('Footer Info', 'tcc'), 'id' => 'info', 'lang' => true, 'type' => 'text' ) ) ), 'marquee_options' => Array( 'title' => __('Setting the marquee message', 'tcc'), 'id' => 'marquee', 'fileds' => Array( Array( 'title' => __('Marquee Message:', 'tcc'), 'id' => 'message', 'lang' => true, 'type' => 'text' ) ) ), 'flexslider_options' => Array( 'title' => __('Setting the FlexSlider contents', 'tcc'), 'id' => 'flex', 'fileds' => Array( Array( 'title' => __('FlexSlider Title', 'tcc'), 'id' => 'title', 'lang' => true, 'type' => 'text' ), Array( 'title' => __('FlexSlider Image', 'tcc'), 'id' => 'image', 'lang' => true, 'type' => 'text' ), Array( 'title' => __('FlexSlider Style', 'tcc'), 'id' => 'style', 'type' => 'select', 'lang' => false, 'options' => Array( 'style1' => __('Style 1', 'tcc'), 'style2' => __('Style 2', 'tcc') ) ) ) ) ); $page = $pages[$page]; //指定頁面 // JavaScript產生 echo '<script> jQuery(document).ready(function() {jQuery("#add_' . $page['id'] . '").click(function() {jQuery("#' . $page['id'] . '_list > tr:last").after(\'<tr>'; foreach ($page['fileds'] as $filed_key => $filed) { echo '<td>'; if ($filed['lang']) { foreach ($options as $option_key => $option) { echo '<label>' . ThemeOptions::get_language_name($option_key) . ' </label>'; echo ThemeOptions::input_boxs($filed['type'], $page['id'] . '_' . $filed['id'] . '_' . $option_key, '', $filed['options']); } } else { echo ThemeOptions::input_boxs($filed['type'], $page['id'] . '_' . $filed['id'] . '_' . $option_key, '', $filed['options']); } echo '</td>'; } echo '</tr>\');});}); </script>'; // CSS 產生 echo '<style type="text/css"> .tcc-theme-list-table td { vertical-align: middle; } .tcc-theme-list-table td > label { min-width: 100px; display: inline-block; } .tcc-theme-list-table td > input { min-width: 90%; display: inline-block; } </style>'; echo '<div class="wrap"><h1>' . $page['title'] . '</h1><form method="post" name="form" id="form">'; echo '<div class="tablenav top"> <div class="alignleft actions bulkactions"> <input type="submit" name="option_save" class="button action" value="' . __('Save Settings','tcc') . '"> <input type="button" name="import" class="button" value="' . __('Import','tcc') . '"> <input type="button" name="export" class="button" value="' . __('Export','tcc') . '"> </div> </div> <table class="wp-list-table widefat fixed striped tcc-theme-list-table"> <thead> <tr>'; foreach ($page['fileds'] as $filed_key => $filed) { echo '<th scope="col" id="' . $filed['id'] . '" class="manage-column column-name">' . $filed['title'] . '</th>'; } echo '</tr> </thead> <tbody id="' . $page['id'] . '_list">'; for ($i = 0; $i < count($options[get_locale()][$page['id']][$page['fileds'][0]['id']]); $i++) { echo '<tr>'; foreach ($page['fileds'] as $filed_key => $filed) { echo '<td>'; if ($filed['lang']) {//!!!可以多判斷是否已有設定語言 foreach ($options as $option_key => $option) { echo '<label>' . ThemeOptions::get_language_name($option_key) . ' </label>'; echo ThemeOptions::input_boxs($filed['type'], $page['id'] . '_' . $filed['id'] . '_' . $option_key, $option[$page['id']][$filed['id']][$i], $filed['options']); } } else { echo ThemeOptions::input_boxs($filed['type'], $page['id'] . '_' . $filed['id'], $options[get_locale()][$page['id']][$filed['id']][$i], $filed['options']); } echo '</td>'; } echo '</tr>'; } echo '<tr>'; foreach ($page['fileds'] as $filed_key => $filed) { echo '<td>'; if ($filed['lang']) { foreach ($options as $option_key => $option) { echo '<label>' . ThemeOptions::get_language_name($option_key) . ' </label>'; echo ThemeOptions::input_boxs($filed['type'], $page['id'] . '_' . $filed['id'] . '_' . $option_key, '', $filed['options']); } } else { echo ThemeOptions::input_boxs($filed['type'], $page['id'] . '_' . $filed['id'] . '_' . $option_key, '', $filed['options']); } echo '</td>'; } echo '</tr> </tbody> <tfoot> <tr> '; foreach ($page['fileds'] as $filed_key => $filed) { echo '<th scope="col" id="name" class="manage-column column-name">' . $filed['title'] . '</th>'; } echo ' </tr> </tfoot> </table> <div class="tablenav bottom"> <div class="alignleft actions bulkactions"> <input type="submit" name="option_save" class="button action" value="' . __('Save Settings','tcc') . '"><input type="button" id="add_' . $page['id'] . '" class="button" value="' . __('Additional Items','tcc') . '"> </div> </div>'; wp_nonce_field('update-options'); echo '<input type="hidden" name="action" value="update" /> <input type="hidden" name="page_options" value="logo" /> </form></div>'; ThemeOptions::MCE_Editer();//MCE Editer // 顯示變數,方便DEBUG if ($display_debug) { echo '<pre>'; var_dump($options); echo '</pre>'; } }
<?get_header();?> <div id="content" class="content"> <!-- 跑馬燈 --> <section> <h2 class='hide'><?_e('Marquee', 'tcc');?></h2> <ul id="marquee" class="marquee"> <?$options = ThemeOptions::getOptions(); //載入主題設定值 foreach ($options[get_locale()]['marquee']['message'] as $key => $value) { echo '<li><h3>'.$value.'</h3></li>';// class="setofont" 引用字型 }?> </ul> </section> <!-- 跑馬燈 --> <div class="article"> <?tcc_flexslider();?> <?tcc_message_table();?> </div> </div> <?get_footer();?>