wp_add_privacy_policy_content

函式
wp_add_privacy_policy_content ( $plugin_name, $policy_text )
引數
  • (string) $plugin_name The name of the plugin or theme that is suggesting content for the site's privacy policy.
    Required:
  • (string) $policy_text The suggested content for inclusion in the policy.
    Required:
定義位置
相關方法
get_privacy_policy_templatethe_privacy_policy_linkis_privacy_policyget_the_privacy_policy_linkget_privacy_policy_url
引入
4.9.6
棄用
-

wp_add_privacy_policy_content: 這個函式用於在WordPress網站上新增隱私政策內容: 該函式需要一個引數:$content。$content是應該被新增到隱私政策頁面的文字或HTML內容。

宣告瞭一個用於向隱私政策指南新增內容的輔助函式。

外掛和主題應建議將文字納入網站的隱私政策中。建議的文字應包含任何影響使用者隱私的功能的資訊,並將顯示在隱私政策指南螢幕上。

一個外掛或主題可以多次使用這個功能,只要它有助於更好地展示建議的政策內容。例如,WooCommerse或Jetpack等模組化外掛可以根據所啟用的模組/擴充套件,新增或刪除建議內容。更多資訊見《外掛手冊》:https://developer.wordpress.org/plugins/privacy/suggesting-text-for-the-site-privacy-policy/。

`$policy_text`的HTML內容支援使用專門的`.privacy-policy-tutorial`CSS類,可以用來提供補充資訊。任何包含在應用了`.privacy-policy-tutorial`CSS類的HTML元素中的內容,在複製該部分內容時將從剪貼簿中省略。

function wp_add_privacy_policy_content( $plugin_name, $policy_text ) {
	if ( ! is_admin() ) {
		_doing_it_wrong(
			__FUNCTION__,
			sprintf(
				/* translators: %s: admin_init */
				__( 'The suggested privacy policy content should be added only in wp-admin by using the %s (or later) action.' ),
				'<code>admin_init</code>'
			),
			'4.9.7'
		);
		return;
	} elseif ( ! doing_action( 'admin_init' ) && ! did_action( 'admin_init' ) ) {
		_doing_it_wrong(
			__FUNCTION__,
			sprintf(
				/* translators: %s: admin_init */
				__( 'The suggested privacy policy content should be added by using the %s (or later) action. Please see the inline documentation.' ),
				'<code>admin_init</code>'
			),
			'4.9.7'
		);
		return;
	}

	if ( ! class_exists( 'WP_Privacy_Policy_Content' ) ) {
		require_once ABSPATH . 'wp-admin/includes/class-wp-privacy-policy-content.php';
	}

	WP_Privacy_Policy_Content::add( $plugin_name, $policy_text );
}

常見問題

FAQs
檢視更多 >