group( 'site', array( 'label' => 'Site settings', 'description' => 'Read the core site settings, and check that AI apps can connect.', 'detected' => true, 'plugins' => array( 'WordPress' => get_bloginfo( 'version' ) ), ) ); self::settings( $r ); } /* ------------------------------------------------------------------ settings */ /** * Settings, Customizer, CSS. * * @param Registry $r Registry. */ private static function settings( Registry $r ): void { $r->add( array( 'name' => 'settings_get', 'group' => 'site', 'title' => 'Get site settings', 'description' => 'Read the main WordPress settings (site title, tagline, addresses, language, time and date formats, front page, reading, comments and permalinks) and, with WooCommerce, the store currency and country. Read only. Other plugins\' options are not included.', 'cap' => 'manage_options', 'input' => array( 'properties' => array( 'names' => array( 'type' => 'array', 'items' => array( 'type' => 'string' ) ) ) ), 'run' => static function ( array $a ) { $out = array(); foreach ( self::readable() as $name => $group ) { if ( ! empty( $a['names'] ) && ! in_array( $name, $a['names'], true ) ) { continue; } $out[ $name ] = array( 'value' => get_option( $name ), 'group' => $group ); } return array( 'settings' => $out ); }, ) ); } /** * Options settings_get may show: core basics, plus store basics with WooCommerce. * * @return array Option name => group. */ private static function readable(): array { $out = array(); foreach ( array( 'blogname', 'blogdescription', 'siteurl', 'home', 'WPLANG', 'timezone_string', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'site_icon' ) as $name ) { $out[ $name ] = 'general'; } foreach ( array( 'posts_per_page', 'show_on_front', 'page_on_front', 'page_for_posts', 'blog_public' ) as $name ) { $out[ $name ] = 'reading'; } $out['default_comment_status'] = 'discussion'; $out['permalink_structure'] = 'permalink'; if ( function_exists( 'WC' ) ) { $out['woocommerce_currency'] = 'woocommerce'; $out['woocommerce_default_country'] = 'woocommerce'; } return $out; } }