on_successful', 'message' => sprintf( // translators: %1$s = Item URL or item type. __( 'Mobile Critical CSS for %s generated.', 'rocket' ), ( 'custom' === $item_type ) ? $item_url : $item_type ), ]; } // Send the current status of job. return [ 'code' => 'cpcss_generation_successful', 'message' => sprintf( // translators: %1$s = Item URL or item type. __( 'Critical CSS for %s generated.', 'rocket' ), ( 'custom' === $item_type ) ? $item_url : $item_type ), ]; } /** * Process the login for CPCSS deletion. * * @param string $item_path Path for item to delete CPCSS code. * * @return array|WP_Error */ public function process_delete( $item_path ) { $deleted = $this->data_manager->delete_cpcss( $item_path ); if ( is_wp_error( $deleted ) ) { return $deleted; } return [ 'code' => 'success', 'message' => __( 'Critical CSS file deleted successfully.', 'rocket' ), ]; } /** * Process timeout action for CPCSS generation. * * @since 3.6 * * @param string $item_url URL for item to be used in error messages. * @param bool $is_mobile Bool identifier for is_mobile CPCSS generation. * @param string $item_type Optional. Type for this item if it's custom or specific type. Default: custom. * @return WP_Error */ private function process_timeout( $item_url, $is_mobile = false, $item_type = 'custom' ) { $this->data_manager->delete_cache_job_id( $item_url, $is_mobile ); if ( $is_mobile ) { return new WP_Error( 'cpcss_generation_timeout', sprintf( // translators: %1$s = Item URL or item type. __( 'Mobile Critical CSS for %1$s timeout. Please retry a little later.', 'rocket' ), ( 'custom' === $item_type ) ? $item_url : $item_type ), [ 'status' => 400, ] ); } return new WP_Error( 'cpcss_generation_timeout', sprintf( // translators: %1$s = Item URL or item type. __( 'Critical CSS for %1$s timeout. Please retry a little later.', 'rocket' ), ( 'custom' === $item_type ) ? $item_url : $item_type ), [ 'status' => 400, ] ); } }