{"id":32816,"date":"2024-11-25T09:41:22","date_gmt":"2024-11-25T01:41:22","guid":{"rendered":"https:\/\/fwq.ai\/blog\/32816\/"},"modified":"2024-11-25T09:41:22","modified_gmt":"2024-11-25T01:41:22","slug":"%e5%a6%82%e4%bd%95%e5%bc%80%e5%8f%91%e4%b8%80%e4%b8%aa%e5%93%8d%e5%ba%94%e5%bc%8f%e7%9a%84wordpress%e6%8f%92%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/32816\/","title":{"rendered":"\u5982\u4f55\u5f00\u53d1\u4e00\u4e2a\u54cd\u5e94\u5f0f\u7684WordPress\u63d2\u4ef6"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/887\/227\/169389730954185.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u5f00\u53d1\u4e00\u4e2a\u54cd\u5e94\u5f0f\u7684WordPress\u63d2\u4ef6\u63d2\u56fe\" alt=\"\u5982\u4f55\u5f00\u53d1\u4e00\u4e2a\u54cd\u5e94\u5f0f\u7684WordPress\u63d2\u4ef6\u63d2\u56fe\" \/><\/p>\n<p>\u5982\u4f55\u5f00\u53d1\u4e00\u4e2a\u54cd\u5e94\u5f0f\u7684WordPress\u63d2\u4ef6<\/p>\n<p>\u7b80\u4ecb<\/p>\n<p>\u5728\u79fb\u52a8\u4e92\u8054\u7f51\u65f6\u4ee3\uff0c\u54cd\u5e94\u5f0f\u8bbe\u8ba1\u5df2\u7ecf\u6210\u4e3a\u4e86\u7f51\u7ad9\u5f00\u53d1\u7684\u6807\u914d\u3002\u800c\u5bf9\u4e8e\u4f7f\u7528WordPress\u642d\u5efa\u7684\u7f51\u7ad9\u6765\u8bf4\uff0c\u5f00\u53d1\u4e00\u4e2a\u54cd\u5e94\u5f0f\u7684\u63d2\u4ef6\u662f\u5341\u5206\u91cd\u8981\u7684\u3002\u672c\u6587\u5c06\u4e3a\u4f60\u4ecb\u7ecd\u5982\u4f55\u5f00\u53d1\u4e00\u4e2a\u54cd\u5e94\u5f0f\u7684WordPress\u63d2\u4ef6\uff0c\u5305\u62ec\u4e00\u4e9b\u5173\u952e\u7684\u4ee3\u7801\u793a\u4f8b\u3002<\/p>\n<ol>\n<li>\u521b\u5efa\u63d2\u4ef6<\/li>\n<\/ol>\n<p>\u9996\u5148\uff0c\u4f60\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u76ee\u5f55\u4ee5\u5b58\u653e\u4f60\u7684\u63d2\u4ef6\u6587\u4ef6\u3002\u5728wp-content\/plugins\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6\u5939\uff0c\u4f8b\u5982&#8221;my-responsive-plugin&#8221;\u3002\u8fdb\u5165\u8be5\u76ee\u5f55\u540e\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a&#8221;my-responsive-plugin.php&#8221;\u7684\u4e3b\u6587\u4ef6\u3002<\/p>\n<p>\u5728\u4e3b\u6587\u4ef6\u4e2d\uff0c\u4f60\u9700\u8981\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\u6765\u5b9a\u4e49\u4f60\u7684\u63d2\u4ef6\uff1a<\/p>\n<pre>\/*\nPlugin Name: My Responsive Plugin\nDescription: A responsive plugin for WordPress\nVersion: 1.0\nAuthor: Your Name\n*\/\n\n\/\/ \u5728\u8fd9\u91cc\u5199\u4e0b\u4f60\u7684\u63d2\u4ef6\u903b\u8f91\u4ee3\u7801<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<ol>\n<li>\u6dfb\u52a0\u54cd\u5e94\u5f0f\u6837\u5f0f<\/li>\n<\/ol>\n<p>\u8981\u4f7f\u4f60\u7684\u63d2\u4ef6\u54cd\u5e94\u5f0f\uff0c\u4f60\u9700\u8981\u5728\u63d2\u4ef6\u4e2d\u6dfb\u52a0\u9002\u5e94\u4e0d\u540c\u8bbe\u5907\u7684\u6837\u5f0f\u8868\u3002\u5728\u63d2\u4ef6\u76ee\u5f55\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a&#8221;css&#8221;\u7684\u6587\u4ef6\u5939\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a&#8221;style.css&#8221;\u7684\u6837\u5f0f\u8868\u6587\u4ef6\u3002<\/p>\n<pre>\/* \u54cd\u5e94\u5f0f\u6837\u5f0f *\/\n@media screen and (max-width: 600px) {\n  \/* \u5728\u8fd9\u91cc\u5199\u4e0b\u9488\u5bf9\u5c0f\u5c4f\u5e55\u8bbe\u5907\u7684\u6837\u5f0f *\/\n}\n\n@media screen and (min-width: 601px) and (max-width: 1200px) {\n  \/* \u5728\u8fd9\u91cc\u5199\u4e0b\u9488\u5bf9\u4e2d\u7b49\u5c4f\u5e55\u8bbe\u5907\u7684\u6837\u5f0f *\/\n}\n\n@media screen and (min-width: 1201px) {\n  \/* \u5728\u8fd9\u91cc\u5199\u4e0b\u9488\u5bf9\u5927\u5c4f\u5e55\u8bbe\u5907\u7684\u6837\u5f0f *\/\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<ol>\n<li>\u6dfb\u52a0\u811a\u672c<\/li>\n<\/ol>\n<p>\u6709\u65f6\u5019\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u5728\u63d2\u4ef6\u4e2d\u6dfb\u52a0\u4e00\u4e9bJavaScript\u811a\u672c\u6765\u589e\u5f3a\u529f\u80fd\u6216\u5b9e\u73b0\u52a8\u6001\u6548\u679c\u3002\u5728\u63d2\u4ef6\u76ee\u5f55\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a&#8221;js&#8221;\u7684\u6587\u4ef6\u5939\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a&#8221;script.js&#8221;\u7684JavaScript\u811a\u672c\u6587\u4ef6\u3002<\/p>\n<pre>\/\/ \u5728\u8fd9\u91cc\u5199\u4e0b\u4f60\u7684JavaScript\u4ee3\u7801<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<ol>\n<li>\u5c06\u6837\u5f0f\u4e0e\u811a\u672c\u5f15\u5165\u5230WordPress<\/li>\n<\/ol>\n<p>\u4e3a\u4e86\u5728WordPress\u4e2d\u52a0\u8f7d\u4f60\u7684\u6837\u5f0f\u548c\u811a\u672c\uff0c\u4f60\u9700\u8981\u4f7f\u7528wp_enqueue_style()\u548cwp_enqueue_script()\u51fd\u6570\u3002\u7f16\u8f91\u4f60\u7684\u4e3b\u6587\u4ef6&#8221;my-responsive-plugin.php&#8221;\uff0c\u5e76\u5728\u9002\u5f53\u7684\u4f4d\u7f6e\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre>\/\/ \u52a0\u8f7d\u6837\u5f0f\nfunction my_responsive_plugin_styles() {\n  wp_enqueue_style( 'my-responsive-plugin-style', plugin_dir_url( __FILE__ ) . 'css\/style.css' );\n}\nadd_action( 'wp_enqueue_scripts', 'my_responsive_plugin_styles' );\n\n\/\/ \u52a0\u8f7d\u811a\u672c\nfunction my_responsive_plugin_scripts() {\n  wp_enqueue_script( 'my-responsive-plugin-script', plugin_dir_url( __FILE__ ) . 'js\/script.js', array( 'jquery' ), '1.0', true );\n}\nadd_action( 'wp_enqueue_scripts', 'my_responsive_plugin_scripts' );<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<ol>\n<li>\u54cd\u5e94\u5f0f\u63d2\u4ef6\u793a\u4f8b<\/li>\n<\/ol>\n<p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u6765\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u54cd\u5e94\u5f0f\u63d2\u4ef6\u793a\u4f8b\u3002\u5047\u8bbe\u6211\u4eec\u8981\u5728\u7f51\u9875\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u54cd\u5e94\u5f0f\u7684\u6309\u94ae\uff0c\u6309\u94ae\u5728\u5c0f\u5c4f\u5e55\u8bbe\u5907\u4e0a\u663e\u793a\u4e3a\u7ea2\u8272\uff0c\u4e2d\u7b49\u5c4f\u5e55\u8bbe\u5907\u4e0a\u663e\u793a\u4e3a\u84dd\u8272\uff0c\u5927\u5c4f\u5e55\u8bbe\u5907\u4e0a\u663e\u793a\u4e3a\u7eff\u8272\u3002<\/p>\n<p>\u9996\u5148\uff0c\u5728\u63d2\u4ef6\u7684\u4e3b\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre>\/\/ \u6dfb\u52a0\u63d2\u4ef6\u5185\u5bb9\nfunction my_responsive_plugin_content() {\n  return '&lt;button class=\"my-responsive-plugin-button\"&gt;Click Me&lt;\/button&gt;';\n}\nadd_shortcode( 'my_responsive_plugin', 'my_responsive_plugin_content' );<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u7136\u540e\uff0c\u5728\u6837\u5f0f\u8868\u6587\u4ef6&#8221;style.css&#8221;\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre>\/* \u5728\u5c0f\u5c4f\u5e55\u8bbe\u5907\u4e0a\u7684\u6837\u5f0f *\/\n@media screen and (max-width: 600px) {\n  .my-responsive-plugin-button {\n    color: red;\n  }\n}\n\n\/* \u5728\u4e2d\u7b49\u5c4f\u5e55\u8bbe\u5907\u4e0a\u7684\u6837\u5f0f *\/\n@media screen and (min-width: 601px) and (max-width: 1200px) {\n  .my-responsive-plugin-button {\n    color: blue;\n  }\n}\n\n\/* \u5728\u5927\u5c4f\u5e55\u8bbe\u5907\u4e0a\u7684\u6837\u5f0f *\/\n@media screen and (min-width: 1201px) {\n  .my-responsive-plugin-button {\n    color: green;\n  }\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6700\u540e\uff0c\u5728\u4f60\u7684WordPress\u9875\u9762\u4e2d\u6dfb\u52a0\u5982\u4e0b\u77ed\u4ee3\u7801\uff1a<\/p>\n<pre>[my_responsive_plugin]<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4fdd\u5b58\u5e76\u9884\u89c8\u4f60\u7684\u7f51\u9875\uff0c\u4f60\u5c06\u770b\u5230\u4e00\u4e2a\u54cd\u5e94\u5f0f\u7684\u6309\u94ae\uff0c\u5b83\u7684\u989c\u8272\u5c06\u6839\u636e\u5c4f\u5e55\u5c3a\u5bf8\u800c\u53d8\u5316\u3002<\/p>\n<p>\u7ed3\u8bba<\/p>\n<p>\u5f00\u53d1\u4e00\u4e2a\u54cd\u5e94\u5f0f\u7684WordPress\u63d2\u4ef6\u53ef\u4ee5\u8ba9\u4f60\u7684\u7f51\u7ad9\u5728\u4e0d\u540c\u8bbe\u5907\u4e0a\u90fd\u80fd\u5f97\u5230\u826f\u597d\u7684\u663e\u793a\u6548\u679c\u3002\u672c\u6587\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5173\u952e\u7684\u4ee3\u7801\u793a\u4f8b\uff0c\u5e2e\u52a9\u4f60\u5f00\u59cb\u5f00\u53d1\u4e00\u4e2a\u54cd\u5e94\u5f0f\u7684WordPress\u63d2\u4ef6\u3002\u5e0c\u671b\u8fd9\u4e9b\u793a\u4f8b\u80fd\u4e3a\u4f60\u7684\u63d2\u4ef6\u5f00\u53d1\u63d0\u4f9b\u4e00\u4e9b\u5e2e\u52a9\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5f00\u53d1\u4e00\u4e2a\u54cd\u5e94\u5f0f\u7684WordPress\u63d2\u4ef6\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u5f00\u53d1\u4e00\u4e2a\u54cd\u5e94\u5f0f\u7684WordPress\u63d2\u4ef6 \u7b80\u4ecb \u5728\u79fb\u52a8\u4e92\u8054\u7f51\u65f6\u4ee3\uff0c\u54cd\u5e94\u5f0f\u8bbe\u8ba1\u5df2\u7ecf\u6210\u4e3a\u4e86\u7f51\u7ad9\u5f00\u53d1\u7684\u6807\u914d\u3002\u800c\u5bf9\u4e8e\u4f7f\u7528WordPress\u642d\u5efa\u7684\u7f51\u7ad9\u6765\u8bf4\uff0c\u5f00\u53d1\u4e00\u4e2a\u54cd\u5e94\u5f0f\u7684\u63d2\u4ef6\u662f\u5341\u5206\u91cd\u8981\u7684\u3002\u672c\u6587\u5c06\u4e3a\u4f60\u4ecb\u7ecd\u5982\u4f55\u5f00\u53d1\u4e00\u4e2a\u54cd\u5e94\u5f0f\u7684WordPress\u63d2\u4ef6\uff0c\u5305\u62ec\u4e00\u4e9b\u5173\u952e\u7684\u4ee3\u7801\u793a\u4f8b\u3002 \u521b\u5efa\u63d2\u4ef6 \u9996\u5148\uff0c\u4f60\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u76ee\u5f55\u4ee5\u5b58\u653e\u4f60\u7684\u63d2\u4ef6\u6587\u4ef6\u3002\u5728wp-content\/plugins\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6\u5939\uff0c\u4f8b\u5982&#8221;my-responsive-plugin&#8221;\u3002\u8fdb\u5165\u8be5\u76ee\u5f55\u540e\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a&#8221;my-responsive-plugin.php&#8221;\u7684\u4e3b\u6587\u4ef6\u3002 \u5728\u4e3b\u6587\u4ef6\u4e2d\uff0c\u4f60\u9700\u8981\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\u6765\u5b9a\u4e49\u4f60\u7684\u63d2\u4ef6\uff1a \/* Plugin Name: My Responsive Plugin Description: A responsive plugin for WordPress Version: 1.0 Author: Your Name *\/ \/\/ \u5728\u8fd9\u91cc\u5199\u4e0b\u4f60\u7684\u63d2\u4ef6\u903b\u8f91\u4ee3\u7801 \u767b\u5f55\u540e\u590d\u5236 \u6dfb\u52a0\u54cd\u5e94\u5f0f\u6837\u5f0f \u8981\u4f7f\u4f60\u7684\u63d2\u4ef6\u54cd\u5e94\u5f0f\uff0c\u4f60\u9700\u8981\u5728\u63d2\u4ef6\u4e2d\u6dfb\u52a0\u9002\u5e94\u4e0d\u540c\u8bbe\u5907\u7684\u6837\u5f0f\u8868\u3002\u5728\u63d2\u4ef6\u76ee\u5f55\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a&#8221;css&#8221;\u7684\u6587\u4ef6\u5939\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a&#8221;style.css&#8221;\u7684\u6837\u5f0f\u8868\u6587\u4ef6\u3002 \/* \u54cd\u5e94\u5f0f\u6837\u5f0f *\/ @media screen and (max-width: 600px) { \/* \u5728\u8fd9\u91cc\u5199\u4e0b\u9488\u5bf9\u5c0f\u5c4f\u5e55\u8bbe\u5907\u7684\u6837\u5f0f *\/ } @media screen and (min-width: 601px) and (max-width: 1200px) { \/* \u5728\u8fd9\u91cc\u5199\u4e0b\u9488\u5bf9\u4e2d\u7b49\u5c4f\u5e55\u8bbe\u5907\u7684\u6837\u5f0f *\/ } [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-32816","post","type-post","status-publish","format-standard","hentry","category-cms"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/32816","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=32816"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/32816\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=32816"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=32816"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=32816"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}