Hide Title - Version 1.0.4

Version Description

  • Now compatible with latest versions of WordPress
  • PHP 4 is no longer supported.
Download this release

Release Info

Developer kraftbj
Plugin Icon wp plugin Hide Title
Version 1.0.4
Comparing to
See all releases

Code changes from version 1.0.2 to 1.0.4

Files changed (2) hide show
  1. dojo-digital-hide-title.php +74 -81
  2. readme.txt +27 -12
dojo-digital-hide-title.php CHANGED
@@ -3,30 +3,25 @@
3
  Plugin Name: Hide Title
4
  Plugin URI: http://dojodigital.com
5
  Description: Allows authors to hide the title tag on single pages and posts via the edit post screen.
6
- Version: 1.0.2
7
- Author: Randall Runnels
8
  Author URI: http://dojodigital.com
9
  */
10
-
11
  if ( !class_exists( 'DojoDigitalHideTitle' ) ) {
12
-
13
  class DojoDigitalHideTitle {
14
-
15
  private $slug = 'dojodigital_toggle_title';
16
  private $selector = '.entry-title';
17
  private $title;
18
  private $afterHead = false;
19
-
20
- /**
21
- * PHP 4 Compatible Constructor
22
- */
23
- function DojoDigitalHideTitle(){ $this->__construct(); }
24
-
25
  /**
26
  * PHP 5 Constructor
27
- */
28
  function __construct(){
29
-
30
  add_action( 'add_meta_boxes', array( $this, 'add_box' ) );
31
  add_action( 'save_post', array( $this, 'on_save' ) );
32
  add_action( 'delete_post', array( $this, 'on_delete' ) );
@@ -35,121 +30,121 @@ if ( !class_exists( 'DojoDigitalHideTitle' ) ) {
35
  add_action( 'wp_enqueue_scripts', array( $this, 'load_scripts' ) );
36
 
37
  } // __construct()
38
-
39
-
40
  private function is_hidden( ){
41
-
42
  if( is_singular() ){
43
-
44
  global $post;
45
-
46
  $toggle = get_post_meta( $post->ID, $this->slug, true );
47
-
48
  if( (bool) $toggle ){
49
  return true;
50
  } else {
51
  return false;
52
- }
53
-
54
  } else {
55
- return false;
56
  }
57
-
58
  } // is_hidden()
59
-
60
-
61
  public function head_insert(){
62
-
63
  if( $this->is_hidden() ){ ?>
64
  <!-- Dojo Digital Hide Title -->
65
  <script type="text/javascript">
66
  jQuery(document).ready(function($){
67
-
68
- if( $('<?php echo $this->selector; ?>') ) {
69
  $('<?php echo $this->selector; ?> span.<?php echo $this->slug; ?>').parents('<?php echo $this->selector; ?>:first').hide();
70
  } else {
71
  $('h1 span.<?php echo $this->slug; ?>').parents('h1:first').hide();
72
  $('h2 span.<?php echo $this->slug; ?>').parents('h2:first').hide();
73
  }
74
-
75
  });
76
  </script>
77
  <noscript><style type="text/css"> <?php echo $this->selector; ?> { display:none !important; }</style></noscript>
78
  <!-- END Dojo Digital Hide Title -->
79
-
80
  <?php }
81
-
82
  // Indicate that the header has run so we can hopefully prevent adding span tags to the meta attributes, etc.
83
  $this->afterHead = true;
84
-
85
  } // head_insert()
86
-
87
-
88
  public function add_box(){
89
-
90
  $posttypes = array( 'post', 'page' );
91
-
92
  foreach ( $posttypes as $posttype ){
93
  add_meta_box( $this->slug, 'Hide Title', array( $this, 'build_box' ), $posttype, 'side' );
94
  }
95
-
96
  } // add_box()
97
-
98
-
99
  public function build_box( $post ){
100
-
101
  $value = get_post_meta( $post->ID, $this->slug, true );
102
-
103
  $checked = '';
104
-
105
  if( (bool) $value ){ $checked = ' checked="checked"'; }
106
-
107
  wp_nonce_field( $this->slug . '_dononce', $this->slug . '_noncename' );
108
-
109
  ?>
110
  <label><input type="checkbox" name="<?php echo $this->slug; ?>" <?php echo $checked; ?> /> Hide the title on singular page views.</label>
111
  <?php
112
-
113
  } // build_box()
114
-
115
-
116
  public function wrap_title( $content ){
117
-
118
  if( $this->is_hidden() && $content == $this->title && $this->afterHead ){
119
  $content = '<span class="' . $this->slug . '">' . $content . '</span>';
120
  }
121
-
122
- return $content;
123
-
124
  } // wrap_title()
125
-
126
-
127
  public function load_scripts(){
128
-
129
-
130
- // Grab the title early in case it's overridden later by extra loops.
131
  global $post;
132
  $this->title = $post->post_title;
133
-
134
- if( $this->is_hidden() ){
135
  wp_enqueue_script( 'jquery' );
136
-
137
  }
138
-
139
  } // load_scripts()
140
-
141
-
142
  public function on_save( $postID ){
143
-
144
  if ( ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
145
  || !isset( $_POST[ $this->slug . '_noncename' ] )
146
  || !wp_verify_nonce( $_POST[ $this->slug . '_noncename' ], $this->slug . '_dononce' ) ) {
147
  return $postID;
148
  }
149
-
150
  $old = get_post_meta( $postID, $this->slug, true );
151
  $new = $_POST[ $this->slug ] ;
152
-
153
  if( $old ){
154
  if ( is_null( $new ) ){
155
  delete_post_meta( $postID, $this->slug );
@@ -159,31 +154,29 @@ if ( !class_exists( 'DojoDigitalHideTitle' ) ) {
159
  } elseif ( !is_null( $new ) ){
160
  add_post_meta( $postID, $this->slug, $new, true );
161
  }
162
-
163
  return $postID;
164
-
165
  } // on_save()
166
-
167
-
168
  public function on_delete( $postID ){
169
  delete_post_meta( $postID, $this->slug );
170
  return $postID;
171
  } // on_delete()
172
-
173
-
174
  public function set_selector( $selector ){
175
-
176
  if( isset( $selector ) && is_string( $selector ) ){
177
  $this->selector = $selector;
178
  }
179
-
180
  } // set_selector()
181
-
182
-
183
  } // DojoDigitalHideTitle
184
-
185
- $DojoDigitalHideTitle = new DojoDigitalHideTitle();
186
-
187
- } // !class_exists( 'DojoDigitalHideTitle' )
188
-
189
- ?>
3
  Plugin Name: Hide Title
4
  Plugin URI: http://dojodigital.com
5
  Description: Allows authors to hide the title tag on single pages and posts via the edit post screen.
6
+ Version: 1.0.4
7
+ Author: Brandon Kraft & Randall Runnels
8
  Author URI: http://dojodigital.com
9
  */
10
+
11
  if ( !class_exists( 'DojoDigitalHideTitle' ) ) {
12
+
13
  class DojoDigitalHideTitle {
14
+
15
  private $slug = 'dojodigital_toggle_title';
16
  private $selector = '.entry-title';
17
  private $title;
18
  private $afterHead = false;
19
+
 
 
 
 
 
20
  /**
21
  * PHP 5 Constructor
22
+ */
23
  function __construct(){
24
+
25
  add_action( 'add_meta_boxes', array( $this, 'add_box' ) );
26
  add_action( 'save_post', array( $this, 'on_save' ) );
27
  add_action( 'delete_post', array( $this, 'on_delete' ) );
30
  add_action( 'wp_enqueue_scripts', array( $this, 'load_scripts' ) );
31
 
32
  } // __construct()
33
+
34
+
35
  private function is_hidden( ){
36
+
37
  if( is_singular() ){
38
+
39
  global $post;
40
+
41
  $toggle = get_post_meta( $post->ID, $this->slug, true );
42
+
43
  if( (bool) $toggle ){
44
  return true;
45
  } else {
46
  return false;
47
+ }
48
+
49
  } else {
50
+ return false;
51
  }
52
+
53
  } // is_hidden()
54
+
55
+
56
  public function head_insert(){
57
+
58
  if( $this->is_hidden() ){ ?>
59
  <!-- Dojo Digital Hide Title -->
60
  <script type="text/javascript">
61
  jQuery(document).ready(function($){
62
+
63
+ if( $('<?php echo $this->selector; ?>').length != 0 ) {
64
  $('<?php echo $this->selector; ?> span.<?php echo $this->slug; ?>').parents('<?php echo $this->selector; ?>:first').hide();
65
  } else {
66
  $('h1 span.<?php echo $this->slug; ?>').parents('h1:first').hide();
67
  $('h2 span.<?php echo $this->slug; ?>').parents('h2:first').hide();
68
  }
69
+
70
  });
71
  </script>
72
  <noscript><style type="text/css"> <?php echo $this->selector; ?> { display:none !important; }</style></noscript>
73
  <!-- END Dojo Digital Hide Title -->
74
+
75
  <?php }
76
+
77
  // Indicate that the header has run so we can hopefully prevent adding span tags to the meta attributes, etc.
78
  $this->afterHead = true;
79
+
80
  } // head_insert()
81
+
82
+
83
  public function add_box(){
84
+
85
  $posttypes = array( 'post', 'page' );
86
+
87
  foreach ( $posttypes as $posttype ){
88
  add_meta_box( $this->slug, 'Hide Title', array( $this, 'build_box' ), $posttype, 'side' );
89
  }
90
+
91
  } // add_box()
92
+
93
+
94
  public function build_box( $post ){
95
+
96
  $value = get_post_meta( $post->ID, $this->slug, true );
97
+
98
  $checked = '';
99
+
100
  if( (bool) $value ){ $checked = ' checked="checked"'; }
101
+
102
  wp_nonce_field( $this->slug . '_dononce', $this->slug . '_noncename' );
103
+
104
  ?>
105
  <label><input type="checkbox" name="<?php echo $this->slug; ?>" <?php echo $checked; ?> /> Hide the title on singular page views.</label>
106
  <?php
107
+
108
  } // build_box()
109
+
110
+
111
  public function wrap_title( $content ){
112
+
113
  if( $this->is_hidden() && $content == $this->title && $this->afterHead ){
114
  $content = '<span class="' . $this->slug . '">' . $content . '</span>';
115
  }
116
+
117
+ return $content;
118
+
119
  } // wrap_title()
120
+
121
+
122
  public function load_scripts(){
123
+
124
+
125
+ // Grab the title early in case it's overridden later by extra loops.
126
  global $post;
127
  $this->title = $post->post_title;
128
+
129
+ if( $this->is_hidden() ){
130
  wp_enqueue_script( 'jquery' );
131
+
132
  }
133
+
134
  } // load_scripts()
135
+
136
+
137
  public function on_save( $postID ){
138
+
139
  if ( ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
140
  || !isset( $_POST[ $this->slug . '_noncename' ] )
141
  || !wp_verify_nonce( $_POST[ $this->slug . '_noncename' ], $this->slug . '_dononce' ) ) {
142
  return $postID;
143
  }
144
+
145
  $old = get_post_meta( $postID, $this->slug, true );
146
  $new = $_POST[ $this->slug ] ;
147
+
148
  if( $old ){
149
  if ( is_null( $new ) ){
150
  delete_post_meta( $postID, $this->slug );
154
  } elseif ( !is_null( $new ) ){
155
  add_post_meta( $postID, $this->slug, $new, true );
156
  }
157
+
158
  return $postID;
159
+
160
  } // on_save()
161
+
162
+
163
  public function on_delete( $postID ){
164
  delete_post_meta( $postID, $this->slug );
165
  return $postID;
166
  } // on_delete()
167
+
168
+
169
  public function set_selector( $selector ){
170
+
171
  if( isset( $selector ) && is_string( $selector ) ){
172
  $this->selector = $selector;
173
  }
174
+
175
  } // set_selector()
176
+
177
+
178
  } // DojoDigitalHideTitle
179
+
180
+ $DojoDigitalHideTitle = new DojoDigitalHideTitle;
181
+
182
+ } // !class_exists( 'DojoDigitalHideTitle' )
 
 
readme.txt CHANGED
@@ -1,22 +1,22 @@
1
  === Hide Title ===
2
 
3
- Contributors: dojodigital
4
  Plugin Name: Hide Title
5
  Plugin URI: http://hidetitle.dojodigital.com/
6
  Tags: wp, title
7
  Author URI: http://dojodigital.com/
8
  Author: Dojo Digital
9
- Requires at least: 3.0
10
- Tested up to: 3.4.2
11
- Stable tag: 1.0.2
12
- Version: 1.0.2
13
 
14
  Allows authors to hide the title on single pages and posts via the edit post screen.
15
 
16
  == Description ==
17
 
18
  This plugin allows the author of a post or page to hide the title and it's containing HTML element from the single view ( is_singular() ).
19
-
20
  == Installation ==
21
 
22
  1. Upload the `hide-title` folder to the `/wp-content/plugins/` directory
@@ -26,7 +26,16 @@ This plugin allows the author of a post or page to hide the title and it's conta
26
 
27
  1. This Meta Box will be added to the Edit screen for pages & posts
28
 
29
- == Changelog ==
 
 
 
 
 
 
 
 
 
30
 
31
  = 1.0.2 =
32
 
@@ -38,7 +47,14 @@ This plugin allows the author of a post or page to hide the title and it's conta
38
  * Changed the jQuery to use a less brute force method of hiding the title.
39
  * Added a set_selector() method to allow end-users to specify the css selector to hide.
40
 
41
- == Upgrade Notice ==
 
 
 
 
 
 
 
42
 
43
  = 1.0.2 =
44
 
@@ -53,7 +69,7 @@ This plugin allows the author of a post or page to hide the title and it's conta
53
 
54
  = I upgraded to 1.0.2 and the plugin stopped working. Why? =
55
 
56
- It is possible that your theme does not have the wp_head function in it's header.php file. In general all themes are suppose to have it, and version 1.0.2 looks for it to prevent adding bad code to the `<head>` area of the page. If you have access to your theme file simply add `<?php wp_head(); ?>` to header.php just before the `</head>` tag. If not, this plugin will no longer be compatible with your theme.
57
 
58
  = Hey! This plugin is hiding things I don't want hidden! =
59
 
@@ -69,8 +85,7 @@ As noted in the comments, you'll need to replace the string `.your-selector` wit
69
 
70
  I could, but I'd like to avoid adding Yet Another Options Page if I can. If enough people request it though, I'll go ahead and bite the bullet.
71
 
 
72
 
 
73
 
74
-
75
-
76
-
1
  === Hide Title ===
2
 
3
+ Contributors: dojodigital, kraftbj
4
  Plugin Name: Hide Title
5
  Plugin URI: http://hidetitle.dojodigital.com/
6
  Tags: wp, title
7
  Author URI: http://dojodigital.com/
8
  Author: Dojo Digital
9
+ Requires at least: 3.2
10
+ Tested up to: 4.2
11
+ Stable tag: 1.0.4
12
+ Version: 1.0.4
13
 
14
  Allows authors to hide the title on single pages and posts via the edit post screen.
15
 
16
  == Description ==
17
 
18
  This plugin allows the author of a post or page to hide the title and it's containing HTML element from the single view ( is_singular() ).
19
+
20
  == Installation ==
21
 
22
  1. Upload the `hide-title` folder to the `/wp-content/plugins/` directory
26
 
27
  1. This Meta Box will be added to the Edit screen for pages & posts
28
 
29
+ == Changelog ==
30
+
31
+ = 1.0.4 =
32
+
33
+ * Now compatible with latest versions of WordPress
34
+ * PHP 4 is no longer supported.
35
+
36
+ = 1.0.3 =
37
+
38
+ * Fixed a jQuery bug which prevented fallbacks in the case that the selector was not found.
39
 
40
  = 1.0.2 =
41
 
47
  * Changed the jQuery to use a less brute force method of hiding the title.
48
  * Added a set_selector() method to allow end-users to specify the css selector to hide.
49
 
50
+ == Upgrade Notice ==
51
+
52
+ = 1.0.4 =
53
+ * Fixes errors on latest versions of WordPress.
54
+
55
+ = 1.0.3 =
56
+
57
+ * This version fixes a jQuery bug which prevented fallbacks in the case that the selector was not found.
58
 
59
  = 1.0.2 =
60
 
69
 
70
  = I upgraded to 1.0.2 and the plugin stopped working. Why? =
71
 
72
+ It is possible that your theme does not have the wp_head function in it's header.php file. In general all themes are suppose to have it, and version 1.0.2 looks for it to prevent adding bad code to the `<head>` area of the page. If you have access to your theme file simply add `<?php wp_head(); ?>` to header.php just before the `</head>` tag. If not, this plugin will no longer be compatible with your theme.
73
 
74
  = Hey! This plugin is hiding things I don't want hidden! =
75
 
85
 
86
  I could, but I'd like to avoid adding Yet Another Options Page if I can. If enough people request it though, I'll go ahead and bite the bullet.
87
 
88
+ = Who is the author of this plugin anyway? =
89
 
90
+ This plugin was originally was developed by Randall Runnels of Dojo Digital. In March 2015, the plugin was not compatible with the latest version of WordPress. After finding the problem, Brandon Kraft reached out with a solution, but didn't hear a response. He contacted the Plugins team at WordPress.org with an offer to assume development to bring it up date. The plugins team reached out and either recieved the approval of Randall, did not hear back at all, or the e-mail bounced.
91