plugin = $plugin; } /** * Hook into WordPress admin. */ public function register() { add_action( 'admin_menu', array( $this, 'menu' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) ); add_action( 'admin_notices', array( $this, 'notices' ) ); add_action( 'admin_init', array( $this, 'privacy_guide' ) ); add_filter( 'plugin_action_links_' . plugin_basename( GOCONSENT_FILE ), array( $this, 'action_links' ) ); } /** * Menu entry. */ public function menu() { $icon = 'data:image/svg+xml;base64,' . base64_encode( '' ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode -- menu icon data URI. $this->hook = add_menu_page( __( 'GoConsent™', 'goconsent' ), __( 'GoConsent™', 'goconsent' ), 'manage_options', self::SLUG, array( $this, 'render' ), $icon, 81 ); } /** * Load the app only on its own screen. * * @param string $hook Current screen hook. */ public function assets( $hook ) { if ( $hook !== $this->hook ) { return; } wp_enqueue_style( 'goconsent-admin', GOCONSENT_URL . 'assets/css/admin.css', array(), GOCONSENT_VERSION ); wp_enqueue_script( 'goconsent-admin', GOCONSENT_URL . 'assets/js/admin.js', array(), GOCONSENT_VERSION, array( 'in_footer' => true ) ); wp_localize_script( 'goconsent-admin', 'GoConsentAdmin', array( 'root' => esc_url_raw( rest_url( Rest::NS . '/' ) ), 'nonce' => wp_create_nonce( 'wp_rest' ), 'state' => State::build( $this->plugin ), 'accepted' => $this->plugin->terms->accepted(), 'i18n' => array( 'scanning' => __( 'Scanning…', 'goconsent' ), 'working' => __( 'Working…', 'goconsent' ), 'confirm' => __( 'Are you sure?', 'goconsent' ), 'cancel' => __( 'Cancel', 'goconsent' ), 'ok' => __( 'Continue', 'goconsent' ), 'copied' => __( 'Wording copied.', 'goconsent' ), 'copyFail' => __( 'Select the text and copy it.', 'goconsent' ), 'error' => __( 'Something went wrong. Reload the page and try again.', 'goconsent' ), 'fix' => __( 'Fix it', 'goconsent' ), 'close' => __( 'Close', 'goconsent' ), 'dismiss' => __( 'Dismiss', 'goconsent' ), 'addPolicy' => __( 'Add to Privacy Policy', 'goconsent' ), 'copy' => __( 'Copy text', 'goconsent' ), 'copyFix' => __( 'Copy & fix', 'goconsent' ), 'requiredBy' => __( 'Required by', 'goconsent' ), 'appliesYou' => __( 'Applies to you', 'goconsent' ), /* translators: %s: date. */ 'startsOn' => __( 'Starts %s', 'goconsent' ), 'reviewPol' => __( 'Review policy', 'goconsent' ), 'newTab' => __( '(opens the privacy page editor in a new tab)', 'goconsent' ), 'pasteIt' => __( 'Wording copied. Paste it into your privacy policy, then update the page.', 'goconsent' ), 'mark' => __( 'Mark as handled…', 'goconsent' ), 'reasonPh' => __( 'Reason, e.g. Our lawyer covers this in section 7', 'goconsent' ), 'save' => __( 'Save', 'goconsent' ), 'suggested' => __( 'Suggested wording · filled in from Settings', 'goconsent' ), 'reviewed' => __( 'Mark as reviewed', 'goconsent' ), 'allSet' => __( 'You’re all set', 'goconsent' ), /* translators: %d: number of issues. */ 'toFix' => __( '%d to fix', 'goconsent' ), /* translators: 1: time since last scan, 2: pages checked, 3: time until next scan. */ 'lastScan' => __( 'Last scan %1$s ago · %2$d pages checked · next scan in %3$s', 'goconsent' ), 'notScanned' => __( 'Not scanned yet. Click Scan now.', 'goconsent' ), 'necessary' => __( 'Necessary', 'goconsent' ), 'analytics' => __( 'Analytics', 'goconsent' ), 'marketing' => __( 'Marketing', 'goconsent' ), 'needs' => __( 'Needs review', 'goconsent' ), /* translators: %s: category name. */ 'approveAs' => __( 'Approve as %s', 'goconsent' ), /* translators: 1: user name, 2: date. */ 'approvedBy' => __( 'Approved by %1$s · %2$s', 'goconsent' ), 'undo' => __( 'Undo', 'goconsent' ), 'changeCat' => __( 'Change category', 'goconsent' ), 'rescan' => __( 'Run a new scan to see which plugin or page adds each script.', 'goconsent' ), 'clickLoad' => __( 'Click-to-load', 'goconsent' ), 'selfHosted' => __( 'Self-hosted', 'goconsent' ), 'failed' => __( 'Download failed', 'goconsent' ), 'loads' => __( 'Loads on every visit', 'goconsent' ), 'nothing' => __( 'Nothing detected yet. Click Scan now.', 'goconsent' ), 'added' => __( 'Wording added to privacy policy', 'goconsent' ), 'handledBy' => __( 'Marked handled', 'goconsent' ), 'dismissed' => __( 'Dismissed', 'goconsent' ), 'visitors' => __( 'visitors', 'goconsent' ), /* translators: %d: number of days. */ 'vsPrev' => __( 'vs previous %d days', 'goconsent' ), 'noData' => __( 'No visits recorded yet. Data appears as visitors arrive.', 'goconsent' ), 'direct' => __( 'Direct / unknown', 'goconsent' ), 'scanNow' => __( 'Scan now', 'goconsent' ), /* translators: %s: date and time. */ 'watching' => __( 'Watching unfamiliar scripts until %s. Known trackers are already held.', 'goconsent' ), 'tool' => __( 'Tool', 'goconsent' ), 'foundOn' => __( 'Found on', 'goconsent' ), 'handling' => __( 'Handling', 'goconsent' ), 'reason' => __( 'Reason', 'goconsent' ), 'privacyPage' => __( 'Privacy policy page', 'goconsent' ), /* translators: %s: list of tools, e.g. "Meta (Facebook) Pixel, Microsoft Clarity". */ 'bannerNeeded' => __( 'The banner has to stay on. Found: %s.', 'goconsent' ), 'active' => __( 'Protection active', 'goconsent' ), 'inactive' => __( 'Not active', 'goconsent' ), 'home' => __( 'Home', 'goconsent' ), 'recommended' => __( 'Recommended', 'goconsent' ), 'pro' => __( 'Pro', 'goconsent' ), 'proOnly' => __( 'Available in GoConsent Pro', 'goconsent' ), 'proIncluded' => __( 'Pro feature, included on this site', 'goconsent' ), 'stMissing' => __( 'Not created', 'goconsent' ), 'stCurrent' => __( 'Up to date', 'goconsent' ), 'stOutdated' => __( 'Update available', 'goconsent' ), 'stCustom' => __( 'Your own text', 'goconsent' ), 'stDraft' => __( 'Draft', 'goconsent' ), 'create' => __( 'Create page', 'goconsent' ), 'update' => __( 'Update', 'goconsent' ), 'replace' => __( 'Replace text…', 'goconsent' ), 'preview' => __( 'Preview', 'goconsent' ), 'view' => __( 'View', 'goconsent' ), 'edit' => __( 'Edit', 'goconsent' ), 'publish' => __( 'Publish', 'goconsent' ), 'undoPage' => __( 'Undo last change', 'goconsent' ), /* translators: %d: number of open privacy policy items. */ 'policyIssues' => __( '%d wording items open on the Overview', 'goconsent' ), /* translators: %s: date. */ 'modified' => __( 'Last modified %s', 'goconsent' ), 'builtWith' => __( 'Built with', 'goconsent' ), 'fmt_blocks' => __( 'Block editor', 'goconsent' ), 'fmt_classic' => __( 'Classic editor', 'goconsent' ), 'fmt_elementor' => __( 'Elementor', 'goconsent' ), 'fmt_beaver' => __( 'Beaver Builder', 'goconsent' ), 'unsupported' => __( 'GoConsent can’t edit this builder. Use Preview and copy the text.', 'goconsent' ), 'pvCreate' => __( 'GoConsent will create this page as a draft with the text below. Nothing is published until you click Publish.', 'goconsent' ), 'pvReplace' => __( 'This page has its own text. GoConsent will replace it with the text below. The current version is kept, so you can undo it.', 'goconsent' ), 'pvMerge' => __( 'GoConsent will update only its own sections. Sections you edited are kept. You can undo it.', 'goconsent' ), 'pvNone' => __( 'This page already matches the suggested text.', 'goconsent' ), 'pvAdded' => __( 'New sections', 'goconsent' ), 'pvUpdated' => __( 'Updated sections', 'goconsent' ), 'pvKept' => __( 'Kept your edits', 'goconsent' ), 'pvRemoved' => __( 'Removed (no longer needed)', 'goconsent' ), 'copyHtml' => __( 'Copy HTML', 'goconsent' ), 'htmlCopied' => __( 'HTML copied. Paste it into a Text or HTML block.', 'goconsent' ), 'codeSite' => __( 'Your site’s code', 'goconsent' ), 'codeOurs' => __( 'Added by GoConsent', 'goconsent' ), 'codeFound' => __( 'Found', 'goconsent' ), 'codeMissing' => __( 'No contact form page found; links go to your privacy email', 'goconsent' ), ), ) ); } /** * Render the app. */ public function render() { if ( ! current_user_can( 'manage_options' ) ) { return; } $plugin = $this->plugin; include GOCONSENT_DIR . 'templates/admin/page.php'; } /** * Notices on other admin screens: accept terms; critical issues. */ public function notices() { if ( ! current_user_can( 'manage_options' ) ) { return; } // Only on the Dashboard and Plugins screens, never across the whole admin. $screen = get_current_screen(); if ( ! $screen || ! in_array( $screen->id, array( 'dashboard', 'plugins' ), true ) ) { return; } $url = admin_url( 'admin.php?page=' . self::SLUG ); if ( ! $this->plugin->terms->accepted() ) { printf( '
%1$s %2$s %4$s
%1$s %2$s %4$s
' . esc_html__( 'This site uses GoConsent to ask for your consent before analytics, advertising and other third-party tools load.', 'goconsent' ) . '
'; $text .= '' . esc_html__( 'Your choice is stored in a first-party cookie named "goconsent" for 12 months. Each Accept, Reject or Save is also recorded on this site as proof of consent: a random consent ID, the time, your choices, whether your browser sent a Global Privacy Control signal, the policy version, the page, your IP address with the last part removed, and your browser’s user agent. These records are kept for 24 months and are not shared.', 'goconsent' ) . '
'; $text .= '' . esc_html__( 'Visit statistics are counted on this site without cookies. Your IP address is used only to create a daily anonymous count and is not stored.', 'goconsent' ) . '
'; $text .= '' . esc_html__( 'Maps and videos from other companies load only after you click to load them. Google Fonts are served from this site, so your browser does not contact Google for them.', 'goconsent' ) . '
'; wp_add_privacy_policy_content( 'GoConsent', wp_kses_post( $text ) ); } /** * "Settings" link on the Plugins screen. * * @param array $links Links. * @return array */ public function action_links( $links ) { array_unshift( $links, '' . esc_html__( 'Settings', 'goconsent' ) . '' ); return $links; } }