] * : table or json. * --- * default: table * options: * - table * - json * --- * * ## EXAMPLES * * wp fixlight status * wp fixlight status --format=json * * @param array $args Positional arguments. * @param array $assoc_args Options. */ public function status( $args, $assoc_args ) { $summary = Store::summary(); if ( isset( $assoc_args['format'] ) && 'json' === $assoc_args['format'] ) { unset( $summary['page_titles'], $summary['page_list'] ); \WP_CLI::line( (string) wp_json_encode( $summary, JSON_PRETTY_PRINT ) ); return; } if ( null === $summary['score_after'] ) { \WP_CLI::line( __( 'No pages checked yet. Run: wp fixlight scan', 'fixlight' ) ); return; } /* translators: 1: score without Fixlight, 2: score with Fixlight, 3: pages checked. */ \WP_CLI::line( sprintf( _n( 'Score: %1$d without Fixlight, %2$d with Fixlight (%3$d page).', 'Score: %1$d without Fixlight, %2$d with Fixlight (%3$d pages).', $summary['pages_scored'], 'fixlight' ), $summary['score_before'], $summary['score_after'], $summary['pages_scored'] ) ); /* translators: 1: issues fixed, 2: issues left. */ \WP_CLI::line( sprintf( __( 'Issues fixed automatically: %1$d. Issues that need you: %2$d.', 'fixlight' ), $summary['fixed'], $summary['remaining'] ) ); $rows = array(); foreach ( $summary['rules'] as $rule ) { $rows[] = array( 'rule' => $rule['rule'], 'issue' => $rule['title'], 'impact' => $rule['impact'], 'wcag' => $rule['wcag'], 'fixed' => max( 0, $rule['before'] - $rule['after'] ), 'left' => $rule['after'], 'pages' => $rule['pages_after'], ); } \WP_CLI\Utils\format_items( 'table', $rows, array( 'rule', 'issue', 'impact', 'wcag', 'fixed', 'left', 'pages' ) ); } /** * Checks every published page on this server (fixes off and on). * * ## EXAMPLES * * wp fixlight scan * * @param array $args Positional arguments. * @param array $assoc_args Options. */ public function scan( $args, $assoc_args ) { $state = Background::start( false ); $progress = \WP_CLI\Utils\make_progress_bar( __( 'Checking pages', 'fixlight' ), $state['total'] ); $done = 0; do { $state = Background::run_chunk( 30, 10 ); if ( ! empty( $state['busy'] ) ) { sleep( 3 ); // A background batch is running; wait for it. } for ( $i = $done; $i < $state['done']; $i++ ) { $progress->tick(); } $done = $state['done']; } while ( $state['running'] ); $progress->finish(); if ( $state['errors'] ) { /* translators: %d: number of pages. */ \WP_CLI::warning( sprintf( _n( '%d page could not be fetched. See the Overview screen for details.', '%d pages could not be fetched. See the Overview screen for details.', $state['errors'], 'fixlight' ), $state['errors'] ) ); } $this->status( array(), array() ); } /** * Lists accessibility widgets (overlays) Fixlight knows on this site, and can deactivate their WordPress plugins. * * Only the widget's own plugin is deactivated; its subscription with the maker is not cancelled, and scripts * pasted into the theme are only reported. * * ## OPTIONS * * [--deactivate] * : Deactivate the plugins of the widgets found. * * [--yes] * : Don't ask before deactivating. * * ## EXAMPLES * * wp fixlight overlays * wp fixlight overlays --deactivate * * @param array $args Positional arguments. * @param array $assoc_args Options. */ public function overlays( $args, $assoc_args ) { Overlays::check_home(); $found = Overlays::found(); if ( ! $found ) { \WP_CLI::success( __( 'No accessibility widget Fixlight knows was found.', 'fixlight' ) ); return; } $rows = array(); foreach ( $found as $id => $vendor ) { $rows[] = array( 'widget' => $vendor['name'], 'plugins' => $vendor['plugins'] ? implode( ', ', $vendor['plugins'] ) : '-', 'script' => $vendor['script'] ? __( 'on the home page, outside a plugin', 'fixlight' ) : '-', 'guide' => Overlays::GUIDE . $id . '/', ); } \WP_CLI\Utils\format_items( 'table', $rows, array( 'widget', 'plugins', 'script', 'guide' ) ); if ( empty( $assoc_args['deactivate'] ) ) { return; } $files = array(); foreach ( $found as $vendor ) { $files = array_merge( $files, $vendor['plugins'] ); } if ( ! $files ) { \WP_CLI::warning( __( 'No widget plugin to deactivate. Remove pasted scripts by hand; see the guide.', 'fixlight' ) ); return; } /* translators: %s: plugin files. */ \WP_CLI::confirm( sprintf( __( 'Deactivate %s? Subscriptions with the makers are not cancelled.', 'fixlight' ), implode( ', ', $files ) ), $assoc_args ); deactivate_plugins( $files ); Overlays::check_home(); /* translators: %d: number of plugins. */ \WP_CLI::success( sprintf( _n( 'Deactivated %d plugin.', 'Deactivated %d plugins.', count( $files ), 'fixlight' ), count( $files ) ) ); } }