[wp-trac] [WordPress Trac] #50424: Privacy Page Shortcode
WordPress Trac
noreply at wordpress.org
Thu Jun 18 17:53:56 UTC 2020
#50424: Privacy Page Shortcode
-------------------------+------------------------------
Reporter: leehodson | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Privacy | Version: 5.4.2
Severity: normal | Resolution:
Keywords: | Focuses:
-------------------------+------------------------------
Comment (by leehodson):
I tried to edit the ticket. Posted the wrong example code. It should be:
{{{#!php
<?php
function privacy_page_sc_vr51( $atts ) {
# Creates a Privacy Page link shortcode.
# Use as [privacy title="Privacy Page Title"] or [privacy]
# Default page title is Privacy Page.
# Page link points to the Privacy Page set in Dashboard > Privacy.
# The privacy page will only display if the page is public (status
= publish).
# Place this snippet into the site theme's functions.php file, a
custom functions plugin or some other
# suitable place.
$atts = shortcode_atts(
array(
'title' => 'Privacy
Policy'
), $atts
);
$title = sanitize_text_field( $atts['title'] );
# See wp-admin/includes/class-wp-privacy-policy-content.php
$privacy_page_id = (int) get_option( 'wp_page_for_privacy_policy'
);
if ( ! empty($privacy_page_id) && get_post_status(
$privacy_page_id ) == 'publish' ) {
$link = get_privacy_policy_url();
return "<a href=\"$link\" />$title</a>";
} else {
return;
}
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/50424#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list