TF0
[LT]?php if (!defined(‘ABSPATH’)) {die;} // Cannot access directly. /** * RiPro是一个优秀的主题,首页拖拽布局,高级筛选,自带会员生态系统,超全支付接口,你喜欢的样子我都有! * 正版唯一购买地址,全自动授权下载使用:https://ritheme.com/ * 作者唯一QQ:200933220 (油条) * 承蒙您对本主题的喜爱,我们愿向小三一样,做大哥的女人,做大哥网站中最想日的一个。 * 能理解使用盗版的人,但是不能接受传播盗版,本身主题没几个钱,主题自有支付体系和会员体系,盗版风险太高,鬼知道那些人乱动什么代码,无利不起早。 * 开发者不易,感谢支持,更好的更用心的等你来调教 */ /** * the theme */ function cao_body_classes($classes) { $dark_session = (!empty($_SESSION[‘is_ripro_dark’])) ? true : false; $this_dark = (_cao(‘is_ripro_dark’)) ? ‘ripro-dark’ : ”; if ($dark_session) { $this_dark = ‘ripro-dark’; } $classes[] = $this_dark; if (_cao(‘is_site_max_width’, ‘0’)) { $classes[] = ‘max_width’; } if (!is_singular()) { $classes[] = ‘hfeed’; } if (is_home()) { $classes[] = ‘modular-title-2’; } $navbar_style = _cao(‘navbar_style’, ‘sticky’); if (is_singular(‘post’) || is_page()) { $navbar_style = cao_compare_options($navbar_style, rwmb_meta(‘navbar_style’)); } $classes[] = ‘navbar-‘ . $navbar_style; if (_cao(‘navbar_full’, false) == true) { $classes[] = ‘navbar-full’; } if (_cao(‘navbar_slide’, false) == true) { $classes[] = ‘navbar-slide’; } if (cao_compare_options(_cao(‘navbar_hidden’, false), rwmb_meta(‘navbar_hidden’)) == true) { $classes[] = ‘navbar-hidden’; } if (_cao(‘disable_search’, false) == true) { $classes[] = ‘no-search’; } $classes[] = ‘sidebar-‘ . cao_sidebar(); if (cao_show_hero()) { $classes[] = ‘with-hero’; if (is_home()) { $classes[] = ‘hero-‘ . _cao(‘hero_home_style’, ‘none’); $classes[] = ‘hero-‘ . _cao(‘hero_home_content’, ‘image’); } elseif (is_singular(‘post’) || is_page()) { $classes[] = ‘hero-‘ . cao_compare_options(_cao(‘hero_single_style’, ‘none’), rwmb_meta(‘hero_single_style’)); $classes[] = get_post_format() ? ‘hero-‘ . get_post_format() : ‘hero-image’; } } $classes[] = ‘pagination-‘ . _cao(‘pagination’, ‘infinite_button’); if (get_previous_posts_link()) { $classes[] = ‘paged-previous’; } if (get_next_posts_link()) { $classes[] = ‘paged-next’; } if ((is_singular(‘post’) || is_page()) && rwmb_meta(‘cao_subheading’) != ”) { $classes[] = ‘with-subheading’; } if (!is_active_sidebar(‘off_canvas’)) { $classes[] = ‘no-off-canvas’; } return $classes; } add_filter(‘body_class’, ‘cao_body_classes’); /** * [cao_entry_header 文章标题 meta统一调用] * @Author Dadong2g * @DateTime 2021-01-12T10:30:58+0800 * @param array $options [description] * @return [type] [description] */ function cao_entry_header( $options = array() ) { $options = array_merge( array( ‘outside_loop’ => false, ‘container’ => ‘header’, ‘tag’ => ‘h2’, ‘link’ => true, ‘white’ => false, ‘author’ => false, ‘category’ => false, ‘date’ => false, ‘comment’ => false, ‘like’ => false, ‘edit’ => false ), $options ); $queried_object = get_queried_object(); $post_id = $options[‘outside_loop’] ? $queried_object->ID : get_the_ID(); $categories = get_the_category( $post_id ); ?> [LT]?php echo ‘[LT]’ . $options[‘container’] . ‘ class=”entry-header’ . esc_attr( $options[‘white’] ? ‘ white’ : ” ) . ‘”>’; ?> [LT]?php if ( $options[‘author’] || $options[‘category’] || $options[‘date’] || $options[‘comment’] || $options[‘like’] ) : ?> [LT]div class=”entry-meta”> [LT]?php if ( $options[‘author’] ) : $author_id = get_post_field( ‘post_author’, $post_id ); ?> [LT]span class=”meta-author”> [LT]a> [LT]?php echo get_avatar( get_the_author_meta( ’email’, $author_id ), ’40’, null, get_the_author_meta( ‘display_name’, $author_id ) ); echo get_the_author_meta( ‘display_name’, $author_id ); ?> [LT]/a> [LT]/span> [LT]?php endif; if ( $categories && $options[‘category’] ) : ?> [LT]span class=”meta-category”> [LT]?php foreach ( $categories as $key=>$category ) : if ($key == 3) {break;} ?> [LT]a[LT]?php echo _target_blank();?> href=”[LT]?php%20echo%20esc_url(%20get_category_link(%20$category->term_id%20)%20);%20?>” rel=”category”> [LT]i class=”dot”>[LT]/i>[LT]?php echo esc_html( $category->name ); ?> [LT]/a> [LT]?php endforeach; ?> [LT]/span> [LT]?php endif; if ( $options[‘date’] ) : ?> [LT]span class=”meta-date”> [LT]a[LT]?php echo _target_blank();?> href=”[LT]?php%20echo%20esc_url(%20get_the_permalink(%20$post_id%20)%20);%20?>”> [LT]time datetime=”[LT]?php echo esc_attr( get_the_date( ‘c’, $post_id ) ); ?>”> [LT]?php // echo esc_html( get_the_date( null, $post_id ) ); echo _timeago( get_gmt_from_date(get_the_time(‘Y-m-d G:i:s’)) ); ?> [LT]/time> [LT]/a> [LT]/span> [LT]?php endif; if ( $options[‘comment’] && ! post_password_required( $post_id ) && ( comments_open( $post_id ) || get_comments_number( $post_id ) ) ) : ?> [LT]span class=”meta-comment”> [LT]a[LT]?php echo _target_blank();?> href=”[LT]?php%20echo%20esc_url(%20get_the_permalink(%20$post_id%20)%20.%20’#comments’%20);%20?>”> [LT]?php printf( _n( ‘%s 评论’, ‘%s 评论’, esc_html( get_comments_number( $post_id ) ), ‘cao’ ), esc_html( number_format_i18n( get_comments_number( $post_id ) ) ) ); ?> [LT]/a> [LT]/span> [LT]?php endif; if ($options[‘edit’]) : ?> [LT]span class=”meta-edit”>[LT]?php edit_post_link(‘[编辑]’); ?>[LT]/span> [LT]?php endif;?> [LT]/div> [LT]?php endif; ?> [LT]?php if ( $options[‘link’] ) { echo ‘[LT]’ . $options[‘tag’] . ‘ class=”entry-title”>[LT]a’. _target_blank() .’ href=”‘%20.%20esc_url(%20get_permalink(%20$post_id%20)%20)%20.%20′” title=”‘.get_the_title( $post_id ).'” rel=”bookmark”>’ . get_the_title( $post_id ) . ‘[LT]/a>[LT]/’ . $options[‘tag’] . ‘>’; } else { echo ‘[LT]’ . $options[‘tag’] . ‘ class=”entry-title”>’ . get_the_title( $post_id ) . ‘[LT]/’ . $options[‘tag’] . ‘>’; } ?> [LT]?php echo ‘[LT]/’ . $options[‘container’] . ‘>’; } //缩略图比例 if (!function_exists(‘cao_thumbnail_ratio’)): function cao_thumbnail_ratio() { // $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id(), $image_size ); $thumbnail = _cao(‘thumbnail-px’); if ($thumbnail[‘width’] && $thumbnail[‘height’]) { return $thumbnail[‘height’] / $thumbnail[‘width’] * 100 . ‘%’; } else { return 200 / 300 * 100 . ‘%’; } } endif; // 获取图片高度 显示img标签 if (!function_exists(‘cao_entry_media’)): function cao_entry_media() { global $post; $ratio = cao_thumbnail_ratio(); ?> [LT]div class=”entry-media”> [LT]div class=”placeholder” style=”padding-bottom: [LT]?php echo esc_attr($ratio); ?>;”> [LT]a[LT]?php echo _target_blank(); ?> href=”[LT]?php%20echo%20esc_url(get_permalink());%20?>”> [LT]img class=”lazyload” src=”data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==” alt=”[LT]?php echo get_the_title(); ?>”> [LT]?php if (_cao(‘post_tim_rload’, ‘0’)) {?> [LT]div class=”cao-cover”>[LT]img src=”[LT]?php%20echo%20get_template_directory_uri();%20?>/assets/images/svg/rings.svg” width=”50″ height=”50px”>[LT]/div> [LT]?php }?> [LT]/a> [LT]/div> [LT]?php get_template_part(‘parts/entry-format’);?> [LT]/div> [LT]?php } endif; /** * [cao_sidebar 修复默认文章无侧边栏问题] * @Author Dadong2g * @DateTime 2021-01-12T09:51:31+0800 * @return [type] [description] */ function cao_sidebar() { if (is_singular(‘post’) || is_page()) { global $post; $sidebar = get_post_meta($post->ID, ‘post_style’, true); if ($sidebar == ‘no_sidebar’) { $sidebar = ‘none’; } else { $sidebar = ‘right’; } return $sidebar; } else { return ‘none’; } } function cao_column_classes($sidebar) { $content_column_class = ‘content-column col-lg-9’; $sidebar_column_class = ‘sidebar-column col-lg-3’; if ($sidebar == ‘none’) { $content_column_class = ‘col-lg-12’; } return array($content_column_class, $sidebar_column_class); } function cao_side_thumbnail() { if ((is_singular(‘post’) || is_page()) && has_post_thumbnail()) { $image_location = ‘mixed’; $featured_image = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), ‘full’); if ((($image_location == ‘mixed’ && $featured_image[2] > $featured_image[1]) || $image_location == ‘side’) && !get_post_format()) { return true; } } return false; } function cao_show_hero() { global $post; if (is_singular(‘post’) || is_page()) { $post_style = get_post_meta($post->ID, ‘post_hero’, true); if ($post_style) { return true; } } return false; } function cao_is_gif() { if (has_post_thumbnail()) { $featured_image = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), ‘full’); $featured_image = $featured_image[0]; $path_parts = pathinfo($featured_image); $extension = $path_parts[‘extension’]; return $extension == ‘gif’ ? true : false; } return false; } //文章图片赖加载,检测图片srcset后添加 lazyload 兼容处理 V6.3 if (!function_exists(‘cao_lazy_content_images’)): function cao_lazy_content_images($content) { global $post; $_the_content = $content; if (is_feed() || is_preview() || (function_exists(‘is_mobile’) && is_mobile())) { return $content; } if (false !== strpos($content, ‘data-original’)) { return $content; } return preg_replace_callback(‘/([LT]s*img[^>]+)(srcs*=s*”[^”]+”)([^>]+>)/i’, function ($matches) { $class_attr = ”; if (!preg_match(‘/classs*=s*”/i’, $matches[0])) { $class_attr = ‘class=”” ‘; } $replacement = $matches[1] . $class_attr . ‘src=”data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==” data-srcset’ . substr($matches[2], 3) . $matches[3]; $replacement = preg_replace(‘/classs*=s*”/i’, ‘class=”lazyload ‘, $replacement); $replacement .= ‘[LT]noscript>’ . $matches[0] . ‘[LT]/noscript>’; return $replacement; }, $content); } if (_cao(‘cao_lazy_content_images’, false)) { add_filter(‘the_content’, ‘cao_lazy_content_images’, 99); } endif; function cao_compare_options($global, $override) { if ($global == $override || $override == ”) { return $global; } else { return $override; } } if (!function_exists(‘rwmb_meta’)) { function rwmb_meta($key, $args = ”, $post_id = null) { return false; } } function _the_theme_name() { $current_theme = wp_get_theme(); return $current_theme->get(‘Name’); } function _the_theme_version() { $current_theme = wp_get_theme(); return $current_theme->get(‘Version’); } function _the_theme_aurl() { $current_theme = wp_get_theme(); return $current_theme->get(‘ThemeURI’); } function _get_description_max_length() { return 200; } function _get_tax_meta($id = 0, $field = ”) { $ops = get_option(“_taxonomy_meta_$id”); if (empty($ops)) { return ”; } if (empty($field)) { return $ops; } return isset($ops[$field]) ? $ops[$field] : ”; } //seo info function _get_delimiter() { return _cao(‘connector’,’-‘); } remove_action(‘wp_head’, ‘_wp_render_title_tag’, 1); function _title() { if (_cao(‘del_ripro_seo’, ‘0’)) { return wp_title(‘-‘, true, ‘right’); } global $paged, $post; $html = ”; $t = trim(wp_title(”, false)); if ($t) { $html .= $t . _get_delimiter(); } if (get_query_var(‘page’)) { $html .= ‘第’ . get_query_var(‘page’) . ‘页’ . _get_delimiter(); } $html .= get_bloginfo(‘name’); if (is_home()) { if ($paged > 1) { $html .= _get_delimiter() . ‘最新发布’; } elseif (get_option(‘blogdescription’)) { $html .= _get_delimiter() . get_option(‘blogdescription’); } } if (is_category()) { global $wp_query; $cat_ID = get_query_var(‘cat’); $seo_str = get_term_meta($cat_ID, ‘seo-title’, true); $cat_tit = ($seo_str) ? $seo_str : _get_tax_meta($cat_ID, ‘title’); if ($cat_tit) { $html = $cat_tit; } } elseif (is_tag()) { $tagName = single_tag_title(”, false); $tagObject = get_term_by(‘name’, $tagName, ‘post_tag’); $tagID = $tagObject->term_id; $seo_str = get_term_meta($tagID, ‘seo-title’, true); $html = ($seo_str) ? trim($seo_str) : $tagName; } elseif (is_singular() && get_post_meta($post->ID, ‘post_titie_s’, true)) { $html = get_post_meta($post->ID, ‘post_titie’, true); } if ($paged > 1) { $html .= _get_delimiter() . ‘第’ . $paged . ‘页’; } return $html; } function _the_head() { _keywords(); _description(); _post_views_record(); $css_str = _cao(‘web_css’); if ($css_str) { echo ‘[LT]style type=”text/css”>’ . $css_str . ‘[LT]/style>’; } } add_action(‘wp_head’, ‘_the_head’); /** * [_keywords SEO关键词优化] * @Author Dadong2g * @DateTime 2019-05-28T12:17:48+0800 * @return [type] [description] */ function _keywords() { if (_cao(‘del_ripro_seo’, ‘0’)) { return; } global $s, $post; $keywords = ”; if (is_singular()) { if (get_the_tags($post->ID)) { foreach (get_the_tags($post->ID) as $tag) { $keywords .= $tag->name . ‘,’; } } foreach (get_the_category($post->ID) as $category) { $keywords .= $category->cat_name . ‘, ‘; } if (get_post_meta($post->ID, ‘post_keywords_s’, true)) { $the = trim(get_post_meta($post->ID, ‘keywords’, true)); if ($the) { $keywords = $the; } } else { $keywords = substr_replace($keywords, ”, -2); } } elseif (is_home()) { $seo_opt = _cao(‘seo’); $keywords = (!empty($seo_opt[‘web_keywords’])) ? $seo_opt[‘web_keywords’] : ‘RiPro主题是最好的资源下载付费主题’; } elseif (is_tag()) { $tagName = single_tag_title(”, false); $tagObject = get_term_by(‘name’, $tagName, ‘post_tag’); $tagID = $tagObject->term_id; $seo_str = get_term_meta($tagID, ‘seo-keywords’, true); $keywords = ($seo_str) ? trim($seo_str) : $tagName; } elseif (is_category()) { global $wp_query; $cat_ID = get_query_var(‘cat’); $seo_str = get_term_meta($cat_ID, ‘seo-keywords’, true); $keywords = ($seo_str) ? trim($seo_str) : trim(wp_title(”, false)); } elseif (is_search()) { $keywords = esc_html($s, 1); } else { $keywords = trim(wp_title(”, false)); } if ($keywords) { echo “[LT]meta name=”keywords” content=”$keywords”>n”; } } /** * [_description SEO描述优化] * @Author Dadong2g * @DateTime 2019-05-28T12:18:02+0800 * @return [type] [description] */ function _description() { if (_cao(‘del_ripro_seo’, ‘0’)) { return; } global $s, $post; $description = ”; $blog_name = get_bloginfo(‘name’); if (is_singular()) { if (!empty($post->post_excerpt)) { $text = $post->post_excerpt; } else { $text = $post->post_content; } $description = trim(str_replace(array(“rn”, “r”, “n”, “ ”, ” “), ” “, str_replace(“””, “‘”, strip_tags($text)))); $description = substr_ext(strip_tags(strip_shortcodes($description)), 0, 140, ‘utf-8’, ‘…’); if (!($description)) { $description = $blog_name . “-” . trim(wp_title(”, false)); } if (get_post_meta($post->ID, ‘post_description_s’, true)) { $the = trim(get_post_meta($post->ID, ‘description’, true)); if ($the) { $description = $the; } } } elseif (is_home()) { $seo_opt = _cao(‘seo’); $description = (!empty($seo_opt[‘web_description’])) ? $seo_opt[‘web_description’] : ‘RiPro主题是最好的资源下载付费主题’; } elseif (is_tag()) { $tagName = single_tag_title(”, false); $tagObject = get_term_by(‘name’, $tagName, ‘post_tag’); $tagID = $tagObject->term_id; $seo_str = get_term_meta($tagID, ‘seo-description’, true); $description = ($seo_str) ? trim($seo_str) : trim(wp_title(”, false)); } elseif (is_category()) { global $wp_query; $cat_ID = get_query_var(‘cat’); $seo_str = get_term_meta($cat_ID, ‘seo-description’, true); $description = ($seo_str) ? trim($seo_str) : trim(wp_title(”, false)); } elseif (is_archive()) { $description = $blog_name . “-” . trim(wp_title(”, false)); } elseif (is_search()) { $description = $blog_name . “: ‘” . esc_html($s, 1) . “‘ ” . __(‘的搜索結果’, ‘haoui’); } elseif (is_tag()) { } else { $description = $blog_name . “‘” . trim(wp_title(”, false)) . “‘”; } $description = mb_substr($description, 0, _get_description_max_length(), ‘utf-8′); echo “[LT]meta name=”description” content=”$description”>n”; } // Open Graph function meta_og() { global $post; if (is_single()) { $img_src = _get_post_thumbnail_url($post); $excerpt = wp_trim_words(strip_shortcodes($post->post_content),120,’…’); $excerpt_more = ”; if (strlen($excerpt) > 155) { $excerpt = substr($excerpt, 0, 155); $excerpt_more = ‘ …’; } $excerpt = str_replace(‘”‘, ”, $excerpt); $excerpt = str_replace(“‘”, ”, $excerpt); $excerptwords = preg_split(‘/[nrt ]+/’, $excerpt, -1, PREG_SPLIT_NO_EMPTY); array_pop($excerptwords); $excerpt = implode(‘ ‘, $excerptwords) . $excerpt_more; ?> [LT]meta property=”og:title” content=”[LT]?php echo get_the_title(); ?>”> [LT]meta property=”og:description” content=”[LT]?php echo $excerpt; ?>”> [LT]meta property=”og:type” content=”article”> [LT]meta property=”og:url” content=”[LT]?php echo the_permalink(); ?>”> [LT]meta property=”og:site_name” content=”[LT]?php echo get_bloginfo(‘name’); ?>”> [LT]meta property=”og:image” content=”[LT]?php echo $img_src; ?>”> [LT]?php } } //是否开启meta_og协议 if (_cao(‘is_post_meta_og’)) { add_action(‘wp_head’, ‘meta_og’, 5); } /** * [cao_oauth_page_rewrite_rules OAuth登录处理页路由(/oauth)] * @Author Dadong2g * @DateTime 2019-05-26T00:04:32+0800 * @param [type] $wp_rewrite [description] * @return [type] [description] * (qq|weibo|weixin|…) */ function cao_oauth_page_rewrite_rules($wp_rewrite) { if ($ps = get_option(‘permalink_structure’)) { $new_rules[‘oauth/([A-Za-z]+)$’] = ‘index.php?oauth=$matches[1]’; $new_rules[‘oauth/([A-Za-z]+)/callback$’] = ‘index.php?oauth=$matches[1]&oauth_callback=1’; $new_rules[‘^go’] = ‘index.php?go=1’; $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; } } add_action(‘generate_rewrite_rules’, ‘cao_oauth_page_rewrite_rules’); /** * [cao_add_oauth_page_query_vars 自定义的Action页添加query_var白名单] * @Author Dadong2g * @DateTime 2019-05-26T00:06:55+0800 * @param [type] $public_query_vars [description] * @return [type] [description] */ function cao_add_oauth_page_query_vars($public_query_vars) { if (!is_admin()) { $public_query_vars[] = ‘oauth’; // 添加参数白名单oauth,代表是各种OAuth登录处理页 $public_query_vars[] = ‘oauth_callback’; // OAuth登录最后一步,整合WP账户,自定义用户名 $public_query_vars[] = ‘go’; //下载页跳转 $public_query_vars[] = ‘ref’; //下载页跳转 } return $public_query_vars; } add_filter(‘query_vars’, ‘cao_add_oauth_page_query_vars’); /** * [cao_oauth_page_template OAuth登录处理页模板] * @Author Dadong2g * @DateTime 2019-05-26T00:07:35+0800 * @return [type] [description] */ function cao_oauth_page_template() { $oauth = strtolower(get_query_var(‘oauth’)); //转换为小写 $oauth_callback = get_query_var(‘oauth_callback’); if ($oauth) { if (in_array($oauth, array(‘qq’, ‘qqagent’, ‘weixin’, ‘mpweixin’, ‘weixinagent’, ‘weibo’, ‘weiboagent’))): global $wp_query; $wp_query->is_home = false; $wp_query->is_page = true; //将该模板改为页面属性,而非首页 $template = $oauth_callback ? TEMPLATEPATH . ‘/inc/oauth/’ . $oauth . ‘/callback.php’ : TEMPLATEPATH . ‘/inc/oauth/’ . $oauth . ‘/login.php’; load_template($template); exit; else: // 非法路由处理 unset($oauth); return; endif; } $goto = strtolower(get_query_var(‘go’)); //转换为小写 if ($goto==1) { $template = TEMPLATEPATH . ‘/inc/go.php’; load_template($template);exit; } // 推荐ref $aff_id = get_query_var(‘ref’); if (!empty($aff_id)) { $_SESSION[‘cao_from_user_id’] = absint($aff_id); } } add_action(‘template_redirect’, ‘cao_oauth_page_template’, 5); /** * [getQrcode 生产二维码] * @Author Dadong2g * @DateTime 2020-09-29T19:22:06+0800 * @param [type] $url [description] * @return [type] [description] */ function getQrcode($url) { $api_url = get_template_directory_uri() . ‘/inc/plugins/qrcode.php?data=’; return $api_url . $url; } /* Gravatar 自定义头像 Hook */ function cao_avatar_hook($avatar, $id_or_email, $size, $default, $alt, $str = ‘img’) { // update_user_meta(1, ‘user_avatar_type’,’weixin’); $user = false; if (is_numeric($id_or_email)) { $id = (int) $id_or_email; $user = get_user_by(‘id’, $id); } elseif (is_object($id_or_email)) { if (!empty($id_or_email->user_id)) { $id = (int) $id_or_email->user_id; $user = get_user_by(‘id’, $id); } } else { $user = get_user_by(’email’, $id_or_email); } if ($user && is_object($user)) { $uid = $user->data->ID; $user_email = $user->data->user_email; $_qqAvatarAPI = ‘https://q.qlogo.cn/qqapp/’; $_gravatarAPI = ‘https://cn.gravatar.com/avatar/’; $_user_avatar_type = (get_user_meta($uid, ‘user_avatar_type’, true)); // 判断头像类型 switch ($_user_avatar_type) { case ‘gravatar’: $user_custom_avatar = get_user_meta($uid, ‘user_custom_avatar’, true); $avatar_url = ($user_custom_avatar) ? $user_custom_avatar : _the_theme_avatar(); break; case ‘qq’: $qqConfig = _cao(‘oauth_qq’); $avatar_url = $_qqAvatarAPI . $qqConfig[‘appid’] . ‘/’ . get_user_meta($uid, ‘open_qq_openid’, true) . ‘/100’; // $avatar_url = set_url_scheme(get_user_meta($uid, ‘open_qq_avatar’, true )); break; case ‘weibo’: $avatar_url = set_url_scheme(get_user_meta($uid, ‘open_weibo_avatar’, true)); break; case ‘weixin’: $avatar_url = set_url_scheme(get_user_meta($uid, ‘open_weixin_avatar’, true)); break; case ‘custom’: $avatar_url = set_url_scheme(get_user_meta($uid, ‘user_custom_avatar’, true)); default: $avatar_url = _the_theme_avatar(); } if ($str == ‘img’) { if (is_admin()) { $avatar = “[LT]img alt='{$alt}’ src='{$avatar_url}’ class=’avatar avatar-{$size} photo {$_user_avatar_type}’ height='{$size}’ width='{$size}’ />”; } else { $avatar = “[LT]img alt='{$alt}’ data-src='{$avatar_url}’ class=’lazyload avatar avatar-{$size} photo {$_user_avatar_type}’ height='{$size}’ width='{$size}’ />”; } } else { $avatar = $avatar_url; } } return $avatar; } add_filter(‘get_avatar’, ‘cao_avatar_hook’, 1, 5); function _the_theme_avatar() { return get_template_directory_uri() . ‘/assets/images/avatar/1.png’; } function _is_bind_openid($type = ‘qq’) { global $current_user; $uid = $current_user->ID; $_bind = (int) get_user_meta($uid, ‘open_’ . $type . ‘_bind’, true); return ($_bind) ? true : false; } //社交登录按钮 function _the_open_oauth_login_btn() { if (_cao(‘is_oauth_qq’) || _cao(‘is_oauth_weixin’) || _cao(‘is_oauth_mpweixin’) || _cao(‘is_oauth_weibo’)) { $oauthArr = array(‘qq’, ‘weixin’, ‘mpweixin’, ‘weibo’); echo ‘[LT]div class=”open-oauth text-center”>’; $rurl = home_url(add_query_arg(array())); foreach ($oauthArr as $value) { if (_cao(‘is_oauth_’ . $value)) { if ($value == ‘mpweixin’) { echo ‘[LT]a href=”‘%20.%20esc_url(home_url(‘/oauth/mpweixin’))%20.%20′” class=”go-mpweixin btn btn-‘ . $value . ‘”>[LT]i class=”fa fa-weixin”>[LT]/i>[LT]/a>’; } else { echo ‘[LT]a href=”‘%20.%20esc_url(home_url(‘/oauth/’%20.%20$value%20.%20’?rurl=’%20.%20$rurl))%20.%20′” class=”btn btn-‘ . $value . ‘”>[LT]i class=”fa fa-‘ . $value . ‘”>[LT]/i>[LT]/a>’; } } } echo ‘[LT]/div>’; echo ‘[LT]div class=”or-text”>[LT]span>or[LT]/span>[LT]/div>’; } } //获取用户社交登录按钮 function _the_open_oauth_btn() { $oauthArr = array(‘qq’, ‘weixin’, ‘mpweixin’, ‘weibo’); foreach ($oau
本篇文章来源于微信公众号:
