• Resolved MarcGuay

    (@marcguay)


    I needed this feature in my version of CPT UI. Here’s a simple patch to add it. Hopefully it will be added to the released version, I don’t see a reason not to.

    Cheerios
    Marc

    Index: custom-post-type-ui.php
    ===================================================================
    --- custom-post-type-ui.php	(revision 651445)
    +++ custom-post-type-ui.php	(working copy)
    @@ -128,7 +128,7 @@
     				'capability_type' => $cpt_post_type["capability_type"],
     				'hierarchical' => get_disp_boolean($cpt_post_type["hierarchical"]),
     				'exclude_from_search' => $cpt_exclude_from_search,
    -				'rewrite' => array('slug' => $cpt_rewrite_slug),
    +				'rewrite' => array('slug' => $cpt_rewrite_slug, 'with_front' => $cpt_post_type["rewrite_with_front"] ),
     				'query_var' => get_disp_boolean($cpt_post_type["query_var"]),
     				'description' => esc_html($cpt_post_type["description"]),
     				'menu_position' => $cpt_menu_position,
    @@ -178,7 +178,7 @@
     				'label' => $cpt_label,
     				'show_ui' => get_disp_boolean($cpt_tax_type["show_ui"]),
     				'query_var' => get_disp_boolean($cpt_tax_type["query_var"]),
    -				'rewrite' => array('slug' => $cpt_rewrite_slug),
    +				'rewrite' => array('slug' => $cpt_rewrite_slug, 'with_front' => $cpt_tax_type["rewrite_with_front"] ),
     				'singular_label' => $cpt_singular_label,
     				'labels' => $cpt_labels
     			) );
    @@ -553,6 +553,7 @@
                         <th><?php _e('Show UI', 'cpt-plugin');?></th>
                         <th><?php _e('Hierarchical', 'cpt-plugin');?></th>
                         <th><?php _e('Rewrite', 'cpt-plugin');?></th>
    +                    <th><?php _e('Rewrite With Front', 'cpt-plugin' );?></th>
                         <th><?php _e('Rewrite Slug', 'cpt-plugin');?></th>
                         <th><?php _e('Total Published', 'cpt-plugin');?></th>
                         <th><?php _e('Total Drafts', 'cpt-plugin');?></th>
    @@ -568,6 +569,7 @@
                         <th><?php _e('Show UI', 'cpt-plugin');?></th>
                         <th><?php _e('Hierarchical', 'cpt-plugin');?></th>
                         <th><?php _e('Rewrite', 'cpt-plugin');?></th>
    +                    <th><?php _e('Rewrite With Front', 'cpt-plugin' );?></th>
                         <th><?php _e('Rewrite Slug', 'cpt-plugin');?></th>
                         <th><?php _e('Total Published', 'cpt-plugin');?></th>
                         <th><?php _e('Total Drafts', 'cpt-plugin');?></th>
    @@ -597,6 +599,7 @@
                     <td valign="top"><?php echo disp_boolean($cpt_post_type["show_ui"]); ?></td>
                     <td valign="top"><?php echo disp_boolean($cpt_post_type["hierarchical"]); ?></td>
                     <td valign="top"><?php echo disp_boolean($cpt_post_type["rewrite"]); ?></td>
    +                <td valign="top"><?php echo disp_boolean($cpt_post_type["rewrite_with_front"]); ?></td>
                     <td valign="top"><?php echo $rewrite_slug; ?></td>
                     <td valign="top"><?php echo $cpt_counts->publish; ?></td>
                     <td valign="top"><?php echo $cpt_counts->draft; ?></td>
    @@ -663,7 +666,7 @@
     						$custom_post_type .= 	'\'show_in_menu\' => ' .$cpt_show_in_menu .',';
     						$custom_post_type .= 	'\'capability_type\' => \''.$cpt_post_type["capability_type"].'\',';
     						$custom_post_type .= 	'\'hierarchical\' => '.disp_boolean($cpt_post_type["hierarchical"]).',';
    -						$custom_post_type .= 	'\'rewrite\' => array(\'slug\' => \'' .$cpt_post_type["rewrite_slug"]. '\'),';
    +						$custom_post_type .= 	'\'rewrite\' => array(\'slug\' => \'' .$cpt_post_type["rewrite_slug"]. '\', \'with_front\' => \'' .$cpt_post_type["rewrite_with_front"]. '\'),';
     						$custom_post_type .= 	'\'query_var\' => '. disp_boolean($cpt_post_type["query_var"]).',';
    
     						if ( $cpt_post_type["has_archive"] ) {
    @@ -822,6 +825,7 @@
                     <th><?php _e('Hierarchical', 'cpt-plugin');?></th>
                     <th><?php _e('Show UI', 'cpt-plugin');?></th>
                     <th><?php _e('Rewrite', 'cpt-plugin');?></th>
    +                <th><?php _e('Rewrite With Front', 'cpt-plugin');?></th>
                     <th><?php _e('Rewrite Slug', 'cpt-plugin');?></th>
                     </tr>
                 </thead>
    @@ -835,6 +839,7 @@
                     <th><?php _e('Hierarchical', 'cpt-plugin');?></th>
                     <th><?php _e('Show UI', 'cpt-plugin');?></th>
                     <th><?php _e('Rewrite', 'cpt-plugin');?></th>
    +                <th><?php _e('Rewrite With Front', 'cpt-plugin');?></th>
                     <th><?php _e('Rewrite Slug', 'cpt-plugin');?></th>
                     </tr>
                 </tfoot>
    @@ -869,6 +874,7 @@
                     <td valign="top"><?php echo disp_boolean($cpt_tax_type["hierarchical"]); ?></td>
                     <td valign="top"><?php echo disp_boolean($cpt_tax_type["show_ui"]); ?></td>
                     <td valign="top"><?php echo disp_boolean($cpt_tax_type["rewrite"]); ?></td>
    +                <td valign="top"><?php echo disp_boolean($cpt_tax_type["rewrite_with_front"]); ?></td>
                     <td valign="top"><?php echo $rewrite_slug; ?></td>
                 </tr>
             	<tr>
    @@ -905,7 +911,7 @@
                                     $custom_tax .= 	'\'label\' => \''.$cpt_label.'\',';
                                     $custom_tax .= 	'\'show_ui\' => '.disp_boolean($cpt_tax_type["show_ui"]).',';
                                     $custom_tax .= 	'\'query_var\' => '. disp_boolean($cpt_tax_type["query_var"]).',';
    -				$custom_tax .= 	'\'rewrite\' => array(\'slug\' => \'' .$cpt_tax_type["rewrite_slug"]. '\'),';
    +				$custom_tax .= 	'\'rewrite\' => array(\'slug\' => \'' .$cpt_tax_type["rewrite_slug"]. '\', \'with_front\' => \'' .$cpt_tax_type["rewrite_with_front"]. '\'),';
                                     $custom_tax .= 	'\'singular_label\' => \''.$cpt_singular_label.'\'';
                                     $custom_tax .= ') );';
    
    @@ -961,6 +967,7 @@
     	$cpt_capability = $cpt_options[$editType]["capability_type"];
     	$cpt_hierarchical = $cpt_options[$editType]["hierarchical"];
     	$cpt_rewrite = $cpt_options[$editType]["rewrite"];
    +    $cpt_rewrite_with_front = $cpt_options[$editType]["rewrite_with_front"];
     	$cpt_rewrite_slug = $cpt_options[$editType]["rewrite_slug"];
     	$cpt_query_var = $cpt_options[$editType]["query_var"];
     	$cpt_description = $cpt_options[$editType]["description"];
    @@ -996,6 +1003,7 @@
     	$cpt_tax_showui = $cpt_options[$editTax]["show_ui"];
     	$cpt_tax_query_var = $cpt_options[$editTax]["query_var"];
     	$cpt_tax_rewrite = $cpt_options[$editTax]["rewrite"];
    +	$cpt_tax_rewrite_with_front = $cpt_options[$editTax]["rewrite_with_front"];
     	$cpt_tax_rewrite_slug = $cpt_options[$editTax]["rewrite_slug"];
     	$cpt_tax_labels = $cpt_options[$editTax][0];
     	$cpt_post_types = $cpt_options[$editTax][1];
    @@ -1225,6 +1233,16 @@
                         </tr>
    
                         <tr valign="top">
    +                    <th scope="row"><?php _e('Rewrite With Front', 'cpt-plugin') ?></th>
    +                    <td>
    +                        <SELECT name="cpt_custom_post_type[rewrite_with_front]" tabindex="8">
    +                            <OPTION value="0" <?php If (isset($cpt_rewrite_with_front)) { If ($cpt_rewrite_with_front == 0 && $cpt_rewrite_with_front != '') { echo 'selected="selected"'; } } ?>>False</OPTION>
    +                            <OPTION value="1" <?php If (isset($cpt_rewrite_with_front)) { If ($cpt_rewrite_with_front == 1 || is_null($cpt_rewrite_with_front)) { echo 'selected="selected"'; } }Else{ echo 'selected="selected"'; } ?>>True</OPTION>
    +                        </SELECT> <a href="#" title="" style="cursor: help;">?</a> (default: True)
    +                    </td>
    +                    </tr>
    +
    +                    <tr valign="top">
                         <th scope="row"><?php _e('Custom Rewrite Slug', 'cpt-plugin') ?></th>
                         <td><input type="text" name="cpt_custom_post_type[rewrite_slug]" tabindex="9" value="<?php If (isset($cpt_rewrite_slug)) { echo esc_attr($cpt_rewrite_slug); } ?>" /> <a href="#" title="Custom Post Type Rewrite Slug" style="cursor: help;">?</a> (default: post type name)</td>
                         </tr>
    @@ -1469,6 +1487,15 @@
                         </tr>
    
                         <tr valign="top">
    +                    <th scope="row"><?php _e('Rewrite With Front', 'cpt-plugin') ?></th>
    +                    <td>
    +                        <SELECT name="cpt_custom_tax[rewrite_with_front]" tabindex="28">
    +                            <OPTION value="0" <?php If (isset($cpt_tax_rewrite_with_front)) { If ($cpt_tax_rewrite_with_front == 0 && $cpt_tax_rewrite_with_front != '') { echo 'selected="selected"'; } } ?>>False</OPTION>
    +                            <OPTION value="1" <?php If (isset($cpt_tax_rewrite_with_front)) { If ($cpt_tax_rewrite_with_front == 1 || is_null($cpt_tax_rewrite_with_front)) { echo 'selected="selected"'; } }Else{ echo 'selected="selected"'; } ?>>True</OPTION>
    +                        </SELECT> <a href="#" title="" style="cursor: help;">?</a> (default: True)
    +                    </td>
    +                    </tr><br />
    +                    <tr valign="top">
                         <th scope="row"><?php _e('Custom Rewrite Slug', 'cpt-plugin') ?></th>
                         <td><input type="text" name="cpt_custom_tax[rewrite_slug]" tabindex="9" value="<?php If (isset($cpt_tax_rewrite_slug)) { echo esc_attr($cpt_tax_rewrite_slug); } ?>" /> <a href="#" title="Custom Taxonomy Rewrite Slug" style="cursor: help;">?</a> (default: taxonomy name)</td>
                         </tr>

    https://www.ads-software.com/extend/plugins/custom-post-type-ui/

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Patch to add "rewrite=>with_front" functionality’ is closed to new replies.