PluginProbe
MM Title Manager — Hide Page and Post Titles / 1.9
MM Title Manager — Hide Page and Post Titles v1.9
1.12 1.11 trunk 1.10 1.10.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.9 1.9.1
hide-titles / hide-titles.php

hide-titles.php in MM Title Manager — Hide Page and Post Titles 1.9, at hide-titles.php

300 lines 12.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Plugin Name: Hide Titles
5 * Plugin URI: https://wordpress.org/plugins/hide-titles/
6 * Description: Remove Titles from Posts and Single Pages on WordPress.
7 * Version: 1.9
8 * Requires at least: 4.4
9 * Requires PHP: 5.6
10 * Tested up to: 6.9
11 * Author: Mehraz Morshed
12 * Author URI: https://profiles.wordpress.org/mehrazmorshed/
13 * License: GPL v2 or later
14 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
15 * Text Domain: hide-titles
16 * Domain Path: /languages
17 */
18
19 /**
20 * Hide Titles is free software: you can redistribute it and/or
21 * modify it under the terms of the GNU General Public License
22 * as published by the Free Software Foundation, either version 3
23 * of the License, or (at your option) any later version.
24 *
25 * Hide Titles is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * You should have received a copy of the GNU General Public License
31 * along with this program. If not, see <https://www.gnu.org/licenses/>.
32 */
33
34 // Exit if accessed directly
35 if ( ! defined( 'ABSPATH' ) ) {
36 exit;
37 }
38
39 // Load the text-domain
40 function hide_titles_load_textdomain() {
41 load_plugin_textdomain( 'hide-titles', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
42 }
43 add_action( 'init', 'hide_titles_load_textdomain' );
44
45 function hide_titles_option_page() {
46
47 add_menu_page( 'Hide Titles', 'Hide Titles', 'manage_options', 'hide-titles', 'hide_titles_create_page', 'dashicons-admin-plugins', 101 );
48 }
49 add_action( 'admin_menu', 'hide_titles_option_page' );
50
51 function hide_titles_style_settings() {
52
53 wp_enqueue_style( 'hide-titles-settings', plugins_url( 'css/hide-titles-settings.css', __FILE__ ), false, "1.0.0" );
54 }
55 add_action( 'admin_enqueue_scripts', 'hide_titles_style_settings' );
56
57 function hide_titles_create_page() {
58 ?>
59 <div class="hide_titles_main">
60 <div class="hide_titles_body hide_titles_common">
61 <h1 id="page-title"><?php esc_attr_e( 'Settings', 'hide-titles' ); ?></h1>
62 <form action="options.php" method="post">
63 <?php wp_nonce_field( 'update-options' ); ?>
64
65 <!-- Hide Titles -->
66 <label for="hide-titles-option"><?php esc_attr_e( 'Hide Titles Option:', 'hide-titles' ); ?></label>
67
68 <label class="radios">
69 <input type="radio" name="hide-titles-option" id="hide-titles-option-nothing" value="nothing" <?php if( get_option( 'hide-titles-option' ) == 'nothing' ) { echo 'checked="checked"'; } ?>>
70 <span><?php _e( 'Show All Titles', 'hide-titles' ); ?></span>
71 </label>
72
73 <label class="radios">
74 <input type="radio" name="hide-titles-option" id="hide-titles-option-all" value="all" <?php if( get_option( 'hide-titles-option' ) == 'all' ) { echo 'checked="checked"'; } ?>>
75 <span><?php _e( 'Hide All Titles', 'hide-titles' ); ?></span>
76 </label>
77
78 <!-- -->
79 <input type="hidden" name="action" value="update">
80 <input type="hidden" name="page_options" value="hide-titles-option">
81
82 <input class="button button-primary" type="submit" name="submit" value="<?php _e( 'Save Changes', 'hide-titles' ) ?>">
83 </form>
84
85 <br>
86 <hr>
87 <br>
88 <label class="">
89 <span>
90 <?php _e( '🎉 New Feature 🎉 Hide Title From Single Post / Page:', 'hide-titles' ); ?>
91 </span>
92 </label>
93 <img class="screenshot" src="<?php print plugin_dir_url( __FILE__ ) . '/img/single.png'; ?>">
94 </div>
95 <div class="hide_titles_aside hide_titles_common">
96 <!-- about plugin author -->
97 <h2 class="aside-title"><?php esc_attr_e( 'About Plugin Author', 'hide-titles' ); ?></h2>
98 <div class="author-card">
99 <a class="link" href="https://profiles.wordpress.org/mehrazmorshed/" target="_blank">
100 <img class="center" src="<?php print plugin_dir_url( __FILE__ ) . '/img/author.png'; ?>" width="128px">
101 <h3 class="author-title"><?php esc_attr_e( 'Mehraz Morshed', 'hide-titles' ); ?></h3>
102 <h4 class="author-title"><?php esc_attr_e( 'WordPress Developer', 'hide-titles' ); ?></h4>
103 </a>
104 <h1 class="author-title">
105 <a class="link" href="https://www.facebook.com/mehrazmorshed" target="_blank"><span class="dashicons dashicons-facebook"></span></a>
106 <a class="link" href="https://twitter.com/mehrazmorshed" target="_blank"><span class="dashicons dashicons-twitter"></span></a>
107 <a class="link" href="https://www.linkedin.com/in/mehrazmorshed" target="_blank"><span class="dashicons dashicons-linkedin"></span></a>
108 <a class="link" href="https://www.youtube.com/@mehrazmorshed" target="_blank"><span class="dashicons dashicons-youtube"></span></a>
109 </h1>
110 </div>
111 <!-- other useful plugins -->
112 <h3 class="aside-title"><?php esc_attr_e( 'Other Useful Plugins', 'hide-titles' ); ?></h3>
113 <div class="author-card">
114 <a class="link" href="https://wordpress.org/plugins/turn-off-comments/" target="_blank">
115 <span class="dashicons dashicons-admin-plugins"></span> <b><?php _e( 'Disable Comments', 'hide-titles' ) ?></b>
116 </a>
117 <hr>
118 <a class="link" href="https://wordpress.org/plugins/hide-admin-navbar/" target="_blank">
119 <span class="dashicons dashicons-admin-plugins"></span> <b><?php _e( 'Hide Admin Toolbar', 'hide-titles' ) ?></b>
120 </a>
121 <hr>
122 <a class="link" href="https://wordpress.org/plugins/about-post-author/" target="_blank">
123 <span class="dashicons dashicons-admin-plugins"></span> <b><?php _e( 'Simple Author Box', 'hide-titles' ) ?></b>
124 </a>
125 </div>
126 <!-- donate to this plugin -->
127 <h3 class="aside-title"><?php esc_attr_e( 'Hide Titles', 'hide-titles' ); ?></h3>
128 <a class="link" href="https://www.buymeacoffee.com/mehrazmorshed" target="_blank">
129 <button class="button button-primary btn"><?php esc_attr_e( 'Donate To This Plugin', 'hide-titles' ); ?></button>
130 </a>
131 <p style="text-align: center;"><b>OR</b></p>
132 <a class="link" href="https://wordpress.org/support/plugin/hide-titles/reviews/?filter=5#new-post" target="_blank">
133 <button class="button button-primary btn"><?php esc_attr_e( 'Leave a Review', 'hide-titles' ); ?></button>
134 </a>
135 </div>
136 </div>
137
138 <?php
139 }
140
141 if( get_option( 'hide-titles-option' ) == 'all' ) {
142
143 function hide_titles() {
144
145 return false;
146 }
147 add_filter('the_title', 'hide_titles');
148 }
149
150 function hide_titles_plugin_activation() {
151
152 add_option( 'hide_titles_plugin_do_activation_redirect', true );
153 }
154 register_activation_hook( __FILE__, 'hide_titles_plugin_activation' );
155
156 function hide_titles_plugin_redirect() {
157
158 if( get_option( 'hide_titles_plugin_do_activation_redirect', false ) ) {
159
160 delete_option( 'hide_titles_plugin_do_activation_redirect' );
161
162 if ( !isset( $_GET['active-multi'] ) ) {
163
164 wp_safe_redirect( admin_url( 'admin.php?page=hide-titles' ) );
165 exit;
166 }
167 }
168 }
169 add_action( 'admin_init', 'hide_titles_plugin_redirect' );
170 /*********************************************************************/
171 add_action('add_meta_boxes', 'hide_titles_meta_box');
172 add_action('save_post', 'hide_titles_save_meta');
173 add_filter('the_title', 'hide_titles_filter_title', 10, 2);
174
175 // Add meta box to hide title
176 function hide_titles_meta_box() {
177 add_meta_box('hide-title-meta-box', 'Hide Titles', 'hide_titles_meta_box_callback', ['post', 'page'], 'side', 'default');
178 }
179
180 // Meta box callback function
181 function hide_titles_meta_box_callback($post) {
182 $value = get_post_meta($post->ID, '_hide_title', true);
183 ?>
184 <label for="hide-titles-checkbox">
185 <input type="checkbox" id="hide-titles-checkbox" name="hide_titles_checkbox" <?php checked($value, 'on'); ?> />
186 Hide The Title
187 </label>
188 <br><br>
189 <p><small>This option comes from the <b>Hide Titles</b> plugin. <a href="https://wordpress.org/support/plugin/hide-titles/reviews/?filter=5#new-post"><strong>Please consider leaving a review</strong></a> to share your experience with us.</small></p>
190 <?php
191 }
192
193 // Save meta box data
194 function hide_titles_save_meta($post_id) {
195 if (array_key_exists('hide_titles_checkbox', $_POST)) {
196 update_post_meta($post_id, '_hide_title', 'on');
197 } else {
198 delete_post_meta($post_id, '_hide_title');
199 }
200 }
201
202 // Filter the title to hide it
203 function hide_titles_filter_title($title, $id = null) {
204 if (is_admin() || !$id) {
205 return $title;
206 }
207
208 $hide_title = get_post_meta($id, '_hide_title', true);
209 if ($hide_title === 'on') {
210 return '';
211 }
212
213 return $title;
214 }
215
216
217
218
219
220 /**
221 * Save installation datetime on plugin activation
222 */
223 function hide_titles_activate() {
224 // Check if the installation time is already saved
225 $installed = get_option('hide_titles_installed');
226
227 if (!$installed) {
228 // Save current datetime if not already set
229 update_option('hide_titles_installed', current_time('mysql'));
230 }
231 }
232 register_activation_hook(__FILE__, 'hide_titles_activate');
233
234 /**
235 * Clean up options on plugin uninstallation
236 */
237 function hide_titles_uninstall() {
238 delete_option('hide_titles_installed');
239 }
240 register_uninstall_hook(__FILE__, 'hide_titles_uninstall');
241
242 /**
243 * Show migration notice for installations before Oct 30, 2025
244 */
245 function ht_show_migration_notice() {
246 // Only show if new plugin is not active
247 if (is_plugin_active('daisy-titles/daisy-titles.php')) {
248 return;
249 }
250
251 // Get installation date
252 $install_date = get_option('hide_titles_installed');
253
254 // Only show notice if:
255 // 1. There is NO install date (new installation) OR
256 // 2. Installation date is BEFORE Oct 30, 2025
257 if ($install_date && strtotime($install_date) >= strtotime('2025-10-30')) {
258 return;
259 }
260
261 // Get install/activate URLs
262 $install_url = wp_nonce_url(
263 add_query_arg([
264 'action' => 'install-plugin',
265 'plugin' => 'daisy-titles'
266 ], admin_url('update.php')),
267 'install-plugin_daisy-titles'
268 );
269
270 $activate_url = '';
271 if (file_exists(WP_PLUGIN_DIR . '/daisy-titles/daisy-titles.php')) {
272 $activate_url = wp_nonce_url(
273 add_query_arg([
274 'action' => 'activate',
275 'plugin' => 'daisy-titles/daisy-titles.php'
276 ], admin_url('plugins.php')),
277 'activate-plugin_daisy-titles/daisy-titles.php'
278 );
279 }
280 ?>
281 <div class="notice notice-error">
282 <h4><?php esc_html_e('Important Notice About Hide Titles', 'hide-titles'); ?></h4>
283 <p>
284 <?php _e('This plugin is no longer maintained. Please migrate to our new improved plugin <b style="color: blue;">"Daisy Titles"</b> for continued support, new features, and future updates.', 'hide-titles'); ?>
285 </p>
286 <p>
287 <?php if ($activate_url) : ?>
288 <a href="<?php echo esc_url($activate_url); ?>" class="button button-primary">
289 <?php esc_html_e('Activate Daisy Titles Now', 'hide-titles'); ?>
290 </a>
291 <?php else : ?>
292 <a href="<?php echo esc_url($install_url); ?>" class="button button-primary">
293 <?php esc_html_e('Migrate to Daisy Titles Now', 'hide-titles'); ?>
294 </a>
295 <?php endif; ?>
296 </p>
297 </div>
298 <?php
299 }
300 add_action('admin_notices', 'ht_show_migration_notice');