' . esc_html__( 'Settings', 'cpod-kit' ) . '', '' . esc_html__( 'Modules', 'cpod-kit' ) . '' ); return $links; } /** Explain modules paused because the old plugin is still active. */ public function paused_notice() { // Only on the Plugins screen and the plugin's own screens. if ( ! current_user_can( 'activate_plugins' ) || ( 'plugins.php' !== ( isset( $GLOBALS['pagenow'] ) ? $GLOBALS['pagenow'] : '' ) && 0 !== strpos( TopBar::current_page(), 'cpod' ) ) ) { return; } $paused = array(); foreach ( Modules::all() as $id => $module ) { if ( 'paused' === Modules::state( $id ) ) { $paused[ Modules::conflict( $id ) ][] = $module['name']; } } foreach ( $paused as $plugin => $names ) { echo '

' . esc_html( sprintf( /* translators: 1: old plugin name, 2: module names */ __( '%1$s is still active, so cPOD Kit has paused: %2$s. Deactivate %1$s to use cPOD Kit instead; its settings are copied and never changed.', 'cpod-kit' ), $plugin, implode( ', ', $names ) ) ) . ' ' . esc_html__( 'Plugins', 'cpod-kit' ) . '

'; } } /** Badge text and CSS class of a module state. */ public static function state_badge( $id ) { switch ( Modules::state( $id ) ) { case 'running': return array( __( 'On', 'cpod-kit' ), 'is-on' ); case 'paused': /* translators: %s: old plugin name */ return array( sprintf( __( 'Paused: %s is active', 'cpod-kit' ), Modules::conflict( $id ) ), 'is-paused' ); case 'blocked': $names = array(); foreach ( Modules::missing_requirements( $id ) as $required ) { $module = Modules::get( $required ); $names[] = $module ? $module['name'] : $required; } /* translators: %s: module names */ return array( sprintf( __( 'Needs %s', 'cpod-kit' ), implode( ', ', $names ) ), 'is-paused' ); case 'locked': /** * Badge of a module held back by the cpod_module_can_boot filter. * * @param array $badge array( text, CSS class ). * @param string $id Module id. */ return (array) apply_filters( 'cpod_module_locked_badge', array( __( 'Not running', 'cpod-kit' ), 'is-paused' ), $id ); default: return array( __( 'Off', 'cpod-kit' ), 'is-off' ); } } public function render_dashboard() { $all = Modules::all(); $running = 0; $paused = array(); foreach ( $all as $id => $module ) { if ( Modules::is_running( $id ) ) { ++$running; } elseif ( in_array( Modules::state( $id ), array( 'paused', 'blocked', 'locked' ), true ) ) { $paused[ $id ] = $module['name']; } } $total = count( $all ); $percent = $total ? round( $running / $total * 100 ) : 0; $manage = current_user_can( 'manage_woocommerce' ); ?>

cPOD Kit


$module ) : list( $badge, $class ) = self::state_badge( $id ); $links = Modules::is_running( $id ) ? (array) Modules::value( $module, 'links' ) : array(); ?>