Pressbooks\Book::updateFrontMatter PHP Метод

updateFrontMatter() статический публичный Метод

WP_Ajax hook. Updates the menu_order field associated with a front matter post after reordering it
static public updateFrontMatter ( )
    static function updateFrontMatter()
    {
        /** @var $wpdb \wpdb */
        global $wpdb;
        if (current_user_can('edit_posts') && check_ajax_referer('pb-update-book-order')) {
            parse_str($_POST['front_matter_order'], $frontMatterOrder);
            if (is_array($frontMatterOrder)) {
                foreach ($frontMatterOrder as $key => $values) {
                    if ('front-matter' == $key) {
                        foreach ($values as $position => $id) {
                            $position += 1;
                            $wpdb->update($wpdb->posts, array('menu_order' => $position), array('ID' => $id));
                            clean_post_cache($id);
                        }
                    }
                }
            }
            static::deleteBookObjectCache();
        }
    }