筛选标签:
roles[0] == get_option('default_role')) { wp_redirect( home_url().'/user' ); exit; exit(); } } /* ================================================== 调用ssl 头像链接 ================================================== */ function get_ssl_avatar($avatar) { if (is_admin()) { $avatar = preg_replace('/.*\/avatar\/(.*)\?s=([\d]+)&.*/','',$avatar, 0); } else { $avatar = preg_replace('/.*\/avatar\/(.*)\?s=([\d]+)&.*/','',$avatar); } return $avatar; } if (cs_get_option('i_function_avatar_ssl_switcher')) { add_filter('get_avatar', 'get_ssl_avatar'); } register_nav_menu( 'page', __( '会员中心菜单', 'page' ) ); //修改中文名称图片转为时间格式 function wpyou_rename_upload_file($filename) { $info = pathinfo($filename); $ext = empty($info['extension']) ? '' : '.' . $info['extension']; $name = basename($filename, $ext); return substr(md5($name), 0, 15) . $ext; // 15 为要截取的文件名长度 } add_filter('sanitize_file_name', 'wpyou_rename_upload_file', 10); //新标签打开顶部网站链接 function googlo_admin_site_ctrlenter() { echo ''; }; add_action('admin_footer', 'googlo_admin_site_ctrlenter'); /* 删除文章时删除图片附件 /* ------------------------ */ function delete_post_and_attachments($post_ID) { global $wpdb; //删除特色图片 $thumbnails = $wpdb->get_results( "SELECT * FROM $wpdb->postmeta WHERE meta_key = '_thumbnail_id' AND post_id = $post_ID" ); foreach ( $thumbnails as $thumbnail ) { wp_delete_attachment( $thumbnail->meta_value, true ); } //删除图片附件 $attachments = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE post_parent = $post_ID AND post_type = 'attachment'" ); foreach ( $attachments as $attachment ) { wp_delete_attachment( $attachment->ID, true ); } $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key = '_thumbnail_id' AND post_id = $post_ID" ); } add_action('before_delete_post', 'delete_post_and_attachments'); //禁止WordPress头部加载s.w.org function remove_dns_prefetch( $hints, $relation_type ) { if ( 'dns-prefetch' === $relation_type ) { return array_diff( wp_dependencies_unique_hosts(), $hints ); } return $hints; } add_filter( 'wp_resource_hints', 'remove_dns_prefetch', 10, 2 ); /* ================================================== modify default gravatar ================================================== */ //add_filter( 'avatar_defaults', 'defaultGravatar' ); //function defaultGravatar ($avatar_defaults) { // if (!cs_get_option('i_function_avatar_location')) { // $myAvatar = get_template_directory_uri()."/assets/images/avatar.png"; // } else { // $myAvatar = cs_get_option('i_function_avatar_location'); // } // $avatar_defaults[$myAvatar] = "本地头像,可以在主题配置中设置"; // return $avatar_defaults; //} /* ================================================== img https ================================================== */ function img2Https($content){ if( is_ssl() ){ $urlArray = explode(":", site_url()); $content = str_replace('http:'.$urlArray[1].'/wp-content/uploads', 'https:'.$urlArray[1].'/wp-content/uploads', $content); } return $content; } add_filter('the_content', 'img2Https'); /* ================================================== 自定义评论 ================================================== */ function listComments($comment, $args, $depth) { $GLOBALS['comment'] = $comment; ?>
  • id="li-comment-">
    comment_author_email, $size='48',$default='' ); ?>
    %s'), get_comment_author_link()) ?> comment_approved == '0') : ?>
    $depth, 'max_depth' => $args['max_depth']))) ?>
    get_results (" SELECT DISTINCT terms2.term_id as tag_id, terms2.name as tag_name FROM $wpdb->posts as p1 LEFT JOIN $wpdb->term_relationships as r1 ON p1.ID = r1.object_ID LEFT JOIN $wpdb->term_taxonomy as t1 ON r1.term_taxonomy_id = t1.term_taxonomy_id LEFT JOIN $wpdb->terms as terms1 ON t1.term_id = terms1.term_id, $wpdb->posts as p2 LEFT JOIN $wpdb->term_relationships as r2 ON p2.ID = r2.object_ID LEFT JOIN $wpdb->term_taxonomy as t2 ON r2.term_taxonomy_id = t2.term_taxonomy_id LEFT JOIN $wpdb->terms as terms2 ON t2.term_id = terms2.term_id WHERE t1.taxonomy = 'category' AND p1.post_status = 'publish' AND terms1.term_id IN (".$args['categories'].") AND t2.taxonomy = 'post_tag' AND p2.post_status = 'publish' AND p1.ID = p2.ID ORDER by tag_name "); $count = 0; if($tags) { foreach ($tags as $tag) { $mytag[$count] = get_term_by('id', $tag->tag_id, 'post_tag'); $count++; } } else { $mytag = NULL; } return $mytag; } /* 获取当前页面url /* ---------------- */ function tin_get_current_page_url(){ $ssl = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? true:false; $sp = strtolower($_SERVER['SERVER_PROTOCOL']); $protocol = substr($sp, 0, strpos($sp, '/')) . (($ssl) ? 's' : ''); $port = $_SERVER['SERVER_PORT']; $port = ((!$ssl && $port=='80') || ($ssl && $port=='443')) ? '' : ':'.$port; $host = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']; return $protocol . '://' . $host . $port . $_SERVER['REQUEST_URI']; } /* AJAX登录变量 /* -------------- */ function ajax_sign_object(){ $object = array(); $object[redirecturl] = tin_get_current_page_url(); $object[ajaxurl] = admin_url( '/admin-ajax.php' ); $object[loadingmessage] = '正在请求中,请稍等...'; $object_json = json_encode($object); return $object_json; } /* AJAX登录验证 /* ------------- */ function mobantu_login(){ $result = 0; $creds = array(); $creds['user_login'] = $_POST['log']; $creds['user_password'] = $_POST['pwd']; $creds['remember'] = ( isset( $_POST['remember'] ) ) ? $_POST['remember'] : false; $login = wp_signon($creds, false); if ( ! is_wp_error( $login ) ){ $result = 1; } echo $result; wp_die(); } add_action( 'wp_ajax_mobantu_login', 'mobantu_login' ); add_action( 'wp_ajax_nopriv_mobantu_login', 'mobantu_login' ); /* AJAX注册验证 /* ------------- */ function mobantu_register(){ session_start(); $result = 0; $user_login = sanitize_user($_POST['user_register']); $user_pass = $_POST['password']; $user_email = apply_filters( 'user_registration_email', $_POST['user_email'] ); $captche2 = $_POST['captcha']; $errors = new WP_Error(); if($_SESSION['MBT_modown_captcha'] != $captche2){ die('验证码不正确'.$captche2." / ".$_SESSION['MBT_modown_captcha']); }elseif( ! validate_username( $user_login ) ){ die('请输入一个有效用户名'); }elseif(username_exists( $user_login )){ die('此用户名已被注册'); }elseif(email_exists( $user_email )){ die('此邮箱已被注册'); } do_action( 'register_post', $user_login, $user_email, $errors ); $errors = apply_filters( 'registration_errors', $errors, $user_login, $user_email ); if ( $errors->get_error_code() ){ $result = 0; } else { $user_id = wp_create_user( $user_login, $user_pass, $user_email ); if ( ! $user_id ) { $errors->add( 'registerfail', sprintf( __( '无法注册,请联系管理员','tinection' ), get_option( 'admin_email' ) ) ); die('无法注册,请联系管理员'); } else{ update_user_option( $user_id, 'default_password_nag', true, true ); //Set up the Password change nag. wp_new_user_notification( $user_id, $user_pass ); $result = 1; //自动登录 wp_set_current_user($user_id); wp_set_auth_cookie($user_id); } } echo $result; wp_die(); } add_action( 'wp_ajax_mobantu_register', 'mobantu_register' ); add_action( 'wp_ajax_nopriv_mobantu_register', 'mobantu_register' ); function MThemes_thumbnail_custom($width=180, $height=120, $postid, $echo=1){ $options = get_option('monkey-options'); $dir = get_bloginfo('template_directory'); $post_img = ''; if( has_post_thumbnail($postid) ){ $timthumb_src = wp_get_attachment_image_src(get_post_thumbnail_id($postid),'full'); $src = $timthumb_src[0]; if($options['timthumb']) $post_img_src = "$src"; else $post_img_src = "$dir/timthumb.php?src=$src&w=$width&h=$height&zc=1&q=100"; }else{ ob_start(); ob_end_clean(); $output = preg_match_all('/\/is',get_post($postid)->post_content,$matches ,PREG_SET_ORDER); $cnt = count( $matches ); if($cnt>0){ $src = $matches[0][1]; }else{ // thumb $thumbs = $options['thumbs']; $cnt = count($thumbs); if($cnt >0){ $index = rand(0, $cnt-1); $src = $thumbs[$index]; }else{ $src = "{$dir}/img/thumbnail.png"; } } if($options['timthumb']) $post_img_src = "$src"; else $post_img_src = "$dir/timthumb.php?src=$src&w=$width&h=$height&zc=1&q=100"; } $post_img =$post_img_src; return $post_img; } function mbthemes_strip_tags($content){ if($content){ $content = preg_replace("/\[.*?\].*?\[\/.*?\]/is", "", $content); } return strip_tags($content); } function MBT_monkey_page_pagination($paged,$max_page) { $p = 2; if ( $max_page == 1 || $max_page < 1) return; echo '
      '; if ( empty( $paged ) ) $paged = 1; echo '
    • '.get_previous_posts_link().'
    • '; if ( $paged > $p + 1 ) p_link( 1 ); if ( $paged > $p + 2 ) echo "
    • ···
    • "; for( $i = $paged - $p; $i <= $paged + $p; $i++ ) { if ( $i > 0 && $i <= $max_page ) $i == $paged ? print "
    • {$i}
    • " : p_link( $i ); } if ( $paged < $max_page - $p - 1 ) echo "
    • ···
    • "; if( $paged < $max_page - $p ) p_link($max_page); echo '
    • '.get_next_posts_link().'
    • '; echo '
    '; } function p_link( $i) { echo "
  • {$i}
  • "; } function get_url_contents($url) { $ch = curl_init (); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, TRUE ); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt ( $ch, CURLOPT_URL, $url ); $result = curl_exec ( $ch ); curl_close ( $ch ); return $result; } function MBThemes_avatar($id=0,$size='50',$class=''){ $photo = get_user_meta($id, 'photo', true); if($photo) echo ''; else echo get_avatar($id,$size); } function MBThemes_page($template) { global $wpdb; $page_id = $wpdb->get_var($wpdb->prepare("SELECT `post_id` FROM `$wpdb->postmeta`, `$wpdb->posts` WHERE `post_id` = `ID` AND `post_status` = 'publish' AND `meta_key` = '_wp_page_template' AND `meta_value` = %s LIMIT 1;", $template)); return $page_id; } function curPageURL(){ $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") { $pageURL .= "s"; } $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { //$pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; } else{ $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; } return $pageURL; } function DGAThemes_page($template) { global $wpdb; $page_id = $wpdb->get_var($wpdb->prepare("SELECT `post_id` FROM `$wpdb->postmeta`, `$wpdb->posts` WHERE `post_id` = `ID` AND `post_status` = 'publish' AND `meta_key` = '_wp_page_template' AND `meta_value` = %s LIMIT 1;", $template)); return $page_id; } //替换“用户名”为“用户名 / 邮箱”https://www.ludou.org/tag/wordpress function username_or_email_login() { if ( 'wp-login.php' != basename( $_SERVER['SCRIPT_NAME'] ) ) return; ?>咖啡图案床上用品店面抱枕插图枕头标牌字体样机样机元素矩形立面纹理长方形饰品
    更多
    没有账号? 忘记密码?

    社交账号快速登录