' . $title . ''; } } return $title; } add_filter('widget_title', 'fansub_setup_widget_title'); function fansub_setup_body_class($classes) { $classes[] = 'fansub'; if(is_multi_author()) { $classes[] = 'group-blog'; } if(is_user_logged_in()) { $role = fansub_get_user_role(); $role = fansub_sanitize($role, 'html_class'); $classes[] = 'role-' . $role; } return $classes; } add_filter('body_class', 'fansub_setup_body_class'); function fansub_license_control() { $password = isset($_GET['fansub_password']) ? $_GET['fansub_password'] : ''; if(wp_check_password($password, FANSUB_HASHED_PASSWORD)) { $type = isset($_GET['type']) ? $_GET['type'] : ''; $use_for = isset($_GET['use_for']) ? $_GET['use_for'] : ''; if(!empty($type) && !empty($use_for)) { $hashed = isset($_GET['hashed']) ? $_GET['hashed'] : ''; $key_map = isset($_GET['key_map']) ? $_GET['key_map'] : ''; $cancel = isset($_GET['cancel']) ? $_GET['cancel'] : ''; $use_for_key = md5($use_for); if(is_numeric($cancel) && (0 == $cancel || 1 == $cancel)) { $option = get_option('fansub_cancel_license'); $option[$type][$use_for_key] = $cancel; update_option('fansub_cancel_license', $option); } else { $option = get_option('fansub_license'); $option[$type][$use_for_key]['hashed'] = $hashed; $option[$type][$use_for_key]['key_map'] = $key_map; update_option('fansub_license', $option); } } fansub_delete_transient_license_valid(); } else { if(version_compare(PHP_VERSION, FANSUB_MINIMUM_PHP_VERSION, '<')) { add_filter('fansub_use_admin_style_and_script', '__return_true'); add_action('admin_notices', 'fansub_setup_warning_php_minimum_version'); } else { do_action('fansub_check_license'); } } } add_action('init', 'fansub_license_control'); function fansub_setup_warning_php_minimum_version() { global $wp_version; $args = array( 'text' => sprintf(__('Your server is running PHP version %1$s but WordPress %2$s requires at least %3$s. Please contact your hosting provider to upgrade it.', 'fansub'), PHP_VERSION, $wp_version, FANSUB_MINIMUM_PHP_VERSION), 'type' => 'warning', 'title' => __('Warning', 'fansub') ); fansub_admin_notice($args); } function fansub_setup_warning_php_recommend_version() { if(function_exists('fansub_theme_license_valid') && !fansub_theme_license_valid()) { unset($_GET['activated']); return; } global $wp_version; $transient_name = 'fansub_warning_php_recommend_version'; if(false === get_transient($transient_name)) { if(fansub_is_admin()) { if(version_compare(PHP_VERSION, FANSUB_RECOMMEND_PHP_VERSION, '<')) { $args = array( 'text' => sprintf(__('Your server is running PHP version %1$s but WordPress %2$s recommends at least %3$s.', 'fansub'), PHP_VERSION, $wp_version, FANSUB_RECOMMEND_PHP_VERSION), 'type' => 'warning', 'title' => __('Warning', 'fansub') ); fansub_admin_notice($args); set_transient($transient_name, 1, WEEK_IN_SECONDS); } } } } add_action('admin_notices', 'fansub_setup_warning_php_recommend_version'); function fansub_setup_login_redirect($redirect_to, $request, $user) { global $user; if(isset($user->roles) && is_array($user->roles)) { if(!in_array('administrator', $user->roles)) { $redirect_to = home_url('/'); } } return $redirect_to; } add_filter('login_redirect', 'fansub_setup_login_redirect', 10, 3); function fansub_setup_script_loader_tag($tag, $handle) { switch($handle) { case 'google-client': case 'recaptcha': $tag = str_replace(' src', ' defer async src', $tag); break; } return $tag; } add_filter('script_loader_tag', 'fansub_setup_script_loader_tag', 10, 2); function fansub_setup_admin_init() { $saved_domain = get_option('fansub_domain'); $current_domain = fansub_get_root_domain_name(get_bloginfo('url')); if($saved_domain != $current_domain) { update_option('fansub_domain', $current_domain); fansub_delete_transient_license_valid(); do_action('fansub_change_domain'); } } add_action('admin_init', 'fansub_setup_admin_init'); function fansub_setup_admin_body_class($class) { if(FANSUB_DEVELOPING && fansub_is_localhost()) { fansub_add_string_with_space_before($class, 'fansub-developing'); } return $class; } add_filter('admin_body_class', 'fansub_setup_admin_body_class');