/** * theme_js * * @version 1.1.5 **/ public static function theme_js() { ?> <script> <?php $config = []; $config['base'] = self::get_theme_js(); $config['paths'] = array('theme_js' => self::get_theme_js(), 'theme_css' => self::get_theme_css()); $config['vars'] = array('locale' => str_replace('-', '_', theme_cache::get_bloginfo('language')), 'theme_js' => self::get_theme_js(), 'theme_css' => self::get_theme_css(), 'theme_images' => self::get_theme_images_url(), 'process_url' => self::get_process_url()); $config['map'] = [['.css', '.css?v=' . theme_file_timestamp::get_timestamp()], ['.js', '.js?v=' . theme_file_timestamp::get_timestamp()]]; /** * seajs hook */ $config['paths'] = apply_filters('frontend_seajs_paths', $config['paths']); $config['alias'] = apply_filters('frontend_seajs_alias', []); $config['vars'] = apply_filters('frontend_seajs_vars', $config['vars']); $config['map'] = apply_filters('frontend_seajs_map', $config['map']); ?> seajs.config(<?php echo json_encode($config); ?> ); <?php unset($config); /** Hook 'frontend_seajs_use' */ do_action('frontend_seajs_use'); ?> </script> <?php }
public static function wp_title($title, $sep) { /** * check unread count */ if (theme_cache::is_user_logged_in()) { $unread_count = (int) self::get_count(array('type' => 'unread')); } else { $unread_count = 0; } if ($unread_count === 0) { if (!self::is_page()) { return $title; } if (self::get_tabs(get_query_var('tab'))) { $title = self::get_tabs(get_query_var('tab'))['text']; } } else { if (!self::is_page()) { return " ({$unread_count}) " . $title; } if (self::get_tabs(get_query_var('tab'))) { $title = " ({$unread_count}) " . self::get_tabs(get_query_var('tab'))['text']; } } return $title . $sep . theme_cache::get_bloginfo('name'); }
public static function wp_title($title, $sep) { if (!self::is_page()) { return $title; } if (self::get_tabs(get_query_var('tab'))) { $title = self::get_tabs(get_query_var('tab'))['text']; } return $title . $sep . theme_cache::get_bloginfo('name'); }
public static function wp_title($title, $sep) { if (!self::is_page()) { return $title; } $post = self::get_decode_post(); if ($post) { return theme_cache::get_the_title($post->ID) . $sep . ___('storage download') . $sep . theme_cache::get_bloginfo('name'); } }
public static function display($args = []) { global $post; $opt = self::get_options(); $img_url = theme_features::get_thumbnail_src($post->ID); $defaults = array('post_title_text' => theme_cache::get_the_title($post->ID), 'post_url' => theme_cache::get_permalink($post->ID), 'blog_name' => theme_cache::get_bloginfo('name'), 'blog_url' => theme_cache::home_url(), 'img_url' => esc_url($img_url), 'post_excerpt' => esc_attr(mb_substr(html_minify(strip_tags(get_the_excerpt())), 0, 120)), 'post_content' => esc_attr(mb_substr(html_minify(strip_tags(get_the_content())), 0, 120)), 'author' => theme_cache::get_the_author_meta('display_name', $post->post_author)); $output_keywords = array_merge($defaults, $args); $tpl_keywords = array('%post_title_text%', '%post_url%', '%blog_name%', '%blog_url%', '%img_url%', '%post_excerpt%', '%post_content%', '%author%'); $post_share_code = stripslashes(str_ireplace($tpl_keywords, $output_keywords, $opt['code'])); echo $post_share_code; }
public static function wp_title($title, $sep) { if (!self::is_page()) { return $title; } $tab_active = get_query_var('tab'); $tabs = self::get_tabs(); if (!empty($tab_active) && isset($tabs[$tab_active])) { $title = $tabs[$tab_active]['text']; } return $title . $sep . theme_cache::get_bloginfo('name'); }
/** * theme_js * * @version 1.1.5 **/ public static function theme_js() { $config = ['vars' => ['locale' => str_replace('-', '_', theme_cache::get_bloginfo('language')), 'theme_js' => self::get_theme_js(), 'theme_css' => self::get_theme_css(), 'theme_images' => self::get_theme_images_url(), 'process_url' => self::get_process_url(), 'timestamp' => theme_file_timestamp::get_timestamp()], 'lang' => ['M01' => ___('Loading, please wait...'), 'E01' => ___('Sorry, server is busy now, can not respond your request, please try again later.')]]; /** Hook 'frontend_js_config' */ ?> <script> window.THEME_CONFIG = <?php echo json_encode(apply_filters('frontend_js_config', (array) $config)); ?> ; </script> <?php }
public static function wp_title($title, $sep) { if (!is_author()) { return $title; } global $author; $tab_active = get_query_var('tab'); $author_display_name = theme_cache::get_the_author_meta('display_name', $author); $tabs = self::get_tabs(null, $author); if (!empty($tab_active) && isset($tabs[$tab_active])) { $title = $tabs[$tab_active]['text']; } else { $title = $tabs['profile']['text']; } $title = $author_display_name . $sep . $title; return $title . $sep . theme_cache::get_bloginfo('name'); }
public static function admin_header_image() { ?> <div id="banner" style="background-image:url(<?php echo get_header_image(); ?> )"> <?php if (display_header_text()) { ?> <h2><?php echo theme_cache::get_bloginfo('description'); ?> </h2> </div> <?php } ?> </div> <?php }
private static function send_email($parent_comment, $child_comment) { if (!is_email($parent_comment->comment_author_email)) { return false; } /** if parent email equal child email, do nothing */ if ($parent_comment->comment_author_email == $child_comment->comment_author_email) { return false; } $post_id = $parent_comment->comment_post_ID; $post_title = theme_cache::get_the_title($post_id); $post_url = theme_cache::get_permalink($post_id); $comment_url = esc_url(get_comment_link($child_comment)); $mail_title = sprintf(___('[%s] Your comment has a reply in "%s".'), theme_cache::get_bloginfo('name'), $post_title); ob_start(); ?> <p> <?php echo sprintf(___('Your comment: %s'), esc_html(get_comment_text($parent_comment->comment_ID))); ?> </p> <p> <?php echo sprintf(___('%s\'s reply: %s'), get_comment_author($child_comment->comment_ID), get_comment_text($child_comment->comment_ID)); ?> </p> <p> <?php echo sprintf(___('Views the comment: %s'), '<a href="' . $comment_url . '" target="_blank">' . $comment_url . '</a>'); ?> </p> <?php $mail_content = ob_get_contents(); ob_end_clean(); add_filter('wp_mail_content_type', __CLASS__ . '::set_html_content_type'); wp_mail($parent_comment->comment_author_email, $mail_title, $mail_content); remove_filter('wp_mail_content_type', __CLASS__ . '::set_html_content_type'); }
public static function get_footer_default() { return sprintf(___('© %1$s %2$s. Theme %3$s.'), '<a href="' . theme_cache::home_url() . '">' . theme_cache::get_bloginfo('name') . '</a>', date('Y'), '<a title="' . ___('Views theme homepage') . '" href="' . theme_features::get_theme_info('ThemeURI') . '" target="_blank" rel="nofollow">' . theme_features::get_theme_info('name') . '</a>'); }
/** * output */ public static function display_frontend() { global $post; $tpl_keywords = ['%post_title_text%', '%post_url%', '%blog_name%', '%blog_url%']; $output_keywords = [theme_cache::get_the_title($post->ID), theme_cache::get_permalink($post->ID), theme_cache::get_bloginfo('name'), theme_cache::home_url()]; $codes = str_replace($tpl_keywords, $output_keywords, self::get_options('code')); echo stripslashes($codes); }
/** * Process * * * @return * @version 1.0.0 * */ public static function process() { theme_features::check_referer(); if (!theme_cache::current_user_can('manage_options')) { die; } $output = []; $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : null; switch ($type) { case 'import': $file = isset($_FILES['file']) ? $_FILES['file'] : false; if (!$file || $file['error'] != 0) { die(theme_features::json_format(['status' => 'error', 'msg' => ___('Invalid file.')])); } $contents = json_decode(base64_decode(file_get_contents($file['tmp_name'])), true); if (is_array($contents) && !empty($contents)) { set_theme_mod('theme_options', $contents); die(theme_features::json_format(['status' => 'success', 'msg' => ___('Settings has been restored, refreshing page, please wait...')])); /** * invalid contents */ } else { die(theme_features::json_format(['status' => 'error', 'msg' => ___('Invalid file content.')])); } break; /** * export */ /** * export */ case 'export': $contents = base64_encode(json_encode(theme_options::get_options())); /** * write content to a tmp file */ $tmp = tmpfile(); $filepath = stream_get_meta_data($tmp)['uri']; file_put_contents($filepath, $contents); /** * output file download */ header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($filepath)); $download_fn = ___('Backup'); $download_fn .= '-' . theme_cache::get_bloginfo('name'); $download_fn .= '-' . theme_functions::$iden; $download_fn .= '-' . date('Ymd-His') . '.bk'; header('Content-Disposition: attachment; filename=" ' . $download_fn . '"'); readfile($filepath); die; } die(theme_features::json_format($output)); }
public static function list_history_signup($history) { if ($history['type'] !== 'signup') { return false; } ?> <li class="list-group-item"> <?php theme_custom_point::the_list_icon('user-plus'); ?> <?php self::the_point_sign(self::get_point_value('signup')); ?> <span class="history-text"> <?php echo sprintf(___('You registered %s.'), '<a href="' . theme_cache::home_url() . '">' . theme_cache::get_bloginfo('name') . '</a>'); ?> </span> <?php self::the_time($history); ?> </li> <?php }
public static function keywords_convert($content) { global $post; $meta = self::get_post_meta($post->ID); $source_url = isset($meta['reprint']['url']) ? esc_url($meta['reprint']['url']) : ___('unknow'); $source_author_name = isset($meta['reprint']['author']) ? esc_html($meta['reprint']['author']) : ___('unknow'); return str_replace(['%site_name%', '%site_url%', '%post_author_name%', '%post_author_url%', '%post_url%', '%source_url%', '%source_author_name%'], [theme_cache::get_bloginfo('name'), theme_cache::home_url(), theme_cache::get_the_author_meta('display_name', $post->post_author), theme_cache::get_author_posts_url($post->post_author), theme_cache::get_permalink($post->ID), $source_url, $source_author_name], $content); }
public static function process() { theme_features::check_nonce(); theme_features::check_referer(); $output = []; $type = isset($_REQUEST['type']) && is_string($_REQUEST['type']) ? $_REQUEST['type'] : null; $user = isset($_POST['user']) && is_array($_POST['user']) ? $_POST['user'] : false; $email = isset($user['email']) && is_email($user['email']) ? $user['email'] : null; $pwd = isset($user['pwd']) && is_string($user['pwd']) ? $user['pwd'] : null; switch ($type) { /** * login */ case 'login': $output = self::user_login(array('email' => $email, 'pwd' => $pwd, 'remember' => isset($user['remember']) ? true : false)); if ($output['status'] === 'success') { $output['msg'] = self::get_options('lang-login-success'); } else { die(theme_features::json_format($output)); } break; /** * register */ /** * register */ case 'register': /** * check can register */ if (!theme_cache::get_option('users_can_register')) { die(theme_features::json_format(['status' => 'error', 'code' => 'users_can_not_register', 'msg' => ___('Sorry, it is not the time, the site is temporarily closed registration.')])); } /** * nickname */ $user['nickname'] = isset($user['nickname']) && is_string($user['nickname']) ? filter_blank($user['nickname']) : false; if (mb_strlen($user['nickname']) < self::$min_display_name_length) { $output['status'] = 'error'; $output['code'] = 'invalid_nickname'; $output['msg'] = sprintf(___('Sorry, you nick name is invalid, at least %d characters in length, please try again.'), self::$min_display_name_length); die(theme_features::json_format($output)); } /** * pwd */ if (mb_strlen($pwd) < self::$min_pwd_length) { $output['status'] = 'error'; $output['code'] = 'invalid_pwd'; $output['msg'] = sprintf(___('Sorry, you password is invalid, at least %d characters in length, please try again.'), self::$min_pwd_length); die(theme_features::json_format($output)); } /** * email */ if (!$email) { $output['status'] = 'error'; $output['code'] = 'invalid_email'; $output['msg'] = ___('Sorry, your email address is invalid, please check it and try again.'); die(theme_features::json_format($output)); } /** * check display_name repeat */ $exists_users = array_filter(get_users(['meta_key' => 'display_name', 'meta_value' => $user['nickname']])); if (count($exists_users) >= 1) { $output['status'] = 'error'; $output['code'] = 'duplicate_display_name'; $output['msg'] = ___('Sorry, the nickname has been used, please change another one.'); die(theme_features::json_format($output)); } /****************** * PASS *****************/ $output = self::user_register(array('email' => $email, 'pwd' => $pwd, 'nickname' => $user['nickname'], 'remember' => true)); if ($output['status'] === 'success') { // $output['redirect'] = $output['msg'] = ___('Register successfully, page is refreshing, please wait...'); } break; /** * lost-password */ /** * lost-password */ case 'recover': if (!$email) { $output['status'] = 'error'; $output['code'] = 'invalid_email'; $output['msg'] = ___('Sorry, your email address is invalid, please check it and try again.'); die(theme_features::json_format($output)); } /** * check the email is exist */ $user_id = email_exists($email); if (!$user_id) { $output['status'] = 'error'; $output['code'] = 'email_not_exist'; $output['msg'] = ___('Sorry, the email does not exist.'); die(theme_features::json_format($output)); } /** * create and encode code */ $user = get_userdata($user_id); $encode_arr = array('user_id' => $user_id, 'user_email' => $user->user_email); $encode_str = json_encode($encode_arr); $encode = base64_encode(authcode($encode_str, 'encode', AUTH_KEY, 7200)); $callback_url = esc_url(add_query_arg(['token' => $encode], self::get_tabs('reset')['url'])); $content = ' <h3>' . sprintf(___('Dear %s!'), esc_html($user->display_name)) . '</h3> <p> ' . sprintf(___('You are receiving this email because you forgot your password. We already made an address for your account, you can access this address ( %s ) to log-in and change your password in 3 hours.'), '<a href="' . $callback_url . '" target="_blank">' . $callback_url . '</a>') . ' </p> <p>' . sprintf(___('-- From %s'), '<a href="' . theme_cache::home_url() . '" target="_blank">' . theme_cache::get_bloginfo('name') . '</a>') . '</p> '; $title = ___('You are applying to reset your password.'); $headers = ['Content-Type: text/html; charset=UTF-8']; $wp_mail = wp_mail($user->user_email, $title, $content, $headers); /** * check wp_mail is success or not */ if ($wp_mail === true) { update_user_meta($user_id, '_tmp_lost_pwd', 1); $output['status'] = 'success'; $output['msg'] = ___('Success, we sent an email that includes how to retrieve your password, please check it out in 3 hours.'); } else { $output['status'] = 'error'; $output['code'] = 'server_error'; $output['detial'] = $wp_mail['msg']; $output['msg'] = ___('Error, server can not send email, please contact the administrator.'); } break; /** * reset */ /** * reset */ case 'reset': if (!$user) { $output['status'] = 'error'; $output['code'] = 'invalid_param'; $output['msg'] = ___('Sorry, the param is invalid.'); die(theme_features::json_format($output)); } $token = isset($user['token']) && is_string($user['token']) ? $user['token'] : false; if (!$token) { $output['status'] = 'error'; $output['code'] = 'invaild_token'; $output['msg'] = ___('Sorry, the token is invaild.'); die(theme_features::json_format($output)); } /** pwd again */ $pwd_again = isset($user['pwd-again']) && is_string($user['pwd-again']) ? $user['pwd-again'] : null; if (empty($pwd) || $pwd !== $pwd_again) { $output['status'] = 'error'; $output['code'] = 'invalid_twice_pwd'; $output['msg'] = ___('Sorry, twice password is invaild, please try again.'); die(theme_features::json_format($output)); } /** decode token */ $token_decode = self::get_decode_token($token); if (!$token_decode) { $output['status'] = 'error'; $output['code'] = 'expired_token'; $output['msg'] = ___('Sorry, the token is expired.'); die(theme_features::json_format($output)); } $token_user_id = isset($token_decode['user_id']) && is_numeric($token_decode['user_id']) ? $token_decode['user_id'] : null; $token_user_email = isset($token_decode['user_email']) && is_email($token_decode['user_email']) ? $token_decode['user_email'] : null; /** check token email is match post email */ if (!$token_user_email) { $output['status'] = 'error'; $output['code'] = 'token_email_not_match'; $output['msg'] = ___('Sorry, the token email and you account email do not match.'); die(theme_features::json_format($output)); } /** check post email exists */ $user_id = (int) email_exists($token_user_email); if ($user_id != $token_decode['user_id']) { $output['status'] = 'error'; $output['code'] = 'email_not_exist'; $output['msg'] = ___('Sorry, your account email is not exist.'); die(theme_features::json_format($output)); } /** check user already apply to recover password */ if (!get_user_meta($user_id, '_tmp_recover_pwd', true)) { $output['status'] = 'error'; $output['code'] = 'not_apply_recover'; $output['msg'] = ___('Sorry, the user do not apply recover yet.'); } /** all ok, just set new password */ delete_user_meta($user_id, '_tmp_recover_pwd'); wp_set_password($pwd, $user_id); wp_set_current_user($user_id); wp_set_auth_cookie($user_id, true); $output['status'] = 'success'; $output['redirect'] = theme_cache::home_url(); $output['msg'] = ___('Congratulation, your account has been recovered! Password has been updated. Redirecting home page, please wait...'); break; default: $output['status'] = 'error'; $output['code'] = 'invalid_type'; $output['msg'] = ___('Invalid type.'); } die(theme_features::json_format($output)); }
public static function get_site_description($echo = true) { $descriptions = []; /** * in home page */ if (theme_cache::is_home()) { if (self::get_options('description') != '') { $descriptions[] = apply_filters('meta_description_home', self::get_options('description')); } else { $descriptions[] = apply_filters('meta_description_home', theme_cache::get_bloginfo('description')); } /** * other page */ } else { if (theme_cache::is_singular()) { global $post; if (!empty($post->post_excerpt)) { $descriptions[] = apply_filters('meta_description_singular', $post->post_excerpt); } else { $descriptions[] = apply_filters('meta_description_singular', mb_substr(strip_tags($post->post_content), 0, 120)); } } else { if (theme_cache::is_category()) { $category_description = category_description(); $descriptions[] = apply_filters('meta_description_category', $category_description); } else { if (theme_cache::is_tag()) { $tag_description = tag_description(); $descriptions[] = apply_filters('meta_description_tag', $tag_description); } } } } /** * add a hook */ $descriptions = array_filter(apply_filters('meta_descriptions', $descriptions)); if (!empty($descriptions)) { if ($echo !== false) { echo '<meta name="description" content="' . esc_attr(strip_tags(implode(',', $descriptions))) . '">'; } else { return $descriptions; } } }
<img src="<?php echo $header_img; ?> " alt="<?php echo theme_cache::get_bloginfo('name'); ?> " width="100" height="40"> <?php if (display_header_text()) { ?> <h1 hidden><?php echo theme_cache::get_bloginfo('name'); ?> </h1> <span hidden><?php echo theme_cache::get_bloginfo('description'); ?> </span> <?php } ?> </a> <?php } ?> <?php /** * menu-header */
public static function process($output) { if (!self::has_url()) { return; } $output = ' <!doctype html> <html lang="' . theme_cache::get_bloginfo('language') . '"> <head> <meta charset="' . theme_cache::get_bloginfo('charset') . '"> <title>' . esc_attr(theme_cache::get_bloginfo('name')) . ' - ' . ___('Maintenance Mode') . '</title> <style> body {font:20px/2 "Microsoft YaHei",Arial,"Liberation Sans",FreeSans,sans-serif;text-align: center; padding: 150px; color: #333;} article { display: block; text-align: left; width: 650px; margin: 0 auto; } a { color: #dc8100; text-decoration: none; } a:hover { color: #333; } .by{text-align:right;} </style> </head> <body> <article> <h1>' . ___('We’ll be back soon!') . '</h1> <p>' . sprintf(___('Sorry for the inconvenience but we’re performing some maintenance at the moment. If you need to you can always <a href="mailto:%s">contact us</a>, otherwise we’ll be back online shortly!'), theme_cache::get_bloginfo('admin_email')) . '</p> <p class="by">— ' . theme_cache::get_bloginfo('name') . '</p> </article> </body> </html> '; die($output); }
public static function backend_js() { if (!theme_cache::current_user_can('manage_options')) { return false; } if (!self::is_options_page()) { return false; } ?> <script id="seajsnode" src="<?php echo theme_features::get_theme_js('seajs/sea'); ?> "></script> <script> <?php $config = []; $config['base'] = theme_features::get_theme_js(); $config['paths'] = array('theme_js' => theme_features::get_theme_js(), 'theme_css' => theme_features::get_theme_css()); $config['vars'] = array('locale' => str_replace('-', '_', theme_cache::get_bloginfo('language')), 'theme_js' => theme_features::get_theme_js(), 'theme_css' => theme_features::get_theme_css(), 'process_url' => theme_features::get_process_url()); $config['map'] = array(['.css', '.css?v=' . theme_file_timestamp::get_timestamp()], ['.js', '.js?v=' . theme_file_timestamp::get_timestamp()]); /** * seajs hook */ $config['paths'] = apply_filters('backend_seajs_paths', $config['paths']); $config['alias'] = apply_filters('backend_seajs_alias', []); $config['vars'] = apply_filters('backend_seajs_vars', $config['vars']); $config['map'] = apply_filters('backend_seajs_map', $config['map']); ?> seajs.config(<?php echo json_encode($config); ?> ); <?php do_action('before_backend_tab_init'); ?> seajs.use('backend',function(backend_m){ backend_m.config.lang.M01 = '<?php echo ___('Saving your settings, please wait...'); ?> '; backend_m.init(); <?php do_action('after_backend_tab_init'); ?> }); </script> <?php }