• 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
13
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

Top 5 công ty thiết kế website chuyên nghiệp uy tín TPHCM

#TOP Công ty dịch vụ thiết kế APP uy tín ở tại Hải Phòng

30 Tháng Mười, 2020
Gắn nút Hotline – Zalo – Facebook cho Website năm 2020

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 “

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

15 Tháng Mười, 2020
STREAM ĐẾN BAO GIỜ – ĐỘ MIXI TOP 1 Thịnh Hành sau 2 ngày

STREAM ĐẾN BAO GIỜ – ĐỘ MIXI TOP 1 Thịnh Hành sau 2 ngày

15 Tháng Chín, 2020

Bài viết liên quan

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
Cách code đưa nút Add Media WordPress Custom
Share Code

Cách code đưa nút Add Media WordPress Custom

27 Tháng Bảy, 2020
Code thêm tab cạnh mô tả cho woocommerce
Wordpress

Code thêm tab cạnh mô tả cho woocommerce

20 Tháng Năm, 2020
Loại bỏ trong đường dẫn danh mục sản phẩm Woocommerce
Wordpress

Thay đổi thẻ html woocommerce change product title p to h3

12 Tháng Sáu, 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

Top 5 công ty thiết kế website chuyên nghiệp uy tín TPHCM

#TOP Công ty dịch vụ thiết kế APP uy tín ở tại Hải Phòng

30 Tháng Mười, 2020
Gắn nút Hotline – Zalo – Facebook cho Website năm 2020

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

14 Tháng Mười Một, 2020
  • 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.