សព្វថ្ងៃខ្ញុំអាចដាក់ Rich Text Editor លើ Comment form ដោយប្រើ Plugin តែបើគិតមើលទៅវាដូចជាមិនចំណេញសោះជាមួយ WordPress ដែលមាន Editor ស្រាប់។
តើមានវិធីប្រើអ្វីដែលមានស្រាប់របស់ WP ធ្វើជា Text Editor ដ៏ស្អាតសំរាប់ Theme ខ្ញុំទេ?
សព្វថ្ងៃខ្ញុំអាចដាក់ Rich Text Editor លើ Comment form ដោយប្រើ Plugin តែបើគិតមើលទៅវាដូចជាមិនចំណេញសោះជាមួយ WordPress ដែលមាន Editor ស្រាប់។
តើមានវិធីប្រើអ្វីដែលមានស្រាប់របស់ WP ធ្វើជា Text Editor ដ៏ស្អាតសំរាប់ Theme ខ្ញុំទេ?
One reply on “WordPress: តើអាចប្រើ Rich Text Editor លើ WP Comment ដោយមិនប្រើ Plugin បានទេ?”
អរគុណចំពោះសំនួរនេះ វាជួយអោយខ្ញុំព្យាយាមស្វែងរកចម្លើយ ទីបំផុតគឺអាចរកឃើញហើយ សំរាប់ប្រើក្នុង WP Comment។
ដាក់កូដខាងក្រោមក្នុង function.php របស់ Theme៖
add_filter('comment_form_defaults','custom_comment_form_defaults');functioncustom_comment_form_defaults($args) {if( is_user_logged_in() ) {$mce_plugins='inlinepopups, fullscreen, wordpress, wplink, wpdialogs';}else{$mce_plugins='fullscreen, wordpress';}ob_start();wp_editor('','comment',array('media_buttons'=> true,'teeny'=> true,'textarea_rows'=>'7','tinymce'=>array('plugins'=>$mce_plugins)) );$args['comment_field'] = ob_get_clean();return$args;}បានឃើញកូដនេះក្នុងអត្ថបទនេះ (Part 2):
Updated
add_action( 'wp_enqueue_scripts', 'osify_scripts' ); function osify_scripts() { wp_enqueue_script('jquery'); } add_filter( 'comment_reply_link', 'osify_comment_reply_link' ); function osify_comment_reply_link($link) { return str_replace( 'onclick=', 'data-onclick=', $link ); } add_action( 'wp_head', 'osify_wp_head' ); function osify_wp_head() { ?> <script type="text/javascript"> jQuery(function($){ $('.comment-reply-link').click(function(e){ e.preventDefault(); var args = $(this).data('onclick'); args = args.replace(/.*\(|\)/gi, '').replace(/\"|\s+/g, ''); args = args.split(','); tinymce.EditorManager.execCommand('mceRemoveControl', true, 'comment'); addComment.moveForm.apply( addComment, args ); tinymce.EditorManager.execCommand('mceAddControl', true, 'comment'); }); }); </script> <?php }