'http://' ) , $atts)); return '' . $content . ''; } add_shortcode("dl", "DownloadUrl"); //添加钮git function GithubUrl($atts, $content = null) { extract(shortcode_atts(array( "href" => 'http://' ) , $atts)); return '' . $content . ''; } add_shortcode('gt', 'GithubUrl'); //添加钮Demo function DemoUrl($atts, $content = null) { extract(shortcode_atts(array( "href" => 'http://' ) , $atts)); return '' . $content . ''; } add_shortcode('dm', 'DemoUrl'); //使用短代码添加回复后可见内容开始 function reply_to_read($atts, $content = null) { extract(shortcode_atts(array( "notice" => '

注意:本段内容须成功“回复本文”后“刷新本页”方可查看!

' ) , $atts)); $email = null; $user_ID = get_current_user_id(); if ($user_ID > 0) { $email = get_user_by('id', $user_ID)->user_email; //对博主直接显示内容 $admin_email = get_bloginfo('admin_email'); if ($email == $admin_email) { return $content; } } else if (isset($_COOKIE['comment_author_email_' . COOKIEHASH])) { $email = str_replace('%40', '@', $_COOKIE['comment_author_email_' . COOKIEHASH]); } else { return $notice; } if (empty($email)) { return $notice; } global $wpdb; $post_id = get_the_ID(); $query = "SELECT `comment_ID` FROM {$wpdb->comments} WHERE `comment_post_ID`={$post_id} and `comment_approved`='1' and `comment_author_email`='{$email}' LIMIT 1"; if ($wpdb->get_results($query)) { return do_shortcode($content); } else { return $notice; } } add_shortcode('reply', 'reply_to_read'); /*绿色提醒框*/ function toz($atts, $content = null) { return '
' . $content . '
'; } add_shortcode('v_notice', 'toz'); /*红色提醒框*/ function toa($atts, $content = null) { return '
' . $content . '
'; } add_shortcode('v_error', 'toa'); /*黄色提醒框*/ function toc($atts, $content = null) { return '
' . $content . '
'; } add_shortcode('v_warn', 'toc'); /*灰色提醒框*/ function tob($atts, $content = null) { return '
' . $content . '
'; } add_shortcode('v_tips', 'tob'); /*蓝色提醒框*/ function tod($atts, $content = null) { return '
' . $content . '
'; } add_shortcode('v_blue', 'tod'); /*蓝边文本框*/ function toe($atts, $content = null) { return '
' . $content . '
'; } add_shortcode('v_act', 'toe'); /*绿色按钮*/ function toi($atts, $content = null) { extract(shortcode_atts(array( "href" => 'http://' ) , $atts)); return '' . $content . ''; } add_shortcode('gb', 'toi'); /*蓝色按钮*/ function toj($atts, $content = null) { extract(shortcode_atts(array( "href" => 'http://' ) , $atts)); return '' . $content . ''; } add_shortcode('bb', 'toj'); /*黄色按钮*/ function tok($atts, $content = null) { extract(shortcode_atts(array( "href" => 'http://' ) , $atts)); return '' . $content . ''; } add_shortcode('yb', 'tok'); /*灵魂按钮*/ function tom($atts, $content = null) { extract(shortcode_atts(array( "href" => 'http://' ) , $atts)); return '' . $content . ''; } add_shortcode('lhb', 'tom'); /*添加视频按钮*/ function too($atts, $content = null) { extract(shortcode_atts(array( "play" => '0' ) , $atts)); if ($play == 0) { return ''; } if ($play == 1) { return ''; } } add_shortcode('video', 'too'); /*添加音频按钮*/ function tkk($atts, $content = null) { extract(shortcode_atts(array( "play" => '0' ) , $atts)); if ($play == 0) { return ''; } if ($play == 1) { return ''; } } add_shortcode('audio', 'tkk'); /*弹窗下载*/ function ton($atts, $content = null) { extract(shortcode_atts(array( "href" => 'http://', "filename" => '', "filesize" => '', "filedown" => '' ) , $atts)); return '文件下载'; } add_shortcode('fanctdl', 'ton'); //代码演示短代码 function git_demo($atts, $content = null) { return '' . $content . ''; } add_shortcode('demo', 'git_demo'); //下载单页短代码 function git_download($atts, $content = null) { return '' . $content . ''; } add_shortcode('download', 'git_download'); /* 短代码信息框 完毕*/ //为WordPress添加展开收缩功能 function xcollapse($atts, $content = null) { extract(shortcode_atts(array( "title" => "" ) , $atts)); return '
' . $title . '
'; } add_shortcode('collapse', 'xcollapse'); //简单的下载面板 function xdltable($atts, $content = null) { extract(shortcode_atts(array( "file" => "", "size" => "" ) , $atts)); return '

文件下载

  文件名称:' . $file . '  文件大小:' . $size . '
  下载声明:' . git_get_option('git_dltable_b') . '
  下载地址:' . $content . '
'; } add_shortcode('dltable', 'xdltable'); //网易云音乐 function music163($atts, $content = null) { extract(shortcode_atts(array( "play" => "1" ) , $atts)); return ''; } add_shortcode('netmusic', 'music163'); //登录可见 function login_to_read($atts, $content = null) { $logina = '登录'; extract(shortcode_atts(array( "notice" => '

注意:本段内容须“' . $logina . '”后方可查看!

' ) , $atts)); if (is_user_logged_in() && !is_null($content) && !is_feed()) { return '
隐藏的内容 ' . $content . '
'; } return $notice; } add_shortcode('vip', 'login_to_read'); // 部分内容输入密码可见 function e_secret($atts, $content = null) { if (!isset($_COOKIE['weixin_fensi']) && isset($_POST['e_secret_key']) && $_POST['e_secret_key'] == git_get_option('git_mp_code')) { setcookie('weixin_fensi', 10086, time() + 2592000, COOKIEPATH, COOKIE_DOMAIN, false); //30天时间 return ''; } extract(shortcode_atts(array( 'wx' => null ) , $atts)); if ($_COOKIE['weixin_fensi'] == '10086' || strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false) { return '
隐藏的内容 ' . $content . '
'; } else { if ($wx == '1') { return '
' . git_get_option('git_mp_name') . '
验证码:
' . git_get_option('git_mp_tips') . '
'; } else { return '
'; } } } add_shortcode('secret', 'e_secret'); // 支持文章和页面运行PHP代码 function php_include($attr) { $file = $attr['file']; $upload_dir = wp_upload_dir(); $folder = $upload_dir['basedir'] . '/php-content' . "/{$file}.php"; ob_start(); include $folder; return ob_get_clean(); } add_shortcode('phpcode', 'php_include'); //给文章加内链短代码 function git_insert_posts($atts, $content = null) { extract(shortcode_atts(array( 'ids' => '' ) , $atts)); global $post; $content = ''; $postids = explode(',', $ids); $inset_posts = get_posts(array( 'post__in' => $postids )); foreach ($inset_posts as $key => $post) { setup_postdata($post); $content.= '
'; $content.= get_the_title(); $content.= '

'; $content.= get_the_excerpt(); $content.= '

'; } wp_reset_postdata(); return $content; } add_shortcode('neilian', 'git_insert_posts'); //给文章加外链短代码 function git_external_posts($atts, $content = null) { $result = curl_post($content) ['data']; $title = preg_match('!(.*?)!i', $result, $matches) ? $matches[1] : '我是标题我是标题我是标题我是标题我是标题我是标题我是标题'; $tags = get_meta_tags($content); $description = $tags['description']; $imgpath = GIT_URL . '/assets/img/pic/' . mt_rand(1, 12) . '.jpg'; global $post; $contents = ''; setup_postdata($post); $contents.= '
'; $contents.= $title; $contents.= '

'; $contents.= $description; $contents.= '

'; wp_reset_postdata(); return $contents; } if (function_exists('curl_init')) { add_shortcode('wailian', 'git_external_posts'); } //快速插入列表 function git_list_shortcode_handler($atts, $content = '') { $lists = explode("\n", $content); $ouput = ''; foreach ($lists as $li) { if (trim($li) != '') { $output.= "
  • {$li}
  • "; } } $output = "\n"; return $output; } add_shortcode('list', 'git_list_shortcode_handler'); //加载密码可见的样式 function secret_css() { global $post; if (is_singular() && has_shortcode($post->post_content, 'secret')) { echo ''; } } add_action('wp_head', 'secret_css');