====== xtreme subtitle ====== ===== Doppelte post_meta für _subtitle in DB beim speichern ===== Ändern der ''function on_save_subtitle'', um doppelte meta Einträge zu verhindern. Original in xtreme-one/lib/xtreme-subtitles.php <code phpwp> function on_save_subtitle($post_id) { if(isset($_POST["_subtitle"])) { //save data if(!update_post_meta($post_id, "_subtitle", strip_tags($_POST["_subtitle"]))){ add_post_meta($post_id, "_subtitle", strip_tags($_POST["_subtitle"])); } } } </code> Geänderte function: <code phpwp> function on_save_subtitle($post_id) { if(isset($_POST["_subtitle"])) { // save data if not empty if( ! empty ( $_POST["_subtitle"] ) ) { update_post_meta($post_id, "_subtitle", strip_tags($_POST["_subtitle"])); } else { delete_post_meta($post_id, "_subtitle"); } } } </code> ===== Optionale Ausgabe von Geschützt und Privat für subtitle ===== Die ''function xtreme_post_subtitle'' läßt sich zwar seit version 1.5.5 in der functions.php im ChildTheme überschreiben, trotzdem hätte ich gerne eine Änderung im core, um einfach über einen ''add_theme_support'' in der functions.php optional nur die Ausgabe von Privat und Geschützt unterbinden zu können, ohne die Funktion nochmal im ChildTheme überschreiben zu müssen. Diese Hinweise liefert WordPress ja schon standardmäßig für die Headline der Seiten oder Beiträge aus, die doppelte Kennzeichnung macht hier meiner Meinung nach keinen Sinn. Original in xtreme-one/lib/xtreme-post-functions.php <code phpwp> <?php if ( ! function_exists( 'xtreme_post_subtitle' ) ) { /** * Get subtitle, the additional subtitle of posts * * @param $tag String * @param $link Boolean * @param $echo Boolean * @return void */ function xtreme_post_subtitle( $tag = 'h4', $link = FALSE, $echo = TRUE ) { if ( ! current_theme_supports( 'xtreme-subtitles' ) ) return; $pt = get_post_type( get_the_ID() ); $spt = get_theme_support( 'xtreme-subtitles' ); if ( ! in_array( $pt, $spt[0]) ) return; if ( ! has_subtitle() ) return; $default_allowed_tags = array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'div' ); // Hook for change the allowed tags $allowed_tags = apply_filters( 'xtreme_allowed_tags_post_subtitle', $default_allowed_tags ); $open_link = ''; $close_link = ''; if ( ! in_array( $tag, $allowed_tags ) ) $tag = 'h4'; if ( $link ) { $open_link = sprintf( '<a href="%s" rel="bookmark" title="' . esc_attr__( 'Permalink to %s', XF_TEXTDOMAIN ) . '">', get_permalink(), the_title_attribute( 'echo=0' ) ); $close_link = '</a>'; } do_action( 'xtreme_before_post_subtitle' ); $output = sprintf( '<%1$s class="subtitle">%3$s%2$s%4$s</%1$s>', $tag, get_the_subtitle(), $open_link, $close_link ); if ( $echo ) echo $output; else return $output; do_action( 'xtreme_after_post_subtitle' ); } }</code> Geänderte function: <code phpwp> <?php if ( ! function_exists( 'xtreme_post_subtitle' ) ) { /** * Get subtitle, the additional subtitle of posts * * @param $tag String * @param $link Boolean * @param $echo Boolean * @return void */ function xtreme_post_subtitle( $tag = 'h4', $link = FALSE, $echo = TRUE ) { if ( ! current_theme_supports( 'xtreme-subtitles' ) ) return; $pt = get_post_type( get_the_ID() ); $spt = get_theme_support( 'xtreme-subtitles' ); if ( ! in_array( $pt, $spt[0]) ) return; $is_subtitle = get_post_meta( get_the_ID(), "_subtitle", true ); if ( empty ( $is_subtitle ) ) { return; } // add_theme_support from ChildTheme/functions.php $subtitle = ( get_theme_support( 'unmark-subtitles' ) ) ? $is_subtitle : get_the_subtitle(); $default_allowed_tags = array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'div' ); // Hook for change the allowed tags $allowed_tags = apply_filters( 'xtreme_allowed_tags_post_subtitle', $default_allowed_tags ); $open_link = ''; $close_link = ''; if ( ! in_array( $tag, $allowed_tags ) ) $tag = 'h4'; if ( $link ) { $open_link = sprintf( '<a href="%s" rel="bookmark" title="' . esc_attr__( 'Permalink to %s', XF_TEXTDOMAIN ) . '">', get_permalink(), the_title_attribute( 'echo=0' ) ); $close_link = '</a>'; } do_action( 'xtreme_before_post_subtitle' ); $output = sprintf( '<%1$s class="subtitle">%3$s%2$s%4$s</%1$s>', $tag, $subtitle, $open_link, $close_link ); if ( $echo ) echo $output; else return $output; do_action( 'xtreme_after_post_subtitle' ); } }</code> add_theme_support für die ChildTheme/functions.php <code phpwp> add_theme_support( 'unmark-subtitles' ); </code> Wenn dieses feature nicht in die functions.php eingetragen wird, werden die vorangestellten Privat/Geschützt Hinweise weiter ausgegeben.