get('plugin_basename') ) {
array_unshift($links, '' . __('Themes') . '');
array_unshift($links, '' . __('Settings') . '');
}
return $links;
}
/* ==================================================
* @param none
* @return none
*/
public function add_menu() {
global $Ktai_Style;
add_menu_page(__('Ktai Style Configuration', 'ktai_style'), __('Mobile Output', 'ktai_style'), 'manage_options', self::OPTIONS, array($this, 'misc_page'), $Ktai_Style->get('plugin_url') . KtaiStyle::CONFIG_DIR . '/icon16.png');
add_submenu_page(self::OPTIONS, __('Ktai Style Configuration', 'ktai_style'), __('Behavior', 'ktai_style'), 'manage_options', self::OPTIONS, array($this, 'misc_page'));
add_submenu_page(self::OPTIONS, __('Theme for mobile', 'ktai_style'), __('Theme', 'ktai_style'), 'switch_themes', self::THEME_OPTIONS, array($this, 'theme_page'));
add_action('load-' . get_plugin_page_hookname(self::THEME_OPTIONS, ''), array($this, 'theme_page_header'));
add_action('load-' . get_plugin_page_hookname(self::THEME_OPTIONS, ''), array($this, 'update_common_theme'));
add_submenu_page(self::OPTIONS, __('Mobile Theme Configuration', 'ktai_style'), __('Color & Format', 'ktai_style'), 'manage_options', self::COLOR_OPTIONS, array($this, 'color_page'));
add_submenu_page(self::OPTIONS, __('Delete Configuration', 'ktai_style'), __('Delete Options', 'ktai_style'), 'manage_options', self::DELETE_OPTIONS, array($this, 'delete_page'));
add_action('admin_print_styles', array($this, 'icon_style'));
}
/* ==================================================
* @param none
* @return none
* @since 2.0.0
*/
public function icon_style() {
global $Ktai_Style;
?>
update_options();
?>
set_radio_button($Ktai_Style->get_option('ks_allow_pictograms'));
$separate_comments = $this->set_radio_button($Ktai_Style->get_option('ks_separate_comments'));
$require_term_id = $this->set_radio_button($Ktai_Style->get_option('ks_require_term_id'));
$treat_as_internal = $Ktai_Style->get_option('ks_treat_as_internal');
?>
update_themes(); ?>
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);
?>
Ktai Style Themes website.', 'ktai_style'); ?>
get('theme_data');
if (isset($theme_data['Screenshot'])) { ?>
%2$s.'), $theme_data['Name'], str_replace( WP_CONTENT_DIR, '', $ct->get('template_dir') )); ?>
' . __( 'Displaying %s–%s of %s', 'ktai_style' ) . '%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; ?>
$cols ) {
?>
$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');
?>
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[] = '' . __('Activate') . '';
$actions[] = '' . __('Preview') . '';
$actions = apply_filters('theme_action_links', $actions, $themes[$theme_name]);
$actions = implode ( ' | ', $actions );
if ( $screenshot ) { ?>
%2$s.'), $title, str_replace( WP_CONTENT_DIR, '', $template_dir ), str_replace( WP_CONTENT_DIR, '', $stylesheet_dir ) ); ?>
|
$page_links_text
"; ?>
update_colors();
?>
get_option('ks_date_color');
$author_color = $Ktai_Style->get_option('ks_author_color');
$comment_type_color = $Ktai_Style->get_option('ks_comment_type_color');
$external_link_color = $Ktai_Style->get_option('ks_external_link_color');
$edit_color = $Ktai_Style->get_option('ks_edit_color');
$year_format = $Ktai_Style->get_option('ks_year_format');
$month_date_format = $Ktai_Style->get_option('ks_month_date_format');
$time_format = $Ktai_Style->get_option('ks_time_format');
?>
delete_options();
?>
update_boolean_option('ks_images_to_link');
$this->update_boolean_option('ks_allow_pictograms');
$this->update_boolean_option('ks_separate_comments');
$this->update_boolean_option('ks_require_term_id');
if (! empty($_POST['ks_treat_as_internal'])) {
$sites = preg_split('/\\s+/', stripslashes($_POST['ks_treat_as_internal']), -1, PREG_SPLIT_NO_EMPTY);
$sites = array_map('clean_url', $sites);
$sites = preg_replace('#/$#', '', $sites);
$sites_join = implode(' ', $sites);
if (! preg_match('/^\\s*$/', $sites_join)) {
update_option('ks_treat_as_internal', $sites_join);
} else {
delete_option('ks_treat_as_internal');
}
} else {
delete_option('ks_treat_as_internal');
}
return;
}
/* ==================================================
* @param none
* @return none
* @since 2.0.0
*/
public function update_common_theme() {
if (isset($_GET['action']) && isset($_GET['template']) && $_GET['action'] == 'activate') {
$theme = stripslashes($_GET['template']);
check_admin_referer('switch-theme_' . $theme);
KtaiThemes::set_theme($theme);
$redirect_to = sprintf('admin.php?page=%s&activated=true', self::THEME_OPTIONS);
$page = absint($_GET['pagenum']);
if ( $page > 1) {
$redirect_to .= '&pagenum=' . $page;
}
wp_redirect($redirect_to);
exit;
}
}
/* ==================================================
* @param none
* @return none
* @since 2.0.0
*/
private function update_themes() {
$theme_opts = KtaiThemes::$target;
foreach ($theme_opts as $t) {
$option = KtaiThemes::OPTION_PREFIX . '_' . $t;
$value = isset($_POST[$option]) ? stripslashes($_POST[$option]) : NULL;
KtaiThemes::set_theme($value, $t);
}
return;
}
/* ==================================================
* @param none
* @return none
* @since 2.0.0
*/
private function update_colors() {
$this->update_hex_option('ks_author_color');
$this->update_hex_option('ks_date_color');
$this->update_hex_option('ks_comment_type_color');
$this->update_hex_option('ks_external_link_color');
$this->update_hex_option('ks_edit_color');
if (! empty($_POST['ks_year_format'])) {
if (preg_match('/[Yyo]/', $_POST['ks_year_format']) && preg_match('/[mnMF]/', $_POST['ks_year_format']) && preg_match('/[djz]/', $_POST['ks_year_format'])) {
update_option('ks_year_format', stripslashes($_POST['ks_year_format']));
}
} else {
delete_option('ks_year_format');
}
if (! empty($_POST['ks_month_date_format'])) {
if (preg_match('/[mnMF]/', $_POST['ks_month_date_format']) && preg_match('/[djz]/', $_POST['ks_month_date_format'])) {
update_option('ks_month_date_format', stripslashes($_POST['ks_month_date_format']));
}
} else {
delete_option('ks_month_date_format');
}
if (! empty($_POST['ks_time_format'])) {
if (preg_match('/[djz]/', $_POST['ks_time_format']) || preg_match('/[BgGhH]/', $_POST['ks_time_format'])) {
update_option('ks_time_format', stripslashes($_POST['ks_time_format']));
}
} else {
delete_option('ks_time_format');
}
return;
}
/* ==================================================
* @param string $key
* @return none
*/
private function update_boolean_option($key) {
update_option($key, ($_POST[$key] != 0));
}
/* ==================================================
* @param string $key
* @return none
*/
private function update_hex_option($key) {
if (! empty($_POST[$key])) {
if (preg_match('/^#[0-9a-fA-F]{6}$/', $_POST[$key])) {
update_option($key, $_POST[$key]);
}
} else {
delete_option($key);
}
}
/* ==================================================
* @param none
* @return none
*/
public function delete_options() {
$theme_opts = array('ks_theme', 'ks_theme_touch', 'ks_theme_mova', 'ks_theme_foma', 'ks_theme_ezweb', 'ks_theme_sb_pdc', 'ks_theme_sb_3g', 'ks_theme_willcom', 'ks_theme_emobile');
foreach ($theme_opts as $t) {
delete_option($t);
}
delete_option('ks_title_only'); // obsolete option
delete_option('ks_external_link'); // obsolete option
delete_option('ks_images_to_link');
delete_option('ks_allow_pictograms');
delete_option('ks_separate_comments');
delete_option('ks_separate_recent_comments'); // obsolete option
delete_option('ks_treat_as_internal');
delete_option('ks_require_term_id');
delete_option('ks_author_color');
delete_option('ks_date_color');
delete_option('ks_comment_type_color');
delete_option('ks_external_link_color');
delete_option('ks_year_format');
delete_option('ks_month_date_format');
delete_option('ks_time_format');
return;
}
/* ==================================================
* @param none
* @return none
*/
public function add_comment_meta() {
add_meta_box('term_sub_ID', __("Poster's terminal ID and subscriber ID", 'ktai_style'), array($this, 'show_author_id'), 'comment', 'normal');
}
/* ==================================================
* @param object $comment
* @param mix $box
* @return none
*/
public function show_author_id($comment, $box) {
$id = KtaiServices::read_term_id($comment);
$author = array();
if (count($id)) {
if ($id[0]) {
$author[] = sprintf(__('Term ID: %s', 'ktai_style'), esc_attr($id[0]));
}
if ($id[1]) {
$author[] = sprintf(__('USIM ID: %s', 'ktai_style'), esc_attr($id[1]));
}
if ($id[2]) {
$author[] = sprintf(__('Sub ID: %s', 'ktai_style'), esc_attr($id[2]));
}
if (count($author)) {
echo implode('
', $author);
} else {
_e('N/A', 'ktai_style');
}
} else {
_e('N/A', 'ktai_style');
}
}
// ===== End of class ====================
}
?>