Esempio n. 1
0
 /**
  * Optionally hide the title header tag on the front end via CSS but still render it in the DOM for SEO purposes.
  *
  * Can be used on single posts/pages including CPT's. Only hide title header tag if checkbox selected on post editor.
  *
  * @since 0.1.0
  */
 public static function hide_title_header_tag($id, $hd_tag = 'h1', $classes = '', $post_meta_id = '_wpgo_hide_title_header_tag')
 {
     $empty_placeholder = '(' . __('no title', 'wpgothemes') . ')';
     $empty_placeholder = WPGo_Hooks::wpgo_empty_title_placeholder($empty_placeholder);
     /* Sanitize CSS class list. */
     $class_list = explode(" ", $classes);
     $classes = '';
     //reset
     foreach ($class_list as $class) {
         $classes .= sanitize_html_class($class) . ' ';
     }
     $classes = rtrim($classes);
     // get rid of trailing space
     $hide_title_header_tag = get_post_meta($id, $post_meta_id, true);
     $title = get_the_title();
     if (empty($title)) {
         $title = $empty_placeholder;
     }
     // if user hasn't entered a title give it a placeholder title
     /* Add classes attribute if not empty. */
     if (!empty($classes)) {
         $classes = ' class="' . $classes . '"';
     }
     if ('1' == $hide_title_header_tag) {
         echo '<' . $hd_tag . ' style="display:none;"' . $classes . '>' . $title . '</' . $hd_tag . '>';
     } else {
         echo '<' . $hd_tag . $classes . '>' . $title . '</' . $hd_tag . '>';
     }
 }