public function postTypeSettings()
    {
        // Add section
        add_settings_section(
            'olympus-permalinks',
            Translate::t('posttypehook.custom_permalinks'),
            [&$this,'postTypeSettingTitle'],
            'permalink'
        );

        // Flush all rewrite rules
        if (isset($_POST['flushpermalink'])) {
            flush_rewrite_rules();
        }

        // Special case: do not change post/page component
        if (in_array($this->slug, $this->reserved_slugs)) {
            return false;
        }

        // Option
        $opt = 'permalink_structure_'.$this->slug;

        // Check POST
        if (isset($_POST[$opt])) {
            $value = $_POST[$opt];
            Option::set($opt, $value);
        } else {
            $value = Option::get($opt, '/%'.$this->slug.'%-%post_id%');
        }

        // Define metabox title
        $title = $this->name.' <code>%'.$this->slug.'%</code>';

        // Add fields
        add_settings_field(
            $opt,
            $title,
            [$this, 'postTypeSettingFunc'],
            'permalink',
            'olympus-permalinks',
            [
                'name' => $opt,
                'value' => $value,
            ]
        );

        return true;
    }
public function postTypeSettings()
    {
        // Add section
        add_settings_section(
            'olympus-permalinks',
            Translate::t('posttypehook.custom_permalinks'),
            [&$this,'postTypeSettingTitle'],
            'permalink'
        );

        // Flush all rewrite rules
        if (isset($_POST['flushpermalink'])) {
            flush_rewrite_rules();
        }

        // Special case: do not change post/page component
        if (in_array($this->slug, $this->reserved_slugs)) {
            return false;
        }

        // Option
        $opt = 'permalink_structure_'.$this->slug;

        // Check POST
        if (isset($_POST[$opt])) {
            $value = $_POST[$opt];
            Option::set($opt, $value);
        } else {
            $value = Option::get($opt, '/%'.$this->slug.'%-%post_id%');
        }

        // Define metabox title
        $title = $this->name.' <code>%'.$this->slug.'%</code>';

        // Add fields
        add_settings_field(
            $opt,
            $title,
            [$this, 'postTypeSettingFunc'],
            'permalink',
            'olympus-permalinks',
            [
                'name' => $opt,
                'value' => $value,
            ]
        );

        return true;
    }
public function postTypeSettings ( ) { // Add section add_settings_section ( 'olympus-permalinks' , Translate :: t ( 'posttypehook.custom_permalinks' ) , [ & $ this , 'postTypeSettingTitle' ] , 'permalink' ) ; // Flush all rewrite rules if ( isset ( $ _POST [ 'flushpermalink' ] ) ) { flush_rewrite_rules ( ) ; } // Special case: do not change post/page component if ( in_array ( $ this -> slug , $ this -> reserved_slugs ) ) { return false ; } // Option $ opt = 'permalink_structure_' . $ this -> slug ; // Check POST if ( isset ( $ _POST [ $ opt ] ) ) { $ value = $ _POST [ $ opt ] ; Option :: set ( $ opt , $ value ) ; } else { $ value = Option :: get ( $ opt , '/%' . $ this -> slug . '%-%post_id%' ) ; } // Define metabox title $ title = $ this -> name . ' <code>%' . $ this -> slug . '%</code>' ; // Add fields add_settings_field ( $ opt , $ title , [ $ this , 'postTypeSettingFunc' ] , 'permalink' , 'olympus-permalinks' , [ 'name' => $ opt , 'value' => $ value , ] ) ; return true ; }
Hook building custom options in Permalink settings page.
Hook building custom options in Permalink settings page .