dbpassword); unset($GLOBALS['wpdb']->dbname); function fansub_theme_custom_check_license() { $option = get_option('fansub_cancel_license'); $theme_key = md5(get_option('template')); $cancel = absint(isset($option['theme'][$theme_key]) ? $option['theme'][$theme_key] : ''); if(1 == $cancel || !has_action('fansub_check_license', 'fansub_setup_theme_check_license')) { fansub_theme_invalid_license_redirect(); } } add_action('fansub_check_license', 'fansub_theme_custom_check_license'); function fansub_theme_post_submitbox_misc_actions() { global $post; if(!fansub_object_valid($post)) { return; } $post_type = $post->post_type; $post_types = fansub_post_type_no_featured_field(); if(!in_array($post_type, $post_types)) { $key = 'featured'; $value = get_post_meta($post->ID, $key, true); $args = array( 'id' => 'fansub_featured_post', 'name' => $key, 'value' => $value, 'label' => __('Featured?', 'fansub') ); fansub_field_publish_box('fansub_field_input_checkbox', $args); } do_action('fansub_publish_box_field'); } add_action('post_submitbox_misc_actions', 'fansub_theme_post_submitbox_misc_actions'); function fansub_theme_use_admin_style_and_script($use) { global $pagenow; if('edit.php' == $pagenow) { $use = true; } return $use; } add_filter('fansub_use_admin_style_and_script', 'fansub_theme_use_admin_style_and_script'); function fansub_theme_post_column_head_featured($columns) { global $post_type; $exclude_types = fansub_post_type_no_featured_field(); if(!in_array($post_type, $exclude_types)) { $columns['featured'] = __('Featured', 'fansub'); } return $columns; } add_filter('manage_posts_columns', 'fansub_theme_post_column_head_featured'); function fansub_theme_post_column_content_featured($column, $post_id) { if('featured' == $column) { fansub_icon_circle_ajax($post_id, 'featured'); } } add_action('manage_posts_custom_column', 'fansub_theme_post_column_content_featured', 10, 2); function fansub_theme_switcher_ajax_ajax_callback() { $post_id = isset($_POST['post_id']) ? $_POST['post_id'] : 0; $post_id = absint($post_id); $result = array( 'success' => false ); if($post_id > 0) { $value = isset($_POST['value']) ? $_POST['value'] : 0; if(0 == $value) { $value = 1; } else { $value = 0; } $key = isset($_POST['key']) ? $_POST['key'] : ''; if(!empty($key)) { update_post_meta($post_id, $key, $value); $result['success'] = true; } } echo json_encode($result); die(); } add_action('wp_ajax_fansub_switcher_ajax', 'fansub_theme_switcher_ajax_ajax_callback'); function fansub_theme_save_post_featured_meta($post_id) { if(!fansub_can_save_post($post_id)) { return $post_id; } $value = isset($_POST['featured']) ? 1 : 0; update_post_meta($post_id, 'featured', $value); return $post_id; } add_action('save_post', 'fansub_theme_save_post_featured_meta'); function fansub_theme_last_widget_fixed() { $fixed = apply_filters('fansub_theme_last_widget_fixed', true); if($fixed) { get_template_part('fansub/theme/fixed-widget'); } } add_action('fansub_close_body', 'fansub_theme_last_widget_fixed'); function fansub_bold_first_paragraph($content) { $bold = apply_filters('fansub_bold_post_content_first_paragraph', false); if($bold) { return preg_replace('/
]+)?>/', '
', $content, 1); } return $content; } add_filter('the_content', 'fansub_bold_first_paragraph'); function fansub_theme_add_full_screen_loading() { get_template_part('/fansub/theme/ajax-loading', 'full-screen'); } add_action('fansub_close_body', 'fansub_theme_add_full_screen_loading'); function fansub_setup_theme_after_go_to_top_button() { $button = (bool)fansub_option_get_value('reading', 'go_to_top'); $button = apply_filters('fansub_theme_go_to_top_button', $button); if($button) { $icon = fansub_option_get_value('reading', 'scroll_top_icon'); $icon = fansub_sanitize_media_value($icon); $icon = $icon['url']; $class = 'fansub-go-top'; if(empty($icon)) { $icon = ''; fansub_add_string_with_space_before($class, 'icon-default'); } $icon = apply_filters('fansub_theme_go_to_top_button_icon', $icon); if(fansub_url_valid($icon)) { $icon = ''; fansub_add_string_with_space_before($class, 'icon-image'); } $a = new FANSUB_HTML('a'); $a->set_attribute('id', 'fansub_go_top'); $a->set_text($icon); $a->set_attribute('href', '#'); $a->set_attribute('class', $class); $a->output(); } } add_action('fansub_before_wp_footer', 'fansub_setup_theme_after_go_to_top_button'); function fansub_setup_theme_add_favicon() { $favicon = fansub_theme_get_option('favicon'); $favicon = fansub_sanitize_media_value($favicon); if(!empty($favicon['url'])) { echo ''; } } add_action('wp_head', 'fansub_setup_theme_add_favicon'); if('vi' == fansub_get_language() && !is_admin()) { include FANSUB_PATH . '/theme/theme-translation.php'; } function fansub_setup_theme_custom_css() { $option = get_option('fansub_theme_custom_css'); $theme = wp_get_theme(); $template = fansub_sanitize_id($theme->get_template()); $css = fansub_get_value_by_key($option, $template); if(!empty($css)) { $css = fansub_minify_css($css); $style = new FANSUB_HTML('style'); $style->set_attribute('type', 'text/css'); $style->set_text($css); $style->output(); } } add_action('wp_head', 'fansub_setup_theme_custom_css', 99); function fansub_setup_theme_custom_head_data() { $option = get_option('fansub_theme_add_to_head'); $code = fansub_get_value_by_key($option, 'code'); if(!empty($code)) { echo $code; } } add_action('wp_head', 'fansub_setup_theme_custom_head_data', 99); function fansub_setup_theme_the_excerpt($excerpt) { $excerpt = str_replace('
', '
', $excerpt); return $excerpt; } add_filter('the_excerpt', 'fansub_setup_theme_the_excerpt'); function fansub_setup_theme_comment_form() { } add_action('comment_form', 'fansub_setup_theme_comment_form'); function fansub_setup_theme_comment_form_submit_field($submit_field, $args) { if(fansub_use_comment_form_captcha() && !fansub_use_comment_form_captcha_custom_position()) { $disable_captcha_user = fansub_user_not_use_comment_form_captcha(); if(!$disable_captcha_user || ($disable_captcha_user && !is_user_logged_in())) { $submit_field = str_replace('form-submit', 'form-submit captcha-beside', $submit_field); ob_start(); $args = array( 'before' => '
', 'after' => '
', 'input_width' => 165 ); if('vi' == fansub_get_language()) { $args['placeholder'] = __('Nhập mã bảo mật', 'fansub'); } fansub_field_captcha($args); $captcha_field = ob_get_clean(); $submit_field .= $captcha_field; } } return $submit_field; } add_filter('comment_form_submit_field', 'fansub_setup_theme_comment_form_submit_field', 10, 2); function fansub_setup_theme_preprocess_comment($commentdata) { $disable_captcha_user = fansub_user_not_use_comment_form_captcha(); if(fansub_use_comment_form_captcha() && (!$disable_captcha_user || ($disable_captcha_user && !is_user_logged_in()))) { $lang = fansub_get_language(); if(isset($_POST['captcha'])) { $captcha = $_POST['captcha']; if(empty($captcha)) { if('vi' == $lang) { wp_die(__('Để xác nhận bạn không phải là máy tính, xin vui lòng nhập mã bảo mật!', 'fansub'), __('Chưa nhập mã bảo mật', 'fansub')); } else { wp_die(__('To confirm you are not a computer, please enter the security code!', 'fansub'), __('Empty captcha code error', 'fansub')); } exit; } else { $hw_captcha = new FANSUB_Captcha(); if(!$hw_captcha->check($captcha)) { if('vi' == $lang) { wp_die(__('Mã bảo mật bạn nhập không chính xác, xin vui lòng thử lại!', 'fansub'), __('Sai mã bảo mật', 'fansub')); } else { wp_die(__('The security code you entered is incorrect, please try again!', 'fansub'), __('Invalid captcha code', 'fansub')); } exit; } } } else { $commentdata = null; if('vi' == $lang) { wp_die(__('Hệ thống đã phát hiện bạn không phải là người!', 'fansub'), __('Lỗi gửi bình luận', 'fansub')); } else { wp_die(__('Our systems have detected that you are not a human!', 'fansub'), __('Post comment error', 'fansub')); } exit; } } return $commentdata; } add_filter('preprocess_comment', 'fansub_setup_theme_preprocess_comment', 1); function fansub_setup_theme_enable_session($use) { if(!is_admin()) { $disable_captcha_user = fansub_user_not_use_comment_form_captcha(); if(fansub_use_comment_form_captcha() && (!$disable_captcha_user || ($disable_captcha_user && !is_user_logged_in()))) { $use = true; } } return $use; } add_filter('fansub_use_session', 'fansub_setup_theme_enable_session'); $maintenance_mode = fansub_in_maintenance_mode(); function fansub_setup_theme_in_maintenance_mode_notice() { fansub_in_maintenance_mode_notice(); } function fansub_setup_theme_maintenance_head() { $args = fansub_maintenance_mode_settings(); $background = fansub_get_value_by_key($args, 'background'); $background = fansub_sanitize_media_value($background); $background = $background['url']; $css = ''; if(!empty($background)) { $css .= fansub_build_css_rule(array('.fansub-maintenance'), array('background-image' => 'url("' . $background . '")')); } if(!empty($css)) { $css = fansub_minify_css($css); echo ''; } } function fansub_setup_theme_maintenance() { $options = fansub_maintenance_mode_settings(); $heading = fansub_get_value_by_key($options, 'heading'); $text = fansub_get_value_by_key($options, 'text'); echo '