{"id":678,"date":"2024-10-22T12:57:34","date_gmt":"2024-10-22T04:57:34","guid":{"rendered":"https:\/\/www.cuishaofeng.com\/?p=678"},"modified":"2024-10-22T14:32:18","modified_gmt":"2024-10-22T06:32:18","slug":"wordpress-%e4%bb%aa%e8%a1%a8%e7%9b%98%e7%95%8c%e9%9d%a2%e6%b7%bb%e5%8a%a0%e7%99%be%e5%ba%a6%e7%bb%9f%e8%ae%a1%e6%95%b0%e6%8d%ae%e5%b1%95%e7%a4%ba%e6%a8%a1%e5%9d%97","status":"publish","type":"post","link":"https:\/\/www.cuishaofeng.com\/?p=678","title":{"rendered":"WordPress \u4eea\u8868\u76d8\u754c\u9762\u6dfb\u52a0\u767e\u5ea6\u7edf\u8ba1\u6570\u636e\u5c55\u793a\u6a21\u5757"},"content":{"rendered":"<div id=\"core-ai-summary-tool\"><\/div>\n<p>\u767e\u5ea6\u7ad9\u957f\u7edf\u8ba1\u76ee\u524d\u8fd8\u662f\u56fd\u5185\u7684\u4e3b\u6d41\u7f51\u7ad9\u7edf\u8ba1\uff0c\u5f88\u591a\u7ad9\u957f\u6bcf\u5929\u90fd\u4f1a\u770b\u770b\u81ea\u5df1\u7684\u7f51\u7ad9\u6570\u636e\uff0c\u6765\u67e5\u770b\u81ea\u5df1\u7684\u6d41\u91cf\u8d70\u5411\u3001\u8bbf\u5ba2\u6765\u8def\u3001\u7f51\u7ad9\u70ed\u95e8\u5173\u952e\u8bcd\u3001\u7f51\u7ad9\u70ed\u95e8\u9875\u9762\u7b49\u7b49\uff0c\u770b\u7684\u6700\u591a\u7684\u8fd8\u662f\u6d4f\u89c8\u91cf\u3001\u8bbf\u5ba2\u6570\u3001IP\u6570\u91cf\u3002<\/p>\n\n\n\n<p>\u8fd9\u6837\u4f60\u53ea\u8981\u767b\u9646\u4f60\u7684 WordPress \u7ad9\u70b9\u540e\u53f0\u5c31\u80fd\u770b\u5230\u767e\u5ea6\u7edf\u8ba1\u7684\u5e38\u89c4\u6570\u636e\uff0c\u662f\u4e0d\u662f\u65b9\u4fbf\u591a\u4e86\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"pk-menu-0\">\u6dfb\u52a0\u767e\u5ea6\u7edf\u8ba1\u6570\u636e\u6a21\u5757<\/h2>\n\n\n\n<p>WordPress \u767e\u5ea6\u7edf\u8ba1\u53ef\u4ee5\u901a\u8fc7 function \u51fd\u6570\u5b9e\u73b0\uff0c\u53ea\u9700\u8981\u5728\u5f53\u524d\u4f7f\u7528\u4e3b\u9898\u76ee\u5f55\u4e0b\u7684<code>functions.php<\/code>\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\u5373\u53ef\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/WordPress \u4eea\u8868\u76d8\u6dfb\u52a0\u767e\u5ea6\u7edf\u8ba1\u6570\u636e\u5c55\u793a\u6a21\u5757 - https:\/\/wpexp.cn\/86.html\nfunction wpexp_add_dashboard_widgets() { \n  wp_add_dashboard_widget('custom_help_widget', '\u767e\u5ea6\u7edf\u8ba1\u6570\u636e', 'bdtj_dashboard_wpexp'); \n} \nadd_action('wp_dashboard_setup', 'wpexp_add_dashboard_widgets' ); \nfunction bdtj_dashboard_wpexp() {\n  $body = array('header'=>array(\n  'username' => '\u767e\u5ea6\u7edf\u8ba1\u8d26\u6237',\n  'password' => '\u767e\u5ea6\u7edf\u8ba1\u5bc6\u7801',\n  'token'=>'\u767e\u5ea6\u7edf\u8ba1token',\n  'account_type'=>1\n  ),'body'=>array(\n  'site_id'=>'\u767e\u5ea6\u7edf\u8ba1\u7ad9\u70b9ID',\n  'start_date'=>date(\"Y-m-d\",strtotime(\"-1 day\")),\n  'end_date'=>date(\"Y-m-d\"),\n  'metrics'=>'pv_count,visitor_count,ip_count',\n  'method'=>'overview\/getTimeTrendRpt'\n  ));\n  $url='https:\/\/api.baidu.com\/json\/tongji\/v1\/ReportService\/getData';\/\/\u767e\u5ea6\u5546\u4e1a\u8d26\u53f7\u8bf7\u6c42\u5730\u5740\n  $request = new WP_Http;\n  $result = $request->request( $url, array( 'method' => 'POST', 'body' => json_encode($body)) );\n  $rst=json_decode($result&#91;'body']);\n \n  $yest=$rst->body->data&#91;0]->result->items&#91;1]&#91;0];\n  $nowt=$rst->body->data&#91;0]->result->items&#91;1]&#91;1];\n  echo '\u65e5\u671f&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp\u6d4f\u89c8\u91cf&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp\u8bbf\u5ba2\u6570&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbspIP\u6570';\n  echo '&lt;\/br>';\n  echo '\u4eca\u65e5:&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp';\n  for($i=0;$i&lt;count($nowt);$i++){\n  echo $nowt&#91;$i];\n  echo '&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp';\n  }\n  echo '&lt;\/br>';\n  echo '\u6628\u65e5:&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp';\n  for($i=0;$i&lt;count($yest);$i++){\n  echo $yest&#91;$i];\n  echo '&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp';\n  }\n}\n\n<\/code><\/pre>\n\n\n\n<p>\u4f7f\u7528\u4e86 WordPress \u81ea\u5e26\u7684 HTTP \u8bf7\u6c42\u7c7b\uff0c\u6ca1\u6709\u4f7f\u7528 Curl \u63d0\u4ea4 Post \u8bf7\u6c42\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"pk-menu-1\">\u83b7\u53d6\u4ee3\u7801\u76f8\u5173\u53c2\u6570<\/h2>\n\n\n\n<p>\u767e\u5ea6\u7edf\u8ba1\u7684 Token \u503c\u53ef\u4ee5\u81ea\u884c\u7533\u8bf7\u5f00\u901a\uff1a\u5728\u767e\u5ea6\u7edf\u8ba1\u53f3\u4e0a\u89d2\u9009\u62e9\u5bf9\u5e94\u7ad9\u70b9\uff0c\u70b9\u51fb\u9876\u90e8\u5bfc\u822a\u83dc\u5355\u7684<code>\u7ba1\u7406<\/code>\uff0c\u7136\u540e\u5728\u5de6\u4fa7\u83dc\u5355\u5e95\u90e8\u627e\u5230<code>\u5176\u4ed6\u8bbe\u7f6e<\/code>\u2192<code>\u6570\u636e\u5bfc\u51fa\u670d\u52a1<\/code>\uff0c\u9009\u62e9\u5f00\u901a\u5373\u53ef\u83b7\u5f97\u767e\u5ea6\u7edf\u8ba1 Token \u503c &#8220;View all posts in \u767e\u5ea6\u7edf\u8ba1 Token \u503c&#8221;)\u3002\u5177\u4f53\u53ef\u53c2\u89c1\u4e0b\u56fe\uff1a<\/p>\n\n\n\n<p>\u767e\u5ea6\u7edf\u8ba1\u7ad9\u70b9ID\u53ef\u4ee5\u70b9\u51fb<code>\u7f51\u7ad9\u6982\u51b5<\/code>\uff0c\u7136\u540e\u5730\u5740\u680f\u5c3e\u90e8\u4f1a\u6709\u4e2a<code>siteId=1234567<\/code>\u8fd9\u4e32\u5bf9\u5e94\u6570\u5b57\u5c31\u662f\u7ad9\u70b9ID\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u767e\u5ea6\u7ad9\u957f\u7edf\u8ba1\u76ee\u524d\u8fd8\u662f\u56fd\u5185\u7684\u4e3b\u6d41\u7f51\u7ad9\u7edf\u8ba1\uff0c\u5f88\u591a\u7ad9\u957f\u6bcf\u5929\u90fd\u4f1a\u770b\u770b\u81ea\u5df1\u7684\u7f51\u7ad9\u6570\u636e\uff0c\u6765\u67e5\u770b\u81ea\u5df1\u7684\u6d41\u91cf\u8d70\u5411\u3001\u8bbf\u5ba2\u6765\u8def\u3001\u7f51\u7ad9\u70ed\u95e8\u5173\u952e\u8bcd\u3001\u7f51\u7ad9\u70ed\u95e8\u9875\u9762\u7b49\u7b49\uff0c\u770b\u7684\u6700\u591a\u7684\u8fd8\u662f\u6d4f\u89c8\u91cf\u3001\u8bbf\u5ba2\u6570\u3001IP\u6570\u91cf\u3002 \u8fd9\u6837\u4f60\u53ea\u8981\u767b\u9646\u4f60\u7684 WordPress \u7ad9\u70b9\u540e\u53f0\u5c31\u80fd\u770b\u5230&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,1],"tags":[41],"topic":[],"_links":{"self":[{"href":"https:\/\/www.cuishaofeng.com\/index.php?rest_route=\/wp\/v2\/posts\/678"}],"collection":[{"href":"https:\/\/www.cuishaofeng.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cuishaofeng.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cuishaofeng.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cuishaofeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=678"}],"version-history":[{"count":1,"href":"https:\/\/www.cuishaofeng.com\/index.php?rest_route=\/wp\/v2\/posts\/678\/revisions"}],"predecessor-version":[{"id":679,"href":"https:\/\/www.cuishaofeng.com\/index.php?rest_route=\/wp\/v2\/posts\/678\/revisions\/679"}],"wp:attachment":[{"href":"https:\/\/www.cuishaofeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=678"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cuishaofeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=678"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cuishaofeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=678"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.cuishaofeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftopic&post=678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}