Artikel 1-10, Stilpruefung, Querverweise, Upload-Skript
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* Plugin Name: Skrift Ratgeber Felder
|
||||
* Description: Meta-Felder fuer Ratgeberartikel (kurzantwort, faq, faq_ueberschrift, cta_ziel, stand_datum) mit Eingabebox im Editor, Shortcodes, Elementor-Widgets fuer FAQ und Kurzantwort sowie Dynamic Tags fuer Lesezeit, FAQ-Ueberschrift und Stand.
|
||||
* Version: 1.3.0
|
||||
* Version: 1.4.0
|
||||
* Author: Lucas Orth
|
||||
*
|
||||
* Ablage: wp-content/mu-plugins/skrift-ratgeber-felder.php
|
||||
@@ -362,6 +362,39 @@ add_shortcode( 'skrift_faq', function ( $atts ) {
|
||||
) );
|
||||
} );
|
||||
|
||||
/**
|
||||
* Querverweis auf einen anderen Ratgeberartikel.
|
||||
* [ratgeber_link slug="kaltakquise-per-brief"]Ankertext[/ratgeber_link]
|
||||
* Veroeffentlichter Zielbeitrag: normaler Link auf den aktuellen Permalink.
|
||||
* Noch nicht veroeffentlicht: nur der Ankertext, damit kein toter Link entsteht.
|
||||
* Wer den Beitrag bearbeiten darf, sieht in der Vorschau einen gestrichelten
|
||||
* Hinweis auf den noch fehlenden Zielartikel.
|
||||
*/
|
||||
add_shortcode( 'ratgeber_link', function ( $atts, $inhalt = '' ) {
|
||||
$atts = shortcode_atts( array( 'slug' => '' ), $atts, 'ratgeber_link' );
|
||||
$slug = sanitize_title( $atts['slug'] );
|
||||
$text = '' !== trim( (string) $inhalt ) ? do_shortcode( $inhalt ) : $slug;
|
||||
if ( '' === $slug ) {
|
||||
return $text;
|
||||
}
|
||||
$ziel = get_posts( array(
|
||||
'name' => $slug,
|
||||
'post_type' => 'post',
|
||||
'post_status' => array( 'publish', 'draft', 'pending', 'future', 'private' ),
|
||||
'numberposts' => 1,
|
||||
'suppress_filters' => true,
|
||||
) );
|
||||
if ( $ziel && 'publish' === $ziel[0]->post_status ) {
|
||||
return '<a href="' . esc_url( get_permalink( $ziel[0] ) ) . '">' . $text . '</a>';
|
||||
}
|
||||
if ( is_user_logged_in() && current_user_can( 'edit_posts' ) ) {
|
||||
$status = $ziel ? $ziel[0]->post_status : 'fehlt';
|
||||
return '<span class="skrift-ratgeber-link--offen" title="Zielartikel ' . esc_attr( $slug )
|
||||
. ' (' . esc_attr( $status ) . ')" style="border-bottom:1px dashed currentColor">' . $text . '</span>';
|
||||
}
|
||||
return $text;
|
||||
} );
|
||||
|
||||
add_shortcode( 'skrift_kurzantwort', function ( $atts ) {
|
||||
$atts = shortcode_atts( array( 'post_id' => 0 ), $atts, 'skrift_kurzantwort' );
|
||||
return skrift_kurzantwort_html( $atts['post_id'] );
|
||||
|
||||
Reference in New Issue
Block a user