*/ protected function input_properties(): array { return array(); } /** * @since 0.0.34 * @return array */ protected function required_input(): array { return array(); } /** * @since 0.0.34 * @return array */ protected function output_properties(): array { return array( 'site_locale' => array( 'type' => 'string' ), 'languages_dir' => array( 'type' => 'string' ), 'languages_dir_exists' => array( 'type' => 'boolean' ), 'languages_dir_writable' => array( 'type' => 'boolean' ), 'uses_php_cache' => array( 'type' => 'boolean', 'description' => __( 'True on WordPress 6.5+, where the .l10n.php cache is read in preference to the MO file.', 'acrossai-abilities-manager' ), ), 'bundle_count' => array( 'type' => 'integer' ), 'loco_version' => array( 'type' => 'string' ), ); } /** * @since 0.0.34 * @return array */ protected function annotations(): array { return array( 'readonly' => true, 'destructive' => false, 'idempotent' => true ); } /** * @since 0.0.34 * @param array $input Input. * @return array|WP_Error */ protected function run( array $input ) { $dir = defined( 'WP_LANG_DIR' ) ? (string) WP_LANG_DIR : ''; $exists = '' !== $dir && is_dir( $dir ); $bundles = Bundle_Repository::all(); return array( 'site_locale' => (string) get_locale(), 'languages_dir' => $dir, 'languages_dir_exists' => $exists, // A missing directory is not a failure: Loco creates it on first save. What matters is // whether the PARENT can be written, which is what decides if that save can succeed. 'languages_dir_writable' => $exists ? is_writable( $dir ) : ( '' !== $dir && is_writable( dirname( $dir ) ) ), 'uses_php_cache' => Loco_Guard::uses_php_cache(), 'bundle_count' => is_wp_error( $bundles ) ? 0 : count( $bundles ), // A FUNCTION, not a constant, despite the lower-case name. `defined()` is always false for // it, so this field reported an empty version on every site until it was measured. 'loco_version' => function_exists( 'loco_plugin_version' ) ? (string) loco_plugin_version() : '', ); } }