From 23570d70042980d3e2d45c9711bd9a6ebbc2544a Mon Sep 17 00:00:00 2001 From: Mashiro Date: Sat, 23 Feb 2019 23:32:04 +0800 Subject: [PATCH] Fix comment reply for wp-5.2 & update to v3.1.6 --- functions.php | 6 ++++-- js/sakura-app.js | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/functions.php b/functions.php index 0ae568e..e90b0cc 100644 --- a/functions.php +++ b/functions.php @@ -7,7 +7,7 @@ * @package Sakura */ -define( 'SAKURA_VERSION', '3.1.5' ); +define( 'SAKURA_VERSION', '3.1.6' ); define( 'BUILD_VERSION', '1' ); define( 'JSDELIVR_VERSION', '3.6.7' ); @@ -194,6 +194,7 @@ function sakura_scripts() { $auto_height = akina_option('focus_height') ? 'fixed' : 'auto'; $code_lamp = 'close'; if(wp_is_mobile()) $auto_height = 'fixed'; //拦截移动端 + version_compare( $GLOBALS['wp_version'], '5.1', '>=' ) ? $reply_link_version = 'new' : $reply_link_version = 'old'; wp_localize_script( 'app', 'Poi' , array( 'pjax' => akina_option('poi_pjax'), 'movies' => $movies, @@ -201,7 +202,8 @@ function sakura_scripts() { 'codelamp' => $code_lamp, 'ajaxurl' => admin_url('admin-ajax.php'), 'order' => get_option('comment_order'), // ajax comments - 'formpostion' => 'bottom' // ajax comments 默认为bottom,如果你的表单在顶部则设置为top。 + 'formpostion' => 'bottom', // ajax comments 默认为bottom,如果你的表单在顶部则设置为top。 + 'reply_link_version' => $reply_link_version )); } add_action( 'wp_enqueue_scripts', 'sakura_scripts' ); diff --git a/js/sakura-app.js b/js/sakura-app.js index 74a1b57..3c85217 100644 --- a/js/sakura-app.js +++ b/js/sakura-app.js @@ -158,6 +158,14 @@ try { code_highlight_style(); } catch (e) {} +if (Poi.reply_link_version == 'new'){ + $('body').on('click','.comment-reply-link',function(){ + addComment.moveForm( "comment-"+$(this).attr('data-commentid'), $(this).attr('data-commentid'), "respond", "1" ); + console.log($(this).attr('data-commentid')); + return false; + }); +} + function attach_image() { $('#upload-img-file').change(function () { if (this.files.length > 10) {