<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                如果您的插件允許用戶在管理員或公共方面提交數據,則應檢查用戶功能。 ##用戶角色和功能 創建高效安全層最重要的一步就是擁有一個用戶權限系統。 WordPress以用戶角色和功能的形式提供。 每個登錄WordPress的用戶都會根據用戶角色自動分配具體的用戶功能。 用戶角色只是說明用戶所屬的組的一種奇特的方式。每個組都有一組特定的預定義功能。 例如,您的網站的主要用戶將具有管理員的用戶角色,而其他用戶可能具有編輯器或作者等角色。您可以將多個用戶分配到角色,即網站可能有兩個管理員。 用戶功能是您分配給每個用戶或用戶角色的特定權限。 例如,管理員具有“manage_options”功能,允許他們查看,編輯和保存網站的選項。另一方面,編輯者缺乏這種能力,這將阻止他們與選項進行交互。 然后在管理員的各個不同點檢查這些功能。取決于分配給角色的功能;可以添加或刪除WordPress體驗的菜單,功能和其他方面。 在構建插件時,請確保僅在當前用戶具有必要功能時運行代碼。 層次結構 用戶角色越高,用戶擁有的功能越多。每個用戶角色都會繼承層次結構中的以前的角色。 例如,單個站點安裝中最高用戶角色的“管理員”繼承了以下角色及其功能:“訂閱者”,“貢獻者”,“作者”和“編輯者”。 ## 無限制 以下示例創建了一個前端的鏈接,該鏈接能夠刪除帖子。由于此代碼不檢查用戶功能,它允許任何訪問者的站點垃圾郵件! ``` <?php /** * generate a Delete link based on the homepage url */ function wporg_generate_delete_link($content) { // run only for single post page if (is_single() && in_the_loop() && is_main_query()) { // add query arguments: action, post $url = add_query_arg( [ 'action' => 'wporg_frontend_delete', 'post' => get_the_ID(), ], home_url() ); return $content . ' <a href="' . esc_url($url) . '">' . esc_html__('Delete Post', 'wporg') . '</a>'; } return null; } /** * request handler */ function wporg_delete_post() { if (isset($_GET['action']) && $_GET['action'] === 'wporg_frontend_delete') { // verify we have a post id $post_id = (isset($_GET['post'])) ? ($_GET['post']) : (null); // verify there is a post with such a number $post = get_post((int)$post_id); if (empty($post)) { return; } // delete the post wp_trash_post($post_id); // redirect to admin page $redirect = admin_url('edit.php'); wp_safe_redirect($redirect); // we are done die; } } /** * add the delete link to the end of the post content */ add_filter('the_content', 'wporg_generate_delete_link'); /** * register our request handler with the init hook */ add_action('init', 'wporg_delete_post'); ``` ## 限于具體能力 上面的示例允許網站的任何訪問者點擊“刪除”鏈接并垃圾郵件。 但是,我們只希望Editors及以上版本能夠點擊“刪除”鏈接。 為了實現這一點,我們將檢查當前用戶是否具有edit_others_posts功能,只有Editors或以上版本具有: ``` <?php /** * generate a Delete link based on the homepage url */ function wporg_generate_delete_link($content) { // run only for single post page if (is_single() && in_the_loop() && is_main_query()) { // add query arguments: action, post $url = add_query_arg( [ 'action' => 'wporg_frontend_delete', 'post' => get_the_ID(), ], home_url() ); return $content . ' <a href="' . esc_url($url) . '">' . esc_html__('Delete Post', 'wporg') . '</a>'; } return null; } /** * request handler */ function wporg_delete_post() { if (isset($_GET['action']) && $_GET['action'] === 'wporg_frontend_delete') { // verify we have a post id $post_id = (isset($_GET['post'])) ? ($_GET['post']) : (null); // verify there is a post with such a number $post = get_post((int)$post_id); if (empty($post)) { return; } // delete the post wp_trash_post($post_id); // redirect to admin page $redirect = admin_url('edit.php'); wp_safe_redirect($redirect); // we are done die; } } if (current_user_can('edit_others_posts')) { /** * add the delete link to the end of the post content */ add_filter('the_content', 'wporg_generate_delete_link'); /** * register our request handler with the init hook */ add_action('init', 'wporg_delete_post'); } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看