Changeset 2261567
- Timestamp:
- 03/16/2020 07:16:03 AM (6 years ago)
- Location:
- ams-hide-page-and-post-title
- Files:
-
- 4 edited
-
tags/1.0/ams-hide-page-and-post-title.php (modified) (3 diffs)
-
tags/1.0/readme.txt (modified) (2 diffs)
-
trunk/ams-hide-page-and-post-title.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ams-hide-page-and-post-title/tags/1.0/ams-hide-page-and-post-title.php
r1523538 r2261567 4 4 Description: Allows authors to hide the title tag on single pages and posts via the edit post screen. 5 5 Author: Manoj Sathyavrathan 6 Version: 1. 06 Version: 1.1 7 7 Text Domain: msv-ams-hide-page-and-post-title 8 8 */ … … 47 47 add_action( 'delete_post', array( $this, 'ams_delete_post_action' ) ); 48 48 49 if( ! is_admin() ) {50 add_filter( 'the_title', array($this, 'ams_the_title'));51 }49 add_filter( 'the_title', array($this, 'ams_wpse309151_title_update'), 10, 2 ); 50 add_filter( 'pre_wp_nav_menu', array($this, 'ams_wpse309151_remove_title_filter_nav_menu'), 10, 2 ); 51 add_filter( 'wp_nav_menu_items', array($this, 'ams_wpse309151_add_title_filter_non_menu'), 10, 2 ); 52 52 } // hooks() 53 53 … … 103 103 } // on_delete() 104 104 105 function ams_the_title( $title ) { 106 global $post; 107 $value = get_post_meta( $post->ID, $this->ams_term, true ); 108 109 if ( 'on' == $value ) 110 return $title = ''; 111 105 // Hide post & page title 106 function ams_wpse309151_title_update( $title, $post_id ) { 107 $post_type = get_post_type( $post_id ); 108 $value = get_post_meta( $post_id, $this->ams_term, true ); 109 if( !is_admin() && ( $post_type === 'post' || $post_type === 'page' ) ) { 110 111 if ( 'on' == $value ){ 112 $title = ''; 113 return $title; 114 } 115 //return $title; 116 } 112 117 return $title; 113 118 } 119 120 121 function ams_wpse309151_remove_title_filter_nav_menu( $nav_menu, $args ) { 122 // we are working with menu, so remove the title filter 123 remove_filter( 'the_title', array($this, 'ams_wpse309151_title_update'), 10, 2 ); 124 return $nav_menu; 125 } 126 // this filter fires just before the nav menu item creation process 127 128 129 function ams_wpse309151_add_title_filter_non_menu( $items, $args ) { 130 // we are done working with menu, so add the title filter back 131 add_filter( 'the_title', array($this, 'ams_wpse309151_title_update'), 10, 2 ); 132 return $items; 133 } 134 // this filter fires after nav menu item creation is done 135 114 136 115 137 } -
ams-hide-page-and-post-title/tags/1.0/readme.txt
r2261261 r2261567 5 5 Donate link: https://www.paypal.me/manojsv 6 6 Tested up to: 5.3.2 7 Stable tag: 1. 07 Stable tag: 1.1 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 39 39 40 40 == Changelog == 41 41 = Version 1.1 = 42 * Fixed issue with menu 42 43 = Version 1.0 = 43 44 * First Release -
ams-hide-page-and-post-title/trunk/ams-hide-page-and-post-title.php
r1523538 r2261567 4 4 Description: Allows authors to hide the title tag on single pages and posts via the edit post screen. 5 5 Author: Manoj Sathyavrathan 6 Version: 1. 06 Version: 1.1 7 7 Text Domain: msv-ams-hide-page-and-post-title 8 8 */ … … 47 47 add_action( 'delete_post', array( $this, 'ams_delete_post_action' ) ); 48 48 49 if( ! is_admin() ) {50 add_filter( 'the_title', array($this, 'ams_the_title'));51 }49 add_filter( 'the_title', array($this, 'ams_wpse309151_title_update'), 10, 2 ); 50 add_filter( 'pre_wp_nav_menu', array($this, 'ams_wpse309151_remove_title_filter_nav_menu'), 10, 2 ); 51 add_filter( 'wp_nav_menu_items', array($this, 'ams_wpse309151_add_title_filter_non_menu'), 10, 2 ); 52 52 } // hooks() 53 53 … … 103 103 } // on_delete() 104 104 105 function ams_the_title( $title ) { 106 global $post; 107 $value = get_post_meta( $post->ID, $this->ams_term, true ); 108 109 if ( 'on' == $value ) 110 return $title = ''; 111 105 // Hide post & page title 106 function ams_wpse309151_title_update( $title, $post_id ) { 107 $post_type = get_post_type( $post_id ); 108 $value = get_post_meta( $post_id, $this->ams_term, true ); 109 if( !is_admin() && ( $post_type === 'post' || $post_type === 'page' ) ) { 110 111 if ( 'on' == $value ){ 112 $title = ''; 113 return $title; 114 } 115 //return $title; 116 } 112 117 return $title; 113 118 } 119 120 121 function ams_wpse309151_remove_title_filter_nav_menu( $nav_menu, $args ) { 122 // we are working with menu, so remove the title filter 123 remove_filter( 'the_title', array($this, 'ams_wpse309151_title_update'), 10, 2 ); 124 return $nav_menu; 125 } 126 // this filter fires just before the nav menu item creation process 127 128 129 function ams_wpse309151_add_title_filter_non_menu( $items, $args ) { 130 // we are done working with menu, so add the title filter back 131 add_filter( 'the_title', array($this, 'ams_wpse309151_title_update'), 10, 2 ); 132 return $items; 133 } 134 // this filter fires after nav menu item creation is done 135 114 136 115 137 } -
ams-hide-page-and-post-title/trunk/readme.txt
r2261261 r2261567 5 5 Donate link: https://www.paypal.me/manojsv 6 6 Tested up to: 5.3.2 7 Stable tag: 1. 07 Stable tag: 1.1 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 39 39 40 40 == Changelog == 41 41 = Version 1.1 = 42 * Fixed issue with menu 42 43 = Version 1.0 = 43 44 * First Release
Note: See TracChangeset
for help on using the changeset viewer.