dd(Language::getInstance()->getLanguages())); add_action('init', function () { new RestrictionController(); new MessageController(); new AppearanceController(); new AdvancedController(); new AccessController(); new ContentController(); new ToolsController(); new PostController(); new Toolbar(); new TroubleShootingController(); }); add_action('admin_notices', [$this, 'notices']); $basename = plugin_basename(AGE_GATE_PATH . 'age-gate.php'); add_filter("plugin_action_links_" . $basename, [$this, 'actionLinks']); add_filter('plugin_row_meta', [$this, 'websiteLink'], 10, 2); } public function notices() { global $pagenow, $plugin_page; // $req = wp_remote_get(rest_url('/age-gate/v3/check'), [ // 'sslverify' => false // ]); if (!is_php_version_compatible('7.4') && strpos(sanitize_text_field($plugin_page ?: ''), 'age-gate') !== false) { echo '

' . esc_html__('Age Gate requires a minimum PHP version of 7.4 which your system does not have. You may experience some issues.', 'age-gate') . '

'; } // if (wp_remote_retrieve_response_code($req) !== 200 && current_user_can(Constants::RESTRICTIONS) && strpos(sanitize_text_field($plugin_page ?: ''), 'age-gate-advanced') !== false) { // echo '

' . esc_html__('Age Gate is having trouble contacting the Wordpress REST API. Is something blocking it?', 'age-gate') . '

'; // } // is it an age gate page? // TODO: replace with notice class. Why is it like this? if ($pagenow === 'admin.php' && isset($_GET['m']) && strpos((sanitize_text_field($plugin_page ?: '')), 'age-gate') === 0) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended switch ((int) $_GET['m']) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended case 1: $status = 'success'; $message = esc_html__('Settings saved', 'age-gate'); break; case 0: $status = 'error'; $message = esc_html__('Something went wrong', 'age-gate'); break; } echo sprintf('

%s

', esc_attr($status), esc_html($message)); } if (Settings::getInstance()->disableAgeGate && current_user_can(Constants::TOOLS)) { echo '

' . esc_html__('Age Gate is currently disabled in the Tools section and will not show for any users', 'age-gate') . '

'; } foreach (Notice::get() ?? [] as $notice) { echo '

' . esc_html($notice['message']) . '

'; } if (is_plugin_active('age-gate-user-registration/age-gate-user-registration.php')) { $data = get_plugin_data(WP_PLUGIN_DIR . '/age-gate-user-registration/age-gate-user-registration.php'); if ($data['Version'] ?? false) { if (version_compare($data['Version'], '1.0.0', '<')) { /* translators: 1: Age Gate User Registration version. 2: Aga gate version */ echo '

' . esc_html(sprintf(__('Your version of Age Gate User Registration (%1$s) is not compatible with Age Gate %2$s. Please download a supported version from our website', 'age-gate'), $data['Version'], AGE_GATE_VERSION)) . '

'; } } } } public function actionLinks($links) { $settings = sprintf('%s', admin_url('admin.php?page=age-gate'), esc_html__('Settings', 'age-gate')); $donate = '' . esc_html__('Donate', 'age-gate') . ''; array_unshift($links, $settings); array_push($links, $donate); return $links; } public function websiteLink($meta, $file) { $basename = plugin_basename(AGE_GATE_PATH) . '/age-gate.php'; if ($basename === $file) { $meta[] = sprintf( '%s', 'https://agegate.io/docs', esc_html__('Documentation', 'age-gate') ); $meta[] = sprintf( '%s', 'https://agegate.io/release-notes', esc_html__('What’s new?', 'age-gate') ); } return $meta; } }