Genesis Title Toggle - Version 1.8.0

Version Description

  • Added support for all StudioPress child themes
  • Added be_title_toggle_remove action for custom theme integration
Download this release

Release Info

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

Code changes from version 1.7.2 to 1.8.0

Files changed (2) hide show
  1. genesis-title-toggle.php +92 -16
  2. readme.txt +13 -5
genesis-title-toggle.php CHANGED
@@ -2,10 +2,10 @@
2
  /**
3
  * Plugin Name: Genesis Title Toggle
4
  * Plugin URI: http://www.billerickson.net/
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
  *
@@ -72,12 +72,13 @@ class BE_Title_Toggle {
72
  add_action( 'add_meta_boxes', array( $this, 'metabox_register' ) );
73
  add_action( 'save_post', array( $this, 'metabox_save' ), 1, 2 );
74
 
75
- // Show/hide Page Title - If using post formats, have to hook in later for some themes
76
- if ( current_theme_supports( 'post-formats' ) ) {
77
- add_action( 'genesis_before_post', array( $this, 'title_toggle' ), 20 );
 
 
 
78
  add_action( 'genesis_before_entry', array( $this, 'title_toggle' ), 20 );
79
- } else {
80
- add_action( 'genesis_before', array( $this, 'title_toggle' ) );
81
  }
82
 
83
  // Site title as h1
@@ -313,10 +314,7 @@ class BE_Title_Toggle {
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' );
317
- remove_action( 'genesis_entry_header', '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
@@ -325,14 +323,92 @@ class BE_Title_Toggle {
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' );
329
- remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
330
- remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
331
- remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
332
  }
333
  }
334
  }
335
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
336
  /**
337
  * Make Site Title an h1 on homepage
338
  *
2
  /**
3
  * Plugin Name: Genesis Title Toggle
4
  * Plugin URI: http://www.billerickson.net/
5
+ * Description: When using the Genesis Theme framework, this plugin allows you to turn on/off page titles on a per page basis, and set sitewide defaults from Theme Settings.
6
  * Author: Bill Erickson
7
+ * Author URI: https://www.billerickson.net
8
+ * Version: 1.8.0
9
  * Text Domain: genesis-title-toggle
10
  * Domain Path: languages
11
  *
72
  add_action( 'add_meta_boxes', array( $this, 'metabox_register' ) );
73
  add_action( 'save_post', array( $this, 'metabox_save' ), 1, 2 );
74
 
75
+ // Show/hide Page Title
76
+ add_action( 'genesis_meta', array( $this, 'title_toggle' ), 20 );
77
+
78
+ // If theme supports post formats, run later
79
+ if( current_theme_supports( 'post-formats' ) ) {
80
+ add_action( 'genesis_before_post', array( $this, 'title_toggle' ), 20 );
81
  add_action( 'genesis_before_entry', array( $this, 'title_toggle' ), 20 );
 
 
82
  }
83
 
84
  // Site title as h1
314
 
315
  // If override is empty, get rid of that title
316
  if ( empty( $override ) ) {
317
+ $this->remove_title();
 
 
 
318
  }
319
 
320
  // If titles are turned on by default, let's see if this specific one is turned off
323
 
324
  // If override has a value, the title's gotta go
325
  if ( !empty( $override ) ) {
326
+ $this->remove_title();
 
 
 
327
  }
328
  }
329
  }
330
 
331
+ /**
332
+ * Remove Title
333
+ *
334
+ * @since 1.8.0
335
+ */
336
+ function remove_title() {
337
+
338
+ // Theme specific code
339
+ $this->theme_specific();
340
+
341
+ // Remove post title
342
+ remove_action( 'genesis_post_title', 'genesis_do_post_title' );
343
+ remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
344
+
345
+ // Remove header markup
346
+ if( apply_filters( 'be_title_toggle_remove_markup', true ) ) {
347
+ remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
348
+ remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
349
+ }
350
+
351
+ }
352
+
353
+ /**
354
+ * Theme Specific Code
355
+ *
356
+ * @since 1.8.0
357
+ */
358
+ function theme_specific() {
359
+
360
+ // Custom themes can use this to disable the title if they've moved it
361
+ // @see https://github.com/billerickson/genesis-title-toggle/wiki#integrating-with-a-custom-theme
362
+ do_action( 'be_title_toggle_remove' );
363
+
364
+ if( ! defined( 'CHILD_THEME_NAME' ) )
365
+ return false;
366
+
367
+ switch( CHILD_THEME_NAME ) {
368
+
369
+ case 'Academy Pro':
370
+ remove_action( 'genesis_before_content_sidebar_wrap', 'genesis_do_post_title' );
371
+ break;
372
+
373
+ case 'Business Pro Theme':
374
+ remove_action( 'business_page_header', 'business_page_title', 10 );
375
+ break;
376
+
377
+ case 'Centric Theme':
378
+ if( is_page() ) {
379
+ add_action(
380
+ 'genesis_before',
381
+ function() {
382
+ remove_action( 'genesis_after_header', 'centric_open_post_title', 1 );
383
+ remove_action( 'genesis_after_header', 'genesis_do_post_title', 2 );
384
+ remove_action( 'genesis_after_header', 'centric_close_post_title', 3 );
385
+ },
386
+ 20
387
+ );
388
+ }
389
+ break;
390
+
391
+ case 'Interior Pro Theme':
392
+ remove_action( 'genesis_after_header', 'genesis_do_post_title' );
393
+ break;
394
+
395
+ case 'Showcase Pro':
396
+ if( has_post_thumbnail() ) {
397
+ add_action( 'genesis_after_header', function() {
398
+ add_filter( 'the_title', '__return_false' );
399
+ }, 7 );
400
+ add_action( 'genesis_after_header', function() {
401
+ remove_filter( 'the_title', '__return_false' );
402
+ }, 9 );
403
+ }
404
+ break;
405
+
406
+ case 'Studio Pro':
407
+ remove_action( 'studio_page_header', 'studio_page_title', 10 );
408
+ break;
409
+ }
410
+ }
411
+
412
  /**
413
  * Make Site Title an h1 on homepage
414
  *
readme.txt CHANGED
@@ -3,20 +3,24 @@ 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
 
11
  == Description ==
12
 
 
 
13
  This plugin lets you easily remove the page title from specific pages. Don't want "Home" at the top of your homepage? Activate, then edit the homepage and check "Hide".
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
 
21
 
22
  == Installation ==
@@ -40,6 +44,10 @@ Finally, if you're comfortable with code you can use the `be_title_toggle_post_t
40
 
41
  == Changelog ==
42
 
 
 
 
 
43
  = 1.7.1 =
44
  * Properly sanitize the metabox key before saving.
45
 
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.9
7
+ Stable tag: 1.8.0
8
+
9
+ This plugin ONLY works with the Genesis theme. Do not install if you are not using Genesis.
10
 
11
  Turn on/off page titles on a per page basis, and set sitewide defaults from Theme Settings. Must be using the Genesis theme.
12
 
13
  == Description ==
14
 
15
+ This plugin ONLY works with the Genesis theme. Do not install if you are not using Genesis.
16
+
17
  This plugin lets you easily remove the page title from specific pages. Don't want "Home" at the top of your homepage? Activate, then edit the homepage and check "Hide".
18
 
19
  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.
20
 
21
+ See [the wiki](https://github.com/billerickson/genesis-title-toggle/wiki) for information on extending the plugin:
22
+ - [Use on Posts or Custom Post Types](https://github.com/billerickson/genesis-title-toggle/wiki#use-on-posts-or-custom-post-types)
23
+ - [Integrate with Custom Theme](https://github.com/billerickson/Genesis-Title-Toggle/wiki#integrating-with-a-custom-theme)
24
 
25
 
26
  == Installation ==
44
 
45
  == Changelog ==
46
 
47
+ = 1.8.0 =
48
+ * Added support for all StudioPress child themes
49
+ * Added `be_title_toggle_remove` action for custom theme integration
50
+
51
  = 1.7.1 =
52
  * Properly sanitize the metabox key before saving.
53