<?php
namespace wp_gdpr_wc\\controller;
use wp_gdpr\\lib\\Gdpr_Language;
class Controller_Menu_Page_Wc {
const PRIVACY_POLICY_TEXT_WOO_REQUEST = \'gdpr_priv_pov_text_woo_request\';
const NOT_CONSENT_WOO_REQUEST = \'gdpr_not_consent_woo_request\';
/**
* Controller_Menu_Page constructor.
*/
public function __construct() {
add_action( \'add_on_settings_menu_page\', array( $this, \'build_form_to_enter_license\' ), 11 );
//display woocommerce privacy policies
add_action( \'gdpr_display_custom_privacy_policy\', array( $this, \'display_woocommerce_privacy_policies\' ) );
add_action( \'gdpr_save_custom_privacy_policy\', array( $this, \'save_woocommerce_privacy_policies\' ), 10, 1 );
}
/**
* build form to include licens
*/
public function build_form_to_enter_license() {
require_once GDPR_WC_DIR . \'view/admin/menu-page.php\';
}
/**
* Display WooCommerce privacy policies
*
* @since 1.1
*/
public function display_woocommerce_privacy_policies() {
$privacy_policy_strings = static::get_privacy_policy_strings();
include GDPR_WC_DIR . \'view/admin/privacy-policy.php\';
}
/**
* Saves WooCommerce privacy policies
*
* @since 1.1
*/
public function save_woocommerce_privacy_policies( $lang ) {
update_option( self::PRIVACY_POLICY_TEXT_WOO_REQUEST . $lang, $_REQUEST[\'gdpr_priv_pov_text_woo_request\'] );
}
/**
* TODO re-read the default text
*
* Returns WooCommerce privacy policy strings
*
* @return array
*
* @since 1.1
*/
public static function get_privacy_policy_strings() {
$lang = new Gdpr_Language();
$lang = $lang->get_language();
$privacy_policy_text_woo_request = get_option( self::PRIVACY_POLICY_TEXT_WOO_REQUEST . $lang, null );
$not_consent_woo_request = get_option( self::NOT_CONSENT_WOO_REQUEST . $lang, null );
if ( ! isset( $privacy_policy_text_woo_request ) ) {
$string = __( \'I consent to having %s collect my personal data and use it for administrative purposes.
For more info check our privacy policy where you\\\'ll get more info on where, how and why we store your data.\', \'wp_gdpr\' );
$blog_name = get_bloginfo( \'name\' );
$privacy_policy_text_data_request = sprintf( $string, $blog_name );
update_option( self::PRIVACY_POLICY_TEXT_WOO_REQUEST . $lang, $privacy_policy_text_data_request );
}
if ( ! isset( $not_consent_woo_request ) ) {
$string = __( \'The consent checkbox was not checked.\', \'wp_gdpr\' );
$not_consent_woo_request = $string;
update_option( self::NOT_CONSENT_WOO_REQUEST . $lang, $not_consent_woo_request );
}
$privacy_policy_strings = array(
self::PRIVACY_POLICY_TEXT_WOO_REQUEST => $privacy_policy_text_woo_request,
self::NOT_CONSENT_WOO_REQUEST => $not_consent_woo_request
);
return $privacy_policy_strings;
}
}
我想编辑此文本
$string = __( \'I consent to having %s collect my personal data and use it for administrative purposes. For more info check our privacy policy where you\\\'ll get more info on where, how and why we store your data.\', \'wp_gdpr\' );
既然插件中没有挂钩,我该怎么做?我想也许可以扩展这个类,但我不知道是否可以编辑现有的函数。
我试过了,但没用。
use wp_gdpr_wc\\controller\\Controller_Menu_Page_Wc;
class test extends Controller_Menu_Page_Wc{
public static function get_privacy_policy_strings() {
$lang = new Gdpr_Language();
$lang = $lang->get_language();
$privacy_policy_text_woo_request = get_option( self::PRIVACY_POLICY_TEXT_WOO_REQUEST . $lang, null );
$not_consent_woo_request = get_option( self::NOT_CONSENT_WOO_REQUEST . $lang, null );
if ( ! isset( $privacy_policy_text_woo_request ) ) {
$string = __( \'I consent to having %s collect my personal data and use it for administrative purposes.
For more info check our privacy policyss where you\\\'ll get more info on where, how and why we store your data.\', \'wp_gdpr\' );
$blog_name = get_bloginfo( \'name\' );
$privacy_policy_text_data_request = sprintf( $string, $blog_name );
update_option( self::PRIVACY_POLICY_TEXT_WOO_REQUEST . $lang, $privacy_policy_text_data_request );
}
if ( ! isset( $not_consent_woo_request ) ) {
$string = __( \'The consent checkbox was not checked.\', \'wp_gdpr\' );
$not_consent_woo_request = $string;
update_option( self::NOT_CONSENT_WOO_REQUEST . $lang, $not_consent_woo_request );
}
$privacy_policy_strings = array(
self::PRIVACY_POLICY_TEXT_WOO_REQUEST => $privacy_policy_text_woo_request,
self::NOT_CONSENT_WOO_REQUEST => $not_consent_woo_request
);
return $privacy_policy_strings;
}
}
编辑:幸运的是,我可以从
wp_options
数据库中的表,若有人知道如何从代码中执行它,那个将非常有用!