public function theme_page() { global $Ktai_Style; register_setting(self::THEME_OPTIONS, 'ks_theme'); register_setting(self::THEME_OPTIONS, 'ks_theme_touch'); register_setting(self::THEME_OPTIONS, 'ks_theme_mova'); register_setting(self::THEME_OPTIONS, 'ks_theme_foma'); register_setting(self::THEME_OPTIONS, 'ks_theme_ezweb'); register_setting(self::THEME_OPTIONS, 'ks_theme_sb_pdc'); register_setting(self::THEME_OPTIONS, 'ks_theme_sb_3g'); register_setting(self::THEME_OPTIONS, 'ks_theme_willcom'); register_setting(self::THEME_OPTIONS, 'ks_theme_emobile'); if (isset($_GET['activated'])) { ?> <div class="updated fade"><p><strong><?php _e('New theme activated.', 'ktai_style'); ?> </strong></p></div> <?php } elseif (isset($_POST['update_option'])) { check_admin_referer(self::THEME_OPTIONS); $this->update_themes(); ?> <div class="updated fade"><p><strong><?php _e('Options saved.'); ?> </strong></p></div> <?php } $theme = $Ktai_Style->get_option('ks_theme'); $theme_touch = $Ktai_Style->get_option('ks_theme_touch'); $theme_mova = $Ktai_Style->get_option('ks_theme_mova'); $theme_foma = $Ktai_Style->get_option('ks_theme_foma'); $theme_ezweb = $Ktai_Style->get_option('ks_theme_ezweb'); $theme_sb_pdc = $Ktai_Style->get_option('ks_theme_sb_pdc'); $theme_sb_3g = $Ktai_Style->get_option('ks_theme_sb_3g'); $theme_willcom = $Ktai_Style->get_option('ks_theme_willcom'); $theme_emobile = $Ktai_Style->get_option('ks_theme_emobile'); $paged_themes = $themes = KtaiThemes::installed(); // assume included inc/themes.php at init_pc() $ct = new KtaiThemes(); unset($paged_themes[$ct->get('theme')]); $theme_total = count($paged_themes); if (isset($_GET['pagenum'])) { $page = absint($_GET['pagenum']); if (empty($page)) { $page = 1; } } else { $page = 1; } $start = $offset = ($page - 1) * self::THEMES_PER_PAGE; $page_links = paginate_links(array('base' => add_query_arg('pagenum', '%#%') . '#themenav', 'format' => '', 'prev_text' => __('«'), 'next_text' => __('»'), 'total' => ceil($theme_total / self::THEMES_PER_PAGE), 'current' => $page)); $paged_themes = array_slice($paged_themes, $start, self::THEMES_PER_PAGE); ?> <div class="wrap"> <div id="icon-ktaistyle" class="icon32"><br /></div> <h2><?php _e('Theme for mobile', 'ktai_style'); ?> </h2> <p><?php _e('Additonal themes are available at <a href="http://ks-theme.sourceforge.jp/">Ktai Style Themes</a> website.', 'ktai_style'); ?> </p> <h3><?php _e('Current Theme'); ?> </h3> <div id="current-theme"> <?php $theme_data = $ct->get('theme_data'); if (isset($theme_data['Screenshot'])) { ?> <img src="<?php echo $theme_data['Screenshot']; ?> " alt="<?php _e('Current theme preview'); ?> " style="width:120px" /> <?php } ?> <h4><?php printf(__('%1$s %2$s by %3$s', 'ktai_style'), $theme_data['Name'], $theme_data['Version'], $theme_data['Author']); ?> </h4> <p class="theme-description"><?php echo $theme_data['Description']; ?> </p> </div> <p><?php printf(__('All of this theme’s files are located in <code>%2$s</code>.'), $theme_data['Name'], str_replace(WP_CONTENT_DIR, '', $ct->get('template_dir'))); ?> </p> <div class="clear"></div> <h3><?php _e('Available Themes'); ?> </h3> <?php if ($theme_total) { if ($page_links) { ?> <div class="tablenav"> <div class="tablenav-pages"><?php $page_links_text = sprintf('<span class="displaying-num">' . __('Displaying %s–%s of %s', 'ktai_style') . '</span>%s', number_format_i18n($start + 1), number_format_i18n(min($page * self::THEMES_PER_PAGE, $theme_total)), number_format_i18n($theme_total), $page_links); echo $page_links_text; ?> </div> </div> <?php } ?> <table id="availablethemes" cellspacing="0" cellpadding="0"> <?php $style = ''; $theme_names = array_keys($paged_themes); natcasesort($theme_names); $table = array(); $rows = ceil(count($theme_names) / self::THEME_COLS); for ($row = 1; $row <= $rows; $row++) { for ($col = 1; $col <= self::THEME_COLS; $col++) { $table[$row][$col] = array_shift($theme_names); } } foreach ($table as $row => $cols) { ?> <tr> <?php foreach ($cols as $col => $theme_name) { $class = array('available-theme'); if ($row == 1) { $class[] = 'top'; } if ($col == 1) { $class[] = 'left'; } if ($row == $rows) { $class[] = 'bottom'; } if ($col == 3) { $class[] = 'right'; } $t = new KtaiThemes($theme_name); $theme_data = $t->get('theme_data'); ?> <td class="<?php echo join(' ', $class); ?> "> <?php if (!empty($theme_name)) { $title = $theme_data['Name']; $version = $theme_data['Version']; $description = $theme_data['Description']; $author = $theme_data['Author']; $screenshot = $theme_data['Screenshot']; $template_dir = $t->get('template_dir'); $theme_root = $theme_data['Theme Root']; $theme_root_uri = ${$theme_data}['Theme Root URI']; $preview_link = esc_attr(get_option('home') . '/'); if (is_ssl()) { $preview_link = str_replace('http://', 'https://', $preview_link); } $preview_link = htmlspecialchars(add_query_arg(array('preview' => 1, 'mobile' => 1, 'template' => urlencode($theme_name), '_wpnonce' => $Ktai_Style->create_anon_nonce('switch-theme_' . $theme_name), 'TB_iframe' => 'true'), $preview_link)); $preview_text = esc_attr(sprintf(__('Preview of “%s”'), $title)); $thickbox_class = 'thickbox thickbox-preview'; $activate_link = wp_nonce_url(sprintf('admin.php?page=%1$s&pagenum=%2$d&action=activate&template=%3$s', self::THEME_OPTIONS, $page, urlencode($theme_name)), 'switch-theme_' . $theme_name); $activate_text = esc_attr(sprintf(__('Activate “%s”'), $title)); $actions = array(); $actions[] = '<a href="' . $activate_link . '" class="activatelink" title="' . $activate_text . '">' . __('Activate') . '</a>'; $actions[] = '<a href="' . $preview_link . '" class="thickbox thickbox-preview" title="' . esc_attr(sprintf(__('Preview “%s”'), $theme_name)) . '">' . __('Preview') . '</a>'; $actions = apply_filters('theme_action_links', $actions, $themes[$theme_name]); $actions = implode(' | ', $actions); if ($screenshot) { ?> <a href="<?php echo $preview_link; ?> " class="<?php echo $thickbox_class; ?> screenshot" style="width:180px;height:450px;"><img src="<?php echo $screenshot; ?> " alt="" style="width:180px;height:450px;" /></a> <?php } ?> <h3><?php /* translators: 1: theme title, 2: theme version, 3: theme author */ printf(__('%1$s %2$s by %3$s', 'ktai_style'), $title, $version, $author); ?> </h3> <p class="description"><?php echo $description; ?> </p> <span class='action-links'><?php echo $actions; ?> </span> <p><?php printf(__('All of this theme’s files are located in <code>%2$s</code>.'), $title, str_replace(WP_CONTENT_DIR, '', $template_dir), str_replace(WP_CONTENT_DIR, '', $stylesheet_dir)); ?> </p> <?php } // end if not empty theme_name ?> </td> <?php } // end foreach $cols ?> </tr> <?php } // end foreach $table ?> </table> <?php } else { ?> <p><?php _e('You only have one theme installed at the moment so there is nothing to show you here. Maybe you should download some more to try out.'); ?> </p> <?php } // end if $theme_total ?> <br class="clear" /> <?php if ($page_links) { ?> <div class="tablenav"> <?php echo "<div class='tablenav-pages'>{$page_links_text}</div>"; ?> <br class="clear" /> </div> <?php } ?> <h3><?php _e('Theme for each career', 'ktai_style'); ?> </h3> <form name="form" method="post" action="<?php echo sprintf('admin.php?page=%s', self::THEME_OPTIONS) . ($page > 1 ? '&pagenum=' . $page : ''); ?> "> <input type="hidden" name="action" value="update" /> <?php wp_nonce_field(self::THEME_OPTIONS); ?> <table class="form-table"><tbody> <?php $careers[] = array('label' => 'theme_touch', 'desc' => __('For iPhone, Android', 'ktai_style')); $careers[] = array('label' => 'theme_mova', 'desc' => __('For mova (docomo)', 'ktai_style')); $careers[] = array('label' => 'theme_foma', 'desc' => __('For FOMA (docomo)', 'ktai_style')); $careers[] = array('label' => 'theme_ezweb', 'desc' => __('For EZweb (au)', 'ktai_style')); $careers[] = array('label' => 'theme_sb_pdc', 'desc' => __('For SoftBank PDC', 'ktai_style')); $careers[] = array('label' => 'theme_sb_3g', 'desc' => __('For SoftBank 3G', 'ktai_style')); $careers[] = array('label' => 'theme_willcom', 'desc' => __('For WILLCOM', 'ktai_style')); $careers[] = array('label' => 'theme_emobile', 'desc' => __('For EMobile Handset', 'ktai_style')); foreach ($careers as $index => $c) { ?> <tr><th><label for="ks_<?php echo $c['label']; ?> "><?php echo $c['desc']; ?> </label></th> <td><select name="ks_<?php echo $c['label']; ?> " id="ks_<?php echo $c['label']; ?> "> <?php if (strcmp($c['label'], 'theme_touch') === 0) { $current = empty(${$c['label']}) ? ' selected="selected"' : ''; echo '<option value="0"' . $current . '>' . __("(Don't use Ktai Style)", 'ktai_style') . '</option>'; ?> <option value="<?php echo KtaiThemes::SAME_THEME_AS_COMMON; ?> "<?php selected(${$c['label']}, KtaiThemes::SAME_THEME_AS_COMMON); ?> ><?php _e('(Same as common theme)', 'ktai_style'); ?> </option><?php } elseif (strcmp($c['label'], 'theme') !== 0) { $current = empty(${$c['label']}) ? ' selected="selected"' : ''; echo '<option value="0"' . $current . '>' . __('(Same as common theme)', 'ktai_style') . '</option>'; } foreach ($themes as $dir => $name) { ?> <option value="<?php echo esc_attr($dir); ?> "<?php selected($dir, ${$c['label']}); ?> ><?php echo esc_attr($name); ?> </option><?php } ?> </select></td></tr> <?php } // foreach ?> <tr><td colspan="2"><?php _e('Other phones (Windows Mobile, Palm, PSP, Nintendo DS, etc) are not able to select an exclusive theme.', 'ktai_style'); ?> </td></tr> </tbody></table> <p class="submit"> <input type="submit" name="update_option" class="button-primary" value="<?php _e('Save Changes'); ?> " /> </p> </form> </div> <?php }