• Share Tốt – Chia Sẻ Kinh Nghiệm Tồi Tệ
Share Tốt
Liên hệ quảng cáo 0965 21 8696
  • Trang chủ
  • WordPress
  • Share Code
  • Dịch vụ Web
  • 365 Ngày 24/7
  • Thủ Thuật
  • Lập Trình PHP
  • News CNTT
  • SEO Google
No Result
View All Result
  • Trang chủ
  • WordPress
  • Share Code
  • Dịch vụ Web
  • 365 Ngày 24/7
  • Thủ Thuật
  • Lập Trình PHP
  • News CNTT
  • SEO Google
No Result
View All Result
Share Tốt
No Result
View All Result

Trang chủ Wordpress

Code thêm nút đóng mã nguồn php – WordPress

0
SHARES
23
VIEWS
Share on FacebookShare on Twitter

Bước 1 :

Cài plugin : TinyMCE Advanced

Tạo folder trong đường dẫn vào plugin : /ibegins.net/public_html/wp-content/plugins

Đặt tên cho folder đó ví dụ : button-php

Bước 2 :

Tạo tiếp một file trong folder trên sẽ thành : /ibegins.net/public_html/wp-content/plugins/button-php/

Đặt tên dưới dạng file : button-php.php : /ibegins.net/public_html/wp-content/plugins/button-php/button-php.php

Gắn code sau vào file button-php.php :

/*
Plugin Name: Visual Editor Buttons PHP
Plugin URI: http://ibegins.net/
Description: Adds a button to visual editor[php_][/_php].
Author: Văn Tưởng
 */
// init process for registering our button
add_action('init', 'ibegins_shortcode_button_init');
function ibegins_shortcode_button_init() {

//Abort early if the user will never see TinyMCE
if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') && get_user_option('rich_editing') == 'true')
return;

//Add a callback to regiser our tinymce plugin
add_filter("mce_external_plugins", "ibegins_register_tinymce_plugin");

// Add a callback to add our button to the TinyMCE toolbar
add_filter('mce_buttons', 'ibegins_add_tinymce_button');
}

//This callback registers our plug-in
function ibegins_register_tinymce_plugin($plugin_array) {
$plugin_array['ibegins_button'] = plugin_dir_url( __FILE__ ) . 'button-js.js';
return $plugin_array;
}

//This callback adds our button to the toolbar
function ibegins_add_tinymce_button($buttons) {
//Add the button ID to the $button array
$buttons[] = "ibegins_button";
return $buttons;
}

Bước 3 :

Tạo tiếp một file JS trong folder button-php :  /ibegins.net/public_html/wp-content/plugins/button-php/

Đặt tên file JS đó button-js.js : /ibegins.net/public_html/wp-content/plugins/button-php/button-js.js

Gắn code sau vào file button-js.js :

jQuery(document).ready(function($) {

tinymce.create('tinymce.plugins.ibegins_plugin', {
init : function(ed, url) {
// Register command for when button is clicked
ed.addCommand('ibegins_insert_shortcode', function() {
selected = tinyMCE.activeEditor.selection.getContent();

if( selected ){
//If text is selected when button is clicked
//Wrap shortcode around it.
content = '
[php_]'+selected+'[/_php]
';
}else{
content = '
[php_]';
                    }

                    tinymce.execCommand('mceInsertContent', false, content);
                });

            // Register buttons - trigger above command when clicked
            ed.addButton('ibegins_button', {title : 'Insert [php]

‘, cmd : ‘ibegins_insert_shortcode’, image: url + ‘/HTML5.png’ });
},
});

// Register our TinyMCE plugin
// first parameter is the button ID1
// second parameter must match the first parameter of the tinymce.create() function above
tinymce.PluginManager.add(‘ibegins_button’, tinymce.plugins.ibegins_plugin);
});

[/php]

Bước 4 :

Tải file ảnh và thay đường link ảnh trong button-js.js trong folder button-php

Bước 5 :

Vào quản lý admin website và kích hoạt plugin đó lên.

 

Chú ý : bỏ dấu gạch _ ở chữ php.

Chúc bạn thành công.

 

 

Đám mây từ khóa

365 Ngày 24/7 Design Dịch vụ Web Lập Trình PHP News CNTT SEO Google Share Code Thủ Thuật Wordpress
ADVERTISEMENT

Tin tức gần đây

Thiết kế website – dịch vụ tiềm năng thời công nghệ

Thiết kế website – dịch vụ tiềm năng thời công nghệ

20 Tháng Tư, 2022
Code fake tối ưu điểm Google Speed cho WordPress

Code fake tối ưu điểm Google Speed nodejs

22 Tháng Mười, 2021
Top 5 công ty thiết kế website chuyên nghiệp uy tín TPHCM

#1 TOP Công ty thiết kế App tại Hà Nội

17 Tháng Một, 2022
Thêm mục đăng bài viết vào Danh mục WooCommerce WordPress

Thêm mục đăng bài viết vào Danh mục WooCommerce WordPress

4 Tháng Chín, 2021

Bài viết liên quan

Thêm mục đăng bài viết vào Danh mục WooCommerce WordPress
Wordpress

Thêm mục đăng bài viết vào Danh mục WooCommerce WordPress

4 Tháng Chín, 2021
Plugins lấy thông tin Contact Form 7 sang Google Sheet
Wordpress

Plugins lấy thông tin Contact Form 7 sang Google Sheet

16 Tháng Chín, 2021
Code fake tối ưu điểm Google Speed cho WordPress
Wordpress

Code fake tối ưu điểm Google Speed cho WordPress

29 Tháng Sáu, 2021
Gắn nút Hotline – Zalo – Facebook cho Website năm 2020
Share Code

Gắn nút Hotline – Zalo – Facebook cho Website năm 2020

14 Tháng Mười Một, 2020
Lỗi đầy nội dung cơ sở dữ liệu MySql ” fatal error: allowed memory size of “
Wordpress

Lỗi đầy nội dung cơ sở dữ liệu MySql ” fatal error: allowed memory size of “

15 Tháng Mười, 2020

Bài tiếp theo

Code Chat Live Fanpages Facebook

Share Tốt

Share Tốt chia sẻ kinh nghiệm, tin tức, thủ thuật, bài giảng hay cho mọi lứa tuổi xem trên trang.

Theo dõi tôi

Chuyên Mục

  • 365 Ngày 24/7
  • Design
  • Dịch vụ Web
  • Lập Trình PHP
  • News CNTT
  • SEO Google
  • Share Code
  • Thủ Thuật
  • Wordpress

Bài viết mới

Thiết kế website – dịch vụ tiềm năng thời công nghệ

Thiết kế website – dịch vụ tiềm năng thời công nghệ

20 Tháng Tư, 2022
Code fake tối ưu điểm Google Speed cho WordPress

Code fake tối ưu điểm Google Speed nodejs

22 Tháng Mười, 2021
  • Share Tốt – Chia Sẻ Kinh Nghiệm Tồi Tệ

© 2020 Share Tốt - Thiết kế web Hải Phòng.

No Result
View All Result
  • Trang chủ
  • WordPress
  • Share Code
  • Dịch vụ Web
  • 365 Ngày 24/7
  • Thủ Thuật
  • Lập Trình PHP
  • News CNTT
  • SEO Google

© 2020 Share Tốt - Thiết kế web Hải Phòng.