Genesis Title Toggle - Version 1.7.1

Version Description

  • Properly sanitize the metabox key before saving.
Download this release

Release Info

Developer billerickson
Plugin Icon 128x128 Genesis Title Toggle
Version 1.7.1
Comparing to
See all releases

Code changes from version 1.7.0 to 1.7.1

Files changed (2) hide show
  1. genesis-title-toggle.php +37 -37
  2. readme.txt +16 -13
genesis-title-toggle.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: Turn on/off page titles on a per page basis, and set sitewide defaults from Theme Settings. Must be using the Genesis theme.
6
  * Author: Bill Erickson
7
  * Author URI: http://www.billerickson.net
8
- * Version: 1.7.0
9
  * Text Domain: genesis-title-toggle
10
  * Domain Path: languages
11
  *
@@ -50,14 +50,14 @@ class BE_Title_Toggle {
50
  register_activation_hook( __FILE__, array( $this, 'activation_hook' ) );
51
 
52
  // Bootstrap and go
53
- add_action( 'init', array( $this, 'init' ) );
54
  }
55
 
56
  /**
57
  * Initialize the plugin.
58
  *
59
  * @since 1.0.0
60
- */
61
  function init() {
62
 
63
  // Translations
@@ -79,11 +79,11 @@ class BE_Title_Toggle {
79
  } else {
80
  add_action( 'genesis_before', array( $this, 'title_toggle' ) );
81
  }
82
-
83
  // Site title as h1
84
  add_filter( 'genesis_site_title_wrap', array( $this, 'site_title_h1' ) );
85
  }
86
-
87
  /**
88
  * Activation Hook - Confirm site is using Genesis
89
  *
@@ -96,7 +96,7 @@ class BE_Title_Toggle {
96
  wp_die( sprintf( __( 'Sorry, you can&rsquo;t activate unless you have installed <a href="%s">Genesis</a>', 'genesis-title-toggle' ), 'http://www.billerickson.net/get-genesis' ) );
97
  }
98
  }
99
-
100
  /**
101
  * Sitewide Setting - Register Defaults
102
  *
@@ -113,8 +113,8 @@ class BE_Title_Toggle {
113
  }
114
  return $defaults;
115
  }
116
-
117
- /**
118
  * Sitewide Setting - Sanitization
119
  *
120
  * @since 1.0.0
@@ -127,10 +127,10 @@ class BE_Title_Toggle {
127
  foreach ( $post_types as $post_type ) {
128
  $fields[] = 'be_title_toggle_' . $post_type;
129
  }
130
-
131
- genesis_add_option_filter( 'one_zero', GENESIS_SETTINGS_FIELD, $fields );
132
  }
133
-
134
  /**
135
  * Sitewide Setting - Register Metabox
136
  *
@@ -142,11 +142,11 @@ class BE_Title_Toggle {
142
 
143
  add_meta_box( 'be-title-toggle', __( 'Title Toggle', 'genesis-title-toggle' ), array( $this, 'settings_render_metabox' ), $_genesis_theme_settings_pagehook, 'main', 'high' );
144
  }
145
-
146
  /**
147
  * Sitewide Setting - Create Metabox
148
  *
149
- * @since 1.0.0
150
  * @link http://www.billerickson.net/genesis-theme-options/
151
  */
152
  function settings_render_metabox() {
@@ -196,7 +196,7 @@ class BE_Title_Toggle {
196
  $hide = !empty( $hide ) ? true : false;
197
  $show = get_post_meta( get_the_ID(), 'be_title_toggle_show', true );
198
  $show = !empty( $show ) ? true : false;
199
-
200
  // Security nonce
201
  wp_nonce_field( 'be_title_toggle', 'be_title_toggle_nonce' );
202
 
@@ -206,39 +206,39 @@ class BE_Title_Toggle {
206
 
207
  // Hide by default
208
  printf( '<label for="be_title_toggle_show">%s</label>', __( 'Show Title', 'genesis-title-toggle' ) );
209
-
210
  echo '<input type="checkbox" id="be_title_toggle_show" name="be_title_toggle_show" ' . checked( true , $show, false ) . ' style="margin:0 20px 0 10px;">';
211
-
212
  printf( '<span style="color:#999;">%s</span>', __( 'By default, this post type is set to remove titles. This checkbox lets you show this specific page&rsquo;s title.', 'genesis-title-toggle' ) );
213
-
214
  echo '<input type="hidden" name="be_title_toggle_key" value="show">';
215
 
216
  } else {
217
-
218
  // Show by default
219
  printf( '<label for="be_title_toggle_hide">%s</label>', __( 'Hide Title', 'genesis-title-toggle' ) );
220
-
221
  echo '<input type="checkbox" id="be_title_toggle_hide" name="be_title_toggle_hide" ' . checked( true , $hide, false ) . ' style="margin:0 20px 0 10px;">';
222
-
223
  printf( '<span style="color:#999;">%s</span>', __( 'By default, this post type is set to display titles. This checkbox lets you hide this specific page&rsquo;s title.', 'genesis-title-toggle' ) );
224
-
225
  echo '<input type="hidden" name="be_title_toggle_key" value="hide">';
226
  }
227
 
228
  echo '</p>';
229
-
230
  // Site title as h1
231
  if( get_the_ID() == get_option( 'page_on_front' ) ) {
232
 
233
  $h1_site_title = get_post_meta( get_the_ID(), 'be_title_toggle_site_title_h1', true );
234
  $h1_site_title = !empty( $h1_site_title ) ? true : false;
235
-
236
  echo '<p style="padding-top:10px;">';
237
  printf( '<label for="be_title_toggle_site_title_h1">%s</label>', __( 'h1 Site Title', 'genesis-title-toggle' ) );
238
  echo '<input type="checkbox" id="be_title_toggle_site_title_h1" name="be_title_toggle_site_title_h1" ' . checked( true , $h1_site_title, false ) . ' style="margin:0 20px 0 10px;">';
239
  printf( '<span style="color:#999;">%s</span>', __( 'Make the site title in header an h1. This is HIGHLY recommended if you are removing the page title.', 'genesis-title-toggle' ) );
240
  echo '</p>';
241
-
242
  }
243
  }
244
 
@@ -271,7 +271,7 @@ class BE_Title_Toggle {
271
  }
272
 
273
  // Which key do we use
274
- $key = 'be_title_toggle_' . $_POST['be_title_toggle_key'];
275
 
276
  // Either save or delete they post meta
277
  if ( isset( $_POST[ $key ] ) ) {
@@ -279,7 +279,7 @@ class BE_Title_Toggle {
279
  } else {
280
  delete_post_meta( $post_id, $key );
281
  }
282
-
283
  // Site title option for front page
284
  if( $post_id == get_option( 'page_on_front' ) ) {
285
  if( isset( $_POST['be_title_toggle_site_title_h1'] ) ) {
@@ -289,7 +289,7 @@ class BE_Title_Toggle {
289
  }
290
  }
291
  }
292
-
293
  /**
294
  * Logic that determines if we should show/hide the title.
295
  *
@@ -300,17 +300,17 @@ class BE_Title_Toggle {
300
  // Make sure we're on the single page
301
  if ( !is_singular() )
302
  return;
303
-
304
- global $post;
305
  $post_type = get_post_type( $post );
306
-
307
  // See if post type has pages turned off by default
308
  $default = genesis_get_option( 'be_title_toggle_' . $post_type );
309
-
310
  // If titles are turned off by default, let's check for an override before removing
311
  if ( !empty( $default ) ) {
312
  $override = get_post_meta( $post->ID, 'be_title_toggle_show', true );
313
-
314
  // If override is empty, get rid of that title
315
  if ( empty( $override ) ) {
316
  remove_action( 'genesis_post_title', 'genesis_do_post_title' );
@@ -318,11 +318,11 @@ class BE_Title_Toggle {
318
  remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
319
  remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
320
  }
321
-
322
  // If titles are turned on by default, let's see if this specific one is turned off
323
  } else {
324
  $override = get_post_meta( $post->ID, 'be_title_toggle_hide', true );
325
-
326
  // If override has a value, the title's gotta go
327
  if ( !empty( $override ) ) {
328
  remove_action( 'genesis_post_title', 'genesis_do_post_title' );
@@ -332,7 +332,7 @@ class BE_Title_Toggle {
332
  }
333
  }
334
  }
335
-
336
  /**
337
  * Make Site Title an h1 on homepage
338
  *
@@ -348,9 +348,9 @@ class BE_Title_Toggle {
348
  if( $show_as_h1 )
349
  $wrap = 'h1';
350
  }
351
-
352
  return $wrap;
353
-
354
  }
355
  }
356
 
5
  * Description: Turn on/off page titles on a per page basis, and set sitewide defaults from Theme Settings. Must be using the Genesis theme.
6
  * Author: Bill Erickson
7
  * Author URI: http://www.billerickson.net
8
+ * Version: 1.7.1
9
  * Text Domain: genesis-title-toggle
10
  * Domain Path: languages
11
  *
50
  register_activation_hook( __FILE__, array( $this, 'activation_hook' ) );
51
 
52
  // Bootstrap and go
53
+ add_action( 'init', array( $this, 'init' ) );
54
  }
55
 
56
  /**
57
  * Initialize the plugin.
58
  *
59
  * @since 1.0.0
60
+ */
61
  function init() {
62
 
63
  // Translations
79
  } else {
80
  add_action( 'genesis_before', array( $this, 'title_toggle' ) );
81
  }
82
+
83
  // Site title as h1
84
  add_filter( 'genesis_site_title_wrap', array( $this, 'site_title_h1' ) );
85
  }
86
+
87
  /**
88
  * Activation Hook - Confirm site is using Genesis
89
  *
96
  wp_die( sprintf( __( 'Sorry, you can&rsquo;t activate unless you have installed <a href="%s">Genesis</a>', 'genesis-title-toggle' ), 'http://www.billerickson.net/get-genesis' ) );
97
  }
98
  }
99
+
100
  /**
101
  * Sitewide Setting - Register Defaults
102
  *
113
  }
114
  return $defaults;
115
  }
116
+
117
+ /**
118
  * Sitewide Setting - Sanitization
119
  *
120
  * @since 1.0.0
127
  foreach ( $post_types as $post_type ) {
128
  $fields[] = 'be_title_toggle_' . $post_type;
129
  }
130
+
131
+ genesis_add_option_filter( 'one_zero', GENESIS_SETTINGS_FIELD, $fields );
132
  }
133
+
134
  /**
135
  * Sitewide Setting - Register Metabox
136
  *
142
 
143
  add_meta_box( 'be-title-toggle', __( 'Title Toggle', 'genesis-title-toggle' ), array( $this, 'settings_render_metabox' ), $_genesis_theme_settings_pagehook, 'main', 'high' );
144
  }
145
+
146
  /**
147
  * Sitewide Setting - Create Metabox
148
  *
149
+ * @since 1.0.0
150
  * @link http://www.billerickson.net/genesis-theme-options/
151
  */
152
  function settings_render_metabox() {
196
  $hide = !empty( $hide ) ? true : false;
197
  $show = get_post_meta( get_the_ID(), 'be_title_toggle_show', true );
198
  $show = !empty( $show ) ? true : false;
199
+
200
  // Security nonce
201
  wp_nonce_field( 'be_title_toggle', 'be_title_toggle_nonce' );
202
 
206
 
207
  // Hide by default
208
  printf( '<label for="be_title_toggle_show">%s</label>', __( 'Show Title', 'genesis-title-toggle' ) );
209
+
210
  echo '<input type="checkbox" id="be_title_toggle_show" name="be_title_toggle_show" ' . checked( true , $show, false ) . ' style="margin:0 20px 0 10px;">';
211
+
212
  printf( '<span style="color:#999;">%s</span>', __( 'By default, this post type is set to remove titles. This checkbox lets you show this specific page&rsquo;s title.', 'genesis-title-toggle' ) );
213
+
214
  echo '<input type="hidden" name="be_title_toggle_key" value="show">';
215
 
216
  } else {
217
+
218
  // Show by default
219
  printf( '<label for="be_title_toggle_hide">%s</label>', __( 'Hide Title', 'genesis-title-toggle' ) );
220
+
221
  echo '<input type="checkbox" id="be_title_toggle_hide" name="be_title_toggle_hide" ' . checked( true , $hide, false ) . ' style="margin:0 20px 0 10px;">';
222
+
223
  printf( '<span style="color:#999;">%s</span>', __( 'By default, this post type is set to display titles. This checkbox lets you hide this specific page&rsquo;s title.', 'genesis-title-toggle' ) );
224
+
225
  echo '<input type="hidden" name="be_title_toggle_key" value="hide">';
226
  }
227
 
228
  echo '</p>';
229
+
230
  // Site title as h1
231
  if( get_the_ID() == get_option( 'page_on_front' ) ) {
232
 
233
  $h1_site_title = get_post_meta( get_the_ID(), 'be_title_toggle_site_title_h1', true );
234
  $h1_site_title = !empty( $h1_site_title ) ? true : false;
235
+
236
  echo '<p style="padding-top:10px;">';
237
  printf( '<label for="be_title_toggle_site_title_h1">%s</label>', __( 'h1 Site Title', 'genesis-title-toggle' ) );
238
  echo '<input type="checkbox" id="be_title_toggle_site_title_h1" name="be_title_toggle_site_title_h1" ' . checked( true , $h1_site_title, false ) . ' style="margin:0 20px 0 10px;">';
239
  printf( '<span style="color:#999;">%s</span>', __( 'Make the site title in header an h1. This is HIGHLY recommended if you are removing the page title.', 'genesis-title-toggle' ) );
240
  echo '</p>';
241
+
242
  }
243
  }
244
 
271
  }
272
 
273
  // Which key do we use
274
+ $key = 'show' == esc_attr( $_POST['be_title_toggle_key'] ) ? 'be_title_toggle_show' : 'be_title_toggle_hide';
275
 
276
  // Either save or delete they post meta
277
  if ( isset( $_POST[ $key ] ) ) {
279
  } else {
280
  delete_post_meta( $post_id, $key );
281
  }
282
+
283
  // Site title option for front page
284
  if( $post_id == get_option( 'page_on_front' ) ) {
285
  if( isset( $_POST['be_title_toggle_site_title_h1'] ) ) {
289
  }
290
  }
291
  }
292
+
293
  /**
294
  * Logic that determines if we should show/hide the title.
295
  *
300
  // Make sure we're on the single page
301
  if ( !is_singular() )
302
  return;
303
+
304
+ global $post;
305
  $post_type = get_post_type( $post );
306
+
307
  // See if post type has pages turned off by default
308
  $default = genesis_get_option( 'be_title_toggle_' . $post_type );
309
+
310
  // If titles are turned off by default, let's check for an override before removing
311
  if ( !empty( $default ) ) {
312
  $override = get_post_meta( $post->ID, 'be_title_toggle_show', true );
313
+
314
  // If override is empty, get rid of that title
315
  if ( empty( $override ) ) {
316
  remove_action( 'genesis_post_title', 'genesis_do_post_title' );
318
  remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
319
  remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
320
  }
321
+
322
  // If titles are turned on by default, let's see if this specific one is turned off
323
  } else {
324
  $override = get_post_meta( $post->ID, 'be_title_toggle_hide', true );
325
+
326
  // If override has a value, the title's gotta go
327
  if ( !empty( $override ) ) {
328
  remove_action( 'genesis_post_title', 'genesis_do_post_title' );
332
  }
333
  }
334
  }
335
+
336
  /**
337
  * Make Site Title an h1 on homepage
338
  *
348
  if( $show_as_h1 )
349
  $wrap = 'h1';
350
  }
351
+
352
  return $wrap;
353
+
354
  }
355
  }
356
 
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Genesis Title Toggle ===
2
  Contributors: billerickson
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=EDYM76U6BTE5L
4
- Tags: genesis, genesiswp, title,
5
  Requires at least: 3.0
6
- Tested up to: 4.3.1
7
- Stable tag: 1.7.0
8
 
9
  Turn on/off page titles on a per page basis, and set sitewide defaults from Theme Settings. Must be using the Genesis theme.
10
 
@@ -14,7 +14,7 @@ This plugin lets you easily remove the page title from specific pages. Don't wan
14
 
15
  You can also set sitewide defaults. If you don't want page titles on any pages, go to Genesis > Theme Settings > Title Toggle and check the appropriate box. Once a post type has the default set to remove, when editing a page you can selectively turn on that page's title.
16
 
17
- Finally, if you're comfortable with code you can use the `be_title_toggle_post_types` filter to change the post types this applies to (it only applies to pages by default).
18
 
19
  [Support Forum](https://github.com/billerickson/Genesis-Title-Toggle/issues)
20
 
@@ -40,42 +40,45 @@ Finally, if you're comfortable with code you can use the `be_title_toggle_post_t
40
 
41
  == Changelog ==
42
 
 
 
 
43
  = 1.7.0 =
44
  * Added option to make site title an h1 when editing homepage. More information: http://www.billerickson.net/genesis-h1-front-page/
45
 
46
- = 1.6.2 =
47
  * Fix issue when you have all titles disabled by default
48
 
49
- = 1.6.1 =
50
  * Fix issue with HTML5 themes using post formats
51
 
52
  = 1.6 =
53
  * Updated the metabox code to prevent conflicts with other plugins
54
  * General refresh of the code to make it cleaner and easier to read
55
 
56
- = 1.5 =
57
  * Add HTML5 Support for Genesis 2.0
58
 
59
- = 1.4 =
60
  * Updated to work with all StudioPress themes with post formats
61
 
62
  = 1.3 =
63
  * Updated the metabox library to latest version
64
 
65
- = 1.2.3 =
66
  * The fix in 1.2.2 didn't make it for some reason, so re-patching it.
67
 
68
  = 1.2.2 =
69
  * Minor modification to the way it detects Genesis. Upgrading is only necessary if you're using Premise
70
 
71
- = 1.2.1 =
72
  * Typo in 1.2 caused the plugin to crash. I'm so sorry!
73
 
74
  = 1.2 =
75
  * Fixed an issue where if you weren't running Genesis, site breaks (ex: WP Touch changes themes when on mobile device)
76
 
77
- = 1.1 =
78
  * Added support for localization and a German language pack. Thanks David Decker.
79
 
80
- = 1.0 =
81
- * Initial release
1
  === Genesis Title Toggle ===
2
  Contributors: billerickson
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=EDYM76U6BTE5L
4
+ Tags: genesis, genesiswp, title,
5
  Requires at least: 3.0
6
+ Tested up to: 4.7.0
7
+ Stable tag: 1.7.1
8
 
9
  Turn on/off page titles on a per page basis, and set sitewide defaults from Theme Settings. Must be using the Genesis theme.
10
 
14
 
15
  You can also set sitewide defaults. If you don't want page titles on any pages, go to Genesis > Theme Settings > Title Toggle and check the appropriate box. Once a post type has the default set to remove, when editing a page you can selectively turn on that page's title.
16
 
17
+ Finally, if you're comfortable with code you can use the `be_title_toggle_post_types` filter to change the post types this applies to (it only applies to pages by default).
18
 
19
  [Support Forum](https://github.com/billerickson/Genesis-Title-Toggle/issues)
20
 
40
 
41
  == Changelog ==
42
 
43
+ = 1.7.1 =
44
+ * Properly sanitize the metabox key before saving.
45
+
46
  = 1.7.0 =
47
  * Added option to make site title an h1 when editing homepage. More information: http://www.billerickson.net/genesis-h1-front-page/
48
 
49
+ = 1.6.2 =
50
  * Fix issue when you have all titles disabled by default
51
 
52
+ = 1.6.1 =
53
  * Fix issue with HTML5 themes using post formats
54
 
55
  = 1.6 =
56
  * Updated the metabox code to prevent conflicts with other plugins
57
  * General refresh of the code to make it cleaner and easier to read
58
 
59
+ = 1.5 =
60
  * Add HTML5 Support for Genesis 2.0
61
 
62
+ = 1.4 =
63
  * Updated to work with all StudioPress themes with post formats
64
 
65
  = 1.3 =
66
  * Updated the metabox library to latest version
67
 
68
+ = 1.2.3 =
69
  * The fix in 1.2.2 didn't make it for some reason, so re-patching it.
70
 
71
  = 1.2.2 =
72
  * Minor modification to the way it detects Genesis. Upgrading is only necessary if you're using Premise
73
 
74
+ = 1.2.1 =
75
  * Typo in 1.2 caused the plugin to crash. I'm so sorry!
76
 
77
  = 1.2 =
78
  * Fixed an issue where if you weren't running Genesis, site breaks (ex: WP Touch changes themes when on mobile device)
79
 
80
+ = 1.1 =
81
  * Added support for localization and a German language pack. Thanks David Decker.
82
 
83
+ = 1.0 =
84
+ * Initial release