{"id":4597,"date":"2020-04-09T09:39:32","date_gmt":"2020-04-09T02:39:32","guid":{"rendered":"https:\/\/tino.vn\/?post_type=ht_kb&#038;p=4597"},"modified":"2021-06-14T22:57:19","modified_gmt":"2021-06-14T15:57:19","slug":"cach-vo-hieu-hoa-nhung-tren-wordpress","status":"publish","type":"ht_kb","link":"https:\/\/tino.vn\/blog\/docs\/cach-vo-hieu-hoa-nhung-tren-wordpress\/","title":{"rendered":"C\u00e1ch v\u00f4 hi\u1ec7u ho\u00e1 nh\u00fang tr\u00ean WordPress"},"content":{"rendered":"<p>\u0110\u1ed1i v\u1edbi b\u1ea5t k\u1ef3 m\u1ed9t website wordpress n\u00e0o, m\u1ed7i m\u1ed9t t\u1ed1i \u01b0u nh\u1ecf c\u1ee7a b\u1ea1n c\u0169ng s\u1ebd gi\u00fap t\u1ed5ng th\u1ec3 website c\u1ee7a b\u1ea1n ho\u1ea1t \u0111\u1ed9ng m\u1ed9t c\u00e1ch tr\u01a1n tru h\u01a1n. M\u1ed7i website do \u0111\u01b0\u1ee3c load t\u1eeb r\u1ea5t nhi\u1ec1u th\u00e0nh ph\u1ea7n n\u00ean vi\u1ec7c t\u1ed1i \u01b0u m\u1ed7i ph\u1ea7n nh\u1ecf l\u00e0 \u0111i\u1ec1u b\u1ea1n n\u00ean l\u00e0m tr\u1eeb khi vi\u1ec7c t\u1ed1i \u01b0u ho\u00e1 l\u00e0 b\u1ea5t kh\u1ea3 kh\u00e1ng ho\u1eb7c l\u00e0m m\u1ea5t t\u00ednh n\u0103ng c\u1ea7n \u0111\u01b0\u1ee3c \u01b0u ti\u00ean.<\/p>\n<p>H\u00f4m nay TinoHost s\u1ebd h\u01b0\u1edbng d\u1eabn c\u00e1c b\u1ea1n c\u00e1ch v\u00f4 hi\u1ec7u ho\u00e1 nh\u00fang tr\u00ean WordPress.<\/p>\n<p>T\u1eeb phi\u00ean b\u1ea3n WordPress 4.4, vi\u1ec7c nh\u00fang video (embed video), \u0111\u00e3 \u0111\u01b0\u1ee3c t\u00edch h\u1ee3p v\u00e0o core. \u0110i\u1ec1u n\u00e0y cho ph\u00e9p b\u1ea1n nh\u00fang c\u00e1c Video nh\u01b0 Youtube, Twitter c\u0169ng nh\u01b0 nhi\u1ec1u ngu\u1ed3n video kh\u00e1c b\u1eb1ng vi\u1ec7c s\u1eed d\u1ee5ng Url, WordPress s\u1ebd t\u1ef1 \u0111\u1ed9ng nh\u00fang video v\u00e0 chuy\u1ec3n th\u00e0nh phi\u00ean b\u1ea3n c\u00f3 th\u1ec3 xem tr\u1ef1c ti\u1ebfp t\u1eeb tr\u00ecnh ch\u1ec9nh s\u1eeda. B\u1ea1n c\u00f3 th\u1ec3 xem chi ti\u1ebft danh s\u00e1ch website h\u1ed7 tr\u1ee3 nh\u00fang t\u1ef1 \u0111\u1ed9ng c\u1ee7a wordpress t\u1ea1i : https:\/\/wordpress.org\/support\/article\/embeds\/<\/p>\n<p><span class=\"notranslate\">T\u00ednh n\u0103ng n\u00e0y th\u1eadt s\u1ef1 h\u1eefu \u00edch,<\/span>\u00a0<span class=\"notranslate\">Tuy nhi\u00ean, \u0111i\u1ec1u n\u00e0y c\u00f3 ngh\u0129a l\u00e0 n\u00f3 c\u0169ng t\u1ea1o ra m\u1ed9t y\u00eau c\u1ea7u HTTP b\u1ed5 sung tr\u00ean trang web WordPress c\u1ee7a b\u1ea1n\u00a0 \u0111\u1ec3 t\u1ea3i t\u1ec7p wp-embed.min.js v\u00e0 t\u1ea3i tr\u00ean t\u1ea5t c\u1ea3 c\u00e1c trang<\/span><span class=\"notranslate\">.<\/span>\u00a0<span class=\"notranslate\">M\u1eb7c d\u00f9 t\u1ec7p n\u00e0y ch\u1ec9 c\u00f3 1,7 KB, nh\u01b0ng theo th\u1eddi gian c\u0169ng nh\u01b0 n\u1ebfu t\u00ednh t\u1ea5t c\u00e1c truy c\u1eadp v\u00e0 c\u00e1c trang \u0111\u1ec1u t\u1ea3i file n\u00e0y th\u00ec dung l\u01b0\u1ee3ng t\u1ed5ng c\u0169ng r\u1ea5t l\u1edbn v\u00e0 v\u00f4 ngh\u0129a n\u1ebfu b\u1ea1n kh\u00f4ng s\u1eed d\u1ee5ng.<\/span><\/p>\n<div id=\"attachment_6483\" class=\"wp-caption alignnone\"><img decoding=\"async\" class=\"wp-image-6483 size-full\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/wp-embed.jpg\" sizes=\"(max-width: 1534px) 100vw, 1534px\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/wp-embed.jpg 1534w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_wp-embed-300x113.jpg 300w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_wp-embed-768x289.jpg 768w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_wp-embed-1024x385.jpg 1024w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/wp-embed-460x173.jpg 460w\" alt=\"nh\u00fang wp\" width=\"1534\" height=\"577\" title=\"\"><\/p>\n<p class=\"wp-caption-text\"><span class=\"notranslate\">wp-embed.min.js<\/span><\/p>\n<\/div>\n<h2 id=\"V\u00f4_hi\u1ec7u_h\u00f3a_nh\u00fang_trong_WordPress\"><span class=\"notranslate\">V\u00f4 hi\u1ec7u h\u00f3a nh\u00fang trong WordPress<\/span><\/h2>\n<p>&nbsp;<\/p>\n<p><span class=\"notranslate\">C\u00f3 m\u1ed9t v\u00e0i c\u00e1ch kh\u00e1c nhau \u0111\u1ec3 v\u00f4 hi\u1ec7u h\u00f3a Nh\u00fang trong WordPress.<\/span><\/p>\n<ul>\n<li><span class=\"notranslate\">V\u00f4 hi\u1ec7u h\u00f3a nh\u00fang v\u1edbi plugin<\/span><\/li>\n<li><span class=\"notranslate\">V\u00f4 hi\u1ec7u h\u00f3a nh\u00fang b\u1eb1ng c\u00e1ch th\u00eam code v\u00e0o website.<\/span><\/li>\n<\/ul>\n<h3 id=\"1._V\u00f4_hi\u1ec7u_h\u00f3a_nh\u00fang_trong_WordPress_v\u1edbi_Plugin\u00a0\"><span class=\"notranslate\">1. V\u00f4 hi\u1ec7u h\u00f3a nh\u00fang trong WordPress v\u1edbi Plugin<\/span>\u00a0<span id=\"1-v-hiu-ha-nhng-trong-wordpress-vi-plugin\" class=\"anchor-hash\" aria-hidden=\"true\"><\/span><\/h3>\n<p><span class=\"notranslate\">C\u00e1ch \u0111\u1ea7u ti\u00ean \u0111\u1ec3 v\u00f4 hi\u1ec7u h\u00f3a c\u00e1c nh\u00fang l\u00e0 ch\u1ec9 c\u1ea7n s\u1eed d\u1ee5ng m\u1ed9t plugin mi\u1ec5n ph\u00ed c\u00f3 t\u00ean l\u00e0 \u00a0<a href=\"https:\/\/wordpress.org\/plugins\/disable-embeds\/\" target=\"_blank\" rel=\"noopener noreferrer nofollow\">Disable Embeds<\/a>,, \u0111\u01b0\u1ee3c ph\u00e1t tri\u1ec3n b\u1edfi\u00a0Pascal Birchler , m\u1ed9t developer c\u00f3 tham gia\u00a0 v\u00e0o vi\u1ec7c ph\u00e1t tri\u1ec3n core WordPress.<\/span><\/p>\n<div id=\"attachment_6479\" class=\"wp-caption alignnone\"><img decoding=\"async\" class=\"wp-image-6479 size-full\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/disable-embeds-wordpress-plugin.jpg\" sizes=\"(max-width: 1346px) 100vw, 1346px\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/disable-embeds-wordpress-plugin.jpg 1346w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_disable-embeds-wordpress-plugin-300x97.jpg 300w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_disable-embeds-wordpress-plugin-768x247.jpg 768w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_disable-embeds-wordpress-plugin-1024x329.jpg 1024w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/disable-embeds-wordpress-plugin-460x148.jpg 460w\" alt=\"v\u00f4 hi\u1ec7u h\u00f3a plugin wordpress\" width=\"1346\" height=\"433\" title=\"\"><\/div>\n<div><\/div>\n<p><span class=\"notranslate\">Plugin n\u00e0y si\u00eau nh\u1eb9, ch\u00ednh x\u00e1c ch\u1ec9 3 KB,<\/span>\u00a0<span class=\"notranslate\">B\u1ea1n c\u00f3 th\u1ec3 t\u1ea3i xu\u1ed1ng t\u1eeb\u00a0kho l\u01b0u tr\u1eef WordPress\u00a0ho\u1eb7c b\u1eb1ng c\u00e1ch t\u00ecm ki\u1ebfm n\u00f3\u00a0trong b\u1ea3ng \u0111i\u1ec1u khi\u1ec3n WordPress, Plugin n\u00e0y gi\u00fap b\u1ea1n:<\/span><\/p>\n<ul>\n<li><span class=\"notranslate\">Ng\u0103n ch\u1eb7n ng\u01b0\u1eddi kh\u00e1c nh\u00fang trang web c\u1ee7a b\u1ea1n.<\/span><\/li>\n<li><span class=\"notranslate\">Ng\u0103n ch\u1eb7n b\u1ea1n nh\u00fang c\u00e1c trang web kh\u00f4ng t\u1ed1t. (C\u00e1c website kh\u00f4ng n\u1eb1m trong white-list)<\/span><\/li>\n<li><span class=\"notranslate\">Kh\u00f4ng cho ph\u00e9p t\u1ea3i t\u1ec7p JavaScript tr\u00ean trang web WordPress c\u1ee7a b\u1ea1n.<\/span><\/li>\n<\/ul>\n<p><span class=\"notranslate\">B\u1ea1n v\u1eabn c\u00f3 th\u1ec3 nh\u00fang c\u00e1c video t\u1eeb youtube hay tweet b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng iframe.<\/span>\u00a0<span class=\"notranslate\">B\u1ea1n c\u0169ng c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng m\u1ed9t plugin kh\u00e1c nh\u01b0 perfmatters, cho ph\u00e9p b\u1ea1n v\u00f4 hi\u1ec7u h\u00f3a nh\u00fang c\u00f9ng v\u1edbi c\u00e1c t\u1ed1i \u01b0u h\u00f3a kh\u00e1c cho trang web WordPress c\u1ee7a b\u1ea1n.<\/span><\/p>\n<div id=\"attachment_12429\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"size-full wp-image-12429\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/disable-embeds-in-perfmatters-plugin.png\" sizes=\"(max-width: 1404px) 100vw, 1404px\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/disable-embeds-in-perfmatters-plugin.png 1404w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_disable-embeds-in-perfmatters-plugin-300x108.png 300w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_disable-embeds-in-perfmatters-plugin-768x277.png 768w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_disable-embeds-in-perfmatters-plugin-1024x370.png 1024w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/disable-embeds-in-perfmatters-plugin-610x220.png 610w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/disable-embeds-in-perfmatters-plugin-460x166.png 460w\" alt=\"V\u00f4 hi\u1ec7u h\u00f3a nh\u00fang trong plugin perfmatters\" width=\"1404\" height=\"507\" title=\"\"><\/p>\n<p class=\"wp-caption-text\"><span class=\"notranslate\">V\u00f4 hi\u1ec7u h\u00f3a nh\u00fang trong plugin perfmatters<\/span><\/p>\n<\/div>\n<h3 id=\"2._V\u00f4_hi\u1ec7u_h\u00f3a_c\u00e1c_nh\u00fang_trong_WordPress_b\u1eb1ng_c\u00e1ch_s\u1eed_d\u1ee5ng_CODE\"><span class=\"notranslate\">2. V\u00f4 hi\u1ec7u h\u00f3a c\u00e1c nh\u00fang trong WordPress b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng CODE<\/span><span id=\"2-v-hiu-ha-cc-nhng-trong-wordpress-vi-m\" class=\"anchor-hash\" aria-hidden=\"true\"><\/span><\/h3>\n<p><span class=\"notranslate\">N\u1ebfu b\u1ea1n kh\u00f4ng mu\u1ed1n c\u00e0i \u0111\u1eb7t m\u1ed9t plugin kh\u00e1c, b\u1ea1n c\u0169ng c\u00f3 th\u1ec3 v\u00f4 hi\u1ec7u h\u00f3a nh\u00fang v\u1edbi \u0111o\u1ea1n code sau.<\/span> B\u1ea1n ch\u1ec9 c\u1ea7n th\u00eam v\u00e0o file functions.php\u00a0 \u0111\u1ed1i v\u1edbi theme b\u1ea1n \u0111ang s\u1eed d\u1ee5ng.<\/p>\n<pre class=\"  language-php\"><code class=\"  language-php\"><span class=\"token keyword\">function<\/span> <span class=\"token function\">disable_embeds_code_init<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token comment\">\/\/ Remove the REST API endpoint. remove_action( 'rest_api_init', 'wp_oembed_register_route' ); \/\/ Turn off oEmbed auto discovery. add_filter( 'embed_oembed_discover', '__return_false' ); \/\/ Don't filter oEmbed results. remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 ); \/\/ Remove oEmbed discovery links. remove_action( 'wp_head', 'wp_oembed_add_discovery_links' ); \/\/ Remove oEmbed-specific JavaScript from the front-end and back-end. remove_action( 'wp_head', 'wp_oembed_add_host_js' ); add_filter( 'tiny_mce_plugins', 'disable_embeds_tiny_mce_plugin' ); \/\/ Remove all embeds rewrite rules. add_filter( 'rewrite_rules_array', 'disable_embeds_rewrites' ); \/\/ Remove filter of the oEmbed result before any HTTP requests are made. remove_filter( 'pre_oembed_result', 'wp_filter_pre_oembed_result', 10 ); } add_action( 'init', 'disable_embeds_code_init', 9999 ); function disable_embeds_tiny_mce_plugin($plugins) { return array_diff($plugins, array('wpembed')); } function disable_embeds_rewrites($rules) { foreach($rules as $rule =&gt; $rewrite) { if(false !== strpos($rewrite, 'embed=true')) { unset($rules[$rule]); } } return $rules; }<\/span><\/code><\/pre>\n<p><span class=\"notranslate\">Ho\u1eb7c b\u1ea1n c\u0169ng c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng h\u00e0m wp_dequeue_script.<\/span><\/p>\n<pre class=\"  language-php\"><code class=\"  language-php\"><span class=\"token keyword\">function<\/span> <span class=\"token function\">my_deregister_scripts<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">{<\/span> <span class=\"token function\">wp_dequeue_script<\/span><span class=\"token punctuation\">(<\/span> <span class=\"token single-quoted-string string\">'wp-embed'<\/span> <span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span> <span class=\"token function\">add_action<\/span><span class=\"token punctuation\">(<\/span> <span class=\"token single-quoted-string string\">'wp_footer'<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token single-quoted-string string\">'my_deregister_scripts'<\/span> <span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u0110\u1ed1i v\u1edbi b\u1ea5t k\u1ef3 m\u1ed9t website wordpress n\u00e0o, m\u1ed7i m\u1ed9t t\u1ed1i \u01b0u nh\u1ecf c\u1ee7a b\u1ea1n c\u0169ng s\u1ebd gi\u00fap t\u1ed5ng th\u1ec3 website c\u1ee7a b\u1ea1n ho\u1ea1t \u0111\u1ed9ng m\u1ed9t c\u00e1ch tr\u01a1n tru h\u01a1n. M\u1ed7i website do \u0111\u01b0\u1ee3c load t\u1eeb r\u1ea5t nhi\u1ec1u th\u00e0nh ph\u1ea7n n\u00ean vi\u1ec7c t\u1ed1i \u01b0u m\u1ed7i ph\u1ea7n nh\u1ecf l\u00e0 \u0111i\u1ec1u b\u1ea1n n\u00ean l\u00e0m tr\u1eeb khi vi\u1ec7c [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":16424,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"tags":[],"ht_kb_category":[5167,5154],"class_list":["post-4597","ht_kb","type-ht_kb","status-publish","format-standard","has-post-thumbnail","hentry","ht_kb_category-cau-hoi-chung-ve-wordpress","ht_kb_category-wordpress"],"_links":{"self":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb\/4597","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb"}],"about":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/comments?post=4597"}],"version-history":[{"count":0,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb\/4597\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/media\/16424"}],"wp:attachment":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/media?parent=4597"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/tags?post=4597"},{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb_category?post=4597"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}