Permalink
Browse files

Unify config section functions.

  • Loading branch information...
1 parent fb8e12b commit 1440ff15b056252d2cfddd8a85b99b270ca59ba0 @mgsisk committed Jan 28, 2013
Showing with 7 additions and 9 deletions.
  1. +7 −9 -/php/config.php
View
@@ -116,7 +116,7 @@ public function admin_init() {
add_settings_field( "{$k}_supports_miscellanea", __( 'Miscellanea', 'webcomic' ), array( $this, 'collection_supports_miscellanea' ), "{$k}-options", "{$k}-features", array( 'label_for' => 'webcomic_posts_revisions' ) );
add_settings_field( "{$k}_supports_taxonomies", __( 'Taxonomies', 'webcomic' ), array( $this, 'collection_supports_taxonomies' ), "{$k}-options", "{$k}-features", array( 'label_for' => 'webcomic_posts_taxonomy' ) );
- add_settings_section( "{$k}-permalinks", __( 'Permalink Settings', 'webcomic' ), array( $this, 'section_permalinks' ), "{$k}-options" );
+ add_settings_section( "{$k}-permalinks", __( 'Permalink Settings', 'webcomic' ), array( $this, 'section' ), "{$k}-options" );
add_settings_field( "{$k}_slug_archive", __( 'Archive', 'webcomic' ), array( $this, 'collection_slugs_archive' ), "{$k}-options", "{$k}-permalinks", array( 'label_for' => 'webcomic_slugs_archive' ) );
add_settings_field( "{$k}_slug_webcomic", __( 'Webcomics', 'webcomic' ), array( $this, 'collection_slugs_webcomic' ), "{$k}-options", "{$k}-permalinks", array( 'label_for' => 'webcomic_slugs_webcomic' ) );
add_settings_field( "{$k}_slug_storyline", __( 'Storylines', 'webcomic' ), array( $this, 'collection_slugs_storyline' ), "{$k}-options", "{$k}-permalinks", array( 'label_for' => 'webcomic_slugs_storyline' ) );
@@ -1151,16 +1151,14 @@ public function save( $options ) {
return ( isset( $_POST[ 'webcomic_general' ] ) or isset( $_POST[ 'webcomic_collection' ] ) ) ? self::$config : $options;
}
- /** Empty callback for add_settings_section(). */
- public function section(){}
-
- /** Permalink settings section.
+ /** Generic settings section callback.
*
- * If permalinks are still set to Default we need to warn users that
- * the permalink URL's won't actually work.
+ * Most sections don't include a description, but if permalinks are
+ * set to Default we need to warn users that the permalink URL's
+ * won't actually work.
*/
- public function section_permalinks() {
- if ( !get_option( 'permalink_structure' ) ) {
+ public function section( $args ) {
+ if ( preg_match( '/^webcomic\d+-permalinks$/', $args[ 'id' ] ) and !get_option( 'permalink_structure' ) ) {
echo '<p>', sprintf( __( "These URL's won't work unless you <a href='%s'>change the permalink setting</a> to something other than <em>Default</em>.", 'webcomic' ), admin_url( 'options-permalink.php' ) ), '</p>';
}
}

0 comments on commit 1440ff1

Please sign in to comment.