'array', 'sanitize_callback' => array( Settings::class, 'sanitize' ), 'default' => Settings::defaults(), ) ); } /** * Purges page caches when fixes change. * * @param mixed $old_value Previous settings. * @param mixed $new_value New settings. */ public static function settings_changed( $old_value, $new_value ) { $old_fixes = is_array( $old_value ) && isset( $old_value['fixes'] ) ? $old_value['fixes'] : array(); $new_fixes = is_array( $new_value ) && isset( $new_value['fixes'] ) ? $new_value['fixes'] : array(); if ( $old_fixes !== $new_fixes ) { Cache::purge(); delete_transient( 'fixlight_summary' ); } } /** * The first save on a new site creates the option instead of updating it; until * then the defaults were in effect. * * @param string $option Option name. * @param mixed $new_value New settings. */ public static function settings_added( $option, $new_value ) { self::settings_changed( Settings::defaults(), $new_value ); } /** * "Overview" link on the Plugins screen. * * @param string[] $links Links. * @return string[] */ public static function action_links( $links ) { array_unshift( $links, '' . esc_html__( 'Overview', 'fixlight' ) . '' ); return $links; } /** * Admin assets, only on Fixlight screens. * * @param string $hook Screen hook. */ public static function enqueue( $hook ) { if ( false === strpos( $hook, self::SLUG ) ) { return; } wp_enqueue_style( 'fixlight-admin', FIXLIGHT_URL . 'assets/css/admin.css', array(), Plugin::asset_version( 'assets/css/admin.css' ) ); wp_enqueue_script( 'fixlight-admin', FIXLIGHT_URL . 'assets/js/screens.js', array( 'wp-api-fetch', 'wp-i18n' ), Plugin::asset_version( 'assets/js/screens.js' ), true ); wp_set_script_translations( 'fixlight-admin', 'fixlight' ); wp_localize_script( 'fixlight-admin', 'fixlightAdmin', array( 'adminOrigin' => Front::origin( admin_url() ), 'homeOrigin' => Front::origin( home_url() ), ) ); } /** * Shared page header with the screen title and tabs. * * @param string $current Current page slug. * @param string $title Screen title. */ public static function header( $current, $title ) { $tabs = array( self::SLUG => __( 'Overview', 'fixlight' ), self::SLUG . '-fixes' => __( 'Fixes', 'fixlight' ), self::SLUG . '-images' => __( 'Images', 'fixlight' ), self::SLUG . '-settings' => __( 'Settings', 'fixlight' ), ); /** * Filters the tabs at the top of Fixlight's screens (page slug => label). * * @param array $tabs Tabs. */ $tabs = (array) apply_filters( 'fixlight_admin_tabs', $tabs ); echo '
' . esc_html( $overlay_notice ) . '
' . esc_html( $text ) . '
'; } /** * One issue in the Overview list. * * @param array $rule Aggregated rule. * @param array $page_titles Page id => url, title. */ private static function issue( array $rule, array $page_titles ) { $fixed = max( 0, $rule['before'] - $rule['after'] ); if ( 0 === $rule['after'] ) { $status = 'fixed'; $status_label = __( 'Fixed by Fixlight', 'fixlight' ); } elseif ( $fixed > 0 ) { $status = 'partial'; $status_label = __( 'Partly fixed', 'fixlight' ); } else { $status = 'open'; $status_label = __( 'Needs you', 'fixlight' ); } $impact_labels = array( 'critical' => __( 'Critical', 'fixlight' ), 'serious' => __( 'Serious', 'fixlight' ), 'moderate' => __( 'Moderate', 'fixlight' ), 'minor' => __( 'Minor', 'fixlight' ), ); $impact = isset( $impact_labels[ $rule['impact'] ] ) ? $impact_labels[ $rule['impact'] ] : $rule['impact']; ?>
|
|
|
>