CPTP_Module_Option::save_options PHP Метод

save_options() публичный Метод

public save_options ( )
    public function save_options()
    {
        if (empty($_POST['submit'])) {
            return false;
        }
        if (empty($_POST['_wpnonce'])) {
            return false;
        }
        if (!wp_verify_nonce($_POST['_wpnonce'], 'update-permalink')) {
            return false;
        }
        if (empty($_POST['_wp_http_referer'])) {
            return false;
        }
        if (false === strpos($_POST['_wp_http_referer'], 'options-permalink.php')) {
            return false;
        }
        $post_types = CPTP_Util::get_post_types();
        foreach ($post_types as $post_type) {
            $structure = trim(esc_attr($_POST[$post_type . '_structure']));
            // get setting
            // default permalink structure
            if (!$structure) {
                $structure = CPTP_DEFAULT_PERMALINK;
            }
            $structure = str_replace('//', '/', '/' . $structure);
            // first "/"
            // last "/"
            $lastString = substr(trim(esc_attr($_POST['permalink_structure'])), -1);
            $structure = rtrim($structure, '/');
            if ('/' == $lastString) {
                $structure = $structure . '/';
            }
            update_option($post_type . '_structure', $structure);
        }
        update_option('no_taxonomy_structure', !isset($_POST['no_taxonomy_structure']));
        update_option('add_post_type_for_tax', isset($_POST['add_post_type_for_tax']));
    }