diff --git a/assets/assets_load.php b/assets/assets_load.php index 0d16786..c191ad2 100644 --- a/assets/assets_load.php +++ b/assets/assets_load.php @@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) { exit; } function gdk_admin_script() { ?> - + '; - } - 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 '
'; - } - } + extract(shortcode_atts(array('wx' => null) , $atts)); + $pid = get_the_ID(); + add_post_meta($pid, '_pass_content', $content, true) or update_post_meta($pid, '_pass_content', $content); + if ( current_user_can( 'administrator' ) || gdk_is_weixin()) { return $content; }//admin show + return '
'; + } add_shortcode('secret', 'e_secret'); -// 支持文章和页面运行PHP代码 +// 支持文章和页面运行PHP代码id function php_include($attr) { $file = $attr['file']; $upload_dir = wp_upload_dir(); @@ -245,7 +235,6 @@ function gdk_insert_posts($atts, $content = null) { } add_shortcode('neilian', 'gdk_insert_posts'); - //给文章加内链短代码 function gdk_insert_temp($atts, $content = null) { extract(shortcode_atts(array( 'id' => '' ) , $atts)); @@ -255,7 +244,6 @@ function gdk_insert_temp($atts, $content = null) { } add_shortcode('temp', 'gdk_insert_temp'); - //快速插入列表 function git_list_shortcode_handler($atts, $content = '') { $lists = explode("\n", $content); @@ -270,7 +258,6 @@ function git_list_shortcode_handler($atts, $content = '') { } add_shortcode('list', 'git_list_shortcode_handler'); - //表格短代码 function table_shortcode_handler( $atts, $content='' ) { extract( shortcode_atts( ['width' => '100%'], $atts ) ); @@ -281,6 +268,7 @@ function table_shortcode_handler( $atts, $content='' ) { $output .= ''; //var_dump($ths); foreach($ths as $th){ + $th = trim($th); $output .= ''.$th.''; } $output .= ''; @@ -308,6 +296,70 @@ function table_shortcode_handler( $atts, $content='' ) { } add_shortcode( 'table', 'table_shortcode_handler' ); +add_shortcode('youku', function( $atts, $content='') { + extract( shortcode_atts( array( + 'width' => '510', + 'height' => '498' + ), $atts ) ); + + $width = (isset($_GET['width']) && intval($_GET['width']))?intval($_GET['width']):$width; // 用于 JSON 接口 + $height = round($width/4*3); + + if(preg_match('#http://v.youku.com/v_show/id_(.*?).html#i',$content,$matches)){ + return ''; + } +}); + + +add_shortcode('qqv', function($atts, $content='') { + extract( shortcode_atts( array( + 'width' => '510', + 'height' => '498' + ), $atts ) ); + + + $width = (isset($_GET['width']) && intval($_GET['width']))?intval($_GET['width']):$width; // 用于 JSON 接口 + $height = round($width/4*3); + + if(preg_match('#//v.qq.com/iframe/player.html\?vid=(.+)#i',$content,$matches)){ + //var_dump($matches);exit(); + return ''; + }elseif(preg_match('#//v.qq.com/iframe/preview.html\?vid=(.+)#i',$content,$matches)){ + //var_dump($matches);exit(); + return ''; + } +}); + +add_shortcode('tudou', function($atts, $content=''){ + extract( shortcode_atts( array( + 'width' => '480', + 'height' => '400' + ), $atts ) ); + + $width = (isset($_GET['width']) && intval($_GET['width']))?intval($_GET['width']):$width; // 用于 JSON 接口 + $height = round($width/4*3); + + if(preg_match('#http://www.tudou.com/programs/view/(.*?)#i',$content, $matches)){ + return ''; + } +}); + +add_shortcode('sohutv', function($atts, $content=''){ + extract( shortcode_atts( array( + 'width' => '510', + 'height' => '498' + ), $atts ) ); + + + $width = (isset($_GET['width']) && intval($_GET['width']))?intval($_GET['width']):$width; // 用于 JSON 接口 + $height = round($width/4*3); + + if(preg_match('#http://tv.sohu.com/upload/static/share/share_play.html\#(.+)#i',$content,$matches)){ + //var_dump($matches);exit(); + return ''; + } +}); + //WordPress 段代码按钮集合 function gdk_shortcode_list() { $wpshortcodes = [ diff --git a/gdk_route.php b/gdk_route.php index 2d41ce4..36d3ea1 100644 --- a/gdk_route.php +++ b/gdk_route.php @@ -9,12 +9,19 @@ Author URI: https://gitcafe.net/ Compatible:5.3.2 */ +//万能的开头 if ( ! defined( 'ABSPATH' ) ) { exit; } +//版本和兼容检查 function deactivate_myself() { deactivate_plugins( plugin_basename( __FILE__ ) ); - wp_die('启动失败,GDK插件需要运行在 PHP 7.2 版本及更高的环境下。'); + wp_die('启动失败,GDK插件不兼容Git主题且需要运行在 PHP 7.2 版本及更高的环境下。'); } + +if (defined('GIT_URL')) { + add_action('update_option_active_plugins', 'deactivate_myself'); +} + if (!version_compare(PHP_VERSION, '7.2', '>=')) { add_action('update_option_active_plugins', 'deactivate_myself'); }