Title Remover - Version 1.2

Version Description

  • Fixed the warnings that are displayed on some websites.
Download this release

Release Info

Developer wpis
Plugin Icon 128x128 Title Remover
Version 1.2
Comparing to
See all releases

Code changes from version 1.1 to 1.2

Files changed (2) hide show
  1. readme.txt +7 -2
  2. title-remover.php +33 -24
readme.txt CHANGED
@@ -4,13 +4,15 @@ Tags: title, page title, post title, hide title, remove title, metaboxes, title
4
  Donate link: http://wpgurus.net/title-remover/
5
  Requires at least: 2.5
6
  Tested up to: 4.9
7
- Stable tag: 1.1
8
  License: License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  Gives you the ability to hide the title of any post, page or custom post type item without affecting menus or titles in the admin area.
12
 
13
  == Description ==
 
 
14
  This plugin adds a simple metabox beside the post creation form in the WordPress admin interface, allowing you to toggle the visibility of the title. Unlike some of the other similar plugins available in the WordPress repository, it completely removes the title instead of just hiding with CSS or JavaScript.
15
 
16
  Some advantages of using this plugin:
@@ -31,4 +33,7 @@ Some advantages of using this plugin:
31
 
32
  = 1.1 =
33
  * Compatibility check with WP 4.9
34
- * Added new graphics for WP.org
 
 
 
4
  Donate link: http://wpgurus.net/title-remover/
5
  Requires at least: 2.5
6
  Tested up to: 4.9
7
+ Stable tag: 1.2
8
  License: License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  Gives you the ability to hide the title of any post, page or custom post type item without affecting menus or titles in the admin area.
12
 
13
  == Description ==
14
+ **Important:** This plugin works with every theme that uses the recommended WP function for displaying the title. For other themes, that display the title using a lesser know method, it might not work.
15
+
16
  This plugin adds a simple metabox beside the post creation form in the WordPress admin interface, allowing you to toggle the visibility of the title. Unlike some of the other similar plugins available in the WordPress repository, it completely removes the title instead of just hiding with CSS or JavaScript.
17
 
18
  Some advantages of using this plugin:
33
 
34
  = 1.1 =
35
  * Compatibility check with WP 4.9
36
+ * Added new graphics for WP.org
37
+
38
+ = 1.2 =
39
+ * Fixed the warnings that are displayed on some websites.
title-remover.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Title Remover
4
  Plugin URI: http://wpgurus.net/title-remover/
5
  Description: Gives you the ability to hide the title of any post, page or custom post type item without affecting menus or titles in the admin area.
6
- Version: 1.1
7
  Author: WPGurus
8
  Author URI: http://wpgurus.net/
9
  License: GPL2
@@ -13,14 +13,20 @@ License: GPL2
13
  Hide Title
14
  ----------------------------------------------------*/
15
 
16
- function wptr_supress_title($title, $post_id) {
17
- global $id;
 
 
 
18
  $hide_title = get_post_meta( $post_id, 'wptr_hide_title', true );
19
- if (!is_admin() && is_singular() && intval($hide_title) && in_the_loop())
20
- return '';
21
- return $title;
 
 
22
  }
23
- add_filter('the_title', 'wptr_supress_title', 10, 2);
 
24
 
25
  /*--------------------------------------------------
26
  MetaBox
@@ -39,39 +45,42 @@ function wptr_post_meta_boxes_setup() {
39
 
40
  function wptr_add_post_meta_boxes() {
41
  add_meta_box(
42
- 'wptr-hide-title', // Unique ID
43
- 'Hide Title?', // Title
44
- 'wptr_render_metabox', // Callback function
45
- null, // Admin page
46
- 'side', // Context
47
- 'core' // Priority
48
  );
49
  }
50
 
51
- function wptr_render_metabox( $object, $box ) {
52
- $curr_value = get_post_meta( $object->ID, 'wptr_hide_title', true );
53
  wp_nonce_field( basename( __FILE__ ), 'wptr_meta_nonce' );
54
- ?>
55
- <input type="hidden" name="wptr-hide-title-checkbox" value="0" />
56
- <input type="checkbox" name="wptr-hide-title-checkbox" id="wptr-hide-title-checkbox" value="1" <?php checked($curr_value, '1'); ?> />
 
57
  <label for="wptr-hide-title-checkbox">Hide the title for this item</label>
58
- <?php
59
  }
60
 
61
  function wptr_save_meta( $post_id, $post ) {
62
 
63
  /* Verify the nonce before proceeding. */
64
- if ( !isset( $_POST['wptr_meta_nonce'] ) || !wp_verify_nonce( $_POST['wptr_meta_nonce'], basename( __FILE__ ) ) )
65
- return $post_id;
 
66
 
67
  /* Get the post type object. */
68
  $post_type = get_post_type_object( $post->post_type );
69
 
70
  /* Check if the current user has permission to edit the post. */
71
- if ( !current_user_can( $post_type->cap->edit_post, $post_id ) )
72
- return $post_id;
 
73
 
74
  /* Get the posted data and sanitize it for use as an HTML class. */
75
- $form_data = ( isset( $_POST['wptr-hide-title-checkbox'] ) ? $_POST['wptr-hide-title-checkbox'] : '0' );
76
  update_post_meta( $post_id, 'wptr_hide_title', $form_data );
77
  }
3
  Plugin Name: Title Remover
4
  Plugin URI: http://wpgurus.net/title-remover/
5
  Description: Gives you the ability to hide the title of any post, page or custom post type item without affecting menus or titles in the admin area.
6
+ Version: 1.2
7
  Author: WPGurus
8
  Author URI: http://wpgurus.net/
9
  License: GPL2
13
  Hide Title
14
  ----------------------------------------------------*/
15
 
16
+ function wptr_supress_title( $title, $post_id = 0 ) {
17
+ if ( ! $post_id ) {
18
+ return $title;
19
+ }
20
+
21
  $hide_title = get_post_meta( $post_id, 'wptr_hide_title', true );
22
+ if ( ! is_admin() && is_singular() && intval( $hide_title ) && in_the_loop() ) {
23
+ return '';
24
+ }
25
+
26
+ return $title;
27
  }
28
+
29
+ add_filter( 'the_title', 'wptr_supress_title', 10, 2 );
30
 
31
  /*--------------------------------------------------
32
  MetaBox
45
 
46
  function wptr_add_post_meta_boxes() {
47
  add_meta_box(
48
+ 'wptr-hide-title', // Unique ID
49
+ 'Hide Title?', // Title
50
+ 'wptr_render_metabox', // Callback function
51
+ null, // Admin page
52
+ 'side', // Context
53
+ 'core' // Priority
54
  );
55
  }
56
 
57
+ function wptr_render_metabox( $post ) {
58
+ $curr_value = get_post_meta( $post->ID, 'wptr_hide_title', true );
59
  wp_nonce_field( basename( __FILE__ ), 'wptr_meta_nonce' );
60
+ ?>
61
+ <input type="hidden" name="wptr-hide-title-checkbox" value="0"/>
62
+ <input type="checkbox" name="wptr-hide-title-checkbox" id="wptr-hide-title-checkbox"
63
+ value="1" <?php checked( $curr_value, '1' ); ?> />
64
  <label for="wptr-hide-title-checkbox">Hide the title for this item</label>
65
+ <?php
66
  }
67
 
68
  function wptr_save_meta( $post_id, $post ) {
69
 
70
  /* Verify the nonce before proceeding. */
71
+ if ( ! isset( $_POST['wptr_meta_nonce'] ) || ! wp_verify_nonce( $_POST['wptr_meta_nonce'], basename( __FILE__ ) ) ) {
72
+ return;
73
+ }
74
 
75
  /* Get the post type object. */
76
  $post_type = get_post_type_object( $post->post_type );
77
 
78
  /* Check if the current user has permission to edit the post. */
79
+ if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
80
+ return;
81
+ }
82
 
83
  /* Get the posted data and sanitize it for use as an HTML class. */
84
+ $form_data = ( isset( $_POST['wptr-hide-title-checkbox'] ) ? $_POST['wptr-hide-title-checkbox'] : '0' );
85
  update_post_meta( $post_id, 'wptr_hide_title', $form_data );
86
  }